@jobber/design 0.101.1-chorecomp-aaf4bc5.3 → 0.101.1

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/dist/index.cjs CHANGED
@@ -2729,8 +2729,14 @@ const tokenStyleToCss = (token) => {
2729
2729
  const tokenAsString = typeof token === "string" ? token : token === null || token === void 0 ? void 0 : token.toString();
2730
2730
  return ((tokenAsString === null || tokenAsString === void 0 ? void 0 : tokenAsString.replace(/\{/g, "var(--").replace(/\./g, "-").replace(/\}/g, ")")) || "");
2731
2731
  };
2732
- const tokenStyleToJs = (token) => {
2733
- const tokenKey = (token === null || token === void 0 ? void 0 : token.replace(/}/g, "").replace(/{/g, "").replace(/\./g, "-")) || "";
2732
+ // Convert a token reference like `"{color.icon}"` into the flat token key
2733
+ // `"color-icon"` used by `tokens` / `allColors`.
2734
+ const tokenReferenceToKey = (token) => (token === null || token === void 0 ? void 0 : token.replace(/[{}]/g, "").replace(/\./g, "-")) || "";
2735
+ const tokenStyleToJs = (token, tokens) => {
2736
+ const tokenKey = tokenReferenceToKey(token);
2737
+ const liveValue = tokens === null || tokens === void 0 ? void 0 : tokens[tokenKey];
2738
+ if (typeof liveValue === "string" && liveValue)
2739
+ return liveValue;
2734
2740
  return allColors[tokenKey] || "";
2735
2741
  };
2736
2742
  function buildSVGStyle(size, specialIconStyle, platform) {
@@ -2754,7 +2760,7 @@ function buildPathStyle(color, specialIconStyle) {
2754
2760
  };
2755
2761
  }
2756
2762
  // eslint-disable-next-line max-statements
2757
- function getIcon({ name, color, platform, size = "base", format = "css", }) {
2763
+ function getIcon({ name, color, platform, size = "base", format = "css", tokens, }) {
2758
2764
  const platformIconStyles = getIconStyles(platform);
2759
2765
  const { paths, viewBox } = getPaths(name);
2760
2766
  let specialIconStyle = {};
@@ -2764,8 +2770,8 @@ function getIcon({ name, color, platform, size = "base", format = "css", }) {
2764
2770
  const svgStyle = buildSVGStyle(size, specialIconStyle, platform);
2765
2771
  const pathStyle = buildPathStyle(color, specialIconStyle);
2766
2772
  if (format === "js") {
2767
- pathStyle.fill = tokenStyleToJs(pathStyle.fill);
2768
- svgStyle.fill = tokenStyleToJs(svgStyle.fill);
2773
+ pathStyle.fill = tokenStyleToJs(pathStyle.fill, tokens);
2774
+ svgStyle.fill = tokenStyleToJs(svgStyle.fill, tokens);
2769
2775
  }
2770
2776
  else {
2771
2777
  pathStyle.fill = tokenStyleToCss(pathStyle.fill);
package/dist/index.d.ts CHANGED
@@ -31,8 +31,15 @@ interface IconProps {
31
31
  interface GetIconProps extends IconProps {
32
32
  platform: "web" | "mobile";
33
33
  format?: "css" | "js";
34
+ /**
35
+ * Live theme tokens used to resolve token references at render time.
36
+ * When supplied (mobile/`format: "js"` consumers), color references resolve
37
+ * against these instead of the light-only `allColors` map. Ignored for
38
+ * `format: "css"` — web uses CSS variables that resolve at runtime.
39
+ */
40
+ tokens?: Record<string, unknown>;
34
41
  }
35
- export declare function getIcon({ name, color, platform, size, format, }: GetIconProps): {
42
+ export declare function getIcon({ name, color, platform, size, format, tokens, }: GetIconProps): {
36
43
  readonly svgStyle: {
37
44
  fill?: string;
38
45
  width: number;
package/dist/index.mjs CHANGED
@@ -2727,8 +2727,14 @@ const tokenStyleToCss = (token) => {
2727
2727
  const tokenAsString = typeof token === "string" ? token : token === null || token === void 0 ? void 0 : token.toString();
2728
2728
  return ((tokenAsString === null || tokenAsString === void 0 ? void 0 : tokenAsString.replace(/\{/g, "var(--").replace(/\./g, "-").replace(/\}/g, ")")) || "");
2729
2729
  };
2730
- const tokenStyleToJs = (token) => {
2731
- const tokenKey = (token === null || token === void 0 ? void 0 : token.replace(/}/g, "").replace(/{/g, "").replace(/\./g, "-")) || "";
2730
+ // Convert a token reference like `"{color.icon}"` into the flat token key
2731
+ // `"color-icon"` used by `tokens` / `allColors`.
2732
+ const tokenReferenceToKey = (token) => (token === null || token === void 0 ? void 0 : token.replace(/[{}]/g, "").replace(/\./g, "-")) || "";
2733
+ const tokenStyleToJs = (token, tokens) => {
2734
+ const tokenKey = tokenReferenceToKey(token);
2735
+ const liveValue = tokens === null || tokens === void 0 ? void 0 : tokens[tokenKey];
2736
+ if (typeof liveValue === "string" && liveValue)
2737
+ return liveValue;
2732
2738
  return allColors[tokenKey] || "";
2733
2739
  };
2734
2740
  function buildSVGStyle(size, specialIconStyle, platform) {
@@ -2752,7 +2758,7 @@ function buildPathStyle(color, specialIconStyle) {
2752
2758
  };
2753
2759
  }
2754
2760
  // eslint-disable-next-line max-statements
2755
- function getIcon({ name, color, platform, size = "base", format = "css", }) {
2761
+ function getIcon({ name, color, platform, size = "base", format = "css", tokens, }) {
2756
2762
  const platformIconStyles = getIconStyles(platform);
2757
2763
  const { paths, viewBox } = getPaths(name);
2758
2764
  let specialIconStyle = {};
@@ -2762,8 +2768,8 @@ function getIcon({ name, color, platform, size = "base", format = "css", }) {
2762
2768
  const svgStyle = buildSVGStyle(size, specialIconStyle, platform);
2763
2769
  const pathStyle = buildPathStyle(color, specialIconStyle);
2764
2770
  if (format === "js") {
2765
- pathStyle.fill = tokenStyleToJs(pathStyle.fill);
2766
- svgStyle.fill = tokenStyleToJs(svgStyle.fill);
2771
+ pathStyle.fill = tokenStyleToJs(pathStyle.fill, tokens);
2772
+ svgStyle.fill = tokenStyleToJs(svgStyle.fill, tokens);
2767
2773
  }
2768
2774
  else {
2769
2775
  pathStyle.fill = tokenStyleToCss(pathStyle.fill);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/design",
3
- "version": "0.101.1-chorecomp-aaf4bc5.3+aaf4bc51",
3
+ "version": "0.101.1",
4
4
  "description": "Design foundation for the Jobber Atlantis Design System",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -71,5 +71,5 @@
71
71
  "rrweb-cssom": "^0.7.1",
72
72
  "tsx": "^4.16.2"
73
73
  },
74
- "gitHead": "aaf4bc51d72500e54945f3734a7078fe2d901c59"
74
+ "gitHead": "7b859533f0b0482ad30654fb0fde5d41c2d918ba"
75
75
  }