@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.
Files changed (72) hide show
  1. package/dist/Avatar.d.ts +6 -1
  2. package/dist/Avatar.d.ts.map +1 -1
  3. package/dist/AvatarGroup.d.ts +2 -0
  4. package/dist/AvatarGroup.d.ts.map +1 -1
  5. package/dist/ComposerTriggers.d.ts +2 -0
  6. package/dist/ComposerTriggers.d.ts.map +1 -1
  7. package/dist/ConversationCard.d.ts +26 -6
  8. package/dist/ConversationCard.d.ts.map +1 -1
  9. package/dist/ConversationLayout.d.ts +18 -6
  10. package/dist/ConversationLayout.d.ts.map +1 -1
  11. package/dist/ConversationMenu.d.ts +14 -5
  12. package/dist/ConversationMenu.d.ts.map +1 -1
  13. package/dist/LinkParts.d.ts +1 -0
  14. package/dist/LinkParts.d.ts.map +1 -1
  15. package/dist/MembersDialog.d.ts +4 -0
  16. package/dist/MembersDialog.d.ts.map +1 -1
  17. package/dist/Person.d.ts +3 -1
  18. package/dist/Person.d.ts.map +1 -1
  19. package/dist/PersonTrigger.d.ts +1 -1
  20. package/dist/PersonTrigger.d.ts.map +1 -1
  21. package/dist/RepliesRow.d.ts +1 -0
  22. package/dist/RepliesRow.d.ts.map +1 -1
  23. package/dist/Thread.d.ts +9 -2
  24. package/dist/Thread.d.ts.map +1 -1
  25. package/dist/editor.js +1 -1
  26. package/dist/editor.js.map +2 -2
  27. package/dist/index.js +196 -92
  28. package/dist/index.js.map +3 -3
  29. package/dist/linked.d.ts +4 -0
  30. package/dist/linked.d.ts.map +1 -1
  31. package/dist/linkedFrom.d.ts +2 -0
  32. package/dist/linkedFrom.d.ts.map +1 -1
  33. package/package.json +1 -1
  34. package/registry.json +153 -19
  35. package/src/Avatar.agent.test.tsx +63 -0
  36. package/src/Avatar.mdx +25 -0
  37. package/src/Avatar.stories.tsx +13 -0
  38. package/src/Avatar.tsx +51 -3
  39. package/src/AvatarGroup.tsx +3 -1
  40. package/src/ComposerTriggers.stories.tsx +2 -0
  41. package/src/ComposerTriggers.tsx +3 -1
  42. package/src/ConversationCard.mdx +3 -2
  43. package/src/ConversationCard.states.test.tsx +25 -5
  44. package/src/ConversationCard.stories.tsx +3 -3
  45. package/src/ConversationCard.test.tsx +4 -4
  46. package/src/ConversationCard.tsx +60 -38
  47. package/src/ConversationLayout.mdx +12 -0
  48. package/src/ConversationLayout.stories.tsx +47 -0
  49. package/src/ConversationLayout.test.tsx +100 -0
  50. package/src/ConversationLayout.tsx +98 -20
  51. package/src/ConversationMenu.mdx +5 -2
  52. package/src/ConversationMenu.stories.tsx +19 -1
  53. package/src/ConversationMenu.test.tsx +17 -4
  54. package/src/ConversationMenu.tsx +37 -16
  55. package/src/LinkCard.tsx +3 -3
  56. package/src/LinkChip.tsx +1 -1
  57. package/src/LinkParts.tsx +4 -4
  58. package/src/LinkRow.tsx +1 -1
  59. package/src/MembersDialog.stories.tsx +11 -0
  60. package/src/MembersDialog.tsx +7 -3
  61. package/src/Person.tsx +4 -2
  62. package/src/PersonTrigger.tsx +3 -3
  63. package/src/PinnedComment.tsx +1 -1
  64. package/src/RepliesRow.tsx +2 -2
  65. package/src/Thread.mdx +2 -0
  66. package/src/Thread.test.tsx +17 -0
  67. package/src/Thread.tsx +32 -8
  68. package/src/linked.ts +4 -0
  69. package/src/linkedFrom.test.tsx +18 -0
  70. package/src/linkedFrom.ts +7 -5
  71. package/src/registry/registry.test.ts +2 -1
  72. package/stories/Choosing.mdx +1 -1
@@ -13,7 +13,8 @@ One comment, the same in every app: who, when, the words, files, cards, reaction
13
13
 
14
14
  - **A comment** in any conversation: in the comments beside a page, or filling the page with its thread beside it (**ConversationLayout**).
15
15
  - `own` on yours: Edit (with `editor`) and Delete (with `onDelete`) in its menu. The card asks before it deletes.
16
- - `resolved`: folded. "✓ Resolved" by the time, with who, when and the note on hover; "Person two → the note · time" above its replies row. While its thread is closed, the words fold to their first line, without files or reactions; open, it is whole.
16
+ - `resolved`: "✓ Resolved" by the time, with who, when and the note on hover; "Person two → the note · time" above its replies row. Nothing of the comment is hidden: its words, cards, files and reactions stay.
17
+ - `noun`: what the delete question calls it, "Delete this comment?" by default; a direct message says `message`.
17
18
  - `about` on a comment on a part of the page: a **QuotedLine** under the name, above the words.
18
19
  - `isNew`, `urgent`: the dot or the urgent mark, and a hairline, until it is read.
19
20
 
@@ -65,7 +66,7 @@ import { ConversationCard } from '@estiva-app/ui'
65
66
  | Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
66
67
  | Asks before it deletes | a confirm dialog | |
67
68
  | Opens the Resolve dialog, and closes it once resolved | a dialog and its open state | |
68
- | Says it is resolved, with who and the note, and folds it while its thread is closed | a resolved line or chip of your own | |
69
+ | Says it is resolved, with who and the note, and hides nothing of it | a resolved line or chip of your own | |
69
70
 
70
71
  ## Props
71
72
 
@@ -277,18 +277,38 @@ describe('what the review found (1 November)', () => {
277
277
  expect(onClick).toHaveBeenCalledOnce()
278
278
  })
279
279
 
280
- it('open beside by the app’s own `selected`, a resolved comment is whole: its files show', () => {
280
+ it('asks about a direct message as a message (Katerina, 1 November), and about a comment by default', async () => {
281
281
  render(
282
- <ConversationCard author={ONE} time="11:08 AM" selected resolved={{ by: 'Person two' }} files={<span>plan.png</span>}>
282
+ <ConversationCard author={ONE} time="11:08 AM" own onDelete={() => {}} noun="message">
283
283
  Words
284
284
  </ConversationCard>,
285
285
  )
286
- expect(screen.getByText('plan.png')).toBeTruthy()
286
+ point('Words')
287
+ fireEvent.click(screen.getByRole('button', { name: 'More actions' }))
288
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
289
+ expect(await screen.findByText('Delete this message?')).toBeTruthy()
290
+ expect(screen.getByRole('button', { name: 'Delete message' })).toBeTruthy()
291
+ })
292
+ })
293
+
294
+ describe('an app’s own words (Katerina, 1 November: Peek reads as it did)', () => {
295
+ it('says the app’s words under the delete question, in place of the kit’s, the replies’ line too', async () => {
296
+ render(
297
+ <ConversationCard author={ONE} time="11:08 AM" own onDelete={() => {}} replies={{ count: 2 }} deleteNote={<p>The app’s own words about what deleting does, and the replies.</p>}>
298
+ Words
299
+ </ConversationCard>,
300
+ )
301
+ point('Words')
302
+ fireEvent.click(screen.getByRole('button', { name: 'More actions' }))
303
+ fireEvent.click(await screen.findByRole('menuitem', { name: 'Delete' }))
304
+ expect(await screen.findByText('The app’s own words about what deleting does, and the replies.')).toBeTruthy()
305
+ expect(screen.queryByText('It is deleted for everyone.')).toBeNull()
306
+ expect(screen.queryByText('Its 2 replies stay.')).toBeNull()
287
307
  })
288
308
  })
289
309
 
290
310
  describe('its files, what it is about, and how it was resolved', () => {
291
- it('draws its files under the words, and holds them back while it is folded', () => {
311
+ it('draws its files under the words, and keeps them once resolved: nothing folds (Katerina, 1 November)', () => {
292
312
  render(
293
313
  <ConversationCard author={ONE} time="11:08 AM" files={<span>plan.png</span>}>
294
314
  Words
@@ -301,7 +321,7 @@ describe('its files, what it is about, and how it was resolved', () => {
301
321
  Words
302
322
  </ConversationCard>,
303
323
  )
304
- expect(screen.queryByText('plan.png')).toBeNull()
324
+ expect(after(screen.getByText('Words'), screen.getByText('plan.png'))).toBe(true)
305
325
  })
306
326
 
307
327
  it('puts what it is about under the name and above the words (Katerina, 1 November), on a reply too', () => {
@@ -24,7 +24,7 @@ type Story = StoryObj<typeof meta>
24
24
  /** Two paragraphs in RichText's own box, as an app's words come. */
25
25
  const RICH = [
26
26
  { type: 'paragraph' as const, inline: [{ text: WORDS, marks: [] }] },
27
- { type: 'paragraph' as const, inline: [{ text: 'A second paragraph, held back while it is folded.', marks: [] }] },
27
+ { type: 'paragraph' as const, inline: [{ text: 'A second paragraph: a resolved comment shows all of it.', marks: [] }] },
28
28
  ]
29
29
 
30
30
  /** A card that answers: its reactions, resolve, edit and delete change it, as an app's would. */
@@ -91,10 +91,10 @@ export const Urgent: Story = { render: (args) => <Live {...args} isNew urgent re
91
91
  /** A person named in the words, and a link. */
92
92
  export const WithMentions: Story = { name: 'Mentions', render: (args) => <Live {...args}><Mentions /></Live> }
93
93
 
94
- /** Resolved, folded: "Resolved" by the time, who and the note above its replies; closed, its words in one line, its reactions and files held back. */
94
+ /** Resolved: "Resolved" by the time, who and the note above its replies; its words, reactions and files all stay. */
95
95
  export const Resolved: Story = { render: (args) => <Live {...args} start={SOME} resolvedAt={{ by: 'Person two', note: 'Keeping the first one.' }} replies={{ count: 2, faces: [TWO, THREE], last: '12:02 PM' }} /> }
96
96
 
97
- /** Resolved, its words in a box of their own, as the apps draw them (RichText here): folded, still their first line. */
97
+ /** Resolved, its words in a box of their own, as the apps draw them (RichText here): all of them shown. */
98
98
  export const ResolvedInABox: Story = {
99
99
  name: 'Resolved, words in a box',
100
100
  render: (args) => (
@@ -71,7 +71,7 @@ describe('ConversationCard', () => {
71
71
  expect(onResolve).toHaveBeenCalledWith('Going with the first one')
72
72
  })
73
73
 
74
- it('folds when resolved: the check by the time, who and the note above its replies, its reactions held back, and still opens its thread on a press', async () => {
74
+ it('resolved: the check by the time, who and the note above its replies, nothing of it hidden, and still opens its thread on a press', async () => {
75
75
  const user = userEvent.setup()
76
76
  const onClick = vi.fn()
77
77
  render(
@@ -79,13 +79,13 @@ describe('ConversationCard', () => {
79
79
  Words
80
80
  </ConversationCard>,
81
81
  )
82
- // Folded (Katerina, 1 November): "✓ Resolved" by the time, and "Person two → Done." above its replies, with no "resolved";
83
- // closed, its words in one line and its reactions wait.
82
+ // "✓ Resolved" by the time, and "Person two → Done." above its replies, with no "resolved"; its words and its reactions
83
+ // stay (Katerina, 1 November: nothing folds).
84
84
  expect(screen.getByText('Resolved')).toBeTruthy()
85
85
  expect(screen.getByText('Person two')).toBeTruthy()
86
86
  expect(screen.getByText('Done.')).toBeTruthy()
87
87
  expect(screen.queryByText(/Person two resolved/)).toBeNull()
88
- expect(screen.queryByRole('button', { name: /👍/ })).toBeNull()
88
+ expect(screen.getByRole('button', { name: /👍/ })).toBeTruthy()
89
89
  await user.click(screen.getByText('Words'))
90
90
  expect(onClick).toHaveBeenCalledOnce()
91
91
  })
@@ -23,6 +23,8 @@ import { UrgentMark } from './UrgentMark'
23
23
  export interface ConversationPerson {
24
24
  name: string
25
25
  picture?: string
26
+ /** An agent: its face is a robot, as Avatar's `bot`. */
27
+ bot?: boolean
26
28
  }
27
29
 
28
30
  /** What a comment and a reply share. */
@@ -32,6 +34,8 @@ export interface ConversationEntryProps {
32
34
  time: ReactNode
33
35
  /** A link to it: the time is then the link, "Link to this", as a reply's is. */
34
36
  timeHref?: string
37
+ /** The time's tooltip when it is a link, in the app's words: "Link to this" by default; Peek's "Link to this message". */
38
+ timeLabel?: string
35
39
  /** When it was last edited, in the app's words for the tooltip ("Edited 11:20 AM"): draws "(edited)". */
36
40
  edited?: string
37
41
  /** The words, as the app draws them: text, mentions, links, attached cards, quoted blocks. */
@@ -58,10 +62,19 @@ export interface ConversationEntryProps {
58
62
  onEditingChange?: (editing: boolean) => void
59
63
  /** Delete, after the card has asked. */
60
64
  onDelete?: () => Promise<boolean | void> | boolean | void
61
- /** The app's sentence in the delete question, what deleting does there. Absent: "It is deleted for everyone." */
65
+ /**
66
+ * The app's own words under the delete question, what deleting does there, in place of the kit's: "It is deleted for
67
+ * everyone.", and on a comment how many replies stay. A string is one paragraph; a node is drawn as given.
68
+ */
62
69
  deleteNote?: ReactNode
63
- /** The app's own rows in the ⋯ menu: `MenuItem`s. */
70
+ /** The app's own rows in the ⋯ menu, after Resolve: `MenuItem`s. */
64
71
  menu?: ReactNode
72
+ /** The app's own rows in the ⋯ menu after Edit, before Delete: Peek's "View details". */
73
+ menuAfter?: ReactNode
74
+ /** A heading over the menu's first rows, in the app's words: Peek's "Utilities". */
75
+ menuLabel?: string
76
+ /** Edit's words in the ⋯ menu: "Edit" by default; Peek's "Edit message". */
77
+ editLabel?: string
65
78
  /** Placement only. */
66
79
  className?: string
67
80
  }
@@ -74,11 +87,18 @@ export interface ConversationCardProps extends ConversationEntryProps {
74
87
  /** Reply: offered on the strip. */
75
88
  onReply?: () => void
76
89
  /**
77
- * Resolved, by whom, with what note and when (`at`, in the app's words). Folded (Katerina, 1 November): "✓ Resolved"
78
- * by the time, who and the note on hover; "Person two → the note · time" above the replies row. While its thread is
79
- * closed, the words fold to their first line, without files or reactions; open, it is whole.
90
+ * Resolved, by whom, with what note and when (`at`, in the app's words): "✓ Resolved" by the time, who and the note on
91
+ * hover; "Person two → the note · time" above the replies row. Nothing of the comment is hidden: its words, cards,
92
+ * files and reactions stay (Katerina, 1 November: nothing folds, in any app).
80
93
  */
81
94
  resolved?: { by: string; note?: string; at?: string }
95
+ /**
96
+ * What the comment is called in the delete question: "Delete this comment?" by default. A direct message says
97
+ * `message` (Katerina, 1 November: "comment" reads wrong in a private chat).
98
+ */
99
+ noun?: string
100
+ /** Beside Resolve in the ⋯ menu, how the app's box resolves too, as its key hint: Peek's "->". */
101
+ resolveHint?: string
82
102
  /** Resolve, with the note written in the dialog the card opens. Offered on the strip and in the menu. */
83
103
  onResolve?: (note: string) => Promise<boolean | void> | boolean | void
84
104
  /** Why the last resolve was refused, in plain words: said under the note, while the dialog stays open (`onResolve` answered `false`). */
@@ -93,16 +113,16 @@ export interface ConversationCardProps extends ConversationEntryProps {
93
113
  export type ReplyCardProps = ConversationEntryProps
94
114
 
95
115
  /** The face, the name, the time and "(edited)", with the new mark at the far right. `meta`: after "(edited)". */
96
- function Head({ author, time, timeHref, edited, isNew, urgent, meta }: Pick<ConversationEntryProps, 'author' | 'time' | 'timeHref' | 'edited' | 'isNew' | 'urgent'> & { meta?: ReactNode }) {
116
+ function Head({ author, time, timeHref, timeLabel = 'Link to this', edited, isNew, urgent, meta }: Pick<ConversationEntryProps, 'author' | 'time' | 'timeHref' | 'timeLabel' | 'edited' | 'isNew' | 'urgent'> & { meta?: ReactNode }) {
97
117
  return (
98
118
  <div className="flex w-full items-center gap-2">
99
119
  <div className="flex min-w-0 flex-1 items-center gap-2">
100
120
  <span data-face className="relative flex shrink-0">
101
- <Avatar size={24} src={author.picture} alt={author.name} />
121
+ <Avatar size={24} src={author.picture} alt={author.name} bot={author.bot} />
102
122
  </span>
103
123
  <span className="min-w-0 truncate text-body-2-strong text-text-primary">{author.name}</span>
104
124
  {timeHref ? (
105
- <WithTooltip label="Link to this" wrapperClassName="shrink-0">
125
+ <WithTooltip label={timeLabel} wrapperClassName="shrink-0">
106
126
  <MetaText className="contents">
107
127
  <Link href={timeHref} variant="quiet" data-interactive>
108
128
  {time}
@@ -127,7 +147,7 @@ function attentionOf(fresh: boolean, urgent: boolean, inThreadCard: boolean) {
127
147
  }
128
148
 
129
149
  /**
130
- * Folded (Katerina, 1 November): who resolved it and the note, "Person two → Keeping the first one. · 12:30 PM", in the
150
+ * Who resolved it and the note (Katerina, 1 November), "Person two → Keeping the first one. · 12:30 PM", in the
131
151
  * thread's own line (the dot in the faces' column). No "resolved": the check by the time says it.
132
152
  */
133
153
  function EndedLine({ by, note, at }: { by: string; note: string; at?: string }) {
@@ -163,18 +183,10 @@ function ResolvedCheck({ by, note, at }: { by: string; note?: string; at?: strin
163
183
  )
164
184
  }
165
185
 
166
- /**
167
- * Folded, the words' first line, whatever the app wraps them in (Peek's and Leaf's words come in a box of their own):
168
- * the cards and pictures among them held back, at either level, then one line, cut with … where the text allows.
169
- * Text blocks stay: paragraphs, lists, quotes, code.
170
- */
171
- const FOLDED_WORDS_CLASSES =
172
- '[&>div]:line-clamp-1 [&>div]:max-h-[1lh] [&>div>*:not(p):not(ul):not(ol):not(blockquote):not(pre):not(div:only-child)]:hidden [&>div>div:only-child>*:not(p):not(ul):not(ol):not(blockquote):not(pre)]:hidden'
173
-
174
- /** The words' own look: Peek's message body, 14px secondary, blocks 8px apart. `oneLine`: folded, the first line only. */
175
- function Words({ children, oneLine = false }: { children: ReactNode; oneLine?: boolean }) {
186
+ /** The words' own look: Peek's message body, 14px secondary, blocks 8px apart. */
187
+ function Words({ children }: { children: ReactNode }) {
176
188
  return (
177
- <div className={cn('relative w-full break-words pb-2 pl-8 pr-2 pt-1', oneLine && FOLDED_WORDS_CLASSES)}>
189
+ <div className="relative w-full break-words pb-2 pl-8 pr-2 pt-1">
178
190
  <div className="flex flex-col gap-2 text-body-2 text-text-secondary">{children}</div>
179
191
  </div>
180
192
  )
@@ -195,7 +207,7 @@ function Editing({ author, children }: { author: ConversationPerson; children: R
195
207
  return (
196
208
  <div className="p-2">
197
209
  <div className="flex items-start gap-2">
198
- <Avatar size={24} src={author.picture} alt={author.name} className="mt-1 shrink-0" />
210
+ <Avatar size={24} src={author.picture} alt={author.name} bot={author.bot} className="mt-1 shrink-0" />
199
211
  <div className="min-w-0 flex-1">{children}</div>
200
212
  </div>
201
213
  </div>
@@ -245,11 +257,11 @@ function useEditing(editing: boolean | undefined, onEditingChange: ((editing: bo
245
257
 
246
258
  /**
247
259
  * One comment: who, when, the words, files, cards, reactions, and the way into its replies, with the strip on hover
248
- * and the ⋯ menu. Resolved, it folds while its thread is closed and says who resolved it and the note.
260
+ * and the ⋯ menu. Resolved, it says who resolved it and the note; nothing of it is hidden.
249
261
  * The same card in every app, each in its own colours (the record that makes one conversation). Peek's, moved.
250
262
  */
251
263
  export function ConversationCard(props: ConversationCardProps) {
252
- const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, onResolve, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, menu, className, children } = props
264
+ const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, noun = 'comment', onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
253
265
  const readOnly = (props.readOnly ?? false) || deleted
254
266
  const inThreadCard = useContext(InThreadCard)
255
267
 
@@ -276,7 +288,7 @@ export function ConversationCard(props: ConversationCardProps) {
276
288
  // Once its picker or menu has closed: the strip only if the card is still pointed at.
277
289
  const settle = () => requestAnimationFrame(() => setHovered(stillHere(root.current)))
278
290
  // The ⋯ menu only when it has a row to show: Resolve or Reopen, the app's rows, or Edit and Delete on your own.
279
- const offersMenu = !!resolves || !!menu || (own && (!!editor || !!onDelete))
291
+ const offersMenu = !!resolves || !!menu || !!menuAfter || (own && (!!editor || !!onDelete))
280
292
  const showStrip = hovered && !isEditing && !readOnly
281
293
  const react = reactions?.onToggle
282
294
  // Read-only with no replies, there is nothing to open: no box to write in, no thread to read (Peek's way, Katerina, 1 November).
@@ -284,10 +296,6 @@ export function ConversationCard(props: ConversationCardProps) {
284
296
  const reply = onReply ?? item?.show
285
297
  const marked = selected ?? (item && !item.under ? item.open : undefined)
286
298
  const under = !!item?.under
287
- // Closed: its thread is not open, under it or beside it (the layout's, or the app's own `selected`).
288
- const closed = !inThreadCard && !marked
289
- // Folded: resolved, its thread closed, the words' first line only (Katerina, 1 November).
290
- const folded = !!resolved && closed
291
299
  const repliesRow = replies && replies.count > 0 && (
292
300
  <RepliesRow {...replies} onOpen={replies.onOpen ?? (under ? item?.toggle : undefined)} open={replies.open ?? (under && !!item?.open)} urgent={urgent} />
293
301
  )
@@ -332,6 +340,7 @@ export function ConversationCard(props: ConversationCardProps) {
332
340
  author={author}
333
341
  time={props.time}
334
342
  timeHref={props.timeHref}
343
+ timeLabel={props.timeLabel}
335
344
  edited={props.edited}
336
345
  isNew={isNew}
337
346
  urgent={urgent}
@@ -341,15 +350,15 @@ export function ConversationCard(props: ConversationCardProps) {
341
350
  // Under the name, above the words (Katerina, 1 November).
342
351
  <div className="relative w-full pl-8 pr-2 pt-0.5">{about}</div>
343
352
  )}
344
- <Words oneLine={folded}>
353
+ <Words>
345
354
  {children}
346
355
  </Words>
347
356
  </>
348
357
  )}
349
- {!deleted && files && !folded && (
358
+ {!deleted && files && (
350
359
  <div className="relative flex w-full flex-wrap items-start gap-2 pb-2 pl-8 pr-2">{files}</div>
351
360
  )}
352
- {!folded && <Reactions reactions={reactions} refused={reactionRefused} readOnly={readOnly} />}
361
+ <Reactions reactions={reactions} refused={reactionRefused} readOnly={readOnly} />
353
362
  {resolved?.note && (
354
363
  // Who resolved it and the note, above the way into the replies; the check by the time says "Resolved" (Katerina, 1 November).
355
364
  <div className="relative w-full pb-1">
@@ -395,7 +404,11 @@ export function ConversationCard(props: ConversationCardProps) {
395
404
  resolved={!!resolved}
396
405
  onResolve={onResolve && (() => setResolving(true))}
397
406
  onReopen={onReopen}
407
+ resolveHint={resolveHint}
408
+ label={menuLabel}
398
409
  onEdit={own && editor ? () => setEditing(true) : undefined}
410
+ editLabel={editLabel}
411
+ after={menuAfter}
399
412
  onDelete={own && onDelete ? () => setDeleting(true) : undefined}
400
413
  >
401
414
  {menu}
@@ -407,9 +420,15 @@ export function ConversationCard(props: ConversationCardProps) {
407
420
  )}
408
421
  </Card>
409
422
  {deleting && onDelete && (
410
- <ConfirmDialog title="Delete this comment?" confirmLabel="Delete comment" destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
411
- <p>{deleteNote ?? 'It is deleted for everyone.'}</p>
412
- {replies && replies.count > 0 && <p>Its {replies.count === 1 ? 'reply stays' : `${replies.count} replies stay`}.</p>}
423
+ <ConfirmDialog title={`Delete this ${noun}?`} confirmLabel={`Delete ${noun}`} destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
424
+ {deleteNote !== undefined ? (
425
+ typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote
426
+ ) : (
427
+ <>
428
+ <p>It is deleted for everyone.</p>
429
+ {replies && replies.count > 0 && <p>Its {replies.count === 1 ? 'reply stays' : `${replies.count} replies stay`}.</p>}
430
+ </>
431
+ )}
413
432
  </ConfirmDialog>
414
433
  )}
415
434
  {resolving && onResolve && (
@@ -432,7 +451,7 @@ export function ConversationCard(props: ConversationCardProps) {
432
451
  * when it has one. Peek's, moved with the conversation.
433
452
  */
434
453
  export function ReplyCard(props: ReplyCardProps) {
435
- const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, className, children } = props
454
+ const { author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, className, children } = props
436
455
  const readOnly = props.readOnly ?? false
437
456
  const [hovered, setHovered] = useState(false)
438
457
  const [menuOpen, setMenuOpen] = useState(false)
@@ -440,7 +459,7 @@ export function ReplyCard(props: ReplyCardProps) {
440
459
  const [deleting, setDeleting] = useState(false)
441
460
  const [editing, setEditing] = useEditing(props.editing, props.onEditingChange)
442
461
  const isEditing = editing && !readOnly && !!editor
443
- const offersMenu = !!menu || (own && (!!editor || !!onDelete))
462
+ const offersMenu = !!menu || !!menuAfter || (own && (!!editor || !!onDelete))
444
463
  const showStrip = hovered && !isEditing && !readOnly && (offersMenu || !!reactions?.onToggle)
445
464
  const root = useRef<HTMLDivElement>(null)
446
465
  const settle = () => requestAnimationFrame(() => setHovered(stillHere(root.current)))
@@ -472,7 +491,7 @@ export function ReplyCard(props: ReplyCardProps) {
472
491
  <Editing author={author}>{editor(() => setEditing(false))}</Editing>
473
492
  ) : (
474
493
  <div className="flex flex-col items-start px-2 pt-2">
475
- <Head author={author} time={props.time} timeHref={props.timeHref} edited={props.edited} isNew={isNew} urgent={urgent} />
494
+ <Head author={author} time={props.time} timeHref={props.timeHref} timeLabel={props.timeLabel} edited={props.edited} isNew={isNew} urgent={urgent} />
476
495
  {/* As on a comment: under the name, above the words. */}
477
496
  {about && <div className="w-full pl-8 pr-2 pt-0.5">{about}</div>}
478
497
  <Words>{children}</Words>
@@ -502,7 +521,10 @@ export function ReplyCard(props: ReplyCardProps) {
502
521
  setMenuOpen(next)
503
522
  if (!next) settle()
504
523
  }}
524
+ label={menuLabel}
505
525
  onEdit={own && editor ? () => setEditing(true) : undefined}
526
+ editLabel={editLabel}
527
+ after={menuAfter}
506
528
  onDelete={own && onDelete ? () => setDeleting(true) : undefined}
507
529
  >
508
530
  {menu}
@@ -514,7 +536,7 @@ export function ReplyCard(props: ReplyCardProps) {
514
536
  </Card>
515
537
  {deleting && onDelete && (
516
538
  <ConfirmDialog title="Delete this reply?" confirmLabel="Delete reply" destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
517
- <p>{deleteNote ?? 'It is deleted for everyone.'}</p>
539
+ {deleteNote === undefined ? <p>It is deleted for everyone.</p> : typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote}
518
540
  </ConfirmDialog>
519
541
  )}
520
542
  </>
@@ -14,6 +14,12 @@ Where a conversation's cards sit: two columns, or one 384px column beside the pa
14
14
  - `threads="beside"`, two columns: the comments fill the page; an open thread stands beside them, 384px.
15
15
  - `threads="under"`, one column: the comments are the 384px column beside the page; a thread opens under its comment, and the two become one card.
16
16
  - With two columns, `header` puts the comments' own **PageHeader** over their column only, and the thread runs the page's full height beside it.
17
+ - With two columns, each comment's `day` names its stretch with a line that stays at the top while the stretch scrolls (Peek's day lines).
18
+
19
+ <Canvas of={Stories.TwoColumnsDays} />
20
+
21
+ <Canvas of={Stories.TwoColumnsArchived} />
22
+
17
23
  - With one column, an item that is `resolved` waits closed under "Resolved" at the end, and one whose part was deleted (`gone`) under "On deleted blocks" before it, each with how many. A group opens by itself for the thread open in it. With two columns they stay in their place.
18
24
 
19
25
  <Canvas of={Stories.OneColumn} />
@@ -40,6 +46,12 @@ import { ConversationLayout } from '@estiva-app/ui'
40
46
  - Write nothing on the cards for opening: no `onClick`, `selected`, `onReply`, or the replies row's `onOpen` and
41
47
  `open`. The layout gives each **ConversationCard** its place, and the card opens its thread from it. What a card is
42
48
  given still wins.
49
+ - Two columns, an app that keeps its own place in the comments (where they were left, a "New" line, following what
50
+ arrives) has their scrolling box with `bodyRef` and `onBodyScroll`. Each comment's `day` draws the app's day lines,
51
+ each staying at the top while its own day scrolls under it; `before` is a line just above one comment (a "New"
52
+ line); `below` is under the comments (a **ReactionHorizon**); `top` stands at the top however few the comments are
53
+ (an **ArchivedNotice**). Few comments sit on the box, as a chat does. `empty` may be the app's own **EmptyState**,
54
+ or `null` for nothing.
43
55
  - The box at the foot of a thread that opens takes the caret, at its end, without scrolling: the layout tells it with
44
56
  `caretOnOpen`, which **CommentBox** reads. Nothing to pass; a box outside a layout never takes it this way.
45
57
 
@@ -3,7 +3,9 @@ import { useState } from 'react'
3
3
  import { ConversationCard, ReplyCard } from './ConversationCard'
4
4
  import { ConversationLayout, type ConversationItem } from './ConversationLayout'
5
5
  import { ONE, SHORT, SOME, THREE, TWO, WORDS, WriteBox, YOU, useReactions } from './conversation.examples'
6
+ import { ArchivedNotice } from './ArchivedNotice'
6
7
  import { Panel } from './Panel'
8
+ import { ReactionHorizon } from './ReactionHorizon'
7
9
  import { QuotedLine } from './QuotedLine'
8
10
  import { SkeletonBar } from './Skeleton'
9
11
  import { Thread } from './Thread'
@@ -105,6 +107,51 @@ export const TwoColumns: Story = {
105
107
  },
106
108
  }
107
109
 
110
+ /**
111
+ * Two columns, as Peek's file page and DMs: each day's comments under a line naming it, which stays at the top while
112
+ * its stretch scrolls; the reactions note under the comments. Few comments sit on the box, as a chat does.
113
+ */
114
+ export const TwoColumnsDays: Story = {
115
+ name: 'Two columns, days',
116
+ render: () => {
117
+ const card = (who: typeof ONE, time: string, words: string) => (
118
+ <ConversationCard author={who} time={time}>
119
+ {words}
120
+ </ConversationCard>
121
+ )
122
+ const items: ConversationItem[] = [
123
+ { id: 'd1', day: 'Monday', card: card(ONE, '9:14 AM', WORDS) },
124
+ { id: 'd2', day: 'Monday', card: card(TWO, '9:40 AM', 'A second comment that Monday.') },
125
+ { id: 'd3', day: 'Today', card: card(ONE, '8:02 AM', 'The first comment today.') },
126
+ { id: 'd4', day: 'Today', card: card(TWO, '10:21 AM', 'A second comment today.') },
127
+ ]
128
+ return <ConversationLayout threads="beside" items={items} below={<ReactionHorizon limit={100} omitted={3} />} box={<WriteBox label="Comment" />} />
129
+ },
130
+ }
131
+
132
+ /** Two columns, an archived file: its card at the top however few the comments, the box's line saying why nothing can be written. */
133
+ export const TwoColumnsArchived: Story = {
134
+ name: 'Two columns, archived',
135
+ render: () => (
136
+ <ConversationLayout
137
+ threads="beside"
138
+ top={<ArchivedNotice by="Person one" when="Monday" resolution="Shipped. What was left moved to the next file." />}
139
+ items={[
140
+ {
141
+ id: 'a1',
142
+ day: 'Monday',
143
+ card: (
144
+ <ConversationCard author={ONE} time="9:14 AM" readOnly>
145
+ {WORDS}
146
+ </ConversationCard>
147
+ ),
148
+ },
149
+ ]}
150
+ box={<WriteBox closed="Archived. Unarchive it to comment." />}
151
+ />
152
+ ),
153
+ }
154
+
108
155
  /** One column beside the page: a thread opens under its comment. */
109
156
  export const OneColumn: Story = {
110
157
  name: 'One column',
@@ -238,3 +238,103 @@ describe('ConversationLayout, read-only (an archived file)', () => {
238
238
  expect(asked).toHaveBeenLastCalledWith('a')
239
239
  })
240
240
  })
241
+
242
+ describe('ConversationLayout, two columns, what an app with its own list keeps (Peek, 1 November)', () => {
243
+ const card = (words: string) => (
244
+ <ConversationCard author={ONE} time="11:08 AM">
245
+ {words}
246
+ </ConversationCard>
247
+ )
248
+ const dayItems: ConversationItem[] = [
249
+ { id: 'a', card: card('Monday one'), day: 'Monday' },
250
+ { id: 'b', card: card('Monday two'), day: 'Monday', before: <p>New</p> },
251
+ { id: 'c', card: card('Today one'), day: 'Today' },
252
+ ]
253
+
254
+ it('names each day once, over its own stretch of comments, the line staying at the top while its stretch scrolls', () => {
255
+ render(<ConversationLayout threads="beside" items={dayItems} />)
256
+ const monday = screen.getByRole('separator', { name: 'Monday' })
257
+ const today = screen.getByRole('separator', { name: 'Today' })
258
+ expect(screen.getAllByRole('separator', { name: 'Monday' }).length).toBe(1)
259
+ expect(monday.className).toContain('sticky')
260
+ // Each line is held by its own day's stretch, so the next day's line pushes it away.
261
+ expect(monday.parentElement?.textContent).toContain('Monday two')
262
+ expect(monday.parentElement?.textContent).not.toContain('Today one')
263
+ expect(today.parentElement?.textContent).toContain('Today one')
264
+ })
265
+
266
+ it('draws a comment’s `before` just above it, outside its card', () => {
267
+ render(<ConversationLayout threads="beside" items={dayItems} />)
268
+ const line = screen.getByText('New')
269
+ const item = document.querySelector('[data-conversation-item="b"]')!
270
+ expect(line.nextElementSibling).toBe(item)
271
+ })
272
+
273
+ it('gives the app its scrolling box and says when it scrolled', () => {
274
+ const ref = { current: null as HTMLDivElement | null }
275
+ const scrolled = vi.fn()
276
+ render(<ConversationLayout threads="beside" items={dayItems} bodyRef={ref} onBodyScroll={scrolled} />)
277
+ expect(ref.current?.contains(document.querySelector('[data-conversation-item="a"]'))).toBe(true)
278
+ fireEvent.scroll(ref.current!)
279
+ expect(scrolled).toHaveBeenCalled()
280
+ })
281
+
282
+ it('sits a short conversation on its box: the room it leaves is above it, under `top`', () => {
283
+ render(<ConversationLayout threads="beside" items={dayItems} top={<p>Archived</p>} below={<p>Reactions note</p>} box={<p>The box</p>} />)
284
+ const top = screen.getByText('Archived').parentElement!
285
+ const room = top.nextElementSibling as HTMLElement
286
+ expect(room.className).toContain('flex-1')
287
+ // The room grows only because the scroll content is at least as tall as the column.
288
+ expect(top.parentElement?.className).toContain('min-h-full')
289
+ expect(room.nextElementSibling?.textContent).toContain('Today one')
290
+ // The note is under the comments, in their list.
291
+ const words = ['Today one', 'Reactions note'].map((w) => screen.getByText(w))
292
+ expect(words[0].compareDocumentPosition(words[1]) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
293
+ })
294
+
295
+ it('redraws no comment when older ones arrive at the top, a day of their own above (PEE-7)', () => {
296
+ const later: ConversationItem[] = [
297
+ { id: 'b', card: card('Monday one'), day: 'Monday' },
298
+ { id: 'c', card: card('Today one'), day: 'Today' },
299
+ ]
300
+ const { rerender } = render(<ConversationLayout threads="beside" items={later} />)
301
+ const before = ['b', 'c'].map((id) => document.querySelector(`[data-conversation-item="${id}"]`))
302
+ rerender(<ConversationLayout threads="beside" items={[{ id: 'a', card: card('Sunday one'), day: 'Sunday' }, ...later]} />)
303
+ // The same elements, not equal ones: a redrawn card would lose an open menu or dialog.
304
+ ;['b', 'c'].forEach((id, i) => expect(document.querySelector(`[data-conversation-item="${id}"]`)).toBe(before[i]))
305
+ })
306
+
307
+ it('draws nothing for a `top` of false, and no `below` while reading', () => {
308
+ const { container } = render(<ConversationLayout threads="beside" items={dayItems} top={false} />)
309
+ expect(container.querySelector('.pt-4.px-4')).toBeNull()
310
+ cleanup()
311
+ render(<ConversationLayout threads="beside" items={[]} loading below={<p>Reactions note</p>} />)
312
+ expect(screen.queryByText('Reactions note')).toBeNull()
313
+ })
314
+
315
+ it('keeps its name with the message when the column throws, and the thread beside it stays', () => {
316
+ const quiet = vi.spyOn(console, 'error').mockImplementation(() => {})
317
+ function Throws(): never {
318
+ throw new Error('a card that throws')
319
+ }
320
+ render(
321
+ <ConversationLayout
322
+ threads="beside"
323
+ title="A DM with Person one"
324
+ items={[{ id: 'x', card: <Throws />, thread: <p>The thread</p> }]}
325
+ open="x"
326
+ />,
327
+ )
328
+ expect(screen.getByText('A DM with Person one')).toBeTruthy()
329
+ expect(screen.getByText('The thread')).toBeTruthy()
330
+ quiet.mockRestore()
331
+ })
332
+
333
+ it('says an empty conversation in the app’s own words, or nothing', () => {
334
+ render(<ConversationLayout threads="beside" items={[]} empty={<p>The relay could not be reached.</p>} />)
335
+ expect(screen.getByText('The relay could not be reached.')).toBeTruthy()
336
+ cleanup()
337
+ render(<ConversationLayout threads="beside" items={[]} empty={null} />)
338
+ expect(screen.queryByText('No comments yet.')).toBeNull()
339
+ })
340
+ })