@pandacss/token-dictionary 0.4.0 → 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.
@@ -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.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;
@@ -153,7 +153,7 @@ var Token = class {
153
153
  return getReferences(this.originalValue);
154
154
  }
155
155
  clone() {
156
- return new Token({
156
+ return new _Token({
157
157
  name: this.name,
158
158
  value: this.value,
159
159
  type: this.type,
package/dist/index.mjs CHANGED
@@ -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;
@@ -126,7 +126,7 @@ var Token = class {
126
126
  return getReferences(this.originalValue);
127
127
  }
128
128
  clone() {
129
- return new Token({
129
+ return new _Token({
130
130
  name: this.name,
131
131
  value: this.value,
132
132
  type: this.type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/token-dictionary",
3
- "version": "0.4.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.4.0",
19
- "@pandacss/shared": "0.4.0"
18
+ "@pandacss/types": "0.5.0",
19
+ "@pandacss/shared": "0.5.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@pandacss/fixture": "0.4.0"
22
+ "@pandacss/fixture": "0.5.0"
23
23
  },
24
24
  "scripts": {
25
25
  "build": "tsup src/index.ts --format=esm,cjs --dts",