@salty-css/core 0.0.1-alpha.3 → 0.0.1-alpha.31
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/README.md +23 -19
- package/bin/bin-util.d.ts +2 -0
- package/bin/index.cjs +2 -0
- package/bin/index.d.ts +2 -0
- package/bin/index.js +3 -0
- package/bin/logger.d.ts +2 -0
- package/bin/main.cjs +8 -0
- package/bin/main.d.ts +1 -0
- package/bin/main.js +156 -0
- package/bin/prettier.d.ts +1 -0
- package/compiler/index.cjs +11 -0
- package/{dist/compiler → compiler}/index.d.ts +4 -4
- package/compiler/index.js +174 -0
- package/{dist/config → config}/config-types.d.ts +3 -3
- package/dash-case-DKzpenwY.cjs +1 -0
- package/{dist/util/index.js → dash-case-DMQMcCO6.js} +5 -5
- package/generator/index.cjs +1 -0
- package/generator/index.js +61 -0
- package/{dist/generator → generator}/style-generator.d.ts +9 -8
- package/index-84Wroia-.cjs +1 -0
- package/index-D_732b92.js +4 -0
- package/package.json +39 -20
- package/{dist/parse-templates-BOSK0Tb6.js → parse-templates-D4p3pgQR.js} +26 -24
- package/parse-templates-W0YfTmOT.cjs +8 -0
- package/pascal-case-BQpR5PdN.js +6 -0
- package/pascal-case-iWoaJWwT.cjs +1 -0
- package/react-styled-file-CGVf5n1B.js +11 -0
- package/react-styled-file-Dkubsz-U.cjs +8 -0
- package/salty.config-BupieCfE.cjs +6 -0
- package/salty.config-D9ANEDiH.js +9 -0
- package/{dist/types → types}/index.d.ts +7 -2
- package/util/camel-case.d.ts +1 -0
- package/util/index.cjs +1 -0
- package/util/index.d.ts +4 -0
- package/util/index.js +11 -0
- package/util/pascal-case.d.ts +1 -0
- package/dist/README.md +0 -107
- package/dist/compiler/index.cjs +0 -11
- package/dist/compiler/index.js +0 -180
- package/dist/generator/index.cjs +0 -1
- package/dist/generator/index.js +0 -51
- package/dist/package.json +0 -50
- package/dist/parse-templates-BY1Xai-_.cjs +0 -8
- package/dist/util/index.cjs +0 -1
- package/dist/util/index.d.ts +0 -2
- /package/{dist/config → config}/define-config.d.ts +0 -0
- /package/{dist/config → config}/index.cjs +0 -0
- /package/{dist/config → config}/index.d.ts +0 -0
- /package/{dist/config → config}/index.js +0 -0
- /package/{dist/css → css}/index.cjs +0 -0
- /package/{dist/css → css}/index.d.ts +0 -0
- /package/{dist/css → css}/index.js +0 -0
- /package/{dist/generator → generator}/index.d.ts +0 -0
- /package/{dist/generator → generator}/parse-modifiers.d.ts +0 -0
- /package/{dist/generator → generator}/parse-styles.d.ts +0 -0
- /package/{dist/generator → generator}/parse-templates.d.ts +0 -0
- /package/{dist/generator → generator}/parse-tokens.d.ts +0 -0
- /package/{dist/generator → generator}/parser-types.d.ts +0 -0
- /package/{dist/types → types}/index.cjs +0 -0
- /package/{dist/types → types}/index.js +0 -0
- /package/{dist/types → types}/util-types.d.ts +0 -0
- /package/{dist/util → util}/dash-case.d.ts +0 -0
- /package/{dist/util → util}/to-hash.d.ts +0 -0
package/README.md
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
### Initial requirements
|
6
6
|
|
7
7
|
1. Add `saltyPlugin` to vite or webpack config from `@salty-css/vite` or `@salty-css/webpack`
|
8
|
-
2. Create `salty
|
8
|
+
2. Create `salty.config.ts` to the root of your project
|
9
9
|
3. Import global styles to any regular .css file from `saltygen/index.css` (does not exist during first run, cli command coming later)
|
10
10
|
4. Create salty components with styled only inside files that end with `.css.ts`, `.salty.ts` `.styled.ts` or `.styles.ts`
|
11
11
|
|
@@ -54,8 +54,10 @@ export const IndexPage = () => {
|
|
54
54
|
import { styled } from '@salty-css/react/styled';
|
55
55
|
|
56
56
|
export const Wrapper = styled('div', {
|
57
|
-
|
58
|
-
|
57
|
+
base: {
|
58
|
+
display: 'block',
|
59
|
+
padding: '2vw',
|
60
|
+
},
|
59
61
|
});
|
60
62
|
```
|
61
63
|
|
@@ -65,22 +67,24 @@ export const Wrapper = styled('div', {
|
|
65
67
|
import { styled } from '@salty-css/react/styled';
|
66
68
|
|
67
69
|
export const Button = styled('button', {
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
70
|
+
base: {
|
71
|
+
display: 'block',
|
72
|
+
padding: `0.6em 1.2em`,
|
73
|
+
border: '1px solid currentColor',
|
74
|
+
background: 'transparent',
|
75
|
+
color: 'currentColor/40',
|
76
|
+
cursor: 'pointer',
|
77
|
+
transition: '200ms',
|
78
|
+
textDecoration: 'none',
|
79
|
+
'&:hover': {
|
80
|
+
background: 'black',
|
81
|
+
borderColor: 'black',
|
82
|
+
color: 'white',
|
83
|
+
},
|
84
|
+
'&:disabled': {
|
85
|
+
opacity: 0.25,
|
86
|
+
pointerEvents: 'none',
|
87
|
+
},
|
84
88
|
},
|
85
89
|
variants: {
|
86
90
|
variant: {
|
package/bin/index.cjs
ADDED
package/bin/index.d.ts
ADDED
package/bin/index.js
ADDED
package/bin/logger.d.ts
ADDED
package/bin/main.cjs
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("commander"),a=require("fs/promises"),e=require("path"),L=require("ejs"),R=require("../compiler/index.cjs"),z=require("../pascal-case-iWoaJWwT.cjs"),k=require("winston"),W=require("fs"),H=require("child_process"),M=require("ora");var U=typeof document<"u"?document.currentScript:null;const t=k.createLogger({level:"debug",format:k.format.combine(k.format.colorize(),k.format.cli()),transports:[new k.transports.Console({})]}),v=i=>{t.error(i)},E=i=>new Promise((g,h)=>{H.exec(i,w=>{if(w)return h(w);g()})}),b=async(...i)=>{const g=i.map(x=>x.replace("-D","").split("@").slice(0,-1).join("@").trim()).join(", "),h=M(`Installing packages: ${g}`).start(),w=i.join(" ");await E(`npm install ${w}`),h.succeed(`Installed packages: ${g}`)},B=()=>W.existsSync(e.join(process.cwd(),"node_modules",".bin","prettier"));async function D(i){try{if(!B())return;await E(`./node_modules/.bin/prettier --write "${i}"`),t.info(`Formatted ${i} with Prettier`)}catch(g){t.error(`Error formatting ${i} with Prettier:`,g)}}async function G(){const i=new T.Command;i.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");const g={"salty.config.ts":Promise.resolve().then(()=>require("../salty.config-BupieCfE.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"))},h=async(o,r)=>{const{default:d}=await g[o],u=L.render(d,r);return{fileName:o,content:u}},w=async()=>{const o=e.join(process.cwd(),".saltyrc");return await a.readFile(o,"utf-8").then(JSON.parse).catch(()=>({}))},x=async o=>{const r=await a.readFile(o,"utf-8").then(JSON.parse).catch(()=>{});if(!r)throw"Could not read package.json file!";return r},O=async()=>{const o=new URL("../package.json",typeof document>"u"?require("url").pathToFileURL(__filename).href:U&&U.tagName.toUpperCase()==="SCRIPT"&&U.src||new URL("bin/main.cjs",document.baseURI).href);return x(o)},J=await(async()=>(await w()).defaultProject)(),C=await O(),I={core:`@salty-css/core@${C.version}`,react:`@salty-css/react@${C.version}`,eslintPluginCore:`@salty-css/eslint-plugin-core@${C.version}`,vite:`@salty-css/vite@${C.version}`};i.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(o){t.info("Initializing a new Salty-CSS project!");const{dir:r=o,cssFile:d,skipInstall:u}=this.opts();if(!r)return v("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");u||(await b(I.core,I.react),await b(`-D ${I.eslintPluginCore}`));const f=process.cwd(),p=e.join(f,r),S=await Promise.all([h("salty.config.ts"),h("saltygen/index.css")]);await a.mkdir(p,{recursive:!0});const j=S.map(async({fileName:n,content:l})=>{const m=e.join(p,n);if(await a.readFile(m,"utf-8").catch(()=>{})!==void 0){t.debug("File already exists: "+m);return}const N=n.split("/").slice(0,-1).join("/");N&&await a.mkdir(e.join(p,N),{recursive:!0}),t.info("Writing file: "+m),await a.writeFile(m,l),await D(m)});await Promise.all(j);const c=e.relative(f,p),s=e.join(f,".saltyrc"),y=await a.readFile(s,"utf-8").catch(()=>{});if(y===void 0){t.info("Creating file: "+s);const l=JSON.stringify({defaultProject:c,projects:[c]},null,2);await a.writeFile(s,l)}else{t.info("Edit file: "+s);const n=JSON.parse(y),l=new Set((n==null?void 0:n.projects)||[]);l.add(c),n.projects=[...l];const m=JSON.stringify(n,null,2);await a.writeFile(s,m)}const $=e.join(f,".gitignore"),F=await a.readFile($,"utf-8").catch(()=>{});if(F!==void 0&&(F.includes("saltygen")||(t.info("Edit file: "+$),await a.writeFile($,F+`
|
2
|
+
|
3
|
+
# Salty-CSS
|
4
|
+
saltygen
|
5
|
+
`))),d){const n=e.join(p,d),l=await a.readFile(n,"utf-8").catch(()=>{});if(l!==void 0&&!l.includes("saltygen")){const q=e.join(n,".."),A=`@import '${e.relative(q,e.join(p,"saltygen/index.css"))}';`;t.info("Edit file: "+n),await a.writeFile(n,A+`
|
6
|
+
`+l),await D(n)}}const P=e.join(p,"vite.config.ts"),_=await a.readFile(P,"utf-8").catch(()=>{});if(_!==void 0&&!_.includes("saltyPlugin")){t.info("Edit file: "+P);const l=`import { saltyPlugin } from '@salty-css/vite';
|
7
|
+
`,q=_.replace(/(plugins: \[)/,`$1
|
8
|
+
saltyPlugin(__dirname),`);t.info("Installing @salty-css/vite"),u||await b(`-D ${I.vite}`),t.info("Adding Salty-CSS plugin to Vite config..."),await a.writeFile(P,l+q),await D(P)}}),i.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>","Project directory to build the project in.").action(async function(o=J){t.info("Building the Salty-CSS project...");const{dir:r=o}=this.opts();if(!r)return v("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");const d=e.join(process.cwd(),r);await R.generateCss(d)}),i.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>","File to generate.").option("-d, --dir <dir>","Project directory to generate the file in.").option("-t, --tag <tag>","HTML tag of the component.","div").option("-n, --name <name>","Name of the component.").option("-c, --className <className>","CSS class of the component.").action(async function(o,r=J){const{file:d=o,dir:u=r,tag:f,name:p,className:S}=this.opts();if(!d)return v("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");if(!u)return v("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");const j=e.join(process.cwd(),u),c=e.join(j,d),s=e.parse(c);s.ext||(s.ext=".ts"),s.name.endsWith(".css")||(s.name=s.name+".css"),s.base=s.name+s.ext;const y=e.format(s);if(await a.readFile(y,"utf-8").catch(()=>{})!==void 0){t.error("File already exists:",y);return}t.info("Generating a new file: "+y);const F=z.pascalCase(p||s.base.replace(/\.css\.\w+$/,"")),{content:P}=await h("react/react-styled-file.ts",{tag:f,name:F,className:S});await a.writeFile(y,P),await D(y)}),i.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>","Use legacy peer dependencies (not recommended).",!1).action(async function(o,r=J){const{legacyPeerDeps:d}=this.opts(),u=e.join(process.cwd(),"package.json"),f=await x(u).catch(c=>v(c));if(!f)return;const p={...f.dependencies,...f.devDependencies},S=Object.keys(p).filter(c=>c==="salty-css"||c.startsWith("@salty-css/"));if(!S.length)return v("No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: "+u);const j=S.map(c=>`${c}@${C.version}`);d?(t.warn("Using legacy peer dependencies to update packages."),await b(...j,"--legacy-peer-deps")):await b(...j),t.info("Salty-CSS packages updated successfully!")}),i.parseAsync(process.argv)}exports.main=G;
|
package/bin/main.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export declare function main(): Promise<void>;
|
package/bin/main.js
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
import { Command as W } from "commander";
|
2
|
+
import { mkdir as _, readFile as y, writeFile as w } from "fs/promises";
|
3
|
+
import { join as o, relative as U, parse as H, format as B } from "path";
|
4
|
+
import { render as G } from "ejs";
|
5
|
+
import { generateCss as M } from "../compiler/index.js";
|
6
|
+
import { p as R } from "../pascal-case-BQpR5PdN.js";
|
7
|
+
import { createLogger as V, format as O, transports as q } from "winston";
|
8
|
+
import { existsSync as K } from "fs";
|
9
|
+
import { exec as Q } from "child_process";
|
10
|
+
import X from "ora";
|
11
|
+
const t = V({
|
12
|
+
level: "debug",
|
13
|
+
format: O.combine(O.colorize(), O.cli()),
|
14
|
+
transports: [new q.Console({})]
|
15
|
+
}), j = (e) => {
|
16
|
+
t.error(e);
|
17
|
+
}, z = (e) => new Promise((g, h) => {
|
18
|
+
Q(e, (S) => {
|
19
|
+
if (S) return h(S);
|
20
|
+
g();
|
21
|
+
});
|
22
|
+
}), x = async (...e) => {
|
23
|
+
const g = e.map((F) => F.replace("-D", "").split("@").slice(0, -1).join("@").trim()).join(", "), h = X(`Installing packages: ${g}`).start(), S = e.join(" ");
|
24
|
+
await z(`npm install ${S}`), h.succeed(`Installed packages: ${g}`);
|
25
|
+
}, Y = () => K(o(process.cwd(), "node_modules", ".bin", "prettier"));
|
26
|
+
async function J(e) {
|
27
|
+
try {
|
28
|
+
if (!Y()) return;
|
29
|
+
await z(`./node_modules/.bin/prettier --write "${e}"`), t.info(`Formatted ${e} with Prettier`);
|
30
|
+
} catch (g) {
|
31
|
+
t.error(`Error formatting ${e} with Prettier:`, g);
|
32
|
+
}
|
33
|
+
}
|
34
|
+
async function dt() {
|
35
|
+
const e = new W();
|
36
|
+
e.name("salty-css").description("Salty-CSS CLI tool to help with annoying configuration tasks.");
|
37
|
+
const g = {
|
38
|
+
// Core files
|
39
|
+
"salty.config.ts": import("../salty.config-D9ANEDiH.js"),
|
40
|
+
"saltygen/index.css": import("../index-D_732b92.js"),
|
41
|
+
// React
|
42
|
+
"react/react-styled-file.ts": import("../react-styled-file-CGVf5n1B.js")
|
43
|
+
}, h = async (i, s) => {
|
44
|
+
const { default: l } = await g[i], p = G(l, s);
|
45
|
+
return { fileName: i, content: p };
|
46
|
+
}, S = async () => {
|
47
|
+
const i = o(process.cwd(), ".saltyrc");
|
48
|
+
return await y(i, "utf-8").then(JSON.parse).catch(() => ({}));
|
49
|
+
}, F = async (i) => {
|
50
|
+
const s = await y(i, "utf-8").then(JSON.parse).catch(() => {
|
51
|
+
});
|
52
|
+
if (!s) throw "Could not read package.json file!";
|
53
|
+
return s;
|
54
|
+
}, L = async () => {
|
55
|
+
const i = new URL("../package.json", import.meta.url);
|
56
|
+
return F(i);
|
57
|
+
}, N = await (async () => (await S()).defaultProject)(), k = await L(), b = {
|
58
|
+
core: `@salty-css/core@${k.version}`,
|
59
|
+
react: `@salty-css/react@${k.version}`,
|
60
|
+
eslintPluginCore: `@salty-css/eslint-plugin-core@${k.version}`,
|
61
|
+
vite: `@salty-css/vite@${k.version}`
|
62
|
+
};
|
63
|
+
e.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) {
|
64
|
+
t.info("Initializing a new Salty-CSS project!");
|
65
|
+
const { dir: s = i, cssFile: l, skipInstall: p } = this.opts();
|
66
|
+
if (!s) return j("Project directory must be provided. Add it as the first argument after init command or use the --dir option.");
|
67
|
+
p || (await x(b.core, b.react), await x(`-D ${b.eslintPluginCore}`));
|
68
|
+
const f = process.cwd(), d = o(f, s), P = await Promise.all([h("salty.config.ts"), h("saltygen/index.css")]);
|
69
|
+
await _(d, { recursive: !0 });
|
70
|
+
const v = P.map(async ({ fileName: n, content: c }) => {
|
71
|
+
const m = o(d, n);
|
72
|
+
if (await y(m, "utf-8").catch(() => {
|
73
|
+
}) !== void 0) {
|
74
|
+
t.debug("File already exists: " + m);
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
const A = n.split("/").slice(0, -1).join("/");
|
78
|
+
A && await _(o(d, A), { recursive: !0 }), t.info("Writing file: " + m), await w(m, c), await J(m);
|
79
|
+
});
|
80
|
+
await Promise.all(v);
|
81
|
+
const r = U(f, d), a = o(f, ".saltyrc"), u = await y(a, "utf-8").catch(() => {
|
82
|
+
});
|
83
|
+
if (u === void 0) {
|
84
|
+
t.info("Creating file: " + a);
|
85
|
+
const c = JSON.stringify({
|
86
|
+
defaultProject: r,
|
87
|
+
projects: [r]
|
88
|
+
}, null, 2);
|
89
|
+
await w(a, c);
|
90
|
+
} else {
|
91
|
+
t.info("Edit file: " + a);
|
92
|
+
const n = JSON.parse(u), c = new Set((n == null ? void 0 : n.projects) || []);
|
93
|
+
c.add(r), n.projects = [...c];
|
94
|
+
const m = JSON.stringify(n, null, 2);
|
95
|
+
await w(a, m);
|
96
|
+
}
|
97
|
+
const I = o(f, ".gitignore"), $ = await y(I, "utf-8").catch(() => {
|
98
|
+
});
|
99
|
+
if ($ !== void 0 && ($.includes("saltygen") || (t.info("Edit file: " + I), await w(I, $ + `
|
100
|
+
|
101
|
+
# Salty-CSS
|
102
|
+
saltygen
|
103
|
+
`))), l) {
|
104
|
+
const n = o(d, l), c = await y(n, "utf-8").catch(() => {
|
105
|
+
});
|
106
|
+
if (c !== void 0 && !c.includes("saltygen")) {
|
107
|
+
const D = o(n, ".."), T = `@import '${U(D, o(d, "saltygen/index.css"))}';`;
|
108
|
+
t.info("Edit file: " + n), await w(n, T + `
|
109
|
+
` + c), await J(n);
|
110
|
+
}
|
111
|
+
}
|
112
|
+
const C = o(d, "vite.config.ts"), E = await y(C, "utf-8").catch(() => {
|
113
|
+
});
|
114
|
+
if (E !== void 0 && !E.includes("saltyPlugin")) {
|
115
|
+
t.info("Edit file: " + C);
|
116
|
+
const c = `import { saltyPlugin } from '@salty-css/vite';
|
117
|
+
`, D = E.replace(/(plugins: \[)/, `$1
|
118
|
+
saltyPlugin(__dirname),`);
|
119
|
+
t.info("Installing @salty-css/vite"), p || await x(`-D ${b.vite}`), t.info("Adding Salty-CSS plugin to Vite config..."), await w(C, c + D), await J(C);
|
120
|
+
}
|
121
|
+
}), e.command("build [directory]").alias("b").description("Build the Salty-CSS project.").option("-d, --dir <dir>", "Project directory to build the project in.").action(async function(i = N) {
|
122
|
+
t.info("Building the Salty-CSS project...");
|
123
|
+
const { dir: s = i } = this.opts();
|
124
|
+
if (!s) return j("Project directory must be provided. Add it as the first argument after build command or use the --dir option.");
|
125
|
+
const l = o(process.cwd(), s);
|
126
|
+
await M(l);
|
127
|
+
}), e.command("generate [file] [directory]").alias("g").description("Generate a new component file.").option("-f, --file <file>", "File to generate.").option("-d, --dir <dir>", "Project directory to generate the file in.").option("-t, --tag <tag>", "HTML tag of the component.", "div").option("-n, --name <name>", "Name of the component.").option("-c, --className <className>", "CSS class of the component.").action(async function(i, s = N) {
|
128
|
+
const { file: l = i, dir: p = s, tag: f, name: d, className: P } = this.opts();
|
129
|
+
if (!l) return j("File to generate must be provided. Add it as the first argument after generate command or use the --file option.");
|
130
|
+
if (!p) return j("Project directory must be provided. Add it as the second argument after generate command or use the --dir option.");
|
131
|
+
const v = o(process.cwd(), p), r = o(v, l), a = H(r);
|
132
|
+
a.ext || (a.ext = ".ts"), a.name.endsWith(".css") || (a.name = a.name + ".css"), a.base = a.name + a.ext;
|
133
|
+
const u = B(a);
|
134
|
+
if (await y(u, "utf-8").catch(() => {
|
135
|
+
}) !== void 0) {
|
136
|
+
t.error("File already exists:", u);
|
137
|
+
return;
|
138
|
+
}
|
139
|
+
t.info("Generating a new file: " + u);
|
140
|
+
const $ = R(d || a.base.replace(/\.css\.\w+$/, "")), { content: C } = await h("react/react-styled-file.ts", { tag: f, name: $, className: P });
|
141
|
+
await w(u, C), await J(u);
|
142
|
+
}), e.command("update").alias("up").description("Update Salty-CSS packages to the latest version.").option("--legacy-peer-deps <legacyPeerDeps>", "Use legacy peer dependencies (not recommended).", !1).action(async function(i, s = N) {
|
143
|
+
const { legacyPeerDeps: l } = this.opts(), p = o(process.cwd(), "package.json"), f = await F(p).catch((r) => j(r));
|
144
|
+
if (!f) return;
|
145
|
+
const d = { ...f.dependencies, ...f.devDependencies }, P = Object.keys(d).filter((r) => r === "salty-css" || r.startsWith("@salty-css/"));
|
146
|
+
if (!P.length)
|
147
|
+
return j(
|
148
|
+
"No Salty-CSS packages found in package.json. Make sure you are running update command in the same directory! Used package.json path: " + p
|
149
|
+
);
|
150
|
+
const v = P.map((r) => `${r}@${k.version}`);
|
151
|
+
l ? (t.warn("Using legacy peer dependencies to update packages."), await x(...v, "--legacy-peer-deps")) : await x(...v), t.info("Salty-CSS packages updated successfully!");
|
152
|
+
}), e.parseAsync(process.argv);
|
153
|
+
}
|
154
|
+
export {
|
155
|
+
dt as main
|
156
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function formatWithPrettier(filePath: string): Promise<void>;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("esbuild"),B=require("child_process"),P=require("../dash-case-DKzpenwY.cjs"),o=require("path"),r=require("fs"),K=require("fs/promises"),V=require("../parse-templates-W0YfTmOT.cjs");function G(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const R=G(z),N=t=>o.join(t,"./saltygen"),_=["salty","css","styles","styled"],q=(t=[])=>new RegExp(`\\.(${[..._,...t].join("|")})\\.`),O=(t,e=[])=>q(e).test(t),J=async t=>{const e=N(t),n=o.join(t,"salty.config.ts"),s=o.join(e,"salty.config.js");await R.build({entryPoints:[n],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:"esm",external:["react"]});const a=Date.now(),{config:w}=await import(`${s}?t=${a}`);return w},M=async t=>{const e=await J(t),n=new Set,s=(d,y=[])=>d?Object.entries(d).flatMap(([p,c])=>{if(!c)return;if(typeof c=="object")return s(c,[...y,p]);const C=[...y,p].join(".");n.add(`"${C}"`);const x=[...y.map(P.dashCase),P.dashCase(p)].join("-"),{result:D}=V.parseValueTokens(c);return`--${x}: ${D};`}):[],a=d=>d?Object.entries(d).flatMap(([y,p])=>{const c=s(p);return y==="base"?c.join(""):`${y} { ${c.join("")} }`}):[],w=d=>d?Object.entries(d).flatMap(([y,p])=>Object.entries(p).flatMap(([c,C])=>{const x=s(C,[y]),D=`.${y}-${c}, [data-${y}="${c}"]`,k=x.join("");return`${D} { ${k} }`})):[],j=s(e.variables),S=a(e.responsiveVariables),l=w(e.conditionalVariables),b=N(t),f=o.join(b,"css/variables.css"),i=`:root { ${j.join("")} ${S.join("")} } ${l.join("")}`;r.writeFileSync(f,i);const g=o.join(b,"types/css-tokens.d.ts"),m=`type VariableTokens = ${[...n].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;r.writeFileSync(g,m);const u=o.join(b,"css/global.css"),h=V.parseStyles(e.global,"");r.writeFileSync(u,h);const F=o.join(b,"css/templates.css"),v=V.parseTemplates(e.templates);r.writeFileSync(F,v)},T=async(t,e)=>{const n=P.toHash(t),s=o.join(e,"js",n+".js");await R.build({entryPoints:[t],minify:!0,treeShaking:!0,bundle:!0,outfile:s,format:"esm",target:["es2022"],keepNames:!0,external:["react"]});const a=Date.now();return await import(`${s}?t=${a}`)},E=async t=>{const e=N(t),n=o.join(e,"salty.config.js"),{config:s}=await import(n);return s},A=async t=>{try{const e=[],n=[],s=N(t),a=o.join(s,"index.css");(()=>{r.existsSync(s)&&B.execSync("rm -rf "+s),r.mkdirSync(s),r.mkdirSync(o.join(s,"css")),r.mkdirSync(o.join(s,"types"))})(),await M(t);const j=await E(t);async function S(i,g){const $=r.statSync(i);if($.isDirectory()){const m=r.readdirSync(i);await Promise.all(m.map(u=>S(o.join(i,u),o.join(g,u))))}else if($.isFile()&&O(i)){const u=await T(i,s),h=[];Object.entries(u).forEach(([y,p])=>{if(p.isKeyframes&&p.css){const k=`${p.animationName}.css`,H=`css/${k}`,I=o.join(s,H);e.push(k),r.writeFileSync(I,p.css);return}if(!p.generator)return;const c=p.generator._withBuildContext({name:y,config:j}),C=`${c.hash}-${c.priority}.css`;n[c.priority]||(n[c.priority]=[]),n[c.priority].push(C),h.push(C);const x=`css/${C}`,D=o.join(s,x);r.writeFileSync(D,c.css)});const F=h.map(y=>`@import url('./${y}');`).join(`
|
2
|
+
`),v=P.toHash(i,6),d=o.join(s,`css/${v}.css`);r.writeFileSync(d,F)}}await S(t,s);const l=e.map(i=>`@import url('./css/${i}');`).join(`
|
3
|
+
`);let f=`@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
4
|
+
|
5
|
+
${["@import url('./css/variables.css');","@import url('./css/global.css');","@import url('./css/templates.css');"].join(`
|
6
|
+
`)}
|
7
|
+
${l}`;if(j.importStrategy!=="component"){const i=n.flat().map(g=>`@import url('./css/${g}');`).join(`
|
8
|
+
`);f+=i}r.writeFileSync(a,f)}catch(e){console.error(e)}},L=async(t,e)=>{try{const n=[],s=o.join(t,"./saltygen"),a=o.join(s,"index.css");if(O(e)){const j=await E(t),S=await T(e,s);Object.entries(S).forEach(([g,$])=>{if(!$.generator)return;const m=$.generator._withBuildContext({name:g,config:j}),u=`${m.hash}-${m.priority}.css`,h=`css/${u}`,F=o.join(s,h);n.push(u),r.writeFileSync(F,m.css)});const l=r.readFileSync(a,"utf8").split(`
|
9
|
+
`),b=n.map(g=>`@import url('../saltygen/css/${g}');`),i=[...new Set([...l,...b])].join(`
|
10
|
+
`);r.writeFileSync(a,i)}}catch(n){console.error(n)}},U=async(t,e)=>{try{const n=o.join(t,"./saltygen");if(O(e)){const a=r.readFileSync(e,"utf8");a.replace(/^(?!export\s)const\s.*/gm,f=>`export ${f}`)!==a&&await K.writeFile(e,a);const j=await E(t),S=await T(e,n);let l=a;Object.entries(S).forEach(([f,i])=>{var F;if(i.isKeyframes){console.log("value",i);return}if(!i.generator)return;const g=i.generator._withBuildContext({name:f,config:j}),$=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),`,"g").exec(a);if(!$)return console.error("Could not find the original declaration");const m=(F=$.at(1))==null?void 0:F.trim(),u=`${f} = styled(${m}, "${g.classNames}", "${g._callerName}", ${JSON.stringify(g.props)});`,h=new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`,"g");l=l.replace(h,u)});const b=P.toHash(e,6);return j.importStrategy==="component"&&(l=`import '../../saltygen/css/${b}.css';
|
11
|
+
${l}`),l=l.replace("{ styled }","{ styledClient as styled }"),l=l.replace("@salty-css/react/styled","@salty-css/react/styled-client"),l}}catch(n){console.error(n)}};exports.compileSaltyFile=T;exports.generateConfigStyles=M;exports.generateCss=A;exports.generateFile=L;exports.isSaltyFile=O;exports.minimizeFile=U;exports.saltyFileExtensions=_;exports.saltyFileRegExp=q;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { StyleComponentGenerator } from '../generator/style-generator';
|
2
|
-
|
3
|
-
export declare const
|
4
|
-
export declare const isSaltyFile: (file: string) => boolean;
|
5
|
-
export declare const
|
2
|
+
export declare const saltyFileExtensions: string[];
|
3
|
+
export declare const saltyFileRegExp: (additional?: string[]) => RegExp;
|
4
|
+
export declare const isSaltyFile: (file: string, additional?: string[]) => boolean;
|
5
|
+
export declare const generateConfigStyles: (dirname: string) => Promise<void>;
|
6
6
|
export declare const compileSaltyFile: (sourceFilePath: string, outputDirectory: string) => Promise<{
|
7
7
|
[key: string]: {
|
8
8
|
generator: StyleComponentGenerator;
|
@@ -0,0 +1,174 @@
|
|
1
|
+
import * as I from "esbuild";
|
2
|
+
import { execSync as H } from "child_process";
|
3
|
+
import { t as T, d as R } from "../dash-case-DMQMcCO6.js";
|
4
|
+
import { join as o } from "path";
|
5
|
+
import { writeFileSync as $, existsSync as K, mkdirSync as V, statSync as z, readdirSync as G, readFileSync as M } from "fs";
|
6
|
+
import { writeFile as J } from "fs/promises";
|
7
|
+
import { p as q, a as A, b as L } from "../parse-templates-D4p3pgQR.js";
|
8
|
+
const N = (s) => o(s, "./saltygen"), U = ["salty", "css", "styles", "styled"], W = (s = []) => new RegExp(`\\.(${[...U, ...s].join("|")})\\.`), v = (s, e = []) => W(e).test(s), X = async (s) => {
|
9
|
+
const e = N(s), n = o(s, "salty.config.ts"), t = o(e, "salty.config.js");
|
10
|
+
await I.build({
|
11
|
+
entryPoints: [n],
|
12
|
+
minify: !0,
|
13
|
+
treeShaking: !0,
|
14
|
+
bundle: !0,
|
15
|
+
outfile: t,
|
16
|
+
format: "esm",
|
17
|
+
external: ["react"]
|
18
|
+
});
|
19
|
+
const c = Date.now(), { config: S } = await import(`${t}?t=${c}`);
|
20
|
+
return S;
|
21
|
+
}, Y = async (s) => {
|
22
|
+
const e = await X(s), n = /* @__PURE__ */ new Set(), t = (u, l = []) => u ? Object.entries(u).flatMap(([p, r]) => {
|
23
|
+
if (!r) return;
|
24
|
+
if (typeof r == "object") return t(r, [...l, p]);
|
25
|
+
const x = [...l, p].join(".");
|
26
|
+
n.add(`"${x}"`);
|
27
|
+
const C = [...l.map(R), R(p)].join("-"), { result: D } = L(r);
|
28
|
+
return `--${C}: ${D};`;
|
29
|
+
}) : [], c = (u) => u ? Object.entries(u).flatMap(([l, p]) => {
|
30
|
+
const r = t(p);
|
31
|
+
return l === "base" ? r.join("") : `${l} { ${r.join("")} }`;
|
32
|
+
}) : [], S = (u) => u ? Object.entries(u).flatMap(([l, p]) => Object.entries(p).flatMap(([r, x]) => {
|
33
|
+
const C = t(x, [l]), D = `.${l}-${r}, [data-${l}="${r}"]`, P = C.join("");
|
34
|
+
return `${D} { ${P} }`;
|
35
|
+
})) : [], d = t(e.variables), w = c(e.responsiveVariables), a = S(e.conditionalVariables), b = N(s), f = o(b, "css/variables.css"), i = `:root { ${d.join("")} ${w.join("")} } ${a.join("")}`;
|
36
|
+
$(f, i);
|
37
|
+
const y = o(b, "types/css-tokens.d.ts"), m = `type VariableTokens = ${[...n].join("|")}; type PropertyValueToken = \`{\${VariableTokens}}\``;
|
38
|
+
$(y, m);
|
39
|
+
const g = o(b, "css/global.css"), F = q(e.global, "");
|
40
|
+
$(g, F);
|
41
|
+
const j = o(b, "css/templates.css"), k = A(e.templates);
|
42
|
+
$(j, k);
|
43
|
+
}, E = async (s, e) => {
|
44
|
+
const n = T(s), t = o(e, "js", n + ".js");
|
45
|
+
await I.build({
|
46
|
+
entryPoints: [s],
|
47
|
+
minify: !0,
|
48
|
+
treeShaking: !0,
|
49
|
+
bundle: !0,
|
50
|
+
outfile: t,
|
51
|
+
format: "esm",
|
52
|
+
target: ["es2022"],
|
53
|
+
keepNames: !0,
|
54
|
+
external: ["react"]
|
55
|
+
});
|
56
|
+
const c = Date.now();
|
57
|
+
return await import(`${t}?t=${c}`);
|
58
|
+
}, O = async (s) => {
|
59
|
+
const e = N(s), n = o(e, "salty.config.js"), { config: t } = await import(n);
|
60
|
+
return t;
|
61
|
+
}, ot = async (s) => {
|
62
|
+
try {
|
63
|
+
const e = [], n = [], t = N(s), c = o(t, "index.css");
|
64
|
+
(() => {
|
65
|
+
K(t) && H("rm -rf " + t), V(t), V(o(t, "css")), V(o(t, "types"));
|
66
|
+
})(), await Y(s);
|
67
|
+
const d = await O(s);
|
68
|
+
async function w(i, y) {
|
69
|
+
const h = z(i);
|
70
|
+
if (h.isDirectory()) {
|
71
|
+
const m = G(i);
|
72
|
+
await Promise.all(m.map((g) => w(o(i, g), o(y, g))));
|
73
|
+
} else if (h.isFile() && v(i)) {
|
74
|
+
const g = await E(i, t), F = [];
|
75
|
+
Object.entries(g).forEach(([l, p]) => {
|
76
|
+
if (p.isKeyframes && p.css) {
|
77
|
+
const P = `${p.animationName}.css`, _ = `css/${P}`, B = o(t, _);
|
78
|
+
e.push(P), $(B, p.css);
|
79
|
+
return;
|
80
|
+
}
|
81
|
+
if (!p.generator) return;
|
82
|
+
const r = p.generator._withBuildContext({
|
83
|
+
name: l,
|
84
|
+
config: d
|
85
|
+
}), x = `${r.hash}-${r.priority}.css`;
|
86
|
+
n[r.priority] || (n[r.priority] = []), n[r.priority].push(x), F.push(x);
|
87
|
+
const C = `css/${x}`, D = o(t, C);
|
88
|
+
$(D, r.css);
|
89
|
+
});
|
90
|
+
const j = F.map((l) => `@import url('./${l}');`).join(`
|
91
|
+
`), k = T(i, 6), u = o(t, `css/${k}.css`);
|
92
|
+
$(u, j);
|
93
|
+
}
|
94
|
+
}
|
95
|
+
await w(s, t);
|
96
|
+
const a = e.map((i) => `@import url('./css/${i}');`).join(`
|
97
|
+
`);
|
98
|
+
let f = `@layer l0, l1, l2, l3, l4, l5, l6, l7, l8;
|
99
|
+
|
100
|
+
${["@import url('./css/variables.css');", "@import url('./css/global.css');", "@import url('./css/templates.css');"].join(`
|
101
|
+
`)}
|
102
|
+
${a}`;
|
103
|
+
if (d.importStrategy !== "component") {
|
104
|
+
const i = n.flat().map((y) => `@import url('./css/${y}');`).join(`
|
105
|
+
`);
|
106
|
+
f += i;
|
107
|
+
}
|
108
|
+
$(c, f);
|
109
|
+
} catch (e) {
|
110
|
+
console.error(e);
|
111
|
+
}
|
112
|
+
}, it = async (s, e) => {
|
113
|
+
try {
|
114
|
+
const n = [], t = o(s, "./saltygen"), c = o(t, "index.css");
|
115
|
+
if (v(e)) {
|
116
|
+
const d = await O(s), w = await E(e, t);
|
117
|
+
Object.entries(w).forEach(([y, h]) => {
|
118
|
+
if (!h.generator) return;
|
119
|
+
const m = h.generator._withBuildContext({
|
120
|
+
name: y,
|
121
|
+
config: d
|
122
|
+
}), g = `${m.hash}-${m.priority}.css`, F = `css/${g}`, j = o(t, F);
|
123
|
+
n.push(g), $(j, m.css);
|
124
|
+
});
|
125
|
+
const a = M(c, "utf8").split(`
|
126
|
+
`), b = n.map((y) => `@import url('../saltygen/css/${y}');`), i = [.../* @__PURE__ */ new Set([...a, ...b])].join(`
|
127
|
+
`);
|
128
|
+
$(c, i);
|
129
|
+
}
|
130
|
+
} catch (n) {
|
131
|
+
console.error(n);
|
132
|
+
}
|
133
|
+
}, rt = async (s, e) => {
|
134
|
+
try {
|
135
|
+
const n = o(s, "./saltygen");
|
136
|
+
if (v(e)) {
|
137
|
+
const c = M(e, "utf8");
|
138
|
+
c.replace(/^(?!export\s)const\s.*/gm, (f) => `export ${f}`) !== c && await J(e, c);
|
139
|
+
const d = await O(s), w = await E(e, n);
|
140
|
+
let a = c;
|
141
|
+
Object.entries(w).forEach(([f, i]) => {
|
142
|
+
var j;
|
143
|
+
if (i.isKeyframes) {
|
144
|
+
console.log("value", i);
|
145
|
+
return;
|
146
|
+
}
|
147
|
+
if (!i.generator) return;
|
148
|
+
const y = i.generator._withBuildContext({
|
149
|
+
name: f,
|
150
|
+
config: d
|
151
|
+
}), h = new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),`, "g").exec(c);
|
152
|
+
if (!h)
|
153
|
+
return console.error("Could not find the original declaration");
|
154
|
+
const m = (j = h.at(1)) == null ? void 0 : j.trim(), g = `${f} = styled(${m}, "${y.classNames}", "${y._callerName}", ${JSON.stringify(y.props)});`, F = new RegExp(`${f}[=\\s]+[^()]+styled\\(([^,]+),[^;]+;`, "g");
|
155
|
+
a = a.replace(F, g);
|
156
|
+
});
|
157
|
+
const b = T(e, 6);
|
158
|
+
return d.importStrategy === "component" && (a = `import '../../saltygen/css/${b}.css';
|
159
|
+
${a}`), a = a.replace("{ styled }", "{ styledClient as styled }"), a = a.replace("@salty-css/react/styled", "@salty-css/react/styled-client"), a;
|
160
|
+
}
|
161
|
+
} catch (n) {
|
162
|
+
console.error(n);
|
163
|
+
}
|
164
|
+
};
|
165
|
+
export {
|
166
|
+
E as compileSaltyFile,
|
167
|
+
Y as generateConfigStyles,
|
168
|
+
ot as generateCss,
|
169
|
+
it as generateFile,
|
170
|
+
v as isSaltyFile,
|
171
|
+
rt as minimizeFile,
|
172
|
+
U as saltyFileExtensions,
|
173
|
+
W as saltyFileRegExp
|
174
|
+
};
|
@@ -30,11 +30,11 @@ export interface SaltyConfig {
|
|
30
30
|
* - `root` will import the css file from the root of the project.
|
31
31
|
* - `component` will import the css file from the component's directory.
|
32
32
|
*/
|
33
|
-
importStrategy
|
33
|
+
importStrategy?: 'root' | 'component';
|
34
34
|
/**
|
35
35
|
* Base variables that can be used in all styles as they are applied globally to :root.
|
36
36
|
*/
|
37
|
-
variables
|
37
|
+
variables?: CssVariables;
|
38
38
|
/**
|
39
39
|
* Variables that are defined for different media queries.
|
40
40
|
*/
|
@@ -46,7 +46,7 @@ export interface SaltyConfig {
|
|
46
46
|
/**
|
47
47
|
* The global styles that are imported in the root of the project.
|
48
48
|
*/
|
49
|
-
global
|
49
|
+
global?: CssStyles;
|
50
50
|
/**
|
51
51
|
* The templates that can be used in styles to create reusable css.
|
52
52
|
*/
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";const n=e=>String.fromCharCode(e+(e>25?39:97)),i=(e,r)=>{let t="",a;for(a=Math.abs(e);a>52;a=a/52|0)t=n(a%52)+t;return t=n(a%52)+t,t.length<r?t=t.padStart(r,"a"):t.length>r&&(t=t.slice(-r)),t},o=(e,r)=>{let t=r.length;for(;t;)e=e*33^r.charCodeAt(--t);return e},c=(e,r=3)=>{const t=o(5381,JSON.stringify(e))>>>0;return i(t,r)};function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/\s/g,"-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g,(r,t)=>(t>0?"-":"")+r.toLowerCase()):""}exports.dashCase=s;exports.toHash=c;
|
@@ -6,14 +6,14 @@ const n = (e) => String.fromCharCode(e + (e > 25 ? 39 : 97)), o = (e, r) => {
|
|
6
6
|
let t = r.length;
|
7
7
|
for (; t; ) e = e * 33 ^ r.charCodeAt(--t);
|
8
8
|
return e;
|
9
|
-
},
|
9
|
+
}, c = (e, r = 3) => {
|
10
10
|
const t = i(5381, JSON.stringify(e)) >>> 0;
|
11
11
|
return o(t, r);
|
12
12
|
};
|
13
|
-
function
|
14
|
-
return e ? typeof e != "string" ? String(e) : e.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, t) => (t > 0 ? "-" : "") + r.toLowerCase()) : "";
|
13
|
+
function s(e) {
|
14
|
+
return e ? typeof e != "string" ? s(String(e)) : e.replace(/\s/g, "-").replace(/[A-Z](?:(?=[^A-Z])|[A-Z]*(?=[A-Z][^A-Z]|$))/g, (r, t) => (t > 0 ? "-" : "") + r.toLowerCase()) : "";
|
15
15
|
}
|
16
16
|
export {
|
17
|
-
|
18
|
-
|
17
|
+
s as d,
|
18
|
+
c as t
|
19
19
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";var m=Object.defineProperty;var l=(a,t,s)=>t in a?m(a,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[t]=s;var c=(a,t,s)=>l(a,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../dash-case-DKzpenwY.cjs"),p=require("../parse-templates-W0YfTmOT.cjs");class g{constructor(t,s){c(this,"_callerName");c(this,"_context");this.tagName=t,this.params=s}get hash(){return u.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 templateKeys(){var t;return(t=this._context)!=null&&t.config.templates?p.getTemplateKeys(this._context.config.templates):[]}get css(){var e;const{base:t={},variants:s={},compoundVariants:r=[]}=this.params,i={...t,variants:s,compoundVariants:r};return p.parseStyles(i,`.${this.cssClassName}`,this.priority,(e=this._context)==null?void 0:e.config)}get props(){const{element:t}=this.params,s=this.params.variants?Object.keys(this.params.variants).map(e=>{var n;const o=(n=this.params.defaultVariants)==null?void 0:n[e];return o!==void 0?`${e}=${String(o)}`:e}):void 0,r=new Set([]),i=/\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));return i&&i.forEach((e,o,n)=>{const h=n.at(1);h&&r.add(h)}),{element:t,variantKeys:s,propValueKeys:[...r]}}_withBuildContext(t){this._context=t;const{name:s,config:r}=t;return this._callerName=s,this}}exports.StyleComponentGenerator=g;
|
@@ -0,0 +1,61 @@
|
|
1
|
+
var h = Object.defineProperty;
|
2
|
+
var m = (e, t, s) => t in e ? h(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
3
|
+
var c = (e, t, s) => m(e, typeof t != "symbol" ? t + "" : t, s);
|
4
|
+
import { t as l } from "../dash-case-DMQMcCO6.js";
|
5
|
+
import { g, p as u } from "../parse-templates-D4p3pgQR.js";
|
6
|
+
class d {
|
7
|
+
constructor(t, s) {
|
8
|
+
c(this, "_callerName");
|
9
|
+
c(this, "_context");
|
10
|
+
this.tagName = t, this.params = s;
|
11
|
+
}
|
12
|
+
get hash() {
|
13
|
+
return l(this.params.base || this.params);
|
14
|
+
}
|
15
|
+
get priority() {
|
16
|
+
var t;
|
17
|
+
return typeof this.tagName == "function" || typeof this.tagName == "object" ? (((t = this.tagName.generator) == null ? void 0 : t.priority) || 0) + 1 : 0;
|
18
|
+
}
|
19
|
+
get classNames() {
|
20
|
+
const t = [this.hash], { className: s } = this.params;
|
21
|
+
return s && t.push(s), t.join(" ");
|
22
|
+
}
|
23
|
+
get cssClassName() {
|
24
|
+
return this.hash;
|
25
|
+
}
|
26
|
+
get cssDisplayNameVar() {
|
27
|
+
return `--${this.hash}-display-name: ${this._callerName};`;
|
28
|
+
}
|
29
|
+
get templateKeys() {
|
30
|
+
var t;
|
31
|
+
return (t = this._context) != null && t.config.templates ? g(this._context.config.templates) : [];
|
32
|
+
}
|
33
|
+
get css() {
|
34
|
+
var a;
|
35
|
+
const { base: t = {}, variants: s = {}, compoundVariants: r = [] } = this.params, i = { ...t, variants: s, compoundVariants: r };
|
36
|
+
return u(i, `.${this.cssClassName}`, this.priority, (a = this._context) == null ? void 0 : a.config);
|
37
|
+
}
|
38
|
+
get props() {
|
39
|
+
const { element: t } = this.params, s = this.params.variants ? Object.keys(this.params.variants).map((a) => {
|
40
|
+
var n;
|
41
|
+
const o = (n = this.params.defaultVariants) == null ? void 0 : n[a];
|
42
|
+
return o !== void 0 ? `${a}=${String(o)}` : a;
|
43
|
+
}) : void 0, r = /* @__PURE__ */ new Set([]), i = /\{props\.([\w\d]+)\}/gi.exec(JSON.stringify(this.params.base));
|
44
|
+
return i && i.forEach((a, o, n) => {
|
45
|
+
const p = n.at(1);
|
46
|
+
p && r.add(p);
|
47
|
+
}), {
|
48
|
+
element: t,
|
49
|
+
variantKeys: s,
|
50
|
+
propValueKeys: [...r]
|
51
|
+
};
|
52
|
+
}
|
53
|
+
_withBuildContext(t) {
|
54
|
+
this._context = t;
|
55
|
+
const { name: s, config: r } = t;
|
56
|
+
return this._callerName = s, this;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
export {
|
60
|
+
d as StyleComponentGenerator
|
61
|
+
};
|
@@ -1,14 +1,18 @@
|
|
1
|
-
import {
|
1
|
+
import { StyledParams, Tag } from '../types';
|
2
|
+
export interface GeneratorProps {
|
3
|
+
element?: string;
|
4
|
+
variantKeys?: string[];
|
5
|
+
propValueKeys?: string[];
|
6
|
+
}
|
2
7
|
export declare class StyleComponentGenerator {
|
3
8
|
tagName: Tag<any>;
|
4
|
-
|
5
|
-
private options;
|
9
|
+
params: StyledParams;
|
6
10
|
_callerName: string | undefined;
|
7
11
|
_context: {
|
8
12
|
name: string;
|
9
13
|
config: any;
|
10
14
|
} | undefined;
|
11
|
-
constructor(tagName: Tag<any>,
|
15
|
+
constructor(tagName: Tag<any>, params: StyledParams);
|
12
16
|
get hash(): string;
|
13
17
|
get priority(): number;
|
14
18
|
get classNames(): string;
|
@@ -16,10 +20,7 @@ export declare class StyleComponentGenerator {
|
|
16
20
|
get cssDisplayNameVar(): string;
|
17
21
|
get templateKeys(): string[];
|
18
22
|
get css(): string;
|
19
|
-
get props():
|
20
|
-
element: string | undefined;
|
21
|
-
variantKeys: string[] | undefined;
|
22
|
-
};
|
23
|
+
get props(): GeneratorProps;
|
23
24
|
_withBuildContext(context: {
|
24
25
|
name: string;
|
25
26
|
config: any;
|
@@ -0,0 +1 @@
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="/* Empty */";exports.default=e;
|