@bigpixelrocket/uiok 0.0.0-stage → 0.1.1
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 +42 -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,265 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown, ChevronUp, Loader } from 'lucide-react';
|
|
3
|
+
import { createContext, useContext, useLayoutEffect, useRef, useState, useSyncExternalStore } from 'react';
|
|
4
|
+
import { useLabels } from '../labels/UiokProvider.js';
|
|
5
|
+
import { InRowContext, RowLinkLookContext } from '../pane/PaneActions.js';
|
|
6
|
+
import { describedTooltip, tooltip } from '../tooltip/Tooltip.logic.js';
|
|
7
|
+
import { pathParts } from './PathParts.logic.js';
|
|
8
|
+
/**
|
|
9
|
+
* A listing column as wide as `ch` characters and the gutter before it, for
|
|
10
|
+
* a listing's `grid`: `column(9)` is "calc(9ch + var(--pane-column-gap))".
|
|
11
|
+
*/
|
|
12
|
+
export const column = (ch) => `calc(${ch}ch + var(--pane-column-gap))`;
|
|
13
|
+
/** The width every listing's action column takes, so actions line up from one listing to the next. */
|
|
14
|
+
export const ACTION_COLUMN = column(10);
|
|
15
|
+
/** A row control drawn as its icon alone (`.pane-icon-act`), in pixels. */
|
|
16
|
+
export const ICON_LINK_PX = 22;
|
|
17
|
+
/**
|
|
18
|
+
* A listing column of `count` row controls drawn as icons alone
|
|
19
|
+
* (`RowIconAction`), `gapPx` apart, with the gutter before it, so they never reach over the column
|
|
20
|
+
* before them.
|
|
21
|
+
*/
|
|
22
|
+
export const iconLinksColumn = (count, gapPx) => `calc(${count * ICON_LINK_PX + Math.max(0, count - 1) * gapPx}px + var(--pane-column-gap))`;
|
|
23
|
+
/**
|
|
24
|
+
* A row link's word, at most this many pixels a character at the 12 px it
|
|
25
|
+
* draws in, so the column it sizes is never narrower than the word.
|
|
26
|
+
*/
|
|
27
|
+
const LINK_CHARACTER_PX = 7;
|
|
28
|
+
/** A row link in words (`.pane-icon-act.worded`), in pixels: its padding, its icon and gap for both, and its word. */
|
|
29
|
+
const wordedLinkPx = (look, word) => 10 + (look === 'both' ? 17 : 0) + word.length * LINK_CHARACTER_PX;
|
|
30
|
+
/**
|
|
31
|
+
* A listing column of row links as `look` draws them (`RowLinkLookContext`):
|
|
32
|
+
* `icons`, the column as it holds them as icons, unchanged; in words, room
|
|
33
|
+
* for each of `words` (the verbs of the row that names the most) and
|
|
34
|
+
* `extraPx` more for the controls beside them that never take words (a
|
|
35
|
+
* favorite's star, a menu), with the gutter before it, so the links never
|
|
36
|
+
* reach over the columns beside them.
|
|
37
|
+
*/
|
|
38
|
+
export const linksColumn = (look, icons, words, extraPx = 0) => look === 'icons'
|
|
39
|
+
? icons
|
|
40
|
+
: `calc(${words.reduce((sum, word) => sum + wordedLinkPx(look, word), extraPx)}px + var(--pane-column-gap))`;
|
|
41
|
+
/**
|
|
42
|
+
* A strip label that sorts: a button over the column's whole surface, the
|
|
43
|
+
* arrow of the way it sorts beside the label (before it over numbers, so
|
|
44
|
+
* the label keeps the edge they line up on).
|
|
45
|
+
*/
|
|
46
|
+
function SortLabel({ label, sort, align }) {
|
|
47
|
+
const { sortBy } = useLabels().listing;
|
|
48
|
+
const mark = sort.direction === null ? null : sort.direction === 'asc' ? (_jsx(ChevronUp, { "aria-hidden": true, size: 12 })) : (_jsx(ChevronDown, { "aria-hidden": true, size: 12 }));
|
|
49
|
+
return (_jsxs("button", { "aria-label": sortBy(label, sort.direction), className: sort.direction === null ? 'pane-sort sortable' : 'pane-sort sortable active', onClick: sort.onSort, type: "button", children: [align === 'right' && mark, _jsx("span", { className: "pane-sort-label", ...tooltip(label), children: label }), align !== 'right' && mark] }));
|
|
50
|
+
}
|
|
51
|
+
/** The `aria-sort` of a sorting column's header. */
|
|
52
|
+
const ariaSort = (sort) => sort?.direction === 'asc' ? 'ascending' : sort?.direction === 'desc' ? 'descending' : undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The ruled column strip a listing opens with: the section's name, then a
|
|
55
|
+
* label over each column. Its labels are text, but for a column that sorts
|
|
56
|
+
* its listing (`sort`, and `titleSort` for the name's column), whose label is
|
|
57
|
+
* the control that sorts it, named by `listing.sortBy` from the labels. In a
|
|
58
|
+
* table (`table`) it is the header row; `heading` makes the name the
|
|
59
|
+
* section's heading. Every visible label carries its whole text as its
|
|
60
|
+
* tooltip, since a narrow column cuts it with an ellipsis.
|
|
61
|
+
*/
|
|
62
|
+
export function Strip({ title, columns = [], table = false, heading = false, className, titleSort, titleLabel }) {
|
|
63
|
+
const Title = heading ? 'h3' : 'span';
|
|
64
|
+
return (_jsxs("div", { className: className === undefined ? 'pane-columns pane-strip' : `pane-columns pane-strip ${className}`, role: table ? 'row' : undefined, children: [_jsx("span", { "aria-sort": table ? ariaSort(titleSort) : undefined, className: "row-name", role: table ? 'columnheader' : undefined, children: titleSort === undefined ? (_jsx("span", { className: "pane-sort", children: _jsx(Title, { className: "pane-sort-label", ...tooltip(titleLabel ?? title), children: titleLabel ?? title }) })) : (_jsx(SortLabel, { label: titleLabel ?? title, sort: titleSort })) }), columns.map((entry) => (_jsxs("span", { "aria-hidden": !table && entry.hidden === true ? true : undefined, className: [
|
|
65
|
+
'row-meta',
|
|
66
|
+
entry.align === 'right' || entry.control !== undefined ? 'align-right' : '',
|
|
67
|
+
entry.hidden === true ? 'pane-col-blank' : '',
|
|
68
|
+
entry.control === undefined ? '' : 'pane-col-control'
|
|
69
|
+
]
|
|
70
|
+
.filter(Boolean)
|
|
71
|
+
.join(' '), "aria-sort": table ? ariaSort(entry.sort) : undefined, role: table ? 'columnheader' : undefined, children: [entry.control, entry.hidden === true
|
|
72
|
+
? table && _jsx("span", { className: "visually-hidden", children: entry.label })
|
|
73
|
+
: entry.control === undefined &&
|
|
74
|
+
(entry.sort === undefined ? (_jsx("span", { className: "pane-sort", children: _jsx("span", { className: "pane-sort-label", ...tooltip(entry.label), children: entry.label }) })) : (_jsx(SortLabel, { align: entry.align, label: entry.label, sort: entry.sort })))] }, entry.label)))] }));
|
|
75
|
+
}
|
|
76
|
+
/** The plainer look a row link takes when the one it has makes its listing scroll sideways. */
|
|
77
|
+
const PLAINER_LOOK = {
|
|
78
|
+
both: 'text',
|
|
79
|
+
text: 'icons',
|
|
80
|
+
icons: null
|
|
81
|
+
};
|
|
82
|
+
/** The richest look from `from` on whose need, as far as `needs` knows it, fits in `width`. */
|
|
83
|
+
function roomiestLook(from, needs, width) {
|
|
84
|
+
let look = from;
|
|
85
|
+
for (let plainer = PLAINER_LOOK[look]; plainer !== null && (needs[look] ?? 0) > width + 1; plainer = PLAINER_LOOK[look]) {
|
|
86
|
+
look = plainer;
|
|
87
|
+
}
|
|
88
|
+
return look;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* The look `listing` steps down to when its look in `room` makes it wider
|
|
92
|
+
* than its pane, noting what that look needs; null while it fits or has no
|
|
93
|
+
* plainer look. A forced layout only where a commit or a resize left one due.
|
|
94
|
+
*/
|
|
95
|
+
function plainerFit(listing, room) {
|
|
96
|
+
const plainer = PLAINER_LOOK[room.look];
|
|
97
|
+
if (plainer === null)
|
|
98
|
+
return null;
|
|
99
|
+
const width = listing.clientWidth;
|
|
100
|
+
const needed = listing.scrollWidth;
|
|
101
|
+
if (needed <= width + 1)
|
|
102
|
+
return null;
|
|
103
|
+
room.needs[room.look] = needed;
|
|
104
|
+
return roomiestLook(plainer, room.needs, width);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The look a listing's row links take (`RowLinkLookContext`): the one
|
|
108
|
+
* `chosen`, unless its words make the listing (`listing`) wider than its
|
|
109
|
+
* pane, when they step down to words alone and then to icons, each still
|
|
110
|
+
* named by its tooltip and accessible name, so the listing never scrolls
|
|
111
|
+
* sideways for its links' words. Each look that overflowed is remembered
|
|
112
|
+
* with the width it needs, so a resize changes the look only where the pane
|
|
113
|
+
* crosses one of those widths, trying a richer look again only once the
|
|
114
|
+
* pane grows to its need, and otherwise checks only that the look it has
|
|
115
|
+
* still fits; a new `chosen` or grid (`richest`) starts again from `chosen`.
|
|
116
|
+
* It settles before the listing paints. `fitting` false keeps `chosen`.
|
|
117
|
+
*/
|
|
118
|
+
function useFittedLook(chosen, richest, listing, fitting) {
|
|
119
|
+
const basis = `${chosen}\n${richest}`;
|
|
120
|
+
const [fitted, setFitted] = useState({ basis, look: chosen });
|
|
121
|
+
const look = fitted.basis === basis ? fitted.look : chosen;
|
|
122
|
+
const room = useRef({ basis, chosen, look, width: -1, needs: {} });
|
|
123
|
+
// A listing wider than its pane takes the next plainer look. Its width is
|
|
124
|
+
// its grid's, which the basis and the look decide; a cell clips its text.
|
|
125
|
+
useLayoutEffect(() => {
|
|
126
|
+
const element = listing.current;
|
|
127
|
+
if (!fitting || element === null)
|
|
128
|
+
return;
|
|
129
|
+
const known = room.current;
|
|
130
|
+
if (known.basis !== basis) {
|
|
131
|
+
Object.assign(known, { basis, chosen, look: chosen, width: -1, needs: {} });
|
|
132
|
+
// A look fitted when this basis last held was fitted to the pane as it
|
|
133
|
+
// was then; it starts again from `chosen`.
|
|
134
|
+
if (look !== chosen) {
|
|
135
|
+
setFitted({ basis, look: chosen });
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
known.look = look;
|
|
140
|
+
const plainer = plainerFit(element, known);
|
|
141
|
+
if (plainer !== null)
|
|
142
|
+
setFitted({ basis, look: plainer });
|
|
143
|
+
}, [basis, chosen, fitting, listing, look]);
|
|
144
|
+
useLayoutEffect(() => {
|
|
145
|
+
const element = listing.current;
|
|
146
|
+
// Optional: jsdom has no ResizeObserver.
|
|
147
|
+
if (!fitting || element === null || typeof ResizeObserver === 'undefined')
|
|
148
|
+
return;
|
|
149
|
+
// Its first report checks the look against the pane as it is now.
|
|
150
|
+
room.current.width = -1;
|
|
151
|
+
const observer = new ResizeObserver(() => {
|
|
152
|
+
const known = room.current;
|
|
153
|
+
const width = element.clientWidth;
|
|
154
|
+
// A listing out of view lays nothing out, which says nothing of its room.
|
|
155
|
+
if (width === 0 || width === known.width)
|
|
156
|
+
return;
|
|
157
|
+
known.width = width;
|
|
158
|
+
const roomiest = roomiestLook(known.chosen, known.needs, width);
|
|
159
|
+
const next = roomiest === known.look ? plainerFit(element, known) : roomiest;
|
|
160
|
+
if (next === null)
|
|
161
|
+
return;
|
|
162
|
+
known.look = next;
|
|
163
|
+
setFitted({ basis: known.basis, look: next });
|
|
164
|
+
});
|
|
165
|
+
observer.observe(element);
|
|
166
|
+
return () => observer.disconnect();
|
|
167
|
+
}, [fitting, listing]);
|
|
168
|
+
return look;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* A listing: a table in the listing look (under `.listing-root`), full
|
|
172
|
+
* bleed in its pane, under a ruled column strip whose first label is
|
|
173
|
+
* `titleLabel`, or the section's name when omitted. `grid` is the listing's
|
|
174
|
+
* `--pane-grid`, shared by the strip and every row, so each label sits over
|
|
175
|
+
* its column; a listing whose row links take words gives it as the grid for
|
|
176
|
+
* a look (`linksColumn`), and its rows take the richest look that keeps it
|
|
177
|
+
* inside its pane. A listing with no rows says so in `empty`: a plain line
|
|
178
|
+
* under the strip instead of a table, so no column headers stand over a row
|
|
179
|
+
* that is not one.
|
|
180
|
+
*/
|
|
181
|
+
export function Listing({ title, label = title, grid, columns, className, empty = null, titleSort, titleLabel, children }) {
|
|
182
|
+
const classes = className === undefined ? 'pane-listing' : `pane-listing ${className}`;
|
|
183
|
+
const chosen = useContext(RowLinkLookContext);
|
|
184
|
+
const listing = useRef(null);
|
|
185
|
+
const fitting = typeof grid === 'function';
|
|
186
|
+
const look = useFittedLook(chosen, fitting ? grid(chosen) : grid, listing, fitting && empty === null);
|
|
187
|
+
const style = { '--pane-grid': fitting ? grid(look) : grid };
|
|
188
|
+
if (empty !== null) {
|
|
189
|
+
return (_jsxs("section", { "aria-label": label, className: classes, ref: listing, style: style, children: [_jsx(Strip, { columns: columns, title: title }), _jsx("p", { className: "pane-message", children: empty })] }));
|
|
190
|
+
}
|
|
191
|
+
return (_jsxs("div", { "aria-label": label, className: classes, ref: listing, role: "table", style: style, children: [_jsx(Strip, { columns: columns, table: true, title: title, titleLabel: titleLabel, titleSort: titleSort }), _jsx(RowLinkLookContext.Provider, { value: look, children: children })] }));
|
|
192
|
+
}
|
|
193
|
+
/** The cursor of the pane a row is in, which the app provides; without one no row is the cursor. */
|
|
194
|
+
export const RowCursorContext = createContext({
|
|
195
|
+
current: () => null,
|
|
196
|
+
subscribe: () => () => undefined,
|
|
197
|
+
point: () => undefined
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* One row of a listing: its mark, its name, then its cells. `rowKey` names
|
|
201
|
+
* it to the pane's cursor (`RowCursorContext`), which it wears as the
|
|
202
|
+
* listing's cursor row (`.cursor`, `aria-current`); the pointer moving over
|
|
203
|
+
* it or the focus entering it moves the cursor there. A row with `onOpen`
|
|
204
|
+
* opens its item on a click anywhere but its controls. Controls that say
|
|
205
|
+
* what the keys run mark it with `data-verb` (`QuietAction`,
|
|
206
|
+
* `RowIconAction`), and the app reads them off the cursor row
|
|
207
|
+
* (`verbControl`); such controls leave the Tab order, unless `tabbable`
|
|
208
|
+
* keeps them in it, for a listing whose rows no key runs. A `focusable` row
|
|
209
|
+
* is a stop of its own: the cursor row in the Tab order (or, while no row
|
|
210
|
+
* is, the one marked `entry`), the others reached by the keys that move it.
|
|
211
|
+
*/
|
|
212
|
+
export function Row({ rowKey, mark, name, nameClass, className, onOpen, tabbable = false, focusable = false, entry = false, children }) {
|
|
213
|
+
const cursor = useContext(RowCursorContext);
|
|
214
|
+
const current = useSyncExternalStore(cursor.subscribe, () => cursor.current() === rowKey);
|
|
215
|
+
useLayoutEffect(() => {
|
|
216
|
+
cursor.rowsChanged?.();
|
|
217
|
+
return () => cursor.rowsChanged?.();
|
|
218
|
+
}, [cursor, rowKey]);
|
|
219
|
+
return (_jsx(InRowContext.Provider, { value: !tabbable, children: _jsxs("div", { "aria-current": current ? 'true' : undefined, className: ['row', current ? 'cursor' : '', className ?? ''].filter(Boolean).join(' '), "data-row-key": rowKey, onClick: onOpen, onFocus: () => cursor.point(rowKey),
|
|
220
|
+
// Movement, not entry: a row scrolled under a still pointer as the
|
|
221
|
+
// keys move the cursor must not take the cursor back.
|
|
222
|
+
onPointerMove: () => {
|
|
223
|
+
if (!current)
|
|
224
|
+
cursor.point(rowKey);
|
|
225
|
+
}, role: "row", tabIndex: focusable ? (current || entry ? 0 : -1) : undefined, children: [_jsx("span", { "aria-hidden": true, className: "row-icon", children: mark }), _jsx("span", { className: nameClass === undefined ? 'row-name' : `row-name ${nameClass}`, role: "cell", children: name }), children] }) }));
|
|
226
|
+
}
|
|
227
|
+
/** A cell of a row after its name, in the listing's metadata look (`.row-meta`). */
|
|
228
|
+
export function Cell({ align, className, tip, children }) {
|
|
229
|
+
return (_jsx("span", { className: ['row-meta', align === 'right' ? 'align-right' : '', className ?? '']
|
|
230
|
+
.filter(Boolean)
|
|
231
|
+
.join(' '), role: "cell", ...(tip === undefined || tip === null ? {} : describedTooltip(tip)), children: children }));
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* A state as a State column says it: a dot in the state's tone and its word
|
|
235
|
+
* ("running", "error"), or a spinner for a transition. Inside a row the word
|
|
236
|
+
* takes the tone too, so a failure reads red and a stopped line dim.
|
|
237
|
+
*/
|
|
238
|
+
export function StateMark({ tone, word, busy = false }) {
|
|
239
|
+
return (_jsxs("span", { className: `pane-state pane-tone-${tone}`, children: [busy ? (_jsx(Loader, { "aria-hidden": true, className: "pane-state-busy", size: 11 })) : (_jsx("span", { "aria-hidden": true, className: "pane-state-dot" })), word] }));
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* A path cell: its folders in the row-meta tone, the head giving way first
|
|
243
|
+
* so the ellipsis falls inside it, then the last folder, then the name, in
|
|
244
|
+
* the text tone or the colour `nameClassName` gives it; the whole path in
|
|
245
|
+
* its tooltip.
|
|
246
|
+
*/
|
|
247
|
+
export function PathCell({ path, nameClassName }) {
|
|
248
|
+
const { head, tail, base } = pathParts(path);
|
|
249
|
+
return (_jsxs(Cell, { className: "pane-path", tip: path, children: [_jsx("span", { className: "pane-path-head", children: head }), _jsx("span", { className: "pane-path-tail", children: tail }), _jsx("span", { className: nameClassName === undefined ? 'pane-path-name' : `pane-path-name ${nameClassName}`, children: base })] }));
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* A column that holds a terminal well under its strip: a log or a
|
|
253
|
+
* process's output, full height in the terminal theme's colours (the
|
|
254
|
+
* well, `.pane-well`, is the child's to draw: a `<pre>` of lines, or a
|
|
255
|
+
* terminal in a box). It is a region when `label` names it.
|
|
256
|
+
*/
|
|
257
|
+
export function WellColumn({ title, columns, label, className, children }) {
|
|
258
|
+
const classes = className === undefined ? 'pane-well-column' : `pane-well-column ${className}`;
|
|
259
|
+
const strip = _jsx(Strip, { columns: columns, title: title });
|
|
260
|
+
// The strip's name, then each of its columns at its own width.
|
|
261
|
+
const style = {
|
|
262
|
+
'--pane-grid': `20px minmax(0, 1fr) ${columns.map(() => 'auto').join(' ')}`
|
|
263
|
+
};
|
|
264
|
+
return label === undefined ? (_jsxs("div", { className: classes, style: style, children: [strip, children] })) : (_jsxs("section", { "aria-label": label, className: classes, style: style, children: [strip, children] }));
|
|
265
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** A path split as a path cell draws it: the folders that give way, the last folder, and the name. */
|
|
2
|
+
export interface PathParts {
|
|
3
|
+
/** The folders before the last one, with their slashes; they give way first. */
|
|
4
|
+
readonly head: string;
|
|
5
|
+
/** The last folder with its slash. */
|
|
6
|
+
readonly tail: string;
|
|
7
|
+
/** The name after the last slash. */
|
|
8
|
+
readonly base: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A path as a listing's path cell (`PathCell`) draws it: the folders before
|
|
12
|
+
* the last one (`head`, which gives way first when the row is narrow), the
|
|
13
|
+
* last folder with its slash (`tail`), and the name (`base`), so a long path
|
|
14
|
+
* keeps the folder and the name that say what it is. A trailing slash is
|
|
15
|
+
* dropped, so a folder's path names the folder.
|
|
16
|
+
*/
|
|
17
|
+
export declare function pathParts(path: string): PathParts;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A path as a listing's path cell (`PathCell`) draws it: the folders before
|
|
3
|
+
* the last one (`head`, which gives way first when the row is narrow), the
|
|
4
|
+
* last folder with its slash (`tail`), and the name (`base`), so a long path
|
|
5
|
+
* keeps the folder and the name that say what it is. A trailing slash is
|
|
6
|
+
* dropped, so a folder's path names the folder.
|
|
7
|
+
*/
|
|
8
|
+
export function pathParts(path) {
|
|
9
|
+
const trimmed = path.length > 1 ? path.replace(/\/+$/u, '') : path;
|
|
10
|
+
const cut = trimmed.lastIndexOf('/');
|
|
11
|
+
const folder = trimmed.slice(0, cut + 1);
|
|
12
|
+
const inner = folder.slice(0, -1).lastIndexOf('/');
|
|
13
|
+
return {
|
|
14
|
+
head: folder.slice(0, inner + 1),
|
|
15
|
+
tail: folder.slice(inner + 1),
|
|
16
|
+
base: trimmed.slice(cut + 1)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Listings: the column strip, rows and cells in the listing look (scoped by
|
|
3
|
+
* `.listing-root`), the row cursor they share with the keys, column widths,
|
|
4
|
+
* and the state, path, and terminal-well cells; `CurrentDot` marks the
|
|
5
|
+
* current one in a list.
|
|
6
|
+
*/
|
|
7
|
+
export { type SortDirection } from '../labels/listing.js';
|
|
8
|
+
export { CurrentDot, type CurrentDotProps } from './CurrentDot.js';
|
|
9
|
+
export { ACTION_COLUMN, Cell, column, ICON_LINK_PX, iconLinksColumn, linksColumn, Listing, PathCell, Row, RowCursorContext, StateMark, Strip, WellColumn, type CellProps, type ColumnSort, type ListingColumn, type ListingProps, type PathCellProps, type RowCursor, type RowProps, type StateMarkProps, type StateTone, type StripProps, type WellColumnProps } from './Listing.js';
|
|
10
|
+
export { pathParts, type PathParts } from './PathParts.logic.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Listings: the column strip, rows and cells in the listing look (scoped by
|
|
3
|
+
* `.listing-root`), the row cursor they share with the keys, column widths,
|
|
4
|
+
* and the state, path, and terminal-well cells; `CurrentDot` marks the
|
|
5
|
+
* current one in a list.
|
|
6
|
+
*/
|
|
7
|
+
export {} from '../labels/listing.js';
|
|
8
|
+
export { CurrentDot } from './CurrentDot.js';
|
|
9
|
+
export { ACTION_COLUMN, Cell, column, ICON_LINK_PX, iconLinksColumn, linksColumn, Listing, PathCell, Row, RowCursorContext, StateMark, Strip, WellColumn } from './Listing.js';
|
|
10
|
+
export { pathParts } from './PathParts.logic.js';
|