chai-tailwind-js 1.0.3 → 1.0.4

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.
@@ -63,6 +63,24 @@
63
63
  "4xl": "32px",
64
64
  "5xl": "40px"
65
65
  },
66
+ fontWeight: {
67
+ thin: 100,
68
+ light: 300,
69
+ normal: 400,
70
+ medium: 500,
71
+ bold: 700
72
+ },
73
+ letterSpacing: {
74
+ tight: "-0.05em",
75
+ normal: "0",
76
+ wide: "0.05em"
77
+ },
78
+ lineHeight: {
79
+ none: "1",
80
+ tight: "1.25",
81
+ normal: "1.5",
82
+ loose: "2"
83
+ },
66
84
  borderRadius: {
67
85
  none: "0px",
68
86
  sm: "4px",
@@ -72,11 +90,92 @@
72
90
  xl: "16px",
73
91
  full: "9999px"
74
92
  },
93
+ borderWidth: {
94
+ DEFAULT: "1px",
95
+ 2: "2px",
96
+ 4: "4px"
97
+ },
75
98
  shadows: {
76
99
  sm: "0 1px 3px rgba(0,0,0,0.1)",
77
100
  DEFAULT: "0 4px 10px rgba(0,0,0,0.1)",
78
101
  md: "0 6px 20px rgba(0,0,0,0.15)",
79
102
  lg: "0 10px 30px rgba(0,0,0,0.2)"
103
+ },
104
+ zIndex: {
105
+ 0: 0,
106
+ 10: 10,
107
+ 20: 20,
108
+ 50: 50,
109
+ 100: 100
110
+ },
111
+ transitionTiming: {
112
+ linear: "linear",
113
+ in: "ease-in",
114
+ out: "ease-out",
115
+ "in-out": "ease-in-out"
116
+ },
117
+ blur: {
118
+ none: "0px",
119
+ sm: "4px",
120
+ DEFAULT: "8px",
121
+ md: "12px",
122
+ lg: "16px",
123
+ xl: "24px"
124
+ },
125
+ opacity: {
126
+ 0: "0",
127
+ 5: "0.05",
128
+ 10: "0.1",
129
+ 20: "0.2",
130
+ 25: "0.25",
131
+ 30: "0.3",
132
+ 40: "0.4",
133
+ 50: "0.5",
134
+ 60: "0.6",
135
+ 70: "0.7",
136
+ 75: "0.75",
137
+ 80: "0.8",
138
+ 90: "0.9",
139
+ 95: "0.95",
140
+ 100: "1"
141
+ },
142
+ display: {
143
+ block: "block",
144
+ inline: "inline",
145
+ "inline-block": "inline-block",
146
+ flex: "flex",
147
+ grid: "grid",
148
+ hidden: "none"
149
+ },
150
+ textAlign: {
151
+ left: "left",
152
+ center: "center",
153
+ right: "right",
154
+ justify: "justify"
155
+ },
156
+ widths: {
157
+ full: "100%",
158
+ half: "50%",
159
+ third: "33.333%",
160
+ quarter: "25%",
161
+ screen: "100vw",
162
+ auto: "auto"
163
+ },
164
+ heights: {
165
+ full: "100%",
166
+ screen: "100vh",
167
+ auto: "auto"
168
+ },
169
+ cursor: {
170
+ pointer: "pointer",
171
+ default: "default",
172
+ "not-allowed": "not-allowed"
173
+ },
174
+ overflow: {
175
+ hidden: "hidden",
176
+ auto: "auto",
177
+ scroll: "scroll",
178
+ visible: "visible"
80
179
  }
81
180
  };
82
181
 
@@ -104,62 +203,78 @@
104
203
 
105
204
  // src/runtime/interpreter.js
106
205
  var handlers = {
107
- p: (element, value) => {
108
- const spacing2 = config.spacing[value];
109
- if (spacing2) element.style.padding = spacing2;
206
+ p: (el, value) => {
207
+ const s = config.spacing[value];
208
+ if (s) el.style.padding = s;
110
209
  },
111
- m: (element, value) => {
112
- const spacing2 = config.spacing[value];
113
- if (spacing2) element.style.margin = spacing2;
210
+ m: (el, value) => {
211
+ const s = config.spacing[value];
212
+ if (s) el.style.margin = s;
114
213
  },
115
- bg: (element, value) => {
214
+ bg: (el, value) => {
116
215
  const [color, shade] = value.split("-");
117
- const colorValue = config.colors[color]?.[shade];
118
- if (colorValue) {
119
- element.style.backgroundColor = colorValue;
120
- }
216
+ const c = config.colors[color]?.[shade];
217
+ if (c) el.style.backgroundColor = c;
121
218
  },
122
- text: (element, value) => {
219
+ text: (el, value) => {
123
220
  const parts = value.split("-");
124
221
  if (parts.length === 1) {
125
222
  const size = config.fontSize[value];
126
- if (size) {
127
- element.style.fontSize = size;
128
- return;
129
- }
223
+ if (size) return el.style.fontSize = size;
130
224
  const color = config.colors[value];
131
- if (color) element.style.color = color;
225
+ if (color) el.style.color = color;
132
226
  } else {
133
227
  const [color, shade] = parts;
134
228
  const c = config.colors[color]?.[shade];
135
- if (c) element.style.color = c;
229
+ if (c) el.style.color = c;
136
230
  }
137
231
  },
138
- rounded: (element, value) => {
139
- if (value === "DEFAULT") return;
140
- const radius = config.borderRadius[value || "DEFAULT"];
141
- if (radius) element.style.borderRadius = radius;
232
+ font: (el, value) => {
233
+ const fw = config.fontWeight[value];
234
+ if (fw) el.style.fontWeight = fw;
235
+ },
236
+ tracking: (el, value) => {
237
+ const ls = config.letterSpacing[value];
238
+ if (ls) el.style.letterSpacing = ls;
239
+ },
240
+ leading: (el, value) => {
241
+ const lh = config.lineHeight[value];
242
+ if (lh) el.style.lineHeight = lh;
142
243
  },
143
- shadow: (element, value) => {
144
- if (value === "DEFAULT") return;
244
+ uppercase: (el) => el.style.textTransform = "uppercase",
245
+ lowercase: (el) => el.style.textTransform = "lowercase",
246
+ capitalize: (el) => el.style.textTransform = "capitalize",
247
+ rounded: (el, value) => {
248
+ const r = config.borderRadius[value || "DEFAULT"];
249
+ if (r) el.style.borderRadius = r;
250
+ },
251
+ shadow: (el, value) => {
145
252
  const s = config.shadows[value || "DEFAULT"];
146
- if (s) element.style.boxShadow = s;
253
+ if (s) el.style.boxShadow = s;
147
254
  },
148
- flex: (element, value) => {
255
+ border: (el, value) => {
149
256
  if (!value) {
150
- element.style.display = "flex";
257
+ el.style.borderWidth = config.borderWidth.DEFAULT;
258
+ el.style.borderStyle = "solid";
151
259
  return;
152
260
  }
153
- if (value === "row") {
154
- element.style.display = "flex";
155
- element.style.flexDirection = "row";
261
+ if (config.borderWidth[value]) {
262
+ el.style.borderWidth = config.borderWidth[value];
263
+ el.style.borderStyle = "solid";
264
+ return;
156
265
  }
157
- if (value === "col") {
158
- element.style.display = "flex";
159
- element.style.flexDirection = "column";
266
+ const [color, shade] = value.split("-");
267
+ const c = config.colors[color]?.[shade] || config.colors[color];
268
+ if (c) {
269
+ el.style.border = `${config.borderWidth.DEFAULT} solid ${c}`;
160
270
  }
161
271
  },
162
- justify: (element, value) => {
272
+ flex: (el, value) => {
273
+ el.style.display = "flex";
274
+ if (value === "col") el.style.flexDirection = "column";
275
+ if (value === "row") el.style.flexDirection = "row";
276
+ },
277
+ justify: (el, value) => {
163
278
  const map = {
164
279
  start: "flex-start",
165
280
  center: "center",
@@ -168,13 +283,12 @@
168
283
  around: "space-around",
169
284
  evenly: "space-evenly"
170
285
  };
171
- const justify = map[value];
172
- if (justify) {
173
- element.style.display = "flex";
174
- element.style.justifyContent = justify;
286
+ if (map[value]) {
287
+ el.style.display = "flex";
288
+ el.style.justifyContent = map[value];
175
289
  }
176
290
  },
177
- items: (element, value) => {
291
+ items: (el, value) => {
178
292
  const map = {
179
293
  start: "flex-start",
180
294
  center: "center",
@@ -182,11 +296,183 @@
182
296
  stretch: "stretch",
183
297
  baseline: "baseline"
184
298
  };
185
- const align = map[value];
186
- if (align) {
187
- element.style.display = "flex";
188
- element.style.alignItems = align;
299
+ if (map[value]) {
300
+ el.style.display = "flex";
301
+ el.style.alignItems = map[value];
302
+ }
303
+ },
304
+ grid: (el, value) => {
305
+ el.style.display = "grid";
306
+ if (value && value.startsWith("cols-")) {
307
+ const n = value.replace("cols-", "");
308
+ el.style.gridTemplateColumns = `repeat(${n}, 1fr)`;
189
309
  }
310
+ },
311
+ gap: (el, value) => {
312
+ const g = config.spacing[value];
313
+ if (g) el.style.gap = g;
314
+ },
315
+ w: (el, value) => {
316
+ const named = config.widths[value];
317
+ if (named) {
318
+ el.style.width = named;
319
+ return;
320
+ }
321
+ const s = config.spacing[value];
322
+ if (s) el.style.width = s;
323
+ },
324
+ h: (el, value) => {
325
+ const named = config.heights[value];
326
+ if (named) {
327
+ el.style.height = named;
328
+ return;
329
+ }
330
+ const s = config.spacing[value];
331
+ if (s) el.style.height = s;
332
+ },
333
+ align: (el, value) => {
334
+ const a = config.textAlign[value];
335
+ if (a) el.style.textAlign = a;
336
+ },
337
+ cursor: (el, value) => {
338
+ const c = config.cursor[value];
339
+ if (c) el.style.cursor = c;
340
+ },
341
+ overflow: (el, value) => {
342
+ const o = config.overflow[value];
343
+ if (o) el.style.overflow = o;
344
+ },
345
+ opacity: (el, value) => {
346
+ el.style.opacity = value / 100;
347
+ },
348
+ relative: (el) => el.style.position = "relative",
349
+ absolute: (el) => el.style.position = "absolute",
350
+ top: (el, value) => {
351
+ const s = config.spacing[value];
352
+ if (s) el.style.top = s;
353
+ },
354
+ left: (el, value) => {
355
+ const s = config.spacing[value];
356
+ if (s) el.style.left = s;
357
+ },
358
+ z: (el, value) => {
359
+ const z = config.zIndex[value];
360
+ if (z !== void 0) el.style.zIndex = z;
361
+ },
362
+ transition: (el) => {
363
+ el.style.transition = "all 0.2s ease";
364
+ },
365
+ duration: (el, value) => {
366
+ el.style.transitionDuration = `${value}ms`;
367
+ },
368
+ ease: (el, value) => {
369
+ const t = config.transitionTiming[value];
370
+ if (t) el.style.transitionTimingFunction = t;
371
+ },
372
+ scale: (el, value) => {
373
+ el.style.transform = `scale(${value / 100})`;
374
+ },
375
+ px: (el, value) => {
376
+ const s = config.spacing[value];
377
+ if (s) {
378
+ el.style.paddingLeft = s;
379
+ el.style.paddingRight = s;
380
+ }
381
+ },
382
+ py: (el, value) => {
383
+ const s = config.spacing[value];
384
+ if (s) {
385
+ el.style.paddingTop = s;
386
+ el.style.paddingBottom = s;
387
+ }
388
+ },
389
+ mx: (el, value) => {
390
+ const s = config.spacing[value];
391
+ if (s) {
392
+ el.style.marginLeft = s;
393
+ el.style.marginRight = s;
394
+ }
395
+ },
396
+ my: (el, value) => {
397
+ const s = config.spacing[value];
398
+ if (s) {
399
+ el.style.marginTop = s;
400
+ el.style.marginBottom = s;
401
+ }
402
+ },
403
+ mt: (el, value) => {
404
+ const s = config.spacing[value];
405
+ if (s) el.style.marginTop = s;
406
+ },
407
+ mb: (el, value) => {
408
+ const s = config.spacing[value];
409
+ if (s) el.style.marginBottom = s;
410
+ },
411
+ ml: (el, value) => {
412
+ const s = config.spacing[value];
413
+ if (s) el.style.marginLeft = s;
414
+ },
415
+ mr: (el, value) => {
416
+ const s = config.spacing[value];
417
+ if (s) el.style.marginRight = s;
418
+ },
419
+ pt: (el, value) => {
420
+ const s = config.spacing[value];
421
+ if (s) el.style.paddingTop = s;
422
+ },
423
+ pb: (el, value) => {
424
+ const s = config.spacing[value];
425
+ if (s) el.style.paddingBottom = s;
426
+ },
427
+ pl: (el, value) => {
428
+ const s = config.spacing[value];
429
+ if (s) el.style.paddingLeft = s;
430
+ },
431
+ pr: (el, value) => {
432
+ const s = config.spacing[value];
433
+ if (s) el.style.paddingRight = s;
434
+ },
435
+ "space-x": (el, value) => {
436
+ const s = config.spacing[value];
437
+ if (s) {
438
+ Array.from(el.children).forEach((child, idx) => {
439
+ if (idx > 0) child.style.marginLeft = s;
440
+ });
441
+ }
442
+ },
443
+ "space-y": (el, value) => {
444
+ const s = config.spacing[value];
445
+ if (s) {
446
+ Array.from(el.children).forEach((child, idx) => {
447
+ if (idx > 0) child.style.marginTop = s;
448
+ });
449
+ }
450
+ },
451
+ "backdrop-blur": (el, value) => {
452
+ const b = config.blur[value || "DEFAULT"];
453
+ if (b) el.style.backdropFilter = `blur(${b})`;
454
+ },
455
+ "bg-opacity": (el, value) => {
456
+ const opacity = config.opacity[value];
457
+ if (opacity !== void 0) {
458
+ const bgColor = window.getComputedStyle(el).backgroundColor;
459
+ const rgbaColor = bgColor.replace(/rgba?\(/, "rgba(").replace(/\)/, `)`);
460
+ const match = rgbaColor.match(/(rgba?\([^,]+,[^,]+,[^,]+),/);
461
+ if (match) {
462
+ el.style.backgroundColor = `${match[1]}, ${opacity})`;
463
+ }
464
+ }
465
+ },
466
+ hidden: (el) => el.style.display = "none",
467
+ block: (el) => el.style.display = "block",
468
+ inline: (el) => el.style.display = "inline",
469
+ right: (el, value) => {
470
+ const s = config.spacing[value];
471
+ if (s) el.style.right = s;
472
+ },
473
+ bottom: (el, value) => {
474
+ const s = config.spacing[value];
475
+ if (s) el.style.bottom = s;
190
476
  }
191
477
  };
192
478
  function interpretClass(element, cls) {
@@ -199,13 +485,12 @@
199
485
  handler(element, value);
200
486
  }
201
487
  if (hover === "hover") {
202
- let original = "";
488
+ const original = element.style.cssText;
203
489
  element.addEventListener("mouseenter", () => {
204
- original = element.style.backgroundColor;
205
490
  handler(element, value);
206
491
  });
207
492
  element.addEventListener("mouseleave", () => {
208
- element.style.backgroundColor = original;
493
+ element.style.cssText = original;
209
494
  });
210
495
  }
211
496
  }
@@ -62,6 +62,24 @@ var config = {
62
62
  "4xl": "32px",
63
63
  "5xl": "40px"
64
64
  },
65
+ fontWeight: {
66
+ thin: 100,
67
+ light: 300,
68
+ normal: 400,
69
+ medium: 500,
70
+ bold: 700
71
+ },
72
+ letterSpacing: {
73
+ tight: "-0.05em",
74
+ normal: "0",
75
+ wide: "0.05em"
76
+ },
77
+ lineHeight: {
78
+ none: "1",
79
+ tight: "1.25",
80
+ normal: "1.5",
81
+ loose: "2"
82
+ },
65
83
  borderRadius: {
66
84
  none: "0px",
67
85
  sm: "4px",
@@ -71,11 +89,92 @@ var config = {
71
89
  xl: "16px",
72
90
  full: "9999px"
73
91
  },
92
+ borderWidth: {
93
+ DEFAULT: "1px",
94
+ 2: "2px",
95
+ 4: "4px"
96
+ },
74
97
  shadows: {
75
98
  sm: "0 1px 3px rgba(0,0,0,0.1)",
76
99
  DEFAULT: "0 4px 10px rgba(0,0,0,0.1)",
77
100
  md: "0 6px 20px rgba(0,0,0,0.15)",
78
101
  lg: "0 10px 30px rgba(0,0,0,0.2)"
102
+ },
103
+ zIndex: {
104
+ 0: 0,
105
+ 10: 10,
106
+ 20: 20,
107
+ 50: 50,
108
+ 100: 100
109
+ },
110
+ transitionTiming: {
111
+ linear: "linear",
112
+ in: "ease-in",
113
+ out: "ease-out",
114
+ "in-out": "ease-in-out"
115
+ },
116
+ blur: {
117
+ none: "0px",
118
+ sm: "4px",
119
+ DEFAULT: "8px",
120
+ md: "12px",
121
+ lg: "16px",
122
+ xl: "24px"
123
+ },
124
+ opacity: {
125
+ 0: "0",
126
+ 5: "0.05",
127
+ 10: "0.1",
128
+ 20: "0.2",
129
+ 25: "0.25",
130
+ 30: "0.3",
131
+ 40: "0.4",
132
+ 50: "0.5",
133
+ 60: "0.6",
134
+ 70: "0.7",
135
+ 75: "0.75",
136
+ 80: "0.8",
137
+ 90: "0.9",
138
+ 95: "0.95",
139
+ 100: "1"
140
+ },
141
+ display: {
142
+ block: "block",
143
+ inline: "inline",
144
+ "inline-block": "inline-block",
145
+ flex: "flex",
146
+ grid: "grid",
147
+ hidden: "none"
148
+ },
149
+ textAlign: {
150
+ left: "left",
151
+ center: "center",
152
+ right: "right",
153
+ justify: "justify"
154
+ },
155
+ widths: {
156
+ full: "100%",
157
+ half: "50%",
158
+ third: "33.333%",
159
+ quarter: "25%",
160
+ screen: "100vw",
161
+ auto: "auto"
162
+ },
163
+ heights: {
164
+ full: "100%",
165
+ screen: "100vh",
166
+ auto: "auto"
167
+ },
168
+ cursor: {
169
+ pointer: "pointer",
170
+ default: "default",
171
+ "not-allowed": "not-allowed"
172
+ },
173
+ overflow: {
174
+ hidden: "hidden",
175
+ auto: "auto",
176
+ scroll: "scroll",
177
+ visible: "visible"
79
178
  }
80
179
  };
81
180
 
@@ -103,62 +202,78 @@ function parseClass(cls) {
103
202
 
104
203
  // src/runtime/interpreter.js
105
204
  var handlers = {
106
- p: (element, value) => {
107
- const spacing2 = config.spacing[value];
108
- if (spacing2) element.style.padding = spacing2;
205
+ p: (el, value) => {
206
+ const s = config.spacing[value];
207
+ if (s) el.style.padding = s;
109
208
  },
110
- m: (element, value) => {
111
- const spacing2 = config.spacing[value];
112
- if (spacing2) element.style.margin = spacing2;
209
+ m: (el, value) => {
210
+ const s = config.spacing[value];
211
+ if (s) el.style.margin = s;
113
212
  },
114
- bg: (element, value) => {
213
+ bg: (el, value) => {
115
214
  const [color, shade] = value.split("-");
116
- const colorValue = config.colors[color]?.[shade];
117
- if (colorValue) {
118
- element.style.backgroundColor = colorValue;
119
- }
215
+ const c = config.colors[color]?.[shade];
216
+ if (c) el.style.backgroundColor = c;
120
217
  },
121
- text: (element, value) => {
218
+ text: (el, value) => {
122
219
  const parts = value.split("-");
123
220
  if (parts.length === 1) {
124
221
  const size = config.fontSize[value];
125
- if (size) {
126
- element.style.fontSize = size;
127
- return;
128
- }
222
+ if (size) return el.style.fontSize = size;
129
223
  const color = config.colors[value];
130
- if (color) element.style.color = color;
224
+ if (color) el.style.color = color;
131
225
  } else {
132
226
  const [color, shade] = parts;
133
227
  const c = config.colors[color]?.[shade];
134
- if (c) element.style.color = c;
228
+ if (c) el.style.color = c;
135
229
  }
136
230
  },
137
- rounded: (element, value) => {
138
- if (value === "DEFAULT") return;
139
- const radius = config.borderRadius[value || "DEFAULT"];
140
- if (radius) element.style.borderRadius = radius;
231
+ font: (el, value) => {
232
+ const fw = config.fontWeight[value];
233
+ if (fw) el.style.fontWeight = fw;
234
+ },
235
+ tracking: (el, value) => {
236
+ const ls = config.letterSpacing[value];
237
+ if (ls) el.style.letterSpacing = ls;
238
+ },
239
+ leading: (el, value) => {
240
+ const lh = config.lineHeight[value];
241
+ if (lh) el.style.lineHeight = lh;
141
242
  },
142
- shadow: (element, value) => {
143
- if (value === "DEFAULT") return;
243
+ uppercase: (el) => el.style.textTransform = "uppercase",
244
+ lowercase: (el) => el.style.textTransform = "lowercase",
245
+ capitalize: (el) => el.style.textTransform = "capitalize",
246
+ rounded: (el, value) => {
247
+ const r = config.borderRadius[value || "DEFAULT"];
248
+ if (r) el.style.borderRadius = r;
249
+ },
250
+ shadow: (el, value) => {
144
251
  const s = config.shadows[value || "DEFAULT"];
145
- if (s) element.style.boxShadow = s;
252
+ if (s) el.style.boxShadow = s;
146
253
  },
147
- flex: (element, value) => {
254
+ border: (el, value) => {
148
255
  if (!value) {
149
- element.style.display = "flex";
256
+ el.style.borderWidth = config.borderWidth.DEFAULT;
257
+ el.style.borderStyle = "solid";
150
258
  return;
151
259
  }
152
- if (value === "row") {
153
- element.style.display = "flex";
154
- element.style.flexDirection = "row";
260
+ if (config.borderWidth[value]) {
261
+ el.style.borderWidth = config.borderWidth[value];
262
+ el.style.borderStyle = "solid";
263
+ return;
155
264
  }
156
- if (value === "col") {
157
- element.style.display = "flex";
158
- element.style.flexDirection = "column";
265
+ const [color, shade] = value.split("-");
266
+ const c = config.colors[color]?.[shade] || config.colors[color];
267
+ if (c) {
268
+ el.style.border = `${config.borderWidth.DEFAULT} solid ${c}`;
159
269
  }
160
270
  },
161
- justify: (element, value) => {
271
+ flex: (el, value) => {
272
+ el.style.display = "flex";
273
+ if (value === "col") el.style.flexDirection = "column";
274
+ if (value === "row") el.style.flexDirection = "row";
275
+ },
276
+ justify: (el, value) => {
162
277
  const map = {
163
278
  start: "flex-start",
164
279
  center: "center",
@@ -167,13 +282,12 @@ var handlers = {
167
282
  around: "space-around",
168
283
  evenly: "space-evenly"
169
284
  };
170
- const justify = map[value];
171
- if (justify) {
172
- element.style.display = "flex";
173
- element.style.justifyContent = justify;
285
+ if (map[value]) {
286
+ el.style.display = "flex";
287
+ el.style.justifyContent = map[value];
174
288
  }
175
289
  },
176
- items: (element, value) => {
290
+ items: (el, value) => {
177
291
  const map = {
178
292
  start: "flex-start",
179
293
  center: "center",
@@ -181,11 +295,183 @@ var handlers = {
181
295
  stretch: "stretch",
182
296
  baseline: "baseline"
183
297
  };
184
- const align = map[value];
185
- if (align) {
186
- element.style.display = "flex";
187
- element.style.alignItems = align;
298
+ if (map[value]) {
299
+ el.style.display = "flex";
300
+ el.style.alignItems = map[value];
301
+ }
302
+ },
303
+ grid: (el, value) => {
304
+ el.style.display = "grid";
305
+ if (value && value.startsWith("cols-")) {
306
+ const n = value.replace("cols-", "");
307
+ el.style.gridTemplateColumns = `repeat(${n}, 1fr)`;
188
308
  }
309
+ },
310
+ gap: (el, value) => {
311
+ const g = config.spacing[value];
312
+ if (g) el.style.gap = g;
313
+ },
314
+ w: (el, value) => {
315
+ const named = config.widths[value];
316
+ if (named) {
317
+ el.style.width = named;
318
+ return;
319
+ }
320
+ const s = config.spacing[value];
321
+ if (s) el.style.width = s;
322
+ },
323
+ h: (el, value) => {
324
+ const named = config.heights[value];
325
+ if (named) {
326
+ el.style.height = named;
327
+ return;
328
+ }
329
+ const s = config.spacing[value];
330
+ if (s) el.style.height = s;
331
+ },
332
+ align: (el, value) => {
333
+ const a = config.textAlign[value];
334
+ if (a) el.style.textAlign = a;
335
+ },
336
+ cursor: (el, value) => {
337
+ const c = config.cursor[value];
338
+ if (c) el.style.cursor = c;
339
+ },
340
+ overflow: (el, value) => {
341
+ const o = config.overflow[value];
342
+ if (o) el.style.overflow = o;
343
+ },
344
+ opacity: (el, value) => {
345
+ el.style.opacity = value / 100;
346
+ },
347
+ relative: (el) => el.style.position = "relative",
348
+ absolute: (el) => el.style.position = "absolute",
349
+ top: (el, value) => {
350
+ const s = config.spacing[value];
351
+ if (s) el.style.top = s;
352
+ },
353
+ left: (el, value) => {
354
+ const s = config.spacing[value];
355
+ if (s) el.style.left = s;
356
+ },
357
+ z: (el, value) => {
358
+ const z = config.zIndex[value];
359
+ if (z !== void 0) el.style.zIndex = z;
360
+ },
361
+ transition: (el) => {
362
+ el.style.transition = "all 0.2s ease";
363
+ },
364
+ duration: (el, value) => {
365
+ el.style.transitionDuration = `${value}ms`;
366
+ },
367
+ ease: (el, value) => {
368
+ const t = config.transitionTiming[value];
369
+ if (t) el.style.transitionTimingFunction = t;
370
+ },
371
+ scale: (el, value) => {
372
+ el.style.transform = `scale(${value / 100})`;
373
+ },
374
+ px: (el, value) => {
375
+ const s = config.spacing[value];
376
+ if (s) {
377
+ el.style.paddingLeft = s;
378
+ el.style.paddingRight = s;
379
+ }
380
+ },
381
+ py: (el, value) => {
382
+ const s = config.spacing[value];
383
+ if (s) {
384
+ el.style.paddingTop = s;
385
+ el.style.paddingBottom = s;
386
+ }
387
+ },
388
+ mx: (el, value) => {
389
+ const s = config.spacing[value];
390
+ if (s) {
391
+ el.style.marginLeft = s;
392
+ el.style.marginRight = s;
393
+ }
394
+ },
395
+ my: (el, value) => {
396
+ const s = config.spacing[value];
397
+ if (s) {
398
+ el.style.marginTop = s;
399
+ el.style.marginBottom = s;
400
+ }
401
+ },
402
+ mt: (el, value) => {
403
+ const s = config.spacing[value];
404
+ if (s) el.style.marginTop = s;
405
+ },
406
+ mb: (el, value) => {
407
+ const s = config.spacing[value];
408
+ if (s) el.style.marginBottom = s;
409
+ },
410
+ ml: (el, value) => {
411
+ const s = config.spacing[value];
412
+ if (s) el.style.marginLeft = s;
413
+ },
414
+ mr: (el, value) => {
415
+ const s = config.spacing[value];
416
+ if (s) el.style.marginRight = s;
417
+ },
418
+ pt: (el, value) => {
419
+ const s = config.spacing[value];
420
+ if (s) el.style.paddingTop = s;
421
+ },
422
+ pb: (el, value) => {
423
+ const s = config.spacing[value];
424
+ if (s) el.style.paddingBottom = s;
425
+ },
426
+ pl: (el, value) => {
427
+ const s = config.spacing[value];
428
+ if (s) el.style.paddingLeft = s;
429
+ },
430
+ pr: (el, value) => {
431
+ const s = config.spacing[value];
432
+ if (s) el.style.paddingRight = s;
433
+ },
434
+ "space-x": (el, value) => {
435
+ const s = config.spacing[value];
436
+ if (s) {
437
+ Array.from(el.children).forEach((child, idx) => {
438
+ if (idx > 0) child.style.marginLeft = s;
439
+ });
440
+ }
441
+ },
442
+ "space-y": (el, value) => {
443
+ const s = config.spacing[value];
444
+ if (s) {
445
+ Array.from(el.children).forEach((child, idx) => {
446
+ if (idx > 0) child.style.marginTop = s;
447
+ });
448
+ }
449
+ },
450
+ "backdrop-blur": (el, value) => {
451
+ const b = config.blur[value || "DEFAULT"];
452
+ if (b) el.style.backdropFilter = `blur(${b})`;
453
+ },
454
+ "bg-opacity": (el, value) => {
455
+ const opacity = config.opacity[value];
456
+ if (opacity !== void 0) {
457
+ const bgColor = window.getComputedStyle(el).backgroundColor;
458
+ const rgbaColor = bgColor.replace(/rgba?\(/, "rgba(").replace(/\)/, `)`);
459
+ const match = rgbaColor.match(/(rgba?\([^,]+,[^,]+,[^,]+),/);
460
+ if (match) {
461
+ el.style.backgroundColor = `${match[1]}, ${opacity})`;
462
+ }
463
+ }
464
+ },
465
+ hidden: (el) => el.style.display = "none",
466
+ block: (el) => el.style.display = "block",
467
+ inline: (el) => el.style.display = "inline",
468
+ right: (el, value) => {
469
+ const s = config.spacing[value];
470
+ if (s) el.style.right = s;
471
+ },
472
+ bottom: (el, value) => {
473
+ const s = config.spacing[value];
474
+ if (s) el.style.bottom = s;
189
475
  }
190
476
  };
191
477
  function interpretClass(element, cls) {
@@ -198,13 +484,12 @@ function interpretClass(element, cls) {
198
484
  handler(element, value);
199
485
  }
200
486
  if (hover === "hover") {
201
- let original = "";
487
+ const original = element.style.cssText;
202
488
  element.addEventListener("mouseenter", () => {
203
- original = element.style.backgroundColor;
204
489
  handler(element, value);
205
490
  });
206
491
  element.addEventListener("mouseleave", () => {
207
- element.style.backgroundColor = original;
492
+ element.style.cssText = original;
208
493
  });
209
494
  }
210
495
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chai-tailwind-js",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "main": "dist/chai-tailwind.js",
5
5
  "type": "module",
6
6
  "scripts": {