@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.
- package/dist/ActivityLine.d.ts +37 -0
- package/dist/ActivityLine.d.ts.map +1 -0
- package/dist/CollapsibleSection.d.ts +6 -1
- package/dist/CollapsibleSection.d.ts.map +1 -1
- package/dist/ContainerHeader.d.ts +10 -1
- package/dist/ContainerHeader.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts.map +1 -1
- package/dist/DialogShell.d.ts +11 -3
- package/dist/DialogShell.d.ts.map +1 -1
- package/dist/ListColumn.d.ts +6 -1
- package/dist/ListColumn.d.ts.map +1 -1
- package/dist/ListTable.d.ts +71 -0
- package/dist/ListTable.d.ts.map +1 -0
- package/dist/MembersDialog.d.ts.map +1 -1
- package/dist/NavTree.d.ts +12 -1
- package/dist/NavTree.d.ts.map +1 -1
- package/dist/PageHeader.d.ts +11 -2
- package/dist/PageHeader.d.ts.map +1 -1
- package/dist/conversationScroll.d.ts +6 -0
- package/dist/conversationScroll.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +586 -433
- package/dist/index.js.map +4 -4
- package/dist/revealCurrentRow.d.ts +28 -0
- package/dist/revealCurrentRow.d.ts.map +1 -0
- package/dist/showInConversation.d.ts +5 -0
- package/dist/showInConversation.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +253 -5
- package/src/ActivityLine.mdx +67 -0
- package/src/ActivityLine.stories.tsx +49 -0
- package/src/ActivityLine.test.tsx +47 -0
- package/src/ActivityLine.tsx +74 -0
- package/src/Button.mdx +5 -0
- package/src/CollapsibleSection.mdx +6 -0
- package/src/CollapsibleSection.stories.tsx +4 -1
- package/src/CollapsibleSection.test.tsx +11 -0
- package/src/CollapsibleSection.tsx +7 -2
- package/src/ContainerHeader.mdx +7 -0
- package/src/ContainerHeader.stories.tsx +3 -0
- package/src/ContainerHeader.test.tsx +12 -1
- package/src/ContainerHeader.tsx +38 -18
- package/src/ConversationLayout.mdx +5 -2
- package/src/ConversationLayout.scroll.test.tsx +62 -1
- package/src/ConversationLayout.stories.tsx +44 -0
- package/src/ConversationLayout.tsx +33 -2
- package/src/DialogShell.mdx +8 -2
- package/src/DialogShell.stories.tsx +20 -7
- package/src/DialogShell.tsx +10 -4
- package/src/ListColumn.mdx +1 -0
- package/src/ListColumn.stories.tsx +53 -1
- package/src/ListColumn.tsx +10 -2
- package/src/ListTable.mdx +112 -0
- package/src/ListTable.stories.tsx +133 -0
- package/src/ListTable.test.tsx +81 -0
- package/src/ListTable.tsx +178 -0
- package/src/MembersDialog.test.tsx +8 -0
- package/src/MembersDialog.tsx +2 -10
- package/src/NavTree.mdx +7 -1
- package/src/NavTree.stories.tsx +75 -1
- package/src/NavTree.test.tsx +18 -0
- package/src/NavTree.tsx +23 -34
- package/src/PageHeader.mdx +13 -2
- package/src/PageHeader.stories.tsx +35 -1
- package/src/PageHeader.test.tsx +21 -0
- package/src/PageHeader.tsx +17 -5
- package/src/conversationScroll.ts +11 -0
- package/src/index.ts +2 -0
- package/src/registry/registry.test.ts +5 -5
- package/src/revealCurrentRow.test.tsx +168 -0
- package/src/revealCurrentRow.ts +68 -0
- package/src/showInConversation.ts +9 -1
- 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
|
/**
|
package/stories/Choosing.mdx
CHANGED
|
@@ -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 |
|