@bigpixelrocket/uiok 0.3.0 → 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.
- package/CHANGELOG.md +23 -1
- package/dist/dialog/ConfirmDialog.d.ts +7 -1
- package/dist/dialog/ConfirmDialog.js +2 -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 +9 -2
- package/dist/frame/Tree.js +29 -6
- 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/viewer.d.ts +193 -0
- package/dist/labels/viewer.js +124 -0
- package/dist/listing/PaneMessage.d.ts +28 -0
- package/dist/listing/PaneMessage.js +12 -0
- package/dist/listing/index.d.ts +4 -2
- package/dist/listing/index.js +4 -2
- package/dist/styles.css +3 -0
- package/dist/surface/Card.d.ts +18 -0
- package/dist/surface/Card.js +10 -0
- package/dist/surface/Notice.d.ts +45 -0
- package/dist/surface/Notice.js +27 -0
- package/dist/surface/index.d.ts +5 -3
- package/dist/surface/index.js +5 -3
- package/dist/themes/themes.generated.css +1 -0
- package/dist/themes/tokens.js +4 -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,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.4.0] - 2026-11-23
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- 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.
|
|
14
|
+
- The `viewer` label group (`ViewerLabels`, `ViewerModeLabels`, `ViewerContentLabels`, `DEFAULT_VIEWER_LABELS`), its number, size, and date formats included.
|
|
15
|
+
- 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`.
|
|
16
|
+
- `Notice` and `Card` (`@bigpixelrocket/uiok/surface`), and `PaneMessage` (`@bigpixelrocket/uiok/listing`): the `.notice`, `.card`, and `.pane-message` looks as components.
|
|
17
|
+
- `TreeTool` takes a `rowKey`, which joins it to the pane's row cursor as a `TreeRow` is, as a `treeitem`.
|
|
18
|
+
- `ProgressDialog`, `ConfirmDialog`, and `TypedNameDialog` take a `container`; `TypedNameDialog` takes `groups`.
|
|
19
|
+
- Theme token `--letterbox` (a video's letterbox, black in every theme).
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- 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.
|
|
24
|
+
- `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.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- `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.
|
|
29
|
+
|
|
9
30
|
## [0.3.0] - 2026-11-23
|
|
10
31
|
|
|
11
32
|
### Added
|
|
@@ -224,7 +245,8 @@ The first published version. The package is published to npm as `@bigpixelrocket
|
|
|
224
245
|
- `lucide-react` 1.31 or later within 1.x is a peer dependency.
|
|
225
246
|
- 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
247
|
|
|
227
|
-
[Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.
|
|
248
|
+
[Unreleased]: https://github.com/Bigpixelrocket/uiok/compare/v0.4.0...HEAD
|
|
249
|
+
[0.4.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.3.0...v0.4.0
|
|
228
250
|
[0.3.0]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.3...v0.3.0
|
|
229
251
|
[0.2.3]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.2...v0.2.3
|
|
230
252
|
[0.2.2]: https://github.com/Bigpixelrocket/uiok/compare/v0.2.1...v0.2.2
|
|
@@ -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
|
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* What a `FieldRow` tells the one control it holds: the id its label names,
|
|
4
|
+
* the ids of what describes it (the problem, the note, and the help a
|
|
5
|
+
* screen reader reads as the control takes focus), and whether its value is
|
|
6
|
+
* wrong.
|
|
7
|
+
*/
|
|
8
|
+
export interface FieldRowWiring {
|
|
9
|
+
readonly id: string;
|
|
10
|
+
readonly describedBy: string | undefined;
|
|
11
|
+
readonly invalid: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The attributes a control takes from the `FieldRow` it stands in, with
|
|
15
|
+
* any it sets itself: its id (the row's, which its label names, so in a row
|
|
16
|
+
* give the id to `FieldRow`), `aria-describedby` (its own ids first), and
|
|
17
|
+
* `aria-invalid`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useFieldWiring(own: {
|
|
20
|
+
readonly id?: string | undefined;
|
|
21
|
+
readonly describedBy?: string | undefined;
|
|
22
|
+
readonly invalid?: boolean | undefined;
|
|
23
|
+
}): {
|
|
24
|
+
readonly id: string | undefined;
|
|
25
|
+
readonly 'aria-describedby': string | undefined;
|
|
26
|
+
readonly 'aria-invalid': true | undefined;
|
|
27
|
+
};
|
|
28
|
+
/** Props for {@link FieldGrid}. */
|
|
29
|
+
export interface FieldGridProps {
|
|
30
|
+
/** Its rows: `FieldRow`s, and any `FieldGroup` or line that spans both columns. */
|
|
31
|
+
readonly children: ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* The label column's width (`136px`, `12em`); by default as wide as the
|
|
34
|
+
* longest label, capped at 40% of the form.
|
|
35
|
+
*/
|
|
36
|
+
readonly labelWidth?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A form laid out as rows of a label and its value on one label column,
|
|
40
|
+
* each label centred on its control's first line. Draws `.field-grid`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function FieldGrid({ children, labelWidth }: FieldGridProps): ReactElement;
|
|
43
|
+
/** Props for {@link FieldRow}. */
|
|
44
|
+
export interface FieldRowProps {
|
|
45
|
+
/** What the field is for: "Host". */
|
|
46
|
+
readonly label: ReactNode;
|
|
47
|
+
/** A quieter second line under the label (which of two bands is in use). */
|
|
48
|
+
readonly labelDetail?: ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* What the control is for, as the label's tooltip and the control's
|
|
51
|
+
* accessible description (`labelHelp`); the label shows a dashed cue.
|
|
52
|
+
*/
|
|
53
|
+
readonly help?: string;
|
|
54
|
+
/**
|
|
55
|
+
* The value: one control (`TextField`, `Select`, …), which takes the
|
|
56
|
+
* row's id, note, problem, and help on its own, or `FieldOption` lines.
|
|
57
|
+
*/
|
|
58
|
+
readonly children: ReactNode;
|
|
59
|
+
/** One short line under the control on what the current choice does. */
|
|
60
|
+
readonly note?: ReactNode;
|
|
61
|
+
/** What is wrong with the value; marks the control invalid while set. */
|
|
62
|
+
readonly problem?: ReactNode;
|
|
63
|
+
/**
|
|
64
|
+
* Names a group of controls (radios, checks) rather than one: the label
|
|
65
|
+
* becomes the group's name, not a `<label>` for one control.
|
|
66
|
+
*/
|
|
67
|
+
readonly group?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* The control's id, when the app must know it; one is made otherwise. The
|
|
70
|
+
* row's id wins over one the control sets, so its label always names it.
|
|
71
|
+
*/
|
|
72
|
+
readonly id?: string;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* One row of a `FieldGrid`: the label, then the value with its note and
|
|
76
|
+
* problem under it. The one control inside takes the label's id, the
|
|
77
|
+
* problem, note, and help as its description, and `aria-invalid` while a
|
|
78
|
+
* problem stands, with no wiring by the app. Draws
|
|
79
|
+
* `.field-label` and `.field-value` with `.field-note` and `.field-problem`.
|
|
80
|
+
*/
|
|
81
|
+
export declare function FieldRow({ label, labelDetail, help, children, note, problem, group, id }: FieldRowProps): ReactElement;
|
|
82
|
+
/** Props for {@link FieldOption}. */
|
|
83
|
+
export interface FieldOptionProps {
|
|
84
|
+
/** Choices or a field and its words, on one wrapping line. */
|
|
85
|
+
readonly children: ReactNode;
|
|
86
|
+
}
|
|
87
|
+
/** One line of a row's value (a field and a choice beside it), at least a control high. Draws `.field-option`. */
|
|
88
|
+
export declare function FieldOption({ children }: FieldOptionProps): ReactElement;
|
|
89
|
+
/** Props for {@link FieldNote} and {@link FieldProblem}. */
|
|
90
|
+
export interface FieldMessageProps {
|
|
91
|
+
/** Its words. */
|
|
92
|
+
readonly children: ReactNode;
|
|
93
|
+
/** Its id, for a control's `aria-describedby`. */
|
|
94
|
+
readonly id?: string;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* One short line under a control on what the current choice does ("Worn
|
|
98
|
+
* while the system is light."). Draws `.field-note`.
|
|
99
|
+
*/
|
|
100
|
+
export declare function FieldNote({ children, id }: FieldMessageProps): ReactElement;
|
|
101
|
+
/**
|
|
102
|
+
* What is wrong with a value, as a status line led by the danger glyph.
|
|
103
|
+
* Name it in the control's `aria-describedby` (`FieldRow` does). Draws
|
|
104
|
+
* `.field-problem`.
|
|
105
|
+
*/
|
|
106
|
+
export declare function FieldProblem({ children, id }: FieldMessageProps): ReactElement;
|
|
107
|
+
/** Props for {@link FieldGroup}. */
|
|
108
|
+
export interface FieldGroupProps {
|
|
109
|
+
/** The group's name, as its legend: "Show". */
|
|
110
|
+
readonly legend: ReactNode;
|
|
111
|
+
/** Speaks the legend without drawing it, for a group a row's label already names. */
|
|
112
|
+
readonly legendHidden?: boolean;
|
|
113
|
+
/** Its choices: `Check`s or `Radio`s with their labels. */
|
|
114
|
+
readonly children: ReactNode;
|
|
115
|
+
/** Lays the choices in this many columns of equal width, filled row by row. */
|
|
116
|
+
readonly columns?: number;
|
|
117
|
+
/** One short line under the choices. */
|
|
118
|
+
readonly note?: ReactNode;
|
|
119
|
+
/** What is wrong with the choice. */
|
|
120
|
+
readonly problem?: ReactNode;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* A group of choices under its legend, 4px apart, or in `columns`. Draws
|
|
124
|
+
* `fieldset.field-group` (`.field-columns`).
|
|
125
|
+
*/
|
|
126
|
+
export declare function FieldGroup({ legend, legendHidden, children, columns, note, problem }: FieldGroupProps): ReactElement;
|