@estiva-app/ui 0.96.0 → 0.98.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/dist/Avatar.d.ts +6 -1
- package/dist/Avatar.d.ts.map +1 -1
- package/dist/AvatarGroup.d.ts +2 -0
- package/dist/AvatarGroup.d.ts.map +1 -1
- package/dist/ComposerTriggers.d.ts +2 -0
- package/dist/ComposerTriggers.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +26 -6
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts +18 -6
- package/dist/ConversationLayout.d.ts.map +1 -1
- package/dist/ConversationMenu.d.ts +14 -5
- package/dist/ConversationMenu.d.ts.map +1 -1
- package/dist/LinkParts.d.ts +1 -0
- package/dist/LinkParts.d.ts.map +1 -1
- package/dist/MembersDialog.d.ts +4 -0
- package/dist/MembersDialog.d.ts.map +1 -1
- package/dist/Person.d.ts +3 -1
- package/dist/Person.d.ts.map +1 -1
- package/dist/PersonTrigger.d.ts +1 -1
- package/dist/PersonTrigger.d.ts.map +1 -1
- package/dist/RepliesRow.d.ts +1 -0
- package/dist/RepliesRow.d.ts.map +1 -1
- package/dist/Thread.d.ts +9 -2
- package/dist/Thread.d.ts.map +1 -1
- package/dist/editor.js +1 -1
- package/dist/editor.js.map +2 -2
- package/dist/index.js +196 -92
- package/dist/index.js.map +3 -3
- package/dist/linked.d.ts +4 -0
- package/dist/linked.d.ts.map +1 -1
- package/dist/linkedFrom.d.ts +2 -0
- package/dist/linkedFrom.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +153 -19
- package/src/Avatar.agent.test.tsx +63 -0
- package/src/Avatar.mdx +25 -0
- package/src/Avatar.stories.tsx +13 -0
- package/src/Avatar.tsx +51 -3
- package/src/AvatarGroup.tsx +3 -1
- package/src/ComposerTriggers.stories.tsx +2 -0
- package/src/ComposerTriggers.tsx +3 -1
- package/src/ConversationCard.mdx +3 -2
- package/src/ConversationCard.states.test.tsx +25 -5
- package/src/ConversationCard.stories.tsx +3 -3
- package/src/ConversationCard.test.tsx +4 -4
- package/src/ConversationCard.tsx +60 -38
- package/src/ConversationLayout.mdx +12 -0
- package/src/ConversationLayout.stories.tsx +47 -0
- package/src/ConversationLayout.test.tsx +100 -0
- package/src/ConversationLayout.tsx +98 -20
- package/src/ConversationMenu.mdx +5 -2
- package/src/ConversationMenu.stories.tsx +19 -1
- package/src/ConversationMenu.test.tsx +17 -4
- package/src/ConversationMenu.tsx +37 -16
- package/src/LinkCard.tsx +3 -3
- package/src/LinkChip.tsx +1 -1
- package/src/LinkParts.tsx +4 -4
- package/src/LinkRow.tsx +1 -1
- package/src/MembersDialog.stories.tsx +11 -0
- package/src/MembersDialog.tsx +7 -3
- package/src/Person.tsx +4 -2
- package/src/PersonTrigger.tsx +3 -3
- package/src/PinnedComment.tsx +1 -1
- package/src/RepliesRow.tsx +2 -2
- package/src/Thread.mdx +2 -0
- package/src/Thread.test.tsx +17 -0
- package/src/Thread.tsx +32 -8
- package/src/linked.ts +4 -0
- package/src/linkedFrom.test.tsx +18 -0
- package/src/linkedFrom.ts +7 -5
- package/src/registry/registry.test.ts +2 -1
- package/stories/Choosing.mdx +1 -1
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react'
|
|
1
|
+
import { Fragment, useEffect, useLayoutEffect, useRef, useState, type ReactNode, type Ref, type UIEventHandler } from 'react'
|
|
2
2
|
import { Card } from './Card'
|
|
3
3
|
import { Chip } from './Chip'
|
|
4
4
|
import { CollapsibleSection } from './CollapsibleSection'
|
|
5
5
|
import { cn } from './cn'
|
|
6
|
+
import { ContainerHeader } from './ContainerHeader'
|
|
7
|
+
import { Divider } from './Divider'
|
|
6
8
|
import { EmptyState } from './EmptyState'
|
|
9
|
+
import { ErrorBoundary } from './ErrorBoundary'
|
|
7
10
|
import { Panel } from './Panel'
|
|
8
11
|
import { ScrollArea } from './ScrollArea'
|
|
9
12
|
import { SkeletonConversation } from './Skeleton'
|
|
@@ -20,6 +23,10 @@ export interface ConversationItem {
|
|
|
20
23
|
resolved?: boolean
|
|
21
24
|
/** What it was on was deleted from the page. In one column it waits under "On deleted blocks", closed, before "Resolved"; a resolved one is under "Resolved". */
|
|
22
25
|
gone?: boolean
|
|
26
|
+
/** Two columns: the day it was written, in the app's words ("Today", "Monday"). Comments of one day are one stretch under a line naming it, which stays at the top while its stretch scrolls under it. */
|
|
27
|
+
day?: string
|
|
28
|
+
/** Two columns: drawn just above it, 8px off, inside its day: the app's "New" line over the first comment not read. */
|
|
29
|
+
before?: ReactNode
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
export interface ConversationLayoutProps {
|
|
@@ -36,15 +43,23 @@ export interface ConversationLayoutProps {
|
|
|
36
43
|
onOpenChange?: (id: string | undefined) => void
|
|
37
44
|
/** The box a new comment is written in, under the comments. */
|
|
38
45
|
box?: ReactNode
|
|
39
|
-
/** Above the comments, inside their list:
|
|
46
|
+
/** Above the comments, inside their list: placeholders while older comments are read, a note. */
|
|
40
47
|
above?: ReactNode
|
|
48
|
+
/** Two columns: under the comments, inside their list, or under the empty line: a `ReactionHorizon`. Not while the comments are read. */
|
|
49
|
+
below?: ReactNode
|
|
50
|
+
/** Two columns: at the top of the column however few the comments are, over the room a short conversation leaves: an `ArchivedNotice`. */
|
|
51
|
+
top?: ReactNode
|
|
41
52
|
/** Still reading the comments. */
|
|
42
53
|
loading?: boolean
|
|
43
|
-
/** What an empty conversation says. */
|
|
44
|
-
empty?:
|
|
54
|
+
/** What an empty conversation says: words, or the app's own `EmptyState` (a read that failed says so). `null`: nothing. */
|
|
55
|
+
empty?: ReactNode
|
|
56
|
+
/** Two columns: the comments' scrolling box, for an app that keeps its own place in it (where it was left, its "New" line, following what arrives). */
|
|
57
|
+
bodyRef?: Ref<HTMLDivElement>
|
|
58
|
+
/** Two columns: the comments' box scrolled. */
|
|
59
|
+
onBodyScroll?: UIEventHandler<HTMLDivElement>
|
|
45
60
|
/** Two columns: the comments' own header, a `PageHeader`, over their column only, so the thread beside them runs the page's full height (Peek's way). */
|
|
46
61
|
header?: ReactNode
|
|
47
|
-
/**
|
|
62
|
+
/** Its name: one column's, in its header. Two columns, said with the message if the column breaks (the page's own bar is `header`). */
|
|
48
63
|
title?: ReactNode
|
|
49
64
|
/** One column: its header's actions, as a `Panel`'s. */
|
|
50
65
|
actions?: ReactNode
|
|
@@ -58,7 +73,7 @@ interface ListProps {
|
|
|
58
73
|
under: boolean
|
|
59
74
|
above?: ReactNode
|
|
60
75
|
loading: boolean
|
|
61
|
-
empty:
|
|
76
|
+
empty: ReactNode
|
|
62
77
|
/** Asked to open or close: `id` is the comment pressed, `next` what is open after; `reply`, asked by Reply. */
|
|
63
78
|
change?: (id: string, next: string | undefined, reply?: boolean) => void
|
|
64
79
|
/** How many times a thread has opened: its box takes the caret each time. */
|
|
@@ -68,7 +83,7 @@ interface ListProps {
|
|
|
68
83
|
/** The list's own room: placeholders, the empty line, or the comments 8px apart. */
|
|
69
84
|
function List({ items, open, under, above, loading, empty, change, caret }: ListProps) {
|
|
70
85
|
if (loading) return <SkeletonConversation />
|
|
71
|
-
if (items.length === 0) return <EmptyState scope="section" message={empty} />
|
|
86
|
+
if (items.length === 0) return typeof empty === 'string' ? <EmptyState scope="section" message={empty} /> : <>{empty}</>
|
|
72
87
|
// How each card opens its thread: only one that has a thread, and only when the app keeps `open`.
|
|
73
88
|
const stateOf = (item: ConversationItem): ConversationItemState | null =>
|
|
74
89
|
change && item.thread
|
|
@@ -82,18 +97,47 @@ function List({ items, open, under, above, loading, empty, change, caret }: List
|
|
|
82
97
|
const draw = (item: ConversationItem) => {
|
|
83
98
|
if (!under) {
|
|
84
99
|
return (
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
100
|
+
<Fragment key={item.id}>
|
|
101
|
+
{item.before}
|
|
102
|
+
<div data-conversation-item={item.id} className="flex flex-col">
|
|
103
|
+
<InConversationItem.Provider value={stateOf(item)}>{item.card}</InConversationItem.Provider>
|
|
104
|
+
</div>
|
|
105
|
+
</Fragment>
|
|
88
106
|
)
|
|
89
107
|
}
|
|
90
108
|
return <UnderItem key={item.id} item={item} isOpen={open === item.id && !!item.thread} state={stateOf(item)} caret={caret} />
|
|
91
109
|
}
|
|
92
110
|
if (!under) {
|
|
111
|
+
// Two columns: a day's comments are one stretch under its line, so the line stays at the top only while its own
|
|
112
|
+
// stretch scrolls under it, and the next day's pushes it away (Peek's day lines).
|
|
113
|
+
// Keyed by its day, not its place, so older comments arriving at the top redraw nothing under them; a day that
|
|
114
|
+
// comes back further down (an app's own order) is that day's second stretch.
|
|
115
|
+
const stretches: { key: string; day?: string; items: ConversationItem[] }[] = []
|
|
116
|
+
const seen = new Map<string, number>()
|
|
117
|
+
for (const item of items) {
|
|
118
|
+
const last = stretches[stretches.length - 1]
|
|
119
|
+
if (last && last.day === item.day) {
|
|
120
|
+
last.items.push(item)
|
|
121
|
+
continue
|
|
122
|
+
}
|
|
123
|
+
const name = item.day ?? ''
|
|
124
|
+
const count = (seen.get(name) ?? 0) + 1
|
|
125
|
+
seen.set(name, count)
|
|
126
|
+
stretches.push({ key: `${item.day === undefined ? 'no-day' : `day:${name}`}#${count}`, day: item.day, items: [item] })
|
|
127
|
+
}
|
|
93
128
|
return (
|
|
94
129
|
<>
|
|
95
130
|
{above}
|
|
96
|
-
{
|
|
131
|
+
{stretches.map((stretch) =>
|
|
132
|
+
stretch.day === undefined ? (
|
|
133
|
+
<Fragment key={stretch.key}>{stretch.items.map(draw)}</Fragment>
|
|
134
|
+
) : (
|
|
135
|
+
<div key={stretch.key} className="flex flex-col gap-2">
|
|
136
|
+
<Divider look="section" label={stretch.day} sticky />
|
|
137
|
+
{stretch.items.map(draw)}
|
|
138
|
+
</div>
|
|
139
|
+
),
|
|
140
|
+
)}
|
|
97
141
|
</>
|
|
98
142
|
)
|
|
99
143
|
}
|
|
@@ -171,7 +215,24 @@ function UnderItem({ item, isOpen, state, caret }: { item: ConversationItem; isO
|
|
|
171
215
|
* comments are the 384px column beside the page, and a thread opens under its comment, the two one card. The right column is 384px in
|
|
172
216
|
* every app (Katerina, 31 October). With two columns the thread runs the full height, beside the comments' header.
|
|
173
217
|
*/
|
|
174
|
-
export function ConversationLayout({
|
|
218
|
+
export function ConversationLayout({
|
|
219
|
+
threads,
|
|
220
|
+
items,
|
|
221
|
+
open,
|
|
222
|
+
onOpenChange,
|
|
223
|
+
box,
|
|
224
|
+
above,
|
|
225
|
+
below,
|
|
226
|
+
top,
|
|
227
|
+
loading = false,
|
|
228
|
+
empty = 'No comments yet.',
|
|
229
|
+
header,
|
|
230
|
+
title = 'Comments',
|
|
231
|
+
actions,
|
|
232
|
+
bodyRef,
|
|
233
|
+
onBodyScroll,
|
|
234
|
+
className,
|
|
235
|
+
}: ConversationLayoutProps) {
|
|
175
236
|
// One column: the pressed comment stays where it was on screen. Opening one thread closes the other, and when that
|
|
176
237
|
// one stood above it, everything under it would rise by its height (Katerina, 31 October). Where it was is noted at
|
|
177
238
|
// the press; once the change is drawn, before it is painted, the column scrolls by however far it went.
|
|
@@ -215,14 +276,31 @@ export function ConversationLayout({ threads, items, open, onOpenChange, box, ab
|
|
|
215
276
|
const opened = items.find((item) => item.id === open)?.thread
|
|
216
277
|
return (
|
|
217
278
|
<div className={cn('flex min-h-0 min-w-0 flex-1', className)}>
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
279
|
+
{/* If the column throws, its name stays with the message, as a Panel's does; the thread beside it stays. */}
|
|
280
|
+
<ErrorBoundary
|
|
281
|
+
label="conversation"
|
|
282
|
+
frame={(message) => (
|
|
283
|
+
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
|
|
284
|
+
<ContainerHeader title={title} />
|
|
285
|
+
<div className="flex min-h-0 flex-1 flex-col px-4">{message}</div>
|
|
286
|
+
</div>
|
|
287
|
+
)}
|
|
288
|
+
>
|
|
289
|
+
<div className="flex min-h-0 min-w-0 flex-1 flex-col">
|
|
290
|
+
{header}
|
|
291
|
+
<ScrollArea className="min-h-0 flex-1" viewportRef={bodyRef} onScroll={onBodyScroll} contentClassName="flex min-h-full flex-col">
|
|
292
|
+
{top != null && top !== false && top !== '' && <div className="shrink-0 px-4 pt-4">{top}</div>}
|
|
293
|
+
{/* A short conversation sits on its box, as a chat does: the newest comment by the box (Peek's way). */}
|
|
294
|
+
<div className="min-h-0 flex-1" />
|
|
295
|
+
<div className="flex shrink-0 flex-col gap-2 p-4">
|
|
296
|
+
<List items={items} open={open} under={false} above={above} loading={loading} empty={empty} change={change} caret={caret} />
|
|
297
|
+
{!loading && below}
|
|
298
|
+
</div>
|
|
299
|
+
</ScrollArea>
|
|
300
|
+
{/* Peek's composer room: 12px all round (useFileConversationView's `p-3`), under the list's 16px. */}
|
|
301
|
+
{box && <div className="shrink-0 p-3">{box}</div>}
|
|
302
|
+
</div>
|
|
303
|
+
</ErrorBoundary>
|
|
226
304
|
{opened && (
|
|
227
305
|
<div className="flex w-[384px] shrink-0 flex-col border-l border-border-subtle">
|
|
228
306
|
<caretOnOpen.Provider value={caret}>{opened}</caretOnOpen.Provider>
|
package/src/ConversationMenu.mdx
CHANGED
|
@@ -5,14 +5,17 @@ import * as Stories from './ConversationMenu.stories'
|
|
|
5
5
|
|
|
6
6
|
# ConversationMenu
|
|
7
7
|
|
|
8
|
-
The ⋯ menu of a comment or a reply: Resolve or Reopen
|
|
8
|
+
The ⋯ menu of a comment or a reply: Resolve or Reopen and the app's own rows; then Edit on your own; then Delete on your own, apart.
|
|
9
9
|
|
|
10
10
|
<Canvas of={Stories.Yours} />
|
|
11
11
|
|
|
12
12
|
## When
|
|
13
13
|
|
|
14
14
|
- Inside **ConversationCard** and **ReplyCard**, which draw it for you.
|
|
15
|
-
- Its `children` are the app's own rows.
|
|
15
|
+
- Its `children` are the app's own rows, after Resolve; `after`, its rows after Edit.
|
|
16
|
+
- In the app's own words: `label` heads the first rows, `resolveHint` stands beside Resolve, `editLabel` is Edit's word. Peek's menu reads as it did with them (Katerina, 1 November).
|
|
17
|
+
|
|
18
|
+
<Canvas of={Stories.InAnAppsWords} />
|
|
16
19
|
|
|
17
20
|
<Canvas of={Stories.Theirs} />
|
|
18
21
|
|
|
@@ -13,7 +13,7 @@ const meta = {
|
|
|
13
13
|
component: ConversationMenu,
|
|
14
14
|
parameters: { layout: 'padded' },
|
|
15
15
|
args: { trigger: <Button variant="outlined">Open the menu</Button> },
|
|
16
|
-
argTypes: { trigger: { control: false }, children: { control: false } },
|
|
16
|
+
argTypes: { trigger: { control: false }, children: { control: false }, after: { control: false } },
|
|
17
17
|
decorators: [(Story) => <div className="flex min-h-[220px] items-start pl-[200px] pt-2">{Story()}</div>],
|
|
18
18
|
play: async ({ canvasElement }) => {
|
|
19
19
|
await userEvent.click(within(canvasElement).getByRole('button', { name: 'Open the menu' }))
|
|
@@ -40,3 +40,21 @@ export const MoreRows: Story = {
|
|
|
40
40
|
name: 'More rows',
|
|
41
41
|
args: { onResolve: () => {}, onEdit: () => {}, onDelete: () => {}, children: <MenuItem label="Item one" onClick={() => {}} /> },
|
|
42
42
|
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* In an app's own words, as Peek's menu reads (Katerina, 1 November): a heading over the first rows, the key that
|
|
46
|
+
* resolves from its box beside Resolve, its word for Edit, and a row of its own after Edit. Delete stays apart.
|
|
47
|
+
*/
|
|
48
|
+
export const InAnAppsWords: Story = {
|
|
49
|
+
name: "In an app's words",
|
|
50
|
+
args: {
|
|
51
|
+
label: 'Heading',
|
|
52
|
+
resolveHint: '->',
|
|
53
|
+
onResolve: () => {},
|
|
54
|
+
onEdit: () => {},
|
|
55
|
+
editLabel: 'Edit message',
|
|
56
|
+
after: <MenuItem label="Item two" onClick={() => {}} />,
|
|
57
|
+
onDelete: () => {},
|
|
58
|
+
children: <MenuItem label="Item one" onClick={() => {}} />,
|
|
59
|
+
},
|
|
60
|
+
}
|
|
@@ -15,7 +15,7 @@ async function open() {
|
|
|
15
15
|
const names = () => screen.getAllByRole('menuitem').map((row) => row.textContent)
|
|
16
16
|
|
|
17
17
|
describe('ConversationMenu', () => {
|
|
18
|
-
it('offers Resolve
|
|
18
|
+
it('offers Resolve and the app’s rows, then Edit, then Delete apart: three groups', async () => {
|
|
19
19
|
const onResolve = vi.fn()
|
|
20
20
|
render(
|
|
21
21
|
<ConversationMenu onResolve={onResolve} onEdit={() => {}} onDelete={() => {}}>
|
|
@@ -24,7 +24,7 @@ describe('ConversationMenu', () => {
|
|
|
24
24
|
)
|
|
25
25
|
await open()
|
|
26
26
|
expect(names()).toEqual(['Resolve', 'Open work', 'Edit', 'Delete'])
|
|
27
|
-
expect(screen.getAllByRole('separator').length).toBe(
|
|
27
|
+
expect(screen.getAllByRole('separator').length).toBe(2)
|
|
28
28
|
fireEvent.click(screen.getByRole('menuitem', { name: 'Resolve' }))
|
|
29
29
|
expect(onResolve).toHaveBeenCalledOnce()
|
|
30
30
|
})
|
|
@@ -38,10 +38,23 @@ describe('ConversationMenu', () => {
|
|
|
38
38
|
expect(onReopen).toHaveBeenCalledOnce()
|
|
39
39
|
})
|
|
40
40
|
|
|
41
|
-
it('offers Edit and Delete only when given,
|
|
41
|
+
it('offers Edit and Delete only when given, Delete apart, and no line before the first group', async () => {
|
|
42
42
|
render(<ConversationMenu onEdit={() => {}} onDelete={() => {}} />)
|
|
43
43
|
await open()
|
|
44
44
|
expect(names()).toEqual(['Edit', 'Delete'])
|
|
45
|
-
expect(screen.
|
|
45
|
+
expect(screen.getAllByRole('separator').length).toBe(1)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
it('reads as Peek’s did, with Peek’s words passed in: a heading, the Resolve hint, "Edit message", "View details" (Katerina, 1 November)', async () => {
|
|
49
|
+
render(
|
|
50
|
+
<ConversationMenu label="Utilities" resolveHint="->" onResolve={() => {}} onEdit={() => {}} editLabel="Edit message" after={<MenuItem label="View details" onClick={() => {}} />} onDelete={() => {}}>
|
|
51
|
+
<MenuItem label="Open work" onClick={() => {}} />
|
|
52
|
+
</ConversationMenu>,
|
|
53
|
+
)
|
|
54
|
+
await open()
|
|
55
|
+
expect(names().map((n) => n?.replace('->', '').trim())).toEqual(['Resolve', 'Open work', 'Edit message', 'View details', 'Delete'])
|
|
56
|
+
expect(screen.getByText('Utilities')).toBeTruthy()
|
|
57
|
+
expect(screen.getByText('->')).toBeTruthy()
|
|
58
|
+
expect(screen.getAllByRole('separator').length).toBe(2)
|
|
46
59
|
})
|
|
47
60
|
})
|
package/src/ConversationMenu.tsx
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from 'react'
|
|
2
2
|
import { IconCircleCheck, IconCircleDashed, IconDotsVertical } from '@tabler/icons-react'
|
|
3
3
|
import { IconButton } from './IconButton'
|
|
4
|
-
import { Menu, MenuItem, MenuSeparator } from './Menu'
|
|
4
|
+
import { Menu, MenuItem, MenuSection, MenuSeparator } from './Menu'
|
|
5
5
|
|
|
6
6
|
export interface ConversationMenuProps {
|
|
7
7
|
/** Resolved: the menu offers Reopen in place of Resolve. */
|
|
8
8
|
resolved?: boolean
|
|
9
9
|
onResolve?: () => void
|
|
10
10
|
onReopen?: () => void
|
|
11
|
-
/**
|
|
11
|
+
/** Beside Resolve, how the app's box resolves too, as its key hint: Peek's "->". */
|
|
12
|
+
resolveHint?: string
|
|
13
|
+
/** The app's own rows, after Resolve: `MenuItem`s. */
|
|
12
14
|
children?: ReactNode
|
|
15
|
+
/** A heading over Resolve and the app's rows, in the app's words: Peek's "Utilities". */
|
|
16
|
+
label?: string
|
|
13
17
|
/** Offered on your own only. */
|
|
14
18
|
onEdit?: () => void
|
|
19
|
+
/** Edit's words: "Edit" by default; Peek's "Edit message". */
|
|
20
|
+
editLabel?: string
|
|
21
|
+
/** The app's own rows after Edit, before Delete: Peek's "View details". */
|
|
22
|
+
after?: ReactNode
|
|
15
23
|
/** Offered on your own only; the card asks before it deletes. */
|
|
16
24
|
onDelete?: () => void
|
|
17
25
|
open?: boolean
|
|
@@ -21,12 +29,30 @@ export interface ConversationMenuProps {
|
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
/**
|
|
24
|
-
* The ⋯ menu of a comment or a reply: Resolve or Reopen and the app's
|
|
25
|
-
* A card offers it only when it has a
|
|
26
|
-
* Peek's, moved with the conversation; its
|
|
32
|
+
* The ⋯ menu of a comment or a reply, in up to three groups: Resolve or Reopen and the app's rows; Edit on your own
|
|
33
|
+
* and the app's rows after it; Delete on your own, apart, as it is destructive. A card offers it only when it has a
|
|
34
|
+
* row to show. Peek's, moved with the conversation; what is Peek's own (its heading, its hint, its words, its rows)
|
|
35
|
+
* Peek passes in, so its menu reads as it did (Katerina, 1 November).
|
|
27
36
|
*/
|
|
28
|
-
export function ConversationMenu({ resolved = false, onResolve, onReopen, children, onEdit, onDelete, open, onOpenChange, trigger }: ConversationMenuProps) {
|
|
37
|
+
export function ConversationMenu({ resolved = false, onResolve, onReopen, resolveHint, children, label, onEdit, editLabel = 'Edit', after, onDelete, open, onOpenChange, trigger }: ConversationMenuProps) {
|
|
29
38
|
const resolves = resolved ? onReopen : onResolve
|
|
39
|
+
const first = (resolves || children) && (
|
|
40
|
+
<>
|
|
41
|
+
{resolves &&
|
|
42
|
+
(resolved ? (
|
|
43
|
+
<MenuItem leading={<IconCircleDashed size={16} stroke={1.5} className="text-text-secondary" />} label="Reopen" onClick={onReopen} />
|
|
44
|
+
) : (
|
|
45
|
+
<MenuItem leading={<IconCircleCheck size={16} stroke={1.5} className="text-text-secondary" />} label="Resolve" shortcut={resolveHint} onClick={onResolve} />
|
|
46
|
+
))}
|
|
47
|
+
{children}
|
|
48
|
+
</>
|
|
49
|
+
)
|
|
50
|
+
const middle = (onEdit || after) && (
|
|
51
|
+
<>
|
|
52
|
+
{onEdit && <MenuItem label={editLabel} onClick={onEdit} />}
|
|
53
|
+
{after}
|
|
54
|
+
</>
|
|
55
|
+
)
|
|
30
56
|
return (
|
|
31
57
|
<Menu
|
|
32
58
|
trigger={
|
|
@@ -41,16 +67,11 @@ export function ConversationMenu({ resolved = false, onResolve, onReopen, childr
|
|
|
41
67
|
onOpenChange={onOpenChange}
|
|
42
68
|
className="w-[244px]"
|
|
43
69
|
>
|
|
44
|
-
{
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
))}
|
|
50
|
-
{children}
|
|
51
|
-
{/* Edit and Delete are one group, as in Peek; the line only between two groups that are both there. */}
|
|
52
|
-
{(resolves || children) && (onEdit || onDelete) && <MenuSeparator />}
|
|
53
|
-
{onEdit && <MenuItem label="Edit" onClick={onEdit} />}
|
|
70
|
+
{first && (label ? <MenuSection label={label}>{first}</MenuSection> : first)}
|
|
71
|
+
{/* A line only between two groups that are both there. */}
|
|
72
|
+
{first && middle && <MenuSeparator />}
|
|
73
|
+
{middle}
|
|
74
|
+
{onDelete && (first || middle) && <MenuSeparator />}
|
|
54
75
|
{onDelete && <MenuItem label="Delete" destructive onClick={onDelete} />}
|
|
55
76
|
</Menu>
|
|
56
77
|
)
|
package/src/LinkCard.tsx
CHANGED
|
@@ -115,7 +115,7 @@ function CardBody({ linked, readOnly }: { linked: Linked; readOnly: boolean }) {
|
|
|
115
115
|
</Link>
|
|
116
116
|
)}
|
|
117
117
|
</span>
|
|
118
|
-
{child.owner ? <Avatar name={child.owner.name} src={child.owner.picture} size={16} /> : <span className="size-4 shrink-0" aria-hidden />}
|
|
118
|
+
{child.owner ? <Avatar name={child.owner.name} src={child.owner.picture} bot={child.owner.bot} size={16} /> : <span className="size-4 shrink-0" aria-hidden />}
|
|
119
119
|
</div>
|
|
120
120
|
))}
|
|
121
121
|
</div>
|
|
@@ -127,7 +127,7 @@ function CardBody({ linked, readOnly }: { linked: Linked; readOnly: boolean }) {
|
|
|
127
127
|
<span className="text-caption text-text-muted">Latest conversation</span>
|
|
128
128
|
<div className={cn('flex flex-col gap-1', QUOTE_BAR_CLASSES)}>
|
|
129
129
|
<span className="flex items-center gap-2 text-caption">
|
|
130
|
-
<Avatar name={linked.latest.author.name} src={linked.latest.author.picture} size={16} />
|
|
130
|
+
<Avatar name={linked.latest.author.name} src={linked.latest.author.picture} bot={linked.latest.author.bot} size={16} />
|
|
131
131
|
<span className="text-text-primary">{linked.latest.author.name}</span>
|
|
132
132
|
<span className={cn('text-text-muted', TIME_CLASSES)}>{linked.latest.at}</span>
|
|
133
133
|
</span>
|
|
@@ -160,7 +160,7 @@ function SaidBody({ linked }: { linked: Linked }) {
|
|
|
160
160
|
return (
|
|
161
161
|
<>
|
|
162
162
|
<div className="flex items-center gap-2">
|
|
163
|
-
<Avatar name={author.name} src={author.picture} size={24} />
|
|
163
|
+
<Avatar name={author.name} src={author.picture} bot={author.bot} size={24} />
|
|
164
164
|
{/* No "Open" in a missing time's place (Katerina, 30 Oct): the name is the link then. */}
|
|
165
165
|
<span className="text-body-2-strong text-text-primary">
|
|
166
166
|
{linked.updated ? author.name : <CardLink href={linked.href}>{author.name}</CardLink>}
|
package/src/LinkChip.tsx
CHANGED
|
@@ -45,7 +45,7 @@ export function LinkChip({ link, preview = true }: LinkChipProps) {
|
|
|
45
45
|
const said = linked.kind === 'message' && linked.author
|
|
46
46
|
const chip = (
|
|
47
47
|
<InlineChip
|
|
48
|
-
icon={said ? <Avatar name={said.name} src={said.picture} size={14} /> : <LinkedIcon kind={linked.kind} size={14} tone="inherit" />}
|
|
48
|
+
icon={said ? <Avatar name={said.name} src={said.picture} bot={said.bot} size={14} /> : <LinkedIcon kind={linked.kind} size={14} tone="inherit" />}
|
|
49
49
|
// No address to open (another app's file with none over https): a label, not a link to nowhere.
|
|
50
50
|
href={linked.href || undefined}
|
|
51
51
|
// Never wider than its line. With its hover card, the card's wrapper holds it to the line (max-w-full): a share of the
|
package/src/LinkParts.tsx
CHANGED
|
@@ -62,8 +62,8 @@ export function kindNounOf(linked: Pick<Linked, 'kind' | 'noun'>): string | unde
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/** The 36px tile a link's kind sits in, as a file's type does in AttachmentCard; words a person wrote show their face. */
|
|
65
|
-
export function LinkTile({ kind, author }: { kind: LinkedKind; author?: { name: string; picture?: string } }) {
|
|
66
|
-
if (author) return <Avatar name={author.name} src={author.picture} size={36} />
|
|
65
|
+
export function LinkTile({ kind, author }: { kind: LinkedKind; author?: { name: string; picture?: string; bot?: boolean } }) {
|
|
66
|
+
if (author) return <Avatar name={author.name} src={author.picture} bot={author.bot} size={36} />
|
|
67
67
|
return (
|
|
68
68
|
<span className={TYPE_TILE_CLASSES}>
|
|
69
69
|
<LinkedIcon kind={kind} />
|
|
@@ -159,9 +159,9 @@ export interface LinkPickersProps {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
/** The face for an owner option: nobody (value `''`, "Unassigned") is the silhouette, never a letter (Katerina, 30 Oct). */
|
|
162
|
-
function OwnerFace({ option }: { option: { value: string; label: string; picture?: string } | undefined }) {
|
|
162
|
+
function OwnerFace({ option }: { option: { value: string; label: string; picture?: string; bot?: boolean } | undefined }) {
|
|
163
163
|
const nobody = !option || option.value === ''
|
|
164
|
-
return <Avatar name={nobody ? undefined : option.label} src={nobody ? undefined : option.picture} size={16} />
|
|
164
|
+
return <Avatar name={nobody ? undefined : option.label} src={nobody ? undefined : option.picture} bot={!nobody && option.bot} size={16} />
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
/**
|
package/src/LinkRow.tsx
CHANGED
|
@@ -170,7 +170,7 @@ export function LinkRow({ link, preview = true }: LinkRowProps) {
|
|
|
170
170
|
{/* A ring already says how far along it is. */}
|
|
171
171
|
{linked.done ? <ProgressRing done={linked.done.done} total={linked.done.total} /> : status?.colour && <StatusMark status={{ label: status.label, colour: status.colour }} />}
|
|
172
172
|
{linked.conversation && <CommentCount conversation={linked.conversation} noun={linked.conversation.noun} />}
|
|
173
|
-
{owner && <Avatar name={owner.label} src={owner.picture} size={16} />}
|
|
173
|
+
{owner && <Avatar name={owner.label} src={owner.picture} bot={owner.bot} size={16} />}
|
|
174
174
|
{linked.members && <AvatarGroup members={linked.members} size={16} on="inset" />}
|
|
175
175
|
{linked.authors && <AvatarGroup members={linked.authors} size={16} on="inset" />}
|
|
176
176
|
</span>
|
|
@@ -77,3 +77,14 @@ export const Long: Story = {
|
|
|
77
77
|
export const AddLayer: Story = {
|
|
78
78
|
args: { initialView: 'add' },
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
/** An agent among the members: its face is a robot (`bot`). */
|
|
82
|
+
export const WithAnAgent: Story = {
|
|
83
|
+
args: {
|
|
84
|
+
members: [
|
|
85
|
+
{ id: 'me', name: 'You', caption: 'Product designer' },
|
|
86
|
+
{ id: 'ana', name: 'Ana Duarte', caption: 'Assignee' },
|
|
87
|
+
{ id: 'agent', name: 'Agent (steered by Ana Duarte)', caption: 'Agent', bot: true },
|
|
88
|
+
],
|
|
89
|
+
},
|
|
90
|
+
}
|
package/src/MembersDialog.tsx
CHANGED
|
@@ -16,6 +16,8 @@ export interface MembersDialogMember {
|
|
|
16
16
|
name: string
|
|
17
17
|
/** A picture URL, resolved by the caller, as `Avatar` takes its `src`. */
|
|
18
18
|
picture?: string
|
|
19
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
20
|
+
bot?: boolean
|
|
19
21
|
/** The line under the name: a role, a relation ("Assignee"), or a state. */
|
|
20
22
|
caption?: string
|
|
21
23
|
}
|
|
@@ -23,6 +25,8 @@ export interface MembersDialogMember {
|
|
|
23
25
|
/** Somebody who can be added: a `ChipInput` option with a face. */
|
|
24
26
|
export interface MembersDialogCandidate extends ChipInputOption {
|
|
25
27
|
picture?: string
|
|
28
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
29
|
+
bot?: boolean
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
/** What the viewer's own row offers: in when they are out, out when they are in. */
|
|
@@ -132,8 +136,8 @@ export function MembersDialog({ members, count, self, candidates = [], onAdd, no
|
|
|
132
136
|
options={candidates}
|
|
133
137
|
placeholder="Search people..."
|
|
134
138
|
excludeIds={members.map((m) => m.id)}
|
|
135
|
-
chipLeading={(o) => <Avatar name={o.label} src={o.picture} size={16} />}
|
|
136
|
-
rowLeading={(o) => <Avatar name={o.label} src={o.picture} size={32} />}
|
|
139
|
+
chipLeading={(o) => <Avatar name={o.label} src={o.picture} bot={o.bot} size={16} />}
|
|
140
|
+
rowLeading={(o) => <Avatar name={o.label} src={o.picture} bot={o.bot} size={32} />}
|
|
137
141
|
autoFocus
|
|
138
142
|
/>
|
|
139
143
|
</Field>
|
|
@@ -182,7 +186,7 @@ export function MembersDialog({ members, count, self, candidates = [], onAdd, no
|
|
|
182
186
|
)}
|
|
183
187
|
{roster.map((member) => (
|
|
184
188
|
<div key={member.id} className="flex h-12 items-center gap-3 px-5">
|
|
185
|
-
<Avatar size={32} name={member.name} src={member.picture} />
|
|
189
|
+
<Avatar size={32} name={member.name} src={member.picture} bot={member.bot} />
|
|
186
190
|
<div className="flex min-w-0 flex-1 flex-col justify-center gap-[2px]">
|
|
187
191
|
<div className="truncate text-body-2 text-text-primary">{member.name}</div>
|
|
188
192
|
{member.caption && <div className="truncate text-caption text-text-secondary">{member.caption}</div>}
|
package/src/Person.tsx
CHANGED
|
@@ -20,19 +20,21 @@ import { Avatar } from './Avatar'
|
|
|
20
20
|
export interface PersonProps {
|
|
21
21
|
name?: string
|
|
22
22
|
picture?: string
|
|
23
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
24
|
+
bot?: boolean
|
|
23
25
|
/** Shown in place of a missing name. */
|
|
24
26
|
fallback?: string
|
|
25
27
|
size?: number
|
|
26
28
|
className?: string
|
|
27
29
|
}
|
|
28
30
|
|
|
29
|
-
export function Person({ name, picture, fallback = '—', size = 20, className }: PersonProps) {
|
|
31
|
+
export function Person({ name, picture, bot, fallback = '—', size = 20, className }: PersonProps) {
|
|
30
32
|
return (
|
|
31
33
|
// gap-2: the face-to-name distance is one rule (8px) wherever a person
|
|
32
34
|
// appears — Katerina, 2026-09-01, set on Person so PersonTrigger and every
|
|
33
35
|
// row agree by construction.
|
|
34
36
|
<span className={cn('flex min-w-0 items-center gap-2', className)}>
|
|
35
|
-
<Avatar name={name} src={picture} size={size} />
|
|
37
|
+
<Avatar name={name} src={picture} bot={bot} size={size} />
|
|
36
38
|
<span className={cn('truncate', !name && 'text-text-muted')}>{name ?? fallback}</span>
|
|
37
39
|
</span>
|
|
38
40
|
)
|
package/src/PersonTrigger.tsx
CHANGED
|
@@ -29,7 +29,7 @@ export interface PersonTriggerProps
|
|
|
29
29
|
compact?: boolean
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export function PersonTrigger({ name, picture, fallback, size, open = false, compact = false, className, ...props }: PersonTriggerProps) {
|
|
32
|
+
export function PersonTrigger({ name, picture, bot, fallback, size, open = false, compact = false, className, ...props }: PersonTriggerProps) {
|
|
33
33
|
if (compact) {
|
|
34
34
|
return (
|
|
35
35
|
<BaseButton
|
|
@@ -56,7 +56,7 @@ export function PersonTrigger({ name, picture, fallback, size, open = false, com
|
|
|
56
56
|
className={cn('cursor-pointer rounded-full', className)}
|
|
57
57
|
{...props}
|
|
58
58
|
>
|
|
59
|
-
<Avatar name={name} src={picture} size={size ?? 36} />
|
|
59
|
+
<Avatar name={name} src={picture} bot={bot} size={size ?? 36} />
|
|
60
60
|
</BaseButton>
|
|
61
61
|
)
|
|
62
62
|
}
|
|
@@ -78,7 +78,7 @@ export function PersonTrigger({ name, picture, fallback, size, open = false, com
|
|
|
78
78
|
)}
|
|
79
79
|
{...props}
|
|
80
80
|
>
|
|
81
|
-
<Person name={name} picture={picture} fallback={fallback} size={size ?? 22} />
|
|
81
|
+
<Person name={name} picture={picture} bot={bot} fallback={fallback} size={size ?? 22} />
|
|
82
82
|
<IconChevronDown size={14} stroke={1.5} className="shrink-0 text-text-muted" />
|
|
83
83
|
</BaseButton>
|
|
84
84
|
)
|
package/src/PinnedComment.tsx
CHANGED
|
@@ -26,7 +26,7 @@ export function PinnedComment({ author, time, words, deleted = false }: PinnedCo
|
|
|
26
26
|
) : (
|
|
27
27
|
<div className="flex flex-col p-2">
|
|
28
28
|
<div className="flex items-center gap-2">
|
|
29
|
-
<Avatar size={24} src={author.picture} alt={author.name} />
|
|
29
|
+
<Avatar size={24} src={author.picture} alt={author.name} bot={author.bot} />
|
|
30
30
|
<span className="min-w-0 truncate text-body-2-strong text-text-primary">{author.name}</span>
|
|
31
31
|
<MetaText className="shrink-0">{time}</MetaText>
|
|
32
32
|
</div>
|
package/src/RepliesRow.tsx
CHANGED
|
@@ -8,7 +8,7 @@ export interface RepliesRowProps {
|
|
|
8
8
|
/** How many replies. */
|
|
9
9
|
count: number
|
|
10
10
|
/** Who replied: their faces. */
|
|
11
|
-
faces?: readonly { name: string; picture?: string }[]
|
|
11
|
+
faces?: readonly { name: string; picture?: string; bot?: boolean }[]
|
|
12
12
|
/** The last reply's time, in the app's words. */
|
|
13
13
|
last?: string
|
|
14
14
|
/** "1 new": a reply you have not read. */
|
|
@@ -39,7 +39,7 @@ export function RepliesRow({ count, faces, last, isNew = false, urgent = false,
|
|
|
39
39
|
<>
|
|
40
40
|
{withFaces && (
|
|
41
41
|
<span className="flex shrink-0 items-center">
|
|
42
|
-
<AvatarGroup size={18} members={faces.map((f) => ({ name: f.name, picture: f.picture }))} />
|
|
42
|
+
<AvatarGroup size={18} members={faces.map((f) => ({ name: f.name, picture: f.picture, bot: f.bot }))} />
|
|
43
43
|
</span>
|
|
44
44
|
)}
|
|
45
45
|
<IconMessage2
|
package/src/Thread.mdx
CHANGED
|
@@ -39,6 +39,8 @@ import { ReplyCard, Thread } from '@estiva-app/ui'
|
|
|
39
39
|
|
|
40
40
|
- Its replies are yours to put in time order. Who resolved it is said on the comment, not among them.
|
|
41
41
|
- Still reading: `loading`. Nobody replied yet: nothing in `children`.
|
|
42
|
+
- 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`, for a link that names the comment, as ConversationLayout's comments carry `data-conversation-item`.
|
|
42
44
|
|
|
43
45
|
## What it owns
|
|
44
46
|
|
package/src/Thread.test.tsx
CHANGED
|
@@ -37,6 +37,23 @@ describe('Thread, beside (the right column)', () => {
|
|
|
37
37
|
expect(onClose).toHaveBeenCalledOnce()
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
+
it('says nothing in an empty thread when the app asks for silence (empty={null})', () => {
|
|
41
|
+
render(<Thread start={START} empty={null} />)
|
|
42
|
+
expect(screen.queryByText('No replies yet.')).toBeNull()
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('carries the comment’s id on the pinned comment, for a link that names it', () => {
|
|
46
|
+
const { container } = render(<Thread start={{ ...START, id: 'c1' }} />)
|
|
47
|
+
expect(container.querySelector('[data-thread-start="c1"]')?.textContent).toContain('The comment it answers')
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
it('names Close in the app’s words for a screen reader, its tooltip still "Close"', () => {
|
|
51
|
+
const onClose = vi.fn()
|
|
52
|
+
render(<Thread start={START} onClose={onClose} closeLabel="Close thread" />)
|
|
53
|
+
fireEvent.click(screen.getByRole('button', { name: 'Close thread' }))
|
|
54
|
+
expect(onClose).toHaveBeenCalledOnce()
|
|
55
|
+
})
|
|
56
|
+
|
|
40
57
|
it('says why no reply can be written in place of the box', () => {
|
|
41
58
|
render(<Thread start={START} box={<p>The box</p>} notice={<p>This file is archived.</p>} />)
|
|
42
59
|
expect(screen.getByText('This file is archived.')).toBeTruthy()
|