@itamarshdev/reactwind 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/chunk-KAWYX6WW.js +341 -0
- package/dist/index.cjs +100 -4
- package/dist/index.js +1 -1
- package/dist/jsx-dev-runtime.cjs +100 -4
- package/dist/jsx-dev-runtime.d.cts +1 -1
- package/dist/jsx-dev-runtime.d.ts +1 -1
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.cjs +100 -4
- package/dist/jsx-runtime.d.cts +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/types-Bb5v_nmy.d.cts +245 -0
- package/dist/types-CBbQP9uE.d.ts +245 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -86,6 +86,50 @@ export default defineConfig({
|
|
|
86
86
|
</div>
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
+
### 3. Modifier Props (Hover, Focus, Responsive, etc.)
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
// Hyphenated syntax
|
|
93
|
+
<button hover-bg="blue-700" hover-scale="105" focus-ring="2">
|
|
94
|
+
Hover Me
|
|
95
|
+
</button>
|
|
96
|
+
|
|
97
|
+
// Object syntax for multiple props per modifier
|
|
98
|
+
<button hover={{ bg: "blue-700", scale: "105", shadow: "lg" }}>
|
|
99
|
+
Hover Me
|
|
100
|
+
</button>
|
|
101
|
+
|
|
102
|
+
// Stacked modifiers via nesting
|
|
103
|
+
<div dark={{ hover: { bg: "slate-800", text: "white" } }}>
|
|
104
|
+
Dark mode hover styles
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
// Responsive breakpoints
|
|
108
|
+
<div md={{ flex: true, gap: "4" }} lg={{ gap: "8" }}>
|
|
109
|
+
Responsive layout
|
|
110
|
+
</div>
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### 4. Position & Layout Props
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
<div absolute top="0" right="0" inset-x="4">
|
|
117
|
+
Positioned element
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<div grid grid-cols="3" gap-x="4" gap-y="2">
|
|
121
|
+
Grid with different gaps
|
|
122
|
+
</div>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### 5. Gradient & Background Props
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<div bg-gradient="to-r" from="blue-500" via="purple-500" to="pink-500">
|
|
129
|
+
Gradient background
|
|
130
|
+
</div>
|
|
131
|
+
```
|
|
132
|
+
|
|
89
133
|
---
|
|
90
134
|
|
|
91
135
|
## 🎯 Goals
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
// src/runtime.ts
|
|
2
|
+
var LAYOUT_PROPS = [
|
|
3
|
+
"flex",
|
|
4
|
+
"grid",
|
|
5
|
+
"hidden",
|
|
6
|
+
"block",
|
|
7
|
+
"inline",
|
|
8
|
+
"inline-block",
|
|
9
|
+
"inline-flex",
|
|
10
|
+
"inline-grid",
|
|
11
|
+
"relative",
|
|
12
|
+
"absolute",
|
|
13
|
+
"fixed",
|
|
14
|
+
"sticky",
|
|
15
|
+
"static",
|
|
16
|
+
"flex-row",
|
|
17
|
+
"flex-col",
|
|
18
|
+
"flex-wrap",
|
|
19
|
+
"flex-nowrap",
|
|
20
|
+
"items-center",
|
|
21
|
+
"items-start",
|
|
22
|
+
"items-end",
|
|
23
|
+
"justify-center",
|
|
24
|
+
"justify-between",
|
|
25
|
+
"justify-start",
|
|
26
|
+
"justify-end",
|
|
27
|
+
"grow",
|
|
28
|
+
"shrink",
|
|
29
|
+
"italic",
|
|
30
|
+
"not-italic",
|
|
31
|
+
"underline",
|
|
32
|
+
"uppercase",
|
|
33
|
+
"lowercase",
|
|
34
|
+
"capitalize",
|
|
35
|
+
"truncate",
|
|
36
|
+
"visible",
|
|
37
|
+
"invisible",
|
|
38
|
+
"collapse",
|
|
39
|
+
"pointer-events-none",
|
|
40
|
+
"pointer-events-auto",
|
|
41
|
+
"sr-only",
|
|
42
|
+
"not-sr-only"
|
|
43
|
+
];
|
|
44
|
+
var VALUE_PROPS_MAP = {
|
|
45
|
+
bg: "bg",
|
|
46
|
+
text: "text",
|
|
47
|
+
border: "border",
|
|
48
|
+
fill: "fill",
|
|
49
|
+
stroke: "stroke",
|
|
50
|
+
p: "p",
|
|
51
|
+
m: "m",
|
|
52
|
+
px: "px",
|
|
53
|
+
py: "py",
|
|
54
|
+
mx: "mx",
|
|
55
|
+
my: "my",
|
|
56
|
+
gap: "gap",
|
|
57
|
+
w: "w",
|
|
58
|
+
h: "h",
|
|
59
|
+
rounded: "rounded",
|
|
60
|
+
shadow: "shadow",
|
|
61
|
+
font: "font",
|
|
62
|
+
z: "z",
|
|
63
|
+
mb: "mb",
|
|
64
|
+
mt: "mt",
|
|
65
|
+
ml: "ml",
|
|
66
|
+
mr: "mr",
|
|
67
|
+
pb: "pb",
|
|
68
|
+
pt: "pt",
|
|
69
|
+
pl: "pl",
|
|
70
|
+
pr: "pr",
|
|
71
|
+
tracking: "tracking",
|
|
72
|
+
leading: "leading",
|
|
73
|
+
"max-w": "max-w",
|
|
74
|
+
"min-w": "min-w",
|
|
75
|
+
"min-h": "min-h",
|
|
76
|
+
"max-h": "max-h",
|
|
77
|
+
"grid-cols": "grid-cols",
|
|
78
|
+
"col-span": "col-span",
|
|
79
|
+
"row-span": "row-span",
|
|
80
|
+
"grid-rows": "grid-rows",
|
|
81
|
+
"items": "items",
|
|
82
|
+
"justify": "justify",
|
|
83
|
+
"self": "self",
|
|
84
|
+
"place-content": "place-content",
|
|
85
|
+
"place-items": "place-items",
|
|
86
|
+
"place-self": "place-self",
|
|
87
|
+
"order": "order",
|
|
88
|
+
overflow: "overflow",
|
|
89
|
+
decoration: "decoration",
|
|
90
|
+
whitespace: "whitespace",
|
|
91
|
+
break: "break",
|
|
92
|
+
content: "content",
|
|
93
|
+
opacity: "opacity",
|
|
94
|
+
"bg-opacity": "bg-opacity",
|
|
95
|
+
"text-opacity": "text-opacity",
|
|
96
|
+
"border-opacity": "border-opacity",
|
|
97
|
+
ring: "ring",
|
|
98
|
+
"ring-offset": "ring-offset",
|
|
99
|
+
outline: "outline",
|
|
100
|
+
divide: "divide",
|
|
101
|
+
"mix-blend": "mix-blend",
|
|
102
|
+
"backdrop-blur": "backdrop-blur",
|
|
103
|
+
blur: "blur",
|
|
104
|
+
brightness: "brightness",
|
|
105
|
+
contrast: "contrast",
|
|
106
|
+
grayscale: "grayscale",
|
|
107
|
+
"hue-rotate": "hue-rotate",
|
|
108
|
+
invert: "invert",
|
|
109
|
+
saturate: "saturate",
|
|
110
|
+
sepia: "sepia",
|
|
111
|
+
"drop-shadow": "drop-shadow",
|
|
112
|
+
transition: "transition",
|
|
113
|
+
duration: "duration",
|
|
114
|
+
ease: "ease",
|
|
115
|
+
delay: "delay",
|
|
116
|
+
animate: "animate",
|
|
117
|
+
cursor: "cursor",
|
|
118
|
+
"pointer-events": "pointer-events",
|
|
119
|
+
resize: "resize",
|
|
120
|
+
select: "select",
|
|
121
|
+
scale: "scale",
|
|
122
|
+
rotate: "rotate",
|
|
123
|
+
translate: "translate",
|
|
124
|
+
skew: "skew",
|
|
125
|
+
origin: "origin",
|
|
126
|
+
// Layout & Position
|
|
127
|
+
top: "top",
|
|
128
|
+
right: "right",
|
|
129
|
+
bottom: "bottom",
|
|
130
|
+
left: "left",
|
|
131
|
+
inset: "inset",
|
|
132
|
+
"inset-x": "inset-x",
|
|
133
|
+
"inset-y": "inset-y",
|
|
134
|
+
aspect: "aspect",
|
|
135
|
+
columns: "columns",
|
|
136
|
+
float: "float",
|
|
137
|
+
clear: "clear",
|
|
138
|
+
// Flexbox & Grid
|
|
139
|
+
basis: "basis",
|
|
140
|
+
"gap-x": "gap-x",
|
|
141
|
+
"gap-y": "gap-y",
|
|
142
|
+
"auto-cols": "auto-cols",
|
|
143
|
+
"auto-rows": "auto-rows",
|
|
144
|
+
"grid-flow": "grid-flow",
|
|
145
|
+
"space-x": "space-x",
|
|
146
|
+
"space-y": "space-y",
|
|
147
|
+
"justify-items": "justify-items",
|
|
148
|
+
"justify-self": "justify-self",
|
|
149
|
+
// Sizing
|
|
150
|
+
size: "size",
|
|
151
|
+
// Borders
|
|
152
|
+
"border-t": "border-t",
|
|
153
|
+
"border-r": "border-r",
|
|
154
|
+
"border-b": "border-b",
|
|
155
|
+
"border-l": "border-l",
|
|
156
|
+
"border-x": "border-x",
|
|
157
|
+
"border-y": "border-y",
|
|
158
|
+
"rounded-t": "rounded-t",
|
|
159
|
+
"rounded-r": "rounded-r",
|
|
160
|
+
"rounded-b": "rounded-b",
|
|
161
|
+
"rounded-l": "rounded-l",
|
|
162
|
+
"rounded-tl": "rounded-tl",
|
|
163
|
+
"rounded-tr": "rounded-tr",
|
|
164
|
+
"rounded-bl": "rounded-bl",
|
|
165
|
+
"rounded-br": "rounded-br",
|
|
166
|
+
"border-style": "border",
|
|
167
|
+
// Typography
|
|
168
|
+
"text-align": "text",
|
|
169
|
+
align: "align",
|
|
170
|
+
"line-clamp": "line-clamp",
|
|
171
|
+
list: "list",
|
|
172
|
+
indent: "indent",
|
|
173
|
+
// Backgrounds & Gradients
|
|
174
|
+
"bg-gradient": "bg-gradient",
|
|
175
|
+
from: "from",
|
|
176
|
+
via: "via",
|
|
177
|
+
to: "to",
|
|
178
|
+
"bg-size": "bg",
|
|
179
|
+
"bg-position": "bg",
|
|
180
|
+
"bg-repeat": "bg",
|
|
181
|
+
// Interactivity
|
|
182
|
+
scroll: "scroll",
|
|
183
|
+
snap: "snap",
|
|
184
|
+
touch: "touch",
|
|
185
|
+
"will-change": "will-change",
|
|
186
|
+
caret: "caret",
|
|
187
|
+
accent: "accent",
|
|
188
|
+
// SVG
|
|
189
|
+
"stroke-width": "stroke"
|
|
190
|
+
};
|
|
191
|
+
var MODIFIERS = [
|
|
192
|
+
"hover",
|
|
193
|
+
"focus",
|
|
194
|
+
"active",
|
|
195
|
+
"visited",
|
|
196
|
+
"disabled",
|
|
197
|
+
"group-hover",
|
|
198
|
+
"group-focus",
|
|
199
|
+
"focus-within",
|
|
200
|
+
"focus-visible",
|
|
201
|
+
"target",
|
|
202
|
+
"first",
|
|
203
|
+
"last",
|
|
204
|
+
"only",
|
|
205
|
+
"odd",
|
|
206
|
+
"even",
|
|
207
|
+
"first-of-type",
|
|
208
|
+
"last-of-type",
|
|
209
|
+
"only-of-type",
|
|
210
|
+
"empty",
|
|
211
|
+
"checked",
|
|
212
|
+
"indeterminate",
|
|
213
|
+
"default",
|
|
214
|
+
"required",
|
|
215
|
+
"valid",
|
|
216
|
+
"invalid",
|
|
217
|
+
"in-range",
|
|
218
|
+
"out-of-range",
|
|
219
|
+
"placeholder-shown",
|
|
220
|
+
"autofill",
|
|
221
|
+
"read-only",
|
|
222
|
+
"open",
|
|
223
|
+
// Responsive breakpoints
|
|
224
|
+
"sm",
|
|
225
|
+
"md",
|
|
226
|
+
"lg",
|
|
227
|
+
"xl",
|
|
228
|
+
"2xl",
|
|
229
|
+
// Dark mode
|
|
230
|
+
"dark",
|
|
231
|
+
// Print
|
|
232
|
+
"print"
|
|
233
|
+
];
|
|
234
|
+
var BOOLEAN_VALUE_PROPS = ["shadow", "rounded", "border", "transition", "ring", "outline"];
|
|
235
|
+
var joinClassNames = (classNames) => {
|
|
236
|
+
if (!classNames || classNames.length === 0) {
|
|
237
|
+
return "";
|
|
238
|
+
}
|
|
239
|
+
return classNames.filter(Boolean).join(" ");
|
|
240
|
+
};
|
|
241
|
+
var processModifierObject = (modifier, obj, classes) => {
|
|
242
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
243
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
244
|
+
if (MODIFIERS.includes(key)) {
|
|
245
|
+
processModifierObject(`${modifier}:${key}`, value, classes);
|
|
246
|
+
}
|
|
247
|
+
} else if (key in VALUE_PROPS_MAP) {
|
|
248
|
+
const prefix = VALUE_PROPS_MAP[key];
|
|
249
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
250
|
+
classes.push(`${modifier}:${prefix}-${value}`);
|
|
251
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(key)) {
|
|
252
|
+
classes.push(`${modifier}:${key}`);
|
|
253
|
+
}
|
|
254
|
+
} else if (LAYOUT_PROPS.includes(key) && value === true) {
|
|
255
|
+
classes.push(`${modifier}:${key}`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
var withClassNames = (props) => {
|
|
260
|
+
if (!props) {
|
|
261
|
+
return props;
|
|
262
|
+
}
|
|
263
|
+
const hasClassNames = "classNames" in props;
|
|
264
|
+
const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
|
|
265
|
+
const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
|
|
266
|
+
const propsKeys = Object.keys(props);
|
|
267
|
+
const hasHyphenatedModifiers = propsKeys.some((key) => {
|
|
268
|
+
return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
|
|
269
|
+
});
|
|
270
|
+
const hasObjectModifiers = propsKeys.some((key) => {
|
|
271
|
+
return MODIFIERS.includes(key) && typeof props[key] === "object" && props[key] !== null;
|
|
272
|
+
});
|
|
273
|
+
const hasModifiers = hasHyphenatedModifiers || hasObjectModifiers;
|
|
274
|
+
if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
|
|
275
|
+
return props;
|
|
276
|
+
}
|
|
277
|
+
const { classNames, className, ...rest } = props;
|
|
278
|
+
const generatedClasses = [];
|
|
279
|
+
const cleanRest = { ...rest };
|
|
280
|
+
for (const prop of LAYOUT_PROPS) {
|
|
281
|
+
if (prop in cleanRest && cleanRest[prop] === true) {
|
|
282
|
+
generatedClasses.push(prop);
|
|
283
|
+
delete cleanRest[prop];
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
for (const [prop, prefix] of Object.entries(VALUE_PROPS_MAP)) {
|
|
287
|
+
if (prop in cleanRest) {
|
|
288
|
+
const value = cleanRest[prop];
|
|
289
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
290
|
+
generatedClasses.push(`${prefix}-${value}`);
|
|
291
|
+
delete cleanRest[prop];
|
|
292
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(prop)) {
|
|
293
|
+
generatedClasses.push(prop);
|
|
294
|
+
delete cleanRest[prop];
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
for (const modifier of MODIFIERS) {
|
|
299
|
+
if (modifier in cleanRest) {
|
|
300
|
+
const value = cleanRest[modifier];
|
|
301
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
302
|
+
processModifierObject(modifier, value, generatedClasses);
|
|
303
|
+
delete cleanRest[modifier];
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
Object.keys(cleanRest).forEach((key) => {
|
|
308
|
+
const firstHyphenIndex = key.indexOf("-");
|
|
309
|
+
if (firstHyphenIndex === -1) return;
|
|
310
|
+
const modifier = key.substring(0, firstHyphenIndex);
|
|
311
|
+
if (MODIFIERS.includes(modifier)) {
|
|
312
|
+
const restKey = key.substring(firstHyphenIndex + 1);
|
|
313
|
+
const value = cleanRest[key];
|
|
314
|
+
if (restKey in VALUE_PROPS_MAP) {
|
|
315
|
+
const prefix = VALUE_PROPS_MAP[restKey];
|
|
316
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
317
|
+
generatedClasses.push(`${modifier}:${prefix}-${value}`);
|
|
318
|
+
delete cleanRest[key];
|
|
319
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(restKey)) {
|
|
320
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
321
|
+
delete cleanRest[key];
|
|
322
|
+
}
|
|
323
|
+
} else if (LAYOUT_PROPS.includes(restKey)) {
|
|
324
|
+
if (value === true) {
|
|
325
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
326
|
+
delete cleanRest[key];
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
const joined = joinClassNames(classNames || []);
|
|
332
|
+
const merged = [className, ...generatedClasses, joined].filter(Boolean).join(" ");
|
|
333
|
+
return {
|
|
334
|
+
...cleanRest,
|
|
335
|
+
...merged ? { className: merged } : {}
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
export {
|
|
340
|
+
withClassNames
|
|
341
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -148,7 +148,71 @@ var VALUE_PROPS_MAP = {
|
|
|
148
148
|
rotate: "rotate",
|
|
149
149
|
translate: "translate",
|
|
150
150
|
skew: "skew",
|
|
151
|
-
origin: "origin"
|
|
151
|
+
origin: "origin",
|
|
152
|
+
// Layout & Position
|
|
153
|
+
top: "top",
|
|
154
|
+
right: "right",
|
|
155
|
+
bottom: "bottom",
|
|
156
|
+
left: "left",
|
|
157
|
+
inset: "inset",
|
|
158
|
+
"inset-x": "inset-x",
|
|
159
|
+
"inset-y": "inset-y",
|
|
160
|
+
aspect: "aspect",
|
|
161
|
+
columns: "columns",
|
|
162
|
+
float: "float",
|
|
163
|
+
clear: "clear",
|
|
164
|
+
// Flexbox & Grid
|
|
165
|
+
basis: "basis",
|
|
166
|
+
"gap-x": "gap-x",
|
|
167
|
+
"gap-y": "gap-y",
|
|
168
|
+
"auto-cols": "auto-cols",
|
|
169
|
+
"auto-rows": "auto-rows",
|
|
170
|
+
"grid-flow": "grid-flow",
|
|
171
|
+
"space-x": "space-x",
|
|
172
|
+
"space-y": "space-y",
|
|
173
|
+
"justify-items": "justify-items",
|
|
174
|
+
"justify-self": "justify-self",
|
|
175
|
+
// Sizing
|
|
176
|
+
size: "size",
|
|
177
|
+
// Borders
|
|
178
|
+
"border-t": "border-t",
|
|
179
|
+
"border-r": "border-r",
|
|
180
|
+
"border-b": "border-b",
|
|
181
|
+
"border-l": "border-l",
|
|
182
|
+
"border-x": "border-x",
|
|
183
|
+
"border-y": "border-y",
|
|
184
|
+
"rounded-t": "rounded-t",
|
|
185
|
+
"rounded-r": "rounded-r",
|
|
186
|
+
"rounded-b": "rounded-b",
|
|
187
|
+
"rounded-l": "rounded-l",
|
|
188
|
+
"rounded-tl": "rounded-tl",
|
|
189
|
+
"rounded-tr": "rounded-tr",
|
|
190
|
+
"rounded-bl": "rounded-bl",
|
|
191
|
+
"rounded-br": "rounded-br",
|
|
192
|
+
"border-style": "border",
|
|
193
|
+
// Typography
|
|
194
|
+
"text-align": "text",
|
|
195
|
+
align: "align",
|
|
196
|
+
"line-clamp": "line-clamp",
|
|
197
|
+
list: "list",
|
|
198
|
+
indent: "indent",
|
|
199
|
+
// Backgrounds & Gradients
|
|
200
|
+
"bg-gradient": "bg-gradient",
|
|
201
|
+
from: "from",
|
|
202
|
+
via: "via",
|
|
203
|
+
to: "to",
|
|
204
|
+
"bg-size": "bg",
|
|
205
|
+
"bg-position": "bg",
|
|
206
|
+
"bg-repeat": "bg",
|
|
207
|
+
// Interactivity
|
|
208
|
+
scroll: "scroll",
|
|
209
|
+
snap: "snap",
|
|
210
|
+
touch: "touch",
|
|
211
|
+
"will-change": "will-change",
|
|
212
|
+
caret: "caret",
|
|
213
|
+
accent: "accent",
|
|
214
|
+
// SVG
|
|
215
|
+
"stroke-width": "stroke"
|
|
152
216
|
};
|
|
153
217
|
var MODIFIERS = [
|
|
154
218
|
"hover",
|
|
@@ -193,12 +257,31 @@ var MODIFIERS = [
|
|
|
193
257
|
// Print
|
|
194
258
|
"print"
|
|
195
259
|
];
|
|
260
|
+
var BOOLEAN_VALUE_PROPS = ["shadow", "rounded", "border", "transition", "ring", "outline"];
|
|
196
261
|
var joinClassNames = (classNames) => {
|
|
197
262
|
if (!classNames || classNames.length === 0) {
|
|
198
263
|
return "";
|
|
199
264
|
}
|
|
200
265
|
return classNames.filter(Boolean).join(" ");
|
|
201
266
|
};
|
|
267
|
+
var processModifierObject = (modifier, obj, classes) => {
|
|
268
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
269
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
270
|
+
if (MODIFIERS.includes(key)) {
|
|
271
|
+
processModifierObject(`${modifier}:${key}`, value, classes);
|
|
272
|
+
}
|
|
273
|
+
} else if (key in VALUE_PROPS_MAP) {
|
|
274
|
+
const prefix = VALUE_PROPS_MAP[key];
|
|
275
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
276
|
+
classes.push(`${modifier}:${prefix}-${value}`);
|
|
277
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(key)) {
|
|
278
|
+
classes.push(`${modifier}:${key}`);
|
|
279
|
+
}
|
|
280
|
+
} else if (LAYOUT_PROPS.includes(key) && value === true) {
|
|
281
|
+
classes.push(`${modifier}:${key}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
};
|
|
202
285
|
var withClassNames = (props) => {
|
|
203
286
|
if (!props) {
|
|
204
287
|
return props;
|
|
@@ -207,9 +290,13 @@ var withClassNames = (props) => {
|
|
|
207
290
|
const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
|
|
208
291
|
const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
|
|
209
292
|
const propsKeys = Object.keys(props);
|
|
210
|
-
const
|
|
293
|
+
const hasHyphenatedModifiers = propsKeys.some((key) => {
|
|
211
294
|
return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
|
|
212
295
|
});
|
|
296
|
+
const hasObjectModifiers = propsKeys.some((key) => {
|
|
297
|
+
return MODIFIERS.includes(key) && typeof props[key] === "object" && props[key] !== null;
|
|
298
|
+
});
|
|
299
|
+
const hasModifiers = hasHyphenatedModifiers || hasObjectModifiers;
|
|
213
300
|
if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
|
|
214
301
|
return props;
|
|
215
302
|
}
|
|
@@ -228,12 +315,21 @@ var withClassNames = (props) => {
|
|
|
228
315
|
if (typeof value === "string" || typeof value === "number") {
|
|
229
316
|
generatedClasses.push(`${prefix}-${value}`);
|
|
230
317
|
delete cleanRest[prop];
|
|
231
|
-
} else if (value === true && (prop
|
|
318
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(prop)) {
|
|
232
319
|
generatedClasses.push(prop);
|
|
233
320
|
delete cleanRest[prop];
|
|
234
321
|
}
|
|
235
322
|
}
|
|
236
323
|
}
|
|
324
|
+
for (const modifier of MODIFIERS) {
|
|
325
|
+
if (modifier in cleanRest) {
|
|
326
|
+
const value = cleanRest[modifier];
|
|
327
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
328
|
+
processModifierObject(modifier, value, generatedClasses);
|
|
329
|
+
delete cleanRest[modifier];
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
}
|
|
237
333
|
Object.keys(cleanRest).forEach((key) => {
|
|
238
334
|
const firstHyphenIndex = key.indexOf("-");
|
|
239
335
|
if (firstHyphenIndex === -1) return;
|
|
@@ -246,7 +342,7 @@ var withClassNames = (props) => {
|
|
|
246
342
|
if (typeof value === "string" || typeof value === "number") {
|
|
247
343
|
generatedClasses.push(`${modifier}:${prefix}-${value}`);
|
|
248
344
|
delete cleanRest[key];
|
|
249
|
-
} else if (value === true && (restKey
|
|
345
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(restKey)) {
|
|
250
346
|
generatedClasses.push(`${modifier}:${restKey}`);
|
|
251
347
|
delete cleanRest[key];
|
|
252
348
|
}
|
package/dist/index.js
CHANGED
package/dist/jsx-dev-runtime.cjs
CHANGED
|
@@ -150,7 +150,71 @@ var VALUE_PROPS_MAP = {
|
|
|
150
150
|
rotate: "rotate",
|
|
151
151
|
translate: "translate",
|
|
152
152
|
skew: "skew",
|
|
153
|
-
origin: "origin"
|
|
153
|
+
origin: "origin",
|
|
154
|
+
// Layout & Position
|
|
155
|
+
top: "top",
|
|
156
|
+
right: "right",
|
|
157
|
+
bottom: "bottom",
|
|
158
|
+
left: "left",
|
|
159
|
+
inset: "inset",
|
|
160
|
+
"inset-x": "inset-x",
|
|
161
|
+
"inset-y": "inset-y",
|
|
162
|
+
aspect: "aspect",
|
|
163
|
+
columns: "columns",
|
|
164
|
+
float: "float",
|
|
165
|
+
clear: "clear",
|
|
166
|
+
// Flexbox & Grid
|
|
167
|
+
basis: "basis",
|
|
168
|
+
"gap-x": "gap-x",
|
|
169
|
+
"gap-y": "gap-y",
|
|
170
|
+
"auto-cols": "auto-cols",
|
|
171
|
+
"auto-rows": "auto-rows",
|
|
172
|
+
"grid-flow": "grid-flow",
|
|
173
|
+
"space-x": "space-x",
|
|
174
|
+
"space-y": "space-y",
|
|
175
|
+
"justify-items": "justify-items",
|
|
176
|
+
"justify-self": "justify-self",
|
|
177
|
+
// Sizing
|
|
178
|
+
size: "size",
|
|
179
|
+
// Borders
|
|
180
|
+
"border-t": "border-t",
|
|
181
|
+
"border-r": "border-r",
|
|
182
|
+
"border-b": "border-b",
|
|
183
|
+
"border-l": "border-l",
|
|
184
|
+
"border-x": "border-x",
|
|
185
|
+
"border-y": "border-y",
|
|
186
|
+
"rounded-t": "rounded-t",
|
|
187
|
+
"rounded-r": "rounded-r",
|
|
188
|
+
"rounded-b": "rounded-b",
|
|
189
|
+
"rounded-l": "rounded-l",
|
|
190
|
+
"rounded-tl": "rounded-tl",
|
|
191
|
+
"rounded-tr": "rounded-tr",
|
|
192
|
+
"rounded-bl": "rounded-bl",
|
|
193
|
+
"rounded-br": "rounded-br",
|
|
194
|
+
"border-style": "border",
|
|
195
|
+
// Typography
|
|
196
|
+
"text-align": "text",
|
|
197
|
+
align: "align",
|
|
198
|
+
"line-clamp": "line-clamp",
|
|
199
|
+
list: "list",
|
|
200
|
+
indent: "indent",
|
|
201
|
+
// Backgrounds & Gradients
|
|
202
|
+
"bg-gradient": "bg-gradient",
|
|
203
|
+
from: "from",
|
|
204
|
+
via: "via",
|
|
205
|
+
to: "to",
|
|
206
|
+
"bg-size": "bg",
|
|
207
|
+
"bg-position": "bg",
|
|
208
|
+
"bg-repeat": "bg",
|
|
209
|
+
// Interactivity
|
|
210
|
+
scroll: "scroll",
|
|
211
|
+
snap: "snap",
|
|
212
|
+
touch: "touch",
|
|
213
|
+
"will-change": "will-change",
|
|
214
|
+
caret: "caret",
|
|
215
|
+
accent: "accent",
|
|
216
|
+
// SVG
|
|
217
|
+
"stroke-width": "stroke"
|
|
154
218
|
};
|
|
155
219
|
var MODIFIERS = [
|
|
156
220
|
"hover",
|
|
@@ -195,12 +259,31 @@ var MODIFIERS = [
|
|
|
195
259
|
// Print
|
|
196
260
|
"print"
|
|
197
261
|
];
|
|
262
|
+
var BOOLEAN_VALUE_PROPS = ["shadow", "rounded", "border", "transition", "ring", "outline"];
|
|
198
263
|
var joinClassNames = (classNames) => {
|
|
199
264
|
if (!classNames || classNames.length === 0) {
|
|
200
265
|
return "";
|
|
201
266
|
}
|
|
202
267
|
return classNames.filter(Boolean).join(" ");
|
|
203
268
|
};
|
|
269
|
+
var processModifierObject = (modifier, obj, classes) => {
|
|
270
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
271
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
272
|
+
if (MODIFIERS.includes(key)) {
|
|
273
|
+
processModifierObject(`${modifier}:${key}`, value, classes);
|
|
274
|
+
}
|
|
275
|
+
} else if (key in VALUE_PROPS_MAP) {
|
|
276
|
+
const prefix = VALUE_PROPS_MAP[key];
|
|
277
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
278
|
+
classes.push(`${modifier}:${prefix}-${value}`);
|
|
279
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(key)) {
|
|
280
|
+
classes.push(`${modifier}:${key}`);
|
|
281
|
+
}
|
|
282
|
+
} else if (LAYOUT_PROPS.includes(key) && value === true) {
|
|
283
|
+
classes.push(`${modifier}:${key}`);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
};
|
|
204
287
|
var withClassNames = (props) => {
|
|
205
288
|
if (!props) {
|
|
206
289
|
return props;
|
|
@@ -209,9 +292,13 @@ var withClassNames = (props) => {
|
|
|
209
292
|
const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
|
|
210
293
|
const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
|
|
211
294
|
const propsKeys = Object.keys(props);
|
|
212
|
-
const
|
|
295
|
+
const hasHyphenatedModifiers = propsKeys.some((key) => {
|
|
213
296
|
return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
|
|
214
297
|
});
|
|
298
|
+
const hasObjectModifiers = propsKeys.some((key) => {
|
|
299
|
+
return MODIFIERS.includes(key) && typeof props[key] === "object" && props[key] !== null;
|
|
300
|
+
});
|
|
301
|
+
const hasModifiers = hasHyphenatedModifiers || hasObjectModifiers;
|
|
215
302
|
if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
|
|
216
303
|
return props;
|
|
217
304
|
}
|
|
@@ -230,12 +317,21 @@ var withClassNames = (props) => {
|
|
|
230
317
|
if (typeof value === "string" || typeof value === "number") {
|
|
231
318
|
generatedClasses.push(`${prefix}-${value}`);
|
|
232
319
|
delete cleanRest[prop];
|
|
233
|
-
} else if (value === true && (prop
|
|
320
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(prop)) {
|
|
234
321
|
generatedClasses.push(prop);
|
|
235
322
|
delete cleanRest[prop];
|
|
236
323
|
}
|
|
237
324
|
}
|
|
238
325
|
}
|
|
326
|
+
for (const modifier of MODIFIERS) {
|
|
327
|
+
if (modifier in cleanRest) {
|
|
328
|
+
const value = cleanRest[modifier];
|
|
329
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
330
|
+
processModifierObject(modifier, value, generatedClasses);
|
|
331
|
+
delete cleanRest[modifier];
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
239
335
|
Object.keys(cleanRest).forEach((key) => {
|
|
240
336
|
const firstHyphenIndex = key.indexOf("-");
|
|
241
337
|
if (firstHyphenIndex === -1) return;
|
|
@@ -248,7 +344,7 @@ var withClassNames = (props) => {
|
|
|
248
344
|
if (typeof value === "string" || typeof value === "number") {
|
|
249
345
|
generatedClasses.push(`${modifier}:${prefix}-${value}`);
|
|
250
346
|
delete cleanRest[key];
|
|
251
|
-
} else if (value === true && (restKey
|
|
347
|
+
} else if (value === true && BOOLEAN_VALUE_PROPS.includes(restKey)) {
|
|
252
348
|
generatedClasses.push(`${modifier}:${restKey}`);
|
|
253
349
|
delete cleanRest[key];
|
|
254
350
|
}
|