@salty-css/core 0.0.1-alpha.13 → 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/.saltyrc.schema.json +40 -0
- package/README.md +143 -26
- 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 +11 -0
- package/bin/main.d.ts +1 -0
- package/bin/main.js +260 -0
- package/bin/prettier.d.ts +1 -0
- package/compiler/get-files.d.ts +3 -0
- package/compiler/index.cjs +1 -11
- package/compiler/index.d.ts +4 -6
- package/compiler/index.js +16 -180
- package/config/config-types.d.ts +15 -5
- package/dash-case-BJEkFEGQ.cjs +1 -0
- package/dash-case-DBThphLm.js +19 -0
- package/generator/index.cjs +1 -1
- package/generator/index.js +40 -17
- package/generator/parse-templates.d.ts +2 -0
- package/generator/style-generator.d.ts +14 -4
- package/index-84Wroia-.cjs +1 -0
- package/index-AXVHdDqw.js +305 -0
- package/index-D2QOtfTb.cjs +21 -0
- package/index-D_732b92.js +4 -0
- package/package.json +20 -2
- package/parse-templates-DdYSw-iq.cjs +8 -0
- package/parse-templates-DnLWJ7Hc.js +100 -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/react-vanilla-file-CCXbsjIb.js +18 -0
- package/react-vanilla-file-CG_WJLam.cjs +15 -0
- package/salty.config-BhBY_oOk.js +10 -0
- package/salty.config-Dk6ZcCxI.cjs +7 -0
- package/templates/salty-reset.d.ts +2 -0
- package/types/index.d.ts +48 -21
- package/util/camel-case.d.ts +1 -0
- package/util/dot-case.d.ts +1 -0
- package/util/index.cjs +1 -1
- package/util/index.d.ts +2 -0
- package/util/index.js +7 -15
- package/util/module-type.d.ts +1 -0
- package/util/pascal-case.d.ts +1 -0
- package/parse-templates-BOSK0Tb6.js +0 -90
- package/parse-templates-BY1Xai-_.cjs +0 -8
package/types/index.d.ts
CHANGED
@@ -1,32 +1,40 @@
|
|
1
|
-
import {
|
1
|
+
import { ReactNode } from 'react';
|
2
2
|
import { StyleComponentGenerator } from '../generator';
|
3
|
-
import { OrString } from './util-types';
|
3
|
+
import { NeverObj, OrAny, OrString } from './util-types';
|
4
|
+
import type * as CSS from 'csstype';
|
4
5
|
export type CreateElementProps = {
|
5
6
|
extend?: Tag<any>;
|
6
7
|
children?: ReactNode;
|
7
8
|
className?: string;
|
8
9
|
element?: string;
|
9
|
-
|
10
|
-
style?:
|
10
|
+
passProps?: boolean | string | string[];
|
11
|
+
style?: CssProperties | {
|
12
|
+
[key: string]: PropertyValueToken | NeverObj;
|
13
|
+
};
|
11
14
|
/** vks = Variant key set */
|
12
15
|
_vks?: Set<string>;
|
13
16
|
};
|
14
|
-
export type StyledComponentProps = Record<string, unknown> & CreateElementProps
|
17
|
+
export type StyledComponentProps = Record<string, unknown> & CreateElementProps;
|
15
18
|
type FnComponent<PROPS extends StyledComponentProps> = {
|
16
|
-
(props: PROPS): ReactNode;
|
19
|
+
(props: OrAny | PROPS): ReactNode;
|
17
20
|
generator?: StyleComponentGenerator;
|
18
21
|
};
|
19
|
-
export type Tag<PROPS extends StyledComponentProps> = OrString | keyof
|
20
|
-
|
21
|
-
|
22
|
-
|
22
|
+
export type Tag<PROPS extends StyledComponentProps> = OrString | keyof HTMLElementTagNameMap | FnComponent<PROPS>;
|
23
|
+
type CSSPropertyValueFunction = (params?: any) => any;
|
24
|
+
export type CssProperties = {
|
25
|
+
[key in keyof CSS.Properties]: CSS.Properties[key] | PropertyValueToken | CSSPropertyValueFunction | NeverObj;
|
23
26
|
};
|
24
|
-
type
|
25
|
-
type
|
26
|
-
|
27
|
+
type CssPropertyKeys = keyof CssProperties;
|
28
|
+
export type StyleValue<K extends string> = K extends CssPropertyKeys ? CssProperties[K] : never;
|
29
|
+
type InvalidVariantKeys = '' | 'css';
|
27
30
|
type VariantOptions = {
|
28
31
|
[key in InvalidVariantKeys]?: never;
|
29
32
|
};
|
33
|
+
export type CompoundVariant = {
|
34
|
+
[key: PropertyKey]: string | boolean | undefined;
|
35
|
+
} | {
|
36
|
+
css: CssStyles;
|
37
|
+
};
|
30
38
|
type Variants = {
|
31
39
|
variants?: VariantOptions & {
|
32
40
|
[key: PropertyKey]: {
|
@@ -38,25 +46,44 @@ type Variants = {
|
|
38
46
|
};
|
39
47
|
compoundVariants?: CompoundVariant[];
|
40
48
|
};
|
41
|
-
type
|
42
|
-
|
43
|
-
|
49
|
+
type BooleanVariantValue = 'true' | 'false' | boolean;
|
50
|
+
type VariantPropValue<T> = T extends 'true' ? BooleanVariantValue : T extends 'false' ? BooleanVariantValue : T extends boolean ? BooleanVariantValue : T | '';
|
51
|
+
type PickType<T, K extends AllKeys<T>> = T extends {
|
52
|
+
[k in K]?: any;
|
53
|
+
} ? T[K] : undefined;
|
54
|
+
type AllKeys<T> = T extends any ? keyof T : never;
|
55
|
+
export type Merge<T> = {
|
56
|
+
[k in AllKeys<T>]?: PickType<T, k>;
|
44
57
|
};
|
45
|
-
export type
|
46
|
-
|
47
|
-
|
58
|
+
export type VariantProps<STYLES extends StyledParams, B = STYLES['variants'] extends undefined ? object : STYLES['variants'], C = STYLES['compoundVariants'] extends CompoundVariant[] ? Merge<STYLES['compoundVariants'][number]> : object> = Merge<{
|
59
|
+
[K in keyof B]?: K extends 'css' ? never : VariantPropValue<keyof B[K]>;
|
60
|
+
} | {
|
61
|
+
[K in keyof C]?: K extends 'css' ? never : VariantPropValue<C[K]>;
|
62
|
+
}>;
|
63
|
+
type CssValuePropKey = `props-${string}`;
|
64
|
+
export type ValueProps = {
|
65
|
+
[key: CssValuePropKey]: string;
|
48
66
|
};
|
67
|
+
export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : object;
|
49
68
|
type StylePropertyValue = Record<never, never> & unknown;
|
50
69
|
export type CssStyles = {
|
51
|
-
[key in
|
70
|
+
[key in OrString]?: CssProperties | StylePropertyValue | PropertyValueToken | TemplateTokens | CssStyles;
|
52
71
|
};
|
53
72
|
export type Styles = CssStyles & Variants;
|
54
73
|
export interface GeneratorOptions {
|
55
74
|
className?: string;
|
56
75
|
displayName?: string;
|
57
76
|
element?: string;
|
77
|
+
passProps?: boolean | string | string[];
|
78
|
+
defaultProps?: Record<PropertyKey, unknown>;
|
58
79
|
}
|
80
|
+
interface Base extends CssProperties, CssStyles, CssPseudos, TemplateTokens {
|
81
|
+
}
|
82
|
+
type Pseudos = CSS.Pseudos | `&${CSS.Pseudos}`;
|
83
|
+
type CssPseudos = {
|
84
|
+
[P in Pseudos]?: Base;
|
85
|
+
};
|
59
86
|
export interface StyledParams extends GeneratorOptions, Variants {
|
60
|
-
base?:
|
87
|
+
base?: Base;
|
61
88
|
}
|
62
89
|
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function camelCase(str: PropertyKey): string;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function dotCase(str: PropertyKey): string;
|
package/util/index.cjs
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../dash-case-BJEkFEGQ.cjs"),t=require("../pascal-case-iWoaJWwT.cjs");function s(e){return e?typeof e!="string"?s(String(e)):e.replace(/\s/g,"-").replace(/-([a-z])/g,r=>r[1].toUpperCase()):""}exports.dashCase=a.dashCase;exports.toHash=a.toHash;exports.pascalCase=t.pascalCase;exports.camelCase=s;
|
package/util/index.d.ts
CHANGED
package/util/index.js
CHANGED
@@ -1,19 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
return
|
5
|
-
}, i = (e, r) => {
|
6
|
-
let t = r.length;
|
7
|
-
for (; t; ) e = e * 33 ^ r.charCodeAt(--t);
|
8
|
-
return e;
|
9
|
-
}, s = (e, r = 3) => {
|
10
|
-
const t = i(5381, JSON.stringify(e)) >>> 0;
|
11
|
-
return o(t, r);
|
12
|
-
};
|
13
|
-
function c(e) {
|
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()) : "";
|
1
|
+
import { d as o, t as s } from "../dash-case-DBThphLm.js";
|
2
|
+
import { p as f } from "../pascal-case-BQpR5PdN.js";
|
3
|
+
function r(e) {
|
4
|
+
return e ? typeof e != "string" ? r(String(e)) : e.replace(/\s/g, "-").replace(/-([a-z])/g, (a) => a[1].toUpperCase()) : "";
|
15
5
|
}
|
16
6
|
export {
|
17
|
-
|
7
|
+
r as camelCase,
|
8
|
+
o as dashCase,
|
9
|
+
f as pascalCase,
|
18
10
|
s as toHash
|
19
11
|
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const detectCurrentModuleType: (dirname: string) => Promise<"esm" | "cjs">;
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare function pascalCase(str: PropertyKey): string;
|
@@ -1,90 +0,0 @@
|
|
1
|
-
import { dashCase as O } from "./util/index.js";
|
2
|
-
const N = (s, r) => {
|
3
|
-
if (typeof s != "string") return { result: s };
|
4
|
-
if (!r) return { result: s };
|
5
|
-
const e = [];
|
6
|
-
return Object.values(r).forEach((n) => {
|
7
|
-
const { pattern: o, transform: c } = n;
|
8
|
-
s = s.replace(o, (h) => {
|
9
|
-
const { value: i, css: m } = c(h);
|
10
|
-
return m && e.push(m), i;
|
11
|
-
});
|
12
|
-
}), { result: s, additionalCss: e };
|
13
|
-
}, P = (s) => typeof s != "string" ? { result: s } : /\{[^{}]+\}/g.test(s) ? { result: s.replace(/\{([^{}]+)\}/g, (...n) => `var(--${O(n[1].replaceAll(".", "-"))})`) } : { result: s }, d = (s, r, e, n) => {
|
14
|
-
const o = [], c = Object.entries(s).reduce((i, [m, t]) => {
|
15
|
-
const p = m.trim();
|
16
|
-
if (typeof t == "function" && (t = t()), typeof t == "object") {
|
17
|
-
if (!t) return i;
|
18
|
-
if (p === "variants")
|
19
|
-
return Object.entries(t).forEach(([u, f]) => {
|
20
|
-
f && Object.entries(f).forEach(([b, j]) => {
|
21
|
-
if (!j) return;
|
22
|
-
const l = `${r}.${u}-${b}`, y = d(j, l, e);
|
23
|
-
o.push(y);
|
24
|
-
});
|
25
|
-
}), i;
|
26
|
-
if (p === "defaultVariants")
|
27
|
-
return i;
|
28
|
-
if (p === "compoundVariants")
|
29
|
-
return t.forEach((u) => {
|
30
|
-
const { css: f, ...b } = u, j = Object.entries(b).reduce((y, [V, W]) => `${y}.${V}-${W}`, r), l = d(f, j, e);
|
31
|
-
o.push(l);
|
32
|
-
}), i;
|
33
|
-
if (p.startsWith("@")) {
|
34
|
-
const u = d(t, r, e), f = `${p} {
|
35
|
-
${u.replace(`
|
36
|
-
`, `
|
37
|
-
`)}
|
38
|
-
}`;
|
39
|
-
return o.push(f), i;
|
40
|
-
}
|
41
|
-
const $ = m.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, a = d(t, $, e);
|
42
|
-
return o.push(a), i;
|
43
|
-
}
|
44
|
-
if (n != null && n.templates && n.templates[p]) {
|
45
|
-
const a = t.split(".").reduce((f, b) => f[b], n.templates[p]), u = d(a, "");
|
46
|
-
return `${i}${u}`;
|
47
|
-
}
|
48
|
-
const g = p.startsWith("-") ? p : O(p), E = ($, a = ";") => i = `${i}${$}${a}`, S = ($) => E(`${g}:${$}`);
|
49
|
-
if (typeof t == "number") return S(t);
|
50
|
-
if (typeof t != "string")
|
51
|
-
if ("toString" in t) t = t.toString();
|
52
|
-
else return i;
|
53
|
-
const { modifiers: k } = n || {}, T = function* () {
|
54
|
-
yield P(t), yield N(t, k);
|
55
|
-
}();
|
56
|
-
for (const { result: $, additionalCss: a = [] } of T)
|
57
|
-
t = $, a.forEach((u) => {
|
58
|
-
const f = d(u, "");
|
59
|
-
E(f, "");
|
60
|
-
});
|
61
|
-
return S(t);
|
62
|
-
}, "");
|
63
|
-
if (!c) return o.join(`
|
64
|
-
`);
|
65
|
-
if (!r) return c;
|
66
|
-
let h = "";
|
67
|
-
return e !== void 0 ? h = `@layer l${e} { ${r} { ${c} } }` : h = `${r} { ${c} }`, [h, ...o].join(`
|
68
|
-
`);
|
69
|
-
}, _ = (s, r = []) => {
|
70
|
-
const e = [], n = {};
|
71
|
-
if (Object.entries(s).forEach(([o, c]) => {
|
72
|
-
if (typeof c == "object") {
|
73
|
-
if (!c) return;
|
74
|
-
const h = o.trim(), i = _(c, [...r, h]);
|
75
|
-
e.push(i);
|
76
|
-
} else
|
77
|
-
n[o] = c;
|
78
|
-
}), Object.keys(n).length) {
|
79
|
-
const o = r.map(O).join("-"), c = d(n, `.${o}`);
|
80
|
-
e.push(c);
|
81
|
-
}
|
82
|
-
return e.join(`
|
83
|
-
`);
|
84
|
-
}, A = (s) => Object.keys(s);
|
85
|
-
export {
|
86
|
-
_ as a,
|
87
|
-
P as b,
|
88
|
-
A as g,
|
89
|
-
d as p
|
90
|
-
};
|
@@ -1,8 +0,0 @@
|
|
1
|
-
"use strict";const O=require("./util/index.cjs"),K=(s,e)=>{if(typeof s!="string")return{result:s};if(!e)return{result:s};const r=[];return Object.values(e).forEach(n=>{const{pattern:o,transform:c}=n;s=s.replace(o,a=>{const{value:i,css:l}=c(a);return l&&r.push(l),i})}),{result:s,additionalCss:r}},k=s=>typeof s!="string"?{result:s}:/\{[^{}]+\}/g.test(s)?{result:s.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${O.dashCase(n[1].replaceAll(".","-"))})`)}:{result:s},h=(s,e,r,n)=>{const o=[],c=Object.entries(s).reduce((i,[l,t])=>{const p=l.trim();if(typeof t=="function"&&(t=t()),typeof t=="object"){if(!t)return i;if(p==="variants")return Object.entries(t).forEach(([u,f])=>{f&&Object.entries(f).forEach(([m,j])=>{if(!j)return;const y=`${e}.${u}-${m}`,b=h(j,y,r);o.push(b)})}),i;if(p==="defaultVariants")return i;if(p==="compoundVariants")return t.forEach(u=>{const{css:f,...m}=u,j=Object.entries(m).reduce((b,[_,q])=>`${b}.${_}-${q}`,e),y=h(f,j,r);o.push(y)}),i;if(p.startsWith("@")){const u=h(t,e,r),f=`${p} {
|
2
|
-
${u.replace(`
|
3
|
-
`,`
|
4
|
-
`)}
|
5
|
-
}`;return o.push(f),i}const $=l.includes("&")?p.replace("&",e):p.startsWith(":")?`${e}${p}`:`${e} ${p}`,d=h(t,$,r);return o.push(d),i}if(n!=null&&n.templates&&n.templates[p]){const d=t.split(".").reduce((f,m)=>f[m],n.templates[p]),u=h(d,"");return`${i}${u}`}const V=p.startsWith("-")?p:O.dashCase(p),T=($,d=";")=>i=`${i}${$}${d}`,S=$=>T(`${V}:${$}`);if(typeof t=="number")return S(t);if(typeof t!="string")if("toString"in t)t=t.toString();else return i;const{modifiers:g}=n||{},W=function*(){yield k(t),yield K(t,g)}();for(const{result:$,additionalCss:d=[]}of W)t=$,d.forEach(u=>{const f=h(u,"");T(f,"")});return S(t)},"");if(!c)return o.join(`
|
6
|
-
`);if(!e)return c;let a="";return r!==void 0?a=`@layer l${r} { ${e} { ${c} } }`:a=`${e} { ${c} }`,[a,...o].join(`
|
7
|
-
`)},E=(s,e=[])=>{const r=[],n={};if(Object.entries(s).forEach(([o,c])=>{if(typeof c=="object"){if(!c)return;const a=o.trim(),i=E(c,[...e,a]);r.push(i)}else n[o]=c}),Object.keys(n).length){const o=e.map(O.dashCase).join("-"),c=h(n,`.${o}`);r.push(c)}return r.join(`
|
8
|
-
`)},N=s=>Object.keys(s);exports.getTemplateKeys=N;exports.parseStyles=h;exports.parseTemplates=E;exports.parseValueTokens=k;
|