@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,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words every chart repeats: the read-outs under the pointer, the point
|
|
3
|
+
* count and zoom control of a scatter chart, the accessible name of an
|
|
4
|
+
* untitled chart, and the messages a picture export fails with. A chart's
|
|
5
|
+
* own title, axis titles, and series names are props, not labels.
|
|
6
|
+
*
|
|
7
|
+
* Functions take raw numbers so an app formats them for its locale and
|
|
8
|
+
* applies its plural rules; values already written as text (a series name, a
|
|
9
|
+
* formatted value) arrive as strings.
|
|
10
|
+
*/
|
|
11
|
+
export interface ChartLabels {
|
|
12
|
+
/** The accessible name of a chart drawn without a title: "Chart". */
|
|
13
|
+
readonly chart: string;
|
|
14
|
+
/** A category's value where its row holds none: "no value". */
|
|
15
|
+
readonly noValue: string;
|
|
16
|
+
/** A scatter chart's caption when every point is in view: "10 points". */
|
|
17
|
+
readonly points: (count: number) => string;
|
|
18
|
+
/** A scatter chart's caption after a zoom leaves some points out: "3 of 10 points". */
|
|
19
|
+
readonly pointsShown: (shown: number, count: number) => string;
|
|
20
|
+
/** The button that undoes a scatter chart's zoom: "Reset zoom". */
|
|
21
|
+
readonly resetZoom: string;
|
|
22
|
+
/** The heading of a line chart's read-out, `time` already written: "Time: 10:42:05". */
|
|
23
|
+
readonly time: (time: string) => string;
|
|
24
|
+
/** One series' value in a read-out: "Questions: 12". */
|
|
25
|
+
readonly seriesValue: (series: string, value: string) => string;
|
|
26
|
+
/** One series' value at a category in a read-out: "sales, Tue: 5". */
|
|
27
|
+
readonly seriesCategoryValue: (series: string, category: string, value: string) => string;
|
|
28
|
+
/** Why a picture could not be saved: the theme sets no readable colour for a token. */
|
|
29
|
+
readonly coloursUnreadable: string;
|
|
30
|
+
/** Why a picture could not be saved: the browser could not draw or encode it. */
|
|
31
|
+
readonly drawFailed: string;
|
|
32
|
+
}
|
|
33
|
+
/** English chart read-outs and messages: the `charts` group `UiokProvider` starts from. */
|
|
34
|
+
export declare const DEFAULT_CHART_LABELS: ChartLabels;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** English digit grouping for the counts the default chart labels write ("1,024 points"). */
|
|
2
|
+
const englishCount = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 });
|
|
3
|
+
/** English chart read-outs and messages: the `charts` group `UiokProvider` starts from. */
|
|
4
|
+
export const DEFAULT_CHART_LABELS = {
|
|
5
|
+
chart: 'Chart',
|
|
6
|
+
noValue: 'no value',
|
|
7
|
+
points: (count) => `${englishCount.format(count)} ${count === 1 ? 'point' : 'points'}`,
|
|
8
|
+
pointsShown: (shown, count) => `${englishCount.format(shown)} of ${englishCount.format(count)} ${count === 1 ? 'point' : 'points'}`,
|
|
9
|
+
resetZoom: 'Reset zoom',
|
|
10
|
+
time: (time) => `Time: ${time}`,
|
|
11
|
+
seriesValue: (series, value) => `${series}: ${value}`,
|
|
12
|
+
seriesCategoryValue: (series, category, value) => `${series}, ${category}: ${value}`,
|
|
13
|
+
coloursUnreadable: 'The theme’s colors could not be read for the picture.',
|
|
14
|
+
drawFailed: 'The picture could not be drawn.'
|
|
15
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words every date and time picker repeats: its month steps, its time
|
|
3
|
+
* fields, its Today, Now, and Done, and the locale its month and weekday
|
|
4
|
+
* names are written in. What a picker's button picks (its accessible name)
|
|
5
|
+
* and what hovering it says are its own props.
|
|
6
|
+
*/
|
|
7
|
+
export interface DateTimeLabels {
|
|
8
|
+
/** The BCP 47 locale month and weekday names are written in, through `Intl`: "en-US". */
|
|
9
|
+
readonly locale: string;
|
|
10
|
+
/** The button that shows the month before: "Previous month". */
|
|
11
|
+
readonly previousMonth: string;
|
|
12
|
+
/** The button that shows the month after: "Next month". */
|
|
13
|
+
readonly nextMonth: string;
|
|
14
|
+
/** The hour field: "Hour". */
|
|
15
|
+
readonly hour: string;
|
|
16
|
+
/** The minute field: "Minute". */
|
|
17
|
+
readonly minute: string;
|
|
18
|
+
/** The second field: "Second". */
|
|
19
|
+
readonly second: string;
|
|
20
|
+
/** The fraction field when it holds up to three digits: "Millisecond". */
|
|
21
|
+
readonly millisecond: string;
|
|
22
|
+
/** The fraction field when it holds four to six digits: "Microsecond". */
|
|
23
|
+
readonly microsecond: string;
|
|
24
|
+
/** The button that picks today's date: "Today". */
|
|
25
|
+
readonly today: string;
|
|
26
|
+
/** The button that picks the current time, or today at it: "Now". */
|
|
27
|
+
readonly now: string;
|
|
28
|
+
/** The button that closes the picker: "Done". */
|
|
29
|
+
readonly done: string;
|
|
30
|
+
}
|
|
31
|
+
/** English picker words and names: the `dateTime` group `UiokProvider` starts from. */
|
|
32
|
+
export declare const DEFAULT_DATE_TIME_LABELS: DateTimeLabels;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** English picker words and names: the `dateTime` group `UiokProvider` starts from. */
|
|
2
|
+
export const DEFAULT_DATE_TIME_LABELS = {
|
|
3
|
+
locale: 'en-US',
|
|
4
|
+
previousMonth: 'Previous month',
|
|
5
|
+
nextMonth: 'Next month',
|
|
6
|
+
hour: 'Hour',
|
|
7
|
+
minute: 'Minute',
|
|
8
|
+
second: 'Second',
|
|
9
|
+
millisecond: 'Millisecond',
|
|
10
|
+
microsecond: 'Microsecond',
|
|
11
|
+
today: 'Today',
|
|
12
|
+
now: 'Now',
|
|
13
|
+
done: 'Done'
|
|
14
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words every dialog repeats whatever it asks: the leave verb's
|
|
3
|
+
* defaults and the name of a confirmation's list of affected items. A
|
|
4
|
+
* dialog's title, message, and verbs are its own props.
|
|
5
|
+
*/
|
|
6
|
+
export interface DialogLabels {
|
|
7
|
+
/** The leave verb on Escape when a dialog names no other: "Cancel". */
|
|
8
|
+
readonly cancel: string;
|
|
9
|
+
/** Escape's verb while a filter field holds a query, which Escape empties first: "Clear". */
|
|
10
|
+
readonly clear: string;
|
|
11
|
+
/**
|
|
12
|
+
* The accessible name of a confirmation's list of the items it touches,
|
|
13
|
+
* given how many it lists: "Affected items".
|
|
14
|
+
*/
|
|
15
|
+
readonly affectedItems: (count: number) => string;
|
|
16
|
+
}
|
|
17
|
+
/** English dialog words: the `dialog` group `UiokProvider` starts from. */
|
|
18
|
+
export declare const DEFAULT_DIALOG_LABELS: DialogLabels;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Shared chrome strings: `UiokProvider`, `useLabels`, and the label groups with their English defaults. */
|
|
2
|
+
export { DEFAULT_CHART_LABELS, type ChartLabels } from './charts.js';
|
|
3
|
+
export { DEFAULT_DATE_TIME_LABELS, type DateTimeLabels } from './dateTime.js';
|
|
4
|
+
export { DEFAULT_DIALOG_LABELS, type DialogLabels } from './dialog.js';
|
|
5
|
+
export { DEFAULT_KEY_LABELS, type KeyLabels } from './keys.js';
|
|
6
|
+
export { DEFAULT_LEGEND_LABELS, type LegendLabels } from './legend.js';
|
|
7
|
+
export { DEFAULT_LISTING_LABELS, type ListingLabels, type SortDirection } from './listing.js';
|
|
8
|
+
export { DEFAULT_PAGER_LABELS, type PagerLabels, type PagerStep } from './pager.js';
|
|
9
|
+
export { DEFAULT_PALETTE_LABELS, type PaletteLabels } from './palette.js';
|
|
10
|
+
export { DEFAULT_SELECT_ALL_LABELS, type SelectAllLabels } from './selectAll.js';
|
|
11
|
+
export { DEFAULT_TERMINAL_LABELS, type TerminalLabels } from './terminal.js';
|
|
12
|
+
export { DEFAULT_LABELS, type UiokLabels } from './UiokLabels.js';
|
|
13
|
+
export { mergeLabels, UiokProvider, useLabels, type LabelsOverride, type UiokLabelsOverride, type UiokProviderProps } from './UiokProvider.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Shared chrome strings: `UiokProvider`, `useLabels`, and the label groups with their English defaults. */
|
|
2
|
+
export { DEFAULT_CHART_LABELS } from './charts.js';
|
|
3
|
+
export { DEFAULT_DATE_TIME_LABELS } from './dateTime.js';
|
|
4
|
+
export { DEFAULT_DIALOG_LABELS } from './dialog.js';
|
|
5
|
+
export { DEFAULT_KEY_LABELS } from './keys.js';
|
|
6
|
+
export { DEFAULT_LEGEND_LABELS } from './legend.js';
|
|
7
|
+
export { DEFAULT_LISTING_LABELS } from './listing.js';
|
|
8
|
+
export { DEFAULT_PAGER_LABELS } from './pager.js';
|
|
9
|
+
export { DEFAULT_PALETTE_LABELS } from './palette.js';
|
|
10
|
+
export { DEFAULT_SELECT_ALL_LABELS } from './selectAll.js';
|
|
11
|
+
export { DEFAULT_TERMINAL_LABELS } from './terminal.js';
|
|
12
|
+
export { DEFAULT_LABELS } from './UiokLabels.js';
|
|
13
|
+
export { mergeLabels, UiokProvider, useLabels } from './UiokProvider.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { LayerModifier } from '../keyboard/KeyChord.logic.js';
|
|
2
|
+
/**
|
|
3
|
+
* The words and glyphs every printed or spoken chord uses: what each
|
|
4
|
+
* modifier and named key is called, how a chord is written as text, and
|
|
5
|
+
* what a key cap says. The defaults are macOS's English names and glyphs; an
|
|
6
|
+
* app on another platform or in another language supplies its own through
|
|
7
|
+
* `UiokProvider`.
|
|
8
|
+
*
|
|
9
|
+
* Keys are `KeyboardEvent.key` values (`ArrowUp`, `Enter`, `' '`, `?`). A key
|
|
10
|
+
* missing from `names` is spoken as its capital, and one missing from
|
|
11
|
+
* `keyGlyphs` is written as its capital.
|
|
12
|
+
*/
|
|
13
|
+
export interface KeyLabels {
|
|
14
|
+
/** Each modifier's name in a spoken chord and a label: "Command". */
|
|
15
|
+
readonly modifiers: Readonly<Record<LayerModifier, string>>;
|
|
16
|
+
/** Named keys in words, by `KeyboardEvent.key`: `{ Enter: 'Return', ' ': 'Space' }`. */
|
|
17
|
+
readonly names: Readonly<Partial<Record<string, string>>>;
|
|
18
|
+
/** Each modifier as a chord written in text prints it: "⌘". */
|
|
19
|
+
readonly modifierGlyphs: Readonly<Record<LayerModifier, string>>;
|
|
20
|
+
/** Named keys as a chord written in text prints them, by `KeyboardEvent.key`: `{ Enter: '↩' }`. */
|
|
21
|
+
readonly keyGlyphs: Readonly<Partial<Record<string, string>>>;
|
|
22
|
+
/** What the space bar's key cap says when a chord is drawn: "space". */
|
|
23
|
+
readonly spaceCap: string;
|
|
24
|
+
/** What the Escape key cap says when a chord is drawn: "esc". */
|
|
25
|
+
readonly escapeCap: string;
|
|
26
|
+
}
|
|
27
|
+
/** English key names and macOS glyphs: the `keys` group `UiokProvider` starts from. */
|
|
28
|
+
export declare const DEFAULT_KEY_LABELS: KeyLabels;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/** English key names and macOS glyphs: the `keys` group `UiokProvider` starts from. */
|
|
2
|
+
export const DEFAULT_KEY_LABELS = {
|
|
3
|
+
modifiers: {
|
|
4
|
+
ctrl: 'Control',
|
|
5
|
+
alt: 'Option',
|
|
6
|
+
shift: 'Shift',
|
|
7
|
+
meta: 'Command'
|
|
8
|
+
},
|
|
9
|
+
names: {
|
|
10
|
+
ArrowUp: 'Up',
|
|
11
|
+
ArrowDown: 'Down',
|
|
12
|
+
ArrowLeft: 'Left',
|
|
13
|
+
ArrowRight: 'Right',
|
|
14
|
+
Backspace: 'Backspace',
|
|
15
|
+
Enter: 'Return',
|
|
16
|
+
Escape: 'Escape',
|
|
17
|
+
Tab: 'Tab',
|
|
18
|
+
Home: 'Home',
|
|
19
|
+
End: 'End',
|
|
20
|
+
PageUp: 'Page Up',
|
|
21
|
+
PageDown: 'Page Down',
|
|
22
|
+
' ': 'Space',
|
|
23
|
+
'`': 'Backquote',
|
|
24
|
+
',': 'Comma',
|
|
25
|
+
'.': 'Period',
|
|
26
|
+
'/': 'Slash',
|
|
27
|
+
'?': 'Question Mark',
|
|
28
|
+
'[': 'Left Bracket',
|
|
29
|
+
']': 'Right Bracket'
|
|
30
|
+
},
|
|
31
|
+
modifierGlyphs: {
|
|
32
|
+
ctrl: '⌃',
|
|
33
|
+
alt: '⌥',
|
|
34
|
+
shift: '⇧',
|
|
35
|
+
meta: '⌘'
|
|
36
|
+
},
|
|
37
|
+
keyGlyphs: {
|
|
38
|
+
ArrowUp: '↑',
|
|
39
|
+
ArrowDown: '↓',
|
|
40
|
+
ArrowLeft: '←',
|
|
41
|
+
ArrowRight: '→',
|
|
42
|
+
Backspace: '⌫',
|
|
43
|
+
Enter: '↩',
|
|
44
|
+
Escape: '⎋',
|
|
45
|
+
Tab: '⇥',
|
|
46
|
+
Home: '↖',
|
|
47
|
+
End: '↘',
|
|
48
|
+
PageUp: '⇞',
|
|
49
|
+
PageDown: '⇟'
|
|
50
|
+
},
|
|
51
|
+
spaceCap: 'space',
|
|
52
|
+
escapeCap: 'esc'
|
|
53
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words a key legend strip says around the verbs it lists: its own
|
|
3
|
+
* name, the name of its verb group, the spoken name of one key cap of a
|
|
4
|
+
* pair, and the overflow chip's spoken count. The verbs' labels and a
|
|
5
|
+
* pair's shared label are the app's (`KeyLegendStrip` props), never here.
|
|
6
|
+
*/
|
|
7
|
+
export interface LegendLabels {
|
|
8
|
+
/** The strip's accessible name: "Keyboard shortcuts". */
|
|
9
|
+
readonly label: string;
|
|
10
|
+
/** The accessible name of the group that holds the verbs: "Verbs". */
|
|
11
|
+
readonly verbs: string;
|
|
12
|
+
/**
|
|
13
|
+
* The accessible name of one key cap in a paired place, which shows no
|
|
14
|
+
* label of its own: the chord in words, then the verb ("Up Move Up").
|
|
15
|
+
*/
|
|
16
|
+
readonly capName: (chord: string, verb: string) => string;
|
|
17
|
+
/** The overflow chip's spoken name for the `count` verbs it holds: "3 more shortcuts". */
|
|
18
|
+
readonly more: (count: number) => string;
|
|
19
|
+
}
|
|
20
|
+
/** English legend words: the `legend` group `UiokProvider` starts from. */
|
|
21
|
+
export declare const DEFAULT_LEGEND_LABELS: LegendLabels;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** English legend words: the `legend` group `UiokProvider` starts from. */
|
|
2
|
+
export const DEFAULT_LEGEND_LABELS = {
|
|
3
|
+
label: 'Keyboard shortcuts',
|
|
4
|
+
verbs: 'Verbs',
|
|
5
|
+
capName: (chord, verb) => `${chord} ${verb}`,
|
|
6
|
+
more: (count) => (count === 1 ? '1 more shortcut' : `${count} more shortcuts`)
|
|
7
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** The way a listing is sorted by one column: up, down, or not by it (null). */
|
|
2
|
+
export type SortDirection = 'asc' | 'desc' | null;
|
|
3
|
+
/**
|
|
4
|
+
* The words a listing's column strip speaks: what a sorting label is called
|
|
5
|
+
* to assistive technology, which says the column and how it sorts now.
|
|
6
|
+
*/
|
|
7
|
+
export interface ListingLabels {
|
|
8
|
+
/**
|
|
9
|
+
* The accessible name of a column label that sorts its listing, given the
|
|
10
|
+
* column's label and the way the listing sorts by it now: "Sort by Name,
|
|
11
|
+
* sorted ascending".
|
|
12
|
+
*/
|
|
13
|
+
readonly sortBy: (column: string, direction: SortDirection) => string;
|
|
14
|
+
}
|
|
15
|
+
/** English listing words: the `listing` group `UiokProvider` starts from. */
|
|
16
|
+
export declare const DEFAULT_LISTING_LABELS: ListingLabels;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** English listing words: the `listing` group `UiokProvider` starts from. */
|
|
2
|
+
export const DEFAULT_LISTING_LABELS = {
|
|
3
|
+
sortBy: (column, direction) => direction === 'asc'
|
|
4
|
+
? `Sort by ${column}, sorted ascending`
|
|
5
|
+
: direction === 'desc'
|
|
6
|
+
? `Sort by ${column}, sorted descending`
|
|
7
|
+
: `Sort by ${column}`
|
|
8
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** One of a pager's four steps: to the first page, the one before, the one after, the last. */
|
|
2
|
+
export type PagerStep = 'begin' | 'previous' | 'next' | 'end';
|
|
3
|
+
/**
|
|
4
|
+
* The words a pager repeats on every list: its steps' names, the accessible
|
|
5
|
+
* names of the pager, its steps, and its page menu, and each page's entry
|
|
6
|
+
* in that menu.
|
|
7
|
+
*
|
|
8
|
+
* The functions take the pager's `kind`, the caller's word for what the
|
|
9
|
+
* pages are of ("rows", or a code an app maps to its own inflected noun),
|
|
10
|
+
* so a language that inflects the noun by its sentence can. Page numbers
|
|
11
|
+
* arrive as raw numbers, so an app formats them for its locale.
|
|
12
|
+
*/
|
|
13
|
+
export interface PagerLabels {
|
|
14
|
+
/** The first page's step, its tooltip or its word: "Begin". */
|
|
15
|
+
readonly begin: string;
|
|
16
|
+
/** The page before's step: "Previous". */
|
|
17
|
+
readonly previous: string;
|
|
18
|
+
/** The page after's step: "Next". */
|
|
19
|
+
readonly next: string;
|
|
20
|
+
/** The last page's step: "End". */
|
|
21
|
+
readonly end: string;
|
|
22
|
+
/** The pager's accessible name: "Pages of rows". */
|
|
23
|
+
readonly pages: (kind: string) => string;
|
|
24
|
+
/** The page menu's accessible name: "Page of rows". */
|
|
25
|
+
readonly page: (kind: string) => string;
|
|
26
|
+
/** A step's accessible name: "Next page of rows". */
|
|
27
|
+
readonly step: (step: PagerStep, kind: string) => string;
|
|
28
|
+
/** A page's entry in the page menu, both numbers from 1: "3 of 12". */
|
|
29
|
+
readonly pageOption: (page: number, pages: number) => string;
|
|
30
|
+
}
|
|
31
|
+
/** English pager words: the `pager` group `UiokProvider` starts from. */
|
|
32
|
+
export declare const DEFAULT_PAGER_LABELS: PagerLabels;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** English digit grouping for the page numbers the default pager labels write ("1,024"). */
|
|
2
|
+
const englishCount = new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 });
|
|
3
|
+
/** The English word for each step, as it opens a step's accessible name. */
|
|
4
|
+
const STEP_WORDS = {
|
|
5
|
+
begin: 'Begin',
|
|
6
|
+
previous: 'Previous',
|
|
7
|
+
next: 'Next',
|
|
8
|
+
end: 'End'
|
|
9
|
+
};
|
|
10
|
+
/** English pager words: the `pager` group `UiokProvider` starts from. */
|
|
11
|
+
export const DEFAULT_PAGER_LABELS = {
|
|
12
|
+
begin: STEP_WORDS.begin,
|
|
13
|
+
previous: STEP_WORDS.previous,
|
|
14
|
+
next: STEP_WORDS.next,
|
|
15
|
+
end: STEP_WORDS.end,
|
|
16
|
+
pages: (kind) => `Pages of ${kind}`,
|
|
17
|
+
page: (kind) => `Page of ${kind}`,
|
|
18
|
+
step: (step, kind) => `${STEP_WORDS[step]} page of ${kind}`,
|
|
19
|
+
pageOption: (page, pages) => `${englishCount.format(page)} of ${englishCount.format(pages)}`
|
|
20
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words a palette's query row speaks: the level chip's tooltip and
|
|
3
|
+
* accessible name, and why a keystroke was refused.
|
|
4
|
+
*/
|
|
5
|
+
export interface PaletteLabels {
|
|
6
|
+
/** The level chip's tooltip verb: "Back". */
|
|
7
|
+
readonly back: string;
|
|
8
|
+
/** The level chip's accessible name, given the level's title: "Back from Formats". */
|
|
9
|
+
readonly backFrom: (level: string) => string;
|
|
10
|
+
/**
|
|
11
|
+
* Said where the count stands after a refused keystroke, given the query
|
|
12
|
+
* it would have made: "nothing matches “dox”".
|
|
13
|
+
*/
|
|
14
|
+
readonly nothingMatches: (query: string) => string;
|
|
15
|
+
}
|
|
16
|
+
/** English palette words: the `palette` group `UiokProvider` starts from. */
|
|
17
|
+
export declare const DEFAULT_PALETTE_LABELS: PaletteLabels;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words a select-all bar repeats under every list whose rows have
|
|
3
|
+
* checkboxes: its checkbox, the lead-in to the bulk actions, and the bar's
|
|
4
|
+
* accessible name when the caller gives none.
|
|
5
|
+
*/
|
|
6
|
+
export interface SelectAllLabels {
|
|
7
|
+
/** The checkbox that checks or clears every row: "Check all". */
|
|
8
|
+
readonly checkAll: string;
|
|
9
|
+
/** The words before the bulk actions: "With selected:". */
|
|
10
|
+
readonly withSelected: string;
|
|
11
|
+
/** The bar's accessible name when the caller gives none: "With selected". */
|
|
12
|
+
readonly label: string;
|
|
13
|
+
}
|
|
14
|
+
/** English select-all words: the `selectAll` group `UiokProvider` starts from. */
|
|
15
|
+
export declare const DEFAULT_SELECT_ALL_LABELS: SelectAllLabels;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The words every terminal repeats: its menu's accessible name and items,
|
|
3
|
+
* the line that stands in for a terminal that could not start, the input
|
|
4
|
+
* element's fallback name, and its scrollbar's name. A terminal's own name
|
|
5
|
+
* is its `ariaLabel` prop.
|
|
6
|
+
*/
|
|
7
|
+
export interface TerminalLabels {
|
|
8
|
+
/** The accessible name of the menu a secondary click opens: "Terminal". */
|
|
9
|
+
readonly menu: string;
|
|
10
|
+
/** The menu's Copy item, macOS's own word for the verb: "Copy". */
|
|
11
|
+
readonly copy: string;
|
|
12
|
+
/** The menu's Paste item, macOS's own word for the verb: "Paste". */
|
|
13
|
+
readonly paste: string;
|
|
14
|
+
/** Shown in place of a terminal whose engine could not start: "Could not start the terminal." */
|
|
15
|
+
readonly startFailed: string;
|
|
16
|
+
/**
|
|
17
|
+
* The input element's accessible name when the engine is started without
|
|
18
|
+
* one (`Terminal` always passes its `ariaLabel`): "Terminal input".
|
|
19
|
+
*/
|
|
20
|
+
readonly input: string;
|
|
21
|
+
/** The accessible name of the scrollbar over the terminal's history: "Scrollback". */
|
|
22
|
+
readonly scrollback: string;
|
|
23
|
+
}
|
|
24
|
+
/** English terminal words: the `terminal` group `UiokProvider` starts from. */
|
|
25
|
+
export declare const DEFAULT_TERMINAL_LABELS: TerminalLabels;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** English terminal words: the `terminal` group `UiokProvider` starts from. */
|
|
2
|
+
export const DEFAULT_TERMINAL_LABELS = {
|
|
3
|
+
menu: 'Terminal',
|
|
4
|
+
copy: 'Copy',
|
|
5
|
+
paste: 'Paste',
|
|
6
|
+
startFailed: 'Could not start the terminal.',
|
|
7
|
+
input: 'Terminal input',
|
|
8
|
+
scrollback: 'Scrollback'
|
|
9
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Chord } from '../keyboard/Keyboard.logic.js';
|
|
2
|
+
import { type LegendLabels } from '../labels/legend.js';
|
|
3
|
+
/**
|
|
4
|
+
* The name of an action with two opposite directions ("upDown"), which two
|
|
5
|
+
* verbs share to say they may be drawn in one place under one label. The app
|
|
6
|
+
* owns the vocabulary and supplies each pair's label (`LegendUnitOptions`
|
|
7
|
+
* `pairLabel`). That label is a message of its own in every language, never
|
|
8
|
+
* the two verbs' labels joined, so a pair folds the same way whatever words
|
|
9
|
+
* the verbs take.
|
|
10
|
+
*/
|
|
11
|
+
export type LegendPair = string;
|
|
12
|
+
/**
|
|
13
|
+
* What a legend needs of a listed verb to pair it: its chord, its label, and
|
|
14
|
+
* the pair it is one direction of, if any. A verb says its pair itself,
|
|
15
|
+
* unless the caller reads it otherwise through `LegendUnitOptions` `pairOf`.
|
|
16
|
+
*/
|
|
17
|
+
export interface Pairable {
|
|
18
|
+
readonly chord: Chord;
|
|
19
|
+
readonly label: string;
|
|
20
|
+
readonly pair?: LegendPair;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One place on a legend: a verb, or two neighbouring verbs that are one
|
|
24
|
+
* action's opposite directions, drawn as both key caps and one label
|
|
25
|
+
* ("Up/Down").
|
|
26
|
+
*/
|
|
27
|
+
export interface LegendUnit<Entry extends Pairable> {
|
|
28
|
+
readonly entries: readonly [Entry] | readonly [Entry, Entry];
|
|
29
|
+
readonly label: string;
|
|
30
|
+
}
|
|
31
|
+
/** How `legendUnits` names and reads pairs. */
|
|
32
|
+
export interface LegendUnitOptions<Entry extends Pairable> {
|
|
33
|
+
/** The one label a pair's place shows ("Up/Down"), in the language in use. */
|
|
34
|
+
readonly pairLabel: (pair: LegendPair) => string;
|
|
35
|
+
/** The pair a verb is one direction of; a verb's own `pair` by default. */
|
|
36
|
+
readonly pairOf?: (entry: Entry) => LegendPair | undefined;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A legend's places, left to right: each verb in the order it is listed,
|
|
40
|
+
* with two neighbours merged into one place when they are one action's two
|
|
41
|
+
* directions: the same modifiers on opposite keys (↑ then ↓, ← then →, Page
|
|
42
|
+
* Up then Page Down, Home then End, `[` then `]`), both of one pair
|
|
43
|
+
* (`pairOf`), under the pair's label (`pairLabel`). Only neighbours merge,
|
|
44
|
+
* so a custom chord that moves one of them apart leaves both as they are,
|
|
45
|
+
* and two verbs that only sit on opposite keys never merge.
|
|
46
|
+
*/
|
|
47
|
+
export declare function legendUnits<Entry extends Pairable>(entries: readonly Entry[], { pairLabel, pairOf }: LegendUnitOptions<Entry>): readonly LegendUnit<Entry>[];
|
|
48
|
+
/**
|
|
49
|
+
* How many places a legend shows from the left when they are `widths` wide
|
|
50
|
+
* and `available` is the room for them: every one when all fit, otherwise
|
|
51
|
+
* as many as fit beside the overflow chip (`chipWidth`, its widest), which
|
|
52
|
+
* then holds the rest. Places drop from the tail, so the everyday verbs a
|
|
53
|
+
* legend lists first stay.
|
|
54
|
+
*/
|
|
55
|
+
export declare function fittingUnits(widths: readonly number[], available: number, chipWidth: number): number;
|
|
56
|
+
/**
|
|
57
|
+
* The overflow chip's text ("+3") and spoken name ("3 more shortcuts", from
|
|
58
|
+
* `UiokLabels.legend`) for the `count` verbs it holds.
|
|
59
|
+
*/
|
|
60
|
+
export declare function moreLabel(count: number, labels?: LegendLabels): {
|
|
61
|
+
readonly text: string;
|
|
62
|
+
readonly spoken: string;
|
|
63
|
+
};
|
|
64
|
+
/** What a key does in a legend's overflow list: close it, move its cursor, or run the row under it. */
|
|
65
|
+
export type MoreListAction = {
|
|
66
|
+
readonly kind: 'close';
|
|
67
|
+
} | {
|
|
68
|
+
readonly kind: 'cursor';
|
|
69
|
+
readonly row: number;
|
|
70
|
+
} | {
|
|
71
|
+
readonly kind: 'run';
|
|
72
|
+
readonly row: number;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* The overflow list's keys, as a menu has them: ↑ and ↓ move the cursor
|
|
76
|
+
* round the `rows`, Home and End go to either end, Return or Space runs the
|
|
77
|
+
* row under the cursor, and Escape or Tab closes the list. Null for any
|
|
78
|
+
* other key, and for any Command chord, which the list leaves to the menu
|
|
79
|
+
* bar.
|
|
80
|
+
*/
|
|
81
|
+
export declare function moreListAction(key: {
|
|
82
|
+
readonly key: string;
|
|
83
|
+
readonly metaKey: boolean;
|
|
84
|
+
}, cursor: number, rows: number): MoreListAction | null;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* How a key legend lays out its verbs: which neighbours fold into one place,
|
|
3
|
+
* how many places fit beside the overflow chip, and what the overflow list's
|
|
4
|
+
* keys do. Pure functions, shared by `KeyLegendStrip` and by any legend an
|
|
5
|
+
* app draws itself.
|
|
6
|
+
*/
|
|
7
|
+
import { DEFAULT_LEGEND_LABELS } from '../labels/legend.js';
|
|
8
|
+
/** Keys that point opposite ways, each pair in the order a legend lists them. */
|
|
9
|
+
const OPPOSITE_KEYS = [
|
|
10
|
+
['ArrowUp', 'ArrowDown'],
|
|
11
|
+
['ArrowLeft', 'ArrowRight'],
|
|
12
|
+
['PageUp', 'PageDown'],
|
|
13
|
+
['Home', 'End'],
|
|
14
|
+
['[', ']']
|
|
15
|
+
];
|
|
16
|
+
const sameModifiers = (a, b) => (a.ctrl ?? false) === (b.ctrl ?? false) &&
|
|
17
|
+
(a.alt ?? false) === (b.alt ?? false) &&
|
|
18
|
+
(a.shift ?? false) === (b.shift ?? false) &&
|
|
19
|
+
(a.meta ?? false) === (b.meta ?? false);
|
|
20
|
+
const oppositeKeys = (a, b) => sameModifiers(a, b) &&
|
|
21
|
+
OPPOSITE_KEYS.some(([first, second]) => a.key === first && b.key === second);
|
|
22
|
+
/**
|
|
23
|
+
* A legend's places, left to right: each verb in the order it is listed,
|
|
24
|
+
* with two neighbours merged into one place when they are one action's two
|
|
25
|
+
* directions: the same modifiers on opposite keys (↑ then ↓, ← then →, Page
|
|
26
|
+
* Up then Page Down, Home then End, `[` then `]`), both of one pair
|
|
27
|
+
* (`pairOf`), under the pair's label (`pairLabel`). Only neighbours merge,
|
|
28
|
+
* so a custom chord that moves one of them apart leaves both as they are,
|
|
29
|
+
* and two verbs that only sit on opposite keys never merge.
|
|
30
|
+
*/
|
|
31
|
+
export function legendUnits(entries, { pairLabel, pairOf = (entry) => entry.pair }) {
|
|
32
|
+
const units = [];
|
|
33
|
+
for (let index = 0; index < entries.length; index += 1) {
|
|
34
|
+
const entry = entries[index];
|
|
35
|
+
const next = entries[index + 1];
|
|
36
|
+
const pair = pairOf(entry);
|
|
37
|
+
if (next !== undefined &&
|
|
38
|
+
pair !== undefined &&
|
|
39
|
+
pairOf(next) === pair &&
|
|
40
|
+
oppositeKeys(entry.chord, next.chord)) {
|
|
41
|
+
units.push({ entries: [entry, next], label: pairLabel(pair) });
|
|
42
|
+
index += 1;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
units.push({ entries: [entry], label: entry.label });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return units;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* How many places a legend shows from the left when they are `widths` wide
|
|
52
|
+
* and `available` is the room for them: every one when all fit, otherwise
|
|
53
|
+
* as many as fit beside the overflow chip (`chipWidth`, its widest), which
|
|
54
|
+
* then holds the rest. Places drop from the tail, so the everyday verbs a
|
|
55
|
+
* legend lists first stay.
|
|
56
|
+
*/
|
|
57
|
+
export function fittingUnits(widths, available, chipWidth) {
|
|
58
|
+
const total = widths.reduce((sum, width) => sum + width, 0);
|
|
59
|
+
if (total <= available) {
|
|
60
|
+
return widths.length;
|
|
61
|
+
}
|
|
62
|
+
let used = chipWidth;
|
|
63
|
+
let shown = 0;
|
|
64
|
+
for (const width of widths) {
|
|
65
|
+
if (used + width > available) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
used += width;
|
|
69
|
+
shown += 1;
|
|
70
|
+
}
|
|
71
|
+
return shown;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The overflow chip's text ("+3") and spoken name ("3 more shortcuts", from
|
|
75
|
+
* `UiokLabels.legend`) for the `count` verbs it holds.
|
|
76
|
+
*/
|
|
77
|
+
export function moreLabel(count, labels = DEFAULT_LEGEND_LABELS) {
|
|
78
|
+
return { text: `+${count}`, spoken: labels.more(count) };
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The overflow list's keys, as a menu has them: ↑ and ↓ move the cursor
|
|
82
|
+
* round the `rows`, Home and End go to either end, Return or Space runs the
|
|
83
|
+
* row under the cursor, and Escape or Tab closes the list. Null for any
|
|
84
|
+
* other key, and for any Command chord, which the list leaves to the menu
|
|
85
|
+
* bar.
|
|
86
|
+
*/
|
|
87
|
+
export function moreListAction(key, cursor, rows) {
|
|
88
|
+
if (key.key === 'Escape' || key.key === 'Tab') {
|
|
89
|
+
return { kind: 'close' };
|
|
90
|
+
}
|
|
91
|
+
if (key.metaKey || rows === 0) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
switch (key.key) {
|
|
95
|
+
case 'ArrowDown':
|
|
96
|
+
return { kind: 'cursor', row: (cursor + 1) % rows };
|
|
97
|
+
case 'ArrowUp':
|
|
98
|
+
return { kind: 'cursor', row: (cursor + rows - 1) % rows };
|
|
99
|
+
case 'Home':
|
|
100
|
+
return { kind: 'cursor', row: 0 };
|
|
101
|
+
case 'End':
|
|
102
|
+
return { kind: 'cursor', row: rows - 1 };
|
|
103
|
+
case 'Enter':
|
|
104
|
+
case ' ':
|
|
105
|
+
return { kind: 'run', row: Math.min(cursor, rows - 1) };
|
|
106
|
+
default:
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}
|