@agent-native/design-system 0.0.0-stage → 0.229.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/LICENSE +21 -0
- package/README.md +78 -2
- package/THIRD_PARTY_NOTICES.md +58 -0
- package/css/appearances.css +91 -0
- package/css/main.css +174 -0
- package/css/parts/accordion.css +104 -0
- package/css/parts/alert-dialog.css +159 -0
- package/css/parts/app-shell.css +45 -0
- package/css/parts/aspect-ratio.css +20 -0
- package/css/parts/autocomplete.css +366 -0
- package/css/parts/avatar.css +108 -0
- package/css/parts/badge.css +100 -0
- package/css/parts/blockquote.css +23 -0
- package/css/parts/button.css +238 -0
- package/css/parts/callout.css +108 -0
- package/css/parts/card.css +144 -0
- package/css/parts/checkbox-cards.css +59 -0
- package/css/parts/checkbox-group.css +20 -0
- package/css/parts/checkbox.css +127 -0
- package/css/parts/code.css +194 -0
- package/css/parts/collapsible.css +40 -0
- package/css/parts/combobox.css +171 -0
- package/css/parts/context-menu.css +18 -0
- package/css/parts/data-list.css +130 -0
- package/css/parts/dialog.css +251 -0
- package/css/parts/drawer.css +289 -0
- package/css/parts/em.css +16 -0
- package/css/parts/field.css +55 -0
- package/css/parts/fieldset.css +34 -0
- package/css/parts/form.css +18 -0
- package/css/parts/heading.css +25 -0
- package/css/parts/icon-button.css +30 -0
- package/css/parts/input.css +206 -0
- package/css/parts/inset.css +90 -0
- package/css/parts/item.css +208 -0
- package/css/parts/kbd.css +126 -0
- package/css/parts/link.css +99 -0
- package/css/parts/menu.css +342 -0
- package/css/parts/menubar.css +71 -0
- package/css/parts/meter.css +112 -0
- package/css/parts/navigation-menu.css +199 -0
- package/css/parts/number-field.css +124 -0
- package/css/parts/otp-field.css +137 -0
- package/css/parts/page-header.css +45 -0
- package/css/parts/popover.css +149 -0
- package/css/parts/preview-card.css +116 -0
- package/css/parts/progress.css +159 -0
- package/css/parts/quote.css +18 -0
- package/css/parts/radio-cards.css +188 -0
- package/css/parts/radio-group.css +124 -0
- package/css/parts/scroll-area.css +95 -0
- package/css/parts/segmented-control.css +191 -0
- package/css/parts/select.css +378 -0
- package/css/parts/separator.css +48 -0
- package/css/parts/sidebar.css +211 -0
- package/css/parts/skeleton.css +65 -0
- package/css/parts/slider.css +156 -0
- package/css/parts/spinner.css +52 -0
- package/css/parts/strong.css +15 -0
- package/css/parts/switch.css +138 -0
- package/css/parts/tab-nav.css +48 -0
- package/css/parts/table.css +177 -0
- package/css/parts/tabs.css +214 -0
- package/css/parts/text-area.css +140 -0
- package/css/parts/text.css +245 -0
- package/css/parts/toast.css +302 -0
- package/css/parts/toggle-group.css +25 -0
- package/css/parts/toggle.css +181 -0
- package/css/parts/toolbar.css +133 -0
- package/css/parts/tooltip.css +61 -0
- package/css/parts/visually-hidden.css +21 -0
- package/css/styles.css +73 -0
- package/css/themes/agent-native.css +2321 -0
- package/css/themes/analytics.css +1159 -0
- package/css/themes/assets.css +1159 -0
- package/css/themes/baseline.css +1107 -0
- package/css/themes/brain.css +1159 -0
- package/css/themes/calendar.css +1159 -0
- package/css/themes/chat.css +1159 -0
- package/css/themes/clips.css +1159 -0
- package/css/themes/content.css +1159 -0
- package/css/themes/crm.css +1159 -0
- package/css/themes/design.css +1159 -0
- package/css/themes/desktop.css +1159 -0
- package/css/themes/dispatch.css +1159 -0
- package/css/themes/docs.css +1159 -0
- package/css/themes/factory.css +1159 -0
- package/css/themes/forms.css +1159 -0
- package/css/themes/mail.css +1159 -0
- package/css/themes/plan.css +1159 -0
- package/css/themes/slides.css +1159 -0
- package/css/themes/tasks.css +1159 -0
- package/css/tokens.css +1249 -0
- package/package.json +67 -4
- package/src/catalog/components/alert-dialog.ts +9 -0
- package/src/catalog/components/aspect-ratio.ts +6 -0
- package/src/catalog/components/autocomplete.ts +23 -0
- package/src/catalog/components/avatar.ts +16 -0
- package/src/catalog/components/badge.ts +19 -0
- package/src/catalog/components/blockquote.ts +10 -0
- package/src/catalog/components/button.ts +24 -0
- package/src/catalog/components/callout.ts +17 -0
- package/src/catalog/components/card.ts +10 -0
- package/src/catalog/components/checkbox-cards.ts +14 -0
- package/src/catalog/components/checkbox-group.ts +13 -0
- package/src/catalog/components/checkbox.ts +13 -0
- package/src/catalog/components/code.ts +22 -0
- package/src/catalog/components/combobox.ts +23 -0
- package/src/catalog/components/context-menu.ts +20 -0
- package/src/catalog/components/data-list.ts +14 -0
- package/src/catalog/components/dialog.ts +9 -0
- package/src/catalog/components/drawer.ts +9 -0
- package/src/catalog/components/em.ts +7 -0
- package/src/catalog/components/heading.ts +11 -0
- package/src/catalog/components/index.ts +54 -0
- package/src/catalog/components/input.ts +23 -0
- package/src/catalog/components/inset.ts +15 -0
- package/src/catalog/components/item.ts +21 -0
- package/src/catalog/components/kbd.ts +9 -0
- package/src/catalog/components/link.ts +19 -0
- package/src/catalog/components/menu.ts +20 -0
- package/src/catalog/components/menubar.ts +20 -0
- package/src/catalog/components/meter.ts +19 -0
- package/src/catalog/components/number-field.ts +10 -0
- package/src/catalog/components/otp-field.ts +9 -0
- package/src/catalog/components/popover.ts +9 -0
- package/src/catalog/components/preview-card.ts +9 -0
- package/src/catalog/components/progress.ts +24 -0
- package/src/catalog/components/quote.ts +7 -0
- package/src/catalog/components/radio-cards.ts +14 -0
- package/src/catalog/components/radio-group.ts +13 -0
- package/src/catalog/components/scroll-area.ts +15 -0
- package/src/catalog/components/segmented-control.ts +8 -0
- package/src/catalog/components/select.ts +26 -0
- package/src/catalog/components/separator.ts +14 -0
- package/src/catalog/components/skeleton.ts +8 -0
- package/src/catalog/components/slider.ts +19 -0
- package/src/catalog/components/spinner.ts +15 -0
- package/src/catalog/components/strong.ts +7 -0
- package/src/catalog/components/switch.ts +19 -0
- package/src/catalog/components/tab-nav.ts +18 -0
- package/src/catalog/components/table.ts +34 -0
- package/src/catalog/components/tabs.ts +18 -0
- package/src/catalog/components/text-area.ts +24 -0
- package/src/catalog/components/text.ts +11 -0
- package/src/catalog/components/toast.ts +12 -0
- package/src/catalog/components/toggle-group.ts +17 -0
- package/src/catalog/components/toggle.ts +17 -0
- package/src/catalog/components/toolbar.ts +6 -0
- package/src/catalog/index.ts +4 -0
- package/src/catalog/parts.ts +915 -0
- package/src/catalog/prop-types-source.ts +93 -0
- package/src/catalog/prop-types.generated.ts +1402 -0
- package/src/catalog/props.ts +225 -0
- package/src/css.ts +318 -0
- package/src/generated-css.ts +21 -0
- package/src/index.ts +8 -0
- package/src/model/compare.ts +127 -0
- package/src/model/dom.ts +253 -0
- package/src/model/ids.ts +25 -0
- package/src/model/index.ts +6 -0
- package/src/model/styles.ts +254 -0
- package/src/model/types.ts +97 -0
- package/src/model/validate.ts +133 -0
- package/src/themes/appearances.ts +105 -0
- package/src/themes/baseline.ts +27 -0
- package/src/themes/index.ts +85 -0
- package/src/themes/reference.ts +9 -0
- package/src/themes/shadcn.ts +239 -0
- package/src/themes/types.ts +53 -0
- package/src/tokens/at.ts +13 -0
- package/src/tokens/base.ts +48 -0
- package/src/tokens/color/bezier.ts +111 -0
- package/src/tokens/color/index.ts +2 -0
- package/src/tokens/color/radix-generator.ts +516 -0
- package/src/tokens/dtcg.ts +298 -0
- package/src/tokens/files/foundations.tokens.json +318 -0
- package/src/tokens/files/palette.tokens.json +58 -0
- package/src/tokens/files/themes/agent-native.dark.tokens.json +405 -0
- package/src/tokens/files/themes/agent-native.light.tokens.json +405 -0
- package/src/tokens/files/themes/analytics.dark.tokens.json +391 -0
- package/src/tokens/files/themes/analytics.light.tokens.json +391 -0
- package/src/tokens/files/themes/assets.dark.tokens.json +391 -0
- package/src/tokens/files/themes/assets.light.tokens.json +391 -0
- package/src/tokens/files/themes/brain.dark.tokens.json +391 -0
- package/src/tokens/files/themes/brain.light.tokens.json +391 -0
- package/src/tokens/files/themes/calendar.dark.tokens.json +391 -0
- package/src/tokens/files/themes/calendar.light.tokens.json +391 -0
- package/src/tokens/files/themes/chat.dark.tokens.json +391 -0
- package/src/tokens/files/themes/chat.light.tokens.json +391 -0
- package/src/tokens/files/themes/clips.dark.tokens.json +391 -0
- package/src/tokens/files/themes/clips.light.tokens.json +391 -0
- package/src/tokens/files/themes/content.dark.tokens.json +391 -0
- package/src/tokens/files/themes/content.light.tokens.json +391 -0
- package/src/tokens/files/themes/crm.dark.tokens.json +391 -0
- package/src/tokens/files/themes/crm.light.tokens.json +391 -0
- package/src/tokens/files/themes/design.dark.tokens.json +391 -0
- package/src/tokens/files/themes/design.light.tokens.json +391 -0
- package/src/tokens/files/themes/desktop.dark.tokens.json +391 -0
- package/src/tokens/files/themes/desktop.light.tokens.json +391 -0
- package/src/tokens/files/themes/dispatch.dark.tokens.json +391 -0
- package/src/tokens/files/themes/dispatch.light.tokens.json +391 -0
- package/src/tokens/files/themes/docs.dark.tokens.json +391 -0
- package/src/tokens/files/themes/docs.light.tokens.json +391 -0
- package/src/tokens/files/themes/factory.dark.tokens.json +391 -0
- package/src/tokens/files/themes/factory.light.tokens.json +391 -0
- package/src/tokens/files/themes/forms.dark.tokens.json +391 -0
- package/src/tokens/files/themes/forms.light.tokens.json +391 -0
- package/src/tokens/files/themes/mail.dark.tokens.json +391 -0
- package/src/tokens/files/themes/mail.light.tokens.json +391 -0
- package/src/tokens/files/themes/plan.dark.tokens.json +391 -0
- package/src/tokens/files/themes/plan.light.tokens.json +391 -0
- package/src/tokens/files/themes/slides.dark.tokens.json +391 -0
- package/src/tokens/files/themes/slides.light.tokens.json +391 -0
- package/src/tokens/files/themes/tasks.dark.tokens.json +391 -0
- package/src/tokens/files/themes/tasks.light.tokens.json +391 -0
- package/src/tokens/palette.ts +354 -0
- package/src/tokens/primitives.ts +84 -0
- package/src/tokens/roles.ts +269 -0
- package/src/tokens/round-trip.ts +277 -0
- package/src/tokens/source.ts +302 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
/** Our extension: the exact HSL text a color came from, so it round-trips without drift. */
|
|
2
|
+
export const EXTENSION = "com.agent-native";
|
|
3
|
+
|
|
4
|
+
export interface DtcgColor {
|
|
5
|
+
colorSpace: "srgb";
|
|
6
|
+
components: [number, number, number];
|
|
7
|
+
alpha: number;
|
|
8
|
+
hex: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type DtcgType = "color" | "number" | "string";
|
|
12
|
+
|
|
13
|
+
export interface DtcgToken {
|
|
14
|
+
$type: DtcgType;
|
|
15
|
+
$value: DtcgColor | number | string;
|
|
16
|
+
$description?: string;
|
|
17
|
+
$extensions?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface DtcgGroup {
|
|
21
|
+
[name: string]: DtcgToken | DtcgGroup;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export class TokenError extends Error {
|
|
25
|
+
constructor(
|
|
26
|
+
readonly file: string,
|
|
27
|
+
readonly tokenPath: string,
|
|
28
|
+
problem: string,
|
|
29
|
+
) {
|
|
30
|
+
super(`${file}: ${tokenPath} ${problem}`);
|
|
31
|
+
this.name = "TokenError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isToken(node: unknown): node is DtcgToken {
|
|
36
|
+
return typeof node === "object" && node !== null && "$value" in node;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Every token in a file by its dotted path (`font.size.1`). */
|
|
40
|
+
export function flattenTokens(
|
|
41
|
+
group: unknown,
|
|
42
|
+
file: string,
|
|
43
|
+
prefix = "",
|
|
44
|
+
): Map<string, DtcgToken> {
|
|
45
|
+
const tokens = new Map<string, DtcgToken>();
|
|
46
|
+
if (typeof group !== "object" || group === null || Array.isArray(group)) {
|
|
47
|
+
throw new TokenError(file, prefix || "(root)", "is not a token group");
|
|
48
|
+
}
|
|
49
|
+
for (const [name, node] of Object.entries(group)) {
|
|
50
|
+
if (name.startsWith("$")) continue;
|
|
51
|
+
const tokenPath = prefix ? `${prefix}.${name}` : name;
|
|
52
|
+
if (isToken(node)) tokens.set(tokenPath, node);
|
|
53
|
+
else {
|
|
54
|
+
for (const [key, token] of flattenTokens(node, file, tokenPath)) {
|
|
55
|
+
tokens.set(key, token);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return tokens;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** A token group from tokens by dotted path: the inverse of `flattenTokens`. */
|
|
63
|
+
export function unflattenTokens(
|
|
64
|
+
tokens: ReadonlyMap<string, DtcgToken>,
|
|
65
|
+
): DtcgGroup {
|
|
66
|
+
const root: DtcgGroup = {};
|
|
67
|
+
for (const [tokenPath, token] of tokens) {
|
|
68
|
+
const names = tokenPath.split(".");
|
|
69
|
+
let group = root;
|
|
70
|
+
for (const name of names.slice(0, -1)) {
|
|
71
|
+
const next = group[name];
|
|
72
|
+
if (next === undefined) {
|
|
73
|
+
const created: DtcgGroup = {};
|
|
74
|
+
group[name] = created;
|
|
75
|
+
group = created;
|
|
76
|
+
} else if (isToken(next)) {
|
|
77
|
+
throw new Error(`${tokenPath} nests under the token ${name}`);
|
|
78
|
+
} else {
|
|
79
|
+
group = next;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
group[names.at(-1) ?? tokenPath] = token;
|
|
83
|
+
}
|
|
84
|
+
return root;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const HEX = /^#[0-9a-f]{6}$/i;
|
|
88
|
+
|
|
89
|
+
/** `#rrggbb` from sRGB components in 0..1. */
|
|
90
|
+
export function componentsToHex(components: readonly number[]): string {
|
|
91
|
+
return `#${components
|
|
92
|
+
.map((value) =>
|
|
93
|
+
Math.round(Math.min(1, Math.max(0, value)) * 255)
|
|
94
|
+
.toString(16)
|
|
95
|
+
.padStart(2, "0"),
|
|
96
|
+
)
|
|
97
|
+
.join("")}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** sRGB components in 0..1 from `#rrggbb`. */
|
|
101
|
+
export function hexToComponents(hex: string): [number, number, number] {
|
|
102
|
+
if (!HEX.test(hex)) throw new Error(`Not a #rrggbb color: ${hex}`);
|
|
103
|
+
const value = Number.parseInt(hex.slice(1), 16);
|
|
104
|
+
return [(value >> 16) / 255, ((value >> 8) & 255) / 255, (value & 255) / 255];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function hslToComponents(
|
|
108
|
+
hue: number,
|
|
109
|
+
saturation: number,
|
|
110
|
+
lightness: number,
|
|
111
|
+
): [number, number, number] {
|
|
112
|
+
const s = saturation / 100;
|
|
113
|
+
const l = lightness / 100;
|
|
114
|
+
const k = (n: number) => (n + hue / 30) % 12;
|
|
115
|
+
const a = s * Math.min(l, 1 - l);
|
|
116
|
+
const channel = (n: number) =>
|
|
117
|
+
l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
118
|
+
return [channel(0), channel(8), channel(4)];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const HSL_TRIPLET = /^(-?[\d.]+)\s+([\d.]+)%\s+([\d.]+)%$/;
|
|
122
|
+
|
|
123
|
+
/** The color token for a shadcn-style `H S% L%` triplet, keeping the text exactly. */
|
|
124
|
+
export function hslColorToken(triplet: string): DtcgToken {
|
|
125
|
+
const match = HSL_TRIPLET.exec(triplet);
|
|
126
|
+
if (!match) throw new Error(`Not an "H S% L%" triplet: ${triplet}`);
|
|
127
|
+
const components = hslToComponents(
|
|
128
|
+
Number(match[1]),
|
|
129
|
+
Number(match[2]),
|
|
130
|
+
Number(match[3]),
|
|
131
|
+
);
|
|
132
|
+
return colorToken(components, triplet);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const round6 = (value: number) => Math.round(value * 1e6) / 1e6;
|
|
136
|
+
|
|
137
|
+
export function colorToken(
|
|
138
|
+
components: readonly number[],
|
|
139
|
+
hsl?: string,
|
|
140
|
+
): DtcgToken {
|
|
141
|
+
const [r = 0, g = 0, b = 0] = components;
|
|
142
|
+
return {
|
|
143
|
+
$type: "color",
|
|
144
|
+
$value: {
|
|
145
|
+
colorSpace: "srgb",
|
|
146
|
+
components: [round6(r), round6(g), round6(b)],
|
|
147
|
+
alpha: 1,
|
|
148
|
+
hex: componentsToHex([r, g, b]),
|
|
149
|
+
},
|
|
150
|
+
...(hsl === undefined ? {} : { $extensions: { [EXTENSION]: { hsl } } }),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** `H S% L%` for sRGB components, at the precision a hand-written triplet uses. */
|
|
155
|
+
export function componentsToHslTriplet(components: readonly number[]): string {
|
|
156
|
+
const [r = 0, g = 0, b = 0] = components;
|
|
157
|
+
const max = Math.max(r, g, b);
|
|
158
|
+
const min = Math.min(r, g, b);
|
|
159
|
+
const lightness = (max + min) / 2;
|
|
160
|
+
let hue = 0;
|
|
161
|
+
let saturation = 0;
|
|
162
|
+
if (max !== min) {
|
|
163
|
+
const delta = max - min;
|
|
164
|
+
saturation =
|
|
165
|
+
lightness > 0.5 ? delta / (2 - max - min) : delta / (max + min);
|
|
166
|
+
hue =
|
|
167
|
+
max === r
|
|
168
|
+
? (g - b) / delta + (g < b ? 6 : 0)
|
|
169
|
+
: max === g
|
|
170
|
+
? (b - r) / delta + 2
|
|
171
|
+
: (r - g) / delta + 4;
|
|
172
|
+
hue *= 60;
|
|
173
|
+
}
|
|
174
|
+
const fixed = (value: number) => String(Math.round(value * 10) / 10);
|
|
175
|
+
return `${fixed(hue)} ${fixed(saturation * 100)}% ${fixed(lightness * 100)}%`;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The sRGB components of a color value: our object form, or a bare hex
|
|
180
|
+
* string, which some tools write instead.
|
|
181
|
+
*/
|
|
182
|
+
export function colorComponents(
|
|
183
|
+
value: unknown,
|
|
184
|
+
file: string,
|
|
185
|
+
tokenPath: string,
|
|
186
|
+
): [number, number, number] {
|
|
187
|
+
if (typeof value === "string") {
|
|
188
|
+
if (!HEX.test(value)) {
|
|
189
|
+
throw new TokenError(file, tokenPath, `is not a #rrggbb color: ${value}`);
|
|
190
|
+
}
|
|
191
|
+
return hexToComponents(value);
|
|
192
|
+
}
|
|
193
|
+
if (typeof value !== "object" || value === null) {
|
|
194
|
+
throw new TokenError(file, tokenPath, "has no color value");
|
|
195
|
+
}
|
|
196
|
+
const color = value as Record<string, unknown>;
|
|
197
|
+
if (color.alpha !== undefined && color.alpha !== 1) {
|
|
198
|
+
throw new TokenError(
|
|
199
|
+
file,
|
|
200
|
+
tokenPath,
|
|
201
|
+
"has an alpha; theme colors are opaque",
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (
|
|
205
|
+
color.colorSpace === "srgb" &&
|
|
206
|
+
Array.isArray(color.components) &&
|
|
207
|
+
color.components.length === 3 &&
|
|
208
|
+
color.components.every(
|
|
209
|
+
(c): c is number => typeof c === "number" && c >= 0 && c <= 1,
|
|
210
|
+
)
|
|
211
|
+
) {
|
|
212
|
+
const [r, g, b] = color.components as [number, number, number];
|
|
213
|
+
return [r, g, b];
|
|
214
|
+
}
|
|
215
|
+
if (typeof color.hex === "string" && HEX.test(color.hex)) {
|
|
216
|
+
return hexToComponents(color.hex);
|
|
217
|
+
}
|
|
218
|
+
throw new TokenError(
|
|
219
|
+
file,
|
|
220
|
+
tokenPath,
|
|
221
|
+
"is not an sRGB color (colorSpace srgb with components, or hex)",
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Reads typed values from one file's tokens, throwing on anything missing or mistyped. */
|
|
226
|
+
export class TokenReader {
|
|
227
|
+
private readonly tokens: Map<string, DtcgToken>;
|
|
228
|
+
|
|
229
|
+
constructor(
|
|
230
|
+
readonly file: string,
|
|
231
|
+
group: unknown,
|
|
232
|
+
) {
|
|
233
|
+
this.tokens = flattenTokens(group, file);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
paths(): string[] {
|
|
237
|
+
return [...this.tokens.keys()];
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
token(tokenPath: string, type: DtcgType): DtcgToken {
|
|
241
|
+
const token = this.tokens.get(tokenPath);
|
|
242
|
+
if (!token) throw new TokenError(this.file, tokenPath, "is missing");
|
|
243
|
+
if (token.$type !== type) {
|
|
244
|
+
throw new TokenError(
|
|
245
|
+
this.file,
|
|
246
|
+
tokenPath,
|
|
247
|
+
`is a ${String(token.$type)}, expected a ${type}`,
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
return token;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
number(tokenPath: string): number {
|
|
254
|
+
const value = this.token(tokenPath, "number").$value;
|
|
255
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
256
|
+
throw new TokenError(this.file, tokenPath, "is not a finite number");
|
|
257
|
+
}
|
|
258
|
+
return value;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
string(tokenPath: string): string {
|
|
262
|
+
const value = this.token(tokenPath, "string").$value;
|
|
263
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
264
|
+
throw new TokenError(this.file, tokenPath, "is not a non-empty string");
|
|
265
|
+
}
|
|
266
|
+
return value;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** A color as `#rrggbb`. */
|
|
270
|
+
hex(tokenPath: string): string {
|
|
271
|
+
return componentsToHex(
|
|
272
|
+
colorComponents(
|
|
273
|
+
this.token(tokenPath, "color").$value,
|
|
274
|
+
this.file,
|
|
275
|
+
tokenPath,
|
|
276
|
+
),
|
|
277
|
+
);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* A color as an `H S% L%` triplet: the exact text it was written as, when
|
|
282
|
+
* the recorded text still describes the same color, else derived from it.
|
|
283
|
+
*/
|
|
284
|
+
hslTriplet(tokenPath: string): string {
|
|
285
|
+
const token = this.token(tokenPath, "color");
|
|
286
|
+
const components = colorComponents(token.$value, this.file, tokenPath);
|
|
287
|
+
const recorded = (
|
|
288
|
+
token.$extensions?.[EXTENSION] as { hsl?: unknown } | undefined
|
|
289
|
+
)?.hsl;
|
|
290
|
+
if (typeof recorded === "string" && HSL_TRIPLET.test(recorded)) {
|
|
291
|
+
const recordedHex = componentsToHex(
|
|
292
|
+
colorComponents(hslColorToken(recorded).$value, this.file, tokenPath),
|
|
293
|
+
);
|
|
294
|
+
if (recordedHex === componentsToHex(components)) return recorded;
|
|
295
|
+
}
|
|
296
|
+
return componentsToHslTriplet(components);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
{
|
|
2
|
+
"size": {
|
|
3
|
+
"control": {
|
|
4
|
+
"1": {
|
|
5
|
+
"$type": "number",
|
|
6
|
+
"$value": 16
|
|
7
|
+
},
|
|
8
|
+
"2": {
|
|
9
|
+
"$type": "number",
|
|
10
|
+
"$value": 20
|
|
11
|
+
},
|
|
12
|
+
"3": {
|
|
13
|
+
"$type": "number",
|
|
14
|
+
"$value": 24
|
|
15
|
+
},
|
|
16
|
+
"4": {
|
|
17
|
+
"$type": "number",
|
|
18
|
+
"$value": 32
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"control-icon": {
|
|
22
|
+
"1": {
|
|
23
|
+
"$type": "number",
|
|
24
|
+
"$value": 12
|
|
25
|
+
},
|
|
26
|
+
"2": {
|
|
27
|
+
"$type": "number",
|
|
28
|
+
"$value": 12
|
|
29
|
+
},
|
|
30
|
+
"3": {
|
|
31
|
+
"$type": "number",
|
|
32
|
+
"$value": 16
|
|
33
|
+
},
|
|
34
|
+
"4": {
|
|
35
|
+
"$type": "number",
|
|
36
|
+
"$value": 16
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"box": {
|
|
40
|
+
"1": {
|
|
41
|
+
"$type": "number",
|
|
42
|
+
"$value": 16
|
|
43
|
+
},
|
|
44
|
+
"2": {
|
|
45
|
+
"$type": "number",
|
|
46
|
+
"$value": 20
|
|
47
|
+
},
|
|
48
|
+
"3": {
|
|
49
|
+
"$type": "number",
|
|
50
|
+
"$value": 24
|
|
51
|
+
},
|
|
52
|
+
"4": {
|
|
53
|
+
"$type": "number",
|
|
54
|
+
"$value": 32
|
|
55
|
+
},
|
|
56
|
+
"5": {
|
|
57
|
+
"$type": "number",
|
|
58
|
+
"$value": 40
|
|
59
|
+
},
|
|
60
|
+
"6": {
|
|
61
|
+
"$type": "number",
|
|
62
|
+
"$value": 48
|
|
63
|
+
},
|
|
64
|
+
"7": {
|
|
65
|
+
"$type": "number",
|
|
66
|
+
"$value": 56
|
|
67
|
+
},
|
|
68
|
+
"8": {
|
|
69
|
+
"$type": "number",
|
|
70
|
+
"$value": 64
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"radius": {
|
|
75
|
+
"1": {
|
|
76
|
+
"$type": "number",
|
|
77
|
+
"$value": 2
|
|
78
|
+
},
|
|
79
|
+
"2": {
|
|
80
|
+
"$type": "number",
|
|
81
|
+
"$value": 4
|
|
82
|
+
},
|
|
83
|
+
"3": {
|
|
84
|
+
"$type": "number",
|
|
85
|
+
"$value": 6
|
|
86
|
+
},
|
|
87
|
+
"4": {
|
|
88
|
+
"$type": "number",
|
|
89
|
+
"$value": 8
|
|
90
|
+
},
|
|
91
|
+
"5": {
|
|
92
|
+
"$type": "number",
|
|
93
|
+
"$value": 12
|
|
94
|
+
},
|
|
95
|
+
"6": {
|
|
96
|
+
"$type": "number",
|
|
97
|
+
"$value": 16
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"font": {
|
|
101
|
+
"size": {
|
|
102
|
+
"0": {
|
|
103
|
+
"$type": "number",
|
|
104
|
+
"$value": 10
|
|
105
|
+
},
|
|
106
|
+
"1": {
|
|
107
|
+
"$type": "number",
|
|
108
|
+
"$value": 12
|
|
109
|
+
},
|
|
110
|
+
"2": {
|
|
111
|
+
"$type": "number",
|
|
112
|
+
"$value": 13
|
|
113
|
+
},
|
|
114
|
+
"3": {
|
|
115
|
+
"$type": "number",
|
|
116
|
+
"$value": 16
|
|
117
|
+
},
|
|
118
|
+
"4": {
|
|
119
|
+
"$type": "number",
|
|
120
|
+
"$value": 18
|
|
121
|
+
},
|
|
122
|
+
"5": {
|
|
123
|
+
"$type": "number",
|
|
124
|
+
"$value": 20
|
|
125
|
+
},
|
|
126
|
+
"6": {
|
|
127
|
+
"$type": "number",
|
|
128
|
+
"$value": 24
|
|
129
|
+
},
|
|
130
|
+
"7": {
|
|
131
|
+
"$type": "number",
|
|
132
|
+
"$value": 28
|
|
133
|
+
},
|
|
134
|
+
"8": {
|
|
135
|
+
"$type": "number",
|
|
136
|
+
"$value": 35
|
|
137
|
+
},
|
|
138
|
+
"9": {
|
|
139
|
+
"$type": "number",
|
|
140
|
+
"$value": 60
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"line-height": {
|
|
144
|
+
"0": {
|
|
145
|
+
"$type": "number",
|
|
146
|
+
"$value": 16
|
|
147
|
+
},
|
|
148
|
+
"1": {
|
|
149
|
+
"$type": "number",
|
|
150
|
+
"$value": 16
|
|
151
|
+
},
|
|
152
|
+
"2": {
|
|
153
|
+
"$type": "number",
|
|
154
|
+
"$value": 16
|
|
155
|
+
},
|
|
156
|
+
"3": {
|
|
157
|
+
"$type": "number",
|
|
158
|
+
"$value": 24
|
|
159
|
+
},
|
|
160
|
+
"4": {
|
|
161
|
+
"$type": "number",
|
|
162
|
+
"$value": 26
|
|
163
|
+
},
|
|
164
|
+
"5": {
|
|
165
|
+
"$type": "number",
|
|
166
|
+
"$value": 28
|
|
167
|
+
},
|
|
168
|
+
"6": {
|
|
169
|
+
"$type": "number",
|
|
170
|
+
"$value": 30
|
|
171
|
+
},
|
|
172
|
+
"7": {
|
|
173
|
+
"$type": "number",
|
|
174
|
+
"$value": 36
|
|
175
|
+
},
|
|
176
|
+
"8": {
|
|
177
|
+
"$type": "number",
|
|
178
|
+
"$value": 40
|
|
179
|
+
},
|
|
180
|
+
"9": {
|
|
181
|
+
"$type": "number",
|
|
182
|
+
"$value": 60
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
"letter-spacing": {
|
|
186
|
+
"0": {
|
|
187
|
+
"$type": "number",
|
|
188
|
+
"$value": 0.01,
|
|
189
|
+
"$extensions": {
|
|
190
|
+
"com.agent-native": {
|
|
191
|
+
"unit": "em"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
"1": {
|
|
196
|
+
"$type": "number",
|
|
197
|
+
"$value": 0,
|
|
198
|
+
"$extensions": {
|
|
199
|
+
"com.agent-native": {
|
|
200
|
+
"unit": "em"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
"2": {
|
|
205
|
+
"$type": "number",
|
|
206
|
+
"$value": 0,
|
|
207
|
+
"$extensions": {
|
|
208
|
+
"com.agent-native": {
|
|
209
|
+
"unit": "em"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
"3": {
|
|
214
|
+
"$type": "number",
|
|
215
|
+
"$value": 0,
|
|
216
|
+
"$extensions": {
|
|
217
|
+
"com.agent-native": {
|
|
218
|
+
"unit": "em"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
"4": {
|
|
223
|
+
"$type": "number",
|
|
224
|
+
"$value": -0.0025,
|
|
225
|
+
"$extensions": {
|
|
226
|
+
"com.agent-native": {
|
|
227
|
+
"unit": "em"
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"5": {
|
|
232
|
+
"$type": "number",
|
|
233
|
+
"$value": -0.005,
|
|
234
|
+
"$extensions": {
|
|
235
|
+
"com.agent-native": {
|
|
236
|
+
"unit": "em"
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
"6": {
|
|
241
|
+
"$type": "number",
|
|
242
|
+
"$value": -0.00625,
|
|
243
|
+
"$extensions": {
|
|
244
|
+
"com.agent-native": {
|
|
245
|
+
"unit": "em"
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
},
|
|
249
|
+
"7": {
|
|
250
|
+
"$type": "number",
|
|
251
|
+
"$value": -0.0075,
|
|
252
|
+
"$extensions": {
|
|
253
|
+
"com.agent-native": {
|
|
254
|
+
"unit": "em"
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"8": {
|
|
259
|
+
"$type": "number",
|
|
260
|
+
"$value": -0.01,
|
|
261
|
+
"$extensions": {
|
|
262
|
+
"com.agent-native": {
|
|
263
|
+
"unit": "em"
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
},
|
|
267
|
+
"9": {
|
|
268
|
+
"$type": "number",
|
|
269
|
+
"$value": -0.025,
|
|
270
|
+
"$extensions": {
|
|
271
|
+
"com.agent-native": {
|
|
272
|
+
"unit": "em"
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
},
|
|
277
|
+
"weight": {
|
|
278
|
+
"light": {
|
|
279
|
+
"$type": "number",
|
|
280
|
+
"$value": 360
|
|
281
|
+
},
|
|
282
|
+
"regular": {
|
|
283
|
+
"$type": "number",
|
|
284
|
+
"$value": 400
|
|
285
|
+
},
|
|
286
|
+
"medium": {
|
|
287
|
+
"$type": "number",
|
|
288
|
+
"$value": 480
|
|
289
|
+
},
|
|
290
|
+
"semibold": {
|
|
291
|
+
"$type": "number",
|
|
292
|
+
"$value": 600
|
|
293
|
+
},
|
|
294
|
+
"bold": {
|
|
295
|
+
"$type": "number",
|
|
296
|
+
"$value": 700
|
|
297
|
+
}
|
|
298
|
+
},
|
|
299
|
+
"family": {
|
|
300
|
+
"sans": {
|
|
301
|
+
"$type": "string",
|
|
302
|
+
"$value": "\"Inter Variable\", \"Inter\", ui-sans-serif, system-ui, -apple-system, sans-serif"
|
|
303
|
+
},
|
|
304
|
+
"heading": {
|
|
305
|
+
"$type": "string",
|
|
306
|
+
"$value": "var(--font-family-sans)"
|
|
307
|
+
},
|
|
308
|
+
"mono": {
|
|
309
|
+
"$type": "string",
|
|
310
|
+
"$value": "ui-monospace, \"SFMono-Regular\", Menlo, Consolas, monospace"
|
|
311
|
+
},
|
|
312
|
+
"wordmark": {
|
|
313
|
+
"$type": "string",
|
|
314
|
+
"$value": "\"Geist Variable\", \"Geist\", var(--font-family-sans)"
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"brand": {
|
|
3
|
+
"$type": "color",
|
|
4
|
+
"$value": {
|
|
5
|
+
"colorSpace": "srgb",
|
|
6
|
+
"components": [0.101961, 0.439216, 0.921569],
|
|
7
|
+
"alpha": 1,
|
|
8
|
+
"hex": "#1a70eb"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"gray": {
|
|
12
|
+
"$type": "color",
|
|
13
|
+
"$value": {
|
|
14
|
+
"colorSpace": "srgb",
|
|
15
|
+
"components": [0.552941, 0.552941, 0.552941],
|
|
16
|
+
"alpha": 1,
|
|
17
|
+
"hex": "#8d8d8d"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"background": {
|
|
21
|
+
"light": {
|
|
22
|
+
"$type": "color",
|
|
23
|
+
"$value": {
|
|
24
|
+
"colorSpace": "srgb",
|
|
25
|
+
"components": [1, 1, 1],
|
|
26
|
+
"alpha": 1,
|
|
27
|
+
"hex": "#ffffff"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"dark": {
|
|
31
|
+
"$type": "color",
|
|
32
|
+
"$value": {
|
|
33
|
+
"colorSpace": "srgb",
|
|
34
|
+
"components": [0.066667, 0.066667, 0.066667],
|
|
35
|
+
"alpha": 1,
|
|
36
|
+
"hex": "#111111"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"status": {
|
|
41
|
+
"danger": {
|
|
42
|
+
"$type": "string",
|
|
43
|
+
"$value": "red"
|
|
44
|
+
},
|
|
45
|
+
"warning": {
|
|
46
|
+
"$type": "string",
|
|
47
|
+
"$value": "amber"
|
|
48
|
+
},
|
|
49
|
+
"success": {
|
|
50
|
+
"$type": "string",
|
|
51
|
+
"$value": "green"
|
|
52
|
+
},
|
|
53
|
+
"info": {
|
|
54
|
+
"$type": "string",
|
|
55
|
+
"$value": "cyan"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|