@sdxc/ui 2026.10.8 → 2026.10.10
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 +71 -2
- package/dist/behaviors/announcer.d.ts +19 -1
- package/dist/behaviors/announcer.js +32 -4
- package/dist/behaviors/toaster.d.ts +1 -1
- package/dist/behaviors/toaster.js +1 -1
- package/dist/components/color-swatch.js +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/marker.js +1 -1
- package/dist/components/shortcut-list.d.ts +49 -0
- package/dist/components/shortcut-list.js +39 -0
- package/dist/components/skeleton.d.ts +1 -1
- package/dist/components/skeleton.js +2 -2
- package/dist/mixins/calendar-keys.js +5 -7
- package/dist/mixins/command-filter.js +9 -7
- package/dist/mixins/command-keys.js +6 -19
- package/dist/mixins/drag-reorder.js +6 -6
- package/dist/mixins/drop-zone.js +6 -8
- package/dist/mixins/grid-list-keys.js +8 -8
- package/dist/mixins/hotkey.d.ts +2 -1
- package/dist/mixins/hotkey.js +8 -54
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/keymap.d.ts +61 -0
- package/dist/mixins/keymap.js +88 -0
- package/dist/mixins/message-follow.js +13 -11
- package/dist/mixins/range-preview.js +5 -7
- package/dist/mixins/resize-handle.js +9 -9
- package/dist/mixins/track-host-node.d.ts +8 -6
- package/dist/mixins/track-host-node.js +8 -6
- package/dist/mixins/treeKeys.js +11 -9
- package/dist/mixins/view-transition.js +14 -13
- package/dist/mixins/while-live.d.ts +24 -0
- package/dist/mixins/while-live.js +56 -0
- package/dist/utils/color-math.js +1 -1
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/key-combo.d.ts +69 -0
- package/dist/utils/key-combo.js +142 -0
- package/package.json +2 -2
- package/src/reset.css +18 -8
package/README.md
CHANGED
|
@@ -303,6 +303,8 @@ positioning, or a custom `--ui-*` command answered by a mixin.
|
|
|
303
303
|
- `Text`, `Header`, `Keyboard`, `Typeset` — muted body copy, an uppercase section label in a
|
|
304
304
|
`<header>`, a shortcut hint in a `<kbd>`, and a typography layer for already-rendered
|
|
305
305
|
markup with `docs`, `chat` and `reading` presets.
|
|
306
|
+
- `ShortcutList` — a two-column `<dl>` pairing each action with the key caps that run it,
|
|
307
|
+
for a keyboard-shortcuts panel.
|
|
306
308
|
- `Highlight` — text split into `{ text, match }` segments, each match a tinted `<mark>`
|
|
307
309
|
that keeps the surrounding color and weight, for search results and filtered lists.
|
|
308
310
|
- `HeadingScope`, `Heading` — an ambient heading-depth scope and the heading that reads it.
|
|
@@ -341,6 +343,7 @@ script never runs, so the cost of every behavior stays visible before you apply
|
|
|
341
343
|
| `gridListKeys(model)` | `GridList` | The ARIA grid keyboard pattern against a `SelectionModel`. |
|
|
342
344
|
| `headingLevelFallback(options)` | an island's heading root | Recovers the ambient heading depth from `data-heading-level` at a hydration boundary. |
|
|
343
345
|
| `hotkey(combo)` | any `<dialog>`/`[popover]` | A document-level shortcut opening or closing its host regardless of focus. |
|
|
346
|
+
| `keymap(bindings)` | any host | Page-wide shortcuts that stand down in fields, IME composition, and dialogs outside the host. |
|
|
344
347
|
| `imageFallback()` | `Avatar` / `Logo` images | Flags a failed image load, including retroactively for cached images. |
|
|
345
348
|
| `listboxKeys()` | `ListBox` | Arrow/Home/End/typeahead through `@remix-run/ui/listbox`. |
|
|
346
349
|
| `longPress(options?)` | any element | Fires once a pointer holds still past a duration and movement tolerance. |
|
|
@@ -359,13 +362,15 @@ script never runs, so the cost of every behavior stays visible before you apply
|
|
|
359
362
|
| `validate(schema)` | a native form control | Applies a `remix/data-schema` schema through `setCustomValidity()`, mirrored into a `FieldError`. |
|
|
360
363
|
| `viewTransition()` | a `SharedElement` island | Bridges a same-document reload to the View Transition API. |
|
|
361
364
|
| `trackHostNode(handle)` | inside a mixin | Caches a mixin's live host node across insert and remove, for the mixins above that read the DOM outside render. |
|
|
365
|
+
| `whileLive(handle, subscribe)` | inside a mixin | Subscribes a mixin or island to a model, session or frame only while it is live in a document. |
|
|
362
366
|
|
|
363
367
|
### Behavior Classes
|
|
364
368
|
|
|
365
369
|
Headless, DOM-free state models. Each is unit-testable on its own, and an island subscribes
|
|
366
370
|
to it and re-renders.
|
|
367
371
|
|
|
368
|
-
- `Announcer` — a priority-ordered queue of `aria-live` announcements
|
|
372
|
+
- `Announcer` — a priority-ordered queue of `aria-live` announcements, optionally advancing
|
|
373
|
+
on its own once each message has been current for a `hold`.
|
|
369
374
|
- `CalendarModel` — the keyboard-focused day, the visible month, and an in-progress range.
|
|
370
375
|
- `DragSession` — the dragged item, the drop candidate under the pointer, and the computed
|
|
371
376
|
drop position.
|
|
@@ -436,6 +441,11 @@ Plain TypeScript with no rendering dependency, importable on its own.
|
|
|
436
441
|
- **DOM** — `asCommandEvent`, `dispatchChange`, `isNewPrimaryPress`, `isPrintableKey`,
|
|
437
442
|
`focusItem`, `queryItems`, `setRovingTabindex`, `labelFor`, `hasAccessibleText`,
|
|
438
443
|
`mergeStyle`, `prefersReducedMotion`, `writeCookie`, `DISABLED_SELECTOR`.
|
|
444
|
+
- **Keys** — `parseKeyCombo`, `matchesKeyCombo`, `keyComboGlyphs`, `isTypingTarget`,
|
|
445
|
+
`TYPING_TARGET_SELECTOR`, and the `KeyCombo` interface. A combo is written once
|
|
446
|
+
(`"mod+k"`, `"escape"`, `"?"`) and both matched and printed from that spelling: `mod` is
|
|
447
|
+
Command on Apple keyboards and Control elsewhere, and a bare character names the character
|
|
448
|
+
typed, so `"J"` and `"?"` match whatever Shift produced them.
|
|
439
449
|
- **Types** — `SemanticColor` (the five-tone union every `color` prop resolves to),
|
|
440
450
|
`AnchorPlacement`, `AriaInvalid`, `CSSStyles`, `StyleProp`, `FieldColor`.
|
|
441
451
|
|
|
@@ -452,13 +462,16 @@ import { clientEntry } from "remix/component";
|
|
|
452
462
|
|
|
453
463
|
import { Toast } from "@sdxc/ui";
|
|
454
464
|
import { Toaster } from "@sdxc/ui/behaviors";
|
|
465
|
+
import { whileLive } from "@sdxc/ui/mixins";
|
|
455
466
|
|
|
456
467
|
export const AppToaster = clientEntry(
|
|
457
468
|
"/app/components/app-toaster.tsx#AppToaster",
|
|
458
469
|
function AppToaster(handle: Handle) {
|
|
459
470
|
let toaster = new Toaster<{ title: string; color?: Toast.Color }>();
|
|
460
471
|
|
|
461
|
-
|
|
472
|
+
whileLive(handle, (model: Toaster, signal) =>
|
|
473
|
+
model.addEventListener("change", () => handle.update(), { signal }),
|
|
474
|
+
)(toaster);
|
|
462
475
|
handle.context.set({ toaster });
|
|
463
476
|
|
|
464
477
|
return () => (
|
|
@@ -479,6 +492,62 @@ export const AppToaster = clientEntry(
|
|
|
479
492
|
Any descendant reaches the queue through context:
|
|
480
493
|
`handle.context.get(AppToaster).toaster.add({ title: t("toasts.saved") })`.
|
|
481
494
|
|
|
495
|
+
## Pattern: A Keyboard Shortcuts Panel
|
|
496
|
+
|
|
497
|
+
The bindings, the panel that lists them, and the live region that says what a key did are
|
|
498
|
+
three independent pieces. `keymap()` binds the keys on the island's host, so a panel rendered
|
|
499
|
+
inside that host keeps answering them while any other dialog keeps its own keys; the panel
|
|
500
|
+
is a native `<dialog>` the `?` key opens through the same button a pointer presses; and an
|
|
501
|
+
`Announcer` with a `hold` paces what the live region reads.
|
|
502
|
+
|
|
503
|
+
```tsx
|
|
504
|
+
import type { Handle } from "remix/component";
|
|
505
|
+
|
|
506
|
+
import { visuallyHidden } from "@sdxc/u/a11y";
|
|
507
|
+
import { Button, Modal, ShortcutList } from "@sdxc/ui";
|
|
508
|
+
import { Announcer } from "@sdxc/ui/behaviors";
|
|
509
|
+
import { keymap, whileLive } from "@sdxc/ui/mixins";
|
|
510
|
+
import { keyComboGlyphs } from "@sdxc/ui/utils";
|
|
511
|
+
import { clientEntry } from "remix/component";
|
|
512
|
+
|
|
513
|
+
type Props = { apple: boolean };
|
|
514
|
+
|
|
515
|
+
export default clientEntry(
|
|
516
|
+
"/app/components/shortcuts.tsx#default",
|
|
517
|
+
function Shortcuts(handle: Handle<Props>) {
|
|
518
|
+
let announcer = new Announcer({ hold: 1200 });
|
|
519
|
+
whileLive(handle, (model: Announcer, signal) =>
|
|
520
|
+
model.addEventListener("change", () => handle.update(), { signal }),
|
|
521
|
+
)(announcer);
|
|
522
|
+
|
|
523
|
+
let openHelp = () =>
|
|
524
|
+
document.querySelector<HTMLButtonElement>('[commandfor="shortcuts"]')?.click();
|
|
525
|
+
|
|
526
|
+
return () => (
|
|
527
|
+
<div mix={[keymap({ "mod+s": save, j: next, "?": openHelp })]}>
|
|
528
|
+
<Button type="button" commandfor="shortcuts" command="show-modal">
|
|
529
|
+
{t("shortcuts.open")}
|
|
530
|
+
</Button>
|
|
531
|
+
<Modal id="shortcuts" aria-label={t("shortcuts.open")}>
|
|
532
|
+
<ShortcutList>
|
|
533
|
+
<ShortcutList.Item keys={keyComboGlyphs("mod+s", handle.props.apple)}>
|
|
534
|
+
{t("shortcuts.save")}
|
|
535
|
+
</ShortcutList.Item>
|
|
536
|
+
<ShortcutList.Item keys={["j"]}>{t("shortcuts.next")}</ShortcutList.Item>
|
|
537
|
+
</ShortcutList>
|
|
538
|
+
</Modal>
|
|
539
|
+
<div role="status" aria-live="polite" mix={[visuallyHidden()]}>
|
|
540
|
+
{announcer.current?.text ?? ""}
|
|
541
|
+
</div>
|
|
542
|
+
</div>
|
|
543
|
+
);
|
|
544
|
+
},
|
|
545
|
+
);
|
|
546
|
+
```
|
|
547
|
+
|
|
548
|
+
Where the bindings are installed from a `ref` callback instead of a mixin, `bindKeymap(document,
|
|
549
|
+
bindings, { signal, scope })` takes the same map and the same stand-down rules.
|
|
550
|
+
|
|
482
551
|
## Pattern: The Custom Command Trigger Contract
|
|
483
552
|
|
|
484
553
|
[Invoker Commands](https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API)
|
|
@@ -28,6 +28,17 @@ export declare namespace Announcer {
|
|
|
28
28
|
readonly text: string;
|
|
29
29
|
readonly priority: Priority;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Options for constructing an {@link Announcer}.
|
|
33
|
+
*/
|
|
34
|
+
interface Options {
|
|
35
|
+
/**
|
|
36
|
+
* Milliseconds each message stays current before the queue advances on its own: long
|
|
37
|
+
* enough for a screen reader to reach it, short enough that a run of quick changes is
|
|
38
|
+
* heard one by one. Omitted, the live region advances the queue with `next()`.
|
|
39
|
+
*/
|
|
40
|
+
hold?: number;
|
|
41
|
+
}
|
|
31
42
|
/**
|
|
32
43
|
* Events dispatched by {@link Announcer}.
|
|
33
44
|
*/
|
|
@@ -45,10 +56,17 @@ export declare namespace Announcer {
|
|
|
45
56
|
* `aria-live` element, and calls {@link Announcer.next} once it has been read.
|
|
46
57
|
*
|
|
47
58
|
* @example
|
|
48
|
-
*
|
|
59
|
+
* whileLive(handle, (model: Announcer, signal) => model.addEventListener("change", () => handle.update(), { signal }))(announcer);
|
|
49
60
|
*/
|
|
50
61
|
export declare class Announcer extends TypedEventTarget<Announcer.Events> {
|
|
51
62
|
#private;
|
|
63
|
+
/**
|
|
64
|
+
* Without `hold`, the queue moves only when a caller advances or dismisses it.
|
|
65
|
+
*
|
|
66
|
+
* @param options How long each message holds before the queue advances on its own.
|
|
67
|
+
* @example new Announcer({ hold: 1200 })
|
|
68
|
+
*/
|
|
69
|
+
constructor(options?: Announcer.Options);
|
|
52
70
|
/**
|
|
53
71
|
* The message a live region should currently render, or `undefined` when
|
|
54
72
|
* the queue is empty.
|
|
@@ -15,10 +15,22 @@ const DEFAULT_PRIORITY = "polite";
|
|
|
15
15
|
* `aria-live` element, and calls {@link Announcer.next} once it has been read.
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
|
-
*
|
|
18
|
+
* whileLive(handle, (model: Announcer, signal) => model.addEventListener("change", () => handle.update(), { signal }))(announcer);
|
|
19
19
|
*/
|
|
20
20
|
export class Announcer extends TypedEventTarget {
|
|
21
21
|
#queue = [];
|
|
22
|
+
#hold;
|
|
23
|
+
#held;
|
|
24
|
+
/**
|
|
25
|
+
* Without `hold`, the queue moves only when a caller advances or dismisses it.
|
|
26
|
+
*
|
|
27
|
+
* @param options How long each message holds before the queue advances on its own.
|
|
28
|
+
* @example new Announcer({ hold: 1200 })
|
|
29
|
+
*/
|
|
30
|
+
constructor(options = {}) {
|
|
31
|
+
super();
|
|
32
|
+
this.#hold = options.hold;
|
|
33
|
+
}
|
|
22
34
|
/**
|
|
23
35
|
* The message a live region should currently render, or `undefined` when
|
|
24
36
|
* the queue is empty.
|
|
@@ -54,7 +66,7 @@ export class Announcer extends TypedEventTarget {
|
|
|
54
66
|
}
|
|
55
67
|
else
|
|
56
68
|
this.#queue.push(message);
|
|
57
|
-
this
|
|
69
|
+
this.#changed();
|
|
58
70
|
return message.id;
|
|
59
71
|
}
|
|
60
72
|
/**
|
|
@@ -68,7 +80,7 @@ export class Announcer extends TypedEventTarget {
|
|
|
68
80
|
if (index === -1)
|
|
69
81
|
return;
|
|
70
82
|
this.#queue.splice(index, 1);
|
|
71
|
-
this
|
|
83
|
+
this.#changed();
|
|
72
84
|
}
|
|
73
85
|
/**
|
|
74
86
|
* Advances past the current message so the next queued one becomes
|
|
@@ -79,7 +91,7 @@ export class Announcer extends TypedEventTarget {
|
|
|
79
91
|
if (this.#queue.length === 0)
|
|
80
92
|
return;
|
|
81
93
|
this.#queue.shift();
|
|
82
|
-
this
|
|
94
|
+
this.#changed();
|
|
83
95
|
}
|
|
84
96
|
/**
|
|
85
97
|
* Empties the queue, dispatching `"change"` only when it held messages.
|
|
@@ -88,6 +100,22 @@ export class Announcer extends TypedEventTarget {
|
|
|
88
100
|
if (this.#queue.length === 0)
|
|
89
101
|
return;
|
|
90
102
|
this.#queue = [];
|
|
103
|
+
this.#changed();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Restarts the hold whenever a different message becomes current, so each message is
|
|
107
|
+
* held for the full duration once it reaches the front, then dispatches `"change"`.
|
|
108
|
+
*/
|
|
109
|
+
#changed() {
|
|
110
|
+
let current = this.current;
|
|
111
|
+
if (this.#hold !== undefined && this.#held?.id !== current?.id) {
|
|
112
|
+
if (this.#held)
|
|
113
|
+
clearTimeout(this.#held.timer);
|
|
114
|
+
this.#held =
|
|
115
|
+
current === undefined
|
|
116
|
+
? undefined
|
|
117
|
+
: { id: current.id, timer: setTimeout(() => this.next(), this.#hold) };
|
|
118
|
+
}
|
|
91
119
|
this.dispatchEvent(new Event("change"));
|
|
92
120
|
}
|
|
93
121
|
}
|
|
@@ -68,7 +68,7 @@ export declare namespace Toaster {
|
|
|
68
68
|
* {@link Toaster.resume} so a toast under the cursor stays readable.
|
|
69
69
|
*
|
|
70
70
|
* @example
|
|
71
|
-
*
|
|
71
|
+
* whileLive(handle, (model: Toaster, signal) => model.addEventListener("change", () => handle.update(), { signal }))(toaster);
|
|
72
72
|
*/
|
|
73
73
|
export declare class Toaster<Data = unknown> extends TypedEventTarget<Toaster.Events> {
|
|
74
74
|
#private;
|
|
@@ -26,7 +26,7 @@ function toPublicToast(entry) {
|
|
|
26
26
|
* {@link Toaster.resume} so a toast under the cursor stays readable.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
29
|
-
*
|
|
29
|
+
* whileLive(handle, (model: Toaster, signal) => model.addEventListener("change", () => handle.update(), { signal }))(toaster);
|
|
30
30
|
*/
|
|
31
31
|
export class Toaster extends TypedEventTarget {
|
|
32
32
|
#toasts = new Map();
|
|
@@ -16,7 +16,7 @@ const DEFAULT_SIZE = "md";
|
|
|
16
16
|
/**
|
|
17
17
|
* Applied through {@link attrs} so the host is hidden from assistive
|
|
18
18
|
* technology by default, since composed uses supply their own accessible
|
|
19
|
-
* name; pass `aria-hidden=
|
|
19
|
+
* name; pass `aria-hidden="false"` and `aria-label` to render standalone.
|
|
20
20
|
*/
|
|
21
21
|
const DEFAULT_ARIA_HIDDEN = "true";
|
|
22
22
|
/**
|
|
@@ -90,6 +90,7 @@ export * from "./sentinel-row.js";
|
|
|
90
90
|
export * from "./separator.js";
|
|
91
91
|
export * from "./shared-element.js";
|
|
92
92
|
export * from "./sheet.js";
|
|
93
|
+
export * from "./shortcut-list.js";
|
|
93
94
|
export * from "./sidebar.js";
|
|
94
95
|
export * from "./skeleton.js";
|
|
95
96
|
export * from "./slider.js";
|
package/dist/components/index.js
CHANGED
|
@@ -90,6 +90,7 @@ export * from "./sentinel-row.js";
|
|
|
90
90
|
export * from "./separator.js";
|
|
91
91
|
export * from "./shared-element.js";
|
|
92
92
|
export * from "./sheet.js";
|
|
93
|
+
export * from "./shortcut-list.js";
|
|
93
94
|
export * from "./sidebar.js";
|
|
94
95
|
export * from "./skeleton.js";
|
|
95
96
|
export * from "./slider.js";
|
|
@@ -125,7 +125,7 @@ export function Marker(handle) {
|
|
|
125
125
|
* @example
|
|
126
126
|
* <Marker.Icon><CheckIcon /></Marker.Icon>
|
|
127
127
|
* @example
|
|
128
|
-
* <Marker.Icon aria-hidden=
|
|
128
|
+
* <Marker.Icon aria-hidden="false">
|
|
129
129
|
* <Spinner size="sm" aria-label={t("status.generating")} />
|
|
130
130
|
* </Marker.Icon>
|
|
131
131
|
*/
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The list a keyboard-shortcuts panel shows: a native `<dl>` pairing each action with the
|
|
3
|
+
* key caps that run it, laid out in two columns so every key lands on one vertical line
|
|
4
|
+
* and the list reads down that line instead of across ragged hints.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { Handle, Props as TagProps, RemixNode } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Prop types for {@link ShortcutList} and its compound parts.
|
|
12
|
+
*/
|
|
13
|
+
export declare namespace ShortcutList {
|
|
14
|
+
/**
|
|
15
|
+
* Props accepted by {@link ShortcutList}.
|
|
16
|
+
*/
|
|
17
|
+
interface Props extends TagProps<"dl"> {
|
|
18
|
+
/** One {@link ShortcutList.Item} per binding, in the order the panel lists them. */
|
|
19
|
+
children: RemixNode;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Props accepted by {@link ShortcutList.Item}.
|
|
23
|
+
*/
|
|
24
|
+
interface ItemProps extends TagProps<"div"> {
|
|
25
|
+
/**
|
|
26
|
+
* The caps to press, in press order, each already the glyph to print — a combo
|
|
27
|
+
* formatted for the reader's keyboard by `keyComboGlyphs()`, or a bare character.
|
|
28
|
+
*/
|
|
29
|
+
keys: string[];
|
|
30
|
+
/** What pressing the keys does. */
|
|
31
|
+
children: RemixNode;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Renders the list's host `<dl>`, a two-column grid whose first column takes the actions
|
|
36
|
+
* and whose second sizes itself to the widest run of caps.
|
|
37
|
+
*
|
|
38
|
+
* @param handle Runtime handle carrying the host `<dl>`'s props.
|
|
39
|
+
* @returns The render function producing the list's markup.
|
|
40
|
+
* @example
|
|
41
|
+
* <ShortcutList>
|
|
42
|
+
* <ShortcutList.Item keys={keyComboGlyphs("mod+k", apple)}>{t("openSearch")}</ShortcutList.Item>
|
|
43
|
+
* <ShortcutList.Item keys={["?"]}>{t("showShortcuts")}</ShortcutList.Item>
|
|
44
|
+
* </ShortcutList>
|
|
45
|
+
*/
|
|
46
|
+
export declare function ShortcutList(handle: Handle<ShortcutList.Props>): () => import("remix/component").RemixElement;
|
|
47
|
+
export declare namespace ShortcutList {
|
|
48
|
+
var Item: (handle: Handle<ShortcutList.ItemProps>) => () => import("remix/component").RemixElement;
|
|
49
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "remix/component/jsx-runtime";
|
|
2
|
+
import { fg } from "@sdxc/u/color";
|
|
3
|
+
import { contents, flex, gap, grid, gridTemplate, items, justify } from "@sdxc/u/layout";
|
|
4
|
+
import { m } from "@sdxc/u/size";
|
|
5
|
+
import { text, weight } from "@sdxc/u/typography";
|
|
6
|
+
import { Keyboard } from "./keyboard.js";
|
|
7
|
+
/**
|
|
8
|
+
* Renders the list's host `<dl>`, a two-column grid whose first column takes the actions
|
|
9
|
+
* and whose second sizes itself to the widest run of caps.
|
|
10
|
+
*
|
|
11
|
+
* @param handle Runtime handle carrying the host `<dl>`'s props.
|
|
12
|
+
* @returns The render function producing the list's markup.
|
|
13
|
+
* @example
|
|
14
|
+
* <ShortcutList>
|
|
15
|
+
* <ShortcutList.Item keys={keyComboGlyphs("mod+k", apple)}>{t("openSearch")}</ShortcutList.Item>
|
|
16
|
+
* <ShortcutList.Item keys={["?"]}>{t("showShortcuts")}</ShortcutList.Item>
|
|
17
|
+
* </ShortcutList>
|
|
18
|
+
*/
|
|
19
|
+
export function ShortcutList(handle) {
|
|
20
|
+
return () => {
|
|
21
|
+
let { children, mix, ...rest } = handle.props;
|
|
22
|
+
return (_jsx("dl", { ...rest, "data-slot": "shortcut-list", mix: [m(0), grid(), gap(2, 4), items("center"), gridTemplate({ columns: "1fr auto" }), mix], children: children }));
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Renders one binding as a `<dt>` naming the action and a `<dd>` holding a cap per key.
|
|
27
|
+
* The wrapping `<div>` lays out as its children, so both cells join the list's own grid.
|
|
28
|
+
*
|
|
29
|
+
* @param handle Runtime handle carrying the wrapping `<div>`'s props.
|
|
30
|
+
* @returns The render function producing the binding's markup.
|
|
31
|
+
* @example
|
|
32
|
+
* <ShortcutList.Item keys={["⌘", "K"]}>{t("openSearch")}</ShortcutList.Item>
|
|
33
|
+
*/
|
|
34
|
+
ShortcutList.Item = function ShortcutListItem(handle) {
|
|
35
|
+
return () => {
|
|
36
|
+
let { children, keys, mix, ...rest } = handle.props;
|
|
37
|
+
return (_jsxs("div", { ...rest, "data-slot": "shortcut", mix: [contents(), mix], children: [_jsx("dt", { mix: [text("sm"), fg("neutral")], children: children }), _jsx("dd", { mix: [m(0), flex(), gap(1), items("center"), justify("end")], children: keys.map((key, index) => (_jsx(Keyboard, { mix: [m(0), weight("medium")], children: key }, `${index}-${key}`))) })] }));
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -31,6 +31,6 @@ export declare namespace Skeleton {
|
|
|
31
31
|
* @example
|
|
32
32
|
* <Skeleton style={{ blockSize: "2.5rem", inlineSize: "2.5rem", borderRadius: "9999px" }} />
|
|
33
33
|
* @example
|
|
34
|
-
* <Skeleton aria-hidden=
|
|
34
|
+
* <Skeleton aria-hidden="false" aria-label={t("status.loadingProfile")} />
|
|
35
35
|
*/
|
|
36
36
|
export declare function Skeleton(handle: Handle<Skeleton.Props>): () => import("remix/component").RemixElement;
|
|
@@ -6,7 +6,7 @@ import { attrs } from "remix/component";
|
|
|
6
6
|
/**
|
|
7
7
|
* Default `aria-hidden` value applied through {@link attrs}, keeping a
|
|
8
8
|
* placeholder out of the accessibility tree unless a consumer sets
|
|
9
|
-
* `aria-hidden=
|
|
9
|
+
* `aria-hidden="false"` to expose a loading label to assistive tech.
|
|
10
10
|
*/
|
|
11
11
|
const DEFAULT_ARIA_HIDDEN = "true";
|
|
12
12
|
/**
|
|
@@ -21,7 +21,7 @@ const DEFAULT_ARIA_HIDDEN = "true";
|
|
|
21
21
|
* @example
|
|
22
22
|
* <Skeleton style={{ blockSize: "2.5rem", inlineSize: "2.5rem", borderRadius: "9999px" }} />
|
|
23
23
|
* @example
|
|
24
|
-
* <Skeleton aria-hidden=
|
|
24
|
+
* <Skeleton aria-hidden="false" aria-label={t("status.loadingProfile")} />
|
|
25
25
|
*/
|
|
26
26
|
export function Skeleton(handle) {
|
|
27
27
|
return () => {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { createElement, createMixin, on } from "remix/component";
|
|
10
10
|
import { DISABLED_SELECTOR } from "../utils/disabled-selector.js";
|
|
11
|
+
import { whileLive } from "./while-live.js";
|
|
11
12
|
/**
|
|
12
13
|
* Attribute every calendar day cell exposes its date on, in local
|
|
13
14
|
* `YYYY-MM-DD` form, that `calendarKeys()` matches against a
|
|
@@ -58,7 +59,9 @@ function fromDateKey(key) {
|
|
|
58
59
|
*/
|
|
59
60
|
export const calendarKeys = createMixin((handle) => {
|
|
60
61
|
let hostNode;
|
|
61
|
-
let
|
|
62
|
+
let follow = whileLive(handle, (model, signal) => {
|
|
63
|
+
model.addEventListener("change", () => syncFocusedCell(model), { signal });
|
|
64
|
+
});
|
|
62
65
|
handle.addEventListener("insert", (event) => {
|
|
63
66
|
hostNode = event.node;
|
|
64
67
|
});
|
|
@@ -81,12 +84,7 @@ export const calendarKeys = createMixin((handle) => {
|
|
|
81
84
|
}
|
|
82
85
|
}
|
|
83
86
|
return (model) => {
|
|
84
|
-
|
|
85
|
-
boundModel = model;
|
|
86
|
-
model.addEventListener("change", () => syncFocusedCell(model), {
|
|
87
|
-
signal: handle.signal,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
87
|
+
follow(model);
|
|
90
88
|
return createElement(handle.element, {
|
|
91
89
|
mix: [
|
|
92
90
|
on("click", (event) => {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* @copyright Sergio Xalambrí 2026
|
|
10
10
|
*/
|
|
11
11
|
import { createElement, createMixin, on } from "remix/component";
|
|
12
|
+
import { whileLive } from "./while-live.js";
|
|
12
13
|
/**
|
|
13
14
|
* Attribute the search input exposes itself on — `Command.Input`'s own
|
|
14
15
|
* `<input>` carries this automatically, and `commandFilter()` forwards its
|
|
@@ -91,6 +92,12 @@ function syncMatches(root, model) {
|
|
|
91
92
|
export const commandFilter = createMixin((handle) => {
|
|
92
93
|
let hostNode;
|
|
93
94
|
let boundModel;
|
|
95
|
+
let follow = whileLive(handle, (model, signal) => {
|
|
96
|
+
model.addEventListener("change", () => {
|
|
97
|
+
if (hostNode !== undefined)
|
|
98
|
+
syncMatches(hostNode, model);
|
|
99
|
+
}, { signal });
|
|
100
|
+
});
|
|
94
101
|
handle.addEventListener("insert", (event) => {
|
|
95
102
|
hostNode = event.node;
|
|
96
103
|
boundModel?.setOptions(collectOptions(hostNode));
|
|
@@ -99,13 +106,8 @@ export const commandFilter = createMixin((handle) => {
|
|
|
99
106
|
hostNode = undefined;
|
|
100
107
|
});
|
|
101
108
|
return (model) => {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
model.addEventListener("change", () => {
|
|
105
|
-
if (hostNode !== undefined)
|
|
106
|
-
syncMatches(hostNode, model);
|
|
107
|
-
}, { signal: handle.signal });
|
|
108
|
-
}
|
|
109
|
+
boundModel = model;
|
|
110
|
+
follow(model);
|
|
109
111
|
return createElement(handle.element, {
|
|
110
112
|
mix: [
|
|
111
113
|
on("input", (event) => {
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { createElement, createMixin, on } from "remix/component";
|
|
12
12
|
import { COMMAND_INPUT_ATTRIBUTE, COMMAND_ITEM_ATTRIBUTE, getCommandItemId, } from "./command-filter.js";
|
|
13
|
+
import { whileLive } from "./while-live.js";
|
|
13
14
|
/** `KeyboardEvent.key` value that moves the active match to the previous visible option. */
|
|
14
15
|
const ARROW_UP_KEY = "ArrowUp";
|
|
15
16
|
/** `KeyboardEvent.key` value that moves the active match to the next visible option. */
|
|
@@ -78,27 +79,14 @@ function activateCurrent(root, model) {
|
|
|
78
79
|
export const commandKeys = createMixin((handle) => {
|
|
79
80
|
let hostNode;
|
|
80
81
|
let boundModel;
|
|
81
|
-
|
|
82
|
-
let pendingModel;
|
|
83
|
-
/**
|
|
84
|
-
* The subscription belongs to the inserted host: it exists to write the active item
|
|
85
|
-
* onto a live node, and `handle.signal` is the lifetime of that node. Binding it while
|
|
86
|
-
* the host is only being rendered — on a server, say — subscribes on behalf of nothing
|
|
87
|
-
* and hands `addEventListener` a signal that does not exist yet.
|
|
88
|
-
*/
|
|
89
|
-
function follow(model) {
|
|
90
|
-
if (boundModel === model)
|
|
91
|
-
return;
|
|
92
|
-
boundModel = model;
|
|
82
|
+
let follow = whileLive(handle, (model, signal) => {
|
|
93
83
|
model.addEventListener("change", () => {
|
|
94
84
|
if (hostNode !== undefined)
|
|
95
85
|
syncActive(hostNode, model);
|
|
96
|
-
}, { signal
|
|
97
|
-
}
|
|
86
|
+
}, { signal });
|
|
87
|
+
});
|
|
98
88
|
handle.addEventListener("insert", (event) => {
|
|
99
89
|
hostNode = event.node;
|
|
100
|
-
if (pendingModel !== undefined)
|
|
101
|
-
follow(pendingModel);
|
|
102
90
|
if (boundModel !== undefined)
|
|
103
91
|
syncActive(hostNode, boundModel);
|
|
104
92
|
});
|
|
@@ -106,9 +94,8 @@ export const commandKeys = createMixin((handle) => {
|
|
|
106
94
|
hostNode = undefined;
|
|
107
95
|
});
|
|
108
96
|
return (model) => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
follow(model);
|
|
97
|
+
boundModel = model;
|
|
98
|
+
follow(model);
|
|
112
99
|
return createElement(handle.element, {
|
|
113
100
|
mix: [
|
|
114
101
|
on("keydown", (event) => {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @copyright Sergio Xalambrí 2026
|
|
9
9
|
*/
|
|
10
10
|
import { createElement, createMixin, on } from "remix/component";
|
|
11
|
+
import { whileLive } from "./while-live.js";
|
|
11
12
|
/**
|
|
12
13
|
* Attribute every reorderable row carries its stable identity on, read by
|
|
13
14
|
* {@link dragReorder} to resolve the row under the pointer and shared by
|
|
@@ -118,8 +119,11 @@ function resolveDropPosition(row, clientY) {
|
|
|
118
119
|
*/
|
|
119
120
|
export const dragReorder = createMixin((handle) => {
|
|
120
121
|
let hostNode;
|
|
121
|
-
let boundSession;
|
|
122
122
|
let activePointerId;
|
|
123
|
+
let follow = whileLive(handle, (session, signal) => {
|
|
124
|
+
session.addEventListener("change", () => syncRows(session), { signal });
|
|
125
|
+
signal.addEventListener("abort", () => session.cancel());
|
|
126
|
+
});
|
|
123
127
|
handle.addEventListener("insert", (event) => {
|
|
124
128
|
hostNode = event.node;
|
|
125
129
|
});
|
|
@@ -148,11 +152,7 @@ export const dragReorder = createMixin((handle) => {
|
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
154
|
return (session) => {
|
|
151
|
-
|
|
152
|
-
boundSession = session;
|
|
153
|
-
session.addEventListener("change", () => syncRows(session), { signal: handle.signal });
|
|
154
|
-
handle.signal.addEventListener("abort", () => session.cancel());
|
|
155
|
-
}
|
|
155
|
+
follow(session);
|
|
156
156
|
return createElement(handle.element, {
|
|
157
157
|
mix: [
|
|
158
158
|
on("pointerdown", (event) => {
|
package/dist/mixins/drop-zone.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* @copyright Sergio Xalambrí 2026
|
|
9
9
|
*/
|
|
10
10
|
import { createElement, createMixin, on } from "remix/component";
|
|
11
|
+
import { whileLive } from "./while-live.js";
|
|
11
12
|
/**
|
|
12
13
|
* `data-*` attribute {@link dropZone} toggles on its host while a file
|
|
13
14
|
* drag from outside the page hovers over it, so a DropZone's styling can
|
|
@@ -65,7 +66,10 @@ function isFileDrag(dataTransfer) {
|
|
|
65
66
|
*/
|
|
66
67
|
export const dropZone = createMixin((handle) => {
|
|
67
68
|
let hostNode;
|
|
68
|
-
let
|
|
69
|
+
let follow = whileLive(handle, (session, signal) => {
|
|
70
|
+
session.addEventListener("change", () => syncDropTarget(session), { signal });
|
|
71
|
+
signal.addEventListener("abort", () => session.cancel());
|
|
72
|
+
});
|
|
69
73
|
handle.addEventListener("insert", (event) => {
|
|
70
74
|
hostNode = event.node;
|
|
71
75
|
});
|
|
@@ -82,13 +86,7 @@ export const dropZone = createMixin((handle) => {
|
|
|
82
86
|
hostNode.removeAttribute(DROP_TARGET_ATTRIBUTE);
|
|
83
87
|
}
|
|
84
88
|
return (session) => {
|
|
85
|
-
|
|
86
|
-
boundSession = session;
|
|
87
|
-
session.addEventListener("change", () => syncDropTarget(session), {
|
|
88
|
-
signal: handle.signal,
|
|
89
|
-
});
|
|
90
|
-
handle.signal.addEventListener("abort", () => session.cancel());
|
|
91
|
-
}
|
|
89
|
+
follow(session);
|
|
92
90
|
return createElement(handle.element, {
|
|
93
91
|
mix: [
|
|
94
92
|
on("dragenter", (event) => {
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { createElement, createMixin, on } from "remix/component";
|
|
11
11
|
import { DISABLED_SELECTOR } from "../utils/disabled-selector.js";
|
|
12
|
+
import { whileLive } from "./while-live.js";
|
|
12
13
|
/**
|
|
13
14
|
* Attribute every GridList row exposes its {@link SelectionModel.Key} on;
|
|
14
15
|
* `gridListKeys()` correlates a row with the key `SelectionModel` tracks its
|
|
@@ -151,7 +152,12 @@ function syncSelection(host, model) {
|
|
|
151
152
|
*/
|
|
152
153
|
export const gridListKeys = createMixin((handle) => {
|
|
153
154
|
let hostNode;
|
|
154
|
-
let
|
|
155
|
+
let follow = whileLive(handle, (model, signal) => {
|
|
156
|
+
model.addEventListener("change", () => {
|
|
157
|
+
if (hostNode !== undefined)
|
|
158
|
+
syncSelection(hostNode, model);
|
|
159
|
+
}, { signal });
|
|
160
|
+
});
|
|
155
161
|
handle.addEventListener("insert", (event) => {
|
|
156
162
|
hostNode = event.node;
|
|
157
163
|
let rows = queryRows(hostNode);
|
|
@@ -162,13 +168,7 @@ export const gridListKeys = createMixin((handle) => {
|
|
|
162
168
|
hostNode = undefined;
|
|
163
169
|
});
|
|
164
170
|
return (model) => {
|
|
165
|
-
|
|
166
|
-
boundModel = model;
|
|
167
|
-
model.addEventListener("change", () => {
|
|
168
|
-
if (hostNode !== undefined)
|
|
169
|
-
syncSelection(hostNode, model);
|
|
170
|
-
}, { signal: handle.signal });
|
|
171
|
-
}
|
|
171
|
+
follow(model);
|
|
172
172
|
return createElement(handle.element, {
|
|
173
173
|
mix: [
|
|
174
174
|
on("focusin", (event) => {
|
package/dist/mixins/hotkey.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ import type { MixinFactory } from "remix/component";
|
|
|
13
13
|
* closed, and closes it again on the same combo while it's already open,
|
|
14
14
|
* driving the host's own native `<dialog>` or `[popover]` open state.
|
|
15
15
|
*
|
|
16
|
-
* @param combo Key combination that opens or closes the host, e.g. `"mod+k"
|
|
16
|
+
* @param combo Key combination that opens or closes the host, e.g. `"mod+k"`, where `mod`
|
|
17
|
+
* is Command on Apple keyboards and Control elsewhere.
|
|
17
18
|
* @example
|
|
18
19
|
* <dialog id="command-palette" mix={[hotkey("mod+k")]}>
|
|
19
20
|
* <Command>...</Command>
|