@mgcrea/react-native-tailwind 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/README.md +459 -39
  2. package/dist/babel/index.cjs +810 -279
  3. package/dist/babel/index.d.ts +2 -1
  4. package/dist/babel/index.ts +328 -22
  5. package/dist/components/Pressable.d.ts +32 -0
  6. package/dist/components/Pressable.js +1 -0
  7. package/dist/components/TextInput.d.ts +56 -0
  8. package/dist/components/TextInput.js +1 -0
  9. package/dist/index.d.ts +9 -2
  10. package/dist/index.js +1 -1
  11. package/dist/parser/aspectRatio.d.ts +16 -0
  12. package/dist/parser/aspectRatio.js +1 -0
  13. package/dist/parser/aspectRatio.test.d.ts +1 -0
  14. package/dist/parser/aspectRatio.test.js +1 -0
  15. package/dist/parser/borders.js +1 -1
  16. package/dist/parser/borders.test.d.ts +1 -0
  17. package/dist/parser/borders.test.js +1 -0
  18. package/dist/parser/colors.d.ts +1 -0
  19. package/dist/parser/colors.js +1 -1
  20. package/dist/parser/colors.test.d.ts +1 -0
  21. package/dist/parser/colors.test.js +1 -0
  22. package/dist/parser/index.d.ts +4 -0
  23. package/dist/parser/index.js +1 -1
  24. package/dist/parser/layout.d.ts +2 -0
  25. package/dist/parser/layout.js +1 -1
  26. package/dist/parser/layout.test.d.ts +1 -0
  27. package/dist/parser/layout.test.js +1 -0
  28. package/dist/parser/modifiers.d.ts +47 -0
  29. package/dist/parser/modifiers.js +1 -0
  30. package/dist/parser/modifiers.test.d.ts +1 -0
  31. package/dist/parser/modifiers.test.js +1 -0
  32. package/dist/parser/shadows.d.ts +26 -0
  33. package/dist/parser/shadows.js +1 -0
  34. package/dist/parser/shadows.test.d.ts +1 -0
  35. package/dist/parser/shadows.test.js +1 -0
  36. package/dist/parser/sizing.test.d.ts +1 -0
  37. package/dist/parser/sizing.test.js +1 -0
  38. package/dist/parser/spacing.d.ts +1 -1
  39. package/dist/parser/spacing.js +1 -1
  40. package/dist/parser/spacing.test.d.ts +1 -0
  41. package/dist/parser/spacing.test.js +1 -0
  42. package/dist/parser/typography.d.ts +2 -1
  43. package/dist/parser/typography.js +1 -1
  44. package/dist/parser/typography.test.d.ts +1 -0
  45. package/dist/parser/typography.test.js +1 -0
  46. package/dist/types.d.ts +5 -2
  47. package/package.json +7 -6
  48. package/src/babel/index.ts +328 -22
  49. package/src/components/Pressable.tsx +46 -0
  50. package/src/components/TextInput.tsx +90 -0
  51. package/src/index.ts +20 -2
  52. package/src/parser/aspectRatio.test.ts +191 -0
  53. package/src/parser/aspectRatio.ts +73 -0
  54. package/src/parser/borders.test.ts +329 -0
  55. package/src/parser/borders.ts +187 -108
  56. package/src/parser/colors.test.ts +335 -0
  57. package/src/parser/colors.ts +117 -6
  58. package/src/parser/index.ts +13 -2
  59. package/src/parser/layout.test.ts +459 -0
  60. package/src/parser/layout.ts +128 -0
  61. package/src/parser/modifiers.test.ts +375 -0
  62. package/src/parser/modifiers.ts +104 -0
  63. package/src/parser/shadows.test.ts +201 -0
  64. package/src/parser/shadows.ts +133 -0
  65. package/src/parser/sizing.test.ts +256 -0
  66. package/src/parser/spacing.test.ts +226 -0
  67. package/src/parser/spacing.ts +93 -138
  68. package/src/parser/typography.test.ts +221 -0
  69. package/src/parser/typography.ts +143 -112
  70. package/src/types.ts +2 -2
  71. package/dist/react-native.d.js +0 -1
@@ -0,0 +1,459 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { parseLayout } from "./layout";
3
+
4
+ describe("parseLayout - display utilities", () => {
5
+ it("should parse display flex", () => {
6
+ expect(parseLayout("flex")).toEqual({ display: "flex" });
7
+ });
8
+
9
+ it("should parse display hidden", () => {
10
+ expect(parseLayout("hidden")).toEqual({ display: "none" });
11
+ });
12
+ });
13
+
14
+ describe("parseLayout - flex direction utilities", () => {
15
+ it("should parse flex row", () => {
16
+ expect(parseLayout("flex-row")).toEqual({ flexDirection: "row" });
17
+ });
18
+
19
+ it("should parse flex row reverse", () => {
20
+ expect(parseLayout("flex-row-reverse")).toEqual({ flexDirection: "row-reverse" });
21
+ });
22
+
23
+ it("should parse flex column", () => {
24
+ expect(parseLayout("flex-col")).toEqual({ flexDirection: "column" });
25
+ });
26
+
27
+ it("should parse flex column reverse", () => {
28
+ expect(parseLayout("flex-col-reverse")).toEqual({ flexDirection: "column-reverse" });
29
+ });
30
+ });
31
+
32
+ describe("parseLayout - flex wrap utilities", () => {
33
+ it("should parse flex wrap", () => {
34
+ expect(parseLayout("flex-wrap")).toEqual({ flexWrap: "wrap" });
35
+ });
36
+
37
+ it("should parse flex wrap reverse", () => {
38
+ expect(parseLayout("flex-wrap-reverse")).toEqual({ flexWrap: "wrap-reverse" });
39
+ });
40
+
41
+ it("should parse flex nowrap", () => {
42
+ expect(parseLayout("flex-nowrap")).toEqual({ flexWrap: "nowrap" });
43
+ });
44
+ });
45
+
46
+ describe("parseLayout - flex utilities", () => {
47
+ it("should parse flex-1", () => {
48
+ expect(parseLayout("flex-1")).toEqual({ flex: 1 });
49
+ });
50
+
51
+ it("should parse flex-auto", () => {
52
+ expect(parseLayout("flex-auto")).toEqual({ flex: 1 });
53
+ });
54
+
55
+ it("should parse flex-none", () => {
56
+ expect(parseLayout("flex-none")).toEqual({ flex: 0 });
57
+ });
58
+ });
59
+
60
+ describe("parseLayout - flex grow/shrink utilities", () => {
61
+ it("should parse grow", () => {
62
+ expect(parseLayout("grow")).toEqual({ flexGrow: 1 });
63
+ });
64
+
65
+ it("should parse grow-0", () => {
66
+ expect(parseLayout("grow-0")).toEqual({ flexGrow: 0 });
67
+ });
68
+
69
+ it("should parse shrink", () => {
70
+ expect(parseLayout("shrink")).toEqual({ flexShrink: 1 });
71
+ });
72
+
73
+ it("should parse shrink-0", () => {
74
+ expect(parseLayout("shrink-0")).toEqual({ flexShrink: 0 });
75
+ });
76
+ });
77
+
78
+ describe("parseLayout - justify content utilities", () => {
79
+ it("should parse justify-start", () => {
80
+ expect(parseLayout("justify-start")).toEqual({ justifyContent: "flex-start" });
81
+ });
82
+
83
+ it("should parse justify-end", () => {
84
+ expect(parseLayout("justify-end")).toEqual({ justifyContent: "flex-end" });
85
+ });
86
+
87
+ it("should parse justify-center", () => {
88
+ expect(parseLayout("justify-center")).toEqual({ justifyContent: "center" });
89
+ });
90
+
91
+ it("should parse justify-between", () => {
92
+ expect(parseLayout("justify-between")).toEqual({ justifyContent: "space-between" });
93
+ });
94
+
95
+ it("should parse justify-around", () => {
96
+ expect(parseLayout("justify-around")).toEqual({ justifyContent: "space-around" });
97
+ });
98
+
99
+ it("should parse justify-evenly", () => {
100
+ expect(parseLayout("justify-evenly")).toEqual({ justifyContent: "space-evenly" });
101
+ });
102
+ });
103
+
104
+ describe("parseLayout - align items utilities", () => {
105
+ it("should parse items-start", () => {
106
+ expect(parseLayout("items-start")).toEqual({ alignItems: "flex-start" });
107
+ });
108
+
109
+ it("should parse items-end", () => {
110
+ expect(parseLayout("items-end")).toEqual({ alignItems: "flex-end" });
111
+ });
112
+
113
+ it("should parse items-center", () => {
114
+ expect(parseLayout("items-center")).toEqual({ alignItems: "center" });
115
+ });
116
+
117
+ it("should parse items-baseline", () => {
118
+ expect(parseLayout("items-baseline")).toEqual({ alignItems: "baseline" });
119
+ });
120
+
121
+ it("should parse items-stretch", () => {
122
+ expect(parseLayout("items-stretch")).toEqual({ alignItems: "stretch" });
123
+ });
124
+ });
125
+
126
+ describe("parseLayout - align self utilities", () => {
127
+ it("should parse self-auto", () => {
128
+ expect(parseLayout("self-auto")).toEqual({ alignSelf: "auto" });
129
+ });
130
+
131
+ it("should parse self-start", () => {
132
+ expect(parseLayout("self-start")).toEqual({ alignSelf: "flex-start" });
133
+ });
134
+
135
+ it("should parse self-end", () => {
136
+ expect(parseLayout("self-end")).toEqual({ alignSelf: "flex-end" });
137
+ });
138
+
139
+ it("should parse self-center", () => {
140
+ expect(parseLayout("self-center")).toEqual({ alignSelf: "center" });
141
+ });
142
+
143
+ it("should parse self-stretch", () => {
144
+ expect(parseLayout("self-stretch")).toEqual({ alignSelf: "stretch" });
145
+ });
146
+
147
+ it("should parse self-baseline", () => {
148
+ expect(parseLayout("self-baseline")).toEqual({ alignSelf: "baseline" });
149
+ });
150
+ });
151
+
152
+ describe("parseLayout - align content utilities", () => {
153
+ it("should parse content-start", () => {
154
+ expect(parseLayout("content-start")).toEqual({ alignContent: "flex-start" });
155
+ });
156
+
157
+ it("should parse content-end", () => {
158
+ expect(parseLayout("content-end")).toEqual({ alignContent: "flex-end" });
159
+ });
160
+
161
+ it("should parse content-center", () => {
162
+ expect(parseLayout("content-center")).toEqual({ alignContent: "center" });
163
+ });
164
+
165
+ it("should parse content-between", () => {
166
+ expect(parseLayout("content-between")).toEqual({ alignContent: "space-between" });
167
+ });
168
+
169
+ it("should parse content-around", () => {
170
+ expect(parseLayout("content-around")).toEqual({ alignContent: "space-around" });
171
+ });
172
+
173
+ it("should parse content-stretch", () => {
174
+ expect(parseLayout("content-stretch")).toEqual({ alignContent: "stretch" });
175
+ });
176
+ });
177
+
178
+ describe("parseLayout - position utilities", () => {
179
+ it("should parse absolute", () => {
180
+ expect(parseLayout("absolute")).toEqual({ position: "absolute" });
181
+ });
182
+
183
+ it("should parse relative", () => {
184
+ expect(parseLayout("relative")).toEqual({ position: "relative" });
185
+ });
186
+ });
187
+
188
+ describe("parseLayout - overflow utilities", () => {
189
+ it("should parse overflow-hidden", () => {
190
+ expect(parseLayout("overflow-hidden")).toEqual({ overflow: "hidden" });
191
+ });
192
+
193
+ it("should parse overflow-visible", () => {
194
+ expect(parseLayout("overflow-visible")).toEqual({ overflow: "visible" });
195
+ });
196
+
197
+ it("should parse overflow-scroll", () => {
198
+ expect(parseLayout("overflow-scroll")).toEqual({ overflow: "scroll" });
199
+ });
200
+ });
201
+
202
+ describe("parseLayout - edge cases", () => {
203
+ it("should return null for invalid classes", () => {
204
+ expect(parseLayout("invalid")).toBeNull();
205
+ expect(parseLayout("flex-invalid")).toBeNull();
206
+ expect(parseLayout("justify")).toBeNull();
207
+ expect(parseLayout("items")).toBeNull();
208
+ });
209
+
210
+ it("should return null for empty string", () => {
211
+ expect(parseLayout("")).toBeNull();
212
+ });
213
+
214
+ it("should return null for partial class names", () => {
215
+ expect(parseLayout("fle")).toBeNull();
216
+ expect(parseLayout("flexbox")).toBeNull();
217
+ expect(parseLayout("justify-start-center")).toBeNull();
218
+ });
219
+
220
+ it("should return null for CSS classes not in React Native", () => {
221
+ expect(parseLayout("inline")).toBeNull();
222
+ expect(parseLayout("block")).toBeNull();
223
+ expect(parseLayout("inline-block")).toBeNull();
224
+ expect(parseLayout("grid")).toBeNull();
225
+ });
226
+ });
227
+
228
+ describe("parseLayout - comprehensive coverage", () => {
229
+ it("should handle all flex direction variants", () => {
230
+ const directions = ["flex-row", "flex-row-reverse", "flex-col", "flex-col-reverse"];
231
+ directions.forEach((dir) => {
232
+ expect(parseLayout(dir)).toBeTruthy();
233
+ });
234
+ });
235
+
236
+ it("should handle all flex wrap variants", () => {
237
+ const wraps = ["flex-wrap", "flex-wrap-reverse", "flex-nowrap"];
238
+ wraps.forEach((wrap) => {
239
+ expect(parseLayout(wrap)).toBeTruthy();
240
+ });
241
+ });
242
+
243
+ it("should handle all justify content variants", () => {
244
+ const justifies = [
245
+ "justify-start",
246
+ "justify-end",
247
+ "justify-center",
248
+ "justify-between",
249
+ "justify-around",
250
+ "justify-evenly",
251
+ ];
252
+ justifies.forEach((justify) => {
253
+ expect(parseLayout(justify)).toBeTruthy();
254
+ });
255
+ });
256
+
257
+ it("should handle all align items variants", () => {
258
+ const aligns = ["items-start", "items-end", "items-center", "items-baseline", "items-stretch"];
259
+ aligns.forEach((align) => {
260
+ expect(parseLayout(align)).toBeTruthy();
261
+ });
262
+ });
263
+
264
+ it("should handle all align self variants", () => {
265
+ const selfs = ["self-auto", "self-start", "self-end", "self-center", "self-stretch", "self-baseline"];
266
+ selfs.forEach((self) => {
267
+ expect(parseLayout(self)).toBeTruthy();
268
+ });
269
+ });
270
+
271
+ it("should handle all align content variants", () => {
272
+ const contents = [
273
+ "content-start",
274
+ "content-end",
275
+ "content-center",
276
+ "content-between",
277
+ "content-around",
278
+ "content-stretch",
279
+ ];
280
+ contents.forEach((content) => {
281
+ expect(parseLayout(content)).toBeTruthy();
282
+ });
283
+ });
284
+
285
+ it("should handle all position variants", () => {
286
+ const positions = ["absolute", "relative"];
287
+ positions.forEach((position) => {
288
+ expect(parseLayout(position)).toBeTruthy();
289
+ });
290
+ });
291
+
292
+ it("should handle all overflow variants", () => {
293
+ const overflows = ["overflow-hidden", "overflow-visible", "overflow-scroll"];
294
+ overflows.forEach((overflow) => {
295
+ expect(parseLayout(overflow)).toBeTruthy();
296
+ });
297
+ });
298
+ });
299
+
300
+ describe("parseLayout - case sensitivity", () => {
301
+ it("should be case-sensitive", () => {
302
+ expect(parseLayout("FLEX")).toBeNull();
303
+ expect(parseLayout("Flex")).toBeNull();
304
+ expect(parseLayout("ABSOLUTE")).toBeNull();
305
+ });
306
+ });
307
+
308
+ describe("parseLayout - z-index utilities", () => {
309
+ it("should parse z-index values", () => {
310
+ expect(parseLayout("z-0")).toEqual({ zIndex: 0 });
311
+ expect(parseLayout("z-10")).toEqual({ zIndex: 10 });
312
+ expect(parseLayout("z-20")).toEqual({ zIndex: 20 });
313
+ expect(parseLayout("z-30")).toEqual({ zIndex: 30 });
314
+ expect(parseLayout("z-40")).toEqual({ zIndex: 40 });
315
+ expect(parseLayout("z-50")).toEqual({ zIndex: 50 });
316
+ });
317
+
318
+ it("should parse z-auto as 0", () => {
319
+ expect(parseLayout("z-auto")).toEqual({ zIndex: 0 });
320
+ });
321
+
322
+ it("should return null for invalid z-index values", () => {
323
+ expect(parseLayout("z-100")).toBeNull();
324
+ expect(parseLayout("z-5")).toBeNull();
325
+ expect(parseLayout("z-invalid")).toBeNull();
326
+ });
327
+ });
328
+
329
+ describe("parseLayout - positioning utilities", () => {
330
+ it("should parse top values", () => {
331
+ expect(parseLayout("top-0")).toEqual({ top: 0 });
332
+ expect(parseLayout("top-4")).toEqual({ top: 16 });
333
+ expect(parseLayout("top-8")).toEqual({ top: 32 });
334
+ expect(parseLayout("top-16")).toEqual({ top: 64 });
335
+ });
336
+
337
+ it("should parse right values", () => {
338
+ expect(parseLayout("right-0")).toEqual({ right: 0 });
339
+ expect(parseLayout("right-4")).toEqual({ right: 16 });
340
+ expect(parseLayout("right-8")).toEqual({ right: 32 });
341
+ expect(parseLayout("right-16")).toEqual({ right: 64 });
342
+ });
343
+
344
+ it("should parse bottom values", () => {
345
+ expect(parseLayout("bottom-0")).toEqual({ bottom: 0 });
346
+ expect(parseLayout("bottom-4")).toEqual({ bottom: 16 });
347
+ expect(parseLayout("bottom-8")).toEqual({ bottom: 32 });
348
+ expect(parseLayout("bottom-16")).toEqual({ bottom: 64 });
349
+ });
350
+
351
+ it("should parse left values", () => {
352
+ expect(parseLayout("left-0")).toEqual({ left: 0 });
353
+ expect(parseLayout("left-4")).toEqual({ left: 16 });
354
+ expect(parseLayout("left-8")).toEqual({ left: 32 });
355
+ expect(parseLayout("left-16")).toEqual({ left: 64 });
356
+ });
357
+
358
+ it("should parse fractional positioning values", () => {
359
+ expect(parseLayout("top-0.5")).toEqual({ top: 2 });
360
+ expect(parseLayout("right-1.5")).toEqual({ right: 6 });
361
+ expect(parseLayout("bottom-2.5")).toEqual({ bottom: 10 });
362
+ expect(parseLayout("left-3.5")).toEqual({ left: 14 });
363
+ });
364
+
365
+ it("should parse auto positioning values as empty object", () => {
366
+ // Auto removes the property, which is useful for responsive overrides
367
+ expect(parseLayout("top-auto")).toEqual({});
368
+ expect(parseLayout("right-auto")).toEqual({});
369
+ expect(parseLayout("bottom-auto")).toEqual({});
370
+ expect(parseLayout("left-auto")).toEqual({});
371
+ });
372
+ });
373
+
374
+ describe("parseLayout - inset utilities", () => {
375
+ it("should parse inset (all sides) values", () => {
376
+ expect(parseLayout("inset-0")).toEqual({ top: 0, right: 0, bottom: 0, left: 0 });
377
+ expect(parseLayout("inset-4")).toEqual({ top: 16, right: 16, bottom: 16, left: 16 });
378
+ expect(parseLayout("inset-8")).toEqual({ top: 32, right: 32, bottom: 32, left: 32 });
379
+ });
380
+
381
+ it("should parse inset-x (horizontal) values", () => {
382
+ expect(parseLayout("inset-x-0")).toEqual({ left: 0, right: 0 });
383
+ expect(parseLayout("inset-x-4")).toEqual({ left: 16, right: 16 });
384
+ expect(parseLayout("inset-x-8")).toEqual({ left: 32, right: 32 });
385
+ });
386
+
387
+ it("should parse inset-y (vertical) values", () => {
388
+ expect(parseLayout("inset-y-0")).toEqual({ top: 0, bottom: 0 });
389
+ expect(parseLayout("inset-y-4")).toEqual({ top: 16, bottom: 16 });
390
+ expect(parseLayout("inset-y-8")).toEqual({ top: 32, bottom: 32 });
391
+ });
392
+
393
+ it("should parse fractional inset values", () => {
394
+ expect(parseLayout("inset-0.5")).toEqual({ top: 2, right: 2, bottom: 2, left: 2 });
395
+ expect(parseLayout("inset-x-1.5")).toEqual({ left: 6, right: 6 });
396
+ expect(parseLayout("inset-y-2.5")).toEqual({ top: 10, bottom: 10 });
397
+ });
398
+
399
+ it("should return null for invalid inset values", () => {
400
+ expect(parseLayout("inset-100")).toBeNull();
401
+ expect(parseLayout("inset-x-100")).toBeNull();
402
+ expect(parseLayout("inset-y-100")).toBeNull();
403
+ });
404
+ });
405
+
406
+ describe("parseLayout - specific property coverage", () => {
407
+ it("should return unique objects for each class", () => {
408
+ const flex1 = parseLayout("flex");
409
+ const flex2 = parseLayout("flex");
410
+ // Should be equal in value but not necessarily same reference
411
+ expect(flex1).toEqual(flex2);
412
+ });
413
+
414
+ it("should handle flex value variations", () => {
415
+ expect(parseLayout("flex-1")).toEqual({ flex: 1 });
416
+ expect(parseLayout("flex-auto")).toEqual({ flex: 1 });
417
+ expect(parseLayout("flex-none")).toEqual({ flex: 0 });
418
+ });
419
+
420
+ it("should distinguish between similar class names", () => {
421
+ expect(parseLayout("flex")).not.toEqual(parseLayout("flex-1"));
422
+ expect(parseLayout("grow")).not.toEqual(parseLayout("grow-0"));
423
+ expect(parseLayout("shrink")).not.toEqual(parseLayout("shrink-0"));
424
+ });
425
+
426
+ it("should handle positioning with absolute/relative", () => {
427
+ // Common pattern: absolute + top/left
428
+ expect(parseLayout("absolute")).toEqual({ position: "absolute" });
429
+ expect(parseLayout("top-0")).toEqual({ top: 0 });
430
+ expect(parseLayout("left-0")).toEqual({ left: 0 });
431
+ });
432
+
433
+ it("should handle all positioning directions", () => {
434
+ expect(parseLayout("top-4")).toHaveProperty("top");
435
+ expect(parseLayout("right-4")).toHaveProperty("right");
436
+ expect(parseLayout("bottom-4")).toHaveProperty("bottom");
437
+ expect(parseLayout("left-4")).toHaveProperty("left");
438
+ });
439
+
440
+ it("should handle inset shorthand variations", () => {
441
+ const insetAll = parseLayout("inset-4");
442
+ expect(insetAll).toHaveProperty("top", 16);
443
+ expect(insetAll).toHaveProperty("right", 16);
444
+ expect(insetAll).toHaveProperty("bottom", 16);
445
+ expect(insetAll).toHaveProperty("left", 16);
446
+
447
+ const insetX = parseLayout("inset-x-4");
448
+ expect(insetX).toHaveProperty("left", 16);
449
+ expect(insetX).toHaveProperty("right", 16);
450
+ expect(insetX).not.toHaveProperty("top");
451
+ expect(insetX).not.toHaveProperty("bottom");
452
+
453
+ const insetY = parseLayout("inset-y-4");
454
+ expect(insetY).toHaveProperty("top", 16);
455
+ expect(insetY).toHaveProperty("bottom", 16);
456
+ expect(insetY).not.toHaveProperty("left");
457
+ expect(insetY).not.toHaveProperty("right");
458
+ });
459
+ });
@@ -92,10 +92,138 @@ const OVERFLOW_MAP: Record<string, StyleObject> = {
92
92
  "overflow-scroll": { overflow: "scroll" },
93
93
  };
94
94
 
95
+ // Z-index scale
96
+ export const Z_INDEX_SCALE: Record<string, number> = {
97
+ 0: 0,
98
+ 10: 10,
99
+ 20: 20,
100
+ 30: 30,
101
+ 40: 40,
102
+ 50: 50,
103
+ auto: 0, // React Native doesn't have 'auto', default to 0
104
+ };
105
+
106
+ // Inset scale (for top/right/bottom/left positioning in pixels)
107
+ export const INSET_SCALE: Record<string, number> = {
108
+ 0: 0,
109
+ 0.5: 2,
110
+ 1: 4,
111
+ 1.5: 6,
112
+ 2: 8,
113
+ 2.5: 10,
114
+ 3: 12,
115
+ 3.5: 14,
116
+ 4: 16,
117
+ 5: 20,
118
+ 6: 24,
119
+ 8: 32,
120
+ 10: 40,
121
+ 12: 48,
122
+ 16: 64,
123
+ 20: 80,
124
+ 24: 96,
125
+ };
126
+
95
127
  /**
96
128
  * Parse layout classes
97
129
  */
98
130
  export function parseLayout(cls: string): StyleObject | null {
131
+ // Z-index: z-0, z-10, z-20, etc.
132
+ if (cls.startsWith("z-")) {
133
+ const zKey = cls.substring(2);
134
+ const zValue = Z_INDEX_SCALE[zKey];
135
+ if (zValue !== undefined) {
136
+ return { zIndex: zValue };
137
+ }
138
+ }
139
+
140
+ // Top positioning: top-0, top-4, etc.
141
+ if (cls.startsWith("top-")) {
142
+ const topKey = cls.substring(4);
143
+
144
+ // Auto value - return empty object (no-op, removes the property)
145
+ if (topKey === "auto") {
146
+ return {};
147
+ }
148
+
149
+ const topValue = INSET_SCALE[topKey];
150
+ if (topValue !== undefined) {
151
+ return { top: topValue };
152
+ }
153
+ }
154
+
155
+ // Right positioning: right-0, right-4, etc.
156
+ if (cls.startsWith("right-")) {
157
+ const rightKey = cls.substring(6);
158
+
159
+ // Auto value - return empty object (no-op, removes the property)
160
+ if (rightKey === "auto") {
161
+ return {};
162
+ }
163
+
164
+ const rightValue = INSET_SCALE[rightKey];
165
+ if (rightValue !== undefined) {
166
+ return { right: rightValue };
167
+ }
168
+ }
169
+
170
+ // Bottom positioning: bottom-0, bottom-4, etc.
171
+ if (cls.startsWith("bottom-")) {
172
+ const bottomKey = cls.substring(7);
173
+
174
+ // Auto value - return empty object (no-op, removes the property)
175
+ if (bottomKey === "auto") {
176
+ return {};
177
+ }
178
+
179
+ const bottomValue = INSET_SCALE[bottomKey];
180
+ if (bottomValue !== undefined) {
181
+ return { bottom: bottomValue };
182
+ }
183
+ }
184
+
185
+ // Left positioning: left-0, left-4, etc.
186
+ if (cls.startsWith("left-")) {
187
+ const leftKey = cls.substring(5);
188
+
189
+ // Auto value - return empty object (no-op, removes the property)
190
+ if (leftKey === "auto") {
191
+ return {};
192
+ }
193
+
194
+ const leftValue = INSET_SCALE[leftKey];
195
+ if (leftValue !== undefined) {
196
+ return { left: leftValue };
197
+ }
198
+ }
199
+
200
+ // Inset (all sides): inset-0, inset-4, etc.
201
+ if (cls.startsWith("inset-")) {
202
+ const insetKey = cls.substring(6);
203
+ const insetValue = INSET_SCALE[insetKey];
204
+ if (insetValue !== undefined) {
205
+ return { top: insetValue, right: insetValue, bottom: insetValue, left: insetValue };
206
+ }
207
+ }
208
+
209
+ // Inset X (left and right): inset-x-0, inset-x-4, etc.
210
+ if (cls.startsWith("inset-x-")) {
211
+ const insetKey = cls.substring(8);
212
+ const insetValue = INSET_SCALE[insetKey];
213
+ if (insetValue !== undefined) {
214
+ return { left: insetValue, right: insetValue };
215
+ }
216
+ }
217
+
218
+ // Inset Y (top and bottom): inset-y-0, inset-y-4, etc.
219
+ if (cls.startsWith("inset-y-")) {
220
+ const insetKey = cls.substring(8);
221
+ const insetValue = INSET_SCALE[insetKey];
222
+ if (insetValue !== undefined) {
223
+ return { top: insetValue, bottom: insetValue };
224
+ }
225
+ }
226
+
99
227
  // Try each lookup table in order
100
228
  return (
101
229
  DISPLAY_MAP[cls] ??