@cwcss/crosswind 0.1.5 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +52 -0
- package/dist/bin/cli.js +14615 -0
- package/dist/build.d.ts +24 -0
- package/dist/config.d.ts +5 -0
- package/dist/generator.d.ts +31 -0
- package/dist/index.d.ts +10 -0
- package/dist/parser.d.ts +42 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/preflight-forms.d.ts +5 -0
- package/dist/preflight.d.ts +2 -0
- package/dist/rules-advanced.d.ts +27 -0
- package/dist/rules-effects.d.ts +25 -0
- package/dist/rules-forms.d.ts +7 -0
- package/dist/rules-grid.d.ts +13 -0
- package/dist/rules-interactivity.d.ts +41 -0
- package/dist/rules-layout.d.ts +26 -0
- package/dist/rules-transforms.d.ts +33 -0
- package/dist/rules-typography.d.ts +41 -0
- package/dist/rules.d.ts +39 -0
- package/dist/scanner.d.ts +18 -0
- package/dist/src/index.js +12848 -0
- package/dist/transformer-compile-class.d.ts +37 -0
- package/{src/types.ts → dist/types.d.ts} +17 -86
- package/package.json +2 -16
- package/PLUGIN.md +0 -235
- package/benchmark/framework-comparison.bench.ts +0 -850
- package/bin/cli.ts +0 -365
- package/bin/crosswind +0 -0
- package/bin/headwind +0 -0
- package/build.ts +0 -8
- package/crosswind.config.ts +0 -9
- package/example/comprehensive.html +0 -70
- package/example/index.html +0 -21
- package/example/output.css +0 -236
- package/examples/plugin/README.md +0 -112
- package/examples/plugin/build.ts +0 -32
- package/examples/plugin/src/index.html +0 -34
- package/examples/plugin/src/index.ts +0 -7
- package/headwind +0 -2
- package/src/build.ts +0 -101
- package/src/config.ts +0 -529
- package/src/generator.ts +0 -2173
- package/src/index.ts +0 -10
- package/src/parser.ts +0 -1471
- package/src/plugin.ts +0 -118
- package/src/preflight-forms.ts +0 -229
- package/src/preflight.ts +0 -388
- package/src/rules-advanced.ts +0 -477
- package/src/rules-effects.ts +0 -461
- package/src/rules-forms.ts +0 -103
- package/src/rules-grid.ts +0 -241
- package/src/rules-interactivity.ts +0 -525
- package/src/rules-layout.ts +0 -385
- package/src/rules-transforms.ts +0 -412
- package/src/rules-typography.ts +0 -486
- package/src/rules.ts +0 -809
- package/src/scanner.ts +0 -84
- package/src/transformer-compile-class.ts +0 -275
- package/test/advanced-features.test.ts +0 -911
- package/test/arbitrary.test.ts +0 -396
- package/test/attributify.test.ts +0 -592
- package/test/bracket-syntax.test.ts +0 -1133
- package/test/build.test.ts +0 -99
- package/test/colors.test.ts +0 -934
- package/test/flexbox.test.ts +0 -669
- package/test/generator.test.ts +0 -597
- package/test/grid.test.ts +0 -584
- package/test/layout.test.ts +0 -404
- package/test/modifiers.test.ts +0 -417
- package/test/parser.test.ts +0 -564
- package/test/performance-regression.test.ts +0 -376
- package/test/performance.test.ts +0 -568
- package/test/plugin.test.ts +0 -160
- package/test/scanner.test.ts +0 -94
- package/test/sizing.test.ts +0 -481
- package/test/spacing.test.ts +0 -394
- package/test/transformer-compile-class.test.ts +0 -287
- package/test/transforms.test.ts +0 -448
- package/test/typography.test.ts +0 -632
- package/test/variants-form-states.test.ts +0 -225
- package/test/variants-group-peer.test.ts +0 -66
- package/test/variants-media.test.ts +0 -213
- package/test/variants-positional.test.ts +0 -58
- package/test/variants-pseudo-elements.test.ts +0 -47
- package/test/variants-state.test.ts +0 -62
- package/tsconfig.json +0 -18
|
@@ -1,525 +0,0 @@
|
|
|
1
|
-
import type { UtilityRule } from './rules'
|
|
2
|
-
|
|
3
|
-
// Filters, Tables, Interactivity, SVG, Accessibility utilities
|
|
4
|
-
|
|
5
|
-
// Filter utilities
|
|
6
|
-
export const filterRule: UtilityRule = (parsed) => {
|
|
7
|
-
// Handle filter-none
|
|
8
|
-
if (parsed.raw === 'filter-none') {
|
|
9
|
-
return { filter: 'none' }
|
|
10
|
-
}
|
|
11
|
-
if (parsed.utility === 'blur' && parsed.value) {
|
|
12
|
-
const blurMap: Record<string, string> = {
|
|
13
|
-
'none': '0',
|
|
14
|
-
'sm': '4px',
|
|
15
|
-
'DEFAULT': '8px',
|
|
16
|
-
'md': '12px',
|
|
17
|
-
'lg': '16px',
|
|
18
|
-
'xl': '24px',
|
|
19
|
-
'2xl': '40px',
|
|
20
|
-
'3xl': '64px',
|
|
21
|
-
}
|
|
22
|
-
return { filter: `blur(${blurMap[parsed.value] || parsed.value})` }
|
|
23
|
-
}
|
|
24
|
-
if (parsed.utility === 'brightness' && parsed.value) {
|
|
25
|
-
return { filter: `brightness(${Number(parsed.value) / 100})` }
|
|
26
|
-
}
|
|
27
|
-
if (parsed.utility === 'contrast' && parsed.value) {
|
|
28
|
-
return { filter: `contrast(${Number(parsed.value) / 100})` }
|
|
29
|
-
}
|
|
30
|
-
if (parsed.utility === 'grayscale' && parsed.value) {
|
|
31
|
-
return { filter: `grayscale(${Number(parsed.value) / 100})` }
|
|
32
|
-
}
|
|
33
|
-
if (parsed.utility === 'invert' && parsed.value) {
|
|
34
|
-
return { filter: `invert(${Number(parsed.value) / 100})` }
|
|
35
|
-
}
|
|
36
|
-
if (parsed.utility === 'saturate' && parsed.value) {
|
|
37
|
-
return { filter: `saturate(${Number(parsed.value) / 100})` }
|
|
38
|
-
}
|
|
39
|
-
if (parsed.utility === 'sepia' && parsed.value) {
|
|
40
|
-
return { filter: `sepia(${Number(parsed.value) / 100})` }
|
|
41
|
-
}
|
|
42
|
-
if (parsed.utility === 'hue-rotate' && parsed.value) {
|
|
43
|
-
return { filter: `hue-rotate(${parsed.value}deg)` }
|
|
44
|
-
}
|
|
45
|
-
if (parsed.utility === 'drop-shadow') {
|
|
46
|
-
const shadows: Record<string, string> = {
|
|
47
|
-
'sm': 'drop-shadow(0 1px 1px rgb(0 0 0 / 0.05))',
|
|
48
|
-
'DEFAULT': 'drop-shadow(0 1px 2px rgb(0 0 0 / 0.1)) drop-shadow(0 1px 1px rgb(0 0 0 / 0.06))',
|
|
49
|
-
'md': 'drop-shadow(0 4px 3px rgb(0 0 0 / 0.07)) drop-shadow(0 2px 2px rgb(0 0 0 / 0.06))',
|
|
50
|
-
'lg': 'drop-shadow(0 10px 8px rgb(0 0 0 / 0.04)) drop-shadow(0 4px 3px rgb(0 0 0 / 0.1))',
|
|
51
|
-
'xl': 'drop-shadow(0 20px 13px rgb(0 0 0 / 0.03)) drop-shadow(0 8px 5px rgb(0 0 0 / 0.08))',
|
|
52
|
-
'2xl': 'drop-shadow(0 25px 25px rgb(0 0 0 / 0.15))',
|
|
53
|
-
'none': 'drop-shadow(0 0 #0000)',
|
|
54
|
-
}
|
|
55
|
-
return { filter: parsed.value ? (shadows[parsed.value] || `drop-shadow(${parsed.value})`) : shadows.DEFAULT }
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const backdropFilterRule: UtilityRule = (parsed) => {
|
|
60
|
-
// Handle backdrop-filter-none
|
|
61
|
-
if (parsed.raw === 'backdrop-filter-none') {
|
|
62
|
-
return { 'backdrop-filter': 'none' }
|
|
63
|
-
}
|
|
64
|
-
if (parsed.utility === 'backdrop-blur' && parsed.value) {
|
|
65
|
-
return { 'backdrop-filter': `blur(${parsed.value}px)` }
|
|
66
|
-
}
|
|
67
|
-
if (parsed.utility === 'backdrop-brightness' && parsed.value) {
|
|
68
|
-
return { 'backdrop-filter': `brightness(${Number(parsed.value) / 100})` }
|
|
69
|
-
}
|
|
70
|
-
if (parsed.utility === 'backdrop-contrast' && parsed.value) {
|
|
71
|
-
return { 'backdrop-filter': `contrast(${Number(parsed.value) / 100})` }
|
|
72
|
-
}
|
|
73
|
-
if (parsed.utility === 'backdrop-grayscale' && parsed.value) {
|
|
74
|
-
return { 'backdrop-filter': `grayscale(${Number(parsed.value) / 100})` }
|
|
75
|
-
}
|
|
76
|
-
if (parsed.utility === 'backdrop-invert' && parsed.value) {
|
|
77
|
-
return { 'backdrop-filter': `invert(${Number(parsed.value) / 100})` }
|
|
78
|
-
}
|
|
79
|
-
if (parsed.utility === 'backdrop-saturate' && parsed.value) {
|
|
80
|
-
return { 'backdrop-filter': `saturate(${Number(parsed.value) / 100})` }
|
|
81
|
-
}
|
|
82
|
-
if (parsed.utility === 'backdrop-sepia' && parsed.value) {
|
|
83
|
-
return { 'backdrop-filter': `sepia(${Number(parsed.value) / 100})` }
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Table utilities
|
|
88
|
-
export const borderCollapseRule: UtilityRule = (parsed) => {
|
|
89
|
-
const values: Record<string, string> = {
|
|
90
|
-
'border-collapse': 'collapse',
|
|
91
|
-
'border-separate': 'separate',
|
|
92
|
-
}
|
|
93
|
-
return values[parsed.raw] ? { 'border-collapse': values[parsed.raw] } : undefined
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const borderSpacingRule: UtilityRule = (parsed, config) => {
|
|
97
|
-
if (parsed.utility === 'border-spacing' && parsed.value) {
|
|
98
|
-
const value = config.theme.spacing[parsed.value] || parsed.value
|
|
99
|
-
return { 'border-spacing': `${value} ${value}` }
|
|
100
|
-
}
|
|
101
|
-
if (parsed.utility === 'border-spacing-x' && parsed.value) {
|
|
102
|
-
const value = config.theme.spacing[parsed.value] || parsed.value
|
|
103
|
-
return { 'border-spacing': `${value} 0` }
|
|
104
|
-
}
|
|
105
|
-
if (parsed.utility === 'border-spacing-y' && parsed.value) {
|
|
106
|
-
const value = config.theme.spacing[parsed.value] || parsed.value
|
|
107
|
-
return { 'border-spacing': `0 ${value}` }
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export const tableLayoutRule: UtilityRule = (parsed) => {
|
|
112
|
-
if (parsed.utility === 'table' && parsed.value) {
|
|
113
|
-
const values: Record<string, string> = {
|
|
114
|
-
auto: 'auto',
|
|
115
|
-
fixed: 'fixed',
|
|
116
|
-
}
|
|
117
|
-
return values[parsed.value] ? { 'table-layout': values[parsed.value] } : undefined
|
|
118
|
-
}
|
|
119
|
-
return undefined
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export const captionSideRule: UtilityRule = (parsed) => {
|
|
123
|
-
const values: Record<string, string> = {
|
|
124
|
-
'caption-top': 'top',
|
|
125
|
-
'caption-bottom': 'bottom',
|
|
126
|
-
}
|
|
127
|
-
return values[parsed.raw] ? { 'caption-side': values[parsed.raw] } : undefined
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
// Interactivity utilities
|
|
131
|
-
export const accentColorRule: UtilityRule = (parsed, config) => {
|
|
132
|
-
if (parsed.utility === 'accent') {
|
|
133
|
-
if (parsed.value === 'auto') {
|
|
134
|
-
return { 'accent-color': 'auto' }
|
|
135
|
-
}
|
|
136
|
-
if (parsed.value) {
|
|
137
|
-
const parts = parsed.value.split('-')
|
|
138
|
-
if (parts.length === 2) {
|
|
139
|
-
const [colorName, shade] = parts
|
|
140
|
-
const colorValue = config.theme.colors[colorName]
|
|
141
|
-
if (typeof colorValue === 'object' && colorValue[shade]) {
|
|
142
|
-
return { 'accent-color': colorValue[shade] }
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export const appearanceRule: UtilityRule = (parsed) => {
|
|
150
|
-
const values: Record<string, string> = {
|
|
151
|
-
'appearance-none': 'none',
|
|
152
|
-
'appearance-auto': 'auto',
|
|
153
|
-
}
|
|
154
|
-
return values[parsed.raw] ? { appearance: values[parsed.raw] } : undefined
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export const caretColorRule: UtilityRule = (parsed, config) => {
|
|
158
|
-
if (parsed.utility === 'caret' && parsed.value) {
|
|
159
|
-
const parts = parsed.value.split('-')
|
|
160
|
-
if (parts.length === 2) {
|
|
161
|
-
const [colorName, shade] = parts
|
|
162
|
-
const colorValue = config.theme.colors[colorName]
|
|
163
|
-
if (typeof colorValue === 'object' && colorValue[shade]) {
|
|
164
|
-
return { 'caret-color': colorValue[shade] }
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
export const colorSchemeRule: UtilityRule = (parsed) => {
|
|
171
|
-
const schemes: Record<string, string> = {
|
|
172
|
-
'color-scheme-normal': 'normal',
|
|
173
|
-
'color-scheme-light': 'light',
|
|
174
|
-
'color-scheme-dark': 'dark',
|
|
175
|
-
'color-scheme-light-dark': 'light dark',
|
|
176
|
-
}
|
|
177
|
-
return schemes[parsed.raw] ? { 'color-scheme': schemes[parsed.raw] } : undefined
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
export const fieldSizingRule: UtilityRule = (parsed) => {
|
|
181
|
-
const values: Record<string, string> = {
|
|
182
|
-
'field-sizing-content': 'content',
|
|
183
|
-
'field-sizing-fixed': 'fixed',
|
|
184
|
-
}
|
|
185
|
-
return values[parsed.raw] ? { 'field-sizing': values[parsed.raw] } : undefined
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
export const cursorRule: UtilityRule = (parsed) => {
|
|
189
|
-
const cursors: Record<string, string> = {
|
|
190
|
-
'cursor-auto': 'auto',
|
|
191
|
-
'cursor-default': 'default',
|
|
192
|
-
'cursor-pointer': 'pointer',
|
|
193
|
-
'cursor-wait': 'wait',
|
|
194
|
-
'cursor-text': 'text',
|
|
195
|
-
'cursor-move': 'move',
|
|
196
|
-
'cursor-help': 'help',
|
|
197
|
-
'cursor-not-allowed': 'not-allowed',
|
|
198
|
-
'cursor-none': 'none',
|
|
199
|
-
'cursor-context-menu': 'context-menu',
|
|
200
|
-
'cursor-progress': 'progress',
|
|
201
|
-
'cursor-cell': 'cell',
|
|
202
|
-
'cursor-crosshair': 'crosshair',
|
|
203
|
-
'cursor-vertical-text': 'vertical-text',
|
|
204
|
-
'cursor-alias': 'alias',
|
|
205
|
-
'cursor-copy': 'copy',
|
|
206
|
-
'cursor-no-drop': 'no-drop',
|
|
207
|
-
'cursor-grab': 'grab',
|
|
208
|
-
'cursor-grabbing': 'grabbing',
|
|
209
|
-
'cursor-all-scroll': 'all-scroll',
|
|
210
|
-
'cursor-col-resize': 'col-resize',
|
|
211
|
-
'cursor-row-resize': 'row-resize',
|
|
212
|
-
'cursor-n-resize': 'n-resize',
|
|
213
|
-
'cursor-e-resize': 'e-resize',
|
|
214
|
-
'cursor-s-resize': 's-resize',
|
|
215
|
-
'cursor-w-resize': 'w-resize',
|
|
216
|
-
'cursor-ne-resize': 'ne-resize',
|
|
217
|
-
'cursor-nw-resize': 'nw-resize',
|
|
218
|
-
'cursor-se-resize': 'se-resize',
|
|
219
|
-
'cursor-sw-resize': 'sw-resize',
|
|
220
|
-
'cursor-ew-resize': 'ew-resize',
|
|
221
|
-
'cursor-ns-resize': 'ns-resize',
|
|
222
|
-
'cursor-nesw-resize': 'nesw-resize',
|
|
223
|
-
'cursor-nwse-resize': 'nwse-resize',
|
|
224
|
-
'cursor-zoom-in': 'zoom-in',
|
|
225
|
-
'cursor-zoom-out': 'zoom-out',
|
|
226
|
-
}
|
|
227
|
-
return cursors[parsed.raw] ? { cursor: cursors[parsed.raw] } : undefined
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
export const pointerEventsRule: UtilityRule = (parsed) => {
|
|
231
|
-
const values: Record<string, string> = {
|
|
232
|
-
'pointer-events-none': 'none',
|
|
233
|
-
'pointer-events-auto': 'auto',
|
|
234
|
-
}
|
|
235
|
-
return values[parsed.raw] ? { 'pointer-events': values[parsed.raw] } : undefined
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export const resizeRule: UtilityRule = (parsed) => {
|
|
239
|
-
const values: Record<string, string> = {
|
|
240
|
-
'resize-none': 'none',
|
|
241
|
-
'resize': 'both',
|
|
242
|
-
'resize-y': 'vertical',
|
|
243
|
-
'resize-x': 'horizontal',
|
|
244
|
-
}
|
|
245
|
-
return values[parsed.raw] ? { resize: values[parsed.raw] } : undefined
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export const scrollBehaviorRule: UtilityRule = (parsed) => {
|
|
249
|
-
const values: Record<string, string> = {
|
|
250
|
-
'scroll-auto': 'auto',
|
|
251
|
-
'scroll-smooth': 'smooth',
|
|
252
|
-
}
|
|
253
|
-
return values[parsed.raw] ? { 'scroll-behavior': values[parsed.raw] } : undefined
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
export const scrollMarginRule: UtilityRule = (parsed, config) => {
|
|
257
|
-
const directions: Record<string, string[]> = {
|
|
258
|
-
'scroll-m': ['scroll-margin'],
|
|
259
|
-
'scroll-mx': ['scroll-margin-left', 'scroll-margin-right'],
|
|
260
|
-
'scroll-my': ['scroll-margin-top', 'scroll-margin-bottom'],
|
|
261
|
-
'scroll-mt': ['scroll-margin-top'],
|
|
262
|
-
'scroll-mr': ['scroll-margin-right'],
|
|
263
|
-
'scroll-mb': ['scroll-margin-bottom'],
|
|
264
|
-
'scroll-ml': ['scroll-margin-left'],
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const props = directions[parsed.utility]
|
|
268
|
-
if (!props || !parsed.value)
|
|
269
|
-
return undefined
|
|
270
|
-
|
|
271
|
-
const value = config.theme.spacing[parsed.value] || parsed.value
|
|
272
|
-
const result: Record<string, string> = {}
|
|
273
|
-
for (const prop of props) {
|
|
274
|
-
result[prop] = value
|
|
275
|
-
}
|
|
276
|
-
return result
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export const scrollPaddingRule: UtilityRule = (parsed, config) => {
|
|
280
|
-
const directions: Record<string, string[]> = {
|
|
281
|
-
'scroll-p': ['scroll-padding'],
|
|
282
|
-
'scroll-px': ['scroll-padding-left', 'scroll-padding-right'],
|
|
283
|
-
'scroll-py': ['scroll-padding-top', 'scroll-padding-bottom'],
|
|
284
|
-
'scroll-pt': ['scroll-padding-top'],
|
|
285
|
-
'scroll-pr': ['scroll-padding-right'],
|
|
286
|
-
'scroll-pb': ['scroll-padding-bottom'],
|
|
287
|
-
'scroll-pl': ['scroll-padding-left'],
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const props = directions[parsed.utility]
|
|
291
|
-
if (!props || !parsed.value)
|
|
292
|
-
return undefined
|
|
293
|
-
|
|
294
|
-
const value = config.theme.spacing[parsed.value] || parsed.value
|
|
295
|
-
const result: Record<string, string> = {}
|
|
296
|
-
for (const prop of props) {
|
|
297
|
-
result[prop] = value
|
|
298
|
-
}
|
|
299
|
-
return result
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
export const scrollSnapRule: UtilityRule = (parsed) => {
|
|
303
|
-
const types: Record<string, string> = {
|
|
304
|
-
'snap-none': 'none',
|
|
305
|
-
'snap-x': 'x mandatory',
|
|
306
|
-
'snap-y': 'y mandatory',
|
|
307
|
-
'snap-both': 'both mandatory',
|
|
308
|
-
'snap-mandatory': 'mandatory',
|
|
309
|
-
'snap-proximity': 'proximity',
|
|
310
|
-
}
|
|
311
|
-
if (types[parsed.raw]) {
|
|
312
|
-
return parsed.raw.includes('mandatory') || parsed.raw.includes('proximity')
|
|
313
|
-
? { 'scroll-snap-type': types[parsed.raw] } as Record<string, string>
|
|
314
|
-
: { 'scroll-snap-type': types[parsed.raw] } as Record<string, string>
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
const aligns: Record<string, string> = {
|
|
318
|
-
'snap-start': 'start',
|
|
319
|
-
'snap-end': 'end',
|
|
320
|
-
'snap-center': 'center',
|
|
321
|
-
'snap-align-none': 'none',
|
|
322
|
-
}
|
|
323
|
-
if (aligns[parsed.raw]) {
|
|
324
|
-
return { 'scroll-snap-align': aligns[parsed.raw] } as Record<string, string>
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
const stops: Record<string, string> = {
|
|
328
|
-
'snap-normal': 'normal',
|
|
329
|
-
'snap-always': 'always',
|
|
330
|
-
}
|
|
331
|
-
if (stops[parsed.raw]) {
|
|
332
|
-
return { 'scroll-snap-stop': stops[parsed.raw] } as Record<string, string>
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export const touchActionRule: UtilityRule = (parsed) => {
|
|
337
|
-
const actions: Record<string, string> = {
|
|
338
|
-
'touch-auto': 'auto',
|
|
339
|
-
'touch-none': 'none',
|
|
340
|
-
'touch-pan-x': 'pan-x',
|
|
341
|
-
'touch-pan-left': 'pan-left',
|
|
342
|
-
'touch-pan-right': 'pan-right',
|
|
343
|
-
'touch-pan-y': 'pan-y',
|
|
344
|
-
'touch-pan-up': 'pan-up',
|
|
345
|
-
'touch-pan-down': 'pan-down',
|
|
346
|
-
'touch-pinch-zoom': 'pinch-zoom',
|
|
347
|
-
'touch-manipulation': 'manipulation',
|
|
348
|
-
}
|
|
349
|
-
return actions[parsed.raw] ? { 'touch-action': actions[parsed.raw] } : undefined
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
export const userSelectRule: UtilityRule = (parsed) => {
|
|
353
|
-
const selects: Record<string, string> = {
|
|
354
|
-
'select-none': 'none',
|
|
355
|
-
'select-text': 'text',
|
|
356
|
-
'select-all': 'all',
|
|
357
|
-
'select-auto': 'auto',
|
|
358
|
-
}
|
|
359
|
-
return selects[parsed.raw] ? { 'user-select': selects[parsed.raw] } : undefined
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
export const willChangeRule: UtilityRule = (parsed) => {
|
|
363
|
-
const values: Record<string, string> = {
|
|
364
|
-
'will-change-auto': 'auto',
|
|
365
|
-
'will-change-scroll': 'scroll-position',
|
|
366
|
-
'will-change-contents': 'contents',
|
|
367
|
-
'will-change-transform': 'transform',
|
|
368
|
-
}
|
|
369
|
-
return values[parsed.raw] ? { 'will-change': values[parsed.raw] } : undefined
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
// SVG utilities
|
|
373
|
-
export const fillRule: UtilityRule = (parsed, config) => {
|
|
374
|
-
if (parsed.utility === 'fill' && parsed.value) {
|
|
375
|
-
if (parsed.value === 'none') {
|
|
376
|
-
return { fill: 'none' }
|
|
377
|
-
}
|
|
378
|
-
if (parsed.value === 'current') {
|
|
379
|
-
return { fill: 'currentColor' }
|
|
380
|
-
}
|
|
381
|
-
const parts = parsed.value.split('-')
|
|
382
|
-
if (parts.length === 2) {
|
|
383
|
-
const [colorName, shade] = parts
|
|
384
|
-
const colorValue = config.theme.colors[colorName]
|
|
385
|
-
if (typeof colorValue === 'object' && colorValue[shade]) {
|
|
386
|
-
return { fill: colorValue[shade] }
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
export const strokeRule: UtilityRule = (parsed, config) => {
|
|
393
|
-
if (parsed.utility === 'stroke' && parsed.value) {
|
|
394
|
-
if (parsed.value === 'none') {
|
|
395
|
-
return { stroke: 'none' }
|
|
396
|
-
}
|
|
397
|
-
if (parsed.value === 'current') {
|
|
398
|
-
return { stroke: 'currentColor' }
|
|
399
|
-
}
|
|
400
|
-
const parts = parsed.value.split('-')
|
|
401
|
-
if (parts.length === 2) {
|
|
402
|
-
const [colorName, shade] = parts
|
|
403
|
-
const colorValue = config.theme.colors[colorName]
|
|
404
|
-
if (typeof colorValue === 'object' && colorValue[shade]) {
|
|
405
|
-
return { stroke: colorValue[shade] }
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
export const strokeWidthRule: UtilityRule = (parsed) => {
|
|
412
|
-
if (parsed.utility === 'stroke' && parsed.value) {
|
|
413
|
-
const widths: Record<string, string> = {
|
|
414
|
-
0: '0',
|
|
415
|
-
1: '1',
|
|
416
|
-
2: '2',
|
|
417
|
-
}
|
|
418
|
-
return { 'stroke-width': widths[parsed.value] || parsed.value }
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// SVG stroke-dasharray
|
|
423
|
-
export const strokeDasharrayRule: UtilityRule = (parsed) => {
|
|
424
|
-
if (parsed.utility === 'stroke-dasharray' && parsed.value) {
|
|
425
|
-
return { 'stroke-dasharray': parsed.value === 'none' ? 'none' : parsed.value }
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// SVG stroke-dashoffset
|
|
430
|
-
export const strokeDashoffsetRule: UtilityRule = (parsed) => {
|
|
431
|
-
if (parsed.utility === 'stroke-dashoffset' && parsed.value) {
|
|
432
|
-
return { 'stroke-dashoffset': parsed.value }
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// SVG stroke-linecap
|
|
437
|
-
export const strokeLinecapRule: UtilityRule = (parsed) => {
|
|
438
|
-
const values: Record<string, string> = {
|
|
439
|
-
'stroke-linecap-butt': 'butt',
|
|
440
|
-
'stroke-linecap-round': 'round',
|
|
441
|
-
'stroke-linecap-square': 'square',
|
|
442
|
-
}
|
|
443
|
-
return values[parsed.raw] ? { 'stroke-linecap': values[parsed.raw] } : undefined
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
// SVG stroke-linejoin
|
|
447
|
-
export const strokeLinejoinRule: UtilityRule = (parsed) => {
|
|
448
|
-
const values: Record<string, string> = {
|
|
449
|
-
'stroke-linejoin-miter': 'miter',
|
|
450
|
-
'stroke-linejoin-round': 'round',
|
|
451
|
-
'stroke-linejoin-bevel': 'bevel',
|
|
452
|
-
}
|
|
453
|
-
return values[parsed.raw] ? { 'stroke-linejoin': values[parsed.raw] } : undefined
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
// Accessibility
|
|
457
|
-
export const screenReaderRule: UtilityRule = (parsed) => {
|
|
458
|
-
if (parsed.raw === 'sr-only') {
|
|
459
|
-
return {
|
|
460
|
-
'position': 'absolute',
|
|
461
|
-
'width': '1px',
|
|
462
|
-
'height': '1px',
|
|
463
|
-
'padding': '0',
|
|
464
|
-
'margin': '-1px',
|
|
465
|
-
'overflow': 'hidden',
|
|
466
|
-
'clip': 'rect(0, 0, 0, 0)',
|
|
467
|
-
'white-space': 'nowrap',
|
|
468
|
-
'border-width': '0',
|
|
469
|
-
} as Record<string, string>
|
|
470
|
-
}
|
|
471
|
-
if (parsed.raw === 'not-sr-only') {
|
|
472
|
-
return {
|
|
473
|
-
'position': 'static',
|
|
474
|
-
'width': 'auto',
|
|
475
|
-
'height': 'auto',
|
|
476
|
-
'padding': '0',
|
|
477
|
-
'margin': '0',
|
|
478
|
-
'overflow': 'visible',
|
|
479
|
-
'clip': 'auto',
|
|
480
|
-
'white-space': 'normal',
|
|
481
|
-
} as Record<string, string>
|
|
482
|
-
}
|
|
483
|
-
return undefined
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export const forcedColorAdjustRule: UtilityRule = (parsed) => {
|
|
487
|
-
const values: Record<string, string> = {
|
|
488
|
-
'forced-color-adjust-auto': 'auto',
|
|
489
|
-
'forced-color-adjust-none': 'none',
|
|
490
|
-
}
|
|
491
|
-
return values[parsed.raw] ? { 'forced-color-adjust': values[parsed.raw] } : undefined
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
export const interactivityRules: UtilityRule[] = [
|
|
495
|
-
filterRule,
|
|
496
|
-
backdropFilterRule,
|
|
497
|
-
borderCollapseRule,
|
|
498
|
-
borderSpacingRule,
|
|
499
|
-
tableLayoutRule,
|
|
500
|
-
captionSideRule,
|
|
501
|
-
accentColorRule,
|
|
502
|
-
appearanceRule,
|
|
503
|
-
caretColorRule,
|
|
504
|
-
colorSchemeRule,
|
|
505
|
-
fieldSizingRule,
|
|
506
|
-
cursorRule,
|
|
507
|
-
pointerEventsRule,
|
|
508
|
-
resizeRule,
|
|
509
|
-
scrollBehaviorRule,
|
|
510
|
-
scrollMarginRule,
|
|
511
|
-
scrollPaddingRule,
|
|
512
|
-
scrollSnapRule,
|
|
513
|
-
touchActionRule,
|
|
514
|
-
userSelectRule,
|
|
515
|
-
willChangeRule,
|
|
516
|
-
fillRule,
|
|
517
|
-
strokeRule,
|
|
518
|
-
strokeWidthRule,
|
|
519
|
-
strokeDasharrayRule,
|
|
520
|
-
strokeDashoffsetRule,
|
|
521
|
-
strokeLinecapRule,
|
|
522
|
-
strokeLinejoinRule,
|
|
523
|
-
screenReaderRule,
|
|
524
|
-
forcedColorAdjustRule,
|
|
525
|
-
]
|