@sdxc/ui 2026.11.10 → 2026.11.14
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 +92 -45
- package/dist/app/app-shell-toggle.d.ts +2 -0
- package/dist/app/app-shell-toggle.js +5 -2
- package/dist/app/app-shell.d.ts +25 -1
- package/dist/app/app-shell.js +73 -38
- package/dist/app/auto-refresh.d.ts +2 -0
- package/dist/app/auto-refresh.js +3 -3
- package/dist/app/behaviors/refresh-schedule.d.ts +8 -3
- package/dist/app/behaviors/refresh-schedule.js +4 -3
- package/dist/app/board.d.ts +123 -0
- package/dist/app/board.js +224 -0
- package/dist/app/chart.d.ts +2 -2
- package/dist/app/chart.js +7 -3
- package/dist/app/check-runs.d.ts +116 -0
- package/dist/app/check-runs.js +201 -0
- package/dist/app/code-view.d.ts +172 -0
- package/dist/app/code-view.js +414 -0
- package/dist/app/command-palette.d.ts +38 -3
- package/dist/app/command-palette.js +53 -5
- package/dist/app/contribution-graph.d.ts +106 -0
- package/dist/app/contribution-graph.js +289 -0
- package/dist/app/detail-sheet.d.ts +7 -0
- package/dist/app/detail-sheet.js +7 -7
- package/dist/app/diff.d.ts +200 -0
- package/dist/app/diff.js +702 -0
- package/dist/app/filter-bar.d.ts +20 -0
- package/dist/app/filter-bar.js +35 -15
- package/dist/app/filter-menu.d.ts +144 -0
- package/dist/app/filter-menu.js +480 -0
- package/dist/app/gantt.d.ts +108 -0
- package/dist/app/gantt.js +420 -0
- package/dist/app/index.d.ts +19 -0
- package/dist/app/index.js +19 -0
- package/dist/app/log-viewer.d.ts +120 -0
- package/dist/app/log-viewer.js +384 -0
- package/dist/app/merge-box.d.ts +97 -0
- package/dist/app/merge-box.js +227 -0
- package/dist/app/mixins/app-shell-controls.d.ts +4 -1
- package/dist/app/mixins/app-shell-controls.js +64 -4
- package/dist/app/mixins/auto-refresh.d.ts +5 -2
- package/dist/app/mixins/auto-refresh.js +9 -3
- package/dist/app/mixins/close-popover-on-submit.d.ts +16 -0
- package/dist/app/mixins/close-popover-on-submit.js +32 -0
- package/dist/app/mixins/code-view-selection.d.ts +60 -0
- package/dist/app/mixins/code-view-selection.js +276 -0
- package/dist/app/mixins/command-palette.d.ts +15 -4
- package/dist/app/mixins/command-palette.js +94 -6
- package/dist/app/mixins/contribution-graph-keys.d.ts +19 -0
- package/dist/app/mixins/contribution-graph-keys.js +155 -0
- package/dist/app/mixins/diff-interactions.d.ts +72 -0
- package/dist/app/mixins/diff-interactions.js +269 -0
- package/dist/app/mixins/filter-menu-keys.d.ts +41 -0
- package/dist/app/mixins/filter-menu-keys.js +91 -0
- package/dist/app/mixins/gantt-today.d.ts +17 -0
- package/dist/app/mixins/gantt-today.js +50 -0
- package/dist/app/mixins/log-viewer.d.ts +29 -0
- package/dist/app/mixins/log-viewer.js +333 -0
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +5 -0
- package/dist/app/mixins/optimistic-toggle-sync.js +25 -1
- package/dist/app/mixins/save-bar-sync.d.ts +7 -1
- package/dist/app/mixins/save-bar-sync.js +23 -4
- package/dist/app/mixins/save-status-sync.js +23 -1
- package/dist/app/mixins/split-view.js +1 -1
- package/dist/app/mixins/submit-on-close.d.ts +17 -0
- package/dist/app/mixins/submit-on-close.js +52 -0
- package/dist/app/mixins/tree-filter.d.ts +44 -0
- package/dist/app/mixins/tree-filter.js +111 -0
- package/dist/app/mixins/tree-navigation.d.ts +50 -0
- package/dist/app/mixins/tree-navigation.js +216 -0
- package/dist/app/optimistic-toggle.d.ts +8 -0
- package/dist/app/optimistic-toggle.js +3 -2
- package/dist/app/page-header.d.ts +18 -3
- package/dist/app/page-header.js +105 -50
- package/dist/app/review-thread.d.ts +115 -0
- package/dist/app/review-thread.js +116 -0
- package/dist/app/save-bar.d.ts +5 -0
- package/dist/app/save-bar.js +1 -1
- package/dist/app/settings-layout.d.ts +5 -0
- package/dist/app/settings-layout.js +5 -5
- package/dist/app/skeleton.d.ts +9 -0
- package/dist/app/skeleton.js +28 -0
- package/dist/app/split-view.d.ts +4 -0
- package/dist/app/split-view.js +3 -3
- package/dist/app/styles/code-tokens.d.ts +24 -0
- package/dist/app/styles/code-tokens.js +47 -0
- package/dist/app/tab-bar.d.ts +59 -0
- package/dist/app/tab-bar.js +111 -0
- package/dist/app/tree.d.ts +111 -14
- package/dist/app/tree.js +202 -15
- package/dist/app/utils/ansi.d.ts +55 -0
- package/dist/app/utils/ansi.js +157 -0
- package/dist/app/utils/diff-rows.d.ts +82 -0
- package/dist/app/utils/diff-rows.js +209 -0
- package/dist/app/utils/fuzzy-path.d.ts +58 -0
- package/dist/app/utils/fuzzy-path.js +202 -0
- package/dist/app/utils/line-range.d.ts +48 -0
- package/dist/app/utils/line-range.js +61 -0
- package/dist/app/utils/log-lines.d.ts +107 -0
- package/dist/app/utils/log-lines.js +170 -0
- package/dist/app/utils/tree-filter.d.ts +19 -0
- package/dist/app/utils/tree-filter.js +26 -0
- package/dist/app/view-options.d.ts +2 -0
- package/dist/app/view-options.js +2 -2
- package/dist/chat/activity.d.ts +72 -0
- package/dist/chat/activity.js +184 -0
- package/dist/chat/composer-submit.d.ts +38 -0
- package/dist/chat/composer-submit.js +44 -0
- package/dist/chat/composer.d.ts +47 -0
- package/dist/chat/composer.js +100 -0
- package/dist/chat/index.d.ts +6 -0
- package/dist/chat/index.js +6 -0
- package/dist/chat/mixins/composer-send.d.ts +32 -0
- package/dist/chat/mixins/composer-send.js +121 -0
- package/dist/chat/mixins/reveal-stream.d.ts +68 -0
- package/dist/chat/mixins/reveal-stream.js +184 -0
- package/dist/chat/mixins/stream-target.d.ts +18 -0
- package/dist/chat/mixins/stream-target.js +38 -0
- package/dist/components/button.js +7 -1
- package/dist/components/character-count.d.ts +44 -0
- package/dist/components/character-count.js +68 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/components/label-chip.d.ts +42 -0
- package/dist/components/label-chip.js +86 -0
- package/dist/components/property-list.d.ts +9 -2
- package/dist/components/property-list.js +11 -6
- package/dist/components/textarea.js +6 -1
- package/dist/components/timeline.d.ts +62 -5
- package/dist/components/timeline.js +124 -5
- package/dist/docs/code-block.js +8 -31
- package/dist/docs/file-tree.js +3 -48
- package/dist/landing/case-study.d.ts +79 -0
- package/dist/landing/case-study.js +162 -0
- package/dist/landing/contributor-wall.d.ts +72 -0
- package/dist/landing/contributor-wall.js +129 -0
- package/dist/landing/countdown.d.ts +88 -0
- package/dist/landing/countdown.js +91 -0
- package/dist/landing/episode-player.d.ts +87 -0
- package/dist/landing/episode-player.js +113 -0
- package/dist/landing/faq-band.d.ts +3 -2
- package/dist/landing/faq-band.js +4 -3
- package/dist/landing/feature-band.d.ts +8 -0
- package/dist/landing/feature-band.js +9 -3
- package/dist/landing/index.d.ts +9 -0
- package/dist/landing/index.js +9 -0
- package/dist/landing/landing-header.js +15 -4
- package/dist/landing/mixins/countdown-tick.d.ts +29 -0
- package/dist/landing/mixins/countdown-tick.js +65 -0
- package/dist/landing/mixins/usage-estimate-live.d.ts +32 -0
- package/dist/landing/mixins/usage-estimate-live.js +120 -0
- package/dist/landing/phone-fan.d.ts +38 -0
- package/dist/landing/phone-fan.js +89 -0
- package/dist/landing/phone-frame.d.ts +48 -0
- package/dist/landing/phone-frame.js +41 -0
- package/dist/landing/price-list.d.ts +68 -0
- package/dist/landing/price-list.js +125 -0
- package/dist/landing/scroll-scene.d.ts +59 -0
- package/dist/landing/scroll-scene.js +70 -0
- package/dist/landing/sponsor-wall.d.ts +30 -6
- package/dist/landing/sponsor-wall.js +70 -14
- package/dist/landing/typed-terminal.d.ts +24 -6
- package/dist/landing/typed-terminal.js +22 -14
- package/dist/landing/usage-estimate.d.ts +127 -0
- package/dist/landing/usage-estimate.js +164 -0
- package/dist/landing/utils/countdown.d.ts +33 -0
- package/dist/landing/utils/countdown.js +42 -0
- package/dist/landing/utils/pause-toggle.d.ts +2 -1
- package/dist/mixins/character-count.d.ts +62 -0
- package/dist/mixins/character-count.js +139 -0
- package/dist/mixins/index.d.ts +6 -2
- package/dist/mixins/index.js +6 -2
- package/dist/mixins/invoker-fields.d.ts +18 -0
- package/dist/mixins/invoker-fields.js +60 -0
- package/dist/mixins/media-sync.d.ts +58 -0
- package/dist/mixins/media-sync.js +102 -0
- package/dist/mixins/menu-keys.d.ts +11 -0
- package/dist/mixins/menu-keys.js +79 -70
- package/dist/mixins/sortable.d.ts +96 -0
- package/dist/mixins/sortable.js +433 -0
- package/dist/utils/code-lines.d.ts +26 -0
- package/dist/utils/code-lines.js +29 -0
- package/dist/utils/file-icon.d.ts +31 -0
- package/dist/utils/file-icon.js +60 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/write-cookie.d.ts +15 -15
- package/dist/utils/write-cookie.js +10 -16
- package/dist/video/index.d.ts +11 -0
- package/dist/video/index.js +11 -0
- package/dist/video/mixins/video-player-sync.d.ts +27 -0
- package/dist/video/mixins/video-player-sync.js +413 -0
- package/dist/video/utils/timeline.d.ts +55 -0
- package/dist/video/utils/timeline.js +90 -0
- package/dist/video/video-player.d.ts +261 -0
- package/dist/video/video-player.js +927 -0
- package/package.json +6 -3
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: seeking a media element in place and marking what plays need its API.
|
|
3
|
+
* No-JS baseline: every time is a link carrying `#t=` into the file, which opens it
|
|
4
|
+
* playing from that moment, and the server marks the moment it renders as now.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { ElementProps, MixinFactory } from "remix/component";
|
|
10
|
+
/** Types associated with {@link mediaSync} and {@link installMediaSync}. */
|
|
11
|
+
export declare namespace MediaSync {
|
|
12
|
+
/** What one player's sync marks and reports. */
|
|
13
|
+
interface Options {
|
|
14
|
+
/**
|
|
15
|
+
* Selectors, each matching one playing-order list under the player whose items carry
|
|
16
|
+
* their start in `data-start` or `data-cue`; the item playing carries `aria-current="true"`.
|
|
17
|
+
*/
|
|
18
|
+
marks: readonly string[];
|
|
19
|
+
/** Runs after every seek and time update, with the items that newly became current. */
|
|
20
|
+
onTime?: (time: number, changed: HTMLElement[]) => void;
|
|
21
|
+
}
|
|
22
|
+
/** Configuration accepted by {@link mediaSync}. */
|
|
23
|
+
interface MixinOptions extends Options {
|
|
24
|
+
/** Selector of the player's root, the closest ancestor of the host that matches. */
|
|
25
|
+
root: string;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Sets `aria-current="true"` on the last item of a playing-order list whose start is at or
|
|
30
|
+
* before `time`, and removes it from the rest, writing only what changes.
|
|
31
|
+
*
|
|
32
|
+
* @param items The list's items in playing order, each with `data-start` or `data-cue`.
|
|
33
|
+
* @param time The media's current time in seconds.
|
|
34
|
+
* @returns The item that newly became current, or `undefined` when no item became current.
|
|
35
|
+
*/
|
|
36
|
+
export declare function markPlaying(items: Iterable<HTMLElement>, time: number): HTMLElement | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Keeps a player's time links and marks in step with its media until `signal` aborts: a
|
|
39
|
+
* plain click on an `a[data-start]` seeks and plays, a modified click still opens the file,
|
|
40
|
+
* and every seek and time update marks the item playing in each list.
|
|
41
|
+
*
|
|
42
|
+
* @param root The player's root, which holds the links and the lists.
|
|
43
|
+
* @param media The `<audio>` or `<video>` the links seek.
|
|
44
|
+
* @param signal Ends the listeners when it aborts.
|
|
45
|
+
* @param options The lists to mark, and what to run after each update.
|
|
46
|
+
* @example installMediaSync(root, audio, signal, { marks: ['[data-slot="chapters"] a'] });
|
|
47
|
+
*/
|
|
48
|
+
export declare function installMediaSync(root: HTMLElement, media: HTMLMediaElement, signal: AbortSignal, options: MediaSync.Options): void;
|
|
49
|
+
/**
|
|
50
|
+
* Makes a player's `a[data-start]` time links seek and play its first `<audio>` or `<video>`,
|
|
51
|
+
* and marks the playing item of each `marks` list, as {@link installMediaSync} does. The player
|
|
52
|
+
* is the host's closest `root` match; the host is usually a hidden marker in the player's island.
|
|
53
|
+
*
|
|
54
|
+
* @param options The player's root selector and the lists to mark.
|
|
55
|
+
* @returns A mixin descriptor for an element inside the player.
|
|
56
|
+
* @example <span hidden mix={[mediaSync({ root: '[data-slot="episode"]', marks: ["[data-cue]"] })]} />
|
|
57
|
+
*/
|
|
58
|
+
export declare const mediaSync: MixinFactory<HTMLElement, [options: MediaSync.MixinOptions], ElementProps>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: seeking a media element in place and marking what plays need its API.
|
|
3
|
+
* No-JS baseline: every time is a link carrying `#t=` into the file, which opens it
|
|
4
|
+
* playing from that moment, and the server marks the moment it renders as now.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createMixin } from "remix/component";
|
|
10
|
+
/** How far, in seconds, a moment may run ahead of a start and still count as reaching it. */
|
|
11
|
+
const SEEK_SLACK = 0.25;
|
|
12
|
+
/**
|
|
13
|
+
* Sets `aria-current="true"` on the last item of a playing-order list whose start is at or
|
|
14
|
+
* before `time`, and removes it from the rest, writing only what changes.
|
|
15
|
+
*
|
|
16
|
+
* @param items The list's items in playing order, each with `data-start` or `data-cue`.
|
|
17
|
+
* @param time The media's current time in seconds.
|
|
18
|
+
* @returns The item that newly became current, or `undefined` when no item became current.
|
|
19
|
+
*/
|
|
20
|
+
export function markPlaying(items, time) {
|
|
21
|
+
let list = [...items];
|
|
22
|
+
let current;
|
|
23
|
+
for (let item of list) {
|
|
24
|
+
if (Number(item.dataset.start ?? item.dataset.cue) <= time + SEEK_SLACK)
|
|
25
|
+
current = item;
|
|
26
|
+
}
|
|
27
|
+
let changed;
|
|
28
|
+
for (let item of list) {
|
|
29
|
+
let isCurrent = item === current;
|
|
30
|
+
if (isCurrent === (item.getAttribute("aria-current") === "true"))
|
|
31
|
+
continue;
|
|
32
|
+
if (isCurrent) {
|
|
33
|
+
item.setAttribute("aria-current", "true");
|
|
34
|
+
changed = item;
|
|
35
|
+
}
|
|
36
|
+
else
|
|
37
|
+
item.removeAttribute("aria-current");
|
|
38
|
+
}
|
|
39
|
+
return changed;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Keeps a player's time links and marks in step with its media until `signal` aborts: a
|
|
43
|
+
* plain click on an `a[data-start]` seeks and plays, a modified click still opens the file,
|
|
44
|
+
* and every seek and time update marks the item playing in each list.
|
|
45
|
+
*
|
|
46
|
+
* @param root The player's root, which holds the links and the lists.
|
|
47
|
+
* @param media The `<audio>` or `<video>` the links seek.
|
|
48
|
+
* @param signal Ends the listeners when it aborts.
|
|
49
|
+
* @param options The lists to mark, and what to run after each update.
|
|
50
|
+
* @example installMediaSync(root, audio, signal, { marks: ['[data-slot="chapters"] a'] });
|
|
51
|
+
*/
|
|
52
|
+
export function installMediaSync(root, media, signal, options) {
|
|
53
|
+
let sync = () => {
|
|
54
|
+
let changed = options.marks
|
|
55
|
+
.map((selector) => markPlaying(root.querySelectorAll(selector), media.currentTime))
|
|
56
|
+
.filter((item) => item !== undefined);
|
|
57
|
+
options.onTime?.(media.currentTime, changed);
|
|
58
|
+
};
|
|
59
|
+
root.addEventListener("click", (click) => {
|
|
60
|
+
if (click.defaultPrevented || click.button !== 0)
|
|
61
|
+
return;
|
|
62
|
+
if (click.metaKey || click.ctrlKey || click.shiftKey || click.altKey)
|
|
63
|
+
return;
|
|
64
|
+
let link = click.target?.closest("a[data-start]");
|
|
65
|
+
if (!link)
|
|
66
|
+
return;
|
|
67
|
+
click.preventDefault();
|
|
68
|
+
media.currentTime = Number(link.dataset.start);
|
|
69
|
+
void media.play().catch(() => undefined);
|
|
70
|
+
sync();
|
|
71
|
+
}, { signal });
|
|
72
|
+
media.addEventListener("timeupdate", sync, { signal });
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Makes a player's `a[data-start]` time links seek and play its first `<audio>` or `<video>`,
|
|
76
|
+
* and marks the playing item of each `marks` list, as {@link installMediaSync} does. The player
|
|
77
|
+
* is the host's closest `root` match; the host is usually a hidden marker in the player's island.
|
|
78
|
+
*
|
|
79
|
+
* @param options The player's root selector and the lists to mark.
|
|
80
|
+
* @returns A mixin descriptor for an element inside the player.
|
|
81
|
+
* @example <span hidden mix={[mediaSync({ root: '[data-slot="episode"]', marks: ["[data-cue]"] })]} />
|
|
82
|
+
*/
|
|
83
|
+
export const mediaSync = createMixin((handle) => {
|
|
84
|
+
let controller;
|
|
85
|
+
let options;
|
|
86
|
+
handle.addEventListener("insert", (event) => {
|
|
87
|
+
controller?.abort();
|
|
88
|
+
let root = options ? event.node.closest(options.root) : null;
|
|
89
|
+
let media = root?.querySelector("audio, video");
|
|
90
|
+
if (!options || !root || !media)
|
|
91
|
+
return;
|
|
92
|
+
controller = new AbortController();
|
|
93
|
+
installMediaSync(root, media, controller.signal, options);
|
|
94
|
+
});
|
|
95
|
+
handle.addEventListener("remove", () => {
|
|
96
|
+
controller?.abort();
|
|
97
|
+
controller = undefined;
|
|
98
|
+
});
|
|
99
|
+
return (next) => {
|
|
100
|
+
options = next;
|
|
101
|
+
};
|
|
102
|
+
});
|
|
@@ -24,6 +24,17 @@ export declare namespace MenuKeys {
|
|
|
24
24
|
itemSelector?: string;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Runs the WAI-ARIA menu keyboard pattern on `host` until `signal` aborts: roving tabindex,
|
|
29
|
+
* arrow keys, Home/End and typeahead across its items. Script that owns server-rendered
|
|
30
|
+
* markup calls it directly; components reach it through {@link menuKeys}.
|
|
31
|
+
*
|
|
32
|
+
* @param host The Menu surface, usually a `role="menu"` element.
|
|
33
|
+
* @param signal Ends the listeners when it aborts.
|
|
34
|
+
* @param options Item-selector override for non-standard markup.
|
|
35
|
+
* @example installMenuKeys(panel, controller.signal, { itemSelector: "[data-item]" });
|
|
36
|
+
*/
|
|
37
|
+
export declare function installMenuKeys(host: HTMLElement, signal: AbortSignal, options?: MenuKeys.Options): void;
|
|
27
38
|
/**
|
|
28
39
|
* Adapts the WAI-ARIA menu keyboard pattern — roving tabindex, arrow-key
|
|
29
40
|
* navigation, Home/End, and typeahead — onto a Menu surface's
|
package/dist/mixins/menu-keys.js
CHANGED
|
@@ -30,6 +30,82 @@ function activeIndexOf(host, items) {
|
|
|
30
30
|
let active = host.ownerDocument.activeElement;
|
|
31
31
|
return active instanceof HTMLElement ? items.indexOf(active) : -1;
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs the WAI-ARIA menu keyboard pattern on `host` until `signal` aborts: roving tabindex,
|
|
35
|
+
* arrow keys, Home/End and typeahead across its items. Script that owns server-rendered
|
|
36
|
+
* markup calls it directly; components reach it through {@link menuKeys}.
|
|
37
|
+
*
|
|
38
|
+
* @param host The Menu surface, usually a `role="menu"` element.
|
|
39
|
+
* @param signal Ends the listeners when it aborts.
|
|
40
|
+
* @param options Item-selector override for non-standard markup.
|
|
41
|
+
* @example installMenuKeys(panel, controller.signal, { itemSelector: "[data-item]" });
|
|
42
|
+
*/
|
|
43
|
+
export function installMenuKeys(host, signal, options = {}) {
|
|
44
|
+
let buffer = "";
|
|
45
|
+
let resetBufferId;
|
|
46
|
+
let selector = options.itemSelector ?? DEFAULT_ITEM_SELECTOR;
|
|
47
|
+
let initialItems = queryItems(host, selector);
|
|
48
|
+
if (initialItems.length > 0)
|
|
49
|
+
setRovingTabindex(initialItems, initialItems[0]);
|
|
50
|
+
host.addEventListener("focusin", (event) => {
|
|
51
|
+
if (!belongsToSurface(event, host))
|
|
52
|
+
return;
|
|
53
|
+
let target = event.target;
|
|
54
|
+
if (!(target instanceof HTMLElement))
|
|
55
|
+
return;
|
|
56
|
+
let items = queryItems(host, selector);
|
|
57
|
+
if (items.includes(target))
|
|
58
|
+
setRovingTabindex(items, target);
|
|
59
|
+
}, { signal });
|
|
60
|
+
host.addEventListener("keydown", (event) => {
|
|
61
|
+
if (!belongsToSurface(event, host))
|
|
62
|
+
return;
|
|
63
|
+
let items = queryItems(host, selector);
|
|
64
|
+
if (items.length === 0)
|
|
65
|
+
return;
|
|
66
|
+
let index = activeIndexOf(host, items);
|
|
67
|
+
switch (event.key) {
|
|
68
|
+
case "ArrowDown": {
|
|
69
|
+
event.preventDefault();
|
|
70
|
+
let next = index === -1 ? items[0] : items[index + 1];
|
|
71
|
+
if (next)
|
|
72
|
+
focusItem(items, next);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
case "ArrowUp": {
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
let previous = index === -1 ? items[items.length - 1] : items[index - 1];
|
|
78
|
+
if (previous)
|
|
79
|
+
focusItem(items, previous);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
case "Home":
|
|
83
|
+
event.preventDefault();
|
|
84
|
+
focusItem(items, items[0]);
|
|
85
|
+
return;
|
|
86
|
+
case "End":
|
|
87
|
+
event.preventDefault();
|
|
88
|
+
focusItem(items, items[items.length - 1]);
|
|
89
|
+
return;
|
|
90
|
+
case "Backspace":
|
|
91
|
+
buffer = buffer.slice(0, -1);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!isPrintableKey(event))
|
|
95
|
+
return;
|
|
96
|
+
clearTimeout(resetBufferId);
|
|
97
|
+
buffer += event.key.toLowerCase();
|
|
98
|
+
resetBufferId = setTimeout(() => {
|
|
99
|
+
buffer = "";
|
|
100
|
+
}, TYPEAHEAD_RESET_MS);
|
|
101
|
+
let start = index === -1 ? 0 : index + 1;
|
|
102
|
+
let searchOrder = [...items.slice(start), ...items.slice(0, start)];
|
|
103
|
+
let match = searchOrder.find((item) => labelFor(item).startsWith(buffer));
|
|
104
|
+
if (match)
|
|
105
|
+
focusItem(items, match);
|
|
106
|
+
}, { signal });
|
|
107
|
+
signal.addEventListener("abort", () => clearTimeout(resetBufferId));
|
|
108
|
+
}
|
|
33
109
|
/**
|
|
34
110
|
* Adapts the WAI-ARIA menu keyboard pattern — roving tabindex, arrow-key
|
|
35
111
|
* navigation, Home/End, and typeahead — onto a Menu surface's
|
|
@@ -43,74 +119,7 @@ function activeIndexOf(host, items) {
|
|
|
43
119
|
* <Menu.Item>Delete</Menu.Item>
|
|
44
120
|
* </Menu.List>
|
|
45
121
|
*/
|
|
46
|
-
export const menuKeys = createMixin((_handle) => {
|
|
47
|
-
let
|
|
48
|
-
|
|
49
|
-
return (options = {}, props = options) => {
|
|
50
|
-
let resolved = props === options ? {} : options;
|
|
51
|
-
let selector = resolved.itemSelector ?? DEFAULT_ITEM_SELECTOR;
|
|
52
|
-
return ref((host, signal) => {
|
|
53
|
-
let initialItems = queryItems(host, selector);
|
|
54
|
-
if (initialItems.length > 0)
|
|
55
|
-
setRovingTabindex(initialItems, initialItems[0]);
|
|
56
|
-
host.addEventListener("focusin", (event) => {
|
|
57
|
-
if (!belongsToSurface(event, host))
|
|
58
|
-
return;
|
|
59
|
-
let target = event.target;
|
|
60
|
-
if (!(target instanceof HTMLElement))
|
|
61
|
-
return;
|
|
62
|
-
let items = queryItems(host, selector);
|
|
63
|
-
if (items.includes(target))
|
|
64
|
-
setRovingTabindex(items, target);
|
|
65
|
-
}, { signal });
|
|
66
|
-
host.addEventListener("keydown", (event) => {
|
|
67
|
-
if (!belongsToSurface(event, host))
|
|
68
|
-
return;
|
|
69
|
-
let items = queryItems(host, selector);
|
|
70
|
-
if (items.length === 0)
|
|
71
|
-
return;
|
|
72
|
-
let index = activeIndexOf(host, items);
|
|
73
|
-
switch (event.key) {
|
|
74
|
-
case "ArrowDown": {
|
|
75
|
-
event.preventDefault();
|
|
76
|
-
let next = index === -1 ? items[0] : items[index + 1];
|
|
77
|
-
if (next)
|
|
78
|
-
focusItem(items, next);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
case "ArrowUp": {
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
let previous = index === -1 ? items[items.length - 1] : items[index - 1];
|
|
84
|
-
if (previous)
|
|
85
|
-
focusItem(items, previous);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
case "Home":
|
|
89
|
-
event.preventDefault();
|
|
90
|
-
focusItem(items, items[0]);
|
|
91
|
-
return;
|
|
92
|
-
case "End":
|
|
93
|
-
event.preventDefault();
|
|
94
|
-
focusItem(items, items[items.length - 1]);
|
|
95
|
-
return;
|
|
96
|
-
case "Backspace":
|
|
97
|
-
buffer = buffer.slice(0, -1);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (!isPrintableKey(event))
|
|
101
|
-
return;
|
|
102
|
-
clearTimeout(resetBufferId);
|
|
103
|
-
buffer += event.key.toLowerCase();
|
|
104
|
-
resetBufferId = setTimeout(() => {
|
|
105
|
-
buffer = "";
|
|
106
|
-
}, TYPEAHEAD_RESET_MS);
|
|
107
|
-
let start = index === -1 ? 0 : index + 1;
|
|
108
|
-
let searchOrder = [...items.slice(start), ...items.slice(0, start)];
|
|
109
|
-
let match = searchOrder.find((item) => labelFor(item).startsWith(buffer));
|
|
110
|
-
if (match)
|
|
111
|
-
focusItem(items, match);
|
|
112
|
-
}, { signal });
|
|
113
|
-
signal.addEventListener("abort", () => clearTimeout(resetBufferId));
|
|
114
|
-
});
|
|
115
|
-
};
|
|
122
|
+
export const menuKeys = createMixin((_handle) => (options = {}, props = options) => {
|
|
123
|
+
let resolved = props === options ? {} : options;
|
|
124
|
+
return ref((host, signal) => installMenuKeys(host, signal, resolved));
|
|
116
125
|
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: dragging an item between or within lists, and moving one from the keyboard, need pointer
|
|
3
|
+
* and key listeners. No-JS baseline: each item's own move form, or a menu inside it, still moves it
|
|
4
|
+
* with a plain post, and the lists stay readable markup.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { MixinFactory } from "remix/component";
|
|
10
|
+
/** Attribute on the element holding every list the mixin moves items between. */
|
|
11
|
+
export declare const SORTABLE_ATTRIBUTE = "data-sortable";
|
|
12
|
+
/** Attribute a list carries its value on, which a move sends in the item's form. */
|
|
13
|
+
export declare const SORTABLE_LIST_ATTRIBUTE = "data-sortable-list";
|
|
14
|
+
/** Attribute on the element inside a list that holds its items; the list itself without one. */
|
|
15
|
+
export declare const SORTABLE_ITEMS_ATTRIBUTE = "data-sortable-items";
|
|
16
|
+
/** Attribute an item carries its value on, unique across the lists. */
|
|
17
|
+
export declare const SORTABLE_ITEM_ATTRIBUTE = "data-sortable-item";
|
|
18
|
+
/** Attribute an item's move form names its item with, so a move finds the form to post. */
|
|
19
|
+
export declare const SORTABLE_FORM_ATTRIBUTE = "data-sortable-form";
|
|
20
|
+
/**
|
|
21
|
+
* Attribute a move form names its list field with. A move appends that field after the form's
|
|
22
|
+
* own, with the list's value, and the next render of the form drops it again.
|
|
23
|
+
*/
|
|
24
|
+
export declare const SORTABLE_FIELD_ATTRIBUTE = "data-sortable-field";
|
|
25
|
+
/**
|
|
26
|
+
* Attribute a move form names its position field with. A move sends the value of the item it
|
|
27
|
+
* lands before in that field, or an empty value when it lands last. A form without one moves
|
|
28
|
+
* its item only between lists, to the top.
|
|
29
|
+
*/
|
|
30
|
+
export declare const SORTABLE_POSITION_ATTRIBUTE = "data-sortable-position";
|
|
31
|
+
/** Attribute on a list's count, which a move between lists keeps current until the page answers. */
|
|
32
|
+
export declare const SORTABLE_COUNT_ATTRIBUTE = "data-sortable-count";
|
|
33
|
+
/** Attribute on a list's title, which a keyboard move announces. */
|
|
34
|
+
export declare const SORTABLE_TITLE_ATTRIBUTE = "data-sortable-title";
|
|
35
|
+
/** Attribute on the live region a keyboard move is announced through. */
|
|
36
|
+
export declare const SORTABLE_STATUS_ATTRIBUTE = "data-sortable-status";
|
|
37
|
+
/** Attribute on the element that scrolls while the pointer rests near its edge mid-drag. */
|
|
38
|
+
export declare const SORTABLE_SCROLLER_ATTRIBUTE = "data-sortable-scroller";
|
|
39
|
+
/** Attribute set on the root for as long as a drag lasts. */
|
|
40
|
+
export declare const SORTABLE_ACTIVE_ATTRIBUTE = "data-sortable-active";
|
|
41
|
+
/** Attribute set on the item being dragged, for as long as the drag lasts. */
|
|
42
|
+
export declare const SORTABLE_DRAGGING_ATTRIBUTE = "data-sortable-dragging";
|
|
43
|
+
/** Attribute set on another list while the dragged item would land in it. */
|
|
44
|
+
export declare const SORTABLE_TARGET_ATTRIBUTE = "data-sortable-target";
|
|
45
|
+
/** Attribute on the copy of the item that follows the pointer. */
|
|
46
|
+
export declare const SORTABLE_GHOST_ATTRIBUTE = "data-sortable-ghost";
|
|
47
|
+
/** DOM event type {@link SortableMoveEvent} is dispatched under. */
|
|
48
|
+
declare const MOVE_EVENT: "ui:sortable-move";
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementEventMap {
|
|
51
|
+
[MOVE_EVENT]: SortableMoveEvent;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Dispatched on an item once it is dropped or moved by key, before its move form posts;
|
|
56
|
+
* `preventDefault()` keeps the item in place and the form from posting, for a consumer that
|
|
57
|
+
* saves the move itself.
|
|
58
|
+
*/
|
|
59
|
+
export declare class SortableMoveEvent extends Event {
|
|
60
|
+
/** The moved item's value. */
|
|
61
|
+
readonly item: string;
|
|
62
|
+
/** The list it left. */
|
|
63
|
+
readonly from: string;
|
|
64
|
+
/** The list it landed in, the same as `from` for a move within a list. */
|
|
65
|
+
readonly to: string;
|
|
66
|
+
/** The item it landed before, `null` when it landed last or its form takes no position. */
|
|
67
|
+
readonly before: string | null;
|
|
68
|
+
/**
|
|
69
|
+
* @param init The item, the two lists, and the item it landed before.
|
|
70
|
+
*/
|
|
71
|
+
constructor(init: {
|
|
72
|
+
item: string;
|
|
73
|
+
from: string;
|
|
74
|
+
to: string;
|
|
75
|
+
before?: string | null;
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
/** Options for {@link sortable}. */
|
|
79
|
+
export interface SortableOptions {
|
|
80
|
+
/**
|
|
81
|
+
* What a keyboard move announces, with `{list}` where the list's title goes, such as
|
|
82
|
+
* "Moved to {list}". Without it a keyboard move is silent.
|
|
83
|
+
*/
|
|
84
|
+
moved?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Moves items within and between the lists inside the nearest {@link SORTABLE_ATTRIBUTE} root.
|
|
88
|
+
* A mouse or pen press on an item that travels past a few pixels lifts it under a ghost, places
|
|
89
|
+
* it between the items under the pointer, and posts its move form on release; Escape puts it
|
|
90
|
+
* back. Shift+ArrowUp/Down move the focused item past its neighbour, and Shift+ArrowLeft/Right to
|
|
91
|
+
* the top of the list on either side. A touch press scrolls as usual.
|
|
92
|
+
*
|
|
93
|
+
* @example <span hidden mix={[sortable({ moved: "Moved to {list}" })]} />
|
|
94
|
+
*/
|
|
95
|
+
export declare const sortable: MixinFactory<HTMLElement, [options?: SortableOptions]>;
|
|
96
|
+
export {};
|