@kbach/react-native 1.0.0-beta.3 → 1.0.0-beta.31
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 +303 -95
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-FLPPVP5G.mjs +40 -0
- package/dist/chunk-XPVSILI4.mjs +112 -0
- package/dist/chunk-ZYE4VIZE.mjs +564 -0
- package/dist/clsx-BCXALPGh.d.ts +239 -0
- package/dist/darkModeStore.d.ts +73 -0
- package/dist/darkModeStore.js +118 -0
- package/dist/dynamicTokens.d.ts +36 -0
- package/dist/dynamicTokens.js +75 -0
- package/dist/index.d.ts +11 -156
- package/dist/index.js +1994 -393
- package/dist/index.web.d.ts +18 -0
- package/dist/index.web.js +505 -0
- package/dist/index.web.mjs +266 -0
- package/dist/jsx-dev-runtime.d.ts +3 -12
- package/dist/jsx-dev-runtime.js +2143 -350
- package/dist/jsx-dev-runtime.web.d.ts +10 -0
- package/dist/jsx-dev-runtime.web.js +282 -0
- package/dist/jsx-dev-runtime.web.mjs +29 -0
- package/dist/jsx-runtime.d.ts +3 -26
- package/dist/jsx-runtime.js +2134 -342
- package/dist/jsx-runtime.web.d.ts +7 -0
- package/dist/jsx-runtime.web.js +264 -0
- package/dist/{jsx-runtime.mjs → jsx-runtime.web.mjs} +2 -2
- package/dist/theme.d.ts +54 -0
- package/dist/{chunk-7KUNKZBM.mjs → theme.js} +87 -72
- package/package.json +56 -11
- package/src/babel-plugin.js +74 -2
- package/dist/chunk-UP5ZN7CN.mjs +0 -44
- package/dist/index.d.mts +0 -161
- package/dist/index.mjs +0 -80
- package/dist/jsx-dev-runtime.d.mts +0 -19
- package/dist/jsx-dev-runtime.mjs +0 -20
- package/dist/jsx-runtime.d.mts +0 -30
package/dist/index.js
CHANGED
|
@@ -21,456 +21,2057 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
23
|
ThemeProvider: () => ThemeProvider,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
applyKbachConfig: () => applyKbachConfig,
|
|
25
|
+
clsx: () => clsx,
|
|
26
|
+
defaultTheme: () => import_theme4.defaultTheme,
|
|
27
|
+
deleteDynamicToken: () => import_dynamicTokens2.deleteDynamicToken,
|
|
28
|
+
getDynamicToken: () => import_dynamicTokens2.getDynamicToken,
|
|
29
|
+
getGlobalDarkMode: () => import_darkModeStore5.getGlobalDarkMode,
|
|
30
|
+
getGlobalThemeMode: () => import_darkModeStore5.getGlobalThemeMode,
|
|
31
|
+
getTheme: () => import_theme4.getTheme,
|
|
32
|
+
resolveKbachConfig: () => resolveKbachConfig,
|
|
28
33
|
resolveStyle: () => resolveStyle,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
setDynamicToken: () => import_dynamicTokens2.setDynamicToken,
|
|
35
|
+
setGlobalThemeMode: () => import_darkModeStore5.setGlobalThemeMode,
|
|
36
|
+
setTheme: () => import_theme4.setTheme,
|
|
37
|
+
subscribeDynamicTokens: () => import_dynamicTokens2.subscribeDynamicTokens,
|
|
38
|
+
subscribeGlobalDarkMode: () => import_darkModeStore5.subscribeGlobalDarkMode,
|
|
39
|
+
toggleGlobalDarkMode: () => import_darkModeStore5.toggleGlobalDarkMode,
|
|
40
|
+
useColors: () => useColors,
|
|
41
|
+
useDynamicToken: () => useDynamicToken,
|
|
34
42
|
useTheme: () => useTheme
|
|
35
43
|
});
|
|
36
44
|
module.exports = __toCommonJS(src_exports);
|
|
45
|
+
var import_theme4 = require("./theme");
|
|
37
46
|
|
|
38
|
-
// src/
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"amber-11": "#451a03",
|
|
43
|
-
"amber-12": "#291002",
|
|
44
|
-
"amber-2": "#fef3c7",
|
|
45
|
-
"amber-3": "#fde68a",
|
|
46
|
-
"amber-4": "#fcd34d",
|
|
47
|
-
"amber-5": "#fbbf24",
|
|
48
|
-
"amber-6": "#f59e0b",
|
|
49
|
-
"amber-7": "#d97706",
|
|
50
|
-
"amber-8": "#b45309",
|
|
51
|
-
"amber-9": "#92400e",
|
|
52
|
-
"black": "#000000",
|
|
53
|
-
"blue-1": "#eff6ff",
|
|
54
|
-
"blue-10": "#1e3a8a",
|
|
55
|
-
"blue-11": "#172554",
|
|
56
|
-
"blue-12": "#0d1633",
|
|
57
|
-
"blue-2": "#dbeafe",
|
|
58
|
-
"blue-3": "#bfdbfe",
|
|
59
|
-
"blue-4": "#93c5fd",
|
|
60
|
-
"blue-5": "#60a5fa",
|
|
61
|
-
"blue-6": "#3b82f6",
|
|
62
|
-
"blue-7": "#2563eb",
|
|
63
|
-
"blue-8": "#1d4ed8",
|
|
64
|
-
"blue-9": "#1e40af",
|
|
65
|
-
"bronze": "#cd7f32",
|
|
66
|
-
"coal": "#1c1c1c",
|
|
67
|
-
"copper": "#b87333",
|
|
68
|
-
"current": "currentColor",
|
|
69
|
-
"cyan-1": "#ecfeff",
|
|
70
|
-
"cyan-10": "#164e63",
|
|
71
|
-
"cyan-11": "#083344",
|
|
72
|
-
"cyan-12": "#041e28",
|
|
73
|
-
"cyan-2": "#cffafe",
|
|
74
|
-
"cyan-3": "#a5f3fc",
|
|
75
|
-
"cyan-4": "#67e8f9",
|
|
76
|
-
"cyan-5": "#22d3ee",
|
|
77
|
-
"cyan-6": "#06b6d4",
|
|
78
|
-
"cyan-7": "#0891b2",
|
|
79
|
-
"cyan-8": "#0e7490",
|
|
80
|
-
"cyan-9": "#155e75",
|
|
81
|
-
"emerald-1": "#ecfdf5",
|
|
82
|
-
"emerald-10": "#064e3b",
|
|
83
|
-
"emerald-11": "#022c22",
|
|
84
|
-
"emerald-12": "#011a14",
|
|
85
|
-
"emerald-2": "#d1fae5",
|
|
86
|
-
"emerald-3": "#a7f3d0",
|
|
87
|
-
"emerald-4": "#6ee7b7",
|
|
88
|
-
"emerald-5": "#34d399",
|
|
89
|
-
"emerald-6": "#10b981",
|
|
90
|
-
"emerald-7": "#059669",
|
|
91
|
-
"emerald-8": "#047857",
|
|
92
|
-
"emerald-9": "#065f46",
|
|
93
|
-
"fuchsia-1": "#fdf4ff",
|
|
94
|
-
"fuchsia-10": "#701a75",
|
|
95
|
-
"fuchsia-11": "#4a044e",
|
|
96
|
-
"fuchsia-12": "#2d022f",
|
|
97
|
-
"fuchsia-2": "#fae8ff",
|
|
98
|
-
"fuchsia-3": "#f5d0fe",
|
|
99
|
-
"fuchsia-4": "#f0abfc",
|
|
100
|
-
"fuchsia-5": "#e879f9",
|
|
101
|
-
"fuchsia-6": "#d946ef",
|
|
102
|
-
"fuchsia-7": "#c026d3",
|
|
103
|
-
"fuchsia-8": "#a21caf",
|
|
104
|
-
"fuchsia-9": "#86198f",
|
|
105
|
-
"gold": "#d4af37",
|
|
106
|
-
"gray-1": "#f9fafb",
|
|
107
|
-
"gray-10": "#111827",
|
|
108
|
-
"gray-11": "#030712",
|
|
109
|
-
"gray-12": "#020409",
|
|
110
|
-
"gray-2": "#f3f4f6",
|
|
111
|
-
"gray-3": "#e5e7eb",
|
|
112
|
-
"gray-4": "#d1d5db",
|
|
113
|
-
"gray-5": "#9ca3af",
|
|
114
|
-
"gray-6": "#6b7280",
|
|
115
|
-
"gray-7": "#4b5563",
|
|
116
|
-
"gray-8": "#374151",
|
|
117
|
-
"gray-9": "#1f2937",
|
|
118
|
-
"green-1": "#f0fdf4",
|
|
119
|
-
"green-10": "#14532d",
|
|
120
|
-
"green-11": "#052e16",
|
|
121
|
-
"green-12": "#031b0d",
|
|
122
|
-
"green-2": "#dcfce7",
|
|
123
|
-
"green-3": "#bbf7d0",
|
|
124
|
-
"green-4": "#86efac",
|
|
125
|
-
"green-5": "#4ade80",
|
|
126
|
-
"green-6": "#22c55e",
|
|
127
|
-
"green-7": "#16a34a",
|
|
128
|
-
"green-8": "#15803d",
|
|
129
|
-
"green-9": "#166534",
|
|
130
|
-
"indigo-1": "#eef2ff",
|
|
131
|
-
"indigo-10": "#312e81",
|
|
132
|
-
"indigo-11": "#1e1b4b",
|
|
133
|
-
"indigo-12": "#12102d",
|
|
134
|
-
"indigo-2": "#e0e7ff",
|
|
135
|
-
"indigo-3": "#c7d2fe",
|
|
136
|
-
"indigo-4": "#a5b4fc",
|
|
137
|
-
"indigo-5": "#818cf8",
|
|
138
|
-
"indigo-6": "#6366f1",
|
|
139
|
-
"indigo-7": "#4f46e5",
|
|
140
|
-
"indigo-8": "#4338ca",
|
|
141
|
-
"indigo-9": "#3730a3",
|
|
142
|
-
"lime-1": "#f7fee7",
|
|
143
|
-
"lime-10": "#365314",
|
|
144
|
-
"lime-11": "#1a2e05",
|
|
145
|
-
"lime-12": "#0f1b03",
|
|
146
|
-
"lime-2": "#ecfccb",
|
|
147
|
-
"lime-3": "#d9f99d",
|
|
148
|
-
"lime-4": "#bef264",
|
|
149
|
-
"lime-5": "#a3e635",
|
|
150
|
-
"lime-6": "#84cc16",
|
|
151
|
-
"lime-7": "#65a30d",
|
|
152
|
-
"lime-8": "#4d7c0f",
|
|
153
|
-
"lime-9": "#3f6212",
|
|
154
|
-
"neutral-1": "#fafafa",
|
|
155
|
-
"neutral-10": "#171717",
|
|
156
|
-
"neutral-11": "#0a0a0a",
|
|
157
|
-
"neutral-12": "#050505",
|
|
158
|
-
"neutral-2": "#f5f5f5",
|
|
159
|
-
"neutral-3": "#e5e5e5",
|
|
160
|
-
"neutral-4": "#d4d4d4",
|
|
161
|
-
"neutral-5": "#a3a3a3",
|
|
162
|
-
"neutral-6": "#737373",
|
|
163
|
-
"neutral-7": "#525252",
|
|
164
|
-
"neutral-8": "#404040",
|
|
165
|
-
"neutral-9": "#262626",
|
|
166
|
-
"orange-1": "#fff7ed",
|
|
167
|
-
"orange-10": "#7c2d12",
|
|
168
|
-
"orange-11": "#431407",
|
|
169
|
-
"orange-12": "#270c04",
|
|
170
|
-
"orange-2": "#ffedd5",
|
|
171
|
-
"orange-3": "#fed7aa",
|
|
172
|
-
"orange-4": "#fdba74",
|
|
173
|
-
"orange-5": "#fb923c",
|
|
174
|
-
"orange-6": "#f97316",
|
|
175
|
-
"orange-7": "#ea580c",
|
|
176
|
-
"orange-8": "#c2410c",
|
|
177
|
-
"orange-9": "#9a3412",
|
|
178
|
-
"pink-1": "#fdf2f8",
|
|
179
|
-
"pink-10": "#831843",
|
|
180
|
-
"pink-11": "#500724",
|
|
181
|
-
"pink-12": "#300415",
|
|
182
|
-
"pink-2": "#fce7f3",
|
|
183
|
-
"pink-3": "#fbcfe8",
|
|
184
|
-
"pink-4": "#f9a8d4",
|
|
185
|
-
"pink-5": "#f472b6",
|
|
186
|
-
"pink-6": "#ec4899",
|
|
187
|
-
"pink-7": "#db2777",
|
|
188
|
-
"pink-8": "#be185d",
|
|
189
|
-
"pink-9": "#9d174d",
|
|
190
|
-
"purple-1": "#faf5ff",
|
|
191
|
-
"purple-10": "#581c87",
|
|
192
|
-
"purple-11": "#3b0764",
|
|
193
|
-
"purple-12": "#23043c",
|
|
194
|
-
"purple-2": "#f3e8ff",
|
|
195
|
-
"purple-3": "#e9d5ff",
|
|
196
|
-
"purple-4": "#d8b4fe",
|
|
197
|
-
"purple-5": "#c084fc",
|
|
198
|
-
"purple-6": "#a855f7",
|
|
199
|
-
"purple-7": "#9333ea",
|
|
200
|
-
"purple-8": "#7e22ce",
|
|
201
|
-
"purple-9": "#6b21a8",
|
|
202
|
-
"red-1": "#fef2f2",
|
|
203
|
-
"red-10": "#7f1d1d",
|
|
204
|
-
"red-11": "#450a0a",
|
|
205
|
-
"red-12": "#280606",
|
|
206
|
-
"red-2": "#fee2e2",
|
|
207
|
-
"red-3": "#fecaca",
|
|
208
|
-
"red-4": "#fca5a5",
|
|
209
|
-
"red-5": "#f87171",
|
|
210
|
-
"red-6": "#ef4444",
|
|
211
|
-
"red-7": "#dc2626",
|
|
212
|
-
"red-8": "#b91c1c",
|
|
213
|
-
"red-9": "#991b1b",
|
|
214
|
-
"rose-1": "#fff1f2",
|
|
215
|
-
"rose-10": "#881337",
|
|
216
|
-
"rose-11": "#4c0519",
|
|
217
|
-
"rose-12": "#2d030e",
|
|
218
|
-
"rose-2": "#ffe4e6",
|
|
219
|
-
"rose-3": "#fecdd3",
|
|
220
|
-
"rose-4": "#fda4af",
|
|
221
|
-
"rose-5": "#fb7185",
|
|
222
|
-
"rose-6": "#f43f5e",
|
|
223
|
-
"rose-7": "#e11d48",
|
|
224
|
-
"rose-8": "#be123c",
|
|
225
|
-
"rose-9": "#9f1239",
|
|
226
|
-
"silver": "#c0c0c0",
|
|
227
|
-
"sky-1": "#f0f9ff",
|
|
228
|
-
"sky-10": "#0c4a6e",
|
|
229
|
-
"sky-11": "#082f49",
|
|
230
|
-
"sky-12": "#041b2b",
|
|
231
|
-
"sky-2": "#e0f2fe",
|
|
232
|
-
"sky-3": "#bae6fd",
|
|
233
|
-
"sky-4": "#7dd3fc",
|
|
234
|
-
"sky-5": "#38bdf8",
|
|
235
|
-
"sky-6": "#0ea5e9",
|
|
236
|
-
"sky-7": "#0284c7",
|
|
237
|
-
"sky-8": "#0369a1",
|
|
238
|
-
"sky-9": "#075985",
|
|
239
|
-
"slate-1": "#f8fafc",
|
|
240
|
-
"slate-10": "#0f172a",
|
|
241
|
-
"slate-11": "#020617",
|
|
242
|
-
"slate-12": "#01020a",
|
|
243
|
-
"slate-2": "#f1f5f9",
|
|
244
|
-
"slate-3": "#e2e8f0",
|
|
245
|
-
"slate-4": "#cbd5e1",
|
|
246
|
-
"slate-5": "#94a3b8",
|
|
247
|
-
"slate-6": "#64748b",
|
|
248
|
-
"slate-7": "#475569",
|
|
249
|
-
"slate-8": "#334155",
|
|
250
|
-
"slate-9": "#1e293b",
|
|
251
|
-
"stone-1": "#fafaf9",
|
|
252
|
-
"stone-10": "#1c1917",
|
|
253
|
-
"stone-11": "#0c0a09",
|
|
254
|
-
"stone-12": "#070605",
|
|
255
|
-
"stone-2": "#f5f5f4",
|
|
256
|
-
"stone-3": "#e7e5e4",
|
|
257
|
-
"stone-4": "#d6d3d1",
|
|
258
|
-
"stone-5": "#a8a29e",
|
|
259
|
-
"stone-6": "#78716c",
|
|
260
|
-
"stone-7": "#57534e",
|
|
261
|
-
"stone-8": "#44403c",
|
|
262
|
-
"stone-9": "#292524",
|
|
263
|
-
"teal-1": "#f0fdfa",
|
|
264
|
-
"teal-10": "#134e4a",
|
|
265
|
-
"teal-11": "#042f2e",
|
|
266
|
-
"teal-12": "#021c1b",
|
|
267
|
-
"teal-2": "#ccfbf1",
|
|
268
|
-
"teal-3": "#99f6e4",
|
|
269
|
-
"teal-4": "#5eead4",
|
|
270
|
-
"teal-5": "#2dd4bf",
|
|
271
|
-
"teal-6": "#14b8a6",
|
|
272
|
-
"teal-7": "#0d9488",
|
|
273
|
-
"teal-8": "#0f766e",
|
|
274
|
-
"teal-9": "#115e59",
|
|
275
|
-
"transparent": "transparent",
|
|
276
|
-
"violet-1": "#f5f3ff",
|
|
277
|
-
"violet-10": "#4c1d95",
|
|
278
|
-
"violet-11": "#2e1065",
|
|
279
|
-
"violet-12": "#1c0a3d",
|
|
280
|
-
"violet-2": "#ede9fe",
|
|
281
|
-
"violet-3": "#ddd6fe",
|
|
282
|
-
"violet-4": "#c4b5fd",
|
|
283
|
-
"violet-5": "#a78bfa",
|
|
284
|
-
"violet-6": "#8b5cf6",
|
|
285
|
-
"violet-7": "#7c3aed",
|
|
286
|
-
"violet-8": "#6d28d9",
|
|
287
|
-
"violet-9": "#5b21b6",
|
|
288
|
-
"white": "#ffffff",
|
|
289
|
-
"yellow-1": "#fefce8",
|
|
290
|
-
"yellow-10": "#713f12",
|
|
291
|
-
"yellow-11": "#422006",
|
|
292
|
-
"yellow-12": "#271304",
|
|
293
|
-
"yellow-2": "#fef9c3",
|
|
294
|
-
"yellow-3": "#fef08a",
|
|
295
|
-
"yellow-4": "#fde047",
|
|
296
|
-
"yellow-5": "#facc15",
|
|
297
|
-
"yellow-6": "#eab308",
|
|
298
|
-
"yellow-7": "#ca8a04",
|
|
299
|
-
"yellow-8": "#a16207",
|
|
300
|
-
"yellow-9": "#854d0e",
|
|
301
|
-
"zinc-1": "#fafafa",
|
|
302
|
-
"zinc-10": "#18181b",
|
|
303
|
-
"zinc-11": "#09090b",
|
|
304
|
-
"zinc-12": "#050506",
|
|
305
|
-
"zinc-2": "#f4f4f5",
|
|
306
|
-
"zinc-3": "#e4e4e7",
|
|
307
|
-
"zinc-4": "#d4d4d8",
|
|
308
|
-
"zinc-5": "#a1a1aa",
|
|
309
|
-
"zinc-6": "#71717a",
|
|
310
|
-
"zinc-7": "#52525b",
|
|
311
|
-
"zinc-8": "#3f3f46",
|
|
312
|
-
"zinc-9": "#27272a"
|
|
313
|
-
};
|
|
47
|
+
// src/nativeBridge.ts
|
|
48
|
+
var import_react_native = require("react-native");
|
|
49
|
+
var import_theme = require("./theme");
|
|
50
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
314
51
|
|
|
315
|
-
// src/
|
|
316
|
-
var
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
52
|
+
// src/jsEngine/parser.ts
|
|
53
|
+
var VALUE_PREFIXES = [
|
|
54
|
+
"bg-opacity-",
|
|
55
|
+
"text-opacity-",
|
|
56
|
+
"bg-blend-",
|
|
57
|
+
"text-shadow-",
|
|
58
|
+
"bg-",
|
|
59
|
+
"text-",
|
|
60
|
+
"border-x-",
|
|
61
|
+
"border-y-",
|
|
62
|
+
"border-t-",
|
|
63
|
+
"border-r-",
|
|
64
|
+
"border-b-",
|
|
65
|
+
"border-l-",
|
|
66
|
+
"border-",
|
|
67
|
+
"caret-",
|
|
68
|
+
"accent-",
|
|
69
|
+
"fill-",
|
|
70
|
+
"stroke-width-",
|
|
71
|
+
"stroke-",
|
|
72
|
+
"resize-",
|
|
73
|
+
"touch-",
|
|
74
|
+
"will-change-",
|
|
75
|
+
"scroll-mx-",
|
|
76
|
+
"scroll-my-",
|
|
77
|
+
"scroll-mt-",
|
|
78
|
+
"scroll-mr-",
|
|
79
|
+
"scroll-mb-",
|
|
80
|
+
"scroll-ml-",
|
|
81
|
+
"scroll-m-",
|
|
82
|
+
"scroll-px-",
|
|
83
|
+
"scroll-py-",
|
|
84
|
+
"scroll-pt-",
|
|
85
|
+
"scroll-pr-",
|
|
86
|
+
"scroll-pb-",
|
|
87
|
+
"scroll-pl-",
|
|
88
|
+
"scroll-p-",
|
|
89
|
+
"px-",
|
|
90
|
+
"py-",
|
|
91
|
+
"pt-",
|
|
92
|
+
"pr-",
|
|
93
|
+
"pb-",
|
|
94
|
+
"pl-",
|
|
95
|
+
"p-",
|
|
96
|
+
"mx-",
|
|
97
|
+
"my-",
|
|
98
|
+
"mt-",
|
|
99
|
+
"mr-",
|
|
100
|
+
"mb-",
|
|
101
|
+
"ml-",
|
|
102
|
+
"m-",
|
|
103
|
+
"gap-x-",
|
|
104
|
+
"gap-y-",
|
|
105
|
+
"gap-",
|
|
106
|
+
"min-w-",
|
|
107
|
+
"max-w-",
|
|
108
|
+
"w-",
|
|
109
|
+
"min-h-",
|
|
110
|
+
"max-h-",
|
|
111
|
+
"h-",
|
|
112
|
+
"size-",
|
|
113
|
+
"basis-",
|
|
114
|
+
"rounded-tl-",
|
|
115
|
+
"rounded-tr-",
|
|
116
|
+
"rounded-br-",
|
|
117
|
+
"rounded-bl-",
|
|
118
|
+
"rounded-t-",
|
|
119
|
+
"rounded-r-",
|
|
120
|
+
"rounded-b-",
|
|
121
|
+
"rounded-l-",
|
|
122
|
+
"rounded-",
|
|
123
|
+
"ring-offset-",
|
|
124
|
+
"ring-",
|
|
125
|
+
"outline-offset-",
|
|
126
|
+
"outline-",
|
|
127
|
+
"shadow-",
|
|
128
|
+
"opacity-",
|
|
129
|
+
"duration-",
|
|
130
|
+
"delay-",
|
|
131
|
+
"ease-",
|
|
132
|
+
"cursor-",
|
|
133
|
+
"mix-blend-",
|
|
134
|
+
"animate-",
|
|
135
|
+
"leading-",
|
|
136
|
+
"tracking-",
|
|
137
|
+
"font-",
|
|
138
|
+
"z-",
|
|
139
|
+
"inset-x-",
|
|
140
|
+
"inset-y-",
|
|
141
|
+
"inset-",
|
|
142
|
+
"top-",
|
|
143
|
+
"right-",
|
|
144
|
+
"bottom-",
|
|
145
|
+
"left-",
|
|
146
|
+
"start-",
|
|
147
|
+
"end-",
|
|
148
|
+
"overflow-x-",
|
|
149
|
+
"overflow-y-",
|
|
150
|
+
"overscroll-x-",
|
|
151
|
+
"overscroll-y-",
|
|
152
|
+
"overscroll-",
|
|
153
|
+
"aspect-",
|
|
154
|
+
"divide-color-",
|
|
155
|
+
"space-x-",
|
|
156
|
+
"space-y-",
|
|
157
|
+
"flex-",
|
|
158
|
+
"grow-",
|
|
159
|
+
"shrink-",
|
|
160
|
+
"order-",
|
|
161
|
+
"grid-cols-",
|
|
162
|
+
"grid-rows-",
|
|
163
|
+
"grid-flow-",
|
|
164
|
+
"auto-cols-",
|
|
165
|
+
"auto-rows-",
|
|
166
|
+
"col-span-",
|
|
167
|
+
"col-start-",
|
|
168
|
+
"col-end-",
|
|
169
|
+
"col-",
|
|
170
|
+
"row-span-",
|
|
171
|
+
"row-start-",
|
|
172
|
+
"row-end-",
|
|
173
|
+
"row-",
|
|
174
|
+
"place-items-",
|
|
175
|
+
"place-content-",
|
|
176
|
+
"place-self-",
|
|
177
|
+
"justify-items-",
|
|
178
|
+
"justify-self-",
|
|
179
|
+
"scale-x-",
|
|
180
|
+
"scale-y-",
|
|
181
|
+
"scale-z-",
|
|
182
|
+
"scale-",
|
|
183
|
+
"rotate-x-",
|
|
184
|
+
"rotate-y-",
|
|
185
|
+
"rotate-z-",
|
|
186
|
+
"rotate-",
|
|
187
|
+
"translate-x-",
|
|
188
|
+
"translate-y-",
|
|
189
|
+
"translate-z-",
|
|
190
|
+
"skew-x-",
|
|
191
|
+
"skew-y-",
|
|
192
|
+
"perspective-origin-",
|
|
193
|
+
"perspective-",
|
|
194
|
+
"origin-",
|
|
195
|
+
"blur-",
|
|
196
|
+
"brightness-",
|
|
197
|
+
"contrast-",
|
|
198
|
+
"grayscale-",
|
|
199
|
+
"hue-rotate-",
|
|
200
|
+
"invert-",
|
|
201
|
+
"saturate-",
|
|
202
|
+
"sepia-",
|
|
203
|
+
"drop-shadow-",
|
|
204
|
+
"filter-",
|
|
205
|
+
"backdrop-blur-",
|
|
206
|
+
"backdrop-brightness-",
|
|
207
|
+
"backdrop-contrast-",
|
|
208
|
+
"backdrop-grayscale-",
|
|
209
|
+
"backdrop-hue-rotate-",
|
|
210
|
+
"backdrop-invert-",
|
|
211
|
+
"backdrop-opacity-",
|
|
212
|
+
"backdrop-saturate-",
|
|
213
|
+
"backdrop-sepia-",
|
|
214
|
+
"backdrop-filter-",
|
|
215
|
+
"decoration-",
|
|
216
|
+
"underline-offset-",
|
|
217
|
+
"indent-",
|
|
218
|
+
"from-",
|
|
219
|
+
"via-",
|
|
220
|
+
"to-"
|
|
221
|
+
];
|
|
222
|
+
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
223
|
+
function isSafeArbitraryValue(value) {
|
|
224
|
+
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
343
225
|
}
|
|
344
|
-
function
|
|
345
|
-
|
|
226
|
+
function normalizeMathWhitespace(raw) {
|
|
227
|
+
if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
|
|
228
|
+
return raw;
|
|
229
|
+
}
|
|
230
|
+
const chars = Array.from(raw);
|
|
231
|
+
let out = "";
|
|
232
|
+
let i = 0;
|
|
233
|
+
let prevEndsValue = false;
|
|
234
|
+
while (i < chars.length) {
|
|
235
|
+
const c = chars[i];
|
|
236
|
+
if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
|
|
237
|
+
const start = i;
|
|
238
|
+
let depth = 0;
|
|
239
|
+
while (i < chars.length) {
|
|
240
|
+
if (chars[i] === "(") depth++;
|
|
241
|
+
else if (chars[i] === ")") {
|
|
242
|
+
depth--;
|
|
243
|
+
if (depth === 0) {
|
|
244
|
+
i++;
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
i++;
|
|
249
|
+
}
|
|
250
|
+
out += chars.slice(start, i).join("");
|
|
251
|
+
prevEndsValue = true;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
if (c === "+" || c === "-") {
|
|
255
|
+
if (prevEndsValue) {
|
|
256
|
+
out += ` ${c} `;
|
|
257
|
+
i++;
|
|
258
|
+
while (i < chars.length && /\s/.test(chars[i])) i++;
|
|
259
|
+
prevEndsValue = false;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
out += c;
|
|
263
|
+
prevEndsValue = false;
|
|
264
|
+
} else if (c === "(" || c === ",") {
|
|
265
|
+
out += c;
|
|
266
|
+
if (c === ",") out += " ";
|
|
267
|
+
prevEndsValue = false;
|
|
268
|
+
} else if (c === ")") {
|
|
269
|
+
out += c;
|
|
270
|
+
prevEndsValue = true;
|
|
271
|
+
} else if (/\s/.test(c)) {
|
|
272
|
+
} else if (c === "*" || c === "/") {
|
|
273
|
+
out += c;
|
|
274
|
+
prevEndsValue = false;
|
|
275
|
+
} else {
|
|
276
|
+
out += c;
|
|
277
|
+
prevEndsValue = true;
|
|
278
|
+
}
|
|
279
|
+
i++;
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
346
282
|
}
|
|
347
|
-
function
|
|
348
|
-
|
|
283
|
+
function splitRespectingBrackets(token) {
|
|
284
|
+
const parts = [];
|
|
285
|
+
let depth = 0;
|
|
286
|
+
let start = 0;
|
|
287
|
+
for (let i = 0; i < token.length; i++) {
|
|
288
|
+
const ch = token[i];
|
|
289
|
+
if (ch === "[") depth += 1;
|
|
290
|
+
else if (ch === "]") depth -= 1;
|
|
291
|
+
else if (ch === ":" && depth <= 0) {
|
|
292
|
+
parts.push(token.slice(start, i));
|
|
293
|
+
start = i + 1;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
parts.push(token.slice(start));
|
|
297
|
+
return parts;
|
|
298
|
+
}
|
|
299
|
+
function parseClass(token) {
|
|
300
|
+
const parts = splitRespectingBrackets(token);
|
|
301
|
+
let base = parts.pop() ?? token;
|
|
302
|
+
const modifiers = parts;
|
|
303
|
+
const important = base.startsWith("!");
|
|
304
|
+
if (important) {
|
|
305
|
+
base = base.slice(1);
|
|
306
|
+
}
|
|
307
|
+
const negative = base.startsWith("-");
|
|
308
|
+
if (negative) {
|
|
309
|
+
base = base.slice(1);
|
|
310
|
+
}
|
|
311
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
312
|
+
const raw = base.slice(1, -1);
|
|
313
|
+
const colonIdx = raw.indexOf(":");
|
|
314
|
+
if (colonIdx !== -1) {
|
|
315
|
+
const property = raw.slice(0, colonIdx);
|
|
316
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
317
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
318
|
+
const value = normalizeMathWhitespace(rawValue.replace(/_/g, " "));
|
|
319
|
+
return {
|
|
320
|
+
modifiers,
|
|
321
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
322
|
+
value: `${property}:${value}`,
|
|
323
|
+
isArbitrary: true,
|
|
324
|
+
important,
|
|
325
|
+
negative,
|
|
326
|
+
original: token
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
332
|
+
if (!base.startsWith(prefix)) continue;
|
|
333
|
+
const value = base.slice(prefix.length);
|
|
334
|
+
if (value === "") continue;
|
|
335
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
336
|
+
const raw = value.slice(1, -1);
|
|
337
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
338
|
+
continue;
|
|
339
|
+
}
|
|
340
|
+
const spaced = normalizeMathWhitespace(raw.replace(/_/g, " "));
|
|
341
|
+
return {
|
|
342
|
+
modifiers,
|
|
343
|
+
utility: prefix.slice(0, -1),
|
|
344
|
+
value: spaced,
|
|
345
|
+
isArbitrary: true,
|
|
346
|
+
important,
|
|
347
|
+
negative,
|
|
348
|
+
original: token
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
return {
|
|
352
|
+
modifiers,
|
|
353
|
+
utility: prefix.slice(0, -1),
|
|
354
|
+
value,
|
|
355
|
+
isArbitrary: false,
|
|
356
|
+
important,
|
|
357
|
+
negative,
|
|
358
|
+
original: token
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
return {
|
|
362
|
+
modifiers,
|
|
363
|
+
utility: base,
|
|
364
|
+
value: null,
|
|
365
|
+
isArbitrary: false,
|
|
366
|
+
important,
|
|
367
|
+
negative,
|
|
368
|
+
original: token
|
|
369
|
+
};
|
|
349
370
|
}
|
|
350
371
|
|
|
351
|
-
// src/
|
|
352
|
-
|
|
372
|
+
// src/jsEngine/shared.ts
|
|
373
|
+
function decl(property, value) {
|
|
374
|
+
return { property, value };
|
|
375
|
+
}
|
|
376
|
+
function spacingPx(theme, value) {
|
|
377
|
+
const fromTable = theme.spacing[value];
|
|
378
|
+
if (fromTable !== void 0) return fromTable;
|
|
379
|
+
const n = Number(value);
|
|
380
|
+
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
381
|
+
}
|
|
382
|
+
function resolveLength(theme, parsed) {
|
|
383
|
+
if (parsed.negative) return null;
|
|
384
|
+
const value = parsed.value;
|
|
385
|
+
if (value === null) return null;
|
|
386
|
+
if (parsed.isArbitrary) return value;
|
|
387
|
+
if (value === "full") return "100%";
|
|
388
|
+
if (value === "auto") return "auto";
|
|
389
|
+
const px = spacingPx(theme, value);
|
|
390
|
+
return px === void 0 ? null : `${px}px`;
|
|
391
|
+
}
|
|
392
|
+
function resolveNegatableLength(theme, parsed) {
|
|
393
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
394
|
+
if (parsed.isArbitrary) {
|
|
395
|
+
const value2 = parsed.value;
|
|
396
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
397
|
+
}
|
|
398
|
+
const value = parsed.value;
|
|
399
|
+
if (value === null) return null;
|
|
400
|
+
const px = spacingPx(theme, value);
|
|
401
|
+
if (px === void 0) return null;
|
|
402
|
+
if (px === 0) return "0px";
|
|
403
|
+
return `-${px}px`;
|
|
404
|
+
}
|
|
405
|
+
function fractionPercent(value) {
|
|
406
|
+
const slashIdx = value.indexOf("/");
|
|
407
|
+
if (slashIdx === -1) return null;
|
|
408
|
+
const numStr = value.slice(0, slashIdx);
|
|
409
|
+
const denStr = value.slice(slashIdx + 1);
|
|
410
|
+
const num = Number(numStr);
|
|
411
|
+
const den = Number(denStr);
|
|
412
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
413
|
+
if (den === 0) return null;
|
|
414
|
+
const pct = num / den * 100;
|
|
415
|
+
const formatted = pct.toFixed(6);
|
|
416
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
417
|
+
return `${trimmed}%`;
|
|
418
|
+
}
|
|
419
|
+
function resolveNegatableSize(theme, parsed) {
|
|
420
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
421
|
+
const pct = fractionPercent(parsed.value);
|
|
422
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
423
|
+
}
|
|
424
|
+
return resolveNegatableLength(theme, parsed);
|
|
425
|
+
}
|
|
426
|
+
function resolvePercent(parsed) {
|
|
427
|
+
if (parsed.negative) return null;
|
|
428
|
+
const value = parsed.value;
|
|
429
|
+
if (value === null) return null;
|
|
430
|
+
if (parsed.isArbitrary) return value;
|
|
431
|
+
const pct = Number(value);
|
|
432
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
433
|
+
return String(pct / 100);
|
|
434
|
+
}
|
|
353
435
|
|
|
354
|
-
// src/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
436
|
+
// src/jsEngine/resolvers/layout.ts
|
|
437
|
+
function negateRaw(value, negative) {
|
|
438
|
+
return negative ? `-${value}` : value;
|
|
439
|
+
}
|
|
440
|
+
function overflowAxisValue(property, value) {
|
|
441
|
+
switch (value) {
|
|
442
|
+
case "auto":
|
|
443
|
+
case "hidden":
|
|
444
|
+
case "clip":
|
|
445
|
+
case "visible":
|
|
446
|
+
case "scroll":
|
|
447
|
+
return [decl(property, value)];
|
|
448
|
+
default:
|
|
449
|
+
return null;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function overscrollValue(property, value) {
|
|
453
|
+
switch (value) {
|
|
454
|
+
case "auto":
|
|
455
|
+
case "contain":
|
|
456
|
+
case "none":
|
|
457
|
+
return [decl(property, value)];
|
|
458
|
+
default:
|
|
459
|
+
return null;
|
|
460
|
+
}
|
|
373
461
|
}
|
|
374
|
-
function
|
|
375
|
-
|
|
462
|
+
function resolve(parsed, theme) {
|
|
463
|
+
switch (parsed.utility) {
|
|
464
|
+
case "flex":
|
|
465
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
466
|
+
case "grid":
|
|
467
|
+
return [decl("display", "grid")];
|
|
468
|
+
case "block":
|
|
469
|
+
return [decl("display", "block")];
|
|
470
|
+
case "inline-block":
|
|
471
|
+
return [decl("display", "inline-block")];
|
|
472
|
+
case "inline":
|
|
473
|
+
return [decl("display", "inline")];
|
|
474
|
+
case "inline-flex":
|
|
475
|
+
return [decl("display", "inline-flex")];
|
|
476
|
+
case "inline-grid":
|
|
477
|
+
return [decl("display", "inline-grid")];
|
|
478
|
+
case "contents":
|
|
479
|
+
return [decl("display", "contents")];
|
|
480
|
+
case "flow-root":
|
|
481
|
+
return [decl("display", "flow-root")];
|
|
482
|
+
case "hidden":
|
|
483
|
+
return [decl("display", "none")];
|
|
484
|
+
case "@container":
|
|
485
|
+
return [decl("container-type", "inline-size")];
|
|
486
|
+
case "items-center":
|
|
487
|
+
return [decl("align-items", "center")];
|
|
488
|
+
case "items-start":
|
|
489
|
+
return [decl("align-items", "flex-start")];
|
|
490
|
+
case "items-end":
|
|
491
|
+
return [decl("align-items", "flex-end")];
|
|
492
|
+
case "items-baseline":
|
|
493
|
+
return [decl("align-items", "baseline")];
|
|
494
|
+
case "items-stretch":
|
|
495
|
+
return [decl("align-items", "stretch")];
|
|
496
|
+
case "justify-center":
|
|
497
|
+
return [decl("justify-content", "center")];
|
|
498
|
+
case "justify-start":
|
|
499
|
+
return [decl("justify-content", "flex-start")];
|
|
500
|
+
case "justify-end":
|
|
501
|
+
return [decl("justify-content", "flex-end")];
|
|
502
|
+
case "justify-between":
|
|
503
|
+
return [decl("justify-content", "space-between")];
|
|
504
|
+
case "justify-around":
|
|
505
|
+
return [decl("justify-content", "space-around")];
|
|
506
|
+
case "justify-evenly":
|
|
507
|
+
return [decl("justify-content", "space-evenly")];
|
|
508
|
+
case "justify-normal":
|
|
509
|
+
return [decl("justify-content", "normal")];
|
|
510
|
+
case "justify-stretch":
|
|
511
|
+
return [decl("justify-content", "stretch")];
|
|
512
|
+
case "content-normal":
|
|
513
|
+
return [decl("align-content", "normal")];
|
|
514
|
+
case "content-start":
|
|
515
|
+
return [decl("align-content", "flex-start")];
|
|
516
|
+
case "content-end":
|
|
517
|
+
return [decl("align-content", "flex-end")];
|
|
518
|
+
case "content-center":
|
|
519
|
+
return [decl("align-content", "center")];
|
|
520
|
+
case "content-between":
|
|
521
|
+
return [decl("align-content", "space-between")];
|
|
522
|
+
case "content-around":
|
|
523
|
+
return [decl("align-content", "space-around")];
|
|
524
|
+
case "content-evenly":
|
|
525
|
+
return [decl("align-content", "space-evenly")];
|
|
526
|
+
case "content-stretch":
|
|
527
|
+
return [decl("align-content", "stretch")];
|
|
528
|
+
case "self-auto":
|
|
529
|
+
return [decl("align-self", "auto")];
|
|
530
|
+
case "self-center":
|
|
531
|
+
return [decl("align-self", "center")];
|
|
532
|
+
case "self-start":
|
|
533
|
+
return [decl("align-self", "flex-start")];
|
|
534
|
+
case "self-end":
|
|
535
|
+
return [decl("align-self", "flex-end")];
|
|
536
|
+
case "self-stretch":
|
|
537
|
+
return [decl("align-self", "stretch")];
|
|
538
|
+
case "self-baseline":
|
|
539
|
+
return [decl("align-self", "baseline")];
|
|
540
|
+
case "overflow-hidden":
|
|
541
|
+
return [decl("overflow", "hidden")];
|
|
542
|
+
case "overflow-auto":
|
|
543
|
+
return [decl("overflow", "auto")];
|
|
544
|
+
case "overflow-scroll":
|
|
545
|
+
return [decl("overflow", "scroll")];
|
|
546
|
+
case "overflow-visible":
|
|
547
|
+
return [decl("overflow", "visible")];
|
|
548
|
+
case "overflow-clip":
|
|
549
|
+
return [decl("overflow", "clip")];
|
|
550
|
+
case "overflow-x":
|
|
551
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
552
|
+
case "overflow-y":
|
|
553
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
554
|
+
case "overscroll":
|
|
555
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
556
|
+
case "overscroll-x":
|
|
557
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
558
|
+
case "overscroll-y":
|
|
559
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
560
|
+
case "static":
|
|
561
|
+
return [decl("position", "static")];
|
|
562
|
+
case "relative":
|
|
563
|
+
return [decl("position", "relative")];
|
|
564
|
+
case "absolute":
|
|
565
|
+
return [decl("position", "absolute")];
|
|
566
|
+
case "fixed":
|
|
567
|
+
return [decl("position", "fixed")];
|
|
568
|
+
case "sticky":
|
|
569
|
+
return [decl("position", "sticky")];
|
|
570
|
+
case "z":
|
|
571
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
572
|
+
case "order":
|
|
573
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
574
|
+
case "grow":
|
|
575
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
576
|
+
case "shrink":
|
|
577
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
578
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
579
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
580
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
581
|
+
case "top": {
|
|
582
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
583
|
+
return v === null ? null : [decl("top", v)];
|
|
584
|
+
}
|
|
585
|
+
case "right": {
|
|
586
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
587
|
+
return v === null ? null : [decl("right", v)];
|
|
588
|
+
}
|
|
589
|
+
case "bottom": {
|
|
590
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
591
|
+
return v === null ? null : [decl("bottom", v)];
|
|
592
|
+
}
|
|
593
|
+
case "left": {
|
|
594
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
595
|
+
return v === null ? null : [decl("left", v)];
|
|
596
|
+
}
|
|
597
|
+
case "inset": {
|
|
598
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
599
|
+
return v === null ? null : [decl("inset", v)];
|
|
600
|
+
}
|
|
601
|
+
case "inset-x": {
|
|
602
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
603
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
604
|
+
}
|
|
605
|
+
case "inset-y": {
|
|
606
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
607
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
608
|
+
}
|
|
609
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
610
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
611
|
+
case "start": {
|
|
612
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
613
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
614
|
+
}
|
|
615
|
+
case "end": {
|
|
616
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
617
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
618
|
+
}
|
|
619
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
620
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
621
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
622
|
+
// "aspect" arm.
|
|
623
|
+
case "aspect": {
|
|
624
|
+
const value = parsed.value;
|
|
625
|
+
if (value === null) return null;
|
|
626
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
627
|
+
switch (value) {
|
|
628
|
+
case "square":
|
|
629
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
630
|
+
case "video":
|
|
631
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
632
|
+
case "auto":
|
|
633
|
+
return [decl("aspect-ratio", "auto")];
|
|
634
|
+
default:
|
|
635
|
+
return null;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
default:
|
|
639
|
+
return null;
|
|
640
|
+
}
|
|
376
641
|
}
|
|
377
|
-
function
|
|
378
|
-
return
|
|
642
|
+
function resolveFlex(parsed, web) {
|
|
643
|
+
if (parsed.utility !== "flex") return null;
|
|
644
|
+
const value = parsed.value;
|
|
645
|
+
if (value === null) return null;
|
|
646
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
647
|
+
switch (value) {
|
|
648
|
+
case "row":
|
|
649
|
+
return [decl("flex-direction", "row")];
|
|
650
|
+
case "col":
|
|
651
|
+
return [decl("flex-direction", "column")];
|
|
652
|
+
case "row-reverse":
|
|
653
|
+
return [decl("flex-direction", "row-reverse")];
|
|
654
|
+
case "col-reverse":
|
|
655
|
+
return [decl("flex-direction", "column-reverse")];
|
|
656
|
+
case "wrap":
|
|
657
|
+
return [decl("flex-wrap", "wrap")];
|
|
658
|
+
case "wrap-reverse":
|
|
659
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
660
|
+
case "nowrap":
|
|
661
|
+
return [decl("flex-wrap", "nowrap")];
|
|
662
|
+
case "1":
|
|
663
|
+
return [decl("flex", "1")];
|
|
664
|
+
case "auto":
|
|
665
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
666
|
+
case "initial":
|
|
667
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
668
|
+
case "none":
|
|
669
|
+
return [decl("flex", web ? "none" : "0")];
|
|
670
|
+
case "grow":
|
|
671
|
+
return [decl("flex-grow", "1")];
|
|
672
|
+
case "grow-0":
|
|
673
|
+
return [decl("flex-grow", "0")];
|
|
674
|
+
case "shrink":
|
|
675
|
+
return [decl("flex-shrink", "1")];
|
|
676
|
+
case "shrink-0":
|
|
677
|
+
return [decl("flex-shrink", "0")];
|
|
678
|
+
default:
|
|
679
|
+
return null;
|
|
680
|
+
}
|
|
379
681
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
682
|
+
|
|
683
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
684
|
+
function namedSize(key) {
|
|
685
|
+
switch (key) {
|
|
686
|
+
case "sm":
|
|
687
|
+
return "24rem";
|
|
688
|
+
case "md":
|
|
689
|
+
return "28rem";
|
|
690
|
+
case "lg":
|
|
691
|
+
return "32rem";
|
|
692
|
+
case "xl":
|
|
693
|
+
return "36rem";
|
|
694
|
+
case "2xl":
|
|
695
|
+
return "42rem";
|
|
696
|
+
case "3xl":
|
|
697
|
+
return "48rem";
|
|
698
|
+
case "4xl":
|
|
699
|
+
return "56rem";
|
|
700
|
+
case "5xl":
|
|
701
|
+
return "64rem";
|
|
702
|
+
case "6xl":
|
|
703
|
+
return "72rem";
|
|
704
|
+
case "7xl":
|
|
705
|
+
return "80rem";
|
|
706
|
+
case "8xl":
|
|
707
|
+
return "88rem";
|
|
708
|
+
case "9xl":
|
|
709
|
+
return "96rem";
|
|
710
|
+
default:
|
|
711
|
+
return null;
|
|
712
|
+
}
|
|
385
713
|
}
|
|
386
|
-
function
|
|
387
|
-
|
|
714
|
+
function cssSizeKeyword(key) {
|
|
715
|
+
switch (key) {
|
|
716
|
+
case "min":
|
|
717
|
+
return "min-content";
|
|
718
|
+
case "max":
|
|
719
|
+
return "max-content";
|
|
720
|
+
case "fit":
|
|
721
|
+
return "fit-content";
|
|
722
|
+
default:
|
|
723
|
+
return null;
|
|
724
|
+
}
|
|
388
725
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
391
|
-
|
|
726
|
+
function resolveSize(theme, parsed) {
|
|
727
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
728
|
+
const named = namedSize(parsed.value);
|
|
729
|
+
if (named !== null) return named;
|
|
730
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
731
|
+
if (kw !== null) return kw;
|
|
732
|
+
const fraction = fractionPercent(parsed.value);
|
|
733
|
+
if (fraction !== null) return fraction;
|
|
734
|
+
}
|
|
735
|
+
return resolveLength(theme, parsed);
|
|
392
736
|
}
|
|
393
|
-
function
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
737
|
+
function resolve2(parsed, theme) {
|
|
738
|
+
const length = () => resolveLength(theme, parsed);
|
|
739
|
+
const size = () => resolveSize(theme, parsed);
|
|
740
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
741
|
+
switch (parsed.utility) {
|
|
742
|
+
case "p": {
|
|
743
|
+
const v = length();
|
|
744
|
+
return v === null ? null : [decl("padding", v)];
|
|
745
|
+
}
|
|
746
|
+
case "px": {
|
|
747
|
+
const v = length();
|
|
748
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
749
|
+
}
|
|
750
|
+
case "py": {
|
|
751
|
+
const v = length();
|
|
752
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
753
|
+
}
|
|
754
|
+
case "pt": {
|
|
755
|
+
const v = length();
|
|
756
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
757
|
+
}
|
|
758
|
+
case "pr": {
|
|
759
|
+
const v = length();
|
|
760
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
761
|
+
}
|
|
762
|
+
case "pb": {
|
|
763
|
+
const v = length();
|
|
764
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
765
|
+
}
|
|
766
|
+
case "pl": {
|
|
767
|
+
const v = length();
|
|
768
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
769
|
+
}
|
|
770
|
+
case "m": {
|
|
771
|
+
const v = negatableLength();
|
|
772
|
+
return v === null ? null : [decl("margin", v)];
|
|
773
|
+
}
|
|
774
|
+
case "mx": {
|
|
775
|
+
const v = negatableLength();
|
|
776
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
777
|
+
}
|
|
778
|
+
case "my": {
|
|
779
|
+
const v = negatableLength();
|
|
780
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
781
|
+
}
|
|
782
|
+
case "mt": {
|
|
783
|
+
const v = negatableLength();
|
|
784
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
785
|
+
}
|
|
786
|
+
case "mr": {
|
|
787
|
+
const v = negatableLength();
|
|
788
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
789
|
+
}
|
|
790
|
+
case "mb": {
|
|
791
|
+
const v = negatableLength();
|
|
792
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
793
|
+
}
|
|
794
|
+
case "ml": {
|
|
795
|
+
const v = negatableLength();
|
|
796
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
797
|
+
}
|
|
798
|
+
case "gap": {
|
|
799
|
+
const v = length();
|
|
800
|
+
return v === null ? null : [decl("gap", v)];
|
|
801
|
+
}
|
|
802
|
+
case "gap-x": {
|
|
803
|
+
const v = length();
|
|
804
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
805
|
+
}
|
|
806
|
+
case "gap-y": {
|
|
807
|
+
const v = length();
|
|
808
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
809
|
+
}
|
|
810
|
+
case "w": {
|
|
811
|
+
const v = size();
|
|
812
|
+
return v === null ? null : [decl("width", v)];
|
|
813
|
+
}
|
|
814
|
+
case "h": {
|
|
815
|
+
const v = size();
|
|
816
|
+
return v === null ? null : [decl("height", v)];
|
|
817
|
+
}
|
|
818
|
+
case "min-w": {
|
|
819
|
+
const v = size();
|
|
820
|
+
return v === null ? null : [decl("min-width", v)];
|
|
821
|
+
}
|
|
822
|
+
case "max-w": {
|
|
823
|
+
const v = size();
|
|
824
|
+
return v === null ? null : [decl("max-width", v)];
|
|
825
|
+
}
|
|
826
|
+
case "min-h": {
|
|
827
|
+
const v = size();
|
|
828
|
+
return v === null ? null : [decl("min-height", v)];
|
|
829
|
+
}
|
|
830
|
+
case "max-h": {
|
|
831
|
+
const v = size();
|
|
832
|
+
return v === null ? null : [decl("max-height", v)];
|
|
833
|
+
}
|
|
834
|
+
case "size": {
|
|
835
|
+
const v = size();
|
|
836
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
837
|
+
}
|
|
838
|
+
case "basis": {
|
|
839
|
+
const v = size();
|
|
840
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
841
|
+
}
|
|
842
|
+
default:
|
|
843
|
+
return null;
|
|
844
|
+
}
|
|
398
845
|
}
|
|
399
846
|
|
|
400
|
-
// src/
|
|
401
|
-
function
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
847
|
+
// src/jsEngine/resolvers/color.ts
|
|
848
|
+
function lookupHex(theme, key) {
|
|
849
|
+
const entry = theme.colors[key];
|
|
850
|
+
return typeof entry === "string" ? entry : null;
|
|
851
|
+
}
|
|
852
|
+
function hexToRgb(hex) {
|
|
853
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
854
|
+
if (!m) return null;
|
|
855
|
+
let h = m[1];
|
|
856
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
857
|
+
const n = parseInt(h, 16);
|
|
858
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
859
|
+
}
|
|
860
|
+
function splitOpacity(value) {
|
|
861
|
+
const slash = value.lastIndexOf("/");
|
|
862
|
+
if (slash === -1) return [value, null];
|
|
863
|
+
const opacityText = value.slice(slash + 1);
|
|
864
|
+
const n = Number(opacityText);
|
|
865
|
+
if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
|
|
866
|
+
return [value.slice(0, slash), n];
|
|
867
|
+
}
|
|
868
|
+
return [value, null];
|
|
869
|
+
}
|
|
870
|
+
function colorValue(theme, parsed) {
|
|
871
|
+
const value = parsed.value;
|
|
872
|
+
if (value === null) return null;
|
|
873
|
+
if (parsed.isArbitrary) return value;
|
|
874
|
+
const [name, opacity] = splitOpacity(value);
|
|
875
|
+
const hex = lookupHex(theme, name);
|
|
876
|
+
if (hex === null) return null;
|
|
877
|
+
if (opacity === null) return hex;
|
|
878
|
+
const rgb = hexToRgb(hex);
|
|
879
|
+
if (rgb === null) return hex;
|
|
880
|
+
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
407
881
|
}
|
|
408
882
|
|
|
409
|
-
// src/
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
883
|
+
// src/jsEngine/resolvers/border.ts
|
|
884
|
+
function radiusSize(key) {
|
|
885
|
+
switch (key) {
|
|
886
|
+
case "none":
|
|
887
|
+
return "0px";
|
|
888
|
+
case "sm":
|
|
889
|
+
return "0.125rem";
|
|
890
|
+
case "md":
|
|
891
|
+
return "0.375rem";
|
|
892
|
+
case "lg":
|
|
893
|
+
return "0.5rem";
|
|
894
|
+
case "xl":
|
|
895
|
+
return "0.75rem";
|
|
896
|
+
case "2xl":
|
|
897
|
+
return "1rem";
|
|
898
|
+
case "3xl":
|
|
899
|
+
return "1.5rem";
|
|
900
|
+
case "full":
|
|
901
|
+
return "9999px";
|
|
902
|
+
default:
|
|
903
|
+
return null;
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
function borderSideProperty(side) {
|
|
907
|
+
switch (side) {
|
|
908
|
+
case "t":
|
|
909
|
+
return "border-top";
|
|
910
|
+
case "r":
|
|
911
|
+
return "border-right";
|
|
912
|
+
case "b":
|
|
913
|
+
return "border-bottom";
|
|
914
|
+
case "l":
|
|
915
|
+
return "border-left";
|
|
916
|
+
default:
|
|
917
|
+
return null;
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
function borderValue(theme, parsed) {
|
|
921
|
+
const value = parsed.value;
|
|
922
|
+
if (value === null) return null;
|
|
923
|
+
if (!parsed.isArbitrary) {
|
|
924
|
+
const side = borderSideProperty(value);
|
|
925
|
+
if (side !== null) {
|
|
926
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
927
|
+
}
|
|
928
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
929
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
930
|
+
}
|
|
931
|
+
if (parsed.isArbitrary) {
|
|
932
|
+
return [decl("border-width", value)];
|
|
933
|
+
}
|
|
934
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
935
|
+
const v = resolveLength(theme, parsed);
|
|
936
|
+
return v === null ? null : [decl("border-width", v)];
|
|
937
|
+
}
|
|
938
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
939
|
+
return [decl("border-style", value)];
|
|
940
|
+
}
|
|
941
|
+
const color = colorValue(theme, parsed);
|
|
942
|
+
return color === null ? null : [decl("border-color", color)];
|
|
943
|
+
}
|
|
944
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
945
|
+
const value = parsed.value;
|
|
946
|
+
if (value === null) return null;
|
|
947
|
+
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
948
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
949
|
+
const v = resolveLength(theme, parsed);
|
|
950
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
951
|
+
}
|
|
952
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
953
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
954
|
+
}
|
|
955
|
+
const color = colorValue(theme, parsed);
|
|
956
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
957
|
+
}
|
|
958
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
959
|
+
const value = parsed.value;
|
|
960
|
+
if (value === null) return null;
|
|
961
|
+
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
962
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
963
|
+
const v = resolveLength(theme, parsed);
|
|
964
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
965
|
+
}
|
|
966
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
967
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
968
|
+
}
|
|
969
|
+
const color = colorValue(theme, parsed);
|
|
970
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
971
|
+
}
|
|
972
|
+
function radiusProperties(side) {
|
|
973
|
+
switch (side) {
|
|
974
|
+
case "t":
|
|
975
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
976
|
+
case "r":
|
|
977
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
978
|
+
case "b":
|
|
979
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
980
|
+
case "l":
|
|
981
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
982
|
+
case "tl":
|
|
983
|
+
return ["border-top-left-radius"];
|
|
984
|
+
case "tr":
|
|
985
|
+
return ["border-top-right-radius"];
|
|
986
|
+
case "br":
|
|
987
|
+
return ["border-bottom-right-radius"];
|
|
988
|
+
case "bl":
|
|
989
|
+
return ["border-bottom-left-radius"];
|
|
990
|
+
default:
|
|
991
|
+
return null;
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
function resolveRadiusValue(theme, parsed) {
|
|
995
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
996
|
+
const size = radiusSize(parsed.value);
|
|
997
|
+
if (size !== null) return size;
|
|
998
|
+
}
|
|
999
|
+
return resolveLength(theme, parsed);
|
|
1000
|
+
}
|
|
1001
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
1002
|
+
const properties = radiusProperties(side);
|
|
1003
|
+
if (properties === null) return null;
|
|
1004
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
1005
|
+
if (value === null) return null;
|
|
1006
|
+
return properties.map((p) => decl(p, value));
|
|
1007
|
+
}
|
|
1008
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1009
|
+
function outlineWidthValue(key) {
|
|
1010
|
+
switch (key) {
|
|
1011
|
+
case "0":
|
|
1012
|
+
return "0px";
|
|
1013
|
+
case "1":
|
|
1014
|
+
return "1px";
|
|
1015
|
+
case "2":
|
|
1016
|
+
return "2px";
|
|
1017
|
+
case "4":
|
|
1018
|
+
return "4px";
|
|
1019
|
+
case "8":
|
|
1020
|
+
return "8px";
|
|
1021
|
+
default:
|
|
1022
|
+
return null;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
function outlineValue(theme, parsed) {
|
|
1026
|
+
const value = parsed.value;
|
|
1027
|
+
if (value === null) return null;
|
|
1028
|
+
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
1029
|
+
const w = outlineWidthValue(value);
|
|
1030
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
1031
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1032
|
+
const color = colorValue(theme, parsed);
|
|
1033
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1034
|
+
}
|
|
1035
|
+
function outlineOffsetValue(parsed) {
|
|
1036
|
+
const value = parsed.value;
|
|
1037
|
+
if (value === null) return null;
|
|
1038
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
1039
|
+
const w = outlineWidthValue(value);
|
|
1040
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
1041
|
+
}
|
|
1042
|
+
var RING_BOX_SHADOW = "var(--kb-ring-inset,) 0 0 0 var(--kb-ring-offset-width, 0px) var(--kb-ring-offset-color, #fff), var(--kb-ring-inset,) 0 0 0 calc(var(--kb-ring-width, 0px) + var(--kb-ring-offset-width, 0px)) var(--kb-ring-color, rgba(59,130,246,0.5))";
|
|
1043
|
+
function ringWidth(key) {
|
|
1044
|
+
switch (key) {
|
|
1045
|
+
case "0":
|
|
1046
|
+
return "0px";
|
|
1047
|
+
case "1":
|
|
1048
|
+
return "1px";
|
|
1049
|
+
case "2":
|
|
1050
|
+
return "2px";
|
|
1051
|
+
case "4":
|
|
1052
|
+
return "4px";
|
|
1053
|
+
case "8":
|
|
1054
|
+
return "8px";
|
|
1055
|
+
default:
|
|
1056
|
+
return null;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
function ringValue(theme, parsed) {
|
|
1060
|
+
const value = parsed.value;
|
|
1061
|
+
if (value === null) return null;
|
|
1062
|
+
if (value === "inset") {
|
|
1063
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1064
|
+
}
|
|
1065
|
+
if (!parsed.isArbitrary) {
|
|
1066
|
+
const w = ringWidth(value);
|
|
1067
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1068
|
+
}
|
|
1069
|
+
const color = colorValue(theme, parsed);
|
|
1070
|
+
if (color === null) return null;
|
|
1071
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1072
|
+
}
|
|
1073
|
+
function ringOffsetValue(theme, parsed) {
|
|
1074
|
+
const value = parsed.value;
|
|
1075
|
+
if (value === null) return null;
|
|
1076
|
+
if (!parsed.isArbitrary) {
|
|
1077
|
+
const w = ringWidth(value);
|
|
1078
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1079
|
+
}
|
|
1080
|
+
const color = colorValue(theme, parsed);
|
|
1081
|
+
if (color === null) return null;
|
|
1082
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1083
|
+
}
|
|
1084
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1085
|
+
function resolve3(parsed, theme) {
|
|
1086
|
+
switch (parsed.utility) {
|
|
1087
|
+
case "border":
|
|
1088
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1089
|
+
return borderValue(theme, parsed);
|
|
1090
|
+
case "border-t":
|
|
1091
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1092
|
+
case "border-r":
|
|
1093
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1094
|
+
case "border-b":
|
|
1095
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1096
|
+
case "border-l":
|
|
1097
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1098
|
+
case "border-x":
|
|
1099
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1100
|
+
case "border-y":
|
|
1101
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1102
|
+
case "rounded": {
|
|
1103
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1104
|
+
const value = parsed.value;
|
|
1105
|
+
if (!parsed.isArbitrary) {
|
|
1106
|
+
const size = radiusSize(value);
|
|
1107
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1108
|
+
}
|
|
1109
|
+
const v = resolveLength(theme, parsed);
|
|
1110
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1111
|
+
}
|
|
1112
|
+
case "ring":
|
|
1113
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1114
|
+
return ringValue(theme, parsed);
|
|
1115
|
+
case "ring-offset":
|
|
1116
|
+
return ringOffsetValue(theme, parsed);
|
|
1117
|
+
case "outline":
|
|
1118
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1119
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1120
|
+
return outlineValue(theme, parsed);
|
|
1121
|
+
case "outline-offset":
|
|
1122
|
+
return outlineOffsetValue(parsed);
|
|
1123
|
+
default:
|
|
1124
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1125
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1126
|
+
}
|
|
1127
|
+
return null;
|
|
1128
|
+
}
|
|
413
1129
|
}
|
|
414
1130
|
|
|
415
|
-
// src/
|
|
416
|
-
|
|
1131
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1132
|
+
function textSize(key) {
|
|
1133
|
+
switch (key) {
|
|
1134
|
+
case "xs":
|
|
1135
|
+
return "0.75rem";
|
|
1136
|
+
case "sm":
|
|
1137
|
+
return "0.875rem";
|
|
1138
|
+
case "base":
|
|
1139
|
+
return "1rem";
|
|
1140
|
+
case "lg":
|
|
1141
|
+
return "1.125rem";
|
|
1142
|
+
case "xl":
|
|
1143
|
+
return "1.25rem";
|
|
1144
|
+
case "2xl":
|
|
1145
|
+
return "1.5rem";
|
|
1146
|
+
case "3xl":
|
|
1147
|
+
return "1.875rem";
|
|
1148
|
+
case "4xl":
|
|
1149
|
+
return "2.25rem";
|
|
1150
|
+
case "5xl":
|
|
1151
|
+
return "3rem";
|
|
1152
|
+
case "6xl":
|
|
1153
|
+
return "3.75rem";
|
|
1154
|
+
case "7xl":
|
|
1155
|
+
return "4.5rem";
|
|
1156
|
+
case "8xl":
|
|
1157
|
+
return "6rem";
|
|
1158
|
+
case "9xl":
|
|
1159
|
+
return "8rem";
|
|
1160
|
+
default:
|
|
1161
|
+
return null;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
function lineHeightSize(key) {
|
|
1165
|
+
switch (key) {
|
|
1166
|
+
case "3":
|
|
1167
|
+
return "0.75rem";
|
|
1168
|
+
case "4":
|
|
1169
|
+
return "1rem";
|
|
1170
|
+
case "5":
|
|
1171
|
+
return "1.25rem";
|
|
1172
|
+
case "6":
|
|
1173
|
+
return "1.5rem";
|
|
1174
|
+
case "7":
|
|
1175
|
+
return "1.75rem";
|
|
1176
|
+
case "8":
|
|
1177
|
+
return "2rem";
|
|
1178
|
+
case "9":
|
|
1179
|
+
return "2.25rem";
|
|
1180
|
+
case "10":
|
|
1181
|
+
return "2.5rem";
|
|
1182
|
+
default:
|
|
1183
|
+
return null;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
function textAlign(key) {
|
|
1187
|
+
switch (key) {
|
|
1188
|
+
case "left":
|
|
1189
|
+
return "left";
|
|
1190
|
+
case "center":
|
|
1191
|
+
return "center";
|
|
1192
|
+
case "right":
|
|
1193
|
+
return "right";
|
|
1194
|
+
case "justify":
|
|
1195
|
+
return "justify";
|
|
1196
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
1197
|
+
// as layout.rs's start/end inset properties.
|
|
1198
|
+
case "start":
|
|
1199
|
+
return "start";
|
|
1200
|
+
case "end":
|
|
1201
|
+
return "end";
|
|
1202
|
+
default:
|
|
1203
|
+
return null;
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
function fontWeight(key) {
|
|
1207
|
+
switch (key) {
|
|
1208
|
+
case "thin":
|
|
1209
|
+
return "100";
|
|
1210
|
+
case "extralight":
|
|
1211
|
+
return "200";
|
|
1212
|
+
case "light":
|
|
1213
|
+
return "300";
|
|
1214
|
+
case "normal":
|
|
1215
|
+
return "400";
|
|
1216
|
+
case "medium":
|
|
1217
|
+
return "500";
|
|
1218
|
+
case "semibold":
|
|
1219
|
+
return "600";
|
|
1220
|
+
case "bold":
|
|
1221
|
+
return "700";
|
|
1222
|
+
case "extrabold":
|
|
1223
|
+
return "800";
|
|
1224
|
+
case "black":
|
|
1225
|
+
return "900";
|
|
1226
|
+
default:
|
|
1227
|
+
return null;
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
function fontFamilyValue(theme, key) {
|
|
1231
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
1232
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
1233
|
+
switch (key) {
|
|
1234
|
+
case "sans":
|
|
1235
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
1236
|
+
case "serif":
|
|
1237
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
1238
|
+
case "mono":
|
|
1239
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1240
|
+
default:
|
|
1241
|
+
return null;
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
417
1244
|
|
|
418
|
-
// src/
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
1245
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1246
|
+
function nativeShadowValue(key) {
|
|
1247
|
+
switch (key) {
|
|
1248
|
+
case "sm":
|
|
1249
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1250
|
+
case "DEFAULT":
|
|
1251
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1252
|
+
case "md":
|
|
1253
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1254
|
+
case "lg":
|
|
1255
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1256
|
+
case "xl":
|
|
1257
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1258
|
+
case "2xl":
|
|
1259
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1260
|
+
case "none":
|
|
1261
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1262
|
+
default:
|
|
1263
|
+
return null;
|
|
1264
|
+
}
|
|
1265
|
+
}
|
|
1266
|
+
function nativeShadowDeclarations(parsed) {
|
|
1267
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1268
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1269
|
+
const s = nativeShadowValue(key);
|
|
1270
|
+
if (s === null) return null;
|
|
1271
|
+
return [
|
|
1272
|
+
decl("shadow-color", "#000000"),
|
|
1273
|
+
decl("shadow-offset-x", "0"),
|
|
1274
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1275
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1276
|
+
decl("shadow-radius", String(s.radius)),
|
|
1277
|
+
decl("elevation", String(s.elevation))
|
|
1278
|
+
];
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
// src/jsEngine/resolvers/transform.ts
|
|
1282
|
+
function scaleFactor(parsed) {
|
|
1283
|
+
if (parsed.value === null) return null;
|
|
1284
|
+
const n = Number(parsed.value);
|
|
1285
|
+
if (!Number.isFinite(n)) return null;
|
|
1286
|
+
return parsed.isArbitrary ? n : n / 100;
|
|
1287
|
+
}
|
|
1288
|
+
function angle(parsed) {
|
|
1289
|
+
if (parsed.value === null) return null;
|
|
1290
|
+
if (parsed.isArbitrary) return parsed.value;
|
|
1291
|
+
const n = Number(parsed.value);
|
|
1292
|
+
if (!Number.isFinite(n)) return null;
|
|
1293
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
1294
|
+
}
|
|
1295
|
+
function resolveNative(parsed, theme) {
|
|
1296
|
+
switch (parsed.utility) {
|
|
1297
|
+
case "transform-none":
|
|
1298
|
+
return [decl("transform-op-none", "1")];
|
|
1299
|
+
case "backface-visible":
|
|
1300
|
+
return [decl("backface-visibility", "visible")];
|
|
1301
|
+
case "backface-hidden":
|
|
1302
|
+
return [decl("backface-visibility", "hidden")];
|
|
1303
|
+
case "translate-x": {
|
|
1304
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1305
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
1306
|
+
}
|
|
1307
|
+
case "translate-y": {
|
|
1308
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1309
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
1310
|
+
}
|
|
1311
|
+
case "scale": {
|
|
1312
|
+
const n = scaleFactor(parsed);
|
|
1313
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
1314
|
+
}
|
|
1315
|
+
case "scale-x": {
|
|
1316
|
+
const n = scaleFactor(parsed);
|
|
1317
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
1318
|
+
}
|
|
1319
|
+
case "scale-y": {
|
|
1320
|
+
const n = scaleFactor(parsed);
|
|
1321
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
1322
|
+
}
|
|
1323
|
+
case "rotate": {
|
|
1324
|
+
const deg = angle(parsed);
|
|
1325
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
1326
|
+
}
|
|
1327
|
+
case "rotate-x": {
|
|
1328
|
+
const deg = angle(parsed);
|
|
1329
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
1330
|
+
}
|
|
1331
|
+
case "rotate-y": {
|
|
1332
|
+
const deg = angle(parsed);
|
|
1333
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
1334
|
+
}
|
|
1335
|
+
case "rotate-z": {
|
|
1336
|
+
const deg = angle(parsed);
|
|
1337
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
1338
|
+
}
|
|
1339
|
+
case "skew-x": {
|
|
1340
|
+
const deg = angle(parsed);
|
|
1341
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
1342
|
+
}
|
|
1343
|
+
case "skew-y": {
|
|
1344
|
+
const deg = angle(parsed);
|
|
1345
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
1346
|
+
}
|
|
1347
|
+
default:
|
|
1348
|
+
return null;
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1352
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1353
|
+
function firstFontName(stack) {
|
|
1354
|
+
const first = stack.split(",")[0] ?? stack;
|
|
1355
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
1356
|
+
}
|
|
1357
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1358
|
+
switch (parsed.utility) {
|
|
1359
|
+
case "font": {
|
|
1360
|
+
if (parsed.value === null) return null;
|
|
1361
|
+
if (parsed.isArbitrary) {
|
|
1362
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
1363
|
+
}
|
|
1364
|
+
const w = fontWeight(parsed.value);
|
|
1365
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
1366
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
1367
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1368
|
+
}
|
|
1369
|
+
case "uppercase":
|
|
1370
|
+
return [decl("text-transform", "uppercase")];
|
|
1371
|
+
case "lowercase":
|
|
1372
|
+
return [decl("text-transform", "lowercase")];
|
|
1373
|
+
case "capitalize":
|
|
1374
|
+
return [decl("text-transform", "capitalize")];
|
|
1375
|
+
case "underline":
|
|
1376
|
+
return [decl("text-decoration-line", "underline")];
|
|
1377
|
+
case "line-through":
|
|
1378
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1379
|
+
case "no-underline":
|
|
1380
|
+
return [decl("text-decoration-line", "none")];
|
|
1381
|
+
case "italic":
|
|
1382
|
+
return [decl("font-style", "italic")];
|
|
1383
|
+
case "not-italic":
|
|
1384
|
+
return [decl("font-style", "normal")];
|
|
1385
|
+
default:
|
|
1386
|
+
return null;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1390
|
+
const value = parsed.value;
|
|
1391
|
+
if (value === null) return null;
|
|
1392
|
+
if (parsed.utility === "leading") {
|
|
1393
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1394
|
+
const v = lineHeightSize(value);
|
|
1395
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1396
|
+
}
|
|
1397
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1398
|
+
return [decl("letter-spacing", value)];
|
|
1399
|
+
}
|
|
1400
|
+
return null;
|
|
1401
|
+
}
|
|
1402
|
+
function nativeHexColor(parsed, theme) {
|
|
1403
|
+
return colorValue(theme, parsed);
|
|
1404
|
+
}
|
|
1405
|
+
function resolveTextNative(parsed, theme) {
|
|
1406
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1407
|
+
const size = textSize(parsed.value);
|
|
1408
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1409
|
+
const align = textAlign(parsed.value);
|
|
1410
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1411
|
+
}
|
|
1412
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1413
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1414
|
+
}
|
|
1415
|
+
function resolveColorNative(parsed, theme) {
|
|
1416
|
+
switch (parsed.utility) {
|
|
1417
|
+
case "bg": {
|
|
1418
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1419
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1420
|
+
}
|
|
1421
|
+
case "text":
|
|
1422
|
+
return resolveTextNative(parsed, theme);
|
|
1423
|
+
default:
|
|
1424
|
+
return null;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
function resolveOpacityNative(parsed) {
|
|
1428
|
+
if (parsed.utility !== "opacity") return null;
|
|
1429
|
+
const v = resolvePercent(parsed);
|
|
1430
|
+
return v === null ? null : [decl("opacity", v)];
|
|
1431
|
+
}
|
|
1432
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1433
|
+
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed, theme) ?? resolveOpacityNative(parsed) ?? nativeShadowDeclarations(parsed) ?? resolveNative(parsed, theme);
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
// src/jsEngine/calc.ts
|
|
1437
|
+
function reduceConstantMath(raw) {
|
|
1438
|
+
const trimmed = raw.trim();
|
|
1439
|
+
const calc = stripCall(trimmed, "calc");
|
|
1440
|
+
if (calc !== null) {
|
|
1441
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
1442
|
+
}
|
|
1443
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
1444
|
+
if (clamp !== null) {
|
|
1445
|
+
const args = splitTopLevelCommas(clamp);
|
|
1446
|
+
if (args.length !== 3) return null;
|
|
1447
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
1448
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
1449
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
1450
|
+
}
|
|
1451
|
+
const min = stripCall(trimmed, "min");
|
|
1452
|
+
if (min !== null) {
|
|
1453
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1454
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
1455
|
+
}
|
|
1456
|
+
const max = stripCall(trimmed, "max");
|
|
1457
|
+
if (max !== null) {
|
|
1458
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1459
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
1460
|
+
}
|
|
1461
|
+
return null;
|
|
1462
|
+
}
|
|
1463
|
+
function stripCall(raw, name) {
|
|
1464
|
+
if (!raw.startsWith(name)) return null;
|
|
1465
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
1466
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
1467
|
+
return afterName.slice(1, -1);
|
|
1468
|
+
}
|
|
1469
|
+
function splitTopLevelCommas(s) {
|
|
1470
|
+
const parts = [];
|
|
1471
|
+
let depth = 0;
|
|
1472
|
+
let start = 0;
|
|
1473
|
+
for (let i = 0; i < s.length; i++) {
|
|
1474
|
+
const ch = s[i];
|
|
1475
|
+
if (ch === "(") depth++;
|
|
1476
|
+
else if (ch === ")") depth--;
|
|
1477
|
+
else if (ch === "," && depth === 0) {
|
|
1478
|
+
parts.push(s.slice(start, i).trim());
|
|
1479
|
+
start = i + 1;
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
parts.push(s.slice(start).trim());
|
|
1483
|
+
return parts;
|
|
1484
|
+
}
|
|
1485
|
+
var Evaluator = class {
|
|
1486
|
+
constructor(s) {
|
|
1487
|
+
this.pos = 0;
|
|
1488
|
+
this.s = s;
|
|
1489
|
+
}
|
|
1490
|
+
parseExprToEnd() {
|
|
1491
|
+
const value = this.expr();
|
|
1492
|
+
if (value === null) return null;
|
|
1493
|
+
this.skipWs();
|
|
1494
|
+
return this.pos === this.s.length ? value : null;
|
|
1495
|
+
}
|
|
1496
|
+
skipWs() {
|
|
1497
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
1498
|
+
}
|
|
1499
|
+
peek() {
|
|
1500
|
+
this.skipWs();
|
|
1501
|
+
return this.s[this.pos];
|
|
1502
|
+
}
|
|
1503
|
+
expr() {
|
|
1504
|
+
let value = this.term();
|
|
1505
|
+
if (value === null) return null;
|
|
1506
|
+
for (; ; ) {
|
|
1507
|
+
const ch = this.peek();
|
|
1508
|
+
if (ch === "+") {
|
|
1509
|
+
this.pos++;
|
|
1510
|
+
const rhs = this.term();
|
|
1511
|
+
if (rhs === null) return null;
|
|
1512
|
+
value += rhs;
|
|
1513
|
+
} else if (ch === "-") {
|
|
1514
|
+
this.pos++;
|
|
1515
|
+
const rhs = this.term();
|
|
1516
|
+
if (rhs === null) return null;
|
|
1517
|
+
value -= rhs;
|
|
1518
|
+
} else {
|
|
1519
|
+
return value;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
term() {
|
|
1524
|
+
let value = this.factor();
|
|
1525
|
+
if (value === null) return null;
|
|
1526
|
+
for (; ; ) {
|
|
1527
|
+
const ch = this.peek();
|
|
1528
|
+
if (ch === "*") {
|
|
1529
|
+
this.pos++;
|
|
1530
|
+
const rhs = this.factor();
|
|
1531
|
+
if (rhs === null) return null;
|
|
1532
|
+
value *= rhs;
|
|
1533
|
+
} else if (ch === "/") {
|
|
1534
|
+
this.pos++;
|
|
1535
|
+
const divisor = this.factor();
|
|
1536
|
+
if (divisor === null || divisor === 0) return null;
|
|
1537
|
+
value /= divisor;
|
|
1538
|
+
} else {
|
|
1539
|
+
return value;
|
|
1540
|
+
}
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
factor() {
|
|
1544
|
+
const ch = this.peek();
|
|
1545
|
+
if (ch === void 0) return null;
|
|
1546
|
+
if (ch === "(") {
|
|
1547
|
+
this.pos++;
|
|
1548
|
+
const value = this.expr();
|
|
1549
|
+
if (value === null || this.peek() !== ")") return null;
|
|
1550
|
+
this.pos++;
|
|
1551
|
+
return value;
|
|
1552
|
+
}
|
|
1553
|
+
if (ch === "-") {
|
|
1554
|
+
this.pos++;
|
|
1555
|
+
const value = this.factor();
|
|
1556
|
+
return value === null ? null : -value;
|
|
1557
|
+
}
|
|
1558
|
+
return this.numberWithUnit();
|
|
1559
|
+
}
|
|
1560
|
+
numberWithUnit() {
|
|
1561
|
+
this.skipWs();
|
|
1562
|
+
const start = this.pos;
|
|
1563
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
1564
|
+
if (this.pos === start) return null;
|
|
1565
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
1566
|
+
if (!Number.isFinite(n)) return null;
|
|
1567
|
+
const unitStart = this.pos;
|
|
1568
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
1569
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
1570
|
+
switch (unit) {
|
|
1571
|
+
case "":
|
|
1572
|
+
return n;
|
|
1573
|
+
case "px":
|
|
1574
|
+
return n;
|
|
1575
|
+
case "rem":
|
|
1576
|
+
return n * 16;
|
|
1577
|
+
default:
|
|
1578
|
+
return null;
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
|
+
// src/jsEngine/resolveStyle.ts
|
|
1584
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1585
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1586
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1587
|
+
if (modifier === "active") return pressed;
|
|
1588
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1589
|
+
const minWidth = theme.screens[modifier];
|
|
1590
|
+
if (minWidth === void 0) return null;
|
|
1591
|
+
return width >= minWidth;
|
|
1592
|
+
}
|
|
1593
|
+
if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
|
|
1594
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1595
|
+
return px === null ? null : width >= px;
|
|
1596
|
+
}
|
|
1597
|
+
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
1598
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1599
|
+
return px === null ? null : width <= px;
|
|
1600
|
+
}
|
|
1601
|
+
return null;
|
|
1602
|
+
}
|
|
1603
|
+
function kebabToCamel(s) {
|
|
1604
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1605
|
+
}
|
|
1606
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1607
|
+
"padding",
|
|
1608
|
+
"padding-top",
|
|
1609
|
+
"padding-right",
|
|
1610
|
+
"padding-bottom",
|
|
1611
|
+
"padding-left",
|
|
1612
|
+
"margin",
|
|
1613
|
+
"margin-top",
|
|
1614
|
+
"margin-right",
|
|
1615
|
+
"margin-bottom",
|
|
1616
|
+
"margin-left",
|
|
1617
|
+
"gap",
|
|
1618
|
+
"column-gap",
|
|
1619
|
+
"row-gap",
|
|
1620
|
+
"width",
|
|
1621
|
+
"height",
|
|
1622
|
+
"min-width",
|
|
1623
|
+
"max-width",
|
|
1624
|
+
"min-height",
|
|
1625
|
+
"max-height",
|
|
1626
|
+
"top",
|
|
1627
|
+
"right",
|
|
1628
|
+
"bottom",
|
|
1629
|
+
"left",
|
|
1630
|
+
"inset",
|
|
1631
|
+
"border-radius",
|
|
1632
|
+
"border-width",
|
|
1633
|
+
"font-size",
|
|
1634
|
+
"z-index",
|
|
1635
|
+
"line-height",
|
|
1636
|
+
"letter-spacing",
|
|
1637
|
+
"flex",
|
|
1638
|
+
"flex-grow",
|
|
1639
|
+
"flex-shrink",
|
|
1640
|
+
"order",
|
|
1641
|
+
"flex-basis",
|
|
1642
|
+
"shadow-opacity",
|
|
1643
|
+
"shadow-radius",
|
|
1644
|
+
"elevation",
|
|
1645
|
+
"opacity",
|
|
1646
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1647
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1648
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1649
|
+
// "border-width"/"border-radius" forms above.
|
|
1650
|
+
"border-top-width",
|
|
1651
|
+
"border-right-width",
|
|
1652
|
+
"border-bottom-width",
|
|
1653
|
+
"border-left-width",
|
|
1654
|
+
"border-top-left-radius",
|
|
1655
|
+
"border-top-right-radius",
|
|
1656
|
+
"border-bottom-right-radius",
|
|
1657
|
+
"border-bottom-left-radius",
|
|
1658
|
+
"outline-width",
|
|
1659
|
+
"outline-offset",
|
|
1660
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
1661
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
1662
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
1663
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
1664
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
1665
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
1666
|
+
// get collected into the final array.
|
|
1667
|
+
"transform-op-translate-x",
|
|
1668
|
+
"transform-op-translate-y",
|
|
1669
|
+
"transform-op-scale-x",
|
|
1670
|
+
"transform-op-scale-y"
|
|
1671
|
+
]);
|
|
1672
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
1673
|
+
["transform-op-translate-x", "translateX"],
|
|
1674
|
+
["transform-op-translate-y", "translateY"],
|
|
1675
|
+
["transform-op-rotate", "rotate"],
|
|
1676
|
+
["transform-op-rotate-x", "rotateX"],
|
|
1677
|
+
["transform-op-rotate-y", "rotateY"],
|
|
1678
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
1679
|
+
["transform-op-skew-x", "skewX"],
|
|
1680
|
+
["transform-op-skew-y", "skewY"],
|
|
1681
|
+
["transform-op-scale-x", "scaleX"],
|
|
1682
|
+
["transform-op-scale-y", "scaleY"]
|
|
1683
|
+
]);
|
|
1684
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
1685
|
+
function isPlainPercentage(value) {
|
|
1686
|
+
if (!value.endsWith("%")) return false;
|
|
1687
|
+
let digits = value.slice(0, -1);
|
|
1688
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
1689
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
1690
|
+
}
|
|
1691
|
+
function rnStyleValue(property, value) {
|
|
1692
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1693
|
+
return { value, warning: null };
|
|
1694
|
+
}
|
|
1695
|
+
let px = null;
|
|
1696
|
+
if (value.endsWith("px")) {
|
|
1697
|
+
const n = Number(value.slice(0, -2));
|
|
1698
|
+
px = Number.isFinite(n) ? n : null;
|
|
1699
|
+
} else if (value.endsWith("rem")) {
|
|
1700
|
+
const n = Number(value.slice(0, -3));
|
|
1701
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1702
|
+
} else {
|
|
1703
|
+
const n = Number(value);
|
|
1704
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1705
|
+
}
|
|
1706
|
+
if (px !== null) return { value: px, warning: null };
|
|
1707
|
+
if (isPlainPercentage(value)) {
|
|
1708
|
+
return { value, warning: null };
|
|
1709
|
+
}
|
|
1710
|
+
const reduced = reduceConstantMath(value);
|
|
1711
|
+
if (reduced !== null) {
|
|
1712
|
+
return { value: reduced, warning: null };
|
|
1713
|
+
}
|
|
1714
|
+
const warning = `[Kbach] "${value}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
1715
|
+
calc()/min()/max()/clamp() only resolve on native when every operand is a constant px/rem length (no %, vw, vh, var(), or other viewport/CSS-variable units \u2014 those need real layout/DOM, which doesn't exist on native at paint time).
|
|
1716
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
1717
|
+
return { value: null, warning };
|
|
1718
|
+
}
|
|
1719
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1720
|
+
const style = {};
|
|
1721
|
+
const warnings = [];
|
|
1722
|
+
let shadowOffset = null;
|
|
1723
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
1724
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1725
|
+
const parsed = parseClass(token);
|
|
1726
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1727
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
426
1728
|
);
|
|
1729
|
+
if (!allModifiersHold) continue;
|
|
1730
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1731
|
+
if (decls === null) continue;
|
|
1732
|
+
for (const d of decls) {
|
|
1733
|
+
if (d.property.startsWith("__")) {
|
|
1734
|
+
continue;
|
|
1735
|
+
}
|
|
1736
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1737
|
+
const n = Number(d.value);
|
|
1738
|
+
if (!Number.isFinite(n)) continue;
|
|
1739
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1740
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
if (d.property === "transform-op-none") {
|
|
1744
|
+
transformOps.clear();
|
|
1745
|
+
continue;
|
|
1746
|
+
}
|
|
1747
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
1748
|
+
if (opKey !== void 0) {
|
|
1749
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
1750
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
1751
|
+
if (value2 !== null) transformOps.set(opKey, value2);
|
|
1752
|
+
continue;
|
|
1753
|
+
}
|
|
1754
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
1755
|
+
if (warning !== null) warnings.push(warning);
|
|
1756
|
+
if (value !== null) style[kebabToCamel(d.property)] = value;
|
|
1757
|
+
}
|
|
1758
|
+
}
|
|
1759
|
+
if (shadowOffset !== null) {
|
|
1760
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1761
|
+
}
|
|
1762
|
+
if (transformOps.size > 0) {
|
|
1763
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
1764
|
+
[key]: transformOps.get(key)
|
|
1765
|
+
}));
|
|
1766
|
+
}
|
|
1767
|
+
return { style, warnings };
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
// src/nativeBridge.ts
|
|
1771
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
1772
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
1773
|
+
var cachedForThemeJson = null;
|
|
1774
|
+
function resolveStyle(classString, pressed = false) {
|
|
1775
|
+
const colorScheme = (0, import_darkModeStore.getGlobalDarkMode)() ? "dark" : "light";
|
|
1776
|
+
const width = import_react_native.Dimensions.get("window").width;
|
|
1777
|
+
const themeJson = (0, import_theme.getThemeJson)();
|
|
1778
|
+
if (themeJson !== cachedForThemeJson) {
|
|
1779
|
+
resolveStyleCache.clear();
|
|
1780
|
+
cachedForThemeJson = themeJson;
|
|
1781
|
+
}
|
|
1782
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
1783
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
1784
|
+
if (cached !== void 0) return { ...cached };
|
|
1785
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
1786
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
1787
|
+
resolveStyleCache.set(cacheKey, style);
|
|
1788
|
+
return { ...style };
|
|
1789
|
+
}
|
|
1790
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
1791
|
+
const KbachModule = import_react_native.TurboModuleRegistry.get("KbachModule");
|
|
1792
|
+
if (!KbachModule) {
|
|
1793
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
|
|
1794
|
+
warnIfDev(classString, warnings2);
|
|
1795
|
+
return style2;
|
|
1796
|
+
}
|
|
1797
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
1798
|
+
const style = JSON.parse(json);
|
|
1799
|
+
const warnings = style.__kbachWarnings;
|
|
1800
|
+
if (warnings !== void 0) {
|
|
1801
|
+
delete style.__kbachWarnings;
|
|
1802
|
+
warnIfDev(classString, warnings);
|
|
1803
|
+
}
|
|
1804
|
+
return style;
|
|
1805
|
+
}
|
|
1806
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
1807
|
+
function warnIfDev(classString, warnings) {
|
|
1808
|
+
if (warnings.length === 0) return;
|
|
1809
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
1810
|
+
for (const warning of warnings) {
|
|
1811
|
+
const message = `${warning}
|
|
1812
|
+
From className: "${classString}"`;
|
|
1813
|
+
if (warnedMessages.has(message)) continue;
|
|
1814
|
+
warnedMessages.add(message);
|
|
1815
|
+
console.warn(message);
|
|
427
1816
|
}
|
|
428
|
-
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
// src/config.ts
|
|
1820
|
+
var import_theme2 = require("./theme");
|
|
1821
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1822
|
+
function parseHexRgb(hex) {
|
|
1823
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1824
|
+
if (!m) return null;
|
|
1825
|
+
let h = m[1];
|
|
1826
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1827
|
+
const n = parseInt(h, 16);
|
|
1828
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1829
|
+
}
|
|
1830
|
+
function applyOpacityToHex(hex, opacityText) {
|
|
1831
|
+
const rgb = parseHexRgb(hex);
|
|
1832
|
+
if (!rgb) return hex;
|
|
1833
|
+
const a = Number(opacityText) / 100;
|
|
1834
|
+
const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
|
|
1835
|
+
return `rgba(${rgb.join(",")},${clamped})`;
|
|
1836
|
+
}
|
|
1837
|
+
function resolveColorEntry(value, lookup) {
|
|
1838
|
+
const slash = value.indexOf("/");
|
|
1839
|
+
const name = slash === -1 ? value : value.slice(0, slash);
|
|
1840
|
+
const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
|
|
1841
|
+
const base = lookup(name);
|
|
1842
|
+
if (base === void 0) return value;
|
|
1843
|
+
return opacity === void 0 ? base : applyOpacityToHex(base, opacity);
|
|
1844
|
+
}
|
|
1845
|
+
function resolveColors(extend, existing) {
|
|
1846
|
+
const resolved = {};
|
|
1847
|
+
const lookup = (name) => {
|
|
1848
|
+
const found = resolved[name] ?? existing[name];
|
|
1849
|
+
return typeof found === "string" ? found : void 0;
|
|
1850
|
+
};
|
|
1851
|
+
for (const [name, value] of Object.entries(extend)) {
|
|
1852
|
+
resolved[name] = resolveColorEntry(value, lookup);
|
|
1853
|
+
}
|
|
1854
|
+
return resolved;
|
|
1855
|
+
}
|
|
1856
|
+
function resolveKbachConfig(config) {
|
|
1857
|
+
let theme = { ...import_theme2.defaultTheme, ...config.theme };
|
|
1858
|
+
if (config.extend?.colors) {
|
|
1859
|
+
theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
|
|
1860
|
+
}
|
|
1861
|
+
if (config.extend?.spacing) {
|
|
1862
|
+
theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
|
|
1863
|
+
}
|
|
1864
|
+
if (config.extend?.screens) {
|
|
1865
|
+
theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
|
|
1866
|
+
}
|
|
1867
|
+
if (config.extend?.fontFamily) {
|
|
1868
|
+
theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
|
|
1869
|
+
}
|
|
1870
|
+
if (config.extend?.container) {
|
|
1871
|
+
theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
|
|
1872
|
+
}
|
|
1873
|
+
if (config.darkMode) {
|
|
1874
|
+
theme = { ...theme, darkMode: config.darkMode };
|
|
1875
|
+
}
|
|
1876
|
+
return theme;
|
|
1877
|
+
}
|
|
1878
|
+
function applyKbachConfig(config) {
|
|
1879
|
+
const theme = resolveKbachConfig(config);
|
|
1880
|
+
(0, import_theme2.setTheme)(theme);
|
|
1881
|
+
(0, import_darkModeStore2.resyncDomWithActiveTheme)();
|
|
1882
|
+
return theme;
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// src/useTheme.ts
|
|
1886
|
+
var import_react = require("react");
|
|
1887
|
+
var import_darkModeStore3 = require("./darkModeStore");
|
|
1888
|
+
function useTheme() {
|
|
1889
|
+
const isDark = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalDarkMode);
|
|
1890
|
+
const mode = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalThemeMode);
|
|
1891
|
+
return (0, import_react.useMemo)(
|
|
1892
|
+
() => ({ mode, isDark, setMode: import_darkModeStore3.setGlobalThemeMode, toggle: import_darkModeStore3.toggleGlobalDarkMode }),
|
|
1893
|
+
[mode, isDark]
|
|
1894
|
+
);
|
|
429
1895
|
}
|
|
430
1896
|
|
|
431
1897
|
// src/ThemeProvider.tsx
|
|
1898
|
+
var import_react2 = require("react");
|
|
1899
|
+
var import_darkModeStore4 = require("./darkModeStore");
|
|
432
1900
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1901
|
+
var PERSIST_STORAGE_KEY = "kbach-theme";
|
|
1902
|
+
function isThemeMode(value) {
|
|
1903
|
+
return value === "light" || value === "dark" || value === "system";
|
|
1904
|
+
}
|
|
433
1905
|
var mountedProviderCount = 0;
|
|
434
1906
|
var warnedMultipleProviders = false;
|
|
435
|
-
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
436
|
-
(0,
|
|
1907
|
+
function ThemeProvider({ children, defaultMode = "system", persist = false }) {
|
|
1908
|
+
(0, import_react2.useEffect)(() => {
|
|
437
1909
|
mountedProviderCount++;
|
|
438
1910
|
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
439
1911
|
warnedMultipleProviders = true;
|
|
440
1912
|
console.warn(
|
|
441
|
-
"[
|
|
1913
|
+
"[Kbach] Multiple <ThemeProvider> instances are mounted at once.\nDark mode is one global store \u2014 useTheme() reads it everywhere, not scoped per provider \u2014 so their defaultMode/persist seeds will fight over the same state.\nMount exactly one <ThemeProvider>, as high in the tree as convenient."
|
|
442
1914
|
);
|
|
443
1915
|
}
|
|
444
1916
|
return () => {
|
|
445
1917
|
mountedProviderCount--;
|
|
446
1918
|
};
|
|
447
1919
|
}, []);
|
|
448
|
-
const seeded = (0,
|
|
449
|
-
(0,
|
|
1920
|
+
const seeded = (0, import_react2.useRef)(false);
|
|
1921
|
+
(0, import_react2.useEffect)(() => {
|
|
450
1922
|
if (seeded.current) return;
|
|
451
1923
|
seeded.current = true;
|
|
452
|
-
|
|
1924
|
+
if (!persist) {
|
|
1925
|
+
(0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
1926
|
+
return;
|
|
1927
|
+
}
|
|
1928
|
+
let cancelled = false;
|
|
1929
|
+
persist.getItem(PERSIST_STORAGE_KEY).then((stored) => {
|
|
1930
|
+
if (cancelled) return;
|
|
1931
|
+
if (isThemeMode(stored)) (0, import_darkModeStore4.seedDefaultMode)(stored);
|
|
1932
|
+
else (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
1933
|
+
}).catch(() => {
|
|
1934
|
+
if (!cancelled) (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
1935
|
+
});
|
|
1936
|
+
return () => {
|
|
1937
|
+
cancelled = true;
|
|
1938
|
+
};
|
|
453
1939
|
}, []);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
1940
|
+
(0, import_react2.useEffect)(() => {
|
|
1941
|
+
if (!persist) return;
|
|
1942
|
+
return (0, import_darkModeStore4.subscribeGlobalDarkMode)(() => {
|
|
1943
|
+
persist.setItem(PERSIST_STORAGE_KEY, (0, import_darkModeStore4.getGlobalThemeMode)()).catch(() => {
|
|
1944
|
+
});
|
|
1945
|
+
});
|
|
1946
|
+
}, [persist]);
|
|
1947
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
// src/index.ts
|
|
1951
|
+
var import_darkModeStore5 = require("./darkModeStore");
|
|
1952
|
+
|
|
1953
|
+
// src/useColors.ts
|
|
1954
|
+
var import_react3 = require("react");
|
|
1955
|
+
var import_theme3 = require("./theme");
|
|
1956
|
+
function parseHexRgb2(hex) {
|
|
1957
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1958
|
+
if (!m) return null;
|
|
1959
|
+
let h = m[1];
|
|
1960
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1961
|
+
const n = parseInt(h, 16);
|
|
1962
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1963
|
+
}
|
|
1964
|
+
function applyOpacity(color, opacity) {
|
|
1965
|
+
const a = Math.max(0, Math.min(1, opacity / 100));
|
|
1966
|
+
if (color.startsWith("#")) {
|
|
1967
|
+
const rgb = parseHexRgb2(color);
|
|
1968
|
+
return rgb ? `rgba(${rgb.join(",")},${a})` : color;
|
|
1969
|
+
}
|
|
1970
|
+
if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
|
|
1971
|
+
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
1972
|
+
return color;
|
|
1973
|
+
}
|
|
1974
|
+
function resolveEntry(entry, isDark) {
|
|
1975
|
+
return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
|
|
1976
|
+
}
|
|
1977
|
+
function makeColorsProxy(theme, isDark) {
|
|
1978
|
+
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
1979
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1980
|
+
function resolveNamed(key) {
|
|
1981
|
+
let name = key;
|
|
1982
|
+
let opacity;
|
|
1983
|
+
if (key.includes("/")) {
|
|
1984
|
+
const slash = key.indexOf("/");
|
|
1985
|
+
name = key.slice(0, slash);
|
|
1986
|
+
opacity = Number(key.slice(slash + 1));
|
|
1987
|
+
}
|
|
1988
|
+
const entry = theme.colors[name];
|
|
1989
|
+
if (entry === void 0) return void 0;
|
|
1990
|
+
const value = resolveEntry(entry, isDark);
|
|
1991
|
+
return opacity === void 0 ? value : applyOpacity(value, opacity);
|
|
1992
|
+
}
|
|
1993
|
+
function makeFamilyProxy(family) {
|
|
1994
|
+
return new Proxy({}, {
|
|
1995
|
+
get(_, prop) {
|
|
1996
|
+
const key = String(prop);
|
|
1997
|
+
if (key === "then") return void 0;
|
|
1998
|
+
return resolveNamed(`${family}-${key}`);
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
}
|
|
2002
|
+
return new Proxy({ alpha }, {
|
|
2003
|
+
get(_, prop) {
|
|
2004
|
+
const key = String(prop);
|
|
2005
|
+
if (key === "then") return void 0;
|
|
2006
|
+
if (key === "alpha") return alpha;
|
|
2007
|
+
const direct = resolveNamed(key);
|
|
2008
|
+
if (direct !== void 0) return direct;
|
|
2009
|
+
if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
|
|
2010
|
+
return cache.get(key);
|
|
2011
|
+
}
|
|
2012
|
+
});
|
|
2013
|
+
}
|
|
2014
|
+
function useColors() {
|
|
2015
|
+
const { isDark } = useTheme();
|
|
2016
|
+
const theme = (0, import_theme3.getTheme)();
|
|
2017
|
+
return (0, import_react3.useMemo)(() => makeColorsProxy(theme, isDark), [theme, isDark]);
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
// src/index.ts
|
|
2021
|
+
var import_dynamicTokens2 = require("./dynamicTokens");
|
|
2022
|
+
|
|
2023
|
+
// src/useDynamicToken.ts
|
|
2024
|
+
var import_react4 = require("react");
|
|
2025
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
2026
|
+
function useDynamicToken(name) {
|
|
2027
|
+
return (0, import_react4.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
// src/clsx.ts
|
|
2031
|
+
function clsx(...inputs) {
|
|
2032
|
+
let out = "";
|
|
2033
|
+
for (const input of inputs) {
|
|
2034
|
+
const piece = resolveClassValue(input);
|
|
2035
|
+
if (piece) out = out ? `${out} ${piece}` : piece;
|
|
2036
|
+
}
|
|
2037
|
+
return out;
|
|
2038
|
+
}
|
|
2039
|
+
function resolveClassValue(value) {
|
|
2040
|
+
if (!value) return "";
|
|
2041
|
+
const type = typeof value;
|
|
2042
|
+
if (type === "string" || type === "number" || type === "bigint") return String(value);
|
|
2043
|
+
if (Array.isArray(value)) return clsx(...value);
|
|
2044
|
+
if (type === "object") {
|
|
2045
|
+
let out = "";
|
|
2046
|
+
for (const key in value) {
|
|
2047
|
+
if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
|
|
2048
|
+
out = out ? `${out} ${key}` : key;
|
|
2049
|
+
}
|
|
2050
|
+
}
|
|
2051
|
+
return out;
|
|
2052
|
+
}
|
|
2053
|
+
return "";
|
|
461
2054
|
}
|
|
462
2055
|
// Annotate the CommonJS export names for ESM import in node:
|
|
463
2056
|
0 && (module.exports = {
|
|
464
2057
|
ThemeProvider,
|
|
2058
|
+
applyKbachConfig,
|
|
2059
|
+
clsx,
|
|
465
2060
|
defaultTheme,
|
|
2061
|
+
deleteDynamicToken,
|
|
2062
|
+
getDynamicToken,
|
|
466
2063
|
getGlobalDarkMode,
|
|
467
2064
|
getGlobalThemeMode,
|
|
468
2065
|
getTheme,
|
|
2066
|
+
resolveKbachConfig,
|
|
469
2067
|
resolveStyle,
|
|
2068
|
+
setDynamicToken,
|
|
470
2069
|
setGlobalThemeMode,
|
|
471
2070
|
setTheme,
|
|
2071
|
+
subscribeDynamicTokens,
|
|
472
2072
|
subscribeGlobalDarkMode,
|
|
473
2073
|
toggleGlobalDarkMode,
|
|
474
|
-
|
|
2074
|
+
useColors,
|
|
2075
|
+
useDynamicToken,
|
|
475
2076
|
useTheme
|
|
476
2077
|
});
|