@kbach/react-native 1.0.0-beta.3 → 1.0.0-beta.30
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-DDNGWPS4.mjs +564 -0
- package/dist/chunk-LOTFFRZP.mjs +112 -0
- package/dist/chunk-UJYEYY6S.mjs +40 -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 +1929 -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 +1941 -351
- 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 +1932 -343
- 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,1992 @@ 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 splitRespectingBrackets(token) {
|
|
227
|
+
const parts = [];
|
|
228
|
+
let depth = 0;
|
|
229
|
+
let start = 0;
|
|
230
|
+
for (let i = 0; i < token.length; i++) {
|
|
231
|
+
const ch = token[i];
|
|
232
|
+
if (ch === "[") depth += 1;
|
|
233
|
+
else if (ch === "]") depth -= 1;
|
|
234
|
+
else if (ch === ":" && depth <= 0) {
|
|
235
|
+
parts.push(token.slice(start, i));
|
|
236
|
+
start = i + 1;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
parts.push(token.slice(start));
|
|
240
|
+
return parts;
|
|
346
241
|
}
|
|
347
|
-
function
|
|
348
|
-
|
|
242
|
+
function parseClass(token) {
|
|
243
|
+
const parts = splitRespectingBrackets(token);
|
|
244
|
+
let base = parts.pop() ?? token;
|
|
245
|
+
const modifiers = parts;
|
|
246
|
+
const important = base.startsWith("!");
|
|
247
|
+
if (important) {
|
|
248
|
+
base = base.slice(1);
|
|
249
|
+
}
|
|
250
|
+
const negative = base.startsWith("-");
|
|
251
|
+
if (negative) {
|
|
252
|
+
base = base.slice(1);
|
|
253
|
+
}
|
|
254
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
255
|
+
const raw = base.slice(1, -1);
|
|
256
|
+
const colonIdx = raw.indexOf(":");
|
|
257
|
+
if (colonIdx !== -1) {
|
|
258
|
+
const property = raw.slice(0, colonIdx);
|
|
259
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
260
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
261
|
+
const value = rawValue.replace(/_/g, " ");
|
|
262
|
+
return {
|
|
263
|
+
modifiers,
|
|
264
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
265
|
+
value: `${property}:${value}`,
|
|
266
|
+
isArbitrary: true,
|
|
267
|
+
important,
|
|
268
|
+
negative,
|
|
269
|
+
original: token
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
275
|
+
if (!base.startsWith(prefix)) continue;
|
|
276
|
+
const value = base.slice(prefix.length);
|
|
277
|
+
if (value === "") continue;
|
|
278
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
279
|
+
const raw = value.slice(1, -1);
|
|
280
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const spaced = raw.replace(/_/g, " ");
|
|
284
|
+
return {
|
|
285
|
+
modifiers,
|
|
286
|
+
utility: prefix.slice(0, -1),
|
|
287
|
+
value: spaced,
|
|
288
|
+
isArbitrary: true,
|
|
289
|
+
important,
|
|
290
|
+
negative,
|
|
291
|
+
original: token
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
modifiers,
|
|
296
|
+
utility: prefix.slice(0, -1),
|
|
297
|
+
value,
|
|
298
|
+
isArbitrary: false,
|
|
299
|
+
important,
|
|
300
|
+
negative,
|
|
301
|
+
original: token
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
return {
|
|
305
|
+
modifiers,
|
|
306
|
+
utility: base,
|
|
307
|
+
value: null,
|
|
308
|
+
isArbitrary: false,
|
|
309
|
+
important,
|
|
310
|
+
negative,
|
|
311
|
+
original: token
|
|
312
|
+
};
|
|
349
313
|
}
|
|
350
314
|
|
|
351
|
-
// src/
|
|
352
|
-
|
|
315
|
+
// src/jsEngine/shared.ts
|
|
316
|
+
function decl(property, value) {
|
|
317
|
+
return { property, value };
|
|
318
|
+
}
|
|
319
|
+
function spacingPx(theme, value) {
|
|
320
|
+
const fromTable = theme.spacing[value];
|
|
321
|
+
if (fromTable !== void 0) return fromTable;
|
|
322
|
+
const n = Number(value);
|
|
323
|
+
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
324
|
+
}
|
|
325
|
+
function resolveLength(theme, parsed) {
|
|
326
|
+
if (parsed.negative) return null;
|
|
327
|
+
const value = parsed.value;
|
|
328
|
+
if (value === null) return null;
|
|
329
|
+
if (parsed.isArbitrary) return value;
|
|
330
|
+
if (value === "full") return "100%";
|
|
331
|
+
if (value === "auto") return "auto";
|
|
332
|
+
const px = spacingPx(theme, value);
|
|
333
|
+
return px === void 0 ? null : `${px}px`;
|
|
334
|
+
}
|
|
335
|
+
function resolveNegatableLength(theme, parsed) {
|
|
336
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
337
|
+
if (parsed.isArbitrary) {
|
|
338
|
+
const value2 = parsed.value;
|
|
339
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
340
|
+
}
|
|
341
|
+
const value = parsed.value;
|
|
342
|
+
if (value === null) return null;
|
|
343
|
+
const px = spacingPx(theme, value);
|
|
344
|
+
if (px === void 0) return null;
|
|
345
|
+
if (px === 0) return "0px";
|
|
346
|
+
return `-${px}px`;
|
|
347
|
+
}
|
|
348
|
+
function fractionPercent(value) {
|
|
349
|
+
const slashIdx = value.indexOf("/");
|
|
350
|
+
if (slashIdx === -1) return null;
|
|
351
|
+
const numStr = value.slice(0, slashIdx);
|
|
352
|
+
const denStr = value.slice(slashIdx + 1);
|
|
353
|
+
const num = Number(numStr);
|
|
354
|
+
const den = Number(denStr);
|
|
355
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
356
|
+
if (den === 0) return null;
|
|
357
|
+
const pct = num / den * 100;
|
|
358
|
+
const formatted = pct.toFixed(6);
|
|
359
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
360
|
+
return `${trimmed}%`;
|
|
361
|
+
}
|
|
362
|
+
function resolveNegatableSize(theme, parsed) {
|
|
363
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
364
|
+
const pct = fractionPercent(parsed.value);
|
|
365
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
366
|
+
}
|
|
367
|
+
return resolveNegatableLength(theme, parsed);
|
|
368
|
+
}
|
|
369
|
+
function resolvePercent(parsed) {
|
|
370
|
+
if (parsed.negative) return null;
|
|
371
|
+
const value = parsed.value;
|
|
372
|
+
if (value === null) return null;
|
|
373
|
+
if (parsed.isArbitrary) return value;
|
|
374
|
+
const pct = Number(value);
|
|
375
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
376
|
+
return String(pct / 100);
|
|
377
|
+
}
|
|
353
378
|
|
|
354
|
-
// src/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
function systemPrefersDark() {
|
|
358
|
-
return import_react_native.Appearance.getColorScheme() === "dark";
|
|
359
|
-
}
|
|
360
|
-
function resolveIsDark(m) {
|
|
361
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
362
|
-
}
|
|
363
|
-
var mode = "system";
|
|
364
|
-
var isDark = resolveIsDark(mode);
|
|
365
|
-
var hasExplicitChoice = false;
|
|
366
|
-
var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
|
|
367
|
-
if (mode !== "system") return;
|
|
368
|
-
isDark = colorScheme === "dark";
|
|
369
|
-
notify();
|
|
370
|
-
});
|
|
371
|
-
function notify() {
|
|
372
|
-
for (const listener of listeners) listener();
|
|
379
|
+
// src/jsEngine/resolvers/layout.ts
|
|
380
|
+
function negateRaw(value, negative) {
|
|
381
|
+
return negative ? `-${value}` : value;
|
|
373
382
|
}
|
|
374
|
-
function
|
|
375
|
-
|
|
383
|
+
function overflowAxisValue(property, value) {
|
|
384
|
+
switch (value) {
|
|
385
|
+
case "auto":
|
|
386
|
+
case "hidden":
|
|
387
|
+
case "clip":
|
|
388
|
+
case "visible":
|
|
389
|
+
case "scroll":
|
|
390
|
+
return [decl(property, value)];
|
|
391
|
+
default:
|
|
392
|
+
return null;
|
|
393
|
+
}
|
|
376
394
|
}
|
|
377
|
-
function
|
|
378
|
-
|
|
395
|
+
function overscrollValue(property, value) {
|
|
396
|
+
switch (value) {
|
|
397
|
+
case "auto":
|
|
398
|
+
case "contain":
|
|
399
|
+
case "none":
|
|
400
|
+
return [decl(property, value)];
|
|
401
|
+
default:
|
|
402
|
+
return null;
|
|
403
|
+
}
|
|
379
404
|
}
|
|
380
|
-
function
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
405
|
+
function resolve(parsed, theme) {
|
|
406
|
+
switch (parsed.utility) {
|
|
407
|
+
case "flex":
|
|
408
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
409
|
+
case "grid":
|
|
410
|
+
return [decl("display", "grid")];
|
|
411
|
+
case "block":
|
|
412
|
+
return [decl("display", "block")];
|
|
413
|
+
case "inline-block":
|
|
414
|
+
return [decl("display", "inline-block")];
|
|
415
|
+
case "inline":
|
|
416
|
+
return [decl("display", "inline")];
|
|
417
|
+
case "inline-flex":
|
|
418
|
+
return [decl("display", "inline-flex")];
|
|
419
|
+
case "inline-grid":
|
|
420
|
+
return [decl("display", "inline-grid")];
|
|
421
|
+
case "contents":
|
|
422
|
+
return [decl("display", "contents")];
|
|
423
|
+
case "flow-root":
|
|
424
|
+
return [decl("display", "flow-root")];
|
|
425
|
+
case "hidden":
|
|
426
|
+
return [decl("display", "none")];
|
|
427
|
+
case "@container":
|
|
428
|
+
return [decl("container-type", "inline-size")];
|
|
429
|
+
case "items-center":
|
|
430
|
+
return [decl("align-items", "center")];
|
|
431
|
+
case "items-start":
|
|
432
|
+
return [decl("align-items", "flex-start")];
|
|
433
|
+
case "items-end":
|
|
434
|
+
return [decl("align-items", "flex-end")];
|
|
435
|
+
case "items-baseline":
|
|
436
|
+
return [decl("align-items", "baseline")];
|
|
437
|
+
case "items-stretch":
|
|
438
|
+
return [decl("align-items", "stretch")];
|
|
439
|
+
case "justify-center":
|
|
440
|
+
return [decl("justify-content", "center")];
|
|
441
|
+
case "justify-start":
|
|
442
|
+
return [decl("justify-content", "flex-start")];
|
|
443
|
+
case "justify-end":
|
|
444
|
+
return [decl("justify-content", "flex-end")];
|
|
445
|
+
case "justify-between":
|
|
446
|
+
return [decl("justify-content", "space-between")];
|
|
447
|
+
case "justify-around":
|
|
448
|
+
return [decl("justify-content", "space-around")];
|
|
449
|
+
case "justify-evenly":
|
|
450
|
+
return [decl("justify-content", "space-evenly")];
|
|
451
|
+
case "justify-normal":
|
|
452
|
+
return [decl("justify-content", "normal")];
|
|
453
|
+
case "justify-stretch":
|
|
454
|
+
return [decl("justify-content", "stretch")];
|
|
455
|
+
case "content-normal":
|
|
456
|
+
return [decl("align-content", "normal")];
|
|
457
|
+
case "content-start":
|
|
458
|
+
return [decl("align-content", "flex-start")];
|
|
459
|
+
case "content-end":
|
|
460
|
+
return [decl("align-content", "flex-end")];
|
|
461
|
+
case "content-center":
|
|
462
|
+
return [decl("align-content", "center")];
|
|
463
|
+
case "content-between":
|
|
464
|
+
return [decl("align-content", "space-between")];
|
|
465
|
+
case "content-around":
|
|
466
|
+
return [decl("align-content", "space-around")];
|
|
467
|
+
case "content-evenly":
|
|
468
|
+
return [decl("align-content", "space-evenly")];
|
|
469
|
+
case "content-stretch":
|
|
470
|
+
return [decl("align-content", "stretch")];
|
|
471
|
+
case "self-auto":
|
|
472
|
+
return [decl("align-self", "auto")];
|
|
473
|
+
case "self-center":
|
|
474
|
+
return [decl("align-self", "center")];
|
|
475
|
+
case "self-start":
|
|
476
|
+
return [decl("align-self", "flex-start")];
|
|
477
|
+
case "self-end":
|
|
478
|
+
return [decl("align-self", "flex-end")];
|
|
479
|
+
case "self-stretch":
|
|
480
|
+
return [decl("align-self", "stretch")];
|
|
481
|
+
case "self-baseline":
|
|
482
|
+
return [decl("align-self", "baseline")];
|
|
483
|
+
case "overflow-hidden":
|
|
484
|
+
return [decl("overflow", "hidden")];
|
|
485
|
+
case "overflow-auto":
|
|
486
|
+
return [decl("overflow", "auto")];
|
|
487
|
+
case "overflow-scroll":
|
|
488
|
+
return [decl("overflow", "scroll")];
|
|
489
|
+
case "overflow-visible":
|
|
490
|
+
return [decl("overflow", "visible")];
|
|
491
|
+
case "overflow-clip":
|
|
492
|
+
return [decl("overflow", "clip")];
|
|
493
|
+
case "overflow-x":
|
|
494
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
495
|
+
case "overflow-y":
|
|
496
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
497
|
+
case "overscroll":
|
|
498
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
499
|
+
case "overscroll-x":
|
|
500
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
501
|
+
case "overscroll-y":
|
|
502
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
503
|
+
case "static":
|
|
504
|
+
return [decl("position", "static")];
|
|
505
|
+
case "relative":
|
|
506
|
+
return [decl("position", "relative")];
|
|
507
|
+
case "absolute":
|
|
508
|
+
return [decl("position", "absolute")];
|
|
509
|
+
case "fixed":
|
|
510
|
+
return [decl("position", "fixed")];
|
|
511
|
+
case "sticky":
|
|
512
|
+
return [decl("position", "sticky")];
|
|
513
|
+
case "z":
|
|
514
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
515
|
+
case "order":
|
|
516
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
517
|
+
case "grow":
|
|
518
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
519
|
+
case "shrink":
|
|
520
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
521
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
522
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
523
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
524
|
+
case "top": {
|
|
525
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
526
|
+
return v === null ? null : [decl("top", v)];
|
|
527
|
+
}
|
|
528
|
+
case "right": {
|
|
529
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
530
|
+
return v === null ? null : [decl("right", v)];
|
|
531
|
+
}
|
|
532
|
+
case "bottom": {
|
|
533
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
534
|
+
return v === null ? null : [decl("bottom", v)];
|
|
535
|
+
}
|
|
536
|
+
case "left": {
|
|
537
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
538
|
+
return v === null ? null : [decl("left", v)];
|
|
539
|
+
}
|
|
540
|
+
case "inset": {
|
|
541
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
542
|
+
return v === null ? null : [decl("inset", v)];
|
|
543
|
+
}
|
|
544
|
+
case "inset-x": {
|
|
545
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
546
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
547
|
+
}
|
|
548
|
+
case "inset-y": {
|
|
549
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
550
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
551
|
+
}
|
|
552
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
553
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
554
|
+
case "start": {
|
|
555
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
556
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
557
|
+
}
|
|
558
|
+
case "end": {
|
|
559
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
560
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
561
|
+
}
|
|
562
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
563
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
564
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
565
|
+
// "aspect" arm.
|
|
566
|
+
case "aspect": {
|
|
567
|
+
const value = parsed.value;
|
|
568
|
+
if (value === null) return null;
|
|
569
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
570
|
+
switch (value) {
|
|
571
|
+
case "square":
|
|
572
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
573
|
+
case "video":
|
|
574
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
575
|
+
case "auto":
|
|
576
|
+
return [decl("aspect-ratio", "auto")];
|
|
577
|
+
default:
|
|
578
|
+
return null;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
default:
|
|
582
|
+
return null;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
function resolveFlex(parsed, web) {
|
|
586
|
+
if (parsed.utility !== "flex") return null;
|
|
587
|
+
const value = parsed.value;
|
|
588
|
+
if (value === null) return null;
|
|
589
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
590
|
+
switch (value) {
|
|
591
|
+
case "row":
|
|
592
|
+
return [decl("flex-direction", "row")];
|
|
593
|
+
case "col":
|
|
594
|
+
return [decl("flex-direction", "column")];
|
|
595
|
+
case "row-reverse":
|
|
596
|
+
return [decl("flex-direction", "row-reverse")];
|
|
597
|
+
case "col-reverse":
|
|
598
|
+
return [decl("flex-direction", "column-reverse")];
|
|
599
|
+
case "wrap":
|
|
600
|
+
return [decl("flex-wrap", "wrap")];
|
|
601
|
+
case "wrap-reverse":
|
|
602
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
603
|
+
case "nowrap":
|
|
604
|
+
return [decl("flex-wrap", "nowrap")];
|
|
605
|
+
case "1":
|
|
606
|
+
return [decl("flex", "1")];
|
|
607
|
+
case "auto":
|
|
608
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
609
|
+
case "initial":
|
|
610
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
611
|
+
case "none":
|
|
612
|
+
return [decl("flex", web ? "none" : "0")];
|
|
613
|
+
case "grow":
|
|
614
|
+
return [decl("flex-grow", "1")];
|
|
615
|
+
case "grow-0":
|
|
616
|
+
return [decl("flex-grow", "0")];
|
|
617
|
+
case "shrink":
|
|
618
|
+
return [decl("flex-shrink", "1")];
|
|
619
|
+
case "shrink-0":
|
|
620
|
+
return [decl("flex-shrink", "0")];
|
|
621
|
+
default:
|
|
622
|
+
return null;
|
|
623
|
+
}
|
|
385
624
|
}
|
|
386
|
-
|
|
387
|
-
|
|
625
|
+
|
|
626
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
627
|
+
function namedSize(key) {
|
|
628
|
+
switch (key) {
|
|
629
|
+
case "sm":
|
|
630
|
+
return "24rem";
|
|
631
|
+
case "md":
|
|
632
|
+
return "28rem";
|
|
633
|
+
case "lg":
|
|
634
|
+
return "32rem";
|
|
635
|
+
case "xl":
|
|
636
|
+
return "36rem";
|
|
637
|
+
case "2xl":
|
|
638
|
+
return "42rem";
|
|
639
|
+
case "3xl":
|
|
640
|
+
return "48rem";
|
|
641
|
+
case "4xl":
|
|
642
|
+
return "56rem";
|
|
643
|
+
case "5xl":
|
|
644
|
+
return "64rem";
|
|
645
|
+
case "6xl":
|
|
646
|
+
return "72rem";
|
|
647
|
+
case "7xl":
|
|
648
|
+
return "80rem";
|
|
649
|
+
case "8xl":
|
|
650
|
+
return "88rem";
|
|
651
|
+
case "9xl":
|
|
652
|
+
return "96rem";
|
|
653
|
+
default:
|
|
654
|
+
return null;
|
|
655
|
+
}
|
|
388
656
|
}
|
|
389
|
-
function
|
|
390
|
-
|
|
391
|
-
|
|
657
|
+
function cssSizeKeyword(key) {
|
|
658
|
+
switch (key) {
|
|
659
|
+
case "min":
|
|
660
|
+
return "min-content";
|
|
661
|
+
case "max":
|
|
662
|
+
return "max-content";
|
|
663
|
+
case "fit":
|
|
664
|
+
return "fit-content";
|
|
665
|
+
default:
|
|
666
|
+
return null;
|
|
667
|
+
}
|
|
392
668
|
}
|
|
393
|
-
function
|
|
394
|
-
if (
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
669
|
+
function resolveSize(theme, parsed) {
|
|
670
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
671
|
+
const named = namedSize(parsed.value);
|
|
672
|
+
if (named !== null) return named;
|
|
673
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
674
|
+
if (kw !== null) return kw;
|
|
675
|
+
const fraction = fractionPercent(parsed.value);
|
|
676
|
+
if (fraction !== null) return fraction;
|
|
677
|
+
}
|
|
678
|
+
return resolveLength(theme, parsed);
|
|
679
|
+
}
|
|
680
|
+
function resolve2(parsed, theme) {
|
|
681
|
+
const length = () => resolveLength(theme, parsed);
|
|
682
|
+
const size = () => resolveSize(theme, parsed);
|
|
683
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
684
|
+
switch (parsed.utility) {
|
|
685
|
+
case "p": {
|
|
686
|
+
const v = length();
|
|
687
|
+
return v === null ? null : [decl("padding", v)];
|
|
688
|
+
}
|
|
689
|
+
case "px": {
|
|
690
|
+
const v = length();
|
|
691
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
692
|
+
}
|
|
693
|
+
case "py": {
|
|
694
|
+
const v = length();
|
|
695
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
696
|
+
}
|
|
697
|
+
case "pt": {
|
|
698
|
+
const v = length();
|
|
699
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
700
|
+
}
|
|
701
|
+
case "pr": {
|
|
702
|
+
const v = length();
|
|
703
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
704
|
+
}
|
|
705
|
+
case "pb": {
|
|
706
|
+
const v = length();
|
|
707
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
708
|
+
}
|
|
709
|
+
case "pl": {
|
|
710
|
+
const v = length();
|
|
711
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
712
|
+
}
|
|
713
|
+
case "m": {
|
|
714
|
+
const v = negatableLength();
|
|
715
|
+
return v === null ? null : [decl("margin", v)];
|
|
716
|
+
}
|
|
717
|
+
case "mx": {
|
|
718
|
+
const v = negatableLength();
|
|
719
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
720
|
+
}
|
|
721
|
+
case "my": {
|
|
722
|
+
const v = negatableLength();
|
|
723
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
724
|
+
}
|
|
725
|
+
case "mt": {
|
|
726
|
+
const v = negatableLength();
|
|
727
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
728
|
+
}
|
|
729
|
+
case "mr": {
|
|
730
|
+
const v = negatableLength();
|
|
731
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
732
|
+
}
|
|
733
|
+
case "mb": {
|
|
734
|
+
const v = negatableLength();
|
|
735
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
736
|
+
}
|
|
737
|
+
case "ml": {
|
|
738
|
+
const v = negatableLength();
|
|
739
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
740
|
+
}
|
|
741
|
+
case "gap": {
|
|
742
|
+
const v = length();
|
|
743
|
+
return v === null ? null : [decl("gap", v)];
|
|
744
|
+
}
|
|
745
|
+
case "gap-x": {
|
|
746
|
+
const v = length();
|
|
747
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
748
|
+
}
|
|
749
|
+
case "gap-y": {
|
|
750
|
+
const v = length();
|
|
751
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
752
|
+
}
|
|
753
|
+
case "w": {
|
|
754
|
+
const v = size();
|
|
755
|
+
return v === null ? null : [decl("width", v)];
|
|
756
|
+
}
|
|
757
|
+
case "h": {
|
|
758
|
+
const v = size();
|
|
759
|
+
return v === null ? null : [decl("height", v)];
|
|
760
|
+
}
|
|
761
|
+
case "min-w": {
|
|
762
|
+
const v = size();
|
|
763
|
+
return v === null ? null : [decl("min-width", v)];
|
|
764
|
+
}
|
|
765
|
+
case "max-w": {
|
|
766
|
+
const v = size();
|
|
767
|
+
return v === null ? null : [decl("max-width", v)];
|
|
768
|
+
}
|
|
769
|
+
case "min-h": {
|
|
770
|
+
const v = size();
|
|
771
|
+
return v === null ? null : [decl("min-height", v)];
|
|
772
|
+
}
|
|
773
|
+
case "max-h": {
|
|
774
|
+
const v = size();
|
|
775
|
+
return v === null ? null : [decl("max-height", v)];
|
|
776
|
+
}
|
|
777
|
+
case "size": {
|
|
778
|
+
const v = size();
|
|
779
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
780
|
+
}
|
|
781
|
+
case "basis": {
|
|
782
|
+
const v = size();
|
|
783
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
784
|
+
}
|
|
785
|
+
default:
|
|
786
|
+
return null;
|
|
787
|
+
}
|
|
398
788
|
}
|
|
399
789
|
|
|
400
|
-
// src/
|
|
401
|
-
function
|
|
402
|
-
const
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
790
|
+
// src/jsEngine/resolvers/color.ts
|
|
791
|
+
function lookupHex(theme, key) {
|
|
792
|
+
const entry = theme.colors[key];
|
|
793
|
+
return typeof entry === "string" ? entry : null;
|
|
794
|
+
}
|
|
795
|
+
function hexToRgb(hex) {
|
|
796
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
797
|
+
if (!m) return null;
|
|
798
|
+
let h = m[1];
|
|
799
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
800
|
+
const n = parseInt(h, 16);
|
|
801
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
802
|
+
}
|
|
803
|
+
function splitOpacity(value) {
|
|
804
|
+
const slash = value.lastIndexOf("/");
|
|
805
|
+
if (slash === -1) return [value, null];
|
|
806
|
+
const opacityText = value.slice(slash + 1);
|
|
807
|
+
const n = Number(opacityText);
|
|
808
|
+
if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
|
|
809
|
+
return [value.slice(0, slash), n];
|
|
810
|
+
}
|
|
811
|
+
return [value, null];
|
|
812
|
+
}
|
|
813
|
+
function colorValue(theme, parsed) {
|
|
814
|
+
const value = parsed.value;
|
|
815
|
+
if (value === null) return null;
|
|
816
|
+
if (parsed.isArbitrary) return value;
|
|
817
|
+
const [name, opacity] = splitOpacity(value);
|
|
818
|
+
const hex = lookupHex(theme, name);
|
|
819
|
+
if (hex === null) return null;
|
|
820
|
+
if (opacity === null) return hex;
|
|
821
|
+
const rgb = hexToRgb(hex);
|
|
822
|
+
if (rgb === null) return hex;
|
|
823
|
+
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
407
824
|
}
|
|
408
825
|
|
|
409
|
-
// src/
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
826
|
+
// src/jsEngine/resolvers/border.ts
|
|
827
|
+
function radiusSize(key) {
|
|
828
|
+
switch (key) {
|
|
829
|
+
case "none":
|
|
830
|
+
return "0px";
|
|
831
|
+
case "sm":
|
|
832
|
+
return "0.125rem";
|
|
833
|
+
case "md":
|
|
834
|
+
return "0.375rem";
|
|
835
|
+
case "lg":
|
|
836
|
+
return "0.5rem";
|
|
837
|
+
case "xl":
|
|
838
|
+
return "0.75rem";
|
|
839
|
+
case "2xl":
|
|
840
|
+
return "1rem";
|
|
841
|
+
case "3xl":
|
|
842
|
+
return "1.5rem";
|
|
843
|
+
case "full":
|
|
844
|
+
return "9999px";
|
|
845
|
+
default:
|
|
846
|
+
return null;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
function borderSideProperty(side) {
|
|
850
|
+
switch (side) {
|
|
851
|
+
case "t":
|
|
852
|
+
return "border-top";
|
|
853
|
+
case "r":
|
|
854
|
+
return "border-right";
|
|
855
|
+
case "b":
|
|
856
|
+
return "border-bottom";
|
|
857
|
+
case "l":
|
|
858
|
+
return "border-left";
|
|
859
|
+
default:
|
|
860
|
+
return null;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
function borderValue(theme, parsed) {
|
|
864
|
+
const value = parsed.value;
|
|
865
|
+
if (value === null) return null;
|
|
866
|
+
if (!parsed.isArbitrary) {
|
|
867
|
+
const side = borderSideProperty(value);
|
|
868
|
+
if (side !== null) {
|
|
869
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
870
|
+
}
|
|
871
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
872
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
873
|
+
}
|
|
874
|
+
if (parsed.isArbitrary) {
|
|
875
|
+
return [decl("border-width", value)];
|
|
876
|
+
}
|
|
877
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
878
|
+
const v = resolveLength(theme, parsed);
|
|
879
|
+
return v === null ? null : [decl("border-width", v)];
|
|
880
|
+
}
|
|
881
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
882
|
+
return [decl("border-style", value)];
|
|
883
|
+
}
|
|
884
|
+
const color = colorValue(theme, parsed);
|
|
885
|
+
return color === null ? null : [decl("border-color", color)];
|
|
886
|
+
}
|
|
887
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
888
|
+
const value = parsed.value;
|
|
889
|
+
if (value === null) return null;
|
|
890
|
+
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
891
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
892
|
+
const v = resolveLength(theme, parsed);
|
|
893
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
894
|
+
}
|
|
895
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
896
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
897
|
+
}
|
|
898
|
+
const color = colorValue(theme, parsed);
|
|
899
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
900
|
+
}
|
|
901
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
902
|
+
const value = parsed.value;
|
|
903
|
+
if (value === null) return null;
|
|
904
|
+
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
905
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
906
|
+
const v = resolveLength(theme, parsed);
|
|
907
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
908
|
+
}
|
|
909
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
910
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
911
|
+
}
|
|
912
|
+
const color = colorValue(theme, parsed);
|
|
913
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
914
|
+
}
|
|
915
|
+
function radiusProperties(side) {
|
|
916
|
+
switch (side) {
|
|
917
|
+
case "t":
|
|
918
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
919
|
+
case "r":
|
|
920
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
921
|
+
case "b":
|
|
922
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
923
|
+
case "l":
|
|
924
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
925
|
+
case "tl":
|
|
926
|
+
return ["border-top-left-radius"];
|
|
927
|
+
case "tr":
|
|
928
|
+
return ["border-top-right-radius"];
|
|
929
|
+
case "br":
|
|
930
|
+
return ["border-bottom-right-radius"];
|
|
931
|
+
case "bl":
|
|
932
|
+
return ["border-bottom-left-radius"];
|
|
933
|
+
default:
|
|
934
|
+
return null;
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
function resolveRadiusValue(theme, parsed) {
|
|
938
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
939
|
+
const size = radiusSize(parsed.value);
|
|
940
|
+
if (size !== null) return size;
|
|
941
|
+
}
|
|
942
|
+
return resolveLength(theme, parsed);
|
|
943
|
+
}
|
|
944
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
945
|
+
const properties = radiusProperties(side);
|
|
946
|
+
if (properties === null) return null;
|
|
947
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
948
|
+
if (value === null) return null;
|
|
949
|
+
return properties.map((p) => decl(p, value));
|
|
950
|
+
}
|
|
951
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
952
|
+
function outlineWidthValue(key) {
|
|
953
|
+
switch (key) {
|
|
954
|
+
case "0":
|
|
955
|
+
return "0px";
|
|
956
|
+
case "1":
|
|
957
|
+
return "1px";
|
|
958
|
+
case "2":
|
|
959
|
+
return "2px";
|
|
960
|
+
case "4":
|
|
961
|
+
return "4px";
|
|
962
|
+
case "8":
|
|
963
|
+
return "8px";
|
|
964
|
+
default:
|
|
965
|
+
return null;
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
function outlineValue(theme, parsed) {
|
|
969
|
+
const value = parsed.value;
|
|
970
|
+
if (value === null) return null;
|
|
971
|
+
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
972
|
+
const w = outlineWidthValue(value);
|
|
973
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
974
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
975
|
+
const color = colorValue(theme, parsed);
|
|
976
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
977
|
+
}
|
|
978
|
+
function outlineOffsetValue(parsed) {
|
|
979
|
+
const value = parsed.value;
|
|
980
|
+
if (value === null) return null;
|
|
981
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
982
|
+
const w = outlineWidthValue(value);
|
|
983
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
984
|
+
}
|
|
985
|
+
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))";
|
|
986
|
+
function ringWidth(key) {
|
|
987
|
+
switch (key) {
|
|
988
|
+
case "0":
|
|
989
|
+
return "0px";
|
|
990
|
+
case "1":
|
|
991
|
+
return "1px";
|
|
992
|
+
case "2":
|
|
993
|
+
return "2px";
|
|
994
|
+
case "4":
|
|
995
|
+
return "4px";
|
|
996
|
+
case "8":
|
|
997
|
+
return "8px";
|
|
998
|
+
default:
|
|
999
|
+
return null;
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
function ringValue(theme, parsed) {
|
|
1003
|
+
const value = parsed.value;
|
|
1004
|
+
if (value === null) return null;
|
|
1005
|
+
if (value === "inset") {
|
|
1006
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1007
|
+
}
|
|
1008
|
+
if (!parsed.isArbitrary) {
|
|
1009
|
+
const w = ringWidth(value);
|
|
1010
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1011
|
+
}
|
|
1012
|
+
const color = colorValue(theme, parsed);
|
|
1013
|
+
if (color === null) return null;
|
|
1014
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1015
|
+
}
|
|
1016
|
+
function ringOffsetValue(theme, parsed) {
|
|
1017
|
+
const value = parsed.value;
|
|
1018
|
+
if (value === null) return null;
|
|
1019
|
+
if (!parsed.isArbitrary) {
|
|
1020
|
+
const w = ringWidth(value);
|
|
1021
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1022
|
+
}
|
|
1023
|
+
const color = colorValue(theme, parsed);
|
|
1024
|
+
if (color === null) return null;
|
|
1025
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1026
|
+
}
|
|
1027
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1028
|
+
function resolve3(parsed, theme) {
|
|
1029
|
+
switch (parsed.utility) {
|
|
1030
|
+
case "border":
|
|
1031
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1032
|
+
return borderValue(theme, parsed);
|
|
1033
|
+
case "border-t":
|
|
1034
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1035
|
+
case "border-r":
|
|
1036
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1037
|
+
case "border-b":
|
|
1038
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1039
|
+
case "border-l":
|
|
1040
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1041
|
+
case "border-x":
|
|
1042
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1043
|
+
case "border-y":
|
|
1044
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1045
|
+
case "rounded": {
|
|
1046
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1047
|
+
const value = parsed.value;
|
|
1048
|
+
if (!parsed.isArbitrary) {
|
|
1049
|
+
const size = radiusSize(value);
|
|
1050
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1051
|
+
}
|
|
1052
|
+
const v = resolveLength(theme, parsed);
|
|
1053
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1054
|
+
}
|
|
1055
|
+
case "ring":
|
|
1056
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1057
|
+
return ringValue(theme, parsed);
|
|
1058
|
+
case "ring-offset":
|
|
1059
|
+
return ringOffsetValue(theme, parsed);
|
|
1060
|
+
case "outline":
|
|
1061
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1062
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1063
|
+
return outlineValue(theme, parsed);
|
|
1064
|
+
case "outline-offset":
|
|
1065
|
+
return outlineOffsetValue(parsed);
|
|
1066
|
+
default:
|
|
1067
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1068
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1069
|
+
}
|
|
1070
|
+
return null;
|
|
1071
|
+
}
|
|
413
1072
|
}
|
|
414
1073
|
|
|
415
|
-
// src/
|
|
416
|
-
|
|
1074
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1075
|
+
function textSize(key) {
|
|
1076
|
+
switch (key) {
|
|
1077
|
+
case "xs":
|
|
1078
|
+
return "0.75rem";
|
|
1079
|
+
case "sm":
|
|
1080
|
+
return "0.875rem";
|
|
1081
|
+
case "base":
|
|
1082
|
+
return "1rem";
|
|
1083
|
+
case "lg":
|
|
1084
|
+
return "1.125rem";
|
|
1085
|
+
case "xl":
|
|
1086
|
+
return "1.25rem";
|
|
1087
|
+
case "2xl":
|
|
1088
|
+
return "1.5rem";
|
|
1089
|
+
case "3xl":
|
|
1090
|
+
return "1.875rem";
|
|
1091
|
+
case "4xl":
|
|
1092
|
+
return "2.25rem";
|
|
1093
|
+
case "5xl":
|
|
1094
|
+
return "3rem";
|
|
1095
|
+
case "6xl":
|
|
1096
|
+
return "3.75rem";
|
|
1097
|
+
case "7xl":
|
|
1098
|
+
return "4.5rem";
|
|
1099
|
+
case "8xl":
|
|
1100
|
+
return "6rem";
|
|
1101
|
+
case "9xl":
|
|
1102
|
+
return "8rem";
|
|
1103
|
+
default:
|
|
1104
|
+
return null;
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function lineHeightSize(key) {
|
|
1108
|
+
switch (key) {
|
|
1109
|
+
case "3":
|
|
1110
|
+
return "0.75rem";
|
|
1111
|
+
case "4":
|
|
1112
|
+
return "1rem";
|
|
1113
|
+
case "5":
|
|
1114
|
+
return "1.25rem";
|
|
1115
|
+
case "6":
|
|
1116
|
+
return "1.5rem";
|
|
1117
|
+
case "7":
|
|
1118
|
+
return "1.75rem";
|
|
1119
|
+
case "8":
|
|
1120
|
+
return "2rem";
|
|
1121
|
+
case "9":
|
|
1122
|
+
return "2.25rem";
|
|
1123
|
+
case "10":
|
|
1124
|
+
return "2.5rem";
|
|
1125
|
+
default:
|
|
1126
|
+
return null;
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
function textAlign(key) {
|
|
1130
|
+
switch (key) {
|
|
1131
|
+
case "left":
|
|
1132
|
+
return "left";
|
|
1133
|
+
case "center":
|
|
1134
|
+
return "center";
|
|
1135
|
+
case "right":
|
|
1136
|
+
return "right";
|
|
1137
|
+
case "justify":
|
|
1138
|
+
return "justify";
|
|
1139
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
1140
|
+
// as layout.rs's start/end inset properties.
|
|
1141
|
+
case "start":
|
|
1142
|
+
return "start";
|
|
1143
|
+
case "end":
|
|
1144
|
+
return "end";
|
|
1145
|
+
default:
|
|
1146
|
+
return null;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
function fontWeight(key) {
|
|
1150
|
+
switch (key) {
|
|
1151
|
+
case "thin":
|
|
1152
|
+
return "100";
|
|
1153
|
+
case "extralight":
|
|
1154
|
+
return "200";
|
|
1155
|
+
case "light":
|
|
1156
|
+
return "300";
|
|
1157
|
+
case "normal":
|
|
1158
|
+
return "400";
|
|
1159
|
+
case "medium":
|
|
1160
|
+
return "500";
|
|
1161
|
+
case "semibold":
|
|
1162
|
+
return "600";
|
|
1163
|
+
case "bold":
|
|
1164
|
+
return "700";
|
|
1165
|
+
case "extrabold":
|
|
1166
|
+
return "800";
|
|
1167
|
+
case "black":
|
|
1168
|
+
return "900";
|
|
1169
|
+
default:
|
|
1170
|
+
return null;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
function fontFamilyValue(theme, key) {
|
|
1174
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
1175
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
1176
|
+
switch (key) {
|
|
1177
|
+
case "sans":
|
|
1178
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
1179
|
+
case "serif":
|
|
1180
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
1181
|
+
case "mono":
|
|
1182
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1183
|
+
default:
|
|
1184
|
+
return null;
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
417
1187
|
|
|
418
|
-
// src/
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
1188
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1189
|
+
function nativeShadowValue(key) {
|
|
1190
|
+
switch (key) {
|
|
1191
|
+
case "sm":
|
|
1192
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1193
|
+
case "DEFAULT":
|
|
1194
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1195
|
+
case "md":
|
|
1196
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1197
|
+
case "lg":
|
|
1198
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1199
|
+
case "xl":
|
|
1200
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1201
|
+
case "2xl":
|
|
1202
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1203
|
+
case "none":
|
|
1204
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1205
|
+
default:
|
|
1206
|
+
return null;
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
function nativeShadowDeclarations(parsed) {
|
|
1210
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1211
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1212
|
+
const s = nativeShadowValue(key);
|
|
1213
|
+
if (s === null) return null;
|
|
1214
|
+
return [
|
|
1215
|
+
decl("shadow-color", "#000000"),
|
|
1216
|
+
decl("shadow-offset-x", "0"),
|
|
1217
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1218
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1219
|
+
decl("shadow-radius", String(s.radius)),
|
|
1220
|
+
decl("elevation", String(s.elevation))
|
|
1221
|
+
];
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// src/jsEngine/resolvers/transform.ts
|
|
1225
|
+
function scaleFactor(parsed) {
|
|
1226
|
+
if (parsed.value === null) return null;
|
|
1227
|
+
const n = Number(parsed.value);
|
|
1228
|
+
if (!Number.isFinite(n)) return null;
|
|
1229
|
+
return parsed.isArbitrary ? n : n / 100;
|
|
1230
|
+
}
|
|
1231
|
+
function angle(parsed) {
|
|
1232
|
+
if (parsed.value === null) return null;
|
|
1233
|
+
if (parsed.isArbitrary) return parsed.value;
|
|
1234
|
+
const n = Number(parsed.value);
|
|
1235
|
+
if (!Number.isFinite(n)) return null;
|
|
1236
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
1237
|
+
}
|
|
1238
|
+
function resolveNative(parsed, theme) {
|
|
1239
|
+
switch (parsed.utility) {
|
|
1240
|
+
case "transform-none":
|
|
1241
|
+
return [decl("transform-op-none", "1")];
|
|
1242
|
+
case "backface-visible":
|
|
1243
|
+
return [decl("backface-visibility", "visible")];
|
|
1244
|
+
case "backface-hidden":
|
|
1245
|
+
return [decl("backface-visibility", "hidden")];
|
|
1246
|
+
case "translate-x": {
|
|
1247
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1248
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
1249
|
+
}
|
|
1250
|
+
case "translate-y": {
|
|
1251
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1252
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
1253
|
+
}
|
|
1254
|
+
case "scale": {
|
|
1255
|
+
const n = scaleFactor(parsed);
|
|
1256
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
1257
|
+
}
|
|
1258
|
+
case "scale-x": {
|
|
1259
|
+
const n = scaleFactor(parsed);
|
|
1260
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
1261
|
+
}
|
|
1262
|
+
case "scale-y": {
|
|
1263
|
+
const n = scaleFactor(parsed);
|
|
1264
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
1265
|
+
}
|
|
1266
|
+
case "rotate": {
|
|
1267
|
+
const deg = angle(parsed);
|
|
1268
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
1269
|
+
}
|
|
1270
|
+
case "rotate-x": {
|
|
1271
|
+
const deg = angle(parsed);
|
|
1272
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
1273
|
+
}
|
|
1274
|
+
case "rotate-y": {
|
|
1275
|
+
const deg = angle(parsed);
|
|
1276
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
1277
|
+
}
|
|
1278
|
+
case "rotate-z": {
|
|
1279
|
+
const deg = angle(parsed);
|
|
1280
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
1281
|
+
}
|
|
1282
|
+
case "skew-x": {
|
|
1283
|
+
const deg = angle(parsed);
|
|
1284
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
1285
|
+
}
|
|
1286
|
+
case "skew-y": {
|
|
1287
|
+
const deg = angle(parsed);
|
|
1288
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
1289
|
+
}
|
|
1290
|
+
default:
|
|
1291
|
+
return null;
|
|
1292
|
+
}
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1296
|
+
function firstFontName(stack) {
|
|
1297
|
+
const first = stack.split(",")[0] ?? stack;
|
|
1298
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
1299
|
+
}
|
|
1300
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1301
|
+
switch (parsed.utility) {
|
|
1302
|
+
case "font": {
|
|
1303
|
+
if (parsed.value === null) return null;
|
|
1304
|
+
if (parsed.isArbitrary) {
|
|
1305
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
1306
|
+
}
|
|
1307
|
+
const w = fontWeight(parsed.value);
|
|
1308
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
1309
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
1310
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1311
|
+
}
|
|
1312
|
+
case "uppercase":
|
|
1313
|
+
return [decl("text-transform", "uppercase")];
|
|
1314
|
+
case "lowercase":
|
|
1315
|
+
return [decl("text-transform", "lowercase")];
|
|
1316
|
+
case "capitalize":
|
|
1317
|
+
return [decl("text-transform", "capitalize")];
|
|
1318
|
+
case "underline":
|
|
1319
|
+
return [decl("text-decoration-line", "underline")];
|
|
1320
|
+
case "line-through":
|
|
1321
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1322
|
+
case "no-underline":
|
|
1323
|
+
return [decl("text-decoration-line", "none")];
|
|
1324
|
+
case "italic":
|
|
1325
|
+
return [decl("font-style", "italic")];
|
|
1326
|
+
case "not-italic":
|
|
1327
|
+
return [decl("font-style", "normal")];
|
|
1328
|
+
default:
|
|
1329
|
+
return null;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1333
|
+
const value = parsed.value;
|
|
1334
|
+
if (value === null) return null;
|
|
1335
|
+
if (parsed.utility === "leading") {
|
|
1336
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1337
|
+
const v = lineHeightSize(value);
|
|
1338
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1339
|
+
}
|
|
1340
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1341
|
+
return [decl("letter-spacing", value)];
|
|
1342
|
+
}
|
|
1343
|
+
return null;
|
|
1344
|
+
}
|
|
1345
|
+
function nativeHexColor(parsed, theme) {
|
|
1346
|
+
return colorValue(theme, parsed);
|
|
1347
|
+
}
|
|
1348
|
+
function resolveTextNative(parsed, theme) {
|
|
1349
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1350
|
+
const size = textSize(parsed.value);
|
|
1351
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1352
|
+
const align = textAlign(parsed.value);
|
|
1353
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1354
|
+
}
|
|
1355
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1356
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1357
|
+
}
|
|
1358
|
+
function resolveColorNative(parsed, theme) {
|
|
1359
|
+
switch (parsed.utility) {
|
|
1360
|
+
case "bg": {
|
|
1361
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1362
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1363
|
+
}
|
|
1364
|
+
case "text":
|
|
1365
|
+
return resolveTextNative(parsed, theme);
|
|
1366
|
+
default:
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
function resolveOpacityNative(parsed) {
|
|
1371
|
+
if (parsed.utility !== "opacity") return null;
|
|
1372
|
+
const v = resolvePercent(parsed);
|
|
1373
|
+
return v === null ? null : [decl("opacity", v)];
|
|
1374
|
+
}
|
|
1375
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1376
|
+
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);
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1379
|
+
// src/jsEngine/calc.ts
|
|
1380
|
+
function reduceConstantMath(raw) {
|
|
1381
|
+
const trimmed = raw.trim();
|
|
1382
|
+
const calc = stripCall(trimmed, "calc");
|
|
1383
|
+
if (calc !== null) {
|
|
1384
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
1385
|
+
}
|
|
1386
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
1387
|
+
if (clamp !== null) {
|
|
1388
|
+
const args = splitTopLevelCommas(clamp);
|
|
1389
|
+
if (args.length !== 3) return null;
|
|
1390
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
1391
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
1392
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
1393
|
+
}
|
|
1394
|
+
const min = stripCall(trimmed, "min");
|
|
1395
|
+
if (min !== null) {
|
|
1396
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1397
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
1398
|
+
}
|
|
1399
|
+
const max = stripCall(trimmed, "max");
|
|
1400
|
+
if (max !== null) {
|
|
1401
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1402
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
1403
|
+
}
|
|
1404
|
+
return null;
|
|
1405
|
+
}
|
|
1406
|
+
function stripCall(raw, name) {
|
|
1407
|
+
if (!raw.startsWith(name)) return null;
|
|
1408
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
1409
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
1410
|
+
return afterName.slice(1, -1);
|
|
1411
|
+
}
|
|
1412
|
+
function splitTopLevelCommas(s) {
|
|
1413
|
+
const parts = [];
|
|
1414
|
+
let depth = 0;
|
|
1415
|
+
let start = 0;
|
|
1416
|
+
for (let i = 0; i < s.length; i++) {
|
|
1417
|
+
const ch = s[i];
|
|
1418
|
+
if (ch === "(") depth++;
|
|
1419
|
+
else if (ch === ")") depth--;
|
|
1420
|
+
else if (ch === "," && depth === 0) {
|
|
1421
|
+
parts.push(s.slice(start, i).trim());
|
|
1422
|
+
start = i + 1;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
parts.push(s.slice(start).trim());
|
|
1426
|
+
return parts;
|
|
1427
|
+
}
|
|
1428
|
+
var Evaluator = class {
|
|
1429
|
+
constructor(s) {
|
|
1430
|
+
this.pos = 0;
|
|
1431
|
+
this.s = s;
|
|
1432
|
+
}
|
|
1433
|
+
parseExprToEnd() {
|
|
1434
|
+
const value = this.expr();
|
|
1435
|
+
if (value === null) return null;
|
|
1436
|
+
this.skipWs();
|
|
1437
|
+
return this.pos === this.s.length ? value : null;
|
|
1438
|
+
}
|
|
1439
|
+
skipWs() {
|
|
1440
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
1441
|
+
}
|
|
1442
|
+
peek() {
|
|
1443
|
+
this.skipWs();
|
|
1444
|
+
return this.s[this.pos];
|
|
1445
|
+
}
|
|
1446
|
+
expr() {
|
|
1447
|
+
let value = this.term();
|
|
1448
|
+
if (value === null) return null;
|
|
1449
|
+
for (; ; ) {
|
|
1450
|
+
const ch = this.peek();
|
|
1451
|
+
if (ch === "+") {
|
|
1452
|
+
this.pos++;
|
|
1453
|
+
const rhs = this.term();
|
|
1454
|
+
if (rhs === null) return null;
|
|
1455
|
+
value += rhs;
|
|
1456
|
+
} else if (ch === "-") {
|
|
1457
|
+
this.pos++;
|
|
1458
|
+
const rhs = this.term();
|
|
1459
|
+
if (rhs === null) return null;
|
|
1460
|
+
value -= rhs;
|
|
1461
|
+
} else {
|
|
1462
|
+
return value;
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
term() {
|
|
1467
|
+
let value = this.factor();
|
|
1468
|
+
if (value === null) return null;
|
|
1469
|
+
for (; ; ) {
|
|
1470
|
+
const ch = this.peek();
|
|
1471
|
+
if (ch === "*") {
|
|
1472
|
+
this.pos++;
|
|
1473
|
+
const rhs = this.factor();
|
|
1474
|
+
if (rhs === null) return null;
|
|
1475
|
+
value *= rhs;
|
|
1476
|
+
} else if (ch === "/") {
|
|
1477
|
+
this.pos++;
|
|
1478
|
+
const divisor = this.factor();
|
|
1479
|
+
if (divisor === null || divisor === 0) return null;
|
|
1480
|
+
value /= divisor;
|
|
1481
|
+
} else {
|
|
1482
|
+
return value;
|
|
1483
|
+
}
|
|
1484
|
+
}
|
|
1485
|
+
}
|
|
1486
|
+
factor() {
|
|
1487
|
+
const ch = this.peek();
|
|
1488
|
+
if (ch === void 0) return null;
|
|
1489
|
+
if (ch === "(") {
|
|
1490
|
+
this.pos++;
|
|
1491
|
+
const value = this.expr();
|
|
1492
|
+
if (value === null || this.peek() !== ")") return null;
|
|
1493
|
+
this.pos++;
|
|
1494
|
+
return value;
|
|
1495
|
+
}
|
|
1496
|
+
if (ch === "-") {
|
|
1497
|
+
this.pos++;
|
|
1498
|
+
const value = this.factor();
|
|
1499
|
+
return value === null ? null : -value;
|
|
1500
|
+
}
|
|
1501
|
+
return this.numberWithUnit();
|
|
1502
|
+
}
|
|
1503
|
+
numberWithUnit() {
|
|
1504
|
+
this.skipWs();
|
|
1505
|
+
const start = this.pos;
|
|
1506
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
1507
|
+
if (this.pos === start) return null;
|
|
1508
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
1509
|
+
if (!Number.isFinite(n)) return null;
|
|
1510
|
+
const unitStart = this.pos;
|
|
1511
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
1512
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
1513
|
+
switch (unit) {
|
|
1514
|
+
case "":
|
|
1515
|
+
return n;
|
|
1516
|
+
case "px":
|
|
1517
|
+
return n;
|
|
1518
|
+
case "rem":
|
|
1519
|
+
return n * 16;
|
|
1520
|
+
default:
|
|
1521
|
+
return null;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
|
|
1526
|
+
// src/jsEngine/resolveStyle.ts
|
|
1527
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1528
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1529
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1530
|
+
if (modifier === "active") return pressed;
|
|
1531
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1532
|
+
const minWidth = theme.screens[modifier];
|
|
1533
|
+
if (minWidth === void 0) return null;
|
|
1534
|
+
return width >= minWidth;
|
|
1535
|
+
}
|
|
1536
|
+
return null;
|
|
1537
|
+
}
|
|
1538
|
+
function kebabToCamel(s) {
|
|
1539
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1540
|
+
}
|
|
1541
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1542
|
+
"padding",
|
|
1543
|
+
"padding-top",
|
|
1544
|
+
"padding-right",
|
|
1545
|
+
"padding-bottom",
|
|
1546
|
+
"padding-left",
|
|
1547
|
+
"margin",
|
|
1548
|
+
"margin-top",
|
|
1549
|
+
"margin-right",
|
|
1550
|
+
"margin-bottom",
|
|
1551
|
+
"margin-left",
|
|
1552
|
+
"gap",
|
|
1553
|
+
"column-gap",
|
|
1554
|
+
"row-gap",
|
|
1555
|
+
"width",
|
|
1556
|
+
"height",
|
|
1557
|
+
"min-width",
|
|
1558
|
+
"max-width",
|
|
1559
|
+
"min-height",
|
|
1560
|
+
"max-height",
|
|
1561
|
+
"top",
|
|
1562
|
+
"right",
|
|
1563
|
+
"bottom",
|
|
1564
|
+
"left",
|
|
1565
|
+
"inset",
|
|
1566
|
+
"border-radius",
|
|
1567
|
+
"border-width",
|
|
1568
|
+
"font-size",
|
|
1569
|
+
"z-index",
|
|
1570
|
+
"line-height",
|
|
1571
|
+
"letter-spacing",
|
|
1572
|
+
"flex",
|
|
1573
|
+
"flex-grow",
|
|
1574
|
+
"flex-shrink",
|
|
1575
|
+
"order",
|
|
1576
|
+
"flex-basis",
|
|
1577
|
+
"shadow-opacity",
|
|
1578
|
+
"shadow-radius",
|
|
1579
|
+
"elevation",
|
|
1580
|
+
"opacity",
|
|
1581
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1582
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1583
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1584
|
+
// "border-width"/"border-radius" forms above.
|
|
1585
|
+
"border-top-width",
|
|
1586
|
+
"border-right-width",
|
|
1587
|
+
"border-bottom-width",
|
|
1588
|
+
"border-left-width",
|
|
1589
|
+
"border-top-left-radius",
|
|
1590
|
+
"border-top-right-radius",
|
|
1591
|
+
"border-bottom-right-radius",
|
|
1592
|
+
"border-bottom-left-radius",
|
|
1593
|
+
"outline-width",
|
|
1594
|
+
"outline-offset",
|
|
1595
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
1596
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
1597
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
1598
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
1599
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
1600
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
1601
|
+
// get collected into the final array.
|
|
1602
|
+
"transform-op-translate-x",
|
|
1603
|
+
"transform-op-translate-y",
|
|
1604
|
+
"transform-op-scale-x",
|
|
1605
|
+
"transform-op-scale-y"
|
|
1606
|
+
]);
|
|
1607
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
1608
|
+
["transform-op-translate-x", "translateX"],
|
|
1609
|
+
["transform-op-translate-y", "translateY"],
|
|
1610
|
+
["transform-op-rotate", "rotate"],
|
|
1611
|
+
["transform-op-rotate-x", "rotateX"],
|
|
1612
|
+
["transform-op-rotate-y", "rotateY"],
|
|
1613
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
1614
|
+
["transform-op-skew-x", "skewX"],
|
|
1615
|
+
["transform-op-skew-y", "skewY"],
|
|
1616
|
+
["transform-op-scale-x", "scaleX"],
|
|
1617
|
+
["transform-op-scale-y", "scaleY"]
|
|
1618
|
+
]);
|
|
1619
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
1620
|
+
function isPlainPercentage(value) {
|
|
1621
|
+
if (!value.endsWith("%")) return false;
|
|
1622
|
+
let digits = value.slice(0, -1);
|
|
1623
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
1624
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
1625
|
+
}
|
|
1626
|
+
function rnStyleValue(property, value) {
|
|
1627
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1628
|
+
return { value, warning: null };
|
|
1629
|
+
}
|
|
1630
|
+
let px = null;
|
|
1631
|
+
if (value.endsWith("px")) {
|
|
1632
|
+
const n = Number(value.slice(0, -2));
|
|
1633
|
+
px = Number.isFinite(n) ? n : null;
|
|
1634
|
+
} else if (value.endsWith("rem")) {
|
|
1635
|
+
const n = Number(value.slice(0, -3));
|
|
1636
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1637
|
+
} else {
|
|
1638
|
+
const n = Number(value);
|
|
1639
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1640
|
+
}
|
|
1641
|
+
if (px !== null) return { value: px, warning: null };
|
|
1642
|
+
if (isPlainPercentage(value)) {
|
|
1643
|
+
return { value, warning: null };
|
|
1644
|
+
}
|
|
1645
|
+
const reduced = reduceConstantMath(value);
|
|
1646
|
+
if (reduced !== null) {
|
|
1647
|
+
return { value: reduced, warning: null };
|
|
1648
|
+
}
|
|
1649
|
+
const warning = `[Kbach] "${value}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
1650
|
+
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).
|
|
1651
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
1652
|
+
return { value: null, warning };
|
|
1653
|
+
}
|
|
1654
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1655
|
+
const style = {};
|
|
1656
|
+
const warnings = [];
|
|
1657
|
+
let shadowOffset = null;
|
|
1658
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
1659
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1660
|
+
const parsed = parseClass(token);
|
|
1661
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1662
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
426
1663
|
);
|
|
1664
|
+
if (!allModifiersHold) continue;
|
|
1665
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1666
|
+
if (decls === null) continue;
|
|
1667
|
+
for (const d of decls) {
|
|
1668
|
+
if (d.property.startsWith("__")) {
|
|
1669
|
+
continue;
|
|
1670
|
+
}
|
|
1671
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1672
|
+
const n = Number(d.value);
|
|
1673
|
+
if (!Number.isFinite(n)) continue;
|
|
1674
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1675
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1676
|
+
continue;
|
|
1677
|
+
}
|
|
1678
|
+
if (d.property === "transform-op-none") {
|
|
1679
|
+
transformOps.clear();
|
|
1680
|
+
continue;
|
|
1681
|
+
}
|
|
1682
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
1683
|
+
if (opKey !== void 0) {
|
|
1684
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
1685
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
1686
|
+
if (value2 !== null) transformOps.set(opKey, value2);
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
1690
|
+
if (warning !== null) warnings.push(warning);
|
|
1691
|
+
if (value !== null) style[kebabToCamel(d.property)] = value;
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
if (shadowOffset !== null) {
|
|
1695
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1696
|
+
}
|
|
1697
|
+
if (transformOps.size > 0) {
|
|
1698
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
1699
|
+
[key]: transformOps.get(key)
|
|
1700
|
+
}));
|
|
1701
|
+
}
|
|
1702
|
+
return { style, warnings };
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
// src/nativeBridge.ts
|
|
1706
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
1707
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
1708
|
+
var cachedForThemeJson = null;
|
|
1709
|
+
function resolveStyle(classString, pressed = false) {
|
|
1710
|
+
const colorScheme = (0, import_darkModeStore.getGlobalDarkMode)() ? "dark" : "light";
|
|
1711
|
+
const width = import_react_native.Dimensions.get("window").width;
|
|
1712
|
+
const themeJson = (0, import_theme.getThemeJson)();
|
|
1713
|
+
if (themeJson !== cachedForThemeJson) {
|
|
1714
|
+
resolveStyleCache.clear();
|
|
1715
|
+
cachedForThemeJson = themeJson;
|
|
1716
|
+
}
|
|
1717
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
1718
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
1719
|
+
if (cached !== void 0) return { ...cached };
|
|
1720
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
1721
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
1722
|
+
resolveStyleCache.set(cacheKey, style);
|
|
1723
|
+
return { ...style };
|
|
1724
|
+
}
|
|
1725
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
1726
|
+
const KbachModule = import_react_native.TurboModuleRegistry.get("KbachModule");
|
|
1727
|
+
if (!KbachModule) {
|
|
1728
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
|
|
1729
|
+
warnIfDev(classString, warnings2);
|
|
1730
|
+
return style2;
|
|
1731
|
+
}
|
|
1732
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
1733
|
+
const style = JSON.parse(json);
|
|
1734
|
+
const warnings = style.__kbachWarnings;
|
|
1735
|
+
if (warnings !== void 0) {
|
|
1736
|
+
delete style.__kbachWarnings;
|
|
1737
|
+
warnIfDev(classString, warnings);
|
|
1738
|
+
}
|
|
1739
|
+
return style;
|
|
1740
|
+
}
|
|
1741
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
1742
|
+
function warnIfDev(classString, warnings) {
|
|
1743
|
+
if (warnings.length === 0) return;
|
|
1744
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
1745
|
+
for (const warning of warnings) {
|
|
1746
|
+
const message = `${warning}
|
|
1747
|
+
From className: "${classString}"`;
|
|
1748
|
+
if (warnedMessages.has(message)) continue;
|
|
1749
|
+
warnedMessages.add(message);
|
|
1750
|
+
console.warn(message);
|
|
1751
|
+
}
|
|
1752
|
+
}
|
|
1753
|
+
|
|
1754
|
+
// src/config.ts
|
|
1755
|
+
var import_theme2 = require("./theme");
|
|
1756
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1757
|
+
function parseHexRgb(hex) {
|
|
1758
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1759
|
+
if (!m) return null;
|
|
1760
|
+
let h = m[1];
|
|
1761
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1762
|
+
const n = parseInt(h, 16);
|
|
1763
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1764
|
+
}
|
|
1765
|
+
function applyOpacityToHex(hex, opacityText) {
|
|
1766
|
+
const rgb = parseHexRgb(hex);
|
|
1767
|
+
if (!rgb) return hex;
|
|
1768
|
+
const a = Number(opacityText) / 100;
|
|
1769
|
+
const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
|
|
1770
|
+
return `rgba(${rgb.join(",")},${clamped})`;
|
|
1771
|
+
}
|
|
1772
|
+
function resolveColorEntry(value, lookup) {
|
|
1773
|
+
const slash = value.indexOf("/");
|
|
1774
|
+
const name = slash === -1 ? value : value.slice(0, slash);
|
|
1775
|
+
const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
|
|
1776
|
+
const base = lookup(name);
|
|
1777
|
+
if (base === void 0) return value;
|
|
1778
|
+
return opacity === void 0 ? base : applyOpacityToHex(base, opacity);
|
|
1779
|
+
}
|
|
1780
|
+
function resolveColors(extend, existing) {
|
|
1781
|
+
const resolved = {};
|
|
1782
|
+
const lookup = (name) => {
|
|
1783
|
+
const found = resolved[name] ?? existing[name];
|
|
1784
|
+
return typeof found === "string" ? found : void 0;
|
|
1785
|
+
};
|
|
1786
|
+
for (const [name, value] of Object.entries(extend)) {
|
|
1787
|
+
resolved[name] = resolveColorEntry(value, lookup);
|
|
1788
|
+
}
|
|
1789
|
+
return resolved;
|
|
1790
|
+
}
|
|
1791
|
+
function resolveKbachConfig(config) {
|
|
1792
|
+
let theme = { ...import_theme2.defaultTheme, ...config.theme };
|
|
1793
|
+
if (config.extend?.colors) {
|
|
1794
|
+
theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
|
|
1795
|
+
}
|
|
1796
|
+
if (config.extend?.spacing) {
|
|
1797
|
+
theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
|
|
427
1798
|
}
|
|
428
|
-
|
|
1799
|
+
if (config.extend?.screens) {
|
|
1800
|
+
theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
|
|
1801
|
+
}
|
|
1802
|
+
if (config.extend?.fontFamily) {
|
|
1803
|
+
theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
|
|
1804
|
+
}
|
|
1805
|
+
if (config.extend?.container) {
|
|
1806
|
+
theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
|
|
1807
|
+
}
|
|
1808
|
+
if (config.darkMode) {
|
|
1809
|
+
theme = { ...theme, darkMode: config.darkMode };
|
|
1810
|
+
}
|
|
1811
|
+
return theme;
|
|
1812
|
+
}
|
|
1813
|
+
function applyKbachConfig(config) {
|
|
1814
|
+
const theme = resolveKbachConfig(config);
|
|
1815
|
+
(0, import_theme2.setTheme)(theme);
|
|
1816
|
+
(0, import_darkModeStore2.resyncDomWithActiveTheme)();
|
|
1817
|
+
return theme;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
// src/useTheme.ts
|
|
1821
|
+
var import_react = require("react");
|
|
1822
|
+
var import_darkModeStore3 = require("./darkModeStore");
|
|
1823
|
+
function useTheme() {
|
|
1824
|
+
const isDark = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalDarkMode);
|
|
1825
|
+
const mode = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalThemeMode);
|
|
1826
|
+
return (0, import_react.useMemo)(
|
|
1827
|
+
() => ({ mode, isDark, setMode: import_darkModeStore3.setGlobalThemeMode, toggle: import_darkModeStore3.toggleGlobalDarkMode }),
|
|
1828
|
+
[mode, isDark]
|
|
1829
|
+
);
|
|
429
1830
|
}
|
|
430
1831
|
|
|
431
1832
|
// src/ThemeProvider.tsx
|
|
1833
|
+
var import_react2 = require("react");
|
|
1834
|
+
var import_darkModeStore4 = require("./darkModeStore");
|
|
432
1835
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
1836
|
+
var PERSIST_STORAGE_KEY = "kbach-theme";
|
|
1837
|
+
function isThemeMode(value) {
|
|
1838
|
+
return value === "light" || value === "dark" || value === "system";
|
|
1839
|
+
}
|
|
433
1840
|
var mountedProviderCount = 0;
|
|
434
1841
|
var warnedMultipleProviders = false;
|
|
435
|
-
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
436
|
-
(0,
|
|
1842
|
+
function ThemeProvider({ children, defaultMode = "system", persist = false }) {
|
|
1843
|
+
(0, import_react2.useEffect)(() => {
|
|
437
1844
|
mountedProviderCount++;
|
|
438
1845
|
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
439
1846
|
warnedMultipleProviders = true;
|
|
440
1847
|
console.warn(
|
|
441
|
-
"[
|
|
1848
|
+
"[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
1849
|
);
|
|
443
1850
|
}
|
|
444
1851
|
return () => {
|
|
445
1852
|
mountedProviderCount--;
|
|
446
1853
|
};
|
|
447
1854
|
}, []);
|
|
448
|
-
const seeded = (0,
|
|
449
|
-
(0,
|
|
1855
|
+
const seeded = (0, import_react2.useRef)(false);
|
|
1856
|
+
(0, import_react2.useEffect)(() => {
|
|
450
1857
|
if (seeded.current) return;
|
|
451
1858
|
seeded.current = true;
|
|
452
|
-
|
|
1859
|
+
if (!persist) {
|
|
1860
|
+
(0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
1861
|
+
return;
|
|
1862
|
+
}
|
|
1863
|
+
let cancelled = false;
|
|
1864
|
+
persist.getItem(PERSIST_STORAGE_KEY).then((stored) => {
|
|
1865
|
+
if (cancelled) return;
|
|
1866
|
+
if (isThemeMode(stored)) (0, import_darkModeStore4.seedDefaultMode)(stored);
|
|
1867
|
+
else (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
1868
|
+
}).catch(() => {
|
|
1869
|
+
if (!cancelled) (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
1870
|
+
});
|
|
1871
|
+
return () => {
|
|
1872
|
+
cancelled = true;
|
|
1873
|
+
};
|
|
453
1874
|
}, []);
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
1875
|
+
(0, import_react2.useEffect)(() => {
|
|
1876
|
+
if (!persist) return;
|
|
1877
|
+
return (0, import_darkModeStore4.subscribeGlobalDarkMode)(() => {
|
|
1878
|
+
persist.setItem(PERSIST_STORAGE_KEY, (0, import_darkModeStore4.getGlobalThemeMode)()).catch(() => {
|
|
1879
|
+
});
|
|
1880
|
+
});
|
|
1881
|
+
}, [persist]);
|
|
1882
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
// src/index.ts
|
|
1886
|
+
var import_darkModeStore5 = require("./darkModeStore");
|
|
1887
|
+
|
|
1888
|
+
// src/useColors.ts
|
|
1889
|
+
var import_react3 = require("react");
|
|
1890
|
+
var import_theme3 = require("./theme");
|
|
1891
|
+
function parseHexRgb2(hex) {
|
|
1892
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1893
|
+
if (!m) return null;
|
|
1894
|
+
let h = m[1];
|
|
1895
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1896
|
+
const n = parseInt(h, 16);
|
|
1897
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1898
|
+
}
|
|
1899
|
+
function applyOpacity(color, opacity) {
|
|
1900
|
+
const a = Math.max(0, Math.min(1, opacity / 100));
|
|
1901
|
+
if (color.startsWith("#")) {
|
|
1902
|
+
const rgb = parseHexRgb2(color);
|
|
1903
|
+
return rgb ? `rgba(${rgb.join(",")},${a})` : color;
|
|
1904
|
+
}
|
|
1905
|
+
if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
|
|
1906
|
+
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
1907
|
+
return color;
|
|
1908
|
+
}
|
|
1909
|
+
function resolveEntry(entry, isDark) {
|
|
1910
|
+
return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
|
|
1911
|
+
}
|
|
1912
|
+
function makeColorsProxy(theme, isDark) {
|
|
1913
|
+
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
1914
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1915
|
+
function resolveNamed(key) {
|
|
1916
|
+
let name = key;
|
|
1917
|
+
let opacity;
|
|
1918
|
+
if (key.includes("/")) {
|
|
1919
|
+
const slash = key.indexOf("/");
|
|
1920
|
+
name = key.slice(0, slash);
|
|
1921
|
+
opacity = Number(key.slice(slash + 1));
|
|
1922
|
+
}
|
|
1923
|
+
const entry = theme.colors[name];
|
|
1924
|
+
if (entry === void 0) return void 0;
|
|
1925
|
+
const value = resolveEntry(entry, isDark);
|
|
1926
|
+
return opacity === void 0 ? value : applyOpacity(value, opacity);
|
|
1927
|
+
}
|
|
1928
|
+
function makeFamilyProxy(family) {
|
|
1929
|
+
return new Proxy({}, {
|
|
1930
|
+
get(_, prop) {
|
|
1931
|
+
const key = String(prop);
|
|
1932
|
+
if (key === "then") return void 0;
|
|
1933
|
+
return resolveNamed(`${family}-${key}`);
|
|
1934
|
+
}
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1937
|
+
return new Proxy({ alpha }, {
|
|
1938
|
+
get(_, prop) {
|
|
1939
|
+
const key = String(prop);
|
|
1940
|
+
if (key === "then") return void 0;
|
|
1941
|
+
if (key === "alpha") return alpha;
|
|
1942
|
+
const direct = resolveNamed(key);
|
|
1943
|
+
if (direct !== void 0) return direct;
|
|
1944
|
+
if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
|
|
1945
|
+
return cache.get(key);
|
|
1946
|
+
}
|
|
1947
|
+
});
|
|
1948
|
+
}
|
|
1949
|
+
function useColors() {
|
|
1950
|
+
const { isDark } = useTheme();
|
|
1951
|
+
const theme = (0, import_theme3.getTheme)();
|
|
1952
|
+
return (0, import_react3.useMemo)(() => makeColorsProxy(theme, isDark), [theme, isDark]);
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// src/index.ts
|
|
1956
|
+
var import_dynamicTokens2 = require("./dynamicTokens");
|
|
1957
|
+
|
|
1958
|
+
// src/useDynamicToken.ts
|
|
1959
|
+
var import_react4 = require("react");
|
|
1960
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
1961
|
+
function useDynamicToken(name) {
|
|
1962
|
+
return (0, import_react4.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
|
|
1963
|
+
}
|
|
1964
|
+
|
|
1965
|
+
// src/clsx.ts
|
|
1966
|
+
function clsx(...inputs) {
|
|
1967
|
+
let out = "";
|
|
1968
|
+
for (const input of inputs) {
|
|
1969
|
+
const piece = resolveClassValue(input);
|
|
1970
|
+
if (piece) out = out ? `${out} ${piece}` : piece;
|
|
1971
|
+
}
|
|
1972
|
+
return out;
|
|
1973
|
+
}
|
|
1974
|
+
function resolveClassValue(value) {
|
|
1975
|
+
if (!value) return "";
|
|
1976
|
+
const type = typeof value;
|
|
1977
|
+
if (type === "string" || type === "number" || type === "bigint") return String(value);
|
|
1978
|
+
if (Array.isArray(value)) return clsx(...value);
|
|
1979
|
+
if (type === "object") {
|
|
1980
|
+
let out = "";
|
|
1981
|
+
for (const key in value) {
|
|
1982
|
+
if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
|
|
1983
|
+
out = out ? `${out} ${key}` : key;
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
return out;
|
|
1987
|
+
}
|
|
1988
|
+
return "";
|
|
461
1989
|
}
|
|
462
1990
|
// Annotate the CommonJS export names for ESM import in node:
|
|
463
1991
|
0 && (module.exports = {
|
|
464
1992
|
ThemeProvider,
|
|
1993
|
+
applyKbachConfig,
|
|
1994
|
+
clsx,
|
|
465
1995
|
defaultTheme,
|
|
1996
|
+
deleteDynamicToken,
|
|
1997
|
+
getDynamicToken,
|
|
466
1998
|
getGlobalDarkMode,
|
|
467
1999
|
getGlobalThemeMode,
|
|
468
2000
|
getTheme,
|
|
2001
|
+
resolveKbachConfig,
|
|
469
2002
|
resolveStyle,
|
|
2003
|
+
setDynamicToken,
|
|
470
2004
|
setGlobalThemeMode,
|
|
471
2005
|
setTheme,
|
|
2006
|
+
subscribeDynamicTokens,
|
|
472
2007
|
subscribeGlobalDarkMode,
|
|
473
2008
|
toggleGlobalDarkMode,
|
|
474
|
-
|
|
2009
|
+
useColors,
|
|
2010
|
+
useDynamicToken,
|
|
475
2011
|
useTheme
|
|
476
2012
|
});
|