@salty-css/core 0.0.1-alpha.29 → 0.0.1-alpha.292

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 (104) hide show
  1. package/.saltyrc.schema.json +48 -0
  2. package/README.md +469 -26
  3. package/bin/logger.d.ts +1 -0
  4. package/bin/main.cjs +8 -5
  5. package/bin/main.js +230 -106
  6. package/cache/resolve-dynamic-config-cache.cjs +1 -0
  7. package/cache/resolve-dynamic-config-cache.d.ts +1 -0
  8. package/cache/resolve-dynamic-config-cache.js +11 -0
  9. package/compiler/get-files.d.ts +3 -0
  10. package/compiler/get-function-range.d.ts +1 -0
  11. package/compiler/helpers.d.ts +2 -0
  12. package/compiler/index.cjs +1 -11
  13. package/compiler/index.d.ts +19 -11
  14. package/compiler/index.js +20 -172
  15. package/config/define-config.d.ts +1 -1
  16. package/config/index.cjs +1 -1
  17. package/config/index.d.ts +2 -1
  18. package/config/index.js +12 -2
  19. package/css/index.cjs +1 -1
  20. package/css/index.d.ts +4 -1
  21. package/css/index.js +10 -2
  22. package/css/keyframes.cjs +1 -0
  23. package/css/keyframes.d.ts +22 -0
  24. package/css/keyframes.js +39 -0
  25. package/css/media.cjs +1 -0
  26. package/css/media.d.ts +87 -0
  27. package/css/media.js +88 -0
  28. package/css/merge.cjs +1 -0
  29. package/css/merge.d.ts +7 -0
  30. package/css/merge.js +5 -0
  31. package/css/token.cjs +1 -0
  32. package/css/token.d.ts +1 -0
  33. package/css/token.js +4 -0
  34. package/{dash-case-DKzpenwY.cjs → dash-case-BJEkFEGQ.cjs} +1 -1
  35. package/{dash-case-DMQMcCO6.js → dash-case-DBThphLm.js} +2 -2
  36. package/define-templates-4A2yHcMF.js +52 -0
  37. package/define-templates-Cunsb_Tr.cjs +1 -0
  38. package/factories/define-global-styles.d.ts +7 -0
  39. package/factories/define-media-query.d.ts +8 -0
  40. package/factories/define-templates.d.ts +27 -0
  41. package/factories/define-variables.d.ts +12 -0
  42. package/factories/index.cjs +1 -0
  43. package/factories/index.d.ts +4 -0
  44. package/factories/index.js +30 -0
  45. package/generators/class-name-generator.d.ts +6 -0
  46. package/generators/index.cjs +1 -0
  47. package/generators/index.d.ts +2 -0
  48. package/generators/index.js +88 -0
  49. package/generators/styled-generator.d.ts +20 -0
  50. package/generators/styles-generator.d.ts +22 -0
  51. package/helpers/color.d.ts +18 -0
  52. package/helpers/index.cjs +1 -0
  53. package/helpers/index.d.ts +2 -0
  54. package/helpers/index.js +1154 -0
  55. package/helpers/viewport-clamp.d.ts +8 -0
  56. package/helpers-CC5pFyba.cjs +1 -0
  57. package/helpers-nHqH4L9L.js +11 -0
  58. package/index-C8WlBhQE.js +524 -0
  59. package/index-CxAphBMJ.cjs +41 -0
  60. package/package.json +54 -6
  61. package/parse-styles-DLPgVsVQ.js +154 -0
  62. package/parse-styles-DZYIEhB4.cjs +5 -0
  63. package/parsers/index.cjs +2 -0
  64. package/parsers/index.d.ts +5 -0
  65. package/parsers/index.js +33 -0
  66. package/parsers/parse-modifiers.d.ts +3 -0
  67. package/parsers/parse-styles.d.ts +13 -0
  68. package/parsers/parse-templates.d.ts +4 -0
  69. package/parsers/parse-tokens.d.ts +3 -0
  70. package/parsers/parser-types.d.ts +8 -0
  71. package/parsers/property-name-check.d.ts +1 -0
  72. package/parsers/unit-check.d.ts +7 -0
  73. package/react-vanilla-file-CCXbsjIb.js +18 -0
  74. package/react-vanilla-file-CG_WJLam.cjs +15 -0
  75. package/{salty.config-D9ANEDiH.js → salty.config-BhBY_oOk.js} +1 -0
  76. package/{salty.config-BupieCfE.cjs → salty.config-Dk6ZcCxI.cjs} +3 -2
  77. package/server/index.cjs +1 -0
  78. package/server/index.d.ts +1 -0
  79. package/server/index.js +4 -0
  80. package/server/should-restart.d.ts +1 -0
  81. package/should-restart-Cp2E_1Lh.cjs +1 -0
  82. package/should-restart-DaT4pHXq.js +12 -0
  83. package/templates/salty-reset.d.ts +2 -0
  84. package/types/cli-types.d.ts +10 -0
  85. package/types/config-types.d.ts +85 -0
  86. package/types/index.d.ts +53 -22
  87. package/util/dot-case.d.ts +1 -0
  88. package/util/index.cjs +1 -1
  89. package/util/index.js +1 -1
  90. package/util/module-type.d.ts +1 -0
  91. package/viewport-clamp-BOc-8Oph.js +7 -0
  92. package/viewport-clamp-kY8JqYzm.cjs +1 -0
  93. package/config/config-types.d.ts +0 -59
  94. package/generator/index.cjs +0 -1
  95. package/generator/index.d.ts +0 -1
  96. package/generator/index.js +0 -61
  97. package/generator/parse-modifiers.d.ts +0 -3
  98. package/generator/parse-styles.d.ts +0 -2
  99. package/generator/parse-templates.d.ts +0 -2
  100. package/generator/parse-tokens.d.ts +0 -2
  101. package/generator/parser-types.d.ts +0 -4
  102. package/generator/style-generator.d.ts +0 -28
  103. package/parse-templates-D4p3pgQR.js +0 -92
  104. package/parse-templates-W0YfTmOT.cjs +0 -8
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
+ export interface BaseStyles 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?: BaseStyles;
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">;
@@ -0,0 +1,7 @@
1
+ const p = (e) => (t) => {
2
+ const { screenSize: n, axis: i = "horizontal", minMultiplier: a = 0.5, maxMultiplier: r = 1.5 } = e, o = Math.round(t / n * 1e4) / 100, l = i === "vertical" ? "vh" : "vw", c = Math.round(a * t), s = Math.round(r * t);
3
+ return `clamp(${c}px, ${o}${l}, ${s}px)`;
4
+ };
5
+ export {
6
+ p as d
7
+ };
@@ -0,0 +1 @@
1
+ "use strict";const p=e=>t=>{const{screenSize:i,axis:n="horizontal",minMultiplier:r=.5,maxMultiplier:a=1.5}=e,o=Math.round(t/i*1e4)/100,l=n==="vertical"?"vh":"vw",c=Math.round(r*t),s=Math.round(a*t);return`clamp(${c}px, ${o}${l}, ${s}px)`};exports.defineViewportClamp=p;
@@ -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';
@@ -1,61 +0,0 @@
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,3 +0,0 @@
1
- import { CssModifiers } from '../config/config-types';
2
- import { ValueParserReturnValue } from './parser-types';
3
- export declare const parseValueModifiers: (value: string, modifiers?: CssModifiers) => ValueParserReturnValue;
@@ -1,2 +0,0 @@
1
- import { SaltyConfig } from '../config/config-types';
2
- export declare const parseStyles: <T extends object>(styles: T, currentClass: string, layer?: number, config?: SaltyConfig | undefined) => string;
@@ -1,2 +0,0 @@
1
- export declare const parseTemplates: <T extends object>(obj: T, path?: PropertyKey[]) => string;
2
- export declare const getTemplateKeys: <T extends object>(templates: T) => string[];
@@ -1,2 +0,0 @@
1
- import { ValueParserReturnValue } from './parser-types';
2
- export declare const parseValueTokens: (value: string) => ValueParserReturnValue;
@@ -1,4 +0,0 @@
1
- export interface ValueParserReturnValue {
2
- result: string;
3
- additionalCss?: Object[];
4
- }
@@ -1,28 +0,0 @@
1
- import { StyledParams, Tag } from '../types';
2
- export interface GeneratorProps {
3
- element?: string;
4
- variantKeys?: string[];
5
- propValueKeys?: string[];
6
- }
7
- export declare class StyleComponentGenerator {
8
- tagName: Tag<any>;
9
- params: StyledParams;
10
- _callerName: string | undefined;
11
- _context: {
12
- name: string;
13
- config: any;
14
- } | undefined;
15
- constructor(tagName: Tag<any>, params: StyledParams);
16
- get hash(): string;
17
- get priority(): number;
18
- get classNames(): string;
19
- get cssClassName(): string;
20
- get cssDisplayNameVar(): string;
21
- get templateKeys(): string[];
22
- get css(): string;
23
- get props(): GeneratorProps;
24
- _withBuildContext(context: {
25
- name: string;
26
- config: any;
27
- }): this;
28
- }
@@ -1,92 +0,0 @@
1
- import { d as O } from "./dash-case-DMQMcCO6.js";
2
- const N = (t, r) => {
3
- if (typeof t != "string") return { result: t };
4
- if (!r) return { result: t };
5
- const e = [];
6
- return Object.values(r).forEach((n) => {
7
- const { pattern: o, transform: c } = n;
8
- t = t.replace(o, (h) => {
9
- const { value: i, css: m } = c(h);
10
- return m && e.push(m), i;
11
- });
12
- }), { result: t, additionalCss: e };
13
- }, P = (t) => typeof t != "string" ? { result: t } : /\{[^{}]+\}/g.test(t) ? { result: t.replace(/\{([^{}]+)\}/g, (...n) => `var(--${O(n[1].replaceAll(".", "-"))})`) } : { result: t }, d = (t, r, e, n) => {
14
- if (!t) return "";
15
- const o = [], c = Object.entries(t).reduce((i, [m, s]) => {
16
- const p = m.trim();
17
- if (typeof s == "function" && (s = s()), typeof s == "object") {
18
- if (!s) return i;
19
- if (p === "variants")
20
- return Object.entries(s).forEach(([u, f]) => {
21
- f && Object.entries(f).forEach(([b, j]) => {
22
- if (!j) return;
23
- const l = `${r}.${u}-${b}`, y = d(j, l, e);
24
- o.push(y);
25
- });
26
- }), i;
27
- if (p === "defaultVariants")
28
- return i;
29
- if (p === "compoundVariants")
30
- return s.forEach((u) => {
31
- const { css: f, ...b } = u, j = Object.entries(b).reduce((y, [V, W]) => `${y}.${V}-${W}`, r), l = d(f, j, e);
32
- o.push(l);
33
- }), i;
34
- if (p.startsWith("@")) {
35
- const u = d(s, r, e), f = `${p} {
36
- ${u.replace(`
37
- `, `
38
- `)}
39
- }`;
40
- return o.push(f), i;
41
- }
42
- const $ = m.includes("&") ? p.replace("&", r) : p.startsWith(":") ? `${r}${p}` : `${r} ${p}`, a = d(s, $, e);
43
- return o.push(a), i;
44
- }
45
- if (n != null && n.templates && n.templates[p]) {
46
- const a = s.split(".").reduce((f, b) => f[b], n.templates[p]), u = d(a, "");
47
- return `${i}${u}`;
48
- }
49
- const g = p.startsWith("-") ? p : O(p), E = ($, a = ";") => i = `${i}${$}${a}`, S = ($) => E(`${g}:${$}`);
50
- if (typeof s == "number") return S(s);
51
- if (typeof s != "string")
52
- if ("toString" in s) s = s.toString();
53
- else return i;
54
- const { modifiers: k } = n || {}, T = function* () {
55
- yield P(s), yield N(s, k);
56
- }();
57
- for (const { result: $, additionalCss: a = [] } of T)
58
- s = $, a.forEach((u) => {
59
- const f = d(u, "");
60
- E(f, "");
61
- });
62
- return S(s);
63
- }, "");
64
- if (!c) return o.join(`
65
- `);
66
- if (!r) return c;
67
- let h = "";
68
- return e !== void 0 ? h = `@layer l${e} { ${r} { ${c} } }` : h = `${r} { ${c} }`, [h, ...o].join(`
69
- `);
70
- }, _ = (t, r = []) => {
71
- if (!t) return "";
72
- const e = [], n = {};
73
- if (Object.entries(t).forEach(([o, c]) => {
74
- if (typeof c == "object") {
75
- if (!c) return;
76
- const h = o.trim(), i = _(c, [...r, h]);
77
- e.push(i);
78
- } else
79
- n[o] = c;
80
- }), Object.keys(n).length) {
81
- const o = r.map(O).join("-"), c = d(n, `.${o}`);
82
- e.push(c);
83
- }
84
- return e.join(`
85
- `);
86
- }, A = (t) => Object.keys(t);
87
- export {
88
- _ as a,
89
- P as b,
90
- A as g,
91
- d as p
92
- };
@@ -1,8 +0,0 @@
1
- "use strict";const O=require("./dash-case-DKzpenwY.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:c}=n;t=t.replace(o,a=>{const{value:i,css:l}=c(a);return l&&r.push(l),i})}),{result:t,additionalCss:r}},k=t=>typeof t!="string"?{result:t}:/\{[^{}]+\}/g.test(t)?{result:t.replace(/\{([^{}]+)\}/g,(...n)=>`var(--${O.dashCase(n[1].replaceAll(".","-"))})`)}:{result:t},h=(t,e,r,n)=>{if(!t)return"";const o=[],c=Object.entries(t).reduce((i,[l,s])=>{const p=l.trim();if(typeof s=="function"&&(s=s()),typeof s=="object"){if(!s)return i;if(p==="variants")return Object.entries(s).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 s.forEach(u=>{const{css:f,...m}=u,j=Object.entries(m).reduce((b,[q,K])=>`${b}.${q}-${K}`,e),y=h(f,j,r);o.push(y)}),i;if(p.startsWith("@")){const u=h(s,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(s,$,r);return o.push(d),i}if(n!=null&&n.templates&&n.templates[p]){const d=s.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 s=="number")return S(s);if(typeof s!="string")if("toString"in s)s=s.toString();else return i;const{modifiers:g}=n||{},W=function*(){yield k(s),yield N(s,g)}();for(const{result:$,additionalCss:d=[]}of W)s=$,d.forEach(u=>{const f=h(u,"");T(f,"")});return S(s)},"");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=(t,e=[])=>{if(!t)return"";const r=[],n={};if(Object.entries(t).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
- `)},P=t=>Object.keys(t);exports.getTemplateKeys=P;exports.parseStyles=h;exports.parseTemplates=E;exports.parseValueTokens=k;