@kbach/react-native 1.0.0-beta.2 → 1.0.0-beta.21
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 +253 -87
- package/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +14 -0
- package/android/src/main/java/com/kbachnative/KbachModule.kt +83 -0
- package/android/src/main/java/com/kbachnative/KbachPackage.kt +54 -0
- 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-AG7ZQ2K4.mjs +552 -0
- package/dist/chunk-OS7EPBH5.mjs +40 -0
- package/dist/chunk-TS2EEVOE.mjs +107 -0
- package/dist/darkModeStore.d.ts +58 -0
- package/dist/darkModeStore.js +112 -0
- package/dist/dynamicTokens.d.ts +36 -0
- package/dist/dynamicTokens.js +75 -0
- package/dist/index.d.ts +53 -102
- package/dist/index.js +1721 -385
- package/dist/index.web.d.ts +18 -0
- package/dist/index.web.js +436 -0
- package/dist/index.web.mjs +210 -0
- package/dist/jsx-dev-runtime.d.ts +3 -12
- package/dist/jsx-dev-runtime.js +1738 -343
- package/dist/jsx-dev-runtime.web.d.ts +10 -0
- package/dist/jsx-dev-runtime.web.js +270 -0
- package/dist/jsx-dev-runtime.web.mjs +29 -0
- package/dist/jsx-runtime.d.ts +3 -23
- package/dist/jsx-runtime.js +1729 -335
- package/dist/jsx-runtime.web.d.ts +7 -0
- package/dist/jsx-runtime.web.js +252 -0
- package/dist/{jsx-runtime.mjs → jsx-runtime.web.mjs} +2 -2
- package/dist/theme.d.ts +54 -0
- package/dist/{chunk-YHF3QLRL.mjs → theme.js} +94 -72
- package/dist/useDynamicToken-Dr15c88t.d.ts +160 -0
- package/package.json +62 -14
- package/react-native.config.js +29 -0
- package/specs/NativeKbachModule.ts +31 -0
- package/src/babel-plugin.js +74 -2
- package/dist/chunk-SVMYVXY6.mjs +0 -44
- package/dist/index.d.mts +0 -148
- 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 -27
package/dist/index.js
CHANGED
|
@@ -21,449 +21,1785 @@ 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
|
+
defaultTheme: () => import_theme4.defaultTheme,
|
|
26
|
+
deleteDynamicToken: () => import_dynamicTokens2.deleteDynamicToken,
|
|
27
|
+
getDynamicToken: () => import_dynamicTokens2.getDynamicToken,
|
|
28
|
+
getGlobalDarkMode: () => import_darkModeStore4.getGlobalDarkMode,
|
|
29
|
+
getGlobalThemeMode: () => import_darkModeStore4.getGlobalThemeMode,
|
|
30
|
+
getTheme: () => import_theme4.getTheme,
|
|
31
|
+
resolveKbachConfig: () => resolveKbachConfig,
|
|
28
32
|
resolveStyle: () => resolveStyle,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
setDynamicToken: () => import_dynamicTokens2.setDynamicToken,
|
|
34
|
+
setGlobalThemeMode: () => import_darkModeStore4.setGlobalThemeMode,
|
|
35
|
+
setTheme: () => import_theme4.setTheme,
|
|
36
|
+
subscribeDynamicTokens: () => import_dynamicTokens2.subscribeDynamicTokens,
|
|
37
|
+
subscribeGlobalDarkMode: () => import_darkModeStore4.subscribeGlobalDarkMode,
|
|
38
|
+
toggleGlobalDarkMode: () => import_darkModeStore4.toggleGlobalDarkMode,
|
|
39
|
+
useColors: () => useColors,
|
|
40
|
+
useDynamicToken: () => useDynamicToken,
|
|
34
41
|
useTheme: () => useTheme
|
|
35
42
|
});
|
|
36
43
|
module.exports = __toCommonJS(src_exports);
|
|
44
|
+
var import_theme4 = require("./theme");
|
|
37
45
|
|
|
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
|
-
};
|
|
46
|
+
// src/nativeBridge.ts
|
|
47
|
+
var import_react_native = require("react-native");
|
|
48
|
+
var import_theme = require("./theme");
|
|
49
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
314
50
|
|
|
315
|
-
// src/
|
|
316
|
-
var
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
51
|
+
// src/jsEngine/parser.ts
|
|
52
|
+
var VALUE_PREFIXES = [
|
|
53
|
+
"bg-opacity-",
|
|
54
|
+
"text-opacity-",
|
|
55
|
+
"bg-blend-",
|
|
56
|
+
"text-shadow-",
|
|
57
|
+
"bg-",
|
|
58
|
+
"text-",
|
|
59
|
+
"border-x-",
|
|
60
|
+
"border-y-",
|
|
61
|
+
"border-t-",
|
|
62
|
+
"border-r-",
|
|
63
|
+
"border-b-",
|
|
64
|
+
"border-l-",
|
|
65
|
+
"border-",
|
|
66
|
+
"caret-",
|
|
67
|
+
"accent-",
|
|
68
|
+
"fill-",
|
|
69
|
+
"stroke-width-",
|
|
70
|
+
"stroke-",
|
|
71
|
+
"resize-",
|
|
72
|
+
"touch-",
|
|
73
|
+
"will-change-",
|
|
74
|
+
"scroll-mx-",
|
|
75
|
+
"scroll-my-",
|
|
76
|
+
"scroll-mt-",
|
|
77
|
+
"scroll-mr-",
|
|
78
|
+
"scroll-mb-",
|
|
79
|
+
"scroll-ml-",
|
|
80
|
+
"scroll-m-",
|
|
81
|
+
"scroll-px-",
|
|
82
|
+
"scroll-py-",
|
|
83
|
+
"scroll-pt-",
|
|
84
|
+
"scroll-pr-",
|
|
85
|
+
"scroll-pb-",
|
|
86
|
+
"scroll-pl-",
|
|
87
|
+
"scroll-p-",
|
|
88
|
+
"px-",
|
|
89
|
+
"py-",
|
|
90
|
+
"pt-",
|
|
91
|
+
"pr-",
|
|
92
|
+
"pb-",
|
|
93
|
+
"pl-",
|
|
94
|
+
"p-",
|
|
95
|
+
"mx-",
|
|
96
|
+
"my-",
|
|
97
|
+
"mt-",
|
|
98
|
+
"mr-",
|
|
99
|
+
"mb-",
|
|
100
|
+
"ml-",
|
|
101
|
+
"m-",
|
|
102
|
+
"gap-x-",
|
|
103
|
+
"gap-y-",
|
|
104
|
+
"gap-",
|
|
105
|
+
"min-w-",
|
|
106
|
+
"max-w-",
|
|
107
|
+
"w-",
|
|
108
|
+
"min-h-",
|
|
109
|
+
"max-h-",
|
|
110
|
+
"h-",
|
|
111
|
+
"size-",
|
|
112
|
+
"basis-",
|
|
113
|
+
"rounded-tl-",
|
|
114
|
+
"rounded-tr-",
|
|
115
|
+
"rounded-br-",
|
|
116
|
+
"rounded-bl-",
|
|
117
|
+
"rounded-t-",
|
|
118
|
+
"rounded-r-",
|
|
119
|
+
"rounded-b-",
|
|
120
|
+
"rounded-l-",
|
|
121
|
+
"rounded-",
|
|
122
|
+
"ring-offset-",
|
|
123
|
+
"ring-",
|
|
124
|
+
"outline-offset-",
|
|
125
|
+
"outline-",
|
|
126
|
+
"shadow-",
|
|
127
|
+
"opacity-",
|
|
128
|
+
"duration-",
|
|
129
|
+
"delay-",
|
|
130
|
+
"ease-",
|
|
131
|
+
"cursor-",
|
|
132
|
+
"mix-blend-",
|
|
133
|
+
"animate-",
|
|
134
|
+
"leading-",
|
|
135
|
+
"tracking-",
|
|
136
|
+
"font-",
|
|
137
|
+
"z-",
|
|
138
|
+
"inset-x-",
|
|
139
|
+
"inset-y-",
|
|
140
|
+
"inset-",
|
|
141
|
+
"top-",
|
|
142
|
+
"right-",
|
|
143
|
+
"bottom-",
|
|
144
|
+
"left-",
|
|
145
|
+
"start-",
|
|
146
|
+
"end-",
|
|
147
|
+
"overflow-x-",
|
|
148
|
+
"overflow-y-",
|
|
149
|
+
"overscroll-x-",
|
|
150
|
+
"overscroll-y-",
|
|
151
|
+
"overscroll-",
|
|
152
|
+
"aspect-",
|
|
153
|
+
"divide-color-",
|
|
154
|
+
"space-x-",
|
|
155
|
+
"space-y-",
|
|
156
|
+
"flex-",
|
|
157
|
+
"grow-",
|
|
158
|
+
"shrink-",
|
|
159
|
+
"order-",
|
|
160
|
+
"grid-cols-",
|
|
161
|
+
"grid-rows-",
|
|
162
|
+
"grid-flow-",
|
|
163
|
+
"auto-cols-",
|
|
164
|
+
"auto-rows-",
|
|
165
|
+
"col-span-",
|
|
166
|
+
"col-start-",
|
|
167
|
+
"col-end-",
|
|
168
|
+
"col-",
|
|
169
|
+
"row-span-",
|
|
170
|
+
"row-start-",
|
|
171
|
+
"row-end-",
|
|
172
|
+
"row-",
|
|
173
|
+
"place-items-",
|
|
174
|
+
"place-content-",
|
|
175
|
+
"place-self-",
|
|
176
|
+
"justify-items-",
|
|
177
|
+
"justify-self-",
|
|
178
|
+
"scale-x-",
|
|
179
|
+
"scale-y-",
|
|
180
|
+
"scale-",
|
|
181
|
+
"rotate-",
|
|
182
|
+
"translate-x-",
|
|
183
|
+
"translate-y-",
|
|
184
|
+
"skew-x-",
|
|
185
|
+
"skew-y-",
|
|
186
|
+
"origin-",
|
|
187
|
+
"blur-",
|
|
188
|
+
"brightness-",
|
|
189
|
+
"contrast-",
|
|
190
|
+
"grayscale-",
|
|
191
|
+
"hue-rotate-",
|
|
192
|
+
"invert-",
|
|
193
|
+
"saturate-",
|
|
194
|
+
"sepia-",
|
|
195
|
+
"drop-shadow-",
|
|
196
|
+
"filter-",
|
|
197
|
+
"backdrop-blur-",
|
|
198
|
+
"backdrop-brightness-",
|
|
199
|
+
"backdrop-contrast-",
|
|
200
|
+
"backdrop-grayscale-",
|
|
201
|
+
"backdrop-hue-rotate-",
|
|
202
|
+
"backdrop-invert-",
|
|
203
|
+
"backdrop-opacity-",
|
|
204
|
+
"backdrop-saturate-",
|
|
205
|
+
"backdrop-sepia-",
|
|
206
|
+
"backdrop-filter-",
|
|
207
|
+
"decoration-",
|
|
208
|
+
"underline-offset-",
|
|
209
|
+
"indent-",
|
|
210
|
+
"from-",
|
|
211
|
+
"via-",
|
|
212
|
+
"to-"
|
|
213
|
+
];
|
|
214
|
+
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
215
|
+
function isSafeArbitraryValue(value) {
|
|
216
|
+
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
337
217
|
}
|
|
338
|
-
function
|
|
339
|
-
|
|
218
|
+
function splitRespectingBrackets(token) {
|
|
219
|
+
const parts = [];
|
|
220
|
+
let depth = 0;
|
|
221
|
+
let start = 0;
|
|
222
|
+
for (let i = 0; i < token.length; i++) {
|
|
223
|
+
const ch = token[i];
|
|
224
|
+
if (ch === "[") depth += 1;
|
|
225
|
+
else if (ch === "]") depth -= 1;
|
|
226
|
+
else if (ch === ":" && depth <= 0) {
|
|
227
|
+
parts.push(token.slice(start, i));
|
|
228
|
+
start = i + 1;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
parts.push(token.slice(start));
|
|
232
|
+
return parts;
|
|
340
233
|
}
|
|
341
|
-
function
|
|
342
|
-
|
|
234
|
+
function parseClass(token) {
|
|
235
|
+
const parts = splitRespectingBrackets(token);
|
|
236
|
+
let base = parts.pop() ?? token;
|
|
237
|
+
const modifiers = parts;
|
|
238
|
+
const important = base.startsWith("!");
|
|
239
|
+
if (important) {
|
|
240
|
+
base = base.slice(1);
|
|
241
|
+
}
|
|
242
|
+
const negative = base.startsWith("-");
|
|
243
|
+
if (negative) {
|
|
244
|
+
base = base.slice(1);
|
|
245
|
+
}
|
|
246
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
247
|
+
const raw = base.slice(1, -1);
|
|
248
|
+
const colonIdx = raw.indexOf(":");
|
|
249
|
+
if (colonIdx !== -1) {
|
|
250
|
+
const property = raw.slice(0, colonIdx);
|
|
251
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
252
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
253
|
+
const value = rawValue.replace(/_/g, " ");
|
|
254
|
+
return {
|
|
255
|
+
modifiers,
|
|
256
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
257
|
+
value: `${property}:${value}`,
|
|
258
|
+
isArbitrary: true,
|
|
259
|
+
important,
|
|
260
|
+
negative,
|
|
261
|
+
original: token
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
267
|
+
if (!base.startsWith(prefix)) continue;
|
|
268
|
+
const value = base.slice(prefix.length);
|
|
269
|
+
if (value === "") continue;
|
|
270
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
271
|
+
const raw = value.slice(1, -1);
|
|
272
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
273
|
+
continue;
|
|
274
|
+
}
|
|
275
|
+
const spaced = raw.replace(/_/g, " ");
|
|
276
|
+
return {
|
|
277
|
+
modifiers,
|
|
278
|
+
utility: prefix.slice(0, -1),
|
|
279
|
+
value: spaced,
|
|
280
|
+
isArbitrary: true,
|
|
281
|
+
important,
|
|
282
|
+
negative,
|
|
283
|
+
original: token
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return {
|
|
287
|
+
modifiers,
|
|
288
|
+
utility: prefix.slice(0, -1),
|
|
289
|
+
value,
|
|
290
|
+
isArbitrary: false,
|
|
291
|
+
important,
|
|
292
|
+
negative,
|
|
293
|
+
original: token
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
modifiers,
|
|
298
|
+
utility: base,
|
|
299
|
+
value: null,
|
|
300
|
+
isArbitrary: false,
|
|
301
|
+
important,
|
|
302
|
+
negative,
|
|
303
|
+
original: token
|
|
304
|
+
};
|
|
343
305
|
}
|
|
344
306
|
|
|
345
|
-
// src/
|
|
346
|
-
|
|
307
|
+
// src/jsEngine/shared.ts
|
|
308
|
+
function decl(property, value) {
|
|
309
|
+
return { property, value };
|
|
310
|
+
}
|
|
311
|
+
function spacingPx(theme, value) {
|
|
312
|
+
const fromTable = theme.spacing[value];
|
|
313
|
+
if (fromTable !== void 0) return fromTable;
|
|
314
|
+
const n = Number(value);
|
|
315
|
+
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
316
|
+
}
|
|
317
|
+
function resolveLength(theme, parsed) {
|
|
318
|
+
if (parsed.negative) return null;
|
|
319
|
+
const value = parsed.value;
|
|
320
|
+
if (value === null) return null;
|
|
321
|
+
if (parsed.isArbitrary) return value;
|
|
322
|
+
if (value === "full") return "100%";
|
|
323
|
+
if (value === "auto") return "auto";
|
|
324
|
+
const px = spacingPx(theme, value);
|
|
325
|
+
return px === void 0 ? null : `${px}px`;
|
|
326
|
+
}
|
|
327
|
+
function resolveNegatableLength(theme, parsed) {
|
|
328
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
329
|
+
if (parsed.isArbitrary) return null;
|
|
330
|
+
const value = parsed.value;
|
|
331
|
+
if (value === null) return null;
|
|
332
|
+
const px = spacingPx(theme, value);
|
|
333
|
+
if (px === void 0) return null;
|
|
334
|
+
if (px === 0) return "0px";
|
|
335
|
+
return `-${px}px`;
|
|
336
|
+
}
|
|
337
|
+
function resolvePercent(parsed) {
|
|
338
|
+
if (parsed.negative) return null;
|
|
339
|
+
const value = parsed.value;
|
|
340
|
+
if (value === null) return null;
|
|
341
|
+
if (parsed.isArbitrary) return value;
|
|
342
|
+
const pct = Number(value);
|
|
343
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
344
|
+
return String(pct / 100);
|
|
345
|
+
}
|
|
347
346
|
|
|
348
|
-
// src/
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
function systemPrefersDark() {
|
|
352
|
-
return import_react_native.Appearance.getColorScheme() === "dark";
|
|
353
|
-
}
|
|
354
|
-
function resolveIsDark(m) {
|
|
355
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
356
|
-
}
|
|
357
|
-
var mode = "system";
|
|
358
|
-
var isDark = resolveIsDark(mode);
|
|
359
|
-
var hasExplicitChoice = false;
|
|
360
|
-
var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
|
|
361
|
-
if (mode !== "system") return;
|
|
362
|
-
isDark = colorScheme === "dark";
|
|
363
|
-
notify();
|
|
364
|
-
});
|
|
365
|
-
function notify() {
|
|
366
|
-
for (const listener of listeners) listener();
|
|
347
|
+
// src/jsEngine/resolvers/layout.ts
|
|
348
|
+
function negateRaw(value, negative) {
|
|
349
|
+
return negative ? `-${value}` : value;
|
|
367
350
|
}
|
|
368
|
-
function
|
|
369
|
-
|
|
351
|
+
function overflowAxisValue(property, value) {
|
|
352
|
+
switch (value) {
|
|
353
|
+
case "auto":
|
|
354
|
+
case "hidden":
|
|
355
|
+
case "clip":
|
|
356
|
+
case "visible":
|
|
357
|
+
case "scroll":
|
|
358
|
+
return [decl(property, value)];
|
|
359
|
+
default:
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
370
362
|
}
|
|
371
|
-
function
|
|
372
|
-
|
|
363
|
+
function overscrollValue(property, value) {
|
|
364
|
+
switch (value) {
|
|
365
|
+
case "auto":
|
|
366
|
+
case "contain":
|
|
367
|
+
case "none":
|
|
368
|
+
return [decl(property, value)];
|
|
369
|
+
default:
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
373
372
|
}
|
|
374
|
-
function
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
373
|
+
function resolve(parsed, theme) {
|
|
374
|
+
switch (parsed.utility) {
|
|
375
|
+
case "flex":
|
|
376
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
377
|
+
case "grid":
|
|
378
|
+
return [decl("display", "grid")];
|
|
379
|
+
case "block":
|
|
380
|
+
return [decl("display", "block")];
|
|
381
|
+
case "inline-block":
|
|
382
|
+
return [decl("display", "inline-block")];
|
|
383
|
+
case "inline":
|
|
384
|
+
return [decl("display", "inline")];
|
|
385
|
+
case "inline-flex":
|
|
386
|
+
return [decl("display", "inline-flex")];
|
|
387
|
+
case "inline-grid":
|
|
388
|
+
return [decl("display", "inline-grid")];
|
|
389
|
+
case "contents":
|
|
390
|
+
return [decl("display", "contents")];
|
|
391
|
+
case "flow-root":
|
|
392
|
+
return [decl("display", "flow-root")];
|
|
393
|
+
case "hidden":
|
|
394
|
+
return [decl("display", "none")];
|
|
395
|
+
case "@container":
|
|
396
|
+
return [decl("container-type", "inline-size")];
|
|
397
|
+
case "items-center":
|
|
398
|
+
return [decl("align-items", "center")];
|
|
399
|
+
case "items-start":
|
|
400
|
+
return [decl("align-items", "flex-start")];
|
|
401
|
+
case "items-end":
|
|
402
|
+
return [decl("align-items", "flex-end")];
|
|
403
|
+
case "items-baseline":
|
|
404
|
+
return [decl("align-items", "baseline")];
|
|
405
|
+
case "items-stretch":
|
|
406
|
+
return [decl("align-items", "stretch")];
|
|
407
|
+
case "justify-center":
|
|
408
|
+
return [decl("justify-content", "center")];
|
|
409
|
+
case "justify-start":
|
|
410
|
+
return [decl("justify-content", "flex-start")];
|
|
411
|
+
case "justify-end":
|
|
412
|
+
return [decl("justify-content", "flex-end")];
|
|
413
|
+
case "justify-between":
|
|
414
|
+
return [decl("justify-content", "space-between")];
|
|
415
|
+
case "justify-around":
|
|
416
|
+
return [decl("justify-content", "space-around")];
|
|
417
|
+
case "justify-evenly":
|
|
418
|
+
return [decl("justify-content", "space-evenly")];
|
|
419
|
+
case "justify-normal":
|
|
420
|
+
return [decl("justify-content", "normal")];
|
|
421
|
+
case "justify-stretch":
|
|
422
|
+
return [decl("justify-content", "stretch")];
|
|
423
|
+
case "content-normal":
|
|
424
|
+
return [decl("align-content", "normal")];
|
|
425
|
+
case "content-start":
|
|
426
|
+
return [decl("align-content", "flex-start")];
|
|
427
|
+
case "content-end":
|
|
428
|
+
return [decl("align-content", "flex-end")];
|
|
429
|
+
case "content-center":
|
|
430
|
+
return [decl("align-content", "center")];
|
|
431
|
+
case "content-between":
|
|
432
|
+
return [decl("align-content", "space-between")];
|
|
433
|
+
case "content-around":
|
|
434
|
+
return [decl("align-content", "space-around")];
|
|
435
|
+
case "content-evenly":
|
|
436
|
+
return [decl("align-content", "space-evenly")];
|
|
437
|
+
case "content-stretch":
|
|
438
|
+
return [decl("align-content", "stretch")];
|
|
439
|
+
case "self-auto":
|
|
440
|
+
return [decl("align-self", "auto")];
|
|
441
|
+
case "self-center":
|
|
442
|
+
return [decl("align-self", "center")];
|
|
443
|
+
case "self-start":
|
|
444
|
+
return [decl("align-self", "flex-start")];
|
|
445
|
+
case "self-end":
|
|
446
|
+
return [decl("align-self", "flex-end")];
|
|
447
|
+
case "self-stretch":
|
|
448
|
+
return [decl("align-self", "stretch")];
|
|
449
|
+
case "self-baseline":
|
|
450
|
+
return [decl("align-self", "baseline")];
|
|
451
|
+
case "overflow-hidden":
|
|
452
|
+
return [decl("overflow", "hidden")];
|
|
453
|
+
case "overflow-auto":
|
|
454
|
+
return [decl("overflow", "auto")];
|
|
455
|
+
case "overflow-scroll":
|
|
456
|
+
return [decl("overflow", "scroll")];
|
|
457
|
+
case "overflow-visible":
|
|
458
|
+
return [decl("overflow", "visible")];
|
|
459
|
+
case "overflow-clip":
|
|
460
|
+
return [decl("overflow", "clip")];
|
|
461
|
+
case "overflow-x":
|
|
462
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
463
|
+
case "overflow-y":
|
|
464
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
465
|
+
case "overscroll":
|
|
466
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
467
|
+
case "overscroll-x":
|
|
468
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
469
|
+
case "overscroll-y":
|
|
470
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
471
|
+
case "static":
|
|
472
|
+
return [decl("position", "static")];
|
|
473
|
+
case "relative":
|
|
474
|
+
return [decl("position", "relative")];
|
|
475
|
+
case "absolute":
|
|
476
|
+
return [decl("position", "absolute")];
|
|
477
|
+
case "fixed":
|
|
478
|
+
return [decl("position", "fixed")];
|
|
479
|
+
case "sticky":
|
|
480
|
+
return [decl("position", "sticky")];
|
|
481
|
+
case "z":
|
|
482
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
483
|
+
case "order":
|
|
484
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
485
|
+
case "grow":
|
|
486
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
487
|
+
case "shrink":
|
|
488
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
489
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
490
|
+
// convention ("-top-4") — see resolveNegatableLength's own doc comment.
|
|
491
|
+
case "top": {
|
|
492
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
493
|
+
return v === null ? null : [decl("top", v)];
|
|
494
|
+
}
|
|
495
|
+
case "right": {
|
|
496
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
497
|
+
return v === null ? null : [decl("right", v)];
|
|
498
|
+
}
|
|
499
|
+
case "bottom": {
|
|
500
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
501
|
+
return v === null ? null : [decl("bottom", v)];
|
|
502
|
+
}
|
|
503
|
+
case "left": {
|
|
504
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
505
|
+
return v === null ? null : [decl("left", v)];
|
|
506
|
+
}
|
|
507
|
+
case "inset": {
|
|
508
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
509
|
+
return v === null ? null : [decl("inset", v)];
|
|
510
|
+
}
|
|
511
|
+
case "inset-x": {
|
|
512
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
513
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
514
|
+
}
|
|
515
|
+
case "inset-y": {
|
|
516
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
517
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
518
|
+
}
|
|
519
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
520
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
521
|
+
case "start": {
|
|
522
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
523
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
524
|
+
}
|
|
525
|
+
case "end": {
|
|
526
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
527
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
528
|
+
}
|
|
529
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
530
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
531
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
532
|
+
// "aspect" arm.
|
|
533
|
+
case "aspect": {
|
|
534
|
+
const value = parsed.value;
|
|
535
|
+
if (value === null) return null;
|
|
536
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
537
|
+
switch (value) {
|
|
538
|
+
case "square":
|
|
539
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
540
|
+
case "video":
|
|
541
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
542
|
+
case "auto":
|
|
543
|
+
return [decl("aspect-ratio", "auto")];
|
|
544
|
+
default:
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
default:
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
function resolveFlex(parsed, web) {
|
|
553
|
+
if (parsed.utility !== "flex") return null;
|
|
554
|
+
const value = parsed.value;
|
|
555
|
+
if (value === null) return null;
|
|
556
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
557
|
+
switch (value) {
|
|
558
|
+
case "row":
|
|
559
|
+
return [decl("flex-direction", "row")];
|
|
560
|
+
case "col":
|
|
561
|
+
return [decl("flex-direction", "column")];
|
|
562
|
+
case "row-reverse":
|
|
563
|
+
return [decl("flex-direction", "row-reverse")];
|
|
564
|
+
case "col-reverse":
|
|
565
|
+
return [decl("flex-direction", "column-reverse")];
|
|
566
|
+
case "wrap":
|
|
567
|
+
return [decl("flex-wrap", "wrap")];
|
|
568
|
+
case "wrap-reverse":
|
|
569
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
570
|
+
case "nowrap":
|
|
571
|
+
return [decl("flex-wrap", "nowrap")];
|
|
572
|
+
case "1":
|
|
573
|
+
return [decl("flex", "1")];
|
|
574
|
+
case "auto":
|
|
575
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
576
|
+
case "initial":
|
|
577
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
578
|
+
case "none":
|
|
579
|
+
return [decl("flex", web ? "none" : "0")];
|
|
580
|
+
case "grow":
|
|
581
|
+
return [decl("flex-grow", "1")];
|
|
582
|
+
case "grow-0":
|
|
583
|
+
return [decl("flex-grow", "0")];
|
|
584
|
+
case "shrink":
|
|
585
|
+
return [decl("flex-shrink", "1")];
|
|
586
|
+
case "shrink-0":
|
|
587
|
+
return [decl("flex-shrink", "0")];
|
|
588
|
+
default:
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
379
591
|
}
|
|
380
|
-
|
|
381
|
-
|
|
592
|
+
|
|
593
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
594
|
+
function namedSize(key) {
|
|
595
|
+
switch (key) {
|
|
596
|
+
case "sm":
|
|
597
|
+
return "24rem";
|
|
598
|
+
case "md":
|
|
599
|
+
return "28rem";
|
|
600
|
+
case "lg":
|
|
601
|
+
return "32rem";
|
|
602
|
+
case "xl":
|
|
603
|
+
return "36rem";
|
|
604
|
+
case "2xl":
|
|
605
|
+
return "42rem";
|
|
606
|
+
case "3xl":
|
|
607
|
+
return "48rem";
|
|
608
|
+
case "4xl":
|
|
609
|
+
return "56rem";
|
|
610
|
+
case "5xl":
|
|
611
|
+
return "64rem";
|
|
612
|
+
case "6xl":
|
|
613
|
+
return "72rem";
|
|
614
|
+
case "7xl":
|
|
615
|
+
return "80rem";
|
|
616
|
+
case "8xl":
|
|
617
|
+
return "88rem";
|
|
618
|
+
case "9xl":
|
|
619
|
+
return "96rem";
|
|
620
|
+
default:
|
|
621
|
+
return null;
|
|
622
|
+
}
|
|
382
623
|
}
|
|
383
|
-
function
|
|
384
|
-
|
|
385
|
-
|
|
624
|
+
function fractionPercent(value) {
|
|
625
|
+
const slashIdx = value.indexOf("/");
|
|
626
|
+
if (slashIdx === -1) return null;
|
|
627
|
+
const numStr = value.slice(0, slashIdx);
|
|
628
|
+
const denStr = value.slice(slashIdx + 1);
|
|
629
|
+
const num = Number(numStr);
|
|
630
|
+
const den = Number(denStr);
|
|
631
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
632
|
+
if (den === 0) return null;
|
|
633
|
+
const pct = num / den * 100;
|
|
634
|
+
const formatted = pct.toFixed(6);
|
|
635
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
636
|
+
return `${trimmed}%`;
|
|
386
637
|
}
|
|
387
|
-
function
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
638
|
+
function cssSizeKeyword(key) {
|
|
639
|
+
switch (key) {
|
|
640
|
+
case "min":
|
|
641
|
+
return "min-content";
|
|
642
|
+
case "max":
|
|
643
|
+
return "max-content";
|
|
644
|
+
case "fit":
|
|
645
|
+
return "fit-content";
|
|
646
|
+
default:
|
|
647
|
+
return null;
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
function resolveSize(theme, parsed) {
|
|
651
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
652
|
+
const named = namedSize(parsed.value);
|
|
653
|
+
if (named !== null) return named;
|
|
654
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
655
|
+
if (kw !== null) return kw;
|
|
656
|
+
const fraction = fractionPercent(parsed.value);
|
|
657
|
+
if (fraction !== null) return fraction;
|
|
658
|
+
}
|
|
659
|
+
return resolveLength(theme, parsed);
|
|
660
|
+
}
|
|
661
|
+
function resolve2(parsed, theme) {
|
|
662
|
+
const length = () => resolveLength(theme, parsed);
|
|
663
|
+
const size = () => resolveSize(theme, parsed);
|
|
664
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
665
|
+
switch (parsed.utility) {
|
|
666
|
+
case "p": {
|
|
667
|
+
const v = length();
|
|
668
|
+
return v === null ? null : [decl("padding", v)];
|
|
669
|
+
}
|
|
670
|
+
case "px": {
|
|
671
|
+
const v = length();
|
|
672
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
673
|
+
}
|
|
674
|
+
case "py": {
|
|
675
|
+
const v = length();
|
|
676
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
677
|
+
}
|
|
678
|
+
case "pt": {
|
|
679
|
+
const v = length();
|
|
680
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
681
|
+
}
|
|
682
|
+
case "pr": {
|
|
683
|
+
const v = length();
|
|
684
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
685
|
+
}
|
|
686
|
+
case "pb": {
|
|
687
|
+
const v = length();
|
|
688
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
689
|
+
}
|
|
690
|
+
case "pl": {
|
|
691
|
+
const v = length();
|
|
692
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
693
|
+
}
|
|
694
|
+
case "m": {
|
|
695
|
+
const v = negatableLength();
|
|
696
|
+
return v === null ? null : [decl("margin", v)];
|
|
697
|
+
}
|
|
698
|
+
case "mx": {
|
|
699
|
+
const v = negatableLength();
|
|
700
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
701
|
+
}
|
|
702
|
+
case "my": {
|
|
703
|
+
const v = negatableLength();
|
|
704
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
705
|
+
}
|
|
706
|
+
case "mt": {
|
|
707
|
+
const v = negatableLength();
|
|
708
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
709
|
+
}
|
|
710
|
+
case "mr": {
|
|
711
|
+
const v = negatableLength();
|
|
712
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
713
|
+
}
|
|
714
|
+
case "mb": {
|
|
715
|
+
const v = negatableLength();
|
|
716
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
717
|
+
}
|
|
718
|
+
case "ml": {
|
|
719
|
+
const v = negatableLength();
|
|
720
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
721
|
+
}
|
|
722
|
+
case "gap": {
|
|
723
|
+
const v = length();
|
|
724
|
+
return v === null ? null : [decl("gap", v)];
|
|
725
|
+
}
|
|
726
|
+
case "gap-x": {
|
|
727
|
+
const v = length();
|
|
728
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
729
|
+
}
|
|
730
|
+
case "gap-y": {
|
|
731
|
+
const v = length();
|
|
732
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
733
|
+
}
|
|
734
|
+
case "w": {
|
|
735
|
+
const v = size();
|
|
736
|
+
return v === null ? null : [decl("width", v)];
|
|
737
|
+
}
|
|
738
|
+
case "h": {
|
|
739
|
+
const v = size();
|
|
740
|
+
return v === null ? null : [decl("height", v)];
|
|
741
|
+
}
|
|
742
|
+
case "min-w": {
|
|
743
|
+
const v = size();
|
|
744
|
+
return v === null ? null : [decl("min-width", v)];
|
|
745
|
+
}
|
|
746
|
+
case "max-w": {
|
|
747
|
+
const v = size();
|
|
748
|
+
return v === null ? null : [decl("max-width", v)];
|
|
749
|
+
}
|
|
750
|
+
case "min-h": {
|
|
751
|
+
const v = size();
|
|
752
|
+
return v === null ? null : [decl("min-height", v)];
|
|
753
|
+
}
|
|
754
|
+
case "max-h": {
|
|
755
|
+
const v = size();
|
|
756
|
+
return v === null ? null : [decl("max-height", v)];
|
|
757
|
+
}
|
|
758
|
+
case "size": {
|
|
759
|
+
const v = size();
|
|
760
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
761
|
+
}
|
|
762
|
+
case "basis": {
|
|
763
|
+
const v = size();
|
|
764
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
765
|
+
}
|
|
766
|
+
default:
|
|
767
|
+
return null;
|
|
768
|
+
}
|
|
392
769
|
}
|
|
393
770
|
|
|
394
|
-
// src/
|
|
395
|
-
function
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
771
|
+
// src/jsEngine/resolvers/color.ts
|
|
772
|
+
function lookupHex(theme, key) {
|
|
773
|
+
const entry = theme.colors[key];
|
|
774
|
+
return typeof entry === "string" ? entry : null;
|
|
775
|
+
}
|
|
776
|
+
function hexToRgb(hex) {
|
|
777
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
778
|
+
if (!m) return null;
|
|
779
|
+
let h = m[1];
|
|
780
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
781
|
+
const n = parseInt(h, 16);
|
|
782
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
783
|
+
}
|
|
784
|
+
function splitOpacity(value) {
|
|
785
|
+
const slash = value.lastIndexOf("/");
|
|
786
|
+
if (slash === -1) return [value, null];
|
|
787
|
+
const opacityText = value.slice(slash + 1);
|
|
788
|
+
const n = Number(opacityText);
|
|
789
|
+
if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
|
|
790
|
+
return [value.slice(0, slash), n];
|
|
791
|
+
}
|
|
792
|
+
return [value, null];
|
|
793
|
+
}
|
|
794
|
+
function colorValue(theme, parsed) {
|
|
795
|
+
const value = parsed.value;
|
|
796
|
+
if (value === null) return null;
|
|
797
|
+
if (parsed.isArbitrary) return value;
|
|
798
|
+
const [name, opacity] = splitOpacity(value);
|
|
799
|
+
const hex = lookupHex(theme, name);
|
|
800
|
+
if (hex === null) return null;
|
|
801
|
+
if (opacity === null) return hex;
|
|
802
|
+
const rgb = hexToRgb(hex);
|
|
803
|
+
if (rgb === null) return hex;
|
|
804
|
+
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
400
805
|
}
|
|
401
806
|
|
|
402
|
-
// src/
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
807
|
+
// src/jsEngine/resolvers/border.ts
|
|
808
|
+
function radiusSize(key) {
|
|
809
|
+
switch (key) {
|
|
810
|
+
case "none":
|
|
811
|
+
return "0px";
|
|
812
|
+
case "sm":
|
|
813
|
+
return "0.125rem";
|
|
814
|
+
case "md":
|
|
815
|
+
return "0.375rem";
|
|
816
|
+
case "lg":
|
|
817
|
+
return "0.5rem";
|
|
818
|
+
case "xl":
|
|
819
|
+
return "0.75rem";
|
|
820
|
+
case "2xl":
|
|
821
|
+
return "1rem";
|
|
822
|
+
case "3xl":
|
|
823
|
+
return "1.5rem";
|
|
824
|
+
case "full":
|
|
825
|
+
return "9999px";
|
|
826
|
+
default:
|
|
827
|
+
return null;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
function borderSideProperty(side) {
|
|
831
|
+
switch (side) {
|
|
832
|
+
case "t":
|
|
833
|
+
return "border-top";
|
|
834
|
+
case "r":
|
|
835
|
+
return "border-right";
|
|
836
|
+
case "b":
|
|
837
|
+
return "border-bottom";
|
|
838
|
+
case "l":
|
|
839
|
+
return "border-left";
|
|
840
|
+
default:
|
|
841
|
+
return null;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
function borderValue(theme, parsed) {
|
|
845
|
+
const value = parsed.value;
|
|
846
|
+
if (value === null) return null;
|
|
847
|
+
if (!parsed.isArbitrary) {
|
|
848
|
+
const side = borderSideProperty(value);
|
|
849
|
+
if (side !== null) {
|
|
850
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
851
|
+
}
|
|
852
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
853
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
854
|
+
}
|
|
855
|
+
if (parsed.isArbitrary) {
|
|
856
|
+
return [decl("border-width", value)];
|
|
857
|
+
}
|
|
858
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
859
|
+
const v = resolveLength(theme, parsed);
|
|
860
|
+
return v === null ? null : [decl("border-width", v)];
|
|
861
|
+
}
|
|
862
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
863
|
+
return [decl("border-style", value)];
|
|
864
|
+
}
|
|
865
|
+
const color = colorValue(theme, parsed);
|
|
866
|
+
return color === null ? null : [decl("border-color", color)];
|
|
867
|
+
}
|
|
868
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
869
|
+
const value = parsed.value;
|
|
870
|
+
if (value === null) return null;
|
|
871
|
+
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
872
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
873
|
+
const v = resolveLength(theme, parsed);
|
|
874
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
875
|
+
}
|
|
876
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
877
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
878
|
+
}
|
|
879
|
+
const color = colorValue(theme, parsed);
|
|
880
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
881
|
+
}
|
|
882
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
883
|
+
const value = parsed.value;
|
|
884
|
+
if (value === null) return null;
|
|
885
|
+
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
886
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
887
|
+
const v = resolveLength(theme, parsed);
|
|
888
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
889
|
+
}
|
|
890
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
891
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
892
|
+
}
|
|
893
|
+
const color = colorValue(theme, parsed);
|
|
894
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
895
|
+
}
|
|
896
|
+
function radiusProperties(side) {
|
|
897
|
+
switch (side) {
|
|
898
|
+
case "t":
|
|
899
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
900
|
+
case "r":
|
|
901
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
902
|
+
case "b":
|
|
903
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
904
|
+
case "l":
|
|
905
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
906
|
+
case "tl":
|
|
907
|
+
return ["border-top-left-radius"];
|
|
908
|
+
case "tr":
|
|
909
|
+
return ["border-top-right-radius"];
|
|
910
|
+
case "br":
|
|
911
|
+
return ["border-bottom-right-radius"];
|
|
912
|
+
case "bl":
|
|
913
|
+
return ["border-bottom-left-radius"];
|
|
914
|
+
default:
|
|
915
|
+
return null;
|
|
916
|
+
}
|
|
917
|
+
}
|
|
918
|
+
function resolveRadiusValue(theme, parsed) {
|
|
919
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
920
|
+
const size = radiusSize(parsed.value);
|
|
921
|
+
if (size !== null) return size;
|
|
922
|
+
}
|
|
923
|
+
return resolveLength(theme, parsed);
|
|
924
|
+
}
|
|
925
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
926
|
+
const properties = radiusProperties(side);
|
|
927
|
+
if (properties === null) return null;
|
|
928
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
929
|
+
if (value === null) return null;
|
|
930
|
+
return properties.map((p) => decl(p, value));
|
|
931
|
+
}
|
|
932
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
933
|
+
function outlineWidthValue(key) {
|
|
934
|
+
switch (key) {
|
|
935
|
+
case "0":
|
|
936
|
+
return "0px";
|
|
937
|
+
case "1":
|
|
938
|
+
return "1px";
|
|
939
|
+
case "2":
|
|
940
|
+
return "2px";
|
|
941
|
+
case "4":
|
|
942
|
+
return "4px";
|
|
943
|
+
case "8":
|
|
944
|
+
return "8px";
|
|
945
|
+
default:
|
|
946
|
+
return null;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function outlineValue(theme, parsed) {
|
|
950
|
+
const value = parsed.value;
|
|
951
|
+
if (value === null) return null;
|
|
952
|
+
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
953
|
+
const w = outlineWidthValue(value);
|
|
954
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
955
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
956
|
+
const color = colorValue(theme, parsed);
|
|
957
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
958
|
+
}
|
|
959
|
+
function outlineOffsetValue(parsed) {
|
|
960
|
+
const value = parsed.value;
|
|
961
|
+
if (value === null) return null;
|
|
962
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
963
|
+
const w = outlineWidthValue(value);
|
|
964
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
965
|
+
}
|
|
966
|
+
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))";
|
|
967
|
+
function ringWidth(key) {
|
|
968
|
+
switch (key) {
|
|
969
|
+
case "0":
|
|
970
|
+
return "0px";
|
|
971
|
+
case "1":
|
|
972
|
+
return "1px";
|
|
973
|
+
case "2":
|
|
974
|
+
return "2px";
|
|
975
|
+
case "4":
|
|
976
|
+
return "4px";
|
|
977
|
+
case "8":
|
|
978
|
+
return "8px";
|
|
979
|
+
default:
|
|
980
|
+
return null;
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
function ringValue(theme, parsed) {
|
|
984
|
+
const value = parsed.value;
|
|
985
|
+
if (value === null) return null;
|
|
986
|
+
if (value === "inset") {
|
|
987
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
988
|
+
}
|
|
989
|
+
if (!parsed.isArbitrary) {
|
|
990
|
+
const w = ringWidth(value);
|
|
991
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
992
|
+
}
|
|
993
|
+
const color = colorValue(theme, parsed);
|
|
994
|
+
if (color === null) return null;
|
|
995
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
996
|
+
}
|
|
997
|
+
function ringOffsetValue(theme, parsed) {
|
|
998
|
+
const value = parsed.value;
|
|
999
|
+
if (value === null) return null;
|
|
1000
|
+
if (!parsed.isArbitrary) {
|
|
1001
|
+
const w = ringWidth(value);
|
|
1002
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1003
|
+
}
|
|
1004
|
+
const color = colorValue(theme, parsed);
|
|
1005
|
+
if (color === null) return null;
|
|
1006
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1007
|
+
}
|
|
1008
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1009
|
+
function resolve3(parsed, theme) {
|
|
1010
|
+
switch (parsed.utility) {
|
|
1011
|
+
case "border":
|
|
1012
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1013
|
+
return borderValue(theme, parsed);
|
|
1014
|
+
case "border-t":
|
|
1015
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1016
|
+
case "border-r":
|
|
1017
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1018
|
+
case "border-b":
|
|
1019
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1020
|
+
case "border-l":
|
|
1021
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1022
|
+
case "border-x":
|
|
1023
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1024
|
+
case "border-y":
|
|
1025
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1026
|
+
case "rounded": {
|
|
1027
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1028
|
+
const value = parsed.value;
|
|
1029
|
+
if (!parsed.isArbitrary) {
|
|
1030
|
+
const size = radiusSize(value);
|
|
1031
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1032
|
+
}
|
|
1033
|
+
const v = resolveLength(theme, parsed);
|
|
1034
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1035
|
+
}
|
|
1036
|
+
case "ring":
|
|
1037
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1038
|
+
return ringValue(theme, parsed);
|
|
1039
|
+
case "ring-offset":
|
|
1040
|
+
return ringOffsetValue(theme, parsed);
|
|
1041
|
+
case "outline":
|
|
1042
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1043
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1044
|
+
return outlineValue(theme, parsed);
|
|
1045
|
+
case "outline-offset":
|
|
1046
|
+
return outlineOffsetValue(parsed);
|
|
1047
|
+
default:
|
|
1048
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1049
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1050
|
+
}
|
|
1051
|
+
return null;
|
|
1052
|
+
}
|
|
406
1053
|
}
|
|
407
1054
|
|
|
408
|
-
// src/
|
|
409
|
-
|
|
1055
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1056
|
+
function textSize(key) {
|
|
1057
|
+
switch (key) {
|
|
1058
|
+
case "xs":
|
|
1059
|
+
return "0.75rem";
|
|
1060
|
+
case "sm":
|
|
1061
|
+
return "0.875rem";
|
|
1062
|
+
case "base":
|
|
1063
|
+
return "1rem";
|
|
1064
|
+
case "lg":
|
|
1065
|
+
return "1.125rem";
|
|
1066
|
+
case "xl":
|
|
1067
|
+
return "1.25rem";
|
|
1068
|
+
case "2xl":
|
|
1069
|
+
return "1.5rem";
|
|
1070
|
+
case "3xl":
|
|
1071
|
+
return "1.875rem";
|
|
1072
|
+
case "4xl":
|
|
1073
|
+
return "2.25rem";
|
|
1074
|
+
case "5xl":
|
|
1075
|
+
return "3rem";
|
|
1076
|
+
case "6xl":
|
|
1077
|
+
return "3.75rem";
|
|
1078
|
+
case "7xl":
|
|
1079
|
+
return "4.5rem";
|
|
1080
|
+
case "8xl":
|
|
1081
|
+
return "6rem";
|
|
1082
|
+
case "9xl":
|
|
1083
|
+
return "8rem";
|
|
1084
|
+
default:
|
|
1085
|
+
return null;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
function lineHeightSize(key) {
|
|
1089
|
+
switch (key) {
|
|
1090
|
+
case "3":
|
|
1091
|
+
return "0.75rem";
|
|
1092
|
+
case "4":
|
|
1093
|
+
return "1rem";
|
|
1094
|
+
case "5":
|
|
1095
|
+
return "1.25rem";
|
|
1096
|
+
case "6":
|
|
1097
|
+
return "1.5rem";
|
|
1098
|
+
case "7":
|
|
1099
|
+
return "1.75rem";
|
|
1100
|
+
case "8":
|
|
1101
|
+
return "2rem";
|
|
1102
|
+
case "9":
|
|
1103
|
+
return "2.25rem";
|
|
1104
|
+
case "10":
|
|
1105
|
+
return "2.5rem";
|
|
1106
|
+
default:
|
|
1107
|
+
return null;
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
function textAlign(key) {
|
|
1111
|
+
switch (key) {
|
|
1112
|
+
case "left":
|
|
1113
|
+
return "left";
|
|
1114
|
+
case "center":
|
|
1115
|
+
return "center";
|
|
1116
|
+
case "right":
|
|
1117
|
+
return "right";
|
|
1118
|
+
case "justify":
|
|
1119
|
+
return "justify";
|
|
1120
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
1121
|
+
// as layout.rs's start/end inset properties.
|
|
1122
|
+
case "start":
|
|
1123
|
+
return "start";
|
|
1124
|
+
case "end":
|
|
1125
|
+
return "end";
|
|
1126
|
+
default:
|
|
1127
|
+
return null;
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
function fontWeight(key) {
|
|
1131
|
+
switch (key) {
|
|
1132
|
+
case "thin":
|
|
1133
|
+
return "100";
|
|
1134
|
+
case "extralight":
|
|
1135
|
+
return "200";
|
|
1136
|
+
case "light":
|
|
1137
|
+
return "300";
|
|
1138
|
+
case "normal":
|
|
1139
|
+
return "400";
|
|
1140
|
+
case "medium":
|
|
1141
|
+
return "500";
|
|
1142
|
+
case "semibold":
|
|
1143
|
+
return "600";
|
|
1144
|
+
case "bold":
|
|
1145
|
+
return "700";
|
|
1146
|
+
case "extrabold":
|
|
1147
|
+
return "800";
|
|
1148
|
+
case "black":
|
|
1149
|
+
return "900";
|
|
1150
|
+
default:
|
|
1151
|
+
return null;
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
function fontFamilyValue(theme, key) {
|
|
1155
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
1156
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
1157
|
+
switch (key) {
|
|
1158
|
+
case "sans":
|
|
1159
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
1160
|
+
case "serif":
|
|
1161
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
1162
|
+
case "mono":
|
|
1163
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1164
|
+
default:
|
|
1165
|
+
return null;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
410
1168
|
|
|
411
|
-
// src/
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
1169
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1170
|
+
function nativeShadowValue(key) {
|
|
1171
|
+
switch (key) {
|
|
1172
|
+
case "sm":
|
|
1173
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1174
|
+
case "DEFAULT":
|
|
1175
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1176
|
+
case "md":
|
|
1177
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1178
|
+
case "lg":
|
|
1179
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1180
|
+
case "xl":
|
|
1181
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1182
|
+
case "2xl":
|
|
1183
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1184
|
+
case "none":
|
|
1185
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1186
|
+
default:
|
|
1187
|
+
return null;
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
function nativeShadowDeclarations(parsed) {
|
|
1191
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1192
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1193
|
+
const s = nativeShadowValue(key);
|
|
1194
|
+
if (s === null) return null;
|
|
1195
|
+
return [
|
|
1196
|
+
decl("shadow-color", "#000000"),
|
|
1197
|
+
decl("shadow-offset-x", "0"),
|
|
1198
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1199
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1200
|
+
decl("shadow-radius", String(s.radius)),
|
|
1201
|
+
decl("elevation", String(s.elevation))
|
|
1202
|
+
];
|
|
1203
|
+
}
|
|
1204
|
+
|
|
1205
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1206
|
+
function firstFontName(stack) {
|
|
1207
|
+
const first = stack.split(",")[0] ?? stack;
|
|
1208
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
1209
|
+
}
|
|
1210
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1211
|
+
switch (parsed.utility) {
|
|
1212
|
+
case "font": {
|
|
1213
|
+
if (parsed.value === null) return null;
|
|
1214
|
+
if (parsed.isArbitrary) {
|
|
1215
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
1216
|
+
}
|
|
1217
|
+
const w = fontWeight(parsed.value);
|
|
1218
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
1219
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
1220
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1221
|
+
}
|
|
1222
|
+
case "uppercase":
|
|
1223
|
+
return [decl("text-transform", "uppercase")];
|
|
1224
|
+
case "lowercase":
|
|
1225
|
+
return [decl("text-transform", "lowercase")];
|
|
1226
|
+
case "capitalize":
|
|
1227
|
+
return [decl("text-transform", "capitalize")];
|
|
1228
|
+
case "underline":
|
|
1229
|
+
return [decl("text-decoration-line", "underline")];
|
|
1230
|
+
case "line-through":
|
|
1231
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1232
|
+
case "no-underline":
|
|
1233
|
+
return [decl("text-decoration-line", "none")];
|
|
1234
|
+
case "italic":
|
|
1235
|
+
return [decl("font-style", "italic")];
|
|
1236
|
+
case "not-italic":
|
|
1237
|
+
return [decl("font-style", "normal")];
|
|
1238
|
+
default:
|
|
1239
|
+
return null;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1243
|
+
const value = parsed.value;
|
|
1244
|
+
if (value === null) return null;
|
|
1245
|
+
if (parsed.utility === "leading") {
|
|
1246
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1247
|
+
const v = lineHeightSize(value);
|
|
1248
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1249
|
+
}
|
|
1250
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1251
|
+
return [decl("letter-spacing", value)];
|
|
1252
|
+
}
|
|
1253
|
+
return null;
|
|
1254
|
+
}
|
|
1255
|
+
function nativeHexColor(parsed, theme) {
|
|
1256
|
+
return colorValue(theme, parsed);
|
|
1257
|
+
}
|
|
1258
|
+
function resolveTextNative(parsed, theme) {
|
|
1259
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1260
|
+
const size = textSize(parsed.value);
|
|
1261
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1262
|
+
const align = textAlign(parsed.value);
|
|
1263
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1264
|
+
}
|
|
1265
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1266
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1267
|
+
}
|
|
1268
|
+
function resolveColorNative(parsed, theme) {
|
|
1269
|
+
switch (parsed.utility) {
|
|
1270
|
+
case "bg": {
|
|
1271
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1272
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1273
|
+
}
|
|
1274
|
+
case "text":
|
|
1275
|
+
return resolveTextNative(parsed, theme);
|
|
1276
|
+
default:
|
|
1277
|
+
return null;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
1280
|
+
function resolveOpacityNative(parsed) {
|
|
1281
|
+
if (parsed.utility !== "opacity") return null;
|
|
1282
|
+
const v = resolvePercent(parsed);
|
|
1283
|
+
return v === null ? null : [decl("opacity", v)];
|
|
1284
|
+
}
|
|
1285
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1286
|
+
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);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
// src/jsEngine/calc.ts
|
|
1290
|
+
function reduceConstantMath(raw) {
|
|
1291
|
+
const trimmed = raw.trim();
|
|
1292
|
+
const calc = stripCall(trimmed, "calc");
|
|
1293
|
+
if (calc !== null) {
|
|
1294
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
1295
|
+
}
|
|
1296
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
1297
|
+
if (clamp !== null) {
|
|
1298
|
+
const args = splitTopLevelCommas(clamp);
|
|
1299
|
+
if (args.length !== 3) return null;
|
|
1300
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
1301
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
1302
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
1303
|
+
}
|
|
1304
|
+
const min = stripCall(trimmed, "min");
|
|
1305
|
+
if (min !== null) {
|
|
1306
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1307
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
1308
|
+
}
|
|
1309
|
+
const max = stripCall(trimmed, "max");
|
|
1310
|
+
if (max !== null) {
|
|
1311
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1312
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
1313
|
+
}
|
|
1314
|
+
return null;
|
|
1315
|
+
}
|
|
1316
|
+
function stripCall(raw, name) {
|
|
1317
|
+
if (!raw.startsWith(name)) return null;
|
|
1318
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
1319
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
1320
|
+
return afterName.slice(1, -1);
|
|
1321
|
+
}
|
|
1322
|
+
function splitTopLevelCommas(s) {
|
|
1323
|
+
const parts = [];
|
|
1324
|
+
let depth = 0;
|
|
1325
|
+
let start = 0;
|
|
1326
|
+
for (let i = 0; i < s.length; i++) {
|
|
1327
|
+
const ch = s[i];
|
|
1328
|
+
if (ch === "(") depth++;
|
|
1329
|
+
else if (ch === ")") depth--;
|
|
1330
|
+
else if (ch === "," && depth === 0) {
|
|
1331
|
+
parts.push(s.slice(start, i).trim());
|
|
1332
|
+
start = i + 1;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
parts.push(s.slice(start).trim());
|
|
1336
|
+
return parts;
|
|
1337
|
+
}
|
|
1338
|
+
var Evaluator = class {
|
|
1339
|
+
constructor(s) {
|
|
1340
|
+
this.pos = 0;
|
|
1341
|
+
this.s = s;
|
|
1342
|
+
}
|
|
1343
|
+
parseExprToEnd() {
|
|
1344
|
+
const value = this.expr();
|
|
1345
|
+
if (value === null) return null;
|
|
1346
|
+
this.skipWs();
|
|
1347
|
+
return this.pos === this.s.length ? value : null;
|
|
1348
|
+
}
|
|
1349
|
+
skipWs() {
|
|
1350
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
1351
|
+
}
|
|
1352
|
+
peek() {
|
|
1353
|
+
this.skipWs();
|
|
1354
|
+
return this.s[this.pos];
|
|
1355
|
+
}
|
|
1356
|
+
expr() {
|
|
1357
|
+
let value = this.term();
|
|
1358
|
+
if (value === null) return null;
|
|
1359
|
+
for (; ; ) {
|
|
1360
|
+
const ch = this.peek();
|
|
1361
|
+
if (ch === "+") {
|
|
1362
|
+
this.pos++;
|
|
1363
|
+
const rhs = this.term();
|
|
1364
|
+
if (rhs === null) return null;
|
|
1365
|
+
value += rhs;
|
|
1366
|
+
} else if (ch === "-") {
|
|
1367
|
+
this.pos++;
|
|
1368
|
+
const rhs = this.term();
|
|
1369
|
+
if (rhs === null) return null;
|
|
1370
|
+
value -= rhs;
|
|
1371
|
+
} else {
|
|
1372
|
+
return value;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
}
|
|
1376
|
+
term() {
|
|
1377
|
+
let value = this.factor();
|
|
1378
|
+
if (value === null) return null;
|
|
1379
|
+
for (; ; ) {
|
|
1380
|
+
const ch = this.peek();
|
|
1381
|
+
if (ch === "*") {
|
|
1382
|
+
this.pos++;
|
|
1383
|
+
const rhs = this.factor();
|
|
1384
|
+
if (rhs === null) return null;
|
|
1385
|
+
value *= rhs;
|
|
1386
|
+
} else if (ch === "/") {
|
|
1387
|
+
this.pos++;
|
|
1388
|
+
const divisor = this.factor();
|
|
1389
|
+
if (divisor === null || divisor === 0) return null;
|
|
1390
|
+
value /= divisor;
|
|
1391
|
+
} else {
|
|
1392
|
+
return value;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
factor() {
|
|
1397
|
+
const ch = this.peek();
|
|
1398
|
+
if (ch === void 0) return null;
|
|
1399
|
+
if (ch === "(") {
|
|
1400
|
+
this.pos++;
|
|
1401
|
+
const value = this.expr();
|
|
1402
|
+
if (value === null || this.peek() !== ")") return null;
|
|
1403
|
+
this.pos++;
|
|
1404
|
+
return value;
|
|
1405
|
+
}
|
|
1406
|
+
if (ch === "-") {
|
|
1407
|
+
this.pos++;
|
|
1408
|
+
const value = this.factor();
|
|
1409
|
+
return value === null ? null : -value;
|
|
1410
|
+
}
|
|
1411
|
+
return this.numberWithUnit();
|
|
1412
|
+
}
|
|
1413
|
+
numberWithUnit() {
|
|
1414
|
+
this.skipWs();
|
|
1415
|
+
const start = this.pos;
|
|
1416
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
1417
|
+
if (this.pos === start) return null;
|
|
1418
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
1419
|
+
if (!Number.isFinite(n)) return null;
|
|
1420
|
+
const unitStart = this.pos;
|
|
1421
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
1422
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
1423
|
+
switch (unit) {
|
|
1424
|
+
case "":
|
|
1425
|
+
return n;
|
|
1426
|
+
case "px":
|
|
1427
|
+
return n;
|
|
1428
|
+
case "rem":
|
|
1429
|
+
return n * 16;
|
|
1430
|
+
default:
|
|
1431
|
+
return null;
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
|
|
1436
|
+
// src/jsEngine/resolveStyle.ts
|
|
1437
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1438
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1439
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1440
|
+
if (modifier === "active") return pressed;
|
|
1441
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1442
|
+
const minWidth = theme.screens[modifier];
|
|
1443
|
+
if (minWidth === void 0) return null;
|
|
1444
|
+
return width >= minWidth;
|
|
1445
|
+
}
|
|
1446
|
+
return null;
|
|
1447
|
+
}
|
|
1448
|
+
function kebabToCamel(s) {
|
|
1449
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1450
|
+
}
|
|
1451
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1452
|
+
"padding",
|
|
1453
|
+
"padding-top",
|
|
1454
|
+
"padding-right",
|
|
1455
|
+
"padding-bottom",
|
|
1456
|
+
"padding-left",
|
|
1457
|
+
"margin",
|
|
1458
|
+
"margin-top",
|
|
1459
|
+
"margin-right",
|
|
1460
|
+
"margin-bottom",
|
|
1461
|
+
"margin-left",
|
|
1462
|
+
"gap",
|
|
1463
|
+
"column-gap",
|
|
1464
|
+
"row-gap",
|
|
1465
|
+
"width",
|
|
1466
|
+
"height",
|
|
1467
|
+
"min-width",
|
|
1468
|
+
"max-width",
|
|
1469
|
+
"min-height",
|
|
1470
|
+
"max-height",
|
|
1471
|
+
"top",
|
|
1472
|
+
"right",
|
|
1473
|
+
"bottom",
|
|
1474
|
+
"left",
|
|
1475
|
+
"inset",
|
|
1476
|
+
"border-radius",
|
|
1477
|
+
"border-width",
|
|
1478
|
+
"font-size",
|
|
1479
|
+
"z-index",
|
|
1480
|
+
"line-height",
|
|
1481
|
+
"letter-spacing",
|
|
1482
|
+
"flex",
|
|
1483
|
+
"flex-grow",
|
|
1484
|
+
"flex-shrink",
|
|
1485
|
+
"order",
|
|
1486
|
+
"flex-basis",
|
|
1487
|
+
"shadow-opacity",
|
|
1488
|
+
"shadow-radius",
|
|
1489
|
+
"elevation",
|
|
1490
|
+
"opacity",
|
|
1491
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1492
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1493
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1494
|
+
// "border-width"/"border-radius" forms above.
|
|
1495
|
+
"border-top-width",
|
|
1496
|
+
"border-right-width",
|
|
1497
|
+
"border-bottom-width",
|
|
1498
|
+
"border-left-width",
|
|
1499
|
+
"border-top-left-radius",
|
|
1500
|
+
"border-top-right-radius",
|
|
1501
|
+
"border-bottom-right-radius",
|
|
1502
|
+
"border-bottom-left-radius",
|
|
1503
|
+
"outline-width",
|
|
1504
|
+
"outline-offset"
|
|
1505
|
+
]);
|
|
1506
|
+
function isPlainPercentage(value) {
|
|
1507
|
+
if (!value.endsWith("%")) return false;
|
|
1508
|
+
let digits = value.slice(0, -1);
|
|
1509
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
1510
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
1511
|
+
}
|
|
1512
|
+
function rnStyleValue(property, value) {
|
|
1513
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1514
|
+
return { value, warning: null };
|
|
1515
|
+
}
|
|
1516
|
+
let px = null;
|
|
1517
|
+
if (value.endsWith("px")) {
|
|
1518
|
+
const n = Number(value.slice(0, -2));
|
|
1519
|
+
px = Number.isFinite(n) ? n : null;
|
|
1520
|
+
} else if (value.endsWith("rem")) {
|
|
1521
|
+
const n = Number(value.slice(0, -3));
|
|
1522
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1523
|
+
} else {
|
|
1524
|
+
const n = Number(value);
|
|
1525
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1526
|
+
}
|
|
1527
|
+
if (px !== null) return { value: px, warning: null };
|
|
1528
|
+
if (isPlainPercentage(value)) {
|
|
1529
|
+
return { value, warning: null };
|
|
1530
|
+
}
|
|
1531
|
+
const reduced = reduceConstantMath(value);
|
|
1532
|
+
if (reduced !== null) {
|
|
1533
|
+
return { value: reduced, warning: null };
|
|
1534
|
+
}
|
|
1535
|
+
const warning = `Kbach: "${value}" is not a valid native value for "${property}" \u2014 dropped. calc()/clamp()/min()/max() 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). Use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
1536
|
+
return { value: null, warning };
|
|
1537
|
+
}
|
|
1538
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1539
|
+
const style = {};
|
|
1540
|
+
const warnings = [];
|
|
1541
|
+
let shadowOffset = null;
|
|
1542
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1543
|
+
const parsed = parseClass(token);
|
|
1544
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1545
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
419
1546
|
);
|
|
1547
|
+
if (!allModifiersHold) continue;
|
|
1548
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1549
|
+
if (decls === null) continue;
|
|
1550
|
+
for (const d of decls) {
|
|
1551
|
+
if (d.property.startsWith("__")) {
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1554
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1555
|
+
const n = Number(d.value);
|
|
1556
|
+
if (!Number.isFinite(n)) continue;
|
|
1557
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1558
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1559
|
+
continue;
|
|
1560
|
+
}
|
|
1561
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
1562
|
+
if (warning !== null) warnings.push(warning);
|
|
1563
|
+
if (value !== null) style[kebabToCamel(d.property)] = value;
|
|
1564
|
+
}
|
|
1565
|
+
}
|
|
1566
|
+
if (shadowOffset !== null) {
|
|
1567
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1568
|
+
}
|
|
1569
|
+
return { style, warnings };
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
// src/nativeBridge.ts
|
|
1573
|
+
function resolveStyle(classString, pressed = false) {
|
|
1574
|
+
const colorScheme = (0, import_darkModeStore.getGlobalDarkMode)() ? "dark" : "light";
|
|
1575
|
+
const width = import_react_native.Dimensions.get("window").width;
|
|
1576
|
+
const KbachModule = import_react_native.TurboModuleRegistry.get("KbachModule");
|
|
1577
|
+
if (!KbachModule) {
|
|
1578
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
|
|
1579
|
+
warnIfDev(classString, warnings2);
|
|
1580
|
+
return style2;
|
|
1581
|
+
}
|
|
1582
|
+
const json = KbachModule.resolveStyle(classString, (0, import_theme.getThemeJson)(), colorScheme, pressed, width);
|
|
1583
|
+
const style = JSON.parse(json);
|
|
1584
|
+
const warnings = style.__kbachWarnings;
|
|
1585
|
+
if (warnings !== void 0) {
|
|
1586
|
+
delete style.__kbachWarnings;
|
|
1587
|
+
warnIfDev(classString, warnings);
|
|
1588
|
+
}
|
|
1589
|
+
return style;
|
|
1590
|
+
}
|
|
1591
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
1592
|
+
function warnIfDev(classString, warnings) {
|
|
1593
|
+
if (warnings.length === 0) return;
|
|
1594
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
1595
|
+
for (const warning of warnings) {
|
|
1596
|
+
const message = `${warning} (from className "${classString}")`;
|
|
1597
|
+
if (warnedMessages.has(message)) continue;
|
|
1598
|
+
warnedMessages.add(message);
|
|
1599
|
+
console.warn(message);
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
// src/config.ts
|
|
1604
|
+
var import_theme2 = require("./theme");
|
|
1605
|
+
function parseHexRgb(hex) {
|
|
1606
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1607
|
+
if (!m) return null;
|
|
1608
|
+
let h = m[1];
|
|
1609
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1610
|
+
const n = parseInt(h, 16);
|
|
1611
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1612
|
+
}
|
|
1613
|
+
function applyOpacityToHex(hex, opacityText) {
|
|
1614
|
+
const rgb = parseHexRgb(hex);
|
|
1615
|
+
if (!rgb) return hex;
|
|
1616
|
+
const a = Number(opacityText) / 100;
|
|
1617
|
+
const clamped = Number.isFinite(a) ? Math.min(1, Math.max(0, a)) : 1;
|
|
1618
|
+
return `rgba(${rgb.join(",")},${clamped})`;
|
|
1619
|
+
}
|
|
1620
|
+
function resolveColorEntry(value, lookup) {
|
|
1621
|
+
const slash = value.indexOf("/");
|
|
1622
|
+
const name = slash === -1 ? value : value.slice(0, slash);
|
|
1623
|
+
const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
|
|
1624
|
+
const base = lookup(name);
|
|
1625
|
+
if (base === void 0) return value;
|
|
1626
|
+
return opacity === void 0 ? base : applyOpacityToHex(base, opacity);
|
|
1627
|
+
}
|
|
1628
|
+
function resolveColors(extend, existing) {
|
|
1629
|
+
const resolved = {};
|
|
1630
|
+
const lookup = (name) => {
|
|
1631
|
+
const found = resolved[name] ?? existing[name];
|
|
1632
|
+
return typeof found === "string" ? found : void 0;
|
|
1633
|
+
};
|
|
1634
|
+
for (const [name, value] of Object.entries(extend)) {
|
|
1635
|
+
resolved[name] = resolveColorEntry(value, lookup);
|
|
1636
|
+
}
|
|
1637
|
+
return resolved;
|
|
1638
|
+
}
|
|
1639
|
+
function resolveKbachConfig(config) {
|
|
1640
|
+
let theme = { ...import_theme2.defaultTheme, ...config.theme };
|
|
1641
|
+
if (config.extend?.colors) {
|
|
1642
|
+
theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
|
|
1643
|
+
}
|
|
1644
|
+
if (config.extend?.spacing) {
|
|
1645
|
+
theme = { ...theme, spacing: { ...theme.spacing, ...config.extend.spacing } };
|
|
1646
|
+
}
|
|
1647
|
+
if (config.extend?.screens) {
|
|
1648
|
+
theme = { ...theme, screens: { ...theme.screens, ...config.extend.screens } };
|
|
1649
|
+
}
|
|
1650
|
+
if (config.extend?.fontFamily) {
|
|
1651
|
+
theme = { ...theme, fontFamily: { ...theme.fontFamily, ...config.extend.fontFamily } };
|
|
420
1652
|
}
|
|
421
|
-
|
|
1653
|
+
if (config.extend?.container) {
|
|
1654
|
+
theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
|
|
1655
|
+
}
|
|
1656
|
+
if (config.darkMode) {
|
|
1657
|
+
theme = { ...theme, darkMode: config.darkMode };
|
|
1658
|
+
}
|
|
1659
|
+
return theme;
|
|
1660
|
+
}
|
|
1661
|
+
function applyKbachConfig(config) {
|
|
1662
|
+
const theme = resolveKbachConfig(config);
|
|
1663
|
+
(0, import_theme2.setTheme)(theme);
|
|
1664
|
+
return theme;
|
|
1665
|
+
}
|
|
1666
|
+
|
|
1667
|
+
// src/useTheme.ts
|
|
1668
|
+
var import_react = require("react");
|
|
1669
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1670
|
+
function useTheme() {
|
|
1671
|
+
const isDark = (0, import_react.useSyncExternalStore)(import_darkModeStore2.subscribeGlobalDarkMode, import_darkModeStore2.getGlobalDarkMode);
|
|
1672
|
+
const mode = (0, import_react.useSyncExternalStore)(import_darkModeStore2.subscribeGlobalDarkMode, import_darkModeStore2.getGlobalThemeMode);
|
|
1673
|
+
return (0, import_react.useMemo)(
|
|
1674
|
+
() => ({ mode, isDark, setMode: import_darkModeStore2.setGlobalThemeMode, toggle: import_darkModeStore2.toggleGlobalDarkMode }),
|
|
1675
|
+
[mode, isDark]
|
|
1676
|
+
);
|
|
422
1677
|
}
|
|
423
1678
|
|
|
424
1679
|
// src/ThemeProvider.tsx
|
|
1680
|
+
var import_react2 = require("react");
|
|
1681
|
+
var import_darkModeStore3 = require("./darkModeStore");
|
|
425
1682
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
426
1683
|
var mountedProviderCount = 0;
|
|
427
1684
|
var warnedMultipleProviders = false;
|
|
428
1685
|
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
429
|
-
(0,
|
|
1686
|
+
(0, import_react2.useEffect)(() => {
|
|
430
1687
|
mountedProviderCount++;
|
|
431
1688
|
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
432
1689
|
warnedMultipleProviders = true;
|
|
433
1690
|
console.warn(
|
|
434
|
-
"[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store (
|
|
1691
|
+
"[kbach] Multiple <ThemeProvider> instances are mounted at once. Dark-mode state is one global store useTheme() reads everywhere, not scoped per-provider, so their defaultMode seeds will fight over the same state."
|
|
435
1692
|
);
|
|
436
1693
|
}
|
|
437
1694
|
return () => {
|
|
438
1695
|
mountedProviderCount--;
|
|
439
1696
|
};
|
|
440
1697
|
}, []);
|
|
441
|
-
const seeded = (0,
|
|
442
|
-
(0,
|
|
1698
|
+
const seeded = (0, import_react2.useRef)(false);
|
|
1699
|
+
(0, import_react2.useEffect)(() => {
|
|
443
1700
|
if (seeded.current) return;
|
|
444
1701
|
seeded.current = true;
|
|
445
|
-
seedDefaultMode(defaultMode);
|
|
1702
|
+
(0, import_darkModeStore3.seedDefaultMode)(defaultMode);
|
|
446
1703
|
}, []);
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
1704
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
// src/index.ts
|
|
1708
|
+
var import_darkModeStore4 = require("./darkModeStore");
|
|
1709
|
+
|
|
1710
|
+
// src/useColors.ts
|
|
1711
|
+
var import_theme3 = require("./theme");
|
|
1712
|
+
function parseHexRgb2(hex) {
|
|
1713
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1714
|
+
if (!m) return null;
|
|
1715
|
+
let h = m[1];
|
|
1716
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1717
|
+
const n = parseInt(h, 16);
|
|
1718
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1719
|
+
}
|
|
1720
|
+
function applyOpacity(color, opacity) {
|
|
1721
|
+
const a = Math.max(0, Math.min(1, opacity / 100));
|
|
1722
|
+
if (color.startsWith("#")) {
|
|
1723
|
+
const rgb = parseHexRgb2(color);
|
|
1724
|
+
return rgb ? `rgba(${rgb.join(",")},${a})` : color;
|
|
1725
|
+
}
|
|
1726
|
+
if (color.startsWith("rgb(")) return color.replace("rgb(", "rgba(").replace(")", `,${a})`);
|
|
1727
|
+
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
1728
|
+
return color;
|
|
1729
|
+
}
|
|
1730
|
+
function resolveEntry(entry, isDark) {
|
|
1731
|
+
return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
|
|
1732
|
+
}
|
|
1733
|
+
function makeColorsProxy(theme, isDark) {
|
|
1734
|
+
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
1735
|
+
const cache = /* @__PURE__ */ new Map();
|
|
1736
|
+
function resolveNamed(key) {
|
|
1737
|
+
let name = key;
|
|
1738
|
+
let opacity;
|
|
1739
|
+
if (key.includes("/")) {
|
|
1740
|
+
const slash = key.indexOf("/");
|
|
1741
|
+
name = key.slice(0, slash);
|
|
1742
|
+
opacity = Number(key.slice(slash + 1));
|
|
1743
|
+
}
|
|
1744
|
+
const entry = theme.colors[name];
|
|
1745
|
+
if (entry === void 0) return void 0;
|
|
1746
|
+
const value = resolveEntry(entry, isDark);
|
|
1747
|
+
return opacity === void 0 ? value : applyOpacity(value, opacity);
|
|
1748
|
+
}
|
|
1749
|
+
function makeFamilyProxy(family) {
|
|
1750
|
+
return new Proxy({}, {
|
|
1751
|
+
get(_, prop) {
|
|
1752
|
+
const key = String(prop);
|
|
1753
|
+
if (key === "then") return void 0;
|
|
1754
|
+
return resolveNamed(`${family}-${key}`);
|
|
1755
|
+
}
|
|
1756
|
+
});
|
|
1757
|
+
}
|
|
1758
|
+
return new Proxy({ alpha }, {
|
|
1759
|
+
get(_, prop) {
|
|
1760
|
+
const key = String(prop);
|
|
1761
|
+
if (key === "then") return void 0;
|
|
1762
|
+
if (key === "alpha") return alpha;
|
|
1763
|
+
const direct = resolveNamed(key);
|
|
1764
|
+
if (direct !== void 0) return direct;
|
|
1765
|
+
if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
|
|
1766
|
+
return cache.get(key);
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
function useColors() {
|
|
1771
|
+
const { isDark } = useTheme();
|
|
1772
|
+
return makeColorsProxy((0, import_theme3.getTheme)(), isDark);
|
|
1773
|
+
}
|
|
1774
|
+
|
|
1775
|
+
// src/index.ts
|
|
1776
|
+
var import_dynamicTokens2 = require("./dynamicTokens");
|
|
1777
|
+
|
|
1778
|
+
// src/useDynamicToken.ts
|
|
1779
|
+
var import_react3 = require("react");
|
|
1780
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
1781
|
+
function useDynamicToken(name) {
|
|
1782
|
+
return (0, import_react3.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
|
|
454
1783
|
}
|
|
455
1784
|
// Annotate the CommonJS export names for ESM import in node:
|
|
456
1785
|
0 && (module.exports = {
|
|
457
1786
|
ThemeProvider,
|
|
1787
|
+
applyKbachConfig,
|
|
458
1788
|
defaultTheme,
|
|
1789
|
+
deleteDynamicToken,
|
|
1790
|
+
getDynamicToken,
|
|
459
1791
|
getGlobalDarkMode,
|
|
460
1792
|
getGlobalThemeMode,
|
|
461
1793
|
getTheme,
|
|
1794
|
+
resolveKbachConfig,
|
|
462
1795
|
resolveStyle,
|
|
1796
|
+
setDynamicToken,
|
|
463
1797
|
setGlobalThemeMode,
|
|
464
1798
|
setTheme,
|
|
1799
|
+
subscribeDynamicTokens,
|
|
465
1800
|
subscribeGlobalDarkMode,
|
|
466
1801
|
toggleGlobalDarkMode,
|
|
467
|
-
|
|
1802
|
+
useColors,
|
|
1803
|
+
useDynamicToken,
|
|
468
1804
|
useTheme
|
|
469
1805
|
});
|