tailwind-variants 2.0.0 → 2.0.1

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.
@@ -0,0 +1 @@
1
+ 'use strict';var u=e=>e===false?"false":e===true?"true":e===0?"0":e,a=e=>{if(!e||typeof e!="object")return true;for(let r in e)return false;return true},y=(e,r)=>{if(e===r)return true;if(!e||!r)return false;let n=Object.keys(e),t=Object.keys(r);if(n.length!==t.length)return false;for(let s=0;s<n.length;s++){let f=n[s];if(!t.includes(f)||e[f]!==r[f])return false}return true},p=e=>e===true||e===false;function o(e,r){for(let n=0;n<e.length;n++){let t=e[n];Array.isArray(t)?o(t,r):r.push(t);}}function g(e){let r=[];return o(e,r),r}var i=(...e)=>{let r=[];o(e,r);let n=[];for(let t=0;t<r.length;t++)r[t]&&n.push(r[t]);return n},c=(e,r)=>{let n={};for(let t in e){let s=e[t];if(t in r){let f=r[t];Array.isArray(s)||Array.isArray(f)?n[t]=i(f,s):typeof s=="object"&&typeof f=="object"&&s&&f?n[t]=c(s,f):n[t]=f+" "+s;}else n[t]=s;}for(let t in r)t in e||(n[t]=r[t]);return n},l=/\s+/g,x=e=>!e||typeof e!="string"?e:e.replace(l," ").trim();exports.a=u;exports.b=a;exports.c=y;exports.d=p;exports.e=g;exports.f=i;exports.g=c;exports.h=x;
@@ -0,0 +1 @@
1
+ var u=e=>e===false?"false":e===true?"true":e===0?"0":e,a=e=>{if(!e||typeof e!="object")return true;for(let r in e)return false;return true},y=(e,r)=>{if(e===r)return true;if(!e||!r)return false;let n=Object.keys(e),t=Object.keys(r);if(n.length!==t.length)return false;for(let s=0;s<n.length;s++){let f=n[s];if(!t.includes(f)||e[f]!==r[f])return false}return true},p=e=>e===true||e===false;function o(e,r){for(let n=0;n<e.length;n++){let t=e[n];Array.isArray(t)?o(t,r):r.push(t);}}function g(e){let r=[];return o(e,r),r}var i=(...e)=>{let r=[];o(e,r);let n=[];for(let t=0;t<r.length;t++)r[t]&&n.push(r[t]);return n},c=(e,r)=>{let n={};for(let t in e){let s=e[t];if(t in r){let f=r[t];Array.isArray(s)||Array.isArray(f)?n[t]=i(f,s):typeof s=="object"&&typeof f=="object"&&s&&f?n[t]=c(s,f):n[t]=f+" "+s;}else n[t]=s;}for(let t in r)t in e||(n[t]=r[t]);return n},l=/\s+/g,x=e=>!e||typeof e!="string"?e:e.replace(l," ").trim();export{u as a,a as b,y as c,p as d,g as e,i as f,c as g,x as h};
@@ -0,0 +1 @@
1
+ import {b}from'./chunk-LK3VBVBE.js';import {twMerge,extendTailwindMerge}from'tailwind-merge';var p=s=>b(s)?twMerge:extendTailwindMerge({...s,extend:{theme:s.theme,classGroups:s.classGroups,conflictingClassGroupModifiers:s.conflictingClassGroupModifiers,conflictingClassGroups:s.conflictingClassGroups,...s.extend}});export{p as a};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk7H22QZCA_cjs=require('./chunk-7H22QZCA.cjs'),tailwindMerge=require('tailwind-merge');var p=s=>chunk7H22QZCA_cjs.b(s)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge({...s,extend:{theme:s.theme,classGroups:s.classGroups,conflictingClassGroupModifiers:s.conflictingClassGroupModifiers,conflictingClassGroups:s.conflictingClassGroups,...s.extend}});exports.a=p;
package/dist/cn.cjs CHANGED
@@ -1,11 +1 @@
1
- 'use strict';
2
-
3
- var chunkBDOHQXGU_cjs = require('./chunk-BDOHQXGU.cjs');
4
- require('./chunk-L4Q3BGWH.cjs');
5
-
6
-
7
-
8
- Object.defineProperty(exports, "createTwMerge", {
9
- enumerable: true,
10
- get: function () { return chunkBDOHQXGU_cjs.createTwMerge; }
11
- });
1
+ 'use strict';var chunkSEUVYOWD_cjs=require('./chunk-SEUVYOWD.cjs');require('./chunk-7H22QZCA.cjs');Object.defineProperty(exports,"createTwMerge",{enumerable:true,get:function(){return chunkSEUVYOWD_cjs.a}});
package/dist/cn.js CHANGED
@@ -1,2 +1 @@
1
- export { createTwMerge } from './chunk-GVHG2OMS.js';
2
- import './chunk-YWS777Q5.js';
1
+ export{a as createTwMerge}from'./chunk-RFCF2RNL.js';import'./chunk-LK3VBVBE.js';
package/dist/index.cjs CHANGED
@@ -1,333 +1 @@
1
- 'use strict';
2
-
3
- var chunkBDOHQXGU_cjs = require('./chunk-BDOHQXGU.cjs');
4
- var chunkL4Q3BGWH_cjs = require('./chunk-L4Q3BGWH.cjs');
5
-
6
- // src/index.js
7
- var defaultConfig = {
8
- twMerge: true,
9
- twMergeConfig: {},
10
- responsiveVariants: false
11
- };
12
- var cnBase = (...classes) => {
13
- const result = [];
14
- flat(classes, result);
15
- let str = "";
16
- for (let i = 0; i < result.length; i++) {
17
- if (result[i]) {
18
- if (str) str += " ";
19
- str += result[i];
20
- }
21
- }
22
- return str || void 0;
23
- };
24
- function flat(arr, target) {
25
- for (let i = 0; i < arr.length; i++) {
26
- const el = arr[i];
27
- if (Array.isArray(el)) flat(el, target);
28
- else if (el) target.push(el);
29
- }
30
- }
31
- var cachedTwMerge = null;
32
- var cachedTwMergeConfig = {};
33
- var didTwMergeConfigChange = false;
34
- var cn = (...classes) => (config) => {
35
- const base = cnBase(classes);
36
- if (!base || !config.twMerge) return base;
37
- if (!cachedTwMerge || didTwMergeConfigChange) {
38
- didTwMergeConfigChange = false;
39
- cachedTwMerge = chunkBDOHQXGU_cjs.createTwMerge(cachedTwMergeConfig);
40
- }
41
- return cachedTwMerge(base) || void 0;
42
- };
43
- var joinObjects = (obj1, obj2) => {
44
- for (const key in obj2) {
45
- if (key in obj1) {
46
- obj1[key] = cnBase(obj1[key], obj2[key]);
47
- } else {
48
- obj1[key] = obj2[key];
49
- }
50
- }
51
- return obj1;
52
- };
53
- var tv = (options, configProp) => {
54
- const {
55
- extend = null,
56
- slots: slotProps = {},
57
- variants: variantsProps = {},
58
- compoundVariants: compoundVariantsProps = [],
59
- compoundSlots = [],
60
- defaultVariants: defaultVariantsProps = {}
61
- } = options;
62
- const config = { ...defaultConfig, ...configProp };
63
- const base = extend?.base ? cnBase(extend.base, options?.base) : options?.base;
64
- const variants = extend?.variants && !chunkL4Q3BGWH_cjs.isEmptyObject(extend.variants) ? chunkL4Q3BGWH_cjs.mergeObjects(variantsProps, extend.variants) : variantsProps;
65
- const defaultVariants = extend?.defaultVariants && !chunkL4Q3BGWH_cjs.isEmptyObject(extend.defaultVariants) ? { ...extend.defaultVariants, ...defaultVariantsProps } : defaultVariantsProps;
66
- if (!chunkL4Q3BGWH_cjs.isEmptyObject(config.twMergeConfig) && !chunkL4Q3BGWH_cjs.isEqual(config.twMergeConfig, cachedTwMergeConfig)) {
67
- didTwMergeConfigChange = true;
68
- cachedTwMergeConfig = config.twMergeConfig;
69
- }
70
- const isExtendedSlotsEmpty = chunkL4Q3BGWH_cjs.isEmptyObject(extend?.slots);
71
- const componentSlots = !chunkL4Q3BGWH_cjs.isEmptyObject(slotProps) ? {
72
- // add "base" to the slots object
73
- base: cnBase(options?.base, isExtendedSlotsEmpty && extend?.base),
74
- ...slotProps
75
- } : {};
76
- const slots = isExtendedSlotsEmpty ? componentSlots : joinObjects(
77
- { ...extend?.slots },
78
- chunkL4Q3BGWH_cjs.isEmptyObject(componentSlots) ? { base: options?.base } : componentSlots
79
- );
80
- const compoundVariants = chunkL4Q3BGWH_cjs.isEmptyObject(extend?.compoundVariants) ? compoundVariantsProps : chunkL4Q3BGWH_cjs.flatMergeArrays(extend?.compoundVariants, compoundVariantsProps);
81
- const component = (props) => {
82
- if (chunkL4Q3BGWH_cjs.isEmptyObject(variants) && chunkL4Q3BGWH_cjs.isEmptyObject(slotProps) && isExtendedSlotsEmpty) {
83
- return cn(base, props?.class, props?.className)(config);
84
- }
85
- if (compoundVariants && !Array.isArray(compoundVariants)) {
86
- throw new TypeError(
87
- `The "compoundVariants" prop must be an array. Received: ${typeof compoundVariants}`
88
- );
89
- }
90
- if (compoundSlots && !Array.isArray(compoundSlots)) {
91
- throw new TypeError(
92
- `The "compoundSlots" prop must be an array. Received: ${typeof compoundSlots}`
93
- );
94
- }
95
- const getScreenVariantValues = (screen, screenVariantValue, acc = [], slotKey) => {
96
- let result = acc;
97
- if (typeof screenVariantValue === "string") {
98
- const cleaned = chunkL4Q3BGWH_cjs.removeExtraSpaces(screenVariantValue);
99
- const parts = cleaned.split(" ");
100
- for (let i = 0; i < parts.length; i++) {
101
- result.push(`${screen}:${parts[i]}`);
102
- }
103
- } else if (Array.isArray(screenVariantValue)) {
104
- for (let i = 0; i < screenVariantValue.length; i++) {
105
- result.push(`${screen}:${screenVariantValue[i]}`);
106
- }
107
- } else if (typeof screenVariantValue === "object" && typeof slotKey === "string") {
108
- if (slotKey in screenVariantValue) {
109
- const value = screenVariantValue[slotKey];
110
- if (value && typeof value === "string") {
111
- const fixedValue = chunkL4Q3BGWH_cjs.removeExtraSpaces(value);
112
- const parts = fixedValue.split(" ");
113
- const arr = [];
114
- for (let i = 0; i < parts.length; i++) {
115
- arr.push(`${screen}:${parts[i]}`);
116
- }
117
- result[slotKey] = result[slotKey] ? result[slotKey].concat(arr) : arr;
118
- } else if (Array.isArray(value) && value.length > 0) {
119
- const arr = [];
120
- for (let i = 0; i < value.length; i++) {
121
- arr.push(`${screen}:${value[i]}`);
122
- }
123
- result[slotKey] = arr;
124
- }
125
- }
126
- }
127
- return result;
128
- };
129
- const getVariantValue = (variant, vrs = variants, slotKey = null, slotProps2 = null) => {
130
- const variantObj = vrs[variant];
131
- if (!variantObj || chunkL4Q3BGWH_cjs.isEmptyObject(variantObj)) {
132
- return null;
133
- }
134
- const variantProp = slotProps2?.[variant] ?? props?.[variant];
135
- if (variantProp === null) return null;
136
- const variantKey = chunkL4Q3BGWH_cjs.falsyToString(variantProp);
137
- const responsiveVarsEnabled = Array.isArray(config.responsiveVariants) && config.responsiveVariants.length > 0 || config.responsiveVariants === true;
138
- let defaultVariantProp = defaultVariants?.[variant];
139
- let screenValues = [];
140
- if (typeof variantKey === "object" && responsiveVarsEnabled) {
141
- for (const [screen, screenVariantKey] of Object.entries(variantKey)) {
142
- const screenVariantValue = variantObj[screenVariantKey];
143
- if (screen === "initial") {
144
- defaultVariantProp = screenVariantKey;
145
- continue;
146
- }
147
- if (Array.isArray(config.responsiveVariants) && !config.responsiveVariants.includes(screen)) {
148
- continue;
149
- }
150
- screenValues = getScreenVariantValues(screen, screenVariantValue, screenValues, slotKey);
151
- }
152
- }
153
- const key = variantKey != null && typeof variantKey != "object" ? variantKey : chunkL4Q3BGWH_cjs.falsyToString(defaultVariantProp);
154
- const value = variantObj[key || "false"];
155
- if (typeof screenValues === "object" && typeof slotKey === "string" && screenValues[slotKey]) {
156
- return joinObjects(screenValues, value);
157
- }
158
- if (screenValues.length > 0) {
159
- screenValues.push(value);
160
- if (slotKey === "base") {
161
- return screenValues.join(" ");
162
- }
163
- return screenValues;
164
- }
165
- return value;
166
- };
167
- const getVariantClassNames = () => {
168
- if (!variants) return null;
169
- const keys = Object.keys(variants);
170
- const result = [];
171
- for (let i = 0; i < keys.length; i++) {
172
- const value = getVariantValue(keys[i], variants);
173
- if (value) result.push(value);
174
- }
175
- return result;
176
- };
177
- const getVariantClassNamesBySlotKey = (slotKey, slotProps2) => {
178
- if (!variants || typeof variants !== "object") return null;
179
- const result = [];
180
- for (const variant in variants) {
181
- const variantValue = getVariantValue(variant, variants, slotKey, slotProps2);
182
- const value = slotKey === "base" && typeof variantValue === "string" ? variantValue : variantValue && variantValue[slotKey];
183
- if (value) result.push(value);
184
- }
185
- return result;
186
- };
187
- const propsWithoutUndefined = {};
188
- for (const prop in props) {
189
- const value = props[prop];
190
- if (value !== void 0) propsWithoutUndefined[prop] = value;
191
- }
192
- const getCompleteProps = (key, slotProps2) => {
193
- const initialProp = typeof props?.[key] === "object" ? {
194
- [key]: props[key]?.initial
195
- } : {};
196
- return {
197
- ...defaultVariants,
198
- ...propsWithoutUndefined,
199
- ...initialProp,
200
- ...slotProps2
201
- };
202
- };
203
- const getCompoundVariantsValue = (cv = [], slotProps2) => {
204
- const result = [];
205
- const cvLength = cv.length;
206
- for (let i = 0; i < cvLength; i++) {
207
- const { class: tvClass, className: tvClassName, ...compoundVariantOptions } = cv[i];
208
- let isValid = true;
209
- const completeProps = getCompleteProps(null, slotProps2);
210
- for (const key in compoundVariantOptions) {
211
- const value = compoundVariantOptions[key];
212
- const completePropsValue = completeProps[key];
213
- if (Array.isArray(value)) {
214
- if (!value.includes(completePropsValue)) {
215
- isValid = false;
216
- break;
217
- }
218
- } else {
219
- if ((value == null || value === false) && (completePropsValue == null || completePropsValue === false))
220
- continue;
221
- if (completePropsValue !== value) {
222
- isValid = false;
223
- break;
224
- }
225
- }
226
- }
227
- if (isValid) {
228
- if (tvClass) result.push(tvClass);
229
- if (tvClassName) result.push(tvClassName);
230
- }
231
- }
232
- return result;
233
- };
234
- const getCompoundVariantClassNamesBySlot = (slotProps2) => {
235
- const compoundClassNames = getCompoundVariantsValue(compoundVariants, slotProps2);
236
- if (!Array.isArray(compoundClassNames)) return compoundClassNames;
237
- const result = {};
238
- const cnFn = cn;
239
- for (let i = 0; i < compoundClassNames.length; i++) {
240
- const className = compoundClassNames[i];
241
- if (typeof className === "string") {
242
- result.base = cnFn(result.base, className)(config);
243
- } else if (typeof className === "object") {
244
- for (const slot in className) {
245
- result[slot] = cnFn(result[slot], className[slot])(config);
246
- }
247
- }
248
- }
249
- return result;
250
- };
251
- const getCompoundSlotClassNameBySlot = (slotProps2) => {
252
- if (compoundSlots.length < 1) return null;
253
- const result = {};
254
- const completeProps = getCompleteProps(null, slotProps2);
255
- for (let i = 0; i < compoundSlots.length; i++) {
256
- const {
257
- slots: slots2 = [],
258
- class: slotClass,
259
- className: slotClassName,
260
- ...slotVariants
261
- } = compoundSlots[i];
262
- if (!chunkL4Q3BGWH_cjs.isEmptyObject(slotVariants)) {
263
- let isValid = true;
264
- for (const key in slotVariants) {
265
- const completePropsValue = completeProps[key];
266
- const slotVariantValue = slotVariants[key];
267
- if (completePropsValue === void 0 || (Array.isArray(slotVariantValue) ? !slotVariantValue.includes(completePropsValue) : slotVariantValue !== completePropsValue)) {
268
- isValid = false;
269
- break;
270
- }
271
- }
272
- if (!isValid) continue;
273
- }
274
- for (let j = 0; j < slots2.length; j++) {
275
- const slotName = slots2[j];
276
- if (!result[slotName]) result[slotName] = [];
277
- result[slotName].push([slotClass, slotClassName]);
278
- }
279
- }
280
- return result;
281
- };
282
- if (!chunkL4Q3BGWH_cjs.isEmptyObject(slotProps) || !isExtendedSlotsEmpty) {
283
- const slotsFns = {};
284
- if (typeof slots === "object" && !chunkL4Q3BGWH_cjs.isEmptyObject(slots)) {
285
- const cnFn = cn;
286
- for (const slotKey in slots) {
287
- slotsFns[slotKey] = (slotProps2) => {
288
- const compoundVariantClasses = getCompoundVariantClassNamesBySlot(slotProps2);
289
- const compoundSlotClasses = getCompoundSlotClassNameBySlot(slotProps2);
290
- return cnFn(
291
- slots[slotKey],
292
- getVariantClassNamesBySlotKey(slotKey, slotProps2),
293
- compoundVariantClasses ? compoundVariantClasses[slotKey] : void 0,
294
- compoundSlotClasses ? compoundSlotClasses[slotKey] : void 0,
295
- slotProps2?.class,
296
- slotProps2?.className
297
- )(config);
298
- };
299
- }
300
- }
301
- return slotsFns;
302
- }
303
- return cn(
304
- base,
305
- getVariantClassNames(),
306
- getCompoundVariantsValue(compoundVariants),
307
- props?.class,
308
- props?.className
309
- )(config);
310
- };
311
- const getVariantKeys = () => {
312
- if (!variants || typeof variants !== "object") return;
313
- return Object.keys(variants);
314
- };
315
- component.variantKeys = getVariantKeys();
316
- component.extend = extend;
317
- component.base = base;
318
- component.slots = slots;
319
- component.variants = variants;
320
- component.defaultVariants = defaultVariants;
321
- component.compoundSlots = compoundSlots;
322
- component.compoundVariants = compoundVariants;
323
- return component;
324
- };
325
- var createTV = (configProp) => {
326
- return (options, config) => tv(options, config ? chunkL4Q3BGWH_cjs.mergeObjects(configProp, config) : configProp);
327
- };
328
-
329
- exports.cn = cn;
330
- exports.cnBase = cnBase;
331
- exports.createTV = createTV;
332
- exports.defaultConfig = defaultConfig;
333
- exports.tv = tv;
1
+ 'use strict';var chunkSEUVYOWD_cjs=require('./chunk-SEUVYOWD.cjs'),chunk7H22QZCA_cjs=require('./chunk-7H22QZCA.cjs');var st={twMerge:true,twMergeConfig:{},responsiveVariants:false},x=(...l)=>{let u=[];X(l,u);let t="";for(let d=0;d<u.length;d++)u[d]&&(t&&(t+=" "),t+=u[d]);return t||void 0};function X(l,u){for(let t=0;t<l.length;t++){let d=l[t];Array.isArray(d)?X(d,u):d&&u.push(d);}}var P=null,B={},F=false,S=(...l)=>u=>{let t=x(l);return !t||!u.twMerge?t:((!P||F)&&(F=false,P=chunkSEUVYOWD_cjs.a(B)),P(t)||void 0)},Q=(l,u)=>{for(let t in u)t in l?l[t]=x(l[t],u[t]):l[t]=u[t];return l},rt=(l,u)=>{let{extend:t=null,slots:d={},variants:R={},compoundVariants:q=[],compoundSlots:A=[],defaultVariants:L={}}=l,m={...st,...u},M=t?.base?x(t.base,l?.base):l?.base,y=t?.variants&&!chunk7H22QZCA_cjs.b(t.variants)?chunk7H22QZCA_cjs.g(R,t.variants):R,T=t?.defaultVariants&&!chunk7H22QZCA_cjs.b(t.defaultVariants)?{...t.defaultVariants,...L}:L;!chunk7H22QZCA_cjs.b(m.twMergeConfig)&&!chunk7H22QZCA_cjs.c(m.twMergeConfig,B)&&(F=true,B=m.twMergeConfig);let j=chunk7H22QZCA_cjs.b(t?.slots),$=chunk7H22QZCA_cjs.b(d)?{}:{base:x(l?.base,j&&t?.base),...d},N=j?$:Q({...t?.slots},chunk7H22QZCA_cjs.b($)?{base:l?.base}:$),w=chunk7H22QZCA_cjs.b(t?.compoundVariants)?q:chunk7H22QZCA_cjs.f(t?.compoundVariants,q),V=b=>{if(chunk7H22QZCA_cjs.b(y)&&chunk7H22QZCA_cjs.b(d)&&j)return S(M,b?.class,b?.className)(m);if(w&&!Array.isArray(w))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof w}`);if(A&&!Array.isArray(A))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof A}`);let Z=(n,e,s=[],o)=>{let a=s;if(typeof e=="string"){let c=chunk7H22QZCA_cjs.h(e).split(" ");for(let f=0;f<c.length;f++)a.push(`${n}:${c[f]}`);}else if(Array.isArray(e))for(let r=0;r<e.length;r++)a.push(`${n}:${e[r]}`);else if(typeof e=="object"&&typeof o=="string"&&o in e){let r=e[o];if(r&&typeof r=="string"){let f=chunk7H22QZCA_cjs.h(r).split(" "),p=[];for(let i=0;i<f.length;i++)p.push(`${n}:${f[i]}`);a[o]=a[o]?a[o].concat(p):p;}else if(Array.isArray(r)&&r.length>0){let c=[];for(let f=0;f<r.length;f++)c.push(`${n}:${r[f]}`);a[o]=c;}}return a},U=(n,e=y,s=null,o=null)=>{let a=e[n];if(!a||chunk7H22QZCA_cjs.b(a))return null;let r=o?.[n]??b?.[n];if(r===null)return null;let c=chunk7H22QZCA_cjs.a(r),f=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===true,p=T?.[n],i=[];if(typeof c=="object"&&f)for(let[C,G]of Object.entries(c)){let nt=a[G];if(C==="initial"){p=G;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(C)||(i=Z(C,nt,i,s));}let v=c!=null&&typeof c!="object"?c:chunk7H22QZCA_cjs.a(p),h=a[v||"false"];return typeof i=="object"&&typeof s=="string"&&i[s]?Q(i,h):i.length>0?(i.push(h),s==="base"?i.join(" "):i):h},_=()=>{if(!y)return null;let n=Object.keys(y),e=[];for(let s=0;s<n.length;s++){let o=U(n[s],y);o&&e.push(o);}return e},K=(n,e)=>{if(!y||typeof y!="object")return null;let s=[];for(let o in y){let a=U(o,y,n,e),r=n==="base"&&typeof a=="string"?a:a&&a[n];r&&s.push(r);}return s},W={};for(let n in b){let e=b[n];e!==void 0&&(W[n]=e);}let z=(n,e)=>{let s=typeof b?.[n]=="object"?{[n]:b[n]?.initial}:{};return {...T,...W,...s,...e}},D=(n=[],e)=>{let s=[],o=n.length;for(let a=0;a<o;a++){let{class:r,className:c,...f}=n[a],p=true,i=z(null,e);for(let v in f){let h=f[v],C=i[v];if(Array.isArray(h)){if(!h.includes(C)){p=false;break}}else {if((h==null||h===false)&&(C==null||C===false))continue;if(C!==h){p=false;break}}}p&&(r&&s.push(r),c&&s.push(c));}return s},tt=n=>{let e=D(w,n);if(!Array.isArray(e))return e;let s={},o=S;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="string")s.base=o(s.base,r)(m);else if(typeof r=="object")for(let c in r)s[c]=o(s[c],r[c])(m);}return s},et=n=>{if(A.length<1)return null;let e={},s=z(null,n);for(let o=0;o<A.length;o++){let{slots:a=[],class:r,className:c,...f}=A[o];if(!chunk7H22QZCA_cjs.b(f)){let p=true;for(let i in f){let v=s[i],h=f[i];if(v===void 0||(Array.isArray(h)?!h.includes(v):h!==v)){p=false;break}}if(!p)continue}for(let p=0;p<a.length;p++){let i=a[p];e[i]||(e[i]=[]),e[i].push([r,c]);}}return e};if(!chunk7H22QZCA_cjs.b(d)||!j){let n={};if(typeof N=="object"&&!chunk7H22QZCA_cjs.b(N)){let e=S;for(let s in N)n[s]=o=>{let a=tt(o),r=et(o);return e(N[s],K(s,o),a?a[s]:void 0,r?r[s]:void 0,o?.class,o?.className)(m)};}return n}return S(M,_(),D(w),b?.class,b?.className)(m)},Y=()=>{if(!(!y||typeof y!="object"))return Object.keys(y)};return V.variantKeys=Y(),V.extend=t,V.base=M,V.slots=N,V.variants=y,V.defaultVariants=T,V.compoundSlots=A,V.compoundVariants=w,V},it=l=>(u,t)=>rt(u,t?chunk7H22QZCA_cjs.g(l,t):l);exports.cn=S;exports.cnBase=x;exports.createTV=it;exports.defaultConfig=st;exports.tv=rt;
package/dist/index.js CHANGED
@@ -1,327 +1 @@
1
- import { createTwMerge } from './chunk-GVHG2OMS.js';
2
- import { isEmptyObject, mergeObjects, isEqual, flatMergeArrays, falsyToString, removeExtraSpaces } from './chunk-YWS777Q5.js';
3
-
4
- // src/index.js
5
- var defaultConfig = {
6
- twMerge: true,
7
- twMergeConfig: {},
8
- responsiveVariants: false
9
- };
10
- var cnBase = (...classes) => {
11
- const result = [];
12
- flat(classes, result);
13
- let str = "";
14
- for (let i = 0; i < result.length; i++) {
15
- if (result[i]) {
16
- if (str) str += " ";
17
- str += result[i];
18
- }
19
- }
20
- return str || void 0;
21
- };
22
- function flat(arr, target) {
23
- for (let i = 0; i < arr.length; i++) {
24
- const el = arr[i];
25
- if (Array.isArray(el)) flat(el, target);
26
- else if (el) target.push(el);
27
- }
28
- }
29
- var cachedTwMerge = null;
30
- var cachedTwMergeConfig = {};
31
- var didTwMergeConfigChange = false;
32
- var cn = (...classes) => (config) => {
33
- const base = cnBase(classes);
34
- if (!base || !config.twMerge) return base;
35
- if (!cachedTwMerge || didTwMergeConfigChange) {
36
- didTwMergeConfigChange = false;
37
- cachedTwMerge = createTwMerge(cachedTwMergeConfig);
38
- }
39
- return cachedTwMerge(base) || void 0;
40
- };
41
- var joinObjects = (obj1, obj2) => {
42
- for (const key in obj2) {
43
- if (key in obj1) {
44
- obj1[key] = cnBase(obj1[key], obj2[key]);
45
- } else {
46
- obj1[key] = obj2[key];
47
- }
48
- }
49
- return obj1;
50
- };
51
- var tv = (options, configProp) => {
52
- const {
53
- extend = null,
54
- slots: slotProps = {},
55
- variants: variantsProps = {},
56
- compoundVariants: compoundVariantsProps = [],
57
- compoundSlots = [],
58
- defaultVariants: defaultVariantsProps = {}
59
- } = options;
60
- const config = { ...defaultConfig, ...configProp };
61
- const base = extend?.base ? cnBase(extend.base, options?.base) : options?.base;
62
- const variants = extend?.variants && !isEmptyObject(extend.variants) ? mergeObjects(variantsProps, extend.variants) : variantsProps;
63
- const defaultVariants = extend?.defaultVariants && !isEmptyObject(extend.defaultVariants) ? { ...extend.defaultVariants, ...defaultVariantsProps } : defaultVariantsProps;
64
- if (!isEmptyObject(config.twMergeConfig) && !isEqual(config.twMergeConfig, cachedTwMergeConfig)) {
65
- didTwMergeConfigChange = true;
66
- cachedTwMergeConfig = config.twMergeConfig;
67
- }
68
- const isExtendedSlotsEmpty = isEmptyObject(extend?.slots);
69
- const componentSlots = !isEmptyObject(slotProps) ? {
70
- // add "base" to the slots object
71
- base: cnBase(options?.base, isExtendedSlotsEmpty && extend?.base),
72
- ...slotProps
73
- } : {};
74
- const slots = isExtendedSlotsEmpty ? componentSlots : joinObjects(
75
- { ...extend?.slots },
76
- isEmptyObject(componentSlots) ? { base: options?.base } : componentSlots
77
- );
78
- const compoundVariants = isEmptyObject(extend?.compoundVariants) ? compoundVariantsProps : flatMergeArrays(extend?.compoundVariants, compoundVariantsProps);
79
- const component = (props) => {
80
- if (isEmptyObject(variants) && isEmptyObject(slotProps) && isExtendedSlotsEmpty) {
81
- return cn(base, props?.class, props?.className)(config);
82
- }
83
- if (compoundVariants && !Array.isArray(compoundVariants)) {
84
- throw new TypeError(
85
- `The "compoundVariants" prop must be an array. Received: ${typeof compoundVariants}`
86
- );
87
- }
88
- if (compoundSlots && !Array.isArray(compoundSlots)) {
89
- throw new TypeError(
90
- `The "compoundSlots" prop must be an array. Received: ${typeof compoundSlots}`
91
- );
92
- }
93
- const getScreenVariantValues = (screen, screenVariantValue, acc = [], slotKey) => {
94
- let result = acc;
95
- if (typeof screenVariantValue === "string") {
96
- const cleaned = removeExtraSpaces(screenVariantValue);
97
- const parts = cleaned.split(" ");
98
- for (let i = 0; i < parts.length; i++) {
99
- result.push(`${screen}:${parts[i]}`);
100
- }
101
- } else if (Array.isArray(screenVariantValue)) {
102
- for (let i = 0; i < screenVariantValue.length; i++) {
103
- result.push(`${screen}:${screenVariantValue[i]}`);
104
- }
105
- } else if (typeof screenVariantValue === "object" && typeof slotKey === "string") {
106
- if (slotKey in screenVariantValue) {
107
- const value = screenVariantValue[slotKey];
108
- if (value && typeof value === "string") {
109
- const fixedValue = removeExtraSpaces(value);
110
- const parts = fixedValue.split(" ");
111
- const arr = [];
112
- for (let i = 0; i < parts.length; i++) {
113
- arr.push(`${screen}:${parts[i]}`);
114
- }
115
- result[slotKey] = result[slotKey] ? result[slotKey].concat(arr) : arr;
116
- } else if (Array.isArray(value) && value.length > 0) {
117
- const arr = [];
118
- for (let i = 0; i < value.length; i++) {
119
- arr.push(`${screen}:${value[i]}`);
120
- }
121
- result[slotKey] = arr;
122
- }
123
- }
124
- }
125
- return result;
126
- };
127
- const getVariantValue = (variant, vrs = variants, slotKey = null, slotProps2 = null) => {
128
- const variantObj = vrs[variant];
129
- if (!variantObj || isEmptyObject(variantObj)) {
130
- return null;
131
- }
132
- const variantProp = slotProps2?.[variant] ?? props?.[variant];
133
- if (variantProp === null) return null;
134
- const variantKey = falsyToString(variantProp);
135
- const responsiveVarsEnabled = Array.isArray(config.responsiveVariants) && config.responsiveVariants.length > 0 || config.responsiveVariants === true;
136
- let defaultVariantProp = defaultVariants?.[variant];
137
- let screenValues = [];
138
- if (typeof variantKey === "object" && responsiveVarsEnabled) {
139
- for (const [screen, screenVariantKey] of Object.entries(variantKey)) {
140
- const screenVariantValue = variantObj[screenVariantKey];
141
- if (screen === "initial") {
142
- defaultVariantProp = screenVariantKey;
143
- continue;
144
- }
145
- if (Array.isArray(config.responsiveVariants) && !config.responsiveVariants.includes(screen)) {
146
- continue;
147
- }
148
- screenValues = getScreenVariantValues(screen, screenVariantValue, screenValues, slotKey);
149
- }
150
- }
151
- const key = variantKey != null && typeof variantKey != "object" ? variantKey : falsyToString(defaultVariantProp);
152
- const value = variantObj[key || "false"];
153
- if (typeof screenValues === "object" && typeof slotKey === "string" && screenValues[slotKey]) {
154
- return joinObjects(screenValues, value);
155
- }
156
- if (screenValues.length > 0) {
157
- screenValues.push(value);
158
- if (slotKey === "base") {
159
- return screenValues.join(" ");
160
- }
161
- return screenValues;
162
- }
163
- return value;
164
- };
165
- const getVariantClassNames = () => {
166
- if (!variants) return null;
167
- const keys = Object.keys(variants);
168
- const result = [];
169
- for (let i = 0; i < keys.length; i++) {
170
- const value = getVariantValue(keys[i], variants);
171
- if (value) result.push(value);
172
- }
173
- return result;
174
- };
175
- const getVariantClassNamesBySlotKey = (slotKey, slotProps2) => {
176
- if (!variants || typeof variants !== "object") return null;
177
- const result = [];
178
- for (const variant in variants) {
179
- const variantValue = getVariantValue(variant, variants, slotKey, slotProps2);
180
- const value = slotKey === "base" && typeof variantValue === "string" ? variantValue : variantValue && variantValue[slotKey];
181
- if (value) result.push(value);
182
- }
183
- return result;
184
- };
185
- const propsWithoutUndefined = {};
186
- for (const prop in props) {
187
- const value = props[prop];
188
- if (value !== void 0) propsWithoutUndefined[prop] = value;
189
- }
190
- const getCompleteProps = (key, slotProps2) => {
191
- const initialProp = typeof props?.[key] === "object" ? {
192
- [key]: props[key]?.initial
193
- } : {};
194
- return {
195
- ...defaultVariants,
196
- ...propsWithoutUndefined,
197
- ...initialProp,
198
- ...slotProps2
199
- };
200
- };
201
- const getCompoundVariantsValue = (cv = [], slotProps2) => {
202
- const result = [];
203
- const cvLength = cv.length;
204
- for (let i = 0; i < cvLength; i++) {
205
- const { class: tvClass, className: tvClassName, ...compoundVariantOptions } = cv[i];
206
- let isValid = true;
207
- const completeProps = getCompleteProps(null, slotProps2);
208
- for (const key in compoundVariantOptions) {
209
- const value = compoundVariantOptions[key];
210
- const completePropsValue = completeProps[key];
211
- if (Array.isArray(value)) {
212
- if (!value.includes(completePropsValue)) {
213
- isValid = false;
214
- break;
215
- }
216
- } else {
217
- if ((value == null || value === false) && (completePropsValue == null || completePropsValue === false))
218
- continue;
219
- if (completePropsValue !== value) {
220
- isValid = false;
221
- break;
222
- }
223
- }
224
- }
225
- if (isValid) {
226
- if (tvClass) result.push(tvClass);
227
- if (tvClassName) result.push(tvClassName);
228
- }
229
- }
230
- return result;
231
- };
232
- const getCompoundVariantClassNamesBySlot = (slotProps2) => {
233
- const compoundClassNames = getCompoundVariantsValue(compoundVariants, slotProps2);
234
- if (!Array.isArray(compoundClassNames)) return compoundClassNames;
235
- const result = {};
236
- const cnFn = cn;
237
- for (let i = 0; i < compoundClassNames.length; i++) {
238
- const className = compoundClassNames[i];
239
- if (typeof className === "string") {
240
- result.base = cnFn(result.base, className)(config);
241
- } else if (typeof className === "object") {
242
- for (const slot in className) {
243
- result[slot] = cnFn(result[slot], className[slot])(config);
244
- }
245
- }
246
- }
247
- return result;
248
- };
249
- const getCompoundSlotClassNameBySlot = (slotProps2) => {
250
- if (compoundSlots.length < 1) return null;
251
- const result = {};
252
- const completeProps = getCompleteProps(null, slotProps2);
253
- for (let i = 0; i < compoundSlots.length; i++) {
254
- const {
255
- slots: slots2 = [],
256
- class: slotClass,
257
- className: slotClassName,
258
- ...slotVariants
259
- } = compoundSlots[i];
260
- if (!isEmptyObject(slotVariants)) {
261
- let isValid = true;
262
- for (const key in slotVariants) {
263
- const completePropsValue = completeProps[key];
264
- const slotVariantValue = slotVariants[key];
265
- if (completePropsValue === void 0 || (Array.isArray(slotVariantValue) ? !slotVariantValue.includes(completePropsValue) : slotVariantValue !== completePropsValue)) {
266
- isValid = false;
267
- break;
268
- }
269
- }
270
- if (!isValid) continue;
271
- }
272
- for (let j = 0; j < slots2.length; j++) {
273
- const slotName = slots2[j];
274
- if (!result[slotName]) result[slotName] = [];
275
- result[slotName].push([slotClass, slotClassName]);
276
- }
277
- }
278
- return result;
279
- };
280
- if (!isEmptyObject(slotProps) || !isExtendedSlotsEmpty) {
281
- const slotsFns = {};
282
- if (typeof slots === "object" && !isEmptyObject(slots)) {
283
- const cnFn = cn;
284
- for (const slotKey in slots) {
285
- slotsFns[slotKey] = (slotProps2) => {
286
- const compoundVariantClasses = getCompoundVariantClassNamesBySlot(slotProps2);
287
- const compoundSlotClasses = getCompoundSlotClassNameBySlot(slotProps2);
288
- return cnFn(
289
- slots[slotKey],
290
- getVariantClassNamesBySlotKey(slotKey, slotProps2),
291
- compoundVariantClasses ? compoundVariantClasses[slotKey] : void 0,
292
- compoundSlotClasses ? compoundSlotClasses[slotKey] : void 0,
293
- slotProps2?.class,
294
- slotProps2?.className
295
- )(config);
296
- };
297
- }
298
- }
299
- return slotsFns;
300
- }
301
- return cn(
302
- base,
303
- getVariantClassNames(),
304
- getCompoundVariantsValue(compoundVariants),
305
- props?.class,
306
- props?.className
307
- )(config);
308
- };
309
- const getVariantKeys = () => {
310
- if (!variants || typeof variants !== "object") return;
311
- return Object.keys(variants);
312
- };
313
- component.variantKeys = getVariantKeys();
314
- component.extend = extend;
315
- component.base = base;
316
- component.slots = slots;
317
- component.variants = variants;
318
- component.defaultVariants = defaultVariants;
319
- component.compoundSlots = compoundSlots;
320
- component.compoundVariants = compoundVariants;
321
- return component;
322
- };
323
- var createTV = (configProp) => {
324
- return (options, config) => tv(options, config ? mergeObjects(configProp, config) : configProp);
325
- };
326
-
327
- export { cn, cnBase, createTV, defaultConfig, tv };
1
+ import {a}from'./chunk-RFCF2RNL.js';import {b,g,c,f,a as a$1,h}from'./chunk-LK3VBVBE.js';var st={twMerge:true,twMergeConfig:{},responsiveVariants:false},x=(...l)=>{let u=[];X(l,u);let t="";for(let d=0;d<u.length;d++)u[d]&&(t&&(t+=" "),t+=u[d]);return t||void 0};function X(l,u){for(let t=0;t<l.length;t++){let d=l[t];Array.isArray(d)?X(d,u):d&&u.push(d);}}var P=null,B={},F=false,S=(...l)=>u=>{let t=x(l);return !t||!u.twMerge?t:((!P||F)&&(F=false,P=a(B)),P(t)||void 0)},Q=(l,u)=>{for(let t in u)t in l?l[t]=x(l[t],u[t]):l[t]=u[t];return l},rt=(l,u)=>{let{extend:t=null,slots:d={},variants:R={},compoundVariants:q=[],compoundSlots:A=[],defaultVariants:L={}}=l,m={...st,...u},M=t?.base?x(t.base,l?.base):l?.base,y=t?.variants&&!b(t.variants)?g(R,t.variants):R,T=t?.defaultVariants&&!b(t.defaultVariants)?{...t.defaultVariants,...L}:L;!b(m.twMergeConfig)&&!c(m.twMergeConfig,B)&&(F=true,B=m.twMergeConfig);let j=b(t?.slots),$=b(d)?{}:{base:x(l?.base,j&&t?.base),...d},N=j?$:Q({...t?.slots},b($)?{base:l?.base}:$),w=b(t?.compoundVariants)?q:f(t?.compoundVariants,q),V=b$1=>{if(b(y)&&b(d)&&j)return S(M,b$1?.class,b$1?.className)(m);if(w&&!Array.isArray(w))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof w}`);if(A&&!Array.isArray(A))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof A}`);let Z=(n,e,s=[],o)=>{let a=s;if(typeof e=="string"){let c=h(e).split(" ");for(let f=0;f<c.length;f++)a.push(`${n}:${c[f]}`);}else if(Array.isArray(e))for(let r=0;r<e.length;r++)a.push(`${n}:${e[r]}`);else if(typeof e=="object"&&typeof o=="string"&&o in e){let r=e[o];if(r&&typeof r=="string"){let f=h(r).split(" "),p=[];for(let i=0;i<f.length;i++)p.push(`${n}:${f[i]}`);a[o]=a[o]?a[o].concat(p):p;}else if(Array.isArray(r)&&r.length>0){let c=[];for(let f=0;f<r.length;f++)c.push(`${n}:${r[f]}`);a[o]=c;}}return a},U=(n,e=y,s=null,o=null)=>{let a=e[n];if(!a||b(a))return null;let r=o?.[n]??b$1?.[n];if(r===null)return null;let c=a$1(r),f=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===true,p=T?.[n],i=[];if(typeof c=="object"&&f)for(let[C,G]of Object.entries(c)){let nt=a[G];if(C==="initial"){p=G;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(C)||(i=Z(C,nt,i,s));}let v=c!=null&&typeof c!="object"?c:a$1(p),h=a[v||"false"];return typeof i=="object"&&typeof s=="string"&&i[s]?Q(i,h):i.length>0?(i.push(h),s==="base"?i.join(" "):i):h},_=()=>{if(!y)return null;let n=Object.keys(y),e=[];for(let s=0;s<n.length;s++){let o=U(n[s],y);o&&e.push(o);}return e},K=(n,e)=>{if(!y||typeof y!="object")return null;let s=[];for(let o in y){let a=U(o,y,n,e),r=n==="base"&&typeof a=="string"?a:a&&a[n];r&&s.push(r);}return s},W={};for(let n in b$1){let e=b$1[n];e!==void 0&&(W[n]=e);}let z=(n,e)=>{let s=typeof b$1?.[n]=="object"?{[n]:b$1[n]?.initial}:{};return {...T,...W,...s,...e}},D=(n=[],e)=>{let s=[],o=n.length;for(let a=0;a<o;a++){let{class:r,className:c,...f}=n[a],p=true,i=z(null,e);for(let v in f){let h=f[v],C=i[v];if(Array.isArray(h)){if(!h.includes(C)){p=false;break}}else {if((h==null||h===false)&&(C==null||C===false))continue;if(C!==h){p=false;break}}}p&&(r&&s.push(r),c&&s.push(c));}return s},tt=n=>{let e=D(w,n);if(!Array.isArray(e))return e;let s={},o=S;for(let a=0;a<e.length;a++){let r=e[a];if(typeof r=="string")s.base=o(s.base,r)(m);else if(typeof r=="object")for(let c in r)s[c]=o(s[c],r[c])(m);}return s},et=n=>{if(A.length<1)return null;let e={},s=z(null,n);for(let o=0;o<A.length;o++){let{slots:a=[],class:r,className:c,...f}=A[o];if(!b(f)){let p=true;for(let i in f){let v=s[i],h=f[i];if(v===void 0||(Array.isArray(h)?!h.includes(v):h!==v)){p=false;break}}if(!p)continue}for(let p=0;p<a.length;p++){let i=a[p];e[i]||(e[i]=[]),e[i].push([r,c]);}}return e};if(!b(d)||!j){let n={};if(typeof N=="object"&&!b(N)){let e=S;for(let s in N)n[s]=o=>{let a=tt(o),r=et(o);return e(N[s],K(s,o),a?a[s]:void 0,r?r[s]:void 0,o?.class,o?.className)(m)};}return n}return S(M,_(),D(w),b$1?.class,b$1?.className)(m)},Y=()=>{if(!(!y||typeof y!="object"))return Object.keys(y)};return V.variantKeys=Y(),V.extend=t,V.base=M,V.slots=N,V.variants=y,V.defaultVariants=T,V.compoundSlots=A,V.compoundVariants=w,V},it=l=>(u,t)=>rt(u,t?g(l,t):l);export{S as cn,x as cnBase,it as createTV,st as defaultConfig,rt as tv};
package/dist/utils.cjs CHANGED
@@ -1,38 +1 @@
1
- 'use strict';
2
-
3
- var chunkL4Q3BGWH_cjs = require('./chunk-L4Q3BGWH.cjs');
4
-
5
-
6
-
7
- Object.defineProperty(exports, "falsyToString", {
8
- enumerable: true,
9
- get: function () { return chunkL4Q3BGWH_cjs.falsyToString; }
10
- });
11
- Object.defineProperty(exports, "flatArray", {
12
- enumerable: true,
13
- get: function () { return chunkL4Q3BGWH_cjs.flatArray; }
14
- });
15
- Object.defineProperty(exports, "flatMergeArrays", {
16
- enumerable: true,
17
- get: function () { return chunkL4Q3BGWH_cjs.flatMergeArrays; }
18
- });
19
- Object.defineProperty(exports, "isBoolean", {
20
- enumerable: true,
21
- get: function () { return chunkL4Q3BGWH_cjs.isBoolean; }
22
- });
23
- Object.defineProperty(exports, "isEmptyObject", {
24
- enumerable: true,
25
- get: function () { return chunkL4Q3BGWH_cjs.isEmptyObject; }
26
- });
27
- Object.defineProperty(exports, "isEqual", {
28
- enumerable: true,
29
- get: function () { return chunkL4Q3BGWH_cjs.isEqual; }
30
- });
31
- Object.defineProperty(exports, "mergeObjects", {
32
- enumerable: true,
33
- get: function () { return chunkL4Q3BGWH_cjs.mergeObjects; }
34
- });
35
- Object.defineProperty(exports, "removeExtraSpaces", {
36
- enumerable: true,
37
- get: function () { return chunkL4Q3BGWH_cjs.removeExtraSpaces; }
38
- });
1
+ 'use strict';var chunk7H22QZCA_cjs=require('./chunk-7H22QZCA.cjs');Object.defineProperty(exports,"falsyToString",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.a}});Object.defineProperty(exports,"flatArray",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.e}});Object.defineProperty(exports,"flatMergeArrays",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.f}});Object.defineProperty(exports,"isBoolean",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.d}});Object.defineProperty(exports,"isEmptyObject",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.b}});Object.defineProperty(exports,"isEqual",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.c}});Object.defineProperty(exports,"mergeObjects",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.g}});Object.defineProperty(exports,"removeExtraSpaces",{enumerable:true,get:function(){return chunk7H22QZCA_cjs.h}});
package/dist/utils.js CHANGED
@@ -1 +1 @@
1
- export { falsyToString, flatArray, flatMergeArrays, isBoolean, isEmptyObject, isEqual, mergeObjects, removeExtraSpaces } from './chunk-YWS777Q5.js';
1
+ export{a as falsyToString,e as flatArray,f as flatMergeArrays,d as isBoolean,b as isEmptyObject,c as isEqual,g as mergeObjects,h as removeExtraSpaces}from'./chunk-LK3VBVBE.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwind-variants",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "🦄 Tailwindcss first-class variant API",
5
5
  "author": "Junior Garcia <jrgarciadev@gmail.com>",
6
6
  "license": "MIT",
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- var chunkL4Q3BGWH_cjs = require('./chunk-L4Q3BGWH.cjs');
4
- var tailwindMerge = require('tailwind-merge');
5
-
6
- var createTwMerge = (cachedTwMergeConfig) => {
7
- return chunkL4Q3BGWH_cjs.isEmptyObject(cachedTwMergeConfig) ? tailwindMerge.twMerge : tailwindMerge.extendTailwindMerge({
8
- ...cachedTwMergeConfig,
9
- extend: {
10
- theme: cachedTwMergeConfig.theme,
11
- classGroups: cachedTwMergeConfig.classGroups,
12
- conflictingClassGroupModifiers: cachedTwMergeConfig.conflictingClassGroupModifiers,
13
- conflictingClassGroups: cachedTwMergeConfig.conflictingClassGroups,
14
- ...cachedTwMergeConfig.extend
15
- }
16
- });
17
- };
18
-
19
- exports.createTwMerge = createTwMerge;
@@ -1,17 +0,0 @@
1
- import { isEmptyObject } from './chunk-YWS777Q5.js';
2
- import { twMerge, extendTailwindMerge } from 'tailwind-merge';
3
-
4
- var createTwMerge = (cachedTwMergeConfig) => {
5
- return isEmptyObject(cachedTwMergeConfig) ? twMerge : extendTailwindMerge({
6
- ...cachedTwMergeConfig,
7
- extend: {
8
- theme: cachedTwMergeConfig.theme,
9
- classGroups: cachedTwMergeConfig.classGroups,
10
- conflictingClassGroupModifiers: cachedTwMergeConfig.conflictingClassGroupModifiers,
11
- conflictingClassGroups: cachedTwMergeConfig.conflictingClassGroups,
12
- ...cachedTwMergeConfig.extend
13
- }
14
- });
15
- };
16
-
17
- export { createTwMerge };
@@ -1,82 +0,0 @@
1
- 'use strict';
2
-
3
- // src/utils.js
4
- var falsyToString = (value) => value === false ? "false" : value === true ? "true" : value === 0 ? "0" : value;
5
- var isEmptyObject = (obj) => {
6
- if (!obj || typeof obj !== "object") return true;
7
- for (const _ in obj) return false;
8
- return true;
9
- };
10
- var isEqual = (obj1, obj2) => {
11
- if (obj1 === obj2) return true;
12
- if (!obj1 || !obj2) return false;
13
- const keys1 = Object.keys(obj1);
14
- const keys2 = Object.keys(obj2);
15
- if (keys1.length !== keys2.length) return false;
16
- for (let i = 0; i < keys1.length; i++) {
17
- const key = keys1[i];
18
- if (!keys2.includes(key)) return false;
19
- if (obj1[key] !== obj2[key]) return false;
20
- }
21
- return true;
22
- };
23
- var isBoolean = (value) => value === true || value === false;
24
- function flat(arr, target) {
25
- for (let i = 0; i < arr.length; i++) {
26
- const el = arr[i];
27
- if (Array.isArray(el)) flat(el, target);
28
- else target.push(el);
29
- }
30
- }
31
- function flatArray(arr) {
32
- const flattened = [];
33
- flat(arr, flattened);
34
- return flattened;
35
- }
36
- var flatMergeArrays = (...arrays) => {
37
- const result = [];
38
- flat(arrays, result);
39
- const filtered = [];
40
- for (let i = 0; i < result.length; i++) {
41
- if (result[i]) filtered.push(result[i]);
42
- }
43
- return filtered;
44
- };
45
- var mergeObjects = (obj1, obj2) => {
46
- const result = {};
47
- for (const key in obj1) {
48
- const val1 = obj1[key];
49
- if (key in obj2) {
50
- const val2 = obj2[key];
51
- if (Array.isArray(val1) || Array.isArray(val2)) {
52
- result[key] = flatMergeArrays(val2, val1);
53
- } else if (typeof val1 === "object" && typeof val2 === "object" && val1 && val2) {
54
- result[key] = mergeObjects(val1, val2);
55
- } else {
56
- result[key] = val2 + " " + val1;
57
- }
58
- } else {
59
- result[key] = val1;
60
- }
61
- }
62
- for (const key in obj2) {
63
- if (!(key in obj1)) {
64
- result[key] = obj2[key];
65
- }
66
- }
67
- return result;
68
- };
69
- var SPACE_REGEX = /\s+/g;
70
- var removeExtraSpaces = (str) => {
71
- if (!str || typeof str !== "string") return str;
72
- return str.replace(SPACE_REGEX, " ").trim();
73
- };
74
-
75
- exports.falsyToString = falsyToString;
76
- exports.flatArray = flatArray;
77
- exports.flatMergeArrays = flatMergeArrays;
78
- exports.isBoolean = isBoolean;
79
- exports.isEmptyObject = isEmptyObject;
80
- exports.isEqual = isEqual;
81
- exports.mergeObjects = mergeObjects;
82
- exports.removeExtraSpaces = removeExtraSpaces;
@@ -1,73 +0,0 @@
1
- // src/utils.js
2
- var falsyToString = (value) => value === false ? "false" : value === true ? "true" : value === 0 ? "0" : value;
3
- var isEmptyObject = (obj) => {
4
- if (!obj || typeof obj !== "object") return true;
5
- for (const _ in obj) return false;
6
- return true;
7
- };
8
- var isEqual = (obj1, obj2) => {
9
- if (obj1 === obj2) return true;
10
- if (!obj1 || !obj2) return false;
11
- const keys1 = Object.keys(obj1);
12
- const keys2 = Object.keys(obj2);
13
- if (keys1.length !== keys2.length) return false;
14
- for (let i = 0; i < keys1.length; i++) {
15
- const key = keys1[i];
16
- if (!keys2.includes(key)) return false;
17
- if (obj1[key] !== obj2[key]) return false;
18
- }
19
- return true;
20
- };
21
- var isBoolean = (value) => value === true || value === false;
22
- function flat(arr, target) {
23
- for (let i = 0; i < arr.length; i++) {
24
- const el = arr[i];
25
- if (Array.isArray(el)) flat(el, target);
26
- else target.push(el);
27
- }
28
- }
29
- function flatArray(arr) {
30
- const flattened = [];
31
- flat(arr, flattened);
32
- return flattened;
33
- }
34
- var flatMergeArrays = (...arrays) => {
35
- const result = [];
36
- flat(arrays, result);
37
- const filtered = [];
38
- for (let i = 0; i < result.length; i++) {
39
- if (result[i]) filtered.push(result[i]);
40
- }
41
- return filtered;
42
- };
43
- var mergeObjects = (obj1, obj2) => {
44
- const result = {};
45
- for (const key in obj1) {
46
- const val1 = obj1[key];
47
- if (key in obj2) {
48
- const val2 = obj2[key];
49
- if (Array.isArray(val1) || Array.isArray(val2)) {
50
- result[key] = flatMergeArrays(val2, val1);
51
- } else if (typeof val1 === "object" && typeof val2 === "object" && val1 && val2) {
52
- result[key] = mergeObjects(val1, val2);
53
- } else {
54
- result[key] = val2 + " " + val1;
55
- }
56
- } else {
57
- result[key] = val1;
58
- }
59
- }
60
- for (const key in obj2) {
61
- if (!(key in obj1)) {
62
- result[key] = obj2[key];
63
- }
64
- }
65
- return result;
66
- };
67
- var SPACE_REGEX = /\s+/g;
68
- var removeExtraSpaces = (str) => {
69
- if (!str || typeof str !== "string") return str;
70
- return str.replace(SPACE_REGEX, " ").trim();
71
- };
72
-
73
- export { falsyToString, flatArray, flatMergeArrays, isBoolean, isEmptyObject, isEqual, mergeObjects, removeExtraSpaces };