@bigpixelrocket/uiok 0.0.0-stage → 0.1.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 +38 -0
- package/LICENSE +21 -0
- package/NOTICE +569 -0
- package/README.md +44 -2
- package/dist/VisuallyHidden.d.ts +13 -0
- package/dist/VisuallyHidden.js +13 -0
- package/dist/activity/ActivityBar.d.ts +29 -0
- package/dist/activity/ActivityBar.js +21 -0
- package/dist/activity/activity.css +43 -0
- package/dist/activity/index.d.ts +2 -0
- package/dist/activity/index.js +2 -0
- package/dist/button/Button.d.ts +26 -0
- package/dist/button/Button.js +14 -0
- package/dist/button/IconButton.d.ts +18 -0
- package/dist/button/IconButton.js +14 -0
- package/dist/button/button.css +95 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.js +3 -0
- package/dist/charts/Drawing.d.ts +27 -0
- package/dist/charts/Drawing.js +117 -0
- package/dist/charts/Drawing.logic.d.ts +2 -0
- package/dist/charts/Drawing.logic.js +22 -0
- package/dist/charts/Line.logic.d.ts +33 -0
- package/dist/charts/Line.logic.js +72 -0
- package/dist/charts/LineChart.d.ts +34 -0
- package/dist/charts/LineChart.js +100 -0
- package/dist/charts/Pie.logic.d.ts +16 -0
- package/dist/charts/Pie.logic.js +28 -0
- package/dist/charts/PieChart.d.ts +20 -0
- package/dist/charts/PieChart.js +16 -0
- package/dist/charts/ResultChart.d.ts +47 -0
- package/dist/charts/ResultChart.js +175 -0
- package/dist/charts/ResultChart.logic.d.ts +42 -0
- package/dist/charts/ResultChart.logic.js +165 -0
- package/dist/charts/Scatter.logic.d.ts +55 -0
- package/dist/charts/Scatter.logic.js +134 -0
- package/dist/charts/ScatterChart.d.ts +36 -0
- package/dist/charts/ScatterChart.js +99 -0
- package/dist/charts/charts.css +310 -0
- package/dist/charts/index.d.ts +14 -0
- package/dist/charts/index.js +11 -0
- package/dist/charts/seriesColour.d.ts +2 -0
- package/dist/charts/seriesColour.js +8 -0
- package/dist/clock/index.d.ts +2 -0
- package/dist/clock/index.js +2 -0
- package/dist/clock/useClock.d.ts +14 -0
- package/dist/clock/useClock.js +57 -0
- package/dist/datetime/DateTimePicker.d.ts +50 -0
- package/dist/datetime/DateTimePicker.js +98 -0
- package/dist/datetime/DateTimePicker.logic.d.ts +59 -0
- package/dist/datetime/DateTimePicker.logic.js +103 -0
- package/dist/datetime/datetime.css +115 -0
- package/dist/datetime/index.d.ts +7 -0
- package/dist/datetime/index.js +7 -0
- package/dist/dialog/ConfirmDialog.d.ts +73 -0
- package/dist/dialog/ConfirmDialog.js +30 -0
- package/dist/dialog/DialogLegend.d.ts +21 -0
- package/dist/dialog/DialogLegend.js +28 -0
- package/dist/dialog/DialogLegend.logic.d.ts +145 -0
- package/dist/dialog/DialogLegend.logic.js +71 -0
- package/dist/dialog/ModalDialog.d.ts +101 -0
- package/dist/dialog/ModalDialog.js +184 -0
- package/dist/dialog/dialog.css +283 -0
- package/dist/dialog/index.d.ts +8 -0
- package/dist/dialog/index.js +8 -0
- package/dist/filter/FilterEscape.d.ts +16 -0
- package/dist/filter/FilterEscape.js +15 -0
- package/dist/filter/FilterIcon.d.ts +8 -0
- package/dist/filter/FilterIcon.js +11 -0
- package/dist/filter/filter.css +42 -0
- package/dist/filter/index.d.ts +3 -0
- package/dist/filter/index.js +3 -0
- package/dist/grid/DataGrid.d.ts +149 -0
- package/dist/grid/DataGrid.js +373 -0
- package/dist/grid/DataGrid.logic.d.ts +57 -0
- package/dist/grid/DataGrid.logic.js +121 -0
- package/dist/grid/grid.css +206 -0
- package/dist/grid/index.d.ts +7 -0
- package/dist/grid/index.js +7 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +32 -0
- package/dist/keyboard/BrowserKeys.d.ts +15 -0
- package/dist/keyboard/BrowserKeys.js +28 -0
- package/dist/keyboard/KeyChord.logic.d.ts +25 -0
- package/dist/keyboard/KeyChord.logic.js +50 -0
- package/dist/keyboard/Keyboard.logic.d.ts +84 -0
- package/dist/keyboard/Keyboard.logic.js +137 -0
- package/dist/keyboard/OverlayWatch.d.ts +28 -0
- package/dist/keyboard/OverlayWatch.js +119 -0
- package/dist/keyboard/PageSelectAll.d.ts +14 -0
- package/dist/keyboard/PageSelectAll.js +22 -0
- package/dist/keyboard/index.d.ts +9 -0
- package/dist/keyboard/index.js +9 -0
- package/dist/keychord/KeyChord.d.ts +16 -0
- package/dist/keychord/KeyChord.js +55 -0
- package/dist/keychord/index.d.ts +2 -0
- package/dist/keychord/index.js +2 -0
- package/dist/keychord/keychord.css +41 -0
- package/dist/labels/UiokLabels.d.ts +41 -0
- package/dist/labels/UiokLabels.js +31 -0
- package/dist/labels/UiokProvider.d.ts +44 -0
- package/dist/labels/UiokProvider.js +54 -0
- package/dist/labels/charts.d.ts +34 -0
- package/dist/labels/charts.js +15 -0
- package/dist/labels/dateTime.d.ts +32 -0
- package/dist/labels/dateTime.js +14 -0
- package/dist/labels/dialog.d.ts +18 -0
- package/dist/labels/dialog.js +6 -0
- package/dist/labels/index.d.ts +13 -0
- package/dist/labels/index.js +13 -0
- package/dist/labels/keys.d.ts +28 -0
- package/dist/labels/keys.js +53 -0
- package/dist/labels/legend.d.ts +21 -0
- package/dist/labels/legend.js +7 -0
- package/dist/labels/listing.d.ts +16 -0
- package/dist/labels/listing.js +8 -0
- package/dist/labels/pager.d.ts +32 -0
- package/dist/labels/pager.js +20 -0
- package/dist/labels/palette.d.ts +17 -0
- package/dist/labels/palette.js +6 -0
- package/dist/labels/selectAll.d.ts +15 -0
- package/dist/labels/selectAll.js +6 -0
- package/dist/labels/terminal.d.ts +25 -0
- package/dist/labels/terminal.js +9 -0
- package/dist/legend/KeyLegend.logic.d.ts +84 -0
- package/dist/legend/KeyLegend.logic.js +109 -0
- package/dist/legend/KeyLegendStrip.d.ts +36 -0
- package/dist/legend/KeyLegendStrip.js +82 -0
- package/dist/legend/index.d.ts +3 -0
- package/dist/legend/index.js +3 -0
- package/dist/legend/legend.css +148 -0
- package/dist/listing/CurrentDot.d.ts +15 -0
- package/dist/listing/CurrentDot.js +13 -0
- package/dist/listing/Listing.d.ts +230 -0
- package/dist/listing/Listing.js +265 -0
- package/dist/listing/PathParts.logic.d.ts +17 -0
- package/dist/listing/PathParts.logic.js +18 -0
- package/dist/listing/index.d.ts +10 -0
- package/dist/listing/index.js +10 -0
- package/dist/listing/listing.css +867 -0
- package/dist/menu/MenuQuery.logic.d.ts +69 -0
- package/dist/menu/MenuQuery.logic.js +75 -0
- package/dist/menu/fuzzyMatch.d.ts +31 -0
- package/dist/menu/fuzzyMatch.js +296 -0
- package/dist/menu/index.d.ts +9 -0
- package/dist/menu/index.js +9 -0
- package/dist/menu/menu.css +203 -0
- package/dist/menu/useBellBeat.d.ts +8 -0
- package/dist/menu/useBellBeat.js +26 -0
- package/dist/namecut/NameCut.d.ts +22 -0
- package/dist/namecut/NameCut.js +28 -0
- package/dist/namecut/NameCut.logic.d.ts +51 -0
- package/dist/namecut/NameCut.logic.js +120 -0
- package/dist/namecut/index.d.ts +3 -0
- package/dist/namecut/index.js +3 -0
- package/dist/namecut/namecut.css +67 -0
- package/dist/pager/Pager.d.ts +37 -0
- package/dist/pager/Pager.js +38 -0
- package/dist/pager/Pager.logic.d.ts +13 -0
- package/dist/pager/Pager.logic.js +63 -0
- package/dist/pager/index.d.ts +7 -0
- package/dist/pager/index.js +7 -0
- package/dist/pager/pager.css +62 -0
- package/dist/palette/Palette.d.ts +79 -0
- package/dist/palette/Palette.js +60 -0
- package/dist/palette/index.d.ts +6 -0
- package/dist/palette/index.js +6 -0
- package/dist/palette/palette.css +159 -0
- package/dist/pane/PaneActions.d.ts +104 -0
- package/dist/pane/PaneActions.js +62 -0
- package/dist/pane/PaneFrame.d.ts +51 -0
- package/dist/pane/PaneFrame.js +28 -0
- package/dist/pane/PaneKeys.d.ts +41 -0
- package/dist/pane/PaneKeys.js +104 -0
- package/dist/pane/PaneKeys.logic.d.ts +95 -0
- package/dist/pane/PaneKeys.logic.js +109 -0
- package/dist/pane/index.d.ts +11 -0
- package/dist/pane/index.js +11 -0
- package/dist/pane/usePaneKeys.d.ts +141 -0
- package/dist/pane/usePaneKeys.js +313 -0
- package/dist/run/RunHeader.d.ts +50 -0
- package/dist/run/RunHeader.js +31 -0
- package/dist/run/RunProgress.logic.d.ts +29 -0
- package/dist/run/RunProgress.logic.js +34 -0
- package/dist/run/index.d.ts +3 -0
- package/dist/run/index.js +3 -0
- package/dist/run/run.css +190 -0
- package/dist/segmented/SegmentedChoice.d.ts +22 -0
- package/dist/segmented/SegmentedChoice.js +31 -0
- package/dist/segmented/index.d.ts +2 -0
- package/dist/segmented/index.js +2 -0
- package/dist/segmented/segmented.css +49 -0
- package/dist/selectall/CheckRange.logic.d.ts +8 -0
- package/dist/selectall/CheckRange.logic.js +23 -0
- package/dist/selectall/SelectAllBar.d.ts +25 -0
- package/dist/selectall/SelectAllBar.js +24 -0
- package/dist/selectall/index.d.ts +7 -0
- package/dist/selectall/index.js +7 -0
- package/dist/selectall/selectall.css +31 -0
- package/dist/store/KeepUnchanged.logic.d.ts +19 -0
- package/dist/store/KeepUnchanged.logic.js +33 -0
- package/dist/store/SameProps.d.ts +15 -0
- package/dist/store/SameProps.js +46 -0
- package/dist/store/ValueStore.d.ts +17 -0
- package/dist/store/ValueStore.js +23 -0
- package/dist/store/index.d.ts +8 -0
- package/dist/store/index.js +8 -0
- package/dist/store/useStableHandlers.d.ts +13 -0
- package/dist/store/useStableHandlers.js +22 -0
- package/dist/styles.css +85 -0
- package/dist/tabs/PageTabs.d.ts +38 -0
- package/dist/tabs/PageTabs.js +33 -0
- package/dist/tabs/index.d.ts +2 -0
- package/dist/tabs/index.js +2 -0
- package/dist/tabs/tabs.css +64 -0
- package/dist/terminal/Terminal.d.ts +104 -0
- package/dist/terminal/Terminal.js +309 -0
- package/dist/terminal/Terminal.logic.d.ts +66 -0
- package/dist/terminal/Terminal.logic.js +156 -0
- package/dist/terminal/TerminalMenu.d.ts +36 -0
- package/dist/terminal/TerminalMenu.js +87 -0
- package/dist/terminal/TerminalMenu.logic.d.ts +78 -0
- package/dist/terminal/TerminalMenu.logic.js +68 -0
- package/dist/terminal/TerminalScrollback.d.ts +10 -0
- package/dist/terminal/TerminalScrollback.js +11 -0
- package/dist/terminal/ghostty/LICENSE +21 -0
- package/dist/terminal/ghostty/core.d.ts +315 -0
- package/dist/terminal/ghostty/core.js +1189 -0
- package/dist/terminal/ghostty/fallbackColors.d.ts +12 -0
- package/dist/terminal/ghostty/fallbackColors.js +23 -0
- package/dist/terminal/ghostty/fonts/LICENSE +21 -0
- package/dist/terminal/ghostty/fonts/SymbolsNerdFontMono-Regular.woff2 +0 -0
- package/dist/terminal/ghostty/keyCodes.logic.d.ts +20 -0
- package/dist/terminal/ghostty/keyCodes.logic.js +249 -0
- package/dist/terminal/ghostty/links.logic.d.ts +39 -0
- package/dist/terminal/ghostty/links.logic.js +84 -0
- package/dist/terminal/ghostty/renderer.d.ts +98 -0
- package/dist/terminal/ghostty/renderer.js +481 -0
- package/dist/terminal/ghostty/runtime.d.ts +126 -0
- package/dist/terminal/ghostty/runtime.js +346 -0
- package/dist/terminal/ghostty/spriteGlyphs.logic.d.ts +64 -0
- package/dist/terminal/ghostty/spriteGlyphs.logic.js +546 -0
- package/dist/terminal/ghostty/surface.d.ts +285 -0
- package/dist/terminal/ghostty/surface.js +1565 -0
- package/dist/terminal/ghostty/surface.logic.d.ts +181 -0
- package/dist/terminal/ghostty/surface.logic.js +392 -0
- package/dist/terminal/ghostty/vendor/LICENSE +21 -0
- package/dist/terminal/ghostty/vendor/ghostty-effects.wasm +0 -0
- package/dist/terminal/ghostty/vendor/ghostty-vt.wasm +0 -0
- package/dist/terminal/index.d.ts +12 -0
- package/dist/terminal/index.js +12 -0
- package/dist/terminal/terminal.css +169 -0
- package/dist/text/MarkedText.d.ts +14 -0
- package/dist/text/MarkedText.js +11 -0
- package/dist/text/highlightSegments.d.ts +13 -0
- package/dist/text/highlightSegments.js +29 -0
- package/dist/text/index.d.ts +3 -0
- package/dist/text/index.js +3 -0
- package/dist/text/text.css +11 -0
- package/dist/themes/attributes.d.ts +21 -0
- package/dist/themes/attributes.js +41 -0
- package/dist/themes/catalog.d.ts +125 -0
- package/dist/themes/catalog.js +940 -0
- package/dist/themes/color.d.ts +29 -0
- package/dist/themes/color.js +52 -0
- package/dist/themes/ids.d.ts +139 -0
- package/dist/themes/ids.js +59 -0
- package/dist/themes/index.d.ts +12 -0
- package/dist/themes/index.js +12 -0
- package/dist/themes/themes.generated.css +1830 -0
- package/dist/themes/tokens.d.ts +189 -0
- package/dist/themes/tokens.js +462 -0
- package/dist/tooltip/Tooltip.d.ts +21 -0
- package/dist/tooltip/Tooltip.js +105 -0
- package/dist/tooltip/Tooltip.logic.d.ts +49 -0
- package/dist/tooltip/Tooltip.logic.js +50 -0
- package/dist/tooltip/index.d.ts +3 -0
- package/dist/tooltip/index.js +3 -0
- package/dist/tooltip/tooltip.css +45 -0
- package/package.json +91 -4
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
/** A crumb that is a control: a press goes to the place it names. */
|
|
3
|
+
export interface PaneCrumb {
|
|
4
|
+
readonly label: string;
|
|
5
|
+
/** Goes to the place the crumb names (a page's parent, its board). */
|
|
6
|
+
readonly onOpen: () => void;
|
|
7
|
+
/** What a press does, when the label alone does not say it. */
|
|
8
|
+
readonly tip?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Props for {@link PanePathBar}. */
|
|
11
|
+
export interface PanePathBarProps {
|
|
12
|
+
/**
|
|
13
|
+
* The trail, broadest first; the last crumb names what the pane shows.
|
|
14
|
+
* A crumb is a label, or a control (`PaneCrumb`) that goes where it names.
|
|
15
|
+
*/
|
|
16
|
+
readonly trail: readonly (string | PaneCrumb)[];
|
|
17
|
+
/** A mark in the root crumb's slot, before the trail: a product mark or a glyph. */
|
|
18
|
+
readonly mark?: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* The last crumb is the page's `h2`; a sidebar's names no page. Only a
|
|
21
|
+
* label crumb becomes the heading, so a heading's last crumb is a string.
|
|
22
|
+
*/
|
|
23
|
+
readonly heading?: boolean;
|
|
24
|
+
/** Drawn after the last crumb's label, inside its crumb: the `CurrentDot` of the one shown. */
|
|
25
|
+
readonly here?: ReactNode;
|
|
26
|
+
/** Facts and compact controls at the bar's end. */
|
|
27
|
+
readonly children?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The row a pane opens with: a path bar, in the listing look (under
|
|
31
|
+
* `.listing-root`). Its crumbs say where the pane is; one handed as a
|
|
32
|
+
* `PaneCrumb` is a control that goes there. A narrow pane, or a longer
|
|
33
|
+
* language, cuts a label crumb with an ellipsis, its whole text in its
|
|
34
|
+
* tooltip. Facts and controls sit at the bar's end (`.path-tools`): a state
|
|
35
|
+
* as `.path-facts`, compact verbs as `QuietAction` and `.path-star` icon
|
|
36
|
+
* buttons.
|
|
37
|
+
*/
|
|
38
|
+
export declare function PanePathBar({ trail, mark, heading, here, children }: PanePathBarProps): ReactElement;
|
|
39
|
+
/** Props for {@link PaneStatus}. */
|
|
40
|
+
export interface PaneStatusProps {
|
|
41
|
+
/** The summary of what the pane lists or shows ("12 items"). */
|
|
42
|
+
readonly children?: ReactNode;
|
|
43
|
+
/** Compact controls at the line's end (Reveal, Copy). */
|
|
44
|
+
readonly tools?: ReactNode;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The line a pane closes with: one summary of what the pane lists or
|
|
48
|
+
* shows, and compact icon controls at its end (`tools`, `RowIconAction`s),
|
|
49
|
+
* which the summary gives way to.
|
|
50
|
+
*/
|
|
51
|
+
export declare function PaneStatus({ children, tools }: PaneStatusProps): ReactElement;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from 'react';
|
|
3
|
+
import { describedTooltip, tooltip } from '../tooltip/Tooltip.logic.js';
|
|
4
|
+
/**
|
|
5
|
+
* The row a pane opens with: a path bar, in the listing look (under
|
|
6
|
+
* `.listing-root`). Its crumbs say where the pane is; one handed as a
|
|
7
|
+
* `PaneCrumb` is a control that goes there. A narrow pane, or a longer
|
|
8
|
+
* language, cuts a label crumb with an ellipsis, its whole text in its
|
|
9
|
+
* tooltip. Facts and controls sit at the bar's end (`.path-tools`): a state
|
|
10
|
+
* as `.path-facts`, compact verbs as `QuietAction` and `.path-star` icon
|
|
11
|
+
* buttons.
|
|
12
|
+
*/
|
|
13
|
+
export function PanePathBar({ trail, mark, heading = false, here, children }) {
|
|
14
|
+
return (_jsxs("div", { className: "pane-path-row", children: [_jsxs("div", { className: "pane-crumbs", children: [mark !== undefined && (_jsx("span", { className: "crumb root", children: _jsx("span", { className: "crumb-label crumb-mark", children: mark }) })), trail.map((crumb, index) => {
|
|
15
|
+
const last = index === trail.length - 1;
|
|
16
|
+
const label = typeof crumb === 'string' ? crumb : crumb.label;
|
|
17
|
+
const Label = last && heading ? 'h2' : 'span';
|
|
18
|
+
return (_jsxs(Fragment, { children: [index > 0 && (_jsx("span", { "aria-hidden": true, className: "crumb-separator", children: "/" })), _jsxs("span", { className: last ? 'crumb here' : 'crumb', children: [typeof crumb === 'string' ? (_jsx(Label, { className: "crumb-label", ...tooltip(label), children: label })) : (_jsx("button", { className: "crumb-label", onClick: crumb.onOpen, type: "button", ...describedTooltip(crumb.tip), children: label })), last && here] })] }, `${index}:${label}`));
|
|
19
|
+
})] }), children !== undefined && children !== null && children !== false && (_jsx("div", { className: "path-tools", children: children }))] }));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* The line a pane closes with: one summary of what the pane lists or
|
|
23
|
+
* shows, and compact icon controls at its end (`tools`, `RowIconAction`s),
|
|
24
|
+
* which the summary gives way to.
|
|
25
|
+
*/
|
|
26
|
+
export function PaneStatus({ children, tools }) {
|
|
27
|
+
return (_jsxs("footer", { className: "pane-status", children: [_jsx("span", { className: "pane-summary", children: children }), tools !== undefined && tools !== null && tools !== false && (_jsx("span", { className: "pane-status-tools", children: tools }))] }));
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ControlVerb } from './PaneActions.js';
|
|
2
|
+
/** The rows a pane's cursor walks, top to bottom: its `data-row-key` elements. */
|
|
3
|
+
export declare const paneRows: (pane: Element | null) => HTMLElement[];
|
|
4
|
+
/** A pane's row by its key, or null for none. */
|
|
5
|
+
export declare const paneRow: (pane: Element | null, key: string | null) => HTMLElement | null;
|
|
6
|
+
/**
|
|
7
|
+
* The control in `root` the keys run for `verb`, when it takes a click: the
|
|
8
|
+
* first whose `data-verb` (or `data-page-verb`, with `attribute`) lists it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function verbControl(root: Element | null, verb: ControlVerb, attribute?: 'verb' | 'page-verb'): HTMLElement | null;
|
|
11
|
+
/** Every element in `root` Tab stops on, in document order. */
|
|
12
|
+
export declare const tabStops: (root: Element) => HTMLElement[];
|
|
13
|
+
/** Whether Tab stops on `element` itself, as `tabStops` judges it. */
|
|
14
|
+
export declare const isTabStop: (element: Element) => element is HTMLElement;
|
|
15
|
+
/** Where Tab or Shift-Tab goes next: the sidebar's home, the page's home, or a control. */
|
|
16
|
+
export type TabStop = 'sidebar' | 'page' | HTMLElement;
|
|
17
|
+
/** The sidebar Tab walks through (`sidebarStops` in `usePaneKeys`): its pane and its home. */
|
|
18
|
+
export interface SidebarTabStops {
|
|
19
|
+
readonly pane: Element;
|
|
20
|
+
readonly home: HTMLElement;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Where Tab (or Shift-Tab, `back`) goes from `from` inside a two-pane layout.
|
|
24
|
+
* Without `sidebar`, from the sidebar to the page's home either way; from the
|
|
25
|
+
* page's home or a control of the main pane to the main pane's next control
|
|
26
|
+
* in document order, and from the last one, or back from the first, to the
|
|
27
|
+
* sidebar. With `sidebar`, the sidebar's controls are stops too: the
|
|
28
|
+
* sidebar's and the page's stops, each pane's home among them where the
|
|
29
|
+
* document puts it, make one cycle in document order that wraps at either
|
|
30
|
+
* end. A row's controls are no stops (the cursor row's keys run them) unless
|
|
31
|
+
* its listing keeps them in the Tab order (`Row`'s `tabbable`); a sidebar
|
|
32
|
+
* row's never are.
|
|
33
|
+
*/
|
|
34
|
+
export declare function nextTabStop(main: Element, home: HTMLElement, from: TabStop, back: boolean, sidebar?: SidebarTabStops | null): TabStop;
|
|
35
|
+
/**
|
|
36
|
+
* The rows one Page Up or Page Down moves in a pane: what its home
|
|
37
|
+
* (`data-pane-home`) shows of 24px rows, less one kept in view.
|
|
38
|
+
*/
|
|
39
|
+
export declare const pageRows: (pane: Element | null) => number;
|
|
40
|
+
/** Brings a row the keys moved to into view, clear of its strip (the row's own scroll margin). */
|
|
41
|
+
export declare const showRow: (row: HTMLElement | null) => void;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* What a two-pane layout's keys read off the rendered panes: the rows the
|
|
3
|
+
* cursor walks, the controls a row or a path bar marks with the verbs the
|
|
4
|
+
* keys run (`data-verb`, `data-page-verb`), and the stops Tab walks. The
|
|
5
|
+
* panes say what they offer by these marks, so the keys run exactly what a
|
|
6
|
+
* click would, disabled where the control is.
|
|
7
|
+
*/
|
|
8
|
+
/** The rows a pane's cursor walks, top to bottom: its `data-row-key` elements. */
|
|
9
|
+
export const paneRows = (pane) => pane === null ? [] : [...pane.querySelectorAll('[data-row-key]')];
|
|
10
|
+
/** A pane's row by its key, or null for none. */
|
|
11
|
+
export const paneRow = (pane, key) => key === null ? null : (paneRows(pane).find((row) => row.dataset.rowKey === key) ?? null);
|
|
12
|
+
/** Whether a control takes a click: not disabled, not inert behind `aria-disabled`. */
|
|
13
|
+
const enabled = (control) => !control.disabled && control.getAttribute('aria-disabled') !== 'true';
|
|
14
|
+
/**
|
|
15
|
+
* The control in `root` the keys run for `verb`, when it takes a click: the
|
|
16
|
+
* first whose `data-verb` (or `data-page-verb`, with `attribute`) lists it.
|
|
17
|
+
*/
|
|
18
|
+
export function verbControl(root, verb, attribute = 'verb') {
|
|
19
|
+
// The verb is quoted, so only a quote or a backslash in it needs escaping.
|
|
20
|
+
const quoted = verb.replace(/["\\]/g, '\\$&');
|
|
21
|
+
const control = root?.querySelector(`[data-${attribute}~="${quoted}"]`) ?? null;
|
|
22
|
+
return control !== null && enabled(control) ? control : null;
|
|
23
|
+
}
|
|
24
|
+
const FOCUSABLE = 'a[href], button, input, select, textarea, summary, [tabindex]';
|
|
25
|
+
/**
|
|
26
|
+
* Whether Tab would stop on an element: focusable, not taken out of the
|
|
27
|
+
* order, not disabled, not hidden or inert, not inside a closed disclosure
|
|
28
|
+
* (its summary aside), and, of a radio group, only its checked radio, or
|
|
29
|
+
* its first while none is.
|
|
30
|
+
*/
|
|
31
|
+
function tabbable(element) {
|
|
32
|
+
if (element.tabIndex < 0 || element.disabled)
|
|
33
|
+
return false;
|
|
34
|
+
if (element.closest('[hidden], [inert], [aria-hidden="true"]') !== null)
|
|
35
|
+
return false;
|
|
36
|
+
const details = element.closest('details');
|
|
37
|
+
if (details !== null && !details.open && element.closest('summary')?.parentElement !== details) {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
if (element instanceof HTMLInputElement && element.type === 'radio' && element.name !== '') {
|
|
41
|
+
const group = [
|
|
42
|
+
...(element.form ?? element.ownerDocument).querySelectorAll(`input[type="radio"][name="${CSS.escape(element.name)}"]`)
|
|
43
|
+
];
|
|
44
|
+
return element.checked || (!group.some((radio) => radio.checked) && group[0] === element);
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
/** Every element in `root` Tab stops on, in document order. */
|
|
49
|
+
export const tabStops = (root) => [...root.querySelectorAll(FOCUSABLE)].filter(tabbable);
|
|
50
|
+
/** Whether Tab stops on `element` itself, as `tabStops` judges it. */
|
|
51
|
+
export const isTabStop = (element) => element instanceof HTMLElement && element.matches(FOCUSABLE) && tabbable(element);
|
|
52
|
+
/** Sorts elements into document order. */
|
|
53
|
+
const inDocumentOrder = (a, b) => a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
54
|
+
/**
|
|
55
|
+
* Where Tab (or Shift-Tab, `back`) goes from `from` inside a two-pane layout.
|
|
56
|
+
* Without `sidebar`, from the sidebar to the page's home either way; from the
|
|
57
|
+
* page's home or a control of the main pane to the main pane's next control
|
|
58
|
+
* in document order, and from the last one, or back from the first, to the
|
|
59
|
+
* sidebar. With `sidebar`, the sidebar's controls are stops too: the
|
|
60
|
+
* sidebar's and the page's stops, each pane's home among them where the
|
|
61
|
+
* document puts it, make one cycle in document order that wraps at either
|
|
62
|
+
* end. A row's controls are no stops (the cursor row's keys run them) unless
|
|
63
|
+
* its listing keeps them in the Tab order (`Row`'s `tabbable`); a sidebar
|
|
64
|
+
* row's never are.
|
|
65
|
+
*/
|
|
66
|
+
export function nextTabStop(main, home, from, back, sidebar = null) {
|
|
67
|
+
if (from === 'sidebar' && sidebar === null)
|
|
68
|
+
return 'page';
|
|
69
|
+
const at = from === 'sidebar' ? (sidebar?.home ?? home) : from === 'page' ? home : from;
|
|
70
|
+
// A pane's home is a stop of its own where the document order puts it,
|
|
71
|
+
// before the controls inside it, though it is out of the Tab order itself.
|
|
72
|
+
const sidebarStops = sidebar === null
|
|
73
|
+
? []
|
|
74
|
+
: [
|
|
75
|
+
...tabStops(sidebar.pane).filter((stop) => stop !== sidebar.home && stop.closest('[data-row-key]') === null),
|
|
76
|
+
sidebar.home
|
|
77
|
+
];
|
|
78
|
+
const stops = [...tabStops(main).filter((stop) => stop !== home), home, ...sidebarStops].sort(inDocumentOrder);
|
|
79
|
+
const index = stops.indexOf(at);
|
|
80
|
+
const next = index >= 0
|
|
81
|
+
? stops[back ? index - 1 : index + 1]
|
|
82
|
+
: back
|
|
83
|
+
? stops
|
|
84
|
+
.filter((stop) => stop.compareDocumentPosition(at) & Node.DOCUMENT_POSITION_FOLLOWING)
|
|
85
|
+
.pop()
|
|
86
|
+
: stops.find((stop) => stop.compareDocumentPosition(at) & Node.DOCUMENT_POSITION_PRECEDING);
|
|
87
|
+
const landed = next ?? (sidebar === null ? undefined : back ? stops.at(-1) : stops[0]);
|
|
88
|
+
if (landed === undefined || landed === sidebar?.home)
|
|
89
|
+
return 'sidebar';
|
|
90
|
+
return landed === home ? 'page' : landed;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The rows one Page Up or Page Down moves in a pane: what its home
|
|
94
|
+
* (`data-pane-home`) shows of 24px rows, less one kept in view.
|
|
95
|
+
*/
|
|
96
|
+
export const pageRows = (pane) => {
|
|
97
|
+
const list = pane?.querySelector('[data-pane-home]');
|
|
98
|
+
return Math.max(1, Math.floor((list?.clientHeight ?? 0) / 24) - 1);
|
|
99
|
+
};
|
|
100
|
+
/** Brings a row the keys moved to into view, clear of its strip (the row's own scroll margin). */
|
|
101
|
+
export const showRow = (row) => {
|
|
102
|
+
// Optional call: jsdom has no scrollIntoView.
|
|
103
|
+
row?.scrollIntoView?.({ block: 'nearest' });
|
|
104
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Where a move takes a pane's cursor. */
|
|
2
|
+
export type PaneMove = 'up' | 'down' | 'start' | 'end' | 'page-up' | 'page-down';
|
|
3
|
+
/** The parts of a key event the panes read. */
|
|
4
|
+
export interface PaneKeyStroke {
|
|
5
|
+
readonly key: string;
|
|
6
|
+
/**
|
|
7
|
+
* The physical key, read for an Option chord alone: Option makes a letter
|
|
8
|
+
* a dead key or another character (⌥N), so an Option chord is known by
|
|
9
|
+
* where its key sits.
|
|
10
|
+
*/
|
|
11
|
+
readonly code: string;
|
|
12
|
+
readonly metaKey: boolean;
|
|
13
|
+
readonly ctrlKey: boolean;
|
|
14
|
+
readonly altKey: boolean;
|
|
15
|
+
readonly shiftKey: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* What a key asks of a two-pane layout before the app names it: a move,
|
|
19
|
+
* Tab or Shift-Tab, Return (`enter`), `.` (`reveal`), ⌘⌫ (`remove`), ⌘⏎
|
|
20
|
+
* (`toggle`), ⌥⌘⏎ (`restart`), or a Command chord on a letter (`chord`,
|
|
21
|
+
* the letter lowercase, `alt` for ⌥⌘), which the app maps to its own verb
|
|
22
|
+
* or leaves alone.
|
|
23
|
+
*/
|
|
24
|
+
export type PaneKeyAction = {
|
|
25
|
+
readonly kind: 'move';
|
|
26
|
+
readonly to: PaneMove;
|
|
27
|
+
} | {
|
|
28
|
+
readonly kind: 'switch-pane';
|
|
29
|
+
readonly back: boolean;
|
|
30
|
+
} | {
|
|
31
|
+
readonly kind: 'enter';
|
|
32
|
+
} | {
|
|
33
|
+
readonly kind: 'reveal';
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: 'remove';
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: 'toggle';
|
|
38
|
+
} | {
|
|
39
|
+
readonly kind: 'restart';
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: 'chord';
|
|
42
|
+
readonly letter: string;
|
|
43
|
+
readonly alt: boolean;
|
|
44
|
+
};
|
|
45
|
+
/** How {@link paneKeyAction} reads the platform's modifiers. */
|
|
46
|
+
export interface PaneKeyOptions {
|
|
47
|
+
/**
|
|
48
|
+
* The modifier that plays Command: `meta` on macOS (the default), `ctrl`
|
|
49
|
+
* where Control does. The other of the two makes no chord of the panes'.
|
|
50
|
+
*/
|
|
51
|
+
readonly command?: 'meta' | 'ctrl';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The action a key asks of a two-pane layout, or null for one no pane
|
|
55
|
+
* answers. Bare keys move the cursor (↑ ↓, Home and End, Page Up and Down,
|
|
56
|
+
* and ⌘↑ ⌘↓, Home and End for a laptop keyboard), Return runs the cursor
|
|
57
|
+
* row's verb, Tab and Shift-Tab switch panes, and `.` reveals; the rest are
|
|
58
|
+
* Command chords. Neither a chord with the other of Command and Control,
|
|
59
|
+
* nor Shift but with Tab, is the panes' (an app that gives Shift a chord
|
|
60
|
+
* reads it before this).
|
|
61
|
+
*/
|
|
62
|
+
export declare function paneKeyAction(stroke: PaneKeyStroke, options?: PaneKeyOptions): PaneKeyAction | null;
|
|
63
|
+
/**
|
|
64
|
+
* Where a move takes a cursor among `count` rows from `index` (-1 for no
|
|
65
|
+
* cursor yet, which any move puts on the first row, or the last for `end`).
|
|
66
|
+
* Every move stops at either end; a page move goes `page` rows. Null when
|
|
67
|
+
* there are no rows.
|
|
68
|
+
*/
|
|
69
|
+
export declare function movedIndex(count: number, index: number, to: PaneMove, page?: number): number | null;
|
|
70
|
+
/**
|
|
71
|
+
* What the cursor row in the main pane offers the keys, as its controls
|
|
72
|
+
* say: the word of the control Return runs (Install, Open), whether it can
|
|
73
|
+
* be removed or revealed, and the toggle (Start or Stop) and restart that
|
|
74
|
+
* ⌘⏎ and ⌥⌘⏎ run for the row or, failing that, for the page. An app with
|
|
75
|
+
* more verbs extends it.
|
|
76
|
+
*/
|
|
77
|
+
export interface MainVerbs {
|
|
78
|
+
/** The main pane lists rows the cursor walks. */
|
|
79
|
+
readonly rows: boolean;
|
|
80
|
+
/** The word of the control Return runs, or null for none. */
|
|
81
|
+
readonly enter: string | null;
|
|
82
|
+
readonly remove: boolean;
|
|
83
|
+
/** `.` reveals the item, and Return does not already. */
|
|
84
|
+
readonly reveal: boolean;
|
|
85
|
+
/** The word of the toggle ⌘⏎ runs (Start or Stop), or null for none. */
|
|
86
|
+
readonly toggle: string | null;
|
|
87
|
+
readonly restart: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** A main pane that offers nothing to the keys. */
|
|
90
|
+
export declare const NO_MAIN_VERBS: MainVerbs;
|
|
91
|
+
/**
|
|
92
|
+
* Whether two readings of what a pane offers say the same, field by field,
|
|
93
|
+
* so a reading that changed nothing keeps the one a legend drew.
|
|
94
|
+
*/
|
|
95
|
+
export declare const sameVerbs: <Verbs extends object>(a: Verbs, b: Verbs) => boolean;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The keys a two-pane layout (a sidebar beside a page) reads: the cursor's
|
|
3
|
+
* moves, Return, Tab between the panes, and the Command chords on the
|
|
4
|
+
* cursor row. The app maps them onto its own verbs and adds its own chords;
|
|
5
|
+
* the window listener that delivers them is `usePaneKeys`.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* The action a key asks of a two-pane layout, or null for one no pane
|
|
9
|
+
* answers. Bare keys move the cursor (↑ ↓, Home and End, Page Up and Down,
|
|
10
|
+
* and ⌘↑ ⌘↓, Home and End for a laptop keyboard), Return runs the cursor
|
|
11
|
+
* row's verb, Tab and Shift-Tab switch panes, and `.` reveals; the rest are
|
|
12
|
+
* Command chords. Neither a chord with the other of Command and Control,
|
|
13
|
+
* nor Shift but with Tab, is the panes' (an app that gives Shift a chord
|
|
14
|
+
* reads it before this).
|
|
15
|
+
*/
|
|
16
|
+
export function paneKeyAction(stroke, options = {}) {
|
|
17
|
+
const { key, altKey: alt, shiftKey: shift } = stroke;
|
|
18
|
+
const command = options.command ?? 'meta';
|
|
19
|
+
const meta = command === 'meta' ? stroke.metaKey : stroke.ctrlKey;
|
|
20
|
+
const other = command === 'meta' ? stroke.ctrlKey : stroke.metaKey;
|
|
21
|
+
if (other)
|
|
22
|
+
return null;
|
|
23
|
+
if (key === 'Tab' && !meta && !alt)
|
|
24
|
+
return { kind: 'switch-pane', back: shift };
|
|
25
|
+
if (shift)
|
|
26
|
+
return null;
|
|
27
|
+
if (!meta && !alt) {
|
|
28
|
+
switch (key) {
|
|
29
|
+
case 'ArrowUp':
|
|
30
|
+
return { kind: 'move', to: 'up' };
|
|
31
|
+
case 'ArrowDown':
|
|
32
|
+
return { kind: 'move', to: 'down' };
|
|
33
|
+
case 'Home':
|
|
34
|
+
return { kind: 'move', to: 'start' };
|
|
35
|
+
case 'End':
|
|
36
|
+
return { kind: 'move', to: 'end' };
|
|
37
|
+
case 'PageUp':
|
|
38
|
+
return { kind: 'move', to: 'page-up' };
|
|
39
|
+
case 'PageDown':
|
|
40
|
+
return { kind: 'move', to: 'page-down' };
|
|
41
|
+
case 'Enter':
|
|
42
|
+
return { kind: 'enter' };
|
|
43
|
+
case '.':
|
|
44
|
+
return { kind: 'reveal' };
|
|
45
|
+
default:
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if (meta && alt) {
|
|
50
|
+
if (key === 'Enter')
|
|
51
|
+
return { kind: 'restart' };
|
|
52
|
+
const letter = /^Key([A-Z])$/u.exec(stroke.code)?.[1];
|
|
53
|
+
return letter === undefined ? null : { kind: 'chord', letter: letter.toLowerCase(), alt: true };
|
|
54
|
+
}
|
|
55
|
+
if (!meta)
|
|
56
|
+
return null;
|
|
57
|
+
switch (key) {
|
|
58
|
+
case 'ArrowUp':
|
|
59
|
+
return { kind: 'move', to: 'start' };
|
|
60
|
+
case 'ArrowDown':
|
|
61
|
+
return { kind: 'move', to: 'end' };
|
|
62
|
+
case 'Backspace':
|
|
63
|
+
return { kind: 'remove' };
|
|
64
|
+
case 'Enter':
|
|
65
|
+
return { kind: 'toggle' };
|
|
66
|
+
default:
|
|
67
|
+
return key.length === 1 ? { kind: 'chord', letter: key.toLowerCase(), alt: false } : null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Where a move takes a cursor among `count` rows from `index` (-1 for no
|
|
72
|
+
* cursor yet, which any move puts on the first row, or the last for `end`).
|
|
73
|
+
* Every move stops at either end; a page move goes `page` rows. Null when
|
|
74
|
+
* there are no rows.
|
|
75
|
+
*/
|
|
76
|
+
export function movedIndex(count, index, to, page = 1) {
|
|
77
|
+
if (count === 0)
|
|
78
|
+
return null;
|
|
79
|
+
if (index < 0)
|
|
80
|
+
return to === 'end' ? count - 1 : 0;
|
|
81
|
+
const step = Math.max(1, page);
|
|
82
|
+
const next = to === 'up'
|
|
83
|
+
? index - 1
|
|
84
|
+
: to === 'down'
|
|
85
|
+
? index + 1
|
|
86
|
+
: to === 'start'
|
|
87
|
+
? 0
|
|
88
|
+
: to === 'end'
|
|
89
|
+
? count - 1
|
|
90
|
+
: to === 'page-up'
|
|
91
|
+
? index - step
|
|
92
|
+
: index + step;
|
|
93
|
+
return Math.min(count - 1, Math.max(0, next));
|
|
94
|
+
}
|
|
95
|
+
/** A main pane that offers nothing to the keys. */
|
|
96
|
+
export const NO_MAIN_VERBS = {
|
|
97
|
+
rows: false,
|
|
98
|
+
enter: null,
|
|
99
|
+
remove: false,
|
|
100
|
+
reveal: false,
|
|
101
|
+
toggle: null,
|
|
102
|
+
restart: false
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Whether two readings of what a pane offers say the same, field by field,
|
|
106
|
+
* so a reading that changed nothing keeps the one a legend drew.
|
|
107
|
+
*/
|
|
108
|
+
export const sameVerbs = (a, b) => Object.keys(a).every((field) => a[field] === b[field]) &&
|
|
109
|
+
Object.keys(b).length === Object.keys(a).length;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panes: the path bar and status line a pane opens and closes with, the
|
|
3
|
+
* compact controls inside them and in listing rows, and the keyboard of a
|
|
4
|
+
* sidebar beside a page (`usePaneKeys`) with the pure key mapping and DOM
|
|
5
|
+
* readers it is built on. Styled by the listing look under `.listing-root`.
|
|
6
|
+
*/
|
|
7
|
+
export { InRowContext, QuietAction, RowIconAction, RowLinkLookContext, useInRow, type ControlVerb, type LinkLook, type QuietActionProps, type RowIconActionProps } from './PaneActions.js';
|
|
8
|
+
export { PanePathBar, PaneStatus, type PaneCrumb, type PanePathBarProps, type PaneStatusProps } from './PaneFrame.js';
|
|
9
|
+
export { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, tabStops, verbControl, type SidebarTabStops, type TabStop } from './PaneKeys.js';
|
|
10
|
+
export { movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs, type MainVerbs, type PaneKeyAction, type PaneKeyOptions, type PaneKeyStroke, type PaneMove } from './PaneKeys.logic.js';
|
|
11
|
+
export { usePaneKeys, type Pane, type PaneKeys, type PaneKeysOptions } from './usePaneKeys.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panes: the path bar and status line a pane opens and closes with, the
|
|
3
|
+
* compact controls inside them and in listing rows, and the keyboard of a
|
|
4
|
+
* sidebar beside a page (`usePaneKeys`) with the pure key mapping and DOM
|
|
5
|
+
* readers it is built on. Styled by the listing look under `.listing-root`.
|
|
6
|
+
*/
|
|
7
|
+
export { InRowContext, QuietAction, RowIconAction, RowLinkLookContext, useInRow } from './PaneActions.js';
|
|
8
|
+
export { PanePathBar, PaneStatus } from './PaneFrame.js';
|
|
9
|
+
export { isTabStop, nextTabStop, pageRows, paneRow, paneRows, showRow, tabStops, verbControl } from './PaneKeys.js';
|
|
10
|
+
export { movedIndex, NO_MAIN_VERBS, paneKeyAction, sameVerbs } from './PaneKeys.logic.js';
|
|
11
|
+
export { usePaneKeys } from './usePaneKeys.js';
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
import type { RowCursor } from '../listing/Listing.js';
|
|
3
|
+
import { type PaneMove } from './PaneKeys.logic.js';
|
|
4
|
+
/** The two panes of a two-pane view: the sidebar and the page beside it. */
|
|
5
|
+
export type Pane = 'sidebar' | 'main';
|
|
6
|
+
/** What a view hands `usePaneKeys`. */
|
|
7
|
+
export interface PaneKeysOptions<Action extends {
|
|
8
|
+
readonly kind: string;
|
|
9
|
+
}, Verbs extends object> {
|
|
10
|
+
/** The view is shown; while it is hidden no key acts. */
|
|
11
|
+
readonly shown: boolean;
|
|
12
|
+
/** The view's first data landed, replacing the panes the focus was in; its turning true hands the focus on again. */
|
|
13
|
+
readonly loaded: boolean;
|
|
14
|
+
/** The pane the keys start in. */
|
|
15
|
+
readonly initialPane: Pane;
|
|
16
|
+
/** Names the page the main pane shows; its cursor row is kept with it, so a new page starts with none. */
|
|
17
|
+
readonly page: string;
|
|
18
|
+
/** The sidebar's rows top to bottom by key, as its cursor walks them. */
|
|
19
|
+
readonly sidebarKeys: readonly string[];
|
|
20
|
+
/** The sidebar row the cursor rests on until the keys or the pointer move it: the open page's. */
|
|
21
|
+
readonly openKey: string | null;
|
|
22
|
+
/** What the main pane's cursor row and path bar offer, read off the rendered pane. */
|
|
23
|
+
readonly readVerbs: (main: Element | null, cursor: string | null) => Verbs;
|
|
24
|
+
/** What a pane that offers nothing offers. */
|
|
25
|
+
readonly noVerbs: Verbs;
|
|
26
|
+
/**
|
|
27
|
+
* What else the main pane's rows and controls follow (its data), so the
|
|
28
|
+
* reading follows it too. Unread where the view leaves the cursor out of
|
|
29
|
+
* render (`cursorInRender`), which reads them after its every render.
|
|
30
|
+
*/
|
|
31
|
+
readonly follows?: readonly unknown[];
|
|
32
|
+
/** The action a key asks of the view, or null for one it leaves alone. */
|
|
33
|
+
readonly readKey: (event: KeyboardEvent) => Action | null;
|
|
34
|
+
/**
|
|
35
|
+
* Whether an action is the cursor's (a move, Return), which a focused
|
|
36
|
+
* control keeps for itself. The shared listener knows two actions by
|
|
37
|
+
* kind: `move` and `switch-pane` (with `back` for Shift-Tab).
|
|
38
|
+
*/
|
|
39
|
+
readonly cursorKey: (action: Action) => boolean;
|
|
40
|
+
/** Runs an action the keys asked for, in the pane the key was aimed at. */
|
|
41
|
+
readonly run: (action: Action, pane: Pane) => void;
|
|
42
|
+
/**
|
|
43
|
+
* Tab and Shift-Tab walk the sidebar's own controls too, as one cycle
|
|
44
|
+
* with the page's in document order (`nextTabStop` with a sidebar), for a
|
|
45
|
+
* sidebar whose path bar, fields, or status line hold controls no key
|
|
46
|
+
* runs. Without it, Tab from the sidebar goes to the page's home.
|
|
47
|
+
*/
|
|
48
|
+
readonly sidebarStops?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The view reads each pane's cursor row in render (`mainKey`,
|
|
51
|
+
* `sidebarKey`), so a cursor move draws the view again: the default.
|
|
52
|
+
* False leaves a move to the two rows it changes and to the verbs it
|
|
53
|
+
* offers, for a view whose pages and sidebar are too large to draw again
|
|
54
|
+
* per move; `mainKey` and `sidebarKey` are then always null,
|
|
55
|
+
* and `rowCursor.current()` and `sidebarCursor.current()` give the rows
|
|
56
|
+
* now. The main pane's rows and verbs are then read after every render of
|
|
57
|
+
* the view, which draws rarely, so a row any of its state adds or
|
|
58
|
+
* removes is never missed. In either mode a row that comes or goes with a
|
|
59
|
+
* render of its page alone (`RowCursor.rowsChanged`) has them read again.
|
|
60
|
+
*/
|
|
61
|
+
readonly cursorInRender?: boolean;
|
|
62
|
+
}
|
|
63
|
+
/** The panes' state and the moves a view's verbs and legend run. */
|
|
64
|
+
export interface PaneKeys<Verbs> {
|
|
65
|
+
/** The view's root, which holds both panes. */
|
|
66
|
+
readonly rootRef: RefObject<HTMLDivElement | null>;
|
|
67
|
+
/** The main pane. */
|
|
68
|
+
readonly mainRef: RefObject<HTMLDivElement | null>;
|
|
69
|
+
/** The pane the keys act in, which wears the accent on its frame. */
|
|
70
|
+
readonly activePane: Pane;
|
|
71
|
+
/**
|
|
72
|
+
* The sidebar's cursor row: the one the keys or the pointer moved to,
|
|
73
|
+
* else `openKey`. Always null where the view leaves the cursor out of
|
|
74
|
+
* render (`cursorInRender`), which reads `sidebarCursor.current()`.
|
|
75
|
+
*/
|
|
76
|
+
readonly sidebarKey: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* The sidebar's cursor as its rows follow it, the same object for the
|
|
79
|
+
* view's life: `current()` is `sidebarKey` now, `subscribe` hears each
|
|
80
|
+
* change of it, from a move or from the rows and `openKey` the view
|
|
81
|
+
* hands in, and `point` is `pointSidebar`. A row that follows it draws
|
|
82
|
+
* on its own when it gains or loses the cursor.
|
|
83
|
+
*/
|
|
84
|
+
readonly sidebarCursor: RowCursor;
|
|
85
|
+
/**
|
|
86
|
+
* The row the sidebar's cursor rests on while it is moved to none: the
|
|
87
|
+
* open row, else the first. A row that follows `sidebarCursor` and is
|
|
88
|
+
* memoized takes whether it is this one as a prop, so it draws in the
|
|
89
|
+
* same render that moves the rest there or away.
|
|
90
|
+
*/
|
|
91
|
+
readonly sidebarRest: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* The main pane's cursor row on the page shown, or null for none yet.
|
|
94
|
+
* Always null where the view leaves the cursor out of render
|
|
95
|
+
* (`cursorInRender`), which reads `rowCursor.current()`.
|
|
96
|
+
*/
|
|
97
|
+
readonly mainKey: string | null;
|
|
98
|
+
/** What the main pane's cursor row and path bar offer now (`readVerbs`). */
|
|
99
|
+
readonly offered: Verbs;
|
|
100
|
+
/** The pointer or the focus entered the sidebar. */
|
|
101
|
+
readonly activateSidebar: () => void;
|
|
102
|
+
/** The pointer or the focus entered the main pane; the sidebar's cursor goes back to the open row. */
|
|
103
|
+
readonly activateMain: () => void;
|
|
104
|
+
/** Makes a pane the active one and gives its home the focus, so the keys go on from there. */
|
|
105
|
+
readonly focusPane: (pane: Pane) => void;
|
|
106
|
+
/** Moves the sidebar's cursor to a row, as the pointer moving over it does. */
|
|
107
|
+
readonly pointSidebar: (key: string) => void;
|
|
108
|
+
/** The pointer left the sidebar's rows: its cursor goes back to the open row unless the pane is in use. */
|
|
109
|
+
readonly leaveSidebar: () => void;
|
|
110
|
+
/** Puts the sidebar's cursor back on the open row, as opening a row does. */
|
|
111
|
+
readonly restSidebar: () => void;
|
|
112
|
+
/** Moves the main pane's cursor to a row of the page shown; the same function while the page is. */
|
|
113
|
+
readonly pointMain: (key: string) => void;
|
|
114
|
+
/**
|
|
115
|
+
* The main pane's cursor as `RowCursorContext` carries it, the same object
|
|
116
|
+
* while the page is, so a move draws only the rows it changes.
|
|
117
|
+
*/
|
|
118
|
+
readonly rowCursor: RowCursor;
|
|
119
|
+
/** Puts the main pane's cursor on a row of a page about to show (an install landing on its page). */
|
|
120
|
+
readonly placeMain: (page: string, key: string) => void;
|
|
121
|
+
/** Moves a pane's cursor, stopping at either end, and brings its row into view. */
|
|
122
|
+
readonly move: (to: PaneMove, pane: Pane) => void;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The keyboard of a view with a sidebar beside a page: each pane has a
|
|
126
|
+
* cursor row the arrows move and the pointer shares (`data-row-key` rows;
|
|
127
|
+
* the main pane's through `RowCursorContext`), Tab and Shift-Tab switch
|
|
128
|
+
* panes and walk the page's other controls, and the sidebar's too where
|
|
129
|
+
* the view asks (`sidebarStops`, `nextTabStop`), and the view's own
|
|
130
|
+
* actions run through `run`. The listener sits on the window in the capture
|
|
131
|
+
* phase and acts only while the view is shown, no overlay is open
|
|
132
|
+
* (`watchOverlays`), no input method is composing, and the key is aimed at
|
|
133
|
+
* the view or at nothing. A text field keeps every key but Tab, a
|
|
134
|
+
* terminal that takes input (a text field inside `.terminal`) keeps Tab
|
|
135
|
+
* too, and a focused control keeps its own arrows and Return. Each pane's
|
|
136
|
+
* home is the element marked `data-pane-home` (`sidebar` for the
|
|
137
|
+
* sidebar's), which the keys hand the focus to.
|
|
138
|
+
*/
|
|
139
|
+
export declare function usePaneKeys<Action extends {
|
|
140
|
+
readonly kind: string;
|
|
141
|
+
}, Verbs extends object>(options: PaneKeysOptions<Action, Verbs>): PaneKeys<Verbs>;
|