@estiva-app/ui 0.97.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/ConversationCard.d.ts +24 -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/Thread.d.ts +9 -2
- package/dist/Thread.d.ts.map +1 -1
- package/dist/index.js +149 -66
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/registry.json +134 -18
- 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 +56 -36
- 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/Thread.mdx +2 -0
- package/src/Thread.test.tsx +17 -0
- package/src/Thread.tsx +32 -8
- package/src/linkedFrom.test.tsx +18 -0
- package/src/linkedFrom.ts +2 -2
- package/stories/Choosing.mdx +1 -1
package/src/Thread.tsx
CHANGED
|
@@ -12,7 +12,10 @@ import { useContext } from 'react'
|
|
|
12
12
|
import { caretOnOpen, LineByLayout } from './threadCard'
|
|
13
13
|
|
|
14
14
|
/** The comment a thread answers, pinned at the top of its column. */
|
|
15
|
-
export
|
|
15
|
+
export interface ThreadStart extends PinnedCommentProps {
|
|
16
|
+
/** Its id, on the pinned comment as `data-thread-start`, as each comment of a ConversationLayout carries `data-conversation-item`: what an app scrolls to when a link names the comment. */
|
|
17
|
+
id?: string
|
|
18
|
+
}
|
|
16
19
|
|
|
17
20
|
export interface ThreadProps {
|
|
18
21
|
/** `beside`: in the right column, beside the comments, under its own header. `under`: open under its comment, in a one-column conversation: its replies hang from a line, quiet, and the box is under them; ConversationLayout makes the comment and its thread one card. */
|
|
@@ -33,6 +36,10 @@ export interface ThreadProps {
|
|
|
33
36
|
actions?: ReactNode
|
|
34
37
|
/** Closes the column. */
|
|
35
38
|
onClose?: () => void
|
|
39
|
+
/** Close's name for a screen reader, in the app's words ("Close thread"). Its tooltip still says "Close". */
|
|
40
|
+
closeLabel?: string
|
|
41
|
+
/** Beside: what an empty thread says, words or the app's own `EmptyState`. `null`: nothing, for an app whose thread stood empty and silent. Under its comment an empty thread is only its box. */
|
|
42
|
+
empty?: ReactNode
|
|
36
43
|
/** The column's name. */
|
|
37
44
|
title?: ReactNode
|
|
38
45
|
/** The column's scrolling box, for opening at the newest reply. */
|
|
@@ -44,9 +51,9 @@ export interface ThreadProps {
|
|
|
44
51
|
/** Whether there are replies: an app's `replies.map(…)` with none is an empty list, which is not nothing to React but is to the reader. */
|
|
45
52
|
const anyIn = (children: ReactNode) => Children.toArray(children).length > 0
|
|
46
53
|
|
|
47
|
-
function Replies({ children, loading }: { children?: ReactNode; loading: boolean }) {
|
|
54
|
+
function Replies({ children, loading, empty }: { children?: ReactNode; loading: boolean; empty: ReactNode }) {
|
|
48
55
|
if (loading) return <SkeletonConversation />
|
|
49
|
-
if (!anyIn(children)) return <EmptyState scope="section" message=
|
|
56
|
+
if (!anyIn(children)) return typeof empty === 'string' ? <EmptyState scope="section" message={empty} /> : <>{empty}</>
|
|
50
57
|
return <>{children}</>
|
|
51
58
|
}
|
|
52
59
|
|
|
@@ -56,7 +63,22 @@ function Replies({ children, loading }: { children?: ReactNode; loading: boolean
|
|
|
56
63
|
* column: Ship's and Leaf's), the replies hung from a line, quiet, and the box under them, all one card with the
|
|
57
64
|
* comment (Ship's way). Peek's replies column, moved with the conversation.
|
|
58
65
|
*/
|
|
59
|
-
export function Thread({
|
|
66
|
+
export function Thread({
|
|
67
|
+
place = 'beside',
|
|
68
|
+
start,
|
|
69
|
+
children,
|
|
70
|
+
loading = false,
|
|
71
|
+
resolved = false,
|
|
72
|
+
box,
|
|
73
|
+
notice,
|
|
74
|
+
actions,
|
|
75
|
+
onClose,
|
|
76
|
+
closeLabel = 'Close',
|
|
77
|
+
empty = 'No replies yet.',
|
|
78
|
+
title = 'Replies',
|
|
79
|
+
bodyRef,
|
|
80
|
+
className,
|
|
81
|
+
}: ThreadProps) {
|
|
60
82
|
const foot = notice ?? box
|
|
61
83
|
// In a ConversationLayout the layout draws the line, from the comment's face to the last reply, as one bar.
|
|
62
84
|
const layoutLine = useContext(LineByLayout)
|
|
@@ -89,7 +111,7 @@ export function Thread({ place = 'beside', start, children, loading = false, res
|
|
|
89
111
|
{resolved && <Chip type="success" label="Resolved" />}
|
|
90
112
|
{actions}
|
|
91
113
|
{onClose && (
|
|
92
|
-
<IconButton tooltip="Close" aria-label=
|
|
114
|
+
<IconButton tooltip="Close" aria-label={closeLabel} onClick={onClose}>
|
|
93
115
|
<IconX size={16} stroke={1.5} />
|
|
94
116
|
</IconButton>
|
|
95
117
|
)}
|
|
@@ -98,14 +120,16 @@ export function Thread({ place = 'beside', start, children, loading = false, res
|
|
|
98
120
|
footer={foot && <div className="p-3">{foot}</div>}
|
|
99
121
|
>
|
|
100
122
|
{start && (
|
|
101
|
-
<div className="px-4 pb-2 pt-4">
|
|
102
|
-
<PinnedComment {
|
|
123
|
+
<div className="px-4 pb-2 pt-4" data-thread-start={start.id}>
|
|
124
|
+
<PinnedComment author={start.author} time={start.time} words={start.words} deleted={start.deleted} />
|
|
103
125
|
</div>
|
|
104
126
|
)}
|
|
105
127
|
<Divider look="section" label="Replies" className="px-4 py-2" />
|
|
106
128
|
<div className="flex flex-col gap-2 px-4 pb-4">
|
|
107
129
|
<caretOnOpen.Provider value={0}>
|
|
108
|
-
<Replies loading={loading}
|
|
130
|
+
<Replies loading={loading} empty={empty}>
|
|
131
|
+
{children}
|
|
132
|
+
</Replies>
|
|
109
133
|
</caretOnOpen.Provider>
|
|
110
134
|
</div>
|
|
111
135
|
</Panel>
|
package/src/linkedFrom.test.tsx
CHANGED
|
@@ -134,6 +134,17 @@ describe('a card built from interop’s projection', () => {
|
|
|
134
134
|
expect(onAct).toHaveBeenCalledWith('set-lead', OTHER)
|
|
135
135
|
})
|
|
136
136
|
|
|
137
|
+
it('draws an agent picked as the lead as the robot, in the picker and its list', async () => {
|
|
138
|
+
const user = userEvent.setup()
|
|
139
|
+
const agent = { ...PEOPLE, [OWNER]: { displayName: 'Claude (steered by Person two)', bot: true } }
|
|
140
|
+
render(<LinkCard link={linkStateFrom({ ...GROUP, people: agent }, UNREAD, options({ onAct: vi.fn(), directory: agent }))} />)
|
|
141
|
+
const robot = 'svg path[d^="M13.5 2C13.5 2.44425"]'
|
|
142
|
+
const lead = screen.getByRole('combobox', { name: 'Lead' })
|
|
143
|
+
expect(lead.querySelectorAll(robot).length).toBe(1)
|
|
144
|
+
await user.click(lead)
|
|
145
|
+
expect((await screen.findByRole('option', { name: /Claude/ })).querySelectorAll(robot).length).toBe(1)
|
|
146
|
+
})
|
|
147
|
+
|
|
137
148
|
it('shows an archived file’s status and lead as words, even to a reader who could change them', () => {
|
|
138
149
|
render(<LinkCard link={linkStateFrom({ ...GROUP, archived: { by: OWNER, at: 1 } }, UNREAD, options({ onAct: vi.fn() }))} />)
|
|
139
150
|
expect(screen.queryByRole('combobox')).toBeNull()
|
|
@@ -187,6 +198,13 @@ describe('when it changed, and who made it', () => {
|
|
|
187
198
|
expect(screen.getByText('Updated 2h ago')).toBeTruthy()
|
|
188
199
|
})
|
|
189
200
|
|
|
201
|
+
it('draws an agent who made it as the robot, from its profile (Katerina, 1 November)', () => {
|
|
202
|
+
const card = render(<LinkCard link={linkStateFrom(PAGE, UNREAD, options({ directory: { ...PEOPLE, [OTHER]: { displayName: 'Claude (steered by Person one)', bot: true } } }))} />)
|
|
203
|
+
// A person named so would be "C"; the agent is the robot instead.
|
|
204
|
+
expect(within(card.container).queryByText('C')).toBeNull()
|
|
205
|
+
expect(card.container.querySelectorAll('svg path[d^="M13.5 2C13.5 2.44425"]').length).toBe(1)
|
|
206
|
+
})
|
|
207
|
+
|
|
190
208
|
it('leaves the person to the owner picker on a file that has one', () => {
|
|
191
209
|
const card = render(<LinkCard link={linkStateFrom({ ...GROUP, children: [] }, UNREAD, options())} />)
|
|
192
210
|
expect(within(card.container).queryByText('PT')).toBeNull()
|
package/src/linkedFrom.ts
CHANGED
|
@@ -227,7 +227,7 @@ function ownerOf(object: LinkedSource, options: Pick<LinkedFromOptions, 'directo
|
|
|
227
227
|
{ value: '', label: 'Unassigned' },
|
|
228
228
|
...Object.entries(known)
|
|
229
229
|
// The em dash for an unnameable person, never the key (FEE-1).
|
|
230
|
-
.map(([pubkey, profile]) => ({ value: pubkey, label: profile.displayName ?? '—', picture: profile.picture }))
|
|
230
|
+
.map(([pubkey, profile]) => ({ value: pubkey, label: profile.displayName ?? '—', picture: profile.picture, ...(profile.bot ? { bot: true } : {}) }))
|
|
231
231
|
.sort((a, b) => a.label.localeCompare(b.label)),
|
|
232
232
|
],
|
|
233
233
|
...(onAct ? { onChange: (value: string) => onAct(action.id, value) } : {}),
|
|
@@ -255,7 +255,7 @@ function authorOf(object: LinkedSource, directory: LinkedFromOptions['directory'
|
|
|
255
255
|
if (!pubkey || !/^[0-9a-f]{64}$/.test(pubkey)) return undefined
|
|
256
256
|
const profile = object.people?.[pubkey] ?? directory?.[pubkey]
|
|
257
257
|
if (!profile?.displayName) return undefined
|
|
258
|
-
return { name: profile.displayName, ...(profile.picture ? { picture: profile.picture } : {}) }
|
|
258
|
+
return { name: profile.displayName, ...(profile.picture ? { picture: profile.picture } : {}), ...(profile.bot ? { bot: true } : {}) }
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
/** The file a reference names, as the kit's chip, row and card draw it. */
|
package/stories/Choosing.mdx
CHANGED
|
@@ -95,7 +95,7 @@ The same conversation in every app; only its colours are each app's.
|
|
|
95
95
|
| One reply in a thread | **ReplyCard** — a comment's pieces, without replies of its own or Resolve |
|
|
96
96
|
| A comment's replies and the box to write one | **Thread** — in the right column under its header, or under its comment |
|
|
97
97
|
| The way into a thread | **RepliesRow** — faces, "2 replies", the last time and "1 new" |
|
|
98
|
-
| Resolving, with a note | **ResolveDialog**; the comment then says who resolved it and the note
|
|
98
|
+
| Resolving, with a note | **ResolveDialog**; the comment then says who resolved it and the note: **ConversationCard** `resolved` |
|
|
99
99
|
| The words a comment on a part is about | **QuotedLine** — above its name, and what changed since |
|
|
100
100
|
| The comment a thread answers, at the top of its replies column | **PinnedComment** — Thread draws it from its `start` |
|
|
101
101
|
| The strip on a pointed-at comment, and its ⋯ menu | **ConversationActions** and **ConversationMenu** — the cards draw both |
|