@kbach/react 0.1.5 → 0.1.9
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/README.md +29 -29
- package/dist/{chunk-FUSJKUE7.mjs → chunk-CNS23UB5.mjs} +9 -7
- package/dist/chunk-PYBA3DFG.mjs +2046 -0
- package/dist/index.d.mts +128 -9
- package/dist/index.d.ts +128 -9
- package/dist/index.js +1985 -40
- package/dist/index.mjs +26 -35
- package/dist/jsx-dev-runtime.js +1943 -18
- package/dist/jsx-dev-runtime.mjs +2 -2
- package/dist/jsx-runtime.js +1943 -18
- package/dist/jsx-runtime.mjs +2 -2
- package/package.json +1 -4
- package/dist/chunk-IZK5HMWK.mjs +0 -85
package/dist/index.js
CHANGED
|
@@ -34,17 +34,18 @@ __export(index_exports, {
|
|
|
34
34
|
ThemeContext: () => ThemeContext,
|
|
35
35
|
ThemeProvider: () => ThemeProvider,
|
|
36
36
|
ThemeToggle: () => ThemeToggle,
|
|
37
|
+
buildConfig: () => buildConfig,
|
|
37
38
|
cx: () => cx,
|
|
38
|
-
defaultColors: () =>
|
|
39
|
-
defaultTheme: () =>
|
|
40
|
-
flatten: () =>
|
|
41
|
-
getConfig: () =>
|
|
42
|
-
parseClass: () =>
|
|
43
|
-
parseClasses: () =>
|
|
44
|
-
resolve: () =>
|
|
39
|
+
defaultColors: () => defaultColors,
|
|
40
|
+
defaultTheme: () => defaultTheme,
|
|
41
|
+
flatten: () => flatten,
|
|
42
|
+
getConfig: () => getConfig,
|
|
43
|
+
parseClass: () => parseClass,
|
|
44
|
+
parseClasses: () => parseClasses,
|
|
45
|
+
resolve: () => resolve,
|
|
45
46
|
styled: () => styled,
|
|
46
47
|
tw: () => tw,
|
|
47
|
-
updateConfig: () =>
|
|
48
|
+
updateConfig: () => updateConfig,
|
|
48
49
|
useGlobalDarkMode: () => useGlobalDarkMode,
|
|
49
50
|
useResolvedStyle: () => useResolvedStyle,
|
|
50
51
|
useStyles: () => useStyles,
|
|
@@ -67,7 +68,1958 @@ function useTheme() {
|
|
|
67
68
|
|
|
68
69
|
// src/ThemeProvider.tsx
|
|
69
70
|
var import_react2 = require("react");
|
|
70
|
-
|
|
71
|
+
|
|
72
|
+
// src/core/theme.ts
|
|
73
|
+
var defaultColors = {
|
|
74
|
+
transparent: "transparent",
|
|
75
|
+
current: "currentColor",
|
|
76
|
+
black: "#000000",
|
|
77
|
+
white: "#ffffff",
|
|
78
|
+
slate: {
|
|
79
|
+
1: "#f8f9fc",
|
|
80
|
+
2: "#edf0f8",
|
|
81
|
+
3: "#dde3f2",
|
|
82
|
+
4: "#c5cee8",
|
|
83
|
+
5: "#9badd3",
|
|
84
|
+
6: "#6c87b6",
|
|
85
|
+
7: "#526b98",
|
|
86
|
+
8: "#3e5479",
|
|
87
|
+
9: "#2d3f5e",
|
|
88
|
+
10: "#1d2b42",
|
|
89
|
+
11: "#0f1828"
|
|
90
|
+
},
|
|
91
|
+
gray: {
|
|
92
|
+
1: "#f9f9f9",
|
|
93
|
+
2: "#f3f3f3",
|
|
94
|
+
3: "#e6e6e7",
|
|
95
|
+
4: "#d2d2d4",
|
|
96
|
+
5: "#aaaaad",
|
|
97
|
+
6: "#757578",
|
|
98
|
+
7: "#585860",
|
|
99
|
+
8: "#434349",
|
|
100
|
+
9: "#2c2c32",
|
|
101
|
+
10: "#1c1c21",
|
|
102
|
+
11: "#0c0c0f"
|
|
103
|
+
},
|
|
104
|
+
zinc: {
|
|
105
|
+
1: "#fafafa",
|
|
106
|
+
2: "#f4f4f5",
|
|
107
|
+
3: "#e8e8ea",
|
|
108
|
+
4: "#d3d4d7",
|
|
109
|
+
5: "#a9aaae",
|
|
110
|
+
6: "#74757c",
|
|
111
|
+
7: "#57585f",
|
|
112
|
+
8: "#42434b",
|
|
113
|
+
9: "#2a2b31",
|
|
114
|
+
10: "#1a1b20",
|
|
115
|
+
11: "#0b0b0e"
|
|
116
|
+
},
|
|
117
|
+
neutral: {
|
|
118
|
+
1: "#fafafa",
|
|
119
|
+
2: "#f5f5f5",
|
|
120
|
+
3: "#e9e9e9",
|
|
121
|
+
4: "#d5d5d5",
|
|
122
|
+
5: "#ababab",
|
|
123
|
+
6: "#777777",
|
|
124
|
+
7: "#5a5a5a",
|
|
125
|
+
8: "#444444",
|
|
126
|
+
9: "#2d2d2d",
|
|
127
|
+
10: "#1d1d1d",
|
|
128
|
+
11: "#0d0d0d"
|
|
129
|
+
},
|
|
130
|
+
stone: {
|
|
131
|
+
1: "#fafaf8",
|
|
132
|
+
2: "#f5f4f1",
|
|
133
|
+
3: "#e9e6e0",
|
|
134
|
+
4: "#d6d0c8",
|
|
135
|
+
5: "#b3ab9c",
|
|
136
|
+
6: "#7e7568",
|
|
137
|
+
7: "#605850",
|
|
138
|
+
8: "#4a4440",
|
|
139
|
+
9: "#302c28",
|
|
140
|
+
10: "#201d1a",
|
|
141
|
+
11: "#100f0c"
|
|
142
|
+
},
|
|
143
|
+
red: {
|
|
144
|
+
1: "#fff4f3",
|
|
145
|
+
2: "#ffe8e6",
|
|
146
|
+
3: "#ffd1ce",
|
|
147
|
+
4: "#ffaba5",
|
|
148
|
+
5: "#ff7b73",
|
|
149
|
+
6: "#f44642",
|
|
150
|
+
7: "#d6302c",
|
|
151
|
+
8: "#be2020",
|
|
152
|
+
9: "#961515",
|
|
153
|
+
10: "#6e0f0f",
|
|
154
|
+
11: "#3e0606"
|
|
155
|
+
},
|
|
156
|
+
orange: {
|
|
157
|
+
1: "#fff8ec",
|
|
158
|
+
2: "#ffedce",
|
|
159
|
+
3: "#ffdda0",
|
|
160
|
+
4: "#ffc06a",
|
|
161
|
+
5: "#ff9c32",
|
|
162
|
+
6: "#f47c0c",
|
|
163
|
+
7: "#cc6205",
|
|
164
|
+
8: "#a34b04",
|
|
165
|
+
9: "#7d3806",
|
|
166
|
+
10: "#5b2807",
|
|
167
|
+
11: "#311502"
|
|
168
|
+
},
|
|
169
|
+
amber: {
|
|
170
|
+
1: "#fffbea",
|
|
171
|
+
2: "#fff5c7",
|
|
172
|
+
3: "#ffeb85",
|
|
173
|
+
4: "#ffd944",
|
|
174
|
+
5: "#f8c00e",
|
|
175
|
+
6: "#e4a500",
|
|
176
|
+
7: "#bd8300",
|
|
177
|
+
8: "#956600",
|
|
178
|
+
9: "#704c00",
|
|
179
|
+
10: "#513600",
|
|
180
|
+
11: "#2d1e00"
|
|
181
|
+
},
|
|
182
|
+
yellow: {
|
|
183
|
+
1: "#ffffe8",
|
|
184
|
+
2: "#ffffc8",
|
|
185
|
+
3: "#fffb82",
|
|
186
|
+
4: "#fff342",
|
|
187
|
+
5: "#f5da0e",
|
|
188
|
+
6: "#e1bd00",
|
|
189
|
+
7: "#bb9a00",
|
|
190
|
+
8: "#947800",
|
|
191
|
+
9: "#6f5900",
|
|
192
|
+
10: "#514200",
|
|
193
|
+
11: "#2d2500"
|
|
194
|
+
},
|
|
195
|
+
lime: {
|
|
196
|
+
1: "#f5ffe8",
|
|
197
|
+
2: "#eaffca",
|
|
198
|
+
3: "#d5ff90",
|
|
199
|
+
4: "#b8f658",
|
|
200
|
+
5: "#97e422",
|
|
201
|
+
6: "#74c90b",
|
|
202
|
+
7: "#5aa407",
|
|
203
|
+
8: "#457e08",
|
|
204
|
+
9: "#346008",
|
|
205
|
+
10: "#254408",
|
|
206
|
+
11: "#132505"
|
|
207
|
+
},
|
|
208
|
+
green: {
|
|
209
|
+
1: "#f0fdf5",
|
|
210
|
+
2: "#dcfce9",
|
|
211
|
+
3: "#b8f4d2",
|
|
212
|
+
4: "#84e8b1",
|
|
213
|
+
5: "#47d38d",
|
|
214
|
+
6: "#1cb86d",
|
|
215
|
+
7: "#129a57",
|
|
216
|
+
8: "#0e7b45",
|
|
217
|
+
9: "#0d6035",
|
|
218
|
+
10: "#0b4f2d",
|
|
219
|
+
11: "#042a18"
|
|
220
|
+
},
|
|
221
|
+
emerald: {
|
|
222
|
+
1: "#ecfdf7",
|
|
223
|
+
2: "#d0fcea",
|
|
224
|
+
3: "#a5f4d6",
|
|
225
|
+
4: "#6aeabc",
|
|
226
|
+
5: "#35d49f",
|
|
227
|
+
6: "#10b982",
|
|
228
|
+
7: "#099768",
|
|
229
|
+
8: "#087a53",
|
|
230
|
+
9: "#0a5f43",
|
|
231
|
+
10: "#094e37",
|
|
232
|
+
11: "#032b1f"
|
|
233
|
+
},
|
|
234
|
+
teal: {
|
|
235
|
+
1: "#efffff",
|
|
236
|
+
2: "#ccfcf8",
|
|
237
|
+
3: "#99f7f1",
|
|
238
|
+
4: "#60eee6",
|
|
239
|
+
5: "#2cdad3",
|
|
240
|
+
6: "#13bebc",
|
|
241
|
+
7: "#0d9997",
|
|
242
|
+
8: "#0d7a78",
|
|
243
|
+
9: "#0e6160",
|
|
244
|
+
10: "#0d4f4e",
|
|
245
|
+
11: "#063535"
|
|
246
|
+
},
|
|
247
|
+
cyan: {
|
|
248
|
+
1: "#ecfeff",
|
|
249
|
+
2: "#cffcfe",
|
|
250
|
+
3: "#a3f6fc",
|
|
251
|
+
4: "#67ebfa",
|
|
252
|
+
5: "#23d7f5",
|
|
253
|
+
6: "#07bde0",
|
|
254
|
+
7: "#0898b8",
|
|
255
|
+
8: "#0c7896",
|
|
256
|
+
9: "#135f78",
|
|
257
|
+
10: "#134e65",
|
|
258
|
+
11: "#053143"
|
|
259
|
+
},
|
|
260
|
+
sky: {
|
|
261
|
+
1: "#f0f8ff",
|
|
262
|
+
2: "#e0f2fe",
|
|
263
|
+
3: "#bde3fd",
|
|
264
|
+
4: "#89cffa",
|
|
265
|
+
5: "#48b4f8",
|
|
266
|
+
6: "#149aeb",
|
|
267
|
+
7: "#057ec8",
|
|
268
|
+
8: "#0664a4",
|
|
269
|
+
9: "#0a5087",
|
|
270
|
+
10: "#0d4270",
|
|
271
|
+
11: "#082748"
|
|
272
|
+
},
|
|
273
|
+
blue: {
|
|
274
|
+
1: "#eff5ff",
|
|
275
|
+
2: "#dde9fe",
|
|
276
|
+
3: "#bdd2fd",
|
|
277
|
+
4: "#8db1fb",
|
|
278
|
+
5: "#5a89f7",
|
|
279
|
+
6: "#2f64f3",
|
|
280
|
+
7: "#1b4de6",
|
|
281
|
+
8: "#1740cc",
|
|
282
|
+
9: "#142da8",
|
|
283
|
+
10: "#102080",
|
|
284
|
+
11: "#0b144f"
|
|
285
|
+
},
|
|
286
|
+
indigo: {
|
|
287
|
+
1: "#eff1ff",
|
|
288
|
+
2: "#e2e7ff",
|
|
289
|
+
3: "#c9d1ff",
|
|
290
|
+
4: "#a9b4ff",
|
|
291
|
+
5: "#8590fe",
|
|
292
|
+
6: "#6267f3",
|
|
293
|
+
7: "#4f51e7",
|
|
294
|
+
8: "#4240d0",
|
|
295
|
+
9: "#3434ae",
|
|
296
|
+
10: "#292888",
|
|
297
|
+
11: "#181854"
|
|
298
|
+
},
|
|
299
|
+
violet: {
|
|
300
|
+
1: "#f5f3ff",
|
|
301
|
+
2: "#ede9ff",
|
|
302
|
+
3: "#ddd5fe",
|
|
303
|
+
4: "#c6b8fd",
|
|
304
|
+
5: "#a893fa",
|
|
305
|
+
6: "#8a69f7",
|
|
306
|
+
7: "#7248ec",
|
|
307
|
+
8: "#6137d6",
|
|
308
|
+
9: "#4f28ae",
|
|
309
|
+
10: "#3f218e",
|
|
310
|
+
11: "#250f58"
|
|
311
|
+
},
|
|
312
|
+
purple: {
|
|
313
|
+
1: "#fbf3ff",
|
|
314
|
+
2: "#f4e8ff",
|
|
315
|
+
3: "#e9cfff",
|
|
316
|
+
4: "#d8adfd",
|
|
317
|
+
5: "#bf7cfa",
|
|
318
|
+
6: "#a650f5",
|
|
319
|
+
7: "#8f30e7",
|
|
320
|
+
8: "#7c1fce",
|
|
321
|
+
9: "#671caa",
|
|
322
|
+
10: "#521885",
|
|
323
|
+
11: "#300860"
|
|
324
|
+
},
|
|
325
|
+
fuchsia: {
|
|
326
|
+
1: "#fef3ff",
|
|
327
|
+
2: "#fbe8ff",
|
|
328
|
+
3: "#f6cfff",
|
|
329
|
+
4: "#efaaff",
|
|
330
|
+
5: "#e672fb",
|
|
331
|
+
6: "#d748ef",
|
|
332
|
+
7: "#be20d3",
|
|
333
|
+
8: "#a41ab5",
|
|
334
|
+
9: "#86168e",
|
|
335
|
+
10: "#631470",
|
|
336
|
+
11: "#42024a"
|
|
337
|
+
},
|
|
338
|
+
pink: {
|
|
339
|
+
1: "#fef2f8",
|
|
340
|
+
2: "#fde7f3",
|
|
341
|
+
3: "#fbcde7",
|
|
342
|
+
4: "#f8a8d1",
|
|
343
|
+
5: "#f36cb8",
|
|
344
|
+
6: "#ea3f98",
|
|
345
|
+
7: "#d4217c",
|
|
346
|
+
8: "#be1965",
|
|
347
|
+
9: "#9c1651",
|
|
348
|
+
10: "#74143e",
|
|
349
|
+
11: "#450827"
|
|
350
|
+
},
|
|
351
|
+
rose: {
|
|
352
|
+
1: "#fff2f3",
|
|
353
|
+
2: "#ffe5e8",
|
|
354
|
+
3: "#ffcacd",
|
|
355
|
+
4: "#ff9fa7",
|
|
356
|
+
5: "#fd6b77",
|
|
357
|
+
6: "#f43e52",
|
|
358
|
+
7: "#e01e31",
|
|
359
|
+
8: "#c0152c",
|
|
360
|
+
9: "#9a1222",
|
|
361
|
+
10: "#701019",
|
|
362
|
+
11: "#420611"
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
var defaultTheme = {
|
|
366
|
+
colors: defaultColors,
|
|
367
|
+
// 1 unit = 4px
|
|
368
|
+
spacing: {
|
|
369
|
+
px: 1,
|
|
370
|
+
0: 0,
|
|
371
|
+
"0.5": 2,
|
|
372
|
+
1: 4,
|
|
373
|
+
"1.5": 6,
|
|
374
|
+
2: 8,
|
|
375
|
+
"2.5": 10,
|
|
376
|
+
3: 12,
|
|
377
|
+
"3.5": 14,
|
|
378
|
+
4: 16,
|
|
379
|
+
5: 20,
|
|
380
|
+
6: 24,
|
|
381
|
+
7: 28,
|
|
382
|
+
8: 32,
|
|
383
|
+
9: 36,
|
|
384
|
+
10: 40,
|
|
385
|
+
11: 44,
|
|
386
|
+
12: 48,
|
|
387
|
+
14: 56,
|
|
388
|
+
16: 64,
|
|
389
|
+
20: 80,
|
|
390
|
+
24: 96,
|
|
391
|
+
28: 112,
|
|
392
|
+
32: 128,
|
|
393
|
+
36: 144,
|
|
394
|
+
40: 160,
|
|
395
|
+
44: 176,
|
|
396
|
+
48: 192,
|
|
397
|
+
52: 208,
|
|
398
|
+
56: 224,
|
|
399
|
+
60: 240,
|
|
400
|
+
64: 256,
|
|
401
|
+
72: 288,
|
|
402
|
+
80: 320,
|
|
403
|
+
96: 384,
|
|
404
|
+
auto: "auto",
|
|
405
|
+
full: "100%",
|
|
406
|
+
"1/2": "50%",
|
|
407
|
+
"1/3": "33.333333%",
|
|
408
|
+
"2/3": "66.666667%",
|
|
409
|
+
"1/4": "25%",
|
|
410
|
+
"3/4": "75%",
|
|
411
|
+
screen: "100vh",
|
|
412
|
+
min: "min-content",
|
|
413
|
+
max: "max-content",
|
|
414
|
+
fit: "fit-content"
|
|
415
|
+
},
|
|
416
|
+
fontSize: {
|
|
417
|
+
xs: 12,
|
|
418
|
+
sm: 14,
|
|
419
|
+
base: 16,
|
|
420
|
+
lg: 18,
|
|
421
|
+
xl: 20,
|
|
422
|
+
"2xl": 24,
|
|
423
|
+
"3xl": 30,
|
|
424
|
+
"4xl": 36,
|
|
425
|
+
"5xl": 48,
|
|
426
|
+
"6xl": 60,
|
|
427
|
+
"7xl": 72,
|
|
428
|
+
"8xl": 96,
|
|
429
|
+
"9xl": 128
|
|
430
|
+
},
|
|
431
|
+
fontFamily: {
|
|
432
|
+
sans: "System",
|
|
433
|
+
mono: "Courier New",
|
|
434
|
+
serif: "Georgia"
|
|
435
|
+
},
|
|
436
|
+
fontWeight: {
|
|
437
|
+
thin: "100",
|
|
438
|
+
extralight: "200",
|
|
439
|
+
light: "300",
|
|
440
|
+
normal: "400",
|
|
441
|
+
medium: "500",
|
|
442
|
+
semibold: "600",
|
|
443
|
+
bold: "700",
|
|
444
|
+
extrabold: "800",
|
|
445
|
+
black: "900"
|
|
446
|
+
},
|
|
447
|
+
borderRadius: {
|
|
448
|
+
none: 0,
|
|
449
|
+
sm: 2,
|
|
450
|
+
DEFAULT: 4,
|
|
451
|
+
md: 6,
|
|
452
|
+
lg: 8,
|
|
453
|
+
xl: 12,
|
|
454
|
+
"2xl": 16,
|
|
455
|
+
"3xl": 24,
|
|
456
|
+
full: 9999
|
|
457
|
+
},
|
|
458
|
+
borderWidth: {
|
|
459
|
+
DEFAULT: 1,
|
|
460
|
+
0: 0,
|
|
461
|
+
2: 2,
|
|
462
|
+
4: 4,
|
|
463
|
+
8: 8
|
|
464
|
+
},
|
|
465
|
+
opacity: {
|
|
466
|
+
0: 0,
|
|
467
|
+
5: 0.05,
|
|
468
|
+
10: 0.1,
|
|
469
|
+
15: 0.15,
|
|
470
|
+
20: 0.2,
|
|
471
|
+
25: 0.25,
|
|
472
|
+
30: 0.3,
|
|
473
|
+
40: 0.4,
|
|
474
|
+
50: 0.5,
|
|
475
|
+
60: 0.6,
|
|
476
|
+
70: 0.7,
|
|
477
|
+
75: 0.75,
|
|
478
|
+
80: 0.8,
|
|
479
|
+
90: 0.9,
|
|
480
|
+
95: 0.95,
|
|
481
|
+
100: 1
|
|
482
|
+
},
|
|
483
|
+
lineHeight: {
|
|
484
|
+
none: 1,
|
|
485
|
+
tight: 1.25,
|
|
486
|
+
snug: 1.375,
|
|
487
|
+
normal: 1.5,
|
|
488
|
+
relaxed: 1.625,
|
|
489
|
+
loose: 2,
|
|
490
|
+
3: 12,
|
|
491
|
+
4: 16,
|
|
492
|
+
5: 20,
|
|
493
|
+
6: 24,
|
|
494
|
+
7: 28,
|
|
495
|
+
8: 32,
|
|
496
|
+
9: 36,
|
|
497
|
+
10: 40
|
|
498
|
+
},
|
|
499
|
+
letterSpacing: {
|
|
500
|
+
tighter: -0.8,
|
|
501
|
+
tight: -0.4,
|
|
502
|
+
normal: 0,
|
|
503
|
+
wide: 0.4,
|
|
504
|
+
wider: 0.8,
|
|
505
|
+
widest: 1.6
|
|
506
|
+
},
|
|
507
|
+
zIndex: {
|
|
508
|
+
auto: "auto",
|
|
509
|
+
0: 0,
|
|
510
|
+
10: 10,
|
|
511
|
+
20: 20,
|
|
512
|
+
30: 30,
|
|
513
|
+
40: 40,
|
|
514
|
+
50: 50
|
|
515
|
+
},
|
|
516
|
+
flex: {
|
|
517
|
+
1: 1,
|
|
518
|
+
auto: 1,
|
|
519
|
+
initial: 0,
|
|
520
|
+
none: 0
|
|
521
|
+
},
|
|
522
|
+
shadow: {
|
|
523
|
+
sm: {
|
|
524
|
+
shadowColor: "#000",
|
|
525
|
+
shadowOffset: { width: 0, height: 1 },
|
|
526
|
+
shadowOpacity: 0.05,
|
|
527
|
+
shadowRadius: 2,
|
|
528
|
+
elevation: 1
|
|
529
|
+
},
|
|
530
|
+
DEFAULT: {
|
|
531
|
+
shadowColor: "#000",
|
|
532
|
+
shadowOffset: { width: 0, height: 2 },
|
|
533
|
+
shadowOpacity: 0.1,
|
|
534
|
+
shadowRadius: 4,
|
|
535
|
+
elevation: 2
|
|
536
|
+
},
|
|
537
|
+
md: {
|
|
538
|
+
shadowColor: "#000",
|
|
539
|
+
shadowOffset: { width: 0, height: 4 },
|
|
540
|
+
shadowOpacity: 0.1,
|
|
541
|
+
shadowRadius: 8,
|
|
542
|
+
elevation: 3
|
|
543
|
+
},
|
|
544
|
+
lg: {
|
|
545
|
+
shadowColor: "#000",
|
|
546
|
+
shadowOffset: { width: 0, height: 8 },
|
|
547
|
+
shadowOpacity: 0.1,
|
|
548
|
+
shadowRadius: 15,
|
|
549
|
+
elevation: 4
|
|
550
|
+
},
|
|
551
|
+
xl: {
|
|
552
|
+
shadowColor: "#000",
|
|
553
|
+
shadowOffset: { width: 0, height: 16 },
|
|
554
|
+
shadowOpacity: 0.1,
|
|
555
|
+
shadowRadius: 24,
|
|
556
|
+
elevation: 6
|
|
557
|
+
},
|
|
558
|
+
"2xl": {
|
|
559
|
+
shadowColor: "#000",
|
|
560
|
+
shadowOffset: { width: 0, height: 24 },
|
|
561
|
+
shadowOpacity: 0.25,
|
|
562
|
+
shadowRadius: 48,
|
|
563
|
+
elevation: 8
|
|
564
|
+
},
|
|
565
|
+
none: {
|
|
566
|
+
shadowColor: "transparent",
|
|
567
|
+
shadowOffset: { width: 0, height: 0 },
|
|
568
|
+
shadowOpacity: 0,
|
|
569
|
+
shadowRadius: 0,
|
|
570
|
+
elevation: 0
|
|
571
|
+
}
|
|
572
|
+
},
|
|
573
|
+
screens: {
|
|
574
|
+
sm: 640,
|
|
575
|
+
md: 768,
|
|
576
|
+
lg: 1024,
|
|
577
|
+
xl: 1280,
|
|
578
|
+
"2xl": 1536
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
|
|
582
|
+
// src/core/cache.ts
|
|
583
|
+
var LRUCache = class {
|
|
584
|
+
constructor(capacity = 1e4) {
|
|
585
|
+
this.capacity = capacity;
|
|
586
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
587
|
+
}
|
|
588
|
+
get(key) {
|
|
589
|
+
if (!this.cache.has(key)) return void 0;
|
|
590
|
+
const value = this.cache.get(key);
|
|
591
|
+
this.cache.delete(key);
|
|
592
|
+
this.cache.set(key, value);
|
|
593
|
+
return value;
|
|
594
|
+
}
|
|
595
|
+
set(key, value) {
|
|
596
|
+
if (this.cache.has(key)) {
|
|
597
|
+
this.cache.delete(key);
|
|
598
|
+
} else if (this.cache.size >= this.capacity) {
|
|
599
|
+
this.cache.delete(this.cache.keys().next().value);
|
|
600
|
+
}
|
|
601
|
+
this.cache.set(key, value);
|
|
602
|
+
return this;
|
|
603
|
+
}
|
|
604
|
+
has(key) {
|
|
605
|
+
return this.cache.has(key);
|
|
606
|
+
}
|
|
607
|
+
delete(key) {
|
|
608
|
+
return this.cache.delete(key);
|
|
609
|
+
}
|
|
610
|
+
clear() {
|
|
611
|
+
this.cache.clear();
|
|
612
|
+
}
|
|
613
|
+
get size() {
|
|
614
|
+
return this.cache.size;
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
|
|
618
|
+
// src/core/platform.ts
|
|
619
|
+
var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
620
|
+
function toNativeValue(raw) {
|
|
621
|
+
if (/^-?\d+(\.\d+)?px$/.test(raw)) return parseFloat(raw);
|
|
622
|
+
if (/^-?\d+(\.\d+)?rem$/.test(raw)) return parseFloat(raw) * 16;
|
|
623
|
+
if (/^-?\d+(\.\d+)?em$/.test(raw)) return parseFloat(raw) * 16;
|
|
624
|
+
if (/^-?\d+(\.\d+)?$/.test(raw)) return parseFloat(raw);
|
|
625
|
+
return raw;
|
|
626
|
+
}
|
|
627
|
+
function escapeCSSSelector(cls) {
|
|
628
|
+
return cls.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// src/core/parser.ts
|
|
632
|
+
var MODIFIERS = /* @__PURE__ */ new Set([
|
|
633
|
+
// Theme
|
|
634
|
+
"dark",
|
|
635
|
+
"light",
|
|
636
|
+
"not-dark",
|
|
637
|
+
"not-light",
|
|
638
|
+
// Interaction
|
|
639
|
+
"hover",
|
|
640
|
+
"focus",
|
|
641
|
+
"active",
|
|
642
|
+
"visited",
|
|
643
|
+
"disabled",
|
|
644
|
+
"checked",
|
|
645
|
+
"pressed",
|
|
646
|
+
"placeholder",
|
|
647
|
+
"focus-within",
|
|
648
|
+
"focus-visible",
|
|
649
|
+
// Negated interaction
|
|
650
|
+
"not-hover",
|
|
651
|
+
"not-focus",
|
|
652
|
+
"not-active",
|
|
653
|
+
"not-visited",
|
|
654
|
+
"not-disabled",
|
|
655
|
+
"not-checked",
|
|
656
|
+
"not-pressed",
|
|
657
|
+
// Structural
|
|
658
|
+
"first",
|
|
659
|
+
"last",
|
|
660
|
+
"odd",
|
|
661
|
+
"even",
|
|
662
|
+
"only",
|
|
663
|
+
// Group / peer
|
|
664
|
+
"group-hover",
|
|
665
|
+
"group-focus",
|
|
666
|
+
"peer-hover",
|
|
667
|
+
"peer-focus",
|
|
668
|
+
// Responsive (handled separately but accepted)
|
|
669
|
+
"sm",
|
|
670
|
+
"md",
|
|
671
|
+
"lg",
|
|
672
|
+
"xl",
|
|
673
|
+
"2xl"
|
|
674
|
+
]);
|
|
675
|
+
var UTILITY_PREFIXES = [
|
|
676
|
+
// Multi-word order matters
|
|
677
|
+
"flex-row-reverse",
|
|
678
|
+
"flex-col-reverse",
|
|
679
|
+
"flex-row",
|
|
680
|
+
"flex-col",
|
|
681
|
+
"flex-wrap-reverse",
|
|
682
|
+
"flex-wrap",
|
|
683
|
+
"flex-nowrap",
|
|
684
|
+
"flex-shrink-0",
|
|
685
|
+
"flex-shrink",
|
|
686
|
+
"flex-grow-0",
|
|
687
|
+
"flex-grow",
|
|
688
|
+
"items-start",
|
|
689
|
+
"items-end",
|
|
690
|
+
"items-center",
|
|
691
|
+
"items-baseline",
|
|
692
|
+
"items-stretch",
|
|
693
|
+
"justify-start",
|
|
694
|
+
"justify-end",
|
|
695
|
+
"justify-center",
|
|
696
|
+
"justify-between",
|
|
697
|
+
"justify-around",
|
|
698
|
+
"justify-evenly",
|
|
699
|
+
"content-start",
|
|
700
|
+
"content-end",
|
|
701
|
+
"content-center",
|
|
702
|
+
"content-between",
|
|
703
|
+
"content-around",
|
|
704
|
+
"content-evenly",
|
|
705
|
+
"self-start",
|
|
706
|
+
"self-end",
|
|
707
|
+
"self-center",
|
|
708
|
+
"self-auto",
|
|
709
|
+
"self-stretch",
|
|
710
|
+
"text-left",
|
|
711
|
+
"text-right",
|
|
712
|
+
"text-center",
|
|
713
|
+
"text-justify",
|
|
714
|
+
"font-thin",
|
|
715
|
+
"font-extralight",
|
|
716
|
+
"font-light",
|
|
717
|
+
"font-normal",
|
|
718
|
+
"font-medium",
|
|
719
|
+
"font-semibold",
|
|
720
|
+
"font-bold",
|
|
721
|
+
"font-extrabold",
|
|
722
|
+
"font-black",
|
|
723
|
+
"overflow-hidden",
|
|
724
|
+
"overflow-visible",
|
|
725
|
+
"overflow-scroll",
|
|
726
|
+
"overflow-auto",
|
|
727
|
+
"overflow-x-hidden",
|
|
728
|
+
"overflow-x-scroll",
|
|
729
|
+
"overflow-x-auto",
|
|
730
|
+
"overflow-y-hidden",
|
|
731
|
+
"overflow-y-scroll",
|
|
732
|
+
"overflow-y-auto",
|
|
733
|
+
"object-contain",
|
|
734
|
+
"object-cover",
|
|
735
|
+
"object-fill",
|
|
736
|
+
"object-none",
|
|
737
|
+
"object-scale-down",
|
|
738
|
+
"border-solid",
|
|
739
|
+
"border-dashed",
|
|
740
|
+
"border-dotted",
|
|
741
|
+
"border-none",
|
|
742
|
+
"border-t",
|
|
743
|
+
"border-r",
|
|
744
|
+
"border-b",
|
|
745
|
+
"border-l",
|
|
746
|
+
"rounded-tl",
|
|
747
|
+
"rounded-tr",
|
|
748
|
+
"rounded-bl",
|
|
749
|
+
"rounded-br",
|
|
750
|
+
"rounded-t",
|
|
751
|
+
"rounded-r",
|
|
752
|
+
"rounded-b",
|
|
753
|
+
"rounded-l",
|
|
754
|
+
"text-decoration-none",
|
|
755
|
+
"list-none",
|
|
756
|
+
"list-disc",
|
|
757
|
+
"list-decimal",
|
|
758
|
+
"cursor-auto",
|
|
759
|
+
"cursor-default",
|
|
760
|
+
"cursor-pointer",
|
|
761
|
+
"cursor-wait",
|
|
762
|
+
"cursor-text",
|
|
763
|
+
"cursor-move",
|
|
764
|
+
"cursor-not-allowed",
|
|
765
|
+
"select-none",
|
|
766
|
+
"select-text",
|
|
767
|
+
"select-all",
|
|
768
|
+
"select-auto",
|
|
769
|
+
"pointer-events-none",
|
|
770
|
+
"pointer-events-auto",
|
|
771
|
+
"whitespace-normal",
|
|
772
|
+
"whitespace-nowrap",
|
|
773
|
+
"whitespace-pre-wrap",
|
|
774
|
+
"whitespace-pre-line",
|
|
775
|
+
"whitespace-pre",
|
|
776
|
+
"break-normal",
|
|
777
|
+
"break-words",
|
|
778
|
+
"break-all",
|
|
779
|
+
"break-keep",
|
|
780
|
+
"bg-clip-border",
|
|
781
|
+
"bg-clip-padding",
|
|
782
|
+
"bg-clip-content",
|
|
783
|
+
"bg-clip-text",
|
|
784
|
+
"resize-none",
|
|
785
|
+
"resize-y",
|
|
786
|
+
"resize-x",
|
|
787
|
+
"box-border",
|
|
788
|
+
"box-content",
|
|
789
|
+
"gap-x",
|
|
790
|
+
"gap-y",
|
|
791
|
+
"inset-x",
|
|
792
|
+
"inset-y",
|
|
793
|
+
"divide-x",
|
|
794
|
+
"divide-y",
|
|
795
|
+
"space-x",
|
|
796
|
+
"space-y",
|
|
797
|
+
"translate-x",
|
|
798
|
+
"translate-y",
|
|
799
|
+
"scale-x",
|
|
800
|
+
"scale-y",
|
|
801
|
+
"skew-x",
|
|
802
|
+
"skew-y",
|
|
803
|
+
"origin-center",
|
|
804
|
+
"origin-top",
|
|
805
|
+
"origin-top-right",
|
|
806
|
+
"origin-right",
|
|
807
|
+
"origin-bottom-right",
|
|
808
|
+
"origin-bottom",
|
|
809
|
+
"origin-bottom-left",
|
|
810
|
+
"origin-left",
|
|
811
|
+
"origin-top-left",
|
|
812
|
+
"min-w",
|
|
813
|
+
"min-h",
|
|
814
|
+
"max-w",
|
|
815
|
+
"max-h",
|
|
816
|
+
"ring-offset",
|
|
817
|
+
"bg-opacity",
|
|
818
|
+
"text-opacity",
|
|
819
|
+
"border-opacity",
|
|
820
|
+
// Single-word prefixes last
|
|
821
|
+
"appearance-none",
|
|
822
|
+
"outline-none",
|
|
823
|
+
"outline",
|
|
824
|
+
"inline-flex",
|
|
825
|
+
"inline-block",
|
|
826
|
+
"inline-grid",
|
|
827
|
+
"italic",
|
|
828
|
+
"non-italic",
|
|
829
|
+
"underline",
|
|
830
|
+
"overline",
|
|
831
|
+
"line-through",
|
|
832
|
+
"no-underline",
|
|
833
|
+
"uppercase",
|
|
834
|
+
"lowercase",
|
|
835
|
+
"capitalize",
|
|
836
|
+
"normal-case",
|
|
837
|
+
"antialiased",
|
|
838
|
+
"truncate",
|
|
839
|
+
"sr-only",
|
|
840
|
+
"not-sr-only",
|
|
841
|
+
"relative",
|
|
842
|
+
"absolute",
|
|
843
|
+
"fixed",
|
|
844
|
+
"sticky",
|
|
845
|
+
"static",
|
|
846
|
+
"visible",
|
|
847
|
+
"invisible",
|
|
848
|
+
"hidden",
|
|
849
|
+
"contents",
|
|
850
|
+
"flow-root",
|
|
851
|
+
"block",
|
|
852
|
+
"inline",
|
|
853
|
+
"flex",
|
|
854
|
+
"grid",
|
|
855
|
+
"resize",
|
|
856
|
+
"appearance",
|
|
857
|
+
"border",
|
|
858
|
+
"rounded",
|
|
859
|
+
"shadow",
|
|
860
|
+
"opacity",
|
|
861
|
+
"leading",
|
|
862
|
+
"tracking",
|
|
863
|
+
"basis",
|
|
864
|
+
"grow",
|
|
865
|
+
"shrink",
|
|
866
|
+
"order",
|
|
867
|
+
"delay",
|
|
868
|
+
"duration",
|
|
869
|
+
"scale",
|
|
870
|
+
"rotate",
|
|
871
|
+
"aspect",
|
|
872
|
+
"columns",
|
|
873
|
+
"placeholder",
|
|
874
|
+
"ring",
|
|
875
|
+
"gap",
|
|
876
|
+
"inset",
|
|
877
|
+
"bg",
|
|
878
|
+
"text",
|
|
879
|
+
"font",
|
|
880
|
+
"from",
|
|
881
|
+
"via",
|
|
882
|
+
"to",
|
|
883
|
+
"divide",
|
|
884
|
+
"space",
|
|
885
|
+
"transition",
|
|
886
|
+
"px",
|
|
887
|
+
"py",
|
|
888
|
+
"pt",
|
|
889
|
+
"pr",
|
|
890
|
+
"pb",
|
|
891
|
+
"pl",
|
|
892
|
+
"p",
|
|
893
|
+
"mx",
|
|
894
|
+
"my",
|
|
895
|
+
"mt",
|
|
896
|
+
"mr",
|
|
897
|
+
"mb",
|
|
898
|
+
"ml",
|
|
899
|
+
"m",
|
|
900
|
+
"w",
|
|
901
|
+
"h",
|
|
902
|
+
"top",
|
|
903
|
+
"right",
|
|
904
|
+
"bottom",
|
|
905
|
+
"left",
|
|
906
|
+
"z",
|
|
907
|
+
"col",
|
|
908
|
+
"row",
|
|
909
|
+
"flex"
|
|
910
|
+
// also a standalone
|
|
911
|
+
];
|
|
912
|
+
var SORTED_PREFIXES = [...new Set(UTILITY_PREFIXES)].sort((a, b) => b.length - a.length);
|
|
913
|
+
var STANDALONE_UTILITIES = /* @__PURE__ */ new Set([
|
|
914
|
+
"flex",
|
|
915
|
+
"block",
|
|
916
|
+
"inline-block",
|
|
917
|
+
"inline",
|
|
918
|
+
"grid",
|
|
919
|
+
"inline-flex",
|
|
920
|
+
"inline-grid",
|
|
921
|
+
"hidden",
|
|
922
|
+
"contents",
|
|
923
|
+
"flow-root",
|
|
924
|
+
"relative",
|
|
925
|
+
"absolute",
|
|
926
|
+
"fixed",
|
|
927
|
+
"sticky",
|
|
928
|
+
"static",
|
|
929
|
+
"visible",
|
|
930
|
+
"invisible",
|
|
931
|
+
"uppercase",
|
|
932
|
+
"lowercase",
|
|
933
|
+
"capitalize",
|
|
934
|
+
"normal-case",
|
|
935
|
+
"italic",
|
|
936
|
+
"non-italic",
|
|
937
|
+
"underline",
|
|
938
|
+
"overline",
|
|
939
|
+
"line-through",
|
|
940
|
+
"no-underline",
|
|
941
|
+
"truncate",
|
|
942
|
+
"antialiased",
|
|
943
|
+
"sr-only",
|
|
944
|
+
"not-sr-only",
|
|
945
|
+
"flex-row",
|
|
946
|
+
"flex-col",
|
|
947
|
+
"flex-row-reverse",
|
|
948
|
+
"flex-col-reverse",
|
|
949
|
+
"flex-wrap",
|
|
950
|
+
"flex-wrap-reverse",
|
|
951
|
+
"flex-nowrap",
|
|
952
|
+
"flex-shrink",
|
|
953
|
+
"flex-shrink-0",
|
|
954
|
+
"flex-grow",
|
|
955
|
+
"flex-grow-0",
|
|
956
|
+
"items-start",
|
|
957
|
+
"items-end",
|
|
958
|
+
"items-center",
|
|
959
|
+
"items-baseline",
|
|
960
|
+
"items-stretch",
|
|
961
|
+
"justify-start",
|
|
962
|
+
"justify-end",
|
|
963
|
+
"justify-center",
|
|
964
|
+
"justify-between",
|
|
965
|
+
"justify-around",
|
|
966
|
+
"justify-evenly",
|
|
967
|
+
"content-start",
|
|
968
|
+
"content-end",
|
|
969
|
+
"content-center",
|
|
970
|
+
"content-between",
|
|
971
|
+
"content-around",
|
|
972
|
+
"content-evenly",
|
|
973
|
+
"self-start",
|
|
974
|
+
"self-end",
|
|
975
|
+
"self-center",
|
|
976
|
+
"self-auto",
|
|
977
|
+
"self-stretch",
|
|
978
|
+
"text-left",
|
|
979
|
+
"text-right",
|
|
980
|
+
"text-center",
|
|
981
|
+
"text-justify",
|
|
982
|
+
"font-thin",
|
|
983
|
+
"font-extralight",
|
|
984
|
+
"font-light",
|
|
985
|
+
"font-normal",
|
|
986
|
+
"font-medium",
|
|
987
|
+
"font-semibold",
|
|
988
|
+
"font-bold",
|
|
989
|
+
"font-extrabold",
|
|
990
|
+
"font-black",
|
|
991
|
+
"overflow-hidden",
|
|
992
|
+
"overflow-visible",
|
|
993
|
+
"overflow-scroll",
|
|
994
|
+
"overflow-auto",
|
|
995
|
+
"overflow-x-hidden",
|
|
996
|
+
"overflow-x-scroll",
|
|
997
|
+
"overflow-x-auto",
|
|
998
|
+
"overflow-y-hidden",
|
|
999
|
+
"overflow-y-scroll",
|
|
1000
|
+
"overflow-y-auto",
|
|
1001
|
+
"object-contain",
|
|
1002
|
+
"object-cover",
|
|
1003
|
+
"object-fill",
|
|
1004
|
+
"object-none",
|
|
1005
|
+
"object-scale-down",
|
|
1006
|
+
"border-solid",
|
|
1007
|
+
"border-dashed",
|
|
1008
|
+
"border-dotted",
|
|
1009
|
+
"border-none",
|
|
1010
|
+
"border-t",
|
|
1011
|
+
"border-r",
|
|
1012
|
+
"border-b",
|
|
1013
|
+
"border-l",
|
|
1014
|
+
"list-none",
|
|
1015
|
+
"list-disc",
|
|
1016
|
+
"list-decimal",
|
|
1017
|
+
"cursor-auto",
|
|
1018
|
+
"cursor-default",
|
|
1019
|
+
"cursor-pointer",
|
|
1020
|
+
"cursor-wait",
|
|
1021
|
+
"cursor-text",
|
|
1022
|
+
"cursor-move",
|
|
1023
|
+
"cursor-not-allowed",
|
|
1024
|
+
"select-none",
|
|
1025
|
+
"select-text",
|
|
1026
|
+
"select-all",
|
|
1027
|
+
"select-auto",
|
|
1028
|
+
"pointer-events-none",
|
|
1029
|
+
"pointer-events-auto",
|
|
1030
|
+
"whitespace-normal",
|
|
1031
|
+
"whitespace-nowrap",
|
|
1032
|
+
"whitespace-pre",
|
|
1033
|
+
"whitespace-pre-wrap",
|
|
1034
|
+
"whitespace-pre-line",
|
|
1035
|
+
"break-normal",
|
|
1036
|
+
"break-words",
|
|
1037
|
+
"break-all",
|
|
1038
|
+
"bg-clip-border",
|
|
1039
|
+
"bg-clip-padding",
|
|
1040
|
+
"bg-clip-content",
|
|
1041
|
+
"bg-clip-text",
|
|
1042
|
+
"box-border",
|
|
1043
|
+
"box-content",
|
|
1044
|
+
"resize",
|
|
1045
|
+
"resize-none",
|
|
1046
|
+
"resize-y",
|
|
1047
|
+
"resize-x",
|
|
1048
|
+
"appearance-none",
|
|
1049
|
+
"outline-none",
|
|
1050
|
+
"outline"
|
|
1051
|
+
]);
|
|
1052
|
+
function parseClass(className) {
|
|
1053
|
+
const trimmed = className.trim();
|
|
1054
|
+
if (!trimmed) return null;
|
|
1055
|
+
const modifiers = [];
|
|
1056
|
+
let remaining = trimmed;
|
|
1057
|
+
for (let i = 0; i < 3; i++) {
|
|
1058
|
+
const colonIdx = findOuterColon(remaining);
|
|
1059
|
+
if (colonIdx === -1) break;
|
|
1060
|
+
const candidate = remaining.slice(0, colonIdx);
|
|
1061
|
+
if (MODIFIERS.has(candidate)) {
|
|
1062
|
+
modifiers.push(candidate);
|
|
1063
|
+
remaining = remaining.slice(colonIdx + 1);
|
|
1064
|
+
} else {
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
let negative = false;
|
|
1069
|
+
if (remaining.startsWith("-") && remaining.length > 1 && remaining[1] !== "-") {
|
|
1070
|
+
negative = true;
|
|
1071
|
+
remaining = remaining.slice(1);
|
|
1072
|
+
}
|
|
1073
|
+
const bracketStart = remaining.lastIndexOf("-[");
|
|
1074
|
+
if (bracketStart > 0 && remaining.endsWith("]")) {
|
|
1075
|
+
const utility = remaining.slice(0, bracketStart);
|
|
1076
|
+
const value = remaining.slice(bracketStart + 2, -1);
|
|
1077
|
+
return { original: trimmed, modifiers, negative, utility, value, isArbitrary: true };
|
|
1078
|
+
}
|
|
1079
|
+
if (STANDALONE_UTILITIES.has(remaining)) {
|
|
1080
|
+
return { original: trimmed, modifiers, negative, utility: remaining, value: "", isArbitrary: false };
|
|
1081
|
+
}
|
|
1082
|
+
for (const prefix of SORTED_PREFIXES) {
|
|
1083
|
+
if (remaining === prefix) {
|
|
1084
|
+
return { original: trimmed, modifiers, negative, utility: prefix, value: "", isArbitrary: false };
|
|
1085
|
+
}
|
|
1086
|
+
if (remaining.startsWith(prefix + "-")) {
|
|
1087
|
+
const value = remaining.slice(prefix.length + 1);
|
|
1088
|
+
return { original: trimmed, modifiers, negative, utility: prefix, value, isArbitrary: false };
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
const firstDash = remaining.indexOf("-");
|
|
1092
|
+
if (firstDash > 0) {
|
|
1093
|
+
return {
|
|
1094
|
+
original: trimmed,
|
|
1095
|
+
modifiers,
|
|
1096
|
+
negative,
|
|
1097
|
+
utility: remaining.slice(0, firstDash),
|
|
1098
|
+
value: remaining.slice(firstDash + 1),
|
|
1099
|
+
isArbitrary: false
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
return { original: trimmed, modifiers, negative, utility: remaining, value: "", isArbitrary: false };
|
|
1103
|
+
}
|
|
1104
|
+
function parseClasses(classString) {
|
|
1105
|
+
const results = [];
|
|
1106
|
+
for (const token of classString.split(/\s+/)) {
|
|
1107
|
+
if (!token) continue;
|
|
1108
|
+
const parsed = parseClass(token);
|
|
1109
|
+
if (parsed) results.push(parsed);
|
|
1110
|
+
}
|
|
1111
|
+
return results;
|
|
1112
|
+
}
|
|
1113
|
+
function findOuterColon(s) {
|
|
1114
|
+
let depth = 0;
|
|
1115
|
+
for (let i = 0; i < s.length; i++) {
|
|
1116
|
+
const ch = s[i];
|
|
1117
|
+
if (ch === "[") depth++;
|
|
1118
|
+
else if (ch === "]") depth--;
|
|
1119
|
+
else if (ch === ":" && depth === 0) return i;
|
|
1120
|
+
}
|
|
1121
|
+
return -1;
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
// src/core/utilities.ts
|
|
1125
|
+
function resolveColor(value, colors, isArbitrary) {
|
|
1126
|
+
if (isArbitrary) return value;
|
|
1127
|
+
const slashIdx = value.indexOf("/");
|
|
1128
|
+
const colorPart = slashIdx > 0 ? value.slice(0, slashIdx) : value;
|
|
1129
|
+
const opacityPart = slashIdx > 0 ? value.slice(slashIdx + 1) : null;
|
|
1130
|
+
let hex = null;
|
|
1131
|
+
if (colorPart in colors) {
|
|
1132
|
+
const entry = colors[colorPart];
|
|
1133
|
+
if (typeof entry === "string") hex = entry;
|
|
1134
|
+
else if (typeof entry === "object" && "6" in entry) hex = entry["6"];
|
|
1135
|
+
} else {
|
|
1136
|
+
const lastDash = colorPart.lastIndexOf("-");
|
|
1137
|
+
if (lastDash > 0) {
|
|
1138
|
+
const colorName = colorPart.slice(0, lastDash);
|
|
1139
|
+
const shade = colorPart.slice(lastDash + 1);
|
|
1140
|
+
const scale = colors[colorName];
|
|
1141
|
+
if (scale && typeof scale === "object" && shade in scale) {
|
|
1142
|
+
hex = scale[shade] ?? null;
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
if (!hex) return null;
|
|
1147
|
+
if (!opacityPart) return hex;
|
|
1148
|
+
let alpha;
|
|
1149
|
+
if (opacityPart.startsWith("[") && opacityPart.endsWith("]")) {
|
|
1150
|
+
const v = parseFloat(opacityPart.slice(1, -1));
|
|
1151
|
+
alpha = v > 1 ? v / 100 : v;
|
|
1152
|
+
} else {
|
|
1153
|
+
alpha = parseFloat(opacityPart) / 100;
|
|
1154
|
+
}
|
|
1155
|
+
if (isNaN(alpha)) return hex;
|
|
1156
|
+
return hexToRgba(hex, alpha);
|
|
1157
|
+
}
|
|
1158
|
+
function hexToRgba(hex, alpha) {
|
|
1159
|
+
const h = hex.replace("#", "");
|
|
1160
|
+
let r, g, b;
|
|
1161
|
+
if (h.length === 3) {
|
|
1162
|
+
r = parseInt(h[0] + h[0], 16);
|
|
1163
|
+
g = parseInt(h[1] + h[1], 16);
|
|
1164
|
+
b = parseInt(h[2] + h[2], 16);
|
|
1165
|
+
} else {
|
|
1166
|
+
r = parseInt(h.slice(0, 2), 16);
|
|
1167
|
+
g = parseInt(h.slice(2, 4), 16);
|
|
1168
|
+
b = parseInt(h.slice(4, 6), 16);
|
|
1169
|
+
}
|
|
1170
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
1171
|
+
}
|
|
1172
|
+
function resolveSpacing(value, negative, spacing, isArbitrary) {
|
|
1173
|
+
if (isArbitrary) {
|
|
1174
|
+
const resolved = isWeb ? value : toNativeValue(value);
|
|
1175
|
+
return negative && typeof resolved === "number" ? -resolved : resolved;
|
|
1176
|
+
}
|
|
1177
|
+
const raw = spacing[value];
|
|
1178
|
+
if (raw === void 0) return null;
|
|
1179
|
+
if (typeof raw === "number") return negative ? -raw : raw;
|
|
1180
|
+
if (raw === "auto") return "auto";
|
|
1181
|
+
if (negative && typeof raw === "string" && raw.endsWith("%")) {
|
|
1182
|
+
return `-${raw}`;
|
|
1183
|
+
}
|
|
1184
|
+
return raw;
|
|
1185
|
+
}
|
|
1186
|
+
function resolveSizing(value, spacing, isArbitrary) {
|
|
1187
|
+
if (isArbitrary) return isWeb ? value : toNativeValue(value);
|
|
1188
|
+
const raw = spacing[value];
|
|
1189
|
+
if (raw !== void 0) return raw;
|
|
1190
|
+
if (/^\d+\/\d+$/.test(value)) {
|
|
1191
|
+
const [num, den] = value.split("/").map(Number);
|
|
1192
|
+
return `${(num / den * 100).toFixed(6)}%`;
|
|
1193
|
+
}
|
|
1194
|
+
return null;
|
|
1195
|
+
}
|
|
1196
|
+
function resolveRadius(value, radii, isArbitrary) {
|
|
1197
|
+
if (isArbitrary) return isWeb ? value : toNativeValue(value);
|
|
1198
|
+
const key = value === "" ? "DEFAULT" : value;
|
|
1199
|
+
return radii[key] ?? null;
|
|
1200
|
+
}
|
|
1201
|
+
function resolveFontSize(value, fontSizes, isArbitrary) {
|
|
1202
|
+
if (isArbitrary) return isWeb ? value : toNativeValue(value);
|
|
1203
|
+
return fontSizes[value] ?? null;
|
|
1204
|
+
}
|
|
1205
|
+
var STANDALONE = {
|
|
1206
|
+
// Display
|
|
1207
|
+
flex: { display: "flex" },
|
|
1208
|
+
block: { display: "block" },
|
|
1209
|
+
"inline-block": { display: "inline-block" },
|
|
1210
|
+
inline: { display: "inline" },
|
|
1211
|
+
grid: { display: "grid" },
|
|
1212
|
+
"inline-flex": { display: "inline-flex" },
|
|
1213
|
+
"inline-grid": { display: "inline-grid" },
|
|
1214
|
+
hidden: { display: "none" },
|
|
1215
|
+
contents: { display: "contents" },
|
|
1216
|
+
"flow-root": { display: "flow-root" },
|
|
1217
|
+
// Flex direction
|
|
1218
|
+
"flex-row": { flexDirection: "row" },
|
|
1219
|
+
"flex-col": { flexDirection: "column" },
|
|
1220
|
+
"flex-row-reverse": { flexDirection: "row-reverse" },
|
|
1221
|
+
"flex-col-reverse": { flexDirection: "column-reverse" },
|
|
1222
|
+
// Flex wrap
|
|
1223
|
+
"flex-wrap": { flexWrap: "wrap" },
|
|
1224
|
+
"flex-wrap-reverse": { flexWrap: "wrap-reverse" },
|
|
1225
|
+
"flex-nowrap": { flexWrap: "nowrap" },
|
|
1226
|
+
// Flex grow / shrink
|
|
1227
|
+
"flex-grow": { flexGrow: 1 },
|
|
1228
|
+
"flex-grow-0": { flexGrow: 0 },
|
|
1229
|
+
"flex-shrink": { flexShrink: 1 },
|
|
1230
|
+
"flex-shrink-0": { flexShrink: 0 },
|
|
1231
|
+
// Align items
|
|
1232
|
+
"items-start": { alignItems: "flex-start" },
|
|
1233
|
+
"items-end": { alignItems: "flex-end" },
|
|
1234
|
+
"items-center": { alignItems: "center" },
|
|
1235
|
+
"items-baseline": { alignItems: "baseline" },
|
|
1236
|
+
"items-stretch": { alignItems: "stretch" },
|
|
1237
|
+
// Justify content
|
|
1238
|
+
"justify-start": { justifyContent: "flex-start" },
|
|
1239
|
+
"justify-end": { justifyContent: "flex-end" },
|
|
1240
|
+
"justify-center": { justifyContent: "center" },
|
|
1241
|
+
"justify-between": { justifyContent: "space-between" },
|
|
1242
|
+
"justify-around": { justifyContent: "space-around" },
|
|
1243
|
+
"justify-evenly": { justifyContent: "space-evenly" },
|
|
1244
|
+
// Align content
|
|
1245
|
+
"content-start": { alignContent: "flex-start" },
|
|
1246
|
+
"content-end": { alignContent: "flex-end" },
|
|
1247
|
+
"content-center": { alignContent: "center" },
|
|
1248
|
+
"content-between": { alignContent: "space-between" },
|
|
1249
|
+
"content-around": { alignContent: "space-around" },
|
|
1250
|
+
"content-evenly": { alignContent: "space-evenly" },
|
|
1251
|
+
// Align self
|
|
1252
|
+
"self-auto": { alignSelf: "auto" },
|
|
1253
|
+
"self-start": { alignSelf: "flex-start" },
|
|
1254
|
+
"self-end": { alignSelf: "flex-end" },
|
|
1255
|
+
"self-center": { alignSelf: "center" },
|
|
1256
|
+
"self-stretch": { alignSelf: "stretch" },
|
|
1257
|
+
// Text align
|
|
1258
|
+
"text-left": { textAlign: "left" },
|
|
1259
|
+
"text-right": { textAlign: "right" },
|
|
1260
|
+
"text-center": { textAlign: "center" },
|
|
1261
|
+
"text-justify": { textAlign: "justify" },
|
|
1262
|
+
// Font weight shortcuts
|
|
1263
|
+
"font-thin": { fontWeight: "100" },
|
|
1264
|
+
"font-extralight": { fontWeight: "200" },
|
|
1265
|
+
"font-light": { fontWeight: "300" },
|
|
1266
|
+
"font-normal": { fontWeight: "400" },
|
|
1267
|
+
"font-medium": { fontWeight: "500" },
|
|
1268
|
+
"font-semibold": { fontWeight: "600" },
|
|
1269
|
+
"font-bold": { fontWeight: "700" },
|
|
1270
|
+
"font-extrabold": { fontWeight: "800" },
|
|
1271
|
+
"font-black": { fontWeight: "900" },
|
|
1272
|
+
// Text decoration
|
|
1273
|
+
underline: { textDecorationLine: "underline" },
|
|
1274
|
+
overline: { textDecorationLine: "overline" },
|
|
1275
|
+
"line-through": { textDecorationLine: "line-through" },
|
|
1276
|
+
"no-underline": { textDecorationLine: "none" },
|
|
1277
|
+
// Text transform
|
|
1278
|
+
uppercase: { textTransform: "uppercase" },
|
|
1279
|
+
lowercase: { textTransform: "lowercase" },
|
|
1280
|
+
capitalize: { textTransform: "capitalize" },
|
|
1281
|
+
"normal-case": { textTransform: "none" },
|
|
1282
|
+
// Font style
|
|
1283
|
+
italic: { fontStyle: "italic" },
|
|
1284
|
+
"non-italic": { fontStyle: "normal" },
|
|
1285
|
+
// Position
|
|
1286
|
+
relative: { position: "relative" },
|
|
1287
|
+
absolute: { position: "absolute" },
|
|
1288
|
+
fixed: { position: "fixed" },
|
|
1289
|
+
sticky: { position: "sticky" },
|
|
1290
|
+
static: { position: "static" },
|
|
1291
|
+
// Visibility
|
|
1292
|
+
visible: { visibility: "visible" },
|
|
1293
|
+
invisible: { visibility: "hidden" },
|
|
1294
|
+
// Overflow
|
|
1295
|
+
"overflow-hidden": { overflow: "hidden" },
|
|
1296
|
+
"overflow-visible": { overflow: "visible" },
|
|
1297
|
+
"overflow-scroll": { overflow: "scroll" },
|
|
1298
|
+
"overflow-auto": { overflow: "auto" },
|
|
1299
|
+
"overflow-x-hidden": { overflowX: "hidden" },
|
|
1300
|
+
"overflow-x-scroll": { overflowX: "scroll" },
|
|
1301
|
+
"overflow-x-auto": { overflowX: "auto" },
|
|
1302
|
+
"overflow-y-hidden": { overflowY: "hidden" },
|
|
1303
|
+
"overflow-y-scroll": { overflowY: "scroll" },
|
|
1304
|
+
"overflow-y-auto": { overflowY: "auto" },
|
|
1305
|
+
// Object fit
|
|
1306
|
+
"object-contain": { objectFit: "contain" },
|
|
1307
|
+
"object-cover": { objectFit: "cover" },
|
|
1308
|
+
"object-fill": { objectFit: "fill" },
|
|
1309
|
+
"object-none": { objectFit: "none" },
|
|
1310
|
+
"object-scale-down": { objectFit: "scale-down" },
|
|
1311
|
+
// Border style
|
|
1312
|
+
"border-solid": { borderStyle: "solid" },
|
|
1313
|
+
"border-dashed": { borderStyle: "dashed" },
|
|
1314
|
+
"border-dotted": { borderStyle: "dotted" },
|
|
1315
|
+
"border-none": { borderWidth: 0 },
|
|
1316
|
+
// Border sides (default width 1)
|
|
1317
|
+
"border-t": { borderTopWidth: 1 },
|
|
1318
|
+
"border-r": { borderRightWidth: 1 },
|
|
1319
|
+
"border-b": { borderBottomWidth: 1 },
|
|
1320
|
+
"border-l": { borderLeftWidth: 1 },
|
|
1321
|
+
// Cursor
|
|
1322
|
+
"cursor-auto": { cursor: "auto" },
|
|
1323
|
+
"cursor-default": { cursor: "default" },
|
|
1324
|
+
"cursor-pointer": { cursor: "pointer" },
|
|
1325
|
+
"cursor-wait": { cursor: "wait" },
|
|
1326
|
+
"cursor-text": { cursor: "text" },
|
|
1327
|
+
"cursor-move": { cursor: "move" },
|
|
1328
|
+
"cursor-not-allowed": { cursor: "not-allowed" },
|
|
1329
|
+
// Select
|
|
1330
|
+
"select-none": { userSelect: "none" },
|
|
1331
|
+
"select-text": { userSelect: "text" },
|
|
1332
|
+
"select-all": { userSelect: "all" },
|
|
1333
|
+
"select-auto": { userSelect: "auto" },
|
|
1334
|
+
// Pointer events
|
|
1335
|
+
"pointer-events-none": { pointerEvents: "none" },
|
|
1336
|
+
"pointer-events-auto": { pointerEvents: "auto" },
|
|
1337
|
+
// Whitespace
|
|
1338
|
+
"whitespace-normal": { whiteSpace: "normal" },
|
|
1339
|
+
"whitespace-nowrap": { whiteSpace: "nowrap" },
|
|
1340
|
+
"whitespace-pre": { whiteSpace: "pre" },
|
|
1341
|
+
"whitespace-pre-wrap": { whiteSpace: "pre-wrap" },
|
|
1342
|
+
"whitespace-pre-line": { whiteSpace: "pre-line" },
|
|
1343
|
+
// Word break
|
|
1344
|
+
"break-normal": { overflowWrap: "normal", wordBreak: "normal" },
|
|
1345
|
+
"break-words": { overflowWrap: "break-word" },
|
|
1346
|
+
"break-all": { wordBreak: "break-all" },
|
|
1347
|
+
// Misc
|
|
1348
|
+
truncate: { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
|
|
1349
|
+
"box-border": { boxSizing: "border-box" },
|
|
1350
|
+
"box-content": { boxSizing: "content-box" },
|
|
1351
|
+
"appearance-none": { appearance: "none" },
|
|
1352
|
+
"outline-none": { outline: "none", outlineOffset: "0" },
|
|
1353
|
+
outline: { outline: "2px solid transparent", outlineOffset: "2px" },
|
|
1354
|
+
resize: { resize: "both" },
|
|
1355
|
+
"resize-none": { resize: "none" },
|
|
1356
|
+
"resize-y": { resize: "vertical" },
|
|
1357
|
+
"resize-x": { resize: "horizontal" },
|
|
1358
|
+
antialiased: { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" },
|
|
1359
|
+
"sr-only": {
|
|
1360
|
+
position: "absolute",
|
|
1361
|
+
width: 1,
|
|
1362
|
+
height: 1,
|
|
1363
|
+
padding: 0,
|
|
1364
|
+
margin: -1,
|
|
1365
|
+
overflow: "hidden",
|
|
1366
|
+
clip: "rect(0,0,0,0)",
|
|
1367
|
+
whiteSpace: "nowrap",
|
|
1368
|
+
border: 0
|
|
1369
|
+
},
|
|
1370
|
+
"not-sr-only": {
|
|
1371
|
+
position: "static",
|
|
1372
|
+
width: "auto",
|
|
1373
|
+
height: "auto",
|
|
1374
|
+
padding: 0,
|
|
1375
|
+
margin: 0,
|
|
1376
|
+
overflow: "visible",
|
|
1377
|
+
clip: "auto",
|
|
1378
|
+
whiteSpace: "normal"
|
|
1379
|
+
},
|
|
1380
|
+
// Lists
|
|
1381
|
+
"list-none": { listStyleType: "none" },
|
|
1382
|
+
"list-disc": { listStyleType: "disc" },
|
|
1383
|
+
"list-decimal": { listStyleType: "decimal" },
|
|
1384
|
+
// Background clip
|
|
1385
|
+
"bg-clip-border": { backgroundClip: "border-box" },
|
|
1386
|
+
"bg-clip-padding": { backgroundClip: "padding-box" },
|
|
1387
|
+
"bg-clip-content": { backgroundClip: "content-box" },
|
|
1388
|
+
"bg-clip-text": { backgroundClip: "text", WebkitBackgroundClip: "text" }
|
|
1389
|
+
};
|
|
1390
|
+
var RESOLVERS = {
|
|
1391
|
+
// ── Background ─────────────────────────────────────────────────────────────
|
|
1392
|
+
bg: ({ value, isArbitrary }, { colors }) => {
|
|
1393
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1394
|
+
return color ? { backgroundColor: color } : null;
|
|
1395
|
+
},
|
|
1396
|
+
"bg-opacity": ({ value, isArbitrary }, _) => {
|
|
1397
|
+
const v = isArbitrary ? parseFloat(value) / 100 : parseFloat(value) / 100;
|
|
1398
|
+
return isNaN(v) ? null : { "--bg-opacity": v };
|
|
1399
|
+
},
|
|
1400
|
+
// ── Text ───────────────────────────────────────────────────────────────────
|
|
1401
|
+
text: ({ value, isArbitrary }, { colors, fontSize }) => {
|
|
1402
|
+
const size = resolveFontSize(value, fontSize, false);
|
|
1403
|
+
if (!isArbitrary && size !== null) return { fontSize: size };
|
|
1404
|
+
if (isArbitrary) {
|
|
1405
|
+
if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
|
|
1406
|
+
return { fontSize: isWeb ? value : toNativeValue(value) };
|
|
1407
|
+
}
|
|
1408
|
+
return { color: value };
|
|
1409
|
+
}
|
|
1410
|
+
const color = resolveColor(value, colors, false);
|
|
1411
|
+
return color ? { color } : null;
|
|
1412
|
+
},
|
|
1413
|
+
"text-opacity": ({ value }, _) => {
|
|
1414
|
+
const v = parseFloat(value) / 100;
|
|
1415
|
+
return isNaN(v) ? null : { "--text-opacity": v };
|
|
1416
|
+
},
|
|
1417
|
+
// ── Padding ────────────────────────────────────────────────────────────────
|
|
1418
|
+
p: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1419
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1420
|
+
return v !== null ? { padding: v } : null;
|
|
1421
|
+
},
|
|
1422
|
+
px: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1423
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1424
|
+
return v !== null ? { paddingHorizontal: v } : null;
|
|
1425
|
+
},
|
|
1426
|
+
py: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1427
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1428
|
+
return v !== null ? { paddingVertical: v } : null;
|
|
1429
|
+
},
|
|
1430
|
+
pt: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1431
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1432
|
+
return v !== null ? { paddingTop: v } : null;
|
|
1433
|
+
},
|
|
1434
|
+
pr: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1435
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1436
|
+
return v !== null ? { paddingRight: v } : null;
|
|
1437
|
+
},
|
|
1438
|
+
pb: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1439
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1440
|
+
return v !== null ? { paddingBottom: v } : null;
|
|
1441
|
+
},
|
|
1442
|
+
pl: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1443
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1444
|
+
return v !== null ? { paddingLeft: v } : null;
|
|
1445
|
+
},
|
|
1446
|
+
// ── Margin ─────────────────────────────────────────────────────────────────
|
|
1447
|
+
m: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1448
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1449
|
+
return v !== null ? { margin: v } : null;
|
|
1450
|
+
},
|
|
1451
|
+
mx: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1452
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1453
|
+
return v !== null ? { marginHorizontal: v } : null;
|
|
1454
|
+
},
|
|
1455
|
+
my: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1456
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1457
|
+
return v !== null ? { marginVertical: v } : null;
|
|
1458
|
+
},
|
|
1459
|
+
mt: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1460
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1461
|
+
return v !== null ? { marginTop: v } : null;
|
|
1462
|
+
},
|
|
1463
|
+
mr: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1464
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1465
|
+
return v !== null ? { marginRight: v } : null;
|
|
1466
|
+
},
|
|
1467
|
+
mb: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1468
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1469
|
+
return v !== null ? { marginBottom: v } : null;
|
|
1470
|
+
},
|
|
1471
|
+
ml: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1472
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1473
|
+
return v !== null ? { marginLeft: v } : null;
|
|
1474
|
+
},
|
|
1475
|
+
// ── Sizing ─────────────────────────────────────────────────────────────────
|
|
1476
|
+
w: ({ value, isArbitrary }, { spacing }) => {
|
|
1477
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1478
|
+
return v !== null ? { width: v } : null;
|
|
1479
|
+
},
|
|
1480
|
+
h: ({ value, isArbitrary }, { spacing }) => {
|
|
1481
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1482
|
+
return v !== null ? { height: v } : null;
|
|
1483
|
+
},
|
|
1484
|
+
"min-w": ({ value, isArbitrary }, { spacing }) => {
|
|
1485
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1486
|
+
return v !== null ? { minWidth: v } : null;
|
|
1487
|
+
},
|
|
1488
|
+
"min-h": ({ value, isArbitrary }, { spacing }) => {
|
|
1489
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1490
|
+
return v !== null ? { minHeight: v } : null;
|
|
1491
|
+
},
|
|
1492
|
+
"max-w": ({ value, isArbitrary }, { spacing }) => {
|
|
1493
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1494
|
+
return v !== null ? { maxWidth: v } : null;
|
|
1495
|
+
},
|
|
1496
|
+
"max-h": ({ value, isArbitrary }, { spacing }) => {
|
|
1497
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1498
|
+
return v !== null ? { maxHeight: v } : null;
|
|
1499
|
+
},
|
|
1500
|
+
// ── Border width ───────────────────────────────────────────────────────────
|
|
1501
|
+
border: ({ value, isArbitrary }, { colors, borderWidth, spacing }) => {
|
|
1502
|
+
if (!value) return { borderWidth: borderWidth["DEFAULT"] ?? 1 };
|
|
1503
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1504
|
+
if (color) return { borderColor: color };
|
|
1505
|
+
if (isArbitrary) {
|
|
1506
|
+
const w2 = toNativeValue(value);
|
|
1507
|
+
return { borderWidth: typeof w2 === "number" ? w2 : 1 };
|
|
1508
|
+
}
|
|
1509
|
+
const w = borderWidth[value] ?? spacing[value];
|
|
1510
|
+
if (w !== void 0) return { borderWidth: typeof w === "number" ? w : parseFloat(String(w)) };
|
|
1511
|
+
return null;
|
|
1512
|
+
},
|
|
1513
|
+
"border-t": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1514
|
+
if (!value) return { borderTopWidth: 1 };
|
|
1515
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1516
|
+
if (color) return { borderTopColor: color };
|
|
1517
|
+
const w = borderWidth[value] ?? (isArbitrary ? toNativeValue(value) : null);
|
|
1518
|
+
return w !== null ? { borderTopWidth: typeof w === "number" ? w : parseFloat(String(w)) } : null;
|
|
1519
|
+
},
|
|
1520
|
+
"border-r": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1521
|
+
if (!value) return { borderRightWidth: 1 };
|
|
1522
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1523
|
+
if (color) return { borderRightColor: color };
|
|
1524
|
+
const w = borderWidth[value] ?? (isArbitrary ? toNativeValue(value) : null);
|
|
1525
|
+
return w !== null ? { borderRightWidth: typeof w === "number" ? w : parseFloat(String(w)) } : null;
|
|
1526
|
+
},
|
|
1527
|
+
"border-b": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1528
|
+
if (!value) return { borderBottomWidth: 1 };
|
|
1529
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1530
|
+
if (color) return { borderBottomColor: color };
|
|
1531
|
+
const w = borderWidth[value] ?? (isArbitrary ? toNativeValue(value) : null);
|
|
1532
|
+
return w !== null ? { borderBottomWidth: typeof w === "number" ? w : parseFloat(String(w)) } : null;
|
|
1533
|
+
},
|
|
1534
|
+
"border-l": ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1535
|
+
if (!value) return { borderLeftWidth: 1 };
|
|
1536
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1537
|
+
if (color) return { borderLeftColor: color };
|
|
1538
|
+
const w = borderWidth[value] ?? (isArbitrary ? toNativeValue(value) : null);
|
|
1539
|
+
return w !== null ? { borderLeftWidth: typeof w === "number" ? w : parseFloat(String(w)) } : null;
|
|
1540
|
+
},
|
|
1541
|
+
// ── Border radius ──────────────────────────────────────────────────────────
|
|
1542
|
+
rounded: ({ value, isArbitrary }, { borderRadius }) => {
|
|
1543
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1544
|
+
return r !== null ? { borderRadius: r } : null;
|
|
1545
|
+
},
|
|
1546
|
+
"rounded-t": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1547
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1548
|
+
return r !== null ? { borderTopLeftRadius: r, borderTopRightRadius: r } : null;
|
|
1549
|
+
},
|
|
1550
|
+
"rounded-r": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1551
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1552
|
+
return r !== null ? { borderTopRightRadius: r, borderBottomRightRadius: r } : null;
|
|
1553
|
+
},
|
|
1554
|
+
"rounded-b": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1555
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1556
|
+
return r !== null ? { borderBottomLeftRadius: r, borderBottomRightRadius: r } : null;
|
|
1557
|
+
},
|
|
1558
|
+
"rounded-l": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1559
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1560
|
+
return r !== null ? { borderTopLeftRadius: r, borderBottomLeftRadius: r } : null;
|
|
1561
|
+
},
|
|
1562
|
+
"rounded-tl": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1563
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1564
|
+
return r !== null ? { borderTopLeftRadius: r } : null;
|
|
1565
|
+
},
|
|
1566
|
+
"rounded-tr": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1567
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1568
|
+
return r !== null ? { borderTopRightRadius: r } : null;
|
|
1569
|
+
},
|
|
1570
|
+
"rounded-bl": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1571
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1572
|
+
return r !== null ? { borderBottomLeftRadius: r } : null;
|
|
1573
|
+
},
|
|
1574
|
+
"rounded-br": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1575
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1576
|
+
return r !== null ? { borderBottomRightRadius: r } : null;
|
|
1577
|
+
},
|
|
1578
|
+
// ── Flex ───────────────────────────────────────────────────────────────────
|
|
1579
|
+
flex: ({ value, isArbitrary }, { flex, spacing }) => {
|
|
1580
|
+
if (!value) return { display: "flex" };
|
|
1581
|
+
if (isArbitrary) {
|
|
1582
|
+
const v = parseFloat(value);
|
|
1583
|
+
return isNaN(v) ? null : { flex: v };
|
|
1584
|
+
}
|
|
1585
|
+
if (value in flex) return { flex: flex[value] };
|
|
1586
|
+
const n = parseFloat(value);
|
|
1587
|
+
return isNaN(n) ? null : { flex: n };
|
|
1588
|
+
},
|
|
1589
|
+
basis: ({ value, isArbitrary }, { spacing }) => {
|
|
1590
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1591
|
+
return v !== null ? { flexBasis: v } : null;
|
|
1592
|
+
},
|
|
1593
|
+
grow: ({ value }, _) => {
|
|
1594
|
+
if (!value) return { flexGrow: 1 };
|
|
1595
|
+
const n = parseFloat(value);
|
|
1596
|
+
return { flexGrow: isNaN(n) ? 1 : n };
|
|
1597
|
+
},
|
|
1598
|
+
shrink: ({ value }, _) => {
|
|
1599
|
+
if (!value) return { flexShrink: 1 };
|
|
1600
|
+
const n = parseFloat(value);
|
|
1601
|
+
return { flexShrink: isNaN(n) ? 1 : n };
|
|
1602
|
+
},
|
|
1603
|
+
order: ({ value, isArbitrary }, _) => {
|
|
1604
|
+
if (isArbitrary) return { order: parseInt(value) };
|
|
1605
|
+
const n = parseInt(value);
|
|
1606
|
+
return isNaN(n) ? null : { order: n };
|
|
1607
|
+
},
|
|
1608
|
+
// ── Gap ────────────────────────────────────────────────────────────────────
|
|
1609
|
+
gap: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1610
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1611
|
+
return v !== null ? { gap: v } : null;
|
|
1612
|
+
},
|
|
1613
|
+
"gap-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1614
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1615
|
+
return v !== null ? { columnGap: v } : null;
|
|
1616
|
+
},
|
|
1617
|
+
"gap-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1618
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1619
|
+
return v !== null ? { rowGap: v } : null;
|
|
1620
|
+
},
|
|
1621
|
+
// ── Position ───────────────────────────────────────────────────────────────
|
|
1622
|
+
top: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1623
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1624
|
+
return v !== null ? { top: v } : null;
|
|
1625
|
+
},
|
|
1626
|
+
right: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1627
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1628
|
+
return v !== null ? { right: v } : null;
|
|
1629
|
+
},
|
|
1630
|
+
bottom: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1631
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1632
|
+
return v !== null ? { bottom: v } : null;
|
|
1633
|
+
},
|
|
1634
|
+
left: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1635
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1636
|
+
return v !== null ? { left: v } : null;
|
|
1637
|
+
},
|
|
1638
|
+
inset: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1639
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1640
|
+
return v !== null ? { top: v, right: v, bottom: v, left: v } : null;
|
|
1641
|
+
},
|
|
1642
|
+
"inset-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1643
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1644
|
+
return v !== null ? { left: v, right: v } : null;
|
|
1645
|
+
},
|
|
1646
|
+
"inset-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1647
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1648
|
+
return v !== null ? { top: v, bottom: v } : null;
|
|
1649
|
+
},
|
|
1650
|
+
// ── Z-index ────────────────────────────────────────────────────────────────
|
|
1651
|
+
z: ({ value, isArbitrary }, { zIndex }) => {
|
|
1652
|
+
if (isArbitrary) return { zIndex: parseInt(value) };
|
|
1653
|
+
const v = zIndex[value];
|
|
1654
|
+
if (v !== void 0) return { zIndex: v };
|
|
1655
|
+
const n = parseInt(value);
|
|
1656
|
+
return isNaN(n) ? null : { zIndex: n };
|
|
1657
|
+
},
|
|
1658
|
+
// ── Opacity ────────────────────────────────────────────────────────────────
|
|
1659
|
+
opacity: ({ value, isArbitrary }, { opacity }) => {
|
|
1660
|
+
if (isArbitrary) {
|
|
1661
|
+
const v2 = parseFloat(value);
|
|
1662
|
+
return isNaN(v2) ? null : { opacity: v2 > 1 ? v2 / 100 : v2 };
|
|
1663
|
+
}
|
|
1664
|
+
const v = opacity[value];
|
|
1665
|
+
if (v !== void 0) return { opacity: v };
|
|
1666
|
+
const n = parseFloat(value);
|
|
1667
|
+
return isNaN(n) ? null : { opacity: n > 1 ? n / 100 : n };
|
|
1668
|
+
},
|
|
1669
|
+
// ── Font ───────────────────────────────────────────────────────────────────
|
|
1670
|
+
font: ({ value, isArbitrary }, { fontFamily, fontWeight }) => {
|
|
1671
|
+
if (isArbitrary) return { fontFamily: value };
|
|
1672
|
+
if (value in fontFamily) {
|
|
1673
|
+
const ff = fontFamily[value];
|
|
1674
|
+
return { fontFamily: Array.isArray(ff) ? ff.join(", ") : ff };
|
|
1675
|
+
}
|
|
1676
|
+
if (value in fontWeight) return { fontWeight: String(fontWeight[value]) };
|
|
1677
|
+
return null;
|
|
1678
|
+
},
|
|
1679
|
+
// ── Line height ────────────────────────────────────────────────────────────
|
|
1680
|
+
leading: ({ value, isArbitrary }, { lineHeight }) => {
|
|
1681
|
+
if (isArbitrary) return { lineHeight: isWeb ? value : toNativeValue(value) };
|
|
1682
|
+
const v = lineHeight[value];
|
|
1683
|
+
return v !== void 0 ? { lineHeight: v } : null;
|
|
1684
|
+
},
|
|
1685
|
+
// ── Letter spacing ─────────────────────────────────────────────────────────
|
|
1686
|
+
tracking: ({ value, isArbitrary }, { letterSpacing }) => {
|
|
1687
|
+
if (isArbitrary) return { letterSpacing: isWeb ? value : toNativeValue(value) };
|
|
1688
|
+
const v = letterSpacing[value];
|
|
1689
|
+
return v !== void 0 ? { letterSpacing: v } : null;
|
|
1690
|
+
},
|
|
1691
|
+
// ── Shadow ─────────────────────────────────────────────────────────────────
|
|
1692
|
+
shadow: ({ value }, { shadow }) => {
|
|
1693
|
+
const key = value === "" ? "DEFAULT" : value;
|
|
1694
|
+
return shadow[key] ?? null;
|
|
1695
|
+
},
|
|
1696
|
+
// ── Scale ──────────────────────────────────────────────────────────────────
|
|
1697
|
+
scale: ({ value, isArbitrary }) => {
|
|
1698
|
+
const n = isArbitrary ? parseFloat(value) / 100 : parseFloat(value) / 100;
|
|
1699
|
+
if (isNaN(n)) return null;
|
|
1700
|
+
return isWeb ? { transform: `scale(${n})` } : { transform: [{ scale: n }] };
|
|
1701
|
+
},
|
|
1702
|
+
"scale-x": ({ value, isArbitrary }) => {
|
|
1703
|
+
const n = isArbitrary ? parseFloat(value) / 100 : parseFloat(value) / 100;
|
|
1704
|
+
if (isNaN(n)) return null;
|
|
1705
|
+
return isWeb ? { transform: `scaleX(${n})` } : { transform: [{ scaleX: n }] };
|
|
1706
|
+
},
|
|
1707
|
+
"scale-y": ({ value, isArbitrary }) => {
|
|
1708
|
+
const n = isArbitrary ? parseFloat(value) / 100 : parseFloat(value) / 100;
|
|
1709
|
+
if (isNaN(n)) return null;
|
|
1710
|
+
return isWeb ? { transform: `scaleY(${n})` } : { transform: [{ scaleY: n }] };
|
|
1711
|
+
},
|
|
1712
|
+
// ── Rotate ─────────────────────────────────────────────────────────────────
|
|
1713
|
+
rotate: ({ value, negative, isArbitrary }) => {
|
|
1714
|
+
const raw = isArbitrary ? value : `${value}deg`;
|
|
1715
|
+
const deg = parseFloat(raw);
|
|
1716
|
+
if (isNaN(deg)) return null;
|
|
1717
|
+
const finalDeg = negative ? -deg : deg;
|
|
1718
|
+
return isWeb ? { transform: `rotate(${finalDeg}deg)` } : { transform: [{ rotate: `${finalDeg}deg` }] };
|
|
1719
|
+
},
|
|
1720
|
+
// ── Translate ──────────────────────────────────────────────────────────────
|
|
1721
|
+
"translate-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1722
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1723
|
+
if (v === null) return null;
|
|
1724
|
+
return isWeb ? { transform: `translateX(${v})` } : { transform: [{ translateX: typeof v === "string" ? parseFloat(v) : v }] };
|
|
1725
|
+
},
|
|
1726
|
+
"translate-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1727
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1728
|
+
if (v === null) return null;
|
|
1729
|
+
return isWeb ? { transform: `translateY(${v})` } : { transform: [{ translateY: typeof v === "string" ? parseFloat(v) : v }] };
|
|
1730
|
+
},
|
|
1731
|
+
// ── Aspect ratio ───────────────────────────────────────────────────────────
|
|
1732
|
+
aspect: ({ value, isArbitrary }) => {
|
|
1733
|
+
if (isArbitrary) return { aspectRatio: value };
|
|
1734
|
+
const presets = { auto: "auto", square: 1, video: 16 / 9 };
|
|
1735
|
+
return value in presets ? { aspectRatio: presets[value] } : null;
|
|
1736
|
+
},
|
|
1737
|
+
// ── Transition ─────────────────────────────────────────────────────────────
|
|
1738
|
+
transition: ({ value }) => {
|
|
1739
|
+
const presets = {
|
|
1740
|
+
"": "color 150ms, background-color 150ms, border-color 150ms, opacity 150ms, box-shadow 150ms",
|
|
1741
|
+
all: "all 150ms",
|
|
1742
|
+
none: "none",
|
|
1743
|
+
colors: "color 150ms, background-color 150ms, border-color 150ms",
|
|
1744
|
+
opacity: "opacity 150ms",
|
|
1745
|
+
shadow: "box-shadow 150ms",
|
|
1746
|
+
transform: "transform 150ms"
|
|
1747
|
+
};
|
|
1748
|
+
const v = presets[value];
|
|
1749
|
+
return v !== void 0 ? { transition: v } : null;
|
|
1750
|
+
},
|
|
1751
|
+
duration: ({ value, isArbitrary }) => {
|
|
1752
|
+
const ms = isArbitrary ? value : `${value}ms`;
|
|
1753
|
+
return { transitionDuration: ms };
|
|
1754
|
+
},
|
|
1755
|
+
delay: ({ value, isArbitrary }) => {
|
|
1756
|
+
const ms = isArbitrary ? value : `${value}ms`;
|
|
1757
|
+
return { transitionDelay: ms };
|
|
1758
|
+
},
|
|
1759
|
+
// ── Space between (uses CSS gap or margin fallback) ────────────────────────
|
|
1760
|
+
"space-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1761
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1762
|
+
return v !== null ? { columnGap: v } : null;
|
|
1763
|
+
},
|
|
1764
|
+
"space-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1765
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1766
|
+
return v !== null ? { rowGap: v } : null;
|
|
1767
|
+
}
|
|
1768
|
+
};
|
|
1769
|
+
function resolveUtility(parsed, theme) {
|
|
1770
|
+
const standalone = STANDALONE[parsed.utility];
|
|
1771
|
+
if (standalone) return standalone;
|
|
1772
|
+
const resolver = RESOLVERS[parsed.utility];
|
|
1773
|
+
if (resolver) return resolver(parsed, theme);
|
|
1774
|
+
return null;
|
|
1775
|
+
}
|
|
1776
|
+
function getStandaloneMap() {
|
|
1777
|
+
return STANDALONE;
|
|
1778
|
+
}
|
|
1779
|
+
function getResolverMap() {
|
|
1780
|
+
return RESOLVERS;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
// src/core/resolver.ts
|
|
1784
|
+
var styleCache = new LRUCache(1e4);
|
|
1785
|
+
var _styleEl = null;
|
|
1786
|
+
var _injectedRules = /* @__PURE__ */ new Set();
|
|
1787
|
+
function getStyleEl() {
|
|
1788
|
+
if (_styleEl) return _styleEl;
|
|
1789
|
+
_styleEl = document.createElement("style");
|
|
1790
|
+
_styleEl.setAttribute("data-kbach", "");
|
|
1791
|
+
document.head.appendChild(_styleEl);
|
|
1792
|
+
return _styleEl;
|
|
1793
|
+
}
|
|
1794
|
+
function injectRule(rule) {
|
|
1795
|
+
if (_injectedRules.has(rule)) return;
|
|
1796
|
+
_injectedRules.add(rule);
|
|
1797
|
+
getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
|
|
1798
|
+
}
|
|
1799
|
+
function injectCSS(classString, resolved, darkMode) {
|
|
1800
|
+
if (!isWeb) return;
|
|
1801
|
+
for (const [modifierKey, styles] of Object.entries(resolved)) {
|
|
1802
|
+
if (!styles || Object.keys(styles).length === 0) continue;
|
|
1803
|
+
const classes = classString.trim().split(/\s+/);
|
|
1804
|
+
for (const cls of classes) {
|
|
1805
|
+
const cssDecls = styleValueToCSS(styles);
|
|
1806
|
+
if (!cssDecls) continue;
|
|
1807
|
+
const escaped = escapeCSSSelector(cls);
|
|
1808
|
+
if (modifierKey === "base") {
|
|
1809
|
+
injectRule(`.${escaped} { ${cssDecls} }`);
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
const mods = modifierKey.split(":");
|
|
1813
|
+
const pseudos = mods.filter((m) => !["dark", "light"].includes(m));
|
|
1814
|
+
const hasDark = mods.includes("dark");
|
|
1815
|
+
const pseudoSuffix = pseudos.map((p) => `:${p}`).join("");
|
|
1816
|
+
let selector = `.${escaped}${pseudoSuffix}`;
|
|
1817
|
+
let rule;
|
|
1818
|
+
if (hasDark) {
|
|
1819
|
+
if (darkMode === "media") {
|
|
1820
|
+
rule = `@media (prefers-color-scheme: dark) { ${selector} { ${cssDecls} } }`;
|
|
1821
|
+
} else if (darkMode === "class") {
|
|
1822
|
+
rule = `.dark ${selector} { ${cssDecls} }`;
|
|
1823
|
+
} else {
|
|
1824
|
+
rule = `[data-theme="dark"] ${selector} { ${cssDecls} }`;
|
|
1825
|
+
}
|
|
1826
|
+
} else {
|
|
1827
|
+
rule = `${selector} { ${cssDecls} }`;
|
|
1828
|
+
}
|
|
1829
|
+
injectRule(rule);
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
function styleValueToCSS(styles) {
|
|
1834
|
+
return Object.entries(styles).filter(([, v]) => v !== void 0 && v !== null).map(([prop, val]) => `${camelToKebab(prop)}: ${val}`).join("; ");
|
|
1835
|
+
}
|
|
1836
|
+
function camelToKebab(str) {
|
|
1837
|
+
return str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
1838
|
+
}
|
|
1839
|
+
function resolve(classString, theme, darkMode = "attribute") {
|
|
1840
|
+
const cacheKey = `${classString}::${darkMode}`;
|
|
1841
|
+
const cached = styleCache.get(cacheKey);
|
|
1842
|
+
if (cached) return cached;
|
|
1843
|
+
const result = {};
|
|
1844
|
+
const parsedClasses = parseClasses(classString);
|
|
1845
|
+
for (const parsed of parsedClasses) {
|
|
1846
|
+
const styles = resolveUtility(parsed, theme);
|
|
1847
|
+
if (!styles) continue;
|
|
1848
|
+
const bucketKey = parsed.modifiers.length === 0 ? "base" : parsed.modifiers.join(":");
|
|
1849
|
+
if (!result[bucketKey]) result[bucketKey] = {};
|
|
1850
|
+
Object.assign(result[bucketKey], styles);
|
|
1851
|
+
}
|
|
1852
|
+
styleCache.set(cacheKey, result);
|
|
1853
|
+
if (isWeb) {
|
|
1854
|
+
Promise.resolve().then(() => injectCSS(classString, result, darkMode));
|
|
1855
|
+
}
|
|
1856
|
+
return result;
|
|
1857
|
+
}
|
|
1858
|
+
function flatten(resolved, isDark, state = {}) {
|
|
1859
|
+
const result = { ...resolved.base ?? {} };
|
|
1860
|
+
for (const [key, styles] of Object.entries(resolved)) {
|
|
1861
|
+
if (key === "base" || !styles) continue;
|
|
1862
|
+
const mods = key.split(":");
|
|
1863
|
+
if (matchesMods(mods, isDark, state)) {
|
|
1864
|
+
Object.assign(result, styles);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
return result;
|
|
1868
|
+
}
|
|
1869
|
+
function matchesMods(mods, isDark, state) {
|
|
1870
|
+
return mods.every((mod) => {
|
|
1871
|
+
switch (mod) {
|
|
1872
|
+
case "dark":
|
|
1873
|
+
return isDark;
|
|
1874
|
+
case "light":
|
|
1875
|
+
case "not-dark":
|
|
1876
|
+
return !isDark;
|
|
1877
|
+
case "not-light":
|
|
1878
|
+
return isDark;
|
|
1879
|
+
case "hover":
|
|
1880
|
+
return !!state.hover;
|
|
1881
|
+
case "not-hover":
|
|
1882
|
+
return !state.hover;
|
|
1883
|
+
case "focus":
|
|
1884
|
+
return !!state.focus;
|
|
1885
|
+
case "not-focus":
|
|
1886
|
+
return !state.focus;
|
|
1887
|
+
case "pressed":
|
|
1888
|
+
case "active":
|
|
1889
|
+
return !!state.pressed || !!state.active;
|
|
1890
|
+
case "not-pressed":
|
|
1891
|
+
case "not-active":
|
|
1892
|
+
return !state.pressed && !state.active;
|
|
1893
|
+
case "disabled":
|
|
1894
|
+
return !!state.disabled;
|
|
1895
|
+
case "not-disabled":
|
|
1896
|
+
return !state.disabled;
|
|
1897
|
+
case "checked":
|
|
1898
|
+
return !!state.checked;
|
|
1899
|
+
case "not-checked":
|
|
1900
|
+
return !state.checked;
|
|
1901
|
+
case "visited":
|
|
1902
|
+
return !!state.visited;
|
|
1903
|
+
case "not-visited":
|
|
1904
|
+
return !state.visited;
|
|
1905
|
+
case "placeholder":
|
|
1906
|
+
return !!state.placeholder;
|
|
1907
|
+
default:
|
|
1908
|
+
return false;
|
|
1909
|
+
}
|
|
1910
|
+
});
|
|
1911
|
+
}
|
|
1912
|
+
|
|
1913
|
+
// src/core/config.ts
|
|
1914
|
+
function deepMerge(base, override) {
|
|
1915
|
+
const result = { ...base };
|
|
1916
|
+
for (const key of Object.keys(override)) {
|
|
1917
|
+
const baseVal = base[key];
|
|
1918
|
+
const overVal = override[key];
|
|
1919
|
+
if (baseVal !== null && typeof baseVal === "object" && !Array.isArray(baseVal) && overVal !== null && typeof overVal === "object" && !Array.isArray(overVal)) {
|
|
1920
|
+
result[key] = deepMerge(
|
|
1921
|
+
baseVal,
|
|
1922
|
+
overVal
|
|
1923
|
+
);
|
|
1924
|
+
} else if (overVal !== void 0) {
|
|
1925
|
+
result[key] = overVal;
|
|
1926
|
+
}
|
|
1927
|
+
}
|
|
1928
|
+
return result;
|
|
1929
|
+
}
|
|
1930
|
+
var _resolved = null;
|
|
1931
|
+
function getConfig() {
|
|
1932
|
+
if (_resolved) return _resolved;
|
|
1933
|
+
_resolved = buildConfig({});
|
|
1934
|
+
return _resolved;
|
|
1935
|
+
}
|
|
1936
|
+
function buildConfig(userConfig) {
|
|
1937
|
+
let theme = { ...defaultTheme };
|
|
1938
|
+
if (userConfig.theme) {
|
|
1939
|
+
theme = deepMerge(theme, userConfig.theme);
|
|
1940
|
+
}
|
|
1941
|
+
if (userConfig.extend?.theme) {
|
|
1942
|
+
const ext = userConfig.extend.theme;
|
|
1943
|
+
for (const [key, value] of Object.entries(ext)) {
|
|
1944
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
1945
|
+
theme[key] = deepMerge(
|
|
1946
|
+
theme[key] ?? {},
|
|
1947
|
+
value
|
|
1948
|
+
);
|
|
1949
|
+
} else {
|
|
1950
|
+
theme[key] = value;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
}
|
|
1954
|
+
const resolved = {
|
|
1955
|
+
darkMode: userConfig.darkMode ?? "attribute",
|
|
1956
|
+
theme,
|
|
1957
|
+
plugins: userConfig.plugins ?? []
|
|
1958
|
+
};
|
|
1959
|
+
for (const plugin of resolved.plugins) {
|
|
1960
|
+
plugin(makePluginAPI(resolved.theme));
|
|
1961
|
+
}
|
|
1962
|
+
return resolved;
|
|
1963
|
+
}
|
|
1964
|
+
function makePluginAPI(theme) {
|
|
1965
|
+
const standalone = getStandaloneMap();
|
|
1966
|
+
const resolvers = getResolverMap();
|
|
1967
|
+
return {
|
|
1968
|
+
addUtility(name, styles) {
|
|
1969
|
+
standalone[name] = styles;
|
|
1970
|
+
},
|
|
1971
|
+
addVariant(name, _selector) {
|
|
1972
|
+
customVariants[name] = _selector;
|
|
1973
|
+
},
|
|
1974
|
+
theme(path, defaultValue) {
|
|
1975
|
+
const parts = path.replace(/\[([^\]]+)\]/g, ".$1").split(".");
|
|
1976
|
+
let current = theme;
|
|
1977
|
+
for (const part of parts) {
|
|
1978
|
+
if (current === null || typeof current !== "object") return defaultValue;
|
|
1979
|
+
current = current[part];
|
|
1980
|
+
}
|
|
1981
|
+
return current ?? defaultValue;
|
|
1982
|
+
},
|
|
1983
|
+
e(className) {
|
|
1984
|
+
return className.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
1985
|
+
}
|
|
1986
|
+
};
|
|
1987
|
+
}
|
|
1988
|
+
var customVariants = {};
|
|
1989
|
+
var listeners = /* @__PURE__ */ new Set();
|
|
1990
|
+
function onConfigChange(listener) {
|
|
1991
|
+
listeners.add(listener);
|
|
1992
|
+
return () => listeners.delete(listener);
|
|
1993
|
+
}
|
|
1994
|
+
function updateConfig(userConfig) {
|
|
1995
|
+
_resolved = buildConfig(userConfig);
|
|
1996
|
+
for (const listener of listeners) {
|
|
1997
|
+
listener(_resolved);
|
|
1998
|
+
}
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
// src/core/darkModeStore.ts
|
|
2002
|
+
var _isDark = false;
|
|
2003
|
+
var _lastNotified = false;
|
|
2004
|
+
var _subscribers = /* @__PURE__ */ new Set();
|
|
2005
|
+
function syncGlobalDarkMode(isDark) {
|
|
2006
|
+
_isDark = isDark;
|
|
2007
|
+
}
|
|
2008
|
+
function setGlobalDarkMode(isDark) {
|
|
2009
|
+
_isDark = isDark;
|
|
2010
|
+
if (_lastNotified === isDark) return;
|
|
2011
|
+
_lastNotified = isDark;
|
|
2012
|
+
for (const sub of _subscribers) sub();
|
|
2013
|
+
}
|
|
2014
|
+
function getGlobalDarkMode() {
|
|
2015
|
+
return _isDark;
|
|
2016
|
+
}
|
|
2017
|
+
function subscribeGlobalDarkMode(callback) {
|
|
2018
|
+
_subscribers.add(callback);
|
|
2019
|
+
return () => _subscribers.delete(callback);
|
|
2020
|
+
}
|
|
2021
|
+
|
|
2022
|
+
// src/ThemeProvider.tsx
|
|
71
2023
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
72
2024
|
var Appearance;
|
|
73
2025
|
try {
|
|
@@ -77,7 +2029,7 @@ try {
|
|
|
77
2029
|
var STORAGE_KEY = "kbach-theme";
|
|
78
2030
|
function loadPersistedMode() {
|
|
79
2031
|
try {
|
|
80
|
-
if (
|
|
2032
|
+
if (isWeb) {
|
|
81
2033
|
return localStorage.getItem(STORAGE_KEY);
|
|
82
2034
|
}
|
|
83
2035
|
return null;
|
|
@@ -87,12 +2039,12 @@ function loadPersistedMode() {
|
|
|
87
2039
|
}
|
|
88
2040
|
function persistMode(mode) {
|
|
89
2041
|
try {
|
|
90
|
-
if (
|
|
2042
|
+
if (isWeb) localStorage.setItem(STORAGE_KEY, mode);
|
|
91
2043
|
} catch {
|
|
92
2044
|
}
|
|
93
2045
|
}
|
|
94
2046
|
function applyWebTheme(resolvedMode, strategy) {
|
|
95
|
-
if (!
|
|
2047
|
+
if (!isWeb) return;
|
|
96
2048
|
const root = document.documentElement;
|
|
97
2049
|
if (strategy === "attribute") {
|
|
98
2050
|
root.setAttribute("data-theme", resolvedMode);
|
|
@@ -108,10 +2060,10 @@ function ThemeProvider({
|
|
|
108
2060
|
disablePersistence = false
|
|
109
2061
|
}) {
|
|
110
2062
|
const [resolvedConfig, setResolvedConfig] = (0, import_react2.useState)(
|
|
111
|
-
() => configOverride ?
|
|
2063
|
+
() => configOverride ? buildConfig(configOverride) : getConfig()
|
|
112
2064
|
);
|
|
113
2065
|
const getSystemScheme = (0, import_react2.useCallback)(() => {
|
|
114
|
-
if (
|
|
2066
|
+
if (isWeb && typeof window !== "undefined") {
|
|
115
2067
|
return window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
116
2068
|
}
|
|
117
2069
|
if (Appearance) {
|
|
@@ -137,10 +2089,10 @@ function ThemeProvider({
|
|
|
137
2089
|
}, [mode, systemScheme, setMode]);
|
|
138
2090
|
const resolvedMode = mode === "system" ? systemScheme : mode;
|
|
139
2091
|
const isDark = resolvedMode === "dark";
|
|
140
|
-
|
|
2092
|
+
syncGlobalDarkMode(isDark);
|
|
141
2093
|
(0, import_react2.useEffect)(() => {
|
|
142
2094
|
applyWebTheme(resolvedMode, resolvedConfig.darkMode);
|
|
143
|
-
|
|
2095
|
+
setGlobalDarkMode(isDark);
|
|
144
2096
|
}, [isDark, resolvedMode, resolvedConfig.darkMode]);
|
|
145
2097
|
const setSystemSchemeRef = (0, import_react2.useRef)(setSystemScheme);
|
|
146
2098
|
setSystemSchemeRef.current = setSystemScheme;
|
|
@@ -153,7 +2105,7 @@ function ThemeProvider({
|
|
|
153
2105
|
}
|
|
154
2106
|
}, []);
|
|
155
2107
|
(0, import_react2.useEffect)(() => {
|
|
156
|
-
if (
|
|
2108
|
+
if (isWeb && typeof window !== "undefined") {
|
|
157
2109
|
const mq = window.matchMedia?.("(prefers-color-scheme: dark)");
|
|
158
2110
|
if (!mq) return;
|
|
159
2111
|
const handler = (e) => {
|
|
@@ -172,7 +2124,7 @@ function ThemeProvider({
|
|
|
172
2124
|
}, []);
|
|
173
2125
|
(0, import_react2.useEffect)(() => {
|
|
174
2126
|
if (configOverride) return;
|
|
175
|
-
const unsub =
|
|
2127
|
+
const unsub = onConfigChange(setResolvedConfig);
|
|
176
2128
|
return unsub;
|
|
177
2129
|
}, [configOverride]);
|
|
178
2130
|
const contextValue = (0, import_react2.useMemo)(
|
|
@@ -323,12 +2275,11 @@ function ThemeToggle({
|
|
|
323
2275
|
|
|
324
2276
|
// src/styled.tsx
|
|
325
2277
|
var import_react4 = __toESM(require("react"));
|
|
326
|
-
var import_core2 = require("@kbach/core");
|
|
327
2278
|
function styled(Component, baseClasses = "") {
|
|
328
2279
|
const Styled = (0, import_react4.forwardRef)(
|
|
329
2280
|
(props, ref) => {
|
|
330
2281
|
const {
|
|
331
|
-
|
|
2282
|
+
kb: extraClasses,
|
|
332
2283
|
style: styleProp,
|
|
333
2284
|
onPressIn,
|
|
334
2285
|
onPressOut,
|
|
@@ -367,9 +2318,9 @@ function styled(Component, baseClasses = "") {
|
|
|
367
2318
|
onBlur?.(e);
|
|
368
2319
|
}, [onBlur]);
|
|
369
2320
|
const combined = extraClasses ? `${baseClasses} ${extraClasses}` : baseClasses;
|
|
370
|
-
const resolved = (0, import_react4.useMemo)(() =>
|
|
2321
|
+
const resolved = (0, import_react4.useMemo)(() => resolve(combined, config.theme, config.darkMode), [combined, config.theme, config.darkMode]);
|
|
371
2322
|
const computedStyle = (0, import_react4.useMemo)(
|
|
372
|
-
() =>
|
|
2323
|
+
() => flatten(resolved, isDark, { pressed, hover: hovered, focus: focused }),
|
|
373
2324
|
[resolved, isDark, pressed, hovered, focused]
|
|
374
2325
|
);
|
|
375
2326
|
const extraStyle = Array.isArray(styleProp) ? Object.assign({}, ...styleProp) : styleProp;
|
|
@@ -394,27 +2345,25 @@ function styled(Component, baseClasses = "") {
|
|
|
394
2345
|
|
|
395
2346
|
// src/useStyles.ts
|
|
396
2347
|
var import_react5 = require("react");
|
|
397
|
-
var import_core3 = require("@kbach/core");
|
|
398
2348
|
function useStyles(classString, state = {}) {
|
|
399
2349
|
const { isDark, config } = useTheme();
|
|
400
2350
|
const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
|
|
401
2351
|
return (0, import_react5.useMemo)(() => {
|
|
402
|
-
const resolved =
|
|
403
|
-
return
|
|
2352
|
+
const resolved = resolve(normalised, config.theme, config.darkMode);
|
|
2353
|
+
return flatten(resolved, isDark, state);
|
|
404
2354
|
}, [normalised, isDark, config, state.hover, state.focus, state.pressed, state.active, state.disabled, state.checked, state.visited, state.placeholder]);
|
|
405
2355
|
}
|
|
406
2356
|
function useResolvedStyle(classString) {
|
|
407
2357
|
const { config } = useTheme();
|
|
408
2358
|
const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
|
|
409
2359
|
return (0, import_react5.useMemo)(
|
|
410
|
-
() =>
|
|
2360
|
+
() => resolve(normalised, config.theme, config.darkMode),
|
|
411
2361
|
[normalised, config]
|
|
412
2362
|
);
|
|
413
2363
|
}
|
|
414
2364
|
|
|
415
2365
|
// src/useGlobalDarkMode.ts
|
|
416
2366
|
var import_react6 = __toESM(require("react"));
|
|
417
|
-
var import_core4 = require("@kbach/core");
|
|
418
2367
|
var useSyncExternalStore = import_react6.default.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
419
2368
|
const [, forceUpdate] = import_react6.default.useReducer((n) => n + 1, 0);
|
|
420
2369
|
import_react6.default.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
@@ -422,8 +2371,8 @@ var useSyncExternalStore = import_react6.default.useSyncExternalStore ?? functio
|
|
|
422
2371
|
};
|
|
423
2372
|
function useGlobalDarkMode() {
|
|
424
2373
|
return useSyncExternalStore(
|
|
425
|
-
|
|
426
|
-
|
|
2374
|
+
subscribeGlobalDarkMode,
|
|
2375
|
+
getGlobalDarkMode,
|
|
427
2376
|
() => false
|
|
428
2377
|
// SSR: default light
|
|
429
2378
|
);
|
|
@@ -431,7 +2380,6 @@ function useGlobalDarkMode() {
|
|
|
431
2380
|
|
|
432
2381
|
// src/InteractiveWrapper.tsx
|
|
433
2382
|
var import_react7 = __toESM(require("react"));
|
|
434
|
-
var import_core5 = require("@kbach/core");
|
|
435
2383
|
function chain(original, extra) {
|
|
436
2384
|
return (...args) => {
|
|
437
2385
|
original?.(...args);
|
|
@@ -463,7 +2411,7 @@ var InteractiveWrapper = (0, import_react7.forwardRef)(
|
|
|
463
2411
|
const handleFocus = (0, import_react7.useCallback)(chain(onFocus, () => setFocused(true)), [onFocus]);
|
|
464
2412
|
const handleBlur = (0, import_react7.useCallback)(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
465
2413
|
const computedStyle = (0, import_react7.useMemo)(
|
|
466
|
-
() =>
|
|
2414
|
+
() => flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused }),
|
|
467
2415
|
[resolvedStyle, isDark, pressed, hovered, focused]
|
|
468
2416
|
);
|
|
469
2417
|
const finalStyle = styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
@@ -472,7 +2420,7 @@ var InteractiveWrapper = (0, import_react7.forwardRef)(
|
|
|
472
2420
|
ref,
|
|
473
2421
|
...restWithoutChildren,
|
|
474
2422
|
style: finalStyle,
|
|
475
|
-
...
|
|
2423
|
+
...isWeb && className ? { className } : {},
|
|
476
2424
|
onPressIn: handlePressIn,
|
|
477
2425
|
onPressOut: handlePressOut,
|
|
478
2426
|
onMouseEnter: handleMouseEnter,
|
|
@@ -486,27 +2434,24 @@ var InteractiveWrapper = (0, import_react7.forwardRef)(
|
|
|
486
2434
|
InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
|
|
487
2435
|
|
|
488
2436
|
// src/tw.ts
|
|
489
|
-
var import_core6 = require("@kbach/core");
|
|
490
2437
|
function tw(classString, isDark = false) {
|
|
491
|
-
const config =
|
|
492
|
-
const resolved =
|
|
493
|
-
if (
|
|
2438
|
+
const config = getConfig();
|
|
2439
|
+
const resolved = resolve(classString, config.theme, config.darkMode);
|
|
2440
|
+
if (isWeb) {
|
|
494
2441
|
return classString;
|
|
495
2442
|
}
|
|
496
|
-
return
|
|
2443
|
+
return flatten(resolved, isDark);
|
|
497
2444
|
}
|
|
498
2445
|
function cx(...classes) {
|
|
499
2446
|
return classes.filter(Boolean).join(" ");
|
|
500
2447
|
}
|
|
501
|
-
|
|
502
|
-
// src/index.ts
|
|
503
|
-
var import_core7 = require("@kbach/core");
|
|
504
2448
|
// Annotate the CommonJS export names for ESM import in node:
|
|
505
2449
|
0 && (module.exports = {
|
|
506
2450
|
InteractiveWrapper,
|
|
507
2451
|
ThemeContext,
|
|
508
2452
|
ThemeProvider,
|
|
509
2453
|
ThemeToggle,
|
|
2454
|
+
buildConfig,
|
|
510
2455
|
cx,
|
|
511
2456
|
defaultColors,
|
|
512
2457
|
defaultTheme,
|