oneslash-design-system 2.15.0 → 2.17.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 +6 -1
- package/dist/DESIGN.md +100 -73
- 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 +1 -1
- package/dist/cases/agent-cancels-when-unanswered.md +1 -1
- package/dist/cases/agent-options/cards.d.ts +1 -0
- package/dist/cases/agent-options/cards.jsx +91 -0
- package/dist/cases/agent-options.md +168 -0
- package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
- package/dist/cases/agent-pending-reply/steps.jsx +149 -0
- package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
- package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
- package/dist/cases/agent-pending-reply.md +432 -0
- package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
- package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
- package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
- package/dist/cases/agent-plan-proposal.md +656 -0
- package/dist/cases/agent-question/choices.d.ts +1 -0
- package/dist/cases/agent-question/choices.jsx +132 -0
- package/dist/cases/agent-question/free-text.d.ts +1 -0
- package/dist/cases/agent-question/free-text.jsx +81 -0
- package/dist/cases/agent-question.md +338 -0
- package/dist/cases/agent-shows-sources.md +2 -2
- package/dist/cases/artifact-card/card.d.ts +1 -0
- package/dist/cases/artifact-card/card.jsx +45 -0
- package/dist/cases/artifact-card.md +103 -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/composer-limit/notice-with-action.d.ts +1 -0
- package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
- package/dist/cases/composer-limit/notice.d.ts +1 -0
- package/dist/cases/composer-limit/notice.jsx +84 -0
- package/dist/cases/composer-limit.md +286 -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/conversation-starters/chips.d.ts +1 -0
- package/dist/cases/conversation-starters/chips.jsx +69 -0
- package/dist/cases/conversation-starters/none.d.ts +1 -0
- package/dist/cases/conversation-starters/none.jsx +45 -0
- package/dist/cases/conversation-starters.md +208 -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.jsx +10 -7
- package/dist/cases/login-page/email-only.jsx +11 -8
- package/dist/cases/login-page/provider-first.jsx +12 -9
- package/dist/cases/login-page/split.jsx +11 -8
- package/dist/cases/login-page.md +58 -41
- package/dist/cases/mention-list/in-composer.d.ts +1 -0
- package/dist/cases/mention-list/in-composer.jsx +169 -0
- package/dist/cases/mention-list.md +252 -0
- package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
- package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
- package/dist/cases/message-actions/menu.d.ts +1 -0
- package/dist/cases/message-actions/menu.jsx +258 -0
- package/dist/cases/message-actions.md +651 -0
- package/dist/cases/message-attachments/in-composer.d.ts +1 -0
- package/dist/cases/message-attachments/in-composer.jsx +134 -0
- package/dist/cases/message-attachments/in-message.d.ts +1 -0
- package/dist/cases/message-attachments/in-message.jsx +46 -0
- package/dist/cases/message-attachments.md +310 -0
- package/dist/cases/message-composer/plain.d.ts +1 -0
- package/dist/cases/message-composer/plain.jsx +57 -0
- package/dist/cases/message-composer/with-tools.d.ts +1 -0
- package/dist/cases/message-composer/with-tools.jsx +182 -0
- package/dist/cases/message-composer.md +356 -0
- package/dist/cases/message-edit/in-place.d.ts +1 -0
- package/dist/cases/message-edit/in-place.jsx +99 -0
- package/dist/cases/message-edit.md +179 -0
- package/dist/cases/message-reactions/chips.d.ts +1 -0
- package/dist/cases/message-reactions/chips.jsx +118 -0
- package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
- package/dist/cases/message-reactions/quick-pick.jsx +155 -0
- package/dist/cases/message-reactions.md +371 -0
- package/dist/cases/message-row/grouped.d.ts +1 -0
- package/dist/cases/message-row/grouped.jsx +56 -0
- package/dist/cases/message-row/person-and-agent.d.ts +1 -0
- package/dist/cases/message-row/person-and-agent.jsx +41 -0
- package/dist/cases/message-row.md +189 -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/reply-feedback/thumbs.d.ts +1 -0
- package/dist/cases/reply-feedback/thumbs.jsx +191 -0
- package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
- package/dist/cases/reply-feedback/with-reason.jsx +221 -0
- package/dist/cases/reply-feedback.md +552 -0
- package/dist/cases/reply-sources/cards.d.ts +1 -0
- package/dist/cases/reply-sources/cards.jsx +83 -0
- package/dist/cases/reply-sources/tag-only.d.ts +1 -0
- package/dist/cases/reply-sources/tag-only.jsx +45 -0
- package/dist/cases/reply-sources.md +247 -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/slash-command-list/in-composer.d.ts +1 -0
- package/dist/cases/slash-command-list/in-composer.jsx +162 -0
- package/dist/cases/slash-command-list.md +247 -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/typing-and-status/line.d.ts +1 -0
- package/dist/cases/typing-and-status/line.jsx +50 -0
- package/dist/cases/typing-and-status.md +96 -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 +3138 -59
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +6 -4
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +9 -7
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/emptyBox.d.ts +6 -1
- package/dist/components/emptyBox.jsx +4 -2
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/iconButton.d.ts +3 -3
- package/dist/components/iconButton.jsx +9 -7
- package/dist/components/layout.d.ts +7 -1
- package/dist/components/layout.jsx +5 -2
- package/dist/components/loadingScreen.d.ts +5 -1
- package/dist/components/loadingScreen.jsx +4 -2
- package/dist/components/menu.d.ts +21 -0
- package/dist/components/menu.jsx +27 -3
- package/dist/components/menuItem.d.ts +9 -1
- package/dist/components/menuItem.jsx +5 -4
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- package/dist/components/modal.d.ts +2 -1
- package/dist/components/modal.jsx +20 -8
- package/dist/components/paragraph.d.ts +3 -1
- package/dist/components/paragraph.jsx +2 -2
- package/dist/components/popover.d.ts +7 -1
- package/dist/components/popover.jsx +35 -9
- package/dist/components/radioGroup.d.ts +9 -1
- package/dist/components/radioGroup.jsx +20 -9
- package/dist/components/select.d.ts +2 -1
- package/dist/components/select.jsx +4 -2
- package/dist/components/sourceCard.d.ts +23 -0
- package/dist/components/sourceCard.jsx +56 -0
- package/dist/components/stepList.d.ts +17 -0
- package/dist/components/stepList.jsx +79 -0
- package/dist/components/tab.jsx +3 -2
- package/dist/components/tabsContainer.d.ts +4 -1
- package/dist/components/tabsContainer.jsx +7 -3
- package/dist/components/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textField.d.ts +5 -1
- package/dist/components/textField.jsx +7 -3
- package/dist/components/textarea.jsx +3 -18
- package/dist/components/toaster.d.ts +12 -0
- package/dist/components/toaster.jsx +103 -0
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- package/dist/internal/alert.d.ts +4 -0
- package/dist/internal/alert.js +6 -0
- package/dist/internal/autoGrow.d.ts +11 -0
- package/dist/internal/autoGrow.js +28 -0
- package/dist/internal/composer.d.ts +16 -0
- package/dist/internal/composer.js +18 -0
- package/dist/internal/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -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 +38 -1
- package/dist/stories/Alert.stories.d.ts +1 -0
- package/dist/stories/Alert.stories.jsx +16 -0
- package/dist/stories/Button.stories.d.ts +1 -0
- package/dist/stories/Button.stories.jsx +17 -1
- package/dist/stories/Cases.generated.stories.d.ts +82 -0
- package/dist/stories/Cases.generated.stories.jsx +164 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/EmptyBox.stories.d.ts +2 -0
- package/dist/stories/EmptyBox.stories.jsx +16 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/Heading.stories.d.ts +6 -0
- package/dist/stories/Heading.stories.jsx +10 -0
- package/dist/stories/IconButton.stories.d.ts +1 -0
- package/dist/stories/IconButton.stories.jsx +18 -1
- package/dist/stories/LoadingScreen.stories.d.ts +1 -0
- package/dist/stories/LoadingScreen.stories.jsx +8 -0
- package/dist/stories/Menu.stories.d.ts +4 -0
- package/dist/stories/Menu.stories.jsx +46 -1
- package/dist/stories/MenuItem.stories.d.ts +1 -0
- package/dist/stories/MenuItem.stories.jsx +8 -0
- package/dist/stories/Message.stories.d.ts +10 -0
- package/dist/stories/Message.stories.jsx +77 -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 +1 -0
- package/dist/stories/PageComponents.stories.jsx +21 -0
- package/dist/stories/RadioGroup.stories.d.ts +3 -0
- package/dist/stories/RadioGroup.stories.jsx +54 -1
- package/dist/stories/Select.stories.d.ts +1 -0
- package/dist/stories/Select.stories.jsx +14 -0
- package/dist/stories/SourceCard.stories.d.ts +8 -0
- package/dist/stories/SourceCard.stories.jsx +33 -0
- package/dist/stories/StepList.stories.d.ts +8 -0
- package/dist/stories/StepList.stories.jsx +35 -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/stories/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +4 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useState } from 'react';
|
|
12
|
+
import Message from '../../components/message';
|
|
13
|
+
import UserImage from '../../components/userImage';
|
|
14
|
+
import TimeStamp from '../../components/timeStamp';
|
|
15
|
+
import Heading from '../../components/heading';
|
|
16
|
+
import Paragraph from '../../components/paragraph';
|
|
17
|
+
import Composer from '../../components/composer';
|
|
18
|
+
import { Center, Stack } from '../../components/layout';
|
|
19
|
+
// A real app reads this from the session.
|
|
20
|
+
var me = 'Dana Lee';
|
|
21
|
+
var firstThread = [
|
|
22
|
+
{ id: 'm1', from: 'Omar Reyes', at: new Date('2025-01-15T11:38:00Z'), text: 'Is the launch email going out today?' },
|
|
23
|
+
{ id: 'm2', from: me, at: new Date('2025-01-15T11:40:00Z'), text: 'Ben has the final copy. Ben, can you confirm?' },
|
|
24
|
+
];
|
|
25
|
+
export default function TypingAndStatusLine() {
|
|
26
|
+
var _a = useState(firstThread), thread = _a[0], setThread = _a[1];
|
|
27
|
+
var _b = useState(''), text = _b[0], setText = _b[1];
|
|
28
|
+
function send() {
|
|
29
|
+
// A real app sends the message to the server here and shows it at once.
|
|
30
|
+
setThread(function (rows) { return __spreadArray(__spreadArray([], rows, true), [{ id: "m".concat(rows.length + 1), from: me, at: new Date(), text: text.trim() }], false); });
|
|
31
|
+
setText('');
|
|
32
|
+
}
|
|
33
|
+
return (<Center width="page">
|
|
34
|
+
<Stack gap="large">
|
|
35
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
36
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
37
|
+
<Stack gap="small">
|
|
38
|
+
{thread.map(function (m) { return (<Message key={m.id} aria-label={m.from} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>}>
|
|
39
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
40
|
+
</Message>); })}
|
|
41
|
+
</Stack>
|
|
42
|
+
<Stack gap="small">
|
|
43
|
+
{/* One person typing. Two: 'Ben and Omar are typing…'. Three or more: 'Ben and 2 others are typing…'.
|
|
44
|
+
A real app removes the line a few seconds after the last keystroke. It is not a live region. */}
|
|
45
|
+
<Paragraph size="caption" tone="secondary" measure="none">Ben is typing…</Paragraph>
|
|
46
|
+
<Composer id="typing-and-status-message" aria-label="Message" placeholder="Message the team" value={text} onChange={setText} onSubmit={send}/>
|
|
47
|
+
</Stack>
|
|
48
|
+
</Stack>
|
|
49
|
+
</Center>);
|
|
50
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Typing line
|
|
2
|
+
|
|
3
|
+
Other people in the thread are writing a message that has not arrived yet.
|
|
4
|
+
|
|
5
|
+
**Not built yet:** Scindo on the web names people by their full name and ends the line with three dots.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Show one line just above the Composer, in small secondary text: `<Paragraph size="caption" tone="secondary">`.
|
|
10
|
+
- Name one person by first name: 'Ben is typing…'.
|
|
11
|
+
- Name two people: 'Ben and Omar are typing…'.
|
|
12
|
+
- Name the first person and count the rest when three or more type: 'Ben and 2 others are typing…'.
|
|
13
|
+
- End the line with an ellipsis, one character.
|
|
14
|
+
- Remove the line a few seconds after the last keystroke, or when the message arrives.
|
|
15
|
+
- Leave out the person who is reading.
|
|
16
|
+
- Show an agent at work with its progress row, not as typing. The case 'Agent at work' has the pattern.
|
|
17
|
+
- Keep the line out of a live region. It changes too often to read aloud.
|
|
18
|
+
|
|
19
|
+
## Don't
|
|
20
|
+
|
|
21
|
+
- Do not say an agent is typing.
|
|
22
|
+
- Do not list every name when three or more people type.
|
|
23
|
+
|
|
24
|
+
## Example: Line above the composer
|
|
25
|
+
|
|
26
|
+
Uses: `Center`, `Composer`, `Heading`, `Message`, `Paragraph`, `Stack`, `TimeStamp`, `UserImage`
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
'use client';
|
|
30
|
+
import { useState } from 'react';
|
|
31
|
+
import Message from 'oneslash-design-system/components/message';
|
|
32
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
33
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
34
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
35
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
36
|
+
import Composer from 'oneslash-design-system/components/composer';
|
|
37
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
38
|
+
|
|
39
|
+
// A real app reads this from the session.
|
|
40
|
+
const me = 'Dana Lee';
|
|
41
|
+
|
|
42
|
+
type Row = { id: string; from: string; at: Date; text: string };
|
|
43
|
+
|
|
44
|
+
const firstThread: Row[] = [
|
|
45
|
+
{ id: 'm1', from: 'Omar Reyes', at: new Date('2025-01-15T11:38:00Z'), text: 'Is the launch email going out today?' },
|
|
46
|
+
{ id: 'm2', from: me, at: new Date('2025-01-15T11:40:00Z'), text: 'Ben has the final copy. Ben, can you confirm?' },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
export default function TypingAndStatusLine() {
|
|
50
|
+
const [thread, setThread] = useState(firstThread);
|
|
51
|
+
const [text, setText] = useState('');
|
|
52
|
+
|
|
53
|
+
function send() {
|
|
54
|
+
// A real app sends the message to the server here and shows it at once.
|
|
55
|
+
setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);
|
|
56
|
+
setText('');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Center width="page">
|
|
61
|
+
<Stack gap="large">
|
|
62
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
63
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
64
|
+
<Stack gap="small">
|
|
65
|
+
{thread.map((m) => (
|
|
66
|
+
<Message
|
|
67
|
+
key={m.id}
|
|
68
|
+
aria-label={m.from}
|
|
69
|
+
avatar={<UserImage userHandle={m.from} decorative />}
|
|
70
|
+
name={m.from}
|
|
71
|
+
meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
|
|
72
|
+
>
|
|
73
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
74
|
+
</Message>
|
|
75
|
+
))}
|
|
76
|
+
</Stack>
|
|
77
|
+
<Stack gap="small">
|
|
78
|
+
{/* One person typing. Two: 'Ben and Omar are typing…'. Three or more: 'Ben and 2 others are typing…'.
|
|
79
|
+
A real app removes the line a few seconds after the last keystroke. It is not a live region. */}
|
|
80
|
+
<Paragraph size="caption" tone="secondary" measure="none">Ben is typing…</Paragraph>
|
|
81
|
+
<Composer
|
|
82
|
+
id="typing-and-status-message"
|
|
83
|
+
aria-label="Message"
|
|
84
|
+
placeholder="Message the team"
|
|
85
|
+
value={text}
|
|
86
|
+
onChange={setText}
|
|
87
|
+
onSubmit={send}
|
|
88
|
+
/>
|
|
89
|
+
</Stack>
|
|
90
|
+
</Stack>
|
|
91
|
+
</Center>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function UnsavedChangesDiscard(): import("react").JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useEffect, useRef, useState } from 'react';
|
|
12
|
+
import Modal from '../../components/modal';
|
|
13
|
+
import Surface from '../../components/surface';
|
|
14
|
+
import Heading from '../../components/heading';
|
|
15
|
+
import Paragraph from '../../components/paragraph';
|
|
16
|
+
import TextField from '../../components/textField';
|
|
17
|
+
import Button from '../../components/button';
|
|
18
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
19
|
+
export default function UnsavedChangesDiscard() {
|
|
20
|
+
var _a = useState([]), replies = _a[0], setReplies = _a[1];
|
|
21
|
+
var _b = useState(true), writing = _b[0], setWriting = _b[1];
|
|
22
|
+
var _c = useState('Friday works for me. I will move the review to Thursday.'), draft = _c[0], setDraft = _c[1];
|
|
23
|
+
// Opens on the question, as if the person just chose Cancel with a reply written.
|
|
24
|
+
var _d = useState(true), asking = _d[0], setAsking = _d[1];
|
|
25
|
+
var _e = useState(false), posting = _e[0], setPosting = _e[1];
|
|
26
|
+
var timer = useRef();
|
|
27
|
+
// Gives each posted reply its own key, even when two read the same.
|
|
28
|
+
var nextId = useRef(1);
|
|
29
|
+
// Stops the request if the example goes away before it ends.
|
|
30
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
31
|
+
// With nothing written, Cancel closes at once.
|
|
32
|
+
function handleCancelReply() {
|
|
33
|
+
if (draft.trim())
|
|
34
|
+
setAsking(true);
|
|
35
|
+
else
|
|
36
|
+
setWriting(false);
|
|
37
|
+
}
|
|
38
|
+
function handleDiscard() {
|
|
39
|
+
setAsking(false);
|
|
40
|
+
setWriting(false);
|
|
41
|
+
setDraft('');
|
|
42
|
+
}
|
|
43
|
+
function handlePost() {
|
|
44
|
+
var text = draft.trim();
|
|
45
|
+
if (posting || !text)
|
|
46
|
+
return;
|
|
47
|
+
setPosting(true);
|
|
48
|
+
// Stands in for the request to the server.
|
|
49
|
+
timer.current = setTimeout(function () {
|
|
50
|
+
setPosting(false);
|
|
51
|
+
var id = nextId.current++;
|
|
52
|
+
setReplies(function (list) { return __spreadArray(__spreadArray([], list, true), [{ id: id, text: text }], false); });
|
|
53
|
+
setDraft('');
|
|
54
|
+
setWriting(false);
|
|
55
|
+
}, 1200);
|
|
56
|
+
}
|
|
57
|
+
return (<Center width="page">
|
|
58
|
+
<Surface padding="large">
|
|
59
|
+
<Stack gap="medium">
|
|
60
|
+
<Heading level={2} size="h6">Dana Lee</Heading>
|
|
61
|
+
<Paragraph size="body2" measure="none">Can we move the launch to Friday?</Paragraph>
|
|
62
|
+
{replies.map(function (reply) { return (<Paragraph key={reply.id} tone="secondary" size="body2" measure="none">You: {reply.text}</Paragraph>); })}
|
|
63
|
+
{writing ? (<>
|
|
64
|
+
<TextField id="unsaved-changes-guard-reply" label="Reply" multiline maxRows={3} value={draft} onChange={function (e) { return setDraft(e.target.value); }}/>
|
|
65
|
+
<Cluster gap="small">
|
|
66
|
+
<Button size="small" type="tertiary" state={posting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancelReply}/>
|
|
67
|
+
<Button size="small" type="primary" state={draft.trim() ? 'enabled' : 'disabled'} label="Reply" loading={posting} onClickButton={handlePost}/>
|
|
68
|
+
</Cluster>
|
|
69
|
+
</>) : (<Cluster>
|
|
70
|
+
<Button size="small" type="secondary" state="enabled" label="Reply" onClickButton={function () { return setWriting(true); }}/>
|
|
71
|
+
</Cluster>)}
|
|
72
|
+
</Stack>
|
|
73
|
+
</Surface>
|
|
74
|
+
<Modal isOpen={asking} size="small" title="Discard Reply" onClose={function () { return setAsking(false); }} actions={<>
|
|
75
|
+
<Button size="small" type="tertiary" state="enabled" label="Keep Editing" onClickButton={function () { return setAsking(false); }}/>
|
|
76
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Discard" onClickButton={handleDiscard}/>
|
|
77
|
+
</>}>
|
|
78
|
+
<Paragraph measure="none">Your reply to Dana is not posted. If you discard it, it is gone.</Paragraph>
|
|
79
|
+
</Modal>
|
|
80
|
+
</Center>);
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function UnsavedChangesSaveOrDiscard(): import("react").JSX.Element;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import TextField from '../../components/textField';
|
|
7
|
+
import Button from '../../components/button';
|
|
8
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
9
|
+
var savedText = 'Ship the new onboarding in October.';
|
|
10
|
+
export default function UnsavedChangesSaveOrDiscard() {
|
|
11
|
+
var _a = useState(savedText), saved = _a[0], setSaved = _a[1];
|
|
12
|
+
var _b = useState('Ship the new onboarding in October. Hire two designers by November.'), draft = _b[0], setDraft = _b[1];
|
|
13
|
+
var _c = useState(true), editorOpen = _c[0], setEditorOpen = _c[1];
|
|
14
|
+
// Opens on the question, as if the person just chose Close with changes not saved.
|
|
15
|
+
var _d = useState(true), asking = _d[0], setAsking = _d[1];
|
|
16
|
+
var _e = useState(false), saving = _e[0], setSaving = _e[1];
|
|
17
|
+
var timer = useRef();
|
|
18
|
+
// Stops the request if the example goes away before it ends.
|
|
19
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
20
|
+
var changed = draft !== saved;
|
|
21
|
+
function handleOpenEditor() {
|
|
22
|
+
setDraft(saved);
|
|
23
|
+
setEditorOpen(true);
|
|
24
|
+
}
|
|
25
|
+
// With nothing changed, Close closes at once.
|
|
26
|
+
function handleCloseEditor() {
|
|
27
|
+
if (changed)
|
|
28
|
+
setAsking(true);
|
|
29
|
+
else
|
|
30
|
+
setEditorOpen(false);
|
|
31
|
+
}
|
|
32
|
+
// Escape, a click outside and Cancel all keep the person editing, except while the save runs.
|
|
33
|
+
function handleCancel() {
|
|
34
|
+
if (saving)
|
|
35
|
+
return;
|
|
36
|
+
setAsking(false);
|
|
37
|
+
}
|
|
38
|
+
function handleDontSave() {
|
|
39
|
+
if (saving)
|
|
40
|
+
return;
|
|
41
|
+
setAsking(false);
|
|
42
|
+
setEditorOpen(false);
|
|
43
|
+
}
|
|
44
|
+
function handleSave() {
|
|
45
|
+
if (saving)
|
|
46
|
+
return;
|
|
47
|
+
setSaving(true);
|
|
48
|
+
// Stands in for the request to the server.
|
|
49
|
+
timer.current = setTimeout(function () {
|
|
50
|
+
setSaving(false);
|
|
51
|
+
setSaved(draft);
|
|
52
|
+
setAsking(false);
|
|
53
|
+
setEditorOpen(false);
|
|
54
|
+
}, 1200);
|
|
55
|
+
}
|
|
56
|
+
if (!editorOpen) {
|
|
57
|
+
return (<Center width="page">
|
|
58
|
+
<Stack gap="medium">
|
|
59
|
+
<Heading level={1} size="h5">Documents</Heading>
|
|
60
|
+
<Paragraph size="body2" measure="none">Q3 plan: {saved}</Paragraph>
|
|
61
|
+
<Cluster>
|
|
62
|
+
<Button size="small" type="secondary" state="enabled" label="Open Q3 Plan" onClickButton={handleOpenEditor}/>
|
|
63
|
+
</Cluster>
|
|
64
|
+
</Stack>
|
|
65
|
+
</Center>);
|
|
66
|
+
}
|
|
67
|
+
return (<Center width="page">
|
|
68
|
+
<Stack gap="medium">
|
|
69
|
+
<Heading level={1} size="h5">Q3 plan</Heading>
|
|
70
|
+
<TextField id="unsaved-changes-guard-body" label="Plan" multiline maxRows={4} value={draft} onChange={function (e) { return setDraft(e.target.value); }}/>
|
|
71
|
+
<Cluster gap="small">
|
|
72
|
+
<Button size="small" type="tertiary" state="enabled" label="Close Draft" onClickButton={handleCloseEditor}/>
|
|
73
|
+
</Cluster>
|
|
74
|
+
</Stack>
|
|
75
|
+
<Modal isOpen={asking} size="small" title="Save Changes" onClose={handleCancel} actions={<>
|
|
76
|
+
{/* The safe choice first, the main action last, as in every confirm. */}
|
|
77
|
+
<Button size="small" type="tertiary" state={saving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel}/>
|
|
78
|
+
<Button size="small" type="secondary" state={saving ? 'disabled' : 'enabled'} label="Don't Save" onClickButton={handleDontSave}/>
|
|
79
|
+
<Button size="small" type="primary" state="enabled" label="Save" loading={saving} onClickButton={handleSave}/>
|
|
80
|
+
</>}>
|
|
81
|
+
<Paragraph measure="none">You changed 'Q3 plan' and did not save it.</Paragraph>
|
|
82
|
+
<Paragraph tone="secondary" size="body2" measure="none">If you do not save, your changes are lost.</Paragraph>
|
|
83
|
+
</Modal>
|
|
84
|
+
</Center>);
|
|
85
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Unsaved changes
|
|
2
|
+
|
|
3
|
+
A person closes or leaves something they changed and did not save.
|
|
4
|
+
|
|
5
|
+
**Not built yet:** Scindo on the web guards no unsaved changes. It drops the changes to a document when the person chooses Cancel, with no question.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Ask only when there are changes. With nothing changed, close at once.
|
|
10
|
+
- Title the Modal with the action it offers, such as 'Save Changes' or 'Discard Reply', and name the thing in the body.
|
|
11
|
+
- Put 'Cancel' first, then 'Don't Save', then 'Save'. As in every confirm, the safe choice comes first and the main action last.
|
|
12
|
+
- Make 'Cancel' tertiary, 'Don't Save' secondary and 'Save' primary, all `size="small"`.
|
|
13
|
+
- Offer 'Keep Editing' and a danger 'Discard' when the product cannot save. 'Keep Editing' comes first.
|
|
14
|
+
- Disable 'Cancel' and 'Don't Save' while 'Save' runs, and leave only when the save works.
|
|
15
|
+
|
|
16
|
+
## Don't
|
|
17
|
+
|
|
18
|
+
- Do not ask when nothing changed.
|
|
19
|
+
- Do not leave when the save fails. Keep the changes on screen.
|
|
20
|
+
- Do not label the choices 'Yes' and 'No'.
|
|
21
|
+
- Do not title the Modal 'Are you sure?'.
|
|
22
|
+
|
|
23
|
+
## Option: Save or discard
|
|
24
|
+
|
|
25
|
+
Use when: The product can save the changes for the person, such as an edited document.
|
|
26
|
+
|
|
27
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`, `TextField`
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
'use client';
|
|
31
|
+
import { useEffect, useRef, useState } from 'react';
|
|
32
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
33
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
34
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
35
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
36
|
+
import Button from 'oneslash-design-system/components/button';
|
|
37
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
38
|
+
|
|
39
|
+
const savedText = 'Ship the new onboarding in October.';
|
|
40
|
+
|
|
41
|
+
export default function UnsavedChangesSaveOrDiscard() {
|
|
42
|
+
const [saved, setSaved] = useState(savedText);
|
|
43
|
+
const [draft, setDraft] = useState('Ship the new onboarding in October. Hire two designers by November.');
|
|
44
|
+
const [editorOpen, setEditorOpen] = useState(true);
|
|
45
|
+
// Opens on the question, as if the person just chose Close with changes not saved.
|
|
46
|
+
const [asking, setAsking] = useState(true);
|
|
47
|
+
const [saving, setSaving] = useState(false);
|
|
48
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
49
|
+
|
|
50
|
+
// Stops the request if the example goes away before it ends.
|
|
51
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
52
|
+
|
|
53
|
+
const changed = draft !== saved;
|
|
54
|
+
|
|
55
|
+
function handleOpenEditor() {
|
|
56
|
+
setDraft(saved);
|
|
57
|
+
setEditorOpen(true);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// With nothing changed, Close closes at once.
|
|
61
|
+
function handleCloseEditor() {
|
|
62
|
+
if (changed) setAsking(true);
|
|
63
|
+
else setEditorOpen(false);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Escape, a click outside and Cancel all keep the person editing, except while the save runs.
|
|
67
|
+
function handleCancel() {
|
|
68
|
+
if (saving) return;
|
|
69
|
+
setAsking(false);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleDontSave() {
|
|
73
|
+
if (saving) return;
|
|
74
|
+
setAsking(false);
|
|
75
|
+
setEditorOpen(false);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function handleSave() {
|
|
79
|
+
if (saving) return;
|
|
80
|
+
setSaving(true);
|
|
81
|
+
// Stands in for the request to the server.
|
|
82
|
+
timer.current = setTimeout(() => {
|
|
83
|
+
setSaving(false);
|
|
84
|
+
setSaved(draft);
|
|
85
|
+
setAsking(false);
|
|
86
|
+
setEditorOpen(false);
|
|
87
|
+
}, 1200);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!editorOpen) {
|
|
91
|
+
return (
|
|
92
|
+
<Center width="page">
|
|
93
|
+
<Stack gap="medium">
|
|
94
|
+
<Heading level={1} size="h5">Documents</Heading>
|
|
95
|
+
<Paragraph size="body2" measure="none">Q3 plan: {saved}</Paragraph>
|
|
96
|
+
<Cluster>
|
|
97
|
+
<Button size="small" type="secondary" state="enabled" label="Open Q3 Plan" onClickButton={handleOpenEditor} />
|
|
98
|
+
</Cluster>
|
|
99
|
+
</Stack>
|
|
100
|
+
</Center>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
return (
|
|
105
|
+
<Center width="page">
|
|
106
|
+
<Stack gap="medium">
|
|
107
|
+
<Heading level={1} size="h5">Q3 plan</Heading>
|
|
108
|
+
<TextField id="unsaved-changes-guard-body" label="Plan" multiline maxRows={4} value={draft} onChange={(e) => setDraft(e.target.value)} />
|
|
109
|
+
<Cluster gap="small">
|
|
110
|
+
<Button size="small" type="tertiary" state="enabled" label="Close Draft" onClickButton={handleCloseEditor} />
|
|
111
|
+
</Cluster>
|
|
112
|
+
</Stack>
|
|
113
|
+
<Modal
|
|
114
|
+
isOpen={asking}
|
|
115
|
+
size="small"
|
|
116
|
+
title="Save Changes"
|
|
117
|
+
onClose={handleCancel}
|
|
118
|
+
actions={
|
|
119
|
+
<>
|
|
120
|
+
{/* The safe choice first, the main action last, as in every confirm. */}
|
|
121
|
+
<Button size="small" type="tertiary" state={saving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancel} />
|
|
122
|
+
<Button size="small" type="secondary" state={saving ? 'disabled' : 'enabled'} label="Don't Save" onClickButton={handleDontSave} />
|
|
123
|
+
<Button size="small" type="primary" state="enabled" label="Save" loading={saving} onClickButton={handleSave} />
|
|
124
|
+
</>
|
|
125
|
+
}
|
|
126
|
+
>
|
|
127
|
+
<Paragraph measure="none">You changed 'Q3 plan' and did not save it.</Paragraph>
|
|
128
|
+
<Paragraph tone="secondary" size="body2" measure="none">If you do not save, your changes are lost.</Paragraph>
|
|
129
|
+
</Modal>
|
|
130
|
+
</Center>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Option: Discard or keep editing
|
|
136
|
+
|
|
137
|
+
Use when: The product cannot save for the person, such as a reply that only posts when they say so.
|
|
138
|
+
|
|
139
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`, `Surface`, `TextField`
|
|
140
|
+
|
|
141
|
+
```tsx
|
|
142
|
+
'use client';
|
|
143
|
+
import { useEffect, useRef, useState } from 'react';
|
|
144
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
145
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
146
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
147
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
148
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
149
|
+
import Button from 'oneslash-design-system/components/button';
|
|
150
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
151
|
+
|
|
152
|
+
export default function UnsavedChangesDiscard() {
|
|
153
|
+
const [replies, setReplies] = useState<{ id: number; text: string }[]>([]);
|
|
154
|
+
const [writing, setWriting] = useState(true);
|
|
155
|
+
const [draft, setDraft] = useState('Friday works for me. I will move the review to Thursday.');
|
|
156
|
+
// Opens on the question, as if the person just chose Cancel with a reply written.
|
|
157
|
+
const [asking, setAsking] = useState(true);
|
|
158
|
+
const [posting, setPosting] = useState(false);
|
|
159
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
160
|
+
// Gives each posted reply its own key, even when two read the same.
|
|
161
|
+
const nextId = useRef(1);
|
|
162
|
+
|
|
163
|
+
// Stops the request if the example goes away before it ends.
|
|
164
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
165
|
+
|
|
166
|
+
// With nothing written, Cancel closes at once.
|
|
167
|
+
function handleCancelReply() {
|
|
168
|
+
if (draft.trim()) setAsking(true);
|
|
169
|
+
else setWriting(false);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function handleDiscard() {
|
|
173
|
+
setAsking(false);
|
|
174
|
+
setWriting(false);
|
|
175
|
+
setDraft('');
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function handlePost() {
|
|
179
|
+
const text = draft.trim();
|
|
180
|
+
if (posting || !text) return;
|
|
181
|
+
setPosting(true);
|
|
182
|
+
// Stands in for the request to the server.
|
|
183
|
+
timer.current = setTimeout(() => {
|
|
184
|
+
setPosting(false);
|
|
185
|
+
const id = nextId.current++;
|
|
186
|
+
setReplies((list) => [...list, { id, text }]);
|
|
187
|
+
setDraft('');
|
|
188
|
+
setWriting(false);
|
|
189
|
+
}, 1200);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return (
|
|
193
|
+
<Center width="page">
|
|
194
|
+
<Surface padding="large">
|
|
195
|
+
<Stack gap="medium">
|
|
196
|
+
<Heading level={2} size="h6">Dana Lee</Heading>
|
|
197
|
+
<Paragraph size="body2" measure="none">Can we move the launch to Friday?</Paragraph>
|
|
198
|
+
{replies.map((reply) => (
|
|
199
|
+
<Paragraph key={reply.id} tone="secondary" size="body2" measure="none">You: {reply.text}</Paragraph>
|
|
200
|
+
))}
|
|
201
|
+
{writing ? (
|
|
202
|
+
<>
|
|
203
|
+
<TextField id="unsaved-changes-guard-reply" label="Reply" multiline maxRows={3} value={draft} onChange={(e) => setDraft(e.target.value)} />
|
|
204
|
+
<Cluster gap="small">
|
|
205
|
+
<Button size="small" type="tertiary" state={posting ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleCancelReply} />
|
|
206
|
+
<Button size="small" type="primary" state={draft.trim() ? 'enabled' : 'disabled'} label="Reply" loading={posting} onClickButton={handlePost} />
|
|
207
|
+
</Cluster>
|
|
208
|
+
</>
|
|
209
|
+
) : (
|
|
210
|
+
<Cluster>
|
|
211
|
+
<Button size="small" type="secondary" state="enabled" label="Reply" onClickButton={() => setWriting(true)} />
|
|
212
|
+
</Cluster>
|
|
213
|
+
)}
|
|
214
|
+
</Stack>
|
|
215
|
+
</Surface>
|
|
216
|
+
<Modal
|
|
217
|
+
isOpen={asking}
|
|
218
|
+
size="small"
|
|
219
|
+
title="Discard Reply"
|
|
220
|
+
onClose={() => setAsking(false)}
|
|
221
|
+
actions={
|
|
222
|
+
<>
|
|
223
|
+
<Button size="small" type="tertiary" state="enabled" label="Keep Editing" onClickButton={() => setAsking(false)} />
|
|
224
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Discard" onClickButton={handleDiscard} />
|
|
225
|
+
</>
|
|
226
|
+
}
|
|
227
|
+
>
|
|
228
|
+
<Paragraph measure="none">Your reply to Dana is not posted. If you discard it, it is gone.</Paragraph>
|
|
229
|
+
</Modal>
|
|
230
|
+
</Center>
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Native
|
|
236
|
+
|
|
237
|
+
On macOS a document window that closes with changes asks with the system alert: 'Save', 'Don't Save' and 'Cancel'. When the product cannot save, use a `confirmationDialog` with 'Discard' in the `.destructive` role and 'Keep Editing' in the `.cancel` role.
|
|
238
|
+
|
|
239
|
+
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function UpgradePromptInline(): import("react").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Surface from '../../components/surface';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import TextField from '../../components/textField';
|
|
7
|
+
import Button from '../../components/button';
|
|
8
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
9
|
+
// A real app passes the router from its framework, such as Next's useRouter().
|
|
10
|
+
var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
|
|
11
|
+
// A real app reads this from the person's role. Only an admin can change the plan.
|
|
12
|
+
var canChangePlan = true;
|
|
13
|
+
var thread = [
|
|
14
|
+
{ id: 'm1', from: 'Dana Lee', text: 'Can you list what is still open for the launch?' },
|
|
15
|
+
{ id: 'm2', from: 'Acme agent', text: 'Three tasks are open: the press kit, the pricing page and the launch email.' },
|
|
16
|
+
{ id: 'm3', from: 'Dana Lee', text: 'Draft the launch email, please.' },
|
|
17
|
+
];
|
|
18
|
+
export default function UpgradePromptInline() {
|
|
19
|
+
// Opens on the notice, as if the workspace just used its last AI agent response of the month.
|
|
20
|
+
var _a = useState(true), showNotice = _a[0], setShowNotice = _a[1];
|
|
21
|
+
return (<Center width="page">
|
|
22
|
+
<Stack gap="large">
|
|
23
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
24
|
+
<Stack gap="medium">
|
|
25
|
+
{thread.map(function (m) { return (<Stack key={m.id} gap="small">
|
|
26
|
+
<Paragraph tone="secondary" size="body2" measure="none">{m.from}</Paragraph>
|
|
27
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
28
|
+
</Stack>); })}
|
|
29
|
+
</Stack>
|
|
30
|
+
{showNotice ? (
|
|
31
|
+
// The notice takes the place of the message box, where the person was about to type.
|
|
32
|
+
<Surface padding="medium">
|
|
33
|
+
<Stack gap="medium">
|
|
34
|
+
<Stack gap="small">
|
|
35
|
+
<Paragraph measure="none">You've used all 50 AI agent responses this month. They start again on December 1.</Paragraph>
|
|
36
|
+
<Paragraph tone="secondary" size="body2" measure="none">
|
|
37
|
+
{canChangePlan
|
|
38
|
+
? 'The Pro plan gives Acme Design 1,000 AI agent responses a month.'
|
|
39
|
+
: 'Ask a workspace admin to upgrade Acme Design to Pro for more replies.'}
|
|
40
|
+
</Paragraph>
|
|
41
|
+
</Stack>
|
|
42
|
+
<Cluster gap="small">
|
|
43
|
+
<Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setShowNotice(false); }}/>
|
|
44
|
+
{canChangePlan && (<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={function () { return router.push('/settings/billing?plan=pro'); }}/>)}
|
|
45
|
+
</Cluster>
|
|
46
|
+
</Stack>
|
|
47
|
+
</Surface>) : (
|
|
48
|
+
// After 'Not Now' the message box comes back, closed until the replies start again.
|
|
49
|
+
<TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="Agent replies start again on December 1." disabled onChange={function () { }}/>)}
|
|
50
|
+
</Stack>
|
|
51
|
+
</Center>);
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function UpgradePromptModal(): import("react").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
8
|
+
// A real app passes the router from its framework, such as Next's useRouter().
|
|
9
|
+
var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
|
|
10
|
+
// A real app reads this from the person's role. Only an admin can change the plan.
|
|
11
|
+
var canChangePlan = true;
|
|
12
|
+
export default function UpgradePromptModal() {
|
|
13
|
+
// Opens on the Modal, as if the person just chose Export PDF.
|
|
14
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
15
|
+
function handleUpgrade() {
|
|
16
|
+
setOpen(false);
|
|
17
|
+
router.push('/settings/billing?plan=pro');
|
|
18
|
+
}
|
|
19
|
+
return (<Center width="page">
|
|
20
|
+
<Stack gap="medium">
|
|
21
|
+
<Heading level={1} size="h5">Q3 plan</Heading>
|
|
22
|
+
<Paragraph tone="secondary" size="body2" measure="none">12 tasks. Updated 2 days ago by Dana Lee.</Paragraph>
|
|
23
|
+
{/* The locked control stays on the page, so the person can find out what unlocks it. */}
|
|
24
|
+
<Cluster gap="small">
|
|
25
|
+
<Button size="small" type="secondary" state="enabled" label="Share"/>
|
|
26
|
+
<Button size="small" type="secondary" state="enabled" label="Export PDF" decoIcon="Lock" onClickButton={function () { return setOpen(true); }}/>
|
|
27
|
+
</Cluster>
|
|
28
|
+
</Stack>
|
|
29
|
+
<Modal isOpen={open} size="small"
|
|
30
|
+
// The title names the action only for a person who can take it.
|
|
31
|
+
title={canChangePlan ? 'Upgrade to Pro' : 'Pro Feature'} onClose={function () { return setOpen(false); }} actions={canChangePlan ? (<>
|
|
32
|
+
<Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setOpen(false); }}/>
|
|
33
|
+
<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={handleUpgrade}/>
|
|
34
|
+
</>) : (<Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setOpen(false); }}/>)}>
|
|
35
|
+
<Paragraph measure="none">Exporting to PDF is part of the Pro plan. Acme Design is on the Free plan.</Paragraph>
|
|
36
|
+
<Paragraph tone="secondary" size="body2" measure="none">
|
|
37
|
+
{canChangePlan
|
|
38
|
+
? 'Pro also adds version history and unlimited guests, for $8 per member each month.'
|
|
39
|
+
: 'Ask a workspace admin to upgrade Acme Design to Pro.'}
|
|
40
|
+
</Paragraph>
|
|
41
|
+
</Modal>
|
|
42
|
+
</Center>);
|
|
43
|
+
}
|