tailwind-variants 0.1.1 → 0.1.2
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/transformer.cjs +5 -5
- package/dist/transformer.js +3 -3
- package/package.json +1 -1
package/dist/transformer.cjs
CHANGED
|
@@ -10,17 +10,17 @@ var V__default = /*#__PURE__*/_interopDefault(V);
|
|
|
10
10
|
var w__default = /*#__PURE__*/_interopDefault(w);
|
|
11
11
|
var O__default = /*#__PURE__*/_interopDefault(O);
|
|
12
12
|
|
|
13
|
-
var S=t=>{w__default.default.writeFileSync(O__default.default.join(__dirname,"generated.d.ts"),t);},C=t=>`export type TVGeneratedScreens = ${Object.keys(t).map(
|
|
14
|
-
`,v=t=>{queueMicrotask(()=>{if(t!=null&&t.screens){let
|
|
15
|
-
const [options, config] = [${
|
|
13
|
+
var S=t=>{w__default.default.writeFileSync(O__default.default.join(__dirname,"generated.d.ts"),t);},C=t=>`export type TVGeneratedScreens = ${Object.keys(t).map(e=>`"${e}"`).join(" | ")};
|
|
14
|
+
`,v=t=>{queueMicrotask(()=>{if(t!=null&&t.screens){let e=C(t.screens);S(e);}});};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=>typeof t=="boolean",y=t=>typeof t=="function",c=t=>!!(!t||l(t)&&t.length===0||E(t)&&t.length===0||p(t)&&Object.keys(t).length===0),k=(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},A=(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),F=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)},B=t=>{let e=F(t);if(!c(e))return e.map(n=>n.includes("responsiveVariants")?new Function(`
|
|
15
|
+
const [options, config] = [${n.toString()}];
|
|
16
16
|
return {options, config};
|
|
17
|
-
`)())},h=t=>t.flatMap(
|
|
17
|
+
`)():{})},h=t=>t.flatMap(e=>e).toString().replaceAll(","," ").split(" "),D=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))n[r]={},n[r].original=s,!c(s)&&(n.temp=l(s)?h(s):s.split(" "),e.forEach(i=>{let o="";n.temp.forEach(a=>{o+=`${i}:${a} `;}),n[r][i]=o.trimEnd();}),delete n.temp);return n},L=(t,e)=>E(t)?t.split(" "):l(t)?h(t):p(t)?D(t,e):t,b=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))if(n[r]={},!c(s))for(let[i,o]of Object.entries(s)){if(n[r][i]={},n[r][i].original=o,c(o))continue;let a=L(o,e);if(!c(a)){if(!l(a)){n[r][i]=a;continue}e.forEach(m=>{let f="";a.forEach(d=>{f+=`${m}:${d} `;}),n[r][i][m]=f.trimEnd();});}}return n},T=({options:t,config:e},n)=>{var i,o;let r=(i=t==null?void 0:t.variants)!=null?i:{},s=(o=e==null?void 0:e.responsiveVariants)!=null?o:!1;if(!(!s||c(r))){if($(s))return b(r,n);if(l(s))return b(r,s);if(p(s)){let a=[];for(let[m,f]of Object.entries(s)){if(!f||c(f))continue;let j={options:{variants:k(r,[m])},config:{responsiveVariants:f}};a.push(T(j,n));}return a}}},N=(t,e)=>{try{if(!t.includes("tailwind-variants"))return t;let n=B(t);if(c(n))return t;let r=JSON.stringify(n.map(o=>T(o,e)),void 0,2),s=`
|
|
18
18
|
/* Tailwind Variants Transformed Content Start
|
|
19
19
|
|
|
20
20
|
`,i=`
|
|
21
21
|
|
|
22
22
|
Tailwind Variants Transformed Content End */
|
|
23
|
-
`;return t.concat(s+r+i)}catch(
|
|
23
|
+
`;return t.concat(s+r+i)}catch(n){return A("Tailwind Variants Transform Failed",n),t}},g=t=>{let e=t.map(n=>{if(p(n)&&n.extension)return n.extension;let r=n.match(u.extension);return r||(r=n.split("{"),r=r.pop().replace("}","").split(",")),r.map(s=>s.replace(".","").split(".")).flat()}).flatMap(n=>n);return Array.from(new Set(e)).filter(n=>n!=="html")},G=t=>{var s;let e=V__default.default(t);if(v(e.theme),c((s=e.content)==null?void 0:s.files)||!l(e.content.files))return e;let n=i=>{var o,a;return N(i,Object.keys((a=(o=e.theme)==null?void 0:o.screens)!=null?a:{}))},r=e.content.transform;if(c(r)){let o=g(e.content.files).map(a=>[a,n]);return e.content.transform=Object.fromEntries(o),e}if(y(r)){let o=g(e.content.files).map(a=>[a,x(n,r)]);return e.content.transform=Object.fromEntries(o),e}if(p(r)){let o=g(e.content.files).map(a=>y(r[a])?[a,x(n,r[a])]:[a,n]);return e.content.transform=Object.fromEntries(o),e}return e};
|
|
24
24
|
|
|
25
25
|
exports.tvTransformer = N;
|
|
26
26
|
exports.withTV = G;
|
package/dist/transformer.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { a } from './chunk-FUBUDMV2.js';
|
|
2
2
|
import w from 'tailwindcss/resolveConfig';
|
|
3
3
|
|
|
4
|
-
var u={tv:/tv\s*\((.*?)\)/gs,tvExtend:/extend:\s*\w
|
|
4
|
+
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(`
|
|
5
5
|
const [options, config] = [${n.toString()}];
|
|
6
6
|
return {options, config};
|
|
7
|
-
`)())},b=t=>t.flatMap(e=>e).toString().replaceAll(","," ").split(" "),k=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))n[r]={},n[r].original=s,!c(s)&&(n.temp=l(s)?b(s):s.split(" "),e.forEach(i=>{let o="";n.temp.forEach(a=>{o+=`${i}:${a} `;}),n[r][i]=o.trimEnd();}),delete n.temp);return n},A=(t,e)=>E(t)?t.split(" "):l(t)?b(t):p(t)?k(t,e):t,y=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))if(n[r]={},!c(s))for(let[i,o]of Object.entries(s)){if(n[r][i]={},n[r][i].original=o,c(o))continue;let a=A(o,e);if(!c(a)){if(!l(a)){n[r][i]=a;continue}e.forEach(m=>{let f="";a.forEach(v=>{f+=`${m}:${v} `;}),n[r][i][m]=f.trimEnd();});}}return n},C=({options:t,config:e},n)=>{var i,o;let r=(i=t==null?void 0:t.variants)!=null?i:{},s=(o=e==null?void 0:e.responsiveVariants)!=null?o:!1;if(!(!s||c(r))){if(T(s))return y(r,n);if(l(s))return y(r,s);if(p(s)){let a=[];for(let[m,f]of Object.entries(s)){if(!f||c(f))continue;let O={options:{variants:j(r,[m])},config:{responsiveVariants:f}};a.push(C(O,n));}return a}}},B=(t,e)=>{try{if(!t.includes("tailwind-variants"))return t;let n=$(t);if(c(n))return t;let r=JSON.stringify(n.map(o=>C(o,e)),void 0,2),s=`
|
|
7
|
+
`)():{})},b=t=>t.flatMap(e=>e).toString().replaceAll(","," ").split(" "),k=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))n[r]={},n[r].original=s,!c(s)&&(n.temp=l(s)?b(s):s.split(" "),e.forEach(i=>{let o="";n.temp.forEach(a=>{o+=`${i}:${a} `;}),n[r][i]=o.trimEnd();}),delete n.temp);return n},A=(t,e)=>E(t)?t.split(" "):l(t)?b(t):p(t)?k(t,e):t,y=(t,e)=>{let n={};for(let[r,s]of Object.entries(t))if(n[r]={},!c(s))for(let[i,o]of Object.entries(s)){if(n[r][i]={},n[r][i].original=o,c(o))continue;let a=A(o,e);if(!c(a)){if(!l(a)){n[r][i]=a;continue}e.forEach(m=>{let f="";a.forEach(v=>{f+=`${m}:${v} `;}),n[r][i][m]=f.trimEnd();});}}return n},C=({options:t,config:e},n)=>{var i,o;let r=(i=t==null?void 0:t.variants)!=null?i:{},s=(o=e==null?void 0:e.responsiveVariants)!=null?o:!1;if(!(!s||c(r))){if(T(s))return y(r,n);if(l(s))return y(r,s);if(p(s)){let a=[];for(let[m,f]of Object.entries(s)){if(!f||c(f))continue;let O={options:{variants:j(r,[m])},config:{responsiveVariants:f}};a.push(C(O,n));}return a}}},B=(t,e)=>{try{if(!t.includes("tailwind-variants"))return t;let n=$(t);if(c(n))return t;let r=JSON.stringify(n.map(o=>C(o,e)),void 0,2),s=`
|
|
8
8
|
/* Tailwind Variants Transformed Content Start
|
|
9
9
|
|
|
10
10
|
`,i=`
|
|
11
11
|
|
|
12
12
|
Tailwind Variants Transformed Content End */
|
|
13
|
-
`;return t.concat(s+r+i)}catch(n){return
|
|
13
|
+
`;return t.concat(s+r+i)}catch(n){return V("Tailwind Variants Transform Failed",n),t}},g=t=>{let e=t.map(n=>{if(p(n)&&n.extension)return n.extension;let r=n.match(u.extension);return r||(r=n.split("{"),r=r.pop().replace("}","").split(",")),r.map(s=>s.replace(".","").split(".")).flat()}).flatMap(n=>n);return Array.from(new Set(e)).filter(n=>n!=="html")},N=t=>{var s;let e=w(t);if(a(e.theme),c((s=e.content)==null?void 0:s.files)||!l(e.content.files))return e;let n=i=>{var o,a;return B(i,Object.keys((a=(o=e.theme)==null?void 0:o.screens)!=null?a:{}))},r=e.content.transform;if(c(r)){let o=g(e.content.files).map(a=>[a,n]);return e.content.transform=Object.fromEntries(o),e}if(h(r)){let o=g(e.content.files).map(a=>[a,x(n,r)]);return e.content.transform=Object.fromEntries(o),e}if(p(r)){let o=g(e.content.files).map(a=>h(r[a])?[a,x(n,r[a])]:[a,n]);return e.content.transform=Object.fromEntries(o),e}return e};
|
|
14
14
|
|
|
15
15
|
export { B as tvTransformer, N as withTV };
|