@salty-css/core 0.1.0-alpha.28 → 0.1.0-alpha.30

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.
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { p as parseAndJoinStyles } from "./parse-styles-CtA-RKqt.js";
4
+ import { p as parseAndJoinStyles, b as parseTemplateCallSite } from "./parse-styles-BBJ3PWyV.js";
5
5
  import { d as dashCase } from "./dash-case-DblXvymC.js";
6
6
  import { t as toHash } from "./to-hash-DAN2LcHK.js";
7
7
  class StylesGenerator {
@@ -50,7 +50,22 @@ class StylesGenerator {
50
50
  if (!(config == null ? void 0 : config.templates) || !this.params.base || this.priority > 0) return [];
51
51
  const templateKeys = Object.keys(config.templates);
52
52
  return Object.entries(this.params.base).reduce((acc, [key, value]) => {
53
- if (templateKeys.includes(key)) acc.push("t_" + toHash(dashCase(`${key}-${value}`), 4));
53
+ if (!templateKeys.includes(key)) return acc;
54
+ const callSite = parseTemplateCallSite(value);
55
+ if (!callSite || callSite.path.length === 0) return acc;
56
+ const { path, variants } = callSite;
57
+ const cumulative = [];
58
+ for (const part of path) {
59
+ cumulative.push(part);
60
+ const baseClassName = dashCase(`${key}-${cumulative.join(".")}`);
61
+ acc.push("t_" + toHash(baseClassName, 4));
62
+ for (const [axis, axisValue] of Object.entries(variants)) {
63
+ if (axisValue === false || axisValue === void 0) continue;
64
+ const valueSuffix = axisValue === true ? "" : `-${dashCase(String(axisValue))}`;
65
+ const variantClassName = `${baseClassName}-${dashCase(axis)}${valueSuffix}`;
66
+ acc.push("tv_" + toHash(variantClassName, 4));
67
+ }
68
+ }
54
69
  return acc;
55
70
  }, []);
56
71
  }
@@ -2,7 +2,7 @@
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- const parseStyles = require("./parse-styles-BFoV7HiL.cjs");
5
+ const parseStyles = require("./parse-styles-lOMGe_c5.cjs");
6
6
  const dashCase = require("./dash-case-DIwKaYgE.cjs");
7
7
  const toHash = require("./to-hash-C05Y906F.cjs");
8
8
  class StylesGenerator {
@@ -51,7 +51,22 @@ class StylesGenerator {
51
51
  if (!(config == null ? void 0 : config.templates) || !this.params.base || this.priority > 0) return [];
52
52
  const templateKeys = Object.keys(config.templates);
53
53
  return Object.entries(this.params.base).reduce((acc, [key, value]) => {
54
- if (templateKeys.includes(key)) acc.push("t_" + toHash.toHash(dashCase.dashCase(`${key}-${value}`), 4));
54
+ if (!templateKeys.includes(key)) return acc;
55
+ const callSite = parseStyles.parseTemplateCallSite(value);
56
+ if (!callSite || callSite.path.length === 0) return acc;
57
+ const { path, variants } = callSite;
58
+ const cumulative = [];
59
+ for (const part of path) {
60
+ cumulative.push(part);
61
+ const baseClassName = dashCase.dashCase(`${key}-${cumulative.join(".")}`);
62
+ acc.push("t_" + toHash.toHash(baseClassName, 4));
63
+ for (const [axis, axisValue] of Object.entries(variants)) {
64
+ if (axisValue === false || axisValue === void 0) continue;
65
+ const valueSuffix = axisValue === true ? "" : `-${dashCase.dashCase(String(axisValue))}`;
66
+ const variantClassName = `${baseClassName}-${dashCase.dashCase(axis)}${valueSuffix}`;
67
+ acc.push("tv_" + toHash.toHash(variantClassName, 4));
68
+ }
69
+ }
55
70
  return acc;
56
71
  }, []);
57
72
  }
@@ -14,7 +14,7 @@ const dashCase = require("../dash-case-DIwKaYgE.cjs");
14
14
  const toHash = require("../to-hash-C05Y906F.cjs");
15
15
  const defineTemplates = require("../define-templates-Deq1aCbN.cjs");
16
16
  const module$1 = require("module");
17
- const parseStyles = require("../parse-styles-BFoV7HiL.cjs");
17
+ const parseStyles = require("../parse-styles-lOMGe_c5.cjs");
18
18
  const css_merge = require("../css/merge.cjs");
19
19
  const parsers_index = require("../parsers/index.cjs");
20
20
  const moduleType = require("../util/module-type");
@@ -607,9 +607,7 @@ ${css}
607
607
  }).join(";\n ")}
608
608
  }` : `type TemplateVariantTokens = Record<string, Record<string, Record<string, never>>>;`;
609
609
  const tsTemplateVariantAliases = templateVariantMapEntries.flatMap(
610
- ([templateKey, pathMap]) => Object.keys(pathMap).map(
611
- (dotPath) => `type ${pascal(templateKey)}${pascal(dotPath)}Variants = TemplateVariantTokens['${templateKey}']['${dotPath}'];`
612
- )
610
+ ([templateKey, pathMap]) => Object.keys(pathMap).map((dotPath) => `type ${pascal(templateKey)}${pascal(dotPath)}Variants = TemplateVariantTokens['${templateKey}']['${dotPath}'];`)
613
611
  ).join("\n ");
614
612
  const tsTokensTypes = `
615
613
  // Variable types
@@ -618,7 +616,10 @@ ${css}
618
616
 
619
617
  // Template types
620
618
  type TemplateTokens = {
621
- ${Object.entries(templateTokens).map(([key, value]) => `${key}?: ${value}`).join("\n")}
619
+ ${Object.entries(templateTokens).map(([key, value]) => {
620
+ if (!value || value === "any") return `${key}?: ${value || "any"}`;
621
+ return `${key}?: ${value} | \`\${${value}}@\${string}\``;
622
+ }).join("\n")}
622
623
  }
623
624
 
624
625
  // Template variant types (per docs/template-variants-spec.md §7)
@@ -12,7 +12,7 @@ import { d as dashCase } from "../dash-case-DblXvymC.js";
12
12
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
13
13
  import { d as defineTemplates } from "../define-templates-CVhhgPnd.js";
14
14
  import { createRequire } from "module";
15
- import { p as parseAndJoinStyles, b as parseVariableTokens } from "../parse-styles-CtA-RKqt.js";
15
+ import { p as parseAndJoinStyles, c as parseVariableTokens } from "../parse-styles-BBJ3PWyV.js";
16
16
  import { mergeObjects, mergeFactories } from "../css/merge.js";
17
17
  import { parseTemplates, getTemplateTypes, getTemplateVariantMaps } from "../parsers/index.js";
18
18
  import { detectCurrentModuleType } from "../util/module-type";
@@ -588,9 +588,7 @@ ${css}
588
588
  }).join(";\n ")}
589
589
  }` : `type TemplateVariantTokens = Record<string, Record<string, Record<string, never>>>;`;
590
590
  const tsTemplateVariantAliases = templateVariantMapEntries.flatMap(
591
- ([templateKey, pathMap]) => Object.keys(pathMap).map(
592
- (dotPath) => `type ${pascal(templateKey)}${pascal(dotPath)}Variants = TemplateVariantTokens['${templateKey}']['${dotPath}'];`
593
- )
591
+ ([templateKey, pathMap]) => Object.keys(pathMap).map((dotPath) => `type ${pascal(templateKey)}${pascal(dotPath)}Variants = TemplateVariantTokens['${templateKey}']['${dotPath}'];`)
594
592
  ).join("\n ");
595
593
  const tsTokensTypes = `
596
594
  // Variable types
@@ -599,7 +597,10 @@ ${css}
599
597
 
600
598
  // Template types
601
599
  type TemplateTokens = {
602
- ${Object.entries(templateTokens).map(([key, value]) => `${key}?: ${value}`).join("\n")}
600
+ ${Object.entries(templateTokens).map(([key, value]) => {
601
+ if (!value || value === "any") return `${key}?: ${value || "any"}`;
602
+ return `${key}?: ${value} | \`\${${value}}@\${string}\``;
603
+ }).join("\n")}
603
604
  }
604
605
 
605
606
  // Template variant types (per docs/template-variants-spec.md §7)
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BFoV7HiL.cjs");
3
+ const parseStyles = require("../parse-styles-lOMGe_c5.cjs");
4
4
  const toHash = require("../to-hash-C05Y906F.cjs");
5
5
  const cache_resolveDynamicConfigCache = require("../cache/resolve-dynamic-config-cache.cjs");
6
6
  const getDynamicStylesClassName = (styles) => {
@@ -1,4 +1,4 @@
1
- import { a as parseStyles } from "../parse-styles-CtA-RKqt.js";
1
+ import { a as parseStyles } from "../parse-styles-BBJ3PWyV.js";
2
2
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
3
3
  import { resolveDynamicConfigCache } from "../cache/resolve-dynamic-config-cache.js";
4
4
  const getDynamicStylesClassName = (styles) => {
package/css/keyframes.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BFoV7HiL.cjs");
3
+ const parseStyles = require("../parse-styles-lOMGe_c5.cjs");
4
4
  const toHash = require("../to-hash-C05Y906F.cjs");
5
5
  const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
6
6
  const modifyKeyframes = async (params = {}) => {
package/css/keyframes.js CHANGED
@@ -1,4 +1,4 @@
1
- import { p as parseAndJoinStyles } from "../parse-styles-CtA-RKqt.js";
1
+ import { p as parseAndJoinStyles } from "../parse-styles-BBJ3PWyV.js";
2
2
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
3
3
  const keyframes = ({ animationName: _name, params: _params, appendInitialStyles, ...keyframes2 }) => {
4
4
  const modifyKeyframes = async (params = {}) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const classNameGenerator = require("../class-name-generator-DZcz_NT4.cjs");
3
+ const classNameGenerator = require("../class-name-generator-BEOEMEKX.cjs");
4
4
  const dashCase = require("../dash-case-DIwKaYgE.cjs");
5
5
  class StyledGenerator extends classNameGenerator.StylesGenerator {
6
6
  constructor(tagName, _params) {
@@ -1,5 +1,5 @@
1
- import { S as StylesGenerator } from "../class-name-generator-zQ8zLbPI.js";
2
- import { C } from "../class-name-generator-zQ8zLbPI.js";
1
+ import { S as StylesGenerator } from "../class-name-generator-B0WkxoIg.js";
2
+ import { C } from "../class-name-generator-B0WkxoIg.js";
3
3
  import { d as dashCase } from "../dash-case-DblXvymC.js";
4
4
  class StyledGenerator extends StylesGenerator {
5
5
  constructor(tagName, _params) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const classNameGenerator = require("../class-name-generator-DZcz_NT4.cjs");
3
+ const classNameGenerator = require("../class-name-generator-BEOEMEKX.cjs");
4
4
  const classNameInstance = (params) => {
5
5
  const generator = new classNameGenerator.ClassNameGenerator(params);
6
6
  const createClass = (classNameStr) => {
@@ -1,4 +1,4 @@
1
- import { C as ClassNameGenerator } from "../class-name-generator-zQ8zLbPI.js";
1
+ import { C as ClassNameGenerator } from "../class-name-generator-B0WkxoIg.js";
2
2
  const classNameInstance = (params) => {
3
3
  const generator = new ClassNameGenerator(params);
4
4
  const createClass = (classNameStr) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salty-css/core",
3
- "version": "0.1.0-alpha.28",
3
+ "version": "0.1.0-alpha.30",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./dist/index.d.ts",
@@ -504,9 +504,10 @@ const combineSelectors = (currentScope, key) => {
504
504
  };
505
505
  export {
506
506
  parseStyles as a,
507
- parseVariableTokens as b,
508
- parseValueModifiers as c,
509
- parseValueTokens as d,
507
+ parseTemplateCallSite as b,
508
+ parseVariableTokens as c,
509
+ parseValueModifiers as d,
510
+ parseValueTokens as e,
510
511
  isRichTemplateNode as i,
511
512
  parseAndJoinStyles as p,
512
513
  reportParserIssue as r
@@ -506,6 +506,7 @@ const combineSelectors = (currentScope, key) => {
506
506
  exports.isRichTemplateNode = isRichTemplateNode;
507
507
  exports.parseAndJoinStyles = parseAndJoinStyles;
508
508
  exports.parseStyles = parseStyles;
509
+ exports.parseTemplateCallSite = parseTemplateCallSite;
509
510
  exports.parseValueModifiers = parseValueModifiers;
510
511
  exports.parseValueTokens = parseValueTokens;
511
512
  exports.parseVariableTokens = parseVariableTokens;
package/parsers/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BFoV7HiL.cjs");
3
+ const parseStyles = require("../parse-styles-lOMGe_c5.cjs");
4
4
  const dashCase = require("../dash-case-DIwKaYgE.cjs");
5
5
  const toHash = require("../to-hash-C05Y906F.cjs");
6
6
  const RICH_META_KEYS = /* @__PURE__ */ new Set(["base", "variants", "defaultVariants", "compoundVariants", "anyOfVariants"]);
@@ -13,12 +13,24 @@ const parseTemplates = async (obj, path = []) => {
13
13
  const classes = [];
14
14
  if (parseStyles.isRichTemplateNode(obj)) {
15
15
  const rich = obj;
16
+ const baseClassName = path.map((p) => dashCase.dashCase(String(p))).join("-");
16
17
  if (rich.base) {
17
- const className = path.map((p) => dashCase.dashCase(String(p))).join("-");
18
- const hashClass = "t_" + toHash.toHash(className, 4);
19
- const result = await parseStyles.parseAndJoinStyles(rich.base, `.${className}, .${hashClass}`);
18
+ const hashClass = "t_" + toHash.toHash(baseClassName, 4);
19
+ const result = await parseStyles.parseAndJoinStyles(rich.base, `.${baseClassName}, .${hashClass}`);
20
20
  classes.push(result);
21
21
  }
22
+ if (rich.variants) {
23
+ for (const [axis, valueMap] of Object.entries(rich.variants)) {
24
+ if (!valueMap || typeof valueMap !== "object") continue;
25
+ for (const [value, styles] of Object.entries(valueMap)) {
26
+ if (!styles || typeof styles !== "object") continue;
27
+ const variantClassName = `${baseClassName}-${dashCase.dashCase(axis)}-${dashCase.dashCase(value)}`;
28
+ const variantHashClass = "tv_" + toHash.toHash(variantClassName, 4);
29
+ const result = await parseStyles.parseAndJoinStyles(styles, `.${variantClassName}, .${variantHashClass}`);
30
+ classes.push(result);
31
+ }
32
+ }
33
+ }
22
34
  for (const [key, value] of Object.entries(rich)) {
23
35
  if (!isChildEntry(key, value)) continue;
24
36
  const result = await parseTemplates(value, [...path, key.trim()]);
package/parsers/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { i as isRichTemplateNode, p as parseAndJoinStyles } from "../parse-styles-CtA-RKqt.js";
2
- import { a, c, d, b, r } from "../parse-styles-CtA-RKqt.js";
1
+ import { i as isRichTemplateNode, p as parseAndJoinStyles } from "../parse-styles-BBJ3PWyV.js";
2
+ import { a, d, e, c, r } from "../parse-styles-BBJ3PWyV.js";
3
3
  import { d as dashCase } from "../dash-case-DblXvymC.js";
4
4
  import { t as toHash } from "../to-hash-DAN2LcHK.js";
5
5
  const RICH_META_KEYS = /* @__PURE__ */ new Set(["base", "variants", "defaultVariants", "compoundVariants", "anyOfVariants"]);
@@ -12,12 +12,24 @@ const parseTemplates = async (obj, path = []) => {
12
12
  const classes = [];
13
13
  if (isRichTemplateNode(obj)) {
14
14
  const rich = obj;
15
+ const baseClassName = path.map((p) => dashCase(String(p))).join("-");
15
16
  if (rich.base) {
16
- const className = path.map((p) => dashCase(String(p))).join("-");
17
- const hashClass = "t_" + toHash(className, 4);
18
- const result = await parseAndJoinStyles(rich.base, `.${className}, .${hashClass}`);
17
+ const hashClass = "t_" + toHash(baseClassName, 4);
18
+ const result = await parseAndJoinStyles(rich.base, `.${baseClassName}, .${hashClass}`);
19
19
  classes.push(result);
20
20
  }
21
+ if (rich.variants) {
22
+ for (const [axis, valueMap] of Object.entries(rich.variants)) {
23
+ if (!valueMap || typeof valueMap !== "object") continue;
24
+ for (const [value, styles] of Object.entries(valueMap)) {
25
+ if (!styles || typeof styles !== "object") continue;
26
+ const variantClassName = `${baseClassName}-${dashCase(axis)}-${dashCase(value)}`;
27
+ const variantHashClass = "tv_" + toHash(variantClassName, 4);
28
+ const result = await parseAndJoinStyles(styles, `.${variantClassName}, .${variantHashClass}`);
29
+ classes.push(result);
30
+ }
31
+ }
32
+ }
21
33
  for (const [key, value] of Object.entries(rich)) {
22
34
  if (!isChildEntry(key, value)) continue;
23
35
  const result = await parseTemplates(value, [...path, key.trim()]);
@@ -130,8 +142,8 @@ export {
130
142
  parseAndJoinStyles,
131
143
  a as parseStyles,
132
144
  parseTemplates,
133
- c as parseValueModifiers,
134
- d as parseValueTokens,
135
- b as parseVariableTokens,
145
+ d as parseValueModifiers,
146
+ e as parseValueTokens,
147
+ c as parseVariableTokens,
136
148
  r as reportParserIssue
137
149
  };
package/runtime/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const parseStyles = require("../parse-styles-BFoV7HiL.cjs");
3
+ const parseStyles = require("../parse-styles-lOMGe_c5.cjs");
4
4
  const defineRuntime = (config) => {
5
5
  const getDynamicStylesCss = async (styles, scope) => {
6
6
  const parsed = await parseStyles.parseStyles(styles, scope, config);
package/runtime/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as parseStyles } from "../parse-styles-CtA-RKqt.js";
1
+ import { a as parseStyles } from "../parse-styles-BBJ3PWyV.js";
2
2
  const defineRuntime = (config) => {
3
3
  const getDynamicStylesCss = async (styles, scope) => {
4
4
  const parsed = await parseStyles(styles, scope, config);