@estiva-app/ui 0.95.0 → 0.97.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 (205) hide show
  1. package/dist/AppShell.d.ts +25 -7
  2. package/dist/AppShell.d.ts.map +1 -1
  3. package/dist/ArchivedNotice.d.ts +28 -0
  4. package/dist/ArchivedNotice.d.ts.map +1 -0
  5. package/dist/Avatar.d.ts +6 -1
  6. package/dist/Avatar.d.ts.map +1 -1
  7. package/dist/AvatarGroup.d.ts +2 -0
  8. package/dist/AvatarGroup.d.ts.map +1 -1
  9. package/dist/Button.d.ts +4 -3
  10. package/dist/Button.d.ts.map +1 -1
  11. package/dist/Card.d.ts.map +1 -1
  12. package/dist/CommentBox.d.ts.map +1 -1
  13. package/dist/ComposerTriggers.d.ts +2 -0
  14. package/dist/ComposerTriggers.d.ts.map +1 -1
  15. package/dist/ConversationActions.d.ts +24 -0
  16. package/dist/ConversationActions.d.ts.map +1 -0
  17. package/dist/ConversationCard.d.ts +90 -0
  18. package/dist/ConversationCard.d.ts.map +1 -0
  19. package/dist/ConversationLayout.d.ts +50 -0
  20. package/dist/ConversationLayout.d.ts.map +1 -0
  21. package/dist/ConversationMenu.d.ts +24 -0
  22. package/dist/ConversationMenu.d.ts.map +1 -0
  23. package/dist/Divider.d.ts +23 -4
  24. package/dist/Divider.d.ts.map +1 -1
  25. package/dist/EditedMarker.d.ts +11 -0
  26. package/dist/EditedMarker.d.ts.map +1 -0
  27. package/dist/IconButton.d.ts +3 -3
  28. package/dist/IconButton.d.ts.map +1 -1
  29. package/dist/LinkParts.d.ts +4 -1
  30. package/dist/LinkParts.d.ts.map +1 -1
  31. package/dist/ListColumn.d.ts +3 -1
  32. package/dist/ListColumn.d.ts.map +1 -1
  33. package/dist/MembersDialog.d.ts +4 -0
  34. package/dist/MembersDialog.d.ts.map +1 -1
  35. package/dist/MetaText.d.ts +22 -0
  36. package/dist/MetaText.d.ts.map +1 -0
  37. package/dist/NavItem.d.ts.map +1 -1
  38. package/dist/PageHeader.d.ts +50 -0
  39. package/dist/PageHeader.d.ts.map +1 -0
  40. package/dist/Panel.d.ts +6 -0
  41. package/dist/Panel.d.ts.map +1 -1
  42. package/dist/Person.d.ts +3 -1
  43. package/dist/Person.d.ts.map +1 -1
  44. package/dist/PersonTrigger.d.ts +1 -1
  45. package/dist/PersonTrigger.d.ts.map +1 -1
  46. package/dist/PinnedComment.d.ts +17 -0
  47. package/dist/PinnedComment.d.ts.map +1 -0
  48. package/dist/QuotedLine.d.ts +16 -0
  49. package/dist/QuotedLine.d.ts.map +1 -0
  50. package/dist/ReactionHorizon.d.ts +14 -0
  51. package/dist/ReactionHorizon.d.ts.map +1 -0
  52. package/dist/RepliesRow.d.ts +27 -0
  53. package/dist/RepliesRow.d.ts.map +1 -0
  54. package/dist/ResolveDialog.d.ts +13 -0
  55. package/dist/ResolveDialog.d.ts.map +1 -0
  56. package/dist/Select.d.ts +1 -1
  57. package/dist/Select.d.ts.map +1 -1
  58. package/dist/Skeleton.d.ts +8 -4
  59. package/dist/Skeleton.d.ts.map +1 -1
  60. package/dist/Thread.d.ts +38 -0
  61. package/dist/Thread.d.ts.map +1 -0
  62. package/dist/TopBar.d.ts +3 -2
  63. package/dist/TopBar.d.ts.map +1 -1
  64. package/dist/UrgentMark.d.ts +6 -0
  65. package/dist/UrgentMark.d.ts.map +1 -0
  66. package/dist/commentBoxFrame.d.ts +3 -1
  67. package/dist/commentBoxFrame.d.ts.map +1 -1
  68. package/dist/conversation.examples.d.ts +52 -0
  69. package/dist/conversation.examples.d.ts.map +1 -0
  70. package/dist/editor.js +33 -25
  71. package/dist/editor.js.map +2 -2
  72. package/dist/eslint/index.js +2 -1
  73. package/dist/eslint/index.js.map +2 -2
  74. package/dist/eslint/no-native-title.d.ts +1 -1
  75. package/dist/eslint/no-native-title.d.ts.map +1 -1
  76. package/dist/eslint/no-restyled-part.d.ts.map +1 -1
  77. package/dist/index.d.ts +18 -2
  78. package/dist/index.d.ts.map +1 -1
  79. package/dist/index.js +1412 -448
  80. package/dist/index.js.map +4 -4
  81. package/dist/linked.d.ts +4 -0
  82. package/dist/linked.d.ts.map +1 -1
  83. package/dist/linkedFrom.d.ts +2 -0
  84. package/dist/linkedFrom.d.ts.map +1 -1
  85. package/dist/looks.d.ts +13 -1
  86. package/dist/looks.d.ts.map +1 -1
  87. package/dist/threadCard.d.ts +46 -0
  88. package/dist/threadCard.d.ts.map +1 -0
  89. package/package.json +1 -1
  90. package/registry.json +1889 -544
  91. package/src/AppShell.mdx +24 -10
  92. package/src/AppShell.stories.tsx +65 -31
  93. package/src/AppShell.test.tsx +92 -10
  94. package/src/AppShell.tsx +108 -18
  95. package/src/ArchivedNotice.mdx +46 -0
  96. package/src/ArchivedNotice.stories.tsx +52 -0
  97. package/src/ArchivedNotice.test.tsx +42 -0
  98. package/src/ArchivedNotice.tsx +71 -0
  99. package/src/Avatar.agent.test.tsx +63 -0
  100. package/src/Avatar.mdx +25 -0
  101. package/src/Avatar.stories.tsx +13 -0
  102. package/src/Avatar.tsx +51 -3
  103. package/src/AvatarGroup.tsx +3 -1
  104. package/src/Button.mdx +2 -2
  105. package/src/Button.tsx +8 -6
  106. package/src/Card.test.tsx +4 -4
  107. package/src/Card.tsx +6 -2
  108. package/src/CommentBox.test.tsx +2 -1
  109. package/src/CommentBox.tsx +14 -7
  110. package/src/ComposerTriggers.stories.tsx +2 -0
  111. package/src/ComposerTriggers.tsx +3 -1
  112. package/src/ConfirmDialog.stories.tsx +12 -0
  113. package/src/ConversationActions.mdx +47 -0
  114. package/src/ConversationActions.stories.tsx +39 -0
  115. package/src/ConversationActions.tsx +96 -0
  116. package/src/ConversationCard.mdx +72 -0
  117. package/src/ConversationCard.states.test.tsx +330 -0
  118. package/src/ConversationCard.stories.tsx +135 -0
  119. package/src/ConversationCard.test.tsx +159 -0
  120. package/src/ConversationCard.tsx +524 -0
  121. package/src/ConversationLayout.mdx +61 -0
  122. package/src/ConversationLayout.stories.tsx +161 -0
  123. package/src/ConversationLayout.test.tsx +240 -0
  124. package/src/ConversationLayout.tsx +233 -0
  125. package/src/ConversationMenu.mdx +47 -0
  126. package/src/ConversationMenu.stories.tsx +42 -0
  127. package/src/ConversationMenu.test.tsx +47 -0
  128. package/src/ConversationMenu.tsx +57 -0
  129. package/src/Divider.mdx +36 -1
  130. package/src/Divider.stories.tsx +57 -0
  131. package/src/Divider.test.tsx +24 -1
  132. package/src/Divider.tsx +49 -9
  133. package/src/EditedMarker.mdx +36 -0
  134. package/src/EditedMarker.stories.tsx +24 -0
  135. package/src/EditedMarker.tsx +20 -0
  136. package/src/IconButton.mdx +2 -1
  137. package/src/IconButton.tsx +8 -5
  138. package/src/LinkCard.tsx +3 -3
  139. package/src/LinkChip.tsx +1 -1
  140. package/src/LinkParts.mdx +4 -0
  141. package/src/LinkParts.stories.tsx +10 -0
  142. package/src/LinkParts.tsx +9 -5
  143. package/src/LinkRow.tsx +1 -1
  144. package/src/ListColumn.tsx +9 -3
  145. package/src/MembersDialog.stories.tsx +11 -0
  146. package/src/MembersDialog.tsx +7 -3
  147. package/src/MetaText.mdx +41 -0
  148. package/src/MetaText.stories.tsx +29 -0
  149. package/src/MetaText.tsx +38 -0
  150. package/src/NavItem.tsx +2 -11
  151. package/src/PageHeader.mdx +123 -0
  152. package/src/PageHeader.stories.tsx +174 -0
  153. package/src/PageHeader.test.tsx +99 -0
  154. package/src/PageHeader.tsx +105 -0
  155. package/src/Panel.mdx +12 -0
  156. package/src/Panel.stories.tsx +47 -5
  157. package/src/Panel.test.tsx +40 -0
  158. package/src/Panel.tsx +8 -2
  159. package/src/Person.tsx +4 -2
  160. package/src/PersonTrigger.tsx +3 -3
  161. package/src/PinnedComment.mdx +40 -0
  162. package/src/PinnedComment.stories.tsx +21 -0
  163. package/src/PinnedComment.tsx +40 -0
  164. package/src/QuotedLine.mdx +44 -0
  165. package/src/QuotedLine.stories.tsx +30 -0
  166. package/src/QuotedLine.test.tsx +34 -0
  167. package/src/QuotedLine.tsx +33 -0
  168. package/src/ReactionHorizon.mdx +36 -0
  169. package/src/ReactionHorizon.stories.tsx +27 -0
  170. package/src/ReactionHorizon.tsx +27 -0
  171. package/src/RepliesRow.mdx +45 -0
  172. package/src/RepliesRow.stories.tsx +33 -0
  173. package/src/RepliesRow.test.tsx +47 -0
  174. package/src/RepliesRow.tsx +86 -0
  175. package/src/ReplyCard.mdx +50 -0
  176. package/src/ReplyCard.stories.tsx +68 -0
  177. package/src/ResolveDialog.mdx +44 -0
  178. package/src/ResolveDialog.stories.tsx +23 -0
  179. package/src/ResolveDialog.test.tsx +53 -0
  180. package/src/ResolveDialog.tsx +58 -0
  181. package/src/Select.tsx +12 -2
  182. package/src/Skeleton.stories.tsx +4 -1
  183. package/src/Skeleton.tsx +33 -4
  184. package/src/Thread.mdx +53 -0
  185. package/src/Thread.stories.tsx +167 -0
  186. package/src/Thread.test.tsx +83 -0
  187. package/src/Thread.tsx +113 -0
  188. package/src/TopBar.mdx +8 -6
  189. package/src/TopBar.stories.tsx +4 -3
  190. package/src/TopBar.tsx +8 -3
  191. package/src/UrgentMark.mdx +37 -0
  192. package/src/UrgentMark.stories.tsx +27 -0
  193. package/src/UrgentMark.tsx +15 -0
  194. package/src/commentBoxFrame.tsx +8 -4
  195. package/src/conversation.examples.tsx +135 -0
  196. package/src/eslint/no-native-title.ts +1 -1
  197. package/src/eslint/no-restyled-part.ts +1 -0
  198. package/src/index.ts +19 -2
  199. package/src/linked.ts +4 -0
  200. package/src/linkedFrom.ts +5 -3
  201. package/src/looks.ts +18 -2
  202. package/src/registry/registry.test.ts +9 -7
  203. package/src/threadCard.ts +84 -0
  204. package/stories/Choosing.mdx +21 -1
  205. package/tokens.css +14 -10
@@ -0,0 +1,33 @@
1
+ import { cn } from './cn'
2
+ import { WithTooltip } from './Tooltip'
3
+
4
+ export interface QuotedLineProps {
5
+ /** The words the comment is on, as they were quoted. */
6
+ words?: string
7
+ /** `here`: still in the text. `reworded`: changed since. `gone`: their part was deleted from the page. */
8
+ state?: 'here' | 'reworded' | 'gone'
9
+ /** A part with no words, a picture or a whole block: what it is, in the app's words ("Picture: plan.png"). */
10
+ label?: string
11
+ }
12
+
13
+ const SINCE = { reworded: 'Changed since', gone: 'Deleted from the page' } as const
14
+
15
+ /**
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
+ * read as one. ConversationCard puts it under the name, above the comment's words ("above the message, not above the
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.
20
+ */
21
+ export function QuotedLine({ words, state = 'here', label }: QuotedLineProps) {
22
+ const shown = words ?? label ?? ''
23
+ return (
24
+ <div data-quoted={words ? state : 'part'} className="flex w-full min-w-0 flex-col gap-0.5">
25
+ <WithTooltip label={shown} wrapperClassName="flex min-w-0">
26
+ <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>
28
+ </p>
29
+ </WithTooltip>
30
+ {state !== 'here' && <span className="text-caption italic text-text-muted">{SINCE[state]}</span>}
31
+ </div>
32
+ )
33
+ }
@@ -0,0 +1,36 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './ReactionHorizon.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # ReactionHorizon
7
+
8
+ The line that says reactions are read only so far back, and how many older comments were not checked.
9
+
10
+ <Canvas of={Stories.Older} />
11
+
12
+ ## When
13
+
14
+ - Under a long conversation, when the app stopped reading reactions before the oldest comment.
15
+
16
+ ## When not
17
+
18
+ No alternative: when every reaction was read, it draws nothing, so it can always be placed.
19
+
20
+ ## How
21
+
22
+ ```tsx
23
+ import { ReactionHorizon } from '@estiva-app/ui'
24
+
25
+ <ReactionHorizon limit={200} omitted={14} cut={false} />
26
+ ```
27
+
28
+ - `limit`, `omitted` and `cut` are the app's to count.
29
+
30
+ ## What it owns
31
+
32
+ Nothing. It only draws. Clicks and keys are yours.
33
+
34
+ ## Props
35
+
36
+ <Controls />
@@ -0,0 +1,27 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { Column } from './conversation.examples'
3
+ import { ReactionHorizon } from './ReactionHorizon'
4
+
5
+ /** How far back reactions are read. Nothing is drawn when every one was. */
6
+ const meta = {
7
+ title: 'Conversation/ReactionHorizon',
8
+ component: ReactionHorizon,
9
+ parameters: { layout: 'padded' },
10
+ args: { limit: 200, omitted: 14 },
11
+ decorators: [(Story) => <Column>{Story()}</Column>],
12
+ } satisfies Meta<typeof ReactionHorizon>
13
+
14
+ export default meta
15
+ type Story = StoryObj<typeof meta>
16
+
17
+ /** Older ones were not checked. */
18
+ export const Older: Story = {}
19
+
20
+ /** One older one. */
21
+ export const One: Story = { args: { omitted: 1 } }
22
+
23
+ /** The read was cut short. */
24
+ export const Cut: Story = { args: { omitted: 0, cut: true } }
25
+
26
+ /** Both. */
27
+ export const Both: Story = { args: { cut: true } }
@@ -0,0 +1,27 @@
1
+ export interface ReactionHorizonProps {
2
+ /** How many comments and replies back reactions are read for. */
3
+ limit: number
4
+ /** How many older ones were not checked. */
5
+ omitted: number
6
+ /** Some reactions may be missing: the read was cut short. */
7
+ cut?: boolean
8
+ }
9
+
10
+ /**
11
+ * The line that says reactions are read only so far back, and how many older comments were not checked. Nothing is
12
+ * drawn when every one was. Peek's, moved with the conversation.
13
+ */
14
+ export function ReactionHorizon({ limit, omitted, cut = false }: ReactionHorizonProps) {
15
+ if (omitted <= 0 && !cut) return null
16
+ return (
17
+ <p className="text-caption text-text-muted">
18
+ {omitted > 0 && (
19
+ <>
20
+ Reactions are shown for the latest {limit} comments and replies here. {omitted} older {omitted === 1 ? 'one was' : 'ones were'} not checked.
21
+ </>
22
+ )}
23
+ {omitted > 0 && cut && ' '}
24
+ {cut && 'Some reactions may be missing.'}
25
+ </p>
26
+ )
27
+ }
@@ -0,0 +1,45 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './RepliesRow.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # RepliesRow
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.
9
+
10
+ <Canvas of={Stories.Several} />
11
+
12
+ ## When
13
+
14
+ - Under a comment with replies: **ConversationCard** draws it from its `replies`.
15
+ - `onOpen` where the row itself opens the thread (one column, the thread under its comment); without it, the card around it does.
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
+
18
+ <Canvas of={Stories.New} />
19
+ <Canvas of={Stories.Open} />
20
+
21
+ ## When not
22
+
23
+ - A count on its own → **MetaText**.
24
+ - Faces on their own → **AvatarGroup**.
25
+
26
+ ## How
27
+
28
+ ```tsx
29
+ import { RepliesRow } from '@estiva-app/ui'
30
+
31
+ <RepliesRow count={3} faces={faces} last="12:02 PM" isNew onOpen={() => openUnder(comment)} />
32
+ ```
33
+
34
+ - Faces and the last time show in Signal; in the other themes the row is the icon and the count.
35
+
36
+ ## What it owns
37
+
38
+ | It does | So you never write | Refused when written by hand |
39
+ |---|---|---|
40
+ | 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 | |
42
+
43
+ ## Props
44
+
45
+ <Controls />
@@ -0,0 +1,33 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { Column, THREE, TWO, YOU } from './conversation.examples'
3
+ import { RepliesRow } from './RepliesRow'
4
+
5
+ /** The way into a thread. In Signal it shows who replied and the last time; in the other themes, the count. */
6
+ const meta = {
7
+ title: 'Conversation/RepliesRow',
8
+ component: RepliesRow,
9
+ parameters: { layout: 'padded' },
10
+ args: { count: 3, faces: [TWO, THREE, YOU], last: '12:02 PM' },
11
+ decorators: [(Story) => <Column>{Story()}</Column>],
12
+ } satisfies Meta<typeof RepliesRow>
13
+
14
+ export default meta
15
+ type Story = StoryObj<typeof meta>
16
+
17
+ /** Several replies, with their faces. */
18
+ export const Several: Story = {}
19
+
20
+ /** One reply. */
21
+ export const One: Story = { args: { count: 1, faces: [TWO] } }
22
+
23
+ /** A reply not read yet. */
24
+ export const New: Story = { args: { isNew: true } }
25
+
26
+ /** A reply not read yet, in an urgent thread. */
27
+ export const Urgent: Story = { args: { isNew: true, urgent: true } }
28
+
29
+ /** A press on it opens the thread. */
30
+ export const Opens: Story = { args: { onOpen: () => {} } }
31
+
32
+ /** Its thread open under it, in one column: the chevron turned down, the row kept marked; a press closes it. */
33
+ export const Open: Story = { args: { onOpen: () => {}, open: true } }
@@ -0,0 +1,47 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, describe, expect, it, vi } from 'vitest'
3
+ import { cleanup, fireEvent, render, screen } from '@testing-library/react'
4
+ import { RepliesRow } from './RepliesRow'
5
+
6
+ afterEach(cleanup)
7
+
8
+ describe('RepliesRow', () => {
9
+ it('says how many, in one or many', () => {
10
+ render(<RepliesRow count={1} />)
11
+ expect(screen.getByText('1 reply')).toBeTruthy()
12
+ cleanup()
13
+ render(<RepliesRow count={3} />)
14
+ expect(screen.getByText('3 replies')).toBeTruthy()
15
+ })
16
+
17
+ it('opens the thread with a press, and says whether it opens or closes it', () => {
18
+ const onOpen = vi.fn()
19
+ render(<RepliesRow count={2} onOpen={onOpen} />)
20
+ const row = screen.getByRole('button', { name: '2 replies, open the thread' })
21
+ expect(row.getAttribute('aria-expanded')).toBe('false')
22
+ fireEvent.click(row)
23
+ expect(onOpen).toHaveBeenCalledOnce()
24
+ cleanup()
25
+ render(<RepliesRow count={2} onOpen={onOpen} open />)
26
+ expect(screen.getByRole('button', { name: '2 replies, close the thread' }).getAttribute('aria-expanded')).toBe('true')
27
+ })
28
+
29
+ it('is no button of its own without onOpen: the card round it opens the thread', () => {
30
+ render(<RepliesRow count={2} />)
31
+ expect(screen.queryByRole('button')).toBeNull()
32
+ })
33
+
34
+ it('says "1 new" until it is read', () => {
35
+ render(<RepliesRow count={2} isNew />)
36
+ expect(screen.getByText('1 new')).toBeTruthy()
37
+ cleanup()
38
+ render(<RepliesRow count={2} />)
39
+ expect(screen.queryByText('1 new')).toBeNull()
40
+ })
41
+
42
+ it('shows the last reply’s time, and the faces in place of the icon', () => {
43
+ const { container } = render(<RepliesRow count={2} last="11:52 AM" faces={[{ name: 'Person two' }, { name: 'Person three' }]} />)
44
+ expect(screen.getByText('11:52 AM')).toBeTruthy()
45
+ expect(container.querySelectorAll('img, [data-avatar], [aria-label="Person two"]').length).toBeGreaterThan(0)
46
+ })
47
+ })
@@ -0,0 +1,86 @@
1
+ import { IconChevronRight, IconMessage2 } from '@tabler/icons-react'
2
+ import { AvatarGroup } from './AvatarGroup'
3
+ import { Chip } from './Chip'
4
+ import { cn } from './cn'
5
+ import { TIME_CLASSES } from './looks'
6
+
7
+ export interface RepliesRowProps {
8
+ /** How many replies. */
9
+ count: number
10
+ /** Who replied: their faces. */
11
+ faces?: readonly { name: string; picture?: string; bot?: boolean }[]
12
+ /** The last reply's time, in the app's words. */
13
+ last?: string
14
+ /** "1 new": a reply you have not read. */
15
+ isNew?: boolean
16
+ /** The "1 new" chip in the warning colour, for an urgent thread. */
17
+ urgent?: boolean
18
+ /** Opens the thread. Absent, the row only says how many (the card around it opens the thread). */
19
+ onOpen?: () => void
20
+ /** Its thread is open under it, in one column: the chevron turns down and the row stays marked; a press closes it (Katerina, 31 October). */
21
+ open?: boolean
22
+ }
23
+
24
+ const ROW_CLASSES = 'flex w-full items-center gap-2 pb-1.5 pl-8 pr-2'
25
+ /** Open: the row keeps the look a pointer gives it, so it reads as the thread's open way in. */
26
+ const OPEN_CLASSES = 'border-accent-outline bg-accent-wash'
27
+ const BOX_CLASSES =
28
+ '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
+
30
+ /**
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
+ * (Katerina, 31 October), each in its own colours.
34
+ */
35
+ export function RepliesRow({ count, faces, last, isNew = false, urgent = false, onOpen, open = false }: RepliesRowProps) {
36
+ const withFaces = !!faces && faces.length > 0
37
+ const label = `${count} ${count === 1 ? 'reply' : 'replies'}`
38
+ const inner = (
39
+ <>
40
+ {withFaces && (
41
+ <span className="flex shrink-0 items-center">
42
+ <AvatarGroup size={18} members={faces.map((f) => ({ name: f.name, picture: f.picture, bot: f.bot }))} />
43
+ </span>
44
+ )}
45
+ <IconMessage2
46
+ size={16}
47
+ stroke={1.5}
48
+ className={cn(
49
+ 'shrink-0 text-text-interactive transition-colors group-hover/replies:text-text-primary',
50
+ withFaces && 'hidden',
51
+ )}
52
+ />
53
+ <span className="text-chip font-medium text-text-interactive transition-colors group-hover/replies:text-text-primary">
54
+ {label}
55
+ </span>
56
+ {last && <span className={cn('mt-px text-small leading-3 text-text-muted', TIME_CLASSES)}>{last}</span>}
57
+ {/* Turned down while its thread is open, as a tree row's chevron is. */}
58
+ <IconChevronRight
59
+ size={12}
60
+ stroke={2}
61
+ className={cn('transition-all group-hover/replies:text-text-primary', open ? 'rotate-90 text-text-primary' : 'text-text-muted group-hover/replies:translate-x-0.5')}
62
+ />
63
+ </>
64
+ )
65
+ const chip = isNew && (
66
+ <>
67
+ <span className="h-0.5 w-0.5 shrink-0 rounded-full bg-text-muted" />
68
+ <Chip type={urgent ? 'warning' : 'brand'} label="1 new" />
69
+ </>
70
+ )
71
+ if (!onOpen) {
72
+ return (
73
+ <div className={ROW_CLASSES}>
74
+ <div className={BOX_CLASSES}>{inner}</div>
75
+ {chip}
76
+ </div>
77
+ )
78
+ }
79
+ return (
80
+ // @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>
82
+ <span className={cn(BOX_CLASSES, open && OPEN_CLASSES)}>{inner}</span>
83
+ {chip}
84
+ </button>
85
+ )
86
+ }
@@ -0,0 +1,50 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './ReplyCard.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # ReplyCard
7
+
8
+ One reply in a thread: the same pieces as a comment, without replies of its own or Resolve.
9
+
10
+ <Canvas of={Stories.Reply} />
11
+
12
+ ## When
13
+
14
+ - **A reply**, inside a **Thread**, in time order.
15
+ - `timeHref`: its time is a link to it, "Link to this".
16
+ - `own` on yours: Edit and Delete in its menu.
17
+
18
+ <Canvas of={Stories.Yours} />
19
+
20
+ <Canvas of={Stories.Linked} />
21
+
22
+ ## When not
23
+
24
+ - A comment, with its replies and Resolve → **ConversationCard**.
25
+ - Who resolved the thread, and the note → the comment says it (**ConversationCard** `resolved`), not a line among the replies.
26
+
27
+ ## How
28
+
29
+ ```tsx
30
+ import { ReplyCard, Thread } from '@estiva-app/ui'
31
+
32
+ <Thread start={start} box={box} onClose={close}>
33
+ <ReplyCard author={author} time={time} timeHref={linkToReply} own={isMine} onDelete={() => remove(reply)}>
34
+ {wordsOf(reply)}
35
+ </ReplyCard>
36
+ </Thread>
37
+ ```
38
+
39
+ - Everything a comment takes about its words, its files, its reactions and its editing, a reply takes the same way.
40
+
41
+ ## What it owns
42
+
43
+ | It does | So you never write | Refused when written by hand |
44
+ |---|---|---|
45
+ | Shows its actions while pointed at, and holds them while a menu is open | hover state and an outside-click check | |
46
+ | Asks before it deletes | a confirm dialog | |
47
+
48
+ ## Props
49
+
50
+ <Controls />
@@ -0,0 +1,68 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { useState } from 'react'
3
+ import { userEvent, within } from 'storybook/test'
4
+ import { ReplyCard, type ReplyCardProps } from './ConversationCard'
5
+ import { Column, EditBox, Files, ONE, SHORT, SOME, WithCard, YOU, useReactions } from './conversation.examples'
6
+ import type { ReactionCount } from './ReactionRow'
7
+
8
+ /** One reply, live: point at it to react, and on your own edit or delete it. */
9
+ const meta = {
10
+ title: 'Conversation/ReplyCard',
11
+ component: ReplyCard,
12
+ parameters: { layout: 'padded' },
13
+ args: { author: ONE, time: '11:40 AM', children: SHORT },
14
+ decorators: [(Story) => <Column>{Story()}</Column>],
15
+ } satisfies Meta<typeof ReplyCard>
16
+
17
+ export default meta
18
+ type Story = StoryObj<typeof meta>
19
+
20
+ function Live({ start, ...props }: ReplyCardProps & { start?: readonly ReactionCount[] }) {
21
+ const reacting = useReactions(start)
22
+ const [gone, setGone] = useState(false)
23
+ if (gone) return null
24
+ return (
25
+ <ReplyCard
26
+ {...props}
27
+ reactions={props.readOnly ? { ...reacting, onToggle: undefined } : reacting}
28
+ onDelete={() => setGone(true)}
29
+ editor={props.own ? (done) => <EditBox text={SHORT} done={done} /> : undefined}
30
+ />
31
+ )
32
+ }
33
+
34
+ /** Someone's reply. */
35
+ export const Reply: Story = { render: (args) => <Live {...args} /> }
36
+
37
+ /** Yours: Edit and Delete in its ⋯ menu. */
38
+ export const Yours: Story = { render: (args) => <Live {...args} author={YOU} own /> }
39
+
40
+ /** Edited since it was sent. */
41
+ export const Edited: Story = { render: (args) => <Live {...args} edited="Edited 11:52 AM" /> }
42
+
43
+ /** Not read yet. */
44
+ export const New: Story = { render: (args) => <Live {...args} isNew /> }
45
+
46
+ /** Urgent and not read yet. */
47
+ export const Urgent: Story = { render: (args) => <Live {...args} isNew urgent /> }
48
+
49
+ /** With reactions. */
50
+ export const Reactions: Story = { render: (args) => <Live {...args} start={SOME} /> }
51
+
52
+ /** Pictures and files under the words. */
53
+ export const WithFiles: Story = { name: 'Files', render: (args) => <Live {...args} files={<Files />} /> }
54
+
55
+ /** A card its author attached. */
56
+ export const Card: Story = { render: (args) => <Live {...args}><WithCard /></Live> }
57
+
58
+ /** Its time is a link to it, "Link to this" on hover: the story points at it. */
59
+ export const Linked: Story = {
60
+ name: 'Time is a link',
61
+ render: (args) => <Live {...args} timeHref="#reply" />,
62
+ play: async ({ canvasElement }) => {
63
+ await userEvent.hover(within(canvasElement).getByRole('link', { name: '11:40 AM' }))
64
+ },
65
+ }
66
+
67
+ /** Nothing can be changed: no strip, reactions only shown. */
68
+ export const ReadOnly: Story = { name: 'Read-only', render: (args) => <Live {...args} readOnly start={SOME} /> }
@@ -0,0 +1,44 @@
1
+ import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'
2
+ import * as Stories from './ResolveDialog.stories'
3
+
4
+ <Meta of={Stories} />
5
+
6
+ # ResolveDialog
7
+
8
+ Resolve, with an optional note: the same dialog in every app.
9
+
10
+ <Canvas of={Stories.Resolve} />
11
+
12
+ ## When
13
+
14
+ - When someone resolves a thread: **ConversationCard** opens it for you from Resolve.
15
+
16
+ <Canvas of={Stories.Refused} />
17
+
18
+ ## When not
19
+
20
+ - A question before something is deleted → **ConfirmDialog**.
21
+ - Any other dialog → **DialogShell**.
22
+
23
+ ## How
24
+
25
+ ```tsx
26
+ import { ResolveDialog } from '@estiva-app/ui'
27
+
28
+ <ResolveDialog onResolve={(note) => resolve(thread, note)} onCancel={close} refused={why} />
29
+ ```
30
+
31
+ - Ctrl+Enter resolves from the note; Enter there is a new line.
32
+ - Answer `false` from `onResolve` when it was refused, and pass why in `refused`.
33
+
34
+ ## What it owns
35
+
36
+ | It does | So you never write | Refused when written by hand |
37
+ |---|---|---|
38
+ | Resolves on Ctrl+Enter from the note | a key handler | |
39
+ | Switches everything off while it waits for the answer | a busy state | |
40
+ | Says why a resolve was refused, under the note | an error line | |
41
+
42
+ ## Props
43
+
44
+ <Controls />
@@ -0,0 +1,23 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite'
2
+ import { ResolveDialog } from './ResolveDialog'
3
+
4
+ /** Resolve, with an optional note. Ctrl+Enter resolves from the note. */
5
+ const meta = {
6
+ title: 'Conversation/ResolveDialog',
7
+ component: ResolveDialog,
8
+ parameters: { layout: 'fullscreen' },
9
+ args: { onResolve: () => {}, onCancel: () => {} },
10
+ decorators: [(Story) => <div className="h-screen">{Story()}</div>],
11
+ } satisfies Meta<typeof ResolveDialog>
12
+
13
+ export default meta
14
+ type Story = StoryObj<typeof meta>
15
+
16
+ /** Nothing written yet: the note is optional. */
17
+ export const Resolve: Story = {}
18
+
19
+ /** Waiting for the answer: everything inside is switched off. */
20
+ export const Sending: Story = { args: { onResolve: () => new Promise(() => {}) } }
21
+
22
+ /** The last resolve was refused: said under the note. */
23
+ export const Refused: Story = { args: { refused: 'Not resolved: try again in a moment.' } }
@@ -0,0 +1,53 @@
1
+ // @vitest-environment jsdom
2
+ import { afterEach, describe, expect, it, vi } from 'vitest'
3
+ import { cleanup, render, screen, within } from '@testing-library/react'
4
+ import userEvent from '@testing-library/user-event'
5
+ import { ResolveDialog } from './ResolveDialog'
6
+
7
+ afterEach(cleanup)
8
+
9
+ describe('ResolveDialog', () => {
10
+ it('resolves with the note written', async () => {
11
+ const user = userEvent.setup()
12
+ const onResolve = vi.fn()
13
+ render(<ResolveDialog onResolve={onResolve} onCancel={() => {}} />)
14
+ const dialog = screen.getByRole('dialog')
15
+ await user.type(within(dialog).getByRole('textbox'), 'Going with the first one')
16
+ await user.click(within(dialog).getByRole('button', { name: 'Resolve' }))
17
+ expect(onResolve).toHaveBeenCalledWith('Going with the first one')
18
+ })
19
+
20
+ it('resolves with no note: the note is optional', async () => {
21
+ const user = userEvent.setup()
22
+ const onResolve = vi.fn()
23
+ render(<ResolveDialog onResolve={onResolve} onCancel={() => {}} />)
24
+ await user.click(screen.getByRole('button', { name: 'Resolve' }))
25
+ expect(onResolve).toHaveBeenCalledWith('')
26
+ })
27
+
28
+ it('resolves with Ctrl+Enter from the note, where Enter is a new line', async () => {
29
+ const user = userEvent.setup()
30
+ const onResolve = vi.fn()
31
+ render(<ResolveDialog onResolve={onResolve} onCancel={() => {}} />)
32
+ const note = screen.getByRole('textbox')
33
+ await user.type(note, 'First line{Enter}second')
34
+ expect(onResolve).not.toHaveBeenCalled()
35
+ await user.keyboard('{Control>}{Enter}{/Control}')
36
+ expect(onResolve).toHaveBeenCalledWith('First line\nsecond')
37
+ })
38
+
39
+ it('Cancel resolves nothing', async () => {
40
+ const user = userEvent.setup()
41
+ const onResolve = vi.fn()
42
+ const onCancel = vi.fn()
43
+ render(<ResolveDialog onResolve={onResolve} onCancel={onCancel} />)
44
+ await user.click(screen.getByRole('button', { name: 'Cancel' }))
45
+ expect(onCancel).toHaveBeenCalledOnce()
46
+ expect(onResolve).not.toHaveBeenCalled()
47
+ })
48
+
49
+ it('says why the last resolve was refused, under the note', () => {
50
+ render(<ResolveDialog onResolve={() => false} onCancel={() => {}} refused="The file is archived" />)
51
+ expect(screen.getByText(/The file is archived/)).toBeTruthy()
52
+ })
53
+ })
@@ -0,0 +1,58 @@
1
+ import { useId, useState } from 'react'
2
+ import { Button } from './Button'
3
+ import { DialogShell } from './DialogShell'
4
+ import { Field } from './Field'
5
+ import { Form } from './Form'
6
+ import { Textarea } from './Textarea'
7
+
8
+ export interface ResolveDialogProps {
9
+ /** Resolve, with what was written (an empty string for none). Answer `false` when it was refused: the dialog stays, with `refused` under the field. */
10
+ onResolve: (note: string) => Promise<boolean | void> | boolean | void
11
+ onCancel: () => void
12
+ /** Why the last resolve was refused, in plain words. */
13
+ refused?: string
14
+ }
15
+
16
+ /**
17
+ * Resolve, with an optional note: the same dialog in every app (Katerina, 31 October). Ctrl+Enter resolves from the
18
+ * note; Enter there is a new line. Peek's, moved with the conversation.
19
+ */
20
+ export function ResolveDialog({ onResolve, onCancel, refused }: ResolveDialogProps) {
21
+ const [note, setNote] = useState('')
22
+ const [busy, setBusy] = useState(false)
23
+ const formId = useId()
24
+ return (
25
+ <DialogShell
26
+ title="Resolve"
27
+ onClose={onCancel}
28
+ footer={
29
+ <>
30
+ <Button variant="muted" onClick={onCancel}>
31
+ Cancel
32
+ </Button>
33
+ {/* Outlined at rest and green on hover in Signal, the kit's `resolve` look. */}
34
+ <Button variant="resolve" type="submit" form={formId} disabled={busy}>
35
+ Resolve
36
+ </Button>
37
+ </>
38
+ }
39
+ >
40
+ <Form
41
+ id={formId}
42
+ busy={busy}
43
+ onSubmit={async () => {
44
+ setBusy(true)
45
+ try {
46
+ await onResolve(note)
47
+ } finally {
48
+ setBusy(false)
49
+ }
50
+ }}
51
+ >
52
+ <Field label="Resolution message (optional)" error={refused}>
53
+ <Textarea autoFocus value={note} onChange={(e) => setNote(e.target.value)} placeholder="Summarize the outcome or decision..." className="h-[109px]" />
54
+ </Field>
55
+ </Form>
56
+ </DialogShell>
57
+ )
58
+ }