@salty-css/core 0.0.1-alpha.130 → 0.0.1-alpha.131
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/bin/main.cjs +1 -1
- package/bin/main.js +1 -1
- package/compiler/index.cjs +1 -1
- package/compiler/index.js +2 -2
- package/generator/index.cjs +1 -1
- package/generator/index.js +1 -1
- package/{index-XN7f6bdr.js → index-AXVHdDqw.js} +1 -1
- package/{index-BrNi5uoh.cjs → index-D2QOtfTb.cjs} +1 -1
- package/package.json +1 -1
- package/parse-templates-DdYSw-iq.cjs +8 -0
- package/parse-templates-DnLWJ7Hc.js +100 -0
- package/parse-templates-BuKrl3n7.js +0 -100
- package/parse-templates-DIOn-gO_.cjs +0 -8
package/bin/main.cjs
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const te=require("commander"),G=require("fs"),s=require("fs/promises"),n=require("path"),ne=require("ejs"),t=require("../index-D2QOtfTb.cjs"),ie=require("../pascal-case-iWoaJWwT.cjs"),se=require("child_process"),oe=require("ora");var z=typeof document<"u"?document.currentScript:null;const X=y=>new Promise((C,P)=>{se.exec(y,F=>{if(F)return P(F);C()})}),I=async(...y)=>{const C=y.map(b=>b.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),P=oe(`Installing packages: ${C}`).start(),F=y.join(" ");await X(`npm install ${F}`),P.succeed(`Installed packages: ${C}`)},ae=()=>G.existsSync(n.join(process.cwd(),"node_modules",".bin","prettier"));async function S(y){try{if(!ae())return;await X(`./node_modules/.bin/prettier --write "${y}"`),t.logger.info(`Formatted ${y} with Prettier`)}catch(C){t.logger.error(`Error formatting ${y} with Prettier:`,C)}}async function re(){const y=new te.Command;y.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const C={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-Dk6ZcCxI.cjs")),"saltygen/index.css":Promise.resolve().then(()=>require("../index-84Wroia-.cjs")),"react/react-styled-file.ts":Promise.resolve().then(()=>require("../react-styled-file-Dkubsz-U.cjs")),"react/react-vanilla-file.ts":Promise.resolve().then(()=>require("../react-vanilla-file-CG_WJLam.cjs"))},P=async(i,a)=>{const{default:l}=await C[i],u=ne.render(l,a);return{fileName:i,content:u}},F=async()=>{const i=n.join(process.cwd(),".saltyrc.json");return await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>({}))},b=n.join(process.cwd(),"package.json"),N=async(i=b)=>{const a=await s.readFile(i,"utf-8").then(JSON.parse).catch(()=>{});if(!a)throw"Could not read package.json file!";return a},Y=async(i,a=b)=>{typeof i=="object"&&(i=JSON.stringify(i,null,2)),await s.writeFile(a,i)},B=async()=>{const i=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:z&&z.tagName.toUpperCase()==="SCRIPT"&&z.src||new URL("bin/main.cjs",document.baseURI).href);return N(i)},V=await(async()=>(await F()).defaultProject)(),$=await B(),D={core:`@salty-css/core@${$.version}`,react:`@salty-css/react@${$.version}`,eslintConfigCore:`@salty-css/eslint-config-core@${$.version}`,vite:`@salty-css/vite@${$.version}`,next:`@salty-css/next@${$.version}`},R=i=>{const a=i==="."?"":i,l=process.cwd();return n.join(l,a)};y.command("init [directory]").description("Initialize a new Salty-CSS project.").option("-d, --dir <dir>","Project directory to initialize the project in.").option("--css-file <css-file>","Existing CSS file where to import the generated CSS. Path must be relative to the given project directory.").option("--skip-install","Skip installing dependencies.").action(async function(i="."){if(!await N().catch(()=>{}))return t.logError("Salty CSS project must be initialized in a directory with a package.json file.");t.logger.info("Initializing a new Salty-CSS project!");const{dir:l=i,cssFile:u,skipInstall:p}=this.opts();if(!l)return t.logError("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");p||await I(D.core,D.react);const f=process.cwd(),r=R(l),T=await Promise.all([P("salty.config.ts"),P("saltygen/index.css")]);await s.mkdir(r,{recursive:!0});const m=T.map(async({fileName:e,content:g})=>{const c=n.join(r,e);if(await s.readFile(c,"utf-8").catch(()=>{})!==void 0){t.logger.debug("File already exists: "+c);return}const k=e.split("/").slice(0,-1).join("/");k&&await s.mkdir(n.join(r,k),{recursive:!0}),t.logger.info("Creating file: "+c),await s.writeFile(c,g),await S(c)});await Promise.all(m);const w=n.relative(f,r)||".",h=n.join(f,".saltyrc.json"),d=await s.readFile(h,"utf-8").catch(()=>{});if(d===void 0){t.logger.info("Creating file: "+h);const g=JSON.stringify({$schema:"./node_modules/@salty-css/core/.saltyrc.schema.json",info:"This file is used to define projects and their configurations for Salty CSS cli. Do not delete, modify or add this file to .gitignore.",defaultProject:w,projects:[{dir:w,framework:"react"}]},null,2);await s.writeFile(h,g),await S(h)}else{const e=JSON.parse(d),g=(e==null?void 0:e.projects)||[];if(g.findIndex(o=>o.dir===w)===-1){g.push({dir:w,framework:"react"}),e.projects=[...g];const o=JSON.stringify(e,null,2);o!==d&&(t.logger.info("Edit file: "+h),await s.writeFile(h,o),await S(h))}}const j=n.join(f,".gitignore"),U=await s.readFile(j,"utf-8").catch(()=>{});U!==void 0&&(U.includes("saltygen")||(t.logger.info("Edit file: "+j),await s.writeFile(j,U+`
|
2
2
|
|
3
3
|
# Salty-CSS
|
4
4
|
saltygen
|
package/bin/main.js
CHANGED
@@ -3,7 +3,7 @@ import { existsSync as K } from "fs";
|
|
3
3
|
import { mkdir as q, readFile as C, writeFile as w } from "fs/promises";
|
4
4
|
import { join as i, relative as z, parse as re, format as ee } from "path";
|
5
5
|
import { render as ce } from "ejs";
|
6
|
-
import { l as t, a as h, g as te } from "../index-
|
6
|
+
import { l as t, a as h, g as te } from "../index-AXVHdDqw.js";
|
7
7
|
import { p as le } from "../pascal-case-BQpR5PdN.js";
|
8
8
|
import { exec as de } from "child_process";
|
9
9
|
import fe from "ora";
|
package/compiler/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("esbuild");require("child_process");require("../dash-case-BJEkFEGQ.cjs");require("path");require("fs");require("fs/promises");require("../parse-templates-DdYSw-iq.cjs");const e=require("../index-D2QOtfTb.cjs");exports.compileSaltyFile=e.compileSaltyFile;exports.generateConfigStyles=e.generateConfigStyles;exports.generateCss=e.generateCss;exports.generateFile=e.generateFile;exports.isSaltyFile=e.isSaltyFile;exports.minimizeFile=e.minimizeFile;exports.saltyFileExtensions=e.saltyFileExtensions;exports.saltyFileRegExp=e.saltyFileRegExp;
|
package/compiler/index.js
CHANGED
@@ -4,8 +4,8 @@ import "../dash-case-DBThphLm.js";
|
|
4
4
|
import "path";
|
5
5
|
import "fs";
|
6
6
|
import "fs/promises";
|
7
|
-
import "../parse-templates-
|
8
|
-
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-
|
7
|
+
import "../parse-templates-DnLWJ7Hc.js";
|
8
|
+
import { d as p, c as n, g, e as F, i as y, m as x, s as S, b as c } from "../index-AXVHdDqw.js";
|
9
9
|
export {
|
10
10
|
p as compileSaltyFile,
|
11
11
|
n as generateConfigStyles,
|
package/generator/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var y=Object.defineProperty;var f=(a,t,s)=>t in a?y(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var c=(a,t,s)=>f(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../dash-case-BJEkFEGQ.cjs"),u=require("../parse-templates-
|
1
|
+
"use strict";var y=Object.defineProperty;var f=(a,t,s)=>t in a?y(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var c=(a,t,s)=>f(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../dash-case-BJEkFEGQ.cjs"),u=require("../parse-templates-DdYSw-iq.cjs");class N{constructor(t,s){c(this,"_isProd");c(this,"_callerName");c(this,"_context");this.tagName=t,this.params=s}get hash(){return d.toHash(this.params.base||this.params)}get priority(){var t;return typeof this.tagName=="function"||typeof this.tagName=="object"?(((t=this.tagName.generator)==null?void 0:t.priority)||0)+1:0}get classNames(){const t=[this.hash],{className:s}=this.params;return s&&t.push(s),t.join(" ")}get cssClassName(){return this.hash}get cssDisplayNameVar(){return`--${this.hash}-display-name: ${this._callerName};`}get cssFileName(){return this._callerName?`c_${d.dashCase(this._callerName)}-${this.hash}-${this.priority}.css`:`${this.hash}-${this.priority}.css`}get templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?u.getTemplateKeys(this._context.config.templates):[]}get css(){var n;const{base:t={},variants:s={},compoundVariants:i=[]}=this.params,r={...t,variants:s,compoundVariants:i};return u.parseStyles(r,`.${this.cssClassName}`,this.priority,(n=this._context)==null?void 0:n.config)}get props(){const{element:t,variants:s={},compoundVariants:i=[],defaultVariants:r={},defaultProps:n={},passProps:g}=this.params,h=new Set([]),p=e=>{const o=r[e];o!==void 0?h.add(`${e}=${String(o)}`):h.add(e)};Object.keys(s).forEach(p),i.map(e=>Object.keys(e).forEach(p));const l=new Set([]);if(this.params.base){const e=JSON.stringify(this.params.base).match(/\{props\.([\w\d]+)\}/gi);e&&e.forEach(o=>{const m=o.replace(/\{props\.([\w\d]+)\}/gi,"$1");m&&l.add(m)})}return{element:t,variantKeys:[...h],propValueKeys:[...l],passProps:g,defaultProps:n,attr:{"data-component-name":this._isProd?void 0:this._callerName}}}_withBuildContext(t){this._context=t;const{name:s,config:i,prod:r}=t;return this._isProd=r,this._callerName=s,this}}exports.StyleComponentGenerator=N;
|
package/generator/index.js
CHANGED
@@ -2,7 +2,7 @@ var u = Object.defineProperty;
|
|
2
2
|
var f = (a, t, s) => t in a ? u(a, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : a[t] = s;
|
3
3
|
var c = (a, t, s) => f(a, typeof t != "symbol" ? t + "" : t, s);
|
4
4
|
import { t as g, d as y } from "../dash-case-DBThphLm.js";
|
5
|
-
import { g as N, p as _ } from "../parse-templates-
|
5
|
+
import { g as N, p as _ } from "../parse-templates-DnLWJ7Hc.js";
|
6
6
|
class v {
|
7
7
|
constructor(t, s) {
|
8
8
|
c(this, "_isProd");
|
@@ -4,7 +4,7 @@ import { t as H, d as R } from "./dash-case-DBThphLm.js";
|
|
4
4
|
import { join as o, parse as I } from "path";
|
5
5
|
import { existsSync as Z, writeFileSync as S, mkdirSync as O, readFileSync as J, statSync as ie, readdirSync as le } from "fs";
|
6
6
|
import { readFile as pe, writeFile as fe } from "fs/promises";
|
7
|
-
import { p as U, a as de, b as ue, c as ge } from "./parse-templates-
|
7
|
+
import { p as U, a as de, b as ue, c as ge } from "./parse-templates-DnLWJ7Hc.js";
|
8
8
|
import { createLogger as me, format as A, transports as ye } from "winston";
|
9
9
|
const Y = (e) => {
|
10
10
|
if (!e || e === "/") throw new Error("Could not find package.json file");
|
@@ -1,4 +1,4 @@
|
|
1
|
-
"use strict";const ae=require("esbuild"),ce=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),a=require("fs"),G=require("fs/promises"),R=require("./parse-templates-
|
1
|
+
"use strict";const ae=require("esbuild"),ce=require("child_process"),D=require("./dash-case-BJEkFEGQ.cjs"),s=require("path"),a=require("fs"),G=require("fs/promises"),R=require("./parse-templates-DdYSw-iq.cjs"),z=require("winston");var I=typeof document<"u"?document.currentScript:null;function le(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const K=le(ae),L=e=>{if(!e||e==="/")throw new Error("Could not find package.json file");const t=s.join(e,"package.json");return a.existsSync(t)?t:L(s.join(e,".."))},pe=async e=>{const t=L(e);return await G.readFile(t,"utf-8").then(JSON.parse).catch(()=>{})},ue=async e=>{const t=await pe(e);if(t)return t.type};let E;const U=async e=>{if(E)return E;const t=await ue(e);return t==="module"?E="esm":(t==="commonjs"||(typeof document>"u"?require("url").pathToFileURL(__filename).href:I&&I.tagName.toUpperCase()==="SCRIPT"&&I.src||new URL("index-D2QOtfTb.cjs",document.baseURI).href).endsWith(".cjs"))&&(E="cjs"),E||"esm"},J=z.createLogger({level:"debug",format:z.format.combine(z.format.colorize(),z.format.cli()),transports:[new z.transports.Console({})]}),de=e=>{J.error(e)};function X(e){return e?typeof e!="string"?X(String(e)):e.replace(/[\s-]/g,".").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(t,n)=>(n>0?".":"")+t.toLowerCase()):""}const fe={"*, *::before, *::after":{boxSizing:"border-box"},"*":{margin:0},html:{lineHeight:1.15,textSizeAdjust:"100%",WebkitFontSmoothing:"antialiased"},"img, picture, video, canvas, svg":{display:"block",maxWidth:"100%"},"p, h1, h2, h3, h4, h5, h6":{overflowWrap:"break-word"},p:{textWrap:"pretty"},"h1, h2, h3, h4, h5, h6":{textWrap:"balance"},button:{lineHeight:"1em"},"input, optgroup, select, textarea":{fontFamily:"inherit",fontSize:"100%",lineHeight:"1.15em"}},A={externalModules:[]},Y=e=>{if(A.externalModules.length>0)return A.externalModules;const t=s.join(e,"salty.config.ts"),o=a.readFileSync(t,"utf8").match(/externalModules:\s?\[(.*)\]/);if(!o)return[];const p=o[1].split(",").map(r=>r.replace(/['"`]/g,"").trim());return A.externalModules=p,p},q=e=>s.join(e,"./saltygen"),Q=["salty","css","styles","styled"],ee=(e=[])=>new RegExp(`\\.(${[...Q,...e].join("|")})\\.`),W=(e,t=[])=>ee(t).test(e),ge=async e=>{const t=q(e),n=s.join(e,"salty.config.ts"),o=s.join(t,"salty.config.js"),p=await U(e),r=Y(e);await K.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:o,format:p,external:r});const y=Date.now(),{config:m}=await import(`${o}?t=${y}`);return m},te=async e=>{const t=await ge(e),n=new Set,o=(l,d=[])=>l?Object.entries(l).flatMap(([h,f])=>{if(!f)return;if(typeof f=="object")return o(f,[...d,h]);const O=X(h),V=D.dashCase(h),P=[...d,O].join(".");n.add(`"${P}"`);const $=[...d.map(D.dashCase),V].join("-"),{result:x}=R.parseValueTokens(f);return`--${$}: ${x};`}):[],p=l=>l?Object.entries(l).flatMap(([d,h])=>{const f=o(h);return d==="base"?f.join(""):`${d} { ${f.join("")} }`}):[],r=l=>l?Object.entries(l).flatMap(([d,h])=>Object.entries(h).flatMap(([f,O])=>{const V=o(O,[d]),P=`.${d}-${f}, [data-${d}="${f}"]`,$=V.join("");return`${P} { ${$} }`})):[],y=o(t.variables),m=p(t.responsiveVariables),F=r(t.conditionalVariables),i=q(e),u=s.join(i,"css/_variables.css"),S=`:root { ${y.join("")} ${m.join("")} } ${F.join("")}`;a.writeFileSync(u,S);const w=s.join(i,"css/_global.css"),C=R.parseStyles(t.global,"");a.writeFileSync(w,`@layer global { ${C} }`);const b=s.join(i,"css/_reset.css"),g=t.reset==="none"?{}:typeof t.reset=="object"?t.reset:fe,k=R.parseStyles(g,"");a.writeFileSync(b,`@layer reset { ${k} }`);const c=s.join(i,"css/_templates.css"),j=R.parseTemplates(t.templates),N=R.getTemplateTypes(t.templates);a.writeFileSync(c,j);const T=s.join(i,"types/css-tokens.d.ts"),v=`
|
2
2
|
// Variable types
|
3
3
|
type VariableTokens = ${[...n].join("|")};
|
4
4
|
type PropertyValueToken = \`{\${VariableTokens}}\`;
|
package/package.json
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";const T=require("./dash-case-BJEkFEGQ.cjs"),N=(t,s)=>{if(typeof t!="string")return{result:t};if(!s)return{result:t};const n=[];return Object.values(s).forEach(e=>{const{pattern:o,transform:i}=e;t=t.replace(o,d=>{const{value:p,css:j}=i(d);return j&&n.push(j),p})}),{result:t,additionalCss:n}},E=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...e)=>`var(--${T.dashCase(e[1].replaceAll(".","-"))})`)}:{result:t},a=(t,s,n,e)=>{if(!t)return"";const o=[],i=Object.entries(t).reduce((p,[j,r])=>{const c=j.trim();if(typeof r=="function"&&(r=r()),typeof r=="object"){if(!r)return p;if(c==="variants")return Object.entries(r).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,m])=>{if(!m)return;const y=`${s}.${f}-${l}`,b=a(m,y,n,e);o.push(b)})}),p;if(c==="defaultVariants")return p;if(c==="compoundVariants")return r.forEach(f=>{const{css:u,...l}=f,m=Object.entries(l).reduce((b,[q,K])=>`${b}.${q}-${K}`,s),y=a(u,m,n,e);o.push(y)}),p;if(c.startsWith("@")){const f=a(r,s,n,e),u=`${c} {
|
2
|
+
${f.replace(`
|
3
|
+
`,`
|
4
|
+
`)}
|
5
|
+
}`;return o.push(u),p}const $=j.includes("&")?c.replace("&",s):c.startsWith(":")?`${s}${c}`:`${s} ${c}`,h=a(r,$,n,e);return o.push(h),p}if(e!=null&&e.templates&&e.templates[c]){const h=r.split(".").reduce((f,u)=>f[u],e.templates[c]);if(h){const f=a(h,"");return`${p}${f}`}return console.warn(`Template "${c}" with path of "${r}" was not found in config!`),p}const k=c.startsWith("-")?c:T.dashCase(c),O=($,h=";")=>p=`${p}${$}${h}`,S=$=>O(`${k}:${$}`);if(typeof r=="number")return S(r);if(typeof r!="string")if("toString"in r)r=r.toString();else return p;const{modifiers:w}=e||{},W=function*(){yield E(r),yield N(r,w)}();for(const{result:$,additionalCss:h=[]}of W)r=$,h.forEach(f=>{const u=a(f,"");O(u,"")});return S(r)},"");if(!i)return o.join(`
|
6
|
+
`);if(!s)return i;let d="";return n!==void 0?d=`@layer l${n} { ${s} { ${i} } }`:d=`${s} { ${i} }`,[d,...o].join(`
|
7
|
+
`)},V=(t,s=[])=>{if(!t)return"";const n=[],e={};if(Object.entries(t).forEach(([o,i])=>{if(typeof i=="object"){if(!i)return;const d=o.trim(),p=V(i,[...s,d]);n.push(p)}else e[o]=i}),Object.keys(e).length){const o=s.map(T.dashCase).join("-"),i=a(e,`.${o}`);n.push(i)}return n.join(`
|
8
|
+
`)},P=t=>Object.keys(t),_=t=>Object.entries(t).reduce((s,[n,e])=>(typeof e=="object"&&(s[n]=g(e).map(o=>`"${o}"`).join(" | ")),s),{}),g=(t,s="",n=new Set)=>t?(Object.entries(t).forEach(([e,o])=>{const i=s?`${s}.${e}`:e;return typeof o=="object"?g(o,i,n):n.add(s)}),[...n]):[];exports.getTemplateKeys=P;exports.getTemplateTypes=_;exports.parseStyles=a;exports.parseTemplates=V;exports.parseValueTokens=E;
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import { d as O } from "./dash-case-DBThphLm.js";
|
2
|
+
const N = (t, r) => {
|
3
|
+
if (typeof t != "string") return { result: t };
|
4
|
+
if (!r) return { result: t };
|
5
|
+
const n = [];
|
6
|
+
return Object.values(r).forEach((e) => {
|
7
|
+
const { pattern: o, transform: i } = e;
|
8
|
+
t = t.replace(o, (d) => {
|
9
|
+
const { value: c, css: j } = i(d);
|
10
|
+
return j && n.push(j), c;
|
11
|
+
});
|
12
|
+
}), { result: t, additionalCss: n };
|
13
|
+
}, P = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...e) => `var(--${O(e[1].replaceAll(".", "-"))})`) } : { result: t }, a = (t, r, n, e) => {
|
14
|
+
if (!t) return "";
|
15
|
+
const o = [], i = Object.entries(t).reduce((c, [j, s]) => {
|
16
|
+
const p = j.trim();
|
17
|
+
if (typeof s == "function" && (s = s()), typeof s == "object") {
|
18
|
+
if (!s) return c;
|
19
|
+
if (p === "variants")
|
20
|
+
return Object.entries(s).forEach(([f, u]) => {
|
21
|
+
u && Object.entries(u).forEach(([m, b]) => {
|
22
|
+
if (!b) return;
|
23
|
+
const y = `${r}.${f}-${m}`, l = a(b, y, n, e);
|
24
|
+
o.push(l);
|
25
|
+
});
|
26
|
+
}), c;
|
27
|
+
if (p === "defaultVariants")
|
28
|
+
return c;
|
29
|
+
if (p === "compoundVariants")
|
30
|
+
return s.forEach((f) => {
|
31
|
+
const { css: u, ...m } = f, b = Object.entries(m).reduce((l, [w, W]) => `${l}.${w}-${W}`, r), y = a(u, b, n, e);
|
32
|
+
o.push(y);
|
33
|
+
}), c;
|
34
|
+
if (p.startsWith("@")) {
|
35
|
+
const f = a(s, r, n, e), u = `${p} {
|
36
|
+
${f.replace(`
|
37
|
+
`, `
|
38
|
+
`)}
|
39
|
+
}`;
|
40
|
+
return o.push(u), c;
|
41
|
+
}
|
42
|
+
const $ = j.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, h = a(s, $, n, e);
|
43
|
+
return o.push(h), c;
|
44
|
+
}
|
45
|
+
if (e != null && e.templates && e.templates[p]) {
|
46
|
+
const h = s.split(".").reduce((f, u) => f[u], e.templates[p]);
|
47
|
+
if (h) {
|
48
|
+
const f = a(h, "");
|
49
|
+
return `${c}${f}`;
|
50
|
+
}
|
51
|
+
return console.warn(`Template "${p}" with path of "${s}" was not found in config!`), c;
|
52
|
+
}
|
53
|
+
const V = p.startsWith("-") ? p : O(p), T = ($, h = ";") => c = `${c}${$}${h}`, E = ($) => T(`${V}:${$}`);
|
54
|
+
if (typeof s == "number") return E(s);
|
55
|
+
if (typeof s != "string")
|
56
|
+
if ("toString" in s) s = s.toString();
|
57
|
+
else return c;
|
58
|
+
const { modifiers: g } = e || {}, k = function* () {
|
59
|
+
yield P(s), yield N(s, g);
|
60
|
+
}();
|
61
|
+
for (const { result: $, additionalCss: h = [] } of k)
|
62
|
+
s = $, h.forEach((f) => {
|
63
|
+
const u = a(f, "");
|
64
|
+
T(u, "");
|
65
|
+
});
|
66
|
+
return E(s);
|
67
|
+
}, "");
|
68
|
+
if (!i) return o.join(`
|
69
|
+
`);
|
70
|
+
if (!r) return i;
|
71
|
+
let d = "";
|
72
|
+
return n !== void 0 ? d = `@layer l${n} { ${r} { ${i} } }` : d = `${r} { ${i} }`, [d, ...o].join(`
|
73
|
+
`);
|
74
|
+
}, _ = (t, r = []) => {
|
75
|
+
if (!t) return "";
|
76
|
+
const n = [], e = {};
|
77
|
+
if (Object.entries(t).forEach(([o, i]) => {
|
78
|
+
if (typeof i == "object") {
|
79
|
+
if (!i) return;
|
80
|
+
const d = o.trim(), c = _(i, [...r, d]);
|
81
|
+
n.push(c);
|
82
|
+
} else
|
83
|
+
e[o] = i;
|
84
|
+
}), Object.keys(e).length) {
|
85
|
+
const o = r.map(O).join("-"), i = a(e, `.${o}`);
|
86
|
+
n.push(i);
|
87
|
+
}
|
88
|
+
return n.join(`
|
89
|
+
`);
|
90
|
+
}, A = (t) => Object.keys(t), K = (t) => Object.entries(t).reduce((r, [n, e]) => (typeof e == "object" && (r[n] = S(e).map((o) => `"${o}"`).join(" | ")), r), {}), S = (t, r = "", n = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([e, o]) => {
|
91
|
+
const i = r ? `${r}.${e}` : e;
|
92
|
+
return typeof o == "object" ? S(o, i, n) : n.add(r);
|
93
|
+
}), [...n]) : [];
|
94
|
+
export {
|
95
|
+
_ as a,
|
96
|
+
K as b,
|
97
|
+
P as c,
|
98
|
+
A as g,
|
99
|
+
a as p
|
100
|
+
};
|
@@ -1,100 +0,0 @@
|
|
1
|
-
import { d as O } from "./dash-case-DBThphLm.js";
|
2
|
-
const N = (t, e) => {
|
3
|
-
if (typeof t != "string") return { result: t };
|
4
|
-
if (!e) return { result: t };
|
5
|
-
const s = [];
|
6
|
-
return Object.values(e).forEach((n) => {
|
7
|
-
const { pattern: o, transform: i } = n;
|
8
|
-
t = t.replace(o, (d) => {
|
9
|
-
const { value: c, css: j } = i(d);
|
10
|
-
return j && s.push(j), c;
|
11
|
-
});
|
12
|
-
}), { result: t, additionalCss: s };
|
13
|
-
}, P = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${O(n[1].replaceAll(".", "-"))})`) } : { result: t }, a = (t, e, s, n) => {
|
14
|
-
if (!t) return "";
|
15
|
-
const o = [], i = Object.entries(t).reduce((c, [j, r]) => {
|
16
|
-
const f = j.trim();
|
17
|
-
if (typeof r == "function" && (r = r()), typeof r == "object") {
|
18
|
-
if (!r) return c;
|
19
|
-
if (f === "variants")
|
20
|
-
return Object.entries(r).forEach(([p, u]) => {
|
21
|
-
u && Object.entries(u).forEach(([m, b]) => {
|
22
|
-
if (!b) return;
|
23
|
-
const y = `${e}.${p}-${m}`, l = a(b, y, s);
|
24
|
-
o.push(l);
|
25
|
-
});
|
26
|
-
}), c;
|
27
|
-
if (f === "defaultVariants")
|
28
|
-
return c;
|
29
|
-
if (f === "compoundVariants")
|
30
|
-
return r.forEach((p) => {
|
31
|
-
const { css: u, ...m } = p, b = Object.entries(m).reduce((l, [w, W]) => `${l}.${w}-${W}`, e), y = a(u, b, s);
|
32
|
-
o.push(y);
|
33
|
-
}), c;
|
34
|
-
if (f.startsWith("@")) {
|
35
|
-
const p = a(r, e, s), u = `${f} {
|
36
|
-
${p.replace(`
|
37
|
-
`, `
|
38
|
-
`)}
|
39
|
-
}`;
|
40
|
-
return o.push(u), c;
|
41
|
-
}
|
42
|
-
const $ = j.includes("&") ? f.replace("&", e) : f.startsWith(":") ? `${e}${f}` : `${e} ${f}`, h = a(r, $, s);
|
43
|
-
return o.push(h), c;
|
44
|
-
}
|
45
|
-
if (n != null && n.templates && n.templates[f]) {
|
46
|
-
const h = r.split(".").reduce((p, u) => p[u], n.templates[f]);
|
47
|
-
if (h) {
|
48
|
-
const p = a(h, "");
|
49
|
-
return `${c}${p}`;
|
50
|
-
}
|
51
|
-
return console.warn(`Template "${f}" with path of "${r}" was not found in config!`), c;
|
52
|
-
}
|
53
|
-
const S = f.startsWith("-") ? f : O(f), g = ($, h = ";") => c = `${c}${$}${h}`, T = ($) => g(`${S}:${$}`);
|
54
|
-
if (typeof r == "number") return T(r);
|
55
|
-
if (typeof r != "string")
|
56
|
-
if ("toString" in r) r = r.toString();
|
57
|
-
else return c;
|
58
|
-
const { modifiers: V } = n || {}, k = function* () {
|
59
|
-
yield P(r), yield N(r, V);
|
60
|
-
}();
|
61
|
-
for (const { result: $, additionalCss: h = [] } of k)
|
62
|
-
r = $, h.forEach((p) => {
|
63
|
-
const u = a(p, "");
|
64
|
-
g(u, "");
|
65
|
-
});
|
66
|
-
return T(r);
|
67
|
-
}, "");
|
68
|
-
if (!i) return o.join(`
|
69
|
-
`);
|
70
|
-
if (!e) return i;
|
71
|
-
let d = "";
|
72
|
-
return s !== void 0 ? d = `@layer l${s} { ${e} { ${i} } }` : d = `${e} { ${i} }`, [d, ...o].join(`
|
73
|
-
`);
|
74
|
-
}, _ = (t, e = []) => {
|
75
|
-
if (!t) return "";
|
76
|
-
const s = [], n = {};
|
77
|
-
if (Object.entries(t).forEach(([o, i]) => {
|
78
|
-
if (typeof i == "object") {
|
79
|
-
if (!i) return;
|
80
|
-
const d = o.trim(), c = _(i, [...e, d]);
|
81
|
-
s.push(c);
|
82
|
-
} else
|
83
|
-
n[o] = i;
|
84
|
-
}), Object.keys(n).length) {
|
85
|
-
const o = e.map(O).join("-"), i = a(n, `.${o}`);
|
86
|
-
s.push(i);
|
87
|
-
}
|
88
|
-
return s.join(`
|
89
|
-
`);
|
90
|
-
}, A = (t) => Object.keys(t), K = (t) => Object.entries(t).reduce((e, [s, n]) => (typeof n == "object" && (e[s] = E(n).map((o) => `"${o}"`).join(" | ")), e), {}), E = (t, e = "", s = /* @__PURE__ */ new Set()) => t ? (Object.entries(t).forEach(([n, o]) => {
|
91
|
-
const i = e ? `${e}.${n}` : n;
|
92
|
-
return typeof o == "object" ? E(o, i, s) : s.add(e);
|
93
|
-
}), [...s]) : [];
|
94
|
-
export {
|
95
|
-
_ as a,
|
96
|
-
K as b,
|
97
|
-
P as c,
|
98
|
-
A as g,
|
99
|
-
a as p
|
100
|
-
};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";const T=require("./dash-case-BJEkFEGQ.cjs"),N=(t,e)=>{if(typeof t!="string")return{result:t};if(!e)return{result:t};const r=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:i}=n;t=t.replace(o,d=>{const{value:c,css:j}=i(d);return j&&r.push(j),c})}),{result:t,additionalCss:r}},S=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${T.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},a=(t,e,r,n)=>{if(!t)return"";const o=[],i=Object.entries(t).reduce((c,[j,s])=>{const p=j.trim();if(typeof s=="function"&&(s=s()),typeof s=="object"){if(!s)return c;if(p==="variants")return Object.entries(s).forEach(([f,u])=>{u&&Object.entries(u).forEach(([l,m])=>{if(!m)return;const y=`${e}.${f}-${l}`,b=a(m,y,r);o.push(b)})}),c;if(p==="defaultVariants")return c;if(p==="compoundVariants")return s.forEach(f=>{const{css:u,...l}=f,m=Object.entries(l).reduce((b,[q,K])=>`${b}.${q}-${K}`,e),y=a(u,m,r);o.push(y)}),c;if(p.startsWith("@")){const f=a(s,e,r),u=`${p} {
|
2
|
-
${f.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return o.push(u),c}const $=j.includes("&")?p.replace("&",e):p.startsWith(":")?`${e}${p}`:`${e} ${p}`,h=a(s,$,r);return o.push(h),c}if(n!=null&&n.templates&&n.templates[p]){const h=s.split(".").reduce((f,u)=>f[u],n.templates[p]);if(h){const f=a(h,"");return`${c}${f}`}return console.warn(`Template "${p}" with path of "${s}" was not found in config!`),c}const k=p.startsWith("-")?p:T.dashCase(p),O=($,h=";")=>c=`${c}${$}${h}`,g=$=>O(`${k}:${$}`);if(typeof s=="number")return g(s);if(typeof s!="string")if("toString"in s)s=s.toString();else return c;const{modifiers:w}=n||{},W=function*(){yield S(s),yield N(s,w)}();for(const{result:$,additionalCss:h=[]}of W)s=$,h.forEach(f=>{const u=a(f,"");O(u,"")});return g(s)},"");if(!i)return o.join(`
|
6
|
-
`);if(!e)return i;let d="";return r!==void 0?d=`@layer l${r} { ${e} { ${i} } }`:d=`${e} { ${i} }`,[d,...o].join(`
|
7
|
-
`)},E=(t,e=[])=>{if(!t)return"";const r=[],n={};if(Object.entries(t).forEach(([o,i])=>{if(typeof i=="object"){if(!i)return;const d=o.trim(),c=E(i,[...e,d]);r.push(c)}else n[o]=i}),Object.keys(n).length){const o=e.map(T.dashCase).join("-"),i=a(n,`.${o}`);r.push(i)}return r.join(`
|
8
|
-
`)},P=t=>Object.keys(t),_=t=>Object.entries(t).reduce((e,[r,n])=>(typeof n=="object"&&(e[r]=V(n).map(o=>`"${o}"`).join(" | ")),e),{}),V=(t,e="",r=new Set)=>t?(Object.entries(t).forEach(([n,o])=>{const i=e?`${e}.${n}`:n;return typeof o=="object"?V(o,i,r):r.add(e)}),[...r]):[];exports.getTemplateKeys=P;exports.getTemplateTypes=_;exports.parseStyles=a;exports.parseTemplates=E;exports.parseValueTokens=S;
|