@itkeazco/graphite 0.0.0-stage → 1.3.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/CHANGELOG.md +68 -0
- package/README.md +271 -2
- package/bin/graphite.js +94 -0
- package/dist/fonts.css +2 -0
- package/dist/icon-sets/phosphor-bold.json +1 -0
- package/dist/icon-sets/phosphor-light.json +1 -0
- package/dist/icon-sets/phosphor-regular.json +1 -0
- package/dist/icon-sets/tabler.json +1 -0
- package/dist/index.css +5 -0
- package/dist/index.d.ts +658 -0
- package/dist/index.js +2227 -0
- package/dist/layers.css +866 -0
- package/dist/neutrals.css +572 -0
- package/dist/styles.css +655 -0
- package/dist/tokens.css +824 -0
- package/dist/tokens.d.ts +35 -0
- package/dist/tokens.js +2 -0
- package/dist/tokens.json +884 -0
- package/dist/typography.css +26 -0
- package/package.json +90 -4
- package/rules/graphite.mdc +100 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,658 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const LUCIDE_NAMES: readonly ["mic", "box", "code", "bookmark", "volume-x", "volume-2", "x", "link", "play", "pause", "check", "minus", "chevron-down", "chevron-right", "chevron-left", "chevron-up", "plus", "search", "info", "triangle-alert", "circle-alert", "circle-check", "trash-2", "copy", "sparkles", "arrow-right", "arrow-left", "settings", "user", "bell", "calendar", "menu", "ellipsis", "external-link", "eye", "eye-off", "upload", "download", "filter", "pencil", "star", "heart", "house", "log-out", "square", "mic-off", "share-2", "clock", "trending-up", "trending-down", "arrow-up-right", "arrow-down-right", "wallet", "credit-card", "pipette", "sun", "moon", "monitor", "rotate-ccw"];
|
|
5
|
+
declare const ICON_ALIASES: {
|
|
6
|
+
readonly cube: "box";
|
|
7
|
+
readonly mute: "volume-x";
|
|
8
|
+
readonly volume: "volume-2";
|
|
9
|
+
readonly close: "x";
|
|
10
|
+
readonly chevronDown: "chevron-down";
|
|
11
|
+
readonly chevronRight: "chevron-right";
|
|
12
|
+
readonly alert: "triangle-alert";
|
|
13
|
+
readonly trash: "trash-2";
|
|
14
|
+
readonly sparkle: "sparkles";
|
|
15
|
+
readonly more: "ellipsis";
|
|
16
|
+
readonly home: "house";
|
|
17
|
+
readonly edit: "pencil";
|
|
18
|
+
};
|
|
19
|
+
/** Built-in icons (Lucide artwork, Lucide names). Older Graphite names are accepted as aliases. */
|
|
20
|
+
type IconName = (typeof LUCIDE_NAMES)[number] | keyof typeof ICON_ALIASES;
|
|
21
|
+
/** Any icon component, e.g. a lucide-react icon. Graphite passes size, strokeWidth and className. */
|
|
22
|
+
type IconComponent = react.ComponentType<{
|
|
23
|
+
size?: number | string;
|
|
24
|
+
strokeWidth?: number | string;
|
|
25
|
+
className?: string;
|
|
26
|
+
"aria-hidden"?: boolean | "true" | "false";
|
|
27
|
+
}>;
|
|
28
|
+
type IconLike = IconName | IconComponent;
|
|
29
|
+
interface IconProps extends Omit<react.SVGProps<SVGSVGElement>, "name" | "ref"> {
|
|
30
|
+
name: IconLike;
|
|
31
|
+
size?: number;
|
|
32
|
+
strokeWidth?: number;
|
|
33
|
+
className?: string; /** When set, the icon is exposed to assistive tech instead of aria-hidden. */
|
|
34
|
+
label?: string;
|
|
35
|
+
}
|
|
36
|
+
/** Type styles from typography.css (.gt-text-*). CSS classes remain the source of truth. */
|
|
37
|
+
type TextVariant = "display-2xl" | "display-xl" | "display-lg" | "display" | "heading" | "subheading" | "title" | "body" | "label" | "caption" | "micro" | "code";
|
|
38
|
+
/** Maps to .gt-text--{tone}, which sets color from the matching semantic text token. */
|
|
39
|
+
type TextTone = "primary" | "secondary" | "danger" | "success" | "warning" | "info" | "inverse" | "accent";
|
|
40
|
+
type TextElement = "span" | "p" | "div" | "label" | "strong" | "em" | "small" | "code" | "pre";
|
|
41
|
+
interface TextProps extends Omit<react.HTMLAttributes<HTMLElement>, "color"> {
|
|
42
|
+
/** Maps to .gt-text-{variant}. Default body. */
|
|
43
|
+
variant?: TextVariant;
|
|
44
|
+
/** Colour role. Adds .gt-text--{tone} (for example .gt-text--secondary → --color-text-default-secondary). */
|
|
45
|
+
tone?: TextTone;
|
|
46
|
+
as?: TextElement;
|
|
47
|
+
}
|
|
48
|
+
type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
49
|
+
interface HeadingProps extends Omit<react.HTMLAttributes<HTMLHeadingElement>, "color"> {
|
|
50
|
+
/** Heading rank; renders h1–h6 unless as is set. Default 2. */
|
|
51
|
+
level?: HeadingLevel;
|
|
52
|
+
/** Maps to .gt-text-{variant}. Default title. */
|
|
53
|
+
variant?: TextVariant;
|
|
54
|
+
as?: "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "div" | "span";
|
|
55
|
+
}
|
|
56
|
+
interface ButtonProps extends react.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
57
|
+
variant?: "primary" | "secondary" | "tertiary" | "danger" | "link" | "soft" | "ghost" | "overlay";
|
|
58
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
59
|
+
icon?: IconLike;
|
|
60
|
+
iconRight?: IconLike;
|
|
61
|
+
block?: boolean; /** Shows a spinner, hides the label, sets aria-busy. */
|
|
62
|
+
loading?: boolean;
|
|
63
|
+
}
|
|
64
|
+
interface IconButtonProps extends react.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
65
|
+
icon: IconLike;
|
|
66
|
+
label: string; /** Same variants as Button (a square Button); "solid" and "outline" are the older floating styles. */
|
|
67
|
+
variant?: "primary" | "secondary" | "tertiary" | "soft" | "ghost" | "danger" | "solid" | "outline";
|
|
68
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
69
|
+
active?: boolean;
|
|
70
|
+
}
|
|
71
|
+
interface SegmentOption {
|
|
72
|
+
value: string;
|
|
73
|
+
label?: string;
|
|
74
|
+
icon?: IconLike;
|
|
75
|
+
ariaLabel?: string;
|
|
76
|
+
className?: string;
|
|
77
|
+
}
|
|
78
|
+
interface SegmentedControlProps {
|
|
79
|
+
options: SegmentOption[];
|
|
80
|
+
value?: string;
|
|
81
|
+
defaultValue?: string;
|
|
82
|
+
onChange?: (value: string) => void;
|
|
83
|
+
label?: string;
|
|
84
|
+
size?: "sm" | "md" | "lg";
|
|
85
|
+
disabled?: boolean; /** Stretch to the container, options share the width equally. */
|
|
86
|
+
block?: boolean;
|
|
87
|
+
className?: string;
|
|
88
|
+
}
|
|
89
|
+
interface SwitchProps extends Omit<react.ButtonHTMLAttributes<HTMLButtonElement>, "onChange" | "role" | "children"> {
|
|
90
|
+
checked?: boolean;
|
|
91
|
+
defaultChecked?: boolean;
|
|
92
|
+
/** Fires with the next boolean. `onChange` is the same callback, kept for existing call sites. */
|
|
93
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
94
|
+
onChange?: (checked: boolean) => void;
|
|
95
|
+
/** Visible label. Required unless `ariaLabel` or `aria-label` is set. */
|
|
96
|
+
label?: string;
|
|
97
|
+
ariaLabel?: string;
|
|
98
|
+
size?: "sm" | "md";
|
|
99
|
+
}
|
|
100
|
+
interface CheckboxProps extends Omit<react.InputHTMLAttributes<HTMLInputElement>, "type" | "onChange"> {
|
|
101
|
+
label: string;
|
|
102
|
+
description?: string;
|
|
103
|
+
indeterminate?: boolean;
|
|
104
|
+
/** Fires with the next boolean. Native `onChange` still receives the input event. */
|
|
105
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
106
|
+
onChange?: react.ChangeEventHandler<HTMLInputElement>;
|
|
107
|
+
}
|
|
108
|
+
interface RadioShellProps {
|
|
109
|
+
value?: string | null;
|
|
110
|
+
defaultValue?: string | null;
|
|
111
|
+
onChange?: (value: string) => void; /** Group label, rendered as a <legend>. */
|
|
112
|
+
label?: string;
|
|
113
|
+
hint?: string;
|
|
114
|
+
error?: string;
|
|
115
|
+
required?: boolean;
|
|
116
|
+
disabled?: boolean;
|
|
117
|
+
className?: string;
|
|
118
|
+
options?: Array<RadioOption | RadioCardOption>;
|
|
119
|
+
orientation?: "vertical" | "horizontal";
|
|
120
|
+
hideLabel?: boolean;
|
|
121
|
+
showLabel?: boolean;
|
|
122
|
+
}
|
|
123
|
+
interface RadioOption {
|
|
124
|
+
value: string;
|
|
125
|
+
label: string;
|
|
126
|
+
description?: string;
|
|
127
|
+
disabled?: boolean;
|
|
128
|
+
className?: string;
|
|
129
|
+
}
|
|
130
|
+
interface RadioGroupProps extends RadioShellProps {
|
|
131
|
+
options: RadioOption[];
|
|
132
|
+
orientation?: "vertical" | "horizontal";
|
|
133
|
+
hideLabel?: boolean;
|
|
134
|
+
}
|
|
135
|
+
interface RadioCardOption {
|
|
136
|
+
value: string;
|
|
137
|
+
title: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
badge?: string;
|
|
140
|
+
disabled?: boolean;
|
|
141
|
+
className?: string;
|
|
142
|
+
}
|
|
143
|
+
interface RadioCardsProps extends RadioShellProps {
|
|
144
|
+
options: RadioCardOption[]; /** Show the legend visually (it is always available to screen readers). */
|
|
145
|
+
showLabel?: boolean;
|
|
146
|
+
}
|
|
147
|
+
interface ChipOption {
|
|
148
|
+
value: string;
|
|
149
|
+
label: string;
|
|
150
|
+
disabled?: boolean;
|
|
151
|
+
className?: string;
|
|
152
|
+
}
|
|
153
|
+
interface ChipGroupProps extends Omit<react.HTMLAttributes<HTMLDivElement>, "onChange" | "defaultValue"> {
|
|
154
|
+
options: Array<string | ChipOption>;
|
|
155
|
+
multiple?: boolean;
|
|
156
|
+
value?: string | string[];
|
|
157
|
+
defaultValue?: string | string[];
|
|
158
|
+
/** Fires with the next value: a string, or a string array when `multiple`. `onChange` is the same callback. */
|
|
159
|
+
onValueChange?: (value: string | string[]) => void;
|
|
160
|
+
onChange?: (value: string | string[]) => void;
|
|
161
|
+
/** Names the group for assistive tech. */
|
|
162
|
+
label?: string;
|
|
163
|
+
}
|
|
164
|
+
interface FieldProps {
|
|
165
|
+
label?: string;
|
|
166
|
+
hint?: string;
|
|
167
|
+
error?: string;
|
|
168
|
+
optional?: boolean;
|
|
169
|
+
className?: string;
|
|
170
|
+
disabled?: boolean;
|
|
171
|
+
}
|
|
172
|
+
interface InputProps extends FieldProps, Omit<react.InputHTMLAttributes<HTMLInputElement>, "className"> {
|
|
173
|
+
icon?: IconLike;
|
|
174
|
+
suffix?: react.ReactNode;
|
|
175
|
+
}
|
|
176
|
+
interface TextareaProps extends FieldProps, Omit<react.TextareaHTMLAttributes<HTMLTextAreaElement>, "className" | "onChange"> {
|
|
177
|
+
value?: string;
|
|
178
|
+
defaultValue?: string;
|
|
179
|
+
onChange?: (value: string) => void;
|
|
180
|
+
maxLength?: number;
|
|
181
|
+
}
|
|
182
|
+
interface SelectOption {
|
|
183
|
+
value: string;
|
|
184
|
+
label: string;
|
|
185
|
+
}
|
|
186
|
+
interface SelectProps extends FieldProps, Omit<react.SelectHTMLAttributes<HTMLSelectElement>, "className"> {
|
|
187
|
+
options: Array<string | SelectOption>;
|
|
188
|
+
/** Fires with the selected value. Native `onChange` still receives the change event. */
|
|
189
|
+
onValueChange?: (value: string) => void;
|
|
190
|
+
}
|
|
191
|
+
interface CardProps extends react.HTMLAttributes<HTMLElement> {
|
|
192
|
+
title?: string;
|
|
193
|
+
description?: string;
|
|
194
|
+
footer?: react.ReactNode;
|
|
195
|
+
/** Surface is flat with a hairline. Elevated lifts the card with a shadow. */
|
|
196
|
+
variant?: "surface" | "elevated";
|
|
197
|
+
}
|
|
198
|
+
interface ListRowProps extends Omit<react.HTMLAttributes<HTMLElement>, "title"> {
|
|
199
|
+
title: string;
|
|
200
|
+
description?: string;
|
|
201
|
+
icon?: IconLike;
|
|
202
|
+
/** Anything at the start instead of an icon, for example an Avatar. */
|
|
203
|
+
leading?: react.ReactNode;
|
|
204
|
+
trailing?: react.ReactNode;
|
|
205
|
+
/** Renders a link. A disabled row stays a button so it cannot be opened. */
|
|
206
|
+
href?: string;
|
|
207
|
+
onClick?: react.MouseEventHandler<HTMLElement>;
|
|
208
|
+
disabled?: boolean;
|
|
209
|
+
/** Trailing chevron for a row that opens something. */
|
|
210
|
+
chevron?: boolean;
|
|
211
|
+
}
|
|
212
|
+
interface DividerProps extends react.HTMLAttributes<HTMLHRElement> {
|
|
213
|
+
orientation?: "horizontal" | "vertical";
|
|
214
|
+
/** Pulls a horizontal rule in from the edges. */
|
|
215
|
+
inset?: boolean;
|
|
216
|
+
}
|
|
217
|
+
interface BadgeProps {
|
|
218
|
+
tone?: "neutral" | "solid" | "outline" | "live" | "success" | "warning" | "danger" | "info";
|
|
219
|
+
/** Subtle (tinted, default) or bold (filled) for higher emphasis. */
|
|
220
|
+
variant?: "subtle" | "bold";
|
|
221
|
+
/** sm 20px, md 24px (default), lg 28px. */
|
|
222
|
+
size?: "sm" | "md" | "lg";
|
|
223
|
+
/** A static dot in the text colour before the label. */
|
|
224
|
+
dot?: boolean;
|
|
225
|
+
/** An icon before the label. */
|
|
226
|
+
icon?: string;
|
|
227
|
+
children?: react.ReactNode;
|
|
228
|
+
className?: string;
|
|
229
|
+
}
|
|
230
|
+
interface AvatarProps {
|
|
231
|
+
name: string;
|
|
232
|
+
src?: string;
|
|
233
|
+
size?: "xs" | "sm" | "md" | "lg";
|
|
234
|
+
status?: "online" | "live" | "away";
|
|
235
|
+
className?: string;
|
|
236
|
+
}
|
|
237
|
+
interface KbdProps {
|
|
238
|
+
children?: react.ReactNode;
|
|
239
|
+
className?: string;
|
|
240
|
+
}
|
|
241
|
+
interface PopoverProps {
|
|
242
|
+
open: boolean;
|
|
243
|
+
onClose: () => void;
|
|
244
|
+
/** The element the popover points from, usually the button that opens it. */
|
|
245
|
+
anchor: react.RefObject<HTMLElement | null>;
|
|
246
|
+
/** Preferred side. Flips when there is no room. Default bottom. */
|
|
247
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
248
|
+
align?: "start" | "center" | "end";
|
|
249
|
+
offset?: number;
|
|
250
|
+
label: string;
|
|
251
|
+
children?: react.ReactNode;
|
|
252
|
+
className?: string;
|
|
253
|
+
}
|
|
254
|
+
type ColorFormat = "hex" | "rgb" | "hsl";
|
|
255
|
+
interface ColorPickerProps {
|
|
256
|
+
/** A colour (#hex, rgb(), hsl()) or, with the gradient mode, a linear-gradient(). */
|
|
257
|
+
value?: string;
|
|
258
|
+
defaultValue?: string;
|
|
259
|
+
/** Fires with #rrggbb (#rrggbbaa below 100% opacity) or linear-gradient(…). */
|
|
260
|
+
onChange?: (value: string) => void;
|
|
261
|
+
/** Tabs at the top. Default ["color"]. */
|
|
262
|
+
modes?: Array<"color" | "gradient">;
|
|
263
|
+
alpha?: boolean;
|
|
264
|
+
/** Shows the screen picker where the browser supports it. */
|
|
265
|
+
eyedropper?: boolean;
|
|
266
|
+
swatches?: string[];
|
|
267
|
+
label?: string;
|
|
268
|
+
className?: string;
|
|
269
|
+
}
|
|
270
|
+
interface ChartPoint {
|
|
271
|
+
label: string;
|
|
272
|
+
value: number;
|
|
273
|
+
}
|
|
274
|
+
interface ChartSegment {
|
|
275
|
+
label: string;
|
|
276
|
+
value: number; /** CSS colour. Defaults to --chart-1 … --chart-6 in order. */
|
|
277
|
+
color?: string;
|
|
278
|
+
}
|
|
279
|
+
interface SparklineProps {
|
|
280
|
+
data: number[];
|
|
281
|
+
width?: number;
|
|
282
|
+
height?: number; /** auto: green when the last value is higher than the first, red when lower. */
|
|
283
|
+
tone?: "default" | "auto" | "success" | "danger" | "muted";
|
|
284
|
+
area?: boolean; /** Read by screen readers, e.g. "Balance, last 30 days, up 4%". */
|
|
285
|
+
label?: string;
|
|
286
|
+
className?: string;
|
|
287
|
+
}
|
|
288
|
+
interface LineChartProps {
|
|
289
|
+
data: number[];
|
|
290
|
+
labels?: string[]; /** A second series drawn dashed, e.g. last month. */
|
|
291
|
+
compare?: number[];
|
|
292
|
+
compareLabel?: string;
|
|
293
|
+
label: string;
|
|
294
|
+
height?: number;
|
|
295
|
+
format?: (value: number) => string;
|
|
296
|
+
area?: boolean;
|
|
297
|
+
yTicks?: number;
|
|
298
|
+
className?: string;
|
|
299
|
+
}
|
|
300
|
+
interface BarChartProps {
|
|
301
|
+
data: ChartPoint[];
|
|
302
|
+
label: string;
|
|
303
|
+
height?: number;
|
|
304
|
+
format?: (value: number) => string; /** Index of the highlighted bar. Defaults to the last one. */
|
|
305
|
+
selected?: number;
|
|
306
|
+
defaultSelected?: number;
|
|
307
|
+
onSelect?: (index: number) => void;
|
|
308
|
+
className?: string;
|
|
309
|
+
}
|
|
310
|
+
interface DonutChartProps {
|
|
311
|
+
data: ChartSegment[];
|
|
312
|
+
label: string;
|
|
313
|
+
size?: number;
|
|
314
|
+
thickness?: number; /** Shown in the hole. Defaults to the total. */
|
|
315
|
+
center?: react.ReactNode;
|
|
316
|
+
centerLabel?: string;
|
|
317
|
+
format?: (value: number) => string;
|
|
318
|
+
legend?: boolean; /** Round ends on each part. Default: follows --chart-cap (round, square under data-radius none or sharp). */
|
|
319
|
+
rounded?: boolean;
|
|
320
|
+
className?: string;
|
|
321
|
+
}
|
|
322
|
+
interface StatProps {
|
|
323
|
+
label: string;
|
|
324
|
+
value: react.ReactNode; /** Change in percent, e.g. 4.2 or -1.5. */
|
|
325
|
+
delta?: number;
|
|
326
|
+
deltaLabel?: string;
|
|
327
|
+
deltaFormat?: (delta: number) => string; /** Down is good, e.g. spending. */
|
|
328
|
+
invert?: boolean;
|
|
329
|
+
chart?: number[];
|
|
330
|
+
icon?: IconLike;
|
|
331
|
+
size?: "md" | "lg";
|
|
332
|
+
className?: string;
|
|
333
|
+
}
|
|
334
|
+
interface ProgressProps {
|
|
335
|
+
value?: number;
|
|
336
|
+
label?: string;
|
|
337
|
+
showValue?: boolean;
|
|
338
|
+
indeterminate?: boolean; /** Error message; turns the bar red. */
|
|
339
|
+
error?: string;
|
|
340
|
+
className?: string;
|
|
341
|
+
}
|
|
342
|
+
interface TooltipProps {
|
|
343
|
+
content: react.ReactNode;
|
|
344
|
+
shortcut?: string;
|
|
345
|
+
side?: "top" | "bottom";
|
|
346
|
+
open?: boolean;
|
|
347
|
+
children: react.ReactNode;
|
|
348
|
+
}
|
|
349
|
+
interface ToastProps {
|
|
350
|
+
tone?: "neutral" | "success" | "info" | "warning" | "error";
|
|
351
|
+
icon?: IconLike;
|
|
352
|
+
action?: string;
|
|
353
|
+
onAction?: () => void;
|
|
354
|
+
onClose?: () => void;
|
|
355
|
+
children?: react.ReactNode;
|
|
356
|
+
className?: string;
|
|
357
|
+
}
|
|
358
|
+
interface DialogProps {
|
|
359
|
+
open: boolean;
|
|
360
|
+
title: string;
|
|
361
|
+
description?: string;
|
|
362
|
+
actions?: react.ReactNode;
|
|
363
|
+
onClose?: () => void;
|
|
364
|
+
inline?: boolean; /** sm 400px (default) for confirmations, md 560px for lists and forms. */
|
|
365
|
+
size?: "sm" | "md";
|
|
366
|
+
children?: react.ReactNode;
|
|
367
|
+
}
|
|
368
|
+
interface LabelProps extends react.LabelHTMLAttributes<HTMLLabelElement> {
|
|
369
|
+
required?: boolean;
|
|
370
|
+
optional?: boolean;
|
|
371
|
+
}
|
|
372
|
+
interface SliderProps {
|
|
373
|
+
value?: number;
|
|
374
|
+
defaultValue?: number;
|
|
375
|
+
onChange?: (value: number) => void;
|
|
376
|
+
min?: number;
|
|
377
|
+
max?: number;
|
|
378
|
+
step?: number;
|
|
379
|
+
disabled?: boolean; /** Accessible name when no visible Label points at it. */
|
|
380
|
+
label?: string;
|
|
381
|
+
valueText?: (value: number) => string;
|
|
382
|
+
size?: "sm" | "md";
|
|
383
|
+
id?: string;
|
|
384
|
+
className?: string;
|
|
385
|
+
}
|
|
386
|
+
interface SkeletonProps {
|
|
387
|
+
width?: number | string;
|
|
388
|
+
height?: number | string;
|
|
389
|
+
radius?: "sm" | "md" | "lg" | "full";
|
|
390
|
+
className?: string;
|
|
391
|
+
style?: react.CSSProperties;
|
|
392
|
+
}
|
|
393
|
+
interface AlertProps {
|
|
394
|
+
tone?: "neutral" | "info" | "success" | "warning" | "danger";
|
|
395
|
+
title?: react.ReactNode;
|
|
396
|
+
children?: react.ReactNode;
|
|
397
|
+
action?: react.ReactNode;
|
|
398
|
+
onClose?: () => void;
|
|
399
|
+
icon?: IconLike;
|
|
400
|
+
className?: string;
|
|
401
|
+
}
|
|
402
|
+
interface BreadcrumbItem {
|
|
403
|
+
label: react.ReactNode;
|
|
404
|
+
href?: string;
|
|
405
|
+
onClick?: () => void;
|
|
406
|
+
}
|
|
407
|
+
interface BreadcrumbProps {
|
|
408
|
+
items: BreadcrumbItem[];
|
|
409
|
+
label?: string;
|
|
410
|
+
className?: string;
|
|
411
|
+
}
|
|
412
|
+
interface TabItem {
|
|
413
|
+
value: string;
|
|
414
|
+
label: react.ReactNode;
|
|
415
|
+
icon?: IconLike;
|
|
416
|
+
count?: number;
|
|
417
|
+
disabled?: boolean;
|
|
418
|
+
content?: react.ReactNode;
|
|
419
|
+
}
|
|
420
|
+
interface TabsProps {
|
|
421
|
+
items: TabItem[];
|
|
422
|
+
value?: string;
|
|
423
|
+
defaultValue?: string;
|
|
424
|
+
onChange?: (value: string) => void;
|
|
425
|
+
variant?: "line" | "pill"; /** Tabs share the full width equally. */
|
|
426
|
+
block?: boolean; /** "vertical" stacks the tabs in a side column, like side navigation, with the panel beside them. */
|
|
427
|
+
orientation?: "horizontal" | "vertical";
|
|
428
|
+
label?: string;
|
|
429
|
+
className?: string;
|
|
430
|
+
}
|
|
431
|
+
interface AccordionItem {
|
|
432
|
+
value: string;
|
|
433
|
+
title: react.ReactNode;
|
|
434
|
+
content: react.ReactNode;
|
|
435
|
+
disabled?: boolean;
|
|
436
|
+
}
|
|
437
|
+
interface AccordionProps {
|
|
438
|
+
items: AccordionItem[];
|
|
439
|
+
type?: "single" | "multiple";
|
|
440
|
+
defaultValue?: string | string[];
|
|
441
|
+
className?: string;
|
|
442
|
+
}
|
|
443
|
+
interface PaginationProps {
|
|
444
|
+
page: number;
|
|
445
|
+
pageCount: number;
|
|
446
|
+
onChange?: (page: number) => void;
|
|
447
|
+
siblings?: number;
|
|
448
|
+
label?: string;
|
|
449
|
+
className?: string;
|
|
450
|
+
}
|
|
451
|
+
interface TableColumn<Row> {
|
|
452
|
+
key: string;
|
|
453
|
+
header: react.ReactNode;
|
|
454
|
+
align?: "start" | "center" | "end";
|
|
455
|
+
width?: number | string;
|
|
456
|
+
render?: (row: Row) => react.ReactNode;
|
|
457
|
+
}
|
|
458
|
+
interface TableProps<Row> {
|
|
459
|
+
columns: TableColumn<Row>[];
|
|
460
|
+
rows: Row[];
|
|
461
|
+
rowKey?: keyof Row | ((row: Row) => string);
|
|
462
|
+
caption?: react.ReactNode;
|
|
463
|
+
density?: "comfortable" | "compact";
|
|
464
|
+
selectedKey?: string;
|
|
465
|
+
onRowClick?: (row: Row) => void;
|
|
466
|
+
empty?: react.ReactNode;
|
|
467
|
+
className?: string;
|
|
468
|
+
}
|
|
469
|
+
interface SheetProps {
|
|
470
|
+
open: boolean;
|
|
471
|
+
onClose: () => void;
|
|
472
|
+
side?: "right" | "left" | "bottom";
|
|
473
|
+
title: string;
|
|
474
|
+
description?: string;
|
|
475
|
+
footer?: react.ReactNode;
|
|
476
|
+
size?: "sm" | "md" | "lg";
|
|
477
|
+
children?: react.ReactNode;
|
|
478
|
+
className?: string;
|
|
479
|
+
}
|
|
480
|
+
type MenuItem = {
|
|
481
|
+
type?: "item";
|
|
482
|
+
label: react.ReactNode;
|
|
483
|
+
icon?: IconLike;
|
|
484
|
+
shortcut?: string;
|
|
485
|
+
onSelect?: () => void;
|
|
486
|
+
danger?: boolean;
|
|
487
|
+
disabled?: boolean;
|
|
488
|
+
} | {
|
|
489
|
+
type: "separator";
|
|
490
|
+
} | {
|
|
491
|
+
type: "label";
|
|
492
|
+
label: react.ReactNode;
|
|
493
|
+
};
|
|
494
|
+
interface DropdownMenuProps {
|
|
495
|
+
trigger: react.ReactNode;
|
|
496
|
+
items: MenuItem[];
|
|
497
|
+
side?: "top" | "bottom" | "left" | "right";
|
|
498
|
+
align?: "start" | "center" | "end";
|
|
499
|
+
label?: string;
|
|
500
|
+
className?: string;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/** An alternative icon set: SVG inner markup per Graphite icon name, drawn in stroke or fill mode. */
|
|
504
|
+
interface IconSet {
|
|
505
|
+
icons: Record<string, string>;
|
|
506
|
+
viewBox?: string;
|
|
507
|
+
mode?: "stroke" | "fill";
|
|
508
|
+
}
|
|
509
|
+
/** Swap every Graphite icon below for another set (Tabler, Phosphor…). Names without a match fall back to Lucide. */
|
|
510
|
+
declare function IconSetProvider({ set, children }: {
|
|
511
|
+
set?: IconSet | null;
|
|
512
|
+
children?: ReactNode;
|
|
513
|
+
}): react.JSX.Element;
|
|
514
|
+
declare const Icon: react.ForwardRefExoticComponent<IconProps & react.RefAttributes<SVGSVGElement>> & {
|
|
515
|
+
names: IconName[];
|
|
516
|
+
};
|
|
517
|
+
|
|
518
|
+
declare const Button: react.ForwardRefExoticComponent<ButtonProps & react.RefAttributes<HTMLButtonElement>>;
|
|
519
|
+
|
|
520
|
+
declare function IconButton({ variant, size, icon, label, className, active, ...rest }: IconButtonProps): react.JSX.Element;
|
|
521
|
+
|
|
522
|
+
declare const Text: react.ForwardRefExoticComponent<TextProps & react.RefAttributes<HTMLElement>>;
|
|
523
|
+
|
|
524
|
+
declare const Heading: react.ForwardRefExoticComponent<HeadingProps & react.RefAttributes<HTMLHeadingElement>>;
|
|
525
|
+
|
|
526
|
+
declare function SegmentedControl({ options, value, defaultValue, onChange, label, size, disabled, block, className }: SegmentedControlProps): react.JSX.Element;
|
|
527
|
+
|
|
528
|
+
declare const Switch: react.ForwardRefExoticComponent<SwitchProps & react.RefAttributes<HTMLButtonElement>>;
|
|
529
|
+
|
|
530
|
+
declare const Checkbox: react.ForwardRefExoticComponent<CheckboxProps & react.RefAttributes<HTMLInputElement>>;
|
|
531
|
+
|
|
532
|
+
declare function RadioGroup(props: RadioGroupProps): react.JSX.Element;
|
|
533
|
+
|
|
534
|
+
declare function RadioCards(props: RadioCardsProps): react.JSX.Element;
|
|
535
|
+
|
|
536
|
+
declare const ChipGroup: react.ForwardRefExoticComponent<ChipGroupProps & react.RefAttributes<HTMLDivElement>>;
|
|
537
|
+
|
|
538
|
+
declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
|
|
539
|
+
|
|
540
|
+
declare function Textarea({ label, hint, error, className, optional, value, defaultValue, onChange, maxLength, disabled, ...rest }: TextareaProps): react.JSX.Element;
|
|
541
|
+
|
|
542
|
+
declare const Select: react.ForwardRefExoticComponent<SelectProps & react.RefAttributes<HTMLSelectElement>>;
|
|
543
|
+
|
|
544
|
+
declare const Card: react.ForwardRefExoticComponent<CardProps & react.RefAttributes<HTMLElement>>;
|
|
545
|
+
|
|
546
|
+
declare const ListRow: react.ForwardRefExoticComponent<ListRowProps & react.RefAttributes<HTMLElement>>;
|
|
547
|
+
|
|
548
|
+
declare const Divider: react.ForwardRefExoticComponent<DividerProps & react.RefAttributes<HTMLHRElement>>;
|
|
549
|
+
|
|
550
|
+
declare function Badge({ tone, variant, size, dot, icon, children, className }: BadgeProps): react.JSX.Element;
|
|
551
|
+
|
|
552
|
+
declare function Avatar({ name, src, size, status, className }: AvatarProps): react.JSX.Element;
|
|
553
|
+
|
|
554
|
+
declare function Kbd({ children, className }: KbdProps): react.JSX.Element;
|
|
555
|
+
|
|
556
|
+
declare function Progress({ value, label, showValue, indeterminate, error, className }: ProgressProps): react.JSX.Element;
|
|
557
|
+
|
|
558
|
+
declare function Tooltip({ content, shortcut, side, open, children }: TooltipProps): react.JSX.Element;
|
|
559
|
+
|
|
560
|
+
declare function Toast({ tone, icon, action, onAction, onClose, children, className }: ToastProps): react.JSX.Element;
|
|
561
|
+
|
|
562
|
+
declare function Dialog({ open, title, description, actions, onClose, inline, size, children }: DialogProps): react.JSX.Element | null;
|
|
563
|
+
|
|
564
|
+
declare function Sparkline({ data, width, height, tone, area, label, className }: SparklineProps): react.JSX.Element | null;
|
|
565
|
+
declare function LineChart({ data, labels, compare, compareLabel, label, height, format, area, yTicks, className }: LineChartProps): react.JSX.Element;
|
|
566
|
+
declare function BarChart({ data, label, height, format, selected, defaultSelected, onSelect, className }: BarChartProps): react.JSX.Element;
|
|
567
|
+
declare function DonutChart({ data, label, size, thickness, center, centerLabel, format, legend, rounded, className }: DonutChartProps): react.JSX.Element;
|
|
568
|
+
|
|
569
|
+
declare function Stat({ label, value, delta, deltaLabel, deltaFormat, invert, chart, icon, size, className }: StatProps): react.JSX.Element;
|
|
570
|
+
|
|
571
|
+
type Rgba = {
|
|
572
|
+
r: number;
|
|
573
|
+
g: number;
|
|
574
|
+
b: number;
|
|
575
|
+
a: number;
|
|
576
|
+
};
|
|
577
|
+
/** Parses #rgb, #rrggbb, #rrggbbaa, rgb()/rgba() and hsl()/hsla(). */
|
|
578
|
+
declare function parseColor(input: string): Rgba | null;
|
|
579
|
+
declare function ColorPicker({ value, defaultValue, onChange, modes, alpha, eyedropper, swatches, label, className }: ColorPickerProps): react.JSX.Element;
|
|
580
|
+
|
|
581
|
+
declare function Popover({ open, onClose, anchor, side, align, offset, label, children, className }: PopoverProps): react.ReactPortal | null;
|
|
582
|
+
|
|
583
|
+
/** A form label. Pair it with any control by htmlFor; required adds a mark, optional a quiet word. */
|
|
584
|
+
declare function Label({ htmlFor, required, optional, children, className, ...rest }: LabelProps): react.JSX.Element;
|
|
585
|
+
|
|
586
|
+
/** A bare slider: a track, the filled part and a thumb. Put its label beside it with Label. */
|
|
587
|
+
declare function Slider({ value, defaultValue, onChange, min, max, step, disabled, label, valueText, size, className, id }: SliderProps): react.JSX.Element;
|
|
588
|
+
|
|
589
|
+
/** A placeholder at the content's own size while it loads. Draw the real layout with these, not a spinner. */
|
|
590
|
+
declare function Skeleton({ width, height, radius, className, style }: SkeletonProps): react.JSX.Element;
|
|
591
|
+
|
|
592
|
+
/** An inline message in the page: a status, a title, one line of detail and at most one action. */
|
|
593
|
+
declare function Alert({ tone, title, children, action, onClose, icon, className }: AlertProps): react.JSX.Element;
|
|
594
|
+
|
|
595
|
+
/** Where this page sits. The last item is the current page and is not a link. */
|
|
596
|
+
declare function Breadcrumb({ items, className, label }: BreadcrumbProps): react.JSX.Element;
|
|
597
|
+
|
|
598
|
+
/** Switch between views of the same page. Underlined (line) by default, contained (pill) for toolbars; orientation="vertical" for side navigation. */
|
|
599
|
+
declare function Tabs({ items, value, defaultValue, onChange, variant, block, orientation, label, className }: TabsProps): react.JSX.Element;
|
|
600
|
+
|
|
601
|
+
/** Stacked sections that open in place. single: one open at a time. multiple: any number. */
|
|
602
|
+
declare function Accordion({ items, type, defaultValue, className }: AccordionProps): react.JSX.Element;
|
|
603
|
+
|
|
604
|
+
/** Page through a long list. Current page, its neighbours, the first and last, ellipses between. */
|
|
605
|
+
declare function Pagination({ page, pageCount, onChange, siblings, label, className }: PaginationProps): react.JSX.Element;
|
|
606
|
+
|
|
607
|
+
/** A data table: real <table> semantics, a sticky header, numbers aligned right, rows that can be selected. */
|
|
608
|
+
declare function Table<Row extends Record<string, unknown>>({ columns, rows, rowKey, caption, density, selectedKey, onRowClick, empty, className }: TableProps<Row>): react.JSX.Element;
|
|
609
|
+
|
|
610
|
+
/** A panel that slides in from an edge over a scrim: filters, details, edit forms. Escape and the scrim close it. */
|
|
611
|
+
declare function Sheet({ open, onClose, side, title, description, footer, size, children, className }: SheetProps): react.ReactPortal | null;
|
|
612
|
+
|
|
613
|
+
/** A list of actions behind a button: icons, shortcuts, separators, one destructive item at the end. */
|
|
614
|
+
declare function DropdownMenu({ trigger, items, side, align, label, className }: DropdownMenuProps): react.JSX.Element;
|
|
615
|
+
|
|
616
|
+
declare const BRAND_STEPS: readonly [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950];
|
|
617
|
+
type BrandStep = (typeof BRAND_STEPS)[number];
|
|
618
|
+
type BrandScale = Record<BrandStep, string>;
|
|
619
|
+
interface BrandTheme {
|
|
620
|
+
[token: string]: string;
|
|
621
|
+
}
|
|
622
|
+
interface BrandTokens {
|
|
623
|
+
scale: BrandScale;
|
|
624
|
+
base: BrandStep;
|
|
625
|
+
light: BrandTheme;
|
|
626
|
+
dark: BrandTheme;
|
|
627
|
+
}
|
|
628
|
+
/** WCAG contrast ratio between two hex colours. */
|
|
629
|
+
declare function contrastRatio(a: string, b: string): number;
|
|
630
|
+
/** A 50–950 scale from one colour. The input lands unchanged on its nearest step. */
|
|
631
|
+
declare function brandScale(hex: string): {
|
|
632
|
+
scale: BrandScale;
|
|
633
|
+
base: BrandStep;
|
|
634
|
+
};
|
|
635
|
+
/**
|
|
636
|
+
* Semantic token values for light and dark, from one brand colour.
|
|
637
|
+
* Every pair is checked: button labels reach 4.5:1 on the primary (the step moves
|
|
638
|
+
* darker or lighter if the picked colour can't carry one), accent text reaches 4.5:1
|
|
639
|
+
* on the page and surfaces, and accent fills reach 3:1.
|
|
640
|
+
*/
|
|
641
|
+
declare function brandTokens(hex: string): BrandTokens;
|
|
642
|
+
interface BrandOptions {
|
|
643
|
+
/** A second colour for links, highlights and the second chart series. Defaults to the brand colour. */
|
|
644
|
+
accent?: string;
|
|
645
|
+
}
|
|
646
|
+
/** Accent tokens (and the second chart series) from their own colour. */
|
|
647
|
+
declare function accentTokens(hex: string): {
|
|
648
|
+
scale: BrandScale;
|
|
649
|
+
light: BrandTheme;
|
|
650
|
+
dark: BrandTheme;
|
|
651
|
+
};
|
|
652
|
+
/**
|
|
653
|
+
* CSS for a brand. Load it after Graphite and set data-brand on <html> (or any element).
|
|
654
|
+
* Pass a primary colour, an accent, or both; the scales are exposed as --brand-50 … and --accent-50 ….
|
|
655
|
+
*/
|
|
656
|
+
declare function brandCss(hex: string | null | undefined, id?: string, options?: BrandOptions): string;
|
|
657
|
+
|
|
658
|
+
export { Accordion, type AccordionItem, type AccordionProps, Alert, type AlertProps, Avatar, type AvatarProps, BRAND_STEPS, Badge, type BadgeProps, BarChart, type BarChartProps, type BrandOptions, type BrandScale, type BrandStep, type BrandTheme, type BrandTokens, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, type ButtonProps, Card, type CardProps, type ChartPoint, type ChartSegment, Checkbox, type CheckboxProps, ChipGroup, type ChipGroupProps, type ColorFormat, ColorPicker, type ColorPickerProps, Dialog, type DialogProps, Divider, type DividerProps, DonutChart, type DonutChartProps, DropdownMenu, type DropdownMenuProps, Heading, type HeadingLevel, type HeadingProps, Icon, IconButton, type IconButtonProps, type IconComponent, type IconLike, type IconName, type IconProps, type IconSet, IconSetProvider, Input, type InputProps, Kbd, type KbdProps, Label, type LabelProps, LineChart, type LineChartProps, ListRow, type ListRowProps, type MenuItem, Pagination, type PaginationProps, Popover, type PopoverProps, Progress, type ProgressProps, type RadioCardOption, RadioCards, type RadioCardsProps, RadioGroup, type RadioGroupProps, type RadioOption, type SegmentOption, SegmentedControl, type SegmentedControlProps, Select, type SelectProps, Sheet, type SheetProps, Skeleton, type SkeletonProps, Slider, type SliderProps, Sparkline, type SparklineProps, Stat, type StatProps, Switch, type SwitchProps, type TabItem, Table, type TableColumn, type TableProps, Tabs, type TabsProps, Text, type TextElement, type TextProps, type TextTone, type TextVariant, Textarea, type TextareaProps, Toast, type ToastProps, Tooltip, type TooltipProps, accentTokens, brandCss, brandScale, brandTokens, contrastRatio, parseColor };
|