@cwcss/crosswind 0.1.4 → 0.1.6
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 +390 -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/index.js +12798 -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/transformer-compile-class.d.ts +37 -0
- package/{src/types.ts → dist/types.d.ts} +17 -86
- package/package.json +1 -1
- 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 -457
- 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 -805
- 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
package/src/rules-effects.ts
DELETED
|
@@ -1,457 +0,0 @@
|
|
|
1
|
-
import type { UtilityRule } from './rules'
|
|
2
|
-
|
|
3
|
-
// =============================================================================
|
|
4
|
-
// Shadow color helpers
|
|
5
|
-
// =============================================================================
|
|
6
|
-
|
|
7
|
-
// Flat color cache for shadow color lookups
|
|
8
|
-
let shadowColorCache: Map<string, string> | null = null
|
|
9
|
-
let shadowColorCacheConfig: any = null
|
|
10
|
-
|
|
11
|
-
function buildShadowColorCache(colors: Record<string, any>): Map<string, string> {
|
|
12
|
-
const cache = new Map<string, string>()
|
|
13
|
-
for (const [name, value] of Object.entries(colors)) {
|
|
14
|
-
if (typeof value === 'string') {
|
|
15
|
-
cache.set(name, value)
|
|
16
|
-
}
|
|
17
|
-
else if (typeof value === 'object' && value !== null) {
|
|
18
|
-
for (const [shade, shadeValue] of Object.entries(value)) {
|
|
19
|
-
if (typeof shadeValue === 'string') {
|
|
20
|
-
cache.set(`${name}-${shade}`, shadeValue)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return cache
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function applyShadowOpacity(color: string, opacity: number): string {
|
|
29
|
-
if (color.charCodeAt(0) === 35) { // '#'
|
|
30
|
-
const hex = color.slice(1)
|
|
31
|
-
const r = Number.parseInt(hex.slice(0, 2), 16)
|
|
32
|
-
const g = Number.parseInt(hex.slice(2, 4), 16)
|
|
33
|
-
const b = Number.parseInt(hex.slice(4, 6), 16)
|
|
34
|
-
return `rgb(${r} ${g} ${b} / ${opacity})`
|
|
35
|
-
}
|
|
36
|
-
return color
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Replace color values in a shadow string with var(--hw-shadow-color)
|
|
41
|
-
* e.g., '0 10px 15px -3px rgb(0 0 0 / 0.1)' -> '0 10px 15px -3px var(--hw-shadow-color)'
|
|
42
|
-
*/
|
|
43
|
-
function createColoredShadow(shadow: string): string {
|
|
44
|
-
return shadow.replace(/rgba?\([^)]+\)/g, 'var(--hw-shadow-color)')
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// =============================================================================
|
|
48
|
-
// Backgrounds, Borders, Effects utilities
|
|
49
|
-
// =============================================================================
|
|
50
|
-
|
|
51
|
-
// Background utilities
|
|
52
|
-
export const backgroundAttachmentRule: UtilityRule = (parsed) => {
|
|
53
|
-
if (parsed.utility === 'bg' && parsed.value) {
|
|
54
|
-
const values: Record<string, string> = {
|
|
55
|
-
fixed: 'fixed',
|
|
56
|
-
local: 'local',
|
|
57
|
-
scroll: 'scroll',
|
|
58
|
-
}
|
|
59
|
-
return values[parsed.value] ? { 'background-attachment': values[parsed.value] } : undefined
|
|
60
|
-
}
|
|
61
|
-
return undefined
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export const backgroundClipRule: UtilityRule = (parsed) => {
|
|
65
|
-
if (parsed.utility === 'bg' && parsed.value && parsed.value.startsWith('clip-')) {
|
|
66
|
-
const val = parsed.value.replace('clip-', '')
|
|
67
|
-
const values: Record<string, string> = {
|
|
68
|
-
border: 'border-box',
|
|
69
|
-
padding: 'padding-box',
|
|
70
|
-
content: 'content-box',
|
|
71
|
-
text: 'text',
|
|
72
|
-
}
|
|
73
|
-
return values[val] ? { 'background-clip': values[val] } : undefined
|
|
74
|
-
}
|
|
75
|
-
return undefined
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const backgroundImageRule: UtilityRule = (parsed) => {
|
|
79
|
-
if (parsed.utility === 'bg' && parsed.value) {
|
|
80
|
-
const gradients: Record<string, string> = {
|
|
81
|
-
'gradient-to-t': 'linear-gradient(to top, var(--hw-gradient-stops))',
|
|
82
|
-
'gradient-to-tr': 'linear-gradient(to top right, var(--hw-gradient-stops))',
|
|
83
|
-
'gradient-to-r': 'linear-gradient(to right, var(--hw-gradient-stops))',
|
|
84
|
-
'gradient-to-br': 'linear-gradient(to bottom right, var(--hw-gradient-stops))',
|
|
85
|
-
'gradient-to-b': 'linear-gradient(to bottom, var(--hw-gradient-stops))',
|
|
86
|
-
'gradient-to-bl': 'linear-gradient(to bottom left, var(--hw-gradient-stops))',
|
|
87
|
-
'gradient-to-l': 'linear-gradient(to left, var(--hw-gradient-stops))',
|
|
88
|
-
'gradient-to-tl': 'linear-gradient(to top left, var(--hw-gradient-stops))',
|
|
89
|
-
}
|
|
90
|
-
if (gradients[parsed.value]) {
|
|
91
|
-
return { 'background-image': gradients[parsed.value] } as Record<string, string>
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const backgroundOriginRule: UtilityRule = (parsed) => {
|
|
97
|
-
const values: Record<string, string> = {
|
|
98
|
-
'bg-origin-border': 'border-box',
|
|
99
|
-
'bg-origin-padding': 'padding-box',
|
|
100
|
-
'bg-origin-content': 'content-box',
|
|
101
|
-
}
|
|
102
|
-
return values[parsed.raw] ? { 'background-origin': values[parsed.raw] } : undefined
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export const backgroundPositionRule: UtilityRule = (parsed) => {
|
|
106
|
-
const positions: Record<string, string> = {
|
|
107
|
-
'bg-bottom': 'bottom',
|
|
108
|
-
'bg-center': 'center',
|
|
109
|
-
'bg-left': 'left',
|
|
110
|
-
'bg-left-bottom': 'left bottom',
|
|
111
|
-
'bg-left-top': 'left top',
|
|
112
|
-
'bg-right': 'right',
|
|
113
|
-
'bg-right-bottom': 'right bottom',
|
|
114
|
-
'bg-right-top': 'right top',
|
|
115
|
-
'bg-top': 'top',
|
|
116
|
-
}
|
|
117
|
-
return positions[parsed.raw] ? { 'background-position': positions[parsed.raw] } : undefined
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
export const backgroundRepeatRule: UtilityRule = (parsed) => {
|
|
121
|
-
const repeats: Record<string, string> = {
|
|
122
|
-
'bg-repeat': 'repeat',
|
|
123
|
-
'bg-no-repeat': 'no-repeat',
|
|
124
|
-
'bg-repeat-x': 'repeat-x',
|
|
125
|
-
'bg-repeat-y': 'repeat-y',
|
|
126
|
-
'bg-repeat-round': 'round',
|
|
127
|
-
'bg-repeat-space': 'space',
|
|
128
|
-
}
|
|
129
|
-
return repeats[parsed.raw] ? { 'background-repeat': repeats[parsed.raw] } : undefined
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export const backgroundSizeRule: UtilityRule = (parsed) => {
|
|
133
|
-
const sizes: Record<string, string> = {
|
|
134
|
-
'bg-auto': 'auto',
|
|
135
|
-
'bg-cover': 'cover',
|
|
136
|
-
'bg-contain': 'contain',
|
|
137
|
-
}
|
|
138
|
-
return sizes[parsed.raw] ? { 'background-size': sizes[parsed.raw] } : undefined
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Border utilities
|
|
142
|
-
export const borderStyleRule: UtilityRule = (parsed) => {
|
|
143
|
-
if (parsed.utility === 'border' && parsed.value) {
|
|
144
|
-
const styles: Record<string, string> = {
|
|
145
|
-
solid: 'solid',
|
|
146
|
-
dashed: 'dashed',
|
|
147
|
-
dotted: 'dotted',
|
|
148
|
-
double: 'double',
|
|
149
|
-
hidden: 'hidden',
|
|
150
|
-
none: 'none',
|
|
151
|
-
}
|
|
152
|
-
return styles[parsed.value] ? { 'border-style': styles[parsed.value] } : undefined
|
|
153
|
-
}
|
|
154
|
-
return undefined
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export const outlineRule: UtilityRule = (parsed, config) => {
|
|
158
|
-
// Outline offset
|
|
159
|
-
if (parsed.utility === 'outline-offset' && parsed.value) {
|
|
160
|
-
const offsets: Record<string, string> = {
|
|
161
|
-
0: '0px',
|
|
162
|
-
1: '1px',
|
|
163
|
-
2: '2px',
|
|
164
|
-
4: '4px',
|
|
165
|
-
8: '8px',
|
|
166
|
-
}
|
|
167
|
-
return { 'outline-offset': offsets[parsed.value] || parsed.value } as Record<string, string>
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Outline styles
|
|
171
|
-
if (parsed.utility === 'outline' && parsed.value) {
|
|
172
|
-
const outlineStyles: Record<string, string> = {
|
|
173
|
-
none: 'none',
|
|
174
|
-
solid: 'solid',
|
|
175
|
-
dashed: 'dashed',
|
|
176
|
-
dotted: 'dotted',
|
|
177
|
-
double: 'double',
|
|
178
|
-
}
|
|
179
|
-
if (outlineStyles[parsed.value]) {
|
|
180
|
-
return { 'outline-style': outlineStyles[parsed.value] } as Record<string, string>
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (parsed.utility === 'outline') {
|
|
185
|
-
if (!parsed.value) {
|
|
186
|
-
return { 'outline-width': '1px' } as Record<string, string>
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Check for colors first (e.g., outline-blue-500)
|
|
190
|
-
const parts = parsed.value.split('-')
|
|
191
|
-
if (parts.length === 2) {
|
|
192
|
-
const [colorName, shade] = parts
|
|
193
|
-
const colorValue = config.theme.colors[colorName]
|
|
194
|
-
if (typeof colorValue === 'object' && colorValue[shade]) {
|
|
195
|
-
return { 'outline-color': colorValue[shade] } as Record<string, string>
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// Direct color (e.g., outline-black)
|
|
200
|
-
const directColor = config.theme.colors[parsed.value]
|
|
201
|
-
if (typeof directColor === 'string') {
|
|
202
|
-
return { 'outline-color': directColor } as Record<string, string>
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// Check for width values
|
|
206
|
-
const widths: Record<string, string> = {
|
|
207
|
-
0: '0px',
|
|
208
|
-
1: '1px',
|
|
209
|
-
2: '2px',
|
|
210
|
-
4: '4px',
|
|
211
|
-
8: '8px',
|
|
212
|
-
}
|
|
213
|
-
if (widths[parsed.value]) {
|
|
214
|
-
return { 'outline-width': widths[parsed.value] } as Record<string, string>
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Fallback to raw value as width
|
|
218
|
-
return { 'outline-width': parsed.value } as Record<string, string>
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// Effect utilities
|
|
223
|
-
export const boxShadowThemeRule: UtilityRule = (parsed, config) => {
|
|
224
|
-
if (parsed.utility === 'shadow') {
|
|
225
|
-
const shadow = parsed.value
|
|
226
|
-
? config.theme.boxShadow[parsed.value]
|
|
227
|
-
: config.theme.boxShadow.DEFAULT
|
|
228
|
-
if (!shadow) return undefined
|
|
229
|
-
|
|
230
|
-
// shadow-none is a simple reset — no CSS variables needed
|
|
231
|
-
if (shadow === 'none') {
|
|
232
|
-
return {
|
|
233
|
-
'--hw-shadow': '0 0 #0000',
|
|
234
|
-
'box-shadow': 'var(--hw-ring-offset-shadow, 0 0 #0000), var(--hw-ring-shadow, 0 0 #0000), var(--hw-shadow)',
|
|
235
|
-
} as Record<string, string>
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
// Generate CSS variable-based shadow for color support
|
|
239
|
-
const colored = createColoredShadow(shadow)
|
|
240
|
-
return {
|
|
241
|
-
'--hw-shadow': shadow,
|
|
242
|
-
'--hw-shadow-colored': colored,
|
|
243
|
-
'box-shadow': 'var(--hw-ring-offset-shadow, 0 0 #0000), var(--hw-ring-shadow, 0 0 #0000), var(--hw-shadow)',
|
|
244
|
-
} as Record<string, string>
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
// Shadow color utilities (shadow-{color}, shadow-{color}/{opacity})
|
|
249
|
-
export const shadowColorRule: UtilityRule = (parsed, config) => {
|
|
250
|
-
if (parsed.utility !== 'shadow' || !parsed.value)
|
|
251
|
-
return undefined
|
|
252
|
-
|
|
253
|
-
// Skip if it matches a theme shadow size (sm, md, lg, xl, none, DEFAULT)
|
|
254
|
-
if (config.theme.boxShadow[parsed.value])
|
|
255
|
-
return undefined
|
|
256
|
-
|
|
257
|
-
// Build/update color cache if needed
|
|
258
|
-
if (shadowColorCache === null || shadowColorCacheConfig !== config.theme.colors) {
|
|
259
|
-
shadowColorCache = buildShadowColorCache(config.theme.colors)
|
|
260
|
-
shadowColorCacheConfig = config.theme.colors
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const value = parsed.value
|
|
264
|
-
const slashIdx = value.indexOf('/')
|
|
265
|
-
|
|
266
|
-
let colorName: string
|
|
267
|
-
let opacity: number | undefined
|
|
268
|
-
|
|
269
|
-
if (slashIdx !== -1) {
|
|
270
|
-
colorName = value.slice(0, slashIdx)
|
|
271
|
-
const opacityValue = Number.parseInt(value.slice(slashIdx + 1), 10)
|
|
272
|
-
if (Number.isNaN(opacityValue) || opacityValue < 0 || opacityValue > 100)
|
|
273
|
-
return undefined
|
|
274
|
-
opacity = opacityValue / 100
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
colorName = value
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const resolvedColor = shadowColorCache.get(colorName)
|
|
281
|
-
if (!resolvedColor) return undefined
|
|
282
|
-
|
|
283
|
-
const finalColor = opacity !== undefined
|
|
284
|
-
? applyShadowOpacity(resolvedColor, opacity)
|
|
285
|
-
: resolvedColor
|
|
286
|
-
|
|
287
|
-
return {
|
|
288
|
-
'--hw-shadow-color': finalColor,
|
|
289
|
-
'--hw-shadow': 'var(--hw-shadow-colored)',
|
|
290
|
-
} as Record<string, string>
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
export const textShadowRule: UtilityRule = (parsed) => {
|
|
294
|
-
if (parsed.utility === 'text-shadow') {
|
|
295
|
-
const shadows: Record<string, string> = {
|
|
296
|
-
sm: '0 1px 2px rgba(0, 0, 0, 0.05)',
|
|
297
|
-
DEFAULT: '0 1px 3px rgba(0, 0, 0, 0.1)',
|
|
298
|
-
md: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
299
|
-
lg: '0 10px 15px rgba(0, 0, 0, 0.1)',
|
|
300
|
-
xl: '0 20px 25px rgba(0, 0, 0, 0.1)',
|
|
301
|
-
none: 'none',
|
|
302
|
-
}
|
|
303
|
-
return parsed.value ? { 'text-shadow': shadows[parsed.value] || parsed.value } : undefined
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
export const opacityRule: UtilityRule = (parsed) => {
|
|
308
|
-
if (parsed.utility === 'opacity' && parsed.value) {
|
|
309
|
-
const opacityMap: Record<string, string> = {
|
|
310
|
-
0: '0',
|
|
311
|
-
5: '0.05',
|
|
312
|
-
10: '0.1',
|
|
313
|
-
20: '0.2',
|
|
314
|
-
25: '0.25',
|
|
315
|
-
30: '0.3',
|
|
316
|
-
40: '0.4',
|
|
317
|
-
50: '0.5',
|
|
318
|
-
60: '0.6',
|
|
319
|
-
70: '0.7',
|
|
320
|
-
75: '0.75',
|
|
321
|
-
80: '0.8',
|
|
322
|
-
90: '0.9',
|
|
323
|
-
95: '0.95',
|
|
324
|
-
100: '1',
|
|
325
|
-
}
|
|
326
|
-
return { opacity: opacityMap[parsed.value] || parsed.value }
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
export const mixBlendModeRule: UtilityRule = (parsed) => {
|
|
331
|
-
if (parsed.utility === 'mix-blend') {
|
|
332
|
-
const modes = ['normal', 'multiply', 'screen', 'overlay', 'darken', 'lighten', 'color-dodge', 'color-burn', 'hard-light', 'soft-light', 'difference', 'exclusion', 'hue', 'saturation', 'color', 'luminosity']
|
|
333
|
-
return parsed.value && modes.includes(parsed.value) ? { 'mix-blend-mode': parsed.value } : undefined
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
export const backgroundBlendModeRule: UtilityRule = (parsed) => {
|
|
338
|
-
if (parsed.utility === 'bg-blend') {
|
|
339
|
-
const modes = ['normal', 'multiply', 'screen', 'overlay', 'darken', 'lighten', 'color-dodge', 'color-burn', 'hard-light', 'soft-light', 'difference', 'exclusion', 'hue', 'saturation', 'color', 'luminosity']
|
|
340
|
-
return parsed.value && modes.includes(parsed.value) ? { 'background-blend-mode': parsed.value } : undefined
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
// Mask utilities
|
|
345
|
-
export const maskRule: UtilityRule = (parsed) => {
|
|
346
|
-
// mask-clip
|
|
347
|
-
if (parsed.utility === 'mask-clip' && parsed.value) {
|
|
348
|
-
const clips: Record<string, string> = {
|
|
349
|
-
'border': 'border-box',
|
|
350
|
-
'padding': 'padding-box',
|
|
351
|
-
'content': 'content-box',
|
|
352
|
-
'text': 'text',
|
|
353
|
-
'fill': 'fill-box',
|
|
354
|
-
'stroke': 'stroke-box',
|
|
355
|
-
'view': 'view-box',
|
|
356
|
-
'no-clip': 'no-clip',
|
|
357
|
-
}
|
|
358
|
-
return { 'mask-clip': clips[parsed.value] || parsed.value } as Record<string, string>
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// mask-composite
|
|
362
|
-
if (parsed.utility === 'mask-composite' && parsed.value) {
|
|
363
|
-
const composites = ['add', 'subtract', 'intersect', 'exclude']
|
|
364
|
-
return composites.includes(parsed.value) ? { 'mask-composite': parsed.value } as Record<string, string> : undefined
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
// mask-image
|
|
368
|
-
if (parsed.utility === 'mask-image' && parsed.value) {
|
|
369
|
-
if (parsed.value === 'none') {
|
|
370
|
-
return { 'mask-image': 'none' } as Record<string, string>
|
|
371
|
-
}
|
|
372
|
-
return { 'mask-image': `url(${parsed.value})` } as Record<string, string>
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// mask-mode
|
|
376
|
-
if (parsed.utility === 'mask-mode' && parsed.value) {
|
|
377
|
-
const modes = ['alpha', 'luminance', 'match-source']
|
|
378
|
-
return modes.includes(parsed.value) ? { 'mask-mode': parsed.value } as Record<string, string> : undefined
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// mask-origin
|
|
382
|
-
if (parsed.utility === 'mask-origin' && parsed.value) {
|
|
383
|
-
const origins: Record<string, string> = {
|
|
384
|
-
border: 'border-box',
|
|
385
|
-
padding: 'padding-box',
|
|
386
|
-
content: 'content-box',
|
|
387
|
-
fill: 'fill-box',
|
|
388
|
-
stroke: 'stroke-box',
|
|
389
|
-
view: 'view-box',
|
|
390
|
-
}
|
|
391
|
-
return { 'mask-origin': origins[parsed.value] || parsed.value } as Record<string, string>
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// mask-position
|
|
395
|
-
if (parsed.utility === 'mask-position' && parsed.value) {
|
|
396
|
-
const positions: Record<string, string> = {
|
|
397
|
-
'center': 'center',
|
|
398
|
-
'top': 'top',
|
|
399
|
-
'right': 'right',
|
|
400
|
-
'bottom': 'bottom',
|
|
401
|
-
'left': 'left',
|
|
402
|
-
'top-left': 'top left',
|
|
403
|
-
'top-right': 'top right',
|
|
404
|
-
'bottom-left': 'bottom left',
|
|
405
|
-
'bottom-right': 'bottom right',
|
|
406
|
-
}
|
|
407
|
-
return { 'mask-position': positions[parsed.value] || parsed.value } as Record<string, string>
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
// mask-repeat
|
|
411
|
-
if (parsed.utility === 'mask-repeat' && parsed.value) {
|
|
412
|
-
const repeats: Record<string, string> = {
|
|
413
|
-
'repeat': 'repeat',
|
|
414
|
-
'no-repeat': 'no-repeat',
|
|
415
|
-
'repeat-x': 'repeat-x',
|
|
416
|
-
'repeat-y': 'repeat-y',
|
|
417
|
-
'round': 'round',
|
|
418
|
-
'space': 'space',
|
|
419
|
-
}
|
|
420
|
-
return { 'mask-repeat': repeats[parsed.value] || parsed.value } as Record<string, string>
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
// mask-size
|
|
424
|
-
if (parsed.utility === 'mask-size' && parsed.value) {
|
|
425
|
-
const sizes: Record<string, string> = {
|
|
426
|
-
auto: 'auto',
|
|
427
|
-
cover: 'cover',
|
|
428
|
-
contain: 'contain',
|
|
429
|
-
}
|
|
430
|
-
return { 'mask-size': sizes[parsed.value] || parsed.value } as Record<string, string>
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
// mask-type
|
|
434
|
-
if (parsed.utility === 'mask-type' && parsed.value) {
|
|
435
|
-
const types = ['alpha', 'luminance']
|
|
436
|
-
return types.includes(parsed.value) ? { 'mask-type': parsed.value } as Record<string, string> : undefined
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
|
|
440
|
-
export const effectsRules: UtilityRule[] = [
|
|
441
|
-
backgroundAttachmentRule,
|
|
442
|
-
backgroundClipRule,
|
|
443
|
-
backgroundImageRule,
|
|
444
|
-
backgroundOriginRule,
|
|
445
|
-
backgroundPositionRule,
|
|
446
|
-
backgroundRepeatRule,
|
|
447
|
-
backgroundSizeRule,
|
|
448
|
-
borderStyleRule,
|
|
449
|
-
outlineRule,
|
|
450
|
-
boxShadowThemeRule,
|
|
451
|
-
shadowColorRule,
|
|
452
|
-
textShadowRule,
|
|
453
|
-
opacityRule,
|
|
454
|
-
mixBlendModeRule,
|
|
455
|
-
backgroundBlendModeRule,
|
|
456
|
-
maskRule,
|
|
457
|
-
]
|
package/src/rules-forms.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import type { UtilityRule } from './rules'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Tailwind Forms utility classes
|
|
5
|
-
* Provides form-* classes that can be used to explicitly apply form styles
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const baseInputStyles = {
|
|
9
|
-
'appearance': 'none',
|
|
10
|
-
'background-color': '#fff',
|
|
11
|
-
'border-color': '#6b7280',
|
|
12
|
-
'border-width': '1px',
|
|
13
|
-
'border-radius': '0px',
|
|
14
|
-
'padding-top': '0.5rem',
|
|
15
|
-
'padding-right': '0.75rem',
|
|
16
|
-
'padding-bottom': '0.5rem',
|
|
17
|
-
'padding-left': '0.75rem',
|
|
18
|
-
'font-size': '1rem',
|
|
19
|
-
'line-height': '1.5rem',
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const baseCheckboxRadioStyles = {
|
|
23
|
-
'appearance': 'none',
|
|
24
|
-
'padding': '0',
|
|
25
|
-
'print-color-adjust': 'exact',
|
|
26
|
-
'display': 'inline-block',
|
|
27
|
-
'vertical-align': 'middle',
|
|
28
|
-
'background-origin': 'border-box',
|
|
29
|
-
'user-select': 'none',
|
|
30
|
-
'flex-shrink': '0',
|
|
31
|
-
'height': '1rem',
|
|
32
|
-
'width': '1rem',
|
|
33
|
-
'color': '#2563eb',
|
|
34
|
-
'background-color': '#fff',
|
|
35
|
-
'border-color': '#6b7280',
|
|
36
|
-
'border-width': '1px',
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const formInputRule: UtilityRule = (parsed) => {
|
|
40
|
-
if (parsed.utility === 'form-input' && !parsed.value) {
|
|
41
|
-
return baseInputStyles
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export const formTextareaRule: UtilityRule = (parsed) => {
|
|
46
|
-
if (parsed.utility === 'form-textarea' && !parsed.value) {
|
|
47
|
-
return baseInputStyles
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export const formSelectRule: UtilityRule = (parsed) => {
|
|
52
|
-
if (parsed.utility === 'form-select' && !parsed.value) {
|
|
53
|
-
return {
|
|
54
|
-
...baseInputStyles,
|
|
55
|
-
'background-image': 'url("data:image/svg+xml,%3csvg xmlns=\'http://www.w3.org/2000/svg\' fill=\'none\' viewBox=\'0 0 20 20\'%3e%3cpath stroke=\'%236b7280\' stroke-linecap=\'round\' stroke-linejoin=\'round\' stroke-width=\'1.5\' d=\'M6 8l4 4 4-4\'/%3e%3c/svg%3e")',
|
|
56
|
-
'background-position': 'right 0.5rem center',
|
|
57
|
-
'background-repeat': 'no-repeat',
|
|
58
|
-
'background-size': '1.5em 1.5em',
|
|
59
|
-
'padding-right': '2.5rem',
|
|
60
|
-
'print-color-adjust': 'exact',
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const formMultiselectRule: UtilityRule = (parsed) => {
|
|
66
|
-
if (parsed.utility === 'form-multiselect' && !parsed.value) {
|
|
67
|
-
return {
|
|
68
|
-
...baseInputStyles,
|
|
69
|
-
'background-image': 'initial',
|
|
70
|
-
'background-position': 'initial',
|
|
71
|
-
'background-repeat': 'unset',
|
|
72
|
-
'background-size': 'initial',
|
|
73
|
-
'print-color-adjust': 'unset',
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export const formCheckboxRule: UtilityRule = (parsed) => {
|
|
79
|
-
if (parsed.utility === 'form-checkbox' && !parsed.value) {
|
|
80
|
-
return {
|
|
81
|
-
...baseCheckboxRadioStyles,
|
|
82
|
-
'border-radius': '0px',
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
export const formRadioRule: UtilityRule = (parsed) => {
|
|
88
|
-
if (parsed.utility === 'form-radio' && !parsed.value) {
|
|
89
|
-
return {
|
|
90
|
-
...baseCheckboxRadioStyles,
|
|
91
|
-
'border-radius': '100%',
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const formsRules: UtilityRule[] = [
|
|
97
|
-
formInputRule,
|
|
98
|
-
formTextareaRule,
|
|
99
|
-
formSelectRule,
|
|
100
|
-
formMultiselectRule,
|
|
101
|
-
formCheckboxRule,
|
|
102
|
-
formRadioRule,
|
|
103
|
-
]
|