Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tailwind-variants

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tailwind-variants - npm Package Compare versions

Comparing version 0.1.20 to 0.2.0

11

dist/config.d.ts

@@ -1,5 +0,8 @@

import type {Config as TwMergeConfig} from "tailwind-merge";
import type {extendTailwindMerge} from "tailwind-merge";
import type {TVVariants} from "./index";
import type {TVGeneratedScreens} from "./generated";
type MergeConfig = Parameters<typeof extendTailwindMerge>[0];
type LegacyMergeConfig = Extract<MergeConfig, {extend?: unknown}>["extend"];
export type TWMConfig = {

@@ -9,3 +12,3 @@ /**

* It's avoid to have duplicate tailwind classes. (Recommended)
* @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/README.md
* @see https://github.com/dcastil/tailwind-merge/blob/v2.2.0/README.md
* @default true

@@ -16,5 +19,5 @@ */

* The config object for `tailwind-merge` library.
* @see https://github.com/dcastil/tailwind-merge/blob/v1.8.1/docs/configuration.md
* @see https://github.com/dcastil/tailwind-merge/blob/v2.2.0/docs/configuration.md
*/
twMergeConfig?: Partial<TwMergeConfig>;
twMergeConfig?: MergeConfig & LegacyMergeConfig;
};

@@ -21,0 +24,0 @@

@@ -15,8 +15,4 @@ import type {ClassNameValue as ClassValue} from "tailwind-merge";

export type ClassProp<V extends unknown = ClassValue> =
| {
class: V;
className?: never;
}
| {class?: never; className: V}
| {class?: never; className?: never};
| {class?: V; className?: never}
| {class?: never; className?: V};

@@ -23,0 +19,0 @@ type TVBaseName = "base";

import { e, b, g, c, f, a, h } from './chunk-JXBJZR5A.js';
import { twMerge, extendTailwindMerge } from 'tailwind-merge';
var se={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},_=s=>s||void 0,N=(...s)=>_(e(s).filter(Boolean).join(" ")),q=null,M={},F=!1,w=(...s)=>b$1=>b$1.twMerge?((!q||F)&&(F=!1,q=b(M)?twMerge:extendTailwindMerge(M)),_(q(N(s)))):N(s),Z=(s,b)=>{for(let e in b)s.hasOwnProperty(e)?s[e]=N(s[e],b[e]):s[e]=b[e];return s},ie=(s,b$1)=>{let{extend:e=null,slots:j={},variants:U={},compoundVariants:C=[],compoundSlots:V=[],defaultVariants:W={}}=s,m={...se,...b$1},S=e!=null&&e.base?N(e.base,s==null?void 0:s.base):s==null?void 0:s.base,g$1=e!=null&&e.variants&&!b(e.variants)?g(U,e.variants):U,A=e!=null&&e.defaultVariants&&!b(e.defaultVariants)?{...e.defaultVariants,...W}:W;!b(m.twMergeConfig)&&!c(m.twMergeConfig,M)&&(F=!0,M=m.twMergeConfig);let O=b(e==null?void 0:e.slots),$=b(j)?{}:{base:N(s==null?void 0:s.base,O&&(e==null?void 0:e.base)),...j},h$1=O?$:Z({...e==null?void 0:e.slots},b($)?{base:s==null?void 0:s.base}:$),v=l=>{if(b(g$1)&&b(j)&&O)return w(S,l==null?void 0:l.class,l==null?void 0:l.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=[],i)=>{let r=a;if(typeof n=="string")r=r.concat(h(n).split(" ").map(c=>`${t}:${c}`));else if(Array.isArray(n))r=r.concat(n.reduce((c,f)=>c.concat(`${t}:${f}`),[]));else if(typeof n=="object"&&typeof i=="string"){for(let c in n)if(n.hasOwnProperty(c)&&c===i){let f=n[c];if(f&&typeof f=="string"){let o=h(f);r[i]?r[i]=r[i].concat(o.split(" ").map(u=>`${t}:${u}`)):r[i]=o.split(" ").map(u=>`${t}:${u}`);}else Array.isArray(f)&&f.length>0&&(r[i]=f.reduce((o,u)=>o.concat(`${t}:${u}`),[]));}}return r},z=(t,n=g$1,a$1=null,i=null)=>{var J;let r=n[t];if(!r||b(r))return null;let c=(J=i==null?void 0:i[t])!=null?J:l==null?void 0:l[t];if(c===null)return null;let f=a(c),o=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,u=A==null?void 0:A[t],d=[];if(typeof f=="object"&&o)for(let[k,L]of Object.entries(f)){let ae=r[L];if(k==="initial"){u=L;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(k)||(d=K(k,ae,d,a$1));}let T=r[f]||r[a(u)];return typeof d=="object"&&typeof a$1=="string"&&d[a$1]?Z(d,T):d.length>0?(d.push(T),d):T},P=()=>g$1?Object.keys(g$1).map(t=>z(t,g$1)):null,p=(t,n)=>{if(!g$1||typeof g$1!="object")return null;let a=new Array;for(let i in g$1){let r=z(i,g$1,t,n),c=t==="base"&&typeof r=="string"?r:r&&r[t];c&&(a[a.length]=c);}return a},D={};for(let t in l)l[t]!==void 0&&(D[t]=l[t]);let G=(t,n)=>{var i;let a=typeof(l==null?void 0:l[t])=="object"?{[t]:(i=l[t])==null?void 0:i.initial}:{};return {...A,...D,...a,...n}},H=(t=[],n)=>{let a=[];for(let{class:i,className:r,...c}of t){let f=!0;for(let[o,u]of Object.entries(c)){let d=G(o,n);if(Array.isArray(u)){if(!u.includes(d[o])){f=!1;break}}else if(d[o]!==u){f=!1;break}}f&&(i&&a.push(i),r&&a.push(r));}return a},I=t=>{let n=H(C,t),a=H(e==null?void 0:e.compoundVariants,t);return f(a,n)},ee=t=>{let n=I(t);if(!Array.isArray(n))return n;let a={};for(let i of n)if(typeof i=="string"&&(a.base=w(a.base,i)(m)),typeof i=="object")for(let[r,c]of Object.entries(i))a[r]=w(a[r],c)(m);return a},te=t=>{if(V.length<1)return null;let n={};for(let{slots:a=[],class:i,className:r,...c}of V){if(!b(c)){let f=!0;for(let o of Object.keys(c)){let u=G(o,t)[o];if(u===void 0||(Array.isArray(c[o])?!c[o].includes(u):c[o]!==u)){f=!1;break}}if(!f)continue}for(let f of a)n[f]=n[f]||[],n[f].push([i,r]);}return n};if(!b(j)||!O){let t={};if(typeof h$1=="object"&&!b(h$1))for(let n of Object.keys(h$1))t[n]=a=>{var i,r;return w(h$1[n],p(n,a),((i=ee(a))!=null?i:[])[n],((r=te(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return w(S,P(),I(),l==null?void 0:l.class,l==null?void 0:l.className)(m)},x=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return v.variantKeys=x(),v.extend=e,v.base=S,v.slots=h$1,v.variants=g$1,v.defaultVariants=A,v.compoundSlots=V,v.compoundVariants=C,v},le=s=>(b,e)=>ie(b,e?g(s,e):s);
var ie={twMerge:!0,twMergeConfig:{},responsiveVariants:!1},Z=s=>s||void 0,N=(...s)=>Z(e(s).filter(Boolean).join(" ")),R=null,C={},q=!1,j=(...s)=>b$1=>b$1.twMerge?((!R||q)&&(q=!1,R=b(C)?twMerge:extendTailwindMerge({...C,extend:{theme:C.theme,classGroups:C.classGroups,conflictingClassGroupModifiers:C.conflictingClassGroupModifiers,conflictingClassGroups:C.conflictingClassGroups,...C.extend}})),Z(R(N(s)))):N(s),Y=(s,b)=>{for(let e in b)s.hasOwnProperty(e)?s[e]=N(s[e],b[e]):s[e]=b[e];return s},ce=(s,b$1)=>{let{extend:e=null,slots:M={},variants:F={},compoundVariants:h$1=[],compoundSlots:V=[],defaultVariants:U={}}=s,m={...ie,...b$1},S=e!=null&&e.base?N(e.base,s==null?void 0:s.base):s==null?void 0:s.base,g$1=e!=null&&e.variants&&!b(e.variants)?g(F,e.variants):F,A=e!=null&&e.defaultVariants&&!b(e.defaultVariants)?{...e.defaultVariants,...U}:U;!b(m.twMergeConfig)&&!c(m.twMergeConfig,C)&&(q=!0,C=m.twMergeConfig);let O=b(e==null?void 0:e.slots),$=b(M)?{}:{base:N(s==null?void 0:s.base,O&&(e==null?void 0:e.base)),...M},w=O?$:Y({...e==null?void 0:e.slots},b($)?{base:s==null?void 0:s.base}:$),v=f$1=>{if(b(g$1)&&b(M)&&O)return j(S,f$1==null?void 0:f$1.class,f$1==null?void 0:f$1.className)(m);if(h$1&&!Array.isArray(h$1))throw new TypeError(`The "compoundVariants" prop must be an array. Received: ${typeof h$1}`);if(V&&!Array.isArray(V))throw new TypeError(`The "compoundSlots" prop must be an array. Received: ${typeof V}`);let K=(t,n,a=[],i)=>{let r=a;if(typeof n=="string")r=r.concat(h(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 i=="string"){for(let l in n)if(n.hasOwnProperty(l)&&l===i){let c=n[l];if(c&&typeof c=="string"){let o=h(c);r[i]?r[i]=r[i].concat(o.split(" ").map(u=>`${t}:${u}`)):r[i]=o.split(" ").map(u=>`${t}:${u}`);}else Array.isArray(c)&&c.length>0&&(r[i]=c.reduce((o,u)=>o.concat(`${t}:${u}`),[]));}}return r},W=(t,n=g$1,a$1=null,i=null)=>{var I;let r=n[t];if(!r||b(r))return null;let l=(I=i==null?void 0:i[t])!=null?I:f$1==null?void 0:f$1[t];if(l===null)return null;let c=a(l),o=Array.isArray(m.responsiveVariants)&&m.responsiveVariants.length>0||m.responsiveVariants===!0,u=A==null?void 0:A[t],d=[];if(typeof c=="object"&&o)for(let[T,J]of Object.entries(c)){let ne=r[J];if(T==="initial"){u=J;continue}Array.isArray(m.responsiveVariants)&&!m.responsiveVariants.includes(T)||(d=K(T,ne,d,a$1));}let ae=c!=null&&typeof c!="object"?c:a(u),k=r[ae]||r.false;return typeof d=="object"&&typeof a$1=="string"&&d[a$1]?Y(d,k):d.length>0?(d.push(k),d):k},P=()=>g$1?Object.keys(g$1).map(t=>W(t,g$1)):null,p=(t,n)=>{if(!g$1||typeof g$1!="object")return null;let a=new Array;for(let i in g$1){let r=W(i,g$1,t,n),l=t==="base"&&typeof r=="string"?r:r&&r[t];l&&(a[a.length]=l);}return a},x={};for(let t in f$1)f$1[t]!==void 0&&(x[t]=f$1[t]);let z=(t,n)=>{var i;let a=typeof(f$1==null?void 0:f$1[t])=="object"?{[t]:(i=f$1[t])==null?void 0:i.initial}:{};return {...A,...x,...a,...n}},D=(t=[],n)=>{let a=[];for(let{class:i,className:r,...l}of t){let c=!0;for(let[o,u]of Object.entries(l)){let d=z(o,n);if(Array.isArray(u)){if(!u.includes(d[o])){c=!1;break}}else if(d[o]!==u){c=!1;break}}c&&(i&&a.push(i),r&&a.push(r));}return a},H=t=>{let n=D(h$1,t),a=D(e==null?void 0:e.compoundVariants,t);return f(a,n)},ee=t=>{let n=H(t);if(!Array.isArray(n))return n;let a={};for(let i of n)if(typeof i=="string"&&(a.base=j(a.base,i)(m)),typeof i=="object")for(let[r,l]of Object.entries(i))a[r]=j(a[r],l)(m);return a},te=t=>{if(V.length<1)return null;let n={};for(let{slots:a=[],class:i,className:r,...l}of V){if(!b(l)){let c=!0;for(let o of Object.keys(l)){let u=z(o,t)[o];if(u===void 0||(Array.isArray(l[o])?!l[o].includes(u):l[o]!==u)){c=!1;break}}if(!c)continue}for(let c of a)n[c]=n[c]||[],n[c].push([i,r]);}return n};if(!b(M)||!O){let t={};if(typeof w=="object"&&!b(w))for(let n of Object.keys(w))t[n]=a=>{var i,r;return j(w[n],p(n,a),((i=ee(a))!=null?i:[])[n],((r=te(a))!=null?r:[])[n],a==null?void 0:a.class,a==null?void 0:a.className)(m)};return t}return j(S,P(),H(),f$1==null?void 0:f$1.class,f$1==null?void 0:f$1.className)(m)},_=()=>{if(!(!g$1||typeof g$1!="object"))return Object.keys(g$1)};return v.variantKeys=_(),v.extend=e,v.base=S,v.slots=w,v.variants=g$1,v.defaultVariants=A,v.compoundSlots=V,v.compoundVariants=h$1,v},oe=s=>(b,e)=>ce(b,e?g(s,e):s);
export { w as cn, N as cnBase, le as createTV, se as defaultConfig, ie as tv, _ as voidEmpty };
export { j as cn, N as cnBase, oe as createTV, ie as defaultConfig, ce as tv, Z as voidEmpty };
import { a } from './chunk-FUBUDMV2.js';
import w from 'tailwindcss/resolveConfig';
var u={tv:/tv\s*\((.*?)\)/gs,tvExtend:/extend:\s*\w+(,| )\s*/,comment:/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,blankLine:/^\s*$(?:\r\n?|\n)/gm,extension:/\.\w+/g},l=t=>Array.isArray(t),E=t=>typeof t=="string",p=t=>typeof t=="object",T=t=>typeof t=="boolean",h=t=>typeof t=="function",c=t=>!!(!t||l(t)&&t.length===0||E(t)&&t.length===0||p(t)&&Object.keys(t).length===0),j=(t,e)=>{let n={},r=e.length,s=Object.prototype.hasOwnProperty;for(let i=0;i<r;i++){let o=e[i];s.call(t,o)&&(n[o]=t[o]);}return n},V=(t,e)=>{let n="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${t}: ${e.message}`),console.log(`If you think this is an issue, please submit it at ${n}`);},x=(...t)=>e=>t.reduce((n,r)=>r(n),e),S=t=>{let n=t.replace(u.comment,"$1").toString().replace(u.blankLine,"").toString(),r=s=>s[1].replace(u.tvExtend,"").toString();return Array.from(n.matchAll(u.tv),r)},$=t=>{let e=S(t);if(!c(e))return e.map(n=>n.includes("responsiveVariants")?new Function(`
var u={tv:/tv\s*\(((\([^\)]*?\)|\[[^\]]*?\]|.)*?)\)/gs,tvExtend:/extend:\s*\w+(,| )\s*/,comment:/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,blankLine:/^\s*$(?:\r\n?|\n)/gm,extension:/\.\w+/g},l=t=>Array.isArray(t),E=t=>typeof t=="string",p=t=>typeof t=="object",T=t=>typeof t=="boolean",h=t=>typeof t=="function",c=t=>!!(!t||l(t)&&t.length===0||E(t)&&t.length===0||p(t)&&Object.keys(t).length===0),j=(t,e)=>{let n={},r=e.length,s=Object.prototype.hasOwnProperty;for(let i=0;i<r;i++){let o=e[i];s.call(t,o)&&(n[o]=t[o]);}return n},V=(t,e)=>{let n="https://github.com/nextui-org/tailwind-variants/issues/new/choose";console.log("\x1B[31m%s\x1B[0m",`${t}: ${e.message}`),console.log(`If you think this is an issue, please submit it at ${n}`);},x=(...t)=>e=>t.reduce((n,r)=>r(n),e),S=t=>{let n=t.replace(u.comment,"$1").toString().replace(u.blankLine,"").toString(),r=s=>s[1].replace(u.tvExtend,"").toString();return Array.from(n.matchAll(u.tv),r)},$=t=>{let e=S(t);if(!c(e))return e.map(n=>n.includes("responsiveVariants")?new Function(`
const [options, config] = [${n.toString()}];

@@ -6,0 +6,0 @@ return {options, config};

{
"name": "tailwind-variants",
"version": "0.1.20",
"version": "0.2.0",
"description": "🦄 Tailwindcss first-class variant API",

@@ -39,3 +39,3 @@ "author": "Junior Garcia <jrgarciadev@gmail.com>",

"dependencies": {
"tailwind-merge": "^1.14.0"
"tailwind-merge": "^2.2.0"
},

@@ -42,0 +42,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc