@bigpixelrocket/uiok 0.6.0 → 0.7.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/CHANGELOG.md +37 -1
- package/dist/button/TextLink.d.ts +14 -2
- package/dist/button/TextLink.js +13 -3
- package/dist/dialog/SectionedDialog.js +2 -1
- package/dist/field/FieldLayout.d.ts +3 -2
- package/dist/field/FieldLayout.js +8 -3
- package/dist/frame/PageParts.js +1 -1
- package/dist/frame/SideBySide.d.ts +2 -1
- package/dist/frame/SideBySide.js +16 -4
- package/dist/frame/Tree.d.ts +19 -6
- package/dist/frame/Tree.js +20 -8
- package/dist/frame/frame.css +8 -0
- package/dist/keychord/KeyChord.d.ts +4 -3
- package/dist/keychord/KeyChord.js +10 -6
- package/dist/legend/legend.css +6 -10
- package/dist/listing/Listing.d.ts +19 -1
- package/dist/listing/Listing.js +43 -4
- package/dist/listing/listing.css +41 -2
- package/dist/menu/Menu.js +2 -2
- package/dist/menu/menu.css +4 -6
- package/dist/palette/Palette.d.ts +3 -1
- package/dist/palette/Palette.js +14 -2
- package/dist/palette/PaletteRows.d.ts +17 -12
- package/dist/palette/PaletteRows.js +17 -15
- package/dist/pane/Pane.d.ts +8 -0
- package/dist/pane/Pane.js +26 -6
- package/dist/pane/PaneTabs.js +7 -3
- package/dist/pane/panetabs.css +14 -2
- package/dist/styles.css +34 -11
- package/dist/surface/surface.css +10 -0
- package/dist/terminal/TerminalMenu.js +1 -1
- package/dist/terminal/terminal.css +3 -2
- package/dist/themes/tokens.js +5 -2
- package/dist/tokens.css +4 -0
- package/dist/viewer/HexView.js +17 -8
- package/dist/viewer/ImageView.js +5 -3
- package/dist/viewer/PdfView.d.ts +8 -1
- package/dist/viewer/PdfView.js +27 -2
- package/dist/viewer/SyntaxHighlighter.d.ts +3 -2
- package/dist/viewer/SyntaxHighlighter.js +7 -2
- package/dist/viewer/SyntaxLanguage.logic.d.ts +5 -0
- package/dist/viewer/SyntaxLanguage.logic.js +17 -3
- package/dist/viewer/SyntaxService.d.ts +3 -1
- package/dist/viewer/SyntaxService.js +8 -1
- package/dist/viewer/TextView.js +14 -7
- package/dist/viewer/ViewerClipboard.js +17 -6
- package/dist/viewer/ViewerFrame.logic.js +4 -1
- package/dist/viewer/types.d.ts +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,41 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.7.0] - 2026-11-23
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `TreeRow`'s `onContextMenu(event, rowKey)`: a secondary click for a tree row's menu, as a listing `Row`'s. The row moves the pane's cursor to itself before calling it and cancels the browser's own menu, so its handler wins over its `TreeList`'s and `TreePane`'s. With the focus on the tree's `TreeList`, the Menu key or Shift-F10 runs the cursor row's, its event placed under the row.
|
|
14
|
+
- `TextLink`'s `verb` (`ControlVerb`, `data-verb`): a link in a listing row, such as a service's port, becomes one of the row's controls, out of the Tab order unless the row is `tabbable`, reached by the cursor row's keys through `verbControl`, and run without opening the row. Without a `verb`, or outside a row, a link keeps its Tab stop.
|
|
15
|
+
- A `FactList` or `FactColumns` set straight in a pane's body (a `PaneList`, `PanePage`, `PageSlot`, or `SideBySide` part) keeps the rows' inset from the pane's edge (`--pane-row-inset`) and `--space-4` above and below, instead of sitting flush with it.
|
|
16
|
+
- `Row`'s `nameTip` and `nameDescription`: the host's words about a row's name. `nameTip` (a narrow pane's dropped columns, say) is the name's tooltip at every width, under the whole name (a name in markup by its drawn words), in place of the tooltip a cut name shows alone. `nameDescription` (the row's kind) and the tip's words, in that order, describe the name's cell, the row when it takes the focus (`focusable`, `tabbable`), and a radio row's radio. Neither repeats the name.
|
|
17
|
+
- The pane docs demo walks Tab listing first (`usePaneKeys`' `tabOrder: 'listing'`) beside the browser's own order, Escape giving the focus back to that choice, and the frame demo opens a tree row's menu, from a secondary click or, through its Focus the tree button, the keys.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- Breaking: a `PaletteOption`'s accessible name is now every word it draws, in the order drawn (its name, its `context`, then its trail, a `KeyChord` by its words, and `current`'s value), read from its content, so it holds the text on screen (WCAG 2.5.3, axe `label-content-name-mismatch`). Its `aria-description` is now only the caller's `description`, for what the row does not draw (why it is disabled). 0.6.0 advised voicing a chord or the context through `description`: a caller that did so drops that text from `description`, or the row reads it twice. `label` now stands in for the drawn name's words alone (pass it for a `MarkedText` name), the context and trail still read after it; an empty `label` is none.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
|
|
25
|
+
- A right-to-left box keeps its inline edge fade (`.scroll-fade-x`) on the right side and a submenu's chevron pointing left after an app's bundler processes the stylesheet, and the key legend's overflow list ends at the chip's left edge. Lightning CSS (Vite) rewrote `:dir(rtl)` into `:lang()` selectors, which a `dir="rtl"` box in an English page does not match; the fade and the chevron now follow the nearest `dir` attribute (`--scroll-fade-inline-to`, `--inline-flip`), reading `:dir()` only under `dir="auto"`, whose direction comes from its text, and the list sits by a logical inset.
|
|
26
|
+
- Return on a command in a `Palette` no longer closes it and opens it again: the query field (`PaletteQuery`) cancels Return's default before the host's `onKeyDown` runs, so a host that hands the focus back to the button that opened the palette on close, even one that stops the key, does not see the browser click that button with the same key. Return on a button inside the palette still presses it.
|
|
27
|
+
- A `TextLink` in a selected listing row takes the selection's words (`--on-selected`, a disabled one `--on-selected-dim`) while the selection is active, instead of its accent or danger tone on the accent fill, which could vanish (1:1 in Catppuccin Mocha). An inactive selection keeps the link's own tone.
|
|
28
|
+
- `PaneTabs` no longer nests each tab's close control inside its `role="tab"` element (axe `nested-interactive`): the `.pane-tab` box is presentational and holds the tab, `.pane-tab-face`, with the close control beside it, out of the Tab order and the pointer's alone (`aria-hidden`, since a tab list owns tabs alone; the host's close chord closes a tab from the keyboard and assistive technology). The look, presses, drag, and folding are unchanged; a stylesheet that reached a tab's mark, name, dirty mark, or pin as the box's direct children reaches them under `.pane-tab-face`.
|
|
29
|
+
- `KeyChord` draws its chord as a `<kbd role="img">`, so its name in words ("Shift Command N") is allowed and read, in a control round it too, where an `aria-label` on a bare `<kbd>` was not (axe `aria-prohibited-attr`). `KeyChords` keeps its "or" apart from the chords in a name read from the content, and `Menu` and the terminal's menu keep an item's label, its current mark's words, and its chord's apart in its name ("Copy Path Option Command C").
|
|
30
|
+
- A `TreeTool`'s words (a note, a heading, a failed read) that a narrow sidebar cuts with an ellipsis show whole in a tooltip while cut, as a cut tree row's name does.
|
|
31
|
+
- A `PageNote` or `PaneMessage` too long for one line wraps its words in their own column beside the glyph (a hanging indent), not under the glyph; `PageNote` draws its words in the same `.pane-message-text` box. A glyph of the host's own leading a `PaneMessage`'s words is drawn at `--icon-md`, and the words after it hang in their own column too.
|
|
32
|
+
- A `Toolbar` set straight in a pane's body (a `PaneList`, `PanePage`, `PageSlot`, or `SideBySide` part) keeps the rows' inset (`--pane-row-inset`) from the pane's edges instead of touching them.
|
|
33
|
+
- A `.terminal-box` that nothing gives a height falls back to the new fixed token `--terminal-box-default-height` (200px, `TERMINAL_BOX_HEIGHT`) instead of collapsing.
|
|
34
|
+
- A mouse's second button pressed while another is held, after a Shift-F10 the browser left alone, opens the pane's menu again, not the cursor row's: `PaneList` forgets the menu key on a `mousedown` as well as a `pointerdown`.
|
|
35
|
+
- `SectionedDialog` focuses a section's first control past the column's end without throwing where the engine has no `scrollIntoView` (jsdom).
|
|
36
|
+
- `SideBySide` applies a changed `from` without the scrollbar hold on the first width measured against it, so a pair hidden while `from` rose comes back stacked if it is now too narrow; one hidden and shown again with the same `from` keeps its hold.
|
|
37
|
+
- `ViewerWindow` no longer takes a file named `constructor`, an extension or interpreter such as `valueOf`, or a media type such as `toString` for an `Object.prototype` member, which posted a function to the highlighting worker and took the viewer down; the worker answers failed for a language it does not ship.
|
|
38
|
+
- A PDF named `.`, `..`, or nothing, or whose name cannot be encoded (a lone surrogate), opens as `document.pdf` below its media URL instead of resolving to the URL's parent or failing. A PDF's `mediaUrl` carries no query or fragment.
|
|
39
|
+
- A text or hex view's drag ends with the view and before the next drag starts, so a lost mouseup or an unmount leaves no window listeners or scroll timer behind.
|
|
40
|
+
- The viewer says the copy failed on a page with no clipboard API (an insecure origin) instead of showing the raw error, and checks that a copy is still the latest in the same step that starts its write, so an overtaken copy never overwrites a newer one.
|
|
41
|
+
- The image view leaves an arrow a control already handled alone, and its arrow keys and the hex view's selection steps are looked up by own keys only. The keyboard table no longer says Shift with an arrow extends a text view's selection; only the hex view's does.
|
|
42
|
+
- `FieldGroup` names its note in the fieldset's `aria-describedby`, after the problem, and draws no note for `note={false}`, as `FieldRow` does.
|
|
43
|
+
|
|
9
44
|
## [0.6.0] - 2026-11-23
|
|
10
45
|
|
|
11
46
|
### Added
|
|
@@ -305,7 +340,8 @@ The first published version. The package is published to npm as `@bigpixelrocket
|
|
|
305
340
|
- `lucide-react` 1.31 or later within 1.x is a peer dependency.
|
|
306
341
|
- Terminal (`@bigpixelrocket/uiok/terminal`, `docs/components/terminal.md`): `Terminal`, Ghostty's VT engine as WebAssembly drawn on a canvas, read-only without `onInput`, with a Copy and Paste menu whose chords come from `menuChords`, a visual bell, line-editing actions bound by `actionForKey`, and `TerminalScrollbackContext`. The package root does not export it, so an app without a terminal never loads its assets. Its words are the new `terminal` label group; the package now ships a `NOTICE` with the engine's, adapter's, and font's licences.
|
|
307
342
|
|
|
308
|
-
[Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.
|
|
343
|
+
[Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.7.0...HEAD
|
|
344
|
+
[0.7.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.6.0...v0.7.0
|
|
309
345
|
[0.6.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.5.0...v0.6.0
|
|
310
346
|
[0.5.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.4.0...v0.5.0
|
|
311
347
|
[0.4.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.3.0...v0.4.0
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LucideIcon } from 'lucide-react';
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
|
+
import { type ControlVerb } from '../pane/PaneActions.js';
|
|
3
4
|
/** Props for {@link TextLink}. */
|
|
4
5
|
export interface TextLinkProps {
|
|
5
6
|
/**
|
|
@@ -35,6 +36,15 @@ export interface TextLinkProps {
|
|
|
35
36
|
* is its accessible description too, so a screen reader says why.
|
|
36
37
|
*/
|
|
37
38
|
readonly tone?: 'danger';
|
|
39
|
+
/**
|
|
40
|
+
* What the keys run it for (`data-verb`, read by `verbControl`), for a link
|
|
41
|
+
* in a listing row such as a service's port: there it leaves the Tab
|
|
42
|
+
* order, as a row's `QuietAction` and `RowIconAction` do, so the cursor
|
|
43
|
+
* row's keys reach it instead of Tab, and a press runs it without opening
|
|
44
|
+
* the row. A `tabbable` row keeps it in the Tab order; outside a row it
|
|
45
|
+
* changes nothing but the attribute.
|
|
46
|
+
*/
|
|
47
|
+
readonly verb?: ControlVerb;
|
|
38
48
|
}
|
|
39
49
|
/**
|
|
40
50
|
* A link in words: a button that reads as a link inside a sentence, a
|
|
@@ -44,7 +54,9 @@ export interface TextLinkProps {
|
|
|
44
54
|
* the host decides how to open what it names (an external browser, a tab),
|
|
45
55
|
* so it never navigates the page itself. A `disabled` link dims and
|
|
46
56
|
* refuses the press; `label` names it when its words are short; `tone`
|
|
47
|
-
* `danger` sets it in the danger tone with its reason described.
|
|
57
|
+
* `danger` sets it in the danger tone with its reason described. With a
|
|
58
|
+
* `verb`, a link in a listing row is one of the row's controls: out of the
|
|
59
|
+
* Tab order, reached by the cursor row's keys. Styled by `.text-link` in
|
|
48
60
|
* `@bigpixelrocket/uiok/styles.css`.
|
|
49
61
|
*/
|
|
50
|
-
export declare function TextLink({ children, onClick, icon: Icon, code, tip, shortcut, label, disabled, tone }: TextLinkProps): ReactElement;
|
|
62
|
+
export declare function TextLink({ children, onClick, icon: Icon, code, tip, shortcut, label, disabled, tone, verb }: TextLinkProps): ReactElement;
|
package/dist/button/TextLink.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ICON_SM } from '../icon/sizes.js';
|
|
3
|
+
import { useInRow } from '../pane/PaneActions.js';
|
|
3
4
|
import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
4
5
|
/**
|
|
5
6
|
* A link in words: a button that reads as a link inside a sentence, a
|
|
@@ -9,9 +10,18 @@ import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
|
9
10
|
* the host decides how to open what it names (an external browser, a tab),
|
|
10
11
|
* so it never navigates the page itself. A `disabled` link dims and
|
|
11
12
|
* refuses the press; `label` names it when its words are short; `tone`
|
|
12
|
-
* `danger` sets it in the danger tone with its reason described.
|
|
13
|
+
* `danger` sets it in the danger tone with its reason described. With a
|
|
14
|
+
* `verb`, a link in a listing row is one of the row's controls: out of the
|
|
15
|
+
* Tab order, reached by the cursor row's keys. Styled by `.text-link` in
|
|
13
16
|
* `@bigpixelrocket/uiok/styles.css`.
|
|
14
17
|
*/
|
|
15
|
-
export function TextLink({ children, onClick, icon: Icon, code = false, tip, shortcut, label, disabled = false, tone }) {
|
|
16
|
-
|
|
18
|
+
export function TextLink({ children, onClick, icon: Icon, code = false, tip, shortcut, label, disabled = false, tone, verb }) {
|
|
19
|
+
// A link the row's keys run is one of the row's controls.
|
|
20
|
+
const rowControl = useInRow() && verb !== undefined;
|
|
21
|
+
return (_jsxs("button", { "aria-description": tone === 'danger' ? tip : undefined, "aria-label": label, className: ['text-link', code ? 'code' : '', tone ?? ''].filter(Boolean).join(' '), "data-verb": verb, disabled: disabled, onClick: (event) => {
|
|
22
|
+
// A row's control runs alone, never opening the row around it too.
|
|
23
|
+
if (verb !== undefined)
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
onClick();
|
|
26
|
+
}, tabIndex: rowControl ? -1 : undefined, type: "button", ...(tip === undefined && shortcut === undefined ? {} : tooltip(tip ?? children, shortcut)), children: [Icon === undefined ? null : _jsx(Icon, { "aria-hidden": true, size: ICON_SM }), _jsx("span", { className: "text-link-words", children: children })] }));
|
|
17
27
|
}
|
|
@@ -96,7 +96,8 @@ export function SectionedDialog({ sections, openAt, notice, className, ...dialog
|
|
|
96
96
|
const box = control.getBoundingClientRect();
|
|
97
97
|
if (box.top < view.top || box.bottom > view.bottom) {
|
|
98
98
|
const before = column.scrollTop;
|
|
99
|
-
|
|
99
|
+
// Optional: an engine with no scrollIntoView (jsdom) only focuses.
|
|
100
|
+
control.scrollIntoView?.({ block: 'nearest' });
|
|
100
101
|
chosenScrollRef.current = chosenScrollRef.current || column.scrollTop !== before;
|
|
101
102
|
}
|
|
102
103
|
}
|
|
@@ -120,7 +120,8 @@ export interface FieldGroupProps {
|
|
|
120
120
|
readonly problem?: ReactNode;
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
|
-
* A group of choices under its legend, 4px apart, or in `columns
|
|
124
|
-
* `
|
|
123
|
+
* A group of choices under its legend, 4px apart, or in `columns`, described
|
|
124
|
+
* by its problem and note (`aria-describedby`); a `note` or `problem` of
|
|
125
|
+
* `false` draws nothing. Draws `fieldset.field-group` (`.field-columns`).
|
|
125
126
|
*/
|
|
126
127
|
export declare function FieldGroup({ legend, legendHidden, children, columns, note, problem }: FieldGroupProps): ReactElement;
|
|
@@ -79,11 +79,16 @@ export function FieldProblem({ children, id }) {
|
|
|
79
79
|
return (_jsx("p", { className: "field-problem", id: id, children: children }));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
-
* A group of choices under its legend, 4px apart, or in `columns
|
|
83
|
-
* `
|
|
82
|
+
* A group of choices under its legend, 4px apart, or in `columns`, described
|
|
83
|
+
* by its problem and note (`aria-describedby`); a `note` or `problem` of
|
|
84
|
+
* `false` draws nothing. Draws `fieldset.field-group` (`.field-columns`).
|
|
84
85
|
*/
|
|
85
86
|
export function FieldGroup({ legend, legendHidden = false, children, columns, note, problem }) {
|
|
86
87
|
const made = useId();
|
|
87
88
|
const hasProblem = problem !== undefined && problem !== null && problem !== false;
|
|
88
|
-
|
|
89
|
+
const hasNote = note !== undefined && note !== null && note !== false;
|
|
90
|
+
const describedBy = [hasProblem ? `${made}-problem` : '', hasNote ? `${made}-note` : '']
|
|
91
|
+
.filter(Boolean)
|
|
92
|
+
.join(' ');
|
|
93
|
+
return (_jsxs("fieldset", { "aria-describedby": describedBy || undefined, className: columns === undefined ? 'field-group' : 'field-group field-columns', style: columns === undefined ? undefined : { '--field-columns': columns }, children: [_jsx("legend", { className: legendHidden ? 'visually-hidden' : undefined, children: legend }), children, hasProblem ? _jsx(FieldProblem, { id: `${made}-problem`, children: problem }) : null, hasNote ? _jsx(FieldNote, { id: `${made}-note`, children: note }) : null] }));
|
|
89
94
|
}
|
package/dist/frame/PageParts.js
CHANGED
|
@@ -35,7 +35,7 @@ export function PageFilter({ children }) {
|
|
|
35
35
|
*/
|
|
36
36
|
export function PageNote({ icon: Icon, busy = false, children }) {
|
|
37
37
|
const scoped = useContext(ListingScopeContext);
|
|
38
|
-
const note = (_jsxs("p", { className: "pane-message pane-page-note", role: busy ? 'status' : undefined, children: [busy ? (_jsx(Spinner, { size: ICON_MD })) : Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, size: ICON_MD })), _jsx("span", { children: children })] }));
|
|
38
|
+
const note = (_jsxs("p", { className: "pane-message pane-page-note", role: busy ? 'status' : undefined, children: [busy ? (_jsx(Spinner, { size: ICON_MD })) : Icon === undefined ? null : (_jsx(Icon, { "aria-hidden": true, size: ICON_MD })), _jsx("span", { className: "pane-message-text", children: children })] }));
|
|
39
39
|
// Outside every listing scope it carries the scope itself, as a listing
|
|
40
40
|
// does, so it keeps its look anywhere.
|
|
41
41
|
return scoped ? note : _jsx("div", { className: "listing-root", children: note });
|
|
@@ -21,7 +21,8 @@ export interface SideBySideProps {
|
|
|
21
21
|
* the room the pair is given is `from` pixels wide or more, one over the
|
|
22
22
|
* other in less, a hairline between them either way. Once side by side, it
|
|
23
23
|
* stacks only under `from` less a scrollbar's width, so a scrollbar the
|
|
24
|
-
* two columns bring cannot flip it back and forth
|
|
24
|
+
* two columns bring cannot flip it back and forth; a changed `from`
|
|
25
|
+
* applies whole to the first width measured against it. The room is the
|
|
25
26
|
* pair's own, measured as it resizes (`data-layout`: `side-by-side` or
|
|
26
27
|
* `stacked`), so a pane narrowed by its sidebar or a split stacks them
|
|
27
28
|
* though the window is wide. It is a layout alone: each part is a group
|
package/dist/frame/SideBySide.js
CHANGED
|
@@ -14,7 +14,8 @@ const SCROLLBAR_HOLD = 20;
|
|
|
14
14
|
* the room the pair is given is `from` pixels wide or more, one over the
|
|
15
15
|
* other in less, a hairline between them either way. Once side by side, it
|
|
16
16
|
* stacks only under `from` less a scrollbar's width, so a scrollbar the
|
|
17
|
-
* two columns bring cannot flip it back and forth
|
|
17
|
+
* two columns bring cannot flip it back and forth; a changed `from`
|
|
18
|
+
* applies whole to the first width measured against it. The room is the
|
|
18
19
|
* pair's own, measured as it resizes (`data-layout`: `side-by-side` or
|
|
19
20
|
* `stacked`), so a pane narrowed by its sidebar or a split stacks them
|
|
20
21
|
* though the window is wide. It is a layout alone: each part is a group
|
|
@@ -25,6 +26,8 @@ const SCROLLBAR_HOLD = 20;
|
|
|
25
26
|
export function SideBySide({ from, first, firstLabel, second, secondLabel }) {
|
|
26
27
|
const ref = useRef(null);
|
|
27
28
|
const [sideBySide, setSideBySide] = useState(false);
|
|
29
|
+
// The `from` the last laid-out width was measured against.
|
|
30
|
+
const measuredFrom = useRef(null);
|
|
28
31
|
// Measured before the first paint, so the pair never draws in the other
|
|
29
32
|
// layout first. A threshold a prop gives cannot reach a container query,
|
|
30
33
|
// whose conditions read no custom property, so the width is read here.
|
|
@@ -32,11 +35,20 @@ export function SideBySide({ from, first, firstLabel, second, secondLabel }) {
|
|
|
32
35
|
const element = ref.current;
|
|
33
36
|
if (element === null)
|
|
34
37
|
return undefined;
|
|
35
|
-
// A width of 0 is a page not laid out (held behind another tab), which
|
|
38
|
+
// A width of 0 is a page not laid out (held behind another tab), which
|
|
39
|
+
// keeps its layout. The hold is for a scrollbar the layout itself
|
|
40
|
+
// brought, so the first width measured against a new `from` (as it
|
|
41
|
+
// mounts, as `from` changes, or when a page hidden through the change
|
|
42
|
+
// comes into view) decides without it. The `from` last measured lives
|
|
43
|
+
// in a ref, not in this effect, so an effect that runs again with the
|
|
44
|
+
// same `from` (a page shown again through <Activity>) keeps the hold.
|
|
36
45
|
const measure = () => {
|
|
37
46
|
const width = element.clientWidth;
|
|
38
|
-
if (width
|
|
39
|
-
|
|
47
|
+
if (width === 0)
|
|
48
|
+
return;
|
|
49
|
+
const hold = measuredFrom.current === from;
|
|
50
|
+
measuredFrom.current = from;
|
|
51
|
+
setSideBySide((now) => width >= (now && hold ? from - SCROLLBAR_HOLD : from));
|
|
40
52
|
};
|
|
41
53
|
measure();
|
|
42
54
|
// Optional: jsdom has no ResizeObserver.
|
package/dist/frame/Tree.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LucideIcon } from 'lucide-react';
|
|
2
|
-
import { type KeyboardEvent, type ReactElement, type ReactNode, type Ref } from 'react';
|
|
2
|
+
import { type KeyboardEvent, type MouseEvent, type ReactElement, type ReactNode, type Ref } from 'react';
|
|
3
3
|
import { type RegionHandlers } from '../pane/Pane.js';
|
|
4
4
|
/** Props for {@link TreePane}. */
|
|
5
5
|
export interface TreePaneProps extends RegionHandlers {
|
|
@@ -33,7 +33,9 @@ export interface TreeListProps extends RegionHandlers {
|
|
|
33
33
|
* finds the sidebar pane by, focusable by script and out of the Tab order.
|
|
34
34
|
* Each row steps in by its level. While the list holds the focus, its
|
|
35
35
|
* active descendant is the cursor row, so a screen reader follows the
|
|
36
|
-
* cursor the keys move.
|
|
36
|
+
* cursor the keys move. As the home, it hands the keyboard's menu key (the
|
|
37
|
+
* Menu key, Shift-F10) to the cursor row's `onContextMenu`, as a page's
|
|
38
|
+
* `PaneList` does.
|
|
37
39
|
*/
|
|
38
40
|
export declare function TreeList({ label, ref, children, ...handlers }: TreeListProps): ReactElement;
|
|
39
41
|
/**
|
|
@@ -71,6 +73,15 @@ export interface TreeRowProps {
|
|
|
71
73
|
readonly marked?: boolean;
|
|
72
74
|
/** Opens the row's item on a click anywhere but its controls. */
|
|
73
75
|
readonly onOpen?: () => void;
|
|
76
|
+
/**
|
|
77
|
+
* A secondary click (the right button, a Control-click, the menu key) on
|
|
78
|
+
* the row, with the row's key, for the row's menu: open it at
|
|
79
|
+
* `event.clientX` and `event.clientY`. The row moves the pane's cursor to
|
|
80
|
+
* itself first, so the menu acts on the cursor row, and cancels the
|
|
81
|
+
* browser's own menu; a cancelled event is one the `TreeList` and
|
|
82
|
+
* `TreePane` around it leave alone, so one click never opens two menus.
|
|
83
|
+
*/
|
|
84
|
+
readonly onContextMenu?: (event: MouseEvent<HTMLElement>, rowKey: string) => void;
|
|
74
85
|
/** The row itself takes the focus: in the Tab order while it is the cursor row. */
|
|
75
86
|
readonly focusable?: boolean;
|
|
76
87
|
/**
|
|
@@ -86,10 +97,12 @@ export interface TreeRowProps {
|
|
|
86
97
|
* trailing column and its own tool. Like a listing's `Row`, it follows the
|
|
87
98
|
* pane's cursor (`RowCursorContext`), wearing the cursor row's look and
|
|
88
99
|
* `aria-current`; the pointer moving over it or the focus entering it moves
|
|
89
|
-
* the cursor there
|
|
90
|
-
*
|
|
100
|
+
* the cursor there, and one with `onContextMenu` takes the cursor on a
|
|
101
|
+
* secondary click, then hands the click and its key to the app for the
|
|
102
|
+
* row's menu. Its controls leave the Tab order, since the tree's keys run
|
|
103
|
+
* them. The expansion and its keys stay the host's.
|
|
91
104
|
*/
|
|
92
|
-
export declare function TreeRow({ rowKey, level, kind, toggle, glyph, name, detail, trailing, tool, marked, onOpen, focusable, add }: TreeRowProps): ReactElement;
|
|
105
|
+
export declare function TreeRow({ rowKey, level, kind, toggle, glyph, name, detail, trailing, tool, marked, onOpen, onContextMenu, focusable, add }: TreeRowProps): ReactElement;
|
|
93
106
|
/**
|
|
94
107
|
* What a tree's tool row is: a plain tool (a filter field, a pager, an Add
|
|
95
108
|
* action), a note under a node (past the chevron's slot), a heading over a
|
|
@@ -104,7 +117,7 @@ export interface TreeToolProps {
|
|
|
104
117
|
readonly level?: number;
|
|
105
118
|
/** Its glyph, before the words. */
|
|
106
119
|
readonly icon?: LucideIcon;
|
|
107
|
-
/** Its words. */
|
|
120
|
+
/** Its words; words in a string the sidebar cuts show whole in a tooltip. */
|
|
108
121
|
readonly text?: ReactNode;
|
|
109
122
|
/**
|
|
110
123
|
* Its key among the tree's rows, which joins it to the pane's cursor
|
package/dist/frame/Tree.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Plus } from 'lucide-react';
|
|
|
3
3
|
import { createContext, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useSyncExternalStore } from 'react';
|
|
4
4
|
import { ICON_MD } from '../icon/sizes.js';
|
|
5
5
|
import { RowCursorContext } from '../listing/Listing.js';
|
|
6
|
-
import { regionHandlers } from '../pane/Pane.js';
|
|
6
|
+
import { regionHandlers, unclaimedContextMenu, useMenuKeyHome } from '../pane/Pane.js';
|
|
7
7
|
import { InListingRowContext, InRowContext } from '../pane/PaneActions.js';
|
|
8
8
|
import { cutTooltip } from '../tooltip/Tooltip.logic.js';
|
|
9
9
|
import { useSharedRef } from './sharedRef.js';
|
|
@@ -27,9 +27,13 @@ export function TreePane({ width, active = false, label, ref, children, ...handl
|
|
|
27
27
|
* finds the sidebar pane by, focusable by script and out of the Tab order.
|
|
28
28
|
* Each row steps in by its level. While the list holds the focus, its
|
|
29
29
|
* active descendant is the cursor row, so a screen reader follows the
|
|
30
|
-
* cursor the keys move.
|
|
30
|
+
* cursor the keys move. As the home, it hands the keyboard's menu key (the
|
|
31
|
+
* Menu key, Shift-F10) to the cursor row's `onContextMenu`, as a page's
|
|
32
|
+
* `PaneList` does.
|
|
31
33
|
*/
|
|
32
34
|
export function TreeList({ label, ref, children, ...handlers }) {
|
|
35
|
+
const region = regionHandlers(handlers);
|
|
36
|
+
const menuKey = useMenuKeyHome(true, region);
|
|
33
37
|
const tree = useId();
|
|
34
38
|
const cursor = useContext(RowCursorContext);
|
|
35
39
|
const [list, attach] = useSharedRef(ref);
|
|
@@ -78,7 +82,7 @@ export function TreeList({ label, ref, children, ...handlers }) {
|
|
|
78
82
|
});
|
|
79
83
|
}
|
|
80
84
|
}), [tree]);
|
|
81
|
-
return (_jsx("div", { "aria-label": label, className: "pane-list tree", "data-pane-home": "sidebar", ref: attach, role: "tree", tabIndex: -1, ...
|
|
85
|
+
return (_jsx("div", { "aria-label": label, className: "pane-list tree", "data-pane-home": "sidebar", ref: attach, role: "tree", tabIndex: -1, ...region, ...menuKey, children: _jsx(TreeIdContext.Provider, { value: scope, children: children }) }));
|
|
82
86
|
}
|
|
83
87
|
/**
|
|
84
88
|
* One row of a sidebar's tree: the chevron's slot, the glyph, the name (cut
|
|
@@ -86,10 +90,12 @@ export function TreeList({ label, ref, children, ...handlers }) {
|
|
|
86
90
|
* trailing column and its own tool. Like a listing's `Row`, it follows the
|
|
87
91
|
* pane's cursor (`RowCursorContext`), wearing the cursor row's look and
|
|
88
92
|
* `aria-current`; the pointer moving over it or the focus entering it moves
|
|
89
|
-
* the cursor there
|
|
90
|
-
*
|
|
93
|
+
* the cursor there, and one with `onContextMenu` takes the cursor on a
|
|
94
|
+
* secondary click, then hands the click and its key to the app for the
|
|
95
|
+
* row's menu. Its controls leave the Tab order, since the tree's keys run
|
|
96
|
+
* them. The expansion and its keys stay the host's.
|
|
91
97
|
*/
|
|
92
|
-
export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name, detail, trailing, tool, marked = false, onOpen, focusable = false, add = false }) {
|
|
98
|
+
export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name, detail, trailing, tool, marked = false, onOpen, onContextMenu, focusable = false, add = false }) {
|
|
93
99
|
const cursor = useContext(RowCursorContext);
|
|
94
100
|
const tree = useContext(TreeIdContext);
|
|
95
101
|
const current = useSyncExternalStore(cursor.subscribe, () => cursor.current() === rowKey);
|
|
@@ -111,7 +117,13 @@ export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name,
|
|
|
111
117
|
]
|
|
112
118
|
.filter(Boolean)
|
|
113
119
|
.join(' ');
|
|
114
|
-
return (_jsx(InListingRowContext.Provider, { value: true, children: _jsx(InRowContext.Provider, { value: true, children: _jsxs("div", { "aria-current": current ? 'true' : undefined, "aria-expanded": toggle === undefined ? undefined : toggle.open, "aria-level": level + 1, "aria-selected": marked, className: classes, "data-row-key": rowKey, id: tree === null ? undefined : rowId(tree.id, rowKey), onClick: onOpen,
|
|
120
|
+
return (_jsx(InListingRowContext.Provider, { value: true, children: _jsx(InRowContext.Provider, { value: true, children: _jsxs("div", { "aria-current": current ? 'true' : undefined, "aria-expanded": toggle === undefined ? undefined : toggle.open, "aria-level": level + 1, "aria-selected": marked, className: classes, "data-row-key": rowKey, "data-row-menu": onContextMenu === undefined ? undefined : '', id: tree === null ? undefined : rowId(tree.id, rowKey), onClick: onOpen, onContextMenu: unclaimedContextMenu(onContextMenu &&
|
|
121
|
+
((event) => {
|
|
122
|
+
// The menu acts on the row it opened over, so that row is the cursor first.
|
|
123
|
+
if (!current)
|
|
124
|
+
cursor.point(rowKey);
|
|
125
|
+
onContextMenu(event, rowKey);
|
|
126
|
+
})), onFocus: () => cursor.point(rowKey), onPointerMove: () => {
|
|
115
127
|
if (!current)
|
|
116
128
|
cursor.point(rowKey);
|
|
117
129
|
}, role: "treeitem", style: levelStyle(level), tabIndex: focusable ? (current ? 0 : -1) : undefined, children: [toggle === undefined ? (_jsx("span", { "aria-hidden": true, className: "row-icon" })) : (_jsx(TreeToggle, { label: toggle.label, onToggle: toggle.onToggle, open: toggle.open })), _jsx("span", { "aria-hidden": true, className: "tree-glyph", children: glyph === undefined && add ? _jsx(Plus, { size: ICON_MD }) : glyph }), _jsxs("span", { className: "row-name tree-name", ...(typeof name === 'string' && detail === undefined ? cutTooltip(name) : {}), children: [name, detail === undefined ? null : (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "tree-detail", children: detail })] }))] }), _jsxs("span", { className: "row-meta align-right", children: [trailing, tool === undefined ? null : _jsx("span", { className: "tree-row-tool", children: tool })] })] }) }) }));
|
|
@@ -149,7 +161,7 @@ export function TreeTool({ kind = 'tool', level = 0, icon: Icon, text, rowKey, c
|
|
|
149
161
|
: () => {
|
|
150
162
|
if (!current)
|
|
151
163
|
cursor.point(rowKey);
|
|
152
|
-
}, "aria-level": rowKey === undefined ? undefined : level + 1, role: rowKey !== undefined ? 'treeitem' : kind === 'danger' ? 'alert' : undefined, style: levelStyle(level), children: [Icon === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "tree-note-glyph", children: _jsx(Icon, { size: ICON_MD }) })), text === undefined ? null : (_jsx("span", { className: "tree-note-text", role: rowKey !== undefined && kind === 'danger' ? 'alert' : undefined, children: text })), children] }));
|
|
164
|
+
}, "aria-level": rowKey === undefined ? undefined : level + 1, role: rowKey !== undefined ? 'treeitem' : kind === 'danger' ? 'alert' : undefined, style: levelStyle(level), children: [Icon === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "tree-note-glyph", children: _jsx(Icon, { size: ICON_MD }) })), text === undefined ? null : (_jsx("span", { className: "tree-note-text", role: rowKey !== undefined && kind === 'danger' ? 'alert' : undefined, ...(typeof text === 'string' ? cutTooltip(text) : {}), children: text })), children] }));
|
|
153
165
|
}
|
|
154
166
|
/**
|
|
155
167
|
* A tree's filter field: a bare field that fills its `TreeTool` row, the
|
package/dist/frame/frame.css
CHANGED
|
@@ -747,6 +747,14 @@
|
|
|
747
747
|
min-width: 0;
|
|
748
748
|
}
|
|
749
749
|
|
|
750
|
+
/* Set straight in a pane's body (a PaneList, a PanePage, a PageSlot, which
|
|
751
|
+
draws no box of its own, or one part of a SideBySide), its tools keep the
|
|
752
|
+
rows' inset from the pane's edges, where a section head and a row's icon
|
|
753
|
+
start, as a list of facts does. */
|
|
754
|
+
:is(.pane-list, .pane-page, .page-slot, .side-by-side-part) > .pane-toolbar {
|
|
755
|
+
padding-inline: var(--pane-row-inset);
|
|
756
|
+
}
|
|
757
|
+
|
|
750
758
|
.pane-toolbar > * {
|
|
751
759
|
flex: none;
|
|
752
760
|
}
|
|
@@ -19,9 +19,10 @@ export interface KeyChordProps {
|
|
|
19
19
|
readonly recording?: boolean;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* A chord as a row of key caps in a `<kbd>`. The accessible name
|
|
23
|
-
* the full chord in words ("Shift Command N", from
|
|
24
|
-
* when the drawing omits a modifier a strip shows
|
|
22
|
+
* A chord as a row of key caps in a `<kbd role="img">`. The accessible name
|
|
23
|
+
* is always the full chord in words ("Shift Command N", from
|
|
24
|
+
* `UiokLabels.keys`), even when the drawing omits a modifier a strip shows
|
|
25
|
+
* once, and a control round it reads it in its own name. A chord with an
|
|
25
26
|
* empty key draws its modifiers alone.
|
|
26
27
|
*/
|
|
27
28
|
export declare function KeyChord({ chord, omit, tone, recording }: KeyChordProps): ReactElement;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ArrowBigUp, ArrowDown, ArrowDownToLine, ArrowLeft, ArrowRight, ArrowRightToLine, ArrowUp, ArrowUpToLine, ChevronUp, ChevronsDown, ChevronsUp, Command, CornerDownLeft, Delete, Option, Slash } from 'lucide-react';
|
|
3
3
|
import { Fragment } from 'react';
|
|
4
4
|
import { chordParts, chordSpoken } from '../keyboard/KeyChord.logic.js';
|
|
@@ -44,15 +44,19 @@ function Key({ part, labels }) {
|
|
|
44
44
|
return (_jsx("span", { "aria-hidden": true, className: text.length > 1 ? 'key key-word' : 'key key-letter', children: text }));
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
|
-
* A chord as a row of key caps in a `<kbd>`. The accessible name
|
|
48
|
-
* the full chord in words ("Shift Command N", from
|
|
49
|
-
* when the drawing omits a modifier a strip shows
|
|
47
|
+
* A chord as a row of key caps in a `<kbd role="img">`. The accessible name
|
|
48
|
+
* is always the full chord in words ("Shift Command N", from
|
|
49
|
+
* `UiokLabels.keys`), even when the drawing omits a modifier a strip shows
|
|
50
|
+
* once, and a control round it reads it in its own name. A chord with an
|
|
50
51
|
* empty key draws its modifiers alone.
|
|
51
52
|
*/
|
|
52
53
|
export function KeyChord({ chord, omit = [], tone, recording = false }) {
|
|
53
54
|
const { keys } = useLabels();
|
|
54
55
|
const parts = chordParts(chord).filter((part) => typeof part === 'object' ? part.key !== '' : !omit.includes(part));
|
|
55
|
-
return (_jsx("kbd", { "aria-label": chordSpoken(chord, keys), className: "keychord",
|
|
56
|
+
return (_jsx("kbd", { "aria-label": chordSpoken(chord, keys), className: "keychord",
|
|
57
|
+
// A kbd has no role of its own to carry a name; as an image its name
|
|
58
|
+
// is the chord in words, and it is how a control round it reads it.
|
|
59
|
+
role: "img", "data-state": recording ? 'recording' : undefined, "data-tone": tone, children: parts.map((part, index) => (_jsx(Key, { labels: keys, part: part }, index))) }));
|
|
56
60
|
}
|
|
57
61
|
/**
|
|
58
62
|
* Several chords that run one verb, each its own `KeyChord`, parted by the
|
|
@@ -66,5 +70,5 @@ export function KeyChords({ chords, tone }) {
|
|
|
66
70
|
const { keys } = useLabels();
|
|
67
71
|
if (chords.length === 0)
|
|
68
72
|
return null;
|
|
69
|
-
return (_jsx("span", { className: "keychords", children: chords.map((chord, index) => (_jsxs(Fragment, { children: [index === 0 ? null : _jsx("span", { className: "keychords-or", children: keys.or }), _jsx(KeyChord, { chord: chord, tone: tone })] }, index))) }));
|
|
73
|
+
return (_jsx("span", { className: "keychords", children: chords.map((chord, index) => (_jsxs(Fragment, { children: [index === 0 ? null : (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "keychords-or", children: keys.or }), ' '] })), _jsx(KeyChord, { chord: chord, tone: tone })] }, index))) }));
|
|
70
74
|
}
|
package/dist/legend/legend.css
CHANGED
|
@@ -210,16 +210,12 @@
|
|
|
210
210
|
.keylegend-more-place > .keylegend-more-list {
|
|
211
211
|
top: auto;
|
|
212
212
|
bottom: calc(100% + var(--space-2));
|
|
213
|
-
|
|
214
|
-
|
|
213
|
+
/* The list ends where the chip ends the strip: its inline end, the right
|
|
214
|
+
edge, or the left right to left. Logical insets follow the box's own
|
|
215
|
+
direction, so an LTR footer inside an RTL page keeps the left-to-right
|
|
216
|
+
place; not :dir(rtl), which a bundler's CSS transform rewrites into
|
|
217
|
+
:lang() selectors that an RTL box in an English page does not match. */
|
|
218
|
+
inset-inline: auto 0;
|
|
215
219
|
width: max-content;
|
|
216
220
|
min-width: 200px;
|
|
217
221
|
}
|
|
218
|
-
|
|
219
|
-
/* Right to left, the chip ends the strip on the left: the list ends there
|
|
220
|
-
too. :dir() follows the nearest direction, so an LTR footer inside an RTL
|
|
221
|
-
page keeps the left-to-right place. */
|
|
222
|
-
.keylegend-more-place > .keylegend-more-list:dir(rtl) {
|
|
223
|
-
left: 0;
|
|
224
|
-
right: auto;
|
|
225
|
-
}
|
|
@@ -169,6 +169,21 @@ export interface RowProps {
|
|
|
169
169
|
readonly name: ReactNode;
|
|
170
170
|
/** The name cell's own class, beside `row-name`. */
|
|
171
171
|
readonly nameClass?: string;
|
|
172
|
+
/**
|
|
173
|
+
* More than the name says, in the host's words: what a narrow pane's
|
|
174
|
+
* dropped columns held ("running · 5432"). The name's tooltip at every
|
|
175
|
+
* width, under the whole name (a name in markup by its drawn words), in
|
|
176
|
+
* place of the tooltip a cut name shows alone; its words are also read
|
|
177
|
+
* as the description (below).
|
|
178
|
+
*/
|
|
179
|
+
readonly nameTip?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Read by assistive technology before `nameTip`'s words, and never shown:
|
|
182
|
+
* what kind of item the row is ("Database"), never the name itself. The
|
|
183
|
+
* two are the description of the name's cell, of the row when it takes
|
|
184
|
+
* the focus (`focusable`, `tabbable`), and of a radio row's radio.
|
|
185
|
+
*/
|
|
186
|
+
readonly nameDescription?: string;
|
|
172
187
|
readonly className?: string;
|
|
173
188
|
/**
|
|
174
189
|
* The row's item is not there yet (a version not installed, a product
|
|
@@ -240,8 +255,11 @@ export interface RowProps {
|
|
|
240
255
|
* keeps them in it, for a listing whose rows no key runs. A `focusable` row
|
|
241
256
|
* is a stop of its own: the cursor row in the Tab order (or, while no row
|
|
242
257
|
* is, the one marked `entry`), the others reached by the keys that move it.
|
|
258
|
+
* `nameTip` puts the host's words under the whole name in its tooltip (a
|
|
259
|
+
* narrow pane's dropped columns), and with `nameDescription` they are read
|
|
260
|
+
* after the name.
|
|
243
261
|
*/
|
|
244
|
-
export declare function Row({ rowKey, mark, radio, name, nameClass, className, dim, add, selected, marked, change, emphasis, onOpen, onContextMenu, level, tabbable, focusable, entry, children }: RowProps): ReactElement;
|
|
262
|
+
export declare function Row({ rowKey, mark, radio, name, nameClass, nameTip, nameDescription, className, dim, add, selected, marked, change, emphasis, onOpen, onContextMenu, level, tabbable, focusable, entry, children }: RowProps): ReactElement;
|
|
245
263
|
/**
|
|
246
264
|
* A cell's tone: `warning` a value with something waiting on it (an
|
|
247
265
|
* update), `accent` a value offered (the version an update brings),
|
package/dist/listing/Listing.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ICON_MD, ICON_SM, Spinner } from '../icon/index.js';
|
|
|
5
5
|
import { useLabels } from '../labels/UiokProvider.js';
|
|
6
6
|
import { unclaimedContextMenu } from '../pane/Pane.js';
|
|
7
7
|
import { InListingRowContext, InRowContext, RowLinkLookContext } from '../pane/PaneActions.js';
|
|
8
|
-
import { cutTooltip, describedTooltip } from '../tooltip/Tooltip.logic.js';
|
|
8
|
+
import { cutTooltip, describedTooltip, tooltip } from '../tooltip/Tooltip.logic.js';
|
|
9
9
|
import { ListingScopeContext } from './ListingScope.js';
|
|
10
10
|
import { pathParts } from './PathParts.logic.js';
|
|
11
11
|
/**
|
|
@@ -211,6 +211,25 @@ export const RowCursorContext = createContext({
|
|
|
211
211
|
});
|
|
212
212
|
/** A press on a row's radio picks it and never opens the row. */
|
|
213
213
|
const keepRadioToSelf = (event) => event.stopPropagation();
|
|
214
|
+
/**
|
|
215
|
+
* The tooltip of a row's name, on the box that cuts it. With no host tip,
|
|
216
|
+
* a name in words shows itself whole only while a narrow column cuts it. A
|
|
217
|
+
* host tip shows at every width under the whole name: `nameText`, the
|
|
218
|
+
* name's words (a marked-up name's as rendered), or the tip alone while
|
|
219
|
+
* they are not known.
|
|
220
|
+
*/
|
|
221
|
+
function nameTooltip(name, nameText, tip) {
|
|
222
|
+
if (tip === undefined || tip === '')
|
|
223
|
+
return typeof name === 'string' ? cutTooltip(name) : {};
|
|
224
|
+
return tooltip(nameText === null || nameText === '' ? tip : `${nameText}\n${tip}`, null, {
|
|
225
|
+
value: true
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/** What a row's name is described by: the host's description, then its tip; none when neither. */
|
|
229
|
+
function nameDescribed(description, tip) {
|
|
230
|
+
const parts = [description, tip].filter((part) => part !== undefined && part !== '');
|
|
231
|
+
return parts.length === 0 ? {} : { 'aria-description': parts.join(', ') };
|
|
232
|
+
}
|
|
214
233
|
/**
|
|
215
234
|
* One row of a listing: its mark, its name, then its cells. `rowKey` names
|
|
216
235
|
* it to the pane's cursor (`RowCursorContext`), which it wears as the
|
|
@@ -225,15 +244,35 @@ const keepRadioToSelf = (event) => event.stopPropagation();
|
|
|
225
244
|
* keeps them in it, for a listing whose rows no key runs. A `focusable` row
|
|
226
245
|
* is a stop of its own: the cursor row in the Tab order (or, while no row
|
|
227
246
|
* is, the one marked `entry`), the others reached by the keys that move it.
|
|
247
|
+
* `nameTip` puts the host's words under the whole name in its tooltip (a
|
|
248
|
+
* narrow pane's dropped columns), and with `nameDescription` they are read
|
|
249
|
+
* after the name.
|
|
228
250
|
*/
|
|
229
|
-
export function Row({ rowKey, mark, radio, name, nameClass, className, dim = false, add = false, selected = false, marked = false, change = null, emphasis = false, onOpen, onContextMenu, level = 0, tabbable = false, focusable = false, entry = false, children }) {
|
|
251
|
+
export function Row({ rowKey, mark, radio, name, nameClass, nameTip, nameDescription, className, dim = false, add = false, selected = false, marked = false, change = null, emphasis = false, onOpen, onContextMenu, level = 0, tabbable = false, focusable = false, entry = false, children }) {
|
|
230
252
|
const cursor = useContext(RowCursorContext);
|
|
231
253
|
const current = useSyncExternalStore(cursor.subscribe, () => cursor.current() === rowKey);
|
|
232
254
|
const nameId = useId();
|
|
255
|
+
const nameBox = useRef(null);
|
|
256
|
+
// A marked-up name's words, read from the drawn name for the host tip's
|
|
257
|
+
// tooltip; a name in words is its own.
|
|
258
|
+
const [drawnName, setDrawnName] = useState(null);
|
|
259
|
+
const nameText = typeof name === 'string' ? name : drawnName;
|
|
260
|
+
const tipped = nameTip !== undefined && nameTip !== '';
|
|
261
|
+
// Read where the focus lands (a focusable or tabbable row, a radio) and in
|
|
262
|
+
// the name's cell for a table's navigation.
|
|
263
|
+
const described = nameDescribed(nameDescription, nameTip);
|
|
233
264
|
useLayoutEffect(() => {
|
|
234
265
|
cursor.rowsChanged?.();
|
|
235
266
|
return () => cursor.rowsChanged?.();
|
|
236
267
|
}, [cursor, rowKey]);
|
|
268
|
+
// Whenever the name is drawn again: a name in markup is a new element
|
|
269
|
+
// each time its host draws it.
|
|
270
|
+
useLayoutEffect(() => {
|
|
271
|
+
if (!tipped || typeof name === 'string')
|
|
272
|
+
return;
|
|
273
|
+
const text = nameBox.current?.textContent ?? '';
|
|
274
|
+
setDrawnName((now) => (now === text ? now : text));
|
|
275
|
+
}, [tipped, name]);
|
|
237
276
|
return (_jsx(InListingRowContext.Provider, { value: true, children: _jsx(InRowContext.Provider, { value: !tabbable, children: _jsxs("div", { "aria-current": current ? 'true' : undefined, "aria-selected": selected || undefined, className: [
|
|
238
277
|
'row',
|
|
239
278
|
current ? 'cursor' : '',
|
|
@@ -258,10 +297,10 @@ export function Row({ rowKey, mark, radio, name, nameClass, className, dim = fal
|
|
|
258
297
|
onPointerMove: () => {
|
|
259
298
|
if (!current)
|
|
260
299
|
cursor.point(rowKey);
|
|
261
|
-
}, role: "row", style: level > 0 ? { '--row-level': level } : undefined, tabIndex: focusable ? (current || entry ? 0 : -1) : undefined, children: [radio === undefined ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: "row-icon", children: mark === undefined && add ? _jsx(Plus, { size: ICON_MD }) : mark }), _jsx("span", { className: nameClass === undefined ? 'row-name' : `row-name ${nameClass}`, role: "cell", ...(
|
|
300
|
+
}, role: "row", style: level > 0 ? { '--row-level': level } : undefined, tabIndex: focusable ? (current || entry ? 0 : -1) : undefined, ...(focusable || tabbable ? described : {}), children: [radio === undefined ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: "row-icon", children: mark === undefined && add ? _jsx(Plus, { size: ICON_MD }) : mark }), _jsx("span", { className: nameClass === undefined ? 'row-name' : `row-name ${nameClass}`, ref: nameBox, role: "cell", ...nameTooltip(name, nameText, nameTip), ...described, children: name })] })) : (_jsxs("span", { className: nameClass === undefined ? 'row-name row-pick' : `row-name row-pick ${nameClass}`, role: "cell", ...described, children: [_jsx("input", { "aria-labelledby": nameId, ...described, checked: radio.checked, className: "check row-radio", "data-verb": radio.verb, disabled: radio.disabled, name: radio.group, onChange: () => {
|
|
262
301
|
if (!radio.disabled)
|
|
263
302
|
radio.onPick();
|
|
264
|
-
}, onClick: keepRadioToSelf, tabIndex: tabbable ? undefined : -1, type: "radio" }), _jsx("span", { className: "row-pick-name", id: nameId,
|
|
303
|
+
}, onClick: keepRadioToSelf, tabIndex: tabbable ? undefined : -1, type: "radio" }), _jsx("span", { className: "row-pick-name", id: nameId, ref: nameBox, ...nameTooltip(name, nameText, nameTip), children: name })] })), children] }) }) }));
|
|
265
304
|
}
|
|
266
305
|
/**
|
|
267
306
|
* A cell of a row after its name, in the listing's metadata look
|