@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,42 @@
1
+ /**
2
+ * How far below the column's top edge a subsection's start may sit and
3
+ * still count as the one in view: the column's top padding and some slack,
4
+ * so the subsection a sidebar click scrolled to is the one marked.
5
+ */
6
+ export const SUBSECTION_SPY_SLACK_PX = 24;
7
+ /** The column's top padding, which a subsection keeps above it once scrolled to. */
8
+ export const SUBSECTION_SCROLL_INSET_PX = 14;
9
+ /**
10
+ * The subsection the sidebar marks as in view: the last one whose start has
11
+ * reached the column's top edge, or the last of all once the column is
12
+ * scrolled to its end (a short last subsection never reaches the top). A
13
+ * page that cannot scroll, or one not yet scrolled past its title, marks
14
+ * its first. Null when the page has no subsections.
15
+ */
16
+ export function spiedSubsection(anchors, view) {
17
+ const first = anchors[0];
18
+ if (!first) {
19
+ return null;
20
+ }
21
+ if (view.scrollHeight <= view.clientHeight + 1) {
22
+ return first.id;
23
+ }
24
+ if (view.scrollTop + view.clientHeight >= view.scrollHeight - 1) {
25
+ return anchors.at(-1)?.id ?? first.id;
26
+ }
27
+ const passed = anchors.filter((anchor) => anchor.top <= view.scrollTop + SUBSECTION_SPY_SLACK_PX);
28
+ return passed.at(-1)?.id ?? first.id;
29
+ }
30
+ /**
31
+ * Where to scroll the column to show a subsection: the top for the first,
32
+ * so the page title stays in view, and otherwise the subsection's start
33
+ * under the column's top padding. Null for an id the page does not draw.
34
+ */
35
+ export function subsectionScrollTop(anchors, id) {
36
+ const index = anchors.findIndex((anchor) => anchor.id === id);
37
+ const anchor = anchors[index];
38
+ if (!anchor) {
39
+ return null;
40
+ }
41
+ return index === 0 ? 0 : Math.max(0, anchor.top - SUBSECTION_SCROLL_INSET_PX);
42
+ }
@@ -0,0 +1,55 @@
1
+ import type { ReactElement } from 'react';
2
+ /**
3
+ * Runs a host request a row's button makes, and keeps the failure it
4
+ * answers: a message to show under the row, or null when it went through.
5
+ */
6
+ export type SettingsFileRequest = () => Promise<string | null>;
7
+ /** One problem in a settings file. */
8
+ export interface SettingsFileProblem {
9
+ /** A mistake (`problem`) or a note about a value the app adjusted (`note`). */
10
+ readonly kind: 'problem' | 'note';
11
+ /** Where it is ("Line 12"); null where the file as a whole is at fault. */
12
+ readonly place: string | null;
13
+ /** The key it is about, set in the code face; null for none. */
14
+ readonly key: string | null;
15
+ readonly message: string;
16
+ }
17
+ /** One settings file the app reads. */
18
+ export interface SettingsFileEntry {
19
+ /** The file's name ("settings.toml"). */
20
+ readonly name: string;
21
+ /** Its state in a few words ("Read 2 minutes ago", "Not created yet"). */
22
+ readonly summary: string;
23
+ /** Opens the file in the system's editor; none while the file does not exist. */
24
+ readonly onOpen?: SettingsFileRequest;
25
+ /** Its problems in line order. */
26
+ readonly problems: readonly SettingsFileProblem[];
27
+ /** The problem list's accessible name ("Problems in settings.toml"). */
28
+ readonly problemsLabel: string;
29
+ }
30
+ /** Props for {@link SettingsFiles}. */
31
+ export interface SettingsFilesProps {
32
+ /** The folder row's label ("Folder"). */
33
+ readonly folderLabel: string;
34
+ /** What the folder is, the label's tooltip. */
35
+ readonly folderHelp?: string;
36
+ /** The folder's path, selectable, cut with an ellipsis. */
37
+ readonly folder: string;
38
+ /** The verb that shows the folder ("Show in Finder"). */
39
+ readonly showFolderLabel: string;
40
+ readonly onShowFolder: SettingsFileRequest;
41
+ /** Why the folder cannot be used; null when it can. */
42
+ readonly folderProblem?: string | null;
43
+ /** The open verb on each file's row ("Open"). */
44
+ readonly openLabel: string;
45
+ readonly files: readonly SettingsFileEntry[];
46
+ }
47
+ /**
48
+ * A Files page of Settings: the settings folder with a verb that shows it,
49
+ * then each file the app reads there, with Open and its problems under it
50
+ * (where, which key, what is wrong), on the label column every page shares.
51
+ * A request the host refuses shows its message under its row. Problems show
52
+ * only here; the host keeps the page current while it is open, so a fix
53
+ * made in an editor clears its problem as soon as the file is saved.
54
+ */
55
+ export declare function SettingsFiles({ folderLabel, folderHelp, folder, showFolderLabel, onShowFolder, folderProblem, openLabel, files }: SettingsFilesProps): ReactElement;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { CircleAlert, FolderOpen, Info, SquarePen } from 'lucide-react';
3
+ import { useState } from 'react';
4
+ import { Button } from '../button/Button.js';
5
+ import { labelHelp } from '../field/labelHelp.js';
6
+ import { ICON_MD, ICON_SM } from '../icon/sizes.js';
7
+ /** A request's failure under its row, or nothing. */
8
+ function Failure({ message }) {
9
+ return message === null ? null : (_jsx("p", { className: "field-problem", role: "alert", children: message }));
10
+ }
11
+ /** One file: its name, its state and Open, and its problems under it. */
12
+ function SettingsFileRow({ file, openLabel }) {
13
+ const [failure, setFailure] = useState(null);
14
+ const open = file.onOpen;
15
+ return (_jsxs(_Fragment, { children: [_jsx("span", { className: "field-label settings-file-name", children: file.name }), _jsxs("div", { className: "field-value", children: [_jsxs("div", { className: "field-option", children: [_jsx("span", { className: "settings-file-summary", children: file.summary }), open === undefined ? null : (_jsxs(Button, { onClick: () => void open().then(setFailure), size: "small", children: [_jsx(SquarePen, { "aria-hidden": true, size: ICON_SM }), openLabel] }))] }), file.problems.length > 0 ? (_jsx("ul", { "aria-label": file.problemsLabel, className: "settings-file-problems", children: file.problems.map((problem, index) => (_jsxs("li", { className: problem.kind === 'note'
16
+ ? 'settings-file-problem notice note'
17
+ : 'settings-file-problem notice notice-danger', children: [problem.kind === 'note' ? (_jsx(Info, { "aria-hidden": true, size: ICON_MD })) : (_jsx(CircleAlert, { "aria-hidden": true, size: ICON_MD })), _jsxs("span", { className: "notice-text settings-file-problem-text", children: [problem.place === null && problem.key === null ? null : (_jsxs("span", { className: "settings-file-problem-place", children: [problem.place, problem.place !== null && problem.key !== null ? ' · ' : null, problem.key === null ? null : _jsx("code", { children: problem.key })] })), _jsx("span", { children: problem.message })] })] }, index))) })) : null, _jsx(Failure, { message: failure })] })] }));
18
+ }
19
+ /**
20
+ * A Files page of Settings: the settings folder with a verb that shows it,
21
+ * then each file the app reads there, with Open and its problems under it
22
+ * (where, which key, what is wrong), on the label column every page shares.
23
+ * A request the host refuses shows its message under its row. Problems show
24
+ * only here; the host keeps the page current while it is open, so a fix
25
+ * made in an editor clears its problem as soon as the file is saved.
26
+ */
27
+ export function SettingsFiles({ folderLabel, folderHelp, folder, showFolderLabel, onShowFolder, folderProblem = null, openLabel, files }) {
28
+ const [failure, setFailure] = useState(null);
29
+ return (_jsxs("div", { className: "field-grid", children: [_jsx("span", { className: "field-label", ...labelHelp(folderHelp).label, children: folderLabel }), _jsxs("div", { className: "field-value", children: [_jsxs("div", { className: "field-option", children: [_jsx("code", { className: "settings-file-path", children: folder }), _jsxs(Button, { onClick: () => void onShowFolder().then(setFailure), size: "small", children: [_jsx(FolderOpen, { "aria-hidden": true, size: ICON_SM }), showFolderLabel] })] }), folderProblem === null ? null : _jsx("p", { className: "field-problem", children: folderProblem }), _jsx(Failure, { message: failure })] }), files.map((file) => (_jsx(SettingsFileRow, { file: file, openLabel: openLabel }, file.name)))] }));
30
+ }
@@ -0,0 +1,42 @@
1
+ import { type DialogLegendModel } from '../dialog/DialogLegend.logic.js';
2
+ /**
3
+ * The keys a Settings page takes over while it shows: the legend it draws
4
+ * in place of the dialog's Done, and what Escape does instead of closing
5
+ * the dialog.
6
+ */
7
+ export interface SettingsPageKeys {
8
+ readonly legend: DialogLegendModel;
9
+ /**
10
+ * True while the page has nothing of its own for Return (a cursor on a
11
+ * locked row, a find that shows no row): the dialog's Done stands as the
12
+ * legend's primary, and Return runs it from anywhere, a find field
13
+ * included. The legend then names no primary of its own.
14
+ */
15
+ readonly done?: boolean;
16
+ /**
17
+ * What Escape, the leave slot, and a press outside the dialog run (Clear a
18
+ * find, Cancel a recording); null leaves them closing the dialog.
19
+ */
20
+ readonly onLeave: (() => void) | null;
21
+ }
22
+ /**
23
+ * Where a page hands its keys to `SettingsDialog`, which provides it around
24
+ * the page it shows; null gives the dialog's own keys back. The default
25
+ * drops them, so a page rendered on its own still works.
26
+ */
27
+ export declare const SettingsPageKeysContext: import("react").Context<(keys: SettingsPageKeys | null) => void>;
28
+ /**
29
+ * The Settings dialog's legend while `keys` show, or its own with none:
30
+ * `done` (the dialog's Done) on Return, which a focused field, pop-up menu,
31
+ * or button keeps, since every control applies at once; the page's legend
32
+ * while it shows one, with Done as its primary when the page says Return
33
+ * is Done.
34
+ */
35
+ export declare function settingsLegend(keys: SettingsPageKeys | null, onDone: () => void, done: string): DialogLegendModel;
36
+ /**
37
+ * Hands a page's keys to `SettingsDialog` while the page is mounted, and
38
+ * gives the dialog its own back when it unmounts. The page may build
39
+ * `keys` afresh on every render: the dialog redraws only when the legend's
40
+ * slots or the leave choice change, and every verb runs the latest handler.
41
+ */
42
+ export declare function useSettingsPageKeys(keys: SettingsPageKeys): void;
@@ -0,0 +1,70 @@
1
+ import { createContext, useContext, useLayoutEffect, useRef } from 'react';
2
+ import { legendSignature } from '../dialog/DialogLegend.logic.js';
3
+ /**
4
+ * Where a page hands its keys to `SettingsDialog`, which provides it around
5
+ * the page it shows; null gives the dialog's own keys back. The default
6
+ * drops them, so a page rendered on its own still works.
7
+ */
8
+ export const SettingsPageKeysContext = createContext(() => { });
9
+ /**
10
+ * The keys with every verb running the latest model's: the dialog holds one
11
+ * model per legend drawn, while the page's handlers change on each render.
12
+ */
13
+ function relayed(latest) {
14
+ const { legend, onLeave } = latest.current;
15
+ const slot = (chosen, index) => ({
16
+ ...chosen,
17
+ onRun: () => latest.current.legend.secondary?.[index]?.onRun()
18
+ });
19
+ const primary = legend.primary
20
+ ? { primary: { ...legend.primary, onRun: () => latest.current.legend.primary?.onRun() } }
21
+ : {};
22
+ const [first, second] = legend.secondary ?? [];
23
+ const relayedLegend = {
24
+ ...(legend.leave === undefined ? {} : { leave: legend.leave }),
25
+ secondary: first === undefined
26
+ ? []
27
+ : second === undefined
28
+ ? [slot(first, 0)]
29
+ : [slot(first, 0), slot(second, 1)],
30
+ ...primary
31
+ };
32
+ return {
33
+ legend: relayedLegend,
34
+ ...(latest.current.done === true ? { done: true } : {}),
35
+ onLeave: onLeave === null ? null : () => latest.current.onLeave?.()
36
+ };
37
+ }
38
+ /**
39
+ * The Settings dialog's legend while `keys` show, or its own with none:
40
+ * `done` (the dialog's Done) on Return, which a focused field, pop-up menu,
41
+ * or button keeps, since every control applies at once; the page's legend
42
+ * while it shows one, with Done as its primary when the page says Return
43
+ * is Done.
44
+ */
45
+ export function settingsLegend(keys, onDone, done) {
46
+ if (keys === null) {
47
+ return { primary: { label: done, onRun: onDone, yieldsReturn: true } };
48
+ }
49
+ return keys.done === true
50
+ ? { ...keys.legend, primary: { label: done, onRun: onDone } }
51
+ : keys.legend;
52
+ }
53
+ /**
54
+ * Hands a page's keys to `SettingsDialog` while the page is mounted, and
55
+ * gives the dialog its own back when it unmounts. The page may build
56
+ * `keys` afresh on every render: the dialog redraws only when the legend's
57
+ * slots or the leave choice change, and every verb runs the latest handler.
58
+ */
59
+ export function useSettingsPageKeys(keys) {
60
+ const publish = useContext(SettingsPageKeysContext);
61
+ const latest = useRef(keys);
62
+ const signature = `${legendSignature(keys.legend)}|${keys.onLeave === null ? 'close' : 'page'}|${keys.done === true ? 'done' : ''}`;
63
+ useLayoutEffect(() => {
64
+ latest.current = keys;
65
+ });
66
+ useLayoutEffect(() => {
67
+ publish(relayed(latest));
68
+ }, [publish, signature]);
69
+ useLayoutEffect(() => () => publish(null), [publish]);
70
+ }
@@ -0,0 +1,34 @@
1
+ import type { ReactElement, ReactNode } from 'react';
2
+ /**
3
+ * The attribute that marks a subsection of a Settings page, carrying its
4
+ * id; `SettingsDialog` finds the subsections by it to scroll to one and to
5
+ * follow the one in view.
6
+ */
7
+ export declare const SETTINGS_SUBSECTION_ATTRIBUTE = "data-settings-subsection";
8
+ /**
9
+ * The attribute that marks a page's sticky head (a find field and its
10
+ * tools, pinned at the top of the column while the subsections scroll
11
+ * under it); `SettingsDialog` counts its height, so a subsection it scrolls
12
+ * to, or marks as in view, starts below the head rather than under it.
13
+ */
14
+ export declare const SETTINGS_PAGE_HEAD_ATTRIBUTE = "data-settings-page-head";
15
+ /**
16
+ * The attribute that marks the control a page brings into view as it opens
17
+ * (the theme in use on Appearance), when it is not wholly in view at the
18
+ * page's top.
19
+ */
20
+ export declare const SETTINGS_REVEAL_ATTRIBUTE = "data-settings-reveal";
21
+ /** Props for {@link SettingsSubsection}. */
22
+ export interface SettingsSubsectionProps {
23
+ /** The id the page lists in its `subsections`. */
24
+ readonly id: string;
25
+ readonly title: string;
26
+ /** The rows: a `field-grid` on the label column every page shares. */
27
+ readonly children: ReactNode;
28
+ }
29
+ /**
30
+ * One subsection of a Settings page: its name as an overline over its rows,
31
+ * with a hairline between subsections, marked so `SettingsDialog`'s sidebar
32
+ * can scroll to it and follow it.
33
+ */
34
+ export declare function SettingsSubsection({ id, title, children }: SettingsSubsectionProps): ReactElement;
@@ -0,0 +1,30 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useId } from 'react';
3
+ /**
4
+ * The attribute that marks a subsection of a Settings page, carrying its
5
+ * id; `SettingsDialog` finds the subsections by it to scroll to one and to
6
+ * follow the one in view.
7
+ */
8
+ export const SETTINGS_SUBSECTION_ATTRIBUTE = 'data-settings-subsection';
9
+ /**
10
+ * The attribute that marks a page's sticky head (a find field and its
11
+ * tools, pinned at the top of the column while the subsections scroll
12
+ * under it); `SettingsDialog` counts its height, so a subsection it scrolls
13
+ * to, or marks as in view, starts below the head rather than under it.
14
+ */
15
+ export const SETTINGS_PAGE_HEAD_ATTRIBUTE = 'data-settings-page-head';
16
+ /**
17
+ * The attribute that marks the control a page brings into view as it opens
18
+ * (the theme in use on Appearance), when it is not wholly in view at the
19
+ * page's top.
20
+ */
21
+ export const SETTINGS_REVEAL_ATTRIBUTE = 'data-settings-reveal';
22
+ /**
23
+ * One subsection of a Settings page: its name as an overline over its rows,
24
+ * with a hairline between subsections, marked so `SettingsDialog`'s sidebar
25
+ * can scroll to it and follow it.
26
+ */
27
+ export function SettingsSubsection({ id, title, children }) {
28
+ const headingId = useId();
29
+ return (_jsxs("section", { "aria-labelledby": headingId, className: "settings-subsection", [SETTINGS_SUBSECTION_ATTRIBUTE]: id, children: [_jsx("h4", { className: "settings-subsection-title overline", id: headingId, children: title }), children] }));
30
+ }
@@ -0,0 +1,61 @@
1
+ import { type LucideIcon } from 'lucide-react';
2
+ import { type ReactElement, type ReactNode } from 'react';
3
+ import type { DialogItem } from '../dialog/DialogLists.js';
4
+ /** A fact row a sign-in opens with: where (Server) and who (Account, Key file). */
5
+ export interface SignInFact {
6
+ readonly label: string;
7
+ readonly value: string;
8
+ }
9
+ /** Props for {@link SignInDialog}. */
10
+ export interface SignInDialogProps {
11
+ /** The title: "Sign In", never the host's name. */
12
+ readonly title: string;
13
+ /** The verb on Return ("Sign In"). */
14
+ readonly confirmLabel: string;
15
+ /** Where and who, as fact rows before the field. */
16
+ readonly facts: readonly SignInFact[];
17
+ /** The field's one-word label ("Password", "Passphrase"). */
18
+ readonly secretLabel: string;
19
+ /** Why it asks again after a refusal ("That password was not accepted."); null on a first ask. */
20
+ readonly rejection?: string | null;
21
+ /** Whether the typed value may be sent; any non-empty value unless given. */
22
+ readonly accepts?: (value: string) => boolean;
23
+ /** What goes under the field (a Save in Keychain choice). */
24
+ readonly children?: ReactNode;
25
+ /** The title strip's glyph; a key unless given. */
26
+ readonly icon?: LucideIcon;
27
+ readonly onSubmit: (value: string) => void;
28
+ readonly onCancel: () => void;
29
+ }
30
+ /**
31
+ * One password or passphrase, asked in the dialog frame: fact rows for
32
+ * where and who, then the field's one-word label beside one secure field,
33
+ * and why it asks again when it does, on one label column. Return signs in
34
+ * and Escape cancels. The value lives in this field alone and leaves only
35
+ * as the answer; the field takes the focus once the dialog is up.
36
+ */
37
+ export declare function SignInDialog({ title, confirmLabel, facts, secretLabel, rejection, accepts, children, icon, onSubmit, onCancel }: SignInDialogProps): ReactElement;
38
+ /** Props for {@link HostKeyDialog}. */
39
+ export interface HostKeyDialogProps {
40
+ /** At most five words ("Trust Host Key?"). */
41
+ readonly title: string;
42
+ /** Why it asks and when to trust the key. */
43
+ readonly message: ReactNode;
44
+ /** The verb ("Trust"). */
45
+ readonly confirmLabel: string;
46
+ /** The host, as the confirmation's one item (its saved name as the detail). */
47
+ readonly host: DialogItem;
48
+ /** The key's type ("ED25519"). */
49
+ readonly keyType: string;
50
+ /** The key's whole fingerprint, selectable. */
51
+ readonly fingerprint: string;
52
+ readonly onTrust: () => void;
53
+ readonly onCancel: () => void;
54
+ }
55
+ /**
56
+ * A host key the computer has not seen before, as a confirmation read at a
57
+ * glance: the lead says why it asks and when to trust it, the host is the
58
+ * one item, and then the key's type and its whole fingerprint in a framed
59
+ * well. The verb answers yes, Cancel no.
60
+ */
61
+ export declare function HostKeyDialog({ title, message, confirmLabel, host, keyType, fingerprint, onTrust, onCancel }: HostKeyDialogProps): ReactElement;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { KeyRound, Server, ShieldQuestionMark } from 'lucide-react';
3
+ import { Fragment, useEffect, useId, useRef, useState } from 'react';
4
+ import { ConfirmDialog } from '../dialog/ConfirmDialog.js';
5
+ import { ModalDialog } from '../dialog/ModalDialog.js';
6
+ import { useLabels } from '../labels/UiokProvider.js';
7
+ import { cutTooltip } from '../tooltip/Tooltip.logic.js';
8
+ /**
9
+ * One password or passphrase, asked in the dialog frame: fact rows for
10
+ * where and who, then the field's one-word label beside one secure field,
11
+ * and why it asks again when it does, on one label column. Return signs in
12
+ * and Escape cancels. The value lives in this field alone and leaves only
13
+ * as the answer; the field takes the focus once the dialog is up.
14
+ */
15
+ export function SignInDialog({ title, confirmLabel, facts, secretLabel, rejection = null, accepts = (value) => value.length > 0, children, icon = KeyRound, onSubmit, onCancel }) {
16
+ const labels = useLabels().dialog;
17
+ const ids = useId();
18
+ const [value, setValue] = useState('');
19
+ const field = useRef(null);
20
+ useEffect(() => {
21
+ field.current?.focus();
22
+ }, []);
23
+ return (_jsx(ModalDialog, { className: "sign-in-dialog", icon: icon, labelId: `${ids}-title`, legend: {
24
+ leave: { label: labels.cancel },
25
+ primary: { label: confirmLabel, disabled: !accepts(value), onRun: () => onSubmit(value) }
26
+ }, onCancel: onCancel, title: title, children: _jsxs("div", { className: "field-grid", children: [facts.map((fact) => (_jsxs(Fragment, { children: [_jsx("span", { className: "field-label sign-in-fact", children: fact.label }), _jsx("p", { className: "sign-in-fact-value dialog-value", ...cutTooltip(fact.value), children: fact.value })] }, fact.label))), _jsx("label", { className: "field-label", htmlFor: `${ids}-secret`, children: secretLabel }), _jsxs("div", { className: "field-value", children: [_jsx("input", { "aria-describedby": rejection === null ? undefined : `${ids}-note`, "aria-invalid": rejection === null ? undefined : true, autoComplete: "off", className: "field sign-in-field", id: `${ids}-secret`, onChange: (event) => setValue(event.target.value), ref: field, spellCheck: false, type: "password", value: value }), children, rejection !== null && (_jsx("p", { className: "field-problem", id: `${ids}-note`, role: "alert", children: rejection }))] })] }) }));
27
+ }
28
+ /**
29
+ * A host key the computer has not seen before, as a confirmation read at a
30
+ * glance: the lead says why it asks and when to trust it, the host is the
31
+ * one item, and then the key's type and its whole fingerprint in a framed
32
+ * well. The verb answers yes, Cancel no.
33
+ */
34
+ export function HostKeyDialog({ title, message, confirmLabel, host, keyType, fingerprint, onTrust, onCancel }) {
35
+ return (_jsx(ConfirmDialog, { confirmLabel: confirmLabel, icon: ShieldQuestionMark, itemIcon: Server, items: [host], message: message, onCancel: onCancel, onConfirm: onTrust, title: title, tone: "primary", children: _jsxs("dl", { className: "sign-in-fingerprint", children: [_jsx("dt", { className: "dialog-value", children: keyType }), _jsx("dd", { className: "dialog-value", children: fingerprint })] }) }));
36
+ }
@@ -0,0 +1,74 @@
1
+ import type { ReactElement } from 'react';
2
+ import type { AppearanceMode } from '../labels/settings.js';
3
+ import { type AppearanceThemes, type ThemeAppearance } from '../themes/ids.js';
4
+ /**
5
+ * Whether the system's appearance, as the page sees it, is dark now,
6
+ * following each change. A page with no `matchMedia` reads as light.
7
+ */
8
+ export declare function useSystemDark(): boolean;
9
+ /**
10
+ * A theme's miniature window, painted in that theme's own colours whatever
11
+ * the page wears (the preview tokens under `data-theme-preview`): the
12
+ * header strip with its window buttons, a sidebar with the cursor row lit,
13
+ * and a panel with a line of text, a quieter line, a primary chip beside an
14
+ * accent mark, and a row of the theme's ANSI colours. Drawn for the eye
15
+ * only; the option's name says which theme it is.
16
+ */
17
+ export declare function ThemePreview({ id }: {
18
+ readonly id: string;
19
+ }): ReactElement;
20
+ /** A theme a picker offers: its id and display name. */
21
+ export interface ThemeChoice {
22
+ readonly id: string;
23
+ readonly name: string;
24
+ }
25
+ /** Props for {@link ThemeChoices}. */
26
+ export interface ThemeChoicesProps {
27
+ /** The themes, in the order the picker lists them. */
28
+ readonly themes: readonly ThemeChoice[];
29
+ /** The chosen theme's id. */
30
+ readonly value: string;
31
+ /** Hears a new choice, never the one already chosen. */
32
+ readonly onChange: (id: string) => void;
33
+ /** The id of the group's label; or `label` names it. */
34
+ readonly labelId?: string;
35
+ /** The group's name where no element labels it. */
36
+ readonly label?: string;
37
+ /** The ids of what describes the group (whether it is in use now, when it shows). */
38
+ readonly describedBy?: string;
39
+ /** Marks the chosen theme for `SettingsDialog` to bring into view as the page opens. */
40
+ readonly reveal?: boolean;
41
+ }
42
+ /**
43
+ * One appearance's themes as a radio group of miniatures (`ThemePreview`),
44
+ * each with its name under it: one Tab stop (the chosen theme), the arrow
45
+ * keys moving the choice through every theme, wrapping at the ends, with
46
+ * the focus following it. A choice applies at once.
47
+ */
48
+ export declare function ThemeChoices({ themes, value, onChange, labelId, label, describedBy, reveal }: ThemeChoicesProps): ReactElement;
49
+ /** The themes of one appearance from the catalog, in its order. */
50
+ export declare const themesOf: (appearance: ThemeAppearance) => readonly ThemeChoice[];
51
+ /** Props for {@link AppearanceSettings}. */
52
+ export interface AppearanceSettingsProps {
53
+ /** Which appearance the windows wear, as last saved. */
54
+ readonly mode: AppearanceMode;
55
+ /** Saves and applies a new appearance. */
56
+ readonly onModeChange: (mode: AppearanceMode) => void;
57
+ /** The theme each appearance wears, as last saved. */
58
+ readonly themes: AppearanceThemes;
59
+ /** Saves the theme one appearance wears; `id` is always one of that appearance's themes. */
60
+ readonly onThemeChange: (appearance: ThemeAppearance, id: string) => void;
61
+ /** The subsection's id in the page's `subsections`; `theme` unless given. */
62
+ readonly subsectionId?: string;
63
+ }
64
+ /**
65
+ * The Appearance page's Theme subsection: which appearance the windows wear
66
+ * (System follows the operating system's), its note following the choice
67
+ * and the system, then each appearance's theme as a grid of miniatures
68
+ * (`ThemeChoices`), the band in use now marked so a dark theme picked while
69
+ * the window is light reads as waiting rather than ignored. When a band
70
+ * shows is the label's tooltip, read with the themes. The host holds every
71
+ * value and saves each change, which applies at once. Words from
72
+ * `UiokLabels.settings.appearance`.
73
+ */
74
+ export declare function AppearanceSettings({ mode, onModeChange, themes, onThemeChange, subsectionId }: AppearanceSettingsProps): ReactElement;
@@ -0,0 +1,96 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from 'react';
3
+ import { useLabels } from '../labels/UiokProvider.js';
4
+ import { SegmentedChoice } from '../segmented/SegmentedChoice.js';
5
+ import { THEME_ENTRIES, THEME_PREVIEW_ATTRIBUTE } from '../themes/ids.js';
6
+ import { tooltip } from '../tooltip/Tooltip.logic.js';
7
+ import { SettingsSubsection, SETTINGS_REVEAL_ATTRIBUTE } from './SettingsSubsection.js';
8
+ import { appearanceInUse, steppedIndex } from './ThemePicker.logic.js';
9
+ const DARK_QUERY = '(prefers-color-scheme: dark)';
10
+ /**
11
+ * Whether the system's appearance, as the page sees it, is dark now,
12
+ * following each change. A page with no `matchMedia` reads as light.
13
+ */
14
+ export function useSystemDark() {
15
+ const [dark, setDark] = useState(() => window.matchMedia?.(DARK_QUERY).matches ?? false);
16
+ useEffect(() => {
17
+ const query = window.matchMedia?.(DARK_QUERY);
18
+ if (!query) {
19
+ return undefined;
20
+ }
21
+ const follow = () => setDark(query.matches);
22
+ follow();
23
+ query.addEventListener('change', follow);
24
+ return () => query.removeEventListener('change', follow);
25
+ }, []);
26
+ return dark;
27
+ }
28
+ /**
29
+ * A theme's miniature window, painted in that theme's own colours whatever
30
+ * the page wears (the preview tokens under `data-theme-preview`): the
31
+ * header strip with its window buttons, a sidebar with the cursor row lit,
32
+ * and a panel with a line of text, a quieter line, a primary chip beside an
33
+ * accent mark, and a row of the theme's ANSI colours. Drawn for the eye
34
+ * only; the option's name says which theme it is.
35
+ */
36
+ export function ThemePreview({ id }) {
37
+ return (_jsxs("span", { "aria-hidden": true, className: "theme-preview", [THEME_PREVIEW_ATTRIBUTE]: id, children: [_jsx("span", { className: "theme-preview-header", children: _jsxs("span", { className: "theme-preview-lights", children: [_jsx("span", {}), _jsx("span", {}), _jsx("span", {})] }) }), _jsxs("span", { className: "theme-preview-body", children: [_jsxs("span", { className: "theme-preview-sidebar", children: [_jsx("span", { className: "theme-preview-row lit" }), _jsx("span", { className: "theme-preview-row" }), _jsx("span", { className: "theme-preview-row" })] }), _jsxs("span", { className: "theme-preview-panel", children: [_jsx("span", { className: "theme-preview-line text" }), _jsx("span", { className: "theme-preview-line dim" }), _jsxs("span", { className: "theme-preview-chips", children: [_jsx("span", { className: "theme-preview-chip primary" }), _jsx("span", { className: "theme-preview-chip accent" })] }), _jsx("span", { className: "theme-preview-swatches", children: [1, 2, 3, 4, 5, 6].map((index) => (_jsx("span", { className: `theme-preview-swatch ansi-${index}` }, index))) })] })] })] }));
38
+ }
39
+ /**
40
+ * One appearance's themes as a radio group of miniatures (`ThemePreview`),
41
+ * each with its name under it: one Tab stop (the chosen theme), the arrow
42
+ * keys moving the choice through every theme, wrapping at the ends, with
43
+ * the focus following it. A choice applies at once.
44
+ */
45
+ export function ThemeChoices({ themes, value, onChange, labelId, label, describedBy, reveal = false }) {
46
+ const group = useRef(null);
47
+ const choose = (id) => {
48
+ if (id !== value)
49
+ onChange(id);
50
+ };
51
+ const step = (event) => {
52
+ const index = steppedIndex(event.key, themes.findIndex((theme) => theme.id === value), themes.length);
53
+ const next = index === null ? undefined : themes[index];
54
+ if (index === null || next === undefined) {
55
+ return;
56
+ }
57
+ event.preventDefault();
58
+ choose(next.id);
59
+ group.current?.querySelectorAll('[role="radio"]')[index]?.focus();
60
+ };
61
+ return (_jsx("div", { "aria-describedby": describedBy, "aria-label": labelId === undefined ? label : undefined, "aria-labelledby": labelId, className: "theme-choices", onKeyDown: step, ref: group, role: "radiogroup", children: themes.map((theme) => (_jsxs("button", { "aria-checked": theme.id === value, className: "theme-choice", onClick: () => choose(theme.id), role: "radio", tabIndex: theme.id === value ? 0 : -1, type: "button", ...(reveal && theme.id === value ? { [SETTINGS_REVEAL_ATTRIBUTE]: '' } : {}), children: [_jsx("span", { className: "theme-choice-frame", children: _jsx(ThemePreview, { id: theme.id }) }), _jsx("span", { className: "theme-choice-name", "data-name": theme.name, children: theme.name })] }, theme.id))) }));
62
+ }
63
+ /** The themes of one appearance from the catalog, in its order. */
64
+ export const themesOf = (appearance) => THEME_ENTRIES.filter((entry) => entry.appearance === appearance);
65
+ /** The appearances whose themes the page lists, in its order. */
66
+ const APPEARANCES = ['light', 'dark'];
67
+ /** The appearance choices, in the segmented control's order. */
68
+ const MODES = ['system', 'light', 'dark'];
69
+ /**
70
+ * The Appearance page's Theme subsection: which appearance the windows wear
71
+ * (System follows the operating system's), its note following the choice
72
+ * and the system, then each appearance's theme as a grid of miniatures
73
+ * (`ThemeChoices`), the band in use now marked so a dark theme picked while
74
+ * the window is light reads as waiting rather than ignored. When a band
75
+ * shows is the label's tooltip, read with the themes. The host holds every
76
+ * value and saves each change, which applies at once. Words from
77
+ * `UiokLabels.settings.appearance`.
78
+ */
79
+ export function AppearanceSettings({ mode, onModeChange, themes, onThemeChange, subsectionId = 'theme' }) {
80
+ const labels = useLabels().settings.appearance;
81
+ const systemDark = useSystemDark();
82
+ const inUse = appearanceInUse(mode, systemDark);
83
+ const ids = useId();
84
+ const modeLabelId = `${ids}-mode`;
85
+ return (_jsx(SettingsSubsection, { id: subsectionId, title: labels.title, children: _jsxs("div", { className: "field-grid", children: [_jsx("span", { className: "field-label", id: modeLabelId, children: labels.mode }), _jsxs("div", { className: "field-value", children: [_jsx("div", { className: "field-option", children: _jsx(SegmentedChoice, { choices: MODES, labelId: modeLabelId, onChange: onModeChange, render: (choice) => labels.modes[choice], value: mode }) }), _jsx("p", { className: "field-note", children: labels.modeNote(mode, systemDark) })] }), APPEARANCES.map((appearance) => {
86
+ const labelId = `${ids}-${appearance}`;
87
+ const noteId = `${labelId}-note`;
88
+ const note = appearance === 'light' ? labels.lightNote : labels.darkNote;
89
+ const used = inUse === appearance;
90
+ return (_jsx(ThemeBand, { describedBy: used ? `${labelId}-in-use ${noteId}` : noteId, inUse: used ? labels.inUse : null, label: appearance === 'light' ? labels.lightTheme : labels.darkTheme, labelId: labelId, note: note, noteId: noteId, onChange: (id) => onThemeChange(appearance, id), themes: themesOf(appearance), value: themes[appearance] }, appearance));
91
+ })] }) }));
92
+ }
93
+ /** One appearance's band: its label, marked while in use, and its themes. */
94
+ function ThemeBand({ label, labelId, inUse, note, noteId, describedBy, themes, value, onChange }) {
95
+ return (_jsxs(_Fragment, { children: [_jsxs("span", { className: "field-label", ...tooltip(note), children: [_jsx("span", { id: labelId, children: label }), inUse === null ? null : (_jsx("span", { className: "settings-label-detail", id: `${labelId}-in-use`, children: inUse }))] }), _jsxs("div", { className: "field-value", children: [_jsx(ThemeChoices, { describedBy: describedBy, labelId: labelId, onChange: onChange, reveal: inUse !== null, themes: themes, value: value }), _jsx("p", { className: "visually-hidden", id: noteId, children: note })] })] }));
96
+ }
@@ -0,0 +1,13 @@
1
+ import type { AppearanceMode } from '../labels/settings.js';
2
+ import type { ThemeAppearance } from '../themes/ids.js';
3
+ /**
4
+ * Where an arrow key moves the choice in a radio group of `count` options
5
+ * from `index`: Right and Down to the next, Left and Up to the previous,
6
+ * wrapping at either end. Null for any other key.
7
+ */
8
+ export declare function steppedIndex(key: string, index: number, count: number): number | null;
9
+ /**
10
+ * The appearance the window wears now: the one chosen, or, while it follows
11
+ * the system, the one the system uses (`systemDark`).
12
+ */
13
+ export declare function appearanceInUse(mode: AppearanceMode, systemDark: boolean): ThemeAppearance;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Where an arrow key moves the choice in a radio group of `count` options
3
+ * from `index`: Right and Down to the next, Left and Up to the previous,
4
+ * wrapping at either end. Null for any other key.
5
+ */
6
+ export function steppedIndex(key, index, count) {
7
+ const delta = key === 'ArrowRight' || key === 'ArrowDown'
8
+ ? 1
9
+ : key === 'ArrowLeft' || key === 'ArrowUp'
10
+ ? -1
11
+ : 0;
12
+ if (delta === 0 || count === 0) {
13
+ return null;
14
+ }
15
+ return (index + delta + count) % count;
16
+ }
17
+ /**
18
+ * The appearance the window wears now: the one chosen, or, while it follows
19
+ * the system, the one the system uses (`systemDark`).
20
+ */
21
+ export function appearanceInUse(mode, systemDark) {
22
+ if (mode === 'system') {
23
+ return systemDark ? 'dark' : 'light';
24
+ }
25
+ return mode;
26
+ }