@orbitcommerce/constellation-docs 1.0.0 → 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/dist/docs.css +14764 -2237
- package/dist/index.js +2 -2
- package/dist/pages/{Playground-CNbBbErC.js → Playground-Mk1yIWXb.js} +2 -2
- 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-BDmScEny.js → _figures-data-DaDvB7Nm.js} +5 -5
- package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
- package/dist/pages/{_overlays-specimens-Dpn6oiyH.js → _overlays-specimens-bawR331Z.js} +33 -23
- 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-BD4e6QTh.js → alert-D3i7xZTU.js} +195 -50
- package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
- package/dist/pages/{app-shell-KbA-nRqZ.js → app-shell-D4hdlHps.js} +133 -54
- package/dist/pages/{area-chart-B91dLcGo.js → area-chart-BEWFwiB2.js} +183 -27
- package/dist/pages/{avatar-DPPHXJAu.js → avatar-BFEqQViw.js} +194 -12
- package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
- package/dist/pages/{badge-C9JR0thI.js → badge-0-PyMrih.js} +441 -135
- 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-D3V912P4.js → button-DAyfssDY.js} +276 -79
- package/dist/pages/{calendar-DSDZ9nRH.js → calendar-Ds7KsgSI.js} +69 -17
- 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-BwuO8xAv.js → colour-q2ntvI0w.js} +496 -20
- package/dist/pages/column-mapper-TsTG39cl.js +502 -0
- package/dist/pages/combobox-DvK2j5tI.js +1334 -0
- package/dist/pages/{command-palette-xAD7fOg6.js → command-palette-CJ7uBA04.js} +201 -58
- 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-BYSa816m.js → date-picker-GdBciR99.js} +186 -38
- package/dist/pages/date-time-BLKCXtVZ.js +678 -0
- package/dist/pages/{delta-CtAo0eIM.js → delta-CNAGv8JY.js} +266 -61
- 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-BNOb7AqR.js → docs-lM2UBSir.js} +20 -15
- 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-CoPFzzKz.js → figure-tabs-QOeQMY6N.js} +153 -35
- 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-CFQwDtC9.js → home-dashboard-CxPmvduE.js} +21 -18
- 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-C9eSVPPW.js → icon-button-Bu4Gj5sy.js} +370 -31
- package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
- package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
- package/dist/pages/{icons-sxkTs5Ob.js → icons-CJ9Aar3d.js} +315 -52
- 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-DpsX8G_n.js → installation-C3UcpQJT.js} +112 -29
- package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
- package/dist/pages/kanban-Dy9sPAI0.js +740 -0
- package/dist/pages/{kbd-cNfDoikz.js → kbd-UNj4zqxn.js} +15 -14
- 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-ClvLn9Lb.js → live-globe-95ROMhGQ.js} +191 -47
- 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-BfGF1Pq9.js → logo-B38rnzoq.js} +13 -13
- 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-by2sgQ09.js → menu-NrLYKqKp.js} +623 -109
- 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-BvTGc2Dk.js → motion-CrXtiBvA.js} +20 -10
- package/dist/pages/number-input-CuyMZg18.js +968 -0
- package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
- package/dist/pages/{orbit-spinner-Dil1Z3Oy.js → orbit-spinner-Dxv5qAhr.js} +30 -14
- package/dist/pages/otp-input-CVRoX1mw.js +591 -0
- package/dist/pages/{overview-BPEbZQ6g.js → overview-LA9XRhZc.js} +4 -4
- package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
- package/dist/pages/{pagination-BBUnGvv5.js → pagination-C1EgVtW4.js} +74 -29
- 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-Db1gLDpb.js → popover-C3Oar9D5.js} +76 -14
- 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-CeAIOIdt.js → principles-pnDyfHpK.js} +9 -9
- 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-CkdBWWfG.js → radio-group-C-4tg6FS.js} +580 -18
- 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-Dvo684UJ.js → release-Cs6tl16C.js} +4 -1
- 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-qmvH84Mq.js → rolling-number-GR3Cyfpz.js} +12 -12
- 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-BN7MWGQ4.js → search-field-D1uG7R6A.js} +15 -15
- 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-CTbIpRBW.js → segmented-control-D-FB1K1T.js} +450 -37
- package/dist/pages/{select-DguELoRR.js → select-DZ43NpOm.js} +22 -17
- package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
- package/dist/pages/{separator-CPZub9pv.js → separator-CFwqRvfO.js} +99 -22
- package/dist/pages/serp-preview-BGwORjmo.js +346 -0
- package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
- package/dist/pages/{shape-DKvA0YKr.js → shape-DzniHAVT.js} +10 -10
- 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-DMMYGbHn.js → sparkline-D3aavCly.js} +301 -22
- 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-B-Qe4kcT.js → switch-C93K6j9h.js} +151 -51
- package/dist/pages/table-CL0vomno.js +3225 -0
- package/dist/pages/{tabs-B4M-usCV.js → tabs-Dh0mUsLw.js} +256 -21
- package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
- package/dist/pages/task-card-Dv0sR1-w.js +295 -0
- package/dist/pages/{textarea-fTuUZRQb.js → textarea-CCM-SnGN.js} +271 -15
- 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-CKP03zjy.js → toast-zXLRiMRT.js} +240 -25
- package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
- package/dist/pages/toolbar-B9l_fHKy.js +754 -0
- package/dist/pages/{tooltip-CBYil3kt.js → tooltip-LHtCUkF-.js} +162 -33
- 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-PCbg8Bhg.js → typography-BSijtiRl.js} +153 -12
- 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 +10984 -1108
- package/package.json +2 -2
- package/dist/pages/card-DUggbis3.js +0 -659
- package/dist/pages/checkbox-DwimQaK3.js +0 -365
- package/dist/pages/dialog-BRAf4LMh.js +0 -1451
- package/dist/pages/empty-state-C-mLrXW2.js +0 -417
- package/dist/pages/input-KF9Gkawf.js +0 -1093
- package/dist/pages/registry-CroHzK9I.js +0 -244
- package/dist/pages/skeleton-DLuBhP46.js +0 -561
- package/dist/pages/table-AMoODng4.js +0 -607
|
@@ -0,0 +1,1351 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
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";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Button, Combobox, EmptyState, Field, Input, Repeater, Select } from "@orbitcommerce/constellation";
|
|
7
|
+
//#region src/pages/components/repeater.tsx
|
|
8
|
+
var BANDS = [
|
|
9
|
+
{
|
|
10
|
+
id: "band-standard",
|
|
11
|
+
name: "Standard (3 to 5 days)",
|
|
12
|
+
price: "4.95"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: "band-express",
|
|
16
|
+
name: "Express (next day)",
|
|
17
|
+
price: "9.95"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "band-collect",
|
|
21
|
+
name: "Click and collect",
|
|
22
|
+
price: "0.00"
|
|
23
|
+
}
|
|
24
|
+
];
|
|
25
|
+
var FIVE_BANDS = [
|
|
26
|
+
...BANDS,
|
|
27
|
+
{
|
|
28
|
+
id: "band-saturday",
|
|
29
|
+
name: "Saturday delivery",
|
|
30
|
+
price: "12.50"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: "band-europe",
|
|
34
|
+
name: "Europe (3 to 7 days)",
|
|
35
|
+
price: "14.00"
|
|
36
|
+
}
|
|
37
|
+
];
|
|
38
|
+
/** The gallery tile's one band: a short name, so the name and the price share a line in the tile. */
|
|
39
|
+
var TILE_BAND = {
|
|
40
|
+
id: "band-tile",
|
|
41
|
+
name: "Next day",
|
|
42
|
+
price: "9.95"
|
|
43
|
+
};
|
|
44
|
+
function Preview() {
|
|
45
|
+
return /* @__PURE__ */ jsx(Repeater, {
|
|
46
|
+
className: "repeater-preview",
|
|
47
|
+
items: [TILE_BAND],
|
|
48
|
+
getKey: (item) => item.id,
|
|
49
|
+
renderRow: (item) => /* @__PURE__ */ jsxs("div", {
|
|
50
|
+
className: "repeater-row",
|
|
51
|
+
children: [/* @__PURE__ */ jsx(Input, {
|
|
52
|
+
size: "sm",
|
|
53
|
+
defaultValue: item.name,
|
|
54
|
+
readOnly: true,
|
|
55
|
+
"aria-label": "Band name"
|
|
56
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
57
|
+
size: "sm",
|
|
58
|
+
defaultValue: item.price,
|
|
59
|
+
readOnly: true,
|
|
60
|
+
"aria-label": "Price"
|
|
61
|
+
})]
|
|
62
|
+
}),
|
|
63
|
+
onAdd: () => {},
|
|
64
|
+
onRemove: () => {},
|
|
65
|
+
onMove: () => {}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
/** A small host, as a page keeps its rows: the Repeater owns the chrome, this owns the data. */
|
|
69
|
+
function BandRepeater({ initial, min, max, undo = true, move = true, disabled, empty, labels }) {
|
|
70
|
+
const [bands, setBands] = useState(initial);
|
|
71
|
+
const nextId = useRef(initial.length + 1);
|
|
72
|
+
const change = (id, patch) => setBands((now) => now.map((band) => band.id === id ? {
|
|
73
|
+
...band,
|
|
74
|
+
...patch
|
|
75
|
+
} : band));
|
|
76
|
+
return /* @__PURE__ */ jsx(Repeater, {
|
|
77
|
+
items: bands,
|
|
78
|
+
getKey: (band) => band.id,
|
|
79
|
+
renderRow: (band, state) => /* @__PURE__ */ jsxs("div", {
|
|
80
|
+
className: "repeater-row",
|
|
81
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
82
|
+
label: "Band " + (state.index + 1),
|
|
83
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
84
|
+
value: band.name,
|
|
85
|
+
placeholder: "e.g. Express (next day)",
|
|
86
|
+
onChange: (event) => change(band.id, { name: event.target.value })
|
|
87
|
+
})
|
|
88
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
89
|
+
label: "Price (£)",
|
|
90
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
91
|
+
value: band.price,
|
|
92
|
+
inputMode: "decimal",
|
|
93
|
+
placeholder: "0.00",
|
|
94
|
+
onChange: (event) => change(band.id, { price: event.target.value })
|
|
95
|
+
})
|
|
96
|
+
})]
|
|
97
|
+
}),
|
|
98
|
+
onAdd: () => setBands((now) => [...now, {
|
|
99
|
+
id: "band-new-" + nextId.current++,
|
|
100
|
+
name: "",
|
|
101
|
+
price: ""
|
|
102
|
+
}]),
|
|
103
|
+
onRemove: (index) => setBands((now) => now.filter((_, i) => i !== index)),
|
|
104
|
+
onRestore: undo ? (band, index) => setBands((now) => {
|
|
105
|
+
const next = [...now];
|
|
106
|
+
next.splice(index, 0, band);
|
|
107
|
+
return next;
|
|
108
|
+
}) : void 0,
|
|
109
|
+
onMove: move ? (from, to) => setBands((now) => {
|
|
110
|
+
const next = [...now];
|
|
111
|
+
const [moved] = next.splice(from, 1);
|
|
112
|
+
if (moved) next.splice(to, 0, moved);
|
|
113
|
+
return next;
|
|
114
|
+
}) : void 0,
|
|
115
|
+
min,
|
|
116
|
+
max,
|
|
117
|
+
disabled,
|
|
118
|
+
empty,
|
|
119
|
+
labels
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
var BAND_CODE = `
|
|
123
|
+
const [bands, setBands] = useState(deliveryBands)
|
|
124
|
+
|
|
125
|
+
<Repeater
|
|
126
|
+
items={bands}
|
|
127
|
+
getKey={(band) => band.id}
|
|
128
|
+
renderRow={(band, { index }) => (
|
|
129
|
+
<div className="repeater-row">
|
|
130
|
+
<Field label={'Band ' + (index + 1)}>
|
|
131
|
+
<Input value={band.name} onChange={…} />
|
|
132
|
+
</Field>
|
|
133
|
+
<Field label="Price (£)">
|
|
134
|
+
<Input value={band.price} onChange={…} />
|
|
135
|
+
</Field>
|
|
136
|
+
</div>
|
|
137
|
+
)}
|
|
138
|
+
onAdd={() => setBands((now) => [...now, newBand()])}
|
|
139
|
+
onRemove={(index) => setBands((now) => now.filter((_, i) => i !== index))}
|
|
140
|
+
onRestore={(band, index) => setBands((now) => putBack(now, band, index))}
|
|
141
|
+
onMove={(from, to) => setBands((now) => move(now, from, to))}
|
|
142
|
+
min={1}
|
|
143
|
+
max={5}
|
|
144
|
+
empty={<EmptyState title="No delivery bands yet" description="Add one for each way you send orders." />}
|
|
145
|
+
/>`;
|
|
146
|
+
var DNS_COLUMNS = [
|
|
147
|
+
{
|
|
148
|
+
key: "type",
|
|
149
|
+
label: "Type",
|
|
150
|
+
width: "96px"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
key: "name",
|
|
154
|
+
label: "Name",
|
|
155
|
+
width: "minmax(0, 0.8fr)"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
key: "value",
|
|
159
|
+
label: "Value",
|
|
160
|
+
width: "minmax(0, 2fr)"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
key: "ttl",
|
|
164
|
+
label: "TTL",
|
|
165
|
+
width: "84px"
|
|
166
|
+
}
|
|
167
|
+
];
|
|
168
|
+
var DNS_TYPES = [
|
|
169
|
+
"A",
|
|
170
|
+
"AAAA",
|
|
171
|
+
"CNAME",
|
|
172
|
+
"MX",
|
|
173
|
+
"TXT"
|
|
174
|
+
].map((type) => ({
|
|
175
|
+
value: type,
|
|
176
|
+
label: type
|
|
177
|
+
}));
|
|
178
|
+
function dnsProblem(record) {
|
|
179
|
+
if (record.managed) return null;
|
|
180
|
+
if (record.name.trim() === "") return "Give the record a name, or @ for the domain itself";
|
|
181
|
+
if (record.value.trim() === "") return "Give the record a value";
|
|
182
|
+
if (record.type === "A" && !/^\d{1,3}(\.\d{1,3}){3}$/.test(record.value.trim())) return "Enter an IPv4 address, like 192.0.2.10";
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
var nextDnsId = 10;
|
|
186
|
+
function DnsRecords() {
|
|
187
|
+
const [records, setRecords] = useState([
|
|
188
|
+
{
|
|
189
|
+
id: "dns-1",
|
|
190
|
+
type: "A",
|
|
191
|
+
name: "@",
|
|
192
|
+
value: "76.76.21.21",
|
|
193
|
+
ttl: "3600",
|
|
194
|
+
managed: true
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
id: "dns-2",
|
|
198
|
+
type: "CNAME",
|
|
199
|
+
name: "www",
|
|
200
|
+
value: "stores.orbitcommerce.example",
|
|
201
|
+
ttl: "3600",
|
|
202
|
+
managed: true
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: "dns-3",
|
|
206
|
+
type: "TXT",
|
|
207
|
+
name: "@",
|
|
208
|
+
value: "v=spf1 include:mail.example ~all",
|
|
209
|
+
ttl: "3600"
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
id: "dns-4",
|
|
213
|
+
type: "A",
|
|
214
|
+
name: "shop",
|
|
215
|
+
value: "192.0.2",
|
|
216
|
+
ttl: "3600"
|
|
217
|
+
}
|
|
218
|
+
]);
|
|
219
|
+
const [checked, setChecked] = useState(false);
|
|
220
|
+
const update = (id, patch) => setRecords((now) => now.map((each) => each.id === id ? {
|
|
221
|
+
...each,
|
|
222
|
+
...patch
|
|
223
|
+
} : each));
|
|
224
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
225
|
+
className: "repeater-stage repeater-stage--wide",
|
|
226
|
+
children: [/* @__PURE__ */ jsx(Repeater, {
|
|
227
|
+
heading: "DNS records",
|
|
228
|
+
addPlacement: "above",
|
|
229
|
+
addLabel: "Add record",
|
|
230
|
+
items: records,
|
|
231
|
+
getKey: (record) => record.id,
|
|
232
|
+
columns: DNS_COLUMNS,
|
|
233
|
+
getLockedReason: (record) => record.managed ? "Managed by your store" : null,
|
|
234
|
+
getRowError: (record) => checked ? dnsProblem(record) : null,
|
|
235
|
+
renderCell: (record, column, { index, locked, errorId }) => {
|
|
236
|
+
const label = `${column.key === "ttl" ? "TTL" : String(column.label)}, record ${index + 1}`;
|
|
237
|
+
if (locked) {
|
|
238
|
+
const text = record[column.key];
|
|
239
|
+
return /* @__PURE__ */ jsx("span", {
|
|
240
|
+
className: column.key === "value" ? "repeater-cell-text repeater-cell-text--mono" : "repeater-cell-text",
|
|
241
|
+
children: text
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
if (column.key === "type") return /* @__PURE__ */ jsx(Select, {
|
|
245
|
+
size: "sm",
|
|
246
|
+
"aria-label": label,
|
|
247
|
+
value: record.type,
|
|
248
|
+
options: DNS_TYPES,
|
|
249
|
+
onValueChange: (type) => update(record.id, { type })
|
|
250
|
+
});
|
|
251
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
252
|
+
size: "sm",
|
|
253
|
+
"aria-label": label,
|
|
254
|
+
"aria-describedby": errorId,
|
|
255
|
+
className: column.key === "value" ? "repeater-mono" : void 0,
|
|
256
|
+
value: record[column.key],
|
|
257
|
+
placeholder: column.key === "name" ? "@" : column.key === "value" ? "192.0.2.10" : "3600",
|
|
258
|
+
onChange: (event) => update(record.id, { [column.key]: event.target.value })
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
onAdd: () => setRecords((now) => [...now, {
|
|
262
|
+
id: `dns-${nextDnsId++}`,
|
|
263
|
+
type: "A",
|
|
264
|
+
name: "",
|
|
265
|
+
value: "",
|
|
266
|
+
ttl: "3600"
|
|
267
|
+
}]),
|
|
268
|
+
onRemove: (index) => setRecords((now) => now.filter((_, i) => i !== index))
|
|
269
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
270
|
+
className: "repeater-actions",
|
|
271
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
272
|
+
size: "sm",
|
|
273
|
+
onClick: () => setChecked(true),
|
|
274
|
+
children: "Check records"
|
|
275
|
+
})
|
|
276
|
+
})]
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
var CATALOGUE = [
|
|
280
|
+
{
|
|
281
|
+
value: "arden-chair",
|
|
282
|
+
label: "Arden ergonomic chair",
|
|
283
|
+
variants: ["Charcoal", "Sand"],
|
|
284
|
+
stock: 42
|
|
285
|
+
},
|
|
286
|
+
{
|
|
287
|
+
value: "kestrel-desk",
|
|
288
|
+
label: "Kestrel standing desk",
|
|
289
|
+
variants: [
|
|
290
|
+
"Oak, 140cm",
|
|
291
|
+
"Oak, 160cm",
|
|
292
|
+
"White, 140cm"
|
|
293
|
+
],
|
|
294
|
+
stock: 9
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
value: "lumen-lamp",
|
|
298
|
+
label: "Lumen desk lamp",
|
|
299
|
+
variants: [],
|
|
300
|
+
stock: 120
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
value: "tidy-tray",
|
|
304
|
+
label: "Tidy cable tray",
|
|
305
|
+
variants: [],
|
|
306
|
+
stock: 75
|
|
307
|
+
}
|
|
308
|
+
];
|
|
309
|
+
function BundleComponents() {
|
|
310
|
+
const [components, setComponents] = useState([{
|
|
311
|
+
id: "kestrel-desk",
|
|
312
|
+
name: "Kestrel standing desk",
|
|
313
|
+
variant: "Oak, 140cm",
|
|
314
|
+
variants: [
|
|
315
|
+
"Oak, 140cm",
|
|
316
|
+
"Oak, 160cm",
|
|
317
|
+
"White, 140cm"
|
|
318
|
+
],
|
|
319
|
+
quantity: "1",
|
|
320
|
+
stock: 9,
|
|
321
|
+
core: true
|
|
322
|
+
}, {
|
|
323
|
+
id: "arden-chair",
|
|
324
|
+
name: "Arden ergonomic chair",
|
|
325
|
+
variant: "",
|
|
326
|
+
variants: ["Charcoal", "Sand"],
|
|
327
|
+
quantity: "1",
|
|
328
|
+
stock: 42
|
|
329
|
+
}]);
|
|
330
|
+
const update = (id, patch) => setComponents((now) => now.map((each) => each.id === id ? {
|
|
331
|
+
...each,
|
|
332
|
+
...patch
|
|
333
|
+
} : each));
|
|
334
|
+
const limiting = components.reduce((low, each) => {
|
|
335
|
+
const bundles = Math.floor(each.stock / Math.max(1, Number(each.quantity) || 1));
|
|
336
|
+
if (!low) return each;
|
|
337
|
+
return bundles < Math.floor(low.stock / Math.max(1, Number(low.quantity) || 1)) ? each : low;
|
|
338
|
+
}, null);
|
|
339
|
+
return /* @__PURE__ */ jsx("div", {
|
|
340
|
+
className: "repeater-stage",
|
|
341
|
+
children: /* @__PURE__ */ jsx(Repeater, {
|
|
342
|
+
className: "repeater-bundle",
|
|
343
|
+
items: components,
|
|
344
|
+
getKey: (component) => component.id,
|
|
345
|
+
addSlot: /* @__PURE__ */ jsx(Combobox, {
|
|
346
|
+
"aria-label": "Add a product to the bundle",
|
|
347
|
+
placeholder: "Search products to add",
|
|
348
|
+
options: CATALOGUE.filter((each) => !components.some((component) => component.id === each.value)),
|
|
349
|
+
value: null,
|
|
350
|
+
onValueChange: (value) => {
|
|
351
|
+
const product = CATALOGUE.find((each) => each.value === value);
|
|
352
|
+
if (!product) return;
|
|
353
|
+
setComponents((now) => [...now, {
|
|
354
|
+
id: product.value,
|
|
355
|
+
name: product.label,
|
|
356
|
+
variant: "",
|
|
357
|
+
variants: product.variants,
|
|
358
|
+
quantity: "1",
|
|
359
|
+
stock: product.stock
|
|
360
|
+
}]);
|
|
361
|
+
}
|
|
362
|
+
}),
|
|
363
|
+
isHighlighted: (component) => components.length > 1 && component.id === limiting?.id,
|
|
364
|
+
isItemRemovable: (component) => !component.core,
|
|
365
|
+
getRowError: (component) => component.variants.length > 1 && component.variant === "" ? "Pick the variant the bundle holds" : null,
|
|
366
|
+
renderRow: (component, { index, errorId }) => /* @__PURE__ */ jsxs("div", {
|
|
367
|
+
className: "repeater-component",
|
|
368
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
369
|
+
className: "repeater-component__main",
|
|
370
|
+
children: [
|
|
371
|
+
/* @__PURE__ */ jsx("span", {
|
|
372
|
+
className: "repeater-component__name",
|
|
373
|
+
children: component.name
|
|
374
|
+
}),
|
|
375
|
+
component.variants.length > 1 ? /* @__PURE__ */ jsx(Select, {
|
|
376
|
+
size: "sm",
|
|
377
|
+
"aria-label": `Variant of ${component.name}`,
|
|
378
|
+
"aria-describedby": errorId,
|
|
379
|
+
placeholder: "Pick a variant",
|
|
380
|
+
value: component.variant || void 0,
|
|
381
|
+
options: component.variants.map((each) => ({
|
|
382
|
+
value: each,
|
|
383
|
+
label: each
|
|
384
|
+
})),
|
|
385
|
+
onValueChange: (variant) => update(component.id, { variant })
|
|
386
|
+
}) : null,
|
|
387
|
+
components.length > 1 && component.id === limiting?.id ? /* @__PURE__ */ jsxs("span", {
|
|
388
|
+
className: "repeater-component__note",
|
|
389
|
+
children: [
|
|
390
|
+
"Limits the bundle’s availability: ",
|
|
391
|
+
component.stock,
|
|
392
|
+
" in stock"
|
|
393
|
+
]
|
|
394
|
+
}) : null
|
|
395
|
+
]
|
|
396
|
+
}), /* @__PURE__ */ jsx(Input, {
|
|
397
|
+
size: "sm",
|
|
398
|
+
type: "number",
|
|
399
|
+
min: 1,
|
|
400
|
+
"aria-label": `Quantity per bundle, component ${index + 1}`,
|
|
401
|
+
className: "repeater-component__qty",
|
|
402
|
+
prefix: "×",
|
|
403
|
+
value: component.quantity,
|
|
404
|
+
onChange: (event) => update(component.id, { quantity: event.target.value })
|
|
405
|
+
})]
|
|
406
|
+
}),
|
|
407
|
+
onMove: (from, to) => setComponents((now) => {
|
|
408
|
+
const next = [...now];
|
|
409
|
+
const [moved] = next.splice(from, 1);
|
|
410
|
+
if (moved) next.splice(to, 0, moved);
|
|
411
|
+
return next;
|
|
412
|
+
}),
|
|
413
|
+
onRemove: (index) => setComponents((now) => now.filter((_, i) => i !== index)),
|
|
414
|
+
empty: /* @__PURE__ */ jsx("p", {
|
|
415
|
+
className: "repeater-empty-line",
|
|
416
|
+
children: "No components yet. Search for a product to add it."
|
|
417
|
+
}),
|
|
418
|
+
labels: {
|
|
419
|
+
remove: (n) => `Remove component ${n}`,
|
|
420
|
+
moveUp: (n) => `Move component ${n} up`,
|
|
421
|
+
moveDown: (n) => `Move component ${n} down`,
|
|
422
|
+
added: (n) => `Component ${n} added`,
|
|
423
|
+
removed: (n) => `Component ${n} removed`
|
|
424
|
+
}
|
|
425
|
+
})
|
|
426
|
+
});
|
|
427
|
+
}
|
|
428
|
+
function PurchaseLines() {
|
|
429
|
+
const [lines, setLines] = useState([{
|
|
430
|
+
id: "line-1",
|
|
431
|
+
name: "Arden ergonomic chair, Charcoal",
|
|
432
|
+
sku: "ARD-CH-CHA",
|
|
433
|
+
quantity: "12",
|
|
434
|
+
cost: "148.00"
|
|
435
|
+
}, {
|
|
436
|
+
id: "line-2",
|
|
437
|
+
name: "Lumen desk lamp",
|
|
438
|
+
sku: "LUM-LAMP",
|
|
439
|
+
quantity: "40",
|
|
440
|
+
cost: "18.50"
|
|
441
|
+
}]);
|
|
442
|
+
const update = (id, patch) => setLines((now) => now.map((each) => each.id === id ? {
|
|
443
|
+
...each,
|
|
444
|
+
...patch
|
|
445
|
+
} : each));
|
|
446
|
+
return /* @__PURE__ */ jsx("div", {
|
|
447
|
+
className: "repeater-drawer",
|
|
448
|
+
children: /* @__PURE__ */ jsx(Repeater, {
|
|
449
|
+
layout: "stacked",
|
|
450
|
+
items: lines,
|
|
451
|
+
getKey: (line) => line.id,
|
|
452
|
+
renderHead: (line) => /* @__PURE__ */ jsxs("div", {
|
|
453
|
+
className: "repeater-line-head",
|
|
454
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
455
|
+
className: "repeater-component__name",
|
|
456
|
+
children: line.name
|
|
457
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
458
|
+
className: "repeater-line-head__sku",
|
|
459
|
+
children: line.sku
|
|
460
|
+
})]
|
|
461
|
+
}),
|
|
462
|
+
renderRow: (line, { index }) => /* @__PURE__ */ jsxs("div", {
|
|
463
|
+
className: "repeater-line-fields",
|
|
464
|
+
children: [
|
|
465
|
+
/* @__PURE__ */ jsx(Field, {
|
|
466
|
+
label: "Quantity",
|
|
467
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
468
|
+
size: "sm",
|
|
469
|
+
type: "number",
|
|
470
|
+
min: 1,
|
|
471
|
+
value: line.quantity,
|
|
472
|
+
onChange: (event) => update(line.id, { quantity: event.target.value }),
|
|
473
|
+
"aria-describedby": void 0
|
|
474
|
+
})
|
|
475
|
+
}),
|
|
476
|
+
/* @__PURE__ */ jsx(Field, {
|
|
477
|
+
label: "Unit cost",
|
|
478
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
479
|
+
size: "sm",
|
|
480
|
+
prefix: "£",
|
|
481
|
+
inputMode: "decimal",
|
|
482
|
+
value: line.cost,
|
|
483
|
+
onChange: (event) => update(line.id, { cost: event.target.value })
|
|
484
|
+
})
|
|
485
|
+
}),
|
|
486
|
+
/* @__PURE__ */ jsxs("div", {
|
|
487
|
+
className: "repeater-line-total",
|
|
488
|
+
"aria-label": `Line ${index + 1} total`,
|
|
489
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
490
|
+
className: "repeater-line-total__label",
|
|
491
|
+
children: "Total"
|
|
492
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
493
|
+
className: "repeater-line-total__value",
|
|
494
|
+
children: ["£", ((Number(line.cost) || 0) * (Number(line.quantity) || 0)).toFixed(2)]
|
|
495
|
+
})]
|
|
496
|
+
})
|
|
497
|
+
]
|
|
498
|
+
}),
|
|
499
|
+
onRemove: (index) => setLines((now) => now.filter((_, i) => i !== index)),
|
|
500
|
+
labels: {
|
|
501
|
+
remove: (n) => `Remove line ${n}`,
|
|
502
|
+
removed: (n) => `Line ${n} removed`
|
|
503
|
+
},
|
|
504
|
+
empty: /* @__PURE__ */ jsx("p", {
|
|
505
|
+
className: "repeater-empty-line",
|
|
506
|
+
children: "No lines yet. Search for a product to order."
|
|
507
|
+
})
|
|
508
|
+
})
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
var nextRegionId = 3;
|
|
512
|
+
function Regions() {
|
|
513
|
+
const [regions, setRegions] = useState([{
|
|
514
|
+
id: "region-1",
|
|
515
|
+
kind: "country",
|
|
516
|
+
value: "United Kingdom"
|
|
517
|
+
}, {
|
|
518
|
+
id: "region-2",
|
|
519
|
+
kind: "state",
|
|
520
|
+
value: "Scottish Highlands"
|
|
521
|
+
}]);
|
|
522
|
+
const add = (kind) => () => setRegions((now) => [...now, {
|
|
523
|
+
id: `region-${nextRegionId++}`,
|
|
524
|
+
kind,
|
|
525
|
+
value: kind === "worldwide" ? "Every country" : ""
|
|
526
|
+
}]);
|
|
527
|
+
return /* @__PURE__ */ jsx("div", {
|
|
528
|
+
className: "repeater-stage",
|
|
529
|
+
children: /* @__PURE__ */ jsx(Repeater, {
|
|
530
|
+
items: regions,
|
|
531
|
+
getKey: (region) => region.id,
|
|
532
|
+
renderRow: (region, { index }) => region.kind === "worldwide" ? /* @__PURE__ */ jsx("span", {
|
|
533
|
+
className: "repeater-cell-text",
|
|
534
|
+
children: "Worldwide: every country"
|
|
535
|
+
}) : /* @__PURE__ */ jsx(Input, {
|
|
536
|
+
size: "sm",
|
|
537
|
+
"aria-label": `${region.kind === "country" ? "Country" : "State or city"}, region ${index + 1}`,
|
|
538
|
+
placeholder: region.kind === "country" ? "Country" : "State or city",
|
|
539
|
+
value: region.value,
|
|
540
|
+
onChange: (event) => setRegions((now) => now.map((each) => each.id === region.id ? {
|
|
541
|
+
...each,
|
|
542
|
+
value: event.target.value
|
|
543
|
+
} : each))
|
|
544
|
+
}),
|
|
545
|
+
addActions: [
|
|
546
|
+
{
|
|
547
|
+
label: "Add country",
|
|
548
|
+
onSelect: add("country")
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
label: "Add state or city",
|
|
552
|
+
onSelect: add("state")
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
label: "Worldwide",
|
|
556
|
+
onSelect: add("worldwide")
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
onRemove: (index) => setRegions((now) => now.filter((_, i) => i !== index)),
|
|
560
|
+
labels: { remove: (n) => `Remove region ${n}` }
|
|
561
|
+
})
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
function Page() {
|
|
565
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
566
|
+
title: "Repeater",
|
|
567
|
+
status: "new",
|
|
568
|
+
importNames: ["Repeater", "repeaterLabels"],
|
|
569
|
+
lead: "A list of rows the person adds, removes and reorders. The host owns the data and draws each row; the Repeater draws the chrome around it, keeps focus where the change left it and announces what happened. Reach for it for delivery bands, variant options, permission rows: a set of the same fields, as many as the person needs.",
|
|
570
|
+
children: [
|
|
571
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
572
|
+
id: "basics",
|
|
573
|
+
title: "Rows the person controls",
|
|
574
|
+
description: /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
575
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
576
|
+
"A ",
|
|
577
|
+
/* @__PURE__ */ jsx("code", { children: "Repeater" }),
|
|
578
|
+
" is an ordered list of rows. You hand it ",
|
|
579
|
+
/* @__PURE__ */ jsx("code", { children: "items" }),
|
|
580
|
+
" and a",
|
|
581
|
+
" ",
|
|
582
|
+
/* @__PURE__ */ jsx("code", { children: "renderRow" }),
|
|
583
|
+
" for the fields of one row, and it draws Add, a Remove on each row with an undo, and Move up and Move down; it calls ",
|
|
584
|
+
/* @__PURE__ */ jsx("code", { children: "onAdd" }),
|
|
585
|
+
", ",
|
|
586
|
+
/* @__PURE__ */ jsx("code", { children: "onRemove" }),
|
|
587
|
+
", ",
|
|
588
|
+
/* @__PURE__ */ jsx("code", { children: "onRestore" }),
|
|
589
|
+
" and",
|
|
590
|
+
" ",
|
|
591
|
+
/* @__PURE__ */ jsx("code", { children: "onMove" }),
|
|
592
|
+
" and you change ",
|
|
593
|
+
/* @__PURE__ */ jsx("code", { children: "items" }),
|
|
594
|
+
". It keeps each row keyed by ",
|
|
595
|
+
/* @__PURE__ */ jsx("code", { children: "getKey" }),
|
|
596
|
+
", so the fields keep their state and their focus across a move."
|
|
597
|
+
] }),
|
|
598
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
599
|
+
"The tools sit level with the row's controls, at the foot of labelled fields. Where a row's fields carry a hint under them, set ",
|
|
600
|
+
/* @__PURE__ */ jsx("code", { children: "--o-repeater-tools-align: flex-start" }),
|
|
601
|
+
" on the Repeater so the tools stay on the first line. Where a row is narrow, on a phone, the tools drop under the fields, to the end, rather than crush them."
|
|
602
|
+
] }),
|
|
603
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
604
|
+
"Reach for it when a form has ",
|
|
605
|
+
/* @__PURE__ */ jsx("em", { children: "n" }),
|
|
606
|
+
" of the same thing and the person decides ",
|
|
607
|
+
/* @__PURE__ */ jsx("em", { children: "n" }),
|
|
608
|
+
". When the fields are fixed, use a ",
|
|
609
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
610
|
+
to: "/components/form-grid",
|
|
611
|
+
children: "form grid"
|
|
612
|
+
}),
|
|
613
|
+
". When the rows are records to read rather than fields to fill in, use a ",
|
|
614
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
615
|
+
to: "/components/table",
|
|
616
|
+
children: "table"
|
|
617
|
+
}),
|
|
618
|
+
" or a",
|
|
619
|
+
" ",
|
|
620
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
621
|
+
to: "/components/row-list",
|
|
622
|
+
children: "row list"
|
|
623
|
+
}),
|
|
624
|
+
". Reordering is one step at a time, so it suits a handful of rows, not a long list to sort."
|
|
625
|
+
] })
|
|
626
|
+
] }),
|
|
627
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
628
|
+
align: "fill",
|
|
629
|
+
code: BAND_CODE,
|
|
630
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
631
|
+
className: "repeater-stage",
|
|
632
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
633
|
+
initial: BANDS,
|
|
634
|
+
min: 1,
|
|
635
|
+
max: 5
|
|
636
|
+
})
|
|
637
|
+
})
|
|
638
|
+
})
|
|
639
|
+
}),
|
|
640
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
641
|
+
id: "states",
|
|
642
|
+
title: "States",
|
|
643
|
+
description: /* @__PURE__ */ jsx("p", { children: "Every state a Repeater can be in, and the props that reach it." }),
|
|
644
|
+
children: [
|
|
645
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
646
|
+
title: "Removing with an undo",
|
|
647
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
648
|
+
align: "fill",
|
|
649
|
+
code: `<Repeater … onRestore={(band, index) => setBands((now) => putBack(now, band, index))} />`,
|
|
650
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
651
|
+
className: "repeater-stage",
|
|
652
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
653
|
+
initial: BANDS,
|
|
654
|
+
min: 1
|
|
655
|
+
})
|
|
656
|
+
})
|
|
657
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
658
|
+
className: "repeater-prose",
|
|
659
|
+
children: [
|
|
660
|
+
"Remove a row and an undo row appears under the list: ",
|
|
661
|
+
/* @__PURE__ */ jsx("em", { children: "Row removed" }),
|
|
662
|
+
", with an Undo button, for eight seconds or until the next change. The removal is announced by the Repeater's polite status (",
|
|
663
|
+
/* @__PURE__ */ jsx("em", { children: "Row 2 removed" }),
|
|
664
|
+
"); the undo row is words and a button. Undo calls ",
|
|
665
|
+
/* @__PURE__ */ jsx("code", { children: "onRestore(item, index)" }),
|
|
666
|
+
", hands focus back to the restored row and says ",
|
|
667
|
+
/* @__PURE__ */ jsx("em", { children: "Row 2 restored" }),
|
|
668
|
+
". Without ",
|
|
669
|
+
/* @__PURE__ */ jsx("code", { children: "onRestore" }),
|
|
670
|
+
" there is no undo row, and the status says the removal all the same."
|
|
671
|
+
]
|
|
672
|
+
})]
|
|
673
|
+
}),
|
|
674
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
675
|
+
title: "Add held off at the maximum",
|
|
676
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
677
|
+
align: "fill",
|
|
678
|
+
code: `<Repeater … max={5} />`,
|
|
679
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
680
|
+
className: "repeater-stage",
|
|
681
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
682
|
+
initial: FIVE_BANDS,
|
|
683
|
+
max: 5
|
|
684
|
+
})
|
|
685
|
+
})
|
|
686
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
687
|
+
className: "repeater-prose",
|
|
688
|
+
children: [
|
|
689
|
+
"At ",
|
|
690
|
+
/* @__PURE__ */ jsx("code", { children: "max" }),
|
|
691
|
+
" the Add button is ",
|
|
692
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
693
|
+
", and ",
|
|
694
|
+
/* @__PURE__ */ jsx("em", { children: "You can add up to 5" }),
|
|
695
|
+
" shows under it and describes it, so a sighted person meets the reason as a screen reader does. It is not natively disabled, so it stays in the tab order."
|
|
696
|
+
]
|
|
697
|
+
})]
|
|
698
|
+
}),
|
|
699
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
700
|
+
title: "Remove held off at the minimum",
|
|
701
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
702
|
+
align: "fill",
|
|
703
|
+
code: `<Repeater … min={1} />`,
|
|
704
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
705
|
+
className: "repeater-stage",
|
|
706
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
707
|
+
initial: BANDS.slice(0, 1),
|
|
708
|
+
min: 1
|
|
709
|
+
})
|
|
710
|
+
})
|
|
711
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
712
|
+
className: "repeater-prose",
|
|
713
|
+
children: [
|
|
714
|
+
"While the count is at ",
|
|
715
|
+
/* @__PURE__ */ jsx("code", { children: "min" }),
|
|
716
|
+
", every Remove is ",
|
|
717
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
718
|
+
": the last row stays. Leave ",
|
|
719
|
+
/* @__PURE__ */ jsx("code", { children: "min" }),
|
|
720
|
+
" out (0) when every row may go. One row has nowhere to move, so its move buttons are not drawn until there is a second."
|
|
721
|
+
]
|
|
722
|
+
})]
|
|
723
|
+
}),
|
|
724
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
725
|
+
title: "Empty",
|
|
726
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
727
|
+
align: "fill",
|
|
728
|
+
code: `<Repeater items={[]} … empty={<EmptyState title="No delivery bands yet" description="Add one for each way you send orders." />} />`,
|
|
729
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
730
|
+
className: "repeater-stage",
|
|
731
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
732
|
+
initial: [],
|
|
733
|
+
empty: /* @__PURE__ */ jsx(EmptyState, {
|
|
734
|
+
title: "No delivery bands yet",
|
|
735
|
+
description: "Add one for each way you send orders.",
|
|
736
|
+
size: "sm"
|
|
737
|
+
})
|
|
738
|
+
})
|
|
739
|
+
})
|
|
740
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
741
|
+
className: "repeater-prose",
|
|
742
|
+
children: [
|
|
743
|
+
"With no rows, ",
|
|
744
|
+
/* @__PURE__ */ jsx("code", { children: "empty" }),
|
|
745
|
+
" is drawn above Add, and Add sits centred under it as its action, so the list says what is missing rather than standing bare. It is any node: an",
|
|
746
|
+
" ",
|
|
747
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
748
|
+
to: "/components/empty-state",
|
|
749
|
+
children: "empty state"
|
|
750
|
+
}),
|
|
751
|
+
", a sentence, a link."
|
|
752
|
+
]
|
|
753
|
+
})]
|
|
754
|
+
}),
|
|
755
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
756
|
+
title: "Disabled",
|
|
757
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
758
|
+
align: "fill",
|
|
759
|
+
code: `<Repeater … disabled />`,
|
|
760
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
761
|
+
className: "repeater-stage",
|
|
762
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
763
|
+
initial: BANDS,
|
|
764
|
+
disabled: true
|
|
765
|
+
})
|
|
766
|
+
})
|
|
767
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
768
|
+
className: "repeater-prose",
|
|
769
|
+
children: [/* @__PURE__ */ jsx("code", { children: "disabled" }), " holds off every tool and Add, and leaves the rows' own fields alone. Use it while the form is saving, or for a section the person cannot change yet."]
|
|
770
|
+
})]
|
|
771
|
+
}),
|
|
772
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
773
|
+
title: "Without moving, or without an undo",
|
|
774
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
775
|
+
align: "fill",
|
|
776
|
+
code: `<Repeater … /> // no onMove and no onRestore`,
|
|
777
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
778
|
+
className: "repeater-stage",
|
|
779
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
780
|
+
initial: BANDS,
|
|
781
|
+
move: false,
|
|
782
|
+
undo: false
|
|
783
|
+
})
|
|
784
|
+
})
|
|
785
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
786
|
+
className: "repeater-prose",
|
|
787
|
+
children: [
|
|
788
|
+
"The chrome follows the props: without ",
|
|
789
|
+
/* @__PURE__ */ jsx("code", { children: "onMove" }),
|
|
790
|
+
" there are no move buttons, and without",
|
|
791
|
+
" ",
|
|
792
|
+
/* @__PURE__ */ jsx("code", { children: "onRestore" }),
|
|
793
|
+
" a removal is final. A Repeater with neither is Add and Remove alone."
|
|
794
|
+
]
|
|
795
|
+
})]
|
|
796
|
+
}),
|
|
797
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
798
|
+
title: "Your own words",
|
|
799
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
800
|
+
align: "fill",
|
|
801
|
+
code: `
|
|
802
|
+
<Repeater
|
|
803
|
+
…
|
|
804
|
+
labels={{
|
|
805
|
+
add: 'Add a band',
|
|
806
|
+
remove: (position) => 'Delete band ' + position,
|
|
807
|
+
removed: (position) => 'Band ' + position + ' deleted',
|
|
808
|
+
undoLine: 'Band deleted',
|
|
809
|
+
undo: 'Restore',
|
|
810
|
+
}}
|
|
811
|
+
/>`,
|
|
812
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
813
|
+
className: "repeater-stage",
|
|
814
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
815
|
+
initial: BANDS,
|
|
816
|
+
labels: {
|
|
817
|
+
add: "Add a band",
|
|
818
|
+
remove: (position) => "Delete band " + position,
|
|
819
|
+
removed: (position) => "Band " + position + " deleted",
|
|
820
|
+
undoLine: "Band deleted",
|
|
821
|
+
undo: "Restore"
|
|
822
|
+
}
|
|
823
|
+
})
|
|
824
|
+
})
|
|
825
|
+
}), /* @__PURE__ */ jsxs("p", {
|
|
826
|
+
className: "repeater-prose",
|
|
827
|
+
children: [
|
|
828
|
+
"Every word, shown or announced, comes from ",
|
|
829
|
+
/* @__PURE__ */ jsx("code", { children: "labels" }),
|
|
830
|
+
". The default set is",
|
|
831
|
+
" ",
|
|
832
|
+
/* @__PURE__ */ jsx("code", { children: "repeaterLabels" }),
|
|
833
|
+
"; the words that name a row are functions of its place, so a translation can put the number where its language wants it."
|
|
834
|
+
]
|
|
835
|
+
})]
|
|
836
|
+
})
|
|
837
|
+
]
|
|
838
|
+
}),
|
|
839
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
840
|
+
id: "columns",
|
|
841
|
+
title: "Columns",
|
|
842
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
843
|
+
/* @__PURE__ */ jsx("code", { children: "columns" }),
|
|
844
|
+
" sets the fields on one grid under column headings, so a field lines up with its heading on every row (a DNS record's Type, Name, Value and TTL); ",
|
|
845
|
+
/* @__PURE__ */ jsx("code", { children: "renderCell" }),
|
|
846
|
+
" draws one cell. The headings are drawn once and are visual only, so label each field yourself (\"Value, record 3\"). Where the Repeater is narrower than 34rem (a phone) the rows fold into stacks, each cell under its column's label."
|
|
847
|
+
] }),
|
|
848
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
849
|
+
align: "fill",
|
|
850
|
+
code: `
|
|
851
|
+
<Repeater
|
|
852
|
+
heading="DNS records"
|
|
853
|
+
addPlacement="above"
|
|
854
|
+
addLabel="Add record"
|
|
855
|
+
items={records}
|
|
856
|
+
getKey={(record) => record.id}
|
|
857
|
+
columns={[
|
|
858
|
+
{ key: 'type', label: 'Type', width: '96px' },
|
|
859
|
+
{ key: 'name', label: 'Name', width: 'minmax(0, 0.8fr)' },
|
|
860
|
+
{ key: 'value', label: 'Value', width: 'minmax(0, 2fr)' },
|
|
861
|
+
{ key: 'ttl', label: 'TTL', width: '84px' },
|
|
862
|
+
]}
|
|
863
|
+
getLockedReason={(record) => (record.managed ? 'Managed by your store' : null)}
|
|
864
|
+
getRowError={(record) => (checked ? problemWith(record) : null)}
|
|
865
|
+
renderCell={(record, column, { index, locked, errorId }) => cellFor(record, column, index, locked, errorId)}
|
|
866
|
+
onAdd={addRecord}
|
|
867
|
+
onRemove={removeRecord}
|
|
868
|
+
/>`,
|
|
869
|
+
children: /* @__PURE__ */ jsx(DnsRecords, {})
|
|
870
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
871
|
+
title: "Locked rows and errors",
|
|
872
|
+
children: [
|
|
873
|
+
/* @__PURE__ */ jsx("code", { children: "getLockedReason" }),
|
|
874
|
+
" draws a row read only, on the sunken ground, with its reason where its tools would be: no padlock, and no way to move or remove it. ",
|
|
875
|
+
/* @__PURE__ */ jsx("code", { children: "getRowError" }),
|
|
876
|
+
" puts a Field's error line under a row and gives it the negative edge; the row state's ",
|
|
877
|
+
/* @__PURE__ */ jsx("code", { children: "errorId" }),
|
|
878
|
+
" is the line's id, for your fields' ",
|
|
879
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby" }),
|
|
880
|
+
". Press Check records to see the incomplete one."
|
|
881
|
+
]
|
|
882
|
+
})]
|
|
883
|
+
}),
|
|
884
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
885
|
+
id: "add-slot",
|
|
886
|
+
title: "An add slot, a highlighted row and a required one",
|
|
887
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
888
|
+
/* @__PURE__ */ jsx("code", { children: "addSlot" }),
|
|
889
|
+
" sets a control above the rows that adds them, such as a search for products: the Repeater draws no Add of its own, and a row that arrives from it fades in and is announced while focus stays in the search for the next.",
|
|
890
|
+
" ",
|
|
891
|
+
/* @__PURE__ */ jsx("code", { children: "isHighlighted" }),
|
|
892
|
+
" gives a row the warning wash, for the component that limits a bundle's stock (say why in the row), and ",
|
|
893
|
+
/* @__PURE__ */ jsx("code", { children: "isItemRemovable" }),
|
|
894
|
+
" keeps a row, with \"Required\" in Remove's place."
|
|
895
|
+
] }),
|
|
896
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
897
|
+
align: "fill",
|
|
898
|
+
code: `
|
|
899
|
+
<Repeater
|
|
900
|
+
items={components}
|
|
901
|
+
getKey={(component) => component.id}
|
|
902
|
+
addSlot={<Combobox aria-label="Add a product to the bundle" placeholder="Search products to add" options={products} value={null} onValueChange={addProduct} />}
|
|
903
|
+
isHighlighted={(component) => component.id === limiting.id}
|
|
904
|
+
isItemRemovable={(component) => !component.core}
|
|
905
|
+
getRowError={(component) => (needsVariant(component) ? 'Pick the variant the bundle holds' : null)}
|
|
906
|
+
renderRow={(component, { errorId }) => <ComponentFields component={component} errorId={errorId} />}
|
|
907
|
+
onMove={moveComponent}
|
|
908
|
+
onRemove={removeComponent}
|
|
909
|
+
/>`,
|
|
910
|
+
children: /* @__PURE__ */ jsx(BundleComponents, {})
|
|
911
|
+
})
|
|
912
|
+
}),
|
|
913
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
914
|
+
id: "stacked",
|
|
915
|
+
title: "Stacked line items",
|
|
916
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
917
|
+
/* @__PURE__ */ jsx("code", { children: "layout=\"stacked\"" }),
|
|
918
|
+
" draws each row as a head over its fields: ",
|
|
919
|
+
/* @__PURE__ */ jsx("code", { children: "renderHead" }),
|
|
920
|
+
" gives the item's name and details, with the tools at the head's end, and ",
|
|
921
|
+
/* @__PURE__ */ jsx("code", { children: "renderRow" }),
|
|
922
|
+
" its labelled fields below, the rows parted by hairlines. It suits a narrow drawer, where a row of six columns would squeeze the names. A new row's first field takes focus, not its tools."
|
|
923
|
+
] }),
|
|
924
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
925
|
+
align: "fill",
|
|
926
|
+
code: `
|
|
927
|
+
<Repeater
|
|
928
|
+
layout="stacked"
|
|
929
|
+
items={lines}
|
|
930
|
+
getKey={(line) => line.id}
|
|
931
|
+
renderHead={(line) => <LineName line={line} />}
|
|
932
|
+
renderRow={(line) => <LineFields line={line} />}
|
|
933
|
+
onRemove={removeLine}
|
|
934
|
+
/>`,
|
|
935
|
+
children: /* @__PURE__ */ jsx(PurchaseLines, {})
|
|
936
|
+
})
|
|
937
|
+
}),
|
|
938
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
939
|
+
id: "add-actions",
|
|
940
|
+
title: "Several ways to add",
|
|
941
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
942
|
+
/* @__PURE__ */ jsx("code", { children: "addActions" }),
|
|
943
|
+
" draws several Add buttons, each adding a row of its own kind: the first a secondary button with a plus, the rest quieter. Each adds, focuses and announces as Add does. ",
|
|
944
|
+
/* @__PURE__ */ jsx("code", { children: "addPlacement" }),
|
|
945
|
+
" puts Add in the head beside the ",
|
|
946
|
+
/* @__PURE__ */ jsx("code", { children: "heading" }),
|
|
947
|
+
" (",
|
|
948
|
+
/* @__PURE__ */ jsx("code", { children: "above" }),
|
|
949
|
+
"), under the rows (",
|
|
950
|
+
/* @__PURE__ */ jsx("code", { children: "below" }),
|
|
951
|
+
", the default) or both."
|
|
952
|
+
] }),
|
|
953
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
954
|
+
align: "fill",
|
|
955
|
+
code: `
|
|
956
|
+
<Repeater
|
|
957
|
+
items={regions}
|
|
958
|
+
getKey={(region) => region.id}
|
|
959
|
+
renderRow={(region) => <RegionField region={region} />}
|
|
960
|
+
addActions={[
|
|
961
|
+
{ label: 'Add country', onSelect: addCountry },
|
|
962
|
+
{ label: 'Add state or city', onSelect: addState },
|
|
963
|
+
{ label: 'Worldwide', onSelect: addWorldwide },
|
|
964
|
+
]}
|
|
965
|
+
onRemove={removeRegion}
|
|
966
|
+
/>`,
|
|
967
|
+
children: /* @__PURE__ */ jsx(Regions, {})
|
|
968
|
+
})
|
|
969
|
+
}),
|
|
970
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
971
|
+
id: "both-themes",
|
|
972
|
+
title: "In both themes",
|
|
973
|
+
description: /* @__PURE__ */ jsx("p", { children: "Rows on their hairline, the tools and Add, light and dark side by side." }),
|
|
974
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
975
|
+
align: "fill",
|
|
976
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
977
|
+
className: "repeater-theme",
|
|
978
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
979
|
+
initial: BANDS.slice(0, 2),
|
|
980
|
+
min: 1
|
|
981
|
+
})
|
|
982
|
+
})
|
|
983
|
+
})
|
|
984
|
+
}),
|
|
985
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
986
|
+
id: "accessibility",
|
|
987
|
+
title: "Accessibility",
|
|
988
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
989
|
+
/* @__PURE__ */ jsx(Fragment$1, { children: "The rows are an ordered list, so a screen reader reads \"3 items\" as it enters the list, then each row's fields in turn." }),
|
|
990
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
991
|
+
"Each tool is named with its row's place: ",
|
|
992
|
+
/* @__PURE__ */ jsx("em", { children: "Remove row 2" }),
|
|
993
|
+
", ",
|
|
994
|
+
/* @__PURE__ */ jsx("em", { children: "Move row 2 up" }),
|
|
995
|
+
",",
|
|
996
|
+
" ",
|
|
997
|
+
/* @__PURE__ */ jsx("em", { children: "Move row 2 down" }),
|
|
998
|
+
". The Add button is ",
|
|
999
|
+
/* @__PURE__ */ jsx("em", { children: "Add" }),
|
|
1000
|
+
". All of them can be replaced through",
|
|
1001
|
+
" ",
|
|
1002
|
+
/* @__PURE__ */ jsx("code", { children: "labels" }),
|
|
1003
|
+
"."
|
|
1004
|
+
] }),
|
|
1005
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1006
|
+
"Every change is announced politely: ",
|
|
1007
|
+
/* @__PURE__ */ jsx("em", { children: "Row 3 added" }),
|
|
1008
|
+
" after Add, ",
|
|
1009
|
+
/* @__PURE__ */ jsx("em", { children: "Row 2 removed" }),
|
|
1010
|
+
" after a removal, ",
|
|
1011
|
+
/* @__PURE__ */ jsx("em", { children: "Row 2 restored" }),
|
|
1012
|
+
" after Undo, and ",
|
|
1013
|
+
/* @__PURE__ */ jsx("em", { children: "Moved to row 1" }),
|
|
1014
|
+
" after a move."
|
|
1015
|
+
] }),
|
|
1016
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1017
|
+
"Focus follows the change: the new row's first field after Add, the next row's first field after a removal (the previous row's when the last went, Add when none are left), and the moved row's button after a move. A held-off tool is ",
|
|
1018
|
+
/* @__PURE__ */ jsx("code", { children: "aria-disabled" }),
|
|
1019
|
+
", not disabled, so it keeps its place in the tab order."
|
|
1020
|
+
] }),
|
|
1021
|
+
"Tab moves through the fields and the tools in order; Enter or Space presses a tool. There is no roving tabindex and no drag to learn."
|
|
1022
|
+
] })
|
|
1023
|
+
}),
|
|
1024
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1025
|
+
id: "guidelines",
|
|
1026
|
+
title: "Guidelines",
|
|
1027
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
1028
|
+
do: {
|
|
1029
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1030
|
+
className: "repeater-dd",
|
|
1031
|
+
children: /* @__PURE__ */ jsx(BandRepeater, {
|
|
1032
|
+
initial: BANDS.slice(0, 1),
|
|
1033
|
+
min: 1
|
|
1034
|
+
})
|
|
1035
|
+
}),
|
|
1036
|
+
caption: "One thing per row, a name and a price, with its own Remove. Add another for the next way you send orders."
|
|
1037
|
+
},
|
|
1038
|
+
dont: {
|
|
1039
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1040
|
+
className: "repeater-dd",
|
|
1041
|
+
children: /* @__PURE__ */ jsx(Repeater, {
|
|
1042
|
+
items: [{ id: "draft" }],
|
|
1043
|
+
getKey: () => "draft",
|
|
1044
|
+
renderRow: () => /* @__PURE__ */ jsx("div", {
|
|
1045
|
+
className: "repeater-row",
|
|
1046
|
+
children: /* @__PURE__ */ jsx(Field, {
|
|
1047
|
+
label: "Band, price, countries, cut-off time, carrier and tracking URL",
|
|
1048
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
1049
|
+
defaultValue: "Almost a page in one row",
|
|
1050
|
+
readOnly: true
|
|
1051
|
+
})
|
|
1052
|
+
})
|
|
1053
|
+
}),
|
|
1054
|
+
onAdd: () => {},
|
|
1055
|
+
onRemove: () => {}
|
|
1056
|
+
})
|
|
1057
|
+
}),
|
|
1058
|
+
caption: "A whole form inside a row, repeated. If a row needs sections of its own, give the thing its own page and list it elsewhere."
|
|
1059
|
+
}
|
|
1060
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1061
|
+
"Give every row a key that stays with the item (an id), not its place, or the fields will jump when a row moves.",
|
|
1062
|
+
"Keep a row short: two or three fields a person reads together. Long field names shorten; long values wrap under the field.",
|
|
1063
|
+
"Show the row’s place in the words (\"Band 2\"), so the Remove and move buttons name the right row aloud.",
|
|
1064
|
+
"Offer an undo (onRestore) for a destructive Remove, and a min where the last row must stay.",
|
|
1065
|
+
"Leave the Add button as the one way to add; do not also add an empty row on load."
|
|
1066
|
+
] })]
|
|
1067
|
+
}),
|
|
1068
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1069
|
+
id: "props",
|
|
1070
|
+
title: "Props",
|
|
1071
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1072
|
+
"Repeater accepts every native div attribute. renderRow is handed the row's state: ",
|
|
1073
|
+
"{ index, first, last, locked, errorId }",
|
|
1074
|
+
"."
|
|
1075
|
+
] }),
|
|
1076
|
+
children: [
|
|
1077
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1078
|
+
title: "Repeater",
|
|
1079
|
+
rows: [
|
|
1080
|
+
{
|
|
1081
|
+
name: "items",
|
|
1082
|
+
type: "T[]",
|
|
1083
|
+
required: true,
|
|
1084
|
+
description: "The rows, in order. The host owns them and changes them in the callbacks."
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
name: "getKey",
|
|
1088
|
+
type: "(item: T, index: number) => string",
|
|
1089
|
+
required: true,
|
|
1090
|
+
description: "A stable key for the row, for React and for the focus after a move."
|
|
1091
|
+
},
|
|
1092
|
+
{
|
|
1093
|
+
name: "renderRow",
|
|
1094
|
+
type: "(item: T, state: RepeaterRowState) => ReactNode",
|
|
1095
|
+
description: "The row’s fields. The tools are drawn beside them (in a stacked row, in its head)."
|
|
1096
|
+
},
|
|
1097
|
+
{
|
|
1098
|
+
name: "renderCell",
|
|
1099
|
+
type: "(item: T, column: RepeaterColumn, state: RepeaterRowState) => ReactNode",
|
|
1100
|
+
description: "The columns layout’s cell for one column of a row."
|
|
1101
|
+
},
|
|
1102
|
+
{
|
|
1103
|
+
name: "renderHead",
|
|
1104
|
+
type: "(item: T, state: RepeaterRowState) => ReactNode",
|
|
1105
|
+
description: "The stacked layout’s head: the item’s name and details."
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: "onAdd",
|
|
1109
|
+
type: "() => void",
|
|
1110
|
+
description: "Appends a row: add an item. The new row is focused and announced. Without it (and addActions) there is no Add."
|
|
1111
|
+
},
|
|
1112
|
+
{
|
|
1113
|
+
name: "onRemove",
|
|
1114
|
+
type: "(index: number) => void",
|
|
1115
|
+
required: true,
|
|
1116
|
+
description: "Removes the row at index. Focus moves to the next row, the previous, or Add."
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
name: "onRestore",
|
|
1120
|
+
type: "(item: T, index: number) => void",
|
|
1121
|
+
description: "Puts a removed row back at index. Without it there is no Undo row."
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
name: "onMove",
|
|
1125
|
+
type: "(from: number, to: number) => void",
|
|
1126
|
+
description: "Moves a row. Without it there are no Move up and Move down buttons."
|
|
1127
|
+
},
|
|
1128
|
+
{
|
|
1129
|
+
name: "min",
|
|
1130
|
+
type: "number",
|
|
1131
|
+
default: "0",
|
|
1132
|
+
description: "Rows that cannot be removed below this count: Remove is held off at it."
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
name: "max",
|
|
1136
|
+
type: "number",
|
|
1137
|
+
description: "The most rows allowed: Add is held off at this count, and the max sentence shows under it and describes it."
|
|
1138
|
+
},
|
|
1139
|
+
{
|
|
1140
|
+
name: "addLabel",
|
|
1141
|
+
type: "ReactNode",
|
|
1142
|
+
default: "labels.add",
|
|
1143
|
+
description: "The Add button’s words."
|
|
1144
|
+
},
|
|
1145
|
+
{
|
|
1146
|
+
name: "empty",
|
|
1147
|
+
type: "ReactNode",
|
|
1148
|
+
description: "Drawn above Add when there are no rows."
|
|
1149
|
+
},
|
|
1150
|
+
{
|
|
1151
|
+
name: "disabled",
|
|
1152
|
+
type: "boolean",
|
|
1153
|
+
default: "false",
|
|
1154
|
+
description: "Holds off every tool and Add."
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
name: "layout",
|
|
1158
|
+
type: "'inline' | 'columns' | 'stacked'",
|
|
1159
|
+
default: "from columns and renderHead",
|
|
1160
|
+
description: "The fields beside the tools, on a grid under headings, or under a head."
|
|
1161
|
+
},
|
|
1162
|
+
{
|
|
1163
|
+
name: "columns",
|
|
1164
|
+
type: "RepeaterColumn[]",
|
|
1165
|
+
description: "The columns layout’s headings and tracks: { key, label, width? }."
|
|
1166
|
+
},
|
|
1167
|
+
{
|
|
1168
|
+
name: "addActions",
|
|
1169
|
+
type: "RepeaterAddAction[]",
|
|
1170
|
+
description: "Several Add buttons, each adding a row of its own kind: { label, onSelect, variant?, icon? }."
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
name: "addPlacement",
|
|
1174
|
+
type: "'below' | 'above' | 'both'",
|
|
1175
|
+
default: "'below'",
|
|
1176
|
+
description: "Where Add goes: under the rows, in the head, or both."
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
name: "heading",
|
|
1180
|
+
type: "ReactNode",
|
|
1181
|
+
description: "A heading over the rows, with Add at its end when it is placed above."
|
|
1182
|
+
},
|
|
1183
|
+
{
|
|
1184
|
+
name: "addSlot",
|
|
1185
|
+
type: "ReactNode",
|
|
1186
|
+
description: "A control above the rows that adds them (a product search): a row it adds fades in and is announced."
|
|
1187
|
+
},
|
|
1188
|
+
{
|
|
1189
|
+
name: "isHighlighted",
|
|
1190
|
+
type: "(item: T, index: number) => boolean",
|
|
1191
|
+
description: "The warning edge and wash, for the row that limits the whole."
|
|
1192
|
+
},
|
|
1193
|
+
{
|
|
1194
|
+
name: "getRowError",
|
|
1195
|
+
type: "(item: T, index: number) => ReactNode",
|
|
1196
|
+
description: "A row’s problem, in a Field’s error line under it, with a negative edge."
|
|
1197
|
+
},
|
|
1198
|
+
{
|
|
1199
|
+
name: "getLockedReason",
|
|
1200
|
+
type: "(item: T, index: number) => ReactNode",
|
|
1201
|
+
description: "Why a row cannot change: read only, its reason in place of the tools."
|
|
1202
|
+
},
|
|
1203
|
+
{
|
|
1204
|
+
name: "isItemRemovable",
|
|
1205
|
+
type: "(item: T, index: number) => boolean",
|
|
1206
|
+
description: "A row that cannot be removed shows “Required” in Remove’s place."
|
|
1207
|
+
},
|
|
1208
|
+
{
|
|
1209
|
+
name: "labels",
|
|
1210
|
+
type: "Partial<RepeaterLabels>",
|
|
1211
|
+
description: "Your words for everything the Repeater says."
|
|
1212
|
+
}
|
|
1213
|
+
]
|
|
1214
|
+
}),
|
|
1215
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
1216
|
+
columns: [
|
|
1217
|
+
"renderRow’s state",
|
|
1218
|
+
"Type",
|
|
1219
|
+
"What it is"
|
|
1220
|
+
],
|
|
1221
|
+
rows: [
|
|
1222
|
+
[
|
|
1223
|
+
"index",
|
|
1224
|
+
"number",
|
|
1225
|
+
"The row’s zero-based place, as the fields are drawn."
|
|
1226
|
+
],
|
|
1227
|
+
[
|
|
1228
|
+
"first",
|
|
1229
|
+
"boolean",
|
|
1230
|
+
"The first row: its Move up is held off."
|
|
1231
|
+
],
|
|
1232
|
+
[
|
|
1233
|
+
"last",
|
|
1234
|
+
"boolean",
|
|
1235
|
+
"The last row: its Move down is held off."
|
|
1236
|
+
],
|
|
1237
|
+
[
|
|
1238
|
+
"locked",
|
|
1239
|
+
"boolean",
|
|
1240
|
+
"getLockedReason gave a reason: draw the row read only."
|
|
1241
|
+
],
|
|
1242
|
+
[
|
|
1243
|
+
"errorId",
|
|
1244
|
+
"string | undefined",
|
|
1245
|
+
"The id of the row’s error line, while it has one: for your fields’ aria-describedby."
|
|
1246
|
+
]
|
|
1247
|
+
]
|
|
1248
|
+
}),
|
|
1249
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1250
|
+
title: "RepeaterLabels",
|
|
1251
|
+
rows: [
|
|
1252
|
+
{
|
|
1253
|
+
name: "add",
|
|
1254
|
+
type: "string",
|
|
1255
|
+
default: "'Add'",
|
|
1256
|
+
description: "The Add button, unless addLabel is given."
|
|
1257
|
+
},
|
|
1258
|
+
{
|
|
1259
|
+
name: "remove",
|
|
1260
|
+
type: "(position: number) => string",
|
|
1261
|
+
default: "(p) => `Remove row ${p}`",
|
|
1262
|
+
description: "Names a row’s Remove button, by its place."
|
|
1263
|
+
},
|
|
1264
|
+
{
|
|
1265
|
+
name: "moveUp",
|
|
1266
|
+
type: "(position: number) => string",
|
|
1267
|
+
default: "(p) => `Move row ${p} up`",
|
|
1268
|
+
description: "Names a row’s Move up button."
|
|
1269
|
+
},
|
|
1270
|
+
{
|
|
1271
|
+
name: "moveDown",
|
|
1272
|
+
type: "(position: number) => string",
|
|
1273
|
+
default: "(p) => `Move row ${p} down`",
|
|
1274
|
+
description: "Names a row’s Move down button."
|
|
1275
|
+
},
|
|
1276
|
+
{
|
|
1277
|
+
name: "removed",
|
|
1278
|
+
type: "(position: number) => string",
|
|
1279
|
+
default: "(p) => `Row ${p} removed`",
|
|
1280
|
+
description: "Announced after a removal."
|
|
1281
|
+
},
|
|
1282
|
+
{
|
|
1283
|
+
name: "undoLine",
|
|
1284
|
+
type: "string",
|
|
1285
|
+
default: "'Row removed'",
|
|
1286
|
+
description: "The undo row’s words. Not a place: the rows below have moved up by then."
|
|
1287
|
+
},
|
|
1288
|
+
{
|
|
1289
|
+
name: "undo",
|
|
1290
|
+
type: "string",
|
|
1291
|
+
default: "'Undo'",
|
|
1292
|
+
description: "The undo row’s button."
|
|
1293
|
+
},
|
|
1294
|
+
{
|
|
1295
|
+
name: "restored",
|
|
1296
|
+
type: "(position: number) => string",
|
|
1297
|
+
default: "(p) => `Row ${p} restored`",
|
|
1298
|
+
description: "Announced when Undo puts a row back."
|
|
1299
|
+
},
|
|
1300
|
+
{
|
|
1301
|
+
name: "added",
|
|
1302
|
+
type: "(position: number) => string",
|
|
1303
|
+
default: "(p) => `Row ${p} added`",
|
|
1304
|
+
description: "Announced when the host adds a row."
|
|
1305
|
+
},
|
|
1306
|
+
{
|
|
1307
|
+
name: "moved",
|
|
1308
|
+
type: "(position: number) => string",
|
|
1309
|
+
default: "(p) => `Moved to row ${p}`",
|
|
1310
|
+
description: "Announced after a move, with the new place."
|
|
1311
|
+
},
|
|
1312
|
+
{
|
|
1313
|
+
name: "max",
|
|
1314
|
+
type: "(max: number) => string",
|
|
1315
|
+
default: "(m) => `You can add up to ${m}`",
|
|
1316
|
+
description: "Describes the Add button, and shows under it at max."
|
|
1317
|
+
},
|
|
1318
|
+
{
|
|
1319
|
+
name: "required",
|
|
1320
|
+
type: "string",
|
|
1321
|
+
default: "'Required'",
|
|
1322
|
+
description: "The badge in Remove’s place on a row isItemRemovable keeps."
|
|
1323
|
+
}
|
|
1324
|
+
]
|
|
1325
|
+
}),
|
|
1326
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
1327
|
+
columns: ["To do this", "Use"],
|
|
1328
|
+
rows: [
|
|
1329
|
+
["Rows of the same fields a person adds and removes", "Repeater"],
|
|
1330
|
+
["A fixed set of fields, paired", /* @__PURE__ */ jsx(DocLink, {
|
|
1331
|
+
to: "/components/form-grid",
|
|
1332
|
+
children: "Form grid"
|
|
1333
|
+
})],
|
|
1334
|
+
["A label above a field, with a hint and an error", /* @__PURE__ */ jsx(DocLink, {
|
|
1335
|
+
to: "/components/input",
|
|
1336
|
+
children: "Field"
|
|
1337
|
+
})],
|
|
1338
|
+
["Nothing here yet, with room to say so", /* @__PURE__ */ jsx(DocLink, {
|
|
1339
|
+
to: "/components/empty-state",
|
|
1340
|
+
children: "Empty state"
|
|
1341
|
+
})]
|
|
1342
|
+
]
|
|
1343
|
+
})
|
|
1344
|
+
]
|
|
1345
|
+
}),
|
|
1346
|
+
/* @__PURE__ */ jsx(Fragment$1, {})
|
|
1347
|
+
]
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
//#endregion
|
|
1351
|
+
export { Page, Preview };
|