@bigpixelrocket/uiok 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -1
- package/dist/button/TextLink.d.ts +19 -3
- package/dist/button/TextLink.js +4 -3
- package/dist/dialog/ConfirmDialog.d.ts +7 -1
- package/dist/dialog/ConfirmDialog.js +2 -2
- package/dist/dialog/ModalDialog.js +8 -2
- package/dist/dialog/ProgressDialog.d.ts +7 -1
- package/dist/dialog/ProgressDialog.js +2 -2
- package/dist/dialog/TypedNameDialog.d.ts +8 -0
- package/dist/field/Check.d.ts +9 -2
- package/dist/field/Check.js +5 -4
- package/dist/field/Controls.d.ts +198 -0
- package/dist/field/Controls.js +94 -0
- package/dist/field/FieldLayout.d.ts +126 -0
- package/dist/field/FieldLayout.js +89 -0
- package/dist/field/index.d.ts +9 -6
- package/dist/field/index.js +9 -6
- package/dist/frame/Dock.js +1 -1
- package/dist/frame/SidebarResizer.js +1 -1
- package/dist/frame/Tree.d.ts +17 -4
- package/dist/frame/Tree.js +34 -9
- package/dist/frame/WindowFrame.js +2 -1
- package/dist/frame/frame.css +26 -4
- package/dist/icon/ProductMark.d.ts +57 -0
- package/dist/icon/ProductMark.js +26 -0
- package/dist/icon/icon.css +53 -0
- package/dist/icon/index.d.ts +3 -1
- package/dist/icon/index.js +3 -1
- package/dist/labels/UiokLabels.d.ts +3 -0
- package/dist/labels/UiokLabels.js +3 -1
- package/dist/labels/index.d.ts +1 -0
- package/dist/labels/index.js +1 -0
- package/dist/labels/settings.d.ts +6 -0
- package/dist/labels/settings.js +1 -0
- package/dist/labels/viewer.d.ts +193 -0
- package/dist/labels/viewer.js +124 -0
- package/dist/listing/Listing.d.ts +60 -4
- package/dist/listing/Listing.js +39 -10
- package/dist/listing/ListingScope.d.ts +7 -0
- package/dist/listing/ListingScope.js +8 -0
- package/dist/listing/PaneMessage.d.ts +28 -0
- package/dist/listing/PaneMessage.js +12 -0
- package/dist/listing/Timeline.d.ts +51 -0
- package/dist/listing/Timeline.js +28 -0
- package/dist/listing/index.d.ts +7 -3
- package/dist/listing/index.js +6 -2
- package/dist/listing/listing.css +185 -22
- package/dist/log/Ansi.logic.d.ts +27 -0
- package/dist/log/Ansi.logic.js +203 -0
- package/dist/log/LogWell.d.ts +11 -2
- package/dist/log/LogWell.js +15 -3
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.js +1 -0
- package/dist/log/log.css +80 -0
- package/dist/menu/Menu.d.ts +89 -0
- package/dist/menu/Menu.js +143 -0
- package/dist/menu/Menu.logic.d.ts +56 -0
- package/dist/menu/Menu.logic.js +64 -0
- package/dist/menu/index.d.ts +5 -1
- package/dist/menu/index.js +5 -1
- package/dist/menu/menu.css +51 -0
- package/dist/palette/Palette.d.ts +3 -2
- package/dist/palette/Palette.js +8 -4
- package/dist/palette/PaletteRows.d.ts +129 -0
- package/dist/palette/PaletteRows.js +74 -0
- package/dist/palette/index.d.ts +5 -2
- package/dist/palette/index.js +5 -2
- package/dist/pane/PaneFrame.d.ts +22 -1
- package/dist/pane/PaneFrame.js +42 -5
- package/dist/pane/index.d.ts +1 -1
- package/dist/shell/SettingsDialog.d.ts +20 -2
- package/dist/shell/SettingsDialog.js +13 -3
- package/dist/shell/index.d.ts +1 -1
- package/dist/styles.css +4 -0
- package/dist/surface/Card.d.ts +18 -0
- package/dist/surface/Card.js +10 -0
- package/dist/surface/FactTable.d.ts +44 -0
- package/dist/surface/FactTable.js +33 -0
- package/dist/surface/Notice.d.ts +45 -0
- package/dist/surface/Notice.js +27 -0
- package/dist/surface/index.d.ts +7 -3
- package/dist/surface/index.js +7 -3
- package/dist/surface/surface.css +64 -0
- package/dist/tabs/PageTabs.d.ts +6 -0
- package/dist/tabs/PageTabs.js +1 -1
- package/dist/tabs/tabs.css +14 -0
- package/dist/terminal/TerminalBox.d.ts +30 -0
- package/dist/terminal/TerminalBox.js +17 -0
- package/dist/terminal/index.d.ts +3 -1
- package/dist/terminal/index.js +3 -1
- package/dist/terminal/terminal.css +29 -0
- package/dist/themes/themes.generated.css +21 -0
- package/dist/themes/tokens.d.ts +1 -0
- package/dist/themes/tokens.js +16 -1
- package/dist/viewer/AudioView.d.ts +13 -0
- package/dist/viewer/AudioView.js +25 -0
- package/dist/viewer/HexJump.logic.d.ts +16 -0
- package/dist/viewer/HexJump.logic.js +27 -0
- package/dist/viewer/HexRows.logic.d.ts +55 -0
- package/dist/viewer/HexRows.logic.js +84 -0
- package/dist/viewer/HexSelection.logic.d.ts +57 -0
- package/dist/viewer/HexSelection.logic.js +68 -0
- package/dist/viewer/HexView.d.ts +10 -0
- package/dist/viewer/HexView.js +291 -0
- package/dist/viewer/HexViewport.logic.d.ts +61 -0
- package/dist/viewer/HexViewport.logic.js +79 -0
- package/dist/viewer/ImageView.d.ts +19 -0
- package/dist/viewer/ImageView.js +230 -0
- package/dist/viewer/ImageZoom.logic.d.ts +65 -0
- package/dist/viewer/ImageZoom.logic.js +119 -0
- package/dist/viewer/LatestRead.logic.d.ts +27 -0
- package/dist/viewer/LatestRead.logic.js +55 -0
- package/dist/viewer/MediaControls.d.ts +25 -0
- package/dist/viewer/MediaControls.js +183 -0
- package/dist/viewer/MediaPlayer.logic.d.ts +53 -0
- package/dist/viewer/MediaPlayer.logic.js +68 -0
- package/dist/viewer/PdfView.d.ts +23 -0
- package/dist/viewer/PdfView.js +25 -0
- package/dist/viewer/QuietFocus.d.ts +19 -0
- package/dist/viewer/QuietFocus.js +27 -0
- package/dist/viewer/ScaledScroll.logic.d.ts +30 -0
- package/dist/viewer/ScaledScroll.logic.js +28 -0
- package/dist/viewer/ScaledScrollbar.d.ts +19 -0
- package/dist/viewer/ScaledScrollbar.js +71 -0
- package/dist/viewer/SyntaxHighlighter.d.ts +29 -0
- package/dist/viewer/SyntaxHighlighter.js +144 -0
- package/dist/viewer/SyntaxLanguage.logic.d.ts +110 -0
- package/dist/viewer/SyntaxLanguage.logic.js +283 -0
- package/dist/viewer/SyntaxService.d.ts +75 -0
- package/dist/viewer/SyntaxService.js +49 -0
- package/dist/viewer/SyntaxSession.logic.d.ts +78 -0
- package/dist/viewer/SyntaxSession.logic.js +221 -0
- package/dist/viewer/SyntaxWorker.d.ts +6 -0
- package/dist/viewer/SyntaxWorker.js +8 -0
- package/dist/viewer/TextEncoding.logic.d.ts +35 -0
- package/dist/viewer/TextEncoding.logic.js +58 -0
- package/dist/viewer/TextRows.logic.d.ts +86 -0
- package/dist/viewer/TextRows.logic.js +241 -0
- package/dist/viewer/TextSelection.logic.d.ts +97 -0
- package/dist/viewer/TextSelection.logic.js +139 -0
- package/dist/viewer/TextView.d.ts +13 -0
- package/dist/viewer/TextView.js +448 -0
- package/dist/viewer/TextViewport.logic.d.ts +70 -0
- package/dist/viewer/TextViewport.logic.js +116 -0
- package/dist/viewer/VideoView.d.ts +18 -0
- package/dist/viewer/VideoView.js +53 -0
- package/dist/viewer/ViewerClipboard.d.ts +30 -0
- package/dist/viewer/ViewerClipboard.js +70 -0
- package/dist/viewer/ViewerFrame.logic.d.ts +61 -0
- package/dist/viewer/ViewerFrame.logic.js +130 -0
- package/dist/viewer/ViewerKeys.d.ts +16 -0
- package/dist/viewer/ViewerKeys.js +14 -0
- package/dist/viewer/ViewerScope.d.ts +12 -0
- package/dist/viewer/ViewerScope.js +22 -0
- package/dist/viewer/ViewerViews.d.ts +28 -0
- package/dist/viewer/ViewerViews.js +22 -0
- package/dist/viewer/ViewerWindow.d.ts +53 -0
- package/dist/viewer/ViewerWindow.js +219 -0
- package/dist/viewer/index.d.ts +12 -0
- package/dist/viewer/index.js +12 -0
- package/dist/viewer/types.d.ts +151 -0
- package/dist/viewer/types.js +26 -0
- package/dist/viewer/useElementHeight.d.ts +6 -0
- package/dist/viewer/useElementHeight.js +22 -0
- package/dist/viewer/useElementSize.d.ts +7 -0
- package/dist/viewer/useElementSize.js +24 -0
- package/dist/viewer/useEscapeToClear.d.ts +8 -0
- package/dist/viewer/useEscapeToClear.js +26 -0
- package/dist/viewer/useHexDocument.d.ts +41 -0
- package/dist/viewer/useHexDocument.js +144 -0
- package/dist/viewer/useMediaElement.d.ts +10 -0
- package/dist/viewer/useMediaElement.js +24 -0
- package/dist/viewer/useSyntaxHighlight.d.ts +24 -0
- package/dist/viewer/useSyntaxHighlight.js +133 -0
- package/dist/viewer/useTextDocument.d.ts +66 -0
- package/dist/viewer/useTextDocument.js +245 -0
- package/dist/viewer/viewer.css +645 -0
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,53 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.5.0] - 2026-11-23
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `Menu` (`@bigpixelrocket/uiok/menu`): a menu of verbs or places opened at a point or dropped from an element, through a portal: items (`MenuItemEntry`) with a glyph or a mark, a chord as key caps, a danger tone, a disabled state with its reason, a check, and the current one's dot; separators and group headings; the keys held while open (↑ ↓, Home, End, Return, Space, Escape, Tab), kept from the browser-key guard and a page's own key handlers (`data-native-keyboard`); a menu taller than the window scrolls, the keys keeping the cursor's item in view. Its pure placement and keys are `placeMenu` and `menuKeyAction`.
|
|
14
|
+
- `PanePathBar`'s `siblings` (`PaneSiblings`): the last crumb becomes a ⌄ button that drops the places beside it (a service's other versions) as a `Menu`, the one shown marked; a pick, a closing key, or a second press gives the focus back to the crumb, even when the pick renames it.
|
|
15
|
+
- Palette rows as components (`@bigpixelrocket/uiok/palette`): `PaletteList`, `PaletteOption` (mark, name, a sentence, path, or command, a trail, the current dot, cursor, disabled; its context, a trail in words, and its current state read as its description unless the caller words one), `PaletteHeading`, `PaletteNote`, `PaletteNotes`, and `PaletteFailure`.
|
|
16
|
+
- `TerminalBox` and `TERMINAL_BOX_HEIGHT` (`@bigpixelrocket/uiok/terminal`): a terminal framed at a fixed height (200px by default, a dialog's console), or filling its parent (a dock).
|
|
17
|
+
- `ProductMark` and `ProductMarkShape` (`@bigpixelrocket/uiok/icon`): a product's brand mark drawn from data the app passes in, with a fallback glyph, and the theme token `--product-mark-mix` (100% in a light theme, 78% in a dark one) that sets how much of the brand colour shows; a mark with no colour of its own and a fallback glyph take a row's icon tone, on the cursor and a selection too.
|
|
18
|
+
- `FactTable`, `FactRow`, and `FactTone` (`@bigpixelrocket/uiok/surface`): a page's short table of facts, a state glyph, name, detail, and value a row.
|
|
19
|
+
- `Cell`'s `tone` (`CellTone`: `warning`, `accent`, `danger`), held on the cursor row and under the pointer; `Row`'s `dim` (a name in the row-meta tone, `.row-dim`) and `add` (the add row's look with its accent plus); `TreeRow`'s `add`, whose plus keeps the accent on the cursor row.
|
|
20
|
+
- `PageTab`'s `count`, drawn after the tab's name and read in its accessible name.
|
|
21
|
+
- `TextLink`'s `disabled` and `label` (an accessible name of its own).
|
|
22
|
+
- `SettingsPage`'s `chip` takes a `SettingsChip` (`text`, `icon`, `tip`) as well as a string, and the `settings` label `pageWithChip`, which names a sidebar row and its chip apart ("Updates, Update to 1.4.4").
|
|
23
|
+
- `TimelineCell` and `TimelineScale` (`@bigpixelrocket/uiok/listing`): a row's span on a shared scale (a wait, then a bar, in the solid accent on the path that matters) and the ticks over its column, its bar and wait in the selection's words on a selected row and its span read once, as its name; `Row`'s `emphasis` puts a row's name in the strong weight.
|
|
24
|
+
- `Row`'s `selected`, `marked`, and `change` (`changed`, `removed`), and `Cell`'s `kind` (`action`, `hover`) and `missing`, so a row's states and a cell's kinds need no class name.
|
|
25
|
+
- `LogWell`'s `ansi`, which draws each line's SGR colours, backgrounds, and weights in the theme's text tones (a dim filled run keeps its fill's paired words) and drops every other escape sequence, control string (OSC, DCS, SOS, PM, APC), and cut-off escape, reading colon subparameters as one parameter and applying no CSI with a private marker or an intermediate, in time linear in the line, over `ansiSegments`, `ANSI_COLOURS`, `AnsiColour`, and `AnsiSegment` (`@bigpixelrocket/uiok/log`).
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- A `ModalDialog`'s box (the Settings dialog's included) and a `Palette`'s box carry the listing scope (`.listing-root`), and a `Listing` drawn outside any scope carries it itself, its own rules matching the listing that carries the scope, so listings, rows, and filter fields keep their look in a dialog, a palette, or anywhere else, in the listing's monospace face. `Palette`'s classes are now `folder-menu palette listing-root`.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- The tree keeps its look where single-class rules lost to others: a chevron off the cursor row draws in the rows' dim icon tone rather than its row's words, a tree note that is also a listing's empty line (`.pane-message.empty`) keeps the tree's small size and padding, and a focused `TreeFilterInput` shows its row's underline without the field focus ring.
|
|
34
|
+
|
|
35
|
+
## [0.4.0] - 2026-11-23
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- The file viewer (`@bigpixelrocket/uiok/viewer`, a new area beside the root, like the terminal): `ViewerWindow` shows one file as text with syntax highlighting and line numbers, hex, image, audio, video, or PDF, reading a bounded range at a time through a `ViewerReader` the app supplies (`inspect`, `readRange`, `reload`, `lineNumber`), with a mode switch, change notices and Reload, fallbacks to hex or source, copy, Go to Offset, zoom, and a media player. `isViewerCloseKey`, `openSyntaxWorker`, `VIEWER_MAX_READ_BYTES`, and the reader's data types. Highlighting runs Shiki on its JavaScript regex engine in a worker the viewer starts itself; each grammar loads only when a file needs it.
|
|
40
|
+
- The `viewer` label group (`ViewerLabels`, `ViewerModeLabels`, `ViewerContentLabels`, `DEFAULT_VIEWER_LABELS`), its number, size, and date formats included.
|
|
41
|
+
- Form components (`@bigpixelrocket/uiok/field`), so an app draws a form with no class name or raw element: `TextField`, `TextArea`, `Select` (`SelectOption`, `SelectOptionGroup`), `FieldBox`, `FieldEditor`, `Radio`, `Range`, `Meter`, `RestoreDefault`; the layout `FieldGrid`, `FieldRow` (wires its control's id, note, problem, invalid state, and help on its own; `useFieldWiring` for a control of the app's), `FieldOption`, `FieldGroup`, `FieldNote`, `FieldProblem`. `Check` takes a `label` and a `tone`.
|
|
42
|
+
- `Notice` and `Card` (`@bigpixelrocket/uiok/surface`), and `PaneMessage` (`@bigpixelrocket/uiok/listing`): the `.notice`, `.card`, and `.pane-message` looks as components.
|
|
43
|
+
- `TreeTool` takes a `rowKey`, which joins it to the pane's row cursor as a `TreeRow` is, as a `treeitem`.
|
|
44
|
+
- `ProgressDialog`, `ConfirmDialog`, and `TypedNameDialog` take a `container`; `TypedNameDialog` takes `groups`.
|
|
45
|
+
- Theme token `--letterbox` (a video's letterbox, black in every theme).
|
|
46
|
+
|
|
47
|
+
### Changed
|
|
48
|
+
|
|
49
|
+
- Breaking: uiok now defines `--letterbox`, so `themeStylesheet` refuses an app token of that name. An app that wrote it as its own token drops it; the value is the same.
|
|
50
|
+
- `SidebarResizer` and `Dock`'s edge no longer set `aria-valuenow`, `aria-valuemin`, or `aria-valuemax`: they take no focus, so a screen reader could not change the value it offered.
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- `TreeList` mounted inside a shadow root keeps its `aria-activedescendant`: it finds the cursor row in its own root, not the document. A tree mounted in an element not yet attached no longer throws.
|
|
55
|
+
|
|
9
56
|
## [0.3.0] - 2026-11-23
|
|
10
57
|
|
|
11
58
|
### Added
|
|
@@ -224,7 +271,9 @@ The first published version. The package is published to npm as `@bigpixelrocket
|
|
|
224
271
|
- `lucide-react` 1.31 or later within 1.x is a peer dependency.
|
|
225
272
|
- Terminal (`@bigpixelrocket/uiok/terminal`, `docs/components/terminal.md`): `Terminal`, Ghostty's VT engine as WebAssembly drawn on a canvas, read-only without `onInput`, with a Copy and Paste menu whose chords come from `menuChords`, a visual bell, line-editing actions bound by `actionForKey`, and `TerminalScrollbackContext`. The package root does not export it, so an app without a terminal never loads its assets. Its words are the new `terminal` label group; the package now ships a `NOTICE` with the engine's, adapter's, and font's licences.
|
|
226
273
|
|
|
227
|
-
[Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.
|
|
274
|
+
[Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.5.0...HEAD
|
|
275
|
+
[0.5.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.4.0...v0.5.0
|
|
276
|
+
[0.4.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.3.0...v0.4.0
|
|
228
277
|
[0.3.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.3...v0.3.0
|
|
229
278
|
[0.2.3]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.2...v0.2.3
|
|
230
279
|
[0.2.2]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.1...v0.2.2
|
|
@@ -2,8 +2,23 @@ import type { LucideIcon } from 'lucide-react';
|
|
|
2
2
|
import type { ReactElement } from 'react';
|
|
3
3
|
/** Props for {@link TextLink}. */
|
|
4
4
|
export interface TextLinkProps {
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* The link's words, which are also its accessible name unless `label`
|
|
7
|
+
* gives one: "DROP DATABASE in the manual".
|
|
8
|
+
*/
|
|
6
9
|
readonly children: string;
|
|
10
|
+
/**
|
|
11
|
+
* The accessible name, when the words alone do not say what the link
|
|
12
|
+
* opens: "View the whole log" for a strip's "View". The words stay what
|
|
13
|
+
* the eye reads; the name is what a screen reader says.
|
|
14
|
+
*/
|
|
15
|
+
readonly label?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Refuses the press for now (nothing to open yet): the words dim, the
|
|
18
|
+
* pointer underlines nothing, and the link leaves the Tab order, as
|
|
19
|
+
* every disabled button does.
|
|
20
|
+
*/
|
|
21
|
+
readonly disabled?: boolean;
|
|
7
22
|
/** What it opens: the host opens the manual page, the place, or the window. */
|
|
8
23
|
readonly onClick: () => void;
|
|
9
24
|
/** A glyph before the words (a book for a manual page), at the small icon size. */
|
|
@@ -21,7 +36,8 @@ export interface TextLinkProps {
|
|
|
21
36
|
* It wears the accent's text colour and underlines under the pointer; it
|
|
22
37
|
* takes the keyboard's focus with the shared ring. It is a button because
|
|
23
38
|
* the host decides how to open what it names (an external browser, a tab),
|
|
24
|
-
* so it never navigates the page itself.
|
|
39
|
+
* so it never navigates the page itself. A `disabled` link dims and
|
|
40
|
+
* refuses the press; `label` names it when its words are short. Styled by `.text-link` in
|
|
25
41
|
* `@bigpixelrocket/uiok/styles.css`.
|
|
26
42
|
*/
|
|
27
|
-
export declare function TextLink({ children, onClick, icon: Icon, code, tip, shortcut }: TextLinkProps): ReactElement;
|
|
43
|
+
export declare function TextLink({ children, onClick, icon: Icon, code, tip, shortcut, label, disabled }: TextLinkProps): ReactElement;
|
package/dist/button/TextLink.js
CHANGED
|
@@ -7,9 +7,10 @@ import { tooltip } from '../tooltip/Tooltip.logic.js';
|
|
|
7
7
|
* It wears the accent's text colour and underlines under the pointer; it
|
|
8
8
|
* takes the keyboard's focus with the shared ring. It is a button because
|
|
9
9
|
* the host decides how to open what it names (an external browser, a tab),
|
|
10
|
-
* so it never navigates the page itself.
|
|
10
|
+
* so it never navigates the page itself. A `disabled` link dims and
|
|
11
|
+
* refuses the press; `label` names it when its words are short. Styled by `.text-link` in
|
|
11
12
|
* `@bigpixelrocket/uiok/styles.css`.
|
|
12
13
|
*/
|
|
13
|
-
export function TextLink({ children, onClick, icon: Icon, code = false, tip, shortcut }) {
|
|
14
|
-
return (_jsxs("button", { className: code ? 'text-link code' : 'text-link', onClick: onClick, type: "button", ...(tip === undefined && shortcut === undefined ? {} : tooltip(tip ?? children, shortcut)), children: [Icon === undefined ? null : _jsx(Icon, { "aria-hidden": true, size: ICON_SM }), _jsx("span", { className: "text-link-words", children: children })] }));
|
|
14
|
+
export function TextLink({ children, onClick, icon: Icon, code = false, tip, shortcut, label, disabled = false }) {
|
|
15
|
+
return (_jsxs("button", { "aria-label": label, className: code ? 'text-link code' : 'text-link', disabled: disabled, onClick: onClick, type: "button", ...(tip === undefined && shortcut === undefined ? {} : tooltip(tip ?? children, shortcut)), children: [Icon === undefined ? null : _jsx(Icon, { "aria-hidden": true, size: ICON_SM }), _jsx("span", { className: "text-link-words", children: children })] }));
|
|
15
16
|
}
|
|
@@ -63,6 +63,12 @@ export interface ConfirmDialogProps {
|
|
|
63
63
|
* count above the same framed list. Drawn after `items`.
|
|
64
64
|
*/
|
|
65
65
|
readonly groups?: readonly DialogItemGroup[];
|
|
66
|
+
/**
|
|
67
|
+
* The element the dialog mounts into, for a dialog that must paint above
|
|
68
|
+
* something it is drawn inside; the enclosing `DialogLayer` otherwise
|
|
69
|
+
* (`ModalDialog`'s `container`).
|
|
70
|
+
*/
|
|
71
|
+
readonly container?: Element;
|
|
66
72
|
/**
|
|
67
73
|
* The statements the action runs (a batch of SQL), every one of them,
|
|
68
74
|
* under its own short label: `{ label: 'SQL', lines }`. Drawn whole,
|
|
@@ -135,4 +141,4 @@ export interface ConfirmDialogProps {
|
|
|
135
141
|
* describe it. Styled by the `.confirm-dialog` rules in
|
|
136
142
|
* `@bigpixelrocket/uiok/styles.css`; reads the `dialog` labels.
|
|
137
143
|
*/
|
|
138
|
-
export declare function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone, items, itemIcon, itemCount, groups, statements, facts, paths, children, className, size, alternative, forGood, confirmDisabled, onConfirm, onCancel }: ConfirmDialogProps): ReactElement;
|
|
144
|
+
export declare function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone, items, itemIcon, itemCount, groups, statements, facts, paths, children, className, size, alternative, forGood, confirmDisabled, onConfirm, onCancel, container }: ConfirmDialogProps): ReactElement;
|
|
@@ -21,7 +21,7 @@ const DELETE_IMMEDIATELY = { key: 'Backspace', meta: true, alt: true };
|
|
|
21
21
|
* describe it. Styled by the `.confirm-dialog` rules in
|
|
22
22
|
* `@bigpixelrocket/uiok/styles.css`; reads the `dialog` labels.
|
|
23
23
|
*/
|
|
24
|
-
export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone = 'danger', items, itemIcon, itemCount, groups = [], statements, facts = [], paths, children, className, size, alternative, forGood = false, confirmDisabled = false, onConfirm, onCancel }) {
|
|
24
|
+
export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon, tone = 'danger', items, itemIcon, itemCount, groups = [], statements, facts = [], paths, children, className, size, alternative, forGood = false, confirmDisabled = false, onConfirm, onCancel, container }) {
|
|
25
25
|
const labels = useLabels().dialog;
|
|
26
26
|
const labelId = useId();
|
|
27
27
|
const messageId = useId();
|
|
@@ -46,7 +46,7 @@ export function ConfirmDialog({ title, message, confirmLabel, cancelLabel, icon,
|
|
|
46
46
|
}
|
|
47
47
|
: { label: confirmLabel, onRun: onConfirm, disabled: confirmDisabled }
|
|
48
48
|
};
|
|
49
|
-
return (_jsxs(ModalDialog, { className: ['confirm-dialog', hasItems || hasStatements ? 'confirm-items' : null, className]
|
|
49
|
+
return (_jsxs(ModalDialog, { container: container, className: ['confirm-dialog', hasItems || hasStatements ? 'confirm-items' : null, className]
|
|
50
50
|
.filter(Boolean)
|
|
51
51
|
.join(' '), describedBy: describedBy, icon: icon, labelId: labelId, legend: legend, onCancel: onCancel, size: size, title: title, tone: tone === 'primary' ? 'accent' : tone, children: [hasMessage && (_jsx("p", { className: "dialog-message", id: messageId, children: message })), hasItems && (_jsxs("div", { className: "confirm-items-lists", id: itemsId, children: [list.length > 0 && _jsx(DialogItems, { count: itemCount, icon: itemIcon, items: list }), groups.map((group) => (_jsx(DialogItems, { count: group.count, icon: group.icon, items: group.items, label: group.label }, group.label)))] })), hasStatements && (_jsx(DialogStatements, { label: statements.label, lines: statements.lines, ...(statements.count === undefined ? {} : { count: statements.count }) })), facts.length > 0 && _jsx(DialogFacts, { facts: facts, id: factsId }), children] }));
|
|
52
52
|
}
|
|
@@ -3,6 +3,7 @@ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, use
|
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import { isKeyKept } from '../keyboard/BrowserKeys.js';
|
|
5
5
|
import { isTextEditingTarget } from '../keyboard/Keyboard.logic.js';
|
|
6
|
+
import { ListingScopeContext } from '../listing/ListingScope.js';
|
|
6
7
|
import { cutTooltip } from '../tooltip/Tooltip.logic.js';
|
|
7
8
|
import { DialogLayerContext } from './DialogLayer.js';
|
|
8
9
|
import { DialogLegend } from './DialogLegend.js';
|
|
@@ -156,7 +157,12 @@ function DialogFrame({ title, labelId, describedBy, className, size, icon: Icon,
|
|
|
156
157
|
containTab(event, dialogRef.current);
|
|
157
158
|
}
|
|
158
159
|
};
|
|
159
|
-
return (_jsx("div", { className: frosted ? 'dialog-backdrop frosted' : 'dialog-backdrop', onMouseDown: onOutsidePress, children: _jsxs("div", { "aria-describedby": describedBy, "aria-labelledby": labelId, "aria-modal": "true", className: [
|
|
160
|
+
return (_jsx("div", { className: frosted ? 'dialog-backdrop frosted' : 'dialog-backdrop', onMouseDown: onOutsidePress, children: _jsxs("div", { "aria-describedby": describedBy, "aria-labelledby": labelId, "aria-modal": "true", className: [
|
|
161
|
+
'dialog',
|
|
162
|
+
'listing-root',
|
|
163
|
+
size === undefined ? null : `dialog-size-${size}`,
|
|
164
|
+
className
|
|
165
|
+
]
|
|
160
166
|
.filter(Boolean)
|
|
161
167
|
.join(' '), "data-pinned": pinned !== null || undefined, "data-tone": tone, onKeyDown: (event) => {
|
|
162
168
|
// React bubbles events through portals, so a dialog portalled from
|
|
@@ -197,5 +203,5 @@ function DialogFrame({ title, labelId, describedBy, className, size, icon: Icon,
|
|
|
197
203
|
}
|
|
198
204
|
}
|
|
199
205
|
containFocus(event);
|
|
200
|
-
}, onMouseDown: (event) => event.stopPropagation(), ref: dialogRef, role: "dialog", style: pinned === null ? undefined : { ['--dialog-top']: `${pinned}px` }, tabIndex: -1, children: [_jsxs("div", { className: "dialog-heading", children: [Icon && _jsx(Icon, { "aria-hidden": true, className: "dialog-icon" }), _jsx("h2", { id: labelId, ...(typeof title === 'string' ? cutTooltip(title) : {}), children: title })] }), _jsx(NestedFocusContext, { value: claimNestedFocus, children: children }), legend && _jsx(DialogLegend, { legend: legend, onLeave: onCancel })] }) }));
|
|
206
|
+
}, onMouseDown: (event) => event.stopPropagation(), ref: dialogRef, role: "dialog", style: pinned === null ? undefined : { ['--dialog-top']: `${pinned}px` }, tabIndex: -1, children: [_jsxs("div", { className: "dialog-heading", children: [Icon && _jsx(Icon, { "aria-hidden": true, className: "dialog-icon" }), _jsx("h2", { id: labelId, ...(typeof title === 'string' ? cutTooltip(title) : {}), children: title })] }), _jsx(NestedFocusContext, { value: claimNestedFocus, children: _jsx(ListingScopeContext, { value: true, children: children }) }), legend && _jsx(DialogLegend, { legend: legend, onLeave: onCancel })] }) }));
|
|
201
207
|
}
|
|
@@ -20,6 +20,12 @@ export interface ProgressDialogProps {
|
|
|
20
20
|
readonly onTryAgain?: () => void;
|
|
21
21
|
/** What the body holds under the header: the run's lists, notes, or console. */
|
|
22
22
|
readonly children?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The element the dialog mounts into, for a dialog that must paint above
|
|
25
|
+
* something it is drawn inside; the enclosing `DialogLayer` otherwise
|
|
26
|
+
* (`ModalDialog`'s `container`).
|
|
27
|
+
*/
|
|
28
|
+
readonly container?: Element;
|
|
23
29
|
}
|
|
24
30
|
/**
|
|
25
31
|
* The progress dialog of long work: `ModalDialog` at the medium size,
|
|
@@ -31,4 +37,4 @@ export interface ProgressDialogProps {
|
|
|
31
37
|
* The header's glyph and bar carry a failure; a press outside the box
|
|
32
38
|
* never stops the run. Verbs from `UiokLabels.dialog`.
|
|
33
39
|
*/
|
|
34
|
-
export declare function ProgressDialog({ title, icon, run, stopping, onStop, onBackground, onClose, onTryAgain, children }: ProgressDialogProps): ReactElement;
|
|
40
|
+
export declare function ProgressDialog({ title, icon, run, stopping, onStop, onBackground, onClose, onTryAgain, children, container }: ProgressDialogProps): ReactElement;
|
|
@@ -14,7 +14,7 @@ import { ModalDialog } from './ModalDialog.js';
|
|
|
14
14
|
* The header's glyph and bar carry a failure; a press outside the box
|
|
15
15
|
* never stops the run. Verbs from `UiokLabels.dialog`.
|
|
16
16
|
*/
|
|
17
|
-
export function ProgressDialog({ title, icon, run, stopping = false, onStop, onBackground, onClose, onTryAgain, children }) {
|
|
17
|
+
export function ProgressDialog({ title, icon, run, stopping = false, onStop, onBackground, onClose, onTryAgain, children, container }) {
|
|
18
18
|
const labels = useLabels().dialog;
|
|
19
19
|
const labelId = useId();
|
|
20
20
|
const settled = isSettledRun(run.state);
|
|
@@ -31,7 +31,7 @@ export function ProgressDialog({ title, icon, run, stopping = false, onStop, onB
|
|
|
31
31
|
primary: { label: labels.runInBackground, onRun: onBackground, disabled: stopping }
|
|
32
32
|
})
|
|
33
33
|
};
|
|
34
|
-
return (_jsxs(ModalDialog, { className: "dialog-size-md", icon: icon, labelId: labelId, legend: legend, onCancel: () => {
|
|
34
|
+
return (_jsxs(ModalDialog, { className: "dialog-size-md", container: container, icon: icon, labelId: labelId, legend: legend, onCancel: () => {
|
|
35
35
|
if (settled || couldNotStart)
|
|
36
36
|
onClose();
|
|
37
37
|
else if (!stopping)
|
|
@@ -18,6 +18,8 @@ export interface TypedNameDialogProps {
|
|
|
18
18
|
readonly items?: readonly DialogItem[];
|
|
19
19
|
readonly itemIcon?: LucideIcon;
|
|
20
20
|
readonly itemCount?: number;
|
|
21
|
+
/** Labelled lists, each its label and count above a framed list (`ConfirmDialog`'s `groups`). */
|
|
22
|
+
readonly groups?: ConfirmDialogProps['groups'];
|
|
21
23
|
readonly statements?: ConfirmDialogProps['statements'];
|
|
22
24
|
/** Facts about the action (where it runs). */
|
|
23
25
|
readonly facts?: readonly DialogFact[];
|
|
@@ -25,6 +27,12 @@ export interface TypedNameDialogProps {
|
|
|
25
27
|
readonly children?: ReactNode;
|
|
26
28
|
readonly onConfirm: () => void;
|
|
27
29
|
readonly onCancel: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* The element the dialog mounts into, for a dialog that must paint above
|
|
32
|
+
* something it is drawn inside; the enclosing `DialogLayer` otherwise
|
|
33
|
+
* (`ModalDialog`'s `container`).
|
|
34
|
+
*/
|
|
35
|
+
readonly container?: Element;
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
30
38
|
* The typed-name confirmation for work that cannot be undone where a slip
|
package/dist/field/Check.d.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { type InputHTMLAttributes } from 'react';
|
|
1
|
+
import { type InputHTMLAttributes, type ReactElement, type ReactNode } from 'react';
|
|
2
2
|
/** Props of `Check`: a native checkbox's, with `checked` able to say "some". */
|
|
3
3
|
export interface CheckProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type' | 'checked' | 'defaultChecked'> {
|
|
4
4
|
/** On, off, or `'mixed'` for some but not all of what it stands for. */
|
|
5
5
|
checked: boolean | 'mixed';
|
|
6
|
+
/**
|
|
7
|
+
* Its words, beside it in a `field-choice` label, the whole label its
|
|
8
|
+
* target; without them the box stands alone and needs an `aria-label`.
|
|
9
|
+
*/
|
|
10
|
+
label?: ReactNode;
|
|
11
|
+
/** A choice whose effect is destructive (`danger`) or needs care (`warning`). */
|
|
12
|
+
tone?: 'danger' | 'warning';
|
|
6
13
|
}
|
|
7
14
|
/**
|
|
8
15
|
* A checkbox in the shared `.check` look whose state can be mixed. The mixed
|
|
@@ -12,4 +19,4 @@ export interface CheckProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
12
19
|
* `checked` stays `'mixed'`); everything else is the native input.
|
|
13
20
|
* A plain `<input type="checkbox" class="check">` needs no component.
|
|
14
21
|
*/
|
|
15
|
-
export declare function Check({ checked, className, onChange, ...props }: CheckProps):
|
|
22
|
+
export declare function Check({ checked, className, onChange, label, tone, ...props }: CheckProps): ReactElement;
|
package/dist/field/Check.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
/**
|
|
4
4
|
* A checkbox in the shared `.check` look whose state can be mixed. The mixed
|
|
@@ -8,16 +8,17 @@ import { useEffect, useRef } from 'react';
|
|
|
8
8
|
* `checked` stays `'mixed'`); everything else is the native input.
|
|
9
9
|
* A plain `<input type="checkbox" class="check">` needs no component.
|
|
10
10
|
*/
|
|
11
|
-
export function Check({ checked, className, onChange, ...props }) {
|
|
11
|
+
export function Check({ checked, className, onChange, label, tone, ...props }) {
|
|
12
12
|
const ref = useRef(null);
|
|
13
13
|
const mixed = checked === 'mixed';
|
|
14
14
|
useEffect(() => {
|
|
15
15
|
if (ref.current)
|
|
16
16
|
ref.current.indeterminate = mixed;
|
|
17
17
|
});
|
|
18
|
-
|
|
18
|
+
const box = (_jsx("input", { ...props, "aria-checked": mixed ? 'mixed' : undefined, checked: checked === true, className: className ? `check ${className}` : 'check', onChange: (event) => {
|
|
19
19
|
onChange?.(event);
|
|
20
20
|
// A render the owner asks for sets the new state after this.
|
|
21
21
|
event.currentTarget.indeterminate = mixed;
|
|
22
|
-
}, ref: ref, type: "checkbox" }));
|
|
22
|
+
}, "data-tone": tone, ref: ref, type: "checkbox" }));
|
|
23
|
+
return label === undefined ? (box) : (_jsxs("label", { className: "field-choice", children: [box, label] }));
|
|
23
24
|
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import type { LucideIcon } from 'lucide-react';
|
|
2
|
+
import type { ChangeEvent, ComponentPropsWithRef, ReactElement, ReactNode } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* A field's height by where it stands: `md` (28px) in a dialog or a single
|
|
5
|
+
* prompt, `sm` (24px) in a page form, a toolbar, or a settings row, `xs`
|
|
6
|
+
* (20px) inside a row or a path bar.
|
|
7
|
+
*/
|
|
8
|
+
export type FieldSize = 'md' | 'sm' | 'xs';
|
|
9
|
+
/**
|
|
10
|
+
* A field's width: `full`, its column's (the default); `short`, eight
|
|
11
|
+
* characters for a port or a code; `count`, a few digits; `countOrWord`, a
|
|
12
|
+
* count whose empty field reads as a word ("No limit").
|
|
13
|
+
*/
|
|
14
|
+
export type FieldWidth = 'full' | 'short' | 'count' | 'countOrWord';
|
|
15
|
+
/**
|
|
16
|
+
* A field's tone: `warning` a value that works but needs a second look,
|
|
17
|
+
* `accent` a value changed from its default. A problem wins over either.
|
|
18
|
+
*/
|
|
19
|
+
export type FieldTone = 'warning' | 'accent';
|
|
20
|
+
/** The props every field shares, beside its element's own. */
|
|
21
|
+
interface FieldLook {
|
|
22
|
+
/** Its height by place; `md` unless given. */
|
|
23
|
+
readonly size?: FieldSize;
|
|
24
|
+
/** Outlines it in the danger tone; a `FieldRow` with a problem sets it on its own. */
|
|
25
|
+
readonly invalid?: boolean;
|
|
26
|
+
/** A warning or a changed value. */
|
|
27
|
+
readonly tone?: FieldTone;
|
|
28
|
+
}
|
|
29
|
+
/** Props for {@link TextField}: an input's own, but its class, style, and change handler. */
|
|
30
|
+
export interface TextFieldProps extends FieldLook, Omit<ComponentPropsWithRef<'input'>, 'className' | 'style' | 'size' | 'onChange' | 'value' | 'defaultValue'> {
|
|
31
|
+
/** The text it holds. */
|
|
32
|
+
readonly value: string;
|
|
33
|
+
/** Hears the text as typed. */
|
|
34
|
+
readonly onChange?: (value: string, event: ChangeEvent<HTMLInputElement>) => void;
|
|
35
|
+
/** Its width; its column's unless given. */
|
|
36
|
+
readonly width?: FieldWidth;
|
|
37
|
+
/**
|
|
38
|
+
* The field holds no value (SQL NULL): its placeholder shows in the
|
|
39
|
+
* missing value's dim italic.
|
|
40
|
+
*/
|
|
41
|
+
readonly nullValue?: boolean;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A text, number, password, or search field in the shared well, its value in
|
|
45
|
+
* the code face. A number field draws the stepper cap. In a `FieldRow` it
|
|
46
|
+
* takes the row's label, note, problem, and help. Draws `input.field`.
|
|
47
|
+
*/
|
|
48
|
+
export declare function TextField({ value, onChange, size, width, invalid, tone, nullValue, id, 'aria-describedby': describedBy, type, ...props }: TextFieldProps): ReactElement;
|
|
49
|
+
/** Props for {@link TextArea}: a textarea's own, but its class, style, and change handler. */
|
|
50
|
+
export interface TextAreaProps extends FieldLook, Omit<ComponentPropsWithRef<'textarea'>, 'className' | 'style' | 'onChange' | 'value' | 'defaultValue'> {
|
|
51
|
+
/** The text it holds. */
|
|
52
|
+
readonly value: string;
|
|
53
|
+
/** Hears the text as typed. */
|
|
54
|
+
readonly onChange?: (value: string, event: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Text of several lines in the shared well, with no corner grip: its pane or
|
|
58
|
+
* dialog sizes it (`rows`). In a `FieldRow` it takes the row's wiring.
|
|
59
|
+
* Draws `textarea.field`.
|
|
60
|
+
*/
|
|
61
|
+
export declare function TextArea({ value, onChange, size, invalid, tone, id, 'aria-describedby': describedBy, ...props }: TextAreaProps): ReactElement;
|
|
62
|
+
/** One item of a `Select`. */
|
|
63
|
+
export interface SelectOption {
|
|
64
|
+
/** What `onChange` hears when it is chosen. */
|
|
65
|
+
readonly value: string;
|
|
66
|
+
/** Its words in the list. */
|
|
67
|
+
readonly label: string;
|
|
68
|
+
readonly disabled?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/** A named run of a `Select`'s items. */
|
|
71
|
+
export interface SelectOptionGroup {
|
|
72
|
+
/** The run's heading in the list. */
|
|
73
|
+
readonly group: string;
|
|
74
|
+
readonly options: readonly SelectOption[];
|
|
75
|
+
}
|
|
76
|
+
/** Props for {@link Select}: a select's own, but its class, style, children, and change handler. */
|
|
77
|
+
export interface SelectProps extends FieldLook, Omit<ComponentPropsWithRef<'select'>, 'className' | 'style' | 'onChange' | 'value' | 'defaultValue' | 'children' | 'multiple' | 'size'> {
|
|
78
|
+
/** The chosen item's value. */
|
|
79
|
+
readonly value: string;
|
|
80
|
+
/** Its items, plain or in named runs. */
|
|
81
|
+
readonly options: readonly (SelectOption | SelectOptionGroup)[];
|
|
82
|
+
/** Hears the value chosen. */
|
|
83
|
+
readonly onChange: (value: string, event: ChangeEvent<HTMLSelectElement>) => void;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A pop-up of items in the shared well with an up and down chevron pair; in
|
|
87
|
+
* a `FieldRow` it is as wide as its longest item. Draws `select.field`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function Select({ value, options, onChange, size, invalid, tone, id, 'aria-describedby': describedBy, ...props }: SelectProps): ReactElement;
|
|
90
|
+
/** Props for {@link FieldBox}: a text field with a glyph before it. */
|
|
91
|
+
export interface FieldBoxProps extends Omit<TextFieldProps, 'width' | 'nullValue' | 'tone'> {
|
|
92
|
+
/** The glyph before the text (a magnifier for a filter). */
|
|
93
|
+
readonly glyph: LucideIcon;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* The field's frame round a leading glyph and its text: a filter or search
|
|
97
|
+
* box. Draws `.field-box` round a bare input.
|
|
98
|
+
*/
|
|
99
|
+
export declare function FieldBox({ glyph: Glyph, value, onChange, size, invalid, id, 'aria-describedby': describedBy, type, ...props }: FieldBoxProps): ReactElement;
|
|
100
|
+
/** Props for {@link FieldEditor}. */
|
|
101
|
+
export interface FieldEditorProps {
|
|
102
|
+
/** The editor the app brings (CodeMirror, Monaco), given its height. */
|
|
103
|
+
readonly children: ReactNode;
|
|
104
|
+
/** Outlines it in the danger tone. */
|
|
105
|
+
readonly invalid?: boolean;
|
|
106
|
+
/** Marks a value changed from its default. */
|
|
107
|
+
readonly changed?: boolean;
|
|
108
|
+
/** Recesses its ground and draws no focus edge: a value to read, not edit. */
|
|
109
|
+
readonly readOnly?: boolean;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A code editor standing in a form as a field: the field's well, hover,
|
|
113
|
+
* focus edge, and tones on its container, clipped to the field's corners.
|
|
114
|
+
* Draws `.field-editor`.
|
|
115
|
+
*/
|
|
116
|
+
export declare function FieldEditor({ children, invalid, changed, readOnly }: FieldEditorProps): ReactElement;
|
|
117
|
+
/** Props for {@link Radio}. */
|
|
118
|
+
export interface RadioProps {
|
|
119
|
+
/** The group it belongs to: every radio of one choice shares it. */
|
|
120
|
+
readonly name: string;
|
|
121
|
+
/** What `onChange` hears when it is chosen. */
|
|
122
|
+
readonly value: string;
|
|
123
|
+
/** Whether it is the chosen one. */
|
|
124
|
+
readonly checked: boolean;
|
|
125
|
+
/** Hears its value when it is chosen. */
|
|
126
|
+
readonly onChange: (value: string) => void;
|
|
127
|
+
/** Its words, beside it; the whole label is its target. */
|
|
128
|
+
readonly label: ReactNode;
|
|
129
|
+
/** A choice whose effect is destructive (`danger`) or needs care (`warning`). */
|
|
130
|
+
readonly tone?: 'danger' | 'warning';
|
|
131
|
+
/** Marks the choice wrong. */
|
|
132
|
+
readonly invalid?: boolean;
|
|
133
|
+
readonly disabled?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* One choice of several, a disc in the shared `.check` look with its words
|
|
137
|
+
* in a `field-choice` label. Put a run of them in a `FieldGroup`.
|
|
138
|
+
*/
|
|
139
|
+
export declare function Radio({ name, value, checked, onChange, label, tone, invalid, disabled }: RadioProps): ReactElement;
|
|
140
|
+
/** Props for {@link Range}. */
|
|
141
|
+
export interface RangeProps {
|
|
142
|
+
/** Where the knob stands. */
|
|
143
|
+
readonly value: number;
|
|
144
|
+
/** Hears the value as the knob moves. */
|
|
145
|
+
readonly onChange: (value: number) => void;
|
|
146
|
+
/** The smallest value; 0 unless given. */
|
|
147
|
+
readonly min?: number;
|
|
148
|
+
/** The largest value; 100 unless given. */
|
|
149
|
+
readonly max?: number;
|
|
150
|
+
/** The step between values; any value unless given. */
|
|
151
|
+
readonly step?: number | 'any';
|
|
152
|
+
/** Its accessible name ("Volume") outside a `FieldRow`; in one, the row's label names it instead. */
|
|
153
|
+
readonly label?: string;
|
|
154
|
+
/** The value as words, read by assistive technology ("1:05 of 3:20"). */
|
|
155
|
+
readonly valueText?: string;
|
|
156
|
+
readonly disabled?: boolean;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* A slider: a trough filled in the accent up to the knob. In a `FieldRow` it
|
|
160
|
+
* takes the row's label and description. Draws `input.range` with
|
|
161
|
+
* `--range-fill` set from the value.
|
|
162
|
+
*/
|
|
163
|
+
export declare function Range({ value, onChange, min, max, step, label, valueText, disabled }: RangeProps): ReactElement;
|
|
164
|
+
/** Props for {@link Meter}. */
|
|
165
|
+
export interface MeterProps {
|
|
166
|
+
/** The measure (a password's strength, a quota used). */
|
|
167
|
+
readonly value: number;
|
|
168
|
+
readonly min?: number;
|
|
169
|
+
readonly max?: number;
|
|
170
|
+
/** Where the low range ends. */
|
|
171
|
+
readonly low: number;
|
|
172
|
+
/** Where the high range starts. */
|
|
173
|
+
readonly high: number;
|
|
174
|
+
/** A value in the range that is good: low, middle, or high. */
|
|
175
|
+
readonly optimum: number;
|
|
176
|
+
/** Its accessible name ("Strength") outside a `FieldRow`; in one, the row's label names it instead. */
|
|
177
|
+
readonly label?: string;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* A measure in a pill trough, filled in the success tone in its optimum
|
|
181
|
+
* range, the warning tone one range away, and the danger tone at the least
|
|
182
|
+
* good. In a `FieldRow` it takes the row's label and description. Draws a
|
|
183
|
+
* themed `<meter>`.
|
|
184
|
+
*/
|
|
185
|
+
export declare function Meter({ value, min, max, low, high, optimum, label }: MeterProps): ReactElement;
|
|
186
|
+
/** Props for {@link RestoreDefault}. */
|
|
187
|
+
export interface RestoreDefaultProps {
|
|
188
|
+
/** Its words: "Restore Default". */
|
|
189
|
+
readonly children: string;
|
|
190
|
+
/** Sets the setting back to its default. */
|
|
191
|
+
readonly onClick: () => void;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* The dim link-like button beside a setting changed from its default that
|
|
195
|
+
* sets it back. Draws `.text-link.settings-restore`.
|
|
196
|
+
*/
|
|
197
|
+
export declare function RestoreDefault({ children, onClick }: RestoreDefaultProps): ReactElement;
|
|
198
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ICON_SM } from '../icon/sizes.js';
|
|
3
|
+
import { useFieldWiring } from './FieldLayout.js';
|
|
4
|
+
const SIZE_CLASS = { md: '', sm: 'field-sm', xs: 'field-xs' };
|
|
5
|
+
const WIDTH_CLASS = {
|
|
6
|
+
full: '',
|
|
7
|
+
short: 'field-short',
|
|
8
|
+
count: 'settings-count',
|
|
9
|
+
countOrWord: 'settings-count-or-word'
|
|
10
|
+
};
|
|
11
|
+
const classes = (...names) => names.filter(Boolean).join(' ');
|
|
12
|
+
/**
|
|
13
|
+
* A text, number, password, or search field in the shared well, its value in
|
|
14
|
+
* the code face. A number field draws the stepper cap. In a `FieldRow` it
|
|
15
|
+
* takes the row's label, note, problem, and help. Draws `input.field`.
|
|
16
|
+
*/
|
|
17
|
+
export function TextField({ value, onChange, size = 'md', width = 'full', invalid, tone, nullValue = false, id, 'aria-describedby': describedBy, type = 'text', ...props }) {
|
|
18
|
+
const wiring = useFieldWiring({ id, describedBy, invalid });
|
|
19
|
+
return (_jsx("input", { ...props, ...wiring, className: classes('field', SIZE_CLASS[size], WIDTH_CLASS[width], nullValue && 'value-null'), "data-tone": tone, onChange: onChange === undefined ? undefined : (event) => onChange(event.target.value, event), readOnly: props.readOnly ?? onChange === undefined, type: type, value: value }));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Text of several lines in the shared well, with no corner grip: its pane or
|
|
23
|
+
* dialog sizes it (`rows`). In a `FieldRow` it takes the row's wiring.
|
|
24
|
+
* Draws `textarea.field`.
|
|
25
|
+
*/
|
|
26
|
+
export function TextArea({ value, onChange, size = 'md', invalid, tone, id, 'aria-describedby': describedBy, ...props }) {
|
|
27
|
+
const wiring = useFieldWiring({ id, describedBy, invalid });
|
|
28
|
+
return (_jsx("textarea", { ...props, ...wiring, className: classes('field', SIZE_CLASS[size]), "data-tone": tone, onChange: onChange === undefined ? undefined : (event) => onChange(event.target.value, event), readOnly: props.readOnly ?? onChange === undefined, value: value }));
|
|
29
|
+
}
|
|
30
|
+
const optionElement = (option) => (_jsx("option", { disabled: option.disabled, value: option.value, children: option.label }, option.value));
|
|
31
|
+
/**
|
|
32
|
+
* A pop-up of items in the shared well with an up and down chevron pair; in
|
|
33
|
+
* a `FieldRow` it is as wide as its longest item. Draws `select.field`.
|
|
34
|
+
*/
|
|
35
|
+
export function Select({ value, options, onChange, size = 'md', invalid, tone, id, 'aria-describedby': describedBy, ...props }) {
|
|
36
|
+
const wiring = useFieldWiring({ id, describedBy, invalid });
|
|
37
|
+
return (_jsx("select", { ...props, ...wiring, className: classes('field', SIZE_CLASS[size]), "data-tone": tone, onChange: (event) => onChange(event.target.value, event), value: value, children: options.map((entry) => 'group' in entry ? (_jsx("optgroup", { label: entry.group, children: entry.options.map(optionElement) }, `group:${entry.group}`)) : (optionElement(entry))) }));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The field's frame round a leading glyph and its text: a filter or search
|
|
41
|
+
* box. Draws `.field-box` round a bare input.
|
|
42
|
+
*/
|
|
43
|
+
export function FieldBox({ glyph: Glyph, value, onChange, size = 'md', invalid, id, 'aria-describedby': describedBy, type = 'text', ...props }) {
|
|
44
|
+
const wiring = useFieldWiring({ id, describedBy, invalid });
|
|
45
|
+
// The frame draws the danger outline; the input is what a screen reader
|
|
46
|
+
// hears as invalid.
|
|
47
|
+
return (_jsxs("label", { "aria-invalid": wiring['aria-invalid'], className: classes('field-box', SIZE_CLASS[size]), children: [_jsx(Glyph, { "aria-hidden": true, size: ICON_SM }), _jsx("input", { ...props, ...wiring, onChange: onChange === undefined ? undefined : (event) => onChange(event.target.value, event), readOnly: props.readOnly ?? onChange === undefined, type: type, value: value })] }));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* A code editor standing in a form as a field: the field's well, hover,
|
|
51
|
+
* focus edge, and tones on its container, clipped to the field's corners.
|
|
52
|
+
* Draws `.field-editor`.
|
|
53
|
+
*/
|
|
54
|
+
export function FieldEditor({ children, invalid = false, changed = false, readOnly = false }) {
|
|
55
|
+
return (_jsx("div", { "aria-invalid": invalid ? true : undefined, className: readOnly ? 'field-editor read-only' : 'field-editor', "data-tone": changed ? 'accent' : undefined, children: children }));
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* One choice of several, a disc in the shared `.check` look with its words
|
|
59
|
+
* in a `field-choice` label. Put a run of them in a `FieldGroup`.
|
|
60
|
+
*/
|
|
61
|
+
export function Radio({ name, value, checked, onChange, label, tone, invalid = false, disabled = false }) {
|
|
62
|
+
return (_jsxs("label", { className: "field-choice", children: [_jsx("input", { "aria-invalid": invalid ? true : undefined, checked: checked, className: "check", "data-tone": tone, disabled: disabled, name: name, onChange: () => onChange(value), type: "radio", value: value }), label] }));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* A slider: a trough filled in the accent up to the knob. In a `FieldRow` it
|
|
66
|
+
* takes the row's label and description. Draws `input.range` with
|
|
67
|
+
* `--range-fill` set from the value.
|
|
68
|
+
*/
|
|
69
|
+
export function Range({ value, onChange, min = 0, max = 100, step = 'any', label, valueText, disabled = false }) {
|
|
70
|
+
const span = max - min;
|
|
71
|
+
const fill = span > 0 ? Math.min(100, Math.max(0, ((value - min) / span) * 100)) : 0;
|
|
72
|
+
const wiring = useFieldWiring({});
|
|
73
|
+
// In a row its label names it; an aria-label would override that.
|
|
74
|
+
const inRow = wiring.id !== undefined;
|
|
75
|
+
return (_jsx("input", { ...wiring, "aria-label": inRow ? undefined : label, "aria-valuetext": valueText, className: "range", disabled: disabled, max: max, min: min, onChange: (event) => onChange(Number(event.target.value)), step: step, style: { '--range-fill': `${fill}%` }, type: "range", value: value }));
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* A measure in a pill trough, filled in the success tone in its optimum
|
|
79
|
+
* range, the warning tone one range away, and the danger tone at the least
|
|
80
|
+
* good. In a `FieldRow` it takes the row's label and description. Draws a
|
|
81
|
+
* themed `<meter>`.
|
|
82
|
+
*/
|
|
83
|
+
export function Meter({ value, min = 0, max = 1, low, high, optimum, label }) {
|
|
84
|
+
const { id, 'aria-describedby': describedBy } = useFieldWiring({});
|
|
85
|
+
// In a row its label names it; an aria-label would override that.
|
|
86
|
+
return (_jsx("meter", { "aria-describedby": describedBy, "aria-label": id === undefined ? label : undefined, id: id, high: high, low: low, max: max, min: min, optimum: optimum, value: value }));
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The dim link-like button beside a setting changed from its default that
|
|
90
|
+
* sets it back. Draws `.text-link.settings-restore`.
|
|
91
|
+
*/
|
|
92
|
+
export function RestoreDefault({ children, onClick }) {
|
|
93
|
+
return (_jsx("button", { className: "text-link settings-restore", onClick: onClick, type: "button", children: _jsx("span", { className: "text-link-words", children: children }) }));
|
|
94
|
+
}
|