@speles7172/controls 0.1.1 → 0.2.1
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/README.md +89 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/KeyValueList.d.ts +58 -0
- package/dist/KeyValueList.d.ts.map +1 -0
- package/dist/KeyValueList.js +54 -0
- package/dist/KeyValueList.js.map +1 -0
- package/dist/Modal.d.ts +48 -0
- package/dist/Modal.d.ts.map +1 -0
- package/dist/Modal.js +160 -0
- package/dist/Modal.js.map +1 -0
- package/dist/ValueInput.d.ts +95 -0
- package/dist/ValueInput.d.ts.map +1 -0
- package/dist/ValueInput.js +100 -0
- package/dist/ValueInput.js.map +1 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.css +255 -0
- package/package.json +2 -2
package/dist/Modal.js
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef } from 'react';
|
|
3
|
+
/**
|
|
4
|
+
* The modals currently open, in the order they opened.
|
|
5
|
+
*
|
|
6
|
+
* Module scope, because two `<Modal>`s rendered from unrelated trees have no
|
|
7
|
+
* other way to agree about which of them is on top — and both of the things
|
|
8
|
+
* below need that answer:
|
|
9
|
+
*
|
|
10
|
+
* - **Escape.** Both instances listen on `document`, and `stopPropagation()`
|
|
11
|
+
* does not stop other listeners on the *same* node (that is
|
|
12
|
+
* `stopImmediatePropagation`), so one Escape closed both. Only the topmost
|
|
13
|
+
* acts on a key now.
|
|
14
|
+
* - **The scroll lock.** Each instance used to snapshot and restore
|
|
15
|
+
* `body.style.overflow` for itself. Nested, that happens to work; unmounted
|
|
16
|
+
* out of order it does not, and the first one to leave hands the page back
|
|
17
|
+
* its scrollbar while a dialog is still open over it.
|
|
18
|
+
*
|
|
19
|
+
* Kept as a plain array rather than a count so a non-LIFO teardown removes the
|
|
20
|
+
* right entry.
|
|
21
|
+
*/
|
|
22
|
+
const openModals = [];
|
|
23
|
+
/** What `body.style.overflow` was before the first modal took it. */
|
|
24
|
+
let releasedOverflow = '';
|
|
25
|
+
/** Everything a `Tab` can land on, in document order. */
|
|
26
|
+
const FOCUSABLE = [
|
|
27
|
+
'a[href]',
|
|
28
|
+
'button:not([disabled])',
|
|
29
|
+
'input:not([disabled])',
|
|
30
|
+
'select:not([disabled])',
|
|
31
|
+
'textarea:not([disabled])',
|
|
32
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
33
|
+
].join(',');
|
|
34
|
+
/**
|
|
35
|
+
* The modal shell.
|
|
36
|
+
*
|
|
37
|
+
* Here rather than in each console for the reason this package exists: a dialog
|
|
38
|
+
* written twice is a dialog that behaves differently in two places, and the two
|
|
39
|
+
* differ in exactly the parts nobody reimplements — the focus trap, the focus
|
|
40
|
+
* *restore*, and the scroll lock. `file-console` carries an older `Dialog` of
|
|
41
|
+
* its own that predates this and should be folded in.
|
|
42
|
+
*
|
|
43
|
+
* What it does that a `<div>` does not:
|
|
44
|
+
*
|
|
45
|
+
* - closes on Escape, and on a click on the backdrop rather than on anything
|
|
46
|
+
* that merely bubbles out of the panel;
|
|
47
|
+
* - announces itself as a modal dialog, so a screen reader stops offering the
|
|
48
|
+
* page behind it;
|
|
49
|
+
* - traps `Tab` inside the panel. Without this the third Tab is on a filter
|
|
50
|
+
* box behind the overlay, focus is invisible, and a keyboard user is typing
|
|
51
|
+
* into a page they cannot see;
|
|
52
|
+
* - puts focus back where it came from on close. A record opened from a table
|
|
53
|
+
* row must return focus to that row, or the next `Tab` restarts from the
|
|
54
|
+
* top of the document and the operator loses their place in a long list;
|
|
55
|
+
* - stops the page behind from scrolling, so a wheel over the backdrop does
|
|
56
|
+
* not silently move the list the dialog was opened from.
|
|
57
|
+
*
|
|
58
|
+
* Rendered in place rather than through a portal, deliberately. A console
|
|
59
|
+
* bridges its own palette onto `--ctl-*` with a descendant selector
|
|
60
|
+
* (`.logc .ctl { --ctl-bg: … }`), and a portal to `document.body` escapes it —
|
|
61
|
+
* so a dark console would open a light dialog. `position: fixed` covers the
|
|
62
|
+
* viewport from wherever the element sits.
|
|
63
|
+
*/
|
|
64
|
+
export function Modal({ title, onClose, children, footer, wide = false, labelledBy, className, theme = 'light', }) {
|
|
65
|
+
const panel = useRef(null);
|
|
66
|
+
const titleId = useId();
|
|
67
|
+
// A stable identity for this instance, and the only thing `openModals` holds.
|
|
68
|
+
const self = useRef({}).current;
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
// Captured before focus moves into the panel below, which is the only
|
|
71
|
+
// moment the element that opened this dialog is still the active one.
|
|
72
|
+
const opener = document.activeElement;
|
|
73
|
+
// The panel itself, not the first control: focusing a text box scrolls a
|
|
74
|
+
// long dialog to it and reads the wrong thing to a screen reader.
|
|
75
|
+
panel.current?.focus();
|
|
76
|
+
return () => {
|
|
77
|
+
// `isConnected` because the opener is routinely a row in a list the close
|
|
78
|
+
// also removed, and focusing a detached node silently sends focus to
|
|
79
|
+
// `<body>` — the very thing this exists to avoid.
|
|
80
|
+
if (opener instanceof HTMLElement && opener.isConnected)
|
|
81
|
+
opener.focus();
|
|
82
|
+
};
|
|
83
|
+
}, []);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
const onKeyDown = (event) => {
|
|
86
|
+
// Only the dialog on top responds. Both instances' listeners sit on
|
|
87
|
+
// `document`, so nothing either of them does to the event stops the
|
|
88
|
+
// other from seeing it.
|
|
89
|
+
if (openModals[openModals.length - 1] !== self)
|
|
90
|
+
return;
|
|
91
|
+
if (event.key === 'Escape') {
|
|
92
|
+
// Not what keeps a second dialog from closing — the check above is.
|
|
93
|
+
// This is for a host with its own Escape handler further out: a drawer
|
|
94
|
+
// behind the dialog should not close alongside it.
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
onClose();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (event.key !== 'Tab' || panel.current === null)
|
|
100
|
+
return;
|
|
101
|
+
const focusable = [...panel.current.querySelectorAll(FOCUSABLE)];
|
|
102
|
+
// Nothing to cycle between: hold focus on the panel rather than letting
|
|
103
|
+
// it escape to the page underneath.
|
|
104
|
+
if (focusable.length === 0) {
|
|
105
|
+
event.preventDefault();
|
|
106
|
+
panel.current.focus();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const first = focusable[0];
|
|
110
|
+
const last = focusable[focusable.length - 1];
|
|
111
|
+
const active = document.activeElement;
|
|
112
|
+
// Only the two ends are intercepted. Everything in between is the
|
|
113
|
+
// browser's own tab order, which handles disabled controls, `tabindex`
|
|
114
|
+
// and shadow roots better than a hand-rolled walk ever does.
|
|
115
|
+
if (event.shiftKey && (active === first || active === panel.current)) {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
last.focus();
|
|
118
|
+
}
|
|
119
|
+
else if (!event.shiftKey && active === last) {
|
|
120
|
+
event.preventDefault();
|
|
121
|
+
first.focus();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
document.addEventListener('keydown', onKeyDown);
|
|
125
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
126
|
+
}, [onClose]);
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
openModals.push(self);
|
|
129
|
+
// The first one in takes the scrollbar and remembers what it interrupted —
|
|
130
|
+
// whatever was there rather than `''`, since a host that had set its own
|
|
131
|
+
// `overflow` on `<body>` must get that back and not the initial value.
|
|
132
|
+
if (openModals.length === 1) {
|
|
133
|
+
releasedOverflow = document.body.style.overflow;
|
|
134
|
+
document.body.style.overflow = 'hidden';
|
|
135
|
+
}
|
|
136
|
+
return () => {
|
|
137
|
+
const index = openModals.indexOf(self);
|
|
138
|
+
if (index !== -1)
|
|
139
|
+
openModals.splice(index, 1);
|
|
140
|
+
// And the last one out gives it back. Restoring per-instance instead lets
|
|
141
|
+
// the page scroll behind a dialog that is still open, whenever two of
|
|
142
|
+
// them close in the order they opened rather than the reverse.
|
|
143
|
+
if (openModals.length === 0)
|
|
144
|
+
document.body.style.overflow = releasedOverflow;
|
|
145
|
+
};
|
|
146
|
+
// Registration and the lock are one effect on purpose: separating them
|
|
147
|
+
// leaves an ordering between two `useEffect`s that has to stay right, and
|
|
148
|
+
// the failure would be a page that never scrolls again.
|
|
149
|
+
}, [self]);
|
|
150
|
+
return (_jsx("div", { className: "ctl ctl-modal-overlay", "data-ctl-theme": theme,
|
|
151
|
+
// A click on the backdrop, not on anything that happens to bubble out of
|
|
152
|
+
// the panel — `currentTarget` is what separates the two. `mousedown`
|
|
153
|
+
// rather than `click`, or a drag that starts on a text selection inside
|
|
154
|
+
// the panel and ends on the backdrop closes the dialog.
|
|
155
|
+
onMouseDown: (event) => {
|
|
156
|
+
if (event.target === event.currentTarget)
|
|
157
|
+
onClose();
|
|
158
|
+
}, children: _jsxs("div", { className: `ctl-modal${wide ? ' ctl-modal-wide' : ''}${className ? ` ${className}` : ''}`, role: "dialog", "aria-modal": "true", "aria-labelledby": labelledBy ?? titleId, tabIndex: -1, ref: panel, children: [_jsxs("div", { className: "ctl-modal-head", children: [_jsx("h2", { className: "ctl-modal-title", id: titleId, children: title }), _jsx("button", { type: "button", className: "ctl-modal-close", "aria-label": "Close", onClick: onClose, children: _jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M18 6 6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })] }), _jsx("div", { className: "ctl-modal-body", children: children }), footer !== undefined && _jsx("div", { className: "ctl-modal-foot", children: footer })] }) }));
|
|
159
|
+
}
|
|
160
|
+
//# sourceMappingURL=Modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../src/Modal.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAkB,MAAM,O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ACtD,CAAC,YAED,eACE,SAAS,EAAE,YAAY,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EACzF,IAAI,EAAC,QAAQ,gBACF,MAAM,qBACA,UAAU,IAAI,OAAO,EACtC,QAAQ,EAAE,CAAC,CAAC,EACZ,GAAG,EAAE,KAAK,aAEV,eAAK,SAAS,EAAC,gBAAgB,aAC7B,aAAI,SAAS,EAAC,iBAAiB,EAAC,EAAE,EAAE,OAAO,YACxC,KAAK,GACH,EACL,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,iBAAiB,gBAChB,OAAO,EAClB,OAAO,EAAE,OAAO,YAEhB,cAAK,KAAK,EAAC,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,OAAO,EAAC,WAAW,EAAC,IAAI,EAAC,MAAM,iBAAa,MAAM,YAC5E,eACE,CAAC,EAAC,sBAAsB,EACxB,MAAM,EAAC,cAAc,EACrB,WAAW,EAAC,GAAG,EACf,aAAa,EAAC,OAAO,GACrB,GACE,GACC,IACL,EACN,cAAK,SAAS,EAAC,gBAAgB,YAAE,QAAQ,GAAO,EAC/C,MAAM,KAAK,SAAS,IAAI,cAAK,SAAS,EAAC,gBAAgB,YAAE,MAAM,GAAO,IACnE,GACF,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { ControlTheme, Option, OptionTransport } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The kinds of value a form field can hold.
|
|
4
|
+
*
|
|
5
|
+
* Not a *domain* vocabulary — there is no `email`, no `currency`, no `percent`,
|
|
6
|
+
* because those are the same input with different validation, and validation is
|
|
7
|
+
* the caller's. These are the distinct **editors**: nine ways of typing a
|
|
8
|
+
* value, each one a different control.
|
|
9
|
+
*/
|
|
10
|
+
export type ValueInputType = 'text' | 'multiline' | 'number' | 'boolean' | 'date' | 'datetime' | 'json' | 'choice' | 'reference';
|
|
11
|
+
export interface ValueInputProps {
|
|
12
|
+
type: ValueInputType;
|
|
13
|
+
/**
|
|
14
|
+
* The value, always as a string.
|
|
15
|
+
*
|
|
16
|
+
* One representation for every type, which is what lets a caller store a
|
|
17
|
+
* whole form in one shape and lets this control stay ignorant of what a value
|
|
18
|
+
* *means*. `'true'`, `'12.5'`, `'2026-08-20'`, `'{"a":1}'` — the caller
|
|
19
|
+
* encodes and decodes; `@speles7172/config-client/core` has the functions for
|
|
20
|
+
* it, and no dependency on them is needed here.
|
|
21
|
+
*/
|
|
22
|
+
value: string;
|
|
23
|
+
onChange(value: string): void;
|
|
24
|
+
label?: string;
|
|
25
|
+
/** Shown under the field, in the error colour. */
|
|
26
|
+
error?: string | null;
|
|
27
|
+
/** Shown under the field, in the muted colour, when there is no error. */
|
|
28
|
+
hint?: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
/** Renders the value, refuses to change it. For a setting the deployment owns. */
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
required?: boolean;
|
|
34
|
+
/** For `choice`: the values on offer. */
|
|
35
|
+
options?: readonly Option[];
|
|
36
|
+
/** For `reference`: where to search for records. */
|
|
37
|
+
transport?: OptionTransport;
|
|
38
|
+
/** For `number`, and for the seconds granularity of `datetime` (default 1). */
|
|
39
|
+
min?: number;
|
|
40
|
+
max?: number;
|
|
41
|
+
step?: number | 'any';
|
|
42
|
+
/** For `multiline` and `json`. */
|
|
43
|
+
rows?: number;
|
|
44
|
+
className?: string;
|
|
45
|
+
theme?: ControlTheme;
|
|
46
|
+
'data-testid'?: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* `datetime-local` will not accept an ISO instant, and says nothing about it.
|
|
50
|
+
*
|
|
51
|
+
* `<input type="datetime-local" value="2026-08-20T13:45:00Z">` renders **empty**
|
|
52
|
+
* — the trailing `Z` makes the value invalid for that input, and browsers
|
|
53
|
+
* silently blank an invalid value rather than reporting one. The symptom is a
|
|
54
|
+
* date field that looks unset for a setting that is set, and the fix is not
|
|
55
|
+
* discoverable from the markup.
|
|
56
|
+
*
|
|
57
|
+
* So the instant is shown in the viewer's own timezone and converted back on
|
|
58
|
+
* the way out. What is stored stays an ISO instant; what is displayed is the
|
|
59
|
+
* local time, which is what the person setting "send the digest at" means.
|
|
60
|
+
*
|
|
61
|
+
* **Seconds are rendered, and `step` defaults to 1 so the browser shows them.**
|
|
62
|
+
* A `datetime-local` at its default step is minute-granular: it displays
|
|
63
|
+
* `13:45` for a value of `13:45:37`, and the moment anyone edits the field the
|
|
64
|
+
* `:37` is gone — the box never showed it, so nothing looks lost. Rendering
|
|
65
|
+
* seconds makes the field display exactly what an edit will keep.
|
|
66
|
+
*
|
|
67
|
+
* Milliseconds are still dropped by an edit, and there is no `step` that fixes
|
|
68
|
+
* that honestly: a control that showed `.000` for every value would be
|
|
69
|
+
* inventing precision it cannot offer. A setting needing sub-second precision
|
|
70
|
+
* wants `text` and its own format.
|
|
71
|
+
*
|
|
72
|
+
* Exported so this conversion can be tested for what it is. jsdom normalises a
|
|
73
|
+
* `datetime-local` value down to minutes whatever the step, so reading the
|
|
74
|
+
* rendered input back proves nothing about the seconds — the rule has to be
|
|
75
|
+
* asserted on the function.
|
|
76
|
+
*/
|
|
77
|
+
export declare function toLocalInput(iso: string): string;
|
|
78
|
+
export declare function fromLocalInput(local: string): string;
|
|
79
|
+
/**
|
|
80
|
+
* One field, whichever kind of value it holds.
|
|
81
|
+
*
|
|
82
|
+
* The control every admin form in this organisation was writing a `switch` for:
|
|
83
|
+
* a checkbox for booleans, a date picker for dates, a searchable select for a
|
|
84
|
+
* reference to a record, a textarea for JSON. Written once, it is also the
|
|
85
|
+
* thing that makes them all agree — a boolean edited on one page and a boolean
|
|
86
|
+
* edited on another should not be a checkbox in one place and a Yes/No dropdown
|
|
87
|
+
* in the other.
|
|
88
|
+
*
|
|
89
|
+
* Markup is plain semantic HTML with `ctl-` class names and no styling
|
|
90
|
+
* dependency; `choice` and `reference` delegate to {@link SearchableSelect}, so
|
|
91
|
+
* a field over forty thousand records is the same component as a field over
|
|
92
|
+
* three.
|
|
93
|
+
*/
|
|
94
|
+
export declare function ValueInput({ type, value, onChange, label, error, hint, placeholder, disabled, readOnly, required, options, transport, min, max, step, rows, className, theme, 'data-testid': testId, }: ValueInputProps): import("react").JSX.Element;
|
|
95
|
+
//# sourceMappingURL=ValueInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValueInput.d.ts","sourceRoot":"","sources":["../src/ValueInput.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAExE;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GACtB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,SAAS,GACT,MAAM,GACN,UAAU,GACV,MAAM,GACN,QAAQ,GACR,WAAW,CAAC;AAEhB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,cAAc,CAAC;IACrB;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAE9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kFAAkF;IAClF,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB,yCAAyC;IACzC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,oDAAoD;IACpD,SAAS,CAAC,EAAE,eAAe,CAAC;IAC5B,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAShD;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAOpD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAK,EACL,IAAI,EACJ,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,OAAO,EACP,SAAS,EACT,GAAG,EACH,GAAG,EACH,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,KAAe,EACf,aAAa,EAAE,MAAM,GACtB,EAAE,eAAe,+BA4GjB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId } from 'react';
|
|
3
|
+
import { SearchableSelect } from './SearchableSelect.js';
|
|
4
|
+
/**
|
|
5
|
+
* `datetime-local` will not accept an ISO instant, and says nothing about it.
|
|
6
|
+
*
|
|
7
|
+
* `<input type="datetime-local" value="2026-08-20T13:45:00Z">` renders **empty**
|
|
8
|
+
* — the trailing `Z` makes the value invalid for that input, and browsers
|
|
9
|
+
* silently blank an invalid value rather than reporting one. The symptom is a
|
|
10
|
+
* date field that looks unset for a setting that is set, and the fix is not
|
|
11
|
+
* discoverable from the markup.
|
|
12
|
+
*
|
|
13
|
+
* So the instant is shown in the viewer's own timezone and converted back on
|
|
14
|
+
* the way out. What is stored stays an ISO instant; what is displayed is the
|
|
15
|
+
* local time, which is what the person setting "send the digest at" means.
|
|
16
|
+
*
|
|
17
|
+
* **Seconds are rendered, and `step` defaults to 1 so the browser shows them.**
|
|
18
|
+
* A `datetime-local` at its default step is minute-granular: it displays
|
|
19
|
+
* `13:45` for a value of `13:45:37`, and the moment anyone edits the field the
|
|
20
|
+
* `:37` is gone — the box never showed it, so nothing looks lost. Rendering
|
|
21
|
+
* seconds makes the field display exactly what an edit will keep.
|
|
22
|
+
*
|
|
23
|
+
* Milliseconds are still dropped by an edit, and there is no `step` that fixes
|
|
24
|
+
* that honestly: a control that showed `.000` for every value would be
|
|
25
|
+
* inventing precision it cannot offer. A setting needing sub-second precision
|
|
26
|
+
* wants `text` and its own format.
|
|
27
|
+
*
|
|
28
|
+
* Exported so this conversion can be tested for what it is. jsdom normalises a
|
|
29
|
+
* `datetime-local` value down to minutes whatever the step, so reading the
|
|
30
|
+
* rendered input back proves nothing about the seconds — the rule has to be
|
|
31
|
+
* asserted on the function.
|
|
32
|
+
*/
|
|
33
|
+
export function toLocalInput(iso) {
|
|
34
|
+
if (iso.trim() === '')
|
|
35
|
+
return '';
|
|
36
|
+
const date = new Date(iso);
|
|
37
|
+
if (Number.isNaN(date.getTime()))
|
|
38
|
+
return '';
|
|
39
|
+
const pad = (part) => String(part).padStart(2, '0');
|
|
40
|
+
return (`${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}` +
|
|
41
|
+
`T${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`);
|
|
42
|
+
}
|
|
43
|
+
export function fromLocalInput(local) {
|
|
44
|
+
if (local === '')
|
|
45
|
+
return '';
|
|
46
|
+
const date = new Date(local);
|
|
47
|
+
// An unparseable half-typed value is handed back untouched rather than
|
|
48
|
+
// becoming an empty string — otherwise the field clears itself under you as
|
|
49
|
+
// you type into it.
|
|
50
|
+
return Number.isNaN(date.getTime()) ? local : date.toISOString();
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* One field, whichever kind of value it holds.
|
|
54
|
+
*
|
|
55
|
+
* The control every admin form in this organisation was writing a `switch` for:
|
|
56
|
+
* a checkbox for booleans, a date picker for dates, a searchable select for a
|
|
57
|
+
* reference to a record, a textarea for JSON. Written once, it is also the
|
|
58
|
+
* thing that makes them all agree — a boolean edited on one page and a boolean
|
|
59
|
+
* edited on another should not be a checkbox in one place and a Yes/No dropdown
|
|
60
|
+
* in the other.
|
|
61
|
+
*
|
|
62
|
+
* Markup is plain semantic HTML with `ctl-` class names and no styling
|
|
63
|
+
* dependency; `choice` and `reference` delegate to {@link SearchableSelect}, so
|
|
64
|
+
* a field over forty thousand records is the same component as a field over
|
|
65
|
+
* three.
|
|
66
|
+
*/
|
|
67
|
+
export function ValueInput({ type, value, onChange, label, error, hint, placeholder, disabled, readOnly, required, options, transport, min, max, step, rows, className, theme = 'light', 'data-testid': testId, }) {
|
|
68
|
+
const id = useId();
|
|
69
|
+
const root = `ctl ctl-field${className === undefined ? '' : ` ${className}`}`;
|
|
70
|
+
// A picker is a whole control of its own, with its own label and its own
|
|
71
|
+
// root — wrapping it in a second `.ctl` would nest two popover contexts and
|
|
72
|
+
// two labels for one field.
|
|
73
|
+
if (type === 'choice' || type === 'reference') {
|
|
74
|
+
return (_jsx(SearchableSelect, { ...(label === undefined ? {} : { label }), ...(options === undefined ? {} : { options }), ...(transport === undefined ? {} : { transport }), ...(placeholder === undefined ? {} : { placeholder }), ...(testId === undefined ? {} : { 'data-testid': testId }), ...(className === undefined ? {} : { className }), value: value === '' ? null : value, onChange: (next) => onChange(next ?? ''), disabled: disabled === true || readOnly === true, clearable: required !== true, theme: theme }));
|
|
75
|
+
}
|
|
76
|
+
// `null` and `undefined` both mean "no error", and so does an empty string —
|
|
77
|
+
// a caller mapping a validator's output straight through should not have to
|
|
78
|
+
// normalise which of the three it produces.
|
|
79
|
+
const hasError = error !== undefined && error !== null && error !== '';
|
|
80
|
+
const described = hasError ? `${id}-error` : hint === undefined ? undefined : `${id}-hint`;
|
|
81
|
+
const shared = {
|
|
82
|
+
id,
|
|
83
|
+
disabled,
|
|
84
|
+
readOnly,
|
|
85
|
+
required,
|
|
86
|
+
'aria-invalid': hasError ? true : undefined,
|
|
87
|
+
'aria-describedby': described,
|
|
88
|
+
'data-testid': testId,
|
|
89
|
+
};
|
|
90
|
+
return (_jsxs("div", { className: root, "data-ctl-theme": theme, children: [label !== undefined && (_jsx("label", { className: "ctl-label", htmlFor: id, children: label })), type === 'boolean' ? (_jsxs("label", { className: "ctl-switch", children: [_jsx("input", { ...shared, type: "checkbox", className: "ctl-switch-box", checked: value === 'true',
|
|
91
|
+
// Never `!checked` off the current string: a value of `'yes'` reads
|
|
92
|
+
// as unchecked, and toggling it would then write `'true'` — which
|
|
93
|
+
// is right — but toggling a value of `'1'` must not write `'false'`
|
|
94
|
+
// and quietly turn a feature off.
|
|
95
|
+
onChange: (event) => onChange(event.target.checked ? 'true' : 'false') }), _jsx("span", { className: "ctl-switch-text", children: value === 'true' ? 'On' : 'Off' })] })) : type === 'multiline' || type === 'json' ? (_jsx("textarea", { ...shared, className: `ctl-textarea${type === 'json' ? ' ctl-mono' : ''}`, value: value, rows: rows ?? (type === 'json' ? 6 : 3), placeholder: placeholder, onChange: (event) => onChange(event.target.value) })) : type === 'datetime' ? (_jsx("input", { ...shared, type: "datetime-local", className: "ctl-input",
|
|
96
|
+
// Without a step of 1 the browser renders no seconds field *and*
|
|
97
|
+
// rejects a value that carries seconds — which blanks the box.
|
|
98
|
+
step: step ?? 1, value: toLocalInput(value), onChange: (event) => onChange(fromLocalInput(event.target.value)) })) : (_jsx("input", { ...shared, type: type === 'number' ? 'number' : type === 'date' ? 'date' : 'text', className: "ctl-input", value: value, placeholder: placeholder, min: min, max: max, step: type === 'number' ? (step ?? 'any') : undefined, onChange: (event) => onChange(event.target.value) })), hasError ? (_jsx("p", { className: "ctl-note ctl-error", id: `${id}-error`, role: "alert", children: error })) : hint === undefined ? null : (_jsx("p", { className: "ctl-note", id: `${id}-hint`, children: hint }))] }));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=ValueInput.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValueInput.js","sourceRoot":"","sources":["../src/ValueInput.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AA+DzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW;IACtC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC;IAC3B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5C,MAAM,GAAG,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IACpE,OAAO,CACL,GAAG,IAAI,CAAC,WAAW,EAAE,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE;QAC1E,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,CAC/E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,IAAI,KAAK,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IAC5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AAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GACjE,CACH,CAAC,CAAC,CAAC,CACF,mBACM,MAAM,EACV,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EACtE,SAAS,EAAC,WAAW,EACrB,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,WAAW,EACxB,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EACrD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GACjD,CACH,EAEA,QAAQ,CAAC,CAAC,CAAC,CACV,YAAG,SAAS,EAAC,oBAAoB,EAAC,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,YAC9D,KAAK,GACJ,CACL,CAAC,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAC9B,YAAG,SAAS,EAAC,UAAU,EAAC,EAAE,EAAE,GAAG,EAAE,OAAO,YACrC,IAAI,GACH,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
*
|
|
5
5
|
* One package that grows: a control that turns out to be needed in two places
|
|
6
6
|
* belongs here rather than being copied into the second one. Today that is a
|
|
7
|
-
* searchable multi-select and its single-select sibling
|
|
7
|
+
* searchable multi-select and its single-select sibling, the typed field
|
|
8
|
+
* `<ValueInput>` that picks an editor from the kind of value it holds,
|
|
9
|
+
* `<KeyValueList>` for a setting that is really several, and the `<Modal>`
|
|
10
|
+
* shell every console was otherwise going to write for itself.
|
|
8
11
|
*
|
|
9
12
|
* Each control takes either a fixed array of options or an
|
|
10
13
|
* {@link OptionTransport}, and behaves the same either way — the difference
|
|
@@ -33,6 +36,9 @@
|
|
|
33
36
|
*/
|
|
34
37
|
export { SearchableMultiSelect, type SearchableMultiSelectProps, } from './SearchableMultiSelect.js';
|
|
35
38
|
export { SearchableSelect, type SearchableSelectProps } from './SearchableSelect.js';
|
|
39
|
+
export { Modal, type ModalProps } from './Modal.js';
|
|
40
|
+
export { ValueInput, type ValueInputProps, type ValueInputType } from './ValueInput.js';
|
|
41
|
+
export { KeyValueList, type KeyValueItem, type KeyValueItemType, type KeyValueListProps, } from './KeyValueList.js';
|
|
36
42
|
export { useOptionSelect, type OptionSelectState, type UseOptionSelectOptions, } from './useOptionSelect.js';
|
|
37
43
|
/**
|
|
38
44
|
* Re-exported from `@speles7172/controls-client/core` so a frontend that only
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAErF,OAAO,EAAE,KAAK,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAExF,OAAO,EACL,YAAY,EACZ,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,GACvB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,KAAK,iBAAiB,EACtB,KAAK,sBAAsB,GAC5B,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,kCAAkC,CAAC;AAE1C,YAAY,EACV,YAAY,EACZ,MAAM,EACN,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
*
|
|
5
5
|
* One package that grows: a control that turns out to be needed in two places
|
|
6
6
|
* belongs here rather than being copied into the second one. Today that is a
|
|
7
|
-
* searchable multi-select and its single-select sibling
|
|
7
|
+
* searchable multi-select and its single-select sibling, the typed field
|
|
8
|
+
* `<ValueInput>` that picks an editor from the kind of value it holds,
|
|
9
|
+
* `<KeyValueList>` for a setting that is really several, and the `<Modal>`
|
|
10
|
+
* shell every console was otherwise going to write for itself.
|
|
8
11
|
*
|
|
9
12
|
* Each control takes either a fixed array of options or an
|
|
10
13
|
* {@link OptionTransport}, and behaves the same either way — the difference
|
|
@@ -33,6 +36,9 @@
|
|
|
33
36
|
*/
|
|
34
37
|
export { SearchableMultiSelect, } from './SearchableMultiSelect.js';
|
|
35
38
|
export { SearchableSelect } from './SearchableSelect.js';
|
|
39
|
+
export { Modal } from './Modal.js';
|
|
40
|
+
export { ValueInput } from './ValueInput.js';
|
|
41
|
+
export { KeyValueList, } from './KeyValueList.js';
|
|
36
42
|
export { useOptionSelect, } from './useOptionSelect.js';
|
|
37
43
|
/**
|
|
38
44
|
* Re-exported from `@speles7172/controls-client/core` so a frontend that only
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EACL,qBAAqB,GAEtB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAA8B,MAAM,uBAAuB,CAAC;AAErF,OAAO,EAAE,KAAK,EAAmB,MAAM,YAAY,CAAC;AAEpD,OAAO,EAAE,UAAU,EAA6C,MAAM,iBAAiB,CAAC;AAExF,OAAO,EACL,YAAY,GAIb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,GAGhB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,OAAO,EACL,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,kCAAkC,CAAC"}
|