@sdxc/ui 2026.10.16 → 2026.10.20
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 +5 -1
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/attachment.js +1 -1
- package/dist/components/calendar.js +1 -1
- package/dist/components/color-picker.js +1 -1
- package/dist/components/command.js +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.js +1 -1
- package/dist/components/dialog.js +1 -1
- package/dist/components/file-trigger.js +1 -1
- package/dist/components/heading-scope.js +1 -1
- package/dist/components/message-scroller.js +1 -1
- package/dist/components/number-field.js +2 -2
- package/dist/components/range-calendar.js +1 -1
- package/dist/components/resizable.js +1 -1
- package/dist/components/select.js +2 -2
- package/dist/components/shared-element.js +1 -1
- package/dist/mixins/active-descendant-keys.d.ts +34 -0
- package/dist/mixins/active-descendant-keys.js +88 -0
- package/dist/mixins/attachment-trigger.js +2 -2
- package/dist/mixins/color-preview.js +1 -1
- package/dist/mixins/context-menu.js +1 -1
- package/dist/mixins/copy-to-clipboard.js +1 -1
- package/dist/mixins/hotkey.js +2 -2
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/live-frame.d.ts +66 -0
- package/dist/mixins/live-frame.js +96 -0
- package/dist/mixins/persist.js +1 -1
- package/dist/mixins/validate.js +1 -1
- package/dist/utils/warn-if-no-accessible-name.js +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -253,6 +253,7 @@ Each mixin module documents why it needs JavaScript and what still works without
|
|
|
253
253
|
|
|
254
254
|
| Mixin | Host | Adds |
|
|
255
255
|
| ------------------------------- | -------------------------- | ----------------------------------------------------------------------- |
|
|
256
|
+
| `activeDescendantKeys()` | a combobox input | Arrows over its `aria-controls` options; Enter follows the chosen link. |
|
|
256
257
|
| `ariaChecked()` | checkbox, switch or radio | `aria-checked` kept in step with the live control. |
|
|
257
258
|
| `attachmentTrigger()` | `Attachment.Trigger` | The whole card as one activation target. |
|
|
258
259
|
| `calendarKeys(model)` | `Calendar.Grid` | Arrow/Page/Home/End navigation over a `CalendarModel`. |
|
|
@@ -277,6 +278,7 @@ Each mixin module documents why it needs JavaScript and what still works without
|
|
|
277
278
|
| `hotkey(combo)` | a `<dialog>`/`[popover]` | A document-wide shortcut toggling its host. |
|
|
278
279
|
| `imageFallback()` | an `Avatar`/`Logo` image | Shows the fallback when the image fails, cached images included. |
|
|
279
280
|
| `keymap(bindings)` | any host | Page-wide shortcuts that stand down in fields and foreign dialogs. |
|
|
281
|
+
| `liveFrame(options)` | a text input in a frame | The frame reloaded from `src(value)` once typing pauses. |
|
|
280
282
|
| `listboxKeys()` | `ListBox` | Arrow, Home/End and typeahead navigation. |
|
|
281
283
|
| `longPress(options?)` | any element | Fires after a pointer holds still for `duration`. |
|
|
282
284
|
| `menuKeys(options?)` | `Menu` | The ARIA menu pattern: roving focus, arrows, typeahead. |
|
|
@@ -302,11 +304,13 @@ Helpers for writing your own:
|
|
|
302
304
|
- `trackHostNode(handle)` — returns a getter for the mixin's current host node.
|
|
303
305
|
- `bindKeymap(document, bindings, { signal, scope? })` — `keymap` without a host, with the same
|
|
304
306
|
stand-down rules as `isClaimedKeystroke(event, scope?)`.
|
|
307
|
+
- `chooseOption(combobox, index)` and `chosenOption(combobox)` — set and read the option
|
|
308
|
+
`activeDescendantKeys` has chosen, after a reload replaces the options.
|
|
305
309
|
- `syncAriaChecked(control)` — refreshes `ariaChecked` after a programmatic checked write or reset.
|
|
306
310
|
- `colorChannelProperty(channel)` and `getCommandItemId(item, index)` — the custom property and the
|
|
307
311
|
item id `channelSync` and `commandFilter` read.
|
|
308
312
|
|
|
309
|
-
Mixins that emit DOM events export their `Event` subclass (`DismissEvent`, `ReorderEvent`,
|
|
313
|
+
Mixins that emit DOM events export their `Event` subclass (`DismissEvent`, `LiveFrameEvent`, `ReorderEvent`,
|
|
310
314
|
`ThemeChangeEvent`, …), and those that read markup export the `data-*` attribute and command names
|
|
311
315
|
they use (`DRAG_REORDER_ROW_ATTRIBUTE`, `SEARCH_FIELD_CLEAR_COMMAND`, …).
|
|
312
316
|
|
|
@@ -142,7 +142,7 @@ AlertDialog.Action = function AlertDialogAction(handle) {
|
|
|
142
142
|
let resolvedType = type ?? DEFAULT_TYPE;
|
|
143
143
|
let isInvoker = resolvedType === "button";
|
|
144
144
|
let resolvedColor = color ?? DEFAULT_ACTION_COLOR;
|
|
145
|
-
if (import.meta.env
|
|
145
|
+
if (import.meta.env?.DEV && isInvoker && !commandfor) {
|
|
146
146
|
console.warn('AlertDialog.Action: needs "commandfor" naming the panel it dismisses, or type="submit" to submit its enclosing form instead — as rendered, pressing it does nothing.');
|
|
147
147
|
}
|
|
148
148
|
return (_jsx(Button, { ...rest, type: resolvedType, color: resolvedColor, commandfor: isInvoker ? commandfor : undefined, command: isInvoker ? (command ?? DEFAULT_COMMAND) : undefined, "data-slot": "action" }));
|
|
@@ -274,7 +274,7 @@ Attachment.Trigger = function AttachmentTrigger(handle) {
|
|
|
274
274
|
let isConfigured = href !== undefined || commandfor !== undefined;
|
|
275
275
|
let resolvedRole = role ?? (href !== undefined ? "link" : isConfigured ? "button" : undefined);
|
|
276
276
|
let resolvedTabIndex = tabIndex ?? (isConfigured ? 0 : undefined);
|
|
277
|
-
if (import.meta.env
|
|
277
|
+
if (import.meta.env?.DEV && !isConfigured) {
|
|
278
278
|
console.warn('Attachment.Trigger: rendered with neither "href" nor "commandfor" — nothing will happen once `attachmentTrigger()` handles an activation.');
|
|
279
279
|
}
|
|
280
280
|
return (_jsx("div", { ...rest, role: resolvedRole, tabIndex: resolvedTabIndex, "data-slot": "trigger", mix: [
|
|
@@ -67,7 +67,7 @@ export function Calendar(handle) {
|
|
|
67
67
|
return () => {
|
|
68
68
|
let { color, name, value, defaultValue, min, max, step, required, disabled, readOnly, autoComplete, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, children, mix, ...rest } = handle.props;
|
|
69
69
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
70
|
-
if (import.meta.env
|
|
70
|
+
if (import.meta.env?.DEV && !children && !ariaLabel && !ariaLabelledBy) {
|
|
71
71
|
console.warn('Calendar: falling back to a plain "input type=date" needs an "aria-label" or "aria-labelledby" describing what it collects for assistive technology.');
|
|
72
72
|
}
|
|
73
73
|
return (_jsx("div", { ...rest, "data-slot": "calendar", mix: [inlineBlock(), rounded("lg"), p(3), bg("neutral.tint"), mix], children: children ?? (_jsx(Input, { type: "date", color: resolvedColor, name: name, value: value, defaultValue: defaultValue, min: min, max: max, step: step, required: required, disabled: disabled, readOnly: readOnly, autoComplete: autoComplete, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy })) }));
|
|
@@ -64,7 +64,7 @@ const DEFAULT_DIALOG_PLACEMENT = "bottom-start";
|
|
|
64
64
|
export function ColorPicker(handle) {
|
|
65
65
|
return () => {
|
|
66
66
|
let { color, label, description, errorMessage, format, name, value, defaultValue, placeholder, required, disabled, readOnly, autoComplete, parts, children, mix, ...rest } = handle.props;
|
|
67
|
-
if (import.meta.env
|
|
67
|
+
if (import.meta.env?.DEV && !children && !label) {
|
|
68
68
|
console.warn('ColorPicker: falling back to ColorField\'s plain color-notation field needs a "label" describing what it collects for assistive technology.');
|
|
69
69
|
}
|
|
70
70
|
if (!children) {
|
|
@@ -122,7 +122,7 @@ Command.List = function CommandList(handle) {
|
|
|
122
122
|
Command.Item = function CommandItem(handle) {
|
|
123
123
|
return () => {
|
|
124
124
|
let { value, children, mix, ...rest } = handle.props;
|
|
125
|
-
if (import.meta.env
|
|
125
|
+
if (import.meta.env?.DEV && !value) {
|
|
126
126
|
console.warn('Command.Item: needs a "value" — a filter behavior matches typed text against this instead of parsing rendered children.');
|
|
127
127
|
}
|
|
128
128
|
return (_jsx("div", { ...rest, "data-slot": "item", "data-value": value, mix: [
|
|
@@ -28,7 +28,7 @@ import { DateField } from "./date-field.js";
|
|
|
28
28
|
export function DatePicker(handle) {
|
|
29
29
|
return () => {
|
|
30
30
|
let { color, label, description, errorMessage, name, value, defaultValue, min, max, step, required, disabled, readOnly, autoComplete, parts, children, mix, ...rest } = handle.props;
|
|
31
|
-
if (import.meta.env
|
|
31
|
+
if (import.meta.env?.DEV && !children && !label) {
|
|
32
32
|
console.warn('DatePicker: falling back to DateField\'s plain "input type=date" needs a "label" describing what it collects for assistive technology.');
|
|
33
33
|
}
|
|
34
34
|
if (!children) {
|
|
@@ -32,7 +32,7 @@ import { DatePicker } from "./date-picker.js";
|
|
|
32
32
|
export function DateRangePicker(handle) {
|
|
33
33
|
return () => {
|
|
34
34
|
let { color, startLabel, endLabel, startDescription, endDescription, startErrorMessage, endErrorMessage, startName, endName, startValue, endValue, startDefaultValue, endDefaultValue, min, max, step, required, disabled, readOnly, autoComplete, parts, children, mix, ...rest } = handle.props;
|
|
35
|
-
if (import.meta.env
|
|
35
|
+
if (import.meta.env?.DEV && !children) {
|
|
36
36
|
if (!startLabel) {
|
|
37
37
|
console.warn('DateRangePicker: falling back to paired "input type=date" fields needs a "startLabel" describing the range\'s start for assistive technology.');
|
|
38
38
|
}
|
|
@@ -59,7 +59,7 @@ const DEFAULT_CLOSE_COMMAND = "close";
|
|
|
59
59
|
export function Dialog(handle) {
|
|
60
60
|
return () => {
|
|
61
61
|
let { id, children, mix, ...rest } = handle.props;
|
|
62
|
-
if (import.meta.env
|
|
62
|
+
if (import.meta.env?.DEV && !id) {
|
|
63
63
|
console.warn('Dialog rendered without an "id" — "commandfor" on a trigger or close control has nothing to target.');
|
|
64
64
|
}
|
|
65
65
|
return (_jsx("dialog", { ...rest, id: id, "data-slot": "dialog", mix: [
|
|
@@ -40,7 +40,7 @@ export function FileTrigger(handle) {
|
|
|
40
40
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
41
41
|
let resolvedVariant = variant ?? DEFAULT_VARIANT;
|
|
42
42
|
let resolvedSize = size ?? DEFAULT_SIZE;
|
|
43
|
-
if (import.meta.env
|
|
43
|
+
if (import.meta.env?.DEV &&
|
|
44
44
|
!handle.props["aria-label"] &&
|
|
45
45
|
!handle.props["aria-labelledby"] &&
|
|
46
46
|
!hasAccessibleText(children)) {
|
|
@@ -48,7 +48,7 @@ export function readAmbientLevel(handle) {
|
|
|
48
48
|
export function resolveHeadingLevel(handle, explicitLevel) {
|
|
49
49
|
let resolved = explicitLevel ?? readAmbientLevel(handle) ?? DEFAULT_LEVEL;
|
|
50
50
|
if (resolved > MAX_LEVEL) {
|
|
51
|
-
if (import.meta.env
|
|
51
|
+
if (import.meta.env?.DEV) {
|
|
52
52
|
console.warn(`Heading nesting resolved to level ${resolved}, past the native "h1"–"h6" range. Flatten the nesting, or start a new top-level HeadingScope instead of nesting further.`);
|
|
53
53
|
}
|
|
54
54
|
return MAX_LEVEL;
|
|
@@ -141,7 +141,7 @@ MessageScroller.Content = function MessageScrollerContent(handle) {
|
|
|
141
141
|
MessageScroller.Item = function MessageScrollerItem(handle) {
|
|
142
142
|
return () => {
|
|
143
143
|
let { messageId, scrollAnchor, children, mix, ...rest } = handle.props;
|
|
144
|
-
if (import.meta.env
|
|
144
|
+
if (import.meta.env?.DEV && !messageId) {
|
|
145
145
|
console.warn('MessageScroller.Item: needs a "messageId" — a scroll-follow behavior matches rows against this instead of parsing rendered children.');
|
|
146
146
|
}
|
|
147
147
|
return (_jsx("div", { ...rest, "data-slot": "item", "data-message-id": messageId, "data-scroll-anchor": scrollAnchor || undefined, mix: [
|
|
@@ -167,7 +167,7 @@ NumberField.Input = function NumberFieldInput(handle) {
|
|
|
167
167
|
NumberField.DecrementButton = function NumberFieldDecrementButton(handle) {
|
|
168
168
|
return () => {
|
|
169
169
|
let { type, mix, ...rest } = handle.props;
|
|
170
|
-
if (import.meta.env
|
|
170
|
+
if (import.meta.env?.DEV && !handle.props["aria-label"] && !handle.props["aria-labelledby"]) {
|
|
171
171
|
console.warn("NumberField.DecrementButton: needs an `aria-label` describing what it does — its content is a decorative glyph with no accessible name of its own.");
|
|
172
172
|
}
|
|
173
173
|
return (_jsx("button", { type: type ?? DEFAULT_BUTTON_TYPE, ...rest, "data-slot": "decrement", mix: [stepperButtonMix("end"), mix], children: _jsx(MinusIcon, {}) }));
|
|
@@ -188,7 +188,7 @@ NumberField.DecrementButton = function NumberFieldDecrementButton(handle) {
|
|
|
188
188
|
NumberField.IncrementButton = function NumberFieldIncrementButton(handle) {
|
|
189
189
|
return () => {
|
|
190
190
|
let { type, mix, ...rest } = handle.props;
|
|
191
|
-
if (import.meta.env
|
|
191
|
+
if (import.meta.env?.DEV && !handle.props["aria-label"] && !handle.props["aria-labelledby"]) {
|
|
192
192
|
console.warn("NumberField.IncrementButton: needs an `aria-label` describing what it does — its content is a decorative glyph with no accessible name of its own.");
|
|
193
193
|
}
|
|
194
194
|
return (_jsx("button", { type: type ?? DEFAULT_BUTTON_TYPE, ...rest, "data-slot": "increment", mix: [stepperButtonMix("start"), mix], children: _jsx(PlusIcon, {}) }));
|
|
@@ -55,7 +55,7 @@ export function RangeCalendar(handle) {
|
|
|
55
55
|
return () => {
|
|
56
56
|
let { color, startName, endName, startValue, endValue, startDefaultValue, endDefaultValue, min, max, step, required, disabled, readOnly, autoComplete, startLabel, endLabel, parts, children, mix, ...rest } = handle.props;
|
|
57
57
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
58
|
-
if (import.meta.env
|
|
58
|
+
if (import.meta.env?.DEV && !children) {
|
|
59
59
|
if (!startLabel) {
|
|
60
60
|
console.warn('RangeCalendar: falling back to a plain "input type=date" pair needs a "startLabel" describing the range\'s start for assistive technology.');
|
|
61
61
|
}
|
|
@@ -118,7 +118,7 @@ Resizable.Handle = function ResizableHandle(handle) {
|
|
|
118
118
|
return () => {
|
|
119
119
|
let { mix, ...rest } = handle.props;
|
|
120
120
|
let context = handle.context.get(Resizable);
|
|
121
|
-
if (import.meta.env
|
|
121
|
+
if (import.meta.env?.DEV && !rest["aria-label"] && !rest["aria-labelledby"]) {
|
|
122
122
|
console.warn("Resizable.Handle: a resize handle with no `aria-label` or `aria-labelledby` needs one describing what it resizes — assistive technology has no accessible name to announce otherwise.");
|
|
123
123
|
}
|
|
124
124
|
return (_jsx("div", { "data-orientation": context.orientation, "aria-orientation": context.orientation, ...rest, mix: [
|
|
@@ -53,7 +53,7 @@ export function Select(handle) {
|
|
|
53
53
|
return () => {
|
|
54
54
|
let { color, multiple, size, mix, ...rest } = handle.props;
|
|
55
55
|
let resolvedColor = color ?? DEFAULT_COLOR;
|
|
56
|
-
if (import.meta.env
|
|
56
|
+
if (import.meta.env?.DEV && (multiple || (typeof size === "number" && size > 1))) {
|
|
57
57
|
console.warn("Select: `appearance: base-select` styling has no effect on a `multiple` select or one with a `size` greater than 1 — the browser keeps its plain list-box rendering there instead of the customized trigger, value, and option styling.");
|
|
58
58
|
}
|
|
59
59
|
let fieldMix = [
|
|
@@ -263,7 +263,7 @@ Select.Option = function SelectOption(handle) {
|
|
|
263
263
|
Select.Group = function SelectGroup(handle) {
|
|
264
264
|
return () => {
|
|
265
265
|
let { mix, ...rest } = handle.props;
|
|
266
|
-
if (import.meta.env
|
|
266
|
+
if (import.meta.env?.DEV && !rest.label) {
|
|
267
267
|
console.warn("Select.Group: an `optgroup` with no `label` renders with no visible heading for its options — pass a `label` describing the group.");
|
|
268
268
|
}
|
|
269
269
|
return (_jsx("optgroup", { ...rest, mix: [
|
|
@@ -39,7 +39,7 @@ const CROSS_DOCUMENT_TRANSITION_STYLESHEET = `
|
|
|
39
39
|
export function SharedElement(handle) {
|
|
40
40
|
return () => {
|
|
41
41
|
let { id, mix, style, ...rest } = handle.props;
|
|
42
|
-
if (import.meta.env
|
|
42
|
+
if (import.meta.env?.DEV && !id) {
|
|
43
43
|
console.warn('SharedElement rendered without an "id" — the browser has nothing to match it against on the other side of a cross-document view transition.');
|
|
44
44
|
}
|
|
45
45
|
let resolvedStyle = mergeStyle(style, { "view-transition-name": id });
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The combobox keyboard pattern over options a server rendered: arrows choose a row of the
|
|
3
|
+
* listbox the host's `aria-controls` names while focus stays in the host, and Enter follows
|
|
4
|
+
* it. Without JS every option is still a link a reader can tab to.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { MixinFactory } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* The index of the option `combobox` has chosen, or `-1` while the combobox itself is the
|
|
12
|
+
* choice. The choice lives in `aria-activedescendant`, so it reads the same to every caller.
|
|
13
|
+
*
|
|
14
|
+
* @param combobox The element carrying `aria-controls` and `aria-activedescendant`.
|
|
15
|
+
* @returns The chosen option's index among the controlled listbox's options.
|
|
16
|
+
*/
|
|
17
|
+
export declare function chosenOption(combobox: HTMLElement): number;
|
|
18
|
+
/**
|
|
19
|
+
* Chooses the option at `index`, or none for `-1`, marking it `aria-selected` and scrolling it
|
|
20
|
+
* into view. Call it after replacing the options, since a new list starts with whatever
|
|
21
|
+
* choice its markup carries.
|
|
22
|
+
*
|
|
23
|
+
* @param combobox The element carrying `aria-controls`.
|
|
24
|
+
* @param index The option to choose, or `-1` to choose none.
|
|
25
|
+
*/
|
|
26
|
+
export declare function chooseOption(combobox: HTMLElement, index: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Moves the choice through the controlled options: Down from the host to the first and around
|
|
29
|
+
* from the last, Up back toward the host. Enter follows the chosen option, or the only option
|
|
30
|
+
* when none is chosen and the listbox sits in no `aria-busy` region, so stale rows never open.
|
|
31
|
+
*
|
|
32
|
+
* @example <input role="combobox" aria-controls="search-options" mix={[activeDescendantKeys()]} />
|
|
33
|
+
*/
|
|
34
|
+
export declare const activeDescendantKeys: MixinFactory<HTMLElement>;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The combobox keyboard pattern over options a server rendered: arrows choose a row of the
|
|
3
|
+
* listbox the host's `aria-controls` names while focus stays in the host, and Enter follows
|
|
4
|
+
* it. Without JS every option is still a link a reader can tab to.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createMixin } from "remix/component";
|
|
10
|
+
/** Every option of the listbox `combobox` controls, in document order. */
|
|
11
|
+
function optionsOf(combobox) {
|
|
12
|
+
let id = combobox.getAttribute("aria-controls");
|
|
13
|
+
let listbox = id ? combobox.ownerDocument.getElementById(id) : null;
|
|
14
|
+
return listbox ? Array.from(listbox.querySelectorAll('[role="option"]')) : [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The index of the option `combobox` has chosen, or `-1` while the combobox itself is the
|
|
18
|
+
* choice. The choice lives in `aria-activedescendant`, so it reads the same to every caller.
|
|
19
|
+
*
|
|
20
|
+
* @param combobox The element carrying `aria-controls` and `aria-activedescendant`.
|
|
21
|
+
* @returns The chosen option's index among the controlled listbox's options.
|
|
22
|
+
*/
|
|
23
|
+
export function chosenOption(combobox) {
|
|
24
|
+
let active = combobox.getAttribute("aria-activedescendant");
|
|
25
|
+
if (!active)
|
|
26
|
+
return -1;
|
|
27
|
+
return optionsOf(combobox).findIndex((option) => option.id === active);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Chooses the option at `index`, or none for `-1`, marking it `aria-selected` and scrolling it
|
|
31
|
+
* into view. Call it after replacing the options, since a new list starts with whatever
|
|
32
|
+
* choice its markup carries.
|
|
33
|
+
*
|
|
34
|
+
* @param combobox The element carrying `aria-controls`.
|
|
35
|
+
* @param index The option to choose, or `-1` to choose none.
|
|
36
|
+
*/
|
|
37
|
+
export function chooseOption(combobox, index) {
|
|
38
|
+
let options = optionsOf(combobox);
|
|
39
|
+
let chosen = options[index];
|
|
40
|
+
options.forEach((option) => option.setAttribute("aria-selected", String(option === chosen)));
|
|
41
|
+
if (chosen?.id)
|
|
42
|
+
combobox.setAttribute("aria-activedescendant", chosen.id);
|
|
43
|
+
else
|
|
44
|
+
combobox.removeAttribute("aria-activedescendant");
|
|
45
|
+
chosen?.scrollIntoView?.({ block: "nearest" });
|
|
46
|
+
}
|
|
47
|
+
/** Activates an option as a click would: its link when it holds one, else the option itself. */
|
|
48
|
+
function follow(option) {
|
|
49
|
+
(option.querySelector("a[href]") ?? option).click();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Moves the choice through the controlled options: Down from the host to the first and around
|
|
53
|
+
* from the last, Up back toward the host. Enter follows the chosen option, or the only option
|
|
54
|
+
* when none is chosen and the listbox sits in no `aria-busy` region, so stale rows never open.
|
|
55
|
+
*
|
|
56
|
+
* @example <input role="combobox" aria-controls="search-options" mix={[activeDescendantKeys()]} />
|
|
57
|
+
*/
|
|
58
|
+
export const activeDescendantKeys = createMixin((handle) => {
|
|
59
|
+
handle.addEventListener("insert", (event) => {
|
|
60
|
+
let host = event.node;
|
|
61
|
+
host.addEventListener("keydown", (keyEvent) => {
|
|
62
|
+
if (keyEvent.defaultPrevented || keyEvent.isComposing)
|
|
63
|
+
return;
|
|
64
|
+
let options = optionsOf(host);
|
|
65
|
+
let chosen = chosenOption(host);
|
|
66
|
+
if (keyEvent.key === "ArrowDown" && options.length > 0) {
|
|
67
|
+
keyEvent.preventDefault();
|
|
68
|
+
chooseOption(host, chosen + 1 >= options.length ? 0 : chosen + 1);
|
|
69
|
+
}
|
|
70
|
+
else if (keyEvent.key === "ArrowUp" && chosen >= 0) {
|
|
71
|
+
keyEvent.preventDefault();
|
|
72
|
+
chooseOption(host, chosen - 1);
|
|
73
|
+
}
|
|
74
|
+
else if (keyEvent.key === "Enter" && options[chosen]) {
|
|
75
|
+
keyEvent.preventDefault();
|
|
76
|
+
follow(options[chosen]);
|
|
77
|
+
}
|
|
78
|
+
else if (keyEvent.key === "Enter" &&
|
|
79
|
+
options.length === 1 &&
|
|
80
|
+
options[0] &&
|
|
81
|
+
!options[0].closest('[aria-busy="true"]')) {
|
|
82
|
+
keyEvent.preventDefault();
|
|
83
|
+
follow(options[0]);
|
|
84
|
+
}
|
|
85
|
+
}, { signal: handle.signal });
|
|
86
|
+
});
|
|
87
|
+
return () => { };
|
|
88
|
+
});
|
|
@@ -56,14 +56,14 @@ function resolveAction(host) {
|
|
|
56
56
|
return undefined;
|
|
57
57
|
let command = host.getAttribute("command") ?? DEFAULT_DIALOG_COMMAND;
|
|
58
58
|
if (command !== DEFAULT_DIALOG_COMMAND) {
|
|
59
|
-
if (import.meta.env
|
|
59
|
+
if (import.meta.env?.DEV) {
|
|
60
60
|
console.warn(`attachmentTrigger(): unsupported command "${command}" — only "${DEFAULT_DIALOG_COMMAND}" opens a dialog from a card activation.`);
|
|
61
61
|
}
|
|
62
62
|
return undefined;
|
|
63
63
|
}
|
|
64
64
|
let dialog = document.getElementById(commandForId);
|
|
65
65
|
if (!(dialog instanceof HTMLDialogElement)) {
|
|
66
|
-
if (import.meta.env
|
|
66
|
+
if (import.meta.env?.DEV) {
|
|
67
67
|
console.warn(`attachmentTrigger(): commandfor="${commandForId}" doesn't reference a <dialog> element.`);
|
|
68
68
|
}
|
|
69
69
|
return undefined;
|
|
@@ -64,7 +64,7 @@ export const colorPreview = createMixin((handle) => {
|
|
|
64
64
|
let host = event.currentTarget;
|
|
65
65
|
let swatch = findSwatch(host);
|
|
66
66
|
if (swatch === null) {
|
|
67
|
-
if (import.meta.env
|
|
67
|
+
if (import.meta.env?.DEV && !hasWarnedMissingSwatch) {
|
|
68
68
|
hasWarnedMissingSwatch = true;
|
|
69
69
|
console.warn(`colorPreview(): no element matching ${SWATCH_SELECTOR} found beneath the ColorField host to update.`);
|
|
70
70
|
}
|
|
@@ -39,7 +39,7 @@ export const contextMenu = createMixin((handle) => {
|
|
|
39
39
|
function openSurfaceAt(id, point, options) {
|
|
40
40
|
let surface = document.getElementById(id);
|
|
41
41
|
if (!surface) {
|
|
42
|
-
if (import.meta.env
|
|
42
|
+
if (import.meta.env?.DEV) {
|
|
43
43
|
console.warn(`contextMenu(): no element with id "${id}" found to open.`);
|
|
44
44
|
}
|
|
45
45
|
return;
|
|
@@ -98,7 +98,7 @@ export const copyToClipboard = createMixin((handle) => {
|
|
|
98
98
|
return;
|
|
99
99
|
let target = resolveCopyTarget(button);
|
|
100
100
|
if (!target) {
|
|
101
|
-
if (import.meta.env
|
|
101
|
+
if (import.meta.env?.DEV) {
|
|
102
102
|
console.warn('copyToClipboard(): button has no "commandfor" target to copy text from.');
|
|
103
103
|
}
|
|
104
104
|
return;
|
package/dist/mixins/hotkey.js
CHANGED
|
@@ -39,7 +39,7 @@ function setOpen(host, open) {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
if (!host.hasAttribute("popover")) {
|
|
42
|
-
if (import.meta.env
|
|
42
|
+
if (import.meta.env?.DEV) {
|
|
43
43
|
console.warn(`hotkey(): host is neither a <dialog> nor a [popover] element, so it cannot be ${open ? "shown" : "hidden"}.`);
|
|
44
44
|
}
|
|
45
45
|
return;
|
|
@@ -86,7 +86,7 @@ export const hotkey = createMixin((handle) => {
|
|
|
86
86
|
});
|
|
87
87
|
return (combo) => {
|
|
88
88
|
parsed = parseKeyCombo(combo);
|
|
89
|
-
if (parsed.key === "" && import.meta.env
|
|
89
|
+
if (parsed.key === "" && import.meta.env?.DEV) {
|
|
90
90
|
console.warn(`hotkey(): "${combo}" has no trigger key and will never match.`);
|
|
91
91
|
}
|
|
92
92
|
};
|
package/dist/mixins/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
|
+
export * from "./active-descendant-keys.js";
|
|
9
10
|
export * from "./aria-checked.js";
|
|
10
11
|
export * from "./attachment-trigger.js";
|
|
11
12
|
export * from "./calendar-keys.js";
|
|
@@ -30,6 +31,7 @@ export * from "./heading-level-fallback.js";
|
|
|
30
31
|
export * from "./hotkey.js";
|
|
31
32
|
export * from "./image-fallback.js";
|
|
32
33
|
export * from "./keymap.js";
|
|
34
|
+
export * from "./live-frame.js";
|
|
33
35
|
export * from "./listbox-keys.js";
|
|
34
36
|
export * from "./long-press.js";
|
|
35
37
|
export * from "./menu-keys.js";
|
package/dist/mixins/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
7
|
* @copyright Sergio Xalambrí 2026
|
|
8
8
|
*/
|
|
9
|
+
export * from "./active-descendant-keys.js";
|
|
9
10
|
export * from "./aria-checked.js";
|
|
10
11
|
export * from "./attachment-trigger.js";
|
|
11
12
|
export * from "./calendar-keys.js";
|
|
@@ -30,6 +31,7 @@ export * from "./heading-level-fallback.js";
|
|
|
30
31
|
export * from "./hotkey.js";
|
|
31
32
|
export * from "./image-fallback.js";
|
|
32
33
|
export * from "./keymap.js";
|
|
34
|
+
export * from "./live-frame.js";
|
|
33
35
|
export * from "./listbox-keys.js";
|
|
34
36
|
export * from "./long-press.js";
|
|
35
37
|
export * from "./menu-keys.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live results for a text control rendered inside a frame: once typing pauses, the frame is
|
|
3
|
+
* pointed at the address for the control's value and reloaded. Without JS the control still
|
|
4
|
+
* submits its form, so the same address answers as a full page.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { MixinFactory } from "remix/component";
|
|
10
|
+
/** DOM event type dispatched by {@link liveFrame} as a reload moves through its states. */
|
|
11
|
+
declare const LIVE_FRAME_EVENT: "ui:live-frame";
|
|
12
|
+
/** DOM event type a consumer dispatches on a {@link liveFrame} host to reload it at once. */
|
|
13
|
+
export declare const LIVE_FRAME_RELOAD_EVENT = "ui:live-frame-reload";
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementEventMap {
|
|
16
|
+
[LIVE_FRAME_EVENT]: LiveFrameEvent;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Types for {@link liveFrame}. */
|
|
20
|
+
export declare namespace LiveFrame {
|
|
21
|
+
/**
|
|
22
|
+
* Where a reload stands: `pending` once the value moves past what the frame shows, `slow`
|
|
23
|
+
* once that has lasted past `slowAfter`, `loading` just before the frame is replaced, and
|
|
24
|
+
* `settled` once the frame shows the newest value.
|
|
25
|
+
*/
|
|
26
|
+
type State = "pending" | "slow" | "loading" | "settled";
|
|
27
|
+
/** Configuration for {@link liveFrame}. */
|
|
28
|
+
interface Options {
|
|
29
|
+
/** The frame address for a value, read each time the frame reloads. */
|
|
30
|
+
src: (value: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* @default 200
|
|
33
|
+
*/
|
|
34
|
+
debounce?: number;
|
|
35
|
+
/**
|
|
36
|
+
* @default 350
|
|
37
|
+
*/
|
|
38
|
+
slowAfter?: number;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Dispatched on a {@link liveFrame} host as a reload moves through its states. Only the reload
|
|
43
|
+
* for the newest value settles, so an answer to an older value never ends a newer wait.
|
|
44
|
+
*/
|
|
45
|
+
export declare class LiveFrameEvent extends Event {
|
|
46
|
+
readonly state: LiveFrame.State;
|
|
47
|
+
/** The address the frame is loading or showing. */
|
|
48
|
+
readonly src: string;
|
|
49
|
+
/**
|
|
50
|
+
* @param init The reload's state and the address it concerns.
|
|
51
|
+
*/
|
|
52
|
+
constructor(init: {
|
|
53
|
+
state: LiveFrame.State;
|
|
54
|
+
src: string;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Reloads the host's frame from `src(value)` once typing pauses, and at once on
|
|
59
|
+
* {@link LIVE_FRAME_RELOAD_EVENT}, which a consumer dispatches after changing the value or
|
|
60
|
+
* anything else `src` reads. A value whose address the frame already shows settles in place.
|
|
61
|
+
*
|
|
62
|
+
* @example <input name="q" mix={[liveFrame({ src: (q) => `/frames/search?q=${encodeURIComponent(q)}` })]} />
|
|
63
|
+
* @example input.value = ""; input.dispatchEvent(new Event(LIVE_FRAME_RELOAD_EVENT));
|
|
64
|
+
*/
|
|
65
|
+
export declare const liveFrame: MixinFactory<HTMLInputElement, [options: LiveFrame.Options]>;
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Live results for a text control rendered inside a frame: once typing pauses, the frame is
|
|
3
|
+
* pointed at the address for the control's value and reloaded. Without JS the control still
|
|
4
|
+
* submits its form, so the same address answers as a full page.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createMixin } from "remix/component";
|
|
10
|
+
/** DOM event type dispatched by {@link liveFrame} as a reload moves through its states. */
|
|
11
|
+
const LIVE_FRAME_EVENT = "ui:live-frame";
|
|
12
|
+
/** DOM event type a consumer dispatches on a {@link liveFrame} host to reload it at once. */
|
|
13
|
+
export const LIVE_FRAME_RELOAD_EVENT = "ui:live-frame-reload";
|
|
14
|
+
/** How long typing must pause, in milliseconds, before the frame follows it. */
|
|
15
|
+
const DEFAULT_DEBOUNCE = 200;
|
|
16
|
+
/**
|
|
17
|
+
* How long a reload may run, in milliseconds, before it counts as slow. Results arriving
|
|
18
|
+
* within it swap in before any loading indicator would flash.
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_SLOW_AFTER = 350;
|
|
21
|
+
/**
|
|
22
|
+
* Dispatched on a {@link liveFrame} host as a reload moves through its states. Only the reload
|
|
23
|
+
* for the newest value settles, so an answer to an older value never ends a newer wait.
|
|
24
|
+
*/
|
|
25
|
+
export class LiveFrameEvent extends Event {
|
|
26
|
+
state;
|
|
27
|
+
/** The address the frame is loading or showing. */
|
|
28
|
+
src;
|
|
29
|
+
/**
|
|
30
|
+
* @param init The reload's state and the address it concerns.
|
|
31
|
+
*/
|
|
32
|
+
constructor(init) {
|
|
33
|
+
super(LIVE_FRAME_EVENT, { bubbles: true });
|
|
34
|
+
this.state = init.state;
|
|
35
|
+
this.src = init.src;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reloads the host's frame from `src(value)` once typing pauses, and at once on
|
|
40
|
+
* {@link LIVE_FRAME_RELOAD_EVENT}, which a consumer dispatches after changing the value or
|
|
41
|
+
* anything else `src` reads. A value whose address the frame already shows settles in place.
|
|
42
|
+
*
|
|
43
|
+
* @example <input name="q" mix={[liveFrame({ src: (q) => `/frames/search?q=${encodeURIComponent(q)}` })]} />
|
|
44
|
+
* @example input.value = ""; input.dispatchEvent(new Event(LIVE_FRAME_RELOAD_EVENT));
|
|
45
|
+
*/
|
|
46
|
+
export const liveFrame = createMixin((handle) => {
|
|
47
|
+
let options = { src: () => handle.frame.src };
|
|
48
|
+
let debounce;
|
|
49
|
+
let slow;
|
|
50
|
+
/** Counts requests, so a reload only settles when no newer one followed it. */
|
|
51
|
+
let latest = 0;
|
|
52
|
+
handle.signal.addEventListener("abort", () => {
|
|
53
|
+
clearTimeout(debounce);
|
|
54
|
+
clearTimeout(slow);
|
|
55
|
+
});
|
|
56
|
+
/** Tells listeners where the reload stands, from the host it concerns. */
|
|
57
|
+
function report(host, state, src) {
|
|
58
|
+
host.dispatchEvent(new LiveFrameEvent({ state, src }));
|
|
59
|
+
}
|
|
60
|
+
/** Marks the value pending and restarts the wait that would call it slow. */
|
|
61
|
+
function begin(host) {
|
|
62
|
+
let request = ++latest;
|
|
63
|
+
clearTimeout(slow);
|
|
64
|
+
report(host, "pending", handle.frame.src);
|
|
65
|
+
slow = setTimeout(() => report(host, "slow", handle.frame.src), options.slowAfter ?? DEFAULT_SLOW_AFTER);
|
|
66
|
+
return request;
|
|
67
|
+
}
|
|
68
|
+
/** Points the frame at the value's address and reloads it, unless it already shows it. */
|
|
69
|
+
async function load(host, request) {
|
|
70
|
+
let src = options.src(host.value);
|
|
71
|
+
if (src !== handle.frame.src) {
|
|
72
|
+
report(host, "loading", src);
|
|
73
|
+
handle.frame.src = src;
|
|
74
|
+
await handle.frame.reload().catch(() => undefined);
|
|
75
|
+
}
|
|
76
|
+
if (request !== latest)
|
|
77
|
+
return;
|
|
78
|
+
clearTimeout(slow);
|
|
79
|
+
report(host, "settled", src);
|
|
80
|
+
}
|
|
81
|
+
handle.addEventListener("insert", (event) => {
|
|
82
|
+
let host = event.node;
|
|
83
|
+
host.addEventListener("input", () => {
|
|
84
|
+
let request = begin(host);
|
|
85
|
+
clearTimeout(debounce);
|
|
86
|
+
debounce = setTimeout(() => void load(host, request), options.debounce ?? DEFAULT_DEBOUNCE);
|
|
87
|
+
}, { signal: handle.signal });
|
|
88
|
+
host.addEventListener(LIVE_FRAME_RELOAD_EVENT, () => {
|
|
89
|
+
clearTimeout(debounce);
|
|
90
|
+
void load(host, begin(host));
|
|
91
|
+
}, { signal: handle.signal });
|
|
92
|
+
});
|
|
93
|
+
return (next) => {
|
|
94
|
+
options = next;
|
|
95
|
+
};
|
|
96
|
+
});
|
package/dist/mixins/persist.js
CHANGED
|
@@ -57,7 +57,7 @@ export const persist = createMixin((handle) => {
|
|
|
57
57
|
let host = event.currentTarget;
|
|
58
58
|
let checkbox = findToggleCheckbox(host);
|
|
59
59
|
if (checkbox === null) {
|
|
60
|
-
if (import.meta.env
|
|
60
|
+
if (import.meta.env?.DEV) {
|
|
61
61
|
console.warn(`persist(): no element with ${SIDEBAR_TOGGLE_ATTRIBUTE} found beneath the Sidebar root to toggle.`);
|
|
62
62
|
}
|
|
63
63
|
return;
|
package/dist/mixins/validate.js
CHANGED
|
@@ -85,7 +85,7 @@ function mirrorValidity(field, message) {
|
|
|
85
85
|
field.setAttribute("aria-invalid", message === "" ? "false" : "true");
|
|
86
86
|
let slot = findFieldErrorSlot(field);
|
|
87
87
|
if (slot === null) {
|
|
88
|
-
if (import.meta.env
|
|
88
|
+
if (import.meta.env?.DEV && message !== "") {
|
|
89
89
|
console.warn("validate(): no FieldError slot found through this field's aria-describedby; " +
|
|
90
90
|
`add ${FIELD_ERROR_ATTRIBUTE} to the element the field describes its error with.`);
|
|
91
91
|
}
|
|
@@ -28,7 +28,7 @@ import { hasAccessibleText } from "./has-accessible-text.js";
|
|
|
28
28
|
* );
|
|
29
29
|
*/
|
|
30
30
|
export function warnIfNoAccessibleName(props, children, message) {
|
|
31
|
-
if (import.meta.env
|
|
31
|
+
if (import.meta.env?.DEV &&
|
|
32
32
|
!props["aria-label"] &&
|
|
33
33
|
!props["aria-labelledby"] &&
|
|
34
34
|
!hasAccessibleText(children)) {
|
|
@@ -49,7 +49,7 @@ export function warnIfNoAccessibleName(props, children, message) {
|
|
|
49
49
|
* );
|
|
50
50
|
*/
|
|
51
51
|
export function warnIfNoAccessibleLabel(props, message) {
|
|
52
|
-
if (import.meta.env
|
|
52
|
+
if (import.meta.env?.DEV && !props["aria-label"] && !props["aria-labelledby"]) {
|
|
53
53
|
console.warn(message);
|
|
54
54
|
}
|
|
55
55
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sdxc/ui",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.20",
|
|
4
4
|
"description": "Styled, accessible remix/component components rendered as server HTML",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@remix-run/ui": "0.12.1",
|
|
21
|
-
"@sdxc/icons": "2026.10.
|
|
22
|
-
"@sdxc/u": "2026.10.
|
|
21
|
+
"@sdxc/icons": "2026.10.20",
|
|
22
|
+
"@sdxc/u": "2026.10.20",
|
|
23
23
|
"@sdxc/uuid": "2026.10.13"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"remix": "3.0.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "bd4473246f405c43055d2fc5e08c62ba35197258",
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|