@qw-ui/tokens 0.1.0 → 0.2.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/color-architecture.d.ts +122 -0
- package/dist/color.d.ts +38 -0
- package/dist/compat/build.d.ts +14 -0
- package/dist/compat/color.d.ts +8 -0
- package/dist/compat/index.d.ts +5 -0
- package/dist/compat/schema.d.ts +114 -0
- package/dist/derive/index.d.ts +25 -0
- package/dist/derive/live-css.d.ts +18 -0
- package/dist/derive/naming.d.ts +18 -0
- package/dist/derive/oklch.d.ts +28 -0
- package/dist/derive/reference.d.ts +189 -0
- package/dist/derive/semantic.d.ts +75 -0
- package/dist/design-doc.d.ts +10 -0
- package/dist/figma/color-contract.d.ts +14 -0
- package/dist/index.d.ts +13 -624
- package/dist/index.js +2118 -1068
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +200 -0
- package/dist/seed/index.d.ts +2 -0
- package/dist/tokens.css +68 -1
- package/dist/tokens.json +66 -2
- package/dist/tokens.live.css +3 -0
- package/dist/tokens.ts +95 -0
- package/package.json +10 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Json = Record<string, unknown>;
|
|
2
|
+
/** 生成 design/reference.tokens.json 的完整 JSON 对象。 */
|
|
3
|
+
export declare function buildReferenceDesignDoc(): Json;
|
|
4
|
+
/** 生成 design/semantic.tokens.json(mode 无关的结构角色)。 */
|
|
5
|
+
export declare function buildSemanticDesignDoc(): Json;
|
|
6
|
+
/** 生成 design/semantic.color.tokens.json(light/dark 合并视图)。 */
|
|
7
|
+
export declare function buildSemanticColorDesignDoc(): Json;
|
|
8
|
+
/** 三份生成文件的文件名 → 生成器映射,供导出脚本与 parity 测试共用。 */
|
|
9
|
+
export declare const GENERATED_DESIGN_DOCS: Record<string, () => Json>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { FIGMA_COLOR_COLLECTION, FIGMA_COLOR_PREFIX, T1_COLOR_KEYS, T2_OKLCH_STEPS } from "../color-architecture.js";
|
|
2
|
+
export declare const T2_ALPHA_STEPS: ["a5", "a10", "a20", "a30", "a40", "a50", "a60", "a70", "a80", "a90", "a100"];
|
|
3
|
+
export declare const T2_OKLCH_STEP_KEYS: string[];
|
|
4
|
+
export interface FigmaColorTokenValidationResult {
|
|
5
|
+
ok: boolean;
|
|
6
|
+
errors: string[];
|
|
7
|
+
counts: {
|
|
8
|
+
t1: number;
|
|
9
|
+
t2: number;
|
|
10
|
+
t3: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function validateFigmaColorTokens(doc: unknown): FigmaColorTokenValidationResult;
|
|
14
|
+
export declare function assertFigmaColorTokens(doc: unknown): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,624 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* - lineHeight 从 size 移入 typography;新增 letterSpacing.base 锚点。
|
|
15
|
-
* - fontFamily 换 text/number/code 三族 + 平台/语言变体(textMacXx、textWindowsXx)。
|
|
16
|
-
*/
|
|
17
|
-
declare const SeedSchema: z.ZodObject<{
|
|
18
|
-
color: z.ZodObject<{
|
|
19
|
-
brand: z.ZodObject<{
|
|
20
|
-
colorSpace: z.ZodEnum<{
|
|
21
|
-
srgb: "srgb";
|
|
22
|
-
oklch: "oklch";
|
|
23
|
-
}>;
|
|
24
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
25
|
-
alpha: z.ZodNumber;
|
|
26
|
-
}, z.core.$strip>;
|
|
27
|
-
black: z.ZodObject<{
|
|
28
|
-
colorSpace: z.ZodEnum<{
|
|
29
|
-
srgb: "srgb";
|
|
30
|
-
oklch: "oklch";
|
|
31
|
-
}>;
|
|
32
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
33
|
-
alpha: z.ZodNumber;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
white: z.ZodObject<{
|
|
36
|
-
colorSpace: z.ZodEnum<{
|
|
37
|
-
srgb: "srgb";
|
|
38
|
-
oklch: "oklch";
|
|
39
|
-
}>;
|
|
40
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
41
|
-
alpha: z.ZodNumber;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
|
-
gray: z.ZodObject<{
|
|
44
|
-
colorSpace: z.ZodEnum<{
|
|
45
|
-
srgb: "srgb";
|
|
46
|
-
oklch: "oklch";
|
|
47
|
-
}>;
|
|
48
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
49
|
-
alpha: z.ZodNumber;
|
|
50
|
-
}, z.core.$strip>;
|
|
51
|
-
red: z.ZodObject<{
|
|
52
|
-
colorSpace: z.ZodEnum<{
|
|
53
|
-
srgb: "srgb";
|
|
54
|
-
oklch: "oklch";
|
|
55
|
-
}>;
|
|
56
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
57
|
-
alpha: z.ZodNumber;
|
|
58
|
-
}, z.core.$strip>;
|
|
59
|
-
orange: z.ZodObject<{
|
|
60
|
-
colorSpace: z.ZodEnum<{
|
|
61
|
-
srgb: "srgb";
|
|
62
|
-
oklch: "oklch";
|
|
63
|
-
}>;
|
|
64
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
65
|
-
alpha: z.ZodNumber;
|
|
66
|
-
}, z.core.$strip>;
|
|
67
|
-
yellow: z.ZodObject<{
|
|
68
|
-
colorSpace: z.ZodEnum<{
|
|
69
|
-
srgb: "srgb";
|
|
70
|
-
oklch: "oklch";
|
|
71
|
-
}>;
|
|
72
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
73
|
-
alpha: z.ZodNumber;
|
|
74
|
-
}, z.core.$strip>;
|
|
75
|
-
green: z.ZodObject<{
|
|
76
|
-
colorSpace: z.ZodEnum<{
|
|
77
|
-
srgb: "srgb";
|
|
78
|
-
oklch: "oklch";
|
|
79
|
-
}>;
|
|
80
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
81
|
-
alpha: z.ZodNumber;
|
|
82
|
-
}, z.core.$strip>;
|
|
83
|
-
cyan: z.ZodObject<{
|
|
84
|
-
colorSpace: z.ZodEnum<{
|
|
85
|
-
srgb: "srgb";
|
|
86
|
-
oklch: "oklch";
|
|
87
|
-
}>;
|
|
88
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
89
|
-
alpha: z.ZodNumber;
|
|
90
|
-
}, z.core.$strip>;
|
|
91
|
-
blue: z.ZodObject<{
|
|
92
|
-
colorSpace: z.ZodEnum<{
|
|
93
|
-
srgb: "srgb";
|
|
94
|
-
oklch: "oklch";
|
|
95
|
-
}>;
|
|
96
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
97
|
-
alpha: z.ZodNumber;
|
|
98
|
-
}, z.core.$strip>;
|
|
99
|
-
purple: z.ZodObject<{
|
|
100
|
-
colorSpace: z.ZodEnum<{
|
|
101
|
-
srgb: "srgb";
|
|
102
|
-
oklch: "oklch";
|
|
103
|
-
}>;
|
|
104
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
105
|
-
alpha: z.ZodNumber;
|
|
106
|
-
}, z.core.$strip>;
|
|
107
|
-
brown: z.ZodObject<{
|
|
108
|
-
colorSpace: z.ZodEnum<{
|
|
109
|
-
srgb: "srgb";
|
|
110
|
-
oklch: "oklch";
|
|
111
|
-
}>;
|
|
112
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
113
|
-
alpha: z.ZodNumber;
|
|
114
|
-
}, z.core.$strip>;
|
|
115
|
-
}, z.core.$strip>;
|
|
116
|
-
size: z.ZodObject<{
|
|
117
|
-
spacing: z.ZodObject<{
|
|
118
|
-
step: z.ZodString;
|
|
119
|
-
}, z.core.$strip>;
|
|
120
|
-
borderWidth: z.ZodObject<{
|
|
121
|
-
hairline: z.ZodString;
|
|
122
|
-
}, z.core.$strip>;
|
|
123
|
-
radius: z.ZodObject<{
|
|
124
|
-
base: z.ZodString;
|
|
125
|
-
full: z.ZodString;
|
|
126
|
-
}, z.core.$strip>;
|
|
127
|
-
controlSize: z.ZodObject<{
|
|
128
|
-
base: z.ZodString;
|
|
129
|
-
}, z.core.$strip>;
|
|
130
|
-
iconSize: z.ZodObject<{
|
|
131
|
-
base: z.ZodString;
|
|
132
|
-
}, z.core.$strip>;
|
|
133
|
-
opacity: z.ZodObject<{
|
|
134
|
-
disabled: z.ZodNumber;
|
|
135
|
-
alphaStep: z.ZodNumber;
|
|
136
|
-
}, z.core.$strip>;
|
|
137
|
-
zIndex: z.ZodObject<{
|
|
138
|
-
step: z.ZodNumber;
|
|
139
|
-
}, z.core.$strip>;
|
|
140
|
-
}, z.core.$strip>;
|
|
141
|
-
typography: z.ZodObject<{
|
|
142
|
-
fontFamily: z.ZodObject<{
|
|
143
|
-
text: z.ZodArray<z.ZodString>;
|
|
144
|
-
number: z.ZodArray<z.ZodString>;
|
|
145
|
-
code: z.ZodArray<z.ZodString>;
|
|
146
|
-
textMacLatin: z.ZodArray<z.ZodString>;
|
|
147
|
-
textMacZh: z.ZodArray<z.ZodString>;
|
|
148
|
-
textMacJa: z.ZodArray<z.ZodString>;
|
|
149
|
-
textWindowsLatin: z.ZodArray<z.ZodString>;
|
|
150
|
-
textWindowsZh: z.ZodArray<z.ZodString>;
|
|
151
|
-
textWindowsJa: z.ZodArray<z.ZodString>;
|
|
152
|
-
}, z.core.$strip>;
|
|
153
|
-
fontWeight: z.ZodObject<{
|
|
154
|
-
regular: z.ZodNumber;
|
|
155
|
-
medium: z.ZodNumber;
|
|
156
|
-
semibold: z.ZodNumber;
|
|
157
|
-
}, z.core.$strip>;
|
|
158
|
-
fontSize: z.ZodObject<{
|
|
159
|
-
base: z.ZodString;
|
|
160
|
-
}, z.core.$strip>;
|
|
161
|
-
lineHeight: z.ZodObject<{
|
|
162
|
-
base: z.ZodNumber;
|
|
163
|
-
}, z.core.$strip>;
|
|
164
|
-
letterSpacing: z.ZodObject<{
|
|
165
|
-
base: z.ZodString;
|
|
166
|
-
}, z.core.$strip>;
|
|
167
|
-
}, z.core.$strip>;
|
|
168
|
-
motion: z.ZodObject<{
|
|
169
|
-
duration: z.ZodObject<{
|
|
170
|
-
base: z.ZodString;
|
|
171
|
-
}, z.core.$strip>;
|
|
172
|
-
easing: z.ZodObject<{
|
|
173
|
-
standard: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
174
|
-
}, z.core.$strip>;
|
|
175
|
-
}, z.core.$strip>;
|
|
176
|
-
effect: z.ZodObject<{
|
|
177
|
-
shadow: z.ZodObject<{
|
|
178
|
-
base: z.ZodObject<{
|
|
179
|
-
color: z.ZodObject<{
|
|
180
|
-
colorSpace: z.ZodEnum<{
|
|
181
|
-
srgb: "srgb";
|
|
182
|
-
oklch: "oklch";
|
|
183
|
-
}>;
|
|
184
|
-
components: z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber], null>;
|
|
185
|
-
alpha: z.ZodNumber;
|
|
186
|
-
}, z.core.$strip>;
|
|
187
|
-
offsetX: z.ZodString;
|
|
188
|
-
offsetY: z.ZodString;
|
|
189
|
-
blur: z.ZodString;
|
|
190
|
-
spread: z.ZodString;
|
|
191
|
-
}, z.core.$strip>;
|
|
192
|
-
}, z.core.$strip>;
|
|
193
|
-
}, z.core.$strip>;
|
|
194
|
-
}, z.core.$strip>;
|
|
195
|
-
type SeedInput = z.input<typeof SeedSchema>;
|
|
196
|
-
type Seed = z.infer<typeof SeedSchema>;
|
|
197
|
-
/**
|
|
198
|
-
* validateSeed — ConfigProvider 在 dev 模式调用;生产环境可裁掉,不带 zod 体积。
|
|
199
|
-
* 解析失败抛错,错误信息直接定位到字段。
|
|
200
|
-
*/
|
|
201
|
-
declare function validateSeed(seed: unknown): Seed;
|
|
202
|
-
|
|
203
|
-
declare const defaultSeed: Seed;
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* SeedColorValue — DTCG Color module 结构化颜色(design-tokens.org 2025.10)。
|
|
207
|
-
* Seed 层颜色不再用十六进制字符串:结构化后输出 Web / iOS / Android / Figma
|
|
208
|
-
* 插件 / 文档都更稳定,且支持 oklch 等更高级色彩空间直接作为设计输入。
|
|
209
|
-
*
|
|
210
|
-
* - srgb:components = [r, g, b],各分量 0–1(不是 0–255)。
|
|
211
|
-
* - oklch:components = [l, c, h](l 0–1、c ≥0、h 角度)。
|
|
212
|
-
*/
|
|
213
|
-
interface SeedColorValue {
|
|
214
|
-
colorSpace: "srgb" | "oklch";
|
|
215
|
-
components: [number, number, number];
|
|
216
|
-
alpha: number;
|
|
217
|
-
}
|
|
218
|
-
/** 十六进制(#rgb / #rrggbb)→ 结构化 srgb SeedColorValue。编辑器色板输入的桥。 */
|
|
219
|
-
declare function hexToSeedColor(hex: string): SeedColorValue;
|
|
220
|
-
/** 结构化颜色 → #rrggbb(丢 alpha;oklch 会先转 sRGB)。展示/对比度计算用。 */
|
|
221
|
-
declare function seedColorToHex(c: SeedColorValue): string;
|
|
222
|
-
/**
|
|
223
|
-
* 结构化颜色 → CSS 颜色字符串。srgb 且不透明输出 hex;srgb 半透明输出
|
|
224
|
-
* `rgb(r g b / a)`;oklch 保持原生 `oklch(l c h / a)`(relative color 派生保真)。
|
|
225
|
-
*/
|
|
226
|
-
declare function seedColorToCss(c: SeedColorValue): string;
|
|
227
|
-
|
|
228
|
-
declare const FIGMA_COLOR_COLLECTION = "Color";
|
|
229
|
-
declare const FIGMA_COLOR_PREFIX = "qw";
|
|
230
|
-
declare const T1_COLOR_KEYS: readonly ["brand", "black", "white", "gray", "red", "orange", "yellow", "green", "cyan", "blue", "purple", "brown"];
|
|
231
|
-
type T1ColorKey = (typeof T1_COLOR_KEYS)[number];
|
|
232
|
-
declare const FIGMA_T1_SEED_HEX: Record<T1ColorKey, string>;
|
|
233
|
-
declare const T2_ALPHA_STEPS: readonly [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
|
|
234
|
-
declare const T2_ALPHA_KEYS: ["a5", "a10", "a20", "a30", "a40", "a50", "a60", "a70", "a80", "a90", "a100"];
|
|
235
|
-
type T2AlphaStep = (typeof T2_ALPHA_STEPS)[number];
|
|
236
|
-
type T2AlphaKey = (typeof T2_ALPHA_KEYS)[number];
|
|
237
|
-
declare const T2_OKLCH_STEPS: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
238
|
-
type T2OklchStep = (typeof T2_OKLCH_STEPS)[number];
|
|
239
|
-
declare const FIGMA_T2_SOLID_SCALE: Record<T1ColorKey, Record<T2OklchStep, string>>;
|
|
240
|
-
declare const FIGMA_T3_COLOR_ROLES: {
|
|
241
|
-
readonly "surface.base": {
|
|
242
|
-
readonly light: "color.white.base";
|
|
243
|
-
readonly dark: "color.black.base";
|
|
244
|
-
};
|
|
245
|
-
readonly "surface.subtle": {
|
|
246
|
-
readonly light: "color.gray.50";
|
|
247
|
-
readonly dark: "color.gray.900";
|
|
248
|
-
};
|
|
249
|
-
readonly "surface.elevated": {
|
|
250
|
-
readonly light: "color.white.base";
|
|
251
|
-
readonly dark: "color.gray.800";
|
|
252
|
-
};
|
|
253
|
-
readonly "surface.header": {
|
|
254
|
-
readonly light: "color.gray.100";
|
|
255
|
-
readonly dark: "color.gray.700";
|
|
256
|
-
};
|
|
257
|
-
readonly "surface.brand-subtle": {
|
|
258
|
-
readonly light: "color.blue.50";
|
|
259
|
-
readonly dark: "color.blue.800";
|
|
260
|
-
};
|
|
261
|
-
readonly "content.primary": {
|
|
262
|
-
readonly light: "color.black.base";
|
|
263
|
-
readonly dark: "color.white.base";
|
|
264
|
-
};
|
|
265
|
-
readonly "content.secondary": {
|
|
266
|
-
readonly light: "color.gray.600";
|
|
267
|
-
readonly dark: "color.gray.base";
|
|
268
|
-
};
|
|
269
|
-
readonly "content.tertiary": {
|
|
270
|
-
readonly light: "color.gray.base";
|
|
271
|
-
readonly dark: "color.gray.600";
|
|
272
|
-
};
|
|
273
|
-
readonly "content.placeholder": {
|
|
274
|
-
readonly light: "color.gray.300";
|
|
275
|
-
readonly dark: "color.white.a30";
|
|
276
|
-
};
|
|
277
|
-
readonly "content.intro": {
|
|
278
|
-
readonly light: "color.gray.400";
|
|
279
|
-
readonly dark: "color.gray.500";
|
|
280
|
-
};
|
|
281
|
-
readonly "border.default": {
|
|
282
|
-
readonly light: "color.gray.100";
|
|
283
|
-
readonly dark: "color.gray.700";
|
|
284
|
-
};
|
|
285
|
-
readonly "border.strong": {
|
|
286
|
-
readonly light: "color.gray.300";
|
|
287
|
-
readonly dark: "color.gray.600";
|
|
288
|
-
};
|
|
289
|
-
readonly "border.focus": {
|
|
290
|
-
readonly light: "color.brand.base";
|
|
291
|
-
readonly dark: "color.brand.500";
|
|
292
|
-
};
|
|
293
|
-
readonly "fill.subtle": {
|
|
294
|
-
readonly light: "color.gray.50";
|
|
295
|
-
readonly dark: "color.white.a20";
|
|
296
|
-
};
|
|
297
|
-
readonly "fill.hover": {
|
|
298
|
-
readonly light: "color.gray.100";
|
|
299
|
-
readonly dark: "color.gray.800";
|
|
300
|
-
};
|
|
301
|
-
readonly "fill.active": {
|
|
302
|
-
readonly light: "color.blue.50";
|
|
303
|
-
readonly dark: "color.blue.800";
|
|
304
|
-
};
|
|
305
|
-
readonly "fill.disabled": {
|
|
306
|
-
readonly light: "color.gray.50";
|
|
307
|
-
readonly dark: "color.gray.900";
|
|
308
|
-
};
|
|
309
|
-
readonly "action.brand": {
|
|
310
|
-
readonly light: "color.brand.base";
|
|
311
|
-
readonly dark: "color.brand.500";
|
|
312
|
-
};
|
|
313
|
-
readonly "action.product": {
|
|
314
|
-
readonly light: "color.blue.base";
|
|
315
|
-
readonly dark: "color.blue.600";
|
|
316
|
-
};
|
|
317
|
-
readonly "action.selected": {
|
|
318
|
-
readonly light: "color.blue.a20";
|
|
319
|
-
readonly dark: "color.blue.a40";
|
|
320
|
-
};
|
|
321
|
-
readonly "action.inverse": {
|
|
322
|
-
readonly light: "color.white.base";
|
|
323
|
-
readonly dark: "color.black.base";
|
|
324
|
-
};
|
|
325
|
-
readonly "status.success": {
|
|
326
|
-
readonly light: "color.green.base";
|
|
327
|
-
readonly dark: "color.green.base";
|
|
328
|
-
};
|
|
329
|
-
readonly "status.warning": {
|
|
330
|
-
readonly light: "color.yellow.base";
|
|
331
|
-
readonly dark: "color.yellow.base";
|
|
332
|
-
};
|
|
333
|
-
readonly "status.danger": {
|
|
334
|
-
readonly light: "color.red.400";
|
|
335
|
-
readonly dark: "color.red.400";
|
|
336
|
-
};
|
|
337
|
-
readonly "status.info": {
|
|
338
|
-
readonly light: "color.blue.base";
|
|
339
|
-
readonly dark: "color.blue.600";
|
|
340
|
-
};
|
|
341
|
-
readonly "overlay.scrim": {
|
|
342
|
-
readonly light: "color.black.a50";
|
|
343
|
-
readonly dark: "color.black.a70";
|
|
344
|
-
};
|
|
345
|
-
readonly "overlay.guide": {
|
|
346
|
-
readonly light: "color.black.a70";
|
|
347
|
-
readonly dark: "color.black.a70";
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
/**
|
|
352
|
-
* T1/T2/T3 token 的 CSS 变量命名:`--qw-{layer}-{kebab(path)}`。
|
|
353
|
-
*
|
|
354
|
-
* `layer` 区分 Seed("seed",仅出现在 live CSS 产物里、供响应式级联的锚点变量)、
|
|
355
|
-
* Reference("ref",原子层,组件禁止直接引用)与 Semantic("sem",组件唯一
|
|
356
|
-
* 合法消费入口)。`path` 的每个 segment 是内部 TS 属性名(天然 camelCase,
|
|
357
|
-
* 如 "brandSubtle"/"controlSize"),命名前需转成 kebab-case 才能对齐
|
|
358
|
-
* packages/tokens/design/*.tokens.json 里锁定的 cssVar 字符串。
|
|
359
|
-
*
|
|
360
|
-
* 例:toVar("sem", ["color","surface","brandSubtle"]) → "--qw-sem-color-surface-brand-subtle"
|
|
361
|
-
* toVar("sem", ["size","controlHeight","sm"]) → "--qw-sem-size-control-height-sm"
|
|
362
|
-
* toVar("seed", ["color","brand"]) → "--qw-seed-color-brand"
|
|
363
|
-
*
|
|
364
|
-
* 这是唯一命名口子,运行时 flat var map、build-tokens.ts 的 CSS 出口与
|
|
365
|
-
* live CSS 生成器共用。
|
|
366
|
-
*/
|
|
367
|
-
type Layer = "seed" | "ref" | "sem";
|
|
368
|
-
declare function toVar(layer: Layer, path: string[]): string;
|
|
369
|
-
|
|
370
|
-
/** 10 档 token: 50 / 100 / 200 / ... / 900 */
|
|
371
|
-
declare const STEPS: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900];
|
|
372
|
-
type Step = (typeof STEPS)[number];
|
|
373
|
-
/**
|
|
374
|
-
* OKLCH L 目标曲线 — 感知均匀的亮度阶梯 (0..1)。
|
|
375
|
-
* 50 最亮 → 900 最暗;端点 0.972 / 0.18 避免纯白纯黑导致对比"塌"。
|
|
376
|
-
* (替换原 HSV:HSV 在感知上不均匀,深档发灰/浅档发白,WCAG 易不过。)
|
|
377
|
-
*
|
|
378
|
-
* 导出供 live-css 生成器复用:CSS relative color 语法
|
|
379
|
-
* `oklch(from var(--seed) L calc(c * f) h)` 的 L/f 常量与这里同源。
|
|
380
|
-
*/
|
|
381
|
-
declare const L_TARGETS: Record<Step, number>;
|
|
382
|
-
type Ramp = Record<Step, string>;
|
|
383
|
-
/**
|
|
384
|
-
* 给一个 seed 颜色(结构化 SeedColorValue 或 CSS 颜色字符串),算 10 阶 ramp。
|
|
385
|
-
* L 走目标曲线,hue 固定,chroma 端点衰减后再 clampChroma 收进 sRGB 色域。
|
|
386
|
-
*/
|
|
387
|
-
declare function ramp(seedColor: SeedColorValue | string): Ramp;
|
|
388
|
-
/** WCAG 对比度 (1..21)。 */
|
|
389
|
-
declare function contrastRatio(fg: string, bg: string): number;
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* T2 Reference(Primitive)派生 —— RFC 0001 §2.1,v3 声明式重构。
|
|
393
|
-
*
|
|
394
|
-
* v3 核心变化:每条 Reference token 的派生规则不再是不透明的 `(seed) => string`
|
|
395
|
-
* 函数,而是可机器读取的 `Derivation` AST——同一份 AST 同时驱动:
|
|
396
|
-
* 1. 运行时求值(evaluateDerivation → tokens);
|
|
397
|
-
* 2. DTCG design 文件生成(scripts/export-design-tokens.ts,$value 全部结构化引用);
|
|
398
|
-
* 3. live CSS 生成(derive/live-css.ts,relative color / calc 表达式);
|
|
399
|
-
* 4. Token Studio 的派生公式展示(formatDerivation)。
|
|
400
|
-
*
|
|
401
|
-
* `seedRefs` 由 AST 自动推导(seedRefsOf),不再手写;可追溯性校验
|
|
402
|
-
* (derive/reference.test.ts)遍历 recipes 断言 seedRefs 非空。
|
|
403
|
-
* 颜色层对齐 Figma `Color/qw` 变量集合:
|
|
404
|
-
* - T1 Seed 为 12 个单色种子;
|
|
405
|
-
* - T2 Reference 为每个 seed 的 A5-A100 Alpha 通道、50-900 OKLCH 设计校准实色色阶、base 引用。
|
|
406
|
-
*/
|
|
407
|
-
type ShadowLevel = "sm" | "md" | "lg";
|
|
408
|
-
type Derivation =
|
|
409
|
-
/** 直通引用 Seed 字段(dimension/number/duration 字符串或数字)。 */
|
|
410
|
-
{
|
|
411
|
-
kind: "alias";
|
|
412
|
-
seedRef: string;
|
|
413
|
-
}
|
|
414
|
-
/** dimension 字符串 × factor;round:"int" 时四舍五入为整数(字号档位用)。 */
|
|
415
|
-
| {
|
|
416
|
-
kind: "scale";
|
|
417
|
-
seedRef: string;
|
|
418
|
-
factor: number;
|
|
419
|
-
round?: "int";
|
|
420
|
-
}
|
|
421
|
-
/** 无单位数字 × factor(zIndex 刻度)。 */
|
|
422
|
-
| {
|
|
423
|
-
kind: "scaleNumber";
|
|
424
|
-
seedRef: string;
|
|
425
|
-
factor: number;
|
|
426
|
-
}
|
|
427
|
-
/** 无单位数字 + delta(lineHeight tight/relaxed = base ∓ 0.25)。 */
|
|
428
|
-
| {
|
|
429
|
-
kind: "offsetNumber";
|
|
430
|
-
seedRef: string;
|
|
431
|
-
delta: number;
|
|
432
|
-
}
|
|
433
|
-
/** dimension + 另一 dimension × n(controlSize/iconSize sm/lg = base ∓ spacing.step × n)。 */
|
|
434
|
-
| {
|
|
435
|
-
kind: "offsetSteps";
|
|
436
|
-
seedRef: string;
|
|
437
|
-
stepRef: string;
|
|
438
|
-
n: number;
|
|
439
|
-
}
|
|
440
|
-
/** OKLCH 感知均匀色阶(L 曲线 + chroma 端点衰减,算法见 oklch.ts)。 */
|
|
441
|
-
| {
|
|
442
|
-
kind: "oklchRamp";
|
|
443
|
-
seedRef: string;
|
|
444
|
-
step: Step;
|
|
445
|
-
}
|
|
446
|
-
/** Figma 校准后的 OKLCH 实色色阶;血缘仍指向 T1 seed,但数值由设计稿拍板。 */
|
|
447
|
-
| {
|
|
448
|
-
kind: "figmaOklchScale";
|
|
449
|
-
seedRef: string;
|
|
450
|
-
step: T2OklchStep;
|
|
451
|
-
value: string;
|
|
452
|
-
}
|
|
453
|
-
/** T1 seed 颜色的固定 Alpha 通道。 */
|
|
454
|
-
| {
|
|
455
|
-
kind: "seedAlpha";
|
|
456
|
-
seedRef: string;
|
|
457
|
-
alpha: number;
|
|
458
|
-
}
|
|
459
|
-
/** 旧版纯黑/纯白透明度工具刻度。保留求值器兼容,不再由 T2 主链路生成。 */
|
|
460
|
-
| {
|
|
461
|
-
kind: "alphaScale";
|
|
462
|
-
channel: "black" | "white";
|
|
463
|
-
stepRef: string;
|
|
464
|
-
multiplier: number;
|
|
465
|
-
}
|
|
466
|
-
/** 字体栈(string[] → CSS font-family 列表)。 */
|
|
467
|
-
| {
|
|
468
|
-
kind: "fontStack";
|
|
469
|
-
seedRef: string;
|
|
470
|
-
}
|
|
471
|
-
/** cubic-bezier 四元组 → CSS 函数。 */
|
|
472
|
-
| {
|
|
473
|
-
kind: "cubicBezier";
|
|
474
|
-
seedRef: string;
|
|
475
|
-
}
|
|
476
|
-
/** 白名单字面量(色彩空间数学端点,非设计决策)。 */
|
|
477
|
-
| {
|
|
478
|
-
kind: "literal";
|
|
479
|
-
value: string;
|
|
480
|
-
}
|
|
481
|
-
/** 阴影档位:形状 = shadow.base × 档位比例,颜色 = alphaStep × 档位倍数。 */
|
|
482
|
-
| {
|
|
483
|
-
kind: "shadowLayer";
|
|
484
|
-
level: ShadowLevel;
|
|
485
|
-
};
|
|
486
|
-
interface ReferenceRecipe {
|
|
487
|
-
path: string[];
|
|
488
|
-
cssVar: string;
|
|
489
|
-
/** 由 derivation 自动推导的 Seed 依赖(点分路径),供可追溯性校验与血缘展示。 */
|
|
490
|
-
seedRefs: string[];
|
|
491
|
-
derivation: Derivation;
|
|
492
|
-
}
|
|
493
|
-
/** 拍平后的 CSS 变量映射:cssVar → 字符串值(--qw-ref-* 全集)。 */
|
|
494
|
-
type ReferenceTokens = Record<string, string>;
|
|
495
|
-
/** 阴影形状(不含颜色),供 Semantic 层复合 effect.shadow.* 时引用固定形状字段。 */
|
|
496
|
-
interface ShadowShape {
|
|
497
|
-
offsetX: string;
|
|
498
|
-
offsetY: string;
|
|
499
|
-
blur: string;
|
|
500
|
-
spread: string;
|
|
501
|
-
}
|
|
502
|
-
interface ReferenceBuild {
|
|
503
|
-
recipes: ReferenceRecipe[];
|
|
504
|
-
tokens: ReferenceTokens;
|
|
505
|
-
shapes: {
|
|
506
|
-
shadow: {
|
|
507
|
-
sm: ShadowShape;
|
|
508
|
-
md: ShadowShape;
|
|
509
|
-
lg: ShadowShape;
|
|
510
|
-
};
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
/** 按点分路径读 Seed 字段("size.spacing.step" → seed.size.spacing.step)。 */
|
|
514
|
-
declare function seedValueAt(seed: Seed, dotted: string): unknown;
|
|
515
|
-
/** 求值:一条 Derivation + Seed → 最终 CSS 值字符串。 */
|
|
516
|
-
declare function evaluateDerivation(d: Derivation, seed: Seed): string;
|
|
517
|
-
/** Seed 依赖推导:AST 里出现的全部 Seed 点分路径。 */
|
|
518
|
-
declare function seedRefsOf(d: Derivation): string[];
|
|
519
|
-
/** 人读派生公式(Token Studio 展示用)。 */
|
|
520
|
-
declare function formatDerivation(d: Derivation): string;
|
|
521
|
-
declare const RAMP_COLORS: readonly ["brand", "black", "white", "gray", "red", "orange", "yellow", "green", "cyan", "blue", "purple", "brown"];
|
|
522
|
-
declare function allReferenceRecipes(): ReferenceRecipe[];
|
|
523
|
-
/** T2 顶层入口:喂一个 Seed,产出全量 Reference recipes + 拍平后的 CSS 变量映射 + 阴影形状(供 Semantic 层消费)。 */
|
|
524
|
-
declare function buildReference(seed: Seed): ReferenceBuild;
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* T3 Semantic 派生 —— RFC 0001 §2.1,v3 修订。
|
|
528
|
-
*
|
|
529
|
-
* R7 类型隔离(强制 FR-010):本模块**不 import `Seed`/`schema.ts`** 任何符号,
|
|
530
|
-
* 只接受 `buildReference()` 的输出(`ReferenceBuild`)。Semantic 角色永远经由
|
|
531
|
-
* Reference 层中转到 Seed,不允许绕过 Reference 直接引用 Seed 字段。
|
|
532
|
-
*
|
|
533
|
-
* v3 变化:全部角色表从模块私有改为导出的结构化元数据(SEMANTIC_ROLES),
|
|
534
|
-
* 供 design 文件生成器(scripts/export-design-tokens.ts)、live CSS 生成器
|
|
535
|
-
* (derive/live-css.ts)与 Token Studio 的血缘展示共用同一份事实。
|
|
536
|
-
*/
|
|
537
|
-
type SemanticMode = "light" | "dark";
|
|
538
|
-
interface TypographyRole {
|
|
539
|
-
fontFamilyRef: string;
|
|
540
|
-
fontSizeRef: string;
|
|
541
|
-
fontWeightRef: string;
|
|
542
|
-
lineHeightRef: string;
|
|
543
|
-
letterSpacingRef: string;
|
|
544
|
-
}
|
|
545
|
-
/** typography.* 复合角色:每个字段各自引用 Reference(无任何裸字面量)。 */
|
|
546
|
-
declare const TYPOGRAPHY_ROLES: Record<string, TypographyRole>;
|
|
547
|
-
interface ColorRoleRefs {
|
|
548
|
-
light: string;
|
|
549
|
-
dark: string;
|
|
550
|
-
}
|
|
551
|
-
declare const COLOR_ROLES: Record<string, ColorRoleRefs>;
|
|
552
|
-
declare const SHADOW_COMPOSITE_ROLES: Record<string, ShadowLevel>;
|
|
553
|
-
type SemanticRoleEntry = {
|
|
554
|
-
kind: "structural";
|
|
555
|
-
/** Semantic 路径(点分,如 "size.radius.control")。 */
|
|
556
|
-
path: string;
|
|
557
|
-
cssVar: string;
|
|
558
|
-
/** 引用的 Reference 路径(点分)。 */
|
|
559
|
-
refPath: string;
|
|
560
|
-
} | {
|
|
561
|
-
kind: "color";
|
|
562
|
-
path: string;
|
|
563
|
-
cssVar: string;
|
|
564
|
-
refPath: {
|
|
565
|
-
light: string;
|
|
566
|
-
dark: string;
|
|
567
|
-
};
|
|
568
|
-
} | {
|
|
569
|
-
kind: "shadowComposite";
|
|
570
|
-
path: string;
|
|
571
|
-
cssVar: string;
|
|
572
|
-
/** 形状来源(reference.effect.shadow.<level>)+ 颜色来源。 */
|
|
573
|
-
shapeRef: string;
|
|
574
|
-
colorRole: string;
|
|
575
|
-
};
|
|
576
|
-
/**
|
|
577
|
-
* 全量 Semantic 角色的结构化血缘表——"角色 → 引用的 Reference 路径(含 light/dark 分支)"。
|
|
578
|
-
* 与 buildSemanticStructural/buildSemanticColor 的产出一一对应(顺序一致)。
|
|
579
|
-
*/
|
|
580
|
-
declare function semanticRoleEntries(): SemanticRoleEntry[];
|
|
581
|
-
/**
|
|
582
|
-
* 结构类(mode 无关):尺寸角色 + 字体族角色 + 排版复合角色 + 动效时长/缓动。
|
|
583
|
-
* `effect.shadow.*` 的颜色字段随 mode 变化,归入 `buildSemanticColor`。
|
|
584
|
-
*/
|
|
585
|
-
declare function buildSemanticStructural(reference: ReferenceBuild): Record<string, string>;
|
|
586
|
-
/**
|
|
587
|
-
* 颜色类(light/dark 分别求值):color.* 全部角色。
|
|
588
|
-
*/
|
|
589
|
-
declare function buildSemanticColor(reference: ReferenceBuild, mode: SemanticMode): Record<string, string>;
|
|
590
|
-
|
|
591
|
-
interface DerivedTokens {
|
|
592
|
-
/** 亮色全量 CSS 变量:--qw-ref-* ∪ --qw-sem-*(light 取值)。 */
|
|
593
|
-
light: Record<string, string>;
|
|
594
|
-
/** 暗色全量 CSS 变量:--qw-ref-* ∪ --qw-sem-*(dark 取值)。 */
|
|
595
|
-
dark: Record<string, string>;
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* derive — 单源派生(RFC 0001)。喂一个 Seed,编排 T2 Reference → T3 Semantic,
|
|
599
|
-
* 返回亮/暗两套全量 CSS 变量映射(含 --qw-ref-* 与 --qw-sem-*)。
|
|
600
|
-
* 外部签名/返回值形状与改造前保持一致(FR-014),供 `@qw-ui/react`、`@qw-ui/vue` 的
|
|
601
|
-
* ConfigProvider 直接消费,无需改动。
|
|
602
|
-
*
|
|
603
|
-
* 注意:`validateSeed` 不在此处调用(沿用现状契约),校验是调用方的责任。
|
|
604
|
-
*/
|
|
605
|
-
declare function derive(seed: Seed): DerivedTokens;
|
|
606
|
-
|
|
607
|
-
/** Seed 拍平成 `--qw-seed-*` → CSS 值。live CSS 里唯一携带具体数值的层。 */
|
|
608
|
-
declare function seedCssVars(seed: Seed): Record<string, string>;
|
|
609
|
-
/** 一条 Derivation → 引用 `--qw-seed-*` 的 CSS 原生表达式。 */
|
|
610
|
-
declare function derivationToCssExpr(d: Derivation): string;
|
|
611
|
-
interface LiveCssOptions {
|
|
612
|
-
/** 亮色作用域选择器,默认 ":root"。 */
|
|
613
|
-
selector?: string;
|
|
614
|
-
/** 暗色作用域选择器,默认 '[data-qw-mode="dark"]'。 */
|
|
615
|
-
darkSelector?: string;
|
|
616
|
-
}
|
|
617
|
-
/**
|
|
618
|
-
* 生成整份 live CSS:
|
|
619
|
-
* 1. seed 块(具体数值);2. ref 块(表达式派生);3. sem 块(light 别名);
|
|
620
|
-
* 4. dark 块(仅重映射随 mode 变化的 sem 颜色别名)。
|
|
621
|
-
*/
|
|
622
|
-
declare function buildLiveCss(seed: Seed, options?: LiveCssOptions): string;
|
|
623
|
-
|
|
624
|
-
export { COLOR_ROLES, type ColorRoleRefs, type Derivation, type DerivedTokens, FIGMA_COLOR_COLLECTION, FIGMA_COLOR_PREFIX, FIGMA_T1_SEED_HEX, FIGMA_T2_SOLID_SCALE, FIGMA_T3_COLOR_ROLES, L_TARGETS, type Layer, type LiveCssOptions, type SemanticMode as Mode, RAMP_COLORS, type Ramp, type ReferenceBuild, type ReferenceRecipe, type ReferenceTokens, SHADOW_COMPOSITE_ROLES, STEPS, type Seed, type SeedColorValue, type SeedInput, SeedSchema, type SemanticRoleEntry, type Step, type T1ColorKey, T1_COLOR_KEYS, type T2AlphaKey, type T2AlphaStep, type T2OklchStep, T2_ALPHA_KEYS, T2_ALPHA_STEPS, T2_OKLCH_STEPS, TYPOGRAPHY_ROLES, allReferenceRecipes, buildLiveCss, buildReference, buildSemanticColor, buildSemanticStructural, contrastRatio, defaultSeed, derivationToCssExpr, derive, evaluateDerivation, formatDerivation, hexToSeedColor, ramp, seedColorToCss, seedColorToHex, seedCssVars, seedRefsOf, seedValueAt, semanticRoleEntries, toVar, validateSeed };
|
|
1
|
+
export { defaultSeed } from "./seed/index.js";
|
|
2
|
+
export { SeedSchema, validateSeed } from "./schema.js";
|
|
3
|
+
export type { Seed, SeedInput } from "./schema.js";
|
|
4
|
+
export { hexToSeedColor, seedColorToHex, seedColorToCss } from "./color.js";
|
|
5
|
+
export type { SeedColorValue } from "./color.js";
|
|
6
|
+
export { FIGMA_COLOR_COLLECTION, FIGMA_COLOR_PREFIX, FIGMA_T1_SEED_HEX, FIGMA_T2_SOLID_SCALE, FIGMA_T3_COLOR_ROLES, T1_COLOR_KEYS, T2_ALPHA_KEYS, T2_ALPHA_STEPS, T2_OKLCH_STEPS, } from "./color-architecture.js";
|
|
7
|
+
export type { T1ColorKey, T2AlphaKey, T2AlphaStep, T2OklchStep } from "./color-architecture.js";
|
|
8
|
+
export { derive, toVar, ramp, STEPS, L_TARGETS, contrastRatio, buildReference, allReferenceRecipes, evaluateDerivation, formatDerivation, seedRefsOf, seedValueAt, buildSemanticStructural, buildSemanticColor, semanticRoleEntries, RAMP_COLORS, COLOR_ROLES, TYPOGRAPHY_ROLES, SHADOW_COMPOSITE_ROLES, } from "./derive/index.js";
|
|
9
|
+
export type { DerivedTokens, Mode, Layer, Step, Ramp, ReferenceRecipe, ReferenceBuild, ReferenceTokens, Derivation, SemanticRoleEntry, ColorRoleRefs, } from "./derive/index.js";
|
|
10
|
+
export { buildLiveCss, seedCssVars, derivationToCssExpr } from "./derive/live-css.js";
|
|
11
|
+
export type { LiveCssOptions } from "./derive/live-css.js";
|
|
12
|
+
export { compatRegistrySchema, compatPathToCssVar, buildCompatFromRegistry, formatCompatTypes, } from "./compat/index.js";
|
|
13
|
+
export type { CompatEntry, CompatRegistry, CompatBuild } from "./compat/index.js";
|