@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
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/linked.ts
CHANGED
|
@@ -34,6 +34,8 @@ export interface LinkedStatus {
|
|
|
34
34
|
export interface LinkedPerson {
|
|
35
35
|
name: string
|
|
36
36
|
picture?: string
|
|
37
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
38
|
+
bot?: boolean
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
/** One choice a picker offers. */
|
|
@@ -44,6 +46,8 @@ export interface PickerOption {
|
|
|
44
46
|
colour?: StatusColour
|
|
45
47
|
/** A person's picture: the option draws their face. */
|
|
46
48
|
picture?: string
|
|
49
|
+
/** An agent: its face is a robot, as Avatar's `bot`. */
|
|
50
|
+
bot?: boolean
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
/**
|
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
|
@@ -16,6 +16,8 @@ import type { LinkState, Linked, LinkedChild, LinkedConversation, LinkedKind, Li
|
|
|
16
16
|
export interface LinkedProfile {
|
|
17
17
|
displayName?: string
|
|
18
18
|
picture?: string
|
|
19
|
+
/** NIP-24's `bot`: the profile is an agent's. */
|
|
20
|
+
bot?: boolean
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
/** One of interop's resolved slots. */
|
|
@@ -178,7 +180,7 @@ function childrenOf<T extends LinkedSource>(object: T, options: LinkedFromOption
|
|
|
178
180
|
href: options.hrefOf(child, false),
|
|
179
181
|
...(key ? { key } : {}),
|
|
180
182
|
status: { label: status?.value ?? nounOf(child) ?? 'File', colour: colourOf(status?.colour) ?? 'muted' },
|
|
181
|
-
...(person?.displayName ? { owner: { name: person.displayName, ...(person.picture ? { picture: person.picture } : {}) } } : {}),
|
|
183
|
+
...(person?.displayName ? { owner: { name: person.displayName, ...(person.picture ? { picture: person.picture } : {}), ...(person.bot ? { bot: true } : {}) } } : {}),
|
|
182
184
|
}
|
|
183
185
|
})
|
|
184
186
|
}
|
|
@@ -225,7 +227,7 @@ function ownerOf(object: LinkedSource, options: Pick<LinkedFromOptions, 'directo
|
|
|
225
227
|
{ value: '', label: 'Unassigned' },
|
|
226
228
|
...Object.entries(known)
|
|
227
229
|
// The em dash for an unnameable person, never the key (FEE-1).
|
|
228
|
-
.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 } : {}) }))
|
|
229
231
|
.sort((a, b) => a.label.localeCompare(b.label)),
|
|
230
232
|
],
|
|
231
233
|
...(onAct ? { onChange: (value: string) => onAct(action.id, value) } : {}),
|
|
@@ -238,7 +240,7 @@ function ownerOf(object: LinkedSource, options: Pick<LinkedFromOptions, 'directo
|
|
|
238
240
|
if (!slot) return undefined
|
|
239
241
|
const person = people?.[slot.value]
|
|
240
242
|
return {
|
|
241
|
-
owner: { value: slot.value, options: [{ value: slot.value, label: person?.displayName ?? '—', ...(person?.picture ? { picture: person.picture } : {}) }] },
|
|
243
|
+
owner: { value: slot.value, options: [{ value: slot.value, label: person?.displayName ?? '—', ...(person?.picture ? { picture: person.picture } : {}), ...(person?.bot ? { bot: true } : {}) }] },
|
|
242
244
|
...(slot.label ? { ownerLabel: slot.label } : {}),
|
|
243
245
|
}
|
|
244
246
|
}
|
|
@@ -253,7 +255,7 @@ function authorOf(object: LinkedSource, directory: LinkedFromOptions['directory'
|
|
|
253
255
|
if (!pubkey || !/^[0-9a-f]{64}$/.test(pubkey)) return undefined
|
|
254
256
|
const profile = object.people?.[pubkey] ?? directory?.[pubkey]
|
|
255
257
|
if (!profile?.displayName) return undefined
|
|
256
|
-
return { name: profile.displayName, ...(profile.picture ? { picture: profile.picture } : {}) }
|
|
258
|
+
return { name: profile.displayName, ...(profile.picture ? { picture: profile.picture } : {}), ...(profile.bot ? { bot: true } : {}) }
|
|
257
259
|
}
|
|
258
260
|
|
|
259
261
|
/** The file a reference names, as the kit's chip, row and card draw it. */
|
|
@@ -273,7 +275,7 @@ export function linkedFrom<T extends LinkedSource>(object: T, options: LinkedFro
|
|
|
273
275
|
kind: 'message',
|
|
274
276
|
title: name,
|
|
275
277
|
href,
|
|
276
|
-
author: { name, ...(person?.picture ? { picture: person.picture } : {}) },
|
|
278
|
+
author: { name, ...(person?.picture ? { picture: person.picture } : {}), ...(person?.bot ? { bot: true } : {}) },
|
|
277
279
|
...(body ? { body } : {}),
|
|
278
280
|
...(updated ? { updated } : {}),
|
|
279
281
|
}
|
|
@@ -363,7 +363,7 @@ describe('a second parser agrees', async () => {
|
|
|
363
363
|
const INHERITED_WITH_A_DEFAULT = new Set(['Button.type', 'IconButton.type', 'TextInput.type', 'SearchInput.placeholder'])
|
|
364
364
|
|
|
365
365
|
/**
|
|
366
|
-
* The
|
|
366
|
+
* The nineteen where **this registry is right and `react-docgen` is not**.
|
|
367
367
|
*
|
|
368
368
|
* `IdentityPanelProps extends Omit<IdentityMenuProps, 'compact'>` and
|
|
369
369
|
* `PersonTriggerProps extends Omit<PersonProps, 'className'>`: docgen does not
|
|
@@ -388,6 +388,7 @@ const DOCGEN_STOPS_AT_OMIT = new Set([
|
|
|
388
388
|
'IdentityPanel.children',
|
|
389
389
|
'PersonTrigger.name',
|
|
390
390
|
'PersonTrigger.picture',
|
|
391
|
+
'PersonTrigger.bot',
|
|
391
392
|
'PersonTrigger.fallback',
|
|
392
393
|
'PersonTrigger.size',
|
|
393
394
|
'ToolbarLink.variant',
|
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 |
|