@pandacss/token-dictionary 0.0.2 → 0.3.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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022 Segun Adebayo
3
+ Copyright (c) 2023 Segun Adebayo
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.d.ts CHANGED
@@ -124,7 +124,7 @@ declare class TokenDictionary$1 {
124
124
 
125
125
  declare class TokenDictionary extends TokenDictionary$1 {
126
126
  constructor(options: TokenDictionaryOptions);
127
- get get(): (path: string, fallback?: string | number | undefined) => any;
127
+ get get(): (path: string, fallback?: string | number | undefined) => string;
128
128
  get conditionMap(): Map<string, Set<Token>>;
129
129
  get categoryMap(): Map<string, Map<string, Token>>;
130
130
  get values(): Map<string, Map<string, string>>;
@@ -149,4 +149,4 @@ declare class TokenDictionary extends TokenDictionary$1 {
149
149
  getTokenVar(path: string): any;
150
150
  }
151
151
 
152
- export { TokenDictionary };
152
+ export { Token, TokenDictionary };
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // src/index.ts
21
21
  var src_exports = {};
22
22
  __export(src_exports, {
23
+ Token: () => Token,
23
24
  TokenDictionary: () => TokenDictionary2
24
25
  });
25
26
  module.exports = __toCommonJS(src_exports);
@@ -232,6 +233,11 @@ function expandBreakpoints(breakpoints) {
232
233
  sizes: Object.fromEntries(Object.entries(breakpoints).map(([key, value]) => [`breakpoint-${key}`, { value }]))
233
234
  };
234
235
  }
236
+ function filterDefault(path) {
237
+ if (path[0] === "DEFAULT")
238
+ return path;
239
+ return path.filter((item) => item !== "DEFAULT");
240
+ }
235
241
  var TokenDictionary = class {
236
242
  allTokens = [];
237
243
  prefix;
@@ -255,6 +261,7 @@ var TokenDictionary = class {
255
261
  (0, import_shared3.walkObject)(
256
262
  computedTokens,
257
263
  (token, path) => {
264
+ path = filterDefault(path);
258
265
  assertTokenFormat(token);
259
266
  const category = path[0];
260
267
  const name = path.join(".");
@@ -270,6 +277,7 @@ var TokenDictionary = class {
270
277
  (0, import_shared3.walkObject)(
271
278
  semanticTokens,
272
279
  (token, path) => {
280
+ path = filterDefault(path);
273
281
  assertTokenFormat(token);
274
282
  const category = path[0];
275
283
  const name = path.join(".");
@@ -527,6 +535,20 @@ var addNegativeTokens = {
527
535
  });
528
536
  }
529
537
  };
538
+ var units = /* @__PURE__ */ new Set(["spacing", "sizes", "borderWidths", "fontSizes", "radii"]);
539
+ var addPixelUnit = {
540
+ enforce: "post",
541
+ transform(dictionary) {
542
+ const tokens = dictionary.filter((token) => {
543
+ return units.has(token.extensions.category) && !token.extensions.isNegative;
544
+ });
545
+ tokens.forEach((token) => {
546
+ token.setExtensions({
547
+ pixelValue: (0, import_shared5.toPx)(token.value)
548
+ });
549
+ });
550
+ }
551
+ };
530
552
  var addVirtualPalette = {
531
553
  enforce: "post",
532
554
  transform(dictionary) {
@@ -566,7 +588,7 @@ var removeEmptyTokens = {
566
588
  dictionary.allTokens = dictionary.allTokens.filter((token) => token.value !== "");
567
589
  }
568
590
  };
569
- var middlewares = [addNegativeTokens, addVirtualPalette, removeEmptyTokens];
591
+ var middlewares = [addNegativeTokens, addVirtualPalette, removeEmptyTokens, addPixelUnit];
570
592
 
571
593
  // src/transform.ts
572
594
  var import_shared6 = require("@pandacss/shared");
@@ -866,5 +888,6 @@ var TokenDictionary2 = class extends TokenDictionary {
866
888
  };
867
889
  // Annotate the CommonJS export names for ESM import in node:
868
890
  0 && (module.exports = {
891
+ Token,
869
892
  TokenDictionary
870
893
  });
package/dist/index.mjs CHANGED
@@ -206,6 +206,11 @@ function expandBreakpoints(breakpoints) {
206
206
  sizes: Object.fromEntries(Object.entries(breakpoints).map(([key, value]) => [`breakpoint-${key}`, { value }]))
207
207
  };
208
208
  }
209
+ function filterDefault(path) {
210
+ if (path[0] === "DEFAULT")
211
+ return path;
212
+ return path.filter((item) => item !== "DEFAULT");
213
+ }
209
214
  var TokenDictionary = class {
210
215
  allTokens = [];
211
216
  prefix;
@@ -229,6 +234,7 @@ var TokenDictionary = class {
229
234
  walkObject2(
230
235
  computedTokens,
231
236
  (token, path) => {
237
+ path = filterDefault(path);
232
238
  assertTokenFormat(token);
233
239
  const category = path[0];
234
240
  const name = path.join(".");
@@ -244,6 +250,7 @@ var TokenDictionary = class {
244
250
  walkObject2(
245
251
  semanticTokens,
246
252
  (token, path) => {
253
+ path = filterDefault(path);
247
254
  assertTokenFormat(token);
248
255
  const category = path[0];
249
256
  const name = path.join(".");
@@ -473,7 +480,7 @@ var formats = {
473
480
  };
474
481
 
475
482
  // src/middleware.ts
476
- import { calc, cssVar } from "@pandacss/shared";
483
+ import { calc, cssVar, toPx } from "@pandacss/shared";
477
484
  var addNegativeTokens = {
478
485
  enforce: "pre",
479
486
  transform(dictionary, { prefix, hash }) {
@@ -501,6 +508,20 @@ var addNegativeTokens = {
501
508
  });
502
509
  }
503
510
  };
511
+ var units = /* @__PURE__ */ new Set(["spacing", "sizes", "borderWidths", "fontSizes", "radii"]);
512
+ var addPixelUnit = {
513
+ enforce: "post",
514
+ transform(dictionary) {
515
+ const tokens = dictionary.filter((token) => {
516
+ return units.has(token.extensions.category) && !token.extensions.isNegative;
517
+ });
518
+ tokens.forEach((token) => {
519
+ token.setExtensions({
520
+ pixelValue: toPx(token.value)
521
+ });
522
+ });
523
+ }
524
+ };
504
525
  var addVirtualPalette = {
505
526
  enforce: "post",
506
527
  transform(dictionary) {
@@ -540,7 +561,7 @@ var removeEmptyTokens = {
540
561
  dictionary.allTokens = dictionary.allTokens.filter((token) => token.value !== "");
541
562
  }
542
563
  };
543
- var middlewares = [addNegativeTokens, addVirtualPalette, removeEmptyTokens];
564
+ var middlewares = [addNegativeTokens, addVirtualPalette, removeEmptyTokens, addPixelUnit];
544
565
 
545
566
  // src/transform.ts
546
567
  import { cssVar as cssVar2, isString as isString2 } from "@pandacss/shared";
@@ -839,5 +860,6 @@ var TokenDictionary2 = class extends TokenDictionary {
839
860
  }
840
861
  };
841
862
  export {
863
+ Token,
842
864
  TokenDictionary2 as TokenDictionary
843
865
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/token-dictionary",
3
- "version": "0.0.2",
3
+ "version": "0.3.1",
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": "4.3.0",
18
- "@pandacss/types": "0.0.2",
19
- "@pandacss/shared": "0.0.2"
18
+ "@pandacss/types": "0.3.1",
19
+ "@pandacss/shared": "0.3.1"
20
20
  },
21
21
  "devDependencies": {
22
- "@pandacss/fixture": "0.0.2"
22
+ "@pandacss/fixture": "0.3.1"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsup src/index.ts --format=esm,cjs --dts",