@pandacss/token-dictionary 0.32.0 → 0.33.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.js CHANGED
@@ -365,6 +365,13 @@ var addVirtualPalette = {
365
365
  const colorPaletteList = colorPalettes.get(formated) || [];
366
366
  colorPaletteList.push(token);
367
367
  colorPalettes.set(formated, colorPaletteList);
368
+ if (token.extensions.isDefault && colorPaletteRoot.length === 1) {
369
+ const keyPath = colorPaletteTokenKeys[0]?.filter(Boolean);
370
+ if (!keyPath.length)
371
+ return;
372
+ const path = colorPaletteRoot.concat(keyPath);
373
+ keys.set(dictionary.formatTokenName(path), []);
374
+ }
368
375
  });
369
376
  });
370
377
  keys.forEach((segments) => {
@@ -576,7 +583,7 @@ var transformAssets = {
576
583
  match: (token) => token.extensions.category === "assets",
577
584
  transform(token) {
578
585
  const raw = token.value;
579
- return (0, import_ts_pattern2.match)(raw).with(import_ts_pattern2.P.string, (value) => value).with({ type: "url" }, ({ value }) => `url('${value}')`).with({ type: "svg" }, ({ value }) => `url('${svgToDataUri(value)})'`).exhaustive();
586
+ return (0, import_ts_pattern2.match)(raw).with(import_ts_pattern2.P.string, (value) => value).with({ type: "url" }, ({ value }) => `url("${value}")`).with({ type: "svg" }, ({ value }) => `url("${svgToDataUri(value)}")`).exhaustive();
580
587
  }
581
588
  };
582
589
  var addCssVariables = {
@@ -626,17 +633,23 @@ var addColorPalette = {
626
633
  if (tokenPathClone.length === 0) {
627
634
  return {};
628
635
  }
629
- const colorPaletteRoots = tokenPathClone.reduce((acc, _, i, arr) => {
630
- const next = arr.slice(0, i + 1);
631
- acc.push(next);
632
- return acc;
633
- }, []);
636
+ const colorPaletteRoots = tokenPathClone.reduce(
637
+ (acc, _, i, arr) => {
638
+ const next = arr.slice(0, i + 1);
639
+ acc.push(next);
640
+ return acc;
641
+ },
642
+ []
643
+ );
634
644
  const colorPaletteRoot = tokenPathClone[0];
635
645
  const colorPalette = dict.formatTokenName(tokenPathClone);
636
- const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce((acc, _, i, arr) => {
637
- acc.push(arr.slice(i));
638
- return acc;
639
- }, []);
646
+ const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce(
647
+ (acc, _, i, arr) => {
648
+ acc.push(arr.slice(i));
649
+ return acc;
650
+ },
651
+ []
652
+ );
640
653
  if (colorPaletteTokenKeys.length === 0) {
641
654
  colorPaletteTokenKeys.push([""]);
642
655
  }
@@ -711,6 +724,7 @@ var TokenDictionary = class {
711
724
  (0, import_shared5.walkObject)(
712
725
  computedTokens,
713
726
  (token, path) => {
727
+ const isDefault = path.includes("DEFAULT");
714
728
  path = filterDefault(path);
715
729
  assertTokenFormat(token);
716
730
  const category = path[0];
@@ -720,6 +734,9 @@ var TokenDictionary = class {
720
734
  category,
721
735
  prop: this.formatTokenName(path.slice(1))
722
736
  });
737
+ if (isDefault) {
738
+ node.setExtensions({ isDefault });
739
+ }
723
740
  this.registerToken(node);
724
741
  },
725
742
  { stop: isToken }
@@ -727,6 +744,7 @@ var TokenDictionary = class {
727
744
  (0, import_shared5.walkObject)(
728
745
  semanticTokens,
729
746
  (token, path) => {
747
+ const isDefault = path.includes("DEFAULT");
730
748
  path = filterDefault(path);
731
749
  assertTokenFormat(token);
732
750
  const category = path[0];
@@ -744,6 +762,9 @@ var TokenDictionary = class {
744
762
  conditions: value,
745
763
  prop: this.formatTokenName(path.slice(1))
746
764
  });
765
+ if (isDefault) {
766
+ node.setExtensions({ isDefault });
767
+ }
747
768
  this.registerToken(node);
748
769
  },
749
770
  { stop: isToken }
@@ -843,10 +864,13 @@ var TokenDictionary = class {
843
864
  return;
844
865
  const references = this.getReferences(token.value);
845
866
  token.setExtensions({
846
- references: references.reduce((object, reference) => {
847
- object[reference.name] = reference;
848
- return object;
849
- }, {})
867
+ references: references.reduce(
868
+ (object, reference) => {
869
+ object[reference.name] = reference;
870
+ return object;
871
+ },
872
+ {}
873
+ )
850
874
  });
851
875
  });
852
876
  return this;
@@ -951,7 +975,8 @@ var TokenDictionaryView = class {
951
975
  group.get(condition).add(token);
952
976
  }
953
977
  processColorPalette(token, group, byName) {
954
- const { colorPalette, colorPaletteRoots, isVirtual } = token.extensions;
978
+ const extensions = token.extensions;
979
+ const { colorPalette, colorPaletteRoots, isVirtual } = extensions;
955
980
  if (!colorPalette || isVirtual)
956
981
  return;
957
982
  colorPaletteRoots.forEach((colorPaletteRoot) => {
@@ -966,6 +991,24 @@ var TokenDictionaryView = class {
966
991
  return;
967
992
  const virtualVar = virtualToken.extensions.var;
968
993
  group.get(formated).set(virtualVar, token.extensions.varRef);
994
+ if (extensions.isDefault && colorPaletteRoot.length === 1) {
995
+ const colorPaletteName = this.dictionary.formatTokenName(["colors", "colorPalette"]);
996
+ const colorPaletteToken = byName.get(colorPaletteName);
997
+ if (!colorPaletteToken)
998
+ return;
999
+ const name = this.dictionary.formatTokenName(token.path);
1000
+ const virtualToken2 = byName.get(name);
1001
+ if (!virtualToken2)
1002
+ return;
1003
+ const keyPath = extensions.colorPaletteTokenKeys[0]?.filter(Boolean);
1004
+ if (!keyPath.length)
1005
+ return;
1006
+ const formated2 = this.dictionary.formatTokenName(colorPaletteRoot.concat(keyPath));
1007
+ if (!group.has(formated2)) {
1008
+ group.set(formated2, /* @__PURE__ */ new Map());
1009
+ }
1010
+ group.get(formated2).set(colorPaletteToken.extensions.var, virtualToken2.extensions.varRef);
1011
+ }
969
1012
  });
970
1013
  }
971
1014
  processCategory(token, group) {
@@ -984,7 +1027,7 @@ var TokenDictionaryView = class {
984
1027
  byCategory.set(category, /* @__PURE__ */ new Map());
985
1028
  const value = isNegative ? token.isConditional ? token.originalValue : token.value : varRef;
986
1029
  byCategory.get(category).set(prop, value);
987
- flat.set([category, prop].join("."), value);
1030
+ flat.set(token.name, value);
988
1031
  }
989
1032
  processVars(token, group) {
990
1033
  const { condition, isNegative, isVirtual, var: varName } = token.extensions;
package/dist/index.mjs CHANGED
@@ -345,6 +345,13 @@ var addVirtualPalette = {
345
345
  const colorPaletteList = colorPalettes.get(formated) || [];
346
346
  colorPaletteList.push(token);
347
347
  colorPalettes.set(formated, colorPaletteList);
348
+ if (token.extensions.isDefault && colorPaletteRoot.length === 1) {
349
+ const keyPath = colorPaletteTokenKeys[0]?.filter(Boolean);
350
+ if (!keyPath.length)
351
+ return;
352
+ const path = colorPaletteRoot.concat(keyPath);
353
+ keys.set(dictionary.formatTokenName(path), []);
354
+ }
348
355
  });
349
356
  });
350
357
  keys.forEach((segments) => {
@@ -556,7 +563,7 @@ var transformAssets = {
556
563
  match: (token) => token.extensions.category === "assets",
557
564
  transform(token) {
558
565
  const raw = token.value;
559
- return match(raw).with(P2.string, (value) => value).with({ type: "url" }, ({ value }) => `url('${value}')`).with({ type: "svg" }, ({ value }) => `url('${svgToDataUri(value)})'`).exhaustive();
566
+ return match(raw).with(P2.string, (value) => value).with({ type: "url" }, ({ value }) => `url("${value}")`).with({ type: "svg" }, ({ value }) => `url("${svgToDataUri(value)}")`).exhaustive();
560
567
  }
561
568
  };
562
569
  var addCssVariables = {
@@ -606,17 +613,23 @@ var addColorPalette = {
606
613
  if (tokenPathClone.length === 0) {
607
614
  return {};
608
615
  }
609
- const colorPaletteRoots = tokenPathClone.reduce((acc, _, i, arr) => {
610
- const next = arr.slice(0, i + 1);
611
- acc.push(next);
612
- return acc;
613
- }, []);
616
+ const colorPaletteRoots = tokenPathClone.reduce(
617
+ (acc, _, i, arr) => {
618
+ const next = arr.slice(0, i + 1);
619
+ acc.push(next);
620
+ return acc;
621
+ },
622
+ []
623
+ );
614
624
  const colorPaletteRoot = tokenPathClone[0];
615
625
  const colorPalette = dict.formatTokenName(tokenPathClone);
616
- const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce((acc, _, i, arr) => {
617
- acc.push(arr.slice(i));
618
- return acc;
619
- }, []);
626
+ const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce(
627
+ (acc, _, i, arr) => {
628
+ acc.push(arr.slice(i));
629
+ return acc;
630
+ },
631
+ []
632
+ );
620
633
  if (colorPaletteTokenKeys.length === 0) {
621
634
  colorPaletteTokenKeys.push([""]);
622
635
  }
@@ -691,6 +704,7 @@ var TokenDictionary = class {
691
704
  walkObject2(
692
705
  computedTokens,
693
706
  (token, path) => {
707
+ const isDefault = path.includes("DEFAULT");
694
708
  path = filterDefault(path);
695
709
  assertTokenFormat(token);
696
710
  const category = path[0];
@@ -700,6 +714,9 @@ var TokenDictionary = class {
700
714
  category,
701
715
  prop: this.formatTokenName(path.slice(1))
702
716
  });
717
+ if (isDefault) {
718
+ node.setExtensions({ isDefault });
719
+ }
703
720
  this.registerToken(node);
704
721
  },
705
722
  { stop: isToken }
@@ -707,6 +724,7 @@ var TokenDictionary = class {
707
724
  walkObject2(
708
725
  semanticTokens,
709
726
  (token, path) => {
727
+ const isDefault = path.includes("DEFAULT");
710
728
  path = filterDefault(path);
711
729
  assertTokenFormat(token);
712
730
  const category = path[0];
@@ -724,6 +742,9 @@ var TokenDictionary = class {
724
742
  conditions: value,
725
743
  prop: this.formatTokenName(path.slice(1))
726
744
  });
745
+ if (isDefault) {
746
+ node.setExtensions({ isDefault });
747
+ }
727
748
  this.registerToken(node);
728
749
  },
729
750
  { stop: isToken }
@@ -823,10 +844,13 @@ var TokenDictionary = class {
823
844
  return;
824
845
  const references = this.getReferences(token.value);
825
846
  token.setExtensions({
826
- references: references.reduce((object, reference) => {
827
- object[reference.name] = reference;
828
- return object;
829
- }, {})
847
+ references: references.reduce(
848
+ (object, reference) => {
849
+ object[reference.name] = reference;
850
+ return object;
851
+ },
852
+ {}
853
+ )
830
854
  });
831
855
  });
832
856
  return this;
@@ -931,7 +955,8 @@ var TokenDictionaryView = class {
931
955
  group.get(condition).add(token);
932
956
  }
933
957
  processColorPalette(token, group, byName) {
934
- const { colorPalette, colorPaletteRoots, isVirtual } = token.extensions;
958
+ const extensions = token.extensions;
959
+ const { colorPalette, colorPaletteRoots, isVirtual } = extensions;
935
960
  if (!colorPalette || isVirtual)
936
961
  return;
937
962
  colorPaletteRoots.forEach((colorPaletteRoot) => {
@@ -946,6 +971,24 @@ var TokenDictionaryView = class {
946
971
  return;
947
972
  const virtualVar = virtualToken.extensions.var;
948
973
  group.get(formated).set(virtualVar, token.extensions.varRef);
974
+ if (extensions.isDefault && colorPaletteRoot.length === 1) {
975
+ const colorPaletteName = this.dictionary.formatTokenName(["colors", "colorPalette"]);
976
+ const colorPaletteToken = byName.get(colorPaletteName);
977
+ if (!colorPaletteToken)
978
+ return;
979
+ const name = this.dictionary.formatTokenName(token.path);
980
+ const virtualToken2 = byName.get(name);
981
+ if (!virtualToken2)
982
+ return;
983
+ const keyPath = extensions.colorPaletteTokenKeys[0]?.filter(Boolean);
984
+ if (!keyPath.length)
985
+ return;
986
+ const formated2 = this.dictionary.formatTokenName(colorPaletteRoot.concat(keyPath));
987
+ if (!group.has(formated2)) {
988
+ group.set(formated2, /* @__PURE__ */ new Map());
989
+ }
990
+ group.get(formated2).set(colorPaletteToken.extensions.var, virtualToken2.extensions.varRef);
991
+ }
949
992
  });
950
993
  }
951
994
  processCategory(token, group) {
@@ -964,7 +1007,7 @@ var TokenDictionaryView = class {
964
1007
  byCategory.set(category, /* @__PURE__ */ new Map());
965
1008
  const value = isNegative ? token.isConditional ? token.originalValue : token.value : varRef;
966
1009
  byCategory.get(category).set(prop, value);
967
- flat.set([category, prop].join("."), value);
1010
+ flat.set(token.name, value);
968
1011
  }
969
1012
  processVars(token, group) {
970
1013
  const { condition, isNegative, isVirtual, var: varName } = token.extensions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/token-dictionary",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "Common error messages for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -33,9 +33,9 @@
33
33
  ],
34
34
  "dependencies": {
35
35
  "ts-pattern": "5.0.8",
36
- "@pandacss/logger": "^0.32.0",
37
- "@pandacss/shared": "0.32.0",
38
- "@pandacss/types": "0.32.0"
36
+ "@pandacss/logger": "^0.33.0",
37
+ "@pandacss/shared": "0.33.0",
38
+ "@pandacss/types": "0.33.0"
39
39
  },
40
40
  "scripts": {
41
41
  "build": "tsup src/index.ts --format=esm,cjs --dts",