@itamarshdev/reactwind 0.1.1 → 1.0.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 +3 -3
- package/dist/chunk-FHQBPEXA.js +232 -0
- package/dist/chunk-M5PDERS6.js +245 -0
- package/dist/index.cjs +86 -2
- package/dist/index.js +1 -1
- package/dist/jsx-dev-runtime.cjs +86 -2
- 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 +86 -2
- 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-Bdh-X84v.d.ts +125 -0
- package/dist/types-CIbmaQ6w.d.ts +125 -0
- package/dist/types-DmvPRSBP.d.cts +125 -0
- package/dist/types-WLlcB_RW.d.cts +125 -0
- package/package.json +22 -243
package/README.md
CHANGED
|
@@ -0,0 +1,232 @@
|
|
|
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
|
+
overflow: "overflow",
|
|
78
|
+
decoration: "decoration",
|
|
79
|
+
whitespace: "whitespace",
|
|
80
|
+
break: "break",
|
|
81
|
+
content: "content",
|
|
82
|
+
opacity: "opacity",
|
|
83
|
+
"bg-opacity": "bg-opacity",
|
|
84
|
+
ring: "ring",
|
|
85
|
+
"ring-offset": "ring-offset",
|
|
86
|
+
outline: "outline",
|
|
87
|
+
divide: "divide",
|
|
88
|
+
"mix-blend": "mix-blend",
|
|
89
|
+
"backdrop-blur": "backdrop-blur",
|
|
90
|
+
blur: "blur",
|
|
91
|
+
brightness: "brightness",
|
|
92
|
+
contrast: "contrast",
|
|
93
|
+
grayscale: "grayscale",
|
|
94
|
+
"hue-rotate": "hue-rotate",
|
|
95
|
+
invert: "invert",
|
|
96
|
+
saturate: "saturate",
|
|
97
|
+
sepia: "sepia",
|
|
98
|
+
"drop-shadow": "drop-shadow",
|
|
99
|
+
transition: "transition",
|
|
100
|
+
duration: "duration",
|
|
101
|
+
ease: "ease",
|
|
102
|
+
delay: "delay",
|
|
103
|
+
animate: "animate",
|
|
104
|
+
cursor: "cursor",
|
|
105
|
+
"pointer-events": "pointer-events",
|
|
106
|
+
resize: "resize",
|
|
107
|
+
select: "select",
|
|
108
|
+
scale: "scale",
|
|
109
|
+
rotate: "rotate",
|
|
110
|
+
translate: "translate",
|
|
111
|
+
skew: "skew",
|
|
112
|
+
origin: "origin"
|
|
113
|
+
};
|
|
114
|
+
var MODIFIERS = [
|
|
115
|
+
"hover",
|
|
116
|
+
"focus",
|
|
117
|
+
"active",
|
|
118
|
+
"visited",
|
|
119
|
+
"disabled",
|
|
120
|
+
"group-hover",
|
|
121
|
+
"group-focus",
|
|
122
|
+
"focus-within",
|
|
123
|
+
"focus-visible",
|
|
124
|
+
"target",
|
|
125
|
+
"first",
|
|
126
|
+
"last",
|
|
127
|
+
"only",
|
|
128
|
+
"odd",
|
|
129
|
+
"even",
|
|
130
|
+
"first-of-type",
|
|
131
|
+
"last-of-type",
|
|
132
|
+
"only-of-type",
|
|
133
|
+
"empty",
|
|
134
|
+
"checked",
|
|
135
|
+
"indeterminate",
|
|
136
|
+
"default",
|
|
137
|
+
"required",
|
|
138
|
+
"valid",
|
|
139
|
+
"invalid",
|
|
140
|
+
"in-range",
|
|
141
|
+
"out-of-range",
|
|
142
|
+
"placeholder-shown",
|
|
143
|
+
"autofill",
|
|
144
|
+
"read-only",
|
|
145
|
+
"open",
|
|
146
|
+
// Responsive breakpoints
|
|
147
|
+
"sm",
|
|
148
|
+
"md",
|
|
149
|
+
"lg",
|
|
150
|
+
"xl",
|
|
151
|
+
"2xl",
|
|
152
|
+
// Dark mode
|
|
153
|
+
"dark",
|
|
154
|
+
// Print
|
|
155
|
+
"print"
|
|
156
|
+
];
|
|
157
|
+
var joinClassNames = (classNames) => {
|
|
158
|
+
if (!classNames || classNames.length === 0) {
|
|
159
|
+
return "";
|
|
160
|
+
}
|
|
161
|
+
return classNames.filter(Boolean).join(" ");
|
|
162
|
+
};
|
|
163
|
+
var withClassNames = (props) => {
|
|
164
|
+
if (!props) {
|
|
165
|
+
return props;
|
|
166
|
+
}
|
|
167
|
+
const hasClassNames = "classNames" in props;
|
|
168
|
+
const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
|
|
169
|
+
const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
|
|
170
|
+
const propsKeys = Object.keys(props);
|
|
171
|
+
const hasModifiers = propsKeys.some((key) => {
|
|
172
|
+
return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
|
|
173
|
+
});
|
|
174
|
+
if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
|
|
175
|
+
return props;
|
|
176
|
+
}
|
|
177
|
+
const { classNames, className, ...rest } = props;
|
|
178
|
+
const generatedClasses = [];
|
|
179
|
+
const cleanRest = { ...rest };
|
|
180
|
+
for (const prop of LAYOUT_PROPS) {
|
|
181
|
+
if (prop in cleanRest && cleanRest[prop] === true) {
|
|
182
|
+
generatedClasses.push(prop);
|
|
183
|
+
delete cleanRest[prop];
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const [prop, prefix] of Object.entries(VALUE_PROPS_MAP)) {
|
|
187
|
+
if (prop in cleanRest) {
|
|
188
|
+
const value = cleanRest[prop];
|
|
189
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
190
|
+
generatedClasses.push(`${prefix}-${value}`);
|
|
191
|
+
delete cleanRest[prop];
|
|
192
|
+
} else if (value === true && (prop === "shadow" || prop === "rounded" || prop === "border" || prop === "transition")) {
|
|
193
|
+
generatedClasses.push(prop);
|
|
194
|
+
delete cleanRest[prop];
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
Object.keys(cleanRest).forEach((key) => {
|
|
199
|
+
const firstHyphenIndex = key.indexOf("-");
|
|
200
|
+
if (firstHyphenIndex === -1) return;
|
|
201
|
+
const modifier = key.substring(0, firstHyphenIndex);
|
|
202
|
+
if (MODIFIERS.includes(modifier)) {
|
|
203
|
+
const restKey = key.substring(firstHyphenIndex + 1);
|
|
204
|
+
const value = cleanRest[key];
|
|
205
|
+
if (restKey in VALUE_PROPS_MAP) {
|
|
206
|
+
const prefix = VALUE_PROPS_MAP[restKey];
|
|
207
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
208
|
+
generatedClasses.push(`${modifier}:${prefix}-${value}`);
|
|
209
|
+
delete cleanRest[key];
|
|
210
|
+
} else if (value === true && (restKey === "shadow" || restKey === "rounded" || restKey === "border")) {
|
|
211
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
212
|
+
delete cleanRest[key];
|
|
213
|
+
}
|
|
214
|
+
} else if (LAYOUT_PROPS.includes(restKey)) {
|
|
215
|
+
if (value === true) {
|
|
216
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
217
|
+
delete cleanRest[key];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
const joined = joinClassNames(classNames || []);
|
|
223
|
+
const merged = [className, ...generatedClasses, joined].filter(Boolean).join(" ");
|
|
224
|
+
return {
|
|
225
|
+
...cleanRest,
|
|
226
|
+
...merged ? { className: merged } : {}
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
export {
|
|
231
|
+
withClassNames
|
|
232
|
+
};
|
|
@@ -0,0 +1,245 @@
|
|
|
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
|
+
};
|
|
127
|
+
var MODIFIERS = [
|
|
128
|
+
"hover",
|
|
129
|
+
"focus",
|
|
130
|
+
"active",
|
|
131
|
+
"visited",
|
|
132
|
+
"disabled",
|
|
133
|
+
"group-hover",
|
|
134
|
+
"group-focus",
|
|
135
|
+
"focus-within",
|
|
136
|
+
"focus-visible",
|
|
137
|
+
"target",
|
|
138
|
+
"first",
|
|
139
|
+
"last",
|
|
140
|
+
"only",
|
|
141
|
+
"odd",
|
|
142
|
+
"even",
|
|
143
|
+
"first-of-type",
|
|
144
|
+
"last-of-type",
|
|
145
|
+
"only-of-type",
|
|
146
|
+
"empty",
|
|
147
|
+
"checked",
|
|
148
|
+
"indeterminate",
|
|
149
|
+
"default",
|
|
150
|
+
"required",
|
|
151
|
+
"valid",
|
|
152
|
+
"invalid",
|
|
153
|
+
"in-range",
|
|
154
|
+
"out-of-range",
|
|
155
|
+
"placeholder-shown",
|
|
156
|
+
"autofill",
|
|
157
|
+
"read-only",
|
|
158
|
+
"open",
|
|
159
|
+
// Responsive breakpoints
|
|
160
|
+
"sm",
|
|
161
|
+
"md",
|
|
162
|
+
"lg",
|
|
163
|
+
"xl",
|
|
164
|
+
"2xl",
|
|
165
|
+
// Dark mode
|
|
166
|
+
"dark",
|
|
167
|
+
// Print
|
|
168
|
+
"print"
|
|
169
|
+
];
|
|
170
|
+
var joinClassNames = (classNames) => {
|
|
171
|
+
if (!classNames || classNames.length === 0) {
|
|
172
|
+
return "";
|
|
173
|
+
}
|
|
174
|
+
return classNames.filter(Boolean).join(" ");
|
|
175
|
+
};
|
|
176
|
+
var withClassNames = (props) => {
|
|
177
|
+
if (!props) {
|
|
178
|
+
return props;
|
|
179
|
+
}
|
|
180
|
+
const hasClassNames = "classNames" in props;
|
|
181
|
+
const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
|
|
182
|
+
const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
|
|
183
|
+
const propsKeys = Object.keys(props);
|
|
184
|
+
const hasModifiers = propsKeys.some((key) => {
|
|
185
|
+
return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
|
|
186
|
+
});
|
|
187
|
+
if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
|
|
188
|
+
return props;
|
|
189
|
+
}
|
|
190
|
+
const { classNames, className, ...rest } = props;
|
|
191
|
+
const generatedClasses = [];
|
|
192
|
+
const cleanRest = { ...rest };
|
|
193
|
+
for (const prop of LAYOUT_PROPS) {
|
|
194
|
+
if (prop in cleanRest && cleanRest[prop] === true) {
|
|
195
|
+
generatedClasses.push(prop);
|
|
196
|
+
delete cleanRest[prop];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
for (const [prop, prefix] of Object.entries(VALUE_PROPS_MAP)) {
|
|
200
|
+
if (prop in cleanRest) {
|
|
201
|
+
const value = cleanRest[prop];
|
|
202
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
203
|
+
generatedClasses.push(`${prefix}-${value}`);
|
|
204
|
+
delete cleanRest[prop];
|
|
205
|
+
} else if (value === true && (prop === "shadow" || prop === "rounded" || prop === "border" || prop === "transition")) {
|
|
206
|
+
generatedClasses.push(prop);
|
|
207
|
+
delete cleanRest[prop];
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
Object.keys(cleanRest).forEach((key) => {
|
|
212
|
+
const firstHyphenIndex = key.indexOf("-");
|
|
213
|
+
if (firstHyphenIndex === -1) return;
|
|
214
|
+
const modifier = key.substring(0, firstHyphenIndex);
|
|
215
|
+
if (MODIFIERS.includes(modifier)) {
|
|
216
|
+
const restKey = key.substring(firstHyphenIndex + 1);
|
|
217
|
+
const value = cleanRest[key];
|
|
218
|
+
if (restKey in VALUE_PROPS_MAP) {
|
|
219
|
+
const prefix = VALUE_PROPS_MAP[restKey];
|
|
220
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
221
|
+
generatedClasses.push(`${modifier}:${prefix}-${value}`);
|
|
222
|
+
delete cleanRest[key];
|
|
223
|
+
} else if (value === true && (restKey === "shadow" || restKey === "rounded" || restKey === "border")) {
|
|
224
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
225
|
+
delete cleanRest[key];
|
|
226
|
+
}
|
|
227
|
+
} else if (LAYOUT_PROPS.includes(restKey)) {
|
|
228
|
+
if (value === true) {
|
|
229
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
230
|
+
delete cleanRest[key];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
const joined = joinClassNames(classNames || []);
|
|
236
|
+
const merged = [className, ...generatedClasses, joined].filter(Boolean).join(" ");
|
|
237
|
+
return {
|
|
238
|
+
...cleanRest,
|
|
239
|
+
...merged ? { className: merged } : {}
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
export {
|
|
244
|
+
withClassNames
|
|
245
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -100,6 +100,17 @@ var VALUE_PROPS_MAP = {
|
|
|
100
100
|
"min-w": "min-w",
|
|
101
101
|
"min-h": "min-h",
|
|
102
102
|
"max-h": "max-h",
|
|
103
|
+
"grid-cols": "grid-cols",
|
|
104
|
+
"col-span": "col-span",
|
|
105
|
+
"row-span": "row-span",
|
|
106
|
+
"grid-rows": "grid-rows",
|
|
107
|
+
"items": "items",
|
|
108
|
+
"justify": "justify",
|
|
109
|
+
"self": "self",
|
|
110
|
+
"place-content": "place-content",
|
|
111
|
+
"place-items": "place-items",
|
|
112
|
+
"place-self": "place-self",
|
|
113
|
+
"order": "order",
|
|
103
114
|
overflow: "overflow",
|
|
104
115
|
decoration: "decoration",
|
|
105
116
|
whitespace: "whitespace",
|
|
@@ -107,6 +118,8 @@ var VALUE_PROPS_MAP = {
|
|
|
107
118
|
content: "content",
|
|
108
119
|
opacity: "opacity",
|
|
109
120
|
"bg-opacity": "bg-opacity",
|
|
121
|
+
"text-opacity": "text-opacity",
|
|
122
|
+
"border-opacity": "border-opacity",
|
|
110
123
|
ring: "ring",
|
|
111
124
|
"ring-offset": "ring-offset",
|
|
112
125
|
outline: "outline",
|
|
@@ -137,6 +150,49 @@ var VALUE_PROPS_MAP = {
|
|
|
137
150
|
skew: "skew",
|
|
138
151
|
origin: "origin"
|
|
139
152
|
};
|
|
153
|
+
var MODIFIERS = [
|
|
154
|
+
"hover",
|
|
155
|
+
"focus",
|
|
156
|
+
"active",
|
|
157
|
+
"visited",
|
|
158
|
+
"disabled",
|
|
159
|
+
"group-hover",
|
|
160
|
+
"group-focus",
|
|
161
|
+
"focus-within",
|
|
162
|
+
"focus-visible",
|
|
163
|
+
"target",
|
|
164
|
+
"first",
|
|
165
|
+
"last",
|
|
166
|
+
"only",
|
|
167
|
+
"odd",
|
|
168
|
+
"even",
|
|
169
|
+
"first-of-type",
|
|
170
|
+
"last-of-type",
|
|
171
|
+
"only-of-type",
|
|
172
|
+
"empty",
|
|
173
|
+
"checked",
|
|
174
|
+
"indeterminate",
|
|
175
|
+
"default",
|
|
176
|
+
"required",
|
|
177
|
+
"valid",
|
|
178
|
+
"invalid",
|
|
179
|
+
"in-range",
|
|
180
|
+
"out-of-range",
|
|
181
|
+
"placeholder-shown",
|
|
182
|
+
"autofill",
|
|
183
|
+
"read-only",
|
|
184
|
+
"open",
|
|
185
|
+
// Responsive breakpoints
|
|
186
|
+
"sm",
|
|
187
|
+
"md",
|
|
188
|
+
"lg",
|
|
189
|
+
"xl",
|
|
190
|
+
"2xl",
|
|
191
|
+
// Dark mode
|
|
192
|
+
"dark",
|
|
193
|
+
// Print
|
|
194
|
+
"print"
|
|
195
|
+
];
|
|
140
196
|
var joinClassNames = (classNames) => {
|
|
141
197
|
if (!classNames || classNames.length === 0) {
|
|
142
198
|
return "";
|
|
@@ -150,7 +206,11 @@ var withClassNames = (props) => {
|
|
|
150
206
|
const hasClassNames = "classNames" in props;
|
|
151
207
|
const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
|
|
152
208
|
const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
|
|
153
|
-
|
|
209
|
+
const propsKeys = Object.keys(props);
|
|
210
|
+
const hasModifiers = propsKeys.some((key) => {
|
|
211
|
+
return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
|
|
212
|
+
});
|
|
213
|
+
if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
|
|
154
214
|
return props;
|
|
155
215
|
}
|
|
156
216
|
const { classNames, className, ...rest } = props;
|
|
@@ -168,12 +228,36 @@ var withClassNames = (props) => {
|
|
|
168
228
|
if (typeof value === "string" || typeof value === "number") {
|
|
169
229
|
generatedClasses.push(`${prefix}-${value}`);
|
|
170
230
|
delete cleanRest[prop];
|
|
171
|
-
} else if (value === true && (prop === "shadow" || prop === "rounded")) {
|
|
231
|
+
} else if (value === true && (prop === "shadow" || prop === "rounded" || prop === "border" || prop === "transition")) {
|
|
172
232
|
generatedClasses.push(prop);
|
|
173
233
|
delete cleanRest[prop];
|
|
174
234
|
}
|
|
175
235
|
}
|
|
176
236
|
}
|
|
237
|
+
Object.keys(cleanRest).forEach((key) => {
|
|
238
|
+
const firstHyphenIndex = key.indexOf("-");
|
|
239
|
+
if (firstHyphenIndex === -1) return;
|
|
240
|
+
const modifier = key.substring(0, firstHyphenIndex);
|
|
241
|
+
if (MODIFIERS.includes(modifier)) {
|
|
242
|
+
const restKey = key.substring(firstHyphenIndex + 1);
|
|
243
|
+
const value = cleanRest[key];
|
|
244
|
+
if (restKey in VALUE_PROPS_MAP) {
|
|
245
|
+
const prefix = VALUE_PROPS_MAP[restKey];
|
|
246
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
247
|
+
generatedClasses.push(`${modifier}:${prefix}-${value}`);
|
|
248
|
+
delete cleanRest[key];
|
|
249
|
+
} else if (value === true && (restKey === "shadow" || restKey === "rounded" || restKey === "border")) {
|
|
250
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
251
|
+
delete cleanRest[key];
|
|
252
|
+
}
|
|
253
|
+
} else if (LAYOUT_PROPS.includes(restKey)) {
|
|
254
|
+
if (value === true) {
|
|
255
|
+
generatedClasses.push(`${modifier}:${restKey}`);
|
|
256
|
+
delete cleanRest[key];
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
});
|
|
177
261
|
const joined = joinClassNames(classNames || []);
|
|
178
262
|
const merged = [className, ...generatedClasses, joined].filter(Boolean).join(" ");
|
|
179
263
|
return {
|