@kbach/react 0.6.0 → 0.6.2
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 +49 -0
- package/dist/{chunk-6NED62DB.mjs → chunk-GRZ6MVIL.mjs} +659 -179
- package/dist/{chunk-AAAI37Y4.mjs → chunk-NWW57Q5Q.mjs} +12 -71
- package/dist/index.d.mts +142 -3
- package/dist/index.d.ts +142 -3
- package/dist/index.js +345 -395
- package/dist/index.mjs +69 -98
- package/dist/jsx-dev-runtime.js +205 -289
- package/dist/jsx-dev-runtime.mjs +4 -4
- package/dist/jsx-runtime.js +204 -288
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/vite-plugin.d.mts +102 -1
- package/dist/vite-plugin.d.ts +102 -1
- package/dist/vite-plugin.js +139 -163
- package/dist/vite-plugin.mjs +2883 -12
- package/jsx-dev-runtime.js +1 -0
- package/jsx-runtime.js +1 -0
- package/kbach-react.md +7 -0
- package/package.json +3 -3
- package/dist/chunk-D4LJICWZ.mjs +0 -524
- package/dist/types-BESBQANS.d.mts +0 -131
- package/dist/types-BESBQANS.d.ts +0 -131
package/dist/vite-plugin.mjs
CHANGED
|
@@ -1,19 +1,2889 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BASE_RESET,
|
|
3
|
-
buildConfig,
|
|
4
|
-
generateClassCSS,
|
|
5
|
-
setCSSGenMode,
|
|
6
|
-
splitClassTokens
|
|
7
|
-
} from "./chunk-6NED62DB.mjs";
|
|
8
|
-
|
|
9
1
|
// src/vite-plugin.ts
|
|
10
2
|
import { readFileSync, writeFileSync, readdirSync, statSync } from "fs";
|
|
11
3
|
import { join } from "path";
|
|
12
4
|
import processImport from "process";
|
|
13
|
-
|
|
5
|
+
|
|
6
|
+
// src/core/platform.ts
|
|
7
|
+
var isWeb = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
8
|
+
var isNative = !isWeb && (typeof globalThis.HermesInternal !== "undefined" || typeof globalThis.__fbBatchedBridge !== "undefined" || typeof navigator !== "undefined" && navigator.product === "ReactNative" || typeof globalThis.__REACT_NATIVE__ !== "undefined");
|
|
9
|
+
var _resolveTargetOverride = null;
|
|
10
|
+
function setCSSGenMode(on) {
|
|
11
|
+
_resolveTargetOverride = on ? "web" : null;
|
|
12
|
+
}
|
|
13
|
+
function getEffectiveIsWeb() {
|
|
14
|
+
if (_resolveTargetOverride) return _resolveTargetOverride === "web";
|
|
15
|
+
return isWeb || !isNative;
|
|
16
|
+
}
|
|
17
|
+
function toNativeValue(raw) {
|
|
18
|
+
if (/^-?\d+(\.\d+)?px$/.test(raw)) return parseFloat(raw);
|
|
19
|
+
if (/^-?\d+(\.\d+)?rem$/.test(raw)) return parseFloat(raw) * 16;
|
|
20
|
+
if (/^-?\d+(\.\d+)?em$/.test(raw)) return parseFloat(raw) * 16;
|
|
21
|
+
if (/^-?\d+(\.\d+)?$/.test(raw)) return parseFloat(raw);
|
|
22
|
+
return raw;
|
|
23
|
+
}
|
|
24
|
+
function escapeCSSSelector(cls) {
|
|
25
|
+
return cls.replace(/[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// src/core/reset.ts
|
|
29
|
+
var BASE_RESET = [
|
|
30
|
+
// border-style: solid means border-N utilities show a visible border without an extra border-solid class.
|
|
31
|
+
// border-width: 0 keeps all elements borderless by default.
|
|
32
|
+
"*, *::before, *::after { box-sizing: border-box; border-width: 0; border-style: solid; border-color: currentColor; }",
|
|
33
|
+
"body { margin: 0; padding: 0; }",
|
|
34
|
+
"h1, h2, h3, h4, h5, h6 { margin: 0; font-size: inherit; font-weight: inherit; }",
|
|
35
|
+
"p { margin: 0; }",
|
|
36
|
+
"a { color: inherit; text-decoration: none; }",
|
|
37
|
+
"ul, ol { margin: 0; padding: 0; list-style: none; }",
|
|
38
|
+
"img, video, svg { display: block; max-width: 100%; }",
|
|
39
|
+
"input, textarea, select { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; line-height: inherit; }",
|
|
40
|
+
"button { appearance: none; -webkit-appearance: none; background: transparent; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; line-height: inherit; text-align: inherit; }",
|
|
41
|
+
"fieldset { padding: 0; margin: 0; }",
|
|
42
|
+
"table { border-collapse: collapse; border-spacing: 0; }"
|
|
43
|
+
].join("\n");
|
|
44
|
+
|
|
45
|
+
// src/core/theme.ts
|
|
46
|
+
var defaultColors = {
|
|
47
|
+
transparent: "transparent",
|
|
48
|
+
current: "currentColor",
|
|
49
|
+
black: "#000000",
|
|
50
|
+
white: "#ffffff",
|
|
51
|
+
slate: {
|
|
52
|
+
1: "#f8fafc",
|
|
53
|
+
2: "#f1f5f9",
|
|
54
|
+
3: "#e2e8f0",
|
|
55
|
+
4: "#cbd5e1",
|
|
56
|
+
5: "#94a3b8",
|
|
57
|
+
6: "#64748b",
|
|
58
|
+
7: "#475569",
|
|
59
|
+
8: "#334155",
|
|
60
|
+
9: "#1e293b",
|
|
61
|
+
10: "#0f172a",
|
|
62
|
+
11: "#020617",
|
|
63
|
+
12: "#01020a"
|
|
64
|
+
},
|
|
65
|
+
gray: {
|
|
66
|
+
1: "#f9fafb",
|
|
67
|
+
2: "#f3f4f6",
|
|
68
|
+
3: "#e5e7eb",
|
|
69
|
+
4: "#d1d5db",
|
|
70
|
+
5: "#9ca3af",
|
|
71
|
+
6: "#6b7280",
|
|
72
|
+
7: "#4b5563",
|
|
73
|
+
8: "#374151",
|
|
74
|
+
9: "#1f2937",
|
|
75
|
+
10: "#111827",
|
|
76
|
+
11: "#030712",
|
|
77
|
+
12: "#020409"
|
|
78
|
+
},
|
|
79
|
+
zinc: {
|
|
80
|
+
1: "#fafafa",
|
|
81
|
+
2: "#f4f4f5",
|
|
82
|
+
3: "#e4e4e7",
|
|
83
|
+
4: "#d4d4d8",
|
|
84
|
+
5: "#a1a1aa",
|
|
85
|
+
6: "#71717a",
|
|
86
|
+
7: "#52525b",
|
|
87
|
+
8: "#3f3f46",
|
|
88
|
+
9: "#27272a",
|
|
89
|
+
10: "#18181b",
|
|
90
|
+
11: "#09090b",
|
|
91
|
+
12: "#050506"
|
|
92
|
+
},
|
|
93
|
+
neutral: {
|
|
94
|
+
1: "#fafafa",
|
|
95
|
+
2: "#f5f5f5",
|
|
96
|
+
3: "#e5e5e5",
|
|
97
|
+
4: "#d4d4d4",
|
|
98
|
+
5: "#a3a3a3",
|
|
99
|
+
6: "#737373",
|
|
100
|
+
7: "#525252",
|
|
101
|
+
8: "#404040",
|
|
102
|
+
9: "#262626",
|
|
103
|
+
10: "#171717",
|
|
104
|
+
11: "#0a0a0a",
|
|
105
|
+
12: "#050505"
|
|
106
|
+
},
|
|
107
|
+
stone: {
|
|
108
|
+
1: "#fafaf9",
|
|
109
|
+
2: "#f5f5f4",
|
|
110
|
+
3: "#e7e5e4",
|
|
111
|
+
4: "#d6d3d1",
|
|
112
|
+
5: "#a8a29e",
|
|
113
|
+
6: "#78716c",
|
|
114
|
+
7: "#57534e",
|
|
115
|
+
8: "#44403c",
|
|
116
|
+
9: "#292524",
|
|
117
|
+
10: "#1c1917",
|
|
118
|
+
11: "#0c0a09",
|
|
119
|
+
12: "#070605"
|
|
120
|
+
},
|
|
121
|
+
red: {
|
|
122
|
+
1: "#fef2f2",
|
|
123
|
+
2: "#fee2e2",
|
|
124
|
+
3: "#fecaca",
|
|
125
|
+
4: "#fca5a5",
|
|
126
|
+
5: "#f87171",
|
|
127
|
+
6: "#ef4444",
|
|
128
|
+
7: "#dc2626",
|
|
129
|
+
8: "#b91c1c",
|
|
130
|
+
9: "#991b1b",
|
|
131
|
+
10: "#7f1d1d",
|
|
132
|
+
11: "#450a0a",
|
|
133
|
+
12: "#280606"
|
|
134
|
+
},
|
|
135
|
+
orange: {
|
|
136
|
+
1: "#fff7ed",
|
|
137
|
+
2: "#ffedd5",
|
|
138
|
+
3: "#fed7aa",
|
|
139
|
+
4: "#fdba74",
|
|
140
|
+
5: "#fb923c",
|
|
141
|
+
6: "#f97316",
|
|
142
|
+
7: "#ea580c",
|
|
143
|
+
8: "#c2410c",
|
|
144
|
+
9: "#9a3412",
|
|
145
|
+
10: "#7c2d12",
|
|
146
|
+
11: "#431407",
|
|
147
|
+
12: "#270c04"
|
|
148
|
+
},
|
|
149
|
+
amber: {
|
|
150
|
+
1: "#fffbeb",
|
|
151
|
+
2: "#fef3c7",
|
|
152
|
+
3: "#fde68a",
|
|
153
|
+
4: "#fcd34d",
|
|
154
|
+
5: "#fbbf24",
|
|
155
|
+
6: "#f59e0b",
|
|
156
|
+
7: "#d97706",
|
|
157
|
+
8: "#b45309",
|
|
158
|
+
9: "#92400e",
|
|
159
|
+
10: "#78350f",
|
|
160
|
+
11: "#451a03",
|
|
161
|
+
12: "#291002"
|
|
162
|
+
},
|
|
163
|
+
yellow: {
|
|
164
|
+
1: "#fefce8",
|
|
165
|
+
2: "#fef9c3",
|
|
166
|
+
3: "#fef08a",
|
|
167
|
+
4: "#fde047",
|
|
168
|
+
5: "#facc15",
|
|
169
|
+
6: "#eab308",
|
|
170
|
+
7: "#ca8a04",
|
|
171
|
+
8: "#a16207",
|
|
172
|
+
9: "#854d0e",
|
|
173
|
+
10: "#713f12",
|
|
174
|
+
11: "#422006",
|
|
175
|
+
12: "#271304"
|
|
176
|
+
},
|
|
177
|
+
lime: {
|
|
178
|
+
1: "#f7fee7",
|
|
179
|
+
2: "#ecfccb",
|
|
180
|
+
3: "#d9f99d",
|
|
181
|
+
4: "#bef264",
|
|
182
|
+
5: "#a3e635",
|
|
183
|
+
6: "#84cc16",
|
|
184
|
+
7: "#65a30d",
|
|
185
|
+
8: "#4d7c0f",
|
|
186
|
+
9: "#3f6212",
|
|
187
|
+
10: "#365314",
|
|
188
|
+
11: "#1a2e05",
|
|
189
|
+
12: "#0f1b03"
|
|
190
|
+
},
|
|
191
|
+
green: {
|
|
192
|
+
1: "#f0fdf4",
|
|
193
|
+
2: "#dcfce7",
|
|
194
|
+
3: "#bbf7d0",
|
|
195
|
+
4: "#86efac",
|
|
196
|
+
5: "#4ade80",
|
|
197
|
+
6: "#22c55e",
|
|
198
|
+
7: "#16a34a",
|
|
199
|
+
8: "#15803d",
|
|
200
|
+
9: "#166534",
|
|
201
|
+
10: "#14532d",
|
|
202
|
+
11: "#052e16",
|
|
203
|
+
12: "#031b0d"
|
|
204
|
+
},
|
|
205
|
+
emerald: {
|
|
206
|
+
1: "#ecfdf5",
|
|
207
|
+
2: "#d1fae5",
|
|
208
|
+
3: "#a7f3d0",
|
|
209
|
+
4: "#6ee7b7",
|
|
210
|
+
5: "#34d399",
|
|
211
|
+
6: "#10b981",
|
|
212
|
+
7: "#059669",
|
|
213
|
+
8: "#047857",
|
|
214
|
+
9: "#065f46",
|
|
215
|
+
10: "#064e3b",
|
|
216
|
+
11: "#022c22",
|
|
217
|
+
12: "#011a14"
|
|
218
|
+
},
|
|
219
|
+
teal: {
|
|
220
|
+
1: "#f0fdfa",
|
|
221
|
+
2: "#ccfbf1",
|
|
222
|
+
3: "#99f6e4",
|
|
223
|
+
4: "#5eead4",
|
|
224
|
+
5: "#2dd4bf",
|
|
225
|
+
6: "#14b8a6",
|
|
226
|
+
7: "#0d9488",
|
|
227
|
+
8: "#0f766e",
|
|
228
|
+
9: "#115e59",
|
|
229
|
+
10: "#134e4a",
|
|
230
|
+
11: "#042f2e",
|
|
231
|
+
12: "#021c1b"
|
|
232
|
+
},
|
|
233
|
+
cyan: {
|
|
234
|
+
1: "#ecfeff",
|
|
235
|
+
2: "#cffafe",
|
|
236
|
+
3: "#a5f3fc",
|
|
237
|
+
4: "#67e8f9",
|
|
238
|
+
5: "#22d3ee",
|
|
239
|
+
6: "#06b6d4",
|
|
240
|
+
7: "#0891b2",
|
|
241
|
+
8: "#0e7490",
|
|
242
|
+
9: "#155e75",
|
|
243
|
+
10: "#164e63",
|
|
244
|
+
11: "#083344",
|
|
245
|
+
12: "#041e28"
|
|
246
|
+
},
|
|
247
|
+
sky: {
|
|
248
|
+
1: "#f0f9ff",
|
|
249
|
+
2: "#e0f2fe",
|
|
250
|
+
3: "#bae6fd",
|
|
251
|
+
4: "#7dd3fc",
|
|
252
|
+
5: "#38bdf8",
|
|
253
|
+
6: "#0ea5e9",
|
|
254
|
+
7: "#0284c7",
|
|
255
|
+
8: "#0369a1",
|
|
256
|
+
9: "#075985",
|
|
257
|
+
10: "#0c4a6e",
|
|
258
|
+
11: "#082f49",
|
|
259
|
+
12: "#041b2b"
|
|
260
|
+
},
|
|
261
|
+
blue: {
|
|
262
|
+
1: "#eff6ff",
|
|
263
|
+
2: "#dbeafe",
|
|
264
|
+
3: "#bfdbfe",
|
|
265
|
+
4: "#93c5fd",
|
|
266
|
+
5: "#60a5fa",
|
|
267
|
+
6: "#3b82f6",
|
|
268
|
+
7: "#2563eb",
|
|
269
|
+
8: "#1d4ed8",
|
|
270
|
+
9: "#1e40af",
|
|
271
|
+
10: "#1e3a8a",
|
|
272
|
+
11: "#172554",
|
|
273
|
+
12: "#0d1633"
|
|
274
|
+
},
|
|
275
|
+
indigo: {
|
|
276
|
+
1: "#eef2ff",
|
|
277
|
+
2: "#e0e7ff",
|
|
278
|
+
3: "#c7d2fe",
|
|
279
|
+
4: "#a5b4fc",
|
|
280
|
+
5: "#818cf8",
|
|
281
|
+
6: "#6366f1",
|
|
282
|
+
7: "#4f46e5",
|
|
283
|
+
8: "#4338ca",
|
|
284
|
+
9: "#3730a3",
|
|
285
|
+
10: "#312e81",
|
|
286
|
+
11: "#1e1b4b",
|
|
287
|
+
12: "#12102d"
|
|
288
|
+
},
|
|
289
|
+
violet: {
|
|
290
|
+
1: "#f5f3ff",
|
|
291
|
+
2: "#ede9fe",
|
|
292
|
+
3: "#ddd6fe",
|
|
293
|
+
4: "#c4b5fd",
|
|
294
|
+
5: "#a78bfa",
|
|
295
|
+
6: "#8b5cf6",
|
|
296
|
+
7: "#7c3aed",
|
|
297
|
+
8: "#6d28d9",
|
|
298
|
+
9: "#5b21b6",
|
|
299
|
+
10: "#4c1d95",
|
|
300
|
+
11: "#2e1065",
|
|
301
|
+
12: "#1c0a3d"
|
|
302
|
+
},
|
|
303
|
+
purple: {
|
|
304
|
+
1: "#faf5ff",
|
|
305
|
+
2: "#f3e8ff",
|
|
306
|
+
3: "#e9d5ff",
|
|
307
|
+
4: "#d8b4fe",
|
|
308
|
+
5: "#c084fc",
|
|
309
|
+
6: "#a855f7",
|
|
310
|
+
7: "#9333ea",
|
|
311
|
+
8: "#7e22ce",
|
|
312
|
+
9: "#6b21a8",
|
|
313
|
+
10: "#581c87",
|
|
314
|
+
11: "#3b0764",
|
|
315
|
+
12: "#23043c"
|
|
316
|
+
},
|
|
317
|
+
fuchsia: {
|
|
318
|
+
1: "#fdf4ff",
|
|
319
|
+
2: "#fae8ff",
|
|
320
|
+
3: "#f5d0fe",
|
|
321
|
+
4: "#f0abfc",
|
|
322
|
+
5: "#e879f9",
|
|
323
|
+
6: "#d946ef",
|
|
324
|
+
7: "#c026d3",
|
|
325
|
+
8: "#a21caf",
|
|
326
|
+
9: "#86198f",
|
|
327
|
+
10: "#701a75",
|
|
328
|
+
11: "#4a044e",
|
|
329
|
+
12: "#2d022f"
|
|
330
|
+
},
|
|
331
|
+
pink: {
|
|
332
|
+
1: "#fdf2f8",
|
|
333
|
+
2: "#fce7f3",
|
|
334
|
+
3: "#fbcfe8",
|
|
335
|
+
4: "#f9a8d4",
|
|
336
|
+
5: "#f472b6",
|
|
337
|
+
6: "#ec4899",
|
|
338
|
+
7: "#db2777",
|
|
339
|
+
8: "#be185d",
|
|
340
|
+
9: "#9d174d",
|
|
341
|
+
10: "#831843",
|
|
342
|
+
11: "#500724",
|
|
343
|
+
12: "#300415"
|
|
344
|
+
},
|
|
345
|
+
rose: {
|
|
346
|
+
1: "#fff1f2",
|
|
347
|
+
2: "#ffe4e6",
|
|
348
|
+
3: "#fecdd3",
|
|
349
|
+
4: "#fda4af",
|
|
350
|
+
5: "#fb7185",
|
|
351
|
+
6: "#f43f5e",
|
|
352
|
+
7: "#e11d48",
|
|
353
|
+
8: "#be123c",
|
|
354
|
+
9: "#9f1239",
|
|
355
|
+
10: "#881337",
|
|
356
|
+
11: "#4c0519",
|
|
357
|
+
12: "#2d030e"
|
|
358
|
+
}
|
|
359
|
+
};
|
|
360
|
+
var defaultTheme = {
|
|
361
|
+
colors: defaultColors,
|
|
362
|
+
// 1 unit = 4px
|
|
363
|
+
spacing: {
|
|
364
|
+
px: 1,
|
|
365
|
+
0: 0,
|
|
366
|
+
"0.5": 2,
|
|
367
|
+
1: 4,
|
|
368
|
+
"1.5": 6,
|
|
369
|
+
2: 8,
|
|
370
|
+
"2.5": 10,
|
|
371
|
+
3: 12,
|
|
372
|
+
"3.5": 14,
|
|
373
|
+
4: 16,
|
|
374
|
+
5: 20,
|
|
375
|
+
6: 24,
|
|
376
|
+
7: 28,
|
|
377
|
+
8: 32,
|
|
378
|
+
9: 36,
|
|
379
|
+
10: 40,
|
|
380
|
+
11: 44,
|
|
381
|
+
12: 48,
|
|
382
|
+
14: 56,
|
|
383
|
+
16: 64,
|
|
384
|
+
20: 80,
|
|
385
|
+
24: 96,
|
|
386
|
+
28: 112,
|
|
387
|
+
32: 128,
|
|
388
|
+
36: 144,
|
|
389
|
+
40: 160,
|
|
390
|
+
44: 176,
|
|
391
|
+
48: 192,
|
|
392
|
+
52: 208,
|
|
393
|
+
56: 224,
|
|
394
|
+
60: 240,
|
|
395
|
+
64: 256,
|
|
396
|
+
72: 288,
|
|
397
|
+
80: 320,
|
|
398
|
+
96: 384,
|
|
399
|
+
auto: "auto",
|
|
400
|
+
full: "100%",
|
|
401
|
+
"1/2": "50%",
|
|
402
|
+
"1/3": "33.333333%",
|
|
403
|
+
"2/3": "66.666667%",
|
|
404
|
+
"1/4": "25%",
|
|
405
|
+
"3/4": "75%",
|
|
406
|
+
screen: "100vh",
|
|
407
|
+
min: "min-content",
|
|
408
|
+
max: "max-content",
|
|
409
|
+
fit: "fit-content"
|
|
410
|
+
},
|
|
411
|
+
fontSize: {
|
|
412
|
+
xs: 12,
|
|
413
|
+
sm: 14,
|
|
414
|
+
base: 16,
|
|
415
|
+
lg: 18,
|
|
416
|
+
xl: 20,
|
|
417
|
+
"2xl": 24,
|
|
418
|
+
"3xl": 30,
|
|
419
|
+
"4xl": 36,
|
|
420
|
+
"5xl": 48,
|
|
421
|
+
"6xl": 60,
|
|
422
|
+
"7xl": 72,
|
|
423
|
+
"8xl": 96,
|
|
424
|
+
"9xl": 128
|
|
425
|
+
},
|
|
426
|
+
fontFamily: {
|
|
427
|
+
sans: "System",
|
|
428
|
+
mono: "Courier New",
|
|
429
|
+
serif: "Georgia"
|
|
430
|
+
},
|
|
431
|
+
fontWeight: {
|
|
432
|
+
thin: "100",
|
|
433
|
+
extralight: "200",
|
|
434
|
+
light: "300",
|
|
435
|
+
normal: "400",
|
|
436
|
+
medium: "500",
|
|
437
|
+
semibold: "600",
|
|
438
|
+
bold: "700",
|
|
439
|
+
extrabold: "800",
|
|
440
|
+
black: "900"
|
|
441
|
+
},
|
|
442
|
+
borderRadius: {
|
|
443
|
+
none: 0,
|
|
444
|
+
sm: 2,
|
|
445
|
+
DEFAULT: 4,
|
|
446
|
+
md: 6,
|
|
447
|
+
lg: 8,
|
|
448
|
+
xl: 12,
|
|
449
|
+
"2xl": 16,
|
|
450
|
+
"3xl": 24,
|
|
451
|
+
full: 9999
|
|
452
|
+
},
|
|
453
|
+
borderWidth: {
|
|
454
|
+
DEFAULT: 1,
|
|
455
|
+
0: 0,
|
|
456
|
+
2: 2,
|
|
457
|
+
4: 4,
|
|
458
|
+
8: 8
|
|
459
|
+
},
|
|
460
|
+
opacity: {
|
|
461
|
+
0: 0,
|
|
462
|
+
5: 0.05,
|
|
463
|
+
10: 0.1,
|
|
464
|
+
15: 0.15,
|
|
465
|
+
20: 0.2,
|
|
466
|
+
25: 0.25,
|
|
467
|
+
30: 0.3,
|
|
468
|
+
40: 0.4,
|
|
469
|
+
50: 0.5,
|
|
470
|
+
60: 0.6,
|
|
471
|
+
70: 0.7,
|
|
472
|
+
75: 0.75,
|
|
473
|
+
80: 0.8,
|
|
474
|
+
90: 0.9,
|
|
475
|
+
95: 0.95,
|
|
476
|
+
100: 1
|
|
477
|
+
},
|
|
478
|
+
lineHeight: {
|
|
479
|
+
none: 1,
|
|
480
|
+
tight: 1.25,
|
|
481
|
+
snug: 1.375,
|
|
482
|
+
normal: 1.5,
|
|
483
|
+
relaxed: 1.625,
|
|
484
|
+
loose: 2,
|
|
485
|
+
// Pixel values stored as strings; styleValueToCSS passes them through, toNativeValue strips the unit
|
|
486
|
+
3: "12px",
|
|
487
|
+
4: "16px",
|
|
488
|
+
5: "20px",
|
|
489
|
+
6: "24px",
|
|
490
|
+
7: "28px",
|
|
491
|
+
8: "32px",
|
|
492
|
+
9: "36px",
|
|
493
|
+
10: "40px"
|
|
494
|
+
},
|
|
495
|
+
letterSpacing: {
|
|
496
|
+
tighter: -0.8,
|
|
497
|
+
tight: -0.4,
|
|
498
|
+
normal: 0,
|
|
499
|
+
wide: 0.4,
|
|
500
|
+
wider: 0.8,
|
|
501
|
+
widest: 1.6
|
|
502
|
+
},
|
|
503
|
+
zIndex: {
|
|
504
|
+
auto: "auto",
|
|
505
|
+
0: 0,
|
|
506
|
+
10: 10,
|
|
507
|
+
20: 20,
|
|
508
|
+
30: 30,
|
|
509
|
+
40: 40,
|
|
510
|
+
50: 50
|
|
511
|
+
},
|
|
512
|
+
flex: {
|
|
513
|
+
1: 1,
|
|
514
|
+
auto: "auto",
|
|
515
|
+
// CSS: flex: auto = 1 1 auto; native: mapped to 1 in resolver
|
|
516
|
+
initial: "initial",
|
|
517
|
+
// CSS: flex: initial = 0 1 auto; native: mapped to 1
|
|
518
|
+
none: "none"
|
|
519
|
+
// CSS: flex: none = 0 0 auto; native: mapped to 0
|
|
520
|
+
},
|
|
521
|
+
shadow: {
|
|
522
|
+
sm: {
|
|
523
|
+
shadowColor: "#000",
|
|
524
|
+
shadowOffset: { width: 0, height: 1 },
|
|
525
|
+
shadowOpacity: 0.05,
|
|
526
|
+
shadowRadius: 2,
|
|
527
|
+
elevation: 1
|
|
528
|
+
},
|
|
529
|
+
DEFAULT: {
|
|
530
|
+
shadowColor: "#000",
|
|
531
|
+
shadowOffset: { width: 0, height: 2 },
|
|
532
|
+
shadowOpacity: 0.1,
|
|
533
|
+
shadowRadius: 4,
|
|
534
|
+
elevation: 2
|
|
535
|
+
},
|
|
536
|
+
md: {
|
|
537
|
+
shadowColor: "#000",
|
|
538
|
+
shadowOffset: { width: 0, height: 4 },
|
|
539
|
+
shadowOpacity: 0.1,
|
|
540
|
+
shadowRadius: 8,
|
|
541
|
+
elevation: 3
|
|
542
|
+
},
|
|
543
|
+
lg: {
|
|
544
|
+
shadowColor: "#000",
|
|
545
|
+
shadowOffset: { width: 0, height: 8 },
|
|
546
|
+
shadowOpacity: 0.1,
|
|
547
|
+
shadowRadius: 15,
|
|
548
|
+
elevation: 4
|
|
549
|
+
},
|
|
550
|
+
xl: {
|
|
551
|
+
shadowColor: "#000",
|
|
552
|
+
shadowOffset: { width: 0, height: 16 },
|
|
553
|
+
shadowOpacity: 0.1,
|
|
554
|
+
shadowRadius: 24,
|
|
555
|
+
elevation: 6
|
|
556
|
+
},
|
|
557
|
+
"2xl": {
|
|
558
|
+
shadowColor: "#000",
|
|
559
|
+
shadowOffset: { width: 0, height: 24 },
|
|
560
|
+
shadowOpacity: 0.25,
|
|
561
|
+
shadowRadius: 48,
|
|
562
|
+
elevation: 8
|
|
563
|
+
},
|
|
564
|
+
none: {
|
|
565
|
+
shadowColor: "transparent",
|
|
566
|
+
shadowOffset: { width: 0, height: 0 },
|
|
567
|
+
shadowOpacity: 0,
|
|
568
|
+
shadowRadius: 0,
|
|
569
|
+
elevation: 0
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
screens: {
|
|
573
|
+
sm: 576,
|
|
574
|
+
// small tablets / large phones (landscape)
|
|
575
|
+
md: 768,
|
|
576
|
+
// tablets (iPad and up)
|
|
577
|
+
lg: 1024,
|
|
578
|
+
// large tablets (iPad Pro)
|
|
579
|
+
xl: 1280,
|
|
580
|
+
// desktop
|
|
581
|
+
"2xl": 1536
|
|
582
|
+
}
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
// src/core/utilities.ts
|
|
586
|
+
function resolveColor(value, colors, isArbitrary) {
|
|
587
|
+
if (isArbitrary) return value;
|
|
588
|
+
const slashIdx = value.indexOf("/");
|
|
589
|
+
const colorPart = slashIdx > 0 ? value.slice(0, slashIdx) : value;
|
|
590
|
+
const opacityPart = slashIdx > 0 ? value.slice(slashIdx + 1) : null;
|
|
591
|
+
let hex = null;
|
|
592
|
+
if (colorPart in colors) {
|
|
593
|
+
const entry = colors[colorPart];
|
|
594
|
+
if (typeof entry === "string") hex = entry;
|
|
595
|
+
else if (typeof entry === "object" && "6" in entry) hex = entry["6"];
|
|
596
|
+
} else {
|
|
597
|
+
const lastDash = colorPart.lastIndexOf("-");
|
|
598
|
+
if (lastDash > 0) {
|
|
599
|
+
const colorName = colorPart.slice(0, lastDash);
|
|
600
|
+
const shade = colorPart.slice(lastDash + 1);
|
|
601
|
+
const scale = colors[colorName];
|
|
602
|
+
if (scale && typeof scale === "object" && shade in scale) {
|
|
603
|
+
hex = scale[shade] ?? null;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
if (hex && !hex.startsWith("#") && !hex.startsWith("rgb") && hex !== "transparent" && hex !== "currentColor") {
|
|
608
|
+
if (hex in colors) {
|
|
609
|
+
const alias = colors[hex];
|
|
610
|
+
if (typeof alias === "string") hex = alias;
|
|
611
|
+
else if (typeof alias === "object" && "6" in alias) hex = alias["6"] ?? hex;
|
|
612
|
+
} else {
|
|
613
|
+
const aliasLastDash = hex.lastIndexOf("-");
|
|
614
|
+
if (aliasLastDash > 0) {
|
|
615
|
+
const aliasColorName = hex.slice(0, aliasLastDash);
|
|
616
|
+
const aliasShade = hex.slice(aliasLastDash + 1);
|
|
617
|
+
const aliasScale = colors[aliasColorName];
|
|
618
|
+
if (aliasScale && typeof aliasScale === "object") {
|
|
619
|
+
hex = aliasScale[aliasShade] ?? null;
|
|
620
|
+
} else if (typeof aliasScale === "string") {
|
|
621
|
+
hex = aliasScale;
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
if (!hex) return null;
|
|
627
|
+
if (!opacityPart) {
|
|
628
|
+
if (!getEffectiveIsWeb() && hex.startsWith("#") && hex.length === 9) {
|
|
629
|
+
return hexToRgba(hex, Math.round(parseInt(hex.slice(7, 9), 16) / 255 * 1e3) / 1e3);
|
|
630
|
+
}
|
|
631
|
+
return hex;
|
|
632
|
+
}
|
|
633
|
+
let alpha;
|
|
634
|
+
if (opacityPart.startsWith("[") && opacityPart.endsWith("]")) {
|
|
635
|
+
const v = parseFloat(opacityPart.slice(1, -1));
|
|
636
|
+
alpha = v > 1 ? v / 100 : v;
|
|
637
|
+
} else {
|
|
638
|
+
alpha = parseFloat(opacityPart) / 100;
|
|
639
|
+
}
|
|
640
|
+
if (isNaN(alpha)) return hex;
|
|
641
|
+
return hexToRgba(hex, alpha);
|
|
642
|
+
}
|
|
643
|
+
function parseHexRgb(hex) {
|
|
644
|
+
const h = hex.replace("#", "");
|
|
645
|
+
if (h.length === 3 || h.length === 4) {
|
|
646
|
+
return [
|
|
647
|
+
parseInt(h[0] + h[0], 16),
|
|
648
|
+
parseInt(h[1] + h[1], 16),
|
|
649
|
+
parseInt(h[2] + h[2], 16)
|
|
650
|
+
];
|
|
651
|
+
}
|
|
652
|
+
if (h.length === 6 || h.length === 8) {
|
|
653
|
+
return [
|
|
654
|
+
parseInt(h.slice(0, 2), 16),
|
|
655
|
+
parseInt(h.slice(2, 4), 16),
|
|
656
|
+
parseInt(h.slice(4, 6), 16)
|
|
657
|
+
];
|
|
658
|
+
}
|
|
659
|
+
return null;
|
|
660
|
+
}
|
|
661
|
+
function hexToRgba(hex, alpha) {
|
|
662
|
+
const rgb = parseHexRgb(hex);
|
|
663
|
+
if (!rgb) return hex;
|
|
664
|
+
const [r, g, b] = rgb;
|
|
665
|
+
return `rgba(${r},${g},${b},${alpha})`;
|
|
666
|
+
}
|
|
667
|
+
function resolveSpacing(value, negative, spacing, isArbitrary) {
|
|
668
|
+
if (isArbitrary) {
|
|
669
|
+
const resolved = getEffectiveIsWeb() ? value : toNativeValue(value);
|
|
670
|
+
if (negative) {
|
|
671
|
+
if (typeof resolved === "number") return -resolved;
|
|
672
|
+
if (typeof resolved === "string") {
|
|
673
|
+
if (/^\d/.test(resolved)) return `-${resolved}`;
|
|
674
|
+
if (/^(calc|var|min|max|clamp|env)\s*\(/.test(resolved)) return `calc(-1 * (${resolved}))`;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
return resolved;
|
|
678
|
+
}
|
|
679
|
+
const raw = spacing[value];
|
|
680
|
+
if (raw === void 0) return null;
|
|
681
|
+
if (typeof raw === "number") return negative ? -raw : raw;
|
|
682
|
+
if (raw === "auto") return "auto";
|
|
683
|
+
if (negative && typeof raw === "string" && raw.endsWith("%")) {
|
|
684
|
+
return `-${raw}`;
|
|
685
|
+
}
|
|
686
|
+
return raw;
|
|
687
|
+
}
|
|
688
|
+
function resolveSizing(value, spacing, isArbitrary) {
|
|
689
|
+
if (isArbitrary) return getEffectiveIsWeb() ? value : toNativeValue(value);
|
|
690
|
+
const raw = spacing[value];
|
|
691
|
+
if (raw !== void 0) return raw;
|
|
692
|
+
if (/^\d+\/\d+$/.test(value)) {
|
|
693
|
+
const [num, den] = value.split("/").map(Number);
|
|
694
|
+
if (!den) return null;
|
|
695
|
+
return `${(num / den * 100).toFixed(6)}%`;
|
|
696
|
+
}
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
function resolveRadius(value, radii, isArbitrary) {
|
|
700
|
+
if (isArbitrary) return getEffectiveIsWeb() ? value : toNativeValue(value);
|
|
701
|
+
const key = value === "" ? "DEFAULT" : value;
|
|
702
|
+
return radii[key] ?? null;
|
|
703
|
+
}
|
|
704
|
+
function resolveFontSize(value, fontSizes, isArbitrary) {
|
|
705
|
+
if (isArbitrary) return getEffectiveIsWeb() ? value : toNativeValue(value);
|
|
706
|
+
return fontSizes[value] ?? null;
|
|
707
|
+
}
|
|
708
|
+
var FILTER_COMPOSE = "var(--kb-blur,) var(--kb-brightness,) var(--kb-contrast,) var(--kb-grayscale,) var(--kb-hue-rotate,) var(--kb-invert,) var(--kb-saturate,) var(--kb-sepia,) var(--kb-drop-shadow,)";
|
|
709
|
+
var BACKDROP_FILTER_COMPOSE = "var(--kb-backdrop-blur,) var(--kb-backdrop-brightness,) var(--kb-backdrop-contrast,) var(--kb-backdrop-grayscale,) var(--kb-backdrop-hue-rotate,) var(--kb-backdrop-invert,) var(--kb-backdrop-opacity,) var(--kb-backdrop-saturate,) var(--kb-backdrop-sepia,)";
|
|
710
|
+
var _standalone = null;
|
|
711
|
+
function buildStandalone() {
|
|
712
|
+
const web = getEffectiveIsWeb();
|
|
713
|
+
return {
|
|
714
|
+
// Display
|
|
715
|
+
// React Native only supports display:'flex'|'none'. Setting 'flex' explicitly is
|
|
716
|
+
// a no-op normally, but is needed to re-show an element that was hidden via `hidden`.
|
|
717
|
+
// `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
|
|
718
|
+
flex: { display: "flex" },
|
|
719
|
+
block: web ? { display: "block" } : null,
|
|
720
|
+
"inline-block": web ? { display: "inline-block" } : null,
|
|
721
|
+
inline: web ? { display: "inline" } : null,
|
|
722
|
+
grid: web ? { display: "grid" } : null,
|
|
723
|
+
grd: web ? { display: "grid" } : null,
|
|
724
|
+
"inline-flex": { display: web ? "inline-flex" : "flex" },
|
|
725
|
+
"inline-grid": web ? { display: "inline-grid" } : null,
|
|
726
|
+
hidden: { display: "none" },
|
|
727
|
+
contents: web ? { display: "contents" } : null,
|
|
728
|
+
"flow-root": web ? { display: "flow-root" } : null,
|
|
729
|
+
// Flex direction (both web and native)
|
|
730
|
+
"flex-row": { flexDirection: "row" },
|
|
731
|
+
"flex-col": { flexDirection: "column" },
|
|
732
|
+
"flex-row-reverse": { flexDirection: "row-reverse" },
|
|
733
|
+
"flex-col-reverse": { flexDirection: "column-reverse" },
|
|
734
|
+
// Flex wrap (both)
|
|
735
|
+
"flex-wrap": { flexWrap: "wrap" },
|
|
736
|
+
"flex-wrap-reverse": { flexWrap: "wrap-reverse" },
|
|
737
|
+
"flex-nowrap": { flexWrap: "nowrap" },
|
|
738
|
+
// Flex grow / shrink (both)
|
|
739
|
+
"flex-grow": { flexGrow: 1 },
|
|
740
|
+
"flex-grow-0": { flexGrow: 0 },
|
|
741
|
+
"flex-shrink": { flexShrink: 1 },
|
|
742
|
+
"flex-shrink-0": { flexShrink: 0 },
|
|
743
|
+
// Align items (both)
|
|
744
|
+
"items-start": { alignItems: "flex-start" },
|
|
745
|
+
"items-end": { alignItems: "flex-end" },
|
|
746
|
+
"items-center": { alignItems: "center" },
|
|
747
|
+
"items-baseline": { alignItems: "baseline" },
|
|
748
|
+
"items-stretch": { alignItems: "stretch" },
|
|
749
|
+
// Justify content (both)
|
|
750
|
+
"justify-start": { justifyContent: "flex-start" },
|
|
751
|
+
"justify-end": { justifyContent: "flex-end" },
|
|
752
|
+
"justify-center": { justifyContent: "center" },
|
|
753
|
+
"justify-between": { justifyContent: "space-between" },
|
|
754
|
+
"justify-around": { justifyContent: "space-around" },
|
|
755
|
+
"justify-evenly": { justifyContent: "space-evenly" },
|
|
756
|
+
// Align content (both)
|
|
757
|
+
"content-start": { alignContent: "flex-start" },
|
|
758
|
+
"content-end": { alignContent: "flex-end" },
|
|
759
|
+
"content-center": { alignContent: "center" },
|
|
760
|
+
"content-between": { alignContent: "space-between" },
|
|
761
|
+
"content-around": { alignContent: "space-around" },
|
|
762
|
+
"content-evenly": { alignContent: "space-evenly" },
|
|
763
|
+
"content-stretch": { alignContent: "stretch" },
|
|
764
|
+
// Align self (both)
|
|
765
|
+
"self-auto": { alignSelf: "auto" },
|
|
766
|
+
"self-start": { alignSelf: "flex-start" },
|
|
767
|
+
"self-end": { alignSelf: "flex-end" },
|
|
768
|
+
"self-center": { alignSelf: "center" },
|
|
769
|
+
"self-stretch": { alignSelf: "stretch" },
|
|
770
|
+
"self-baseline": { alignSelf: "baseline" },
|
|
771
|
+
// Text align (both)
|
|
772
|
+
"text-left": { textAlign: "left" },
|
|
773
|
+
"text-right": { textAlign: "right" },
|
|
774
|
+
"text-center": { textAlign: "center" },
|
|
775
|
+
"text-justify": { textAlign: "justify" },
|
|
776
|
+
// Font weight shortcuts (both)
|
|
777
|
+
"font-thin": { fontWeight: "100" },
|
|
778
|
+
"font-extralight": { fontWeight: "200" },
|
|
779
|
+
"font-light": { fontWeight: "300" },
|
|
780
|
+
"font-normal": { fontWeight: "400" },
|
|
781
|
+
"font-medium": { fontWeight: "500" },
|
|
782
|
+
"font-semibold": { fontWeight: "600" },
|
|
783
|
+
"font-bold": { fontWeight: "700" },
|
|
784
|
+
"font-extrabold": { fontWeight: "800" },
|
|
785
|
+
"font-black": { fontWeight: "900" },
|
|
786
|
+
// Text decoration (overline is web-only)
|
|
787
|
+
underline: { textDecorationLine: "underline" },
|
|
788
|
+
overline: web ? { textDecorationLine: "overline" } : null,
|
|
789
|
+
"line-through": { textDecorationLine: "line-through" },
|
|
790
|
+
"no-underline": { textDecorationLine: "none" },
|
|
791
|
+
// Text transform (both)
|
|
792
|
+
uppercase: { textTransform: "uppercase" },
|
|
793
|
+
lowercase: { textTransform: "lowercase" },
|
|
794
|
+
capitalize: { textTransform: "capitalize" },
|
|
795
|
+
"normal-case": { textTransform: "none" },
|
|
796
|
+
// Font style (both)
|
|
797
|
+
italic: { fontStyle: "italic" },
|
|
798
|
+
"non-italic": { fontStyle: "normal" },
|
|
799
|
+
// Position (fixed/sticky/static are web-only; RN only supports relative/absolute)
|
|
800
|
+
relative: { position: "relative" },
|
|
801
|
+
absolute: { position: "absolute" },
|
|
802
|
+
fixed: web ? { position: "fixed" } : null,
|
|
803
|
+
sticky: web ? { position: "sticky" } : null,
|
|
804
|
+
static: web ? { position: "static" } : null,
|
|
805
|
+
// Visibility (no `visibility` prop on native; use opacity instead)
|
|
806
|
+
visible: web ? { visibility: "visible" } : null,
|
|
807
|
+
invisible: web ? { visibility: "hidden" } : { opacity: 0 },
|
|
808
|
+
// Overflow (RN supports 'hidden' | 'visible' | 'scroll'; not 'auto')
|
|
809
|
+
"overflow-hidden": { overflow: "hidden" },
|
|
810
|
+
"overflow-visible": { overflow: "visible" },
|
|
811
|
+
"overflow-scroll": { overflow: "scroll" },
|
|
812
|
+
"overflow-auto": web ? { overflow: "auto" } : { overflow: "scroll" },
|
|
813
|
+
// overflowX / overflowY are web-only
|
|
814
|
+
"overflow-x-hidden": web ? { overflowX: "hidden" } : null,
|
|
815
|
+
"overflow-x-scroll": web ? { overflowX: "scroll" } : null,
|
|
816
|
+
"overflow-x-auto": web ? { overflowX: "auto" } : null,
|
|
817
|
+
"overflow-y-hidden": web ? { overflowY: "hidden" } : null,
|
|
818
|
+
"overflow-y-scroll": web ? { overflowY: "scroll" } : null,
|
|
819
|
+
"overflow-y-auto": web ? { overflowY: "auto" } : null,
|
|
820
|
+
// Object fit (web-only; use resizeMode prop on RN Image)
|
|
821
|
+
"object-contain": web ? { objectFit: "contain" } : null,
|
|
822
|
+
"object-cover": web ? { objectFit: "cover" } : null,
|
|
823
|
+
"object-fill": web ? { objectFit: "fill" } : null,
|
|
824
|
+
"object-none": web ? { objectFit: "none" } : null,
|
|
825
|
+
"object-scale-down": web ? { objectFit: "scale-down" } : null,
|
|
826
|
+
// Border style (both)
|
|
827
|
+
"border-solid": { borderStyle: "solid" },
|
|
828
|
+
"border-dashed": { borderStyle: "dashed" },
|
|
829
|
+
"border-dotted": { borderStyle: "dotted" },
|
|
830
|
+
"border-none": { borderWidth: 0 },
|
|
831
|
+
// Border sides default width (both)
|
|
832
|
+
"border-t": { borderTopWidth: 1 },
|
|
833
|
+
"border-r": { borderRightWidth: 1 },
|
|
834
|
+
"border-b": { borderBottomWidth: 1 },
|
|
835
|
+
"border-l": { borderLeftWidth: 1 },
|
|
836
|
+
// Cursor (web-only)
|
|
837
|
+
"cursor-auto": web ? { cursor: "auto" } : null,
|
|
838
|
+
"cursor-default": web ? { cursor: "default" } : null,
|
|
839
|
+
"cursor-pointer": web ? { cursor: "pointer" } : null,
|
|
840
|
+
"cursor-wait": web ? { cursor: "wait" } : null,
|
|
841
|
+
"cursor-text": web ? { cursor: "text" } : null,
|
|
842
|
+
"cursor-move": web ? { cursor: "move" } : null,
|
|
843
|
+
"cursor-not-allowed": web ? { cursor: "not-allowed" } : null,
|
|
844
|
+
// User select (web-only)
|
|
845
|
+
"select-none": web ? { userSelect: "none" } : null,
|
|
846
|
+
"select-text": web ? { userSelect: "text" } : null,
|
|
847
|
+
"select-all": web ? { userSelect: "all" } : null,
|
|
848
|
+
"select-auto": web ? { userSelect: "auto" } : null,
|
|
849
|
+
// Pointer events (both)
|
|
850
|
+
"pointer-events-none": { pointerEvents: "none" },
|
|
851
|
+
"pointer-events-auto": { pointerEvents: "auto" },
|
|
852
|
+
// Whitespace (web-only; RN Text uses numberOfLines prop instead)
|
|
853
|
+
"whitespace-normal": web ? { whiteSpace: "normal" } : null,
|
|
854
|
+
"whitespace-nowrap": web ? { whiteSpace: "nowrap" } : null,
|
|
855
|
+
"whitespace-pre": web ? { whiteSpace: "pre" } : null,
|
|
856
|
+
"whitespace-pre-wrap": web ? { whiteSpace: "pre-wrap" } : null,
|
|
857
|
+
"whitespace-pre-line": web ? { whiteSpace: "pre-line" } : null,
|
|
858
|
+
// Word break (web-only)
|
|
859
|
+
"break-normal": web ? { overflowWrap: "normal", wordBreak: "normal" } : null,
|
|
860
|
+
"break-words": web ? { overflowWrap: "break-word" } : null,
|
|
861
|
+
"break-all": web ? { wordBreak: "break-all" } : null,
|
|
862
|
+
// Misc web-only
|
|
863
|
+
truncate: web ? { overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } : null,
|
|
864
|
+
"box-border": web ? { boxSizing: "border-box" } : null,
|
|
865
|
+
"box-content": web ? { boxSizing: "content-box" } : null,
|
|
866
|
+
"appearance-none": web ? { appearance: "none" } : null,
|
|
867
|
+
"outline-none": web ? { outline: "none", outlineOffset: "0" } : null,
|
|
868
|
+
outline: web ? { outline: "2px solid transparent", outlineOffset: "2px" } : null,
|
|
869
|
+
resize: web ? { resize: "both" } : null,
|
|
870
|
+
"resize-none": web ? { resize: "none" } : null,
|
|
871
|
+
"resize-y": web ? { resize: "vertical" } : null,
|
|
872
|
+
"resize-x": web ? { resize: "horizontal" } : null,
|
|
873
|
+
antialiased: web ? { WebkitFontSmoothing: "antialiased", MozOsxFontSmoothing: "grayscale" } : null,
|
|
874
|
+
"subpixel-antialiased": web ? { WebkitFontSmoothing: "subpixel-antialiased", MozOsxFontSmoothing: "auto" } : null,
|
|
875
|
+
"overflow-ellipsis": web ? { textOverflow: "ellipsis" } : null,
|
|
876
|
+
"sr-only": web ? {
|
|
877
|
+
position: "absolute",
|
|
878
|
+
width: 1,
|
|
879
|
+
height: 1,
|
|
880
|
+
padding: 0,
|
|
881
|
+
margin: -1,
|
|
882
|
+
overflow: "hidden",
|
|
883
|
+
clip: "rect(0,0,0,0)",
|
|
884
|
+
whiteSpace: "nowrap",
|
|
885
|
+
border: 0
|
|
886
|
+
} : null,
|
|
887
|
+
"not-sr-only": web ? {
|
|
888
|
+
position: "static",
|
|
889
|
+
width: "auto",
|
|
890
|
+
height: "auto",
|
|
891
|
+
padding: 0,
|
|
892
|
+
margin: 0,
|
|
893
|
+
overflow: "visible",
|
|
894
|
+
clip: "auto",
|
|
895
|
+
whiteSpace: "normal"
|
|
896
|
+
} : null,
|
|
897
|
+
// Lists (web-only)
|
|
898
|
+
"list-none": web ? { listStyleType: "none" } : null,
|
|
899
|
+
"list-disc": web ? { listStyleType: "disc" } : null,
|
|
900
|
+
"list-decimal": web ? { listStyleType: "decimal" } : null,
|
|
901
|
+
// Background clip (web-only)
|
|
902
|
+
"bg-clip-border": web ? { backgroundClip: "border-box" } : null,
|
|
903
|
+
"bg-clip-padding": web ? { backgroundClip: "padding-box" } : null,
|
|
904
|
+
"bg-clip-content": web ? { backgroundClip: "content-box" } : null,
|
|
905
|
+
"bg-clip-text": web ? { backgroundClip: "text", WebkitBackgroundClip: "text" } : null,
|
|
906
|
+
// Background image
|
|
907
|
+
"bg-none": web ? { backgroundImage: "none" } : null,
|
|
908
|
+
// Background size (web-only)
|
|
909
|
+
"bg-auto": web ? { backgroundSize: "auto" } : null,
|
|
910
|
+
"bg-cover": web ? { backgroundSize: "cover" } : null,
|
|
911
|
+
"bg-contain": web ? { backgroundSize: "contain" } : null,
|
|
912
|
+
// Background position (web-only)
|
|
913
|
+
"bg-center": web ? { backgroundPosition: "center" } : null,
|
|
914
|
+
"bg-top": web ? { backgroundPosition: "top" } : null,
|
|
915
|
+
"bg-bottom": web ? { backgroundPosition: "bottom" } : null,
|
|
916
|
+
"bg-left": web ? { backgroundPosition: "left" } : null,
|
|
917
|
+
"bg-right": web ? { backgroundPosition: "right" } : null,
|
|
918
|
+
"bg-left-top": web ? { backgroundPosition: "left top" } : null,
|
|
919
|
+
"bg-left-bottom": web ? { backgroundPosition: "left bottom" } : null,
|
|
920
|
+
"bg-right-top": web ? { backgroundPosition: "right top" } : null,
|
|
921
|
+
"bg-right-bottom": web ? { backgroundPosition: "right bottom" } : null,
|
|
922
|
+
// Background repeat (web-only)
|
|
923
|
+
"bg-repeat": web ? { backgroundRepeat: "repeat" } : null,
|
|
924
|
+
"bg-no-repeat": web ? { backgroundRepeat: "no-repeat" } : null,
|
|
925
|
+
"bg-repeat-x": web ? { backgroundRepeat: "repeat-x" } : null,
|
|
926
|
+
"bg-repeat-y": web ? { backgroundRepeat: "repeat-y" } : null,
|
|
927
|
+
"bg-repeat-round": web ? { backgroundRepeat: "round" } : null,
|
|
928
|
+
"bg-repeat-space": web ? { backgroundRepeat: "space" } : null,
|
|
929
|
+
// Background attachment (web-only)
|
|
930
|
+
"bg-fixed": web ? { backgroundAttachment: "fixed" } : null,
|
|
931
|
+
"bg-local": web ? { backgroundAttachment: "local" } : null,
|
|
932
|
+
"bg-scroll": web ? { backgroundAttachment: "scroll" } : null,
|
|
933
|
+
// Object position (web-only)
|
|
934
|
+
"object-center": web ? { objectPosition: "center" } : null,
|
|
935
|
+
"object-top": web ? { objectPosition: "top" } : null,
|
|
936
|
+
"object-bottom": web ? { objectPosition: "bottom" } : null,
|
|
937
|
+
"object-left": web ? { objectPosition: "left" } : null,
|
|
938
|
+
"object-right": web ? { objectPosition: "right" } : null,
|
|
939
|
+
"object-left-top": web ? { objectPosition: "left top" } : null,
|
|
940
|
+
"object-left-bottom": web ? { objectPosition: "left bottom" } : null,
|
|
941
|
+
"object-right-top": web ? { objectPosition: "right top" } : null,
|
|
942
|
+
"object-right-bottom": web ? { objectPosition: "right bottom" } : null,
|
|
943
|
+
// Table (web-only)
|
|
944
|
+
table: web ? { display: "table" } : null,
|
|
945
|
+
"table-auto": web ? { tableLayout: "auto" } : null,
|
|
946
|
+
"table-fixed": web ? { tableLayout: "fixed" } : null,
|
|
947
|
+
"caption-top": web ? { captionSide: "top" } : null,
|
|
948
|
+
"caption-bottom": web ? { captionSide: "bottom" } : null,
|
|
949
|
+
"border-collapse": web ? { borderCollapse: "collapse" } : null,
|
|
950
|
+
"border-separate": web ? { borderCollapse: "separate" } : null,
|
|
951
|
+
// List style position (web-only)
|
|
952
|
+
"list-inside": web ? { listStylePosition: "inside" } : null,
|
|
953
|
+
"list-outside": web ? { listStylePosition: "outside" } : null,
|
|
954
|
+
// Font variant numeric (web-only)
|
|
955
|
+
"normal-nums": web ? { fontVariantNumeric: "normal" } : null,
|
|
956
|
+
ordinal: web ? { fontVariantNumeric: "ordinal" } : null,
|
|
957
|
+
"slashed-zero": web ? { fontVariantNumeric: "slashed-zero" } : null,
|
|
958
|
+
"lining-nums": web ? { fontVariantNumeric: "lining-nums" } : null,
|
|
959
|
+
"oldstyle-nums": web ? { fontVariantNumeric: "oldstyle-nums" } : null,
|
|
960
|
+
"proportional-nums": web ? { fontVariantNumeric: "proportional-nums" } : null,
|
|
961
|
+
"tabular-nums": web ? { fontVariantNumeric: "tabular-nums" } : null,
|
|
962
|
+
"diagonal-fractions": web ? { fontVariantNumeric: "diagonal-fractions" } : null,
|
|
963
|
+
"stacked-fractions": web ? { fontVariantNumeric: "stacked-fractions" } : null,
|
|
964
|
+
// Isolation (web-only)
|
|
965
|
+
isolate: web ? { isolation: "isolate" } : null,
|
|
966
|
+
"isolation-auto": web ? { isolation: "auto" } : null,
|
|
967
|
+
// Backface visibility (both iOS and Android)
|
|
968
|
+
"backface-visible": { backfaceVisibility: "visible" },
|
|
969
|
+
"backface-hidden": { backfaceVisibility: "hidden" },
|
|
970
|
+
// CSS filters — standalone = default/full effect (web-only)
|
|
971
|
+
grayscale: web ? { "--kb-grayscale": "grayscale(100%)", filter: FILTER_COMPOSE } : null,
|
|
972
|
+
invert: web ? { "--kb-invert": "invert(100%)", filter: FILTER_COMPOSE } : null,
|
|
973
|
+
sepia: web ? { "--kb-sepia": "sepia(100%)", filter: FILTER_COMPOSE } : null,
|
|
974
|
+
// Divide none
|
|
975
|
+
"divide-none": web ? { __divideX: 0, __divideY: 0 } : null,
|
|
976
|
+
// Group / peer markers (no-op: no style emitted; just ensures isKnownUtility returns true)
|
|
977
|
+
group: web ? {} : null,
|
|
978
|
+
peer: web ? {} : null,
|
|
979
|
+
// Text-wrap (web-only)
|
|
980
|
+
"text-wrap": web ? { textWrap: "wrap" } : null,
|
|
981
|
+
"text-nowrap": web ? { textWrap: "nowrap" } : null,
|
|
982
|
+
"text-balance": web ? { textWrap: "balance" } : null,
|
|
983
|
+
"text-pretty": web ? { textWrap: "pretty" } : null,
|
|
984
|
+
// Screen sizing (vw values are web-only; vh values work cross-platform via spacing scale for h-*)
|
|
985
|
+
"w-screen": web ? { width: "100vw" } : null,
|
|
986
|
+
"min-h-screen": { minHeight: "100vh" },
|
|
987
|
+
"max-h-screen": { maxHeight: "100vh" },
|
|
988
|
+
"min-w-screen": web ? { minWidth: "100vw" } : null,
|
|
989
|
+
"max-w-screen": web ? { maxWidth: "100vw" } : null,
|
|
990
|
+
// max-w named container sizes (mirrors Tailwind's container scale)
|
|
991
|
+
"max-w-none": { maxWidth: "none" },
|
|
992
|
+
"max-w-xs": { maxWidth: 320 },
|
|
993
|
+
"max-w-sm": { maxWidth: 384 },
|
|
994
|
+
"max-w-md": { maxWidth: 448 },
|
|
995
|
+
"max-w-lg": { maxWidth: 512 },
|
|
996
|
+
"max-w-xl": { maxWidth: 576 },
|
|
997
|
+
"max-w-2xl": { maxWidth: 672 },
|
|
998
|
+
"max-w-3xl": { maxWidth: 768 },
|
|
999
|
+
"max-w-4xl": { maxWidth: 896 },
|
|
1000
|
+
"max-w-5xl": { maxWidth: 1024 },
|
|
1001
|
+
"max-w-6xl": { maxWidth: 1152 },
|
|
1002
|
+
"max-w-7xl": { maxWidth: 1280 },
|
|
1003
|
+
"max-w-prose": web ? { maxWidth: "65ch" } : null,
|
|
1004
|
+
// Extended cursors (web-only)
|
|
1005
|
+
"cursor-grab": web ? { cursor: "grab" } : null,
|
|
1006
|
+
"cursor-grabbing": web ? { cursor: "grabbing" } : null,
|
|
1007
|
+
"cursor-zoom-in": web ? { cursor: "zoom-in" } : null,
|
|
1008
|
+
"cursor-zoom-out": web ? { cursor: "zoom-out" } : null,
|
|
1009
|
+
"cursor-crosshair": web ? { cursor: "crosshair" } : null,
|
|
1010
|
+
"cursor-help": web ? { cursor: "help" } : null,
|
|
1011
|
+
"cursor-none": web ? { cursor: "none" } : null,
|
|
1012
|
+
// Overflow clip (web-only)
|
|
1013
|
+
"overflow-clip": web ? { overflow: "clip" } : null,
|
|
1014
|
+
"overflow-x-clip": web ? { overflowX: "clip" } : null,
|
|
1015
|
+
"overflow-y-clip": web ? { overflowY: "clip" } : null,
|
|
1016
|
+
// Scroll behavior (web-only)
|
|
1017
|
+
"scroll-smooth": web ? { scrollBehavior: "smooth" } : null,
|
|
1018
|
+
"scroll-auto": web ? { scrollBehavior: "auto" } : null,
|
|
1019
|
+
// Float (web-only)
|
|
1020
|
+
"float-left": web ? { float: "left" } : null,
|
|
1021
|
+
"float-right": web ? { float: "right" } : null,
|
|
1022
|
+
"float-start": web ? { float: "inline-start" } : null,
|
|
1023
|
+
"float-end": web ? { float: "inline-end" } : null,
|
|
1024
|
+
"float-none": web ? { float: "none" } : null,
|
|
1025
|
+
// Clear (web-only)
|
|
1026
|
+
"clear-left": web ? { clear: "left" } : null,
|
|
1027
|
+
"clear-right": web ? { clear: "right" } : null,
|
|
1028
|
+
"clear-both": web ? { clear: "both" } : null,
|
|
1029
|
+
"clear-start": web ? { clear: "inline-start" } : null,
|
|
1030
|
+
"clear-end": web ? { clear: "inline-end" } : null,
|
|
1031
|
+
"clear-none": web ? { clear: "none" } : null,
|
|
1032
|
+
// Vertical align (web-only)
|
|
1033
|
+
"align-baseline": web ? { verticalAlign: "baseline" } : null,
|
|
1034
|
+
"align-top": web ? { verticalAlign: "top" } : null,
|
|
1035
|
+
"align-middle": web ? { verticalAlign: "middle" } : null,
|
|
1036
|
+
"align-bottom": web ? { verticalAlign: "bottom" } : null,
|
|
1037
|
+
"align-text-top": web ? { verticalAlign: "text-top" } : null,
|
|
1038
|
+
"align-text-bottom": web ? { verticalAlign: "text-bottom" } : null,
|
|
1039
|
+
"align-sub": web ? { verticalAlign: "sub" } : null,
|
|
1040
|
+
"align-super": web ? { verticalAlign: "super" } : null,
|
|
1041
|
+
// Touch action (web-only)
|
|
1042
|
+
"touch-auto": web ? { touchAction: "auto" } : null,
|
|
1043
|
+
"touch-none": web ? { touchAction: "none" } : null,
|
|
1044
|
+
"touch-pan-x": web ? { touchAction: "pan-x" } : null,
|
|
1045
|
+
"touch-pan-y": web ? { touchAction: "pan-y" } : null,
|
|
1046
|
+
"touch-pan-left": web ? { touchAction: "pan-left" } : null,
|
|
1047
|
+
"touch-pan-right": web ? { touchAction: "pan-right" } : null,
|
|
1048
|
+
"touch-pan-up": web ? { touchAction: "pan-up" } : null,
|
|
1049
|
+
"touch-pan-down": web ? { touchAction: "pan-down" } : null,
|
|
1050
|
+
"touch-pinch-zoom": web ? { touchAction: "pinch-zoom" } : null,
|
|
1051
|
+
"touch-manipulation": web ? { touchAction: "manipulation" } : null
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
function getStandalone() {
|
|
1055
|
+
if (!_standalone) _standalone = buildStandalone();
|
|
1056
|
+
return _standalone;
|
|
1057
|
+
}
|
|
1058
|
+
function makeSpacingResolver(prop) {
|
|
1059
|
+
return ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1060
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1061
|
+
return v !== null ? { [prop]: v } : null;
|
|
1062
|
+
};
|
|
1063
|
+
}
|
|
1064
|
+
var PADDING_MARGIN_PROPS = {
|
|
1065
|
+
p: "padding",
|
|
1066
|
+
px: "paddingHorizontal",
|
|
1067
|
+
py: "paddingVertical",
|
|
1068
|
+
pt: "paddingTop",
|
|
1069
|
+
pr: "paddingRight",
|
|
1070
|
+
pb: "paddingBottom",
|
|
1071
|
+
pl: "paddingLeft",
|
|
1072
|
+
m: "margin",
|
|
1073
|
+
mx: "marginHorizontal",
|
|
1074
|
+
my: "marginVertical",
|
|
1075
|
+
mt: "marginTop",
|
|
1076
|
+
mr: "marginRight",
|
|
1077
|
+
mb: "marginBottom",
|
|
1078
|
+
ml: "marginLeft"
|
|
1079
|
+
};
|
|
1080
|
+
function makeBorderSideResolver(widthProp, colorProp) {
|
|
1081
|
+
return ({ value, isArbitrary }, { colors, borderWidth }) => {
|
|
1082
|
+
if (!value) return { [widthProp]: 1 };
|
|
1083
|
+
if (isArbitrary) {
|
|
1084
|
+
const w2 = toNativeValue(value);
|
|
1085
|
+
if (typeof w2 === "number") return { [widthProp]: w2 };
|
|
1086
|
+
return { [colorProp]: value };
|
|
1087
|
+
}
|
|
1088
|
+
const color = resolveColor(value, colors, false);
|
|
1089
|
+
if (color) return { [colorProp]: color };
|
|
1090
|
+
const w = borderWidth[value];
|
|
1091
|
+
return w !== void 0 ? { [widthProp]: w } : null;
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
var BORDER_SIDE_PROPS = {
|
|
1095
|
+
"border-t": ["borderTopWidth", "borderTopColor"],
|
|
1096
|
+
"border-r": ["borderRightWidth", "borderRightColor"],
|
|
1097
|
+
"border-b": ["borderBottomWidth", "borderBottomColor"],
|
|
1098
|
+
"border-l": ["borderLeftWidth", "borderLeftColor"]
|
|
1099
|
+
};
|
|
1100
|
+
var RESOLVERS = {
|
|
1101
|
+
// ── Background ─────────────────────────────────────────────────────────────
|
|
1102
|
+
bg: ({ value, isArbitrary }, { colors }) => {
|
|
1103
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1104
|
+
return color ? { backgroundColor: color } : null;
|
|
1105
|
+
},
|
|
1106
|
+
"bg-opacity": ({ value, isArbitrary }, _) => {
|
|
1107
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1108
|
+
const n = parseFloat(value);
|
|
1109
|
+
if (isNaN(n)) return null;
|
|
1110
|
+
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1111
|
+
return { "--bg-opacity": v };
|
|
1112
|
+
},
|
|
1113
|
+
// ── Text ───────────────────────────────────────────────────────────────────
|
|
1114
|
+
text: ({ value, isArbitrary }, { colors, fontSize }) => {
|
|
1115
|
+
const size = resolveFontSize(value, fontSize, false);
|
|
1116
|
+
if (!isArbitrary && size !== null) return { fontSize: size };
|
|
1117
|
+
if (isArbitrary) {
|
|
1118
|
+
if (/^\d/.test(value) || /^(calc|min|max|clamp)/.test(value)) {
|
|
1119
|
+
return { fontSize: getEffectiveIsWeb() ? value : toNativeValue(value) };
|
|
1120
|
+
}
|
|
1121
|
+
return { color: value };
|
|
1122
|
+
}
|
|
1123
|
+
const color = resolveColor(value, colors, false);
|
|
1124
|
+
return color ? { color } : null;
|
|
1125
|
+
},
|
|
1126
|
+
"text-opacity": ({ value, isArbitrary }, _) => {
|
|
1127
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1128
|
+
const n = parseFloat(value);
|
|
1129
|
+
if (isNaN(n)) return null;
|
|
1130
|
+
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1131
|
+
return { "--text-opacity": v };
|
|
1132
|
+
},
|
|
1133
|
+
// ── Padding & margin ───────────────────────────────────────────────────────
|
|
1134
|
+
// Generated below via makeSpacingResolver() — see PADDING_MARGIN_PROPS.
|
|
1135
|
+
// ── Sizing ─────────────────────────────────────────────────────────────────
|
|
1136
|
+
w: ({ value, isArbitrary }, { spacing }) => {
|
|
1137
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1138
|
+
return v !== null ? { width: v } : null;
|
|
1139
|
+
},
|
|
1140
|
+
h: ({ value, isArbitrary }, { spacing }) => {
|
|
1141
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1142
|
+
return v !== null ? { height: v } : null;
|
|
1143
|
+
},
|
|
1144
|
+
"min-w": ({ value, isArbitrary }, { spacing }) => {
|
|
1145
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1146
|
+
return v !== null ? { minWidth: v } : null;
|
|
1147
|
+
},
|
|
1148
|
+
"min-h": ({ value, isArbitrary }, { spacing }) => {
|
|
1149
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1150
|
+
return v !== null ? { minHeight: v } : null;
|
|
1151
|
+
},
|
|
1152
|
+
"max-w": ({ value, isArbitrary }, { spacing }) => {
|
|
1153
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1154
|
+
return v !== null ? { maxWidth: v } : null;
|
|
1155
|
+
},
|
|
1156
|
+
"max-h": ({ value, isArbitrary }, { spacing }) => {
|
|
1157
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1158
|
+
return v !== null ? { maxHeight: v } : null;
|
|
1159
|
+
},
|
|
1160
|
+
// ── Border width ───────────────────────────────────────────────────────────
|
|
1161
|
+
border: ({ value, isArbitrary }, { colors, borderWidth, spacing }) => {
|
|
1162
|
+
if (!value) return { borderWidth: borderWidth["DEFAULT"] ?? 1 };
|
|
1163
|
+
if (isArbitrary) {
|
|
1164
|
+
const w2 = toNativeValue(value);
|
|
1165
|
+
if (typeof w2 === "number") return { borderWidth: w2 };
|
|
1166
|
+
return { borderColor: value };
|
|
1167
|
+
}
|
|
1168
|
+
const color = resolveColor(value, colors, false);
|
|
1169
|
+
if (color) return { borderColor: color };
|
|
1170
|
+
const w = borderWidth[value] ?? spacing[value];
|
|
1171
|
+
if (w !== void 0) {
|
|
1172
|
+
const numW = typeof w === "number" ? w : parseFloat(String(w));
|
|
1173
|
+
if (isNaN(numW)) return null;
|
|
1174
|
+
return { borderWidth: numW };
|
|
1175
|
+
}
|
|
1176
|
+
return null;
|
|
1177
|
+
},
|
|
1178
|
+
// border-t/-r/-b/-l generated below via makeBorderSideResolver() — see BORDER_SIDE_PROPS.
|
|
1179
|
+
// ── Border radius ──────────────────────────────────────────────────────────
|
|
1180
|
+
rounded: ({ value, isArbitrary }, { borderRadius }) => {
|
|
1181
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1182
|
+
return r !== null ? { borderRadius: r } : null;
|
|
1183
|
+
},
|
|
1184
|
+
"rounded-t": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1185
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1186
|
+
return r !== null ? { borderTopLeftRadius: r, borderTopRightRadius: r } : null;
|
|
1187
|
+
},
|
|
1188
|
+
"rounded-r": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1189
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1190
|
+
return r !== null ? { borderTopRightRadius: r, borderBottomRightRadius: r } : null;
|
|
1191
|
+
},
|
|
1192
|
+
"rounded-b": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1193
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1194
|
+
return r !== null ? { borderBottomLeftRadius: r, borderBottomRightRadius: r } : null;
|
|
1195
|
+
},
|
|
1196
|
+
"rounded-l": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1197
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1198
|
+
return r !== null ? { borderTopLeftRadius: r, borderBottomLeftRadius: r } : null;
|
|
1199
|
+
},
|
|
1200
|
+
"rounded-tl": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1201
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1202
|
+
return r !== null ? { borderTopLeftRadius: r } : null;
|
|
1203
|
+
},
|
|
1204
|
+
"rounded-tr": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1205
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1206
|
+
return r !== null ? { borderTopRightRadius: r } : null;
|
|
1207
|
+
},
|
|
1208
|
+
"rounded-bl": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1209
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1210
|
+
return r !== null ? { borderBottomLeftRadius: r } : null;
|
|
1211
|
+
},
|
|
1212
|
+
"rounded-br": ({ value, isArbitrary }, { borderRadius }) => {
|
|
1213
|
+
const r = resolveRadius(value, borderRadius, isArbitrary);
|
|
1214
|
+
return r !== null ? { borderBottomRightRadius: r } : null;
|
|
1215
|
+
},
|
|
1216
|
+
// ── Grid (responsive column count: grid-1 … grid-12, or arbitrary) ───────
|
|
1217
|
+
grid: ({ value, isArbitrary }) => {
|
|
1218
|
+
if (!value) return null;
|
|
1219
|
+
if (isArbitrary) return { display: "grid", gridTemplateColumns: value };
|
|
1220
|
+
const n = parseInt(value, 10);
|
|
1221
|
+
if (isNaN(n) || n < 1 || n > 12) return null;
|
|
1222
|
+
return { display: "grid", gridTemplateColumns: `repeat(${n}, minmax(0, 1fr))` };
|
|
1223
|
+
},
|
|
1224
|
+
// ── Grid template columns/rows (Tailwind-style aliases, web-only) ──────────
|
|
1225
|
+
"grid-cols": ({ value, isArbitrary }) => {
|
|
1226
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1227
|
+
if (!value) return null;
|
|
1228
|
+
if (isArbitrary) return { display: "grid", gridTemplateColumns: value };
|
|
1229
|
+
if (value === "none") return { display: "grid", gridTemplateColumns: "none" };
|
|
1230
|
+
const n = parseInt(value, 10);
|
|
1231
|
+
if (isNaN(n) || n < 1 || n > 12) return null;
|
|
1232
|
+
return { display: "grid", gridTemplateColumns: `repeat(${n}, minmax(0, 1fr))` };
|
|
1233
|
+
},
|
|
1234
|
+
"grid-rows": ({ value, isArbitrary }) => {
|
|
1235
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1236
|
+
if (!value) return null;
|
|
1237
|
+
if (isArbitrary) return { gridTemplateRows: value };
|
|
1238
|
+
if (value === "none") return { gridTemplateRows: "none" };
|
|
1239
|
+
const n = parseInt(value, 10);
|
|
1240
|
+
if (isNaN(n) || n < 1) return null;
|
|
1241
|
+
return { gridTemplateRows: `repeat(${n}, minmax(0, 1fr))` };
|
|
1242
|
+
},
|
|
1243
|
+
// ── Grid auto flow (web-only) ─────────────────────────────────────────────
|
|
1244
|
+
"grid-flow": ({ value }) => {
|
|
1245
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1246
|
+
const flows = {
|
|
1247
|
+
row: "row",
|
|
1248
|
+
col: "column",
|
|
1249
|
+
dense: "dense",
|
|
1250
|
+
"row-dense": "row dense",
|
|
1251
|
+
"col-dense": "column dense"
|
|
1252
|
+
};
|
|
1253
|
+
const flow = flows[value];
|
|
1254
|
+
return flow ? { gridAutoFlow: flow } : null;
|
|
1255
|
+
},
|
|
1256
|
+
// ── Grid auto sizing (web-only) ───────────────────────────────────────────
|
|
1257
|
+
"auto-cols": ({ value, isArbitrary }) => {
|
|
1258
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1259
|
+
if (isArbitrary) return { gridAutoColumns: value };
|
|
1260
|
+
const presets = {
|
|
1261
|
+
auto: "auto",
|
|
1262
|
+
min: "min-content",
|
|
1263
|
+
max: "max-content",
|
|
1264
|
+
fr: "minmax(0, 1fr)"
|
|
1265
|
+
};
|
|
1266
|
+
const v = presets[value];
|
|
1267
|
+
return v ? { gridAutoColumns: v } : null;
|
|
1268
|
+
},
|
|
1269
|
+
"auto-rows": ({ value, isArbitrary }) => {
|
|
1270
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1271
|
+
if (isArbitrary) return { gridAutoRows: value };
|
|
1272
|
+
const presets = {
|
|
1273
|
+
auto: "auto",
|
|
1274
|
+
min: "min-content",
|
|
1275
|
+
max: "max-content",
|
|
1276
|
+
fr: "minmax(0, 1fr)"
|
|
1277
|
+
};
|
|
1278
|
+
const v = presets[value];
|
|
1279
|
+
return v ? { gridAutoRows: v } : null;
|
|
1280
|
+
},
|
|
1281
|
+
// ── Grid column placement (web-only) ──────────────────────────────────────
|
|
1282
|
+
"col-span": ({ value }) => {
|
|
1283
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1284
|
+
if (value === "full") return { gridColumn: "1 / -1" };
|
|
1285
|
+
const n = parseInt(value, 10);
|
|
1286
|
+
return isNaN(n) ? null : { gridColumn: `span ${n} / span ${n}` };
|
|
1287
|
+
},
|
|
1288
|
+
"col-start": ({ value, isArbitrary }) => {
|
|
1289
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1290
|
+
if (value === "auto") return { gridColumnStart: "auto" };
|
|
1291
|
+
if (isArbitrary) return { gridColumnStart: value };
|
|
1292
|
+
const n = parseInt(value, 10);
|
|
1293
|
+
return isNaN(n) ? null : { gridColumnStart: n };
|
|
1294
|
+
},
|
|
1295
|
+
"col-end": ({ value, isArbitrary }) => {
|
|
1296
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1297
|
+
if (value === "auto") return { gridColumnEnd: "auto" };
|
|
1298
|
+
if (isArbitrary) return { gridColumnEnd: value };
|
|
1299
|
+
const n = parseInt(value, 10);
|
|
1300
|
+
return isNaN(n) ? null : { gridColumnEnd: n };
|
|
1301
|
+
},
|
|
1302
|
+
col: ({ value, isArbitrary }) => {
|
|
1303
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1304
|
+
if (!value || value === "auto") return { gridColumn: "auto" };
|
|
1305
|
+
if (isArbitrary) return { gridColumn: value };
|
|
1306
|
+
return null;
|
|
1307
|
+
},
|
|
1308
|
+
// ── Grid row placement (web-only) ─────────────────────────────────────────
|
|
1309
|
+
"row-span": ({ value }) => {
|
|
1310
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1311
|
+
if (value === "full") return { gridRow: "1 / -1" };
|
|
1312
|
+
const n = parseInt(value, 10);
|
|
1313
|
+
return isNaN(n) ? null : { gridRow: `span ${n} / span ${n}` };
|
|
1314
|
+
},
|
|
1315
|
+
"row-start": ({ value, isArbitrary }) => {
|
|
1316
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1317
|
+
if (value === "auto") return { gridRowStart: "auto" };
|
|
1318
|
+
if (isArbitrary) return { gridRowStart: value };
|
|
1319
|
+
const n = parseInt(value, 10);
|
|
1320
|
+
return isNaN(n) ? null : { gridRowStart: n };
|
|
1321
|
+
},
|
|
1322
|
+
"row-end": ({ value, isArbitrary }) => {
|
|
1323
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1324
|
+
if (value === "auto") return { gridRowEnd: "auto" };
|
|
1325
|
+
if (isArbitrary) return { gridRowEnd: value };
|
|
1326
|
+
const n = parseInt(value, 10);
|
|
1327
|
+
return isNaN(n) ? null : { gridRowEnd: n };
|
|
1328
|
+
},
|
|
1329
|
+
row: ({ value, isArbitrary }) => {
|
|
1330
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1331
|
+
if (!value || value === "auto") return { gridRow: "auto" };
|
|
1332
|
+
if (isArbitrary) return { gridRow: value };
|
|
1333
|
+
return null;
|
|
1334
|
+
},
|
|
1335
|
+
// ── Grid alignment (web-only) ──────────────────────────────────────────────
|
|
1336
|
+
// place-items is shorthand for align-items + justify-items on a grid container
|
|
1337
|
+
"place-items": ({ value }) => {
|
|
1338
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1339
|
+
const map = {
|
|
1340
|
+
start: "start",
|
|
1341
|
+
end: "end",
|
|
1342
|
+
center: "center",
|
|
1343
|
+
stretch: "stretch",
|
|
1344
|
+
baseline: "baseline"
|
|
1345
|
+
};
|
|
1346
|
+
return map[value] ? { placeItems: map[value] } : null;
|
|
1347
|
+
},
|
|
1348
|
+
// place-content is shorthand for align-content + justify-content on a grid container
|
|
1349
|
+
"place-content": ({ value }) => {
|
|
1350
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1351
|
+
const map = {
|
|
1352
|
+
start: "start",
|
|
1353
|
+
end: "end",
|
|
1354
|
+
center: "center",
|
|
1355
|
+
stretch: "stretch",
|
|
1356
|
+
between: "space-between",
|
|
1357
|
+
around: "space-around",
|
|
1358
|
+
evenly: "space-evenly",
|
|
1359
|
+
baseline: "baseline"
|
|
1360
|
+
};
|
|
1361
|
+
return map[value] ? { placeContent: map[value] } : null;
|
|
1362
|
+
},
|
|
1363
|
+
// justify-items controls inline-axis alignment of grid items within their cells
|
|
1364
|
+
"justify-items": ({ value }) => {
|
|
1365
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1366
|
+
const map = {
|
|
1367
|
+
start: "start",
|
|
1368
|
+
end: "end",
|
|
1369
|
+
center: "center",
|
|
1370
|
+
stretch: "stretch"
|
|
1371
|
+
};
|
|
1372
|
+
return map[value] ? { justifyItems: map[value] } : null;
|
|
1373
|
+
},
|
|
1374
|
+
// place-self is shorthand for align-self + justify-self on a grid item
|
|
1375
|
+
"place-self": ({ value }) => {
|
|
1376
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1377
|
+
const map = {
|
|
1378
|
+
auto: "auto",
|
|
1379
|
+
start: "start",
|
|
1380
|
+
end: "end",
|
|
1381
|
+
center: "center",
|
|
1382
|
+
stretch: "stretch"
|
|
1383
|
+
};
|
|
1384
|
+
return map[value] ? { placeSelf: map[value] } : null;
|
|
1385
|
+
},
|
|
1386
|
+
// justify-self controls inline-axis self-alignment of a grid item
|
|
1387
|
+
"justify-self": ({ value }) => {
|
|
1388
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1389
|
+
const map = {
|
|
1390
|
+
auto: "auto",
|
|
1391
|
+
start: "start",
|
|
1392
|
+
end: "end",
|
|
1393
|
+
center: "center",
|
|
1394
|
+
stretch: "stretch"
|
|
1395
|
+
};
|
|
1396
|
+
return map[value] ? { justifySelf: map[value] } : null;
|
|
1397
|
+
},
|
|
1398
|
+
// ── CSS Filters (composable via CSS variables, web-only) ─────────────────
|
|
1399
|
+
blur: ({ value, isArbitrary }) => {
|
|
1400
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1401
|
+
const sizes = {
|
|
1402
|
+
"": "blur(8px)",
|
|
1403
|
+
sm: "blur(4px)",
|
|
1404
|
+
md: "blur(12px)",
|
|
1405
|
+
lg: "blur(16px)",
|
|
1406
|
+
xl: "blur(24px)",
|
|
1407
|
+
"2xl": "blur(40px)",
|
|
1408
|
+
"3xl": "blur(64px)"
|
|
1409
|
+
};
|
|
1410
|
+
if (value === "none") return { "--kb-blur": "", filter: FILTER_COMPOSE };
|
|
1411
|
+
const v = isArbitrary ? `blur(${value})` : sizes[value];
|
|
1412
|
+
return v !== void 0 ? { "--kb-blur": v, filter: FILTER_COMPOSE } : null;
|
|
1413
|
+
},
|
|
1414
|
+
brightness: ({ value, isArbitrary }) => {
|
|
1415
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1416
|
+
const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
|
|
1417
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-brightness": v, filter: FILTER_COMPOSE };
|
|
1418
|
+
},
|
|
1419
|
+
contrast: ({ value, isArbitrary }) => {
|
|
1420
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1421
|
+
const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
|
|
1422
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-contrast": v, filter: FILTER_COMPOSE };
|
|
1423
|
+
},
|
|
1424
|
+
grayscale: ({ value }) => {
|
|
1425
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1426
|
+
const v = value === "0" ? "grayscale(0)" : "grayscale(100%)";
|
|
1427
|
+
return { "--kb-grayscale": v, filter: FILTER_COMPOSE };
|
|
1428
|
+
},
|
|
1429
|
+
"hue-rotate": ({ value, negative, isArbitrary }) => {
|
|
1430
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1431
|
+
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1432
|
+
if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
|
|
1433
|
+
return { "--kb-hue-rotate": `hue-rotate(${deg})`, filter: FILTER_COMPOSE };
|
|
1434
|
+
},
|
|
1435
|
+
invert: ({ value }) => {
|
|
1436
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1437
|
+
const v = value === "0" ? "invert(0)" : "invert(100%)";
|
|
1438
|
+
return { "--kb-invert": v, filter: FILTER_COMPOSE };
|
|
1439
|
+
},
|
|
1440
|
+
saturate: ({ value, isArbitrary }) => {
|
|
1441
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1442
|
+
const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
|
|
1443
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-saturate": v, filter: FILTER_COMPOSE };
|
|
1444
|
+
},
|
|
1445
|
+
sepia: ({ value }) => {
|
|
1446
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1447
|
+
const v = value === "0" ? "sepia(0)" : "sepia(100%)";
|
|
1448
|
+
return { "--kb-sepia": v, filter: FILTER_COMPOSE };
|
|
1449
|
+
},
|
|
1450
|
+
"drop-shadow": ({ value, isArbitrary }) => {
|
|
1451
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1452
|
+
if (isArbitrary) return { "--kb-drop-shadow": `drop-shadow(${value.replace(/_/g, " ")})`, filter: FILTER_COMPOSE };
|
|
1453
|
+
const presets = {
|
|
1454
|
+
"": "drop-shadow(0 1px 2px rgb(0 0 0/0.1)) drop-shadow(0 1px 1px rgb(0 0 0/0.06))",
|
|
1455
|
+
sm: "drop-shadow(0 1px 1px rgb(0 0 0/0.05))",
|
|
1456
|
+
md: "drop-shadow(0 4px 3px rgb(0 0 0/0.07)) drop-shadow(0 2px 2px rgb(0 0 0/0.06))",
|
|
1457
|
+
lg: "drop-shadow(0 10px 8px rgb(0 0 0/0.04)) drop-shadow(0 4px 3px rgb(0 0 0/0.1))",
|
|
1458
|
+
xl: "drop-shadow(0 20px 13px rgb(0 0 0/0.03)) drop-shadow(0 8px 5px rgb(0 0 0/0.08))",
|
|
1459
|
+
"2xl": "drop-shadow(0 25px 25px rgb(0 0 0/0.15))",
|
|
1460
|
+
none: "drop-shadow(0 0 #0000)"
|
|
1461
|
+
};
|
|
1462
|
+
const v = presets[value];
|
|
1463
|
+
return v !== void 0 ? { "--kb-drop-shadow": v, filter: FILTER_COMPOSE } : null;
|
|
1464
|
+
},
|
|
1465
|
+
// Arbitrary full filter string: filter-[blur(4px)_grayscale(1)]
|
|
1466
|
+
filter: ({ value, isArbitrary }) => {
|
|
1467
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1468
|
+
if (isArbitrary) return { filter: value.replace(/_/g, " ") };
|
|
1469
|
+
if (value === "none") return { filter: "none" };
|
|
1470
|
+
return null;
|
|
1471
|
+
},
|
|
1472
|
+
// ── Backdrop Filters (composable via CSS variables, web-only) ────────────
|
|
1473
|
+
"backdrop-blur": ({ value, isArbitrary }) => {
|
|
1474
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1475
|
+
const sizes = {
|
|
1476
|
+
"": "blur(8px)",
|
|
1477
|
+
sm: "blur(4px)",
|
|
1478
|
+
md: "blur(12px)",
|
|
1479
|
+
lg: "blur(16px)",
|
|
1480
|
+
xl: "blur(24px)",
|
|
1481
|
+
"2xl": "blur(40px)",
|
|
1482
|
+
"3xl": "blur(64px)"
|
|
1483
|
+
};
|
|
1484
|
+
if (value === "none") return { "--kb-backdrop-blur": "", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1485
|
+
const v = isArbitrary ? `blur(${value})` : sizes[value];
|
|
1486
|
+
return v !== void 0 ? { "--kb-backdrop-blur": v, backdropFilter: BACKDROP_FILTER_COMPOSE } : null;
|
|
1487
|
+
},
|
|
1488
|
+
"backdrop-brightness": ({ value, isArbitrary }) => {
|
|
1489
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1490
|
+
const v = isArbitrary ? `brightness(${value})` : `brightness(${parseFloat(value) / 100})`;
|
|
1491
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-brightness": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1492
|
+
},
|
|
1493
|
+
"backdrop-contrast": ({ value, isArbitrary }) => {
|
|
1494
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1495
|
+
const v = isArbitrary ? `contrast(${value})` : `contrast(${parseFloat(value) / 100})`;
|
|
1496
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-contrast": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1497
|
+
},
|
|
1498
|
+
"backdrop-grayscale": ({ value }) => {
|
|
1499
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1500
|
+
return { "--kb-backdrop-grayscale": value === "0" ? "grayscale(0)" : "grayscale(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1501
|
+
},
|
|
1502
|
+
"backdrop-hue-rotate": ({ value, negative, isArbitrary }) => {
|
|
1503
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1504
|
+
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1505
|
+
if (isNaN(parseFloat(deg)) && !isArbitrary) return null;
|
|
1506
|
+
return { "--kb-backdrop-hue-rotate": `hue-rotate(${deg})`, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1507
|
+
},
|
|
1508
|
+
"backdrop-invert": ({ value }) => {
|
|
1509
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1510
|
+
return { "--kb-backdrop-invert": value === "0" ? "invert(0)" : "invert(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1511
|
+
},
|
|
1512
|
+
"backdrop-opacity": ({ value, isArbitrary }) => {
|
|
1513
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1514
|
+
const v = isArbitrary ? `opacity(${value})` : `opacity(${parseFloat(value) / 100})`;
|
|
1515
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-opacity": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1516
|
+
},
|
|
1517
|
+
"backdrop-saturate": ({ value, isArbitrary }) => {
|
|
1518
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1519
|
+
const v = isArbitrary ? `saturate(${value})` : `saturate(${parseFloat(value) / 100})`;
|
|
1520
|
+
return isNaN(parseFloat(value)) && !isArbitrary ? null : { "--kb-backdrop-saturate": v, backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1521
|
+
},
|
|
1522
|
+
"backdrop-sepia": ({ value }) => {
|
|
1523
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1524
|
+
return { "--kb-backdrop-sepia": value === "0" ? "sepia(0)" : "sepia(100%)", backdropFilter: BACKDROP_FILTER_COMPOSE };
|
|
1525
|
+
},
|
|
1526
|
+
"backdrop-filter": ({ value, isArbitrary }) => {
|
|
1527
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1528
|
+
if (isArbitrary) return { backdropFilter: value.replace(/_/g, " ") };
|
|
1529
|
+
if (value === "none") return { backdropFilter: "none" };
|
|
1530
|
+
return null;
|
|
1531
|
+
},
|
|
1532
|
+
// ── Background gradient (CSS variable gradient stops, web-only) ──────────
|
|
1533
|
+
"bg-gradient-to": ({ value }) => {
|
|
1534
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1535
|
+
const directions = {
|
|
1536
|
+
t: "to top",
|
|
1537
|
+
tr: "to top right",
|
|
1538
|
+
r: "to right",
|
|
1539
|
+
br: "to bottom right",
|
|
1540
|
+
b: "to bottom",
|
|
1541
|
+
bl: "to bottom left",
|
|
1542
|
+
l: "to left",
|
|
1543
|
+
tl: "to top left"
|
|
1544
|
+
};
|
|
1545
|
+
const dir = directions[value];
|
|
1546
|
+
if (!dir) return null;
|
|
1547
|
+
return {
|
|
1548
|
+
backgroundImage: `linear-gradient(${dir}, var(--kb-gradient-from, transparent), var(--kb-gradient-stops, transparent))`
|
|
1549
|
+
};
|
|
1550
|
+
},
|
|
1551
|
+
from: ({ value, isArbitrary }, { colors }) => {
|
|
1552
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1553
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1554
|
+
if (!color) return null;
|
|
1555
|
+
return {
|
|
1556
|
+
"--kb-gradient-from": color,
|
|
1557
|
+
"--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-to, transparent)`
|
|
1558
|
+
};
|
|
1559
|
+
},
|
|
1560
|
+
via: ({ value, isArbitrary }, { colors }) => {
|
|
1561
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1562
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1563
|
+
if (!color) return null;
|
|
1564
|
+
return {
|
|
1565
|
+
"--kb-gradient-via": color,
|
|
1566
|
+
"--kb-gradient-stops": `var(--kb-gradient-from), var(--kb-gradient-via), var(--kb-gradient-to, transparent)`
|
|
1567
|
+
};
|
|
1568
|
+
},
|
|
1569
|
+
to: ({ value, isArbitrary }, { colors }) => {
|
|
1570
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1571
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1572
|
+
if (!color) return null;
|
|
1573
|
+
return { "--kb-gradient-to": color };
|
|
1574
|
+
},
|
|
1575
|
+
// ── Transform extras (web-only) ───────────────────────────────────────────
|
|
1576
|
+
"skew-x": ({ value, negative, isArbitrary }) => {
|
|
1577
|
+
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1578
|
+
if (!isArbitrary && isNaN(parseFloat(value))) return null;
|
|
1579
|
+
return getEffectiveIsWeb() ? { transform: `skewX(${deg})` } : { transform: [{ skewX: deg }] };
|
|
1580
|
+
},
|
|
1581
|
+
"skew-y": ({ value, negative, isArbitrary }) => {
|
|
1582
|
+
const deg = isArbitrary ? value : `${(negative ? -1 : 1) * parseFloat(value)}deg`;
|
|
1583
|
+
if (!isArbitrary && isNaN(parseFloat(value))) return null;
|
|
1584
|
+
return getEffectiveIsWeb() ? { transform: `skewY(${deg})` } : { transform: [{ skewY: deg }] };
|
|
1585
|
+
},
|
|
1586
|
+
// Arbitrary full transform string: transform-[rotate(45deg)_scale(1.5)]
|
|
1587
|
+
transform: ({ value, isArbitrary }) => {
|
|
1588
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1589
|
+
if (isArbitrary) return { transform: value.replace(/_/g, " ") };
|
|
1590
|
+
if (value === "none") return { transform: "none" };
|
|
1591
|
+
return null;
|
|
1592
|
+
},
|
|
1593
|
+
// Transform origin
|
|
1594
|
+
origin: ({ value, isArbitrary }) => {
|
|
1595
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1596
|
+
if (isArbitrary) return { transformOrigin: value.replace(/_/g, " ") };
|
|
1597
|
+
const origins = {
|
|
1598
|
+
center: "center",
|
|
1599
|
+
top: "top",
|
|
1600
|
+
"top-right": "top right",
|
|
1601
|
+
right: "right",
|
|
1602
|
+
"bottom-right": "bottom right",
|
|
1603
|
+
bottom: "bottom",
|
|
1604
|
+
"bottom-left": "bottom left",
|
|
1605
|
+
left: "left",
|
|
1606
|
+
"top-left": "top left"
|
|
1607
|
+
};
|
|
1608
|
+
return origins[value] ? { transformOrigin: origins[value] } : null;
|
|
1609
|
+
},
|
|
1610
|
+
// ── Text decoration advanced (web-only) ───────────────────────────────────
|
|
1611
|
+
decoration: ({ value, isArbitrary }, { colors }) => {
|
|
1612
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1613
|
+
if (isArbitrary) {
|
|
1614
|
+
if (/^\d/.test(value) || value.startsWith("calc(")) return { textDecorationThickness: value };
|
|
1615
|
+
return { textDecorationColor: value };
|
|
1616
|
+
}
|
|
1617
|
+
const thickTokens = {
|
|
1618
|
+
auto: "auto",
|
|
1619
|
+
"from-font": "from-font",
|
|
1620
|
+
"0": "0px",
|
|
1621
|
+
"1": "1px",
|
|
1622
|
+
"2": "2px",
|
|
1623
|
+
"4": "4px",
|
|
1624
|
+
"8": "8px"
|
|
1625
|
+
};
|
|
1626
|
+
if (value in thickTokens) return { textDecorationThickness: thickTokens[value] };
|
|
1627
|
+
const styleTokens = {
|
|
1628
|
+
solid: "solid",
|
|
1629
|
+
dashed: "dashed",
|
|
1630
|
+
dotted: "dotted",
|
|
1631
|
+
double: "double",
|
|
1632
|
+
wavy: "wavy"
|
|
1633
|
+
};
|
|
1634
|
+
if (value in styleTokens) return { textDecorationStyle: styleTokens[value] };
|
|
1635
|
+
const color = resolveColor(value, colors, false);
|
|
1636
|
+
return color ? { textDecorationColor: color } : null;
|
|
1637
|
+
},
|
|
1638
|
+
"underline-offset": ({ value, isArbitrary }) => {
|
|
1639
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1640
|
+
if (isArbitrary) return { textUnderlineOffset: value };
|
|
1641
|
+
const offsets = {
|
|
1642
|
+
auto: "auto",
|
|
1643
|
+
"0": "0px",
|
|
1644
|
+
"1": "1px",
|
|
1645
|
+
"2": "2px",
|
|
1646
|
+
"4": "4px",
|
|
1647
|
+
"8": "8px"
|
|
1648
|
+
};
|
|
1649
|
+
return offsets[value] ? { textUnderlineOffset: offsets[value] } : null;
|
|
1650
|
+
},
|
|
1651
|
+
// ── Outline extended (web-only) ───────────────────────────────────────────
|
|
1652
|
+
outline: ({ value, isArbitrary }, { colors }) => {
|
|
1653
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1654
|
+
if (!value) return { outline: "2px solid transparent", outlineOffset: "2px" };
|
|
1655
|
+
if (value === "none") return { outline: "none", outlineOffset: "0" };
|
|
1656
|
+
if (isArbitrary) {
|
|
1657
|
+
if (/^\d/.test(value) || value.startsWith("calc(")) return { outlineWidth: value };
|
|
1658
|
+
return { outlineColor: value };
|
|
1659
|
+
}
|
|
1660
|
+
const widths = { "0": "0px", "1": "1px", "2": "2px", "4": "4px", "8": "8px" };
|
|
1661
|
+
if (value in widths) return { outlineWidth: widths[value] };
|
|
1662
|
+
const color = resolveColor(value, colors, false);
|
|
1663
|
+
return color ? { outlineColor: color } : null;
|
|
1664
|
+
},
|
|
1665
|
+
"outline-offset": ({ value, isArbitrary }) => {
|
|
1666
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1667
|
+
if (isArbitrary) return { outlineOffset: value };
|
|
1668
|
+
const offsets = { "0": "0px", "1": "1px", "2": "2px", "4": "4px", "8": "8px" };
|
|
1669
|
+
return offsets[value] ? { outlineOffset: offsets[value] } : null;
|
|
1670
|
+
},
|
|
1671
|
+
// ── Columns (web-only) ─────────────────────────────────────────────────────
|
|
1672
|
+
columns: ({ value, isArbitrary }) => {
|
|
1673
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1674
|
+
if (isArbitrary) return { columnCount: value };
|
|
1675
|
+
if (value === "auto") return { columnCount: "auto" };
|
|
1676
|
+
const n = parseInt(value, 10);
|
|
1677
|
+
if (!isNaN(n)) return { columnCount: n };
|
|
1678
|
+
const widths = {
|
|
1679
|
+
"3xs": "16rem",
|
|
1680
|
+
"2xs": "18rem",
|
|
1681
|
+
xs: "20rem",
|
|
1682
|
+
sm: "24rem",
|
|
1683
|
+
md: "28rem",
|
|
1684
|
+
lg: "32rem",
|
|
1685
|
+
xl: "36rem",
|
|
1686
|
+
"2xl": "42rem",
|
|
1687
|
+
"3xl": "48rem",
|
|
1688
|
+
"4xl": "56rem",
|
|
1689
|
+
"5xl": "64rem",
|
|
1690
|
+
"6xl": "72rem",
|
|
1691
|
+
"7xl": "80rem"
|
|
1692
|
+
};
|
|
1693
|
+
return widths[value] ? { columnWidth: widths[value] } : null;
|
|
1694
|
+
},
|
|
1695
|
+
// ── Mix / background blend mode (web-only) ───────────────────────────────
|
|
1696
|
+
"mix-blend": ({ value }) => {
|
|
1697
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1698
|
+
const modes = [
|
|
1699
|
+
"normal",
|
|
1700
|
+
"multiply",
|
|
1701
|
+
"screen",
|
|
1702
|
+
"overlay",
|
|
1703
|
+
"darken",
|
|
1704
|
+
"lighten",
|
|
1705
|
+
"color-dodge",
|
|
1706
|
+
"color-burn",
|
|
1707
|
+
"hard-light",
|
|
1708
|
+
"soft-light",
|
|
1709
|
+
"difference",
|
|
1710
|
+
"exclusion",
|
|
1711
|
+
"hue",
|
|
1712
|
+
"saturation",
|
|
1713
|
+
"color",
|
|
1714
|
+
"luminosity",
|
|
1715
|
+
"plus-lighter"
|
|
1716
|
+
];
|
|
1717
|
+
return modes.includes(value) ? { mixBlendMode: value } : null;
|
|
1718
|
+
},
|
|
1719
|
+
"bg-blend": ({ value }) => {
|
|
1720
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1721
|
+
const modes = [
|
|
1722
|
+
"normal",
|
|
1723
|
+
"multiply",
|
|
1724
|
+
"screen",
|
|
1725
|
+
"overlay",
|
|
1726
|
+
"darken",
|
|
1727
|
+
"lighten",
|
|
1728
|
+
"color-dodge",
|
|
1729
|
+
"color-burn",
|
|
1730
|
+
"hard-light",
|
|
1731
|
+
"soft-light",
|
|
1732
|
+
"difference",
|
|
1733
|
+
"exclusion",
|
|
1734
|
+
"hue",
|
|
1735
|
+
"saturation",
|
|
1736
|
+
"color",
|
|
1737
|
+
"luminosity"
|
|
1738
|
+
];
|
|
1739
|
+
return modes.includes(value) ? { backgroundBlendMode: value } : null;
|
|
1740
|
+
},
|
|
1741
|
+
// ── Will-change (web-only) ─────────────────────────────────────────────────
|
|
1742
|
+
"will-change": ({ value, isArbitrary }) => {
|
|
1743
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1744
|
+
if (isArbitrary) return { willChange: value.replace(/_/g, ", ") };
|
|
1745
|
+
const presets = {
|
|
1746
|
+
auto: "auto",
|
|
1747
|
+
scroll: "scroll-position",
|
|
1748
|
+
contents: "contents",
|
|
1749
|
+
transform: "transform"
|
|
1750
|
+
};
|
|
1751
|
+
return presets[value] ? { willChange: presets[value] } : null;
|
|
1752
|
+
},
|
|
1753
|
+
// ── Divide (child combinator CSS, web-only) ───────────────────────────────
|
|
1754
|
+
// These return special __divide* markers that resolver.ts converts to
|
|
1755
|
+
// .cls > * + * { border-... } CSS rules. No inline style is applied.
|
|
1756
|
+
"divide-x": ({ value, isArbitrary }) => {
|
|
1757
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1758
|
+
if (value === "reverse") return null;
|
|
1759
|
+
if (!value) return { __divideX: 1 };
|
|
1760
|
+
const n = parseFloat(value);
|
|
1761
|
+
return isNaN(n) ? null : { __divideX: n };
|
|
1762
|
+
},
|
|
1763
|
+
"divide-y": ({ value, isArbitrary }) => {
|
|
1764
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1765
|
+
if (value === "reverse") return null;
|
|
1766
|
+
if (!value) return { __divideY: 1 };
|
|
1767
|
+
const n = parseFloat(value);
|
|
1768
|
+
return isNaN(n) ? null : { __divideY: n };
|
|
1769
|
+
},
|
|
1770
|
+
divide: ({ value, isArbitrary }, { colors }) => {
|
|
1771
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1772
|
+
if (isArbitrary) return { __divideColor: value };
|
|
1773
|
+
const styleTokens = {
|
|
1774
|
+
solid: "solid",
|
|
1775
|
+
dashed: "dashed",
|
|
1776
|
+
dotted: "dotted",
|
|
1777
|
+
double: "double",
|
|
1778
|
+
none: "none"
|
|
1779
|
+
};
|
|
1780
|
+
if (value in styleTokens) return { __divideStyle: styleTokens[value] };
|
|
1781
|
+
const color = resolveColor(value, colors, false);
|
|
1782
|
+
return color ? { __divideColor: color } : null;
|
|
1783
|
+
},
|
|
1784
|
+
// ── Text shadow (cross-platform: iOS, Android, web) ─────────────────────
|
|
1785
|
+
// Named presets give cross-platform shadow; arbitrary is web-only.
|
|
1786
|
+
"text-shadow": ({ value, isArbitrary }, { colors }) => {
|
|
1787
|
+
if (value === "none") {
|
|
1788
|
+
return getEffectiveIsWeb() ? { textShadow: "none" } : { textShadowColor: "transparent", textShadowOffset: { width: 0, height: 0 }, textShadowRadius: 0 };
|
|
1789
|
+
}
|
|
1790
|
+
const webPresets = {
|
|
1791
|
+
"": "0 2px 4px rgba(0,0,0,0.3)",
|
|
1792
|
+
sm: "0 1px 2px rgba(0,0,0,0.3)",
|
|
1793
|
+
md: "0 4px 6px rgba(0,0,0,0.3)",
|
|
1794
|
+
lg: "0 8px 16px rgba(0,0,0,0.5)",
|
|
1795
|
+
xl: "0 16px 32px rgba(0,0,0,0.5)"
|
|
1796
|
+
};
|
|
1797
|
+
const nativePresets = {
|
|
1798
|
+
"": { textShadowColor: "rgba(0,0,0,0.3)", textShadowOffset: { width: 0, height: 2 }, textShadowRadius: 4 },
|
|
1799
|
+
sm: { textShadowColor: "rgba(0,0,0,0.3)", textShadowOffset: { width: 0, height: 1 }, textShadowRadius: 2 },
|
|
1800
|
+
md: { textShadowColor: "rgba(0,0,0,0.3)", textShadowOffset: { width: 0, height: 4 }, textShadowRadius: 6 },
|
|
1801
|
+
lg: { textShadowColor: "rgba(0,0,0,0.5)", textShadowOffset: { width: 0, height: 8 }, textShadowRadius: 16 },
|
|
1802
|
+
xl: { textShadowColor: "rgba(0,0,0,0.5)", textShadowOffset: { width: 0, height: 16 }, textShadowRadius: 32 }
|
|
1803
|
+
};
|
|
1804
|
+
if (value in webPresets) {
|
|
1805
|
+
if (getEffectiveIsWeb()) return { textShadow: webPresets[value] };
|
|
1806
|
+
return nativePresets[value] ?? null;
|
|
1807
|
+
}
|
|
1808
|
+
if (isArbitrary) {
|
|
1809
|
+
return getEffectiveIsWeb() ? { textShadow: value.replace(/_/g, " ") } : null;
|
|
1810
|
+
}
|
|
1811
|
+
const color = resolveColor(value, colors, false);
|
|
1812
|
+
if (color) {
|
|
1813
|
+
return getEffectiveIsWeb() ? { textShadow: `0 2px 4px ${color}` } : { textShadowColor: color };
|
|
1814
|
+
}
|
|
1815
|
+
return null;
|
|
1816
|
+
},
|
|
1817
|
+
// ── Perspective transform (cross-platform: iOS, Android, web) ────────────
|
|
1818
|
+
perspective: ({ value, isArbitrary }) => {
|
|
1819
|
+
if (isArbitrary) {
|
|
1820
|
+
const numPx = parseFloat(value);
|
|
1821
|
+
if (getEffectiveIsWeb()) return { transform: `perspective(${value})` };
|
|
1822
|
+
return isNaN(numPx) ? null : { transform: [{ perspective: numPx }] };
|
|
1823
|
+
}
|
|
1824
|
+
if (value === "none") return getEffectiveIsWeb() ? { transform: "none" } : null;
|
|
1825
|
+
const n = parseFloat(value);
|
|
1826
|
+
if (isNaN(n)) return null;
|
|
1827
|
+
return getEffectiveIsWeb() ? { transform: `perspective(${n}px)` } : { transform: [{ perspective: n }] };
|
|
1828
|
+
},
|
|
1829
|
+
// ── Tint color (native-only, for Image and icon components) ──────────────
|
|
1830
|
+
tint: ({ value, isArbitrary }, { colors }) => {
|
|
1831
|
+
if (getEffectiveIsWeb()) return null;
|
|
1832
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1833
|
+
return color ? { tintColor: color } : null;
|
|
1834
|
+
},
|
|
1835
|
+
// ── Size shorthand (sets width AND height in one utility) ────────────────
|
|
1836
|
+
size: ({ value, isArbitrary }, { spacing }) => {
|
|
1837
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1838
|
+
return v !== null ? { width: v, height: v } : null;
|
|
1839
|
+
},
|
|
1840
|
+
// ── Animations (CSS keyframe animations, web-only) ────────────────────────
|
|
1841
|
+
// Each variant injects a @keyframes rule once via the __keyframe marker.
|
|
1842
|
+
// resolver.ts detects __keyframe, injects the rule, then strips the marker
|
|
1843
|
+
// so it never reaches element inline styles.
|
|
1844
|
+
animate: ({ value, isArbitrary }) => {
|
|
1845
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1846
|
+
if (isArbitrary) return { animation: value.replace(/_/g, " ") };
|
|
1847
|
+
const defs = {
|
|
1848
|
+
none: { animation: "none" },
|
|
1849
|
+
spin: {
|
|
1850
|
+
animation: "kb-spin 1s linear infinite",
|
|
1851
|
+
__keyframe: "@keyframes kb-spin { from { transform: rotate(0deg) } to { transform: rotate(360deg) } }"
|
|
1852
|
+
},
|
|
1853
|
+
ping: {
|
|
1854
|
+
animation: "kb-ping 1s cubic-bezier(0,0,0.2,1) infinite",
|
|
1855
|
+
__keyframe: "@keyframes kb-ping { 75%, 100% { transform: scale(2); opacity: 0 } }"
|
|
1856
|
+
},
|
|
1857
|
+
pulse: {
|
|
1858
|
+
animation: "kb-pulse 2s cubic-bezier(0.4,0,0.6,1) infinite",
|
|
1859
|
+
__keyframe: "@keyframes kb-pulse { 0%, 100% { opacity: 1 } 50% { opacity: .5 } }"
|
|
1860
|
+
},
|
|
1861
|
+
bounce: {
|
|
1862
|
+
animation: "kb-bounce 1s infinite",
|
|
1863
|
+
__keyframe: "@keyframes kb-bounce { 0%, 100% { transform: translateY(-25%); animation-timing-function: cubic-bezier(0.8,0,1,1) } 50% { transform: none; animation-timing-function: cubic-bezier(0,0,0.2,1) } }"
|
|
1864
|
+
}
|
|
1865
|
+
};
|
|
1866
|
+
const def = defs[value];
|
|
1867
|
+
return def ? def : null;
|
|
1868
|
+
},
|
|
1869
|
+
// ── Line-clamp (web-only) ─────────────────────────────────────────────────
|
|
1870
|
+
"line-clamp": ({ value }) => {
|
|
1871
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1872
|
+
if (value === "none") return { overflow: "visible", display: "block", WebkitLineClamp: "unset" };
|
|
1873
|
+
const n = parseInt(value, 10);
|
|
1874
|
+
if (isNaN(n) || n < 1) return null;
|
|
1875
|
+
return {
|
|
1876
|
+
overflow: "hidden",
|
|
1877
|
+
display: "-webkit-box",
|
|
1878
|
+
WebkitBoxOrient: "vertical",
|
|
1879
|
+
WebkitLineClamp: n
|
|
1880
|
+
};
|
|
1881
|
+
},
|
|
1882
|
+
// ── Caret color (web-only) ────────────────────────────────────────────────
|
|
1883
|
+
caret: ({ value, isArbitrary }, { colors }) => {
|
|
1884
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1885
|
+
if (value === "auto" || value === "transparent") return { caretColor: value };
|
|
1886
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1887
|
+
return color ? { caretColor: color } : null;
|
|
1888
|
+
},
|
|
1889
|
+
// ── Accent color (web-only) ───────────────────────────────────────────────
|
|
1890
|
+
accent: ({ value, isArbitrary }, { colors }) => {
|
|
1891
|
+
if (!getEffectiveIsWeb()) return null;
|
|
1892
|
+
if (value === "auto") return { accentColor: "auto" };
|
|
1893
|
+
const color = resolveColor(value, colors, isArbitrary);
|
|
1894
|
+
return color ? { accentColor: color } : null;
|
|
1895
|
+
},
|
|
1896
|
+
// ── Flex ───────────────────────────────────────────────────────────────────
|
|
1897
|
+
flex: ({ value, isArbitrary }, { flex }) => {
|
|
1898
|
+
if (!value) return { display: "flex" };
|
|
1899
|
+
if (isArbitrary) {
|
|
1900
|
+
const v = parseFloat(value);
|
|
1901
|
+
return isNaN(v) ? null : { flex: v };
|
|
1902
|
+
}
|
|
1903
|
+
if (value in flex) {
|
|
1904
|
+
const v = flex[value];
|
|
1905
|
+
if (typeof v === "string" && !getEffectiveIsWeb()) {
|
|
1906
|
+
if (v === "auto" || v === "initial") return { flex: 1 };
|
|
1907
|
+
if (v === "none") return { flex: 0 };
|
|
1908
|
+
return null;
|
|
1909
|
+
}
|
|
1910
|
+
return { flex: v };
|
|
1911
|
+
}
|
|
1912
|
+
const n = parseFloat(value);
|
|
1913
|
+
return isNaN(n) ? null : { flex: n };
|
|
1914
|
+
},
|
|
1915
|
+
basis: ({ value, isArbitrary }, { spacing }) => {
|
|
1916
|
+
const v = resolveSizing(value, spacing, isArbitrary);
|
|
1917
|
+
return v !== null ? { flexBasis: v } : null;
|
|
1918
|
+
},
|
|
1919
|
+
grow: ({ value }, _) => {
|
|
1920
|
+
if (!value) return { flexGrow: 1 };
|
|
1921
|
+
const n = parseFloat(value);
|
|
1922
|
+
return { flexGrow: isNaN(n) ? 1 : n };
|
|
1923
|
+
},
|
|
1924
|
+
shrink: ({ value }, _) => {
|
|
1925
|
+
if (!value) return { flexShrink: 1 };
|
|
1926
|
+
const n = parseFloat(value);
|
|
1927
|
+
return { flexShrink: isNaN(n) ? 1 : n };
|
|
1928
|
+
},
|
|
1929
|
+
order: ({ value, negative }, _) => {
|
|
1930
|
+
const n = parseInt(value, 10);
|
|
1931
|
+
return isNaN(n) ? null : { order: negative ? -n : n };
|
|
1932
|
+
},
|
|
1933
|
+
// ── Gap ────────────────────────────────────────────────────────────────────
|
|
1934
|
+
gap: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1935
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1936
|
+
return v !== null ? { gap: v } : null;
|
|
1937
|
+
},
|
|
1938
|
+
"gap-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1939
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1940
|
+
return v !== null ? { columnGap: v } : null;
|
|
1941
|
+
},
|
|
1942
|
+
"gap-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1943
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1944
|
+
return v !== null ? { rowGap: v } : null;
|
|
1945
|
+
},
|
|
1946
|
+
// ── Position ───────────────────────────────────────────────────────────────
|
|
1947
|
+
top: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1948
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1949
|
+
return v !== null ? { top: v } : null;
|
|
1950
|
+
},
|
|
1951
|
+
right: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1952
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1953
|
+
return v !== null ? { right: v } : null;
|
|
1954
|
+
},
|
|
1955
|
+
bottom: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1956
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1957
|
+
return v !== null ? { bottom: v } : null;
|
|
1958
|
+
},
|
|
1959
|
+
left: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1960
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1961
|
+
return v !== null ? { left: v } : null;
|
|
1962
|
+
},
|
|
1963
|
+
inset: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1964
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1965
|
+
return v !== null ? { top: v, right: v, bottom: v, left: v } : null;
|
|
1966
|
+
},
|
|
1967
|
+
"inset-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1968
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1969
|
+
return v !== null ? { left: v, right: v } : null;
|
|
1970
|
+
},
|
|
1971
|
+
"inset-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
1972
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
1973
|
+
return v !== null ? { top: v, bottom: v } : null;
|
|
1974
|
+
},
|
|
1975
|
+
// ── Z-index ────────────────────────────────────────────────────────────────
|
|
1976
|
+
z: ({ value, isArbitrary }, { zIndex }) => {
|
|
1977
|
+
if (isArbitrary) {
|
|
1978
|
+
const n2 = parseInt(value);
|
|
1979
|
+
return isNaN(n2) ? null : { zIndex: n2 };
|
|
1980
|
+
}
|
|
1981
|
+
const v = zIndex[value];
|
|
1982
|
+
if (v !== void 0) {
|
|
1983
|
+
if (v === "auto") return getEffectiveIsWeb() ? { zIndex: "auto" } : null;
|
|
1984
|
+
return { zIndex: v };
|
|
1985
|
+
}
|
|
1986
|
+
const n = parseInt(value);
|
|
1987
|
+
return isNaN(n) ? null : { zIndex: n };
|
|
1988
|
+
},
|
|
1989
|
+
// ── Opacity ────────────────────────────────────────────────────────────────
|
|
1990
|
+
opacity: ({ value, isArbitrary }, { opacity }) => {
|
|
1991
|
+
if (isArbitrary) {
|
|
1992
|
+
const v2 = parseFloat(value);
|
|
1993
|
+
return isNaN(v2) ? null : { opacity: v2 > 1 ? v2 / 100 : v2 };
|
|
1994
|
+
}
|
|
1995
|
+
const v = opacity[value];
|
|
1996
|
+
if (v !== void 0) return { opacity: v };
|
|
1997
|
+
const n = parseFloat(value);
|
|
1998
|
+
return isNaN(n) ? null : { opacity: n > 1 ? n / 100 : n };
|
|
1999
|
+
},
|
|
2000
|
+
// ── Font ───────────────────────────────────────────────────────────────────
|
|
2001
|
+
font: ({ value, isArbitrary }, { fontFamily, fontWeight }) => {
|
|
2002
|
+
if (isArbitrary) return { fontFamily: value };
|
|
2003
|
+
if (value in fontFamily) {
|
|
2004
|
+
const ff = fontFamily[value];
|
|
2005
|
+
return { fontFamily: Array.isArray(ff) ? ff.join(", ") : ff };
|
|
2006
|
+
}
|
|
2007
|
+
if (value in fontWeight) return { fontWeight: String(fontWeight[value]) };
|
|
2008
|
+
return null;
|
|
2009
|
+
},
|
|
2010
|
+
// ── Line height ────────────────────────────────────────────────────────────
|
|
2011
|
+
leading: ({ value, isArbitrary }, { lineHeight }) => {
|
|
2012
|
+
if (isArbitrary) return { lineHeight: getEffectiveIsWeb() ? value : toNativeValue(value) };
|
|
2013
|
+
const v = lineHeight[value];
|
|
2014
|
+
if (v === void 0) return null;
|
|
2015
|
+
if (typeof v === "string" && !getEffectiveIsWeb()) return { lineHeight: toNativeValue(v) };
|
|
2016
|
+
return { lineHeight: v };
|
|
2017
|
+
},
|
|
2018
|
+
// ── Letter spacing ─────────────────────────────────────────────────────────
|
|
2019
|
+
tracking: ({ value, isArbitrary }, { letterSpacing }) => {
|
|
2020
|
+
if (isArbitrary) return { letterSpacing: getEffectiveIsWeb() ? value : toNativeValue(value) };
|
|
2021
|
+
const v = letterSpacing[value];
|
|
2022
|
+
return v !== void 0 ? { letterSpacing: v } : null;
|
|
2023
|
+
},
|
|
2024
|
+
// ── Shadow ─────────────────────────────────────────────────────────────────
|
|
2025
|
+
shadow: ({ value }, { shadow }) => {
|
|
2026
|
+
const key = value === "" ? "DEFAULT" : value;
|
|
2027
|
+
return shadow[key] ?? null;
|
|
2028
|
+
},
|
|
2029
|
+
// ── Scale ──────────────────────────────────────────────────────────────────
|
|
2030
|
+
// Non-arbitrary: scale-150 → value='150' → 150/100 = 1.5
|
|
2031
|
+
// Arbitrary: scale-[1.5] → value='1.5' → used as-is (already the factor)
|
|
2032
|
+
scale: ({ value, isArbitrary }) => {
|
|
2033
|
+
const n = isArbitrary ? parseFloat(value) : parseFloat(value) / 100;
|
|
2034
|
+
if (isNaN(n)) return null;
|
|
2035
|
+
return getEffectiveIsWeb() ? { transform: `scale(${n})` } : { transform: [{ scale: n }] };
|
|
2036
|
+
},
|
|
2037
|
+
"scale-x": ({ value, isArbitrary }) => {
|
|
2038
|
+
const n = isArbitrary ? parseFloat(value) : parseFloat(value) / 100;
|
|
2039
|
+
if (isNaN(n)) return null;
|
|
2040
|
+
return getEffectiveIsWeb() ? { transform: `scaleX(${n})` } : { transform: [{ scaleX: n }] };
|
|
2041
|
+
},
|
|
2042
|
+
"scale-y": ({ value, isArbitrary }) => {
|
|
2043
|
+
const n = isArbitrary ? parseFloat(value) : parseFloat(value) / 100;
|
|
2044
|
+
if (isNaN(n)) return null;
|
|
2045
|
+
return getEffectiveIsWeb() ? { transform: `scaleY(${n})` } : { transform: [{ scaleY: n }] };
|
|
2046
|
+
},
|
|
2047
|
+
// ── Rotate ─────────────────────────────────────────────────────────────────
|
|
2048
|
+
rotate: ({ value, negative, isArbitrary }) => {
|
|
2049
|
+
if (isArbitrary) {
|
|
2050
|
+
const finalValue = negative ? `-${value}` : value;
|
|
2051
|
+
return getEffectiveIsWeb() ? { transform: `rotate(${finalValue})` } : { transform: [{ rotate: finalValue }] };
|
|
2052
|
+
}
|
|
2053
|
+
const deg = parseFloat(value);
|
|
2054
|
+
if (isNaN(deg)) return null;
|
|
2055
|
+
const finalDeg = negative ? -deg : deg;
|
|
2056
|
+
return getEffectiveIsWeb() ? { transform: `rotate(${finalDeg}deg)` } : { transform: [{ rotate: `${finalDeg}deg` }] };
|
|
2057
|
+
},
|
|
2058
|
+
// ── Translate ──────────────────────────────────────────────────────────────
|
|
2059
|
+
"translate-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
2060
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
2061
|
+
if (v === null) return null;
|
|
2062
|
+
if (getEffectiveIsWeb()) return { transform: `translateX(${v})` };
|
|
2063
|
+
if (typeof v === "string") {
|
|
2064
|
+
const n = parseFloat(v);
|
|
2065
|
+
return isNaN(n) ? null : { transform: [{ translateX: n }] };
|
|
2066
|
+
}
|
|
2067
|
+
return { transform: [{ translateX: v }] };
|
|
2068
|
+
},
|
|
2069
|
+
"translate-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
2070
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
2071
|
+
if (v === null) return null;
|
|
2072
|
+
if (getEffectiveIsWeb()) return { transform: `translateY(${v})` };
|
|
2073
|
+
if (typeof v === "string") {
|
|
2074
|
+
const n = parseFloat(v);
|
|
2075
|
+
return isNaN(n) ? null : { transform: [{ translateY: n }] };
|
|
2076
|
+
}
|
|
2077
|
+
return { transform: [{ translateY: v }] };
|
|
2078
|
+
},
|
|
2079
|
+
// ── Aspect ratio ───────────────────────────────────────────────────────────
|
|
2080
|
+
aspect: ({ value, isArbitrary }) => {
|
|
2081
|
+
if (isArbitrary) return { aspectRatio: value };
|
|
2082
|
+
const presets = { auto: "auto", square: 1, video: 16 / 9 };
|
|
2083
|
+
if (!(value in presets)) return null;
|
|
2084
|
+
const v = presets[value];
|
|
2085
|
+
if (v === "auto") return getEffectiveIsWeb() ? { aspectRatio: "auto" } : null;
|
|
2086
|
+
return { aspectRatio: v };
|
|
2087
|
+
},
|
|
2088
|
+
// ── Transition (web-only; use Animated API on native) ─────────────────────
|
|
2089
|
+
transition: ({ value }) => {
|
|
2090
|
+
if (!getEffectiveIsWeb()) return null;
|
|
2091
|
+
const presets = {
|
|
2092
|
+
"": "color 150ms, background-color 150ms, border-color 150ms, text-decoration-color 150ms, fill 150ms, stroke 150ms, opacity 150ms, box-shadow 150ms, transform 150ms, filter 150ms, backdrop-filter 150ms",
|
|
2093
|
+
all: "all 150ms",
|
|
2094
|
+
none: "none",
|
|
2095
|
+
colors: "color 150ms, background-color 150ms, border-color 150ms",
|
|
2096
|
+
opacity: "opacity 150ms",
|
|
2097
|
+
shadow: "box-shadow 150ms",
|
|
2098
|
+
transform: "transform 150ms"
|
|
2099
|
+
};
|
|
2100
|
+
const v = presets[value];
|
|
2101
|
+
return v !== void 0 ? { transition: v } : null;
|
|
2102
|
+
},
|
|
2103
|
+
duration: ({ value, isArbitrary }) => {
|
|
2104
|
+
if (!getEffectiveIsWeb()) return null;
|
|
2105
|
+
if (!isArbitrary && isNaN(parseFloat(value))) return null;
|
|
2106
|
+
const ms = isArbitrary ? value : `${value}ms`;
|
|
2107
|
+
return { transitionDuration: ms };
|
|
2108
|
+
},
|
|
2109
|
+
delay: ({ value, isArbitrary }) => {
|
|
2110
|
+
if (!getEffectiveIsWeb()) return null;
|
|
2111
|
+
if (!isArbitrary && isNaN(parseFloat(value))) return null;
|
|
2112
|
+
const ms = isArbitrary ? value : `${value}ms`;
|
|
2113
|
+
return { transitionDelay: ms };
|
|
2114
|
+
},
|
|
2115
|
+
// ── Ring (web-only: box-shadow outline ring) ──────────────────────────────
|
|
2116
|
+
ring: ({ value, isArbitrary }, { colors }) => {
|
|
2117
|
+
if (!getEffectiveIsWeb()) return null;
|
|
2118
|
+
const DEFAULT_COLOR = "rgba(59, 130, 246, 0.5)";
|
|
2119
|
+
const DEFAULT_WIDTH = 3;
|
|
2120
|
+
if (!value) {
|
|
2121
|
+
return { boxShadow: `0 0 0 ${DEFAULT_WIDTH}px ${DEFAULT_COLOR}` };
|
|
2122
|
+
}
|
|
2123
|
+
if (value === "inset") {
|
|
2124
|
+
return { boxShadow: `inset 0 0 0 ${DEFAULT_WIDTH}px ${DEFAULT_COLOR}` };
|
|
2125
|
+
}
|
|
2126
|
+
const widthTokens = { "0": 0, "1": 1, "2": 2, "4": 4, "8": 8 };
|
|
2127
|
+
if (!isArbitrary && value in widthTokens) {
|
|
2128
|
+
const w = widthTokens[value];
|
|
2129
|
+
return { boxShadow: w === 0 ? "none" : `0 0 0 ${w}px ${DEFAULT_COLOR}` };
|
|
2130
|
+
}
|
|
2131
|
+
if (isArbitrary) {
|
|
2132
|
+
const numMatch = /^(\d+(?:\.\d+)?)(px|rem|em|vw|vh)?$/.exec(value);
|
|
2133
|
+
if (numMatch) {
|
|
2134
|
+
const unit = numMatch[2] ?? "px";
|
|
2135
|
+
return { boxShadow: `0 0 0 ${numMatch[1]}${unit} ${DEFAULT_COLOR}` };
|
|
2136
|
+
}
|
|
2137
|
+
return { boxShadow: value.replace(/_/g, " ") };
|
|
2138
|
+
}
|
|
2139
|
+
const color = resolveColor(value, colors, false);
|
|
2140
|
+
if (color) return { boxShadow: `0 0 0 ${DEFAULT_WIDTH}px ${color}` };
|
|
2141
|
+
return null;
|
|
2142
|
+
},
|
|
2143
|
+
"ring-offset": ({ value, isArbitrary }, _theme) => {
|
|
2144
|
+
if (!getEffectiveIsWeb()) return null;
|
|
2145
|
+
const DEFAULT_RING_COLOR = "rgba(59, 130, 246, 0.5)";
|
|
2146
|
+
const DEFAULT_RING_WIDTH = 3;
|
|
2147
|
+
const offsetTokens = { "0": 0, "1": 1, "2": 2, "4": 4, "8": 8 };
|
|
2148
|
+
let offsetWidth;
|
|
2149
|
+
if (!isArbitrary) {
|
|
2150
|
+
offsetWidth = value in offsetTokens ? offsetTokens[value] : null;
|
|
2151
|
+
} else {
|
|
2152
|
+
offsetWidth = /^-?\d+(\.\d+)?$/.test(value) ? parseFloat(value) : value;
|
|
2153
|
+
}
|
|
2154
|
+
if (offsetWidth === null || typeof offsetWidth === "number" && isNaN(offsetWidth)) return null;
|
|
2155
|
+
const isZero = offsetWidth === 0 || offsetWidth === "0";
|
|
2156
|
+
const offsetCss = typeof offsetWidth === "number" ? `${offsetWidth}px` : offsetWidth;
|
|
2157
|
+
return {
|
|
2158
|
+
boxShadow: isZero ? `0 0 0 ${DEFAULT_RING_WIDTH}px ${DEFAULT_RING_COLOR}` : `0 0 0 ${offsetCss} #fff, 0 0 0 calc(${offsetCss} + ${DEFAULT_RING_WIDTH}px) ${DEFAULT_RING_COLOR}`
|
|
2159
|
+
};
|
|
2160
|
+
},
|
|
2161
|
+
// ── Space between ─────────────────────────────────────────────────────────
|
|
2162
|
+
// On web: emits __spaceX/__spaceY markers → resolver generates > * + * CSS rules.
|
|
2163
|
+
// On native (RN 0.71+): uses columnGap/rowGap directly.
|
|
2164
|
+
"space-x": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
2165
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
2166
|
+
if (v === null) return null;
|
|
2167
|
+
if (getEffectiveIsWeb()) return { __spaceX: v };
|
|
2168
|
+
return { columnGap: v };
|
|
2169
|
+
},
|
|
2170
|
+
"space-y": ({ value, negative, isArbitrary }, { spacing }) => {
|
|
2171
|
+
const v = resolveSpacing(value, negative, spacing, isArbitrary);
|
|
2172
|
+
if (v === null) return null;
|
|
2173
|
+
if (getEffectiveIsWeb()) return { __spaceY: v };
|
|
2174
|
+
return { rowGap: v };
|
|
2175
|
+
}
|
|
2176
|
+
};
|
|
2177
|
+
for (const [utility, prop] of Object.entries(PADDING_MARGIN_PROPS)) {
|
|
2178
|
+
RESOLVERS[utility] = makeSpacingResolver(prop);
|
|
2179
|
+
}
|
|
2180
|
+
for (const [utility, [widthProp, colorProp]] of Object.entries(BORDER_SIDE_PROPS)) {
|
|
2181
|
+
RESOLVERS[utility] = makeBorderSideResolver(widthProp, colorProp);
|
|
2182
|
+
}
|
|
2183
|
+
function resolveUtility(parsed, theme) {
|
|
2184
|
+
if (!parsed.value) {
|
|
2185
|
+
if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
|
|
2186
|
+
if (parsed.utility in getStandalone()) return getStandalone()[parsed.utility] ?? null;
|
|
2187
|
+
}
|
|
2188
|
+
const resolver = PLUGIN_RESOLVERS[parsed.utility] ?? RESOLVERS[parsed.utility];
|
|
2189
|
+
if (resolver) return resolver(parsed, theme);
|
|
2190
|
+
return null;
|
|
2191
|
+
}
|
|
2192
|
+
var PLUGIN_STANDALONE = {};
|
|
2193
|
+
var PLUGIN_RESOLVERS = {};
|
|
2194
|
+
function clearPluginUtilities() {
|
|
2195
|
+
for (const key of Object.keys(PLUGIN_STANDALONE)) delete PLUGIN_STANDALONE[key];
|
|
2196
|
+
for (const key of Object.keys(PLUGIN_RESOLVERS)) delete PLUGIN_RESOLVERS[key];
|
|
2197
|
+
_sortedPrefixes = null;
|
|
2198
|
+
_standaloneNames = null;
|
|
2199
|
+
}
|
|
2200
|
+
function getPluginStandaloneMap() {
|
|
2201
|
+
return PLUGIN_STANDALONE;
|
|
2202
|
+
}
|
|
2203
|
+
var _sortedPrefixes = null;
|
|
2204
|
+
var _standaloneNames = null;
|
|
2205
|
+
function getBuiltinUtilityPrefixes() {
|
|
2206
|
+
if (!_sortedPrefixes) {
|
|
2207
|
+
const all = [.../* @__PURE__ */ new Set([...Object.keys(RESOLVERS), ...Object.keys(PLUGIN_RESOLVERS)])];
|
|
2208
|
+
_sortedPrefixes = all.sort((a, b) => b.length - a.length);
|
|
2209
|
+
}
|
|
2210
|
+
return _sortedPrefixes;
|
|
2211
|
+
}
|
|
2212
|
+
function getBuiltinStandaloneNames() {
|
|
2213
|
+
if (!_standaloneNames) {
|
|
2214
|
+
_standaloneNames = /* @__PURE__ */ new Set([...Object.keys(getStandalone()), ...Object.keys(PLUGIN_STANDALONE)]);
|
|
2215
|
+
}
|
|
2216
|
+
return _standaloneNames;
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
// src/core/registry.ts
|
|
2220
|
+
var BUILTIN_MODIFIERS = {
|
|
2221
|
+
// ── Mode ─────────────────────────────────────────────────────────────────
|
|
2222
|
+
dark: { darkScheme: "dark", jsBehavior: "mode", jsMatch: (d) => d },
|
|
2223
|
+
"not-light": { darkScheme: "dark", jsBehavior: "mode", jsMatch: (d) => d },
|
|
2224
|
+
light: { darkScheme: "light", jsBehavior: "mode", jsMatch: (d) => !d },
|
|
2225
|
+
"not-dark": { darkScheme: "light", jsBehavior: "mode", jsMatch: (d) => !d },
|
|
2226
|
+
// ── Interactive — JS state + CSS pseudo ───────────────────────────────────
|
|
2227
|
+
hover: { pseudo: ":hover", jsBehavior: "interactive", jsMatch: (_, s) => !!s.hover },
|
|
2228
|
+
"not-hover": { pseudo: ":not(:hover)", jsBehavior: "interactive", jsMatch: (_, s) => !s.hover },
|
|
2229
|
+
focus: { pseudo: ":focus", jsBehavior: "interactive", jsMatch: (_, s) => !!s.focus },
|
|
2230
|
+
"not-focus": { pseudo: ":not(:focus)", jsBehavior: "interactive", jsMatch: (_, s) => !s.focus },
|
|
2231
|
+
active: { pseudo: ":active", jsBehavior: "interactive", jsMatch: (_, s) => !!s.active || !!s.pressed },
|
|
2232
|
+
"not-active": { pseudo: ":not(:active)", jsBehavior: "interactive", jsMatch: (_, s) => !s.active && !s.pressed },
|
|
2233
|
+
pressed: { pseudo: ":active", jsBehavior: "interactive", jsMatch: (_, s) => !!s.pressed || !!s.active },
|
|
2234
|
+
"not-pressed": { pseudo: ":not(:active)", jsBehavior: "interactive", jsMatch: (_, s) => !s.pressed && !s.active },
|
|
2235
|
+
disabled: { pseudo: ":disabled", jsBehavior: "interactive", jsMatch: (_, s) => !!s.disabled },
|
|
2236
|
+
"not-disabled": { pseudo: ":not(:disabled)", jsBehavior: "interactive", jsMatch: (_, s) => !s.disabled },
|
|
2237
|
+
checked: { pseudo: ":checked", jsBehavior: "interactive", jsMatch: (_, s) => !!s.checked },
|
|
2238
|
+
"not-checked": { pseudo: ":not(:checked)", jsBehavior: "interactive", jsMatch: (_, s) => !s.checked },
|
|
2239
|
+
visited: { pseudo: ":visited", jsBehavior: "interactive", jsMatch: (_, s) => !!s.visited },
|
|
2240
|
+
"not-visited": { pseudo: ":not(:visited)", jsBehavior: "interactive", jsMatch: (_, s) => !s.visited },
|
|
2241
|
+
placeholder: { pseudo: "::placeholder", jsBehavior: "interactive", jsMatch: (_, s) => !!s.placeholder },
|
|
2242
|
+
// ── CSS-only pseudo-classes (structural) ──────────────────────────────────
|
|
2243
|
+
first: { pseudo: ":first-child", jsBehavior: "css-only", forcesImportant: true },
|
|
2244
|
+
last: { pseudo: ":last-child", jsBehavior: "css-only", forcesImportant: true },
|
|
2245
|
+
odd: { pseudo: ":nth-child(odd)", jsBehavior: "css-only", forcesImportant: true },
|
|
2246
|
+
even: { pseudo: ":nth-child(even)", jsBehavior: "css-only", forcesImportant: true },
|
|
2247
|
+
only: { pseudo: ":only-child", jsBehavior: "css-only", forcesImportant: true },
|
|
2248
|
+
"focus-within": { pseudo: ":focus-within", jsBehavior: "css-only", forcesImportant: true },
|
|
2249
|
+
"focus-visible": { pseudo: ":focus-visible", jsBehavior: "css-only", forcesImportant: true },
|
|
2250
|
+
// ── CSS-only pseudo-elements ───────────────────────────────────────────────
|
|
2251
|
+
before: { pseudo: "::before", jsBehavior: "css-only" },
|
|
2252
|
+
after: { pseudo: "::after", jsBehavior: "css-only" },
|
|
2253
|
+
selection: { pseudo: "::selection", jsBehavior: "css-only" },
|
|
2254
|
+
"first-letter": { pseudo: "::first-letter", jsBehavior: "css-only" },
|
|
2255
|
+
"first-line": { pseudo: "::first-line", jsBehavior: "css-only" },
|
|
2256
|
+
marker: { pseudo: "::marker", jsBehavior: "css-only" },
|
|
2257
|
+
// ── Group / peer ancestor selectors (CSS-only) ─────────────────────────────
|
|
2258
|
+
"group-hover": { ancestorSelector: ".group:hover ", jsBehavior: "css-only", forcesImportant: true },
|
|
2259
|
+
"group-focus": { ancestorSelector: ".group:focus ", jsBehavior: "css-only", forcesImportant: true },
|
|
2260
|
+
"peer-hover": { ancestorSelector: ".peer:hover ~ ", jsBehavior: "css-only", forcesImportant: true },
|
|
2261
|
+
"peer-focus": { ancestorSelector: ".peer:focus ~ ", jsBehavior: "css-only", forcesImportant: true },
|
|
2262
|
+
// ── Responsive — both CSS (@media min-width) and JS (breakpoints set) ──────
|
|
2263
|
+
sm: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("sm") },
|
|
2264
|
+
md: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("md") },
|
|
2265
|
+
lg: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("lg") },
|
|
2266
|
+
xl: { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("xl") },
|
|
2267
|
+
"2xl": { isResponsive: true, jsBehavior: "responsive", jsMatch: (_, __, bp) => bp.has("2xl") },
|
|
2268
|
+
// ── Print media (CSS-only) ─────────────────────────────────────────────────
|
|
2269
|
+
print: { mediaQuery: "print", jsBehavior: "css-only", forcesImportant: true },
|
|
2270
|
+
// ── Orientation / accessibility media (CSS-only) ───────────────────────────
|
|
2271
|
+
landscape: { mediaQuery: "(orientation: landscape)", jsBehavior: "css-only", forcesImportant: true },
|
|
2272
|
+
portrait: { mediaQuery: "(orientation: portrait)", jsBehavior: "css-only", forcesImportant: true },
|
|
2273
|
+
"motion-reduce": { mediaQuery: "(prefers-reduced-motion: reduce)", jsBehavior: "css-only", forcesImportant: true },
|
|
2274
|
+
"motion-safe": { mediaQuery: "(prefers-reduced-motion: no-preference)", jsBehavior: "css-only", forcesImportant: true },
|
|
2275
|
+
"contrast-more": { mediaQuery: "(prefers-contrast: more)", jsBehavior: "css-only", forcesImportant: true },
|
|
2276
|
+
"contrast-less": { mediaQuery: "(prefers-contrast: less)", jsBehavior: "css-only", forcesImportant: true },
|
|
2277
|
+
// ── Directionality (CSS-only) ──────────────────────────────────────────────
|
|
2278
|
+
rtl: { dirSelector: '[dir="rtl"] ', jsBehavior: "css-only", forcesImportant: true },
|
|
2279
|
+
ltr: { dirSelector: '[dir="ltr"] ', jsBehavior: "css-only", forcesImportant: true }
|
|
2280
|
+
};
|
|
2281
|
+
var _pluginModifiers = {};
|
|
2282
|
+
var _allNames = null;
|
|
2283
|
+
var _interactiveNames = null;
|
|
2284
|
+
var _modeNames = null;
|
|
2285
|
+
var _responsiveNames = null;
|
|
2286
|
+
function _invalidate() {
|
|
2287
|
+
_allNames = null;
|
|
2288
|
+
_interactiveNames = null;
|
|
2289
|
+
_modeNames = null;
|
|
2290
|
+
_responsiveNames = null;
|
|
2291
|
+
}
|
|
2292
|
+
function registerModifier(name, def) {
|
|
2293
|
+
if (process.env.NODE_ENV !== "production" && name in BUILTIN_MODIFIERS) {
|
|
2294
|
+
console.warn(`[kbach] registerModifier: "${name}" is a built-in modifier and cannot be overridden. Use a different name.`);
|
|
2295
|
+
return;
|
|
2296
|
+
}
|
|
2297
|
+
_pluginModifiers[name] = def;
|
|
2298
|
+
_invalidate();
|
|
2299
|
+
}
|
|
2300
|
+
function clearPluginModifiers() {
|
|
2301
|
+
for (const k of Object.keys(_pluginModifiers)) delete _pluginModifiers[k];
|
|
2302
|
+
_invalidate();
|
|
2303
|
+
}
|
|
2304
|
+
function getModifier(name) {
|
|
2305
|
+
return BUILTIN_MODIFIERS[name] ?? _pluginModifiers[name];
|
|
2306
|
+
}
|
|
2307
|
+
function isKnownModifier(name) {
|
|
2308
|
+
return name in BUILTIN_MODIFIERS || name in _pluginModifiers;
|
|
2309
|
+
}
|
|
2310
|
+
|
|
2311
|
+
// src/core/parser.ts
|
|
2312
|
+
function parseClass(className) {
|
|
2313
|
+
const trimmed = className.trim();
|
|
2314
|
+
if (!trimmed) return null;
|
|
2315
|
+
const modifiers = [];
|
|
2316
|
+
let remaining = trimmed;
|
|
2317
|
+
while (true) {
|
|
2318
|
+
const colonIdx = findOuterColon(remaining);
|
|
2319
|
+
if (colonIdx === -1) break;
|
|
2320
|
+
const candidate = remaining.slice(0, colonIdx);
|
|
2321
|
+
if (!isKnownModifier(candidate)) break;
|
|
2322
|
+
modifiers.push(candidate);
|
|
2323
|
+
remaining = remaining.slice(colonIdx + 1);
|
|
2324
|
+
}
|
|
2325
|
+
let important = false;
|
|
2326
|
+
if (remaining.startsWith("!") && remaining.length > 1) {
|
|
2327
|
+
important = true;
|
|
2328
|
+
remaining = remaining.slice(1);
|
|
2329
|
+
}
|
|
2330
|
+
let negative = false;
|
|
2331
|
+
if (remaining.startsWith("-") && remaining.length > 1 && remaining[1] !== "-") {
|
|
2332
|
+
negative = true;
|
|
2333
|
+
remaining = remaining.slice(1);
|
|
2334
|
+
}
|
|
2335
|
+
let bracketDepth = 0;
|
|
2336
|
+
let bracketStart = -1;
|
|
2337
|
+
for (let i = remaining.length - 1; i >= 0; i--) {
|
|
2338
|
+
if (remaining[i] === "]") bracketDepth++;
|
|
2339
|
+
else if (remaining[i] === "[") {
|
|
2340
|
+
bracketDepth--;
|
|
2341
|
+
if (bracketDepth === 0) {
|
|
2342
|
+
bracketStart = i;
|
|
2343
|
+
break;
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
if (bracketStart > 0 && remaining[bracketStart - 1] === "-" && remaining.endsWith("]")) {
|
|
2348
|
+
const utility = remaining.slice(0, bracketStart - 1);
|
|
2349
|
+
const value = remaining.slice(bracketStart + 1, -1).replace(/_/g, " ");
|
|
2350
|
+
return { original: trimmed, modifiers, negative, important, utility, value, isArbitrary: true };
|
|
2351
|
+
}
|
|
2352
|
+
if (remaining.endsWith("]") && bracketStart === -1) {
|
|
2353
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2354
|
+
console.warn(`[kbach] Malformed class string: "${trimmed}" \u2014 unbalanced brackets`);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
if (remaining.startsWith("[") && remaining.endsWith("]")) {
|
|
2358
|
+
const value = remaining.slice(1, -1).replace(/_/g, " ");
|
|
2359
|
+
return { original: trimmed, modifiers, negative, important, utility: "", value, isArbitrary: true };
|
|
2360
|
+
}
|
|
2361
|
+
if (getBuiltinStandaloneNames().has(remaining)) {
|
|
2362
|
+
return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
|
|
2363
|
+
}
|
|
2364
|
+
for (const prefix of getBuiltinUtilityPrefixes()) {
|
|
2365
|
+
if (remaining === prefix) {
|
|
2366
|
+
return { original: trimmed, modifiers, negative, important, utility: prefix, value: "", isArbitrary: false };
|
|
2367
|
+
}
|
|
2368
|
+
if (remaining.startsWith(prefix + "-")) {
|
|
2369
|
+
const value = remaining.slice(prefix.length + 1);
|
|
2370
|
+
return { original: trimmed, modifiers, negative, important, utility: prefix, value, isArbitrary: false };
|
|
2371
|
+
}
|
|
2372
|
+
}
|
|
2373
|
+
const firstDash = remaining.indexOf("-");
|
|
2374
|
+
if (firstDash > 0) {
|
|
2375
|
+
return {
|
|
2376
|
+
original: trimmed,
|
|
2377
|
+
modifiers,
|
|
2378
|
+
negative,
|
|
2379
|
+
important,
|
|
2380
|
+
utility: remaining.slice(0, firstDash),
|
|
2381
|
+
value: remaining.slice(firstDash + 1),
|
|
2382
|
+
isArbitrary: false
|
|
2383
|
+
};
|
|
2384
|
+
}
|
|
2385
|
+
return { original: trimmed, modifiers, negative, important, utility: remaining, value: "", isArbitrary: false };
|
|
2386
|
+
}
|
|
2387
|
+
function splitClassTokens(classString) {
|
|
2388
|
+
const tokens = [];
|
|
2389
|
+
let current = "";
|
|
2390
|
+
let depth = 0;
|
|
2391
|
+
let parenDepth = 0;
|
|
2392
|
+
for (let i = 0; i < classString.length; i++) {
|
|
2393
|
+
const ch = classString[i];
|
|
2394
|
+
if (ch === "[") {
|
|
2395
|
+
depth++;
|
|
2396
|
+
current += ch;
|
|
2397
|
+
continue;
|
|
2398
|
+
}
|
|
2399
|
+
if (ch === "]") {
|
|
2400
|
+
depth--;
|
|
2401
|
+
current += ch;
|
|
2402
|
+
continue;
|
|
2403
|
+
}
|
|
2404
|
+
if (ch === "(") {
|
|
2405
|
+
parenDepth++;
|
|
2406
|
+
current += ch;
|
|
2407
|
+
continue;
|
|
2408
|
+
}
|
|
2409
|
+
if (ch === ")") {
|
|
2410
|
+
parenDepth--;
|
|
2411
|
+
current += ch;
|
|
2412
|
+
continue;
|
|
2413
|
+
}
|
|
2414
|
+
if (/\s/.test(ch)) {
|
|
2415
|
+
if (depth === 0 && parenDepth === 0) {
|
|
2416
|
+
if (current) {
|
|
2417
|
+
tokens.push(current);
|
|
2418
|
+
current = "";
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
} else {
|
|
2422
|
+
current += ch;
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
if (current) tokens.push(current);
|
|
2426
|
+
return tokens;
|
|
2427
|
+
}
|
|
2428
|
+
function parseClasses(classString) {
|
|
2429
|
+
const results = [];
|
|
2430
|
+
for (const token of splitClassTokens(classString)) {
|
|
2431
|
+
const parsed = parseClass(token);
|
|
2432
|
+
if (parsed) results.push(parsed);
|
|
2433
|
+
}
|
|
2434
|
+
return results;
|
|
2435
|
+
}
|
|
2436
|
+
function findOuterColon(s) {
|
|
2437
|
+
let depth = 0;
|
|
2438
|
+
for (let i = 0; i < s.length; i++) {
|
|
2439
|
+
const ch = s[i];
|
|
2440
|
+
if (ch === "[") depth++;
|
|
2441
|
+
else if (ch === "]") depth--;
|
|
2442
|
+
else if (ch === ":" && depth === 0) return i;
|
|
2443
|
+
}
|
|
2444
|
+
return -1;
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
// src/core/cache.ts
|
|
2448
|
+
var LRUCache = class {
|
|
2449
|
+
constructor(capacity = 1e4, onEvict) {
|
|
2450
|
+
this.capacity = capacity;
|
|
2451
|
+
if (capacity <= 0) throw new Error("LRUCache: capacity must be a positive integer");
|
|
2452
|
+
this.cache = /* @__PURE__ */ new Map();
|
|
2453
|
+
this.onEvict = onEvict;
|
|
2454
|
+
}
|
|
2455
|
+
get(key) {
|
|
2456
|
+
if (!this.cache.has(key)) return void 0;
|
|
2457
|
+
const value = this.cache.get(key);
|
|
2458
|
+
this.cache.delete(key);
|
|
2459
|
+
this.cache.set(key, value);
|
|
2460
|
+
return value;
|
|
2461
|
+
}
|
|
2462
|
+
set(key, value) {
|
|
2463
|
+
if (this.cache.has(key)) {
|
|
2464
|
+
this.cache.delete(key);
|
|
2465
|
+
} else if (this.cache.size >= this.capacity) {
|
|
2466
|
+
const oldestKey = this.cache.keys().next().value;
|
|
2467
|
+
const oldestValue = this.cache.get(oldestKey);
|
|
2468
|
+
this.cache.delete(oldestKey);
|
|
2469
|
+
this.onEvict?.(oldestKey, oldestValue);
|
|
2470
|
+
}
|
|
2471
|
+
this.cache.set(key, value);
|
|
2472
|
+
return this;
|
|
2473
|
+
}
|
|
2474
|
+
has(key) {
|
|
2475
|
+
return this.cache.has(key);
|
|
2476
|
+
}
|
|
2477
|
+
delete(key) {
|
|
2478
|
+
return this.cache.delete(key);
|
|
2479
|
+
}
|
|
2480
|
+
clear() {
|
|
2481
|
+
this.cache.clear();
|
|
2482
|
+
}
|
|
2483
|
+
get size() {
|
|
2484
|
+
return this.cache.size;
|
|
2485
|
+
}
|
|
2486
|
+
};
|
|
2487
|
+
|
|
2488
|
+
// src/core/resolver.ts
|
|
2489
|
+
var FONT_KEY = "__kbach_default_font__";
|
|
2490
|
+
function setDefaultFontFamily(font) {
|
|
2491
|
+
globalThis[FONT_KEY] = font;
|
|
2492
|
+
}
|
|
2493
|
+
var _styleEl = null;
|
|
2494
|
+
function evictInjectedRule(rule) {
|
|
2495
|
+
const sheet = _styleEl?.sheet;
|
|
2496
|
+
if (!sheet) return;
|
|
2497
|
+
for (let i = 0; i < sheet.cssRules.length; i++) {
|
|
2498
|
+
if (sheet.cssRules[i].cssText === rule) {
|
|
2499
|
+
try {
|
|
2500
|
+
sheet.deleteRule(i);
|
|
2501
|
+
} catch {
|
|
2502
|
+
}
|
|
2503
|
+
return;
|
|
2504
|
+
}
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
var _injectedRules = new LRUCache(5e4, evictInjectedRule);
|
|
2508
|
+
var _CSS_DISABLED_KEY = "__kbach_runtime_css_disabled__";
|
|
2509
|
+
function isRuntimeCSSDisabled() {
|
|
2510
|
+
return !!globalThis[_CSS_DISABLED_KEY];
|
|
2511
|
+
}
|
|
2512
|
+
function getStyleEl() {
|
|
2513
|
+
if (_styleEl) return _styleEl;
|
|
2514
|
+
_styleEl = document.createElement("style");
|
|
2515
|
+
_styleEl.setAttribute("data-kbach", "");
|
|
2516
|
+
document.head.appendChild(_styleEl);
|
|
2517
|
+
return _styleEl;
|
|
2518
|
+
}
|
|
2519
|
+
var _globalStyleEl = null;
|
|
2520
|
+
function getGlobalStyleEl() {
|
|
2521
|
+
if (_globalStyleEl) return _globalStyleEl;
|
|
2522
|
+
_globalStyleEl = document.createElement("style");
|
|
2523
|
+
_globalStyleEl.setAttribute("data-kbach-global", "");
|
|
2524
|
+
document.head.insertBefore(_globalStyleEl, getStyleEl());
|
|
2525
|
+
return _globalStyleEl;
|
|
2526
|
+
}
|
|
2527
|
+
function injectGlobalStyles(theme) {
|
|
2528
|
+
if (typeof document === "undefined" || isRuntimeCSSDisabled()) return;
|
|
2529
|
+
const rules = [BASE_RESET];
|
|
2530
|
+
const ff = theme.fontFamily;
|
|
2531
|
+
if (ff?.sans && ff.sans !== "System") {
|
|
2532
|
+
const family = Array.isArray(ff.sans) ? ff.sans.join(", ") : ff.sans;
|
|
2533
|
+
rules.push(`body { font-family: ${family}; }`);
|
|
2534
|
+
}
|
|
2535
|
+
getGlobalStyleEl().textContent = rules.join("\n");
|
|
2536
|
+
}
|
|
2537
|
+
function buildDivideDecls(styles, forceImportant) {
|
|
2538
|
+
const imp = forceImportant ? " !important" : "";
|
|
2539
|
+
const parts = [];
|
|
2540
|
+
if ("__divideX" in styles) {
|
|
2541
|
+
const w = Number(styles.__divideX);
|
|
2542
|
+
parts.push(`border-left-width: ${w}px${imp}`, `border-right-width: 0px${imp}`);
|
|
2543
|
+
}
|
|
2544
|
+
if ("__divideY" in styles) {
|
|
2545
|
+
const w = Number(styles.__divideY);
|
|
2546
|
+
parts.push(`border-top-width: ${w}px${imp}`, `border-bottom-width: 0px${imp}`);
|
|
2547
|
+
}
|
|
2548
|
+
if ("__divideColor" in styles) parts.push(`border-color: ${String(styles.__divideColor)}${imp}`);
|
|
2549
|
+
if ("__divideStyle" in styles) parts.push(`border-style: ${String(styles.__divideStyle)}${imp}`);
|
|
2550
|
+
return parts.join("; ");
|
|
2551
|
+
}
|
|
2552
|
+
function buildSpaceDecls(styles, forceImportant) {
|
|
2553
|
+
const imp = forceImportant ? " !important" : "";
|
|
2554
|
+
const parts = [];
|
|
2555
|
+
if ("__spaceX" in styles) {
|
|
2556
|
+
const v = styles.__spaceX;
|
|
2557
|
+
const val = typeof v === "number" ? `${v}px` : String(v);
|
|
2558
|
+
parts.push(`margin-left: ${val}${imp}`);
|
|
2559
|
+
}
|
|
2560
|
+
if ("__spaceY" in styles) {
|
|
2561
|
+
const v = styles.__spaceY;
|
|
2562
|
+
const val = typeof v === "number" ? `${v}px` : String(v);
|
|
2563
|
+
parts.push(`margin-top: ${val}${imp}`);
|
|
2564
|
+
}
|
|
2565
|
+
return parts.join("; ");
|
|
2566
|
+
}
|
|
2567
|
+
var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
|
|
2568
|
+
"shadowColor",
|
|
2569
|
+
"shadowOffset",
|
|
2570
|
+
"shadowOpacity",
|
|
2571
|
+
"shadowRadius",
|
|
2572
|
+
"elevation",
|
|
2573
|
+
"includeFontPadding",
|
|
2574
|
+
"textAlignVertical",
|
|
2575
|
+
"writingDirection",
|
|
2576
|
+
"textShadowColor",
|
|
2577
|
+
"textShadowOffset",
|
|
2578
|
+
"textShadowRadius",
|
|
2579
|
+
"tintColor",
|
|
2580
|
+
"__divideX",
|
|
2581
|
+
"__divideY",
|
|
2582
|
+
"__divideColor",
|
|
2583
|
+
"__divideStyle",
|
|
2584
|
+
"__keyframe",
|
|
2585
|
+
"__spaceX",
|
|
2586
|
+
"__spaceY"
|
|
2587
|
+
]);
|
|
2588
|
+
var CSS_UNITLESS = /* @__PURE__ */ new Set([
|
|
2589
|
+
"opacity",
|
|
2590
|
+
"fontWeight",
|
|
2591
|
+
"flex",
|
|
2592
|
+
"flexGrow",
|
|
2593
|
+
"flexShrink",
|
|
2594
|
+
"order",
|
|
2595
|
+
"zIndex",
|
|
2596
|
+
"aspectRatio",
|
|
2597
|
+
"columnCount",
|
|
2598
|
+
"lineHeight",
|
|
2599
|
+
"gridColumnStart",
|
|
2600
|
+
"gridColumnEnd",
|
|
2601
|
+
"gridRowStart",
|
|
2602
|
+
"gridRowEnd"
|
|
2603
|
+
]);
|
|
2604
|
+
var RN_SHORTHAND_EXPAND = {
|
|
2605
|
+
marginHorizontal: ["margin-left", "margin-right"],
|
|
2606
|
+
marginVertical: ["margin-top", "margin-bottom"],
|
|
2607
|
+
paddingHorizontal: ["padding-left", "padding-right"],
|
|
2608
|
+
paddingVertical: ["padding-top", "padding-bottom"]
|
|
2609
|
+
};
|
|
2610
|
+
function styleValueToCSS(styles, forceImportant = false) {
|
|
2611
|
+
const parts = [];
|
|
2612
|
+
for (const [prop, val] of Object.entries(styles)) {
|
|
2613
|
+
if (val === void 0 || val === null || typeof val === "object" || RN_ONLY_PROPS.has(prop)) continue;
|
|
2614
|
+
let cssVal;
|
|
2615
|
+
if (typeof val === "number") {
|
|
2616
|
+
cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
|
|
2617
|
+
} else {
|
|
2618
|
+
cssVal = String(val);
|
|
2619
|
+
}
|
|
2620
|
+
const imp = forceImportant || prop === "display" && (cssVal === "grid" || cssVal === "inline-grid") || prop === "position" && (cssVal === "sticky" || cssVal === "fixed" || cssVal === "static") ? " !important" : "";
|
|
2621
|
+
if (prop in RN_SHORTHAND_EXPAND) {
|
|
2622
|
+
const [p1, p2] = RN_SHORTHAND_EXPAND[prop];
|
|
2623
|
+
parts.push(`${p1}: ${cssVal}${imp}`, `${p2}: ${cssVal}${imp}`);
|
|
2624
|
+
continue;
|
|
2625
|
+
}
|
|
2626
|
+
parts.push(`${camelToKebab(prop)}: ${cssVal}${imp}`);
|
|
2627
|
+
}
|
|
2628
|
+
return parts.join("; ");
|
|
2629
|
+
}
|
|
2630
|
+
function camelToKebab(str) {
|
|
2631
|
+
return str.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
2632
|
+
}
|
|
2633
|
+
function buildClassCSSRules(cls, bucketKey, styles, darkMode, important, screens) {
|
|
2634
|
+
const rules = [];
|
|
2635
|
+
if ("__keyframe" in styles && typeof styles.__keyframe === "string") {
|
|
2636
|
+
rules.push(styles.__keyframe);
|
|
2637
|
+
}
|
|
2638
|
+
const isDivide = "__divideX" in styles || "__divideY" in styles || "__divideColor" in styles || "__divideStyle" in styles;
|
|
2639
|
+
const isSpace = "__spaceX" in styles || "__spaceY" in styles;
|
|
2640
|
+
const isChildCombinator = isDivide || isSpace;
|
|
2641
|
+
const escaped = escapeCSSSelector(cls);
|
|
2642
|
+
const childSuffix = isChildCombinator ? " > * + *" : "";
|
|
2643
|
+
if (bucketKey === "base") {
|
|
2644
|
+
const decls2 = isDivide ? buildDivideDecls(styles, important) : isSpace ? buildSpaceDecls(styles, important) : styleValueToCSS(styles, important);
|
|
2645
|
+
if (!decls2) return rules;
|
|
2646
|
+
rules.push(`.${escaped}${childSuffix} { ${decls2} }`);
|
|
2647
|
+
return rules;
|
|
2648
|
+
}
|
|
2649
|
+
const mods = bucketKey.split(":");
|
|
2650
|
+
let darkScheme;
|
|
2651
|
+
let needsImportant = important;
|
|
2652
|
+
const pseudoParts = [];
|
|
2653
|
+
const ancestorParts = [];
|
|
2654
|
+
const dirParts = [];
|
|
2655
|
+
const mediaWrappers = [];
|
|
2656
|
+
let minWidth = 0;
|
|
2657
|
+
for (const mod of mods) {
|
|
2658
|
+
const def = getModifier(mod);
|
|
2659
|
+
if (!def) continue;
|
|
2660
|
+
if (def.darkScheme) darkScheme = def.darkScheme;
|
|
2661
|
+
if (def.pseudo) pseudoParts.push(def.pseudo);
|
|
2662
|
+
if (def.ancestorSelector) {
|
|
2663
|
+
ancestorParts.push(def.ancestorSelector);
|
|
2664
|
+
needsImportant = true;
|
|
2665
|
+
}
|
|
2666
|
+
if (def.dirSelector) {
|
|
2667
|
+
dirParts.push(def.dirSelector);
|
|
2668
|
+
needsImportant = true;
|
|
2669
|
+
}
|
|
2670
|
+
if (def.mediaQuery) {
|
|
2671
|
+
mediaWrappers.push(`@media ${def.mediaQuery}`);
|
|
2672
|
+
needsImportant = true;
|
|
2673
|
+
}
|
|
2674
|
+
if (def.isResponsive) {
|
|
2675
|
+
const w = screens[mod] ?? 0;
|
|
2676
|
+
if (w > minWidth) minWidth = w;
|
|
2677
|
+
}
|
|
2678
|
+
if (def.forcesImportant) needsImportant = true;
|
|
2679
|
+
}
|
|
2680
|
+
const pseudoSuffix = pseudoParts.join("");
|
|
2681
|
+
const elementSelector = `.${escaped}${pseudoSuffix}${childSuffix}`;
|
|
2682
|
+
const ancestorPrefix = ancestorParts.join("");
|
|
2683
|
+
const dirPrefix = dirParts.join("");
|
|
2684
|
+
const selector = `${dirPrefix}${ancestorPrefix}${elementSelector}`;
|
|
2685
|
+
const decls = isDivide ? buildDivideDecls(styles, needsImportant) : isSpace ? buildSpaceDecls(styles, needsImportant) : styleValueToCSS(styles, needsImportant);
|
|
2686
|
+
if (!decls) return rules;
|
|
2687
|
+
let rule;
|
|
2688
|
+
if (darkScheme === "dark") {
|
|
2689
|
+
if (darkMode === "media") rule = `@media (prefers-color-scheme: dark) { ${selector} { ${decls} } }`;
|
|
2690
|
+
else if (darkMode === "class") rule = `.dark ${selector} { ${decls} }`;
|
|
2691
|
+
else rule = `[data-theme="dark"] ${selector} { ${decls} }`;
|
|
2692
|
+
} else if (darkScheme === "light") {
|
|
2693
|
+
if (darkMode === "media") rule = `@media (prefers-color-scheme: light) { ${selector} { ${decls} } }`;
|
|
2694
|
+
else if (darkMode === "class") rule = `.light ${selector} { ${decls} }`;
|
|
2695
|
+
else rule = `[data-theme="light"] ${selector} { ${decls} }`;
|
|
2696
|
+
} else {
|
|
2697
|
+
rule = `${selector} { ${decls} }`;
|
|
2698
|
+
}
|
|
2699
|
+
for (const mw of mediaWrappers) rule = `${mw} { ${rule} }`;
|
|
2700
|
+
if (minWidth > 0) rule = `@media (min-width: ${minWidth}px) { ${rule} }`;
|
|
2701
|
+
rules.push(rule);
|
|
2702
|
+
return rules;
|
|
2703
|
+
}
|
|
2704
|
+
function generateClassCSS(classString, theme, darkMode = "attribute", screens = {}) {
|
|
2705
|
+
const rules = [];
|
|
2706
|
+
for (const parsed of parseClasses(classString)) {
|
|
2707
|
+
const styles = resolveUtility(parsed, theme);
|
|
2708
|
+
if (!styles) continue;
|
|
2709
|
+
const bucketKey = parsed.modifiers.length === 0 ? "base" : parsed.modifiers.join(":");
|
|
2710
|
+
rules.push(...buildClassCSSRules(parsed.original, bucketKey, styles, darkMode, parsed.important, screens));
|
|
2711
|
+
}
|
|
2712
|
+
return rules.join("\n");
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
// src/core/config.ts
|
|
2716
|
+
function deepMerge(base, override) {
|
|
2717
|
+
const result = { ...base };
|
|
2718
|
+
for (const key of Object.keys(override)) {
|
|
2719
|
+
const baseVal = base[key];
|
|
2720
|
+
const overVal = override[key];
|
|
2721
|
+
if (baseVal !== null && typeof baseVal === "object" && !Array.isArray(baseVal) && overVal !== null && typeof overVal === "object" && !Array.isArray(overVal)) {
|
|
2722
|
+
result[key] = deepMerge(
|
|
2723
|
+
baseVal,
|
|
2724
|
+
overVal
|
|
2725
|
+
);
|
|
2726
|
+
} else if (overVal !== void 0) {
|
|
2727
|
+
result[key] = overVal;
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
return result;
|
|
2731
|
+
}
|
|
2732
|
+
var CONFIG_KEY = "__kbach_config_store__";
|
|
2733
|
+
function getConfigStore() {
|
|
2734
|
+
const g = globalThis;
|
|
2735
|
+
if (!g[CONFIG_KEY]) {
|
|
2736
|
+
g[CONFIG_KEY] = { resolved: null, listeners: /* @__PURE__ */ new Set(), customVariants: {} };
|
|
2737
|
+
}
|
|
2738
|
+
return g[CONFIG_KEY];
|
|
2739
|
+
}
|
|
2740
|
+
function resolveOneRef(ref, colors) {
|
|
2741
|
+
const lastDash = ref.lastIndexOf("-");
|
|
2742
|
+
if (lastDash <= 0) return null;
|
|
2743
|
+
const name = ref.slice(0, lastDash);
|
|
2744
|
+
const shade = ref.slice(lastDash + 1);
|
|
2745
|
+
if (!/^\d+$/.test(shade)) return null;
|
|
2746
|
+
const entry = colors[name];
|
|
2747
|
+
if (!entry || typeof entry !== "object") return null;
|
|
2748
|
+
return entry[shade] ?? null;
|
|
2749
|
+
}
|
|
2750
|
+
function resolveColorRefs(colors) {
|
|
2751
|
+
const MAX_DEPTH = 5;
|
|
2752
|
+
function resolveChain(raw) {
|
|
2753
|
+
let current = raw;
|
|
2754
|
+
for (let i = 0; i < MAX_DEPTH; i++) {
|
|
2755
|
+
const next = resolveOneRef(current, colors);
|
|
2756
|
+
if (!next || next === current) break;
|
|
2757
|
+
current = next;
|
|
2758
|
+
}
|
|
2759
|
+
return current;
|
|
2760
|
+
}
|
|
2761
|
+
const out = {};
|
|
2762
|
+
for (const [key, val] of Object.entries(colors)) {
|
|
2763
|
+
if (typeof val === "string") {
|
|
2764
|
+
out[key] = resolveChain(val);
|
|
2765
|
+
} else {
|
|
2766
|
+
const shades = {};
|
|
2767
|
+
for (const [shade, hex] of Object.entries(val)) {
|
|
2768
|
+
shades[shade] = resolveChain(hex);
|
|
2769
|
+
}
|
|
2770
|
+
out[key] = shades;
|
|
2771
|
+
}
|
|
2772
|
+
}
|
|
2773
|
+
return out;
|
|
2774
|
+
}
|
|
2775
|
+
function buildConfig(userConfig) {
|
|
2776
|
+
let theme = { ...defaultTheme };
|
|
2777
|
+
if (userConfig.theme) {
|
|
2778
|
+
theme = { ...theme, ...userConfig.theme };
|
|
2779
|
+
}
|
|
2780
|
+
if (userConfig.extend) {
|
|
2781
|
+
const extendConfig = userConfig.extend;
|
|
2782
|
+
const { theme: nestedTheme, ...directKeys } = extendConfig;
|
|
2783
|
+
const extSources = [];
|
|
2784
|
+
if (nestedTheme) extSources.push(nestedTheme);
|
|
2785
|
+
if (Object.keys(directKeys).length) extSources.push(directKeys);
|
|
2786
|
+
for (const ext of extSources) {
|
|
2787
|
+
for (const [key, value] of Object.entries(ext)) {
|
|
2788
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
2789
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2790
|
+
console.warn(`[kbach] config.extend.${key} must be a plain object, got ${typeof value}. Skipping.`);
|
|
2791
|
+
}
|
|
2792
|
+
continue;
|
|
2793
|
+
}
|
|
2794
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
2795
|
+
theme[key] = deepMerge(
|
|
2796
|
+
theme[key] ?? {},
|
|
2797
|
+
value
|
|
2798
|
+
);
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
theme = { ...theme, colors: resolveColorRefs(theme.colors) };
|
|
2804
|
+
const resolved = {
|
|
2805
|
+
darkMode: userConfig.darkMode ?? "attribute",
|
|
2806
|
+
theme,
|
|
2807
|
+
plugins: userConfig.plugins ?? []
|
|
2808
|
+
};
|
|
2809
|
+
if (userConfig.plugins !== void 0) {
|
|
2810
|
+
clearPluginUtilities();
|
|
2811
|
+
clearPluginModifiers();
|
|
2812
|
+
}
|
|
2813
|
+
const _store = getConfigStore();
|
|
2814
|
+
for (const k of Object.keys(_store.customVariants)) delete _store.customVariants[k];
|
|
2815
|
+
const pluginAPI = makePluginAPI(resolved.theme);
|
|
2816
|
+
for (const plugin of resolved.plugins) {
|
|
2817
|
+
plugin(pluginAPI);
|
|
2818
|
+
}
|
|
2819
|
+
const rawSans = theme.fontFamily?.sans;
|
|
2820
|
+
const sansFontValue = Array.isArray(rawSans) ? rawSans[0] : rawSans;
|
|
2821
|
+
setDefaultFontFamily(sansFontValue && sansFontValue !== "System" ? sansFontValue : void 0);
|
|
2822
|
+
injectGlobalStyles(resolved.theme);
|
|
2823
|
+
return resolved;
|
|
2824
|
+
}
|
|
2825
|
+
function _selectorToModifierDef(selector) {
|
|
2826
|
+
const s = selector.trim();
|
|
2827
|
+
if (s.startsWith("@media ")) {
|
|
2828
|
+
return { mediaQuery: s.slice(7), jsBehavior: "css-only", forcesImportant: true };
|
|
2829
|
+
}
|
|
2830
|
+
if (s.startsWith("::") || s.startsWith(":") && !s.includes(" ") && !s.includes("&") && !s.includes("(")) {
|
|
2831
|
+
return { pseudo: s, jsBehavior: "css-only", forcesImportant: true };
|
|
2832
|
+
}
|
|
2833
|
+
return { ancestorSelector: s.endsWith(" ") ? s : `${s} `, jsBehavior: "css-only", forcesImportant: true };
|
|
2834
|
+
}
|
|
2835
|
+
function makePluginAPI(theme) {
|
|
2836
|
+
const standalone = getPluginStandaloneMap();
|
|
2837
|
+
return {
|
|
2838
|
+
addUtility(name, styles) {
|
|
2839
|
+
standalone[name] = styles;
|
|
2840
|
+
},
|
|
2841
|
+
addVariant(name, selectorOrDef) {
|
|
2842
|
+
const def = typeof selectorOrDef === "string" ? _selectorToModifierDef(selectorOrDef) : selectorOrDef;
|
|
2843
|
+
const selector = typeof selectorOrDef === "string" ? selectorOrDef : selectorOrDef.pseudo ?? selectorOrDef.mediaQuery ?? selectorOrDef.ancestorSelector ?? null;
|
|
2844
|
+
if (selector !== null && selector !== name) customVariants[name] = selector;
|
|
2845
|
+
registerModifier(name, def);
|
|
2846
|
+
},
|
|
2847
|
+
theme(path, defaultValue) {
|
|
2848
|
+
const parts = path.replace(/\[([^\]]+)\]/g, ".$1").split(".");
|
|
2849
|
+
let current = theme;
|
|
2850
|
+
for (const part of parts) {
|
|
2851
|
+
if (current === null || typeof current !== "object") return defaultValue;
|
|
2852
|
+
current = current[part];
|
|
2853
|
+
}
|
|
2854
|
+
return current ?? defaultValue;
|
|
2855
|
+
},
|
|
2856
|
+
e(className) {
|
|
2857
|
+
return className.replace(/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g, "\\$&");
|
|
2858
|
+
}
|
|
2859
|
+
};
|
|
2860
|
+
}
|
|
2861
|
+
var customVariants = new Proxy(
|
|
2862
|
+
{},
|
|
2863
|
+
{
|
|
2864
|
+
get(_t, p) {
|
|
2865
|
+
return typeof p === "string" ? getConfigStore().customVariants[p] : void 0;
|
|
2866
|
+
},
|
|
2867
|
+
set(_t, p, v) {
|
|
2868
|
+
if (typeof p === "string") getConfigStore().customVariants[p] = v;
|
|
2869
|
+
return true;
|
|
2870
|
+
},
|
|
2871
|
+
ownKeys() {
|
|
2872
|
+
return Object.keys(getConfigStore().customVariants);
|
|
2873
|
+
},
|
|
2874
|
+
getOwnPropertyDescriptor(_t, p) {
|
|
2875
|
+
if (typeof p !== "string") return void 0;
|
|
2876
|
+
const v = getConfigStore().customVariants[p];
|
|
2877
|
+
return v !== void 0 ? { value: v, writable: true, enumerable: true, configurable: true } : void 0;
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
);
|
|
2881
|
+
|
|
2882
|
+
// src/vite-plugin.ts
|
|
2883
|
+
var process2 = processImport;
|
|
14
2884
|
function normPath(p) {
|
|
15
2885
|
const fwd = p.replace(/\\/g, "/");
|
|
16
|
-
return
|
|
2886
|
+
return process2.platform === "win32" ? fwd.toLowerCase() : fwd;
|
|
17
2887
|
}
|
|
18
2888
|
setCSSGenMode(true);
|
|
19
2889
|
var KBACH_START = "/* kbach:start */";
|
|
@@ -58,8 +2928,9 @@ function buildColorVarMap(theme, usedCSS) {
|
|
|
58
2928
|
function formatKbachCSS(tokenCSS, theme, responsiveRe) {
|
|
59
2929
|
const allRaw = [...tokenCSS.values()].filter(Boolean).join("\n");
|
|
60
2930
|
const colorVars = buildColorVarMap(theme, allRaw);
|
|
2931
|
+
const sortedColorVars = [...colorVars].sort(([a], [b]) => b.length - a.length);
|
|
61
2932
|
function applyVars(css) {
|
|
62
|
-
for (const [val, varName] of
|
|
2933
|
+
for (const [val, varName] of sortedColorVars)
|
|
63
2934
|
css = css.split(val).join(`var(${varName})`);
|
|
64
2935
|
return css;
|
|
65
2936
|
}
|
|
@@ -253,7 +3124,7 @@ function kbach(userConfigOrOptions) {
|
|
|
253
3124
|
const screenKeys = Object.keys(cfg.theme.screens ?? {});
|
|
254
3125
|
const responsivePattern = screenKeys.length ? screenKeys.map((k) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|") : "sm|md|lg|xl|2xl";
|
|
255
3126
|
const responsiveRe = new RegExp(`^(${responsivePattern}):`);
|
|
256
|
-
let root =
|
|
3127
|
+
let root = process2.cwd();
|
|
257
3128
|
let mainCSSFile = null;
|
|
258
3129
|
const fileTokens = /* @__PURE__ */ new Map();
|
|
259
3130
|
const tokenCSS = /* @__PURE__ */ new Map();
|