@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,1451 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { a as DocTable, d as Section, 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-BNOb7AqR.js";
|
|
3
|
+
import { c as SpecimenFrame, t as DialogSheet } from "./_overlays-specimens-Dpn6oiyH.js";
|
|
4
|
+
import { useRef, useState } from "react";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { Avatar, Badge, Button, ConfirmDialog, Dialog, DialogBody, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, Field, Input, SegmentedControl, Switch } from "@orbitcommerce/constellation";
|
|
7
|
+
import { DownloadSimpleIcon, EnvelopeSimpleIcon, PaperPlaneTiltIcon, SignOutIcon, TrashIcon, UploadSimpleIcon, UserPlusIcon } from "@orbitcommerce/constellation/icons";
|
|
8
|
+
//#region src/pages/components/dialog.tsx
|
|
9
|
+
var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
|
+
/**
|
|
11
|
+
* ConfirmDialog has no trigger of its own, so it cannot hand focus back when it closes. Keep a ref to
|
|
12
|
+
* the button that opened it and focus that once the dialog has let go of focus.
|
|
13
|
+
*/
|
|
14
|
+
function useOpener() {
|
|
15
|
+
const ref = useRef(null);
|
|
16
|
+
const handBack = () => requestAnimationFrame(() => ref.current?.focus());
|
|
17
|
+
return [ref, handBack];
|
|
18
|
+
}
|
|
19
|
+
function Preview() {
|
|
20
|
+
return /* @__PURE__ */ jsxs(DialogSheet, {
|
|
21
|
+
size: "sm",
|
|
22
|
+
width: 224,
|
|
23
|
+
style: {
|
|
24
|
+
"--o-dialog-pad": "16px",
|
|
25
|
+
"--o-dialog-title-fs": "1rem"
|
|
26
|
+
},
|
|
27
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: "o-dialog__header",
|
|
29
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
30
|
+
className: "o-dialog__title",
|
|
31
|
+
children: "Delete 3 products?"
|
|
32
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
33
|
+
className: "o-dialog__description",
|
|
34
|
+
style: { fontSize: "var(--o-text-sm)" },
|
|
35
|
+
children: "They leave your catalogue."
|
|
36
|
+
})]
|
|
37
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: "o-dialog__footer",
|
|
39
|
+
style: {
|
|
40
|
+
marginTop: 14,
|
|
41
|
+
gap: 6
|
|
42
|
+
},
|
|
43
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
44
|
+
size: "xs",
|
|
45
|
+
tabIndex: -1,
|
|
46
|
+
children: "Cancel"
|
|
47
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
48
|
+
size: "xs",
|
|
49
|
+
variant: "critical",
|
|
50
|
+
tabIndex: -1,
|
|
51
|
+
children: "Delete"
|
|
52
|
+
})]
|
|
53
|
+
})]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
var ACCESS_HINT = {
|
|
57
|
+
full: "Everything except billing and store ownership.",
|
|
58
|
+
orders: "Orders, customers and fulfilment. No settings.",
|
|
59
|
+
view: "Can look at everything and change nothing."
|
|
60
|
+
};
|
|
61
|
+
function InviteDialog() {
|
|
62
|
+
const [open, setOpen] = useState(false);
|
|
63
|
+
const [email, setEmail] = useState("");
|
|
64
|
+
const [error, setError] = useState();
|
|
65
|
+
const [access, setAccess] = useState("orders");
|
|
66
|
+
const [sending, setSending] = useState(false);
|
|
67
|
+
const submit = async (event) => {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
const value = email.trim();
|
|
70
|
+
if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) {
|
|
71
|
+
setError(value ? "Enter an email address in the correct format, like name@example.com" : "Enter their email address");
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
setError(void 0);
|
|
75
|
+
setSending(true);
|
|
76
|
+
await wait(1200);
|
|
77
|
+
setSending(false);
|
|
78
|
+
setOpen(false);
|
|
79
|
+
setEmail("");
|
|
80
|
+
};
|
|
81
|
+
return /* @__PURE__ */ jsxs(Dialog, {
|
|
82
|
+
open,
|
|
83
|
+
onOpenChange: (next) => {
|
|
84
|
+
setOpen(next);
|
|
85
|
+
if (!next) setError(void 0);
|
|
86
|
+
},
|
|
87
|
+
children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
88
|
+
asChild: true,
|
|
89
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
90
|
+
variant: "primary",
|
|
91
|
+
icon: /* @__PURE__ */ jsx(UserPlusIcon, {}),
|
|
92
|
+
children: "Invite staff"
|
|
93
|
+
})
|
|
94
|
+
}), /* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs("form", {
|
|
95
|
+
onSubmit: submit,
|
|
96
|
+
noValidate: true,
|
|
97
|
+
style: { display: "contents" },
|
|
98
|
+
children: [
|
|
99
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Invite a staff member" }), /* @__PURE__ */ jsx(DialogDescription, { children: "They get an email with a link to join Harbour Desk Co. Invites run out after 7 days." })] }),
|
|
100
|
+
/* @__PURE__ */ jsxs(DialogBody, {
|
|
101
|
+
className: "dialog-fields",
|
|
102
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
103
|
+
label: "Email address",
|
|
104
|
+
error,
|
|
105
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
106
|
+
type: "email",
|
|
107
|
+
icon: /* @__PURE__ */ jsx(EnvelopeSimpleIcon, {}),
|
|
108
|
+
placeholder: "name@example.com",
|
|
109
|
+
value: email,
|
|
110
|
+
onChange: (e) => {
|
|
111
|
+
setEmail(e.target.value);
|
|
112
|
+
if (error) setError(void 0);
|
|
113
|
+
}
|
|
114
|
+
})
|
|
115
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
116
|
+
className: "dialog-group",
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ jsx("span", {
|
|
119
|
+
className: "dialog-group__label",
|
|
120
|
+
"aria-hidden": "true",
|
|
121
|
+
children: "Access"
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
124
|
+
"aria-label": "Access",
|
|
125
|
+
fullWidth: true,
|
|
126
|
+
value: access,
|
|
127
|
+
onValueChange: setAccess,
|
|
128
|
+
options: [
|
|
129
|
+
{
|
|
130
|
+
value: "full",
|
|
131
|
+
label: "Full access"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
value: "orders",
|
|
135
|
+
label: "Orders only"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
value: "view",
|
|
139
|
+
label: "View only"
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}),
|
|
143
|
+
/* @__PURE__ */ jsx("span", {
|
|
144
|
+
className: "dialog-group__hint",
|
|
145
|
+
children: ACCESS_HINT[access]
|
|
146
|
+
})
|
|
147
|
+
]
|
|
148
|
+
})]
|
|
149
|
+
}),
|
|
150
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
151
|
+
asChild: true,
|
|
152
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Cancel" })
|
|
153
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
154
|
+
type: "submit",
|
|
155
|
+
variant: "primary",
|
|
156
|
+
loading: sending,
|
|
157
|
+
children: "Send invite"
|
|
158
|
+
})] })
|
|
159
|
+
]
|
|
160
|
+
}) })]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function RenameDialog() {
|
|
164
|
+
return /* @__PURE__ */ jsxs(Dialog, { children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
165
|
+
asChild: true,
|
|
166
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Rename collection" })
|
|
167
|
+
}), /* @__PURE__ */ jsxs(DialogContent, {
|
|
168
|
+
size: "sm",
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Rename collection" }), /* @__PURE__ */ jsx(DialogDescription, { children: "The collection's web address stays the same." })] }),
|
|
171
|
+
/* @__PURE__ */ jsx(DialogBody, { children: /* @__PURE__ */ jsx(Field, {
|
|
172
|
+
label: "Name",
|
|
173
|
+
children: /* @__PURE__ */ jsx(Input, { defaultValue: "Home office" })
|
|
174
|
+
}) }),
|
|
175
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
176
|
+
asChild: true,
|
|
177
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Cancel" })
|
|
178
|
+
}), /* @__PURE__ */ jsx(DialogClose, {
|
|
179
|
+
asChild: true,
|
|
180
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
181
|
+
variant: "primary",
|
|
182
|
+
children: "Save"
|
|
183
|
+
})
|
|
184
|
+
})] })
|
|
185
|
+
]
|
|
186
|
+
})] });
|
|
187
|
+
}
|
|
188
|
+
function RateDialog() {
|
|
189
|
+
return /* @__PURE__ */ jsxs(Dialog, { children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
190
|
+
asChild: true,
|
|
191
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Add delivery rate" })
|
|
192
|
+
}), /* @__PURE__ */ jsxs(DialogContent, { children: [
|
|
193
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Add a delivery rate" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Customers in the UK mainland zone see it at checkout." })] }),
|
|
194
|
+
/* @__PURE__ */ jsxs(DialogBody, {
|
|
195
|
+
className: "dialog-fields",
|
|
196
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
197
|
+
label: "Name",
|
|
198
|
+
hint: "Shown at checkout",
|
|
199
|
+
children: /* @__PURE__ */ jsx(Input, { defaultValue: "Next working day" })
|
|
200
|
+
}), /* @__PURE__ */ jsx(Field, {
|
|
201
|
+
label: "Price",
|
|
202
|
+
hint: "Includes VAT at 20%",
|
|
203
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
204
|
+
prefix: "£",
|
|
205
|
+
inputMode: "decimal",
|
|
206
|
+
defaultValue: "7.95"
|
|
207
|
+
})
|
|
208
|
+
})]
|
|
209
|
+
}),
|
|
210
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
211
|
+
asChild: true,
|
|
212
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Cancel" })
|
|
213
|
+
}), /* @__PURE__ */ jsx(DialogClose, {
|
|
214
|
+
asChild: true,
|
|
215
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
216
|
+
variant: "primary",
|
|
217
|
+
children: "Add rate"
|
|
218
|
+
})
|
|
219
|
+
})] })
|
|
220
|
+
] })] });
|
|
221
|
+
}
|
|
222
|
+
function ZoneDialog() {
|
|
223
|
+
return /* @__PURE__ */ jsxs(Dialog, { children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
224
|
+
asChild: true,
|
|
225
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Edit delivery zone" })
|
|
226
|
+
}), /* @__PURE__ */ jsxs(DialogContent, {
|
|
227
|
+
size: "lg",
|
|
228
|
+
children: [
|
|
229
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Edit delivery zone" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Rates for Northern Ireland and the Scottish islands, where carriers charge more." })] }),
|
|
230
|
+
/* @__PURE__ */ jsxs(DialogBody, {
|
|
231
|
+
className: "dialog-fields",
|
|
232
|
+
"data-columns": "2",
|
|
233
|
+
children: [
|
|
234
|
+
/* @__PURE__ */ jsx(Field, {
|
|
235
|
+
label: "Zone name",
|
|
236
|
+
children: /* @__PURE__ */ jsx(Input, { defaultValue: "Highlands, islands and NI" })
|
|
237
|
+
}),
|
|
238
|
+
/* @__PURE__ */ jsx(Field, {
|
|
239
|
+
label: "Postcode areas",
|
|
240
|
+
hint: "Separate them with commas",
|
|
241
|
+
children: /* @__PURE__ */ jsx(Input, { defaultValue: "BT, HS, IV, KW, ZE" })
|
|
242
|
+
}),
|
|
243
|
+
/* @__PURE__ */ jsx(Field, {
|
|
244
|
+
label: "Rate",
|
|
245
|
+
hint: "Includes VAT at 20%",
|
|
246
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
247
|
+
prefix: "£",
|
|
248
|
+
inputMode: "decimal",
|
|
249
|
+
defaultValue: "14.50"
|
|
250
|
+
})
|
|
251
|
+
}),
|
|
252
|
+
/* @__PURE__ */ jsx(Field, {
|
|
253
|
+
label: "Free over",
|
|
254
|
+
hint: "Leave empty for no free delivery",
|
|
255
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
256
|
+
prefix: "£",
|
|
257
|
+
inputMode: "decimal",
|
|
258
|
+
defaultValue: "250.00"
|
|
259
|
+
})
|
|
260
|
+
})
|
|
261
|
+
]
|
|
262
|
+
}),
|
|
263
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
264
|
+
asChild: true,
|
|
265
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Cancel" })
|
|
266
|
+
}), /* @__PURE__ */ jsx(DialogClose, {
|
|
267
|
+
asChild: true,
|
|
268
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
269
|
+
variant: "primary",
|
|
270
|
+
children: "Save zone"
|
|
271
|
+
})
|
|
272
|
+
})] })
|
|
273
|
+
]
|
|
274
|
+
})] });
|
|
275
|
+
}
|
|
276
|
+
var IMPORT = [
|
|
277
|
+
[
|
|
278
|
+
"Arden ergonomic chair",
|
|
279
|
+
"CHR-ARD-01",
|
|
280
|
+
"£229.00",
|
|
281
|
+
"New"
|
|
282
|
+
],
|
|
283
|
+
[
|
|
284
|
+
"Arden chair, headrest",
|
|
285
|
+
"CHR-ARD-02",
|
|
286
|
+
"£259.00",
|
|
287
|
+
"New"
|
|
288
|
+
],
|
|
289
|
+
[
|
|
290
|
+
"Walnut desk riser",
|
|
291
|
+
"DSK-WAL-60",
|
|
292
|
+
"£84.00",
|
|
293
|
+
"Update"
|
|
294
|
+
],
|
|
295
|
+
[
|
|
296
|
+
"Brass desk lamp",
|
|
297
|
+
"LMP-BRS-01",
|
|
298
|
+
"£72.00",
|
|
299
|
+
"Update"
|
|
300
|
+
],
|
|
301
|
+
[
|
|
302
|
+
"Oak monitor shelf",
|
|
303
|
+
"SHF-OAK-80",
|
|
304
|
+
"£96.00",
|
|
305
|
+
"New"
|
|
306
|
+
],
|
|
307
|
+
[
|
|
308
|
+
"Felt desk pad, slate",
|
|
309
|
+
"PAD-FLT-SL",
|
|
310
|
+
"£28.00",
|
|
311
|
+
"New"
|
|
312
|
+
],
|
|
313
|
+
[
|
|
314
|
+
"Felt desk pad, moss",
|
|
315
|
+
"PAD-FLT-MS",
|
|
316
|
+
"£28.00",
|
|
317
|
+
"New"
|
|
318
|
+
],
|
|
319
|
+
[
|
|
320
|
+
"Linen cushion, sage",
|
|
321
|
+
"CSH-LIN-SG",
|
|
322
|
+
"£24.00",
|
|
323
|
+
"Update"
|
|
324
|
+
],
|
|
325
|
+
[
|
|
326
|
+
"Cable tidy tray",
|
|
327
|
+
"CBL-TRY-01",
|
|
328
|
+
"£19.00",
|
|
329
|
+
"New"
|
|
330
|
+
],
|
|
331
|
+
[
|
|
332
|
+
"Sit-stand desk, 140cm",
|
|
333
|
+
"DSK-SIT-140",
|
|
334
|
+
"£449.00",
|
|
335
|
+
"Update"
|
|
336
|
+
],
|
|
337
|
+
[
|
|
338
|
+
"Sit-stand desk, 160cm",
|
|
339
|
+
"DSK-SIT-160",
|
|
340
|
+
"£489.00",
|
|
341
|
+
"Update"
|
|
342
|
+
],
|
|
343
|
+
[
|
|
344
|
+
"Pedestal, three drawers",
|
|
345
|
+
"PED-3DR-01",
|
|
346
|
+
"£179.00",
|
|
347
|
+
"New"
|
|
348
|
+
]
|
|
349
|
+
];
|
|
350
|
+
function ImportDialog() {
|
|
351
|
+
return /* @__PURE__ */ jsxs(Dialog, { children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
352
|
+
asChild: true,
|
|
353
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
354
|
+
icon: /* @__PURE__ */ jsx(UploadSimpleIcon, {}),
|
|
355
|
+
children: "Review import"
|
|
356
|
+
})
|
|
357
|
+
}), /* @__PURE__ */ jsxs(DialogContent, {
|
|
358
|
+
size: "lg",
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Import 12 products from Northgate Supply" }), /* @__PURE__ */ jsx(DialogDescription, { children: "7 are new to your catalogue and 5 update products you already sell." })] }),
|
|
361
|
+
/* @__PURE__ */ jsx(DialogBody, { children: /* @__PURE__ */ jsx("ul", {
|
|
362
|
+
className: "dialog-import",
|
|
363
|
+
children: IMPORT.map(([name, sku, price, kind]) => /* @__PURE__ */ jsxs("li", { children: [
|
|
364
|
+
/* @__PURE__ */ jsx(Avatar, {
|
|
365
|
+
name,
|
|
366
|
+
shape: "square"
|
|
367
|
+
}),
|
|
368
|
+
/* @__PURE__ */ jsxs("span", {
|
|
369
|
+
className: "dialog-import__name",
|
|
370
|
+
children: [/* @__PURE__ */ jsx("span", { children: name }), /* @__PURE__ */ jsx("span", {
|
|
371
|
+
className: "dialog-import__sku",
|
|
372
|
+
children: sku
|
|
373
|
+
})]
|
|
374
|
+
}),
|
|
375
|
+
/* @__PURE__ */ jsx(Badge, {
|
|
376
|
+
tone: kind === "New" ? "accent" : "neutral",
|
|
377
|
+
children: kind
|
|
378
|
+
}),
|
|
379
|
+
/* @__PURE__ */ jsx("span", {
|
|
380
|
+
className: "dialog-import__price",
|
|
381
|
+
children: price
|
|
382
|
+
})
|
|
383
|
+
] }, sku))
|
|
384
|
+
}) }),
|
|
385
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
386
|
+
asChild: true,
|
|
387
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Cancel" })
|
|
388
|
+
}), /* @__PURE__ */ jsx(DialogClose, {
|
|
389
|
+
asChild: true,
|
|
390
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
391
|
+
variant: "primary",
|
|
392
|
+
children: "Import 12 products"
|
|
393
|
+
})
|
|
394
|
+
})] })
|
|
395
|
+
]
|
|
396
|
+
})] });
|
|
397
|
+
}
|
|
398
|
+
function ExportDialog() {
|
|
399
|
+
const [format, setFormat] = useState("csv");
|
|
400
|
+
const [lines, setLines] = useState(true);
|
|
401
|
+
return /* @__PURE__ */ jsxs(Dialog, { children: [/* @__PURE__ */ jsx(DialogTrigger, {
|
|
402
|
+
asChild: true,
|
|
403
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
404
|
+
icon: /* @__PURE__ */ jsx(DownloadSimpleIcon, {}),
|
|
405
|
+
children: "Export orders"
|
|
406
|
+
})
|
|
407
|
+
}), /* @__PURE__ */ jsxs(DialogContent, {
|
|
408
|
+
size: "sm",
|
|
409
|
+
hideClose: true,
|
|
410
|
+
children: [
|
|
411
|
+
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: "Export 318 orders" }), /* @__PURE__ */ jsx(DialogDescription, { children: "Orders from the last 30 days, with the filters you have set." })] }),
|
|
412
|
+
/* @__PURE__ */ jsxs(DialogBody, {
|
|
413
|
+
className: "dialog-fields",
|
|
414
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
415
|
+
className: "dialog-group",
|
|
416
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
417
|
+
className: "dialog-group__label",
|
|
418
|
+
"aria-hidden": "true",
|
|
419
|
+
children: "Format"
|
|
420
|
+
}), /* @__PURE__ */ jsx(SegmentedControl, {
|
|
421
|
+
"aria-label": "Format",
|
|
422
|
+
fullWidth: true,
|
|
423
|
+
value: format,
|
|
424
|
+
onValueChange: setFormat,
|
|
425
|
+
options: [{
|
|
426
|
+
value: "csv",
|
|
427
|
+
label: "CSV"
|
|
428
|
+
}, {
|
|
429
|
+
value: "xlsx",
|
|
430
|
+
label: "Excel"
|
|
431
|
+
}]
|
|
432
|
+
})]
|
|
433
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
434
|
+
label: "One row per line item",
|
|
435
|
+
checked: lines,
|
|
436
|
+
onCheckedChange: setLines
|
|
437
|
+
})]
|
|
438
|
+
}),
|
|
439
|
+
/* @__PURE__ */ jsxs(DialogFooter, { children: [/* @__PURE__ */ jsx(DialogClose, {
|
|
440
|
+
asChild: true,
|
|
441
|
+
children: /* @__PURE__ */ jsx(Button, { children: "Cancel" })
|
|
442
|
+
}), /* @__PURE__ */ jsx(DialogClose, {
|
|
443
|
+
asChild: true,
|
|
444
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
445
|
+
variant: "primary",
|
|
446
|
+
icon: /* @__PURE__ */ jsx(DownloadSimpleIcon, {}),
|
|
447
|
+
children: "Export"
|
|
448
|
+
})
|
|
449
|
+
})] })
|
|
450
|
+
]
|
|
451
|
+
})] });
|
|
452
|
+
}
|
|
453
|
+
function ConfirmTones() {
|
|
454
|
+
const [status, setStatus] = useState("");
|
|
455
|
+
const [deleteOpen, setDeleteOpen] = useState(false);
|
|
456
|
+
const [logOutOpen, setLogOutOpen] = useState(false);
|
|
457
|
+
const [sendOpen, setSendOpen] = useState(false);
|
|
458
|
+
const [deleteRef, deleteBack] = useOpener();
|
|
459
|
+
const [logOutRef, logOutBack] = useOpener();
|
|
460
|
+
const [sendRef, sendBack] = useOpener();
|
|
461
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
462
|
+
/* @__PURE__ */ jsx(Button, {
|
|
463
|
+
ref: deleteRef,
|
|
464
|
+
variant: "critical",
|
|
465
|
+
icon: /* @__PURE__ */ jsx(TrashIcon, {}),
|
|
466
|
+
onClick: () => setDeleteOpen(true),
|
|
467
|
+
children: "Delete 3 products"
|
|
468
|
+
}),
|
|
469
|
+
/* @__PURE__ */ jsx(Button, {
|
|
470
|
+
ref: logOutRef,
|
|
471
|
+
icon: /* @__PURE__ */ jsx(SignOutIcon, {}),
|
|
472
|
+
onClick: () => setLogOutOpen(true),
|
|
473
|
+
children: "Log out"
|
|
474
|
+
}),
|
|
475
|
+
/* @__PURE__ */ jsx(Button, {
|
|
476
|
+
ref: sendRef,
|
|
477
|
+
icon: /* @__PURE__ */ jsx(PaperPlaneTiltIcon, {}),
|
|
478
|
+
onClick: () => setSendOpen(true),
|
|
479
|
+
children: "Send 12 invoices"
|
|
480
|
+
}),
|
|
481
|
+
/* @__PURE__ */ jsx("p", {
|
|
482
|
+
className: "dialog-status",
|
|
483
|
+
"aria-live": "polite",
|
|
484
|
+
children: status
|
|
485
|
+
}),
|
|
486
|
+
/* @__PURE__ */ jsx(ConfirmDialog, {
|
|
487
|
+
open: deleteOpen,
|
|
488
|
+
onOpenChange: (open) => {
|
|
489
|
+
setDeleteOpen(open);
|
|
490
|
+
if (!open) deleteBack();
|
|
491
|
+
},
|
|
492
|
+
tone: "critical",
|
|
493
|
+
title: "Delete 3 products?",
|
|
494
|
+
description: "Arden ergonomic chair, Walnut desk riser and Brass desk lamp leave your catalogue. Past orders keep their line items.",
|
|
495
|
+
confirmLabel: "Delete products",
|
|
496
|
+
onConfirm: () => wait(1400).then(() => setStatus("Deleted 3 products."))
|
|
497
|
+
}),
|
|
498
|
+
/* @__PURE__ */ jsx(ConfirmDialog, {
|
|
499
|
+
open: logOutOpen,
|
|
500
|
+
onOpenChange: (open) => {
|
|
501
|
+
setLogOutOpen(open);
|
|
502
|
+
if (!open) logOutBack();
|
|
503
|
+
},
|
|
504
|
+
tone: "critical",
|
|
505
|
+
title: "Log out of Orbit?",
|
|
506
|
+
description: "You will be signed out of Harbour Desk Co on this device.",
|
|
507
|
+
confirmLabel: "Log out",
|
|
508
|
+
onConfirm: () => wait(900).then(() => setStatus("Logged out. (Not really: this is the docs.)"))
|
|
509
|
+
}),
|
|
510
|
+
/* @__PURE__ */ jsx(ConfirmDialog, {
|
|
511
|
+
open: sendOpen,
|
|
512
|
+
onOpenChange: (open) => {
|
|
513
|
+
setSendOpen(open);
|
|
514
|
+
if (!open) sendBack();
|
|
515
|
+
},
|
|
516
|
+
title: "Send 12 invoices?",
|
|
517
|
+
description: "Each customer gets their invoice by email, as a PDF.",
|
|
518
|
+
confirmLabel: "Send invoices",
|
|
519
|
+
onConfirm: () => setStatus("Sent 12 invoices.")
|
|
520
|
+
})
|
|
521
|
+
] });
|
|
522
|
+
}
|
|
523
|
+
function RefundConfirm() {
|
|
524
|
+
const [open, setOpen] = useState(false);
|
|
525
|
+
const [failed, setFailed] = useState(false);
|
|
526
|
+
const [error, setError] = useState();
|
|
527
|
+
const [done, setDone] = useState("");
|
|
528
|
+
const [opener, handBack] = useOpener();
|
|
529
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
530
|
+
/* @__PURE__ */ jsx(Button, {
|
|
531
|
+
ref: opener,
|
|
532
|
+
onClick: () => {
|
|
533
|
+
setFailed(false);
|
|
534
|
+
setError(void 0);
|
|
535
|
+
setOpen(true);
|
|
536
|
+
},
|
|
537
|
+
children: "Refund £89.50"
|
|
538
|
+
}),
|
|
539
|
+
/* @__PURE__ */ jsx("p", {
|
|
540
|
+
className: "dialog-status",
|
|
541
|
+
"aria-live": "polite",
|
|
542
|
+
children: done
|
|
543
|
+
}),
|
|
544
|
+
/* @__PURE__ */ jsx(ConfirmDialog, {
|
|
545
|
+
open,
|
|
546
|
+
onOpenChange: (next) => {
|
|
547
|
+
setOpen(next);
|
|
548
|
+
if (!next) handBack();
|
|
549
|
+
},
|
|
550
|
+
title: "Refund £89.50 to James Okafor?",
|
|
551
|
+
description: "It goes back on the card he paid with and takes 5 to 10 working days to arrive.",
|
|
552
|
+
confirmLabel: "Refund £89.50",
|
|
553
|
+
onConfirm: async () => {
|
|
554
|
+
setError(void 0);
|
|
555
|
+
await wait(1100);
|
|
556
|
+
if (!failed) {
|
|
557
|
+
setFailed(true);
|
|
558
|
+
setError("The card issuer did not answer, so nothing was refunded. Try again.");
|
|
559
|
+
throw new Error("Refund failed");
|
|
560
|
+
}
|
|
561
|
+
setDone("Refunded £89.50.");
|
|
562
|
+
},
|
|
563
|
+
children: error ? /* @__PURE__ */ jsx("p", {
|
|
564
|
+
className: "dialog-error",
|
|
565
|
+
role: "alert",
|
|
566
|
+
children: error
|
|
567
|
+
}) : void 0
|
|
568
|
+
})
|
|
569
|
+
] });
|
|
570
|
+
}
|
|
571
|
+
function CancelOrderConfirm() {
|
|
572
|
+
const [open, setOpen] = useState(false);
|
|
573
|
+
const [notify, setNotify] = useState(true);
|
|
574
|
+
const [restock, setRestock] = useState(true);
|
|
575
|
+
const [opener, handBack] = useOpener();
|
|
576
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
|
|
577
|
+
ref: opener,
|
|
578
|
+
onClick: () => setOpen(true),
|
|
579
|
+
children: "Cancel order #1042"
|
|
580
|
+
}), /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
581
|
+
open,
|
|
582
|
+
onOpenChange: (next) => {
|
|
583
|
+
setOpen(next);
|
|
584
|
+
if (!next) handBack();
|
|
585
|
+
},
|
|
586
|
+
tone: "critical",
|
|
587
|
+
title: "Cancel order #1042?",
|
|
588
|
+
description: "James Okafor gets £89.50 back on his card.",
|
|
589
|
+
confirmLabel: "Cancel order",
|
|
590
|
+
cancelLabel: "Keep order",
|
|
591
|
+
onConfirm: () => wait(1e3),
|
|
592
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
593
|
+
className: "dialog-switches",
|
|
594
|
+
children: [/* @__PURE__ */ jsx(Switch, {
|
|
595
|
+
label: "Email James to say so",
|
|
596
|
+
checked: notify,
|
|
597
|
+
onCheckedChange: setNotify
|
|
598
|
+
}), /* @__PURE__ */ jsx(Switch, {
|
|
599
|
+
label: "Put the 2 items back in stock",
|
|
600
|
+
checked: restock,
|
|
601
|
+
onCheckedChange: setRestock
|
|
602
|
+
})]
|
|
603
|
+
})
|
|
604
|
+
})] });
|
|
605
|
+
}
|
|
606
|
+
function PublishConfirm() {
|
|
607
|
+
const [open, setOpen] = useState(false);
|
|
608
|
+
const [publishing, setPublishing] = useState(false);
|
|
609
|
+
const [opener, handBack] = useOpener();
|
|
610
|
+
const publish = () => {
|
|
611
|
+
setPublishing(true);
|
|
612
|
+
window.setTimeout(() => {
|
|
613
|
+
setPublishing(false);
|
|
614
|
+
setOpen(false);
|
|
615
|
+
handBack();
|
|
616
|
+
}, 1500);
|
|
617
|
+
};
|
|
618
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
|
|
619
|
+
ref: opener,
|
|
620
|
+
variant: "inverse",
|
|
621
|
+
onClick: () => setOpen(true),
|
|
622
|
+
children: "Publish theme"
|
|
623
|
+
}), /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
624
|
+
open,
|
|
625
|
+
onOpenChange: (next) => {
|
|
626
|
+
setOpen(next);
|
|
627
|
+
if (!next) handBack();
|
|
628
|
+
},
|
|
629
|
+
title: "Publish the Harbour theme?",
|
|
630
|
+
description: "Your store switches to it straight away. You can switch back from Themes at any time.",
|
|
631
|
+
confirmLabel: "Publish theme",
|
|
632
|
+
loading: publishing,
|
|
633
|
+
onConfirm: publish
|
|
634
|
+
})] });
|
|
635
|
+
}
|
|
636
|
+
function StillPage({ children }) {
|
|
637
|
+
return /* @__PURE__ */ jsxs(SpecimenFrame, {
|
|
638
|
+
className: "dialog-still",
|
|
639
|
+
children: [
|
|
640
|
+
/* @__PURE__ */ jsxs("div", {
|
|
641
|
+
className: "dialog-still__page",
|
|
642
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
643
|
+
className: "dialog-still__bar",
|
|
644
|
+
"data-strong": "",
|
|
645
|
+
style: { width: "34%" }
|
|
646
|
+
}), [
|
|
647
|
+
62,
|
|
648
|
+
48,
|
|
649
|
+
55,
|
|
650
|
+
40,
|
|
651
|
+
58
|
|
652
|
+
].map((w, i) => /* @__PURE__ */ jsxs("span", {
|
|
653
|
+
className: "dialog-still__row",
|
|
654
|
+
children: [/* @__PURE__ */ jsx("span", { className: "dialog-still__tile" }), /* @__PURE__ */ jsx("span", {
|
|
655
|
+
className: "dialog-still__bar",
|
|
656
|
+
style: { width: `${w}%` }
|
|
657
|
+
})]
|
|
658
|
+
}, i))]
|
|
659
|
+
}),
|
|
660
|
+
/* @__PURE__ */ jsx("div", { className: "o-dialog-overlay" }),
|
|
661
|
+
children
|
|
662
|
+
]
|
|
663
|
+
});
|
|
664
|
+
}
|
|
665
|
+
function ConfirmStill() {
|
|
666
|
+
return /* @__PURE__ */ jsx(StillPage, { children: /* @__PURE__ */ jsxs(DialogSheet, {
|
|
667
|
+
size: "sm",
|
|
668
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
669
|
+
className: "o-dialog__header",
|
|
670
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
671
|
+
className: "o-dialog__title",
|
|
672
|
+
children: "Delete 3 products?"
|
|
673
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
674
|
+
className: "o-dialog__description",
|
|
675
|
+
children: "Arden ergonomic chair, Walnut desk riser and Brass desk lamp leave your catalogue. Past orders keep their line items."
|
|
676
|
+
})]
|
|
677
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
678
|
+
className: "o-dialog__footer",
|
|
679
|
+
children: [/* @__PURE__ */ jsx(Button, { children: "Cancel" }), /* @__PURE__ */ jsx(Button, {
|
|
680
|
+
variant: "critical",
|
|
681
|
+
children: "Delete products"
|
|
682
|
+
})]
|
|
683
|
+
})]
|
|
684
|
+
}) });
|
|
685
|
+
}
|
|
686
|
+
function FormStill() {
|
|
687
|
+
return /* @__PURE__ */ jsx(StillPage, { children: /* @__PURE__ */ jsxs(DialogSheet, {
|
|
688
|
+
close: true,
|
|
689
|
+
children: [
|
|
690
|
+
/* @__PURE__ */ jsxs("div", {
|
|
691
|
+
className: "o-dialog__header",
|
|
692
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
693
|
+
className: "o-dialog__title",
|
|
694
|
+
children: "Invite a staff member"
|
|
695
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
696
|
+
className: "o-dialog__description",
|
|
697
|
+
children: "They get an email with a link to join Harbour Desk Co. Invites run out after 7 days."
|
|
698
|
+
})]
|
|
699
|
+
}),
|
|
700
|
+
/* @__PURE__ */ jsxs("div", {
|
|
701
|
+
className: "o-dialog__body dialog-fields",
|
|
702
|
+
children: [/* @__PURE__ */ jsx(Field, {
|
|
703
|
+
label: "Email address",
|
|
704
|
+
children: /* @__PURE__ */ jsx(Input, {
|
|
705
|
+
type: "email",
|
|
706
|
+
icon: /* @__PURE__ */ jsx(EnvelopeSimpleIcon, {}),
|
|
707
|
+
defaultValue: "tom.hughes@example.co.uk"
|
|
708
|
+
})
|
|
709
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
710
|
+
className: "dialog-group",
|
|
711
|
+
children: [
|
|
712
|
+
/* @__PURE__ */ jsx("span", {
|
|
713
|
+
className: "dialog-group__label",
|
|
714
|
+
children: "Access"
|
|
715
|
+
}),
|
|
716
|
+
/* @__PURE__ */ jsx(SegmentedControl, {
|
|
717
|
+
"aria-label": "Access",
|
|
718
|
+
fullWidth: true,
|
|
719
|
+
defaultValue: "orders",
|
|
720
|
+
options: [
|
|
721
|
+
{
|
|
722
|
+
value: "full",
|
|
723
|
+
label: "Full access"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
value: "orders",
|
|
727
|
+
label: "Orders only"
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
value: "view",
|
|
731
|
+
label: "View only"
|
|
732
|
+
}
|
|
733
|
+
]
|
|
734
|
+
}),
|
|
735
|
+
/* @__PURE__ */ jsx("span", {
|
|
736
|
+
className: "dialog-group__hint",
|
|
737
|
+
children: ACCESS_HINT.orders
|
|
738
|
+
})
|
|
739
|
+
]
|
|
740
|
+
})]
|
|
741
|
+
}),
|
|
742
|
+
/* @__PURE__ */ jsxs("div", {
|
|
743
|
+
className: "o-dialog__footer",
|
|
744
|
+
children: [/* @__PURE__ */ jsx(Button, { children: "Cancel" }), /* @__PURE__ */ jsx(Button, {
|
|
745
|
+
variant: "primary",
|
|
746
|
+
children: "Send invite"
|
|
747
|
+
})]
|
|
748
|
+
})
|
|
749
|
+
]
|
|
750
|
+
}) });
|
|
751
|
+
}
|
|
752
|
+
function DoDontSheet({ title, description, cancel, confirm }) {
|
|
753
|
+
return /* @__PURE__ */ jsx(SpecimenFrame, {
|
|
754
|
+
style: { width: "100%" },
|
|
755
|
+
children: /* @__PURE__ */ jsxs(DialogSheet, {
|
|
756
|
+
size: "sm",
|
|
757
|
+
width: "100%",
|
|
758
|
+
style: { boxShadow: "var(--o-shadow-2)" },
|
|
759
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
760
|
+
className: "o-dialog__header",
|
|
761
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
762
|
+
className: "o-dialog__title",
|
|
763
|
+
children: title
|
|
764
|
+
}), description ? /* @__PURE__ */ jsx("p", {
|
|
765
|
+
className: "o-dialog__description",
|
|
766
|
+
children: description
|
|
767
|
+
}) : null]
|
|
768
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
769
|
+
className: "o-dialog__footer",
|
|
770
|
+
children: [/* @__PURE__ */ jsx(Button, {
|
|
771
|
+
size: "sm",
|
|
772
|
+
children: cancel
|
|
773
|
+
}), /* @__PURE__ */ jsx(Button, {
|
|
774
|
+
size: "sm",
|
|
775
|
+
variant: "critical",
|
|
776
|
+
children: confirm
|
|
777
|
+
})]
|
|
778
|
+
})]
|
|
779
|
+
})
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
function Page() {
|
|
783
|
+
return /* @__PURE__ */ jsxs(DocPage, {
|
|
784
|
+
title: "Dialog",
|
|
785
|
+
status: "stable",
|
|
786
|
+
importNames: [
|
|
787
|
+
"Dialog",
|
|
788
|
+
"DialogTrigger",
|
|
789
|
+
"DialogContent",
|
|
790
|
+
"DialogHeader",
|
|
791
|
+
"DialogTitle",
|
|
792
|
+
"ConfirmDialog"
|
|
793
|
+
],
|
|
794
|
+
lead: "A focused task over a dimmed, softly blurred page. Reach for it when the merchant has to finish or dismiss something before carrying on: a short form, or a question before an action that matters.",
|
|
795
|
+
children: [
|
|
796
|
+
/* @__PURE__ */ jsx(Section, {
|
|
797
|
+
id: "basics",
|
|
798
|
+
title: "Basics",
|
|
799
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
800
|
+
"A ",
|
|
801
|
+
/* @__PURE__ */ jsx("code", { children: "DialogTrigger" }),
|
|
802
|
+
" opens it and a ",
|
|
803
|
+
/* @__PURE__ */ jsx("code", { children: "DialogContent" }),
|
|
804
|
+
" holds the sheet: a",
|
|
805
|
+
" ",
|
|
806
|
+
/* @__PURE__ */ jsx("code", { children: "DialogHeader" }),
|
|
807
|
+
" with the ",
|
|
808
|
+
/* @__PURE__ */ jsx("code", { children: "DialogTitle" }),
|
|
809
|
+
" and ",
|
|
810
|
+
/* @__PURE__ */ jsx("code", { children: "DialogDescription" }),
|
|
811
|
+
", a",
|
|
812
|
+
" ",
|
|
813
|
+
/* @__PURE__ */ jsx("code", { children: "DialogBody" }),
|
|
814
|
+
", and a ",
|
|
815
|
+
/* @__PURE__ */ jsx("code", { children: "DialogFooter" }),
|
|
816
|
+
" of actions with the primary last. A close button sits in the top right. The sheet rises 10px and settles on the spring; it leaves in half the time."
|
|
817
|
+
] }),
|
|
818
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
819
|
+
code: `
|
|
820
|
+
<Dialog open={open} onOpenChange={setOpen}>
|
|
821
|
+
<DialogTrigger asChild>
|
|
822
|
+
<Button variant="primary" icon={<UserPlusIcon />}>Invite staff</Button>
|
|
823
|
+
</DialogTrigger>
|
|
824
|
+
<DialogContent>
|
|
825
|
+
<form onSubmit={submit} noValidate style={{ display: 'contents' }}>
|
|
826
|
+
<DialogHeader>
|
|
827
|
+
<DialogTitle>Invite a staff member</DialogTitle>
|
|
828
|
+
<DialogDescription>
|
|
829
|
+
They get an email with a link to join Harbour Desk Co. Invites run out after 7 days.
|
|
830
|
+
</DialogDescription>
|
|
831
|
+
</DialogHeader>
|
|
832
|
+
<DialogBody>
|
|
833
|
+
<Field label="Email address" error={error}>
|
|
834
|
+
<Input type="email" icon={<EnvelopeSimpleIcon />} placeholder="name@example.com" … />
|
|
835
|
+
</Field>
|
|
836
|
+
<SegmentedControl aria-label="Access" fullWidth options={access} … />
|
|
837
|
+
</DialogBody>
|
|
838
|
+
<DialogFooter>
|
|
839
|
+
<DialogClose asChild>
|
|
840
|
+
<Button>Cancel</Button>
|
|
841
|
+
</DialogClose>
|
|
842
|
+
<Button type="submit" variant="primary" loading={sending}>Send invite</Button>
|
|
843
|
+
</DialogFooter>
|
|
844
|
+
</form>
|
|
845
|
+
</DialogContent>
|
|
846
|
+
</Dialog>`,
|
|
847
|
+
caption: "Press Send invite with the field empty to see the error, then with an address to see the busy state.",
|
|
848
|
+
children: /* @__PURE__ */ jsx(InviteDialog, {})
|
|
849
|
+
})
|
|
850
|
+
}),
|
|
851
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
852
|
+
id: "both-themes",
|
|
853
|
+
title: "In both themes",
|
|
854
|
+
description: /* @__PURE__ */ jsx("p", { children: "Held open for review, light beside dark. The page behind dims to 34% near-black under a 3px blur (62% in dark), and the sheet has the system's widest corners (20px) on the modal shadow. In dark it lifts to graphite with a faint ring." }),
|
|
855
|
+
children: [
|
|
856
|
+
/* @__PURE__ */ jsx(ThemePair, {
|
|
857
|
+
align: "fill",
|
|
858
|
+
children: /* @__PURE__ */ jsx(ConfirmStill, {})
|
|
859
|
+
}),
|
|
860
|
+
/* @__PURE__ */ jsx("div", {
|
|
861
|
+
className: "overlays-stack",
|
|
862
|
+
children: /* @__PURE__ */ jsx(ThemePair, {
|
|
863
|
+
align: "fill",
|
|
864
|
+
caption: "Stills of the open dialogs, drawn with their own classes so both themes can be compared at once. Every dialog on the rest of this page is live.",
|
|
865
|
+
children: /* @__PURE__ */ jsx(FormStill, {})
|
|
866
|
+
})
|
|
867
|
+
}),
|
|
868
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
869
|
+
title: "Open them for real",
|
|
870
|
+
description: /* @__PURE__ */ jsx("p", { children: "Each trigger opens its dialog in the theme of its own side." }),
|
|
871
|
+
children: /* @__PURE__ */ jsxs(ThemePair, {
|
|
872
|
+
minHeight: 160,
|
|
873
|
+
children: [/* @__PURE__ */ jsx(InviteDialog, {}), /* @__PURE__ */ jsx(ConfirmTonesLite, {})]
|
|
874
|
+
})
|
|
875
|
+
})
|
|
876
|
+
]
|
|
877
|
+
}),
|
|
878
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
879
|
+
id: "sizes",
|
|
880
|
+
title: "Sizes",
|
|
881
|
+
description: /* @__PURE__ */ jsx("p", { children: "Three widths. On a screen narrower than the dialog it keeps 16px clear of each edge, and from 480px down its padding tightens to 20px and the footer stacks full width with the primary on top." }),
|
|
882
|
+
children: [/* @__PURE__ */ jsxs(Example, {
|
|
883
|
+
code: `
|
|
884
|
+
<DialogContent size="sm">…</DialogContent> {/* 400px */}
|
|
885
|
+
<DialogContent>…</DialogContent> {/* 520px, the default */}
|
|
886
|
+
<DialogContent size="lg">…</DialogContent> {/* 720px */}`,
|
|
887
|
+
children: [
|
|
888
|
+
/* @__PURE__ */ jsx(RenameDialog, {}),
|
|
889
|
+
/* @__PURE__ */ jsx(RateDialog, {}),
|
|
890
|
+
/* @__PURE__ */ jsx(ZoneDialog, {})
|
|
891
|
+
]
|
|
892
|
+
}), /* @__PURE__ */ jsx(DocTable, {
|
|
893
|
+
columns: [
|
|
894
|
+
"Size",
|
|
895
|
+
"Width",
|
|
896
|
+
"Use it for"
|
|
897
|
+
],
|
|
898
|
+
rows: [
|
|
899
|
+
[
|
|
900
|
+
/* @__PURE__ */ jsx("code", { children: "sm" }),
|
|
901
|
+
"400px",
|
|
902
|
+
"Confirmations, and forms of one or two fields."
|
|
903
|
+
],
|
|
904
|
+
[
|
|
905
|
+
/* @__PURE__ */ jsx("code", { children: "md" }),
|
|
906
|
+
"520px",
|
|
907
|
+
"Short forms. The default."
|
|
908
|
+
],
|
|
909
|
+
[
|
|
910
|
+
/* @__PURE__ */ jsx("code", { children: "lg" }),
|
|
911
|
+
"720px",
|
|
912
|
+
"Wider content: two columns of fields, a list to review, a small table."
|
|
913
|
+
]
|
|
914
|
+
]
|
|
915
|
+
})]
|
|
916
|
+
}),
|
|
917
|
+
/* @__PURE__ */ jsx(Section, {
|
|
918
|
+
id: "long-content",
|
|
919
|
+
title: "Long content",
|
|
920
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
921
|
+
"The dialog never grows taller than the window less 48px. When its content would, only the",
|
|
922
|
+
" ",
|
|
923
|
+
/* @__PURE__ */ jsx("code", { children: "DialogBody" }),
|
|
924
|
+
" scrolls: the title and the actions stay in view. The body runs to the sheet's edges, so its scrollbar sits at the edge and focus rings inside it are never clipped."
|
|
925
|
+
] }),
|
|
926
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
927
|
+
code: `
|
|
928
|
+
<DialogContent size="lg">
|
|
929
|
+
<DialogHeader>
|
|
930
|
+
<DialogTitle>Import 12 products from Northgate Supply</DialogTitle>
|
|
931
|
+
<DialogDescription>7 are new to your catalogue and 5 update products you already sell.</DialogDescription>
|
|
932
|
+
</DialogHeader>
|
|
933
|
+
<DialogBody>
|
|
934
|
+
<ul>{products.map((p) => <li key={p.sku}>…</li>)}</ul>
|
|
935
|
+
</DialogBody>
|
|
936
|
+
<DialogFooter>
|
|
937
|
+
<DialogClose asChild><Button>Cancel</Button></DialogClose>
|
|
938
|
+
<DialogClose asChild><Button variant="primary">Import 12 products</Button></DialogClose>
|
|
939
|
+
</DialogFooter>
|
|
940
|
+
</DialogContent>`,
|
|
941
|
+
caption: "Make the window short to see the body scroll on its own.",
|
|
942
|
+
children: /* @__PURE__ */ jsx(ImportDialog, {})
|
|
943
|
+
})
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ jsx(Section, {
|
|
946
|
+
id: "without-close",
|
|
947
|
+
title: "Without the close button",
|
|
948
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
949
|
+
/* @__PURE__ */ jsx("code", { children: "hideClose" }),
|
|
950
|
+
" drops the top-right close button when the footer already offers a way out, as a Cancel does. Escape still closes it. ",
|
|
951
|
+
/* @__PURE__ */ jsx("code", { children: "closeLabel" }),
|
|
952
|
+
" renames the close button for screen readers, for example in another language."
|
|
953
|
+
] }),
|
|
954
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
955
|
+
code: `
|
|
956
|
+
<DialogContent size="sm" hideClose>
|
|
957
|
+
<DialogHeader>
|
|
958
|
+
<DialogTitle>Export 318 orders</DialogTitle>
|
|
959
|
+
<DialogDescription>Orders from the last 30 days, with the filters you have set.</DialogDescription>
|
|
960
|
+
</DialogHeader>
|
|
961
|
+
<DialogBody>
|
|
962
|
+
<SegmentedControl aria-label="Format" fullWidth options={formats} … />
|
|
963
|
+
<Switch label="One row per line item" … />
|
|
964
|
+
</DialogBody>
|
|
965
|
+
<DialogFooter>
|
|
966
|
+
<DialogClose asChild><Button>Cancel</Button></DialogClose>
|
|
967
|
+
<DialogClose asChild><Button variant="primary" icon={<DownloadSimpleIcon />}>Export</Button></DialogClose>
|
|
968
|
+
</DialogFooter>
|
|
969
|
+
</DialogContent>`,
|
|
970
|
+
children: /* @__PURE__ */ jsx(ExportDialog, {})
|
|
971
|
+
})
|
|
972
|
+
}),
|
|
973
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
974
|
+
id: "confirm-dialog",
|
|
975
|
+
title: "Confirm dialog",
|
|
976
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
977
|
+
/* @__PURE__ */ jsx("code", { children: "ConfirmDialog" }),
|
|
978
|
+
" asks one question before an action that matters. Give it the question as the",
|
|
979
|
+
" ",
|
|
980
|
+
/* @__PURE__ */ jsx("code", { children: "title" }),
|
|
981
|
+
", what will happen as the ",
|
|
982
|
+
/* @__PURE__ */ jsx("code", { children: "description" }),
|
|
983
|
+
", and the verb as the",
|
|
984
|
+
" ",
|
|
985
|
+
/* @__PURE__ */ jsx("code", { children: "confirmLabel" }),
|
|
986
|
+
". It is an ",
|
|
987
|
+
/* @__PURE__ */ jsx("code", { children: "alertdialog" }),
|
|
988
|
+
": a click outside never closes it."
|
|
989
|
+
] }),
|
|
990
|
+
children: [
|
|
991
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
992
|
+
title: "Tones",
|
|
993
|
+
description: /* @__PURE__ */ jsxs("p", { children: [/* @__PURE__ */ jsx("code", { children: "tone=\"critical\"" }), " is for actions that destroy something or sign out: the confirm pill turns red and first focus goes to Cancel, so Enter cannot destroy anything by accident. Without a tone the confirm pill is primary and takes first focus."] }),
|
|
994
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
995
|
+
code: `
|
|
996
|
+
const [open, setOpen] = useState(false)
|
|
997
|
+
const opener = useRef<HTMLButtonElement>(null)
|
|
998
|
+
|
|
999
|
+
<Button ref={opener} variant="critical" icon={<TrashIcon />} onClick={() => setOpen(true)}>
|
|
1000
|
+
Delete 3 products
|
|
1001
|
+
</Button>
|
|
1002
|
+
<ConfirmDialog
|
|
1003
|
+
open={open}
|
|
1004
|
+
onOpenChange={(next) => {
|
|
1005
|
+
setOpen(next)
|
|
1006
|
+
if (!next) requestAnimationFrame(() => opener.current?.focus())
|
|
1007
|
+
}}
|
|
1008
|
+
tone="critical"
|
|
1009
|
+
title="Delete 3 products?"
|
|
1010
|
+
description="Arden ergonomic chair, Walnut desk riser and Brass desk lamp leave your catalogue. Past orders keep their line items."
|
|
1011
|
+
confirmLabel="Delete products"
|
|
1012
|
+
onConfirm={() => deleteProducts(ids)}
|
|
1013
|
+
/>
|
|
1014
|
+
|
|
1015
|
+
<ConfirmDialog
|
|
1016
|
+
title="Send 12 invoices?"
|
|
1017
|
+
description="Each customer gets their invoice by email, as a PDF."
|
|
1018
|
+
confirmLabel="Send invoices"
|
|
1019
|
+
onConfirm={sendInvoices}
|
|
1020
|
+
…
|
|
1021
|
+
/>`,
|
|
1022
|
+
children: /* @__PURE__ */ jsx(ConfirmTones, {})
|
|
1023
|
+
})
|
|
1024
|
+
}),
|
|
1025
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
1026
|
+
title: "Waiting for the work",
|
|
1027
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1028
|
+
"Return a promise from ",
|
|
1029
|
+
/* @__PURE__ */ jsx("code", { children: "onConfirm" }),
|
|
1030
|
+
" and the dialog waits for it: the comet stays in orbit round the confirm pill, Cancel is off, and Escape does nothing until the work is done. It closes when the promise resolves and stays open when it rejects, so you can say what went wrong in its ",
|
|
1031
|
+
/* @__PURE__ */ jsx("code", { children: "children" }),
|
|
1032
|
+
". This refund fails the first time."
|
|
1033
|
+
] }),
|
|
1034
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
1035
|
+
code: `
|
|
1036
|
+
<ConfirmDialog
|
|
1037
|
+
open={open}
|
|
1038
|
+
onOpenChange={…}
|
|
1039
|
+
title="Refund £89.50 to James Okafor?"
|
|
1040
|
+
description="It goes back on the card he paid with and takes 5 to 10 working days to arrive."
|
|
1041
|
+
confirmLabel="Refund £89.50"
|
|
1042
|
+
onConfirm={async () => {
|
|
1043
|
+
setError(undefined)
|
|
1044
|
+
try {
|
|
1045
|
+
await refund(order)
|
|
1046
|
+
} catch (err) {
|
|
1047
|
+
setError('The card issuer did not answer, so nothing was refunded. Try again.')
|
|
1048
|
+
throw err // keeps the dialog open
|
|
1049
|
+
}
|
|
1050
|
+
}}
|
|
1051
|
+
>
|
|
1052
|
+
{error ? <p role="alert">{error}</p> : null}
|
|
1053
|
+
</ConfirmDialog>`,
|
|
1054
|
+
children: /* @__PURE__ */ jsx(RefundConfirm, {})
|
|
1055
|
+
})
|
|
1056
|
+
}),
|
|
1057
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
1058
|
+
title: "Extra content",
|
|
1059
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1060
|
+
"Anything passed as ",
|
|
1061
|
+
/* @__PURE__ */ jsx("code", { children: "children" }),
|
|
1062
|
+
" sits between the description and the actions: options that go with the action, or an error."
|
|
1063
|
+
] }),
|
|
1064
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
1065
|
+
code: `
|
|
1066
|
+
<ConfirmDialog
|
|
1067
|
+
tone="critical"
|
|
1068
|
+
title="Cancel order #1042?"
|
|
1069
|
+
description="James Okafor gets £89.50 back on his card."
|
|
1070
|
+
confirmLabel="Cancel order"
|
|
1071
|
+
cancelLabel="Keep order"
|
|
1072
|
+
onConfirm={cancelOrder}
|
|
1073
|
+
…
|
|
1074
|
+
>
|
|
1075
|
+
<Switch label="Email James to say so" checked={notify} onCheckedChange={setNotify} />
|
|
1076
|
+
<Switch label="Put the 2 items back in stock" checked={restock} onCheckedChange={setRestock} />
|
|
1077
|
+
</ConfirmDialog>`,
|
|
1078
|
+
children: /* @__PURE__ */ jsx(CancelOrderConfirm, {})
|
|
1079
|
+
})
|
|
1080
|
+
}),
|
|
1081
|
+
/* @__PURE__ */ jsx(SubSection, {
|
|
1082
|
+
title: "Managing the busy state yourself",
|
|
1083
|
+
description: /* @__PURE__ */ jsxs("p", { children: [
|
|
1084
|
+
"Pass ",
|
|
1085
|
+
/* @__PURE__ */ jsx("code", { children: "loading" }),
|
|
1086
|
+
" when the work is tracked somewhere else, such as a mutation. The dialog then shows the busy state while ",
|
|
1087
|
+
/* @__PURE__ */ jsx("code", { children: "loading" }),
|
|
1088
|
+
" is true and leaves closing to you."
|
|
1089
|
+
] }),
|
|
1090
|
+
children: /* @__PURE__ */ jsx(Example, {
|
|
1091
|
+
code: `
|
|
1092
|
+
const publish = useMutation({ mutationFn: publishTheme, onSuccess: () => setOpen(false) })
|
|
1093
|
+
|
|
1094
|
+
<ConfirmDialog
|
|
1095
|
+
open={open}
|
|
1096
|
+
onOpenChange={…}
|
|
1097
|
+
title="Publish the Harbour theme?"
|
|
1098
|
+
description="Your store switches to it straight away. You can switch back from Themes at any time."
|
|
1099
|
+
confirmLabel="Publish theme"
|
|
1100
|
+
loading={publish.isPending}
|
|
1101
|
+
onConfirm={() => publish.mutate()}
|
|
1102
|
+
/>`,
|
|
1103
|
+
children: /* @__PURE__ */ jsx(PublishConfirm, {})
|
|
1104
|
+
})
|
|
1105
|
+
})
|
|
1106
|
+
]
|
|
1107
|
+
}),
|
|
1108
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
1109
|
+
id: "focus",
|
|
1110
|
+
title: "Focus and Escape",
|
|
1111
|
+
description: /* @__PURE__ */ jsx("p", { children: "What happens to focus, the keyboard and the page behind, from opening to closing." }),
|
|
1112
|
+
children: [/* @__PURE__ */ jsx(DocTable, {
|
|
1113
|
+
columns: [
|
|
1114
|
+
"",
|
|
1115
|
+
"Dialog",
|
|
1116
|
+
"ConfirmDialog"
|
|
1117
|
+
],
|
|
1118
|
+
rows: [
|
|
1119
|
+
[
|
|
1120
|
+
"Opening",
|
|
1121
|
+
"Focus moves to the first thing in the sheet that takes focus. The close button comes last in the page order, so it lands on your content: the email field above.",
|
|
1122
|
+
"Focus goes to Cancel when the tone is critical, otherwise to the confirm button."
|
|
1123
|
+
],
|
|
1124
|
+
[
|
|
1125
|
+
"Tab",
|
|
1126
|
+
"Moves through the dialog and wraps round. It never reaches the page behind.",
|
|
1127
|
+
"The same."
|
|
1128
|
+
],
|
|
1129
|
+
[
|
|
1130
|
+
"Escape",
|
|
1131
|
+
"Closes it.",
|
|
1132
|
+
"Closes it, except while the work is running."
|
|
1133
|
+
],
|
|
1134
|
+
[
|
|
1135
|
+
"Click on the dimmed page",
|
|
1136
|
+
"Closes it.",
|
|
1137
|
+
"Does nothing."
|
|
1138
|
+
],
|
|
1139
|
+
[
|
|
1140
|
+
"Closing",
|
|
1141
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1142
|
+
"Focus goes back to the ",
|
|
1143
|
+
/* @__PURE__ */ jsx("code", { children: "DialogTrigger" }),
|
|
1144
|
+
". Opened some other way, hand it back yourself with",
|
|
1145
|
+
" ",
|
|
1146
|
+
/* @__PURE__ */ jsx("code", { children: "onCloseAutoFocus" }),
|
|
1147
|
+
"."
|
|
1148
|
+
] }),
|
|
1149
|
+
"It has no trigger of its own, so hand focus back to the button that opened it (see below)."
|
|
1150
|
+
],
|
|
1151
|
+
[
|
|
1152
|
+
"While open",
|
|
1153
|
+
"The page behind cannot scroll and is hidden from screen readers.",
|
|
1154
|
+
"The same."
|
|
1155
|
+
]
|
|
1156
|
+
]
|
|
1157
|
+
}), /* @__PURE__ */ jsxs(Note, {
|
|
1158
|
+
title: "Handing focus back",
|
|
1159
|
+
children: [
|
|
1160
|
+
"Radix returns focus only to its own ",
|
|
1161
|
+
/* @__PURE__ */ jsx("code", { children: "DialogTrigger" }),
|
|
1162
|
+
". A ",
|
|
1163
|
+
/* @__PURE__ */ jsx("code", { children: "ConfirmDialog" }),
|
|
1164
|
+
", or a dialog opened from a menu row, has none, so on closing focus would fall to the top of the page. Keep a ref to the button that opened it and focus it once the dialog has closed:",
|
|
1165
|
+
" ",
|
|
1166
|
+
/* @__PURE__ */ jsx("code", { children: "if (!open) requestAnimationFrame(() => opener.current?.focus())" }),
|
|
1167
|
+
" in ",
|
|
1168
|
+
/* @__PURE__ */ jsx("code", { children: "onOpenChange" }),
|
|
1169
|
+
", as every example on this page does."
|
|
1170
|
+
]
|
|
1171
|
+
})]
|
|
1172
|
+
}),
|
|
1173
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
1174
|
+
id: "guidelines",
|
|
1175
|
+
title: "Guidelines",
|
|
1176
|
+
children: [/* @__PURE__ */ jsx(DoDont, {
|
|
1177
|
+
do: {
|
|
1178
|
+
children: /* @__PURE__ */ jsx(DoDontSheet, {
|
|
1179
|
+
title: "Delete 3 products?",
|
|
1180
|
+
description: "They leave your catalogue. Past orders keep their line items.",
|
|
1181
|
+
cancel: "Cancel",
|
|
1182
|
+
confirm: "Delete products"
|
|
1183
|
+
}),
|
|
1184
|
+
caption: "Ask the real question, say what will happen, and name the action on the button."
|
|
1185
|
+
},
|
|
1186
|
+
dont: {
|
|
1187
|
+
children: /* @__PURE__ */ jsx(DoDontSheet, {
|
|
1188
|
+
title: "Are you sure?",
|
|
1189
|
+
cancel: "No",
|
|
1190
|
+
confirm: "OK"
|
|
1191
|
+
}),
|
|
1192
|
+
caption: "\"Are you sure?\" and \"OK\" make people read the page behind to find out what they are agreeing to."
|
|
1193
|
+
}
|
|
1194
|
+
}), /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1195
|
+
"Title it with the task (\"Invite a staff member\") or the question (\"Delete 3 products?\"), never \"Confirm\" or \"Warning\".",
|
|
1196
|
+
"Keep the name of the action from the button that opened it to the button that confirms it: Delete 3 products, then Delete products.",
|
|
1197
|
+
"One primary, last in the footer. Use critical only for actions that destroy something or sign out.",
|
|
1198
|
+
"Keep dialogs short. A form that needs a scroll bar or more than a handful of fields wants its own page.",
|
|
1199
|
+
"Never open one dialog on top of another, and never open one on page load.",
|
|
1200
|
+
"After an action that is not reversible, confirm it happened with a quiet message on the page, not another dialog."
|
|
1201
|
+
] })]
|
|
1202
|
+
}),
|
|
1203
|
+
/* @__PURE__ */ jsx(Section, {
|
|
1204
|
+
id: "accessibility",
|
|
1205
|
+
title: "Accessibility",
|
|
1206
|
+
children: /* @__PURE__ */ jsx(Guidelines, { items: [
|
|
1207
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1208
|
+
"Built on Radix Dialog. ",
|
|
1209
|
+
/* @__PURE__ */ jsx("code", { children: "DialogContent" }),
|
|
1210
|
+
" is a ",
|
|
1211
|
+
/* @__PURE__ */ jsx("code", { children: "dialog" }),
|
|
1212
|
+
" named by its",
|
|
1213
|
+
" ",
|
|
1214
|
+
/* @__PURE__ */ jsx("code", { children: "DialogTitle" }),
|
|
1215
|
+
" and described by its ",
|
|
1216
|
+
/* @__PURE__ */ jsx("code", { children: "DialogDescription" }),
|
|
1217
|
+
"; ",
|
|
1218
|
+
/* @__PURE__ */ jsx("code", { children: "ConfirmDialog" }),
|
|
1219
|
+
" is an ",
|
|
1220
|
+
/* @__PURE__ */ jsx("code", { children: "alertdialog" }),
|
|
1221
|
+
"."
|
|
1222
|
+
] }),
|
|
1223
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1224
|
+
"Every dialog needs a ",
|
|
1225
|
+
/* @__PURE__ */ jsx("code", { children: "DialogTitle" }),
|
|
1226
|
+
". Give it a ",
|
|
1227
|
+
/* @__PURE__ */ jsx("code", { children: "DialogDescription" }),
|
|
1228
|
+
" too, or pass",
|
|
1229
|
+
" ",
|
|
1230
|
+
/* @__PURE__ */ jsx("code", { children: "aria-describedby={undefined}" }),
|
|
1231
|
+
" to ",
|
|
1232
|
+
/* @__PURE__ */ jsx("code", { children: "DialogContent" }),
|
|
1233
|
+
": Radix warns in development when neither is there. Always give a ",
|
|
1234
|
+
/* @__PURE__ */ jsx("code", { children: "ConfirmDialog" }),
|
|
1235
|
+
" a ",
|
|
1236
|
+
/* @__PURE__ */ jsx("code", { children: "description" }),
|
|
1237
|
+
" for the same reason."
|
|
1238
|
+
] }),
|
|
1239
|
+
"Focus is trapped inside while it is open, the page behind cannot scroll, and the rest of the page is hidden from screen readers.",
|
|
1240
|
+
/* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1241
|
+
"The close button is named \"Close\" (",
|
|
1242
|
+
/* @__PURE__ */ jsx("code", { children: "closeLabel" }),
|
|
1243
|
+
" changes it) and comes last in the page order."
|
|
1244
|
+
] }),
|
|
1245
|
+
"While a ConfirmDialog is busy its confirm pill says so (aria-busy) and keeps focus inside the dialog.",
|
|
1246
|
+
"With reduced motion the sheet fades in and out without rising or scaling."
|
|
1247
|
+
] })
|
|
1248
|
+
}),
|
|
1249
|
+
/* @__PURE__ */ jsxs(Section, {
|
|
1250
|
+
id: "props",
|
|
1251
|
+
title: "Props",
|
|
1252
|
+
description: /* @__PURE__ */ jsx("p", { children: "The parts also accept the matching Radix Dialog props." }),
|
|
1253
|
+
children: [
|
|
1254
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1255
|
+
title: "Dialog",
|
|
1256
|
+
rows: [
|
|
1257
|
+
{
|
|
1258
|
+
name: "open",
|
|
1259
|
+
type: "boolean",
|
|
1260
|
+
description: "Controlled open state."
|
|
1261
|
+
},
|
|
1262
|
+
{
|
|
1263
|
+
name: "defaultOpen",
|
|
1264
|
+
type: "boolean",
|
|
1265
|
+
default: "false",
|
|
1266
|
+
description: "Starting state when uncontrolled."
|
|
1267
|
+
},
|
|
1268
|
+
{
|
|
1269
|
+
name: "onOpenChange",
|
|
1270
|
+
type: "(open: boolean) => void",
|
|
1271
|
+
description: "Called when it opens or closes."
|
|
1272
|
+
},
|
|
1273
|
+
{
|
|
1274
|
+
name: "modal",
|
|
1275
|
+
type: "boolean",
|
|
1276
|
+
default: "true",
|
|
1277
|
+
description: "Trap focus, lock scrolling and hide the page behind while open."
|
|
1278
|
+
}
|
|
1279
|
+
]
|
|
1280
|
+
}),
|
|
1281
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1282
|
+
title: "DialogTrigger, DialogClose",
|
|
1283
|
+
rows: [{
|
|
1284
|
+
name: "asChild",
|
|
1285
|
+
type: "boolean",
|
|
1286
|
+
default: "false",
|
|
1287
|
+
description: "Render your Button as the trigger or the close control."
|
|
1288
|
+
}]
|
|
1289
|
+
}),
|
|
1290
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1291
|
+
title: "DialogContent",
|
|
1292
|
+
rows: [
|
|
1293
|
+
{
|
|
1294
|
+
name: "size",
|
|
1295
|
+
type: "'sm' | 'md' | 'lg'",
|
|
1296
|
+
default: "'md'",
|
|
1297
|
+
description: "400px for confirmations, 520px for short forms, 720px for wider content."
|
|
1298
|
+
},
|
|
1299
|
+
{
|
|
1300
|
+
name: "hideClose",
|
|
1301
|
+
type: "boolean",
|
|
1302
|
+
default: "false",
|
|
1303
|
+
description: "Drop the top-right close button when the footer already offers a way out."
|
|
1304
|
+
},
|
|
1305
|
+
{
|
|
1306
|
+
name: "closeLabel",
|
|
1307
|
+
type: "string",
|
|
1308
|
+
default: "'Close'",
|
|
1309
|
+
description: "Accessible name of the close button."
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
name: "container",
|
|
1313
|
+
type: "HTMLElement | null",
|
|
1314
|
+
default: "document.body",
|
|
1315
|
+
description: "Where the dialog is portalled."
|
|
1316
|
+
},
|
|
1317
|
+
{
|
|
1318
|
+
name: "onOpenAutoFocus",
|
|
1319
|
+
type: "(event: Event) => void",
|
|
1320
|
+
description: "Runs as focus moves in. Prevent it and focus something yourself."
|
|
1321
|
+
},
|
|
1322
|
+
{
|
|
1323
|
+
name: "onCloseAutoFocus",
|
|
1324
|
+
type: "(event: Event) => void",
|
|
1325
|
+
description: "Runs as focus leaves. Prevent it to send focus somewhere other than the trigger."
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
name: "onEscapeKeyDown",
|
|
1329
|
+
type: "(event: KeyboardEvent) => void",
|
|
1330
|
+
description: "Prevent it to keep the dialog open on Escape."
|
|
1331
|
+
},
|
|
1332
|
+
{
|
|
1333
|
+
name: "onPointerDownOutside",
|
|
1334
|
+
type: "(event: Event) => void",
|
|
1335
|
+
description: "Prevent it to keep the dialog open on a click outside."
|
|
1336
|
+
}
|
|
1337
|
+
]
|
|
1338
|
+
}),
|
|
1339
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1340
|
+
title: "DialogHeader, DialogBody, DialogFooter",
|
|
1341
|
+
rows: [{
|
|
1342
|
+
name: "children",
|
|
1343
|
+
type: "ReactNode",
|
|
1344
|
+
description: "Header: title and description, stacked. Body: scrolls on its own when the dialog meets the window. Footer: actions, right-aligned, primary last. Each accepts every div attribute."
|
|
1345
|
+
}]
|
|
1346
|
+
}),
|
|
1347
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1348
|
+
title: "DialogTitle, DialogDescription",
|
|
1349
|
+
rows: [{
|
|
1350
|
+
name: "children",
|
|
1351
|
+
type: "ReactNode",
|
|
1352
|
+
required: true,
|
|
1353
|
+
description: "Title: the task or question, set in Sora. Description: one or two sentences of context."
|
|
1354
|
+
}, {
|
|
1355
|
+
name: "asChild",
|
|
1356
|
+
type: "boolean",
|
|
1357
|
+
default: "false",
|
|
1358
|
+
description: "Render your own heading or paragraph element."
|
|
1359
|
+
}]
|
|
1360
|
+
}),
|
|
1361
|
+
/* @__PURE__ */ jsx(PropsTable, {
|
|
1362
|
+
title: "ConfirmDialog",
|
|
1363
|
+
rows: [
|
|
1364
|
+
{
|
|
1365
|
+
name: "open",
|
|
1366
|
+
type: "boolean",
|
|
1367
|
+
required: true,
|
|
1368
|
+
description: "Controlled open state."
|
|
1369
|
+
},
|
|
1370
|
+
{
|
|
1371
|
+
name: "onOpenChange",
|
|
1372
|
+
type: "(open: boolean) => void",
|
|
1373
|
+
required: true,
|
|
1374
|
+
description: "Called when it asks to open or close. Ignored while busy."
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
name: "title",
|
|
1378
|
+
type: "ReactNode",
|
|
1379
|
+
required: true,
|
|
1380
|
+
description: "The question, e.g. \"Log out of Orbit?\"."
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
name: "description",
|
|
1384
|
+
type: "ReactNode",
|
|
1385
|
+
description: "What happens if they confirm, in a sentence or two."
|
|
1386
|
+
},
|
|
1387
|
+
{
|
|
1388
|
+
name: "confirmLabel",
|
|
1389
|
+
type: "ReactNode",
|
|
1390
|
+
required: true,
|
|
1391
|
+
description: "The verb that confirms, e.g. \"Delete products\". Never just \"OK\"."
|
|
1392
|
+
},
|
|
1393
|
+
{
|
|
1394
|
+
name: "cancelLabel",
|
|
1395
|
+
type: "ReactNode",
|
|
1396
|
+
default: "'Cancel'",
|
|
1397
|
+
description: "The way out. Change it when \"Cancel\" would be ambiguous, e.g. \"Keep order\"."
|
|
1398
|
+
},
|
|
1399
|
+
{
|
|
1400
|
+
name: "tone",
|
|
1401
|
+
type: "'critical'",
|
|
1402
|
+
description: "Red confirm pill, and first focus on Cancel."
|
|
1403
|
+
},
|
|
1404
|
+
{
|
|
1405
|
+
name: "onConfirm",
|
|
1406
|
+
type: "() => void | Promise<unknown>",
|
|
1407
|
+
required: true,
|
|
1408
|
+
description: "Runs on confirm. Return a promise to show the busy state: it closes when it resolves and stays open when it rejects. Return nothing and it closes straight away, unless you control loading."
|
|
1409
|
+
},
|
|
1410
|
+
{
|
|
1411
|
+
name: "loading",
|
|
1412
|
+
type: "boolean",
|
|
1413
|
+
description: "Controls the busy state yourself. You then close the dialog."
|
|
1414
|
+
},
|
|
1415
|
+
{
|
|
1416
|
+
name: "children",
|
|
1417
|
+
type: "ReactNode",
|
|
1418
|
+
description: "Extra content between the description and the actions."
|
|
1419
|
+
}
|
|
1420
|
+
]
|
|
1421
|
+
})
|
|
1422
|
+
]
|
|
1423
|
+
})
|
|
1424
|
+
]
|
|
1425
|
+
});
|
|
1426
|
+
}
|
|
1427
|
+
/** The critical confirmation on its own, for the side-by-side live pair. */
|
|
1428
|
+
function ConfirmTonesLite() {
|
|
1429
|
+
const [open, setOpen] = useState(false);
|
|
1430
|
+
const [opener, handBack] = useOpener();
|
|
1431
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Button, {
|
|
1432
|
+
ref: opener,
|
|
1433
|
+
variant: "critical",
|
|
1434
|
+
icon: /* @__PURE__ */ jsx(TrashIcon, {}),
|
|
1435
|
+
onClick: () => setOpen(true),
|
|
1436
|
+
children: "Delete 3 products"
|
|
1437
|
+
}), /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
1438
|
+
open,
|
|
1439
|
+
onOpenChange: (next) => {
|
|
1440
|
+
setOpen(next);
|
|
1441
|
+
if (!next) handBack();
|
|
1442
|
+
},
|
|
1443
|
+
tone: "critical",
|
|
1444
|
+
title: "Delete 3 products?",
|
|
1445
|
+
description: "Arden ergonomic chair, Walnut desk riser and Brass desk lamp leave your catalogue. Past orders keep their line items.",
|
|
1446
|
+
confirmLabel: "Delete products",
|
|
1447
|
+
onConfirm: () => wait(1400)
|
|
1448
|
+
})] });
|
|
1449
|
+
}
|
|
1450
|
+
//#endregion
|
|
1451
|
+
export { Page, Preview };
|