@estiva-app/ui 0.77.0 → 0.79.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/EditorTableControls.d.ts +9 -1
- package/dist/EditorTableControls.d.ts.map +1 -1
- package/dist/NavItem.d.ts +3 -1
- package/dist/NavItem.d.ts.map +1 -1
- package/dist/editor.d.ts +1 -1
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +17 -1
- package/dist/editor.js.map +3 -3
- package/dist/index.js +6 -1
- package/dist/index.js.map +2 -2
- package/dist/linked.d.ts +1 -1
- package/package.json +1 -1
- package/registry.json +27 -2
- package/src/CardUnder.tsx +1 -1
- package/src/EditorTableControls.mdx +7 -2
- package/src/EditorTableControls.stories.tsx +16 -3
- package/src/EditorTableControls.test.tsx +40 -2
- package/src/EditorTableControls.tsx +25 -2
- package/src/NavItem.mdx +8 -0
- package/src/NavItem.stories.tsx +5 -0
- package/src/NavItem.test.tsx +40 -1
- package/src/NavItem.tsx +12 -1
- package/src/editor.ts +1 -1
- package/src/linked.ts +1 -1
- package/src/registry/registry.test.ts +3 -3
package/dist/linked.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* widgets look nothing up, and keep nothing but what a reader does to them.
|
|
7
7
|
*
|
|
8
8
|
* The shape follows the prototype Miky approved (Widgets 2, 15 Oct; why:
|
|
9
|
-
* https://github.com/estiva-app/estiva-docs/blob/main/decisions/
|
|
9
|
+
* https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md).
|
|
10
10
|
*/
|
|
11
11
|
import type { ThingKind } from './KindIcon';
|
|
12
12
|
/** What a link stands for, by its icon. `page` draws a page of text. */
|
package/package.json
CHANGED
package/registry.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"kind": "package",
|
|
5
5
|
"repo": "estiva-ui",
|
|
6
6
|
"package": "@estiva-app/ui",
|
|
7
|
-
"packageVersion": "0.
|
|
8
|
-
"exports":
|
|
7
|
+
"packageVersion": "0.79.0",
|
|
8
|
+
"exports": 204,
|
|
9
9
|
"typeExports": 197,
|
|
10
10
|
"files": null
|
|
11
11
|
},
|
|
@@ -5611,6 +5611,12 @@
|
|
|
5611
5611
|
"required": false,
|
|
5612
5612
|
"note": "Shown only while the row is pointed at or focused, left of the count: a neutral `Chip`, typically."
|
|
5613
5613
|
},
|
|
5614
|
+
{
|
|
5615
|
+
"name": "tooltip",
|
|
5616
|
+
"takes": "text",
|
|
5617
|
+
"required": false,
|
|
5618
|
+
"note": "A sentence about the item, in the package's tooltip while the label is pointed at; the row stays one line."
|
|
5619
|
+
},
|
|
5614
5620
|
{
|
|
5615
5621
|
"name": "unread",
|
|
5616
5622
|
"takes": "true/false",
|
|
@@ -8696,6 +8702,25 @@
|
|
|
8696
8702
|
"bg-error-muted signal:bg-bg-inset signal:border signal:border-border-default signal:shadow-md leaf:bg-bg-inset leaf:border leaf:border-border-default leaf:shadow-md"
|
|
8697
8703
|
]
|
|
8698
8704
|
},
|
|
8705
|
+
{
|
|
8706
|
+
"name": "toggleTableHeaderRow",
|
|
8707
|
+
"repo": "estiva-ui",
|
|
8708
|
+
"kind": "helper",
|
|
8709
|
+
"importPath": "@estiva-app/ui/editor",
|
|
8710
|
+
"sourceFile": "src/EditorTableControls.tsx",
|
|
8711
|
+
"purpose": "The table's first row becomes its header row, or an ordinary row again: whichever cell of the table `cell` is.",
|
|
8712
|
+
"purposeFrom": "comment",
|
|
8713
|
+
"props": [],
|
|
8714
|
+
"variants": [],
|
|
8715
|
+
"ownsBehaviours": [],
|
|
8716
|
+
"status": "stable",
|
|
8717
|
+
"migrationStage": null,
|
|
8718
|
+
"docsId": "primitives-editortablecontrols--docs",
|
|
8719
|
+
"storyId": "primitives-editortablecontrols--default",
|
|
8720
|
+
"docPage": null,
|
|
8721
|
+
"app": null,
|
|
8722
|
+
"looks": []
|
|
8723
|
+
},
|
|
8699
8724
|
{
|
|
8700
8725
|
"name": "Toolbar",
|
|
8701
8726
|
"repo": "estiva-ui",
|
package/src/CardUnder.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one card added under a piece of text, and the ✕ that removes it (why:
|
|
3
|
-
* https://github.com/estiva-app/estiva-docs/blob/main/decisions/
|
|
3
|
+
* https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md).
|
|
4
4
|
*
|
|
5
5
|
* Under a box being written in, the ✕ always shows. Under text already sent
|
|
6
6
|
* (`revealOnHover`) it shows when the pointer is over the card or the ✕ has
|
|
@@ -10,14 +10,19 @@ row and on its column, and a ➕ bar under the table and right of it.
|
|
|
10
10
|
|
|
11
11
|
<Canvas of={EditorTableControlsStories.Default} />
|
|
12
12
|
|
|
13
|
+
<Canvas of={EditorTableControlsStories.NoHeaderRow} />
|
|
14
|
+
|
|
13
15
|
## When
|
|
14
16
|
|
|
15
17
|
- **An editor whose documents hold tables** — with TableKit
|
|
16
18
|
(`@tiptap/extension-table`) in its extensions. Point at a cell: the row's
|
|
17
19
|
handle sits on the table's left edge, the column's on its top edge; each
|
|
18
20
|
opens Insert (above and below, or left and right), Delete, and Delete
|
|
19
|
-
table.
|
|
20
|
-
row the
|
|
21
|
+
table. The first row's menu opens with Header row, ticked while the first
|
|
22
|
+
row is the table's header; choosing it turns the header row off (the first
|
|
23
|
+
row becomes an ordinary row) or on again. A header row offers nothing above
|
|
24
|
+
it, and deleting it makes the next row the header. With the header off, the
|
|
25
|
+
first row takes Insert above and deleting it promotes nothing. From the last row, a ➕ under the table adds a row after it; from the
|
|
21
26
|
last column, a ➕ right of the table adds a column after it.
|
|
22
27
|
- **Not editable**: nothing is drawn.
|
|
23
28
|
|
|
@@ -36,10 +36,18 @@ const DOCUMENT = {
|
|
|
36
36
|
],
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
const NO_HEADER = {
|
|
40
|
+
type: 'doc',
|
|
41
|
+
content: [
|
|
42
|
+
{ type: 'paragraph', content: [{ type: 'text', text: 'The first row’s handle turns the header row back on.' }] },
|
|
43
|
+
{ type: 'table', content: [row('tableCell', 'Item one', 'Value', 'Value'), row('tableCell', 'Item two', 'Value', 'Value')] },
|
|
44
|
+
],
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function Editing({ editable, content = DOCUMENT }: { editable: boolean; content?: object }) {
|
|
40
48
|
const editor = useEditor({
|
|
41
49
|
extensions: [StarterKit.configure({ dropcursor: blockDropCursor }), TableKit.configure({ table: { resizable: false } }), BlockId],
|
|
42
|
-
content
|
|
50
|
+
content,
|
|
43
51
|
editable,
|
|
44
52
|
editorProps: { attributes: { class: richTextClassName('default', 'outline-none'), 'aria-label': 'Text' } },
|
|
45
53
|
})
|
|
@@ -52,11 +60,16 @@ function Editing({ editable }: { editable: boolean }) {
|
|
|
52
60
|
)
|
|
53
61
|
}
|
|
54
62
|
|
|
55
|
-
/** Point at a cell; press a handle for Insert and Delete, or a ➕ bar to add a row or a column at the end. */
|
|
63
|
+
/** Point at a cell; press a handle for Insert and Delete, or a ➕ bar to add a row or a column at the end. The first row's handle also has Header row, ticked while it is on. */
|
|
56
64
|
export const Default: Story = {
|
|
57
65
|
render: () => <Editing editable />,
|
|
58
66
|
}
|
|
59
67
|
|
|
68
|
+
/** A table with its header row off: the first row is an ordinary row, and its handle's Header row is not ticked. */
|
|
69
|
+
export const NoHeaderRow: Story = {
|
|
70
|
+
render: () => <Editing editable content={NO_HEADER} />,
|
|
71
|
+
}
|
|
72
|
+
|
|
60
73
|
/** An editor that is not editable: no controls. */
|
|
61
74
|
export const NotEditable: Story = {
|
|
62
75
|
render: () => <Editing editable={false} />,
|
|
@@ -13,7 +13,7 @@ import { Editor } from '@tiptap/core'
|
|
|
13
13
|
import StarterKit from '@tiptap/starter-kit'
|
|
14
14
|
import { TableKit } from '@tiptap/extension-table'
|
|
15
15
|
import { BlockId } from './BlockNodes'
|
|
16
|
-
import { EditorTableControls, appendTableColumn, appendTableRow, deleteTableColumn, deleteTableRow } from './EditorTableControls'
|
|
16
|
+
import { EditorTableControls, appendTableColumn, appendTableRow, deleteTableColumn, deleteTableRow, toggleTableHeaderRow } from './EditorTableControls'
|
|
17
17
|
|
|
18
18
|
type Json = { type: string; attrs?: Record<string, unknown>; content?: Json[]; text?: string }
|
|
19
19
|
|
|
@@ -230,12 +230,50 @@ describe('EditorTableControls', () => {
|
|
|
230
230
|
const user = await mount(e)
|
|
231
231
|
await act(async () => user.hover(screen.getByText('B')))
|
|
232
232
|
await press(user, screen.getByRole('button', { name: 'Row menu' }))
|
|
233
|
-
expect(screen.getAllByRole('menuitem').map((r) => r.textContent)).toEqual(['Insert below', 'Delete', 'Delete table'])
|
|
233
|
+
expect(screen.getAllByRole('menuitem').map((r) => r.textContent)).toEqual(['Header row', 'Insert below', 'Delete', 'Delete table'])
|
|
234
234
|
await user.click(screen.getByRole('menuitem', { name: 'Delete' }))
|
|
235
235
|
await frame()
|
|
236
236
|
expect(shape(e)).toEqual(['#a1|#b1|#c1', 'a2|b2|c2'])
|
|
237
237
|
})
|
|
238
238
|
|
|
239
|
+
it('the first row’s menu turns the header row off and on; off, the first row is an ordinary row', async () => {
|
|
240
|
+
const e = editor()
|
|
241
|
+
const user = await mount(e)
|
|
242
|
+
await act(async () => user.hover(screen.getByText('B')))
|
|
243
|
+
await press(user, screen.getByRole('button', { name: 'Row menu' }))
|
|
244
|
+
await user.click(screen.getByRole('menuitem', { name: 'Header row' }))
|
|
245
|
+
await frame()
|
|
246
|
+
expect(shape(e)).toEqual(['A|B|C', 'a1|b1|c1', 'a2|b2|c2'])
|
|
247
|
+
|
|
248
|
+
// Off: the first row takes a row above it, and deleting it promotes nothing.
|
|
249
|
+
await act(async () => user.hover(screen.getByText('B')))
|
|
250
|
+
await press(user, screen.getByRole('button', { name: 'Row menu' }))
|
|
251
|
+
expect(screen.getAllByRole('menuitem').map((r) => r.textContent)).toEqual(['Header row', 'Insert above', 'Insert below', 'Delete', 'Delete table'])
|
|
252
|
+
await user.click(screen.getByRole('menuitem', { name: 'Header row' }))
|
|
253
|
+
await frame()
|
|
254
|
+
expect(shape(e)).toEqual(['#A|#B|#C', 'a1|b1|c1', 'a2|b2|c2'])
|
|
255
|
+
|
|
256
|
+
await act(async () => user.hover(screen.getByText('B')))
|
|
257
|
+
await press(user, screen.getByRole('button', { name: 'Row menu' }))
|
|
258
|
+
await user.click(screen.getByRole('menuitem', { name: 'Header row' }))
|
|
259
|
+
await frame()
|
|
260
|
+
await act(async () => user.hover(screen.getByText('B')))
|
|
261
|
+
await press(user, screen.getByRole('button', { name: 'Row menu' }))
|
|
262
|
+
await user.click(screen.getByRole('menuitem', { name: 'Delete' }))
|
|
263
|
+
await frame()
|
|
264
|
+
expect(shape(e)).toEqual(['a1|b1|c1', 'a2|b2|c2'])
|
|
265
|
+
})
|
|
266
|
+
|
|
267
|
+
it('switches the header row from any cell of the table, and only on the first row’s menu', async () => {
|
|
268
|
+
const e = editor()
|
|
269
|
+
const user = await mount(e)
|
|
270
|
+
await act(async () => user.hover(screen.getByText('b2')))
|
|
271
|
+
await press(user, screen.getByRole('button', { name: 'Row menu' }))
|
|
272
|
+
expect(screen.queryByRole('menuitem', { name: 'Header row' })).toBeNull()
|
|
273
|
+
expect(toggleTableHeaderRow(e, cellOf('b2'))).toBe(true)
|
|
274
|
+
expect(shape(e)).toEqual(['A|B|C', 'a1|b1|c1', 'a2|b2|c2'])
|
|
275
|
+
})
|
|
276
|
+
|
|
239
277
|
it('takes the controls away when the document changes without an update — someone else’s edit loaded', async () => {
|
|
240
278
|
const e = editor()
|
|
241
279
|
const user = await mount(e)
|
|
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useRef, useState, type MouseEvent, type ReactNo
|
|
|
2
2
|
import type { Editor } from '@tiptap/core'
|
|
3
3
|
import { TextSelection, type Command } from '@tiptap/pm/state'
|
|
4
4
|
import { addColumnAfter, addColumnBefore, addRowAfter, addRowBefore, deleteColumn, deleteRow, deleteTable, toggleHeader } from '@tiptap/pm/tables'
|
|
5
|
-
import { IconColumnInsertLeft, IconColumnInsertRight, IconGripHorizontal, IconGripVertical, IconPlus, IconRowInsertBottom, IconRowInsertTop, IconTrash } from '@tabler/icons-react'
|
|
5
|
+
import { IconCheck, IconColumnInsertLeft, IconColumnInsertRight, IconGripHorizontal, IconGripVertical, IconPlus, IconRowInsertBottom, IconRowInsertTop, IconTableRow, IconTrash } from '@tabler/icons-react'
|
|
6
6
|
import { cn } from './cn'
|
|
7
7
|
import { IconButton } from './IconButton'
|
|
8
8
|
import { FLOATING_SURFACE_CLASSES } from './looks'
|
|
@@ -67,6 +67,15 @@ export function deleteTableRow(editor: Editor, cell: HTMLTableCellElement): bool
|
|
|
67
67
|
return inCell(editor, cell, header ? (state, dispatch, view) => deleteRow(state, dispatch) && (!view || toggleHeader('row')(view.state, view.dispatch)) : deleteRow)
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
/**
|
|
71
|
+
* The table's first row becomes its header row, or an ordinary row again:
|
|
72
|
+
* whichever cell of the table `cell` is. A table with no header row has no
|
|
73
|
+
* text spelling, so the agent keeps it as written (SPEC §13.3, "No spelling").
|
|
74
|
+
*/
|
|
75
|
+
export function toggleTableHeaderRow(editor: Editor, cell: HTMLTableCellElement): boolean {
|
|
76
|
+
return inCell(editor, cell, toggleHeader('row'))
|
|
77
|
+
}
|
|
78
|
+
|
|
70
79
|
/** The same for a column: the last one deletes the table. */
|
|
71
80
|
export function deleteTableColumn(editor: Editor, cell: HTMLTableCellElement): boolean {
|
|
72
81
|
const row = cell.closest('tr')
|
|
@@ -114,7 +123,9 @@ const HANDLE_BOX = cn(FLOATING_SURFACE_CLASSES, 'shadow-none')
|
|
|
114
123
|
/**
|
|
115
124
|
* A table's own controls in an editor, as in Notion: point at a cell and a
|
|
116
125
|
* handle sits on its row's left edge and on its column's top edge; press one
|
|
117
|
-
* for Insert above and below (left and right), Delete, and Delete table.
|
|
126
|
+
* for Insert above and below (left and right), Delete, and Delete table. The
|
|
127
|
+
* first row's menu also turns the header row on and off (Header row, ticked
|
|
128
|
+
* while it is on); with it off, the first row is an ordinary row. On
|
|
118
129
|
* the last row a ➕ bar under the table adds a row, and on the last column one
|
|
119
130
|
* right of it adds a column. Tab in
|
|
120
131
|
* the last cell adds a row too — that is TableKit's own.
|
|
@@ -202,6 +213,18 @@ export function EditorTableControls({ editor, children, className }: EditorTable
|
|
|
202
213
|
</IconButton>
|
|
203
214
|
}
|
|
204
215
|
>
|
|
216
|
+
{/* The header row is switched where it lives: on the first row's menu, ticked while that row is the header. */}
|
|
217
|
+
{shown.row.rowIndex === 0 && (
|
|
218
|
+
<>
|
|
219
|
+
<MenuItem
|
|
220
|
+
label="Header row"
|
|
221
|
+
leading={<IconTableRow {...ICON} />}
|
|
222
|
+
trailing={isHeaderRow(shown.row) ? <IconCheck {...ICON} aria-hidden /> : undefined}
|
|
223
|
+
onClick={run(() => toggleTableHeaderRow(editor, shown.cell))}
|
|
224
|
+
/>
|
|
225
|
+
<MenuSeparator />
|
|
226
|
+
</>
|
|
227
|
+
)}
|
|
205
228
|
{/* Nothing goes above a header row: it is the table's first row, and a header anywhere else is no header (RichText, the agent's text). */}
|
|
206
229
|
{!isHeaderRow(shown.row) && <MenuItem label="Insert above" leading={<IconRowInsertTop {...ICON} />} onClick={run(() => inCell(editor, shown.cell, addRowBefore))} />}
|
|
207
230
|
<MenuItem label="Insert below" leading={<IconRowInsertBottom {...ICON} />} onClick={run(() => inCell(editor, shown.cell, addRowAfter))} />
|
package/src/NavItem.mdx
CHANGED
|
@@ -51,6 +51,14 @@ count — a muted mono number whose tooltip says what it counts.
|
|
|
51
51
|
|
|
52
52
|
<Canvas of={NavItemStories.WithHintLongLabel} />
|
|
53
53
|
|
|
54
|
+
- A sentence about the item, for whoever points at it, is `tooltip`: it
|
|
55
|
+
shows in the package's tooltip while the **label** is pointed at, and the
|
|
56
|
+
row stays one line. The ⋮ and the `action` keep their own tooltips. Absent
|
|
57
|
+
or blank, there is none. A screen with no hover never shows it, so it can
|
|
58
|
+
carry nothing the row needs.
|
|
59
|
+
|
|
60
|
+
<Canvas of={NavItemStories.LabelTooltip} />
|
|
61
|
+
|
|
54
62
|
- Something new on the row is `unread`: its words and icon brighten, the
|
|
55
63
|
label is set in medium, and the **UnreadDot** sits at the right.
|
|
56
64
|
`urgent` with it draws the warning badge in the dot's place. Say "unread"
|
package/src/NavItem.stories.tsx
CHANGED
|
@@ -122,6 +122,11 @@ export const WithActionAndMenu: Story = {
|
|
|
122
122
|
args: { label: 'An item whose label runs much longer than the column has room for', icon: placeholder, action: REMOVE, menu: MENU },
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
/** A sentence about the item: point at the label and it shows in the tooltip. The row stays one line. */
|
|
126
|
+
export const LabelTooltip: Story = {
|
|
127
|
+
args: { icon: placeholder, action: REMOVE, tooltip: 'One sentence saying what this item is about, shown while its label is pointed at.' },
|
|
128
|
+
}
|
|
129
|
+
|
|
125
130
|
/** A hint and a button: point at it and the chip shows, then the button — a row whose state is a word (here, archived) and which can be taken off the list. */
|
|
126
131
|
export const WithActionAndHint: Story = {
|
|
127
132
|
args: { label: 'An item whose label runs much longer than the column has room for', icon: placeholder, action: REMOVE, hint: <Chip type="neutral" label="Archived" /> },
|
package/src/NavItem.test.tsx
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* The reveal on hover and the slide are Chrome's to show.
|
|
7
7
|
*/
|
|
8
8
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
9
|
-
import { cleanup, render, screen } from '@testing-library/react'
|
|
9
|
+
import { cleanup, render, screen, waitFor } from '@testing-library/react'
|
|
10
10
|
import userEvent from '@testing-library/user-event'
|
|
11
11
|
import { NavItem } from './NavItem'
|
|
12
12
|
|
|
@@ -177,3 +177,42 @@ describe('NavItem with a button of its own', () => {
|
|
|
177
177
|
expect(container.querySelector('[data-unread]')!.parentElement!.className.split(' ')).toContain('group-hover/nav:opacity-0')
|
|
178
178
|
})
|
|
179
179
|
})
|
|
180
|
+
|
|
181
|
+
describe('NavItem with a tooltip', () => {
|
|
182
|
+
it('shows it while the label is pointed at, and none when it is absent or blank', async () => {
|
|
183
|
+
const user = userEvent.setup()
|
|
184
|
+
render(
|
|
185
|
+
<>
|
|
186
|
+
<NavItem href="#" label="Item one" tooltip="A sentence about item one." />
|
|
187
|
+
<NavItem href="#" label="Item two" tooltip=" " />
|
|
188
|
+
<NavItem href="#" label="Item three" />
|
|
189
|
+
</>,
|
|
190
|
+
)
|
|
191
|
+
// The blank and absent ones first, so a tooltip still closing cannot answer for them.
|
|
192
|
+
for (const label of ['Item two', 'Item three']) {
|
|
193
|
+
await user.hover(screen.getByText(label))
|
|
194
|
+
await new Promise((r) => setTimeout(r, 400))
|
|
195
|
+
expect(screen.queryByRole('tooltip')).toBeNull()
|
|
196
|
+
await user.unhover(screen.getByText(label))
|
|
197
|
+
}
|
|
198
|
+
await user.hover(screen.getByText('Item one'))
|
|
199
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe('A sentence about item one.')
|
|
200
|
+
await user.unhover(screen.getByText('Item one'))
|
|
201
|
+
await waitFor(() => expect(screen.queryByRole('tooltip')).toBeNull())
|
|
202
|
+
})
|
|
203
|
+
|
|
204
|
+
it('keeps the row one line, and the label inside the link', () => {
|
|
205
|
+
render(<NavItem href="#" label="Item one" tooltip="A sentence about item one." />)
|
|
206
|
+
const link = screen.getByRole('link', { name: 'Item one' })
|
|
207
|
+
expect(link.contains(screen.getByText('Item one'))).toBe(true)
|
|
208
|
+
expect(link.className.split(' ')).toContain('h-8')
|
|
209
|
+
expect(screen.getByText('Item one').className.split(' ')).toContain('truncate')
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('leaves the action its own tooltip: pointing at it shows the action’s, not the label’s', async () => {
|
|
213
|
+
const user = userEvent.setup()
|
|
214
|
+
render(<NavItem href="#" label="Item one" tooltip="A sentence about item one." action={{ icon: <span>x</span>, tooltip: 'Remove from list', onClick: () => {} }} />)
|
|
215
|
+
await user.hover(screen.getByRole('button', { name: 'Remove from list: Item one' }))
|
|
216
|
+
expect((await screen.findByRole('tooltip')).textContent).toBe('Remove from list')
|
|
217
|
+
})
|
|
218
|
+
})
|
package/src/NavItem.tsx
CHANGED
|
@@ -72,6 +72,8 @@ export interface NavItemProps extends Omit<ComponentPropsWithoutRef<'a'>, 'href'
|
|
|
72
72
|
action?: SectionAction
|
|
73
73
|
/** Shown only while the row is pointed at or focused, left of the count: a neutral `Chip`, typically. */
|
|
74
74
|
hint?: ReactNode
|
|
75
|
+
/** A sentence about the item, in the package's tooltip while the label is pointed at; the row stays one line. Absent or blank, no tooltip. */
|
|
76
|
+
tooltip?: string
|
|
75
77
|
/** Something new here: brighter words, the label in medium, and the `UnreadDot` at the right. Say so in the row's own words for assistive tech too. */
|
|
76
78
|
unread?: boolean
|
|
77
79
|
/** With `unread`: the warning badge in the dot's place. */
|
|
@@ -97,6 +99,7 @@ export function NavItem({
|
|
|
97
99
|
menuLabel,
|
|
98
100
|
action,
|
|
99
101
|
hint,
|
|
102
|
+
tooltip,
|
|
100
103
|
unread = false,
|
|
101
104
|
urgent = false,
|
|
102
105
|
children,
|
|
@@ -163,7 +166,15 @@ export function NavItem({
|
|
|
163
166
|
{icon}
|
|
164
167
|
</span>
|
|
165
168
|
)}
|
|
166
|
-
|
|
169
|
+
{tooltip?.trim() ? (
|
|
170
|
+
// On the label alone, not the row: the ⋮ and the action keep their
|
|
171
|
+
// own tooltips, and the two never stand up at once.
|
|
172
|
+
<WithTooltip label={tooltip} inline wrapperClassName="flex min-w-0 flex-1">
|
|
173
|
+
<span className={cn('flex-1 truncate', unread && 'font-medium')}>{label}</span>
|
|
174
|
+
</WithTooltip>
|
|
175
|
+
) : (
|
|
176
|
+
<span className={cn('flex-1 truncate', unread && 'font-medium')}>{label}</span>
|
|
177
|
+
)}
|
|
167
178
|
{hint != null && (
|
|
168
179
|
// Takes room only while it shows, so the label gives way to it.
|
|
169
180
|
<span className="hidden shrink-0 items-center group-hover/nav:flex group-has-[:focus-visible]/nav:flex">{hint}</span>
|
package/src/editor.ts
CHANGED
|
@@ -53,7 +53,7 @@ export {
|
|
|
53
53
|
type ListKind,
|
|
54
54
|
type QuoteKind,
|
|
55
55
|
} from './EditorBlockHandle'
|
|
56
|
-
export { EditorTableControls, appendTableRow, appendTableColumn, deleteTableRow, deleteTableColumn, type EditorTableControlsProps } from './EditorTableControls'
|
|
56
|
+
export { EditorTableControls, appendTableRow, appendTableColumn, deleteTableRow, deleteTableColumn, toggleTableHeaderRow, type EditorTableControlsProps } from './EditorTableControls'
|
|
57
57
|
export {
|
|
58
58
|
PersonMention,
|
|
59
59
|
UrgentPersonMention,
|
package/src/linked.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* widgets look nothing up, and keep nothing but what a reader does to them.
|
|
7
7
|
*
|
|
8
8
|
* The shape follows the prototype Miky approved (Widgets 2, 15 Oct; why:
|
|
9
|
-
* https://github.com/estiva-app/estiva-docs/blob/main/decisions/
|
|
9
|
+
* https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-link-on-words-counts-toward-the-card.md).
|
|
10
10
|
*/
|
|
11
11
|
import type { ThingKind } from './KindIcon'
|
|
12
12
|
|
|
@@ -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 204 names over 95 files: 138 components, 63 helpers and 3 hooks (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: 138, helper:
|
|
57
|
+
expect(kinds).toEqual({ component: 138, helper: 63, hook: 3 })
|
|
58
58
|
expect(new Set(registry.entries.map((one) => one.sourceFile)).size).toBe(95)
|
|
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
63
|
expect(registry.entries.filter((one) => one.purposeFrom === 'page').length).toBe(89)
|
|
64
|
-
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(
|
|
64
|
+
expect(registry.entries.filter((one) => one.purposeFrom === 'comment').length).toBe(115)
|
|
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', () => {
|