@salty-css/core 0.0.1-alpha.23 → 0.0.1-alpha.230

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.
Files changed (95) hide show
  1. package/.saltyrc.schema.json +48 -0
  2. package/README.md +463 -26
  3. package/bin/index.cjs +1 -8
  4. package/bin/index.js +2 -129
  5. package/bin/logger.d.ts +1 -0
  6. package/bin/main.cjs +11 -0
  7. package/bin/main.d.ts +1 -0
  8. package/bin/main.js +260 -0
  9. package/compiler/get-files.d.ts +3 -0
  10. package/compiler/get-function-range.d.ts +1 -0
  11. package/compiler/index.cjs +1 -11
  12. package/compiler/index.d.ts +19 -11
  13. package/compiler/index.js +18 -172
  14. package/config/define-config.d.ts +1 -1
  15. package/config/index.cjs +1 -1
  16. package/config/index.d.ts +2 -1
  17. package/config/index.js +12 -2
  18. package/css/index.cjs +1 -1
  19. package/css/index.d.ts +4 -1
  20. package/css/index.js +10 -2
  21. package/css/keyframes.cjs +1 -0
  22. package/css/keyframes.d.ts +22 -0
  23. package/css/keyframes.js +34 -0
  24. package/css/media.cjs +1 -0
  25. package/css/media.d.ts +87 -0
  26. package/css/media.js +88 -0
  27. package/css/merge.cjs +1 -0
  28. package/css/merge.d.ts +7 -0
  29. package/css/merge.js +5 -0
  30. package/css/token.cjs +1 -0
  31. package/css/token.d.ts +1 -0
  32. package/css/token.js +4 -0
  33. package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
  34. package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
  35. package/define-templates-4A2yHcMF.js +52 -0
  36. package/define-templates-Cunsb_Tr.cjs +1 -0
  37. package/factories/define-global-styles.d.ts +7 -0
  38. package/factories/define-media-query.d.ts +8 -0
  39. package/factories/define-templates.d.ts +27 -0
  40. package/factories/define-variables.d.ts +12 -0
  41. package/factories/index.d.ts +4 -0
  42. package/generators/class-name-generator.d.ts +6 -0
  43. package/generators/index.cjs +1 -0
  44. package/generators/index.d.ts +2 -0
  45. package/generators/index.js +86 -0
  46. package/generators/styled-generator.d.ts +19 -0
  47. package/generators/styles-generator.d.ts +22 -0
  48. package/helpers/color.d.ts +18 -0
  49. package/helpers/index.cjs +1 -0
  50. package/helpers/index.d.ts +2 -0
  51. package/helpers/index.js +1156 -0
  52. package/helpers/viewport-clamp.d.ts +8 -0
  53. package/index-CuYozIxT.js +507 -0
  54. package/index-q4N-TRZZ.cjs +38 -0
  55. package/package.json +34 -2
  56. package/parse-styles-3N79AOBO.cjs +5 -0
  57. package/parse-styles-Bo7fQ_SV.js +134 -0
  58. package/parsers/index.cjs +1 -0
  59. package/parsers/index.d.ts +5 -0
  60. package/parsers/index.js +30 -0
  61. package/parsers/parse-modifiers.d.ts +3 -0
  62. package/parsers/parse-styles.d.ts +13 -0
  63. package/parsers/parse-templates.d.ts +4 -0
  64. package/parsers/parse-tokens.d.ts +3 -0
  65. package/parsers/parser-types.d.ts +8 -0
  66. package/parsers/property-name-check.d.ts +1 -0
  67. package/parsers/unit-check.d.ts +7 -0
  68. package/react-vanilla-file-CCXbsjIb.js +18 -0
  69. package/react-vanilla-file-CG_WJLam.cjs +15 -0
  70. package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
  71. package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
  72. package/server/index.cjs +1 -0
  73. package/server/index.d.ts +1 -0
  74. package/server/index.js +12 -0
  75. package/server/should-restart.d.ts +1 -0
  76. package/templates/salty-reset.d.ts +2 -0
  77. package/types/cli-types.d.ts +10 -0
  78. package/types/config-types.d.ts +84 -0
  79. package/types/index.d.ts +53 -22
  80. package/util/dot-case.d.ts +1 -0
  81. package/util/index.cjs +1 -1
  82. package/util/index.js +1 -1
  83. package/util/module-type.d.ts +1 -0
  84. package/config/config-types.d.ts +0 -59
  85. package/generator/index.cjs +0 -1
  86. package/generator/index.d.ts +0 -1
  87. package/generator/index.js +0 -61
  88. package/generator/parse-modifiers.d.ts +0 -3
  89. package/generator/parse-styles.d.ts +0 -2
  90. package/generator/parse-templates.d.ts +0 -2
  91. package/generator/parse-tokens.d.ts +0 -2
  92. package/generator/parser-types.d.ts +0 -4
  93. package/generator/style-generator.d.ts +0 -28
  94. package/parse-templates-D4p3pgQR.js +0 -92
  95. package/parse-templates-W0YfTmOT.cjs +0 -8
@@ -0,0 +1,134 @@
1
+ import { d as V } from "./dash-case-DBThphLm.js";
2
+ const M = (o) => (e) => {
3
+ if (typeof e != "string" || !o) return;
4
+ let t = e;
5
+ const p = [];
6
+ return Object.values(o).forEach((n) => {
7
+ const { pattern: b, transform: y } = n;
8
+ t = t.replace(b, (C) => {
9
+ const { value: O, css: E } = y(C);
10
+ return E && p.push(E), O;
11
+ });
12
+ }), { transformed: t, additionalCss: p };
13
+ }, z = (o) => (e) => typeof e != "string" || !/\{[^{}]+\}/g.test(e) ? void 0 : { transformed: e.replace(/\{([^{}]+)\}/g, (...n) => `var(--${V(n[1].replaceAll(".", "-"))})`) }, B = z(), Q = [
14
+ "top",
15
+ "right",
16
+ "bottom",
17
+ "left",
18
+ "min-width",
19
+ /.*width.*/,
20
+ /^[^line]*height.*/,
21
+ // Exclude line-height
22
+ /padding.*/,
23
+ /margin.*/,
24
+ /border.*/,
25
+ /inset.*/,
26
+ /.*radius.*/,
27
+ /.*spacing.*/,
28
+ /.*gap.*/,
29
+ /.*indent.*/,
30
+ /.*offset.*/,
31
+ /.*size.*/,
32
+ /.*thickness.*/,
33
+ /.*font-size.*/
34
+ ], _ = (o, e, t) => {
35
+ if (Q.some((n) => typeof n == "string" ? n === o : n.test(o))) {
36
+ const n = (t == null ? void 0 : t.defaultUnit) || "px";
37
+ return `${e}${n}`;
38
+ }
39
+ return `${e}`;
40
+ }, k = ["Webkit", "Moz", "ms", "O"], q = (o) => o.startsWith("-") ? o : k.some((e) => o.startsWith(e)) ? `-${V(o)}` : V(o), $ = async (o, e = "", t, p = !1) => {
41
+ if (!o) throw new Error("No styles provided to parseStyles function!");
42
+ const n = /* @__PURE__ */ new Set(), b = Object.entries(o), y = async ([u, s]) => {
43
+ var j;
44
+ const r = u.trim(), w = q(r), l = (i, d = ";") => `${w}:${i}${d}`, P = { scope: e, config: t };
45
+ if (typeof s == "function") return y([u, s(P)]);
46
+ if (s instanceof Promise) return y([u, await s]);
47
+ if (t != null && t.templates && t.templatePaths[r])
48
+ try {
49
+ const [i, d] = t.templatePaths[r].split(";;"), a = await import(d), c = d.includes("salty.config"), f = c ? a[i].templates : a[i], h = c ? f[r] : f.params[r];
50
+ if (f && typeof h == "function") {
51
+ const x = await h(s), [m] = await $(x, "");
52
+ return m;
53
+ }
54
+ } catch (i) {
55
+ console.error(`Error loading template "${r}" from path "${t.templatePaths[r]}"`, i);
56
+ return;
57
+ }
58
+ if (t != null && t.templates && t.templates[r]) {
59
+ if (p) return;
60
+ const d = s.split(".").reduce((a, c) => a[c], t.templates[r]);
61
+ if (d) {
62
+ const [a] = await $(d, "");
63
+ return a;
64
+ }
65
+ console.warn(`Template "${r}" with path of "${s}" was not found in config!`);
66
+ return;
67
+ }
68
+ if (typeof s == "object") {
69
+ if (!s) return;
70
+ if (s.isColor) return l(s.toString());
71
+ if (r === "defaultVariants") return;
72
+ if (r === "variants") {
73
+ const a = Object.entries(s);
74
+ for (const [c, f] of a) {
75
+ if (!f) return;
76
+ const h = Object.entries(f);
77
+ for (const [x, m] of h) {
78
+ if (!m) return;
79
+ const T = `${e}.${c}-${x}`;
80
+ (await $(m, T, t)).forEach((U) => n.add(U));
81
+ }
82
+ }
83
+ return;
84
+ }
85
+ if (r === "compoundVariants") {
86
+ for (const a of s) {
87
+ const { css: c, ...f } = a, h = Object.entries(f).reduce((m, [T, A]) => `${m}.${T}-${A}`, e);
88
+ (await $(c, h, t)).forEach((m) => n.add(m));
89
+ }
90
+ return;
91
+ }
92
+ if (r.startsWith("@")) {
93
+ const a = ((j = t == null ? void 0 : t.mediaQueries) == null ? void 0 : j[r]) || r, c = await N(s, e, t), f = `${a} { ${c} }`;
94
+ n.add(f);
95
+ return;
96
+ }
97
+ const i = u.includes("&") ? r.replace("&", e) : r.startsWith(":") ? `${e}${r}` : `${e} ${r}`;
98
+ (await $(s, i, t)).forEach((a) => n.add(a));
99
+ return;
100
+ }
101
+ if (typeof s == "number") {
102
+ const i = _(w, s, t);
103
+ return l(i);
104
+ }
105
+ if (typeof s != "string")
106
+ if ("toString" in s) s = s.toString();
107
+ else throw new Error(`Invalid value type for property ${w}`);
108
+ return l(s);
109
+ }, C = b.map(y), { modifiers: O } = t || {}, E = [z(), M(O)], S = (await Promise.all(C).then((u) => Promise.all(
110
+ u.map((s) => E.reduce(async (r, w) => {
111
+ const l = await r;
112
+ if (!l) return l;
113
+ const P = await w(l);
114
+ if (!P) return l;
115
+ const { transformed: j, additionalCss: i } = P;
116
+ let d = "";
117
+ if (i)
118
+ for (const a of i)
119
+ d += await N(a, "");
120
+ return `${d}${j}`;
121
+ }, Promise.resolve(s)))
122
+ ))).filter((u) => u !== void 0).join(`
123
+ `);
124
+ if (!S.trim()) return Array.from(n);
125
+ const W = e ? `${e} {
126
+ ${S}
127
+ }` : S;
128
+ return n.has(W) ? Array.from(n) : [W, ...n];
129
+ }, N = async (o, e, t, p = !1) => (await $(o, e, t, p)).join(`
130
+ `);
131
+ export {
132
+ B as a,
133
+ N as p
134
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("../css/media.cjs"),r=require("../define-templates-Cunsb_Tr.cjs");class a{constructor(t){this._current=t}get isGlobalDefine(){return!0}}const i=e=>new a(e),n=e=>e(l.media);class s{constructor(t){this._current=t}get isDefineVariables(){return!0}}const o=e=>new s(e);exports.TemplateFactory=r.TemplateFactory;exports.TemplatesFactory=r.TemplatesFactory;exports.defineTemplates=r.defineTemplates;exports.GlobalStylesFactory=a;exports.VariablesFactory=s;exports.defineGlobalStyles=i;exports.defineMediaQuery=n;exports.defineVariables=o;
@@ -0,0 +1,5 @@
1
+ export * from './parse-modifiers';
2
+ export * from './parse-styles';
3
+ export * from './parse-templates';
4
+ export * from './parse-tokens';
5
+ export * from './parser-types';
@@ -0,0 +1,30 @@
1
+ import { media as t } from "../css/media.js";
2
+ import { T as f, a as d, d as m } from "../define-templates-4A2yHcMF.js";
3
+ class a {
4
+ constructor(r) {
5
+ this._current = r;
6
+ }
7
+ get isGlobalDefine() {
8
+ return !0;
9
+ }
10
+ }
11
+ const o = (e) => new a(e), i = (e) => e(t);
12
+ class s {
13
+ constructor(r) {
14
+ this._current = r;
15
+ }
16
+ get isDefineVariables() {
17
+ return !0;
18
+ }
19
+ }
20
+ const l = (e) => new s(e);
21
+ export {
22
+ a as GlobalStylesFactory,
23
+ f as TemplateFactory,
24
+ d as TemplatesFactory,
25
+ s as VariablesFactory,
26
+ o as defineGlobalStyles,
27
+ i as defineMediaQuery,
28
+ m as defineTemplates,
29
+ l as defineVariables
30
+ };
@@ -0,0 +1,3 @@
1
+ import { CssModifiers } from '../types/config-types';
2
+ import { StyleValueModifierFunction } from './parser-types';
3
+ export declare const parseValueModifiers: (modifiers?: CssModifiers) => StyleValueModifierFunction;
@@ -0,0 +1,13 @@
1
+ import { CachedConfig, SaltyConfig } from '../types/config-types';
2
+ /**
3
+ * Transform styles object to css string with or without scope
4
+ * @param styles CSS as JS object
5
+ * @param currentScope Scope of the styles, for class names full path with dot separator is required
6
+ * @param config Salty config object to allow use of templates and media queries etc.
7
+ * @param omitTemplates If true, static templates will be ignored
8
+ * @returns CSS strings that can be injected to the .css file or used inside of styles tag
9
+ * - First item is the main class with all the styles
10
+ * - Rest of the items are child selectors or media queries etc.
11
+ */
12
+ export declare const parseStyles: <T extends object>(styles?: T, currentScope?: string, config?: (SaltyConfig & CachedConfig) | undefined, omitTemplates?: boolean) => Promise<string[]>;
13
+ export declare const parseAndJoinStyles: <T extends object>(styles: T, currentClass: string, config?: (SaltyConfig & CachedConfig) | undefined, omitTemplates?: boolean) => Promise<string>;
@@ -0,0 +1,4 @@
1
+ export declare const parseTemplates: <T extends object>(obj: T, path?: PropertyKey[]) => Promise<string>;
2
+ export declare const getTemplateKeys: <T extends object>(templates: T) => string[];
3
+ export declare const getTemplateTypes: <T extends object>(templates: T) => Record<string, string>;
4
+ export declare const getTemplateTokens: <T extends object>(templates: T, parent?: string, templateTokens?: Set<string>) => string[];
@@ -0,0 +1,3 @@
1
+ import { SyncronousStyleValueModifierFunction } from './parser-types';
2
+ export declare const parseValueTokens: (tokenNames?: string[]) => SyncronousStyleValueModifierFunction;
3
+ export declare const parseVariableTokens: SyncronousStyleValueModifierFunction;
@@ -0,0 +1,8 @@
1
+ export interface ValueParserReturnValue {
2
+ transformed: string;
3
+ additionalCss?: object[];
4
+ }
5
+ type StyleValueModifierFunctionReturnValue = undefined | ValueParserReturnValue;
6
+ export type SyncronousStyleValueModifierFunction = (current: unknown) => StyleValueModifierFunctionReturnValue;
7
+ export type StyleValueModifierFunction = (current: string) => Promise<StyleValueModifierFunctionReturnValue> | StyleValueModifierFunctionReturnValue;
8
+ export {};
@@ -0,0 +1 @@
1
+ export declare const propertyNameCheck: (key: string) => string;
@@ -0,0 +1,7 @@
1
+ import { SaltyConfig } from '../config';
2
+ /**
3
+ * Add unit to a number value based on property name
4
+ * @param key - The property name
5
+ * @param value - The value to add unit to
6
+ */
7
+ export declare const addUnit: (key: string, value: string | number, config?: SaltyConfig) => string;
@@ -0,0 +1,18 @@
1
+ const n = `import { <%- styledComponentName %> } from "./<%- fileName %>.css";
2
+
3
+ interface <%- componentName %>Props {
4
+ text?: string;
5
+ }
6
+
7
+ export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
8
+ return (
9
+ <<%- styledComponentName %>>
10
+ {text}
11
+ </<%- styledComponentName %>>
12
+ );
13
+ };
14
+
15
+ export default <%- componentName %>;`;
16
+ export {
17
+ n as default
18
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { <%- styledComponentName %> } from "./<%- fileName %>.css";
2
+
3
+ interface <%- componentName %>Props {
4
+ text?: string;
5
+ }
6
+
7
+ export const <%- componentName %> = ({ text = 'Lorem ipsum' }: <%- componentName %>Props) => {
8
+ return (
9
+ <<%- styledComponentName %>>
10
+ {text}
11
+ </<%- styledComponentName %>>
12
+ );
13
+ };
14
+
15
+ export default <%- componentName %>;`;exports.default=e;
@@ -2,6 +2,7 @@ const n = `import { defineConfig } from '@salty-css/core/config';
2
2
 
3
3
  export const config = defineConfig({
4
4
  // Add your custom config here
5
+ externalModules: ['react', 'react-dom']
5
6
  });
6
7
  `;
7
8
  export {
@@ -1,6 +1,7 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=`import { defineConfig } from '@salty-css/core/config';
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=`import { defineConfig } from '@salty-css/core/config';
2
2
 
3
3
  export const config = defineConfig({
4
4
  // Add your custom config here
5
+ externalModules: ['react', 'react-dom']
5
6
  });
6
- `;exports.default=o;
7
+ `;exports.default=e;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("fs/promises"),r=require("../index-q4N-TRZZ.cjs"),i=async t=>{if(!t||t.includes("node_modules")||t.includes("saltygen"))return!1;if(t.includes("salty.config"))return!0;if(!r.isSaltyFile(t))return!1;const e=await s.readFile(t,"utf-8");return!!/.+define[A-Z]\w+/.test(e)};exports.checkShouldRestart=i;
@@ -0,0 +1 @@
1
+ export * from './should-restart';
@@ -0,0 +1,12 @@
1
+ import { readFile as r } from "fs/promises";
2
+ import { i as e } from "../index-CuYozIxT.js";
3
+ const f = async (t) => {
4
+ if (!t || t.includes("node_modules") || t.includes("saltygen")) return !1;
5
+ if (t.includes("salty.config")) return !0;
6
+ if (!e(t)) return !1;
7
+ const s = await r(t, "utf-8");
8
+ return !!/.+define[A-Z]\w+/.test(s);
9
+ };
10
+ export {
11
+ f as checkShouldRestart
12
+ };
@@ -0,0 +1 @@
1
+ export declare const checkShouldRestart: (filename: string) => Promise<boolean>;
@@ -0,0 +1,2 @@
1
+ import { GlobalStyles } from '../types/config-types';
2
+ export declare const saltyReset: GlobalStyles;
@@ -0,0 +1,10 @@
1
+ export interface RCFile {
2
+ defaultProject?: string;
3
+ projects?: {
4
+ dir?: string;
5
+ framework?: string;
6
+ components?: string;
7
+ configDir?: string;
8
+ saltygenDir?: string;
9
+ }[];
10
+ }
@@ -0,0 +1,84 @@
1
+ import { CssProperties, CssStyles } from '../types';
2
+ import { OrString } from '../types/util-types';
3
+ export type GlobalStyles = Record<string, CssProperties>;
4
+ export type CssVariableTokensObject = Record<string, unknown>;
5
+ export interface CssResponsiveVariables {
6
+ [key: string]: CssVariableTokensObject;
7
+ }
8
+ export interface CssConditionalVariables {
9
+ [key: PropertyKey]: {
10
+ [key: PropertyKey]: CssVariableTokensObject;
11
+ };
12
+ }
13
+ export interface SaltyVariables {
14
+ responsive?: CssResponsiveVariables;
15
+ conditional?: CssConditionalVariables;
16
+ [key: string]: undefined | string | number | CssVariableTokensObject;
17
+ }
18
+ type CssTemplate = CssStyles | {
19
+ [key: PropertyKey]: CssTemplate;
20
+ };
21
+ export interface CssTemplateObject {
22
+ [key: PropertyKey]: CssTemplate;
23
+ }
24
+ export interface CssTemplateFunction {
25
+ (value: any): CssTemplate;
26
+ }
27
+ export interface CssTemplates {
28
+ [key: PropertyKey]: CssTemplateObject | CssTemplateFunction;
29
+ }
30
+ export interface CssModifier {
31
+ pattern: RegExp;
32
+ transform: (regexMatch: string) => {
33
+ css?: CssStyles;
34
+ value: string;
35
+ };
36
+ }
37
+ export type CssModifiers = Record<string, CssModifier>;
38
+ export interface SaltyConfig {
39
+ /**
40
+ * The import strategy to use when importing css files.
41
+ * - `root` will import the css file from the root of the project.
42
+ * - `component` will import the css file from the component's directory.
43
+ */
44
+ importStrategy?: 'root' | 'component';
45
+ /**
46
+ * Base level variables that can be used in all styles as they are applied globally to :root.
47
+ @param responsive Variables that are defined for different media queries.
48
+ @param conditional Variables that are defined for different parent selectors (classes or data attributes).
49
+ */
50
+ variables?: SaltyVariables;
51
+ /**
52
+ * The global styles that are imported in the root of the project.
53
+ */
54
+ reset?: 'default' | 'none' | GlobalStyles;
55
+ /**
56
+ * The global styles that are imported in the root of the project.
57
+ */
58
+ global?: GlobalStyles;
59
+ /**
60
+ * The templates that can be used in styles to create reusable css.
61
+ */
62
+ templates?: CssTemplates;
63
+ /**
64
+ * The modifiers that can transform css values.
65
+ */
66
+ modifiers?: CssModifiers;
67
+ /**
68
+ * Define modules that should not be bundled when generating the css file. This improves the performance of the css generation and can help with issues relared to external packages being imported in an environment that does not support them.
69
+ */
70
+ externalModules?: ('react' | 'react-dom' | OrString)[];
71
+ /**
72
+ * default unit for px based properties when providing a number value. Default is 'px'.
73
+ */
74
+ defaultUnit?: 'px' | 'rem' | 'em' | 'vh' | 'vw' | 'vmin' | 'vmax' | 'cm' | 'mm' | 'in' | 'pt' | 'pc' | 'ch' | 'ex' | 'fr' | 'percent' | OrString;
75
+ }
76
+ export interface CachedConfig {
77
+ templates: CssTemplates;
78
+ staticVariables: Record<string, any>;
79
+ mediaQueries: Record<string, string>;
80
+ templatePaths: {
81
+ [key: string]: string;
82
+ };
83
+ }
84
+ export {};
package/types/index.d.ts CHANGED
@@ -1,36 +1,44 @@
1
- import { AllHTMLAttributes, ReactDOM, ReactNode } from 'react';
2
- import { StyleComponentGenerator } from '../generator';
3
- import { OrString } from './util-types';
1
+ import { ReactNode } from 'react';
2
+ import { NeverObj, OrAny, OrString } from './util-types';
3
+ import { StyledGenerator } from '../generators';
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
- passVariantProps?: boolean;
10
- style?: any;
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
17
  export type StyledComponentProps = Record<string, unknown> & CreateElementProps;
15
18
  type FnComponent<PROPS extends StyledComponentProps> = {
16
- (props: PROPS): ReactNode;
17
- generator?: StyleComponentGenerator;
19
+ (props: OrAny | PROPS): ReactNode;
20
+ generator?: StyledGenerator;
18
21
  };
19
- export type Tag<PROPS extends StyledComponentProps> = OrString | keyof ReactDOM | FnComponent<PROPS>;
20
- export type CompoundVariant = {
21
- [key: PropertyKey]: any;
22
- css: CssStyles;
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 InvalidVariantKeys = keyof AllHTMLAttributes<HTMLElement>;
25
- type StyleKeys = keyof Required<AllHTMLAttributes<HTMLElement>>['style'];
26
- export type StyleValue<K extends string> = K extends StyleKeys ? Required<AllHTMLAttributes<HTMLElement>>['style'][K] : never;
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: CSSinJS;
37
+ };
30
38
  type Variants = {
31
39
  variants?: VariantOptions & {
32
40
  [key: PropertyKey]: {
33
- [key: string]: Styles;
41
+ [key: PropertyKey]: CSSinJS;
34
42
  };
35
43
  };
36
44
  defaultVariants?: {
@@ -38,26 +46,49 @@ type Variants = {
38
46
  };
39
47
  compoundVariants?: CompoundVariant[];
40
48
  };
41
- type VariantPropValue<T> = T extends 'true' ? 'true' | true : T;
42
- export type VariantProps<STYLES extends StyledParams> = STYLES['variants'] extends undefined ? object : {
43
- [K in keyof STYLES['variants']]?: VariantPropValue<keyof STYLES['variants'][K]> | '';
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
  };
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
+ }>;
45
63
  type CssValuePropKey = `props-${string}`;
46
64
  export type ValueProps = {
47
65
  [key: CssValuePropKey]: string;
48
66
  };
49
- export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : unknown;
67
+ export type ParentComponentProps<TAG extends Tag<any>> = TAG extends (props: infer P) => ReactNode ? P : object;
50
68
  type StylePropertyValue = Record<never, never> & unknown;
69
+ export type CSSinJS = CssProperties | StylePropertyValue | TemplateTokens | CssPseudos;
51
70
  export type CssStyles = {
52
- [key in StyleKeys | OrString]?: StyleValue<key> | StylePropertyValue | PropertyValueToken | CssStyles;
71
+ [key in OrString]?: CSSinJS | CssStyles;
53
72
  };
54
73
  export type Styles = CssStyles & Variants;
74
+ export type MediaQueryStyles = {
75
+ [key in MediaQueryKeys]?: CssProperties | CssStyles | CssPseudos | TemplateTokens | MediaQueryStyles;
76
+ };
55
77
  export interface GeneratorOptions {
56
- className?: string;
78
+ className?: string | string[];
57
79
  displayName?: string;
58
80
  element?: string;
81
+ passProps?: boolean | string | string[];
82
+ defaultProps?: Record<PropertyKey, unknown>;
83
+ priority?: number;
59
84
  }
85
+ interface Base extends CssProperties, CssStyles, CssPseudos, TemplateTokens, MediaQueryStyles {
86
+ }
87
+ type Pseudos = CSS.Pseudos | `&${CSS.Pseudos}`;
88
+ type CssPseudos = {
89
+ [P in Pseudos]?: CssStyles;
90
+ };
60
91
  export interface StyledParams extends GeneratorOptions, Variants {
61
- base?: CssStyles;
92
+ base?: Base;
62
93
  }
63
94
  export {};
@@ -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 a=require("../dash-case-DKzpenwY.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;
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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { d as o, t as s } from "../dash-case-DMQMcCO6.js";
1
+ import { d as o, t as s } from "../dash-case-DBThphLm.js";
2
2
  import { p as f } from "../pascal-case-BQpR5PdN.js";
3
3
  function r(e) {
4
4
  return e ? typeof e != "string" ? r(String(e)) : e.replace(/\s/g, "-").replace(/-([a-z])/g, (a) => a[1].toUpperCase()) : "";
@@ -0,0 +1 @@
1
+ export declare const detectCurrentModuleType: (dirname: string) => Promise<"esm" | "cjs">;
@@ -1,59 +0,0 @@
1
- import { CssStyles } from '../types';
2
- type CssTemplate = CssStyles | {
3
- [key: PropertyKey]: CssTemplate;
4
- };
5
- export type CssVariables = Record<string, unknown>;
6
- export interface CssResponsiveVariables {
7
- [key: string]: CssVariables;
8
- }
9
- export interface CssConditionalVariables {
10
- [key: PropertyKey]: {
11
- [key: PropertyKey]: CssVariables;
12
- };
13
- }
14
- export interface CssTemplates {
15
- [key: PropertyKey]: {
16
- [key: PropertyKey]: CssTemplate;
17
- };
18
- }
19
- export interface CssModifier {
20
- pattern: RegExp;
21
- transform: (regexMatch: string) => {
22
- css?: CssStyles;
23
- value: string;
24
- };
25
- }
26
- export type CssModifiers = Record<string, CssModifier>;
27
- export interface SaltyConfig {
28
- /**
29
- * The import strategy to use when importing css files.
30
- * - `root` will import the css file from the root of the project.
31
- * - `component` will import the css file from the component's directory.
32
- */
33
- importStrategy?: 'root' | 'component';
34
- /**
35
- * Base variables that can be used in all styles as they are applied globally to :root.
36
- */
37
- variables?: CssVariables;
38
- /**
39
- * Variables that are defined for different media queries.
40
- */
41
- responsiveVariables?: CssResponsiveVariables;
42
- /**
43
- * Variables that are defined for different parent selectors (classes or data attributes).
44
- */
45
- conditionalVariables?: CssConditionalVariables;
46
- /**
47
- * The global styles that are imported in the root of the project.
48
- */
49
- global?: CssStyles;
50
- /**
51
- * The templates that can be used in styles to create reusable css.
52
- */
53
- templates?: CssTemplates;
54
- /**
55
- * The modifiers that can transform css values.
56
- */
57
- modifiers?: CssModifiers;
58
- }
59
- export {};
@@ -1 +0,0 @@
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;
@@ -1 +0,0 @@
1
- export * from './style-generator';