@sdxc/ui 2026.10.15 → 2026.10.17

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 CHANGED
@@ -121,6 +121,7 @@ A page that sticks to baseline behavior ships no library JavaScript at all.
121
121
  | Import | Contains |
122
122
  | --------------------- | ------------------------------------------------------------------- |
123
123
  | `@sdxc/ui` | Every component and its compound parts. |
124
+ | `@sdxc/ui/<name>` | One component, by its file name: `@sdxc/ui/youtube-embed`. |
124
125
  | `@sdxc/ui/mixins` | Opt-in DOM behaviors applied through `mix`. |
125
126
  | `@sdxc/ui/behaviors` | Headless state classes built on `TypedEventTarget`. |
126
127
  | `@sdxc/ui/animations` | CSS-only motion factories and the `durations`/`easings` tokens. |
@@ -252,6 +253,7 @@ Each mixin module documents why it needs JavaScript and what still works without
252
253
 
253
254
  | Mixin | Host | Adds |
254
255
  | ------------------------------- | -------------------------- | ----------------------------------------------------------------------- |
256
+ | `activeDescendantKeys()` | a combobox input | Arrows over its `aria-controls` options; Enter follows the chosen link. |
255
257
  | `ariaChecked()` | checkbox, switch or radio | `aria-checked` kept in step with the live control. |
256
258
  | `attachmentTrigger()` | `Attachment.Trigger` | The whole card as one activation target. |
257
259
  | `calendarKeys(model)` | `Calendar.Grid` | Arrow/Page/Home/End navigation over a `CalendarModel`. |
@@ -276,6 +278,7 @@ Each mixin module documents why it needs JavaScript and what still works without
276
278
  | `hotkey(combo)` | a `<dialog>`/`[popover]` | A document-wide shortcut toggling its host. |
277
279
  | `imageFallback()` | an `Avatar`/`Logo` image | Shows the fallback when the image fails, cached images included. |
278
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. |
279
282
  | `listboxKeys()` | `ListBox` | Arrow, Home/End and typeahead navigation. |
280
283
  | `longPress(options?)` | any element | Fires after a pointer holds still for `duration`. |
281
284
  | `menuKeys(options?)` | `Menu` | The ARIA menu pattern: roving focus, arrows, typeahead. |
@@ -301,11 +304,13 @@ Helpers for writing your own:
301
304
  - `trackHostNode(handle)` — returns a getter for the mixin's current host node.
302
305
  - `bindKeymap(document, bindings, { signal, scope? })` — `keymap` without a host, with the same
303
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.
304
309
  - `syncAriaChecked(control)` — refreshes `ariaChecked` after a programmatic checked write or reset.
305
310
  - `colorChannelProperty(channel)` and `getCommandItemId(item, index)` — the custom property and the
306
311
  item id `channelSync` and `commandFilter` read.
307
312
 
308
- Mixins that emit DOM events export their `Event` subclass (`DismissEvent`, `ReorderEvent`,
313
+ Mixins that emit DOM events export their `Event` subclass (`DismissEvent`, `LiveFrameEvent`, `ReorderEvent`,
309
314
  `ThemeChangeEvent`, …), and those that read markup export the `data-*` attribute and command names
310
315
  they use (`DRAG_REORDER_ROW_ATTRIBUTE`, `SEARCH_FIELD_CLEAR_COMMAND`, …).
311
316
 
@@ -362,7 +367,7 @@ Recipes for a `mix` array: `floatingSurface()`, `surfaceInset()`, `hitArea()`, `
362
367
  `"?"`); `mod` is Command on Apple keyboards and Control elsewhere.
363
368
  - **Fields** — `resolveFieldWiring(id, options)`, `findPairedRangeInputs`.
364
369
  - **DOM** — `asCommandEvent`, `dispatchChange`, `isNewPrimaryPress`, `isPrintableKey`, `focusItem`,
365
- `queryItems`, `setRovingTabindex`, `labelFor`, `hasAccessibleText`, `mergeStyle`, `prefersReducedMotion`, `writeCookie(name, value, maxAgeSeconds?)`,
370
+ `queryItems`, `setRovingTabindex`, `labelFor`, `hasAccessibleText`, `glyphEdges`, `mergeStyle`, `prefersReducedMotion`, `writeCookie(name, value, maxAgeSeconds?)`,
366
371
  `DISABLED_SELECTOR`, `DEFAULT_ICON_ARIA_HIDDEN`, `ONE_YEAR_SECONDS`.
367
372
  - **Accessibility checks** — `warnIfNoAccessibleName(props, children, message)` and
368
373
  `warnIfNoAccessibleLabel(props, message)`, development-only warnings.
@@ -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
+ });
@@ -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";
@@ -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
+ });
@@ -18,6 +18,7 @@ export * from "./dispatch-change.js";
18
18
  export * from "./field-parts.js";
19
19
  export * from "./full-turn-radians.js";
20
20
  export * from "./geometry.js";
21
+ export * from "./glyph-edges.js";
21
22
  export * from "./has-accessible-text.js";
22
23
  export * from "./hue-spectrum.js";
23
24
  export * from "./is-new-primary-press.js";
@@ -18,6 +18,7 @@ export * from "./dispatch-change.js";
18
18
  export * from "./field-parts.js";
19
19
  export * from "./full-turn-radians.js";
20
20
  export * from "./geometry.js";
21
+ export * from "./glyph-edges.js";
21
22
  export * from "./has-accessible-text.js";
22
23
  export * from "./hue-spectrum.js";
23
24
  export * from "./is-new-primary-press.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sdxc/ui",
3
- "version": "2026.10.15",
3
+ "version": "2026.10.17",
4
4
  "description": "Styled, accessible remix/component components rendered as server HTML",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -13,16 +13,19 @@
13
13
  "./styles": "./dist/styles/index.js",
14
14
  "./utils": "./dist/utils/index.js",
15
15
  "./reset.css": "./src/reset.css",
16
- "./theme.css": "./src/theme.css"
16
+ "./theme.css": "./src/theme.css",
17
+ "./*": "./dist/components/*.js"
17
18
  },
18
19
  "dependencies": {
19
20
  "@remix-run/ui": "0.12.1",
20
- "@sdxc/icons": "2026.10.13",
21
- "@sdxc/u": "2026.10.13",
22
- "@sdxc/uuid": "2026.10.13",
21
+ "@sdxc/icons": "2026.10.16",
22
+ "@sdxc/u": "2026.10.16",
23
+ "@sdxc/uuid": "2026.10.13"
24
+ },
25
+ "peerDependencies": {
23
26
  "remix": "3.0.0"
24
27
  },
25
- "gitHead": "beb40c0508bf7ce7a13a884c14dc6b07299a6926",
28
+ "gitHead": "4f4bce453e9afe69f53194368af9e9739d73a876",
26
29
  "publishConfig": {
27
30
  "access": "public"
28
31
  },
@@ -31,7 +34,7 @@
31
34
  "url": "git+https://github.com/sergiodxa/monorepo.git",
32
35
  "directory": "packages/ui"
33
36
  },
34
- "homepage": "https://sdxc.sergiodxa.com/api/ui",
37
+ "homepage": "https://sdxc.dev/api/ui",
35
38
  "author": {
36
39
  "name": "Sergio Xalambrí",
37
40
  "url": "https://sergiodxa.com"