@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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
3
|
+
import { cleanup, render, screen } from '@testing-library/react'
|
|
4
|
+
import { ReactionHorizon } from './ReactionHorizon'
|
|
5
|
+
|
|
6
|
+
afterEach(cleanup)
|
|
7
|
+
|
|
8
|
+
describe('ReactionHorizon', () => {
|
|
9
|
+
it('says how far back reactions are read, in the kit’s words', () => {
|
|
10
|
+
render(<ReactionHorizon limit={100} omitted={3} />)
|
|
11
|
+
expect(screen.getByText(/the latest 100 comments and replies here\. 3 older ones were not checked\./)).toBeTruthy()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('in the app’s own noun: Peek’s messages', () => {
|
|
15
|
+
render(<ReactionHorizon limit={100} omitted={1} noun="messages" />)
|
|
16
|
+
expect(screen.getByText(/the latest 100 messages and replies here\. 1 older one was not checked\./)).toBeTruthy()
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('draws nothing when every one was checked and the read was whole', () => {
|
|
20
|
+
const { container } = render(<ReactionHorizon limit={100} omitted={0} />)
|
|
21
|
+
expect(container.textContent).toBe('')
|
|
22
|
+
})
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* While older comments are still read, the line keeps its room (Peek's PEE-7): the whole read will say it, so the
|
|
27
|
+
* newest comments do not move up when the rest lands under a reader at the bottom. Before, Peek drew a second,
|
|
28
|
+
* invisible line of its own for it.
|
|
29
|
+
*/
|
|
30
|
+
describe('ReactionHorizon, keeping its room', () => {
|
|
31
|
+
it('holds the room of the one-older line, unseen and unread, while it has nothing to say yet', () => {
|
|
32
|
+
const { container } = render(<ReactionHorizon limit={100} omitted={0} noun="messages" keepRoom />)
|
|
33
|
+
const kept = container.querySelector('p')
|
|
34
|
+
expect(kept).not.toBeNull()
|
|
35
|
+
expect(kept?.getAttribute('aria-hidden')).toBe('true')
|
|
36
|
+
expect(kept?.className).toContain('invisible')
|
|
37
|
+
// The room of the line it will be: Peek's copy said one older one.
|
|
38
|
+
expect(kept?.textContent).toBe('Reactions are shown for the latest 100 messages and replies here. 1 older one was not checked.')
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('says the line itself once it has something to say', () => {
|
|
42
|
+
const { container } = render(<ReactionHorizon limit={100} omitted={4} keepRoom />)
|
|
43
|
+
expect(container.querySelectorAll('p').length).toBe(1)
|
|
44
|
+
expect(container.querySelector('[aria-hidden]')).toBeNull()
|
|
45
|
+
expect(screen.getByText(/4 older ones were not checked\./)).toBeTruthy()
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('keeps the room under a cut read’s line too, as Peek drew both', () => {
|
|
49
|
+
const { container } = render(<ReactionHorizon limit={100} omitted={0} cut keepRoom />)
|
|
50
|
+
const lines = container.querySelectorAll('p')
|
|
51
|
+
expect(lines.length).toBe(2)
|
|
52
|
+
expect(lines[0].textContent).toBe('Some reactions may be missing.')
|
|
53
|
+
expect(lines[1].getAttribute('aria-hidden')).toBe('true')
|
|
54
|
+
})
|
|
55
|
+
})
|
package/src/ReactionHorizon.tsx
CHANGED
|
@@ -5,23 +5,42 @@ export interface ReactionHorizonProps {
|
|
|
5
5
|
omitted: number
|
|
6
6
|
/** Some reactions may be missing: the read was cut short. */
|
|
7
7
|
cut?: boolean
|
|
8
|
+
/** What the app calls what is said, in the plural: "messages" in Peek. Default "comments". */
|
|
9
|
+
noun?: string
|
|
10
|
+
/** Older comments are still being read and the whole read will need the line: its room is kept, unseen, so nothing moves when it lands. */
|
|
11
|
+
keepRoom?: boolean
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** The words of the line, for `omitted` older ones. */
|
|
15
|
+
function Said({ limit, omitted, noun }: { limit: number; omitted: number; noun: string }) {
|
|
16
|
+
return (
|
|
17
|
+
<>
|
|
18
|
+
Reactions are shown for the latest {limit} {noun} and replies here. {omitted} older {omitted === 1 ? 'one was' : 'ones were'} not checked.
|
|
19
|
+
</>
|
|
20
|
+
)
|
|
8
21
|
}
|
|
9
22
|
|
|
10
23
|
/**
|
|
11
24
|
* The line that says reactions are read only so far back, and how many older comments were not checked. Nothing is
|
|
12
25
|
* drawn when every one was. Peek's, moved with the conversation.
|
|
13
26
|
*/
|
|
14
|
-
export function ReactionHorizon({ limit, omitted, cut = false }: ReactionHorizonProps) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Reactions are shown for the latest {limit} comments and replies here. {omitted} older {omitted === 1 ? 'one was' : 'ones were'} not checked.
|
|
21
|
-
</>
|
|
22
|
-
)}
|
|
23
|
-
{omitted > 0 && cut && ' '}
|
|
24
|
-
{cut && 'Some reactions may be missing.'}
|
|
27
|
+
export function ReactionHorizon({ limit, omitted, cut = false, noun = 'comments', keepRoom = false }: ReactionHorizonProps) {
|
|
28
|
+
// While the rest is read, the room of the line it will be, with one older one, unseen: as Peek kept it (PEE-7), so
|
|
29
|
+
// the newest comments do not move up under a reader at the bottom when the rest lands.
|
|
30
|
+
const room = keepRoom && omitted <= 0 && (
|
|
31
|
+
<p aria-hidden className="invisible text-caption text-text-muted">
|
|
32
|
+
<Said limit={limit} omitted={1} noun={noun} />
|
|
25
33
|
</p>
|
|
26
34
|
)
|
|
35
|
+
if (omitted <= 0 && !cut) return room || null
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<p className="text-caption text-text-muted">
|
|
39
|
+
{omitted > 0 && <Said limit={limit} omitted={omitted} noun={noun} />}
|
|
40
|
+
{omitted > 0 && cut && ' '}
|
|
41
|
+
{cut && 'Some reactions may be missing.'}
|
|
42
|
+
</p>
|
|
43
|
+
{room}
|
|
44
|
+
</>
|
|
45
|
+
)
|
|
27
46
|
}
|
package/src/ReplyCard.mdx
CHANGED
|
@@ -13,7 +13,9 @@ One reply in a thread: the same pieces as a comment, without replies of its own
|
|
|
13
13
|
|
|
14
14
|
- **A reply**, inside a **Thread**, in time order.
|
|
15
15
|
- `timeHref`: its time is a link to it, "Link to this".
|
|
16
|
+
- `at`, its moment: the time says the exact date and time under the pointer; a time that is a link says it, then "Link to this".
|
|
16
17
|
- `own` on yours: Edit and Delete in its menu.
|
|
18
|
+
- `id` on every reply: on the card as `data-reply-id`, what a link to it shows (`showInConversation`) and what **Thread** watches to say it was seen.
|
|
17
19
|
|
|
18
20
|
<Canvas of={Stories.Yours} />
|
|
19
21
|
|
|
@@ -44,6 +46,7 @@ import { ReplyCard, Thread } from '@estiva-app/ui'
|
|
|
44
46
|
|---|---|---|
|
|
45
47
|
| Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
|
|
46
48
|
| Asks before it deletes | a confirm dialog | |
|
|
49
|
+
| Says the exact date and time under the pointer, from `at` | a tooltip round the time | |
|
|
47
50
|
|
|
48
51
|
## Props
|
|
49
52
|
|
|
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'
|
|
|
2
2
|
import { useState } from 'react'
|
|
3
3
|
import { userEvent, within } from 'storybook/test'
|
|
4
4
|
import { ReplyCard, type ReplyCardProps } from './ConversationCard'
|
|
5
|
-
import { Column, EditBox, Files, ONE, SHORT, SOME, WithCard, YOU, useReactions } from './conversation.examples'
|
|
5
|
+
import { AT, Column, EditBox, Files, ONE, SHORT, SOME, WithCard, YOU, useReactions } from './conversation.examples'
|
|
6
6
|
import type { ReactionCount } from './ReactionRow'
|
|
7
7
|
|
|
8
8
|
/** One reply, live: point at it to react, and on your own edit or delete it. */
|
|
@@ -64,5 +64,23 @@ export const Linked: Story = {
|
|
|
64
64
|
},
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
+
/** With its moment, `at`: the time says the exact date and time under the pointer. The story points at it. */
|
|
68
|
+
export const ExactTime: Story = {
|
|
69
|
+
name: 'Exact time',
|
|
70
|
+
render: (args) => <Live {...args} at={AT + 32 * 60_000} />,
|
|
71
|
+
play: async ({ canvasElement }) => {
|
|
72
|
+
await userEvent.hover(within(canvasElement).getByText('11:40 AM'))
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Its time a link, with its moment: the exact time, then where the link goes. The story points at it. */
|
|
77
|
+
export const LinkedExactTime: Story = {
|
|
78
|
+
name: 'Time is a link, exact time',
|
|
79
|
+
render: (args) => <Live {...args} at={AT + 32 * 60_000} timeHref="#reply" />,
|
|
80
|
+
play: async ({ canvasElement }) => {
|
|
81
|
+
await userEvent.hover(within(canvasElement).getByRole('link', { name: '11:40 AM' }))
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
|
|
67
85
|
/** Nothing can be changed: no strip, reactions only shown. */
|
|
68
86
|
export const ReadOnly: Story = { name: 'Read-only', render: (args) => <Live {...args} readOnly start={SOME} /> }
|
package/src/ResolveDialog.mdx
CHANGED
|
@@ -30,6 +30,8 @@ import { ResolveDialog } from '@estiva-app/ui'
|
|
|
30
30
|
|
|
31
31
|
- Ctrl+Enter resolves from the note; Enter there is a new line.
|
|
32
32
|
- Answer `false` from `onResolve` when it was refused, and pass why in `refused`.
|
|
33
|
+
Any other answer closes it, through `onCancel`.
|
|
34
|
+
- It is a **FormDialog**: while it resolves, the note and both buttons wait.
|
|
33
35
|
|
|
34
36
|
## What it owns
|
|
35
37
|
|
|
@@ -46,6 +46,27 @@ describe('ResolveDialog', () => {
|
|
|
46
46
|
expect(onResolve).not.toHaveBeenCalled()
|
|
47
47
|
})
|
|
48
48
|
|
|
49
|
+
it('Cancel waits while it resolves, as in every form dialog', async () => {
|
|
50
|
+
const user = userEvent.setup()
|
|
51
|
+
render(<ResolveDialog onResolve={() => new Promise<void>(() => {})} onCancel={() => {}} />)
|
|
52
|
+
await user.click(screen.getByRole('button', { name: 'Resolve' }))
|
|
53
|
+
expect((screen.getByRole('button', { name: 'Cancel' }) as HTMLButtonElement).disabled).toBe(true)
|
|
54
|
+
expect((screen.getByRole('button', { name: 'Resolve' }) as HTMLButtonElement).disabled).toBe(true)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('closes itself once a resolve is not refused, and stays when it is', async () => {
|
|
58
|
+
const user = userEvent.setup()
|
|
59
|
+
const onCancel = vi.fn()
|
|
60
|
+
const { unmount } = render(<ResolveDialog onResolve={async () => false} onCancel={onCancel} />)
|
|
61
|
+
await user.click(screen.getByRole('button', { name: 'Resolve' }))
|
|
62
|
+
await vi.waitFor(() => expect((screen.getByRole('button', { name: 'Resolve' }) as HTMLButtonElement).disabled).toBe(false))
|
|
63
|
+
expect(onCancel).not.toHaveBeenCalled()
|
|
64
|
+
unmount()
|
|
65
|
+
render(<ResolveDialog onResolve={async () => true} onCancel={onCancel} />)
|
|
66
|
+
await user.click(screen.getByRole('button', { name: 'Resolve' }))
|
|
67
|
+
await vi.waitFor(() => expect(onCancel).toHaveBeenCalledOnce())
|
|
68
|
+
})
|
|
69
|
+
|
|
49
70
|
it('says why the last resolve was refused, under the note', () => {
|
|
50
71
|
render(<ResolveDialog onResolve={() => false} onCancel={() => {}} refused="The file is archived" />)
|
|
51
72
|
expect(screen.getByText(/The file is archived/)).toBeTruthy()
|
package/src/ResolveDialog.tsx
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Button } from './Button'
|
|
3
|
-
import { DialogShell } from './DialogShell'
|
|
1
|
+
import { useState } from 'react'
|
|
4
2
|
import { Field } from './Field'
|
|
5
|
-
import {
|
|
3
|
+
import { FormDialog } from './FormDialog'
|
|
6
4
|
import { Textarea } from './Textarea'
|
|
7
5
|
|
|
8
6
|
export interface ResolveDialogProps {
|
|
9
7
|
/** Resolve, with what was written (an empty string for none). Answer `false` when it was refused: the dialog stays, with `refused` under the field. */
|
|
10
8
|
onResolve: (note: string) => Promise<boolean | void> | boolean | void
|
|
9
|
+
/** Cancel, Escape, the ✕ — and a resolve that was not refused, which closes it. */
|
|
11
10
|
onCancel: () => void
|
|
12
11
|
/** Why the last resolve was refused, in plain words. */
|
|
13
12
|
refused?: string
|
|
@@ -15,44 +14,17 @@ export interface ResolveDialogProps {
|
|
|
15
14
|
|
|
16
15
|
/**
|
|
17
16
|
* Resolve, with an optional note: the same dialog in every app (Katerina, 31 October). Ctrl+Enter resolves from the
|
|
18
|
-
* note; Enter there is a new line. Peek's, moved with the conversation
|
|
17
|
+
* note; Enter there is a new line. Peek's, moved with the conversation; a `FormDialog` since 2 November, so Cancel waits
|
|
18
|
+
* while it resolves and a resolve that went through closes it.
|
|
19
19
|
*/
|
|
20
20
|
export function ResolveDialog({ onResolve, onCancel, refused }: ResolveDialogProps) {
|
|
21
21
|
const [note, setNote] = useState('')
|
|
22
|
-
const [busy, setBusy] = useState(false)
|
|
23
|
-
const formId = useId()
|
|
24
22
|
return (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Cancel
|
|
32
|
-
</Button>
|
|
33
|
-
{/* Outlined at rest and green on hover in Signal, the kit's `resolve` look. */}
|
|
34
|
-
<Button variant="resolve" type="submit" form={formId} disabled={busy}>
|
|
35
|
-
Resolve
|
|
36
|
-
</Button>
|
|
37
|
-
</>
|
|
38
|
-
}
|
|
39
|
-
>
|
|
40
|
-
<Form
|
|
41
|
-
id={formId}
|
|
42
|
-
busy={busy}
|
|
43
|
-
onSubmit={async () => {
|
|
44
|
-
setBusy(true)
|
|
45
|
-
try {
|
|
46
|
-
await onResolve(note)
|
|
47
|
-
} finally {
|
|
48
|
-
setBusy(false)
|
|
49
|
-
}
|
|
50
|
-
}}
|
|
51
|
-
>
|
|
52
|
-
<Field label="Resolution message (optional)" error={refused}>
|
|
53
|
-
<Textarea autoFocus value={note} onChange={(e) => setNote(e.target.value)} placeholder="Summarize the outcome or decision..." className="h-[109px]" />
|
|
54
|
-
</Field>
|
|
55
|
-
</Form>
|
|
56
|
-
</DialogShell>
|
|
23
|
+
// Outlined at rest and green on hover in Signal, the kit's `resolve` look.
|
|
24
|
+
<FormDialog title="Resolve" submitLabel="Resolve" submitVariant="resolve" onSubmit={() => onResolve(note)} onClose={onCancel}>
|
|
25
|
+
<Field label="Resolution message (optional)" error={refused}>
|
|
26
|
+
<Textarea autoFocus value={note} onChange={(e) => setNote(e.target.value)} placeholder="Summarize the outcome or decision..." className="h-[109px]" />
|
|
27
|
+
</Field>
|
|
28
|
+
</FormDialog>
|
|
57
29
|
)
|
|
58
30
|
}
|
package/src/SelectionToolbar.tsx
CHANGED
|
@@ -20,8 +20,8 @@ import { shortcutLabel } from './shortcuts'
|
|
|
20
20
|
* the field opened (measured 2026-09-07). Linear keeps it, and Katerina asked
|
|
21
21
|
* for the same. The editor's own selection never moved — ProseMirror keeps it
|
|
22
22
|
* while unfocused — so this only *draws* it: an inline decoration over the
|
|
23
|
-
* range, in `bg-selected` — the token
|
|
24
|
-
* mapped through edits and cleared when the field closes.
|
|
23
|
+
* range, in `bg-selected` — the token every kit editor paints `::selection` in
|
|
24
|
+
* (`EDITOR_SELECTION_CLASSES`) — mapped through edits and cleared when the field closes.
|
|
25
25
|
*
|
|
26
26
|
* A decoration rather than a second selection, because a document has one
|
|
27
27
|
* and the field needs it. Editor-internal by design (the editor owns its own
|
package/src/Textarea.mdx
CHANGED
|
@@ -17,6 +17,7 @@ TextInput's look on a multi-line field that does not resize.
|
|
|
17
17
|
## When not
|
|
18
18
|
|
|
19
19
|
- One line → **TextInput**.
|
|
20
|
+
- Formatted text that lands as a document: blocks, marks, `[` and `@` → **DocumentField**.
|
|
20
21
|
- Editing text where it is displayed → **EditableText** with `multiline`.
|
|
21
22
|
|
|
22
23
|
## How
|
package/src/Thread.mdx
CHANGED
|
@@ -18,6 +18,14 @@ A comment's replies, with the box to write one: in the right column under its ow
|
|
|
18
18
|
|
|
19
19
|
<Canvas of={Stories.Resolved} />
|
|
20
20
|
|
|
21
|
+
- A link to a reply shows it: `showInConversation`, scrolled to the middle and flashed.
|
|
22
|
+
|
|
23
|
+
<Canvas of={Stories.Shown} />
|
|
24
|
+
|
|
25
|
+
- `seen`: its replies are watched, and a new one keeps its look until it has been seen.
|
|
26
|
+
|
|
27
|
+
<Canvas of={Stories.Seen} />
|
|
28
|
+
|
|
21
29
|
<Canvas of={Stories.Under} />
|
|
22
30
|
|
|
23
31
|
## When not
|
|
@@ -37,18 +45,27 @@ import { ReplyCard, Thread } from '@estiva-app/ui'
|
|
|
37
45
|
</Thread>
|
|
38
46
|
```
|
|
39
47
|
|
|
48
|
+
- A reply is read by being seen in its thread: `useSeenOnScreen(key)` for the thread, handed to `seen`, holds the ids of the replies that have been on screen a moment. Draw each reply's `isNew` from it.
|
|
49
|
+
- Beside, where it scrolls is the thread's: it opens at its newest reply, goes to each new **ReplyCard** drawn in it (a
|
|
50
|
+
line of your own among them takes it nowhere), and stays at the bottom while cards and pictures fill in. A reply
|
|
51
|
+
deleted moves nothing. Key each reply by its own id: another thread's replies are then drawn afresh, and it opens at
|
|
52
|
+
their newest, with or without a `start`.
|
|
40
53
|
- Its replies are yours to put in time order. Who resolved it is said on the comment, not among them.
|
|
41
54
|
- Still reading: `loading`. Nobody replied yet: nothing in `children`.
|
|
42
55
|
- An app whose empty thread said nothing keeps its silence with `empty={null}`; `closeLabel` names Close in its words for a screen reader.
|
|
43
|
-
- `start.id` is put on the pinned comment as `data-thread-start`,
|
|
56
|
+
- `start.id` is put on the pinned comment as `data-thread-start`, and each **ReplyCard**'s `id` on it as `data-reply-id`, as ConversationLayout's comments carry `data-conversation-item`. Give every reply its `id`.
|
|
57
|
+
- A link to a reply or to the comment shows it: `showInConversation(id)` scrolls it to the middle of the column and flashes it, and answers `false` when it is not drawn; `showInConversationWhenDrawn(id)` waits for a thread just asked to open, up to 3 seconds, and stops when a newer link is pressed. Never a wrapper of your own round a reply to carry its id, and never a flash of your own.
|
|
44
58
|
|
|
45
59
|
## What it owns
|
|
46
60
|
|
|
47
61
|
| It does | So you never write | Refused when written by hand |
|
|
48
62
|
|---|---|---|
|
|
49
63
|
| Pins the comment at the top, and keeps the box under the replies | a header and a fixed footer | |
|
|
64
|
+
| Beside: opens at its newest reply, goes to each new one, holds still while cards load | a scroll to the bottom, a ResizeObserver | |
|
|
50
65
|
| Placeholders while reading, and a line when nobody replied | a loading and an empty state | |
|
|
51
66
|
| "Resolved" in green at the top of the column | a chip | |
|
|
67
|
+
| Says which replies have been on screen a moment, with `seen` | an IntersectionObserver and a timer per reply | |
|
|
68
|
+
| The id on each reply and on the pinned comment, and the flash when a link shows one | a wrapper with an id, a flash in your CSS | |
|
|
52
69
|
|
|
53
70
|
## Props
|
|
54
71
|
|
package/src/Thread.stories.tsx
CHANGED
|
@@ -6,6 +6,8 @@ import { ConversationCard, ReplyCard } from './ConversationCard'
|
|
|
6
6
|
import { ConversationLayout } from './ConversationLayout'
|
|
7
7
|
import { ONE, SHORT, SOME, THREE, TWO, WORDS, WriteBox, YOU, useReactions } from './conversation.examples'
|
|
8
8
|
import { MembersPill } from './MembersPill'
|
|
9
|
+
import { useSeenOnScreen } from './seenOnScreen'
|
|
10
|
+
import { showInConversation } from './showInConversation'
|
|
9
11
|
import { Thread } from './Thread'
|
|
10
12
|
|
|
11
13
|
/** A comment's replies, with the box to write one: in the right column, or under its comment. */
|
|
@@ -27,17 +29,17 @@ function Side({ children }: { children: ReactNode }) {
|
|
|
27
29
|
)
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
const START = { author: ONE, time: '11:08 AM', words: WORDS }
|
|
32
|
+
const START = { id: 'c1', author: ONE, time: '11:08 AM', words: WORDS }
|
|
31
33
|
|
|
32
34
|
function Replies({ readOnly = false }: { readOnly?: boolean }) {
|
|
33
35
|
const one = useReactions(SOME)
|
|
34
36
|
const two = useReactions()
|
|
35
37
|
return (
|
|
36
38
|
<>
|
|
37
|
-
<ReplyCard author={TWO} time="11:40 AM" reactions={one} readOnly={readOnly}>
|
|
39
|
+
<ReplyCard id="r1" author={TWO} time="11:40 AM" reactions={one} readOnly={readOnly}>
|
|
38
40
|
{SHORT}
|
|
39
41
|
</ReplyCard>
|
|
40
|
-
<ReplyCard author={THREE} time="11:52 AM" reactions={two} readOnly={readOnly}>
|
|
42
|
+
<ReplyCard id="r2" author={THREE} time="11:52 AM" reactions={two} readOnly={readOnly}>
|
|
41
43
|
A second reply, under the first, in the order they were written.
|
|
42
44
|
</ReplyCard>
|
|
43
45
|
</>
|
|
@@ -55,6 +57,56 @@ export const Column: Story = {
|
|
|
55
57
|
),
|
|
56
58
|
}
|
|
57
59
|
|
|
60
|
+
/** A link to a reply showed it (`showInConversation`): scrolled to the middle of the column and flashed in the accent's wash, fading. The story shows the second reply. */
|
|
61
|
+
export const Shown: Story = {
|
|
62
|
+
name: 'A reply shown',
|
|
63
|
+
render: () => (
|
|
64
|
+
<Side>
|
|
65
|
+
<Thread start={START} onClose={() => {}} box={<WriteBox />}>
|
|
66
|
+
<Replies />
|
|
67
|
+
</Thread>
|
|
68
|
+
</Side>
|
|
69
|
+
),
|
|
70
|
+
play: () => {
|
|
71
|
+
showInConversation('r2')
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Read by being seen: a new reply keeps its edge until it has been on screen a moment (`useSeenOnScreen`, handed to `seen`). */
|
|
76
|
+
export const Seen: Story = {
|
|
77
|
+
name: 'New until seen',
|
|
78
|
+
render: function Render() {
|
|
79
|
+
const seen = useSeenOnScreen('story')
|
|
80
|
+
return (
|
|
81
|
+
<Side>
|
|
82
|
+
<Thread start={START} onClose={() => {}} box={<WriteBox />} seen={seen}>
|
|
83
|
+
<ReplyCard id="n1" author={TWO} time="11:40 AM" isNew={!seen.ids.has('n1')}>
|
|
84
|
+
{SHORT}
|
|
85
|
+
</ReplyCard>
|
|
86
|
+
<ReplyCard id="n2" author={THREE} time="11:52 AM" isNew={!seen.ids.has('n2')}>
|
|
87
|
+
A second reply, new too.
|
|
88
|
+
</ReplyCard>
|
|
89
|
+
</Thread>
|
|
90
|
+
</Side>
|
|
91
|
+
)
|
|
92
|
+
},
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** A long thread: it opens at its newest reply, and goes to each new one. */
|
|
96
|
+
export const Long: Story = {
|
|
97
|
+
render: () => (
|
|
98
|
+
<Side>
|
|
99
|
+
<Thread start={START} onClose={() => {}} box={<WriteBox />}>
|
|
100
|
+
{Array.from({ length: 9 }, (_, i) => (
|
|
101
|
+
<ReplyCard key={i} id={`l${i}`} author={[TWO, THREE, YOU][i % 3]} time={`11:${10 + i * 4} AM`}>
|
|
102
|
+
{i % 3 === 0 ? SHORT : `Reply ${i + 1}, in the order they were written.`}
|
|
103
|
+
</ReplyCard>
|
|
104
|
+
))}
|
|
105
|
+
</Thread>
|
|
106
|
+
</Side>
|
|
107
|
+
),
|
|
108
|
+
}
|
|
109
|
+
|
|
58
110
|
/** Resolved: "Resolved" at the top. Who resolved it, and the note, are said on the comment, not among the replies. */
|
|
59
111
|
export const Resolved: Story = {
|
|
60
112
|
render: () => (
|
package/src/Thread.test.tsx
CHANGED
|
@@ -98,3 +98,14 @@ describe('Thread, under its comment (one column)', () => {
|
|
|
98
98
|
expect(container.querySelector('[data-thread-replies]')).toBeNull()
|
|
99
99
|
})
|
|
100
100
|
})
|
|
101
|
+
|
|
102
|
+
describe('Thread, the pinned comment’s exact time (B10)', () => {
|
|
103
|
+
it('says the exact date and time under the pointer, as every comment’s time does', async () => {
|
|
104
|
+
const { default: userEvent } = await import('@testing-library/user-event')
|
|
105
|
+
const user = userEvent.setup()
|
|
106
|
+
const at = Date.UTC(2026, 10, 2, 11, 8)
|
|
107
|
+
render(<Thread start={{ ...START, at }} />)
|
|
108
|
+
await user.hover(screen.getByText('11:08 AM'))
|
|
109
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe(new Date(at).toLocaleString(undefined, { dateStyle: 'long', timeStyle: 'short' }))
|
|
110
|
+
})
|
|
111
|
+
})
|
package/src/Thread.tsx
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { Children, type ReactNode, type Ref } from 'react'
|
|
1
|
+
import { Children, useCallback, useContext, useLayoutEffect, useRef, useState, type ReactNode, type Ref } from 'react'
|
|
2
2
|
import { IconX } from '@tabler/icons-react'
|
|
3
3
|
import { Chip } from './Chip'
|
|
4
4
|
import { cn } from './cn'
|
|
5
|
+
import { repliesDrawn, useSteadyScroll } from './conversationScroll'
|
|
5
6
|
import { Divider } from './Divider'
|
|
6
7
|
import { EmptyState } from './EmptyState'
|
|
7
8
|
import { IconButton } from './IconButton'
|
|
8
9
|
import { Panel } from './Panel'
|
|
9
10
|
import { PinnedComment, type PinnedCommentProps } from './PinnedComment'
|
|
11
|
+
import { useWatchSeen, type SeenOnScreen } from './seenOnScreen'
|
|
10
12
|
import { SkeletonConversation } from './Skeleton'
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
+
import { caretOnOpen, LineByLayout, SHOWN_CLASSES } from './threadCard'
|
|
14
|
+
|
|
15
|
+
/** A thread is placed as it opens, at its newest: the keeper may act from the first change of size. */
|
|
16
|
+
const always = () => true
|
|
13
17
|
|
|
14
18
|
/** The comment a thread answers, pinned at the top of its column. */
|
|
15
19
|
export interface ThreadStart extends PinnedCommentProps {
|
|
@@ -22,7 +26,7 @@ export interface ThreadProps {
|
|
|
22
26
|
place?: 'beside' | 'under'
|
|
23
27
|
/** The comment it answers, pinned at the top of the column. Under its comment it is not repeated. */
|
|
24
28
|
start?: ThreadStart
|
|
25
|
-
/** Its replies, in time order: `ReplyCard`s. How it was resolved is said on its comment, not among them (Katerina, 1 November). */
|
|
29
|
+
/** Its replies, in time order: `ReplyCard`s, each keyed by its own id. How it was resolved is said on its comment, not among them (Katerina, 1 November). */
|
|
26
30
|
children?: ReactNode
|
|
27
31
|
/** Still reading the replies: placeholders in their place. */
|
|
28
32
|
loading?: boolean
|
|
@@ -42,8 +46,10 @@ export interface ThreadProps {
|
|
|
42
46
|
empty?: ReactNode
|
|
43
47
|
/** The column's name. */
|
|
44
48
|
title?: ReactNode
|
|
45
|
-
/**
|
|
49
|
+
/** Beside: the column's scrolling box. Where it scrolls is the thread's: it opens at the newest reply and goes to each new one. */
|
|
46
50
|
bodyRef?: Ref<HTMLDivElement>
|
|
51
|
+
/** Beside: what `useSeenOnScreen` made for this thread: it watches its replies (each `ReplyCard`'s `id`), and says in it which were seen. */
|
|
52
|
+
seen?: SeenOnScreen
|
|
47
53
|
/** Placement only. */
|
|
48
54
|
className?: string
|
|
49
55
|
}
|
|
@@ -77,8 +83,42 @@ export function Thread({
|
|
|
77
83
|
empty = 'No replies yet.',
|
|
78
84
|
title = 'Replies',
|
|
79
85
|
bodyRef,
|
|
86
|
+
seen,
|
|
80
87
|
className,
|
|
81
88
|
}: ThreadProps) {
|
|
89
|
+
const body = useRef<HTMLDivElement>(null)
|
|
90
|
+
// The column's box is the thread's, and lent to the app as `bodyRef`.
|
|
91
|
+
const setBody = useCallback(
|
|
92
|
+
(el: HTMLDivElement | null) => {
|
|
93
|
+
body.current = el
|
|
94
|
+
if (typeof bodyRef === 'function') bodyRef(el)
|
|
95
|
+
else if (bodyRef) bodyRef.current = el
|
|
96
|
+
},
|
|
97
|
+
[bodyRef],
|
|
98
|
+
)
|
|
99
|
+
// A reply is read by being seen in its thread (Peek's PEE-44): each one is watched.
|
|
100
|
+
useWatchSeen(seen, body, 'data-reply-id')
|
|
101
|
+
/*
|
|
102
|
+
Beside: it opens at its newest reply, before the paint, so it never shows its top for a frame and then jumps; and
|
|
103
|
+
it goes to the newest each time a reply is added, or another thread is drawn in it (Peek's OPT-9). Each ReplyCard
|
|
104
|
+
counts itself as it is first drawn in it: another thread's replies, keyed by their own ids, are drawn afresh and
|
|
105
|
+
take it to their newest whether or not it has a `start` and however many there are. A reply taken away (a delete)
|
|
106
|
+
is not counted, and the reader stays where they are (Peek's thread went to its bottom then). A line of the app's
|
|
107
|
+
own among them (a resolve history) takes it nowhere.
|
|
108
|
+
*/
|
|
109
|
+
const [drawn] = useState(() => ({ added: 0 }))
|
|
110
|
+
const last = useRef<{ added: number; start?: string } | null>(null)
|
|
111
|
+
const steady = useSteadyScroll(body, undefined, always, start?.id, place === 'beside')
|
|
112
|
+
useLayoutEffect(() => {
|
|
113
|
+
const el = body.current
|
|
114
|
+
if (place !== 'beside' || !el) return
|
|
115
|
+
const now = { added: drawn.added, start: start?.id }
|
|
116
|
+
if (last.current && last.current.added === now.added && last.current.start === now.start) return
|
|
117
|
+
last.current = now
|
|
118
|
+
el.scrollTop = el.scrollHeight
|
|
119
|
+
// And it stays there while the replies' cards, chips and pictures fill in (OPT-10).
|
|
120
|
+
steady.rebase()
|
|
121
|
+
})
|
|
82
122
|
const foot = notice ?? box
|
|
83
123
|
// In a ConversationLayout the layout draws the line, from the comment's face to the last reply, as one bar.
|
|
84
124
|
const layoutLine = useContext(LineByLayout)
|
|
@@ -103,7 +143,7 @@ export function Thread({
|
|
|
103
143
|
return (
|
|
104
144
|
<Panel
|
|
105
145
|
className={className}
|
|
106
|
-
bodyRef={
|
|
146
|
+
bodyRef={setBody}
|
|
107
147
|
bodyClassName="flex flex-col"
|
|
108
148
|
title={title}
|
|
109
149
|
actions={
|
|
@@ -120,16 +160,18 @@ export function Thread({
|
|
|
120
160
|
footer={foot && <div className="p-3">{foot}</div>}
|
|
121
161
|
>
|
|
122
162
|
{start && (
|
|
123
|
-
<div className=
|
|
124
|
-
<PinnedComment author={start.author} time={start.time} words={start.words} deleted={start.deleted} />
|
|
163
|
+
<div className={cn('px-4 pb-2 pt-4', SHOWN_CLASSES)} data-thread-start={start.id}>
|
|
164
|
+
<PinnedComment author={start.author} time={start.time} at={start.at} words={start.words} deleted={start.deleted} />
|
|
125
165
|
</div>
|
|
126
166
|
)}
|
|
127
167
|
<Divider look="section" label="Replies" className="px-4 py-2" />
|
|
128
168
|
<div className="flex flex-col gap-2 px-4 pb-4">
|
|
129
169
|
<caretOnOpen.Provider value={0}>
|
|
130
|
-
<
|
|
131
|
-
{
|
|
132
|
-
|
|
170
|
+
<repliesDrawn.Provider value={drawn}>
|
|
171
|
+
<Replies loading={loading} empty={empty}>
|
|
172
|
+
{children}
|
|
173
|
+
</Replies>
|
|
174
|
+
</repliesDrawn.Provider>
|
|
133
175
|
</caretOnOpen.Provider>
|
|
134
176
|
</div>
|
|
135
177
|
</Panel>
|
package/src/commentBoxFrame.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { Toolbar } from './Toolbar'
|
|
|
8
8
|
import { cn } from './cn'
|
|
9
9
|
import { richTextClassName } from './RichText'
|
|
10
10
|
import { ScrollArea } from './ScrollArea'
|
|
11
|
-
import { BOX_HINT_CLASSES, WRITING_BOX_CLASSES, WRITING_RING_CLASSES } from './looks'
|
|
11
|
+
import { BOX_HINT_CLASSES, EDITOR_SELECTION_CLASSES, WRITING_BOX_CLASSES, WRITING_RING_CLASSES } from './looks'
|
|
12
12
|
import { SelectionToolbar, type SelectionToolbarProps } from './SelectionToolbar'
|
|
13
13
|
import { isSuggestionActive } from './suggestionPopup'
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ import { isSuggestionActive } from './suggestionPopup'
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/** The classes the box's editor wears: rich text with no outline. It never scrolls itself; the box does, in a `ScrollArea`. */
|
|
26
|
-
export const COMPOSE_EDITOR_CLASSES = richTextClassName('default', 'outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1')
|
|
26
|
+
export const COMPOSE_EDITOR_CLASSES = richTextClassName('default', cn('outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1', EDITOR_SELECTION_CLASSES))
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* A long draft stops at half the window and scrolls inside the box, so its
|
|
@@ -28,6 +28,9 @@ export const TWO = { name: 'Person two' }
|
|
|
28
28
|
export const THREE = { name: 'Person three' }
|
|
29
29
|
export const YOU = { name: 'You' }
|
|
30
30
|
|
|
31
|
+
/** A moment for a time's exact date under the pointer: 11:08 AM, on a placeholder day. */
|
|
32
|
+
export const AT = new Date(2026, 9, 31, 11, 8).getTime()
|
|
33
|
+
|
|
31
34
|
export const WORDS = 'A comment says what its author wrote. Its replies sit in the thread under it, and anyone here can react.'
|
|
32
35
|
export const SHORT = 'A reply answers the comment above it.'
|
|
33
36
|
export const LONG =
|
|
@@ -125,10 +128,15 @@ export function EditBox({ text, done, refuse = false }: { text: string; done: ()
|
|
|
125
128
|
const uploaded = (file: File): Promise<UploadAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: true, value: file.name }), 900))
|
|
126
129
|
|
|
127
130
|
/** The box a reply or a comment is written in, with its tools as an app gives them: the paperclip. */
|
|
128
|
-
export function WriteBox({ label = 'Reply', closed }: { label?: string; closed?: string }) {
|
|
129
|
-
|
|
131
|
+
export function WriteBox({ label = 'Reply', closed, onSend }: { label?: string; closed?: string; onSend?: (words: string) => void }) {
|
|
132
|
+
// With `onSend`, the app draws what was written at once, as Peek does, before the answer.
|
|
133
|
+
const send = onSend ? (body: JSONContent) => (onSend(plainOf(body)), saved()) : saved
|
|
134
|
+
return <CommentBox people={[]} label={label} placeholder={`${label}…`} send={send} showsAtOnce={!!onSend} upload={uploaded} closed={closed ? { reason: closed } : undefined} />
|
|
130
135
|
}
|
|
131
136
|
|
|
137
|
+
/** The words of a box's body, plain. */
|
|
138
|
+
const plainOf = (body: JSONContent): string => (body.text ?? '') + (body.content ?? []).map(plainOf).join(body.type === 'doc' ? ' ' : '')
|
|
139
|
+
|
|
132
140
|
/** A column's width: 384px, every app's right column. */
|
|
133
141
|
export function Column({ children }: { children: ReactNode }) {
|
|
134
142
|
return <div className="flex w-[384px] flex-col gap-2">{children}</div>
|