@orbitcommerce/constellation-docs 0.0.0-stage → 1.0.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 (62) hide show
  1. package/LICENSE.md +6 -0
  2. package/README.md +6 -2
  3. package/dist/docs.css +8260 -0
  4. package/dist/index.d.ts +33 -0
  5. package/dist/index.js +308 -0
  6. package/dist/pages/Playground-CNbBbErC.js +129 -0
  7. package/dist/pages/_figures-data-BDmScEny.js +606 -0
  8. package/dist/pages/_foundations-blXWyYh8.js +30 -0
  9. package/dist/pages/_overlays-specimens-Dpn6oiyH.js +310 -0
  10. package/dist/pages/alert-BD4e6QTh.js +769 -0
  11. package/dist/pages/app-shell-KbA-nRqZ.js +1479 -0
  12. package/dist/pages/area-chart-B91dLcGo.js +562 -0
  13. package/dist/pages/avatar-DPPHXJAu.js +713 -0
  14. package/dist/pages/badge-C9JR0thI.js +729 -0
  15. package/dist/pages/button-D3V912P4.js +518 -0
  16. package/dist/pages/calendar-DSDZ9nRH.js +630 -0
  17. package/dist/pages/card-DUggbis3.js +659 -0
  18. package/dist/pages/checkbox-DwimQaK3.js +365 -0
  19. package/dist/pages/colour-BwuO8xAv.js +1498 -0
  20. package/dist/pages/command-palette-xAD7fOg6.js +1243 -0
  21. package/dist/pages/date-picker-BYSa816m.js +1421 -0
  22. package/dist/pages/delta-CtAo0eIM.js +574 -0
  23. package/dist/pages/dialog-BRAf4LMh.js +1451 -0
  24. package/dist/pages/docs-BNOb7AqR.js +515 -0
  25. package/dist/pages/empty-state-C-mLrXW2.js +417 -0
  26. package/dist/pages/figure-tabs-CoPFzzKz.js +460 -0
  27. package/dist/pages/home-dashboard-CFQwDtC9.js +959 -0
  28. package/dist/pages/host-B6znjEgQ.js +109 -0
  29. package/dist/pages/icon-button-C9eSVPPW.js +861 -0
  30. package/dist/pages/icons-sxkTs5Ob.js +473 -0
  31. package/dist/pages/input-KF9Gkawf.js +1093 -0
  32. package/dist/pages/installation-DpsX8G_n.js +445 -0
  33. package/dist/pages/kbd-cNfDoikz.js +544 -0
  34. package/dist/pages/live-globe-ClvLn9Lb.js +571 -0
  35. package/dist/pages/logo-BfGF1Pq9.js +571 -0
  36. package/dist/pages/menu-by2sgQ09.js +1618 -0
  37. package/dist/pages/motion-BvTGc2Dk.js +855 -0
  38. package/dist/pages/orbit-spinner-Dil1Z3Oy.js +332 -0
  39. package/dist/pages/overview-BPEbZQ6g.js +130 -0
  40. package/dist/pages/pagination-BBUnGvv5.js +249 -0
  41. package/dist/pages/popover-Db1gLDpb.js +1136 -0
  42. package/dist/pages/principles-CeAIOIdt.js +483 -0
  43. package/dist/pages/radio-group-CkdBWWfG.js +1077 -0
  44. package/dist/pages/registry-CroHzK9I.js +244 -0
  45. package/dist/pages/release-Dvo684UJ.js +13 -0
  46. package/dist/pages/rolling-number-qmvH84Mq.js +529 -0
  47. package/dist/pages/search-field-BN7MWGQ4.js +693 -0
  48. package/dist/pages/segmented-control-CTbIpRBW.js +777 -0
  49. package/dist/pages/select-DguELoRR.js +1429 -0
  50. package/dist/pages/separator-CPZub9pv.js +351 -0
  51. package/dist/pages/shape-DKvA0YKr.js +627 -0
  52. package/dist/pages/skeleton-DLuBhP46.js +561 -0
  53. package/dist/pages/sparkline-DMMYGbHn.js +668 -0
  54. package/dist/pages/switch-B-Qe4kcT.js +517 -0
  55. package/dist/pages/table-AMoODng4.js +607 -0
  56. package/dist/pages/tabs-B4M-usCV.js +1455 -0
  57. package/dist/pages/textarea-fTuUZRQb.js +693 -0
  58. package/dist/pages/toast-CKP03zjy.js +1176 -0
  59. package/dist/pages/tooltip-CBYil3kt.js +697 -0
  60. package/dist/pages/typography-PCbg8Bhg.js +735 -0
  61. package/manifest.json +3125 -0
  62. package/package.json +35 -4
@@ -0,0 +1,460 @@
1
+ "use client";
2
+ import { t as DocLink } from "./host-B6znjEgQ.js";
3
+ import { a as DocTable, d as Section, i as DocPage, l as Note, m as ThemePair, o as Example, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-BNOb7AqR.js";
4
+ import { l as figuresFor, r as PerformanceStrip } from "./_figures-data-BDmScEny.js";
5
+ import { useMemo, useState } from "react";
6
+ import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
+ import { Card, Delta, FigureTabs, SegmentedControl } from "@orbitcommerce/constellation";
8
+ //#region src/pages/components/figure-tabs.tsx
9
+ var MONTH = figuresFor("30");
10
+ var itemsFrom = (hint) => MONTH.map((f) => ({
11
+ key: f.key,
12
+ label: f.label,
13
+ value: f.format(f.key === "conversion" ? f.amount * 100 : f.amount),
14
+ change: /* @__PURE__ */ jsx(Delta, {
15
+ value: f.change,
16
+ size: "sm"
17
+ }),
18
+ hint
19
+ }));
20
+ function Preview() {
21
+ return /* @__PURE__ */ jsx(FigureTabs, {
22
+ "aria-label": "Headline figures",
23
+ value: "sales",
24
+ onValueChange: () => {},
25
+ style: {
26
+ gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
27
+ width: 236
28
+ },
29
+ items: [{
30
+ key: "sales",
31
+ label: "Sales",
32
+ value: "£2,950",
33
+ change: /* @__PURE__ */ jsx(Delta, {
34
+ value: 2.8,
35
+ size: "sm"
36
+ })
37
+ }, {
38
+ key: "orders",
39
+ label: "Orders",
40
+ value: "23",
41
+ change: /* @__PURE__ */ jsx(Delta, {
42
+ value: -4.2,
43
+ size: "sm"
44
+ })
45
+ }]
46
+ });
47
+ }
48
+ function DefaultDemo() {
49
+ const [selected, setSelected] = useState("sales");
50
+ const items = useMemo(() => itemsFrom("vs previous 30 days"), []);
51
+ return /* @__PURE__ */ jsxs("div", {
52
+ className: "figure-tabs-demo",
53
+ children: [/* @__PURE__ */ jsx(FigureTabs, {
54
+ "aria-label": "Headline figures",
55
+ value: selected,
56
+ onValueChange: setSelected,
57
+ items
58
+ }), /* @__PURE__ */ jsxs("p", {
59
+ className: "figure-tabs-demo__readout",
60
+ children: [
61
+ "The chart below this row would now show",
62
+ " ",
63
+ /* @__PURE__ */ jsx("strong", { children: MONTH.find((f) => f.key === selected)?.label.toLowerCase() }),
64
+ "."
65
+ ]
66
+ })]
67
+ });
68
+ }
69
+ function CompactDemo() {
70
+ const [selected, setSelected] = useState("sales");
71
+ const items = useMemo(() => itemsFrom(), []);
72
+ return /* @__PURE__ */ jsx(FigureTabs, {
73
+ variant: "compact",
74
+ "aria-label": "Headline figures",
75
+ value: selected,
76
+ onValueChange: setSelected,
77
+ items
78
+ });
79
+ }
80
+ function LoadingDemo() {
81
+ const [state, setState] = useState("loading");
82
+ const [selected, setSelected] = useState("sales");
83
+ const items = useMemo(() => itemsFrom("vs previous 30 days"), []);
84
+ return /* @__PURE__ */ jsxs("div", {
85
+ className: "figure-tabs-demo",
86
+ children: [
87
+ /* @__PURE__ */ jsx(SegmentedControl, {
88
+ "aria-label": "Figures",
89
+ size: "sm",
90
+ value: state,
91
+ onValueChange: setState,
92
+ options: [{
93
+ value: "loading",
94
+ label: "Loading"
95
+ }, {
96
+ value: "loaded",
97
+ label: "Loaded"
98
+ }]
99
+ }),
100
+ /* @__PURE__ */ jsx(FigureTabs, {
101
+ "aria-label": "Headline figures",
102
+ value: selected,
103
+ onValueChange: setSelected,
104
+ loading: state === "loading",
105
+ items
106
+ }),
107
+ /* @__PURE__ */ jsx(FigureTabs, {
108
+ variant: "compact",
109
+ "aria-label": "Headline figures, compact",
110
+ value: selected,
111
+ onValueChange: setSelected,
112
+ loading: state === "loading",
113
+ items: items.map(({ hint: _hint, ...item }) => item)
114
+ })
115
+ ]
116
+ });
117
+ }
118
+ function PairSpecimen() {
119
+ const [selected, setSelected] = useState("sales");
120
+ const items = useMemo(() => itemsFrom().slice(0, 2), []);
121
+ return /* @__PURE__ */ jsxs("div", {
122
+ className: "figure-tabs-pair",
123
+ children: [/* @__PURE__ */ jsx(FigureTabs, {
124
+ "aria-label": "Headline figures",
125
+ value: selected,
126
+ onValueChange: setSelected,
127
+ items
128
+ }), /* @__PURE__ */ jsx(FigureTabs, {
129
+ variant: "compact",
130
+ "aria-label": "Headline figures, compact",
131
+ value: selected,
132
+ onValueChange: setSelected,
133
+ items
134
+ })]
135
+ });
136
+ }
137
+ function Page() {
138
+ return /* @__PURE__ */ jsxs(DocPage, {
139
+ title: "Figure tabs",
140
+ status: "new",
141
+ importNames: ["FigureTabs"],
142
+ lead: "Headline figures that double as the tabs of the chart beneath them. Each figure is a label, a value and how it moved; the one that is selected wears a teal line, which glides to the next when you pick it. Reach for them above a chart, in place of a row of stat cards.",
143
+ children: [
144
+ /* @__PURE__ */ jsx(Section, {
145
+ id: "default",
146
+ title: "Default",
147
+ description: /* @__PURE__ */ jsxs("p", { children: [
148
+ "Figures sit straight on the surface, divided by hairlines, with a hairline under the row. Each has a label, a value in Sora, a change (usually a ",
149
+ /* @__PURE__ */ jsx(DocLink, {
150
+ to: "/components/delta",
151
+ children: "Delta"
152
+ }),
153
+ ") and an optional quiet hint. Pick one: the teal line glides to it on a spring."
154
+ ] }),
155
+ children: /* @__PURE__ */ jsx(Example, {
156
+ clientOnly: true,
157
+ align: "fill",
158
+ code: `
159
+ const [metric, setMetric] = useState('sales')
160
+
161
+ <FigureTabs
162
+ aria-label="Headline figures"
163
+ value={metric}
164
+ onValueChange={setMetric}
165
+ items={[
166
+ { key: 'sales', label: 'Total sales', value: '£84,210.55', change: <Delta value={12.4} size="sm" />, hint: 'vs previous 30 days' },
167
+ { key: 'orders', label: 'Orders', value: '546', change: <Delta value={8.1} size="sm" />, hint: 'vs previous 30 days' },
168
+ // ...
169
+ ]}
170
+ />`,
171
+ children: /* @__PURE__ */ jsx(DefaultDemo, {})
172
+ })
173
+ }),
174
+ /* @__PURE__ */ jsx(Section, {
175
+ id: "compact",
176
+ title: "Compact: the Z-read strip",
177
+ description: /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "variant=\"compact\"" }), " sets each figure on one baseline (label, value, change) like the totals on a till's Z-read, 36px apart with no dividers and a smaller 21px figure. It is the strip on the home page of Orbit Commerce's store dashboard. On phones it becomes two columns, with the label and the change on lines of their own."] }),
178
+ children: /* @__PURE__ */ jsx(Example, {
179
+ clientOnly: true,
180
+ align: "fill",
181
+ code: `<FigureTabs variant="compact" aria-label="Headline figures" value={metric} onValueChange={setMetric} items={items} />`,
182
+ children: /* @__PURE__ */ jsx(CompactDemo, {})
183
+ })
184
+ }),
185
+ /* @__PURE__ */ jsx(Section, {
186
+ id: "both-themes",
187
+ title: "In both themes",
188
+ description: /* @__PURE__ */ jsx("p", { children: "Default above, compact below. The line is Orbit teal with a soft glow in light, and mint in dark." }),
189
+ children: /* @__PURE__ */ jsx(ThemePair, {
190
+ clientOnly: true,
191
+ align: "fill",
192
+ children: /* @__PURE__ */ jsx(PairSpecimen, {})
193
+ })
194
+ }),
195
+ /* @__PURE__ */ jsx(Section, {
196
+ id: "loading",
197
+ title: "Loading",
198
+ description: /* @__PURE__ */ jsxs("p", { children: [
199
+ "With ",
200
+ /* @__PURE__ */ jsx("code", { children: "loading" }),
201
+ ", a shimmering pill stands in for each value and the change is held back, while labels and hints stay put so the row does not jump when the figures land."
202
+ ] }),
203
+ children: /* @__PURE__ */ jsx(Example, {
204
+ clientOnly: true,
205
+ align: "fill",
206
+ code: `<FigureTabs aria-label="Headline figures" loading={isLoading} value={metric} onValueChange={setMetric} items={items} />`,
207
+ children: /* @__PURE__ */ jsx(LoadingDemo, {})
208
+ })
209
+ }),
210
+ /* @__PURE__ */ jsxs(Section, {
211
+ id: "with-chart",
212
+ title: "With a chart: the performance strip",
213
+ description: /* @__PURE__ */ jsxs("p", { children: [
214
+ "The pairing the component exists for, as it runs on the home. A",
215
+ " ",
216
+ /* @__PURE__ */ jsx(DocLink, {
217
+ to: "/components/segmented-control",
218
+ children: "Segmented control"
219
+ }),
220
+ " picks the range, the compact strip shows four figures as ",
221
+ /* @__PURE__ */ jsx(DocLink, {
222
+ to: "/components/rolling-number",
223
+ children: "Rolling numbers"
224
+ }),
225
+ " (they roll when the range changes), and the ",
226
+ /* @__PURE__ */ jsx(DocLink, {
227
+ to: "/components/area-chart",
228
+ children: "Area chart"
229
+ }),
230
+ " below follows the selected figure. Change the range, then pick another figure."
231
+ ] }),
232
+ children: [/* @__PURE__ */ jsx(Example, {
233
+ clientOnly: true,
234
+ align: "fill",
235
+ code: `
236
+ <header>
237
+ <h2 id="performance">Performance</h2>
238
+ <SegmentedControl aria-label="Date range" size="sm" value={range} onValueChange={setRange} options={ranges} />
239
+ </header>
240
+
241
+ <FigureTabs
242
+ variant="compact"
243
+ aria-label="Headline figures"
244
+ value={current.key}
245
+ onValueChange={setSelected}
246
+ items={figures.map((f) => ({
247
+ key: f.key,
248
+ label: f.label,
249
+ value: <RollingNumber value={f.amount} format={f.numberFormat} />,
250
+ change: <Delta value={f.change} size="sm" />,
251
+ }))}
252
+ />
253
+
254
+ <div role="tabpanel" aria-label={current.label}>
255
+ <AreaChart height={280} data={current.series} valueLabel={current.label} formatValue={current.format} />
256
+ </div>`,
257
+ children: /* @__PURE__ */ jsx(PerformanceStrip, { headingId: "figure-tabs-performance" })
258
+ }), /* @__PURE__ */ jsxs(Note, {
259
+ title: "Name the panel",
260
+ children: [
261
+ "The tabs are not linked to the chart for you. Wrap the chart in ",
262
+ /* @__PURE__ */ jsx("code", { children: "role=\"tabpanel\"" }),
263
+ " named after the selected figure, as above, so a screen reader knows what the chart is showing."
264
+ ]
265
+ })]
266
+ }),
267
+ /* @__PURE__ */ jsx(Section, {
268
+ id: "motion",
269
+ title: "Motion",
270
+ children: /* @__PURE__ */ jsx(DocTable, {
271
+ columns: ["Moment", "What happens"],
272
+ rows: [
273
+ ["Selecting a figure", "One teal line glides from the old figure to the new on the snappy spring, so the eye follows a single mark."],
274
+ ["Hover", "The label darkens; in the default variant a faint wash rises from the hairline."],
275
+ ["Loading", "The placeholder pills shimmer slowly until the figures arrive."],
276
+ ["Reduced motion", "The line moves at once and the shimmer stops. Everything else is unchanged."]
277
+ ]
278
+ })
279
+ }),
280
+ /* @__PURE__ */ jsxs(Section, {
281
+ id: "guidelines",
282
+ title: "Guidelines",
283
+ children: [/* @__PURE__ */ jsx(DoDont, {
284
+ clientOnly: true,
285
+ do: {
286
+ children: /* @__PURE__ */ jsx("div", {
287
+ className: "figure-tabs-dodont",
288
+ children: /* @__PURE__ */ jsx(FigureTabs, {
289
+ variant: "compact",
290
+ "aria-label": "Do example",
291
+ value: "sales",
292
+ onValueChange: () => {},
293
+ items: [{
294
+ key: "sales",
295
+ label: "Sales",
296
+ value: "£84,211",
297
+ change: /* @__PURE__ */ jsx(Delta, {
298
+ value: 12.4,
299
+ size: "sm"
300
+ })
301
+ }, {
302
+ key: "orders",
303
+ label: "Orders",
304
+ value: "546",
305
+ change: /* @__PURE__ */ jsx(Delta, {
306
+ value: 8.1,
307
+ size: "sm"
308
+ })
309
+ }]
310
+ })
311
+ }),
312
+ caption: "Figures on a hairline, one baseline each, doubling as the tabs of the chart below."
313
+ },
314
+ dont: {
315
+ children: /* @__PURE__ */ jsxs("div", {
316
+ className: "figure-tabs-dodont figure-tabs-dodont--cards",
317
+ children: [/* @__PURE__ */ jsxs(Card, {
318
+ padding: "sm",
319
+ children: [/* @__PURE__ */ jsx("span", {
320
+ className: "figure-tabs-dodont__label",
321
+ children: "Sales"
322
+ }), /* @__PURE__ */ jsx("span", {
323
+ className: "figure-tabs-dodont__value",
324
+ children: "£84,211"
325
+ })]
326
+ }), /* @__PURE__ */ jsxs(Card, {
327
+ padding: "sm",
328
+ children: [/* @__PURE__ */ jsx("span", {
329
+ className: "figure-tabs-dodont__label",
330
+ children: "Orders"
331
+ }), /* @__PURE__ */ jsx("span", {
332
+ className: "figure-tabs-dodont__value",
333
+ children: "546"
334
+ })]
335
+ })]
336
+ }),
337
+ caption: "A row of boxed stat cards says nothing more, adds borders to read past, and gives no way to change the chart."
338
+ }
339
+ }), /* @__PURE__ */ jsx(Guidelines, { items: [
340
+ "Two to four figures. More than four and the row wraps, and the eye loses which one drives the chart.",
341
+ "Labels of one or two words: \"Total sales\", \"Orders\", \"Conversion rate\".",
342
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
343
+ "Pass values already formatted, or a ",
344
+ /* @__PURE__ */ jsx(DocLink, {
345
+ to: "/components/rolling-number",
346
+ children: "Rolling number"
347
+ }),
348
+ " for a figure that changes while it is on screen. Show movement with a ",
349
+ /* @__PURE__ */ jsx(DocLink, {
350
+ to: "/components/delta",
351
+ children: "Delta"
352
+ }),
353
+ " in",
354
+ " ",
355
+ /* @__PURE__ */ jsx("code", { children: "change" }),
356
+ "."
357
+ ] }),
358
+ "Say what the change compares with once, in a hint or near the range control, and keep it the same for every figure."
359
+ ] })]
360
+ }),
361
+ /* @__PURE__ */ jsx(Section, {
362
+ id: "accessibility",
363
+ title: "Accessibility",
364
+ children: /* @__PURE__ */ jsx(Guidelines, { items: [
365
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
366
+ "The row is a tab list and needs an ",
367
+ /* @__PURE__ */ jsx("code", { children: "aria-label" }),
368
+ " (the prop is required). Each figure is a tab with its label, value and change as its name, and ",
369
+ /* @__PURE__ */ jsx("code", { children: "aria-selected" }),
370
+ " on the chosen one."
371
+ ] }),
372
+ "The row is one tab stop. Left and right arrows move the selection and focus together, wrapping at the ends, and Home and End jump to the first and last. The chart follows as you move.",
373
+ "The focus ring is teal, 2px, drawn just inside the figure.",
374
+ /* @__PURE__ */ jsxs(Fragment$1, { children: [
375
+ "Name the chart with ",
376
+ /* @__PURE__ */ jsx("code", { children: "role=\"tabpanel\"" }),
377
+ " and the selected figure's label, since the tabs do not point at a panel themselves."
378
+ ] })
379
+ ] })
380
+ }),
381
+ /* @__PURE__ */ jsxs(Section, {
382
+ id: "props",
383
+ title: "Props",
384
+ description: /* @__PURE__ */ jsx("p", { children: "Also accepts every native div attribute except onChange." }),
385
+ children: [/* @__PURE__ */ jsx(PropsTable, { rows: [
386
+ {
387
+ name: "items",
388
+ type: "ReadonlyArray<FigureTabItem<K>>",
389
+ required: true,
390
+ description: "The figures, in order."
391
+ },
392
+ {
393
+ name: "value",
394
+ type: "K",
395
+ required: true,
396
+ description: "The key of the selected figure."
397
+ },
398
+ {
399
+ name: "onValueChange",
400
+ type: "(key: K) => void",
401
+ required: true,
402
+ description: "Called with the key of the figure picked."
403
+ },
404
+ {
405
+ name: "aria-label",
406
+ type: "string",
407
+ required: true,
408
+ description: "Names the row for assistive tech, e.g. \"Headline figures\"."
409
+ },
410
+ {
411
+ name: "variant",
412
+ type: "'default' | 'compact'",
413
+ default: "'default'",
414
+ description: "Compact sets each figure on one baseline, like a Z-read."
415
+ },
416
+ {
417
+ name: "loading",
418
+ type: "boolean",
419
+ default: "false",
420
+ description: "Shows a shimmer where the values will be."
421
+ }
422
+ ] }), /* @__PURE__ */ jsx(PropsTable, {
423
+ title: "FigureTabItem",
424
+ rows: [
425
+ {
426
+ name: "key",
427
+ type: "K extends string",
428
+ required: true,
429
+ description: "Identifies the figure."
430
+ },
431
+ {
432
+ name: "label",
433
+ type: "ReactNode",
434
+ required: true,
435
+ description: "What the figure is, e.g. \"Orders\"."
436
+ },
437
+ {
438
+ name: "value",
439
+ type: "ReactNode",
440
+ required: true,
441
+ description: "The figure, already formatted, or a RollingNumber."
442
+ },
443
+ {
444
+ name: "change",
445
+ type: "ReactNode",
446
+ description: "How it moved, e.g. <Delta />."
447
+ },
448
+ {
449
+ name: "hint",
450
+ type: "ReactNode",
451
+ description: "Quiet context after the change, e.g. \"vs previous 30 days\"."
452
+ }
453
+ ]
454
+ })]
455
+ })
456
+ ]
457
+ });
458
+ }
459
+ //#endregion
460
+ export { Page, Preview };