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,134 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
import { useEffect, useRef, useState } from 'react';
|
|
23
|
+
import Message from '../../components/message';
|
|
24
|
+
import UserImage from '../../components/userImage';
|
|
25
|
+
import TimeStamp from '../../components/timeStamp';
|
|
26
|
+
import Heading from '../../components/heading';
|
|
27
|
+
import Paragraph from '../../components/paragraph';
|
|
28
|
+
import Composer from '../../components/composer';
|
|
29
|
+
import FileChip from '../../components/fileChip';
|
|
30
|
+
import IconButton from '../../components/iconButton';
|
|
31
|
+
import Tooltip from '../../components/tooltip';
|
|
32
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
33
|
+
// A real app reads this from the session.
|
|
34
|
+
var me = 'Dana Lee';
|
|
35
|
+
var MAX_FILES = 5;
|
|
36
|
+
var firstThread = [
|
|
37
|
+
{ id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'Can someone send the launch assets?' },
|
|
38
|
+
{ id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Dana has the final versions.' },
|
|
39
|
+
];
|
|
40
|
+
// Opens with one file ready, one still uploading and one the server refused.
|
|
41
|
+
var firstFiles = [
|
|
42
|
+
{ id: 'f1', name: 'Launch brief.pdf', kind: 'PDF', size: '1.2 MB', state: 'ready' },
|
|
43
|
+
{ id: 'f2', name: 'Hero image.png', kind: 'PNG', size: '3.4 MB', state: 'uploading' },
|
|
44
|
+
{ id: 'f3', name: 'Product video.mov', kind: 'MOV', size: '48 MB', state: 'failed', error: 'Too large. The limit is 25 MB.' },
|
|
45
|
+
];
|
|
46
|
+
// What the attach button adds, in turn. A real app opens the file picker.
|
|
47
|
+
var sampleFiles = [
|
|
48
|
+
{ name: 'Press list.xlsx', kind: 'XLSX', size: '48 KB' },
|
|
49
|
+
{ name: 'Pricing sheet.pdf', kind: 'PDF', size: '320 KB' },
|
|
50
|
+
{ name: 'Logo.svg', kind: 'SVG', size: '12 KB' },
|
|
51
|
+
];
|
|
52
|
+
// Where a sent file opens. A real app links to the stored file.
|
|
53
|
+
var fileHref = function (name) { return "/files/".concat(name.toLowerCase().replace(/\s+/g, '-')); };
|
|
54
|
+
// The line that says why sending is blocked. The message box points at it with aria-describedby.
|
|
55
|
+
var blockedId = 'message-attachments-send-blocked';
|
|
56
|
+
var FIVE_MINUTES = 5 * 60 * 1000;
|
|
57
|
+
// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.
|
|
58
|
+
function followsOn(rows, i) {
|
|
59
|
+
var prev = rows[i - 1];
|
|
60
|
+
return (!!prev &&
|
|
61
|
+
prev.from === rows[i].from &&
|
|
62
|
+
rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&
|
|
63
|
+
rows[i].at.toDateString() === prev.at.toDateString());
|
|
64
|
+
}
|
|
65
|
+
export default function MessageAttachmentsInComposer() {
|
|
66
|
+
var _a = useState(firstThread), thread = _a[0], setThread = _a[1];
|
|
67
|
+
var _b = useState(''), text = _b[0], setText = _b[1];
|
|
68
|
+
var _c = useState(firstFiles), files = _c[0], setFiles = _c[1];
|
|
69
|
+
var added = useRef(0);
|
|
70
|
+
var timers = useRef([]);
|
|
71
|
+
var field = useRef(null);
|
|
72
|
+
// On unmount it stops every upload still running.
|
|
73
|
+
useEffect(function () { return function () {
|
|
74
|
+
timers.current.forEach(function (t) { return clearTimeout(t); });
|
|
75
|
+
timers.current = [];
|
|
76
|
+
}; }, []);
|
|
77
|
+
var atLimit = files.length >= MAX_FILES;
|
|
78
|
+
var uploading = files.some(function (f) { return f.state === 'uploading'; });
|
|
79
|
+
var failed = files.find(function (f) { return f.state === 'failed'; });
|
|
80
|
+
var blockedReason = failed ? "Remove ".concat(failed.name, " to send.") : uploading ? 'Wait for the upload to finish, then send.' : null;
|
|
81
|
+
function attach() {
|
|
82
|
+
if (atLimit)
|
|
83
|
+
return;
|
|
84
|
+
var sample = sampleFiles[added.current % sampleFiles.length];
|
|
85
|
+
var id = "a".concat(added.current + 1);
|
|
86
|
+
added.current += 1;
|
|
87
|
+
setFiles(function (list) { return __spreadArray(__spreadArray([], list, true), [__assign(__assign({}, sample), { id: id, state: 'uploading' })], false); });
|
|
88
|
+
// Stands in for the request to the server.
|
|
89
|
+
timers.current.push(setTimeout(function () {
|
|
90
|
+
setFiles(function (list) { return list.map(function (f) { return (f.id === id ? __assign(__assign({}, f), { state: 'ready' }) : f); }); });
|
|
91
|
+
}, 1200));
|
|
92
|
+
}
|
|
93
|
+
// The chip that had focus is gone. A real app moves focus to the next chip, or to the message box when
|
|
94
|
+
// none is left. FileChip does not pass a ref to its remove button, so this example always uses the message box.
|
|
95
|
+
function remove(id) {
|
|
96
|
+
var _a;
|
|
97
|
+
setFiles(function (list) { return list.filter(function (f) { return f.id !== id; }); });
|
|
98
|
+
(_a = field.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
99
|
+
}
|
|
100
|
+
// The Composer calls this only when canSubmit is true: no upload running, none failed.
|
|
101
|
+
function send() {
|
|
102
|
+
// A real app sends the message to the server here and shows it at once.
|
|
103
|
+
setThread(function (rows) { return __spreadArray(__spreadArray([], rows, true), [{ id: "m".concat(rows.length + 1), from: me, at: new Date(), text: text.trim(), files: files }], false); });
|
|
104
|
+
setText('');
|
|
105
|
+
setFiles([]);
|
|
106
|
+
}
|
|
107
|
+
return (<Center width="page">
|
|
108
|
+
<Stack gap="large">
|
|
109
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
110
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
111
|
+
<Stack gap="small">
|
|
112
|
+
{thread.map(function (m, i) { return (<Message key={m.id} aria-label={m.from} compact={followsOn(thread, i)} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>} footer={m.files && m.files.length > 0 ? (<Cluster gap="small">
|
|
113
|
+
{m.files.map(function (f) { return (
|
|
114
|
+
// A sent file opens when its chip is pressed.
|
|
115
|
+
<FileChip key={f.id} name={f.name} kind={f.kind} meta={f.size} href={fileHref(f.name)} openInNewTab/>); })}
|
|
116
|
+
</Cluster>) : undefined}>
|
|
117
|
+
{m.text && <Paragraph measure="none">{m.text}</Paragraph>}
|
|
118
|
+
</Message>); })}
|
|
119
|
+
</Stack>
|
|
120
|
+
<Composer ref={field} id="message-attachments-message" aria-label="Message" placeholder="Message the team" value={text} onChange={setText} onSubmit={send} aria-describedby={blockedReason ? blockedId : undefined}
|
|
121
|
+
// Files alone can be sent, but not while one uploads or has failed.
|
|
122
|
+
canSubmit={(text.trim() !== '' || files.length > 0) && !uploading && !failed} above={files.length > 0 ? (<Stack gap="small">
|
|
123
|
+
<Cluster gap="small">
|
|
124
|
+
{files.map(function (f) { return (<FileChip key={f.id} name={f.name} kind={f.kind} state={f.state} meta={f.state === 'uploading' ? 'Uploading' : f.state === 'failed' ? f.error : f.size} onRemove={function () { return remove(f.id); }}/>); })}
|
|
125
|
+
</Cluster>
|
|
126
|
+
{/* A real app also says these in a polite live region when they change. */}
|
|
127
|
+
{blockedReason && (<Paragraph id={blockedId} size="caption" tone="secondary" measure="none">{blockedReason}</Paragraph>)}
|
|
128
|
+
{atLimit && (<Paragraph size="caption" tone="secondary" measure="none">{"You can attach up to ".concat(MAX_FILES, " files.")}</Paragraph>)}
|
|
129
|
+
</Stack>) : undefined} tools={<Tooltip title="Attach files">
|
|
130
|
+
<IconButton color="iconOnly" state={atLimit ? 'disabled' : 'enabled'} size="small" iconName="Paperclip" ariaLabel="Attach files" onClick={attach}/>
|
|
131
|
+
</Tooltip>}/>
|
|
132
|
+
</Stack>
|
|
133
|
+
</Center>);
|
|
134
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MessageAttachmentsInMessage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Message from '../../components/message';
|
|
3
|
+
import UserImage from '../../components/userImage';
|
|
4
|
+
import TimeStamp from '../../components/timeStamp';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import FileChip from '../../components/fileChip';
|
|
8
|
+
import Figure from '../../components/figure';
|
|
9
|
+
import Image from '../../components/image';
|
|
10
|
+
import { Center, Cluster, Grid, Stack } from '../../components/layout';
|
|
11
|
+
// Two small drawings stand in for the uploaded photos.
|
|
12
|
+
var hillside = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E";
|
|
13
|
+
var desk = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23efe6da'/%3E%3Crect x='30' y='30' width='100' height='60' rx='6' fill='%23333d47'/%3E%3Crect x='38' y='38' width='84' height='44' rx='2' fill='%2389b4d9'/%3E%3Crect x='20' y='92' width='120' height='6' rx='3' fill='%238a6d4b'/%3E%3C/svg%3E";
|
|
14
|
+
var before = { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'Can someone send the launch assets?' };
|
|
15
|
+
var withFiles = { id: 'm2', from: 'Dana Lee', at: new Date('2025-01-15T11:44:00Z'), text: 'Here are the two hero options and the brief.' };
|
|
16
|
+
export default function MessageAttachmentsInMessage() {
|
|
17
|
+
return (<Center width="page">
|
|
18
|
+
<Stack gap="large">
|
|
19
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
20
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
21
|
+
<Stack gap="small">
|
|
22
|
+
<Message aria-label={before.from} avatar={<UserImage userHandle={before.from} decorative/>} name={before.from} meta={<TimeStamp createdAt={before.at} dateFormat="absolute" data="time"/>}>
|
|
23
|
+
<Paragraph measure="none">{before.text}</Paragraph>
|
|
24
|
+
</Message>
|
|
25
|
+
<Message aria-label={withFiles.from} avatar={<UserImage userHandle={withFiles.from} decorative/>} name={withFiles.from} meta={<TimeStamp createdAt={withFiles.at} dateFormat="absolute" data="time"/>} footer={<Stack gap="small">
|
|
26
|
+
{/* Small thumbnails: four columns, two of them used. A real app opens the full image on click. */}
|
|
27
|
+
<Grid columns={4} compact gap="small">
|
|
28
|
+
<Figure crop={4 / 3} radius="control">
|
|
29
|
+
<Image src={hillside} alt="Hero option A: a green hillside under a pale sky with the sun on the right" width={160} height={120}/>
|
|
30
|
+
</Figure>
|
|
31
|
+
<Figure crop={4 / 3} radius="control">
|
|
32
|
+
<Image src={desk} alt="Hero option B: a laptop on a wooden desk, its screen blue" width={160} height={120}/>
|
|
33
|
+
</Figure>
|
|
34
|
+
</Grid>
|
|
35
|
+
<Cluster gap="small">
|
|
36
|
+
{/* Each chip opens the file. */}
|
|
37
|
+
<FileChip name="Launch brief.pdf" kind="PDF" meta="1.2 MB" href="/files/launch-brief.pdf" openInNewTab/>
|
|
38
|
+
<FileChip name="Press list.xlsx" kind="XLSX" meta="48 KB" href="/files/press-list.xlsx" openInNewTab/>
|
|
39
|
+
</Cluster>
|
|
40
|
+
</Stack>}>
|
|
41
|
+
<Paragraph measure="none">{withFiles.text}</Paragraph>
|
|
42
|
+
</Message>
|
|
43
|
+
</Stack>
|
|
44
|
+
</Stack>
|
|
45
|
+
</Center>);
|
|
46
|
+
}
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
# Attachments
|
|
2
|
+
|
|
3
|
+
A person adds files to a message, and people open the files in a message that was sent.
|
|
4
|
+
|
|
5
|
+
**Not built yet:** No product shows upload progress or a failed upload on the file itself. Scindo on the web shows a rejected file in an error Alert above the field, and its images use the file name as `alt` text.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Show each waiting file as a `FileChip` in the Composer's `above` slot, with `onRemove`.
|
|
10
|
+
- Show a file that is still uploading with `state="uploading"` and the `meta` 'Uploading'.
|
|
11
|
+
- Show a file that cannot be sent with `state="failed"` and the reason in `meta`: 'Too large. The limit is 25 MB.'
|
|
12
|
+
- Pass `onClick` and the `meta` 'Failed. Try again' when the upload can be tried again. A file that is too large can only be removed.
|
|
13
|
+
- Announce when an upload finishes or fails: the app puts the words in a polite live region, since the chip announces nothing.
|
|
14
|
+
- Block sending while a file uploads or has failed, and say why under the chips: 'Wait for the upload to finish, then send.'
|
|
15
|
+
- Give that line an `id`, and point the message box at it with `aria-describedby`, so a screen reader hears why it cannot send.
|
|
16
|
+
- Say the limit in one line under the chips when it is reached: 'You can attach up to 5 files.' Disable the attach button too.
|
|
17
|
+
- Pass `canSubmit` so a message with files and no text can be sent.
|
|
18
|
+
- Keep the files and the text when a send fails. Show an inline error Alert above the message box, as the rule 'A form error shows next to the problem' says.
|
|
19
|
+
- Move focus to the next chip after a chip is removed, or to the message box when none is left, since the chip that had it is gone.
|
|
20
|
+
- Show images in a sent message as thumbnails: a `Grid` of `<Figure crop>` with an `Image` each. Write `alt` text that says what the image shows.
|
|
21
|
+
- Show other files as `FileChip`s that open the file, with the kind ('PDF'), the name and the size.
|
|
22
|
+
- Show a `FileChip` with the file's name in place of an image that fails to load, so the file can still be opened.
|
|
23
|
+
- Let the person open an image at full size. The example shows the thumbnails only.
|
|
24
|
+
|
|
25
|
+
## Don't
|
|
26
|
+
|
|
27
|
+
- Do not show a failed upload only in an Alert away from the file.
|
|
28
|
+
- Do not use the file name as the `alt` text of an image. Say what it shows.
|
|
29
|
+
- Do not send a message while one of its files is still uploading.
|
|
30
|
+
- Do not clear the waiting files when a send is blocked.
|
|
31
|
+
|
|
32
|
+
## Option: In the composer
|
|
33
|
+
|
|
34
|
+
Use when: Files are waiting to be sent with the next message.
|
|
35
|
+
|
|
36
|
+
Uses: `Center`, `Cluster`, `Composer`, `FileChip`, `Heading`, `IconButton`, `Message`, `Paragraph`, `Stack`, `TimeStamp`, `Tooltip`, `UserImage`
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
'use client';
|
|
40
|
+
import { useEffect, useRef, useState } from 'react';
|
|
41
|
+
import Message from 'oneslash-design-system/components/message';
|
|
42
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
43
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
44
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
45
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
46
|
+
import Composer from 'oneslash-design-system/components/composer';
|
|
47
|
+
import FileChip from 'oneslash-design-system/components/fileChip';
|
|
48
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
49
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
50
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
51
|
+
|
|
52
|
+
// A real app reads this from the session.
|
|
53
|
+
const me = 'Dana Lee';
|
|
54
|
+
const MAX_FILES = 5;
|
|
55
|
+
|
|
56
|
+
type Upload = { id: string; name: string; kind: string; size: string; state: 'ready' | 'uploading' | 'failed'; error?: string };
|
|
57
|
+
type Row = { id: string; from: string; at: Date; text: string; files?: Upload[] };
|
|
58
|
+
|
|
59
|
+
const firstThread: Row[] = [
|
|
60
|
+
{ id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'Can someone send the launch assets?' },
|
|
61
|
+
{ id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Dana has the final versions.' },
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
// Opens with one file ready, one still uploading and one the server refused.
|
|
65
|
+
const firstFiles: Upload[] = [
|
|
66
|
+
{ id: 'f1', name: 'Launch brief.pdf', kind: 'PDF', size: '1.2 MB', state: 'ready' },
|
|
67
|
+
{ id: 'f2', name: 'Hero image.png', kind: 'PNG', size: '3.4 MB', state: 'uploading' },
|
|
68
|
+
{ id: 'f3', name: 'Product video.mov', kind: 'MOV', size: '48 MB', state: 'failed', error: 'Too large. The limit is 25 MB.' },
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
// What the attach button adds, in turn. A real app opens the file picker.
|
|
72
|
+
const sampleFiles = [
|
|
73
|
+
{ name: 'Press list.xlsx', kind: 'XLSX', size: '48 KB' },
|
|
74
|
+
{ name: 'Pricing sheet.pdf', kind: 'PDF', size: '320 KB' },
|
|
75
|
+
{ name: 'Logo.svg', kind: 'SVG', size: '12 KB' },
|
|
76
|
+
];
|
|
77
|
+
|
|
78
|
+
// Where a sent file opens. A real app links to the stored file.
|
|
79
|
+
const fileHref = (name: string) => `/files/${name.toLowerCase().replace(/\s+/g, '-')}`;
|
|
80
|
+
|
|
81
|
+
// The line that says why sending is blocked. The message box points at it with aria-describedby.
|
|
82
|
+
const blockedId = 'message-attachments-send-blocked';
|
|
83
|
+
|
|
84
|
+
const FIVE_MINUTES = 5 * 60 * 1000;
|
|
85
|
+
|
|
86
|
+
// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.
|
|
87
|
+
function followsOn(rows: Row[], i: number) {
|
|
88
|
+
const prev = rows[i - 1];
|
|
89
|
+
return (
|
|
90
|
+
!!prev &&
|
|
91
|
+
prev.from === rows[i].from &&
|
|
92
|
+
rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&
|
|
93
|
+
rows[i].at.toDateString() === prev.at.toDateString()
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default function MessageAttachmentsInComposer() {
|
|
98
|
+
const [thread, setThread] = useState(firstThread);
|
|
99
|
+
const [text, setText] = useState('');
|
|
100
|
+
const [files, setFiles] = useState(firstFiles);
|
|
101
|
+
const added = useRef(0);
|
|
102
|
+
const timers = useRef<ReturnType<typeof setTimeout>[]>([]);
|
|
103
|
+
const field = useRef<HTMLTextAreaElement>(null);
|
|
104
|
+
|
|
105
|
+
// On unmount it stops every upload still running.
|
|
106
|
+
useEffect(() => () => {
|
|
107
|
+
timers.current.forEach((t) => clearTimeout(t));
|
|
108
|
+
timers.current = [];
|
|
109
|
+
}, []);
|
|
110
|
+
|
|
111
|
+
const atLimit = files.length >= MAX_FILES;
|
|
112
|
+
const uploading = files.some((f) => f.state === 'uploading');
|
|
113
|
+
const failed = files.find((f) => f.state === 'failed');
|
|
114
|
+
const blockedReason = failed ? `Remove ${failed.name} to send.` : uploading ? 'Wait for the upload to finish, then send.' : null;
|
|
115
|
+
|
|
116
|
+
function attach() {
|
|
117
|
+
if (atLimit) return;
|
|
118
|
+
const sample = sampleFiles[added.current % sampleFiles.length];
|
|
119
|
+
const id = `a${added.current + 1}`;
|
|
120
|
+
added.current += 1;
|
|
121
|
+
setFiles((list) => [...list, { ...sample, id, state: 'uploading' }]);
|
|
122
|
+
// Stands in for the request to the server.
|
|
123
|
+
timers.current.push(
|
|
124
|
+
setTimeout(() => {
|
|
125
|
+
setFiles((list) => list.map((f) => (f.id === id ? { ...f, state: 'ready' } : f)));
|
|
126
|
+
}, 1200),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// The chip that had focus is gone. A real app moves focus to the next chip, or to the message box when
|
|
131
|
+
// none is left. FileChip does not pass a ref to its remove button, so this example always uses the message box.
|
|
132
|
+
function remove(id: string) {
|
|
133
|
+
setFiles((list) => list.filter((f) => f.id !== id));
|
|
134
|
+
field.current?.focus();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// The Composer calls this only when canSubmit is true: no upload running, none failed.
|
|
138
|
+
function send() {
|
|
139
|
+
// A real app sends the message to the server here and shows it at once.
|
|
140
|
+
setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim(), files }]);
|
|
141
|
+
setText('');
|
|
142
|
+
setFiles([]);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<Center width="page">
|
|
147
|
+
<Stack gap="large">
|
|
148
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
149
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
150
|
+
<Stack gap="small">
|
|
151
|
+
{thread.map((m, i) => (
|
|
152
|
+
<Message
|
|
153
|
+
key={m.id}
|
|
154
|
+
aria-label={m.from}
|
|
155
|
+
compact={followsOn(thread, i)}
|
|
156
|
+
avatar={<UserImage userHandle={m.from} decorative />}
|
|
157
|
+
name={m.from}
|
|
158
|
+
meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
|
|
159
|
+
footer={
|
|
160
|
+
m.files && m.files.length > 0 ? (
|
|
161
|
+
<Cluster gap="small">
|
|
162
|
+
{m.files.map((f) => (
|
|
163
|
+
// A sent file opens when its chip is pressed.
|
|
164
|
+
<FileChip key={f.id} name={f.name} kind={f.kind} meta={f.size} href={fileHref(f.name)} openInNewTab />
|
|
165
|
+
))}
|
|
166
|
+
</Cluster>
|
|
167
|
+
) : undefined
|
|
168
|
+
}
|
|
169
|
+
>
|
|
170
|
+
{m.text && <Paragraph measure="none">{m.text}</Paragraph>}
|
|
171
|
+
</Message>
|
|
172
|
+
))}
|
|
173
|
+
</Stack>
|
|
174
|
+
<Composer
|
|
175
|
+
ref={field}
|
|
176
|
+
id="message-attachments-message"
|
|
177
|
+
aria-label="Message"
|
|
178
|
+
placeholder="Message the team"
|
|
179
|
+
value={text}
|
|
180
|
+
onChange={setText}
|
|
181
|
+
onSubmit={send}
|
|
182
|
+
aria-describedby={blockedReason ? blockedId : undefined}
|
|
183
|
+
// Files alone can be sent, but not while one uploads or has failed.
|
|
184
|
+
canSubmit={(text.trim() !== '' || files.length > 0) && !uploading && !failed}
|
|
185
|
+
above={
|
|
186
|
+
files.length > 0 ? (
|
|
187
|
+
<Stack gap="small">
|
|
188
|
+
<Cluster gap="small">
|
|
189
|
+
{files.map((f) => (
|
|
190
|
+
<FileChip
|
|
191
|
+
key={f.id}
|
|
192
|
+
name={f.name}
|
|
193
|
+
kind={f.kind}
|
|
194
|
+
state={f.state}
|
|
195
|
+
meta={f.state === 'uploading' ? 'Uploading' : f.state === 'failed' ? f.error : f.size}
|
|
196
|
+
onRemove={() => remove(f.id)}
|
|
197
|
+
/>
|
|
198
|
+
))}
|
|
199
|
+
</Cluster>
|
|
200
|
+
{/* A real app also says these in a polite live region when they change. */}
|
|
201
|
+
{blockedReason && (
|
|
202
|
+
<Paragraph id={blockedId} size="caption" tone="secondary" measure="none">{blockedReason}</Paragraph>
|
|
203
|
+
)}
|
|
204
|
+
{atLimit && (
|
|
205
|
+
<Paragraph size="caption" tone="secondary" measure="none">{`You can attach up to ${MAX_FILES} files.`}</Paragraph>
|
|
206
|
+
)}
|
|
207
|
+
</Stack>
|
|
208
|
+
) : undefined
|
|
209
|
+
}
|
|
210
|
+
tools={
|
|
211
|
+
<Tooltip title="Attach files">
|
|
212
|
+
<IconButton
|
|
213
|
+
color="iconOnly"
|
|
214
|
+
state={atLimit ? 'disabled' : 'enabled'}
|
|
215
|
+
size="small"
|
|
216
|
+
iconName="Paperclip"
|
|
217
|
+
ariaLabel="Attach files"
|
|
218
|
+
onClick={attach}
|
|
219
|
+
/>
|
|
220
|
+
</Tooltip>
|
|
221
|
+
}
|
|
222
|
+
/>
|
|
223
|
+
</Stack>
|
|
224
|
+
</Center>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Option: In a sent message
|
|
230
|
+
|
|
231
|
+
Use when: Files are part of a message in the thread.
|
|
232
|
+
|
|
233
|
+
Uses: `Center`, `Cluster`, `Figure`, `FileChip`, `Grid`, `Heading`, `Image`, `Message`, `Paragraph`, `Stack`, `TimeStamp`, `UserImage`
|
|
234
|
+
|
|
235
|
+
```tsx
|
|
236
|
+
'use client';
|
|
237
|
+
import Message from 'oneslash-design-system/components/message';
|
|
238
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
239
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
240
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
241
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
242
|
+
import FileChip from 'oneslash-design-system/components/fileChip';
|
|
243
|
+
import Figure from 'oneslash-design-system/components/figure';
|
|
244
|
+
import Image from 'oneslash-design-system/components/image';
|
|
245
|
+
import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
246
|
+
|
|
247
|
+
// Two small drawings stand in for the uploaded photos.
|
|
248
|
+
const hillside =
|
|
249
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23dfe9f2'/%3E%3Ccircle cx='120' cy='32' r='14' fill='%23f2c46d'/%3E%3Cpath d='M0 90 50 60l40 22 30-18 40 24v32H0z' fill='%232f6b4f'/%3E%3C/svg%3E";
|
|
250
|
+
const desk =
|
|
251
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 120'%3E%3Crect width='160' height='120' fill='%23efe6da'/%3E%3Crect x='30' y='30' width='100' height='60' rx='6' fill='%23333d47'/%3E%3Crect x='38' y='38' width='84' height='44' rx='2' fill='%2389b4d9'/%3E%3Crect x='20' y='92' width='120' height='6' rx='3' fill='%238a6d4b'/%3E%3C/svg%3E";
|
|
252
|
+
|
|
253
|
+
type Row = { id: string; from: string; at: Date; text: string };
|
|
254
|
+
|
|
255
|
+
const before: Row = { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'Can someone send the launch assets?' };
|
|
256
|
+
const withFiles: Row = { id: 'm2', from: 'Dana Lee', at: new Date('2025-01-15T11:44:00Z'), text: 'Here are the two hero options and the brief.' };
|
|
257
|
+
|
|
258
|
+
export default function MessageAttachmentsInMessage() {
|
|
259
|
+
return (
|
|
260
|
+
<Center width="page">
|
|
261
|
+
<Stack gap="large">
|
|
262
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
263
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
264
|
+
<Stack gap="small">
|
|
265
|
+
<Message
|
|
266
|
+
aria-label={before.from}
|
|
267
|
+
avatar={<UserImage userHandle={before.from} decorative />}
|
|
268
|
+
name={before.from}
|
|
269
|
+
meta={<TimeStamp createdAt={before.at} dateFormat="absolute" data="time" />}
|
|
270
|
+
>
|
|
271
|
+
<Paragraph measure="none">{before.text}</Paragraph>
|
|
272
|
+
</Message>
|
|
273
|
+
<Message
|
|
274
|
+
aria-label={withFiles.from}
|
|
275
|
+
avatar={<UserImage userHandle={withFiles.from} decorative />}
|
|
276
|
+
name={withFiles.from}
|
|
277
|
+
meta={<TimeStamp createdAt={withFiles.at} dateFormat="absolute" data="time" />}
|
|
278
|
+
footer={
|
|
279
|
+
<Stack gap="small">
|
|
280
|
+
{/* Small thumbnails: four columns, two of them used. A real app opens the full image on click. */}
|
|
281
|
+
<Grid columns={4} compact gap="small">
|
|
282
|
+
<Figure crop={4 / 3} radius="control">
|
|
283
|
+
<Image src={hillside} alt="Hero option A: a green hillside under a pale sky with the sun on the right" width={160} height={120} />
|
|
284
|
+
</Figure>
|
|
285
|
+
<Figure crop={4 / 3} radius="control">
|
|
286
|
+
<Image src={desk} alt="Hero option B: a laptop on a wooden desk, its screen blue" width={160} height={120} />
|
|
287
|
+
</Figure>
|
|
288
|
+
</Grid>
|
|
289
|
+
<Cluster gap="small">
|
|
290
|
+
{/* Each chip opens the file. */}
|
|
291
|
+
<FileChip name="Launch brief.pdf" kind="PDF" meta="1.2 MB" href="/files/launch-brief.pdf" openInNewTab />
|
|
292
|
+
<FileChip name="Press list.xlsx" kind="XLSX" meta="48 KB" href="/files/press-list.xlsx" openInNewTab />
|
|
293
|
+
</Cluster>
|
|
294
|
+
</Stack>
|
|
295
|
+
}
|
|
296
|
+
>
|
|
297
|
+
<Paragraph measure="none">{withFiles.text}</Paragraph>
|
|
298
|
+
</Message>
|
|
299
|
+
</Stack>
|
|
300
|
+
</Stack>
|
|
301
|
+
</Center>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Native
|
|
307
|
+
|
|
308
|
+
On Apple the attach button opens a menu with Photo Library and Files on iPhone, and opens Files on a Mac. Waiting files show as chips with a remove button. Sent images open full screen.
|
|
309
|
+
|
|
310
|
+
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MessageComposerPlain(): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
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: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The launch email is ready for review.' },
|
|
23
|
+
{ id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'I will read it after lunch.' },
|
|
24
|
+
];
|
|
25
|
+
var FIVE_MINUTES = 5 * 60 * 1000;
|
|
26
|
+
// A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.
|
|
27
|
+
function followsOn(rows, i) {
|
|
28
|
+
var prev = rows[i - 1];
|
|
29
|
+
return (!!prev &&
|
|
30
|
+
prev.from === rows[i].from &&
|
|
31
|
+
rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&
|
|
32
|
+
rows[i].at.toDateString() === prev.at.toDateString());
|
|
33
|
+
}
|
|
34
|
+
export default function MessageComposerPlain() {
|
|
35
|
+
var _a = useState(firstThread), thread = _a[0], setThread = _a[1];
|
|
36
|
+
// A real app keeps the draft per thread, so it is still there when the person comes back.
|
|
37
|
+
var _b = useState(''), text = _b[0], setText = _b[1];
|
|
38
|
+
// Enter sends and Shift+Enter adds a line. The Composer calls this only when there is text.
|
|
39
|
+
function send() {
|
|
40
|
+
// A real app sends the message to the server here and shows it at once.
|
|
41
|
+
setThread(function (rows) { return __spreadArray(__spreadArray([], rows, true), [{ id: "m".concat(rows.length + 1), from: me, at: new Date(), text: text.trim() }], false); });
|
|
42
|
+
setText('');
|
|
43
|
+
}
|
|
44
|
+
return (<Center width="page">
|
|
45
|
+
<Stack gap="large">
|
|
46
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
47
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
48
|
+
<Stack gap="small">
|
|
49
|
+
{thread.map(function (m, i) { return (<Message key={m.id} aria-label={m.from} compact={followsOn(thread, i)} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>}>
|
|
50
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
51
|
+
</Message>); })}
|
|
52
|
+
</Stack>
|
|
53
|
+
{/* On a touch screen, pass submitOnEnter={false} so Return adds a line. */}
|
|
54
|
+
<Composer id="message-composer-message" aria-label="Message" placeholder="Message the team" value={text} onChange={setText} onSubmit={send}/>
|
|
55
|
+
</Stack>
|
|
56
|
+
</Center>);
|
|
57
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MessageComposerWithTools(): import("react").JSX.Element;
|