@pandacss/token-dictionary 0.0.0-dev-20221121152823
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 +21 -0
- package/dist/index.d.ts +216 -0
- package/dist/index.js +694 -0
- package/dist/index.mjs +667 -0
- package/package.json +28 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Segun Adebayo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
declare type TokenStatus$1 = 'deprecated' | 'experimental' | 'new';
|
|
2
|
+
declare type ExtensionData = {
|
|
3
|
+
status?: TokenStatus$1;
|
|
4
|
+
category?: string;
|
|
5
|
+
references?: TokenReferences;
|
|
6
|
+
condition?: string;
|
|
7
|
+
conditions?: TokenConditions;
|
|
8
|
+
};
|
|
9
|
+
declare type TokenConditions = Record<string, string>;
|
|
10
|
+
declare type TokenReferences = Record<string, Token>;
|
|
11
|
+
declare type TokenExtensions = ExtensionData & {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
};
|
|
14
|
+
declare type ExtendedToken = {
|
|
15
|
+
name: string;
|
|
16
|
+
value: any;
|
|
17
|
+
type?: string;
|
|
18
|
+
path?: string[];
|
|
19
|
+
description?: string;
|
|
20
|
+
extensions?: TokenExtensions;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Represents a design token in the dictionary
|
|
24
|
+
*/
|
|
25
|
+
declare class Token {
|
|
26
|
+
name: string;
|
|
27
|
+
value: any;
|
|
28
|
+
originalValue: any;
|
|
29
|
+
path: string[];
|
|
30
|
+
type?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
extensions: TokenExtensions;
|
|
33
|
+
constructor(data: ExtendedToken);
|
|
34
|
+
/**
|
|
35
|
+
* Whether the token is a conditional token.
|
|
36
|
+
* Conditional tokens are tokens that have multiple values based on a condition.
|
|
37
|
+
*/
|
|
38
|
+
get isConditional(): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Whether the token has a reference in its value.
|
|
41
|
+
* e.g. {color.gray.100}
|
|
42
|
+
*/
|
|
43
|
+
get hasReference(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the token is a complex or composite token.
|
|
46
|
+
*/
|
|
47
|
+
get isComposite(): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the token value with the references expanded.
|
|
50
|
+
* e.g. {color.gray.100} => #f7fafc
|
|
51
|
+
*
|
|
52
|
+
*/
|
|
53
|
+
expandReferences(): string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether this token has a reference to another token
|
|
56
|
+
*/
|
|
57
|
+
get isReference(): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Returns the list of references in the token value
|
|
60
|
+
*/
|
|
61
|
+
get references(): string[];
|
|
62
|
+
clone(): Token;
|
|
63
|
+
/**
|
|
64
|
+
* Returns an array of tokens per conditions.
|
|
65
|
+
* It is commonly used in semantic tokens, and can have multiple values based on a condition.
|
|
66
|
+
* e.g. primary: { light: '#000', dark: '#fff' }
|
|
67
|
+
*/
|
|
68
|
+
getConditionTokens(): Token[] | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Add more extensions to the token
|
|
71
|
+
*/
|
|
72
|
+
setExtensions(extensions: TokenExtensions): this;
|
|
73
|
+
setType(): void;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare type TokenStatus = 'deprecated' | 'experimental' | 'new';
|
|
77
|
+
declare type TokenEntry<V = any> = {
|
|
78
|
+
value: V;
|
|
79
|
+
description?: string;
|
|
80
|
+
type?: string;
|
|
81
|
+
extensions?: {
|
|
82
|
+
status?: TokenStatus;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
declare type SemanticTokenEntry<V = string, C extends string = string> = {
|
|
87
|
+
description?: string;
|
|
88
|
+
type?: string;
|
|
89
|
+
value: V | Record<C, V>;
|
|
90
|
+
extensions?: {
|
|
91
|
+
[key: string]: any;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
declare type Border = {
|
|
95
|
+
color: string;
|
|
96
|
+
width: string | number;
|
|
97
|
+
style: string;
|
|
98
|
+
};
|
|
99
|
+
declare type Shadow = {
|
|
100
|
+
offsetX: number;
|
|
101
|
+
offsetY: number;
|
|
102
|
+
blur: number;
|
|
103
|
+
spread: number;
|
|
104
|
+
color: string;
|
|
105
|
+
inset?: boolean;
|
|
106
|
+
};
|
|
107
|
+
declare type Gradient = {
|
|
108
|
+
type: 'linear' | 'radial';
|
|
109
|
+
placement: string | number;
|
|
110
|
+
stops: Array<{
|
|
111
|
+
color: string;
|
|
112
|
+
position: number;
|
|
113
|
+
}>;
|
|
114
|
+
};
|
|
115
|
+
declare type Nested<T> = {
|
|
116
|
+
[key: string]: T | Nested<T>;
|
|
117
|
+
};
|
|
118
|
+
declare type TokenValues = {
|
|
119
|
+
zIndex: number;
|
|
120
|
+
opacity: number;
|
|
121
|
+
colors: string;
|
|
122
|
+
fonts: string | string[];
|
|
123
|
+
fontSizes: string;
|
|
124
|
+
fontWeights: string | number;
|
|
125
|
+
lineHeights: string | number;
|
|
126
|
+
letterSpacings: string;
|
|
127
|
+
sizes: string;
|
|
128
|
+
largeSizes: string;
|
|
129
|
+
shadows: Shadow | Shadow[] | string | string[];
|
|
130
|
+
spacing: string | number;
|
|
131
|
+
radii: string;
|
|
132
|
+
borders: string | Border;
|
|
133
|
+
durations: string;
|
|
134
|
+
easings: string | number[];
|
|
135
|
+
animations: string;
|
|
136
|
+
blurs: string;
|
|
137
|
+
gradients: string | Gradient;
|
|
138
|
+
};
|
|
139
|
+
declare type Tokens = {
|
|
140
|
+
[key in keyof TokenValues]?: Nested<TokenEntry<TokenValues[key]>>;
|
|
141
|
+
};
|
|
142
|
+
declare type SemanticTokens<C extends string = string> = {
|
|
143
|
+
[key in keyof TokenValues]?: Nested<SemanticTokenEntry<TokenValues[key], C>>;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
declare type EnforcePhase = 'pre' | 'post';
|
|
147
|
+
declare type Options = {
|
|
148
|
+
prefix?: string;
|
|
149
|
+
};
|
|
150
|
+
declare type TokenTransformer = {
|
|
151
|
+
name: string;
|
|
152
|
+
enforce?: EnforcePhase;
|
|
153
|
+
type?: 'value' | 'name' | 'extensions';
|
|
154
|
+
match?: (token: Token) => boolean;
|
|
155
|
+
transform: (token: Token, options: Options) => any;
|
|
156
|
+
};
|
|
157
|
+
declare type TokenDictionaryOptions = {
|
|
158
|
+
tokens?: Tokens;
|
|
159
|
+
semanticTokens?: SemanticTokens;
|
|
160
|
+
prefix?: string;
|
|
161
|
+
};
|
|
162
|
+
declare type TokenMiddleware = {
|
|
163
|
+
enforce?: EnforcePhase;
|
|
164
|
+
transform: (dict: TokenDictionary$1, options: Options) => void;
|
|
165
|
+
};
|
|
166
|
+
declare class TokenDictionary$1 {
|
|
167
|
+
allTokens: Token[];
|
|
168
|
+
prefix: string | undefined;
|
|
169
|
+
get allNames(): string[];
|
|
170
|
+
constructor(options: TokenDictionaryOptions);
|
|
171
|
+
getByName: (name: string) => Token | undefined;
|
|
172
|
+
private transforms;
|
|
173
|
+
registerTransform(...transforms: TokenTransformer[]): this;
|
|
174
|
+
private execTransform;
|
|
175
|
+
transformTokens(enforce: EnforcePhase): this;
|
|
176
|
+
private middlewares;
|
|
177
|
+
registerMiddleware(...middlewares: TokenMiddleware[]): this;
|
|
178
|
+
applyMiddlewares(enforce: EnforcePhase): void;
|
|
179
|
+
getReferences(value: string): Token[];
|
|
180
|
+
usesReference(value: any): boolean;
|
|
181
|
+
addReferences(): this;
|
|
182
|
+
filter(pattern: Partial<Token> | ((token: Token) => boolean)): Token[];
|
|
183
|
+
addConditionalTokens(): this;
|
|
184
|
+
expandReferences(): this;
|
|
185
|
+
build(): void;
|
|
186
|
+
get isEmpty(): boolean;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
declare class TokenDictionary extends TokenDictionary$1 {
|
|
190
|
+
constructor(options: TokenDictionaryOptions);
|
|
191
|
+
get get(): (path: string, fallback?: string | number | undefined) => any;
|
|
192
|
+
get conditionMap(): Map<string, Set<Token>>;
|
|
193
|
+
get categoryMap(): Map<string, Map<string, Token>>;
|
|
194
|
+
get values(): Map<string, Map<string, string>>;
|
|
195
|
+
get palettes(): {
|
|
196
|
+
clear: never;
|
|
197
|
+
delete: never;
|
|
198
|
+
forEach: never;
|
|
199
|
+
get: never;
|
|
200
|
+
has: never;
|
|
201
|
+
set: never;
|
|
202
|
+
readonly size: never;
|
|
203
|
+
entries: never;
|
|
204
|
+
keys: never;
|
|
205
|
+
values: never;
|
|
206
|
+
[Symbol.iterator]: never;
|
|
207
|
+
readonly [Symbol.toStringTag]: never;
|
|
208
|
+
};
|
|
209
|
+
get vars(): Map<string, Map<string, string>>;
|
|
210
|
+
getValue(path: string): {
|
|
211
|
+
[k: string]: string;
|
|
212
|
+
} | undefined;
|
|
213
|
+
getTokenVar(path: string): any;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { TokenDictionary };
|