@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/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,437 +17,55 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var src_exports = {};
|
|
22
32
|
__export(src_exports, {
|
|
33
|
+
Button: () => Button,
|
|
34
|
+
H1: () => H1,
|
|
35
|
+
H2: () => H2,
|
|
36
|
+
H3: () => H3,
|
|
37
|
+
H4: () => H4,
|
|
38
|
+
H5: () => H5,
|
|
39
|
+
H6: () => H6,
|
|
40
|
+
Paragraph: () => Paragraph,
|
|
23
41
|
ThemeProvider: () => ThemeProvider,
|
|
24
42
|
applyKbachConfig: () => applyKbachConfig,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
clsx: () => clsx,
|
|
44
|
+
defaultTheme: () => import_theme4.defaultTheme,
|
|
45
|
+
deleteDynamicToken: () => import_dynamicTokens2.deleteDynamicToken,
|
|
46
|
+
getDynamicToken: () => import_dynamicTokens2.getDynamicToken,
|
|
47
|
+
getGlobalDarkMode: () => import_darkModeStore5.getGlobalDarkMode,
|
|
48
|
+
getGlobalThemeMode: () => import_darkModeStore5.getGlobalThemeMode,
|
|
49
|
+
getTheme: () => import_theme4.getTheme,
|
|
29
50
|
resolveKbachConfig: () => resolveKbachConfig,
|
|
30
51
|
resolveStyle: () => resolveStyle,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
52
|
+
setDynamicToken: () => import_dynamicTokens2.setDynamicToken,
|
|
53
|
+
setGlobalThemeMode: () => import_darkModeStore5.setGlobalThemeMode,
|
|
54
|
+
setTheme: () => import_theme4.setTheme,
|
|
55
|
+
subscribeDynamicTokens: () => import_dynamicTokens2.subscribeDynamicTokens,
|
|
56
|
+
subscribeGlobalDarkMode: () => import_darkModeStore5.subscribeGlobalDarkMode,
|
|
57
|
+
toggleGlobalDarkMode: () => import_darkModeStore5.toggleGlobalDarkMode,
|
|
35
58
|
useColors: () => useColors,
|
|
59
|
+
useDynamicToken: () => useDynamicToken,
|
|
36
60
|
useTheme: () => useTheme
|
|
37
61
|
});
|
|
38
62
|
module.exports = __toCommonJS(src_exports);
|
|
39
|
-
|
|
40
|
-
// src/generatedPalette.ts
|
|
41
|
-
var PALETTE = {
|
|
42
|
-
"amber-1": "#fffbeb",
|
|
43
|
-
"amber-10": "#78350f",
|
|
44
|
-
"amber-11": "#451a03",
|
|
45
|
-
"amber-12": "#291002",
|
|
46
|
-
"amber-2": "#fef3c7",
|
|
47
|
-
"amber-3": "#fde68a",
|
|
48
|
-
"amber-4": "#fcd34d",
|
|
49
|
-
"amber-5": "#fbbf24",
|
|
50
|
-
"amber-6": "#f59e0b",
|
|
51
|
-
"amber-7": "#d97706",
|
|
52
|
-
"amber-8": "#b45309",
|
|
53
|
-
"amber-9": "#92400e",
|
|
54
|
-
"black": "#000000",
|
|
55
|
-
"blue-1": "#eff6ff",
|
|
56
|
-
"blue-10": "#1e3a8a",
|
|
57
|
-
"blue-11": "#172554",
|
|
58
|
-
"blue-12": "#0d1633",
|
|
59
|
-
"blue-2": "#dbeafe",
|
|
60
|
-
"blue-3": "#bfdbfe",
|
|
61
|
-
"blue-4": "#93c5fd",
|
|
62
|
-
"blue-5": "#60a5fa",
|
|
63
|
-
"blue-6": "#3b82f6",
|
|
64
|
-
"blue-7": "#2563eb",
|
|
65
|
-
"blue-8": "#1d4ed8",
|
|
66
|
-
"blue-9": "#1e40af",
|
|
67
|
-
"bronze": "#cd7f32",
|
|
68
|
-
"coal": "#1c1c1c",
|
|
69
|
-
"copper": "#b87333",
|
|
70
|
-
"current": "currentColor",
|
|
71
|
-
"cyan-1": "#ecfeff",
|
|
72
|
-
"cyan-10": "#164e63",
|
|
73
|
-
"cyan-11": "#083344",
|
|
74
|
-
"cyan-12": "#041e28",
|
|
75
|
-
"cyan-2": "#cffafe",
|
|
76
|
-
"cyan-3": "#a5f3fc",
|
|
77
|
-
"cyan-4": "#67e8f9",
|
|
78
|
-
"cyan-5": "#22d3ee",
|
|
79
|
-
"cyan-6": "#06b6d4",
|
|
80
|
-
"cyan-7": "#0891b2",
|
|
81
|
-
"cyan-8": "#0e7490",
|
|
82
|
-
"cyan-9": "#155e75",
|
|
83
|
-
"emerald-1": "#ecfdf5",
|
|
84
|
-
"emerald-10": "#064e3b",
|
|
85
|
-
"emerald-11": "#022c22",
|
|
86
|
-
"emerald-12": "#011a14",
|
|
87
|
-
"emerald-2": "#d1fae5",
|
|
88
|
-
"emerald-3": "#a7f3d0",
|
|
89
|
-
"emerald-4": "#6ee7b7",
|
|
90
|
-
"emerald-5": "#34d399",
|
|
91
|
-
"emerald-6": "#10b981",
|
|
92
|
-
"emerald-7": "#059669",
|
|
93
|
-
"emerald-8": "#047857",
|
|
94
|
-
"emerald-9": "#065f46",
|
|
95
|
-
"fuchsia-1": "#fdf4ff",
|
|
96
|
-
"fuchsia-10": "#701a75",
|
|
97
|
-
"fuchsia-11": "#4a044e",
|
|
98
|
-
"fuchsia-12": "#2d022f",
|
|
99
|
-
"fuchsia-2": "#fae8ff",
|
|
100
|
-
"fuchsia-3": "#f5d0fe",
|
|
101
|
-
"fuchsia-4": "#f0abfc",
|
|
102
|
-
"fuchsia-5": "#e879f9",
|
|
103
|
-
"fuchsia-6": "#d946ef",
|
|
104
|
-
"fuchsia-7": "#c026d3",
|
|
105
|
-
"fuchsia-8": "#a21caf",
|
|
106
|
-
"fuchsia-9": "#86198f",
|
|
107
|
-
"gold": "#d4af37",
|
|
108
|
-
"gray-1": "#f9fafb",
|
|
109
|
-
"gray-10": "#111827",
|
|
110
|
-
"gray-11": "#030712",
|
|
111
|
-
"gray-12": "#020409",
|
|
112
|
-
"gray-2": "#f3f4f6",
|
|
113
|
-
"gray-3": "#e5e7eb",
|
|
114
|
-
"gray-4": "#d1d5db",
|
|
115
|
-
"gray-5": "#9ca3af",
|
|
116
|
-
"gray-6": "#6b7280",
|
|
117
|
-
"gray-7": "#4b5563",
|
|
118
|
-
"gray-8": "#374151",
|
|
119
|
-
"gray-9": "#1f2937",
|
|
120
|
-
"green-1": "#f0fdf4",
|
|
121
|
-
"green-10": "#14532d",
|
|
122
|
-
"green-11": "#052e16",
|
|
123
|
-
"green-12": "#031b0d",
|
|
124
|
-
"green-2": "#dcfce7",
|
|
125
|
-
"green-3": "#bbf7d0",
|
|
126
|
-
"green-4": "#86efac",
|
|
127
|
-
"green-5": "#4ade80",
|
|
128
|
-
"green-6": "#22c55e",
|
|
129
|
-
"green-7": "#16a34a",
|
|
130
|
-
"green-8": "#15803d",
|
|
131
|
-
"green-9": "#166534",
|
|
132
|
-
"indigo-1": "#eef2ff",
|
|
133
|
-
"indigo-10": "#312e81",
|
|
134
|
-
"indigo-11": "#1e1b4b",
|
|
135
|
-
"indigo-12": "#12102d",
|
|
136
|
-
"indigo-2": "#e0e7ff",
|
|
137
|
-
"indigo-3": "#c7d2fe",
|
|
138
|
-
"indigo-4": "#a5b4fc",
|
|
139
|
-
"indigo-5": "#818cf8",
|
|
140
|
-
"indigo-6": "#6366f1",
|
|
141
|
-
"indigo-7": "#4f46e5",
|
|
142
|
-
"indigo-8": "#4338ca",
|
|
143
|
-
"indigo-9": "#3730a3",
|
|
144
|
-
"lime-1": "#f7fee7",
|
|
145
|
-
"lime-10": "#365314",
|
|
146
|
-
"lime-11": "#1a2e05",
|
|
147
|
-
"lime-12": "#0f1b03",
|
|
148
|
-
"lime-2": "#ecfccb",
|
|
149
|
-
"lime-3": "#d9f99d",
|
|
150
|
-
"lime-4": "#bef264",
|
|
151
|
-
"lime-5": "#a3e635",
|
|
152
|
-
"lime-6": "#84cc16",
|
|
153
|
-
"lime-7": "#65a30d",
|
|
154
|
-
"lime-8": "#4d7c0f",
|
|
155
|
-
"lime-9": "#3f6212",
|
|
156
|
-
"neutral-1": "#fafafa",
|
|
157
|
-
"neutral-10": "#171717",
|
|
158
|
-
"neutral-11": "#0a0a0a",
|
|
159
|
-
"neutral-12": "#050505",
|
|
160
|
-
"neutral-2": "#f5f5f5",
|
|
161
|
-
"neutral-3": "#e5e5e5",
|
|
162
|
-
"neutral-4": "#d4d4d4",
|
|
163
|
-
"neutral-5": "#a3a3a3",
|
|
164
|
-
"neutral-6": "#737373",
|
|
165
|
-
"neutral-7": "#525252",
|
|
166
|
-
"neutral-8": "#404040",
|
|
167
|
-
"neutral-9": "#262626",
|
|
168
|
-
"orange-1": "#fff7ed",
|
|
169
|
-
"orange-10": "#7c2d12",
|
|
170
|
-
"orange-11": "#431407",
|
|
171
|
-
"orange-12": "#270c04",
|
|
172
|
-
"orange-2": "#ffedd5",
|
|
173
|
-
"orange-3": "#fed7aa",
|
|
174
|
-
"orange-4": "#fdba74",
|
|
175
|
-
"orange-5": "#fb923c",
|
|
176
|
-
"orange-6": "#f97316",
|
|
177
|
-
"orange-7": "#ea580c",
|
|
178
|
-
"orange-8": "#c2410c",
|
|
179
|
-
"orange-9": "#9a3412",
|
|
180
|
-
"pink-1": "#fdf2f8",
|
|
181
|
-
"pink-10": "#831843",
|
|
182
|
-
"pink-11": "#500724",
|
|
183
|
-
"pink-12": "#300415",
|
|
184
|
-
"pink-2": "#fce7f3",
|
|
185
|
-
"pink-3": "#fbcfe8",
|
|
186
|
-
"pink-4": "#f9a8d4",
|
|
187
|
-
"pink-5": "#f472b6",
|
|
188
|
-
"pink-6": "#ec4899",
|
|
189
|
-
"pink-7": "#db2777",
|
|
190
|
-
"pink-8": "#be185d",
|
|
191
|
-
"pink-9": "#9d174d",
|
|
192
|
-
"purple-1": "#faf5ff",
|
|
193
|
-
"purple-10": "#581c87",
|
|
194
|
-
"purple-11": "#3b0764",
|
|
195
|
-
"purple-12": "#23043c",
|
|
196
|
-
"purple-2": "#f3e8ff",
|
|
197
|
-
"purple-3": "#e9d5ff",
|
|
198
|
-
"purple-4": "#d8b4fe",
|
|
199
|
-
"purple-5": "#c084fc",
|
|
200
|
-
"purple-6": "#a855f7",
|
|
201
|
-
"purple-7": "#9333ea",
|
|
202
|
-
"purple-8": "#7e22ce",
|
|
203
|
-
"purple-9": "#6b21a8",
|
|
204
|
-
"red-1": "#fef2f2",
|
|
205
|
-
"red-10": "#7f1d1d",
|
|
206
|
-
"red-11": "#450a0a",
|
|
207
|
-
"red-12": "#280606",
|
|
208
|
-
"red-2": "#fee2e2",
|
|
209
|
-
"red-3": "#fecaca",
|
|
210
|
-
"red-4": "#fca5a5",
|
|
211
|
-
"red-5": "#f87171",
|
|
212
|
-
"red-6": "#ef4444",
|
|
213
|
-
"red-7": "#dc2626",
|
|
214
|
-
"red-8": "#b91c1c",
|
|
215
|
-
"red-9": "#991b1b",
|
|
216
|
-
"rose-1": "#fff1f2",
|
|
217
|
-
"rose-10": "#881337",
|
|
218
|
-
"rose-11": "#4c0519",
|
|
219
|
-
"rose-12": "#2d030e",
|
|
220
|
-
"rose-2": "#ffe4e6",
|
|
221
|
-
"rose-3": "#fecdd3",
|
|
222
|
-
"rose-4": "#fda4af",
|
|
223
|
-
"rose-5": "#fb7185",
|
|
224
|
-
"rose-6": "#f43f5e",
|
|
225
|
-
"rose-7": "#e11d48",
|
|
226
|
-
"rose-8": "#be123c",
|
|
227
|
-
"rose-9": "#9f1239",
|
|
228
|
-
"silver": "#c0c0c0",
|
|
229
|
-
"sky-1": "#f0f9ff",
|
|
230
|
-
"sky-10": "#0c4a6e",
|
|
231
|
-
"sky-11": "#082f49",
|
|
232
|
-
"sky-12": "#041b2b",
|
|
233
|
-
"sky-2": "#e0f2fe",
|
|
234
|
-
"sky-3": "#bae6fd",
|
|
235
|
-
"sky-4": "#7dd3fc",
|
|
236
|
-
"sky-5": "#38bdf8",
|
|
237
|
-
"sky-6": "#0ea5e9",
|
|
238
|
-
"sky-7": "#0284c7",
|
|
239
|
-
"sky-8": "#0369a1",
|
|
240
|
-
"sky-9": "#075985",
|
|
241
|
-
"slate-1": "#f8fafc",
|
|
242
|
-
"slate-10": "#0f172a",
|
|
243
|
-
"slate-11": "#020617",
|
|
244
|
-
"slate-12": "#01020a",
|
|
245
|
-
"slate-2": "#f1f5f9",
|
|
246
|
-
"slate-3": "#e2e8f0",
|
|
247
|
-
"slate-4": "#cbd5e1",
|
|
248
|
-
"slate-5": "#94a3b8",
|
|
249
|
-
"slate-6": "#64748b",
|
|
250
|
-
"slate-7": "#475569",
|
|
251
|
-
"slate-8": "#334155",
|
|
252
|
-
"slate-9": "#1e293b",
|
|
253
|
-
"stone-1": "#fafaf9",
|
|
254
|
-
"stone-10": "#1c1917",
|
|
255
|
-
"stone-11": "#0c0a09",
|
|
256
|
-
"stone-12": "#070605",
|
|
257
|
-
"stone-2": "#f5f5f4",
|
|
258
|
-
"stone-3": "#e7e5e4",
|
|
259
|
-
"stone-4": "#d6d3d1",
|
|
260
|
-
"stone-5": "#a8a29e",
|
|
261
|
-
"stone-6": "#78716c",
|
|
262
|
-
"stone-7": "#57534e",
|
|
263
|
-
"stone-8": "#44403c",
|
|
264
|
-
"stone-9": "#292524",
|
|
265
|
-
"teal-1": "#f0fdfa",
|
|
266
|
-
"teal-10": "#134e4a",
|
|
267
|
-
"teal-11": "#042f2e",
|
|
268
|
-
"teal-12": "#021c1b",
|
|
269
|
-
"teal-2": "#ccfbf1",
|
|
270
|
-
"teal-3": "#99f6e4",
|
|
271
|
-
"teal-4": "#5eead4",
|
|
272
|
-
"teal-5": "#2dd4bf",
|
|
273
|
-
"teal-6": "#14b8a6",
|
|
274
|
-
"teal-7": "#0d9488",
|
|
275
|
-
"teal-8": "#0f766e",
|
|
276
|
-
"teal-9": "#115e59",
|
|
277
|
-
"transparent": "transparent",
|
|
278
|
-
"violet-1": "#f5f3ff",
|
|
279
|
-
"violet-10": "#4c1d95",
|
|
280
|
-
"violet-11": "#2e1065",
|
|
281
|
-
"violet-12": "#1c0a3d",
|
|
282
|
-
"violet-2": "#ede9fe",
|
|
283
|
-
"violet-3": "#ddd6fe",
|
|
284
|
-
"violet-4": "#c4b5fd",
|
|
285
|
-
"violet-5": "#a78bfa",
|
|
286
|
-
"violet-6": "#8b5cf6",
|
|
287
|
-
"violet-7": "#7c3aed",
|
|
288
|
-
"violet-8": "#6d28d9",
|
|
289
|
-
"violet-9": "#5b21b6",
|
|
290
|
-
"white": "#ffffff",
|
|
291
|
-
"yellow-1": "#fefce8",
|
|
292
|
-
"yellow-10": "#713f12",
|
|
293
|
-
"yellow-11": "#422006",
|
|
294
|
-
"yellow-12": "#271304",
|
|
295
|
-
"yellow-2": "#fef9c3",
|
|
296
|
-
"yellow-3": "#fef08a",
|
|
297
|
-
"yellow-4": "#fde047",
|
|
298
|
-
"yellow-5": "#facc15",
|
|
299
|
-
"yellow-6": "#eab308",
|
|
300
|
-
"yellow-7": "#ca8a04",
|
|
301
|
-
"yellow-8": "#a16207",
|
|
302
|
-
"yellow-9": "#854d0e",
|
|
303
|
-
"zinc-1": "#fafafa",
|
|
304
|
-
"zinc-10": "#18181b",
|
|
305
|
-
"zinc-11": "#09090b",
|
|
306
|
-
"zinc-12": "#050506",
|
|
307
|
-
"zinc-2": "#f4f4f5",
|
|
308
|
-
"zinc-3": "#e4e4e7",
|
|
309
|
-
"zinc-4": "#d4d4d8",
|
|
310
|
-
"zinc-5": "#a1a1aa",
|
|
311
|
-
"zinc-6": "#71717a",
|
|
312
|
-
"zinc-7": "#52525b",
|
|
313
|
-
"zinc-8": "#3f3f46",
|
|
314
|
-
"zinc-9": "#27272a"
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
// src/theme.ts
|
|
318
|
-
var defaultTheme = {
|
|
319
|
-
colors: PALETTE,
|
|
320
|
-
// Real Tailwind's default spacing scale in full — every step is exactly
|
|
321
|
-
// `n * 4px`, including the fractional `.5` steps (`1.5` -> 6px, `2.5` ->
|
|
322
|
-
// 10px, `3.5` -> 14px) and the "px" literal (a bare 1px). Only the
|
|
323
|
-
// "usual stops", though — `jsEngine/shared.ts`'s `spacingPx` (and the
|
|
324
|
-
// native Rust dispatcher's own `spacing_px`) falls back to Tailwind v4's
|
|
325
|
-
// live `n * 4px` formula for any bare numeric step not listed here
|
|
326
|
-
// (`p-0.25`, `w-13`, ...), so this table names the common values and
|
|
327
|
-
// gives a theme override something to target, not the full resolvable
|
|
328
|
-
// set. Mirrors @kbach/react's theme.ts exactly.
|
|
329
|
-
spacing: {
|
|
330
|
-
"0": 0,
|
|
331
|
-
"px": 1,
|
|
332
|
-
"0.5": 2,
|
|
333
|
-
"1": 4,
|
|
334
|
-
"1.5": 6,
|
|
335
|
-
"2": 8,
|
|
336
|
-
"2.5": 10,
|
|
337
|
-
"3": 12,
|
|
338
|
-
"3.5": 14,
|
|
339
|
-
"4": 16,
|
|
340
|
-
"5": 20,
|
|
341
|
-
"6": 24,
|
|
342
|
-
"7": 28,
|
|
343
|
-
"8": 32,
|
|
344
|
-
"9": 36,
|
|
345
|
-
"10": 40,
|
|
346
|
-
"11": 44,
|
|
347
|
-
"12": 48,
|
|
348
|
-
"14": 56,
|
|
349
|
-
"16": 64,
|
|
350
|
-
"20": 80,
|
|
351
|
-
"24": 96,
|
|
352
|
-
"28": 112,
|
|
353
|
-
"32": 128,
|
|
354
|
-
"36": 144,
|
|
355
|
-
"40": 160,
|
|
356
|
-
"44": 176,
|
|
357
|
-
"48": 192,
|
|
358
|
-
"52": 208,
|
|
359
|
-
"56": 224,
|
|
360
|
-
"60": 240,
|
|
361
|
-
"64": 256,
|
|
362
|
-
"72": 288,
|
|
363
|
-
"80": 320,
|
|
364
|
-
"96": 384
|
|
365
|
-
},
|
|
366
|
-
screens: {
|
|
367
|
-
sm: 640,
|
|
368
|
-
md: 768,
|
|
369
|
-
lg: 1024,
|
|
370
|
-
xl: 1280,
|
|
371
|
-
"2xl": 1536
|
|
372
|
-
},
|
|
373
|
-
// Byte-for-byte the same three stacks
|
|
374
|
-
// packages/core-engine/src/resolvers/typography.rs's `font_family_value`
|
|
375
|
-
// falls back to. On native these three still effectively no-op (see
|
|
376
|
-
// `first_font_name`'s own doc comment for why a generic CSS keyword
|
|
377
|
-
// isn't a real loadable font) — only a caller-configured custom name
|
|
378
|
-
// changes native rendering; Expo Web uses the full stack as-is.
|
|
379
|
-
fontFamily: {
|
|
380
|
-
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
381
|
-
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
382
|
-
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
383
|
-
},
|
|
384
|
-
darkMode: "attribute",
|
|
385
|
-
// Empty by default, matching real Tailwind's own defaults.
|
|
386
|
-
container: {}
|
|
387
|
-
};
|
|
388
|
-
var activeTheme = defaultTheme;
|
|
389
|
-
var activeThemeJson = JSON.stringify(defaultTheme);
|
|
390
|
-
function setTheme(theme) {
|
|
391
|
-
activeTheme = theme;
|
|
392
|
-
activeThemeJson = JSON.stringify(theme);
|
|
393
|
-
}
|
|
394
|
-
function getTheme() {
|
|
395
|
-
return activeTheme;
|
|
396
|
-
}
|
|
397
|
-
function getThemeJson() {
|
|
398
|
-
return activeThemeJson;
|
|
399
|
-
}
|
|
63
|
+
var import_theme4 = require("./theme");
|
|
400
64
|
|
|
401
65
|
// src/nativeBridge.ts
|
|
402
|
-
var import_react_native2 = require("react-native");
|
|
403
|
-
|
|
404
|
-
// src/darkModeStore.ts
|
|
405
66
|
var import_react_native = require("react-native");
|
|
406
|
-
var
|
|
407
|
-
|
|
408
|
-
return import_react_native.Appearance.getColorScheme() === "dark";
|
|
409
|
-
}
|
|
410
|
-
function resolveIsDark(m) {
|
|
411
|
-
return m === "system" ? systemPrefersDark() : m === "dark";
|
|
412
|
-
}
|
|
413
|
-
var mode = "system";
|
|
414
|
-
var isDark = resolveIsDark(mode);
|
|
415
|
-
var hasExplicitChoice = false;
|
|
416
|
-
var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
|
|
417
|
-
if (mode !== "system") return;
|
|
418
|
-
isDark = colorScheme === "dark";
|
|
419
|
-
notify();
|
|
420
|
-
});
|
|
421
|
-
function notify() {
|
|
422
|
-
for (const listener of listeners) listener();
|
|
423
|
-
}
|
|
424
|
-
function getGlobalDarkMode() {
|
|
425
|
-
return isDark;
|
|
426
|
-
}
|
|
427
|
-
function getGlobalThemeMode() {
|
|
428
|
-
return mode;
|
|
429
|
-
}
|
|
430
|
-
function setGlobalThemeMode(nextMode) {
|
|
431
|
-
mode = nextMode;
|
|
432
|
-
isDark = resolveIsDark(nextMode);
|
|
433
|
-
hasExplicitChoice = true;
|
|
434
|
-
notify();
|
|
435
|
-
}
|
|
436
|
-
function toggleGlobalDarkMode() {
|
|
437
|
-
setGlobalThemeMode(isDark ? "light" : "dark");
|
|
438
|
-
}
|
|
439
|
-
function subscribeGlobalDarkMode(listener) {
|
|
440
|
-
listeners.add(listener);
|
|
441
|
-
return () => listeners.delete(listener);
|
|
442
|
-
}
|
|
443
|
-
function seedDefaultMode(fallback) {
|
|
444
|
-
if (hasExplicitChoice || mode === fallback) return;
|
|
445
|
-
mode = fallback;
|
|
446
|
-
isDark = resolveIsDark(fallback);
|
|
447
|
-
notify();
|
|
448
|
-
}
|
|
67
|
+
var import_theme = require("./theme");
|
|
68
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
449
69
|
|
|
450
70
|
// src/jsEngine/parser.ts
|
|
451
71
|
var VALUE_PREFIXES = [
|
|
@@ -533,12 +153,23 @@ var VALUE_PREFIXES = [
|
|
|
533
153
|
"leading-",
|
|
534
154
|
"tracking-",
|
|
535
155
|
"font-",
|
|
156
|
+
"align-",
|
|
536
157
|
"z-",
|
|
158
|
+
"inset-x-",
|
|
159
|
+
"inset-y-",
|
|
537
160
|
"inset-",
|
|
538
161
|
"top-",
|
|
539
162
|
"right-",
|
|
540
163
|
"bottom-",
|
|
541
164
|
"left-",
|
|
165
|
+
"start-",
|
|
166
|
+
"end-",
|
|
167
|
+
"overflow-x-",
|
|
168
|
+
"overflow-y-",
|
|
169
|
+
"overscroll-x-",
|
|
170
|
+
"overscroll-y-",
|
|
171
|
+
"overscroll-",
|
|
172
|
+
"aspect-",
|
|
542
173
|
"divide-color-",
|
|
543
174
|
"space-x-",
|
|
544
175
|
"space-y-",
|
|
@@ -566,12 +197,23 @@ var VALUE_PREFIXES = [
|
|
|
566
197
|
"justify-self-",
|
|
567
198
|
"scale-x-",
|
|
568
199
|
"scale-y-",
|
|
200
|
+
"scale-z-",
|
|
569
201
|
"scale-",
|
|
202
|
+
"rotate-x-",
|
|
203
|
+
"rotate-y-",
|
|
204
|
+
"rotate-z-",
|
|
570
205
|
"rotate-",
|
|
206
|
+
// Bare 'translate-'/'skew-' (both axes) after their per-axis forms, same
|
|
207
|
+
// longer-before-shorter rule as resolvers/parser.rs.
|
|
571
208
|
"translate-x-",
|
|
572
209
|
"translate-y-",
|
|
210
|
+
"translate-z-",
|
|
211
|
+
"translate-",
|
|
573
212
|
"skew-x-",
|
|
574
213
|
"skew-y-",
|
|
214
|
+
"skew-",
|
|
215
|
+
"perspective-origin-",
|
|
216
|
+
"perspective-",
|
|
575
217
|
"origin-",
|
|
576
218
|
"blur-",
|
|
577
219
|
"brightness-",
|
|
@@ -604,14 +246,200 @@ var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
|
604
246
|
function isSafeArbitraryValue(value) {
|
|
605
247
|
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
606
248
|
}
|
|
249
|
+
function normalizeMathWhitespace(raw) {
|
|
250
|
+
if (!(raw.startsWith("calc(") || raw.startsWith("min(") || raw.startsWith("max(") || raw.startsWith("clamp("))) {
|
|
251
|
+
return raw;
|
|
252
|
+
}
|
|
253
|
+
const chars = Array.from(raw);
|
|
254
|
+
let out = "";
|
|
255
|
+
let i = 0;
|
|
256
|
+
let prevEndsValue = false;
|
|
257
|
+
while (i < chars.length) {
|
|
258
|
+
const c = chars[i];
|
|
259
|
+
if (c === "v" && chars[i + 1] === "a" && chars[i + 2] === "r" && chars[i + 3] === "(") {
|
|
260
|
+
const start = i;
|
|
261
|
+
let depth = 0;
|
|
262
|
+
while (i < chars.length) {
|
|
263
|
+
if (chars[i] === "(") depth++;
|
|
264
|
+
else if (chars[i] === ")") {
|
|
265
|
+
depth--;
|
|
266
|
+
if (depth === 0) {
|
|
267
|
+
i++;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
i++;
|
|
272
|
+
}
|
|
273
|
+
out += chars.slice(start, i).join("");
|
|
274
|
+
prevEndsValue = true;
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (c === "+" || c === "-") {
|
|
278
|
+
if (prevEndsValue) {
|
|
279
|
+
out += ` ${c} `;
|
|
280
|
+
i++;
|
|
281
|
+
while (i < chars.length && /\s/.test(chars[i])) i++;
|
|
282
|
+
prevEndsValue = false;
|
|
283
|
+
continue;
|
|
284
|
+
}
|
|
285
|
+
out += c;
|
|
286
|
+
prevEndsValue = false;
|
|
287
|
+
} else if (c === "(" || c === ",") {
|
|
288
|
+
out += c;
|
|
289
|
+
if (c === ",") out += " ";
|
|
290
|
+
prevEndsValue = false;
|
|
291
|
+
} else if (c === ")") {
|
|
292
|
+
out += c;
|
|
293
|
+
prevEndsValue = true;
|
|
294
|
+
} else if (/\s/.test(c)) {
|
|
295
|
+
} else if (c === "*" || c === "/") {
|
|
296
|
+
out += c;
|
|
297
|
+
prevEndsValue = false;
|
|
298
|
+
} else {
|
|
299
|
+
out += c;
|
|
300
|
+
prevEndsValue = true;
|
|
301
|
+
}
|
|
302
|
+
i++;
|
|
303
|
+
}
|
|
304
|
+
return out;
|
|
305
|
+
}
|
|
306
|
+
var TYPE_HINTS = /* @__PURE__ */ new Set([
|
|
307
|
+
"color",
|
|
308
|
+
"length",
|
|
309
|
+
"size",
|
|
310
|
+
"line-width",
|
|
311
|
+
"percentage",
|
|
312
|
+
"number",
|
|
313
|
+
"integer",
|
|
314
|
+
"image",
|
|
315
|
+
"url",
|
|
316
|
+
"position",
|
|
317
|
+
"bg-size",
|
|
318
|
+
"family-name",
|
|
319
|
+
"generic-name",
|
|
320
|
+
"absolute-size",
|
|
321
|
+
"relative-size",
|
|
322
|
+
"angle",
|
|
323
|
+
"shadow",
|
|
324
|
+
"any"
|
|
325
|
+
]);
|
|
326
|
+
function arbitraryModifier(modifier) {
|
|
327
|
+
const bracketed = parenVarShorthand(modifier) ?? modifier;
|
|
328
|
+
if (!(bracketed.length > 2 && bracketed.startsWith("[") && bracketed.endsWith("]"))) return null;
|
|
329
|
+
const raw = bracketed.slice(1, -1);
|
|
330
|
+
if (!isSafeArbitraryValue(raw)) return null;
|
|
331
|
+
return normalizeMathWhitespace(raw.replace(/_/g, " "));
|
|
332
|
+
}
|
|
333
|
+
function splitTypeHint(raw) {
|
|
334
|
+
const i = raw.indexOf(":");
|
|
335
|
+
if (i > 0 && i < raw.length - 1 && TYPE_HINTS.has(raw.slice(0, i))) return [raw.slice(0, i), raw.slice(i + 1)];
|
|
336
|
+
return [null, raw];
|
|
337
|
+
}
|
|
338
|
+
function parenVarShorthand(value) {
|
|
339
|
+
const m = /^\((?:([a-z-]+):)?--([A-Za-z0-9_-]+)\)(\/.*)?$/.exec(value);
|
|
340
|
+
if (!m) return null;
|
|
341
|
+
const [, hint, name, tail = ""] = m;
|
|
342
|
+
if (hint !== void 0 && !TYPE_HINTS.has(hint)) return null;
|
|
343
|
+
return hint ? `[${hint}:var(--${name})]${tail}` : `[var(--${name})]${tail}`;
|
|
344
|
+
}
|
|
345
|
+
function splitBracketModifier(value) {
|
|
346
|
+
if (!value.startsWith("[")) return [value, null];
|
|
347
|
+
let depth = 0;
|
|
348
|
+
for (let i = 0; i < value.length; i++) {
|
|
349
|
+
const ch = value[i];
|
|
350
|
+
if (ch === "[") depth += 1;
|
|
351
|
+
else if (ch === "]") {
|
|
352
|
+
depth -= 1;
|
|
353
|
+
if (depth === 0) {
|
|
354
|
+
const after = value.slice(i + 1);
|
|
355
|
+
return after.startsWith("/") && after.length > 1 ? [value.slice(0, i + 1), after.slice(1)] : [value, null];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return [value, null];
|
|
360
|
+
}
|
|
361
|
+
function trimNumber(n) {
|
|
362
|
+
return `${Math.round(n * 1e6) / 1e6}`;
|
|
363
|
+
}
|
|
364
|
+
function parseAlpha(modifier) {
|
|
365
|
+
const raw = arbitraryModifier(modifier);
|
|
366
|
+
if (raw !== null) {
|
|
367
|
+
if (raw.endsWith("%")) {
|
|
368
|
+
const n3 = strictNumber(raw.slice(0, -1));
|
|
369
|
+
return n3 !== null && n3 >= 0 && n3 <= 100 ? { fraction: n3 / 100 } : null;
|
|
370
|
+
}
|
|
371
|
+
const n2 = strictNumber(raw);
|
|
372
|
+
if (n2 !== null) return n2 >= 0 && n2 <= 1 ? { fraction: n2 } : null;
|
|
373
|
+
return raw.startsWith("var(") || raw.startsWith("calc(") ? { raw } : null;
|
|
374
|
+
}
|
|
375
|
+
if (!/^(?:\d+\.?\d*|\.\d+)$/.test(modifier)) return null;
|
|
376
|
+
const n = Number(modifier);
|
|
377
|
+
return n <= 100 ? { fraction: n / 100 } : null;
|
|
378
|
+
}
|
|
379
|
+
function strictNumber(text) {
|
|
380
|
+
return /^[+-]?(?:\d+\.?\d*|\.\d+)$/.test(text) ? Number(text) : null;
|
|
381
|
+
}
|
|
382
|
+
function expandThemeFunctions(raw) {
|
|
383
|
+
if (!raw.includes("--spacing(") && !raw.includes("--alpha(")) return raw;
|
|
384
|
+
let out = "";
|
|
385
|
+
let rest = raw;
|
|
386
|
+
for (; ; ) {
|
|
387
|
+
const found = ["--spacing(", "--alpha("].map((name) => ({ name, at: rest.indexOf(name) })).filter((f) => f.at !== -1).sort((a, b) => a.at - b.at)[0];
|
|
388
|
+
if (found === void 0) break;
|
|
389
|
+
const argsFrom = found.at + found.name.length;
|
|
390
|
+
let depth = 1;
|
|
391
|
+
let close = -1;
|
|
392
|
+
for (let i = argsFrom; i < rest.length; i++) {
|
|
393
|
+
if (rest[i] === "(") depth += 1;
|
|
394
|
+
else if (rest[i] === ")") {
|
|
395
|
+
depth -= 1;
|
|
396
|
+
if (depth === 0) {
|
|
397
|
+
close = i;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
if (close === -1) break;
|
|
403
|
+
const arg = expandThemeFunctions(rest.slice(argsFrom, close).trim());
|
|
404
|
+
out += rest.slice(0, found.at);
|
|
405
|
+
if (found.name === "--spacing(") {
|
|
406
|
+
const n = strictNumber(arg);
|
|
407
|
+
out += n !== null ? `${trimNumber(n * 4)}px` : `calc(4px * ${arg})`;
|
|
408
|
+
} else {
|
|
409
|
+
const slash = arg.lastIndexOf("/");
|
|
410
|
+
if (slash === -1) {
|
|
411
|
+
out += arg;
|
|
412
|
+
} else {
|
|
413
|
+
const alpha = arg.slice(slash + 1).trim();
|
|
414
|
+
const n = strictNumber(alpha);
|
|
415
|
+
out += `color-mix(in srgb, ${arg.slice(0, slash).trim()} ${n !== null ? `${trimNumber(n * 100)}%` : alpha}, transparent)`;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
rest = rest.slice(close + 1);
|
|
419
|
+
}
|
|
420
|
+
return out + rest;
|
|
421
|
+
}
|
|
422
|
+
var COLOR_FUNCTIONS = ["rgb(", "rgba(", "hsl(", "hsla(", "hwb(", "lab(", "lch(", "oklab(", "oklch(", "color(", "color-mix(", "var("];
|
|
423
|
+
function looksLikeColor(value) {
|
|
424
|
+
return value.startsWith("#") || COLOR_FUNCTIONS.some((f) => value.startsWith(f)) || /^[A-Za-z]+$/.test(value);
|
|
425
|
+
}
|
|
426
|
+
function colorWithOpacity(color, alpha) {
|
|
427
|
+
const m = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.exec(color);
|
|
428
|
+
if (m && "fraction" in alpha) {
|
|
429
|
+
const h = m[1].length === 3 ? m[1].split("").map((c) => c + c).join("") : m[1];
|
|
430
|
+
const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));
|
|
431
|
+
return `rgba(${r},${g},${b},${trimNumber(alpha.fraction)})`;
|
|
432
|
+
}
|
|
433
|
+
return `color-mix(in srgb, ${color} ${"fraction" in alpha ? `${trimNumber(alpha.fraction * 100)}%` : alpha.raw}, transparent)`;
|
|
434
|
+
}
|
|
607
435
|
function splitRespectingBrackets(token) {
|
|
608
436
|
const parts = [];
|
|
609
437
|
let depth = 0;
|
|
610
438
|
let start = 0;
|
|
611
439
|
for (let i = 0; i < token.length; i++) {
|
|
612
440
|
const ch = token[i];
|
|
613
|
-
if (ch === "[") depth += 1;
|
|
614
|
-
else if (ch === "]") depth -= 1;
|
|
441
|
+
if (ch === "[" || ch === "(") depth += 1;
|
|
442
|
+
else if (ch === "]" || ch === ")") depth -= 1;
|
|
615
443
|
else if (ch === ":" && depth <= 0) {
|
|
616
444
|
parts.push(token.slice(start, i));
|
|
617
445
|
start = i + 1;
|
|
@@ -624,9 +452,11 @@ function parseClass(token) {
|
|
|
624
452
|
const parts = splitRespectingBrackets(token);
|
|
625
453
|
let base = parts.pop() ?? token;
|
|
626
454
|
const modifiers = parts;
|
|
627
|
-
const important = base.startsWith("!");
|
|
628
|
-
if (
|
|
455
|
+
const important = base.startsWith("!") || base.length > 1 && base.endsWith("!");
|
|
456
|
+
if (base.startsWith("!")) {
|
|
629
457
|
base = base.slice(1);
|
|
458
|
+
} else if (important) {
|
|
459
|
+
base = base.slice(0, -1);
|
|
630
460
|
}
|
|
631
461
|
const negative = base.startsWith("-");
|
|
632
462
|
if (negative) {
|
|
@@ -639,7 +469,7 @@ function parseClass(token) {
|
|
|
639
469
|
const property = raw.slice(0, colonIdx);
|
|
640
470
|
const rawValue = raw.slice(colonIdx + 1);
|
|
641
471
|
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
642
|
-
const value = rawValue.replace(/_/g, " ");
|
|
472
|
+
const value = normalizeMathWhitespace(expandThemeFunctions(rawValue.replace(/_/g, " ")));
|
|
643
473
|
return {
|
|
644
474
|
modifiers,
|
|
645
475
|
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
@@ -654,28 +484,46 @@ function parseClass(token) {
|
|
|
654
484
|
}
|
|
655
485
|
for (const prefix of VALUE_PREFIXES) {
|
|
656
486
|
if (!base.startsWith(prefix)) continue;
|
|
657
|
-
const
|
|
658
|
-
if (
|
|
487
|
+
const written = base.slice(prefix.length);
|
|
488
|
+
if (written === "") continue;
|
|
489
|
+
const [value, tail] = splitBracketModifier(parenVarShorthand(written) ?? written);
|
|
659
490
|
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
660
491
|
const raw = value.slice(1, -1);
|
|
661
492
|
if (!isSafeArbitraryValue(raw)) {
|
|
662
493
|
continue;
|
|
663
494
|
}
|
|
664
|
-
const spaced = raw.replace(/_/g, " ");
|
|
495
|
+
const spaced = normalizeMathWhitespace(expandThemeFunctions(raw.replace(/_/g, " ")));
|
|
496
|
+
let [typeHint, hinted] = splitTypeHint(spaced);
|
|
497
|
+
let modifier = null;
|
|
498
|
+
if (tail !== null) {
|
|
499
|
+
const isColor = typeHint === "color" || typeHint === null && looksLikeColor(hinted);
|
|
500
|
+
const alpha = isColor ? parseAlpha(tail) : null;
|
|
501
|
+
if (alpha !== null) {
|
|
502
|
+
hinted = colorWithOpacity(hinted, alpha);
|
|
503
|
+
typeHint = "color";
|
|
504
|
+
} else if (prefix === "text-") {
|
|
505
|
+
modifier = tail;
|
|
506
|
+
} else {
|
|
507
|
+
continue;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
665
510
|
return {
|
|
666
511
|
modifiers,
|
|
667
512
|
utility: prefix.slice(0, -1),
|
|
668
|
-
value:
|
|
513
|
+
value: hinted,
|
|
514
|
+
typeHint,
|
|
669
515
|
isArbitrary: true,
|
|
670
516
|
important,
|
|
671
517
|
negative,
|
|
672
|
-
original: token
|
|
518
|
+
original: token,
|
|
519
|
+
modifier
|
|
673
520
|
};
|
|
674
521
|
}
|
|
675
522
|
return {
|
|
676
523
|
modifiers,
|
|
677
524
|
utility: prefix.slice(0, -1),
|
|
678
|
-
value
|
|
525
|
+
// a named value keeps its own /opacity (`bg-blue-6/50`)
|
|
526
|
+
value: tail === null ? value : `${value}/${tail}`,
|
|
679
527
|
isArbitrary: false,
|
|
680
528
|
important,
|
|
681
529
|
negative,
|
|
@@ -693,6 +541,73 @@ function parseClass(token) {
|
|
|
693
541
|
};
|
|
694
542
|
}
|
|
695
543
|
|
|
544
|
+
// src/jsEngine/groups.ts
|
|
545
|
+
function expandVariantGroups(input) {
|
|
546
|
+
if (!input.includes(":(")) return input;
|
|
547
|
+
const out = [];
|
|
548
|
+
for (const token of splitTopLevel(input)) expandToken(token, "", false, out);
|
|
549
|
+
return out.join(" ");
|
|
550
|
+
}
|
|
551
|
+
function splitTopLevel(s) {
|
|
552
|
+
const parts = [];
|
|
553
|
+
let depth = 0;
|
|
554
|
+
let start = -1;
|
|
555
|
+
for (let i = 0; i < s.length; i++) {
|
|
556
|
+
const ch = s[i];
|
|
557
|
+
if (ch === "(" || ch === "[") depth++;
|
|
558
|
+
else if (ch === ")" || ch === "]") depth--;
|
|
559
|
+
const space = /\s/.test(ch);
|
|
560
|
+
if (space && depth <= 0) {
|
|
561
|
+
if (start >= 0) {
|
|
562
|
+
parts.push(s.slice(start, i));
|
|
563
|
+
start = -1;
|
|
564
|
+
}
|
|
565
|
+
depth = Math.max(depth, 0);
|
|
566
|
+
} else if (start < 0 && !space) {
|
|
567
|
+
start = i;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
if (start >= 0) parts.push(s.slice(start));
|
|
571
|
+
return parts;
|
|
572
|
+
}
|
|
573
|
+
function groupOpen(token) {
|
|
574
|
+
let brackets = 0;
|
|
575
|
+
for (let i = 0; i < token.length; i++) {
|
|
576
|
+
const ch = token[i];
|
|
577
|
+
if (ch === "[") brackets++;
|
|
578
|
+
else if (ch === "]") brackets--;
|
|
579
|
+
else if (ch === "(" && brackets === 0 && i > 1 && token[i - 1] === ":") return i;
|
|
580
|
+
}
|
|
581
|
+
return -1;
|
|
582
|
+
}
|
|
583
|
+
function groupClose(token, open) {
|
|
584
|
+
let depth = 0;
|
|
585
|
+
for (let i = open; i < token.length; i++) {
|
|
586
|
+
const ch = token[i];
|
|
587
|
+
if (ch === "(" || ch === "[") depth++;
|
|
588
|
+
else if (ch === ")" || ch === "]") {
|
|
589
|
+
depth--;
|
|
590
|
+
if (depth === 0) return ch === ")" ? i : -1;
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return -1;
|
|
594
|
+
}
|
|
595
|
+
function pushClass(prefix, cls, important, out) {
|
|
596
|
+
if (!cls) return;
|
|
597
|
+
const bare = cls.split(":").pop() ?? cls;
|
|
598
|
+
out.push(prefix + cls + (important && !cls.endsWith("!") && !bare.startsWith("!") ? "!" : ""));
|
|
599
|
+
}
|
|
600
|
+
function expandToken(token, prefix, important, out) {
|
|
601
|
+
const open = groupOpen(token);
|
|
602
|
+
if (open < 0) return pushClass(prefix, token, important, out);
|
|
603
|
+
const close = groupClose(token, open);
|
|
604
|
+
if (close < 0) return pushClass(prefix, token, important, out);
|
|
605
|
+
const rest = token.slice(close + 1);
|
|
606
|
+
if (rest !== "" && rest !== "!") return pushClass(prefix, token, important, out);
|
|
607
|
+
const innerPrefix = prefix + token.slice(0, open);
|
|
608
|
+
for (const part of splitTopLevel(token.slice(open + 1, close))) expandToken(part, innerPrefix, rest === "!" || important, out);
|
|
609
|
+
}
|
|
610
|
+
|
|
696
611
|
// src/jsEngine/shared.ts
|
|
697
612
|
function decl(property, value) {
|
|
698
613
|
return { property, value };
|
|
@@ -700,6 +615,7 @@ function decl(property, value) {
|
|
|
700
615
|
function spacingPx(theme, value) {
|
|
701
616
|
const fromTable = theme.spacing[value];
|
|
702
617
|
if (fromTable !== void 0) return fromTable;
|
|
618
|
+
if (value === "px") return 1;
|
|
703
619
|
const n = Number(value);
|
|
704
620
|
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
705
621
|
}
|
|
@@ -715,7 +631,10 @@ function resolveLength(theme, parsed) {
|
|
|
715
631
|
}
|
|
716
632
|
function resolveNegatableLength(theme, parsed) {
|
|
717
633
|
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
718
|
-
if (parsed.isArbitrary)
|
|
634
|
+
if (parsed.isArbitrary) {
|
|
635
|
+
const value2 = parsed.value;
|
|
636
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
637
|
+
}
|
|
719
638
|
const value = parsed.value;
|
|
720
639
|
if (value === null) return null;
|
|
721
640
|
const px = spacingPx(theme, value);
|
|
@@ -723,11 +642,71 @@ function resolveNegatableLength(theme, parsed) {
|
|
|
723
642
|
if (px === 0) return "0px";
|
|
724
643
|
return `-${px}px`;
|
|
725
644
|
}
|
|
645
|
+
function fractionPercent(value) {
|
|
646
|
+
const slashIdx = value.indexOf("/");
|
|
647
|
+
if (slashIdx === -1) return null;
|
|
648
|
+
const numStr = value.slice(0, slashIdx);
|
|
649
|
+
const denStr = value.slice(slashIdx + 1);
|
|
650
|
+
const num = Number(numStr);
|
|
651
|
+
const den = Number(denStr);
|
|
652
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
653
|
+
if (den === 0) return null;
|
|
654
|
+
const pct = num / den * 100;
|
|
655
|
+
const formatted = pct.toFixed(6);
|
|
656
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
657
|
+
return `${trimmed}%`;
|
|
658
|
+
}
|
|
659
|
+
function resolveNegatableSize(theme, parsed) {
|
|
660
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
661
|
+
if (parsed.negative && parsed.value === "full") return "-100%";
|
|
662
|
+
const pct = fractionPercent(parsed.value);
|
|
663
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
664
|
+
}
|
|
665
|
+
return resolveNegatableLength(theme, parsed);
|
|
666
|
+
}
|
|
667
|
+
function negate(value) {
|
|
668
|
+
const numeric = (v) => /^[\d.]/.test(v);
|
|
669
|
+
if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
|
|
670
|
+
return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
|
|
671
|
+
}
|
|
672
|
+
function resolvePercent(parsed) {
|
|
673
|
+
if (parsed.negative) return null;
|
|
674
|
+
const value = parsed.value;
|
|
675
|
+
if (value === null) return null;
|
|
676
|
+
if (parsed.isArbitrary) return value;
|
|
677
|
+
const pct = Number(value);
|
|
678
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
679
|
+
return String(pct / 100);
|
|
680
|
+
}
|
|
726
681
|
|
|
727
682
|
// src/jsEngine/resolvers/layout.ts
|
|
728
683
|
function negateRaw(value, negative) {
|
|
729
684
|
return negative ? `-${value}` : value;
|
|
730
685
|
}
|
|
686
|
+
var WHOLE = /^\d+$/;
|
|
687
|
+
var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
688
|
+
function overflowAxisValue(property, value) {
|
|
689
|
+
switch (value) {
|
|
690
|
+
case "auto":
|
|
691
|
+
case "hidden":
|
|
692
|
+
case "clip":
|
|
693
|
+
case "visible":
|
|
694
|
+
case "scroll":
|
|
695
|
+
return [decl(property, value)];
|
|
696
|
+
default:
|
|
697
|
+
return null;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
function overscrollValue(property, value) {
|
|
701
|
+
switch (value) {
|
|
702
|
+
case "auto":
|
|
703
|
+
case "contain":
|
|
704
|
+
case "none":
|
|
705
|
+
return [decl(property, value)];
|
|
706
|
+
default:
|
|
707
|
+
return null;
|
|
708
|
+
}
|
|
709
|
+
}
|
|
731
710
|
function resolve(parsed, theme) {
|
|
732
711
|
switch (parsed.utility) {
|
|
733
712
|
case "flex":
|
|
@@ -774,6 +753,12 @@ function resolve(parsed, theme) {
|
|
|
774
753
|
return [decl("justify-content", "space-around")];
|
|
775
754
|
case "justify-evenly":
|
|
776
755
|
return [decl("justify-content", "space-evenly")];
|
|
756
|
+
case "justify-normal":
|
|
757
|
+
return [decl("justify-content", "normal")];
|
|
758
|
+
case "justify-stretch":
|
|
759
|
+
return [decl("justify-content", "stretch")];
|
|
760
|
+
case "content-normal":
|
|
761
|
+
return [decl("align-content", "normal")];
|
|
777
762
|
case "content-start":
|
|
778
763
|
return [decl("align-content", "flex-start")];
|
|
779
764
|
case "content-end":
|
|
@@ -808,6 +793,18 @@ function resolve(parsed, theme) {
|
|
|
808
793
|
return [decl("overflow", "scroll")];
|
|
809
794
|
case "overflow-visible":
|
|
810
795
|
return [decl("overflow", "visible")];
|
|
796
|
+
case "overflow-clip":
|
|
797
|
+
return [decl("overflow", "clip")];
|
|
798
|
+
case "overflow-x":
|
|
799
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
800
|
+
case "overflow-y":
|
|
801
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
802
|
+
case "overscroll":
|
|
803
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
804
|
+
case "overscroll-x":
|
|
805
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
806
|
+
case "overscroll-y":
|
|
807
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
811
808
|
case "static":
|
|
812
809
|
return [decl("position", "static")];
|
|
813
810
|
case "relative":
|
|
@@ -818,40 +815,91 @@ function resolve(parsed, theme) {
|
|
|
818
815
|
return [decl("position", "fixed")];
|
|
819
816
|
case "sticky":
|
|
820
817
|
return [decl("position", "sticky")];
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
818
|
+
// Only real values, mirroring layout.rs: a whole number, z-auto, the
|
|
819
|
+
// order-first/-last/-none keywords, or an arbitrary [...]. Anything
|
|
820
|
+
// else used to pass straight through (z-banana -> z-index: banana).
|
|
821
|
+
case "z": {
|
|
822
|
+
const v = parsed.value;
|
|
823
|
+
if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
|
|
824
|
+
return [decl("z-index", negateRaw(v, parsed.negative))];
|
|
825
|
+
}
|
|
826
|
+
case "order": {
|
|
827
|
+
const v = parsed.value;
|
|
828
|
+
if (v === null) return null;
|
|
829
|
+
if (v === "first") return [decl("order", "-9999")];
|
|
830
|
+
if (v === "last") return [decl("order", "9999")];
|
|
831
|
+
if (v === "none") return [decl("order", "0")];
|
|
832
|
+
if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
|
|
833
|
+
return [decl("order", negateRaw(v, parsed.negative))];
|
|
834
|
+
}
|
|
825
835
|
case "grow":
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
836
|
+
case "shrink": {
|
|
837
|
+
const v = parsed.value ?? "1";
|
|
838
|
+
if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
|
|
839
|
+
return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
|
|
840
|
+
}
|
|
829
841
|
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
830
|
-
// convention ("-top-4")
|
|
842
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
843
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
831
844
|
case "top": {
|
|
832
|
-
const v =
|
|
845
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
833
846
|
return v === null ? null : [decl("top", v)];
|
|
834
847
|
}
|
|
835
848
|
case "right": {
|
|
836
|
-
const v =
|
|
849
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
837
850
|
return v === null ? null : [decl("right", v)];
|
|
838
851
|
}
|
|
839
852
|
case "bottom": {
|
|
840
|
-
const v =
|
|
853
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
841
854
|
return v === null ? null : [decl("bottom", v)];
|
|
842
855
|
}
|
|
843
856
|
case "left": {
|
|
844
|
-
const v =
|
|
857
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
845
858
|
return v === null ? null : [decl("left", v)];
|
|
846
859
|
}
|
|
847
860
|
case "inset": {
|
|
848
|
-
const v =
|
|
861
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
849
862
|
return v === null ? null : [decl("inset", v)];
|
|
850
863
|
}
|
|
851
|
-
case "
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
864
|
+
case "inset-x": {
|
|
865
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
866
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
867
|
+
}
|
|
868
|
+
case "inset-y": {
|
|
869
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
870
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
871
|
+
}
|
|
872
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
873
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
874
|
+
case "start": {
|
|
875
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
876
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
877
|
+
}
|
|
878
|
+
case "end": {
|
|
879
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
880
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
881
|
+
}
|
|
882
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
883
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
884
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
885
|
+
// "aspect" arm.
|
|
886
|
+
case "aspect": {
|
|
887
|
+
const value = parsed.value;
|
|
888
|
+
if (value === null) return null;
|
|
889
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
890
|
+
switch (value) {
|
|
891
|
+
case "square":
|
|
892
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
893
|
+
case "video":
|
|
894
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
895
|
+
case "auto":
|
|
896
|
+
return [decl("aspect-ratio", "auto")];
|
|
897
|
+
default: {
|
|
898
|
+
const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
|
|
899
|
+
return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
}
|
|
855
903
|
default:
|
|
856
904
|
return null;
|
|
857
905
|
}
|
|
@@ -893,7 +941,7 @@ function resolveFlex(parsed, web) {
|
|
|
893
941
|
case "shrink-0":
|
|
894
942
|
return [decl("flex-shrink", "0")];
|
|
895
943
|
default:
|
|
896
|
-
return null;
|
|
944
|
+
return /^\d+$/.test(value) ? [decl("flex", value)] : null;
|
|
897
945
|
}
|
|
898
946
|
}
|
|
899
947
|
|
|
@@ -928,20 +976,6 @@ function namedSize(key) {
|
|
|
928
976
|
return null;
|
|
929
977
|
}
|
|
930
978
|
}
|
|
931
|
-
function fractionPercent(value) {
|
|
932
|
-
const slashIdx = value.indexOf("/");
|
|
933
|
-
if (slashIdx === -1) return null;
|
|
934
|
-
const numStr = value.slice(0, slashIdx);
|
|
935
|
-
const denStr = value.slice(slashIdx + 1);
|
|
936
|
-
const num = Number(numStr);
|
|
937
|
-
const den = Number(denStr);
|
|
938
|
-
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
939
|
-
if (den === 0) return null;
|
|
940
|
-
const pct = num / den * 100;
|
|
941
|
-
const formatted = pct.toFixed(6);
|
|
942
|
-
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
943
|
-
return `${trimmed}%`;
|
|
944
|
-
}
|
|
945
979
|
function cssSizeKeyword(key) {
|
|
946
980
|
switch (key) {
|
|
947
981
|
case "min":
|
|
@@ -1080,14 +1114,94 @@ function lookupHex(theme, key) {
|
|
|
1080
1114
|
const entry = theme.colors[key];
|
|
1081
1115
|
return typeof entry === "string" ? entry : null;
|
|
1082
1116
|
}
|
|
1117
|
+
var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
|
|
1118
|
+
function findModeAwareColor(base, theme) {
|
|
1119
|
+
const important = base.startsWith("!") ? "!" : "";
|
|
1120
|
+
const rest = important ? base.slice(1) : base;
|
|
1121
|
+
for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
|
|
1122
|
+
if (!rest.startsWith(prefix)) continue;
|
|
1123
|
+
const [name, opacity] = splitOpacity(rest.slice(prefix.length));
|
|
1124
|
+
const entry = theme.colors[name];
|
|
1125
|
+
if (typeof entry === "object" && entry !== null) {
|
|
1126
|
+
return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
return null;
|
|
1130
|
+
}
|
|
1131
|
+
function applyOpacityToHex(hex, opacity) {
|
|
1132
|
+
if (opacity === null) return hex;
|
|
1133
|
+
if (hexToRgb(hex) === null) return hex;
|
|
1134
|
+
return colorWithOpacity(hex.trim(), opacity).replace(/ /g, "_");
|
|
1135
|
+
}
|
|
1136
|
+
function substituteModeAwareColorToken(token, theme, colorScheme) {
|
|
1137
|
+
const segments = token.split(":");
|
|
1138
|
+
const base = segments.pop() ?? token;
|
|
1139
|
+
const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
|
|
1140
|
+
const found = findModeAwareColor(base, theme);
|
|
1141
|
+
if (found === null) return token;
|
|
1142
|
+
const hex = colorScheme === "dark" ? found.dark : found.light;
|
|
1143
|
+
return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
|
|
1144
|
+
}
|
|
1145
|
+
function hexToRgb(hex) {
|
|
1146
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1147
|
+
if (!m) return null;
|
|
1148
|
+
let h = m[1];
|
|
1149
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1150
|
+
const n = parseInt(h, 16);
|
|
1151
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1152
|
+
}
|
|
1153
|
+
function splitOpacity(value) {
|
|
1154
|
+
const slash = value.indexOf("/");
|
|
1155
|
+
if (slash === -1) return [value, null];
|
|
1156
|
+
const alpha = parseAlpha(value.slice(slash + 1));
|
|
1157
|
+
return alpha === null ? [value, null] : [value.slice(0, slash), alpha];
|
|
1158
|
+
}
|
|
1159
|
+
function colorValue(theme, parsed) {
|
|
1160
|
+
const value = parsed.value;
|
|
1161
|
+
if (value === null) return null;
|
|
1162
|
+
if (parsed.isArbitrary) return value;
|
|
1163
|
+
const [name, opacity] = splitOpacity(value);
|
|
1164
|
+
const hex = lookupHex(theme, name);
|
|
1165
|
+
if (hex === null) return null;
|
|
1166
|
+
return opacity === null ? hex : colorWithOpacity(hex, opacity);
|
|
1167
|
+
}
|
|
1168
|
+
var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
|
|
1169
|
+
function looksLikeLength(value) {
|
|
1170
|
+
const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
|
|
1171
|
+
const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
|
|
1172
|
+
if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
|
|
1173
|
+
if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
|
|
1174
|
+
return MATH_LENGTH_UNIT.test(value);
|
|
1175
|
+
}
|
|
1176
|
+
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])/;
|
|
1177
|
+
function isLength(parsed, value) {
|
|
1178
|
+
switch (parsed.typeHint ?? null) {
|
|
1179
|
+
case null:
|
|
1180
|
+
return looksLikeLength(value);
|
|
1181
|
+
case "length":
|
|
1182
|
+
case "size":
|
|
1183
|
+
case "line-width":
|
|
1184
|
+
case "percentage":
|
|
1185
|
+
case "number":
|
|
1186
|
+
case "integer":
|
|
1187
|
+
case "absolute-size":
|
|
1188
|
+
case "relative-size":
|
|
1189
|
+
return true;
|
|
1190
|
+
default:
|
|
1191
|
+
return false;
|
|
1192
|
+
}
|
|
1193
|
+
}
|
|
1083
1194
|
|
|
1084
1195
|
// src/jsEngine/resolvers/border.ts
|
|
1085
1196
|
function radiusSize(key) {
|
|
1086
1197
|
switch (key) {
|
|
1087
1198
|
case "none":
|
|
1088
1199
|
return "0px";
|
|
1089
|
-
|
|
1200
|
+
// Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
|
|
1201
|
+
case "xs":
|
|
1090
1202
|
return "0.125rem";
|
|
1203
|
+
case "sm":
|
|
1204
|
+
return "0.25rem";
|
|
1091
1205
|
case "md":
|
|
1092
1206
|
return "0.375rem";
|
|
1093
1207
|
case "lg":
|
|
@@ -1098,12 +1212,19 @@ function radiusSize(key) {
|
|
|
1098
1212
|
return "1rem";
|
|
1099
1213
|
case "3xl":
|
|
1100
1214
|
return "1.5rem";
|
|
1215
|
+
case "4xl":
|
|
1216
|
+
return "2rem";
|
|
1101
1217
|
case "full":
|
|
1102
1218
|
return "9999px";
|
|
1103
1219
|
default:
|
|
1104
1220
|
return null;
|
|
1105
1221
|
}
|
|
1106
1222
|
}
|
|
1223
|
+
function borderWidthPx(parsed) {
|
|
1224
|
+
if (parsed.negative || parsed.isArbitrary || parsed.value === null) return null;
|
|
1225
|
+
const n = Number(parsed.value);
|
|
1226
|
+
return Number.isFinite(n) && n >= 0 && parsed.value.trim() !== "" ? `${n}px` : null;
|
|
1227
|
+
}
|
|
1107
1228
|
function borderSideProperty(side) {
|
|
1108
1229
|
switch (side) {
|
|
1109
1230
|
case "t":
|
|
@@ -1126,49 +1247,68 @@ function borderValue(theme, parsed) {
|
|
|
1126
1247
|
if (side !== null) {
|
|
1127
1248
|
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1128
1249
|
}
|
|
1250
|
+
const pair = value === "x" ? ["border-left", "border-right"] : value === "y" ? ["border-top", "border-bottom"] : null;
|
|
1251
|
+
if (pair !== null) {
|
|
1252
|
+
return [
|
|
1253
|
+
decl(`${pair[0]}-width`, "1px"),
|
|
1254
|
+
decl(`${pair[1]}-width`, "1px"),
|
|
1255
|
+
decl(`${pair[0]}-style`, "solid"),
|
|
1256
|
+
decl(`${pair[1]}-style`, "solid")
|
|
1257
|
+
];
|
|
1258
|
+
}
|
|
1129
1259
|
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1130
1260
|
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1131
1261
|
}
|
|
1132
1262
|
if (parsed.isArbitrary) {
|
|
1133
|
-
return [decl("border-width", value)];
|
|
1263
|
+
if (isLength(parsed, value)) return [decl("border-width", value)];
|
|
1264
|
+
const color2 = colorValue(theme, parsed);
|
|
1265
|
+
return color2 === null ? null : [decl("border-color", color2)];
|
|
1134
1266
|
}
|
|
1135
1267
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1136
|
-
const v =
|
|
1268
|
+
const v = borderWidthPx(parsed);
|
|
1137
1269
|
return v === null ? null : [decl("border-width", v)];
|
|
1138
1270
|
}
|
|
1139
1271
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1140
1272
|
return [decl("border-style", value)];
|
|
1141
1273
|
}
|
|
1142
|
-
const
|
|
1143
|
-
return
|
|
1274
|
+
const color = colorValue(theme, parsed);
|
|
1275
|
+
return color === null ? null : [decl("border-color", color)];
|
|
1144
1276
|
}
|
|
1145
1277
|
function borderSideValue(theme, parsed, sideProperty) {
|
|
1146
1278
|
const value = parsed.value;
|
|
1147
1279
|
if (value === null) return null;
|
|
1148
|
-
if (parsed.isArbitrary)
|
|
1280
|
+
if (parsed.isArbitrary) {
|
|
1281
|
+
if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
|
|
1282
|
+
const color2 = colorValue(theme, parsed);
|
|
1283
|
+
return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
|
|
1284
|
+
}
|
|
1149
1285
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1150
|
-
const v =
|
|
1286
|
+
const v = borderWidthPx(parsed);
|
|
1151
1287
|
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1152
1288
|
}
|
|
1153
1289
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1154
1290
|
return [decl(`${sideProperty}-style`, value)];
|
|
1155
1291
|
}
|
|
1156
|
-
const
|
|
1157
|
-
return
|
|
1292
|
+
const color = colorValue(theme, parsed);
|
|
1293
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
1158
1294
|
}
|
|
1159
1295
|
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1160
1296
|
const value = parsed.value;
|
|
1161
1297
|
if (value === null) return null;
|
|
1162
|
-
if (parsed.isArbitrary)
|
|
1298
|
+
if (parsed.isArbitrary) {
|
|
1299
|
+
if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1300
|
+
const color2 = colorValue(theme, parsed);
|
|
1301
|
+
return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
|
|
1302
|
+
}
|
|
1163
1303
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1164
|
-
const v =
|
|
1304
|
+
const v = borderWidthPx(parsed);
|
|
1165
1305
|
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1166
1306
|
}
|
|
1167
1307
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1168
1308
|
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1169
1309
|
}
|
|
1170
|
-
const
|
|
1171
|
-
return
|
|
1310
|
+
const color = colorValue(theme, parsed);
|
|
1311
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1172
1312
|
}
|
|
1173
1313
|
function radiusProperties(side) {
|
|
1174
1314
|
switch (side) {
|
|
@@ -1208,79 +1348,28 @@ function resolveRadiusSide(theme, parsed, side) {
|
|
|
1208
1348
|
}
|
|
1209
1349
|
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1210
1350
|
function outlineWidthValue(key) {
|
|
1211
|
-
|
|
1212
|
-
case "0":
|
|
1213
|
-
return "0px";
|
|
1214
|
-
case "1":
|
|
1215
|
-
return "1px";
|
|
1216
|
-
case "2":
|
|
1217
|
-
return "2px";
|
|
1218
|
-
case "4":
|
|
1219
|
-
return "4px";
|
|
1220
|
-
case "8":
|
|
1221
|
-
return "8px";
|
|
1222
|
-
default:
|
|
1223
|
-
return null;
|
|
1224
|
-
}
|
|
1351
|
+
return /^\d+$/.test(key) ? `${Number(key)}px` : null;
|
|
1225
1352
|
}
|
|
1226
1353
|
function outlineValue(theme, parsed) {
|
|
1227
1354
|
const value = parsed.value;
|
|
1228
1355
|
if (value === null) return null;
|
|
1229
|
-
if (parsed.isArbitrary)
|
|
1356
|
+
if (parsed.isArbitrary) {
|
|
1357
|
+
if (isLength(parsed, value)) return [decl("outline-width", value)];
|
|
1358
|
+
const color2 = colorValue(theme, parsed);
|
|
1359
|
+
return color2 === null ? null : [decl("outline-color", color2)];
|
|
1360
|
+
}
|
|
1230
1361
|
const w = outlineWidthValue(value);
|
|
1231
1362
|
if (w !== null) return [decl("outline-width", w)];
|
|
1232
1363
|
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1233
|
-
const
|
|
1234
|
-
return
|
|
1364
|
+
const color = colorValue(theme, parsed);
|
|
1365
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1235
1366
|
}
|
|
1236
1367
|
function outlineOffsetValue(parsed) {
|
|
1237
1368
|
const value = parsed.value;
|
|
1238
1369
|
if (value === null) return null;
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
return
|
|
1242
|
-
}
|
|
1243
|
-
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))";
|
|
1244
|
-
function ringWidth(key) {
|
|
1245
|
-
switch (key) {
|
|
1246
|
-
case "0":
|
|
1247
|
-
return "0px";
|
|
1248
|
-
case "1":
|
|
1249
|
-
return "1px";
|
|
1250
|
-
case "2":
|
|
1251
|
-
return "2px";
|
|
1252
|
-
case "4":
|
|
1253
|
-
return "4px";
|
|
1254
|
-
case "8":
|
|
1255
|
-
return "8px";
|
|
1256
|
-
default:
|
|
1257
|
-
return null;
|
|
1258
|
-
}
|
|
1259
|
-
}
|
|
1260
|
-
function ringValue(theme, parsed) {
|
|
1261
|
-
const value = parsed.value;
|
|
1262
|
-
if (value === null) return null;
|
|
1263
|
-
if (value === "inset") {
|
|
1264
|
-
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1265
|
-
}
|
|
1266
|
-
if (!parsed.isArbitrary) {
|
|
1267
|
-
const w = ringWidth(value);
|
|
1268
|
-
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1269
|
-
}
|
|
1270
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1271
|
-
if (color === null) return null;
|
|
1272
|
-
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1273
|
-
}
|
|
1274
|
-
function ringOffsetValue(theme, parsed) {
|
|
1275
|
-
const value = parsed.value;
|
|
1276
|
-
if (value === null) return null;
|
|
1277
|
-
if (!parsed.isArbitrary) {
|
|
1278
|
-
const w = ringWidth(value);
|
|
1279
|
-
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1280
|
-
}
|
|
1281
|
-
const color = parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1282
|
-
if (color === null) return null;
|
|
1283
|
-
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1370
|
+
const v = parsed.isArbitrary ? value : outlineWidthValue(value);
|
|
1371
|
+
if (v === null) return null;
|
|
1372
|
+
return [decl("outline-offset", parsed.negative ? negate(v) : v)];
|
|
1284
1373
|
}
|
|
1285
1374
|
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1286
1375
|
function resolve3(parsed, theme) {
|
|
@@ -1310,14 +1399,19 @@ function resolve3(parsed, theme) {
|
|
|
1310
1399
|
const v = resolveLength(theme, parsed);
|
|
1311
1400
|
return v === null ? null : [decl("border-radius", v)];
|
|
1312
1401
|
}
|
|
1402
|
+
// Rings are web-only (a var()-composed CSS box-shadow React Native can't
|
|
1403
|
+
// parse) — same as resolvers/mod.rs's native dispatcher.
|
|
1313
1404
|
case "ring":
|
|
1314
|
-
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1315
|
-
return ringValue(theme, parsed);
|
|
1316
1405
|
case "ring-offset":
|
|
1317
|
-
return
|
|
1406
|
+
return null;
|
|
1407
|
+
// Outlines: the same final native style the Rust engine produces once
|
|
1408
|
+
// its var()-based web declarations are filtered out (resolve_style.rs):
|
|
1409
|
+
// bare `outline` is a 1px width, `outline-none` is outline-style: none,
|
|
1410
|
+
// `outline-hidden` keeps only its offset (RN has no `outline` shorthand).
|
|
1318
1411
|
case "outline":
|
|
1319
|
-
if (parsed.value === null) return [decl("outline-
|
|
1320
|
-
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1412
|
+
if (parsed.value === null) return [decl("outline-width", "1px")];
|
|
1413
|
+
if (parsed.value === "none") return [decl("outline-style", "none")];
|
|
1414
|
+
if (!parsed.isArbitrary && parsed.value === "hidden") return [decl("outline-offset", "2px")];
|
|
1321
1415
|
return outlineValue(theme, parsed);
|
|
1322
1416
|
case "outline-offset":
|
|
1323
1417
|
return outlineOffsetValue(parsed);
|
|
@@ -1348,32 +1442,75 @@ function textSize(key) {
|
|
|
1348
1442
|
return "1.875rem";
|
|
1349
1443
|
case "4xl":
|
|
1350
1444
|
return "2.25rem";
|
|
1445
|
+
case "5xl":
|
|
1446
|
+
return "3rem";
|
|
1447
|
+
case "6xl":
|
|
1448
|
+
return "3.75rem";
|
|
1449
|
+
case "7xl":
|
|
1450
|
+
return "4.5rem";
|
|
1451
|
+
case "8xl":
|
|
1452
|
+
return "6rem";
|
|
1453
|
+
case "9xl":
|
|
1454
|
+
return "8rem";
|
|
1351
1455
|
default:
|
|
1352
1456
|
return null;
|
|
1353
1457
|
}
|
|
1354
1458
|
}
|
|
1355
1459
|
function lineHeightSize(key) {
|
|
1460
|
+
if (key === "px") return "1px";
|
|
1461
|
+
if (key.trim() === "") return null;
|
|
1462
|
+
const n = Number(key);
|
|
1463
|
+
return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
|
|
1464
|
+
}
|
|
1465
|
+
function leadingNamed(key) {
|
|
1356
1466
|
switch (key) {
|
|
1357
|
-
case "
|
|
1358
|
-
return
|
|
1359
|
-
case "
|
|
1360
|
-
return
|
|
1361
|
-
case "
|
|
1362
|
-
return
|
|
1363
|
-
case "
|
|
1364
|
-
return
|
|
1365
|
-
case "
|
|
1366
|
-
return
|
|
1367
|
-
case "
|
|
1368
|
-
return
|
|
1369
|
-
case "9":
|
|
1370
|
-
return "2.25rem";
|
|
1371
|
-
case "10":
|
|
1372
|
-
return "2.5rem";
|
|
1467
|
+
case "none":
|
|
1468
|
+
return 1;
|
|
1469
|
+
case "tight":
|
|
1470
|
+
return 1.25;
|
|
1471
|
+
case "snug":
|
|
1472
|
+
return 1.375;
|
|
1473
|
+
case "normal":
|
|
1474
|
+
return 1.5;
|
|
1475
|
+
case "relaxed":
|
|
1476
|
+
return 1.625;
|
|
1477
|
+
case "loose":
|
|
1478
|
+
return 2;
|
|
1373
1479
|
default:
|
|
1374
1480
|
return null;
|
|
1375
1481
|
}
|
|
1376
1482
|
}
|
|
1483
|
+
function splitSizeLeading(value) {
|
|
1484
|
+
const i = value.indexOf("/");
|
|
1485
|
+
if (i === -1) return null;
|
|
1486
|
+
const size = textSize(value.slice(0, i));
|
|
1487
|
+
const leading = value.slice(i + 1);
|
|
1488
|
+
return size === null || leading === "" ? null : [size, leading];
|
|
1489
|
+
}
|
|
1490
|
+
function sizeLeadingNative(size, leading) {
|
|
1491
|
+
const rem = (n) => {
|
|
1492
|
+
const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
|
|
1493
|
+
if (unit === null) return null;
|
|
1494
|
+
const number = size.slice(0, -unit.length);
|
|
1495
|
+
const s = Number(number);
|
|
1496
|
+
return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
|
|
1497
|
+
};
|
|
1498
|
+
const arbitrary = arbitraryModifier(leading);
|
|
1499
|
+
if (arbitrary !== null) {
|
|
1500
|
+
if (arbitrary.startsWith("var(")) return null;
|
|
1501
|
+
const n = Number(arbitrary);
|
|
1502
|
+
return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
|
|
1503
|
+
}
|
|
1504
|
+
const scale = lineHeightSize(leading);
|
|
1505
|
+
if (scale !== null) return scale;
|
|
1506
|
+
const m = leadingNamed(leading);
|
|
1507
|
+
return m === null ? null : rem(m);
|
|
1508
|
+
}
|
|
1509
|
+
function arbitraryFontIsWeight(parsed, value) {
|
|
1510
|
+
const hint = parsed.typeHint ?? null;
|
|
1511
|
+
if (hint !== null) return hint === "number" || hint === "integer";
|
|
1512
|
+
return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
|
|
1513
|
+
}
|
|
1377
1514
|
function textAlign(key) {
|
|
1378
1515
|
switch (key) {
|
|
1379
1516
|
case "left":
|
|
@@ -1384,6 +1521,12 @@ function textAlign(key) {
|
|
|
1384
1521
|
return "right";
|
|
1385
1522
|
case "justify":
|
|
1386
1523
|
return "justify";
|
|
1524
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
1525
|
+
// as layout.rs's start/end inset properties.
|
|
1526
|
+
case "start":
|
|
1527
|
+
return "start";
|
|
1528
|
+
case "end":
|
|
1529
|
+
return "end";
|
|
1387
1530
|
default:
|
|
1388
1531
|
return null;
|
|
1389
1532
|
}
|
|
@@ -1392,6 +1535,10 @@ function fontWeight(key) {
|
|
|
1392
1535
|
switch (key) {
|
|
1393
1536
|
case "thin":
|
|
1394
1537
|
return "100";
|
|
1538
|
+
case "extralight":
|
|
1539
|
+
return "200";
|
|
1540
|
+
case "light":
|
|
1541
|
+
return "300";
|
|
1395
1542
|
case "normal":
|
|
1396
1543
|
return "400";
|
|
1397
1544
|
case "medium":
|
|
@@ -1402,6 +1549,22 @@ function fontWeight(key) {
|
|
|
1402
1549
|
return "700";
|
|
1403
1550
|
case "extrabold":
|
|
1404
1551
|
return "800";
|
|
1552
|
+
case "black":
|
|
1553
|
+
return "900";
|
|
1554
|
+
default:
|
|
1555
|
+
return null;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
function fontFamilyValue(theme, key) {
|
|
1559
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
1560
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
1561
|
+
switch (key) {
|
|
1562
|
+
case "sans":
|
|
1563
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
1564
|
+
case "serif":
|
|
1565
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
1566
|
+
case "mono":
|
|
1567
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1405
1568
|
default:
|
|
1406
1569
|
return null;
|
|
1407
1570
|
}
|
|
@@ -1410,8 +1573,14 @@ function fontWeight(key) {
|
|
|
1410
1573
|
// src/jsEngine/resolvers/effects.ts
|
|
1411
1574
|
function nativeShadowValue(key) {
|
|
1412
1575
|
switch (key) {
|
|
1413
|
-
|
|
1576
|
+
// Tailwind v4.3's scale, like effects.rs: `sm` is the default shadow,
|
|
1577
|
+
// v3's `sm` is `xs`.
|
|
1578
|
+
case "2xs":
|
|
1579
|
+
return { offsetY: 1, radius: 0, opacity: 0.05, elevation: 1 };
|
|
1580
|
+
case "xs":
|
|
1414
1581
|
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1582
|
+
case "sm":
|
|
1583
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1415
1584
|
case "DEFAULT":
|
|
1416
1585
|
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1417
1586
|
case "md":
|
|
@@ -1443,13 +1612,115 @@ function nativeShadowDeclarations(parsed) {
|
|
|
1443
1612
|
];
|
|
1444
1613
|
}
|
|
1445
1614
|
|
|
1615
|
+
// src/jsEngine/resolvers/transform.ts
|
|
1616
|
+
function scaleFactor(parsed) {
|
|
1617
|
+
if (parsed.value === null || parsed.value.trim() === "") return null;
|
|
1618
|
+
const n = Number(parsed.value);
|
|
1619
|
+
if (!Number.isFinite(n)) return null;
|
|
1620
|
+
const factor = parsed.isArbitrary ? n : n / 100;
|
|
1621
|
+
return parsed.negative ? -factor : factor;
|
|
1622
|
+
}
|
|
1623
|
+
function angle(parsed) {
|
|
1624
|
+
if (parsed.value === null) return null;
|
|
1625
|
+
if (parsed.isArbitrary) {
|
|
1626
|
+
if (!parsed.negative) return parsed.value;
|
|
1627
|
+
if (parsed.value.startsWith("-")) return parsed.value.slice(1);
|
|
1628
|
+
if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
|
|
1629
|
+
return `calc(${parsed.value} * -1)`;
|
|
1630
|
+
}
|
|
1631
|
+
const n = Number(parsed.value);
|
|
1632
|
+
if (!Number.isFinite(n)) return null;
|
|
1633
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
1634
|
+
}
|
|
1635
|
+
function resolveNative(parsed, theme) {
|
|
1636
|
+
switch (parsed.utility) {
|
|
1637
|
+
case "transform-none":
|
|
1638
|
+
return [decl("transform-op-none", "1")];
|
|
1639
|
+
// Both axes at once (`translate-4`, `-skew-3`); mirrors transform.rs.
|
|
1640
|
+
case "translate": {
|
|
1641
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-translate-x", "0"), decl("transform-op-translate-y", "0")];
|
|
1642
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1643
|
+
return v === null ? null : [decl("transform-op-translate-x", v), decl("transform-op-translate-y", v)];
|
|
1644
|
+
}
|
|
1645
|
+
case "skew": {
|
|
1646
|
+
const deg = angle(parsed);
|
|
1647
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg), decl("transform-op-skew-y", deg)];
|
|
1648
|
+
}
|
|
1649
|
+
case "backface-visible":
|
|
1650
|
+
return [decl("backface-visibility", "visible")];
|
|
1651
|
+
case "backface-hidden":
|
|
1652
|
+
return [decl("backface-visibility", "hidden")];
|
|
1653
|
+
case "translate-x": {
|
|
1654
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1655
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
1656
|
+
}
|
|
1657
|
+
case "translate-y": {
|
|
1658
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1659
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
1660
|
+
}
|
|
1661
|
+
case "scale": {
|
|
1662
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-scale-x", "1"), decl("transform-op-scale-y", "1")];
|
|
1663
|
+
const n = scaleFactor(parsed);
|
|
1664
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
1665
|
+
}
|
|
1666
|
+
case "scale-x": {
|
|
1667
|
+
const n = scaleFactor(parsed);
|
|
1668
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
1669
|
+
}
|
|
1670
|
+
case "scale-y": {
|
|
1671
|
+
const n = scaleFactor(parsed);
|
|
1672
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
1673
|
+
}
|
|
1674
|
+
case "rotate": {
|
|
1675
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-rotate", "0deg")];
|
|
1676
|
+
const deg = angle(parsed);
|
|
1677
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
1678
|
+
}
|
|
1679
|
+
case "rotate-x": {
|
|
1680
|
+
const deg = angle(parsed);
|
|
1681
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
1682
|
+
}
|
|
1683
|
+
case "rotate-y": {
|
|
1684
|
+
const deg = angle(parsed);
|
|
1685
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
1686
|
+
}
|
|
1687
|
+
case "rotate-z": {
|
|
1688
|
+
const deg = angle(parsed);
|
|
1689
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
1690
|
+
}
|
|
1691
|
+
case "skew-x": {
|
|
1692
|
+
const deg = angle(parsed);
|
|
1693
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
1694
|
+
}
|
|
1695
|
+
case "skew-y": {
|
|
1696
|
+
const deg = angle(parsed);
|
|
1697
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
1698
|
+
}
|
|
1699
|
+
default:
|
|
1700
|
+
return null;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1446
1704
|
// src/jsEngine/resolveUtilityNative.ts
|
|
1447
|
-
function
|
|
1705
|
+
function firstFontName(stack) {
|
|
1706
|
+
const first = stack.split(",")[0] ?? stack;
|
|
1707
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
1708
|
+
}
|
|
1709
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1448
1710
|
switch (parsed.utility) {
|
|
1449
1711
|
case "font": {
|
|
1450
1712
|
if (parsed.value === null) return null;
|
|
1713
|
+
if (parsed.isArbitrary) {
|
|
1714
|
+
if (arbitraryFontIsWeight(parsed, parsed.value)) {
|
|
1715
|
+
const n = Number(parsed.value);
|
|
1716
|
+
return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
|
|
1717
|
+
}
|
|
1718
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
1719
|
+
}
|
|
1451
1720
|
const w = fontWeight(parsed.value);
|
|
1452
|
-
|
|
1721
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
1722
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
1723
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1453
1724
|
}
|
|
1454
1725
|
case "uppercase":
|
|
1455
1726
|
return [decl("text-transform", "uppercase")];
|
|
@@ -1485,16 +1756,27 @@ function resolveLeadingTrackingNative(parsed) {
|
|
|
1485
1756
|
return null;
|
|
1486
1757
|
}
|
|
1487
1758
|
function nativeHexColor(parsed, theme) {
|
|
1488
|
-
|
|
1489
|
-
if (value === null) return null;
|
|
1490
|
-
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1759
|
+
return colorValue(theme, parsed);
|
|
1491
1760
|
}
|
|
1492
1761
|
function resolveTextNative(parsed, theme) {
|
|
1493
1762
|
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1494
1763
|
const size = textSize(parsed.value);
|
|
1495
1764
|
if (size !== null) return [decl("font-size", size)];
|
|
1765
|
+
const sized = splitSizeLeading(parsed.value);
|
|
1766
|
+
if (sized !== null) {
|
|
1767
|
+
const lh = sizeLeadingNative(sized[0], sized[1]);
|
|
1768
|
+
return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
|
|
1769
|
+
}
|
|
1496
1770
|
const align = textAlign(parsed.value);
|
|
1497
1771
|
if (align !== null) return [decl("text-align", align)];
|
|
1772
|
+
} else if (parsed.isArbitrary && parsed.value !== null) {
|
|
1773
|
+
const leading = parsed.modifier ?? null;
|
|
1774
|
+
if (isLength(parsed, parsed.value)) {
|
|
1775
|
+
if (leading === null) return [decl("font-size", parsed.value)];
|
|
1776
|
+
const lh = sizeLeadingNative(parsed.value, leading);
|
|
1777
|
+
return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
|
|
1778
|
+
}
|
|
1779
|
+
if (leading !== null) return null;
|
|
1498
1780
|
}
|
|
1499
1781
|
const hex = nativeHexColor(parsed, theme);
|
|
1500
1782
|
return hex === null ? null : [decl("color", hex)];
|
|
@@ -1511,13 +1793,167 @@ function resolveColorNative(parsed, theme) {
|
|
|
1511
1793
|
return null;
|
|
1512
1794
|
}
|
|
1513
1795
|
}
|
|
1796
|
+
function resolveOpacityNative(parsed) {
|
|
1797
|
+
if (parsed.utility !== "opacity") return null;
|
|
1798
|
+
const v = resolvePercent(parsed);
|
|
1799
|
+
return v === null ? null : [decl("opacity", v)];
|
|
1800
|
+
}
|
|
1514
1801
|
function resolveUtilityNative(parsed, theme) {
|
|
1515
|
-
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
1802
|
+
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);
|
|
1516
1803
|
}
|
|
1517
1804
|
|
|
1805
|
+
// src/jsEngine/calc.ts
|
|
1806
|
+
function reduceConstantMath(raw) {
|
|
1807
|
+
const trimmed = raw.trim();
|
|
1808
|
+
const calc = stripCall(trimmed, "calc");
|
|
1809
|
+
if (calc !== null) {
|
|
1810
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
1811
|
+
}
|
|
1812
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
1813
|
+
if (clamp !== null) {
|
|
1814
|
+
const args = splitTopLevelCommas(clamp);
|
|
1815
|
+
if (args.length !== 3) return null;
|
|
1816
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
1817
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
1818
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
1819
|
+
}
|
|
1820
|
+
const min = stripCall(trimmed, "min");
|
|
1821
|
+
if (min !== null) {
|
|
1822
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1823
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
1824
|
+
}
|
|
1825
|
+
const max = stripCall(trimmed, "max");
|
|
1826
|
+
if (max !== null) {
|
|
1827
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1828
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
1829
|
+
}
|
|
1830
|
+
return null;
|
|
1831
|
+
}
|
|
1832
|
+
function stripCall(raw, name) {
|
|
1833
|
+
if (!raw.startsWith(name)) return null;
|
|
1834
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
1835
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
1836
|
+
return afterName.slice(1, -1);
|
|
1837
|
+
}
|
|
1838
|
+
function splitTopLevelCommas(s) {
|
|
1839
|
+
const parts = [];
|
|
1840
|
+
let depth = 0;
|
|
1841
|
+
let start = 0;
|
|
1842
|
+
for (let i = 0; i < s.length; i++) {
|
|
1843
|
+
const ch = s[i];
|
|
1844
|
+
if (ch === "(") depth++;
|
|
1845
|
+
else if (ch === ")") depth--;
|
|
1846
|
+
else if (ch === "," && depth === 0) {
|
|
1847
|
+
parts.push(s.slice(start, i).trim());
|
|
1848
|
+
start = i + 1;
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
parts.push(s.slice(start).trim());
|
|
1852
|
+
return parts;
|
|
1853
|
+
}
|
|
1854
|
+
var Evaluator = class {
|
|
1855
|
+
constructor(s) {
|
|
1856
|
+
this.pos = 0;
|
|
1857
|
+
this.s = s;
|
|
1858
|
+
}
|
|
1859
|
+
parseExprToEnd() {
|
|
1860
|
+
const value = this.expr();
|
|
1861
|
+
if (value === null) return null;
|
|
1862
|
+
this.skipWs();
|
|
1863
|
+
return this.pos === this.s.length ? value : null;
|
|
1864
|
+
}
|
|
1865
|
+
skipWs() {
|
|
1866
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
1867
|
+
}
|
|
1868
|
+
peek() {
|
|
1869
|
+
this.skipWs();
|
|
1870
|
+
return this.s[this.pos];
|
|
1871
|
+
}
|
|
1872
|
+
expr() {
|
|
1873
|
+
let value = this.term();
|
|
1874
|
+
if (value === null) return null;
|
|
1875
|
+
for (; ; ) {
|
|
1876
|
+
const ch = this.peek();
|
|
1877
|
+
if (ch === "+") {
|
|
1878
|
+
this.pos++;
|
|
1879
|
+
const rhs = this.term();
|
|
1880
|
+
if (rhs === null) return null;
|
|
1881
|
+
value += rhs;
|
|
1882
|
+
} else if (ch === "-") {
|
|
1883
|
+
this.pos++;
|
|
1884
|
+
const rhs = this.term();
|
|
1885
|
+
if (rhs === null) return null;
|
|
1886
|
+
value -= rhs;
|
|
1887
|
+
} else {
|
|
1888
|
+
return value;
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
term() {
|
|
1893
|
+
let value = this.factor();
|
|
1894
|
+
if (value === null) return null;
|
|
1895
|
+
for (; ; ) {
|
|
1896
|
+
const ch = this.peek();
|
|
1897
|
+
if (ch === "*") {
|
|
1898
|
+
this.pos++;
|
|
1899
|
+
const rhs = this.factor();
|
|
1900
|
+
if (rhs === null) return null;
|
|
1901
|
+
value *= rhs;
|
|
1902
|
+
} else if (ch === "/") {
|
|
1903
|
+
this.pos++;
|
|
1904
|
+
const divisor = this.factor();
|
|
1905
|
+
if (divisor === null || divisor === 0) return null;
|
|
1906
|
+
value /= divisor;
|
|
1907
|
+
} else {
|
|
1908
|
+
return value;
|
|
1909
|
+
}
|
|
1910
|
+
}
|
|
1911
|
+
}
|
|
1912
|
+
factor() {
|
|
1913
|
+
const ch = this.peek();
|
|
1914
|
+
if (ch === void 0) return null;
|
|
1915
|
+
if (ch === "(") {
|
|
1916
|
+
this.pos++;
|
|
1917
|
+
const value = this.expr();
|
|
1918
|
+
if (value === null || this.peek() !== ")") return null;
|
|
1919
|
+
this.pos++;
|
|
1920
|
+
return value;
|
|
1921
|
+
}
|
|
1922
|
+
if (ch === "-") {
|
|
1923
|
+
this.pos++;
|
|
1924
|
+
const value = this.factor();
|
|
1925
|
+
return value === null ? null : -value;
|
|
1926
|
+
}
|
|
1927
|
+
return this.numberWithUnit();
|
|
1928
|
+
}
|
|
1929
|
+
numberWithUnit() {
|
|
1930
|
+
this.skipWs();
|
|
1931
|
+
const start = this.pos;
|
|
1932
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
1933
|
+
if (this.pos === start) return null;
|
|
1934
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
1935
|
+
if (!Number.isFinite(n)) return null;
|
|
1936
|
+
const unitStart = this.pos;
|
|
1937
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
1938
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
1939
|
+
switch (unit) {
|
|
1940
|
+
case "":
|
|
1941
|
+
return n;
|
|
1942
|
+
case "px":
|
|
1943
|
+
return n;
|
|
1944
|
+
case "rem":
|
|
1945
|
+
return n * 16;
|
|
1946
|
+
default:
|
|
1947
|
+
return null;
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1951
|
+
|
|
1518
1952
|
// src/jsEngine/resolveStyle.ts
|
|
1519
1953
|
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1954
|
+
var STATE_HOLD_MARKER = "_kbon";
|
|
1520
1955
|
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1956
|
+
if (modifier === STATE_HOLD_MARKER) return true;
|
|
1521
1957
|
if (modifier === "dark") return colorScheme === "dark";
|
|
1522
1958
|
if (modifier === "active") return pressed;
|
|
1523
1959
|
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
@@ -1525,6 +1961,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
|
1525
1961
|
if (minWidth === void 0) return null;
|
|
1526
1962
|
return width >= minWidth;
|
|
1527
1963
|
}
|
|
1964
|
+
if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
|
|
1965
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1966
|
+
return px === null ? null : width >= px;
|
|
1967
|
+
}
|
|
1968
|
+
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
1969
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1970
|
+
return px === null ? null : width < px;
|
|
1971
|
+
}
|
|
1972
|
+
const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
|
|
1973
|
+
const custom = screen(modifier);
|
|
1974
|
+
if (typeof custom === "number") return width >= custom;
|
|
1975
|
+
if (modifier.startsWith("max-")) {
|
|
1976
|
+
const max = screen(modifier.slice(4));
|
|
1977
|
+
if (typeof max === "number") return width < max;
|
|
1978
|
+
}
|
|
1979
|
+
if (modifier.startsWith("min-")) {
|
|
1980
|
+
const min = screen(modifier.slice(4));
|
|
1981
|
+
if (typeof min === "number") return width >= min;
|
|
1982
|
+
}
|
|
1983
|
+
if (modifier.startsWith("not-")) {
|
|
1984
|
+
const rest = modifier.slice(4);
|
|
1985
|
+
if (rest === "dark") return colorScheme !== "dark";
|
|
1986
|
+
const isBreakpoint = (name) => typeof screen(name) === "number";
|
|
1987
|
+
if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
|
|
1988
|
+
const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
|
|
1989
|
+
return holds === null ? null : !holds;
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1528
1992
|
return null;
|
|
1529
1993
|
}
|
|
1530
1994
|
function kebabToCamel(s) {
|
|
@@ -1569,6 +2033,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1569
2033
|
"shadow-opacity",
|
|
1570
2034
|
"shadow-radius",
|
|
1571
2035
|
"elevation",
|
|
2036
|
+
"opacity",
|
|
1572
2037
|
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1573
2038
|
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1574
2039
|
// style system wants plain numbers for these exactly like the generic
|
|
@@ -1582,29 +2047,105 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1582
2047
|
"border-bottom-right-radius",
|
|
1583
2048
|
"border-bottom-left-radius",
|
|
1584
2049
|
"outline-width",
|
|
1585
|
-
"outline-offset"
|
|
2050
|
+
"outline-offset",
|
|
2051
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
2052
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
2053
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
2054
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
2055
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
2056
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
2057
|
+
// get collected into the final array.
|
|
2058
|
+
"transform-op-translate-x",
|
|
2059
|
+
"transform-op-translate-y",
|
|
2060
|
+
"transform-op-scale-x",
|
|
2061
|
+
"transform-op-scale-y"
|
|
2062
|
+
]);
|
|
2063
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
2064
|
+
["transform-op-translate-x", "translateX"],
|
|
2065
|
+
["transform-op-translate-y", "translateY"],
|
|
2066
|
+
["transform-op-rotate", "rotate"],
|
|
2067
|
+
["transform-op-rotate-x", "rotateX"],
|
|
2068
|
+
["transform-op-rotate-y", "rotateY"],
|
|
2069
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
2070
|
+
["transform-op-skew-x", "skewX"],
|
|
2071
|
+
["transform-op-skew-y", "skewY"],
|
|
2072
|
+
["transform-op-scale-x", "scaleX"],
|
|
2073
|
+
["transform-op-scale-y", "scaleY"]
|
|
1586
2074
|
]);
|
|
2075
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
2076
|
+
function isPlainPercentage(value) {
|
|
2077
|
+
if (!value.endsWith("%")) return false;
|
|
2078
|
+
let digits = value.slice(0, -1);
|
|
2079
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
2080
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
2081
|
+
}
|
|
2082
|
+
function sanitizeForWarning(value) {
|
|
2083
|
+
const MAX_CHARS = 60;
|
|
2084
|
+
const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
|
|
2085
|
+
if (escaped.length <= MAX_CHARS) return escaped;
|
|
2086
|
+
return `${escaped.slice(0, MAX_CHARS)}\u2026`;
|
|
2087
|
+
}
|
|
1587
2088
|
function rnStyleValue(property, value) {
|
|
1588
|
-
if (
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
2089
|
+
if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
|
|
2090
|
+
const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
|
|
2091
|
+
const space = inner.lastIndexOf(" ");
|
|
2092
|
+
if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
|
|
2093
|
+
}
|
|
2094
|
+
if (property === "aspect-ratio") {
|
|
2095
|
+
if (value.trim() === "auto") return { value: null, warning: null };
|
|
2096
|
+
const parts = value.split("/").map((s) => s.trim());
|
|
2097
|
+
let n = null;
|
|
2098
|
+
if (parts.length === 1) {
|
|
2099
|
+
const a = Number(parts[0]);
|
|
2100
|
+
n = Number.isFinite(a) ? a : null;
|
|
2101
|
+
} else if (parts.length === 2) {
|
|
2102
|
+
const a = Number(parts[0]);
|
|
2103
|
+
const b = Number(parts[1]);
|
|
2104
|
+
n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
|
|
1599
2105
|
}
|
|
1600
|
-
|
|
2106
|
+
return { value: n, warning: null };
|
|
1601
2107
|
}
|
|
1602
|
-
|
|
1603
|
-
}
|
|
1604
|
-
|
|
2108
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
2109
|
+
return { value, warning: null };
|
|
2110
|
+
}
|
|
2111
|
+
if (value === "auto") {
|
|
2112
|
+
return { value: "auto", warning: null };
|
|
2113
|
+
}
|
|
2114
|
+
let px = null;
|
|
2115
|
+
if (value.endsWith("px")) {
|
|
2116
|
+
const n = Number(value.slice(0, -2));
|
|
2117
|
+
px = Number.isFinite(n) ? n : null;
|
|
2118
|
+
} else if (value.endsWith("rem")) {
|
|
2119
|
+
const n = Number(value.slice(0, -3));
|
|
2120
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
2121
|
+
} else {
|
|
2122
|
+
const n = Number(value);
|
|
2123
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
2124
|
+
}
|
|
2125
|
+
if (px !== null) return { value: px, warning: null };
|
|
2126
|
+
if (isPlainPercentage(value)) {
|
|
2127
|
+
return { value, warning: null };
|
|
2128
|
+
}
|
|
2129
|
+
const reduced = reduceConstantMath(value);
|
|
2130
|
+
if (reduced !== null) {
|
|
2131
|
+
return { value: reduced, warning: null };
|
|
2132
|
+
}
|
|
2133
|
+
const sanitizedValue = sanitizeForWarning(value);
|
|
2134
|
+
const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
2135
|
+
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).
|
|
2136
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
2137
|
+
return { value: null, warning };
|
|
2138
|
+
}
|
|
2139
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
2140
|
+
classString = expandVariantGroups(classString);
|
|
1605
2141
|
const style = {};
|
|
2142
|
+
const warnings = [];
|
|
1606
2143
|
let shadowOffset = null;
|
|
1607
|
-
|
|
2144
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
2145
|
+
const keySpecificity = /* @__PURE__ */ new Map();
|
|
2146
|
+
const transformSpecificity = /* @__PURE__ */ new Map();
|
|
2147
|
+
for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
|
|
2148
|
+
const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
|
|
1608
2149
|
const parsed = parseClass(token);
|
|
1609
2150
|
const allModifiersHold = parsed.modifiers.every(
|
|
1610
2151
|
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
@@ -1612,39 +2153,126 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
|
1612
2153
|
if (!allModifiersHold) continue;
|
|
1613
2154
|
const decls = resolveUtilityNative(parsed, theme);
|
|
1614
2155
|
if (decls === null) continue;
|
|
2156
|
+
const spec = parsed.modifiers.length;
|
|
1615
2157
|
for (const d of decls) {
|
|
1616
2158
|
if (d.property.startsWith("__")) {
|
|
1617
2159
|
continue;
|
|
1618
2160
|
}
|
|
2161
|
+
if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
|
|
2162
|
+
continue;
|
|
2163
|
+
}
|
|
1619
2164
|
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
2165
|
+
if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
|
|
1620
2166
|
const n = Number(d.value);
|
|
1621
2167
|
if (!Number.isFinite(n)) continue;
|
|
1622
2168
|
if (shadowOffset === null) shadowOffset = {};
|
|
1623
2169
|
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
2170
|
+
keySpecificity.set("shadowOffset", spec);
|
|
2171
|
+
continue;
|
|
2172
|
+
}
|
|
2173
|
+
if (d.property === "transform-op-none") {
|
|
2174
|
+
transformOps.clear();
|
|
2175
|
+
transformSpecificity.clear();
|
|
1624
2176
|
continue;
|
|
1625
2177
|
}
|
|
1626
|
-
|
|
2178
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
2179
|
+
if (opKey !== void 0) {
|
|
2180
|
+
if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
|
|
2181
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
2182
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
2183
|
+
if (value2 !== null) {
|
|
2184
|
+
transformOps.set(opKey, value2);
|
|
2185
|
+
transformSpecificity.set(opKey, spec);
|
|
2186
|
+
}
|
|
2187
|
+
continue;
|
|
2188
|
+
}
|
|
2189
|
+
const key = kebabToCamel(d.property);
|
|
2190
|
+
if (spec < (keySpecificity.get(key) ?? 0)) continue;
|
|
2191
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
2192
|
+
if (warning !== null) warnings.push(warning);
|
|
2193
|
+
if (value !== null) {
|
|
2194
|
+
style[key] = value;
|
|
2195
|
+
keySpecificity.set(key, spec);
|
|
2196
|
+
}
|
|
1627
2197
|
}
|
|
1628
2198
|
}
|
|
1629
2199
|
if (shadowOffset !== null) {
|
|
1630
2200
|
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1631
2201
|
}
|
|
1632
|
-
|
|
2202
|
+
if (transformOps.size > 0) {
|
|
2203
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
2204
|
+
[key]: transformOps.get(key)
|
|
2205
|
+
}));
|
|
2206
|
+
}
|
|
2207
|
+
return { style, warnings };
|
|
1633
2208
|
}
|
|
1634
2209
|
|
|
1635
2210
|
// src/nativeBridge.ts
|
|
2211
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
2212
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
2213
|
+
var cachedForThemeJson = null;
|
|
1636
2214
|
function resolveStyle(classString, pressed = false) {
|
|
1637
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1638
|
-
const width =
|
|
1639
|
-
const
|
|
2215
|
+
const colorScheme = (0, import_darkModeStore.getGlobalDarkMode)() ? "dark" : "light";
|
|
2216
|
+
const width = import_react_native.Dimensions.get("window").width;
|
|
2217
|
+
const themeJson = (0, import_theme.getThemeJson)();
|
|
2218
|
+
if (themeJson !== cachedForThemeJson) {
|
|
2219
|
+
resolveStyleCache.clear();
|
|
2220
|
+
cachedForThemeJson = themeJson;
|
|
2221
|
+
}
|
|
2222
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
2223
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
2224
|
+
if (cached !== void 0) return { ...cached };
|
|
2225
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
2226
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
2227
|
+
resolveStyleCache.set(cacheKey, style);
|
|
2228
|
+
return { ...style };
|
|
2229
|
+
}
|
|
2230
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
2231
|
+
const KbachModule = import_react_native.TurboModuleRegistry.get("KbachModule");
|
|
1640
2232
|
if (!KbachModule) {
|
|
1641
|
-
|
|
2233
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
|
|
2234
|
+
warnIfDev(classString, warnings2);
|
|
2235
|
+
return style2;
|
|
2236
|
+
}
|
|
2237
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
2238
|
+
const style = JSON.parse(json);
|
|
2239
|
+
const warnings = style.__kbachWarnings;
|
|
2240
|
+
if (warnings !== void 0) {
|
|
2241
|
+
delete style.__kbachWarnings;
|
|
2242
|
+
warnIfDev(classString, warnings);
|
|
2243
|
+
}
|
|
2244
|
+
return style;
|
|
2245
|
+
}
|
|
2246
|
+
var WARNED_MESSAGES_MAX = 500;
|
|
2247
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
2248
|
+
var QUOTED_TOKEN_RE = /"([^"]*)"/;
|
|
2249
|
+
function highlightToken(classString, warning) {
|
|
2250
|
+
const match = QUOTED_TOKEN_RE.exec(warning);
|
|
2251
|
+
if (match === null) return classString;
|
|
2252
|
+
const quoted = match[1].replace(/\s+/g, "");
|
|
2253
|
+
if (quoted === "") return classString;
|
|
2254
|
+
const parts = classString.split(/(\s+)/);
|
|
2255
|
+
const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
|
|
2256
|
+
if (idx === -1) return classString;
|
|
2257
|
+
parts[idx] = `\xBB${parts[idx]}\xAB`;
|
|
2258
|
+
return parts.join("");
|
|
2259
|
+
}
|
|
2260
|
+
function warnIfDev(classString, warnings) {
|
|
2261
|
+
if (warnings.length === 0) return;
|
|
2262
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
2263
|
+
for (const warning of warnings) {
|
|
2264
|
+
const message = `${warning}
|
|
2265
|
+
From className: "${highlightToken(classString, warning)}"`;
|
|
2266
|
+
if (warnedMessages.has(message)) continue;
|
|
2267
|
+
if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
|
|
2268
|
+
warnedMessages.add(message);
|
|
2269
|
+
console.warn(message);
|
|
1642
2270
|
}
|
|
1643
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1644
|
-
return JSON.parse(json);
|
|
1645
2271
|
}
|
|
1646
2272
|
|
|
1647
2273
|
// src/config.ts
|
|
2274
|
+
var import_theme2 = require("./theme");
|
|
2275
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1648
2276
|
function parseHexRgb(hex) {
|
|
1649
2277
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1650
2278
|
if (!m) return null;
|
|
@@ -1653,7 +2281,7 @@ function parseHexRgb(hex) {
|
|
|
1653
2281
|
const n = parseInt(h, 16);
|
|
1654
2282
|
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1655
2283
|
}
|
|
1656
|
-
function
|
|
2284
|
+
function applyOpacityToHex2(hex, opacityText) {
|
|
1657
2285
|
const rgb = parseHexRgb(hex);
|
|
1658
2286
|
if (!rgb) return hex;
|
|
1659
2287
|
const a = Number(opacityText) / 100;
|
|
@@ -1666,21 +2294,39 @@ function resolveColorEntry(value, lookup) {
|
|
|
1666
2294
|
const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
|
|
1667
2295
|
const base = lookup(name);
|
|
1668
2296
|
if (base === void 0) return value;
|
|
1669
|
-
return opacity === void 0 ? base :
|
|
2297
|
+
return opacity === void 0 ? base : applyOpacityToHex2(base, opacity);
|
|
1670
2298
|
}
|
|
1671
2299
|
function resolveColors(extend, existing) {
|
|
1672
|
-
const
|
|
1673
|
-
const
|
|
1674
|
-
|
|
2300
|
+
const { dark: darkExtend, ...lightExtend } = extend;
|
|
2301
|
+
const resolvedLight = {};
|
|
2302
|
+
const lookupLight = (name) => {
|
|
2303
|
+
const found = resolvedLight[name] ?? existing[name];
|
|
1675
2304
|
return typeof found === "string" ? found : void 0;
|
|
1676
2305
|
};
|
|
1677
|
-
for (const [name, value] of Object.entries(
|
|
1678
|
-
|
|
2306
|
+
for (const [name, value] of Object.entries(lightExtend)) {
|
|
2307
|
+
if (typeof value !== "string") continue;
|
|
2308
|
+
resolvedLight[name] = resolveColorEntry(value, lookupLight);
|
|
2309
|
+
}
|
|
2310
|
+
const result = { ...resolvedLight };
|
|
2311
|
+
if (darkExtend) {
|
|
2312
|
+
const resolvedDark = {};
|
|
2313
|
+
const lookupDark = (name) => {
|
|
2314
|
+
const found = resolvedDark[name] ?? existing[name];
|
|
2315
|
+
return typeof found === "string" ? found : void 0;
|
|
2316
|
+
};
|
|
2317
|
+
for (const [name, value] of Object.entries(darkExtend)) {
|
|
2318
|
+
resolvedDark[name] = resolveColorEntry(value, lookupDark);
|
|
2319
|
+
}
|
|
2320
|
+
for (const [name, darkValue] of Object.entries(resolvedDark)) {
|
|
2321
|
+
const lightValue = resolvedLight[name];
|
|
2322
|
+
if (lightValue === void 0) continue;
|
|
2323
|
+
result[name] = { light: lightValue, dark: darkValue };
|
|
2324
|
+
}
|
|
1679
2325
|
}
|
|
1680
|
-
return
|
|
2326
|
+
return result;
|
|
1681
2327
|
}
|
|
1682
2328
|
function resolveKbachConfig(config) {
|
|
1683
|
-
let theme = { ...defaultTheme, ...config.theme };
|
|
2329
|
+
let theme = { ...import_theme2.defaultTheme, ...config.theme };
|
|
1684
2330
|
if (config.extend?.colors) {
|
|
1685
2331
|
theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
|
|
1686
2332
|
}
|
|
@@ -1703,33 +2349,40 @@ function resolveKbachConfig(config) {
|
|
|
1703
2349
|
}
|
|
1704
2350
|
function applyKbachConfig(config) {
|
|
1705
2351
|
const theme = resolveKbachConfig(config);
|
|
1706
|
-
setTheme(theme);
|
|
2352
|
+
(0, import_theme2.setTheme)(theme);
|
|
2353
|
+
(0, import_darkModeStore2.resyncDomWithActiveTheme)();
|
|
1707
2354
|
return theme;
|
|
1708
2355
|
}
|
|
1709
2356
|
|
|
1710
2357
|
// src/useTheme.ts
|
|
1711
2358
|
var import_react = require("react");
|
|
2359
|
+
var import_darkModeStore3 = require("./darkModeStore");
|
|
1712
2360
|
function useTheme() {
|
|
1713
|
-
const
|
|
1714
|
-
const
|
|
2361
|
+
const isDark = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalDarkMode);
|
|
2362
|
+
const mode = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalThemeMode);
|
|
1715
2363
|
return (0, import_react.useMemo)(
|
|
1716
|
-
() => ({ mode
|
|
1717
|
-
[
|
|
2364
|
+
() => ({ mode, isDark, setMode: import_darkModeStore3.setGlobalThemeMode, toggle: import_darkModeStore3.toggleGlobalDarkMode }),
|
|
2365
|
+
[mode, isDark]
|
|
1718
2366
|
);
|
|
1719
2367
|
}
|
|
1720
2368
|
|
|
1721
2369
|
// src/ThemeProvider.tsx
|
|
1722
2370
|
var import_react2 = require("react");
|
|
2371
|
+
var import_darkModeStore4 = require("./darkModeStore");
|
|
1723
2372
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2373
|
+
var PERSIST_STORAGE_KEY = "kbach-theme";
|
|
2374
|
+
function isThemeMode(value) {
|
|
2375
|
+
return value === "light" || value === "dark" || value === "system";
|
|
2376
|
+
}
|
|
1724
2377
|
var mountedProviderCount = 0;
|
|
1725
2378
|
var warnedMultipleProviders = false;
|
|
1726
|
-
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
2379
|
+
function ThemeProvider({ children, defaultMode = "system", persist = false }) {
|
|
1727
2380
|
(0, import_react2.useEffect)(() => {
|
|
1728
2381
|
mountedProviderCount++;
|
|
1729
2382
|
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
1730
2383
|
warnedMultipleProviders = true;
|
|
1731
2384
|
console.warn(
|
|
1732
|
-
"[
|
|
2385
|
+
"[Kbach] Multiple <ThemeProvider> instances are mounted at once.\nDark mode is one global store \u2014 useTheme() reads it everywhere, not scoped per provider \u2014 so their defaultMode/persist seeds will fight over the same state.\nMount exactly one <ThemeProvider>, as high in the tree as convenient."
|
|
1733
2386
|
);
|
|
1734
2387
|
}
|
|
1735
2388
|
return () => {
|
|
@@ -1740,12 +2393,38 @@ function ThemeProvider({ children, defaultMode = "system" }) {
|
|
|
1740
2393
|
(0, import_react2.useEffect)(() => {
|
|
1741
2394
|
if (seeded.current) return;
|
|
1742
2395
|
seeded.current = true;
|
|
1743
|
-
|
|
2396
|
+
if (!persist) {
|
|
2397
|
+
(0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2398
|
+
return;
|
|
2399
|
+
}
|
|
2400
|
+
let cancelled = false;
|
|
2401
|
+
persist.getItem(PERSIST_STORAGE_KEY).then((stored) => {
|
|
2402
|
+
if (cancelled) return;
|
|
2403
|
+
if (isThemeMode(stored)) (0, import_darkModeStore4.seedDefaultMode)(stored);
|
|
2404
|
+
else (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2405
|
+
}).catch(() => {
|
|
2406
|
+
if (!cancelled) (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2407
|
+
});
|
|
2408
|
+
return () => {
|
|
2409
|
+
cancelled = true;
|
|
2410
|
+
};
|
|
1744
2411
|
}, []);
|
|
2412
|
+
(0, import_react2.useEffect)(() => {
|
|
2413
|
+
if (!persist) return;
|
|
2414
|
+
return (0, import_darkModeStore4.subscribeGlobalDarkMode)(() => {
|
|
2415
|
+
persist.setItem(PERSIST_STORAGE_KEY, (0, import_darkModeStore4.getGlobalThemeMode)()).catch(() => {
|
|
2416
|
+
});
|
|
2417
|
+
});
|
|
2418
|
+
}, [persist]);
|
|
1745
2419
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
1746
2420
|
}
|
|
1747
2421
|
|
|
2422
|
+
// src/index.ts
|
|
2423
|
+
var import_darkModeStore5 = require("./darkModeStore");
|
|
2424
|
+
|
|
1748
2425
|
// src/useColors.ts
|
|
2426
|
+
var import_react3 = require("react");
|
|
2427
|
+
var import_theme3 = require("./theme");
|
|
1749
2428
|
function parseHexRgb2(hex) {
|
|
1750
2429
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1751
2430
|
if (!m) return null;
|
|
@@ -1764,10 +2443,10 @@ function applyOpacity(color, opacity) {
|
|
|
1764
2443
|
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
1765
2444
|
return color;
|
|
1766
2445
|
}
|
|
1767
|
-
function resolveEntry(entry,
|
|
1768
|
-
return typeof entry === "string" ? entry :
|
|
2446
|
+
function resolveEntry(entry, isDark) {
|
|
2447
|
+
return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
|
|
1769
2448
|
}
|
|
1770
|
-
function makeColorsProxy(theme,
|
|
2449
|
+
function makeColorsProxy(theme, isDark) {
|
|
1771
2450
|
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
1772
2451
|
const cache = /* @__PURE__ */ new Map();
|
|
1773
2452
|
function resolveNamed(key) {
|
|
@@ -1780,7 +2459,7 @@ function makeColorsProxy(theme, isDark2) {
|
|
|
1780
2459
|
}
|
|
1781
2460
|
const entry = theme.colors[name];
|
|
1782
2461
|
if (entry === void 0) return void 0;
|
|
1783
|
-
const value = resolveEntry(entry,
|
|
2462
|
+
const value = resolveEntry(entry, isDark);
|
|
1784
2463
|
return opacity === void 0 ? value : applyOpacity(value, opacity);
|
|
1785
2464
|
}
|
|
1786
2465
|
function makeFamilyProxy(family) {
|
|
@@ -1792,11 +2471,13 @@ function makeColorsProxy(theme, isDark2) {
|
|
|
1792
2471
|
}
|
|
1793
2472
|
});
|
|
1794
2473
|
}
|
|
1795
|
-
|
|
2474
|
+
const get = (name) => resolveNamed(name) ?? name;
|
|
2475
|
+
return new Proxy({ alpha, get }, {
|
|
1796
2476
|
get(_, prop) {
|
|
1797
2477
|
const key = String(prop);
|
|
1798
2478
|
if (key === "then") return void 0;
|
|
1799
2479
|
if (key === "alpha") return alpha;
|
|
2480
|
+
if (key === "get") return get;
|
|
1800
2481
|
const direct = resolveNamed(key);
|
|
1801
2482
|
if (direct !== void 0) return direct;
|
|
1802
2483
|
if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
|
|
@@ -1805,23 +2486,100 @@ function makeColorsProxy(theme, isDark2) {
|
|
|
1805
2486
|
});
|
|
1806
2487
|
}
|
|
1807
2488
|
function useColors() {
|
|
1808
|
-
const { isDark
|
|
1809
|
-
|
|
2489
|
+
const { isDark } = useTheme();
|
|
2490
|
+
const theme = (0, import_theme3.getTheme)();
|
|
2491
|
+
return (0, import_react3.useMemo)(() => makeColorsProxy(theme, isDark), [theme, isDark]);
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
// src/index.ts
|
|
2495
|
+
var import_dynamicTokens2 = require("./dynamicTokens");
|
|
2496
|
+
|
|
2497
|
+
// src/useDynamicToken.ts
|
|
2498
|
+
var import_react4 = require("react");
|
|
2499
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
2500
|
+
function useDynamicToken(name) {
|
|
2501
|
+
return (0, import_react4.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
// src/clsx.ts
|
|
2505
|
+
function clsx(...inputs) {
|
|
2506
|
+
let out = "";
|
|
2507
|
+
for (const input of inputs) {
|
|
2508
|
+
const piece = resolveClassValue(input);
|
|
2509
|
+
if (piece) out = out ? `${out} ${piece}` : piece;
|
|
2510
|
+
}
|
|
2511
|
+
return out;
|
|
2512
|
+
}
|
|
2513
|
+
function resolveClassValue(value) {
|
|
2514
|
+
if (!value) return "";
|
|
2515
|
+
const type = typeof value;
|
|
2516
|
+
if (type === "string" || type === "number" || type === "bigint") return String(value);
|
|
2517
|
+
if (Array.isArray(value)) return clsx(...value);
|
|
2518
|
+
if (type === "object") {
|
|
2519
|
+
let out = "";
|
|
2520
|
+
for (const key in value) {
|
|
2521
|
+
if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
|
|
2522
|
+
out = out ? `${out} ${key}` : key;
|
|
2523
|
+
}
|
|
2524
|
+
}
|
|
2525
|
+
return out;
|
|
2526
|
+
}
|
|
2527
|
+
return "";
|
|
1810
2528
|
}
|
|
2529
|
+
|
|
2530
|
+
// src/semanticElements.tsx
|
|
2531
|
+
var React = __toESM(require("react"));
|
|
2532
|
+
var import_react_native2 = require("react-native");
|
|
2533
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2534
|
+
var Button = React.forwardRef(function Button2(props, ref) {
|
|
2535
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Pressable, { ref, accessibilityRole: "button", ...props });
|
|
2536
|
+
});
|
|
2537
|
+
var PARAGRAPH_ROLE = "paragraph";
|
|
2538
|
+
var Paragraph = React.forwardRef(function Paragraph2(props, ref) {
|
|
2539
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { ref, role: PARAGRAPH_ROLE, ...props });
|
|
2540
|
+
});
|
|
2541
|
+
function makeHeading(level) {
|
|
2542
|
+
const extra = { "aria-level": level };
|
|
2543
|
+
const Heading = React.forwardRef(function Heading2(props, ref) {
|
|
2544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { ref, accessibilityRole: "header", ...extra, ...props });
|
|
2545
|
+
});
|
|
2546
|
+
Heading.displayName = `H${level}`;
|
|
2547
|
+
return Heading;
|
|
2548
|
+
}
|
|
2549
|
+
var H1 = makeHeading(1);
|
|
2550
|
+
var H2 = makeHeading(2);
|
|
2551
|
+
var H3 = makeHeading(3);
|
|
2552
|
+
var H4 = makeHeading(4);
|
|
2553
|
+
var H5 = makeHeading(5);
|
|
2554
|
+
var H6 = makeHeading(6);
|
|
1811
2555
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1812
2556
|
0 && (module.exports = {
|
|
2557
|
+
Button,
|
|
2558
|
+
H1,
|
|
2559
|
+
H2,
|
|
2560
|
+
H3,
|
|
2561
|
+
H4,
|
|
2562
|
+
H5,
|
|
2563
|
+
H6,
|
|
2564
|
+
Paragraph,
|
|
1813
2565
|
ThemeProvider,
|
|
1814
2566
|
applyKbachConfig,
|
|
2567
|
+
clsx,
|
|
1815
2568
|
defaultTheme,
|
|
2569
|
+
deleteDynamicToken,
|
|
2570
|
+
getDynamicToken,
|
|
1816
2571
|
getGlobalDarkMode,
|
|
1817
2572
|
getGlobalThemeMode,
|
|
1818
2573
|
getTheme,
|
|
1819
2574
|
resolveKbachConfig,
|
|
1820
2575
|
resolveStyle,
|
|
2576
|
+
setDynamicToken,
|
|
1821
2577
|
setGlobalThemeMode,
|
|
1822
2578
|
setTheme,
|
|
2579
|
+
subscribeDynamicTokens,
|
|
1823
2580
|
subscribeGlobalDarkMode,
|
|
1824
2581
|
toggleGlobalDarkMode,
|
|
1825
2582
|
useColors,
|
|
2583
|
+
useDynamicToken,
|
|
1826
2584
|
useTheme
|
|
1827
2585
|
});
|