tailwind-variants 0.1.12 → 0.1.14
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/dist/chunk-FHRYMRZ3.js +3 -0
- package/dist/index.cjs +6 -6
- package/dist/index.d.ts +15 -10
- package/dist/index.js +3 -3
- package/dist/utils.cjs +6 -6
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-ZPYG7BIQ.js +0 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var a=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,l=t=>!t||typeof t!="object"||Object.keys(t).length===0,u=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function i(t,e){t.forEach(function(n){Array.isArray(n)?i(n,e):e.push(n);});}function y(t){let e=[];return i(t,e),e}var x=(...t)=>y(t).filter(Boolean),p=(t,e)=>{let n={},c=Object.keys(t),f=Object.keys(e);for(let o of c)if(f.includes(o)){let r=t[o],s=e[o];typeof r=="object"&&typeof s=="object"?n[o]=p(r,s):n[o]=s+" "+r;}else n[o]=t[o];for(let o of f)c.includes(o)||(n[o]=e[o]);return n},g=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();
|
|
2
|
+
|
|
3
|
+
export { a, l as b, u as c, y as d, x as e, p as f, g };
|
package/dist/index.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var tailwindMerge = require('tailwind-merge');
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var B=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,y=e=>!e||typeof e!="object"||Object.keys(e).length===0,L=(e,l)=>JSON.stringify(e)===JSON.stringify(l);function Q(e,l){e.forEach(function(t){Array.isArray(t)?Q(t,l):l.push(t);});}function q(e){let l=[];return Q(e,l),l}var X=(...e)=>q(e).filter(Boolean),x=(e,l)=>{let t={},A=Object.keys(e),O=Object.keys(l);for(let u of A)if(O.includes(u)){let V=e[u],h=l[u];typeof V=="object"&&typeof h=="object"?t[u]=x(V,h):t[u]=h+" "+V;}else t[u]=e[u];for(let u of O)A.includes(u)||(t[u]=l[u]);return t},J=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var se={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=e=>e||void 0,k=(...e)=>Z(q(e).filter(Boolean).join(" ")),R=null,S={},F=!1,j=(...e)=>l=>l.twMerge?((!R||F)&&(F=!1,R=y(S)?tailwindMerge.twMerge:tailwindMerge.extendTailwindMerge(S)),Z(R(k(e)))):k(e),Y=(e,l)=>{for(let t in l)e.hasOwnProperty(t)?e[t]=k(e[t],l[t]):e[t]=l[t];return e},fe=(e,l)=>{let{extend:t=null,slots:A={},variants:O={},compoundVariants:u=[],compoundSlots:V=[],defaultVariants:h={}}=e,b={...se,...l},M=t!=null&&t.base?k(t.base,e==null?void 0:e.base):e==null?void 0:e.base,d=t!=null&&t.variants&&!y(t.variants)?x(O,t.variants):O,w=t!=null&&t.defaultVariants&&!y(t.defaultVariants)?{...t.defaultVariants,...h}:h;!y(b.twMergeConfig)&&!L(b.twMergeConfig,S)&&(F=!0,S=b.twMergeConfig);let $=y(A)?{}:{base:e==null?void 0:e.base,...A},N=y(t==null?void 0:t.slots)?$:Y(t==null?void 0:t.slots,y($)?{base:e==null?void 0:e.base}:$),C=o=>{if(y(d)&&y(A)&&y(t==null?void 0:t.slots))return j(M,o==null?void 0:o.class,o==null?void 0:o.className)(b);if(u&&!Array.isArray(u))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof u}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let p=(n,r,a=[],c)=>{let s=a;if(typeof r=="string")s=s.concat(J(r).split(" ").map(f=>`${n}:${f}`));else if(Array.isArray(r))s=s.concat(r.reduce((f,i)=>f.concat(`${n}:${i}`),[]));else if(typeof r=="object"&&typeof c=="string"){for(let f in r)if(r.hasOwnProperty(f)&&f===c){let i=r[f];if(i&&typeof i=="string"){let m=J(i);s[c]?s[c]=s[c].concat(m.split(" ").map(g=>`${n}:${g}`)):s[c]=m.split(" ").map(g=>`${n}:${g}`);}else Array.isArray(i)&&i.length>0&&(s[c]=i.reduce((m,g)=>m.concat(`${n}:${g}`),[]));}}return s},U=(n,r=d,a=null,c=null)=>{var H;let s=r[n];if(!s||y(s))return null;let f=(H=c==null?void 0:c[n])!=null?H:o==null?void 0:o[n];if(f===null)return null;let i=B(f),m=Array.isArray(b.responsiveVariants)&&b.responsiveVariants.length>0||b.responsiveVariants===!0,g=w==null?void 0:w[n],v=[];if(typeof i=="object"&&m)for(let[T,I]of Object.entries(i)){let ne=s[I];if(T==="initial"){g=I;continue}Array.isArray(b.responsiveVariants)&&!b.responsiveVariants.includes(T)||(v=p(T,ne,v,a));}let E=s[i]||s[B(g)];return typeof v=="object"&&typeof a=="string"&&v[a]?Y(v,E):v.length>0?(v.push(E),v):E},K=()=>d?Object.keys(d).map(n=>U(n,d)):null,P=(n,r)=>{if(!d||typeof d!="object")return null;let a=new Array;for(let c in d){let s=U(c,d,n,r),f=n==="base"&&typeof s=="string"?s:s&&s[n];f&&(a[a.length]=f);}return a},W={};for(let n in o)o[n]!==void 0&&(W[n]=o[n]);let z=(n,r)=>{var c;let a=typeof(o==null?void 0:o[n])=="object"?{[n]:(c=o[n])==null?void 0:c.initial}:{};return {...w,...W,...a,...r}},D=(n=[],r)=>{let a=[];for(let{class:c,className:s,...f}of n){let i=!0;for(let[m,g]of Object.entries(f)){let v=z(m,r);if(Array.isArray(g)){if(!g.includes(v[m])){i=!1;break}}else if(v[m]!==g){i=!1;break}}i&&(c&&a.push(c),s&&a.push(s));}return a},G=n=>{let r=D(u,n),a=D(t==null?void 0:t.compoundVariants,n);return X(a,r)},ee=n=>{let r=G(n);if(!Array.isArray(r))return r;let a={};for(let c of r)if(typeof c=="string"&&(a.base=j(a.base,c)(b)),typeof c=="object")for(let[s,f]of Object.entries(c))a[s]=j(a[s],f)(b);return a},te=n=>{if(V.length<1)return null;let r={};for(let{slots:a=[],class:c,className:s,...f}of V){if(!y(f)){let i=!0;for(let m of Object.keys(f)){let g=z(m,n)[m];if(g===void 0||g!==f[m]){i=!1;break}}if(!i)continue}for(let i of a)r[i]=r[i]||[],r[i].push([c,s]);}return r};if(!y(A)||!y(t==null?void 0:t.slots)){let n={};if(typeof N=="object"&&!y(N))for(let r of Object.keys(N))n[r]=a=>{var c,s;return j(N[r],P(r,a),((c=ee(a))!=null?c:[])[r],((s=te(a))!=null?s:[])[r],a==null?void 0:a.class,a==null?void 0:a.className)(b)};return n}return j(M,K(),G(),o==null?void 0:o.class,o==null?void 0:o.className)(b)},_=()=>{if(!(!d||typeof d!="object"))return Object.keys(d)};return C.variantKeys=_(),C.extend=t,C.base=M,C.slots=N,C.variants=d,C.defaultVariants=w,C.compoundSlots=V,C.compoundVariants=u,C};
|
|
6
6
|
|
|
7
|
-
exports.cn =
|
|
8
|
-
exports.cnBase =
|
|
9
|
-
exports.defaultConfig =
|
|
10
|
-
exports.tv =
|
|
11
|
-
exports.voidEmpty =
|
|
7
|
+
exports.cn = j;
|
|
8
|
+
exports.cnBase = k;
|
|
9
|
+
exports.defaultConfig = se;
|
|
10
|
+
exports.tv = fe;
|
|
11
|
+
exports.voidEmpty = Z;
|
package/dist/index.d.ts
CHANGED
|
@@ -180,7 +180,10 @@ export type TVReturnProps<
|
|
|
180
180
|
B extends ClassValue,
|
|
181
181
|
EV extends TVVariants<ES>,
|
|
182
182
|
ES extends TVSlots,
|
|
183
|
+
// @ts-expect-error
|
|
184
|
+
E extends TVReturnType = undefined,
|
|
183
185
|
> = {
|
|
186
|
+
extend: E;
|
|
184
187
|
base: B;
|
|
185
188
|
slots: S;
|
|
186
189
|
variants: V;
|
|
@@ -197,13 +200,15 @@ export type TVReturnType<
|
|
|
197
200
|
C extends TVConfig<V, EV>,
|
|
198
201
|
EV extends TVVariants<ES>,
|
|
199
202
|
ES extends TVSlots,
|
|
203
|
+
// @ts-expect-error
|
|
204
|
+
E extends TVReturnType = undefined,
|
|
200
205
|
> = {
|
|
201
206
|
(props?: TVProps<V, S, C, EV, ES>): ES extends undefined
|
|
202
207
|
? S extends undefined
|
|
203
208
|
? string
|
|
204
|
-
: {[K in TVSlotsWithBase<S, B>]: (slotProps?:
|
|
205
|
-
: {[K in TVSlotsWithBase<ES & S, B>]: (slotProps?:
|
|
206
|
-
} & TVReturnProps<V, S, B, EV, ES>;
|
|
209
|
+
: {[K in TVSlotsWithBase<S, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string}
|
|
210
|
+
: {[K in TVSlotsWithBase<ES & S, B>]: (slotProps?: TVProps<V, S, C, EV, ES>) => string};
|
|
211
|
+
} & TVReturnProps<V, S, B, EV, ES, E>;
|
|
207
212
|
|
|
208
213
|
export type TV = {
|
|
209
214
|
<
|
|
@@ -229,7 +234,7 @@ export type TV = {
|
|
|
229
234
|
>(
|
|
230
235
|
options: {
|
|
231
236
|
/**
|
|
232
|
-
* Extend allows
|
|
237
|
+
* Extend allows for easy composition of components.
|
|
233
238
|
* @see https://www.tailwind-variants.org/docs/composing-components
|
|
234
239
|
*/
|
|
235
240
|
extend?: E;
|
|
@@ -238,22 +243,22 @@ export type TV = {
|
|
|
238
243
|
*/
|
|
239
244
|
base?: B;
|
|
240
245
|
/**
|
|
241
|
-
* Slots
|
|
246
|
+
* Slots allow you to separate a component into multiple parts.
|
|
242
247
|
* @see https://www.tailwind-variants.org/docs/slots
|
|
243
248
|
*/
|
|
244
249
|
slots?: S;
|
|
245
250
|
/**
|
|
246
|
-
* Variants
|
|
251
|
+
* Variants allow you to create multiple versions of the same component.
|
|
247
252
|
* @see https://www.tailwind-variants.org/docs/variants#adding-variants
|
|
248
253
|
*/
|
|
249
254
|
variants?: V;
|
|
250
255
|
/**
|
|
251
|
-
* Compound variants allow apply classes to multiple variants at once.
|
|
256
|
+
* Compound variants allow you to apply classes to multiple variants at once.
|
|
252
257
|
* @see https://www.tailwind-variants.org/docs/variants#compound-variants
|
|
253
258
|
*/
|
|
254
259
|
compoundVariants?: CV;
|
|
255
260
|
/**
|
|
256
|
-
* Compound slots allow apply classes to multiple slots at once.
|
|
261
|
+
* Compound slots allow you to apply classes to multiple slots at once.
|
|
257
262
|
*/
|
|
258
263
|
compoundSlots?: TVCompoundSlots<V, S, B>;
|
|
259
264
|
/**
|
|
@@ -263,11 +268,11 @@ export type TV = {
|
|
|
263
268
|
defaultVariants?: DV;
|
|
264
269
|
},
|
|
265
270
|
/**
|
|
266
|
-
* The config object to modify the default configuration.
|
|
271
|
+
* The config object allows you to modify the default configuration.
|
|
267
272
|
* @see https://www.tailwind-variants.org/docs/api-reference#config-optional
|
|
268
273
|
*/
|
|
269
274
|
config?: C,
|
|
270
|
-
): TVReturnType<V, S, B, C, EV, ES>;
|
|
275
|
+
): TVReturnType<V, S, B, C, EV, ES, E>;
|
|
271
276
|
};
|
|
272
277
|
|
|
273
278
|
// main function
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { d, b, f, c, e, a, g } from './chunk-
|
|
1
|
+
import { d, b, f, c, e, a, g } from './chunk-FHRYMRZ3.js';
|
|
2
2
|
import { twMerge, extendTailwindMerge } from 'tailwind-merge';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var re={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=i=>i||void 0,j=(...i)=>Z(d(i).filter(Boolean).join(" ")),B=null,O={},R=!1,A=(...i)=>v=>v.twMerge?((!B||R)&&(R=!1,B=b(O)?twMerge:extendTailwindMerge(O)),Z(B(j(i)))):j(i),Y=(i,v)=>{for(let e in v)i.hasOwnProperty(e)?i[e]=j(i[e],v[e]):i[e]=v[e];return i},ce=(i,v)=>{let{extend:e$1=null,slots:N={},variants:q={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:F={}}=i,m={...re,...v},M=e$1!=null&&e$1.base?j(e$1.base,i==null?void 0:i.base):i==null?void 0:i.base,g$1=e$1!=null&&e$1.variants&&!b(e$1.variants)?f(q,e$1.variants):q,h=e$1!=null&&e$1.defaultVariants&&!b(e$1.defaultVariants)?{...e$1.defaultVariants,...F}:F;!b(m.twMergeConfig)&&!c(m.twMergeConfig,O)&&(R=!0,O=m.twMergeConfig);let $=b(N)?{}:{base:i==null?void 0:i.base,...N},w=b(e$1==null?void 0:e$1.slots)?$:Y(e$1==null?void 0:e$1.slots,b($)?{base:i==null?void 0:i.base}:$),d=f=>{if(b(g$1)&&b(N)&&b(e$1==null?void 0:e$1.slots))return A(M,f==null?void 0:f.class,f==null?void 0:f.className)(m);if(C&&!Array.isArray(C))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof C}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let K=(t,n,a=[],s)=>{let r=a;if(typeof n=="string")r=r.concat(g(n).split(" ").map(l=>`${t}:${l}`));else if(Array.isArray(n))r=r.concat(n.reduce((l,c)=>l.concat(`${t}:${c}`),[]));else if(typeof n=="object"&&typeof s=="string"){for(let l in n)if(n.hasOwnProperty(l)&&l===s){let c=n[l];if(c&&typeof c=="string"){let y=g(c);r[s]?r[s]=r[s].concat(y.split(" ").map(u=>`${t}:${u}`)):r[s]=y.split(" ").map(u=>`${t}:${u}`);}else Array.isArray(c)&&c.length>0&&(r[s]=c.reduce((y,u)=>y.concat(`${t}:${u}`),[]));}}return r},U=(t,n=g$1,a$1=null,s=null)=>{var H;let r=n[t];if(!r||b(r))return null;let l=(H=s==null?void 0:s[t])!=null?H:f==null?void 0:f[t];if(l===null)return null;let c=a(l),y=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,u=h==null?void 0:h[t],b$1=[];if(typeof c=="object"&&y)for(let[k,I]of Object.entries(c)){let te=r[I];if(k==="initial"){u=I;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(k)||(b$1=K(k,te,b$1,a$1));}let S=r[c]||r[a(u)];return typeof b$1=="object"&&typeof a$1=="string"&&b$1[a$1]?Y(b$1,S):b$1.length>0?(b$1.push(S),b$1):S},x=()=>g$1?Object.keys(g$1).map(t=>U(t,g$1)):null,P=(t,n)=>{if(!g$1||typeof g$1!="object")return null;let a=new Array;for(let s in g$1){let r=U(s,g$1,t,n),l=t==="base"&&typeof r=="string"?r:r&&r[t];l&&(a[a.length]=l);}return a},W={};for(let t in f)f[t]!==void 0&&(W[t]=f[t]);let z=(t,n)=>{var s;let a=typeof(f==null?void 0:f[t])=="object"?{[t]:(s=f[t])==null?void 0:s.initial}:{};return {...h,...W,...a,...n}},D=(t=[],n)=>{let a=[];for(let{class:s,className:r,...l}of t){let c=!0;for(let[y,u]of Object.entries(l)){let b=z(y,n);if(Array.isArray(u)){if(!u.includes(b[y])){c=!1;break}}else if(b[y]!==u){c=!1;break}}c&&(s&&a.push(s),r&&a.push(r));}return a},G=t=>{let n=D(C,t),a=D(e$1==null?void 0:e$1.compoundVariants,t);return e(a,n)},p=t=>{let n=G(t);if(!Array.isArray(n))return n;let a={};for(let s of n)if(typeof s=="string"&&(a.base=A(a.base,s)(m)),typeof s=="object")for(let[r,l]of Object.entries(s))a[r]=A(a[r],l)(m);return a},ee=t=>{if(V.length<1)return null;let n={};for(let{slots:a=[],class:s,className:r,...l}of V){if(!b(l)){let c=!0;for(let y of Object.keys(l)){let u=z(y,t)[y];if(u===void 0||u!==l[y]){c=!1;break}}if(!c)continue}for(let c of a)n[c]=n[c]||[],n[c].push([s,r]);}return n};if(!b(N)||!b(e$1==null?void 0:e$1.slots)){let t={};if(typeof w=="object"&&!b(w))for(let n of Object.keys(w))t[n]=a=>{var s,r;return A(w[n],P(n,a),((s=p(a))!=null?s:[])[n],((r=ee(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return A(M,x(),G(),f==null?void 0:f.class,f==null?void 0:f.className)(m)},_=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return d.variantKeys=_(),d.extend=e$1,d.base=M,d.slots=w,d.variants=g$1,d.defaultVariants=h,d.compoundSlots=V,d.compoundVariants=C,d};
|
|
5
5
|
|
|
6
|
-
export {
|
|
6
|
+
export { A as cn, j as cnBase, re as defaultConfig, ce as tv, Z as voidEmpty };
|
package/dist/utils.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var a=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,l=t=>!t||typeof t!="object"||Object.keys(t).length===0,u=(t,e)=>JSON.stringify(t)===JSON.stringify(e);function i(t,e){t.forEach(function(n){Array.isArray(n)?i(n,e):e.push(n);});}function y(t){let e=[];return i(t,e),e}var x=(...t)=>y(t).filter(Boolean),p=(t,e)=>{let n={},c=Object.keys(t),f=Object.keys(e);for(let o of c)if(f.includes(o)){let r=t[o],s=e[o];typeof r=="object"&&typeof s=="object"?n[o]=p(r,s):n[o]=s+" "+r;}else n[o]=t[o];for(let o of f)c.includes(o)||(n[o]=e[o]);return n},g=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();
|
|
4
4
|
|
|
5
|
-
exports.falsyToString =
|
|
6
|
-
exports.flatArray =
|
|
7
|
-
exports.flatMergeArrays =
|
|
5
|
+
exports.falsyToString = a;
|
|
6
|
+
exports.flatArray = y;
|
|
7
|
+
exports.flatMergeArrays = x;
|
|
8
8
|
exports.isEmptyObject = l;
|
|
9
|
-
exports.isEqual =
|
|
9
|
+
exports.isEqual = u;
|
|
10
10
|
exports.mergeObjects = p;
|
|
11
|
-
exports.removeExtraSpaces =
|
|
11
|
+
exports.removeExtraSpaces = g;
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { a as falsyToString, d as flatArray, e as flatMergeArrays, b as isEmptyObject, c as isEqual, f as mergeObjects, g as removeExtraSpaces } from './chunk-
|
|
1
|
+
export { a as falsyToString, d as flatArray, e as flatMergeArrays, b as isEmptyObject, c as isEqual, f as mergeObjects, g as removeExtraSpaces } from './chunk-FHRYMRZ3.js';
|
package/package.json
CHANGED
package/dist/chunk-ZPYG7BIQ.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
var i=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,l=e=>!e||typeof e!="object"||Object.keys(e).length===0,o=(e,r)=>JSON.stringify(e)===JSON.stringify(r),n=e=>{let r=[],s=[...e];for(;s.length;){let t=s.pop();Array.isArray(t)?s.push(...t):r.push(t);}return r.reverse()},y=(...e)=>n(e).filter(Boolean),p=(e,r)=>{let s={};for(let t in e)r!=null&&r.hasOwnProperty(t)?s[t]=typeof e[t]=="object"?p(e[t],r[t]):r[t]+" "+e[t]:s[t]=e[t];for(let t in r)s.hasOwnProperty(t)||(s[t]=r[t]);return s},f=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();
|
|
2
|
-
|
|
3
|
-
export { i as a, l as b, o as c, n as d, y as e, p as f, f as g };
|