File tree Expand file tree Collapse file tree 6 files changed +64
-0
lines changed Expand file tree Collapse file tree 6 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## [ Unreleased]
99
10+ ### Added
11+
12+ - _ Experimental_ : Add ` user-valid ` and ` user-invalid ` variants ([ #12370 ] ( https://github.com/tailwindlabs/tailwindcss/pull/12370 ) )
13+
1014### Fixed
1115
1216- Export ` tailwindcss/lib/util/flattenColorPalette.js ` for backward compatibility ([ #16411 ] ( https://github.com/tailwindlabs/tailwindcss/pull/16411 ) )
Original file line number Diff line number Diff line change @@ -11,5 +11,6 @@ export default defineConfig({
1111 } ,
1212 define : {
1313 'process.env.NODE_ENV' : '"production"' ,
14+ 'process.env.FEATURES_ENV' : '"stable"' ,
1415 } ,
1516} )
Original file line number Diff line number Diff line change @@ -8405,6 +8405,8 @@ exports[`getVariants 1`] = `
84058405 " required" ,
84068406 " valid" ,
84078407 " invalid" ,
8408+ " user-valid" ,
8409+ " user-invalid" ,
84088410 " in-range" ,
84098411 " out-of-range" ,
84108412 " read-only" ,
@@ -8474,6 +8476,8 @@ exports[`getVariants 1`] = `
84748476 " required" ,
84758477 " valid" ,
84768478 " invalid" ,
8479+ " user-valid" ,
8480+ " user-invalid" ,
84778481 " in-range" ,
84788482 " out-of-range" ,
84798483 " read-only" ,
@@ -8527,6 +8531,8 @@ exports[`getVariants 1`] = `
85278531 " required" ,
85288532 " valid" ,
85298533 " invalid" ,
8534+ " user-valid" ,
8535+ " user-invalid" ,
85308536 " in-range" ,
85318537 " out-of-range" ,
85328538 " read-only" ,
@@ -8754,6 +8760,20 @@ exports[`getVariants 1`] = `
87548760 " selectors" : [Function ],
87558761 " values" : [],
87568762 } ,
8763+ {
8764+ " hasDash" : true ,
8765+ " isArbitrary" : false ,
8766+ " name" : " user-valid" ,
8767+ " selectors" : [Function ],
8768+ " values" : [],
8769+ } ,
8770+ {
8771+ " hasDash" : true ,
8772+ " isArbitrary" : false ,
8773+ " name" : " user-invalid" ,
8774+ " selectors" : [Function ],
8775+ " values" : [],
8776+ } ,
87578777 {
87588778 " hasDash" : true ,
87598779 " isArbitrary" : false ,
@@ -8867,6 +8887,8 @@ exports[`getVariants 1`] = `
88678887 " required" ,
88688888 " valid" ,
88698889 " invalid" ,
8890+ " user-valid" ,
8891+ " user-invalid" ,
88708892 " in-range" ,
88718893 " out-of-range" ,
88728894 " read-only" ,
@@ -8920,6 +8942,8 @@ exports[`getVariants 1`] = `
89208942 " required" ,
89218943 " valid" ,
89228944 " invalid" ,
8945+ " user-valid" ,
8946+ " user-invalid" ,
89238947 " in-range" ,
89248948 " out-of-range" ,
89258949 " read-only" ,
Original file line number Diff line number Diff line change 11export const enableRemoveUnusedThemeVariables = false
2+
3+ export const enableUserValid = process . env . FEATURES_ENV !== 'stable'
Original file line number Diff line number Diff line change @@ -325,6 +325,34 @@ test('invalid', async () => {
325325 expect ( await run ( [ 'invalid/foo:flex' ] ) ) . toEqual ( '' )
326326} )
327327
328+ test ( 'user-valid' , async ( ) => {
329+ expect ( await run ( [ 'user-valid:flex' , 'group-user-valid:flex' , 'peer-user-valid:flex' ] ) )
330+ . toMatchInlineSnapshot ( `
331+ ".group-user-valid\\:flex:is(:where(.group):user-valid *), .peer-user-valid\\:flex:is(:where(.peer):user-valid ~ *) {
332+ display: flex;
333+ }
334+
335+ .user-valid\\:flex:user-valid {
336+ display: flex;
337+ }"
338+ ` )
339+ expect ( await run ( [ 'user-valid/foo:flex' ] ) ) . toEqual ( '' )
340+ } )
341+
342+ test ( 'user-invalid' , async ( ) => {
343+ expect ( await run ( [ 'user-invalid:flex' , 'group-user-invalid:flex' , 'peer-user-invalid:flex' ] ) )
344+ . toMatchInlineSnapshot ( `
345+ ".group-user-invalid\\:flex:is(:where(.group):user-invalid *), .peer-user-invalid\\:flex:is(:where(.peer):user-invalid ~ *) {
346+ display: flex;
347+ }
348+
349+ .user-invalid\\:flex:user-invalid {
350+ display: flex;
351+ }"
352+ ` )
353+ expect ( await run ( [ 'invalid/foo:flex' ] ) ) . toEqual ( '' )
354+ } )
355+
328356test ( 'in-range' , async ( ) => {
329357 expect ( await run ( [ 'in-range:flex' , 'group-in-range:flex' , 'peer-in-range:flex' ] ) )
330358 . toMatchInlineSnapshot ( `
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 type StyleRule ,
1313} from './ast'
1414import { type Variant } from './candidate'
15+ import { enableUserValid } from './feature-flags'
1516import type { Theme } from './theme'
1617import { compareBreakpoints } from './utils/compare-breakpoints'
1718import { DefaultMap } from './utils/default-map'
@@ -692,6 +693,10 @@ export function createVariants(theme: Theme): Variants {
692693 staticVariant ( 'required' , [ '&:required' ] )
693694 staticVariant ( 'valid' , [ '&:valid' ] )
694695 staticVariant ( 'invalid' , [ '&:invalid' ] )
696+ if ( enableUserValid ) {
697+ staticVariant ( 'user-valid' , [ '&:user-valid' ] )
698+ staticVariant ( 'user-invalid' , [ '&:user-invalid' ] )
699+ }
695700 staticVariant ( 'in-range' , [ '&:in-range' ] )
696701 staticVariant ( 'out-of-range' , [ '&:out-of-range' ] )
697702 staticVariant ( 'read-only' , [ '&:read-only' ] )
You can’t perform that action at this time.
0 commit comments