@estiva-app/ui 0.117.0 → 0.119.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 (74) hide show
  1. package/dist/ActivityLine.d.ts +37 -0
  2. package/dist/ActivityLine.d.ts.map +1 -0
  3. package/dist/CollapsibleSection.d.ts +6 -1
  4. package/dist/CollapsibleSection.d.ts.map +1 -1
  5. package/dist/ContainerHeader.d.ts +10 -1
  6. package/dist/ContainerHeader.d.ts.map +1 -1
  7. package/dist/ConversationLayout.d.ts.map +1 -1
  8. package/dist/DialogShell.d.ts +11 -3
  9. package/dist/DialogShell.d.ts.map +1 -1
  10. package/dist/ListColumn.d.ts +6 -1
  11. package/dist/ListColumn.d.ts.map +1 -1
  12. package/dist/ListTable.d.ts +71 -0
  13. package/dist/ListTable.d.ts.map +1 -0
  14. package/dist/MembersDialog.d.ts.map +1 -1
  15. package/dist/NavTree.d.ts +12 -1
  16. package/dist/NavTree.d.ts.map +1 -1
  17. package/dist/PageHeader.d.ts +11 -2
  18. package/dist/PageHeader.d.ts.map +1 -1
  19. package/dist/conversationScroll.d.ts +6 -0
  20. package/dist/conversationScroll.d.ts.map +1 -1
  21. package/dist/index.d.ts +2 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +586 -433
  24. package/dist/index.js.map +4 -4
  25. package/dist/revealCurrentRow.d.ts +28 -0
  26. package/dist/revealCurrentRow.d.ts.map +1 -0
  27. package/dist/showInConversation.d.ts +5 -0
  28. package/dist/showInConversation.d.ts.map +1 -1
  29. package/package.json +1 -1
  30. package/registry.json +253 -5
  31. package/src/ActivityLine.mdx +67 -0
  32. package/src/ActivityLine.stories.tsx +49 -0
  33. package/src/ActivityLine.test.tsx +47 -0
  34. package/src/ActivityLine.tsx +74 -0
  35. package/src/Button.mdx +5 -0
  36. package/src/CollapsibleSection.mdx +6 -0
  37. package/src/CollapsibleSection.stories.tsx +4 -1
  38. package/src/CollapsibleSection.test.tsx +11 -0
  39. package/src/CollapsibleSection.tsx +7 -2
  40. package/src/ContainerHeader.mdx +7 -0
  41. package/src/ContainerHeader.stories.tsx +3 -0
  42. package/src/ContainerHeader.test.tsx +12 -1
  43. package/src/ContainerHeader.tsx +38 -18
  44. package/src/ConversationLayout.mdx +5 -2
  45. package/src/ConversationLayout.scroll.test.tsx +62 -1
  46. package/src/ConversationLayout.stories.tsx +44 -0
  47. package/src/ConversationLayout.tsx +33 -2
  48. package/src/DialogShell.mdx +8 -2
  49. package/src/DialogShell.stories.tsx +20 -7
  50. package/src/DialogShell.tsx +10 -4
  51. package/src/ListColumn.mdx +1 -0
  52. package/src/ListColumn.stories.tsx +53 -1
  53. package/src/ListColumn.tsx +10 -2
  54. package/src/ListTable.mdx +112 -0
  55. package/src/ListTable.stories.tsx +133 -0
  56. package/src/ListTable.test.tsx +81 -0
  57. package/src/ListTable.tsx +178 -0
  58. package/src/MembersDialog.test.tsx +8 -0
  59. package/src/MembersDialog.tsx +2 -10
  60. package/src/NavTree.mdx +7 -1
  61. package/src/NavTree.stories.tsx +75 -1
  62. package/src/NavTree.test.tsx +18 -0
  63. package/src/NavTree.tsx +23 -34
  64. package/src/PageHeader.mdx +13 -2
  65. package/src/PageHeader.stories.tsx +35 -1
  66. package/src/PageHeader.test.tsx +21 -0
  67. package/src/PageHeader.tsx +17 -5
  68. package/src/conversationScroll.ts +11 -0
  69. package/src/index.ts +2 -0
  70. package/src/registry/registry.test.ts +5 -5
  71. package/src/revealCurrentRow.test.tsx +168 -0
  72. package/src/revealCurrentRow.ts +68 -0
  73. package/src/showInConversation.ts +9 -1
  74. package/stories/Choosing.mdx +2 -0
@@ -0,0 +1,68 @@
1
+ import { useEffect, useRef, type RefObject } from 'react'
2
+
3
+ /**
4
+ * Showing where the open page lives in a list: its row (`aria-current="page"`, what `NavItem`'s `active` sets) brought
5
+ * into the column's sight, once for each new current row, whenever it is drawn and shown (Katerina, 17 November: "the
6
+ * selected [row] could be somewhere above or below the fold … a general problem we need to fix").
7
+ *
8
+ * However late: a row a fold reads only once it opens, a group sliding open, rows that arrive with a read. The list is
9
+ * watched for what changes in it, not for its own draws, so a row drawn by a part inside it is seen too (a team's Files
10
+ * fold, which reads its files itself, never drew the tree again: its open file stayed below the fold).
11
+ *
12
+ * Once: a row brought into sight is not brought back after the reader scrolls away, while it stays the current one;
13
+ * a new current row is.
14
+ */
15
+
16
+ /** How long it waits to look, after the list changes: a group above the row slides open in 150ms. */
17
+ export const REVEAL_MS = 200
18
+
19
+ /**
20
+ * Scroll the column the row is in, and only that box — never the page, nor a
21
+ * drawer that is shut — so the row is in sight. A row in sight stays put.
22
+ * A group taller than the column keeps its top in sight, as the browser's
23
+ * `block: 'nearest'` does (a row is never that tall).
24
+ */
25
+ export function scrollToRow(row: HTMLElement) {
26
+ let box = row.parentElement
27
+ while (box && !(/(auto|scroll)/.test(getComputedStyle(box).overflowY) && box.scrollHeight > box.clientHeight)) box = box.parentElement
28
+ if (!box || box === document.documentElement || box === document.body) return
29
+ const at = row.getBoundingClientRect()
30
+ const view = box.getBoundingClientRect()
31
+ if (at.top < view.top) box.scrollTop -= view.top - at.top
32
+ else if (at.bottom > view.bottom) box.scrollTop += Math.min(at.bottom - view.bottom, at.top - view.top)
33
+ }
34
+
35
+ /**
36
+ * Brings the current row inside `box` into sight, once per current row. `current` names it when the caller knows it
37
+ * (`NavTree`'s `selected`); without it, the row is known by its link.
38
+ */
39
+ export function useRevealCurrentRow(box: RefObject<HTMLElement | null>, current?: string): void {
40
+ const shown = useRef<string | undefined>(undefined)
41
+ useEffect(() => {
42
+ const root = box.current
43
+ if (!root) return
44
+ let timer: ReturnType<typeof setTimeout> | undefined
45
+ const look = () => {
46
+ timer = undefined
47
+ const row = root.querySelector<HTMLElement>('[aria-current="page"]')
48
+ if (!row) return
49
+ const key = current ?? row.getAttribute('href') ?? row.textContent ?? ''
50
+ if (shown.current === key) return
51
+ // Not drawn yet, or inside a fold that is shut: whatever opens it changes the list, and it is looked for again.
52
+ if (row.getBoundingClientRect().height === 0) return
53
+ shown.current = key
54
+ scrollToRow(row)
55
+ }
56
+ // One look a moment after the list changes, however often it does: a live list changes all the time.
57
+ const soon = () => {
58
+ if (timer === undefined) timer = setTimeout(look, REVEAL_MS)
59
+ }
60
+ const watch = typeof MutationObserver === 'undefined' ? undefined : new MutationObserver(soon)
61
+ watch?.observe(root, { subtree: true, childList: true, attributes: true, attributeFilter: ['aria-current', 'hidden'] })
62
+ soon()
63
+ return () => {
64
+ watch?.disconnect()
65
+ if (timer !== undefined) clearTimeout(timer)
66
+ }
67
+ }, [box, current])
68
+ }
@@ -59,6 +59,15 @@ function show(id: string, options: ShowOptions): boolean {
59
59
  const el = find(id, options)
60
60
  if (!el) return false
61
61
  el.scrollIntoView({ behavior: 'smooth', block: 'center' })
62
+ markShown(el)
63
+ return true
64
+ }
65
+
66
+ /**
67
+ * Marks one drawn comment or reply a moment (`data-shown`, the kit's flash): a show's mark, and the one a
68
+ * `ConversationLayout` gives the comment it lands on when it opens at a thread. The package's own, not exported.
69
+ */
70
+ export function markShown(el: HTMLElement): void {
62
71
  const previous = owed.get(el)
63
72
  if (previous !== undefined) window.clearTimeout(previous)
64
73
  el.dataset.shown = 'true'
@@ -69,7 +78,6 @@ function show(id: string, options: ShowOptions): boolean {
69
78
  owed.delete(el)
70
79
  }, SHOWN_MS),
71
80
  )
72
- return true
73
81
  }
74
82
 
75
83
  /**
@@ -109,6 +109,7 @@ The same conversation in every app; only its colours are each app's.
109
109
  | The strip on a pointed-at comment, and its ⋯ menu | **ConversationActions** and **ConversationMenu** — the cards draw both |
110
110
  | A time beside a name, "(edited)", urgent and new | **MetaText**, **EditedMarker**, **UrgentMark** |
111
111
  | How far back reactions were read | **ReactionHorizon** — draws nothing when every one was |
112
+ | One thing that happened, in a list of what is new: who, what they did, when, where | **ActivityLine** — a menu row’s look, a link or a button; the mark beside the first line |
112
113
 
113
114
  ## Structure and wayfinding
114
115
 
@@ -123,6 +124,7 @@ The same conversation in every app; only its colours are each app's.
123
124
  | Something new on a row or a card, no count | **UnreadDot** — the 6px dot in a 24px slot; in a sidebar row, **NavItem** `unread` draws it; `quiet` for a dot that is always there with nothing new; `tone="reaction"` for a reaction to you (NavItem `unreadTone`) |
124
125
  | One thing — a conversation, a project, an object — as a box you can pick | **Card** — the fill by what it sits on; `href` for a link, `hover="fill"` in a feed, `onPress` when a press opens it |
125
126
  | A section heading, chevron, hover actions, a count beside the title | **SectionHeader** |
127
+ | A list of things on a page, under column headings, each row a link | **ListTable** with **ListTableRow** — the columns give way by the list’s own width; `headings={false}` where the part’s heading names it |
126
128
  | A group of rows that opens and closes, and stays how you left it | **CollapsibleSection** — `storageKey` remembers |
127
129
  | The uppercase micro-label | **SectionLabel** |
128
130
  | A hairline, or a line with words in the middle | **Divider** — `label`; `look="section"` between stretches of a list, `sticky` while it scrolls |