@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,1298 @@
|
|
|
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, n as CodeBlock$1, o as Example, p as SubSection, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-lM2UBSir.js";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Badge, Card, SortableGroup, SortableList, moveItem, transferItem, useSortable } from "@orbitcommerce/constellation";
|
|
7
|
+
import { ArrowsDownUpIcon, CubeIcon, ImageSquareIcon, PlayIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/sortable-list.tsx
|
|
9
|
+
/** Four images of one product, as a record page would hold them. */
|
|
10
|
+
var PRODUCT_IMAGES = [
|
|
11
|
+
{
|
|
12
|
+
id: "front",
|
|
13
|
+
name: "Arden chair, front"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "side",
|
|
17
|
+
name: "Arden chair, side"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
id: "room",
|
|
21
|
+
name: "Arden chair, in a room"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "swatch",
|
|
25
|
+
name: "Arden chair, fabric swatch"
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
/** One row of the list: a thumbnail drawn as a shape, and the image's name. */
|
|
29
|
+
function ImageRow({ image }) {
|
|
30
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
31
|
+
className: "sortable-list-image",
|
|
32
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
33
|
+
className: "sortable-list-thumb",
|
|
34
|
+
"aria-hidden": "true",
|
|
35
|
+
children: /* @__PURE__ */ jsx(ImageSquareIcon, { size: 18 })
|
|
36
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
37
|
+
className: "sortable-list-image__name",
|
|
38
|
+
children: image.name
|
|
39
|
+
})]
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Reorder a product's images: the list the component is for. */
|
|
43
|
+
function Images() {
|
|
44
|
+
const [images, setImages] = useState(PRODUCT_IMAGES);
|
|
45
|
+
return /* @__PURE__ */ jsx("div", {
|
|
46
|
+
className: "sortable-list-stage",
|
|
47
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
48
|
+
items: images,
|
|
49
|
+
"aria-label": "Product images",
|
|
50
|
+
getKey: (image) => image.id,
|
|
51
|
+
getLabel: (image) => image.name,
|
|
52
|
+
onReorder: (from, to) => setImages((was) => moveItem(was, from, to)),
|
|
53
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** The main image held first: the other rows still move past it. */
|
|
58
|
+
function HeldStill() {
|
|
59
|
+
const [images, setImages] = useState(PRODUCT_IMAGES);
|
|
60
|
+
return /* @__PURE__ */ jsx("div", {
|
|
61
|
+
className: "sortable-list-stage",
|
|
62
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
63
|
+
items: images,
|
|
64
|
+
"aria-label": "Product images, with the main image held first",
|
|
65
|
+
getKey: (image) => image.id,
|
|
66
|
+
getLabel: (image) => image.name,
|
|
67
|
+
isItemDisabled: (image) => image.id === "front",
|
|
68
|
+
onReorder: (from, to) => setImages((was) => moveItem(was, from, to)),
|
|
69
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/** The whole list off, as it would be while it saves. */
|
|
74
|
+
function ListOff() {
|
|
75
|
+
return /* @__PURE__ */ jsx("div", {
|
|
76
|
+
className: "sortable-list-stage",
|
|
77
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
78
|
+
items: PRODUCT_IMAGES,
|
|
79
|
+
"aria-label": "Product images, while they save",
|
|
80
|
+
getKey: (image) => image.id,
|
|
81
|
+
getLabel: (image) => image.name,
|
|
82
|
+
disabled: true,
|
|
83
|
+
onReorder: () => {},
|
|
84
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
85
|
+
})
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
/** Rows that draw nothing of their own, so the card around them is the surface. */
|
|
89
|
+
function PlainRows() {
|
|
90
|
+
return /* @__PURE__ */ jsx("div", {
|
|
91
|
+
className: "sortable-list-stage",
|
|
92
|
+
children: /* @__PURE__ */ jsx(Card, {
|
|
93
|
+
padding: "sm",
|
|
94
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
95
|
+
variant: "plain",
|
|
96
|
+
items: PRODUCT_IMAGES,
|
|
97
|
+
"aria-label": "Product images, inside a card",
|
|
98
|
+
getKey: (image) => image.id,
|
|
99
|
+
getLabel: (image) => image.name,
|
|
100
|
+
onReorder: () => {},
|
|
101
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** A handle of your own drawing, in place of the default grip. */
|
|
107
|
+
function OwnHandle() {
|
|
108
|
+
return /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: "sortable-list-stage",
|
|
110
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
111
|
+
items: PRODUCT_IMAGES.slice(0, 3),
|
|
112
|
+
"aria-label": "Product images, with an up and down handle",
|
|
113
|
+
getKey: (image) => image.id,
|
|
114
|
+
getLabel: (image) => image.name,
|
|
115
|
+
handleIcon: /* @__PURE__ */ jsx(ArrowsDownUpIcon, {
|
|
116
|
+
size: 16,
|
|
117
|
+
"aria-hidden": "true"
|
|
118
|
+
}),
|
|
119
|
+
onReorder: () => {},
|
|
120
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/** Your own words for the handle and the instructions it is described by. */
|
|
125
|
+
function OwnWords() {
|
|
126
|
+
return /* @__PURE__ */ jsx("div", {
|
|
127
|
+
className: "sortable-list-stage",
|
|
128
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
129
|
+
items: PRODUCT_IMAGES.slice(0, 3),
|
|
130
|
+
"aria-label": "Product images, with your own words",
|
|
131
|
+
getKey: (image) => image.id,
|
|
132
|
+
getLabel: (image) => image.name,
|
|
133
|
+
labels: {
|
|
134
|
+
handle: (name) => `Move ${name} up or down`,
|
|
135
|
+
instructions: "Press Space or Enter to lift this image. Use the arrow keys to move it, Space or Enter to drop it, or Escape to leave it where it was."
|
|
136
|
+
},
|
|
137
|
+
onReorder: () => {},
|
|
138
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
139
|
+
})
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/** An option's values, as a product's "Finish" option would hold them. */
|
|
143
|
+
var FINISHES = [
|
|
144
|
+
"Oak",
|
|
145
|
+
"Walnut",
|
|
146
|
+
"Smoked ash",
|
|
147
|
+
"White",
|
|
148
|
+
"Black"
|
|
149
|
+
];
|
|
150
|
+
/** A row of chips: the values of one product option, in the order the storefront shows them. */
|
|
151
|
+
function Chips() {
|
|
152
|
+
const [values, setValues] = useState(FINISHES);
|
|
153
|
+
return /* @__PURE__ */ jsx("div", {
|
|
154
|
+
className: "sortable-list-stage",
|
|
155
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
156
|
+
layout: "horizontal",
|
|
157
|
+
items: values,
|
|
158
|
+
"aria-label": "Finish values",
|
|
159
|
+
getKey: (value) => value,
|
|
160
|
+
getLabel: (value) => value,
|
|
161
|
+
onReorder: (from, to) => setValues((was) => moveItem(was, from, to)),
|
|
162
|
+
renderItem: (value) => /* @__PURE__ */ jsx("span", {
|
|
163
|
+
className: "sortable-list-chip",
|
|
164
|
+
children: value
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
var TILES = [
|
|
170
|
+
{
|
|
171
|
+
id: "t1",
|
|
172
|
+
name: "Arden chair, front",
|
|
173
|
+
kind: "image"
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
id: "t2",
|
|
177
|
+
name: "Arden chair, side",
|
|
178
|
+
kind: "image"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: "t3",
|
|
182
|
+
name: "Arden chair, in use",
|
|
183
|
+
kind: "video"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
id: "t4",
|
|
187
|
+
name: "Arden chair, swatch",
|
|
188
|
+
kind: "image"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: "t5",
|
|
192
|
+
name: "Arden chair, model",
|
|
193
|
+
kind: "3d"
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
id: "t6",
|
|
197
|
+
name: "Arden chair, back",
|
|
198
|
+
kind: "image"
|
|
199
|
+
}
|
|
200
|
+
];
|
|
201
|
+
/** One tile: a picture drawn as a shape, its first place marked Primary. */
|
|
202
|
+
function TileFace({ tile, position }) {
|
|
203
|
+
const Icon = tile.kind === "video" ? PlayIcon : tile.kind === "3d" ? CubeIcon : ImageSquareIcon;
|
|
204
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
205
|
+
className: "sortable-list-tile",
|
|
206
|
+
children: [
|
|
207
|
+
/* @__PURE__ */ jsx(Icon, {
|
|
208
|
+
size: 22,
|
|
209
|
+
"aria-hidden": "true"
|
|
210
|
+
}),
|
|
211
|
+
position === 0 ? /* @__PURE__ */ jsx(Badge, {
|
|
212
|
+
size: "sm",
|
|
213
|
+
variant: "solid",
|
|
214
|
+
className: "sortable-list-tile__badge",
|
|
215
|
+
children: "Primary"
|
|
216
|
+
}) : null,
|
|
217
|
+
/* @__PURE__ */ jsx("span", {
|
|
218
|
+
className: "o-sr-only",
|
|
219
|
+
children: tile.name
|
|
220
|
+
})
|
|
221
|
+
]
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
/** A grid of tiles: a product's media, the first one its primary image. */
|
|
225
|
+
function Tiles({ wholeTile = false }) {
|
|
226
|
+
const [tiles, setTiles] = useState(TILES);
|
|
227
|
+
const [opened, setOpened] = useState(null);
|
|
228
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
229
|
+
className: "sortable-list-stage sortable-list-stage--wide",
|
|
230
|
+
children: [/* @__PURE__ */ jsx(SortableList, {
|
|
231
|
+
layout: "grid",
|
|
232
|
+
handle: wholeTile ? "item" : "grip",
|
|
233
|
+
items: tiles,
|
|
234
|
+
"aria-label": "Product media",
|
|
235
|
+
getKey: (tile) => tile.id,
|
|
236
|
+
getLabel: (tile) => tile.name,
|
|
237
|
+
onReorder: (from, to) => setTiles((was) => moveItem(was, from, to)),
|
|
238
|
+
renderItem: (tile, state) => wholeTile ? /* @__PURE__ */ jsx("button", {
|
|
239
|
+
type: "button",
|
|
240
|
+
className: "sortable-list-tile-button",
|
|
241
|
+
"data-drag-handle": "",
|
|
242
|
+
onClick: () => setOpened(tile.name),
|
|
243
|
+
children: /* @__PURE__ */ jsx(TileFace, {
|
|
244
|
+
tile,
|
|
245
|
+
position: state.position
|
|
246
|
+
})
|
|
247
|
+
}) : /* @__PURE__ */ jsx(TileFace, {
|
|
248
|
+
tile,
|
|
249
|
+
position: state.position
|
|
250
|
+
})
|
|
251
|
+
}), wholeTile ? /* @__PURE__ */ jsx("p", {
|
|
252
|
+
className: "sortable-list-note",
|
|
253
|
+
"aria-live": "polite",
|
|
254
|
+
children: opened ? `Opened ${opened}` : "Click a tile to open it, or drag it to move it."
|
|
255
|
+
}) : null]
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
/** Rows dragged by the whole row: a store's delivery options. */
|
|
259
|
+
var OPTIONS = [
|
|
260
|
+
"Standard delivery",
|
|
261
|
+
"Next working day",
|
|
262
|
+
"Saturday delivery",
|
|
263
|
+
"Collect from the showroom"
|
|
264
|
+
];
|
|
265
|
+
function WholeRows() {
|
|
266
|
+
const [options, setOptions] = useState(OPTIONS);
|
|
267
|
+
return /* @__PURE__ */ jsx("div", {
|
|
268
|
+
className: "sortable-list-stage",
|
|
269
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
270
|
+
handle: "item",
|
|
271
|
+
items: options,
|
|
272
|
+
"aria-label": "Delivery options",
|
|
273
|
+
getKey: (option) => option,
|
|
274
|
+
getLabel: (option) => option,
|
|
275
|
+
onReorder: (from, to) => setOptions((was) => moveItem(was, from, to)),
|
|
276
|
+
renderItem: (option) => /* @__PURE__ */ jsx("span", {
|
|
277
|
+
className: "sortable-list-image__name",
|
|
278
|
+
children: option
|
|
279
|
+
})
|
|
280
|
+
})
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
/** Two lists items cross between: the columns a report shows, and the ones it leaves out. */
|
|
284
|
+
function TwoLists() {
|
|
285
|
+
const [lists, setLists] = useState({
|
|
286
|
+
shown: [
|
|
287
|
+
"Order number",
|
|
288
|
+
"Customer",
|
|
289
|
+
"Total"
|
|
290
|
+
],
|
|
291
|
+
hidden: ["Delivery method", "Discount code"]
|
|
292
|
+
});
|
|
293
|
+
const onMove = (move) => setLists((now) => {
|
|
294
|
+
const [from, to] = transferItem(now[move.from.list], now[move.to.list], move.from.index, move.to.index);
|
|
295
|
+
return {
|
|
296
|
+
...now,
|
|
297
|
+
[move.from.list]: from,
|
|
298
|
+
[move.to.list]: to
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
const list = (id, label) => /* @__PURE__ */ jsxs("div", {
|
|
302
|
+
className: "sortable-list-column",
|
|
303
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
304
|
+
className: "sortable-list-column__title",
|
|
305
|
+
"aria-hidden": "true",
|
|
306
|
+
children: label
|
|
307
|
+
}), /* @__PURE__ */ jsx(SortableList, {
|
|
308
|
+
listId: id,
|
|
309
|
+
"aria-label": `${label} columns`,
|
|
310
|
+
className: "sortable-list-column__list",
|
|
311
|
+
items: lists[id],
|
|
312
|
+
getKey: (field) => field,
|
|
313
|
+
getLabel: (field) => field,
|
|
314
|
+
onReorder: (from, to) => setLists((now) => ({
|
|
315
|
+
...now,
|
|
316
|
+
[id]: moveItem(now[id], from, to)
|
|
317
|
+
})),
|
|
318
|
+
renderItem: (field) => /* @__PURE__ */ jsx("span", {
|
|
319
|
+
className: "sortable-list-image__name",
|
|
320
|
+
children: field
|
|
321
|
+
})
|
|
322
|
+
})]
|
|
323
|
+
});
|
|
324
|
+
return /* @__PURE__ */ jsx("div", {
|
|
325
|
+
className: "sortable-list-columns",
|
|
326
|
+
children: /* @__PURE__ */ jsxs(SortableGroup, {
|
|
327
|
+
onMove,
|
|
328
|
+
children: [list("shown", "Shown"), list("hidden", "Hidden")]
|
|
329
|
+
})
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
/** Table rows reordered by a handle cell, on the engine's hook: a zone's delivery methods. */
|
|
333
|
+
var METHODS = [
|
|
334
|
+
{
|
|
335
|
+
name: "Standard",
|
|
336
|
+
days: "3 to 5 working days",
|
|
337
|
+
price: "£4.95"
|
|
338
|
+
},
|
|
339
|
+
{
|
|
340
|
+
name: "Next working day",
|
|
341
|
+
days: "Order by 2pm",
|
|
342
|
+
price: "£8.50"
|
|
343
|
+
},
|
|
344
|
+
{
|
|
345
|
+
name: "Saturday",
|
|
346
|
+
days: "Order by Thursday",
|
|
347
|
+
price: "£12.00"
|
|
348
|
+
},
|
|
349
|
+
{
|
|
350
|
+
name: "Collection",
|
|
351
|
+
days: "From the showroom",
|
|
352
|
+
price: "Free"
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
name: "Pallet delivery",
|
|
356
|
+
days: "5 to 7 working days",
|
|
357
|
+
price: "£45.00"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
name: "Two-person delivery",
|
|
361
|
+
days: "Booked by phone",
|
|
362
|
+
price: "£65.00"
|
|
363
|
+
}
|
|
364
|
+
];
|
|
365
|
+
function TableRows() {
|
|
366
|
+
const [methods, setMethods] = useState(METHODS);
|
|
367
|
+
const sortable = useSortable({
|
|
368
|
+
items: methods,
|
|
369
|
+
getKey: (method) => method.name,
|
|
370
|
+
getLabel: (method) => method.name,
|
|
371
|
+
onReorder: (from, to) => setMethods((was) => moveItem(was, from, to)),
|
|
372
|
+
confine: true
|
|
373
|
+
});
|
|
374
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
375
|
+
className: "sortable-list-stage sortable-list-table-frame",
|
|
376
|
+
"data-testid": "table-frame",
|
|
377
|
+
children: [/* @__PURE__ */ jsx("table", {
|
|
378
|
+
className: "sortable-list-table",
|
|
379
|
+
"aria-label": "Delivery methods",
|
|
380
|
+
children: /* @__PURE__ */ jsx("tbody", {
|
|
381
|
+
ref: sortable.zoneProps.ref,
|
|
382
|
+
onBlur: sortable.zoneProps.onBlur,
|
|
383
|
+
children: sortable.entries.map((entry) => /* @__PURE__ */ jsxs("tr", {
|
|
384
|
+
...sortable.itemProps(entry),
|
|
385
|
+
className: "sortable-list-table__row",
|
|
386
|
+
children: [
|
|
387
|
+
/* @__PURE__ */ jsx("td", {
|
|
388
|
+
className: "sortable-list-table__cell sortable-list-table__grip",
|
|
389
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
390
|
+
...sortable.handleProps(entry),
|
|
391
|
+
className: "o-sortable-list__handle",
|
|
392
|
+
"aria-label": `Move ${entry.label}`,
|
|
393
|
+
children: /* @__PURE__ */ jsx(ArrowsDownUpIcon, {
|
|
394
|
+
size: 16,
|
|
395
|
+
"aria-hidden": "true"
|
|
396
|
+
})
|
|
397
|
+
})
|
|
398
|
+
}),
|
|
399
|
+
/* @__PURE__ */ jsx("td", {
|
|
400
|
+
className: "sortable-list-table__cell",
|
|
401
|
+
children: entry.item.name
|
|
402
|
+
}),
|
|
403
|
+
/* @__PURE__ */ jsx("td", {
|
|
404
|
+
className: "sortable-list-table__cell sortable-list-table__days",
|
|
405
|
+
children: entry.item.days
|
|
406
|
+
}),
|
|
407
|
+
/* @__PURE__ */ jsx("td", {
|
|
408
|
+
className: "sortable-list-table__cell sortable-list-table__place",
|
|
409
|
+
children: entry.item.price
|
|
410
|
+
})
|
|
411
|
+
]
|
|
412
|
+
}, entry.reactKey))
|
|
413
|
+
})
|
|
414
|
+
}), sortable.outlet]
|
|
415
|
+
});
|
|
416
|
+
}
|
|
417
|
+
/** Tiles whose picture is the handle but not a grip: a click opens one, a drag past 8px moves it, Space lifts it. */
|
|
418
|
+
function PictureHandles() {
|
|
419
|
+
const [tiles, setTiles] = useState(TILES.slice(0, 4));
|
|
420
|
+
const [opened, setOpened] = useState(null);
|
|
421
|
+
const sortable = useSortable({
|
|
422
|
+
items: tiles,
|
|
423
|
+
getKey: (tile) => tile.id,
|
|
424
|
+
getLabel: (tile) => tile.name,
|
|
425
|
+
layout: "grid",
|
|
426
|
+
onReorder: (from, to) => setTiles((was) => moveItem(was, from, to)),
|
|
427
|
+
instructions: "Press Enter to open. Press Space to lift, the arrow keys to move, Space to drop, Escape to cancel."
|
|
428
|
+
});
|
|
429
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
430
|
+
className: "sortable-list-stage sortable-list-stage--wide",
|
|
431
|
+
children: [
|
|
432
|
+
/* @__PURE__ */ jsx("ul", {
|
|
433
|
+
className: "sortable-list-pictures",
|
|
434
|
+
"aria-label": "Product media",
|
|
435
|
+
...sortable.zoneProps,
|
|
436
|
+
children: sortable.entries.map((entry) => {
|
|
437
|
+
const handle = sortable.handleProps(entry, { grip: false });
|
|
438
|
+
return /* @__PURE__ */ jsx("li", {
|
|
439
|
+
...sortable.itemProps(entry),
|
|
440
|
+
className: "sortable-list-pictures__tile",
|
|
441
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
442
|
+
...handle,
|
|
443
|
+
className: "sortable-list-tile-button",
|
|
444
|
+
"aria-label": `Open ${entry.label}`,
|
|
445
|
+
onKeyDown: (event) => {
|
|
446
|
+
if (event.key === "Enter" && !sortable.scope.active) {
|
|
447
|
+
event.preventDefault();
|
|
448
|
+
setOpened(entry.item.name);
|
|
449
|
+
return;
|
|
450
|
+
}
|
|
451
|
+
handle.onKeyDown(event);
|
|
452
|
+
},
|
|
453
|
+
onClick: (event) => {
|
|
454
|
+
if (event.detail !== 0) setOpened(entry.item.name);
|
|
455
|
+
},
|
|
456
|
+
children: /* @__PURE__ */ jsx(TileFace, {
|
|
457
|
+
tile: entry.item,
|
|
458
|
+
position: entry.state.position
|
|
459
|
+
})
|
|
460
|
+
})
|
|
461
|
+
}, entry.reactKey);
|
|
462
|
+
})
|
|
463
|
+
}),
|
|
464
|
+
sortable.outlet,
|
|
465
|
+
/* @__PURE__ */ jsx("p", {
|
|
466
|
+
className: "sortable-list-note",
|
|
467
|
+
"aria-live": "polite",
|
|
468
|
+
children: opened ? `Opened ${opened}` : "Click a picture to open it, or drag it to move it."
|
|
469
|
+
})
|
|
470
|
+
]
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
/** One of everything, for the two themes side by side. */
|
|
474
|
+
function Everything() {
|
|
475
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
476
|
+
className: "sortable-list-theme",
|
|
477
|
+
children: [/* @__PURE__ */ jsx(SortableList, {
|
|
478
|
+
items: PRODUCT_IMAGES,
|
|
479
|
+
"aria-label": "Product images",
|
|
480
|
+
getKey: (image) => image.id,
|
|
481
|
+
getLabel: (image) => image.name,
|
|
482
|
+
isItemDisabled: (image) => image.id === "front",
|
|
483
|
+
onReorder: () => {},
|
|
484
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
485
|
+
}), /* @__PURE__ */ jsx(SortableList, {
|
|
486
|
+
items: PRODUCT_IMAGES.slice(0, 2),
|
|
487
|
+
"aria-label": "Product images, a list turned off",
|
|
488
|
+
getKey: (image) => image.id,
|
|
489
|
+
getLabel: (image) => image.name,
|
|
490
|
+
disabled: true,
|
|
491
|
+
onReorder: () => {},
|
|
492
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
493
|
+
})]
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
function Preview() {
|
|
497
|
+
return /* @__PURE__ */ jsx(SortableList, {
|
|
498
|
+
className: "sortable-list-preview",
|
|
499
|
+
items: PRODUCT_IMAGES.slice(0, 3),
|
|
500
|
+
"aria-label": "Product images",
|
|
501
|
+
getKey: (image) => image.id,
|
|
502
|
+
getLabel: (image) => image.name,
|
|
503
|
+
onReorder: () => {},
|
|
504
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
function Page() {
|
|
508
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
509
|
+
title: "Sortable list",
|
|
510
|
+
status: "new",
|
|
511
|
+
importNames: [
|
|
512
|
+
"SortableList",
|
|
513
|
+
"SortableGroup",
|
|
514
|
+
"moveItem",
|
|
515
|
+
"transferItem",
|
|
516
|
+
"useSortable"
|
|
517
|
+
],
|
|
518
|
+
lead: "A list a person reorders, by dragging a row's handle or by lifting it from the keyboard: a stack of rows, a row of chips or a grid of tiles. Reach for it when the order of things inside one record matters: a product's images, a store's delivery options, the fields of a custom report. A list whose order does not matter is a Row list, and rows you compare by their figures belong in a table.",
|
|
519
|
+
children: [
|
|
520
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
521
|
+
id: "basics",
|
|
522
|
+
title: "Basics",
|
|
523
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
524
|
+
"Give the list your ",
|
|
525
|
+
/* @__PURE__ */ jsx("code", { children: "items" }),
|
|
526
|
+
", a ",
|
|
527
|
+
/* @__PURE__ */ jsx("code", { children: "getKey" }),
|
|
528
|
+
" and a ",
|
|
529
|
+
/* @__PURE__ */ jsx("code", { children: "getLabel" }),
|
|
530
|
+
" for each, a",
|
|
531
|
+
" ",
|
|
532
|
+
/* @__PURE__ */ jsx("code", { children: "renderItem" }),
|
|
533
|
+
" for the row's own content, and an ",
|
|
534
|
+
/* @__PURE__ */ jsx("code", { children: "onReorder" }),
|
|
535
|
+
" that keeps the new order. The component draws the drag handle itself, before the row's content. Drag a handle with the mouse, or tab to one and lift it from the keyboard: Space or Enter picks the row up, the arrow keys move it, Space or Enter puts it down, and Escape leaves it where it was. Every move is spoken in a polite status, so the keyboard path is usable without sight of the row. A list whose order does not matter is a",
|
|
536
|
+
" ",
|
|
537
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
538
|
+
to: "/components/row-list",
|
|
539
|
+
children: "Row list"
|
|
540
|
+
}),
|
|
541
|
+
"; rows you compare by their figures belong in a",
|
|
542
|
+
" ",
|
|
543
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
544
|
+
to: "/components/table",
|
|
545
|
+
children: "Table"
|
|
546
|
+
}),
|
|
547
|
+
"."
|
|
548
|
+
] }),
|
|
549
|
+
children: [
|
|
550
|
+
/* @__PURE__ */ jsx(Example, {
|
|
551
|
+
align: "fill",
|
|
552
|
+
caption: "Drag a handle, or tab to one and press Space, then use the arrow keys.",
|
|
553
|
+
code: `
|
|
554
|
+
const [images, setImages] = useState(PRODUCT_IMAGES)
|
|
555
|
+
|
|
556
|
+
<SortableList
|
|
557
|
+
items={images}
|
|
558
|
+
aria-label="Product images"
|
|
559
|
+
getKey={(image) => image.id}
|
|
560
|
+
getLabel={(image) => image.name}
|
|
561
|
+
onReorder={(from, to) => setImages((was) => moveItem(was, from, to))}
|
|
562
|
+
renderItem={(image) => (
|
|
563
|
+
<div className="sortable-list-image">
|
|
564
|
+
<span className="sortable-list-thumb" aria-hidden="true">
|
|
565
|
+
<ImageSquareIcon size={18} />
|
|
566
|
+
</span>
|
|
567
|
+
<span className="sortable-list-image__name">{image.name}</span>
|
|
568
|
+
</div>
|
|
569
|
+
)}
|
|
570
|
+
/>`,
|
|
571
|
+
children: /* @__PURE__ */ jsx(Images, {})
|
|
572
|
+
}),
|
|
573
|
+
/* @__PURE__ */ jsxs(Note, {
|
|
574
|
+
title: "A row is the host's own",
|
|
575
|
+
children: [
|
|
576
|
+
"The list draws the handle and the row shell; everything inside the row comes from ",
|
|
577
|
+
/* @__PURE__ */ jsx("code", { children: "renderItem" }),
|
|
578
|
+
", which is handed the item and its state. Keep a row to one line, so the drag stays easy to follow."
|
|
579
|
+
]
|
|
580
|
+
}),
|
|
581
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
582
|
+
title: "Plain rows",
|
|
583
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
584
|
+
align: "fill",
|
|
585
|
+
caption: "Inside a card or a menu, the rows can leave the surface to their container.",
|
|
586
|
+
code: `
|
|
587
|
+
<Card padding="sm">
|
|
588
|
+
<SortableList
|
|
589
|
+
variant="plain"
|
|
590
|
+
items={PRODUCT_IMAGES}
|
|
591
|
+
aria-label="Product images, inside a card"
|
|
592
|
+
getKey={(image) => image.id}
|
|
593
|
+
getLabel={(image) => image.name}
|
|
594
|
+
onReorder={() => {}}
|
|
595
|
+
renderItem={(image) => <ImageRow image={image} />}
|
|
596
|
+
/>
|
|
597
|
+
</Card>`,
|
|
598
|
+
children: /* @__PURE__ */ jsx(PlainRows, {})
|
|
599
|
+
})
|
|
600
|
+
})
|
|
601
|
+
]
|
|
602
|
+
}),
|
|
603
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
604
|
+
id: "layouts",
|
|
605
|
+
title: "A row of chips, and a grid of tiles",
|
|
606
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
607
|
+
/* @__PURE__ */ jsx("code", { children: "layout=\"horizontal\"" }),
|
|
608
|
+
" lays the items out as chips in a row that wraps: the values of a product option, the order the storefront shows them in. Left and right move a lifted chip, in the order the page reads. ",
|
|
609
|
+
/* @__PURE__ */ jsx("code", { children: "layout=\"grid\"" }),
|
|
610
|
+
" lays them out as tiles in as many columns as fit: a product's pictures, the first its primary one. The arrow keys move a lifted tile in two dimensions, up and down a row as well as along it, and a pointer drag carries a lifted copy while the tile's place is held open. The grip sits in the tile's corner and shows while the tile is hovered or holds focus."
|
|
611
|
+
] }),
|
|
612
|
+
children: [/* @__PURE__ */ jsx(SubSection, {
|
|
613
|
+
title: "Chips",
|
|
614
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
615
|
+
align: "fill",
|
|
616
|
+
caption: "Drag a chip's grip along the row, or tab to it and use the left and right arrows.",
|
|
617
|
+
code: `
|
|
618
|
+
<SortableList
|
|
619
|
+
layout="horizontal"
|
|
620
|
+
items={values}
|
|
621
|
+
aria-label="Finish values"
|
|
622
|
+
getKey={(value) => value}
|
|
623
|
+
getLabel={(value) => value}
|
|
624
|
+
onReorder={(from, to) => setValues((was) => moveItem(was, from, to))}
|
|
625
|
+
renderItem={(value) => <span className="sortable-list-chip">{value}</span>}
|
|
626
|
+
/>`,
|
|
627
|
+
children: /* @__PURE__ */ jsx(Chips, {})
|
|
628
|
+
})
|
|
629
|
+
}), /* @__PURE__ */ jsxs(SubSection, {
|
|
630
|
+
title: "Tiles",
|
|
631
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
632
|
+
align: "fill",
|
|
633
|
+
caption: "Hover a tile for its grip. The Primary badge follows whichever tile is first, as you drag.",
|
|
634
|
+
code: `
|
|
635
|
+
<SortableList
|
|
636
|
+
layout="grid"
|
|
637
|
+
items={tiles}
|
|
638
|
+
aria-label="Product media"
|
|
639
|
+
getKey={(tile) => tile.id}
|
|
640
|
+
getLabel={(tile) => tile.name}
|
|
641
|
+
onReorder={(from, to) => setTiles((was) => moveItem(was, from, to))}
|
|
642
|
+
renderItem={(tile, state) => <TileFace tile={tile} position={state.position} />}
|
|
643
|
+
/>`,
|
|
644
|
+
children: /* @__PURE__ */ jsx(Tiles, {})
|
|
645
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
646
|
+
title: "A badge that follows",
|
|
647
|
+
children: [
|
|
648
|
+
/* @__PURE__ */ jsx("code", { children: "state.position" }),
|
|
649
|
+
" is where the item stands as the list is drawn now, mid-drag included, so a position badge or a Primary mark moves with the drag. ",
|
|
650
|
+
/* @__PURE__ */ jsx("code", { children: "state.index" }),
|
|
651
|
+
" stays its place in",
|
|
652
|
+
" ",
|
|
653
|
+
/* @__PURE__ */ jsx("code", { children: "items" }),
|
|
654
|
+
"."
|
|
655
|
+
]
|
|
656
|
+
})]
|
|
657
|
+
})]
|
|
658
|
+
}),
|
|
659
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
660
|
+
id: "whole-row",
|
|
661
|
+
title: "Dragging by the whole row",
|
|
662
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
663
|
+
"With ",
|
|
664
|
+
/* @__PURE__ */ jsx("code", { children: "handle=\"item\"" }),
|
|
665
|
+
" the whole row or tile drags, not only its grip. A press becomes a drag only once the pointer has moved 8px (on touch, once it has been held a moment), so a click still clicks, and the click a drag ends with is swallowed. The row's own fields, buttons and links keep the pointer to themselves; mark one of your own controls with ",
|
|
666
|
+
/* @__PURE__ */ jsx("code", { children: "data-drag-handle" }),
|
|
667
|
+
" when it should drag too, as a tile's picture button does. The grip stays, as the keyboard's way in."
|
|
668
|
+
] }),
|
|
669
|
+
children: [/* @__PURE__ */ jsx(SubSection, {
|
|
670
|
+
title: "Rows",
|
|
671
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
672
|
+
align: "fill",
|
|
673
|
+
caption: "Drag a row from anywhere on it.",
|
|
674
|
+
code: `
|
|
675
|
+
<SortableList
|
|
676
|
+
handle="item"
|
|
677
|
+
items={options}
|
|
678
|
+
aria-label="Delivery options"
|
|
679
|
+
getKey={(option) => option}
|
|
680
|
+
getLabel={(option) => option}
|
|
681
|
+
onReorder={(from, to) => setOptions((was) => moveItem(was, from, to))}
|
|
682
|
+
renderItem={(option) => <span className="sortable-list-image__name">{option}</span>}
|
|
683
|
+
/>`,
|
|
684
|
+
children: /* @__PURE__ */ jsx(WholeRows, {})
|
|
685
|
+
})
|
|
686
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
687
|
+
title: "Tiles that open",
|
|
688
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
689
|
+
align: "fill",
|
|
690
|
+
caption: "A click opens the tile; a drag moves it.",
|
|
691
|
+
code: `
|
|
692
|
+
<SortableList
|
|
693
|
+
layout="grid"
|
|
694
|
+
handle="item"
|
|
695
|
+
items={tiles}
|
|
696
|
+
aria-label="Product media"
|
|
697
|
+
getKey={(tile) => tile.id}
|
|
698
|
+
getLabel={(tile) => tile.name}
|
|
699
|
+
onReorder={(from, to) => setTiles((was) => moveItem(was, from, to))}
|
|
700
|
+
renderItem={(tile, state) => (
|
|
701
|
+
<button type="button" data-drag-handle="" onClick={() => open(tile)}>
|
|
702
|
+
<TileFace tile={tile} position={state.position} />
|
|
703
|
+
</button>
|
|
704
|
+
)}
|
|
705
|
+
/>`,
|
|
706
|
+
children: /* @__PURE__ */ jsx(Tiles, { wholeTile: true })
|
|
707
|
+
})
|
|
708
|
+
})]
|
|
709
|
+
}),
|
|
710
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
711
|
+
id: "two-lists",
|
|
712
|
+
title: "Two lists",
|
|
713
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
714
|
+
"Wrap lists in a ",
|
|
715
|
+
/* @__PURE__ */ jsx("code", { children: "SortableGroup" }),
|
|
716
|
+
" and items cross between them: the columns a report shows and the ones it leaves out. Give each list a ",
|
|
717
|
+
/* @__PURE__ */ jsx("code", { children: "listId" }),
|
|
718
|
+
", which moves name it by, and an",
|
|
719
|
+
" ",
|
|
720
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
721
|
+
" (or ",
|
|
722
|
+
/* @__PURE__ */ jsx("code", { children: "aria-labelledby" }),
|
|
723
|
+
"), which is said as an item crosses into it. From the keyboard, the arrows carry a lifted item on past the end of its list into the next (left and right when the lists sit side by side). A move within one list goes to that list's ",
|
|
724
|
+
/* @__PURE__ */ jsx("code", { children: "onReorder" }),
|
|
725
|
+
"; a move between two goes to the group's",
|
|
726
|
+
" ",
|
|
727
|
+
/* @__PURE__ */ jsx("code", { children: "onMove" }),
|
|
728
|
+
", and ",
|
|
729
|
+
/* @__PURE__ */ jsx("code", { children: "transferItem" }),
|
|
730
|
+
" does the array work. ",
|
|
731
|
+
/* @__PURE__ */ jsx("code", { children: "canDrop" }),
|
|
732
|
+
" keeps a list from taking items from another."
|
|
733
|
+
] }),
|
|
734
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
735
|
+
align: "fill",
|
|
736
|
+
caption: "Drag a field from one list to the other, or lift it and use the arrows to carry it across.",
|
|
737
|
+
code: `
|
|
738
|
+
<SortableGroup
|
|
739
|
+
onMove={(move) =>
|
|
740
|
+
setLists((now) => {
|
|
741
|
+
const [from, to] = transferItem(now[move.from.list], now[move.to.list], move.from.index, move.to.index)
|
|
742
|
+
return { ...now, [move.from.list]: from, [move.to.list]: to }
|
|
743
|
+
})
|
|
744
|
+
}
|
|
745
|
+
>
|
|
746
|
+
<SortableList listId="shown" aria-label="Shown columns" items={lists.shown} onReorder={...} {...rest} />
|
|
747
|
+
<SortableList listId="hidden" aria-label="Hidden columns" items={lists.hidden} onReorder={...} {...rest} />
|
|
748
|
+
</SortableGroup>`,
|
|
749
|
+
children: /* @__PURE__ */ jsx(TwoLists, {})
|
|
750
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
751
|
+
title: "Lists in a group draw each other's items",
|
|
752
|
+
children: [
|
|
753
|
+
"An item visiting another list is drawn there by that list's ",
|
|
754
|
+
/* @__PURE__ */ jsx("code", { children: "renderItem" }),
|
|
755
|
+
", so give the lists of a group the same kind of item. A drag in a group carries a lifted copy by default (",
|
|
756
|
+
/* @__PURE__ */ jsx("code", { children: "overlay" }),
|
|
757
|
+
")."
|
|
758
|
+
]
|
|
759
|
+
})]
|
|
760
|
+
}),
|
|
761
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
762
|
+
id: "card-rows",
|
|
763
|
+
title: "Card rows",
|
|
764
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
765
|
+
"A row with a header and a body (a pricing rule, a product option) sets its handle on its first line with",
|
|
766
|
+
" ",
|
|
767
|
+
/* @__PURE__ */ jsx("code", { children: "handleAlign=\"start\"" }),
|
|
768
|
+
", or takes the handle into its own header with",
|
|
769
|
+
" ",
|
|
770
|
+
/* @__PURE__ */ jsx("code", { children: "handlePlacement=\"inside\"" }),
|
|
771
|
+
", which hands it to ",
|
|
772
|
+
/* @__PURE__ */ jsx("code", { children: "renderItem" }),
|
|
773
|
+
" as ",
|
|
774
|
+
/* @__PURE__ */ jsx("code", { children: "state.handle" }),
|
|
775
|
+
". The ",
|
|
776
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
777
|
+
to: "/components/sortable-card",
|
|
778
|
+
children: "Sortable card"
|
|
779
|
+
}),
|
|
780
|
+
" is that card, ready made: it folds to its header while the list moves."
|
|
781
|
+
] })
|
|
782
|
+
}),
|
|
783
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
784
|
+
id: "engine",
|
|
785
|
+
title: "Building on the engine",
|
|
786
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
787
|
+
"SortableList is one part drawn on the kit's drag engine, which table rows, boards, trees and tiles share.",
|
|
788
|
+
/* @__PURE__ */ jsx("code", { children: "useSortable" }),
|
|
789
|
+
" gives one list's items in the order a drag would leave them, with the props for the list, each item and its handle, so a part that draws its own markup (rows of a table here) moves the same way, by pointer and keyboard, and says the same things. ",
|
|
790
|
+
/* @__PURE__ */ jsx("code", { children: "useSortableScope" }),
|
|
791
|
+
" and",
|
|
792
|
+
" ",
|
|
793
|
+
/* @__PURE__ */ jsx("code", { children: "useSortableList" }),
|
|
794
|
+
" bind several lists to one drag, as the",
|
|
795
|
+
" ",
|
|
796
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
797
|
+
to: "/components/kanban",
|
|
798
|
+
children: "Kanban board"
|
|
799
|
+
}),
|
|
800
|
+
" does; ",
|
|
801
|
+
/* @__PURE__ */ jsx("code", { children: "onDragMove" }),
|
|
802
|
+
" reports the pointer, for a part that draws more than the engine does (a tree's depth); ",
|
|
803
|
+
/* @__PURE__ */ jsx("code", { children: "validateMove" }),
|
|
804
|
+
" refuses a move with a sentence that is said."
|
|
805
|
+
] }),
|
|
806
|
+
children: [
|
|
807
|
+
/* @__PURE__ */ jsx(Example, {
|
|
808
|
+
align: "fill",
|
|
809
|
+
caption: "Rows of a table in a scrolling frame, moved by the handle cell. Hold a row near the frame's edge and it scrolls, never past its rows; the row stays inside the body.",
|
|
810
|
+
code: `
|
|
811
|
+
const sortable = useSortable({
|
|
812
|
+
items: methods,
|
|
813
|
+
getKey: (method) => method.name,
|
|
814
|
+
getLabel: (method) => method.name,
|
|
815
|
+
onReorder: (from, to) => setMethods((was) => moveItem(was, from, to)),
|
|
816
|
+
// The moving row stays inside the table body.
|
|
817
|
+
confine: true,
|
|
818
|
+
})
|
|
819
|
+
|
|
820
|
+
<table aria-label="Delivery methods">
|
|
821
|
+
<tbody ref={sortable.zoneProps.ref} onBlur={sortable.zoneProps.onBlur}>
|
|
822
|
+
{sortable.entries.map((entry) => (
|
|
823
|
+
<tr key={entry.reactKey} {...sortable.itemProps(entry)}>
|
|
824
|
+
<td>
|
|
825
|
+
<button {...sortable.handleProps(entry)} className="o-sortable-list__handle" aria-label={\`Move \${entry.label}\`}>
|
|
826
|
+
<ArrowsDownUpIcon size={16} aria-hidden="true" />
|
|
827
|
+
</button>
|
|
828
|
+
</td>
|
|
829
|
+
<td>{entry.item.name}</td>
|
|
830
|
+
</tr>
|
|
831
|
+
))}
|
|
832
|
+
</tbody>
|
|
833
|
+
</table>
|
|
834
|
+
{sortable.outlet}`,
|
|
835
|
+
children: /* @__PURE__ */ jsx(TableRows, {})
|
|
836
|
+
}),
|
|
837
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
838
|
+
title: "A picture as the handle",
|
|
839
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
840
|
+
"A tile whose picture opens it can still be what the keyboard lifts it by:",
|
|
841
|
+
" ",
|
|
842
|
+
/* @__PURE__ */ jsx("code", { children: "handleProps(entry, { grip: false })" }),
|
|
843
|
+
" keeps the lift on the picture (Space here, since Enter opens it), drags only once the pointer has moved past 8px (a held press on touch), and leaves a plain click to the picture's own ",
|
|
844
|
+
/* @__PURE__ */ jsx("code", { children: "onClick" }),
|
|
845
|
+
". A grip, the default, takes the press at once."
|
|
846
|
+
] }),
|
|
847
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
848
|
+
align: "fill",
|
|
849
|
+
caption: "Click a picture to open it; drag one past 8px to move it; tab to one and press Space to lift it.",
|
|
850
|
+
code: `
|
|
851
|
+
const handle = sortable.handleProps(entry, { grip: false })
|
|
852
|
+
|
|
853
|
+
<button
|
|
854
|
+
{...handle}
|
|
855
|
+
aria-label={\`Open \${entry.label}\`}
|
|
856
|
+
onKeyDown={(event) => {
|
|
857
|
+
if (event.key === 'Enter' && !sortable.scope.active) return open(entry.item)
|
|
858
|
+
handle.onKeyDown(event)
|
|
859
|
+
}}
|
|
860
|
+
onClick={(event) => event.detail !== 0 && open(entry.item)}
|
|
861
|
+
>
|
|
862
|
+
<TileFace tile={entry.item} position={entry.state.position} />
|
|
863
|
+
</button>`,
|
|
864
|
+
children: /* @__PURE__ */ jsx(PictureHandles, {})
|
|
865
|
+
})
|
|
866
|
+
}),
|
|
867
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
868
|
+
columns: ["Part", "What it is for"],
|
|
869
|
+
rows: [
|
|
870
|
+
[/* @__PURE__ */ jsx("code", { children: "useSortable(options)" }), "One list on a drag of its own: entries, zoneProps, itemProps, handleProps and the outlet to render once."],
|
|
871
|
+
[/* @__PURE__ */ jsx("code", { children: "useSortableScope(options)" }), "One drag over several lists: onMove, canDrop, validateMove, onDragMove, the words, and arrangement for the arrow keys."],
|
|
872
|
+
[/* @__PURE__ */ jsx("code", { children: "useSortableList(scope, options)" }), "Binds one list to a scope: layout, activation (the handle or the whole item), overlay, onReorder."],
|
|
873
|
+
[/* @__PURE__ */ jsx("code", { children: "confine" }), "Keeps the moving item inside its list's box, so a table row is never carried over the next group's heading."],
|
|
874
|
+
[/* @__PURE__ */ jsx("code", { children: "area" }), "A region off which a dragged item waits back home, so a drop there moves nothing (a board)."],
|
|
875
|
+
[/* @__PURE__ */ jsx("code", { children: "data-drag-handle" }), "Marks a control inside a whole-item drag that may still start one."],
|
|
876
|
+
[/* @__PURE__ */ jsx("code", { children: "handleProps(entry, { grip: false })" }), "Makes a control of its own the handle, such as a tile's picture that opens it: Space or Enter lifts the item from it, a press drags only past 8px (a held press on touch), and a plain click reaches its own onClick."]
|
|
877
|
+
]
|
|
878
|
+
})
|
|
879
|
+
]
|
|
880
|
+
}),
|
|
881
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
882
|
+
id: "held",
|
|
883
|
+
title: "Rows held still, and a list turned off",
|
|
884
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
885
|
+
"Some rows should not move: the main image of a product, the first step of a set. ",
|
|
886
|
+
/* @__PURE__ */ jsx("code", { children: "isItemDisabled" }),
|
|
887
|
+
" ",
|
|
888
|
+
"holds those in place, and the other rows still move past them, so the order can be fixed where it matters. When the whole list is saving or is otherwise out of reach, ",
|
|
889
|
+
/* @__PURE__ */ jsx("code", { children: "disabled" }),
|
|
890
|
+
" turns every handle off without hiding the rows."
|
|
891
|
+
] }),
|
|
892
|
+
children: [/* @__PURE__ */ jsx(SubSection, {
|
|
893
|
+
title: "One row that cannot be picked up",
|
|
894
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
895
|
+
align: "fill",
|
|
896
|
+
caption: "The main image stays first. Drag any other handle past it.",
|
|
897
|
+
code: `
|
|
898
|
+
<SortableList
|
|
899
|
+
items={images}
|
|
900
|
+
aria-label="Product images, with the main image held first"
|
|
901
|
+
getKey={(image) => image.id}
|
|
902
|
+
getLabel={(image) => image.name}
|
|
903
|
+
isItemDisabled={(image) => image.id === 'front'}
|
|
904
|
+
onReorder={(from, to) => setImages((was) => moveItem(was, from, to))}
|
|
905
|
+
renderItem={(image) => <ImageRow image={image} />}
|
|
906
|
+
/>`,
|
|
907
|
+
children: /* @__PURE__ */ jsx(HeldStill, {})
|
|
908
|
+
})
|
|
909
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
910
|
+
title: "The whole list off",
|
|
911
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
912
|
+
align: "fill",
|
|
913
|
+
caption: "Every handle is off. Use it while the list saves, rather than taking the rows away.",
|
|
914
|
+
code: `
|
|
915
|
+
<SortableList
|
|
916
|
+
items={images}
|
|
917
|
+
aria-label="Product images, while they save"
|
|
918
|
+
getKey={(image) => image.id}
|
|
919
|
+
getLabel={(image) => image.name}
|
|
920
|
+
disabled
|
|
921
|
+
onReorder={() => {}}
|
|
922
|
+
renderItem={(image) => <ImageRow image={image} />}
|
|
923
|
+
/>`,
|
|
924
|
+
children: /* @__PURE__ */ jsx(ListOff, {})
|
|
925
|
+
})
|
|
926
|
+
})]
|
|
927
|
+
}),
|
|
928
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
929
|
+
id: "handle",
|
|
930
|
+
title: "The handle and its words",
|
|
931
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
932
|
+
"The handle is a real button, named after its row (\"Reorder Arden chair, side\") and described by the instructions, so a screen reader reads them the first time it meets one. Give it another icon with",
|
|
933
|
+
" ",
|
|
934
|
+
/* @__PURE__ */ jsx("code", { children: "handleIcon" }),
|
|
935
|
+
", or another set of words with ",
|
|
936
|
+
/* @__PURE__ */ jsx("code", { children: "labels" }),
|
|
937
|
+
"."
|
|
938
|
+
] }),
|
|
939
|
+
children: [/* @__PURE__ */ jsx(SubSection, {
|
|
940
|
+
title: "Your own handle icon",
|
|
941
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
942
|
+
align: "fill",
|
|
943
|
+
code: `
|
|
944
|
+
<SortableList
|
|
945
|
+
items={images}
|
|
946
|
+
aria-label="Product images, with an up and down handle"
|
|
947
|
+
getKey={(image) => image.id}
|
|
948
|
+
getLabel={(image) => image.name}
|
|
949
|
+
handleIcon={<ArrowsDownUpIcon size={16} aria-hidden="true" />}
|
|
950
|
+
onReorder={() => {}}
|
|
951
|
+
renderItem={(image) => <ImageRow image={image} />}
|
|
952
|
+
/>`,
|
|
953
|
+
children: /* @__PURE__ */ jsx(OwnHandle, {})
|
|
954
|
+
})
|
|
955
|
+
}), /* @__PURE__ */ jsxs(SubSection, {
|
|
956
|
+
title: "Your own words",
|
|
957
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
958
|
+
align: "fill",
|
|
959
|
+
code: `
|
|
960
|
+
<SortableList
|
|
961
|
+
items={images}
|
|
962
|
+
getKey={(image) => image.id}
|
|
963
|
+
getLabel={(image) => image.name}
|
|
964
|
+
labels={{
|
|
965
|
+
handle: (name) => \`Move \${name} up or down\`,
|
|
966
|
+
instructions: 'Press Space or Enter to lift this image. Use the arrow keys to move it, Space or Enter to drop it, or Escape to leave it where it was.',
|
|
967
|
+
}}
|
|
968
|
+
onReorder={() => {}}
|
|
969
|
+
renderItem={(image) => <ImageRow image={image} />}
|
|
970
|
+
/>`,
|
|
971
|
+
children: /* @__PURE__ */ jsx(OwnWords, {})
|
|
972
|
+
}), /* @__PURE__ */ jsx(DocTable, {
|
|
973
|
+
columns: ["Word", "Default"],
|
|
974
|
+
rows: [
|
|
975
|
+
["handle", /* @__PURE__ */ jsx("code", { children: "(label) => `Reorder ${label}`" })],
|
|
976
|
+
["instructions", /* @__PURE__ */ jsx("code", { children: "'Press Space or Enter to lift. Use the arrow keys to move, Space or Enter to drop, Escape to cancel.'" })],
|
|
977
|
+
["lifted", /* @__PURE__ */ jsx("code", { children: "(label, position, total) => `${label} lifted, position ${position} of ${total}`" })],
|
|
978
|
+
["moved", /* @__PURE__ */ jsx("code", { children: "(label, position, total) => `${label} moved to position ${position} of ${total}`" })],
|
|
979
|
+
["dropped", /* @__PURE__ */ jsx("code", { children: "(label, position, total) => `${label} dropped at position ${position} of ${total}`" })],
|
|
980
|
+
["cancelled", /* @__PURE__ */ jsx("code", { children: "(label, position) => `Move cancelled, ${label} back at position ${position}`" })]
|
|
981
|
+
]
|
|
982
|
+
})]
|
|
983
|
+
})]
|
|
984
|
+
}),
|
|
985
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
986
|
+
id: "both-themes",
|
|
987
|
+
title: "In both themes",
|
|
988
|
+
description: /* @__PURE__ */ jsx("p", { children: "A list with a row held still and a list turned off, light and dark side by side. Lift a row to see its ring, and drag one to see it ride above the others on the raised surface." }),
|
|
989
|
+
children: /* @__PURE__ */ jsx(ThemePair, { children: /* @__PURE__ */ jsx(Everything, {}) })
|
|
990
|
+
}),
|
|
991
|
+
/* @__PURE__ */ jsx(Fragment$1, {}),
|
|
992
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
993
|
+
id: "guidelines",
|
|
994
|
+
title: "Guidelines",
|
|
995
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
996
|
+
do: {
|
|
997
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
998
|
+
className: "sortable-list-dd",
|
|
999
|
+
children: /* @__PURE__ */ jsx(SortableList, {
|
|
1000
|
+
items: PRODUCT_IMAGES.slice(0, 3),
|
|
1001
|
+
"aria-label": "Product images",
|
|
1002
|
+
getKey: (image) => image.id,
|
|
1003
|
+
getLabel: (image) => image.name,
|
|
1004
|
+
onReorder: () => {},
|
|
1005
|
+
renderItem: (image) => /* @__PURE__ */ jsx(ImageRow, { image })
|
|
1006
|
+
})
|
|
1007
|
+
}),
|
|
1008
|
+
caption: "A handle on every row. Drag it with the mouse, or lift it from the keyboard."
|
|
1009
|
+
},
|
|
1010
|
+
dont: {
|
|
1011
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1012
|
+
className: "sortable-list-dd",
|
|
1013
|
+
children: PRODUCT_IMAGES.slice(0, 2).map((image) => /* @__PURE__ */ jsx(Card, {
|
|
1014
|
+
padding: "sm",
|
|
1015
|
+
children: /* @__PURE__ */ jsx(ImageRow, { image })
|
|
1016
|
+
}, image.id))
|
|
1017
|
+
}),
|
|
1018
|
+
caption: "A plain stack: the order matters, but there is no way to change it."
|
|
1019
|
+
}
|
|
1020
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1021
|
+
"Order only matters within one record or form. Outside that, a Row list is simpler and reads better.",
|
|
1022
|
+
"Give every row a short, spoken getLabel: it names the handle and every announcement.",
|
|
1023
|
+
"Hold a row still with isItemDisabled rather than taking it out, so the rows around it keep their meaning.",
|
|
1024
|
+
"Turn the whole list off with disabled while it saves, rather than hiding the rows.",
|
|
1025
|
+
"Keep rows one line tall. A heavy row makes the drag hard to follow.",
|
|
1026
|
+
"The component owns the announcements. Do not add a live region of your own beside it."
|
|
1027
|
+
] })]
|
|
1028
|
+
}),
|
|
1029
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1030
|
+
id: "accessibility",
|
|
1031
|
+
title: "Accessibility",
|
|
1032
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1033
|
+
"The list is a real list, named by ",
|
|
1034
|
+
/* @__PURE__ */ jsx("code", { children: "aria-label" }),
|
|
1035
|
+
" when a page has more than one. Each handle is a button named after its row, described by the instructions. Lifting, each move, the drop and a cancel are spoken in a polite status that is in the page from the first render, empty until the list is used. While a row is lifted its handle says ",
|
|
1036
|
+
/* @__PURE__ */ jsx("code", { children: "aria-pressed=\"true\"" }),
|
|
1037
|
+
" and the row wears a ring, so the state is never colour alone. Focus stays on the lifted row's handle as it moves, so the keyboard path is never lost."
|
|
1038
|
+
] }),
|
|
1039
|
+
children: [
|
|
1040
|
+
/* @__PURE__ */ jsx(Example, {
|
|
1041
|
+
align: "fill",
|
|
1042
|
+
caption: "Tab to a handle and press Space to hear it: the moves are announced as you make them.",
|
|
1043
|
+
code: `
|
|
1044
|
+
<SortableList
|
|
1045
|
+
items={images}
|
|
1046
|
+
aria-label="Product images"
|
|
1047
|
+
getKey={(image) => image.id}
|
|
1048
|
+
getLabel={(image) => image.name}
|
|
1049
|
+
onReorder={(from, to) => setImages((was) => moveItem(was, from, to))}
|
|
1050
|
+
renderItem={(image) => <ImageRow image={image} />}
|
|
1051
|
+
/>`,
|
|
1052
|
+
children: /* @__PURE__ */ jsx(Images, {})
|
|
1053
|
+
}),
|
|
1054
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
1055
|
+
columns: ["Key", "What it does"],
|
|
1056
|
+
rows: [
|
|
1057
|
+
["Space or Enter", "On a handle: lift that row. While lifted: put it down where it is."],
|
|
1058
|
+
["Arrow up, or left", "While lifted: move the row up one place. In a row of chips, left and right go back and on in the order the page reads."],
|
|
1059
|
+
["Arrow down, or right", "While lifted: move the row down one place."],
|
|
1060
|
+
["Arrows in a grid", "Left and right move a tile along its row; up and down move it to the row above or below."],
|
|
1061
|
+
["Arrows in a group", "Past the first or last place, into the list before or after (left and right when the lists sit side by side)."],
|
|
1062
|
+
["Escape", "While lifted: cancel, leaving the row where it started."],
|
|
1063
|
+
["Tab", "While lifted: cancel and move on to the next control, so focus is never caught."]
|
|
1064
|
+
]
|
|
1065
|
+
}),
|
|
1066
|
+
/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1067
|
+
"A row held still by isItemDisabled has no working handle, and a list turned off with disabled has none at all. The handles stay in the Tab order, marked aria-disabled, so a list turned off while it saves keeps the focus it had; pressed, they do nothing.",
|
|
1068
|
+
"A lifted row goes back where it started if focus leaves the list any other way, with a click elsewhere on the page too, and the move is announced as cancelled.",
|
|
1069
|
+
"A pointer drag captures the pointer and follows it, and scrolls the nearest scroll box while the pointer is held near its top or bottom edge, so a row can travel past the rows in view. Escape, or a cancelled pointer, leaves the order as it was.",
|
|
1070
|
+
"The component announces every move. Do not wrap it in another live region: the two would talk over each other.",
|
|
1071
|
+
"Give the list an aria-label when a page shows more than one."
|
|
1072
|
+
] })
|
|
1073
|
+
]
|
|
1074
|
+
}),
|
|
1075
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
1076
|
+
id: "props",
|
|
1077
|
+
title: "Props",
|
|
1078
|
+
description: /* @__PURE__ */ jsx("p", { children: "SortableList also accepts every native list attribute; className, aria-label and the rest land on the list itself." }),
|
|
1079
|
+
children: [
|
|
1080
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1081
|
+
title: "SortableList",
|
|
1082
|
+
rows: [
|
|
1083
|
+
{
|
|
1084
|
+
name: "items",
|
|
1085
|
+
type: "T[]",
|
|
1086
|
+
required: true,
|
|
1087
|
+
description: "The rows, in their current order."
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
name: "getKey",
|
|
1091
|
+
type: "(item, index) => string",
|
|
1092
|
+
required: true,
|
|
1093
|
+
description: "A stable key per item. React reuses the row by it as the list reorders."
|
|
1094
|
+
},
|
|
1095
|
+
{
|
|
1096
|
+
name: "getLabel",
|
|
1097
|
+
type: "(item, index) => string",
|
|
1098
|
+
required: true,
|
|
1099
|
+
description: "Words for the item in the handle's name and the announcements."
|
|
1100
|
+
},
|
|
1101
|
+
{
|
|
1102
|
+
name: "onReorder",
|
|
1103
|
+
type: "(from, to) => void",
|
|
1104
|
+
required: true,
|
|
1105
|
+
description: "Called once per finished move, with the old and new index (never when they are equal)."
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
name: "renderItem",
|
|
1109
|
+
type: "(item, state) => ReactNode",
|
|
1110
|
+
required: true,
|
|
1111
|
+
description: "The row's content; the handle is drawn before it."
|
|
1112
|
+
},
|
|
1113
|
+
{
|
|
1114
|
+
name: "isItemDisabled",
|
|
1115
|
+
type: "(item, index) => boolean",
|
|
1116
|
+
description: "Rows that cannot be picked up (other rows can still move past them)."
|
|
1117
|
+
},
|
|
1118
|
+
{
|
|
1119
|
+
name: "disabled",
|
|
1120
|
+
type: "boolean",
|
|
1121
|
+
default: "false",
|
|
1122
|
+
description: "Turns every handle off. They keep focus (aria-disabled), so a list turned off while it saves does not drop it."
|
|
1123
|
+
},
|
|
1124
|
+
{
|
|
1125
|
+
name: "variant",
|
|
1126
|
+
type: "'card' | 'plain'",
|
|
1127
|
+
default: "'card'",
|
|
1128
|
+
description: "Each row's own bordered surface, or plain rows that draw nothing of their own, for a list inside a menu or a card."
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
name: "handleIcon",
|
|
1132
|
+
type: "ReactNode",
|
|
1133
|
+
default: "DotsSixVerticalIcon, 16px",
|
|
1134
|
+
description: "The handle's icon."
|
|
1135
|
+
},
|
|
1136
|
+
{
|
|
1137
|
+
name: "layout",
|
|
1138
|
+
type: "'vertical' | 'horizontal' | 'grid'",
|
|
1139
|
+
default: "'vertical'",
|
|
1140
|
+
description: "A stack of rows, a row of chips that wraps, or a grid of tiles moved in two dimensions."
|
|
1141
|
+
},
|
|
1142
|
+
{
|
|
1143
|
+
name: "handle",
|
|
1144
|
+
type: "'grip' | 'item'",
|
|
1145
|
+
default: "'grip'",
|
|
1146
|
+
description: "Where a pointer drag starts: the grip only, or anywhere on the row or tile once the pointer has moved 8px. The grip stays, for the keyboard."
|
|
1147
|
+
},
|
|
1148
|
+
{
|
|
1149
|
+
name: "overlay",
|
|
1150
|
+
type: "boolean",
|
|
1151
|
+
default: "true in a grid or a group",
|
|
1152
|
+
description: "A pointer drag carries a lifted copy, and the row's place is held open as a dashed slot."
|
|
1153
|
+
},
|
|
1154
|
+
{
|
|
1155
|
+
name: "renderOverlay",
|
|
1156
|
+
type: "(item, state) => ReactNode",
|
|
1157
|
+
default: "renderItem",
|
|
1158
|
+
description: "The lifted copy's content."
|
|
1159
|
+
},
|
|
1160
|
+
{
|
|
1161
|
+
name: "handleAlign",
|
|
1162
|
+
type: "'center' | 'start'",
|
|
1163
|
+
default: "'center'",
|
|
1164
|
+
description: "Centre the handle on the row, or set it on the row's first line."
|
|
1165
|
+
},
|
|
1166
|
+
{
|
|
1167
|
+
name: "handlePlacement",
|
|
1168
|
+
type: "'start' | 'inside'",
|
|
1169
|
+
default: "'start'",
|
|
1170
|
+
description: "Draw the handle before each row, or hand it to renderItem as state.handle to place inside the row."
|
|
1171
|
+
},
|
|
1172
|
+
{
|
|
1173
|
+
name: "listId",
|
|
1174
|
+
type: "string",
|
|
1175
|
+
default: "its own",
|
|
1176
|
+
description: "The list's id inside a SortableGroup, as moves name it."
|
|
1177
|
+
},
|
|
1178
|
+
{
|
|
1179
|
+
name: "activationDistance",
|
|
1180
|
+
type: "number",
|
|
1181
|
+
default: "0 on the grip, 8 on a whole row",
|
|
1182
|
+
description: "Pixels the pointer moves before a press is a drag."
|
|
1183
|
+
},
|
|
1184
|
+
{
|
|
1185
|
+
name: "labels",
|
|
1186
|
+
type: "Partial<SortableListLabels>",
|
|
1187
|
+
default: "English defaults",
|
|
1188
|
+
description: "Reword the list's own sentences, above."
|
|
1189
|
+
}
|
|
1190
|
+
]
|
|
1191
|
+
}),
|
|
1192
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1193
|
+
title: "SortableGroup",
|
|
1194
|
+
rows: [
|
|
1195
|
+
{
|
|
1196
|
+
name: "children",
|
|
1197
|
+
type: "ReactNode",
|
|
1198
|
+
required: true,
|
|
1199
|
+
description: "The SortableLists, each with a listId and an aria-label, laid out as the page needs."
|
|
1200
|
+
},
|
|
1201
|
+
{
|
|
1202
|
+
name: "onMove",
|
|
1203
|
+
type: "(move: SortableMove) => void",
|
|
1204
|
+
required: true,
|
|
1205
|
+
description: "A move from one list to another: { key, from: { list, index }, to: { list, index } }."
|
|
1206
|
+
},
|
|
1207
|
+
{
|
|
1208
|
+
name: "canDrop",
|
|
1209
|
+
type: "(from, to, key) => boolean",
|
|
1210
|
+
description: "Whether list to takes the item key from list from. A list that will not is passed over and refuses the pointer."
|
|
1211
|
+
},
|
|
1212
|
+
{
|
|
1213
|
+
name: "arrangement",
|
|
1214
|
+
type: "'horizontal' | 'vertical'",
|
|
1215
|
+
default: "read from the page",
|
|
1216
|
+
description: "How the lists sit, for the arrow keys that cross between them."
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
name: "labels",
|
|
1220
|
+
type: "Partial<SortableGroupLabels>",
|
|
1221
|
+
default: "English defaults",
|
|
1222
|
+
description: "The instructions and the four announcements, each told the list's name."
|
|
1223
|
+
}
|
|
1224
|
+
]
|
|
1225
|
+
}),
|
|
1226
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
1227
|
+
columns: [
|
|
1228
|
+
"Field",
|
|
1229
|
+
"Type",
|
|
1230
|
+
"What it says"
|
|
1231
|
+
],
|
|
1232
|
+
rows: [
|
|
1233
|
+
[
|
|
1234
|
+
"index",
|
|
1235
|
+
"number",
|
|
1236
|
+
"The row's index in items."
|
|
1237
|
+
],
|
|
1238
|
+
[
|
|
1239
|
+
"position",
|
|
1240
|
+
"number",
|
|
1241
|
+
"Where it stands as the list is drawn now, mid-drag included."
|
|
1242
|
+
],
|
|
1243
|
+
[
|
|
1244
|
+
"lifted",
|
|
1245
|
+
"boolean",
|
|
1246
|
+
"Picked up by the keyboard."
|
|
1247
|
+
],
|
|
1248
|
+
[
|
|
1249
|
+
"dragging",
|
|
1250
|
+
"boolean",
|
|
1251
|
+
"Being dragged by a pointer."
|
|
1252
|
+
],
|
|
1253
|
+
[
|
|
1254
|
+
"sorting",
|
|
1255
|
+
"boolean",
|
|
1256
|
+
"Something in the list (or its group) is moving."
|
|
1257
|
+
],
|
|
1258
|
+
[
|
|
1259
|
+
"overlay",
|
|
1260
|
+
"boolean",
|
|
1261
|
+
"Drawn in the lifted copy, not in the list."
|
|
1262
|
+
],
|
|
1263
|
+
[
|
|
1264
|
+
"disabled",
|
|
1265
|
+
"boolean",
|
|
1266
|
+
"It cannot be picked up."
|
|
1267
|
+
],
|
|
1268
|
+
[
|
|
1269
|
+
"handle",
|
|
1270
|
+
"ReactNode",
|
|
1271
|
+
"With handlePlacement=\"inside\", the handle to place in the row."
|
|
1272
|
+
]
|
|
1273
|
+
]
|
|
1274
|
+
}),
|
|
1275
|
+
/* @__PURE__ */ jsxs(SubSection, {
|
|
1276
|
+
title: "moveItem",
|
|
1277
|
+
children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
1278
|
+
"The helper the callback is easiest to write with: it returns a fresh array with the item at ",
|
|
1279
|
+
/* @__PURE__ */ jsx("code", { children: "from" }),
|
|
1280
|
+
" ",
|
|
1281
|
+
"moved to ",
|
|
1282
|
+
/* @__PURE__ */ jsx("code", { children: "to" }),
|
|
1283
|
+
", and leaves ",
|
|
1284
|
+
/* @__PURE__ */ jsx("code", { children: "items" }),
|
|
1285
|
+
" as it was."
|
|
1286
|
+
] }), /* @__PURE__ */ jsx(CodeBlock$1, { code: `
|
|
1287
|
+
import { moveItem } from '@orbitcommerce/constellation'
|
|
1288
|
+
|
|
1289
|
+
moveItem(['front', 'side', 'room'], 0, 2) // ['side', 'room', 'front']
|
|
1290
|
+
moveItem(['front', 'side', 'room'], 2, 0) // ['room', 'front', 'side']` })]
|
|
1291
|
+
})
|
|
1292
|
+
]
|
|
1293
|
+
})
|
|
1294
|
+
]
|
|
1295
|
+
});
|
|
1296
|
+
}
|
|
1297
|
+
//#endregion
|
|
1298
|
+
export { Page, Preview };
|