@bigpixelrocket/uiok 0.5.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.
Files changed (107) hide show
  1. package/CHANGELOG.md +72 -1
  2. package/dist/button/TextLink.d.ts +21 -2
  3. package/dist/button/TextLink.js +14 -3
  4. package/dist/button/button.css +7 -0
  5. package/dist/dialog/SectionedDialog.d.ts +37 -0
  6. package/dist/dialog/SectionedDialog.js +158 -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/field/FieldLayout.d.ts +3 -2
  11. package/dist/field/FieldLayout.js +8 -3
  12. package/dist/frame/AppRoot.d.ts +1 -1
  13. package/dist/frame/AppRoot.js +2 -1
  14. package/dist/frame/Dock.d.ts +1 -1
  15. package/dist/frame/Dock.js +2 -1
  16. package/dist/frame/FilterChips.d.ts +5 -2
  17. package/dist/frame/FilterChips.js +35 -2
  18. package/dist/frame/FilterChips.logic.d.ts +24 -0
  19. package/dist/frame/FilterChips.logic.js +34 -0
  20. package/dist/frame/PageParts.d.ts +4 -3
  21. package/dist/frame/PageParts.js +10 -3
  22. package/dist/frame/SideBySide.d.ts +33 -0
  23. package/dist/frame/SideBySide.js +62 -0
  24. package/dist/frame/Tree.d.ts +20 -7
  25. package/dist/frame/Tree.js +21 -8
  26. package/dist/frame/WindowFrame.d.ts +1 -1
  27. package/dist/frame/WindowFrame.js +2 -1
  28. package/dist/frame/frame.css +56 -1
  29. package/dist/frame/index.d.ts +4 -2
  30. package/dist/frame/index.js +4 -2
  31. package/dist/grid/grid.css +1 -0
  32. package/dist/keyboard/Keyboard.logic.js +20 -3
  33. package/dist/keychord/KeyChord.d.ts +21 -4
  34. package/dist/keychord/KeyChord.js +24 -5
  35. package/dist/keychord/ShortcutIndex.d.ts +49 -0
  36. package/dist/keychord/ShortcutIndex.js +28 -0
  37. package/dist/keychord/index.d.ts +8 -2
  38. package/dist/keychord/index.js +8 -2
  39. package/dist/keychord/keychord.css +101 -0
  40. package/dist/labels/dialog.d.ts +2 -0
  41. package/dist/labels/dialog.js +2 -1
  42. package/dist/labels/keys.d.ts +5 -0
  43. package/dist/labels/keys.js +2 -1
  44. package/dist/legend/legend.css +6 -10
  45. package/dist/listing/Listing.d.ts +54 -4
  46. package/dist/listing/Listing.js +61 -7
  47. package/dist/listing/PaneMessage.d.ts +7 -4
  48. package/dist/listing/PaneMessage.js +11 -4
  49. package/dist/listing/index.d.ts +1 -1
  50. package/dist/listing/listing.css +124 -5
  51. package/dist/menu/Menu.d.ts +52 -8
  52. package/dist/menu/Menu.js +288 -80
  53. package/dist/menu/Menu.logic.d.ts +39 -12
  54. package/dist/menu/Menu.logic.js +36 -8
  55. package/dist/menu/index.d.ts +4 -3
  56. package/dist/menu/index.js +2 -1
  57. package/dist/menu/menu.css +4 -0
  58. package/dist/palette/Palette.d.ts +3 -1
  59. package/dist/palette/Palette.js +14 -2
  60. package/dist/palette/PaletteRows.d.ts +28 -14
  61. package/dist/palette/PaletteRows.js +21 -17
  62. package/dist/pane/Pane.d.ts +50 -6
  63. package/dist/pane/Pane.js +112 -5
  64. package/dist/pane/PaneKeys.d.ts +5 -1
  65. package/dist/pane/PaneKeys.js +28 -3
  66. package/dist/pane/PaneKeys.logic.d.ts +25 -0
  67. package/dist/pane/PaneKeys.logic.js +30 -0
  68. package/dist/pane/PaneTabs.js +7 -3
  69. package/dist/pane/index.d.ts +1 -1
  70. package/dist/pane/index.js +1 -1
  71. package/dist/pane/panetabs.css +14 -2
  72. package/dist/pane/usePaneKeys.d.ts +8 -1
  73. package/dist/pane/usePaneKeys.js +32 -12
  74. package/dist/styles.css +40 -3
  75. package/dist/surface/FactList.d.ts +54 -0
  76. package/dist/surface/FactList.js +33 -0
  77. package/dist/surface/index.d.ts +4 -1
  78. package/dist/surface/index.js +4 -1
  79. package/dist/surface/surface.css +85 -2
  80. package/dist/terminal/TerminalMenu.js +1 -1
  81. package/dist/terminal/ghostty/core.d.ts +12 -4
  82. package/dist/terminal/ghostty/core.js +12 -4
  83. package/dist/terminal/index.d.ts +4 -2
  84. package/dist/terminal/index.js +4 -2
  85. package/dist/terminal/terminal.css +3 -2
  86. package/dist/text/Code.d.ts +15 -0
  87. package/dist/text/Code.js +12 -0
  88. package/dist/text/index.d.ts +6 -1
  89. package/dist/text/index.js +6 -1
  90. package/dist/text/text.css +21 -0
  91. package/dist/themes/tokens.js +8 -3
  92. package/dist/tokens.css +4 -0
  93. package/dist/viewer/HexView.js +17 -8
  94. package/dist/viewer/ImageView.js +5 -3
  95. package/dist/viewer/PdfView.d.ts +8 -1
  96. package/dist/viewer/PdfView.js +27 -2
  97. package/dist/viewer/SyntaxHighlighter.d.ts +3 -2
  98. package/dist/viewer/SyntaxHighlighter.js +7 -2
  99. package/dist/viewer/SyntaxLanguage.logic.d.ts +5 -0
  100. package/dist/viewer/SyntaxLanguage.logic.js +17 -3
  101. package/dist/viewer/SyntaxService.d.ts +3 -1
  102. package/dist/viewer/SyntaxService.js +8 -1
  103. package/dist/viewer/TextView.js +14 -7
  104. package/dist/viewer/ViewerClipboard.js +17 -6
  105. package/dist/viewer/ViewerFrame.logic.js +4 -1
  106. package/dist/viewer/types.d.ts +3 -2
  107. package/package.json +1 -1
@@ -53,7 +53,9 @@ export function Palette({ label, className, busy = false, onClose, children }) {
53
53
  * stands below its first level, the field (a combobox over the list it
54
54
  * names, holding the focus), then the count ("3 of 12") while a query
55
55
  * narrows the list, or, after a refused keystroke, why it was refused in the
56
- * count's place, and any tag the caller puts at the field's end. A refused
56
+ * count's place, and any tag the caller puts at the field's end. The field
57
+ * cancels Return's default before the caller's `onKeyDown` runs, so a focus
58
+ * the caller hands back on close cannot take the same key. A refused
57
59
  * keystroke also rings the visual bell on the row, once per refusal
58
60
  * (`useBellBeat`). The chip's words and the refusal come from the `palette`
59
61
  * label group.
@@ -61,5 +63,15 @@ export function Palette({ label, className, busy = false, onClose, children }) {
61
63
  export function PaletteQuery({ inputRef, value, label, placeholder, listId, activeId, bell, level = null, count, refused, aside, onChange, onKeyDown }) {
62
64
  const labels = useLabels().palette;
63
65
  const beat = useBellBeat(bell);
64
- return (_jsxs("div", { className: beat === null ? 'folder-menu-query' : `folder-menu-query bell-${beat}`, children: [_jsx(FilterIcon, {}), level !== null && (_jsxs("button", { "aria-label": labels.backFrom(level.title), className: "palette-level", disabled: level.disabled, onClick: level.onBack, tabIndex: -1, type: "button", ...tooltip(labels.back, '←'), children: [_jsx(ArrowLeft, { "aria-hidden": true, size: ICON_SM }), level.title] })), _jsx("input", { "aria-activedescendant": activeId, "aria-autocomplete": "list", "aria-controls": listId, "aria-expanded": true, "aria-label": label, onChange: onChange, onKeyDown: onKeyDown, placeholder: placeholder, ref: inputRef, role: "combobox", spellCheck: false, value: value }), refused !== null ? (_jsx("span", { className: "palette-refused", children: labels.nothingMatches(refused) })) : (count !== null && _jsx("span", { className: "folder-menu-count", children: count })), aside] }));
66
+ return (_jsxs("div", { className: beat === null ? 'folder-menu-query' : `folder-menu-query bell-${beat}`, children: [_jsx(FilterIcon, {}), level !== null && (_jsxs("button", { "aria-label": labels.backFrom(level.title), className: "palette-level", disabled: level.disabled, onClick: level.onBack, tabIndex: -1, type: "button", ...tooltip(labels.back, '←'), children: [_jsx(ArrowLeft, { "aria-hidden": true, size: ICON_SM }), level.title] })), _jsx("input", { "aria-activedescendant": activeId, "aria-autocomplete": "list", "aria-controls": listId, "aria-expanded": true, "aria-label": label, onChange: onChange, onKeyDown: (event) => {
67
+ // Return in the field runs the cursor row, so its default goes
68
+ // first, before the caller's handler can stop the key: a caller
69
+ // that closes on it and hands the focus back to the button that
70
+ // opened the palette would otherwise see the browser click that
71
+ // button with the same key and open the palette again. An input
72
+ // method's Return stays the input method's.
73
+ if (event.key === 'Enter' && !event.nativeEvent.isComposing)
74
+ event.preventDefault();
75
+ onKeyDown(event);
76
+ }, placeholder: placeholder, ref: inputRef, role: "combobox", spellCheck: false, value: value }), refused !== null ? (_jsx("span", { className: "palette-refused", children: labels.nothingMatches(refused) })) : (count !== null && _jsx("span", { className: "folder-menu-count", children: count })), aside] }));
65
77
  }
@@ -1,4 +1,4 @@
1
- import { type ReactElement, type ReactNode, type Ref } from 'react';
1
+ import type { ReactElement, ReactNode, Ref } from 'react';
2
2
  /** Props for {@link PaletteList}. */
3
3
  export interface PaletteListProps {
4
4
  /** The listbox's id, which `PaletteQuery`'s `listId` names. */
@@ -27,9 +27,10 @@ export interface PaletteOptionProps {
27
27
  /** The row's name: words, or `MarkedText` with the query's matches lit. */
28
28
  readonly name: ReactNode;
29
29
  /**
30
- * The row's accessible name. Pass it whenever `name` is markup
31
- * (`MarkedText`): without it the row is named by the drawn words, which a
32
- * screen reader may read split at the highlights ("Po stgreSQL").
30
+ * The drawn name's words for the row's accessible name, in their place
31
+ * before the context and trail. Pass it whenever `name` is markup
32
+ * (`MarkedText`): without it the name part is read from the drawn words,
33
+ * which a screen reader may split at the highlights ("Po stgreSQL").
33
34
  */
34
35
  readonly label?: string;
35
36
  /** The glyph in the icon column (a `ProductMark`, a lucide icon), decorative. */
@@ -46,6 +47,13 @@ export interface PaletteOptionProps {
46
47
  * name: a `CurrentDot` after the trail.
47
48
  */
48
49
  readonly current?: string | null;
50
+ /**
51
+ * The row is one of several that can be picked together (the scripts a
52
+ * project includes): true draws the check mark in the icon column, in
53
+ * place of `mark`, and false leaves it empty (`aria-checked`). A press
54
+ * calls `onPick`, which toggles it; absent, the row is a plain option.
55
+ */
56
+ readonly checked?: boolean;
49
57
  /** The keyboard's cursor stands on it: the cursor fill and bar. */
50
58
  readonly cursor?: boolean;
51
59
  /**
@@ -54,11 +62,11 @@ export interface PaletteOptionProps {
54
62
  */
55
63
  readonly disabled?: boolean;
56
64
  /**
57
- * Read after the name by assistive technology, in place of what the row
58
- * derives: its context, a trail in words, and what `current` means, in
59
- * that order. Give it to say why the row is disabled, or to word a trail
60
- * that is not text (a `KeyChord`); an empty string reads nothing after
61
- * the name.
65
+ * Read after the name by assistive technology, for what the row does not
66
+ * draw: why it is disabled ("Already added"). The name already reads the
67
+ * row's words in the order they are drawn, its context and trail (a
68
+ * `KeyChord` by its words) and what `current` means included, so the
69
+ * description never repeats them.
62
70
  */
63
71
  readonly description?: string;
64
72
  /** A press picks it; never called while it is disabled. */
@@ -74,12 +82,18 @@ export interface PaletteOptionProps {
74
82
  * whole in its tooltip), and a trailing column (a version, a count, a
75
83
  * chord) with the current item's dot. The cursor row wears the cursor fill
76
84
  * 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
78
- * focus in its field, so a press here never takes it. Its name is `label`
79
- * or its words; the context, a trail in words, and what `current` means
80
- * are read after it as its description, unless `description` says it.
85
+ * is dimmed and never takes the cursor or a pick. A `checked` row, one of
86
+ * several picked together, wears the check mark while it is ticked, as a
87
+ * menu's setting does. The palette keeps the
88
+ * focus in its field, so a press here never takes it. Its accessible name
89
+ * is the words it draws, in the order drawn: its name, its context, and its
90
+ * trail with what `current` means, so the name holds every visible word
91
+ * (WCAG 2.5.3), read from its content; `label` stands in for the drawn
92
+ * name's words alone (a name marked up by a query), the context and trail
93
+ * still read after it.
94
+ * `description` adds what the row does not draw.
81
95
  */
82
- export declare function PaletteOption({ id, name, label, mark, context, contextKind, trail, current, cursor, disabled, description, onPick, onPoint, ref }: PaletteOptionProps): ReactElement;
96
+ export declare function PaletteOption({ id, name, label, mark, context, contextKind, trail, current, checked, cursor, disabled, description, onPick, onPoint, ref }: PaletteOptionProps): ReactElement;
83
97
  /** Props for {@link PaletteHeading}. */
84
98
  export interface PaletteHeadingProps {
85
99
  /** The group's name: "Installed", "Databases". */
@@ -1,7 +1,7 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useId } from 'react';
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import { CurrentDot } from '../listing/CurrentDot.js';
4
3
  import { cutTooltip } from '../tooltip/Tooltip.logic.js';
4
+ import { VisuallyHidden } from '../VisuallyHidden.js';
5
5
  /**
6
6
  * A palette's list: the listbox its query field drives, seventeen rows tall
7
7
  * at most and fading the edge that has more (`.folder-menu-options`). The
@@ -16,28 +16,32 @@ 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
20
- * focus in its field, so a press here never takes it. Its name is `label`
21
- * or its words; the context, a trail in words, and what `current` means
22
- * are read after it as its description, unless `description` says it.
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
22
+ * focus in its field, so a press here never takes it. Its accessible name
23
+ * is the words it draws, in the order drawn: its name, its context, and its
24
+ * trail with what `current` means, so the name holds every visible word
25
+ * (WCAG 2.5.3), read from its content; `label` stands in for the drawn
26
+ * name's words alone (a name marked up by a query), the context and trail
27
+ * still read after it.
28
+ * `description` adds what the row does not draw.
23
29
  */
24
- export function PaletteOption({ id, name, label, mark, context, contextKind = 'sentence', trail, current = null, cursor = false, disabled = false, description, onPick, onPoint, ref }) {
25
- // The name's own id, private to the row, so it never meets a caller's id.
26
- const nameId = useId();
30
+ export function PaletteOption({ id, name, label, mark, context, contextKind = 'sentence', trail, current = null, checked, cursor = false, disabled = false, description, onPick, onPoint, ref }) {
27
31
  const contextClass = contextKind === 'path' ? 'palette-context' : `palette-context palette-${contextKind}`;
28
- // The row is named by its name alone, which hides the words drawn after
29
- // it, so those are read as its description unless the caller words one.
30
- const described = description ??
31
- [context, typeof trail === 'string' || typeof trail === 'number' ? String(trail) : '', current]
32
- .filter((part) => typeof part === 'string' && part !== '')
33
- .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: () => {
32
+ const hasContext = context !== undefined && context !== '';
33
+ // An empty label is none, as an empty context or description is.
34
+ const hasLabel = label !== undefined && label !== '';
35
+ // Named from its content, every word it draws in the order drawn, so the
36
+ // name a voice user speaks is the text they see. The spaces between the
37
+ // parts are for that name: the row's grid and flex rows draw none.
38
+ return (_jsxs("div", { "aria-checked": checked, "aria-description": description === undefined || description === '' ? undefined : description, "aria-disabled": disabled || undefined, "aria-selected": cursor, className: cursor ? 'folder-menu-option cursor' : 'folder-menu-option', id: id, onClick: () => {
35
39
  if (!disabled)
36
40
  onPick();
37
41
  }, onMouseMove: () => {
38
42
  if (!disabled && !cursor)
39
43
  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 })] })] }));
44
+ }, ref: ref, role: "option", children: [_jsx("span", { "aria-hidden": true, className: "row-icon", children: checked === undefined ? mark : null }), ' ', _jsxs("span", { className: "palette-text", children: [hasLabel ? _jsx(VisuallyHidden, { children: label }) : null, _jsx("span", { "aria-hidden": hasLabel ? true : undefined, className: "row-name", children: name }), !hasContext ? null : (_jsxs(_Fragment, { children: [' ', _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 : (_jsxs(_Fragment, { children: [' ', _jsx(CurrentDot, { label: current })] }))] })] }));
41
45
  }
42
46
  /**
43
47
  * 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,17 @@ 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;
86
+ /**
87
+ * The handlers that make a pane's home (`PaneList` with `home`, a tree's
88
+ * `TreeList`) hand the keyboard's menu key (the Menu key, Shift-F10) to its
89
+ * cursor row's menu, around the region's own handlers (`regionHandlers`),
90
+ * which they call in turn. Spread after the region's. Not a home, the
91
+ * element keeps the region's menu alone.
92
+ */
93
+ export declare function useMenuKeyHome(home: boolean, region: RegionHandlers): Pick<DOMAttributes<HTMLElement>, 'onContextMenu' | 'onKeyDownCapture' | 'onMouseDownCapture' | 'onPointerDownCapture'>;
package/dist/pane/Pane.js CHANGED
@@ -1,17 +1,124 @@
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
+ const menuKey = useMenuKeyHome(home, region);
59
+ 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, ...menuKey, children: children }));
60
+ }
61
+ /**
62
+ * The handlers that make a pane's home (`PaneList` with `home`, a tree's
63
+ * `TreeList`) hand the keyboard's menu key (the Menu key, Shift-F10) to its
64
+ * cursor row's menu, around the region's own handlers (`regionHandlers`),
65
+ * which they call in turn. Spread after the region's. Not a home, the
66
+ * element keeps the region's menu alone.
67
+ */
68
+ export function useMenuKeyHome(home, region) {
69
+ // Whether the keyboard's menu key (the Menu key, Shift-F10) was the last
70
+ // thing pressed: only it makes a menu the keyboard's, until the menu it
71
+ // asks for, another key, or a press of the pointer or a mouse button. The
72
+ // event alone cannot tell: Chromium sends the Menu key's as a mouse's
73
+ // pointer event. A mouse's second button pressed while another is held
74
+ // brings a mousedown but no pointerdown, so both clear it.
75
+ const menuKey = useRef(false);
76
+ return {
77
+ onContextMenu: (event) => {
78
+ const fromKeys = menuKey.current;
79
+ menuKey.current = false;
80
+ if (home && fromKeys && event.target === event.currentTarget)
81
+ menuOnCursorRow(event);
82
+ region.onContextMenu?.(event);
83
+ },
84
+ onKeyDownCapture: (event) => {
85
+ menuKey.current =
86
+ event.key === 'ContextMenu' ||
87
+ (event.key === 'F10' &&
88
+ event.shiftKey &&
89
+ !event.ctrlKey &&
90
+ !event.altKey &&
91
+ !event.metaKey);
92
+ region.onKeyDownCapture?.(event);
93
+ },
94
+ onMouseDownCapture: () => {
95
+ menuKey.current = false;
96
+ },
97
+ onPointerDownCapture: () => {
98
+ menuKey.current = false;
99
+ }
100
+ };
101
+ }
102
+ /**
103
+ * The keyboard's menu key aimed at a pane's home, which holds the focus
104
+ * while its cursor row does not: the cursor row with a menu of its own
105
+ * (`Row`'s `onContextMenu`, `data-row-menu`) takes it, as a secondary click
106
+ * on it, placed under the row's leading edge rather than wherever the
107
+ * keyboard's event says, and the home's own claims none.
108
+ */
109
+ function menuOnCursorRow(event) {
110
+ const row = event.currentTarget.querySelector('[data-row-key][aria-current="true"][data-row-menu]');
111
+ if (row === null || event.nativeEvent.defaultPrevented)
112
+ return;
113
+ const box = row.getBoundingClientRect();
114
+ const rtl = getComputedStyle(row).direction === 'rtl';
115
+ const click = new globalThis.MouseEvent('contextmenu', {
116
+ bubbles: true,
117
+ cancelable: true,
118
+ clientX: rtl ? box.right : box.left,
119
+ clientY: box.bottom
120
+ });
121
+ row.dispatchEvent(click);
122
+ if (click.defaultPrevented)
123
+ event.preventDefault();
17
124
  }
@@ -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
+ }
@@ -274,7 +274,11 @@ export function PaneTabs({ label, tabs, front, picked = NO_PICKS, onSelect, onCl
274
274
  ]
275
275
  .filter((part) => part !== undefined && part !== '')
276
276
  .join(', ');
277
- return (_jsxs("div", { ...tooltip(tab.tip, null, { value: true }), "aria-description": description === '' ? undefined : description, "aria-label": isPicked ? labels.picked(spoken) : spoken, "aria-selected": isFront, className: [
277
+ // The box draws the tab and takes its presses; the tab a screen reader
278
+ // meets is its face, which holds no control. The close control stands
279
+ // beside the face in the box, so it is never inside the tab, and is the
280
+ // pointer's alone.
281
+ return (_jsxs("div", { ...tooltip(tab.tip, null, { value: true }), className: [
278
282
  'pane-tab',
279
283
  isFront ? 'active' : '',
280
284
  tab.following === true ? 'following' : '',
@@ -310,9 +314,9 @@ export function PaneTabs({ label, tabs, front, picked = NO_PICKS, onSelect, onCl
310
314
  if (onReorder !== undefined) {
311
315
  drag.begin(tab.id, event.currentTarget, event.clientX);
312
316
  }
313
- }, ref: drag.tabRef(tab.id), role: "tab", style: {
317
+ }, ref: drag.tabRef(tab.id), role: "presentation", style: {
314
318
  '--pane-tab-floor': `${floor.context + (tab.context === undefined ? 0 : 1) + floor.name}ch`
315
- }, children: [tab.mark === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "pane-tab-mark", children: tab.mark })), _jsx(TabLabel, { tab: tab }), tab.dirty === true ? (_jsx("span", { "aria-hidden": true, className: "pane-tab-dirty", ...tooltip(labels.notSaved), children: _jsx(StateMark, { tone: "warning", word: "" }) })) : null, tab.pinned === true ? (_jsx("span", { "aria-hidden": true, className: "pane-tab-pin", ...tooltip(labels.pinned), children: _jsx(Pin, { size: ICON_SM }) })) : closes(tab) ? (_jsx("button", { "aria-label": labels.close(spoken), className: "pane-tab-close hit-target quiet-control", onClick: (event) => {
319
+ }, children: [_jsxs("span", { "aria-description": description === '' ? undefined : description, "aria-label": isPicked ? labels.picked(spoken) : spoken, "aria-selected": isFront, className: "pane-tab-face", role: "tab", children: [tab.mark === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "pane-tab-mark", children: tab.mark })), _jsx(TabLabel, { tab: tab }), tab.dirty === true ? (_jsx("span", { "aria-hidden": true, className: "pane-tab-dirty", ...tooltip(labels.notSaved), children: _jsx(StateMark, { tone: "warning", word: "" }) })) : null, tab.pinned === true ? (_jsx("span", { "aria-hidden": true, className: "pane-tab-pin", ...tooltip(labels.pinned), children: _jsx(Pin, { size: ICON_SM }) })) : null] }), tab.pinned !== true && closes(tab) ? (_jsx("button", { "aria-hidden": true, "aria-label": labels.close(spoken), className: "pane-tab-close hit-target quiet-control", onClick: (event) => {
316
320
  event.stopPropagation();
317
321
  onClose(tab.id);
318
322
  }, onDoubleClick: (event) => event.stopPropagation(), onMouseDown: keepFocus,
@@ -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';
@@ -86,8 +86,19 @@
86
86
  cursor: default;
87
87
  }
88
88
 
89
+ /* The tab's face, the element a screen reader meets as the tab: its mark,
90
+ name, and dirty or pin mark in the box's row, the close control beside it
91
+ (a control is never inside a tab). */
92
+ :where(.listing-root) .pane-tab-face {
93
+ display: inline-flex;
94
+ flex: 0 1 auto;
95
+ align-items: center;
96
+ gap: var(--space-2);
97
+ min-width: 0;
98
+ }
99
+
89
100
  /* A mark ahead of the name takes its own room on top of the floor. */
90
- :where(.listing-root) .pane-tab:has(> .pane-tab-mark) {
101
+ :where(.listing-root) .pane-tab:has(> .pane-tab-face > .pane-tab-mark) {
91
102
  min-width: calc(
92
103
  var(--pane-tab-floor, 0ch) + var(--space-4) + var(--space-2) + var(--space-2) + var(--icon-lg) +
93
104
  2 * var(--line) + var(--icon-md) + var(--space-2)
@@ -95,7 +106,8 @@
95
106
  }
96
107
 
97
108
  /* A tab with no close control, pin, or mark of its own has nothing to keep room for. */
98
- :where(.listing-root) .pane-tab:not(:has(> :is(.pane-tab-close, .pane-tab-pin, .pane-tab-dirty))) {
109
+ :where(.listing-root)
110
+ .pane-tab:not(:has(> .pane-tab-close, > .pane-tab-face > :is(.pane-tab-pin, .pane-tab-dirty))) {
99
111
  padding-right: var(--space-4);
100
112
  }
101
113