@estiva-app/ui 0.98.0 → 0.99.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/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 +6 -1
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts +19 -4
- package/dist/ConversationLayout.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/MoveDialog.d.ts +61 -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 +5 -1
- package/dist/ReactionHorizon.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 +2210 -1458
- 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 +904 -139
- 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 +4 -0
- package/src/ConversationCard.stories.tsx +11 -1
- package/src/ConversationCard.test.tsx +116 -0
- package/src/ConversationCard.tsx +53 -36
- package/src/ConversationLayout.mdx +30 -4
- package/src/ConversationLayout.scroll.test.tsx +411 -0
- package/src/ConversationLayout.stories.tsx +79 -1
- package/src/ConversationLayout.test.tsx +79 -0
- package/src/ConversationLayout.tsx +136 -15
- 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/MoveDialog.mdx +74 -0
- package/src/MoveDialog.stories.tsx +121 -0
- package/src/MoveDialog.test.tsx +203 -0
- package/src/MoveDialog.tsx +183 -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 +3 -0
- package/src/ReactionHorizon.stories.tsx +3 -0
- package/src/ReactionHorizon.test.tsx +55 -0
- package/src/ReactionHorizon.tsx +30 -11
- package/src/ReplyCard.mdx +3 -0
- package/src/ReplyCard.stories.tsx +19 -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 +18 -1
- package/src/Thread.stories.tsx +55 -3
- package/src/Thread.test.tsx +11 -0
- package/src/Thread.tsx +53 -11
- 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 +182 -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 +7 -2
- 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
|
@@ -17,6 +17,7 @@ One comment, the same in every app: who, when, the words, files, cards, reaction
|
|
|
17
17
|
- `noun`: what the delete question calls it, "Delete this comment?" by default; a direct message says `message`.
|
|
18
18
|
- `about` on a comment on a part of the page: a **QuotedLine** under the name, above the words.
|
|
19
19
|
- `isNew`, `urgent`: the dot or the urgent mark, and a hairline, until it is read.
|
|
20
|
+
- `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
21
|
|
|
21
22
|
<Canvas of={Stories.Replies} />
|
|
22
23
|
|
|
@@ -56,6 +57,7 @@ import { ConversationCard } from '@estiva-app/ui'
|
|
|
56
57
|
- **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
58
|
- **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
59
|
- **Resolve opens the dialog**: **ResolveDialog**, then `onResolve(note)`. Answer `false` when it was refused; the dialog stays.
|
|
60
|
+
- `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
61
|
- 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
62
|
- The strip shows while the card is pointed at or has focus, and holds while its reactions or its menu are open.
|
|
61
63
|
|
|
@@ -64,7 +66,9 @@ import { ConversationCard } from '@estiva-app/ui'
|
|
|
64
66
|
| It does | So you never write | Refused when written by hand |
|
|
65
67
|
|---|---|---|
|
|
66
68
|
| Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
|
|
69
|
+
| 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 | |
|
|
67
70
|
| Asks before it deletes | a confirm dialog | |
|
|
71
|
+
| Says the exact date and time under the pointer, from `at` | a tooltip round the time | |
|
|
68
72
|
| Opens the Resolve dialog, and closes it once resolved | a dialog and its open state | |
|
|
69
73
|
| Says it is resolved, with who and the note, and hides nothing of it | a resolved line or chip of your own | |
|
|
70
74
|
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -157,3 +158,118 @@ describe('ReplyCard', () => {
|
|
|
157
158
|
expect(onDelete).toHaveBeenCalledOnce()
|
|
158
159
|
})
|
|
159
160
|
})
|
|
161
|
+
|
|
162
|
+
describe('ConversationCard, by the keyboard (Peek’s review, 1 November)', () => {
|
|
163
|
+
it('a card that opens on a press is a Tab stop: reaching it shows the strip, and Enter opens it', async () => {
|
|
164
|
+
const user = userEvent.setup()
|
|
165
|
+
const opened = vi.fn()
|
|
166
|
+
render(
|
|
167
|
+
<ConversationCard author={ONE} time="11:08 AM" onClick={opened} onReply={() => {}}>
|
|
168
|
+
A comment with nothing focusable in it
|
|
169
|
+
</ConversationCard>,
|
|
170
|
+
)
|
|
171
|
+
await user.tab()
|
|
172
|
+
const card = document.activeElement as HTMLElement
|
|
173
|
+
expect(card.textContent).toContain('A comment with nothing focusable in it')
|
|
174
|
+
expect(screen.getByRole('button', { name: 'Reply' })).toBeTruthy()
|
|
175
|
+
fireEvent.keyDown(card, { key: 'Enter' })
|
|
176
|
+
expect(opened).toHaveBeenCalledOnce()
|
|
177
|
+
fireEvent.keyDown(card, { key: ' ' })
|
|
178
|
+
expect(opened).toHaveBeenCalledTimes(2)
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
it('a key in a link inside it is the link’s, not a press on the card', () => {
|
|
182
|
+
const opened = vi.fn()
|
|
183
|
+
render(
|
|
184
|
+
<ConversationCard author={ONE} time="11:08 AM" onClick={opened}>
|
|
185
|
+
<a href="#somewhere">a link</a>
|
|
186
|
+
</ConversationCard>,
|
|
187
|
+
)
|
|
188
|
+
fireEvent.keyDown(screen.getByRole('link', { name: 'a link' }), { key: 'Enter' })
|
|
189
|
+
expect(opened).not.toHaveBeenCalled()
|
|
190
|
+
})
|
|
191
|
+
|
|
192
|
+
it('a card with nothing to open is no Tab stop', () => {
|
|
193
|
+
const { container } = render(
|
|
194
|
+
<ConversationCard author={ONE} time="11:08 AM" readOnly>
|
|
195
|
+
Nothing to open
|
|
196
|
+
</ConversationCard>,
|
|
197
|
+
)
|
|
198
|
+
expect(container.querySelector('[tabindex="0"]')).toBeNull()
|
|
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". */
|
|
@@ -110,10 +113,37 @@ export interface ConversationCardProps extends ConversationEntryProps {
|
|
|
110
113
|
onClick?: () => void
|
|
111
114
|
}
|
|
112
115
|
|
|
113
|
-
export
|
|
116
|
+
export interface ReplyCardProps extends ConversationEntryProps {
|
|
117
|
+
/** 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. */
|
|
118
|
+
id?: string
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* When it was written: the app's words, and with its moment the exact date and time under the pointer (B10: as Peek's
|
|
123
|
+
* rows of another app's comments always said it, now on every comment and reply). A time that is a link says the exact
|
|
124
|
+
* time, then where the link goes.
|
|
125
|
+
*/
|
|
126
|
+
function When({ time, at: given, timeHref, timeLabel = 'Link to this' }: Pick<ConversationEntryProps, 'time' | 'at' | 'timeHref' | 'timeLabel'>) {
|
|
127
|
+
const at = momentOf(given)
|
|
128
|
+
const exact = at === undefined ? undefined : exactTime(at)
|
|
129
|
+
const said = at === undefined ? time : <time dateTime={new Date(at).toISOString()}>{time}</time>
|
|
130
|
+
if (timeHref) {
|
|
131
|
+
return (
|
|
132
|
+
<WithTooltip label={exact ? `${exact} · ${timeLabel}` : timeLabel} wrapperClassName="shrink-0">
|
|
133
|
+
<MetaText className="contents">
|
|
134
|
+
<Link href={timeHref} variant="quiet" data-interactive>
|
|
135
|
+
{said}
|
|
136
|
+
</Link>
|
|
137
|
+
</MetaText>
|
|
138
|
+
</WithTooltip>
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
// Drawn as Peek's rows of another app's comments drew it: the tooltip's own box round the time, inside its words' look.
|
|
142
|
+
return <MetaText className="shrink-0">{exact ? <WithTooltip label={exact}>{said}</WithTooltip> : time}</MetaText>
|
|
143
|
+
}
|
|
114
144
|
|
|
115
145
|
/** 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
|
|
146
|
+
function Head({ author, time, at, timeHref, timeLabel, edited, isNew, urgent, meta }: Pick<ConversationEntryProps, 'author' | 'time' | 'at' | 'timeHref' | 'timeLabel' | 'edited' | 'isNew' | 'urgent'> & { meta?: ReactNode }) {
|
|
117
147
|
return (
|
|
118
148
|
<div className="flex w-full items-center gap-2">
|
|
119
149
|
<div className="flex min-w-0 flex-1 items-center gap-2">
|
|
@@ -121,17 +151,7 @@ function Head({ author, time, timeHref, timeLabel = 'Link to this', edited, isNe
|
|
|
121
151
|
<Avatar size={24} src={author.picture} alt={author.name} bot={author.bot} />
|
|
122
152
|
</span>
|
|
123
153
|
<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
|
-
)}
|
|
154
|
+
<When time={time} at={at} timeHref={timeHref} timeLabel={timeLabel} />
|
|
135
155
|
<EditedMarker edited={edited} />
|
|
136
156
|
{meta}
|
|
137
157
|
</div>
|
|
@@ -214,23 +234,6 @@ function Editing({ author, children }: { author: ConversationPerson; children: R
|
|
|
214
234
|
)
|
|
215
235
|
}
|
|
216
236
|
|
|
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
237
|
/**
|
|
235
238
|
* After its picker or its menu closes, a card keeps its strip only while it is still pointed at, or reached by the
|
|
236
239
|
* keyboard. A pointer that left while they were open sent the card no leave, and the strip stayed (the review, 1 November).
|
|
@@ -316,7 +319,14 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
316
319
|
active={isEditing}
|
|
317
320
|
attention={attentionOf(isNew || !!replies?.isNew, urgent, inThreadCard)}
|
|
318
321
|
className={cn('relative', className)}
|
|
319
|
-
|
|
322
|
+
// A press opens its thread, wherever it lands on the card but for what acts by itself (Card's `onPress`). Before,
|
|
323
|
+
// the whole reactions row and the strip stopped every press, so a press beside the reactions did nothing
|
|
324
|
+
// (Katerina, 31 October). Not while its menu or picker is open: a press there is theirs.
|
|
325
|
+
onPress={press && !isEditing && !overlay ? press : undefined}
|
|
326
|
+
// Tab stops on it, which shows its strip, and Enter or Space opens it — and it stays a Tab stop while its menu is
|
|
327
|
+
// open, so focus has somewhere to come back to. Before, a comment with nothing focusable in it (no replies, no
|
|
328
|
+
// link) could not be opened without a pointer.
|
|
329
|
+
tabIndex={press && !isEditing ? 0 : undefined}
|
|
320
330
|
onMouseEnter={() => setHovered(true)}
|
|
321
331
|
onMouseLeave={() => {
|
|
322
332
|
if (picking || menuOpen) return
|
|
@@ -339,6 +349,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
339
349
|
<Head
|
|
340
350
|
author={author}
|
|
341
351
|
time={props.time}
|
|
352
|
+
at={props.at}
|
|
342
353
|
timeHref={props.timeHref}
|
|
343
354
|
timeLabel={props.timeLabel}
|
|
344
355
|
edited={props.edited}
|
|
@@ -451,7 +462,7 @@ export function ConversationCard(props: ConversationCardProps) {
|
|
|
451
462
|
* when it has one. Peek's, moved with the conversation.
|
|
452
463
|
*/
|
|
453
464
|
export function ReplyCard(props: ReplyCardProps) {
|
|
454
|
-
const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
|
|
465
|
+
const { id, author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
|
|
455
466
|
const readOnly = props.readOnly ?? false
|
|
456
467
|
const [hovered, setHovered] = useState(false)
|
|
457
468
|
const [menuOpen, setMenuOpen] = useState(false)
|
|
@@ -463,6 +474,11 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
463
474
|
const showStrip = hovered && !isEditing && !readOnly && (offersMenu || !!reactions?.onToggle)
|
|
464
475
|
const root = useRef<HTMLDivElement>(null)
|
|
465
476
|
const settle = () => requestAnimationFrame(() => setHovered(stillHere(root.current)))
|
|
477
|
+
// In a Thread beside, a reply counts itself as it is first drawn: a new one takes the thread to its newest.
|
|
478
|
+
const drawn = useContext(repliesDrawn)
|
|
479
|
+
useLayoutEffect(() => {
|
|
480
|
+
if (drawn) drawn.added += 1
|
|
481
|
+
}, [drawn])
|
|
466
482
|
return (
|
|
467
483
|
<>
|
|
468
484
|
<Card
|
|
@@ -475,7 +491,8 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
475
491
|
active={isEditing}
|
|
476
492
|
// A reply is marked inside its thread card too.
|
|
477
493
|
attention={attentionOf(isNew, urgent, false)}
|
|
478
|
-
|
|
494
|
+
data-reply-id={id}
|
|
495
|
+
className={cn('relative', SHOWN_CLASSES, className)}
|
|
479
496
|
onMouseEnter={() => setHovered(true)}
|
|
480
497
|
onMouseLeave={() => {
|
|
481
498
|
if (picking || menuOpen) return
|
|
@@ -491,7 +508,7 @@ export function ReplyCard(props: ReplyCardProps) {
|
|
|
491
508
|
<Editing author={author}>{editor(() => setEditing(false))}</Editing>
|
|
492
509
|
) : (
|
|
493
510
|
<div className="flex flex-col items-start px-2 pt-2">
|
|
494
|
-
<Head author={author} time={props.time} timeHref={props.timeHref} timeLabel={props.timeLabel} edited={props.edited} isNew={isNew} urgent={urgent} />
|
|
511
|
+
<Head author={author} time={props.time} at={props.at} timeHref={props.timeHref} timeLabel={props.timeLabel} edited={props.edited} isNew={isNew} urgent={urgent} />
|
|
495
512
|
{/* As on a comment: under the name, above the words. */}
|
|
496
513
|
{about && <div className="w-full pl-8 pr-2 pt-0.5">{about}</div>}
|
|
497
514
|
<Words>{children}</Words>
|
|
@@ -14,6 +14,9 @@ Where a conversation's cards sit: two columns, or one 384px column beside the pa
|
|
|
14
14
|
- `threads="beside"`, two columns: the comments fill the page; an open thread stands beside them, 384px.
|
|
15
15
|
- `threads="under"`, one column: the comments are the 384px column beside the page; a thread opens under its comment, and the two become one card.
|
|
16
16
|
- With two columns, `header` puts the comments' own **PageHeader** over their column only, and the thread runs the page's full height beside it.
|
|
17
|
+
- With two columns, `aside` is what the 384px column holds while no thread is open: the page's own **Panel** beside its comments (an overview). A thread opened takes its place.
|
|
18
|
+
|
|
19
|
+
<Canvas of={Stories.TwoColumnsAside} />
|
|
17
20
|
- With two columns, each comment's `day` names its stretch with a line that stays at the top while the stretch scrolls (Peek's day lines).
|
|
18
21
|
|
|
19
22
|
<Canvas of={Stories.TwoColumnsDays} />
|
|
@@ -42,16 +45,37 @@ import { ConversationLayout } from '@estiva-app/ui'
|
|
|
42
45
|
- Which layout is the app's: where a conversation sits is its own.
|
|
43
46
|
- The right column is 384px in every app.
|
|
44
47
|
- The app keeps `open`; the layout says when it changes, with `onOpenChange`. Give every comment a `thread`, a
|
|
45
|
-
**Thread** with its box, even one with no replies yet: pressing it opens it to its box.
|
|
48
|
+
**Thread** with its box, even one with no replies yet: pressing it opens it to its box. An app that builds only the
|
|
49
|
+
open thread gives a function, `thread: () => threadOf(comment)`: it is called only while that one is open.
|
|
50
|
+
- Draw no column of your own for the thread or for the panel beside the comments: `aside`. The column catches what
|
|
51
|
+
throws in it, and says so in its place; the comments stay.
|
|
46
52
|
- Write nothing on the cards for opening: no `onClick`, `selected`, `onReply`, or the replies row's `onOpen` and
|
|
47
53
|
`open`. The layout gives each **ConversationCard** its place, and the card opens its thread from it. What a card is
|
|
48
54
|
given still wins.
|
|
49
|
-
- Two columns,
|
|
50
|
-
|
|
55
|
+
- Two columns, where the comments scroll is the layout's, the same in every app: they open at the newest; they
|
|
56
|
+
follow what arrives only while the reader is at the bottom (within 80px); the reader's own comment, sent from `box`,
|
|
57
|
+
brings them down to it as it is drawn, and a refusal leaves them where they are; and they hold still while cards and
|
|
58
|
+
pictures fill in. Give the conversation its name, `rememberAs` (its address), and going back to it lands where it was
|
|
59
|
+
left, in this tab. `useLeftAt(name)` says when the reader left it away from the newest, for your "New" line in
|
|
60
|
+
`before` over the first comment written since. Keep no place of your own: `bodyRef` and `onBodyScroll` only read the box.
|
|
61
|
+
|
|
62
|
+
<Canvas of={Stories.TwoColumnsLong} />
|
|
63
|
+
|
|
64
|
+
- Each comment's `day` draws the app's day lines,
|
|
51
65
|
each staying at the top while its own day scrolls under it; `before` is a line just above one comment (a "New"
|
|
52
66
|
line); `below` is under the comments (a **ReactionHorizon**); `top` stands at the top however few the comments are
|
|
53
67
|
(an **ArchivedNotice**). Few comments sit on the box, as a chat does. `empty` may be the app's own **EmptyState**,
|
|
54
68
|
or `null` for nothing.
|
|
69
|
+
- A comment is read by being seen: `useSeenOnScreen(key)` for the conversation, handed to `seen`, holds the ids of the
|
|
70
|
+
comments that have been on screen a moment (half of the card, or 120px of a taller one, for 1.5 seconds, in a tab
|
|
71
|
+
that is not hidden). Draw `isNew` from it; mark the conversation read from it. `key` `null` watches nothing, until you
|
|
72
|
+
have judged what is new. Never an observer of your own.
|
|
73
|
+
|
|
74
|
+
<Canvas of={Stories.TwoColumnsSeen} />
|
|
75
|
+
|
|
76
|
+
- A link to a comment shows it: `showInConversation(id, { comments: true })` scrolls it to the middle and flashes it
|
|
77
|
+
(the open thread's pinned comment first, when it is that one's); `false` when it is not drawn. Each comment carries
|
|
78
|
+
its `id` as `data-conversation-item`. See **Thread** for replies.
|
|
55
79
|
- The box at the foot of a thread that opens takes the caret, at its end, without scrolling: the layout tells it with
|
|
56
80
|
`caretOnOpen`, which **CommentBox** reads. Nothing to pass; a box outside a layout never takes it this way.
|
|
57
81
|
|
|
@@ -65,8 +89,10 @@ import { ConversationLayout } from '@estiva-app/ui'
|
|
|
65
89
|
| Opens and closes in place: the comment is never redrawn and does not move, open or closed | a wrapper that changes when it opens | |
|
|
66
90
|
| One column: resolved comments and comments on deleted blocks closed under their names at the end, opened for the thread open in them | the groups, their counts, opening one | |
|
|
67
91
|
| Puts the caret in the box of a thread that opens, without scrolling | a focus call | |
|
|
92
|
+
| Two columns: opens at the newest, comes back to where it was left, follows only a reader at the bottom, goes down to the reader's own comment, holds still while cards load | a scroll policy, a place per conversation, a ResizeObserver | |
|
|
68
93
|
| Placeholders while reading, and a line when there are none | a loading and an empty state | |
|
|
69
|
-
|
|
|
94
|
+
| Says which comments have been on screen a moment, with `seen` | an IntersectionObserver and a timer per card | |
|
|
95
|
+
| The right column at 384px, in every app: the open thread, or the page's `aside` | a width, a column, its error boundary | |
|
|
70
96
|
|
|
71
97
|
## Props
|
|
72
98
|
|