@pandacss/token-dictionary 0.3.2 → 0.5.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 +156 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -2
- package/dist/index.mjs +12 -3
- package/package.json +4 -4
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Tokens, SemanticTokens } from '@pandacss/types';
|
|
2
|
+
|
|
3
|
+
type TokenStatus = 'deprecated' | 'experimental' | 'new';
|
|
4
|
+
type ExtensionData = {
|
|
5
|
+
status?: TokenStatus;
|
|
6
|
+
category?: string;
|
|
7
|
+
references?: TokenReferences;
|
|
8
|
+
condition?: string;
|
|
9
|
+
conditions?: TokenConditions;
|
|
10
|
+
};
|
|
11
|
+
type TokenConditions = Record<string, string>;
|
|
12
|
+
type TokenReferences = Record<string, Token>;
|
|
13
|
+
type TokenExtensions = ExtensionData & {
|
|
14
|
+
[key: string]: any;
|
|
15
|
+
};
|
|
16
|
+
type ExtendedToken = {
|
|
17
|
+
name: string;
|
|
18
|
+
value: any;
|
|
19
|
+
type?: string;
|
|
20
|
+
path?: string[];
|
|
21
|
+
description?: string;
|
|
22
|
+
extensions?: TokenExtensions;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Represents a design token in the dictionary
|
|
26
|
+
*/
|
|
27
|
+
declare class Token {
|
|
28
|
+
name: string;
|
|
29
|
+
value: any;
|
|
30
|
+
originalValue: any;
|
|
31
|
+
path: string[];
|
|
32
|
+
type?: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
extensions: TokenExtensions;
|
|
35
|
+
constructor(data: ExtendedToken);
|
|
36
|
+
/**
|
|
37
|
+
* The unique identifier of the token.
|
|
38
|
+
*/
|
|
39
|
+
get id(): string;
|
|
40
|
+
/**
|
|
41
|
+
* Whether the token is a conditional token.
|
|
42
|
+
* Conditional tokens are tokens that have multiple values based on a condition.
|
|
43
|
+
*/
|
|
44
|
+
get isConditional(): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the token has a reference in its value.
|
|
47
|
+
* e.g. {color.gray.100}
|
|
48
|
+
*/
|
|
49
|
+
get hasReference(): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the token is a complex or composite token.
|
|
52
|
+
*/
|
|
53
|
+
get isComposite(): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Returns the token value with the references expanded.
|
|
56
|
+
* e.g. {color.gray.100} => #f7fafc
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
expandReferences(): string;
|
|
60
|
+
/**
|
|
61
|
+
* Whether this token has a reference to another token
|
|
62
|
+
*/
|
|
63
|
+
get isReference(): boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the list of references in the token value
|
|
66
|
+
*/
|
|
67
|
+
get references(): string[];
|
|
68
|
+
clone(): Token;
|
|
69
|
+
/**
|
|
70
|
+
* Returns an array of tokens per conditions.
|
|
71
|
+
* It is commonly used in semantic tokens, and can have multiple values based on a condition.
|
|
72
|
+
* e.g. primary: { light: '#000', dark: '#fff' }
|
|
73
|
+
*/
|
|
74
|
+
getConditionTokens(): Token[] | undefined;
|
|
75
|
+
/**
|
|
76
|
+
* Add more extensions to the token
|
|
77
|
+
*/
|
|
78
|
+
setExtensions(extensions: TokenExtensions): this;
|
|
79
|
+
setType(): void;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
type EnforcePhase = 'pre' | 'post';
|
|
83
|
+
type Options = {
|
|
84
|
+
prefix?: string;
|
|
85
|
+
hash?: boolean;
|
|
86
|
+
};
|
|
87
|
+
type TokenTransformer = {
|
|
88
|
+
name: string;
|
|
89
|
+
enforce?: EnforcePhase;
|
|
90
|
+
type?: 'value' | 'name' | 'extensions';
|
|
91
|
+
match?: (token: Token) => boolean;
|
|
92
|
+
transform: (token: Token, options: Options) => any;
|
|
93
|
+
};
|
|
94
|
+
type TokenDictionaryOptions = {
|
|
95
|
+
tokens?: Tokens;
|
|
96
|
+
semanticTokens?: SemanticTokens;
|
|
97
|
+
breakpoints?: Record<string, string>;
|
|
98
|
+
prefix?: string;
|
|
99
|
+
hash?: boolean;
|
|
100
|
+
};
|
|
101
|
+
type TokenMiddleware = {
|
|
102
|
+
enforce?: EnforcePhase;
|
|
103
|
+
transform: (dict: TokenDictionary$1, options: Options) => void;
|
|
104
|
+
};
|
|
105
|
+
declare class TokenDictionary$1 {
|
|
106
|
+
allTokens: Token[];
|
|
107
|
+
prefix: string | undefined;
|
|
108
|
+
hash: boolean | undefined;
|
|
109
|
+
get allNames(): string[];
|
|
110
|
+
constructor(options: TokenDictionaryOptions);
|
|
111
|
+
getByName: (name: string) => Token | undefined;
|
|
112
|
+
private transforms;
|
|
113
|
+
registerTransform(...transforms: TokenTransformer[]): this;
|
|
114
|
+
private execTransform;
|
|
115
|
+
transformTokens(enforce: EnforcePhase): this;
|
|
116
|
+
private middlewares;
|
|
117
|
+
registerMiddleware(...middlewares: TokenMiddleware[]): this;
|
|
118
|
+
applyMiddlewares(enforce: EnforcePhase): void;
|
|
119
|
+
getReferences(value: string): Token[];
|
|
120
|
+
usesReference(value: any): boolean;
|
|
121
|
+
addReferences(): this;
|
|
122
|
+
filter(pattern: Partial<Token> | ((token: Token) => boolean)): Token[];
|
|
123
|
+
addConditionalTokens(): this;
|
|
124
|
+
expandReferences(): this;
|
|
125
|
+
build(): void;
|
|
126
|
+
get isEmpty(): boolean;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare class TokenDictionary extends TokenDictionary$1 {
|
|
130
|
+
constructor(options: TokenDictionaryOptions);
|
|
131
|
+
get get(): (path: string, fallback?: string | number | undefined) => string;
|
|
132
|
+
get conditionMap(): Map<string, Set<Token>>;
|
|
133
|
+
get categoryMap(): Map<string, Map<string, Token>>;
|
|
134
|
+
get values(): Map<string, Map<string, string>>;
|
|
135
|
+
get colorPalettes(): {
|
|
136
|
+
clear: never;
|
|
137
|
+
delete: never;
|
|
138
|
+
forEach: never;
|
|
139
|
+
get: never;
|
|
140
|
+
has: never;
|
|
141
|
+
set: never;
|
|
142
|
+
readonly size: never;
|
|
143
|
+
entries: never;
|
|
144
|
+
keys: never;
|
|
145
|
+
values: never;
|
|
146
|
+
[Symbol.iterator]: never;
|
|
147
|
+
readonly [Symbol.toStringTag]: never;
|
|
148
|
+
};
|
|
149
|
+
get vars(): Map<string, Map<string, string>>;
|
|
150
|
+
getValue(path: string): {
|
|
151
|
+
[k: string]: string;
|
|
152
|
+
} | undefined;
|
|
153
|
+
getTokenVar(path: string): any;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export { Token, TokenDictionary };
|
package/dist/index.d.ts
CHANGED
|
@@ -33,6 +33,10 @@ declare class Token {
|
|
|
33
33
|
description?: string;
|
|
34
34
|
extensions: TokenExtensions;
|
|
35
35
|
constructor(data: ExtendedToken);
|
|
36
|
+
/**
|
|
37
|
+
* The unique identifier of the token.
|
|
38
|
+
*/
|
|
39
|
+
get id(): string;
|
|
36
40
|
/**
|
|
37
41
|
* Whether the token is a conditional token.
|
|
38
42
|
* Conditional tokens are tokens that have multiple values based on a condition.
|
package/dist/index.js
CHANGED
|
@@ -71,7 +71,7 @@ function assertTokenFormat(token) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
// src/token.ts
|
|
74
|
-
var Token = class {
|
|
74
|
+
var Token = class _Token {
|
|
75
75
|
name;
|
|
76
76
|
value;
|
|
77
77
|
originalValue;
|
|
@@ -94,6 +94,12 @@ var Token = class {
|
|
|
94
94
|
this.extensions.condition = data.extensions?.condition ?? "base";
|
|
95
95
|
this.setType();
|
|
96
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* The unique identifier of the token.
|
|
99
|
+
*/
|
|
100
|
+
get id() {
|
|
101
|
+
return (0, import_shared2.toHash)(`${this.name}-${this.extensions.condition}-${this.value}`);
|
|
102
|
+
}
|
|
97
103
|
/**
|
|
98
104
|
* Whether the token is a conditional token.
|
|
99
105
|
* Conditional tokens are tokens that have multiple values based on a condition.
|
|
@@ -147,7 +153,7 @@ var Token = class {
|
|
|
147
153
|
return getReferences(this.originalValue);
|
|
148
154
|
}
|
|
149
155
|
clone() {
|
|
150
|
-
return new
|
|
156
|
+
return new _Token({
|
|
151
157
|
name: this.name,
|
|
152
158
|
value: this.value,
|
|
153
159
|
type: this.type,
|
|
@@ -517,6 +523,9 @@ var addNegativeTokens = {
|
|
|
517
523
|
tokens.forEach((token) => {
|
|
518
524
|
const originalPath = [...token.path];
|
|
519
525
|
const originalVar = (0, import_shared5.cssVar)(originalPath.join("-"), { prefix, hash });
|
|
526
|
+
if (token.value === "0rem") {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
520
529
|
const node = token.clone();
|
|
521
530
|
node.setExtensions({
|
|
522
531
|
isNegative: true,
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { compact, isString, mapObject, memo, walkObject as walkObject2 } from "@
|
|
|
6
6
|
import { isMatching, match } from "ts-pattern";
|
|
7
7
|
|
|
8
8
|
// src/token.ts
|
|
9
|
-
import { isBaseCondition, isObject as isObject2, walkObject } from "@pandacss/shared";
|
|
9
|
+
import { isBaseCondition, isObject as isObject2, toHash, walkObject } from "@pandacss/shared";
|
|
10
10
|
|
|
11
11
|
// src/utils.ts
|
|
12
12
|
import { isObject } from "@pandacss/shared";
|
|
@@ -44,7 +44,7 @@ function assertTokenFormat(token) {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
// src/token.ts
|
|
47
|
-
var Token = class {
|
|
47
|
+
var Token = class _Token {
|
|
48
48
|
name;
|
|
49
49
|
value;
|
|
50
50
|
originalValue;
|
|
@@ -67,6 +67,12 @@ var Token = class {
|
|
|
67
67
|
this.extensions.condition = data.extensions?.condition ?? "base";
|
|
68
68
|
this.setType();
|
|
69
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* The unique identifier of the token.
|
|
72
|
+
*/
|
|
73
|
+
get id() {
|
|
74
|
+
return toHash(`${this.name}-${this.extensions.condition}-${this.value}`);
|
|
75
|
+
}
|
|
70
76
|
/**
|
|
71
77
|
* Whether the token is a conditional token.
|
|
72
78
|
* Conditional tokens are tokens that have multiple values based on a condition.
|
|
@@ -120,7 +126,7 @@ var Token = class {
|
|
|
120
126
|
return getReferences(this.originalValue);
|
|
121
127
|
}
|
|
122
128
|
clone() {
|
|
123
|
-
return new
|
|
129
|
+
return new _Token({
|
|
124
130
|
name: this.name,
|
|
125
131
|
value: this.value,
|
|
126
132
|
type: this.type,
|
|
@@ -490,6 +496,9 @@ var addNegativeTokens = {
|
|
|
490
496
|
tokens.forEach((token) => {
|
|
491
497
|
const originalPath = [...token.path];
|
|
492
498
|
const originalVar = cssVar(originalPath.join("-"), { prefix, hash });
|
|
499
|
+
if (token.value === "0rem") {
|
|
500
|
+
return;
|
|
501
|
+
}
|
|
493
502
|
const node = token.clone();
|
|
494
503
|
node.setExtensions({
|
|
495
504
|
isNegative: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/token-dictionary",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.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": "4.3.0",
|
|
18
|
-
"@pandacss/types": "0.
|
|
19
|
-
"@pandacss/shared": "0.
|
|
18
|
+
"@pandacss/types": "0.5.0",
|
|
19
|
+
"@pandacss/shared": "0.5.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@pandacss/fixture": "0.
|
|
22
|
+
"@pandacss/fixture": "0.5.0"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
25
|
"build": "tsup src/index.ts --format=esm,cjs --dts",
|