@estiva-app/ui 0.102.2 → 0.104.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 (52) hide show
  1. package/dist/CommentBox.d.ts +16 -0
  2. package/dist/CommentBox.d.ts.map +1 -1
  3. package/dist/ConfirmDialog.d.ts +6 -1
  4. package/dist/ConfirmDialog.d.ts.map +1 -1
  5. package/dist/ConversationCard.d.ts +2 -0
  6. package/dist/ConversationCard.d.ts.map +1 -1
  7. package/dist/LinkChip.d.ts.map +1 -1
  8. package/dist/LinkRow.d.ts +6 -0
  9. package/dist/LinkRow.d.ts.map +1 -1
  10. package/dist/MoveDialog.d.ts +12 -1
  11. package/dist/MoveDialog.d.ts.map +1 -1
  12. package/dist/QuotedLine.d.ts +1 -1
  13. package/dist/QuotedLine.d.ts.map +1 -1
  14. package/dist/SectionHeader.d.ts.map +1 -1
  15. package/dist/editor.d.ts +1 -1
  16. package/dist/editor.d.ts.map +1 -1
  17. package/dist/editor.js +14 -6
  18. package/dist/editor.js.map +3 -3
  19. package/dist/index.d.ts +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +278 -265
  22. package/dist/index.js.map +4 -4
  23. package/package.json +1 -1
  24. package/registry.json +32 -2
  25. package/src/CommentBox.mdx +1 -0
  26. package/src/CommentBox.stories.tsx +17 -1
  27. package/src/CommentBox.test.tsx +24 -0
  28. package/src/CommentBox.tsx +29 -1
  29. package/src/ConfirmDialog.mdx +2 -0
  30. package/src/ConfirmDialog.stories.tsx +6 -0
  31. package/src/ConfirmDialog.test.tsx +12 -1
  32. package/src/ConfirmDialog.tsx +8 -1
  33. package/src/ConversationCard.mdx +2 -0
  34. package/src/ConversationCard.stories.tsx +6 -0
  35. package/src/ConversationCard.test.tsx +50 -0
  36. package/src/ConversationCard.tsx +13 -7
  37. package/src/LinkChip.test.tsx +13 -2
  38. package/src/LinkChip.tsx +4 -3
  39. package/src/LinkRow.tsx +6 -2
  40. package/src/MoveDialog.mdx +6 -0
  41. package/src/MoveDialog.stories.tsx +13 -0
  42. package/src/MoveDialog.test.tsx +40 -1
  43. package/src/MoveDialog.tsx +19 -1
  44. package/src/NavTree.stories.tsx +1 -1
  45. package/src/QuotedLine.mdx +2 -1
  46. package/src/QuotedLine.test.tsx +9 -0
  47. package/src/QuotedLine.tsx +4 -2
  48. package/src/SectionHeader.mdx +1 -0
  49. package/src/SectionHeader.test.tsx +7 -0
  50. package/src/SectionHeader.tsx +4 -1
  51. package/src/editor.ts +1 -0
  52. package/src/index.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@estiva-app/ui",
3
- "version": "0.102.2",
3
+ "version": "0.104.0",
4
4
  "description": "Estiva's design tokens (the contract) and a small set of primitives (a convenience) for every Estiva app.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/registry.json CHANGED
@@ -4,9 +4,9 @@
4
4
  "kind": "package",
5
5
  "repo": "estiva-ui",
6
6
  "package": "@estiva-app/ui",
7
- "packageVersion": "0.102.2",
7
+ "packageVersion": "0.104.0",
8
8
  "exports": 245,
9
- "typeExports": 252,
9
+ "typeExports": 254,
10
10
  "files": null
11
11
  },
12
12
  "storybook": {
@@ -2286,6 +2286,12 @@
2286
2286
  "required": false,
2287
2287
  "note": "The card and parts in the box while something is written, with the files, ✕ on the card."
2288
2288
  },
2289
+ {
2290
+ "name": "about",
2291
+ "takes": "BoxAbout",
2292
+ "required": false,
2293
+ "note": "What the new comment will be on, in a strip above the box on the inset fill: the `about` the posted card will carry (a `QuotedLine`, the app's words for a block), with ✕ in it, in the app's words, to drop it."
2294
+ },
2289
2295
  {
2290
2296
  "name": "showsAtOnce",
2291
2297
  "takes": "true/false",
@@ -2558,6 +2564,12 @@
2558
2564
  "takes": "ConfirmDialogAlternative",
2559
2565
  "required": false,
2560
2566
  "note": "A third, safer answer — \"Archive instead\" — drawn after the words, under its sentence, and switched off while the confirm runs (Peek's, 2 November)."
2567
+ },
2568
+ {
2569
+ "name": "refused",
2570
+ "takes": "text",
2571
+ "required": false,
2572
+ "note": "Why the last confirm was refused, in plain words: said under the words, in the error line, while the question stays open (`onConfirm` answered `false`), as `ResolveDialog`'s `refused` is said under its field."
2561
2573
  }
2562
2574
  ],
2563
2575
  "variants": [],
@@ -2933,6 +2945,12 @@
2933
2945
  "required": false,
2934
2946
  "note": "The app's own words under the delete question, what deleting does there, in place of the kit's: \"It is deleted for everyone.\", and on a comment how many replies stay."
2935
2947
  },
2948
+ {
2949
+ "name": "deleteRefused",
2950
+ "takes": "text",
2951
+ "required": false,
2952
+ "note": "Why the last delete was refused, in plain words: said under the question, while it stays open (`onDelete` answered `false`)."
2953
+ },
2936
2954
  {
2937
2955
  "name": "menu",
2938
2956
  "takes": "anything",
@@ -7212,6 +7230,12 @@
7212
7230
  "required": false,
7213
7231
  "note": "Said when no Folder is offered. \"There is no other folder it can be moved to.\" when absent."
7214
7232
  },
7233
+ {
7234
+ "name": "check",
7235
+ "takes": "MoveCheck",
7236
+ "required": false,
7237
+ "note": "A box under the choice, asked only where `label` names it; its answer comes back as `checked`."
7238
+ },
7215
7239
  {
7216
7240
  "name": "onMove",
7217
7241
  "takes": "a handler",
@@ -9481,6 +9505,12 @@
9481
9505
  "required": false,
9482
9506
  "note": "The app's own words under the delete question, what deleting does there, in place of the kit's: \"It is deleted for everyone.\", and on a comment how many replies stay."
9483
9507
  },
9508
+ {
9509
+ "name": "deleteRefused",
9510
+ "takes": "text",
9511
+ "required": false,
9512
+ "note": "Why the last delete was refused, in plain words: said under the question, while it stays open (`onDelete` answered `false`)."
9513
+ },
9484
9514
  {
9485
9515
  "name": "menu",
9486
9516
  "takes": "anything",
@@ -18,6 +18,7 @@ The one box every app writes a comment, a reply and a line of a conversation in:
18
18
  - `under` to show, while something is written, the one card it will be sent with and the live part of each block link. They sit inside the box with the files, on the files' fill; the card's ✕ is a file's, on hover, and its values and links read as words until it is sent, so a click on it never leaves the draft. An edit box shows the card and no part.
19
19
  - `referenceView` to draw every link the box holds — a pasted app URL once it names something, a pasted `nostr:` address of a file or a message, and a `[` pick — as the app draws a link, with the kit's **LinkChip**: one chip look in every box. It is told it is being edited, so it shows no preview, and a click on it stays in the draft.
20
20
  - `closed` where nothing can be written (archived, signed out): a line saying why, in the box's place. No greyed box.
21
+ - `about` when the new comment will be on a part of the page: a strip above the box, on the inset fill, its ✕ in it, `view` being the `about` the posted **ConversationCard** will carry (a **QuotedLine**, your words for a block), and `remove` its ✕ in your words ("Comment on the whole page instead"). Not drawn on an edit or a closed box.
21
22
  - `marked` when the app has its own reason for the bar down the text, besides an urgent mention, which always draws it.
22
23
  - `onEditor` when something outside the box writes into it: the app keeps the editor it is handed and inserts into the box last used.
23
24
 
@@ -1,5 +1,5 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { useState } from 'react'
2
+ import { useState, type ReactNode } from 'react'
3
3
  import type { Editor, JSONContent } from '@tiptap/react'
4
4
  import { IconSquareRounded } from '@tabler/icons-react'
5
5
  import { expect, userEvent, waitFor, within } from 'storybook/test'
@@ -13,6 +13,7 @@ import { LinkCard } from './LinkCard'
13
13
  import { LinkChip } from './LinkChip'
14
14
  import { ITEM, ITEM_NO_SUMMARY, ready } from './linked.examples'
15
15
  import { PartCard } from './PartCard'
16
+ import { QuotedLine } from './QuotedLine'
16
17
  import { RichText } from './RichText'
17
18
 
18
19
  /**
@@ -215,6 +216,21 @@ export const ReadOnlyArchived: Story = { render: () => <Live closed={{ reason: '
215
216
  /** Read-only, signed out: a line in the box's place. */
216
217
  export const ReadOnlySignedOut: Story = { render: () => <Live closed={{ reason: 'Sign in to write here.' }} /> }
217
218
 
219
+ /** A new comment on a part of the page; ✕ drops the line, and the comment is on the whole page. */
220
+ function OnAPart({ view, remove, placeholder }: { view: ReactNode; remove: string; placeholder: string }) {
221
+ const [on, setOn] = useState(true)
222
+ return <Live about={on ? { view, remove: { label: remove, onRemove: () => setOn(false) } } : undefined} placeholder={on ? placeholder : 'Comment on this page…'} />
223
+ }
224
+
225
+ /** On words of the page: the line above the box says which, as the posted comment's `about` will (Leaf's and Ship's, 3 November). */
226
+ export const OnWords: Story = {
227
+ name: 'On words',
228
+ render: () => <OnAPart view={<QuotedLine words="the second step of the plan" />} remove="Comment on the whole page instead" placeholder="Comment on these words…" />,
229
+ }
230
+
231
+ /** On a part with no words, a block: the app's own words for it, in the same line. */
232
+ export const OnABlock: Story = { name: 'On a block', render: () => <OnAPart view={<QuotedLine label="On the paragraph" />} remove="Remove" placeholder="Comment on this block…" /> }
233
+
218
234
  const ITEM_URL = 'https://app.example/item/one'
219
235
  const PART_URL = 'https://app.example/page/two#block'
220
236
 
@@ -440,6 +440,30 @@ describe('read-only', () => {
440
440
  })
441
441
  })
442
442
 
443
+ // Leaf's "On “words”" and Ship's block note over the box, each hand-made, now the kit's (Katerina, 3 November).
444
+ describe('above the box: what the new comment will be on, with ✕', () => {
445
+ it('draws the app’s line above the box, and its ✕ in the app’s words drops it', () => {
446
+ const onRemove = vi.fn()
447
+ render(<Box about={{ view: <span>On “press notes”</span>, remove: { label: 'Comment on the whole document instead', onRemove } }} />)
448
+ const line = screen.getByText('On “press notes”')
449
+ expect(line.compareDocumentPosition(document.querySelector('.ProseMirror')!) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
450
+ fireEvent.click(screen.getByRole('button', { name: 'Comment on the whole document instead' }))
451
+ expect(onRemove).toHaveBeenCalledOnce()
452
+ })
453
+
454
+ it('with no remove, the line has no ✕', () => {
455
+ render(<Box about={{ view: <span>On the paragraph</span> }} />)
456
+ expect(screen.getByText('On the paragraph')).toBeTruthy()
457
+ expect(screen.queryByRole('button', { name: /instead|Remove/ })).toBeNull()
458
+ })
459
+
460
+ it('a closed box says only why: no line about a comment it cannot write', () => {
461
+ render(<Box closed={{ reason: 'Archived.' }} about={{ view: <span>On the paragraph</span>, remove: { label: 'Remove', onRemove: () => {} } }} />)
462
+ expect(screen.getByText('Archived.')).toBeTruthy()
463
+ expect(screen.queryByText('On the paragraph')).toBeNull()
464
+ })
465
+ })
466
+
443
467
  describe('under the box: the one card, with ✕, and the live parts', () => {
444
468
  const ISSUE = 'https://app.example/item/one'
445
469
  const BLOCK = 'https://app.example/page/two#block'
@@ -1,7 +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 { IconLock, IconPaperclip, IconSquareRounded } from '@tabler/icons-react'
4
+ import { IconLock, IconPaperclip, IconSquareRounded, IconX } from '@tabler/icons-react'
5
5
  import { AttachedCard } from './AttachedCard'
6
6
  import { AttachmentCard } from './AttachmentCard'
7
7
  import { ReferenceNode, type ReferenceViewProps } from './BlockNodes'
@@ -25,6 +25,7 @@ import {
25
25
  } from './ComposerTriggers'
26
26
  import { FieldLine } from './Field'
27
27
  import { FilePicker } from './FilePicker'
28
+ import { IconButton } from './IconButton'
28
29
  import { inTheBox } from './linked'
29
30
  import { LinkedIcon } from './LinkParts'
30
31
  import { linkedKindOfReference } from './LinkPlaces'
@@ -127,6 +128,14 @@ export interface BoxSentUnder {
127
128
  card?: string
128
129
  }
129
130
 
131
+ /** What a new comment will be on, above the box (Leaf's "On “words”", Ship's block: each hand-made until 3 November). */
132
+ export interface BoxAbout {
133
+ /** The line: what the posted card's `about` will show. */
134
+ view: ReactNode
135
+ /** ✕ beside it, in the app's words: "Comment on the whole document instead", "Remove". Absent, no ✕. */
136
+ remove?: { label: string; onRemove: () => void }
137
+ }
138
+
130
139
  export interface CommentBoxProps {
131
140
  /** Who `@` and `!@` offer. */
132
141
  people: readonly MentionPerson[]
@@ -147,6 +156,12 @@ export interface CommentBoxProps {
147
156
  send: (body: JSONContent, files: BoxFile[], under: BoxSentUnder) => Promise<SendAnswer>
148
157
  /** The card and parts in the box while something is written, with the files, ✕ on the card. Absent, there are none. */
149
158
  under?: BoxUnder
159
+ /**
160
+ * What the new comment will be on, in a strip above the box on the inset fill: the `about` the posted card will carry
161
+ * (a `QuotedLine`, the app's words for a block), with ✕ in it, in the app's words, to drop it. Not drawn on an edit or
162
+ * a closed box.
163
+ */
164
+ about?: BoxAbout
150
165
  /**
151
166
  * The app shows a send before the relay answers: the box empties at once,
152
167
  * and a refusal puts the words back. Otherwise the box holds the words, shut,
@@ -460,6 +475,7 @@ function OpenCommentBox({
460
475
  code = 'block',
461
476
  send,
462
477
  under,
478
+ about,
463
479
  showsAtOnce = false,
464
480
  label,
465
481
  placeholder,
@@ -804,6 +820,18 @@ function OpenCommentBox({
804
820
 
805
821
  return (
806
822
  <div ref={root} className={cn('flex flex-col gap-1', className)} onDragOver={upload ? (e) => e.preventDefault() : undefined} onDrop={onDrop}>
823
+ {about && (
824
+ // The whole strip, its ✕ in it, on the inset fill the closed box's line has (Katerina, 3 November: B); 8px above
825
+ // the box with the column's 4px. 36px tall with or without ✕, so the box does not move when an app offers none.
826
+ <Card data-box-about fill="inset" className="mb-1 flex min-h-9 items-center gap-2 py-1 pl-3 pr-1">
827
+ <div className="min-w-0 flex-1">{about.view}</div>
828
+ {about.remove && (
829
+ <IconButton tooltip={about.remove.label} aria-label={about.remove.label} onClick={about.remove.onRemove}>
830
+ <IconX size={16} stroke={1.5} />
831
+ </IconButton>
832
+ )}
833
+ </Card>
834
+ )}
807
835
  <SendBox
808
836
  editor={editor}
809
837
  onSend={go}
@@ -45,6 +45,8 @@ import { ConfirmDialog } from '@estiva-app/ui'
45
45
  )}
46
46
  ```
47
47
 
48
+ - `refused` says why the last confirm was refused (`onConfirm` answered
49
+ `false`): the error line under your words, while the question stays open.
48
50
  - `alternative` is `{ label, sentence, onClick }`. Its button sits under its
49
51
  sentence, after your words, and waits while the confirm runs, as Cancel does.
50
52
  It closes nothing: open what it leads to, and that takes this one's place.
@@ -69,6 +69,12 @@ export const DeleteAComment: Story = {
69
69
  args: { title: 'Delete this comment?', confirmLabel: 'Delete comment', children: 'Its 2 replies stay.' },
70
70
  }
71
71
 
72
+ /** A delete that was refused: the question stays, and the error line under its words says why (`refused`; Leaf's, 3 November). */
73
+ export const DeleteRefused: Story = {
74
+ name: 'Delete refused',
75
+ args: { title: 'Delete this comment?', confirmLabel: 'Delete comment', children: 'Its reply stays.', refused: 'Could not delete it. Try again.' },
76
+ }
77
+
72
78
  /** Before a reply is deleted. The question a `ReplyCard` asks. */
73
79
  export const DeleteAReply: Story = {
74
80
  name: 'Delete a reply',
@@ -11,7 +11,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
11
11
  import { readFileSync } from 'node:fs'
12
12
  import { join } from 'node:path'
13
13
  import { useState } from 'react'
14
- import { act, cleanup, render, screen } from '@testing-library/react'
14
+ import { act, cleanup, render, screen, within } from '@testing-library/react'
15
15
  import userEvent from '@testing-library/user-event'
16
16
  import { ConfirmDialog } from './ConfirmDialog'
17
17
  import { readIndexExports } from './registry/build'
@@ -89,6 +89,17 @@ describe('ConfirmDialog', () => {
89
89
  expect(screen.getByRole('alertdialog')).toBeTruthy()
90
90
  })
91
91
 
92
+ // Leaf's delete question said why in its own line; now the kit's does, as ResolveDialog's field does (3 November).
93
+ it('says why the last action was refused, under its words, in the error line', async () => {
94
+ const { rerender } = render(<Fixture />)
95
+ const dialog = await screen.findByRole('alertdialog')
96
+ expect(within(dialog).queryByRole('alert')).toBeNull()
97
+ rerender(<Fixture refused="The relay refused it." />)
98
+ const line = within(dialog).getByRole('alert')
99
+ expect(line.textContent).toBe('The relay refused it.')
100
+ expect(within(dialog).getByText('This cannot be undone.').compareDocumentPosition(line) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
101
+ })
102
+
92
103
  it('an action that resolves nothing still closes', async () => {
93
104
  const user = userEvent.setup()
94
105
  const onClose = vi.fn()
@@ -1,6 +1,7 @@
1
1
  import { useRef, useState, type ReactNode } from 'react'
2
2
  import { Button, type ButtonAction } from './Button'
3
3
  import { DialogShell } from './DialogShell'
4
+ import { FieldLine } from './Field'
4
5
 
5
6
  /**
6
7
  * A question with two answers — three, with a safer `alternative` — before something a person would want back —
@@ -38,9 +39,14 @@ export interface ConfirmDialogProps {
38
39
  * It closes nothing: what it opens takes this question's place.
39
40
  */
40
41
  alternative?: ConfirmDialogAlternative
42
+ /**
43
+ * Why the last confirm was refused, in plain words: said under the words, in the error line, while the question
44
+ * stays open (`onConfirm` answered `false`), as `ResolveDialog`'s `refused` is said under its field.
45
+ */
46
+ refused?: string
41
47
  }
42
48
 
43
- export function ConfirmDialog({ title, children, confirmLabel, destructive = false, onConfirm, onClose, alternative }: ConfirmDialogProps) {
49
+ export function ConfirmDialog({ title, children, confirmLabel, destructive = false, onConfirm, onClose, alternative, refused }: ConfirmDialogProps) {
44
50
  const [busy, setBusy] = useState(false)
45
51
  // Closed while the action ran (Escape, the ✕): the action that then goes through does not close it a second time.
46
52
  const closed = useRef(false)
@@ -77,6 +83,7 @@ export function ConfirmDialog({ title, children, confirmLabel, destructive = fal
77
83
  {/* The words' look on a box of the dialog's own, not pushed into DialogShell's body (UIG-9). */}
78
84
  <div className="flex flex-col gap-3 text-body-2 text-text-primary">
79
85
  {children}
86
+ {refused && <FieldLine tone="error">{refused}</FieldLine>}
80
87
  {/* Its sentence and its button one block, 8px apart, as Peek's delete question drew them. */}
81
88
  {alternative && (
82
89
  <div className="flex flex-col items-start gap-2">
@@ -61,6 +61,8 @@ import { ConversationCard } from '@estiva-app/ui'
61
61
  - **The words are yours to draw**: text, people named, links, attached cards and quoted blocks, with **RichText** and the link parts. The card gives them their size and colour.
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; the dialog stays.
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
+ - **Deleted** keeps its `about`: what it was on stays above "This comment was deleted.", for the replies under it.
64
66
  - `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`.
65
67
  - A press on the card is `onClick` (its thread opens); a press on a button, a link or anything marked `data-interactive` inside it is not.
66
68
  - The strip shows while the card is pointed at or has focus, and holds while its reactions or its menu are open.
@@ -68,6 +68,12 @@ export const Edited: Story = { render: (args) => <Live {...args} edited="Edited
68
68
  /** Deleted: its replies stay under it. */
69
69
  export const Deleted: Story = { render: (args) => <Live {...args} deleted replies={{ count: 2, faces: [TWO, THREE], last: '11:40 AM' }} /> }
70
70
 
71
+ /** Deleted, on a part of the page: what it was on stays, for its replies (Leaf's, 3 November). */
72
+ export const DeletedOnAPart: Story = {
73
+ name: 'Deleted, on a part',
74
+ render: (args) => <Live {...args} deleted about={<QuotedLine words="the words this comment was on" />} replies={{ count: 2, faces: [TWO, THREE], last: '11:40 AM' }} />,
75
+ }
76
+
71
77
  /** Pictures and files under the words. */
72
78
  export const WithFiles: Story = { name: 'Files', render: (args) => <Live {...args} files={<Files />} /> }
73
79
 
@@ -1,4 +1,5 @@
1
1
  // @vitest-environment jsdom
2
+ import { useState } from 'react'
2
3
  import { afterEach, describe, expect, it, vi } from 'vitest'
3
4
  import { cleanup, fireEvent, render, screen, within } from '@testing-library/react'
4
5
  import userEvent from '@testing-library/user-event'
@@ -140,6 +141,42 @@ describe('ConversationCard', () => {
140
141
  expect(screen.queryByText('Words')).toBeNull()
141
142
  expect(screen.getByText('3 replies')).toBeTruthy()
142
143
  })
144
+
145
+ // Leaf's column kept it, and now every app does (Katerina, 3 November): the replies still talk about that place.
146
+ it('a deleted comment still says what it was on, above "This comment was deleted."', () => {
147
+ render(
148
+ <ConversationCard author={ONE} time="11:08 AM" deleted about={<p>On the paragraph</p>} replies={{ count: 1 }}>
149
+ Words
150
+ </ConversationCard>,
151
+ )
152
+ const place = screen.getByText('On the paragraph')
153
+ expect(place.compareDocumentPosition(screen.getByText('This comment was deleted.')) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy()
154
+ })
155
+
156
+ it('a delete the app refused keeps the question open and says why (Leaf’s, Katerina, 3 November)', async () => {
157
+ const user = userEvent.setup()
158
+ function Refusing() {
159
+ const [refused, setRefused] = useState<string>()
160
+ const refuse = () => {
161
+ setRefused('Could not delete it. Try again.')
162
+ return false
163
+ }
164
+ return (
165
+ <ConversationCard author={ONE} time="11:08 AM" own onDelete={refuse} deleteRefused={refused}>
166
+ Words
167
+ </ConversationCard>
168
+ )
169
+ }
170
+ render(<Refusing />)
171
+ await point(user, 'Words')
172
+ press('More actions')
173
+ await user.click(await screen.findByRole('menuitem', { name: 'Delete' }))
174
+ const question = await screen.findByRole('alertdialog')
175
+ expect(within(question).queryByRole('alert')).toBeNull()
176
+ await user.click(within(question).getByRole('button', { name: 'Delete comment' }))
177
+ expect((await within(question).findByRole('alert')).textContent).toBe('Could not delete it. Try again.')
178
+ expect(screen.getByRole('alertdialog')).toBe(question)
179
+ })
143
180
  })
144
181
 
145
182
  describe('ReplyCard', () => {
@@ -157,6 +194,19 @@ describe('ReplyCard', () => {
157
194
  await user.click(within(await screen.findByRole('alertdialog')).getByRole('button', { name: 'Delete reply' }))
158
195
  expect(onDelete).toHaveBeenCalledOnce()
159
196
  })
197
+
198
+ it('a delete the app refused says why, as a comment’s does', async () => {
199
+ const user = userEvent.setup()
200
+ render(
201
+ <ReplyCard author={ONE} time="11:40 AM" own onDelete={() => false} deleteRefused="Could not delete it. Try again.">
202
+ A reply
203
+ </ReplyCard>,
204
+ )
205
+ await point(user, 'A reply')
206
+ press('More actions')
207
+ await user.click(await screen.findByRole('menuitem', { name: 'Delete' }))
208
+ expect(within(await screen.findByRole('alertdialog')).getByRole('alert').textContent).toBe('Could not delete it. Try again.')
209
+ })
160
210
  })
161
211
 
162
212
  describe('ConversationCard, by the keyboard (Peek’s review, 1 November)', () => {
@@ -70,6 +70,8 @@ export interface ConversationEntryProps {
70
70
  * everyone.", and on a comment how many replies stay. A string is one paragraph; a node is drawn as given.
71
71
  */
72
72
  deleteNote?: ReactNode
73
+ /** Why the last delete was refused, in plain words: said under the question, while it stays open (`onDelete` answered `false`). */
74
+ deleteRefused?: string
73
75
  /** The app's own rows in the ⋯ menu, after Resolve: `MenuItem`s. */
74
76
  menu?: ReactNode
75
77
  /** The app's own rows in the ⋯ menu after Edit, before Delete: Peek's "View details". */
@@ -270,7 +272,7 @@ function useEditing(editing: boolean | undefined, onEditingChange: ((editing: bo
270
272
  * The same card in every app, each in its own colours (the record that makes one conversation). Peek's, moved.
271
273
  */
272
274
  export function ConversationCard(props: ConversationCardProps) {
273
- 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, deleteLabel, moreLabel = 'More actions', className, children } = props
275
+ 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
274
276
  const readOnly = (props.readOnly ?? false) || deleted
275
277
  const inThreadCard = useContext(InThreadCard)
276
278
 
@@ -308,7 +310,6 @@ export function ConversationCard(props: ConversationCardProps) {
308
310
  const repliesRow = replies && replies.count > 0 && (
309
311
  <RepliesRow {...replies} onOpen={replies.onOpen ?? (under ? item?.toggle : undefined)} open={replies.open ?? (under && !!item?.open)} urgent={urgent} />
310
312
  )
311
- const aboutShown = !!about && !deleted
312
313
  return (
313
314
  <>
314
315
  <Card
@@ -349,7 +350,12 @@ export function ConversationCard(props: ConversationCardProps) {
349
350
  ) : (
350
351
  <div data-comment-body className="flex flex-col items-start px-2 pt-2">
351
352
  {deleted ? (
352
- <p className="w-full pb-2 pl-8 pr-2 text-caption italic text-text-muted">This comment was deleted.</p>
353
+ <>
354
+ {/* What it was on stays, where the words start: its replies still talk about that place (Leaf's; Katerina, 3 November: every app). */}
355
+ {!!about && <div className="relative w-full pl-8 pr-2">{about}</div>}
356
+ {/* 4px under it, as the words sit under it on a comment that is there. */}
357
+ <p className={cn('w-full pb-2 pl-8 pr-2 text-caption italic text-text-muted', !!about && 'pt-1')}>This comment was deleted.</p>
358
+ </>
353
359
  ) : (
354
360
  <>
355
361
  <Head
@@ -363,7 +369,7 @@ export function ConversationCard(props: ConversationCardProps) {
363
369
  urgent={urgent}
364
370
  meta={resolved && <ResolvedCheck by={resolved.by} note={resolved.note} at={resolved.at} />}
365
371
  />
366
- {aboutShown && (
372
+ {!!about && (
367
373
  // Under the name, above the words (Katerina, 1 November).
368
374
  <div className="relative w-full pl-8 pr-2 pt-0.5">{about}</div>
369
375
  )}
@@ -438,7 +444,7 @@ export function ConversationCard(props: ConversationCardProps) {
438
444
  )}
439
445
  </Card>
440
446
  {deleting && onDelete && (
441
- <ConfirmDialog title={`Delete this ${noun}?`} confirmLabel={`Delete ${noun}`} destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
447
+ <ConfirmDialog title={`Delete this ${noun}?`} confirmLabel={`Delete ${noun}`} destructive onConfirm={onDelete} onClose={() => setDeleting(false)} refused={deleteRefused}>
442
448
  {deleteNote !== undefined ? (
443
449
  typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote
444
450
  ) : (
@@ -469,7 +475,7 @@ export function ConversationCard(props: ConversationCardProps) {
469
475
  * when it has one. Peek's, moved with the conversation.
470
476
  */
471
477
  export function ReplyCard(props: ReplyCardProps) {
472
- const { id, author, about, files, reactions, reactionRefused, isNew = false, urgent = false, own = false, editor, onDelete, deleteNote, menu, menuAfter, menuLabel, editLabel, deleteLabel, moreLabel = 'More actions', noun = 'reply', className, children } = props
478
+ 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
473
479
  const readOnly = props.readOnly ?? false
474
480
  const [hovered, setHovered] = useState(false)
475
481
  const [menuOpen, setMenuOpen] = useState(false)
@@ -560,7 +566,7 @@ export function ReplyCard(props: ReplyCardProps) {
560
566
  )}
561
567
  </Card>
562
568
  {deleting && onDelete && (
563
- <ConfirmDialog title={`Delete this ${noun}?`} confirmLabel={`Delete ${noun}`} destructive onConfirm={onDelete} onClose={() => setDeleting(false)}>
569
+ <ConfirmDialog title={`Delete this ${noun}?`} confirmLabel={`Delete ${noun}`} destructive onConfirm={onDelete} onClose={() => setDeleting(false)} refused={deleteRefused}>
564
570
  {deleteNote === undefined ? <p>It is deleted for everyone.</p> : typeof deleteNote === 'string' ? <p>{deleteNote}</p> : deleteNote}
565
571
  </ConfirmDialog>
566
572
  )}
@@ -57,12 +57,23 @@ describe('LinkChip', () => {
57
57
  expect(screen.queryByRole('link')).toBeNull()
58
58
  })
59
59
 
60
- it('says “not available” in words, and leads nowhere', () => {
60
+ // Changed on purpose (Katerina, 3 November): the chip says what a row and a card say since 0.102.0, one wording everywhere.
61
+ it('says “You can’t open this issue” in words, as a row and a card do, and leads nowhere', () => {
61
62
  render(<LinkChip link={UNAVAILABLE} />)
62
- expect(screen.getByText('Issue not available')).toBeTruthy()
63
+ expect(screen.getByText("You can't open this issue")).toBeTruthy()
63
64
  expect(screen.queryByRole('link')).toBeNull()
64
65
  })
65
66
 
67
+ it('names where an app-named file lives, as a row does: “You can’t open this file in Peek”', () => {
68
+ render(<LinkChip link={{ state: 'unavailable', kind: 'file', noun: 'Peek', named: true }} />)
69
+ expect(screen.getByText("You can't open this file in Peek")).toBeTruthy()
70
+ })
71
+
72
+ it('a read that failed says “Couldn’t load this issue”, as a row does', () => {
73
+ render(<LinkChip link={{ state: 'unavailable', kind: 'issue', noun: 'Issue', failed: true }} />)
74
+ expect(screen.getByText("Couldn't load this issue")).toBeTruthy()
75
+ })
76
+
66
77
  it('is a label, not a link, for a file with no address to open', () => {
67
78
  const { container } = render(<LinkChip link={{ state: 'ready', linked: { id: 'x', kind: 'file', title: 'Item one', href: '' } }} preview={false} />)
68
79
  expect(container.querySelector('a')).toBeNull()
package/src/LinkChip.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * A link in running text: the icon (or the author's face, for words a person
3
3
  * wrote), the key, the title cut short, the status as its shape. Loading
4
- * keeps the icon, since the kind is known from the address; not available says
4
+ * keeps the icon, since the kind is known from the address; one it can't open says
5
5
  * so in words. Hovering it shows its card; a tap opens it.
6
6
  *
7
7
  * Look C (Katerina, 29 Oct): the key a step lighter than LinkKey's muted grey
@@ -14,7 +14,7 @@ import type { LinkState } from './linked'
14
14
  import { chosenOf } from './linked'
15
15
  import { LinkedIcon, LinkKey, StatusMark } from './LinkParts'
16
16
  import { LinkPreview } from './LinkPreview'
17
- import { WrittenUrl } from './LinkRow'
17
+ import { unavailableWords, WrittenUrl } from './LinkRow'
18
18
  import { SkeletonBar } from './Skeleton'
19
19
 
20
20
  export interface LinkChipProps {
@@ -35,8 +35,9 @@ export function LinkChip({ link, preview = true }: LinkChipProps) {
35
35
  // Written as a URL, it stays that URL (SPEC §13.1); only a `nostr:` reference says why it is not shown.
36
36
  if (link.url) return <WrittenUrl url={link.url} />
37
37
  return (
38
+ // A row's and a card's words, one wording everywhere (Katerina, 3 November).
38
39
  <InlineChip tone="muted" icon={<LinkedIcon kind={link.kind} size={14} tone="inherit" />}>
39
- {link.noun} {link.deleted ? 'deleted' : 'not available'}
40
+ {unavailableWords(link.noun, { named: link.named, deleted: link.deleted, failed: link.failed })}
40
41
  </InlineChip>
41
42
  )
42
43
  }
package/src/LinkRow.tsx CHANGED
@@ -50,10 +50,14 @@ const ROW_CLASSES = 'flex items-center gap-3 p-1.5 pr-3'
50
50
  * access (Miky, 3 November).
51
51
  */
52
52
  export function LinkUnavailable({ kind, noun, named = false, card = false, deleted = false, failed = false }: LinkUnavailableProps) {
53
+ return <UnavailableRow kind={kind} words={unavailableWords(noun, { named, deleted, failed })} card={card} />
54
+ }
55
+
56
+ /** What a link that can't be opened says, row, card and chip alike: "You can't open this issue", "Couldn't load this issue", "Issue deleted". */
57
+ export function unavailableWords(noun: string, { named = false, deleted = false, failed = false }: { named?: boolean; deleted?: boolean; failed?: boolean } = {}): string {
53
58
  // A word ("Issue") reads in the sentence in small letters; an app's name is where the file lives: "file in Peek".
54
59
  const word = named ? `file in ${noun}` : /^[A-Z][a-z]*$/.test(noun) ? noun.toLowerCase() : noun
55
- const words = deleted ? `${named ? `File in ${noun}` : noun} deleted` : failed ? `Couldn't load this ${word}` : `You can't open this ${word}`
56
- return <UnavailableRow kind={kind} words={words} card={card} />
60
+ return deleted ? `${named ? `File in ${noun}` : noun} deleted` : failed ? `Couldn't load this ${word}` : `You can't open this ${word}`
57
61
  }
58
62
 
59
63
  /** The not-available row with the words it is given; `href` makes the words a link (a part that can't be shown opens its whole file). */
@@ -65,6 +65,12 @@ import { MoveDialog } from '@estiva-app/ui'
65
65
  - Pass only the Folders a move can land in: filter `folders` before, by your
66
66
  app's own rules (a Folder 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:
69
+ `label(folder)` gives its words there, or `undefined` to leave it out;
70
+ `checked` ticks it at open. `onMove` then gets `checked`, only when the box
71
+ was shown for the Folder picked.
72
+
73
+ <Canvas of={MoveDialogStories.WithABox} />
68
74
 
69
75
  <Canvas of={MoveDialogStories.FolderUnreadable} />
70
76
 
@@ -120,6 +120,19 @@ export const ListedTwice: Story = {
120
120
  },
121
121
  }
122
122
 
123
+ /** A box only some Folders ask, ticked as it opened: here Steer asks it and Estiva HQ does not. The story picks Steer. */
124
+ export const WithABox: Story = {
125
+ name: 'With a box',
126
+ args: {
127
+ title: 'Folders: navigation for the whole suite',
128
+ from: '',
129
+ places: undefined,
130
+ placesIn: undefined,
131
+ check: { label: (folder: string) => (folder === 'steer' ? 'Label' : undefined), checked: true },
132
+ },
133
+ play: pickSteer,
134
+ }
135
+
123
136
  /** Moving: the button says so, and everything waits for the answer. */
124
137
  export const Moving: Story = {
125
138
  args: { onMove: () => new Promise<boolean>(() => {}) },