@orbitcommerce/constellation-docs 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +6 -0
- package/README.md +6 -2
- package/dist/docs.css +8260 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.js +308 -0
- package/dist/pages/Playground-CNbBbErC.js +129 -0
- package/dist/pages/_figures-data-BDmScEny.js +606 -0
- package/dist/pages/_foundations-blXWyYh8.js +30 -0
- package/dist/pages/_overlays-specimens-Dpn6oiyH.js +310 -0
- package/dist/pages/alert-BD4e6QTh.js +769 -0
- package/dist/pages/app-shell-KbA-nRqZ.js +1479 -0
- package/dist/pages/area-chart-B91dLcGo.js +562 -0
- package/dist/pages/avatar-DPPHXJAu.js +713 -0
- package/dist/pages/badge-C9JR0thI.js +729 -0
- package/dist/pages/button-D3V912P4.js +518 -0
- package/dist/pages/calendar-DSDZ9nRH.js +630 -0
- package/dist/pages/card-DUggbis3.js +659 -0
- package/dist/pages/checkbox-DwimQaK3.js +365 -0
- package/dist/pages/colour-BwuO8xAv.js +1498 -0
- package/dist/pages/command-palette-xAD7fOg6.js +1243 -0
- package/dist/pages/date-picker-BYSa816m.js +1421 -0
- package/dist/pages/delta-CtAo0eIM.js +574 -0
- package/dist/pages/dialog-BRAf4LMh.js +1451 -0
- package/dist/pages/docs-BNOb7AqR.js +515 -0
- package/dist/pages/empty-state-C-mLrXW2.js +417 -0
- package/dist/pages/figure-tabs-CoPFzzKz.js +460 -0
- package/dist/pages/home-dashboard-CFQwDtC9.js +959 -0
- package/dist/pages/host-B6znjEgQ.js +109 -0
- package/dist/pages/icon-button-C9eSVPPW.js +861 -0
- package/dist/pages/icons-sxkTs5Ob.js +473 -0
- package/dist/pages/input-KF9Gkawf.js +1093 -0
- package/dist/pages/installation-DpsX8G_n.js +445 -0
- package/dist/pages/kbd-cNfDoikz.js +544 -0
- package/dist/pages/live-globe-ClvLn9Lb.js +571 -0
- package/dist/pages/logo-BfGF1Pq9.js +571 -0
- package/dist/pages/menu-by2sgQ09.js +1618 -0
- package/dist/pages/motion-BvTGc2Dk.js +855 -0
- package/dist/pages/orbit-spinner-Dil1Z3Oy.js +332 -0
- package/dist/pages/overview-BPEbZQ6g.js +130 -0
- package/dist/pages/pagination-BBUnGvv5.js +249 -0
- package/dist/pages/popover-Db1gLDpb.js +1136 -0
- package/dist/pages/principles-CeAIOIdt.js +483 -0
- package/dist/pages/radio-group-CkdBWWfG.js +1077 -0
- package/dist/pages/registry-CroHzK9I.js +244 -0
- package/dist/pages/release-Dvo684UJ.js +13 -0
- package/dist/pages/rolling-number-qmvH84Mq.js +529 -0
- package/dist/pages/search-field-BN7MWGQ4.js +693 -0
- package/dist/pages/segmented-control-CTbIpRBW.js +777 -0
- package/dist/pages/select-DguELoRR.js +1429 -0
- package/dist/pages/separator-CPZub9pv.js +351 -0
- package/dist/pages/shape-DKvA0YKr.js +627 -0
- package/dist/pages/skeleton-DLuBhP46.js +561 -0
- package/dist/pages/sparkline-DMMYGbHn.js +668 -0
- package/dist/pages/switch-B-Qe4kcT.js +517 -0
- package/dist/pages/table-AMoODng4.js +607 -0
- package/dist/pages/tabs-B4M-usCV.js +1455 -0
- package/dist/pages/textarea-fTuUZRQb.js +693 -0
- package/dist/pages/toast-CKP03zjy.js +1176 -0
- package/dist/pages/tooltip-CBYil3kt.js +697 -0
- package/dist/pages/typography-PCbg8Bhg.js +735 -0
- package/manifest.json +3125 -0
- package/package.json +35 -4
|
@@ -0,0 +1,607 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { t as DocLink } from "./host-B6znjEgQ.js";
|
|
3
|
+
import { a as DocTable, d as Section, i as DocPage, m as ThemePair, o as Example, r as DoDont, s as Guidelines, u as PropsTable } from "./docs-BNOb7AqR.js";
|
|
4
|
+
import { useMemo, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Avatar, Badge, Button, Checkbox, IconButton, Pagination, Table, TableBody, TableCell, TableFrame, TableHead, TableHeaderCell, TableRow } from "@orbitcommerce/constellation";
|
|
7
|
+
import { DotsThreeIcon, PackageIcon, PrinterIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/table.tsx
|
|
9
|
+
var PAID = {
|
|
10
|
+
label: "Paid",
|
|
11
|
+
tone: "positive"
|
|
12
|
+
};
|
|
13
|
+
var PENDING = {
|
|
14
|
+
label: "Payment pending",
|
|
15
|
+
tone: "warning"
|
|
16
|
+
};
|
|
17
|
+
var REFUNDED = {
|
|
18
|
+
label: "Refunded",
|
|
19
|
+
tone: "negative"
|
|
20
|
+
};
|
|
21
|
+
var UNFULFILLED = {
|
|
22
|
+
label: "Unfulfilled",
|
|
23
|
+
tone: "warning"
|
|
24
|
+
};
|
|
25
|
+
var FULFILLED = {
|
|
26
|
+
label: "Fulfilled",
|
|
27
|
+
tone: "positive"
|
|
28
|
+
};
|
|
29
|
+
var ORDERS = [
|
|
30
|
+
{
|
|
31
|
+
id: "o1",
|
|
32
|
+
number: "#1043",
|
|
33
|
+
customer: "Sarah Whitfield",
|
|
34
|
+
date: "29 Sep, 14:02",
|
|
35
|
+
total: 240,
|
|
36
|
+
payment: PAID,
|
|
37
|
+
fulfilment: UNFULFILLED,
|
|
38
|
+
items: 2
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "o2",
|
|
42
|
+
number: "#1042",
|
|
43
|
+
customer: "James Okafor",
|
|
44
|
+
date: "29 Sep, 11:47",
|
|
45
|
+
total: 89.5,
|
|
46
|
+
payment: PENDING,
|
|
47
|
+
fulfilment: UNFULFILLED,
|
|
48
|
+
items: 1
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: "o3",
|
|
52
|
+
number: "#1041",
|
|
53
|
+
customer: "Priya Shah",
|
|
54
|
+
date: "28 Sep, 19:20",
|
|
55
|
+
total: 1120,
|
|
56
|
+
payment: PAID,
|
|
57
|
+
fulfilment: FULFILLED,
|
|
58
|
+
items: 4
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: "o4",
|
|
62
|
+
number: "#1040",
|
|
63
|
+
customer: "Tom Hughes",
|
|
64
|
+
date: "28 Sep, 09:05",
|
|
65
|
+
total: 34.99,
|
|
66
|
+
payment: REFUNDED,
|
|
67
|
+
fulfilment: FULFILLED,
|
|
68
|
+
items: 1
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "o5",
|
|
72
|
+
number: "#1039",
|
|
73
|
+
customer: "Eleanor Price",
|
|
74
|
+
date: "27 Sep, 16:33",
|
|
75
|
+
total: 412.8,
|
|
76
|
+
payment: PAID,
|
|
77
|
+
fulfilment: FULFILLED,
|
|
78
|
+
items: 3
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
var gbp = new Intl.NumberFormat("en-GB", {
|
|
82
|
+
style: "currency",
|
|
83
|
+
currency: "GBP"
|
|
84
|
+
});
|
|
85
|
+
function OrdersTable({ rows = ORDERS, density = "comfortable", selectable = false, sortable = false }) {
|
|
86
|
+
const [selected, setSelected] = useState({ o2: true });
|
|
87
|
+
const [sort, setSort] = useState({
|
|
88
|
+
key: "date",
|
|
89
|
+
dir: "descending"
|
|
90
|
+
});
|
|
91
|
+
const sorted = useMemo(() => {
|
|
92
|
+
if (!sortable) return rows;
|
|
93
|
+
const list = [...rows];
|
|
94
|
+
if (sort.key === "total") list.sort((a, b) => sort.dir === "ascending" ? a.total - b.total : b.total - a.total);
|
|
95
|
+
else if (sort.dir === "ascending") list.reverse();
|
|
96
|
+
return list;
|
|
97
|
+
}, [
|
|
98
|
+
rows,
|
|
99
|
+
sortable,
|
|
100
|
+
sort
|
|
101
|
+
]);
|
|
102
|
+
const count = Object.values(selected).filter(Boolean).length;
|
|
103
|
+
const all = count === rows.length ? true : count === 0 ? false : "indeterminate";
|
|
104
|
+
const sortOf = (key) => sort.key === key ? sort.dir : "none";
|
|
105
|
+
const toggleSort = (key) => setSort((s) => ({
|
|
106
|
+
key,
|
|
107
|
+
dir: s.key === key && s.dir === "descending" ? "ascending" : "descending"
|
|
108
|
+
}));
|
|
109
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
110
|
+
className: "table-demo",
|
|
111
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
112
|
+
density,
|
|
113
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
114
|
+
selectable ? /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
115
|
+
style: { width: 44 },
|
|
116
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
117
|
+
"aria-label": "Select all orders",
|
|
118
|
+
checked: all,
|
|
119
|
+
onCheckedChange: (next) => setSelected(Object.fromEntries(rows.map((r) => [r.id, next])))
|
|
120
|
+
})
|
|
121
|
+
}) : null,
|
|
122
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
123
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
124
|
+
sort: sortable ? sortOf("date") : void 0,
|
|
125
|
+
onSort: sortable ? () => toggleSort("date") : void 0,
|
|
126
|
+
children: "Date"
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
129
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Payment" }),
|
|
130
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Fulfilment" }),
|
|
131
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
132
|
+
align: "end",
|
|
133
|
+
sort: sortable ? sortOf("total") : void 0,
|
|
134
|
+
onSort: sortable ? () => toggleSort("total") : void 0,
|
|
135
|
+
children: "Total"
|
|
136
|
+
})
|
|
137
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: sorted.map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
138
|
+
interactive: true,
|
|
139
|
+
selected: selectable && !!selected[order.id],
|
|
140
|
+
children: [
|
|
141
|
+
selectable ? /* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
142
|
+
"aria-label": `Select order ${order.number}`,
|
|
143
|
+
checked: !!selected[order.id],
|
|
144
|
+
onCheckedChange: (next) => setSelected((s) => ({
|
|
145
|
+
...s,
|
|
146
|
+
[order.id]: next
|
|
147
|
+
}))
|
|
148
|
+
}) }) : null,
|
|
149
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
150
|
+
href: "#basics",
|
|
151
|
+
children: order.number
|
|
152
|
+
}) }),
|
|
153
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
154
|
+
className: "table-demo__quiet",
|
|
155
|
+
children: order.date
|
|
156
|
+
}),
|
|
157
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs("span", {
|
|
158
|
+
className: "table-demo__who",
|
|
159
|
+
children: [/* @__PURE__ */ jsx(Avatar, {
|
|
160
|
+
size: "xs",
|
|
161
|
+
name: order.customer
|
|
162
|
+
}), order.customer]
|
|
163
|
+
}) }),
|
|
164
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
165
|
+
size: "sm",
|
|
166
|
+
tone: order.payment.tone,
|
|
167
|
+
dot: true,
|
|
168
|
+
children: order.payment.label
|
|
169
|
+
}) }),
|
|
170
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
171
|
+
size: "sm",
|
|
172
|
+
tone: order.fulfilment.tone,
|
|
173
|
+
dot: true,
|
|
174
|
+
children: order.fulfilment.label
|
|
175
|
+
}) }),
|
|
176
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
177
|
+
numeric: true,
|
|
178
|
+
children: gbp.format(order.total)
|
|
179
|
+
})
|
|
180
|
+
]
|
|
181
|
+
}, order.id)) })]
|
|
182
|
+
})
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function SelectionDemo() {
|
|
186
|
+
const [selected, setSelected] = useState({
|
|
187
|
+
o1: true,
|
|
188
|
+
o2: true
|
|
189
|
+
});
|
|
190
|
+
const count = Object.values(selected).filter(Boolean).length;
|
|
191
|
+
const all = count === ORDERS.length ? true : count === 0 ? false : "indeterminate";
|
|
192
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
193
|
+
className: "table-demo",
|
|
194
|
+
children: /* @__PURE__ */ jsxs(Table, { children: [/* @__PURE__ */ jsx(TableHead, { children: count > 0 ? /* @__PURE__ */ jsxs(TableRow, { children: [/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
195
|
+
style: { width: 44 },
|
|
196
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
197
|
+
"aria-label": "Select all orders",
|
|
198
|
+
checked: all,
|
|
199
|
+
onCheckedChange: (next) => setSelected(Object.fromEntries(ORDERS.map((r) => [r.id, next])))
|
|
200
|
+
})
|
|
201
|
+
}), /* @__PURE__ */ jsx(TableHeaderCell, {
|
|
202
|
+
colSpan: 3,
|
|
203
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
204
|
+
className: "table-demo__bulk",
|
|
205
|
+
children: [
|
|
206
|
+
/* @__PURE__ */ jsxs("strong", { children: [count, " selected"] }),
|
|
207
|
+
/* @__PURE__ */ jsx(Button, {
|
|
208
|
+
size: "xs",
|
|
209
|
+
variant: "soft",
|
|
210
|
+
icon: /* @__PURE__ */ jsx(PackageIcon, {}),
|
|
211
|
+
children: "Fulfil"
|
|
212
|
+
}),
|
|
213
|
+
/* @__PURE__ */ jsx(Button, {
|
|
214
|
+
size: "xs",
|
|
215
|
+
variant: "soft",
|
|
216
|
+
icon: /* @__PURE__ */ jsx(PrinterIcon, {}),
|
|
217
|
+
children: "Print packing slips"
|
|
218
|
+
}),
|
|
219
|
+
/* @__PURE__ */ jsx(IconButton, {
|
|
220
|
+
size: "xs",
|
|
221
|
+
label: "More actions",
|
|
222
|
+
children: /* @__PURE__ */ jsx(DotsThreeIcon, {})
|
|
223
|
+
})
|
|
224
|
+
]
|
|
225
|
+
})
|
|
226
|
+
})] }) : /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
227
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
228
|
+
style: { width: 44 },
|
|
229
|
+
children: /* @__PURE__ */ jsx(Checkbox, {
|
|
230
|
+
"aria-label": "Select all orders",
|
|
231
|
+
checked: false,
|
|
232
|
+
onCheckedChange: (next) => setSelected(Object.fromEntries(ORDERS.map((r) => [r.id, next])))
|
|
233
|
+
})
|
|
234
|
+
}),
|
|
235
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
236
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
237
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
238
|
+
align: "end",
|
|
239
|
+
children: "Total"
|
|
240
|
+
})
|
|
241
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: ORDERS.map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
242
|
+
interactive: true,
|
|
243
|
+
selected: !!selected[order.id],
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Checkbox, {
|
|
246
|
+
"aria-label": `Select order ${order.number}`,
|
|
247
|
+
checked: !!selected[order.id],
|
|
248
|
+
onCheckedChange: (next) => setSelected((s) => ({
|
|
249
|
+
...s,
|
|
250
|
+
[order.id]: next
|
|
251
|
+
}))
|
|
252
|
+
}) }),
|
|
253
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
254
|
+
href: "#selection",
|
|
255
|
+
children: order.number
|
|
256
|
+
}) }),
|
|
257
|
+
/* @__PURE__ */ jsx(TableCell, { children: order.customer }),
|
|
258
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
259
|
+
numeric: true,
|
|
260
|
+
children: gbp.format(order.total)
|
|
261
|
+
})
|
|
262
|
+
]
|
|
263
|
+
}, order.id)) })] })
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function FramedDemo() {
|
|
267
|
+
const [page, setPage] = useState(1);
|
|
268
|
+
const many = Array.from({ length: 12 }, (_, i) => ({
|
|
269
|
+
...ORDERS[i % ORDERS.length],
|
|
270
|
+
id: `m${i}`,
|
|
271
|
+
number: `#${1043 - i}`
|
|
272
|
+
}));
|
|
273
|
+
return /* @__PURE__ */ jsx(TableFrame, {
|
|
274
|
+
height: 300,
|
|
275
|
+
className: "table-demo",
|
|
276
|
+
footer: /* @__PURE__ */ jsx(Pagination, {
|
|
277
|
+
page,
|
|
278
|
+
pageCount: 25,
|
|
279
|
+
onPageChange: setPage,
|
|
280
|
+
summary: "1–50 of 1,241 orders"
|
|
281
|
+
}),
|
|
282
|
+
children: /* @__PURE__ */ jsxs(Table, {
|
|
283
|
+
density: "compact",
|
|
284
|
+
children: [/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
285
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Order" }),
|
|
286
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Customer" }),
|
|
287
|
+
/* @__PURE__ */ jsx(TableHeaderCell, { children: "Payment" }),
|
|
288
|
+
/* @__PURE__ */ jsx(TableHeaderCell, {
|
|
289
|
+
align: "end",
|
|
290
|
+
children: "Total"
|
|
291
|
+
})
|
|
292
|
+
] }) }), /* @__PURE__ */ jsx(TableBody, { children: many.map((order) => /* @__PURE__ */ jsxs(TableRow, {
|
|
293
|
+
interactive: true,
|
|
294
|
+
children: [
|
|
295
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx("a", {
|
|
296
|
+
href: "#frame",
|
|
297
|
+
children: order.number
|
|
298
|
+
}) }),
|
|
299
|
+
/* @__PURE__ */ jsx(TableCell, { children: order.customer }),
|
|
300
|
+
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsx(Badge, {
|
|
301
|
+
size: "sm",
|
|
302
|
+
tone: order.payment.tone,
|
|
303
|
+
dot: true,
|
|
304
|
+
children: order.payment.label
|
|
305
|
+
}) }),
|
|
306
|
+
/* @__PURE__ */ jsx(TableCell, {
|
|
307
|
+
numeric: true,
|
|
308
|
+
children: gbp.format(order.total)
|
|
309
|
+
})
|
|
310
|
+
]
|
|
311
|
+
}, order.id)) })]
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
function Preview() {
|
|
316
|
+
return /* @__PURE__ */ jsx("div", {
|
|
317
|
+
className: "table-preview",
|
|
318
|
+
children: /* @__PURE__ */ jsx(OrdersTable, {
|
|
319
|
+
rows: ORDERS.slice(0, 3),
|
|
320
|
+
density: "compact"
|
|
321
|
+
})
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
function Page() {
|
|
325
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
326
|
+
title: "Table",
|
|
327
|
+
status: "new",
|
|
328
|
+
importNames: [
|
|
329
|
+
"TableFrame",
|
|
330
|
+
"Table",
|
|
331
|
+
"TableHead",
|
|
332
|
+
"TableBody",
|
|
333
|
+
"TableRow",
|
|
334
|
+
"TableHeaderCell",
|
|
335
|
+
"TableCell"
|
|
336
|
+
],
|
|
337
|
+
lead: "Rows of records on hairlines: orders, products, customers. Quiet headings that stay put while the rows scroll, a soft hover, and a line of teal on the rows you have chosen.",
|
|
338
|
+
children: [
|
|
339
|
+
/* @__PURE__ */ jsx(Section, {
|
|
340
|
+
id: "basics",
|
|
341
|
+
title: "Basics",
|
|
342
|
+
description: /* @__PURE__ */ jsx("p", { children: "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." }),
|
|
343
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
344
|
+
align: "fill",
|
|
345
|
+
code: `
|
|
346
|
+
<TableFrame>
|
|
347
|
+
<Table>
|
|
348
|
+
<TableHead>
|
|
349
|
+
<TableRow>
|
|
350
|
+
<TableHeaderCell>Order</TableHeaderCell>
|
|
351
|
+
<TableHeaderCell>Customer</TableHeaderCell>
|
|
352
|
+
<TableHeaderCell>Payment</TableHeaderCell>
|
|
353
|
+
<TableHeaderCell align="end">Total</TableHeaderCell>
|
|
354
|
+
</TableRow>
|
|
355
|
+
</TableHead>
|
|
356
|
+
<TableBody>
|
|
357
|
+
{orders.map((order) => (
|
|
358
|
+
<TableRow key={order.id} interactive onClick={() => open(order)}>
|
|
359
|
+
<TableCell><Link to={order.href}>{order.number}</Link></TableCell>
|
|
360
|
+
<TableCell>{order.customer}</TableCell>
|
|
361
|
+
<TableCell><Badge size="sm" tone="positive" dot>Paid</Badge></TableCell>
|
|
362
|
+
<TableCell numeric>{gbp.format(order.total)}</TableCell>
|
|
363
|
+
</TableRow>
|
|
364
|
+
))}
|
|
365
|
+
</TableBody>
|
|
366
|
+
</Table>
|
|
367
|
+
</TableFrame>`,
|
|
368
|
+
children: /* @__PURE__ */ jsx(OrdersTable, {})
|
|
369
|
+
})
|
|
370
|
+
}),
|
|
371
|
+
/* @__PURE__ */ jsx(Section, {
|
|
372
|
+
id: "selection",
|
|
373
|
+
title: "Selection",
|
|
374
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
375
|
+
"A ",
|
|
376
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
377
|
+
to: "/components/checkbox",
|
|
378
|
+
children: "Checkbox"
|
|
379
|
+
}),
|
|
380
|
+
" 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."
|
|
381
|
+
] }),
|
|
382
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
383
|
+
align: "fill",
|
|
384
|
+
code: `<TableRow selected={!!selected[order.id]}>…</TableRow>`,
|
|
385
|
+
children: /* @__PURE__ */ jsx(SelectionDemo, {})
|
|
386
|
+
})
|
|
387
|
+
}),
|
|
388
|
+
/* @__PURE__ */ jsx(Section, {
|
|
389
|
+
id: "sorting",
|
|
390
|
+
title: "Sorting",
|
|
391
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
392
|
+
"Give a heading ",
|
|
393
|
+
/* @__PURE__ */ jsx("code", { children: "sort" }),
|
|
394
|
+
" and ",
|
|
395
|
+
/* @__PURE__ */ jsx("code", { children: "onSort" }),
|
|
396
|
+
" and it becomes a button with an arrow; the header cell carries ",
|
|
397
|
+
/* @__PURE__ */ jsx("code", { children: "aria-sort" }),
|
|
398
|
+
". Press Date or Total."
|
|
399
|
+
] }),
|
|
400
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
401
|
+
align: "fill",
|
|
402
|
+
code: `<TableHeaderCell align="end" sort={sort.key === 'total' ? sort.dir : 'none'} onSort={() => toggle('total')}>
|
|
403
|
+
Total
|
|
404
|
+
</TableHeaderCell>`,
|
|
405
|
+
children: /* @__PURE__ */ jsx(OrdersTable, { sortable: true })
|
|
406
|
+
})
|
|
407
|
+
}),
|
|
408
|
+
/* @__PURE__ */ jsx(Section, {
|
|
409
|
+
id: "frame",
|
|
410
|
+
title: "Frame, scrolling and pages",
|
|
411
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
412
|
+
/* @__PURE__ */ jsx("code", { children: "TableFrame" }),
|
|
413
|
+
" is the hairline box with its own scroll area: set ",
|
|
414
|
+
/* @__PURE__ */ jsx("code", { children: "height" }),
|
|
415
|
+
" and the headings stay put while rows scroll. ",
|
|
416
|
+
/* @__PURE__ */ jsx("code", { children: "footer" }),
|
|
417
|
+
" pins ",
|
|
418
|
+
/* @__PURE__ */ jsx(DocLink, {
|
|
419
|
+
to: "/components/pagination",
|
|
420
|
+
children: "Pagination"
|
|
421
|
+
}),
|
|
422
|
+
" under it. Its ref goes to the scroll area, for virtual rows."
|
|
423
|
+
] }),
|
|
424
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
425
|
+
align: "fill",
|
|
426
|
+
code: `
|
|
427
|
+
<TableFrame height={300} footer={<Pagination page={page} pageCount={25} onPageChange={setPage} summary="1–50 of 1,241 orders" />}>
|
|
428
|
+
<Table density="compact">…</Table>
|
|
429
|
+
</TableFrame>`,
|
|
430
|
+
children: /* @__PURE__ */ jsx(FramedDemo, {})
|
|
431
|
+
})
|
|
432
|
+
}),
|
|
433
|
+
/* @__PURE__ */ jsx(Section, {
|
|
434
|
+
id: "density",
|
|
435
|
+
title: "Density",
|
|
436
|
+
description: /* @__PURE__ */ jsx("p", { children: "Rows are 56px (comfortable, the default) or 44px (compact) for long lists and side panels." }),
|
|
437
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
438
|
+
align: "fill",
|
|
439
|
+
code: `<Table density="compact">…</Table>`,
|
|
440
|
+
children: /* @__PURE__ */ jsx(OrdersTable, { density: "compact" })
|
|
441
|
+
})
|
|
442
|
+
}),
|
|
443
|
+
/* @__PURE__ */ jsx(Section, {
|
|
444
|
+
id: "both-themes",
|
|
445
|
+
title: "In both themes",
|
|
446
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
447
|
+
align: "fill",
|
|
448
|
+
children: /* @__PURE__ */ jsx(OrdersTable, {
|
|
449
|
+
rows: ORDERS.slice(0, 3),
|
|
450
|
+
density: "compact",
|
|
451
|
+
selectable: true
|
|
452
|
+
})
|
|
453
|
+
})
|
|
454
|
+
}),
|
|
455
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
456
|
+
id: "guidelines",
|
|
457
|
+
title: "Guidelines",
|
|
458
|
+
children: [
|
|
459
|
+
/* @__PURE__ */ jsx(DoDont, {
|
|
460
|
+
do: {
|
|
461
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
462
|
+
className: "table-demo__cell-sample",
|
|
463
|
+
children: [
|
|
464
|
+
/* @__PURE__ */ jsx("span", { children: "£1,120.00" }),
|
|
465
|
+
/* @__PURE__ */ jsx("span", { children: "£89.50" }),
|
|
466
|
+
/* @__PURE__ */ jsx("span", { children: "£34.99" })
|
|
467
|
+
]
|
|
468
|
+
}),
|
|
469
|
+
caption: "Money and counts in tabular figures, aligned to the end, so digits line up by place."
|
|
470
|
+
},
|
|
471
|
+
dont: {
|
|
472
|
+
children: /* @__PURE__ */ jsxs("span", {
|
|
473
|
+
className: "table-demo__cell-sample",
|
|
474
|
+
"data-start": "",
|
|
475
|
+
children: [
|
|
476
|
+
/* @__PURE__ */ jsx("span", { children: "£1,120.00" }),
|
|
477
|
+
/* @__PURE__ */ jsx("span", { children: "£89.50" }),
|
|
478
|
+
/* @__PURE__ */ jsx("span", { children: "£34.99" })
|
|
479
|
+
]
|
|
480
|
+
}),
|
|
481
|
+
caption: "Left-aligned amounts make readers hunt for the decimal point."
|
|
482
|
+
}
|
|
483
|
+
}),
|
|
484
|
+
/* @__PURE__ */ jsx(Guidelines, { items: [
|
|
485
|
+
"Lead with the thing people scan for (the order number, the product name) and keep it one line where you can.",
|
|
486
|
+
"Status in words on a badge, never colour alone. Brand teal is not a status colour: it marks selection.",
|
|
487
|
+
"One primary action per page, outside the table. Row actions go in a menu at the end of the row.",
|
|
488
|
+
"Keep headings short and in sentence case; the heading names the column, the cells carry the detail."
|
|
489
|
+
] }),
|
|
490
|
+
/* @__PURE__ */ jsx(Fragment$1, {})
|
|
491
|
+
]
|
|
492
|
+
}),
|
|
493
|
+
/* @__PURE__ */ jsx(Section, {
|
|
494
|
+
id: "accessibility",
|
|
495
|
+
title: "Accessibility",
|
|
496
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
497
|
+
"Real table elements: headers are th with scope=\"col\", so screen readers announce the column for each cell.",
|
|
498
|
+
"Sortable headings are buttons inside the th, and the th carries aria-sort.",
|
|
499
|
+
"A selected row carries aria-selected; every row checkbox names its row (\"Select order #1043\").",
|
|
500
|
+
"A clickable row also has a real link in its first cell, so keyboard users can open it with Tab and Enter."
|
|
501
|
+
] })
|
|
502
|
+
}),
|
|
503
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
504
|
+
id: "props",
|
|
505
|
+
title: "Props",
|
|
506
|
+
description: /* @__PURE__ */ jsx("p", { children: "Every part also accepts the native attributes of its element." }),
|
|
507
|
+
children: [
|
|
508
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
509
|
+
title: "TableFrame",
|
|
510
|
+
rows: [
|
|
511
|
+
{
|
|
512
|
+
name: "height",
|
|
513
|
+
type: "number | string",
|
|
514
|
+
description: "Height of the scroll area. The headings stick while rows scroll."
|
|
515
|
+
},
|
|
516
|
+
{
|
|
517
|
+
name: "footer",
|
|
518
|
+
type: "ReactNode",
|
|
519
|
+
description: "Pinned under the scroll area, e.g. Pagination."
|
|
520
|
+
},
|
|
521
|
+
{
|
|
522
|
+
name: "ref",
|
|
523
|
+
type: "Ref<HTMLDivElement>",
|
|
524
|
+
description: "The scroll area, for virtual rows."
|
|
525
|
+
}
|
|
526
|
+
]
|
|
527
|
+
}),
|
|
528
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
529
|
+
title: "Table",
|
|
530
|
+
rows: [{
|
|
531
|
+
name: "density",
|
|
532
|
+
type: "'comfortable' | 'compact'",
|
|
533
|
+
default: "'comfortable'",
|
|
534
|
+
description: "56 or 44px rows."
|
|
535
|
+
}, {
|
|
536
|
+
name: "layout",
|
|
537
|
+
type: "'auto' | 'fixed'",
|
|
538
|
+
default: "'auto'",
|
|
539
|
+
description: "fixed pins column widths to a colgroup: steady columns under virtual rows."
|
|
540
|
+
}]
|
|
541
|
+
}),
|
|
542
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
543
|
+
title: "TableRow",
|
|
544
|
+
rows: [{
|
|
545
|
+
name: "selected",
|
|
546
|
+
type: "boolean",
|
|
547
|
+
default: "false",
|
|
548
|
+
description: "Teal line and tint; aria-selected."
|
|
549
|
+
}, {
|
|
550
|
+
name: "interactive",
|
|
551
|
+
type: "boolean",
|
|
552
|
+
default: "false",
|
|
553
|
+
description: "Pointer cursor: the row opens something."
|
|
554
|
+
}]
|
|
555
|
+
}),
|
|
556
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
557
|
+
title: "TableHeaderCell and TableCell",
|
|
558
|
+
rows: [
|
|
559
|
+
{
|
|
560
|
+
name: "align",
|
|
561
|
+
type: "'start' | 'center' | 'end'",
|
|
562
|
+
default: "'start'",
|
|
563
|
+
description: "Text alignment."
|
|
564
|
+
},
|
|
565
|
+
{
|
|
566
|
+
name: "sort",
|
|
567
|
+
type: "'ascending' | 'descending' | 'none'",
|
|
568
|
+
description: "Header cell: current sort; sets aria-sort."
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
name: "onSort",
|
|
572
|
+
type: "() => void",
|
|
573
|
+
description: "Header cell: makes the heading a sort button."
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
name: "numeric",
|
|
577
|
+
type: "boolean",
|
|
578
|
+
default: "false",
|
|
579
|
+
description: "Cell: tabular figures, aligned to the end."
|
|
580
|
+
},
|
|
581
|
+
{
|
|
582
|
+
name: "truncate",
|
|
583
|
+
type: "boolean",
|
|
584
|
+
default: "false",
|
|
585
|
+
description: "Cell: one line with an ellipsis (set a column width)."
|
|
586
|
+
}
|
|
587
|
+
]
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ jsx(DocTable, {
|
|
590
|
+
columns: ["Part", "Element"],
|
|
591
|
+
rows: [
|
|
592
|
+
[/* @__PURE__ */ jsx("code", { children: "TableFrame" }), "div (frame) › div (scroll area)"],
|
|
593
|
+
[/* @__PURE__ */ jsx("code", { children: "Table" }), "table"],
|
|
594
|
+
[/* @__PURE__ */ jsx("code", { children: "TableHead" }), "thead"],
|
|
595
|
+
[/* @__PURE__ */ jsx("code", { children: "TableBody" }), "tbody"],
|
|
596
|
+
[/* @__PURE__ */ jsx("code", { children: "TableRow" }), "tr"],
|
|
597
|
+
[/* @__PURE__ */ jsx("code", { children: "TableHeaderCell" }), "th"],
|
|
598
|
+
[/* @__PURE__ */ jsx("code", { children: "TableCell" }), "td"]
|
|
599
|
+
]
|
|
600
|
+
})
|
|
601
|
+
]
|
|
602
|
+
})
|
|
603
|
+
]
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
//#endregion
|
|
607
|
+
export { Page, Preview };
|