@kbach/react-native 1.0.0-beta.2 → 1.0.0-beta.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +220 -87
- package/android/build.gradle +36 -0
- package/android/src/main/AndroidManifest.xml +14 -0
- package/android/src/main/java/com/kbachnative/KbachModule.kt +83 -0
- package/android/src/main/java/com/kbachnative/KbachPackage.kt +54 -0
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/chunk-45GOGUHJ.mjs +107 -0
- package/dist/chunk-MJWWZJMH.mjs +40 -0
- package/dist/chunk-OGFB3OXS.mjs +552 -0
- package/dist/darkModeStore.d.ts +58 -0
- package/dist/darkModeStore.js +112 -0
- package/dist/dynamicTokens.d.ts +35 -0
- package/dist/dynamicTokens.js +75 -0
- package/dist/index.d.ts +53 -102
- package/dist/index.js +1578 -385
- package/dist/index.web.d.ts +18 -0
- package/dist/index.web.js +436 -0
- package/dist/index.web.mjs +210 -0
- package/dist/jsx-dev-runtime.d.ts +3 -12
- package/dist/jsx-dev-runtime.js +1565 -344
- package/dist/jsx-dev-runtime.web.d.ts +10 -0
- package/dist/jsx-dev-runtime.web.js +271 -0
- package/dist/jsx-dev-runtime.web.mjs +29 -0
- package/dist/jsx-runtime.d.ts +3 -23
- package/dist/jsx-runtime.js +1556 -336
- package/dist/jsx-runtime.web.d.ts +7 -0
- package/dist/jsx-runtime.web.js +252 -0
- package/dist/{jsx-runtime.mjs → jsx-runtime.web.mjs} +2 -2
- package/dist/theme.d.ts +54 -0
- package/dist/{chunk-YHF3QLRL.mjs → theme.js} +94 -72
- package/dist/useDynamicToken-Dr15c88t.d.ts +160 -0
- package/package.json +62 -14
- package/react-native.config.js +29 -0
- package/specs/NativeKbachModule.ts +31 -0
- package/src/babel-plugin.js +74 -2
- package/dist/chunk-SVMYVXY6.mjs +0 -44
- package/dist/index.d.mts +0 -148
- package/dist/index.mjs +0 -80
- package/dist/jsx-dev-runtime.d.mts +0 -19
- package/dist/jsx-dev-runtime.mjs +0 -20
- package/dist/jsx-runtime.d.mts +0 -27
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -25,350 +25,218 @@ __export(jsx_dev_runtime_exports, {
|
|
|
25
25
|
});
|
|
26
26
|
module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
27
27
|
|
|
28
|
-
// src/
|
|
28
|
+
// src/jsxRuntimeCore.ts
|
|
29
29
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
30
30
|
var import_react = require("react");
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
var
|
|
31
|
+
var import_react_native = require("react-native");
|
|
32
|
+
var import_darkModeStore = require("./darkModeStore");
|
|
33
|
+
var import_dynamicTokens = require("./dynamicTokens");
|
|
34
|
+
var import_theme = require("./theme");
|
|
35
35
|
|
|
36
|
-
// src/
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
"pink-3": "#fbcfe8",
|
|
182
|
-
"pink-4": "#f9a8d4",
|
|
183
|
-
"pink-5": "#f472b6",
|
|
184
|
-
"pink-6": "#ec4899",
|
|
185
|
-
"pink-7": "#db2777",
|
|
186
|
-
"pink-8": "#be185d",
|
|
187
|
-
"pink-9": "#9d174d",
|
|
188
|
-
"purple-1": "#faf5ff",
|
|
189
|
-
"purple-10": "#581c87",
|
|
190
|
-
"purple-11": "#3b0764",
|
|
191
|
-
"purple-12": "#23043c",
|
|
192
|
-
"purple-2": "#f3e8ff",
|
|
193
|
-
"purple-3": "#e9d5ff",
|
|
194
|
-
"purple-4": "#d8b4fe",
|
|
195
|
-
"purple-5": "#c084fc",
|
|
196
|
-
"purple-6": "#a855f7",
|
|
197
|
-
"purple-7": "#9333ea",
|
|
198
|
-
"purple-8": "#7e22ce",
|
|
199
|
-
"purple-9": "#6b21a8",
|
|
200
|
-
"red-1": "#fef2f2",
|
|
201
|
-
"red-10": "#7f1d1d",
|
|
202
|
-
"red-11": "#450a0a",
|
|
203
|
-
"red-12": "#280606",
|
|
204
|
-
"red-2": "#fee2e2",
|
|
205
|
-
"red-3": "#fecaca",
|
|
206
|
-
"red-4": "#fca5a5",
|
|
207
|
-
"red-5": "#f87171",
|
|
208
|
-
"red-6": "#ef4444",
|
|
209
|
-
"red-7": "#dc2626",
|
|
210
|
-
"red-8": "#b91c1c",
|
|
211
|
-
"red-9": "#991b1b",
|
|
212
|
-
"rose-1": "#fff1f2",
|
|
213
|
-
"rose-10": "#881337",
|
|
214
|
-
"rose-11": "#4c0519",
|
|
215
|
-
"rose-12": "#2d030e",
|
|
216
|
-
"rose-2": "#ffe4e6",
|
|
217
|
-
"rose-3": "#fecdd3",
|
|
218
|
-
"rose-4": "#fda4af",
|
|
219
|
-
"rose-5": "#fb7185",
|
|
220
|
-
"rose-6": "#f43f5e",
|
|
221
|
-
"rose-7": "#e11d48",
|
|
222
|
-
"rose-8": "#be123c",
|
|
223
|
-
"rose-9": "#9f1239",
|
|
224
|
-
"silver": "#c0c0c0",
|
|
225
|
-
"sky-1": "#f0f9ff",
|
|
226
|
-
"sky-10": "#0c4a6e",
|
|
227
|
-
"sky-11": "#082f49",
|
|
228
|
-
"sky-12": "#041b2b",
|
|
229
|
-
"sky-2": "#e0f2fe",
|
|
230
|
-
"sky-3": "#bae6fd",
|
|
231
|
-
"sky-4": "#7dd3fc",
|
|
232
|
-
"sky-5": "#38bdf8",
|
|
233
|
-
"sky-6": "#0ea5e9",
|
|
234
|
-
"sky-7": "#0284c7",
|
|
235
|
-
"sky-8": "#0369a1",
|
|
236
|
-
"sky-9": "#075985",
|
|
237
|
-
"slate-1": "#f8fafc",
|
|
238
|
-
"slate-10": "#0f172a",
|
|
239
|
-
"slate-11": "#020617",
|
|
240
|
-
"slate-12": "#01020a",
|
|
241
|
-
"slate-2": "#f1f5f9",
|
|
242
|
-
"slate-3": "#e2e8f0",
|
|
243
|
-
"slate-4": "#cbd5e1",
|
|
244
|
-
"slate-5": "#94a3b8",
|
|
245
|
-
"slate-6": "#64748b",
|
|
246
|
-
"slate-7": "#475569",
|
|
247
|
-
"slate-8": "#334155",
|
|
248
|
-
"slate-9": "#1e293b",
|
|
249
|
-
"stone-1": "#fafaf9",
|
|
250
|
-
"stone-10": "#1c1917",
|
|
251
|
-
"stone-11": "#0c0a09",
|
|
252
|
-
"stone-12": "#070605",
|
|
253
|
-
"stone-2": "#f5f5f4",
|
|
254
|
-
"stone-3": "#e7e5e4",
|
|
255
|
-
"stone-4": "#d6d3d1",
|
|
256
|
-
"stone-5": "#a8a29e",
|
|
257
|
-
"stone-6": "#78716c",
|
|
258
|
-
"stone-7": "#57534e",
|
|
259
|
-
"stone-8": "#44403c",
|
|
260
|
-
"stone-9": "#292524",
|
|
261
|
-
"teal-1": "#f0fdfa",
|
|
262
|
-
"teal-10": "#134e4a",
|
|
263
|
-
"teal-11": "#042f2e",
|
|
264
|
-
"teal-12": "#021c1b",
|
|
265
|
-
"teal-2": "#ccfbf1",
|
|
266
|
-
"teal-3": "#99f6e4",
|
|
267
|
-
"teal-4": "#5eead4",
|
|
268
|
-
"teal-5": "#2dd4bf",
|
|
269
|
-
"teal-6": "#14b8a6",
|
|
270
|
-
"teal-7": "#0d9488",
|
|
271
|
-
"teal-8": "#0f766e",
|
|
272
|
-
"teal-9": "#115e59",
|
|
273
|
-
"transparent": "transparent",
|
|
274
|
-
"violet-1": "#f5f3ff",
|
|
275
|
-
"violet-10": "#4c1d95",
|
|
276
|
-
"violet-11": "#2e1065",
|
|
277
|
-
"violet-12": "#1c0a3d",
|
|
278
|
-
"violet-2": "#ede9fe",
|
|
279
|
-
"violet-3": "#ddd6fe",
|
|
280
|
-
"violet-4": "#c4b5fd",
|
|
281
|
-
"violet-5": "#a78bfa",
|
|
282
|
-
"violet-6": "#8b5cf6",
|
|
283
|
-
"violet-7": "#7c3aed",
|
|
284
|
-
"violet-8": "#6d28d9",
|
|
285
|
-
"violet-9": "#5b21b6",
|
|
286
|
-
"white": "#ffffff",
|
|
287
|
-
"yellow-1": "#fefce8",
|
|
288
|
-
"yellow-10": "#713f12",
|
|
289
|
-
"yellow-11": "#422006",
|
|
290
|
-
"yellow-12": "#271304",
|
|
291
|
-
"yellow-2": "#fef9c3",
|
|
292
|
-
"yellow-3": "#fef08a",
|
|
293
|
-
"yellow-4": "#fde047",
|
|
294
|
-
"yellow-5": "#facc15",
|
|
295
|
-
"yellow-6": "#eab308",
|
|
296
|
-
"yellow-7": "#ca8a04",
|
|
297
|
-
"yellow-8": "#a16207",
|
|
298
|
-
"yellow-9": "#854d0e",
|
|
299
|
-
"zinc-1": "#fafafa",
|
|
300
|
-
"zinc-10": "#18181b",
|
|
301
|
-
"zinc-11": "#09090b",
|
|
302
|
-
"zinc-12": "#050506",
|
|
303
|
-
"zinc-2": "#f4f4f5",
|
|
304
|
-
"zinc-3": "#e4e4e7",
|
|
305
|
-
"zinc-4": "#d4d4d8",
|
|
306
|
-
"zinc-5": "#a1a1aa",
|
|
307
|
-
"zinc-6": "#71717a",
|
|
308
|
-
"zinc-7": "#52525b",
|
|
309
|
-
"zinc-8": "#3f3f46",
|
|
310
|
-
"zinc-9": "#27272a"
|
|
36
|
+
// src/jsEngine/calc.ts
|
|
37
|
+
function reduceConstantMath(raw) {
|
|
38
|
+
const trimmed = raw.trim();
|
|
39
|
+
const calc = stripCall(trimmed, "calc");
|
|
40
|
+
if (calc !== null) {
|
|
41
|
+
return new Evaluator(calc).parseExprToEnd();
|
|
42
|
+
}
|
|
43
|
+
const clamp = stripCall(trimmed, "clamp");
|
|
44
|
+
if (clamp !== null) {
|
|
45
|
+
const args = splitTopLevelCommas(clamp);
|
|
46
|
+
if (args.length !== 3) return null;
|
|
47
|
+
const [min2, preferred, max2] = args.map((a) => new Evaluator(a).parseExprToEnd());
|
|
48
|
+
if (min2 === null || preferred === null || max2 === null) return null;
|
|
49
|
+
return Math.max(min2, Math.min(preferred, max2));
|
|
50
|
+
}
|
|
51
|
+
const min = stripCall(trimmed, "min");
|
|
52
|
+
if (min !== null) {
|
|
53
|
+
const values = splitTopLevelCommas(min).map((a) => new Evaluator(a).parseExprToEnd());
|
|
54
|
+
return values.some((v) => v === null) ? null : Math.min(...values);
|
|
55
|
+
}
|
|
56
|
+
const max = stripCall(trimmed, "max");
|
|
57
|
+
if (max !== null) {
|
|
58
|
+
const values = splitTopLevelCommas(max).map((a) => new Evaluator(a).parseExprToEnd());
|
|
59
|
+
return values.some((v) => v === null) ? null : Math.max(...values);
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
function stripCall(raw, name) {
|
|
64
|
+
if (!raw.startsWith(name)) return null;
|
|
65
|
+
const afterName = raw.slice(name.length).trimStart();
|
|
66
|
+
if (!afterName.startsWith("(") || !afterName.endsWith(")")) return null;
|
|
67
|
+
return afterName.slice(1, -1);
|
|
68
|
+
}
|
|
69
|
+
function splitTopLevelCommas(s) {
|
|
70
|
+
const parts = [];
|
|
71
|
+
let depth = 0;
|
|
72
|
+
let start = 0;
|
|
73
|
+
for (let i = 0; i < s.length; i++) {
|
|
74
|
+
const ch = s[i];
|
|
75
|
+
if (ch === "(") depth++;
|
|
76
|
+
else if (ch === ")") depth--;
|
|
77
|
+
else if (ch === "," && depth === 0) {
|
|
78
|
+
parts.push(s.slice(start, i).trim());
|
|
79
|
+
start = i + 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
parts.push(s.slice(start).trim());
|
|
83
|
+
return parts;
|
|
84
|
+
}
|
|
85
|
+
var Evaluator = class {
|
|
86
|
+
constructor(s) {
|
|
87
|
+
this.pos = 0;
|
|
88
|
+
this.s = s;
|
|
89
|
+
}
|
|
90
|
+
parseExprToEnd() {
|
|
91
|
+
const value = this.expr();
|
|
92
|
+
if (value === null) return null;
|
|
93
|
+
this.skipWs();
|
|
94
|
+
return this.pos === this.s.length ? value : null;
|
|
95
|
+
}
|
|
96
|
+
skipWs() {
|
|
97
|
+
while (this.pos < this.s.length && /\s/.test(this.s[this.pos])) this.pos++;
|
|
98
|
+
}
|
|
99
|
+
peek() {
|
|
100
|
+
this.skipWs();
|
|
101
|
+
return this.s[this.pos];
|
|
102
|
+
}
|
|
103
|
+
expr() {
|
|
104
|
+
let value = this.term();
|
|
105
|
+
if (value === null) return null;
|
|
106
|
+
for (; ; ) {
|
|
107
|
+
const ch = this.peek();
|
|
108
|
+
if (ch === "+") {
|
|
109
|
+
this.pos++;
|
|
110
|
+
const rhs = this.term();
|
|
111
|
+
if (rhs === null) return null;
|
|
112
|
+
value += rhs;
|
|
113
|
+
} else if (ch === "-") {
|
|
114
|
+
this.pos++;
|
|
115
|
+
const rhs = this.term();
|
|
116
|
+
if (rhs === null) return null;
|
|
117
|
+
value -= rhs;
|
|
118
|
+
} else {
|
|
119
|
+
return value;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
term() {
|
|
124
|
+
let value = this.factor();
|
|
125
|
+
if (value === null) return null;
|
|
126
|
+
for (; ; ) {
|
|
127
|
+
const ch = this.peek();
|
|
128
|
+
if (ch === "*") {
|
|
129
|
+
this.pos++;
|
|
130
|
+
const rhs = this.factor();
|
|
131
|
+
if (rhs === null) return null;
|
|
132
|
+
value *= rhs;
|
|
133
|
+
} else if (ch === "/") {
|
|
134
|
+
this.pos++;
|
|
135
|
+
const divisor = this.factor();
|
|
136
|
+
if (divisor === null || divisor === 0) return null;
|
|
137
|
+
value /= divisor;
|
|
138
|
+
} else {
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
factor() {
|
|
144
|
+
const ch = this.peek();
|
|
145
|
+
if (ch === void 0) return null;
|
|
146
|
+
if (ch === "(") {
|
|
147
|
+
this.pos++;
|
|
148
|
+
const value = this.expr();
|
|
149
|
+
if (value === null || this.peek() !== ")") return null;
|
|
150
|
+
this.pos++;
|
|
151
|
+
return value;
|
|
152
|
+
}
|
|
153
|
+
if (ch === "-") {
|
|
154
|
+
this.pos++;
|
|
155
|
+
const value = this.factor();
|
|
156
|
+
return value === null ? null : -value;
|
|
157
|
+
}
|
|
158
|
+
return this.numberWithUnit();
|
|
159
|
+
}
|
|
160
|
+
numberWithUnit() {
|
|
161
|
+
this.skipWs();
|
|
162
|
+
const start = this.pos;
|
|
163
|
+
while (this.pos < this.s.length && (/[0-9]/.test(this.s[this.pos]) || this.s[this.pos] === ".")) this.pos++;
|
|
164
|
+
if (this.pos === start) return null;
|
|
165
|
+
const n = Number(this.s.slice(start, this.pos));
|
|
166
|
+
if (!Number.isFinite(n)) return null;
|
|
167
|
+
const unitStart = this.pos;
|
|
168
|
+
while (this.pos < this.s.length && /[a-zA-Z]/.test(this.s[this.pos])) this.pos++;
|
|
169
|
+
const unit = this.s.slice(unitStart, this.pos);
|
|
170
|
+
switch (unit) {
|
|
171
|
+
case "":
|
|
172
|
+
return n;
|
|
173
|
+
case "px":
|
|
174
|
+
return n;
|
|
175
|
+
case "rem":
|
|
176
|
+
return n * 16;
|
|
177
|
+
default:
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
311
181
|
};
|
|
312
182
|
|
|
313
|
-
// src/
|
|
314
|
-
var
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
"
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
};
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
183
|
+
// src/layoutCalc.ts
|
|
184
|
+
var PERCENT_CALC_TOKEN_RE = /^(w|h)-\[calc\(([^)]+)\)\]$/;
|
|
185
|
+
function parsePercentRelativeCalc(token) {
|
|
186
|
+
const m = PERCENT_CALC_TOKEN_RE.exec(token);
|
|
187
|
+
if (!m) return null;
|
|
188
|
+
const property = m[1] === "w" ? "width" : "height";
|
|
189
|
+
const inner = m[2].replace(/_/g, " ").trim();
|
|
190
|
+
let mm = /^(-?[\d.]+)%\s*([+-])\s*(.+)$/.exec(inner);
|
|
191
|
+
if (mm) {
|
|
192
|
+
const percentCoefficient = Number(mm[1]);
|
|
193
|
+
const magnitude = reduceConstantMath(`calc(${mm[3].trim()})`);
|
|
194
|
+
if (!Number.isFinite(percentCoefficient) || magnitude === null) return null;
|
|
195
|
+
return { property, percentCoefficient, constantPx: mm[2] === "+" ? magnitude : -magnitude };
|
|
196
|
+
}
|
|
197
|
+
mm = /^(.+?)\s*([+-])\s*(-?[\d.]+)%$/.exec(inner);
|
|
198
|
+
if (mm) {
|
|
199
|
+
const constantPx = reduceConstantMath(`calc(${mm[1].trim()})`);
|
|
200
|
+
const percentMagnitude = Number(mm[3]);
|
|
201
|
+
if (constantPx === null || !Number.isFinite(percentMagnitude)) return null;
|
|
202
|
+
return { property, percentCoefficient: mm[2] === "+" ? percentMagnitude : -percentMagnitude, constantPx };
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
function resolvePercentRelativeCalc(basisPx, calc) {
|
|
207
|
+
return basisPx * calc.percentCoefficient / 100 + calc.constantPx;
|
|
333
208
|
}
|
|
334
209
|
|
|
335
|
-
// src/
|
|
336
|
-
var
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
}
|
|
344
|
-
var mode = "system";
|
|
345
|
-
var isDark = resolveIsDark(mode);
|
|
346
|
-
var subscription = import_react_native.Appearance.addChangeListener(({ colorScheme }) => {
|
|
347
|
-
if (mode !== "system") return;
|
|
348
|
-
isDark = colorScheme === "dark";
|
|
349
|
-
notify();
|
|
350
|
-
});
|
|
351
|
-
function notify() {
|
|
352
|
-
for (const listener of listeners) listener();
|
|
210
|
+
// src/jsxRuntimeCore.ts
|
|
211
|
+
var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
|
|
212
|
+
function substituteDynamicTokens(classStrRaw) {
|
|
213
|
+
if (!classStrRaw.includes("var(--")) return classStrRaw;
|
|
214
|
+
return classStrRaw.replace(DYNAMIC_TOKEN_MATCH_RE, (whole, name) => {
|
|
215
|
+
const value = (0, import_dynamicTokens.getDynamicToken)(name);
|
|
216
|
+
return value ?? whole;
|
|
217
|
+
});
|
|
353
218
|
}
|
|
354
|
-
|
|
355
|
-
|
|
219
|
+
var PERCENT_RELATIVE_CALC_HINT_RE = /[wh]-\[calc\([^)]*%[^)]*\)\]/;
|
|
220
|
+
function extractPercentRelativeCalcs(classStrRaw) {
|
|
221
|
+
const found = [];
|
|
222
|
+
for (const token of classStrRaw.split(/\s+/)) {
|
|
223
|
+
const parsed = parsePercentRelativeCalc(token);
|
|
224
|
+
if (parsed) found.push(parsed);
|
|
225
|
+
}
|
|
226
|
+
return found;
|
|
356
227
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
function resolveStyle(classString, pressed = false) {
|
|
360
|
-
const KbachModule = import_react_native2.TurboModuleRegistry.getEnforcing("KbachModule");
|
|
361
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
362
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed);
|
|
363
|
-
return JSON.parse(json);
|
|
228
|
+
function stripPercentRelativeCalcTokens(classStrRaw) {
|
|
229
|
+
return classStrRaw.split(/\s+/).filter((token) => token && parsePercentRelativeCalc(token) === null).join(" ");
|
|
364
230
|
}
|
|
365
|
-
|
|
366
|
-
// src/jsx-runtime.tsx
|
|
367
231
|
function makeElement(isStaticChildren, type, props, key) {
|
|
368
232
|
return (isStaticChildren ? import_jsx_runtime.jsxs : import_jsx_runtime.jsx)(type, props, key);
|
|
369
233
|
}
|
|
370
|
-
function resolvedStyleFor(classStrRaw, userStyle, pressed) {
|
|
371
|
-
const
|
|
234
|
+
function resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, pressed, layoutOverrides) {
|
|
235
|
+
const cleaned = stripPercentRelativeCalcTokens(substituteDynamicTokens(classStrRaw));
|
|
236
|
+
const resolved = resolveStyle2(cleaned, pressed);
|
|
237
|
+
if (layoutOverrides) {
|
|
238
|
+
Object.assign(resolved, layoutOverrides);
|
|
239
|
+
}
|
|
372
240
|
if (userStyle === void 0) {
|
|
373
241
|
return resolved;
|
|
374
242
|
}
|
|
@@ -377,7 +245,77 @@ function resolvedStyleFor(classStrRaw, userStyle, pressed) {
|
|
|
377
245
|
}
|
|
378
246
|
return [resolved, userStyle];
|
|
379
247
|
}
|
|
380
|
-
|
|
248
|
+
var DARK_MODIFIER_RE = /(^|\s)dark:/;
|
|
249
|
+
var BREAKPOINT_MODIFIER_RE = /(^|\s)(sm|md|lg|xl|2xl):/;
|
|
250
|
+
var BREAKPOINT_MODIFIER_MATCH_RE = /(?:^|\s)(sm|md|lg|xl|2xl):/g;
|
|
251
|
+
function darkModeKeySuffix(classStrRaw) {
|
|
252
|
+
return DARK_MODIFIER_RE.test(classStrRaw) ? `:kb-dark-${(0, import_darkModeStore.getGlobalDarkMode)()}` : "";
|
|
253
|
+
}
|
|
254
|
+
function breakpointKeySuffix(classStrRaw, width) {
|
|
255
|
+
const matches = classStrRaw.match(BREAKPOINT_MODIFIER_MATCH_RE);
|
|
256
|
+
if (!matches) {
|
|
257
|
+
return "";
|
|
258
|
+
}
|
|
259
|
+
const screens = (0, import_theme.getTheme)().screens;
|
|
260
|
+
const present = Array.from(new Set(matches.map((m) => m.trim().slice(0, -1))));
|
|
261
|
+
const state = present.map((name) => screens[name] !== void 0 && width >= screens[name] ? "1" : "0").join("");
|
|
262
|
+
return `:kb-bp-${state}`;
|
|
263
|
+
}
|
|
264
|
+
function dynamicTokenKeySuffix(classStrRaw) {
|
|
265
|
+
const matches = classStrRaw.match(DYNAMIC_TOKEN_MATCH_RE);
|
|
266
|
+
if (!matches) return "";
|
|
267
|
+
const values = matches.map((m) => (0, import_dynamicTokens.getDynamicToken)(m.slice("var(--".length, -1)) ?? "");
|
|
268
|
+
return `:kb-dt-${values.join("|")}`;
|
|
269
|
+
}
|
|
270
|
+
function percentCalcKeySuffix(percentCalcs, measuredBasis) {
|
|
271
|
+
if (percentCalcs.length === 0) return "";
|
|
272
|
+
const values = percentCalcs.map((calc) => {
|
|
273
|
+
const basis = measuredBasis?.[calc.property];
|
|
274
|
+
return basis === void 0 ? "pending" : resolvePercentRelativeCalc(basis, calc);
|
|
275
|
+
});
|
|
276
|
+
return `:kb-pc-${values.join("|")}`;
|
|
277
|
+
}
|
|
278
|
+
function ReactiveElement({
|
|
279
|
+
hostType,
|
|
280
|
+
hostRest,
|
|
281
|
+
classStrRaw,
|
|
282
|
+
userStyle,
|
|
283
|
+
resolveStyle: resolveStyle2,
|
|
284
|
+
elementKey,
|
|
285
|
+
isStaticChildren
|
|
286
|
+
}) {
|
|
287
|
+
(0, import_react.useSyncExternalStore)(import_darkModeStore.subscribeGlobalDarkMode, import_darkModeStore.getGlobalDarkMode);
|
|
288
|
+
(0, import_react.useSyncExternalStore)(import_dynamicTokens.subscribeDynamicTokens, import_dynamicTokens.getDynamicTokensVersion);
|
|
289
|
+
const { width } = (0, import_react_native.useWindowDimensions)();
|
|
290
|
+
const [measuredBasis, setMeasuredBasis] = (0, import_react.useState)(null);
|
|
291
|
+
const measure = (0, import_react.useCallback)((e) => {
|
|
292
|
+
const { width: w, height: h } = e.nativeEvent.layout;
|
|
293
|
+
setMeasuredBasis((prev) => prev && prev.width === w && prev.height === h ? prev : { width: w, height: h });
|
|
294
|
+
}, []);
|
|
295
|
+
const percentCalcs = extractPercentRelativeCalcs(classStrRaw);
|
|
296
|
+
let layoutOverrides;
|
|
297
|
+
let hostRestWithLayout = hostRest;
|
|
298
|
+
if (percentCalcs.length > 0) {
|
|
299
|
+
layoutOverrides = {};
|
|
300
|
+
for (const calc of percentCalcs) {
|
|
301
|
+
const basis = measuredBasis?.[calc.property];
|
|
302
|
+
layoutOverrides[calc.property] = basis === void 0 ? "100%" : resolvePercentRelativeCalc(basis, calc);
|
|
303
|
+
}
|
|
304
|
+
const userOnLayout = hostRest.onLayout;
|
|
305
|
+
hostRestWithLayout = {
|
|
306
|
+
...hostRest,
|
|
307
|
+
onLayout: userOnLayout ? (e) => {
|
|
308
|
+
measure(e);
|
|
309
|
+
userOnLayout(e);
|
|
310
|
+
} : measure
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const finalStyle = hostType === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed, layoutOverrides) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false, layoutOverrides);
|
|
314
|
+
const suffix = darkModeKeySuffix(classStrRaw) + breakpointKeySuffix(classStrRaw, width) + dynamicTokenKeySuffix(classStrRaw) + percentCalcKeySuffix(percentCalcs, measuredBasis);
|
|
315
|
+
const finalKey = suffix ? `${elementKey ?? ""}${suffix}` : elementKey;
|
|
316
|
+
return makeElement(isStaticChildren, hostType, { ...hostRestWithLayout, style: finalStyle }, finalKey);
|
|
317
|
+
}
|
|
318
|
+
function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
381
319
|
if (type === null || typeof type === "symbol" || !rawProps) {
|
|
382
320
|
return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
383
321
|
}
|
|
@@ -385,25 +323,1308 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
385
323
|
if (typeof classStrRaw !== "string") {
|
|
386
324
|
return makeElement(isStaticChildren, type, rawProps, key);
|
|
387
325
|
}
|
|
388
|
-
|
|
326
|
+
if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw) || classStrRaw.includes("var(--") || PERCENT_RELATIVE_CALC_HINT_RE.test(classStrRaw)) {
|
|
327
|
+
return (0, import_jsx_runtime.jsx)(
|
|
328
|
+
ReactiveElement,
|
|
329
|
+
{ hostType: type, hostRest: rest, classStrRaw, userStyle, resolveStyle: resolveStyle2, elementKey: key, isStaticChildren },
|
|
330
|
+
key
|
|
331
|
+
);
|
|
332
|
+
}
|
|
333
|
+
const finalStyle = type === import_react_native.Pressable ? (state) => resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, state.pressed) : resolvedStyleFor(resolveStyle2, classStrRaw, userStyle, false);
|
|
389
334
|
return makeElement(isStaticChildren, type, { ...rest, style: finalStyle }, key);
|
|
390
335
|
}
|
|
391
|
-
function
|
|
392
|
-
|
|
336
|
+
function createJsxFunctions(resolveStyle2) {
|
|
337
|
+
function jsx2(type, props, key) {
|
|
338
|
+
return processElement(resolveStyle2, type, props, key, false);
|
|
339
|
+
}
|
|
340
|
+
function jsxs2(type, props, key) {
|
|
341
|
+
return processElement(resolveStyle2, type, props, key, true);
|
|
342
|
+
}
|
|
343
|
+
return { jsx: jsx2, jsxs: jsxs2 };
|
|
393
344
|
}
|
|
394
|
-
function
|
|
395
|
-
return
|
|
345
|
+
function createJsxDEV(jsx2, jsxs2) {
|
|
346
|
+
return function jsxDEV2(type, props, key, isStaticChildren, source, self) {
|
|
347
|
+
const element = (isStaticChildren ? jsxs2 : jsx2)(type, props, key);
|
|
348
|
+
if (source && element && typeof element === "object" && Object.isExtensible(element)) {
|
|
349
|
+
element._source = source;
|
|
350
|
+
element._self = self;
|
|
351
|
+
}
|
|
352
|
+
return element;
|
|
353
|
+
};
|
|
396
354
|
}
|
|
397
355
|
|
|
398
|
-
// src/
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
356
|
+
// src/nativeBridge.ts
|
|
357
|
+
var import_react_native2 = require("react-native");
|
|
358
|
+
var import_theme2 = require("./theme");
|
|
359
|
+
var import_darkModeStore2 = require("./darkModeStore");
|
|
360
|
+
|
|
361
|
+
// src/jsEngine/parser.ts
|
|
362
|
+
var VALUE_PREFIXES = [
|
|
363
|
+
"bg-opacity-",
|
|
364
|
+
"text-opacity-",
|
|
365
|
+
"bg-blend-",
|
|
366
|
+
"text-shadow-",
|
|
367
|
+
"bg-",
|
|
368
|
+
"text-",
|
|
369
|
+
"border-x-",
|
|
370
|
+
"border-y-",
|
|
371
|
+
"border-t-",
|
|
372
|
+
"border-r-",
|
|
373
|
+
"border-b-",
|
|
374
|
+
"border-l-",
|
|
375
|
+
"border-",
|
|
376
|
+
"caret-",
|
|
377
|
+
"accent-",
|
|
378
|
+
"fill-",
|
|
379
|
+
"stroke-width-",
|
|
380
|
+
"stroke-",
|
|
381
|
+
"resize-",
|
|
382
|
+
"touch-",
|
|
383
|
+
"will-change-",
|
|
384
|
+
"scroll-mx-",
|
|
385
|
+
"scroll-my-",
|
|
386
|
+
"scroll-mt-",
|
|
387
|
+
"scroll-mr-",
|
|
388
|
+
"scroll-mb-",
|
|
389
|
+
"scroll-ml-",
|
|
390
|
+
"scroll-m-",
|
|
391
|
+
"scroll-px-",
|
|
392
|
+
"scroll-py-",
|
|
393
|
+
"scroll-pt-",
|
|
394
|
+
"scroll-pr-",
|
|
395
|
+
"scroll-pb-",
|
|
396
|
+
"scroll-pl-",
|
|
397
|
+
"scroll-p-",
|
|
398
|
+
"px-",
|
|
399
|
+
"py-",
|
|
400
|
+
"pt-",
|
|
401
|
+
"pr-",
|
|
402
|
+
"pb-",
|
|
403
|
+
"pl-",
|
|
404
|
+
"p-",
|
|
405
|
+
"mx-",
|
|
406
|
+
"my-",
|
|
407
|
+
"mt-",
|
|
408
|
+
"mr-",
|
|
409
|
+
"mb-",
|
|
410
|
+
"ml-",
|
|
411
|
+
"m-",
|
|
412
|
+
"gap-x-",
|
|
413
|
+
"gap-y-",
|
|
414
|
+
"gap-",
|
|
415
|
+
"min-w-",
|
|
416
|
+
"max-w-",
|
|
417
|
+
"w-",
|
|
418
|
+
"min-h-",
|
|
419
|
+
"max-h-",
|
|
420
|
+
"h-",
|
|
421
|
+
"size-",
|
|
422
|
+
"basis-",
|
|
423
|
+
"rounded-tl-",
|
|
424
|
+
"rounded-tr-",
|
|
425
|
+
"rounded-br-",
|
|
426
|
+
"rounded-bl-",
|
|
427
|
+
"rounded-t-",
|
|
428
|
+
"rounded-r-",
|
|
429
|
+
"rounded-b-",
|
|
430
|
+
"rounded-l-",
|
|
431
|
+
"rounded-",
|
|
432
|
+
"ring-offset-",
|
|
433
|
+
"ring-",
|
|
434
|
+
"outline-offset-",
|
|
435
|
+
"outline-",
|
|
436
|
+
"shadow-",
|
|
437
|
+
"opacity-",
|
|
438
|
+
"duration-",
|
|
439
|
+
"delay-",
|
|
440
|
+
"ease-",
|
|
441
|
+
"cursor-",
|
|
442
|
+
"mix-blend-",
|
|
443
|
+
"animate-",
|
|
444
|
+
"leading-",
|
|
445
|
+
"tracking-",
|
|
446
|
+
"font-",
|
|
447
|
+
"z-",
|
|
448
|
+
"inset-",
|
|
449
|
+
"top-",
|
|
450
|
+
"right-",
|
|
451
|
+
"bottom-",
|
|
452
|
+
"left-",
|
|
453
|
+
"divide-color-",
|
|
454
|
+
"space-x-",
|
|
455
|
+
"space-y-",
|
|
456
|
+
"flex-",
|
|
457
|
+
"grow-",
|
|
458
|
+
"shrink-",
|
|
459
|
+
"order-",
|
|
460
|
+
"grid-cols-",
|
|
461
|
+
"grid-rows-",
|
|
462
|
+
"grid-flow-",
|
|
463
|
+
"auto-cols-",
|
|
464
|
+
"auto-rows-",
|
|
465
|
+
"col-span-",
|
|
466
|
+
"col-start-",
|
|
467
|
+
"col-end-",
|
|
468
|
+
"col-",
|
|
469
|
+
"row-span-",
|
|
470
|
+
"row-start-",
|
|
471
|
+
"row-end-",
|
|
472
|
+
"row-",
|
|
473
|
+
"place-items-",
|
|
474
|
+
"place-content-",
|
|
475
|
+
"place-self-",
|
|
476
|
+
"justify-items-",
|
|
477
|
+
"justify-self-",
|
|
478
|
+
"scale-x-",
|
|
479
|
+
"scale-y-",
|
|
480
|
+
"scale-",
|
|
481
|
+
"rotate-",
|
|
482
|
+
"translate-x-",
|
|
483
|
+
"translate-y-",
|
|
484
|
+
"skew-x-",
|
|
485
|
+
"skew-y-",
|
|
486
|
+
"origin-",
|
|
487
|
+
"blur-",
|
|
488
|
+
"brightness-",
|
|
489
|
+
"contrast-",
|
|
490
|
+
"grayscale-",
|
|
491
|
+
"hue-rotate-",
|
|
492
|
+
"invert-",
|
|
493
|
+
"saturate-",
|
|
494
|
+
"sepia-",
|
|
495
|
+
"drop-shadow-",
|
|
496
|
+
"filter-",
|
|
497
|
+
"backdrop-blur-",
|
|
498
|
+
"backdrop-brightness-",
|
|
499
|
+
"backdrop-contrast-",
|
|
500
|
+
"backdrop-grayscale-",
|
|
501
|
+
"backdrop-hue-rotate-",
|
|
502
|
+
"backdrop-invert-",
|
|
503
|
+
"backdrop-opacity-",
|
|
504
|
+
"backdrop-saturate-",
|
|
505
|
+
"backdrop-sepia-",
|
|
506
|
+
"backdrop-filter-",
|
|
507
|
+
"decoration-",
|
|
508
|
+
"underline-offset-",
|
|
509
|
+
"indent-",
|
|
510
|
+
"from-",
|
|
511
|
+
"via-",
|
|
512
|
+
"to-"
|
|
513
|
+
];
|
|
514
|
+
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
515
|
+
function isSafeArbitraryValue(value) {
|
|
516
|
+
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
517
|
+
}
|
|
518
|
+
function splitRespectingBrackets(token) {
|
|
519
|
+
const parts = [];
|
|
520
|
+
let depth = 0;
|
|
521
|
+
let start = 0;
|
|
522
|
+
for (let i = 0; i < token.length; i++) {
|
|
523
|
+
const ch = token[i];
|
|
524
|
+
if (ch === "[") depth += 1;
|
|
525
|
+
else if (ch === "]") depth -= 1;
|
|
526
|
+
else if (ch === ":" && depth <= 0) {
|
|
527
|
+
parts.push(token.slice(start, i));
|
|
528
|
+
start = i + 1;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
parts.push(token.slice(start));
|
|
532
|
+
return parts;
|
|
533
|
+
}
|
|
534
|
+
function parseClass(token) {
|
|
535
|
+
const parts = splitRespectingBrackets(token);
|
|
536
|
+
let base = parts.pop() ?? token;
|
|
537
|
+
const modifiers = parts;
|
|
538
|
+
const important = base.startsWith("!");
|
|
539
|
+
if (important) {
|
|
540
|
+
base = base.slice(1);
|
|
541
|
+
}
|
|
542
|
+
const negative = base.startsWith("-");
|
|
543
|
+
if (negative) {
|
|
544
|
+
base = base.slice(1);
|
|
545
|
+
}
|
|
546
|
+
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
547
|
+
const raw = base.slice(1, -1);
|
|
548
|
+
const colonIdx = raw.indexOf(":");
|
|
549
|
+
if (colonIdx !== -1) {
|
|
550
|
+
const property = raw.slice(0, colonIdx);
|
|
551
|
+
const rawValue = raw.slice(colonIdx + 1);
|
|
552
|
+
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
553
|
+
const value = rawValue.replace(/_/g, " ");
|
|
554
|
+
return {
|
|
555
|
+
modifiers,
|
|
556
|
+
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
557
|
+
value: `${property}:${value}`,
|
|
558
|
+
isArbitrary: true,
|
|
559
|
+
important,
|
|
560
|
+
negative,
|
|
561
|
+
original: token
|
|
562
|
+
};
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
for (const prefix of VALUE_PREFIXES) {
|
|
567
|
+
if (!base.startsWith(prefix)) continue;
|
|
568
|
+
const value = base.slice(prefix.length);
|
|
569
|
+
if (value === "") continue;
|
|
570
|
+
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
571
|
+
const raw = value.slice(1, -1);
|
|
572
|
+
if (!isSafeArbitraryValue(raw)) {
|
|
573
|
+
continue;
|
|
574
|
+
}
|
|
575
|
+
const spaced = raw.replace(/_/g, " ");
|
|
576
|
+
return {
|
|
577
|
+
modifiers,
|
|
578
|
+
utility: prefix.slice(0, -1),
|
|
579
|
+
value: spaced,
|
|
580
|
+
isArbitrary: true,
|
|
581
|
+
important,
|
|
582
|
+
negative,
|
|
583
|
+
original: token
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
modifiers,
|
|
588
|
+
utility: prefix.slice(0, -1),
|
|
589
|
+
value,
|
|
590
|
+
isArbitrary: false,
|
|
591
|
+
important,
|
|
592
|
+
negative,
|
|
593
|
+
original: token
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
return {
|
|
597
|
+
modifiers,
|
|
598
|
+
utility: base,
|
|
599
|
+
value: null,
|
|
600
|
+
isArbitrary: false,
|
|
601
|
+
important,
|
|
602
|
+
negative,
|
|
603
|
+
original: token
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
// src/jsEngine/shared.ts
|
|
608
|
+
function decl(property, value) {
|
|
609
|
+
return { property, value };
|
|
610
|
+
}
|
|
611
|
+
function spacingPx(theme, value) {
|
|
612
|
+
const fromTable = theme.spacing[value];
|
|
613
|
+
if (fromTable !== void 0) return fromTable;
|
|
614
|
+
const n = Number(value);
|
|
615
|
+
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
616
|
+
}
|
|
617
|
+
function resolveLength(theme, parsed) {
|
|
618
|
+
if (parsed.negative) return null;
|
|
619
|
+
const value = parsed.value;
|
|
620
|
+
if (value === null) return null;
|
|
621
|
+
if (parsed.isArbitrary) return value;
|
|
622
|
+
if (value === "full") return "100%";
|
|
623
|
+
if (value === "auto") return "auto";
|
|
624
|
+
const px = spacingPx(theme, value);
|
|
625
|
+
return px === void 0 ? null : `${px}px`;
|
|
626
|
+
}
|
|
627
|
+
function resolveNegatableLength(theme, parsed) {
|
|
628
|
+
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
629
|
+
if (parsed.isArbitrary) return null;
|
|
630
|
+
const value = parsed.value;
|
|
631
|
+
if (value === null) return null;
|
|
632
|
+
const px = spacingPx(theme, value);
|
|
633
|
+
if (px === void 0) return null;
|
|
634
|
+
if (px === 0) return "0px";
|
|
635
|
+
return `-${px}px`;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// src/jsEngine/resolvers/layout.ts
|
|
639
|
+
function negateRaw(value, negative) {
|
|
640
|
+
return negative ? `-${value}` : value;
|
|
641
|
+
}
|
|
642
|
+
function resolve(parsed, theme) {
|
|
643
|
+
switch (parsed.utility) {
|
|
644
|
+
case "flex":
|
|
645
|
+
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
646
|
+
case "grid":
|
|
647
|
+
return [decl("display", "grid")];
|
|
648
|
+
case "block":
|
|
649
|
+
return [decl("display", "block")];
|
|
650
|
+
case "inline-block":
|
|
651
|
+
return [decl("display", "inline-block")];
|
|
652
|
+
case "inline":
|
|
653
|
+
return [decl("display", "inline")];
|
|
654
|
+
case "inline-flex":
|
|
655
|
+
return [decl("display", "inline-flex")];
|
|
656
|
+
case "inline-grid":
|
|
657
|
+
return [decl("display", "inline-grid")];
|
|
658
|
+
case "contents":
|
|
659
|
+
return [decl("display", "contents")];
|
|
660
|
+
case "flow-root":
|
|
661
|
+
return [decl("display", "flow-root")];
|
|
662
|
+
case "hidden":
|
|
663
|
+
return [decl("display", "none")];
|
|
664
|
+
case "@container":
|
|
665
|
+
return [decl("container-type", "inline-size")];
|
|
666
|
+
case "items-center":
|
|
667
|
+
return [decl("align-items", "center")];
|
|
668
|
+
case "items-start":
|
|
669
|
+
return [decl("align-items", "flex-start")];
|
|
670
|
+
case "items-end":
|
|
671
|
+
return [decl("align-items", "flex-end")];
|
|
672
|
+
case "items-baseline":
|
|
673
|
+
return [decl("align-items", "baseline")];
|
|
674
|
+
case "items-stretch":
|
|
675
|
+
return [decl("align-items", "stretch")];
|
|
676
|
+
case "justify-center":
|
|
677
|
+
return [decl("justify-content", "center")];
|
|
678
|
+
case "justify-start":
|
|
679
|
+
return [decl("justify-content", "flex-start")];
|
|
680
|
+
case "justify-end":
|
|
681
|
+
return [decl("justify-content", "flex-end")];
|
|
682
|
+
case "justify-between":
|
|
683
|
+
return [decl("justify-content", "space-between")];
|
|
684
|
+
case "justify-around":
|
|
685
|
+
return [decl("justify-content", "space-around")];
|
|
686
|
+
case "justify-evenly":
|
|
687
|
+
return [decl("justify-content", "space-evenly")];
|
|
688
|
+
case "content-start":
|
|
689
|
+
return [decl("align-content", "flex-start")];
|
|
690
|
+
case "content-end":
|
|
691
|
+
return [decl("align-content", "flex-end")];
|
|
692
|
+
case "content-center":
|
|
693
|
+
return [decl("align-content", "center")];
|
|
694
|
+
case "content-between":
|
|
695
|
+
return [decl("align-content", "space-between")];
|
|
696
|
+
case "content-around":
|
|
697
|
+
return [decl("align-content", "space-around")];
|
|
698
|
+
case "content-evenly":
|
|
699
|
+
return [decl("align-content", "space-evenly")];
|
|
700
|
+
case "content-stretch":
|
|
701
|
+
return [decl("align-content", "stretch")];
|
|
702
|
+
case "self-auto":
|
|
703
|
+
return [decl("align-self", "auto")];
|
|
704
|
+
case "self-center":
|
|
705
|
+
return [decl("align-self", "center")];
|
|
706
|
+
case "self-start":
|
|
707
|
+
return [decl("align-self", "flex-start")];
|
|
708
|
+
case "self-end":
|
|
709
|
+
return [decl("align-self", "flex-end")];
|
|
710
|
+
case "self-stretch":
|
|
711
|
+
return [decl("align-self", "stretch")];
|
|
712
|
+
case "self-baseline":
|
|
713
|
+
return [decl("align-self", "baseline")];
|
|
714
|
+
case "overflow-hidden":
|
|
715
|
+
return [decl("overflow", "hidden")];
|
|
716
|
+
case "overflow-auto":
|
|
717
|
+
return [decl("overflow", "auto")];
|
|
718
|
+
case "overflow-scroll":
|
|
719
|
+
return [decl("overflow", "scroll")];
|
|
720
|
+
case "overflow-visible":
|
|
721
|
+
return [decl("overflow", "visible")];
|
|
722
|
+
case "static":
|
|
723
|
+
return [decl("position", "static")];
|
|
724
|
+
case "relative":
|
|
725
|
+
return [decl("position", "relative")];
|
|
726
|
+
case "absolute":
|
|
727
|
+
return [decl("position", "absolute")];
|
|
728
|
+
case "fixed":
|
|
729
|
+
return [decl("position", "fixed")];
|
|
730
|
+
case "sticky":
|
|
731
|
+
return [decl("position", "sticky")];
|
|
732
|
+
case "z":
|
|
733
|
+
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
734
|
+
case "order":
|
|
735
|
+
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
736
|
+
case "grow":
|
|
737
|
+
return [decl("flex-grow", parsed.value ?? "1")];
|
|
738
|
+
case "shrink":
|
|
739
|
+
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
740
|
+
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
741
|
+
// convention ("-top-4") — see resolveNegatableLength's own doc comment.
|
|
742
|
+
case "top": {
|
|
743
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
744
|
+
return v === null ? null : [decl("top", v)];
|
|
745
|
+
}
|
|
746
|
+
case "right": {
|
|
747
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
748
|
+
return v === null ? null : [decl("right", v)];
|
|
749
|
+
}
|
|
750
|
+
case "bottom": {
|
|
751
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
752
|
+
return v === null ? null : [decl("bottom", v)];
|
|
753
|
+
}
|
|
754
|
+
case "left": {
|
|
755
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
756
|
+
return v === null ? null : [decl("left", v)];
|
|
757
|
+
}
|
|
758
|
+
case "inset": {
|
|
759
|
+
const v = resolveNegatableLength(theme, parsed);
|
|
760
|
+
return v === null ? null : [decl("inset", v)];
|
|
761
|
+
}
|
|
762
|
+
case "aspect-square":
|
|
763
|
+
return [decl("aspect-ratio", "1 / 1")];
|
|
764
|
+
case "aspect-video":
|
|
765
|
+
return [decl("aspect-ratio", "16 / 9")];
|
|
766
|
+
default:
|
|
767
|
+
return null;
|
|
404
768
|
}
|
|
405
|
-
return element;
|
|
406
769
|
}
|
|
770
|
+
function resolveFlex(parsed, web) {
|
|
771
|
+
if (parsed.utility !== "flex") return null;
|
|
772
|
+
const value = parsed.value;
|
|
773
|
+
if (value === null) return null;
|
|
774
|
+
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
775
|
+
switch (value) {
|
|
776
|
+
case "row":
|
|
777
|
+
return [decl("flex-direction", "row")];
|
|
778
|
+
case "col":
|
|
779
|
+
return [decl("flex-direction", "column")];
|
|
780
|
+
case "row-reverse":
|
|
781
|
+
return [decl("flex-direction", "row-reverse")];
|
|
782
|
+
case "col-reverse":
|
|
783
|
+
return [decl("flex-direction", "column-reverse")];
|
|
784
|
+
case "wrap":
|
|
785
|
+
return [decl("flex-wrap", "wrap")];
|
|
786
|
+
case "wrap-reverse":
|
|
787
|
+
return [decl("flex-wrap", "wrap-reverse")];
|
|
788
|
+
case "nowrap":
|
|
789
|
+
return [decl("flex-wrap", "nowrap")];
|
|
790
|
+
case "1":
|
|
791
|
+
return [decl("flex", "1")];
|
|
792
|
+
case "auto":
|
|
793
|
+
return [decl("flex", web ? "auto" : "1")];
|
|
794
|
+
case "initial":
|
|
795
|
+
return [decl("flex", web ? "initial" : "1")];
|
|
796
|
+
case "none":
|
|
797
|
+
return [decl("flex", web ? "none" : "0")];
|
|
798
|
+
case "grow":
|
|
799
|
+
return [decl("flex-grow", "1")];
|
|
800
|
+
case "grow-0":
|
|
801
|
+
return [decl("flex-grow", "0")];
|
|
802
|
+
case "shrink":
|
|
803
|
+
return [decl("flex-shrink", "1")];
|
|
804
|
+
case "shrink-0":
|
|
805
|
+
return [decl("flex-shrink", "0")];
|
|
806
|
+
default:
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// src/jsEngine/resolvers/spacing.ts
|
|
812
|
+
function namedSize(key) {
|
|
813
|
+
switch (key) {
|
|
814
|
+
case "sm":
|
|
815
|
+
return "24rem";
|
|
816
|
+
case "md":
|
|
817
|
+
return "28rem";
|
|
818
|
+
case "lg":
|
|
819
|
+
return "32rem";
|
|
820
|
+
case "xl":
|
|
821
|
+
return "36rem";
|
|
822
|
+
case "2xl":
|
|
823
|
+
return "42rem";
|
|
824
|
+
case "3xl":
|
|
825
|
+
return "48rem";
|
|
826
|
+
case "4xl":
|
|
827
|
+
return "56rem";
|
|
828
|
+
case "5xl":
|
|
829
|
+
return "64rem";
|
|
830
|
+
case "6xl":
|
|
831
|
+
return "72rem";
|
|
832
|
+
case "7xl":
|
|
833
|
+
return "80rem";
|
|
834
|
+
case "8xl":
|
|
835
|
+
return "88rem";
|
|
836
|
+
case "9xl":
|
|
837
|
+
return "96rem";
|
|
838
|
+
default:
|
|
839
|
+
return null;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
function fractionPercent(value) {
|
|
843
|
+
const slashIdx = value.indexOf("/");
|
|
844
|
+
if (slashIdx === -1) return null;
|
|
845
|
+
const numStr = value.slice(0, slashIdx);
|
|
846
|
+
const denStr = value.slice(slashIdx + 1);
|
|
847
|
+
const num = Number(numStr);
|
|
848
|
+
const den = Number(denStr);
|
|
849
|
+
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
850
|
+
if (den === 0) return null;
|
|
851
|
+
const pct = num / den * 100;
|
|
852
|
+
const formatted = pct.toFixed(6);
|
|
853
|
+
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
854
|
+
return `${trimmed}%`;
|
|
855
|
+
}
|
|
856
|
+
function cssSizeKeyword(key) {
|
|
857
|
+
switch (key) {
|
|
858
|
+
case "min":
|
|
859
|
+
return "min-content";
|
|
860
|
+
case "max":
|
|
861
|
+
return "max-content";
|
|
862
|
+
case "fit":
|
|
863
|
+
return "fit-content";
|
|
864
|
+
default:
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
function resolveSize(theme, parsed) {
|
|
869
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
870
|
+
const named = namedSize(parsed.value);
|
|
871
|
+
if (named !== null) return named;
|
|
872
|
+
const kw = cssSizeKeyword(parsed.value);
|
|
873
|
+
if (kw !== null) return kw;
|
|
874
|
+
const fraction = fractionPercent(parsed.value);
|
|
875
|
+
if (fraction !== null) return fraction;
|
|
876
|
+
}
|
|
877
|
+
return resolveLength(theme, parsed);
|
|
878
|
+
}
|
|
879
|
+
function resolve2(parsed, theme) {
|
|
880
|
+
const length = () => resolveLength(theme, parsed);
|
|
881
|
+
const size = () => resolveSize(theme, parsed);
|
|
882
|
+
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
883
|
+
switch (parsed.utility) {
|
|
884
|
+
case "p": {
|
|
885
|
+
const v = length();
|
|
886
|
+
return v === null ? null : [decl("padding", v)];
|
|
887
|
+
}
|
|
888
|
+
case "px": {
|
|
889
|
+
const v = length();
|
|
890
|
+
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
891
|
+
}
|
|
892
|
+
case "py": {
|
|
893
|
+
const v = length();
|
|
894
|
+
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
895
|
+
}
|
|
896
|
+
case "pt": {
|
|
897
|
+
const v = length();
|
|
898
|
+
return v === null ? null : [decl("padding-top", v)];
|
|
899
|
+
}
|
|
900
|
+
case "pr": {
|
|
901
|
+
const v = length();
|
|
902
|
+
return v === null ? null : [decl("padding-right", v)];
|
|
903
|
+
}
|
|
904
|
+
case "pb": {
|
|
905
|
+
const v = length();
|
|
906
|
+
return v === null ? null : [decl("padding-bottom", v)];
|
|
907
|
+
}
|
|
908
|
+
case "pl": {
|
|
909
|
+
const v = length();
|
|
910
|
+
return v === null ? null : [decl("padding-left", v)];
|
|
911
|
+
}
|
|
912
|
+
case "m": {
|
|
913
|
+
const v = negatableLength();
|
|
914
|
+
return v === null ? null : [decl("margin", v)];
|
|
915
|
+
}
|
|
916
|
+
case "mx": {
|
|
917
|
+
const v = negatableLength();
|
|
918
|
+
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
919
|
+
}
|
|
920
|
+
case "my": {
|
|
921
|
+
const v = negatableLength();
|
|
922
|
+
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
923
|
+
}
|
|
924
|
+
case "mt": {
|
|
925
|
+
const v = negatableLength();
|
|
926
|
+
return v === null ? null : [decl("margin-top", v)];
|
|
927
|
+
}
|
|
928
|
+
case "mr": {
|
|
929
|
+
const v = negatableLength();
|
|
930
|
+
return v === null ? null : [decl("margin-right", v)];
|
|
931
|
+
}
|
|
932
|
+
case "mb": {
|
|
933
|
+
const v = negatableLength();
|
|
934
|
+
return v === null ? null : [decl("margin-bottom", v)];
|
|
935
|
+
}
|
|
936
|
+
case "ml": {
|
|
937
|
+
const v = negatableLength();
|
|
938
|
+
return v === null ? null : [decl("margin-left", v)];
|
|
939
|
+
}
|
|
940
|
+
case "gap": {
|
|
941
|
+
const v = length();
|
|
942
|
+
return v === null ? null : [decl("gap", v)];
|
|
943
|
+
}
|
|
944
|
+
case "gap-x": {
|
|
945
|
+
const v = length();
|
|
946
|
+
return v === null ? null : [decl("column-gap", v)];
|
|
947
|
+
}
|
|
948
|
+
case "gap-y": {
|
|
949
|
+
const v = length();
|
|
950
|
+
return v === null ? null : [decl("row-gap", v)];
|
|
951
|
+
}
|
|
952
|
+
case "w": {
|
|
953
|
+
const v = size();
|
|
954
|
+
return v === null ? null : [decl("width", v)];
|
|
955
|
+
}
|
|
956
|
+
case "h": {
|
|
957
|
+
const v = size();
|
|
958
|
+
return v === null ? null : [decl("height", v)];
|
|
959
|
+
}
|
|
960
|
+
case "min-w": {
|
|
961
|
+
const v = size();
|
|
962
|
+
return v === null ? null : [decl("min-width", v)];
|
|
963
|
+
}
|
|
964
|
+
case "max-w": {
|
|
965
|
+
const v = size();
|
|
966
|
+
return v === null ? null : [decl("max-width", v)];
|
|
967
|
+
}
|
|
968
|
+
case "min-h": {
|
|
969
|
+
const v = size();
|
|
970
|
+
return v === null ? null : [decl("min-height", v)];
|
|
971
|
+
}
|
|
972
|
+
case "max-h": {
|
|
973
|
+
const v = size();
|
|
974
|
+
return v === null ? null : [decl("max-height", v)];
|
|
975
|
+
}
|
|
976
|
+
case "size": {
|
|
977
|
+
const v = size();
|
|
978
|
+
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
979
|
+
}
|
|
980
|
+
case "basis": {
|
|
981
|
+
const v = size();
|
|
982
|
+
return v === null ? null : [decl("flex-basis", v)];
|
|
983
|
+
}
|
|
984
|
+
default:
|
|
985
|
+
return null;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
// src/jsEngine/resolvers/color.ts
|
|
990
|
+
function lookupHex(theme, key) {
|
|
991
|
+
const entry = theme.colors[key];
|
|
992
|
+
return typeof entry === "string" ? entry : null;
|
|
993
|
+
}
|
|
994
|
+
function hexToRgb(hex) {
|
|
995
|
+
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
996
|
+
if (!m) return null;
|
|
997
|
+
let h = m[1];
|
|
998
|
+
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
999
|
+
const n = parseInt(h, 16);
|
|
1000
|
+
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
1001
|
+
}
|
|
1002
|
+
function splitOpacity(value) {
|
|
1003
|
+
const slash = value.lastIndexOf("/");
|
|
1004
|
+
if (slash === -1) return [value, null];
|
|
1005
|
+
const opacityText = value.slice(slash + 1);
|
|
1006
|
+
const n = Number(opacityText);
|
|
1007
|
+
if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
|
|
1008
|
+
return [value.slice(0, slash), n];
|
|
1009
|
+
}
|
|
1010
|
+
return [value, null];
|
|
1011
|
+
}
|
|
1012
|
+
function colorValue(theme, parsed) {
|
|
1013
|
+
const value = parsed.value;
|
|
1014
|
+
if (value === null) return null;
|
|
1015
|
+
if (parsed.isArbitrary) return value;
|
|
1016
|
+
const [name, opacity] = splitOpacity(value);
|
|
1017
|
+
const hex = lookupHex(theme, name);
|
|
1018
|
+
if (hex === null) return null;
|
|
1019
|
+
if (opacity === null) return hex;
|
|
1020
|
+
const rgb = hexToRgb(hex);
|
|
1021
|
+
if (rgb === null) return hex;
|
|
1022
|
+
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
// src/jsEngine/resolvers/border.ts
|
|
1026
|
+
function radiusSize(key) {
|
|
1027
|
+
switch (key) {
|
|
1028
|
+
case "none":
|
|
1029
|
+
return "0px";
|
|
1030
|
+
case "sm":
|
|
1031
|
+
return "0.125rem";
|
|
1032
|
+
case "md":
|
|
1033
|
+
return "0.375rem";
|
|
1034
|
+
case "lg":
|
|
1035
|
+
return "0.5rem";
|
|
1036
|
+
case "xl":
|
|
1037
|
+
return "0.75rem";
|
|
1038
|
+
case "2xl":
|
|
1039
|
+
return "1rem";
|
|
1040
|
+
case "3xl":
|
|
1041
|
+
return "1.5rem";
|
|
1042
|
+
case "full":
|
|
1043
|
+
return "9999px";
|
|
1044
|
+
default:
|
|
1045
|
+
return null;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
function borderSideProperty(side) {
|
|
1049
|
+
switch (side) {
|
|
1050
|
+
case "t":
|
|
1051
|
+
return "border-top";
|
|
1052
|
+
case "r":
|
|
1053
|
+
return "border-right";
|
|
1054
|
+
case "b":
|
|
1055
|
+
return "border-bottom";
|
|
1056
|
+
case "l":
|
|
1057
|
+
return "border-left";
|
|
1058
|
+
default:
|
|
1059
|
+
return null;
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
function borderValue(theme, parsed) {
|
|
1063
|
+
const value = parsed.value;
|
|
1064
|
+
if (value === null) return null;
|
|
1065
|
+
if (!parsed.isArbitrary) {
|
|
1066
|
+
const side = borderSideProperty(value);
|
|
1067
|
+
if (side !== null) {
|
|
1068
|
+
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
1069
|
+
}
|
|
1070
|
+
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
1071
|
+
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
1072
|
+
}
|
|
1073
|
+
if (parsed.isArbitrary) {
|
|
1074
|
+
return [decl("border-width", value)];
|
|
1075
|
+
}
|
|
1076
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1077
|
+
const v = resolveLength(theme, parsed);
|
|
1078
|
+
return v === null ? null : [decl("border-width", v)];
|
|
1079
|
+
}
|
|
1080
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1081
|
+
return [decl("border-style", value)];
|
|
1082
|
+
}
|
|
1083
|
+
const color = colorValue(theme, parsed);
|
|
1084
|
+
return color === null ? null : [decl("border-color", color)];
|
|
1085
|
+
}
|
|
1086
|
+
function borderSideValue(theme, parsed, sideProperty) {
|
|
1087
|
+
const value = parsed.value;
|
|
1088
|
+
if (value === null) return null;
|
|
1089
|
+
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
1090
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1091
|
+
const v = resolveLength(theme, parsed);
|
|
1092
|
+
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
1093
|
+
}
|
|
1094
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1095
|
+
return [decl(`${sideProperty}-style`, value)];
|
|
1096
|
+
}
|
|
1097
|
+
const color = colorValue(theme, parsed);
|
|
1098
|
+
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
1099
|
+
}
|
|
1100
|
+
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
1101
|
+
const value = parsed.value;
|
|
1102
|
+
if (value === null) return null;
|
|
1103
|
+
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
1104
|
+
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
1105
|
+
const v = resolveLength(theme, parsed);
|
|
1106
|
+
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
1107
|
+
}
|
|
1108
|
+
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
1109
|
+
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
1110
|
+
}
|
|
1111
|
+
const color = colorValue(theme, parsed);
|
|
1112
|
+
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
1113
|
+
}
|
|
1114
|
+
function radiusProperties(side) {
|
|
1115
|
+
switch (side) {
|
|
1116
|
+
case "t":
|
|
1117
|
+
return ["border-top-left-radius", "border-top-right-radius"];
|
|
1118
|
+
case "r":
|
|
1119
|
+
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
1120
|
+
case "b":
|
|
1121
|
+
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
1122
|
+
case "l":
|
|
1123
|
+
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
1124
|
+
case "tl":
|
|
1125
|
+
return ["border-top-left-radius"];
|
|
1126
|
+
case "tr":
|
|
1127
|
+
return ["border-top-right-radius"];
|
|
1128
|
+
case "br":
|
|
1129
|
+
return ["border-bottom-right-radius"];
|
|
1130
|
+
case "bl":
|
|
1131
|
+
return ["border-bottom-left-radius"];
|
|
1132
|
+
default:
|
|
1133
|
+
return null;
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
function resolveRadiusValue(theme, parsed) {
|
|
1137
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1138
|
+
const size = radiusSize(parsed.value);
|
|
1139
|
+
if (size !== null) return size;
|
|
1140
|
+
}
|
|
1141
|
+
return resolveLength(theme, parsed);
|
|
1142
|
+
}
|
|
1143
|
+
function resolveRadiusSide(theme, parsed, side) {
|
|
1144
|
+
const properties = radiusProperties(side);
|
|
1145
|
+
if (properties === null) return null;
|
|
1146
|
+
const value = resolveRadiusValue(theme, parsed);
|
|
1147
|
+
if (value === null) return null;
|
|
1148
|
+
return properties.map((p) => decl(p, value));
|
|
1149
|
+
}
|
|
1150
|
+
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
1151
|
+
function outlineWidthValue(key) {
|
|
1152
|
+
switch (key) {
|
|
1153
|
+
case "0":
|
|
1154
|
+
return "0px";
|
|
1155
|
+
case "1":
|
|
1156
|
+
return "1px";
|
|
1157
|
+
case "2":
|
|
1158
|
+
return "2px";
|
|
1159
|
+
case "4":
|
|
1160
|
+
return "4px";
|
|
1161
|
+
case "8":
|
|
1162
|
+
return "8px";
|
|
1163
|
+
default:
|
|
1164
|
+
return null;
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
function outlineValue(theme, parsed) {
|
|
1168
|
+
const value = parsed.value;
|
|
1169
|
+
if (value === null) return null;
|
|
1170
|
+
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
1171
|
+
const w = outlineWidthValue(value);
|
|
1172
|
+
if (w !== null) return [decl("outline-width", w)];
|
|
1173
|
+
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
1174
|
+
const color = colorValue(theme, parsed);
|
|
1175
|
+
return color === null ? null : [decl("outline-color", color)];
|
|
1176
|
+
}
|
|
1177
|
+
function outlineOffsetValue(parsed) {
|
|
1178
|
+
const value = parsed.value;
|
|
1179
|
+
if (value === null) return null;
|
|
1180
|
+
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
1181
|
+
const w = outlineWidthValue(value);
|
|
1182
|
+
return w === null ? null : [decl("outline-offset", w)];
|
|
1183
|
+
}
|
|
1184
|
+
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))";
|
|
1185
|
+
function ringWidth(key) {
|
|
1186
|
+
switch (key) {
|
|
1187
|
+
case "0":
|
|
1188
|
+
return "0px";
|
|
1189
|
+
case "1":
|
|
1190
|
+
return "1px";
|
|
1191
|
+
case "2":
|
|
1192
|
+
return "2px";
|
|
1193
|
+
case "4":
|
|
1194
|
+
return "4px";
|
|
1195
|
+
case "8":
|
|
1196
|
+
return "8px";
|
|
1197
|
+
default:
|
|
1198
|
+
return null;
|
|
1199
|
+
}
|
|
1200
|
+
}
|
|
1201
|
+
function ringValue(theme, parsed) {
|
|
1202
|
+
const value = parsed.value;
|
|
1203
|
+
if (value === null) return null;
|
|
1204
|
+
if (value === "inset") {
|
|
1205
|
+
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1206
|
+
}
|
|
1207
|
+
if (!parsed.isArbitrary) {
|
|
1208
|
+
const w = ringWidth(value);
|
|
1209
|
+
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1210
|
+
}
|
|
1211
|
+
const color = colorValue(theme, parsed);
|
|
1212
|
+
if (color === null) return null;
|
|
1213
|
+
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1214
|
+
}
|
|
1215
|
+
function ringOffsetValue(theme, parsed) {
|
|
1216
|
+
const value = parsed.value;
|
|
1217
|
+
if (value === null) return null;
|
|
1218
|
+
if (!parsed.isArbitrary) {
|
|
1219
|
+
const w = ringWidth(value);
|
|
1220
|
+
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1221
|
+
}
|
|
1222
|
+
const color = colorValue(theme, parsed);
|
|
1223
|
+
if (color === null) return null;
|
|
1224
|
+
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1225
|
+
}
|
|
1226
|
+
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
1227
|
+
function resolve3(parsed, theme) {
|
|
1228
|
+
switch (parsed.utility) {
|
|
1229
|
+
case "border":
|
|
1230
|
+
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
1231
|
+
return borderValue(theme, parsed);
|
|
1232
|
+
case "border-t":
|
|
1233
|
+
return borderSideValue(theme, parsed, "border-top");
|
|
1234
|
+
case "border-r":
|
|
1235
|
+
return borderSideValue(theme, parsed, "border-right");
|
|
1236
|
+
case "border-b":
|
|
1237
|
+
return borderSideValue(theme, parsed, "border-bottom");
|
|
1238
|
+
case "border-l":
|
|
1239
|
+
return borderSideValue(theme, parsed, "border-left");
|
|
1240
|
+
case "border-x":
|
|
1241
|
+
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
1242
|
+
case "border-y":
|
|
1243
|
+
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
1244
|
+
case "rounded": {
|
|
1245
|
+
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
1246
|
+
const value = parsed.value;
|
|
1247
|
+
if (!parsed.isArbitrary) {
|
|
1248
|
+
const size = radiusSize(value);
|
|
1249
|
+
if (size !== null) return [decl("border-radius", size)];
|
|
1250
|
+
}
|
|
1251
|
+
const v = resolveLength(theme, parsed);
|
|
1252
|
+
return v === null ? null : [decl("border-radius", v)];
|
|
1253
|
+
}
|
|
1254
|
+
case "ring":
|
|
1255
|
+
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
1256
|
+
return ringValue(theme, parsed);
|
|
1257
|
+
case "ring-offset":
|
|
1258
|
+
return ringOffsetValue(theme, parsed);
|
|
1259
|
+
case "outline":
|
|
1260
|
+
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
1261
|
+
if (parsed.value === "none") return [decl("outline", "none")];
|
|
1262
|
+
return outlineValue(theme, parsed);
|
|
1263
|
+
case "outline-offset":
|
|
1264
|
+
return outlineOffsetValue(parsed);
|
|
1265
|
+
default:
|
|
1266
|
+
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
1267
|
+
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
1268
|
+
}
|
|
1269
|
+
return null;
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
|
|
1273
|
+
// src/jsEngine/resolvers/typography.ts
|
|
1274
|
+
function textSize(key) {
|
|
1275
|
+
switch (key) {
|
|
1276
|
+
case "xs":
|
|
1277
|
+
return "0.75rem";
|
|
1278
|
+
case "sm":
|
|
1279
|
+
return "0.875rem";
|
|
1280
|
+
case "base":
|
|
1281
|
+
return "1rem";
|
|
1282
|
+
case "lg":
|
|
1283
|
+
return "1.125rem";
|
|
1284
|
+
case "xl":
|
|
1285
|
+
return "1.25rem";
|
|
1286
|
+
case "2xl":
|
|
1287
|
+
return "1.5rem";
|
|
1288
|
+
case "3xl":
|
|
1289
|
+
return "1.875rem";
|
|
1290
|
+
case "4xl":
|
|
1291
|
+
return "2.25rem";
|
|
1292
|
+
default:
|
|
1293
|
+
return null;
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
function lineHeightSize(key) {
|
|
1297
|
+
switch (key) {
|
|
1298
|
+
case "3":
|
|
1299
|
+
return "0.75rem";
|
|
1300
|
+
case "4":
|
|
1301
|
+
return "1rem";
|
|
1302
|
+
case "5":
|
|
1303
|
+
return "1.25rem";
|
|
1304
|
+
case "6":
|
|
1305
|
+
return "1.5rem";
|
|
1306
|
+
case "7":
|
|
1307
|
+
return "1.75rem";
|
|
1308
|
+
case "8":
|
|
1309
|
+
return "2rem";
|
|
1310
|
+
case "9":
|
|
1311
|
+
return "2.25rem";
|
|
1312
|
+
case "10":
|
|
1313
|
+
return "2.5rem";
|
|
1314
|
+
default:
|
|
1315
|
+
return null;
|
|
1316
|
+
}
|
|
1317
|
+
}
|
|
1318
|
+
function textAlign(key) {
|
|
1319
|
+
switch (key) {
|
|
1320
|
+
case "left":
|
|
1321
|
+
return "left";
|
|
1322
|
+
case "center":
|
|
1323
|
+
return "center";
|
|
1324
|
+
case "right":
|
|
1325
|
+
return "right";
|
|
1326
|
+
case "justify":
|
|
1327
|
+
return "justify";
|
|
1328
|
+
default:
|
|
1329
|
+
return null;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
function fontWeight(key) {
|
|
1333
|
+
switch (key) {
|
|
1334
|
+
case "thin":
|
|
1335
|
+
return "100";
|
|
1336
|
+
case "normal":
|
|
1337
|
+
return "400";
|
|
1338
|
+
case "medium":
|
|
1339
|
+
return "500";
|
|
1340
|
+
case "semibold":
|
|
1341
|
+
return "600";
|
|
1342
|
+
case "bold":
|
|
1343
|
+
return "700";
|
|
1344
|
+
case "extrabold":
|
|
1345
|
+
return "800";
|
|
1346
|
+
default:
|
|
1347
|
+
return null;
|
|
1348
|
+
}
|
|
1349
|
+
}
|
|
1350
|
+
|
|
1351
|
+
// src/jsEngine/resolvers/effects.ts
|
|
1352
|
+
function nativeShadowValue(key) {
|
|
1353
|
+
switch (key) {
|
|
1354
|
+
case "sm":
|
|
1355
|
+
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1356
|
+
case "DEFAULT":
|
|
1357
|
+
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1358
|
+
case "md":
|
|
1359
|
+
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1360
|
+
case "lg":
|
|
1361
|
+
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1362
|
+
case "xl":
|
|
1363
|
+
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1364
|
+
case "2xl":
|
|
1365
|
+
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1366
|
+
case "none":
|
|
1367
|
+
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1368
|
+
default:
|
|
1369
|
+
return null;
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
function nativeShadowDeclarations(parsed) {
|
|
1373
|
+
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1374
|
+
const key = parsed.value ?? "DEFAULT";
|
|
1375
|
+
const s = nativeShadowValue(key);
|
|
1376
|
+
if (s === null) return null;
|
|
1377
|
+
return [
|
|
1378
|
+
decl("shadow-color", "#000000"),
|
|
1379
|
+
decl("shadow-offset-x", "0"),
|
|
1380
|
+
decl("shadow-offset-y", String(s.offsetY)),
|
|
1381
|
+
decl("shadow-opacity", String(s.opacity)),
|
|
1382
|
+
decl("shadow-radius", String(s.radius)),
|
|
1383
|
+
decl("elevation", String(s.elevation))
|
|
1384
|
+
];
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
// src/jsEngine/resolveUtilityNative.ts
|
|
1388
|
+
function resolveTypographyNative(parsed) {
|
|
1389
|
+
switch (parsed.utility) {
|
|
1390
|
+
case "font": {
|
|
1391
|
+
if (parsed.value === null) return null;
|
|
1392
|
+
const w = fontWeight(parsed.value);
|
|
1393
|
+
return w === null ? null : [decl("font-weight", w)];
|
|
1394
|
+
}
|
|
1395
|
+
case "uppercase":
|
|
1396
|
+
return [decl("text-transform", "uppercase")];
|
|
1397
|
+
case "lowercase":
|
|
1398
|
+
return [decl("text-transform", "lowercase")];
|
|
1399
|
+
case "capitalize":
|
|
1400
|
+
return [decl("text-transform", "capitalize")];
|
|
1401
|
+
case "underline":
|
|
1402
|
+
return [decl("text-decoration-line", "underline")];
|
|
1403
|
+
case "line-through":
|
|
1404
|
+
return [decl("text-decoration-line", "line-through")];
|
|
1405
|
+
case "no-underline":
|
|
1406
|
+
return [decl("text-decoration-line", "none")];
|
|
1407
|
+
case "italic":
|
|
1408
|
+
return [decl("font-style", "italic")];
|
|
1409
|
+
case "not-italic":
|
|
1410
|
+
return [decl("font-style", "normal")];
|
|
1411
|
+
default:
|
|
1412
|
+
return null;
|
|
1413
|
+
}
|
|
1414
|
+
}
|
|
1415
|
+
function resolveLeadingTrackingNative(parsed) {
|
|
1416
|
+
const value = parsed.value;
|
|
1417
|
+
if (value === null) return null;
|
|
1418
|
+
if (parsed.utility === "leading") {
|
|
1419
|
+
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1420
|
+
const v = lineHeightSize(value);
|
|
1421
|
+
return v === null ? null : [decl("line-height", v)];
|
|
1422
|
+
}
|
|
1423
|
+
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1424
|
+
return [decl("letter-spacing", value)];
|
|
1425
|
+
}
|
|
1426
|
+
return null;
|
|
1427
|
+
}
|
|
1428
|
+
function nativeHexColor(parsed, theme) {
|
|
1429
|
+
return colorValue(theme, parsed);
|
|
1430
|
+
}
|
|
1431
|
+
function resolveTextNative(parsed, theme) {
|
|
1432
|
+
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1433
|
+
const size = textSize(parsed.value);
|
|
1434
|
+
if (size !== null) return [decl("font-size", size)];
|
|
1435
|
+
const align = textAlign(parsed.value);
|
|
1436
|
+
if (align !== null) return [decl("text-align", align)];
|
|
1437
|
+
}
|
|
1438
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1439
|
+
return hex === null ? null : [decl("color", hex)];
|
|
1440
|
+
}
|
|
1441
|
+
function resolveColorNative(parsed, theme) {
|
|
1442
|
+
switch (parsed.utility) {
|
|
1443
|
+
case "bg": {
|
|
1444
|
+
const hex = nativeHexColor(parsed, theme);
|
|
1445
|
+
return hex === null ? null : [decl("background-color", hex)];
|
|
1446
|
+
}
|
|
1447
|
+
case "text":
|
|
1448
|
+
return resolveTextNative(parsed, theme);
|
|
1449
|
+
default:
|
|
1450
|
+
return null;
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
function resolveUtilityNative(parsed, theme) {
|
|
1454
|
+
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// src/jsEngine/resolveStyle.ts
|
|
1458
|
+
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1459
|
+
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1460
|
+
if (modifier === "dark") return colorScheme === "dark";
|
|
1461
|
+
if (modifier === "active") return pressed;
|
|
1462
|
+
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1463
|
+
const minWidth = theme.screens[modifier];
|
|
1464
|
+
if (minWidth === void 0) return null;
|
|
1465
|
+
return width >= minWidth;
|
|
1466
|
+
}
|
|
1467
|
+
return null;
|
|
1468
|
+
}
|
|
1469
|
+
function kebabToCamel(s) {
|
|
1470
|
+
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1471
|
+
}
|
|
1472
|
+
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1473
|
+
"padding",
|
|
1474
|
+
"padding-top",
|
|
1475
|
+
"padding-right",
|
|
1476
|
+
"padding-bottom",
|
|
1477
|
+
"padding-left",
|
|
1478
|
+
"margin",
|
|
1479
|
+
"margin-top",
|
|
1480
|
+
"margin-right",
|
|
1481
|
+
"margin-bottom",
|
|
1482
|
+
"margin-left",
|
|
1483
|
+
"gap",
|
|
1484
|
+
"column-gap",
|
|
1485
|
+
"row-gap",
|
|
1486
|
+
"width",
|
|
1487
|
+
"height",
|
|
1488
|
+
"min-width",
|
|
1489
|
+
"max-width",
|
|
1490
|
+
"min-height",
|
|
1491
|
+
"max-height",
|
|
1492
|
+
"top",
|
|
1493
|
+
"right",
|
|
1494
|
+
"bottom",
|
|
1495
|
+
"left",
|
|
1496
|
+
"inset",
|
|
1497
|
+
"border-radius",
|
|
1498
|
+
"border-width",
|
|
1499
|
+
"font-size",
|
|
1500
|
+
"z-index",
|
|
1501
|
+
"line-height",
|
|
1502
|
+
"letter-spacing",
|
|
1503
|
+
"flex",
|
|
1504
|
+
"flex-grow",
|
|
1505
|
+
"flex-shrink",
|
|
1506
|
+
"order",
|
|
1507
|
+
"flex-basis",
|
|
1508
|
+
"shadow-opacity",
|
|
1509
|
+
"shadow-radius",
|
|
1510
|
+
"elevation",
|
|
1511
|
+
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1512
|
+
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1513
|
+
// style system wants plain numbers for these exactly like the generic
|
|
1514
|
+
// "border-width"/"border-radius" forms above.
|
|
1515
|
+
"border-top-width",
|
|
1516
|
+
"border-right-width",
|
|
1517
|
+
"border-bottom-width",
|
|
1518
|
+
"border-left-width",
|
|
1519
|
+
"border-top-left-radius",
|
|
1520
|
+
"border-top-right-radius",
|
|
1521
|
+
"border-bottom-right-radius",
|
|
1522
|
+
"border-bottom-left-radius",
|
|
1523
|
+
"outline-width",
|
|
1524
|
+
"outline-offset"
|
|
1525
|
+
]);
|
|
1526
|
+
function isPlainPercentage(value) {
|
|
1527
|
+
if (!value.endsWith("%")) return false;
|
|
1528
|
+
let digits = value.slice(0, -1);
|
|
1529
|
+
if (digits.startsWith("-")) digits = digits.slice(1);
|
|
1530
|
+
return digits.length > 0 && /^[0-9.]+$/.test(digits);
|
|
1531
|
+
}
|
|
1532
|
+
function rnStyleValue(property, value) {
|
|
1533
|
+
if (!NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1534
|
+
return { value, warning: null };
|
|
1535
|
+
}
|
|
1536
|
+
let px = null;
|
|
1537
|
+
if (value.endsWith("px")) {
|
|
1538
|
+
const n = Number(value.slice(0, -2));
|
|
1539
|
+
px = Number.isFinite(n) ? n : null;
|
|
1540
|
+
} else if (value.endsWith("rem")) {
|
|
1541
|
+
const n = Number(value.slice(0, -3));
|
|
1542
|
+
px = Number.isFinite(n) ? n * 16 : null;
|
|
1543
|
+
} else {
|
|
1544
|
+
const n = Number(value);
|
|
1545
|
+
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1546
|
+
}
|
|
1547
|
+
if (px !== null) return { value: px, warning: null };
|
|
1548
|
+
if (isPlainPercentage(value)) {
|
|
1549
|
+
return { value, warning: null };
|
|
1550
|
+
}
|
|
1551
|
+
const reduced = reduceConstantMath(value);
|
|
1552
|
+
if (reduced !== null) {
|
|
1553
|
+
return { value: reduced, warning: null };
|
|
1554
|
+
}
|
|
1555
|
+
const warning = `Kbach: "${value}" is not a valid native value for "${property}" \u2014 dropped. calc()/clamp()/min()/max() only resolve on native when every operand is a constant px/rem length (no %, vw, vh, var(), or other viewport/CSS-variable units \u2014 those need real layout/DOM, which doesn't exist on native at paint time). Use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this value in JS instead.`;
|
|
1556
|
+
return { value: null, warning };
|
|
1557
|
+
}
|
|
1558
|
+
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
1559
|
+
const style = {};
|
|
1560
|
+
const warnings = [];
|
|
1561
|
+
let shadowOffset = null;
|
|
1562
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1563
|
+
const parsed = parseClass(token);
|
|
1564
|
+
const allModifiersHold = parsed.modifiers.every(
|
|
1565
|
+
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
1566
|
+
);
|
|
1567
|
+
if (!allModifiersHold) continue;
|
|
1568
|
+
const decls = resolveUtilityNative(parsed, theme);
|
|
1569
|
+
if (decls === null) continue;
|
|
1570
|
+
for (const d of decls) {
|
|
1571
|
+
if (d.property.startsWith("__")) {
|
|
1572
|
+
continue;
|
|
1573
|
+
}
|
|
1574
|
+
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1575
|
+
const n = Number(d.value);
|
|
1576
|
+
if (!Number.isFinite(n)) continue;
|
|
1577
|
+
if (shadowOffset === null) shadowOffset = {};
|
|
1578
|
+
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1579
|
+
continue;
|
|
1580
|
+
}
|
|
1581
|
+
const { value, warning } = rnStyleValue(d.property, d.value);
|
|
1582
|
+
if (warning !== null) warnings.push(warning);
|
|
1583
|
+
if (value !== null) style[kebabToCamel(d.property)] = value;
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1586
|
+
if (shadowOffset !== null) {
|
|
1587
|
+
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1588
|
+
}
|
|
1589
|
+
return { style, warnings };
|
|
1590
|
+
}
|
|
1591
|
+
|
|
1592
|
+
// src/nativeBridge.ts
|
|
1593
|
+
function resolveStyle(classString, pressed = false) {
|
|
1594
|
+
const colorScheme = (0, import_darkModeStore2.getGlobalDarkMode)() ? "dark" : "light";
|
|
1595
|
+
const width = import_react_native2.Dimensions.get("window").width;
|
|
1596
|
+
const KbachModule = import_react_native2.TurboModuleRegistry.get("KbachModule");
|
|
1597
|
+
if (!KbachModule) {
|
|
1598
|
+
const { style: style2, warnings: warnings2 } = resolveStyleJsWithWarnings(classString, (0, import_theme2.getTheme)(), colorScheme, pressed, width);
|
|
1599
|
+
warnIfDev(classString, warnings2);
|
|
1600
|
+
return style2;
|
|
1601
|
+
}
|
|
1602
|
+
const json = KbachModule.resolveStyle(classString, (0, import_theme2.getThemeJson)(), colorScheme, pressed, width);
|
|
1603
|
+
const style = JSON.parse(json);
|
|
1604
|
+
const warnings = style.__kbachWarnings;
|
|
1605
|
+
if (warnings !== void 0) {
|
|
1606
|
+
delete style.__kbachWarnings;
|
|
1607
|
+
warnIfDev(classString, warnings);
|
|
1608
|
+
}
|
|
1609
|
+
return style;
|
|
1610
|
+
}
|
|
1611
|
+
var warnedMessages = /* @__PURE__ */ new Set();
|
|
1612
|
+
function warnIfDev(classString, warnings) {
|
|
1613
|
+
if (warnings.length === 0) return;
|
|
1614
|
+
if (typeof __DEV__ !== "undefined" && !__DEV__) return;
|
|
1615
|
+
for (const warning of warnings) {
|
|
1616
|
+
const message = `${warning} (from className "${classString}")`;
|
|
1617
|
+
if (warnedMessages.has(message)) continue;
|
|
1618
|
+
warnedMessages.add(message);
|
|
1619
|
+
console.warn(message);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
// src/jsx-runtime.tsx
|
|
1624
|
+
var { jsx, jsxs } = createJsxFunctions(resolveStyle);
|
|
1625
|
+
|
|
1626
|
+
// src/jsx-dev-runtime.tsx
|
|
1627
|
+
var jsxDEV = createJsxDEV(jsx, jsxs);
|
|
407
1628
|
// Annotate the CommonJS export names for ESM import in node:
|
|
408
1629
|
0 && (module.exports = {
|
|
409
1630
|
Fragment,
|