@orbitcommerce/constellation-docs 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/README.md +6 -2
- package/dist/docs.css +20787 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-Mk1yIWXb.js +129 -0
- package/dist/pages/_address-data-L9BR499w.js +161 -0
- package/dist/pages/_builder-demo-C0eJUmPU.js +282 -0
- package/dist/pages/_card-art-0be5ncyV.js +18 -0
- package/dist/pages/_conversation-samples-Bq7cn-4d.js +70 -0
- package/dist/pages/_figures-data-DaDvB7Nm.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
- package/dist/pages/_overlays-specimens-bawR331Z.js +320 -0
- package/dist/pages/_preview-specimens-DKQC9HAo.js +153 -0
- package/dist/pages/accordion-Sg0TUqxB.js +1036 -0
- package/dist/pages/address-autocomplete-DP0PUOlK.js +360 -0
- package/dist/pages/address-block-BZOOOPA9.js +368 -0
- package/dist/pages/address-fields-CwSqro3W.js +277 -0
- package/dist/pages/ai-highlight-D3x2vD83.js +642 -0
- package/dist/pages/alert-D3i7xZTU.js +914 -0
- package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
- package/dist/pages/app-shell-D4hdlHps.js +1558 -0
- package/dist/pages/area-chart-BEWFwiB2.js +718 -0
- package/dist/pages/avatar-BFEqQViw.js +895 -0
- package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
- package/dist/pages/badge-0-PyMrih.js +1035 -0
- package/dist/pages/bar-chart-DkLogYlt.js +1060 -0
- package/dist/pages/bar-fold-B-3XeIDZ.js +360 -0
- package/dist/pages/board-card-D2tZY_mU.js +415 -0
- package/dist/pages/brand-mark-BqiLvFSR.js +417 -0
- package/dist/pages/button-DAyfssDY.js +715 -0
- package/dist/pages/calendar-Ds7KsgSI.js +682 -0
- package/dist/pages/canvas-stage-1KiPspkX.js +472 -0
- package/dist/pages/card-CQEM1_wc.js +1567 -0
- package/dist/pages/caret-suggestions-oHI6QvqW.js +526 -0
- package/dist/pages/chart-legend-B20AbakD.js +724 -0
- package/dist/pages/chat-composer-CwzUJYIa.js +437 -0
- package/dist/pages/checkbox-BG9Zkb6j.js +1581 -0
- package/dist/pages/checklist-card-DEyykVFS.js +783 -0
- package/dist/pages/chip-Ck-o3Ui6.js +839 -0
- package/dist/pages/chip-list-k1LxXuCi.js +414 -0
- package/dist/pages/clamp-text-n-iE8RDR.js +203 -0
- package/dist/pages/coachmark-Be2ghobT.js +366 -0
- package/dist/pages/code-block-Dv_Y5GYq.js +622 -0
- package/dist/pages/collab-field-CfqqK7d2.js +696 -0
- package/dist/pages/color-field-CZpfcA-A.js +1127 -0
- package/dist/pages/colour-q2ntvI0w.js +1974 -0
- package/dist/pages/column-mapper-TsTG39cl.js +502 -0
- package/dist/pages/combobox-DvK2j5tI.js +1334 -0
- package/dist/pages/command-palette-CJ7uBA04.js +1386 -0
- package/dist/pages/comment-box-CDSGYhr5.js +346 -0
- package/dist/pages/composer-D4B0NgpA.js +689 -0
- package/dist/pages/condition-builder-BZy2ZGXe.js +715 -0
- package/dist/pages/conflict-chooser-C--_9UIS.js +210 -0
- package/dist/pages/context-menu-F9DV30ia.js +487 -0
- package/dist/pages/copy-button-Cn7WiKRF.js +568 -0
- package/dist/pages/copy-field-D3Xt3Jq6.js +511 -0
- package/dist/pages/danger-zone-Db_UUeiP.js +564 -0
- package/dist/pages/date-input-GOW067EB.js +956 -0
- package/dist/pages/date-picker-GdBciR99.js +1569 -0
- package/dist/pages/date-time-BLKCXtVZ.js +678 -0
- package/dist/pages/delta-CNAGv8JY.js +779 -0
- package/dist/pages/description-list-BPeXn1eW.js +1268 -0
- package/dist/pages/device-switcher-BCaN99c1.js +554 -0
- package/dist/pages/dialog-CRpkRC98.js +3164 -0
- package/dist/pages/docs-lM2UBSir.js +520 -0
- package/dist/pages/doodle-nzkqi2UI.js +201 -0
- package/dist/pages/drag-ghost-B6kpzC3O.js +426 -0
- package/dist/pages/drill-menu-cskH5mol.js +490 -0
- package/dist/pages/dropzone-DOY_Rhw0.js +1069 -0
- package/dist/pages/element-toolbar-DZIhXlCJ.js +498 -0
- package/dist/pages/emoji-picker-CqaWaffD.js +235 -0
- package/dist/pages/empty-state-4U2txFpI.js +1113 -0
- package/dist/pages/facet-filters-McbBeY9e.js +353 -0
- package/dist/pages/figure-D-HF5vCj.js +563 -0
- package/dist/pages/figure-strip-BB3mNl7D.js +1364 -0
- package/dist/pages/figure-tabs-QOeQMY6N.js +578 -0
- package/dist/pages/file-chip-DMDjtlqQ.js +738 -0
- package/dist/pages/filter-pill-DzqNOsD4.js +1295 -0
- package/dist/pages/font-picker-Bqhu0QMh.js +416 -0
- package/dist/pages/form-grid-BfWCVlie.js +692 -0
- package/dist/pages/gallery-BBk2EOri.js +453 -0
- package/dist/pages/gif-picker-CnoDTCaL.js +270 -0
- package/dist/pages/gradient-editor-Bqxp7Fxj.js +378 -0
- package/dist/pages/grouped-checklist-gNZ0tBKU.js +477 -0
- package/dist/pages/heatmap-BohgIcNk.js +507 -0
- package/dist/pages/highlight-text-BfxzfmvS.js +287 -0
- package/dist/pages/home-dashboard-CxPmvduE.js +962 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/hosted-embed-Jef3aIMP.js +163 -0
- package/dist/pages/hosted-field-BLh-53AE.js +208 -0
- package/dist/pages/hosted-field-DEpI4lVS.js +514 -0
- package/dist/pages/icon-button-Bu4Gj5sy.js +1200 -0
- package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
- package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
- package/dist/pages/icons-CJ9Aar3d.js +736 -0
- package/dist/pages/image-cropper-NyougqLH.js +466 -0
- package/dist/pages/image-field-7knBv4mJ.js +567 -0
- package/dist/pages/import-result-CmTtGXW_.js +486 -0
- package/dist/pages/inline-confirm-CEcI5Lxo.js +327 -0
- package/dist/pages/inline-edit-Ba39SzhM.js +1125 -0
- package/dist/pages/input-CzLCzfyx.js +2372 -0
- package/dist/pages/installation-C3UcpQJT.js +528 -0
- package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
- package/dist/pages/kanban-Dy9sPAI0.js +740 -0
- package/dist/pages/kbd-UNj4zqxn.js +545 -0
- package/dist/pages/layout-primitives-CPRaZeyt.js +483 -0
- package/dist/pages/line-chart-CntWxeMF.js +1117 -0
- package/dist/pages/link-CXqvAg9z.js +689 -0
- package/dist/pages/link-picker-BMFGCC67.js +478 -0
- package/dist/pages/link-row-x8yaUuWc.js +595 -0
- package/dist/pages/live-globe-95ROMhGQ.js +715 -0
- package/dist/pages/loading-overlay-BeGuXM9G.js +456 -0
- package/dist/pages/loading-state-BNbCo51C.js +556 -0
- package/dist/pages/log-viewer-BQz8I_a2.js +503 -0
- package/dist/pages/logo-B38rnzoq.js +571 -0
- package/dist/pages/lottie_light-CxEH8eiR.js +9116 -0
- package/dist/pages/markdown-Ied72vMT.js +237 -0
- package/dist/pages/markdown-field-BfnIEKZH.js +193 -0
- package/dist/pages/media-banner-DkStCia0.js +233 -0
- package/dist/pages/menu-NrLYKqKp.js +2132 -0
- package/dist/pages/message-thread-Bo4zbxqu.js +731 -0
- package/dist/pages/meta-line-D5p2TycR.js +371 -0
- package/dist/pages/model-viewer-BfokvHoc.js +60288 -0
- package/dist/pages/model-viewer-C8PFO8wk.js +577 -0
- package/dist/pages/month-calendar-T1vw9Rup.js +457 -0
- package/dist/pages/motion-CrXtiBvA.js +865 -0
- package/dist/pages/number-input-CuyMZg18.js +968 -0
- package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
- package/dist/pages/orbit-spinner-Dxv5qAhr.js +348 -0
- package/dist/pages/otp-input-CVRoX1mw.js +591 -0
- package/dist/pages/overview-LA9XRhZc.js +130 -0
- package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
- package/dist/pages/pagination-C1EgVtW4.js +294 -0
- package/dist/pages/palette-tile-X9ZXu2Z0.js +414 -0
- package/dist/pages/password-field-DHEQKyUC.js +912 -0
- package/dist/pages/person-cell-BmjbADBz.js +564 -0
- package/dist/pages/phone-input-B3G7Qpb2.js +747 -0
- package/dist/pages/plan-card-DRaA6RuB.js +621 -0
- package/dist/pages/plan-card-DtloWvMh.js +258 -0
- package/dist/pages/plan-comparison-BVIGTtbd.js +559 -0
- package/dist/pages/plan-grid-cfPVTB5V.js +251 -0
- package/dist/pages/point-list-BbPmZjsm.js +222 -0
- package/dist/pages/popover-C3Oar9D5.js +1198 -0
- package/dist/pages/presence-avatars-CRZIk8n9.js +328 -0
- package/dist/pages/preview-frame-Bcwk0y_Q.js +1631 -0
- package/dist/pages/price-CRBLoa9h.js +604 -0
- package/dist/pages/principles-pnDyfHpK.js +483 -0
- package/dist/pages/print-page-BkLv6bW8.js +513 -0
- package/dist/pages/profile-hero-CC9dUzuN.js +498 -0
- package/dist/pages/progress-CP_awmo4.js +904 -0
- package/dist/pages/progress-ring-JuOAwk2T.js +576 -0
- package/dist/pages/radio-group-C-4tg6FS.js +1639 -0
- package/dist/pages/radius-control-B2kRA2Ch.js +441 -0
- package/dist/pages/rating-CweKN2SX.js +471 -0
- package/dist/pages/record-layout-DUP_X0RL.js +719 -0
- package/dist/pages/record-pager-y9D7JFgb.js +278 -0
- package/dist/pages/registry-BZg-xAbi.js +594 -0
- package/dist/pages/release-Cs6tl16C.js +16 -0
- package/dist/pages/repeater-BRZYKRQa.js +1351 -0
- package/dist/pages/reply-feedback-BDnHprla.js +192 -0
- package/dist/pages/reveal-BygENBbL.js +460 -0
- package/dist/pages/rich-text-DOFQZEpT.js +156 -0
- package/dist/pages/rich-text-editor-BhIM20JI.js +1265 -0
- package/dist/pages/rolldown-runtime-CbKu08Hx.js +25 -0
- package/dist/pages/rolling-number-GR3Cyfpz.js +529 -0
- package/dist/pages/row-list-Dl6CYhC-.js +1565 -0
- package/dist/pages/rule-list-DTCmIMpT.js +648 -0
- package/dist/pages/save-status-B5KkyMZP.js +378 -0
- package/dist/pages/schedule-YycI95O1.js +243 -0
- package/dist/pages/scroll-area-B2sGm23Q.js +423 -0
- package/dist/pages/search-field-D1uG7R6A.js +693 -0
- package/dist/pages/search-menu-DMuXyUUW.js +580 -0
- package/dist/pages/secret-field-Dj9x3LL8.js +337 -0
- package/dist/pages/section-rail-BtTCETS5.js +637 -0
- package/dist/pages/section-v2Pubup9.js +639 -0
- package/dist/pages/segmented-control-D-FB1K1T.js +1190 -0
- package/dist/pages/select-DZ43NpOm.js +1434 -0
- package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
- package/dist/pages/separator-CFwqRvfO.js +428 -0
- package/dist/pages/serp-preview-BGwORjmo.js +346 -0
- package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
- package/dist/pages/shape-DzniHAVT.js +627 -0
- package/dist/pages/share-list-D4wgBxKN.js +926 -0
- package/dist/pages/side-panel-CCtkrZjs.js +811 -0
- package/dist/pages/site-preview-Dj1hM2Yo.js +353 -0
- package/dist/pages/skeleton-C1F5HkAu.js +1325 -0
- package/dist/pages/skip-link-BxznhSkz.js +252 -0
- package/dist/pages/slider-CAoPURKD.js +774 -0
- package/dist/pages/sortable-card-Sr44uCpI.js +424 -0
- package/dist/pages/sortable-list-DUAleYE1.js +1298 -0
- package/dist/pages/sortable-tree-BLzK-hTE.js +737 -0
- package/dist/pages/spacing-box-CtuvzxQu.js +550 -0
- package/dist/pages/sparkline-D3aavCly.js +947 -0
- package/dist/pages/split-bar-DYgZnFID.js +414 -0
- package/dist/pages/split-button-Be08-VI-.js +335 -0
- package/dist/pages/split-pane-lSNZgTKt.js +523 -0
- package/dist/pages/status-badge-DOdNhmzn.js +1074 -0
- package/dist/pages/status-checklist-CWkjCZIC.js +1152 -0
- package/dist/pages/status-dot-D99gAGsV.js +567 -0
- package/dist/pages/stepper-CxKTbEA-.js +1093 -0
- package/dist/pages/success-mark-CqFTOBEu.js +142 -0
- package/dist/pages/swatch-H_kNvHuC.js +565 -0
- package/dist/pages/switch-C93K6j9h.js +617 -0
- package/dist/pages/table-CL0vomno.js +3225 -0
- package/dist/pages/tabs-Dh0mUsLw.js +1690 -0
- package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
- package/dist/pages/task-card-Dv0sR1-w.js +295 -0
- package/dist/pages/textarea-CCM-SnGN.js +949 -0
- package/dist/pages/thumbnail-DwFJL_k1.js +1147 -0
- package/dist/pages/time-input-CA9-uZAa.js +442 -0
- package/dist/pages/time-zone-select-CEtMXVYO.js +296 -0
- package/dist/pages/timeline-BsMUTlpR.js +1798 -0
- package/dist/pages/toast-zXLRiMRT.js +1391 -0
- package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
- package/dist/pages/toolbar-B9l_fHKy.js +754 -0
- package/dist/pages/tooltip-LHtCUkF-.js +826 -0
- package/dist/pages/translation-field-CTRXiF2N.js +251 -0
- package/dist/pages/tree-checklist-CJj3OcLg.js +451 -0
- package/dist/pages/tree-select-DU1qXHy_.js +492 -0
- package/dist/pages/tree-view-g_RjLtAb.js +739 -0
- package/dist/pages/typography-BSijtiRl.js +876 -0
- package/dist/pages/unit-input-Dml4fjmK.js +659 -0
- package/dist/pages/upload-rules-yozEzSah.js +419 -0
- package/dist/pages/url-upload-input-SSnMgfpA.js +307 -0
- package/dist/pages/value-change-CnubDKyO.js +489 -0
- package/dist/pages/weekly-hours-i2EpsmTx.js +287 -0
- package/dist/pages/widget-preview-CUJMyZ_k.js +625 -0
- package/dist/pages/working-status-CENemSsw.js +389 -0
- package/manifest.json +13001 -0
- package/package.json +35 -4
|
@@ -0,0 +1,1190 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as DocTable, d as Section$1, i as DocPage, l as Note, m as ThemePair, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
3
|
+
import { t as Playground } from "./Playground-Mk1yIWXb.js";
|
|
4
|
+
import { useId, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { AreaChart, Delta, SegmentedControl } from "@orbitcommerce/constellation";
|
|
7
|
+
import { DesktopIcon, DeviceMobileIcon, DeviceTabletIcon, RowsIcon, SquaresFourIcon, TextAlignCenterIcon, TextAlignJustifyIcon, TextAlignLeftIcon, TextAlignRightIcon, TextBIcon, TextItalicIcon, TextUnderlineIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/segmented-control.tsx
|
|
9
|
+
function Preview() {
|
|
10
|
+
return /* @__PURE__ */ jsx(SegmentedControl, {
|
|
11
|
+
"aria-label": "Date range",
|
|
12
|
+
defaultValue: "7d",
|
|
13
|
+
options: [
|
|
14
|
+
{
|
|
15
|
+
value: "today",
|
|
16
|
+
label: "Today"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
value: "7d",
|
|
20
|
+
label: "7 days"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
value: "30d",
|
|
24
|
+
label: "30 days"
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
var quote = (v) => String(v).replace(/"/g, """);
|
|
30
|
+
var DEVICES = [
|
|
31
|
+
{
|
|
32
|
+
value: "desktop",
|
|
33
|
+
label: "Desktop",
|
|
34
|
+
icon: /* @__PURE__ */ jsx(DesktopIcon, {}),
|
|
35
|
+
name: "DesktopIcon"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
value: "tablet",
|
|
39
|
+
label: "Tablet",
|
|
40
|
+
icon: /* @__PURE__ */ jsx(DeviceTabletIcon, {}),
|
|
41
|
+
name: "DeviceTabletIcon"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
value: "phone",
|
|
45
|
+
label: "Phone",
|
|
46
|
+
icon: /* @__PURE__ */ jsx(DeviceMobileIcon, {}),
|
|
47
|
+
name: "DeviceMobileIcon"
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
function deviceOptions(form) {
|
|
51
|
+
return DEVICES.map((d) => ({
|
|
52
|
+
value: d.value,
|
|
53
|
+
label: d.label,
|
|
54
|
+
icon: form === "text" ? void 0 : d.icon,
|
|
55
|
+
iconOnly: form === "icon only"
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
function deviceOptionsCode(form) {
|
|
59
|
+
return `options={[\n ${DEVICES.map((d) => form === "text" ? `{ value: '${d.value}', label: '${d.label}' }` : form === "icon and text" ? `{ value: '${d.value}', label: '${d.label}', icon: <${d.name} /> }` : `{ value: '${d.value}', label: '${d.label}', icon: <${d.name} />, iconOnly: true }`).join(",\n ")},\n]}`;
|
|
60
|
+
}
|
|
61
|
+
var PLAYGROUND = [
|
|
62
|
+
{
|
|
63
|
+
prop: "aria-label",
|
|
64
|
+
type: "text",
|
|
65
|
+
default: "Preview size",
|
|
66
|
+
toAttr: (v) => `aria-label="${quote(v)}"`
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
prop: "options",
|
|
70
|
+
type: "select",
|
|
71
|
+
options: [
|
|
72
|
+
"text",
|
|
73
|
+
"icon and text",
|
|
74
|
+
"icon only"
|
|
75
|
+
],
|
|
76
|
+
default: "icon and text",
|
|
77
|
+
toAttr: (v) => deviceOptionsCode(v)
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
prop: "size",
|
|
81
|
+
type: "select",
|
|
82
|
+
options: ["sm", "md"],
|
|
83
|
+
default: "md"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
prop: "fullWidth",
|
|
87
|
+
type: "boolean",
|
|
88
|
+
default: false
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
prop: "disabled",
|
|
92
|
+
type: "boolean",
|
|
93
|
+
default: false
|
|
94
|
+
}
|
|
95
|
+
];
|
|
96
|
+
var RANGES = [
|
|
97
|
+
{
|
|
98
|
+
value: "7d",
|
|
99
|
+
label: "7 days"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
value: "30d",
|
|
103
|
+
label: "30 days"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
value: "90d",
|
|
107
|
+
label: "90 days"
|
|
108
|
+
}
|
|
109
|
+
];
|
|
110
|
+
var DAYS = {
|
|
111
|
+
"7d": 7,
|
|
112
|
+
"30d": 30,
|
|
113
|
+
"90d": 90
|
|
114
|
+
};
|
|
115
|
+
/** A day `offset` days before Monday 28 September 2026, as YYYY-MM-DD. */
|
|
116
|
+
function dayBefore(offset) {
|
|
117
|
+
const d = new Date(2026, 8, 28 - offset);
|
|
118
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`;
|
|
119
|
+
}
|
|
120
|
+
/** Invented daily takings: quieter weekends, a slow rise, a little noise. */
|
|
121
|
+
function takingsOn(offset) {
|
|
122
|
+
const day = new Date(2026, 8, 28 - offset).getDay();
|
|
123
|
+
const weekend = day === 0 || day === 6 ? .74 : 1;
|
|
124
|
+
const wave = 1 + .16 * Math.sin(offset / 5.3) + .07 * Math.sin(offset / 1.7);
|
|
125
|
+
const trend = 1 + (180 - offset) * .0016;
|
|
126
|
+
const seed = Math.sin((offset + 1) * 12.9898) * 43758.5453;
|
|
127
|
+
const noise = .86 + (seed - Math.floor(seed)) * .28;
|
|
128
|
+
return Math.round(380 * weekend * wave * trend * noise * 100) / 100;
|
|
129
|
+
}
|
|
130
|
+
function seriesFor(range) {
|
|
131
|
+
const n = DAYS[range];
|
|
132
|
+
return Array.from({ length: n }, (_, i) => {
|
|
133
|
+
const offset = n - 1 - i;
|
|
134
|
+
return {
|
|
135
|
+
date: dayBefore(offset),
|
|
136
|
+
value: takingsOn(offset),
|
|
137
|
+
compare: takingsOn(offset + n)
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
var SERIES = {
|
|
142
|
+
"7d": seriesFor("7d"),
|
|
143
|
+
"30d": seriesFor("30d"),
|
|
144
|
+
"90d": seriesFor("90d")
|
|
145
|
+
};
|
|
146
|
+
var pounds = new Intl.NumberFormat("en-GB", {
|
|
147
|
+
style: "currency",
|
|
148
|
+
currency: "GBP"
|
|
149
|
+
});
|
|
150
|
+
var formatPounds = (v) => pounds.format(v);
|
|
151
|
+
function TakingsChart() {
|
|
152
|
+
const [range, setRange] = useState("30d");
|
|
153
|
+
const data = SERIES[range];
|
|
154
|
+
const total = data.reduce((sum, d) => sum + d.value, 0);
|
|
155
|
+
const before = data.reduce((sum, d) => sum + (d.compare ?? 0), 0);
|
|
156
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
157
|
+
className: "segmented-control-chart",
|
|
158
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
159
|
+
className: "segmented-control-chart__head",
|
|
160
|
+
children: [/* @__PURE__ */ jsxs("p", {
|
|
161
|
+
className: "segmented-control-figure",
|
|
162
|
+
children: [
|
|
163
|
+
/* @__PURE__ */ jsx("span", {
|
|
164
|
+
className: "segmented-control-figure__label",
|
|
165
|
+
children: "Takings"
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx("span", {
|
|
168
|
+
className: "segmented-control-figure__value",
|
|
169
|
+
children: formatPounds(total)
|
|
170
|
+
}),
|
|
171
|
+
/* @__PURE__ */ jsx("span", {
|
|
172
|
+
className: "segmented-control-figure__meta",
|
|
173
|
+
children: /* @__PURE__ */ jsx(Delta, {
|
|
174
|
+
value: (total - before) / before * 100,
|
|
175
|
+
size: "sm",
|
|
176
|
+
label: `vs the ${DAYS[range]} days before`
|
|
177
|
+
})
|
|
178
|
+
})
|
|
179
|
+
]
|
|
180
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
181
|
+
"aria-label": "Date range",
|
|
182
|
+
size: "sm",
|
|
183
|
+
value: range,
|
|
184
|
+
onValueChange: setRange,
|
|
185
|
+
options: RANGES
|
|
186
|
+
})]
|
|
187
|
+
}), /* @__PURE__ */ jsx(AreaChart, {
|
|
188
|
+
data,
|
|
189
|
+
height: 200,
|
|
190
|
+
formatValue: formatPounds,
|
|
191
|
+
formatTick: (v) => `£${Math.round(v)}`,
|
|
192
|
+
valueLabel: `Last ${DAYS[range]} days`,
|
|
193
|
+
compareLabel: "The period before"
|
|
194
|
+
})]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
var TEXT_STYLES = [
|
|
198
|
+
{
|
|
199
|
+
value: "bold",
|
|
200
|
+
label: "Bold",
|
|
201
|
+
icon: /* @__PURE__ */ jsx(TextBIcon, {}),
|
|
202
|
+
iconOnly: true,
|
|
203
|
+
shortcut: ["mod", "B"]
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
value: "italic",
|
|
207
|
+
label: "Italic",
|
|
208
|
+
icon: /* @__PURE__ */ jsx(TextItalicIcon, {}),
|
|
209
|
+
iconOnly: true,
|
|
210
|
+
shortcut: ["mod", "I"]
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
value: "underline",
|
|
214
|
+
label: "Underline",
|
|
215
|
+
icon: /* @__PURE__ */ jsx(TextUnderlineIcon, {}),
|
|
216
|
+
iconOnly: true,
|
|
217
|
+
shortcut: ["mod", "U"]
|
|
218
|
+
}
|
|
219
|
+
];
|
|
220
|
+
/** Bold, italic and underline at once, over a line of text that wears them. */
|
|
221
|
+
function TextStyleChoice() {
|
|
222
|
+
const [styles, setStyles] = useState(["bold"]);
|
|
223
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
224
|
+
className: "segmented-control-inspector",
|
|
225
|
+
children: [/* @__PURE__ */ jsx(SegmentedControl, {
|
|
226
|
+
type: "multiple",
|
|
227
|
+
"aria-label": "Text style",
|
|
228
|
+
size: "sm",
|
|
229
|
+
options: TEXT_STYLES,
|
|
230
|
+
value: styles,
|
|
231
|
+
onValueChange: setStyles
|
|
232
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
233
|
+
className: "segmented-control-sample",
|
|
234
|
+
style: {
|
|
235
|
+
fontWeight: styles.includes("bold") ? 700 : 400,
|
|
236
|
+
fontStyle: styles.includes("italic") ? "italic" : "normal",
|
|
237
|
+
textDecoration: styles.includes("underline") ? "underline" : "none"
|
|
238
|
+
},
|
|
239
|
+
children: "Arden ergonomic chair, in stock"
|
|
240
|
+
})]
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
var ALIGNMENT = [
|
|
244
|
+
{
|
|
245
|
+
value: "left",
|
|
246
|
+
label: "Align left",
|
|
247
|
+
icon: /* @__PURE__ */ jsx(TextAlignLeftIcon, {}),
|
|
248
|
+
iconOnly: true
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
value: "center",
|
|
252
|
+
label: "Align centre",
|
|
253
|
+
icon: /* @__PURE__ */ jsx(TextAlignCenterIcon, {}),
|
|
254
|
+
iconOnly: true
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
value: "right",
|
|
258
|
+
label: "Align right",
|
|
259
|
+
icon: /* @__PURE__ */ jsx(TextAlignRightIcon, {}),
|
|
260
|
+
iconOnly: true
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
value: "justify",
|
|
264
|
+
label: "Justify",
|
|
265
|
+
icon: /* @__PURE__ */ jsx(TextAlignJustifyIcon, {}),
|
|
266
|
+
iconOnly: true
|
|
267
|
+
}
|
|
268
|
+
];
|
|
269
|
+
var PREVIEW_DEVICES = [
|
|
270
|
+
{
|
|
271
|
+
value: "desktop",
|
|
272
|
+
label: "Desktop",
|
|
273
|
+
icon: /* @__PURE__ */ jsx(DesktopIcon, {}),
|
|
274
|
+
iconOnly: true
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
value: "tablet",
|
|
278
|
+
label: "Tablet",
|
|
279
|
+
icon: /* @__PURE__ */ jsx(DeviceTabletIcon, {}),
|
|
280
|
+
iconOnly: true
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
value: "mobile",
|
|
284
|
+
label: "Mobile",
|
|
285
|
+
icon: /* @__PURE__ */ jsx(DeviceMobileIcon, {}),
|
|
286
|
+
iconOnly: true
|
|
287
|
+
}
|
|
288
|
+
];
|
|
289
|
+
var GROUP_BY = [
|
|
290
|
+
{
|
|
291
|
+
value: "colour",
|
|
292
|
+
label: "Colour"
|
|
293
|
+
},
|
|
294
|
+
{
|
|
295
|
+
value: "size",
|
|
296
|
+
label: "Size"
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
value: "material",
|
|
300
|
+
label: "Material"
|
|
301
|
+
}
|
|
302
|
+
];
|
|
303
|
+
var ACCESS = [
|
|
304
|
+
{
|
|
305
|
+
value: "full",
|
|
306
|
+
label: "Full access",
|
|
307
|
+
hint: "Everything except billing and store ownership."
|
|
308
|
+
},
|
|
309
|
+
{
|
|
310
|
+
value: "orders",
|
|
311
|
+
label: "Orders only",
|
|
312
|
+
hint: "Orders, customers and fulfilment. No settings."
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
value: "view",
|
|
316
|
+
label: "View only",
|
|
317
|
+
hint: "Can look at everything and change nothing."
|
|
318
|
+
}
|
|
319
|
+
];
|
|
320
|
+
function AccessChoice() {
|
|
321
|
+
const [access, setAccess] = useState("orders");
|
|
322
|
+
const labelId = useId();
|
|
323
|
+
const hintId = useId();
|
|
324
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
325
|
+
className: "segmented-control-group",
|
|
326
|
+
children: [
|
|
327
|
+
/* @__PURE__ */ jsx("p", {
|
|
328
|
+
id: labelId,
|
|
329
|
+
className: "segmented-control-group__label",
|
|
330
|
+
children: "Access"
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
333
|
+
"aria-labelledby": labelId,
|
|
334
|
+
"aria-describedby": hintId,
|
|
335
|
+
fullWidth: true,
|
|
336
|
+
value: access,
|
|
337
|
+
onValueChange: setAccess,
|
|
338
|
+
options: ACCESS.map(({ value, label }) => ({
|
|
339
|
+
value,
|
|
340
|
+
label
|
|
341
|
+
}))
|
|
342
|
+
}),
|
|
343
|
+
/* @__PURE__ */ jsx("p", {
|
|
344
|
+
id: hintId,
|
|
345
|
+
className: "segmented-control-group__hint",
|
|
346
|
+
children: ACCESS.find((a) => a.value === access)?.hint
|
|
347
|
+
})
|
|
348
|
+
]
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
function Page() {
|
|
352
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
353
|
+
title: "Segmented control",
|
|
354
|
+
status: "stable",
|
|
355
|
+
importNames: ["SegmentedControl"],
|
|
356
|
+
lead: "A pill track for choosing one of a few views: the date range of a chart, a grid or a list, a device to preview on. The chosen option rides a raised thumb that glides between them.",
|
|
357
|
+
children: [
|
|
358
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
359
|
+
id: "playground",
|
|
360
|
+
title: "Playground",
|
|
361
|
+
description: /* @__PURE__ */ jsx("p", { children: "Change the props, then click between the options to watch the thumb glide." }),
|
|
362
|
+
children: /* @__PURE__ */ jsx(Playground, {
|
|
363
|
+
component: "SegmentedControl",
|
|
364
|
+
controls: PLAYGROUND,
|
|
365
|
+
render: (v) => /* @__PURE__ */ jsx("div", {
|
|
366
|
+
className: "segmented-control-stage",
|
|
367
|
+
children: /* @__PURE__ */ jsx(SegmentedControl, {
|
|
368
|
+
"aria-label": String(v["aria-label"]),
|
|
369
|
+
options: deviceOptions(v.options),
|
|
370
|
+
size: v.size,
|
|
371
|
+
fullWidth: Boolean(v.fullWidth),
|
|
372
|
+
disabled: Boolean(v.disabled)
|
|
373
|
+
})
|
|
374
|
+
})
|
|
375
|
+
})
|
|
376
|
+
}),
|
|
377
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
378
|
+
id: "controlled",
|
|
379
|
+
title: "A date range for a chart",
|
|
380
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
381
|
+
"The most common job: pick the period, and the figure and chart change in place. Control it with",
|
|
382
|
+
" ",
|
|
383
|
+
/* @__PURE__ */ jsx("code", { children: "value" }),
|
|
384
|
+
" and ",
|
|
385
|
+
/* @__PURE__ */ jsx("code", { children: "onValueChange" }),
|
|
386
|
+
". Typed options keep the value typed too."
|
|
387
|
+
] }),
|
|
388
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
389
|
+
align: "fill",
|
|
390
|
+
code: `
|
|
391
|
+
type Range = '7d' | '30d' | '90d'
|
|
392
|
+
|
|
393
|
+
const ranges: SegmentedControlOption<Range>[] = [
|
|
394
|
+
{ value: '7d', label: '7 days' },
|
|
395
|
+
{ value: '30d', label: '30 days' },
|
|
396
|
+
{ value: '90d', label: '90 days' },
|
|
397
|
+
]
|
|
398
|
+
|
|
399
|
+
const [range, setRange] = useState<Range>('30d')
|
|
400
|
+
|
|
401
|
+
<SegmentedControl aria-label="Date range" size="sm" value={range} onValueChange={setRange} options={ranges} />
|
|
402
|
+
<AreaChart data={takings[range]} height={200} formatValue={formatPounds} />`,
|
|
403
|
+
children: /* @__PURE__ */ jsx(TakingsChart, {})
|
|
404
|
+
})
|
|
405
|
+
}),
|
|
406
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
407
|
+
id: "sizes",
|
|
408
|
+
title: "Sizes",
|
|
409
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
410
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
411
|
+
" is 36px tall (default) and ",
|
|
412
|
+
/* @__PURE__ */ jsx("code", { children: "sm" }),
|
|
413
|
+
" 30px, the same heights as buttons. Labels are 13px and 12px; icons 15px and 13px."
|
|
414
|
+
] }),
|
|
415
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
416
|
+
code: `
|
|
417
|
+
<SegmentedControl aria-label="Date range" options={ranges} defaultValue="30d" />
|
|
418
|
+
<SegmentedControl aria-label="Date range" size="sm" options={ranges} defaultValue="30d" />`,
|
|
419
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
420
|
+
className: "segmented-control-rows",
|
|
421
|
+
children: [/* @__PURE__ */ jsx(SegmentedControl, {
|
|
422
|
+
"aria-label": "Date range",
|
|
423
|
+
options: RANGES,
|
|
424
|
+
defaultValue: "30d"
|
|
425
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
426
|
+
"aria-label": "Date range",
|
|
427
|
+
size: "sm",
|
|
428
|
+
options: RANGES,
|
|
429
|
+
defaultValue: "30d"
|
|
430
|
+
})]
|
|
431
|
+
})
|
|
432
|
+
})
|
|
433
|
+
}),
|
|
434
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
435
|
+
id: "full-width",
|
|
436
|
+
title: "Full width",
|
|
437
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
438
|
+
/* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "fullWidth" }), " stretches the track and shares it equally between the options. Use it in dialogs, popovers and narrow panels, where the control is the width of the fields around it."] }),
|
|
439
|
+
/* @__PURE__ */ jsx("p", { children: "It never squeezes an option below its words. A track that does not fit its container, full width or not (on a phone, say), scrolls sideways instead: it fades at whichever end has more to show and keeps the chosen option in view, as tabs do." }),
|
|
440
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
441
|
+
"The control has no visible label of its own and cannot sit in a Field. For a visible label, write it above and point ",
|
|
442
|
+
/* @__PURE__ */ jsx("code", { children: "aria-labelledby" }),
|
|
443
|
+
" at it, in place of ",
|
|
444
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
445
|
+
". A hint below can be linked with ",
|
|
446
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
447
|
+
"."
|
|
448
|
+
] })
|
|
449
|
+
] }),
|
|
450
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
451
|
+
align: "fill",
|
|
452
|
+
code: `
|
|
453
|
+
<p id="access-label">Access</p>
|
|
454
|
+
<SegmentedControl
|
|
455
|
+
aria-labelledby="access-label"
|
|
456
|
+
aria-describedby="access-hint"
|
|
457
|
+
fullWidth
|
|
458
|
+
value={access}
|
|
459
|
+
onValueChange={setAccess}
|
|
460
|
+
options={[
|
|
461
|
+
{ value: 'full', label: 'Full access' },
|
|
462
|
+
{ value: 'orders', label: 'Orders only' },
|
|
463
|
+
{ value: 'view', label: 'View only' },
|
|
464
|
+
]}
|
|
465
|
+
/>
|
|
466
|
+
<p id="access-hint">Orders, customers and fulfilment. No settings.</p>`,
|
|
467
|
+
children: /* @__PURE__ */ jsx(AccessChoice, {})
|
|
468
|
+
})
|
|
469
|
+
}),
|
|
470
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
471
|
+
id: "icons",
|
|
472
|
+
title: "With icons",
|
|
473
|
+
description: /* @__PURE__ */ jsx("p", { children: "A leading icon on each option, for views that have a well-known picture." }),
|
|
474
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
475
|
+
code: `
|
|
476
|
+
<SegmentedControl
|
|
477
|
+
aria-label="Product layout"
|
|
478
|
+
size="sm"
|
|
479
|
+
options={[
|
|
480
|
+
{ value: 'grid', label: 'Grid', icon: <SquaresFourIcon /> },
|
|
481
|
+
{ value: 'list', label: 'List', icon: <RowsIcon /> },
|
|
482
|
+
]}
|
|
483
|
+
/>`,
|
|
484
|
+
children: /* @__PURE__ */ jsx(SegmentedControl, {
|
|
485
|
+
"aria-label": "Product layout",
|
|
486
|
+
size: "sm",
|
|
487
|
+
options: [{
|
|
488
|
+
value: "grid",
|
|
489
|
+
label: "Grid",
|
|
490
|
+
icon: /* @__PURE__ */ jsx(SquaresFourIcon, {})
|
|
491
|
+
}, {
|
|
492
|
+
value: "list",
|
|
493
|
+
label: "List",
|
|
494
|
+
icon: /* @__PURE__ */ jsx(RowsIcon, {})
|
|
495
|
+
}]
|
|
496
|
+
})
|
|
497
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
498
|
+
title: "Icon only",
|
|
499
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
500
|
+
"Set ",
|
|
501
|
+
/* @__PURE__ */ jsx("code", { children: "iconOnly" }),
|
|
502
|
+
" on an option and keep its ",
|
|
503
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
504
|
+
": the icon is centred, the label becomes what screen readers say, and it shows as a tooltip on hover and keyboard focus. Drop the words only where the icons are well known, like text alignment in the page builder."
|
|
505
|
+
] }),
|
|
506
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
507
|
+
code: `
|
|
508
|
+
<SegmentedControl
|
|
509
|
+
aria-label="Text alignment"
|
|
510
|
+
options={[
|
|
511
|
+
{ value: 'left', label: 'Align left', icon: <TextAlignLeftIcon />, iconOnly: true },
|
|
512
|
+
{ value: 'center', label: 'Align centre', icon: <TextAlignCenterIcon />, iconOnly: true },
|
|
513
|
+
{ value: 'right', label: 'Align right', icon: <TextAlignRightIcon />, iconOnly: true },
|
|
514
|
+
]}
|
|
515
|
+
/>`,
|
|
516
|
+
children: /* @__PURE__ */ jsx(SegmentedControl, {
|
|
517
|
+
"aria-label": "Text alignment",
|
|
518
|
+
options: [
|
|
519
|
+
{
|
|
520
|
+
value: "left",
|
|
521
|
+
label: "Align left",
|
|
522
|
+
icon: /* @__PURE__ */ jsx(TextAlignLeftIcon, {}),
|
|
523
|
+
iconOnly: true
|
|
524
|
+
},
|
|
525
|
+
{
|
|
526
|
+
value: "center",
|
|
527
|
+
label: "Align centre",
|
|
528
|
+
icon: /* @__PURE__ */ jsx(TextAlignCenterIcon, {}),
|
|
529
|
+
iconOnly: true
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
value: "right",
|
|
533
|
+
label: "Align right",
|
|
534
|
+
icon: /* @__PURE__ */ jsx(TextAlignRightIcon, {}),
|
|
535
|
+
iconOnly: true
|
|
536
|
+
}
|
|
537
|
+
]
|
|
538
|
+
})
|
|
539
|
+
})
|
|
540
|
+
})]
|
|
541
|
+
}),
|
|
542
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
543
|
+
id: "tooltips",
|
|
544
|
+
title: "Tooltips",
|
|
545
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
546
|
+
"An icon-only option shows its ",
|
|
547
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
548
|
+
" in a tooltip on hover and on keyboard focus, so the name is on screen and not only read out. Give any option a ",
|
|
549
|
+
/* @__PURE__ */ jsx("code", { children: "tooltip" }),
|
|
550
|
+
" of its own, a short sentence about what it does, and a ",
|
|
551
|
+
/* @__PURE__ */ jsx("code", { children: "shortcut" }),
|
|
552
|
+
" to show its keys after the words. ",
|
|
553
|
+
/* @__PURE__ */ jsx("code", { children: "tooltip: false" }),
|
|
554
|
+
" ",
|
|
555
|
+
"turns one off."
|
|
556
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
557
|
+
"The tooltips share their timing: once one is open, the next opens at once as the pointer moves along.",
|
|
558
|
+
" ",
|
|
559
|
+
/* @__PURE__ */ jsx("code", { children: "tooltipSide=\"bottom\"" }),
|
|
560
|
+
" opens them below, for a control in a top bar."
|
|
561
|
+
] })] }),
|
|
562
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
563
|
+
code: `
|
|
564
|
+
<SegmentedControl
|
|
565
|
+
aria-label="Preview device"
|
|
566
|
+
size="sm"
|
|
567
|
+
tooltipSide="bottom"
|
|
568
|
+
options={[
|
|
569
|
+
{ value: 'desktop', label: 'Desktop', icon: <DesktopIcon />, iconOnly: true },
|
|
570
|
+
{ value: 'tablet', label: 'Tablet', icon: <DeviceTabletIcon />, iconOnly: true },
|
|
571
|
+
{ value: 'mobile', label: 'Mobile', icon: <DeviceMobileIcon />, iconOnly: true },
|
|
572
|
+
]}
|
|
573
|
+
/>
|
|
574
|
+
<SegmentedControl
|
|
575
|
+
aria-label="Editor mode"
|
|
576
|
+
size="sm"
|
|
577
|
+
options={[
|
|
578
|
+
{ value: 'basic', label: 'Basic', tooltip: 'The settings most pages need' },
|
|
579
|
+
{ value: 'pro', label: 'Pro', tooltip: 'Every setting, for fine control' },
|
|
580
|
+
]}
|
|
581
|
+
/>`,
|
|
582
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
583
|
+
className: "segmented-control-row",
|
|
584
|
+
children: [/* @__PURE__ */ jsx(SegmentedControl, {
|
|
585
|
+
"aria-label": "Preview device",
|
|
586
|
+
size: "sm",
|
|
587
|
+
tooltipSide: "bottom",
|
|
588
|
+
options: PREVIEW_DEVICES
|
|
589
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
590
|
+
"aria-label": "Editor mode",
|
|
591
|
+
size: "sm",
|
|
592
|
+
options: [{
|
|
593
|
+
value: "basic",
|
|
594
|
+
label: "Basic",
|
|
595
|
+
tooltip: "The settings most pages need"
|
|
596
|
+
}, {
|
|
597
|
+
value: "pro",
|
|
598
|
+
label: "Pro",
|
|
599
|
+
tooltip: "Every setting, for fine control"
|
|
600
|
+
}]
|
|
601
|
+
})]
|
|
602
|
+
})
|
|
603
|
+
})
|
|
604
|
+
}),
|
|
605
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
606
|
+
id: "multiple",
|
|
607
|
+
title: "Several at once",
|
|
608
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
609
|
+
/* @__PURE__ */ jsx("code", { children: "type=\"multiple\"" }),
|
|
610
|
+
" makes a row of toggles: any number can be on, each with a raised thumb of its own, as bold, italic and underline are in a text editor. ",
|
|
611
|
+
/* @__PURE__ */ jsx("code", { children: "value" }),
|
|
612
|
+
" is an array, and",
|
|
613
|
+
" ",
|
|
614
|
+
/* @__PURE__ */ jsx("code", { children: "onValueChange" }),
|
|
615
|
+
" reports every option that is on, in the options' order. It is a group of pressed buttons rather than a radio group: the arrow keys move along the row, and Space or Enter turns one on or off."
|
|
616
|
+
] }),
|
|
617
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
618
|
+
code: `
|
|
619
|
+
const [styles, setStyles] = useState<TextStyle[]>(['bold'])
|
|
620
|
+
|
|
621
|
+
<SegmentedControl
|
|
622
|
+
type="multiple"
|
|
623
|
+
aria-label="Text style"
|
|
624
|
+
size="sm"
|
|
625
|
+
value={styles}
|
|
626
|
+
onValueChange={setStyles}
|
|
627
|
+
options={[
|
|
628
|
+
{ value: 'bold', label: 'Bold', icon: <TextBIcon />, iconOnly: true, shortcut: ['mod', 'B'] },
|
|
629
|
+
{ value: 'italic', label: 'Italic', icon: <TextItalicIcon />, iconOnly: true, shortcut: ['mod', 'I'] },
|
|
630
|
+
{ value: 'underline', label: 'Underline', icon: <TextUnderlineIcon />, iconOnly: true, shortcut: ['mod', 'U'] },
|
|
631
|
+
]}
|
|
632
|
+
/>`,
|
|
633
|
+
children: /* @__PURE__ */ jsx(TextStyleChoice, {})
|
|
634
|
+
})
|
|
635
|
+
}),
|
|
636
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
637
|
+
id: "grid",
|
|
638
|
+
title: "A grid",
|
|
639
|
+
description: /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsxs("p", { children: [
|
|
640
|
+
/* @__PURE__ */ jsx("code", { children: "columns" }),
|
|
641
|
+
" lays the options in a grid of equal columns that fills its container, as the font style pair does in an inspector panel. ",
|
|
642
|
+
/* @__PURE__ */ jsx("code", { children: "columns=\"wrap\"" }),
|
|
643
|
+
" lets them run onto more rows instead. Either way the track never scrolls sideways: it grows down, and rounds off at the curve of one row, so a single row is still the pill."
|
|
644
|
+
] }) }),
|
|
645
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
646
|
+
align: "fill",
|
|
647
|
+
code: `
|
|
648
|
+
<SegmentedControl
|
|
649
|
+
aria-label="Font style"
|
|
650
|
+
columns={2}
|
|
651
|
+
options={[
|
|
652
|
+
{ value: 'normal', label: 'Normal' },
|
|
653
|
+
{ value: 'italic', label: <span style={{ fontStyle: 'italic' }}>Italic</span> },
|
|
654
|
+
]}
|
|
655
|
+
/>
|
|
656
|
+
<SegmentedControl aria-label="Card layout" columns={3} options={layouts} />`,
|
|
657
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
658
|
+
className: "segmented-control-inspector",
|
|
659
|
+
children: [/* @__PURE__ */ jsx(SegmentedControl, {
|
|
660
|
+
"aria-label": "Font style",
|
|
661
|
+
columns: 2,
|
|
662
|
+
size: "sm",
|
|
663
|
+
defaultValue: "normal",
|
|
664
|
+
options: [{
|
|
665
|
+
value: "normal",
|
|
666
|
+
label: "Normal"
|
|
667
|
+
}, {
|
|
668
|
+
value: "italic",
|
|
669
|
+
label: /* @__PURE__ */ jsx("span", {
|
|
670
|
+
style: { fontStyle: "italic" },
|
|
671
|
+
children: "Italic"
|
|
672
|
+
})
|
|
673
|
+
}]
|
|
674
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
675
|
+
"aria-label": "Card layout",
|
|
676
|
+
columns: 3,
|
|
677
|
+
size: "sm",
|
|
678
|
+
defaultValue: "grid-3",
|
|
679
|
+
options: [
|
|
680
|
+
{
|
|
681
|
+
value: "grid-2",
|
|
682
|
+
label: "2 across"
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
value: "grid-3",
|
|
686
|
+
label: "3 across"
|
|
687
|
+
},
|
|
688
|
+
{
|
|
689
|
+
value: "grid-4",
|
|
690
|
+
label: "4 across"
|
|
691
|
+
},
|
|
692
|
+
{
|
|
693
|
+
value: "list",
|
|
694
|
+
label: "List"
|
|
695
|
+
},
|
|
696
|
+
{
|
|
697
|
+
value: "carousel",
|
|
698
|
+
label: "Carousel"
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
value: "masonry",
|
|
702
|
+
label: "Masonry"
|
|
703
|
+
}
|
|
704
|
+
]
|
|
705
|
+
})]
|
|
706
|
+
})
|
|
707
|
+
})
|
|
708
|
+
}),
|
|
709
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
710
|
+
id: "caption",
|
|
711
|
+
title: "A caption",
|
|
712
|
+
description: /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "caption" }), " writes the chosen option's name in a quiet line under the track, for icon-only options whose choice has no words on screen. Pass a function for words of your own. It is for the eye: the chosen option already says its name to assistive tech, so the caption is hidden from it."] }),
|
|
713
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
714
|
+
code: `
|
|
715
|
+
<SegmentedControl aria-label="Text alignment" size="sm" caption options={alignment} defaultValue="left" />`,
|
|
716
|
+
children: /* @__PURE__ */ jsx(SegmentedControl, {
|
|
717
|
+
"aria-label": "Text alignment",
|
|
718
|
+
size: "sm",
|
|
719
|
+
caption: true,
|
|
720
|
+
options: ALIGNMENT,
|
|
721
|
+
defaultValue: "left"
|
|
722
|
+
})
|
|
723
|
+
})
|
|
724
|
+
}),
|
|
725
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
726
|
+
id: "chips",
|
|
727
|
+
title: "Chips",
|
|
728
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
729
|
+
/* @__PURE__ */ jsx("code", { children: "variant=\"chips\"" }),
|
|
730
|
+
" drops the track for loose pills: the chosen one in the accent wash with a teal hairline inside it, the others lighting on hover. Use it for a second-level choice that sits inside something else, such as \"Group by\" over a variant table, where a full track would be too heavy.",
|
|
731
|
+
" ",
|
|
732
|
+
/* @__PURE__ */ jsx("code", { children: "size=\"xs\"" }),
|
|
733
|
+
" makes them 24px, a size only chips have."
|
|
734
|
+
] }), /* @__PURE__ */ jsxs("p", { children: [
|
|
735
|
+
"Tabs have the same look, for a section's sub-tabs: ",
|
|
736
|
+
/* @__PURE__ */ jsx("code", { children: "<TabsList variant=\"chips\">" }),
|
|
737
|
+
"."
|
|
738
|
+
] })] }),
|
|
739
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
740
|
+
code: `
|
|
741
|
+
<SegmentedControl aria-label="Group by" variant="chips" size="xs" options={groupBy} defaultValue="colour" />
|
|
742
|
+
<SegmentedControl aria-label="Group by" variant="chips" size="sm" options={groupBy} defaultValue="colour" />`,
|
|
743
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
744
|
+
className: "segmented-control-rows",
|
|
745
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
746
|
+
className: "segmented-control-chips-row",
|
|
747
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
748
|
+
className: "segmented-control-chips-row__label",
|
|
749
|
+
children: "Group by"
|
|
750
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
751
|
+
"aria-label": "Group by",
|
|
752
|
+
variant: "chips",
|
|
753
|
+
size: "xs",
|
|
754
|
+
options: GROUP_BY,
|
|
755
|
+
defaultValue: "colour"
|
|
756
|
+
})]
|
|
757
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
758
|
+
"aria-label": "Group by",
|
|
759
|
+
variant: "chips",
|
|
760
|
+
size: "sm",
|
|
761
|
+
options: GROUP_BY,
|
|
762
|
+
defaultValue: "colour"
|
|
763
|
+
})]
|
|
764
|
+
})
|
|
765
|
+
})
|
|
766
|
+
}),
|
|
767
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
768
|
+
id: "disabled",
|
|
769
|
+
title: "Disabled",
|
|
770
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
771
|
+
"An option with ",
|
|
772
|
+
/* @__PURE__ */ jsx("code", { children: "disabled: true" }),
|
|
773
|
+
" drops to 45%, cannot be chosen and is skipped by the arrow keys. Say nearby why it is off. ",
|
|
774
|
+
/* @__PURE__ */ jsx("code", { children: "disabled" }),
|
|
775
|
+
" on the control turns off every option."
|
|
776
|
+
] }),
|
|
777
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
778
|
+
code: `
|
|
779
|
+
<SegmentedControl
|
|
780
|
+
aria-label="Delivery method"
|
|
781
|
+
defaultValue="ship"
|
|
782
|
+
options={[
|
|
783
|
+
{ value: 'ship', label: 'Ship' },
|
|
784
|
+
{ value: 'collect', label: 'Click and collect' },
|
|
785
|
+
{ value: 'local', label: 'Local delivery', disabled: true },
|
|
786
|
+
]}
|
|
787
|
+
/>
|
|
788
|
+
<SegmentedControl aria-label="Date range" options={ranges} defaultValue="30d" disabled />`,
|
|
789
|
+
caption: "Local delivery is off until it is set up in Shipping settings.",
|
|
790
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
791
|
+
className: "segmented-control-rows",
|
|
792
|
+
children: [/* @__PURE__ */ jsx(SegmentedControl, {
|
|
793
|
+
"aria-label": "Delivery method",
|
|
794
|
+
defaultValue: "ship",
|
|
795
|
+
options: [
|
|
796
|
+
{
|
|
797
|
+
value: "ship",
|
|
798
|
+
label: "Ship"
|
|
799
|
+
},
|
|
800
|
+
{
|
|
801
|
+
value: "collect",
|
|
802
|
+
label: "Click and collect"
|
|
803
|
+
},
|
|
804
|
+
{
|
|
805
|
+
value: "local",
|
|
806
|
+
label: "Local delivery",
|
|
807
|
+
disabled: true
|
|
808
|
+
}
|
|
809
|
+
]
|
|
810
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
811
|
+
"aria-label": "Date range",
|
|
812
|
+
options: RANGES,
|
|
813
|
+
defaultValue: "30d",
|
|
814
|
+
disabled: true
|
|
815
|
+
})]
|
|
816
|
+
})
|
|
817
|
+
})
|
|
818
|
+
}),
|
|
819
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
820
|
+
id: "keyboard",
|
|
821
|
+
title: "Keyboard",
|
|
822
|
+
description: /* @__PURE__ */ jsx("p", { children: "It behaves as a radio group: one Tab stop, and the arrows move the choice." }),
|
|
823
|
+
children: [/* @__PURE__ */ jsx(DocTable, {
|
|
824
|
+
columns: ["Key", "What it does"],
|
|
825
|
+
rows: [
|
|
826
|
+
["Tab", "Moves focus to the chosen option. The whole control is one Tab stop."],
|
|
827
|
+
["Right and down arrows", "Choose the next option, skipping disabled ones, and wrap round from the last to the first."],
|
|
828
|
+
["Left and up arrows", "Choose the previous option, the same way. Left and right swap in right-to-left layouts."],
|
|
829
|
+
["Home, End", "Choose the first or the last enabled option."]
|
|
830
|
+
]
|
|
831
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
832
|
+
title: "Several at once",
|
|
833
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
834
|
+
"With ",
|
|
835
|
+
/* @__PURE__ */ jsx("code", { children: "type=\"multiple\"" }),
|
|
836
|
+
", moving and choosing are apart."
|
|
837
|
+
] }),
|
|
838
|
+
children: /* @__PURE__ */ jsx(DocTable, {
|
|
839
|
+
columns: ["Key", "What it does"],
|
|
840
|
+
rows: [
|
|
841
|
+
["Tab", "Moves focus to the first option that is on, or the first option. The whole row is one Tab stop."],
|
|
842
|
+
["Arrows, Home, End", "Move focus along the row, without changing anything."],
|
|
843
|
+
["Space, Enter", "Turn the focused option on or off."]
|
|
844
|
+
]
|
|
845
|
+
})
|
|
846
|
+
})]
|
|
847
|
+
}),
|
|
848
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
849
|
+
id: "motion",
|
|
850
|
+
title: "The gliding thumb",
|
|
851
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("p", { children: "There is one thumb, and it moves: a raised pill (white in light, a step lighter than the track in dark) that glides to the new choice on the snappy spring. The chosen label turns semibold without changing width, because an invisible semibold copy of the text holds the space." }), /* @__PURE__ */ jsx("p", { children: "Under reduced motion the thumb jumps straight to the new option, and only the text colour fades. Click along the options, or use the arrow keys." })] }),
|
|
852
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
853
|
+
code: `
|
|
854
|
+
<SegmentedControl
|
|
855
|
+
aria-label="Date range"
|
|
856
|
+
defaultValue="30d"
|
|
857
|
+
options={[
|
|
858
|
+
{ value: 'today', label: 'Today' },
|
|
859
|
+
{ value: '7d', label: '7 days' },
|
|
860
|
+
{ value: '30d', label: '30 days' },
|
|
861
|
+
{ value: '90d', label: '90 days' },
|
|
862
|
+
{ value: '12m', label: '12 months' },
|
|
863
|
+
]}
|
|
864
|
+
/>`,
|
|
865
|
+
children: /* @__PURE__ */ jsx(SegmentedControl, {
|
|
866
|
+
"aria-label": "Date range",
|
|
867
|
+
defaultValue: "30d",
|
|
868
|
+
options: [
|
|
869
|
+
{
|
|
870
|
+
value: "today",
|
|
871
|
+
label: "Today"
|
|
872
|
+
},
|
|
873
|
+
{
|
|
874
|
+
value: "7d",
|
|
875
|
+
label: "7 days"
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
value: "30d",
|
|
879
|
+
label: "30 days"
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
value: "90d",
|
|
883
|
+
label: "90 days"
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
value: "12m",
|
|
887
|
+
label: "12 months"
|
|
888
|
+
}
|
|
889
|
+
]
|
|
890
|
+
})
|
|
891
|
+
}), /* @__PURE__ */ jsx(Note, { children: "The width is only held when the label is a string. Pass words as plain strings: text wrapped in an element still turns semibold, and nudges the row when it does." })]
|
|
892
|
+
}),
|
|
893
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
894
|
+
id: "both-themes",
|
|
895
|
+
title: "In both themes",
|
|
896
|
+
description: /* @__PURE__ */ jsx("p", { children: "Text, icons and icon only, light and dark side by side. In dark the thumb is a lighter step of the track." }),
|
|
897
|
+
children: /* @__PURE__ */ jsx(ThemePair, { children: /* @__PURE__ */ jsxs("div", {
|
|
898
|
+
className: "segmented-control-rows",
|
|
899
|
+
children: [
|
|
900
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
901
|
+
"aria-label": "Date range",
|
|
902
|
+
options: RANGES,
|
|
903
|
+
defaultValue: "30d"
|
|
904
|
+
}),
|
|
905
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
906
|
+
"aria-label": "Product layout",
|
|
907
|
+
size: "sm",
|
|
908
|
+
options: [{
|
|
909
|
+
value: "grid",
|
|
910
|
+
label: "Grid",
|
|
911
|
+
icon: /* @__PURE__ */ jsx(SquaresFourIcon, {})
|
|
912
|
+
}, {
|
|
913
|
+
value: "list",
|
|
914
|
+
label: "List",
|
|
915
|
+
icon: /* @__PURE__ */ jsx(RowsIcon, {})
|
|
916
|
+
}]
|
|
917
|
+
}),
|
|
918
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
919
|
+
"aria-label": "Text alignment",
|
|
920
|
+
size: "sm",
|
|
921
|
+
defaultValue: "center",
|
|
922
|
+
options: [
|
|
923
|
+
{
|
|
924
|
+
value: "left",
|
|
925
|
+
label: "Align left",
|
|
926
|
+
icon: /* @__PURE__ */ jsx(TextAlignLeftIcon, {}),
|
|
927
|
+
iconOnly: true
|
|
928
|
+
},
|
|
929
|
+
{
|
|
930
|
+
value: "center",
|
|
931
|
+
label: "Align centre",
|
|
932
|
+
icon: /* @__PURE__ */ jsx(TextAlignCenterIcon, {}),
|
|
933
|
+
iconOnly: true
|
|
934
|
+
},
|
|
935
|
+
{
|
|
936
|
+
value: "right",
|
|
937
|
+
label: "Align right",
|
|
938
|
+
icon: /* @__PURE__ */ jsx(TextAlignRightIcon, {}),
|
|
939
|
+
iconOnly: true
|
|
940
|
+
}
|
|
941
|
+
]
|
|
942
|
+
}),
|
|
943
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
944
|
+
type: "multiple",
|
|
945
|
+
"aria-label": "Text style",
|
|
946
|
+
size: "sm",
|
|
947
|
+
options: TEXT_STYLES,
|
|
948
|
+
defaultValue: ["bold", "italic"]
|
|
949
|
+
}),
|
|
950
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
951
|
+
"aria-label": "Group by",
|
|
952
|
+
variant: "chips",
|
|
953
|
+
size: "xs",
|
|
954
|
+
options: GROUP_BY,
|
|
955
|
+
defaultValue: "size"
|
|
956
|
+
})
|
|
957
|
+
]
|
|
958
|
+
}) })
|
|
959
|
+
}),
|
|
960
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
961
|
+
id: "guidelines",
|
|
962
|
+
title: "Guidelines",
|
|
963
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
964
|
+
do: {
|
|
965
|
+
children: /* @__PURE__ */ jsx(SegmentedControl, {
|
|
966
|
+
"aria-label": "Date range",
|
|
967
|
+
defaultValue: "7d",
|
|
968
|
+
options: [
|
|
969
|
+
{
|
|
970
|
+
value: "today",
|
|
971
|
+
label: "Today"
|
|
972
|
+
},
|
|
973
|
+
{
|
|
974
|
+
value: "7d",
|
|
975
|
+
label: "7 days"
|
|
976
|
+
},
|
|
977
|
+
{
|
|
978
|
+
value: "30d",
|
|
979
|
+
label: "30 days"
|
|
980
|
+
}
|
|
981
|
+
]
|
|
982
|
+
}),
|
|
983
|
+
caption: "A few short options that change the view in place, at once."
|
|
984
|
+
},
|
|
985
|
+
dont: {
|
|
986
|
+
children: /* @__PURE__ */ jsx(SegmentedControl, {
|
|
987
|
+
"aria-label": "Order pages",
|
|
988
|
+
defaultValue: "orders",
|
|
989
|
+
options: [
|
|
990
|
+
{
|
|
991
|
+
value: "orders",
|
|
992
|
+
label: "Orders"
|
|
993
|
+
},
|
|
994
|
+
{
|
|
995
|
+
value: "drafts",
|
|
996
|
+
label: "Drafts"
|
|
997
|
+
},
|
|
998
|
+
{
|
|
999
|
+
value: "abandoned",
|
|
1000
|
+
label: "Abandoned"
|
|
1001
|
+
}
|
|
1002
|
+
]
|
|
1003
|
+
}),
|
|
1004
|
+
caption: "Moving between pages is navigation: use links. A segmented control only changes the view in place."
|
|
1005
|
+
}
|
|
1006
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1007
|
+
"Two to five options, one or two words each. With more, or with long names, use a menu.",
|
|
1008
|
+
"It changes what is on screen straight away and never waits for a Save button.",
|
|
1009
|
+
"Keep the options in a natural order, such as shortest period to longest, and start on the one people use most.",
|
|
1010
|
+
"Drop the words only when every icon is unmistakable, and keep a hidden label on each."
|
|
1011
|
+
] })]
|
|
1012
|
+
}),
|
|
1013
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
1014
|
+
id: "accessibility",
|
|
1015
|
+
title: "Accessibility",
|
|
1016
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1017
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1018
|
+
"A ",
|
|
1019
|
+
/* @__PURE__ */ jsx("code", { children: "radiogroup" }),
|
|
1020
|
+
" named by the required ",
|
|
1021
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
1022
|
+
", with each option a",
|
|
1023
|
+
" ",
|
|
1024
|
+
/* @__PURE__ */ jsx("code", { children: "radio" }),
|
|
1025
|
+
" button carrying ",
|
|
1026
|
+
/* @__PURE__ */ jsx("code", { children: "aria-checked" }),
|
|
1027
|
+
"."
|
|
1028
|
+
] }),
|
|
1029
|
+
"One Tab stop: focus lands on the chosen option, and the arrow keys move and choose together.",
|
|
1030
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1031
|
+
"Disabled options are native disabled and skipped by the arrows. ",
|
|
1032
|
+
/* @__PURE__ */ jsx("code", { children: "disabled" }),
|
|
1033
|
+
" on the control also sets ",
|
|
1034
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
1035
|
+
" on the group."
|
|
1036
|
+
] }),
|
|
1037
|
+
"Icons are hidden from assistive tech, so an icon-only option needs its hidden text label, which also shows as its tooltip.",
|
|
1038
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1039
|
+
"With ",
|
|
1040
|
+
/* @__PURE__ */ jsx("code", { children: "type=\"multiple\"" }),
|
|
1041
|
+
" it is a ",
|
|
1042
|
+
/* @__PURE__ */ jsx("code", { children: "group" }),
|
|
1043
|
+
" of buttons carrying ",
|
|
1044
|
+
/* @__PURE__ */ jsx("code", { children: "aria-pressed" }),
|
|
1045
|
+
", with one Tab stop: the arrows move focus, and Space or Enter toggles."
|
|
1046
|
+
] }),
|
|
1047
|
+
"A caption is hidden from assistive tech: the chosen option already says its name.",
|
|
1048
|
+
"Under forced colours the chosen option keeps a system outline, as its thumb fill is dropped.",
|
|
1049
|
+
"The focus ring is teal, 2px, just outside the option, for keyboard focus only.",
|
|
1050
|
+
"Under reduced motion the thumb jumps instead of gliding."
|
|
1051
|
+
] })
|
|
1052
|
+
}),
|
|
1053
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1054
|
+
id: "props",
|
|
1055
|
+
title: "Props",
|
|
1056
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1057
|
+
"Other attributes, such as ",
|
|
1058
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
1059
|
+
", go to the group."
|
|
1060
|
+
] }),
|
|
1061
|
+
children: [/* @__PURE__ */ jsx(PropsTable, {
|
|
1062
|
+
title: "SegmentedControl",
|
|
1063
|
+
rows: [
|
|
1064
|
+
{
|
|
1065
|
+
name: "options",
|
|
1066
|
+
type: "SegmentedControlOption<V>[]",
|
|
1067
|
+
required: true,
|
|
1068
|
+
description: "The choices, in order. See Option below."
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
name: "aria-label",
|
|
1072
|
+
type: "string",
|
|
1073
|
+
description: "Names the group, e.g. \"Date range\". Give this or aria-labelledby: the control has no visible label."
|
|
1074
|
+
},
|
|
1075
|
+
{
|
|
1076
|
+
name: "aria-labelledby",
|
|
1077
|
+
type: "string",
|
|
1078
|
+
description: "The id of a visible heading that names the group, in place of aria-label."
|
|
1079
|
+
},
|
|
1080
|
+
{
|
|
1081
|
+
name: "type",
|
|
1082
|
+
type: "'single' | 'multiple'",
|
|
1083
|
+
default: "'single'",
|
|
1084
|
+
description: "One option at a time (a radio group), or any number on at once (a row of toggles)."
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
name: "value",
|
|
1088
|
+
type: "V | V[]",
|
|
1089
|
+
description: "The chosen value, or with type=\"multiple\" the options that are on, when you control it."
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
name: "defaultValue",
|
|
1093
|
+
type: "V | V[]",
|
|
1094
|
+
description: "The starting value when uncontrolled. Defaults to the first enabled option, or none with type=\"multiple\"."
|
|
1095
|
+
},
|
|
1096
|
+
{
|
|
1097
|
+
name: "onValueChange",
|
|
1098
|
+
type: "(value: V) => void | (value: V[]) => void",
|
|
1099
|
+
description: "Called when the choice changes, by click or by arrow key; with type=\"multiple\", with every option that is on."
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
name: "variant",
|
|
1103
|
+
type: "'track' | 'chips'",
|
|
1104
|
+
default: "'track'",
|
|
1105
|
+
description: "A pill track with a raised thumb, or loose pills with the chosen one in the accent wash."
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: "size",
|
|
1109
|
+
type: "'xs' | 'sm' | 'md'",
|
|
1110
|
+
default: "'md'",
|
|
1111
|
+
description: "30 or 36px tall; xs is 24px, for chips (the track draws it at sm)."
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
name: "columns",
|
|
1115
|
+
type: "number | 'wrap'",
|
|
1116
|
+
description: "A grid of this many equal columns that fills its container, or options that wrap onto more rows. Never scrolls."
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
name: "caption",
|
|
1120
|
+
type: "boolean | (chosen) => ReactNode",
|
|
1121
|
+
description: "A quiet line under the track naming the choice, or what the function makes of the chosen options."
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
name: "tooltipSide",
|
|
1125
|
+
type: "'top' | 'bottom'",
|
|
1126
|
+
default: "'top'",
|
|
1127
|
+
description: "Where the options’ tooltips open."
|
|
1128
|
+
},
|
|
1129
|
+
{
|
|
1130
|
+
name: "fullWidth",
|
|
1131
|
+
type: "boolean",
|
|
1132
|
+
default: "false",
|
|
1133
|
+
description: "Stretch to the container, options sharing the width equally."
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
name: "disabled",
|
|
1137
|
+
type: "boolean",
|
|
1138
|
+
default: "false",
|
|
1139
|
+
description: "Turns off every option."
|
|
1140
|
+
}
|
|
1141
|
+
]
|
|
1142
|
+
}), /* @__PURE__ */ jsx(PropsTable, {
|
|
1143
|
+
title: "Option",
|
|
1144
|
+
rows: [
|
|
1145
|
+
{
|
|
1146
|
+
name: "value",
|
|
1147
|
+
type: "V",
|
|
1148
|
+
required: true,
|
|
1149
|
+
description: "A string. What onValueChange reports."
|
|
1150
|
+
},
|
|
1151
|
+
{
|
|
1152
|
+
name: "label",
|
|
1153
|
+
type: "ReactNode",
|
|
1154
|
+
required: true,
|
|
1155
|
+
description: "The words. With iconOnly, what screen readers say."
|
|
1156
|
+
},
|
|
1157
|
+
{
|
|
1158
|
+
name: "icon",
|
|
1159
|
+
type: "ReactNode",
|
|
1160
|
+
description: "Leading icon: 15px, or 13px at sm."
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
name: "iconOnly",
|
|
1164
|
+
type: "boolean",
|
|
1165
|
+
default: "false",
|
|
1166
|
+
description: "Show the icon alone, centred on a round thumb, with the label as its tooltip. Needs an icon."
|
|
1167
|
+
},
|
|
1168
|
+
{
|
|
1169
|
+
name: "tooltip",
|
|
1170
|
+
type: "ReactNode | false",
|
|
1171
|
+
description: "A tooltip of its own on hover and keyboard focus. Icon-only options, and options with a shortcut, show the label by default; false for none."
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
name: "shortcut",
|
|
1175
|
+
type: "string[]",
|
|
1176
|
+
description: "Keys drawn as keycaps after the tooltip's words, e.g. ['mod', 'B']. Visual only."
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
name: "disabled",
|
|
1180
|
+
type: "boolean",
|
|
1181
|
+
description: "Cannot be chosen; skipped by the arrow keys."
|
|
1182
|
+
}
|
|
1183
|
+
]
|
|
1184
|
+
})]
|
|
1185
|
+
})
|
|
1186
|
+
]
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
//#endregion
|
|
1190
|
+
export { Page, Preview };
|