oneslash-design-system 2.14.2 → 2.16.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/README.md +15 -0
- package/dist/DESIGN.md +138 -1
- package/dist/cases/accept-invite/signed-in.d.ts +1 -0
- package/dist/cases/accept-invite/signed-in.jsx +57 -0
- package/dist/cases/accept-invite/signed-out.d.ts +1 -0
- package/dist/cases/accept-invite/signed-out.jsx +33 -0
- package/dist/cases/accept-invite.md +161 -0
- package/dist/cases/agent-asks-before-risky-action.md +29 -0
- package/dist/cases/agent-cancels-when-unanswered.md +27 -0
- package/dist/cases/agent-refuses-clearly.md +31 -0
- package/dist/cases/agent-says-what-it-is.md +29 -0
- package/dist/cases/agent-shows-progress.md +30 -0
- package/dist/cases/agent-shows-sources.md +26 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner-with-line.jsx +10 -0
- package/dist/cases/auth-gate-loading/spinner.d.ts +1 -0
- package/dist/cases/auth-gate-loading/spinner.jsx +10 -0
- package/dist/cases/auth-gate-loading.md +70 -0
- package/dist/cases/check-your-email/alert-on-login.d.ts +1 -0
- package/dist/cases/check-your-email/alert-on-login.jsx +78 -0
- package/dist/cases/check-your-email/page.d.ts +1 -0
- package/dist/cases/check-your-email/page.jsx +49 -0
- package/dist/cases/check-your-email.md +184 -0
- package/dist/cases/confirm-destructive-action/inline.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/inline.jsx +69 -0
- package/dist/cases/confirm-destructive-action/modal.d.ts +1 -0
- package/dist/cases/confirm-destructive-action/modal.jsx +66 -0
- package/dist/cases/confirm-destructive-action.md +211 -0
- package/dist/cases/confirm-dialogs.md +36 -0
- package/dist/cases/create-modal/quick.d.ts +1 -0
- package/dist/cases/create-modal/quick.jsx +80 -0
- package/dist/cases/create-modal/with-settings.d.ts +1 -0
- package/dist/cases/create-modal/with-settings.jsx +99 -0
- package/dist/cases/create-modal.md +244 -0
- package/dist/cases/device-login/popup.d.ts +1 -0
- package/dist/cases/device-login/popup.jsx +14 -0
- package/dist/cases/device-login/provider-first.d.ts +1 -0
- package/dist/cases/device-login/provider-first.jsx +98 -0
- package/dist/cases/device-login.md +171 -0
- package/dist/cases/email-confirmed/alert-on-login.d.ts +1 -0
- package/dist/cases/email-confirmed/alert-on-login.jsx +78 -0
- package/dist/cases/email-confirmed/page.d.ts +1 -0
- package/dist/cases/email-confirmed/page.jsx +21 -0
- package/dist/cases/email-confirmed.md +151 -0
- package/dist/cases/empty-list/region.d.ts +1 -0
- package/dist/cases/empty-list/region.jsx +13 -0
- package/dist/cases/empty-list/section.d.ts +1 -0
- package/dist/cases/empty-list/section.jsx +17 -0
- package/dist/cases/empty-list.md +77 -0
- package/dist/cases/empty-lists.md +35 -0
- package/dist/cases/empty-not-set-up/action.d.ts +1 -0
- package/dist/cases/empty-not-set-up/action.jsx +16 -0
- package/dist/cases/empty-not-set-up/pointer.d.ts +1 -0
- package/dist/cases/empty-not-set-up/pointer.jsx +13 -0
- package/dist/cases/empty-not-set-up.md +88 -0
- package/dist/cases/empty-search/clear-search.d.ts +1 -0
- package/dist/cases/empty-search/clear-search.jsx +29 -0
- package/dist/cases/empty-search.md +77 -0
- package/dist/cases/error-page/full-page.d.ts +1 -0
- package/dist/cases/error-page/full-page.jsx +19 -0
- package/dist/cases/error-page/in-shell.d.ts +1 -0
- package/dist/cases/error-page/in-shell.jsx +39 -0
- package/dist/cases/error-page.md +107 -0
- package/dist/cases/feedback-form/modal.d.ts +1 -0
- package/dist/cases/feedback-form/modal.jsx +89 -0
- package/dist/cases/feedback-form.md +139 -0
- package/dist/cases/forgot-password/in-place.d.ts +1 -0
- package/dist/cases/forgot-password/in-place.jsx +155 -0
- package/dist/cases/forgot-password/own-page.d.ts +1 -0
- package/dist/cases/forgot-password/own-page.jsx +99 -0
- package/dist/cases/forgot-password.md +328 -0
- package/dist/cases/form-errors.md +32 -0
- package/dist/cases/import-checklist/modal.d.ts +1 -0
- package/dist/cases/import-checklist/modal.jsx +125 -0
- package/dist/cases/import-checklist.md +188 -0
- package/dist/cases/inline-form-feedback/button-label.d.ts +1 -0
- package/dist/cases/inline-form-feedback/button-label.jsx +54 -0
- package/dist/cases/inline-form-feedback/inline-alert.d.ts +1 -0
- package/dist/cases/inline-form-feedback/inline-alert.jsx +49 -0
- package/dist/cases/inline-form-feedback/toast.d.ts +1 -0
- package/dist/cases/inline-form-feedback/toast.jsx +66 -0
- package/dist/cases/inline-form-feedback.md +237 -0
- package/dist/cases/invite-member/by-email.d.ts +1 -0
- package/dist/cases/invite-member/by-email.jsx +98 -0
- package/dist/cases/invite-member/by-link.d.ts +1 -0
- package/dist/cases/invite-member/by-link.jsx +122 -0
- package/dist/cases/invite-member.md +321 -0
- package/dist/cases/load-failure/inline.d.ts +1 -0
- package/dist/cases/load-failure/inline.jsx +52 -0
- package/dist/cases/load-failure/region.d.ts +1 -0
- package/dist/cases/load-failure/region.jsx +34 -0
- package/dist/cases/load-failure.md +155 -0
- package/dist/cases/log-out-confirm/modal.d.ts +1 -0
- package/dist/cases/log-out-confirm/modal.jsx +57 -0
- package/dist/cases/log-out-confirm.md +106 -0
- package/dist/cases/login-page/centered.d.ts +1 -0
- package/dist/cases/login-page/centered.jsx +72 -0
- package/dist/cases/login-page/email-only.d.ts +1 -0
- package/dist/cases/login-page/email-only.jsx +59 -0
- package/dist/cases/login-page/provider-first.d.ts +1 -0
- package/dist/cases/login-page/provider-first.jsx +66 -0
- package/dist/cases/login-page/split.d.ts +1 -0
- package/dist/cases/login-page/split.jsx +79 -0
- package/dist/cases/login-page.md +373 -0
- package/dist/cases/not-found-page/full-page.d.ts +1 -0
- package/dist/cases/not-found-page/full-page.jsx +16 -0
- package/dist/cases/not-found-page/in-shell.d.ts +1 -0
- package/dist/cases/not-found-page/in-shell.jsx +36 -0
- package/dist/cases/not-found-page.md +98 -0
- package/dist/cases/oauth-consent/simple.d.ts +1 -0
- package/dist/cases/oauth-consent/simple.jsx +73 -0
- package/dist/cases/oauth-consent/with-scope.d.ts +1 -0
- package/dist/cases/oauth-consent/with-scope.jsx +89 -0
- package/dist/cases/oauth-consent.md +233 -0
- package/dist/cases/rename/inline.d.ts +1 -0
- package/dist/cases/rename/inline.jsx +58 -0
- package/dist/cases/rename/modal.d.ts +1 -0
- package/dist/cases/rename/modal.jsx +70 -0
- package/dist/cases/rename.md +205 -0
- package/dist/cases/route-loading/full-screen.d.ts +1 -0
- package/dist/cases/route-loading/full-screen.jsx +8 -0
- package/dist/cases/route-loading/region.d.ts +1 -0
- package/dist/cases/route-loading/region.jsx +26 -0
- package/dist/cases/route-loading.md +84 -0
- package/dist/cases/set-new-password/form.d.ts +1 -0
- package/dist/cases/set-new-password/form.jsx +130 -0
- package/dist/cases/set-new-password/invalid-link.d.ts +1 -0
- package/dist/cases/set-new-password/invalid-link.jsx +50 -0
- package/dist/cases/set-new-password.md +247 -0
- package/dist/cases/sign-up-page/centered.d.ts +1 -0
- package/dist/cases/sign-up-page/centered.jsx +124 -0
- package/dist/cases/sign-up-page/provider-first.d.ts +1 -0
- package/dist/cases/sign-up-page/provider-first.jsx +124 -0
- package/dist/cases/sign-up-page/split.d.ts +1 -0
- package/dist/cases/sign-up-page/split.jsx +134 -0
- package/dist/cases/sign-up-page.md +478 -0
- package/dist/cases/success-feedback.md +35 -0
- package/dist/cases/type-to-confirm/inline.d.ts +1 -0
- package/dist/cases/type-to-confirm/inline.jsx +69 -0
- package/dist/cases/type-to-confirm/modal.d.ts +1 -0
- package/dist/cases/type-to-confirm/modal.jsx +73 -0
- package/dist/cases/type-to-confirm.md +222 -0
- package/dist/cases/unsaved-changes-guard/discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/discard.jsx +81 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.d.ts +1 -0
- package/dist/cases/unsaved-changes-guard/save-or-discard.jsx +85 -0
- package/dist/cases/unsaved-changes-guard.md +239 -0
- package/dist/cases/upgrade-prompt/inline.d.ts +1 -0
- package/dist/cases/upgrade-prompt/inline.jsx +52 -0
- package/dist/cases/upgrade-prompt/modal.d.ts +1 -0
- package/dist/cases/upgrade-prompt/modal.jsx +43 -0
- package/dist/cases/upgrade-prompt.md +174 -0
- package/dist/cases.json +2073 -0
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +6 -4
- package/dist/components/brandIcon.d.ts +12 -0
- package/dist/components/brandIcon.jsx +24 -0
- package/dist/components/emptyBox.d.ts +6 -1
- package/dist/components/emptyBox.jsx +4 -2
- package/dist/components/form.d.ts +11 -0
- package/dist/components/form.jsx +22 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/image.d.ts +14 -0
- package/dist/components/image.jsx +6 -0
- package/dist/components/layout.d.ts +18 -1
- package/dist/components/layout.jsx +16 -0
- package/dist/components/line.d.ts +3 -1
- package/dist/components/line.jsx +8 -1
- package/dist/components/loadingScreen.d.ts +5 -1
- package/dist/components/loadingScreen.jsx +4 -2
- package/dist/components/modal.d.ts +2 -1
- package/dist/components/modal.jsx +20 -8
- package/dist/components/radioGroup.d.ts +2 -1
- package/dist/components/radioGroup.jsx +2 -2
- package/dist/components/select.d.ts +2 -1
- package/dist/components/select.jsx +4 -2
- package/dist/components/tab.jsx +3 -2
- package/dist/components/tabsContainer.d.ts +4 -1
- package/dist/components/tabsContainer.jsx +11 -5
- package/dist/components/textField.d.ts +5 -1
- package/dist/components/textField.jsx +7 -3
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.jsx +103 -0
- package/dist/components/tooltip.jsx +3 -1
- package/dist/designTokens.d.ts +1 -0
- package/dist/designTokens.js +1 -0
- package/dist/internal/alert.d.ts +4 -0
- package/dist/internal/alert.js +6 -0
- package/dist/internal/modal.d.ts +2 -0
- package/dist/internal/modal.js +21 -0
- package/dist/internal/toaster.d.ts +19 -0
- package/dist/internal/toaster.js +50 -0
- package/dist/native-mapping.json +23 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +16 -0
- package/dist/stories/BrandIcon.stories.d.ts +9 -0
- package/dist/stories/BrandIcon.stories.jsx +19 -0
- package/dist/stories/Cases.generated.stories.d.ts +60 -0
- package/dist/stories/Cases.generated.stories.jsx +116 -0
- package/dist/stories/EmptyBox.stories.d.ts +2 -0
- package/dist/stories/EmptyBox.stories.jsx +16 -0
- package/dist/stories/Form.stories.d.ts +6 -0
- package/dist/stories/Form.stories.jsx +26 -0
- package/dist/stories/Heading.stories.d.ts +6 -0
- package/dist/stories/Heading.stories.jsx +10 -0
- package/dist/stories/Image.stories.d.ts +7 -0
- package/dist/stories/Image.stories.jsx +18 -0
- package/dist/stories/Line.stories.d.ts +1 -0
- package/dist/stories/Line.stories.jsx +12 -0
- package/dist/stories/LoadingScreen.stories.d.ts +1 -0
- package/dist/stories/LoadingScreen.stories.jsx +8 -0
- package/dist/stories/Modal.stories.d.ts +2 -0
- package/dist/stories/Modal.stories.jsx +36 -0
- package/dist/stories/PageComponents.stories.d.ts +2 -0
- package/dist/stories/PageComponents.stories.jsx +15 -1
- package/dist/stories/RadioGroup.stories.d.ts +1 -0
- package/dist/stories/RadioGroup.stories.jsx +14 -0
- package/dist/stories/Select.stories.d.ts +1 -0
- package/dist/stories/Select.stories.jsx +14 -0
- package/dist/stories/TabsContainer.stories.d.ts +1 -0
- package/dist/stories/TabsContainer.stories.jsx +12 -0
- package/dist/stories/TextField.stories.d.ts +2 -0
- package/dist/stories/TextField.stories.jsx +22 -0
- package/dist/stories/Toaster.stories.d.ts +6 -0
- package/dist/stories/Toaster.stories.jsx +29 -0
- package/dist/tailwind-preset-auto.js +2 -1
- package/dist/tailwind-preset.js +2 -1
- package/dist/theme-auto.css +1 -0
- package/dist/theme.css +1 -0
- package/dist/tokens.css +1 -0
- package/dist/tokens.json +7 -0
- package/package.json +4 -2
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Toaster, { toast, dismissToast } from '../../components/toaster';
|
|
4
|
+
import Modal from '../../components/modal';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import TableContainer from '../../components/tableContainer';
|
|
8
|
+
import TableRow from '../../components/tableRow';
|
|
9
|
+
import TableCell from '../../components/tableCell';
|
|
10
|
+
import Form from '../../components/form';
|
|
11
|
+
import TextField from '../../components/textField';
|
|
12
|
+
import Button from '../../components/button';
|
|
13
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
14
|
+
var members = [
|
|
15
|
+
{ name: 'Dana Lee', email: 'dana@example.com', role: 'Admin' },
|
|
16
|
+
{ name: 'Omar Haddad', email: 'omar@example.com', role: 'Member' },
|
|
17
|
+
{ name: 'Mei Tanaka', email: 'mei@example.com', role: 'Member' },
|
|
18
|
+
];
|
|
19
|
+
// A small check: some text, an @, then some text.
|
|
20
|
+
function looksLikeEmail(value) {
|
|
21
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
22
|
+
}
|
|
23
|
+
export default function InviteMemberByEmail() {
|
|
24
|
+
// Opens on the Modal, as if the person just chose Invite Member.
|
|
25
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
26
|
+
var _b = useState('ada@example.com'), email = _b[0], setEmail = _b[1];
|
|
27
|
+
var _c = useState(''), emailError = _c[0], setEmailError = _c[1];
|
|
28
|
+
var _d = useState(false), sending = _d[0], setSending = _d[1];
|
|
29
|
+
var timer = useRef();
|
|
30
|
+
var toastIds = useRef([]);
|
|
31
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
32
|
+
useEffect(function () { return function () {
|
|
33
|
+
clearTimeout(timer.current);
|
|
34
|
+
toastIds.current.forEach(function (id) { return dismissToast(id); });
|
|
35
|
+
toastIds.current = [];
|
|
36
|
+
}; }, []);
|
|
37
|
+
var address = email.trim();
|
|
38
|
+
function handleOpen() {
|
|
39
|
+
setEmail('');
|
|
40
|
+
setEmailError('');
|
|
41
|
+
setOpen(true);
|
|
42
|
+
}
|
|
43
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
44
|
+
function handleClose() {
|
|
45
|
+
if (sending)
|
|
46
|
+
return;
|
|
47
|
+
setOpen(false);
|
|
48
|
+
}
|
|
49
|
+
function handleSend() {
|
|
50
|
+
if (sending || address === '')
|
|
51
|
+
return;
|
|
52
|
+
setEmailError('');
|
|
53
|
+
if (!looksLikeEmail(address)) {
|
|
54
|
+
setEmailError('Enter an email address, like name@example.com.');
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
// Type omar@example.com to see a problem with the address.
|
|
58
|
+
var member = members.find(function (m) { return m.email === address.toLowerCase(); });
|
|
59
|
+
if (member) {
|
|
60
|
+
setEmailError("".concat(member.name, " is already a member of Acme Design."));
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
setSending(true);
|
|
64
|
+
// Stands in for the request to the server.
|
|
65
|
+
timer.current = setTimeout(function () {
|
|
66
|
+
setSending(false);
|
|
67
|
+
setOpen(false);
|
|
68
|
+
toastIds.current.push(toast({ type: 'success', message: "Invite sent to ".concat(address, ".") }));
|
|
69
|
+
}, 1200);
|
|
70
|
+
}
|
|
71
|
+
return (<Center width="page">
|
|
72
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
73
|
+
<Toaster />
|
|
74
|
+
<Stack gap="large">
|
|
75
|
+
<Cluster>
|
|
76
|
+
<Heading level={1} size="h5">Members</Heading>
|
|
77
|
+
<Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleOpen}/>
|
|
78
|
+
</Cluster>
|
|
79
|
+
<TableContainer>
|
|
80
|
+
{members.map(function (m) { return (<TableRow key={m.email}>
|
|
81
|
+
<TableCell>{m.name}</TableCell>
|
|
82
|
+
<TableCell>{m.email}</TableCell>
|
|
83
|
+
<TableCell width="100px">{m.role}</TableCell>
|
|
84
|
+
</TableRow>); })}
|
|
85
|
+
</TableContainer>
|
|
86
|
+
</Stack>
|
|
87
|
+
<Modal isOpen={open} size="small" initialFocus="body" title="Invite Member" onClose={handleClose} actions={<>
|
|
88
|
+
<Button size="small" type="tertiary" state={sending ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
89
|
+
<Button size="small" type="primary" state={address === '' ? 'disabled' : 'enabled'} label="Invite" loading={sending} onClickButton={handleSend}/>
|
|
90
|
+
</>}>
|
|
91
|
+
<Paragraph measure="none">We email them a link to join Acme Design as a member. The link works for 7 days.</Paragraph>
|
|
92
|
+
{/* The Form lets Enter in the field send too. */}
|
|
93
|
+
<Form aria-label="Invite member" onSubmit={handleSend}>
|
|
94
|
+
<TextField id="invite-member-email" label="Email" type="email" value={email} disabled={sending} error={Boolean(emailError)} errorText={emailError} onChange={function (e) { setEmail(e.target.value); setEmailError(''); }}/>
|
|
95
|
+
</Form>
|
|
96
|
+
</Modal>
|
|
97
|
+
</Center>);
|
|
98
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function InviteMemberByLink(): import("react").JSX.Element;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Toaster, { toast, dismissToast } from '../../components/toaster';
|
|
4
|
+
import Modal from '../../components/modal';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import TableContainer from '../../components/tableContainer';
|
|
8
|
+
import TableRow from '../../components/tableRow';
|
|
9
|
+
import TableCell from '../../components/tableCell';
|
|
10
|
+
import TextField from '../../components/textField';
|
|
11
|
+
import EmptyBox from '../../components/emptyBox';
|
|
12
|
+
import Button from '../../components/button';
|
|
13
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
14
|
+
var members = [
|
|
15
|
+
{ name: 'Dana Lee', email: 'dana@example.com', role: 'Admin' },
|
|
16
|
+
{ name: 'Omar Haddad', email: 'omar@example.com', role: 'Member' },
|
|
17
|
+
{ name: 'Mei Tanaka', email: 'mei@example.com', role: 'Member' },
|
|
18
|
+
];
|
|
19
|
+
// The link made for this Modal. A real app gets it from the server.
|
|
20
|
+
var inviteLink = 'https://acme.example/join/k7Qm2xLp';
|
|
21
|
+
var earlierLinks = [
|
|
22
|
+
{ id: 'l1', createdBy: 'Dana Lee', expires: '5 days left' },
|
|
23
|
+
{ id: 'l2', createdBy: 'Omar Haddad', expires: '2 days left' },
|
|
24
|
+
];
|
|
25
|
+
export default function InviteMemberByLink() {
|
|
26
|
+
// Opens on the Modal, as if the person just chose Invite Member.
|
|
27
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
28
|
+
var _b = useState(false), copied = _b[0], setCopied = _b[1];
|
|
29
|
+
var _c = useState(false), copyBlocked = _c[0], setCopyBlocked = _c[1];
|
|
30
|
+
var _d = useState(earlierLinks), links = _d[0], setLinks = _d[1];
|
|
31
|
+
var _e = useState(null), confirming = _e[0], setConfirming = _e[1];
|
|
32
|
+
var _f = useState(false), revoking = _f[0], setRevoking = _f[1];
|
|
33
|
+
var copyTimer = useRef();
|
|
34
|
+
var timer = useRef();
|
|
35
|
+
var toastIds = useRef([]);
|
|
36
|
+
// On unmount it stops the timers and closes every toast it opened.
|
|
37
|
+
useEffect(function () { return function () {
|
|
38
|
+
clearTimeout(copyTimer.current);
|
|
39
|
+
clearTimeout(timer.current);
|
|
40
|
+
toastIds.current.forEach(function (id) { return dismissToast(id); });
|
|
41
|
+
toastIds.current = [];
|
|
42
|
+
}; }, []);
|
|
43
|
+
// Only reads 'Copied' when the link reached the clipboard. When the browser has no
|
|
44
|
+
// clipboard or refuses the write, a line under the field says so, and the label stays 'Copy'.
|
|
45
|
+
function handleCopy() {
|
|
46
|
+
clearTimeout(copyTimer.current);
|
|
47
|
+
setCopied(false);
|
|
48
|
+
var blocked = function () { return setCopyBlocked(true); };
|
|
49
|
+
if (!navigator.clipboard) {
|
|
50
|
+
blocked();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
navigator.clipboard.writeText(inviteLink).then(function () {
|
|
54
|
+
setCopyBlocked(false);
|
|
55
|
+
setCopied(true);
|
|
56
|
+
copyTimer.current = setTimeout(function () { return setCopied(false); }, 2000);
|
|
57
|
+
}, blocked);
|
|
58
|
+
}
|
|
59
|
+
// Done, Escape and a click outside all close it, except while a revoke runs.
|
|
60
|
+
// Closing drops a row's open confirm, so the Modal never reopens on it.
|
|
61
|
+
function handleClose() {
|
|
62
|
+
if (revoking)
|
|
63
|
+
return;
|
|
64
|
+
setConfirming(null);
|
|
65
|
+
setOpen(false);
|
|
66
|
+
}
|
|
67
|
+
function handleRevoke(id, createdBy) {
|
|
68
|
+
if (revoking)
|
|
69
|
+
return;
|
|
70
|
+
setRevoking(true);
|
|
71
|
+
// Stands in for the request to the server.
|
|
72
|
+
timer.current = setTimeout(function () {
|
|
73
|
+
setRevoking(false);
|
|
74
|
+
setConfirming(null);
|
|
75
|
+
setLinks(function (list) { return list.filter(function (l) { return l.id !== id; }); });
|
|
76
|
+
toastIds.current.push(toast({ type: 'success', message: "Link made by ".concat(createdBy, " revoked.") }));
|
|
77
|
+
}, 1200);
|
|
78
|
+
}
|
|
79
|
+
return (<Center width="page">
|
|
80
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
81
|
+
<Toaster />
|
|
82
|
+
<Stack gap="large">
|
|
83
|
+
<Cluster>
|
|
84
|
+
<Heading level={1} size="h5">Members</Heading>
|
|
85
|
+
<Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={function () { return setOpen(true); }}/>
|
|
86
|
+
</Cluster>
|
|
87
|
+
<TableContainer>
|
|
88
|
+
{members.map(function (m) { return (<TableRow key={m.email}>
|
|
89
|
+
<TableCell>{m.name}</TableCell>
|
|
90
|
+
<TableCell>{m.email}</TableCell>
|
|
91
|
+
<TableCell width="100px">{m.role}</TableCell>
|
|
92
|
+
</TableRow>); })}
|
|
93
|
+
</TableContainer>
|
|
94
|
+
</Stack>
|
|
95
|
+
<Modal isOpen={open} size="medium" title="Invite Member" onClose={handleClose} actions={<Button size="small" type="primary" state={revoking ? 'disabled' : 'enabled'} label="Done" onClickButton={handleClose}/>}>
|
|
96
|
+
<Paragraph measure="none">Anyone with this link can join Acme Design as a member. It works for 7 days.</Paragraph>
|
|
97
|
+
<Stack gap="small" align="start">
|
|
98
|
+
<TextField id="invite-member-link" label="Invite link" value={inviteLink} readOnly onChange={function () { }}/>
|
|
99
|
+
{copyBlocked && <Paragraph tone="secondary" size="body2" measure="none">Copying is blocked here. Select the link and copy it.</Paragraph>}
|
|
100
|
+
<Button size="small" type="secondary" state="enabled" label={copied ? 'Copied' : 'Copy'} decoIcon={copied ? 'Check' : 'Copy'} onClickButton={handleCopy}/>
|
|
101
|
+
</Stack>
|
|
102
|
+
<Stack gap="small">
|
|
103
|
+
<Heading level={3} size="subtitle1">Other links that still work</Heading>
|
|
104
|
+
{links.length > 0 ? (<TableContainer>
|
|
105
|
+
{links.map(function (l) { return (<TableRow key={l.id}>
|
|
106
|
+
<TableCell>Made by {l.createdBy}</TableCell>
|
|
107
|
+
<TableCell width="120px">{l.expires}</TableCell>
|
|
108
|
+
{/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
|
|
109
|
+
<TableCell width="168px">
|
|
110
|
+
{confirming === l.id ? (<Cluster gap="small">
|
|
111
|
+
<Button size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Cancel" aria-label={"Cancel, keep the link made by ".concat(l.createdBy)} onClickButton={function () { return setConfirming(null); }}/>
|
|
112
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={"Revoke the link made by ".concat(l.createdBy)} loading={revoking} onClickButton={function () { return handleRevoke(l.id, l.createdBy); }}/>
|
|
113
|
+
</Cluster>) : (<Cluster gap="small">
|
|
114
|
+
<Button size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={"Revoke the link made by ".concat(l.createdBy)} onClickButton={function () { return setConfirming(l.id); }}/>
|
|
115
|
+
</Cluster>)}
|
|
116
|
+
</TableCell>
|
|
117
|
+
</TableRow>); })}
|
|
118
|
+
</TableContainer>) : (<EmptyBox size="small" icon="Link" text="No other links" secondText="Links you make here show until they stop working."/>)}
|
|
119
|
+
</Stack>
|
|
120
|
+
</Modal>
|
|
121
|
+
</Center>);
|
|
122
|
+
}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# Member invite
|
|
2
|
+
|
|
3
|
+
A person invites someone to join a workspace.
|
|
4
|
+
|
|
5
|
+
**Not built yet:** Scindo on the web replaces the fields with a spinner while it creates an invite, labels the way out 'Close' and reads 'Copied!'. It cancels an invite link on one click with no confirm. Scindo's Apple app cancels a pending invite with no confirm too.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Title the Modal 'Invite Member' and label its action 'Invite', after 'Cancel'.
|
|
10
|
+
- Send on Enter too: put the email field in a `Form`.
|
|
11
|
+
- Focus the email field when the Modal opens, with `initialFocus="body"`, and disable it while the invite is sent.
|
|
12
|
+
- Show a problem with the address under the field, such as a person who is already a member.
|
|
13
|
+
- Close the Modal once the invite is sent, and show a toast that names the address: 'Invite sent to ada@example.com.'
|
|
14
|
+
- Show a toast that names the link once it is revoked: 'Link made by Dana Lee revoked.'
|
|
15
|
+
- Show the link in a `TextField` with `readOnly`, so it can be selected, and a 'Copy' Button next to it.
|
|
16
|
+
- Change 'Copy' to 'Copied' for 2 seconds, and only when the link reached the clipboard.
|
|
17
|
+
- Say under the field when copying is blocked: 'Copying is blocked here. Select the link and copy it.'
|
|
18
|
+
- Say who can use the link and when it stops working.
|
|
19
|
+
- List the links that still work, each with a 'Revoke' Button. Revoking removes access, so confirm it in the row, as the case 'Delete confirm' does.
|
|
20
|
+
- Give each row's 'Revoke', and the confirm's 'Cancel' and 'Revoke', an `aria-label` that names the link: 'Revoke the link made by Dana Lee'.
|
|
21
|
+
- Start each `aria-label` with the visible label, so voice control still finds the Button.
|
|
22
|
+
- Disable 'Done', and ignore Escape and a click outside, while a revoke runs.
|
|
23
|
+
|
|
24
|
+
## Don't
|
|
25
|
+
|
|
26
|
+
- Do not label the way out 'Close', or the action 'Create Invite' when the product sends it.
|
|
27
|
+
- Do not replace the field with a spinner while the invite is sent.
|
|
28
|
+
- Do not show 'Copied' when the copy failed, or 'Copied!' with an exclamation mark.
|
|
29
|
+
- Do not revoke a link on the first click.
|
|
30
|
+
- Do not touch `navigator` while the page renders. Copy only in the click handler.
|
|
31
|
+
|
|
32
|
+
## Option: Send an invite by email
|
|
33
|
+
|
|
34
|
+
Use when: The product sends the invite to an address the person types.
|
|
35
|
+
|
|
36
|
+
Uses: `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Modal`, `Paragraph`, `Stack`, `TableCell`, `TableContainer`, `TableRow`, `TextField`, `Toaster`, `dismissToast`, `toast`
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
'use client';
|
|
40
|
+
import { useEffect, useRef, useState } from 'react';
|
|
41
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
42
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
43
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
44
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
45
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
46
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
47
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
48
|
+
import Form from 'oneslash-design-system/components/form';
|
|
49
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
50
|
+
import Button from 'oneslash-design-system/components/button';
|
|
51
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
52
|
+
|
|
53
|
+
const members = [
|
|
54
|
+
{ name: 'Dana Lee', email: 'dana@example.com', role: 'Admin' },
|
|
55
|
+
{ name: 'Omar Haddad', email: 'omar@example.com', role: 'Member' },
|
|
56
|
+
{ name: 'Mei Tanaka', email: 'mei@example.com', role: 'Member' },
|
|
57
|
+
];
|
|
58
|
+
|
|
59
|
+
// A small check: some text, an @, then some text.
|
|
60
|
+
function looksLikeEmail(value: string) {
|
|
61
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default function InviteMemberByEmail() {
|
|
65
|
+
// Opens on the Modal, as if the person just chose Invite Member.
|
|
66
|
+
const [open, setOpen] = useState(true);
|
|
67
|
+
const [email, setEmail] = useState('ada@example.com');
|
|
68
|
+
const [emailError, setEmailError] = useState('');
|
|
69
|
+
const [sending, setSending] = useState(false);
|
|
70
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
71
|
+
const toastIds = useRef<string[]>([]);
|
|
72
|
+
|
|
73
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
74
|
+
useEffect(() => () => {
|
|
75
|
+
clearTimeout(timer.current);
|
|
76
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
77
|
+
toastIds.current = [];
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
const address = email.trim();
|
|
81
|
+
|
|
82
|
+
function handleOpen() {
|
|
83
|
+
setEmail('');
|
|
84
|
+
setEmailError('');
|
|
85
|
+
setOpen(true);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
89
|
+
function handleClose() {
|
|
90
|
+
if (sending) return;
|
|
91
|
+
setOpen(false);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function handleSend() {
|
|
95
|
+
if (sending || address === '') return;
|
|
96
|
+
setEmailError('');
|
|
97
|
+
if (!looksLikeEmail(address)) {
|
|
98
|
+
setEmailError('Enter an email address, like name@example.com.');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
// Type omar@example.com to see a problem with the address.
|
|
102
|
+
const member = members.find((m) => m.email === address.toLowerCase());
|
|
103
|
+
if (member) {
|
|
104
|
+
setEmailError(`${member.name} is already a member of Acme Design.`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
setSending(true);
|
|
108
|
+
// Stands in for the request to the server.
|
|
109
|
+
timer.current = setTimeout(() => {
|
|
110
|
+
setSending(false);
|
|
111
|
+
setOpen(false);
|
|
112
|
+
toastIds.current.push(toast({ type: 'success', message: `Invite sent to ${address}.` }));
|
|
113
|
+
}, 1200);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<Center width="page">
|
|
118
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
119
|
+
<Toaster />
|
|
120
|
+
<Stack gap="large">
|
|
121
|
+
<Cluster>
|
|
122
|
+
<Heading level={1} size="h5">Members</Heading>
|
|
123
|
+
<Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={handleOpen} />
|
|
124
|
+
</Cluster>
|
|
125
|
+
<TableContainer>
|
|
126
|
+
{members.map((m) => (
|
|
127
|
+
<TableRow key={m.email}>
|
|
128
|
+
<TableCell>{m.name}</TableCell>
|
|
129
|
+
<TableCell>{m.email}</TableCell>
|
|
130
|
+
<TableCell width="100px">{m.role}</TableCell>
|
|
131
|
+
</TableRow>
|
|
132
|
+
))}
|
|
133
|
+
</TableContainer>
|
|
134
|
+
</Stack>
|
|
135
|
+
<Modal
|
|
136
|
+
isOpen={open}
|
|
137
|
+
size="small"
|
|
138
|
+
initialFocus="body"
|
|
139
|
+
title="Invite Member"
|
|
140
|
+
onClose={handleClose}
|
|
141
|
+
actions={
|
|
142
|
+
<>
|
|
143
|
+
<Button size="small" type="tertiary" state={sending ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
144
|
+
<Button size="small" type="primary" state={address === '' ? 'disabled' : 'enabled'} label="Invite" loading={sending} onClickButton={handleSend} />
|
|
145
|
+
</>
|
|
146
|
+
}
|
|
147
|
+
>
|
|
148
|
+
<Paragraph measure="none">We email them a link to join Acme Design as a member. The link works for 7 days.</Paragraph>
|
|
149
|
+
{/* The Form lets Enter in the field send too. */}
|
|
150
|
+
<Form aria-label="Invite member" onSubmit={handleSend}>
|
|
151
|
+
<TextField id="invite-member-email" label="Email" type="email" value={email} disabled={sending} error={Boolean(emailError)} errorText={emailError} onChange={(e) => { setEmail(e.target.value); setEmailError(''); }} />
|
|
152
|
+
</Form>
|
|
153
|
+
</Modal>
|
|
154
|
+
</Center>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## Option: Share an invite link
|
|
160
|
+
|
|
161
|
+
Use when: The person shares a link themselves, in their own chat or email.
|
|
162
|
+
|
|
163
|
+
Uses: `Button`, `Center`, `Cluster`, `EmptyBox`, `Heading`, `Modal`, `Paragraph`, `Stack`, `TableCell`, `TableContainer`, `TableRow`, `TextField`, `Toaster`, `dismissToast`, `toast`
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
'use client';
|
|
167
|
+
import { useEffect, useRef, useState } from 'react';
|
|
168
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
169
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
170
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
171
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
172
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
173
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
174
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
175
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
176
|
+
import EmptyBox from 'oneslash-design-system/components/emptyBox';
|
|
177
|
+
import Button from 'oneslash-design-system/components/button';
|
|
178
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
179
|
+
|
|
180
|
+
const members = [
|
|
181
|
+
{ name: 'Dana Lee', email: 'dana@example.com', role: 'Admin' },
|
|
182
|
+
{ name: 'Omar Haddad', email: 'omar@example.com', role: 'Member' },
|
|
183
|
+
{ name: 'Mei Tanaka', email: 'mei@example.com', role: 'Member' },
|
|
184
|
+
];
|
|
185
|
+
|
|
186
|
+
// The link made for this Modal. A real app gets it from the server.
|
|
187
|
+
const inviteLink = 'https://acme.example/join/k7Qm2xLp';
|
|
188
|
+
|
|
189
|
+
const earlierLinks = [
|
|
190
|
+
{ id: 'l1', createdBy: 'Dana Lee', expires: '5 days left' },
|
|
191
|
+
{ id: 'l2', createdBy: 'Omar Haddad', expires: '2 days left' },
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
export default function InviteMemberByLink() {
|
|
195
|
+
// Opens on the Modal, as if the person just chose Invite Member.
|
|
196
|
+
const [open, setOpen] = useState(true);
|
|
197
|
+
const [copied, setCopied] = useState(false);
|
|
198
|
+
const [copyBlocked, setCopyBlocked] = useState(false);
|
|
199
|
+
const [links, setLinks] = useState(earlierLinks);
|
|
200
|
+
const [confirming, setConfirming] = useState<string | null>(null);
|
|
201
|
+
const [revoking, setRevoking] = useState(false);
|
|
202
|
+
const copyTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
203
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
204
|
+
const toastIds = useRef<string[]>([]);
|
|
205
|
+
|
|
206
|
+
// On unmount it stops the timers and closes every toast it opened.
|
|
207
|
+
useEffect(() => () => {
|
|
208
|
+
clearTimeout(copyTimer.current);
|
|
209
|
+
clearTimeout(timer.current);
|
|
210
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
211
|
+
toastIds.current = [];
|
|
212
|
+
}, []);
|
|
213
|
+
|
|
214
|
+
// Only reads 'Copied' when the link reached the clipboard. When the browser has no
|
|
215
|
+
// clipboard or refuses the write, a line under the field says so, and the label stays 'Copy'.
|
|
216
|
+
function handleCopy() {
|
|
217
|
+
clearTimeout(copyTimer.current);
|
|
218
|
+
setCopied(false);
|
|
219
|
+
const blocked = () => setCopyBlocked(true);
|
|
220
|
+
if (!navigator.clipboard) {
|
|
221
|
+
blocked();
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
navigator.clipboard.writeText(inviteLink).then(() => {
|
|
225
|
+
setCopyBlocked(false);
|
|
226
|
+
setCopied(true);
|
|
227
|
+
copyTimer.current = setTimeout(() => setCopied(false), 2000);
|
|
228
|
+
}, blocked);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Done, Escape and a click outside all close it, except while a revoke runs.
|
|
232
|
+
// Closing drops a row's open confirm, so the Modal never reopens on it.
|
|
233
|
+
function handleClose() {
|
|
234
|
+
if (revoking) return;
|
|
235
|
+
setConfirming(null);
|
|
236
|
+
setOpen(false);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function handleRevoke(id: string, createdBy: string) {
|
|
240
|
+
if (revoking) return;
|
|
241
|
+
setRevoking(true);
|
|
242
|
+
// Stands in for the request to the server.
|
|
243
|
+
timer.current = setTimeout(() => {
|
|
244
|
+
setRevoking(false);
|
|
245
|
+
setConfirming(null);
|
|
246
|
+
setLinks((list) => list.filter((l) => l.id !== id));
|
|
247
|
+
toastIds.current.push(toast({ type: 'success', message: `Link made by ${createdBy} revoked.` }));
|
|
248
|
+
}, 1200);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
return (
|
|
252
|
+
<Center width="page">
|
|
253
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
254
|
+
<Toaster />
|
|
255
|
+
<Stack gap="large">
|
|
256
|
+
<Cluster>
|
|
257
|
+
<Heading level={1} size="h5">Members</Heading>
|
|
258
|
+
<Button size="small" type="primary" state="enabled" label="Invite Member" decoIcon="UserPlus" onClickButton={() => setOpen(true)} />
|
|
259
|
+
</Cluster>
|
|
260
|
+
<TableContainer>
|
|
261
|
+
{members.map((m) => (
|
|
262
|
+
<TableRow key={m.email}>
|
|
263
|
+
<TableCell>{m.name}</TableCell>
|
|
264
|
+
<TableCell>{m.email}</TableCell>
|
|
265
|
+
<TableCell width="100px">{m.role}</TableCell>
|
|
266
|
+
</TableRow>
|
|
267
|
+
))}
|
|
268
|
+
</TableContainer>
|
|
269
|
+
</Stack>
|
|
270
|
+
<Modal
|
|
271
|
+
isOpen={open}
|
|
272
|
+
size="medium"
|
|
273
|
+
title="Invite Member"
|
|
274
|
+
onClose={handleClose}
|
|
275
|
+
actions={<Button size="small" type="primary" state={revoking ? 'disabled' : 'enabled'} label="Done" onClickButton={handleClose} />}
|
|
276
|
+
>
|
|
277
|
+
<Paragraph measure="none">Anyone with this link can join Acme Design as a member. It works for 7 days.</Paragraph>
|
|
278
|
+
<Stack gap="small" align="start">
|
|
279
|
+
<TextField id="invite-member-link" label="Invite link" value={inviteLink} readOnly onChange={() => {}} />
|
|
280
|
+
{copyBlocked && <Paragraph tone="secondary" size="body2" measure="none">Copying is blocked here. Select the link and copy it.</Paragraph>}
|
|
281
|
+
<Button size="small" type="secondary" state="enabled" label={copied ? 'Copied' : 'Copy'} decoIcon={copied ? 'Check' : 'Copy'} onClickButton={handleCopy} />
|
|
282
|
+
</Stack>
|
|
283
|
+
<Stack gap="small">
|
|
284
|
+
<Heading level={3} size="subtitle1">Other links that still work</Heading>
|
|
285
|
+
{links.length > 0 ? (
|
|
286
|
+
<TableContainer>
|
|
287
|
+
{links.map((l) => (
|
|
288
|
+
<TableRow key={l.id}>
|
|
289
|
+
<TableCell>Made by {l.createdBy}</TableCell>
|
|
290
|
+
<TableCell width="120px">{l.expires}</TableCell>
|
|
291
|
+
{/* A fixed last column keeps every row's Buttons in one place, so they do not jump when they change. */}
|
|
292
|
+
<TableCell width="168px">
|
|
293
|
+
{confirming === l.id ? (
|
|
294
|
+
<Cluster gap="small">
|
|
295
|
+
<Button size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Cancel" aria-label={`Cancel, keep the link made by ${l.createdBy}`} onClickButton={() => setConfirming(null)} />
|
|
296
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Revoke" aria-label={`Revoke the link made by ${l.createdBy}`} loading={revoking} onClickButton={() => handleRevoke(l.id, l.createdBy)} />
|
|
297
|
+
</Cluster>
|
|
298
|
+
) : (
|
|
299
|
+
<Cluster gap="small">
|
|
300
|
+
<Button size="small" type="tertiary" state={revoking ? 'disabled' : 'enabled'} label="Revoke" aria-label={`Revoke the link made by ${l.createdBy}`} onClickButton={() => setConfirming(l.id)} />
|
|
301
|
+
</Cluster>
|
|
302
|
+
)}
|
|
303
|
+
</TableCell>
|
|
304
|
+
</TableRow>
|
|
305
|
+
))}
|
|
306
|
+
</TableContainer>
|
|
307
|
+
) : (
|
|
308
|
+
<EmptyBox size="small" icon="Link" text="No other links" secondText="Links you make here show until they stop working." />
|
|
309
|
+
)}
|
|
310
|
+
</Stack>
|
|
311
|
+
</Modal>
|
|
312
|
+
</Center>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
## Native
|
|
318
|
+
|
|
319
|
+
On Apple use a sheet with a `Form`, share the link with `ShareLink`, and revoke a link with a `.destructive` Button that asks first in a `confirmationDialog`.
|
|
320
|
+
|
|
321
|
+
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function LoadFailureInline(): import("react").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Surface from '../../components/surface';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import Alert from '../../components/alert';
|
|
7
|
+
import List from '../../components/list';
|
|
8
|
+
import Button from '../../components/button';
|
|
9
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
10
|
+
var invoices = ['November 2026: $240', 'October 2026: $240', 'September 2026: $180'];
|
|
11
|
+
export default function LoadFailureInline() {
|
|
12
|
+
var _a = useState('Could not load your invoices.'), error = _a[0], setError = _a[1];
|
|
13
|
+
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
14
|
+
var timer = useRef();
|
|
15
|
+
// Stops the request if the example goes away before it ends.
|
|
16
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
17
|
+
function handleTryAgain() {
|
|
18
|
+
if (loading)
|
|
19
|
+
return;
|
|
20
|
+
setLoading(true);
|
|
21
|
+
// Stands in for the request to the server.
|
|
22
|
+
timer.current = setTimeout(function () {
|
|
23
|
+
setLoading(false);
|
|
24
|
+
setError('');
|
|
25
|
+
}, 1200);
|
|
26
|
+
}
|
|
27
|
+
return (<Center width="page">
|
|
28
|
+
<Stack gap="xlarge">
|
|
29
|
+
<Surface padding="large">
|
|
30
|
+
<Stack gap="medium">
|
|
31
|
+
<Heading level={2} size="h6">Plan</Heading>
|
|
32
|
+
<Paragraph size="body2" measure="none">Team plan, 12 seats, renews on December 1.</Paragraph>
|
|
33
|
+
<Cluster>
|
|
34
|
+
<Button size="small" type="secondary" state="enabled" label="Change Plan"/>
|
|
35
|
+
</Cluster>
|
|
36
|
+
</Stack>
|
|
37
|
+
</Surface>
|
|
38
|
+
<Surface padding="large">
|
|
39
|
+
<Stack gap="medium">
|
|
40
|
+
<Heading level={2} size="h6">Invoices</Heading>
|
|
41
|
+
{error ? (<>
|
|
42
|
+
{/* The section stays failed until it loads, so the Alert has no close button and does not close on its own. */}
|
|
43
|
+
<Alert type="error" variant="inline" message={error} autoDismiss={false}/>
|
|
44
|
+
<Cluster>
|
|
45
|
+
<Button size="small" type="primary" state="enabled" label="Try Again" loading={loading} onClickButton={handleTryAgain}/>
|
|
46
|
+
</Cluster>
|
|
47
|
+
</>) : (<List items={invoices} size="body2"/>)}
|
|
48
|
+
</Stack>
|
|
49
|
+
</Surface>
|
|
50
|
+
</Stack>
|
|
51
|
+
</Center>);
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function LoadFailureRegion(): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Surface from '../../components/surface';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import EmptyBox from '../../components/emptyBox';
|
|
6
|
+
import List from '../../components/list';
|
|
7
|
+
import Button from '../../components/button';
|
|
8
|
+
import { Stack } from '../../components/layout';
|
|
9
|
+
var projects = ['Website refresh', 'Hiring plan', 'Q4 budget', 'Office move'];
|
|
10
|
+
export default function LoadFailureRegion() {
|
|
11
|
+
var _a = useState(false), loaded = _a[0], setLoaded = _a[1];
|
|
12
|
+
var _b = useState(false), loading = _b[0], setLoading = _b[1];
|
|
13
|
+
var timer = useRef();
|
|
14
|
+
// Stops the request if the example goes away before it ends.
|
|
15
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
16
|
+
function handleTryAgain() {
|
|
17
|
+
if (loading)
|
|
18
|
+
return;
|
|
19
|
+
setLoading(true);
|
|
20
|
+
// Stands in for the request to the server.
|
|
21
|
+
timer.current = setTimeout(function () {
|
|
22
|
+
setLoading(false);
|
|
23
|
+
setLoaded(true);
|
|
24
|
+
}, 1200);
|
|
25
|
+
}
|
|
26
|
+
return (<Stack gap="large">
|
|
27
|
+
<Heading level={2} size="h5">Projects</Heading>
|
|
28
|
+
{loaded ? (<Surface minHeight="tall">
|
|
29
|
+
<List items={projects} size="body1"/>
|
|
30
|
+
</Surface>) : (<Surface minHeight="tall" align="center">
|
|
31
|
+
<EmptyBox size="large" icon="CloudOff" text="Could not load projects" secondText="Check your connection and try again." action={<Button size="medium" type="primary" state="enabled" label="Try Again" loading={loading} onClickButton={handleTryAgain}/>}/>
|
|
32
|
+
</Surface>)}
|
|
33
|
+
</Stack>);
|
|
34
|
+
}
|