@kbach/react-native 1.0.0-beta.9 → 1.1.1-beta.0
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/AGENTS.md +504 -0
- package/LICENSE +21 -0
- package/README.md +206 -70
- package/THIRD_PARTY_NOTICES.md +41 -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-YOC3SHF5.mjs → chunk-6F44N62F.mjs} +2 -2
- package/dist/chunk-FSO4WVCH.mjs +112 -0
- package/dist/chunk-R7E5D3D6.mjs +623 -0
- package/dist/darkModeStore.d.ts +73 -0
- package/dist/darkModeStore.js +118 -0
- package/dist/dynamicTokens.d.ts +53 -0
- package/dist/dynamicTokens.js +75 -0
- package/dist/index.d.ts +90 -70
- package/dist/index.js +1369 -611
- package/dist/index.web.d.ts +91 -1
- package/dist/index.web.js +204 -441
- package/dist/index.web.mjs +294 -12
- package/dist/jsx-dev-runtime.d.ts +2 -2
- package/dist/jsx-dev-runtime.js +1600 -603
- package/dist/jsx-dev-runtime.web.d.ts +2 -2
- package/dist/jsx-dev-runtime.web.js +20 -355
- package/dist/jsx-dev-runtime.web.mjs +18 -6
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.js +1590 -593
- package/dist/jsx-runtime.web.d.ts +3 -3
- package/dist/jsx-runtime.web.js +17 -355
- package/dist/jsx-runtime.web.mjs +2 -3
- package/dist/semanticElements-Bk3TB-vt.d.ts +334 -0
- package/dist/theme.d.ts +79 -0
- package/dist/{chunk-HK6PDJJK.mjs → theme.js} +99 -11
- package/llms.txt +38 -0
- package/package.json +15 -13
- package/src/babel-plugin.js +95 -25
- package/dist/chunk-DLIXI5OW.mjs +0 -53
- package/dist/chunk-DOWW44F7.mjs +0 -14
- package/dist/chunk-H5Z24XX5.mjs +0 -192
- package/dist/chunk-SY5OAY2C.mjs +0 -1211
- package/dist/chunk-X4UQCEOE.mjs +0 -186
- package/dist/chunk-Z664AKW7.mjs +0 -54
- package/dist/index.d.mts +0 -83
- package/dist/index.mjs +0 -38
- package/dist/index.web.d.mts +0 -15
- package/dist/jsx-dev-runtime.d.mts +0 -10
- package/dist/jsx-dev-runtime.mjs +0 -18
- package/dist/jsx-dev-runtime.web.d.mts +0 -10
- package/dist/jsx-runtime.d.mts +0 -7
- package/dist/jsx-runtime.mjs +0 -15
- package/dist/jsx-runtime.web.d.mts +0 -7
- package/dist/useColors-CeP5_HvM.d.mts +0 -230
- package/dist/useColors-CeP5_HvM.d.ts +0 -230
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -29,432 +29,8 @@ module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var import_react = require("react");
|
|
31
31
|
var import_react_native = require("react-native");
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed) {
|
|
36
|
-
const resolved = resolveStyle2(classStrRaw, pressed);
|
|
37
|
-
if (userStyle === void 0) {
|
|
38
|
-
return resolved;
|
|
39
|
-
}
|
|
40
|
-
if (typeof userStyle === "function") {
|
|
41
|
-
return [resolved, userStyle({ pressed })];
|
|
42
|
-
}
|
|
43
|
-
return [resolved, userStyle];
|
|
44
|
-
}
|
|
45
|
-
function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
46
|
-
if (type === null || typeof type === "symbol" || !rawProps) {
|
|
47
|
-
return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
48
|
-
}
|
|
49
|
-
const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
|
|
50
|
-
if (typeof classStrRaw !== "string") {
|
|
51
|
-
return makeElement(isStaticChildren, type, rawProps, key);
|
|
52
|
-
}
|
|
53
|
-
const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
|
|
54
|
-
return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
|
|
55
|
-
}
|
|
56
|
-
function createJsxFunctions(resolveStyle2) {
|
|
57
|
-
function jsx2(type, props, key) {
|
|
58
|
-
return processElement(resolveStyle2, type, props, key, false);
|
|
59
|
-
}
|
|
60
|
-
function jsxs2(type, props, key) {
|
|
61
|
-
return processElement(resolveStyle2, type, props, key, true);
|
|
62
|
-
}
|
|
63
|
-
return { jsx: jsx2, jsxs: jsxs2 };
|
|
64
|
-
}
|
|
65
|
-
function createJsxDEV(jsx2, jsxs2) {
|
|
66
|
-
return function jsxDEV2(type, props, key, isStaticChildren, source, self) {
|
|
67
|
-
const element = (isStaticChildren ? jsxs2 : jsx2)(type, props, key);
|
|
68
|
-
if (source && element && typeof element === "object" && Object.isExtensible(element)) {
|
|
69
|
-
element._source = source;
|
|
70
|
-
element._self = self;
|
|
71
|
-
}
|
|
72
|
-
return element;
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// src/nativeBridge.ts
|
|
77
|
-
var import_react_native3 = require("react-native");
|
|
78
|
-
|
|
79
|
-
// src/generatedPalette.ts
|
|
80
|
-
var PALETTE = {
|
|
81
|
-
"amber-1": "#fffbeb",
|
|
82
|
-
"amber-10": "#78350f",
|
|
83
|
-
"amber-11": "#451a03",
|
|
84
|
-
"amber-12": "#291002",
|
|
85
|
-
"amber-2": "#fef3c7",
|
|
86
|
-
"amber-3": "#fde68a",
|
|
87
|
-
"amber-4": "#fcd34d",
|
|
88
|
-
"amber-5": "#fbbf24",
|
|
89
|
-
"amber-6": "#f59e0b",
|
|
90
|
-
"amber-7": "#d97706",
|
|
91
|
-
"amber-8": "#b45309",
|
|
92
|
-
"amber-9": "#92400e",
|
|
93
|
-
"black": "#000000",
|
|
94
|
-
"blue-1": "#eff6ff",
|
|
95
|
-
"blue-10": "#1e3a8a",
|
|
96
|
-
"blue-11": "#172554",
|
|
97
|
-
"blue-12": "#0d1633",
|
|
98
|
-
"blue-2": "#dbeafe",
|
|
99
|
-
"blue-3": "#bfdbfe",
|
|
100
|
-
"blue-4": "#93c5fd",
|
|
101
|
-
"blue-5": "#60a5fa",
|
|
102
|
-
"blue-6": "#3b82f6",
|
|
103
|
-
"blue-7": "#2563eb",
|
|
104
|
-
"blue-8": "#1d4ed8",
|
|
105
|
-
"blue-9": "#1e40af",
|
|
106
|
-
"bronze": "#cd7f32",
|
|
107
|
-
"coal": "#1c1c1c",
|
|
108
|
-
"copper": "#b87333",
|
|
109
|
-
"current": "currentColor",
|
|
110
|
-
"cyan-1": "#ecfeff",
|
|
111
|
-
"cyan-10": "#164e63",
|
|
112
|
-
"cyan-11": "#083344",
|
|
113
|
-
"cyan-12": "#041e28",
|
|
114
|
-
"cyan-2": "#cffafe",
|
|
115
|
-
"cyan-3": "#a5f3fc",
|
|
116
|
-
"cyan-4": "#67e8f9",
|
|
117
|
-
"cyan-5": "#22d3ee",
|
|
118
|
-
"cyan-6": "#06b6d4",
|
|
119
|
-
"cyan-7": "#0891b2",
|
|
120
|
-
"cyan-8": "#0e7490",
|
|
121
|
-
"cyan-9": "#155e75",
|
|
122
|
-
"emerald-1": "#ecfdf5",
|
|
123
|
-
"emerald-10": "#064e3b",
|
|
124
|
-
"emerald-11": "#022c22",
|
|
125
|
-
"emerald-12": "#011a14",
|
|
126
|
-
"emerald-2": "#d1fae5",
|
|
127
|
-
"emerald-3": "#a7f3d0",
|
|
128
|
-
"emerald-4": "#6ee7b7",
|
|
129
|
-
"emerald-5": "#34d399",
|
|
130
|
-
"emerald-6": "#10b981",
|
|
131
|
-
"emerald-7": "#059669",
|
|
132
|
-
"emerald-8": "#047857",
|
|
133
|
-
"emerald-9": "#065f46",
|
|
134
|
-
"fuchsia-1": "#fdf4ff",
|
|
135
|
-
"fuchsia-10": "#701a75",
|
|
136
|
-
"fuchsia-11": "#4a044e",
|
|
137
|
-
"fuchsia-12": "#2d022f",
|
|
138
|
-
"fuchsia-2": "#fae8ff",
|
|
139
|
-
"fuchsia-3": "#f5d0fe",
|
|
140
|
-
"fuchsia-4": "#f0abfc",
|
|
141
|
-
"fuchsia-5": "#e879f9",
|
|
142
|
-
"fuchsia-6": "#d946ef",
|
|
143
|
-
"fuchsia-7": "#c026d3",
|
|
144
|
-
"fuchsia-8": "#a21caf",
|
|
145
|
-
"fuchsia-9": "#86198f",
|
|
146
|
-
"gold": "#d4af37",
|
|
147
|
-
"gray-1": "#f9fafb",
|
|
148
|
-
"gray-10": "#111827",
|
|
149
|
-
"gray-11": "#030712",
|
|
150
|
-
"gray-12": "#020409",
|
|
151
|
-
"gray-2": "#f3f4f6",
|
|
152
|
-
"gray-3": "#e5e7eb",
|
|
153
|
-
"gray-4": "#d1d5db",
|
|
154
|
-
"gray-5": "#9ca3af",
|
|
155
|
-
"gray-6": "#6b7280",
|
|
156
|
-
"gray-7": "#4b5563",
|
|
157
|
-
"gray-8": "#374151",
|
|
158
|
-
"gray-9": "#1f2937",
|
|
159
|
-
"green-1": "#f0fdf4",
|
|
160
|
-
"green-10": "#14532d",
|
|
161
|
-
"green-11": "#052e16",
|
|
162
|
-
"green-12": "#031b0d",
|
|
163
|
-
"green-2": "#dcfce7",
|
|
164
|
-
"green-3": "#bbf7d0",
|
|
165
|
-
"green-4": "#86efac",
|
|
166
|
-
"green-5": "#4ade80",
|
|
167
|
-
"green-6": "#22c55e",
|
|
168
|
-
"green-7": "#16a34a",
|
|
169
|
-
"green-8": "#15803d",
|
|
170
|
-
"green-9": "#166534",
|
|
171
|
-
"indigo-1": "#eef2ff",
|
|
172
|
-
"indigo-10": "#312e81",
|
|
173
|
-
"indigo-11": "#1e1b4b",
|
|
174
|
-
"indigo-12": "#12102d",
|
|
175
|
-
"indigo-2": "#e0e7ff",
|
|
176
|
-
"indigo-3": "#c7d2fe",
|
|
177
|
-
"indigo-4": "#a5b4fc",
|
|
178
|
-
"indigo-5": "#818cf8",
|
|
179
|
-
"indigo-6": "#6366f1",
|
|
180
|
-
"indigo-7": "#4f46e5",
|
|
181
|
-
"indigo-8": "#4338ca",
|
|
182
|
-
"indigo-9": "#3730a3",
|
|
183
|
-
"lime-1": "#f7fee7",
|
|
184
|
-
"lime-10": "#365314",
|
|
185
|
-
"lime-11": "#1a2e05",
|
|
186
|
-
"lime-12": "#0f1b03",
|
|
187
|
-
"lime-2": "#ecfccb",
|
|
188
|
-
"lime-3": "#d9f99d",
|
|
189
|
-
"lime-4": "#bef264",
|
|
190
|
-
"lime-5": "#a3e635",
|
|
191
|
-
"lime-6": "#84cc16",
|
|
192
|
-
"lime-7": "#65a30d",
|
|
193
|
-
"lime-8": "#4d7c0f",
|
|
194
|
-
"lime-9": "#3f6212",
|
|
195
|
-
"neutral-1": "#fafafa",
|
|
196
|
-
"neutral-10": "#171717",
|
|
197
|
-
"neutral-11": "#0a0a0a",
|
|
198
|
-
"neutral-12": "#050505",
|
|
199
|
-
"neutral-2": "#f5f5f5",
|
|
200
|
-
"neutral-3": "#e5e5e5",
|
|
201
|
-
"neutral-4": "#d4d4d4",
|
|
202
|
-
"neutral-5": "#a3a3a3",
|
|
203
|
-
"neutral-6": "#737373",
|
|
204
|
-
"neutral-7": "#525252",
|
|
205
|
-
"neutral-8": "#404040",
|
|
206
|
-
"neutral-9": "#262626",
|
|
207
|
-
"orange-1": "#fff7ed",
|
|
208
|
-
"orange-10": "#7c2d12",
|
|
209
|
-
"orange-11": "#431407",
|
|
210
|
-
"orange-12": "#270c04",
|
|
211
|
-
"orange-2": "#ffedd5",
|
|
212
|
-
"orange-3": "#fed7aa",
|
|
213
|
-
"orange-4": "#fdba74",
|
|
214
|
-
"orange-5": "#fb923c",
|
|
215
|
-
"orange-6": "#f97316",
|
|
216
|
-
"orange-7": "#ea580c",
|
|
217
|
-
"orange-8": "#c2410c",
|
|
218
|
-
"orange-9": "#9a3412",
|
|
219
|
-
"pink-1": "#fdf2f8",
|
|
220
|
-
"pink-10": "#831843",
|
|
221
|
-
"pink-11": "#500724",
|
|
222
|
-
"pink-12": "#300415",
|
|
223
|
-
"pink-2": "#fce7f3",
|
|
224
|
-
"pink-3": "#fbcfe8",
|
|
225
|
-
"pink-4": "#f9a8d4",
|
|
226
|
-
"pink-5": "#f472b6",
|
|
227
|
-
"pink-6": "#ec4899",
|
|
228
|
-
"pink-7": "#db2777",
|
|
229
|
-
"pink-8": "#be185d",
|
|
230
|
-
"pink-9": "#9d174d",
|
|
231
|
-
"purple-1": "#faf5ff",
|
|
232
|
-
"purple-10": "#581c87",
|
|
233
|
-
"purple-11": "#3b0764",
|
|
234
|
-
"purple-12": "#23043c",
|
|
235
|
-
"purple-2": "#f3e8ff",
|
|
236
|
-
"purple-3": "#e9d5ff",
|
|
237
|
-
"purple-4": "#d8b4fe",
|
|
238
|
-
"purple-5": "#c084fc",
|
|
239
|
-
"purple-6": "#a855f7",
|
|
240
|
-
"purple-7": "#9333ea",
|
|
241
|
-
"purple-8": "#7e22ce",
|
|
242
|
-
"purple-9": "#6b21a8",
|
|
243
|
-
"red-1": "#fef2f2",
|
|
244
|
-
"red-10": "#7f1d1d",
|
|
245
|
-
"red-11": "#450a0a",
|
|
246
|
-
"red-12": "#280606",
|
|
247
|
-
"red-2": "#fee2e2",
|
|
248
|
-
"red-3": "#fecaca",
|
|
249
|
-
"red-4": "#fca5a5",
|
|
250
|
-
"red-5": "#f87171",
|
|
251
|
-
"red-6": "#ef4444",
|
|
252
|
-
"red-7": "#dc2626",
|
|
253
|
-
"red-8": "#b91c1c",
|
|
254
|
-
"red-9": "#991b1b",
|
|
255
|
-
"rose-1": "#fff1f2",
|
|
256
|
-
"rose-10": "#881337",
|
|
257
|
-
"rose-11": "#4c0519",
|
|
258
|
-
"rose-12": "#2d030e",
|
|
259
|
-
"rose-2": "#ffe4e6",
|
|
260
|
-
"rose-3": "#fecdd3",
|
|
261
|
-
"rose-4": "#fda4af",
|
|
262
|
-
"rose-5": "#fb7185",
|
|
263
|
-
"rose-6": "#f43f5e",
|
|
264
|
-
"rose-7": "#e11d48",
|
|
265
|
-
"rose-8": "#be123c",
|
|
266
|
-
"rose-9": "#9f1239",
|
|
267
|
-
"silver": "#c0c0c0",
|
|
268
|
-
"sky-1": "#f0f9ff",
|
|
269
|
-
"sky-10": "#0c4a6e",
|
|
270
|
-
"sky-11": "#082f49",
|
|
271
|
-
"sky-12": "#041b2b",
|
|
272
|
-
"sky-2": "#e0f2fe",
|
|
273
|
-
"sky-3": "#bae6fd",
|
|
274
|
-
"sky-4": "#7dd3fc",
|
|
275
|
-
"sky-5": "#38bdf8",
|
|
276
|
-
"sky-6": "#0ea5e9",
|
|
277
|
-
"sky-7": "#0284c7",
|
|
278
|
-
"sky-8": "#0369a1",
|
|
279
|
-
"sky-9": "#075985",
|
|
280
|
-
"slate-1": "#f8fafc",
|
|
281
|
-
"slate-10": "#0f172a",
|
|
282
|
-
"slate-11": "#020617",
|
|
283
|
-
"slate-12": "#01020a",
|
|
284
|
-
"slate-2": "#f1f5f9",
|
|
285
|
-
"slate-3": "#e2e8f0",
|
|
286
|
-
"slate-4": "#cbd5e1",
|
|
287
|
-
"slate-5": "#94a3b8",
|
|
288
|
-
"slate-6": "#64748b",
|
|
289
|
-
"slate-7": "#475569",
|
|
290
|
-
"slate-8": "#334155",
|
|
291
|
-
"slate-9": "#1e293b",
|
|
292
|
-
"stone-1": "#fafaf9",
|
|
293
|
-
"stone-10": "#1c1917",
|
|
294
|
-
"stone-11": "#0c0a09",
|
|
295
|
-
"stone-12": "#070605",
|
|
296
|
-
"stone-2": "#f5f5f4",
|
|
297
|
-
"stone-3": "#e7e5e4",
|
|
298
|
-
"stone-4": "#d6d3d1",
|
|
299
|
-
"stone-5": "#a8a29e",
|
|
300
|
-
"stone-6": "#78716c",
|
|
301
|
-
"stone-7": "#57534e",
|
|
302
|
-
"stone-8": "#44403c",
|
|
303
|
-
"stone-9": "#292524",
|
|
304
|
-
"teal-1": "#f0fdfa",
|
|
305
|
-
"teal-10": "#134e4a",
|
|
306
|
-
"teal-11": "#042f2e",
|
|
307
|
-
"teal-12": "#021c1b",
|
|
308
|
-
"teal-2": "#ccfbf1",
|
|
309
|
-
"teal-3": "#99f6e4",
|
|
310
|
-
"teal-4": "#5eead4",
|
|
311
|
-
"teal-5": "#2dd4bf",
|
|
312
|
-
"teal-6": "#14b8a6",
|
|
313
|
-
"teal-7": "#0d9488",
|
|
314
|
-
"teal-8": "#0f766e",
|
|
315
|
-
"teal-9": "#115e59",
|
|
316
|
-
"transparent": "transparent",
|
|
317
|
-
"violet-1": "#f5f3ff",
|
|
318
|
-
"violet-10": "#4c1d95",
|
|
319
|
-
"violet-11": "#2e1065",
|
|
320
|
-
"violet-12": "#1c0a3d",
|
|
321
|
-
"violet-2": "#ede9fe",
|
|
322
|
-
"violet-3": "#ddd6fe",
|
|
323
|
-
"violet-4": "#c4b5fd",
|
|
324
|
-
"violet-5": "#a78bfa",
|
|
325
|
-
"violet-6": "#8b5cf6",
|
|
326
|
-
"violet-7": "#7c3aed",
|
|
327
|
-
"violet-8": "#6d28d9",
|
|
328
|
-
"violet-9": "#5b21b6",
|
|
329
|
-
"white": "#ffffff",
|
|
330
|
-
"yellow-1": "#fefce8",
|
|
331
|
-
"yellow-10": "#713f12",
|
|
332
|
-
"yellow-11": "#422006",
|
|
333
|
-
"yellow-12": "#271304",
|
|
334
|
-
"yellow-2": "#fef9c3",
|
|
335
|
-
"yellow-3": "#fef08a",
|
|
336
|
-
"yellow-4": "#fde047",
|
|
337
|
-
"yellow-5": "#facc15",
|
|
338
|
-
"yellow-6": "#eab308",
|
|
339
|
-
"yellow-7": "#ca8a04",
|
|
340
|
-
"yellow-8": "#a16207",
|
|
341
|
-
"yellow-9": "#854d0e",
|
|
342
|
-
"zinc-1": "#fafafa",
|
|
343
|
-
"zinc-10": "#18181b",
|
|
344
|
-
"zinc-11": "#09090b",
|
|
345
|
-
"zinc-12": "#050506",
|
|
346
|
-
"zinc-2": "#f4f4f5",
|
|
347
|
-
"zinc-3": "#e4e4e7",
|
|
348
|
-
"zinc-4": "#d4d4d8",
|
|
349
|
-
"zinc-5": "#a1a1aa",
|
|
350
|
-
"zinc-6": "#71717a",
|
|
351
|
-
"zinc-7": "#52525b",
|
|
352
|
-
"zinc-8": "#3f3f46",
|
|
353
|
-
"zinc-9": "#27272a"
|
|
354
|
-
};
|
|
355
|
-
|
|
356
|
-
// src/theme.ts
|
|
357
|
-
var defaultTheme = {
|
|
358
|
-
colors: PALETTE,
|
|
359
|
-
// Real Tailwind's default spacing scale in full — every step is exactly
|
|
360
|
-
// `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
|
|
361
|
-
// 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Only the
|
|
362
|
-
// "usual stops", though — `jsEngine/shared.ts`'s `spacingPx` (and the
|
|
363
|
-
// native Rust dispatcher's own `spacing_px`) falls back to Tailwind v4's
|
|
364
|
-
// live `n * 4px` formula for any bare numeric step not listed here
|
|
365
|
-
// (`p-0.25`, `w-13`, ...), so this table names the common values and
|
|
366
|
-
// gives a theme override something to target, not the full resolvable
|
|
367
|
-
// set. Mirrors @kbach/react's theme.ts exactly.
|
|
368
|
-
spacing: {
|
|
369
|
-
"0": 0,
|
|
370
|
-
"px": 1,
|
|
371
|
-
"0.5": 2,
|
|
372
|
-
"1": 4,
|
|
373
|
-
"1.5": 6,
|
|
374
|
-
"2": 8,
|
|
375
|
-
"2.5": 10,
|
|
376
|
-
"3": 12,
|
|
377
|
-
"3.5": 14,
|
|
378
|
-
"4": 16,
|
|
379
|
-
"5": 20,
|
|
380
|
-
"6": 24,
|
|
381
|
-
"7": 28,
|
|
382
|
-
"8": 32,
|
|
383
|
-
"9": 36,
|
|
384
|
-
"10": 40,
|
|
385
|
-
"11": 44,
|
|
386
|
-
"12": 48,
|
|
387
|
-
"14": 56,
|
|
388
|
-
"16": 64,
|
|
389
|
-
"20": 80,
|
|
390
|
-
"24": 96,
|
|
391
|
-
"28": 112,
|
|
392
|
-
"32": 128,
|
|
393
|
-
"36": 144,
|
|
394
|
-
"40": 160,
|
|
395
|
-
"44": 176,
|
|
396
|
-
"48": 192,
|
|
397
|
-
"52": 208,
|
|
398
|
-
"56": 224,
|
|
399
|
-
"60": 240,
|
|
400
|
-
"64": 256,
|
|
401
|
-
"72": 288,
|
|
402
|
-
"80": 320,
|
|
403
|
-
"96": 384
|
|
404
|
-
},
|
|
405
|
-
screens: {
|
|
406
|
-
sm: 640,
|
|
407
|
-
md: 768,
|
|
408
|
-
lg: 1024,
|
|
409
|
-
xl: 1280,
|
|
410
|
-
"2xl": 1536
|
|
411
|
-
},
|
|
412
|
-
// Byte-for-byte the same three stacks
|
|
413
|
-
// packages/core-engine/src/resolvers/typography.rs's `font_family_value`
|
|
414
|
-
// falls back to. On native these three still effectively no-op (see
|
|
415
|
-
// `first_font_name`'s own doc comment for why a generic CSS keyword
|
|
416
|
-
// isn't a real loadable font) — only a caller-configured custom name
|
|
417
|
-
// changes native rendering; Expo Web uses the full stack as-is.
|
|
418
|
-
fontFamily: {
|
|
419
|
-
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
420
|
-
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
421
|
-
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
422
|
-
},
|
|
423
|
-
darkMode: "attribute",
|
|
424
|
-
// Empty by default, matching real Tailwind's own defaults.
|
|
425
|
-
container: {}
|
|
426
|
-
};
|
|
427
|
-
var activeTheme = defaultTheme;
|
|
428
|
-
var activeThemeJson = JSON.stringify(defaultTheme);
|
|
429
|
-
function getTheme() {
|
|
430
|
-
return activeTheme;
|
|
431
|
-
}
|
|
432
|
-
function getThemeJson() {
|
|
433
|
-
return activeThemeJson;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
// src/darkModeStore.ts
|
|
437
|
-
var import_react_native2 = require("react-native");
|
|
438
|
-
var listeners = /* @__PURE__ */ new Set();
|
|
439
|
-
function systemPrefersDark() {
|
|
440
|
-
return import_react_native2.Appearance.getColorScheme() === "dark";
|
|
441
|
-
}
|
|
442
|
-
function resolveIsDark(m) {
|
|
443
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
444
|
-
}
|
|
445
|
-
var mode = "system";
|
|
446
|
-
var isDark = resolveIsDark(mode);
|
|
447
|
-
var subscription = import_react_native2.Appearance.addChangeListener(({ colorScheme }) => {
|
|
448
|
-
if (mode !== "system") return;
|
|
449
|
-
isDark = colorScheme === "dark";
|
|
450
|
-
notify();
|
|
451
|
-
});
|
|
452
|
-
function notify() {
|
|
453
|
-
for (const listener of listeners) listener();
|
|
454
|
-
}
|
|
455
|
-
function getGlobalDarkMode() {
|
|
456
|
-
return isDark;
|
|
457
|
-
}
|
|
32
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
33
|
+
var import_theme = require("./theme");
|
|
458
34
|
|
|
459
35
|
// src/jsEngine/parser.ts
|
|
460
36
|
var VALUE_PREFIXES = [
|
|
@@ -542,12 +118,23 @@ var VALUE_PREFIXES = [
|
|
|
542
118
|
"leading-",
|
|
543
119
|
"tracking-",
|
|
544
120
|
"font-",
|
|
121
|
+
"align-",
|
|
545
122
|
"z-",
|
|
123
|
+
"inset-x-",
|
|
124
|
+
"inset-y-",
|
|
546
125
|
"inset-",
|
|
547
126
|
"top-",
|
|
548
127
|
"right-",
|
|
549
128
|
"bottom-",
|
|
550
129
|
"left-",
|
|
130
|
+
"start-",
|
|
131
|
+
"end-",
|
|
132
|
+
"overflow-x-",
|
|
133
|
+
"overflow-y-",
|
|
134
|
+
"overscroll-x-",
|
|
135
|
+
"overscroll-y-",
|
|
136
|
+
"overscroll-",
|
|
137
|
+
"aspect-",
|
|
551
138
|
"divide-color-",
|
|
552
139
|
"space-x-",
|
|
553
140
|
"space-y-",
|
|
@@ -575,12 +162,23 @@ var VALUE_PREFIXES = [
|
|
|
575
162
|
"justify-self-",
|
|
576
163
|
"scale-x-",
|
|
577
164
|
"scale-y-",
|
|
165
|
+
"scale-z-",
|
|
578
166
|
"scale-",
|
|
167
|
+
"rotate-x-",
|
|
168
|
+
"rotate-y-",
|
|
169
|
+
"rotate-z-",
|
|
579
170
|
"rotate-",
|
|
171
|
+
// Bare 'translate-'/'skew-' (both axes) after their per-axis forms, same
|
|
172
|
+
// longer-before-shorter rule as resolvers/parser.rs.
|
|
580
173
|
"translate-x-",
|
|
581
174
|
"translate-y-",
|
|
175
|
+
"translate-z-",
|
|
176
|
+
"translate-",
|
|
582
177
|
"skew-x-",
|
|
583
178
|
"skew-y-",
|
|
179
|
+
"skew-",
|
|
180
|
+
"perspective-origin-",
|
|
181
|
+
"perspective-",
|
|
584
182
|
"origin-",
|
|
585
183
|
"blur-",
|
|
586
184
|
"brightness-",
|
|
@@ -613,14 +211,200 @@ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
|
613
211
|
function isSafeArbitraryValue(value) {
|
|
614
212
|
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
615
213
|
}
|
|
214
|
+
function normalizeMathWhitespace(raw) {
|
|
215
|
+
if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
|
|
216
|
+
return raw;
|
|
217
|
+
}
|
|
218
|
+
const chars = Array.from(raw);
|
|
219
|
+
let out = "";
|
|
220
|
+
let i = 0;
|
|
221
|
+
let prevEndsValue = false;
|
|
222
|
+
while (i < chars.length) {
|
|
223
|
+
const c = chars[i];
|
|
224
|
+
if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
|
|
225
|
+
const start = i;
|
|
226
|
+
let depth = 0;
|
|
227
|
+
while (i < chars.length) {
|
|
228
|
+
if (chars[i] === "(") depth++;
|
|
229
|
+
else if (chars[i] === ")") {
|
|
230
|
+
depth--;
|
|
231
|
+
if (depth === 0) {
|
|
232
|
+
i++;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
i++;
|
|
237
|
+
}
|
|
238
|
+
out += chars.slice(start, i).join("");
|
|
239
|
+
prevEndsValue = true;
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
if (c === "+" || c === "-") {
|
|
243
|
+
if (prevEndsValue) {
|
|
244
|
+
out += ` ${c} `;
|
|
245
|
+
i++;
|
|
246
|
+
while (i < chars.length && /\s/.test(chars[i])) i++;
|
|
247
|
+
prevEndsValue = false;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
out += c;
|
|
251
|
+
prevEndsValue = false;
|
|
252
|
+
} else if (c === "(" || c === ",") {
|
|
253
|
+
out += c;
|
|
254
|
+
if (c === ",") out += " ";
|
|
255
|
+
prevEndsValue = false;
|
|
256
|
+
} else if (c === ")") {
|
|
257
|
+
out += c;
|
|
258
|
+
prevEndsValue = true;
|
|
259
|
+
} else if (/\s/.test(c)) {
|
|
260
|
+
} else if (c === "*" || c === "/") {
|
|
261
|
+
out += c;
|
|
262
|
+
prevEndsValue = false;
|
|
263
|
+
} else {
|
|
264
|
+
out += c;
|
|
265
|
+
prevEndsValue = true;
|
|
266
|
+
}
|
|
267
|
+
i++;
|
|
268
|
+
}
|
|
269
|
+
return out;
|
|
270
|
+
}
|
|
271
|
+
var TYPE_HINTS = /* @__PURE__ */ new Set([
|
|
272
|
+
"color",
|
|
273
|
+
"length",
|
|
274
|
+
"size",
|
|
275
|
+
"line-width",
|
|
276
|
+
"percentage",
|
|
277
|
+
"number",
|
|
278
|
+
"integer",
|
|
279
|
+
"image",
|
|
280
|
+
"url",
|
|
281
|
+
"position",
|
|
282
|
+
"bg-size",
|
|
283
|
+
"family-name",
|
|
284
|
+
"generic-name",
|
|
285
|
+
"absolute-size",
|
|
286
|
+
"relative-size",
|
|
287
|
+
"angle",
|
|
288
|
+
"shadow",
|
|
289
|
+
"any"
|
|
290
|
+
]);
|
|
291
|
+
function arbitraryModifier(modifier) {
|
|
292
|
+
const bracketed = parenVarShorthand(modifier) ?? modifier;
|
|
293
|
+
if (!(bracketed.length > 2 && bracketed.startsWith("[") && bracketed.endsWith("]"))) return null;
|
|
294
|
+
const raw = bracketed.slice(1, -1);
|
|
295
|
+
if (!isSafeArbitraryValue(raw)) return null;
|
|
296
|
+
return normalizeMathWhitespace(raw.replace(/_/g, " "));
|
|
297
|
+
}
|
|
298
|
+
function splitTypeHint(raw) {
|
|
299
|
+
const i = raw.indexOf(":");
|
|
300
|
+
if (i > 0 && i < raw.length - 1 && TYPE_HINTS.has(raw.slice(0, i))) return [raw.slice(0, i), raw.slice(i + 1)];
|
|
301
|
+
return [null, raw];
|
|
302
|
+
}
|
|
303
|
+
function parenVarShorthand(value) {
|
|
304
|
+
const m = /^\((?:([a-z-]+):)?--([A-Za-z0-9_-]+)\)(\/.*)?$/.exec(value);
|
|
305
|
+
if (!m) return null;
|
|
306
|
+
const [, hint, name, tail = ""] = m;
|
|
307
|
+
if (hint !== void 0 && !TYPE_HINTS.has(hint)) return null;
|
|
308
|
+
return hint ? `[${hint}:var(--${name})]${tail}` : `[var(--${name})]${tail}`;
|
|
309
|
+
}
|
|
310
|
+
function splitBracketModifier(value) {
|
|
311
|
+
if (!value.startsWith("[")) return [value, null];
|
|
312
|
+
let depth = 0;
|
|
313
|
+
for (let i = 0; i < value.length; i++) {
|
|
314
|
+
const ch = value[i];
|
|
315
|
+
if (ch === "[") depth += 1;
|
|
316
|
+
else if (ch === "]") {
|
|
317
|
+
depth -= 1;
|
|
318
|
+
if (depth === 0) {
|
|
319
|
+
const after = value.slice(i + 1);
|
|
320
|
+
return after.startsWith("/") && after.length > 1 ? [value.slice(0, i + 1), after.slice(1)] : [value, null];
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return [value, null];
|
|
325
|
+
}
|
|
326
|
+
function trimNumber(n) {
|
|
327
|
+
return `${Math.round(n * 1e6) / 1e6}`;
|
|
328
|
+
}
|
|
329
|
+
function parseAlpha(modifier) {
|
|
330
|
+
const raw = arbitraryModifier(modifier);
|
|
331
|
+
if (raw !== null) {
|
|
332
|
+
if (raw.endsWith("%")) {
|
|
333
|
+
const n3 = strictNumber(raw.slice(0, -1));
|
|
334
|
+
return n3 !== null && n3 >= 0 && n3 <= 100 ? { fraction: n3 / 100 } : null;
|
|
335
|
+
}
|
|
336
|
+
const n2 = strictNumber(raw);
|
|
337
|
+
if (n2 !== null) return n2 >= 0 && n2 <= 1 ? { fraction: n2 } : null;
|
|
338
|
+
return raw.startsWith("var(") || raw.startsWith("calc(") ? { raw } : null;
|
|
339
|
+
}
|
|
340
|
+
if (!/^(?:\d+\.?\d*|\.\d+)$/.test(modifier)) return null;
|
|
341
|
+
const n = Number(modifier);
|
|
342
|
+
return n <= 100 ? { fraction: n / 100 } : null;
|
|
343
|
+
}
|
|
344
|
+
function strictNumber(text) {
|
|
345
|
+
return /^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(text) ? Number(text) : null;
|
|
346
|
+
}
|
|
347
|
+
function expandThemeFunctions(raw) {
|
|
348
|
+
if (!raw.includes("--spacing(") && !raw.includes("--alpha(")) return raw;
|
|
349
|
+
let out = "";
|
|
350
|
+
let rest = raw;
|
|
351
|
+
for (; ; ) {
|
|
352
|
+
const found = ["--spacing(", "--alpha("].map((name) => ({ name, at: rest.indexOf(name) })).filter((f) => f.at !== -1).sort((a, b) => a.at - b.at)[0];
|
|
353
|
+
if (found === void 0) break;
|
|
354
|
+
const argsFrom = found.at + found.name.length;
|
|
355
|
+
let depth = 1;
|
|
356
|
+
let close = -1;
|
|
357
|
+
for (let i = argsFrom; i < rest.length; i++) {
|
|
358
|
+
if (rest[i] === "(") depth += 1;
|
|
359
|
+
else if (rest[i] === ")") {
|
|
360
|
+
depth -= 1;
|
|
361
|
+
if (depth === 0) {
|
|
362
|
+
close = i;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
if (close === -1) break;
|
|
368
|
+
const arg = expandThemeFunctions(rest.slice(argsFrom, close).trim());
|
|
369
|
+
out += rest.slice(0, found.at);
|
|
370
|
+
if (found.name === "--spacing(") {
|
|
371
|
+
const n = strictNumber(arg);
|
|
372
|
+
out += n !== null ? `${trimNumber(n * 4)}px` : `calc(4px * ${arg})`;
|
|
373
|
+
} else {
|
|
374
|
+
const slash = arg.lastIndexOf("/");
|
|
375
|
+
if (slash === -1) {
|
|
376
|
+
out += arg;
|
|
377
|
+
} else {
|
|
378
|
+
const alpha = arg.slice(slash + 1).trim();
|
|
379
|
+
const n = strictNumber(alpha);
|
|
380
|
+
out += `color-mix(in srgb, ${arg.slice(0, slash).trim()} ${n !== null ? `${trimNumber(n * 100)}%` : alpha}, transparent)`;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
rest = rest.slice(close + 1);
|
|
384
|
+
}
|
|
385
|
+
return out + rest;
|
|
386
|
+
}
|
|
387
|
+
var COLOR_FUNCTIONS = ["rgb(", "rgba(", "hsl(", "hsla(", "hwb(", "lab(", "lch(", "oklab(", "oklch(", "color(", "color-mix(", "var("];
|
|
388
|
+
function looksLikeColor(value) {
|
|
389
|
+
return value.startsWith("#") || COLOR_FUNCTIONS.some((f) => value.startsWith(f)) || /^[A-Za-z]+$/.test(value);
|
|
390
|
+
}
|
|
391
|
+
function colorWithOpacity(color, alpha) {
|
|
392
|
+
const m = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color);
|
|
393
|
+
if (m && "fraction" in alpha) {
|
|
394
|
+
const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
|
|
395
|
+
const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
396
|
+
return `rgba(${r},${g},${b},${trimNumber(alpha.fraction)})`;
|
|
397
|
+
}
|
|
398
|
+
return `color-mix(in srgb, ${color} ${"fraction" in alpha ? `${trimNumber(alpha.fraction * 100)}%` : alpha.raw}, transparent)`;
|
|
399
|
+
}
|
|
616
400
|
function splitRespectingBrackets(token) {
|
|
617
401
|
const parts = [];
|
|
618
402
|
let depth = 0;
|
|
619
403
|
let start = 0;
|
|
620
404
|
for (let i = 0; i < token.length; i++) {
|
|
621
405
|
const ch = token[i];
|
|
622
|
-
if (ch === "[") depth += 1;
|
|
623
|
-
else if (ch === "]") depth -= 1;
|
|
406
|
+
if (ch === "[" || ch === "(") depth += 1;
|
|
407
|
+
else if (ch === "]" || ch === ")") depth -= 1;
|
|
624
408
|
else if (ch === ":" && depth <= 0) {
|
|
625
409
|
parts.push(token.slice(start, i));
|
|
626
410
|
start = i + 1;
|
|
@@ -633,9 +417,11 @@ function parseClass(token) {
|
|
|
633
417
|
const parts = splitRespectingBrackets(token);
|
|
634
418
|
let base = parts.pop() ?? token;
|
|
635
419
|
const modifiers = parts;
|
|
636
|
-
const important = base.startsWith("!");
|
|
637
|
-
if (
|
|
420
|
+
const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
|
|
421
|
+
if (base.startsWith("!")) {
|
|
638
422
|
base = base.slice(1);
|
|
423
|
+
} else if (important) {
|
|
424
|
+
base = base.slice(0, -1);
|
|
639
425
|
}
|
|
640
426
|
const negative = base.startsWith("-");
|
|
641
427
|
if (negative) {
|
|
@@ -648,7 +434,7 @@ function parseClass(token) {
|
|
|
648
434
|
const property = raw.slice(0, colonIdx);
|
|
649
435
|
const rawValue = raw.slice(colonIdx + 1);
|
|
650
436
|
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
651
|
-
const value = rawValue.replace(/_/g, " ");
|
|
437
|
+
const value = normalizeMathWhitespace(expandThemeFunctions(rawValue.replace(/_/g, " ")));
|
|
652
438
|
return {
|
|
653
439
|
modifiers,
|
|
654
440
|
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
@@ -663,28 +449,46 @@ function parseClass(token) {
|
|
|
663
449
|
}
|
|
664
450
|
for (const prefix of VALUE_PREFIXES) {
|
|
665
451
|
if (!base.startsWith(prefix)) continue;
|
|
666
|
-
const
|
|
667
|
-
if (
|
|
452
|
+
const written = base.slice(prefix.length);
|
|
453
|
+
if (written === "") continue;
|
|
454
|
+
const [value, tail] = splitBracketModifier(parenVarShorthand(written) ?? written);
|
|
668
455
|
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
669
456
|
const raw = value.slice(1, -1);
|
|
670
457
|
if (!isSafeArbitraryValue(raw)) {
|
|
671
458
|
continue;
|
|
672
459
|
}
|
|
673
|
-
const spaced = raw.replace(/_/g, " ");
|
|
460
|
+
const spaced = normalizeMathWhitespace(expandThemeFunctions(raw.replace(/_/g, " ")));
|
|
461
|
+
let [typeHint, hinted] = splitTypeHint(spaced);
|
|
462
|
+
let modifier = null;
|
|
463
|
+
if (tail !== null) {
|
|
464
|
+
const isColor = typeHint === "color" || typeHint === null && looksLikeColor(hinted);
|
|
465
|
+
const alpha = isColor ? parseAlpha(tail) : null;
|
|
466
|
+
if (alpha !== null) {
|
|
467
|
+
hinted = colorWithOpacity(hinted, alpha);
|
|
468
|
+
typeHint = "color";
|
|
469
|
+
} else if (prefix === "text-") {
|
|
470
|
+
modifier = tail;
|
|
471
|
+
} else {
|
|
472
|
+
continue;
|
|
473
|
+
}
|
|
474
|
+
}
|
|
674
475
|
return {
|
|
675
476
|
modifiers,
|
|
676
477
|
utility: prefix.slice(0, -1),
|
|
677
|
-
value:
|
|
478
|
+
value: hinted,
|
|
479
|
+
typeHint,
|
|
678
480
|
isArbitrary: true,
|
|
679
481
|
important,
|
|
680
482
|
negative,
|
|
681
|
-
original: token
|
|
483
|
+
original: token,
|
|
484
|
+
modifier
|
|
682
485
|
};
|
|
683
486
|
}
|
|
684
487
|
return {
|
|
685
488
|
modifiers,
|
|
686
489
|
utility: prefix.slice(0, -1),
|
|
687
|
-
value
|
|
490
|
+
// a named value keeps its own /opacity (`bg-blue-6/50`)
|
|
491
|
+
value: tail === null ? value : `${value}/${tail}`,
|
|
688
492
|
isArbitrary: false,
|
|
689
493
|
important,
|
|
690
494
|
negative,
|
|
@@ -702,6 +506,718 @@ function parseClass(token) {
|
|
|
702
506
|
};
|
|
703
507
|
}
|
|
704
508
|
|
|
509
|
+
// src/jsEngine/resolvers/color.ts
|
|
510
|
+
function lookupHex(theme, key) {
|
|
511
|
+
const entry = theme.colors[key];
|
|
512
|
+
return typeof entry === "string" ? entry : null;
|
|
513
|
+
}
|
|
514
|
+
var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
|
|
515
|
+
function findModeAwareColor(base, theme) {
|
|
516
|
+
const important = base.startsWith("!") ? "!" : "";
|
|
517
|
+
const rest = important ? base.slice(1) : base;
|
|
518
|
+
for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
|
|
519
|
+
if (!rest.startsWith(prefix)) continue;
|
|
520
|
+
const [name, opacity] = splitOpacity(rest.slice(prefix.length));
|
|
521
|
+
const entry = theme.colors[name];
|
|
522
|
+
if (typeof entry === "object" && entry !== null) {
|
|
523
|
+
return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
528
|
+
function applyOpacityToHex(hex, opacity) {
|
|
529
|
+
if (opacity === null) return hex;
|
|
530
|
+
if (hexToRgb(hex) === null) return hex;
|
|
531
|
+
return colorWithOpacity(hex.trim(), opacity).replace(/ /g, "_");
|
|
532
|
+
}
|
|
533
|
+
function substituteModeAwareColorToken(token, theme, colorScheme) {
|
|
534
|
+
const segments = token.split(":");
|
|
535
|
+
const base = segments.pop() ?? token;
|
|
536
|
+
const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
|
|
537
|
+
const found = findModeAwareColor(base, theme);
|
|
538
|
+
if (found === null) return token;
|
|
539
|
+
const hex = colorScheme === "dark" ? found.dark : found.light;
|
|
540
|
+
return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
|
|
541
|
+
}
|
|
542
|
+
function classStringUsesModeAwareColor(classString, theme) {
|
|
543
|
+
return classString.split(/\s+/).some((rawToken) => {
|
|
544
|
+
if (!rawToken) return false;
|
|
545
|
+
const segments = rawToken.split(":");
|
|
546
|
+
const base = segments.pop() ?? rawToken;
|
|
547
|
+
return findModeAwareColor(base, theme) !== null;
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function hexToRgb(hex) {
|
|
551
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
552
|
+
if (!m) return null;
|
|
553
|
+
let h = m[1];
|
|
554
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
555
|
+
const n = parseInt(h, 16);
|
|
556
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
557
|
+
}
|
|
558
|
+
function splitOpacity(value) {
|
|
559
|
+
const slash = value.indexOf("/");
|
|
560
|
+
if (slash === -1) return [value, null];
|
|
561
|
+
const alpha = parseAlpha(value.slice(slash + 1));
|
|
562
|
+
return alpha === null ? [value, null] : [value.slice(0, slash), alpha];
|
|
563
|
+
}
|
|
564
|
+
function colorValue(theme, parsed) {
|
|
565
|
+
const value = parsed.value;
|
|
566
|
+
if (value === null) return null;
|
|
567
|
+
if (parsed.isArbitrary) return value;
|
|
568
|
+
const [name, opacity] = splitOpacity(value);
|
|
569
|
+
const hex = lookupHex(theme, name);
|
|
570
|
+
if (hex === null) return null;
|
|
571
|
+
return opacity === null ? hex : colorWithOpacity(hex, opacity);
|
|
572
|
+
}
|
|
573
|
+
var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
|
|
574
|
+
function looksLikeLength(value) {
|
|
575
|
+
const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
|
|
576
|
+
const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
|
|
577
|
+
if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
|
|
578
|
+
if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
|
|
579
|
+
return MATH_LENGTH_UNIT.test(value);
|
|
580
|
+
}
|
|
581
|
+
var MATH_LENGTH_UNIT = /\d(?:px|rem|em|%|vh|vw|vmin|vmax|dvh|dvw|svh|svw|lvh|lvw|ch|ex|lh|cqw|cqh|cqi|cqb)(?![A-Za-z])/;
|
|
582
|
+
function isLength(parsed, value) {
|
|
583
|
+
switch (parsed.typeHint ?? null) {
|
|
584
|
+
case null:
|
|
585
|
+
return looksLikeLength(value);
|
|
586
|
+
case "length":
|
|
587
|
+
case "size":
|
|
588
|
+
case "line-width":
|
|
589
|
+
case "percentage":
|
|
590
|
+
case "number":
|
|
591
|
+
case "integer":
|
|
592
|
+
case "absolute-size":
|
|
593
|
+
case "relative-size":
|
|
594
|
+
return true;
|
|
595
|
+
default:
|
|
596
|
+
return false;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
// src/jsxRuntimeCore.ts
|
|
601
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
602
|
+
|
|
603
|
+
// src/jsEngine/calc.ts
|
|
604
|
+
function reduceConstantMath(raw) {
|
|
605
|
+
const trimmed = raw.trim();
|
|
606
|
+
const calc = stripCall(trimmed, "calc");
|
|
607
|
+
if (calc !== null) {
|
|
608
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
609
|
+
}
|
|
610
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
611
|
+
if (clamp !== null) {
|
|
612
|
+
const args = splitTopLevelCommas(clamp);
|
|
613
|
+
if (args.length !== 3) return null;
|
|
614
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
615
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
616
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
617
|
+
}
|
|
618
|
+
const min = stripCall(trimmed, "min");
|
|
619
|
+
if (min !== null) {
|
|
620
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
621
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
622
|
+
}
|
|
623
|
+
const max = stripCall(trimmed, "max");
|
|
624
|
+
if (max !== null) {
|
|
625
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
626
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
627
|
+
}
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
function stripCall(raw, name) {
|
|
631
|
+
if (!raw.startsWith(name)) return null;
|
|
632
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
633
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
634
|
+
return afterName.slice(1, -1);
|
|
635
|
+
}
|
|
636
|
+
function splitTopLevelCommas(s) {
|
|
637
|
+
const parts = [];
|
|
638
|
+
let depth = 0;
|
|
639
|
+
let start = 0;
|
|
640
|
+
for (let i = 0; i < s.length; i++) {
|
|
641
|
+
const ch = s[i];
|
|
642
|
+
if (ch === "(") depth++;
|
|
643
|
+
else if (ch === ")") depth--;
|
|
644
|
+
else if (ch === "," && depth === 0) {
|
|
645
|
+
parts.push(s.slice(start, i).trim());
|
|
646
|
+
start = i + 1;
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
parts.push(s.slice(start).trim());
|
|
650
|
+
return parts;
|
|
651
|
+
}
|
|
652
|
+
var Evaluator = class {
|
|
653
|
+
constructor(s) {
|
|
654
|
+
this.pos = 0;
|
|
655
|
+
this.s = s;
|
|
656
|
+
}
|
|
657
|
+
parseExprToEnd() {
|
|
658
|
+
const value = this.expr();
|
|
659
|
+
if (value === null) return null;
|
|
660
|
+
this.skipWs();
|
|
661
|
+
return this.pos === this.s.length ? value : null;
|
|
662
|
+
}
|
|
663
|
+
skipWs() {
|
|
664
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
665
|
+
}
|
|
666
|
+
peek() {
|
|
667
|
+
this.skipWs();
|
|
668
|
+
return this.s[this.pos];
|
|
669
|
+
}
|
|
670
|
+
expr() {
|
|
671
|
+
let value = this.term();
|
|
672
|
+
if (value === null) return null;
|
|
673
|
+
for (; ; ) {
|
|
674
|
+
const ch = this.peek();
|
|
675
|
+
if (ch === "+") {
|
|
676
|
+
this.pos++;
|
|
677
|
+
const rhs = this.term();
|
|
678
|
+
if (rhs === null) return null;
|
|
679
|
+
value += rhs;
|
|
680
|
+
} else if (ch === "-") {
|
|
681
|
+
this.pos++;
|
|
682
|
+
const rhs = this.term();
|
|
683
|
+
if (rhs === null) return null;
|
|
684
|
+
value -= rhs;
|
|
685
|
+
} else {
|
|
686
|
+
return value;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
term() {
|
|
691
|
+
let value = this.factor();
|
|
692
|
+
if (value === null) return null;
|
|
693
|
+
for (; ; ) {
|
|
694
|
+
const ch = this.peek();
|
|
695
|
+
if (ch === "*") {
|
|
696
|
+
this.pos++;
|
|
697
|
+
const rhs = this.factor();
|
|
698
|
+
if (rhs === null) return null;
|
|
699
|
+
value *= rhs;
|
|
700
|
+
} else if (ch === "/") {
|
|
701
|
+
this.pos++;
|
|
702
|
+
const divisor = this.factor();
|
|
703
|
+
if (divisor === null || divisor === 0) return null;
|
|
704
|
+
value /= divisor;
|
|
705
|
+
} else {
|
|
706
|
+
return value;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
factor() {
|
|
711
|
+
const ch = this.peek();
|
|
712
|
+
if (ch === void 0) return null;
|
|
713
|
+
if (ch === "(") {
|
|
714
|
+
this.pos++;
|
|
715
|
+
const value = this.expr();
|
|
716
|
+
if (value === null || this.peek() !== ")") return null;
|
|
717
|
+
this.pos++;
|
|
718
|
+
return value;
|
|
719
|
+
}
|
|
720
|
+
if (ch === "-") {
|
|
721
|
+
this.pos++;
|
|
722
|
+
const value = this.factor();
|
|
723
|
+
return value === null ? null : -value;
|
|
724
|
+
}
|
|
725
|
+
return this.numberWithUnit();
|
|
726
|
+
}
|
|
727
|
+
numberWithUnit() {
|
|
728
|
+
this.skipWs();
|
|
729
|
+
const start = this.pos;
|
|
730
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
731
|
+
if (this.pos === start) return null;
|
|
732
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
733
|
+
if (!Number.isFinite(n)) return null;
|
|
734
|
+
const unitStart = this.pos;
|
|
735
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
736
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
737
|
+
switch (unit) {
|
|
738
|
+
case "":
|
|
739
|
+
return n;
|
|
740
|
+
case "px":
|
|
741
|
+
return n;
|
|
742
|
+
case "rem":
|
|
743
|
+
return n * 16;
|
|
744
|
+
default:
|
|
745
|
+
return null;
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
// src/layoutCalc.ts
|
|
751
|
+
var NEG = (v) => ({ percent: -v.percent, px: -v.px });
|
|
752
|
+
var ADD = (a, b) => ({ percent: a.percent + b.percent, px: a.px + b.px });
|
|
753
|
+
var SUB = (a, b) => ({ percent: a.percent - b.percent, px: a.px - b.px });
|
|
754
|
+
function MUL(a, b) {
|
|
755
|
+
if (a.percent === 0) return { percent: b.percent * a.px, px: b.px * a.px };
|
|
756
|
+
if (b.percent === 0) return { percent: a.percent * b.px, px: a.px * b.px };
|
|
757
|
+
return null;
|
|
758
|
+
}
|
|
759
|
+
function DIV(a, b) {
|
|
760
|
+
if (b.percent !== 0 || b.px === 0) return null;
|
|
761
|
+
return { percent: a.percent / b.px, px: a.px / b.px };
|
|
762
|
+
}
|
|
763
|
+
var PercentAwareEvaluator = class {
|
|
764
|
+
constructor(s) {
|
|
765
|
+
this.pos = 0;
|
|
766
|
+
this.s = s;
|
|
767
|
+
}
|
|
768
|
+
parseExprToEnd() {
|
|
769
|
+
const value = this.expr();
|
|
770
|
+
if (value === null) return null;
|
|
771
|
+
this.skipWs();
|
|
772
|
+
return this.pos === this.s.length ? value : null;
|
|
773
|
+
}
|
|
774
|
+
skipWs() {
|
|
775
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
776
|
+
}
|
|
777
|
+
peek() {
|
|
778
|
+
this.skipWs();
|
|
779
|
+
return this.s[this.pos];
|
|
780
|
+
}
|
|
781
|
+
expr() {
|
|
782
|
+
let value = this.term();
|
|
783
|
+
if (value === null) return null;
|
|
784
|
+
for (; ; ) {
|
|
785
|
+
const ch = this.peek();
|
|
786
|
+
if (ch === "+") {
|
|
787
|
+
this.pos++;
|
|
788
|
+
const rhs = this.term();
|
|
789
|
+
if (rhs === null) return null;
|
|
790
|
+
value = ADD(value, rhs);
|
|
791
|
+
} else if (ch === "-") {
|
|
792
|
+
this.pos++;
|
|
793
|
+
const rhs = this.term();
|
|
794
|
+
if (rhs === null) return null;
|
|
795
|
+
value = SUB(value, rhs);
|
|
796
|
+
} else {
|
|
797
|
+
return value;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
term() {
|
|
802
|
+
let value = this.factor();
|
|
803
|
+
if (value === null) return null;
|
|
804
|
+
for (; ; ) {
|
|
805
|
+
const ch = this.peek();
|
|
806
|
+
if (ch === "*") {
|
|
807
|
+
this.pos++;
|
|
808
|
+
const rhs = this.factor();
|
|
809
|
+
if (rhs === null) return null;
|
|
810
|
+
const result = MUL(value, rhs);
|
|
811
|
+
if (result === null) return null;
|
|
812
|
+
value = result;
|
|
813
|
+
} else if (ch === "/") {
|
|
814
|
+
this.pos++;
|
|
815
|
+
const rhs = this.factor();
|
|
816
|
+
if (rhs === null) return null;
|
|
817
|
+
const result = DIV(value, rhs);
|
|
818
|
+
if (result === null) return null;
|
|
819
|
+
value = result;
|
|
820
|
+
} else {
|
|
821
|
+
return value;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
factor() {
|
|
826
|
+
const ch = this.peek();
|
|
827
|
+
if (ch === void 0) return null;
|
|
828
|
+
if (ch === "(") {
|
|
829
|
+
this.pos++;
|
|
830
|
+
const value = this.expr();
|
|
831
|
+
if (value === null || this.peek() !== ")") return null;
|
|
832
|
+
this.pos++;
|
|
833
|
+
return value;
|
|
834
|
+
}
|
|
835
|
+
if (ch === "-") {
|
|
836
|
+
this.pos++;
|
|
837
|
+
const value = this.factor();
|
|
838
|
+
return value === null ? null : NEG(value);
|
|
839
|
+
}
|
|
840
|
+
return this.numberWithUnit();
|
|
841
|
+
}
|
|
842
|
+
numberWithUnit() {
|
|
843
|
+
this.skipWs();
|
|
844
|
+
const start = this.pos;
|
|
845
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
846
|
+
if (this.pos === start) return null;
|
|
847
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
848
|
+
if (!Number.isFinite(n)) return null;
|
|
849
|
+
if (this.s[this.pos] === "%") {
|
|
850
|
+
this.pos++;
|
|
851
|
+
return { percent: n, px: 0 };
|
|
852
|
+
}
|
|
853
|
+
const unitStart = this.pos;
|
|
854
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
855
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
856
|
+
switch (unit) {
|
|
857
|
+
case "":
|
|
858
|
+
return { percent: 0, px: n };
|
|
859
|
+
case "px":
|
|
860
|
+
return { percent: 0, px: n };
|
|
861
|
+
case "rem":
|
|
862
|
+
return { percent: 0, px: n * 16 };
|
|
863
|
+
default:
|
|
864
|
+
return null;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
};
|
|
868
|
+
var PERCENT_TOKEN_OUTER_RE = /^(w|h)-\[(.+)\]$/;
|
|
869
|
+
function parsePercentRelativeCalc(token) {
|
|
870
|
+
const m = PERCENT_TOKEN_OUTER_RE.exec(token);
|
|
871
|
+
if (!m) return null;
|
|
872
|
+
const property = m[1] === "w" ? "width" : "height";
|
|
873
|
+
const inner = stripCall(m[2].replace(/_/g, " ").trim(), "calc");
|
|
874
|
+
if (inner === null) return null;
|
|
875
|
+
const result = new PercentAwareEvaluator(inner).parseExprToEnd();
|
|
876
|
+
if (result === null || result.percent === 0) return null;
|
|
877
|
+
return { property, percentCoefficient: result.percent, constantPx: result.px };
|
|
878
|
+
}
|
|
879
|
+
function resolvePercentRelativeCalc(basisPx, calc) {
|
|
880
|
+
return basisPx * calc.percentCoefficient / 100 + calc.constantPx;
|
|
881
|
+
}
|
|
882
|
+
function parsePercentRelativeMinMaxClamp(token) {
|
|
883
|
+
const m = PERCENT_TOKEN_OUTER_RE.exec(token);
|
|
884
|
+
if (!m) return null;
|
|
885
|
+
const property = m[1] === "w" ? "width" : "height";
|
|
886
|
+
const spaced = m[2].replace(/_/g, " ");
|
|
887
|
+
let kind;
|
|
888
|
+
let inner;
|
|
889
|
+
if ((inner = stripCall(spaced, "min")) !== null) kind = "min";
|
|
890
|
+
else if ((inner = stripCall(spaced, "max")) !== null) kind = "max";
|
|
891
|
+
else if ((inner = stripCall(spaced, "clamp")) !== null) kind = "clamp";
|
|
892
|
+
else return null;
|
|
893
|
+
const args = splitTopLevelCommas(inner);
|
|
894
|
+
if (kind === "clamp" && args.length !== 3) return null;
|
|
895
|
+
if (kind !== "clamp" && args.length < 1) return null;
|
|
896
|
+
const operands = args.map((arg) => new PercentAwareEvaluator(arg.trim()).parseExprToEnd());
|
|
897
|
+
if (operands.some((o) => o === null)) return null;
|
|
898
|
+
const resolved = operands;
|
|
899
|
+
if (!resolved.some((o) => o.percent !== 0)) return null;
|
|
900
|
+
return {
|
|
901
|
+
property,
|
|
902
|
+
resolve(basisPx) {
|
|
903
|
+
const values = resolved.map((o) => basisPx * o.percent / 100 + o.px);
|
|
904
|
+
if (kind === "min") return Math.min(...values);
|
|
905
|
+
if (kind === "max") return Math.max(...values);
|
|
906
|
+
const [min, preferred, max] = values;
|
|
907
|
+
return Math.max(min, Math.min(preferred, max));
|
|
908
|
+
}
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
function parsePercentRelativeExpr(token) {
|
|
912
|
+
const calc = parsePercentRelativeCalc(token);
|
|
913
|
+
if (calc) return { property: calc.property, resolve: (basisPx) => resolvePercentRelativeCalc(basisPx, calc) };
|
|
914
|
+
return parsePercentRelativeMinMaxClamp(token);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
// src/jsxRuntimeCore.ts
|
|
918
|
+
var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
|
|
919
|
+
function substituteDynamicTokens(classStrRaw) {
|
|
920
|
+
if (!classStrRaw.includes("var(--")) return classStrRaw;
|
|
921
|
+
return classStrRaw.replace(DYNAMIC_TOKEN_MATCH_RE, (whole, name) => {
|
|
922
|
+
const value = (0, import_dynamicTokens.getDynamicToken)(name);
|
|
923
|
+
return value ?? whole;
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
var PERCENT_RELATIVE_CALC_HINT_RE = /[wh]-\[(calc|min|max|clamp)\(.*%.*\)\]/;
|
|
927
|
+
function extractPercentRelativeCalcs(classStrRaw) {
|
|
928
|
+
const found = [];
|
|
929
|
+
for (const token of classStrRaw.split(/\s+/)) {
|
|
930
|
+
const parsed = parsePercentRelativeExpr(token);
|
|
931
|
+
if (parsed) found.push(parsed);
|
|
932
|
+
}
|
|
933
|
+
return found;
|
|
934
|
+
}
|
|
935
|
+
function stripPercentRelativeCalcTokens(classStrRaw) {
|
|
936
|
+
return classStrRaw.split(/\s+/).filter((token) => token && parsePercentRelativeExpr(token) === null).join(" ");
|
|
937
|
+
}
|
|
938
|
+
var STATE_MODIFIER_NAMES = /* @__PURE__ */ new Set(["hover", "focus", "disabled"]);
|
|
939
|
+
var STATIC_ARIA_SHORTCUT_NAMES = /* @__PURE__ */ new Set([
|
|
940
|
+
"aria-checked",
|
|
941
|
+
"aria-disabled",
|
|
942
|
+
"aria-expanded",
|
|
943
|
+
"aria-hidden",
|
|
944
|
+
"aria-pressed",
|
|
945
|
+
"aria-readonly",
|
|
946
|
+
"aria-required",
|
|
947
|
+
"aria-selected",
|
|
948
|
+
"aria-busy"
|
|
949
|
+
]);
|
|
950
|
+
var STATE_MODIFIER_HINT_RE = /(^|\s|:)(hover|focus|disabled|aria-checked|aria-disabled|aria-expanded|aria-hidden|aria-pressed|aria-readonly|aria-required|aria-selected|aria-busy):|data-\[|aria-\[/;
|
|
951
|
+
function bracketContent(name, prefix) {
|
|
952
|
+
if (!name.startsWith(prefix)) return null;
|
|
953
|
+
const rest = name.slice(prefix.length);
|
|
954
|
+
if (!rest.startsWith("[") || !rest.endsWith("]")) return null;
|
|
955
|
+
return rest.slice(1, -1);
|
|
956
|
+
}
|
|
957
|
+
function evalAttrCondition(hostRest, attrPrefix, inner) {
|
|
958
|
+
const eqIdx = inner.indexOf("=");
|
|
959
|
+
if (eqIdx === -1) return Boolean(hostRest[`${attrPrefix}${inner}`]);
|
|
960
|
+
const key = inner.slice(0, eqIdx);
|
|
961
|
+
const value = inner.slice(eqIdx + 1);
|
|
962
|
+
return String(hostRest[`${attrPrefix}${key}`]) === value;
|
|
963
|
+
}
|
|
964
|
+
function isAriaTruthy(value) {
|
|
965
|
+
return value === true || value === "true";
|
|
966
|
+
}
|
|
967
|
+
function propBasedModifierState(name, states, hostRest) {
|
|
968
|
+
if (STATE_MODIFIER_NAMES.has(name)) return states[name];
|
|
969
|
+
if (STATIC_ARIA_SHORTCUT_NAMES.has(name)) return isAriaTruthy(hostRest[name]);
|
|
970
|
+
const dataInner = bracketContent(name, "data-");
|
|
971
|
+
if (dataInner !== null) return evalAttrCondition(hostRest, "data-", dataInner);
|
|
972
|
+
const ariaInner = bracketContent(name, "aria-");
|
|
973
|
+
if (ariaInner !== null) return evalAttrCondition(hostRest, "aria-", ariaInner);
|
|
974
|
+
return null;
|
|
975
|
+
}
|
|
976
|
+
var STATE_HOLD_MARKER = "_kbon";
|
|
977
|
+
function markSatisfiedStateModifiers(parts, namesToReplace) {
|
|
978
|
+
const utility = parts[parts.length - 1] ?? "";
|
|
979
|
+
const modifiers = parts.slice(0, -1).map((m) => namesToReplace.has(m) ? STATE_HOLD_MARKER : m);
|
|
980
|
+
return [...modifiers, utility].join(":");
|
|
981
|
+
}
|
|
982
|
+
function substituteStateModifiers(classStrRaw, states, hostRest) {
|
|
983
|
+
if (!STATE_MODIFIER_HINT_RE.test(classStrRaw)) return classStrRaw;
|
|
984
|
+
const kept = [];
|
|
985
|
+
for (const token of classStrRaw.split(/\s+/)) {
|
|
986
|
+
if (!token) continue;
|
|
987
|
+
const parts = splitRespectingBrackets(token);
|
|
988
|
+
const modifiers = parts.slice(0, -1);
|
|
989
|
+
const resolved = modifiers.map((m) => [m, propBasedModifierState(m, states, hostRest)]);
|
|
990
|
+
const required = resolved.filter(([, v]) => v !== null);
|
|
991
|
+
if (required.length === 0) {
|
|
992
|
+
kept.push(token);
|
|
993
|
+
continue;
|
|
994
|
+
}
|
|
995
|
+
if (required.every(([, v]) => v === true)) {
|
|
996
|
+
const requiredNames = new Set(required.map(([m]) => m));
|
|
997
|
+
kept.push(markSatisfiedStateModifiers(parts, requiredNames));
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
return kept.join(" ");
|
|
1001
|
+
}
|
|
1002
|
+
function makeElement(isStaticChildren, type, props, key) {
|
|
1003
|
+
return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
|
|
1004
|
+
}
|
|
1005
|
+
function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed, hostRest, layoutOverrides, states = { hover: false, focus: false, disabled: false }) {
|
|
1006
|
+
const stateResolved = substituteStateModifiers(classStrRaw, states, hostRest);
|
|
1007
|
+
const cleaned = stripPercentRelativeCalcTokens(substituteDynamicTokens(stateResolved));
|
|
1008
|
+
const resolved = resolveStyle2(cleaned, pressed);
|
|
1009
|
+
if (layoutOverrides) {
|
|
1010
|
+
Object.assign(resolved, layoutOverrides);
|
|
1011
|
+
}
|
|
1012
|
+
if (userStyle === void 0) {
|
|
1013
|
+
return resolved;
|
|
1014
|
+
}
|
|
1015
|
+
if (typeof userStyle === "function") {
|
|
1016
|
+
return [resolved, userStyle({ pressed })];
|
|
1017
|
+
}
|
|
1018
|
+
return [resolved, userStyle];
|
|
1019
|
+
}
|
|
1020
|
+
var DARK_MODIFIER_RE = /(^|\s|:)dark:/;
|
|
1021
|
+
var BREAKPOINT_MODIFIER_RE = /(^|\s|:)(sm|md|lg|xl|2xl):|(^|\s|:)(min|max)-\[[^\]]*\]:/;
|
|
1022
|
+
var HOVER_MODIFIER_RE = /(^|\s|:)hover:/;
|
|
1023
|
+
var FOCUS_MODIFIER_RE = /(^|\s|:)focus:/;
|
|
1024
|
+
function usesModeAwareColor(classStrRaw) {
|
|
1025
|
+
return classStringUsesModeAwareColor(classStrRaw, (0, import_theme.getTheme)());
|
|
1026
|
+
}
|
|
1027
|
+
function ReactiveElement({
|
|
1028
|
+
hostType,
|
|
1029
|
+
hostRest,
|
|
1030
|
+
classStrRaw,
|
|
1031
|
+
userStyle,
|
|
1032
|
+
resolveStyle: resolveStyle2,
|
|
1033
|
+
elementKey,
|
|
1034
|
+
isStaticChildren
|
|
1035
|
+
}) {
|
|
1036
|
+
(0, import_react.useSyncExternalStore)(import_darkModeStore.subscribeGlobalDarkMode, import_darkModeStore.getGlobalDarkMode);
|
|
1037
|
+
(0, import_react.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, import_dynamicTokens.getDynamicTokensVersion);
|
|
1038
|
+
const windowSize = (0, import_react_native.useWindowDimensions)();
|
|
1039
|
+
const [measuredBasis, setMeasuredBasis] = (0, import_react.useState)(null);
|
|
1040
|
+
const lastWindowSizeRef = (0, import_react.useRef)(windowSize);
|
|
1041
|
+
if (lastWindowSizeRef.current.width !== windowSize.width || lastWindowSizeRef.current.height !== windowSize.height) {
|
|
1042
|
+
lastWindowSizeRef.current = windowSize;
|
|
1043
|
+
if (measuredBasis !== null) {
|
|
1044
|
+
setMeasuredBasis(null);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
const measure = (0, import_react.useCallback)((e) => {
|
|
1048
|
+
const { width: w, height: h } = e.nativeEvent.layout;
|
|
1049
|
+
setMeasuredBasis((prev) => prev === null ? { width: w, height: h } : prev);
|
|
1050
|
+
}, []);
|
|
1051
|
+
const [isHovered, setIsHovered] = (0, import_react.useState)(false);
|
|
1052
|
+
const [isFocused, setIsFocused] = (0, import_react.useState)(false);
|
|
1053
|
+
const percentCalcs = extractPercentRelativeCalcs(classStrRaw);
|
|
1054
|
+
let layoutOverrides;
|
|
1055
|
+
let hostRestWithLayout = hostRest;
|
|
1056
|
+
if (percentCalcs.length > 0) {
|
|
1057
|
+
layoutOverrides = {};
|
|
1058
|
+
for (const calc of percentCalcs) {
|
|
1059
|
+
const basis = measuredBasis?.[calc.property];
|
|
1060
|
+
layoutOverrides[calc.property] = basis === void 0 ? "100%" : calc.resolve(basis);
|
|
1061
|
+
}
|
|
1062
|
+
const userOnLayout = hostRest.onLayout;
|
|
1063
|
+
hostRestWithLayout = {
|
|
1064
|
+
...hostRest,
|
|
1065
|
+
onLayout: userOnLayout ? (e) => {
|
|
1066
|
+
measure(e);
|
|
1067
|
+
userOnLayout(e);
|
|
1068
|
+
} : measure
|
|
1069
|
+
};
|
|
1070
|
+
}
|
|
1071
|
+
if (HOVER_MODIFIER_RE.test(classStrRaw)) {
|
|
1072
|
+
const userOnHoverIn = hostRestWithLayout.onHoverIn;
|
|
1073
|
+
const userOnHoverOut = hostRestWithLayout.onHoverOut;
|
|
1074
|
+
hostRestWithLayout = {
|
|
1075
|
+
...hostRestWithLayout,
|
|
1076
|
+
onHoverIn: (e) => {
|
|
1077
|
+
setIsHovered(true);
|
|
1078
|
+
userOnHoverIn?.(e);
|
|
1079
|
+
},
|
|
1080
|
+
onHoverOut: (e) => {
|
|
1081
|
+
setIsHovered(false);
|
|
1082
|
+
userOnHoverOut?.(e);
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
}
|
|
1086
|
+
if (FOCUS_MODIFIER_RE.test(classStrRaw)) {
|
|
1087
|
+
const userOnFocus = hostRestWithLayout.onFocus;
|
|
1088
|
+
const userOnBlur = hostRestWithLayout.onBlur;
|
|
1089
|
+
hostRestWithLayout = {
|
|
1090
|
+
...hostRestWithLayout,
|
|
1091
|
+
onFocus: (e) => {
|
|
1092
|
+
setIsFocused(true);
|
|
1093
|
+
userOnFocus?.(e);
|
|
1094
|
+
},
|
|
1095
|
+
onBlur: (e) => {
|
|
1096
|
+
setIsFocused(false);
|
|
1097
|
+
userOnBlur?.(e);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
}
|
|
1101
|
+
const states = { hover: isHovered, focus: isFocused, disabled: hostRest.disabled === true };
|
|
1102
|
+
const finalStyle = hostType === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, hostRest, layoutOverrides, states) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, hostRest, layoutOverrides, states);
|
|
1103
|
+
return makeElement(
|
|
1104
|
+
isStaticChildren,
|
|
1105
|
+
hostType,
|
|
1106
|
+
{ ...hostRestWithLayout, className: classStrRaw, style: finalStyle },
|
|
1107
|
+
elementKey
|
|
1108
|
+
);
|
|
1109
|
+
}
|
|
1110
|
+
function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
1111
|
+
if (type === null || typeof type === "symbol" || !rawProps) {
|
|
1112
|
+
return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
1113
|
+
}
|
|
1114
|
+
const { className: classStrRaw, style: userStyle, ...rest } = rawProps;
|
|
1115
|
+
if (typeof classStrRaw !== "string") {
|
|
1116
|
+
return makeElement(isStaticChildren, type, rawProps, key);
|
|
1117
|
+
}
|
|
1118
|
+
if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw) || HOVER_MODIFIER_RE.test(classStrRaw) || FOCUS_MODIFIER_RE.test(classStrRaw) || classStrRaw.includes("var(--") || PERCENT_RELATIVE_CALC_HINT_RE.test(classStrRaw) || usesModeAwareColor(classStrRaw)) {
|
|
1119
|
+
return (0, import_jsx_runtime.jsx)(
|
|
1120
|
+
ReactiveElement,
|
|
1121
|
+
{ hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
|
|
1122
|
+
key
|
|
1123
|
+
);
|
|
1124
|
+
}
|
|
1125
|
+
const staticStates = { hover: false, focus: false, disabled: rest.disabled === true };
|
|
1126
|
+
const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, rest, void 0, staticStates) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, rest, void 0, staticStates);
|
|
1127
|
+
return makeElement(isStaticChildren, type, { ...rest, className: classStrRaw, style: finalStyle }, key);
|
|
1128
|
+
}
|
|
1129
|
+
function createJsxFunctions(resolveStyle2) {
|
|
1130
|
+
function jsx2(type, props, key) {
|
|
1131
|
+
return processElement(resolveStyle2, type, props, key, false);
|
|
1132
|
+
}
|
|
1133
|
+
function jsxs2(type, props, key) {
|
|
1134
|
+
return processElement(resolveStyle2, type, props, key, true);
|
|
1135
|
+
}
|
|
1136
|
+
return { jsx: jsx2, jsxs: jsxs2 };
|
|
1137
|
+
}
|
|
1138
|
+
function createJsxDEV(jsx2, jsxs2) {
|
|
1139
|
+
return function jsxDEV2(type, props, key, isStaticChildren, source, self) {
|
|
1140
|
+
const element = (isStaticChildren ? jsxs2 : jsx2)(type, props, key);
|
|
1141
|
+
if (source && element && typeof element === "object" && Object.isExtensible(element)) {
|
|
1142
|
+
element._source = source;
|
|
1143
|
+
element._self = self;
|
|
1144
|
+
}
|
|
1145
|
+
return element;
|
|
1146
|
+
};
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
// src/nativeBridge.ts
|
|
1150
|
+
var import_react_native2 = require("react-native");
|
|
1151
|
+
var import_theme2 = require("./theme");
|
|
1152
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1153
|
+
|
|
1154
|
+
// src/jsEngine/groups.ts
|
|
1155
|
+
function expandVariantGroups(input) {
|
|
1156
|
+
if (!input.includes(":(")) return input;
|
|
1157
|
+
const out = [];
|
|
1158
|
+
for (const token of splitTopLevel(input)) expandToken(token, "", false, out);
|
|
1159
|
+
return out.join(" ");
|
|
1160
|
+
}
|
|
1161
|
+
function splitTopLevel(s) {
|
|
1162
|
+
const parts = [];
|
|
1163
|
+
let depth = 0;
|
|
1164
|
+
let start = -1;
|
|
1165
|
+
for (let i = 0; i < s.length; i++) {
|
|
1166
|
+
const ch = s[i];
|
|
1167
|
+
if (ch === "(" || ch === "[") depth++;
|
|
1168
|
+
else if (ch === ")" || ch === "]") depth--;
|
|
1169
|
+
const space = /\s/.test(ch);
|
|
1170
|
+
if (space && depth <= 0) {
|
|
1171
|
+
if (start >= 0) {
|
|
1172
|
+
parts.push(s.slice(start, i));
|
|
1173
|
+
start = -1;
|
|
1174
|
+
}
|
|
1175
|
+
depth = Math.max(depth, 0);
|
|
1176
|
+
} else if (start < 0 && !space) {
|
|
1177
|
+
start = i;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
if (start >= 0) parts.push(s.slice(start));
|
|
1181
|
+
return parts;
|
|
1182
|
+
}
|
|
1183
|
+
function groupOpen(token) {
|
|
1184
|
+
let brackets = 0;
|
|
1185
|
+
for (let i = 0; i < token.length; i++) {
|
|
1186
|
+
const ch = token[i];
|
|
1187
|
+
if (ch === "[") brackets++;
|
|
1188
|
+
else if (ch === "]") brackets--;
|
|
1189
|
+
else if (ch === "(" && brackets === 0 && i > 1 && token[i - 1] === ":") return i;
|
|
1190
|
+
}
|
|
1191
|
+
return -1;
|
|
1192
|
+
}
|
|
1193
|
+
function groupClose(token, open) {
|
|
1194
|
+
let depth = 0;
|
|
1195
|
+
for (let i = open; i < token.length; i++) {
|
|
1196
|
+
const ch = token[i];
|
|
1197
|
+
if (ch === "(" || ch === "[") depth++;
|
|
1198
|
+
else if (ch === ")" || ch === "]") {
|
|
1199
|
+
depth--;
|
|
1200
|
+
if (depth === 0) return ch === ")" ? i : -1;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
return -1;
|
|
1204
|
+
}
|
|
1205
|
+
function pushClass(prefix, cls, important, out) {
|
|
1206
|
+
if (!cls) return;
|
|
1207
|
+
const bare = cls.split(":").pop() ?? cls;
|
|
1208
|
+
out.push(prefix + cls + (important && !cls.endsWith("!") && !bare.startsWith("!") ? "!" : ""));
|
|
1209
|
+
}
|
|
1210
|
+
function expandToken(token, prefix, important, out) {
|
|
1211
|
+
const open = groupOpen(token);
|
|
1212
|
+
if (open < 0) return pushClass(prefix, token, important, out);
|
|
1213
|
+
const close = groupClose(token, open);
|
|
1214
|
+
if (close < 0) return pushClass(prefix, token, important, out);
|
|
1215
|
+
const rest = token.slice(close + 1);
|
|
1216
|
+
if (rest !== "" && rest !== "!") return pushClass(prefix, token, important, out);
|
|
1217
|
+
const innerPrefix = prefix + token.slice(0, open);
|
|
1218
|
+
for (const part of splitTopLevel(token.slice(open + 1, close))) expandToken(part, innerPrefix, rest === "!" || important, out);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
705
1221
|
// src/jsEngine/shared.ts
|
|
706
1222
|
function decl(property, value) {
|
|
707
1223
|
return { property, value };
|
|
@@ -709,6 +1225,7 @@ function decl(property, value) {
|
|
|
709
1225
|
function spacingPx(theme, value) {
|
|
710
1226
|
const fromTable = theme.spacing[value];
|
|
711
1227
|
if (fromTable !== void 0) return fromTable;
|
|
1228
|
+
if (value === "px") return 1;
|
|
712
1229
|
const n = Number(value);
|
|
713
1230
|
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
714
1231
|
}
|
|
@@ -724,7 +1241,10 @@ function resolveLength(theme, parsed) {
|
|
|
724
1241
|
}
|
|
725
1242
|
function resolveNegatableLength(theme, parsed) {
|
|
726
1243
|
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
727
|
-
if (parsed.isArbitrary)
|
|
1244
|
+
if (parsed.isArbitrary) {
|
|
1245
|
+
const value2 = parsed.value;
|
|
1246
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
1247
|
+
}
|
|
728
1248
|
const value = parsed.value;
|
|
729
1249
|
if (value === null) return null;
|
|
730
1250
|
const px = spacingPx(theme, value);
|
|
@@ -732,11 +1252,71 @@ function resolveNegatableLength(theme, parsed) {
|
|
|
732
1252
|
if (px === 0) return "0px";
|
|
733
1253
|
return `-${px}px`;
|
|
734
1254
|
}
|
|
1255
|
+
function fractionPercent(value) {
|
|
1256
|
+
const slashIdx = value.indexOf("/");
|
|
1257
|
+
if (slashIdx === -1) return null;
|
|
1258
|
+
const numStr = value.slice(0, slashIdx);
|
|
1259
|
+
const denStr = value.slice(slashIdx + 1);
|
|
1260
|
+
const num = Number(numStr);
|
|
1261
|
+
const den = Number(denStr);
|
|
1262
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
1263
|
+
if (den === 0) return null;
|
|
1264
|
+
const pct = num / den * 100;
|
|
1265
|
+
const formatted = pct.toFixed(6);
|
|
1266
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
1267
|
+
return `${trimmed}%`;
|
|
1268
|
+
}
|
|
1269
|
+
function resolveNegatableSize(theme, parsed) {
|
|
1270
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1271
|
+
if (parsed.negative && parsed.value === "full") return "-100%";
|
|
1272
|
+
const pct = fractionPercent(parsed.value);
|
|
1273
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
1274
|
+
}
|
|
1275
|
+
return resolveNegatableLength(theme, parsed);
|
|
1276
|
+
}
|
|
1277
|
+
function negate(value) {
|
|
1278
|
+
const numeric = (v) => /^[\d.]/.test(v);
|
|
1279
|
+
if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
|
|
1280
|
+
return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
|
|
1281
|
+
}
|
|
1282
|
+
function resolvePercent(parsed) {
|
|
1283
|
+
if (parsed.negative) return null;
|
|
1284
|
+
const value = parsed.value;
|
|
1285
|
+
if (value === null) return null;
|
|
1286
|
+
if (parsed.isArbitrary) return value;
|
|
1287
|
+
const pct = Number(value);
|
|
1288
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
1289
|
+
return String(pct / 100);
|
|
1290
|
+
}
|
|
735
1291
|
|
|
736
1292
|
// src/jsEngine/resolvers/layout.ts
|
|
737
1293
|
function negateRaw(value, negative) {
|
|
738
1294
|
return negative ? `-${value}` : value;
|
|
739
1295
|
}
|
|
1296
|
+
var WHOLE = /^\d+$/;
|
|
1297
|
+
var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
1298
|
+
function overflowAxisValue(property, value) {
|
|
1299
|
+
switch (value) {
|
|
1300
|
+
case "auto":
|
|
1301
|
+
case "hidden":
|
|
1302
|
+
case "clip":
|
|
1303
|
+
case "visible":
|
|
1304
|
+
case "scroll":
|
|
1305
|
+
return [decl(property, value)];
|
|
1306
|
+
default:
|
|
1307
|
+
return null;
|
|
1308
|
+
}
|
|
1309
|
+
}
|
|
1310
|
+
function overscrollValue(property, value) {
|
|
1311
|
+
switch (value) {
|
|
1312
|
+
case "auto":
|
|
1313
|
+
case "contain":
|
|
1314
|
+
case "none":
|
|
1315
|
+
return [decl(property, value)];
|
|
1316
|
+
default:
|
|
1317
|
+
return null;
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
740
1320
|
function resolve(parsed, theme) {
|
|
741
1321
|
switch (parsed.utility) {
|
|
742
1322
|
case "flex":
|
|
@@ -783,6 +1363,12 @@ function resolve(parsed, theme) {
|
|
|
783
1363
|
return [decl("justify-content", "space-around")];
|
|
784
1364
|
case "justify-evenly":
|
|
785
1365
|
return [decl("justify-content", "space-evenly")];
|
|
1366
|
+
case "justify-normal":
|
|
1367
|
+
return [decl("justify-content", "normal")];
|
|
1368
|
+
case "justify-stretch":
|
|
1369
|
+
return [decl("justify-content", "stretch")];
|
|
1370
|
+
case "content-normal":
|
|
1371
|
+
return [decl("align-content", "normal")];
|
|
786
1372
|
case "content-start":
|
|
787
1373
|
return [decl("align-content", "flex-start")];
|
|
788
1374
|
case "content-end":
|
|
@@ -817,6 +1403,18 @@ function resolve(parsed, theme) {
|
|
|
817
1403
|
return [decl("overflow", "scroll")];
|
|
818
1404
|
case "overflow-visible":
|
|
819
1405
|
return [decl("overflow", "visible")];
|
|
1406
|
+
case "overflow-clip":
|
|
1407
|
+
return [decl("overflow", "clip")];
|
|
1408
|
+
case "overflow-x":
|
|
1409
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
1410
|
+
case "overflow-y":
|
|
1411
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
1412
|
+
case "overscroll":
|
|
1413
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
1414
|
+
case "overscroll-x":
|
|
1415
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
1416
|
+
case "overscroll-y":
|
|
1417
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
820
1418
|
case "static":
|
|
821
1419
|
return [decl("position", "static")];
|
|
822
1420
|
case "relative":
|
|
@@ -827,40 +1425,91 @@ function resolve(parsed, theme) {
|
|
|
827
1425
|
return [decl("position", "fixed")];
|
|
828
1426
|
case "sticky":
|
|
829
1427
|
return [decl("position", "sticky")];
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
1428
|
+
// Only real values, mirroring layout.rs: a whole number, z-auto, the
|
|
1429
|
+
// order-first/-last/-none keywords, or an arbitrary [...]. Anything
|
|
1430
|
+
// else used to pass straight through (z-banana -> z-index: banana).
|
|
1431
|
+
case "z": {
|
|
1432
|
+
const v = parsed.value;
|
|
1433
|
+
if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
|
|
1434
|
+
return [decl("z-index", negateRaw(v, parsed.negative))];
|
|
1435
|
+
}
|
|
1436
|
+
case "order": {
|
|
1437
|
+
const v = parsed.value;
|
|
1438
|
+
if (v === null) return null;
|
|
1439
|
+
if (v === "first") return [decl("order", "-9999")];
|
|
1440
|
+
if (v === "last") return [decl("order", "9999")];
|
|
1441
|
+
if (v === "none") return [decl("order", "0")];
|
|
1442
|
+
if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
|
|
1443
|
+
return [decl("order", negateRaw(v, parsed.negative))];
|
|
1444
|
+
}
|
|
834
1445
|
case "grow":
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
1446
|
+
case "shrink": {
|
|
1447
|
+
const v = parsed.value ?? "1";
|
|
1448
|
+
if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
|
|
1449
|
+
return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
|
|
1450
|
+
}
|
|
838
1451
|
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
839
|
-
// convention ("-top-4")
|
|
1452
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
1453
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
840
1454
|
case "top": {
|
|
841
|
-
const v =
|
|
1455
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
842
1456
|
return v === null ? null : [decl("top", v)];
|
|
843
1457
|
}
|
|
844
1458
|
case "right": {
|
|
845
|
-
const v =
|
|
1459
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
846
1460
|
return v === null ? null : [decl("right", v)];
|
|
847
1461
|
}
|
|
848
1462
|
case "bottom": {
|
|
849
|
-
const v =
|
|
1463
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
850
1464
|
return v === null ? null : [decl("bottom", v)];
|
|
851
1465
|
}
|
|
852
1466
|
case "left": {
|
|
853
|
-
const v =
|
|
1467
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
854
1468
|
return v === null ? null : [decl("left", v)];
|
|
855
1469
|
}
|
|
856
1470
|
case "inset": {
|
|
857
|
-
const v =
|
|
1471
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
858
1472
|
return v === null ? null : [decl("inset", v)];
|
|
859
1473
|
}
|
|
860
|
-
case "
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
1474
|
+
case "inset-x": {
|
|
1475
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1476
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
1477
|
+
}
|
|
1478
|
+
case "inset-y": {
|
|
1479
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1480
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
1481
|
+
}
|
|
1482
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
1483
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
1484
|
+
case "start": {
|
|
1485
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1486
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
1487
|
+
}
|
|
1488
|
+
case "end": {
|
|
1489
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1490
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
1491
|
+
}
|
|
1492
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
1493
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
1494
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
1495
|
+
// "aspect" arm.
|
|
1496
|
+
case "aspect": {
|
|
1497
|
+
const value = parsed.value;
|
|
1498
|
+
if (value === null) return null;
|
|
1499
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
1500
|
+
switch (value) {
|
|
1501
|
+
case "square":
|
|
1502
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
1503
|
+
case "video":
|
|
1504
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
1505
|
+
case "auto":
|
|
1506
|
+
return [decl("aspect-ratio", "auto")];
|
|
1507
|
+
default: {
|
|
1508
|
+
const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
|
|
1509
|
+
return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
}
|
|
864
1513
|
default:
|
|
865
1514
|
return null;
|
|
866
1515
|
}
|
|
@@ -902,7 +1551,7 @@ function resolveFlex(parsed, web) {
|
|
|
902
1551
|
case "shrink-0":
|
|
903
1552
|
return [decl("flex-shrink", "0")];
|
|
904
1553
|
default:
|
|
905
|
-
return null;
|
|
1554
|
+
return /^\d+$/.test(value) ? [decl("flex", value)] : null;
|
|
906
1555
|
}
|
|
907
1556
|
}
|
|
908
1557
|
|
|
@@ -937,20 +1586,6 @@ function namedSize(key) {
|
|
|
937
1586
|
return null;
|
|
938
1587
|
}
|
|
939
1588
|
}
|
|
940
|
-
function fractionPercent(value) {
|
|
941
|
-
const slashIdx = value.indexOf("/");
|
|
942
|
-
if (slashIdx === -1) return null;
|
|
943
|
-
const numStr = value.slice(0, slashIdx);
|
|
944
|
-
const denStr = value.slice(slashIdx + 1);
|
|
945
|
-
const num = Number(numStr);
|
|
946
|
-
const den = Number(denStr);
|
|
947
|
-
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
948
|
-
if (den === 0) return null;
|
|
949
|
-
const pct = num / den * 100;
|
|
950
|
-
const formatted = pct.toFixed(6);
|
|
951
|
-
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
952
|
-
return `${trimmed}%`;
|
|
953
|
-
}
|
|
954
1589
|
function cssSizeKeyword(key) {
|
|
955
1590
|
switch (key) {
|
|
956
1591
|
case "min":
|
|
@@ -1084,19 +1719,16 @@ function resolve2(parsed, theme) {
|
|
|
1084
1719
|
}
|
|
1085
1720
|
}
|
|
1086
1721
|
|
|
1087
|
-
// src/jsEngine/resolvers/color.ts
|
|
1088
|
-
function lookupHex(theme, key) {
|
|
1089
|
-
const entry = theme.colors[key];
|
|
1090
|
-
return typeof entry === "string" ? entry : null;
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
1722
|
// src/jsEngine/resolvers/border.ts
|
|
1094
1723
|
function radiusSize(key) {
|
|
1095
1724
|
switch (key) {
|
|
1096
1725
|
case "none":
|
|
1097
1726
|
return "0px";
|
|
1098
|
-
|
|
1727
|
+
// Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
|
|
1728
|
+
case "xs":
|
|
1099
1729
|
return "0.125rem";
|
|
1730
|
+
case "sm":
|
|
1731
|
+
return "0.25rem";
|
|
1100
1732
|
case "md":
|
|
1101
1733
|
return "0.375rem";
|
|
1102
1734
|
case "lg":
|
|
@@ -1107,12 +1739,19 @@ function radiusSize(key) {
|
|
|
1107
1739
|
return "1rem";
|
|
1108
1740
|
case "3xl":
|
|
1109
1741
|
return "1.5rem";
|
|
1742
|
+
case "4xl":
|
|
1743
|
+
return "2rem";
|
|
1110
1744
|
case "full":
|
|
1111
1745
|
return "9999px";
|
|
1112
1746
|
default:
|
|
1113
1747
|
return null;
|
|
1114
1748
|
}
|
|
1115
1749
|
}
|
|
1750
|
+
function borderWidthPx(parsed) {
|
|
1751
|
+
if (parsed.negative || parsed.isArbitrary || parsed.value === null) return null;
|
|
1752
|
+
const n = Number(parsed.value);
|
|
1753
|
+
return Number.isFinite(n) && n >= 0 && parsed.value.trim() !== "" ? `${n}px` : null;
|
|
1754
|
+
}
|
|
1116
1755
|
function borderSideProperty(side) {
|
|
1117
1756
|
switch (side) {
|
|
1118
1757
|
case "t":
|
|
@@ -1135,49 +1774,68 @@ function borderValue(theme, parsed) {
|
|
|
1135
1774
|
if (side !== null) {
|
|
1136
1775
|
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1137
1776
|
}
|
|
1777
|
+
const pair = value === "x" ? ["border-left", "border-right"] : value === "y" ? ["border-top", "border-bottom"] : null;
|
|
1778
|
+
if (pair !== null) {
|
|
1779
|
+
return [
|
|
1780
|
+
decl(`${pair[0]}-width`, "1px"),
|
|
1781
|
+
decl(`${pair[1]}-width`, "1px"),
|
|
1782
|
+
decl(`${pair[0]}-style`, "solid"),
|
|
1783
|
+
decl(`${pair[1]}-style`, "solid")
|
|
1784
|
+
];
|
|
1785
|
+
}
|
|
1138
1786
|
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1139
1787
|
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1140
1788
|
}
|
|
1141
1789
|
if (parsed.isArbitrary) {
|
|
1142
|
-
return [decl("border-width", value)];
|
|
1790
|
+
if (isLength(parsed, value)) return [decl("border-width", value)];
|
|
1791
|
+
const color2 = colorValue(theme, parsed);
|
|
1792
|
+
return color2 === null ? null : [decl("border-color", color2)];
|
|
1143
1793
|
}
|
|
1144
1794
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1145
|
-
const v =
|
|
1795
|
+
const v = borderWidthPx(parsed);
|
|
1146
1796
|
return v === null ? null : [decl("border-width", v)];
|
|
1147
1797
|
}
|
|
1148
1798
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1149
1799
|
return [decl("border-style", value)];
|
|
1150
1800
|
}
|
|
1151
|
-
const
|
|
1152
|
-
return
|
|
1801
|
+
const color = colorValue(theme, parsed);
|
|
1802
|
+
return color === null ? null : [decl("border-color", color)];
|
|
1153
1803
|
}
|
|
1154
1804
|
function borderSideValue(theme, parsed, sideProperty) {
|
|
1155
1805
|
const value = parsed.value;
|
|
1156
1806
|
if (value === null) return null;
|
|
1157
|
-
if (parsed.isArbitrary)
|
|
1807
|
+
if (parsed.isArbitrary) {
|
|
1808
|
+
if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
|
|
1809
|
+
const color2 = colorValue(theme, parsed);
|
|
1810
|
+
return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
|
|
1811
|
+
}
|
|
1158
1812
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1159
|
-
const v =
|
|
1813
|
+
const v = borderWidthPx(parsed);
|
|
1160
1814
|
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1161
1815
|
}
|
|
1162
1816
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1163
1817
|
return [decl(`${sideProperty}-style`, value)];
|
|
1164
1818
|
}
|
|
1165
|
-
const
|
|
1166
|
-
return
|
|
1819
|
+
const color = colorValue(theme, parsed);
|
|
1820
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
1167
1821
|
}
|
|
1168
1822
|
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1169
1823
|
const value = parsed.value;
|
|
1170
1824
|
if (value === null) return null;
|
|
1171
|
-
if (parsed.isArbitrary)
|
|
1825
|
+
if (parsed.isArbitrary) {
|
|
1826
|
+
if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1827
|
+
const color2 = colorValue(theme, parsed);
|
|
1828
|
+
return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
|
|
1829
|
+
}
|
|
1172
1830
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1173
|
-
const v =
|
|
1831
|
+
const v = borderWidthPx(parsed);
|
|
1174
1832
|
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1175
1833
|
}
|
|
1176
1834
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1177
1835
|
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1178
1836
|
}
|
|
1179
|
-
const
|
|
1180
|
-
return
|
|
1837
|
+
const color = colorValue(theme, parsed);
|
|
1838
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1181
1839
|
}
|
|
1182
1840
|
function radiusProperties(side) {
|
|
1183
1841
|
switch (side) {
|
|
@@ -1217,79 +1875,28 @@ function resolveRadiusSide(theme, parsed, side) {
|
|
|
1217
1875
|
}
|
|
1218
1876
|
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1219
1877
|
function outlineWidthValue(key) {
|
|
1220
|
-
|
|
1221
|
-
case "0":
|
|
1222
|
-
return "0px";
|
|
1223
|
-
case "1":
|
|
1224
|
-
return "1px";
|
|
1225
|
-
case "2":
|
|
1226
|
-
return "2px";
|
|
1227
|
-
case "4":
|
|
1228
|
-
return "4px";
|
|
1229
|
-
case "8":
|
|
1230
|
-
return "8px";
|
|
1231
|
-
default:
|
|
1232
|
-
return null;
|
|
1233
|
-
}
|
|
1878
|
+
return /^\d+$/.test(key) ? `${Number(key)}px` : null;
|
|
1234
1879
|
}
|
|
1235
1880
|
function outlineValue(theme, parsed) {
|
|
1236
1881
|
const value = parsed.value;
|
|
1237
1882
|
if (value === null) return null;
|
|
1238
|
-
if (parsed.isArbitrary)
|
|
1883
|
+
if (parsed.isArbitrary) {
|
|
1884
|
+
if (isLength(parsed, value)) return [decl("outline-width", value)];
|
|
1885
|
+
const color2 = colorValue(theme, parsed);
|
|
1886
|
+
return color2 === null ? null : [decl("outline-color", color2)];
|
|
1887
|
+
}
|
|
1239
1888
|
const w = outlineWidthValue(value);
|
|
1240
1889
|
if (w !== null) return [decl("outline-width", w)];
|
|
1241
1890
|
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1242
|
-
const
|
|
1243
|
-
return
|
|
1891
|
+
const color = colorValue(theme, parsed);
|
|
1892
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1244
1893
|
}
|
|
1245
1894
|
function outlineOffsetValue(parsed) {
|
|
1246
1895
|
const value = parsed.value;
|
|
1247
1896
|
if (value === null) return null;
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
return
|
|
1251
|
-
}
|
|
1252
|
-
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))";
|
|
1253
|
-
function ringWidth(key) {
|
|
1254
|
-
switch (key) {
|
|
1255
|
-
case "0":
|
|
1256
|
-
return "0px";
|
|
1257
|
-
case "1":
|
|
1258
|
-
return "1px";
|
|
1259
|
-
case "2":
|
|
1260
|
-
return "2px";
|
|
1261
|
-
case "4":
|
|
1262
|
-
return "4px";
|
|
1263
|
-
case "8":
|
|
1264
|
-
return "8px";
|
|
1265
|
-
default:
|
|
1266
|
-
return null;
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
function ringValue(theme, parsed) {
|
|
1270
|
-
const value = parsed.value;
|
|
1271
|
-
if (value === null) return null;
|
|
1272
|
-
if (value === "inset") {
|
|
1273
|
-
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1274
|
-
}
|
|
1275
|
-
if (!parsed.isArbitrary) {
|
|
1276
|
-
const w = ringWidth(value);
|
|
1277
|
-
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1278
|
-
}
|
|
1279
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1280
|
-
if (color === null) return null;
|
|
1281
|
-
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1282
|
-
}
|
|
1283
|
-
function ringOffsetValue(theme, parsed) {
|
|
1284
|
-
const value = parsed.value;
|
|
1285
|
-
if (value === null) return null;
|
|
1286
|
-
if (!parsed.isArbitrary) {
|
|
1287
|
-
const w = ringWidth(value);
|
|
1288
|
-
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1289
|
-
}
|
|
1290
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1291
|
-
if (color === null) return null;
|
|
1292
|
-
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1897
|
+
const v = parsed.isArbitrary ? value : outlineWidthValue(value);
|
|
1898
|
+
if (v === null) return null;
|
|
1899
|
+
return [decl("outline-offset", parsed.negative ? negate(v) : v)];
|
|
1293
1900
|
}
|
|
1294
1901
|
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1295
1902
|
function resolve3(parsed, theme) {
|
|
@@ -1319,14 +1926,19 @@ function resolve3(parsed, theme) {
|
|
|
1319
1926
|
const v = resolveLength(theme, parsed);
|
|
1320
1927
|
return v === null ? null : [decl("border-radius", v)];
|
|
1321
1928
|
}
|
|
1929
|
+
// Rings are web-only (a var()-composed CSS box-shadow React Native can't
|
|
1930
|
+
// parse) — same as resolvers/mod.rs's native dispatcher.
|
|
1322
1931
|
case "ring":
|
|
1323
|
-
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1324
|
-
return ringValue(theme, parsed);
|
|
1325
1932
|
case "ring-offset":
|
|
1326
|
-
return
|
|
1933
|
+
return null;
|
|
1934
|
+
// Outlines: the same final native style the Rust engine produces once
|
|
1935
|
+
// its var()-based web declarations are filtered out (resolve_style.rs):
|
|
1936
|
+
// bare `outline` is a 1px width, `outline-none` is outline-style: none,
|
|
1937
|
+
// `outline-hidden` keeps only its offset (RN has no `outline` shorthand).
|
|
1327
1938
|
case "outline":
|
|
1328
|
-
if (parsed.value === null) return [decl("outline-
|
|
1329
|
-
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1939
|
+
if (parsed.value === null) return [decl("outline-width", "1px")];
|
|
1940
|
+
if (parsed.value === "none") return [decl("outline-style", "none")];
|
|
1941
|
+
if (!parsed.isArbitrary && parsed.value === "hidden") return [decl("outline-offset", "2px")];
|
|
1330
1942
|
return outlineValue(theme, parsed);
|
|
1331
1943
|
case "outline-offset":
|
|
1332
1944
|
return outlineOffsetValue(parsed);
|
|
@@ -1357,32 +1969,75 @@ function textSize(key) {
|
|
|
1357
1969
|
return "1.875rem";
|
|
1358
1970
|
case "4xl":
|
|
1359
1971
|
return "2.25rem";
|
|
1972
|
+
case "5xl":
|
|
1973
|
+
return "3rem";
|
|
1974
|
+
case "6xl":
|
|
1975
|
+
return "3.75rem";
|
|
1976
|
+
case "7xl":
|
|
1977
|
+
return "4.5rem";
|
|
1978
|
+
case "8xl":
|
|
1979
|
+
return "6rem";
|
|
1980
|
+
case "9xl":
|
|
1981
|
+
return "8rem";
|
|
1360
1982
|
default:
|
|
1361
1983
|
return null;
|
|
1362
1984
|
}
|
|
1363
1985
|
}
|
|
1364
1986
|
function lineHeightSize(key) {
|
|
1987
|
+
if (key === "px") return "1px";
|
|
1988
|
+
if (key.trim() === "") return null;
|
|
1989
|
+
const n = Number(key);
|
|
1990
|
+
return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
|
|
1991
|
+
}
|
|
1992
|
+
function leadingNamed(key) {
|
|
1365
1993
|
switch (key) {
|
|
1366
|
-
case "
|
|
1367
|
-
return
|
|
1368
|
-
case "
|
|
1369
|
-
return
|
|
1370
|
-
case "
|
|
1371
|
-
return
|
|
1372
|
-
case "
|
|
1373
|
-
return
|
|
1374
|
-
case "
|
|
1375
|
-
return
|
|
1376
|
-
case "
|
|
1377
|
-
return
|
|
1378
|
-
case "9":
|
|
1379
|
-
return "2.25rem";
|
|
1380
|
-
case "10":
|
|
1381
|
-
return "2.5rem";
|
|
1994
|
+
case "none":
|
|
1995
|
+
return 1;
|
|
1996
|
+
case "tight":
|
|
1997
|
+
return 1.25;
|
|
1998
|
+
case "snug":
|
|
1999
|
+
return 1.375;
|
|
2000
|
+
case "normal":
|
|
2001
|
+
return 1.5;
|
|
2002
|
+
case "relaxed":
|
|
2003
|
+
return 1.625;
|
|
2004
|
+
case "loose":
|
|
2005
|
+
return 2;
|
|
1382
2006
|
default:
|
|
1383
2007
|
return null;
|
|
1384
2008
|
}
|
|
1385
2009
|
}
|
|
2010
|
+
function splitSizeLeading(value) {
|
|
2011
|
+
const i = value.indexOf("/");
|
|
2012
|
+
if (i === -1) return null;
|
|
2013
|
+
const size = textSize(value.slice(0, i));
|
|
2014
|
+
const leading = value.slice(i + 1);
|
|
2015
|
+
return size === null || leading === "" ? null : [size, leading];
|
|
2016
|
+
}
|
|
2017
|
+
function sizeLeadingNative(size, leading) {
|
|
2018
|
+
const rem = (n) => {
|
|
2019
|
+
const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
|
|
2020
|
+
if (unit === null) return null;
|
|
2021
|
+
const number = size.slice(0, -unit.length);
|
|
2022
|
+
const s = Number(number);
|
|
2023
|
+
return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
|
|
2024
|
+
};
|
|
2025
|
+
const arbitrary = arbitraryModifier(leading);
|
|
2026
|
+
if (arbitrary !== null) {
|
|
2027
|
+
if (arbitrary.startsWith("var(")) return null;
|
|
2028
|
+
const n = Number(arbitrary);
|
|
2029
|
+
return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
|
|
2030
|
+
}
|
|
2031
|
+
const scale = lineHeightSize(leading);
|
|
2032
|
+
if (scale !== null) return scale;
|
|
2033
|
+
const m = leadingNamed(leading);
|
|
2034
|
+
return m === null ? null : rem(m);
|
|
2035
|
+
}
|
|
2036
|
+
function arbitraryFontIsWeight(parsed, value) {
|
|
2037
|
+
const hint = parsed.typeHint ?? null;
|
|
2038
|
+
if (hint !== null) return hint === "number" || hint === "integer";
|
|
2039
|
+
return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
|
|
2040
|
+
}
|
|
1386
2041
|
function textAlign(key) {
|
|
1387
2042
|
switch (key) {
|
|
1388
2043
|
case "left":
|
|
@@ -1393,6 +2048,12 @@ function textAlign(key) {
|
|
|
1393
2048
|
return "right";
|
|
1394
2049
|
case "justify":
|
|
1395
2050
|
return "justify";
|
|
2051
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
2052
|
+
// as layout.rs's start/end inset properties.
|
|
2053
|
+
case "start":
|
|
2054
|
+
return "start";
|
|
2055
|
+
case "end":
|
|
2056
|
+
return "end";
|
|
1396
2057
|
default:
|
|
1397
2058
|
return null;
|
|
1398
2059
|
}
|
|
@@ -1401,6 +2062,10 @@ function fontWeight(key) {
|
|
|
1401
2062
|
switch (key) {
|
|
1402
2063
|
case "thin":
|
|
1403
2064
|
return "100";
|
|
2065
|
+
case "extralight":
|
|
2066
|
+
return "200";
|
|
2067
|
+
case "light":
|
|
2068
|
+
return "300";
|
|
1404
2069
|
case "normal":
|
|
1405
2070
|
return "400";
|
|
1406
2071
|
case "medium":
|
|
@@ -1411,6 +2076,22 @@ function fontWeight(key) {
|
|
|
1411
2076
|
return "700";
|
|
1412
2077
|
case "extrabold":
|
|
1413
2078
|
return "800";
|
|
2079
|
+
case "black":
|
|
2080
|
+
return "900";
|
|
2081
|
+
default:
|
|
2082
|
+
return null;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
function fontFamilyValue(theme, key) {
|
|
2086
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
2087
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
2088
|
+
switch (key) {
|
|
2089
|
+
case "sans":
|
|
2090
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
2091
|
+
case "serif":
|
|
2092
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
2093
|
+
case "mono":
|
|
2094
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1414
2095
|
default:
|
|
1415
2096
|
return null;
|
|
1416
2097
|
}
|
|
@@ -1419,8 +2100,14 @@ function fontWeight(key) {
|
|
|
1419
2100
|
// src/jsEngine/resolvers/effects.ts
|
|
1420
2101
|
function nativeShadowValue(key) {
|
|
1421
2102
|
switch (key) {
|
|
1422
|
-
|
|
2103
|
+
// Tailwind v4.3's scale, like effects.rs: `sm` is the default shadow,
|
|
2104
|
+
// v3's `sm` is `xs`.
|
|
2105
|
+
case "2xs":
|
|
2106
|
+
return { offsetY: 1, radius: 0, opacity: 0.05, elevation: 1 };
|
|
2107
|
+
case "xs":
|
|
1423
2108
|
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
2109
|
+
case "sm":
|
|
2110
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1424
2111
|
case "DEFAULT":
|
|
1425
2112
|
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1426
2113
|
case "md":
|
|
@@ -1452,13 +2139,115 @@ function nativeShadowDeclarations(parsed) {
|
|
|
1452
2139
|
];
|
|
1453
2140
|
}
|
|
1454
2141
|
|
|
2142
|
+
// src/jsEngine/resolvers/transform.ts
|
|
2143
|
+
function scaleFactor(parsed) {
|
|
2144
|
+
if (parsed.value === null || parsed.value.trim() === "") return null;
|
|
2145
|
+
const n = Number(parsed.value);
|
|
2146
|
+
if (!Number.isFinite(n)) return null;
|
|
2147
|
+
const factor = parsed.isArbitrary ? n : n / 100;
|
|
2148
|
+
return parsed.negative ? -factor : factor;
|
|
2149
|
+
}
|
|
2150
|
+
function angle(parsed) {
|
|
2151
|
+
if (parsed.value === null) return null;
|
|
2152
|
+
if (parsed.isArbitrary) {
|
|
2153
|
+
if (!parsed.negative) return parsed.value;
|
|
2154
|
+
if (parsed.value.startsWith("-")) return parsed.value.slice(1);
|
|
2155
|
+
if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
|
|
2156
|
+
return `calc(${parsed.value} * -1)`;
|
|
2157
|
+
}
|
|
2158
|
+
const n = Number(parsed.value);
|
|
2159
|
+
if (!Number.isFinite(n)) return null;
|
|
2160
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
2161
|
+
}
|
|
2162
|
+
function resolveNative(parsed, theme) {
|
|
2163
|
+
switch (parsed.utility) {
|
|
2164
|
+
case "transform-none":
|
|
2165
|
+
return [decl("transform-op-none", "1")];
|
|
2166
|
+
// Both axes at once (`translate-4`, `-skew-3`); mirrors transform.rs.
|
|
2167
|
+
case "translate": {
|
|
2168
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-translate-x", "0"), decl("transform-op-translate-y", "0")];
|
|
2169
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2170
|
+
return v === null ? null : [decl("transform-op-translate-x", v), decl("transform-op-translate-y", v)];
|
|
2171
|
+
}
|
|
2172
|
+
case "skew": {
|
|
2173
|
+
const deg = angle(parsed);
|
|
2174
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg), decl("transform-op-skew-y", deg)];
|
|
2175
|
+
}
|
|
2176
|
+
case "backface-visible":
|
|
2177
|
+
return [decl("backface-visibility", "visible")];
|
|
2178
|
+
case "backface-hidden":
|
|
2179
|
+
return [decl("backface-visibility", "hidden")];
|
|
2180
|
+
case "translate-x": {
|
|
2181
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2182
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
2183
|
+
}
|
|
2184
|
+
case "translate-y": {
|
|
2185
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
2186
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
2187
|
+
}
|
|
2188
|
+
case "scale": {
|
|
2189
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-scale-x", "1"), decl("transform-op-scale-y", "1")];
|
|
2190
|
+
const n = scaleFactor(parsed);
|
|
2191
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
2192
|
+
}
|
|
2193
|
+
case "scale-x": {
|
|
2194
|
+
const n = scaleFactor(parsed);
|
|
2195
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
2196
|
+
}
|
|
2197
|
+
case "scale-y": {
|
|
2198
|
+
const n = scaleFactor(parsed);
|
|
2199
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
2200
|
+
}
|
|
2201
|
+
case "rotate": {
|
|
2202
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-rotate", "0deg")];
|
|
2203
|
+
const deg = angle(parsed);
|
|
2204
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
2205
|
+
}
|
|
2206
|
+
case "rotate-x": {
|
|
2207
|
+
const deg = angle(parsed);
|
|
2208
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
2209
|
+
}
|
|
2210
|
+
case "rotate-y": {
|
|
2211
|
+
const deg = angle(parsed);
|
|
2212
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
2213
|
+
}
|
|
2214
|
+
case "rotate-z": {
|
|
2215
|
+
const deg = angle(parsed);
|
|
2216
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
2217
|
+
}
|
|
2218
|
+
case "skew-x": {
|
|
2219
|
+
const deg = angle(parsed);
|
|
2220
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
2221
|
+
}
|
|
2222
|
+
case "skew-y": {
|
|
2223
|
+
const deg = angle(parsed);
|
|
2224
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
2225
|
+
}
|
|
2226
|
+
default:
|
|
2227
|
+
return null;
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
|
|
1455
2231
|
// src/jsEngine/resolveUtilityNative.ts
|
|
1456
|
-
function
|
|
2232
|
+
function firstFontName(stack) {
|
|
2233
|
+
const first = stack.split(",")[0] ?? stack;
|
|
2234
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
2235
|
+
}
|
|
2236
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1457
2237
|
switch (parsed.utility) {
|
|
1458
2238
|
case "font": {
|
|
1459
2239
|
if (parsed.value === null) return null;
|
|
2240
|
+
if (parsed.isArbitrary) {
|
|
2241
|
+
if (arbitraryFontIsWeight(parsed, parsed.value)) {
|
|
2242
|
+
const n = Number(parsed.value);
|
|
2243
|
+
return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
|
|
2244
|
+
}
|
|
2245
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
2246
|
+
}
|
|
1460
2247
|
const w = fontWeight(parsed.value);
|
|
1461
|
-
|
|
2248
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
2249
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
2250
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1462
2251
|
}
|
|
1463
2252
|
case "uppercase":
|
|
1464
2253
|
return [decl("text-transform", "uppercase")];
|
|
@@ -1494,16 +2283,27 @@ function resolveLeadingTrackingNative(parsed) {
|
|
|
1494
2283
|
return null;
|
|
1495
2284
|
}
|
|
1496
2285
|
function nativeHexColor(parsed, theme) {
|
|
1497
|
-
|
|
1498
|
-
if (value === null) return null;
|
|
1499
|
-
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
2286
|
+
return colorValue(theme, parsed);
|
|
1500
2287
|
}
|
|
1501
2288
|
function resolveTextNative(parsed, theme) {
|
|
1502
2289
|
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1503
2290
|
const size = textSize(parsed.value);
|
|
1504
2291
|
if (size !== null) return [decl("font-size", size)];
|
|
2292
|
+
const sized = splitSizeLeading(parsed.value);
|
|
2293
|
+
if (sized !== null) {
|
|
2294
|
+
const lh = sizeLeadingNative(sized[0], sized[1]);
|
|
2295
|
+
return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
|
|
2296
|
+
}
|
|
1505
2297
|
const align = textAlign(parsed.value);
|
|
1506
2298
|
if (align !== null) return [decl("text-align", align)];
|
|
2299
|
+
} else if (parsed.isArbitrary && parsed.value !== null) {
|
|
2300
|
+
const leading = parsed.modifier ?? null;
|
|
2301
|
+
if (isLength(parsed, parsed.value)) {
|
|
2302
|
+
if (leading === null) return [decl("font-size", parsed.value)];
|
|
2303
|
+
const lh = sizeLeadingNative(parsed.value, leading);
|
|
2304
|
+
return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
|
|
2305
|
+
}
|
|
2306
|
+
if (leading !== null) return null;
|
|
1507
2307
|
}
|
|
1508
2308
|
const hex = nativeHexColor(parsed, theme);
|
|
1509
2309
|
return hex === null ? null : [decl("color", hex)];
|
|
@@ -1520,13 +2320,20 @@ function resolveColorNative(parsed, theme) {
|
|
|
1520
2320
|
return null;
|
|
1521
2321
|
}
|
|
1522
2322
|
}
|
|
2323
|
+
function resolveOpacityNative(parsed) {
|
|
2324
|
+
if (parsed.utility !== "opacity") return null;
|
|
2325
|
+
const v = resolvePercent(parsed);
|
|
2326
|
+
return v === null ? null : [decl("opacity", v)];
|
|
2327
|
+
}
|
|
1523
2328
|
function resolveUtilityNative(parsed, theme) {
|
|
1524
|
-
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
2329
|
+
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);
|
|
1525
2330
|
}
|
|
1526
2331
|
|
|
1527
2332
|
// src/jsEngine/resolveStyle.ts
|
|
1528
2333
|
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
2334
|
+
var STATE_HOLD_MARKER2 = "_kbon";
|
|
1529
2335
|
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
2336
|
+
if (modifier === STATE_HOLD_MARKER2) return true;
|
|
1530
2337
|
if (modifier === "dark") return colorScheme === "dark";
|
|
1531
2338
|
if (modifier === "active") return pressed;
|
|
1532
2339
|
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
@@ -1534,6 +2341,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
|
1534
2341
|
if (minWidth === void 0) return null;
|
|
1535
2342
|
return width >= minWidth;
|
|
1536
2343
|
}
|
|
2344
|
+
if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
|
|
2345
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
2346
|
+
return px === null ? null : width >= px;
|
|
2347
|
+
}
|
|
2348
|
+
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
2349
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
2350
|
+
return px === null ? null : width < px;
|
|
2351
|
+
}
|
|
2352
|
+
const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
|
|
2353
|
+
const custom = screen(modifier);
|
|
2354
|
+
if (typeof custom === "number") return width >= custom;
|
|
2355
|
+
if (modifier.startsWith("max-")) {
|
|
2356
|
+
const max = screen(modifier.slice(4));
|
|
2357
|
+
if (typeof max === "number") return width < max;
|
|
2358
|
+
}
|
|
2359
|
+
if (modifier.startsWith("min-")) {
|
|
2360
|
+
const min = screen(modifier.slice(4));
|
|
2361
|
+
if (typeof min === "number") return width >= min;
|
|
2362
|
+
}
|
|
2363
|
+
if (modifier.startsWith("not-")) {
|
|
2364
|
+
const rest = modifier.slice(4);
|
|
2365
|
+
if (rest === "dark") return colorScheme !== "dark";
|
|
2366
|
+
const isBreakpoint = (name) => typeof screen(name) === "number";
|
|
2367
|
+
if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
|
|
2368
|
+
const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
|
|
2369
|
+
return holds === null ? null : !holds;
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
1537
2372
|
return null;
|
|
1538
2373
|
}
|
|
1539
2374
|
function kebabToCamel(s) {
|
|
@@ -1578,6 +2413,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1578
2413
|
"shadow-opacity",
|
|
1579
2414
|
"shadow-radius",
|
|
1580
2415
|
"elevation",
|
|
2416
|
+
"opacity",
|
|
1581
2417
|
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1582
2418
|
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1583
2419
|
// style system wants plain numbers for these exactly like the generic
|
|
@@ -1591,29 +2427,105 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1591
2427
|
"border-bottom-right-radius",
|
|
1592
2428
|
"border-bottom-left-radius",
|
|
1593
2429
|
"outline-width",
|
|
1594
|
-
"outline-offset"
|
|
2430
|
+
"outline-offset",
|
|
2431
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
2432
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
2433
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
2434
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
2435
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
2436
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
2437
|
+
// get collected into the final array.
|
|
2438
|
+
"transform-op-translate-x",
|
|
2439
|
+
"transform-op-translate-y",
|
|
2440
|
+
"transform-op-scale-x",
|
|
2441
|
+
"transform-op-scale-y"
|
|
2442
|
+
]);
|
|
2443
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
2444
|
+
["transform-op-translate-x", "translateX"],
|
|
2445
|
+
["transform-op-translate-y", "translateY"],
|
|
2446
|
+
["transform-op-rotate", "rotate"],
|
|
2447
|
+
["transform-op-rotate-x", "rotateX"],
|
|
2448
|
+
["transform-op-rotate-y", "rotateY"],
|
|
2449
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
2450
|
+
["transform-op-skew-x", "skewX"],
|
|
2451
|
+
["transform-op-skew-y", "skewY"],
|
|
2452
|
+
["transform-op-scale-x", "scaleX"],
|
|
2453
|
+
["transform-op-scale-y", "scaleY"]
|
|
1595
2454
|
]);
|
|
2455
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
2456
|
+
function isPlainPercentage(value) {
|
|
2457
|
+
if (!value.endsWith("%")) return false;
|
|
2458
|
+
let digits = value.slice(0, -1);
|
|
2459
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
2460
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
2461
|
+
}
|
|
2462
|
+
function sanitizeForWarning(value) {
|
|
2463
|
+
const MAX_CHARS = 60;
|
|
2464
|
+
const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
|
|
2465
|
+
if (escaped.length <= MAX_CHARS) return escaped;
|
|
2466
|
+
return `${escaped.slice(0, MAX_CHARS)}\u2026`;
|
|
2467
|
+
}
|
|
1596
2468
|
function rnStyleValue(property, value) {
|
|
1597
|
-
if (
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
2469
|
+
if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
|
|
2470
|
+
const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
|
|
2471
|
+
const space = inner.lastIndexOf(" ");
|
|
2472
|
+
if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
|
|
2473
|
+
}
|
|
2474
|
+
if (property === "aspect-ratio") {
|
|
2475
|
+
if (value.trim() === "auto") return { value: null, warning: null };
|
|
2476
|
+
const parts = value.split("/").map((s) => s.trim());
|
|
2477
|
+
let n = null;
|
|
2478
|
+
if (parts.length === 1) {
|
|
2479
|
+
const a = Number(parts[0]);
|
|
2480
|
+
n = Number.isFinite(a) ? a : null;
|
|
2481
|
+
} else if (parts.length === 2) {
|
|
2482
|
+
const a = Number(parts[0]);
|
|
2483
|
+
const b = Number(parts[1]);
|
|
2484
|
+
n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
|
|
1608
2485
|
}
|
|
1609
|
-
|
|
2486
|
+
return { value: n, warning: null };
|
|
1610
2487
|
}
|
|
1611
|
-
|
|
2488
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
2489
|
+
return { value, warning: null };
|
|
2490
|
+
}
|
|
2491
|
+
if (value === "auto") {
|
|
2492
|
+
return { value: "auto", warning: null };
|
|
2493
|
+
}
|
|
2494
|
+
let px = null;
|
|
2495
|
+
if (value.endsWith("px")) {
|
|
2496
|
+
const n = Number(value.slice(0, -2));
|
|
2497
|
+
px = Number.isFinite(n) ? n : null;
|
|
2498
|
+
} else if (value.endsWith("rem")) {
|
|
2499
|
+
const n = Number(value.slice(0, -3));
|
|
2500
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
2501
|
+
} else {
|
|
2502
|
+
const n = Number(value);
|
|
2503
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
2504
|
+
}
|
|
2505
|
+
if (px !== null) return { value: px, warning: null };
|
|
2506
|
+
if (isPlainPercentage(value)) {
|
|
2507
|
+
return { value, warning: null };
|
|
2508
|
+
}
|
|
2509
|
+
const reduced = reduceConstantMath(value);
|
|
2510
|
+
if (reduced !== null) {
|
|
2511
|
+
return { value: reduced, warning: null };
|
|
2512
|
+
}
|
|
2513
|
+
const sanitizedValue = sanitizeForWarning(value);
|
|
2514
|
+
const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
2515
|
+
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).
|
|
2516
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
2517
|
+
return { value: null, warning };
|
|
1612
2518
|
}
|
|
1613
|
-
function
|
|
2519
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
2520
|
+
classString = expandVariantGroups(classString);
|
|
1614
2521
|
const style = {};
|
|
2522
|
+
const warnings = [];
|
|
1615
2523
|
let shadowOffset = null;
|
|
1616
|
-
|
|
2524
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
2525
|
+
const keySpecificity = /* @__PURE__ */ new Map();
|
|
2526
|
+
const transformSpecificity = /* @__PURE__ */ new Map();
|
|
2527
|
+
for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
|
|
2528
|
+
const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
|
|
1617
2529
|
const parsed = parseClass(token);
|
|
1618
2530
|
const allModifiersHold = parsed.modifiers.every(
|
|
1619
2531
|
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
@@ -1621,36 +2533,121 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
|
1621
2533
|
if (!allModifiersHold) continue;
|
|
1622
2534
|
const decls = resolveUtilityNative(parsed, theme);
|
|
1623
2535
|
if (decls === null) continue;
|
|
2536
|
+
const spec = parsed.modifiers.length;
|
|
1624
2537
|
for (const d of decls) {
|
|
1625
2538
|
if (d.property.startsWith("__")) {
|
|
1626
2539
|
continue;
|
|
1627
2540
|
}
|
|
2541
|
+
if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
|
|
2542
|
+
continue;
|
|
2543
|
+
}
|
|
1628
2544
|
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
2545
|
+
if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
|
|
1629
2546
|
const n = Number(d.value);
|
|
1630
2547
|
if (!Number.isFinite(n)) continue;
|
|
1631
2548
|
if (shadowOffset === null) shadowOffset = {};
|
|
1632
2549
|
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
2550
|
+
keySpecificity.set("shadowOffset", spec);
|
|
1633
2551
|
continue;
|
|
1634
2552
|
}
|
|
1635
|
-
|
|
2553
|
+
if (d.property === "transform-op-none") {
|
|
2554
|
+
transformOps.clear();
|
|
2555
|
+
transformSpecificity.clear();
|
|
2556
|
+
continue;
|
|
2557
|
+
}
|
|
2558
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
2559
|
+
if (opKey !== void 0) {
|
|
2560
|
+
if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
|
|
2561
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
2562
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
2563
|
+
if (value2 !== null) {
|
|
2564
|
+
transformOps.set(opKey, value2);
|
|
2565
|
+
transformSpecificity.set(opKey, spec);
|
|
2566
|
+
}
|
|
2567
|
+
continue;
|
|
2568
|
+
}
|
|
2569
|
+
const key = kebabToCamel(d.property);
|
|
2570
|
+
if (spec < (keySpecificity.get(key) ?? 0)) continue;
|
|
2571
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
2572
|
+
if (warning !== null) warnings.push(warning);
|
|
2573
|
+
if (value !== null) {
|
|
2574
|
+
style[key] = value;
|
|
2575
|
+
keySpecificity.set(key, spec);
|
|
2576
|
+
}
|
|
1636
2577
|
}
|
|
1637
2578
|
}
|
|
1638
2579
|
if (shadowOffset !== null) {
|
|
1639
2580
|
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1640
2581
|
}
|
|
1641
|
-
|
|
2582
|
+
if (transformOps.size > 0) {
|
|
2583
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
2584
|
+
[key]: transformOps.get(key)
|
|
2585
|
+
}));
|
|
2586
|
+
}
|
|
2587
|
+
return { style, warnings };
|
|
1642
2588
|
}
|
|
1643
2589
|
|
|
1644
2590
|
// src/nativeBridge.ts
|
|
2591
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
2592
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
2593
|
+
var cachedForThemeJson = null;
|
|
1645
2594
|
function resolveStyle(classString, pressed = false) {
|
|
1646
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1647
|
-
const width =
|
|
1648
|
-
const
|
|
2595
|
+
const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
|
|
2596
|
+
const width = import_react_native2.Dimensions.get("window").width;
|
|
2597
|
+
const themeJson = (0, import_theme2.getThemeJson)();
|
|
2598
|
+
if (themeJson !== cachedForThemeJson) {
|
|
2599
|
+
resolveStyleCache.clear();
|
|
2600
|
+
cachedForThemeJson = themeJson;
|
|
2601
|
+
}
|
|
2602
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
2603
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
2604
|
+
if (cached !== void 0) return { ...cached };
|
|
2605
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
2606
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
2607
|
+
resolveStyleCache.set(cacheKey, style);
|
|
2608
|
+
return { ...style };
|
|
2609
|
+
}
|
|
2610
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
2611
|
+
const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
|
|
1649
2612
|
if (!KbachModule) {
|
|
1650
|
-
|
|
2613
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme2.getTheme)(), colorScheme, pressed, width);
|
|
2614
|
+
warnIfDev(classString, warnings2);
|
|
2615
|
+
return style2;
|
|
2616
|
+
}
|
|
2617
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
2618
|
+
const style = JSON.parse(json);
|
|
2619
|
+
const warnings = style.__kbachWarnings;
|
|
2620
|
+
if (warnings !== void 0) {
|
|
2621
|
+
delete style.__kbachWarnings;
|
|
2622
|
+
warnIfDev(classString, warnings);
|
|
2623
|
+
}
|
|
2624
|
+
return style;
|
|
2625
|
+
}
|
|
2626
|
+
var WARNED_MESSAGES_MAX = 500;
|
|
2627
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
2628
|
+
var QUOTED_TOKEN_RE = /"([^"]*)"/;
|
|
2629
|
+
function highlightToken(classString, warning) {
|
|
2630
|
+
const match = QUOTED_TOKEN_RE.exec(warning);
|
|
2631
|
+
if (match === null) return classString;
|
|
2632
|
+
const quoted = match[1].replace(/\s+/g, "");
|
|
2633
|
+
if (quoted === "") return classString;
|
|
2634
|
+
const parts = classString.split(/(\s+)/);
|
|
2635
|
+
const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
|
|
2636
|
+
if (idx === -1) return classString;
|
|
2637
|
+
parts[idx] = `\xBB${parts[idx]}\xAB`;
|
|
2638
|
+
return parts.join("");
|
|
2639
|
+
}
|
|
2640
|
+
function warnIfDev(classString, warnings) {
|
|
2641
|
+
if (warnings.length === 0) return;
|
|
2642
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
2643
|
+
for (const warning of warnings) {
|
|
2644
|
+
const message = `${warning}
|
|
2645
|
+
From className: "${highlightToken(classString, warning)}"`;
|
|
2646
|
+
if (warnedMessages.has(message)) continue;
|
|
2647
|
+
if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
|
|
2648
|
+
warnedMessages.add(message);
|
|
2649
|
+
console.warn(message);
|
|
1651
2650
|
}
|
|
1652
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1653
|
-
return JSON.parse(json);
|
|
1654
2651
|
}
|
|
1655
2652
|
|
|
1656
2653
|
// src/jsx-runtime.tsx
|