tailwind-variants
Advanced tools
Comparing version 0.0.17-dev.1 to 0.0.17
@@ -42,6 +42,12 @@ import {TVConfig} from "./config"; | ||
export type TVProps<V extends TVVariants<S>, S extends TVSlots> = { | ||
[K in keyof V]?: StringToBoolean<keyof V[K]> | TVScreenPropsValue<V, K>; | ||
} & ClassProp<ClassValue>; | ||
export type TVProps<V extends TVVariants<S>, S extends TVSlots> = V extends undefined | ||
? ClassProp<ClassValue> | ||
: { | ||
[K in keyof V]?: StringToBoolean<keyof V[K]> | TVScreenPropsValue<V, K>; | ||
} & ClassProp<ClassValue>; | ||
export type TVVariantKeys<V extends TVVariants<S>, S extends TVSlots> = V extends Object | ||
? Array<keyof V> | ||
: undefined; | ||
export type TVReturnType<V extends TVVariants<S>, S extends TVSlots, B extends ClassValue> = { | ||
@@ -51,9 +57,9 @@ (props?: TVProps<V, S>): S extends undefined | ||
: {[K in TVSlotsWithBase<S, B>]: (slotProps?: ClassProp) => string}; | ||
}; | ||
} & Record<"variantkeys", TVVariantKeys<V, S>>; | ||
export type TV = { | ||
< | ||
V extends TVVariants<S> = {}, | ||
CV extends TVCompoundVariants<V, S, B> = [], | ||
DV extends TVDefaultVariants<V, S> = {}, | ||
V extends TVVariants<S> = undefined, | ||
CV extends TVCompoundVariants<V, S, B> = undefined, | ||
DV extends TVDefaultVariants<V, S> = undefined, | ||
C extends TVConfig, | ||
@@ -60,0 +66,0 @@ B extends ClassValue = undefined, |
@@ -1,6 +0,5 @@ | ||
import C from 'fs'; | ||
import { extendTailwindMerge, twMerge } from 'tailwind-merge'; | ||
var M=(...e)=>e.flat(1/0).filter(Boolean).join(" "),O=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,b=e=>e&&Object.keys(e).length>0,y=(...e)=>(c={})=>c.twMerge?(b(c.twMergeConfig)?extendTailwindMerge(c.twMergeConfig):twMerge)(M(e)):M(e),B=(e,c)=>{let t={};return typeof e!="object"||typeof c!="object"||Object.keys(e).forEach(u=>{c[u]?t[u]=M([e[u],c[u]]):t[u]=e[u];}),t},A=e=>!e||typeof e!="string"?e:e.replace(/\s+/g," ").trim();var Z=(e,c={twMerge:!0,twMergeConfig:{}})=>t=>{var v;let{slots:u={},variants:g={},compoundVariants:m=[],defaultVariants:j={}}=e;if(g==null&&!b(u))return y(e==null?void 0:e.base,t==null?void 0:t.class,t==null?void 0:t.className)(c);if(m&&!Array.isArray(m))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof m}`);let x={base:e==null?void 0:e.base,...u},F=(r,n,i=[],s)=>{let a=i;if(typeof n=="string")a.push(A(n).split(" ").map(l=>`${r}:${l}`));else if(Array.isArray(n))a.push(n.flatMap(l=>`${r}:${l}`));else if(typeof n=="object"&&typeof s=="string"){let l=n==null?void 0:n[s];if(l&&typeof l=="string"){let f=A(l);a[s]=a[s]?[...a[s],...f.split(" ").map(o=>`${r}:${o}`)]:f.split(" ").map(o=>`${r}:${o}`);}else Array.isArray(l)&&l.length>0&&(a[s]=l.flatMap(f=>`${r}:${f}`));}return a},N=(r,n=null)=>{let i=g==null?void 0:g[r];if(typeof i!="object"||!b(i))return null;let s=t==null?void 0:t[r],a=j==null?void 0:j[r],l=[];if(s===null)return null;let f=O(s);if(typeof f=="object"&&(l=Object.keys(f).reduce((d,h)=>{let w=f[h],$=i==null?void 0:i[w];return h==="initial"?(a=w,d):F(h,$,d,n)},[]),l.length>0&&typeof C=="object")){let d=`// ${l}`,$=`./dist/generated/${`${d.substring(0,30).replace(/[^a-zA-Z0-9]/g,"")}-${r}.js`}`;C.existsSync("./dist/generated")||C.mkdirSync("./dist/generated"),C.writeFile($,d,function(E){E?console.error(E):console.log(`File created at ${$}`);});}let o=i[f]||i[O(a)];return typeof l=="object"&&typeof n=="string"&&l[n]?B(l,o):l.length>0?[o,...l]:o},T=g?Object.keys(g).map(N):null,z=r=>!g||typeof g!="object"?null:Object.keys(g).map(n=>{let i=N(n,r);return r==="base"&&typeof i=="string"?i:i&&i[r]}).filter(Boolean),I=t&&Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0)),S=m==null?void 0:m.filter(({class:r,className:n,...i})=>Object.entries(i).every(([s,a])=>{var o;let l=typeof(t==null?void 0:t[s])=="object"?(o=t[s])==null?void 0:o.initial:{},f={...j,...l,...I};return Array.isArray(a)?a.includes(f[s]):f[s]===a})).flatMap(({class:r,className:n})=>[r,n]),R=()=>{let r=S;return Array.isArray(r)?r.reduce((n,i)=>(typeof i=="string"&&(n.base=y(n.base,i)(c)),typeof i=="object"&&Object.entries(i).forEach(([s,a])=>{n[s]=y(n[s],a)(c);}),n),{}):r};if(b(u)){let r=(v=R())!=null?v:[];return {...typeof x=="object"&&b(x)?Object.keys(x).reduce((i,s)=>(i[s]=a=>y(x[s],z(s),r==null?void 0:r[s],a==null?void 0:a.class,a==null?void 0:a.className)(c),i),{}):{}}}return y(e==null?void 0:e.base,T,S,t==null?void 0:t.class,t==null?void 0:t.className)(c)},q=Z({base:"font-semibold text-white py-1 px-3 rounded-full active:opacity-80",variants:{color:{primary:"bg-blue-500 hover:bg-blue-700",secondary:"bg-purple-500 hover:bg-purple-700",success:"bg-green-500 hover:bg-green-700"},size:{small:"py-1 px-2 text-xs",medium:"bg-blue-500 hover:bg-blue-700",large:"py-1.5 px-3 text-md"}}}),D=q({color:{initial:"primary",sm:"success",md:"secondary"},size:{initial:"small",sm:"medium",md:"large"}});console.log(D); | ||
var O=(...t)=>t.flat(1/0).filter(Boolean).join(" "),M=t=>typeof t=="boolean"?`${t}`:t===0?"0":t,m=t=>t&&Object.keys(t).length>0,j=(...t)=>(l={})=>l.twMerge?(m(l.twMergeConfig)?extendTailwindMerge(l.twMergeConfig):twMerge)(O(t)):O(t),S=(t,l)=>{let b={};return typeof t!="object"||typeof l!="object"||Object.keys(t).forEach(c=>{l[c]?b[c]=O([t[c],l[c]]):b[c]=t[c];}),b},w=t=>!t||typeof t!="string"?t:t.replace(/\s+/g," ").trim();var G=(t,l={twMerge:!0,twMergeConfig:{}})=>{let{slots:b={},variants:c={},compoundVariants:g=[],defaultVariants:o={}}=t,$=i=>{var A;if(c==null&&!m(b))return j(t==null?void 0:t.base,i==null?void 0:i.class,i==null?void 0:i.className)(l);if(g&&!Array.isArray(g))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof g}`);let d={base:t==null?void 0:t.base,...b},T=(e,r,n=[],f)=>{let a=n;if(typeof r=="string")a.push(w(r).split(" ").map(u=>`${e}:${u}`));else if(Array.isArray(r))a.push(r.flatMap(u=>`${e}:${u}`));else if(typeof r=="object"&&typeof f=="string"){let u=r==null?void 0:r[f];if(u&&typeof u=="string"){let s=w(u);a[f]=a[f]?[...a[f],...s.split(" ").map(y=>`${e}:${y}`)]:s.split(" ").map(y=>`${e}:${y}`);}else Array.isArray(u)&&u.length>0&&(a[f]=u.flatMap(s=>`${e}:${s}`));}return a},C=(e,r=null)=>{let n=c==null?void 0:c[e];if(typeof n!="object"||!m(n))return null;let f=i==null?void 0:i[e],a=o==null?void 0:o[e],u=[];if(f===null)return null;let s=M(f);typeof s=="object"&&(u=Object.keys(s).reduce((N,x)=>{let E=s[x],U=n==null?void 0:n[E];return x==="initial"?(a=E,N):T(x,U,N,r)},[]));let y=n[s]||n[M(a)];return typeof u=="object"&&typeof r=="string"&&u[r]?S(u,y):u.length>0?[y,...u]:y},v=c?Object.keys(c).map(C):null,F=e=>!c||typeof c!="object"?null:Object.keys(c).map(r=>{let n=C(r,e);return e==="base"&&typeof n=="string"?n:n&&n[e]}).filter(Boolean),I=i&&Object.fromEntries(Object.entries(i).filter(([,e])=>e!==void 0)),h=g==null?void 0:g.filter(({class:e,className:r,...n})=>Object.entries(n).every(([f,a])=>{var y;let u=typeof(i==null?void 0:i[f])=="object"?(y=i[f])==null?void 0:y.initial:{},s={...o,...u,...I};return Array.isArray(a)?a.includes(s[f]):s[f]===a})).flatMap(({class:e,className:r})=>[e,r]),R=()=>{let e=h;return Array.isArray(e)?e.reduce((r,n)=>(typeof n=="string"&&(r.base=j(r.base,n)(l)),typeof n=="object"&&Object.entries(n).forEach(([f,a])=>{r[f]=j(r[f],a)(l);}),r),{}):e};if(m(b)){let e=(A=R())!=null?A:[];return {...typeof d=="object"&&m(d)?Object.keys(d).reduce((n,f)=>(n[f]=a=>j(d[f],F(f),e==null?void 0:e[f],a==null?void 0:a.class,a==null?void 0:a.className)(l),n),{}):{}}}return j(t==null?void 0:t.base,v,h,i==null?void 0:i.class,i==null?void 0:i.className)(l)},B=()=>{if(!(!c||typeof c!="object"))return Object.keys(c)};return $.variantkeys=B(),$}; | ||
export { Z as tv }; | ||
export { G as tv }; |
{ | ||
"name": "tailwind-variants", | ||
"version": "0.0.17-dev.1", | ||
"version": "0.0.17", | ||
"description": "🦄 Tailwindcss first-class variant API", | ||
@@ -73,4 +73,6 @@ "author": "Junior Garcia <jrgarciadev@gmail.com>", | ||
"classes", | ||
"responsive", | ||
"zero-runtime", | ||
"variants", | ||
"styled.", | ||
"styled", | ||
"styles" | ||
@@ -77,0 +79,0 @@ ], |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
15285
128