@estiva-app/ui 0.98.1 → 0.100.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 +4 -2
- package/dist/AppProvider.d.ts +6 -3
- package/dist/AppProvider.d.ts.map +1 -1
- package/dist/ArchiveDialog.d.ts +35 -0
- package/dist/ArchiveDialog.d.ts.map +1 -0
- package/dist/AttachedCard.d.ts +13 -2
- package/dist/AttachedCard.d.ts.map +1 -1
- package/dist/Card.d.ts +6 -1
- package/dist/Card.d.ts.map +1 -1
- package/dist/ChipInput.d.ts +3 -1
- package/dist/ChipInput.d.ts.map +1 -1
- package/dist/CollapsibleSection.d.ts +27 -2
- package/dist/CollapsibleSection.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +2 -2
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConfirmDialog.d.ts +15 -2
- package/dist/ConfirmDialog.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +12 -1
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts +20 -5
- package/dist/ConversationLayout.d.ts.map +1 -1
- package/dist/ConversationMenu.d.ts +5 -1
- package/dist/ConversationMenu.d.ts.map +1 -1
- package/dist/ConversationPlace.d.ts +17 -0
- package/dist/ConversationPlace.d.ts.map +1 -0
- package/dist/DocumentEditor.d.ts +38 -0
- package/dist/DocumentEditor.d.ts.map +1 -1
- package/dist/DocumentField.d.ts +50 -0
- package/dist/DocumentField.d.ts.map +1 -0
- package/dist/EditableText.d.ts +38 -4
- package/dist/EditableText.d.ts.map +1 -1
- package/dist/EmptyState.d.ts +10 -5
- package/dist/EmptyState.d.ts.map +1 -1
- package/dist/FormDialog.d.ts +38 -0
- package/dist/FormDialog.d.ts.map +1 -0
- package/dist/InlineText.d.ts.map +1 -1
- package/dist/Menu.d.ts +11 -3
- package/dist/Menu.d.ts.map +1 -1
- package/dist/MoveDialog.d.ts +64 -0
- package/dist/MoveDialog.d.ts.map +1 -0
- package/dist/NavItem.d.ts +9 -2
- package/dist/NavItem.d.ts.map +1 -1
- package/dist/NavTree.d.ts +16 -3
- package/dist/NavTree.d.ts.map +1 -1
- package/dist/PinnedComment.d.ts +3 -1
- package/dist/PinnedComment.d.ts.map +1 -1
- package/dist/ReactionHorizon.d.ts +3 -1
- package/dist/ReactionHorizon.d.ts.map +1 -1
- package/dist/RepliesRow.d.ts +5 -3
- package/dist/RepliesRow.d.ts.map +1 -1
- package/dist/ResolveDialog.d.ts +3 -1
- package/dist/ResolveDialog.d.ts.map +1 -1
- package/dist/SelectionToolbar.d.ts +2 -2
- package/dist/Thread.d.ts +6 -3
- package/dist/Thread.d.ts.map +1 -1
- package/dist/commentBoxFrame.d.ts.map +1 -1
- package/dist/conversation.examples.d.ts +4 -1
- package/dist/conversation.examples.d.ts.map +1 -1
- package/dist/conversationScroll.d.ts +80 -0
- package/dist/conversationScroll.d.ts.map +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +228 -69
- package/dist/editor.js.map +4 -4
- package/dist/eslint/index.js +2 -2
- package/dist/eslint/index.js.map +2 -2
- package/dist/eslint/no-field-outside-a-form.d.ts +2 -2
- package/dist/eslint/no-field-outside-a-form.d.ts.map +1 -1
- package/dist/eslint/no-native-title.d.ts +1 -1
- package/dist/eslint/no-native-title.d.ts.map +1 -1
- package/dist/formBusy.d.ts +5 -2
- package/dist/formBusy.d.ts.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2242 -1471
- package/dist/index.js.map +4 -4
- package/dist/looks.d.ts +8 -0
- package/dist/looks.d.ts.map +1 -1
- package/dist/seenOnScreen.d.ts +27 -0
- package/dist/seenOnScreen.d.ts.map +1 -0
- package/dist/showInConversation.d.ts +31 -0
- package/dist/showInConversation.d.ts.map +1 -0
- package/dist/threadCard.d.ts +13 -0
- package/dist/threadCard.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +953 -126
- package/src/AppProvider.mdx +4 -0
- package/src/AppProvider.test.tsx +34 -2
- package/src/AppProvider.tsx +17 -6
- package/src/ArchiveDialog.mdx +70 -0
- package/src/ArchiveDialog.stories.tsx +64 -0
- package/src/ArchiveDialog.test.tsx +90 -0
- package/src/ArchiveDialog.tsx +70 -0
- package/src/AttachedCard.mdx +6 -0
- package/src/AttachedCard.stories.tsx +9 -1
- package/src/AttachedCard.test.tsx +111 -2
- package/src/AttachedCard.tsx +77 -7
- package/src/Card.mdx +20 -1
- package/src/Card.stories.tsx +20 -0
- package/src/Card.test.tsx +87 -1
- package/src/Card.tsx +51 -3
- package/src/ChipInput.mdx +7 -1
- package/src/ChipInput.stories.tsx +9 -0
- package/src/ChipInput.test.tsx +42 -0
- package/src/ChipInput.tsx +7 -3
- package/src/CollapsibleSection.mdx +20 -1
- package/src/CollapsibleSection.stories.tsx +19 -1
- package/src/CollapsibleSection.test.tsx +85 -2
- package/src/CollapsibleSection.tsx +54 -15
- package/src/CommentBox.mdx +2 -1
- package/src/CommentBox.test.tsx +81 -1
- package/src/CommentBox.tsx +32 -11
- package/src/ConfirmDialog.mdx +25 -3
- package/src/ConfirmDialog.stories.tsx +27 -0
- package/src/ConfirmDialog.test.tsx +87 -1
- package/src/ConfirmDialog.tsx +39 -8
- package/src/ConversationCard.mdx +7 -0
- package/src/ConversationCard.states.test.tsx +67 -0
- package/src/ConversationCard.stories.tsx +27 -1
- package/src/ConversationCard.test.tsx +76 -0
- package/src/ConversationCard.tsx +65 -53
- package/src/ConversationLayout.mdx +34 -4
- package/src/ConversationLayout.scroll.test.tsx +411 -0
- package/src/ConversationLayout.stories.tsx +107 -1
- package/src/ConversationLayout.test.tsx +133 -0
- package/src/ConversationLayout.tsx +141 -16
- package/src/ConversationMenu.mdx +3 -0
- package/src/ConversationMenu.stories.tsx +12 -0
- package/src/ConversationMenu.test.tsx +17 -0
- package/src/ConversationMenu.tsx +7 -3
- package/src/ConversationPlace.mdx +53 -0
- package/src/ConversationPlace.stories.tsx +48 -0
- package/src/ConversationPlace.test.tsx +51 -0
- package/src/ConversationPlace.tsx +30 -0
- package/src/DocumentEditor.mdx +2 -1
- package/src/DocumentEditor.tsx +118 -64
- package/src/DocumentField.mdx +83 -0
- package/src/DocumentField.stories.tsx +110 -0
- package/src/DocumentField.test.tsx +281 -0
- package/src/DocumentField.tsx +199 -0
- package/src/EditableText.buttons.test.tsx +318 -0
- package/src/EditableText.mdx +50 -2
- package/src/EditableText.stories.tsx +96 -2
- package/src/EditableText.tsx +189 -5
- package/src/EmptyState.mdx +33 -8
- package/src/EmptyState.stories.tsx +26 -1
- package/src/EmptyState.test.tsx +63 -2
- package/src/EmptyState.tsx +28 -6
- package/src/Form.mdx +3 -1
- package/src/FormDialog.mdx +78 -0
- package/src/FormDialog.stories.tsx +90 -0
- package/src/FormDialog.test.tsx +183 -0
- package/src/FormDialog.tsx +93 -0
- package/src/InlineText.mdx +1 -0
- package/src/InlineText.tsx +2 -1
- package/src/Menu.test.tsx +80 -0
- package/src/Menu.tsx +35 -14
- package/src/MenuItem.mdx +12 -0
- package/src/MenuItem.stories.tsx +39 -1
- package/src/MoveDialog.mdx +85 -0
- package/src/MoveDialog.stories.tsx +134 -0
- package/src/MoveDialog.test.tsx +239 -0
- package/src/MoveDialog.tsx +186 -0
- package/src/NavItem.mdx +15 -0
- package/src/NavItem.stories.tsx +15 -0
- package/src/NavItem.test.tsx +64 -1
- package/src/NavItem.tsx +10 -2
- package/src/NavTree.mdx +26 -4
- package/src/NavTree.stories.tsx +59 -0
- package/src/NavTree.test.tsx +232 -2
- package/src/NavTree.tsx +93 -43
- package/src/PinnedComment.mdx +6 -1
- package/src/PinnedComment.stories.tsx +11 -1
- package/src/PinnedComment.tsx +15 -2
- package/src/ReactionHorizon.mdx +2 -0
- package/src/ReactionHorizon.stories.tsx +3 -0
- package/src/ReactionHorizon.test.tsx +32 -0
- package/src/ReactionHorizon.tsx +28 -11
- package/src/RepliesRow.mdx +6 -3
- package/src/RepliesRow.stories.tsx +3 -0
- package/src/RepliesRow.test.tsx +24 -0
- package/src/RepliesRow.tsx +12 -6
- package/src/ReplyCard.mdx +8 -0
- package/src/ReplyCard.stories.tsx +45 -1
- package/src/ResolveDialog.mdx +2 -0
- package/src/ResolveDialog.test.tsx +21 -0
- package/src/ResolveDialog.tsx +11 -39
- package/src/SelectionToolbar.tsx +2 -2
- package/src/Textarea.mdx +1 -0
- package/src/Thread.mdx +20 -1
- package/src/Thread.stories.tsx +94 -3
- package/src/Thread.test.tsx +11 -0
- package/src/Thread.tsx +56 -12
- package/src/commentBoxFrame.tsx +2 -2
- package/src/conversation.examples.tsx +10 -2
- package/src/conversationScroll.ts +155 -0
- package/src/editor.ts +1 -0
- package/src/editorSelection.test.tsx +53 -0
- package/src/eslint/no-field-outside-a-form.test.ts +4 -0
- package/src/eslint/no-field-outside-a-form.ts +2 -2
- package/src/eslint/no-native-title.ts +1 -1
- package/src/formBusy.ts +5 -2
- package/src/index.ts +16 -6
- package/src/looks.ts +10 -0
- package/src/registry/registry.test.ts +12 -6
- package/src/seenOnScreen.test.tsx +241 -0
- package/src/seenOnScreen.ts +146 -0
- package/src/showInConversation.test.tsx +168 -0
- package/src/showInConversation.ts +93 -0
- package/src/threadCard.ts +16 -0
- package/stories/Choosing.mdx +8 -3
- package/tailwind-preset.js +7 -0
package/src/ConfirmDialog.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useState, type ReactNode } from 'react'
|
|
2
|
-
import { Button } from './Button'
|
|
1
|
+
import { useRef, useState, type ReactNode } from 'react'
|
|
2
|
+
import { Button, type ButtonAction } from './Button'
|
|
3
3
|
import { DialogShell } from './DialogShell'
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* A question with two answers, before something a person would want back —
|
|
6
|
+
* A question with two answers — three, with a safer `alternative` — before something a person would want back —
|
|
7
7
|
* Ship's ConfirmDialog (2026-09-01), verbatim. Its own comment always called
|
|
8
8
|
* it a package candidate: nothing here knows what is being confirmed.
|
|
9
9
|
*
|
|
@@ -17,6 +17,12 @@ import { DialogShell } from './DialogShell'
|
|
|
17
17
|
* closes it** (Katerina, D20): a destructive question is answered, not
|
|
18
18
|
* clicked away. Escape and the close button still cancel, as they did.
|
|
19
19
|
*/
|
|
20
|
+
/** A third answer: the safer one, with the sentence that says why. */
|
|
21
|
+
export interface ConfirmDialogAlternative extends ButtonAction {
|
|
22
|
+
/** The sentence above the button — "To take it out of every list and keep it readable, archive it instead." */
|
|
23
|
+
sentence: string
|
|
24
|
+
}
|
|
25
|
+
|
|
20
26
|
export interface ConfirmDialogProps {
|
|
21
27
|
title: string
|
|
22
28
|
/** The body — plain sentences, body-2. */
|
|
@@ -24,16 +30,30 @@ export interface ConfirmDialogProps {
|
|
|
24
30
|
confirmLabel: string
|
|
25
31
|
destructive?: boolean
|
|
26
32
|
onConfirm: () => Promise<boolean | void> | boolean | void
|
|
33
|
+
/** Cancel, Escape, the ✕, and an action that went through: once, when it was closed while the action ran. */
|
|
27
34
|
onClose: () => void
|
|
35
|
+
/**
|
|
36
|
+
* A third, safer answer — "Archive instead" — drawn after the words, under
|
|
37
|
+
* its sentence, and switched off while the confirm runs (Peek's, 2 November).
|
|
38
|
+
* It closes nothing: what it opens takes this question's place.
|
|
39
|
+
*/
|
|
40
|
+
alternative?: ConfirmDialogAlternative
|
|
28
41
|
}
|
|
29
42
|
|
|
30
|
-
export function ConfirmDialog({ title, children, confirmLabel, destructive = false, onConfirm, onClose }: ConfirmDialogProps) {
|
|
43
|
+
export function ConfirmDialog({ title, children, confirmLabel, destructive = false, onConfirm, onClose, alternative }: ConfirmDialogProps) {
|
|
31
44
|
const [busy, setBusy] = useState(false)
|
|
45
|
+
// Closed while the action ran (Escape, the ✕): the action that then goes through does not close it a second time.
|
|
46
|
+
const closed = useRef(false)
|
|
47
|
+
const close = () => {
|
|
48
|
+
closed.current = true
|
|
49
|
+
onClose()
|
|
50
|
+
}
|
|
32
51
|
const confirm = async () => {
|
|
52
|
+
closed.current = false
|
|
33
53
|
setBusy(true)
|
|
34
54
|
try {
|
|
35
55
|
const ok = await onConfirm()
|
|
36
|
-
if (ok !== false)
|
|
56
|
+
if (ok !== false && !closed.current) close()
|
|
37
57
|
} finally {
|
|
38
58
|
setBusy(false)
|
|
39
59
|
}
|
|
@@ -42,10 +62,10 @@ export function ConfirmDialog({ title, children, confirmLabel, destructive = fal
|
|
|
42
62
|
<DialogShell
|
|
43
63
|
alert
|
|
44
64
|
title={title}
|
|
45
|
-
onClose={
|
|
65
|
+
onClose={close}
|
|
46
66
|
footer={
|
|
47
67
|
<>
|
|
48
|
-
<Button variant="muted" onClick={
|
|
68
|
+
<Button variant="muted" onClick={close} disabled={busy}>
|
|
49
69
|
Cancel
|
|
50
70
|
</Button>
|
|
51
71
|
<Button variant={destructive ? 'destructive' : 'primary'} onClick={() => void confirm()} disabled={busy}>
|
|
@@ -55,7 +75,18 @@ export function ConfirmDialog({ title, children, confirmLabel, destructive = fal
|
|
|
55
75
|
}
|
|
56
76
|
>
|
|
57
77
|
{/* The words' look on a box of the dialog's own, not pushed into DialogShell's body (UIG-9). */}
|
|
58
|
-
<div className="flex flex-col gap-3 text-body-2 text-text-primary">
|
|
78
|
+
<div className="flex flex-col gap-3 text-body-2 text-text-primary">
|
|
79
|
+
{children}
|
|
80
|
+
{/* Its sentence and its button one block, 8px apart, as Peek's delete question drew them. */}
|
|
81
|
+
{alternative && (
|
|
82
|
+
<div className="flex flex-col items-start gap-2">
|
|
83
|
+
<p>{alternative.sentence}</p>
|
|
84
|
+
<Button variant="outlined" size="small" onClick={alternative.onClick} disabled={busy}>
|
|
85
|
+
{alternative.label}
|
|
86
|
+
</Button>
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
</div>
|
|
59
90
|
</DialogShell>
|
|
60
91
|
)
|
|
61
92
|
}
|
package/src/ConversationCard.mdx
CHANGED
|
@@ -15,8 +15,13 @@ One comment, the same in every app: who, when, the words, files, cards, reaction
|
|
|
15
15
|
- `own` on yours: Edit (with `editor`) and Delete (with `onDelete`) in its menu. The card asks before it deletes.
|
|
16
16
|
- `resolved`: "✓ Resolved" by the time, with who, when and the note on hover; "Person two → the note · time" above its replies row. Nothing of the comment is hidden: its words, cards, files and reactions stay.
|
|
17
17
|
- `noun`: what the delete question calls it, "Delete this comment?" by default; a direct message says `message`.
|
|
18
|
+
- In the app's own words, the ⋯ menu: `menuLabel` heads its first rows, `editLabel` and `deleteLabel` are Edit's and Delete's words ("Edit message", "Delete message"), and `moreLabel` names the ⋯ button, its tooltip too ("Message actions"; "More actions" by default).
|
|
19
|
+
|
|
20
|
+
<Canvas of={Stories.InAnAppsWords} />
|
|
18
21
|
- `about` on a comment on a part of the page: a **QuotedLine** under the name, above the words.
|
|
19
22
|
- `isNew`, `urgent`: the dot or the urgent mark, and a hairline, until it is read.
|
|
23
|
+
- `replies.newCount`, how many replies under it are new: its replies row says "2 new", and the comment takes the hairline too. `replies.isNew` alone says "1 new".
|
|
24
|
+
- `at`, its moment: the time says the exact date and time under the pointer, in the reader's own way. Give it on every comment.
|
|
20
25
|
|
|
21
26
|
<Canvas of={Stories.Replies} />
|
|
22
27
|
|
|
@@ -56,6 +61,7 @@ import { ConversationCard } from '@estiva-app/ui'
|
|
|
56
61
|
- **The words are yours to draw**: text, people named, links, attached cards and quoted blocks, with **RichText** and the link parts. The card gives them their size and colour.
|
|
57
62
|
- **Edit opens your box**: `editor` draws your **CommentBox** edit form; call `done` when it saves or cancels. To open it again after a refused save, hold `editing` yourself.
|
|
58
63
|
- **Resolve opens the dialog**: **ResolveDialog**, then `onResolve(note)`. Answer `false` when it was refused; the dialog stays.
|
|
64
|
+
- `time` is your words for it ("11:08 AM"); `at` is the moment (ms), from which the card says the exact date and time on hover. Never a tooltip of your own round `time`.
|
|
59
65
|
- A press on the card is `onClick` (its thread opens); a press on a button, a link or anything marked `data-interactive` inside it is not.
|
|
60
66
|
- The strip shows while the card is pointed at or has focus, and holds while its reactions or its menu are open.
|
|
61
67
|
|
|
@@ -66,6 +72,7 @@ import { ConversationCard } from '@estiva-app/ui'
|
|
|
66
72
|
| Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
|
|
67
73
|
| A card that opens on a press is a Tab stop: reaching it shows its actions, Enter or Space opens it | a `tabIndex` and a key handler | |
|
|
68
74
|
| Asks before it deletes | a confirm dialog | |
|
|
75
|
+
| Says the exact date and time under the pointer, from `at` | a tooltip round the time | |
|
|
69
76
|
| Opens the Resolve dialog, and closes it once resolved | a dialog and its open state | |
|
|
70
77
|
| Says it is resolved, with who and the note, and hides nothing of it | a resolved line or chip of your own | |
|
|
71
78
|
|
|
@@ -195,6 +195,16 @@ describe('new and urgent (Peek: ConversationCard.urgent, the card’s part)', ()
|
|
|
195
195
|
expect(screen.getByText('1 new')).toBeTruthy()
|
|
196
196
|
})
|
|
197
197
|
|
|
198
|
+
it('replies under it new by count mark the comment too, and its row says how many (Ship, 2 November): "2 new"', () => {
|
|
199
|
+
const { container } = render(
|
|
200
|
+
<ConversationCard author={ONE} time="11:08 AM" replies={{ count: 3, newCount: 2 }}>
|
|
201
|
+
Words
|
|
202
|
+
</ConversationCard>,
|
|
203
|
+
)
|
|
204
|
+
expect(container.firstElementChild?.className).toMatch(/\bborder-accent-outline\b/)
|
|
205
|
+
expect(screen.getByText('2 new')).toBeTruthy()
|
|
206
|
+
})
|
|
207
|
+
|
|
198
208
|
it('read, it draws neither mark nor edge', () => {
|
|
199
209
|
const { container } = render(
|
|
200
210
|
<ConversationCard author={ONE} time="11:08 AM">
|
|
@@ -348,3 +358,60 @@ describe('its files, what it is about, and how it was resolved', () => {
|
|
|
348
358
|
expect(container.querySelector('[data-resolved="line"]')).toBeNull()
|
|
349
359
|
})
|
|
350
360
|
})
|
|
361
|
+
|
|
362
|
+
describe('an app’s own words and counts (Ship, 2 November: Ship takes the one conversation with its own words)', () => {
|
|
363
|
+
it('asks about a reply in the app’s noun, "Delete this message?", and as a reply by default', async () => {
|
|
364
|
+
render(
|
|
365
|
+
<ReplyCard author={ONE} time="11:40 AM" own onDelete={() => {}} noun="message">
|
|
366
|
+
A reply
|
|
367
|
+
</ReplyCard>,
|
|
368
|
+
)
|
|
369
|
+
point('A reply')
|
|
370
|
+
fireEvent.click(screen.getByRole('button', { name: 'More actions' }))
|
|
371
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
|
|
372
|
+
expect(await screen.findByText('Delete this message?')).toBeTruthy()
|
|
373
|
+
expect(screen.getByRole('button', { name: 'Delete message' })).toBeTruthy()
|
|
374
|
+
cleanup()
|
|
375
|
+
render(
|
|
376
|
+
<ReplyCard author={ONE} time="11:40 AM" own onDelete={() => {}}>
|
|
377
|
+
A reply
|
|
378
|
+
</ReplyCard>,
|
|
379
|
+
)
|
|
380
|
+
point('A reply')
|
|
381
|
+
fireEvent.click(screen.getByRole('button', { name: 'More actions' }))
|
|
382
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
|
|
383
|
+
expect(await screen.findByText('Delete this reply?')).toBeTruthy()
|
|
384
|
+
expect(screen.getByRole('button', { name: 'Delete reply' })).toBeTruthy()
|
|
385
|
+
})
|
|
386
|
+
|
|
387
|
+
it('names the ⋯ and its Delete row in the app’s words, "Message actions" and "Delete message", on a comment and a reply', async () => {
|
|
388
|
+
for (const Part of [ConversationCard, ReplyCard]) {
|
|
389
|
+
const onDelete = vi.fn()
|
|
390
|
+
render(
|
|
391
|
+
<Part author={ONE} time="11:08 AM" own onDelete={onDelete} noun="message" moreLabel="Message actions" deleteLabel="Delete message">
|
|
392
|
+
Words
|
|
393
|
+
</Part>,
|
|
394
|
+
)
|
|
395
|
+
point('Words')
|
|
396
|
+
expect(screen.queryByRole('button', { name: 'More actions' })).toBeNull()
|
|
397
|
+
fireEvent.click(screen.getByRole('button', { name: 'Message actions' }))
|
|
398
|
+
fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete message' }))
|
|
399
|
+
expect(await screen.findByText('Delete this message?')).toBeTruthy()
|
|
400
|
+
fireEvent.click(screen.getByRole('button', { name: 'Delete message' }))
|
|
401
|
+
await vi.waitFor(() => expect(onDelete).toHaveBeenCalledOnce())
|
|
402
|
+
cleanup()
|
|
403
|
+
}
|
|
404
|
+
})
|
|
405
|
+
|
|
406
|
+
it('says the ⋯ button’s name as its tooltip too', async () => {
|
|
407
|
+
const user = userEvent.setup()
|
|
408
|
+
render(
|
|
409
|
+
<ReplyCard author={ONE} time="11:40 AM" own onDelete={() => {}} moreLabel="Message actions">
|
|
410
|
+
A reply
|
|
411
|
+
</ReplyCard>,
|
|
412
|
+
)
|
|
413
|
+
point('A reply')
|
|
414
|
+
await user.hover(screen.getByRole('button', { name: 'Message actions' }))
|
|
415
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe('Message actions')
|
|
416
|
+
})
|
|
417
|
+
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
2
2
|
import { useState } from 'react'
|
|
3
|
+
import { userEvent, within } from 'storybook/test'
|
|
3
4
|
import { ConversationCard, type ConversationCardProps } from './ConversationCard'
|
|
4
|
-
import { Column, EditBox, Files, LONG, Mentions, ONE, SOME, THREE, TWO, WithBlock, WithCard, WORDS, YOU, useReactions } from './conversation.examples'
|
|
5
|
+
import { AT, Column, EditBox, Files, LONG, Mentions, ONE, SOME, THREE, TWO, WithBlock, WithCard, WORDS, YOU, useReactions } from './conversation.examples'
|
|
5
6
|
import { RichText } from './RichText'
|
|
6
7
|
import { MenuItem } from './Menu'
|
|
7
8
|
import type { ReactionCount } from './ReactionRow'
|
|
@@ -49,6 +50,15 @@ function Live({ start, resolvedAt, deletable = true, ...props }: ConversationCar
|
|
|
49
50
|
/** Someone's comment. */
|
|
50
51
|
export const Comment: Story = { render: (args) => <Live {...args} /> }
|
|
51
52
|
|
|
53
|
+
/** With its moment, `at`: the time says the exact date and time under the pointer. The story points at it. */
|
|
54
|
+
export const ExactTime: Story = {
|
|
55
|
+
name: 'Exact time',
|
|
56
|
+
render: (args) => <Live {...args} at={AT} />,
|
|
57
|
+
play: async ({ canvasElement }) => {
|
|
58
|
+
await userEvent.hover(within(canvasElement).getByText('11:08 AM'))
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
|
|
52
62
|
/** Yours: Edit and Delete in its ⋯ menu. */
|
|
53
63
|
export const Yours: Story = { render: (args) => <Live {...args} author={YOU} own /> }
|
|
54
64
|
|
|
@@ -85,6 +95,9 @@ export const New: Story = { render: (args) => <Live {...args} isNew /> }
|
|
|
85
95
|
/** A reply under it not read yet. */
|
|
86
96
|
export const NewReply: Story = { name: 'New reply', render: (args) => <Live {...args} replies={{ count: 2, faces: [TWO, THREE], last: '12:02 PM', isNew: true }} onClick={() => {}} /> }
|
|
87
97
|
|
|
98
|
+
/** Replies under it not read yet, by count: the row says how many. */
|
|
99
|
+
export const NewReplies: Story = { name: 'New replies, how many', render: (args) => <Live {...args} replies={{ count: 3, faces: [TWO, THREE, YOU], last: '12:02 PM', newCount: 2 }} onClick={() => {}} /> }
|
|
100
|
+
|
|
88
101
|
/** Urgent and not read yet. */
|
|
89
102
|
export const Urgent: Story = { render: (args) => <Live {...args} isNew urgent replies={{ count: 1, faces: [TWO], last: '12:02 PM', isNew: true }} /> }
|
|
90
103
|
|
|
@@ -128,6 +141,19 @@ export const ReadOnly: Story = { name: 'Read-only', render: (args) => <Live {...
|
|
|
128
141
|
/** A long comment, at its full height. */
|
|
129
142
|
export const Long: Story = { render: (args) => <Live {...args}>{LONG}</Live> }
|
|
130
143
|
|
|
144
|
+
/**
|
|
145
|
+
* Yours, in an app's own words: the ⋯ named "Message actions", its Delete row "Delete message", and the question
|
|
146
|
+
* asking about a message (`noun`). The story points at it and opens the menu.
|
|
147
|
+
*/
|
|
148
|
+
export const InAnAppsWords: Story = {
|
|
149
|
+
name: "In an app's words",
|
|
150
|
+
render: (args) => <Live {...args} author={YOU} own noun="message" deleteLabel="Delete message" moreLabel="Message actions" />,
|
|
151
|
+
play: async ({ canvasElement }) => {
|
|
152
|
+
await userEvent.hover(within(canvasElement).getByText(WORDS))
|
|
153
|
+
await userEvent.click(within(canvasElement).getByRole('button', { name: 'Message actions' }))
|
|
154
|
+
},
|
|
155
|
+
}
|
|
156
|
+
|
|
131
157
|
/** The app's own rows in its ⋯ menu, between Resolve and Edit. */
|
|
132
158
|
export const MoreRows: Story = {
|
|
133
159
|
name: 'More rows',
|
|
@@ -3,6 +3,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
3
3
|
import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
|
|
4
4
|
import userEvent from '@testing-library/user-event'
|
|
5
5
|
import { ConversationCard, ReplyCard } from './ConversationCard'
|
|
6
|
+
import { PinnedComment } from './PinnedComment'
|
|
6
7
|
|
|
7
8
|
afterEach(cleanup)
|
|
8
9
|
|
|
@@ -197,3 +198,78 @@ describe('ConversationCard, by the keyboard (Peek’s review, 1 November)', () =
|
|
|
197
198
|
expect(container.querySelector('[tabindex="0"]')).toBeNull()
|
|
198
199
|
})
|
|
199
200
|
})
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* The exact time on hover (B10, the audit of 2 November): Peek's words for it, the whole date and the time
|
|
204
|
+
* (`toLocaleString`, `dateStyle: 'long'`, `timeStyle: 'short'`), on every comment and reply, as Peek's rows of another
|
|
205
|
+
* app's comments always said it and as PageHeader's time does. Before, only those rows did, by hand.
|
|
206
|
+
*/
|
|
207
|
+
describe('ConversationCard and ReplyCard, the exact time', () => {
|
|
208
|
+
const AT = Date.UTC(2026, 10, 2, 11, 8)
|
|
209
|
+
const exact = new Date(AT).toLocaleString(undefined, { dateStyle: 'long', timeStyle: 'short' })
|
|
210
|
+
|
|
211
|
+
it('a comment’s time says the exact date and time under the pointer, and is a time the page can read', async () => {
|
|
212
|
+
const user = userEvent.setup()
|
|
213
|
+
render(
|
|
214
|
+
<ConversationCard author={ONE} time="11:08 AM" at={AT}>
|
|
215
|
+
Words
|
|
216
|
+
</ConversationCard>,
|
|
217
|
+
)
|
|
218
|
+
const time = screen.getByText('11:08 AM')
|
|
219
|
+
expect(time.tagName).toBe('TIME')
|
|
220
|
+
expect(time.getAttribute('datetime')).toBe(new Date(AT).toISOString())
|
|
221
|
+
await user.hover(time)
|
|
222
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe(exact)
|
|
223
|
+
})
|
|
224
|
+
|
|
225
|
+
it('a reply’s too', async () => {
|
|
226
|
+
const user = userEvent.setup()
|
|
227
|
+
render(
|
|
228
|
+
<ReplyCard author={ONE} time="11:08 AM" at={AT}>
|
|
229
|
+
Words
|
|
230
|
+
</ReplyCard>,
|
|
231
|
+
)
|
|
232
|
+
await user.hover(screen.getByText('11:08 AM'))
|
|
233
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe(exact)
|
|
234
|
+
})
|
|
235
|
+
|
|
236
|
+
it('a time that is a link says the exact time, then where the link goes', async () => {
|
|
237
|
+
const user = userEvent.setup()
|
|
238
|
+
render(
|
|
239
|
+
<ReplyCard author={ONE} time="11:08 AM" at={AT} timeHref="#reply" timeLabel="Link to this one">
|
|
240
|
+
Words
|
|
241
|
+
</ReplyCard>,
|
|
242
|
+
)
|
|
243
|
+
await user.hover(screen.getByRole('link', { name: '11:08 AM' }))
|
|
244
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe(`${exact} · Link to this one`)
|
|
245
|
+
})
|
|
246
|
+
|
|
247
|
+
it('a moment that is not one (not a number, endless) draws the time as with none, and breaks nothing', () => {
|
|
248
|
+
for (const at of [NaN, Infinity]) {
|
|
249
|
+
render(
|
|
250
|
+
<>
|
|
251
|
+
<ConversationCard author={ONE} time="11:08 AM" at={at}>
|
|
252
|
+
A comment
|
|
253
|
+
</ConversationCard>
|
|
254
|
+
<ReplyCard author={ONE} time="11:30 AM" at={at}>
|
|
255
|
+
A reply
|
|
256
|
+
</ReplyCard>
|
|
257
|
+
<PinnedComment author={ONE} time="Today at 11:08 AM" at={at} words="The comment" />
|
|
258
|
+
</>,
|
|
259
|
+
)
|
|
260
|
+
for (const time of ['11:08 AM', '11:30 AM', 'Today at 11:08 AM']) expect(screen.getByText(time).tagName).not.toBe('TIME')
|
|
261
|
+
cleanup()
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
it('with no moment, the time is the app’s words alone, as before', async () => {
|
|
266
|
+
const user = userEvent.setup()
|
|
267
|
+
render(
|
|
268
|
+
<ConversationCard author={ONE} time="11:08 AM">
|
|
269
|
+
Words
|
|
270
|
+
</ConversationCard>,
|
|
271
|
+
)
|
|
272
|
+
await user.hover(screen.getByText('11:08 AM'))
|
|
273
|
+
expect(screen.queryByRole('tooltip')).toBeNull()
|
|
274
|
+
})
|
|
275
|
+
})
|
package/src/ConversationCard.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useRef, useState, type
|
|
1
|
+
import { useContext, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
|
|
2
2
|
import { IconArrowNarrowRight, IconCircleCheck, IconDotsVertical } from '@tabler/icons-react'
|
|
3
3
|
import { Avatar } from './Avatar'
|
|
4
4
|
import { Card } from './Card'
|
|
@@ -6,6 +6,7 @@ import { cn } from './cn'
|
|
|
6
6
|
import { ConfirmDialog } from './ConfirmDialog'
|
|
7
7
|
import { ConversationActions } from './ConversationActions'
|
|
8
8
|
import { ConversationMenu } from './ConversationMenu'
|
|
9
|
+
import { repliesDrawn } from './conversationScroll'
|
|
9
10
|
import { EditedMarker } from './EditedMarker'
|
|
10
11
|
import { FieldLine } from './Field'
|
|
11
12
|
import { Link } from './Link'
|
|
@@ -13,7 +14,7 @@ import { MetaText } from './MetaText'
|
|
|
13
14
|
import { ReactionRow, type ReactionRowProps } from './ReactionRow'
|
|
14
15
|
import { RepliesRow, type RepliesRowProps } from './RepliesRow'
|
|
15
16
|
import { ResolveDialog } from './ResolveDialog'
|
|
16
|
-
import { InConversationItem, InThreadCard, useFaceLine } from './threadCard'
|
|
17
|
+
import { exactTime, InConversationItem, InThreadCard, momentOf, SHOWN_CLASSES, useFaceLine } from './threadCard'
|
|
17
18
|
import { ToolbarButton } from './Toolbar'
|
|
18
19
|
import { WithTooltip } from './Tooltip'
|
|
19
20
|
import { UnreadDot } from './UnreadDot'
|
|
@@ -32,6 +33,8 @@ export interface ConversationEntryProps {
|
|
|
32
33
|
author: ConversationPerson
|
|
33
34
|
/** When it was written, in the app's words ("11:08 AM"). */
|
|
34
35
|
time: ReactNode
|
|
36
|
+
/** When it was written, as a moment (ms since 1970): the time then says the exact date and time under the pointer. */
|
|
37
|
+
at?: number
|
|
35
38
|
/** A link to it: the time is then the link, "Link to this", as a reply's is. */
|
|
36
39
|
timeHref?: string
|
|
37
40
|
/** The time's tooltip when it is a link, in the app's words: "Link to this" by default; Peek's "Link to this message". */
|
|
@@ -75,6 +78,10 @@ export interface ConversationEntryProps {
|
|
|
75
78
|
menuLabel?: string
|
|
76
79
|
/** Edit's words in the ⋯ menu: "Edit" by default; Peek's "Edit message". */
|
|
77
80
|
editLabel?: string
|
|
81
|
+
/** Delete's words in the ⋯ menu: "Delete" by default; Ship's "Delete message". The question's button says `noun`'s. */
|
|
82
|
+
deleteLabel?: string
|
|
83
|
+
/** The ⋯ button's name and tooltip: "More actions" by default; Ship's "Message actions". */
|
|
84
|
+
moreLabel?: string
|
|
78
85
|
/** Placement only. */
|
|
79
86
|
className?: string
|
|
80
87
|
}
|
|
@@ -110,10 +117,39 @@ export interface ConversationCardProps extends ConversationEntryProps {
|
|
|
110
117
|
onClick?: () => void
|
|
111
118
|
}
|
|
112
119
|
|
|
113
|
-
export
|
|
120
|
+
export interface ReplyCardProps extends ConversationEntryProps {
|
|
121
|
+
/** Its id, on the card as `data-reply-id`: what a link to it shows (`showInConversation`), and what `Thread` watches to say it was seen. */
|
|
122
|
+
id?: string
|
|
123
|
+
/** What the reply is called in the delete question: "Delete this reply?" by default; Ship's `message`. */
|
|
124
|
+
noun?: string
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* When it was written: the app's words, and with its moment the exact date and time under the pointer (B10: as Peek's
|
|
129
|
+
* rows of another app's comments always said it, now on every comment and reply). A time that is a link says the exact
|
|
130
|
+
* time, then where the link goes.
|
|
131
|
+
*/
|
|
132
|
+
function When({ time, at: given, timeHref, timeLabel = 'Link to this' }: Pick<ConversationEntryProps, 'time' | 'at' | 'timeHref' | 'timeLabel'>) {
|
|
133
|
+
const at = momentOf(given)
|
|
134
|
+
const exact = at === undefined ? undefined : exactTime(at)
|
|
135
|
+
const said = at === undefined ? time : <time dateTime={new Date(at).toISOString()}>{time}</time>
|
|
136
|
+
if (timeHref) {
|
|
137
|
+
return (
|
|
138
|
+
<WithTooltip label={exact ? `${exact} · ${timeLabel}` : timeLabel} wrapperClassName="shrink-0">
|
|
139
|
+
<MetaText className="contents">
|
|
140
|
+
<Link href={timeHref} variant="quiet" data-interactive>
|
|
141
|
+
{said}
|
|
142
|
+
</Link>
|
|
143
|
+
</MetaText>
|
|
144
|
+
</WithTooltip>
|
|
145
|
+
)
|
|
146
|
+
}
|
|
147
|
+
// Drawn as Peek's rows of another app's comments drew it: the tooltip's own box round the time, inside its words' look.
|
|
148
|
+
return <MetaText className="shrink-0">{exact ? <WithTooltip label={exact}>{said}</WithTooltip> : time}</MetaText>
|
|
149
|
+
}
|
|
114
150
|
|
|
115
151
|
/** The face, the name, the time and "(edited)", with the new mark at the far right. `meta`: after "(edited)". */
|
|
116
|
-
function Head({ author, time, timeHref, timeLabel
|
|
152
|
+
function Head({ author, time, at, timeHref, timeLabel, edited, isNew, urgent, meta }: Pick<ConversationEntryProps, 'author' | 'time' | 'at' | 'timeHref' | 'timeLabel' | 'edited' | 'isNew' | 'urgent'> & { meta?: ReactNode }) {
|
|
117
153
|
return (
|
|
118
154
|
<div className="flex w-full items-center gap-2">
|
|
119
155
|
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
@@ -121,17 +157,7 @@ function Head({ author, time, timeHref, timeLabel = 'Link to this', edited, isNe
|
|
|
121
157
|
<Avatar size={24} src={author.picture} alt={author.name} bot={author.bot} />
|
|
122
158
|
</span>
|
|
123
159
|
<span className="min-w-0 truncate text-body-2-strong text-text-primary">{author.name}</span>
|
|
124
|
-
{timeHref
|
|
125
|
-
<WithTooltip label={timeLabel} wrapperClassName="shrink-0">
|
|
126
|
-
<MetaText className="contents">
|
|
127
|
-
<Link href={timeHref} variant="quiet" data-interactive>
|
|
128
|
-
{time}
|
|
129
|
-
</Link>
|
|
130
|
-
</MetaText>
|
|
131
|
-
</WithTooltip>
|
|
132
|
-
) : (
|
|
133
|
-
<MetaText className="shrink-0">{time}</MetaText>
|
|
134
|
-
)}
|
|
160
|
+
<When time={time} at={at} timeHref={timeHref} timeLabel={timeLabel} />
|
|
135
161
|
<EditedMarker edited={edited} />
|
|
136
162
|
{meta}
|
|
137
163
|
</div>
|
|
@@ -214,23 +240,6 @@ function Editing({ author, children }: { author: ConversationPerson; children: R
|
|
|
214
240
|
)
|
|
215
241
|
}
|
|
216
242
|
|
|
217
|
-
/**
|
|
218
|
-
* A press on the card opens its thread, wherever it lands on the card, but for what acts by itself: a button, a
|
|
219
|
-
* link, the strip, a field. A press in a picker or a menu the card opened lands here too, through React's tree, from
|
|
220
|
-
* outside the card: that is not a press on it. (Before, the whole reactions row and the strip stopped every press,
|
|
221
|
-
* so a press beside the reactions did nothing: Katerina, 31 October.)
|
|
222
|
-
*/
|
|
223
|
-
function pressed(e: MouseEvent<HTMLDivElement>, press: () => void) {
|
|
224
|
-
const target = e.target as HTMLElement
|
|
225
|
-
if (!e.currentTarget.contains(target)) return
|
|
226
|
-
// A double click picks a word and a drag picks words: neither is a press, or the thread would open and close under the reader.
|
|
227
|
-
if (e.detail > 1) return
|
|
228
|
-
const picked = typeof window === 'undefined' ? null : window.getSelection()
|
|
229
|
-
if (picked && !picked.isCollapsed && picked.anchorNode && e.currentTarget.contains(picked.anchorNode)) return
|
|
230
|
-
if (target.closest('button, a, input, textarea, [contenteditable="true"], [role="button"], [role="toolbar"], [data-interactive]')) return
|
|
231
|
-
press()
|
|
232
|
-
}
|
|
233
|
-
|
|
234
243
|
/**
|
|
235
244
|
* After its picker or its menu closes, a card keeps its strip only while it is still pointed at, or reached by the
|
|
236
245
|
* keyboard. A pointer that left while they were open sent the card no leave, and the strip stayed (the review, 1 November).
|
|
@@ -261,7 +270,7 @@ function useEditing(editing: boolean | undefined, onEditingChange: ((editing: bo
|
|
|
261
270
|
* The same card in every app, each in its own colours (the record that makes one conversation). Peek's, moved.
|
|
262
271
|
*/
|
|
263
272
|
export function ConversationCard(props: ConversationCardProps) {
|
|
264
|
-
const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, noun = 'comment', onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
|
|
273
|
+
const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, noun = 'comment', onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', className, children } = props
|
|
265
274
|
const readOnly = (props.readOnly ?? false) || deleted
|
|
266
275
|
const inThreadCard = useContext(InThreadCard)
|
|
267
276
|
|
|
@@ -314,22 +323,16 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
314
323
|
hovered={hovered}
|
|
315
324
|
selected={marked}
|
|
316
325
|
active={isEditing}
|
|
317
|
-
attention={attentionOf(isNew ||
|
|
326
|
+
attention={attentionOf(isNew || (replies?.newCount ?? (replies?.isNew ? 1 : 0)) > 0, urgent, inThreadCard)}
|
|
318
327
|
className={cn('relative', className)}
|
|
319
|
-
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
|
|
328
|
+
// A press opens its thread, wherever it lands on the card but for what acts by itself (Card's `onPress`). Before,
|
|
329
|
+
// the whole reactions row and the strip stopped every press, so a press beside the reactions did nothing
|
|
330
|
+
// (Katerina, 31 October). Not while its menu or picker is open: a press there is theirs.
|
|
331
|
+
onPress={press && !isEditing && !overlay ? press : undefined}
|
|
332
|
+
// Tab stops on it, which shows its strip, and Enter or Space opens it — and it stays a Tab stop while its menu is
|
|
333
|
+
// open, so focus has somewhere to come back to. Before, a comment with nothing focusable in it (no replies, no
|
|
334
|
+
// link) could not be opened without a pointer.
|
|
323
335
|
tabIndex={press && !isEditing ? 0 : undefined}
|
|
324
|
-
onKeyDown={
|
|
325
|
-
press && !isEditing && !overlay
|
|
326
|
-
? (e) => {
|
|
327
|
-
if (e.target !== e.currentTarget || (e.key !== 'Enter' && e.key !== ' ')) return
|
|
328
|
-
e.preventDefault()
|
|
329
|
-
press()
|
|
330
|
-
}
|
|
331
|
-
: undefined
|
|
332
|
-
}
|
|
333
336
|
onMouseEnter={() => setHovered(true)}
|
|
334
337
|
onMouseLeave={() => {
|
|
335
338
|
if (picking || menuOpen) return
|
|
@@ -352,6 +355,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
352
355
|
<Head
|
|
353
356
|
author={author}
|
|
354
357
|
time={props.time}
|
|
358
|
+
at={props.at}
|
|
355
359
|
timeHref={props.timeHref}
|
|
356
360
|
timeLabel={props.timeLabel}
|
|
357
361
|
edited={props.edited}
|
|
@@ -405,7 +409,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
405
409
|
offersMenu && (
|
|
406
410
|
<ConversationMenu
|
|
407
411
|
trigger={
|
|
408
|
-
<ToolbarButton tooltip=
|
|
412
|
+
<ToolbarButton tooltip={moreLabel} aria-label={moreLabel}>
|
|
409
413
|
<IconDotsVertical size={16} stroke={1.5} />
|
|
410
414
|
</ToolbarButton>
|
|
411
415
|
}
|
|
@@ -423,6 +427,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
423
427
|
editLabel={editLabel}
|
|
424
428
|
after={menuAfter}
|
|
425
429
|
onDelete={own && onDelete ? () => setDeleting(true) : undefined}
|
|
430
|
+
deleteLabel={deleteLabel}
|
|
426
431
|
>
|
|
427
432
|
{menu}
|
|
428
433
|
</ConversationMenu>
|
|
@@ -464,7 +469,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
464
469
|
* when it has one. Peek's, moved with the conversation.
|
|
465
470
|
*/
|
|
466
471
|
export function ReplyCard(props: ReplyCardProps) {
|
|
467
|
-
const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
|
|
472
|
+
const { id, author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', noun = 'reply', className, children } = props
|
|
468
473
|
const readOnly = props.readOnly ?? false
|
|
469
474
|
const [hovered, setHovered] = useState(false)
|
|
470
475
|
const [menuOpen, setMenuOpen] = useState(false)
|
|
@@ -476,6 +481,11 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
476
481
|
const showStrip = hovered && !isEditing && !readOnly && (offersMenu || !!reactions?.onToggle)
|
|
477
482
|
const root = useRef<HTMLDivElement>(null)
|
|
478
483
|
const settle = () => requestAnimationFrame(() => setHovered(stillHere(root.current)))
|
|
484
|
+
// In a Thread beside, a reply counts itself as it is first drawn: a new one takes the thread to its newest.
|
|
485
|
+
const drawn = useContext(repliesDrawn)
|
|
486
|
+
useLayoutEffect(() => {
|
|
487
|
+
if (drawn) drawn.added += 1
|
|
488
|
+
}, [drawn])
|
|
479
489
|
return (
|
|
480
490
|
<>
|
|
481
491
|
<Card
|
|
@@ -488,7 +498,8 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
488
498
|
active={isEditing}
|
|
489
499
|
// A reply is marked inside its thread card too.
|
|
490
500
|
attention={attentionOf(isNew, urgent, false)}
|
|
491
|
-
|
|
501
|
+
data-reply-id={id}
|
|
502
|
+
className={cn('relative', SHOWN_CLASSES, className)}
|
|
492
503
|
onMouseEnter={() => setHovered(true)}
|
|
493
504
|
onMouseLeave={() => {
|
|
494
505
|
if (picking || menuOpen) return
|
|
@@ -504,7 +515,7 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
504
515
|
<Editing author={author}>{editor(() => setEditing(false))}</Editing>
|
|
505
516
|
) : (
|
|
506
517
|
<div className="flex flex-col items-start px-2 pt-2">
|
|
507
|
-
<Head author={author} time={props.time} timeHref={props.timeHref} timeLabel={props.timeLabel} edited={props.edited} isNew={isNew} urgent={urgent} />
|
|
518
|
+
<Head author={author} time={props.time} at={props.at} timeHref={props.timeHref} timeLabel={props.timeLabel} edited={props.edited} isNew={isNew} urgent={urgent} />
|
|
508
519
|
{/* As on a comment: under the name, above the words. */}
|
|
509
520
|
{about && <div className="w-full pl-8 pr-2 pt-0.5">{about}</div>}
|
|
510
521
|
<Words>{children}</Words>
|
|
@@ -525,7 +536,7 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
525
536
|
offersMenu && (
|
|
526
537
|
<ConversationMenu
|
|
527
538
|
trigger={
|
|
528
|
-
<ToolbarButton tooltip=
|
|
539
|
+
<ToolbarButton tooltip={moreLabel} aria-label={moreLabel}>
|
|
529
540
|
<IconDotsVertical size={16} stroke={1.5} />
|
|
530
541
|
</ToolbarButton>
|
|
531
542
|
}
|
|
@@ -539,6 +550,7 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
539
550
|
editLabel={editLabel}
|
|
540
551
|
after={menuAfter}
|
|
541
552
|
onDelete={own && onDelete ? () => setDeleting(true) : undefined}
|
|
553
|
+
deleteLabel={deleteLabel}
|
|
542
554
|
>
|
|
543
555
|
{menu}
|
|
544
556
|
</ConversationMenu>
|
|
@@ -548,7 +560,7 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
548
560
|
)}
|
|
549
561
|
</Card>
|
|
550
562
|
{deleting && onDelete && (
|
|
551
|
-
<ConfirmDialog title=
|
|
563
|
+
<ConfirmDialog title={`Delete this ${noun}?`} confirmLabel={`Delete ${noun}`} destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
|
|
552
564
|
{deleteNote === undefined ? <p>It is deleted for everyone.</p> : typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote}
|
|
553
565
|
</ConfirmDialog>
|
|
554
566
|
)}
|