@bigpixelrocket/uiok 0.2.3 → 0.3.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 +26 -1
- package/dist/charts/Sparkline.d.ts +20 -0
- package/dist/charts/Sparkline.js +12 -0
- package/dist/charts/Sparkline.logic.d.ts +9 -0
- package/dist/charts/Sparkline.logic.js +27 -0
- package/dist/charts/charts.css +17 -0
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +2 -0
- package/dist/dialog/ConfirmDialog.d.ts +11 -1
- package/dist/dialog/ConfirmDialog.js +3 -2
- package/dist/dialog/ModalDialog.d.ts +8 -0
- package/dist/dialog/ModalDialog.js +4 -2
- package/dist/dialog/ProgressDialog.d.ts +34 -0
- package/dist/dialog/ProgressDialog.js +40 -0
- package/dist/dialog/TypedNameDialog.d.ts +36 -0
- package/dist/dialog/TypedNameDialog.js +17 -0
- package/dist/dialog/index.d.ts +5 -2
- package/dist/dialog/index.js +4 -1
- package/dist/field/Switch.d.ts +26 -0
- package/dist/field/Switch.js +20 -0
- package/dist/field/index.d.ts +3 -2
- package/dist/field/index.js +3 -2
- package/dist/frame/AppRoot.d.ts +44 -0
- package/dist/frame/AppRoot.js +26 -0
- package/dist/frame/Dock.d.ts +88 -0
- package/dist/frame/Dock.js +129 -0
- package/dist/frame/FilterChips.d.ts +28 -0
- package/dist/frame/FilterChips.js +14 -0
- package/dist/frame/PageParts.d.ts +69 -0
- package/dist/frame/PageParts.js +60 -0
- package/dist/frame/PaneSplit.d.ts +74 -0
- package/dist/frame/PaneSplit.js +197 -0
- package/dist/frame/SidebarResizer.d.ts +35 -0
- package/dist/frame/SidebarResizer.js +43 -0
- package/dist/frame/StatusNotice.d.ts +20 -0
- package/dist/frame/StatusNotice.js +13 -0
- package/dist/frame/Tree.d.ts +140 -0
- package/dist/frame/Tree.js +141 -0
- package/dist/frame/TreeToggle.d.ts +18 -0
- package/dist/frame/TreeToggle.js +17 -0
- package/dist/frame/WindowFrame.d.ts +57 -0
- package/dist/frame/WindowFrame.js +19 -0
- package/dist/frame/frame.css +801 -0
- package/dist/frame/index.d.ts +22 -0
- package/dist/frame/index.js +22 -0
- package/dist/frame/sharedRef.d.ts +8 -0
- package/dist/frame/sharedRef.js +26 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/labels/UiokLabels.d.ts +3 -0
- package/dist/labels/UiokLabels.js +3 -1
- package/dist/labels/dialog.d.ts +12 -0
- package/dist/labels/dialog.js +7 -1
- package/dist/labels/index.d.ts +1 -0
- package/dist/labels/index.js +1 -0
- package/dist/labels/settings.d.ts +46 -0
- package/dist/labels/settings.js +29 -0
- package/dist/listing/EmptyState.d.ts +40 -0
- package/dist/listing/EmptyState.js +14 -0
- package/dist/listing/index.d.ts +3 -1
- package/dist/listing/index.js +3 -1
- package/dist/listing/listing.css +66 -2
- package/dist/log/LogWell.d.ts +34 -0
- package/dist/log/LogWell.js +39 -0
- package/dist/log/LogWell.logic.d.ts +16 -0
- package/dist/log/LogWell.logic.js +26 -0
- package/dist/log/index.d.ts +8 -0
- package/dist/log/index.js +8 -0
- package/dist/log/log.css +57 -0
- package/dist/pane/Pane.d.ts +49 -0
- package/dist/pane/Pane.js +17 -0
- package/dist/pane/PaneKeys.d.ts +10 -3
- package/dist/pane/PaneKeys.js +26 -7
- package/dist/pane/index.d.ts +4 -2
- package/dist/pane/index.js +4 -2
- package/dist/pane/usePaneKeys.js +9 -11
- package/dist/shell/AboutWindow.d.ts +21 -0
- package/dist/shell/AboutWindow.js +10 -0
- package/dist/shell/LanguageChoice.d.ts +27 -0
- package/dist/shell/LanguageChoice.js +17 -0
- package/dist/shell/LoadFailure.d.ts +22 -0
- package/dist/shell/LoadFailure.js +15 -0
- package/dist/shell/Lockup.d.ts +52 -0
- package/dist/shell/Lockup.js +30 -0
- package/dist/shell/SettingsDialog.d.ts +97 -0
- package/dist/shell/SettingsDialog.js +219 -0
- package/dist/shell/SettingsDialog.logic.d.ts +33 -0
- package/dist/shell/SettingsDialog.logic.js +42 -0
- package/dist/shell/SettingsFiles.d.ts +55 -0
- package/dist/shell/SettingsFiles.js +30 -0
- package/dist/shell/SettingsPageKeys.d.ts +42 -0
- package/dist/shell/SettingsPageKeys.js +70 -0
- package/dist/shell/SettingsSubsection.d.ts +34 -0
- package/dist/shell/SettingsSubsection.js +30 -0
- package/dist/shell/SignIn.d.ts +61 -0
- package/dist/shell/SignIn.js +36 -0
- package/dist/shell/ThemePicker.d.ts +74 -0
- package/dist/shell/ThemePicker.js +96 -0
- package/dist/shell/ThemePicker.logic.d.ts +13 -0
- package/dist/shell/ThemePicker.logic.js +26 -0
- package/dist/shell/TitleBar.d.ts +44 -0
- package/dist/shell/TitleBar.js +23 -0
- package/dist/shell/UpdatePill.d.ts +26 -0
- package/dist/shell/UpdatePill.js +17 -0
- package/dist/shell/Updates.d.ts +99 -0
- package/dist/shell/Updates.js +72 -0
- package/dist/shell/index.d.ts +27 -0
- package/dist/shell/index.js +27 -0
- package/dist/shell/shell.css +243 -4
- package/dist/styles.css +2 -0
- package/dist/themes/catalog.js +4 -0
- package/dist/themes/themes.generated.css +244 -0
- package/dist/themes/tokens.d.ts +17 -5
- package/dist/themes/tokens.js +64 -1
- package/dist/tokens.css +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/** Props for {@link SidebarResizer}. */
|
|
3
|
+
export interface SidebarResizerProps {
|
|
4
|
+
/** The sidebar's width now, in pixels. */
|
|
5
|
+
readonly width: number;
|
|
6
|
+
/** The narrowest the drag makes it. */
|
|
7
|
+
readonly min: number;
|
|
8
|
+
/** The widest the drag makes it, whatever the room. */
|
|
9
|
+
readonly max: number;
|
|
10
|
+
/** The least the page beside it keeps; the drag stops there. */
|
|
11
|
+
readonly pageMin: number;
|
|
12
|
+
/** The separator's accessible name ("Resize the sidebar"). */
|
|
13
|
+
readonly label: string;
|
|
14
|
+
/** Hears each width the drag reaches. */
|
|
15
|
+
readonly onResize: (width: number) => void;
|
|
16
|
+
/** Hears the width the drag ends on, to keep. */
|
|
17
|
+
readonly onResizeEnd: (width: number) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The width a drag of the sidebar's edge gives: the start width moved by
|
|
21
|
+
* the pointer, kept between `min` and the widest the room allows (`max`,
|
|
22
|
+
* and the room less `pageMin`; `max` alone before the room is laid out),
|
|
23
|
+
* in whole pixels.
|
|
24
|
+
*/
|
|
25
|
+
export declare function draggedWidth(start: number, moved: number, room: number, bounds: {
|
|
26
|
+
readonly min: number;
|
|
27
|
+
readonly max: number;
|
|
28
|
+
readonly pageMin: number;
|
|
29
|
+
}): number;
|
|
30
|
+
/**
|
|
31
|
+
* The sidebar's edge (`window-frame-resizer`), in the gap beside the page:
|
|
32
|
+
* the pointer drags it, the width following the pointer and kept on
|
|
33
|
+
* release. It measures the room from the window frame it stands in.
|
|
34
|
+
*/
|
|
35
|
+
export declare function SidebarResizer({ width, min, max, pageMin, label, onResize, onResizeEnd }: SidebarResizerProps): ReactElement;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* The width a drag of the sidebar's edge gives: the start width moved by
|
|
4
|
+
* the pointer, kept between `min` and the widest the room allows (`max`,
|
|
5
|
+
* and the room less `pageMin`; `max` alone before the room is laid out),
|
|
6
|
+
* in whole pixels.
|
|
7
|
+
*/
|
|
8
|
+
export function draggedWidth(start, moved, room, bounds) {
|
|
9
|
+
const widest = room > 0 ? Math.min(bounds.max, Math.max(bounds.min, room - bounds.pageMin)) : bounds.max;
|
|
10
|
+
return Math.round(Math.min(widest, Math.max(bounds.min, start + moved)));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The sidebar's edge (`window-frame-resizer`), in the gap beside the page:
|
|
14
|
+
* the pointer drags it, the width following the pointer and kept on
|
|
15
|
+
* release. It measures the room from the window frame it stands in.
|
|
16
|
+
*/
|
|
17
|
+
export function SidebarResizer({ width, min, max, pageMin, label, onResize, onResizeEnd }) {
|
|
18
|
+
const start = (event) => {
|
|
19
|
+
if (event.button !== 0)
|
|
20
|
+
return;
|
|
21
|
+
event.preventDefault();
|
|
22
|
+
const handle = event.currentTarget;
|
|
23
|
+
const frame = handle.closest('.window-frame, .space-root') ?? handle.parentElement;
|
|
24
|
+
const room = frame?.getBoundingClientRect().width ?? 0;
|
|
25
|
+
const startX = event.clientX;
|
|
26
|
+
let last = width;
|
|
27
|
+
handle.setPointerCapture?.(event.pointerId);
|
|
28
|
+
const move = (next) => {
|
|
29
|
+
last = draggedWidth(width, next.clientX - startX, room, { min, max, pageMin });
|
|
30
|
+
onResize(last);
|
|
31
|
+
};
|
|
32
|
+
const end = () => {
|
|
33
|
+
handle.removeEventListener('pointermove', move);
|
|
34
|
+
handle.removeEventListener('pointerup', end);
|
|
35
|
+
handle.removeEventListener('pointercancel', end);
|
|
36
|
+
onResizeEnd(last);
|
|
37
|
+
};
|
|
38
|
+
handle.addEventListener('pointermove', move);
|
|
39
|
+
handle.addEventListener('pointerup', end);
|
|
40
|
+
handle.addEventListener('pointercancel', end);
|
|
41
|
+
};
|
|
42
|
+
return (_jsx("div", { "aria-label": label, "aria-orientation": "vertical", "aria-valuemax": max, "aria-valuemin": min, "aria-valuenow": width, className: "window-frame-resizer", onPointerDown: start, role: "separator" }));
|
|
43
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
/** A status notice's tone: plain news, a failure, or an outcome that went well. */
|
|
4
|
+
export type StatusNoticeTone = 'info' | 'danger' | 'success';
|
|
5
|
+
/** Props for {@link StatusNotice}. */
|
|
6
|
+
export interface StatusNoticeProps {
|
|
7
|
+
readonly tone?: StatusNoticeTone;
|
|
8
|
+
/** The tone's glyph. */
|
|
9
|
+
readonly icon: LucideIcon;
|
|
10
|
+
/** The message, on one line, cut with an ellipsis and whole in its tooltip. */
|
|
11
|
+
readonly text: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* A message about the window (an outcome, a step the host refused) as a
|
|
15
|
+
* pane's status line while it stands, in place of the line's own words
|
|
16
|
+
* (`PaneStatus`'s children): the tone's glyph and the words in the text
|
|
17
|
+
* colour on one line, a failure announced as an alert and anything else as
|
|
18
|
+
* a status. Its verbs (Show, Close) go in the status line's tools.
|
|
19
|
+
*/
|
|
20
|
+
export declare function StatusNotice({ tone, icon: Icon, text }: StatusNoticeProps): ReactElement;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ICON_SM } from '../icon/sizes.js';
|
|
3
|
+
import { cutTooltip } from '../tooltip/Tooltip.logic.js';
|
|
4
|
+
/**
|
|
5
|
+
* A message about the window (an outcome, a step the host refused) as a
|
|
6
|
+
* pane's status line while it stands, in place of the line's own words
|
|
7
|
+
* (`PaneStatus`'s children): the tone's glyph and the words in the text
|
|
8
|
+
* colour on one line, a failure announced as an alert and anything else as
|
|
9
|
+
* a status. Its verbs (Show, Close) go in the status line's tools.
|
|
10
|
+
*/
|
|
11
|
+
export function StatusNotice({ tone = 'info', icon: Icon, text }) {
|
|
12
|
+
return (_jsxs("span", { className: tone === 'info' ? 'status-notice' : `status-notice ${tone}`, role: tone === 'danger' ? 'alert' : 'status', children: [_jsx(Icon, { "aria-hidden": true, size: ICON_SM }), _jsx("span", { className: "status-notice-text", ...cutTooltip(text), children: text })] }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
import { type KeyboardEvent, type ReactElement, type ReactNode, type Ref } from 'react';
|
|
3
|
+
import type { RegionHandlers } from '../pane/Pane.js';
|
|
4
|
+
/** Props for {@link TreePane}. */
|
|
5
|
+
export interface TreePaneProps extends RegionHandlers {
|
|
6
|
+
/** The width the host keeps, in pixels; none takes `--sidebar-width` (240px). */
|
|
7
|
+
readonly width?: number;
|
|
8
|
+
/** The pane holds the keyboard: its frame wears the accent. */
|
|
9
|
+
readonly active?: boolean;
|
|
10
|
+
readonly label?: string;
|
|
11
|
+
readonly ref?: Ref<HTMLElement>;
|
|
12
|
+
/** Its path bar, quick row (`FilterChips`), `TreeList`, and status line. */
|
|
13
|
+
readonly children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* The sidebar's pane, which holds a tree: a pane at the sidebar's width
|
|
17
|
+
* whose rows lay out as the chevron's slot, the node's glyph, its name, and
|
|
18
|
+
* one trailing column. Narrower than its title and its tools side by side,
|
|
19
|
+
* its path bar takes a line for each.
|
|
20
|
+
*/
|
|
21
|
+
export declare function TreePane({ width, active, label, ref, children, ...handlers }: TreePaneProps): ReactElement;
|
|
22
|
+
/** Props for {@link TreeList}. */
|
|
23
|
+
export interface TreeListProps extends RegionHandlers {
|
|
24
|
+
/** The tree's accessible name ("Services"). */
|
|
25
|
+
readonly label: string;
|
|
26
|
+
readonly ref?: Ref<HTMLDivElement>;
|
|
27
|
+
/** Its `TreeRow`s and `TreeTool`s, in order. */
|
|
28
|
+
readonly children: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The tree's rows in the sidebar's scrolling list: the sidebar's home
|
|
32
|
+
* (`data-pane-home="sidebar"`), which `usePaneKeys` hands the focus and
|
|
33
|
+
* finds the sidebar pane by, focusable by script and out of the Tab order.
|
|
34
|
+
* Each row steps in by its level. While the list holds the focus, its
|
|
35
|
+
* active descendant is the cursor row, so a screen reader follows the
|
|
36
|
+
* cursor the keys move.
|
|
37
|
+
*/
|
|
38
|
+
export declare function TreeList({ label, ref, children, ...handlers }: TreeListProps): ReactElement;
|
|
39
|
+
/**
|
|
40
|
+
* What a tree row is: a node, a band that heads the rows under it (a
|
|
41
|
+
* server, a project) on the strip's ground with a hairline under it, or a
|
|
42
|
+
* group whose name reads as a heading over its rows.
|
|
43
|
+
*/
|
|
44
|
+
export type TreeRowKind = 'node' | 'band' | 'group';
|
|
45
|
+
/** A tree row's disclosure: whether its children show, how to toggle them, and the chevron's name. */
|
|
46
|
+
export interface TreeRowToggle {
|
|
47
|
+
readonly open: boolean;
|
|
48
|
+
readonly onToggle: () => void;
|
|
49
|
+
/** The chevron's accessible name ("Expand shop", "Collapse shop"). */
|
|
50
|
+
readonly label: string;
|
|
51
|
+
}
|
|
52
|
+
/** Props for {@link TreeRow}. */
|
|
53
|
+
export interface TreeRowProps {
|
|
54
|
+
/** Names the row to the pane's cursor (`data-row-key`); unique in its pane. */
|
|
55
|
+
readonly rowKey: string;
|
|
56
|
+
/** How deep it stands: 0 at the tree's root. */
|
|
57
|
+
readonly level?: number;
|
|
58
|
+
readonly kind?: TreeRowKind;
|
|
59
|
+
/** A row with children: its chevron; none leaves the chevron's slot empty. */
|
|
60
|
+
readonly toggle?: TreeRowToggle;
|
|
61
|
+
/** The node's glyph, in the quiet tone. */
|
|
62
|
+
readonly glyph?: ReactNode;
|
|
63
|
+
readonly name: ReactNode;
|
|
64
|
+
/** Quieter words after the name ("×3"). */
|
|
65
|
+
readonly detail?: ReactNode;
|
|
66
|
+
/** The trailing column: a count, a port, a state (`StateMark`). */
|
|
67
|
+
readonly trailing?: ReactNode;
|
|
68
|
+
/** The row's own tool (Hide), shown on the cursor row only. */
|
|
69
|
+
readonly tool?: ReactNode;
|
|
70
|
+
/** Marked as chosen though it is not the cursor row (the page the main pane shows). */
|
|
71
|
+
readonly marked?: boolean;
|
|
72
|
+
/** Opens the row's item on a click anywhere but its controls. */
|
|
73
|
+
readonly onOpen?: () => void;
|
|
74
|
+
/** The row itself takes the focus: in the Tab order while it is the cursor row. */
|
|
75
|
+
readonly focusable?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* One row of a sidebar's tree: the chevron's slot, the glyph, the name (cut
|
|
79
|
+
* with an ellipsis, whole in its tooltip) with its quieter detail, then its
|
|
80
|
+
* trailing column and its own tool. Like a listing's `Row`, it follows the
|
|
81
|
+
* pane's cursor (`RowCursorContext`), wearing the cursor row's look and
|
|
82
|
+
* `aria-current`; the pointer moving over it or the focus entering it moves
|
|
83
|
+
* the cursor there. Its controls leave the Tab order, since the tree's keys
|
|
84
|
+
* run them. The expansion and its keys stay the host's.
|
|
85
|
+
*/
|
|
86
|
+
export declare function TreeRow({ rowKey, level, kind, toggle, glyph, name, detail, trailing, tool, marked, onOpen, focusable }: TreeRowProps): ReactElement;
|
|
87
|
+
/**
|
|
88
|
+
* What a tree's tool row is: a plain tool (a filter field, a pager, an Add
|
|
89
|
+
* action), a note under a node (past the chevron's slot), a heading over a
|
|
90
|
+
* group further down, or a read that failed (its reason wraps, its action
|
|
91
|
+
* under it).
|
|
92
|
+
*/
|
|
93
|
+
export type TreeToolKind = 'tool' | 'note' | 'heading' | 'danger';
|
|
94
|
+
/** Props for {@link TreeTool}. */
|
|
95
|
+
export interface TreeToolProps {
|
|
96
|
+
readonly kind?: TreeToolKind;
|
|
97
|
+
/** How deep it stands, as the rows around it. */
|
|
98
|
+
readonly level?: number;
|
|
99
|
+
/** Its glyph, before the words. */
|
|
100
|
+
readonly icon?: LucideIcon;
|
|
101
|
+
/** Its words. */
|
|
102
|
+
readonly text?: ReactNode;
|
|
103
|
+
/** The pane's cursor stands on it. */
|
|
104
|
+
readonly cursor?: boolean;
|
|
105
|
+
/** Its control after the words: a `TreeFilterInput`, a pager, an action. */
|
|
106
|
+
readonly children?: ReactNode;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A row of a tree that is not a node, at its level's indent in the small
|
|
110
|
+
* size: a filter field, a pager, a note, a heading, or a failed read with
|
|
111
|
+
* its action.
|
|
112
|
+
*/
|
|
113
|
+
export declare function TreeTool({ kind, level, icon: Icon, text, cursor, children }: TreeToolProps): ReactElement;
|
|
114
|
+
/** Props for {@link TreeFilterInput}. */
|
|
115
|
+
export interface TreeFilterInputProps {
|
|
116
|
+
readonly value: string;
|
|
117
|
+
/** Hears each edit. */
|
|
118
|
+
readonly onChange: (value: string) => void;
|
|
119
|
+
/** Its accessible name ("Filter services"). */
|
|
120
|
+
readonly label: string;
|
|
121
|
+
readonly placeholder?: string;
|
|
122
|
+
/** The host's keys while it holds the keyboard (Escape clears, ↓ goes to the rows). */
|
|
123
|
+
readonly onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
124
|
+
readonly ref?: Ref<HTMLInputElement>;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A tree's filter field: a bare field that fills its `TreeTool` row, the
|
|
128
|
+
* row underlined in the accent while the field holds the keyboard.
|
|
129
|
+
*/
|
|
130
|
+
export declare function TreeFilterInput({ value, onChange, label, placeholder, onKeyDown, ref }: TreeFilterInputProps): ReactElement;
|
|
131
|
+
/** Props for {@link SidebarEmpty}. */
|
|
132
|
+
export interface SidebarEmptyProps {
|
|
133
|
+
/** What it says ("No services yet."). */
|
|
134
|
+
readonly children: ReactNode;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* A sidebar with nothing to list, saying so as a quiet row in the rows'
|
|
138
|
+
* place: from where a row's icon starts, dim, one row high.
|
|
139
|
+
*/
|
|
140
|
+
export declare function SidebarEmpty({ children }: SidebarEmptyProps): ReactElement;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useId, useLayoutEffect, useMemo, useRef, useSyncExternalStore } from 'react';
|
|
3
|
+
import { ICON_MD } from '../icon/sizes.js';
|
|
4
|
+
import { RowCursorContext } from '../listing/Listing.js';
|
|
5
|
+
import { InListingRowContext, InRowContext } from '../pane/PaneActions.js';
|
|
6
|
+
import { cutTooltip } from '../tooltip/Tooltip.logic.js';
|
|
7
|
+
import { useSharedRef } from './sharedRef.js';
|
|
8
|
+
import { TreeToggle } from './TreeToggle.js';
|
|
9
|
+
const TreeIdContext = createContext(null);
|
|
10
|
+
/** A row's element id in its tree: the tree's prefix and the row's key, made safe for an id. */
|
|
11
|
+
const rowId = (tree, rowKey) => `${tree}-${encodeURIComponent(rowKey)}`;
|
|
12
|
+
const levelStyle = (level) => level > 0 ? { '--tree-level': level } : undefined;
|
|
13
|
+
/**
|
|
14
|
+
* The sidebar's pane, which holds a tree: a pane at the sidebar's width
|
|
15
|
+
* whose rows lay out as the chevron's slot, the node's glyph, its name, and
|
|
16
|
+
* one trailing column. Narrower than its title and its tools side by side,
|
|
17
|
+
* its path bar takes a line for each.
|
|
18
|
+
*/
|
|
19
|
+
export function TreePane({ width, active = false, label, ref, children, ...handlers }) {
|
|
20
|
+
return (_jsx("aside", { "aria-label": label, className: active ? 'pane tree-pane active' : 'pane tree-pane', ref: ref, style: width === undefined ? undefined : { width }, ...handlers, children: children }));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The tree's rows in the sidebar's scrolling list: the sidebar's home
|
|
24
|
+
* (`data-pane-home="sidebar"`), which `usePaneKeys` hands the focus and
|
|
25
|
+
* finds the sidebar pane by, focusable by script and out of the Tab order.
|
|
26
|
+
* Each row steps in by its level. While the list holds the focus, its
|
|
27
|
+
* active descendant is the cursor row, so a screen reader follows the
|
|
28
|
+
* cursor the keys move.
|
|
29
|
+
*/
|
|
30
|
+
export function TreeList({ label, ref, children, ...handlers }) {
|
|
31
|
+
const tree = useId();
|
|
32
|
+
const cursor = useContext(RowCursorContext);
|
|
33
|
+
const [list, attach] = useSharedRef(ref);
|
|
34
|
+
// Names the cursor row only while it is drawn here: a row a filter took
|
|
35
|
+
// away, or a cursor on another pane's row, leaves no active descendant
|
|
36
|
+
// pointing at nothing.
|
|
37
|
+
const sync = useCallback(() => {
|
|
38
|
+
const element = list.current;
|
|
39
|
+
if (element === null)
|
|
40
|
+
return;
|
|
41
|
+
const key = cursor.current();
|
|
42
|
+
const id = key === null ? null : rowId(tree, key);
|
|
43
|
+
// One lookup by id (the tree's prefix makes it unique in the document),
|
|
44
|
+
// never a scan of the rows.
|
|
45
|
+
const row = id === null ? null : element.ownerDocument.getElementById(id);
|
|
46
|
+
const drawnRow = row !== null && element.contains(row);
|
|
47
|
+
if (drawnRow && id !== null)
|
|
48
|
+
element.setAttribute('aria-activedescendant', id);
|
|
49
|
+
else
|
|
50
|
+
element.removeAttribute('aria-activedescendant');
|
|
51
|
+
}, [cursor, list, tree]);
|
|
52
|
+
// After every render and on every cursor move; and once a commit has put
|
|
53
|
+
// rows in or taken them out, by whatever state drew them: one microtask
|
|
54
|
+
// per commit, however many rows came or went, calling the latest sync.
|
|
55
|
+
const latestSync = useRef(sync);
|
|
56
|
+
const pending = useRef(false);
|
|
57
|
+
useLayoutEffect(() => {
|
|
58
|
+
latestSync.current = sync;
|
|
59
|
+
sync();
|
|
60
|
+
return cursor.subscribe(sync);
|
|
61
|
+
});
|
|
62
|
+
const scope = useMemo(() => ({
|
|
63
|
+
id: tree,
|
|
64
|
+
rowsChanged: () => {
|
|
65
|
+
if (pending.current)
|
|
66
|
+
return;
|
|
67
|
+
pending.current = true;
|
|
68
|
+
queueMicrotask(() => {
|
|
69
|
+
pending.current = false;
|
|
70
|
+
latestSync.current();
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}), [tree]);
|
|
74
|
+
return (_jsx("div", { "aria-label": label, className: "pane-list tree", "data-pane-home": "sidebar", ref: attach, role: "tree", tabIndex: -1, ...handlers, children: _jsx(TreeIdContext.Provider, { value: scope, children: children }) }));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* One row of a sidebar's tree: the chevron's slot, the glyph, the name (cut
|
|
78
|
+
* with an ellipsis, whole in its tooltip) with its quieter detail, then its
|
|
79
|
+
* trailing column and its own tool. Like a listing's `Row`, it follows the
|
|
80
|
+
* pane's cursor (`RowCursorContext`), wearing the cursor row's look and
|
|
81
|
+
* `aria-current`; the pointer moving over it or the focus entering it moves
|
|
82
|
+
* the cursor there. Its controls leave the Tab order, since the tree's keys
|
|
83
|
+
* run them. The expansion and its keys stay the host's.
|
|
84
|
+
*/
|
|
85
|
+
export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name, detail, trailing, tool, marked = false, onOpen, focusable = false }) {
|
|
86
|
+
const cursor = useContext(RowCursorContext);
|
|
87
|
+
const tree = useContext(TreeIdContext);
|
|
88
|
+
const current = useSyncExternalStore(cursor.subscribe, () => cursor.current() === rowKey);
|
|
89
|
+
useLayoutEffect(() => {
|
|
90
|
+
cursor.rowsChanged?.();
|
|
91
|
+
tree?.rowsChanged();
|
|
92
|
+
return () => {
|
|
93
|
+
cursor.rowsChanged?.();
|
|
94
|
+
tree?.rowsChanged();
|
|
95
|
+
};
|
|
96
|
+
}, [cursor, rowKey, tree]);
|
|
97
|
+
const classes = [
|
|
98
|
+
'row',
|
|
99
|
+
kind === 'band' ? 'tree-band' : '',
|
|
100
|
+
kind === 'group' ? 'tree-group' : '',
|
|
101
|
+
current ? 'cursor' : '',
|
|
102
|
+
marked ? 'marked' : ''
|
|
103
|
+
]
|
|
104
|
+
.filter(Boolean)
|
|
105
|
+
.join(' ');
|
|
106
|
+
return (_jsx(InListingRowContext.Provider, { value: true, children: _jsx(InRowContext.Provider, { value: true, children: _jsxs("div", { "aria-current": current ? 'true' : undefined, "aria-expanded": toggle === undefined ? undefined : toggle.open, "aria-level": level + 1, "aria-selected": marked, className: classes, "data-row-key": rowKey, id: tree === null ? undefined : rowId(tree.id, rowKey), onClick: onOpen, onFocus: () => cursor.point(rowKey), onPointerMove: () => {
|
|
107
|
+
if (!current)
|
|
108
|
+
cursor.point(rowKey);
|
|
109
|
+
}, role: "treeitem", style: levelStyle(level), tabIndex: focusable ? (current ? 0 : -1) : undefined, children: [toggle === undefined ? (_jsx("span", { "aria-hidden": true, className: "row-icon" })) : (_jsx(TreeToggle, { label: toggle.label, onToggle: toggle.onToggle, open: toggle.open })), _jsx("span", { "aria-hidden": true, className: "tree-glyph", children: glyph }), _jsxs("span", { className: "row-name tree-name", ...(typeof name === 'string' && detail === undefined ? cutTooltip(name) : {}), children: [name, detail === undefined ? null : (_jsxs(_Fragment, { children: [' ', _jsx("span", { className: "tree-detail", children: detail })] }))] }), _jsxs("span", { className: "row-meta align-right", children: [trailing, tool === undefined ? null : _jsx("span", { className: "tree-row-tool", children: tool })] })] }) }) }));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A row of a tree that is not a node, at its level's indent in the small
|
|
113
|
+
* size: a filter field, a pager, a note, a heading, or a failed read with
|
|
114
|
+
* its action.
|
|
115
|
+
*/
|
|
116
|
+
export function TreeTool({ kind = 'tool', level = 0, icon: Icon, text, cursor = false, children }) {
|
|
117
|
+
const classes = [
|
|
118
|
+
'tree-tool',
|
|
119
|
+
kind === 'note' ? 'tree-note' : '',
|
|
120
|
+
kind === 'heading' ? 'tree-heading' : '',
|
|
121
|
+
kind === 'danger' ? 'danger' : '',
|
|
122
|
+
cursor ? 'cursor' : ''
|
|
123
|
+
]
|
|
124
|
+
.filter(Boolean)
|
|
125
|
+
.join(' ');
|
|
126
|
+
return (_jsxs("div", { className: classes, role: kind === 'danger' ? 'alert' : undefined, style: levelStyle(level), children: [Icon === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "tree-note-glyph", children: _jsx(Icon, { size: ICON_MD }) })), text === undefined ? null : _jsx("span", { className: "tree-note-text", children: text }), children] }));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A tree's filter field: a bare field that fills its `TreeTool` row, the
|
|
130
|
+
* row underlined in the accent while the field holds the keyboard.
|
|
131
|
+
*/
|
|
132
|
+
export function TreeFilterInput({ value, onChange, label, placeholder, onKeyDown, ref }) {
|
|
133
|
+
return (_jsx("input", { "aria-label": label, className: "tree-filter-input", onChange: (event) => onChange(event.currentTarget.value), onKeyDown: onKeyDown, placeholder: placeholder, ref: ref, spellCheck: false, type: "text", value: value }));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* A sidebar with nothing to list, saying so as a quiet row in the rows'
|
|
137
|
+
* place: from where a row's icon starts, dim, one row high.
|
|
138
|
+
*/
|
|
139
|
+
export function SidebarEmpty({ children }) {
|
|
140
|
+
return _jsx("p", { className: "space-nav-empty", children: children });
|
|
141
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactElement } from 'react';
|
|
2
|
+
/** Props for {@link TreeToggle}. */
|
|
3
|
+
export interface TreeToggleProps {
|
|
4
|
+
/** Whether the row's children show. */
|
|
5
|
+
readonly open: boolean;
|
|
6
|
+
/** Opens or closes the row's children. */
|
|
7
|
+
readonly onToggle: () => void;
|
|
8
|
+
/** The button's accessible name ("Expand shop", "Collapse shop"). */
|
|
9
|
+
readonly label: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A tree row's disclosure chevron, in the row's first column (`tree-chev`):
|
|
13
|
+
* right while closed, down while open. A press toggles the row's children
|
|
14
|
+
* and never opens the row itself; it leaves the focus where it was, as a
|
|
15
|
+
* row's click does, and stays out of the Tab order, since the tree's keys
|
|
16
|
+
* open and close a row.
|
|
17
|
+
*/
|
|
18
|
+
export declare function TreeToggle({ open, onToggle, label }: TreeToggleProps): ReactElement;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown, ChevronRight } from 'lucide-react';
|
|
3
|
+
import { ICON_MD } from '../icon/sizes.js';
|
|
4
|
+
/**
|
|
5
|
+
* A tree row's disclosure chevron, in the row's first column (`tree-chev`):
|
|
6
|
+
* right while closed, down while open. A press toggles the row's children
|
|
7
|
+
* and never opens the row itself; it leaves the focus where it was, as a
|
|
8
|
+
* row's click does, and stays out of the Tab order, since the tree's keys
|
|
9
|
+
* open and close a row.
|
|
10
|
+
*/
|
|
11
|
+
export function TreeToggle({ open, onToggle, label }) {
|
|
12
|
+
const Icon = open ? ChevronDown : ChevronRight;
|
|
13
|
+
return (_jsx("button", { "aria-expanded": open, "aria-label": label, className: "tree-chev row-icon", onClick: (event) => {
|
|
14
|
+
event.stopPropagation();
|
|
15
|
+
onToggle();
|
|
16
|
+
}, onMouseDown: (event) => event.preventDefault(), tabIndex: -1, type: "button", children: _jsx(Icon, { "aria-hidden": true, size: ICON_MD }) }));
|
|
17
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode, Ref } from 'react';
|
|
2
|
+
import type { RegionHandlers } from '../pane/Pane.js';
|
|
3
|
+
/** Whether a slot was given something to draw: idiomatic `cond && <Part />` passes false for none. */
|
|
4
|
+
export declare const drawn: (node: ReactNode) => boolean;
|
|
5
|
+
/**
|
|
6
|
+
* The one element a host keeps its sidebar and main pane in (for its keys
|
|
7
|
+
* or its drop zone): its handlers and ref. It draws no box, so the parts
|
|
8
|
+
* inside it keep their places in the frame's grid.
|
|
9
|
+
*/
|
|
10
|
+
export interface WindowFrameGroup extends RegionHandlers {
|
|
11
|
+
readonly ref?: Ref<HTMLDivElement>;
|
|
12
|
+
}
|
|
13
|
+
/** Props for {@link WindowFrame}. */
|
|
14
|
+
export interface WindowFrameProps {
|
|
15
|
+
/** The title bar at the band's leading end (`TitleBar`), as wide as the sidebar. */
|
|
16
|
+
readonly brand: ReactNode;
|
|
17
|
+
/** The sidebar's pane (a `tree-pane`); none hides it, and the main pane takes the window's width. */
|
|
18
|
+
readonly sidebar?: ReactNode;
|
|
19
|
+
/** The sidebar's edge (`SidebarResizer`), beside it while it shows. */
|
|
20
|
+
readonly resizer?: ReactNode;
|
|
21
|
+
/**
|
|
22
|
+
* The sidebar's width in pixels, which the title bar matches, and which it
|
|
23
|
+
* keeps while the sidebar is hidden so no tab moves.
|
|
24
|
+
*/
|
|
25
|
+
readonly sidebarWidth: number;
|
|
26
|
+
/** The main pane, whose tab row rises into the band beside the title bar. */
|
|
27
|
+
readonly main: ReactNode;
|
|
28
|
+
/** A strip that takes its turn under the main pane (files being imported). */
|
|
29
|
+
readonly tray?: ReactNode;
|
|
30
|
+
/** The dock under the main pane (a console, a log). */
|
|
31
|
+
readonly dock?: ReactNode;
|
|
32
|
+
/** The key legend across the window's foot (`KeyLegendStrip`). */
|
|
33
|
+
readonly legend?: ReactNode;
|
|
34
|
+
/**
|
|
35
|
+
* What stands at the band's trailing end, out of the drag region (the
|
|
36
|
+
* `UpdatePill`), for a window whose main pane has no tabs; a pane with
|
|
37
|
+
* tabs takes it as `PaneTabs`' `trailing` instead.
|
|
38
|
+
*/
|
|
39
|
+
readonly trailing?: ReactNode;
|
|
40
|
+
/**
|
|
41
|
+
* Gathers the sidebar, its edge, the main pane, the tray, and the dock in
|
|
42
|
+
* one element with these handlers; none leaves them the frame's own children.
|
|
43
|
+
*/
|
|
44
|
+
readonly group?: WindowFrameGroup;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The window's grid: the top band (the title bar at the sidebar's width,
|
|
48
|
+
* then the main pane's tabs), the sidebar and the main pane side by side on
|
|
49
|
+
* the ground, the tray and the dock under the main pane while they show,
|
|
50
|
+
* and the key legend across the foot. Each part fills its slot; the band's
|
|
51
|
+
* empty end is the window's drag region. Hiding the sidebar gives its room
|
|
52
|
+
* to the main pane, the tray, and the dock, and the main pane's tabs keep
|
|
53
|
+
* their place beside the title bar. The frame is the space's root, in the
|
|
54
|
+
* listing look: a column the panel's height that sizes every box by its
|
|
55
|
+
* border and resets its buttons, code, fieldsets, and legends.
|
|
56
|
+
*/
|
|
57
|
+
export declare function WindowFrame({ brand, sidebar, resizer, sidebarWidth, main, tray, dock, legend, trailing, group }: WindowFrameProps): ReactElement;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/** Whether a slot was given something to draw: idiomatic `cond && <Part />` passes false for none. */
|
|
3
|
+
export const drawn = (node) => node !== null && node !== undefined && node !== false && node !== '';
|
|
4
|
+
/**
|
|
5
|
+
* The window's grid: the top band (the title bar at the sidebar's width,
|
|
6
|
+
* then the main pane's tabs), the sidebar and the main pane side by side on
|
|
7
|
+
* the ground, the tray and the dock under the main pane while they show,
|
|
8
|
+
* and the key legend across the foot. Each part fills its slot; the band's
|
|
9
|
+
* empty end is the window's drag region. Hiding the sidebar gives its room
|
|
10
|
+
* to the main pane, the tray, and the dock, and the main pane's tabs keep
|
|
11
|
+
* their place beside the title bar. The frame is the space's root, in the
|
|
12
|
+
* listing look: a column the panel's height that sizes every box by its
|
|
13
|
+
* border and resets its buttons, code, fieldsets, and legends.
|
|
14
|
+
*/
|
|
15
|
+
export function WindowFrame({ brand, sidebar = null, resizer = null, sidebarWidth, main, tray = null, dock = null, legend = null, trailing = null, group }) {
|
|
16
|
+
const shown = drawn(sidebar);
|
|
17
|
+
const parts = (_jsxs(_Fragment, { children: [shown ? _jsx("div", { className: "window-frame-slot window-frame-sidebar", children: sidebar }) : null, shown ? resizer : null, _jsx("div", { className: "window-frame-slot window-frame-main", children: main }), drawn(tray) ? _jsx("div", { className: "window-frame-slot window-frame-tray", children: tray }) : null, drawn(dock) ? _jsx("div", { className: "window-frame-slot window-frame-dock", children: dock }) : null] }));
|
|
18
|
+
return (_jsxs("div", { className: "window-frame space-root listing-root", "data-sidebar": shown ? 'shown' : 'hidden', style: { '--window-band-width': `${sidebarWidth}px` }, children: [_jsxs("div", { className: "window-frame-band", children: [_jsx("div", { className: "window-frame-band-lead", children: brand }), _jsx("span", { "aria-hidden": true, className: "window-frame-band-rest" }), drawn(trailing) ? _jsx("div", { className: "shell-trailing", children: trailing }) : null] }), group === undefined ? (parts) : (_jsx("div", { className: "window-frame-group", ...group, children: parts })), drawn(legend) ? _jsx("div", { className: "window-frame-legend", children: legend }) : null] }));
|
|
19
|
+
}
|