@estiva-app/ui 0.98.1 → 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.
- package/README.md +4 -2
- package/dist/AppProvider.d.ts +6 -3
- package/dist/AppProvider.d.ts.map +1 -1
- package/dist/ArchiveDialog.d.ts +35 -0
- package/dist/ArchiveDialog.d.ts.map +1 -0
- package/dist/AttachedCard.d.ts +13 -2
- package/dist/AttachedCard.d.ts.map +1 -1
- package/dist/Card.d.ts +6 -1
- package/dist/Card.d.ts.map +1 -1
- package/dist/ChipInput.d.ts +3 -1
- package/dist/ChipInput.d.ts.map +1 -1
- package/dist/CollapsibleSection.d.ts +27 -2
- package/dist/CollapsibleSection.d.ts.map +1 -1
- package/dist/CommentBox.d.ts +2 -2
- package/dist/CommentBox.d.ts.map +1 -1
- package/dist/ConfirmDialog.d.ts +15 -2
- package/dist/ConfirmDialog.d.ts.map +1 -1
- package/dist/ConversationCard.d.ts +12 -1
- package/dist/ConversationCard.d.ts.map +1 -1
- package/dist/ConversationLayout.d.ts +20 -5
- package/dist/ConversationLayout.d.ts.map +1 -1
- package/dist/ConversationMenu.d.ts +5 -1
- package/dist/ConversationMenu.d.ts.map +1 -1
- package/dist/ConversationPlace.d.ts +17 -0
- package/dist/ConversationPlace.d.ts.map +1 -0
- package/dist/DocumentEditor.d.ts +38 -0
- package/dist/DocumentEditor.d.ts.map +1 -1
- package/dist/DocumentField.d.ts +50 -0
- package/dist/DocumentField.d.ts.map +1 -0
- package/dist/EditableText.d.ts +38 -4
- package/dist/EditableText.d.ts.map +1 -1
- package/dist/EmptyState.d.ts +10 -5
- package/dist/EmptyState.d.ts.map +1 -1
- package/dist/FormDialog.d.ts +38 -0
- package/dist/FormDialog.d.ts.map +1 -0
- package/dist/InlineText.d.ts.map +1 -1
- package/dist/Menu.d.ts +11 -3
- package/dist/Menu.d.ts.map +1 -1
- package/dist/MoveDialog.d.ts +64 -0
- package/dist/MoveDialog.d.ts.map +1 -0
- package/dist/NavItem.d.ts +9 -2
- package/dist/NavItem.d.ts.map +1 -1
- package/dist/NavTree.d.ts +16 -3
- package/dist/NavTree.d.ts.map +1 -1
- package/dist/PinnedComment.d.ts +3 -1
- package/dist/PinnedComment.d.ts.map +1 -1
- package/dist/ReactionHorizon.d.ts +3 -1
- package/dist/ReactionHorizon.d.ts.map +1 -1
- package/dist/RepliesRow.d.ts +5 -3
- package/dist/RepliesRow.d.ts.map +1 -1
- package/dist/ResolveDialog.d.ts +3 -1
- package/dist/ResolveDialog.d.ts.map +1 -1
- package/dist/SelectionToolbar.d.ts +2 -2
- package/dist/Thread.d.ts +6 -3
- package/dist/Thread.d.ts.map +1 -1
- package/dist/commentBoxFrame.d.ts.map +1 -1
- package/dist/conversation.examples.d.ts +4 -1
- package/dist/conversation.examples.d.ts.map +1 -1
- package/dist/conversationScroll.d.ts +80 -0
- package/dist/conversationScroll.d.ts.map +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +228 -69
- package/dist/editor.js.map +4 -4
- package/dist/eslint/index.js +2 -2
- package/dist/eslint/index.js.map +2 -2
- package/dist/eslint/no-field-outside-a-form.d.ts +2 -2
- package/dist/eslint/no-field-outside-a-form.d.ts.map +1 -1
- package/dist/eslint/no-native-title.d.ts +1 -1
- package/dist/eslint/no-native-title.d.ts.map +1 -1
- package/dist/formBusy.d.ts +5 -2
- package/dist/formBusy.d.ts.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2242 -1471
- package/dist/index.js.map +4 -4
- package/dist/looks.d.ts +8 -0
- package/dist/looks.d.ts.map +1 -1
- package/dist/seenOnScreen.d.ts +27 -0
- package/dist/seenOnScreen.d.ts.map +1 -0
- package/dist/showInConversation.d.ts +31 -0
- package/dist/showInConversation.d.ts.map +1 -0
- package/dist/threadCard.d.ts +13 -0
- package/dist/threadCard.d.ts.map +1 -1
- package/package.json +1 -1
- package/registry.json +953 -126
- package/src/AppProvider.mdx +4 -0
- package/src/AppProvider.test.tsx +34 -2
- package/src/AppProvider.tsx +17 -6
- package/src/ArchiveDialog.mdx +70 -0
- package/src/ArchiveDialog.stories.tsx +64 -0
- package/src/ArchiveDialog.test.tsx +90 -0
- package/src/ArchiveDialog.tsx +70 -0
- package/src/AttachedCard.mdx +6 -0
- package/src/AttachedCard.stories.tsx +9 -1
- package/src/AttachedCard.test.tsx +111 -2
- package/src/AttachedCard.tsx +77 -7
- package/src/Card.mdx +20 -1
- package/src/Card.stories.tsx +20 -0
- package/src/Card.test.tsx +87 -1
- package/src/Card.tsx +51 -3
- package/src/ChipInput.mdx +7 -1
- package/src/ChipInput.stories.tsx +9 -0
- package/src/ChipInput.test.tsx +42 -0
- package/src/ChipInput.tsx +7 -3
- package/src/CollapsibleSection.mdx +20 -1
- package/src/CollapsibleSection.stories.tsx +19 -1
- package/src/CollapsibleSection.test.tsx +85 -2
- package/src/CollapsibleSection.tsx +54 -15
- package/src/CommentBox.mdx +2 -1
- package/src/CommentBox.test.tsx +81 -1
- package/src/CommentBox.tsx +32 -11
- package/src/ConfirmDialog.mdx +25 -3
- package/src/ConfirmDialog.stories.tsx +27 -0
- package/src/ConfirmDialog.test.tsx +87 -1
- package/src/ConfirmDialog.tsx +39 -8
- package/src/ConversationCard.mdx +7 -0
- package/src/ConversationCard.states.test.tsx +67 -0
- package/src/ConversationCard.stories.tsx +27 -1
- package/src/ConversationCard.test.tsx +76 -0
- package/src/ConversationCard.tsx +65 -53
- package/src/ConversationLayout.mdx +34 -4
- package/src/ConversationLayout.scroll.test.tsx +411 -0
- package/src/ConversationLayout.stories.tsx +107 -1
- package/src/ConversationLayout.test.tsx +133 -0
- package/src/ConversationLayout.tsx +141 -16
- package/src/ConversationMenu.mdx +3 -0
- package/src/ConversationMenu.stories.tsx +12 -0
- package/src/ConversationMenu.test.tsx +17 -0
- package/src/ConversationMenu.tsx +7 -3
- package/src/ConversationPlace.mdx +53 -0
- package/src/ConversationPlace.stories.tsx +48 -0
- package/src/ConversationPlace.test.tsx +51 -0
- package/src/ConversationPlace.tsx +30 -0
- package/src/DocumentEditor.mdx +2 -1
- package/src/DocumentEditor.tsx +118 -64
- package/src/DocumentField.mdx +83 -0
- package/src/DocumentField.stories.tsx +110 -0
- package/src/DocumentField.test.tsx +281 -0
- package/src/DocumentField.tsx +199 -0
- package/src/EditableText.buttons.test.tsx +318 -0
- package/src/EditableText.mdx +50 -2
- package/src/EditableText.stories.tsx +96 -2
- package/src/EditableText.tsx +189 -5
- package/src/EmptyState.mdx +33 -8
- package/src/EmptyState.stories.tsx +26 -1
- package/src/EmptyState.test.tsx +63 -2
- package/src/EmptyState.tsx +28 -6
- package/src/Form.mdx +3 -1
- package/src/FormDialog.mdx +78 -0
- package/src/FormDialog.stories.tsx +90 -0
- package/src/FormDialog.test.tsx +183 -0
- package/src/FormDialog.tsx +93 -0
- package/src/InlineText.mdx +1 -0
- package/src/InlineText.tsx +2 -1
- package/src/Menu.test.tsx +80 -0
- package/src/Menu.tsx +35 -14
- package/src/MenuItem.mdx +12 -0
- package/src/MenuItem.stories.tsx +39 -1
- package/src/MoveDialog.mdx +85 -0
- package/src/MoveDialog.stories.tsx +134 -0
- package/src/MoveDialog.test.tsx +239 -0
- package/src/MoveDialog.tsx +186 -0
- package/src/NavItem.mdx +15 -0
- package/src/NavItem.stories.tsx +15 -0
- package/src/NavItem.test.tsx +64 -1
- package/src/NavItem.tsx +10 -2
- package/src/NavTree.mdx +26 -4
- package/src/NavTree.stories.tsx +59 -0
- package/src/NavTree.test.tsx +232 -2
- package/src/NavTree.tsx +93 -43
- package/src/PinnedComment.mdx +6 -1
- package/src/PinnedComment.stories.tsx +11 -1
- package/src/PinnedComment.tsx +15 -2
- package/src/ReactionHorizon.mdx +2 -0
- package/src/ReactionHorizon.stories.tsx +3 -0
- package/src/ReactionHorizon.test.tsx +32 -0
- package/src/ReactionHorizon.tsx +28 -11
- package/src/RepliesRow.mdx +6 -3
- package/src/RepliesRow.stories.tsx +3 -0
- package/src/RepliesRow.test.tsx +24 -0
- package/src/RepliesRow.tsx +12 -6
- package/src/ReplyCard.mdx +8 -0
- package/src/ReplyCard.stories.tsx +45 -1
- package/src/ResolveDialog.mdx +2 -0
- package/src/ResolveDialog.test.tsx +21 -0
- package/src/ResolveDialog.tsx +11 -39
- package/src/SelectionToolbar.tsx +2 -2
- package/src/Textarea.mdx +1 -0
- package/src/Thread.mdx +20 -1
- package/src/Thread.stories.tsx +94 -3
- package/src/Thread.test.tsx +11 -0
- package/src/Thread.tsx +56 -12
- package/src/commentBoxFrame.tsx +2 -2
- package/src/conversation.examples.tsx +10 -2
- package/src/conversationScroll.ts +155 -0
- package/src/editor.ts +1 -0
- package/src/editorSelection.test.tsx +53 -0
- package/src/eslint/no-field-outside-a-form.test.ts +4 -0
- package/src/eslint/no-field-outside-a-form.ts +2 -2
- package/src/eslint/no-native-title.ts +1 -1
- package/src/formBusy.ts +5 -2
- package/src/index.ts +16 -6
- package/src/looks.ts +10 -0
- package/src/registry/registry.test.ts +12 -6
- package/src/seenOnScreen.test.tsx +241 -0
- package/src/seenOnScreen.ts +146 -0
- package/src/showInConversation.test.tsx +168 -0
- package/src/showInConversation.ts +93 -0
- package/src/threadCard.ts +16 -0
- package/stories/Choosing.mdx +8 -3
- package/tailwind-preset.js +7 -0
package/src/Thread.tsx
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import { Children, type ReactNode, type Ref } from 'react'
|
|
1
|
+
import { Children, useCallback, useContext, useLayoutEffect, useRef, useState, type ReactNode, type Ref } from 'react'
|
|
2
2
|
import { IconX } from '@tabler/icons-react'
|
|
3
3
|
import { Chip } from './Chip'
|
|
4
4
|
import { cn } from './cn'
|
|
5
|
+
import { repliesDrawn, useSteadyScroll } from './conversationScroll'
|
|
5
6
|
import { Divider } from './Divider'
|
|
6
7
|
import { EmptyState } from './EmptyState'
|
|
7
8
|
import { IconButton } from './IconButton'
|
|
8
9
|
import { Panel } from './Panel'
|
|
9
10
|
import { PinnedComment, type PinnedCommentProps } from './PinnedComment'
|
|
11
|
+
import { useWatchSeen, type SeenOnScreen } from './seenOnScreen'
|
|
10
12
|
import { SkeletonConversation } from './Skeleton'
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
+
import { caretOnOpen, LineByLayout, SHOWN_CLASSES } from './threadCard'
|
|
14
|
+
|
|
15
|
+
/** A thread is placed as it opens, at its newest: the keeper may act from the first change of size. */
|
|
16
|
+
const always = () => true
|
|
13
17
|
|
|
14
18
|
/** The comment a thread answers, pinned at the top of its column. */
|
|
15
19
|
export interface ThreadStart extends PinnedCommentProps {
|
|
@@ -22,7 +26,7 @@ export interface ThreadProps {
|
|
|
22
26
|
place?: 'beside' | 'under'
|
|
23
27
|
/** The comment it answers, pinned at the top of the column. Under its comment it is not repeated. */
|
|
24
28
|
start?: ThreadStart
|
|
25
|
-
/** Its replies, in time order: `ReplyCard`s. How it was resolved is said on its comment, not among them (Katerina, 1 November). */
|
|
29
|
+
/** Its replies, in time order: `ReplyCard`s, each keyed by its own id. How it was resolved is said on its comment, not among them (Katerina, 1 November). */
|
|
26
30
|
children?: ReactNode
|
|
27
31
|
/** Still reading the replies: placeholders in their place. */
|
|
28
32
|
loading?: boolean
|
|
@@ -42,8 +46,10 @@ export interface ThreadProps {
|
|
|
42
46
|
empty?: ReactNode
|
|
43
47
|
/** The column's name. */
|
|
44
48
|
title?: ReactNode
|
|
45
|
-
/**
|
|
49
|
+
/** Beside: the column's scrolling box. Where it scrolls is the thread's: it opens at the newest reply and goes to each new one. */
|
|
46
50
|
bodyRef?: Ref<HTMLDivElement>
|
|
51
|
+
/** What `useSeenOnScreen` made for this thread: it watches its replies (each `ReplyCard`'s `id`), beside or under its comment, and says in it which were seen. */
|
|
52
|
+
seen?: SeenOnScreen
|
|
47
53
|
/** Placement only. */
|
|
48
54
|
className?: string
|
|
49
55
|
}
|
|
@@ -77,14 +83,50 @@ export function Thread({
|
|
|
77
83
|
empty = 'No replies yet.',
|
|
78
84
|
title = 'Replies',
|
|
79
85
|
bodyRef,
|
|
86
|
+
seen,
|
|
80
87
|
className,
|
|
81
88
|
}: ThreadProps) {
|
|
89
|
+
const body = useRef<HTMLDivElement>(null)
|
|
90
|
+
// The column's box is the thread's, and lent to the app as `bodyRef`.
|
|
91
|
+
const setBody = useCallback(
|
|
92
|
+
(el: HTMLDivElement | null) => {
|
|
93
|
+
body.current = el
|
|
94
|
+
if (typeof bodyRef === 'function') bodyRef(el)
|
|
95
|
+
else if (bodyRef) bodyRef.current = el
|
|
96
|
+
},
|
|
97
|
+
[bodyRef],
|
|
98
|
+
)
|
|
99
|
+
// A reply is read by being seen in its thread (Peek's PEE-44): each one is watched, beside in the column's box, and
|
|
100
|
+
// under its comment in the thread's own (one column; Ship, 2 November). The app's `bodyRef` stays the column's only.
|
|
101
|
+
const under = useRef<HTMLDivElement>(null)
|
|
102
|
+
useWatchSeen(seen, place === 'under' ? under : body, 'data-reply-id')
|
|
103
|
+
/*
|
|
104
|
+
Beside: it opens at its newest reply, before the paint, so it never shows its top for a frame and then jumps; and
|
|
105
|
+
it goes to the newest each time a reply is added, or another thread is drawn in it (Peek's OPT-9). Each ReplyCard
|
|
106
|
+
counts itself as it is first drawn in it: another thread's replies, keyed by their own ids, are drawn afresh and
|
|
107
|
+
take it to their newest whether or not it has a `start` and however many there are. A reply taken away (a delete)
|
|
108
|
+
is not counted, and the reader stays where they are (Peek's thread went to its bottom then). A line of the app's
|
|
109
|
+
own among them (a resolve history) takes it nowhere.
|
|
110
|
+
*/
|
|
111
|
+
const [drawn] = useState(() => ({ added: 0 }))
|
|
112
|
+
const last = useRef<{ added: number; start?: string } | null>(null)
|
|
113
|
+
const steady = useSteadyScroll(body, undefined, always, start?.id, place === 'beside')
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
const el = body.current
|
|
116
|
+
if (place !== 'beside' || !el) return
|
|
117
|
+
const now = { added: drawn.added, start: start?.id }
|
|
118
|
+
if (last.current && last.current.added === now.added && last.current.start === now.start) return
|
|
119
|
+
last.current = now
|
|
120
|
+
el.scrollTop = el.scrollHeight
|
|
121
|
+
// And it stays there while the replies' cards, chips and pictures fill in (OPT-10).
|
|
122
|
+
steady.rebase()
|
|
123
|
+
})
|
|
82
124
|
const foot = notice ?? box
|
|
83
125
|
// In a ConversationLayout the layout draws the line, from the comment's face to the last reply, as one bar.
|
|
84
126
|
const layoutLine = useContext(LineByLayout)
|
|
85
127
|
if (place === 'under') {
|
|
86
128
|
return (
|
|
87
|
-
<div data-thread="under" className={cn('flex flex-col', className)}>
|
|
129
|
+
<div ref={under} data-thread="under" className={cn('flex flex-col', className)}>
|
|
88
130
|
{(loading || anyIn(children)) && (
|
|
89
131
|
// The replies hang from a line under the comment's face (20px in: its 8px and half its 24px), one step in (Ship's way).
|
|
90
132
|
// 8px from the one card's right edge too, as the box under them: a hovered reply never touches it (Katerina, 31 October).
|
|
@@ -103,7 +145,7 @@ export function Thread({
|
|
|
103
145
|
return (
|
|
104
146
|
<Panel
|
|
105
147
|
className={className}
|
|
106
|
-
bodyRef={
|
|
148
|
+
bodyRef={setBody}
|
|
107
149
|
bodyClassName="flex flex-col"
|
|
108
150
|
title={title}
|
|
109
151
|
actions={
|
|
@@ -120,16 +162,18 @@ export function Thread({
|
|
|
120
162
|
footer={foot && <div className="p-3">{foot}</div>}
|
|
121
163
|
>
|
|
122
164
|
{start && (
|
|
123
|
-
<div className=
|
|
124
|
-
<PinnedComment author={start.author} time={start.time} words={start.words} deleted={start.deleted} />
|
|
165
|
+
<div className={cn('px-4 pb-2 pt-4', SHOWN_CLASSES)} data-thread-start={start.id}>
|
|
166
|
+
<PinnedComment author={start.author} time={start.time} at={start.at} words={start.words} deleted={start.deleted} />
|
|
125
167
|
</div>
|
|
126
168
|
)}
|
|
127
169
|
<Divider look="section" label="Replies" className="px-4 py-2" />
|
|
128
170
|
<div className="flex flex-col gap-2 px-4 pb-4">
|
|
129
171
|
<caretOnOpen.Provider value={0}>
|
|
130
|
-
<
|
|
131
|
-
{
|
|
132
|
-
|
|
172
|
+
<repliesDrawn.Provider value={drawn}>
|
|
173
|
+
<Replies loading={loading} empty={empty}>
|
|
174
|
+
{children}
|
|
175
|
+
</Replies>
|
|
176
|
+
</repliesDrawn.Provider>
|
|
133
177
|
</caretOnOpen.Provider>
|
|
134
178
|
</div>
|
|
135
179
|
</Panel>
|
package/src/commentBoxFrame.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import { Toolbar } from './Toolbar'
|
|
|
8
8
|
import { cn } from './cn'
|
|
9
9
|
import { richTextClassName } from './RichText'
|
|
10
10
|
import { ScrollArea } from './ScrollArea'
|
|
11
|
-
import { BOX_HINT_CLASSES, WRITING_BOX_CLASSES, WRITING_RING_CLASSES } from './looks'
|
|
11
|
+
import { BOX_HINT_CLASSES, EDITOR_SELECTION_CLASSES, WRITING_BOX_CLASSES, WRITING_RING_CLASSES } from './looks'
|
|
12
12
|
import { SelectionToolbar, type SelectionToolbarProps } from './SelectionToolbar'
|
|
13
13
|
import { isSuggestionActive } from './suggestionPopup'
|
|
14
14
|
|
|
@@ -23,7 +23,7 @@ import { isSuggestionActive } from './suggestionPopup'
|
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/** The classes the box's editor wears: rich text with no outline. It never scrolls itself; the box does, in a `ScrollArea`. */
|
|
26
|
-
export const COMPOSE_EDITOR_CLASSES = richTextClassName('default', 'outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1')
|
|
26
|
+
export const COMPOSE_EDITOR_CLASSES = richTextClassName('default', cn('outline-none w-full bg-transparent min-h-[20px] [&>p+p]:-mt-1', EDITOR_SELECTION_CLASSES))
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* A long draft stops at half the window and scrolls inside the box, so its
|
|
@@ -28,6 +28,9 @@ export const TWO = { name: 'Person two' }
|
|
|
28
28
|
export const THREE = { name: 'Person three' }
|
|
29
29
|
export const YOU = { name: 'You' }
|
|
30
30
|
|
|
31
|
+
/** A moment for a time's exact date under the pointer: 11:08 AM, on a placeholder day. */
|
|
32
|
+
export const AT = new Date(2026, 9, 31, 11, 8).getTime()
|
|
33
|
+
|
|
31
34
|
export const WORDS = 'A comment says what its author wrote. Its replies sit in the thread under it, and anyone here can react.'
|
|
32
35
|
export const SHORT = 'A reply answers the comment above it.'
|
|
33
36
|
export const LONG =
|
|
@@ -125,10 +128,15 @@ export function EditBox({ text, done, refuse = false }: { text: string; done: ()
|
|
|
125
128
|
const uploaded = (file: File): Promise<UploadAnswer> => new Promise((resolve) => setTimeout(() => resolve({ accepted: true, value: file.name }), 900))
|
|
126
129
|
|
|
127
130
|
/** The box a reply or a comment is written in, with its tools as an app gives them: the paperclip. */
|
|
128
|
-
export function WriteBox({ label = 'Reply', closed }: { label?: string; closed?: string }) {
|
|
129
|
-
|
|
131
|
+
export function WriteBox({ label = 'Reply', closed, onSend }: { label?: string; closed?: string; onSend?: (words: string) => void }) {
|
|
132
|
+
// With `onSend`, the app draws what was written at once, as Peek does, before the answer.
|
|
133
|
+
const send = onSend ? (body: JSONContent) => (onSend(plainOf(body)), saved()) : saved
|
|
134
|
+
return <CommentBox people={[]} label={label} placeholder={`${label}…`} send={send} showsAtOnce={!!onSend} upload={uploaded} closed={closed ? { reason: closed } : undefined} />
|
|
130
135
|
}
|
|
131
136
|
|
|
137
|
+
/** The words of a box's body, plain. */
|
|
138
|
+
const plainOf = (body: JSONContent): string => (body.text ?? '') + (body.content ?? []).map(plainOf).join(body.type === 'doc' ? ' ' : '')
|
|
139
|
+
|
|
132
140
|
/** A column's width: 384px, every app's right column. */
|
|
133
141
|
export function Column({ children }: { children: ReactNode }) {
|
|
134
142
|
return <div className="flex w-[384px] flex-col gap-2">{children}</div>
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { createContext, useEffect, useState, type RefObject } from 'react'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Where a conversation scrolls, Peek's way, moved into the kit (C1 of the audit of 2 November): it opens at the newest
|
|
5
|
+
* comment, comes back to where the reader left it, follows what arrives only while the reader is at the bottom, goes
|
|
6
|
+
* down to the reader's own comment as it is sent, and holds still while cards and pictures fill in. ConversationLayout
|
|
7
|
+
* and Thread use it; nothing here is for an app to call but `useLeftAt`.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* How close to the bottom still counts as at the bottom. Not zero: `scrollHeight - scrollTop - clientHeight` is rarely
|
|
12
|
+
* exactly zero (display scaling, zoom and fractional pixel ratios leave a fraction while the last comment is squarely
|
|
13
|
+
* in view), and a strict check would make following work on one machine and not another. 80px is about one comment,
|
|
14
|
+
* so a glance at the line above still counts as watching. Peek's NEAR_BOTTOM_PX.
|
|
15
|
+
*/
|
|
16
|
+
export const NEAR_BOTTOM_PX = 80
|
|
17
|
+
|
|
18
|
+
/** Whether the box is close enough to the bottom to follow what arrives. */
|
|
19
|
+
export function isNearBottom(el: HTMLElement): boolean {
|
|
20
|
+
return el.scrollHeight - el.scrollTop - el.clientHeight <= NEAR_BOTTOM_PX
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The comment at the top of a conversation's view, and how far below the view's top it is: what "the same spot" means
|
|
25
|
+
* to the reader, whatever above it changed height.
|
|
26
|
+
*/
|
|
27
|
+
export function anchorIn(el: HTMLElement): { id: string; top: number } | undefined {
|
|
28
|
+
// jsdom has no layout: no anchor, and the restore keeps the plain offset.
|
|
29
|
+
if (typeof document.elementFromPoint !== 'function') return undefined
|
|
30
|
+
const box = el.getBoundingClientRect()
|
|
31
|
+
// A gap between cards, or a day line, is passed over a few pixels at a time.
|
|
32
|
+
for (let y = box.top + 1; y < box.top + 96; y += 8) {
|
|
33
|
+
const marker = document.elementFromPoint(box.left + box.width / 2, y)?.closest<HTMLElement>('[data-conversation-item]')
|
|
34
|
+
const card = marker?.firstElementChild
|
|
35
|
+
if (marker?.dataset.conversationItem && card) return { id: marker.dataset.conversationItem, top: card.getBoundingClientRect().top - box.top }
|
|
36
|
+
}
|
|
37
|
+
return undefined
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The card of the comment `id` in `el`: the first child of its `data-conversation-item`. */
|
|
41
|
+
export const cardIn = (el: HTMLElement, id: string) => el.querySelector(`[data-conversation-item="${CSS.escape(id)}"]`)?.firstElementChild ?? null
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Keeps a conversation where the reader is while what is in it changes size: a card, a chip or a picture filling in, a
|
|
45
|
+
* card shown or hidden (Peek's OPT-10).
|
|
46
|
+
*
|
|
47
|
+
* At the bottom (`atBottom`, the view's own judgement), it stays the same distance from the bottom, so the newest
|
|
48
|
+
* comments stay in view as a card above them loads. Anywhere else, the comment at the top of the view stays at the same
|
|
49
|
+
* height. Browsers that anchor scrolling themselves (Chromium, Firefox) do the second only for what changes above the
|
|
50
|
+
* view, and only roughly; Safari does neither, and a conversation there was pushed thousands of pixels off its bottom
|
|
51
|
+
* by one card.
|
|
52
|
+
*
|
|
53
|
+
* Only once `ready()` says the conversation has been placed: before that, where it lands is the view's to decide.
|
|
54
|
+
* Without `atBottom` (a thread), "at the bottom" is where the last scroll left it. `rebase()` takes it again from where
|
|
55
|
+
* the box is now, at the bottom: a thread that just went down to a new reply.
|
|
56
|
+
*/
|
|
57
|
+
export function useSteadyScroll(
|
|
58
|
+
scrollRef: RefObject<HTMLElement | null>,
|
|
59
|
+
atBottom: RefObject<boolean> | undefined,
|
|
60
|
+
ready: () => boolean,
|
|
61
|
+
key: unknown,
|
|
62
|
+
enabled: boolean,
|
|
63
|
+
): { rebase: () => void } {
|
|
64
|
+
const [handle] = useState(() => ({ rebase: () => {} }))
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
const el = scrollRef.current
|
|
67
|
+
if (!enabled || !el || typeof ResizeObserver === 'undefined') return
|
|
68
|
+
let fromBottom = 0
|
|
69
|
+
let lastTop = 0
|
|
70
|
+
let anchor: ReturnType<typeof anchorIn>
|
|
71
|
+
let scrolledToBottom = true
|
|
72
|
+
const bottom = () => (atBottom ? atBottom.current : scrolledToBottom)
|
|
73
|
+
const remember = () => {
|
|
74
|
+
fromBottom = el.scrollHeight - el.scrollTop - el.clientHeight
|
|
75
|
+
lastTop = el.scrollTop
|
|
76
|
+
anchor = bottom() ? undefined : anchorIn(el)
|
|
77
|
+
}
|
|
78
|
+
remember()
|
|
79
|
+
handle.rebase = () => {
|
|
80
|
+
scrolledToBottom = true
|
|
81
|
+
remember()
|
|
82
|
+
}
|
|
83
|
+
const onScroll = () => {
|
|
84
|
+
scrolledToBottom = isNearBottom(el)
|
|
85
|
+
remember()
|
|
86
|
+
}
|
|
87
|
+
const keep = () => {
|
|
88
|
+
if (!ready()) return remember()
|
|
89
|
+
if (bottom()) {
|
|
90
|
+
// The distance it was left at, unless the view was moved down to the live edge since (a new comment followed,
|
|
91
|
+
// before its scroll event): that move stands, rather than being put back.
|
|
92
|
+
const now = el.scrollHeight - el.scrollTop - el.clientHeight
|
|
93
|
+
const keepAt = el.scrollTop > lastTop && now < fromBottom ? now : fromBottom
|
|
94
|
+
const top = el.scrollHeight - el.clientHeight - Math.max(0, keepAt)
|
|
95
|
+
if (Math.abs(el.scrollTop - top) >= 1) el.scrollTop = top
|
|
96
|
+
} else if (anchor) {
|
|
97
|
+
const card = cardIn(el, anchor.id)
|
|
98
|
+
if (card) {
|
|
99
|
+
const moved = card.getBoundingClientRect().top - el.getBoundingClientRect().top - anchor.top
|
|
100
|
+
if (Math.abs(moved) >= 1) el.scrollTop += moved
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
remember()
|
|
104
|
+
}
|
|
105
|
+
el.addEventListener('scroll', onScroll, { passive: true })
|
|
106
|
+
// The scroller for its own height (the box under it grows), its content for everything in it.
|
|
107
|
+
const observer = new ResizeObserver(keep)
|
|
108
|
+
observer.observe(el)
|
|
109
|
+
for (const child of el.children) observer.observe(child)
|
|
110
|
+
return () => {
|
|
111
|
+
handle.rebase = () => {}
|
|
112
|
+
el.removeEventListener('scroll', onScroll)
|
|
113
|
+
observer.disconnect()
|
|
114
|
+
}
|
|
115
|
+
}, [scrollRef, atBottom, ready, key, enabled, handle])
|
|
116
|
+
return handle
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Where each conversation was left in this tab (Peek's OPT-3), by the name the app gave it (`rememberAs`): at the
|
|
121
|
+
* bottom or at an offset, the comment at the top of the view and how far down it sat, and when (ms). Not per reader:
|
|
122
|
+
* it holds no words.
|
|
123
|
+
*/
|
|
124
|
+
export const places = new Map<string, { atBottom: boolean; offset: number; anchor?: { id: string; top: number }; leftAt: number }>()
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* When the reader last left the conversation `key` (a `ConversationLayout`'s `rememberAs`) away from its newest
|
|
128
|
+
* comment, in ms since 1970: what an app draws its "New" line from, over the first comment written since. `null` when
|
|
129
|
+
* it was left at the newest, or not opened before in this tab. Taken once per visit, as the conversation opens: later
|
|
130
|
+
* scrolling moves the record, not the line.
|
|
131
|
+
*/
|
|
132
|
+
export function useLeftAt(key: string | null | undefined): number | null {
|
|
133
|
+
const [taken, setTaken] = useState<{ key: string; at: number | null }>()
|
|
134
|
+
// Nothing shown: the visit is over, and the next one, to the same conversation too, takes it again.
|
|
135
|
+
if (!key && taken) setTaken(undefined)
|
|
136
|
+
if (key && taken?.key !== key) {
|
|
137
|
+
const left = places.get(key)
|
|
138
|
+
const at = left && !left.atBottom ? left.leftAt : null
|
|
139
|
+
setTaken({ key, at })
|
|
140
|
+
return at
|
|
141
|
+
}
|
|
142
|
+
return key && taken?.key === key ? taken.at : null
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Set by ConversationLayout round its own box, read by CommentBox: the reader's own comment brings them down to it as
|
|
147
|
+
* it is drawn, before the relay has answered (Peek's OPT-6), and a refusal leaves where they actually are to decide.
|
|
148
|
+
*/
|
|
149
|
+
export const sendsInLayout = createContext<{ sending: () => void; refused: () => void } | null>(null)
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Set by a Thread round its replies, counted by each ReplyCard as it is first drawn in it: a new reply, or another
|
|
153
|
+
* thread's replies, take the thread to its newest; a reply taken away (a delete) is never counted, and moves nothing.
|
|
154
|
+
*/
|
|
155
|
+
export const repliesDrawn = createContext<{ added: number } | null>(null)
|
package/src/editor.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
/**
|
|
3
|
+
* Every editor in the kit paints the words you select in `bg-selected`: the
|
|
4
|
+
* colour the selection strip's kept selection paints them while its link field
|
|
5
|
+
* has the focus (`KeptSelection`), so selected and kept look the same. Peek
|
|
6
|
+
* painted it with a rule of its own over every editor (`.tiptap ::selection`,
|
|
7
|
+
* PEE-19); Ship and Leaf painted nothing, and showed the browser's.
|
|
8
|
+
*
|
|
9
|
+
* jsdom draws no selection, so this pins the class that paints it on each
|
|
10
|
+
* editor's text, as `heights.test.tsx` pins a class jsdom cannot measure. In
|
|
11
|
+
* Chrome the selection's computed background is the token's value (the record).
|
|
12
|
+
*/
|
|
13
|
+
import { afterEach, beforeAll, describe, expect, it, vi } from 'vitest'
|
|
14
|
+
import { cleanup, render, screen } from '@testing-library/react'
|
|
15
|
+
import type { JSONContent } from '@tiptap/react'
|
|
16
|
+
import { CommentBox } from './CommentBox'
|
|
17
|
+
import { DocumentEditor, type DocumentCodec } from './DocumentEditor'
|
|
18
|
+
import { InlineText } from './InlineText'
|
|
19
|
+
|
|
20
|
+
beforeAll(() => {
|
|
21
|
+
Element.prototype.scrollIntoView = vi.fn()
|
|
22
|
+
Element.prototype.getClientRects = () => [] as unknown as DOMRectList
|
|
23
|
+
Range.prototype.getClientRects = () => [] as unknown as DOMRectList
|
|
24
|
+
Range.prototype.getBoundingClientRect = () => new DOMRect()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
afterEach(cleanup)
|
|
28
|
+
|
|
29
|
+
const PAINTS_SELECTION = 'selection:bg-bg-selected'
|
|
30
|
+
const paints = (name: string) => (screen.getByRole('textbox', { name }).getAttribute('class') ?? '').split(/\s+/).includes(PAINTS_SELECTION)
|
|
31
|
+
|
|
32
|
+
const codec: DocumentCodec = {
|
|
33
|
+
read: (value) => JSON.parse(value) as JSONContent,
|
|
34
|
+
write: (doc) => ({ value: JSON.stringify(doc) }),
|
|
35
|
+
}
|
|
36
|
+
const DOC = JSON.stringify({ type: 'doc', content: [{ type: 'paragraph', content: [{ type: 'text', text: 'Words' }] }] })
|
|
37
|
+
|
|
38
|
+
describe('an editor paints the words you select in the selected colour', () => {
|
|
39
|
+
it('the comment box', () => {
|
|
40
|
+
render(<CommentBox label="Box" placeholder="Write" people={[]} send={async () => ({ accepted: true })} />)
|
|
41
|
+
expect(paints('Box')).toBe(true)
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
it('the document editor', () => {
|
|
45
|
+
render(<DocumentEditor value={DOC} format="blocks" codec={codec} label="Document" onCommit={() => true} />)
|
|
46
|
+
expect(paints('Document')).toBe(true)
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('a line of text edited in place', () => {
|
|
50
|
+
render(<InlineText value="Item one" placeholder="Untitled" label="Title" onCommit={() => true} />)
|
|
51
|
+
expect(paints('Title')).toBe(true)
|
|
52
|
+
})
|
|
53
|
+
})
|
|
@@ -40,6 +40,10 @@ tester.run('no-field-outside-a-form', noFieldOutsideAForm, {
|
|
|
40
40
|
{ name: 'a one-line field with its button', code: component('<Form onSubmit={() => {}}><TextInput value={text} onChange={(e) => set(e.target.value)} /></Form>', ui('Form', 'TextInput')) },
|
|
41
41
|
{ name: 'fields drawn from a list, inside the form', code: component("<Form onSubmit={() => {}}>{['a', 'b'].map((k) => <Field key={k} label={k}><TextInput value={text} /></Field>)}</Form>", ui('Form', 'Field', 'TextInput')) },
|
|
42
42
|
{ name: "the palette's form level is a Form (UIG-29)", code: component('<CommandPaletteForm submitLabel="Create" onSubmit={() => {}}><Field label="Title"><TextInput value={text} /></Field></CommandPaletteForm>', ui('CommandPaletteForm', 'Field', 'TextInput')) },
|
|
43
|
+
{
|
|
44
|
+
name: "FormDialog is a Form: Peek's New folder dialog",
|
|
45
|
+
code: component('<FormDialog title="New folder" submitLabel="Create" onClose={() => {}} onSubmit={() => {}}>\n<Field label="Name"><TextInput value={text} onChange={(e) => set(e.target.value)} /></Field>\n</FormDialog>', ui('FormDialog', 'Field', 'TextInput')),
|
|
46
|
+
},
|
|
43
47
|
{ name: 'a field that saves itself as you leave it', code: component('<EditableText value={text} onCommit={set} />', ui('EditableText')) },
|
|
44
48
|
{ name: 'a field that filters a list', code: component('<SearchInput value={text} onChange={set} />', ui('SearchInput')) },
|
|
45
49
|
{
|
|
@@ -9,8 +9,8 @@ import { bindingOfTag, partsOfFile, type Node, type Parser, type PartBinding } f
|
|
|
9
9
|
*/
|
|
10
10
|
export const FIELD_PARTS = ['Field', 'TextInput', 'Textarea'] as const
|
|
11
11
|
|
|
12
|
-
/** The parts that are a `Form`: the package's own,
|
|
13
|
-
export const FORM_PARTS = ['Form', 'CommandPaletteForm'] as const
|
|
12
|
+
/** The parts that are a `Form`: the package's own, the palette's form level (UIG-29), and `FormDialog`, a dialog that draws one. */
|
|
13
|
+
export const FORM_PARTS = ['Form', 'CommandPaletteForm', 'FormDialog'] as const
|
|
14
14
|
|
|
15
15
|
const child = (node: Node, key: string) => node[key] as Node | null | undefined
|
|
16
16
|
const nameOf = (node: Node | null | undefined): string | undefined =>
|
|
@@ -8,7 +8,7 @@ import { bindingOfTag, partsOfFile, type Node, type Parser, type PartBinding } f
|
|
|
8
8
|
* the browser shows it as its tooltip. `no-native-title.test.ts` holds this
|
|
9
9
|
* list to the catalogue: a part that gains a `title` of its own joins it.
|
|
10
10
|
*/
|
|
11
|
-
export const PARTS_WITH_A_TITLE = ['CollapsibleSection', 'ConfirmDialog', 'ContainerHeader', 'ConversationLayout', 'DialogShell', 'ListColumn', 'NavTree', 'NavTreeSection', 'PageHeader', 'Panel', 'SectionHeader', 'Thread'] as const
|
|
11
|
+
export const PARTS_WITH_A_TITLE = ['ArchiveDialog', 'CollapsibleSection', 'ConfirmDialog', 'ContainerHeader', 'ConversationLayout', 'DialogShell', 'FormDialog', 'ListColumn', 'MoveDialog', 'NavTree', 'NavTreeSection', 'PageHeader', 'Panel', 'SectionHeader', 'Thread'] as const
|
|
12
12
|
|
|
13
13
|
const child = (node: Node, key: string) => node[key] as Node | null | undefined
|
|
14
14
|
const nameOf = (node: Node | null | undefined): string | undefined =>
|
package/src/formBusy.ts
CHANGED
|
@@ -9,11 +9,14 @@ import { createContext, useContext } from 'react'
|
|
|
9
9
|
* told, so it kept its normal look while it could not be pressed, and a
|
|
10
10
|
* Checkbox, which is a `<span>`, could still be ticked (Katerina saw the busy
|
|
11
11
|
* story's button unchanged, 16 September). Those parts read this and switch
|
|
12
|
-
* off the way their own `disabled` does
|
|
13
|
-
*
|
|
12
|
+
* off the way their own `disabled` does; so does the editor's DocumentField,
|
|
13
|
+
* whose box no fieldset reaches. Not for an app: it is the package's wiring
|
|
14
|
+
* between Form and its parts, exported from the main entry only because the
|
|
15
|
+
* editor's bundle reads it from there (one context, as `caretOnOpen`).
|
|
14
16
|
*/
|
|
15
17
|
export const FormBusyContext = createContext(false)
|
|
16
18
|
|
|
19
|
+
/** Whether a `Form` around this is sending: its fields and buttons wait. The kit's parts read it; an app has no need to. */
|
|
17
20
|
export function useFormBusy(): boolean {
|
|
18
21
|
return useContext(FormBusyContext)
|
|
19
22
|
}
|
package/src/index.ts
CHANGED
|
@@ -9,12 +9,13 @@
|
|
|
9
9
|
* `src/` still ships in the tarball, so stepping into a component lands on the
|
|
10
10
|
* TypeScript that produced it.
|
|
11
11
|
*/
|
|
12
|
-
export { AppProvider, type AppProviderProps } from './AppProvider'
|
|
12
|
+
export { AppProvider, isPlainClick, type AppProviderProps } from './AppProvider'
|
|
13
13
|
export { AppShell, useSidebarFold, type AppShellProps, type SidebarFoldOptions } from './AppShell'
|
|
14
14
|
export { AttachmentCard, type AttachmentCardProps, type AttachmentCardState } from './AttachmentCard'
|
|
15
15
|
export { Avatar, hueFor, initialsFor, type AvatarProps } from './Avatar'
|
|
16
16
|
export { AvatarGroup, type AvatarGroupMember, type AvatarGroupProps } from './AvatarGroup'
|
|
17
17
|
export { MembersPill, type MembersPillProps } from './MembersPill'
|
|
18
|
+
export { MoveDialog, type MoveChoice, type MoveDialogProps, type MoveFolder, type MovePlace } from './MoveDialog'
|
|
18
19
|
export { MembersDialog, type MembersDialogCandidate, type MembersDialogMember, type MembersDialogProps, type MembersDialogSelfAction } from './MembersDialog'
|
|
19
20
|
export { Banner, type BannerProps, type BannerTone } from './Banner'
|
|
20
21
|
export { BlockHandle, blockAtY, type BlockHandleProps, type BlockHandleEditing, type HandleBlock } from './BlockHandle'
|
|
@@ -61,13 +62,16 @@ export { Tooltip, TooltipProvider, WithTooltip, type TooltipProps, type TooltipP
|
|
|
61
62
|
export { Field, FieldLine, type FieldLineProps, type FieldLineTone, type FieldProps } from './Field'
|
|
62
63
|
export { FilePicker, type FilePickerProps } from './FilePicker'
|
|
63
64
|
export { Form, type FormProps } from './Form'
|
|
65
|
+
// Whether a Form around it is sending: the kit's own wiring, read by the editor's DocumentField from this entry (one context).
|
|
66
|
+
export { useFormBusy } from './formBusy'
|
|
67
|
+
export { FormDialog, type FormDialogProps } from './FormDialog'
|
|
64
68
|
export { Select, type SelectOption, type SelectProps } from './Select'
|
|
65
69
|
export { TextInput, type TextInputProps } from './TextInput'
|
|
66
70
|
export { Textarea, type TextareaProps } from './Textarea'
|
|
67
|
-
export { ConfirmDialog, type ConfirmDialogProps } from './ConfirmDialog'
|
|
71
|
+
export { ConfirmDialog, type ConfirmDialogAlternative, type ConfirmDialogProps } from './ConfirmDialog'
|
|
68
72
|
export { DialogShell, type DialogShellProps } from './DialogShell'
|
|
69
73
|
export { Divider, type DividerProps } from './Divider'
|
|
70
|
-
export { EditableText, type EditableTextProps } from './EditableText'
|
|
74
|
+
export { EditableText, type EditableTextAnswer, type EditableTextOutcome, type EditableTextProps } from './EditableText'
|
|
71
75
|
export { EmptyState, type EmptyStateProps } from './EmptyState'
|
|
72
76
|
export { EntryShell, type EntryShellProps } from './EntryShell'
|
|
73
77
|
export { ErrorBoundary, type ErrorBoundaryProps } from './ErrorBoundary'
|
|
@@ -77,7 +81,7 @@ export { Breadcrumb, type BreadcrumbProps, type Crumb } from './Breadcrumb'
|
|
|
77
81
|
export { EnterHint, Menu, MenuItem, MenuPanel, MenuRow, MenuSection, MenuSeparator, MenuSub, type MenuItemProps, type MenuPanelProps, type MenuProps, type MenuSubProps } from './Menu'
|
|
78
82
|
export { NavItem, type NavItemProps } from './NavItem'
|
|
79
83
|
export { UnreadDot } from './UnreadDot'
|
|
80
|
-
export { NavTree, NavTreeSection, type NavTreeGroup, type NavTreeNode, type NavTreeProps, type NavTreeSectionProps } from './NavTree'
|
|
84
|
+
export { NAV_TREE_PENDING_MS, NavTree, NavTreeSection, type NavTreeGroup, type NavTreeNode, type NavTreeProps, type NavTreeSectionProps } from './NavTree'
|
|
81
85
|
export { Popover, type PopoverProps } from './Popover'
|
|
82
86
|
export { SuggestionMenu, type SuggestionMenuHandle, type SuggestionMenuProps, type SuggestionMenuRow, type SuggestionMenuSection } from './SuggestionMenu'
|
|
83
87
|
export { ScrollArea, type ScrollAreaProps } from './ScrollArea'
|
|
@@ -122,7 +126,7 @@ export { LinkChip, type LinkChipProps } from './LinkChip'
|
|
|
122
126
|
export { LinkRow, LinkUnavailable, type LinkRowProps, type LinkUnavailableProps } from './LinkRow'
|
|
123
127
|
export { LinkCard, LinkCardLoading, type LinkCardProps, type LinkCardLoadingProps } from './LinkCard'
|
|
124
128
|
export { LinkPreview, LinkPreviewOpen, useCanHover, type LinkPreviewProps } from './LinkPreview'
|
|
125
|
-
export { AttachedCard, type AttachedCardProps } from './AttachedCard'
|
|
129
|
+
export { AttachedCard, type AttachedCardMemory, type AttachedCardProps } from './AttachedCard'
|
|
126
130
|
export { PartCard, type PartCardProps, type PartCardState } from './PartCard'
|
|
127
131
|
export { Person, type PersonProps } from './Person'
|
|
128
132
|
export { Rail, type RailProps } from './Rail'
|
|
@@ -137,7 +141,10 @@ export { ConversationCard, ReplyCard, type ConversationCardProps, type Conversat
|
|
|
137
141
|
export { ConversationLayout, type ConversationItem, type ConversationLayoutProps } from './ConversationLayout'
|
|
138
142
|
// The box at a thread's foot takes the caret when a ConversationLayout opens it: one context, shared with the editor's CommentBox.
|
|
139
143
|
export { caretOnOpen } from './threadCard'
|
|
144
|
+
// Where a two-column conversation was left, for the app's "New" line; and the layout's word to its box that the reader's own comment is on its way (CommentBox reads it, from the editor's bundle).
|
|
145
|
+
export { useLeftAt, sendsInLayout } from './conversationScroll'
|
|
140
146
|
export { ConversationMenu, type ConversationMenuProps } from './ConversationMenu'
|
|
147
|
+
export { ConversationPlace, type ConversationPlaceProps } from './ConversationPlace'
|
|
141
148
|
export { EditedMarker, type EditedMarkerProps } from './EditedMarker'
|
|
142
149
|
export { MetaText, type MetaTextProps } from './MetaText'
|
|
143
150
|
export { QuotedLine, type QuotedLineProps } from './QuotedLine'
|
|
@@ -145,8 +152,11 @@ export { ReactionHorizon, type ReactionHorizonProps } from './ReactionHorizon'
|
|
|
145
152
|
export { RepliesRow, type RepliesRowProps } from './RepliesRow'
|
|
146
153
|
export { ResolveDialog, type ResolveDialogProps } from './ResolveDialog'
|
|
147
154
|
export { PinnedComment, type PinnedCommentProps } from './PinnedComment'
|
|
155
|
+
export { ArchiveDialog, type ArchiveDialogProps } from './ArchiveDialog'
|
|
148
156
|
export { ArchivedNotice, type ArchivedNoticeProps } from './ArchivedNotice'
|
|
149
157
|
export { Thread, type ThreadProps, type ThreadStart } from './Thread'
|
|
158
|
+
export { useSeenOnScreen, type SeenOnScreen } from './seenOnScreen'
|
|
159
|
+
export { showInConversation, showInConversationWhenDrawn, type ShowOptions, type ShowWhenDrawnOptions } from './showInConversation'
|
|
150
160
|
export { UrgentMark } from './UrgentMark'
|
|
151
161
|
export { ReactionRow, AddReactionButton, whoReacted, type ReactionRowProps, type AddReactionButtonProps, type ReactionCount } from './ReactionRow'
|
|
152
162
|
export { SearchInput, type SearchInputProps } from './SearchInput'
|
|
@@ -155,7 +165,7 @@ export { ContainerHeader, type ContainerHeaderProps } from './ContainerHeader'
|
|
|
155
165
|
export { Panel, type PanelProps } from './Panel'
|
|
156
166
|
export { PageHeader, type PageHeaderMeta, type PageHeaderProps } from './PageHeader'
|
|
157
167
|
export { ListColumn, type ListColumnProps } from './ListColumn'
|
|
158
|
-
export { CollapsibleSection, type CollapsibleSectionProps } from './CollapsibleSection'
|
|
168
|
+
export { CollapsibleSection, useRememberedOpen, type CollapsibleSectionProps } from './CollapsibleSection'
|
|
159
169
|
export { SectionLabel } from './SectionLabel'
|
|
160
170
|
export { Tabs, type TabDef, type TabsProps } from './Tabs'
|
|
161
171
|
export { Toast, ToastProvider, useToast, type ToastOptions, type ToastProps, type ToastType } from './Toast'
|
package/src/looks.ts
CHANGED
|
@@ -34,6 +34,9 @@ export const FIELD_SIZE_CLASSES = {
|
|
|
34
34
|
/** The box around an input that sits inside it, before its focus look: SearchInput and ChipInput. */
|
|
35
35
|
export const FIELD_SHELL_CLASSES = 'bg-bg-field border border-border-field shadow-field hover:border-border-strong group-hover/field:border-border-strong rounded-lg transition-colors'
|
|
36
36
|
|
|
37
|
+
/** That box focused, while what is typed in it has the focus: the focus border, held under the pointer, and Signal's ring. ChipInput and DocumentField. */
|
|
38
|
+
export const FIELD_SHELL_FOCUS_CLASSES = 'focus-within:border-border-focus focus-within:hover:border-border-focus group-hover/field:focus-within:border-border-focus signal:transition-shadow signal:focus-within:shadow-focus-ring'
|
|
39
|
+
|
|
37
40
|
/** A panel that floats over the page: Menu's panel and Tooltip. */
|
|
38
41
|
export const FLOATING_SURFACE_CLASSES = 'rounded-lg border border-border-default bg-bg-elevated shadow-lg'
|
|
39
42
|
|
|
@@ -92,6 +95,13 @@ export const COLLAPSIBLE_PANEL_CLASSES = 'h-[var(--collapsible-panel-height)] ov
|
|
|
92
95
|
// A field's fill and edge, as every field has (Katerina, 31 October: the comment box is a field, and every field has its fill).
|
|
93
96
|
export const WRITING_BOX_CLASSES = 'relative bg-bg-field border border-border-field rounded-lg p-3 flex flex-col gap-4'
|
|
94
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Selected words in an editor: the selected thing's fill, the colour the selection strip's kept selection paints
|
|
100
|
+
* while its link field has the focus (`KeptSelection`), so the words look the same selected and kept. Peek's
|
|
101
|
+
* composer rule (PEE-19), moved into every editor: the comment box, the document editor and InlineText.
|
|
102
|
+
*/
|
|
103
|
+
export const EDITOR_SELECTION_CLASSES = 'selection:bg-bg-selected'
|
|
104
|
+
|
|
95
105
|
/** The keys under the send box, in words: "Enter to send · Shift+Enter new line". One line, cut when the room runs out; no key caps. The edit box writes none (Katerina, 1 November). */
|
|
96
106
|
export const BOX_HINT_CLASSES = 'min-w-0 truncate select-none text-caption text-text-muted signal:font-mono signal:text-menu signal:font-normal signal:tracking-wider'
|
|
97
107
|
|
|
@@ -48,20 +48,20 @@ describe('the registry builds', () => {
|
|
|
48
48
|
expect(registry.entries.map((one) => one.name).sort()).toEqual(values.map((one) => one.name).sort())
|
|
49
49
|
})
|
|
50
50
|
|
|
51
|
-
it('counts
|
|
51
|
+
it('counts 243 names over 123 files: 160 components, 76 helpers and 7 hooks (useFormBusy, whether a Form around it is sending, read by the editor’s DocumentField from the main entry, in the review of 2 November; useLeftAt, sendsInLayout, useSeenOnScreen, showInConversation and showInConversationWhenDrawn, where a conversation scrolls, what was seen and a link landing on a comment, moved from Peek for every app, on 2 November; useRememberedOpen, the fold a section remembers, read by the app, and NAV_TREE_PENDING_MS and isPlainClick, Peek’s Folder timer and plain-click check, moved in, on 2 November; FormDialog, MoveDialog and ArchiveDialog, the dialogs Peek wired by hand, on 2 November; ConversationPlace, the line saying where a comment was said, and DocumentField, a rich-text field of a form, moved from Peek, on 2 November; ArchivedNotice, the card on an archived file, from Peek, Ship and Leaf, on 31 October; caretOnOpen, the box at a thread’s foot taking the caret when a ConversationLayout opens it, without scrolling, on 31 October; the conversation from Peek for every app, with PageHeader and PinnedComment, on 31 October, and ResolutionNote and ResolutionHistory gone with the resolved looks not picked, on 1 November; useSidebarFold, a folded sidebar kept folded in every app, on 31 October; cardShapeMemory, a card’s last shape on this device, lifted from Peek and Ship for Leaf, and ReferenceCards and useReferenceCards gone with their deprecated page, in the widget review, on 30 October; inTheBox, a card or part in a box being written in, on the files’ fill and in words, on 29 October; archivedLine, the line on an archived file in every app (PEEKM-2), on 23 October; keepCommentBoxWarm, a box built ahead, exported as 0.84.0 promised (PEEKM-1), on 21 October;linkedFrom and linkStateFrom, one card for a file in every app (5ebf2756), on 21 October; ComposeBox, ComposeKeys and COMPOSE_EDITOR_CLASSES gone into CommentBox’s own frame (one box), on 21 October; LinkPlaces with linkPlaceAt and staysChip, a link in a document drawn where it sits (WBD-4), on 20 October; DocumentEditor, one document editor for every app, and PersonReference, `@` in a document (WBD-3), on 20 October; toggleTableHeaderRow, a table’s header row on and off (LEAF-12), on 19 October;EntryShell, the screen while nobody is signed in, moved from Peek (AUT-3), on 17 October; CommentBox with commentBoxRows, and ReactionRow with AddReactionButton and whoReacted, the shared comment box and reaction row (COMM-2), on 17 October; the link widgets — LinkChip, LinkRow, LinkCard, CardUnder, PartCard, LinkPreview and their parts, with useCanHover, chosenOf, loadingShapeOf and unavailableMemory — from the Widgets 2 prototype, on 16 October; InlineText, a title or the line under it edited where it stands (SUM-4), on 16 October; ComposeBox with ComposeKeys and its classes, CommentHighlights with its five helpers, and keepSelection and releaseSelection, from the Leaf prototype (LEAF-4), on 16 October;NavTree, NavTreeSection, the composer triggers and UnreadDot joined on 2 October; BlockHandle and EditorBlockHandle (RIC-18) on 2 October, moveBlock and blockDropCursor, the drop in the gutter, on 5 October, MembersPill and MembersDialog, moved from Peek (SHI-31), on 6 October, ShowMore on 7 October, AppProvider on 8 October, and KindIcon, thingKindOf and PastedImages with its two helpers, moved from Peek, on 8 October; CodeBlockColours, the coloured code block of the editor, on 9 October; Checklist, Callout, isChecklistTick and calloutLook (RIC-19) on 13 October; EditorTableControls and its four actions (RIC-21) on 13 October; ReferenceCards, useReferenceCards and its three helpers, the card a chip in a document asks for, on 14 October; LinkChips and its two helpers, a URL in a document read as its chip, on 14 October; ReferenceMenu, ReferenceMenuView and three helpers, the menu of a chip while writing, on 14 October; PastedMarkdown, markdown pasted as the blocks it spells (LEAF-10), on 15 October; turnIntoRows, turnListInto and turnQuoteInto, the block menu’s Turn into for a list and a quote (LEAF-11), on 15 October)', () => {
|
|
52
52
|
// The reconciliation GATES.md §24 explains. If this changes, that changes.
|
|
53
53
|
// The `EDITOR_EXTENSIONS` count as components by their names; they are
|
|
54
54
|
// editor extensions, documented on SelectionToolbar's, BlockNodes' and
|
|
55
55
|
// ComposerTriggers' pages.
|
|
56
56
|
const kinds = registry.entries.reduce<Record<string, number>>((all, one) => ({ ...all, [one.kind]: (all[one.kind] ?? 0) + 1 }), {})
|
|
57
|
-
expect(kinds).toEqual({ component:
|
|
58
|
-
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(
|
|
57
|
+
expect(kinds).toEqual({ component: 160, helper: 76, hook: 7 })
|
|
58
|
+
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(123)
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
it('gives every entry a purpose, from its own page or from the comment above it', () => {
|
|
62
62
|
expect(registry.entries.filter((one) => one.purpose.trim() === '')).toEqual([])
|
|
63
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(
|
|
64
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(
|
|
63
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(110)
|
|
64
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(133)
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
it('takes a name with a page of its own from the page, and a name without one from the code', () => {
|
|
@@ -262,7 +262,7 @@ describe('the ids point at something', () => {
|
|
|
262
262
|
|
|
263
263
|
it('gives every component a page and a story, and only a helper none', () => {
|
|
264
264
|
const without = registry.entries.filter((one) => one.docsId === null || one.storyId === null)
|
|
265
|
-
// The helpers in a file with no page: cn, the shortcut names, the editor's suggestion wiring (documented on SuggestionMenu's page), the link widgets' data helpers (documented on LinkCard's and LinkChip's pages; linkedFrom's and cardShapeMemory's on LinkCard's), a chip's card choice (ReferenceMenu writes it),
|
|
265
|
+
// The helpers in a file with no page: cn, the shortcut names, the editor's suggestion wiring (documented on SuggestionMenu's page), the link widgets' data helpers (documented on LinkCard's and LinkChip's pages; linkedFrom's and cardShapeMemory's on LinkCard's), a chip's card choice (ReferenceMenu writes it), the caret a ConversationLayout gives a thread's box, whether a Form is sending (the kit's own wiring, documented on Form's page), and where a conversation scrolls, what was seen and a link landing on a comment (documented on ConversationLayout's and Thread's pages).
|
|
266
266
|
expect(without.map((one) => one.name).sort()).toEqual([
|
|
267
267
|
'archivedLine',
|
|
268
268
|
'cardShapeMemory',
|
|
@@ -278,11 +278,17 @@ describe('the ids point at something', () => {
|
|
|
278
278
|
'loadingShapeOf',
|
|
279
279
|
'referenceAtSelection',
|
|
280
280
|
'referenceCardPlacements',
|
|
281
|
+
'sendsInLayout',
|
|
281
282
|
'setReferenceCard',
|
|
282
283
|
'setReferenceCardAt',
|
|
283
284
|
'shortcutLabel',
|
|
285
|
+
'showInConversation',
|
|
286
|
+
'showInConversationWhenDrawn',
|
|
284
287
|
'suggestionPopup',
|
|
285
288
|
'unavailableMemory',
|
|
289
|
+
'useFormBusy',
|
|
290
|
+
'useLeftAt',
|
|
291
|
+
'useSeenOnScreen',
|
|
286
292
|
])
|
|
287
293
|
expect(without.every((one) => one.kind !== 'component')).toBe(true)
|
|
288
294
|
})
|