@pandacss/token-dictionary 0.13.1 → 0.15.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
@@ -364,7 +364,7 @@ var TokenDictionary = class {
364
364
  applyMiddlewares(enforce) {
365
365
  this.middlewares.forEach((middleware) => {
366
366
  if (middleware.enforce === enforce) {
367
- middleware.transform(this, { prefix: this.prefix });
367
+ middleware.transform(this, { prefix: this.prefix, hash: this.hash });
368
368
  }
369
369
  });
370
370
  }
@@ -444,16 +444,18 @@ var formats = {
444
444
  groupByColorPalette(dictionary) {
445
445
  const grouped = /* @__PURE__ */ new Map();
446
446
  dictionary.allTokens.forEach((token) => {
447
- const { colorPalette } = token.extensions;
447
+ const { colorPalette, colorPaletteRoots } = token.extensions;
448
448
  if (!colorPalette || token.extensions.isVirtual)
449
449
  return;
450
- grouped.get(colorPalette) || grouped.set(colorPalette, /* @__PURE__ */ new Map());
451
- const virtualName = token.name.replace(colorPalette, "colorPalette");
452
- const virtualToken = dictionary.getByName(virtualName);
453
- if (!virtualToken)
454
- return;
455
- const virtualVar = virtualToken.extensions.var;
456
- grouped.get(colorPalette).set(virtualVar, token.extensions.varRef);
450
+ colorPaletteRoots.forEach((colorPaletteRoot) => {
451
+ grouped.get(colorPaletteRoot) || grouped.set(colorPaletteRoot, /* @__PURE__ */ new Map());
452
+ const virtualName = token.name.replace(colorPaletteRoot, "colorPalette");
453
+ const virtualToken = dictionary.getByName(virtualName);
454
+ if (!virtualToken)
455
+ return;
456
+ const virtualVar = virtualToken.extensions.var;
457
+ grouped.get(colorPaletteRoot).set(virtualVar, token.extensions.varRef);
458
+ });
457
459
  });
458
460
  return grouped;
459
461
  },
@@ -567,19 +569,21 @@ var addVirtualPalette = {
567
569
  const keys = /* @__PURE__ */ new Set();
568
570
  const colorPalettes = /* @__PURE__ */ new Map();
569
571
  tokens.forEach((token) => {
570
- const { colorPalette } = token.extensions;
572
+ const { colorPalette, colorPaletteRoots, colorPaletteTokenKeys } = token.extensions;
571
573
  if (!colorPalette)
572
574
  return;
573
- const list = colorPalettes.get(colorPalette) || [];
574
- keys.add(token.path.at(-1));
575
- list.push(token);
576
- colorPalettes.set(colorPalette, list);
575
+ colorPaletteTokenKeys.forEach(keys.add, keys);
576
+ colorPaletteRoots.forEach((colorPaletteRoot) => {
577
+ const colorPaletteList = colorPalettes.get(colorPaletteRoot) || [];
578
+ colorPaletteList.push(token);
579
+ colorPalettes.set(colorPaletteRoot, colorPaletteList);
580
+ });
577
581
  });
578
582
  keys.forEach((key) => {
579
583
  const node = new Token({
580
584
  name: `colors.colorPalette.${key}`,
581
585
  value: `{colors.colorPalette.${key}}`,
582
- path: ["colors", "colorPalette", key]
586
+ path: ["colors", "colorPalette", ...key.split(".")]
583
587
  });
584
588
  node.setExtensions({
585
589
  category: "colors",
@@ -839,22 +843,34 @@ var addConditionalCssVariables = {
839
843
  return token.value;
840
844
  }
841
845
  };
842
- function getColorPaletteName(path) {
843
- if (path.includes("colorPalette"))
844
- return "";
845
- const clone = [...path];
846
- clone.pop();
847
- clone.shift();
848
- return clone.join(".");
849
- }
850
846
  var addColorPalette = {
851
847
  type: "extensions",
852
848
  name: "tokens/colors/colorPalette",
853
849
  match(token) {
854
- return token.extensions.category === "colors";
850
+ return token.extensions.category === "colors" && !token.extensions.isVirtual;
855
851
  },
856
852
  transform(token) {
857
- return { colorPalette: getColorPaletteName(token.path) };
853
+ const tokenPathClone = [...token.path];
854
+ tokenPathClone.pop();
855
+ tokenPathClone.shift();
856
+ if (tokenPathClone.length === 0) {
857
+ return {};
858
+ }
859
+ const colorPaletteRoots = tokenPathClone.reduce((acc, _, i, arr) => {
860
+ acc.push(arr.slice(0, i + 1).join("."));
861
+ return acc;
862
+ }, []);
863
+ const colorPaletteRoot = tokenPathClone.at(0);
864
+ const colorPalette = tokenPathClone.join(".");
865
+ const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce((acc, _, i, arr) => {
866
+ acc.push(arr.slice(i).join("."));
867
+ return acc;
868
+ }, []);
869
+ return {
870
+ colorPalette,
871
+ colorPaletteRoots,
872
+ colorPaletteTokenKeys
873
+ };
858
874
  }
859
875
  };
860
876
  var transforms = [
package/dist/index.mjs CHANGED
@@ -337,7 +337,7 @@ var TokenDictionary = class {
337
337
  applyMiddlewares(enforce) {
338
338
  this.middlewares.forEach((middleware) => {
339
339
  if (middleware.enforce === enforce) {
340
- middleware.transform(this, { prefix: this.prefix });
340
+ middleware.transform(this, { prefix: this.prefix, hash: this.hash });
341
341
  }
342
342
  });
343
343
  }
@@ -417,16 +417,18 @@ var formats = {
417
417
  groupByColorPalette(dictionary) {
418
418
  const grouped = /* @__PURE__ */ new Map();
419
419
  dictionary.allTokens.forEach((token) => {
420
- const { colorPalette } = token.extensions;
420
+ const { colorPalette, colorPaletteRoots } = token.extensions;
421
421
  if (!colorPalette || token.extensions.isVirtual)
422
422
  return;
423
- grouped.get(colorPalette) || grouped.set(colorPalette, /* @__PURE__ */ new Map());
424
- const virtualName = token.name.replace(colorPalette, "colorPalette");
425
- const virtualToken = dictionary.getByName(virtualName);
426
- if (!virtualToken)
427
- return;
428
- const virtualVar = virtualToken.extensions.var;
429
- grouped.get(colorPalette).set(virtualVar, token.extensions.varRef);
423
+ colorPaletteRoots.forEach((colorPaletteRoot) => {
424
+ grouped.get(colorPaletteRoot) || grouped.set(colorPaletteRoot, /* @__PURE__ */ new Map());
425
+ const virtualName = token.name.replace(colorPaletteRoot, "colorPalette");
426
+ const virtualToken = dictionary.getByName(virtualName);
427
+ if (!virtualToken)
428
+ return;
429
+ const virtualVar = virtualToken.extensions.var;
430
+ grouped.get(colorPaletteRoot).set(virtualVar, token.extensions.varRef);
431
+ });
430
432
  });
431
433
  return grouped;
432
434
  },
@@ -540,19 +542,21 @@ var addVirtualPalette = {
540
542
  const keys = /* @__PURE__ */ new Set();
541
543
  const colorPalettes = /* @__PURE__ */ new Map();
542
544
  tokens.forEach((token) => {
543
- const { colorPalette } = token.extensions;
545
+ const { colorPalette, colorPaletteRoots, colorPaletteTokenKeys } = token.extensions;
544
546
  if (!colorPalette)
545
547
  return;
546
- const list = colorPalettes.get(colorPalette) || [];
547
- keys.add(token.path.at(-1));
548
- list.push(token);
549
- colorPalettes.set(colorPalette, list);
548
+ colorPaletteTokenKeys.forEach(keys.add, keys);
549
+ colorPaletteRoots.forEach((colorPaletteRoot) => {
550
+ const colorPaletteList = colorPalettes.get(colorPaletteRoot) || [];
551
+ colorPaletteList.push(token);
552
+ colorPalettes.set(colorPaletteRoot, colorPaletteList);
553
+ });
550
554
  });
551
555
  keys.forEach((key) => {
552
556
  const node = new Token({
553
557
  name: `colors.colorPalette.${key}`,
554
558
  value: `{colors.colorPalette.${key}}`,
555
- path: ["colors", "colorPalette", key]
559
+ path: ["colors", "colorPalette", ...key.split(".")]
556
560
  });
557
561
  node.setExtensions({
558
562
  category: "colors",
@@ -812,22 +816,34 @@ var addConditionalCssVariables = {
812
816
  return token.value;
813
817
  }
814
818
  };
815
- function getColorPaletteName(path) {
816
- if (path.includes("colorPalette"))
817
- return "";
818
- const clone = [...path];
819
- clone.pop();
820
- clone.shift();
821
- return clone.join(".");
822
- }
823
819
  var addColorPalette = {
824
820
  type: "extensions",
825
821
  name: "tokens/colors/colorPalette",
826
822
  match(token) {
827
- return token.extensions.category === "colors";
823
+ return token.extensions.category === "colors" && !token.extensions.isVirtual;
828
824
  },
829
825
  transform(token) {
830
- return { colorPalette: getColorPaletteName(token.path) };
826
+ const tokenPathClone = [...token.path];
827
+ tokenPathClone.pop();
828
+ tokenPathClone.shift();
829
+ if (tokenPathClone.length === 0) {
830
+ return {};
831
+ }
832
+ const colorPaletteRoots = tokenPathClone.reduce((acc, _, i, arr) => {
833
+ acc.push(arr.slice(0, i + 1).join("."));
834
+ return acc;
835
+ }, []);
836
+ const colorPaletteRoot = tokenPathClone.at(0);
837
+ const colorPalette = tokenPathClone.join(".");
838
+ const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce((acc, _, i, arr) => {
839
+ acc.push(arr.slice(i).join("."));
840
+ return acc;
841
+ }, []);
842
+ return {
843
+ colorPalette,
844
+ colorPaletteRoots,
845
+ colorPaletteTokenKeys
846
+ };
831
847
  }
832
848
  };
833
849
  var transforms = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/token-dictionary",
3
- "version": "0.13.1",
3
+ "version": "0.15.0",
4
4
  "description": "Common error messages for css panda",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -15,11 +15,11 @@
15
15
  ],
16
16
  "dependencies": {
17
17
  "ts-pattern": "5.0.4",
18
- "@pandacss/types": "0.13.1",
19
- "@pandacss/shared": "0.13.1"
18
+ "@pandacss/types": "0.15.0",
19
+ "@pandacss/shared": "0.15.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@pandacss/fixture": "0.13.1"
22
+ "@pandacss/fixture": "0.15.0"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsup src/index.ts --format=esm,cjs --dts",