@bigpixelrocket/uiok 0.2.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (215) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/dist/charts/Sparkline.d.ts +20 -0
  3. package/dist/charts/Sparkline.js +12 -0
  4. package/dist/charts/Sparkline.logic.d.ts +9 -0
  5. package/dist/charts/Sparkline.logic.js +27 -0
  6. package/dist/charts/charts.css +17 -0
  7. package/dist/charts/index.d.ts +2 -0
  8. package/dist/charts/index.js +2 -0
  9. package/dist/dialog/ConfirmDialog.d.ts +17 -1
  10. package/dist/dialog/ConfirmDialog.js +4 -3
  11. package/dist/dialog/ModalDialog.d.ts +8 -0
  12. package/dist/dialog/ModalDialog.js +4 -2
  13. package/dist/dialog/ProgressDialog.d.ts +40 -0
  14. package/dist/dialog/ProgressDialog.js +40 -0
  15. package/dist/dialog/TypedNameDialog.d.ts +44 -0
  16. package/dist/dialog/TypedNameDialog.js +17 -0
  17. package/dist/dialog/index.d.ts +5 -2
  18. package/dist/dialog/index.js +4 -1
  19. package/dist/field/Check.d.ts +9 -2
  20. package/dist/field/Check.js +5 -4
  21. package/dist/field/Controls.d.ts +198 -0
  22. package/dist/field/Controls.js +94 -0
  23. package/dist/field/FieldLayout.d.ts +126 -0
  24. package/dist/field/FieldLayout.js +89 -0
  25. package/dist/field/Switch.d.ts +26 -0
  26. package/dist/field/Switch.js +20 -0
  27. package/dist/field/index.d.ts +10 -6
  28. package/dist/field/index.js +10 -6
  29. package/dist/frame/AppRoot.d.ts +44 -0
  30. package/dist/frame/AppRoot.js +26 -0
  31. package/dist/frame/Dock.d.ts +88 -0
  32. package/dist/frame/Dock.js +129 -0
  33. package/dist/frame/FilterChips.d.ts +28 -0
  34. package/dist/frame/FilterChips.js +14 -0
  35. package/dist/frame/PageParts.d.ts +69 -0
  36. package/dist/frame/PageParts.js +60 -0
  37. package/dist/frame/PaneSplit.d.ts +74 -0
  38. package/dist/frame/PaneSplit.js +197 -0
  39. package/dist/frame/SidebarResizer.d.ts +35 -0
  40. package/dist/frame/SidebarResizer.js +43 -0
  41. package/dist/frame/StatusNotice.d.ts +20 -0
  42. package/dist/frame/StatusNotice.js +13 -0
  43. package/dist/frame/Tree.d.ts +147 -0
  44. package/dist/frame/Tree.js +164 -0
  45. package/dist/frame/TreeToggle.d.ts +18 -0
  46. package/dist/frame/TreeToggle.js +17 -0
  47. package/dist/frame/WindowFrame.d.ts +57 -0
  48. package/dist/frame/WindowFrame.js +19 -0
  49. package/dist/frame/frame.css +801 -0
  50. package/dist/frame/index.d.ts +22 -0
  51. package/dist/frame/index.js +22 -0
  52. package/dist/frame/sharedRef.d.ts +8 -0
  53. package/dist/frame/sharedRef.js +26 -0
  54. package/dist/index.d.ts +3 -0
  55. package/dist/index.js +3 -0
  56. package/dist/labels/UiokLabels.d.ts +6 -0
  57. package/dist/labels/UiokLabels.js +5 -1
  58. package/dist/labels/dialog.d.ts +12 -0
  59. package/dist/labels/dialog.js +7 -1
  60. package/dist/labels/index.d.ts +2 -0
  61. package/dist/labels/index.js +2 -0
  62. package/dist/labels/settings.d.ts +46 -0
  63. package/dist/labels/settings.js +29 -0
  64. package/dist/labels/viewer.d.ts +193 -0
  65. package/dist/labels/viewer.js +124 -0
  66. package/dist/listing/EmptyState.d.ts +40 -0
  67. package/dist/listing/EmptyState.js +14 -0
  68. package/dist/listing/PaneMessage.d.ts +28 -0
  69. package/dist/listing/PaneMessage.js +12 -0
  70. package/dist/listing/index.d.ts +5 -1
  71. package/dist/listing/index.js +5 -1
  72. package/dist/listing/listing.css +66 -2
  73. package/dist/log/LogWell.d.ts +34 -0
  74. package/dist/log/LogWell.js +39 -0
  75. package/dist/log/LogWell.logic.d.ts +16 -0
  76. package/dist/log/LogWell.logic.js +26 -0
  77. package/dist/log/index.d.ts +8 -0
  78. package/dist/log/index.js +8 -0
  79. package/dist/log/log.css +57 -0
  80. package/dist/pane/Pane.d.ts +49 -0
  81. package/dist/pane/Pane.js +17 -0
  82. package/dist/pane/PaneKeys.d.ts +10 -3
  83. package/dist/pane/PaneKeys.js +26 -7
  84. package/dist/pane/index.d.ts +4 -2
  85. package/dist/pane/index.js +4 -2
  86. package/dist/pane/usePaneKeys.js +9 -11
  87. package/dist/shell/AboutWindow.d.ts +21 -0
  88. package/dist/shell/AboutWindow.js +10 -0
  89. package/dist/shell/LanguageChoice.d.ts +27 -0
  90. package/dist/shell/LanguageChoice.js +17 -0
  91. package/dist/shell/LoadFailure.d.ts +22 -0
  92. package/dist/shell/LoadFailure.js +15 -0
  93. package/dist/shell/Lockup.d.ts +52 -0
  94. package/dist/shell/Lockup.js +30 -0
  95. package/dist/shell/SettingsDialog.d.ts +97 -0
  96. package/dist/shell/SettingsDialog.js +219 -0
  97. package/dist/shell/SettingsDialog.logic.d.ts +33 -0
  98. package/dist/shell/SettingsDialog.logic.js +42 -0
  99. package/dist/shell/SettingsFiles.d.ts +55 -0
  100. package/dist/shell/SettingsFiles.js +30 -0
  101. package/dist/shell/SettingsPageKeys.d.ts +42 -0
  102. package/dist/shell/SettingsPageKeys.js +70 -0
  103. package/dist/shell/SettingsSubsection.d.ts +34 -0
  104. package/dist/shell/SettingsSubsection.js +30 -0
  105. package/dist/shell/SignIn.d.ts +61 -0
  106. package/dist/shell/SignIn.js +36 -0
  107. package/dist/shell/ThemePicker.d.ts +74 -0
  108. package/dist/shell/ThemePicker.js +96 -0
  109. package/dist/shell/ThemePicker.logic.d.ts +13 -0
  110. package/dist/shell/ThemePicker.logic.js +26 -0
  111. package/dist/shell/TitleBar.d.ts +44 -0
  112. package/dist/shell/TitleBar.js +23 -0
  113. package/dist/shell/UpdatePill.d.ts +26 -0
  114. package/dist/shell/UpdatePill.js +17 -0
  115. package/dist/shell/Updates.d.ts +99 -0
  116. package/dist/shell/Updates.js +72 -0
  117. package/dist/shell/index.d.ts +27 -0
  118. package/dist/shell/index.js +27 -0
  119. package/dist/shell/shell.css +243 -4
  120. package/dist/styles.css +5 -0
  121. package/dist/surface/Card.d.ts +18 -0
  122. package/dist/surface/Card.js +10 -0
  123. package/dist/surface/Notice.d.ts +45 -0
  124. package/dist/surface/Notice.js +27 -0
  125. package/dist/surface/index.d.ts +5 -3
  126. package/dist/surface/index.js +5 -3
  127. package/dist/themes/catalog.js +4 -0
  128. package/dist/themes/themes.generated.css +245 -0
  129. package/dist/themes/tokens.d.ts +17 -5
  130. package/dist/themes/tokens.js +67 -1
  131. package/dist/tokens.css +11 -0
  132. package/dist/viewer/AudioView.d.ts +13 -0
  133. package/dist/viewer/AudioView.js +25 -0
  134. package/dist/viewer/HexJump.logic.d.ts +16 -0
  135. package/dist/viewer/HexJump.logic.js +27 -0
  136. package/dist/viewer/HexRows.logic.d.ts +55 -0
  137. package/dist/viewer/HexRows.logic.js +84 -0
  138. package/dist/viewer/HexSelection.logic.d.ts +57 -0
  139. package/dist/viewer/HexSelection.logic.js +68 -0
  140. package/dist/viewer/HexView.d.ts +10 -0
  141. package/dist/viewer/HexView.js +291 -0
  142. package/dist/viewer/HexViewport.logic.d.ts +61 -0
  143. package/dist/viewer/HexViewport.logic.js +79 -0
  144. package/dist/viewer/ImageView.d.ts +19 -0
  145. package/dist/viewer/ImageView.js +230 -0
  146. package/dist/viewer/ImageZoom.logic.d.ts +65 -0
  147. package/dist/viewer/ImageZoom.logic.js +119 -0
  148. package/dist/viewer/LatestRead.logic.d.ts +27 -0
  149. package/dist/viewer/LatestRead.logic.js +55 -0
  150. package/dist/viewer/MediaControls.d.ts +25 -0
  151. package/dist/viewer/MediaControls.js +183 -0
  152. package/dist/viewer/MediaPlayer.logic.d.ts +53 -0
  153. package/dist/viewer/MediaPlayer.logic.js +68 -0
  154. package/dist/viewer/PdfView.d.ts +23 -0
  155. package/dist/viewer/PdfView.js +25 -0
  156. package/dist/viewer/QuietFocus.d.ts +19 -0
  157. package/dist/viewer/QuietFocus.js +27 -0
  158. package/dist/viewer/ScaledScroll.logic.d.ts +30 -0
  159. package/dist/viewer/ScaledScroll.logic.js +28 -0
  160. package/dist/viewer/ScaledScrollbar.d.ts +19 -0
  161. package/dist/viewer/ScaledScrollbar.js +71 -0
  162. package/dist/viewer/SyntaxHighlighter.d.ts +29 -0
  163. package/dist/viewer/SyntaxHighlighter.js +144 -0
  164. package/dist/viewer/SyntaxLanguage.logic.d.ts +110 -0
  165. package/dist/viewer/SyntaxLanguage.logic.js +283 -0
  166. package/dist/viewer/SyntaxService.d.ts +75 -0
  167. package/dist/viewer/SyntaxService.js +49 -0
  168. package/dist/viewer/SyntaxSession.logic.d.ts +78 -0
  169. package/dist/viewer/SyntaxSession.logic.js +221 -0
  170. package/dist/viewer/SyntaxWorker.d.ts +6 -0
  171. package/dist/viewer/SyntaxWorker.js +8 -0
  172. package/dist/viewer/TextEncoding.logic.d.ts +35 -0
  173. package/dist/viewer/TextEncoding.logic.js +58 -0
  174. package/dist/viewer/TextRows.logic.d.ts +86 -0
  175. package/dist/viewer/TextRows.logic.js +241 -0
  176. package/dist/viewer/TextSelection.logic.d.ts +97 -0
  177. package/dist/viewer/TextSelection.logic.js +139 -0
  178. package/dist/viewer/TextView.d.ts +13 -0
  179. package/dist/viewer/TextView.js +448 -0
  180. package/dist/viewer/TextViewport.logic.d.ts +70 -0
  181. package/dist/viewer/TextViewport.logic.js +116 -0
  182. package/dist/viewer/VideoView.d.ts +18 -0
  183. package/dist/viewer/VideoView.js +53 -0
  184. package/dist/viewer/ViewerClipboard.d.ts +30 -0
  185. package/dist/viewer/ViewerClipboard.js +70 -0
  186. package/dist/viewer/ViewerFrame.logic.d.ts +61 -0
  187. package/dist/viewer/ViewerFrame.logic.js +130 -0
  188. package/dist/viewer/ViewerKeys.d.ts +16 -0
  189. package/dist/viewer/ViewerKeys.js +14 -0
  190. package/dist/viewer/ViewerScope.d.ts +12 -0
  191. package/dist/viewer/ViewerScope.js +22 -0
  192. package/dist/viewer/ViewerViews.d.ts +28 -0
  193. package/dist/viewer/ViewerViews.js +22 -0
  194. package/dist/viewer/ViewerWindow.d.ts +53 -0
  195. package/dist/viewer/ViewerWindow.js +219 -0
  196. package/dist/viewer/index.d.ts +12 -0
  197. package/dist/viewer/index.js +12 -0
  198. package/dist/viewer/types.d.ts +151 -0
  199. package/dist/viewer/types.js +26 -0
  200. package/dist/viewer/useElementHeight.d.ts +6 -0
  201. package/dist/viewer/useElementHeight.js +22 -0
  202. package/dist/viewer/useElementSize.d.ts +7 -0
  203. package/dist/viewer/useElementSize.js +24 -0
  204. package/dist/viewer/useEscapeToClear.d.ts +8 -0
  205. package/dist/viewer/useEscapeToClear.js +26 -0
  206. package/dist/viewer/useHexDocument.d.ts +41 -0
  207. package/dist/viewer/useHexDocument.js +144 -0
  208. package/dist/viewer/useMediaElement.d.ts +10 -0
  209. package/dist/viewer/useMediaElement.js +24 -0
  210. package/dist/viewer/useSyntaxHighlight.d.ts +24 -0
  211. package/dist/viewer/useSyntaxHighlight.js +133 -0
  212. package/dist/viewer/useTextDocument.d.ts +66 -0
  213. package/dist/viewer/useTextDocument.js +245 -0
  214. package/dist/viewer/viewer.css +645 -0
  215. package/package.json +7 -1
@@ -0,0 +1,197 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
3
+ /**
4
+ * The lower pane's height each page was last dragged to, for as long as the
5
+ * window lives, keyed by the page's split name. A page that comes back opens
6
+ * at the height the user left it.
7
+ */
8
+ const heldHeights = new Map();
9
+ /** A list's rows: every row of a listing or a grid, its column strip aside. */
10
+ const LIST_ROWS = '[role="row"]:not(.pane-columns), .data-grid-row';
11
+ /**
12
+ * How far a scroller's lower edge cuts into its last visible row: zero when
13
+ * its rows fit or its edge falls between two rows. Rows may differ in
14
+ * height (a wrapped name), so the cut row is found, not computed.
15
+ */
16
+ export const cutRowDepth = (scroller) => {
17
+ if (scroller.scrollHeight <= scroller.clientHeight + 1)
18
+ return 0;
19
+ const box = scroller.getBoundingClientRect();
20
+ const bottom = box.top + scroller.clientTop + scroller.clientHeight;
21
+ for (const row of scroller.querySelectorAll(LIST_ROWS)) {
22
+ const edge = row.getBoundingClientRect();
23
+ if (edge.bottom > bottom + 0.5)
24
+ return edge.top < bottom ? Math.max(0, bottom - edge.top) : 0;
25
+ }
26
+ return 0;
27
+ };
28
+ /**
29
+ * The least an upper list keeps under a dragged split: its own min-height,
30
+ * and never under two rows, so a split held from a taller window never
31
+ * leaves the list with nothing in a shorter one.
32
+ */
33
+ const upperFloor = (top) => {
34
+ const style = getComputedStyle(top);
35
+ const row = Number.parseFloat(style.getPropertyValue('--row-height')) || 24;
36
+ return Math.max(Number.parseFloat(style.minHeight) || 0, 2 * row);
37
+ };
38
+ /**
39
+ * The lower pane's height under a dragged split: the height dragged, less
40
+ * what the upper list must keep of the two regions' room (`floor`), and
41
+ * never under the lower pane's own least (`least`), in whole pixels, none
42
+ * left included; the height dragged stands alone only while the split is
43
+ * not laid out (`room` null: a page held out of sight).
44
+ */
45
+ export const heldSplitHeight = (held, room, bounds) => room === null
46
+ ? Math.round(Math.max(bounds.least, held))
47
+ : Math.round(Math.max(bounds.least, Math.min(held, room - bounds.floor)));
48
+ /**
49
+ * The room the upper list and the lower pane share: from the list's top to
50
+ * the end of their container's content box, less whatever follows the
51
+ * lower pane, measured from the container so a lower pane held taller than
52
+ * the room (and overflowing it) is not counted as room; null while the
53
+ * container is not laid out.
54
+ */
55
+ const splitRoom = (top, pane) => {
56
+ const parent = top.parentElement;
57
+ // Not laid out (a page held out of sight): no room to fit to, which is
58
+ // not the same as a page with no room left.
59
+ if ((parent ?? top).getClientRects().length === 0)
60
+ return null;
61
+ if (parent === null)
62
+ return top.getBoundingClientRect().height + pane.getBoundingClientRect().height;
63
+ const box = parent.getBoundingClientRect();
64
+ const end = box.top + parent.clientTop + parent.clientHeight;
65
+ let after = 0;
66
+ for (let next = pane.nextElementSibling; next !== null; next = next.nextElementSibling) {
67
+ after += next.getBoundingClientRect().height;
68
+ }
69
+ return end - top.getBoundingClientRect().top - after;
70
+ };
71
+ /**
72
+ * A splitter between a page's upper list and the pane under it: the user drags the divide, the height is
73
+ * kept per page (`name`) while the window lives, and both regions come to
74
+ * rest at a whole row. The upper list (`upper`, a `PaneList`'s ref) ends at
75
+ * a row's lower edge (the slice it would have cut goes to the lower pane);
76
+ * the lower pane's own list, the first match of `lowerScroller` inside it
77
+ * (a `SplitDetail`'s body unless given), ends at a whole row with the rest
78
+ * of the pane left empty under it.
79
+ *
80
+ * The lower pane is a flex item whose basis the splitter sets; until the
81
+ * user drags, both regions take the sizes the page's stylesheet gives them. `layoutKey` changes when the rows change (a load, a
82
+ * tab switch), so the rest is measured again; a window resize is observed.
83
+ */
84
+ export function usePaneSplit(name, layoutKey, lowerScroller = '.split-detail-body') {
85
+ const upper = useRef(null);
86
+ const lower = useRef(null);
87
+ const drag = useRef(null);
88
+ const [held, setHeld] = useState(() => ({ name, height: heldHeights.get(name) ?? null }));
89
+ // A page that changes its split's name while mounted takes that page's
90
+ // kept height, not the one it was showing.
91
+ const height = held.name === name ? held.height : (heldHeights.get(name) ?? null);
92
+ const setHeight = useCallback((next) => setHeld({ name, height: next }), [name]);
93
+ const settle = useCallback(() => {
94
+ const top = upper.current;
95
+ const pane = lower.current;
96
+ if (top === null || pane === null)
97
+ return;
98
+ const inner = pane.querySelector(lowerScroller);
99
+ // Until a drag each region takes the share the stylesheet gives it (the
100
+ // shorter one as tall as its rows, up to a cap); a dragged height holds
101
+ // the lower pane there and gives the upper list the rest.
102
+ pane.style.flex = height === null ? '' : `0 0 ${height}px`;
103
+ pane.style.maxHeight = height === null ? '' : 'none';
104
+ top.style.flex = height === null ? '' : '1 1 0';
105
+ top.style.maxHeight = height === null ? '' : 'none';
106
+ if (inner !== null)
107
+ inner.style.maxHeight = '';
108
+ const floor = upperFloor(top);
109
+ // A height dragged in a taller window gives way in a shorter one, so the
110
+ // upper list keeps its floor; the drag itself is kept for when the room
111
+ // comes back.
112
+ if (height !== null) {
113
+ const room = splitRoom(top, pane);
114
+ const least = Number.parseFloat(getComputedStyle(pane).minHeight) || 0;
115
+ const fitted = heldSplitHeight(height, room, { floor, least });
116
+ if (fitted !== height)
117
+ pane.style.flex = `0 0 ${fitted}px`;
118
+ }
119
+ const cut = cutRowDepth(top);
120
+ if (cut > 0) {
121
+ const paneHeight = pane.getBoundingClientRect().height;
122
+ const room = top.getBoundingClientRect().height - floor;
123
+ // The cut slice goes to the lower pane, past the cap its stylesheet
124
+ // gives it at rest; an upper list already at its floor keeps its
125
+ // slice rather than overflow the page.
126
+ if (cut <= room) {
127
+ pane.style.flexBasis = `${paneHeight + cut}px`;
128
+ pane.style.maxHeight = `${paneHeight + cut}px`;
129
+ }
130
+ }
131
+ if (inner !== null) {
132
+ const innerCut = cutRowDepth(inner);
133
+ if (innerCut > 0)
134
+ inner.style.maxHeight = `${inner.clientHeight - innerCut}px`;
135
+ }
136
+ }, [height, lowerScroller]);
137
+ useLayoutEffect(settle, [settle, layoutKey]);
138
+ // Observed again when the layout changes, so a list that mounts after a
139
+ // load (its ref null at first) is watched from then on.
140
+ useEffect(() => {
141
+ const frame = upper.current?.parentElement;
142
+ if (frame === null || frame === undefined || typeof ResizeObserver === 'undefined') {
143
+ return undefined;
144
+ }
145
+ const observer = new ResizeObserver(() => settle());
146
+ observer.observe(frame);
147
+ return () => observer.disconnect();
148
+ }, [settle, layoutKey]);
149
+ useEffect(() => () => drag.current?.abort(), []);
150
+ const start = (event) => {
151
+ const top = upper.current;
152
+ const pane = lower.current;
153
+ if (top === null || pane === null || event.button !== 0)
154
+ return;
155
+ event.preventDefault();
156
+ drag.current?.abort();
157
+ const listeners = new AbortController();
158
+ const startY = event.clientY;
159
+ const startHeight = pane.getBoundingClientRect().height;
160
+ const least = Number.parseFloat(getComputedStyle(pane).minHeight) || 0;
161
+ const most = startHeight + top.getBoundingClientRect().height - upperFloor(top);
162
+ let latest = startHeight;
163
+ const end = () => {
164
+ listeners.abort();
165
+ heldHeights.set(name, latest);
166
+ };
167
+ drag.current = listeners;
168
+ window.addEventListener('pointermove', (moved) => {
169
+ latest = Math.round(Math.min(most, Math.max(least, startHeight - (moved.clientY - startY))));
170
+ setHeight(latest);
171
+ }, { signal: listeners.signal });
172
+ window.addEventListener('pointerup', end, { signal: listeners.signal });
173
+ window.addEventListener('pointercancel', end, { signal: listeners.signal });
174
+ };
175
+ const reset = () => {
176
+ heldHeights.delete(name);
177
+ setHeight(null);
178
+ };
179
+ return { upper, lower, drag: start, reset };
180
+ }
181
+ /**
182
+ * The splitter's band, between the upper list and the lower pane: the
183
+ * resize cursor over the hairline that divides them. A double click puts
184
+ * the divide back at the page's own share. The pointer drags it; the keys
185
+ * reach both lists without it.
186
+ */
187
+ export function PaneSplitter({ split }) {
188
+ return (_jsx("div", { "aria-hidden": true, className: "pane-splitter", onDoubleClick: split.reset, onPointerDown: split.drag }));
189
+ }
190
+ /**
191
+ * The pane under a page's list, under its `PaneSplitter`: as tall as what
192
+ * it shows until dragged, up to 38% of the page and never under seven
193
+ * dense rows, its body scrolling under its head.
194
+ */
195
+ export function SplitDetail({ split, folded = false, label, head, children }) {
196
+ return (_jsxs("section", { "aria-label": label, className: folded ? 'split-detail folded' : 'split-detail', ref: split.lower, children: [head, folded ? null : _jsx("div", { className: "split-detail-body", children: children })] }));
197
+ }
@@ -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", 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,147 @@
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
+ /**
104
+ * Its key among the tree's rows, which joins it to the pane's cursor
105
+ * (`RowCursorContext`) as a `TreeRow` is: the cursor's keys reach it and
106
+ * the pointer moves the cursor to it. Without one it stands outside the
107
+ * cursor, which `cursor` then draws.
108
+ */
109
+ readonly rowKey?: string;
110
+ /** The pane's cursor stands on it, for a tool row without a `rowKey`. */
111
+ readonly cursor?: boolean;
112
+ /** Its control after the words: a `TreeFilterInput`, a pager, an action. */
113
+ readonly children?: ReactNode;
114
+ }
115
+ /**
116
+ * A row of a tree that is not a node, at its level's indent in the small
117
+ * size: a filter field, a pager, a note, a heading, or a failed read with
118
+ * its action.
119
+ */
120
+ export declare function TreeTool({ kind, level, icon: Icon, text, rowKey, cursor: cursorOn, children }: TreeToolProps): ReactElement;
121
+ /** Props for {@link TreeFilterInput}. */
122
+ export interface TreeFilterInputProps {
123
+ readonly value: string;
124
+ /** Hears each edit. */
125
+ readonly onChange: (value: string) => void;
126
+ /** Its accessible name ("Filter services"). */
127
+ readonly label: string;
128
+ readonly placeholder?: string;
129
+ /** The host's keys while it holds the keyboard (Escape clears, ↓ goes to the rows). */
130
+ readonly onKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
131
+ readonly ref?: Ref<HTMLInputElement>;
132
+ }
133
+ /**
134
+ * A tree's filter field: a bare field that fills its `TreeTool` row, the
135
+ * row underlined in the accent while the field holds the keyboard.
136
+ */
137
+ export declare function TreeFilterInput({ value, onChange, label, placeholder, onKeyDown, ref }: TreeFilterInputProps): ReactElement;
138
+ /** Props for {@link SidebarEmpty}. */
139
+ export interface SidebarEmptyProps {
140
+ /** What it says ("No services yet."). */
141
+ readonly children: ReactNode;
142
+ }
143
+ /**
144
+ * A sidebar with nothing to list, saying so as a quiet row in the rows'
145
+ * place: from where a row's icon starts, dim, one row high.
146
+ */
147
+ export declare function SidebarEmpty({ children }: SidebarEmptyProps): ReactElement;
@@ -0,0 +1,164 @@
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 in the tree's own root (the document, or the shadow
44
+ // root it is mounted in, where the document cannot see), never a scan
45
+ // of the rows; the tree's prefix makes the id unique there. A tree not
46
+ // yet attached has no such root, and nothing to name.
47
+ // Asked by shape, not instanceof, so a tree React renders into another
48
+ // window's document (a same-origin frame) finds its row too.
49
+ const root = element.getRootNode();
50
+ const row = id === null || typeof root.getElementById !== 'function' ? null : root.getElementById(id);
51
+ const drawnRow = row !== null && element.contains(row);
52
+ if (drawnRow && id !== null)
53
+ element.setAttribute('aria-activedescendant', id);
54
+ else
55
+ element.removeAttribute('aria-activedescendant');
56
+ }, [cursor, list, tree]);
57
+ // After every render and on every cursor move; and once a commit has put
58
+ // rows in or taken them out, by whatever state drew them: one microtask
59
+ // per commit, however many rows came or went, calling the latest sync.
60
+ const latestSync = useRef(sync);
61
+ const pending = useRef(false);
62
+ useLayoutEffect(() => {
63
+ latestSync.current = sync;
64
+ sync();
65
+ return cursor.subscribe(sync);
66
+ });
67
+ const scope = useMemo(() => ({
68
+ id: tree,
69
+ rowsChanged: () => {
70
+ if (pending.current)
71
+ return;
72
+ pending.current = true;
73
+ queueMicrotask(() => {
74
+ pending.current = false;
75
+ latestSync.current();
76
+ });
77
+ }
78
+ }), [tree]);
79
+ 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 }) }));
80
+ }
81
+ /**
82
+ * One row of a sidebar's tree: the chevron's slot, the glyph, the name (cut
83
+ * with an ellipsis, whole in its tooltip) with its quieter detail, then its
84
+ * trailing column and its own tool. Like a listing's `Row`, it follows the
85
+ * pane's cursor (`RowCursorContext`), wearing the cursor row's look and
86
+ * `aria-current`; the pointer moving over it or the focus entering it moves
87
+ * the cursor there. Its controls leave the Tab order, since the tree's keys
88
+ * run them. The expansion and its keys stay the host's.
89
+ */
90
+ export function TreeRow({ rowKey, level = 0, kind = 'node', toggle, glyph, name, detail, trailing, tool, marked = false, onOpen, focusable = false }) {
91
+ const cursor = useContext(RowCursorContext);
92
+ const tree = useContext(TreeIdContext);
93
+ const current = useSyncExternalStore(cursor.subscribe, () => cursor.current() === rowKey);
94
+ useLayoutEffect(() => {
95
+ cursor.rowsChanged?.();
96
+ tree?.rowsChanged();
97
+ return () => {
98
+ cursor.rowsChanged?.();
99
+ tree?.rowsChanged();
100
+ };
101
+ }, [cursor, rowKey, tree]);
102
+ const classes = [
103
+ 'row',
104
+ kind === 'band' ? 'tree-band' : '',
105
+ kind === 'group' ? 'tree-group' : '',
106
+ current ? 'cursor' : '',
107
+ marked ? 'marked' : ''
108
+ ]
109
+ .filter(Boolean)
110
+ .join(' ');
111
+ 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: () => {
112
+ if (!current)
113
+ cursor.point(rowKey);
114
+ }, 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 })] })] }) }) }));
115
+ }
116
+ /**
117
+ * A row of a tree that is not a node, at its level's indent in the small
118
+ * size: a filter field, a pager, a note, a heading, or a failed read with
119
+ * its action.
120
+ */
121
+ export function TreeTool({ kind = 'tool', level = 0, icon: Icon, text, rowKey, cursor: cursorOn = false, children }) {
122
+ const cursor = useContext(RowCursorContext);
123
+ const tree = useContext(TreeIdContext);
124
+ const current = useSyncExternalStore(cursor.subscribe, () => rowKey !== undefined && cursor.current() === rowKey);
125
+ useLayoutEffect(() => {
126
+ if (rowKey === undefined)
127
+ return;
128
+ cursor.rowsChanged?.();
129
+ tree?.rowsChanged();
130
+ return () => {
131
+ cursor.rowsChanged?.();
132
+ tree?.rowsChanged();
133
+ };
134
+ }, [cursor, rowKey, tree]);
135
+ const classes = [
136
+ 'tree-tool',
137
+ kind === 'note' ? 'tree-note' : '',
138
+ kind === 'heading' ? 'tree-heading' : '',
139
+ kind === 'danger' ? 'danger' : '',
140
+ current || (rowKey === undefined && cursorOn) ? 'cursor' : ''
141
+ ]
142
+ .filter(Boolean)
143
+ .join(' ');
144
+ return (_jsxs("div", { className: classes, "data-row-key": rowKey, id: rowKey === undefined || tree === null ? undefined : rowId(tree.id, rowKey), onPointerMove: rowKey === undefined
145
+ ? undefined
146
+ : () => {
147
+ if (!current)
148
+ cursor.point(rowKey);
149
+ }, "aria-level": rowKey === undefined ? undefined : level + 1, role: rowKey !== undefined ? 'treeitem' : 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", role: rowKey !== undefined && kind === 'danger' ? 'alert' : undefined, children: text })), children] }));
150
+ }
151
+ /**
152
+ * A tree's filter field: a bare field that fills its `TreeTool` row, the
153
+ * row underlined in the accent while the field holds the keyboard.
154
+ */
155
+ export function TreeFilterInput({ value, onChange, label, placeholder, onKeyDown, ref }) {
156
+ 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 }));
157
+ }
158
+ /**
159
+ * A sidebar with nothing to list, saying so as a quiet row in the rows'
160
+ * place: from where a row's icon starts, dim, one row high.
161
+ */
162
+ export function SidebarEmpty({ children }) {
163
+ return _jsx("p", { className: "space-nav-empty", children: children });
164
+ }
@@ -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
+ }