@kbach/react-native 1.0.0-beta.9 → 1.0.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 +495 -0
- package/LICENSE +21 -0
- package/README.md +198 -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-7CNURQSH.mjs +112 -0
- package/dist/{chunk-YOC3SHF5.mjs → chunk-HYQFT32E.mjs} +2 -2
- package/dist/chunk-MUPEQJRT.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 +1300 -610
- 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 +1532 -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 +1522 -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,
|
|
@@ -700,6 +548,7 @@ function decl(property, value) {
|
|
|
700
548
|
function spacingPx(theme, value) {
|
|
701
549
|
const fromTable = theme.spacing[value];
|
|
702
550
|
if (fromTable !== void 0) return fromTable;
|
|
551
|
+
if (value === "px") return 1;
|
|
703
552
|
const n = Number(value);
|
|
704
553
|
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
705
554
|
}
|
|
@@ -715,7 +564,10 @@ function resolveLength(theme, parsed) {
|
|
|
715
564
|
}
|
|
716
565
|
function resolveNegatableLength(theme, parsed) {
|
|
717
566
|
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
718
|
-
if (parsed.isArbitrary)
|
|
567
|
+
if (parsed.isArbitrary) {
|
|
568
|
+
const value2 = parsed.value;
|
|
569
|
+
return value2 === null ? null : `calc(${value2} * -1)`;
|
|
570
|
+
}
|
|
719
571
|
const value = parsed.value;
|
|
720
572
|
if (value === null) return null;
|
|
721
573
|
const px = spacingPx(theme, value);
|
|
@@ -723,11 +575,71 @@ function resolveNegatableLength(theme, parsed) {
|
|
|
723
575
|
if (px === 0) return "0px";
|
|
724
576
|
return `-${px}px`;
|
|
725
577
|
}
|
|
578
|
+
function fractionPercent(value) {
|
|
579
|
+
const slashIdx = value.indexOf("/");
|
|
580
|
+
if (slashIdx === -1) return null;
|
|
581
|
+
const numStr = value.slice(0, slashIdx);
|
|
582
|
+
const denStr = value.slice(slashIdx + 1);
|
|
583
|
+
const num = Number(numStr);
|
|
584
|
+
const den = Number(denStr);
|
|
585
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
586
|
+
if (den === 0) return null;
|
|
587
|
+
const pct = num / den * 100;
|
|
588
|
+
const formatted = pct.toFixed(6);
|
|
589
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
590
|
+
return `${trimmed}%`;
|
|
591
|
+
}
|
|
592
|
+
function resolveNegatableSize(theme, parsed) {
|
|
593
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
594
|
+
if (parsed.negative && parsed.value === "full") return "-100%";
|
|
595
|
+
const pct = fractionPercent(parsed.value);
|
|
596
|
+
if (pct !== null) return parsed.negative ? `-${pct}` : pct;
|
|
597
|
+
}
|
|
598
|
+
return resolveNegatableLength(theme, parsed);
|
|
599
|
+
}
|
|
600
|
+
function negate(value) {
|
|
601
|
+
const numeric = (v) => /^[\d.]/.test(v);
|
|
602
|
+
if (value.startsWith("-")) return numeric(value.slice(1)) ? value.slice(1) : `calc(${value} * -1)`;
|
|
603
|
+
return numeric(value) ? `-${value}` : `calc(${value} * -1)`;
|
|
604
|
+
}
|
|
605
|
+
function resolvePercent(parsed) {
|
|
606
|
+
if (parsed.negative) return null;
|
|
607
|
+
const value = parsed.value;
|
|
608
|
+
if (value === null) return null;
|
|
609
|
+
if (parsed.isArbitrary) return value;
|
|
610
|
+
const pct = Number(value);
|
|
611
|
+
if (!Number.isFinite(pct) || value.trim() === "") return null;
|
|
612
|
+
return String(pct / 100);
|
|
613
|
+
}
|
|
726
614
|
|
|
727
615
|
// src/jsEngine/resolvers/layout.ts
|
|
728
616
|
function negateRaw(value, negative) {
|
|
729
617
|
return negative ? `-${value}` : value;
|
|
730
618
|
}
|
|
619
|
+
var WHOLE = /^\d+$/;
|
|
620
|
+
var PLAIN_NUMBER = /^(?:\d+\.?\d*|\.\d+)$/;
|
|
621
|
+
function overflowAxisValue(property, value) {
|
|
622
|
+
switch (value) {
|
|
623
|
+
case "auto":
|
|
624
|
+
case "hidden":
|
|
625
|
+
case "clip":
|
|
626
|
+
case "visible":
|
|
627
|
+
case "scroll":
|
|
628
|
+
return [decl(property, value)];
|
|
629
|
+
default:
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
function overscrollValue(property, value) {
|
|
634
|
+
switch (value) {
|
|
635
|
+
case "auto":
|
|
636
|
+
case "contain":
|
|
637
|
+
case "none":
|
|
638
|
+
return [decl(property, value)];
|
|
639
|
+
default:
|
|
640
|
+
return null;
|
|
641
|
+
}
|
|
642
|
+
}
|
|
731
643
|
function resolve(parsed, theme) {
|
|
732
644
|
switch (parsed.utility) {
|
|
733
645
|
case "flex":
|
|
@@ -774,6 +686,12 @@ function resolve(parsed, theme) {
|
|
|
774
686
|
return [decl("justify-content", "space-around")];
|
|
775
687
|
case "justify-evenly":
|
|
776
688
|
return [decl("justify-content", "space-evenly")];
|
|
689
|
+
case "justify-normal":
|
|
690
|
+
return [decl("justify-content", "normal")];
|
|
691
|
+
case "justify-stretch":
|
|
692
|
+
return [decl("justify-content", "stretch")];
|
|
693
|
+
case "content-normal":
|
|
694
|
+
return [decl("align-content", "normal")];
|
|
777
695
|
case "content-start":
|
|
778
696
|
return [decl("align-content", "flex-start")];
|
|
779
697
|
case "content-end":
|
|
@@ -808,6 +726,18 @@ function resolve(parsed, theme) {
|
|
|
808
726
|
return [decl("overflow", "scroll")];
|
|
809
727
|
case "overflow-visible":
|
|
810
728
|
return [decl("overflow", "visible")];
|
|
729
|
+
case "overflow-clip":
|
|
730
|
+
return [decl("overflow", "clip")];
|
|
731
|
+
case "overflow-x":
|
|
732
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-x", parsed.value);
|
|
733
|
+
case "overflow-y":
|
|
734
|
+
return parsed.value === null ? null : overflowAxisValue("overflow-y", parsed.value);
|
|
735
|
+
case "overscroll":
|
|
736
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior", parsed.value);
|
|
737
|
+
case "overscroll-x":
|
|
738
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-x", parsed.value);
|
|
739
|
+
case "overscroll-y":
|
|
740
|
+
return parsed.value === null ? null : overscrollValue("overscroll-behavior-y", parsed.value);
|
|
811
741
|
case "static":
|
|
812
742
|
return [decl("position", "static")];
|
|
813
743
|
case "relative":
|
|
@@ -818,40 +748,91 @@ function resolve(parsed, theme) {
|
|
|
818
748
|
return [decl("position", "fixed")];
|
|
819
749
|
case "sticky":
|
|
820
750
|
return [decl("position", "sticky")];
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
751
|
+
// Only real values, mirroring layout.rs: a whole number, z-auto, the
|
|
752
|
+
// order-first/-last/-none keywords, or an arbitrary [...]. Anything
|
|
753
|
+
// else used to pass straight through (z-banana -> z-index: banana).
|
|
754
|
+
case "z": {
|
|
755
|
+
const v = parsed.value;
|
|
756
|
+
if (v === null || !(parsed.isArbitrary || v === "auto" || WHOLE.test(v))) return null;
|
|
757
|
+
return [decl("z-index", negateRaw(v, parsed.negative))];
|
|
758
|
+
}
|
|
759
|
+
case "order": {
|
|
760
|
+
const v = parsed.value;
|
|
761
|
+
if (v === null) return null;
|
|
762
|
+
if (v === "first") return [decl("order", "-9999")];
|
|
763
|
+
if (v === "last") return [decl("order", "9999")];
|
|
764
|
+
if (v === "none") return [decl("order", "0")];
|
|
765
|
+
if (!(parsed.isArbitrary || WHOLE.test(v))) return null;
|
|
766
|
+
return [decl("order", negateRaw(v, parsed.negative))];
|
|
767
|
+
}
|
|
825
768
|
case "grow":
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
769
|
+
case "shrink": {
|
|
770
|
+
const v = parsed.value ?? "1";
|
|
771
|
+
if (!(parsed.isArbitrary || PLAIN_NUMBER.test(v))) return null;
|
|
772
|
+
return [decl(parsed.utility === "grow" ? "flex-grow" : "flex-shrink", v)];
|
|
773
|
+
}
|
|
829
774
|
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
830
|
-
// convention ("-top-4")
|
|
775
|
+
// convention ("-top-4") AND its percentage-fraction scale ("top-1/2",
|
|
776
|
+
// "-inset-1/3") — see resolveNegatableSize's own doc comment.
|
|
831
777
|
case "top": {
|
|
832
|
-
const v =
|
|
778
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
833
779
|
return v === null ? null : [decl("top", v)];
|
|
834
780
|
}
|
|
835
781
|
case "right": {
|
|
836
|
-
const v =
|
|
782
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
837
783
|
return v === null ? null : [decl("right", v)];
|
|
838
784
|
}
|
|
839
785
|
case "bottom": {
|
|
840
|
-
const v =
|
|
786
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
841
787
|
return v === null ? null : [decl("bottom", v)];
|
|
842
788
|
}
|
|
843
789
|
case "left": {
|
|
844
|
-
const v =
|
|
790
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
845
791
|
return v === null ? null : [decl("left", v)];
|
|
846
792
|
}
|
|
847
793
|
case "inset": {
|
|
848
|
-
const v =
|
|
794
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
849
795
|
return v === null ? null : [decl("inset", v)];
|
|
850
796
|
}
|
|
851
|
-
case "
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
797
|
+
case "inset-x": {
|
|
798
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
799
|
+
return v === null ? null : [decl("left", v), decl("right", v)];
|
|
800
|
+
}
|
|
801
|
+
case "inset-y": {
|
|
802
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
803
|
+
return v === null ? null : [decl("top", v), decl("bottom", v)];
|
|
804
|
+
}
|
|
805
|
+
// Logical inset — just a different CSS property name, same reasoning
|
|
806
|
+
// as Rust's layout.rs (no direction-tracking logic needed here).
|
|
807
|
+
case "start": {
|
|
808
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
809
|
+
return v === null ? null : [decl("inset-inline-start", v)];
|
|
810
|
+
}
|
|
811
|
+
case "end": {
|
|
812
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
813
|
+
return v === null ? null : [decl("inset-inline-end", v)];
|
|
814
|
+
}
|
|
815
|
+
// "aspect-" is a registered VALUE_PREFIXES entry (parser.ts), so
|
|
816
|
+
// "aspect-square"/"aspect-video"/"aspect-auto"/arbitrary all arrive
|
|
817
|
+
// here as utility="aspect" + a value, mirroring layout.rs's own
|
|
818
|
+
// "aspect" arm.
|
|
819
|
+
case "aspect": {
|
|
820
|
+
const value = parsed.value;
|
|
821
|
+
if (value === null) return null;
|
|
822
|
+
if (parsed.isArbitrary) return [decl("aspect-ratio", value)];
|
|
823
|
+
switch (value) {
|
|
824
|
+
case "square":
|
|
825
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
826
|
+
case "video":
|
|
827
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
828
|
+
case "auto":
|
|
829
|
+
return [decl("aspect-ratio", "auto")];
|
|
830
|
+
default: {
|
|
831
|
+
const m = /^(\d+(?:\.\d*)?|\.\d+)\/(\d+(?:\.\d*)?|\.\d+)$/.exec(value);
|
|
832
|
+
return m ? [decl("aspect-ratio", `${m[1]} / ${m[2]}`)] : null;
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
855
836
|
default:
|
|
856
837
|
return null;
|
|
857
838
|
}
|
|
@@ -893,7 +874,7 @@ function resolveFlex(parsed, web) {
|
|
|
893
874
|
case "shrink-0":
|
|
894
875
|
return [decl("flex-shrink", "0")];
|
|
895
876
|
default:
|
|
896
|
-
return null;
|
|
877
|
+
return /^\d+$/.test(value) ? [decl("flex", value)] : null;
|
|
897
878
|
}
|
|
898
879
|
}
|
|
899
880
|
|
|
@@ -928,20 +909,6 @@ function namedSize(key) {
|
|
|
928
909
|
return null;
|
|
929
910
|
}
|
|
930
911
|
}
|
|
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
912
|
function cssSizeKeyword(key) {
|
|
946
913
|
switch (key) {
|
|
947
914
|
case "min":
|
|
@@ -1080,14 +1047,94 @@ function lookupHex(theme, key) {
|
|
|
1080
1047
|
const entry = theme.colors[key];
|
|
1081
1048
|
return typeof entry === "string" ? entry : null;
|
|
1082
1049
|
}
|
|
1050
|
+
var MODE_AWARE_COLOR_PREFIXES = ["bg-", "text-", "border-"];
|
|
1051
|
+
function findModeAwareColor(base, theme) {
|
|
1052
|
+
const important = base.startsWith("!") ? "!" : "";
|
|
1053
|
+
const rest = important ? base.slice(1) : base;
|
|
1054
|
+
for (const prefix of MODE_AWARE_COLOR_PREFIXES) {
|
|
1055
|
+
if (!rest.startsWith(prefix)) continue;
|
|
1056
|
+
const [name, opacity] = splitOpacity(rest.slice(prefix.length));
|
|
1057
|
+
const entry = theme.colors[name];
|
|
1058
|
+
if (typeof entry === "object" && entry !== null) {
|
|
1059
|
+
return { prefix: `${important}${prefix}`, opacity, light: entry.light, dark: entry.dark };
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
return null;
|
|
1063
|
+
}
|
|
1064
|
+
function applyOpacityToHex(hex, opacity) {
|
|
1065
|
+
if (opacity === null) return hex;
|
|
1066
|
+
if (hexToRgb(hex) === null) return hex;
|
|
1067
|
+
return colorWithOpacity(hex.trim(), opacity).replace(/ /g, "_");
|
|
1068
|
+
}
|
|
1069
|
+
function substituteModeAwareColorToken(token, theme, colorScheme) {
|
|
1070
|
+
const segments = token.split(":");
|
|
1071
|
+
const base = segments.pop() ?? token;
|
|
1072
|
+
const modifierPrefix = segments.length > 0 ? `${segments.join(":")}:` : "";
|
|
1073
|
+
const found = findModeAwareColor(base, theme);
|
|
1074
|
+
if (found === null) return token;
|
|
1075
|
+
const hex = colorScheme === "dark" ? found.dark : found.light;
|
|
1076
|
+
return `${modifierPrefix}${found.prefix}[${applyOpacityToHex(hex, found.opacity)}]`;
|
|
1077
|
+
}
|
|
1078
|
+
function hexToRgb(hex) {
|
|
1079
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1080
|
+
if (!m) return null;
|
|
1081
|
+
let h = m[1];
|
|
1082
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
1083
|
+
const n = parseInt(h, 16);
|
|
1084
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1085
|
+
}
|
|
1086
|
+
function splitOpacity(value) {
|
|
1087
|
+
const slash = value.indexOf("/");
|
|
1088
|
+
if (slash === -1) return [value, null];
|
|
1089
|
+
const alpha = parseAlpha(value.slice(slash + 1));
|
|
1090
|
+
return alpha === null ? [value, null] : [value.slice(0, slash), alpha];
|
|
1091
|
+
}
|
|
1092
|
+
function colorValue(theme, parsed) {
|
|
1093
|
+
const value = parsed.value;
|
|
1094
|
+
if (value === null) return null;
|
|
1095
|
+
if (parsed.isArbitrary) return value;
|
|
1096
|
+
const [name, opacity] = splitOpacity(value);
|
|
1097
|
+
const hex = lookupHex(theme, name);
|
|
1098
|
+
if (hex === null) return null;
|
|
1099
|
+
return opacity === null ? hex : colorWithOpacity(hex, opacity);
|
|
1100
|
+
}
|
|
1101
|
+
var LENGTH_UNITS = ["px", "rem", "em", "%", "vh", "vw"];
|
|
1102
|
+
function looksLikeLength(value) {
|
|
1103
|
+
const unit = LENGTH_UNITS.find((u) => value.endsWith(u));
|
|
1104
|
+
const withoutUnit = unit ? value.slice(0, value.length - unit.length) : value;
|
|
1105
|
+
if (withoutUnit !== "" && Number.isFinite(Number(withoutUnit))) return true;
|
|
1106
|
+
if (!["calc(", "clamp(", "min(", "max("].some((f) => value.startsWith(f))) return false;
|
|
1107
|
+
return MATH_LENGTH_UNIT.test(value);
|
|
1108
|
+
}
|
|
1109
|
+
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])/;
|
|
1110
|
+
function isLength(parsed, value) {
|
|
1111
|
+
switch (parsed.typeHint ?? null) {
|
|
1112
|
+
case null:
|
|
1113
|
+
return looksLikeLength(value);
|
|
1114
|
+
case "length":
|
|
1115
|
+
case "size":
|
|
1116
|
+
case "line-width":
|
|
1117
|
+
case "percentage":
|
|
1118
|
+
case "number":
|
|
1119
|
+
case "integer":
|
|
1120
|
+
case "absolute-size":
|
|
1121
|
+
case "relative-size":
|
|
1122
|
+
return true;
|
|
1123
|
+
default:
|
|
1124
|
+
return false;
|
|
1125
|
+
}
|
|
1126
|
+
}
|
|
1083
1127
|
|
|
1084
1128
|
// src/jsEngine/resolvers/border.ts
|
|
1085
1129
|
function radiusSize(key) {
|
|
1086
1130
|
switch (key) {
|
|
1087
1131
|
case "none":
|
|
1088
1132
|
return "0px";
|
|
1089
|
-
|
|
1133
|
+
// Tailwind v4.3's radius scale: `sm` is 0.25rem (v3's 0.125rem is `xs`).
|
|
1134
|
+
case "xs":
|
|
1090
1135
|
return "0.125rem";
|
|
1136
|
+
case "sm":
|
|
1137
|
+
return "0.25rem";
|
|
1091
1138
|
case "md":
|
|
1092
1139
|
return "0.375rem";
|
|
1093
1140
|
case "lg":
|
|
@@ -1098,12 +1145,19 @@ function radiusSize(key) {
|
|
|
1098
1145
|
return "1rem";
|
|
1099
1146
|
case "3xl":
|
|
1100
1147
|
return "1.5rem";
|
|
1148
|
+
case "4xl":
|
|
1149
|
+
return "2rem";
|
|
1101
1150
|
case "full":
|
|
1102
1151
|
return "9999px";
|
|
1103
1152
|
default:
|
|
1104
1153
|
return null;
|
|
1105
1154
|
}
|
|
1106
1155
|
}
|
|
1156
|
+
function borderWidthPx(parsed) {
|
|
1157
|
+
if (parsed.negative || parsed.isArbitrary || parsed.value === null) return null;
|
|
1158
|
+
const n = Number(parsed.value);
|
|
1159
|
+
return Number.isFinite(n) && n >= 0 && parsed.value.trim() !== "" ? `${n}px` : null;
|
|
1160
|
+
}
|
|
1107
1161
|
function borderSideProperty(side) {
|
|
1108
1162
|
switch (side) {
|
|
1109
1163
|
case "t":
|
|
@@ -1126,49 +1180,68 @@ function borderValue(theme, parsed) {
|
|
|
1126
1180
|
if (side !== null) {
|
|
1127
1181
|
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1128
1182
|
}
|
|
1183
|
+
const pair = value === "x" ? ["border-left", "border-right"] : value === "y" ? ["border-top", "border-bottom"] : null;
|
|
1184
|
+
if (pair !== null) {
|
|
1185
|
+
return [
|
|
1186
|
+
decl(`${pair[0]}-width`, "1px"),
|
|
1187
|
+
decl(`${pair[1]}-width`, "1px"),
|
|
1188
|
+
decl(`${pair[0]}-style`, "solid"),
|
|
1189
|
+
decl(`${pair[1]}-style`, "solid")
|
|
1190
|
+
];
|
|
1191
|
+
}
|
|
1129
1192
|
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1130
1193
|
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1131
1194
|
}
|
|
1132
1195
|
if (parsed.isArbitrary) {
|
|
1133
|
-
return [decl("border-width", value)];
|
|
1196
|
+
if (isLength(parsed, value)) return [decl("border-width", value)];
|
|
1197
|
+
const color2 = colorValue(theme, parsed);
|
|
1198
|
+
return color2 === null ? null : [decl("border-color", color2)];
|
|
1134
1199
|
}
|
|
1135
1200
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1136
|
-
const v =
|
|
1201
|
+
const v = borderWidthPx(parsed);
|
|
1137
1202
|
return v === null ? null : [decl("border-width", v)];
|
|
1138
1203
|
}
|
|
1139
1204
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1140
1205
|
return [decl("border-style", value)];
|
|
1141
1206
|
}
|
|
1142
|
-
const
|
|
1143
|
-
return
|
|
1207
|
+
const color = colorValue(theme, parsed);
|
|
1208
|
+
return color === null ? null : [decl("border-color", color)];
|
|
1144
1209
|
}
|
|
1145
1210
|
function borderSideValue(theme, parsed, sideProperty) {
|
|
1146
1211
|
const value = parsed.value;
|
|
1147
1212
|
if (value === null) return null;
|
|
1148
|
-
if (parsed.isArbitrary)
|
|
1213
|
+
if (parsed.isArbitrary) {
|
|
1214
|
+
if (isLength(parsed, value)) return [decl(`${sideProperty}-width`, value)];
|
|
1215
|
+
const color2 = colorValue(theme, parsed);
|
|
1216
|
+
return color2 === null ? null : [decl(`${sideProperty}-color`, color2)];
|
|
1217
|
+
}
|
|
1149
1218
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1150
|
-
const v =
|
|
1219
|
+
const v = borderWidthPx(parsed);
|
|
1151
1220
|
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1152
1221
|
}
|
|
1153
1222
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1154
1223
|
return [decl(`${sideProperty}-style`, value)];
|
|
1155
1224
|
}
|
|
1156
|
-
const
|
|
1157
|
-
return
|
|
1225
|
+
const color = colorValue(theme, parsed);
|
|
1226
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
1158
1227
|
}
|
|
1159
1228
|
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1160
1229
|
const value = parsed.value;
|
|
1161
1230
|
if (value === null) return null;
|
|
1162
|
-
if (parsed.isArbitrary)
|
|
1231
|
+
if (parsed.isArbitrary) {
|
|
1232
|
+
if (isLength(parsed, value)) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1233
|
+
const color2 = colorValue(theme, parsed);
|
|
1234
|
+
return color2 === null ? null : [decl(`${sideA}-color`, color2), decl(`${sideB}-color`, color2)];
|
|
1235
|
+
}
|
|
1163
1236
|
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1164
|
-
const v =
|
|
1237
|
+
const v = borderWidthPx(parsed);
|
|
1165
1238
|
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1166
1239
|
}
|
|
1167
1240
|
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1168
1241
|
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1169
1242
|
}
|
|
1170
|
-
const
|
|
1171
|
-
return
|
|
1243
|
+
const color = colorValue(theme, parsed);
|
|
1244
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1172
1245
|
}
|
|
1173
1246
|
function radiusProperties(side) {
|
|
1174
1247
|
switch (side) {
|
|
@@ -1208,79 +1281,28 @@ function resolveRadiusSide(theme, parsed, side) {
|
|
|
1208
1281
|
}
|
|
1209
1282
|
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1210
1283
|
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
|
-
}
|
|
1284
|
+
return /^\d+$/.test(key) ? `${Number(key)}px` : null;
|
|
1225
1285
|
}
|
|
1226
1286
|
function outlineValue(theme, parsed) {
|
|
1227
1287
|
const value = parsed.value;
|
|
1228
1288
|
if (value === null) return null;
|
|
1229
|
-
if (parsed.isArbitrary)
|
|
1289
|
+
if (parsed.isArbitrary) {
|
|
1290
|
+
if (isLength(parsed, value)) return [decl("outline-width", value)];
|
|
1291
|
+
const color2 = colorValue(theme, parsed);
|
|
1292
|
+
return color2 === null ? null : [decl("outline-color", color2)];
|
|
1293
|
+
}
|
|
1230
1294
|
const w = outlineWidthValue(value);
|
|
1231
1295
|
if (w !== null) return [decl("outline-width", w)];
|
|
1232
1296
|
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1233
|
-
const
|
|
1234
|
-
return
|
|
1297
|
+
const color = colorValue(theme, parsed);
|
|
1298
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1235
1299
|
}
|
|
1236
1300
|
function outlineOffsetValue(parsed) {
|
|
1237
1301
|
const value = parsed.value;
|
|
1238
1302
|
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)];
|
|
1303
|
+
const v = parsed.isArbitrary ? value : outlineWidthValue(value);
|
|
1304
|
+
if (v === null) return null;
|
|
1305
|
+
return [decl("outline-offset", parsed.negative ? negate(v) : v)];
|
|
1284
1306
|
}
|
|
1285
1307
|
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1286
1308
|
function resolve3(parsed, theme) {
|
|
@@ -1310,14 +1332,19 @@ function resolve3(parsed, theme) {
|
|
|
1310
1332
|
const v = resolveLength(theme, parsed);
|
|
1311
1333
|
return v === null ? null : [decl("border-radius", v)];
|
|
1312
1334
|
}
|
|
1335
|
+
// Rings are web-only (a var()-composed CSS box-shadow React Native can't
|
|
1336
|
+
// parse) — same as resolvers/mod.rs's native dispatcher.
|
|
1313
1337
|
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
1338
|
case "ring-offset":
|
|
1317
|
-
return
|
|
1339
|
+
return null;
|
|
1340
|
+
// Outlines: the same final native style the Rust engine produces once
|
|
1341
|
+
// its var()-based web declarations are filtered out (resolve_style.rs):
|
|
1342
|
+
// bare `outline` is a 1px width, `outline-none` is outline-style: none,
|
|
1343
|
+
// `outline-hidden` keeps only its offset (RN has no `outline` shorthand).
|
|
1318
1344
|
case "outline":
|
|
1319
|
-
if (parsed.value === null) return [decl("outline-
|
|
1320
|
-
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1345
|
+
if (parsed.value === null) return [decl("outline-width", "1px")];
|
|
1346
|
+
if (parsed.value === "none") return [decl("outline-style", "none")];
|
|
1347
|
+
if (!parsed.isArbitrary && parsed.value === "hidden") return [decl("outline-offset", "2px")];
|
|
1321
1348
|
return outlineValue(theme, parsed);
|
|
1322
1349
|
case "outline-offset":
|
|
1323
1350
|
return outlineOffsetValue(parsed);
|
|
@@ -1348,32 +1375,75 @@ function textSize(key) {
|
|
|
1348
1375
|
return "1.875rem";
|
|
1349
1376
|
case "4xl":
|
|
1350
1377
|
return "2.25rem";
|
|
1378
|
+
case "5xl":
|
|
1379
|
+
return "3rem";
|
|
1380
|
+
case "6xl":
|
|
1381
|
+
return "3.75rem";
|
|
1382
|
+
case "7xl":
|
|
1383
|
+
return "4.5rem";
|
|
1384
|
+
case "8xl":
|
|
1385
|
+
return "6rem";
|
|
1386
|
+
case "9xl":
|
|
1387
|
+
return "8rem";
|
|
1351
1388
|
default:
|
|
1352
1389
|
return null;
|
|
1353
1390
|
}
|
|
1354
1391
|
}
|
|
1355
1392
|
function lineHeightSize(key) {
|
|
1393
|
+
if (key === "px") return "1px";
|
|
1394
|
+
if (key.trim() === "") return null;
|
|
1395
|
+
const n = Number(key);
|
|
1396
|
+
return Number.isFinite(n) && n >= 0 ? `${n * 0.25}rem` : null;
|
|
1397
|
+
}
|
|
1398
|
+
function leadingNamed(key) {
|
|
1356
1399
|
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";
|
|
1400
|
+
case "none":
|
|
1401
|
+
return 1;
|
|
1402
|
+
case "tight":
|
|
1403
|
+
return 1.25;
|
|
1404
|
+
case "snug":
|
|
1405
|
+
return 1.375;
|
|
1406
|
+
case "normal":
|
|
1407
|
+
return 1.5;
|
|
1408
|
+
case "relaxed":
|
|
1409
|
+
return 1.625;
|
|
1410
|
+
case "loose":
|
|
1411
|
+
return 2;
|
|
1373
1412
|
default:
|
|
1374
1413
|
return null;
|
|
1375
1414
|
}
|
|
1376
1415
|
}
|
|
1416
|
+
function splitSizeLeading(value) {
|
|
1417
|
+
const i = value.indexOf("/");
|
|
1418
|
+
if (i === -1) return null;
|
|
1419
|
+
const size = textSize(value.slice(0, i));
|
|
1420
|
+
const leading = value.slice(i + 1);
|
|
1421
|
+
return size === null || leading === "" ? null : [size, leading];
|
|
1422
|
+
}
|
|
1423
|
+
function sizeLeadingNative(size, leading) {
|
|
1424
|
+
const rem = (n) => {
|
|
1425
|
+
const unit = size.endsWith("rem") ? "rem" : size.endsWith("px") ? "px" : null;
|
|
1426
|
+
if (unit === null) return null;
|
|
1427
|
+
const number = size.slice(0, -unit.length);
|
|
1428
|
+
const s = Number(number);
|
|
1429
|
+
return number.trim() !== "" && Number.isFinite(s) ? `${s * n}${unit}` : null;
|
|
1430
|
+
};
|
|
1431
|
+
const arbitrary = arbitraryModifier(leading);
|
|
1432
|
+
if (arbitrary !== null) {
|
|
1433
|
+
if (arbitrary.startsWith("var(")) return null;
|
|
1434
|
+
const n = Number(arbitrary);
|
|
1435
|
+
return arbitrary.trim() !== "" && Number.isFinite(n) ? rem(n) : arbitrary;
|
|
1436
|
+
}
|
|
1437
|
+
const scale = lineHeightSize(leading);
|
|
1438
|
+
if (scale !== null) return scale;
|
|
1439
|
+
const m = leadingNamed(leading);
|
|
1440
|
+
return m === null ? null : rem(m);
|
|
1441
|
+
}
|
|
1442
|
+
function arbitraryFontIsWeight(parsed, value) {
|
|
1443
|
+
const hint = parsed.typeHint ?? null;
|
|
1444
|
+
if (hint !== null) return hint === "number" || hint === "integer";
|
|
1445
|
+
return value.trim() !== "" && Number.isFinite(Number(value)) || value.startsWith("var(") && value.endsWith(")") && !value.includes(",");
|
|
1446
|
+
}
|
|
1377
1447
|
function textAlign(key) {
|
|
1378
1448
|
switch (key) {
|
|
1379
1449
|
case "left":
|
|
@@ -1384,6 +1454,12 @@ function textAlign(key) {
|
|
|
1384
1454
|
return "right";
|
|
1385
1455
|
case "justify":
|
|
1386
1456
|
return "justify";
|
|
1457
|
+
// Logical alignment — same "no direction-tracking logic needed" reasoning
|
|
1458
|
+
// as layout.rs's start/end inset properties.
|
|
1459
|
+
case "start":
|
|
1460
|
+
return "start";
|
|
1461
|
+
case "end":
|
|
1462
|
+
return "end";
|
|
1387
1463
|
default:
|
|
1388
1464
|
return null;
|
|
1389
1465
|
}
|
|
@@ -1392,6 +1468,10 @@ function fontWeight(key) {
|
|
|
1392
1468
|
switch (key) {
|
|
1393
1469
|
case "thin":
|
|
1394
1470
|
return "100";
|
|
1471
|
+
case "extralight":
|
|
1472
|
+
return "200";
|
|
1473
|
+
case "light":
|
|
1474
|
+
return "300";
|
|
1395
1475
|
case "normal":
|
|
1396
1476
|
return "400";
|
|
1397
1477
|
case "medium":
|
|
@@ -1402,6 +1482,22 @@ function fontWeight(key) {
|
|
|
1402
1482
|
return "700";
|
|
1403
1483
|
case "extrabold":
|
|
1404
1484
|
return "800";
|
|
1485
|
+
case "black":
|
|
1486
|
+
return "900";
|
|
1487
|
+
default:
|
|
1488
|
+
return null;
|
|
1489
|
+
}
|
|
1490
|
+
}
|
|
1491
|
+
function fontFamilyValue(theme, key) {
|
|
1492
|
+
const fromTheme = theme.fontFamily?.[key];
|
|
1493
|
+
if (fromTheme !== void 0) return fromTheme;
|
|
1494
|
+
switch (key) {
|
|
1495
|
+
case "sans":
|
|
1496
|
+
return 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"';
|
|
1497
|
+
case "serif":
|
|
1498
|
+
return 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif';
|
|
1499
|
+
case "mono":
|
|
1500
|
+
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
1405
1501
|
default:
|
|
1406
1502
|
return null;
|
|
1407
1503
|
}
|
|
@@ -1410,8 +1506,14 @@ function fontWeight(key) {
|
|
|
1410
1506
|
// src/jsEngine/resolvers/effects.ts
|
|
1411
1507
|
function nativeShadowValue(key) {
|
|
1412
1508
|
switch (key) {
|
|
1413
|
-
|
|
1509
|
+
// Tailwind v4.3's scale, like effects.rs: `sm` is the default shadow,
|
|
1510
|
+
// v3's `sm` is `xs`.
|
|
1511
|
+
case "2xs":
|
|
1512
|
+
return { offsetY: 1, radius: 0, opacity: 0.05, elevation: 1 };
|
|
1513
|
+
case "xs":
|
|
1414
1514
|
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1515
|
+
case "sm":
|
|
1516
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1415
1517
|
case "DEFAULT":
|
|
1416
1518
|
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1417
1519
|
case "md":
|
|
@@ -1443,13 +1545,115 @@ function nativeShadowDeclarations(parsed) {
|
|
|
1443
1545
|
];
|
|
1444
1546
|
}
|
|
1445
1547
|
|
|
1548
|
+
// src/jsEngine/resolvers/transform.ts
|
|
1549
|
+
function scaleFactor(parsed) {
|
|
1550
|
+
if (parsed.value === null || parsed.value.trim() === "") return null;
|
|
1551
|
+
const n = Number(parsed.value);
|
|
1552
|
+
if (!Number.isFinite(n)) return null;
|
|
1553
|
+
const factor = parsed.isArbitrary ? n : n / 100;
|
|
1554
|
+
return parsed.negative ? -factor : factor;
|
|
1555
|
+
}
|
|
1556
|
+
function angle(parsed) {
|
|
1557
|
+
if (parsed.value === null) return null;
|
|
1558
|
+
if (parsed.isArbitrary) {
|
|
1559
|
+
if (!parsed.negative) return parsed.value;
|
|
1560
|
+
if (parsed.value.startsWith("-")) return parsed.value.slice(1);
|
|
1561
|
+
if (/^[\d.]/.test(parsed.value)) return `-${parsed.value}`;
|
|
1562
|
+
return `calc(${parsed.value} * -1)`;
|
|
1563
|
+
}
|
|
1564
|
+
const n = Number(parsed.value);
|
|
1565
|
+
if (!Number.isFinite(n)) return null;
|
|
1566
|
+
return `${parsed.negative ? -n : n}deg`;
|
|
1567
|
+
}
|
|
1568
|
+
function resolveNative(parsed, theme) {
|
|
1569
|
+
switch (parsed.utility) {
|
|
1570
|
+
case "transform-none":
|
|
1571
|
+
return [decl("transform-op-none", "1")];
|
|
1572
|
+
// Both axes at once (`translate-4`, `-skew-3`); mirrors transform.rs.
|
|
1573
|
+
case "translate": {
|
|
1574
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-translate-x", "0"), decl("transform-op-translate-y", "0")];
|
|
1575
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1576
|
+
return v === null ? null : [decl("transform-op-translate-x", v), decl("transform-op-translate-y", v)];
|
|
1577
|
+
}
|
|
1578
|
+
case "skew": {
|
|
1579
|
+
const deg = angle(parsed);
|
|
1580
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg), decl("transform-op-skew-y", deg)];
|
|
1581
|
+
}
|
|
1582
|
+
case "backface-visible":
|
|
1583
|
+
return [decl("backface-visibility", "visible")];
|
|
1584
|
+
case "backface-hidden":
|
|
1585
|
+
return [decl("backface-visibility", "hidden")];
|
|
1586
|
+
case "translate-x": {
|
|
1587
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1588
|
+
return v === null ? null : [decl("transform-op-translate-x", v)];
|
|
1589
|
+
}
|
|
1590
|
+
case "translate-y": {
|
|
1591
|
+
const v = resolveNegatableSize(theme, parsed);
|
|
1592
|
+
return v === null ? null : [decl("transform-op-translate-y", v)];
|
|
1593
|
+
}
|
|
1594
|
+
case "scale": {
|
|
1595
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-scale-x", "1"), decl("transform-op-scale-y", "1")];
|
|
1596
|
+
const n = scaleFactor(parsed);
|
|
1597
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`), decl("transform-op-scale-y", `${n}`)];
|
|
1598
|
+
}
|
|
1599
|
+
case "scale-x": {
|
|
1600
|
+
const n = scaleFactor(parsed);
|
|
1601
|
+
return n === null ? null : [decl("transform-op-scale-x", `${n}`)];
|
|
1602
|
+
}
|
|
1603
|
+
case "scale-y": {
|
|
1604
|
+
const n = scaleFactor(parsed);
|
|
1605
|
+
return n === null ? null : [decl("transform-op-scale-y", `${n}`)];
|
|
1606
|
+
}
|
|
1607
|
+
case "rotate": {
|
|
1608
|
+
if (!parsed.isArbitrary && parsed.value === "none") return [decl("transform-op-rotate", "0deg")];
|
|
1609
|
+
const deg = angle(parsed);
|
|
1610
|
+
return deg === null ? null : [decl("transform-op-rotate", deg)];
|
|
1611
|
+
}
|
|
1612
|
+
case "rotate-x": {
|
|
1613
|
+
const deg = angle(parsed);
|
|
1614
|
+
return deg === null ? null : [decl("transform-op-rotate-x", deg)];
|
|
1615
|
+
}
|
|
1616
|
+
case "rotate-y": {
|
|
1617
|
+
const deg = angle(parsed);
|
|
1618
|
+
return deg === null ? null : [decl("transform-op-rotate-y", deg)];
|
|
1619
|
+
}
|
|
1620
|
+
case "rotate-z": {
|
|
1621
|
+
const deg = angle(parsed);
|
|
1622
|
+
return deg === null ? null : [decl("transform-op-rotate-z", deg)];
|
|
1623
|
+
}
|
|
1624
|
+
case "skew-x": {
|
|
1625
|
+
const deg = angle(parsed);
|
|
1626
|
+
return deg === null ? null : [decl("transform-op-skew-x", deg)];
|
|
1627
|
+
}
|
|
1628
|
+
case "skew-y": {
|
|
1629
|
+
const deg = angle(parsed);
|
|
1630
|
+
return deg === null ? null : [decl("transform-op-skew-y", deg)];
|
|
1631
|
+
}
|
|
1632
|
+
default:
|
|
1633
|
+
return null;
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1446
1637
|
// src/jsEngine/resolveUtilityNative.ts
|
|
1447
|
-
function
|
|
1638
|
+
function firstFontName(stack) {
|
|
1639
|
+
const first = stack.split(",")[0] ?? stack;
|
|
1640
|
+
return first.trim().replace(/^["']|["']$/g, "");
|
|
1641
|
+
}
|
|
1642
|
+
function resolveTypographyNative(parsed, theme) {
|
|
1448
1643
|
switch (parsed.utility) {
|
|
1449
1644
|
case "font": {
|
|
1450
1645
|
if (parsed.value === null) return null;
|
|
1646
|
+
if (parsed.isArbitrary) {
|
|
1647
|
+
if (arbitraryFontIsWeight(parsed, parsed.value)) {
|
|
1648
|
+
const n = Number(parsed.value);
|
|
1649
|
+
return /^\d+$/.test(parsed.value) && n % 100 === 0 && n >= 100 && n <= 900 ? [decl("font-weight", parsed.value)] : null;
|
|
1650
|
+
}
|
|
1651
|
+
return [decl("font-family", firstFontName(parsed.value))];
|
|
1652
|
+
}
|
|
1451
1653
|
const w = fontWeight(parsed.value);
|
|
1452
|
-
|
|
1654
|
+
if (w !== null) return [decl("font-weight", w)];
|
|
1655
|
+
const family = fontFamilyValue(theme, parsed.value);
|
|
1656
|
+
return family === null ? null : [decl("font-family", firstFontName(family))];
|
|
1453
1657
|
}
|
|
1454
1658
|
case "uppercase":
|
|
1455
1659
|
return [decl("text-transform", "uppercase")];
|
|
@@ -1485,16 +1689,27 @@ function resolveLeadingTrackingNative(parsed) {
|
|
|
1485
1689
|
return null;
|
|
1486
1690
|
}
|
|
1487
1691
|
function nativeHexColor(parsed, theme) {
|
|
1488
|
-
|
|
1489
|
-
if (value === null) return null;
|
|
1490
|
-
return parsed.isArbitrary ? value : lookupHex(theme, value);
|
|
1692
|
+
return colorValue(theme, parsed);
|
|
1491
1693
|
}
|
|
1492
1694
|
function resolveTextNative(parsed, theme) {
|
|
1493
1695
|
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1494
1696
|
const size = textSize(parsed.value);
|
|
1495
1697
|
if (size !== null) return [decl("font-size", size)];
|
|
1698
|
+
const sized = splitSizeLeading(parsed.value);
|
|
1699
|
+
if (sized !== null) {
|
|
1700
|
+
const lh = sizeLeadingNative(sized[0], sized[1]);
|
|
1701
|
+
return lh === null ? null : [decl("font-size", sized[0]), decl("line-height", lh)];
|
|
1702
|
+
}
|
|
1496
1703
|
const align = textAlign(parsed.value);
|
|
1497
1704
|
if (align !== null) return [decl("text-align", align)];
|
|
1705
|
+
} else if (parsed.isArbitrary && parsed.value !== null) {
|
|
1706
|
+
const leading = parsed.modifier ?? null;
|
|
1707
|
+
if (isLength(parsed, parsed.value)) {
|
|
1708
|
+
if (leading === null) return [decl("font-size", parsed.value)];
|
|
1709
|
+
const lh = sizeLeadingNative(parsed.value, leading);
|
|
1710
|
+
return lh === null ? null : [decl("font-size", parsed.value), decl("line-height", lh)];
|
|
1711
|
+
}
|
|
1712
|
+
if (leading !== null) return null;
|
|
1498
1713
|
}
|
|
1499
1714
|
const hex = nativeHexColor(parsed, theme);
|
|
1500
1715
|
return hex === null ? null : [decl("color", hex)];
|
|
@@ -1511,13 +1726,167 @@ function resolveColorNative(parsed, theme) {
|
|
|
1511
1726
|
return null;
|
|
1512
1727
|
}
|
|
1513
1728
|
}
|
|
1729
|
+
function resolveOpacityNative(parsed) {
|
|
1730
|
+
if (parsed.utility !== "opacity") return null;
|
|
1731
|
+
const v = resolvePercent(parsed);
|
|
1732
|
+
return v === null ? null : [decl("opacity", v)];
|
|
1733
|
+
}
|
|
1514
1734
|
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);
|
|
1735
|
+
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);
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
// src/jsEngine/calc.ts
|
|
1739
|
+
function reduceConstantMath(raw) {
|
|
1740
|
+
const trimmed = raw.trim();
|
|
1741
|
+
const calc = stripCall(trimmed, "calc");
|
|
1742
|
+
if (calc !== null) {
|
|
1743
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
1744
|
+
}
|
|
1745
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
1746
|
+
if (clamp !== null) {
|
|
1747
|
+
const args = splitTopLevelCommas(clamp);
|
|
1748
|
+
if (args.length !== 3) return null;
|
|
1749
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
1750
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
1751
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
1752
|
+
}
|
|
1753
|
+
const min = stripCall(trimmed, "min");
|
|
1754
|
+
if (min !== null) {
|
|
1755
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1756
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
1757
|
+
}
|
|
1758
|
+
const max = stripCall(trimmed, "max");
|
|
1759
|
+
if (max !== null) {
|
|
1760
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
1761
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
1762
|
+
}
|
|
1763
|
+
return null;
|
|
1764
|
+
}
|
|
1765
|
+
function stripCall(raw, name) {
|
|
1766
|
+
if (!raw.startsWith(name)) return null;
|
|
1767
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
1768
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
1769
|
+
return afterName.slice(1, -1);
|
|
1770
|
+
}
|
|
1771
|
+
function splitTopLevelCommas(s) {
|
|
1772
|
+
const parts = [];
|
|
1773
|
+
let depth = 0;
|
|
1774
|
+
let start = 0;
|
|
1775
|
+
for (let i = 0; i < s.length; i++) {
|
|
1776
|
+
const ch = s[i];
|
|
1777
|
+
if (ch === "(") depth++;
|
|
1778
|
+
else if (ch === ")") depth--;
|
|
1779
|
+
else if (ch === "," && depth === 0) {
|
|
1780
|
+
parts.push(s.slice(start, i).trim());
|
|
1781
|
+
start = i + 1;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
parts.push(s.slice(start).trim());
|
|
1785
|
+
return parts;
|
|
1516
1786
|
}
|
|
1787
|
+
var Evaluator = class {
|
|
1788
|
+
constructor(s) {
|
|
1789
|
+
this.pos = 0;
|
|
1790
|
+
this.s = s;
|
|
1791
|
+
}
|
|
1792
|
+
parseExprToEnd() {
|
|
1793
|
+
const value = this.expr();
|
|
1794
|
+
if (value === null) return null;
|
|
1795
|
+
this.skipWs();
|
|
1796
|
+
return this.pos === this.s.length ? value : null;
|
|
1797
|
+
}
|
|
1798
|
+
skipWs() {
|
|
1799
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
1800
|
+
}
|
|
1801
|
+
peek() {
|
|
1802
|
+
this.skipWs();
|
|
1803
|
+
return this.s[this.pos];
|
|
1804
|
+
}
|
|
1805
|
+
expr() {
|
|
1806
|
+
let value = this.term();
|
|
1807
|
+
if (value === null) return null;
|
|
1808
|
+
for (; ; ) {
|
|
1809
|
+
const ch = this.peek();
|
|
1810
|
+
if (ch === "+") {
|
|
1811
|
+
this.pos++;
|
|
1812
|
+
const rhs = this.term();
|
|
1813
|
+
if (rhs === null) return null;
|
|
1814
|
+
value += rhs;
|
|
1815
|
+
} else if (ch === "-") {
|
|
1816
|
+
this.pos++;
|
|
1817
|
+
const rhs = this.term();
|
|
1818
|
+
if (rhs === null) return null;
|
|
1819
|
+
value -= rhs;
|
|
1820
|
+
} else {
|
|
1821
|
+
return value;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
term() {
|
|
1826
|
+
let value = this.factor();
|
|
1827
|
+
if (value === null) return null;
|
|
1828
|
+
for (; ; ) {
|
|
1829
|
+
const ch = this.peek();
|
|
1830
|
+
if (ch === "*") {
|
|
1831
|
+
this.pos++;
|
|
1832
|
+
const rhs = this.factor();
|
|
1833
|
+
if (rhs === null) return null;
|
|
1834
|
+
value *= rhs;
|
|
1835
|
+
} else if (ch === "/") {
|
|
1836
|
+
this.pos++;
|
|
1837
|
+
const divisor = this.factor();
|
|
1838
|
+
if (divisor === null || divisor === 0) return null;
|
|
1839
|
+
value /= divisor;
|
|
1840
|
+
} else {
|
|
1841
|
+
return value;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
factor() {
|
|
1846
|
+
const ch = this.peek();
|
|
1847
|
+
if (ch === void 0) return null;
|
|
1848
|
+
if (ch === "(") {
|
|
1849
|
+
this.pos++;
|
|
1850
|
+
const value = this.expr();
|
|
1851
|
+
if (value === null || this.peek() !== ")") return null;
|
|
1852
|
+
this.pos++;
|
|
1853
|
+
return value;
|
|
1854
|
+
}
|
|
1855
|
+
if (ch === "-") {
|
|
1856
|
+
this.pos++;
|
|
1857
|
+
const value = this.factor();
|
|
1858
|
+
return value === null ? null : -value;
|
|
1859
|
+
}
|
|
1860
|
+
return this.numberWithUnit();
|
|
1861
|
+
}
|
|
1862
|
+
numberWithUnit() {
|
|
1863
|
+
this.skipWs();
|
|
1864
|
+
const start = this.pos;
|
|
1865
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
1866
|
+
if (this.pos === start) return null;
|
|
1867
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
1868
|
+
if (!Number.isFinite(n)) return null;
|
|
1869
|
+
const unitStart = this.pos;
|
|
1870
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
1871
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
1872
|
+
switch (unit) {
|
|
1873
|
+
case "":
|
|
1874
|
+
return n;
|
|
1875
|
+
case "px":
|
|
1876
|
+
return n;
|
|
1877
|
+
case "rem":
|
|
1878
|
+
return n * 16;
|
|
1879
|
+
default:
|
|
1880
|
+
return null;
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1517
1884
|
|
|
1518
1885
|
// src/jsEngine/resolveStyle.ts
|
|
1519
1886
|
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1887
|
+
var STATE_HOLD_MARKER = "_kbon";
|
|
1520
1888
|
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1889
|
+
if (modifier === STATE_HOLD_MARKER) return true;
|
|
1521
1890
|
if (modifier === "dark") return colorScheme === "dark";
|
|
1522
1891
|
if (modifier === "active") return pressed;
|
|
1523
1892
|
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
@@ -1525,6 +1894,34 @@ function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
|
1525
1894
|
if (minWidth === void 0) return null;
|
|
1526
1895
|
return width >= minWidth;
|
|
1527
1896
|
}
|
|
1897
|
+
if (modifier.startsWith("min-[") && modifier.endsWith("]")) {
|
|
1898
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1899
|
+
return px === null ? null : width >= px;
|
|
1900
|
+
}
|
|
1901
|
+
if (modifier.startsWith("max-[") && modifier.endsWith("]")) {
|
|
1902
|
+
const px = reduceConstantMath(`calc(${modifier.slice(5, -1).trim()})`);
|
|
1903
|
+
return px === null ? null : width < px;
|
|
1904
|
+
}
|
|
1905
|
+
const screen = (name) => Object.prototype.hasOwnProperty.call(theme.screens, name) ? theme.screens[name] : void 0;
|
|
1906
|
+
const custom = screen(modifier);
|
|
1907
|
+
if (typeof custom === "number") return width >= custom;
|
|
1908
|
+
if (modifier.startsWith("max-")) {
|
|
1909
|
+
const max = screen(modifier.slice(4));
|
|
1910
|
+
if (typeof max === "number") return width < max;
|
|
1911
|
+
}
|
|
1912
|
+
if (modifier.startsWith("min-")) {
|
|
1913
|
+
const min = screen(modifier.slice(4));
|
|
1914
|
+
if (typeof min === "number") return width >= min;
|
|
1915
|
+
}
|
|
1916
|
+
if (modifier.startsWith("not-")) {
|
|
1917
|
+
const rest = modifier.slice(4);
|
|
1918
|
+
if (rest === "dark") return colorScheme !== "dark";
|
|
1919
|
+
const isBreakpoint = (name) => typeof screen(name) === "number";
|
|
1920
|
+
if (isBreakpoint(rest) || (rest.startsWith("max-") || rest.startsWith("min-")) && isBreakpoint(rest.slice(4))) {
|
|
1921
|
+
const holds = nativeModifierState(rest, theme, colorScheme, pressed, width);
|
|
1922
|
+
return holds === null ? null : !holds;
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1528
1925
|
return null;
|
|
1529
1926
|
}
|
|
1530
1927
|
function kebabToCamel(s) {
|
|
@@ -1569,6 +1966,7 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1569
1966
|
"shadow-opacity",
|
|
1570
1967
|
"shadow-radius",
|
|
1571
1968
|
"elevation",
|
|
1969
|
+
"opacity",
|
|
1572
1970
|
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1573
1971
|
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1574
1972
|
// style system wants plain numbers for these exactly like the generic
|
|
@@ -1582,29 +1980,104 @@ var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
|
1582
1980
|
"border-bottom-right-radius",
|
|
1583
1981
|
"border-bottom-left-radius",
|
|
1584
1982
|
"outline-width",
|
|
1585
|
-
"outline-offset"
|
|
1983
|
+
"outline-offset",
|
|
1984
|
+
// The transform ops whose RN value is a plain JS number — translate takes
|
|
1985
|
+
// a length (px/percentage, same as top/left/etc. above) and scale takes a
|
|
1986
|
+
// bare decimal factor (parsed by the same "raw value" fallback branch
|
|
1987
|
+
// below). transform-op-rotate*/transform-op-skew* stay OUT of this set on
|
|
1988
|
+
// purpose, since RN wants those as literal "45deg"-shaped strings, not
|
|
1989
|
+
// numbers. See the transform-ops accumulator below for how these markers
|
|
1990
|
+
// get collected into the final array.
|
|
1991
|
+
"transform-op-translate-x",
|
|
1992
|
+
"transform-op-translate-y",
|
|
1993
|
+
"transform-op-scale-x",
|
|
1994
|
+
"transform-op-scale-y"
|
|
1586
1995
|
]);
|
|
1996
|
+
var TRANSFORM_OP_KEYS = /* @__PURE__ */ new Map([
|
|
1997
|
+
["transform-op-translate-x", "translateX"],
|
|
1998
|
+
["transform-op-translate-y", "translateY"],
|
|
1999
|
+
["transform-op-rotate", "rotate"],
|
|
2000
|
+
["transform-op-rotate-x", "rotateX"],
|
|
2001
|
+
["transform-op-rotate-y", "rotateY"],
|
|
2002
|
+
["transform-op-rotate-z", "rotateZ"],
|
|
2003
|
+
["transform-op-skew-x", "skewX"],
|
|
2004
|
+
["transform-op-skew-y", "skewY"],
|
|
2005
|
+
["transform-op-scale-x", "scaleX"],
|
|
2006
|
+
["transform-op-scale-y", "scaleY"]
|
|
2007
|
+
]);
|
|
2008
|
+
var TRANSFORM_OP_ORDER = ["translateX", "translateY", "rotate", "rotateX", "rotateY", "rotateZ", "skewX", "skewY", "scaleX", "scaleY"];
|
|
2009
|
+
function isPlainPercentage(value) {
|
|
2010
|
+
if (!value.endsWith("%")) return false;
|
|
2011
|
+
let digits = value.slice(0, -1);
|
|
2012
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
2013
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
2014
|
+
}
|
|
2015
|
+
function sanitizeForWarning(value) {
|
|
2016
|
+
const MAX_CHARS = 60;
|
|
2017
|
+
const escaped = value.replace(/"/g, "'").replace(/[\n\r]/g, " ");
|
|
2018
|
+
if (escaped.length <= MAX_CHARS) return escaped;
|
|
2019
|
+
return `${escaped.slice(0, MAX_CHARS)}\u2026`;
|
|
2020
|
+
}
|
|
1587
2021
|
function rnStyleValue(property, value) {
|
|
1588
|
-
if (
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
2022
|
+
if (value.startsWith("color-mix(in srgb, ") && value.endsWith(", transparent)")) {
|
|
2023
|
+
const inner = value.slice("color-mix(in srgb, ".length, -", transparent)".length);
|
|
2024
|
+
const space = inner.lastIndexOf(" ");
|
|
2025
|
+
if (space !== -1) return rnStyleValue(property, inner.slice(0, space));
|
|
2026
|
+
}
|
|
2027
|
+
if (property === "aspect-ratio") {
|
|
2028
|
+
if (value.trim() === "auto") return { value: null, warning: null };
|
|
2029
|
+
const parts = value.split("/").map((s) => s.trim());
|
|
2030
|
+
let n = null;
|
|
2031
|
+
if (parts.length === 1) {
|
|
2032
|
+
const a = Number(parts[0]);
|
|
2033
|
+
n = Number.isFinite(a) ? a : null;
|
|
2034
|
+
} else if (parts.length === 2) {
|
|
2035
|
+
const a = Number(parts[0]);
|
|
2036
|
+
const b = Number(parts[1]);
|
|
2037
|
+
n = Number.isFinite(a) && Number.isFinite(b) && b !== 0 ? a / b : null;
|
|
1599
2038
|
}
|
|
1600
|
-
|
|
2039
|
+
return { value: n, warning: null };
|
|
2040
|
+
}
|
|
2041
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
2042
|
+
return { value, warning: null };
|
|
2043
|
+
}
|
|
2044
|
+
if (value === "auto") {
|
|
2045
|
+
return { value: "auto", warning: null };
|
|
2046
|
+
}
|
|
2047
|
+
let px = null;
|
|
2048
|
+
if (value.endsWith("px")) {
|
|
2049
|
+
const n = Number(value.slice(0, -2));
|
|
2050
|
+
px = Number.isFinite(n) ? n : null;
|
|
2051
|
+
} else if (value.endsWith("rem")) {
|
|
2052
|
+
const n = Number(value.slice(0, -3));
|
|
2053
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
2054
|
+
} else {
|
|
2055
|
+
const n = Number(value);
|
|
2056
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1601
2057
|
}
|
|
1602
|
-
return value;
|
|
2058
|
+
if (px !== null) return { value: px, warning: null };
|
|
2059
|
+
if (isPlainPercentage(value)) {
|
|
2060
|
+
return { value, warning: null };
|
|
2061
|
+
}
|
|
2062
|
+
const reduced = reduceConstantMath(value);
|
|
2063
|
+
if (reduced !== null) {
|
|
2064
|
+
return { value: reduced, warning: null };
|
|
2065
|
+
}
|
|
2066
|
+
const sanitizedValue = sanitizeForWarning(value);
|
|
2067
|
+
const warning = `[Kbach] "${sanitizedValue}" isn't a valid native value for "${property}" \u2014 dropped.
|
|
2068
|
+
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).
|
|
2069
|
+
Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
2070
|
+
return { value: null, warning };
|
|
1603
2071
|
}
|
|
1604
|
-
function
|
|
2072
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1605
2073
|
const style = {};
|
|
2074
|
+
const warnings = [];
|
|
1606
2075
|
let shadowOffset = null;
|
|
1607
|
-
|
|
2076
|
+
const transformOps = /* @__PURE__ */ new Map();
|
|
2077
|
+
const keySpecificity = /* @__PURE__ */ new Map();
|
|
2078
|
+
const transformSpecificity = /* @__PURE__ */ new Map();
|
|
2079
|
+
for (const rawToken of classString.split(/\s+/).filter(Boolean)) {
|
|
2080
|
+
const token = substituteModeAwareColorToken(rawToken, theme, colorScheme);
|
|
1608
2081
|
const parsed = parseClass(token);
|
|
1609
2082
|
const allModifiersHold = parsed.modifiers.every(
|
|
1610
2083
|
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
@@ -1612,39 +2085,126 @@ function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
|
1612
2085
|
if (!allModifiersHold) continue;
|
|
1613
2086
|
const decls = resolveUtilityNative(parsed, theme);
|
|
1614
2087
|
if (decls === null) continue;
|
|
2088
|
+
const spec = parsed.modifiers.length;
|
|
1615
2089
|
for (const d of decls) {
|
|
1616
2090
|
if (d.property.startsWith("__")) {
|
|
1617
2091
|
continue;
|
|
1618
2092
|
}
|
|
2093
|
+
if (d.property.startsWith("--") || d.value.includes("var(") || d.property === "outline" || d.property === "object-position" || d.property === "container-type" || d.property === "container-name") {
|
|
2094
|
+
continue;
|
|
2095
|
+
}
|
|
1619
2096
|
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
2097
|
+
if (spec < (keySpecificity.get("shadowOffset") ?? 0)) continue;
|
|
1620
2098
|
const n = Number(d.value);
|
|
1621
2099
|
if (!Number.isFinite(n)) continue;
|
|
1622
2100
|
if (shadowOffset === null) shadowOffset = {};
|
|
1623
2101
|
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
2102
|
+
keySpecificity.set("shadowOffset", spec);
|
|
1624
2103
|
continue;
|
|
1625
2104
|
}
|
|
1626
|
-
|
|
2105
|
+
if (d.property === "transform-op-none") {
|
|
2106
|
+
transformOps.clear();
|
|
2107
|
+
transformSpecificity.clear();
|
|
2108
|
+
continue;
|
|
2109
|
+
}
|
|
2110
|
+
const opKey = TRANSFORM_OP_KEYS.get(d.property);
|
|
2111
|
+
if (opKey !== void 0) {
|
|
2112
|
+
if (spec < (transformSpecificity.get(opKey) ?? 0)) continue;
|
|
2113
|
+
const { value: value2, warning: warning2 } = rnStyleValue(d.property, d.value);
|
|
2114
|
+
if (warning2 !== null) warnings.push(warning2);
|
|
2115
|
+
if (value2 !== null) {
|
|
2116
|
+
transformOps.set(opKey, value2);
|
|
2117
|
+
transformSpecificity.set(opKey, spec);
|
|
2118
|
+
}
|
|
2119
|
+
continue;
|
|
2120
|
+
}
|
|
2121
|
+
const key = kebabToCamel(d.property);
|
|
2122
|
+
if (spec < (keySpecificity.get(key) ?? 0)) continue;
|
|
2123
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
2124
|
+
if (warning !== null) warnings.push(warning);
|
|
2125
|
+
if (value !== null) {
|
|
2126
|
+
style[key] = value;
|
|
2127
|
+
keySpecificity.set(key, spec);
|
|
2128
|
+
}
|
|
1627
2129
|
}
|
|
1628
2130
|
}
|
|
1629
2131
|
if (shadowOffset !== null) {
|
|
1630
2132
|
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1631
2133
|
}
|
|
1632
|
-
|
|
2134
|
+
if (transformOps.size > 0) {
|
|
2135
|
+
style.transform = TRANSFORM_OP_ORDER.filter((key) => transformOps.has(key)).map((key) => ({
|
|
2136
|
+
[key]: transformOps.get(key)
|
|
2137
|
+
}));
|
|
2138
|
+
}
|
|
2139
|
+
return { style, warnings };
|
|
1633
2140
|
}
|
|
1634
2141
|
|
|
1635
2142
|
// src/nativeBridge.ts
|
|
2143
|
+
var RESOLVE_STYLE_CACHE_MAX = 500;
|
|
2144
|
+
var resolveStyleCache = /* @__PURE__ */ new Map();
|
|
2145
|
+
var cachedForThemeJson = null;
|
|
1636
2146
|
function resolveStyle(classString, pressed = false) {
|
|
1637
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1638
|
-
const width =
|
|
1639
|
-
const
|
|
2147
|
+
const colorScheme = (0, import_darkModeStore.getGlobalDarkMode)() ? "dark" : "light";
|
|
2148
|
+
const width = import_react_native.Dimensions.get("window").width;
|
|
2149
|
+
const themeJson = (0, import_theme.getThemeJson)();
|
|
2150
|
+
if (themeJson !== cachedForThemeJson) {
|
|
2151
|
+
resolveStyleCache.clear();
|
|
2152
|
+
cachedForThemeJson = themeJson;
|
|
2153
|
+
}
|
|
2154
|
+
const cacheKey = `${classString}\0${pressed}\0${colorScheme}\0${width}`;
|
|
2155
|
+
const cached = resolveStyleCache.get(cacheKey);
|
|
2156
|
+
if (cached !== void 0) return { ...cached };
|
|
2157
|
+
const style = resolveStyleUncached(classString, pressed, colorScheme, width, themeJson);
|
|
2158
|
+
if (resolveStyleCache.size >= RESOLVE_STYLE_CACHE_MAX) resolveStyleCache.clear();
|
|
2159
|
+
resolveStyleCache.set(cacheKey, style);
|
|
2160
|
+
return { ...style };
|
|
2161
|
+
}
|
|
2162
|
+
function resolveStyleUncached(classString, pressed, colorScheme, width, themeJson) {
|
|
2163
|
+
const KbachModule = import_react_native.TurboModuleRegistry.get("KbachModule");
|
|
1640
2164
|
if (!KbachModule) {
|
|
1641
|
-
|
|
2165
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme.getTheme)(), colorScheme, pressed, width);
|
|
2166
|
+
warnIfDev(classString, warnings2);
|
|
2167
|
+
return style2;
|
|
2168
|
+
}
|
|
2169
|
+
const json = KbachModule.resolveStyle(classString, themeJson, colorScheme, pressed, width);
|
|
2170
|
+
const style = JSON.parse(json);
|
|
2171
|
+
const warnings = style.__kbachWarnings;
|
|
2172
|
+
if (warnings !== void 0) {
|
|
2173
|
+
delete style.__kbachWarnings;
|
|
2174
|
+
warnIfDev(classString, warnings);
|
|
2175
|
+
}
|
|
2176
|
+
return style;
|
|
2177
|
+
}
|
|
2178
|
+
var WARNED_MESSAGES_MAX = 500;
|
|
2179
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
2180
|
+
var QUOTED_TOKEN_RE = /"([^"]*)"/;
|
|
2181
|
+
function highlightToken(classString, warning) {
|
|
2182
|
+
const match = QUOTED_TOKEN_RE.exec(warning);
|
|
2183
|
+
if (match === null) return classString;
|
|
2184
|
+
const quoted = match[1].replace(/\s+/g, "");
|
|
2185
|
+
if (quoted === "") return classString;
|
|
2186
|
+
const parts = classString.split(/(\s+)/);
|
|
2187
|
+
const idx = parts.findIndex((part) => part.replace(/\s+/g, "").includes(quoted));
|
|
2188
|
+
if (idx === -1) return classString;
|
|
2189
|
+
parts[idx] = `\xBB${parts[idx]}\xAB`;
|
|
2190
|
+
return parts.join("");
|
|
2191
|
+
}
|
|
2192
|
+
function warnIfDev(classString, warnings) {
|
|
2193
|
+
if (warnings.length === 0) return;
|
|
2194
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
2195
|
+
for (const warning of warnings) {
|
|
2196
|
+
const message = `${warning}
|
|
2197
|
+
From className: "${highlightToken(classString, warning)}"`;
|
|
2198
|
+
if (warnedMessages.has(message)) continue;
|
|
2199
|
+
if (warnedMessages.size >= WARNED_MESSAGES_MAX) warnedMessages.clear();
|
|
2200
|
+
warnedMessages.add(message);
|
|
2201
|
+
console.warn(message);
|
|
1642
2202
|
}
|
|
1643
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1644
|
-
return JSON.parse(json);
|
|
1645
2203
|
}
|
|
1646
2204
|
|
|
1647
2205
|
// src/config.ts
|
|
2206
|
+
var import_theme2 = require("./theme");
|
|
2207
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
1648
2208
|
function parseHexRgb(hex) {
|
|
1649
2209
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1650
2210
|
if (!m) return null;
|
|
@@ -1653,7 +2213,7 @@ function parseHexRgb(hex) {
|
|
|
1653
2213
|
const n = parseInt(h, 16);
|
|
1654
2214
|
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1655
2215
|
}
|
|
1656
|
-
function
|
|
2216
|
+
function applyOpacityToHex2(hex, opacityText) {
|
|
1657
2217
|
const rgb = parseHexRgb(hex);
|
|
1658
2218
|
if (!rgb) return hex;
|
|
1659
2219
|
const a = Number(opacityText) / 100;
|
|
@@ -1666,21 +2226,39 @@ function resolveColorEntry(value, lookup) {
|
|
|
1666
2226
|
const opacity = slash === -1 ? void 0 : value.slice(slash + 1);
|
|
1667
2227
|
const base = lookup(name);
|
|
1668
2228
|
if (base === void 0) return value;
|
|
1669
|
-
return opacity === void 0 ? base :
|
|
2229
|
+
return opacity === void 0 ? base : applyOpacityToHex2(base, opacity);
|
|
1670
2230
|
}
|
|
1671
2231
|
function resolveColors(extend, existing) {
|
|
1672
|
-
const
|
|
1673
|
-
const
|
|
1674
|
-
|
|
2232
|
+
const { dark: darkExtend, ...lightExtend } = extend;
|
|
2233
|
+
const resolvedLight = {};
|
|
2234
|
+
const lookupLight = (name) => {
|
|
2235
|
+
const found = resolvedLight[name] ?? existing[name];
|
|
1675
2236
|
return typeof found === "string" ? found : void 0;
|
|
1676
2237
|
};
|
|
1677
|
-
for (const [name, value] of Object.entries(
|
|
1678
|
-
|
|
2238
|
+
for (const [name, value] of Object.entries(lightExtend)) {
|
|
2239
|
+
if (typeof value !== "string") continue;
|
|
2240
|
+
resolvedLight[name] = resolveColorEntry(value, lookupLight);
|
|
2241
|
+
}
|
|
2242
|
+
const result = { ...resolvedLight };
|
|
2243
|
+
if (darkExtend) {
|
|
2244
|
+
const resolvedDark = {};
|
|
2245
|
+
const lookupDark = (name) => {
|
|
2246
|
+
const found = resolvedDark[name] ?? existing[name];
|
|
2247
|
+
return typeof found === "string" ? found : void 0;
|
|
2248
|
+
};
|
|
2249
|
+
for (const [name, value] of Object.entries(darkExtend)) {
|
|
2250
|
+
resolvedDark[name] = resolveColorEntry(value, lookupDark);
|
|
2251
|
+
}
|
|
2252
|
+
for (const [name, darkValue] of Object.entries(resolvedDark)) {
|
|
2253
|
+
const lightValue = resolvedLight[name];
|
|
2254
|
+
if (lightValue === void 0) continue;
|
|
2255
|
+
result[name] = { light: lightValue, dark: darkValue };
|
|
2256
|
+
}
|
|
1679
2257
|
}
|
|
1680
|
-
return
|
|
2258
|
+
return result;
|
|
1681
2259
|
}
|
|
1682
2260
|
function resolveKbachConfig(config) {
|
|
1683
|
-
let theme = { ...defaultTheme, ...config.theme };
|
|
2261
|
+
let theme = { ...import_theme2.defaultTheme, ...config.theme };
|
|
1684
2262
|
if (config.extend?.colors) {
|
|
1685
2263
|
theme = { ...theme, colors: { ...theme.colors, ...resolveColors(config.extend.colors, theme.colors) } };
|
|
1686
2264
|
}
|
|
@@ -1703,33 +2281,40 @@ function resolveKbachConfig(config) {
|
|
|
1703
2281
|
}
|
|
1704
2282
|
function applyKbachConfig(config) {
|
|
1705
2283
|
const theme = resolveKbachConfig(config);
|
|
1706
|
-
setTheme(theme);
|
|
2284
|
+
(0, import_theme2.setTheme)(theme);
|
|
2285
|
+
(0, import_darkModeStore2.resyncDomWithActiveTheme)();
|
|
1707
2286
|
return theme;
|
|
1708
2287
|
}
|
|
1709
2288
|
|
|
1710
2289
|
// src/useTheme.ts
|
|
1711
2290
|
var import_react = require("react");
|
|
2291
|
+
var import_darkModeStore3 = require("./darkModeStore");
|
|
1712
2292
|
function useTheme() {
|
|
1713
|
-
const
|
|
1714
|
-
const
|
|
2293
|
+
const isDark = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalDarkMode);
|
|
2294
|
+
const mode = (0, import_react.useSyncExternalStore)(import_darkModeStore3.subscribeGlobalDarkMode, import_darkModeStore3.getGlobalThemeMode);
|
|
1715
2295
|
return (0, import_react.useMemo)(
|
|
1716
|
-
() => ({ mode
|
|
1717
|
-
[
|
|
2296
|
+
() => ({ mode, isDark, setMode: import_darkModeStore3.setGlobalThemeMode, toggle: import_darkModeStore3.toggleGlobalDarkMode }),
|
|
2297
|
+
[mode, isDark]
|
|
1718
2298
|
);
|
|
1719
2299
|
}
|
|
1720
2300
|
|
|
1721
2301
|
// src/ThemeProvider.tsx
|
|
1722
2302
|
var import_react2 = require("react");
|
|
2303
|
+
var import_darkModeStore4 = require("./darkModeStore");
|
|
1723
2304
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
2305
|
+
var PERSIST_STORAGE_KEY = "kbach-theme";
|
|
2306
|
+
function isThemeMode(value) {
|
|
2307
|
+
return value === "light" || value === "dark" || value === "system";
|
|
2308
|
+
}
|
|
1724
2309
|
var mountedProviderCount = 0;
|
|
1725
2310
|
var warnedMultipleProviders = false;
|
|
1726
|
-
function ThemeProvider({ children, defaultMode = "system" }) {
|
|
2311
|
+
function ThemeProvider({ children, defaultMode = "system", persist = false }) {
|
|
1727
2312
|
(0, import_react2.useEffect)(() => {
|
|
1728
2313
|
mountedProviderCount++;
|
|
1729
2314
|
if (mountedProviderCount > 1 && !warnedMultipleProviders) {
|
|
1730
2315
|
warnedMultipleProviders = true;
|
|
1731
2316
|
console.warn(
|
|
1732
|
-
"[
|
|
2317
|
+
"[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
2318
|
);
|
|
1734
2319
|
}
|
|
1735
2320
|
return () => {
|
|
@@ -1740,12 +2325,38 @@ function ThemeProvider({ children, defaultMode = "system" }) {
|
|
|
1740
2325
|
(0, import_react2.useEffect)(() => {
|
|
1741
2326
|
if (seeded.current) return;
|
|
1742
2327
|
seeded.current = true;
|
|
1743
|
-
|
|
2328
|
+
if (!persist) {
|
|
2329
|
+
(0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2330
|
+
return;
|
|
2331
|
+
}
|
|
2332
|
+
let cancelled = false;
|
|
2333
|
+
persist.getItem(PERSIST_STORAGE_KEY).then((stored) => {
|
|
2334
|
+
if (cancelled) return;
|
|
2335
|
+
if (isThemeMode(stored)) (0, import_darkModeStore4.seedDefaultMode)(stored);
|
|
2336
|
+
else (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2337
|
+
}).catch(() => {
|
|
2338
|
+
if (!cancelled) (0, import_darkModeStore4.seedDefaultMode)(defaultMode);
|
|
2339
|
+
});
|
|
2340
|
+
return () => {
|
|
2341
|
+
cancelled = true;
|
|
2342
|
+
};
|
|
1744
2343
|
}, []);
|
|
2344
|
+
(0, import_react2.useEffect)(() => {
|
|
2345
|
+
if (!persist) return;
|
|
2346
|
+
return (0, import_darkModeStore4.subscribeGlobalDarkMode)(() => {
|
|
2347
|
+
persist.setItem(PERSIST_STORAGE_KEY, (0, import_darkModeStore4.getGlobalThemeMode)()).catch(() => {
|
|
2348
|
+
});
|
|
2349
|
+
});
|
|
2350
|
+
}, [persist]);
|
|
1745
2351
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children });
|
|
1746
2352
|
}
|
|
1747
2353
|
|
|
2354
|
+
// src/index.ts
|
|
2355
|
+
var import_darkModeStore5 = require("./darkModeStore");
|
|
2356
|
+
|
|
1748
2357
|
// src/useColors.ts
|
|
2358
|
+
var import_react3 = require("react");
|
|
2359
|
+
var import_theme3 = require("./theme");
|
|
1749
2360
|
function parseHexRgb2(hex) {
|
|
1750
2361
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
1751
2362
|
if (!m) return null;
|
|
@@ -1764,10 +2375,10 @@ function applyOpacity(color, opacity) {
|
|
|
1764
2375
|
if (color.startsWith("rgba(")) return color.replace(/,\s*[\d.]+\)$/, `,${a})`);
|
|
1765
2376
|
return color;
|
|
1766
2377
|
}
|
|
1767
|
-
function resolveEntry(entry,
|
|
1768
|
-
return typeof entry === "string" ? entry :
|
|
2378
|
+
function resolveEntry(entry, isDark) {
|
|
2379
|
+
return typeof entry === "string" ? entry : isDark ? entry.dark : entry.light;
|
|
1769
2380
|
}
|
|
1770
|
-
function makeColorsProxy(theme,
|
|
2381
|
+
function makeColorsProxy(theme, isDark) {
|
|
1771
2382
|
const alpha = (color, opacity) => opacity === void 0 ? color : applyOpacity(color, opacity);
|
|
1772
2383
|
const cache = /* @__PURE__ */ new Map();
|
|
1773
2384
|
function resolveNamed(key) {
|
|
@@ -1780,7 +2391,7 @@ function makeColorsProxy(theme, isDark2) {
|
|
|
1780
2391
|
}
|
|
1781
2392
|
const entry = theme.colors[name];
|
|
1782
2393
|
if (entry === void 0) return void 0;
|
|
1783
|
-
const value = resolveEntry(entry,
|
|
2394
|
+
const value = resolveEntry(entry, isDark);
|
|
1784
2395
|
return opacity === void 0 ? value : applyOpacity(value, opacity);
|
|
1785
2396
|
}
|
|
1786
2397
|
function makeFamilyProxy(family) {
|
|
@@ -1792,11 +2403,13 @@ function makeColorsProxy(theme, isDark2) {
|
|
|
1792
2403
|
}
|
|
1793
2404
|
});
|
|
1794
2405
|
}
|
|
1795
|
-
|
|
2406
|
+
const get = (name) => resolveNamed(name) ?? name;
|
|
2407
|
+
return new Proxy({ alpha, get }, {
|
|
1796
2408
|
get(_, prop) {
|
|
1797
2409
|
const key = String(prop);
|
|
1798
2410
|
if (key === "then") return void 0;
|
|
1799
2411
|
if (key === "alpha") return alpha;
|
|
2412
|
+
if (key === "get") return get;
|
|
1800
2413
|
const direct = resolveNamed(key);
|
|
1801
2414
|
if (direct !== void 0) return direct;
|
|
1802
2415
|
if (!cache.has(key)) cache.set(key, makeFamilyProxy(key));
|
|
@@ -1805,23 +2418,100 @@ function makeColorsProxy(theme, isDark2) {
|
|
|
1805
2418
|
});
|
|
1806
2419
|
}
|
|
1807
2420
|
function useColors() {
|
|
1808
|
-
const { isDark
|
|
1809
|
-
|
|
2421
|
+
const { isDark } = useTheme();
|
|
2422
|
+
const theme = (0, import_theme3.getTheme)();
|
|
2423
|
+
return (0, import_react3.useMemo)(() => makeColorsProxy(theme, isDark), [theme, isDark]);
|
|
2424
|
+
}
|
|
2425
|
+
|
|
2426
|
+
// src/index.ts
|
|
2427
|
+
var import_dynamicTokens2 = require("./dynamicTokens");
|
|
2428
|
+
|
|
2429
|
+
// src/useDynamicToken.ts
|
|
2430
|
+
var import_react4 = require("react");
|
|
2431
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
2432
|
+
function useDynamicToken(name) {
|
|
2433
|
+
return (0, import_react4.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, () => (0, import_dynamicTokens.getDynamicToken)(name));
|
|
1810
2434
|
}
|
|
2435
|
+
|
|
2436
|
+
// src/clsx.ts
|
|
2437
|
+
function clsx(...inputs) {
|
|
2438
|
+
let out = "";
|
|
2439
|
+
for (const input of inputs) {
|
|
2440
|
+
const piece = resolveClassValue(input);
|
|
2441
|
+
if (piece) out = out ? `${out} ${piece}` : piece;
|
|
2442
|
+
}
|
|
2443
|
+
return out;
|
|
2444
|
+
}
|
|
2445
|
+
function resolveClassValue(value) {
|
|
2446
|
+
if (!value) return "";
|
|
2447
|
+
const type = typeof value;
|
|
2448
|
+
if (type === "string" || type === "number" || type === "bigint") return String(value);
|
|
2449
|
+
if (Array.isArray(value)) return clsx(...value);
|
|
2450
|
+
if (type === "object") {
|
|
2451
|
+
let out = "";
|
|
2452
|
+
for (const key in value) {
|
|
2453
|
+
if (Object.prototype.hasOwnProperty.call(value, key) && value[key]) {
|
|
2454
|
+
out = out ? `${out} ${key}` : key;
|
|
2455
|
+
}
|
|
2456
|
+
}
|
|
2457
|
+
return out;
|
|
2458
|
+
}
|
|
2459
|
+
return "";
|
|
2460
|
+
}
|
|
2461
|
+
|
|
2462
|
+
// src/semanticElements.tsx
|
|
2463
|
+
var React = __toESM(require("react"));
|
|
2464
|
+
var import_react_native2 = require("react-native");
|
|
2465
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2466
|
+
var Button = React.forwardRef(function Button2(props, ref) {
|
|
2467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Pressable, { ref, accessibilityRole: "button", ...props });
|
|
2468
|
+
});
|
|
2469
|
+
var PARAGRAPH_ROLE = "paragraph";
|
|
2470
|
+
var Paragraph = React.forwardRef(function Paragraph2(props, ref) {
|
|
2471
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { ref, role: PARAGRAPH_ROLE, ...props });
|
|
2472
|
+
});
|
|
2473
|
+
function makeHeading(level) {
|
|
2474
|
+
const extra = { "aria-level": level };
|
|
2475
|
+
const Heading = React.forwardRef(function Heading2(props, ref) {
|
|
2476
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_native2.Text, { ref, accessibilityRole: "header", ...extra, ...props });
|
|
2477
|
+
});
|
|
2478
|
+
Heading.displayName = `H${level}`;
|
|
2479
|
+
return Heading;
|
|
2480
|
+
}
|
|
2481
|
+
var H1 = makeHeading(1);
|
|
2482
|
+
var H2 = makeHeading(2);
|
|
2483
|
+
var H3 = makeHeading(3);
|
|
2484
|
+
var H4 = makeHeading(4);
|
|
2485
|
+
var H5 = makeHeading(5);
|
|
2486
|
+
var H6 = makeHeading(6);
|
|
1811
2487
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1812
2488
|
0 && (module.exports = {
|
|
2489
|
+
Button,
|
|
2490
|
+
H1,
|
|
2491
|
+
H2,
|
|
2492
|
+
H3,
|
|
2493
|
+
H4,
|
|
2494
|
+
H5,
|
|
2495
|
+
H6,
|
|
2496
|
+
Paragraph,
|
|
1813
2497
|
ThemeProvider,
|
|
1814
2498
|
applyKbachConfig,
|
|
2499
|
+
clsx,
|
|
1815
2500
|
defaultTheme,
|
|
2501
|
+
deleteDynamicToken,
|
|
2502
|
+
getDynamicToken,
|
|
1816
2503
|
getGlobalDarkMode,
|
|
1817
2504
|
getGlobalThemeMode,
|
|
1818
2505
|
getTheme,
|
|
1819
2506
|
resolveKbachConfig,
|
|
1820
2507
|
resolveStyle,
|
|
2508
|
+
setDynamicToken,
|
|
1821
2509
|
setGlobalThemeMode,
|
|
1822
2510
|
setTheme,
|
|
2511
|
+
subscribeDynamicTokens,
|
|
1823
2512
|
subscribeGlobalDarkMode,
|
|
1824
2513
|
toggleGlobalDarkMode,
|
|
1825
2514
|
useColors,
|
|
2515
|
+
useDynamicToken,
|
|
1826
2516
|
useTheme
|
|
1827
2517
|
});
|