@estiva-app/ui 0.99.0 → 0.100.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 (50) hide show
  1. package/README.md +3 -1
  2. package/dist/ConversationCard.d.ts +6 -0
  3. package/dist/ConversationCard.d.ts.map +1 -1
  4. package/dist/ConversationLayout.d.ts +1 -1
  5. package/dist/ConversationLayout.d.ts.map +1 -1
  6. package/dist/ConversationMenu.d.ts +5 -1
  7. package/dist/ConversationMenu.d.ts.map +1 -1
  8. package/dist/Menu.d.ts +11 -3
  9. package/dist/Menu.d.ts.map +1 -1
  10. package/dist/MoveDialog.d.ts +6 -3
  11. package/dist/MoveDialog.d.ts.map +1 -1
  12. package/dist/RepliesRow.d.ts +5 -3
  13. package/dist/RepliesRow.d.ts.map +1 -1
  14. package/dist/Thread.d.ts +1 -1
  15. package/dist/Thread.d.ts.map +1 -1
  16. package/dist/index.js +62 -35
  17. package/dist/index.js.map +2 -2
  18. package/package.json +1 -1
  19. package/registry.json +80 -12
  20. package/src/ConversationCard.mdx +4 -0
  21. package/src/ConversationCard.states.test.tsx +67 -0
  22. package/src/ConversationCard.stories.tsx +16 -0
  23. package/src/ConversationCard.tsx +14 -6
  24. package/src/ConversationLayout.mdx +4 -0
  25. package/src/ConversationLayout.stories.tsx +28 -0
  26. package/src/ConversationLayout.test.tsx +54 -0
  27. package/src/ConversationLayout.tsx +6 -2
  28. package/src/ConversationMenu.mdx +3 -0
  29. package/src/ConversationMenu.stories.tsx +12 -0
  30. package/src/ConversationMenu.test.tsx +17 -0
  31. package/src/ConversationMenu.tsx +7 -3
  32. package/src/Menu.test.tsx +80 -0
  33. package/src/Menu.tsx +35 -14
  34. package/src/MenuItem.mdx +12 -0
  35. package/src/MenuItem.stories.tsx +39 -1
  36. package/src/MoveDialog.mdx +12 -1
  37. package/src/MoveDialog.stories.tsx +13 -0
  38. package/src/MoveDialog.test.tsx +36 -0
  39. package/src/MoveDialog.tsx +6 -3
  40. package/src/RepliesRow.mdx +6 -3
  41. package/src/RepliesRow.stories.tsx +3 -0
  42. package/src/RepliesRow.test.tsx +24 -0
  43. package/src/RepliesRow.tsx +12 -6
  44. package/src/ReplyCard.mdx +5 -0
  45. package/src/ReplyCard.stories.tsx +26 -0
  46. package/src/Thread.mdx +3 -1
  47. package/src/Thread.stories.tsx +39 -0
  48. package/src/Thread.tsx +6 -4
  49. package/src/seenOnScreen.test.tsx +59 -0
  50. package/stories/Choosing.mdx +1 -1
@@ -22,6 +22,10 @@ export interface ConversationMenuProps {
22
22
  after?: ReactNode
23
23
  /** Offered on your own only; the card asks before it deletes. */
24
24
  onDelete?: () => void
25
+ /** Delete's words: "Delete" by default; Ship's "Delete message". */
26
+ deleteLabel?: string
27
+ /** Its own ⋯ button's name and tooltip, with no `trigger`: "More actions" by default; Ship's "Message actions". */
28
+ moreLabel?: string
25
29
  open?: boolean
26
30
  onOpenChange?: (open: boolean) => void
27
31
  /** The button that opens it: a `ToolbarButton` inside `ConversationActions`. Absent: an `IconButton`. */
@@ -34,7 +38,7 @@ export interface ConversationMenuProps {
34
38
  * row to show. Peek's, moved with the conversation; what is Peek's own (its heading, its hint, its words, its rows)
35
39
  * Peek passes in, so its menu reads as it did (Katerina, 1 November).
36
40
  */
37
- export function ConversationMenu({ resolved = false, onResolve, onReopen, resolveHint, children, label, onEdit, editLabel = 'Edit', after, onDelete, open, onOpenChange, trigger }: ConversationMenuProps) {
41
+ export function ConversationMenu({ resolved = false, onResolve, onReopen, resolveHint, children, label, onEdit, editLabel = 'Edit', after, onDelete, deleteLabel = 'Delete', moreLabel = 'More actions', open, onOpenChange, trigger }: ConversationMenuProps) {
38
42
  const resolves = resolved ? onReopen : onResolve
39
43
  const first = (resolves || children) && (
40
44
  <>
@@ -57,7 +61,7 @@ export function ConversationMenu({ resolved = false, onResolve, onReopen, resolv
57
61
  <Menu
58
62
  trigger={
59
63
  trigger ?? (
60
- <IconButton tooltip="More actions" aria-label="More actions">
64
+ <IconButton tooltip={moreLabel} aria-label={moreLabel}>
61
65
  <IconDotsVertical size={16} stroke={1.5} />
62
66
  </IconButton>
63
67
  )
@@ -72,7 +76,7 @@ export function ConversationMenu({ resolved = false, onResolve, onReopen, resolv
72
76
  {first && middle && <MenuSeparator />}
73
77
  {middle}
74
78
  {onDelete && (first || middle) && <MenuSeparator />}
75
- {onDelete && <MenuItem label="Delete" destructive onClick={onDelete} />}
79
+ {onDelete && <MenuItem label={deleteLabel} destructive onClick={onDelete} />}
76
80
  </Menu>
77
81
  )
78
82
  }
package/src/Menu.test.tsx CHANGED
@@ -364,3 +364,83 @@ describe('Menu, padding', () => {
364
364
  expect(classes).not.toContain('p-2')
365
365
  })
366
366
  })
367
+
368
+ describe('MenuItem, shown but shut, saying why (disabledReason; Ship, 2 November)', () => {
369
+ function Shut({ onClick }: { onClick: () => void }) {
370
+ return (
371
+ <Menu trigger={<Button variant="outlined">Trigger</Button>}>
372
+ <MenuItem label="Rename" onClick={() => {}} />
373
+ <MenuItem label="Archive" disabledReason="Archived with its project: unarchive the project." onClick={onClick} />
374
+ </Menu>
375
+ )
376
+ }
377
+
378
+ it('is shown, shut: a press runs nothing and the menu stays open', async () => {
379
+ const user = userEvent.setup()
380
+ const onClick = vi.fn()
381
+ render(<Shut onClick={onClick} />)
382
+ await user.click(screen.getByRole('button', { name: 'Trigger' }))
383
+ const row = await screen.findByRole('menuitem', { name: 'Archive' })
384
+ expect(row.getAttribute('aria-disabled')).toBe('true')
385
+ await user.click(row)
386
+ expect(onClick).not.toHaveBeenCalled()
387
+ expect(screen.getByRole('menu')).toBeTruthy()
388
+ })
389
+
390
+ it('says why under the pointer', async () => {
391
+ const user = userEvent.setup()
392
+ render(<Shut onClick={() => {}} />)
393
+ await user.click(screen.getByRole('button', { name: 'Trigger' }))
394
+ await user.hover(await screen.findByRole('menuitem', { name: 'Archive' }))
395
+ expect((await screen.findByRole('tooltip')).textContent).toBe('Archived with its project: unarchive the project.')
396
+ })
397
+
398
+ it('stays where the arrow keys go, so the keyboard reaches the reason too', async () => {
399
+ const user = userEvent.setup()
400
+ render(<Shut onClick={() => {}} />)
401
+ screen.getByRole('button', { name: 'Trigger' }).focus()
402
+ await user.keyboard('{Enter}')
403
+ await screen.findByRole('menu')
404
+ await user.keyboard('{ArrowDown}')
405
+ await waitFor(() => expect(document.activeElement?.textContent).toBe('Archive'))
406
+ expect((await screen.findByRole('tooltip')).textContent).toBe('Archived with its project: unarchive the project.')
407
+ })
408
+
409
+ it('never takes the fill, under the pointer or the arrow keys (Katerina, 2 November); an open row keeps it', async () => {
410
+ const user = userEvent.setup()
411
+ render(<Shut onClick={() => {}} />)
412
+ await user.click(screen.getByRole('button', { name: 'Trigger' }))
413
+ const fills = (row: HTMLElement) => row.className.split(/\s+/).filter((c) => c.endsWith('bg-bg-hover'))
414
+ const shut = await screen.findByRole('menuitem', { name: 'Archive' })
415
+ expect(fills(shut)).toEqual([])
416
+ expect(fills(screen.getByRole('menuitem', { name: 'Rename' })).length).toBeGreaterThan(0)
417
+ await user.hover(shut)
418
+ expect(fills(shut)).toEqual([])
419
+ })
420
+
421
+ it('on a bare MenuPanel, no fill either', () => {
422
+ render(
423
+ <MenuPanel>
424
+ <MenuItem label="Archive" disabledReason="Archived with its project." onClick={() => {}} />
425
+ </MenuPanel>,
426
+ )
427
+ expect(screen.getByRole('button', { name: 'Archive' }).className.split(/\s+/).filter((c) => c.endsWith('bg-bg-hover'))).toEqual([])
428
+ })
429
+
430
+ it('on a bare MenuPanel too: shut, and a press runs nothing', async () => {
431
+ const user = userEvent.setup()
432
+ const onClick = vi.fn()
433
+ render(
434
+ <MenuPanel>
435
+ <MenuItem label="Archive" disabledReason="Archived with its project." onClick={onClick} />
436
+ </MenuPanel>,
437
+ )
438
+ const row = screen.getByRole('button', { name: 'Archive' })
439
+ expect(row.getAttribute('aria-disabled')).toBe('true')
440
+ await user.hover(row)
441
+ expect((await screen.findByRole('tooltip')).textContent).toBe('Archived with its project.')
442
+ await user.click(row)
443
+ await user.keyboard('{Enter}')
444
+ expect(onClick).not.toHaveBeenCalled()
445
+ })
446
+ })
package/src/Menu.tsx CHANGED
@@ -5,6 +5,7 @@ import { cn } from './cn'
5
5
  import { Divider, DividerInPanel } from './Divider'
6
6
  import { triggerDisabled } from './triggerDisabled'
7
7
  import { ScrollArea } from './ScrollArea'
8
+ import { TooltipTrigger } from './Tooltip'
8
9
  import { Kbd } from './Kbd'
9
10
  import { SectionLabel } from './SectionLabel'
10
11
  import { FLOATING_SURFACE_CLASSES } from './looks'
@@ -384,6 +385,11 @@ export interface MenuItemProps extends Omit<ComponentPropsWithRef<'button'>, 'ch
384
385
  destructive?: boolean
385
386
  /** The row the menu currently points at (a submenu's chosen value). */
386
387
  selected?: boolean
388
+ /**
389
+ * Why it cannot be chosen right now: the row is shown, shut, in the disabled colour, with no fill, and says why under
390
+ * the pointer and when the arrow keys reach it, as `Button`'s does. A press runs nothing and the menu stays open.
391
+ */
392
+ disabledReason?: string
387
393
  }
388
394
 
389
395
  /**
@@ -398,7 +404,7 @@ export interface MenuItemProps extends Omit<ComponentPropsWithRef<'button'>, 'ch
398
404
  * `Select` puts it on Base UI's `Select.Item`, whose parts (`ItemText`,
399
405
  * `ItemIndicator`) have to stay the element's own. One row, two parts. Not
400
406
  * exported from the package's index. */
401
- export function menuItemClassName({ size, selected, className }: { size: 'default' | 'tall'; selected?: boolean; className?: string }) {
407
+ export function menuItemClassName({ size, selected, shut = false, className }: { size: 'default' | 'tall'; selected?: boolean; shut?: boolean; className?: string }) {
402
408
  return cn(
403
409
  // shrink-0: a menu is a flex column that scrolls at its max height,
404
410
  // and a flex child shrinks before its container does — so every row
@@ -414,7 +420,9 @@ export function menuItemClassName({ size, selected, className }: { size: 'defaul
414
420
  // hint flickering in and out. Both are instant now: they still change
415
421
  // on exactly the same :hover, so they cannot come apart, and a row
416
422
  // lights and unlights crisply as the pointer crosses it.
417
- 'group flex w-full shrink-0 cursor-pointer items-center rounded-lg text-left outline-none hover:bg-bg-hover data-[highlighted]:bg-bg-hover',
423
+ 'group flex w-full shrink-0 cursor-pointer items-center rounded-lg text-left outline-none',
424
+ // The fill under the pointer and the arrow keys: never on a shut row (Katerina, 2 November), whose reason shows instead.
425
+ !shut && 'hover:bg-bg-hover data-[highlighted]:bg-bg-hover',
418
426
  // Both sizes are as tall as their content and never shorter than a
419
427
  // floor: 36px for a default row (Katerina, 2026-09-11), 40px for a
420
428
  // tall one (Katerina, 2026-09-01). A single-line action row sits at
@@ -424,6 +432,9 @@ export function menuItemClassName({ size, selected, className }: { size: 'defaul
424
432
  // this 36px and was the only menu in either app out of step.
425
433
  size === 'tall' ? 'min-h-10 gap-3 px-3 py-1.5' : 'min-h-9 gap-2 px-2 py-1.5',
426
434
  selected && 'bg-bg-hover',
435
+ // Shut, with its reason: the arrow, not the hand, and its icon in the disabled colour as its words are, as a
436
+ // disabled IconButton draws its own. No fill under the pointer or the arrow keys: its reason is what shows there.
437
+ shut && 'cursor-default [&_svg]:text-text-disabled',
427
438
  className,
428
439
  )
429
440
  }
@@ -431,7 +442,9 @@ export function menuItemClassName({ size, selected, className }: { size: 'defaul
431
442
  /** Everything inside the row — written once, for the same reason. Shared
432
443
  * inside the package like `menuItemClassName`: `CommandPalette` draws it
433
444
  * inside Base UI's `Autocomplete.Item`. Not exported from the index. */
434
- export function MenuItemBody({ label, children, size = 'default', description, aside, leading, trailing, hint, shortcut, submenu, destructive, selected }: Pick<MenuItemProps, 'label' | 'children' | 'size' | 'description' | 'aside' | 'leading' | 'trailing' | 'hint' | 'shortcut' | 'submenu' | 'destructive' | 'selected'>) {
445
+ export function MenuItemBody({ label, children, size = 'default', description, aside, leading, trailing, hint, shortcut, submenu, destructive, selected, shut = false }: Pick<MenuItemProps, 'label' | 'children' | 'size' | 'description' | 'aside' | 'leading' | 'trailing' | 'hint' | 'shortcut' | 'submenu' | 'destructive' | 'selected'> & { shut?: boolean }) {
446
+ // Shut, its words in the disabled colour, a destructive one's too.
447
+ const labelColour = shut ? 'text-text-disabled' : destructive ? 'text-error-default' : 'text-text-primary'
435
448
  const edge =
436
449
  trailing ??
437
450
  (shortcut ? (
@@ -449,15 +462,15 @@ export function MenuItemBody({ label, children, size = 'default', description, a
449
462
  <span className={cn('flex min-w-0 flex-1 flex-col', size === 'tall' && 'gap-[2px]')}>
450
463
  {aside ? (
451
464
  <span className="flex min-w-0 items-baseline gap-2">
452
- <span className={cn('truncate text-body-2', destructive ? 'text-error-default' : 'text-text-primary')}>{label}</span>
453
- <span className="shrink-0 text-caption text-text-muted">{aside}</span>
465
+ <span className={cn('truncate text-body-2', labelColour)}>{label}</span>
466
+ <span className={cn('shrink-0 text-caption', shut ? 'text-text-disabled' : 'text-text-muted')}>{aside}</span>
454
467
  </span>
455
468
  ) : (
456
- <span className={cn('truncate text-body-2', destructive ? 'text-error-default' : 'text-text-primary')}>
469
+ <span className={cn('truncate text-body-2', labelColour)}>
457
470
  {label}
458
471
  </span>
459
472
  )}
460
- {description && <span className="truncate text-caption text-text-secondary">{description}</span>}
473
+ {description && <span className={cn('truncate text-caption', shut ? 'text-text-disabled' : 'text-text-secondary')}>{description}</span>}
461
474
  </span>
462
475
  )}
463
476
  {(edge || hint) && (
@@ -482,7 +495,8 @@ export function MenuItemBody({ label, children, size = 'default', description, a
482
495
  )
483
496
  }
484
497
 
485
- export function MenuItem({ label, children, size = 'default', description, aside, leading, trailing, hint, shortcut, submenu, destructive, selected, className, ...props }: MenuItemProps) {
498
+ export function MenuItem({ label, children, size = 'default', description, aside, leading, trailing, hint, shortcut, submenu, destructive, selected, disabledReason, className, ...props }: MenuItemProps) {
499
+ const shut = !!disabledReason
486
500
  const body = (
487
501
  <MenuItemBody
488
502
  label={label}
@@ -496,11 +510,14 @@ export function MenuItem({ label, children, size = 'default', description, aside
496
510
  submenu={submenu}
497
511
  destructive={destructive}
498
512
  selected={selected}
513
+ shut={shut}
499
514
  >
500
515
  {children}
501
516
  </MenuItemBody>
502
517
  )
503
- const rowClassName = menuItemClassName({ size, selected, className })
518
+ const rowClassName = menuItemClassName({ size, selected, shut, className })
519
+ // Shut with its reason, the row is the reason's trigger, as Button is.
520
+ const withReason = (row: ReactElement) => (shut ? <TooltipTrigger label={disabledReason ?? ''}>{row}</TooltipTrigger> : row)
504
521
 
505
522
  /*
506
523
  * Inside a `Menu` the row is Base UI's `Menu.Item`: it joins the roving
@@ -521,13 +538,14 @@ export function MenuItem({ label, children, size = 'default', description, aside
521
538
  * than claiming none.
522
539
  */
523
540
  if (!useContext(MenuContext)) {
524
- return (
525
- <button type="button" className={rowClassName} {...props}>
541
+ // Shut: still a button the pointer and Tab reach, for its reason, but a press runs nothing.
542
+ return withReason(
543
+ <button type="button" className={rowClassName} {...props} {...(shut ? { 'aria-disabled': true, onClick: undefined } : {})}>
526
544
  {body}
527
- </button>
545
+ </button>,
528
546
  )
529
547
  }
530
- return (
548
+ return withReason(
531
549
  <BaseMenu.Item
532
550
  nativeButton
533
551
  render={<button type="button" />}
@@ -539,9 +557,12 @@ export function MenuItem({ label, children, size = 'default', description, aside
539
557
  handler facing a div signature. The element underneath is a
540
558
  `<button>`, which `Menu.test.tsx` pins. */
541
559
  {...(props as ComponentPropsWithRef<'div'>)}
560
+ /* Base UI's own disabled: the row stays where the arrow keys go (focusable when disabled), says
561
+ `aria-disabled`, and a press neither runs it nor closes the menu. */
562
+ disabled={props.disabled || shut}
542
563
  >
543
564
  {body}
544
- </BaseMenu.Item>
565
+ </BaseMenu.Item>,
545
566
  )
546
567
  }
547
568
 
package/src/MenuItem.mdx CHANGED
@@ -23,6 +23,17 @@ other two), `destructive` in the error colour, `selected` as the fill.
23
23
 
24
24
  <Canvas of={MenuItemStories.Tall} />
25
25
 
26
+ - **`disabledReason`**: a row shown but shut, saying why, as `Button`'s
27
+ does. Its words and its icon take the disabled colour, and it takes no
28
+ fill under the pointer or the arrow keys; the reason shows there instead,
29
+ on hover and where the arrow keys reach it. A press runs
30
+ nothing, and the menu stays open. For an action the reader should see
31
+ but cannot take right now; one they may never take is not offered.
32
+
33
+ <Canvas of={MenuItemStories.Shut} />
34
+
35
+ <Canvas of={MenuItemStories.ShutInAMenu} />
36
+
26
37
  ## When not
27
38
 
28
39
  - A single action that is not a row in a list → **Button**. Outside a
@@ -62,6 +73,7 @@ It does these by itself. Write none of them around it.
62
73
  | Is a row of its Menu: the Menu highlights it, walks to it with the arrow keys, and closes when it is chosen | a highlight or a key handler on the row | |
63
74
  | Opens its `submenu` with → and closes it with ← | a submenu of your own | |
64
75
  | Keeps its row's height in a scrolling column | `shrink-0` | |
76
+ | Shut with `disabledReason`: says why under the pointer and on the arrow keys, runs nothing, keeps the menu open | a tooltip round a row, a check in `onClick` | |
65
77
 
66
78
  ## Props
67
79
 
@@ -1,5 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
- import { IconCopy, IconHash, IconPin, IconTrash } from '@tabler/icons-react'
2
+ import { IconArchive, IconCopy, IconHash, IconPin, IconTrash } from '@tabler/icons-react'
3
+ import { userEvent, within } from 'storybook/test'
3
4
  import { Avatar } from './Avatar'
4
5
  import { useRef, useState } from 'react'
5
6
  import { Button } from './Button'
@@ -99,6 +100,43 @@ export const Destructive: Story = {
99
100
  args: { label: 'Delete', destructive: true, leading: <IconTrash size={16} stroke={1.5} className="text-error-default" /> },
100
101
  }
101
102
 
103
+ /** Shown but shut, with why: its words and its icon in the disabled colour, no fill, and the reason under the pointer. The story points at it. */
104
+ export const Shut: Story = {
105
+ name: 'Shut, saying why',
106
+ args: {
107
+ label: 'Archive',
108
+ leading: <IconArchive size={16} stroke={1.5} className="text-text-secondary" />,
109
+ disabledReason: 'Shut for now, and this says why, in the app’s words.',
110
+ },
111
+ play: async ({ canvasElement }) => {
112
+ await userEvent.hover(within(canvasElement).getByRole('button', { name: 'Archive' }))
113
+ },
114
+ }
115
+
116
+ /**
117
+ * Shut in a live menu: the arrow keys still reach it, its reason shows there as under the pointer, and a press runs
118
+ * nothing and leaves the menu open. The story opens the menu and points at the shut row.
119
+ */
120
+ export const ShutInAMenu: Story = {
121
+ name: 'Shut, in a menu',
122
+ parameters: { controls: { disable: true } },
123
+ decorators: [(Story) => <Story />],
124
+ render: () => (
125
+ <div className="flex min-h-[220px] w-full items-start justify-center pt-12">
126
+ <Menu trigger={<Button variant="outlined">Open the menu</Button>}>
127
+ <MenuItem label="Rename" onClick={() => {}} />
128
+ <MenuItem label="Archive" leading={<IconArchive size={16} stroke={1.5} className="text-text-secondary" />} disabledReason="Shut for now, and this says why, in the app’s words." onClick={() => {}} />
129
+ <Divider className="my-1" />
130
+ <MenuItem label="Delete" destructive onClick={() => {}} />
131
+ </Menu>
132
+ </div>
133
+ ),
134
+ play: async ({ canvasElement }) => {
135
+ await userEvent.click(within(canvasElement).getByRole('button', { name: 'Open the menu' }))
136
+ await userEvent.hover(await within(canvasElement.ownerDocument.body).findByRole('menuitem', { name: 'Archive' }))
137
+ },
138
+ }
139
+
102
140
  /** Every shape on one canvas. */
103
141
  export const AllVariants: Story = {
104
142
  parameters: { controls: { disable: true } },
@@ -18,6 +18,12 @@ first, then what it goes under, read when the Folder is picked.
18
18
  - A file that may sit at the top of any Folder: `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
22
+ back. Listed in none; or in two after a move that half-worked, where moving
23
+ into either takes it out of the other, so Move again is the retry. Nothing is
24
+ chosen for the person even so; `startIn` opens it on one.
25
+
26
+ <Canvas of={MoveDialogStories.ListedTwice} />
21
27
 
22
28
  <Canvas of={MoveDialogStories.Project} />
23
29
 
@@ -53,7 +59,12 @@ import { MoveDialog } from '@estiva-app/ui'
53
59
  Answer `false` to keep it open once you have said why.
54
60
  - `folders` undefined while they are read: the list says "Reading…".
55
61
  - `heading`, `folderLabel`, `noFolder` and `topLabel` are for your app's words;
56
- `startIn` opens it on another Folder than the one it is in.
62
+ `startIn` opens it on another Folder than the one it is in. An app that
63
+ chooses one for the person holds its `startIn` steady while the dialog is
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
67
+ it is made is answered with `false`, said why, and the dialog stays.
57
68
 
58
69
  <Canvas of={MoveDialogStories.FolderUnreadable} />
59
70
 
@@ -107,6 +107,19 @@ export const AnotherAppsWords: Story = {
107
107
  },
108
108
  }
109
109
 
110
+ /**
111
+ * A file listed in two Folders, after a move that half-worked: `from` is empty, so every Folder is offered, the ones
112
+ * it is in too, since moving into one takes it out of the other; Move again is the retry. Nothing is chosen for the
113
+ * person. The story opens the list.
114
+ */
115
+ export const ListedTwice: Story = {
116
+ name: 'Listed in two Folders',
117
+ args: { title: 'Folders: navigation for the whole suite', from: '', places: undefined, placesIn: undefined },
118
+ play: async ({ canvasElement }) => {
119
+ await userEvent.click(within(canvasElement.ownerDocument.body).getByRole('combobox', { name: 'Folder' }))
120
+ },
121
+ }
122
+
110
123
  /** Moving: the button says so, and everything waits for the answer. */
111
124
  export const Moving: Story = {
112
125
  args: { onMove: () => new Promise<boolean>(() => {}) },
@@ -201,3 +201,39 @@ describe('MoveDialog, the kit’s', () => {
201
201
  expect((screen.getByRole('button', { name: 'Cancel' }) as HTMLButtonElement).disabled).toBe(true)
202
202
  })
203
203
  })
204
+
205
+ describe('MoveDialog, a file not listed in exactly one Folder (`from` empty; Ship’s move, 2 November)', () => {
206
+ const THIRD = { id: 'third', name: 'Third' }
207
+ const flat = { places: undefined, placesIn: undefined, from: '' }
208
+
209
+ it('holds no Folder back: listed in two after a move that half-worked, or in none, every Folder is offered', async () => {
210
+ render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} />)
211
+ expect(await optionsOf('Folder')).toEqual(['Estiva HQ', 'Steer', 'Third'])
212
+ })
213
+
214
+ it('chooses nothing for the person even so: Move waits for a pick, or it opens on startIn', async () => {
215
+ render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} />)
216
+ expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(true)
217
+ cleanup()
218
+ render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} startIn="third" />)
219
+ expect(screen.getByRole('combobox', { name: 'Folder' }).textContent).toContain('Third')
220
+ })
221
+
222
+ it('stays open on a refusal, and Move again is the retry, to the same Folder', async () => {
223
+ const onMove = vi.fn(async () => false)
224
+ render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} onMove={onMove} />)
225
+ await pick('Folder', 'Steer')
226
+ await userEvent.click(screen.getByRole('button', { name: 'Move' }))
227
+ await waitFor(() => expect(onMove).toHaveBeenCalledTimes(1))
228
+ await waitFor(() => expect((screen.getByRole('button', { name: 'Move' }) as HTMLButtonElement).disabled).toBe(false))
229
+ await userEvent.click(screen.getByRole('button', { name: 'Move' }))
230
+ await waitFor(() => expect(onMove).toHaveBeenCalledTimes(2))
231
+ expect(onMove).toHaveBeenLastCalledWith({ folder: 'steer' })
232
+ })
233
+
234
+ it('listed in one again (`from` named), the one it is in is held back once more', async () => {
235
+ const { rerender } = render(<Fixture {...flat} folders={[HQ, STEER, THIRD]} />)
236
+ rerender(<Fixture {...flat} from="hq" folders={[HQ, STEER, THIRD]} />)
237
+ expect(await optionsOf('Folder')).toEqual(['Steer', 'Third'])
238
+ })
239
+ })
@@ -36,15 +36,18 @@ export interface MoveChoice {
36
36
  * chose.
37
37
  *
38
38
  * A file that nests under nothing (no `placesIn`) is asked only for the
39
- * Folder, and the one it is in is not offered. A Folder that could not be
40
- * read says so as the section's empty line does, with its Try again (B8).
39
+ * Folder, and the one it is in is not offered. One that is not in exactly one
40
+ * Folder passes `from` empty, and no Folder is held back: listed in none, or
41
+ * in two after a move that half-worked, where moving into either takes it out
42
+ * of the other and Move again is the retry (Ship's rule). A Folder that could
43
+ * not be read says so as the section's empty line does, with its Try again (B8).
41
44
  */
42
45
  export interface MoveDialogProps {
43
46
  /** The file's name, said above the choice. */
44
47
  title: string
45
48
  /** The sentence under the name, in the app's words: "Everyone who can read it now still can." */
46
49
  description: string
47
- /** The Folder it is in now. */
50
+ /** The Folder it is in now, not offered to a file that nests under nothing. `''` when it is not in exactly one: then no Folder is held back. */
48
51
  from: string
49
52
  /** The Folders it may go to. Undefined while they are still read: the list says "Reading…". */
50
53
  folders: readonly MoveFolder[] | undefined
@@ -5,7 +5,7 @@ import * as Stories from './RepliesRow.stories'
5
5
 
6
6
  # RepliesRow
7
7
 
8
- The way into a thread, under its comment: who replied, "2 replies", the last reply's time, and "1 new" until it is read.
8
+ The way into a thread, under its comment: who replied, "2 replies", the last reply's time, and how many are new ("2 new") until they are read.
9
9
 
10
10
  <Canvas of={Stories.Several} />
11
11
 
@@ -14,7 +14,10 @@ The way into a thread, under its comment: who replied, "2 replies", the last rep
14
14
  - Under a comment with replies: **ConversationCard** draws it from its `replies`.
15
15
  - `onOpen` where the row itself opens the thread (one column, the thread under its comment); without it, the card around it does.
16
16
  - `open` while that thread is open under it: the chevron turns down and the row stays marked, and a press closes it. The whole card around it opens and closes the thread too.
17
+ - `newCount`, how many replies are new: "2 new", and the row's name says it too ("3 replies, 2 new, open the thread"). Given, it decides; 0 says nothing new.
18
+ - `isNew` alone, for an app that knows only that one is new: "1 new", and the row's name stays the count.
17
19
 
20
+ <Canvas of={Stories.NewSeveral} />
18
21
  <Canvas of={Stories.New} />
19
22
  <Canvas of={Stories.Open} />
20
23
 
@@ -28,7 +31,7 @@ The way into a thread, under its comment: who replied, "2 replies", the last rep
28
31
  ```tsx
29
32
  import { RepliesRow } from '@estiva-app/ui'
30
33
 
31
- <RepliesRow count={3} faces={faces} last="12:02 PM" isNew onOpen={() => openUnder(comment)} />
34
+ <RepliesRow count={3} faces={faces} last="12:02 PM" newCount={2} onOpen={() => openUnder(comment)} />
32
35
  ```
33
36
 
34
37
  - Faces and the last time show in Signal; in the other themes the row is the icon and the count.
@@ -38,7 +41,7 @@ import { RepliesRow } from '@estiva-app/ui'
38
41
  | It does | So you never write | Refused when written by hand |
39
42
  |---|---|---|
40
43
  | Says "1 reply" or "2 replies" | the plural | |
41
- | Shows "1 new" until it is read, in the warning colour when urgent | the chip and its colour | |
44
+ | Shows how many are new until they are read ("2 new"; "1 new" for `isNew`), in the warning colour when urgent | the chip and its colour | |
42
45
 
43
46
  ## Props
44
47
 
@@ -23,6 +23,9 @@ export const One: Story = { args: { count: 1, faces: [TWO] } }
23
23
  /** A reply not read yet. */
24
24
  export const New: Story = { args: { isNew: true } }
25
25
 
26
+ /** Several replies not read yet: how many, from `newCount`. */
27
+ export const NewSeveral: Story = { name: 'New, how many', args: { newCount: 2 } }
28
+
26
29
  /** A reply not read yet, in an urgent thread. */
27
30
  export const Urgent: Story = { args: { isNew: true, urgent: true } }
28
31
 
@@ -45,3 +45,27 @@ describe('RepliesRow', () => {
45
45
  expect(container.querySelectorAll('img, [data-avatar], [aria-label="Person two"]').length).toBeGreaterThan(0)
46
46
  })
47
47
  })
48
+
49
+ describe('RepliesRow, how many are new (newCount)', () => {
50
+ it('says how many replies are new, not "1 new" whatever the count (Ship: "3 replies, 2 new")', () => {
51
+ render(<RepliesRow count={3} newCount={2} />)
52
+ expect(screen.getByText('2 new')).toBeTruthy()
53
+ expect(screen.queryByText('1 new')).toBeNull()
54
+ })
55
+
56
+ it('says nothing new when none is, whatever isNew says', () => {
57
+ render(<RepliesRow count={3} newCount={0} isNew />)
58
+ expect(screen.queryByText(/ new$/)).toBeNull()
59
+ })
60
+
61
+ it('says how many are new in the name a press reads, before what the press does', () => {
62
+ render(<RepliesRow count={3} newCount={2} onOpen={() => {}} />)
63
+ expect(screen.getByRole('button', { name: '3 replies, 2 new, open the thread' })).toBeTruthy()
64
+ })
65
+
66
+ it('with isNew alone, says "1 new" and keeps its name as it was (Peek passes no count)', () => {
67
+ render(<RepliesRow count={3} isNew onOpen={() => {}} />)
68
+ expect(screen.getByText('1 new')).toBeTruthy()
69
+ expect(screen.getByRole('button', { name: '3 replies, open the thread' })).toBeTruthy()
70
+ })
71
+ })
@@ -13,6 +13,8 @@ export interface RepliesRowProps {
13
13
  last?: string
14
14
  /** "1 new": a reply you have not read. */
15
15
  isNew?: boolean
16
+ /** How many replies you have not read: "2 new", and the row's name says it too. Given, it decides over `isNew`; 0 is none. */
17
+ newCount?: number
16
18
  /** The "1 new" chip in the warning colour, for an urgent thread. */
17
19
  urgent?: boolean
18
20
  /** Opens the thread. Absent, the row only says how many (the card around it opens the thread). */
@@ -28,13 +30,17 @@ const BOX_CLASSES =
28
30
  'group/replies flex shrink-0 items-center gap-2 rounded-lg border border-transparent px-2 py-1.5 transition-colors hover:border-accent-outline hover:bg-accent-wash'
29
31
 
30
32
  /**
31
- * The way into a thread, under its comment: who replied, "2 replies", the last reply's time, and "1 new" until it is
32
- * read. Peek's, moved with the conversation; in every app the row a thread opens from, the same in every theme
33
+ * The way into a thread, under its comment: who replied, "2 replies", the last reply's time, and how many are new
34
+ * ("2 new") until they are read. Peek's, moved with the conversation; in every app the row a thread opens from, the same in every theme
33
35
  * (Katerina, 31 October), each in its own colours.
34
36
  */
35
- export function RepliesRow({ count, faces, last, isNew = false, urgent = false, onOpen, open = false }: RepliesRowProps) {
37
+ export function RepliesRow({ count, faces, last, isNew = false, newCount, urgent = false, onOpen, open = false }: RepliesRowProps) {
36
38
  const withFaces = !!faces && faces.length > 0
37
39
  const label = `${count} ${count === 1 ? 'reply' : 'replies'}`
40
+ // How many are new: the app's count, or one for `isNew` (all an app without a count can say).
41
+ const fresh = newCount ?? (isNew ? 1 : 0)
42
+ // Its name says how many are new only with the app's count: with `isNew` alone it stays as it was.
43
+ const name = newCount ? `${label}, ${newCount} new` : label
38
44
  const inner = (
39
45
  <>
40
46
  {withFaces && (
@@ -62,10 +68,10 @@ export function RepliesRow({ count, faces, last, isNew = false, urgent = false,
62
68
  />
63
69
  </>
64
70
  )
65
- const chip = isNew && (
71
+ const chip = fresh > 0 && (
66
72
  <>
67
73
  <span className="h-0.5 w-0.5 shrink-0 rounded-full bg-text-muted" />
68
- <Chip type={urgent ? 'warning' : 'brand'} label="1 new" />
74
+ <Chip type={urgent ? 'warning' : 'brand'} label={`${fresh} new`} />
69
75
  </>
70
76
  )
71
77
  if (!onOpen) {
@@ -78,7 +84,7 @@ export function RepliesRow({ count, faces, last, isNew = false, urgent = false,
78
84
  }
79
85
  return (
80
86
  // @estiva-escape(no-raw-element): the row is the thread's way in, Peek's replies row; no kit button takes a face stack, a count, a time and the new chip in one press
81
- <button type="button" className={cn(ROW_CLASSES, 'cursor-pointer text-left')} onClick={onOpen} aria-expanded={open} aria-label={`${label}, ${open ? 'close' : 'open'} the thread`} data-interactive>
87
+ <button type="button" className={cn(ROW_CLASSES, 'cursor-pointer text-left')} onClick={onOpen} aria-expanded={open} aria-label={`${name}, ${open ? 'close' : 'open'} the thread`} data-interactive>
82
88
  <span className={cn(BOX_CLASSES, open && OPEN_CLASSES)}>{inner}</span>
83
89
  {chip}
84
90
  </button>
package/src/ReplyCard.mdx CHANGED
@@ -16,9 +16,14 @@ One reply in a thread: the same pieces as a comment, without replies of its own
16
16
  - `at`, its moment: the time says the exact date and time under the pointer; a time that is a link says it, then "Link to this".
17
17
  - `own` on yours: Edit and Delete in its menu.
18
18
  - `id` on every reply: on the card as `data-reply-id`, what a link to it shows (`showInConversation`) and what **Thread** watches to say it was seen.
19
+ - In the app's own words: `noun`, what the delete question calls it ("Delete this reply?" by default, "Delete this message?" with `message`, its button "Delete message"); `deleteLabel`, the Delete row's words; `moreLabel`, the ⋯ button's name and tooltip ("More actions" by default). With `menuLabel` and `editLabel`, as a comment takes them.
19
20
 
20
21
  <Canvas of={Stories.Yours} />
21
22
 
23
+ <Canvas of={Stories.InAnAppsWords} />
24
+
25
+ <Canvas of={Stories.DeleteInAnAppsWords} />
26
+
22
27
  <Canvas of={Stories.Linked} />
23
28
 
24
29
  ## When not
@@ -82,5 +82,31 @@ export const LinkedExactTime: Story = {
82
82
  },
83
83
  }
84
84
 
85
+ /** Points at the reply and opens its ⋯ by the name it is given. */
86
+ async function openMenu(canvasElement: HTMLElement, name: string) {
87
+ await userEvent.hover(within(canvasElement).getByText(SHORT))
88
+ await userEvent.click(within(canvasElement).getByRole('button', { name }))
89
+ }
90
+
91
+ /**
92
+ * Yours, in an app's own words: the ⋯ named "Message actions", its Delete row "Delete message", and the question
93
+ * asking about a message. The story points at it and opens the menu.
94
+ */
95
+ export const InAnAppsWords: Story = {
96
+ name: "In an app's words",
97
+ render: (args) => <Live {...args} author={YOU} own noun="message" deleteLabel="Delete message" moreLabel="Message actions" />,
98
+ play: async ({ canvasElement }) => openMenu(canvasElement, 'Message actions'),
99
+ }
100
+
101
+ /** The delete question in the app's noun: "Delete this message?", answered by "Delete message". The story asks it. */
102
+ export const DeleteInAnAppsWords: Story = {
103
+ name: "In an app's words, deleting",
104
+ render: (args) => <Live {...args} author={YOU} own noun="message" deleteLabel="Delete message" moreLabel="Message actions" />,
105
+ play: async ({ canvasElement }) => {
106
+ await openMenu(canvasElement, 'Message actions')
107
+ await userEvent.click(await within(canvasElement.ownerDocument.body).findByRole('menuitem', { name: 'Delete message' }))
108
+ },
109
+ }
110
+
85
111
  /** Nothing can be changed: no strip, reactions only shown. */
86
112
  export const ReadOnly: Story = { name: 'Read-only', render: (args) => <Live {...args} readOnly start={SOME} /> }
package/src/Thread.mdx CHANGED
@@ -22,10 +22,12 @@ A comment's replies, with the box to write one: in the right column under its ow
22
22
 
23
23
  <Canvas of={Stories.Shown} />
24
24
 
25
- - `seen`: its replies are watched, and a new one keeps its look until it has been seen.
25
+ - `seen`: its replies are watched, beside or under its comment, and a new one keeps its look until it has been seen.
26
26
 
27
27
  <Canvas of={Stories.Seen} />
28
28
 
29
+ <Canvas of={Stories.UnderSeen} />
30
+
29
31
  <Canvas of={Stories.Under} />
30
32
 
31
33
  ## When not