@kbach/react-native 1.0.0-beta.15 → 1.0.0-beta.16
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/dist/{chunk-AXGAYOQ7.mjs → chunk-3ED4FIO2.mjs} +363 -3
- package/dist/{chunk-VD233W3L.mjs → chunk-6ML62O2R.mjs} +1 -1
- package/dist/{chunk-RBJXE32L.mjs → chunk-XGQWM65X.mjs} +1 -1
- package/dist/darkModeStore.d.ts +58 -0
- package/dist/{index.d.mts → index.d.ts} +3 -1
- package/dist/{index.web.d.mts → index.web.d.ts} +3 -1
- package/dist/index.web.mjs +169 -12
- package/dist/jsx-dev-runtime.web.mjs +18 -7
- package/dist/jsx-runtime.web.mjs +2 -3
- package/dist/theme.d.ts +54 -0
- package/dist/{useColors-C6jyCLuG.d.mts → useColors-Br8QhIlE.d.ts} +3 -95
- package/package.json +1 -5
- package/dist/chunk-EMZ47OSG.mjs +0 -100
- package/dist/chunk-HK6PDJJK.mjs +0 -367
- package/dist/chunk-JMNJCPGK.mjs +0 -1239
- package/dist/chunk-TDWBXJH5.mjs +0 -186
- package/dist/chunk-UNZ6PQVO.mjs +0 -14
- package/dist/index.mjs +0 -38
- package/dist/jsx-dev-runtime.mjs +0 -18
- package/dist/jsx-runtime.mjs +0 -15
- /package/dist/{jsx-dev-runtime.d.mts → jsx-dev-runtime.d.ts} +0 -0
- /package/dist/{jsx-dev-runtime.web.d.mts → jsx-dev-runtime.web.d.ts} +0 -0
- /package/dist/{jsx-runtime.d.mts → jsx-runtime.d.ts} +0 -0
- /package/dist/{jsx-runtime.web.d.mts → jsx-runtime.web.d.ts} +0 -0
package/dist/chunk-JMNJCPGK.mjs
DELETED
|
@@ -1,1239 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getGlobalDarkMode
|
|
3
|
-
} from "./chunk-RBJXE32L.mjs";
|
|
4
|
-
import {
|
|
5
|
-
getTheme,
|
|
6
|
-
getThemeJson
|
|
7
|
-
} from "./chunk-HK6PDJJK.mjs";
|
|
8
|
-
|
|
9
|
-
// src/nativeBridge.ts
|
|
10
|
-
import { Dimensions, TurboModuleRegistry } from "react-native";
|
|
11
|
-
|
|
12
|
-
// src/jsEngine/parser.ts
|
|
13
|
-
var VALUE_PREFIXES = [
|
|
14
|
-
"bg-opacity-",
|
|
15
|
-
"text-opacity-",
|
|
16
|
-
"bg-blend-",
|
|
17
|
-
"text-shadow-",
|
|
18
|
-
"bg-",
|
|
19
|
-
"text-",
|
|
20
|
-
"border-x-",
|
|
21
|
-
"border-y-",
|
|
22
|
-
"border-t-",
|
|
23
|
-
"border-r-",
|
|
24
|
-
"border-b-",
|
|
25
|
-
"border-l-",
|
|
26
|
-
"border-",
|
|
27
|
-
"caret-",
|
|
28
|
-
"accent-",
|
|
29
|
-
"fill-",
|
|
30
|
-
"stroke-width-",
|
|
31
|
-
"stroke-",
|
|
32
|
-
"resize-",
|
|
33
|
-
"touch-",
|
|
34
|
-
"will-change-",
|
|
35
|
-
"scroll-mx-",
|
|
36
|
-
"scroll-my-",
|
|
37
|
-
"scroll-mt-",
|
|
38
|
-
"scroll-mr-",
|
|
39
|
-
"scroll-mb-",
|
|
40
|
-
"scroll-ml-",
|
|
41
|
-
"scroll-m-",
|
|
42
|
-
"scroll-px-",
|
|
43
|
-
"scroll-py-",
|
|
44
|
-
"scroll-pt-",
|
|
45
|
-
"scroll-pr-",
|
|
46
|
-
"scroll-pb-",
|
|
47
|
-
"scroll-pl-",
|
|
48
|
-
"scroll-p-",
|
|
49
|
-
"px-",
|
|
50
|
-
"py-",
|
|
51
|
-
"pt-",
|
|
52
|
-
"pr-",
|
|
53
|
-
"pb-",
|
|
54
|
-
"pl-",
|
|
55
|
-
"p-",
|
|
56
|
-
"mx-",
|
|
57
|
-
"my-",
|
|
58
|
-
"mt-",
|
|
59
|
-
"mr-",
|
|
60
|
-
"mb-",
|
|
61
|
-
"ml-",
|
|
62
|
-
"m-",
|
|
63
|
-
"gap-x-",
|
|
64
|
-
"gap-y-",
|
|
65
|
-
"gap-",
|
|
66
|
-
"min-w-",
|
|
67
|
-
"max-w-",
|
|
68
|
-
"w-",
|
|
69
|
-
"min-h-",
|
|
70
|
-
"max-h-",
|
|
71
|
-
"h-",
|
|
72
|
-
"size-",
|
|
73
|
-
"basis-",
|
|
74
|
-
"rounded-tl-",
|
|
75
|
-
"rounded-tr-",
|
|
76
|
-
"rounded-br-",
|
|
77
|
-
"rounded-bl-",
|
|
78
|
-
"rounded-t-",
|
|
79
|
-
"rounded-r-",
|
|
80
|
-
"rounded-b-",
|
|
81
|
-
"rounded-l-",
|
|
82
|
-
"rounded-",
|
|
83
|
-
"ring-offset-",
|
|
84
|
-
"ring-",
|
|
85
|
-
"outline-offset-",
|
|
86
|
-
"outline-",
|
|
87
|
-
"shadow-",
|
|
88
|
-
"opacity-",
|
|
89
|
-
"duration-",
|
|
90
|
-
"delay-",
|
|
91
|
-
"ease-",
|
|
92
|
-
"cursor-",
|
|
93
|
-
"mix-blend-",
|
|
94
|
-
"animate-",
|
|
95
|
-
"leading-",
|
|
96
|
-
"tracking-",
|
|
97
|
-
"font-",
|
|
98
|
-
"z-",
|
|
99
|
-
"inset-",
|
|
100
|
-
"top-",
|
|
101
|
-
"right-",
|
|
102
|
-
"bottom-",
|
|
103
|
-
"left-",
|
|
104
|
-
"divide-color-",
|
|
105
|
-
"space-x-",
|
|
106
|
-
"space-y-",
|
|
107
|
-
"flex-",
|
|
108
|
-
"grow-",
|
|
109
|
-
"shrink-",
|
|
110
|
-
"order-",
|
|
111
|
-
"grid-cols-",
|
|
112
|
-
"grid-rows-",
|
|
113
|
-
"grid-flow-",
|
|
114
|
-
"auto-cols-",
|
|
115
|
-
"auto-rows-",
|
|
116
|
-
"col-span-",
|
|
117
|
-
"col-start-",
|
|
118
|
-
"col-end-",
|
|
119
|
-
"col-",
|
|
120
|
-
"row-span-",
|
|
121
|
-
"row-start-",
|
|
122
|
-
"row-end-",
|
|
123
|
-
"row-",
|
|
124
|
-
"place-items-",
|
|
125
|
-
"place-content-",
|
|
126
|
-
"place-self-",
|
|
127
|
-
"justify-items-",
|
|
128
|
-
"justify-self-",
|
|
129
|
-
"scale-x-",
|
|
130
|
-
"scale-y-",
|
|
131
|
-
"scale-",
|
|
132
|
-
"rotate-",
|
|
133
|
-
"translate-x-",
|
|
134
|
-
"translate-y-",
|
|
135
|
-
"skew-x-",
|
|
136
|
-
"skew-y-",
|
|
137
|
-
"origin-",
|
|
138
|
-
"blur-",
|
|
139
|
-
"brightness-",
|
|
140
|
-
"contrast-",
|
|
141
|
-
"grayscale-",
|
|
142
|
-
"hue-rotate-",
|
|
143
|
-
"invert-",
|
|
144
|
-
"saturate-",
|
|
145
|
-
"sepia-",
|
|
146
|
-
"drop-shadow-",
|
|
147
|
-
"filter-",
|
|
148
|
-
"backdrop-blur-",
|
|
149
|
-
"backdrop-brightness-",
|
|
150
|
-
"backdrop-contrast-",
|
|
151
|
-
"backdrop-grayscale-",
|
|
152
|
-
"backdrop-hue-rotate-",
|
|
153
|
-
"backdrop-invert-",
|
|
154
|
-
"backdrop-opacity-",
|
|
155
|
-
"backdrop-saturate-",
|
|
156
|
-
"backdrop-sepia-",
|
|
157
|
-
"backdrop-filter-",
|
|
158
|
-
"decoration-",
|
|
159
|
-
"underline-offset-",
|
|
160
|
-
"indent-",
|
|
161
|
-
"from-",
|
|
162
|
-
"via-",
|
|
163
|
-
"to-"
|
|
164
|
-
];
|
|
165
|
-
var ARBITRARY_PROPERTY_SENTINEL = "[arbitrary-property]";
|
|
166
|
-
function isSafeArbitraryValue(value) {
|
|
167
|
-
return !value.includes("{") && !value.includes("}") && !value.includes(";");
|
|
168
|
-
}
|
|
169
|
-
function splitRespectingBrackets(token) {
|
|
170
|
-
const parts = [];
|
|
171
|
-
let depth = 0;
|
|
172
|
-
let start = 0;
|
|
173
|
-
for (let i = 0; i < token.length; i++) {
|
|
174
|
-
const ch = token[i];
|
|
175
|
-
if (ch === "[") depth += 1;
|
|
176
|
-
else if (ch === "]") depth -= 1;
|
|
177
|
-
else if (ch === ":" && depth <= 0) {
|
|
178
|
-
parts.push(token.slice(start, i));
|
|
179
|
-
start = i + 1;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
parts.push(token.slice(start));
|
|
183
|
-
return parts;
|
|
184
|
-
}
|
|
185
|
-
function parseClass(token) {
|
|
186
|
-
const parts = splitRespectingBrackets(token);
|
|
187
|
-
let base = parts.pop() ?? token;
|
|
188
|
-
const modifiers = parts;
|
|
189
|
-
const important = base.startsWith("!");
|
|
190
|
-
if (important) {
|
|
191
|
-
base = base.slice(1);
|
|
192
|
-
}
|
|
193
|
-
const negative = base.startsWith("-");
|
|
194
|
-
if (negative) {
|
|
195
|
-
base = base.slice(1);
|
|
196
|
-
}
|
|
197
|
-
if (base.length >= 2 && base.startsWith("[") && base.endsWith("]")) {
|
|
198
|
-
const raw = base.slice(1, -1);
|
|
199
|
-
const colonIdx = raw.indexOf(":");
|
|
200
|
-
if (colonIdx !== -1) {
|
|
201
|
-
const property = raw.slice(0, colonIdx);
|
|
202
|
-
const rawValue = raw.slice(colonIdx + 1);
|
|
203
|
-
if (property !== "" && rawValue !== "" && isSafeArbitraryValue(raw)) {
|
|
204
|
-
const value = rawValue.replace(/_/g, " ");
|
|
205
|
-
return {
|
|
206
|
-
modifiers,
|
|
207
|
-
utility: ARBITRARY_PROPERTY_SENTINEL,
|
|
208
|
-
value: `${property}:${value}`,
|
|
209
|
-
isArbitrary: true,
|
|
210
|
-
important,
|
|
211
|
-
negative,
|
|
212
|
-
original: token
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
for (const prefix of VALUE_PREFIXES) {
|
|
218
|
-
if (!base.startsWith(prefix)) continue;
|
|
219
|
-
const value = base.slice(prefix.length);
|
|
220
|
-
if (value === "") continue;
|
|
221
|
-
if (value.length >= 2 && value.startsWith("[") && value.endsWith("]")) {
|
|
222
|
-
const raw = value.slice(1, -1);
|
|
223
|
-
if (!isSafeArbitraryValue(raw)) {
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
const spaced = raw.replace(/_/g, " ");
|
|
227
|
-
return {
|
|
228
|
-
modifiers,
|
|
229
|
-
utility: prefix.slice(0, -1),
|
|
230
|
-
value: spaced,
|
|
231
|
-
isArbitrary: true,
|
|
232
|
-
important,
|
|
233
|
-
negative,
|
|
234
|
-
original: token
|
|
235
|
-
};
|
|
236
|
-
}
|
|
237
|
-
return {
|
|
238
|
-
modifiers,
|
|
239
|
-
utility: prefix.slice(0, -1),
|
|
240
|
-
value,
|
|
241
|
-
isArbitrary: false,
|
|
242
|
-
important,
|
|
243
|
-
negative,
|
|
244
|
-
original: token
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
return {
|
|
248
|
-
modifiers,
|
|
249
|
-
utility: base,
|
|
250
|
-
value: null,
|
|
251
|
-
isArbitrary: false,
|
|
252
|
-
important,
|
|
253
|
-
negative,
|
|
254
|
-
original: token
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// src/jsEngine/shared.ts
|
|
259
|
-
function decl(property, value) {
|
|
260
|
-
return { property, value };
|
|
261
|
-
}
|
|
262
|
-
function spacingPx(theme, value) {
|
|
263
|
-
const fromTable = theme.spacing[value];
|
|
264
|
-
if (fromTable !== void 0) return fromTable;
|
|
265
|
-
const n = Number(value);
|
|
266
|
-
return Number.isFinite(n) && value.trim() !== "" ? n * 4 : void 0;
|
|
267
|
-
}
|
|
268
|
-
function resolveLength(theme, parsed) {
|
|
269
|
-
if (parsed.negative) return null;
|
|
270
|
-
const value = parsed.value;
|
|
271
|
-
if (value === null) return null;
|
|
272
|
-
if (parsed.isArbitrary) return value;
|
|
273
|
-
if (value === "full") return "100%";
|
|
274
|
-
if (value === "auto") return "auto";
|
|
275
|
-
const px = spacingPx(theme, value);
|
|
276
|
-
return px === void 0 ? null : `${px}px`;
|
|
277
|
-
}
|
|
278
|
-
function resolveNegatableLength(theme, parsed) {
|
|
279
|
-
if (!parsed.negative) return resolveLength(theme, parsed);
|
|
280
|
-
if (parsed.isArbitrary) return null;
|
|
281
|
-
const value = parsed.value;
|
|
282
|
-
if (value === null) return null;
|
|
283
|
-
const px = spacingPx(theme, value);
|
|
284
|
-
if (px === void 0) return null;
|
|
285
|
-
if (px === 0) return "0px";
|
|
286
|
-
return `-${px}px`;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
// src/jsEngine/resolvers/layout.ts
|
|
290
|
-
function negateRaw(value, negative) {
|
|
291
|
-
return negative ? `-${value}` : value;
|
|
292
|
-
}
|
|
293
|
-
function resolve(parsed, theme) {
|
|
294
|
-
switch (parsed.utility) {
|
|
295
|
-
case "flex":
|
|
296
|
-
return parsed.value === null ? [decl("display", "flex")] : null;
|
|
297
|
-
case "grid":
|
|
298
|
-
return [decl("display", "grid")];
|
|
299
|
-
case "block":
|
|
300
|
-
return [decl("display", "block")];
|
|
301
|
-
case "inline-block":
|
|
302
|
-
return [decl("display", "inline-block")];
|
|
303
|
-
case "inline":
|
|
304
|
-
return [decl("display", "inline")];
|
|
305
|
-
case "inline-flex":
|
|
306
|
-
return [decl("display", "inline-flex")];
|
|
307
|
-
case "inline-grid":
|
|
308
|
-
return [decl("display", "inline-grid")];
|
|
309
|
-
case "contents":
|
|
310
|
-
return [decl("display", "contents")];
|
|
311
|
-
case "flow-root":
|
|
312
|
-
return [decl("display", "flow-root")];
|
|
313
|
-
case "hidden":
|
|
314
|
-
return [decl("display", "none")];
|
|
315
|
-
case "@container":
|
|
316
|
-
return [decl("container-type", "inline-size")];
|
|
317
|
-
case "items-center":
|
|
318
|
-
return [decl("align-items", "center")];
|
|
319
|
-
case "items-start":
|
|
320
|
-
return [decl("align-items", "flex-start")];
|
|
321
|
-
case "items-end":
|
|
322
|
-
return [decl("align-items", "flex-end")];
|
|
323
|
-
case "items-baseline":
|
|
324
|
-
return [decl("align-items", "baseline")];
|
|
325
|
-
case "items-stretch":
|
|
326
|
-
return [decl("align-items", "stretch")];
|
|
327
|
-
case "justify-center":
|
|
328
|
-
return [decl("justify-content", "center")];
|
|
329
|
-
case "justify-start":
|
|
330
|
-
return [decl("justify-content", "flex-start")];
|
|
331
|
-
case "justify-end":
|
|
332
|
-
return [decl("justify-content", "flex-end")];
|
|
333
|
-
case "justify-between":
|
|
334
|
-
return [decl("justify-content", "space-between")];
|
|
335
|
-
case "justify-around":
|
|
336
|
-
return [decl("justify-content", "space-around")];
|
|
337
|
-
case "justify-evenly":
|
|
338
|
-
return [decl("justify-content", "space-evenly")];
|
|
339
|
-
case "content-start":
|
|
340
|
-
return [decl("align-content", "flex-start")];
|
|
341
|
-
case "content-end":
|
|
342
|
-
return [decl("align-content", "flex-end")];
|
|
343
|
-
case "content-center":
|
|
344
|
-
return [decl("align-content", "center")];
|
|
345
|
-
case "content-between":
|
|
346
|
-
return [decl("align-content", "space-between")];
|
|
347
|
-
case "content-around":
|
|
348
|
-
return [decl("align-content", "space-around")];
|
|
349
|
-
case "content-evenly":
|
|
350
|
-
return [decl("align-content", "space-evenly")];
|
|
351
|
-
case "content-stretch":
|
|
352
|
-
return [decl("align-content", "stretch")];
|
|
353
|
-
case "self-auto":
|
|
354
|
-
return [decl("align-self", "auto")];
|
|
355
|
-
case "self-center":
|
|
356
|
-
return [decl("align-self", "center")];
|
|
357
|
-
case "self-start":
|
|
358
|
-
return [decl("align-self", "flex-start")];
|
|
359
|
-
case "self-end":
|
|
360
|
-
return [decl("align-self", "flex-end")];
|
|
361
|
-
case "self-stretch":
|
|
362
|
-
return [decl("align-self", "stretch")];
|
|
363
|
-
case "self-baseline":
|
|
364
|
-
return [decl("align-self", "baseline")];
|
|
365
|
-
case "overflow-hidden":
|
|
366
|
-
return [decl("overflow", "hidden")];
|
|
367
|
-
case "overflow-auto":
|
|
368
|
-
return [decl("overflow", "auto")];
|
|
369
|
-
case "overflow-scroll":
|
|
370
|
-
return [decl("overflow", "scroll")];
|
|
371
|
-
case "overflow-visible":
|
|
372
|
-
return [decl("overflow", "visible")];
|
|
373
|
-
case "static":
|
|
374
|
-
return [decl("position", "static")];
|
|
375
|
-
case "relative":
|
|
376
|
-
return [decl("position", "relative")];
|
|
377
|
-
case "absolute":
|
|
378
|
-
return [decl("position", "absolute")];
|
|
379
|
-
case "fixed":
|
|
380
|
-
return [decl("position", "fixed")];
|
|
381
|
-
case "sticky":
|
|
382
|
-
return [decl("position", "sticky")];
|
|
383
|
-
case "z":
|
|
384
|
-
return parsed.value === null ? null : [decl("z-index", negateRaw(parsed.value, parsed.negative))];
|
|
385
|
-
case "order":
|
|
386
|
-
return parsed.value === null ? null : [decl("order", negateRaw(parsed.value, parsed.negative))];
|
|
387
|
-
case "grow":
|
|
388
|
-
return [decl("flex-grow", parsed.value ?? "1")];
|
|
389
|
-
case "shrink":
|
|
390
|
-
return [decl("flex-shrink", parsed.value ?? "1")];
|
|
391
|
-
// top/right/bottom/left/inset support real Tailwind's negative-value
|
|
392
|
-
// convention ("-top-4") — see resolveNegatableLength's own doc comment.
|
|
393
|
-
case "top": {
|
|
394
|
-
const v = resolveNegatableLength(theme, parsed);
|
|
395
|
-
return v === null ? null : [decl("top", v)];
|
|
396
|
-
}
|
|
397
|
-
case "right": {
|
|
398
|
-
const v = resolveNegatableLength(theme, parsed);
|
|
399
|
-
return v === null ? null : [decl("right", v)];
|
|
400
|
-
}
|
|
401
|
-
case "bottom": {
|
|
402
|
-
const v = resolveNegatableLength(theme, parsed);
|
|
403
|
-
return v === null ? null : [decl("bottom", v)];
|
|
404
|
-
}
|
|
405
|
-
case "left": {
|
|
406
|
-
const v = resolveNegatableLength(theme, parsed);
|
|
407
|
-
return v === null ? null : [decl("left", v)];
|
|
408
|
-
}
|
|
409
|
-
case "inset": {
|
|
410
|
-
const v = resolveNegatableLength(theme, parsed);
|
|
411
|
-
return v === null ? null : [decl("inset", v)];
|
|
412
|
-
}
|
|
413
|
-
case "aspect-square":
|
|
414
|
-
return [decl("aspect-ratio", "1 / 1")];
|
|
415
|
-
case "aspect-video":
|
|
416
|
-
return [decl("aspect-ratio", "16 / 9")];
|
|
417
|
-
default:
|
|
418
|
-
return null;
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
function resolveFlex(parsed, web) {
|
|
422
|
-
if (parsed.utility !== "flex") return null;
|
|
423
|
-
const value = parsed.value;
|
|
424
|
-
if (value === null) return null;
|
|
425
|
-
if (parsed.isArbitrary) return [decl("flex", value)];
|
|
426
|
-
switch (value) {
|
|
427
|
-
case "row":
|
|
428
|
-
return [decl("flex-direction", "row")];
|
|
429
|
-
case "col":
|
|
430
|
-
return [decl("flex-direction", "column")];
|
|
431
|
-
case "row-reverse":
|
|
432
|
-
return [decl("flex-direction", "row-reverse")];
|
|
433
|
-
case "col-reverse":
|
|
434
|
-
return [decl("flex-direction", "column-reverse")];
|
|
435
|
-
case "wrap":
|
|
436
|
-
return [decl("flex-wrap", "wrap")];
|
|
437
|
-
case "wrap-reverse":
|
|
438
|
-
return [decl("flex-wrap", "wrap-reverse")];
|
|
439
|
-
case "nowrap":
|
|
440
|
-
return [decl("flex-wrap", "nowrap")];
|
|
441
|
-
case "1":
|
|
442
|
-
return [decl("flex", "1")];
|
|
443
|
-
case "auto":
|
|
444
|
-
return [decl("flex", web ? "auto" : "1")];
|
|
445
|
-
case "initial":
|
|
446
|
-
return [decl("flex", web ? "initial" : "1")];
|
|
447
|
-
case "none":
|
|
448
|
-
return [decl("flex", web ? "none" : "0")];
|
|
449
|
-
case "grow":
|
|
450
|
-
return [decl("flex-grow", "1")];
|
|
451
|
-
case "grow-0":
|
|
452
|
-
return [decl("flex-grow", "0")];
|
|
453
|
-
case "shrink":
|
|
454
|
-
return [decl("flex-shrink", "1")];
|
|
455
|
-
case "shrink-0":
|
|
456
|
-
return [decl("flex-shrink", "0")];
|
|
457
|
-
default:
|
|
458
|
-
return null;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// src/jsEngine/resolvers/spacing.ts
|
|
463
|
-
function namedSize(key) {
|
|
464
|
-
switch (key) {
|
|
465
|
-
case "sm":
|
|
466
|
-
return "24rem";
|
|
467
|
-
case "md":
|
|
468
|
-
return "28rem";
|
|
469
|
-
case "lg":
|
|
470
|
-
return "32rem";
|
|
471
|
-
case "xl":
|
|
472
|
-
return "36rem";
|
|
473
|
-
case "2xl":
|
|
474
|
-
return "42rem";
|
|
475
|
-
case "3xl":
|
|
476
|
-
return "48rem";
|
|
477
|
-
case "4xl":
|
|
478
|
-
return "56rem";
|
|
479
|
-
case "5xl":
|
|
480
|
-
return "64rem";
|
|
481
|
-
case "6xl":
|
|
482
|
-
return "72rem";
|
|
483
|
-
case "7xl":
|
|
484
|
-
return "80rem";
|
|
485
|
-
case "8xl":
|
|
486
|
-
return "88rem";
|
|
487
|
-
case "9xl":
|
|
488
|
-
return "96rem";
|
|
489
|
-
default:
|
|
490
|
-
return null;
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
function fractionPercent(value) {
|
|
494
|
-
const slashIdx = value.indexOf("/");
|
|
495
|
-
if (slashIdx === -1) return null;
|
|
496
|
-
const numStr = value.slice(0, slashIdx);
|
|
497
|
-
const denStr = value.slice(slashIdx + 1);
|
|
498
|
-
const num = Number(numStr);
|
|
499
|
-
const den = Number(denStr);
|
|
500
|
-
if (!Number.isFinite(num) || !Number.isFinite(den) || numStr.trim() === "" || denStr.trim() === "") return null;
|
|
501
|
-
if (den === 0) return null;
|
|
502
|
-
const pct = num / den * 100;
|
|
503
|
-
const formatted = pct.toFixed(6);
|
|
504
|
-
const trimmed = formatted.replace(/0+$/, "").replace(/\.$/, "");
|
|
505
|
-
return `${trimmed}%`;
|
|
506
|
-
}
|
|
507
|
-
function cssSizeKeyword(key) {
|
|
508
|
-
switch (key) {
|
|
509
|
-
case "min":
|
|
510
|
-
return "min-content";
|
|
511
|
-
case "max":
|
|
512
|
-
return "max-content";
|
|
513
|
-
case "fit":
|
|
514
|
-
return "fit-content";
|
|
515
|
-
default:
|
|
516
|
-
return null;
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
function resolveSize(theme, parsed) {
|
|
520
|
-
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
521
|
-
const named = namedSize(parsed.value);
|
|
522
|
-
if (named !== null) return named;
|
|
523
|
-
const kw = cssSizeKeyword(parsed.value);
|
|
524
|
-
if (kw !== null) return kw;
|
|
525
|
-
const fraction = fractionPercent(parsed.value);
|
|
526
|
-
if (fraction !== null) return fraction;
|
|
527
|
-
}
|
|
528
|
-
return resolveLength(theme, parsed);
|
|
529
|
-
}
|
|
530
|
-
function resolve2(parsed, theme) {
|
|
531
|
-
const length = () => resolveLength(theme, parsed);
|
|
532
|
-
const size = () => resolveSize(theme, parsed);
|
|
533
|
-
const negatableLength = () => resolveNegatableLength(theme, parsed);
|
|
534
|
-
switch (parsed.utility) {
|
|
535
|
-
case "p": {
|
|
536
|
-
const v = length();
|
|
537
|
-
return v === null ? null : [decl("padding", v)];
|
|
538
|
-
}
|
|
539
|
-
case "px": {
|
|
540
|
-
const v = length();
|
|
541
|
-
return v === null ? null : [decl("padding-left", v), decl("padding-right", v)];
|
|
542
|
-
}
|
|
543
|
-
case "py": {
|
|
544
|
-
const v = length();
|
|
545
|
-
return v === null ? null : [decl("padding-top", v), decl("padding-bottom", v)];
|
|
546
|
-
}
|
|
547
|
-
case "pt": {
|
|
548
|
-
const v = length();
|
|
549
|
-
return v === null ? null : [decl("padding-top", v)];
|
|
550
|
-
}
|
|
551
|
-
case "pr": {
|
|
552
|
-
const v = length();
|
|
553
|
-
return v === null ? null : [decl("padding-right", v)];
|
|
554
|
-
}
|
|
555
|
-
case "pb": {
|
|
556
|
-
const v = length();
|
|
557
|
-
return v === null ? null : [decl("padding-bottom", v)];
|
|
558
|
-
}
|
|
559
|
-
case "pl": {
|
|
560
|
-
const v = length();
|
|
561
|
-
return v === null ? null : [decl("padding-left", v)];
|
|
562
|
-
}
|
|
563
|
-
case "m": {
|
|
564
|
-
const v = negatableLength();
|
|
565
|
-
return v === null ? null : [decl("margin", v)];
|
|
566
|
-
}
|
|
567
|
-
case "mx": {
|
|
568
|
-
const v = negatableLength();
|
|
569
|
-
return v === null ? null : [decl("margin-left", v), decl("margin-right", v)];
|
|
570
|
-
}
|
|
571
|
-
case "my": {
|
|
572
|
-
const v = negatableLength();
|
|
573
|
-
return v === null ? null : [decl("margin-top", v), decl("margin-bottom", v)];
|
|
574
|
-
}
|
|
575
|
-
case "mt": {
|
|
576
|
-
const v = negatableLength();
|
|
577
|
-
return v === null ? null : [decl("margin-top", v)];
|
|
578
|
-
}
|
|
579
|
-
case "mr": {
|
|
580
|
-
const v = negatableLength();
|
|
581
|
-
return v === null ? null : [decl("margin-right", v)];
|
|
582
|
-
}
|
|
583
|
-
case "mb": {
|
|
584
|
-
const v = negatableLength();
|
|
585
|
-
return v === null ? null : [decl("margin-bottom", v)];
|
|
586
|
-
}
|
|
587
|
-
case "ml": {
|
|
588
|
-
const v = negatableLength();
|
|
589
|
-
return v === null ? null : [decl("margin-left", v)];
|
|
590
|
-
}
|
|
591
|
-
case "gap": {
|
|
592
|
-
const v = length();
|
|
593
|
-
return v === null ? null : [decl("gap", v)];
|
|
594
|
-
}
|
|
595
|
-
case "gap-x": {
|
|
596
|
-
const v = length();
|
|
597
|
-
return v === null ? null : [decl("column-gap", v)];
|
|
598
|
-
}
|
|
599
|
-
case "gap-y": {
|
|
600
|
-
const v = length();
|
|
601
|
-
return v === null ? null : [decl("row-gap", v)];
|
|
602
|
-
}
|
|
603
|
-
case "w": {
|
|
604
|
-
const v = size();
|
|
605
|
-
return v === null ? null : [decl("width", v)];
|
|
606
|
-
}
|
|
607
|
-
case "h": {
|
|
608
|
-
const v = size();
|
|
609
|
-
return v === null ? null : [decl("height", v)];
|
|
610
|
-
}
|
|
611
|
-
case "min-w": {
|
|
612
|
-
const v = size();
|
|
613
|
-
return v === null ? null : [decl("min-width", v)];
|
|
614
|
-
}
|
|
615
|
-
case "max-w": {
|
|
616
|
-
const v = size();
|
|
617
|
-
return v === null ? null : [decl("max-width", v)];
|
|
618
|
-
}
|
|
619
|
-
case "min-h": {
|
|
620
|
-
const v = size();
|
|
621
|
-
return v === null ? null : [decl("min-height", v)];
|
|
622
|
-
}
|
|
623
|
-
case "max-h": {
|
|
624
|
-
const v = size();
|
|
625
|
-
return v === null ? null : [decl("max-height", v)];
|
|
626
|
-
}
|
|
627
|
-
case "size": {
|
|
628
|
-
const v = size();
|
|
629
|
-
return v === null ? null : [decl("width", v), decl("height", v)];
|
|
630
|
-
}
|
|
631
|
-
case "basis": {
|
|
632
|
-
const v = size();
|
|
633
|
-
return v === null ? null : [decl("flex-basis", v)];
|
|
634
|
-
}
|
|
635
|
-
default:
|
|
636
|
-
return null;
|
|
637
|
-
}
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
// src/jsEngine/resolvers/color.ts
|
|
641
|
-
function lookupHex(theme, key) {
|
|
642
|
-
const entry = theme.colors[key];
|
|
643
|
-
return typeof entry === "string" ? entry : null;
|
|
644
|
-
}
|
|
645
|
-
function hexToRgb(hex) {
|
|
646
|
-
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
647
|
-
if (!m) return null;
|
|
648
|
-
let h = m[1];
|
|
649
|
-
if (h.length === 3) h = h.split("").map((c) => c + c).join("");
|
|
650
|
-
const n = parseInt(h, 16);
|
|
651
|
-
return [n >> 16 & 255, n >> 8 & 255, n & 255];
|
|
652
|
-
}
|
|
653
|
-
function splitOpacity(value) {
|
|
654
|
-
const slash = value.lastIndexOf("/");
|
|
655
|
-
if (slash === -1) return [value, null];
|
|
656
|
-
const opacityText = value.slice(slash + 1);
|
|
657
|
-
const n = Number(opacityText);
|
|
658
|
-
if (opacityText !== "" && Number.isInteger(n) && n >= 0 && n <= 100) {
|
|
659
|
-
return [value.slice(0, slash), n];
|
|
660
|
-
}
|
|
661
|
-
return [value, null];
|
|
662
|
-
}
|
|
663
|
-
function colorValue(theme, parsed) {
|
|
664
|
-
const value = parsed.value;
|
|
665
|
-
if (value === null) return null;
|
|
666
|
-
if (parsed.isArbitrary) return value;
|
|
667
|
-
const [name, opacity] = splitOpacity(value);
|
|
668
|
-
const hex = lookupHex(theme, name);
|
|
669
|
-
if (hex === null) return null;
|
|
670
|
-
if (opacity === null) return hex;
|
|
671
|
-
const rgb = hexToRgb(hex);
|
|
672
|
-
if (rgb === null) return hex;
|
|
673
|
-
return `rgba(${rgb.join(",")},${opacity / 100})`;
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
// src/jsEngine/resolvers/border.ts
|
|
677
|
-
function radiusSize(key) {
|
|
678
|
-
switch (key) {
|
|
679
|
-
case "none":
|
|
680
|
-
return "0px";
|
|
681
|
-
case "sm":
|
|
682
|
-
return "0.125rem";
|
|
683
|
-
case "md":
|
|
684
|
-
return "0.375rem";
|
|
685
|
-
case "lg":
|
|
686
|
-
return "0.5rem";
|
|
687
|
-
case "xl":
|
|
688
|
-
return "0.75rem";
|
|
689
|
-
case "2xl":
|
|
690
|
-
return "1rem";
|
|
691
|
-
case "3xl":
|
|
692
|
-
return "1.5rem";
|
|
693
|
-
case "full":
|
|
694
|
-
return "9999px";
|
|
695
|
-
default:
|
|
696
|
-
return null;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
function borderSideProperty(side) {
|
|
700
|
-
switch (side) {
|
|
701
|
-
case "t":
|
|
702
|
-
return "border-top";
|
|
703
|
-
case "r":
|
|
704
|
-
return "border-right";
|
|
705
|
-
case "b":
|
|
706
|
-
return "border-bottom";
|
|
707
|
-
case "l":
|
|
708
|
-
return "border-left";
|
|
709
|
-
default:
|
|
710
|
-
return null;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
function borderValue(theme, parsed) {
|
|
714
|
-
const value = parsed.value;
|
|
715
|
-
if (value === null) return null;
|
|
716
|
-
if (!parsed.isArbitrary) {
|
|
717
|
-
const side = borderSideProperty(value);
|
|
718
|
-
if (side !== null) {
|
|
719
|
-
return [decl(`${side}-width`, "1px"), decl(`${side}-style`, "solid")];
|
|
720
|
-
}
|
|
721
|
-
if (value === "collapse") return [decl("border-collapse", "collapse")];
|
|
722
|
-
if (value === "separate") return [decl("border-collapse", "separate")];
|
|
723
|
-
}
|
|
724
|
-
if (parsed.isArbitrary) {
|
|
725
|
-
return [decl("border-width", value)];
|
|
726
|
-
}
|
|
727
|
-
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
728
|
-
const v = resolveLength(theme, parsed);
|
|
729
|
-
return v === null ? null : [decl("border-width", v)];
|
|
730
|
-
}
|
|
731
|
-
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
732
|
-
return [decl("border-style", value)];
|
|
733
|
-
}
|
|
734
|
-
const color = colorValue(theme, parsed);
|
|
735
|
-
return color === null ? null : [decl("border-color", color)];
|
|
736
|
-
}
|
|
737
|
-
function borderSideValue(theme, parsed, sideProperty) {
|
|
738
|
-
const value = parsed.value;
|
|
739
|
-
if (value === null) return null;
|
|
740
|
-
if (parsed.isArbitrary) return [decl(`${sideProperty}-width`, value)];
|
|
741
|
-
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
742
|
-
const v = resolveLength(theme, parsed);
|
|
743
|
-
return v === null ? null : [decl(`${sideProperty}-width`, v)];
|
|
744
|
-
}
|
|
745
|
-
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
746
|
-
return [decl(`${sideProperty}-style`, value)];
|
|
747
|
-
}
|
|
748
|
-
const color = colorValue(theme, parsed);
|
|
749
|
-
return color === null ? null : [decl(`${sideProperty}-color`, color)];
|
|
750
|
-
}
|
|
751
|
-
function borderAxisValue(theme, parsed, sideA, sideB) {
|
|
752
|
-
const value = parsed.value;
|
|
753
|
-
if (value === null) return null;
|
|
754
|
-
if (parsed.isArbitrary) return [decl(`${sideA}-width`, value), decl(`${sideB}-width`, value)];
|
|
755
|
-
if (Number.isFinite(Number(value)) && value.trim() !== "") {
|
|
756
|
-
const v = resolveLength(theme, parsed);
|
|
757
|
-
return v === null ? null : [decl(`${sideA}-width`, v), decl(`${sideB}-width`, v)];
|
|
758
|
-
}
|
|
759
|
-
if (value === "solid" || value === "dashed" || value === "dotted" || value === "double" || value === "hidden" || value === "none") {
|
|
760
|
-
return [decl(`${sideA}-style`, value), decl(`${sideB}-style`, value)];
|
|
761
|
-
}
|
|
762
|
-
const color = colorValue(theme, parsed);
|
|
763
|
-
return color === null ? null : [decl(`${sideA}-color`, color), decl(`${sideB}-color`, color)];
|
|
764
|
-
}
|
|
765
|
-
function radiusProperties(side) {
|
|
766
|
-
switch (side) {
|
|
767
|
-
case "t":
|
|
768
|
-
return ["border-top-left-radius", "border-top-right-radius"];
|
|
769
|
-
case "r":
|
|
770
|
-
return ["border-top-right-radius", "border-bottom-right-radius"];
|
|
771
|
-
case "b":
|
|
772
|
-
return ["border-bottom-right-radius", "border-bottom-left-radius"];
|
|
773
|
-
case "l":
|
|
774
|
-
return ["border-top-left-radius", "border-bottom-left-radius"];
|
|
775
|
-
case "tl":
|
|
776
|
-
return ["border-top-left-radius"];
|
|
777
|
-
case "tr":
|
|
778
|
-
return ["border-top-right-radius"];
|
|
779
|
-
case "br":
|
|
780
|
-
return ["border-bottom-right-radius"];
|
|
781
|
-
case "bl":
|
|
782
|
-
return ["border-bottom-left-radius"];
|
|
783
|
-
default:
|
|
784
|
-
return null;
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
function resolveRadiusValue(theme, parsed) {
|
|
788
|
-
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
789
|
-
const size = radiusSize(parsed.value);
|
|
790
|
-
if (size !== null) return size;
|
|
791
|
-
}
|
|
792
|
-
return resolveLength(theme, parsed);
|
|
793
|
-
}
|
|
794
|
-
function resolveRadiusSide(theme, parsed, side) {
|
|
795
|
-
const properties = radiusProperties(side);
|
|
796
|
-
if (properties === null) return null;
|
|
797
|
-
const value = resolveRadiusValue(theme, parsed);
|
|
798
|
-
if (value === null) return null;
|
|
799
|
-
return properties.map((p) => decl(p, value));
|
|
800
|
-
}
|
|
801
|
-
var OUTLINE_STYLES = ["solid", "dashed", "dotted", "double"];
|
|
802
|
-
function outlineWidthValue(key) {
|
|
803
|
-
switch (key) {
|
|
804
|
-
case "0":
|
|
805
|
-
return "0px";
|
|
806
|
-
case "1":
|
|
807
|
-
return "1px";
|
|
808
|
-
case "2":
|
|
809
|
-
return "2px";
|
|
810
|
-
case "4":
|
|
811
|
-
return "4px";
|
|
812
|
-
case "8":
|
|
813
|
-
return "8px";
|
|
814
|
-
default:
|
|
815
|
-
return null;
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
function outlineValue(theme, parsed) {
|
|
819
|
-
const value = parsed.value;
|
|
820
|
-
if (value === null) return null;
|
|
821
|
-
if (parsed.isArbitrary) return [decl("outline-width", value)];
|
|
822
|
-
const w = outlineWidthValue(value);
|
|
823
|
-
if (w !== null) return [decl("outline-width", w)];
|
|
824
|
-
if (OUTLINE_STYLES.includes(value)) return [decl("outline-style", value)];
|
|
825
|
-
const color = colorValue(theme, parsed);
|
|
826
|
-
return color === null ? null : [decl("outline-color", color)];
|
|
827
|
-
}
|
|
828
|
-
function outlineOffsetValue(parsed) {
|
|
829
|
-
const value = parsed.value;
|
|
830
|
-
if (value === null) return null;
|
|
831
|
-
if (parsed.isArbitrary) return [decl("outline-offset", value)];
|
|
832
|
-
const w = outlineWidthValue(value);
|
|
833
|
-
return w === null ? null : [decl("outline-offset", w)];
|
|
834
|
-
}
|
|
835
|
-
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))";
|
|
836
|
-
function ringWidth(key) {
|
|
837
|
-
switch (key) {
|
|
838
|
-
case "0":
|
|
839
|
-
return "0px";
|
|
840
|
-
case "1":
|
|
841
|
-
return "1px";
|
|
842
|
-
case "2":
|
|
843
|
-
return "2px";
|
|
844
|
-
case "4":
|
|
845
|
-
return "4px";
|
|
846
|
-
case "8":
|
|
847
|
-
return "8px";
|
|
848
|
-
default:
|
|
849
|
-
return null;
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
function ringValue(theme, parsed) {
|
|
853
|
-
const value = parsed.value;
|
|
854
|
-
if (value === null) return null;
|
|
855
|
-
if (value === "inset") {
|
|
856
|
-
return [decl("--kb-ring-inset", "inset"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
857
|
-
}
|
|
858
|
-
if (!parsed.isArbitrary) {
|
|
859
|
-
const w = ringWidth(value);
|
|
860
|
-
if (w !== null) return [decl("--kb-ring-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
861
|
-
}
|
|
862
|
-
const color = colorValue(theme, parsed);
|
|
863
|
-
if (color === null) return null;
|
|
864
|
-
return [decl("--kb-ring-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
865
|
-
}
|
|
866
|
-
function ringOffsetValue(theme, parsed) {
|
|
867
|
-
const value = parsed.value;
|
|
868
|
-
if (value === null) return null;
|
|
869
|
-
if (!parsed.isArbitrary) {
|
|
870
|
-
const w = ringWidth(value);
|
|
871
|
-
if (w !== null) return [decl("--kb-ring-offset-width", w), decl("box-shadow", RING_BOX_SHADOW)];
|
|
872
|
-
}
|
|
873
|
-
const color = colorValue(theme, parsed);
|
|
874
|
-
if (color === null) return null;
|
|
875
|
-
return [decl("--kb-ring-offset-color", color), decl("box-shadow", RING_BOX_SHADOW)];
|
|
876
|
-
}
|
|
877
|
-
var RADIUS_SIDES = /* @__PURE__ */ new Set(["t", "r", "b", "l", "tl", "tr", "br", "bl"]);
|
|
878
|
-
function resolve3(parsed, theme) {
|
|
879
|
-
switch (parsed.utility) {
|
|
880
|
-
case "border":
|
|
881
|
-
if (parsed.value === null) return [decl("border-width", "1px"), decl("border-style", "solid")];
|
|
882
|
-
return borderValue(theme, parsed);
|
|
883
|
-
case "border-t":
|
|
884
|
-
return borderSideValue(theme, parsed, "border-top");
|
|
885
|
-
case "border-r":
|
|
886
|
-
return borderSideValue(theme, parsed, "border-right");
|
|
887
|
-
case "border-b":
|
|
888
|
-
return borderSideValue(theme, parsed, "border-bottom");
|
|
889
|
-
case "border-l":
|
|
890
|
-
return borderSideValue(theme, parsed, "border-left");
|
|
891
|
-
case "border-x":
|
|
892
|
-
return borderAxisValue(theme, parsed, "border-left", "border-right");
|
|
893
|
-
case "border-y":
|
|
894
|
-
return borderAxisValue(theme, parsed, "border-top", "border-bottom");
|
|
895
|
-
case "rounded": {
|
|
896
|
-
if (parsed.value === null) return [decl("border-radius", "0.25rem")];
|
|
897
|
-
const value = parsed.value;
|
|
898
|
-
if (!parsed.isArbitrary) {
|
|
899
|
-
const size = radiusSize(value);
|
|
900
|
-
if (size !== null) return [decl("border-radius", size)];
|
|
901
|
-
}
|
|
902
|
-
const v = resolveLength(theme, parsed);
|
|
903
|
-
return v === null ? null : [decl("border-radius", v)];
|
|
904
|
-
}
|
|
905
|
-
case "ring":
|
|
906
|
-
if (parsed.value === null) return [decl("--kb-ring-width", "3px"), decl("box-shadow", RING_BOX_SHADOW)];
|
|
907
|
-
return ringValue(theme, parsed);
|
|
908
|
-
case "ring-offset":
|
|
909
|
-
return ringOffsetValue(theme, parsed);
|
|
910
|
-
case "outline":
|
|
911
|
-
if (parsed.value === null) return [decl("outline-style", "solid")];
|
|
912
|
-
if (parsed.value === "none") return [decl("outline", "none")];
|
|
913
|
-
return outlineValue(theme, parsed);
|
|
914
|
-
case "outline-offset":
|
|
915
|
-
return outlineOffsetValue(parsed);
|
|
916
|
-
default:
|
|
917
|
-
if (parsed.utility.startsWith("rounded-") && RADIUS_SIDES.has(parsed.utility.slice("rounded-".length))) {
|
|
918
|
-
return resolveRadiusSide(theme, parsed, parsed.utility.slice("rounded-".length));
|
|
919
|
-
}
|
|
920
|
-
return null;
|
|
921
|
-
}
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
// src/jsEngine/resolvers/typography.ts
|
|
925
|
-
function textSize(key) {
|
|
926
|
-
switch (key) {
|
|
927
|
-
case "xs":
|
|
928
|
-
return "0.75rem";
|
|
929
|
-
case "sm":
|
|
930
|
-
return "0.875rem";
|
|
931
|
-
case "base":
|
|
932
|
-
return "1rem";
|
|
933
|
-
case "lg":
|
|
934
|
-
return "1.125rem";
|
|
935
|
-
case "xl":
|
|
936
|
-
return "1.25rem";
|
|
937
|
-
case "2xl":
|
|
938
|
-
return "1.5rem";
|
|
939
|
-
case "3xl":
|
|
940
|
-
return "1.875rem";
|
|
941
|
-
case "4xl":
|
|
942
|
-
return "2.25rem";
|
|
943
|
-
default:
|
|
944
|
-
return null;
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
function lineHeightSize(key) {
|
|
948
|
-
switch (key) {
|
|
949
|
-
case "3":
|
|
950
|
-
return "0.75rem";
|
|
951
|
-
case "4":
|
|
952
|
-
return "1rem";
|
|
953
|
-
case "5":
|
|
954
|
-
return "1.25rem";
|
|
955
|
-
case "6":
|
|
956
|
-
return "1.5rem";
|
|
957
|
-
case "7":
|
|
958
|
-
return "1.75rem";
|
|
959
|
-
case "8":
|
|
960
|
-
return "2rem";
|
|
961
|
-
case "9":
|
|
962
|
-
return "2.25rem";
|
|
963
|
-
case "10":
|
|
964
|
-
return "2.5rem";
|
|
965
|
-
default:
|
|
966
|
-
return null;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
function textAlign(key) {
|
|
970
|
-
switch (key) {
|
|
971
|
-
case "left":
|
|
972
|
-
return "left";
|
|
973
|
-
case "center":
|
|
974
|
-
return "center";
|
|
975
|
-
case "right":
|
|
976
|
-
return "right";
|
|
977
|
-
case "justify":
|
|
978
|
-
return "justify";
|
|
979
|
-
default:
|
|
980
|
-
return null;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
function fontWeight(key) {
|
|
984
|
-
switch (key) {
|
|
985
|
-
case "thin":
|
|
986
|
-
return "100";
|
|
987
|
-
case "normal":
|
|
988
|
-
return "400";
|
|
989
|
-
case "medium":
|
|
990
|
-
return "500";
|
|
991
|
-
case "semibold":
|
|
992
|
-
return "600";
|
|
993
|
-
case "bold":
|
|
994
|
-
return "700";
|
|
995
|
-
case "extrabold":
|
|
996
|
-
return "800";
|
|
997
|
-
default:
|
|
998
|
-
return null;
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
|
|
1002
|
-
// src/jsEngine/resolvers/effects.ts
|
|
1003
|
-
function nativeShadowValue(key) {
|
|
1004
|
-
switch (key) {
|
|
1005
|
-
case "sm":
|
|
1006
|
-
return { offsetY: 1, radius: 2, opacity: 0.05, elevation: 1 };
|
|
1007
|
-
case "DEFAULT":
|
|
1008
|
-
return { offsetY: 1, radius: 3, opacity: 0.1, elevation: 2 };
|
|
1009
|
-
case "md":
|
|
1010
|
-
return { offsetY: 4, radius: 6, opacity: 0.1, elevation: 4 };
|
|
1011
|
-
case "lg":
|
|
1012
|
-
return { offsetY: 10, radius: 15, opacity: 0.1, elevation: 8 };
|
|
1013
|
-
case "xl":
|
|
1014
|
-
return { offsetY: 20, radius: 25, opacity: 0.1, elevation: 12 };
|
|
1015
|
-
case "2xl":
|
|
1016
|
-
return { offsetY: 25, radius: 50, opacity: 0.25, elevation: 16 };
|
|
1017
|
-
case "none":
|
|
1018
|
-
return { offsetY: 0, radius: 0, opacity: 0, elevation: 0 };
|
|
1019
|
-
default:
|
|
1020
|
-
return null;
|
|
1021
|
-
}
|
|
1022
|
-
}
|
|
1023
|
-
function nativeShadowDeclarations(parsed) {
|
|
1024
|
-
if (parsed.utility !== "shadow" || parsed.isArbitrary) return null;
|
|
1025
|
-
const key = parsed.value ?? "DEFAULT";
|
|
1026
|
-
const s = nativeShadowValue(key);
|
|
1027
|
-
if (s === null) return null;
|
|
1028
|
-
return [
|
|
1029
|
-
decl("shadow-color", "#000000"),
|
|
1030
|
-
decl("shadow-offset-x", "0"),
|
|
1031
|
-
decl("shadow-offset-y", String(s.offsetY)),
|
|
1032
|
-
decl("shadow-opacity", String(s.opacity)),
|
|
1033
|
-
decl("shadow-radius", String(s.radius)),
|
|
1034
|
-
decl("elevation", String(s.elevation))
|
|
1035
|
-
];
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
// src/jsEngine/resolveUtilityNative.ts
|
|
1039
|
-
function resolveTypographyNative(parsed) {
|
|
1040
|
-
switch (parsed.utility) {
|
|
1041
|
-
case "font": {
|
|
1042
|
-
if (parsed.value === null) return null;
|
|
1043
|
-
const w = fontWeight(parsed.value);
|
|
1044
|
-
return w === null ? null : [decl("font-weight", w)];
|
|
1045
|
-
}
|
|
1046
|
-
case "uppercase":
|
|
1047
|
-
return [decl("text-transform", "uppercase")];
|
|
1048
|
-
case "lowercase":
|
|
1049
|
-
return [decl("text-transform", "lowercase")];
|
|
1050
|
-
case "capitalize":
|
|
1051
|
-
return [decl("text-transform", "capitalize")];
|
|
1052
|
-
case "underline":
|
|
1053
|
-
return [decl("text-decoration-line", "underline")];
|
|
1054
|
-
case "line-through":
|
|
1055
|
-
return [decl("text-decoration-line", "line-through")];
|
|
1056
|
-
case "no-underline":
|
|
1057
|
-
return [decl("text-decoration-line", "none")];
|
|
1058
|
-
case "italic":
|
|
1059
|
-
return [decl("font-style", "italic")];
|
|
1060
|
-
case "not-italic":
|
|
1061
|
-
return [decl("font-style", "normal")];
|
|
1062
|
-
default:
|
|
1063
|
-
return null;
|
|
1064
|
-
}
|
|
1065
|
-
}
|
|
1066
|
-
function resolveLeadingTrackingNative(parsed) {
|
|
1067
|
-
const value = parsed.value;
|
|
1068
|
-
if (value === null) return null;
|
|
1069
|
-
if (parsed.utility === "leading") {
|
|
1070
|
-
if (parsed.isArbitrary) return [decl("line-height", value)];
|
|
1071
|
-
const v = lineHeightSize(value);
|
|
1072
|
-
return v === null ? null : [decl("line-height", v)];
|
|
1073
|
-
}
|
|
1074
|
-
if (parsed.utility === "tracking" && parsed.isArbitrary) {
|
|
1075
|
-
return [decl("letter-spacing", value)];
|
|
1076
|
-
}
|
|
1077
|
-
return null;
|
|
1078
|
-
}
|
|
1079
|
-
function nativeHexColor(parsed, theme) {
|
|
1080
|
-
return colorValue(theme, parsed);
|
|
1081
|
-
}
|
|
1082
|
-
function resolveTextNative(parsed, theme) {
|
|
1083
|
-
if (!parsed.isArbitrary && parsed.value !== null) {
|
|
1084
|
-
const size = textSize(parsed.value);
|
|
1085
|
-
if (size !== null) return [decl("font-size", size)];
|
|
1086
|
-
const align = textAlign(parsed.value);
|
|
1087
|
-
if (align !== null) return [decl("text-align", align)];
|
|
1088
|
-
}
|
|
1089
|
-
const hex = nativeHexColor(parsed, theme);
|
|
1090
|
-
return hex === null ? null : [decl("color", hex)];
|
|
1091
|
-
}
|
|
1092
|
-
function resolveColorNative(parsed, theme) {
|
|
1093
|
-
switch (parsed.utility) {
|
|
1094
|
-
case "bg": {
|
|
1095
|
-
const hex = nativeHexColor(parsed, theme);
|
|
1096
|
-
return hex === null ? null : [decl("background-color", hex)];
|
|
1097
|
-
}
|
|
1098
|
-
case "text":
|
|
1099
|
-
return resolveTextNative(parsed, theme);
|
|
1100
|
-
default:
|
|
1101
|
-
return null;
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
function resolveUtilityNative(parsed, theme) {
|
|
1105
|
-
return resolveFlex(parsed, false) ?? resolve(parsed, theme) ?? resolve2(parsed, theme) ?? resolve3(parsed, theme) ?? resolveColorNative(parsed, theme) ?? resolveLeadingTrackingNative(parsed) ?? resolveTypographyNative(parsed) ?? nativeShadowDeclarations(parsed);
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
// src/jsEngine/resolveStyle.ts
|
|
1109
|
-
var RESPONSIVE_BREAKPOINTS = /* @__PURE__ */ new Set(["sm", "md", "lg", "xl", "2xl"]);
|
|
1110
|
-
function nativeModifierState(modifier, theme, colorScheme, pressed, width) {
|
|
1111
|
-
if (modifier === "dark") return colorScheme === "dark";
|
|
1112
|
-
if (modifier === "active") return pressed;
|
|
1113
|
-
if (RESPONSIVE_BREAKPOINTS.has(modifier)) {
|
|
1114
|
-
const minWidth = theme.screens[modifier];
|
|
1115
|
-
if (minWidth === void 0) return null;
|
|
1116
|
-
return width >= minWidth;
|
|
1117
|
-
}
|
|
1118
|
-
return null;
|
|
1119
|
-
}
|
|
1120
|
-
function kebabToCamel(s) {
|
|
1121
|
-
return s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
1122
|
-
}
|
|
1123
|
-
var NUMERIC_LENGTH_PROPS = /* @__PURE__ */ new Set([
|
|
1124
|
-
"padding",
|
|
1125
|
-
"padding-top",
|
|
1126
|
-
"padding-right",
|
|
1127
|
-
"padding-bottom",
|
|
1128
|
-
"padding-left",
|
|
1129
|
-
"margin",
|
|
1130
|
-
"margin-top",
|
|
1131
|
-
"margin-right",
|
|
1132
|
-
"margin-bottom",
|
|
1133
|
-
"margin-left",
|
|
1134
|
-
"gap",
|
|
1135
|
-
"column-gap",
|
|
1136
|
-
"row-gap",
|
|
1137
|
-
"width",
|
|
1138
|
-
"height",
|
|
1139
|
-
"min-width",
|
|
1140
|
-
"max-width",
|
|
1141
|
-
"min-height",
|
|
1142
|
-
"max-height",
|
|
1143
|
-
"top",
|
|
1144
|
-
"right",
|
|
1145
|
-
"bottom",
|
|
1146
|
-
"left",
|
|
1147
|
-
"inset",
|
|
1148
|
-
"border-radius",
|
|
1149
|
-
"border-width",
|
|
1150
|
-
"font-size",
|
|
1151
|
-
"z-index",
|
|
1152
|
-
"line-height",
|
|
1153
|
-
"letter-spacing",
|
|
1154
|
-
"flex",
|
|
1155
|
-
"flex-grow",
|
|
1156
|
-
"flex-shrink",
|
|
1157
|
-
"order",
|
|
1158
|
-
"flex-basis",
|
|
1159
|
-
"shadow-opacity",
|
|
1160
|
-
"shadow-radius",
|
|
1161
|
-
"elevation",
|
|
1162
|
-
// Per-side border width + per-corner radius — see resolvers/border.ts's
|
|
1163
|
-
// new borderSideValue/borderAxisValue/resolveRadiusSide additions; RN's
|
|
1164
|
-
// style system wants plain numbers for these exactly like the generic
|
|
1165
|
-
// "border-width"/"border-radius" forms above.
|
|
1166
|
-
"border-top-width",
|
|
1167
|
-
"border-right-width",
|
|
1168
|
-
"border-bottom-width",
|
|
1169
|
-
"border-left-width",
|
|
1170
|
-
"border-top-left-radius",
|
|
1171
|
-
"border-top-right-radius",
|
|
1172
|
-
"border-bottom-right-radius",
|
|
1173
|
-
"border-bottom-left-radius",
|
|
1174
|
-
"outline-width",
|
|
1175
|
-
"outline-offset"
|
|
1176
|
-
]);
|
|
1177
|
-
function rnStyleValue(property, value) {
|
|
1178
|
-
if (NUMERIC_LENGTH_PROPS.has(property)) {
|
|
1179
|
-
let px = null;
|
|
1180
|
-
if (value.endsWith("px")) {
|
|
1181
|
-
const n = Number(value.slice(0, -2));
|
|
1182
|
-
px = Number.isFinite(n) ? n : null;
|
|
1183
|
-
} else if (value.endsWith("rem")) {
|
|
1184
|
-
const n = Number(value.slice(0, -3));
|
|
1185
|
-
px = Number.isFinite(n) ? n * 16 : null;
|
|
1186
|
-
} else {
|
|
1187
|
-
const n = Number(value);
|
|
1188
|
-
px = value.trim() !== "" && Number.isFinite(n) ? n : null;
|
|
1189
|
-
}
|
|
1190
|
-
if (px !== null) return px;
|
|
1191
|
-
}
|
|
1192
|
-
return value;
|
|
1193
|
-
}
|
|
1194
|
-
function resolveStyleJs(classString, theme, colorScheme, pressed, width) {
|
|
1195
|
-
const style = {};
|
|
1196
|
-
let shadowOffset = null;
|
|
1197
|
-
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1198
|
-
const parsed = parseClass(token);
|
|
1199
|
-
const allModifiersHold = parsed.modifiers.every(
|
|
1200
|
-
(m) => nativeModifierState(m, theme, colorScheme, pressed, width) === true
|
|
1201
|
-
);
|
|
1202
|
-
if (!allModifiersHold) continue;
|
|
1203
|
-
const decls = resolveUtilityNative(parsed, theme);
|
|
1204
|
-
if (decls === null) continue;
|
|
1205
|
-
for (const d of decls) {
|
|
1206
|
-
if (d.property.startsWith("__")) {
|
|
1207
|
-
continue;
|
|
1208
|
-
}
|
|
1209
|
-
if (d.property === "shadow-offset-x" || d.property === "shadow-offset-y") {
|
|
1210
|
-
const n = Number(d.value);
|
|
1211
|
-
if (!Number.isFinite(n)) continue;
|
|
1212
|
-
if (shadowOffset === null) shadowOffset = {};
|
|
1213
|
-
shadowOffset[d.property === "shadow-offset-x" ? "width" : "height"] = n;
|
|
1214
|
-
continue;
|
|
1215
|
-
}
|
|
1216
|
-
style[kebabToCamel(d.property)] = rnStyleValue(d.property, d.value);
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
if (shadowOffset !== null) {
|
|
1220
|
-
style.shadowOffset = { width: shadowOffset.width ?? 0, height: shadowOffset.height ?? 0 };
|
|
1221
|
-
}
|
|
1222
|
-
return style;
|
|
1223
|
-
}
|
|
1224
|
-
|
|
1225
|
-
// src/nativeBridge.ts
|
|
1226
|
-
function resolveStyle(classString, pressed = false) {
|
|
1227
|
-
const colorScheme = getGlobalDarkMode() ? "dark" : "light";
|
|
1228
|
-
const width = Dimensions.get("window").width;
|
|
1229
|
-
const KbachModule = TurboModuleRegistry.get("KbachModule");
|
|
1230
|
-
if (!KbachModule) {
|
|
1231
|
-
return resolveStyleJs(classString, getTheme(), colorScheme, pressed, width);
|
|
1232
|
-
}
|
|
1233
|
-
const json = KbachModule.resolveStyle(classString, getThemeJson(), colorScheme, pressed, width);
|
|
1234
|
-
return JSON.parse(json);
|
|
1235
|
-
}
|
|
1236
|
-
|
|
1237
|
-
export {
|
|
1238
|
-
resolveStyle
|
|
1239
|
-
};
|