@estiva-app/ui 0.104.3 → 0.106.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.
@@ -1,6 +1,7 @@
1
1
  import { Fragment, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState, type ComponentType, type DragEvent, type ReactNode } from 'react'
2
2
  import { Extension, nodePasteRule, type AnyExtension, type EditorOptions } from '@tiptap/core'
3
3
  import { Editor, type JSONContent } from '@tiptap/react'
4
+ import { REFUSAL_REASONS, refusalCause, refusalReason, tooLarge, uploadRefusal } from '@estiva-app/conversation'
4
5
  import { IconLock, IconPaperclip, IconSquareRounded, IconX } from '@tabler/icons-react'
5
6
  import { AttachedCard } from './AttachedCard'
6
7
  import { AttachmentCard } from './AttachmentCard'
@@ -52,11 +53,15 @@ import { sendsInLayout } from './conversationScroll'
52
53
  * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/every-app-writes-and-reacts-with-one-shared-box.md
53
54
  */
54
55
 
55
- /** What the relay said about a send, an edit or an upload. */
56
- export type SendAnswer = { accepted: true } | { accepted: false; reason: string }
56
+ /**
57
+ * What the relay said about a send, an edit or a reaction. `reason` is the refusal as it came (the relay's words, an
58
+ * `Error`, an HTTP body, or `{ cause }` for an app's own): the box says it in `@estiva-app/conversation`'s plain words
59
+ * (`refusalReason`), the same in every app, never the relay's.
60
+ */
61
+ export type SendAnswer = { accepted: true } | { accepted: false; reason: unknown }
57
62
 
58
- /** What an upload answered: the app's own record of the file, or why not. */
59
- export type UploadAnswer = { accepted: true; value: unknown } | { accepted: false; reason: string }
63
+ /** What an upload answered: the app's own record of the file, or why not, as it came; the card says `uploadRefusal`'s line. */
64
+ export type UploadAnswer = { accepted: true; value: unknown } | { accepted: false; reason: unknown }
60
65
 
61
66
  /** Where a file in the box is: Send waits for one uploading. */
62
67
  export type BoxFileState = 'uploading' | 'ready' | 'failed'
@@ -74,6 +79,15 @@ export interface BoxFile {
74
79
  value?: unknown
75
80
  }
76
81
 
82
+ /**
83
+ * Why a send was refused. "This message was deleted" is an edit's or a reaction's (Decided, ONE-4): a new message
84
+ * refused the same way (a reply whose message went) is one you can no longer write here.
85
+ */
86
+ function sendRefusal(reason: unknown): string {
87
+ const cause = refusalCause(reason)
88
+ return REFUSAL_REASONS[cause === 'gone' ? 'no-access' : cause]
89
+ }
90
+
77
91
  /** A draft, in the box's terms — `@estiva-app/conversation`'s `composerDraft` is one. */
78
92
  export interface CommentBoxDraft {
79
93
  read(): JSONContent | undefined
@@ -92,8 +106,8 @@ export interface CommentBoxEdit {
92
106
  * Opt-in, so an app whose save drops them never offers it: a file added and silently lost.
93
107
  */
94
108
  writesFiles?: boolean
95
- /** Why the relay refused this edit, when the app reopens a box it closed at once: said under it as it opens. Read as the box opens, so a reopen is a new box (a new `key`). */
96
- refused?: string
109
+ /** Why the relay refused this edit, as it came, when the app reopens a box it closed at once: said under it as it opens. Read as the box opens, so a reopen is a new box (a new `key`). */
110
+ refused?: unknown
97
111
  onCancel: () => void
98
112
  /** Save; the box holds the words until the answer, and a refusal is said under it. */
99
113
  onSave: (body: JSONContent, files: BoxFile[], under: BoxSentUnder) => Promise<SendAnswer>
@@ -495,7 +509,8 @@ function OpenCommentBox({
495
509
  }: CommentBoxProps) {
496
510
  const [files, setFiles] = useState<BoxFile[]>(edit?.files ?? [])
497
511
  const [sending, setSending] = useState(false)
498
- const [refused, setRefused] = useState<string | null>(edit?.refused ?? null)
512
+ // The plain reason, never the relay's words (ONE-4).
513
+ const [refused, setRefused] = useState<string | null>(edit?.refused ? refusalReason(edit.refused) : null)
499
514
  // What shows under the box, and what ✕ took off.
500
515
  const [reading, setReading] = useState<BoxUnderRead | undefined>(undefined)
501
516
  const [removed, setRemoved] = useState<ReadonlySet<string>>(() => new Set())
@@ -512,14 +527,19 @@ function OpenCommentBox({
512
527
  for (const file of picked) {
513
528
  fileCount += 1
514
529
  const id = `file-${fileCount}`
515
- setFiles((all) => [...all, { id, name: file.name, size: file.size, contentType: file.type, state: 'uploading' }])
516
- uploadOne(file).then(
517
- (answer) =>
518
- setFiles((all) =>
519
- all.map((f) => (f.id !== id ? f : answer.accepted ? { ...f, state: 'ready', value: answer.value } : { ...f, state: 'failed', note: answer.reason })),
520
- ),
521
- () => setFiles((all) => all.map((f) => (f.id === id ? { ...f, state: 'failed', note: 'It could not be uploaded.' } : f))),
522
- )
530
+ const card = { id, name: file.name, size: file.size, contentType: file.type }
531
+ // Over the server's limit for its type: said on its card before anything uploads (Miky, 4 Nov).
532
+ const over = tooLarge(file)
533
+ if (over) {
534
+ setFiles((all) => [...all, { ...card, state: 'failed', note: over }])
535
+ continue
536
+ }
537
+ setFiles((all) => [...all, { ...card, state: 'uploading' }])
538
+ const failed = (reason: unknown) => setFiles((all) => all.map((f) => (f.id === id ? { ...f, state: 'failed', note: uploadRefusal(reason, file) } : f)))
539
+ uploadOne(file).then((answer) => {
540
+ if (!answer.accepted) return failed(answer.reason)
541
+ setFiles((all) => all.map((f) => (f.id === id ? { ...f, state: 'ready', value: answer.value } : f)))
542
+ }, failed)
523
543
  }
524
544
  return true
525
545
  }, [])
@@ -558,6 +578,19 @@ function OpenCommentBox({
558
578
  return () => handOut.current?.(null)
559
579
  }, [editor])
560
580
 
581
+ // Whether the edit's words are gone: Save waits for something to save, and a refusal says the changes are in the box only while they are.
582
+ const editing = !!edit
583
+ const [wordless, setWordless] = useState(() => editing && !!editor && isEmpty(editor))
584
+ useEffect(() => {
585
+ if (!editor || !editing) return
586
+ const read = () => setWordless(isEmpty(editor))
587
+ read()
588
+ editor.on('update', read)
589
+ return () => {
590
+ editor.off('update', read)
591
+ }
592
+ }, [editor, editing])
593
+
561
594
  // Drafts: every change is kept, and an empty box is no draft.
562
595
  useEffect(() => {
563
596
  if (!editor || edit) return
@@ -645,7 +678,7 @@ function OpenCommentBox({
645
678
  const sent = files.filter((f) => f.state === 'ready')
646
679
  const sentUnder = underOf(body)
647
680
  setRefused(null)
648
- const answered = (answer: Promise<SendAnswer>) => answer.catch((): SendAnswer => ({ accepted: false, reason: 'try again in a moment' }))
681
+ const answered = (answer: Promise<SendAnswer>) => answer.catch((reason: unknown): SendAnswer => ({ accepted: false, reason }))
649
682
  if (showsAtOnce) {
650
683
  // Shown at once: the box empties now (the send box clears it); a refusal puts the words back above anything written since,
651
684
  // and what ✕ took off with them.
@@ -667,7 +700,7 @@ function OpenCommentBox({
667
700
  ed.commands.focus('end')
668
701
  setRemoved((now) => new Set([...now, ...took]))
669
702
  setFiles((all) => [...sent, ...all])
670
- setRefused(answer.reason)
703
+ setRefused(sendRefusal(answer.reason))
671
704
  })
672
705
  return true
673
706
  }
@@ -677,7 +710,7 @@ function OpenCommentBox({
677
710
  setSending(false)
678
711
  if (!answer.accepted) {
679
712
  layout?.refused()
680
- setRefused(answer.reason)
713
+ setRefused(sendRefusal(answer.reason))
681
714
  return
682
715
  }
683
716
  if (!ed.isDestroyed) ed.commands.clearContent(true)
@@ -691,17 +724,20 @@ function OpenCommentBox({
691
724
  [files, removed, underOf, showsAtOnce, send, draft, onSent, onRefused, layout],
692
725
  )
693
726
 
727
+ // An edit holding nothing, no words and no file, cannot be saved: Save is off, and nothing is said (Miky, 4 Nov). One
728
+ // emptied of its words that keeps a file is saved, in every app.
729
+ const holdsNothing = !!edit && wordless && files.length === 0
694
730
  save.current = () => {
695
- if (!editor || !edit || sending || uploading || failed > 0) return true
731
+ if (!editor || !edit || sending || uploading || failed > 0 || (isEmpty(editor) && files.length === 0)) return true
696
732
  setRefused(null)
697
733
  setSending(true)
698
734
  const body = editor.getJSON()
699
735
  void edit
700
736
  .onSave(body, files, underOf(body))
701
- .catch((): SendAnswer => ({ accepted: false, reason: 'try again in a moment' }))
737
+ .catch((reason: unknown): SendAnswer => ({ accepted: false, reason }))
702
738
  .then((answer) => {
703
739
  setSending(false)
704
- if (!answer.accepted) setRefused(answer.reason)
740
+ if (!answer.accepted) setRefused(refusalReason(answer.reason))
705
741
  })
706
742
  return true
707
743
  }
@@ -762,7 +798,7 @@ function OpenCommentBox({
762
798
 
763
799
  const refusedLine = refused && (
764
800
  <FieldLine tone="error">
765
- {edit ? `Not saved: ${refused}. Your changes are still in the box.` : `Not sent: ${refused}. Your text is back in the box.`}
801
+ {edit ? `Not saved: ${refused}.${holdsNothing ? '' : ' Your changes are still in the box.'}` : `Not sent: ${refused}. Your text is back in the box.`}
766
802
  </FieldLine>
767
803
  )
768
804
 
@@ -803,7 +839,7 @@ function OpenCommentBox({
803
839
  <Button variant="outlined" size="small" onClick={edit.onCancel}>
804
840
  Cancel
805
841
  </Button>
806
- <Button variant="primary" size="small" disabled={uploading || failed > 0 || sending} onClick={() => save.current()}>
842
+ <Button variant="primary" size="small" disabled={uploading || failed > 0 || sending || holdsNothing} onClick={() => save.current()}>
807
843
  Save
808
844
  </Button>
809
845
  </div>
@@ -62,6 +62,7 @@ import { ConversationCard } from '@estiva-app/ui'
62
62
  - **Edit opens your box**: `editor` draws your **CommentBox** edit form; call `done` when it saves or cancels. To open it again after a refused save, hold `editing` yourself.
63
63
  - **Resolve opens the dialog**: **ResolveDialog**, then `onResolve(note)`. Answer `false` when it was refused, and pass `resolveRefused` (why, in plain words); the dialog stays and says it.
64
64
  - **Delete asks first**: **ConfirmDialog**, then `onDelete()`. Answer `false` when it was refused, and pass `deleteRefused` (why, in plain words): the question stays and says it, as Resolve's does.
65
+ - **A reaction answers**: `reactions.onToggle` returns the relay's answer, `{ accepted: false, reason }` with the reason as it came. The card says "Not reacted: *why*." under the reactions in `@estiva-app/conversation`'s plain words, until the next reaction on it or until it goes; only the latest reaction's answer is said. Hold no refusal of your own.
65
66
  - **A refusal is said only in the question it answered.** Keep it in your own state and never clear it: a question opened again says nothing until its own press is refused.
66
67
  - **Deleted** keeps its `about`: what it was on stays above "This comment was deleted.", for the replies under it.
67
68
  - `time` is your words for it ("11:08 AM"); `at` is the moment (ms), from which the card says the exact date and time on hover. Never a tooltip of your own round `time`.
@@ -76,6 +77,7 @@ import { ConversationCard } from '@estiva-app/ui'
76
77
  | A card that opens on a press is a Tab stop: reaching it shows its actions, Enter or Space opens it | a `tabIndex` and a key handler | |
77
78
  | Asks before it deletes | a confirm dialog | |
78
79
  | Says a refusal only in the question it answered | clearing it when the question closes | |
80
+ | Says why a reaction was refused, in the words every app says, until the next reaction or until the card goes | a refusal state, or words for the relay's reasons | |
79
81
  | Says the exact date and time under the pointer, from `at` | a tooltip round the time | |
80
82
  | Opens the Resolve dialog, and closes it once resolved | a dialog and its open state | |
81
83
  | Says it is resolved, with who and the note, and hides nothing of it | a resolved line or chip of your own | |
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
  import { useState } from 'react'
3
3
  import { userEvent, within } from 'storybook/test'
4
4
  import { ConversationCard, type ConversationCardProps } from './ConversationCard'
5
- import { AT, Column, EditBox, Files, LONG, Mentions, ONE, SOME, THREE, TWO, WithBlock, WithCard, WORDS, YOU, useReactions } from './conversation.examples'
5
+ import { AT, Column, EditBox, Files, LONG, Mentions, ONE, RELAY_SAYS, SOME, THREE, TWO, WithBlock, WithCard, WORDS, YOU, useReactions, type RelaySays } from './conversation.examples'
6
6
  import { RichText } from './RichText'
7
7
  import { MenuItem } from './Menu'
8
8
  import type { ReactionCount } from './ReactionRow'
@@ -47,6 +47,14 @@ function Live({ start, resolvedAt, deletable = true, ...props }: ConversationCar
47
47
  )
48
48
  }
49
49
 
50
+ type CardWithRefusal = ConversationCardProps & { refusal: RelaySays }
51
+
52
+ /** A card whose every reaction the relay refuses, for `refusal`. */
53
+ function RefusingReactions({ refusal, ...props }: CardWithRefusal) {
54
+ const reacting = useReactions(SOME)
55
+ return <ConversationCard {...props} reactions={{ ...reacting, onToggle: () => new Promise((resolve) => setTimeout(() => resolve({ accepted: false, reason: RELAY_SAYS[refusal] }), 400)) }} />
56
+ }
57
+
50
58
  /** Someone's comment. */
51
59
  export const Comment: Story = { render: (args) => <Live {...args} /> }
52
60
 
@@ -146,14 +154,30 @@ export const Selected: Story = { render: (args) => <Live {...args} selected repl
146
154
  /** Being edited, in the kit's box. */
147
155
  export const Editing: Story = { render: (args) => <Live {...args} author={YOU} own editing /> }
148
156
 
149
- /** An edit that was refused: the box opens again, and says why. */
150
- export const EditRefused: Story = {
157
+ /** An edit that was refused: Save, and the box says why. Pick what the relay said in the controls. */
158
+ export const EditRefused: StoryObj<CardWithRefusal> = {
151
159
  name: 'Edit refused',
152
- render: (args) => <ConversationCard {...args} author={YOU} own editing editor={(done) => <EditBox text={WORDS} done={done} refuse />} />,
160
+ args: { refusal: 'Too long' },
161
+ argTypes: { refusal: { control: 'select', options: Object.keys(RELAY_SAYS) } },
162
+ render: ({ refusal, ...args }) => <ConversationCard {...args} author={YOU} own editing editor={(done) => <EditBox text={WORDS} done={done} refuse={refusal} />} />,
163
+ play: async ({ canvasElement }) => {
164
+ await userEvent.click(within(canvasElement).getByRole('button', { name: 'Save' }))
165
+ },
153
166
  }
154
167
 
155
- /** A reaction that was refused: said under the reactions. */
156
- export const ReactionRefused: Story = { name: 'Reaction refused', render: (args) => <Live {...args} start={SOME} reactionRefused="try again in a moment" /> }
168
+ /**
169
+ * A reaction that was refused: said under the reactions until the next reaction here, or until the card goes. Pick
170
+ * what the relay said in the controls; the story presses a reaction.
171
+ */
172
+ export const ReactionRefused: StoryObj<CardWithRefusal> = {
173
+ name: 'Reaction refused',
174
+ args: { refusal: 'Deleted, or no longer yours to write beside' },
175
+ argTypes: { refusal: { control: 'select', options: Object.keys(RELAY_SAYS) } },
176
+ render: ({ refusal, ...args }) => <RefusingReactions {...args} refusal={refusal} />,
177
+ play: async ({ canvasElement }) => {
178
+ await userEvent.click(within(canvasElement).getByRole('button', { name: 'Makes sense, 2' }))
179
+ },
180
+ }
157
181
 
158
182
  /** Nothing can be changed: no strip, reactions only shown. */
159
183
  export const ReadOnly: Story = { name: 'Read-only', render: (args) => <Live {...args} readOnly start={SOME} replies={{ count: 2, faces: [TWO, THREE], last: '12:02 PM' }} /> }
@@ -1,7 +1,7 @@
1
1
  // @vitest-environment jsdom
2
2
  import { useState } from 'react'
3
3
  import { afterEach, describe, expect, it, vi } from 'vitest'
4
- import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
4
+ import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
5
5
  import userEvent from '@testing-library/user-event'
6
6
  import { ConversationCard, ReplyCard } from './ConversationCard'
7
7
  import { PinnedComment } from './PinnedComment'
@@ -179,6 +179,68 @@ describe('ConversationCard', () => {
179
179
  })
180
180
  })
181
181
 
182
+ describe('a refused reaction (ONE-4)', () => {
183
+ const OPTIONS = [{ emoji: '👍', label: 'Makes sense' }]
184
+ const row = (onToggle: (emoji: string) => Promise<{ accepted: true } | { accepted: false; reason: unknown }>) => ({
185
+ reactions: [{ emoji: '👍', by: ['a', 'b'] }],
186
+ options: OPTIONS,
187
+ nameOf: () => 'Someone',
188
+ onToggle,
189
+ })
190
+ const settle = () => act(async () => {
191
+ for (let i = 0; i < 5; i++) await Promise.resolve()
192
+ })
193
+
194
+ it('says why in plain words under the reactions, never the relay’s', async () => {
195
+ render(
196
+ <ConversationCard author={ONE} time="11:08 AM" reactions={row(async () => ({ accepted: false, reason: 'invalid: reaction target event not found' }))}>
197
+ Words
198
+ </ConversationCard>,
199
+ )
200
+ fireEvent.click(screen.getByRole('button', { name: 'Makes sense, 2' }))
201
+ await settle()
202
+ expect(screen.getByText('Not reacted: this message was deleted, or you can no longer write here.')).toBeTruthy()
203
+ expect(screen.queryByText(/invalid:/)).toBeNull()
204
+ })
205
+
206
+ it('is gone on the next reaction, and a reply’s works the same', async () => {
207
+ const answers: ((a: { accepted: true } | { accepted: false; reason: unknown }) => void)[] = []
208
+ const onToggle = () => new Promise<{ accepted: true } | { accepted: false; reason: unknown }>((resolve) => answers.push(resolve))
209
+ render(
210
+ <ReplyCard author={ONE} time="11:40 AM" reactions={row(onToggle)}>
211
+ A reply
212
+ </ReplyCard>,
213
+ )
214
+ fireEvent.click(screen.getByRole('button', { name: 'Makes sense, 2' }))
215
+ answers[0]({ accepted: false, reason: 'rate-limited: slow down' })
216
+ await settle()
217
+ expect(screen.getByText('Not reacted: too many at once, try again in a moment.')).toBeTruthy()
218
+ fireEvent.click(screen.getByRole('button', { name: 'Makes sense, 2' }))
219
+ expect(screen.queryByText(/Not reacted/)).toBeNull()
220
+ answers[1]({ accepted: true })
221
+ await settle()
222
+ expect(screen.queryByText(/Not reacted/)).toBeNull()
223
+ })
224
+
225
+ it('says only the latest reaction’s answer: an earlier refusal arriving late does not replace it', async () => {
226
+ const answers: ((a: { accepted: true } | { accepted: false; reason: unknown }) => void)[] = []
227
+ const onToggle = () => new Promise<{ accepted: true } | { accepted: false; reason: unknown }>((resolve) => answers.push(resolve))
228
+ render(
229
+ <ConversationCard author={ONE} time="11:08 AM" reactions={row(onToggle)}>
230
+ Words
231
+ </ConversationCard>,
232
+ )
233
+ fireEvent.click(screen.getByRole('button', { name: 'Makes sense, 2' }))
234
+ fireEvent.click(screen.getByRole('button', { name: 'Makes sense, 2' }))
235
+ answers[1]({ accepted: false, reason: 'rate-limited: slow down' })
236
+ await settle()
237
+ answers[0]({ accepted: false, reason: 'invalid: reaction target event not found' })
238
+ await settle()
239
+ expect(screen.getByText('Not reacted: too many at once, try again in a moment.')).toBeTruthy()
240
+ expect(screen.queryByText(/this message was deleted/)).toBeNull()
241
+ })
242
+ })
243
+
182
244
  describe('ReplyCard', () => {
183
245
  it('asks before it deletes your reply', async () => {
184
246
  const user = userEvent.setup()
@@ -1,4 +1,5 @@
1
1
  import { useContext, useLayoutEffect, useRef, useState, type ReactNode, type RefObject } from 'react'
2
+ import { refusalReason } from '@estiva-app/conversation'
2
3
  import { IconArrowNarrowRight, IconCircleCheck, IconDotsVertical } from '@tabler/icons-react'
3
4
  import { Avatar } from './Avatar'
4
5
  import { Card } from './Card'
@@ -47,10 +48,11 @@ export interface ConversationEntryProps {
47
48
  about?: ReactNode
48
49
  /** Pictures and files: `AttachmentCard`s, laid out under the words. */
49
50
  files?: ReactNode
50
- /** Its reactions: the kit's `ReactionRow`. With `onToggle`, the strip offers React too. */
51
+ /**
52
+ * Its reactions: the kit's `ReactionRow`. With `onToggle`, the strip offers React too; when `onToggle` answers with a
53
+ * refusal, "Not reacted: <why>." is said under the reactions until the next reaction here, or until the card goes.
54
+ */
51
55
  reactions?: ReactionRowProps
52
- /** Why the last reaction was refused, in plain words: said under the reactions. */
53
- reactionRefused?: string
54
56
  /** Not read yet: the dot, or the urgent mark with `urgent`, and the card's edge in the theme's colour. */
55
57
  isNew?: boolean
56
58
  urgent?: boolean
@@ -253,6 +255,34 @@ function Words({ children }: { children: ReactNode }) {
253
255
  )
254
256
  }
255
257
 
258
+ /**
259
+ * The card holds why its last reaction was refused, so it lasts the same in every app: said from the answer until the
260
+ * next reaction here, or until the card goes. Only the latest reaction's answer is said.
261
+ */
262
+ function useReactionRefusal(reactions: ReactionRowProps | undefined): { row: ReactionRowProps | undefined; refused: string | undefined } {
263
+ const [refused, setRefused] = useState<string>()
264
+ const latest = useRef(0)
265
+ const toggle = reactions?.onToggle
266
+ if (!reactions || !toggle) return { row: reactions, refused }
267
+ const onToggle = (emoji: string) => {
268
+ const mine = ++latest.current
269
+ setRefused(undefined)
270
+ const say = (reason: unknown) => {
271
+ if (mine === latest.current) setRefused(refusalReason(reason))
272
+ }
273
+ const answer = toggle(emoji)
274
+ if (!answer) return
275
+ return answer.then((said) => {
276
+ if (said && !said.accepted) say(said.reason)
277
+ return said
278
+ }, (reason: unknown) => {
279
+ say(reason)
280
+ return { accepted: false as const, reason }
281
+ })
282
+ }
283
+ return { row: { ...reactions, onToggle }, refused }
284
+ }
285
+
256
286
  function Reactions({ reactions, refused, readOnly }: { reactions?: ReactionRowProps; refused?: string; readOnly: boolean }) {
257
287
  if ((!reactions || reactions.reactions.length === 0) && !refused) return null
258
288
  return (
@@ -347,7 +377,7 @@ function useEditing(editing: boolean | undefined, onEditingChange: ((editing: bo
347
377
  * The same card in every app, each in its own colours (the record that makes one conversation). Peek's, moved.
348
378
  */
349
379
  export function ConversationCard(props: ConversationCardProps) {
350
- 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, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', className, children } = props
380
+ const { author, about, files, reactions, isNew = false, urgent = false, own = false, editor, deleted = false, replies, onReply, resolved, noun = 'comment', onResolve, resolveHint, resolveRefused, onReopen, selected, onClick, onDelete, deleteNote, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', className, children } = props
351
381
  const readOnly = (props.readOnly ?? false) || deleted
352
382
  const inThreadCard = useContext(InThreadCard)
353
383
 
@@ -378,7 +408,8 @@ export function ConversationCard(props: ConversationCardProps) {
378
408
  const showStrip = hovered && !isEditing && !readOnly
379
409
  const strip = useRef<HTMLDivElement>(null)
380
410
  const wordsEnd = useClearOfStrip(root, strip, showStrip)
381
- const react = reactions?.onToggle
411
+ const { row: reactionRow, refused: reactionRefused } = useReactionRefusal(reactions)
412
+ const react = reactionRow?.onToggle
382
413
  // 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).
383
414
  const press = onClick ?? (readOnly && !replies?.count ? undefined : item?.toggle)
384
415
  const reply = onReply ?? item?.show
@@ -459,7 +490,7 @@ export function ConversationCard(props: ConversationCardProps) {
459
490
  {!deleted && files && (
460
491
  <div className="relative flex w-full flex-wrap items-start gap-2 pb-2 pl-8 pr-2">{files}</div>
461
492
  )}
462
- <Reactions reactions={reactions} refused={reactionRefused} readOnly={readOnly} />
493
+ <Reactions reactions={reactionRow} refused={reactionRefused} readOnly={readOnly} />
463
494
  {resolved?.note && (
464
495
  // Who resolved it and the note, above the way into the replies; the check by the time says "Resolved" (Katerina, 1 November).
465
496
  <div className="relative w-full pb-1">
@@ -543,7 +574,8 @@ export function ConversationCard(props: ConversationCardProps) {
543
574
  * when it has one. Peek's, moved with the conversation.
544
575
  */
545
576
  export function ReplyCard(props: ReplyCardProps) {
546
- const { id, author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', noun = 'reply', className, children } = props
577
+ const { id, author, about, files, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, deleteRefused, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', noun = 'reply', className, children } = props
578
+ const { row: reactions, refused: reactionRefused } = useReactionRefusal(props.reactions)
547
579
  const readOnly = props.readOnly ?? false
548
580
  const [hovered, setHovered] = useState(false)
549
581
  const [menuOpen, setMenuOpen] = useState(false)
@@ -13,7 +13,7 @@ the button that sends it, waiting together while it sends.
13
13
  ## When
14
14
 
15
15
  - A dialog that asks for something and then does it: a name, a destination, a
16
- resolution. New folder, Rename folder, Start a topic, Move, Archive.
16
+ resolution. New team, Rename team, Start a topic, Move, Archive.
17
17
  - `ready` says when there is enough to send; until then the button is greyed and
18
18
  Enter sends nothing.
19
19
  - Nothing to choose from: give a section's **EmptyState** as the only child and
@@ -35,7 +35,7 @@ import { FormDialog, Field, TextInput } from '@estiva-app/ui'
35
35
 
36
36
  {open && (
37
37
  <FormDialog
38
- title="New folder"
38
+ title="New team"
39
39
  submitLabel="Create"
40
40
  busyLabel="Creating…"
41
41
  ready={!!name.trim()}
@@ -43,7 +43,7 @@ import { FormDialog, Field, TextInput } from '@estiva-app/ui'
43
43
  onClose={() => setOpen(false)}
44
44
  >
45
45
  <p className="text-body-2 text-text-secondary">A place for files and conversations.</p>
46
- <Field label="Folder name">
46
+ <Field label="Team name">
47
47
  <TextInput value={name} onChange={(e) => setName(e.target.value)} autoFocus />
48
48
  </Field>
49
49
  </FormDialog>
@@ -17,7 +17,7 @@ const meta = {
17
17
  },
18
18
  argTypes: { children: { control: false }, onSubmit: { control: false }, onClose: { control: false } },
19
19
  args: {
20
- title: 'New folder',
20
+ title: 'New team',
21
21
  submitLabel: 'Create',
22
22
  busyLabel: 'Creating…',
23
23
  onSubmit: () => {},
@@ -31,14 +31,14 @@ type Story = StoryObj<typeof meta>
31
31
 
32
32
  /** One field and the sentence before it. Create waits for a name; Enter in the field sends. */
33
33
  export const NewFolder: Story = {
34
- name: 'New folder',
34
+ name: 'New team',
35
35
  parameters: { controls: { disable: true } },
36
36
  render: (args) => {
37
37
  const [name, setName] = useState('')
38
38
  return (
39
39
  <FormDialog {...args} ready={!!name.trim()}>
40
40
  <p className="text-body-2 text-text-secondary">A place for files and conversations. Everyone you add to it can read what is in it.</p>
41
- <Field label="Folder name">
41
+ <Field label="Team name">
42
42
  <TextInput value={name} onChange={(event) => setName(event.target.value)} placeholder="What is it for?" autoFocus />
43
43
  </Field>
44
44
  </FormDialog>
@@ -53,7 +53,7 @@ export const Sending: Story = {
53
53
  render: NewFolder.render,
54
54
  play: async ({ canvasElement }) => {
55
55
  const page = within(canvasElement.ownerDocument.body)
56
- await userEvent.type(page.getByRole('textbox', { name: 'Folder name' }), 'Steer')
56
+ await userEvent.type(page.getByRole('textbox', { name: 'Team name' }), 'Steer')
57
57
  await userEvent.click(page.getByRole('button', { name: 'Create' }))
58
58
  },
59
59
  }
@@ -69,7 +69,7 @@ export const Refused: Story = {
69
69
  /** Nothing to choose from: a section's empty line where the fields would be, and the button greyed. */
70
70
  export const NothingToChoose: Story = {
71
71
  name: 'Nothing to choose',
72
- args: { title: 'Move', submitLabel: 'Move', busyLabel: 'Moving…', ready: false, children: <EmptyState scope="section" message="There is no other folder it can be moved to." /> },
72
+ args: { title: 'Move', submitLabel: 'Move', busyLabel: 'Moving…', ready: false, children: <EmptyState scope="section" message="There is no other team it can be moved to." /> },
73
73
  }
74
74
 
75
75
  /** A Resolve: the kit's `resolve` look on the sending button, as `ResolveDialog` draws it. */
@@ -5,20 +5,20 @@ import * as MoveDialogStories from './MoveDialog.stories'
5
5
 
6
6
  # MoveDialog
7
7
 
8
- Move a file to another Folder, under another file there, or both: the Folder
9
- first, then what it goes under, read when the Folder is picked.
8
+ Move a file to another team, under another file there, or both: the team
9
+ first, then what it goes under, read when the team is picked.
10
10
 
11
11
  <Canvas of={MoveDialogStories.Topic} />
12
12
 
13
13
  ## When
14
14
 
15
- - Moving any file, from its menu, its row or its Folder. A file that may sit
15
+ - Moving any file, from its menu, its row or its team. A file that may sit
16
16
  under another passes `placesIn`; one that nests under nothing passes none, and
17
- is asked only for the Folder.
18
- - A file that may sit at the top of any Folder: `startAtTop`, so the top is
17
+ is asked only for the team.
18
+ - A file that may sit at the top of any team: `startAtTop`, so the top is
19
19
  chosen for the person. Otherwise Move waits for a pick: a preselected place is
20
20
  a move nobody chose.
21
- - A file not listed in exactly one Folder: `from=""`, and no Folder is held
21
+ - A file not listed in exactly one team: `from=""`, and no team is held
22
22
  back. Listed in none; or in two after a move that half-worked, where moving
23
23
  into either takes it out of the other, so Move again is the retry. Nothing is
24
24
  chosen for the person even so; `startIn` opens it on one.
@@ -29,7 +29,7 @@ first, then what it goes under, read when the Folder is picked.
29
29
 
30
30
  ## When not
31
31
 
32
- - Renaming, or choosing a Folder for something new → **FormDialog** with a **Select**.
32
+ - Renaming, or choosing a team for something new → **FormDialog** with a **Select**.
33
33
  - One value from a list on a page, not a move → **Select**.
34
34
 
35
35
  ## How
@@ -52,23 +52,23 @@ import { MoveDialog } from '@estiva-app/ui'
52
52
 
53
53
  - A place is `{ id, path }`: `id` is what it goes under, its address, and `''`
54
54
  for the top; `path` is its breadcrumb, drawn as "Brief › Notes".
55
- - `placesIn` is called once per Folder, when it is picked; a rejection is said as
55
+ - `placesIn` is called once per team, when it is picked; a rejection is said as
56
56
  the section's empty line, with **Try again**. `places` are the ones in `from`,
57
- already read; without them the Folder it opens on is read at once.
57
+ already read; without them the team it opens on is read at once.
58
58
  - `onMove` gets `{ folder }`, and `parent` too when it nests (`''` for the top).
59
59
  Answer `false` to keep it open once you have said why.
60
60
  - `folders` undefined while they are read: the list says "Reading…".
61
61
  - `heading`, `folderLabel`, `noFolder` and `topLabel` are for your app's words;
62
- `startIn` opens it on another Folder than the one it is in. An app that
62
+ `startIn` opens it on another team than the one it is in. An app that
63
63
  chooses one for the person holds its `startIn` steady while the dialog is
64
64
  open: a refusal that changes where the file is listed must not move it.
65
- - Pass only the Folders a move can land in: filter `folders` before, by your
66
- app's own rules (a Folder that cannot take it). A move your app refuses when
65
+ - Pass only the teams a move can land in: filter `folders` before, by your
66
+ app's own rules (a team that cannot take it). A move your app refuses when
67
67
  it is made is answered with `false`, said why, and the dialog stays.
68
- - `check` adds one box under the choice that only some Folders ask:
68
+ - `check` adds one box under the choice that only some teams ask:
69
69
  `label(folder)` gives its words there, or `undefined` to leave it out;
70
70
  `checked` ticks it at open. `onMove` then gets `checked`, only when the box
71
- was shown for the Folder picked.
71
+ was shown for the team picked.
72
72
 
73
73
  <Canvas of={MoveDialogStories.WithABox} />
74
74
 
@@ -82,8 +82,8 @@ import { MoveDialog } from '@estiva-app/ui'
82
82
 
83
83
  | It does | So you never write | Refused when written by hand |
84
84
  |---|---|---|
85
- | Reads a Folder's places when it is picked, once, and says when it could not, with Try again | a read state per Folder, or a retry row | |
86
- | Offers only moves that do something, and chooses nothing for the person but the top when asked | a filter on the Folders, or a preselection | |
85
+ | Reads a team's places when it is picked, once, and says when it could not, with Try again | a read state per team, or a retry row | |
86
+ | Offers only moves that do something, and chooses nothing for the person but the top when asked | a filter on the teams, or a preselection | |
87
87
  | Sends on Move, says it is moving, and closes when the move went through | a busy state, or an `if (ok) onClose()` | |
88
88
 
89
89
  ## Props