oneslash-design-system 2.16.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 +1 -1
- package/dist/DESIGN.md +26 -3
- package/dist/cases/accept-invite/signed-in.jsx +1 -1
- package/dist/cases/accept-invite/signed-out.jsx +1 -1
- package/dist/cases/accept-invite.md +2 -2
- 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/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/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/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/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/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 +1 -1
- 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.json +1276 -14
- 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/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- 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/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/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 +8 -1
- package/dist/components/radioGroup.jsx +19 -8
- 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/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textarea.jsx +3 -18
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- 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/native-mapping.json +32 -1
- 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 +30 -0
- package/dist/stories/Cases.generated.stories.jsx +60 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/IconButton.stories.d.ts +1 -0
- package/dist/stories/IconButton.stories.jsx +18 -1
- 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/PageComponents.stories.d.ts +1 -0
- package/dist/stories/PageComponents.stories.jsx +21 -0
- package/dist/stories/RadioGroup.stories.d.ts +2 -0
- package/dist/stories/RadioGroup.stories.jsx +40 -1
- 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/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +4 -3
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
# Message actions
|
|
2
|
+
|
|
3
|
+
A person acts on one message: reacts to it, copies it, edits or deletes it.
|
|
4
|
+
|
|
5
|
+
**Not built yet:** Scindo on the web deletes a message with no confirm and has no Copy. Its row actions show only while the pointer is on the row, so a keyboard or a phone cannot reach them.
|
|
6
|
+
|
|
7
|
+
## Do
|
|
8
|
+
|
|
9
|
+
- Put the actions in the Message's `actions`. They show while the pointer is on the row or focus is in it.
|
|
10
|
+
- Use the More menu on a touch screen, where `actions` always show: one button per row instead of four.
|
|
11
|
+
- Order them Add reaction, Copy, then Edit and Delete. Edit and Delete show only on the person's own messages.
|
|
12
|
+
- Give each `IconButton` a short `Tooltip`, such as 'Add reaction' or 'Copy'. Give it an `ariaLabel` in sentence case that names the row's message: 'Add reaction to message from Dana Lee'.
|
|
13
|
+
- Call the reaction action 'Add Reaction' in the menu, the same action as the 'Add reaction' button.
|
|
14
|
+
- Swap Copy's icon to `Check` for 2 seconds after it copies, as the rule 'Success shows where the person is looking' says.
|
|
15
|
+
- Show the toast 'Message copied.' when Copy is chosen from a menu, because the menu item is gone.
|
|
16
|
+
- Check that the example is still mounted before the clipboard promise sets state, starts a timer or shows a toast.
|
|
17
|
+
- Confirm Delete in the row, as the case 'Delete confirm' says for a row in a dense list. The row's `footer` shows 'Delete this message?', 'Cancel', then a danger 'Delete'.
|
|
18
|
+
- Make 'Cancel' a small tertiary Button and 'Delete' a small primary Button with `color="danger"`. Hide the row's actions while it asks.
|
|
19
|
+
- Show 'Delete' as `loading` while the request runs, and disable 'Cancel'.
|
|
20
|
+
- Move focus to 'Cancel' when the confirm opens, and back to the row's Delete or More button after 'Cancel'.
|
|
21
|
+
- Remove the row once the message is deleted, and show a toast that names it: 'Message deleted.'
|
|
22
|
+
- Move focus to the next row's first action after a delete, or to the message box when no row follows.
|
|
23
|
+
- Edit the message in place, as the case 'Message edit' says. After Save or Cancel, focus goes to the row's Edit or More button.
|
|
24
|
+
- Put every action in a More menu when there are more than four: `<Popover returnFocus>` around `<Menu navigable aria-label="Message actions">`.
|
|
25
|
+
- Open the menu from the More button the person pressed: pass `event.currentTarget` to the Popover as `anchorEl`.
|
|
26
|
+
- Keep the More button on screen with `actionsVisible` while its menu is open.
|
|
27
|
+
- Make Delete the last item, a `MenuItem` with `color="danger"`.
|
|
28
|
+
|
|
29
|
+
## Don't
|
|
30
|
+
|
|
31
|
+
- Do not delete a message on the first click.
|
|
32
|
+
- Do not open a Modal to confirm a delete. The confirm stays in the row, so the person keeps their place in the thread.
|
|
33
|
+
- Do not show the actions only on pointer hover. A keyboard and a touch screen must reach them too.
|
|
34
|
+
- Do not show Edit or Delete on someone else's message.
|
|
35
|
+
- Do not open the menu when the page loads.
|
|
36
|
+
|
|
37
|
+
## Option: Toolbar on the row
|
|
38
|
+
|
|
39
|
+
Use when: A product used with a pointer, with three or four frequent actions.
|
|
40
|
+
|
|
41
|
+
Uses: `Button`, `Center`, `Cluster`, `Composer`, `Heading`, `IconButton`, `Message`, `Paragraph`, `Stack`, `Tag`, `TimeStamp`, `Toaster`, `Tooltip`, `UserImage`, `dismissToast`, `toast`
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
'use client';
|
|
45
|
+
import { useEffect, useRef, useState } from 'react';
|
|
46
|
+
import { Bot } from 'lucide-react';
|
|
47
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
48
|
+
import Message from 'oneslash-design-system/components/message';
|
|
49
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
50
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
51
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
52
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
53
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
54
|
+
import Composer from 'oneslash-design-system/components/composer';
|
|
55
|
+
import Button from 'oneslash-design-system/components/button';
|
|
56
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
57
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
58
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
59
|
+
|
|
60
|
+
// A real app reads this from the session.
|
|
61
|
+
const me = 'Dana Lee';
|
|
62
|
+
|
|
63
|
+
type Row = { id: string; from: string; agent?: boolean; at: Date; text: string; edited?: boolean; reacted?: boolean };
|
|
64
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
65
|
+
|
|
66
|
+
const firstThread: Row[] = [
|
|
67
|
+
{ id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The press kit is in the shared folder.' },
|
|
68
|
+
{ id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'I checked the press kit. Two images have no alt text.' },
|
|
69
|
+
{ id: 'm3', from: me, at: new Date('2025-01-15T11:44:00Z'), text: 'Thanks. I will add the alt text today.' },
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
export default function MessageActionsHoverToolbar() {
|
|
73
|
+
const [thread, setThread] = useState(firstThread);
|
|
74
|
+
const [text, setText] = useState('');
|
|
75
|
+
const [copiedId, setCopiedId] = useState<string | null>(null);
|
|
76
|
+
const [editingId, setEditingId] = useState<string | null>(null);
|
|
77
|
+
const [draft, setDraft] = useState('');
|
|
78
|
+
const [saving, setSaving] = useState(false);
|
|
79
|
+
// The row whose footer asks to confirm the delete. One row at a time.
|
|
80
|
+
const [confirmingId, setConfirmingId] = useState<string | null>(null);
|
|
81
|
+
const [deleting, setDeleting] = useState(false);
|
|
82
|
+
const copyTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
83
|
+
// One timer per request, so a save and a delete never clear each other's.
|
|
84
|
+
const saveTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
85
|
+
const deleteTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
86
|
+
const toastIds = useRef<string[]>([]);
|
|
87
|
+
const field = useRef<HTMLTextAreaElement>(null);
|
|
88
|
+
const box = useRef<HTMLTextAreaElement>(null);
|
|
89
|
+
const cancelDelete = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
90
|
+
// Each row's buttons by row id, so focus can move to one when the thing that had it is gone.
|
|
91
|
+
const reactButtons = useRef<Record<string, Focusable>>({});
|
|
92
|
+
const editButtons = useRef<Record<string, Focusable>>({});
|
|
93
|
+
const deleteButtons = useRef<Record<string, Focusable>>({});
|
|
94
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
95
|
+
const focusNext = useRef<() => void>();
|
|
96
|
+
// The clipboard answers later; by then the example may be gone.
|
|
97
|
+
const mounted = useRef(true);
|
|
98
|
+
|
|
99
|
+
// On unmount it stops the timers and closes every toast it opened.
|
|
100
|
+
useEffect(() => () => {
|
|
101
|
+
mounted.current = false;
|
|
102
|
+
clearTimeout(copyTimer.current);
|
|
103
|
+
clearTimeout(saveTimer.current);
|
|
104
|
+
clearTimeout(deleteTimer.current);
|
|
105
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
106
|
+
toastIds.current = [];
|
|
107
|
+
}, []);
|
|
108
|
+
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
const move = focusNext.current;
|
|
111
|
+
focusNext.current = undefined;
|
|
112
|
+
move?.();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
const editingRow = thread.find((m) => m.id === editingId);
|
|
116
|
+
const canSave = !!editingRow && draft.trim() !== '' && draft.trim() !== editingRow.text;
|
|
117
|
+
|
|
118
|
+
// A real app opens its reaction picker here; this one adds or removes a thumbs-up.
|
|
119
|
+
function react(id: string) {
|
|
120
|
+
setThread((rows) => rows.map((m) => (m.id === id ? { ...m, reacted: !m.reacted } : m)));
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function copy(m: Row) {
|
|
124
|
+
navigator.clipboard?.writeText(m.text).then(() => {
|
|
125
|
+
if (!mounted.current) return;
|
|
126
|
+
setCopiedId(m.id);
|
|
127
|
+
clearTimeout(copyTimer.current);
|
|
128
|
+
copyTimer.current = setTimeout(() => setCopiedId(null), 2000);
|
|
129
|
+
}, () => {});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// The field takes focus, with the caret after the text.
|
|
133
|
+
function startEditing(m: Row) {
|
|
134
|
+
setDraft(m.text);
|
|
135
|
+
setEditingId(m.id);
|
|
136
|
+
focusNext.current = () => {
|
|
137
|
+
const end = field.current?.value.length ?? 0;
|
|
138
|
+
field.current?.focus();
|
|
139
|
+
field.current?.setSelectionRange(end, end);
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// The field that had focus is gone, so focus goes to the row's Edit button.
|
|
144
|
+
function stopEditing(id: string) {
|
|
145
|
+
setEditingId(null);
|
|
146
|
+
focusNext.current = () => editButtons.current[id]?.focus();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function cancelEditing() {
|
|
150
|
+
if (saving || !editingId) return;
|
|
151
|
+
stopEditing(editingId);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function save() {
|
|
155
|
+
if (saving || !canSave || !editingId) return;
|
|
156
|
+
const id = editingId;
|
|
157
|
+
const value = draft.trim();
|
|
158
|
+
setSaving(true);
|
|
159
|
+
// Stands in for the request to the server.
|
|
160
|
+
saveTimer.current = setTimeout(() => {
|
|
161
|
+
setSaving(false);
|
|
162
|
+
setThread((rows) => rows.map((m) => (m.id === id ? { ...m, text: value, edited: true } : m)));
|
|
163
|
+
stopEditing(id);
|
|
164
|
+
}, 1200);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// The confirm opens in the row's footer, with focus on 'Cancel'.
|
|
168
|
+
function askToDelete(id: string) {
|
|
169
|
+
setConfirmingId(id);
|
|
170
|
+
focusNext.current = () => cancelDelete.current?.focus();
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's Delete button.
|
|
174
|
+
function keepMessage() {
|
|
175
|
+
if (deleting || !confirmingId) return;
|
|
176
|
+
const id = confirmingId;
|
|
177
|
+
setConfirmingId(null);
|
|
178
|
+
focusNext.current = () => deleteButtons.current[id]?.focus();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function confirmDelete() {
|
|
182
|
+
if (deleting || !confirmingId) return;
|
|
183
|
+
const id = confirmingId;
|
|
184
|
+
const next = thread[thread.findIndex((m) => m.id === id) + 1];
|
|
185
|
+
setDeleting(true);
|
|
186
|
+
// Stands in for the request to the server.
|
|
187
|
+
deleteTimer.current = setTimeout(() => {
|
|
188
|
+
setDeleting(false);
|
|
189
|
+
setConfirmingId(null);
|
|
190
|
+
setThread((rows) => rows.filter((m) => m.id !== id));
|
|
191
|
+
toastIds.current.push(toast({ type: 'success', message: 'Message deleted.' }));
|
|
192
|
+
// The row is gone: focus goes to the next row's first action, or to the message box when none follows.
|
|
193
|
+
// If the next row's button is not on screen, focus goes to the message box.
|
|
194
|
+
focusNext.current = () => ((next ? reactButtons.current[next.id] : null) ?? box.current)?.focus();
|
|
195
|
+
}, 1200);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function send() {
|
|
199
|
+
// A real app sends the message to the server here and shows it at once.
|
|
200
|
+
setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);
|
|
201
|
+
setText('');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return (
|
|
205
|
+
<Center width="page">
|
|
206
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
207
|
+
<Toaster />
|
|
208
|
+
<Stack gap="large">
|
|
209
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
210
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
211
|
+
<Stack gap="small">
|
|
212
|
+
{thread.map((m) => {
|
|
213
|
+
const own = m.from === me;
|
|
214
|
+
const editing = m.id === editingId;
|
|
215
|
+
const confirming = m.id === confirmingId;
|
|
216
|
+
return (
|
|
217
|
+
<Message
|
|
218
|
+
key={m.id}
|
|
219
|
+
aria-label={m.agent ? `${m.from}, agent` : m.from}
|
|
220
|
+
avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}
|
|
221
|
+
name={m.from}
|
|
222
|
+
meta={
|
|
223
|
+
<>
|
|
224
|
+
{m.agent && <Tag variant="contained" size="small" label="Agent" />}
|
|
225
|
+
<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />
|
|
226
|
+
{m.agent && <Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>}
|
|
227
|
+
{m.edited && <Paragraph size="caption" tone="secondary" measure="none">(edited)</Paragraph>}
|
|
228
|
+
</>
|
|
229
|
+
}
|
|
230
|
+
footer={
|
|
231
|
+
m.reacted || confirming ? (
|
|
232
|
+
<Stack gap="small">
|
|
233
|
+
{m.reacted && <Tag variant="contained" size="small" state="selected" label="👍 1" aria-label="Thumbs up, 1 reaction" />}
|
|
234
|
+
{confirming && (
|
|
235
|
+
// The confirm is in the row, as the case 'Delete confirm' says for a row in a dense list.
|
|
236
|
+
<Stack gap="small">
|
|
237
|
+
<Paragraph size="body2" measure="none">Delete this message?</Paragraph>
|
|
238
|
+
<Cluster gap="small">
|
|
239
|
+
<Button ref={cancelDelete} size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" aria-label="Cancel deleting your message" onClickButton={keepMessage} />
|
|
240
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Delete" aria-label="Delete this message" loading={deleting} onClickButton={confirmDelete} />
|
|
241
|
+
</Cluster>
|
|
242
|
+
</Stack>
|
|
243
|
+
)}
|
|
244
|
+
</Stack>
|
|
245
|
+
) : undefined
|
|
246
|
+
}
|
|
247
|
+
// Shown while the pointer is on the row or focus is in it, and always on a touch screen.
|
|
248
|
+
actions={
|
|
249
|
+
editing || confirming ? undefined : (
|
|
250
|
+
<>
|
|
251
|
+
<Tooltip title="Add reaction">
|
|
252
|
+
<IconButton
|
|
253
|
+
ref={(el) => { reactButtons.current[m.id] = el; }}
|
|
254
|
+
color="iconOnly"
|
|
255
|
+
state="enabled"
|
|
256
|
+
size="small"
|
|
257
|
+
iconName="SmilePlus"
|
|
258
|
+
ariaLabel={`Add reaction to message from ${m.from}`}
|
|
259
|
+
onClick={() => react(m.id)}
|
|
260
|
+
/>
|
|
261
|
+
</Tooltip>
|
|
262
|
+
<Tooltip title={copiedId === m.id ? 'Copied' : 'Copy'}>
|
|
263
|
+
<IconButton color="iconOnly" state="enabled" size="small" iconName={copiedId === m.id ? 'Check' : 'Copy'} ariaLabel={copiedId === m.id ? 'Copied' : `Copy message from ${m.from}`} onClick={() => copy(m)} />
|
|
264
|
+
</Tooltip>
|
|
265
|
+
{own && (
|
|
266
|
+
<Tooltip title="Edit">
|
|
267
|
+
<IconButton ref={(el) => { editButtons.current[m.id] = el; }} color="iconOnly" state="enabled" size="small" iconName="Pencil" ariaLabel="Edit your message" onClick={() => startEditing(m)} />
|
|
268
|
+
</Tooltip>
|
|
269
|
+
)}
|
|
270
|
+
{own && (
|
|
271
|
+
<Tooltip title="Delete">
|
|
272
|
+
<IconButton ref={(el) => { deleteButtons.current[m.id] = el; }} color="iconOnly" state="enabled" size="small" iconName="Trash2" ariaLabel="Delete your message" onClick={() => askToDelete(m.id)} />
|
|
273
|
+
</Tooltip>
|
|
274
|
+
)}
|
|
275
|
+
</>
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
>
|
|
279
|
+
{editing ? (
|
|
280
|
+
// Edit works as the case 'Message edit' says.
|
|
281
|
+
<Composer
|
|
282
|
+
ref={field}
|
|
283
|
+
id="message-actions-hover-edit"
|
|
284
|
+
aria-label="Edit message"
|
|
285
|
+
value={draft}
|
|
286
|
+
onChange={setDraft}
|
|
287
|
+
onSubmit={save}
|
|
288
|
+
canSubmit={canSave}
|
|
289
|
+
disabled={saving}
|
|
290
|
+
onKeyDown={(e) => {
|
|
291
|
+
if (e.key === 'Escape') {
|
|
292
|
+
e.preventDefault();
|
|
293
|
+
e.stopPropagation();
|
|
294
|
+
cancelEditing();
|
|
295
|
+
}
|
|
296
|
+
}}
|
|
297
|
+
actions={
|
|
298
|
+
<Cluster gap="small">
|
|
299
|
+
<Button size="small" type="tertiary" state={saving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelEditing} />
|
|
300
|
+
<Button size="small" type="primary" state={canSave ? 'enabled' : 'disabled'} label="Save" loading={saving} onClickButton={save} />
|
|
301
|
+
</Cluster>
|
|
302
|
+
}
|
|
303
|
+
/>
|
|
304
|
+
) : (
|
|
305
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
306
|
+
)}
|
|
307
|
+
</Message>
|
|
308
|
+
);
|
|
309
|
+
})}
|
|
310
|
+
</Stack>
|
|
311
|
+
<Composer
|
|
312
|
+
ref={box}
|
|
313
|
+
id="message-actions-hover-message"
|
|
314
|
+
aria-label="Message"
|
|
315
|
+
placeholder="Message the team"
|
|
316
|
+
value={text}
|
|
317
|
+
onChange={setText}
|
|
318
|
+
onSubmit={send}
|
|
319
|
+
/>
|
|
320
|
+
</Stack>
|
|
321
|
+
</Center>
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
## Option: More menu
|
|
327
|
+
|
|
328
|
+
Use when: There are more than four actions, or the product is used on a touch screen.
|
|
329
|
+
|
|
330
|
+
Uses: `Button`, `Center`, `Cluster`, `Composer`, `Heading`, `IconButton`, `Menu`, `MenuItem`, `Message`, `Paragraph`, `Popover`, `Stack`, `Tag`, `TimeStamp`, `Toaster`, `Tooltip`, `UserImage`, `dismissToast`, `toast`
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
'use client';
|
|
334
|
+
import { useEffect, useRef, useState } from 'react';
|
|
335
|
+
import { Bot } from 'lucide-react';
|
|
336
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
337
|
+
import Message from 'oneslash-design-system/components/message';
|
|
338
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
339
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
340
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
341
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
342
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
343
|
+
import Composer from 'oneslash-design-system/components/composer';
|
|
344
|
+
import Button from 'oneslash-design-system/components/button';
|
|
345
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
346
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
347
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
348
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
349
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
350
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
351
|
+
|
|
352
|
+
// A real app reads this from the session.
|
|
353
|
+
const me = 'Dana Lee';
|
|
354
|
+
|
|
355
|
+
type Row = { id: string; from: string; agent?: boolean; at: Date; text: string; edited?: boolean; reacted?: boolean };
|
|
356
|
+
type Focusable = HTMLButtonElement | HTMLAnchorElement | null;
|
|
357
|
+
|
|
358
|
+
const firstThread: Row[] = [
|
|
359
|
+
{ id: 'm1', from: 'Ben Carter', at: new Date('2025-01-15T11:40:00Z'), text: 'The press kit is in the shared folder.' },
|
|
360
|
+
{ id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'I checked the press kit. Two images have no alt text.' },
|
|
361
|
+
{ id: 'm3', from: me, at: new Date('2025-01-15T11:44:00Z'), text: 'Thanks. I will add the alt text today.' },
|
|
362
|
+
];
|
|
363
|
+
|
|
364
|
+
export default function MessageActionsMenu() {
|
|
365
|
+
const [thread, setThread] = useState(firstThread);
|
|
366
|
+
const [text, setText] = useState('');
|
|
367
|
+
// The row whose menu is open, and the More button it opens from. Both stay set while the menu fades out.
|
|
368
|
+
const [menuRow, setMenuRow] = useState<Row | null>(null);
|
|
369
|
+
const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
|
|
370
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
371
|
+
const [editingId, setEditingId] = useState<string | null>(null);
|
|
372
|
+
const [draft, setDraft] = useState('');
|
|
373
|
+
const [saving, setSaving] = useState(false);
|
|
374
|
+
// The row whose footer asks to confirm the delete. One row at a time.
|
|
375
|
+
const [confirmingId, setConfirmingId] = useState<string | null>(null);
|
|
376
|
+
const [deleting, setDeleting] = useState(false);
|
|
377
|
+
// One timer per request, so a save and a delete never clear each other's.
|
|
378
|
+
const saveTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
379
|
+
const deleteTimer = useRef<ReturnType<typeof setTimeout>>();
|
|
380
|
+
const toastIds = useRef<string[]>([]);
|
|
381
|
+
const field = useRef<HTMLTextAreaElement>(null);
|
|
382
|
+
const box = useRef<HTMLTextAreaElement>(null);
|
|
383
|
+
const cancelDelete = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
384
|
+
// Each row's More button by row id, so focus can move to one when the thing that had it is gone.
|
|
385
|
+
const moreButtons = useRef<Record<string, Focusable>>({});
|
|
386
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
387
|
+
const focusNext = useRef<() => void>();
|
|
388
|
+
// The clipboard answers later; by then the example may be gone.
|
|
389
|
+
const mounted = useRef(true);
|
|
390
|
+
|
|
391
|
+
// On unmount it stops the timers and closes every toast it opened.
|
|
392
|
+
useEffect(() => () => {
|
|
393
|
+
mounted.current = false;
|
|
394
|
+
clearTimeout(saveTimer.current);
|
|
395
|
+
clearTimeout(deleteTimer.current);
|
|
396
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
397
|
+
toastIds.current = [];
|
|
398
|
+
}, []);
|
|
399
|
+
|
|
400
|
+
useEffect(() => {
|
|
401
|
+
const move = focusNext.current;
|
|
402
|
+
focusNext.current = undefined;
|
|
403
|
+
move?.();
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
const editingRow = thread.find((m) => m.id === editingId);
|
|
407
|
+
const canSave = !!editingRow && draft.trim() !== '' && draft.trim() !== editingRow.text;
|
|
408
|
+
|
|
409
|
+
// A real app opens its reaction picker here; this one adds or removes a thumbs-up.
|
|
410
|
+
function react(m: Row) {
|
|
411
|
+
setThread((rows) => rows.map((r) => (r.id === m.id ? { ...r, reacted: !r.reacted } : r)));
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// The menu closes when an item is chosen, so a copy shows a toast rather than a check.
|
|
415
|
+
function copy(m: Row) {
|
|
416
|
+
navigator.clipboard?.writeText(m.text).then(() => {
|
|
417
|
+
if (!mounted.current) return;
|
|
418
|
+
toastIds.current.push(toast({ type: 'success', message: 'Message copied.' }));
|
|
419
|
+
}, () => {});
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// A real app sends the task to the server here.
|
|
423
|
+
function createTask(m: Row) {
|
|
424
|
+
toastIds.current.push(toast({ type: 'success', message: `Task created from ${m.from}'s message.` }));
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
// A real app asks for a reason in a Modal, then sends the report.
|
|
428
|
+
function report(m: Row) {
|
|
429
|
+
toastIds.current.push(toast({ type: 'success', message: `${m.from}'s message reported to the workspace admins.` }));
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function openMenu(m: Row, anchor: HTMLElement) {
|
|
433
|
+
if (menuOpen && menuRow?.id === m.id) {
|
|
434
|
+
closeMenu();
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
setMenuRow(m);
|
|
438
|
+
setMenuAnchor(anchor);
|
|
439
|
+
setMenuOpen(true);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
// Escape, a click outside and every item close the menu. Popover's returnFocus gives focus back to More.
|
|
443
|
+
function closeMenu() {
|
|
444
|
+
setMenuOpen(false);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
function choose(action: (m: Row) => void) {
|
|
448
|
+
if (!menuRow) return;
|
|
449
|
+
const m = menuRow;
|
|
450
|
+
closeMenu();
|
|
451
|
+
action(m);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// The field takes focus, with the caret after the text.
|
|
455
|
+
function startEditing(m: Row) {
|
|
456
|
+
setDraft(m.text);
|
|
457
|
+
setEditingId(m.id);
|
|
458
|
+
focusNext.current = () => {
|
|
459
|
+
const end = field.current?.value.length ?? 0;
|
|
460
|
+
field.current?.focus();
|
|
461
|
+
field.current?.setSelectionRange(end, end);
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// The field that had focus is gone, so focus goes to the row's More button.
|
|
466
|
+
function stopEditing(id: string) {
|
|
467
|
+
setEditingId(null);
|
|
468
|
+
focusNext.current = () => moreButtons.current[id]?.focus();
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function cancelEditing() {
|
|
472
|
+
if (saving || !editingId) return;
|
|
473
|
+
stopEditing(editingId);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
function save() {
|
|
477
|
+
if (saving || !canSave || !editingId) return;
|
|
478
|
+
const id = editingId;
|
|
479
|
+
const value = draft.trim();
|
|
480
|
+
setSaving(true);
|
|
481
|
+
// Stands in for the request to the server.
|
|
482
|
+
saveTimer.current = setTimeout(() => {
|
|
483
|
+
setSaving(false);
|
|
484
|
+
setThread((rows) => rows.map((m) => (m.id === id ? { ...m, text: value, edited: true } : m)));
|
|
485
|
+
stopEditing(id);
|
|
486
|
+
}, 1200);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
// The confirm opens in the row's footer, with focus on 'Cancel'.
|
|
490
|
+
function askToDelete(m: Row) {
|
|
491
|
+
setConfirmingId(m.id);
|
|
492
|
+
focusNext.current = () => cancelDelete.current?.focus();
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// 'Cancel' goes away with the confirm, so focus goes back to the row's More button.
|
|
496
|
+
function keepMessage() {
|
|
497
|
+
if (deleting || !confirmingId) return;
|
|
498
|
+
const id = confirmingId;
|
|
499
|
+
setConfirmingId(null);
|
|
500
|
+
focusNext.current = () => moreButtons.current[id]?.focus();
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function confirmDelete() {
|
|
504
|
+
if (deleting || !confirmingId) return;
|
|
505
|
+
const id = confirmingId;
|
|
506
|
+
const next = thread[thread.findIndex((m) => m.id === id) + 1];
|
|
507
|
+
setDeleting(true);
|
|
508
|
+
// Stands in for the request to the server.
|
|
509
|
+
deleteTimer.current = setTimeout(() => {
|
|
510
|
+
setDeleting(false);
|
|
511
|
+
setConfirmingId(null);
|
|
512
|
+
setThread((rows) => rows.filter((m) => m.id !== id));
|
|
513
|
+
toastIds.current.push(toast({ type: 'success', message: 'Message deleted.' }));
|
|
514
|
+
// The row is gone: focus goes to the next row's More button, or to the message box when none follows.
|
|
515
|
+
// If the next row's button is not on screen, focus goes to the message box.
|
|
516
|
+
focusNext.current = () => ((next ? moreButtons.current[next.id] : null) ?? box.current)?.focus();
|
|
517
|
+
}, 1200);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function send() {
|
|
521
|
+
// A real app sends the message to the server here and shows it at once.
|
|
522
|
+
setThread((rows) => [...rows, { id: `m${rows.length + 1}`, from: me, at: new Date(), text: text.trim() }]);
|
|
523
|
+
setText('');
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
return (
|
|
527
|
+
<Center width="page">
|
|
528
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
529
|
+
<Toaster />
|
|
530
|
+
<Stack gap="large">
|
|
531
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
532
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
533
|
+
<Stack gap="small">
|
|
534
|
+
{thread.map((m) => {
|
|
535
|
+
const editing = m.id === editingId;
|
|
536
|
+
const confirming = m.id === confirmingId;
|
|
537
|
+
return (
|
|
538
|
+
<Message
|
|
539
|
+
key={m.id}
|
|
540
|
+
aria-label={m.agent ? `${m.from}, agent` : m.from}
|
|
541
|
+
avatar={m.agent ? <UserImage userHandle={m.from} icon={Bot} decorative /> : <UserImage userHandle={m.from} decorative />}
|
|
542
|
+
name={m.from}
|
|
543
|
+
meta={
|
|
544
|
+
<>
|
|
545
|
+
{m.agent && <Tag variant="contained" size="small" label="Agent" />}
|
|
546
|
+
<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />
|
|
547
|
+
{m.agent && <Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>}
|
|
548
|
+
{m.edited && <Paragraph size="caption" tone="secondary" measure="none">(edited)</Paragraph>}
|
|
549
|
+
</>
|
|
550
|
+
}
|
|
551
|
+
footer={
|
|
552
|
+
m.reacted || confirming ? (
|
|
553
|
+
<Stack gap="small">
|
|
554
|
+
{m.reacted && <Tag variant="contained" size="small" state="selected" label="👍 1" aria-label="Thumbs up, 1 reaction" />}
|
|
555
|
+
{confirming && (
|
|
556
|
+
// The confirm is in the row, as the case 'Delete confirm' says for a row in a dense list.
|
|
557
|
+
<Stack gap="small">
|
|
558
|
+
<Paragraph size="body2" measure="none">Delete this message?</Paragraph>
|
|
559
|
+
<Cluster gap="small">
|
|
560
|
+
<Button ref={cancelDelete} size="small" type="tertiary" state={deleting ? 'disabled' : 'enabled'} label="Cancel" aria-label="Cancel deleting your message" onClickButton={keepMessage} />
|
|
561
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Delete" aria-label="Delete this message" loading={deleting} onClickButton={confirmDelete} />
|
|
562
|
+
</Cluster>
|
|
563
|
+
</Stack>
|
|
564
|
+
)}
|
|
565
|
+
</Stack>
|
|
566
|
+
) : undefined
|
|
567
|
+
}
|
|
568
|
+
// One More button. Shown while the pointer is on the row or focus is in it, and always on a touch screen.
|
|
569
|
+
// It stays on screen while its menu is open, though the pointer and focus are in the menu.
|
|
570
|
+
actionsVisible={menuOpen && menuRow?.id === m.id}
|
|
571
|
+
actions={
|
|
572
|
+
editing || confirming ? undefined : (
|
|
573
|
+
<Tooltip title="More">
|
|
574
|
+
<IconButton
|
|
575
|
+
ref={(el) => { moreButtons.current[m.id] = el; }}
|
|
576
|
+
color="iconOnly"
|
|
577
|
+
state={menuOpen && menuRow?.id === m.id ? 'selected' : 'enabled'}
|
|
578
|
+
size="small"
|
|
579
|
+
iconName="Ellipsis"
|
|
580
|
+
ariaLabel={`More actions for message from ${m.from}`}
|
|
581
|
+
aria-haspopup="menu"
|
|
582
|
+
aria-expanded={menuOpen && menuRow?.id === m.id}
|
|
583
|
+
onClick={(e: { currentTarget: HTMLElement }) => openMenu(m, e.currentTarget)}
|
|
584
|
+
/>
|
|
585
|
+
</Tooltip>
|
|
586
|
+
)
|
|
587
|
+
}
|
|
588
|
+
>
|
|
589
|
+
{editing ? (
|
|
590
|
+
// Edit works as the case 'Message edit' says.
|
|
591
|
+
<Composer
|
|
592
|
+
ref={field}
|
|
593
|
+
id="message-actions-menu-edit"
|
|
594
|
+
aria-label="Edit message"
|
|
595
|
+
value={draft}
|
|
596
|
+
onChange={setDraft}
|
|
597
|
+
onSubmit={save}
|
|
598
|
+
canSubmit={canSave}
|
|
599
|
+
disabled={saving}
|
|
600
|
+
onKeyDown={(e) => {
|
|
601
|
+
if (e.key === 'Escape') {
|
|
602
|
+
e.preventDefault();
|
|
603
|
+
e.stopPropagation();
|
|
604
|
+
cancelEditing();
|
|
605
|
+
}
|
|
606
|
+
}}
|
|
607
|
+
actions={
|
|
608
|
+
<Cluster gap="small">
|
|
609
|
+
<Button size="small" type="tertiary" state={saving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelEditing} />
|
|
610
|
+
<Button size="small" type="primary" state={canSave ? 'enabled' : 'disabled'} label="Save" loading={saving} onClickButton={save} />
|
|
611
|
+
</Cluster>
|
|
612
|
+
}
|
|
613
|
+
/>
|
|
614
|
+
) : (
|
|
615
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
616
|
+
)}
|
|
617
|
+
</Message>
|
|
618
|
+
);
|
|
619
|
+
})}
|
|
620
|
+
</Stack>
|
|
621
|
+
<Composer
|
|
622
|
+
ref={box}
|
|
623
|
+
id="message-actions-menu-message"
|
|
624
|
+
aria-label="Message"
|
|
625
|
+
placeholder="Message the team"
|
|
626
|
+
value={text}
|
|
627
|
+
onChange={setText}
|
|
628
|
+
onSubmit={send}
|
|
629
|
+
/>
|
|
630
|
+
</Stack>
|
|
631
|
+
{/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}
|
|
632
|
+
<Popover open={menuOpen} anchorEl={menuAnchor} onClose={closeMenu} returnFocus>
|
|
633
|
+
<Menu navigable aria-label="Message actions" width={200}>
|
|
634
|
+
<MenuItem size="small" iconName="SmilePlus" label="Add Reaction" onClick={() => choose(react)} />
|
|
635
|
+
<MenuItem size="small" iconName="Copy" label="Copy" onClick={() => choose(copy)} />
|
|
636
|
+
{menuRow?.from === me && <MenuItem size="small" iconName="Pencil" label="Edit" onClick={() => choose(startEditing)} />}
|
|
637
|
+
<MenuItem size="small" iconName="ClipboardPlus" label="Create Task" onClick={() => choose(createTask)} />
|
|
638
|
+
{menuRow?.from !== me && <MenuItem size="small" iconName="Flag" label="Report" onClick={() => choose(report)} />}
|
|
639
|
+
{menuRow?.from === me && <MenuItem size="small" color="danger" iconName="Trash2" label="Delete" onClick={() => choose(askToDelete)} />}
|
|
640
|
+
</Menu>
|
|
641
|
+
</Popover>
|
|
642
|
+
</Center>
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
## Native
|
|
648
|
+
|
|
649
|
+
On Apple put the actions in the row's `contextMenu`: Copy, Edit, Add Reaction, Create Task and Report, with Delete last in the `.destructive` role. Delete asks in a system `confirmationDialog`, not in the row.
|
|
650
|
+
|
|
651
|
+
Seen in: Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MessageAttachmentsInComposer(): import("react").JSX.Element;
|