@pandacss/token-dictionary 0.18.0 → 0.18.2
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 +78 -52
- package/dist/index.mjs +79 -53
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -30,7 +30,41 @@ var import_shared7 = require("@pandacss/shared");
|
|
|
30
30
|
|
|
31
31
|
// src/dictionary.ts
|
|
32
32
|
var import_shared3 = require("@pandacss/shared");
|
|
33
|
+
var import_ts_pattern2 = require("ts-pattern");
|
|
34
|
+
|
|
35
|
+
// src/is-composite.ts
|
|
33
36
|
var import_ts_pattern = require("ts-pattern");
|
|
37
|
+
var isCompositeShadow = (0, import_ts_pattern.isMatching)({
|
|
38
|
+
inset: import_ts_pattern.P.optional(import_ts_pattern.P.boolean),
|
|
39
|
+
offsetX: import_ts_pattern.P.number,
|
|
40
|
+
offsetY: import_ts_pattern.P.number,
|
|
41
|
+
blur: import_ts_pattern.P.number,
|
|
42
|
+
spread: import_ts_pattern.P.number,
|
|
43
|
+
color: import_ts_pattern.P.string
|
|
44
|
+
});
|
|
45
|
+
var isCompositeGradient = (0, import_ts_pattern.isMatching)({
|
|
46
|
+
type: import_ts_pattern.P.string,
|
|
47
|
+
placement: import_ts_pattern.P.string,
|
|
48
|
+
stops: import_ts_pattern.P.union(
|
|
49
|
+
import_ts_pattern.P.array(import_ts_pattern.P.string),
|
|
50
|
+
import_ts_pattern.P.array({
|
|
51
|
+
color: import_ts_pattern.P.string,
|
|
52
|
+
position: import_ts_pattern.P.number
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
});
|
|
56
|
+
var isCompositeBorder = (0, import_ts_pattern.isMatching)({
|
|
57
|
+
color: import_ts_pattern.P.string,
|
|
58
|
+
width: import_ts_pattern.P.union(import_ts_pattern.P.string, import_ts_pattern.P.number),
|
|
59
|
+
style: import_ts_pattern.P.string
|
|
60
|
+
});
|
|
61
|
+
var isCompositeAsset = (0, import_ts_pattern.isMatching)({
|
|
62
|
+
type: import_ts_pattern.P.union("url", "svg"),
|
|
63
|
+
value: import_ts_pattern.P.string
|
|
64
|
+
});
|
|
65
|
+
var isCompositeTokenValue = (value) => {
|
|
66
|
+
return isCompositeGradient(value) || isCompositeShadow(value) || isCompositeBorder(value) || isCompositeAsset(value) || Array.isArray(value);
|
|
67
|
+
};
|
|
34
68
|
|
|
35
69
|
// src/token.ts
|
|
36
70
|
var import_shared2 = require("@pandacss/shared");
|
|
@@ -118,7 +152,7 @@ var Token = class _Token {
|
|
|
118
152
|
* Whether the token is a complex or composite token.
|
|
119
153
|
*/
|
|
120
154
|
get isComposite() {
|
|
121
|
-
return (
|
|
155
|
+
return isCompositeTokenValue(this.originalValue);
|
|
122
156
|
}
|
|
123
157
|
/**
|
|
124
158
|
* Returns the token value with the references expanded.
|
|
@@ -287,7 +321,7 @@ var TokenDictionary = class {
|
|
|
287
321
|
assertTokenFormat(token);
|
|
288
322
|
const category = path[0];
|
|
289
323
|
const name = path.join(".");
|
|
290
|
-
const normalizedToken = (0, import_shared3.isString)(token.value) ? { value: { base: token.value } } : token;
|
|
324
|
+
const normalizedToken = (0, import_shared3.isString)(token.value) || isCompositeTokenValue(token.value) ? { value: { base: token.value } } : token;
|
|
291
325
|
const { value, ...restData } = normalizedToken;
|
|
292
326
|
const node = new Token({
|
|
293
327
|
...restData,
|
|
@@ -329,17 +363,24 @@ var TokenDictionary = class {
|
|
|
329
363
|
return;
|
|
330
364
|
if (typeof transform.match === "function" && !transform.match(token))
|
|
331
365
|
return;
|
|
332
|
-
const
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
});
|
|
336
|
-
(0, import_ts_pattern.match)(transform).with({ type: "extensions" }, () => {
|
|
366
|
+
const exec = (v) => transform.transform(v, { prefix: this.prefix, hash: this.hash });
|
|
367
|
+
const transformed = exec(token);
|
|
368
|
+
(0, import_ts_pattern2.match)(transform).with({ type: "extensions" }, () => {
|
|
337
369
|
token.setExtensions(transformed);
|
|
338
370
|
}).with({ type: "value" }, () => {
|
|
339
371
|
token.value = transformed;
|
|
340
372
|
if (token.isComposite) {
|
|
341
373
|
token.originalValue = transformed;
|
|
342
374
|
}
|
|
375
|
+
if (token.extensions.conditions) {
|
|
376
|
+
const conditions = token.extensions.conditions;
|
|
377
|
+
const transformedConditions = (0, import_shared3.walkObject)(conditions, (value) => exec({ value }), {
|
|
378
|
+
stop: isCompositeTokenValue
|
|
379
|
+
});
|
|
380
|
+
token.setExtensions({
|
|
381
|
+
conditions: transformedConditions
|
|
382
|
+
});
|
|
383
|
+
}
|
|
343
384
|
}).otherwise(() => {
|
|
344
385
|
token[transform.type] = transformed;
|
|
345
386
|
});
|
|
@@ -392,7 +433,7 @@ var TokenDictionary = class {
|
|
|
392
433
|
return this;
|
|
393
434
|
}
|
|
394
435
|
filter(pattern) {
|
|
395
|
-
const predicate = typeof pattern === "function" ? pattern : (0,
|
|
436
|
+
const predicate = typeof pattern === "function" ? pattern : (0, import_ts_pattern2.isMatching)(pattern);
|
|
396
437
|
return this.allTokens.filter(predicate);
|
|
397
438
|
}
|
|
398
439
|
addConditionalTokens() {
|
|
@@ -581,13 +622,13 @@ var addVirtualPalette = {
|
|
|
581
622
|
});
|
|
582
623
|
keys.forEach((key) => {
|
|
583
624
|
const node = new Token({
|
|
584
|
-
name:
|
|
585
|
-
value:
|
|
625
|
+
name: ["colors.colorPalette", key].filter(Boolean).join("."),
|
|
626
|
+
value: ["colors.colorPalette", key].filter(Boolean).join("."),
|
|
586
627
|
path: ["colors", "colorPalette", ...key.split(".")]
|
|
587
628
|
});
|
|
588
629
|
node.setExtensions({
|
|
589
630
|
category: "colors",
|
|
590
|
-
prop:
|
|
631
|
+
prop: ["colorPalette", key].filter(Boolean).join("."),
|
|
591
632
|
isVirtual: true
|
|
592
633
|
});
|
|
593
634
|
dictionary.allTokens.push(node);
|
|
@@ -605,7 +646,7 @@ var middlewares = [addNegativeTokens, addVirtualPalette, removeEmptyTokens, addP
|
|
|
605
646
|
|
|
606
647
|
// src/transform.ts
|
|
607
648
|
var import_shared6 = require("@pandacss/shared");
|
|
608
|
-
var
|
|
649
|
+
var import_ts_pattern3 = require("ts-pattern");
|
|
609
650
|
|
|
610
651
|
// src/mini-svg-uri.ts
|
|
611
652
|
var shorterNames = {
|
|
@@ -710,34 +751,15 @@ function svgToDataUri(svgString) {
|
|
|
710
751
|
var objectKeys = (obj) => Object.keys(obj);
|
|
711
752
|
|
|
712
753
|
// src/transform.ts
|
|
713
|
-
var isCompositeShadow = (0, import_ts_pattern2.isMatching)({
|
|
714
|
-
inset: import_ts_pattern2.P.optional(import_ts_pattern2.P.boolean),
|
|
715
|
-
offsetX: import_ts_pattern2.P.number,
|
|
716
|
-
offsetY: import_ts_pattern2.P.number,
|
|
717
|
-
blur: import_ts_pattern2.P.number,
|
|
718
|
-
spread: import_ts_pattern2.P.number,
|
|
719
|
-
color: import_ts_pattern2.P.string
|
|
720
|
-
});
|
|
721
754
|
var transformShadow = {
|
|
722
755
|
name: "tokens/shadow",
|
|
723
756
|
match: (token) => token.extensions.category === "shadows",
|
|
724
|
-
transform(token,
|
|
757
|
+
transform(token, opts) {
|
|
725
758
|
if ((0, import_shared6.isString)(token.value)) {
|
|
726
759
|
return token.value;
|
|
727
760
|
}
|
|
728
761
|
if (Array.isArray(token.value)) {
|
|
729
|
-
|
|
730
|
-
const conditions = token.extensions.conditions;
|
|
731
|
-
for (const [prop, value] of Object.entries(conditions)) {
|
|
732
|
-
if (Array.isArray(value)) {
|
|
733
|
-
conditions[prop] = value.map((value2) => this.transform({ value: value2 }, { prefix })).join(", ");
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
if (token.extensions.conditions?.base && Array.isArray(token.originalValue)) {
|
|
737
|
-
return token.extensions.conditions.base;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
return token.value.map((value) => this.transform({ value }, { prefix })).join(", ");
|
|
762
|
+
return token.value.map((value) => this.transform({ value }, opts)).join(", ");
|
|
741
763
|
}
|
|
742
764
|
if (isCompositeShadow(token.value)) {
|
|
743
765
|
const { offsetX, offsetY, blur, spread, color, inset } = token.value;
|
|
@@ -746,17 +768,6 @@ var transformShadow = {
|
|
|
746
768
|
return token.value;
|
|
747
769
|
}
|
|
748
770
|
};
|
|
749
|
-
var isCompositeGradient = (0, import_ts_pattern2.isMatching)({
|
|
750
|
-
type: import_ts_pattern2.P.string,
|
|
751
|
-
placement: import_ts_pattern2.P.string,
|
|
752
|
-
stops: import_ts_pattern2.P.union(
|
|
753
|
-
import_ts_pattern2.P.array(import_ts_pattern2.P.string),
|
|
754
|
-
import_ts_pattern2.P.array({
|
|
755
|
-
color: import_ts_pattern2.P.string,
|
|
756
|
-
position: import_ts_pattern2.P.number
|
|
757
|
-
})
|
|
758
|
-
)
|
|
759
|
-
});
|
|
760
771
|
var transformGradient = {
|
|
761
772
|
name: "tokens/gradient",
|
|
762
773
|
match: (token) => token.extensions.category === "gradients",
|
|
@@ -794,7 +805,10 @@ var transformEasings = {
|
|
|
794
805
|
if ((0, import_shared6.isString)(token.value)) {
|
|
795
806
|
return token.value;
|
|
796
807
|
}
|
|
797
|
-
|
|
808
|
+
if (Array.isArray(token.value)) {
|
|
809
|
+
return `cubic-bezier(${token.value.join(", ")})`;
|
|
810
|
+
}
|
|
811
|
+
return token.value;
|
|
798
812
|
}
|
|
799
813
|
};
|
|
800
814
|
var transformBorders = {
|
|
@@ -804,8 +818,11 @@ var transformBorders = {
|
|
|
804
818
|
if ((0, import_shared6.isString)(token.value)) {
|
|
805
819
|
return token.value;
|
|
806
820
|
}
|
|
807
|
-
|
|
808
|
-
|
|
821
|
+
if (isCompositeBorder(token.value)) {
|
|
822
|
+
const { width, style, color } = token.value;
|
|
823
|
+
return `${width}px ${style} ${color}`;
|
|
824
|
+
}
|
|
825
|
+
return token.value;
|
|
809
826
|
}
|
|
810
827
|
};
|
|
811
828
|
var transformAssets = {
|
|
@@ -813,7 +830,7 @@ var transformAssets = {
|
|
|
813
830
|
match: (token) => token.extensions.category === "assets",
|
|
814
831
|
transform(token) {
|
|
815
832
|
const raw = token.value;
|
|
816
|
-
return (0,
|
|
833
|
+
return (0, import_ts_pattern3.match)(raw).with(import_ts_pattern3.P.string, (value) => value).with({ type: "url" }, ({ value }) => `url('${value}')`).with({ type: "svg" }, ({ value }) => `url('${svgToDataUri(value)})'`).exhaustive();
|
|
817
834
|
}
|
|
818
835
|
};
|
|
819
836
|
var addCssVariables = {
|
|
@@ -822,7 +839,7 @@ var addCssVariables = {
|
|
|
822
839
|
transform(token, { prefix, hash }) {
|
|
823
840
|
const { isNegative, originalPath } = token.extensions;
|
|
824
841
|
const pathValue = isNegative ? originalPath : token.path;
|
|
825
|
-
const variable = (0, import_shared6.cssVar)(pathValue.join("-"), { prefix, hash });
|
|
842
|
+
const variable = (0, import_shared6.cssVar)(pathValue.filter(Boolean).join("-"), { prefix, hash });
|
|
826
843
|
return {
|
|
827
844
|
var: variable.var,
|
|
828
845
|
varRef: variable.ref
|
|
@@ -850,22 +867,31 @@ var addColorPalette = {
|
|
|
850
867
|
return token.extensions.category === "colors" && !token.extensions.isVirtual;
|
|
851
868
|
},
|
|
852
869
|
transform(token) {
|
|
853
|
-
|
|
870
|
+
let tokenPathClone = [...token.path];
|
|
854
871
|
tokenPathClone.pop();
|
|
855
872
|
tokenPathClone.shift();
|
|
873
|
+
if (tokenPathClone.length === 0) {
|
|
874
|
+
const newPath = [...token.path];
|
|
875
|
+
newPath.shift();
|
|
876
|
+
tokenPathClone = newPath;
|
|
877
|
+
}
|
|
856
878
|
if (tokenPathClone.length === 0) {
|
|
857
879
|
return {};
|
|
858
880
|
}
|
|
859
881
|
const colorPaletteRoots = tokenPathClone.reduce((acc, _, i, arr) => {
|
|
860
|
-
|
|
882
|
+
const next = arr.slice(0, i + 1).join(".");
|
|
883
|
+
acc.push(next);
|
|
861
884
|
return acc;
|
|
862
885
|
}, []);
|
|
863
|
-
const colorPaletteRoot = tokenPathClone
|
|
886
|
+
const colorPaletteRoot = tokenPathClone[0];
|
|
864
887
|
const colorPalette = tokenPathClone.join(".");
|
|
865
888
|
const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce((acc, _, i, arr) => {
|
|
866
889
|
acc.push(arr.slice(i).join("."));
|
|
867
890
|
return acc;
|
|
868
891
|
}, []);
|
|
892
|
+
if (colorPaletteTokenKeys.length === 0) {
|
|
893
|
+
colorPaletteTokenKeys.push("");
|
|
894
|
+
}
|
|
869
895
|
return {
|
|
870
896
|
colorPalette,
|
|
871
897
|
colorPaletteRoots,
|
package/dist/index.mjs
CHANGED
|
@@ -3,10 +3,44 @@ import { getDotPath as getDotPath2, mapToJson as mapToJson2 } from "@pandacss/sh
|
|
|
3
3
|
|
|
4
4
|
// src/dictionary.ts
|
|
5
5
|
import { compact, isString, mapObject, memo, walkObject as walkObject2 } from "@pandacss/shared";
|
|
6
|
-
import { isMatching, match } from "ts-pattern";
|
|
6
|
+
import { isMatching as isMatching2, match } from "ts-pattern";
|
|
7
|
+
|
|
8
|
+
// src/is-composite.ts
|
|
9
|
+
import { P, isMatching } from "ts-pattern";
|
|
10
|
+
var isCompositeShadow = isMatching({
|
|
11
|
+
inset: P.optional(P.boolean),
|
|
12
|
+
offsetX: P.number,
|
|
13
|
+
offsetY: P.number,
|
|
14
|
+
blur: P.number,
|
|
15
|
+
spread: P.number,
|
|
16
|
+
color: P.string
|
|
17
|
+
});
|
|
18
|
+
var isCompositeGradient = isMatching({
|
|
19
|
+
type: P.string,
|
|
20
|
+
placement: P.string,
|
|
21
|
+
stops: P.union(
|
|
22
|
+
P.array(P.string),
|
|
23
|
+
P.array({
|
|
24
|
+
color: P.string,
|
|
25
|
+
position: P.number
|
|
26
|
+
})
|
|
27
|
+
)
|
|
28
|
+
});
|
|
29
|
+
var isCompositeBorder = isMatching({
|
|
30
|
+
color: P.string,
|
|
31
|
+
width: P.union(P.string, P.number),
|
|
32
|
+
style: P.string
|
|
33
|
+
});
|
|
34
|
+
var isCompositeAsset = isMatching({
|
|
35
|
+
type: P.union("url", "svg"),
|
|
36
|
+
value: P.string
|
|
37
|
+
});
|
|
38
|
+
var isCompositeTokenValue = (value) => {
|
|
39
|
+
return isCompositeGradient(value) || isCompositeShadow(value) || isCompositeBorder(value) || isCompositeAsset(value) || Array.isArray(value);
|
|
40
|
+
};
|
|
7
41
|
|
|
8
42
|
// src/token.ts
|
|
9
|
-
import { isBaseCondition,
|
|
43
|
+
import { isBaseCondition, toHash, walkObject } from "@pandacss/shared";
|
|
10
44
|
|
|
11
45
|
// src/utils.ts
|
|
12
46
|
import { isObject } from "@pandacss/shared";
|
|
@@ -91,7 +125,7 @@ var Token = class _Token {
|
|
|
91
125
|
* Whether the token is a complex or composite token.
|
|
92
126
|
*/
|
|
93
127
|
get isComposite() {
|
|
94
|
-
return
|
|
128
|
+
return isCompositeTokenValue(this.originalValue);
|
|
95
129
|
}
|
|
96
130
|
/**
|
|
97
131
|
* Returns the token value with the references expanded.
|
|
@@ -260,7 +294,7 @@ var TokenDictionary = class {
|
|
|
260
294
|
assertTokenFormat(token);
|
|
261
295
|
const category = path[0];
|
|
262
296
|
const name = path.join(".");
|
|
263
|
-
const normalizedToken = isString(token.value) ? { value: { base: token.value } } : token;
|
|
297
|
+
const normalizedToken = isString(token.value) || isCompositeTokenValue(token.value) ? { value: { base: token.value } } : token;
|
|
264
298
|
const { value, ...restData } = normalizedToken;
|
|
265
299
|
const node = new Token({
|
|
266
300
|
...restData,
|
|
@@ -302,10 +336,8 @@ var TokenDictionary = class {
|
|
|
302
336
|
return;
|
|
303
337
|
if (typeof transform.match === "function" && !transform.match(token))
|
|
304
338
|
return;
|
|
305
|
-
const
|
|
306
|
-
|
|
307
|
-
hash: this.hash
|
|
308
|
-
});
|
|
339
|
+
const exec = (v) => transform.transform(v, { prefix: this.prefix, hash: this.hash });
|
|
340
|
+
const transformed = exec(token);
|
|
309
341
|
match(transform).with({ type: "extensions" }, () => {
|
|
310
342
|
token.setExtensions(transformed);
|
|
311
343
|
}).with({ type: "value" }, () => {
|
|
@@ -313,6 +345,15 @@ var TokenDictionary = class {
|
|
|
313
345
|
if (token.isComposite) {
|
|
314
346
|
token.originalValue = transformed;
|
|
315
347
|
}
|
|
348
|
+
if (token.extensions.conditions) {
|
|
349
|
+
const conditions = token.extensions.conditions;
|
|
350
|
+
const transformedConditions = walkObject2(conditions, (value) => exec({ value }), {
|
|
351
|
+
stop: isCompositeTokenValue
|
|
352
|
+
});
|
|
353
|
+
token.setExtensions({
|
|
354
|
+
conditions: transformedConditions
|
|
355
|
+
});
|
|
356
|
+
}
|
|
316
357
|
}).otherwise(() => {
|
|
317
358
|
token[transform.type] = transformed;
|
|
318
359
|
});
|
|
@@ -365,7 +406,7 @@ var TokenDictionary = class {
|
|
|
365
406
|
return this;
|
|
366
407
|
}
|
|
367
408
|
filter(pattern) {
|
|
368
|
-
const predicate = typeof pattern === "function" ? pattern :
|
|
409
|
+
const predicate = typeof pattern === "function" ? pattern : isMatching2(pattern);
|
|
369
410
|
return this.allTokens.filter(predicate);
|
|
370
411
|
}
|
|
371
412
|
addConditionalTokens() {
|
|
@@ -554,13 +595,13 @@ var addVirtualPalette = {
|
|
|
554
595
|
});
|
|
555
596
|
keys.forEach((key) => {
|
|
556
597
|
const node = new Token({
|
|
557
|
-
name:
|
|
558
|
-
value:
|
|
598
|
+
name: ["colors.colorPalette", key].filter(Boolean).join("."),
|
|
599
|
+
value: ["colors.colorPalette", key].filter(Boolean).join("."),
|
|
559
600
|
path: ["colors", "colorPalette", ...key.split(".")]
|
|
560
601
|
});
|
|
561
602
|
node.setExtensions({
|
|
562
603
|
category: "colors",
|
|
563
|
-
prop:
|
|
604
|
+
prop: ["colorPalette", key].filter(Boolean).join("."),
|
|
564
605
|
isVirtual: true
|
|
565
606
|
});
|
|
566
607
|
dictionary.allTokens.push(node);
|
|
@@ -578,7 +619,7 @@ var middlewares = [addNegativeTokens, addVirtualPalette, removeEmptyTokens, addP
|
|
|
578
619
|
|
|
579
620
|
// src/transform.ts
|
|
580
621
|
import { cssVar as cssVar2, isString as isString2 } from "@pandacss/shared";
|
|
581
|
-
import {
|
|
622
|
+
import { P as P2, match as match2 } from "ts-pattern";
|
|
582
623
|
|
|
583
624
|
// src/mini-svg-uri.ts
|
|
584
625
|
var shorterNames = {
|
|
@@ -683,34 +724,15 @@ function svgToDataUri(svgString) {
|
|
|
683
724
|
var objectKeys = (obj) => Object.keys(obj);
|
|
684
725
|
|
|
685
726
|
// src/transform.ts
|
|
686
|
-
var isCompositeShadow = isMatching2({
|
|
687
|
-
inset: P.optional(P.boolean),
|
|
688
|
-
offsetX: P.number,
|
|
689
|
-
offsetY: P.number,
|
|
690
|
-
blur: P.number,
|
|
691
|
-
spread: P.number,
|
|
692
|
-
color: P.string
|
|
693
|
-
});
|
|
694
727
|
var transformShadow = {
|
|
695
728
|
name: "tokens/shadow",
|
|
696
729
|
match: (token) => token.extensions.category === "shadows",
|
|
697
|
-
transform(token,
|
|
730
|
+
transform(token, opts) {
|
|
698
731
|
if (isString2(token.value)) {
|
|
699
732
|
return token.value;
|
|
700
733
|
}
|
|
701
734
|
if (Array.isArray(token.value)) {
|
|
702
|
-
|
|
703
|
-
const conditions = token.extensions.conditions;
|
|
704
|
-
for (const [prop, value] of Object.entries(conditions)) {
|
|
705
|
-
if (Array.isArray(value)) {
|
|
706
|
-
conditions[prop] = value.map((value2) => this.transform({ value: value2 }, { prefix })).join(", ");
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
if (token.extensions.conditions?.base && Array.isArray(token.originalValue)) {
|
|
710
|
-
return token.extensions.conditions.base;
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
return token.value.map((value) => this.transform({ value }, { prefix })).join(", ");
|
|
735
|
+
return token.value.map((value) => this.transform({ value }, opts)).join(", ");
|
|
714
736
|
}
|
|
715
737
|
if (isCompositeShadow(token.value)) {
|
|
716
738
|
const { offsetX, offsetY, blur, spread, color, inset } = token.value;
|
|
@@ -719,17 +741,6 @@ var transformShadow = {
|
|
|
719
741
|
return token.value;
|
|
720
742
|
}
|
|
721
743
|
};
|
|
722
|
-
var isCompositeGradient = isMatching2({
|
|
723
|
-
type: P.string,
|
|
724
|
-
placement: P.string,
|
|
725
|
-
stops: P.union(
|
|
726
|
-
P.array(P.string),
|
|
727
|
-
P.array({
|
|
728
|
-
color: P.string,
|
|
729
|
-
position: P.number
|
|
730
|
-
})
|
|
731
|
-
)
|
|
732
|
-
});
|
|
733
744
|
var transformGradient = {
|
|
734
745
|
name: "tokens/gradient",
|
|
735
746
|
match: (token) => token.extensions.category === "gradients",
|
|
@@ -767,7 +778,10 @@ var transformEasings = {
|
|
|
767
778
|
if (isString2(token.value)) {
|
|
768
779
|
return token.value;
|
|
769
780
|
}
|
|
770
|
-
|
|
781
|
+
if (Array.isArray(token.value)) {
|
|
782
|
+
return `cubic-bezier(${token.value.join(", ")})`;
|
|
783
|
+
}
|
|
784
|
+
return token.value;
|
|
771
785
|
}
|
|
772
786
|
};
|
|
773
787
|
var transformBorders = {
|
|
@@ -777,8 +791,11 @@ var transformBorders = {
|
|
|
777
791
|
if (isString2(token.value)) {
|
|
778
792
|
return token.value;
|
|
779
793
|
}
|
|
780
|
-
|
|
781
|
-
|
|
794
|
+
if (isCompositeBorder(token.value)) {
|
|
795
|
+
const { width, style, color } = token.value;
|
|
796
|
+
return `${width}px ${style} ${color}`;
|
|
797
|
+
}
|
|
798
|
+
return token.value;
|
|
782
799
|
}
|
|
783
800
|
};
|
|
784
801
|
var transformAssets = {
|
|
@@ -786,7 +803,7 @@ var transformAssets = {
|
|
|
786
803
|
match: (token) => token.extensions.category === "assets",
|
|
787
804
|
transform(token) {
|
|
788
805
|
const raw = token.value;
|
|
789
|
-
return match2(raw).with(
|
|
806
|
+
return match2(raw).with(P2.string, (value) => value).with({ type: "url" }, ({ value }) => `url('${value}')`).with({ type: "svg" }, ({ value }) => `url('${svgToDataUri(value)})'`).exhaustive();
|
|
790
807
|
}
|
|
791
808
|
};
|
|
792
809
|
var addCssVariables = {
|
|
@@ -795,7 +812,7 @@ var addCssVariables = {
|
|
|
795
812
|
transform(token, { prefix, hash }) {
|
|
796
813
|
const { isNegative, originalPath } = token.extensions;
|
|
797
814
|
const pathValue = isNegative ? originalPath : token.path;
|
|
798
|
-
const variable = cssVar2(pathValue.join("-"), { prefix, hash });
|
|
815
|
+
const variable = cssVar2(pathValue.filter(Boolean).join("-"), { prefix, hash });
|
|
799
816
|
return {
|
|
800
817
|
var: variable.var,
|
|
801
818
|
varRef: variable.ref
|
|
@@ -823,22 +840,31 @@ var addColorPalette = {
|
|
|
823
840
|
return token.extensions.category === "colors" && !token.extensions.isVirtual;
|
|
824
841
|
},
|
|
825
842
|
transform(token) {
|
|
826
|
-
|
|
843
|
+
let tokenPathClone = [...token.path];
|
|
827
844
|
tokenPathClone.pop();
|
|
828
845
|
tokenPathClone.shift();
|
|
846
|
+
if (tokenPathClone.length === 0) {
|
|
847
|
+
const newPath = [...token.path];
|
|
848
|
+
newPath.shift();
|
|
849
|
+
tokenPathClone = newPath;
|
|
850
|
+
}
|
|
829
851
|
if (tokenPathClone.length === 0) {
|
|
830
852
|
return {};
|
|
831
853
|
}
|
|
832
854
|
const colorPaletteRoots = tokenPathClone.reduce((acc, _, i, arr) => {
|
|
833
|
-
|
|
855
|
+
const next = arr.slice(0, i + 1).join(".");
|
|
856
|
+
acc.push(next);
|
|
834
857
|
return acc;
|
|
835
858
|
}, []);
|
|
836
|
-
const colorPaletteRoot = tokenPathClone
|
|
859
|
+
const colorPaletteRoot = tokenPathClone[0];
|
|
837
860
|
const colorPalette = tokenPathClone.join(".");
|
|
838
861
|
const colorPaletteTokenKeys = token.path.slice(token.path.indexOf(colorPaletteRoot) + 1).reduce((acc, _, i, arr) => {
|
|
839
862
|
acc.push(arr.slice(i).join("."));
|
|
840
863
|
return acc;
|
|
841
864
|
}, []);
|
|
865
|
+
if (colorPaletteTokenKeys.length === 0) {
|
|
866
|
+
colorPaletteTokenKeys.push("");
|
|
867
|
+
}
|
|
842
868
|
return {
|
|
843
869
|
colorPalette,
|
|
844
870
|
colorPaletteRoots,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/token-dictionary",
|
|
3
|
-
"version": "0.18.
|
|
3
|
+
"version": "0.18.2",
|
|
4
4
|
"description": "Common error messages for css panda",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"ts-pattern": "5.0.5",
|
|
30
|
-
"@pandacss/shared": "0.18.
|
|
31
|
-
"@pandacss/types": "0.18.
|
|
30
|
+
"@pandacss/shared": "0.18.2",
|
|
31
|
+
"@pandacss/types": "0.18.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@pandacss/fixture": "0.18.
|
|
34
|
+
"@pandacss/fixture": "0.18.2"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
|
37
37
|
"build": "tsup src/index.ts --format=esm,cjs --dts",
|