-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
62 lines (54 loc) · 1.64 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import plugin from 'tailwindcss/plugin.js';
const buildSelector = (modifier: string | null) => `.member${modifier ? `\\/${modifier}` : ''}`;
export default plugin(({ matchVariant }) => {
matchVariant(
'member',
(rawValue, { modifier }) => {
const value = rawValue || '&';
const selector = buildSelector(modifier);
return `&:has(${selector}:is(${value.replaceAll('&', selector)})) { & }`;
},
{
values: {
// Default
DEFAULT: '&',
// Positional
first: '&:first-child',
last: '&:last-child',
only: '&:only-child',
odd: '&:nth-child(odd)',
even: '&:nth-child(even)',
'first-of-type': '&:first-of-type',
'last-of-type': '&:last-of-type',
'only-of-type': '&:only-of-type',
// State
visited: '&:visited',
target: '&:target',
open: '&:is([open], :popover-open)',
// Forms
default: '&:default',
checked: '&:checked',
indeterminate: '&:indeterminate',
'placeholder-shown': '&:placeholder-shown',
autofill: '&:autofill',
optional: '&:optional',
required: '&:required',
valid: '&:valid',
invalid: '&:invalid',
'in-range': '&:in-range',
'out-of-range': '&:out-of-range',
'read-only': '&:read-only',
// Content
empty: '&:empty',
// Interactive
'focus-within': '&:focus-within',
hover: '&:hover',
focus: '&:focus',
'focus-visible': '&:focus-visible',
active: '&:active',
enabled: '&:enabled',
disabled: '&:disabled',
},
}
);
});