@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
@@ -8,7 +8,7 @@
8
8
  import { afterEach, describe, expect, it, vi } from 'vitest'
9
9
  import { cleanup, render, screen, waitFor } from '@testing-library/react'
10
10
  import userEvent from '@testing-library/user-event'
11
- import { MoveDialog, type MoveDialogProps, type MovePlace } from './MoveDialog'
11
+ import { MoveDialog, type MoveChoice, type MoveDialogProps, type MovePlace } from './MoveDialog'
12
12
 
13
13
  afterEach(cleanup)
14
14
 
@@ -231,6 +231,45 @@ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Shi
231
231
  expect(onMove).toHaveBeenLastCalledWith({ folder: 'steer' })
232
232
  })
233
233
 
234
+ it('asks the box only for the Folders that name it, ticked as it opened, and says what it answered', async () => {
235
+ const onMove = vi.fn(async () => true)
236
+ const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
237
+ render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} check={check} onMove={onMove} />)
238
+ await pick('Folder', 'Third')
239
+ expect(screen.queryByRole('checkbox')).toBeNull()
240
+ await pick('Folder', 'Steer')
241
+ const box = screen.getByRole('checkbox', { name: 'Keep it a space in Steer' })
242
+ expect(box.getAttribute('aria-checked')).toBe('true')
243
+ await userEvent.click(box)
244
+ await userEvent.click(screen.getByRole('button', { name: 'Move' }))
245
+ await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer', checked: false }))
246
+ })
247
+
248
+ it('a Folder that does not ask the box moves with no answer for it, even after another Folder showed it ticked', async () => {
249
+ const onMove = vi.fn(async (_choice: MoveChoice) => true)
250
+ const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
251
+ render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} check={check} onMove={onMove} />)
252
+ await pick('Folder', 'Steer')
253
+ expect(screen.getByRole('checkbox', { name: 'Keep it a space in Steer' }).getAttribute('aria-checked')).toBe('true')
254
+ await pick('Folder', 'Third')
255
+ expect(screen.queryByRole('checkbox')).toBeNull()
256
+ await userEvent.click(screen.getByRole('button', { name: 'Move' }))
257
+ await waitFor(() => expect(onMove).toHaveBeenCalledTimes(1))
258
+ expect(onMove.mock.calls[0][0]).toEqual({ folder: 'third' })
259
+ expect(onMove.mock.calls[0][0]).not.toHaveProperty('checked')
260
+ })
261
+
262
+ it('a file that nests sends the box’s answer with the place it goes under', async () => {
263
+ const onMove = vi.fn(async () => true)
264
+ const check = { label: (folder: string) => (folder === 'steer' ? 'Keep it a space in Steer' : undefined), checked: true }
265
+ render(<Fixture startAtTop placesIn={vi.fn(async () => [TOP])} check={check} onMove={onMove} />)
266
+ await pick('Folder', 'Steer')
267
+ expect(screen.getByRole('checkbox', { name: 'Keep it a space in Steer' }).getAttribute('aria-checked')).toBe('true')
268
+ await waitFor(() => expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(false))
269
+ await userEvent.click(screen.getByRole('button', { name: 'Move' }))
270
+ await waitFor(() => expect(onMove).toHaveBeenCalledWith({ folder: 'steer', parent: '', checked: true }))
271
+ })
272
+
234
273
  it('listed in one again (`from` named), the one it is in is held back once more', async () => {
235
274
  const { rerender } = render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} />)
236
275
  rerender(<Fixture {...flat} from="hq" folders={[HQ, STEER, THIRD]} />)
@@ -1,4 +1,5 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
+ import { Checkbox } from './Checkbox'
2
3
  import { EmptyState } from './EmptyState'
3
4
  import { Field } from './Field'
4
5
  import { FormDialog } from './FormDialog'
@@ -24,6 +25,16 @@ export interface MovePlace {
24
25
  export interface MoveChoice {
25
26
  folder: string
26
27
  parent?: string
28
+ /** Whether `check`'s box was ticked; only when it was shown for the Folder picked. */
29
+ checked?: boolean
30
+ }
31
+
32
+ /** A box under the choice that only some Folders offer, such as "Keep it a space in <team>" where the person may mark one. */
33
+ export interface MoveCheck {
34
+ /** The box's words for a Folder, or `undefined` to leave it out there. */
35
+ label: (folder: string) => string | undefined
36
+ /** Ticked when the dialog opens. */
37
+ checked: boolean
27
38
  }
28
39
 
29
40
  /**
@@ -67,6 +78,8 @@ export interface MoveDialogProps {
67
78
  folderLabel?: string
68
79
  /** Said when no Folder is offered. "There is no other folder it can be moved to." when absent. */
69
80
  noFolder?: string
81
+ /** A box under the choice, asked only where `label` names it; its answer comes back as `checked`. */
82
+ check?: MoveCheck
70
83
  /** Answer `false` to keep the dialog open (you have said why); anything else closes it. */
71
84
  onMove: (choice: MoveChoice) => Promise<boolean | void> | boolean | void
72
85
  onClose: () => void
@@ -85,9 +98,11 @@ export function MoveDialog({
85
98
  heading = 'Move',
86
99
  folderLabel = 'Folder',
87
100
  noFolder = 'There is no other folder it can be moved to.',
101
+ check,
88
102
  onMove,
89
103
  onClose,
90
104
  }: MoveDialogProps) {
105
+ const [ticked, setTicked] = useState(check?.checked ?? false)
91
106
  const nests = !!placesIn
92
107
  // Moving a file that nests under nothing into the Folder it is in would do nothing, so that one is not offered.
93
108
  const destinations = folders && (nests ? folders : folders.filter((folder) => folder.id !== from))
@@ -130,6 +145,8 @@ export function MoveDialog({
130
145
  const valueOf = (place: MovePlace) => place.id || TOP
131
146
  const parent = picked ?? (startAtTop && targets[0] && !targets[0].id ? TOP : undefined)
132
147
  const ready = !!folder && (!nests || !!parent)
148
+ const checkLabel = folder ? check?.label(folder) : undefined
149
+ const asked = checkLabel === undefined ? {} : { checked: ticked }
133
150
 
134
151
  return (
135
152
  <FormDialog
@@ -137,7 +154,7 @@ export function MoveDialog({
137
154
  submitLabel="Move"
138
155
  busyLabel="Moving…"
139
156
  ready={ready}
140
- onSubmit={() => onMove(nests ? { folder, parent: parent === TOP ? '' : parent } : { folder })}
157
+ onSubmit={() => onMove({ ...(nests ? { folder, parent: parent === TOP ? '' : parent } : { folder }), ...asked })}
141
158
  onClose={onClose}
142
159
  >
143
160
  {destinations?.length === 0 ? (
@@ -179,6 +196,7 @@ export function MoveDialog({
179
196
  />
180
197
  </Field>
181
198
  ))}
199
+ {checkLabel !== undefined && <Checkbox checked={ticked} onChange={setTicked} label={checkLabel} />}
182
200
  </>
183
201
  )}
184
202
  </FormDialog>
@@ -36,7 +36,7 @@ const GROUPS: NavTreeGroup[] = [
36
36
  { id: 'f', label: 'An item with a hint and a count', href: '#', icon: placeholder, hint, count: 12, countLabel: '12 open' },
37
37
  ],
38
38
  },
39
- { id: 'g3', title: 'Group three', nodes: [{ id: 'g', label: 'Item six', href: '#', icon: placeholder }] },
39
+ { id: 'g3', title: 'A group whose name runs longer than the column, cut short', nodes: [{ id: 'g', label: 'Item six', href: '#', icon: placeholder }] },
40
40
  ]
41
41
 
42
42
  const meta = {
@@ -12,6 +12,7 @@ On a comment on a part of the page: the words it is on, in the page's own highli
12
12
  ## When
13
13
 
14
14
  - On a **ConversationCard** about a part of the page, in its `about`.
15
+ - Above a **CommentBox** whose new comment will be on that part, in its `about`: the same line the posted card will carry.
15
16
 
16
17
  <Canvas of={Stories.Reworded} />
17
18
 
@@ -32,7 +33,7 @@ import { ConversationCard, QuotedLine } from '@estiva-app/ui'
32
33
  ```
33
34
 
34
35
  - Two lines at most; the whole words are in the tooltip.
35
- - A part with no words, a picture or a block: `label`, its name in your words.
36
+ - A part with no words, a picture or a block: `label`, its name in your words, on the grey: the yellow is only for words still in the page.
36
37
  - Made for the card's `about`: the card puts it under the name, where the words start.
37
38
 
38
39
  ## What it owns
@@ -31,4 +31,13 @@ describe('QuotedLine', () => {
31
31
  expect(screen.getByText('Picture: plan-sketch.png')).toBeTruthy()
32
32
  expect(container.querySelector('[data-quoted="part"]')).not.toBeNull()
33
33
  })
34
+
35
+ // Yellow means "these words are in the page"; a block's name is not (Katerina, 3 November: grey, not yellow).
36
+ it('draws a part’s name on the grey, never the page’s yellow', () => {
37
+ render(<QuotedLine label="On the paragraph" />)
38
+ const mark = screen.getByText('On the paragraph')
39
+ expect(mark.className).not.toMatch(/\bbg-warning-muted\b/)
40
+ expect(mark.className).toMatch(/\bbg-bg-inset\b/)
41
+ expect(mark.className).not.toMatch(/\bline-through\b/)
42
+ })
34
43
  })
@@ -16,15 +16,17 @@ const SINCE = { reworded: 'Changed since', gone: 'Deleted from the page' } as co
16
16
  * What a comment on a part of the page is on: its words, two lines at most, in the page's own highlight, so the two
17
17
  * read as one. ConversationCard puts it under the name, above the comment's words ("above the message, not above the
18
18
  * person": Katerina, 1 November). Words changed since or deleted lose the highlight and say so; a part with no words
19
- * gives its name.
19
+ * gives its name, on the grey: it is not words of the page.
20
20
  */
21
21
  export function QuotedLine({ words, state = 'here', label }: QuotedLineProps) {
22
22
  const shown = words ?? label ?? ''
23
+ // The page's yellow only for words still in it; a part's name is not words of the page, so it takes the grey (Katerina, 3 November).
24
+ const inThePage = !!words && state === 'here'
23
25
  return (
24
26
  <div data-quoted={words ? state : 'part'} className="flex w-full min-w-0 flex-col gap-0.5">
25
27
  <WithTooltip label={shown} wrapperClassName="flex min-w-0">
26
28
  <p className="line-clamp-2 text-caption text-text-secondary">
27
- <mark className={cn('rounded-sm px-0.5 text-text-primary [box-decoration-break:clone]', state === 'here' ? 'bg-warning-muted' : 'bg-bg-inset text-text-secondary', state === 'gone' && 'line-through')}>{shown}</mark>
29
+ <mark className={cn('rounded-sm px-0.5 text-text-primary [box-decoration-break:clone]', inThePage ? 'bg-warning-muted' : 'bg-bg-inset text-text-secondary', state === 'gone' && 'line-through')}>{shown}</mark>
28
30
  </p>
29
31
  </WithTooltip>
30
32
  {state !== 'here' && <span className="text-caption italic text-text-muted">{SINCE[state]}</span>}
@@ -93,6 +93,7 @@ It does these by itself. Write none of them around it.
93
93
  | With `chevron`, its title is a button that calls `onToggle` on a click, Enter or Space, and says whether it is open | a button of your own, or `aria-expanded` | |
94
94
  | Shows its actions while the keyboard is in the row — on the title or on one of them — and always on a screen with no hover | a focus style of your own | |
95
95
  | Keeps its 32px in a scrolling column | `shrink-0` | |
96
+ | Keeps a long title on one line, cut short with "…", in every look | `truncate` around the title | |
96
97
 
97
98
  ## Keys
98
99
 
@@ -49,6 +49,13 @@ describe('SectionHeader', () => {
49
49
  expect(screen.queryByRole('button')).toBeNull()
50
50
  expect(screen.getByText('Section')).not.toBeNull()
51
51
  })
52
+
53
+ // A Folder named by its id ran onto two lines in the sidebar (Katerina, 3 November). Chrome draws the cut (the NavTree story).
54
+ it.each(['heading', 'quiet', 'row'] as const)('a long title stays on one line, cut short, in the %s look', (look) => {
55
+ const name = '0f3c9a12-5b7e-4d21-9c8a-6e2f1b4d7a90'
56
+ render(<SectionHeader title={name} chevron look={look} />)
57
+ expect(screen.getByText(name).className.split(' ')).toEqual(expect.arrayContaining(['min-w-0', 'truncate']))
58
+ })
52
59
  })
53
60
 
54
61
  /**
@@ -189,7 +189,10 @@ export function SectionHeader({ title, chevron = false, icon, isExpanded = true,
189
189
  // A row's words: NavItem's size and colour, brightening under the pointer with the row.
190
190
  <span className="min-w-0 flex-1 truncate text-body-2">{title}</span>
191
191
  ) : (
192
- <SectionLabel folds={chevron}>{title}</SectionLabel>
192
+ // One line, as the other looks and a NavItem's label: a Folder named by its id ran onto two (Katerina, 3 November).
193
+ <SectionLabel folds={chevron} truncate>
194
+ {title}
195
+ </SectionLabel>
193
196
  )}
194
197
  {/* 8px after the title with the 4px gap, in a row's count style. */}
195
198
  {count != null && <span className={cn('ml-1 shrink-0', COUNT_TEXT_CLASSES)}>{count}</span>}
package/src/editor.ts CHANGED
@@ -18,6 +18,7 @@ export {
18
18
  type CommentBoxEdit,
19
19
  type BoxFile,
20
20
  type BoxFileState,
21
+ type BoxAbout,
21
22
  type BoxUnder,
22
23
  type BoxUnderRead,
23
24
  type BoxSentUnder,
package/src/index.ts CHANGED
@@ -15,7 +15,7 @@ export { AttachmentCard, type AttachmentCardProps, type AttachmentCardState } fr
15
15
  export { Avatar, hueFor, initialsFor, type AvatarProps } from './Avatar'
16
16
  export { AvatarGroup, type AvatarGroupMember, type AvatarGroupProps } from './AvatarGroup'
17
17
  export { MembersPill, type MembersPillProps } from './MembersPill'
18
- export { MoveDialog, type MoveChoice, type MoveDialogProps, type MoveFolder, type MovePlace } from './MoveDialog'
18
+ export { MoveDialog, type MoveCheck, type MoveChoice, type MoveDialogProps, type MoveFolder, type MovePlace } from './MoveDialog'
19
19
  export { MembersDialog, type MembersDialogCandidate, type MembersDialogMember, type MembersDialogProps, type MembersDialogSelfAction } from './MembersDialog'
20
20
  export { Banner, type BannerProps, type BannerTone } from './Banner'
21
21
  export { BlockHandle, blockAtY, type BlockHandleProps, type BlockHandleEditing, type HandleBlock } from './BlockHandle'