@bigpixelrocket/uiok 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +36 -1
  2. package/dist/button/TextLink.d.ts +9 -2
  3. package/dist/button/TextLink.js +4 -3
  4. package/dist/button/button.css +7 -0
  5. package/dist/dialog/SectionedDialog.d.ts +37 -0
  6. package/dist/dialog/SectionedDialog.js +157 -0
  7. package/dist/dialog/dialog.css +102 -0
  8. package/dist/dialog/index.d.ts +4 -2
  9. package/dist/dialog/index.js +4 -2
  10. package/dist/frame/AppRoot.d.ts +1 -1
  11. package/dist/frame/AppRoot.js +2 -1
  12. package/dist/frame/Dock.d.ts +1 -1
  13. package/dist/frame/Dock.js +2 -1
  14. package/dist/frame/FilterChips.d.ts +5 -2
  15. package/dist/frame/FilterChips.js +35 -2
  16. package/dist/frame/FilterChips.logic.d.ts +24 -0
  17. package/dist/frame/FilterChips.logic.js +34 -0
  18. package/dist/frame/PageParts.d.ts +4 -3
  19. package/dist/frame/PageParts.js +10 -3
  20. package/dist/frame/SideBySide.d.ts +32 -0
  21. package/dist/frame/SideBySide.js +50 -0
  22. package/dist/frame/Tree.d.ts +1 -1
  23. package/dist/frame/Tree.js +3 -2
  24. package/dist/frame/WindowFrame.d.ts +1 -1
  25. package/dist/frame/WindowFrame.js +2 -1
  26. package/dist/frame/frame.css +48 -1
  27. package/dist/frame/index.d.ts +4 -2
  28. package/dist/frame/index.js +4 -2
  29. package/dist/grid/grid.css +1 -0
  30. package/dist/keyboard/Keyboard.logic.js +20 -3
  31. package/dist/keychord/KeyChord.d.ts +17 -1
  32. package/dist/keychord/KeyChord.js +16 -1
  33. package/dist/keychord/ShortcutIndex.d.ts +49 -0
  34. package/dist/keychord/ShortcutIndex.js +28 -0
  35. package/dist/keychord/index.d.ts +8 -2
  36. package/dist/keychord/index.js +8 -2
  37. package/dist/keychord/keychord.css +101 -0
  38. package/dist/labels/dialog.d.ts +2 -0
  39. package/dist/labels/dialog.js +2 -1
  40. package/dist/labels/keys.d.ts +5 -0
  41. package/dist/labels/keys.js +2 -1
  42. package/dist/listing/Listing.d.ts +36 -4
  43. package/dist/listing/Listing.js +21 -6
  44. package/dist/listing/PaneMessage.d.ts +7 -4
  45. package/dist/listing/PaneMessage.js +11 -4
  46. package/dist/listing/index.d.ts +1 -1
  47. package/dist/listing/listing.css +84 -4
  48. package/dist/menu/Menu.d.ts +52 -8
  49. package/dist/menu/Menu.js +288 -80
  50. package/dist/menu/Menu.logic.d.ts +39 -12
  51. package/dist/menu/Menu.logic.js +36 -8
  52. package/dist/menu/index.d.ts +4 -3
  53. package/dist/menu/index.js +2 -1
  54. package/dist/menu/menu.css +6 -0
  55. package/dist/palette/PaletteRows.d.ts +11 -2
  56. package/dist/palette/PaletteRows.js +6 -4
  57. package/dist/pane/Pane.d.ts +42 -6
  58. package/dist/pane/Pane.js +92 -5
  59. package/dist/pane/PaneKeys.d.ts +5 -1
  60. package/dist/pane/PaneKeys.js +28 -3
  61. package/dist/pane/PaneKeys.logic.d.ts +25 -0
  62. package/dist/pane/PaneKeys.logic.js +30 -0
  63. package/dist/pane/index.d.ts +1 -1
  64. package/dist/pane/index.js +1 -1
  65. package/dist/pane/usePaneKeys.d.ts +8 -1
  66. package/dist/pane/usePaneKeys.js +32 -12
  67. package/dist/styles.css +17 -3
  68. package/dist/surface/FactList.d.ts +54 -0
  69. package/dist/surface/FactList.js +33 -0
  70. package/dist/surface/index.d.ts +4 -1
  71. package/dist/surface/index.js +4 -1
  72. package/dist/surface/surface.css +75 -2
  73. package/dist/terminal/ghostty/core.d.ts +12 -4
  74. package/dist/terminal/ghostty/core.js +12 -4
  75. package/dist/terminal/index.d.ts +4 -2
  76. package/dist/terminal/index.js +4 -2
  77. package/dist/text/Code.d.ts +15 -0
  78. package/dist/text/Code.js +12 -0
  79. package/dist/text/index.d.ts +6 -1
  80. package/dist/text/index.js +6 -1
  81. package/dist/text/text.css +21 -0
  82. package/dist/themes/tokens.js +3 -1
  83. package/package.json +1 -1
@@ -46,6 +46,13 @@ export interface PaletteOptionProps {
46
46
  * name: a `CurrentDot` after the trail.
47
47
  */
48
48
  readonly current?: string | null;
49
+ /**
50
+ * The row is one of several that can be picked together (the scripts a
51
+ * project includes): true draws the check mark in the icon column, in
52
+ * place of `mark`, and false leaves it empty (`aria-checked`). A press
53
+ * calls `onPick`, which toggles it; absent, the row is a plain option.
54
+ */
55
+ readonly checked?: boolean;
49
56
  /** The keyboard's cursor stands on it: the cursor fill and bar. */
50
57
  readonly cursor?: boolean;
51
58
  /**
@@ -74,12 +81,14 @@ export interface PaletteOptionProps {
74
81
  * whole in its tooltip), and a trailing column (a version, a count, a
75
82
  * chord) with the current item's dot. The cursor row wears the cursor fill
76
83
  * and bar, its quiet words in the tone made for that fill; a disabled row
77
- * is dimmed and never takes the cursor or a pick. The palette keeps the
84
+ * is dimmed and never takes the cursor or a pick. A `checked` row, one of
85
+ * several picked together, wears the check mark while it is ticked, as a
86
+ * menu's setting does. The palette keeps the
78
87
  * focus in its field, so a press here never takes it. Its name is `label`
79
88
  * or its words; the context, a trail in words, and what `current` means
80
89
  * are read after it as its description, unless `description` says it.
81
90
  */
82
- export declare function PaletteOption({ id, name, label, mark, context, contextKind, trail, current, cursor, disabled, description, onPick, onPoint, ref }: PaletteOptionProps): ReactElement;
91
+ export declare function PaletteOption({ id, name, label, mark, context, contextKind, trail, current, checked, cursor, disabled, description, onPick, onPoint, ref }: PaletteOptionProps): ReactElement;
83
92
  /** Props for {@link PaletteHeading}. */
84
93
  export interface PaletteHeadingProps {
85
94
  /** The group's name: "Installed", "Databases". */
@@ -16,12 +16,14 @@ export function PaletteList({ id, label, children }) {
16
16
  * whole in its tooltip), and a trailing column (a version, a count, a
17
17
  * chord) with the current item's dot. The cursor row wears the cursor fill
18
18
  * and bar, its quiet words in the tone made for that fill; a disabled row
19
- * is dimmed and never takes the cursor or a pick. The palette keeps the
19
+ * is dimmed and never takes the cursor or a pick. A `checked` row, one of
20
+ * several picked together, wears the check mark while it is ticked, as a
21
+ * menu's setting does. The palette keeps the
20
22
  * focus in its field, so a press here never takes it. Its name is `label`
21
23
  * or its words; the context, a trail in words, and what `current` means
22
24
  * are read after it as its description, unless `description` says it.
23
25
  */
24
- export function PaletteOption({ id, name, label, mark, context, contextKind = 'sentence', trail, current = null, cursor = false, disabled = false, description, onPick, onPoint, ref }) {
26
+ export function PaletteOption({ id, name, label, mark, context, contextKind = 'sentence', trail, current = null, checked, cursor = false, disabled = false, description, onPick, onPoint, ref }) {
25
27
  // The name's own id, private to the row, so it never meets a caller's id.
26
28
  const nameId = useId();
27
29
  const contextClass = contextKind === 'path' ? 'palette-context' : `palette-context palette-${contextKind}`;
@@ -31,13 +33,13 @@ export function PaletteOption({ id, name, label, mark, context, contextKind = 's
31
33
  [context, typeof trail === 'string' || typeof trail === 'number' ? String(trail) : '', current]
32
34
  .filter((part) => typeof part === 'string' && part !== '')
33
35
  .join(', ');
34
- return (_jsxs("div", { "aria-description": described === '' ? undefined : described, "aria-disabled": disabled || undefined, "aria-label": label ?? (typeof name === 'string' ? name : undefined), "aria-labelledby": label === undefined && typeof name !== 'string' ? nameId : undefined, "aria-selected": cursor, className: cursor ? 'folder-menu-option cursor' : 'folder-menu-option', id: id, onClick: () => {
36
+ return (_jsxs("div", { "aria-checked": checked, "aria-description": described === '' ? undefined : described, "aria-disabled": disabled || undefined, "aria-label": label ?? (typeof name === 'string' ? name : undefined), "aria-labelledby": label === undefined && typeof name !== 'string' ? nameId : undefined, "aria-selected": cursor, className: cursor ? 'folder-menu-option cursor' : 'folder-menu-option', id: id, onClick: () => {
35
37
  if (!disabled)
36
38
  onPick();
37
39
  }, onMouseMove: () => {
38
40
  if (!disabled && !cursor)
39
41
  onPoint?.();
40
- }, ref: ref, role: "option", children: [_jsx("span", { "aria-hidden": true, className: "row-icon", children: mark }), _jsxs("span", { className: "palette-text", children: [_jsx("span", { className: "row-name", id: nameId, children: name }), context === undefined || context === '' ? null : (_jsx("span", { className: contextClass, ...cutTooltip(context), children: contextKind === 'path' ? _jsx("bdi", { children: context }) : context }))] }), _jsxs("span", { className: "palette-trail", children: [trail === undefined || trail === null ? null : (_jsx("span", { className: "palette-meta", children: trail })), current === null ? null : _jsx(CurrentDot, { label: current })] })] }));
42
+ }, ref: ref, role: "option", children: [_jsx("span", { "aria-hidden": true, className: "row-icon", children: checked === undefined ? mark : null }), _jsxs("span", { className: "palette-text", children: [_jsx("span", { className: "row-name", id: nameId, children: name }), context === undefined || context === '' ? null : (_jsx("span", { className: contextClass, ...cutTooltip(context), children: contextKind === 'path' ? _jsx("bdi", { children: context }) : context }))] }), _jsxs("span", { className: "palette-trail", children: [trail === undefined || trail === null ? null : (_jsx("span", { className: "palette-meta", children: trail })), current === null ? null : _jsx(CurrentDot, { label: current })] })] }));
41
43
  }
42
44
  /**
43
45
  * A group's name over its rows in a palette's or a menu's list, with a
@@ -1,9 +1,32 @@
1
- import type { DOMAttributes, ReactElement, ReactNode, Ref } from 'react';
1
+ import { type DOMAttributes, type MouseEvent, type ReactElement, type ReactNode, type Ref } from 'react';
2
2
  /**
3
3
  * The event handlers a host hangs on a pane or a region of the window for
4
- * its keys, its focus, and its drop zone; nothing that styles it.
4
+ * its keys, its focus, its drop zone, and its menu; nothing that styles it.
5
+ * `onContextMenu` is the region's own menu (open it at `event.clientX` and
6
+ * `event.clientY`): it runs for a secondary click nothing inside the region
7
+ * took (`unclaimedContextMenu`), so the innermost part with a menu wins (a
8
+ * row's, then its pane's, then the region's around it) and one click never
9
+ * opens two.
5
10
  */
6
- export type RegionHandlers = Pick<DOMAttributes<HTMLElement>, 'onBlur' | 'onDragEnter' | 'onDragLeave' | 'onDragOver' | 'onDrop' | 'onFocus' | 'onKeyDown' | 'onKeyDownCapture' | 'onMouseDown' | 'onPointerDown'>;
11
+ export type RegionHandlers = Pick<DOMAttributes<HTMLElement>, 'onBlur' | 'onContextMenu' | 'onDragEnter' | 'onDragLeave' | 'onDragOver' | 'onDrop' | 'onFocus' | 'onKeyDown' | 'onKeyDownCapture' | 'onMouseDown' | 'onPointerDown'>;
12
+ /**
13
+ * A secondary-click handler that runs only for a click nothing inside its
14
+ * element took: a click whose default is already cancelled (a row's menu, a
15
+ * terminal's, a `Menu` opened from inside, whose events reach its owner
16
+ * through React) passes it by, and so does one in a text field (a text
17
+ * input, a textarea, editable content, read-only ones too), which keeps the
18
+ * browser's own Cut, Copy, and Paste. It cancels the browser's own menu
19
+ * before it runs, so the parts around it pass the click by in turn, and one
20
+ * click opens one menu, the innermost's.
21
+ */
22
+ export declare const unclaimedContextMenu: <Target extends Element>(handler: ((event: MouseEvent<Target>) => void) | undefined) => ((event: MouseEvent<Target>) => void) | undefined;
23
+ /**
24
+ * A region's handlers as its element wears them: as given, but for
25
+ * `onContextMenu`, which runs only for a click nothing inside took
26
+ * (`unclaimedContextMenu`). Every part that takes `RegionHandlers` spreads
27
+ * these.
28
+ */
29
+ export declare function regionHandlers<Handlers extends RegionHandlers>(handlers: Handlers): Handlers;
7
30
  /** Props for {@link PaneBox}. */
8
31
  export interface PaneBoxProps extends RegionHandlers {
9
32
  /** The pane holds the keyboard: its frame wears the accent. */
@@ -17,6 +40,14 @@ export interface PaneBoxProps extends RegionHandlers {
17
40
  readonly tone?: 'danger';
18
41
  /** The element it draws: a `section` by default, an `aside` for a sidebar. */
19
42
  readonly as?: 'section' | 'aside';
43
+ /**
44
+ * The visual bell: a count the host raises each time a key could not act
45
+ * (a move past the last row, a verb the cursor row does not offer). Each
46
+ * rise shoves the cursor row sideways for one beat; under reduced motion
47
+ * the row flashes the selection fill instead. The count's value means
48
+ * nothing; only its change rings.
49
+ */
50
+ readonly bell?: number;
20
51
  readonly ref?: Ref<HTMLElement>;
21
52
  /** Its tabs (`PaneTabs`), path bar, list, and status line, top to bottom. */
22
53
  readonly children?: ReactNode;
@@ -25,9 +56,11 @@ export interface PaneBoxProps extends RegionHandlers {
25
56
  * A pane in the listing look (under the listing root a `WindowFrame`
26
57
  * wears): a framed column of its tab strip or path bar, its list, and its
27
58
  * status line. `active` marks the pane that holds the keyboard; the others
28
- * show their cursor row quietly.
59
+ * show their cursor row quietly. `bell` rings on its cursor row
60
+ * (`useBellBeat`; `.bell-0`, `.bell-1`). Its `onContextMenu` takes a
61
+ * secondary click no row or part inside it took.
29
62
  */
30
- export declare function PaneBox({ active, label, tone, as: Element, ref, children, ...handlers }: PaneBoxProps): ReactElement;
63
+ export declare function PaneBox({ active, label, tone, as: Element, bell, ref, children, ...handlers }: PaneBoxProps): ReactElement;
31
64
  /** Props for {@link PaneList}. */
32
65
  export interface PaneListProps extends RegionHandlers {
33
66
  /**
@@ -44,6 +77,9 @@ export interface PaneListProps extends RegionHandlers {
44
77
  }
45
78
  /**
46
79
  * The scrolling body of a pane, between its path bar and its status line:
47
- * the listings and notes the pane shows.
80
+ * the listings and notes the pane shows. As the pane's home, which holds
81
+ * the focus while the keys move its cursor, it hands the keyboard's menu
82
+ * key (the Menu key, Shift-F10) to the cursor row's `onContextMenu`, so a
83
+ * row's menu is reached from the keys too.
48
84
  */
49
85
  export declare function PaneList({ home, pointer, label, ref, children, ...handlers }: PaneListProps): ReactElement;
package/dist/pane/Pane.js CHANGED
@@ -1,17 +1,104 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import { isTextEditingTarget } from '../keyboard/Keyboard.logic.js';
4
+ import { useBellBeat } from '../menu/useBellBeat.js';
5
+ /**
6
+ * A secondary-click handler that runs only for a click nothing inside its
7
+ * element took: a click whose default is already cancelled (a row's menu, a
8
+ * terminal's, a `Menu` opened from inside, whose events reach its owner
9
+ * through React) passes it by, and so does one in a text field (a text
10
+ * input, a textarea, editable content, read-only ones too), which keeps the
11
+ * browser's own Cut, Copy, and Paste. It cancels the browser's own menu
12
+ * before it runs, so the parts around it pass the click by in turn, and one
13
+ * click opens one menu, the innermost's.
14
+ */
15
+ export const unclaimedContextMenu = (handler) => handler === undefined
16
+ ? undefined
17
+ : (event) => {
18
+ if (event.nativeEvent.defaultPrevented || isTextEditingTarget(event.target))
19
+ return;
20
+ event.preventDefault();
21
+ handler(event);
22
+ };
23
+ /**
24
+ * A region's handlers as its element wears them: as given, but for
25
+ * `onContextMenu`, which runs only for a click nothing inside took
26
+ * (`unclaimedContextMenu`). Every part that takes `RegionHandlers` spreads
27
+ * these.
28
+ */
29
+ export function regionHandlers(handlers) {
30
+ const { onContextMenu } = handlers;
31
+ return onContextMenu === undefined
32
+ ? handlers
33
+ : { ...handlers, onContextMenu: unclaimedContextMenu(onContextMenu) };
34
+ }
2
35
  /**
3
36
  * A pane in the listing look (under the listing root a `WindowFrame`
4
37
  * wears): a framed column of its tab strip or path bar, its list, and its
5
38
  * status line. `active` marks the pane that holds the keyboard; the others
6
- * show their cursor row quietly.
39
+ * show their cursor row quietly. `bell` rings on its cursor row
40
+ * (`useBellBeat`; `.bell-0`, `.bell-1`). Its `onContextMenu` takes a
41
+ * secondary click no row or part inside it took.
7
42
  */
8
- export function PaneBox({ active = false, label, tone, as: Element = 'section', ref, children, ...handlers }) {
9
- return (_jsx(Element, { "aria-label": label, className: active ? 'pane active' : 'pane', "data-tone": tone, ref: ref, ...handlers, children: children }));
43
+ export function PaneBox({ active = false, label, tone, as: Element = 'section', bell = 0, ref, children, ...handlers }) {
44
+ const beat = useBellBeat(bell);
45
+ return (_jsx(Element, { "aria-label": label, className: ['pane', active ? 'active' : '', beat === null ? '' : `bell-${beat}`]
46
+ .filter(Boolean)
47
+ .join(' '), "data-tone": tone, ref: ref, ...regionHandlers(handlers), children: children }));
10
48
  }
11
49
  /**
12
50
  * The scrolling body of a pane, between its path bar and its status line:
13
- * the listings and notes the pane shows.
51
+ * the listings and notes the pane shows. As the pane's home, which holds
52
+ * the focus while the keys move its cursor, it hands the keyboard's menu
53
+ * key (the Menu key, Shift-F10) to the cursor row's `onContextMenu`, so a
54
+ * row's menu is reached from the keys too.
14
55
  */
15
56
  export function PaneList({ home = false, pointer = false, label, ref, children, ...handlers }) {
16
- return (_jsx("div", { "aria-label": label, className: pointer ? 'pane-list pointer' : 'pane-list', "data-pane-home": home ? '' : undefined, ref: ref, tabIndex: home ? -1 : undefined, ...handlers, children: children }));
57
+ const region = regionHandlers(handlers);
58
+ // Whether the keyboard's menu key (the Menu key, Shift-F10) was the last
59
+ // thing pressed: only it makes a menu the keyboard's, until the menu it
60
+ // asks for, another key, or a press of the pointer. The event alone cannot
61
+ // tell: Chromium sends the Menu key's as a mouse's pointer event.
62
+ const menuKey = useRef(false);
63
+ return (_jsx("div", { "aria-label": label, className: pointer ? 'pane-list pointer' : 'pane-list', "data-pane-home": home ? '' : undefined, ref: ref, tabIndex: home ? -1 : undefined, ...region, onContextMenu: (event) => {
64
+ const fromKeys = menuKey.current;
65
+ menuKey.current = false;
66
+ if (home && fromKeys && event.target === event.currentTarget)
67
+ menuOnCursorRow(event);
68
+ region.onContextMenu?.(event);
69
+ }, onKeyDownCapture: (event) => {
70
+ menuKey.current =
71
+ event.key === 'ContextMenu' ||
72
+ (event.key === 'F10' &&
73
+ event.shiftKey &&
74
+ !event.ctrlKey &&
75
+ !event.altKey &&
76
+ !event.metaKey);
77
+ region.onKeyDownCapture?.(event);
78
+ }, onPointerDownCapture: () => {
79
+ menuKey.current = false;
80
+ }, children: children }));
81
+ }
82
+ /**
83
+ * The keyboard's menu key aimed at a pane's home, which holds the focus
84
+ * while its cursor row does not: the cursor row with a menu of its own
85
+ * (`Row`'s `onContextMenu`, `data-row-menu`) takes it, as a secondary click
86
+ * on it, placed under the row's leading edge rather than wherever the
87
+ * keyboard's event says, and the home's own claims none.
88
+ */
89
+ function menuOnCursorRow(event) {
90
+ const row = event.currentTarget.querySelector('[data-row-key][aria-current="true"][data-row-menu]');
91
+ if (row === null || event.nativeEvent.defaultPrevented)
92
+ return;
93
+ const box = row.getBoundingClientRect();
94
+ const rtl = getComputedStyle(row).direction === 'rtl';
95
+ const click = new globalThis.MouseEvent('contextmenu', {
96
+ bubbles: true,
97
+ cancelable: true,
98
+ clientX: rtl ? box.right : box.left,
99
+ clientY: box.bottom
100
+ });
101
+ row.dispatchEvent(click);
102
+ if (click.defaultPrevented)
103
+ event.preventDefault();
17
104
  }
@@ -1,4 +1,5 @@
1
1
  import type { ControlVerb } from './PaneActions.js';
2
+ import { type TabOrder } from './PaneKeys.logic.js';
2
3
  /**
3
4
  * A pane's home that shows: the first `data-pane-home` element in it (the
4
5
  * sidebar's with `"sidebar"`) outside a hidden page, or null for none.
@@ -37,8 +38,11 @@ export interface SidebarTabStops {
37
38
  * its listing keeps them in the Tab order (`Row`'s `tabbable`); a sidebar
38
39
  * row's never are. With `alone` (no sidebar shown) the page's stops make
39
40
  * the one cycle, wrapping at either end, and the sidebar is never named.
41
+ * With `order` `listing`, each pane's listing comes first instead of where
42
+ * the document puts it (`listingFirstStop`): the page's listing, its other
43
+ * stops, then the sidebar's listing and, with `sidebar`, its stops.
40
44
  */
41
- export declare function nextTabStop(main: Element, home: HTMLElement, from: TabStop, back: boolean, sidebar?: SidebarTabStops | null, alone?: boolean): TabStop;
45
+ export declare function nextTabStop(main: Element, home: HTMLElement, from: TabStop, back: boolean, sidebar?: SidebarTabStops | null, alone?: boolean, order?: TabOrder): TabStop;
42
46
  /**
43
47
  * The rows one Page Up or Page Down moves in a pane: what its home
44
48
  * (`data-pane-home`) shows of 24px rows, less one kept in view.
@@ -5,6 +5,7 @@
5
5
  * panes say what they offer by these marks, so the keys run exactly what a
6
6
  * click would, disabled where the control is.
7
7
  */
8
+ import { listingFirstStop } from './PaneKeys.logic.js';
8
9
  /**
9
10
  * The elements in `root` matching `selector` that show: none inside a
10
11
  * `hidden` element under `root`, such as a page held mounted out of sight
@@ -42,12 +43,17 @@ export function verbControl(root, verb, attribute = 'verb') {
42
43
  const FOCUSABLE = 'a[href], button, input, select, textarea, summary, [tabindex]';
43
44
  /**
44
45
  * Whether Tab would stop on an element: focusable, not taken out of the
45
- * order, not disabled, not hidden or inert, not inside a closed disclosure
46
+ * order, not disabled, not a hidden input, not hidden or inert, not inside a closed disclosure
46
47
  * (its summary aside), and, of a radio group, only its checked radio, or
47
48
  * its first while none is.
48
49
  */
49
50
  function tabbable(element) {
50
- if (element.tabIndex < 0 || element.disabled)
51
+ // `:disabled` also covers a control inside a disabled fieldset, which
52
+ // refuses the focus though its own `disabled` is false.
53
+ if (element.tabIndex < 0 || element.matches(':disabled'))
54
+ return false;
55
+ // A hidden input is never drawn, so it never takes the focus, whatever its tabindex.
56
+ if (element instanceof HTMLInputElement && element.type === 'hidden')
51
57
  return false;
52
58
  if (element.closest('[hidden], [inert], [aria-hidden="true"]') !== null)
53
59
  return false;
@@ -81,8 +87,27 @@ const inDocumentOrder = (a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_P
81
87
  * its listing keeps them in the Tab order (`Row`'s `tabbable`); a sidebar
82
88
  * row's never are. With `alone` (no sidebar shown) the page's stops make
83
89
  * the one cycle, wrapping at either end, and the sidebar is never named.
90
+ * With `order` `listing`, each pane's listing comes first instead of where
91
+ * the document puts it (`listingFirstStop`): the page's listing, its other
92
+ * stops, then the sidebar's listing and, with `sidebar`, its stops.
84
93
  */
85
- export function nextTabStop(main, home, from, back, sidebar = null, alone = false) {
94
+ export function nextTabStop(main, home, from, back, sidebar = null, alone = false, order = 'document') {
95
+ if (order === 'listing') {
96
+ const page = {
97
+ home: 'page',
98
+ stops: tabStops(main).filter((stop) => stop !== home)
99
+ };
100
+ const side = alone
101
+ ? null
102
+ : {
103
+ home: 'sidebar',
104
+ stops: sidebar === null
105
+ ? []
106
+ : tabStops(sidebar.pane).filter((stop) => stop !== sidebar.home && stop.closest('[data-row-key]') === null)
107
+ };
108
+ const at = from === home ? 'page' : sidebar !== null && from === sidebar.home ? 'sidebar' : from;
109
+ return listingFirstStop(page, side, at, back);
110
+ }
86
111
  if (from === 'sidebar' && sidebar === null)
87
112
  return 'page';
88
113
  const at = from === 'sidebar' ? (sidebar?.home ?? home) : from === 'page' ? home : from;
@@ -93,3 +93,28 @@ export declare const NO_MAIN_VERBS: MainVerbs;
93
93
  * so a reading that changed nothing keeps the one a legend drew.
94
94
  */
95
95
  export declare const sameVerbs: <Verbs extends object>(a: Verbs, b: Verbs) => boolean;
96
+ /**
97
+ * The order Tab walks a two-pane window in: `document`, every stop where
98
+ * the document puts it, each pane's listing among them; `listing`, each
99
+ * pane's listing first, then its other stops in document order, as a file
100
+ * manager walks its panes (`listingFirstStop`).
101
+ */
102
+ export type TabOrder = 'document' | 'listing';
103
+ /** One pane as a listing-first walk sees it: its listing (its home) and its other stops in document order. */
104
+ export interface WalkPane<Stop> {
105
+ readonly home: Stop;
106
+ /** The pane's Tab stops in document order, its home left out. */
107
+ readonly stops: readonly Stop[];
108
+ }
109
+ /**
110
+ * Where Tab (Shift-Tab with `back`) goes from `from` in a listing-first
111
+ * walk: from the page's listing through the page's other stops in document
112
+ * order, then to the sidebar's listing and through its stops, then back to
113
+ * the page's listing. Shift-Tab steps back through a pane's stops to its
114
+ * listing, and from a listing switches panes to the other one's listing.
115
+ * Without a sidebar (none shown), the page's listing and stops make one
116
+ * cycle that wraps at either end. A `from` neither pane holds (the window
117
+ * itself, a row's control) goes on as from the page's listing. Pure over
118
+ * whatever stands for a stop, so the rule is tested without a DOM.
119
+ */
120
+ export declare function listingFirstStop<Stop>(page: WalkPane<Stop>, sidebar: WalkPane<Stop> | null, from: Stop | null, back: boolean): Stop;
@@ -107,3 +107,33 @@ export const NO_MAIN_VERBS = {
107
107
  */
108
108
  export const sameVerbs = (a, b) => Object.keys(a).every((field) => a[field] === b[field]) &&
109
109
  Object.keys(b).length === Object.keys(a).length;
110
+ /**
111
+ * Where Tab (Shift-Tab with `back`) goes from `from` in a listing-first
112
+ * walk: from the page's listing through the page's other stops in document
113
+ * order, then to the sidebar's listing and through its stops, then back to
114
+ * the page's listing. Shift-Tab steps back through a pane's stops to its
115
+ * listing, and from a listing switches panes to the other one's listing.
116
+ * Without a sidebar (none shown), the page's listing and stops make one
117
+ * cycle that wraps at either end. A `from` neither pane holds (the window
118
+ * itself, a row's control) goes on as from the page's listing. Pure over
119
+ * whatever stands for a stop, so the rule is tested without a DOM.
120
+ */
121
+ export function listingFirstStop(page, sidebar, from, back) {
122
+ if (sidebar !== null && from !== null) {
123
+ const at = from === sidebar.home ? -1 : sidebar.stops.indexOf(from);
124
+ if (from === sidebar.home || at >= 0) {
125
+ if (!back)
126
+ return sidebar.stops[at + 1] ?? page.home;
127
+ if (at === -1)
128
+ return page.home;
129
+ return at === 0 ? sidebar.home : (sidebar.stops[at - 1] ?? sidebar.home);
130
+ }
131
+ }
132
+ const at = from === null ? -1 : page.stops.indexOf(from);
133
+ if (back) {
134
+ if (at === -1)
135
+ return sidebar?.home ?? page.stops.at(-1) ?? page.home;
136
+ return at === 0 ? page.home : (page.stops[at - 1] ?? page.home);
137
+ }
138
+ return page.stops[at + 1] ?? sidebar?.home ?? page.home;
139
+ }
@@ -12,7 +12,7 @@ export { PaneBox, PaneList, type PaneBoxProps, type PaneListProps, type RegionHa
12
12
  export { InRowContext, QuietAction, RowIconAction, RowLinkLookContext, useInRow, type ControlVerb, type LinkLook, type QuietActionProps, type RowIconActionProps } from './PaneActions.js';
13
13
  export { PanePathBar, PaneStatus, PathFact, type PaneCrumb, type PaneSiblings, type PanePathBarProps, type PaneStatusProps, type PathFactProps } from './PaneFrame.js';
14
14
  export { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, tabStops, verbControl, type SidebarTabStops, type TabStop } from './PaneKeys.js';
15
- export { movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs, type MainVerbs, type PaneKeyAction, type PaneKeyOptions, type PaneKeyStroke, type PaneMove } from './PaneKeys.logic.js';
15
+ export { listingFirstStop, movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs, type MainVerbs, type PaneKeyAction, type PaneKeyOptions, type PaneKeyStroke, type TabOrder, type WalkPane, type PaneMove } from './PaneKeys.logic.js';
16
16
  export { PaneTabs, type PaneTabItem, type PaneTabsProps } from './PaneTabs.js';
17
17
  export { draggedTabOrder, foldOrder, foldsNeeded, gatherTabs, pickedTabs, pickRun, tabLabelFloor, togglePick, type FoldableTab, type TabBox, type TabPicks } from './PaneTabs.logic.js';
18
18
  export { useToolbarFit } from './useToolbarFit.js';
@@ -12,7 +12,7 @@ export { PaneBox, PaneList } from './Pane.js';
12
12
  export { InRowContext, QuietAction, RowIconAction, RowLinkLookContext, useInRow } from './PaneActions.js';
13
13
  export { PanePathBar, PaneStatus, PathFact } from './PaneFrame.js';
14
14
  export { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, tabStops, verbControl } from './PaneKeys.js';
15
- export { movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs } from './PaneKeys.logic.js';
15
+ export { listingFirstStop, movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs } from './PaneKeys.logic.js';
16
16
  export { PaneTabs } from './PaneTabs.js';
17
17
  export { draggedTabOrder, foldOrder, foldsNeeded, gatherTabs, pickedTabs, pickRun, tabLabelFloor, togglePick } from './PaneTabs.logic.js';
18
18
  export { useToolbarFit } from './useToolbarFit.js';
@@ -1,6 +1,6 @@
1
1
  import { type RefObject } from 'react';
2
2
  import type { RowCursor } from '../listing/Listing.js';
3
- import { type PaneMove } from './PaneKeys.logic.js';
3
+ import { type PaneMove, type TabOrder } from './PaneKeys.logic.js';
4
4
  /** The two panes of a two-pane view: the sidebar and the page beside it. */
5
5
  export type Pane = 'sidebar' | 'main';
6
6
  /** What a view hands `usePaneKeys`. */
@@ -46,6 +46,13 @@ export interface PaneKeysOptions<Action extends {
46
46
  * runs. Without it, Tab from the sidebar goes to the page's home.
47
47
  */
48
48
  readonly sidebarStops?: boolean;
49
+ /**
50
+ * The order Tab walks the panes in (`TabOrder`): `document` (the
51
+ * default), every stop where the document puts it; `listing`, each
52
+ * pane's listing first, then its other controls, so Tab from the window
53
+ * lands in the page's listing however many controls stand above it.
54
+ */
55
+ readonly tabOrder?: TabOrder;
49
56
  /**
50
57
  * The view reads each pane's cursor row in render (`mainKey`,
51
58
  * `sidebarKey`), so a cursor move draws the view again: the default.
@@ -2,7 +2,7 @@ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState, use
2
2
  import { isTextEditingTarget } from '../keyboard/Keyboard.logic.js';
3
3
  import { watchOverlays } from '../keyboard/OverlayWatch.js';
4
4
  import { createValueStore, unheard } from '../store/ValueStore.js';
5
- import { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, shownHome } from './PaneKeys.js';
5
+ import { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, shownHome, tabStops } from './PaneKeys.js';
6
6
  import { movedIndex, sameVerbs } from './PaneKeys.logic.js';
7
7
  /** The sidebar's cursor row: the one moved to while it is listed, else the open row, else the first. */
8
8
  const sidebarRow = (moved, keys, openKey) => (moved !== null && keys.includes(moved) ? moved : (openKey ?? keys[0] ?? null));
@@ -240,21 +240,41 @@ export function usePaneKeys(options) {
240
240
  // sidebar control (Refresh) switches panes as the listing does, and a
241
241
  // row's control out of the Tab order goes on from the page's home.
242
242
  const stop = node !== null && isTabStop(node) ? node : null;
243
- const from = pane === 'sidebar'
244
- ? walked !== null && stop !== null && !inRow
245
- ? stop
246
- : 'sidebar'
247
- : onHome || (inRow && stop === null)
248
- ? 'page'
249
- : node;
243
+ const listingFirst = current.tabOrder === 'listing';
244
+ // In a listing-first walk, a key aimed at neither pane (the view
245
+ // itself) goes on as from the page's listing, whichever pane was
246
+ // active (`listingFirstStop`).
247
+ const from = listingFirst && !inSidebar && !inMain
248
+ ? 'page'
249
+ : pane === 'sidebar'
250
+ ? walked !== null && stop !== null && !inRow
251
+ ? stop
252
+ : 'sidebar'
253
+ : onHome || (inRow && stop === null)
254
+ ? 'page'
255
+ : node;
250
256
  const back = 'back' in action && action.back === true;
251
- const to = nextTabStop(main, home, from, back, walked, sidebar === null);
257
+ const after = (stop) => nextTabStop(main, home, stop, back, walked, sidebar === null, listingFirst ? 'listing' : 'document');
252
258
  event.preventDefault();
253
259
  event.stopPropagation();
254
- if (to === 'sidebar' || to === 'page')
255
- focusPane(to === 'sidebar' ? 'sidebar' : 'main');
256
- else
260
+ // A stop the stylesheet hides (display: none) refuses the focus, so
261
+ // the walk goes on past it the same way, once round the stops at
262
+ // most, and ends on the pane's home when none takes it.
263
+ let to = after(from);
264
+ for (let left = tabStops(root).length;; left -= 1) {
265
+ if (to === 'sidebar' || to === 'page') {
266
+ focusPane(to === 'sidebar' ? 'sidebar' : 'main');
267
+ break;
268
+ }
257
269
  to.focus();
270
+ if (document.activeElement === to)
271
+ break;
272
+ if (left <= 0) {
273
+ focusPane(pane);
274
+ break;
275
+ }
276
+ to = after(to);
277
+ }
258
278
  return;
259
279
  }
260
280
  if (typing)
package/dist/styles.css CHANGED
@@ -284,11 +284,22 @@ meter::-webkit-meter-even-less-good-value {
284
284
  animation-timeline: scroll(self block);
285
285
  }
286
286
 
287
+ /* The inline fade runs from the inline start, where the scroll timeline
288
+ starts: the left edge, or the right in a right-to-left box, whose
289
+ scroll position counts down from its right edge. */
290
+ .scroll-fade-x {
291
+ --scroll-fade-inline-to: to right;
292
+ }
293
+
294
+ .scroll-fade-x:dir(rtl) {
295
+ --scroll-fade-inline-to: to left;
296
+ }
297
+
287
298
  .scroll-fade-x {
288
299
  mask-image:
289
300
  linear-gradient(var(--ground), var(--ground)), linear-gradient(var(--ground), var(--ground)),
290
301
  linear-gradient(
291
- to right,
302
+ var(--scroll-fade-inline-to),
292
303
  transparent,
293
304
  var(--ground) var(--scroll-fade-inline-start),
294
305
  var(--ground) calc(100% - var(--scroll-fade-inline-end)),
@@ -320,7 +331,7 @@ meter::-webkit-meter-even-less-good-value {
320
331
  transparent
321
332
  ),
322
333
  linear-gradient(
323
- to right,
334
+ var(--scroll-fade-inline-to),
324
335
  transparent,
325
336
  var(--ground) var(--scroll-fade-inline-start),
326
337
  var(--ground) calc(100% - var(--scroll-fade-inline-end)),
@@ -333,7 +344,7 @@ meter::-webkit-meter-even-less-good-value {
333
344
  linear-gradient(var(--ground), var(--ground)), linear-gradient(var(--ground), var(--ground)),
334
345
  linear-gradient(to bottom, var(--ground) calc(100% - var(--scroll-fade-end)), transparent),
335
346
  linear-gradient(
336
- to right,
347
+ var(--scroll-fade-inline-to),
337
348
  transparent,
338
349
  var(--ground) var(--scroll-fade-inline-start),
339
350
  var(--ground) calc(100% - var(--scroll-fade-inline-end)),
@@ -472,6 +483,7 @@ meter::-webkit-meter-even-less-good-value {
472
483
  .palette-level,
473
484
  .settings-sidebar-page,
474
485
  .settings-sidebar-subsection,
486
+ .sectioned-dialog-nav-row,
475
487
  .quiet-control,
476
488
  .quiet-track-item,
477
489
  .toggle-chip
@@ -490,6 +502,7 @@ meter::-webkit-meter-even-less-good-value {
490
502
  .pane-strip-link,
491
503
  .settings-sidebar-page,
492
504
  .settings-sidebar-subsection,
505
+ .sectioned-dialog-nav-row,
493
506
  .quiet-control,
494
507
  .toggle-chip
495
508
  ):where(button, a[href], [role='button'], [role='tab'], [role='radio']):where(
@@ -551,6 +564,7 @@ meter::-webkit-meter-even-less-good-value {
551
564
  .disclosure,
552
565
  .settings-sidebar-page,
553
566
  .settings-sidebar-subsection,
567
+ .sectioned-dialog-nav-row,
554
568
  .quiet-control,
555
569
  .quiet-track-item,
556
570
  .toggle-chip
@@ -0,0 +1,54 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ /** Props for {@link FactList}. */
3
+ export interface FactListProps {
4
+ /** Its heading, an overline over the facts ("Command"), which names the list too. */
5
+ readonly title?: string;
6
+ /** The list's accessible name, where it has no `title` or the title says less. */
7
+ readonly label?: string;
8
+ /** Its facts (`Fact`). */
9
+ readonly children: ReactNode;
10
+ }
11
+ /**
12
+ * A headed list of facts on a page (what a process runs, how it restarts),
13
+ * one name and value a line: the names in a column of their own in the
14
+ * dim interface face, each value beside its name in the code face. A long
15
+ * value wraps whole as a block beside its name, its next lines under its
16
+ * first, and never runs under the name or breaks the line's alignment. For
17
+ * facts read at a glance, set straight on the page (no card); a short table
18
+ * with a state each is a `FactTable`, and a list the keys move through is a
19
+ * `Listing`. Put several side by side in `FactColumns`. Draws
20
+ * `section.fact-list` with its `dl.fact-list-items`.
21
+ */
22
+ export declare function FactList({ title, label, children }: FactListProps): ReactElement;
23
+ /** A fact value's tone: `danger` a failure (an exit code, an error), `warning` a state that needs a look. */
24
+ export type FactValueTone = 'danger' | 'warning';
25
+ /** Props for {@link Fact}. */
26
+ export interface FactProps {
27
+ /** What the fact is ("Restarts"); an empty name lets the value run on under the line above. */
28
+ readonly name: string;
29
+ /** The value, in the code face ("2h 35m · since 11:48"). */
30
+ readonly children: ReactNode;
31
+ /** Its words in a tone; the text tone unless given. */
32
+ readonly tone?: FactValueTone;
33
+ /**
34
+ * The value is lines a program printed: its line breaks and runs of
35
+ * spaces kept as printed, each line wrapping whole.
36
+ */
37
+ readonly printed?: boolean;
38
+ }
39
+ /**
40
+ * One fact of a `FactList`: its name, then its value beside it, which wraps
41
+ * as a block however long it is. The words can be swept and copied.
42
+ */
43
+ export declare function Fact({ name, children, tone, printed }: FactProps): ReactElement;
44
+ /** Props for {@link FactColumns}. */
45
+ export interface FactColumnsProps {
46
+ /** The lists (`FactList`), in reading order. */
47
+ readonly children: ReactNode;
48
+ }
49
+ /**
50
+ * Fact lists side by side: as many columns of one width as the page has
51
+ * room for (three on a wide page), the lists flowing across and then down,
52
+ * so the lists of a row start on one line. Draws `.fact-columns`.
53
+ */
54
+ export declare function FactColumns({ children }: FactColumnsProps): ReactElement;