@orbitcommerce/constellation-docs 0.0.0-stage → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/README.md +6 -2
- package/dist/docs.css +20787 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-Mk1yIWXb.js +129 -0
- package/dist/pages/_address-data-L9BR499w.js +161 -0
- package/dist/pages/_builder-demo-C0eJUmPU.js +282 -0
- package/dist/pages/_card-art-0be5ncyV.js +18 -0
- package/dist/pages/_conversation-samples-Bq7cn-4d.js +70 -0
- package/dist/pages/_figures-data-DaDvB7Nm.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_kpi-examples-DeGCBB9T.js +208 -0
- package/dist/pages/_overlays-specimens-bawR331Z.js +320 -0
- package/dist/pages/_preview-specimens-DKQC9HAo.js +153 -0
- package/dist/pages/accordion-Sg0TUqxB.js +1036 -0
- package/dist/pages/address-autocomplete-DP0PUOlK.js +360 -0
- package/dist/pages/address-block-BZOOOPA9.js +368 -0
- package/dist/pages/address-fields-CwSqro3W.js +277 -0
- package/dist/pages/ai-highlight-D3x2vD83.js +642 -0
- package/dist/pages/alert-D3i7xZTU.js +914 -0
- package/dist/pages/anchored-overlay-BV0OCu2Q.js +788 -0
- package/dist/pages/app-shell-D4hdlHps.js +1558 -0
- package/dist/pages/area-chart-BEWFwiB2.js +718 -0
- package/dist/pages/avatar-BFEqQViw.js +895 -0
- package/dist/pages/avatar-upload-BDCzJfyN.js +484 -0
- package/dist/pages/badge-0-PyMrih.js +1035 -0
- package/dist/pages/bar-chart-DkLogYlt.js +1060 -0
- package/dist/pages/bar-fold-B-3XeIDZ.js +360 -0
- package/dist/pages/board-card-D2tZY_mU.js +415 -0
- package/dist/pages/brand-mark-BqiLvFSR.js +417 -0
- package/dist/pages/button-DAyfssDY.js +715 -0
- package/dist/pages/calendar-Ds7KsgSI.js +682 -0
- package/dist/pages/canvas-stage-1KiPspkX.js +472 -0
- package/dist/pages/card-CQEM1_wc.js +1567 -0
- package/dist/pages/caret-suggestions-oHI6QvqW.js +526 -0
- package/dist/pages/chart-legend-B20AbakD.js +724 -0
- package/dist/pages/chat-composer-CwzUJYIa.js +437 -0
- package/dist/pages/checkbox-BG9Zkb6j.js +1581 -0
- package/dist/pages/checklist-card-DEyykVFS.js +783 -0
- package/dist/pages/chip-Ck-o3Ui6.js +839 -0
- package/dist/pages/chip-list-k1LxXuCi.js +414 -0
- package/dist/pages/clamp-text-n-iE8RDR.js +203 -0
- package/dist/pages/coachmark-Be2ghobT.js +366 -0
- package/dist/pages/code-block-Dv_Y5GYq.js +622 -0
- package/dist/pages/collab-field-CfqqK7d2.js +696 -0
- package/dist/pages/color-field-CZpfcA-A.js +1127 -0
- package/dist/pages/colour-q2ntvI0w.js +1974 -0
- package/dist/pages/column-mapper-TsTG39cl.js +502 -0
- package/dist/pages/combobox-DvK2j5tI.js +1334 -0
- package/dist/pages/command-palette-CJ7uBA04.js +1386 -0
- package/dist/pages/comment-box-CDSGYhr5.js +346 -0
- package/dist/pages/composer-D4B0NgpA.js +689 -0
- package/dist/pages/condition-builder-BZy2ZGXe.js +715 -0
- package/dist/pages/conflict-chooser-C--_9UIS.js +210 -0
- package/dist/pages/context-menu-F9DV30ia.js +487 -0
- package/dist/pages/copy-button-Cn7WiKRF.js +568 -0
- package/dist/pages/copy-field-D3Xt3Jq6.js +511 -0
- package/dist/pages/danger-zone-Db_UUeiP.js +564 -0
- package/dist/pages/date-input-GOW067EB.js +956 -0
- package/dist/pages/date-picker-GdBciR99.js +1569 -0
- package/dist/pages/date-time-BLKCXtVZ.js +678 -0
- package/dist/pages/delta-CNAGv8JY.js +779 -0
- package/dist/pages/description-list-BPeXn1eW.js +1268 -0
- package/dist/pages/device-switcher-BCaN99c1.js +554 -0
- package/dist/pages/dialog-CRpkRC98.js +3164 -0
- package/dist/pages/docs-lM2UBSir.js +520 -0
- package/dist/pages/doodle-nzkqi2UI.js +201 -0
- package/dist/pages/drag-ghost-B6kpzC3O.js +426 -0
- package/dist/pages/drill-menu-cskH5mol.js +490 -0
- package/dist/pages/dropzone-DOY_Rhw0.js +1069 -0
- package/dist/pages/element-toolbar-DZIhXlCJ.js +498 -0
- package/dist/pages/emoji-picker-CqaWaffD.js +235 -0
- package/dist/pages/empty-state-4U2txFpI.js +1113 -0
- package/dist/pages/facet-filters-McbBeY9e.js +353 -0
- package/dist/pages/figure-D-HF5vCj.js +563 -0
- package/dist/pages/figure-strip-BB3mNl7D.js +1364 -0
- package/dist/pages/figure-tabs-QOeQMY6N.js +578 -0
- package/dist/pages/file-chip-DMDjtlqQ.js +738 -0
- package/dist/pages/filter-pill-DzqNOsD4.js +1295 -0
- package/dist/pages/font-picker-Bqhu0QMh.js +416 -0
- package/dist/pages/form-grid-BfWCVlie.js +692 -0
- package/dist/pages/gallery-BBk2EOri.js +453 -0
- package/dist/pages/gif-picker-CnoDTCaL.js +270 -0
- package/dist/pages/gradient-editor-Bqxp7Fxj.js +378 -0
- package/dist/pages/grouped-checklist-gNZ0tBKU.js +477 -0
- package/dist/pages/heatmap-BohgIcNk.js +507 -0
- package/dist/pages/highlight-text-BfxzfmvS.js +287 -0
- package/dist/pages/home-dashboard-CxPmvduE.js +962 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/hosted-embed-Jef3aIMP.js +163 -0
- package/dist/pages/hosted-field-BLh-53AE.js +208 -0
- package/dist/pages/hosted-field-DEpI4lVS.js +514 -0
- package/dist/pages/icon-button-Bu4Gj5sy.js +1200 -0
- package/dist/pages/icon-picker-DEyoMUTh.js +291 -0
- package/dist/pages/icon-tile-DcgxyXPF.js +592 -0
- package/dist/pages/icons-CJ9Aar3d.js +736 -0
- package/dist/pages/image-cropper-NyougqLH.js +466 -0
- package/dist/pages/image-field-7knBv4mJ.js +567 -0
- package/dist/pages/import-result-CmTtGXW_.js +486 -0
- package/dist/pages/inline-confirm-CEcI5Lxo.js +327 -0
- package/dist/pages/inline-edit-Ba39SzhM.js +1125 -0
- package/dist/pages/input-CzLCzfyx.js +2372 -0
- package/dist/pages/installation-C3UcpQJT.js +528 -0
- package/dist/pages/job-indicator-DOXWbFdl.js +755 -0
- package/dist/pages/kanban-Dy9sPAI0.js +740 -0
- package/dist/pages/kbd-UNj4zqxn.js +545 -0
- package/dist/pages/layout-primitives-CPRaZeyt.js +483 -0
- package/dist/pages/line-chart-CntWxeMF.js +1117 -0
- package/dist/pages/link-CXqvAg9z.js +689 -0
- package/dist/pages/link-picker-BMFGCC67.js +478 -0
- package/dist/pages/link-row-x8yaUuWc.js +595 -0
- package/dist/pages/live-globe-95ROMhGQ.js +715 -0
- package/dist/pages/loading-overlay-BeGuXM9G.js +456 -0
- package/dist/pages/loading-state-BNbCo51C.js +556 -0
- package/dist/pages/log-viewer-BQz8I_a2.js +503 -0
- package/dist/pages/logo-B38rnzoq.js +571 -0
- package/dist/pages/lottie_light-CxEH8eiR.js +9116 -0
- package/dist/pages/markdown-Ied72vMT.js +237 -0
- package/dist/pages/markdown-field-BfnIEKZH.js +193 -0
- package/dist/pages/media-banner-DkStCia0.js +233 -0
- package/dist/pages/menu-NrLYKqKp.js +2132 -0
- package/dist/pages/message-thread-Bo4zbxqu.js +731 -0
- package/dist/pages/meta-line-D5p2TycR.js +371 -0
- package/dist/pages/model-viewer-BfokvHoc.js +60288 -0
- package/dist/pages/model-viewer-C8PFO8wk.js +577 -0
- package/dist/pages/month-calendar-T1vw9Rup.js +457 -0
- package/dist/pages/motion-CrXtiBvA.js +865 -0
- package/dist/pages/number-input-CuyMZg18.js +968 -0
- package/dist/pages/orbit-loader-DeVBtkFE.js +219 -0
- package/dist/pages/orbit-spinner-Dxv5qAhr.js +348 -0
- package/dist/pages/otp-input-CVRoX1mw.js +591 -0
- package/dist/pages/overview-LA9XRhZc.js +130 -0
- package/dist/pages/package-dimensions-DFCyZj_T.js +192 -0
- package/dist/pages/pagination-C1EgVtW4.js +294 -0
- package/dist/pages/palette-tile-X9ZXu2Z0.js +414 -0
- package/dist/pages/password-field-DHEQKyUC.js +912 -0
- package/dist/pages/person-cell-BmjbADBz.js +564 -0
- package/dist/pages/phone-input-B3G7Qpb2.js +747 -0
- package/dist/pages/plan-card-DRaA6RuB.js +621 -0
- package/dist/pages/plan-card-DtloWvMh.js +258 -0
- package/dist/pages/plan-comparison-BVIGTtbd.js +559 -0
- package/dist/pages/plan-grid-cfPVTB5V.js +251 -0
- package/dist/pages/point-list-BbPmZjsm.js +222 -0
- package/dist/pages/popover-C3Oar9D5.js +1198 -0
- package/dist/pages/presence-avatars-CRZIk8n9.js +328 -0
- package/dist/pages/preview-frame-Bcwk0y_Q.js +1631 -0
- package/dist/pages/price-CRBLoa9h.js +604 -0
- package/dist/pages/principles-pnDyfHpK.js +483 -0
- package/dist/pages/print-page-BkLv6bW8.js +513 -0
- package/dist/pages/profile-hero-CC9dUzuN.js +498 -0
- package/dist/pages/progress-CP_awmo4.js +904 -0
- package/dist/pages/progress-ring-JuOAwk2T.js +576 -0
- package/dist/pages/radio-group-C-4tg6FS.js +1639 -0
- package/dist/pages/radius-control-B2kRA2Ch.js +441 -0
- package/dist/pages/rating-CweKN2SX.js +471 -0
- package/dist/pages/record-layout-DUP_X0RL.js +719 -0
- package/dist/pages/record-pager-y9D7JFgb.js +278 -0
- package/dist/pages/registry-BZg-xAbi.js +594 -0
- package/dist/pages/release-Cs6tl16C.js +16 -0
- package/dist/pages/repeater-BRZYKRQa.js +1351 -0
- package/dist/pages/reply-feedback-BDnHprla.js +192 -0
- package/dist/pages/reveal-BygENBbL.js +460 -0
- package/dist/pages/rich-text-DOFQZEpT.js +156 -0
- package/dist/pages/rich-text-editor-BhIM20JI.js +1265 -0
- package/dist/pages/rolldown-runtime-CbKu08Hx.js +25 -0
- package/dist/pages/rolling-number-GR3Cyfpz.js +529 -0
- package/dist/pages/row-list-Dl6CYhC-.js +1565 -0
- package/dist/pages/rule-list-DTCmIMpT.js +648 -0
- package/dist/pages/save-status-B5KkyMZP.js +378 -0
- package/dist/pages/schedule-YycI95O1.js +243 -0
- package/dist/pages/scroll-area-B2sGm23Q.js +423 -0
- package/dist/pages/search-field-D1uG7R6A.js +693 -0
- package/dist/pages/search-menu-DMuXyUUW.js +580 -0
- package/dist/pages/secret-field-Dj9x3LL8.js +337 -0
- package/dist/pages/section-rail-BtTCETS5.js +637 -0
- package/dist/pages/section-v2Pubup9.js +639 -0
- package/dist/pages/segmented-control-D-FB1K1T.js +1190 -0
- package/dist/pages/select-DZ43NpOm.js +1434 -0
- package/dist/pages/selection-chrome-Czcs6RN6.js +437 -0
- package/dist/pages/separator-CFwqRvfO.js +428 -0
- package/dist/pages/serp-preview-BGwORjmo.js +346 -0
- package/dist/pages/setting-row-Bt-dZV8H.js +913 -0
- package/dist/pages/shape-DzniHAVT.js +627 -0
- package/dist/pages/share-list-D4wgBxKN.js +926 -0
- package/dist/pages/side-panel-CCtkrZjs.js +811 -0
- package/dist/pages/site-preview-Dj1hM2Yo.js +353 -0
- package/dist/pages/skeleton-C1F5HkAu.js +1325 -0
- package/dist/pages/skip-link-BxznhSkz.js +252 -0
- package/dist/pages/slider-CAoPURKD.js +774 -0
- package/dist/pages/sortable-card-Sr44uCpI.js +424 -0
- package/dist/pages/sortable-list-DUAleYE1.js +1298 -0
- package/dist/pages/sortable-tree-BLzK-hTE.js +737 -0
- package/dist/pages/spacing-box-CtuvzxQu.js +550 -0
- package/dist/pages/sparkline-D3aavCly.js +947 -0
- package/dist/pages/split-bar-DYgZnFID.js +414 -0
- package/dist/pages/split-button-Be08-VI-.js +335 -0
- package/dist/pages/split-pane-lSNZgTKt.js +523 -0
- package/dist/pages/status-badge-DOdNhmzn.js +1074 -0
- package/dist/pages/status-checklist-CWkjCZIC.js +1152 -0
- package/dist/pages/status-dot-D99gAGsV.js +567 -0
- package/dist/pages/stepper-CxKTbEA-.js +1093 -0
- package/dist/pages/success-mark-CqFTOBEu.js +142 -0
- package/dist/pages/swatch-H_kNvHuC.js +565 -0
- package/dist/pages/switch-C93K6j9h.js +617 -0
- package/dist/pages/table-CL0vomno.js +3225 -0
- package/dist/pages/tabs-Dh0mUsLw.js +1690 -0
- package/dist/pages/tag-input-BjZWKKRJ.js +1307 -0
- package/dist/pages/task-card-Dv0sR1-w.js +295 -0
- package/dist/pages/textarea-CCM-SnGN.js +949 -0
- package/dist/pages/thumbnail-DwFJL_k1.js +1147 -0
- package/dist/pages/time-input-CA9-uZAa.js +442 -0
- package/dist/pages/time-zone-select-CEtMXVYO.js +296 -0
- package/dist/pages/timeline-BsMUTlpR.js +1798 -0
- package/dist/pages/toast-zXLRiMRT.js +1391 -0
- package/dist/pages/tool-rail-B1AbTMCP.js +355 -0
- package/dist/pages/toolbar-B9l_fHKy.js +754 -0
- package/dist/pages/tooltip-LHtCUkF-.js +826 -0
- package/dist/pages/translation-field-CTRXiF2N.js +251 -0
- package/dist/pages/tree-checklist-CJj3OcLg.js +451 -0
- package/dist/pages/tree-select-DU1qXHy_.js +492 -0
- package/dist/pages/tree-view-g_RjLtAb.js +739 -0
- package/dist/pages/typography-BSijtiRl.js +876 -0
- package/dist/pages/unit-input-Dml4fjmK.js +659 -0
- package/dist/pages/upload-rules-yozEzSah.js +419 -0
- package/dist/pages/url-upload-input-SSnMgfpA.js +307 -0
- package/dist/pages/value-change-CnubDKyO.js +489 -0
- package/dist/pages/weekly-hours-i2EpsmTx.js +287 -0
- package/dist/pages/widget-preview-CUJMyZ_k.js +625 -0
- package/dist/pages/working-status-CENemSsw.js +389 -0
- package/manifest.json +13001 -0
- package/package.json +35 -4
|
@@ -0,0 +1,3225 @@
|
|
|
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 { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Badge, Button, Card, CardHeader, Checkbox, EmptyState, IconButton, Input, Pagination, PersonCell, SegmentedControl, SkeletonTable, Table, TableBody, TableCaption, TableCell, TableDetailRow, TableExpandAll, TableExpandToggle, TableFooter, TableFrame, TableHead, TableHeaderCell, TableReorderBody, TableRow, TableSectionRow, TableUndo, Thumbnail, moveItem } from "@orbitcommerce/constellation";
|
|
7
|
+
import { DotsThreeIcon, PackageIcon, PrinterIcon, TrashIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/_table-parts.tsx
|
|
9
|
+
var gbp$1 = new Intl.NumberFormat("en-GB", {
|
|
10
|
+
style: "currency",
|
|
11
|
+
currency: "GBP"
|
|
12
|
+
});
|
|
13
|
+
var STOCK = [
|
|
14
|
+
{
|
|
15
|
+
sku: "ARD-CHAIR-BLK",
|
|
16
|
+
name: "Arden ergonomic chair, black",
|
|
17
|
+
bin: "A-04",
|
|
18
|
+
onHand: 42,
|
|
19
|
+
held: 6
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
sku: "ARD-CHAIR-GRY",
|
|
23
|
+
name: "Arden ergonomic chair, grey",
|
|
24
|
+
bin: "A-05",
|
|
25
|
+
onHand: 18,
|
|
26
|
+
held: 2
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
sku: "WAL-DESK-140",
|
|
30
|
+
name: "Walnut desk, 140cm",
|
|
31
|
+
bin: "C-11",
|
|
32
|
+
onHand: 7,
|
|
33
|
+
held: 3
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
sku: "WAL-DESK-160",
|
|
37
|
+
name: "Walnut desk, 160cm",
|
|
38
|
+
bin: "C-12",
|
|
39
|
+
onHand: 4,
|
|
40
|
+
held: 0
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
sku: "CAB-TRAY-01",
|
|
44
|
+
name: "Cable tray",
|
|
45
|
+
bin: "F-02",
|
|
46
|
+
onHand: 130,
|
|
47
|
+
held: 12
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
sku: "MRL-LAMP-030",
|
|
51
|
+
name: "Marlow desk lamp",
|
|
52
|
+
bin: "F-08",
|
|
53
|
+
onHand: 88,
|
|
54
|
+
held: 9
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
/** A long list read across: every second row on the light sunken ground. */
|
|
58
|
+
function StripedDemo() {
|
|
59
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
60
|
+
className: "table-demo",
|
|
61
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
62
|
+
striped: true,
|
|
63
|
+
density: "compact",
|
|
64
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
65
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Product" }),
|
|
66
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "SKU" }),
|
|
67
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Bin" }),
|
|
68
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
69
|
+
align: "end",
|
|
70
|
+
children: "On hand"
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
73
|
+
align: "end",
|
|
74
|
+
children: "Held for orders"
|
|
75
|
+
})
|
|
76
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: STOCK.map((line) => /* @__PURE__ */ jsxs(TableRow, {
|
|
77
|
+
interactive: true,
|
|
78
|
+
selected: line.sku === "WAL-DESK-140",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
81
|
+
href: "#stripes",
|
|
82
|
+
children: line.name
|
|
83
|
+
}) }),
|
|
84
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
85
|
+
className: "table-demo__quiet",
|
|
86
|
+
children: line.sku
|
|
87
|
+
}),
|
|
88
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.bin }),
|
|
89
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
90
|
+
numeric: true,
|
|
91
|
+
children: line.onHand
|
|
92
|
+
}),
|
|
93
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
94
|
+
numeric: true,
|
|
95
|
+
children: line.held
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
}, line.sku)) })]
|
|
99
|
+
})
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
var MONTHS = [
|
|
103
|
+
"Apr",
|
|
104
|
+
"May",
|
|
105
|
+
"Jun",
|
|
106
|
+
"Jul",
|
|
107
|
+
"Aug",
|
|
108
|
+
"Sep",
|
|
109
|
+
"Oct",
|
|
110
|
+
"Nov",
|
|
111
|
+
"Dec"
|
|
112
|
+
];
|
|
113
|
+
/** A report wider than its frame: the shadows say there is more on each side. Scrolled a little way in to begin with. */
|
|
114
|
+
function EdgesDemo() {
|
|
115
|
+
const scroller = useRef(null);
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (scroller.current) scroller.current.scrollLeft = 160;
|
|
118
|
+
}, []);
|
|
119
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
120
|
+
ref: scroller,
|
|
121
|
+
className: "table-demo",
|
|
122
|
+
role: "region",
|
|
123
|
+
"aria-label": "Sales by month, scrolls sideways",
|
|
124
|
+
tabIndex: 0,
|
|
125
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
126
|
+
nowrap: true,
|
|
127
|
+
className: "table-demo__wide",
|
|
128
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [/* @__PURE__ */ jsx(TableHeaderCell, { children: "Product" }), MONTHS.map((month) => /* @__PURE__ */ jsxs(TableHeaderCell, {
|
|
129
|
+
align: "end",
|
|
130
|
+
children: [month, " 2026"]
|
|
131
|
+
}, month))] }) }), /* @__PURE__ */ jsx(TableBody, { children: STOCK.slice(0, 4).map((line, row) => /* @__PURE__ */ jsxs(TableRow, { children: [/* @__PURE__ */ jsx(TableCell, { children: line.name }), MONTHS.map((month, column) => /* @__PURE__ */ jsx(TableCell, {
|
|
132
|
+
numeric: true,
|
|
133
|
+
children: gbp$1.format(240 + (row * 37 + column * 53) % 410 * 3)
|
|
134
|
+
}, month))] }, line.sku)) })]
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
var PRODUCTS = [
|
|
139
|
+
{
|
|
140
|
+
id: "p1",
|
|
141
|
+
name: "Titanium spork 4-pack",
|
|
142
|
+
tone: 4,
|
|
143
|
+
variants: [{
|
|
144
|
+
id: "p1-blue",
|
|
145
|
+
name: "Blue",
|
|
146
|
+
price: 15.5,
|
|
147
|
+
stock: 34
|
|
148
|
+
}, {
|
|
149
|
+
id: "p1-red",
|
|
150
|
+
name: "Red",
|
|
151
|
+
price: 15.5,
|
|
152
|
+
stock: 12
|
|
153
|
+
}]
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
id: "p2",
|
|
157
|
+
name: "Hip pack 3L",
|
|
158
|
+
tone: 3,
|
|
159
|
+
variants: [
|
|
160
|
+
{
|
|
161
|
+
id: "p2-blue",
|
|
162
|
+
name: "Blue",
|
|
163
|
+
price: 26.5,
|
|
164
|
+
stock: 9
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
id: "p2-red",
|
|
168
|
+
name: "Red",
|
|
169
|
+
price: 26.5,
|
|
170
|
+
stock: 0
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
id: "p2-green",
|
|
174
|
+
name: "Moss green",
|
|
175
|
+
price: 28,
|
|
176
|
+
stock: 21
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
id: "p3",
|
|
182
|
+
name: "Enamel camping mug",
|
|
183
|
+
tone: 2,
|
|
184
|
+
variants: [{
|
|
185
|
+
id: "p3-one",
|
|
186
|
+
name: "One size",
|
|
187
|
+
price: 9.99,
|
|
188
|
+
stock: 140
|
|
189
|
+
}]
|
|
190
|
+
}
|
|
191
|
+
];
|
|
192
|
+
/** A drawn stand-in for a product photo: a soft tile in one of the chart colours. */
|
|
193
|
+
function Swatch({ tone, size = "sm" }) {
|
|
194
|
+
return /* @__PURE__ */ jsx(Thumbnail, {
|
|
195
|
+
alt: "",
|
|
196
|
+
size,
|
|
197
|
+
fallback: /* @__PURE__ */ jsx("span", {
|
|
198
|
+
className: "table-demo__swatch",
|
|
199
|
+
style: { "--table-demo-swatch": `var(--o-chart-${tone})` }
|
|
200
|
+
})
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Products that open into their variants: the group row has its own cells (a box that is part ticked over its
|
|
205
|
+
* variants, a picture, a price that sets every variant's, the stock they add up to) and its variants hang beneath.
|
|
206
|
+
*/
|
|
207
|
+
function TreeDemo() {
|
|
208
|
+
const groups = PRODUCTS.filter((product) => product.variants.length > 1);
|
|
209
|
+
const [open, setOpen] = useState({ p2: true });
|
|
210
|
+
const [justOpened, setJustOpened] = useState(null);
|
|
211
|
+
const [chosen, setChosen] = useState({ "p2-green": true });
|
|
212
|
+
const allOpen = groups.every((product) => open[product.id]);
|
|
213
|
+
const toggle = (id, next) => {
|
|
214
|
+
setOpen((state) => ({
|
|
215
|
+
...state,
|
|
216
|
+
[id]: next
|
|
217
|
+
}));
|
|
218
|
+
setJustOpened(next ? id : null);
|
|
219
|
+
};
|
|
220
|
+
const chooseAll = (product, next) => setChosen((state) => ({
|
|
221
|
+
...state,
|
|
222
|
+
...Object.fromEntries(product.variants.map((variant) => [variant.id, next]))
|
|
223
|
+
}));
|
|
224
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
225
|
+
className: "table-demo__states",
|
|
226
|
+
children: [/* @__PURE__ */ jsx(TableExpandAll, {
|
|
227
|
+
expanded: allOpen,
|
|
228
|
+
onExpandedChange: (next) => {
|
|
229
|
+
setOpen(Object.fromEntries(groups.map((product) => [product.id, next])));
|
|
230
|
+
setJustOpened(null);
|
|
231
|
+
}
|
|
232
|
+
}), /* @__PURE__ */ jsx(TableFrame, {
|
|
233
|
+
className: "table-demo",
|
|
234
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
235
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
236
|
+
style: { width: 44 },
|
|
237
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
238
|
+
className: "o-sr-only",
|
|
239
|
+
children: "Select"
|
|
240
|
+
})
|
|
241
|
+
}),
|
|
242
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
243
|
+
style: { minWidth: 240 },
|
|
244
|
+
children: "Product"
|
|
245
|
+
}),
|
|
246
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
247
|
+
align: "end",
|
|
248
|
+
children: "Price"
|
|
249
|
+
}),
|
|
250
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
251
|
+
align: "end",
|
|
252
|
+
children: "Stock"
|
|
253
|
+
})
|
|
254
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: PRODUCTS.map((product) => {
|
|
255
|
+
const many = product.variants.length > 1;
|
|
256
|
+
const isOpen = many && Boolean(open[product.id]);
|
|
257
|
+
const ticked = product.variants.filter((variant) => chosen[variant.id]).length;
|
|
258
|
+
const box = ticked === 0 ? false : ticked === product.variants.length ? true : "indeterminate";
|
|
259
|
+
const stock = product.variants.reduce((sum, variant) => sum + variant.stock, 0);
|
|
260
|
+
if (!many) {
|
|
261
|
+
const only = product.variants[0];
|
|
262
|
+
return /* @__PURE__ */ jsxs(TableRow, {
|
|
263
|
+
selected: !!chosen[only.id],
|
|
264
|
+
children: [
|
|
265
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
266
|
+
"aria-label": `Select ${product.name}`,
|
|
267
|
+
checked: !!chosen[only.id],
|
|
268
|
+
onCheckedChange: (next) => setChosen((state) => ({
|
|
269
|
+
...state,
|
|
270
|
+
[only.id]: next === true
|
|
271
|
+
}))
|
|
272
|
+
}) }),
|
|
273
|
+
/* @__PURE__ */ jsxs(TableCell, {
|
|
274
|
+
indent: true,
|
|
275
|
+
children: [/* @__PURE__ */ jsx(TableExpandToggle, {
|
|
276
|
+
expandable: false,
|
|
277
|
+
expanded: false,
|
|
278
|
+
label: `Variants of ${product.name}`
|
|
279
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
280
|
+
className: "table-demo__product",
|
|
281
|
+
children: [/* @__PURE__ */ jsx(Swatch, { tone: product.tone }), /* @__PURE__ */ jsx("span", { children: product.name })]
|
|
282
|
+
})]
|
|
283
|
+
}),
|
|
284
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
285
|
+
numeric: true,
|
|
286
|
+
children: gbp$1.format(only.price)
|
|
287
|
+
}),
|
|
288
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
289
|
+
numeric: true,
|
|
290
|
+
children: only.stock
|
|
291
|
+
})
|
|
292
|
+
]
|
|
293
|
+
}, product.id);
|
|
294
|
+
}
|
|
295
|
+
return [/* @__PURE__ */ jsxs(TableRow, {
|
|
296
|
+
expanded: isOpen,
|
|
297
|
+
selected: box === true,
|
|
298
|
+
children: [
|
|
299
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
300
|
+
"aria-label": `Select every ${product.name}`,
|
|
301
|
+
checked: box,
|
|
302
|
+
onCheckedChange: (next) => chooseAll(product, next === true)
|
|
303
|
+
}) }),
|
|
304
|
+
/* @__PURE__ */ jsxs(TableCell, {
|
|
305
|
+
indent: true,
|
|
306
|
+
children: [/* @__PURE__ */ jsx(TableExpandToggle, {
|
|
307
|
+
expanded: isOpen,
|
|
308
|
+
onExpandedChange: (next) => toggle(product.id, next),
|
|
309
|
+
label: `Variants of ${product.name}`,
|
|
310
|
+
controls: `${product.id}-first`
|
|
311
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
312
|
+
className: "table-demo__product",
|
|
313
|
+
children: [/* @__PURE__ */ jsx(Swatch, { tone: product.tone }), /* @__PURE__ */ jsxs("span", {
|
|
314
|
+
className: "table-demo__product-name",
|
|
315
|
+
children: [/* @__PURE__ */ jsx("span", { children: product.name }), /* @__PURE__ */ jsxs("span", {
|
|
316
|
+
className: "table-demo__quiet",
|
|
317
|
+
children: [product.variants.length, " variants"]
|
|
318
|
+
})]
|
|
319
|
+
})]
|
|
320
|
+
})]
|
|
321
|
+
}),
|
|
322
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
323
|
+
align: "end",
|
|
324
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
325
|
+
size: "sm",
|
|
326
|
+
className: "table-demo__set-all",
|
|
327
|
+
"aria-label": `Price of every ${product.name}, in pounds`,
|
|
328
|
+
placeholder: "Set all"
|
|
329
|
+
})
|
|
330
|
+
}),
|
|
331
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
332
|
+
numeric: true,
|
|
333
|
+
children: stock
|
|
334
|
+
})
|
|
335
|
+
]
|
|
336
|
+
}, product.id), ...isOpen ? product.variants.map((variant, index) => /* @__PURE__ */ jsxs(TableRow, {
|
|
337
|
+
id: index === 0 ? `${product.id}-first` : void 0,
|
|
338
|
+
level: 1,
|
|
339
|
+
last: index === product.variants.length - 1,
|
|
340
|
+
entering: justOpened === product.id ? index : void 0,
|
|
341
|
+
selected: !!chosen[variant.id],
|
|
342
|
+
children: [
|
|
343
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
344
|
+
"aria-label": `Select ${product.name}, ${variant.name}`,
|
|
345
|
+
checked: !!chosen[variant.id],
|
|
346
|
+
onCheckedChange: (next) => setChosen((state) => ({
|
|
347
|
+
...state,
|
|
348
|
+
[variant.id]: next === true
|
|
349
|
+
}))
|
|
350
|
+
}) }),
|
|
351
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
352
|
+
indent: true,
|
|
353
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
354
|
+
className: "table-demo__product",
|
|
355
|
+
children: [/* @__PURE__ */ jsx(Swatch, {
|
|
356
|
+
tone: (product.tone + index) % 8 + 1,
|
|
357
|
+
size: "xs"
|
|
358
|
+
}), /* @__PURE__ */ jsx("span", { children: variant.name })]
|
|
359
|
+
})
|
|
360
|
+
}),
|
|
361
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
362
|
+
numeric: true,
|
|
363
|
+
children: gbp$1.format(variant.price)
|
|
364
|
+
}),
|
|
365
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
366
|
+
numeric: true,
|
|
367
|
+
children: variant.stock
|
|
368
|
+
})
|
|
369
|
+
]
|
|
370
|
+
}, variant.id)) : []];
|
|
371
|
+
}) })] })
|
|
372
|
+
})]
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
var LINES$1 = [{
|
|
376
|
+
id: "l1",
|
|
377
|
+
sku: "ARD-CHAIR-BLK",
|
|
378
|
+
item: "Arden ergonomic chair",
|
|
379
|
+
shipped: "2 of 2",
|
|
380
|
+
tone: "positive",
|
|
381
|
+
parcels: [{
|
|
382
|
+
ref: "DPD 1550 2231 0081",
|
|
383
|
+
date: "3 Mar",
|
|
384
|
+
items: 1
|
|
385
|
+
}, {
|
|
386
|
+
ref: "DPD 1550 2231 0094",
|
|
387
|
+
date: "4 Mar",
|
|
388
|
+
items: 1
|
|
389
|
+
}]
|
|
390
|
+
}, {
|
|
391
|
+
id: "l2",
|
|
392
|
+
sku: "WAL-DESK-140",
|
|
393
|
+
item: "Walnut desk, 140cm",
|
|
394
|
+
shipped: "0 of 1",
|
|
395
|
+
tone: "neutral",
|
|
396
|
+
parcels: []
|
|
397
|
+
}];
|
|
398
|
+
/** Order lines: the one sent in two parcels opens to list them, from a toggle at the end of its row. */
|
|
399
|
+
function DetailDemo() {
|
|
400
|
+
const [open, setOpen] = useState({ l1: true });
|
|
401
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
402
|
+
className: "table-demo",
|
|
403
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
404
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
405
|
+
style: { minWidth: 180 },
|
|
406
|
+
children: "Item"
|
|
407
|
+
}),
|
|
408
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "SKU" }),
|
|
409
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Sent" }),
|
|
410
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
411
|
+
style: { width: 52 },
|
|
412
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
413
|
+
className: "o-sr-only",
|
|
414
|
+
children: "Parcels"
|
|
415
|
+
})
|
|
416
|
+
})
|
|
417
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: LINES$1.map((line) => {
|
|
418
|
+
const many = line.parcels.length > 1;
|
|
419
|
+
const isOpen = many && Boolean(open[line.id]);
|
|
420
|
+
return [/* @__PURE__ */ jsxs(TableRow, {
|
|
421
|
+
expanded: isOpen,
|
|
422
|
+
children: [
|
|
423
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.item }),
|
|
424
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
425
|
+
className: "table-demo__quiet",
|
|
426
|
+
children: line.sku
|
|
427
|
+
}),
|
|
428
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
429
|
+
size: "sm",
|
|
430
|
+
tone: line.tone,
|
|
431
|
+
dot: true,
|
|
432
|
+
children: line.shipped
|
|
433
|
+
}) }),
|
|
434
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
435
|
+
align: "end",
|
|
436
|
+
children: /* @__PURE__ */ jsx(TableExpandToggle, {
|
|
437
|
+
expandable: many,
|
|
438
|
+
expanded: isOpen,
|
|
439
|
+
onExpandedChange: (next) => setOpen((state) => ({
|
|
440
|
+
...state,
|
|
441
|
+
[line.id]: next
|
|
442
|
+
})),
|
|
443
|
+
label: `Parcels for ${line.sku}`,
|
|
444
|
+
controls: `${line.id}-parcels`
|
|
445
|
+
})
|
|
446
|
+
})
|
|
447
|
+
]
|
|
448
|
+
}, line.id), isOpen ? /* @__PURE__ */ jsx(TableDetailRow, {
|
|
449
|
+
id: `${line.id}-parcels`,
|
|
450
|
+
colSpan: 4,
|
|
451
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
452
|
+
className: "table-demo__parcels",
|
|
453
|
+
children: line.parcels.map((parcel) => /* @__PURE__ */ jsxs("li", {
|
|
454
|
+
className: "table-demo__parcel",
|
|
455
|
+
children: [/* @__PURE__ */ jsx("span", { children: parcel.ref }), /* @__PURE__ */ jsxs("span", {
|
|
456
|
+
className: "table-demo__quiet",
|
|
457
|
+
children: [
|
|
458
|
+
parcel.items,
|
|
459
|
+
" item, sent ",
|
|
460
|
+
parcel.date
|
|
461
|
+
]
|
|
462
|
+
})]
|
|
463
|
+
}, parcel.ref))
|
|
464
|
+
})
|
|
465
|
+
}, `${line.id}-parcels`) : null];
|
|
466
|
+
}) })] })
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
var IMPORTS = [
|
|
470
|
+
{
|
|
471
|
+
row: 2,
|
|
472
|
+
name: "Arden ergonomic chair",
|
|
473
|
+
sku: "ARD-CHAIR-BLK",
|
|
474
|
+
status: "Imported",
|
|
475
|
+
tone: "positive"
|
|
476
|
+
},
|
|
477
|
+
{
|
|
478
|
+
row: 3,
|
|
479
|
+
name: "Walnut desk, 140cm",
|
|
480
|
+
sku: "WAL-DESK-140",
|
|
481
|
+
status: "Failed",
|
|
482
|
+
tone: "negative",
|
|
483
|
+
why: "The SKU WAL-DESK-140 is already in use by another product."
|
|
484
|
+
},
|
|
485
|
+
{
|
|
486
|
+
row: 4,
|
|
487
|
+
name: "Cable tray",
|
|
488
|
+
sku: "CAB-TRAY-01",
|
|
489
|
+
status: "Imported",
|
|
490
|
+
tone: "positive"
|
|
491
|
+
}
|
|
492
|
+
];
|
|
493
|
+
/** An import's rows: a failed row keeps a note under it that says why. */
|
|
494
|
+
function NoteDemo() {
|
|
495
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
496
|
+
className: "table-demo",
|
|
497
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
498
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
499
|
+
align: "end",
|
|
500
|
+
style: { width: 64 },
|
|
501
|
+
children: "Row"
|
|
502
|
+
}),
|
|
503
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Product" }),
|
|
504
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "SKU" }),
|
|
505
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Result" })
|
|
506
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: IMPORTS.map((line) => [/* @__PURE__ */ jsxs(TableRow, { children: [
|
|
507
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
508
|
+
numeric: true,
|
|
509
|
+
children: line.row
|
|
510
|
+
}),
|
|
511
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.name }),
|
|
512
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
513
|
+
className: "table-demo__quiet",
|
|
514
|
+
children: line.sku
|
|
515
|
+
}),
|
|
516
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
517
|
+
size: "sm",
|
|
518
|
+
tone: line.tone,
|
|
519
|
+
dot: true,
|
|
520
|
+
children: line.status
|
|
521
|
+
}) })
|
|
522
|
+
] }, line.row), line.why ? /* @__PURE__ */ jsx(TableDetailRow, {
|
|
523
|
+
colSpan: 4,
|
|
524
|
+
variant: "note",
|
|
525
|
+
tone: "negative",
|
|
526
|
+
inset: 58,
|
|
527
|
+
children: line.why
|
|
528
|
+
}, `${line.row}-why`) : null]) })] })
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
var ACTIVITY = [
|
|
532
|
+
{
|
|
533
|
+
section: "Today",
|
|
534
|
+
rows: [{
|
|
535
|
+
who: "Priya Shah",
|
|
536
|
+
what: "Changed the price of Arden ergonomic chair",
|
|
537
|
+
when: "14:02"
|
|
538
|
+
}, {
|
|
539
|
+
who: "James Okafor",
|
|
540
|
+
what: "Refunded order #1040",
|
|
541
|
+
when: "11:47"
|
|
542
|
+
}]
|
|
543
|
+
},
|
|
544
|
+
{
|
|
545
|
+
section: "This week",
|
|
546
|
+
rows: [{
|
|
547
|
+
who: "Priya Shah",
|
|
548
|
+
what: "Added the supplier Harbour Desk Co",
|
|
549
|
+
when: "Mon 12 Oct"
|
|
550
|
+
}]
|
|
551
|
+
},
|
|
552
|
+
{
|
|
553
|
+
section: "Earlier",
|
|
554
|
+
rows: [{
|
|
555
|
+
who: "Tom Hughes",
|
|
556
|
+
what: "Turned on two-step sign-in",
|
|
557
|
+
when: "28 Sep"
|
|
558
|
+
}]
|
|
559
|
+
}
|
|
560
|
+
];
|
|
561
|
+
/** An activity log in three groups by when, each a body of its own under its heading. */
|
|
562
|
+
function SectionDemo() {
|
|
563
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
564
|
+
className: "table-demo",
|
|
565
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
566
|
+
density: "compact",
|
|
567
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
568
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Who" }),
|
|
569
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "What" }),
|
|
570
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
571
|
+
align: "end",
|
|
572
|
+
children: "When"
|
|
573
|
+
})
|
|
574
|
+
] }) }), ACTIVITY.map((group) => /* @__PURE__ */ jsxs(TableBody, { children: [/* @__PURE__ */ jsx(TableSectionRow, {
|
|
575
|
+
colSpan: 3,
|
|
576
|
+
children: group.section
|
|
577
|
+
}), group.rows.map((row) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
578
|
+
/* @__PURE__ */ jsx(TableCell, { children: row.who }),
|
|
579
|
+
/* @__PURE__ */ jsx(TableCell, { children: row.what }),
|
|
580
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
581
|
+
align: "end",
|
|
582
|
+
className: "table-demo__quiet",
|
|
583
|
+
children: row.when
|
|
584
|
+
})
|
|
585
|
+
] }, row.what))] }, group.section))]
|
|
586
|
+
})
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
var BULK = [
|
|
590
|
+
{
|
|
591
|
+
id: "b1",
|
|
592
|
+
name: "Arden ergonomic chair",
|
|
593
|
+
status: "Active",
|
|
594
|
+
price: 240,
|
|
595
|
+
cost: 132,
|
|
596
|
+
sku: "ARD-CHAIR-BLK",
|
|
597
|
+
barcode: "5060123450011",
|
|
598
|
+
weight: "14.2 kg",
|
|
599
|
+
brand: "Arden"
|
|
600
|
+
},
|
|
601
|
+
{
|
|
602
|
+
id: "b2",
|
|
603
|
+
name: "Walnut desk, 140cm",
|
|
604
|
+
status: "Active",
|
|
605
|
+
price: 620,
|
|
606
|
+
cost: 318,
|
|
607
|
+
sku: "WAL-DESK-140",
|
|
608
|
+
barcode: "5060123450028",
|
|
609
|
+
weight: "31.0 kg",
|
|
610
|
+
brand: "Harbour Desk Co"
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
id: "b3",
|
|
614
|
+
name: "Cable tray",
|
|
615
|
+
status: "Draft",
|
|
616
|
+
price: 18.5,
|
|
617
|
+
cost: 6.2,
|
|
618
|
+
sku: "CAB-TRAY-01",
|
|
619
|
+
barcode: "5060123450035",
|
|
620
|
+
weight: "0.9 kg",
|
|
621
|
+
brand: "Harbour Desk Co"
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
id: "b4",
|
|
625
|
+
name: "Marlow desk lamp",
|
|
626
|
+
status: "Active",
|
|
627
|
+
price: 64,
|
|
628
|
+
cost: 27,
|
|
629
|
+
sku: "MRL-LAMP-030",
|
|
630
|
+
barcode: "5060123450042",
|
|
631
|
+
weight: "1.4 kg",
|
|
632
|
+
brand: "Marlow"
|
|
633
|
+
}
|
|
634
|
+
];
|
|
635
|
+
/** A bulk editor's grid: the box and the product stay at the start, the actions at the end, the rest slides between. */
|
|
636
|
+
function StickyStartDemo() {
|
|
637
|
+
const [chosen, setChosen] = useState({ b2: true });
|
|
638
|
+
const scroller = useRef(null);
|
|
639
|
+
useEffect(() => {
|
|
640
|
+
if (scroller.current) scroller.current.scrollLeft = 140;
|
|
641
|
+
}, []);
|
|
642
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
643
|
+
ref: scroller,
|
|
644
|
+
className: "table-demo",
|
|
645
|
+
role: "region",
|
|
646
|
+
"aria-label": "Products to edit, scrolls sideways",
|
|
647
|
+
tabIndex: 0,
|
|
648
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
649
|
+
nowrap: true,
|
|
650
|
+
className: "table-demo__wide",
|
|
651
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
652
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
653
|
+
sticky: "start",
|
|
654
|
+
style: {
|
|
655
|
+
width: 52,
|
|
656
|
+
minWidth: 52
|
|
657
|
+
},
|
|
658
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
659
|
+
className: "o-sr-only",
|
|
660
|
+
children: "Select"
|
|
661
|
+
})
|
|
662
|
+
}),
|
|
663
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
664
|
+
sticky: "start",
|
|
665
|
+
stickyOffset: 52,
|
|
666
|
+
style: { minWidth: 220 },
|
|
667
|
+
children: "Product"
|
|
668
|
+
}),
|
|
669
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Status" }),
|
|
670
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
671
|
+
align: "end",
|
|
672
|
+
children: "Price"
|
|
673
|
+
}),
|
|
674
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
675
|
+
align: "end",
|
|
676
|
+
children: "Cost"
|
|
677
|
+
}),
|
|
678
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "SKU" }),
|
|
679
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Barcode" }),
|
|
680
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
681
|
+
align: "end",
|
|
682
|
+
children: "Weight"
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Brand" }),
|
|
685
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
686
|
+
sticky: "end",
|
|
687
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
688
|
+
className: "o-sr-only",
|
|
689
|
+
children: "Actions"
|
|
690
|
+
})
|
|
691
|
+
})
|
|
692
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: BULK.map((product) => /* @__PURE__ */ jsxs(TableRow, {
|
|
693
|
+
interactive: true,
|
|
694
|
+
selected: !!chosen[product.id],
|
|
695
|
+
children: [
|
|
696
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
697
|
+
sticky: "start",
|
|
698
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
699
|
+
"aria-label": `Select ${product.name}`,
|
|
700
|
+
checked: !!chosen[product.id],
|
|
701
|
+
onCheckedChange: (next) => setChosen((state) => ({
|
|
702
|
+
...state,
|
|
703
|
+
[product.id]: next === true
|
|
704
|
+
}))
|
|
705
|
+
})
|
|
706
|
+
}),
|
|
707
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
708
|
+
sticky: "start",
|
|
709
|
+
stickyOffset: 52,
|
|
710
|
+
children: /* @__PURE__ */ jsx("a", {
|
|
711
|
+
href: "#pinned-column",
|
|
712
|
+
children: product.name
|
|
713
|
+
})
|
|
714
|
+
}),
|
|
715
|
+
/* @__PURE__ */ jsx(TableCell, { children: product.status }),
|
|
716
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
717
|
+
numeric: true,
|
|
718
|
+
children: gbp$1.format(product.price)
|
|
719
|
+
}),
|
|
720
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
721
|
+
numeric: true,
|
|
722
|
+
children: gbp$1.format(product.cost)
|
|
723
|
+
}),
|
|
724
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
725
|
+
className: "table-demo__quiet",
|
|
726
|
+
children: product.sku
|
|
727
|
+
}),
|
|
728
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
729
|
+
className: "table-demo__quiet",
|
|
730
|
+
children: product.barcode
|
|
731
|
+
}),
|
|
732
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
733
|
+
numeric: true,
|
|
734
|
+
children: product.weight
|
|
735
|
+
}),
|
|
736
|
+
/* @__PURE__ */ jsx(TableCell, { children: product.brand }),
|
|
737
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
738
|
+
sticky: "end",
|
|
739
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
740
|
+
size: "sm",
|
|
741
|
+
label: `Actions for ${product.name}`,
|
|
742
|
+
children: /* @__PURE__ */ jsx(DotsThreeIcon, {})
|
|
743
|
+
})
|
|
744
|
+
})
|
|
745
|
+
]
|
|
746
|
+
}, product.id)) })]
|
|
747
|
+
})
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
var LINKS = [
|
|
751
|
+
{
|
|
752
|
+
id: "k1",
|
|
753
|
+
label: "Spring launch",
|
|
754
|
+
code: "SPRING26",
|
|
755
|
+
url: "harbourdesk.example/r/SPRING26",
|
|
756
|
+
clicks: 1840,
|
|
757
|
+
signups: 63
|
|
758
|
+
},
|
|
759
|
+
{
|
|
760
|
+
id: "k2",
|
|
761
|
+
label: "Newsletter, March",
|
|
762
|
+
code: "NEWS0326",
|
|
763
|
+
url: "harbourdesk.example/r/NEWS0326",
|
|
764
|
+
clicks: 612,
|
|
765
|
+
signups: 21
|
|
766
|
+
},
|
|
767
|
+
{
|
|
768
|
+
id: "k3",
|
|
769
|
+
label: "Podcast read",
|
|
770
|
+
code: "DESKPOD",
|
|
771
|
+
url: "harbourdesk.example/r/DESKPOD",
|
|
772
|
+
clicks: 298,
|
|
773
|
+
signups: 14
|
|
774
|
+
}
|
|
775
|
+
];
|
|
776
|
+
/** A frame that can be made narrower than the window, to watch a table answer the room it has. */
|
|
777
|
+
function RoomFor({ room, narrow, children }) {
|
|
778
|
+
return /* @__PURE__ */ jsx("div", {
|
|
779
|
+
className: "table-demo__room",
|
|
780
|
+
style: { maxWidth: room === "narrow" ? narrow : void 0 },
|
|
781
|
+
children
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
function RoomSwitch({ room, onRoom, narrow }) {
|
|
785
|
+
return /* @__PURE__ */ jsx(SegmentedControl, {
|
|
786
|
+
"aria-label": "Room for the table",
|
|
787
|
+
size: "sm",
|
|
788
|
+
value: room,
|
|
789
|
+
onValueChange: (next) => onRoom(next),
|
|
790
|
+
options: [{
|
|
791
|
+
value: "wide",
|
|
792
|
+
label: "All the room"
|
|
793
|
+
}, {
|
|
794
|
+
value: "narrow",
|
|
795
|
+
label: `${narrow}px`
|
|
796
|
+
}]
|
|
797
|
+
});
|
|
798
|
+
}
|
|
799
|
+
/** Referral links: the code is the end of the URL beside it, so it gives way first, below 640px of room. */
|
|
800
|
+
function HideBelowDemo() {
|
|
801
|
+
const [room, setRoom] = useState("narrow");
|
|
802
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
803
|
+
className: "table-demo__states",
|
|
804
|
+
children: [/* @__PURE__ */ jsx(RoomSwitch, {
|
|
805
|
+
room,
|
|
806
|
+
onRoom: setRoom,
|
|
807
|
+
narrow: 520
|
|
808
|
+
}), /* @__PURE__ */ jsx(RoomFor, {
|
|
809
|
+
room,
|
|
810
|
+
narrow: 520,
|
|
811
|
+
children: /* @__PURE__ */ jsx(TableFrame, {
|
|
812
|
+
className: "table-demo",
|
|
813
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
814
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Label" }),
|
|
815
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
816
|
+
hideBelow: 640,
|
|
817
|
+
children: "Code"
|
|
818
|
+
}),
|
|
819
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "URL" }),
|
|
820
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
821
|
+
align: "end",
|
|
822
|
+
children: "Clicks"
|
|
823
|
+
}),
|
|
824
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
825
|
+
align: "end",
|
|
826
|
+
children: "Sign-ups"
|
|
827
|
+
})
|
|
828
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: LINKS.map((link) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
829
|
+
/* @__PURE__ */ jsx(TableCell, { children: link.label }),
|
|
830
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
831
|
+
hideBelow: 640,
|
|
832
|
+
children: /* @__PURE__ */ jsx("code", {
|
|
833
|
+
className: "table-demo__code",
|
|
834
|
+
children: link.code
|
|
835
|
+
})
|
|
836
|
+
}),
|
|
837
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
838
|
+
className: "table-demo__quiet",
|
|
839
|
+
children: link.url
|
|
840
|
+
}),
|
|
841
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
842
|
+
numeric: true,
|
|
843
|
+
children: link.clicks.toLocaleString("en-GB")
|
|
844
|
+
}),
|
|
845
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
846
|
+
numeric: true,
|
|
847
|
+
children: link.signups
|
|
848
|
+
})
|
|
849
|
+
] }, link.id)) })] })
|
|
850
|
+
})
|
|
851
|
+
})]
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
var EVENTS = [
|
|
855
|
+
{
|
|
856
|
+
id: "e1",
|
|
857
|
+
type: "Deployment",
|
|
858
|
+
change: "Paused to Running",
|
|
859
|
+
actor: "Priya Shah",
|
|
860
|
+
when: "14:02"
|
|
861
|
+
},
|
|
862
|
+
{
|
|
863
|
+
id: "e2",
|
|
864
|
+
type: "Subscription",
|
|
865
|
+
change: "To Past due",
|
|
866
|
+
actor: "System",
|
|
867
|
+
when: "09:15"
|
|
868
|
+
},
|
|
869
|
+
{
|
|
870
|
+
id: "e3",
|
|
871
|
+
type: "Enforcement",
|
|
872
|
+
change: "Running to Paused",
|
|
873
|
+
actor: "Tom Hughes",
|
|
874
|
+
when: "Yesterday"
|
|
875
|
+
}
|
|
876
|
+
];
|
|
877
|
+
/** Hosting events: four columns whose words need 700px, so below that each event is a card. */
|
|
878
|
+
function StackAtDemo() {
|
|
879
|
+
const [room, setRoom] = useState("narrow");
|
|
880
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
881
|
+
className: "table-demo__states",
|
|
882
|
+
children: [/* @__PURE__ */ jsx(RoomSwitch, {
|
|
883
|
+
room,
|
|
884
|
+
onRoom: setRoom,
|
|
885
|
+
narrow: 560
|
|
886
|
+
}), /* @__PURE__ */ jsx(RoomFor, {
|
|
887
|
+
room,
|
|
888
|
+
narrow: 560,
|
|
889
|
+
children: /* @__PURE__ */ jsx(TableFrame, {
|
|
890
|
+
className: "table-demo",
|
|
891
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
892
|
+
stack: 700,
|
|
893
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
894
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Type" }),
|
|
895
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Change" }),
|
|
896
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Actor" }),
|
|
897
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
898
|
+
align: "end",
|
|
899
|
+
children: "When"
|
|
900
|
+
})
|
|
901
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: EVENTS.map((event) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
902
|
+
/* @__PURE__ */ jsx(TableCell, { children: event.type }),
|
|
903
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
904
|
+
label: "Change",
|
|
905
|
+
children: event.change
|
|
906
|
+
}),
|
|
907
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
908
|
+
label: "Actor",
|
|
909
|
+
children: event.actor
|
|
910
|
+
}),
|
|
911
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
912
|
+
label: "When",
|
|
913
|
+
align: "end",
|
|
914
|
+
children: event.when
|
|
915
|
+
})
|
|
916
|
+
] }, event.id)) })]
|
|
917
|
+
})
|
|
918
|
+
})
|
|
919
|
+
})]
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
/** Stock, with what each figure means a press or a point away. */
|
|
923
|
+
function HelpDemo() {
|
|
924
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
925
|
+
className: "table-demo",
|
|
926
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
927
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Product" }),
|
|
928
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
929
|
+
help: "Where it is kept in the warehouse: the aisle, then the shelf.",
|
|
930
|
+
children: "Bin"
|
|
931
|
+
}),
|
|
932
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
933
|
+
align: "end",
|
|
934
|
+
help: "Everything on the shelves, including what is held for orders.",
|
|
935
|
+
children: "On hand"
|
|
936
|
+
}),
|
|
937
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
938
|
+
align: "end",
|
|
939
|
+
help: "What can be sold now: on hand, less what is held for orders not yet sent.",
|
|
940
|
+
children: "Available"
|
|
941
|
+
})
|
|
942
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: STOCK.slice(0, 4).map((line) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
943
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.name }),
|
|
944
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.bin }),
|
|
945
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
946
|
+
numeric: true,
|
|
947
|
+
children: line.onHand
|
|
948
|
+
}),
|
|
949
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
950
|
+
numeric: true,
|
|
951
|
+
children: line.onHand - line.held
|
|
952
|
+
})
|
|
953
|
+
] }, line.sku)) })] })
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
var UPDATING = "This product is being updated in the background. It unlocks when the update finishes.";
|
|
957
|
+
/** A product list where an update holds one row: press the button to lock and unlock it. */
|
|
958
|
+
function LockedDemo() {
|
|
959
|
+
const [locked, setLocked] = useState(true);
|
|
960
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
961
|
+
className: "table-demo__states",
|
|
962
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
963
|
+
size: "sm",
|
|
964
|
+
onClick: () => setLocked((value) => !value),
|
|
965
|
+
children: locked ? "Finish the update" : "Start an update of the walnut desk"
|
|
966
|
+
}), /* @__PURE__ */ jsx(TableFrame, {
|
|
967
|
+
className: "table-demo",
|
|
968
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
969
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Product" }),
|
|
970
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
971
|
+
align: "end",
|
|
972
|
+
children: "Price"
|
|
973
|
+
}),
|
|
974
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Status" }),
|
|
975
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
976
|
+
sticky: "end",
|
|
977
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
978
|
+
className: "o-sr-only",
|
|
979
|
+
children: "Actions"
|
|
980
|
+
})
|
|
981
|
+
})
|
|
982
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: BULK.slice(0, 3).map((product) => /* @__PURE__ */ jsxs(TableRow, {
|
|
983
|
+
interactive: true,
|
|
984
|
+
locked: product.id === "b2" ? locked : void 0,
|
|
985
|
+
lockedReason: product.id === "b2" ? UPDATING : void 0,
|
|
986
|
+
children: [
|
|
987
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
988
|
+
href: "#locked-rows",
|
|
989
|
+
children: product.name
|
|
990
|
+
}) }),
|
|
991
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
992
|
+
numeric: true,
|
|
993
|
+
children: gbp$1.format(product.price)
|
|
994
|
+
}),
|
|
995
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
996
|
+
size: "sm",
|
|
997
|
+
tone: product.status === "Active" ? "positive" : "neutral",
|
|
998
|
+
dot: true,
|
|
999
|
+
children: product.status
|
|
1000
|
+
}) }),
|
|
1001
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1002
|
+
sticky: "end",
|
|
1003
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1004
|
+
size: "sm",
|
|
1005
|
+
label: `Actions for ${product.name}`,
|
|
1006
|
+
children: /* @__PURE__ */ jsx(DotsThreeIcon, {})
|
|
1007
|
+
})
|
|
1008
|
+
})
|
|
1009
|
+
]
|
|
1010
|
+
}, product.id)) })] })
|
|
1011
|
+
})]
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
var TRANSACTIONS = [
|
|
1015
|
+
{
|
|
1016
|
+
id: "t1",
|
|
1017
|
+
date: "12 Oct 2026",
|
|
1018
|
+
what: "Gift card issued",
|
|
1019
|
+
amount: 100
|
|
1020
|
+
},
|
|
1021
|
+
{
|
|
1022
|
+
id: "t2",
|
|
1023
|
+
date: "13 Oct 2026",
|
|
1024
|
+
what: "Spent on order #1043",
|
|
1025
|
+
amount: -64
|
|
1026
|
+
},
|
|
1027
|
+
{
|
|
1028
|
+
id: "t3",
|
|
1029
|
+
date: "14 Oct 2026",
|
|
1030
|
+
what: "Spent on order #1051",
|
|
1031
|
+
amount: -18.5
|
|
1032
|
+
}
|
|
1033
|
+
];
|
|
1034
|
+
/** A gift card's record section: the card is the box, and the columns start on its content edge. */
|
|
1035
|
+
function EmbeddedDemo() {
|
|
1036
|
+
return /* @__PURE__ */ jsxs(Card, {
|
|
1037
|
+
className: "table-demo__card",
|
|
1038
|
+
children: [/* @__PURE__ */ jsx(CardHeader, {
|
|
1039
|
+
title: "Transactions",
|
|
1040
|
+
description: "Balance £17.50"
|
|
1041
|
+
}), /* @__PURE__ */ jsx(TableFrame, {
|
|
1042
|
+
variant: "embedded",
|
|
1043
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1044
|
+
edges: "flush",
|
|
1045
|
+
density: "compact",
|
|
1046
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1047
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Date" }),
|
|
1048
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Transaction" }),
|
|
1049
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1050
|
+
align: "end",
|
|
1051
|
+
children: "Amount"
|
|
1052
|
+
})
|
|
1053
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: TRANSACTIONS.map((line) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1054
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1055
|
+
className: "table-demo__quiet",
|
|
1056
|
+
children: line.date
|
|
1057
|
+
}),
|
|
1058
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.what }),
|
|
1059
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1060
|
+
numeric: true,
|
|
1061
|
+
children: line.amount < 0 ? `−${gbp$1.format(-line.amount)}` : gbp$1.format(line.amount)
|
|
1062
|
+
})
|
|
1063
|
+
] }, line.id)) })]
|
|
1064
|
+
})
|
|
1065
|
+
})]
|
|
1066
|
+
});
|
|
1067
|
+
}
|
|
1068
|
+
var ZONES = [{
|
|
1069
|
+
id: "uk",
|
|
1070
|
+
name: "United Kingdom",
|
|
1071
|
+
methods: [
|
|
1072
|
+
{
|
|
1073
|
+
id: "uk-standard",
|
|
1074
|
+
name: "Standard, 3 to 5 days",
|
|
1075
|
+
price: 4.95
|
|
1076
|
+
},
|
|
1077
|
+
{
|
|
1078
|
+
id: "uk-next",
|
|
1079
|
+
name: "Next working day",
|
|
1080
|
+
price: 8.95
|
|
1081
|
+
},
|
|
1082
|
+
{
|
|
1083
|
+
id: "uk-saturday",
|
|
1084
|
+
name: "Saturday",
|
|
1085
|
+
price: 14.5,
|
|
1086
|
+
removed: true
|
|
1087
|
+
},
|
|
1088
|
+
{
|
|
1089
|
+
id: "uk-collect",
|
|
1090
|
+
name: "Collect from the showroom",
|
|
1091
|
+
price: 0
|
|
1092
|
+
}
|
|
1093
|
+
]
|
|
1094
|
+
}, {
|
|
1095
|
+
id: "ie",
|
|
1096
|
+
name: "Ireland",
|
|
1097
|
+
methods: [{
|
|
1098
|
+
id: "ie-standard",
|
|
1099
|
+
name: "Standard, 5 to 7 days",
|
|
1100
|
+
price: 9.95
|
|
1101
|
+
}, {
|
|
1102
|
+
id: "ie-express",
|
|
1103
|
+
name: "Express",
|
|
1104
|
+
price: 16.5
|
|
1105
|
+
}]
|
|
1106
|
+
}];
|
|
1107
|
+
/**
|
|
1108
|
+
* The delivery methods of each zone, in the order checkout offers them: a body per zone, so a method moves among its
|
|
1109
|
+
* zone's only. A method marked for removal is dimmed with its undo until the page saves, and does not move.
|
|
1110
|
+
*/
|
|
1111
|
+
function ReorderDemo() {
|
|
1112
|
+
const [zones, setZones] = useState(ZONES);
|
|
1113
|
+
const reorder = (zone, from, to) => setZones((now) => now.map((each) => each.id === zone ? {
|
|
1114
|
+
...each,
|
|
1115
|
+
methods: moveItem(each.methods, from, to)
|
|
1116
|
+
} : each));
|
|
1117
|
+
const mark = (zone, id, removed) => {
|
|
1118
|
+
setZones((now) => now.map((each) => each.id === zone ? {
|
|
1119
|
+
...each,
|
|
1120
|
+
methods: each.methods.map((method) => method.id === id ? {
|
|
1121
|
+
...method,
|
|
1122
|
+
removed
|
|
1123
|
+
} : method)
|
|
1124
|
+
} : each));
|
|
1125
|
+
};
|
|
1126
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1127
|
+
className: "table-demo",
|
|
1128
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1129
|
+
"aria-label": "Delivery methods by zone",
|
|
1130
|
+
stack: true,
|
|
1131
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1132
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1133
|
+
className: "table-demo__grip",
|
|
1134
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1135
|
+
className: "o-sr-only",
|
|
1136
|
+
children: "Order"
|
|
1137
|
+
})
|
|
1138
|
+
}),
|
|
1139
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Method" }),
|
|
1140
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1141
|
+
align: "end",
|
|
1142
|
+
children: "Price"
|
|
1143
|
+
}),
|
|
1144
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1145
|
+
sticky: "end",
|
|
1146
|
+
align: "end",
|
|
1147
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1148
|
+
className: "o-sr-only",
|
|
1149
|
+
children: "Actions"
|
|
1150
|
+
})
|
|
1151
|
+
})
|
|
1152
|
+
] }) }), zones.map((zone) => /* @__PURE__ */ jsx(TableReorderBody, {
|
|
1153
|
+
items: zone.methods,
|
|
1154
|
+
getKey: (method) => method.id,
|
|
1155
|
+
getLabel: (method) => method.name,
|
|
1156
|
+
isItemDisabled: (method) => Boolean(method.removed),
|
|
1157
|
+
onReorder: (from, to) => reorder(zone.id, from, to),
|
|
1158
|
+
heading: /* @__PURE__ */ jsx(TableSectionRow, {
|
|
1159
|
+
colSpan: 4,
|
|
1160
|
+
children: zone.name
|
|
1161
|
+
}),
|
|
1162
|
+
children: (method, row) => /* @__PURE__ */ jsxs(TableRow, {
|
|
1163
|
+
...row.rowProps,
|
|
1164
|
+
removed: method.removed,
|
|
1165
|
+
children: [
|
|
1166
|
+
/* @__PURE__ */ jsx(TableCell, { children: row.handle }),
|
|
1167
|
+
/* @__PURE__ */ jsx(TableCell, { children: method.name }),
|
|
1168
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1169
|
+
numeric: true,
|
|
1170
|
+
label: "Price",
|
|
1171
|
+
children: method.price === 0 ? "Free" : gbp$1.format(method.price)
|
|
1172
|
+
}),
|
|
1173
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1174
|
+
sticky: "end",
|
|
1175
|
+
align: "end",
|
|
1176
|
+
children: method.removed ? /* @__PURE__ */ jsx(TableUndo, {
|
|
1177
|
+
label: method.name,
|
|
1178
|
+
onClick: () => mark(zone.id, method.id, false)
|
|
1179
|
+
}) : /* @__PURE__ */ jsx(IconButton, {
|
|
1180
|
+
size: "sm",
|
|
1181
|
+
label: `Remove ${method.name}`,
|
|
1182
|
+
onClick: () => mark(zone.id, method.id, true),
|
|
1183
|
+
children: /* @__PURE__ */ jsx(TrashIcon, {})
|
|
1184
|
+
})
|
|
1185
|
+
})
|
|
1186
|
+
]
|
|
1187
|
+
})
|
|
1188
|
+
}, zone.id))]
|
|
1189
|
+
})
|
|
1190
|
+
});
|
|
1191
|
+
}
|
|
1192
|
+
//#endregion
|
|
1193
|
+
//#region src/pages/components/table.tsx
|
|
1194
|
+
var PAID = {
|
|
1195
|
+
label: "Paid",
|
|
1196
|
+
tone: "positive"
|
|
1197
|
+
};
|
|
1198
|
+
var PENDING = {
|
|
1199
|
+
label: "Payment pending",
|
|
1200
|
+
tone: "warning"
|
|
1201
|
+
};
|
|
1202
|
+
var REFUNDED = {
|
|
1203
|
+
label: "Refunded",
|
|
1204
|
+
tone: "warning"
|
|
1205
|
+
};
|
|
1206
|
+
var UNFULFILLED = {
|
|
1207
|
+
label: "Unfulfilled",
|
|
1208
|
+
tone: "neutral"
|
|
1209
|
+
};
|
|
1210
|
+
var FULFILLED = {
|
|
1211
|
+
label: "Fulfilled",
|
|
1212
|
+
tone: "positive"
|
|
1213
|
+
};
|
|
1214
|
+
var ORDERS = [
|
|
1215
|
+
{
|
|
1216
|
+
id: "o1",
|
|
1217
|
+
number: "#1043",
|
|
1218
|
+
customer: "Sarah Whitfield",
|
|
1219
|
+
date: "29 Sep, 14:02",
|
|
1220
|
+
total: 240,
|
|
1221
|
+
payment: PAID,
|
|
1222
|
+
fulfilment: UNFULFILLED,
|
|
1223
|
+
items: 2
|
|
1224
|
+
},
|
|
1225
|
+
{
|
|
1226
|
+
id: "o2",
|
|
1227
|
+
number: "#1042",
|
|
1228
|
+
customer: "James Okafor",
|
|
1229
|
+
date: "29 Sep, 11:47",
|
|
1230
|
+
total: 89.5,
|
|
1231
|
+
payment: PENDING,
|
|
1232
|
+
fulfilment: UNFULFILLED,
|
|
1233
|
+
items: 1
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
id: "o3",
|
|
1237
|
+
number: "#1041",
|
|
1238
|
+
customer: "Priya Shah",
|
|
1239
|
+
date: "28 Sep, 19:20",
|
|
1240
|
+
total: 1120,
|
|
1241
|
+
payment: PAID,
|
|
1242
|
+
fulfilment: FULFILLED,
|
|
1243
|
+
items: 4
|
|
1244
|
+
},
|
|
1245
|
+
{
|
|
1246
|
+
id: "o4",
|
|
1247
|
+
number: "#1040",
|
|
1248
|
+
customer: "Tom Hughes",
|
|
1249
|
+
date: "28 Sep, 09:05",
|
|
1250
|
+
total: 34.99,
|
|
1251
|
+
payment: REFUNDED,
|
|
1252
|
+
fulfilment: FULFILLED,
|
|
1253
|
+
items: 1
|
|
1254
|
+
},
|
|
1255
|
+
{
|
|
1256
|
+
id: "o5",
|
|
1257
|
+
number: "#1039",
|
|
1258
|
+
customer: "Eleanor Price",
|
|
1259
|
+
date: "27 Sep, 16:33",
|
|
1260
|
+
total: 412.8,
|
|
1261
|
+
payment: PAID,
|
|
1262
|
+
fulfilment: FULFILLED,
|
|
1263
|
+
items: 3
|
|
1264
|
+
}
|
|
1265
|
+
];
|
|
1266
|
+
var gbp = new Intl.NumberFormat("en-GB", {
|
|
1267
|
+
style: "currency",
|
|
1268
|
+
currency: "GBP"
|
|
1269
|
+
});
|
|
1270
|
+
function OrdersTable({ rows = ORDERS, density = "comfortable", selectable = false, sortable = false, short = false }) {
|
|
1271
|
+
const [selected, setSelected] = useState({ o2: true });
|
|
1272
|
+
const [sort, setSort] = useState({
|
|
1273
|
+
key: "date",
|
|
1274
|
+
dir: "descending"
|
|
1275
|
+
});
|
|
1276
|
+
const sorted = useMemo(() => {
|
|
1277
|
+
if (!sortable) return rows;
|
|
1278
|
+
const list = [...rows];
|
|
1279
|
+
if (sort.key === "total") list.sort((a, b) => sort.dir === "ascending" ? a.total - b.total : b.total - a.total);
|
|
1280
|
+
else if (sort.dir === "ascending") list.reverse();
|
|
1281
|
+
return list;
|
|
1282
|
+
}, [
|
|
1283
|
+
rows,
|
|
1284
|
+
sortable,
|
|
1285
|
+
sort
|
|
1286
|
+
]);
|
|
1287
|
+
const count = Object.values(selected).filter(Boolean).length;
|
|
1288
|
+
const all = count === rows.length ? true : count === 0 ? false : "indeterminate";
|
|
1289
|
+
const sortOf = (key) => sort.key === key ? sort.dir : "none";
|
|
1290
|
+
const toggleSort = (key) => setSort((s) => ({
|
|
1291
|
+
key,
|
|
1292
|
+
dir: s.key === key && s.dir === "descending" ? "ascending" : "descending"
|
|
1293
|
+
}));
|
|
1294
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1295
|
+
className: "table-demo",
|
|
1296
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1297
|
+
density,
|
|
1298
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1299
|
+
selectable ? /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1300
|
+
style: { width: 44 },
|
|
1301
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1302
|
+
"aria-label": "Select all orders",
|
|
1303
|
+
checked: all,
|
|
1304
|
+
onCheckedChange: (next) => setSelected(Object.fromEntries(rows.map((r) => [r.id, next])))
|
|
1305
|
+
})
|
|
1306
|
+
}) : null,
|
|
1307
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
1308
|
+
short ? null : /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1309
|
+
sort: sortable ? sortOf("date") : void 0,
|
|
1310
|
+
onSort: sortable ? () => toggleSort("date") : void 0,
|
|
1311
|
+
children: "Date"
|
|
1312
|
+
}),
|
|
1313
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1314
|
+
style: { minWidth: 180 },
|
|
1315
|
+
children: "Customer"
|
|
1316
|
+
}),
|
|
1317
|
+
short ? null : /* @__PURE__ */ jsx(TableHeaderCell, { children: "Payment" }),
|
|
1318
|
+
short ? null : /* @__PURE__ */ jsx(TableHeaderCell, { children: "Fulfilment" }),
|
|
1319
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1320
|
+
align: "end",
|
|
1321
|
+
sort: sortable ? sortOf("total") : void 0,
|
|
1322
|
+
onSort: sortable ? () => toggleSort("total") : void 0,
|
|
1323
|
+
children: "Total"
|
|
1324
|
+
})
|
|
1325
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: sorted.map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
1326
|
+
interactive: true,
|
|
1327
|
+
selected: selectable && !!selected[order.id],
|
|
1328
|
+
children: [
|
|
1329
|
+
selectable ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1330
|
+
"aria-label": `Select order ${order.number}`,
|
|
1331
|
+
checked: !!selected[order.id],
|
|
1332
|
+
onCheckedChange: (next) => setSelected((s) => ({
|
|
1333
|
+
...s,
|
|
1334
|
+
[order.id]: next
|
|
1335
|
+
}))
|
|
1336
|
+
}) }) : null,
|
|
1337
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
1338
|
+
href: "#basics",
|
|
1339
|
+
children: order.number
|
|
1340
|
+
}) }),
|
|
1341
|
+
short ? null : /* @__PURE__ */ jsx(TableCell, {
|
|
1342
|
+
className: "table-demo__quiet",
|
|
1343
|
+
children: order.date
|
|
1344
|
+
}),
|
|
1345
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(PersonCell, { name: order.customer }) }),
|
|
1346
|
+
short ? null : /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
1347
|
+
size: "sm",
|
|
1348
|
+
tone: order.payment.tone,
|
|
1349
|
+
dot: true,
|
|
1350
|
+
children: order.payment.label
|
|
1351
|
+
}) }),
|
|
1352
|
+
short ? null : /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
1353
|
+
size: "sm",
|
|
1354
|
+
tone: order.fulfilment.tone,
|
|
1355
|
+
dot: true,
|
|
1356
|
+
children: order.fulfilment.label
|
|
1357
|
+
}) }),
|
|
1358
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1359
|
+
numeric: true,
|
|
1360
|
+
children: gbp.format(order.total)
|
|
1361
|
+
})
|
|
1362
|
+
]
|
|
1363
|
+
}, order.id)) })]
|
|
1364
|
+
})
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
function SelectionDemo() {
|
|
1368
|
+
const [selected, setSelected] = useState({
|
|
1369
|
+
o1: true,
|
|
1370
|
+
o2: true
|
|
1371
|
+
});
|
|
1372
|
+
const count = Object.values(selected).filter(Boolean).length;
|
|
1373
|
+
const all = count === ORDERS.length ? true : count === 0 ? false : "indeterminate";
|
|
1374
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1375
|
+
className: "table-demo",
|
|
1376
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: count > 0 ? /* @__PURE__ */ jsxs(TableRow, { children: [/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1377
|
+
style: { width: 44 },
|
|
1378
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1379
|
+
"aria-label": "Select all orders",
|
|
1380
|
+
checked: all,
|
|
1381
|
+
onCheckedChange: (next) => setSelected(Object.fromEntries(ORDERS.map((r) => [r.id, next])))
|
|
1382
|
+
})
|
|
1383
|
+
}), /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1384
|
+
colSpan: 3,
|
|
1385
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
1386
|
+
className: "table-demo__bulk",
|
|
1387
|
+
children: [
|
|
1388
|
+
/* @__PURE__ */ jsxs("strong", {
|
|
1389
|
+
className: "table-demo__bulk-count",
|
|
1390
|
+
children: [count, " selected"]
|
|
1391
|
+
}),
|
|
1392
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1393
|
+
size: "xs",
|
|
1394
|
+
variant: "soft",
|
|
1395
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
1396
|
+
children: "Fulfil"
|
|
1397
|
+
}),
|
|
1398
|
+
/* @__PURE__ */ jsx(Button, {
|
|
1399
|
+
size: "xs",
|
|
1400
|
+
variant: "soft",
|
|
1401
|
+
icon: /* @__PURE__ */ jsx(PrinterIcon, {}),
|
|
1402
|
+
children: "Print packing slips"
|
|
1403
|
+
}),
|
|
1404
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
1405
|
+
size: "xs",
|
|
1406
|
+
label: "More actions",
|
|
1407
|
+
children: /* @__PURE__ */ jsx(DotsThreeIcon, {})
|
|
1408
|
+
})
|
|
1409
|
+
]
|
|
1410
|
+
})
|
|
1411
|
+
})] }) : /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1412
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1413
|
+
style: { width: 44 },
|
|
1414
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1415
|
+
"aria-label": "Select all orders",
|
|
1416
|
+
checked: false,
|
|
1417
|
+
onCheckedChange: (next) => setSelected(Object.fromEntries(ORDERS.map((r) => [r.id, next])))
|
|
1418
|
+
})
|
|
1419
|
+
}),
|
|
1420
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
1421
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
1422
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1423
|
+
align: "end",
|
|
1424
|
+
children: "Total"
|
|
1425
|
+
})
|
|
1426
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: ORDERS.map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
1427
|
+
interactive: true,
|
|
1428
|
+
selected: !!selected[order.id],
|
|
1429
|
+
children: [
|
|
1430
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1431
|
+
"aria-label": `Select order ${order.number}`,
|
|
1432
|
+
checked: !!selected[order.id],
|
|
1433
|
+
onCheckedChange: (next) => setSelected((s) => ({
|
|
1434
|
+
...s,
|
|
1435
|
+
[order.id]: next
|
|
1436
|
+
}))
|
|
1437
|
+
}) }),
|
|
1438
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
1439
|
+
href: "#selection",
|
|
1440
|
+
children: order.number
|
|
1441
|
+
}) }),
|
|
1442
|
+
/* @__PURE__ */ jsx(TableCell, { children: order.customer }),
|
|
1443
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1444
|
+
numeric: true,
|
|
1445
|
+
children: gbp.format(order.total)
|
|
1446
|
+
})
|
|
1447
|
+
]
|
|
1448
|
+
}, order.id)) })] })
|
|
1449
|
+
});
|
|
1450
|
+
}
|
|
1451
|
+
function FramedDemo() {
|
|
1452
|
+
const [page, setPage] = useState(1);
|
|
1453
|
+
const many = Array.from({ length: 12 }, (_, i) => ({
|
|
1454
|
+
...ORDERS[i % ORDERS.length],
|
|
1455
|
+
id: `m${i}`,
|
|
1456
|
+
number: `#${1043 - i}`
|
|
1457
|
+
}));
|
|
1458
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1459
|
+
height: 300,
|
|
1460
|
+
className: "table-demo",
|
|
1461
|
+
footer: /* @__PURE__ */ jsx(Pagination, {
|
|
1462
|
+
page,
|
|
1463
|
+
pageCount: 25,
|
|
1464
|
+
onPageChange: setPage,
|
|
1465
|
+
summary: "1–50 of 1,241 orders"
|
|
1466
|
+
}),
|
|
1467
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1468
|
+
density: "compact",
|
|
1469
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1470
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
1471
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
1472
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Payment" }),
|
|
1473
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1474
|
+
align: "end",
|
|
1475
|
+
children: "Total"
|
|
1476
|
+
})
|
|
1477
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: many.map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
1478
|
+
interactive: true,
|
|
1479
|
+
children: [
|
|
1480
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
1481
|
+
href: "#frame",
|
|
1482
|
+
children: order.number
|
|
1483
|
+
}) }),
|
|
1484
|
+
/* @__PURE__ */ jsx(TableCell, { children: order.customer }),
|
|
1485
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
1486
|
+
size: "sm",
|
|
1487
|
+
tone: order.payment.tone,
|
|
1488
|
+
dot: true,
|
|
1489
|
+
children: order.payment.label
|
|
1490
|
+
}) }),
|
|
1491
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1492
|
+
numeric: true,
|
|
1493
|
+
children: gbp.format(order.total)
|
|
1494
|
+
})
|
|
1495
|
+
]
|
|
1496
|
+
}, order.id)) })]
|
|
1497
|
+
})
|
|
1498
|
+
});
|
|
1499
|
+
}
|
|
1500
|
+
var TEAM = [{
|
|
1501
|
+
id: "m1",
|
|
1502
|
+
name: "Priya Shah",
|
|
1503
|
+
email: "priya.shah@harbourdesk.example",
|
|
1504
|
+
role: "Account owner",
|
|
1505
|
+
seen: "29 Sep 2026, 14:02",
|
|
1506
|
+
note: "Looks after the Harbour Desk Co store and its suppliers."
|
|
1507
|
+
}, {
|
|
1508
|
+
id: "m2",
|
|
1509
|
+
name: "James Okafor",
|
|
1510
|
+
email: "james@arden-ergonomic-furniture.example",
|
|
1511
|
+
role: "Billing manager",
|
|
1512
|
+
seen: "28 Sep 2026, 09:45",
|
|
1513
|
+
note: "Approves refunds over £500."
|
|
1514
|
+
}];
|
|
1515
|
+
/** A table at the width of a phone, so the wrapping can be seen at any size of window. */
|
|
1516
|
+
function TeamTable({ nowrap = false }) {
|
|
1517
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1518
|
+
className: "table-demo table-demo--phone",
|
|
1519
|
+
role: "region",
|
|
1520
|
+
"aria-label": nowrap ? "Team members on one line each, scrolls sideways" : "Team members with wrapping text, scrolls sideways",
|
|
1521
|
+
tabIndex: 0,
|
|
1522
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1523
|
+
nowrap,
|
|
1524
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1525
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Member" }),
|
|
1526
|
+
nowrap ? null : /* @__PURE__ */ jsx(TableHeaderCell, { children: "Email" }),
|
|
1527
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Role" }),
|
|
1528
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Last active" }),
|
|
1529
|
+
nowrap ? /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1530
|
+
wrap: true,
|
|
1531
|
+
children: "Note"
|
|
1532
|
+
}) : null
|
|
1533
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: TEAM.map((member) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1534
|
+
/* @__PURE__ */ jsx(TableCell, { children: member.name }),
|
|
1535
|
+
nowrap ? null : /* @__PURE__ */ jsx(TableCell, { children: member.email }),
|
|
1536
|
+
/* @__PURE__ */ jsx(TableCell, { children: member.role }),
|
|
1537
|
+
/* @__PURE__ */ jsx(TableCell, { children: member.seen }),
|
|
1538
|
+
nowrap ? /* @__PURE__ */ jsx(TableCell, {
|
|
1539
|
+
wrap: true,
|
|
1540
|
+
className: "table-demo__note",
|
|
1541
|
+
children: member.note
|
|
1542
|
+
}) : null
|
|
1543
|
+
] }, member.id)) })]
|
|
1544
|
+
})
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
/** A table wider than its frame, with the actions column pinned. */
|
|
1548
|
+
function PinnedDemo() {
|
|
1549
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1550
|
+
className: "table-demo",
|
|
1551
|
+
role: "region",
|
|
1552
|
+
"aria-label": "Orders, scrolls sideways",
|
|
1553
|
+
tabIndex: 0,
|
|
1554
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1555
|
+
className: "table-demo__wide",
|
|
1556
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1557
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
1558
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Date" }),
|
|
1559
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
1560
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Payment" }),
|
|
1561
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Fulfilment" }),
|
|
1562
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1563
|
+
align: "end",
|
|
1564
|
+
children: "Total"
|
|
1565
|
+
}),
|
|
1566
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1567
|
+
sticky: "end",
|
|
1568
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1569
|
+
className: "o-sr-only",
|
|
1570
|
+
children: "Actions"
|
|
1571
|
+
})
|
|
1572
|
+
})
|
|
1573
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: ORDERS.slice(0, 4).map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
1574
|
+
interactive: true,
|
|
1575
|
+
selected: order.id === "o2",
|
|
1576
|
+
children: [
|
|
1577
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
1578
|
+
href: "#pinned-column",
|
|
1579
|
+
children: order.number
|
|
1580
|
+
}) }),
|
|
1581
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1582
|
+
className: "table-demo__quiet",
|
|
1583
|
+
children: order.date
|
|
1584
|
+
}),
|
|
1585
|
+
/* @__PURE__ */ jsx(TableCell, { children: order.customer }),
|
|
1586
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
1587
|
+
size: "sm",
|
|
1588
|
+
tone: order.payment.tone,
|
|
1589
|
+
dot: true,
|
|
1590
|
+
children: order.payment.label
|
|
1591
|
+
}) }),
|
|
1592
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
1593
|
+
size: "sm",
|
|
1594
|
+
tone: order.fulfilment.tone,
|
|
1595
|
+
dot: true,
|
|
1596
|
+
children: order.fulfilment.label
|
|
1597
|
+
}) }),
|
|
1598
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1599
|
+
numeric: true,
|
|
1600
|
+
children: gbp.format(order.total)
|
|
1601
|
+
}),
|
|
1602
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1603
|
+
sticky: "end",
|
|
1604
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1605
|
+
size: "sm",
|
|
1606
|
+
label: `Actions for order ${order.number}`,
|
|
1607
|
+
children: /* @__PURE__ */ jsx(DotsThreeIcon, {})
|
|
1608
|
+
})
|
|
1609
|
+
})
|
|
1610
|
+
]
|
|
1611
|
+
}, order.id)) })]
|
|
1612
|
+
})
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
var LINES = [
|
|
1616
|
+
{
|
|
1617
|
+
id: "l1",
|
|
1618
|
+
item: "Arden ergonomic chair",
|
|
1619
|
+
sku: "ARD-CHAIR-BLK",
|
|
1620
|
+
quantity: 2,
|
|
1621
|
+
price: 240
|
|
1622
|
+
},
|
|
1623
|
+
{
|
|
1624
|
+
id: "l2",
|
|
1625
|
+
item: "Walnut desk, 140cm",
|
|
1626
|
+
sku: "WAL-DESK-140",
|
|
1627
|
+
quantity: 1,
|
|
1628
|
+
price: 620
|
|
1629
|
+
},
|
|
1630
|
+
{
|
|
1631
|
+
id: "l3",
|
|
1632
|
+
item: "Cable tray",
|
|
1633
|
+
sku: "CAB-TRAY-01",
|
|
1634
|
+
quantity: 3,
|
|
1635
|
+
price: 18.5
|
|
1636
|
+
}
|
|
1637
|
+
];
|
|
1638
|
+
/** An order's items, folded into cards on a phone: the 390px frame is the measure, so it stacks on a desktop page too. */
|
|
1639
|
+
function StackedItems() {
|
|
1640
|
+
const total = LINES.reduce((sum, line) => sum + line.quantity * line.price, 0);
|
|
1641
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1642
|
+
className: "table-demo table-demo--stack",
|
|
1643
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1644
|
+
stack: true,
|
|
1645
|
+
children: [
|
|
1646
|
+
/* @__PURE__ */ jsx(TableCaption, { children: "Prices include VAT at 20%." }),
|
|
1647
|
+
/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1648
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Item" }),
|
|
1649
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "SKU" }),
|
|
1650
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1651
|
+
align: "end",
|
|
1652
|
+
children: "Quantity"
|
|
1653
|
+
}),
|
|
1654
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1655
|
+
align: "end",
|
|
1656
|
+
children: "Unit price"
|
|
1657
|
+
}),
|
|
1658
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1659
|
+
align: "end",
|
|
1660
|
+
children: "Line total"
|
|
1661
|
+
})
|
|
1662
|
+
] }) }),
|
|
1663
|
+
/* @__PURE__ */ jsx(TableBody, { children: LINES.map((line) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1664
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.item }),
|
|
1665
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1666
|
+
label: "SKU",
|
|
1667
|
+
children: line.sku
|
|
1668
|
+
}),
|
|
1669
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1670
|
+
label: "Quantity",
|
|
1671
|
+
numeric: true,
|
|
1672
|
+
children: line.quantity
|
|
1673
|
+
}),
|
|
1674
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1675
|
+
label: "Unit price",
|
|
1676
|
+
numeric: true,
|
|
1677
|
+
children: gbp.format(line.price)
|
|
1678
|
+
}),
|
|
1679
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1680
|
+
label: "Line total",
|
|
1681
|
+
numeric: true,
|
|
1682
|
+
children: gbp.format(line.quantity * line.price)
|
|
1683
|
+
})
|
|
1684
|
+
] }, line.id)) }),
|
|
1685
|
+
/* @__PURE__ */ jsx(TableFooter, { children: /* @__PURE__ */ jsxs(TableRow, { children: [/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1686
|
+
scope: "row",
|
|
1687
|
+
colSpan: 4,
|
|
1688
|
+
children: "Total"
|
|
1689
|
+
}), /* @__PURE__ */ jsx(TableCell, {
|
|
1690
|
+
numeric: true,
|
|
1691
|
+
children: gbp.format(total)
|
|
1692
|
+
})] }) })
|
|
1693
|
+
]
|
|
1694
|
+
})
|
|
1695
|
+
});
|
|
1696
|
+
}
|
|
1697
|
+
/** Orders with a selection box and a menu of actions, folded into cards: the box and the menu take the card's corners. */
|
|
1698
|
+
function StackedOrders() {
|
|
1699
|
+
const [selected, setSelected] = useState({ o2: true });
|
|
1700
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1701
|
+
className: "table-demo table-demo--stack",
|
|
1702
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
1703
|
+
stack: true,
|
|
1704
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1705
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: /* @__PURE__ */ jsx("span", {
|
|
1706
|
+
className: "o-sr-only",
|
|
1707
|
+
children: "Select"
|
|
1708
|
+
}) }),
|
|
1709
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
1710
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
1711
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Payment" }),
|
|
1712
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1713
|
+
align: "end",
|
|
1714
|
+
children: "Total"
|
|
1715
|
+
}),
|
|
1716
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1717
|
+
sticky: "end",
|
|
1718
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
1719
|
+
className: "o-sr-only",
|
|
1720
|
+
children: "Actions"
|
|
1721
|
+
})
|
|
1722
|
+
})
|
|
1723
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: ORDERS.slice(0, 3).map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
1724
|
+
interactive: true,
|
|
1725
|
+
selected: !!selected[order.id],
|
|
1726
|
+
children: [
|
|
1727
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
1728
|
+
"aria-label": `Select order ${order.number}`,
|
|
1729
|
+
checked: !!selected[order.id],
|
|
1730
|
+
onCheckedChange: (next) => setSelected((s) => ({
|
|
1731
|
+
...s,
|
|
1732
|
+
[order.id]: next
|
|
1733
|
+
}))
|
|
1734
|
+
}) }),
|
|
1735
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
1736
|
+
href: "#on-a-phone",
|
|
1737
|
+
children: order.number
|
|
1738
|
+
}) }),
|
|
1739
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1740
|
+
label: "Customer",
|
|
1741
|
+
children: order.customer
|
|
1742
|
+
}),
|
|
1743
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1744
|
+
label: "Payment",
|
|
1745
|
+
children: /* @__PURE__ */ jsx(Badge, {
|
|
1746
|
+
size: "sm",
|
|
1747
|
+
tone: order.payment.tone,
|
|
1748
|
+
dot: true,
|
|
1749
|
+
children: order.payment.label
|
|
1750
|
+
})
|
|
1751
|
+
}),
|
|
1752
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1753
|
+
label: "Total",
|
|
1754
|
+
numeric: true,
|
|
1755
|
+
children: gbp.format(order.total)
|
|
1756
|
+
}),
|
|
1757
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1758
|
+
sticky: "end",
|
|
1759
|
+
children: /* @__PURE__ */ jsx(IconButton, {
|
|
1760
|
+
size: "sm",
|
|
1761
|
+
label: `Actions for order ${order.number}`,
|
|
1762
|
+
children: /* @__PURE__ */ jsx(DotsThreeIcon, {})
|
|
1763
|
+
})
|
|
1764
|
+
})
|
|
1765
|
+
]
|
|
1766
|
+
}, order.id)) })]
|
|
1767
|
+
})
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
/** The table while its first page loads, with no rows, and loaded. */
|
|
1771
|
+
function LoadingAndEmpty() {
|
|
1772
|
+
const [state, setState] = useState("empty");
|
|
1773
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1774
|
+
className: "table-demo__states",
|
|
1775
|
+
children: [/* @__PURE__ */ jsx(SegmentedControl, {
|
|
1776
|
+
"aria-label": "What the table holds",
|
|
1777
|
+
size: "sm",
|
|
1778
|
+
value: state,
|
|
1779
|
+
onValueChange: (next) => setState(next),
|
|
1780
|
+
options: [
|
|
1781
|
+
{
|
|
1782
|
+
value: "loading",
|
|
1783
|
+
label: "Loading"
|
|
1784
|
+
},
|
|
1785
|
+
{
|
|
1786
|
+
value: "empty",
|
|
1787
|
+
label: "No orders"
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
value: "loaded",
|
|
1791
|
+
label: "Orders"
|
|
1792
|
+
}
|
|
1793
|
+
]
|
|
1794
|
+
}), state === "loading" ? /* @__PURE__ */ jsx(SkeletonTable, {
|
|
1795
|
+
className: "table-demo",
|
|
1796
|
+
rows: 3,
|
|
1797
|
+
columns: 4,
|
|
1798
|
+
label: "Loading orders"
|
|
1799
|
+
}) : /* @__PURE__ */ jsx(TableFrame, {
|
|
1800
|
+
className: "table-demo",
|
|
1801
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1802
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
1803
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
1804
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Payment" }),
|
|
1805
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1806
|
+
align: "end",
|
|
1807
|
+
children: "Total"
|
|
1808
|
+
})
|
|
1809
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: state === "empty" ? /* @__PURE__ */ jsx(TableRow, { children: /* @__PURE__ */ jsx(TableCell, {
|
|
1810
|
+
colSpan: 4,
|
|
1811
|
+
children: /* @__PURE__ */ jsx(EmptyState, {
|
|
1812
|
+
size: "sm",
|
|
1813
|
+
title: "No orders yet",
|
|
1814
|
+
description: "Orders show here as soon as a customer checks out."
|
|
1815
|
+
})
|
|
1816
|
+
}) }) : ORDERS.slice(0, 3).map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
1817
|
+
interactive: true,
|
|
1818
|
+
children: [
|
|
1819
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
1820
|
+
href: "#loading-and-empty",
|
|
1821
|
+
children: order.number
|
|
1822
|
+
}) }),
|
|
1823
|
+
/* @__PURE__ */ jsx(TableCell, { children: order.customer }),
|
|
1824
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
1825
|
+
size: "sm",
|
|
1826
|
+
tone: order.payment.tone,
|
|
1827
|
+
dot: true,
|
|
1828
|
+
children: order.payment.label
|
|
1829
|
+
}) }),
|
|
1830
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1831
|
+
numeric: true,
|
|
1832
|
+
children: gbp.format(order.total)
|
|
1833
|
+
})
|
|
1834
|
+
]
|
|
1835
|
+
}, order.id)) })] })
|
|
1836
|
+
})]
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
function TotalsDemo({ side = "bottom" }) {
|
|
1840
|
+
const total = LINES.reduce((sum, line) => sum + line.quantity * line.price, 0);
|
|
1841
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
1842
|
+
className: "table-demo",
|
|
1843
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [
|
|
1844
|
+
/* @__PURE__ */ jsx(TableCaption, {
|
|
1845
|
+
side,
|
|
1846
|
+
children: "Prices include VAT at 20%."
|
|
1847
|
+
}),
|
|
1848
|
+
/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1849
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Item" }),
|
|
1850
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1851
|
+
align: "end",
|
|
1852
|
+
children: "Quantity"
|
|
1853
|
+
}),
|
|
1854
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1855
|
+
align: "end",
|
|
1856
|
+
children: "Line total"
|
|
1857
|
+
})
|
|
1858
|
+
] }) }),
|
|
1859
|
+
/* @__PURE__ */ jsx(TableBody, { children: LINES.map((line) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1860
|
+
/* @__PURE__ */ jsx(TableCell, { children: line.item }),
|
|
1861
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1862
|
+
numeric: true,
|
|
1863
|
+
children: line.quantity
|
|
1864
|
+
}),
|
|
1865
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1866
|
+
numeric: true,
|
|
1867
|
+
children: gbp.format(line.quantity * line.price)
|
|
1868
|
+
})
|
|
1869
|
+
] }, line.id)) }),
|
|
1870
|
+
/* @__PURE__ */ jsx(TableFooter, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
1871
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
1872
|
+
scope: "row",
|
|
1873
|
+
children: "Total"
|
|
1874
|
+
}),
|
|
1875
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1876
|
+
numeric: true,
|
|
1877
|
+
children: LINES.reduce((sum, line) => sum + line.quantity, 0)
|
|
1878
|
+
}),
|
|
1879
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
1880
|
+
numeric: true,
|
|
1881
|
+
children: gbp.format(total)
|
|
1882
|
+
})
|
|
1883
|
+
] }) })
|
|
1884
|
+
] })
|
|
1885
|
+
});
|
|
1886
|
+
}
|
|
1887
|
+
function Preview() {
|
|
1888
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1889
|
+
className: "table-preview",
|
|
1890
|
+
children: /* @__PURE__ */ jsx(OrdersTable, {
|
|
1891
|
+
rows: ORDERS.slice(0, 3),
|
|
1892
|
+
density: "compact"
|
|
1893
|
+
})
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
function Page() {
|
|
1897
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
1898
|
+
title: "Table",
|
|
1899
|
+
status: "new",
|
|
1900
|
+
importNames: [
|
|
1901
|
+
"TableFrame",
|
|
1902
|
+
"Table",
|
|
1903
|
+
"TableHead",
|
|
1904
|
+
"TableBody",
|
|
1905
|
+
"TableFooter",
|
|
1906
|
+
"TableCaption",
|
|
1907
|
+
"TableRow",
|
|
1908
|
+
"TableHeaderCell",
|
|
1909
|
+
"TableCell",
|
|
1910
|
+
"TableExpandToggle",
|
|
1911
|
+
"TableExpandAll",
|
|
1912
|
+
"TableDetailRow",
|
|
1913
|
+
"TableSectionRow",
|
|
1914
|
+
"TableHelp"
|
|
1915
|
+
],
|
|
1916
|
+
lead: "Rows of records on hairlines: orders, products, customers. Quiet headings that stay put while the rows scroll, a soft hover on a row that opens something, and a line of teal on the rows you have chosen.",
|
|
1917
|
+
children: [
|
|
1918
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
1919
|
+
id: "basics",
|
|
1920
|
+
title: "Basics",
|
|
1921
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1922
|
+
"Plain table elements dressed by the kit, so bring any data engine (Orbit Commerce's store dashboard uses TanStack Table with virtual rows). Links in cells read as ink until pointed at: the row is the target. Only a row marked ",
|
|
1923
|
+
/* @__PURE__ */ jsx("code", { children: "interactive" }),
|
|
1924
|
+
", one that opens something, tints on hover; a row that opens nothing (a total, a change history) stays still, so it does not look pressable. The customer is a",
|
|
1925
|
+
" ",
|
|
1926
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
1927
|
+
to: "/components/person-cell",
|
|
1928
|
+
children: "PersonCell"
|
|
1929
|
+
}),
|
|
1930
|
+
", in a column with a ",
|
|
1931
|
+
/* @__PURE__ */ jsx("code", { children: "minWidth" }),
|
|
1932
|
+
": it takes the room its column has, and a table short of room on a phone would give it none."
|
|
1933
|
+
] }),
|
|
1934
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
1935
|
+
align: "fill",
|
|
1936
|
+
code: `
|
|
1937
|
+
<TableFrame>
|
|
1938
|
+
<Table>
|
|
1939
|
+
<TableHead>
|
|
1940
|
+
<TableRow>
|
|
1941
|
+
<TableHeaderCell>Order</TableHeaderCell>
|
|
1942
|
+
<TableHeaderCell>Date</TableHeaderCell>
|
|
1943
|
+
<TableHeaderCell style={{ minWidth: 180 }}>Customer</TableHeaderCell>
|
|
1944
|
+
<TableHeaderCell>Payment</TableHeaderCell>
|
|
1945
|
+
<TableHeaderCell>Fulfilment</TableHeaderCell>
|
|
1946
|
+
<TableHeaderCell align="end">Total</TableHeaderCell>
|
|
1947
|
+
</TableRow>
|
|
1948
|
+
</TableHead>
|
|
1949
|
+
<TableBody>
|
|
1950
|
+
{orders.map((order) => (
|
|
1951
|
+
<TableRow key={order.id} interactive onClick={() => open(order)}>
|
|
1952
|
+
<TableCell><Link to={order.href}>{order.number}</Link></TableCell>
|
|
1953
|
+
<TableCell>{order.date}</TableCell>
|
|
1954
|
+
<TableCell><PersonCell name={order.customer} /></TableCell>
|
|
1955
|
+
<TableCell><Badge size="sm" tone="positive" dot>Paid</Badge></TableCell>
|
|
1956
|
+
<TableCell><Badge size="sm" tone="neutral" dot>Unfulfilled</Badge></TableCell>
|
|
1957
|
+
<TableCell numeric>{gbp.format(order.total)}</TableCell>
|
|
1958
|
+
</TableRow>
|
|
1959
|
+
))}
|
|
1960
|
+
</TableBody>
|
|
1961
|
+
</Table>
|
|
1962
|
+
</TableFrame>`,
|
|
1963
|
+
children: /* @__PURE__ */ jsx(OrdersTable, {})
|
|
1964
|
+
})
|
|
1965
|
+
}),
|
|
1966
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
1967
|
+
id: "selection",
|
|
1968
|
+
title: "Selection",
|
|
1969
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1970
|
+
"A ",
|
|
1971
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
1972
|
+
to: "/components/checkbox",
|
|
1973
|
+
children: "Checkbox"
|
|
1974
|
+
}),
|
|
1975
|
+
" column; the head box goes part-ticked while some rows are chosen. Chosen rows take a teal line on their leading edge and a tint. While anything is selected, the head row can make way for the actions that apply to the selection."
|
|
1976
|
+
] }),
|
|
1977
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
1978
|
+
align: "fill",
|
|
1979
|
+
code: `<TableRow selected={!!selected[order.id]}>…</TableRow>`,
|
|
1980
|
+
children: /* @__PURE__ */ jsx(SelectionDemo, {})
|
|
1981
|
+
})
|
|
1982
|
+
}),
|
|
1983
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
1984
|
+
id: "sorting",
|
|
1985
|
+
title: "Sorting",
|
|
1986
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1987
|
+
"Give a heading ",
|
|
1988
|
+
/* @__PURE__ */ jsx("code", { children: "sort" }),
|
|
1989
|
+
" and ",
|
|
1990
|
+
/* @__PURE__ */ jsx("code", { children: "onSort" }),
|
|
1991
|
+
" and it becomes a button with an arrow; the header cell carries ",
|
|
1992
|
+
/* @__PURE__ */ jsx("code", { children: "aria-sort" }),
|
|
1993
|
+
". Press Date or Total."
|
|
1994
|
+
] }),
|
|
1995
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
1996
|
+
align: "fill",
|
|
1997
|
+
code: `<TableHeaderCell align="end" sort={sort.key === 'total' ? sort.dir : 'none'} onSort={() => toggle('total')}>
|
|
1998
|
+
Total
|
|
1999
|
+
</TableHeaderCell>`,
|
|
2000
|
+
children: /* @__PURE__ */ jsx(OrdersTable, { sortable: true })
|
|
2001
|
+
})
|
|
2002
|
+
}),
|
|
2003
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2004
|
+
id: "stripes",
|
|
2005
|
+
title: "Stripes",
|
|
2006
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2007
|
+
/* @__PURE__ */ jsx("code", { children: "striped" }),
|
|
2008
|
+
" tints every second row with a light sunken ground, for a long list people read across, a stock count or a price list, where the eye can lose its row. A hover and a chosen row paint over the stripe, and a section's heading or a detail under a row does not count as a row. Keep stripes for wide lists of figures: most lists read well on their hairlines alone. For rows a virtualiser draws, whose window can start at any row, use ",
|
|
2009
|
+
/* @__PURE__ */ jsx("code", { children: "striped=\"marked\"" }),
|
|
2010
|
+
" and give every second row of the list ",
|
|
2011
|
+
/* @__PURE__ */ jsx("code", { children: "alternate" }),
|
|
2012
|
+
", so a row keeps its tint as it scrolls."
|
|
2013
|
+
] }),
|
|
2014
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2015
|
+
align: "fill",
|
|
2016
|
+
code: `
|
|
2017
|
+
<Table striped density="compact">
|
|
2018
|
+
<TableHead>…</TableHead>
|
|
2019
|
+
<TableBody>
|
|
2020
|
+
{stock.map((line) => (
|
|
2021
|
+
<TableRow key={line.sku} interactive>…</TableRow>
|
|
2022
|
+
))}
|
|
2023
|
+
</TableBody>
|
|
2024
|
+
</Table>
|
|
2025
|
+
|
|
2026
|
+
// Rows from a virtualiser: the row's place in the whole list decides.
|
|
2027
|
+
<Table striped="marked">
|
|
2028
|
+
…<TableRow alternate={index % 2 === 1}>…</TableRow>
|
|
2029
|
+
</Table>`,
|
|
2030
|
+
children: /* @__PURE__ */ jsx(StripedDemo, {})
|
|
2031
|
+
})
|
|
2032
|
+
}),
|
|
2033
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2034
|
+
id: "frame",
|
|
2035
|
+
title: "Frame, scrolling and pages",
|
|
2036
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2037
|
+
/* @__PURE__ */ jsx("code", { children: "TableFrame" }),
|
|
2038
|
+
" is the hairline box with its own scroll area: set ",
|
|
2039
|
+
/* @__PURE__ */ jsx("code", { children: "height" }),
|
|
2040
|
+
" and the headings stay put while rows scroll. ",
|
|
2041
|
+
/* @__PURE__ */ jsx("code", { children: "footer" }),
|
|
2042
|
+
" pins ",
|
|
2043
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
2044
|
+
to: "/components/pagination",
|
|
2045
|
+
children: "Pagination"
|
|
2046
|
+
}),
|
|
2047
|
+
" under it. Its ref goes to the scroll area, for virtual rows."
|
|
2048
|
+
] }),
|
|
2049
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
2050
|
+
align: "fill",
|
|
2051
|
+
code: `
|
|
2052
|
+
<TableFrame height={300} footer={<Pagination page={page} pageCount={25} onPageChange={setPage} summary="1–50 of 1,241 orders" />}>
|
|
2053
|
+
<Table density="compact">…</Table>
|
|
2054
|
+
</TableFrame>`,
|
|
2055
|
+
children: /* @__PURE__ */ jsx(FramedDemo, {})
|
|
2056
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
2057
|
+
title: "Shadows on the edges",
|
|
2058
|
+
description: /* @__PURE__ */ jsx("p", { children: "While a table is wider than its frame, each edge with columns beyond it casts a soft shadow: the end edge until the table has scrolled to its end, the start edge once it has left its start. Each fades in over the first 32px of scrolling or out over the last, driven by the frame's own scroll position, so nothing has to watch for overflow; where the table fits, nothing is drawn. An edge that a column is pinned to draws none: the pinned column draws its own seam. A browser without scroll-driven animations shows no shadow." }),
|
|
2059
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2060
|
+
align: "fill",
|
|
2061
|
+
code: `<TableFrame role="region" aria-label="Sales by month, scrolls sideways" tabIndex={0}>
|
|
2062
|
+
<Table nowrap>…</Table>
|
|
2063
|
+
</TableFrame>`,
|
|
2064
|
+
children: /* @__PURE__ */ jsx(EdgesDemo, {})
|
|
2065
|
+
})
|
|
2066
|
+
})]
|
|
2067
|
+
}),
|
|
2068
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2069
|
+
id: "rows-under-rows",
|
|
2070
|
+
title: "Rows under rows",
|
|
2071
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2072
|
+
"A row can hold rows: a product's variants, a parcel's lines. Give each row under another ",
|
|
2073
|
+
/* @__PURE__ */ jsx("code", { children: "level={1}" }),
|
|
2074
|
+
" ",
|
|
2075
|
+
"(2 for a row under that), mark the one they belong to ",
|
|
2076
|
+
/* @__PURE__ */ jsx("code", { children: "expanded" }),
|
|
2077
|
+
" while they show, and mark the last of them ",
|
|
2078
|
+
/* @__PURE__ */ jsx("code", { children: "last" }),
|
|
2079
|
+
". The group then reads as one block on a sunken ground, a firmer line closes it, and in the cell marked ",
|
|
2080
|
+
/* @__PURE__ */ jsx("code", { children: "indent" }),
|
|
2081
|
+
" each row steps in and hangs from a guide line that turns into the last with a rounded corner. Put a ",
|
|
2082
|
+
/* @__PURE__ */ jsx("code", { children: "TableExpandToggle" }),
|
|
2083
|
+
" first in that cell: it is named for its row, says whether it is open, and turns from pointing at the end to pointing down. A row with nothing under it keeps the toggle's room with ",
|
|
2084
|
+
/* @__PURE__ */ jsx("code", { children: "expandable={false}" }),
|
|
2085
|
+
", so the names line up. Give the rows that have just appeared ",
|
|
2086
|
+
/* @__PURE__ */ jsx("code", { children: "entering" }),
|
|
2087
|
+
" (their place, for a stagger) and they drop into place. The group row is a row of its own, with cells of its own: here a box part ticked over its variants, a picture, a price that sets all of theirs and the stock they add up to. ",
|
|
2088
|
+
/* @__PURE__ */ jsx("code", { children: "TableExpandAll" }),
|
|
2089
|
+
" opens and shuts every group."
|
|
2090
|
+
] }),
|
|
2091
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
2092
|
+
align: "fill",
|
|
2093
|
+
code: `
|
|
2094
|
+
<TableExpandAll expanded={allOpen} onExpandedChange={openAll} />
|
|
2095
|
+
<Table>
|
|
2096
|
+
…
|
|
2097
|
+
<TableRow expanded={open}>
|
|
2098
|
+
<TableCell><Checkbox aria-label="Select every Hip pack 3L" checked="indeterminate" /></TableCell>
|
|
2099
|
+
<TableCell indent>
|
|
2100
|
+
<TableExpandToggle expanded={open} onExpandedChange={setOpen} label="Variants of Hip pack 3L" />
|
|
2101
|
+
<Thumbnail alt="" size="sm" … /> Hip pack 3L
|
|
2102
|
+
</TableCell>
|
|
2103
|
+
<TableCell align="end"><Input size="sm" placeholder="Set all" aria-label="Price of every Hip pack 3L, in pounds" /></TableCell>
|
|
2104
|
+
<TableCell numeric>30</TableCell>
|
|
2105
|
+
</TableRow>
|
|
2106
|
+
{open && variants.map((variant, index) => (
|
|
2107
|
+
<TableRow key={variant.id} level={1} last={index === variants.length - 1} entering={justOpened ? index : undefined}>
|
|
2108
|
+
<TableCell><Checkbox aria-label={\`Select Hip pack 3L, \${variant.name}\`} /></TableCell>
|
|
2109
|
+
<TableCell indent>{variant.name}</TableCell>
|
|
2110
|
+
<TableCell numeric>{gbp.format(variant.price)}</TableCell>
|
|
2111
|
+
<TableCell numeric>{variant.stock}</TableCell>
|
|
2112
|
+
</TableRow>
|
|
2113
|
+
))}
|
|
2114
|
+
</Table>`,
|
|
2115
|
+
children: /* @__PURE__ */ jsx(TreeDemo, {})
|
|
2116
|
+
}), /* @__PURE__ */ jsx(Note, {
|
|
2117
|
+
title: "One level of guide",
|
|
2118
|
+
children: "The guide joins a row to the row it belongs to. Under a second level the rows step in and hang from their own parent's line, but a line from further up is not carried through them, so keep trees to two levels where you can."
|
|
2119
|
+
})]
|
|
2120
|
+
}),
|
|
2121
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2122
|
+
id: "details-under-rows",
|
|
2123
|
+
title: "A detail under a row",
|
|
2124
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2125
|
+
/* @__PURE__ */ jsx("code", { children: "TableDetailRow" }),
|
|
2126
|
+
" is one cell across every column, under the row it belongs to: what the row opens, on a sunken ground (an order line's parcels, the details of an event). Give it an ",
|
|
2127
|
+
/* @__PURE__ */ jsx("code", { children: "id" }),
|
|
2128
|
+
" and pass that to the toggle as ",
|
|
2129
|
+
/* @__PURE__ */ jsx("code", { children: "controls" }),
|
|
2130
|
+
", and mark its row ",
|
|
2131
|
+
/* @__PURE__ */ jsx("code", { children: "expanded" }),
|
|
2132
|
+
" so the two read as one. The toggle can sit at the end of the row, in a narrow cell of its own. Its ",
|
|
2133
|
+
/* @__PURE__ */ jsx("code", { children: "note" }),
|
|
2134
|
+
" variant is a line that stays under a row and reads as part of it, with no line between them and the row's own ground: why a row of an import failed, in a ",
|
|
2135
|
+
/* @__PURE__ */ jsx("code", { children: "tone" }),
|
|
2136
|
+
". ",
|
|
2137
|
+
/* @__PURE__ */ jsx("code", { children: "inset" }),
|
|
2138
|
+
" lines its words up with a column's."
|
|
2139
|
+
] }),
|
|
2140
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
2141
|
+
align: "fill",
|
|
2142
|
+
code: `
|
|
2143
|
+
<TableRow expanded={open}>
|
|
2144
|
+
…
|
|
2145
|
+
<TableCell align="end">
|
|
2146
|
+
<TableExpandToggle expanded={open} onExpandedChange={setOpen} label="Parcels for ARD-CHAIR-BLK" controls="l1-parcels" />
|
|
2147
|
+
</TableCell>
|
|
2148
|
+
</TableRow>
|
|
2149
|
+
{open ? (
|
|
2150
|
+
<TableDetailRow id="l1-parcels" colSpan={4}>
|
|
2151
|
+
<ParcelList parcels={line.parcels} />
|
|
2152
|
+
</TableDetailRow>
|
|
2153
|
+
) : null}`,
|
|
2154
|
+
children: /* @__PURE__ */ jsx(DetailDemo, {})
|
|
2155
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
2156
|
+
title: "A note that stays",
|
|
2157
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2158
|
+
align: "fill",
|
|
2159
|
+
code: `
|
|
2160
|
+
<TableRow>…</TableRow>
|
|
2161
|
+
<TableDetailRow colSpan={4} variant="note" tone="negative" inset={58}>
|
|
2162
|
+
The SKU WAL-DESK-140 is already in use by another product.
|
|
2163
|
+
</TableDetailRow>`,
|
|
2164
|
+
children: /* @__PURE__ */ jsx(NoteDemo, {})
|
|
2165
|
+
})
|
|
2166
|
+
})]
|
|
2167
|
+
}),
|
|
2168
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2169
|
+
id: "section-rows",
|
|
2170
|
+
title: "Section rows",
|
|
2171
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2172
|
+
/* @__PURE__ */ jsx("code", { children: "TableSectionRow" }),
|
|
2173
|
+
" heads a group of rows across every column, in quiet medium words on the sunken ground: \"Today\", \"This week\" and \"Earlier\" in a log, or \"Allowances\" and \"Pricing\" in a comparison. Put each group in a ",
|
|
2174
|
+
/* @__PURE__ */ jsx("code", { children: "TableBody" }),
|
|
2175
|
+
" of its own with its heading first, so the heading names the rows of its body for a screen reader. Rows that share one body (a list a virtualiser draws) take ",
|
|
2176
|
+
/* @__PURE__ */ jsx("code", { children: "scope=\"row\"" }),
|
|
2177
|
+
"."
|
|
2178
|
+
] }),
|
|
2179
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2180
|
+
align: "fill",
|
|
2181
|
+
code: `
|
|
2182
|
+
<Table>
|
|
2183
|
+
<TableHead>…</TableHead>
|
|
2184
|
+
{groups.map((group) => (
|
|
2185
|
+
<TableBody key={group.section}>
|
|
2186
|
+
<TableSectionRow colSpan={3}>{group.section}</TableSectionRow>
|
|
2187
|
+
{group.rows.map((row) => <TableRow key={row.id}>…</TableRow>)}
|
|
2188
|
+
</TableBody>
|
|
2189
|
+
))}
|
|
2190
|
+
</Table>`,
|
|
2191
|
+
children: /* @__PURE__ */ jsx(SectionDemo, {})
|
|
2192
|
+
})
|
|
2193
|
+
}),
|
|
2194
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2195
|
+
id: "loading-and-empty",
|
|
2196
|
+
title: "Loading and empty",
|
|
2197
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2198
|
+
"While the first page loads, show a ",
|
|
2199
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
2200
|
+
to: "/components/skeleton#frames",
|
|
2201
|
+
children: "SkeletonTable"
|
|
2202
|
+
}),
|
|
2203
|
+
" in place of the frame: the same frame, headings and rows in the shape of what is coming, so nothing moves when the data lands. It says it is loading once, through its own status line, in the words of its ",
|
|
2204
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
2205
|
+
"; the placeholders are hidden from assistive technology. With no rows, keep the headings and put an",
|
|
2206
|
+
" ",
|
|
2207
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
2208
|
+
to: "/components/empty-state",
|
|
2209
|
+
children: "EmptyState"
|
|
2210
|
+
}),
|
|
2211
|
+
" in one cell across every column, so the table still says what it lists. Press each to see it."
|
|
2212
|
+
] }),
|
|
2213
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2214
|
+
align: "fill",
|
|
2215
|
+
code: `
|
|
2216
|
+
{loading ? (
|
|
2217
|
+
<SkeletonTable rows={3} columns={4} label="Loading orders" />
|
|
2218
|
+
) : (
|
|
2219
|
+
<TableFrame>
|
|
2220
|
+
<Table>
|
|
2221
|
+
<TableHead>
|
|
2222
|
+
<TableRow>
|
|
2223
|
+
<TableHeaderCell>Order</TableHeaderCell>
|
|
2224
|
+
<TableHeaderCell>Customer</TableHeaderCell>
|
|
2225
|
+
<TableHeaderCell>Payment</TableHeaderCell>
|
|
2226
|
+
<TableHeaderCell align="end">Total</TableHeaderCell>
|
|
2227
|
+
</TableRow>
|
|
2228
|
+
</TableHead>
|
|
2229
|
+
<TableBody>
|
|
2230
|
+
{orders.length === 0 ? (
|
|
2231
|
+
<TableRow>
|
|
2232
|
+
<TableCell colSpan={4}>
|
|
2233
|
+
<EmptyState size="sm" title="No orders yet" description="Orders show here as soon as a customer checks out." />
|
|
2234
|
+
</TableCell>
|
|
2235
|
+
</TableRow>
|
|
2236
|
+
) : (
|
|
2237
|
+
orders.map((order) => <TableRow key={order.id} interactive>…</TableRow>)
|
|
2238
|
+
)}
|
|
2239
|
+
</TableBody>
|
|
2240
|
+
</Table>
|
|
2241
|
+
</TableFrame>
|
|
2242
|
+
)}`,
|
|
2243
|
+
children: /* @__PURE__ */ jsx(LoadingAndEmpty, {})
|
|
2244
|
+
})
|
|
2245
|
+
}),
|
|
2246
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2247
|
+
id: "wrapping",
|
|
2248
|
+
title: "Wrapping and narrow screens",
|
|
2249
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2250
|
+
"Text in a cell wraps at spaces and never inside a word. A table that cannot fit its frame, on a phone say, keeps each column as wide as its longest word and the frame scrolls sideways, rather than squeezing every column until its words break letter by letter. A word too long for a column that has a fixed width (a table with ",
|
|
2251
|
+
/* @__PURE__ */ jsx("code", { children: "layout=\"fixed\"" }),
|
|
2252
|
+
") breaks inside it. ",
|
|
2253
|
+
/* @__PURE__ */ jsx("code", { children: "nowrap" }),
|
|
2254
|
+
" keeps every cell to one line, and",
|
|
2255
|
+
" ",
|
|
2256
|
+
/* @__PURE__ */ jsx("code", { children: "wrap" }),
|
|
2257
|
+
" on the cells of one column, a name or a note, lets that column wrap again."
|
|
2258
|
+
] }),
|
|
2259
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
2260
|
+
align: "fill",
|
|
2261
|
+
code: `
|
|
2262
|
+
<TableFrame>
|
|
2263
|
+
<Table>
|
|
2264
|
+
<TableHead>
|
|
2265
|
+
<TableRow>
|
|
2266
|
+
<TableHeaderCell>Member</TableHeaderCell>
|
|
2267
|
+
<TableHeaderCell>Email</TableHeaderCell>
|
|
2268
|
+
<TableHeaderCell>Role</TableHeaderCell>
|
|
2269
|
+
<TableHeaderCell>Last active</TableHeaderCell>
|
|
2270
|
+
</TableRow>
|
|
2271
|
+
</TableHead>
|
|
2272
|
+
<TableBody>
|
|
2273
|
+
{team.map((member) => (
|
|
2274
|
+
<TableRow key={member.id}>
|
|
2275
|
+
<TableCell>{member.name}</TableCell>
|
|
2276
|
+
<TableCell>{member.email}</TableCell>
|
|
2277
|
+
<TableCell>{member.role}</TableCell>
|
|
2278
|
+
<TableCell>{member.seen}</TableCell>
|
|
2279
|
+
</TableRow>
|
|
2280
|
+
))}
|
|
2281
|
+
</TableBody>
|
|
2282
|
+
</Table>
|
|
2283
|
+
</TableFrame>`,
|
|
2284
|
+
children: /* @__PURE__ */ jsx(TeamTable, {})
|
|
2285
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
2286
|
+
title: "One line per cell",
|
|
2287
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2288
|
+
"For a list that reads best as single lines, set ",
|
|
2289
|
+
/* @__PURE__ */ jsx("code", { children: "nowrap" }),
|
|
2290
|
+
" on the table. The note column keeps wrapping because its heading and its cells say ",
|
|
2291
|
+
/* @__PURE__ */ jsx("code", { children: "wrap" }),
|
|
2292
|
+
"."
|
|
2293
|
+
] }),
|
|
2294
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2295
|
+
align: "fill",
|
|
2296
|
+
code: `
|
|
2297
|
+
<Table nowrap>
|
|
2298
|
+
<TableHead>
|
|
2299
|
+
<TableRow>
|
|
2300
|
+
<TableHeaderCell>Member</TableHeaderCell>
|
|
2301
|
+
<TableHeaderCell>Role</TableHeaderCell>
|
|
2302
|
+
<TableHeaderCell>Last active</TableHeaderCell>
|
|
2303
|
+
<TableHeaderCell wrap>Note</TableHeaderCell>
|
|
2304
|
+
</TableRow>
|
|
2305
|
+
</TableHead>
|
|
2306
|
+
<TableBody>
|
|
2307
|
+
{team.map((member) => (
|
|
2308
|
+
<TableRow key={member.id}>
|
|
2309
|
+
<TableCell>{member.name}</TableCell>
|
|
2310
|
+
<TableCell>{member.role}</TableCell>
|
|
2311
|
+
<TableCell>{member.seen}</TableCell>
|
|
2312
|
+
<TableCell wrap>{member.note}</TableCell>
|
|
2313
|
+
</TableRow>
|
|
2314
|
+
))}
|
|
2315
|
+
</TableBody>
|
|
2316
|
+
</Table>`,
|
|
2317
|
+
children: /* @__PURE__ */ jsx(TeamTable, { nowrap: true })
|
|
2318
|
+
})
|
|
2319
|
+
})]
|
|
2320
|
+
}),
|
|
2321
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2322
|
+
id: "on-a-phone",
|
|
2323
|
+
title: "On a phone",
|
|
2324
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2325
|
+
"Give the table ",
|
|
2326
|
+
/* @__PURE__ */ jsx("code", { children: "stack" }),
|
|
2327
|
+
" and, while the room it has is narrower than 640px, each row becomes a card: the first cell is the row's title and every other cell shows its column name above the value, with",
|
|
2328
|
+
" ",
|
|
2329
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
2330
|
+
" on the cell, as many pairs to a line as fit (two on a phone, so a code keeps its line). The headings leave the eye's way but stay for a screen reader, and the card is one surface: it tints and takes the line of light whole. A caption and a footer read under the cards, the total on one line. The frame's scroll area is the measure, so the fold follows the table's own width and not the window: the 390px frames below stack on a desktop page too. Nothing changes for a table without ",
|
|
2331
|
+
/* @__PURE__ */ jsx("code", { children: "stack" }),
|
|
2332
|
+
"."
|
|
2333
|
+
] }),
|
|
2334
|
+
children: [
|
|
2335
|
+
/* @__PURE__ */ jsx(Example, {
|
|
2336
|
+
align: "fill",
|
|
2337
|
+
code: `
|
|
2338
|
+
<Table stack>
|
|
2339
|
+
<TableCaption>Prices include VAT at 20%.</TableCaption>
|
|
2340
|
+
<TableHead>
|
|
2341
|
+
<TableRow>
|
|
2342
|
+
<TableHeaderCell>Item</TableHeaderCell>
|
|
2343
|
+
<TableHeaderCell>SKU</TableHeaderCell>
|
|
2344
|
+
<TableHeaderCell align="end">Quantity</TableHeaderCell>
|
|
2345
|
+
<TableHeaderCell align="end">Unit price</TableHeaderCell>
|
|
2346
|
+
<TableHeaderCell align="end">Line total</TableHeaderCell>
|
|
2347
|
+
</TableRow>
|
|
2348
|
+
</TableHead>
|
|
2349
|
+
<TableBody>
|
|
2350
|
+
{lines.map((line) => (
|
|
2351
|
+
<TableRow key={line.id}>
|
|
2352
|
+
<TableCell>{line.item}</TableCell>
|
|
2353
|
+
<TableCell label="SKU">{line.sku}</TableCell>
|
|
2354
|
+
<TableCell label="Quantity" numeric>{line.quantity}</TableCell>
|
|
2355
|
+
<TableCell label="Unit price" numeric>{gbp.format(line.price)}</TableCell>
|
|
2356
|
+
<TableCell label="Line total" numeric>{gbp.format(line.quantity * line.price)}</TableCell>
|
|
2357
|
+
</TableRow>
|
|
2358
|
+
))}
|
|
2359
|
+
</TableBody>
|
|
2360
|
+
<TableFooter>
|
|
2361
|
+
<TableRow>
|
|
2362
|
+
<TableHeaderCell scope="row" colSpan={4}>Total</TableHeaderCell>
|
|
2363
|
+
<TableCell numeric>{gbp.format(total)}</TableCell>
|
|
2364
|
+
</TableRow>
|
|
2365
|
+
</TableFooter>
|
|
2366
|
+
</Table>`,
|
|
2367
|
+
children: /* @__PURE__ */ jsx(StackedItems, {})
|
|
2368
|
+
}),
|
|
2369
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
2370
|
+
title: "A selection box and a menu of actions",
|
|
2371
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2372
|
+
"A ",
|
|
2373
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
2374
|
+
to: "/components/checkbox",
|
|
2375
|
+
children: "Checkbox"
|
|
2376
|
+
}),
|
|
2377
|
+
" alone in the first cell sits in the card's top start corner, and the cell after it is the row's title, so give that cell no ",
|
|
2378
|
+
/* @__PURE__ */ jsx("code", { children: "label" }),
|
|
2379
|
+
". A pinned column of actions (",
|
|
2380
|
+
/* @__PURE__ */ jsx("code", { children: "sticky=\"end\"" }),
|
|
2381
|
+
") sits in the top end corner rather than on a line of its own."
|
|
2382
|
+
] }),
|
|
2383
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2384
|
+
align: "fill",
|
|
2385
|
+
code: `
|
|
2386
|
+
<Table stack>
|
|
2387
|
+
<TableHead>
|
|
2388
|
+
<TableRow>
|
|
2389
|
+
<TableHeaderCell><span className="o-sr-only">Select</span></TableHeaderCell>
|
|
2390
|
+
<TableHeaderCell>Order</TableHeaderCell>
|
|
2391
|
+
<TableHeaderCell>Customer</TableHeaderCell>
|
|
2392
|
+
<TableHeaderCell>Payment</TableHeaderCell>
|
|
2393
|
+
<TableHeaderCell align="end">Total</TableHeaderCell>
|
|
2394
|
+
<TableHeaderCell sticky="end"><span className="o-sr-only">Actions</span></TableHeaderCell>
|
|
2395
|
+
</TableRow>
|
|
2396
|
+
</TableHead>
|
|
2397
|
+
<TableBody>
|
|
2398
|
+
{orders.map((order) => (
|
|
2399
|
+
<TableRow key={order.id} interactive selected={!!selected[order.id]}>
|
|
2400
|
+
<TableCell>
|
|
2401
|
+
<Checkbox aria-label={\`Select order \${order.number}\`} checked={!!selected[order.id]} onCheckedChange={…} />
|
|
2402
|
+
</TableCell>
|
|
2403
|
+
<TableCell><Link to={order.href}>{order.number}</Link></TableCell>
|
|
2404
|
+
<TableCell label="Customer">{order.customer}</TableCell>
|
|
2405
|
+
<TableCell label="Payment"><Badge size="sm" tone="positive" dot>Paid</Badge></TableCell>
|
|
2406
|
+
<TableCell label="Total" numeric>{gbp.format(order.total)}</TableCell>
|
|
2407
|
+
<TableCell sticky="end">
|
|
2408
|
+
<IconButton size="sm" label={\`Actions for order \${order.number}\`}><DotsThreeIcon /></IconButton>
|
|
2409
|
+
</TableCell>
|
|
2410
|
+
</TableRow>
|
|
2411
|
+
))}
|
|
2412
|
+
</TableBody>
|
|
2413
|
+
</Table>`,
|
|
2414
|
+
children: /* @__PURE__ */ jsx(StackedOrders, {})
|
|
2415
|
+
})
|
|
2416
|
+
}),
|
|
2417
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
2418
|
+
title: "A fold at a width of its own",
|
|
2419
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2420
|
+
"Some tables need more than 640px for their columns to hold their words whole. Give ",
|
|
2421
|
+
/* @__PURE__ */ jsx("code", { children: "stack" }),
|
|
2422
|
+
" the width they need, ",
|
|
2423
|
+
/* @__PURE__ */ jsx("code", { children: "stack={840}" }),
|
|
2424
|
+
", and the table folds into cards whenever the box it sits in is narrower than that. The box is measured once the page runs, so a page drawn on a server shows the table unfolded until then; ",
|
|
2425
|
+
/* @__PURE__ */ jsx("code", { children: "stack" }),
|
|
2426
|
+
" on its own folds by CSS alone, from the first paint. Switch the room below."
|
|
2427
|
+
] }),
|
|
2428
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2429
|
+
align: "fill",
|
|
2430
|
+
code: `
|
|
2431
|
+
<Table stack={700}>
|
|
2432
|
+
…
|
|
2433
|
+
<TableCell label="Change">{event.change}</TableCell>
|
|
2434
|
+
</Table>`,
|
|
2435
|
+
children: /* @__PURE__ */ jsx(StackAtDemo, {})
|
|
2436
|
+
})
|
|
2437
|
+
}),
|
|
2438
|
+
/* @__PURE__ */ jsx(Note, {
|
|
2439
|
+
title: "Keep the head's controls outside a stacked table",
|
|
2440
|
+
children: "While the table stacks, its headings are out of sight, so a sort button or a select-all box in the head would take focus where no one can see it. Put them above the table, in a toolbar, when the table can stack."
|
|
2441
|
+
})
|
|
2442
|
+
]
|
|
2443
|
+
}),
|
|
2444
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2445
|
+
id: "give-way",
|
|
2446
|
+
title: "Columns that give way",
|
|
2447
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2448
|
+
"A column of little worth can step aside before a table has to scroll: give its heading and every cell of it the same ",
|
|
2449
|
+
/* @__PURE__ */ jsx("code", { children: "hideBelow" }),
|
|
2450
|
+
", a width in px, and they are hidden while the box the table sits in is narrower than that. The box's width is the measure, not the window's, so the table answers the room it is given wherever it sits. Keep it for columns whose words are said elsewhere in the row (a code that ends the URL beside it), and never for the column people scan for. The width is measured once the page runs, and the table draws again only when the room crosses a width one of its columns gave."
|
|
2451
|
+
] }),
|
|
2452
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2453
|
+
align: "fill",
|
|
2454
|
+
code: `
|
|
2455
|
+
<TableHeaderCell hideBelow={640}>Code</TableHeaderCell>
|
|
2456
|
+
…
|
|
2457
|
+
<TableCell hideBelow={640}><code>{link.code}</code></TableCell>`,
|
|
2458
|
+
children: /* @__PURE__ */ jsx(HideBelowDemo, {})
|
|
2459
|
+
})
|
|
2460
|
+
}),
|
|
2461
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2462
|
+
id: "pinned-column",
|
|
2463
|
+
title: "Pinned actions column",
|
|
2464
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2465
|
+
"On a table wider than its frame, give the heading and every cell of the actions column",
|
|
2466
|
+
" ",
|
|
2467
|
+
/* @__PURE__ */ jsx("code", { children: "sticky=\"end\"" }),
|
|
2468
|
+
" and it stays at the end edge while the other columns scroll under it. Its cells take the row's own ground, a hovered or chosen row's tint included, and a soft shadow shows on its start edge while columns are tucked beneath it, fading as the table reaches its end. Where the table fits, nothing is pinned and nothing is drawn. It works in any element that scrolls: a ",
|
|
2469
|
+
/* @__PURE__ */ jsx("code", { children: "TableFrame" }),
|
|
2470
|
+
" or a wrapper of your own with",
|
|
2471
|
+
" ",
|
|
2472
|
+
/* @__PURE__ */ jsx("code", { children: "overflow-x: auto" }),
|
|
2473
|
+
". The shadow follows the scroll position through scroll-driven animation; a browser without it still pins the column, with no shadow."
|
|
2474
|
+
] }),
|
|
2475
|
+
children: [
|
|
2476
|
+
/* @__PURE__ */ jsx(Example, {
|
|
2477
|
+
align: "fill",
|
|
2478
|
+
code: `
|
|
2479
|
+
<TableFrame>
|
|
2480
|
+
<Table>
|
|
2481
|
+
<TableHead>
|
|
2482
|
+
<TableRow>
|
|
2483
|
+
<TableHeaderCell>Order</TableHeaderCell>
|
|
2484
|
+
…
|
|
2485
|
+
<TableHeaderCell align="end">Total</TableHeaderCell>
|
|
2486
|
+
<TableHeaderCell sticky="end">
|
|
2487
|
+
<span className="o-sr-only">Actions</span>
|
|
2488
|
+
</TableHeaderCell>
|
|
2489
|
+
</TableRow>
|
|
2490
|
+
</TableHead>
|
|
2491
|
+
<TableBody>
|
|
2492
|
+
{orders.map((order) => (
|
|
2493
|
+
<TableRow key={order.id} interactive>
|
|
2494
|
+
…
|
|
2495
|
+
<TableCell numeric>{gbp.format(order.total)}</TableCell>
|
|
2496
|
+
<TableCell sticky="end">
|
|
2497
|
+
<IconButton size="sm" label={\`Actions for order \${order.number}\`}>
|
|
2498
|
+
<DotsThreeIcon />
|
|
2499
|
+
</IconButton>
|
|
2500
|
+
</TableCell>
|
|
2501
|
+
</TableRow>
|
|
2502
|
+
))}
|
|
2503
|
+
</TableBody>
|
|
2504
|
+
</Table>
|
|
2505
|
+
</TableFrame>`,
|
|
2506
|
+
children: /* @__PURE__ */ jsx(PinnedDemo, {})
|
|
2507
|
+
}),
|
|
2508
|
+
/* @__PURE__ */ jsx(Note, {
|
|
2509
|
+
title: "Pin one column, the last",
|
|
2510
|
+
children: "Pin only the column of actions, and only the last one: a pinned column takes room from the others on a phone. A row's menu button should be named for its row, as above, because the heading is hidden."
|
|
2511
|
+
}),
|
|
2512
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
2513
|
+
title: "Pin the column people scan",
|
|
2514
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2515
|
+
"In a grid many columns wide (a bulk editor), the column that says which row is which can stay at the start edge: give its heading and every cell ",
|
|
2516
|
+
/* @__PURE__ */ jsx("code", { children: "sticky=\"start\"" }),
|
|
2517
|
+
". A column pinned after another takes",
|
|
2518
|
+
" ",
|
|
2519
|
+
/* @__PURE__ */ jsx("code", { children: "stickyOffset" }),
|
|
2520
|
+
", the width of the pinned columns before it, so the two stay side by side: give those columns a width that holds (a ",
|
|
2521
|
+
/* @__PURE__ */ jsx("code", { children: "width" }),
|
|
2522
|
+
" and the same ",
|
|
2523
|
+
/* @__PURE__ */ jsx("code", { children: "minWidth" }),
|
|
2524
|
+
", or a fixed layout), since a table short of room squeezes a column below the width it asks for. The last of them casts the seam, fading in as soon as columns slide under it; the cells take the row's ground, its stripe, hover and choice included, and a chosen row keeps its line of light. Where the pins would leave the columns that scroll under 120px beside them (a wide name on a phone) the start pins let go and scroll with the rest, so pin little. In a stacked table a column pinned to the start is a plain line of the card."
|
|
2525
|
+
] }),
|
|
2526
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2527
|
+
align: "fill",
|
|
2528
|
+
code: `
|
|
2529
|
+
<TableHeaderCell sticky="start" style={{ width: 52, minWidth: 52 }}><span className="o-sr-only">Select</span></TableHeaderCell>
|
|
2530
|
+
<TableHeaderCell sticky="start" stickyOffset={52}>Product</TableHeaderCell>
|
|
2531
|
+
…
|
|
2532
|
+
<TableCell sticky="start"><Checkbox aria-label="Select Walnut desk, 140cm" /></TableCell>
|
|
2533
|
+
<TableCell sticky="start" stickyOffset={52}><Link to="/products/b2">Walnut desk, 140cm</Link></TableCell>`,
|
|
2534
|
+
children: /* @__PURE__ */ jsx(StickyStartDemo, {})
|
|
2535
|
+
})
|
|
2536
|
+
})
|
|
2537
|
+
]
|
|
2538
|
+
}),
|
|
2539
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2540
|
+
id: "help",
|
|
2541
|
+
title: "Help on a heading",
|
|
2542
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2543
|
+
"A heading whose figures need explaining takes ",
|
|
2544
|
+
/* @__PURE__ */ jsx("code", { children: "help" }),
|
|
2545
|
+
": a quiet mark beside its words, outside the sort button, that shows what the column means in a tooltip when it is pointed at, reached with the keyboard or pressed (a touch screen has no hover). It is named \"About\" and the heading's words, \"About Available\", or what you give ",
|
|
2546
|
+
/* @__PURE__ */ jsx("code", { children: "helpLabel" }),
|
|
2547
|
+
". In an end-aligned column the mark goes before the words, so they end on the edge their figures end on. Keep the help to a sentence; a link or a longer explanation belongs in a",
|
|
2548
|
+
" ",
|
|
2549
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
2550
|
+
to: "/components/input#help",
|
|
2551
|
+
children: "FieldHelp"
|
|
2552
|
+
}),
|
|
2553
|
+
" popover. For a heading your own component draws (a column's menu button), ",
|
|
2554
|
+
/* @__PURE__ */ jsx("code", { children: "TableHelp" }),
|
|
2555
|
+
" is the mark on its own, to set beside it outside any button, and",
|
|
2556
|
+
" ",
|
|
2557
|
+
/* @__PURE__ */ jsx("code", { children: "after" }),
|
|
2558
|
+
" on ",
|
|
2559
|
+
/* @__PURE__ */ jsx("code", { children: "TableHeaderCell" }),
|
|
2560
|
+
" holds what comes after the words, outside the sort button and the help (a column's resize handle)."
|
|
2561
|
+
] }),
|
|
2562
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2563
|
+
align: "fill",
|
|
2564
|
+
code: `
|
|
2565
|
+
<TableHeaderCell help="Where it is kept in the warehouse: the aisle, then the shelf.">Bin</TableHeaderCell>
|
|
2566
|
+
<TableHeaderCell align="end" help="What can be sold now: on hand, less what is held for orders not yet sent.">
|
|
2567
|
+
Available
|
|
2568
|
+
</TableHeaderCell>`,
|
|
2569
|
+
children: /* @__PURE__ */ jsx(HelpDemo, {})
|
|
2570
|
+
})
|
|
2571
|
+
}),
|
|
2572
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2573
|
+
id: "locked-rows",
|
|
2574
|
+
title: "Locked rows",
|
|
2575
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2576
|
+
"While something updates a row in the background, give it ",
|
|
2577
|
+
/* @__PURE__ */ jsx("code", { children: "locked" }),
|
|
2578
|
+
" and a ",
|
|
2579
|
+
/* @__PURE__ */ jsx("code", { children: "lockedReason" }),
|
|
2580
|
+
". A veil of the table's ground dims it whole, its words, pictures and controls alike; a press on it does nothing and it does not open; its controls leave the tab order until it unlocks, each with its own tab index back; and the reason shows in a tooltip while the pointer is on it, and is the row's description for a screen reader. Pass ",
|
|
2581
|
+
/* @__PURE__ */ jsx("code", { children: "locked={false}" }),
|
|
2582
|
+
" rather than leaving it out while a row may lock, so its content is not drawn afresh when it does. No padlock: the dim and the words say it."
|
|
2583
|
+
] }),
|
|
2584
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2585
|
+
align: "fill",
|
|
2586
|
+
code: `
|
|
2587
|
+
<TableRow
|
|
2588
|
+
interactive
|
|
2589
|
+
locked={updating.has(product.id)}
|
|
2590
|
+
lockedReason="This product is being updated in the background. It unlocks when the update finishes."
|
|
2591
|
+
>
|
|
2592
|
+
…
|
|
2593
|
+
</TableRow>`,
|
|
2594
|
+
children: /* @__PURE__ */ jsx(LockedDemo, {})
|
|
2595
|
+
})
|
|
2596
|
+
}),
|
|
2597
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2598
|
+
id: "reorder-rows",
|
|
2599
|
+
title: "Rows that reorder",
|
|
2600
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2601
|
+
"Where the order of the rows is the point (the delivery methods checkout offers, in the order it offers them; a product's variants), give each row a handle in its first cell and let ",
|
|
2602
|
+
/* @__PURE__ */ jsx("code", { children: "TableReorderBody" }),
|
|
2603
|
+
" move them on the kit's drag engine. A pointer drags a row by its handle and the row rides under it, raised and a little dimmed, while the rows it passes make way. From the keyboard, Space or Enter lifts the focused handle's row, the arrow keys move it, Space or Enter drops it and Escape puts it back, and every step is said. A body is one group, and its rows move among themselves only: a table of groups is a body per group, each with its",
|
|
2604
|
+
" ",
|
|
2605
|
+
/* @__PURE__ */ jsx("code", { children: "heading" }),
|
|
2606
|
+
". ",
|
|
2607
|
+
/* @__PURE__ */ jsx("code", { children: "onReorder(from, to)" }),
|
|
2608
|
+
" is called once, when a row drops somewhere new."
|
|
2609
|
+
] }),
|
|
2610
|
+
children: [/* @__PURE__ */ jsx(Example, {
|
|
2611
|
+
align: "fill",
|
|
2612
|
+
code: `
|
|
2613
|
+
{zones.map((zone) => (
|
|
2614
|
+
<TableReorderBody
|
|
2615
|
+
key={zone.id}
|
|
2616
|
+
items={zone.methods}
|
|
2617
|
+
getKey={(method) => method.id}
|
|
2618
|
+
getLabel={(method) => method.name}
|
|
2619
|
+
isItemDisabled={(method) => method.removed}
|
|
2620
|
+
onReorder={(from, to) => reorder(zone.id, from, to)}
|
|
2621
|
+
heading={<TableSectionRow colSpan={4}>{zone.name}</TableSectionRow>}
|
|
2622
|
+
>
|
|
2623
|
+
{(method, row) => (
|
|
2624
|
+
<TableRow {...row.rowProps} removed={method.removed}>
|
|
2625
|
+
<TableCell>{row.handle}</TableCell>
|
|
2626
|
+
<TableCell>{method.name}</TableCell>
|
|
2627
|
+
<TableCell numeric>{gbp.format(method.price)}</TableCell>
|
|
2628
|
+
<TableCell sticky="end">
|
|
2629
|
+
{method.removed ? <TableUndo label={method.name} onClick={() => restore(method)} /> : <IconButton …>}
|
|
2630
|
+
</TableCell>
|
|
2631
|
+
</TableRow>
|
|
2632
|
+
)}
|
|
2633
|
+
</TableReorderBody>
|
|
2634
|
+
))}`,
|
|
2635
|
+
children: /* @__PURE__ */ jsx(ReorderDemo, {})
|
|
2636
|
+
}), /* @__PURE__ */ jsx(SubSection, {
|
|
2637
|
+
title: "A row marked for removal",
|
|
2638
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2639
|
+
"A row that will go when the page saves, and can still be kept, takes ",
|
|
2640
|
+
/* @__PURE__ */ jsx("code", { children: "removed" }),
|
|
2641
|
+
": its words go quiet and its pictures and controls fade, but for the cell that holds its ",
|
|
2642
|
+
/* @__PURE__ */ jsx("code", { children: "TableUndo" }),
|
|
2643
|
+
", and it says so to a screen reader (\"Marked for removal\", or the sentence you give). Put the undo where the row's actions are, in the place of the button that removes it: as the one takes the other's place, the row hands focus across, to the undo and back. A removed row does not move: give it to ",
|
|
2644
|
+
/* @__PURE__ */ jsx("code", { children: "isItemDisabled" }),
|
|
2645
|
+
"."
|
|
2646
|
+
] })
|
|
2647
|
+
})]
|
|
2648
|
+
}),
|
|
2649
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2650
|
+
id: "in-a-card",
|
|
2651
|
+
title: "Inside a card",
|
|
2652
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2653
|
+
"A table that is a section of a record (a gift card's transactions, a subscription's invoices) sits in its",
|
|
2654
|
+
" ",
|
|
2655
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
2656
|
+
to: "/components/card",
|
|
2657
|
+
children: "Card"
|
|
2658
|
+
}),
|
|
2659
|
+
", and the card is the box: ",
|
|
2660
|
+
/* @__PURE__ */ jsx("code", { children: "TableFrame variant=\"embedded\"" }),
|
|
2661
|
+
" ",
|
|
2662
|
+
"drops the frame's own edge, corners and ground, and ",
|
|
2663
|
+
/* @__PURE__ */ jsx("code", { children: "edges=\"flush\"" }),
|
|
2664
|
+
" on the table starts its first and last columns on the card's content edge rather than 18px in. The headings and any pinned column paint",
|
|
2665
|
+
" ",
|
|
2666
|
+
/* @__PURE__ */ jsx("code", { children: "--o-table-ground" }),
|
|
2667
|
+
", the canvas, which a card on another ground (raised or sunken) sets to its own."
|
|
2668
|
+
] }),
|
|
2669
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2670
|
+
code: `
|
|
2671
|
+
<Card>
|
|
2672
|
+
<CardHeader title="Transactions" description="Balance £17.50" />
|
|
2673
|
+
<TableFrame variant="embedded">
|
|
2674
|
+
<Table edges="flush" density="compact">…</Table>
|
|
2675
|
+
</TableFrame>
|
|
2676
|
+
</Card>`,
|
|
2677
|
+
children: /* @__PURE__ */ jsx(EmbeddedDemo, {})
|
|
2678
|
+
})
|
|
2679
|
+
}),
|
|
2680
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2681
|
+
id: "footer-and-caption",
|
|
2682
|
+
title: "Footer and caption",
|
|
2683
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
2684
|
+
/* @__PURE__ */ jsx("code", { children: "TableFooter" }),
|
|
2685
|
+
" holds a totals row under the rows: a sunken ground under a rule, in medium weight, with figures in tabular type. Name its row with a ",
|
|
2686
|
+
/* @__PURE__ */ jsx("code", { children: "TableHeaderCell" }),
|
|
2687
|
+
" that has ",
|
|
2688
|
+
/* @__PURE__ */ jsx("code", { children: "scope=\"row\"" }),
|
|
2689
|
+
".",
|
|
2690
|
+
" ",
|
|
2691
|
+
/* @__PURE__ */ jsx("code", { children: "TableCaption" }),
|
|
2692
|
+
" names the table for a screen reader and shows a note beneath it, such as what the prices include; ",
|
|
2693
|
+
/* @__PURE__ */ jsx("code", { children: "side=\"top\"" }),
|
|
2694
|
+
" puts it above, and ",
|
|
2695
|
+
/* @__PURE__ */ jsx("code", { children: "visuallyHidden" }),
|
|
2696
|
+
" keeps it for assistive technology when a heading above the table already says the same. A caption scrolls with the table. Anything that should stay pinned under the table, a pager, goes in the frame's ",
|
|
2697
|
+
/* @__PURE__ */ jsx("code", { children: "footer" }),
|
|
2698
|
+
"."
|
|
2699
|
+
] }),
|
|
2700
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2701
|
+
align: "fill",
|
|
2702
|
+
code: `
|
|
2703
|
+
<TableFrame>
|
|
2704
|
+
<Table>
|
|
2705
|
+
<TableCaption>Prices include VAT at 20%.</TableCaption>
|
|
2706
|
+
<TableHead>…</TableHead>
|
|
2707
|
+
<TableBody>…</TableBody>
|
|
2708
|
+
<TableFooter>
|
|
2709
|
+
<TableRow>
|
|
2710
|
+
<TableHeaderCell scope="row">Total</TableHeaderCell>
|
|
2711
|
+
<TableCell numeric>6</TableCell>
|
|
2712
|
+
<TableCell numeric>{gbp.format(total)}</TableCell>
|
|
2713
|
+
</TableRow>
|
|
2714
|
+
</TableFooter>
|
|
2715
|
+
</Table>
|
|
2716
|
+
</TableFrame>`,
|
|
2717
|
+
children: /* @__PURE__ */ jsx(TotalsDemo, {})
|
|
2718
|
+
})
|
|
2719
|
+
}),
|
|
2720
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2721
|
+
id: "density",
|
|
2722
|
+
title: "Density",
|
|
2723
|
+
description: /* @__PURE__ */ jsx("p", { children: "Rows are 56px (comfortable, the default) or 44px (compact) for long lists and side panels." }),
|
|
2724
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
2725
|
+
align: "fill",
|
|
2726
|
+
code: `<Table density="compact">…</Table>`,
|
|
2727
|
+
children: /* @__PURE__ */ jsx(OrdersTable, { density: "compact" })
|
|
2728
|
+
})
|
|
2729
|
+
}),
|
|
2730
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2731
|
+
id: "both-themes",
|
|
2732
|
+
title: "In both themes",
|
|
2733
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
2734
|
+
align: "fill",
|
|
2735
|
+
children: /* @__PURE__ */ jsx(OrdersTable, {
|
|
2736
|
+
rows: ORDERS.slice(0, 3),
|
|
2737
|
+
density: "compact",
|
|
2738
|
+
selectable: true,
|
|
2739
|
+
short: true
|
|
2740
|
+
})
|
|
2741
|
+
})
|
|
2742
|
+
}),
|
|
2743
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2744
|
+
id: "guidelines",
|
|
2745
|
+
title: "Guidelines",
|
|
2746
|
+
children: [
|
|
2747
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
2748
|
+
do: {
|
|
2749
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
2750
|
+
className: "table-demo__cell-sample",
|
|
2751
|
+
children: [
|
|
2752
|
+
/* @__PURE__ */ jsx("span", { children: "£1,120.00" }),
|
|
2753
|
+
/* @__PURE__ */ jsx("span", { children: "£89.50" }),
|
|
2754
|
+
/* @__PURE__ */ jsx("span", { children: "£34.99" })
|
|
2755
|
+
]
|
|
2756
|
+
}),
|
|
2757
|
+
caption: "Money and counts in tabular figures, aligned to the end, so digits line up by place."
|
|
2758
|
+
},
|
|
2759
|
+
dont: {
|
|
2760
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
2761
|
+
className: "table-demo__cell-sample",
|
|
2762
|
+
"data-start": "",
|
|
2763
|
+
children: [
|
|
2764
|
+
/* @__PURE__ */ jsx("span", { children: "£1,120.00" }),
|
|
2765
|
+
/* @__PURE__ */ jsx("span", { children: "£89.50" }),
|
|
2766
|
+
/* @__PURE__ */ jsx("span", { children: "£34.99" })
|
|
2767
|
+
]
|
|
2768
|
+
}),
|
|
2769
|
+
caption: "Left-aligned amounts make readers hunt for the decimal point."
|
|
2770
|
+
}
|
|
2771
|
+
}),
|
|
2772
|
+
/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
2773
|
+
"Lead with the thing people scan for (the order number, the product name) and keep it one line where you can.",
|
|
2774
|
+
"Status in words on a badge, never colour alone, with the tone from the status registry (StatusBadge) so a word is one colour everywhere. Teal marks selection, and the few states that draw in the accent are listed there.",
|
|
2775
|
+
"One primary action per page, outside the table. Row actions go in a menu at the end of the row.",
|
|
2776
|
+
"Keep headings short and in sentence case; the heading names the column, the cells carry the detail.",
|
|
2777
|
+
"On a phone a table that does not fit scrolls sideways inside its frame. Keep the column people scan for first, and pin the actions column, rather than squeezing every column narrower."
|
|
2778
|
+
] }),
|
|
2779
|
+
/* @__PURE__ */ jsx(Fragment$1, {})
|
|
2780
|
+
]
|
|
2781
|
+
}),
|
|
2782
|
+
/* @__PURE__ */ jsx(Section$1, {
|
|
2783
|
+
id: "accessibility",
|
|
2784
|
+
title: "Accessibility",
|
|
2785
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
2786
|
+
"Real table elements: headers are th with scope=\"col\", so screen readers announce the column for each cell.",
|
|
2787
|
+
"Sortable headings are buttons inside the th, and the th carries aria-sort.",
|
|
2788
|
+
"A selected row carries aria-selected; every row checkbox names its row (\"Select order #1043\").",
|
|
2789
|
+
"A clickable row also has a real link in its first cell, so keyboard users can open it with Tab and Enter.",
|
|
2790
|
+
"A frame that scrolls sideways is reachable by keyboard when something inside it takes focus, a link or a menu button. When nothing does, give the frame tabIndex={0}, role=\"region\" and a name, as the examples here do; its focus ring is drawn round the frame.",
|
|
2791
|
+
"While a table is stack, its parts carry their roles (table, row, columnheader, rowheader, cell), which some browsers stop reading once the display of a table changes. A cell's label is shown but not read: the column heading already names the cell.",
|
|
2792
|
+
"A caption is the table's accessible name. Hide it with visuallyHidden when a heading above the table already says the same, and the name stays.",
|
|
2793
|
+
"A footer row names itself with a row heading (scope=\"row\"), so a screen reader reads \"Total\" with the figure. A pinned column's hidden heading keeps its words for assistive technology.",
|
|
2794
|
+
"A row's toggle is a button named for its row that says expanded or collapsed (aria-expanded) and what it opens (aria-controls); its name does not change as it opens. Give the rows under it and their parent a real order in the markup, parent first.",
|
|
2795
|
+
"A section heading is a th across the columns: with each section in a body of its own (scope=\"rowgroup\") it names the rows under it.",
|
|
2796
|
+
"A help mark is a button named \"About\" and its heading's words; its tooltip opens on keyboard focus as well as on hover and on a press.",
|
|
2797
|
+
"A locked row says aria-disabled and its reason as its description, turns every press away and takes its controls out of the tab order until it unlocks.",
|
|
2798
|
+
"A column that gives way is hidden for everyone, a screen reader too: hide only what the row says elsewhere.",
|
|
2799
|
+
"A row's drag handle is a button named for its row (\"Reorder Standard\") and described by how to move it from the keyboard; it says pressed while its row is lifted, and every lift, move, drop and cancel is said in a polite status. A handle that is off stays in the tab order (aria-disabled).",
|
|
2800
|
+
"A row marked for removal says so as its description, and its undo button names the row (\"Undo removing Saturday\"). As the undo takes the place of the button that removed the row, and back, the row hands focus to it, so focus never drops to the page."
|
|
2801
|
+
] })
|
|
2802
|
+
}),
|
|
2803
|
+
/* @__PURE__ */ jsxs(Section$1, {
|
|
2804
|
+
id: "props",
|
|
2805
|
+
title: "Props",
|
|
2806
|
+
description: /* @__PURE__ */ jsx("p", { children: "Every part also accepts the native attributes of its element." }),
|
|
2807
|
+
children: [
|
|
2808
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
2809
|
+
title: "TableFrame",
|
|
2810
|
+
rows: [
|
|
2811
|
+
{
|
|
2812
|
+
name: "height",
|
|
2813
|
+
type: "number | string",
|
|
2814
|
+
description: "Height of the scroll area. The headings stick while rows scroll."
|
|
2815
|
+
},
|
|
2816
|
+
{
|
|
2817
|
+
name: "footer",
|
|
2818
|
+
type: "ReactNode",
|
|
2819
|
+
description: "Pinned under the scroll area, e.g. Pagination."
|
|
2820
|
+
},
|
|
2821
|
+
{
|
|
2822
|
+
name: "ref",
|
|
2823
|
+
type: "Ref<HTMLDivElement>",
|
|
2824
|
+
description: "The scroll area, for virtual rows."
|
|
2825
|
+
},
|
|
2826
|
+
{
|
|
2827
|
+
name: "variant",
|
|
2828
|
+
type: "'default' | 'embedded'",
|
|
2829
|
+
default: "'default'",
|
|
2830
|
+
description: "embedded drops the edge, corners and ground, for a frame inside a Card."
|
|
2831
|
+
}
|
|
2832
|
+
]
|
|
2833
|
+
}),
|
|
2834
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
2835
|
+
title: "Table",
|
|
2836
|
+
rows: [
|
|
2837
|
+
{
|
|
2838
|
+
name: "density",
|
|
2839
|
+
type: "'comfortable' | 'compact'",
|
|
2840
|
+
default: "'comfortable'",
|
|
2841
|
+
description: "56 or 44px rows."
|
|
2842
|
+
},
|
|
2843
|
+
{
|
|
2844
|
+
name: "layout",
|
|
2845
|
+
type: "'auto' | 'fixed'",
|
|
2846
|
+
default: "'auto'",
|
|
2847
|
+
description: "fixed pins column widths to a colgroup: steady columns under virtual rows."
|
|
2848
|
+
},
|
|
2849
|
+
{
|
|
2850
|
+
name: "nowrap",
|
|
2851
|
+
type: "boolean",
|
|
2852
|
+
default: "false",
|
|
2853
|
+
description: "Every cell on one line; a table wider than its frame scrolls sideways. A cell with wrap still wraps."
|
|
2854
|
+
},
|
|
2855
|
+
{
|
|
2856
|
+
name: "stack",
|
|
2857
|
+
type: "boolean | number",
|
|
2858
|
+
default: "false",
|
|
2859
|
+
description: "Under 640px (or the width you give) each row becomes a card: the first cell its title (or the cell after a selection box), the rest labelled pairs, pinned actions in the corner. The head stays for assistive technology. true folds by CSS alone; a width is measured once the page runs."
|
|
2860
|
+
},
|
|
2861
|
+
{
|
|
2862
|
+
name: "striped",
|
|
2863
|
+
type: "boolean | 'marked'",
|
|
2864
|
+
default: "false",
|
|
2865
|
+
description: "Every second row on a light sunken ground; marked tints the rows marked alternate, for virtual rows."
|
|
2866
|
+
},
|
|
2867
|
+
{
|
|
2868
|
+
name: "edges",
|
|
2869
|
+
type: "'inset' | 'flush'",
|
|
2870
|
+
default: "'inset'",
|
|
2871
|
+
description: "flush starts the first and last columns on the frame’s edge, for a table in a card."
|
|
2872
|
+
}
|
|
2873
|
+
]
|
|
2874
|
+
}),
|
|
2875
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
2876
|
+
title: "TableCaption",
|
|
2877
|
+
rows: [{
|
|
2878
|
+
name: "side",
|
|
2879
|
+
type: "'top' | 'bottom'",
|
|
2880
|
+
default: "'bottom'",
|
|
2881
|
+
description: "Under the rows as a note, or above the headings."
|
|
2882
|
+
}, {
|
|
2883
|
+
name: "visuallyHidden",
|
|
2884
|
+
type: "boolean",
|
|
2885
|
+
default: "false",
|
|
2886
|
+
description: "Kept for assistive technology: it still names the table."
|
|
2887
|
+
}]
|
|
2888
|
+
}),
|
|
2889
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
2890
|
+
title: "TableRow",
|
|
2891
|
+
rows: [
|
|
2892
|
+
{
|
|
2893
|
+
name: "selected",
|
|
2894
|
+
type: "boolean",
|
|
2895
|
+
default: "false",
|
|
2896
|
+
description: "Teal line and tint; aria-selected."
|
|
2897
|
+
},
|
|
2898
|
+
{
|
|
2899
|
+
name: "interactive",
|
|
2900
|
+
type: "boolean",
|
|
2901
|
+
default: "false",
|
|
2902
|
+
description: "The row opens something: a pointer cursor and a hover tint. A row without it takes neither."
|
|
2903
|
+
},
|
|
2904
|
+
{
|
|
2905
|
+
name: "level",
|
|
2906
|
+
type: "number",
|
|
2907
|
+
default: "0",
|
|
2908
|
+
description: "Depth in a tree: 1 or more sits on the sunken ground, stepped in, in its indent cell, and hung from a guide line."
|
|
2909
|
+
},
|
|
2910
|
+
{
|
|
2911
|
+
name: "expanded",
|
|
2912
|
+
type: "boolean",
|
|
2913
|
+
default: "false",
|
|
2914
|
+
description: "Its rows (or its detail) are open beneath it: it joins them on their ground."
|
|
2915
|
+
},
|
|
2916
|
+
{
|
|
2917
|
+
name: "last",
|
|
2918
|
+
type: "boolean",
|
|
2919
|
+
default: "false",
|
|
2920
|
+
description: "The last row under its parent: the guide turns into it, and a firmer line closes the group."
|
|
2921
|
+
},
|
|
2922
|
+
{
|
|
2923
|
+
name: "entering",
|
|
2924
|
+
type: "boolean | number",
|
|
2925
|
+
description: "It has just appeared as its parent opened: it drops into place. A number staggers it, as its place among those appearing."
|
|
2926
|
+
},
|
|
2927
|
+
{
|
|
2928
|
+
name: "alternate",
|
|
2929
|
+
type: "boolean",
|
|
2930
|
+
default: "false",
|
|
2931
|
+
description: "In a striped=\"marked\" table, this row takes the stripe."
|
|
2932
|
+
},
|
|
2933
|
+
{
|
|
2934
|
+
name: "locked",
|
|
2935
|
+
type: "boolean",
|
|
2936
|
+
description: "Veiled, presses turned away, controls out of the tab order. Pass false while it may lock."
|
|
2937
|
+
},
|
|
2938
|
+
{
|
|
2939
|
+
name: "lockedReason",
|
|
2940
|
+
type: "string",
|
|
2941
|
+
description: "Why it is locked: a tooltip on the row and its description."
|
|
2942
|
+
},
|
|
2943
|
+
{
|
|
2944
|
+
name: "removed",
|
|
2945
|
+
type: "boolean | string",
|
|
2946
|
+
default: "false",
|
|
2947
|
+
description: "Marked for removal and not yet gone: dimmed but for the cell with its TableUndo, and described as such (or by the sentence given)."
|
|
2948
|
+
}
|
|
2949
|
+
]
|
|
2950
|
+
}),
|
|
2951
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
2952
|
+
title: "TableHeaderCell and TableCell",
|
|
2953
|
+
rows: [
|
|
2954
|
+
{
|
|
2955
|
+
name: "align",
|
|
2956
|
+
type: "'start' | 'center' | 'end'",
|
|
2957
|
+
default: "'start'",
|
|
2958
|
+
description: "Text alignment."
|
|
2959
|
+
},
|
|
2960
|
+
{
|
|
2961
|
+
name: "sort",
|
|
2962
|
+
type: "'ascending' | 'descending' | 'none'",
|
|
2963
|
+
description: "Header cell: current sort; sets aria-sort."
|
|
2964
|
+
},
|
|
2965
|
+
{
|
|
2966
|
+
name: "onSort",
|
|
2967
|
+
type: "() => void",
|
|
2968
|
+
description: "Header cell: makes the heading a sort button."
|
|
2969
|
+
},
|
|
2970
|
+
{
|
|
2971
|
+
name: "numeric",
|
|
2972
|
+
type: "boolean",
|
|
2973
|
+
default: "false",
|
|
2974
|
+
description: "Cell: tabular figures, aligned to the end."
|
|
2975
|
+
},
|
|
2976
|
+
{
|
|
2977
|
+
name: "label",
|
|
2978
|
+
type: "string",
|
|
2979
|
+
description: "Cell: the column name shown above the value in a stacked table. The row's title takes none."
|
|
2980
|
+
},
|
|
2981
|
+
{
|
|
2982
|
+
name: "truncate",
|
|
2983
|
+
type: "boolean",
|
|
2984
|
+
default: "false",
|
|
2985
|
+
description: "Cell: one line with an ellipsis (set a column width)."
|
|
2986
|
+
},
|
|
2987
|
+
{
|
|
2988
|
+
name: "wrap",
|
|
2989
|
+
type: "boolean",
|
|
2990
|
+
default: "false",
|
|
2991
|
+
description: "Let this cell or heading wrap: a heading is one line otherwise, and a cell in a nowrap table."
|
|
2992
|
+
},
|
|
2993
|
+
{
|
|
2994
|
+
name: "sticky",
|
|
2995
|
+
type: "'start' | 'end'",
|
|
2996
|
+
description: "Pin the cell to an edge while the table scrolls sideways. Set it on the heading and every cell of the column."
|
|
2997
|
+
},
|
|
2998
|
+
{
|
|
2999
|
+
name: "stickyOffset",
|
|
3000
|
+
type: "number | string",
|
|
3001
|
+
description: "With sticky=\"start\": how far in it is pinned, past the pinned columns before it."
|
|
3002
|
+
},
|
|
3003
|
+
{
|
|
3004
|
+
name: "hideBelow",
|
|
3005
|
+
type: "number",
|
|
3006
|
+
description: "Hidden while the box the table sits in is narrower than this many px. Set it on the heading and every cell of the column."
|
|
3007
|
+
},
|
|
3008
|
+
{
|
|
3009
|
+
name: "help",
|
|
3010
|
+
type: "ReactNode",
|
|
3011
|
+
description: "Header cell: what the column means, behind a quiet mark beside the heading."
|
|
3012
|
+
},
|
|
3013
|
+
{
|
|
3014
|
+
name: "helpLabel",
|
|
3015
|
+
type: "string",
|
|
3016
|
+
description: "Header cell: the mark’s name. Defaults to “About” and the heading’s words."
|
|
3017
|
+
},
|
|
3018
|
+
{
|
|
3019
|
+
name: "indent",
|
|
3020
|
+
type: "boolean",
|
|
3021
|
+
default: "false",
|
|
3022
|
+
description: "Cell: the row’s name cell in a tree, stepped in by the row’s level, where its guide is drawn."
|
|
3023
|
+
}
|
|
3024
|
+
]
|
|
3025
|
+
}),
|
|
3026
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
3027
|
+
title: "TableExpandToggle",
|
|
3028
|
+
rows: [
|
|
3029
|
+
{
|
|
3030
|
+
name: "expanded",
|
|
3031
|
+
type: "boolean",
|
|
3032
|
+
required: true,
|
|
3033
|
+
description: "Whether what it opens is open; aria-expanded."
|
|
3034
|
+
},
|
|
3035
|
+
{
|
|
3036
|
+
name: "onExpandedChange",
|
|
3037
|
+
type: "(expanded: boolean) => void",
|
|
3038
|
+
description: "Called with the next state when pressed. The press never opens its row."
|
|
3039
|
+
},
|
|
3040
|
+
{
|
|
3041
|
+
name: "label",
|
|
3042
|
+
type: "string",
|
|
3043
|
+
required: true,
|
|
3044
|
+
description: "Its name, which names its row: “Variants of Hip pack 3L”. The same open or shut."
|
|
3045
|
+
},
|
|
3046
|
+
{
|
|
3047
|
+
name: "controls",
|
|
3048
|
+
type: "string",
|
|
3049
|
+
description: "The id of what it opens, for aria-controls."
|
|
3050
|
+
},
|
|
3051
|
+
{
|
|
3052
|
+
name: "expandable",
|
|
3053
|
+
type: "boolean",
|
|
3054
|
+
default: "true",
|
|
3055
|
+
description: "false keeps its room empty, for a row with nothing under it."
|
|
3056
|
+
}
|
|
3057
|
+
]
|
|
3058
|
+
}),
|
|
3059
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
3060
|
+
title: "TableExpandAll",
|
|
3061
|
+
rows: [
|
|
3062
|
+
{
|
|
3063
|
+
name: "expanded",
|
|
3064
|
+
type: "boolean",
|
|
3065
|
+
required: true,
|
|
3066
|
+
description: "True while every row is open: it then offers to collapse them."
|
|
3067
|
+
},
|
|
3068
|
+
{
|
|
3069
|
+
name: "onExpandedChange",
|
|
3070
|
+
type: "(expanded: boolean) => void",
|
|
3071
|
+
required: true,
|
|
3072
|
+
description: "Called with true to open every row, false to shut them."
|
|
3073
|
+
},
|
|
3074
|
+
{
|
|
3075
|
+
name: "labels",
|
|
3076
|
+
type: "Partial<Pick<TableLabels, 'expandAll' | 'collapseAll'>>",
|
|
3077
|
+
description: "Its words, for translation (tableLabels is the English set)."
|
|
3078
|
+
},
|
|
3079
|
+
{
|
|
3080
|
+
name: "variant, size",
|
|
3081
|
+
type: "ButtonVariant, ButtonSize",
|
|
3082
|
+
default: "'secondary', 'sm'",
|
|
3083
|
+
description: "As a Button."
|
|
3084
|
+
}
|
|
3085
|
+
]
|
|
3086
|
+
}),
|
|
3087
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
3088
|
+
title: "TableDetailRow",
|
|
3089
|
+
rows: [
|
|
3090
|
+
{
|
|
3091
|
+
name: "colSpan",
|
|
3092
|
+
type: "number",
|
|
3093
|
+
required: true,
|
|
3094
|
+
description: "How many columns the table has: its one cell spans them."
|
|
3095
|
+
},
|
|
3096
|
+
{
|
|
3097
|
+
name: "variant",
|
|
3098
|
+
type: "'panel' | 'note'",
|
|
3099
|
+
default: "'panel'",
|
|
3100
|
+
description: "What its row opens, on a sunken ground; or a note that stays under its row and reads as part of it."
|
|
3101
|
+
},
|
|
3102
|
+
{
|
|
3103
|
+
name: "tone",
|
|
3104
|
+
type: "'neutral' | 'negative' | 'warning'",
|
|
3105
|
+
default: "'neutral'",
|
|
3106
|
+
description: "A note’s tone."
|
|
3107
|
+
},
|
|
3108
|
+
{
|
|
3109
|
+
name: "inset",
|
|
3110
|
+
type: "number | string",
|
|
3111
|
+
description: "How far past the table’s edge its words start, to line them up with a column’s."
|
|
3112
|
+
}
|
|
3113
|
+
]
|
|
3114
|
+
}),
|
|
3115
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
3116
|
+
title: "TableSectionRow",
|
|
3117
|
+
rows: [{
|
|
3118
|
+
name: "colSpan",
|
|
3119
|
+
type: "number",
|
|
3120
|
+
required: true,
|
|
3121
|
+
description: "How many columns the table has: the heading spans them."
|
|
3122
|
+
}, {
|
|
3123
|
+
name: "scope",
|
|
3124
|
+
type: "'rowgroup' | 'row'",
|
|
3125
|
+
default: "'rowgroup'",
|
|
3126
|
+
description: "rowgroup names the rows of its body (one body per section); row names only itself, for a shared body."
|
|
3127
|
+
}]
|
|
3128
|
+
}),
|
|
3129
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
3130
|
+
title: "TableReorderBody",
|
|
3131
|
+
rows: [
|
|
3132
|
+
{
|
|
3133
|
+
name: "items",
|
|
3134
|
+
type: "T[]",
|
|
3135
|
+
required: true,
|
|
3136
|
+
description: "The rows, in their order."
|
|
3137
|
+
},
|
|
3138
|
+
{
|
|
3139
|
+
name: "getKey",
|
|
3140
|
+
type: "(item: T, index: number) => string",
|
|
3141
|
+
required: true,
|
|
3142
|
+
description: "A stable key per row, unique in the body."
|
|
3143
|
+
},
|
|
3144
|
+
{
|
|
3145
|
+
name: "getLabel",
|
|
3146
|
+
type: "(item: T, index: number) => string",
|
|
3147
|
+
required: true,
|
|
3148
|
+
description: "The row’s words, in its handle’s name (“Reorder Standard”) and in what is said as it moves."
|
|
3149
|
+
},
|
|
3150
|
+
{
|
|
3151
|
+
name: "onReorder",
|
|
3152
|
+
type: "(from: number, to: number) => void",
|
|
3153
|
+
required: true,
|
|
3154
|
+
description: "A finished move, as moveItem reads it. Not called for a row put back where it was."
|
|
3155
|
+
},
|
|
3156
|
+
{
|
|
3157
|
+
name: "children",
|
|
3158
|
+
type: "(item: T, row: TableReorderRow) => ReactNode",
|
|
3159
|
+
required: true,
|
|
3160
|
+
description: "Draws a row: spread row.rowProps on its TableRow and put row.handle in its first cell."
|
|
3161
|
+
},
|
|
3162
|
+
{
|
|
3163
|
+
name: "isItemDisabled",
|
|
3164
|
+
type: "(item: T, index: number) => boolean",
|
|
3165
|
+
description: "Rows that cannot move; others still move past them. Their handles are off but still reached."
|
|
3166
|
+
},
|
|
3167
|
+
{
|
|
3168
|
+
name: "disabled",
|
|
3169
|
+
type: "boolean",
|
|
3170
|
+
default: "false",
|
|
3171
|
+
description: "Turns every handle off, as while the order saves."
|
|
3172
|
+
},
|
|
3173
|
+
{
|
|
3174
|
+
name: "heading",
|
|
3175
|
+
type: "ReactNode",
|
|
3176
|
+
description: "A row drawn first that does not move: the group’s TableSectionRow."
|
|
3177
|
+
},
|
|
3178
|
+
{
|
|
3179
|
+
name: "labels",
|
|
3180
|
+
type: "Partial<TableReorderLabels>",
|
|
3181
|
+
description: "The handle’s name, its instructions and what is said as a row moves, for translation (tableReorderLabels is the English set)."
|
|
3182
|
+
}
|
|
3183
|
+
]
|
|
3184
|
+
}),
|
|
3185
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
3186
|
+
title: "TableDragHandle and TableUndo",
|
|
3187
|
+
rows: [{
|
|
3188
|
+
name: "label",
|
|
3189
|
+
type: "string",
|
|
3190
|
+
required: true,
|
|
3191
|
+
description: "The row’s words: “Reorder Standard”, “Undo removing Saturday”. (TableUndo: optional, it then says only “Undo”.)"
|
|
3192
|
+
}, {
|
|
3193
|
+
name: "labels",
|
|
3194
|
+
type: "Partial<TableReorderLabels>",
|
|
3195
|
+
description: "TableDragHandle: handle. TableUndo: undo and undoNamed."
|
|
3196
|
+
}]
|
|
3197
|
+
}),
|
|
3198
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
3199
|
+
columns: ["Part", "Element"],
|
|
3200
|
+
rows: [
|
|
3201
|
+
[/* @__PURE__ */ jsx("code", { children: "TableFrame" }), "div (frame) › div (scroll area)"],
|
|
3202
|
+
[/* @__PURE__ */ jsx("code", { children: "Table" }), "table"],
|
|
3203
|
+
[/* @__PURE__ */ jsx("code", { children: "TableHead" }), "thead"],
|
|
3204
|
+
[/* @__PURE__ */ jsx("code", { children: "TableBody" }), "tbody"],
|
|
3205
|
+
[/* @__PURE__ */ jsx("code", { children: "TableFooter" }), "tfoot"],
|
|
3206
|
+
[/* @__PURE__ */ jsx("code", { children: "TableCaption" }), "caption"],
|
|
3207
|
+
[/* @__PURE__ */ jsx("code", { children: "TableRow" }), "tr"],
|
|
3208
|
+
[/* @__PURE__ */ jsx("code", { children: "TableHeaderCell" }), "th"],
|
|
3209
|
+
[/* @__PURE__ */ jsx("code", { children: "TableCell" }), "td"],
|
|
3210
|
+
[/* @__PURE__ */ jsx("code", { children: "TableExpandToggle" }), "button (an IconButton)"],
|
|
3211
|
+
[/* @__PURE__ */ jsx("code", { children: "TableExpandAll" }), "button (a Button)"],
|
|
3212
|
+
[/* @__PURE__ */ jsx("code", { children: "TableDetailRow" }), "tr › td (one, across the columns)"],
|
|
3213
|
+
[/* @__PURE__ */ jsx("code", { children: "TableSectionRow" }), "tr › th (one, across the columns)"],
|
|
3214
|
+
[/* @__PURE__ */ jsx("code", { children: "TableReorderBody" }), "tbody (its words for a screen reader portal to the page)"],
|
|
3215
|
+
[/* @__PURE__ */ jsx("code", { children: "TableDragHandle" }), "button"],
|
|
3216
|
+
[/* @__PURE__ */ jsx("code", { children: "TableUndo" }), "button (a Button)"]
|
|
3217
|
+
]
|
|
3218
|
+
})
|
|
3219
|
+
]
|
|
3220
|
+
})
|
|
3221
|
+
]
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
3224
|
+
//#endregion
|
|
3225
|
+
export { Page, Preview };
|