@itamarshdev/reactwind 0.1.1 → 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.
@@ -102,6 +102,17 @@ var VALUE_PROPS_MAP = {
102
102
  "min-w": "min-w",
103
103
  "min-h": "min-h",
104
104
  "max-h": "max-h",
105
+ "grid-cols": "grid-cols",
106
+ "col-span": "col-span",
107
+ "row-span": "row-span",
108
+ "grid-rows": "grid-rows",
109
+ "items": "items",
110
+ "justify": "justify",
111
+ "self": "self",
112
+ "place-content": "place-content",
113
+ "place-items": "place-items",
114
+ "place-self": "place-self",
115
+ "order": "order",
105
116
  overflow: "overflow",
106
117
  decoration: "decoration",
107
118
  whitespace: "whitespace",
@@ -109,6 +120,8 @@ var VALUE_PROPS_MAP = {
109
120
  content: "content",
110
121
  opacity: "opacity",
111
122
  "bg-opacity": "bg-opacity",
123
+ "text-opacity": "text-opacity",
124
+ "border-opacity": "border-opacity",
112
125
  ring: "ring",
113
126
  "ring-offset": "ring-offset",
114
127
  outline: "outline",
@@ -137,14 +150,140 @@ var VALUE_PROPS_MAP = {
137
150
  rotate: "rotate",
138
151
  translate: "translate",
139
152
  skew: "skew",
140
- 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"
141
218
  };
219
+ var MODIFIERS = [
220
+ "hover",
221
+ "focus",
222
+ "active",
223
+ "visited",
224
+ "disabled",
225
+ "group-hover",
226
+ "group-focus",
227
+ "focus-within",
228
+ "focus-visible",
229
+ "target",
230
+ "first",
231
+ "last",
232
+ "only",
233
+ "odd",
234
+ "even",
235
+ "first-of-type",
236
+ "last-of-type",
237
+ "only-of-type",
238
+ "empty",
239
+ "checked",
240
+ "indeterminate",
241
+ "default",
242
+ "required",
243
+ "valid",
244
+ "invalid",
245
+ "in-range",
246
+ "out-of-range",
247
+ "placeholder-shown",
248
+ "autofill",
249
+ "read-only",
250
+ "open",
251
+ // Responsive breakpoints
252
+ "sm",
253
+ "md",
254
+ "lg",
255
+ "xl",
256
+ "2xl",
257
+ // Dark mode
258
+ "dark",
259
+ // Print
260
+ "print"
261
+ ];
262
+ var BOOLEAN_VALUE_PROPS = ["shadow", "rounded", "border", "transition", "ring", "outline"];
142
263
  var joinClassNames = (classNames) => {
143
264
  if (!classNames || classNames.length === 0) {
144
265
  return "";
145
266
  }
146
267
  return classNames.filter(Boolean).join(" ");
147
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
+ };
148
287
  var withClassNames = (props) => {
149
288
  if (!props) {
150
289
  return props;
@@ -152,7 +291,15 @@ var withClassNames = (props) => {
152
291
  const hasClassNames = "classNames" in props;
153
292
  const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
154
293
  const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
155
- if (!hasClassNames && !hasLayoutProps && !hasValueProps) {
294
+ const propsKeys = Object.keys(props);
295
+ const hasHyphenatedModifiers = propsKeys.some((key) => {
296
+ return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
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;
302
+ if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
156
303
  return props;
157
304
  }
158
305
  const { classNames, className, ...rest } = props;
@@ -170,12 +317,45 @@ var withClassNames = (props) => {
170
317
  if (typeof value === "string" || typeof value === "number") {
171
318
  generatedClasses.push(`${prefix}-${value}`);
172
319
  delete cleanRest[prop];
173
- } else if (value === true && (prop === "shadow" || prop === "rounded")) {
320
+ } else if (value === true && BOOLEAN_VALUE_PROPS.includes(prop)) {
174
321
  generatedClasses.push(prop);
175
322
  delete cleanRest[prop];
176
323
  }
177
324
  }
178
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
+ }
335
+ Object.keys(cleanRest).forEach((key) => {
336
+ const firstHyphenIndex = key.indexOf("-");
337
+ if (firstHyphenIndex === -1) return;
338
+ const modifier = key.substring(0, firstHyphenIndex);
339
+ if (MODIFIERS.includes(modifier)) {
340
+ const restKey = key.substring(firstHyphenIndex + 1);
341
+ const value = cleanRest[key];
342
+ if (restKey in VALUE_PROPS_MAP) {
343
+ const prefix = VALUE_PROPS_MAP[restKey];
344
+ if (typeof value === "string" || typeof value === "number") {
345
+ generatedClasses.push(`${modifier}:${prefix}-${value}`);
346
+ delete cleanRest[key];
347
+ } else if (value === true && BOOLEAN_VALUE_PROPS.includes(restKey)) {
348
+ generatedClasses.push(`${modifier}:${restKey}`);
349
+ delete cleanRest[key];
350
+ }
351
+ } else if (LAYOUT_PROPS.includes(restKey)) {
352
+ if (value === true) {
353
+ generatedClasses.push(`${modifier}:${restKey}`);
354
+ delete cleanRest[key];
355
+ }
356
+ }
357
+ }
358
+ });
179
359
  const joined = joinClassNames(classNames || []);
180
360
  const merged = [className, ...generatedClasses, joined].filter(Boolean).join(" ");
181
361
  return {
@@ -1,4 +1,4 @@
1
- import './types-CvNsUSZP.cjs';
1
+ import './types-Bb5v_nmy.cjs';
2
2
  import React from 'react';
3
3
  export { Fragment } from 'react/jsx-dev-runtime';
4
4
  export { JSX } from 'react/jsx-runtime';
@@ -1,4 +1,4 @@
1
- import './types-DDH_n69B.js';
1
+ import './types-CBbQP9uE.js';
2
2
  import React from 'react';
3
3
  export { Fragment } from 'react/jsx-dev-runtime';
4
4
  export { JSX } from 'react/jsx-runtime';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withClassNames
3
- } from "./chunk-WXTVOZ4W.js";
3
+ } from "./chunk-KAWYX6WW.js";
4
4
 
5
5
  // src/jsx-dev-runtime.ts
6
6
  import { Fragment, jsxDEV as reactJsxDEV } from "react/jsx-dev-runtime";
@@ -103,6 +103,17 @@ var VALUE_PROPS_MAP = {
103
103
  "min-w": "min-w",
104
104
  "min-h": "min-h",
105
105
  "max-h": "max-h",
106
+ "grid-cols": "grid-cols",
107
+ "col-span": "col-span",
108
+ "row-span": "row-span",
109
+ "grid-rows": "grid-rows",
110
+ "items": "items",
111
+ "justify": "justify",
112
+ "self": "self",
113
+ "place-content": "place-content",
114
+ "place-items": "place-items",
115
+ "place-self": "place-self",
116
+ "order": "order",
106
117
  overflow: "overflow",
107
118
  decoration: "decoration",
108
119
  whitespace: "whitespace",
@@ -110,6 +121,8 @@ var VALUE_PROPS_MAP = {
110
121
  content: "content",
111
122
  opacity: "opacity",
112
123
  "bg-opacity": "bg-opacity",
124
+ "text-opacity": "text-opacity",
125
+ "border-opacity": "border-opacity",
113
126
  ring: "ring",
114
127
  "ring-offset": "ring-offset",
115
128
  outline: "outline",
@@ -138,14 +151,140 @@ var VALUE_PROPS_MAP = {
138
151
  rotate: "rotate",
139
152
  translate: "translate",
140
153
  skew: "skew",
141
- origin: "origin"
154
+ origin: "origin",
155
+ // Layout & Position
156
+ top: "top",
157
+ right: "right",
158
+ bottom: "bottom",
159
+ left: "left",
160
+ inset: "inset",
161
+ "inset-x": "inset-x",
162
+ "inset-y": "inset-y",
163
+ aspect: "aspect",
164
+ columns: "columns",
165
+ float: "float",
166
+ clear: "clear",
167
+ // Flexbox & Grid
168
+ basis: "basis",
169
+ "gap-x": "gap-x",
170
+ "gap-y": "gap-y",
171
+ "auto-cols": "auto-cols",
172
+ "auto-rows": "auto-rows",
173
+ "grid-flow": "grid-flow",
174
+ "space-x": "space-x",
175
+ "space-y": "space-y",
176
+ "justify-items": "justify-items",
177
+ "justify-self": "justify-self",
178
+ // Sizing
179
+ size: "size",
180
+ // Borders
181
+ "border-t": "border-t",
182
+ "border-r": "border-r",
183
+ "border-b": "border-b",
184
+ "border-l": "border-l",
185
+ "border-x": "border-x",
186
+ "border-y": "border-y",
187
+ "rounded-t": "rounded-t",
188
+ "rounded-r": "rounded-r",
189
+ "rounded-b": "rounded-b",
190
+ "rounded-l": "rounded-l",
191
+ "rounded-tl": "rounded-tl",
192
+ "rounded-tr": "rounded-tr",
193
+ "rounded-bl": "rounded-bl",
194
+ "rounded-br": "rounded-br",
195
+ "border-style": "border",
196
+ // Typography
197
+ "text-align": "text",
198
+ align: "align",
199
+ "line-clamp": "line-clamp",
200
+ list: "list",
201
+ indent: "indent",
202
+ // Backgrounds & Gradients
203
+ "bg-gradient": "bg-gradient",
204
+ from: "from",
205
+ via: "via",
206
+ to: "to",
207
+ "bg-size": "bg",
208
+ "bg-position": "bg",
209
+ "bg-repeat": "bg",
210
+ // Interactivity
211
+ scroll: "scroll",
212
+ snap: "snap",
213
+ touch: "touch",
214
+ "will-change": "will-change",
215
+ caret: "caret",
216
+ accent: "accent",
217
+ // SVG
218
+ "stroke-width": "stroke"
142
219
  };
220
+ var MODIFIERS = [
221
+ "hover",
222
+ "focus",
223
+ "active",
224
+ "visited",
225
+ "disabled",
226
+ "group-hover",
227
+ "group-focus",
228
+ "focus-within",
229
+ "focus-visible",
230
+ "target",
231
+ "first",
232
+ "last",
233
+ "only",
234
+ "odd",
235
+ "even",
236
+ "first-of-type",
237
+ "last-of-type",
238
+ "only-of-type",
239
+ "empty",
240
+ "checked",
241
+ "indeterminate",
242
+ "default",
243
+ "required",
244
+ "valid",
245
+ "invalid",
246
+ "in-range",
247
+ "out-of-range",
248
+ "placeholder-shown",
249
+ "autofill",
250
+ "read-only",
251
+ "open",
252
+ // Responsive breakpoints
253
+ "sm",
254
+ "md",
255
+ "lg",
256
+ "xl",
257
+ "2xl",
258
+ // Dark mode
259
+ "dark",
260
+ // Print
261
+ "print"
262
+ ];
263
+ var BOOLEAN_VALUE_PROPS = ["shadow", "rounded", "border", "transition", "ring", "outline"];
143
264
  var joinClassNames = (classNames) => {
144
265
  if (!classNames || classNames.length === 0) {
145
266
  return "";
146
267
  }
147
268
  return classNames.filter(Boolean).join(" ");
148
269
  };
270
+ var processModifierObject = (modifier, obj, classes) => {
271
+ for (const [key, value] of Object.entries(obj)) {
272
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
273
+ if (MODIFIERS.includes(key)) {
274
+ processModifierObject(`${modifier}:${key}`, value, classes);
275
+ }
276
+ } else if (key in VALUE_PROPS_MAP) {
277
+ const prefix = VALUE_PROPS_MAP[key];
278
+ if (typeof value === "string" || typeof value === "number") {
279
+ classes.push(`${modifier}:${prefix}-${value}`);
280
+ } else if (value === true && BOOLEAN_VALUE_PROPS.includes(key)) {
281
+ classes.push(`${modifier}:${key}`);
282
+ }
283
+ } else if (LAYOUT_PROPS.includes(key) && value === true) {
284
+ classes.push(`${modifier}:${key}`);
285
+ }
286
+ }
287
+ };
149
288
  var withClassNames = (props) => {
150
289
  if (!props) {
151
290
  return props;
@@ -153,7 +292,15 @@ var withClassNames = (props) => {
153
292
  const hasClassNames = "classNames" in props;
154
293
  const hasLayoutProps = LAYOUT_PROPS.some((k) => k in props);
155
294
  const hasValueProps = Object.keys(VALUE_PROPS_MAP).some((k) => k in props);
156
- if (!hasClassNames && !hasLayoutProps && !hasValueProps) {
295
+ const propsKeys = Object.keys(props);
296
+ const hasHyphenatedModifiers = propsKeys.some((key) => {
297
+ return MODIFIERS.some((mod) => key.startsWith(`${mod}-`));
298
+ });
299
+ const hasObjectModifiers = propsKeys.some((key) => {
300
+ return MODIFIERS.includes(key) && typeof props[key] === "object" && props[key] !== null;
301
+ });
302
+ const hasModifiers = hasHyphenatedModifiers || hasObjectModifiers;
303
+ if (!hasClassNames && !hasLayoutProps && !hasValueProps && !hasModifiers) {
157
304
  return props;
158
305
  }
159
306
  const { classNames, className, ...rest } = props;
@@ -171,12 +318,45 @@ var withClassNames = (props) => {
171
318
  if (typeof value === "string" || typeof value === "number") {
172
319
  generatedClasses.push(`${prefix}-${value}`);
173
320
  delete cleanRest[prop];
174
- } else if (value === true && (prop === "shadow" || prop === "rounded")) {
321
+ } else if (value === true && BOOLEAN_VALUE_PROPS.includes(prop)) {
175
322
  generatedClasses.push(prop);
176
323
  delete cleanRest[prop];
177
324
  }
178
325
  }
179
326
  }
327
+ for (const modifier of MODIFIERS) {
328
+ if (modifier in cleanRest) {
329
+ const value = cleanRest[modifier];
330
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) {
331
+ processModifierObject(modifier, value, generatedClasses);
332
+ delete cleanRest[modifier];
333
+ }
334
+ }
335
+ }
336
+ Object.keys(cleanRest).forEach((key) => {
337
+ const firstHyphenIndex = key.indexOf("-");
338
+ if (firstHyphenIndex === -1) return;
339
+ const modifier = key.substring(0, firstHyphenIndex);
340
+ if (MODIFIERS.includes(modifier)) {
341
+ const restKey = key.substring(firstHyphenIndex + 1);
342
+ const value = cleanRest[key];
343
+ if (restKey in VALUE_PROPS_MAP) {
344
+ const prefix = VALUE_PROPS_MAP[restKey];
345
+ if (typeof value === "string" || typeof value === "number") {
346
+ generatedClasses.push(`${modifier}:${prefix}-${value}`);
347
+ delete cleanRest[key];
348
+ } else if (value === true && BOOLEAN_VALUE_PROPS.includes(restKey)) {
349
+ generatedClasses.push(`${modifier}:${restKey}`);
350
+ delete cleanRest[key];
351
+ }
352
+ } else if (LAYOUT_PROPS.includes(restKey)) {
353
+ if (value === true) {
354
+ generatedClasses.push(`${modifier}:${restKey}`);
355
+ delete cleanRest[key];
356
+ }
357
+ }
358
+ }
359
+ });
180
360
  const joined = joinClassNames(classNames || []);
181
361
  const merged = [className, ...generatedClasses, joined].filter(Boolean).join(" ");
182
362
  return {
@@ -1,4 +1,4 @@
1
- import './types-CvNsUSZP.cjs';
1
+ import './types-Bb5v_nmy.cjs';
2
2
  import React from 'react';
3
3
  export { Fragment, JSX } from 'react/jsx-runtime';
4
4
  import './tailwind.types-BSQudz76.cjs';
@@ -1,4 +1,4 @@
1
- import './types-DDH_n69B.js';
1
+ import './types-CBbQP9uE.js';
2
2
  import React from 'react';
3
3
  export { Fragment, JSX } from 'react/jsx-runtime';
4
4
  import './tailwind.types-BSQudz76.js';
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  withClassNames
3
- } from "./chunk-WXTVOZ4W.js";
3
+ } from "./chunk-KAWYX6WW.js";
4
4
 
5
5
  // src/jsx-runtime.ts
6
6
  import { Fragment, jsx as reactJsx, jsxs as reactJsxs } from "react/jsx-runtime";