@walco-ai/claude-plugin-design-system 0.0.0-stage → 0.4.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.
Files changed (53) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +35 -2
  3. package/dist/breakpoints.d.ts +10 -0
  4. package/dist/components/AppHeader/AppHeader.d.ts +23 -0
  5. package/dist/components/Badge/Badge.d.ts +9 -0
  6. package/dist/components/Banner/Banner.d.ts +23 -0
  7. package/dist/components/Button/Button.d.ts +13 -0
  8. package/dist/components/Card/Card.d.ts +12 -0
  9. package/dist/components/ChangeBar/ChangeBar.d.ts +9 -0
  10. package/dist/components/Checkbox/Checkbox.d.ts +3 -0
  11. package/dist/components/CollapsibleRow/CollapsibleRow.d.ts +24 -0
  12. package/dist/components/Field/Field.d.ts +18 -0
  13. package/dist/components/Figure/Figure.d.ts +10 -0
  14. package/dist/components/FilterChip/FilterChip.d.ts +14 -0
  15. package/dist/components/Icon/Icon.d.ts +12 -0
  16. package/dist/components/Icon/icons.d.ts +34 -0
  17. package/dist/components/IconButton/IconButton.d.ts +10 -0
  18. package/dist/components/Link/Link.d.ts +8 -0
  19. package/dist/components/LiveIndicator/LiveIndicator.d.ts +10 -0
  20. package/dist/components/PillButton/PillButton.d.ts +13 -0
  21. package/dist/components/ProgressBar/ProgressBar.d.ts +12 -0
  22. package/dist/components/Prose/Prose.d.ts +13 -0
  23. package/dist/components/Radio/Choice.d.ts +10 -0
  24. package/dist/components/Radio/Radio.d.ts +3 -0
  25. package/dist/components/ScrollArea/ScrollArea.d.ts +12 -0
  26. package/dist/components/SegmentedControl/SegmentedControl.d.ts +17 -0
  27. package/dist/components/StatusBadge/StatusBadge.d.ts +9 -0
  28. package/dist/components/StatusDot/StatusDot.d.ts +13 -0
  29. package/dist/components/Tabs/Tabs.d.ts +17 -0
  30. package/dist/components/TextArea/TextArea.d.ts +10 -0
  31. package/dist/components/TextField/TextField.d.ts +10 -0
  32. package/dist/components/TruncatedPath/TruncatedPath.d.ts +7 -0
  33. package/dist/components/VisuallyHidden/VisuallyHidden.d.ts +7 -0
  34. package/dist/fonts/OFL.txt +94 -0
  35. package/dist/fonts/fonts.css +91 -0
  36. package/dist/fonts/ibm-plex-mono-latin-400-normal.woff2 +0 -0
  37. package/dist/fonts/ibm-plex-mono-latin-500-normal.woff2 +0 -0
  38. package/dist/fonts/ibm-plex-mono-latin-ext-400-normal.woff2 +0 -0
  39. package/dist/fonts/ibm-plex-mono-latin-ext-500-normal.woff2 +0 -0
  40. package/dist/fonts/ibm-plex-sans-latin-400-normal.woff2 +0 -0
  41. package/dist/fonts/ibm-plex-sans-latin-500-normal.woff2 +0 -0
  42. package/dist/fonts/ibm-plex-sans-latin-600-normal.woff2 +0 -0
  43. package/dist/fonts/ibm-plex-sans-latin-ext-400-normal.woff2 +0 -0
  44. package/dist/fonts/ibm-plex-sans-latin-ext-500-normal.woff2 +0 -0
  45. package/dist/fonts/ibm-plex-sans-latin-ext-600-normal.woff2 +0 -0
  46. package/dist/index.d.ts +30 -0
  47. package/dist/index.js +758 -0
  48. package/dist/internal/cx.d.ts +2 -0
  49. package/dist/internal/tone.d.ts +2 -0
  50. package/dist/internal/useIndicator.d.ts +9 -0
  51. package/dist/internal/useTonePulse.d.ts +5 -0
  52. package/dist/styles.css +2010 -0
  53. package/package.json +33 -4
package/dist/index.js ADDED
@@ -0,0 +1,758 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { ArrowLeft, ArrowRight, Check, ChevronDown, ChevronRight, CircleAlert, CircleCheck, Clock, Copy, ExternalLink, History, Info, LoaderCircle, MessageSquareText, Network, NotepadText, Pencil, Plus, RefreshCw, Search, Send, TriangleAlert, X } from "lucide-react";
3
+ import { useId, useLayoutEffect, useRef, useState } from "react";
4
+ //#region package/src/internal/cx.ts
5
+ /** Joins the class names that are set. */
6
+ function cx(...names) {
7
+ return names.filter((name) => typeof name === "string" && name !== "").join(" ");
8
+ }
9
+ //#endregion
10
+ //#region package/src/components/Icon/Icon.tsx
11
+ function Icon({ icon, size = "md", label, className }) {
12
+ const Glyph = icon.component;
13
+ const naming = label === void 0 ? { "aria-hidden": true } : {
14
+ role: "img",
15
+ "aria-label": label
16
+ };
17
+ return /* @__PURE__ */ jsx(Glyph, {
18
+ className: cx("cpds-icon", `cpds-icon--${size}`, className),
19
+ strokeWidth: 1.75,
20
+ focusable: "false",
21
+ "data-icon": icon.name,
22
+ ...naming
23
+ });
24
+ }
25
+ //#endregion
26
+ //#region package/src/components/Icon/icons.ts
27
+ /**
28
+ * One icon of the design system's set. Only this package creates them, so the set stays closed; each icon is its own
29
+ * export, so a bundle keeps only the icons an interface imports.
30
+ */
31
+ var IconGlyph = class {
32
+ #closedSet = true;
33
+ name;
34
+ component;
35
+ constructor(name, component) {
36
+ this.name = name;
37
+ this.component = component;
38
+ }
39
+ };
40
+ var iconArrowLeft = /* @__PURE__ */ new IconGlyph("arrow-left", ArrowLeft);
41
+ var iconArrowRight = /* @__PURE__ */ new IconGlyph("arrow-right", ArrowRight);
42
+ var iconCheck = /* @__PURE__ */ new IconGlyph("check", Check);
43
+ var iconChevronDown = /* @__PURE__ */ new IconGlyph("chevron-down", ChevronDown);
44
+ var iconChevronRight = /* @__PURE__ */ new IconGlyph("chevron-right", ChevronRight);
45
+ var iconCircleAlert = /* @__PURE__ */ new IconGlyph("circle-alert", CircleAlert);
46
+ var iconCircleCheck = /* @__PURE__ */ new IconGlyph("circle-check", CircleCheck);
47
+ var iconClock = /* @__PURE__ */ new IconGlyph("clock", Clock);
48
+ var iconCopy = /* @__PURE__ */ new IconGlyph("copy", Copy);
49
+ var iconDiagram = /* @__PURE__ */ new IconGlyph("diagram", Network);
50
+ var iconExternalLink = /* @__PURE__ */ new IconGlyph("external-link", ExternalLink);
51
+ var iconHistory = /* @__PURE__ */ new IconGlyph("history", History);
52
+ var iconInfo = /* @__PURE__ */ new IconGlyph("info", Info);
53
+ var iconLoader = /* @__PURE__ */ new IconGlyph("loader", LoaderCircle);
54
+ var iconMessage = /* @__PURE__ */ new IconGlyph("message", MessageSquareText);
55
+ var iconNotepad = /* @__PURE__ */ new IconGlyph("notepad", NotepadText);
56
+ var iconPencil = /* @__PURE__ */ new IconGlyph("pencil", Pencil);
57
+ var iconPlus = /* @__PURE__ */ new IconGlyph("plus", Plus);
58
+ var iconRefresh = /* @__PURE__ */ new IconGlyph("refresh", RefreshCw);
59
+ var iconSearch = /* @__PURE__ */ new IconGlyph("search", Search);
60
+ var iconSend = /* @__PURE__ */ new IconGlyph("send", Send);
61
+ var iconTriangleAlert = /* @__PURE__ */ new IconGlyph("triangle-alert", TriangleAlert);
62
+ var iconX = /* @__PURE__ */ new IconGlyph("x", X);
63
+ //#endregion
64
+ //#region package/src/components/Button/Button.tsx
65
+ function Button({ variant = "secondary", icon, loading = false, type = "button", className, onClick, children, ...rest }) {
66
+ const lead = loading ? /* @__PURE__ */ jsx(Icon, {
67
+ icon: iconLoader,
68
+ className: "cpds-button__spinner"
69
+ }) : icon === void 0 ? null : /* @__PURE__ */ jsx(Icon, { icon });
70
+ const click = (event) => {
71
+ if (loading) {
72
+ event.preventDefault();
73
+ return;
74
+ }
75
+ onClick?.(event);
76
+ };
77
+ return /* @__PURE__ */ jsxs("button", {
78
+ type,
79
+ className: cx("cpds-button", `cpds-button--${variant}`, className),
80
+ "aria-busy": loading || void 0,
81
+ "aria-disabled": loading || rest["aria-disabled"],
82
+ "data-loading": loading || void 0,
83
+ onClick: click,
84
+ ...rest,
85
+ children: [/* @__PURE__ */ jsx("span", {
86
+ className: "cpds-button__lead",
87
+ "data-open": lead !== null || void 0,
88
+ children: /* @__PURE__ */ jsx("span", {
89
+ className: "cpds-button__lead-inner",
90
+ children: lead
91
+ })
92
+ }), /* @__PURE__ */ jsx("span", { children })]
93
+ });
94
+ }
95
+ //#endregion
96
+ //#region package/src/components/IconButton/IconButton.tsx
97
+ function IconButton({ icon, label, variant = "ghost", type = "button", title, className, ...rest }) {
98
+ return /* @__PURE__ */ jsx("button", {
99
+ type,
100
+ "aria-label": label,
101
+ title: title ?? label,
102
+ className: cx("cpds-icon-button", `cpds-icon-button--${variant}`, className),
103
+ ...rest,
104
+ children: /* @__PURE__ */ jsx(Icon, { icon })
105
+ });
106
+ }
107
+ //#endregion
108
+ //#region package/src/components/Link/Link.tsx
109
+ function Link({ variant = "accent", className, children, ...rest }) {
110
+ return /* @__PURE__ */ jsx("a", {
111
+ className: cx("cpds-link", `cpds-link--${variant}`, className),
112
+ ...rest,
113
+ children
114
+ });
115
+ }
116
+ //#endregion
117
+ //#region package/src/components/Field/Field.tsx
118
+ /** The frame shared by the text fields: a label above, the control, then a hint or an error below. */
119
+ function Field({ id, label, hint, error, className, children }) {
120
+ const [previous, setPrevious] = useState(error);
121
+ const [leaving, setLeaving] = useState(void 0);
122
+ if (error !== previous) {
123
+ setPrevious(error);
124
+ setLeaving(error === void 0 ? previous : void 0);
125
+ }
126
+ const isLeaving = error === void 0 && leaving !== void 0;
127
+ const message = isLeaving ? leaving : error;
128
+ const errorBox = useRef(null);
129
+ useLayoutEffect(() => {
130
+ const box = errorBox.current;
131
+ if (isLeaving && (box === null || getComputedStyle(box).animationName === "none")) setLeaving(void 0);
132
+ }, [isLeaving]);
133
+ const hintId = hint === void 0 ? void 0 : `${id}-hint`;
134
+ const errorId = error === void 0 ? void 0 : `${id}-error`;
135
+ const describedBy = [errorId, hintId].filter((value) => value !== void 0).join(" ") || void 0;
136
+ return /* @__PURE__ */ jsxs("div", {
137
+ className: cx("cpds-field", className),
138
+ children: [
139
+ /* @__PURE__ */ jsx("label", {
140
+ className: "cpds-field__label",
141
+ htmlFor: id,
142
+ children: label
143
+ }),
144
+ children({
145
+ id,
146
+ describedBy,
147
+ invalid: error !== void 0
148
+ }),
149
+ message !== void 0 && /* @__PURE__ */ jsxs("p", {
150
+ ref: errorBox,
151
+ className: cx("cpds-field__error", isLeaving && "cpds-field__error--leaving"),
152
+ id: errorId,
153
+ "aria-hidden": isLeaving || void 0,
154
+ onAnimationEnd: (event) => {
155
+ if (isLeaving && event.animationName === "cpds-field-error-out") setLeaving(void 0);
156
+ },
157
+ children: [/* @__PURE__ */ jsx(Icon, {
158
+ icon: iconCircleAlert,
159
+ size: "sm"
160
+ }), /* @__PURE__ */ jsx("span", { children: message })]
161
+ }),
162
+ hint !== void 0 && /* @__PURE__ */ jsx("p", {
163
+ className: "cpds-field__hint",
164
+ id: hintId,
165
+ children: hint
166
+ })
167
+ ]
168
+ });
169
+ }
170
+ //#endregion
171
+ //#region package/src/components/TextField/TextField.tsx
172
+ function TextField({ label, hint, error, className, id, type = "text", ...rest }) {
173
+ const generated = useId();
174
+ return /* @__PURE__ */ jsx(Field, {
175
+ id: id ?? generated,
176
+ label,
177
+ hint,
178
+ error,
179
+ className,
180
+ children: (control) => /* @__PURE__ */ jsx("input", {
181
+ ...rest,
182
+ id: control.id,
183
+ type,
184
+ className: "cpds-input",
185
+ "aria-invalid": control.invalid || void 0,
186
+ "aria-describedby": control.describedBy
187
+ })
188
+ });
189
+ }
190
+ //#endregion
191
+ //#region package/src/components/TextArea/TextArea.tsx
192
+ function TextArea({ label, hint, error, className, id, rows = 3, ...rest }) {
193
+ const generated = useId();
194
+ return /* @__PURE__ */ jsx(Field, {
195
+ id: id ?? generated,
196
+ label,
197
+ hint,
198
+ error,
199
+ className,
200
+ children: (control) => /* @__PURE__ */ jsx("textarea", {
201
+ ...rest,
202
+ id: control.id,
203
+ rows,
204
+ className: "cpds-input",
205
+ "aria-invalid": control.invalid || void 0,
206
+ "aria-describedby": control.describedBy
207
+ })
208
+ });
209
+ }
210
+ //#endregion
211
+ //#region package/src/components/Radio/Choice.tsx
212
+ /** A radio button or a checkbox with its label, the whole row being the touch target. */
213
+ function Choice({ type, label, description, className, ...rest }) {
214
+ return /* @__PURE__ */ jsxs("label", {
215
+ className: cx("cpds-choice", className),
216
+ children: [/* @__PURE__ */ jsx("input", {
217
+ ...rest,
218
+ type,
219
+ className: "cpds-choice__input"
220
+ }), /* @__PURE__ */ jsxs("span", {
221
+ className: "cpds-choice__text",
222
+ children: [/* @__PURE__ */ jsx("span", {
223
+ className: "cpds-choice__label",
224
+ children: label
225
+ }), description !== void 0 && /* @__PURE__ */ jsx("span", {
226
+ className: "cpds-choice__description",
227
+ children: description
228
+ })]
229
+ })]
230
+ });
231
+ }
232
+ //#endregion
233
+ //#region package/src/components/Radio/Radio.tsx
234
+ function Radio(props) {
235
+ return /* @__PURE__ */ jsx(Choice, {
236
+ ...props,
237
+ type: "radio"
238
+ });
239
+ }
240
+ //#endregion
241
+ //#region package/src/components/Checkbox/Checkbox.tsx
242
+ function Checkbox(props) {
243
+ return /* @__PURE__ */ jsx(Choice, {
244
+ ...props,
245
+ type: "checkbox"
246
+ });
247
+ }
248
+ //#endregion
249
+ //#region package/src/components/Card/Card.tsx
250
+ function Card({ variant = "default", inset = "lg", as: Tag = "div", className, children, ...rest }) {
251
+ return /* @__PURE__ */ jsx(Tag, {
252
+ className: cx("cpds-card", `cpds-card--${variant}`, `cpds-card--inset-${inset}`, className),
253
+ ...rest,
254
+ children
255
+ });
256
+ }
257
+ //#endregion
258
+ //#region package/src/internal/useTonePulse.ts
259
+ /**
260
+ * The class that restarts a one-off pulse each time `tone` changes, none before the first change.
261
+ * Two identical keyframes alternate, so that the pulse restarts without remounting the element.
262
+ */
263
+ function useTonePulse(tone) {
264
+ const [seen, setSeen] = useState({
265
+ tone,
266
+ changes: 0
267
+ });
268
+ if (seen.tone !== tone) setSeen({
269
+ tone,
270
+ changes: seen.changes + 1
271
+ });
272
+ if (seen.changes === 0) return void 0;
273
+ return seen.changes % 2 === 1 ? "cpds-pulse-a" : "cpds-pulse-b";
274
+ }
275
+ //#endregion
276
+ //#region package/src/components/Badge/Badge.tsx
277
+ /** A small label attached to an item, such as "Recommended" or "Revised". */
278
+ function Badge({ tone = "neutral", className, children, ...rest }) {
279
+ const pulse = useTonePulse(tone);
280
+ return /* @__PURE__ */ jsx("span", {
281
+ className: cx("cpds-badge", `cpds-tone--${tone}`, pulse, className),
282
+ ...rest,
283
+ children
284
+ });
285
+ }
286
+ //#endregion
287
+ //#region package/src/components/StatusBadge/StatusBadge.tsx
288
+ /** The status of an item or of a view, such as "Waiting for you" or "Confirmed". */
289
+ function StatusBadge({ tone, className, children, ...rest }) {
290
+ const pulse = useTonePulse(tone);
291
+ return /* @__PURE__ */ jsx("span", {
292
+ className: cx("cpds-status-badge", `cpds-tone--${tone}`, pulse, className),
293
+ ...rest,
294
+ children
295
+ });
296
+ }
297
+ //#endregion
298
+ //#region package/src/components/CollapsibleRow/CollapsibleRow.tsx
299
+ /** A row that shows or hides its content, collapsed by default. */
300
+ function CollapsibleRow({ title, leading, meta, variant = "card", selected = false, expanded, defaultExpanded = false, onExpandedChange, className, children }) {
301
+ const [own, setOwn] = useState(defaultExpanded);
302
+ const open = expanded ?? own;
303
+ const contentId = useId();
304
+ const toggle = () => {
305
+ setOwn(!open);
306
+ onExpandedChange?.(!open);
307
+ };
308
+ const sliding = variant === "row";
309
+ return /* @__PURE__ */ jsxs("div", {
310
+ className: cx("cpds-collapsible", `cpds-collapsible--${variant}`, className),
311
+ "data-expanded": open,
312
+ "data-selected": selected || void 0,
313
+ "aria-current": selected || void 0,
314
+ children: [/* @__PURE__ */ jsxs("button", {
315
+ type: "button",
316
+ className: "cpds-collapsible__trigger",
317
+ "aria-expanded": open,
318
+ "aria-controls": contentId,
319
+ onClick: toggle,
320
+ children: [
321
+ /* @__PURE__ */ jsx(Icon, {
322
+ icon: iconChevronRight,
323
+ size: "sm",
324
+ className: "cpds-collapsible__chevron"
325
+ }),
326
+ leading !== void 0 && /* @__PURE__ */ jsx("span", {
327
+ className: "cpds-collapsible__leading",
328
+ children: leading
329
+ }),
330
+ /* @__PURE__ */ jsx("span", {
331
+ className: "cpds-collapsible__title",
332
+ children: title
333
+ }),
334
+ meta !== void 0 && /* @__PURE__ */ jsx("span", {
335
+ className: "cpds-collapsible__meta",
336
+ children: meta
337
+ })
338
+ ]
339
+ }), sliding ? /* @__PURE__ */ jsx("div", {
340
+ id: contentId,
341
+ className: "cpds-collapsible__content",
342
+ inert: !open,
343
+ children: /* @__PURE__ */ jsx("div", {
344
+ className: "cpds-collapsible__inner",
345
+ children
346
+ })
347
+ }) : /* @__PURE__ */ jsx("div", {
348
+ id: contentId,
349
+ className: "cpds-collapsible__content",
350
+ hidden: !open,
351
+ children
352
+ })]
353
+ });
354
+ }
355
+ //#endregion
356
+ //#region package/src/components/LiveIndicator/LiveIndicator.tsx
357
+ var defaultLabels = {
358
+ live: "Live",
359
+ offline: "Offline"
360
+ };
361
+ /** Whether the page is receiving live updates: a dot and a word. */
362
+ function LiveIndicator({ connection, label, className }) {
363
+ return /* @__PURE__ */ jsxs("span", {
364
+ className: cx("cpds-live", `cpds-live--${connection}`, className),
365
+ role: "status",
366
+ children: [/* @__PURE__ */ jsx("span", {
367
+ className: "cpds-live__dot",
368
+ "aria-hidden": "true"
369
+ }), label ?? defaultLabels[connection]]
370
+ });
371
+ }
372
+ //#endregion
373
+ //#region package/src/components/AppHeader/AppHeader.tsx
374
+ /** The bar at the top of an interface: its name, the breadcrumb, the live indicator and a few actions. */
375
+ function AppHeader({ title, icon, breadcrumb, connection, actions, className }) {
376
+ return /* @__PURE__ */ jsxs("header", {
377
+ className: cx("cpds-app-header", className),
378
+ children: [
379
+ /* @__PURE__ */ jsxs("div", {
380
+ className: "cpds-app-header__title",
381
+ children: [icon !== void 0 && /* @__PURE__ */ jsx(Icon, {
382
+ icon,
383
+ size: "lg"
384
+ }), /* @__PURE__ */ jsx("span", { children: title })]
385
+ }),
386
+ breadcrumb !== void 0 && breadcrumb.length > 0 && /* @__PURE__ */ jsx("nav", {
387
+ "aria-label": "Breadcrumb",
388
+ className: "cpds-app-header__breadcrumb",
389
+ children: /* @__PURE__ */ jsx("ol", { children: breadcrumb.map((item, index) => {
390
+ const current = index === breadcrumb.length - 1;
391
+ return /* @__PURE__ */ jsxs("li", { children: [index > 0 && /* @__PURE__ */ jsx("span", {
392
+ "aria-hidden": "true",
393
+ className: "cpds-app-header__separator",
394
+ children: "/"
395
+ }), item.href !== void 0 && !current ? /* @__PURE__ */ jsx(Link, {
396
+ href: item.href,
397
+ variant: "muted",
398
+ children: item.label
399
+ }) : /* @__PURE__ */ jsx("span", {
400
+ "aria-current": current ? "page" : void 0,
401
+ className: "cpds-app-header__current",
402
+ children: item.label
403
+ })] }, `${String(index)}-${item.label}`);
404
+ }) })
405
+ }),
406
+ (connection !== void 0 || actions !== void 0) && /* @__PURE__ */ jsxs("div", {
407
+ className: "cpds-app-header__end",
408
+ children: [connection !== void 0 && /* @__PURE__ */ jsx(LiveIndicator, { connection }), actions]
409
+ })
410
+ ]
411
+ });
412
+ }
413
+ //#endregion
414
+ //#region package/src/components/Banner/Banner.tsx
415
+ var toneIcons = {
416
+ neutral: iconInfo,
417
+ info: iconInfo,
418
+ waiting: iconClock,
419
+ success: iconCircleCheck,
420
+ danger: iconCircleAlert
421
+ };
422
+ /** A message about the state of a view or an item, announced politely to assistive technologies. */
423
+ function Banner({ variant = "info", tone = "info", icon, title, actions, onDismiss, dismissLabel = "Dismiss", className, children }) {
424
+ const [leaving, setLeaving] = useState(false);
425
+ const root = useRef(null);
426
+ useLayoutEffect(() => {
427
+ if (!leaving || root.current === null) return;
428
+ if (getComputedStyle(root.current).animationName === "none") onDismiss?.();
429
+ }, [leaving, onDismiss]);
430
+ const controls = variant === "info" && (actions !== void 0 || onDismiss !== void 0);
431
+ const message = /* @__PURE__ */ jsxs(Fragment, { children: [
432
+ title !== void 0 && /* @__PURE__ */ jsx("strong", {
433
+ className: "cpds-banner__title",
434
+ children: title
435
+ }),
436
+ title !== void 0 && " ",
437
+ children
438
+ ] });
439
+ return /* @__PURE__ */ jsxs("div", {
440
+ ref: root,
441
+ "data-leaving": leaving ? "" : void 0,
442
+ onAnimationEnd: (event) => {
443
+ if (leaving && event.target === event.currentTarget && event.animationName === "cpds-banner-collapse") onDismiss?.();
444
+ },
445
+ role: controls ? void 0 : "status",
446
+ className: cx("cpds-banner", `cpds-banner--${variant}`, `cpds-banner-tone--${tone}`, variant === "info" && `cpds-tone--${tone}`, controls && "cpds-banner--with-controls", className),
447
+ children: [
448
+ /* @__PURE__ */ jsx(Icon, {
449
+ icon: icon ?? toneIcons[tone],
450
+ size: variant === "status" ? "sm" : "md"
451
+ }),
452
+ /* @__PURE__ */ jsx("span", {
453
+ role: controls ? "status" : void 0,
454
+ className: "cpds-banner__message",
455
+ children: message
456
+ }),
457
+ controls && /* @__PURE__ */ jsxs("span", {
458
+ className: "cpds-banner__controls",
459
+ children: [actions, onDismiss !== void 0 && /* @__PURE__ */ jsx(IconButton, {
460
+ icon: iconX,
461
+ label: dismissLabel,
462
+ variant: "ghost",
463
+ onClick: () => {
464
+ setLeaving(true);
465
+ }
466
+ })]
467
+ })
468
+ ]
469
+ });
470
+ }
471
+ //#endregion
472
+ //#region package/src/components/Figure/Figure.tsx
473
+ /** A frame around a visual, with an optional caption. */
474
+ function Figure({ caption, className, children }) {
475
+ const captionId = useId();
476
+ return /* @__PURE__ */ jsxs("figure", {
477
+ className: cx("cpds-figure", className),
478
+ "aria-labelledby": caption === void 0 ? void 0 : captionId,
479
+ children: [/* @__PURE__ */ jsx("div", {
480
+ className: "cpds-figure__content",
481
+ children
482
+ }), caption !== void 0 && /* @__PURE__ */ jsx("figcaption", {
483
+ id: captionId,
484
+ className: "cpds-figure__caption",
485
+ children: caption
486
+ })]
487
+ });
488
+ }
489
+ //#endregion
490
+ //#region package/src/components/Prose/Prose.tsx
491
+ /** Styles rendered rich text, such as the output of a Markdown renderer, with the design system's tokens. */
492
+ function Prose({ density = "block", className, children, ...rest }) {
493
+ return /* @__PURE__ */ jsx(density === "inline" ? "span" : "div", {
494
+ className: cx("cpds-prose", `cpds-prose--${density}`, className),
495
+ ...rest,
496
+ children
497
+ });
498
+ }
499
+ //#endregion
500
+ //#region package/src/components/VisuallyHidden/VisuallyHidden.tsx
501
+ /** Text read by assistive technologies and never drawn, such as the full name of a compact item. */
502
+ function VisuallyHidden({ className, children }) {
503
+ return /* @__PURE__ */ jsx("span", {
504
+ className: cx("cpds-visually-hidden", className),
505
+ children
506
+ });
507
+ }
508
+ //#endregion
509
+ //#region package/src/components/StatusDot/StatusDot.tsx
510
+ /** A small dot in the tone of a state, filled for an active state, outlined for one that has not started. */
511
+ function StatusDot({ status, label, className }) {
512
+ const pulse = useTonePulse(status);
513
+ return /* @__PURE__ */ jsx("span", {
514
+ className: cx("cpds-status-dot", `cpds-status-dot--${status}`, pulse, className),
515
+ "aria-hidden": label === void 0 ? true : void 0,
516
+ children: label !== void 0 && /* @__PURE__ */ jsx(VisuallyHidden, { children: label })
517
+ });
518
+ }
519
+ //#endregion
520
+ //#region package/src/components/ProgressBar/ProgressBar.tsx
521
+ /** How far a task has gone: a short bar, filled in the running tone, in the success tone once complete. */
522
+ function ProgressBar({ value, max, label, valueText, className }) {
523
+ const ratio = max > 0 ? Math.min(Math.max(value / max, 0), 1) : 0;
524
+ const complete = max > 0 && value >= max;
525
+ return /* @__PURE__ */ jsxs("span", {
526
+ className: cx("cpds-progress", className),
527
+ "data-complete": complete || void 0,
528
+ children: [/* @__PURE__ */ jsx("span", {
529
+ className: "cpds-progress__track",
530
+ role: "progressbar",
531
+ "aria-label": label,
532
+ "aria-valuemin": 0,
533
+ "aria-valuemax": max,
534
+ "aria-valuenow": value,
535
+ style: { "--cpds-progress-ratio": ratio },
536
+ children: /* @__PURE__ */ jsx("span", { className: "cpds-progress__fill" })
537
+ }), valueText !== void 0 && /* @__PURE__ */ jsx("span", {
538
+ className: "cpds-progress__text",
539
+ children: valueText
540
+ })]
541
+ });
542
+ }
543
+ //#endregion
544
+ //#region package/src/components/FilterChip/FilterChip.tsx
545
+ /** A filter the user turns on or off: outlined while off, filled in its tone while on. */
546
+ function FilterChip({ pressed, onPressedChange, tone = "accent", count, type = "button", className, children, ...rest }) {
547
+ return /* @__PURE__ */ jsxs("button", {
548
+ type,
549
+ "aria-pressed": pressed,
550
+ className: cx("cpds-filter-chip", pressed && `cpds-tone--${tone}`, className),
551
+ onClick: () => {
552
+ onPressedChange(!pressed);
553
+ },
554
+ ...rest,
555
+ children: [children, count !== void 0 && /* @__PURE__ */ jsx("span", {
556
+ className: "cpds-filter-chip__count",
557
+ children: count
558
+ })]
559
+ });
560
+ }
561
+ //#endregion
562
+ //#region package/src/internal/useIndicator.ts
563
+ /**
564
+ * Measures the element of `container` that matches `selector` and writes its box on the container as the custom
565
+ * properties --cpds-indicator-x, -y, -w and -h, so that one block drawn by the container can sit behind it.
566
+ * The container must be the offset parent of the element. It gets `data-indicator-ready` one frame after its first
567
+ * measure, so that the block is placed at once on the first render and slides only afterwards. A change of width
568
+ * measures again.
569
+ */
570
+ function useIndicator(container, selector, dependency) {
571
+ const ready = useRef(false);
572
+ useLayoutEffect(() => {
573
+ const host = container.current;
574
+ if (host === null) return;
575
+ let frame = 0;
576
+ const measure = () => {
577
+ const target = host.querySelector(selector);
578
+ if (target === null) return;
579
+ host.style.setProperty("--cpds-indicator-x", `${String(target.offsetLeft)}px`);
580
+ host.style.setProperty("--cpds-indicator-y", `${String(target.offsetTop)}px`);
581
+ host.style.setProperty("--cpds-indicator-w", `${String(target.offsetWidth)}px`);
582
+ host.style.setProperty("--cpds-indicator-h", `${String(target.offsetHeight)}px`);
583
+ if (!ready.current && frame === 0) frame = requestAnimationFrame(() => {
584
+ ready.current = true;
585
+ host.dataset["indicatorReady"] = "";
586
+ });
587
+ };
588
+ measure();
589
+ const observer = new ResizeObserver(measure);
590
+ observer.observe(host);
591
+ return () => {
592
+ cancelAnimationFrame(frame);
593
+ observer.disconnect();
594
+ };
595
+ }, [
596
+ container,
597
+ selector,
598
+ dependency
599
+ ]);
600
+ }
601
+ //#endregion
602
+ //#region package/src/components/SegmentedControl/SegmentedControl.tsx
603
+ /** A choice between a few views, side by side in one track, the selected one filled; no option changes size. */
604
+ function SegmentedControl({ options, value, onChange, label, fullWidth = false, className }) {
605
+ const group = useRef(null);
606
+ useIndicator(group, ".cpds-segmented__option[aria-pressed='true']", value);
607
+ return /* @__PURE__ */ jsx("div", {
608
+ ref: group,
609
+ role: "group",
610
+ "aria-label": label,
611
+ className: cx("cpds-segmented", fullWidth && "cpds-segmented--full-width", className),
612
+ children: options.map((option) => /* @__PURE__ */ jsx("button", {
613
+ type: "button",
614
+ className: "cpds-segmented__option",
615
+ "aria-pressed": option.id === value,
616
+ onClick: () => {
617
+ onChange(option.id);
618
+ },
619
+ children: option.label
620
+ }, option.id))
621
+ });
622
+ }
623
+ //#endregion
624
+ //#region package/src/components/Tabs/Tabs.tsx
625
+ /**
626
+ * Tabs sharing the full width over panels drawn in one grid cell: only the selected panel shows, the others stay laid
627
+ * out but hidden and inert, so the cell keeps the tallest panel's height and switching moves nothing below.
628
+ */
629
+ function Tabs({ tabs, value, onChange, label, panels, className }) {
630
+ const prefix = useId();
631
+ const list = useRef(null);
632
+ useIndicator(list, ".cpds-tabs__tab[aria-selected=\"true\"]", value);
633
+ const move = (event, index) => {
634
+ const last = tabs.length - 1;
635
+ const target = {
636
+ ArrowRight: index === last ? 0 : index + 1,
637
+ ArrowLeft: index === 0 ? last : index - 1,
638
+ Home: 0,
639
+ End: last
640
+ }[event.key];
641
+ const next = target === void 0 ? void 0 : tabs[target];
642
+ if (next === void 0) return;
643
+ event.preventDefault();
644
+ onChange(next.id);
645
+ list.current?.querySelector(`#${CSS.escape(`${prefix}-tab-${next.id}`)}`)?.focus();
646
+ };
647
+ return /* @__PURE__ */ jsxs("div", {
648
+ className: cx("cpds-tabs", className),
649
+ children: [/* @__PURE__ */ jsx("div", {
650
+ ref: list,
651
+ role: "tablist",
652
+ "aria-label": label,
653
+ className: "cpds-tabs__list",
654
+ children: tabs.map((tab, index) => /* @__PURE__ */ jsx("button", {
655
+ type: "button",
656
+ role: "tab",
657
+ id: `${prefix}-tab-${tab.id}`,
658
+ className: "cpds-tabs__tab",
659
+ "aria-selected": tab.id === value,
660
+ "aria-controls": `${prefix}-panel-${tab.id}`,
661
+ tabIndex: tab.id === value ? 0 : -1,
662
+ onClick: () => {
663
+ onChange(tab.id);
664
+ },
665
+ onKeyDown: (event) => {
666
+ move(event, index);
667
+ },
668
+ children: tab.label
669
+ }, tab.id))
670
+ }), /* @__PURE__ */ jsx("div", {
671
+ className: "cpds-tabs__panels",
672
+ children: tabs.map((tab) => /* @__PURE__ */ jsx("div", {
673
+ role: "tabpanel",
674
+ id: `${prefix}-panel-${tab.id}`,
675
+ "aria-labelledby": `${prefix}-tab-${tab.id}`,
676
+ className: "cpds-tabs__panel",
677
+ "data-active": tab.id === value || void 0,
678
+ inert: tab.id !== value,
679
+ children: panels[tab.id]
680
+ }, tab.id))
681
+ })]
682
+ });
683
+ }
684
+ //#endregion
685
+ //#region package/src/components/ScrollArea/ScrollArea.tsx
686
+ /** A region that scrolls its content within itself, with thin scrollbars, reachable and scrollable by keyboard. */
687
+ function ScrollArea({ label, axis = "vertical", className, children }) {
688
+ return /* @__PURE__ */ jsx("div", {
689
+ role: "region",
690
+ "aria-label": label,
691
+ tabIndex: 0,
692
+ className: cx("cpds-scroll-area", `cpds-scroll-area--${axis}`, className),
693
+ children
694
+ });
695
+ }
696
+ //#endregion
697
+ //#region package/src/components/PillButton/PillButton.tsx
698
+ /** A compact rounded button for a small count or a short action, such as "+2" or "3 hidden". */
699
+ function PillButton({ tone = "neutral", variant = "tinted", icon, type = "button", className, children, ...rest }) {
700
+ return /* @__PURE__ */ jsxs("button", {
701
+ type,
702
+ className: cx("cpds-pill-button", `cpds-pill-button--${variant}`, `cpds-pill-button-tone--${tone}`, variant === "tinted" && `cpds-tone--${tone}`, className),
703
+ ...rest,
704
+ children: [icon !== void 0 && /* @__PURE__ */ jsx(Icon, {
705
+ icon,
706
+ size: "sm"
707
+ }), children]
708
+ });
709
+ }
710
+ //#endregion
711
+ //#region package/src/components/ChangeBar/ChangeBar.tsx
712
+ /** The share of lines added and removed, as a row of cells; decorative, so the counts must be given as text too. */
713
+ function ChangeBar({ added, removed, cells = 5, className }) {
714
+ const total = added + removed;
715
+ const red = removed > 0 ? Math.max(1, Math.round(removed / total * cells)) : 0;
716
+ const green = added > 0 ? Math.max(1, cells - red) : 0;
717
+ const removedCells = Math.min(red, cells - green);
718
+ return /* @__PURE__ */ jsx("span", {
719
+ className: cx("cpds-change-bar", className),
720
+ "aria-hidden": "true",
721
+ children: Array.from({ length: cells }, (_, index) => /* @__PURE__ */ jsx("span", {
722
+ className: "cpds-change-bar__cell",
723
+ "data-change": index < green ? "added" : index < green + removedCells ? "removed" : void 0
724
+ }, index))
725
+ });
726
+ }
727
+ //#endregion
728
+ //#region package/src/components/TruncatedPath/TruncatedPath.tsx
729
+ /** A file path on one line, shortened in its middle: the directory gives way first, the file name stays whole. */
730
+ function TruncatedPath({ path, className }) {
731
+ const slash = path.lastIndexOf("/");
732
+ const directory = path.slice(0, slash + 1);
733
+ const name = path.slice(slash + 1);
734
+ return /* @__PURE__ */ jsxs("span", {
735
+ className: cx("cpds-truncated-path", className),
736
+ title: path,
737
+ children: [directory !== "" && /* @__PURE__ */ jsx("span", {
738
+ className: "cpds-truncated-path__directory",
739
+ children: directory
740
+ }), /* @__PURE__ */ jsx("span", {
741
+ className: "cpds-truncated-path__name",
742
+ children: name
743
+ })]
744
+ });
745
+ }
746
+ //#endregion
747
+ //#region package/src/breakpoints.ts
748
+ /**
749
+ * The widths in CSS pixels where a layout changes, the same as the --breakpoint-medium and --breakpoint-wide tokens.
750
+ * Custom properties cannot drive a media or a container query, so a layout reads these numbers instead: narrow below
751
+ * medium, medium from medium to below wide, wide from wide up.
752
+ */
753
+ var breakpoints = {
754
+ medium: 720,
755
+ wide: 1200
756
+ };
757
+ //#endregion
758
+ export { AppHeader, Badge, Banner, Button, Card, ChangeBar, Checkbox, CollapsibleRow, Figure, FilterChip, Icon, IconButton, Link, LiveIndicator, PillButton, ProgressBar, Prose, Radio, ScrollArea, SegmentedControl, StatusBadge, StatusDot, Tabs, TextArea, TextField, TruncatedPath, VisuallyHidden, breakpoints, iconArrowLeft, iconArrowRight, iconCheck, iconChevronDown, iconChevronRight, iconCircleAlert, iconCircleCheck, iconClock, iconCopy, iconDiagram, iconExternalLink, iconHistory, iconInfo, iconLoader, iconMessage, iconNotepad, iconPencil, iconPlus, iconRefresh, iconSearch, iconSend, iconTriangleAlert, iconX };