@pandacss/token-dictionary 0.24.2 → 0.25.0

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.d.mts CHANGED
@@ -155,6 +155,7 @@ declare class TokenDictionary extends TokenDictionary$1 {
155
155
  [k: string]: string;
156
156
  } | undefined;
157
157
  getTokenVar(path: string): any;
158
+ expandReference(value: string): string;
158
159
  }
159
160
 
160
161
  export { Token, TokenDictionary };
package/dist/index.d.ts CHANGED
@@ -155,6 +155,7 @@ declare class TokenDictionary extends TokenDictionary$1 {
155
155
  [k: string]: string;
156
156
  } | undefined;
157
157
  getTokenVar(path: string): any;
158
+ expandReference(value: string): string;
158
159
  }
159
160
 
160
161
  export { Token, TokenDictionary };
package/dist/index.js CHANGED
@@ -84,6 +84,15 @@ function getReferences(value) {
84
84
  function hasReference(value) {
85
85
  return REFERENCE_REGEX.test(value);
86
86
  }
87
+ function expandReferences(value, fn) {
88
+ if (!hasReference(value))
89
+ return value;
90
+ const references = getReferences(value);
91
+ return references.reduce((valueStr, key) => {
92
+ const value2 = fn(key) ?? key;
93
+ return valueStr.replace(`{${key}}`, value2);
94
+ }, value);
95
+ }
87
96
  function mapToJson(map) {
88
97
  const obj = {};
89
98
  map.forEach((value, key) => {
@@ -947,6 +956,9 @@ var TokenDictionary2 = class extends TokenDictionary {
947
956
  const json = (0, import_shared7.mapToJson)(this.values);
948
957
  return (0, import_shared7.getDotPath)(json, path);
949
958
  }
959
+ expandReference(value) {
960
+ return expandReferences(value, (key) => this.get(key));
961
+ }
950
962
  };
951
963
  // Annotate the CommonJS export names for ESM import in node:
952
964
  0 && (module.exports = {
package/dist/index.mjs CHANGED
@@ -57,6 +57,15 @@ function getReferences(value) {
57
57
  function hasReference(value) {
58
58
  return REFERENCE_REGEX.test(value);
59
59
  }
60
+ function expandReferences(value, fn) {
61
+ if (!hasReference(value))
62
+ return value;
63
+ const references = getReferences(value);
64
+ return references.reduce((valueStr, key) => {
65
+ const value2 = fn(key) ?? key;
66
+ return valueStr.replace(`{${key}}`, value2);
67
+ }, value);
68
+ }
60
69
  function mapToJson(map) {
61
70
  const obj = {};
62
71
  map.forEach((value, key) => {
@@ -920,6 +929,9 @@ var TokenDictionary2 = class extends TokenDictionary {
920
929
  const json = mapToJson2(this.values);
921
930
  return getDotPath2(json, path);
922
931
  }
932
+ expandReference(value) {
933
+ return expandReferences(value, (key) => this.get(key));
934
+ }
923
935
  };
924
936
  export {
925
937
  Token,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/token-dictionary",
3
- "version": "0.24.2",
3
+ "version": "0.25.0",
4
4
  "description": "Common error messages for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,8 +33,8 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "ts-pattern": "5.0.5",
36
- "@pandacss/shared": "0.24.2",
37
- "@pandacss/types": "0.24.2"
36
+ "@pandacss/shared": "0.25.0",
37
+ "@pandacss/types": "0.25.0"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsup src/index.ts --format=esm,cjs --dts",