@sdxc/ui 2026.11.1 → 2026.11.3
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 +1 -1
- package/dist/app/app-shell-toggle.d.ts +31 -0
- package/dist/app/app-shell-toggle.js +43 -0
- package/dist/app/app-shell.d.ts +131 -0
- package/dist/app/app-shell.js +542 -0
- package/dist/app/auto-refresh.d.ts +104 -0
- package/dist/app/auto-refresh.js +126 -0
- package/dist/app/behaviors/refresh-schedule.d.ts +53 -0
- package/dist/app/behaviors/refresh-schedule.js +95 -0
- package/dist/app/behaviors/shortcuts.d.ts +175 -0
- package/dist/app/behaviors/shortcuts.js +401 -0
- package/dist/app/behaviors/toaster.d.ts +31 -2
- package/dist/app/behaviors/toaster.js +62 -5
- package/dist/app/chart.d.ts +62 -8
- package/dist/app/chart.js +207 -9
- package/dist/app/command-palette.d.ts +132 -0
- package/dist/app/command-palette.js +181 -0
- package/dist/app/danger-zone.d.ts +66 -0
- package/dist/app/danger-zone.js +66 -0
- package/dist/app/detail-sheet.d.ts +119 -0
- package/dist/app/detail-sheet.js +173 -0
- package/dist/app/drop-zone.d.ts +2 -1
- package/dist/app/drop-zone.js +6 -3
- package/dist/app/editor-layout.d.ts +69 -0
- package/dist/app/editor-layout.js +143 -0
- package/dist/app/empty.d.ts +56 -19
- package/dist/app/empty.js +129 -22
- package/dist/app/filter-bar.d.ts +169 -0
- package/dist/app/filter-bar.js +346 -0
- package/dist/app/index.d.ts +51 -0
- package/dist/app/index.js +51 -0
- package/dist/app/keyboard-help.d.ts +66 -0
- package/dist/app/keyboard-help.js +56 -0
- package/dist/app/mixins/app-shell-controls.d.ts +46 -0
- package/dist/app/mixins/app-shell-controls.js +131 -0
- package/dist/app/mixins/auto-refresh.d.ts +29 -0
- package/dist/app/mixins/auto-refresh.js +66 -0
- package/dist/app/mixins/command-palette.d.ts +56 -0
- package/dist/app/mixins/command-palette.js +297 -0
- package/dist/app/mixins/copy-permalink.d.ts +26 -0
- package/dist/app/mixins/copy-permalink.js +54 -0
- package/dist/app/mixins/detail-sheet-keys.d.ts +28 -0
- package/dist/app/mixins/detail-sheet-keys.js +88 -0
- package/dist/app/mixins/escape-link.d.ts +17 -0
- package/dist/app/mixins/escape-link.js +35 -0
- package/dist/app/mixins/keyboard-help.d.ts +38 -0
- package/dist/app/mixins/keyboard-help.js +51 -0
- package/dist/app/mixins/optimistic-toggle-sync.d.ts +80 -0
- package/dist/app/mixins/optimistic-toggle-sync.js +153 -0
- package/dist/app/mixins/range-picker-keys.d.ts +18 -0
- package/dist/app/mixins/range-picker-keys.js +94 -0
- package/dist/app/mixins/row-navigation.d.ts +85 -0
- package/dist/app/mixins/row-navigation.js +208 -0
- package/dist/app/mixins/save-bar-sync.d.ts +27 -0
- package/dist/app/mixins/save-bar-sync.js +106 -0
- package/dist/app/mixins/save-shortcut.d.ts +47 -0
- package/dist/app/mixins/save-shortcut.js +101 -0
- package/dist/app/mixins/save-status-sync.d.ts +77 -0
- package/dist/app/mixins/save-status-sync.js +159 -0
- package/dist/app/mixins/selection-bar-sync.d.ts +32 -0
- package/dist/app/mixins/selection-bar-sync.js +151 -0
- package/dist/app/mixins/split-view.d.ts +66 -0
- package/dist/app/mixins/split-view.js +319 -0
- package/dist/app/mixins/status-strip-keys.d.ts +17 -0
- package/dist/app/mixins/status-strip-keys.js +79 -0
- package/dist/app/mixins/submit-on-change.d.ts +16 -0
- package/dist/app/mixins/submit-on-change.js +28 -0
- package/dist/app/mixins/table-selection.d.ts +39 -0
- package/dist/app/mixins/table-selection.js +272 -0
- package/dist/app/mixins/toast-queue.d.ts +36 -0
- package/dist/app/mixins/toast-queue.js +77 -0
- package/dist/app/mixins/toast-stack.d.ts +20 -0
- package/dist/app/mixins/toast-stack.js +55 -0
- package/dist/app/optimistic-toggle.d.ts +48 -0
- package/dist/app/optimistic-toggle.js +38 -0
- package/dist/app/page-header.d.ts +71 -0
- package/dist/app/page-header.js +249 -0
- package/dist/app/range-picker.d.ts +102 -0
- package/dist/app/range-picker.js +118 -0
- package/dist/app/save-bar.d.ts +54 -0
- package/dist/app/save-bar.js +64 -0
- package/dist/app/save-status.d.ts +50 -0
- package/dist/app/save-status.js +54 -0
- package/dist/app/selection-bar.d.ts +101 -0
- package/dist/app/selection-bar.js +157 -0
- package/dist/app/settings-layout.d.ts +70 -0
- package/dist/app/settings-layout.js +112 -0
- package/dist/app/settings-section.d.ts +140 -0
- package/dist/app/settings-section.js +182 -0
- package/dist/app/skeleton.d.ts +47 -4
- package/dist/app/skeleton.js +149 -2
- package/dist/app/sparkline.d.ts +61 -0
- package/dist/app/sparkline.js +145 -0
- package/dist/app/split-view.d.ts +154 -0
- package/dist/app/split-view.js +272 -0
- package/dist/app/stat-card.d.ts +109 -0
- package/dist/app/stat-card.js +379 -0
- package/dist/app/status-strip.d.ts +70 -0
- package/dist/app/status-strip.js +155 -0
- package/dist/app/styles/action-row.d.ts +41 -0
- package/dist/app/styles/action-row.js +59 -0
- package/dist/app/styles/stat-delta.d.ts +29 -0
- package/dist/app/styles/stat-delta.js +36 -0
- package/dist/app/styles/toast-stack.d.ts +21 -0
- package/dist/app/styles/toast-stack.js +54 -0
- package/dist/app/table.d.ts +199 -24
- package/dist/app/table.js +640 -36
- package/dist/app/toast.d.ts +105 -5
- package/dist/app/toast.js +89 -17
- package/dist/app/toasts.d.ts +49 -0
- package/dist/app/toasts.js +103 -0
- package/dist/app/utils/app-shell-cookie.d.ts +21 -0
- package/dist/app/utils/app-shell-cookie.js +33 -0
- package/dist/app/utils/chart-marker-indices.d.ts +9 -5
- package/dist/app/utils/chart-marker-indices.js +9 -8
- package/dist/app/utils/chart-path.d.ts +14 -10
- package/dist/app/utils/chart-path.js +46 -18
- package/dist/app/utils/edited-time.d.ts +19 -0
- package/dist/app/utils/edited-time.js +35 -0
- package/dist/app/utils/key-target.d.ts +23 -0
- package/dist/app/utils/key-target.js +48 -0
- package/dist/app/utils/search-params.d.ts +69 -0
- package/dist/app/utils/search-params.js +132 -0
- package/dist/app/utils/shortcut-groups.d.ts +21 -0
- package/dist/app/utils/shortcut-groups.js +53 -0
- package/dist/app/utils/split-view-layout.d.ts +48 -0
- package/dist/app/utils/split-view-layout.js +71 -0
- package/dist/app/view-options.d.ts +99 -0
- package/dist/app/view-options.js +182 -0
- package/dist/components/banner.d.ts +61 -0
- package/dist/components/banner.js +101 -0
- package/dist/components/confirm.d.ts +54 -5
- package/dist/components/confirm.js +44 -5
- package/dist/components/group.d.ts +14 -0
- package/dist/components/group.js +66 -11
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -0
- package/dist/components/input.js +9 -3
- package/dist/components/link-button.js +8 -2
- package/dist/components/property-list.d.ts +76 -0
- package/dist/components/property-list.js +175 -0
- package/dist/components/relative-time.d.ts +72 -0
- package/dist/components/relative-time.js +45 -0
- package/dist/components/status-dot.d.ts +62 -0
- package/dist/components/status-dot.js +99 -0
- package/dist/components/text-field.d.ts +17 -2
- package/dist/components/text-field.js +13 -4
- package/dist/components/timeline.d.ts +67 -0
- package/dist/components/timeline.js +159 -0
- package/dist/components/typeset.d.ts +2 -1
- package/dist/components/typeset.js +4 -1
- package/dist/docs/code-tabs-sync.d.ts +1 -1
- package/dist/docs/code-tabs-sync.js +2 -2
- package/dist/docs/copy-button.d.ts +1 -1
- package/dist/docs/copy-button.js +2 -2
- package/dist/docs/docs-feedback.d.ts +12 -0
- package/dist/docs/docs-feedback.js +4 -2
- package/dist/docs/docs-hub.js +4 -4
- package/dist/docs/docs-layout.d.ts +1 -1
- package/dist/docs/docs-layout.js +1 -1
- package/dist/docs/docs-nav-tools.d.ts +1 -1
- package/dist/docs/docs-nav-tools.js +2 -2
- package/dist/docs/docs-nav.d.ts +6 -2
- package/dist/docs/docs-nav.js +2 -2
- package/dist/docs/docs-pager.d.ts +5 -1
- package/dist/docs/docs-pager.js +7 -6
- package/dist/docs/mixins/docs-nav-tools.d.ts +2 -2
- package/dist/docs/mixins/docs-nav-tools.js +32 -5
- package/dist/docs/next-steps.js +3 -2
- package/dist/docs/page-actions.d.ts +1 -1
- package/dist/docs/page-actions.js +2 -2
- package/dist/docs/table-of-contents.d.ts +1 -1
- package/dist/docs/table-of-contents.js +2 -2
- package/dist/mixins/confirm-phrase.d.ts +19 -0
- package/dist/mixins/confirm-phrase.js +56 -0
- package/dist/mixins/index.d.ts +2 -0
- package/dist/mixins/index.js +2 -0
- package/dist/mixins/viewer-time.d.ts +20 -0
- package/dist/mixins/viewer-time.js +40 -0
- package/dist/styles/index.d.ts +1 -0
- package/dist/styles/index.js +1 -0
- package/dist/styles/segmented-control.d.ts +49 -0
- package/dist/styles/segmented-control.js +71 -0
- package/dist/test/table.d.ts +65 -0
- package/dist/test/table.js +108 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/relative-time.d.ts +44 -0
- package/dist/utils/relative-time.js +69 -0
- package/package.json +6 -6
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: a split view remembers its panes' widths and collapsed panes in a cookie, resizes
|
|
3
|
+
* from the keyboard, steps through the list with j/k while the list keeps its scroll, and
|
|
4
|
+
* closes its sidebar sheet on navigation; HTML has no declarative wiring for any of these.
|
|
5
|
+
* No-JS baseline: panes render at their remembered layout and every item is a link.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import type { MixinFactory } from "remix/component";
|
|
11
|
+
import type { SplitViewPane } from "../utils/split-view-layout.js";
|
|
12
|
+
/**
|
|
13
|
+
* Where a split view's j/k answer: `"page"` anywhere in the document, `"view"` only while
|
|
14
|
+
* focus is inside the view, for a view shown on a page whose own keys come first.
|
|
15
|
+
*/
|
|
16
|
+
export type SplitViewKeyScope = "page" | "view";
|
|
17
|
+
/** Attribute an app puts on each list link j/k steps through, in list order. */
|
|
18
|
+
export declare const SPLIT_VIEW_ITEM_ATTRIBUTE = "data-split-view-item";
|
|
19
|
+
/**
|
|
20
|
+
* Collapses or restores `pane` and remembers it. The list and the detail never both
|
|
21
|
+
* collapse: collapsing one brings the other back, so the view always shows a record.
|
|
22
|
+
*
|
|
23
|
+
* @param root The split view.
|
|
24
|
+
* @param pane The pane to change.
|
|
25
|
+
* @param collapsed Whether it ends collapsed.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setSplitViewCollapsed(root: HTMLElement, pane: SplitViewPane, collapsed: boolean): void;
|
|
28
|
+
/**
|
|
29
|
+
* The split view's part of a divider, beside `resizeHandle()`: measures the panes before a
|
|
30
|
+
* drag starts, remembers the settled layout, moves the divider with ←/→, and collapses or
|
|
31
|
+
* restores the pane before it with Enter. Put it before `resizeHandle()` in `mix`.
|
|
32
|
+
*
|
|
33
|
+
* @param pane The pane before the divider, which Enter collapses.
|
|
34
|
+
* @returns A mixin descriptor for the divider.
|
|
35
|
+
* @example <div data-resizable-handle mix={[splitViewHandle("list"), resizeHandle("horizontal", session)]} />
|
|
36
|
+
*/
|
|
37
|
+
export declare const splitViewHandle: MixinFactory<HTMLElement, [pane: SplitViewPane]>;
|
|
38
|
+
/**
|
|
39
|
+
* Collapses or restores a pane from a button. For the sidebar below the wide breakpoint
|
|
40
|
+
* the button's own `popovertarget` opens the sidebar as a sheet instead.
|
|
41
|
+
*
|
|
42
|
+
* @param viewId The split view's id.
|
|
43
|
+
* @param pane The pane the button collapses.
|
|
44
|
+
* @returns A mixin descriptor for the toggle button.
|
|
45
|
+
* @example <button data-pane="sidebar" mix={[splitViewToggle("inbox", "sidebar")]} />
|
|
46
|
+
*/
|
|
47
|
+
export declare const splitViewToggle: MixinFactory<HTMLButtonElement, [
|
|
48
|
+
viewId: string,
|
|
49
|
+
pane: SplitViewPane
|
|
50
|
+
]>;
|
|
51
|
+
/**
|
|
52
|
+
* Binds j/k to step through the list's items while the list keeps its scroll, keeps the
|
|
53
|
+
* list's scroll offset across full page loads, and closes the sidebar sheet when one of
|
|
54
|
+
* its links is followed.
|
|
55
|
+
*
|
|
56
|
+
* @param listId The list pane's id.
|
|
57
|
+
* @param sidebarId The sidebar pane's id, when the view has one.
|
|
58
|
+
* @param scope `"page"` answers j/k anywhere; `"view"` only while focus is inside the view.
|
|
59
|
+
* @returns A mixin descriptor for the view's key marker.
|
|
60
|
+
* @example <span hidden mix={[splitViewKeys("inbox-list", "inbox-sidebar", "page")]} />
|
|
61
|
+
*/
|
|
62
|
+
export declare const splitViewKeys: MixinFactory<HTMLElement, [
|
|
63
|
+
listId: string,
|
|
64
|
+
sidebarId: string | undefined,
|
|
65
|
+
scope: SplitViewKeyScope
|
|
66
|
+
]>;
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: a split view remembers its panes' widths and collapsed panes in a cookie, resizes
|
|
3
|
+
* from the keyboard, steps through the list with j/k while the list keeps its scroll, and
|
|
4
|
+
* closes its sidebar sheet on navigation; HTML has no declarative wiring for any of these.
|
|
5
|
+
* No-JS baseline: panes render at their remembered layout and every item is a link.
|
|
6
|
+
*
|
|
7
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
8
|
+
* @copyright Sergio Xalambrí 2026
|
|
9
|
+
*/
|
|
10
|
+
import { iife } from "@sdxc/iife";
|
|
11
|
+
import { createElement, createMixin, on } from "remix/component";
|
|
12
|
+
import { isClaimedKeystroke } from "../../mixins/keymap.js";
|
|
13
|
+
import { matchesKeyCombo } from "../../utils/key-combo.js";
|
|
14
|
+
import { writeCookie } from "../../utils/write-cookie.js";
|
|
15
|
+
import { ResizeSession } from "../behaviors/resize-session.js";
|
|
16
|
+
import { serializeSplitViewLayout } from "../utils/split-view-layout.js";
|
|
17
|
+
import { ResizableLayoutChangeEvent } from "./resize-handle.js";
|
|
18
|
+
/** Attribute an app puts on each list link j/k steps through, in list order. */
|
|
19
|
+
export const SPLIT_VIEW_ITEM_ATTRIBUTE = "data-split-view-item";
|
|
20
|
+
/** The custom property each resizable pane's share is stored in. */
|
|
21
|
+
const SIZE_PROPERTY = "--ui-resizable-panel-size";
|
|
22
|
+
/** How far one arrow press moves a divider, as a percentage of the view. */
|
|
23
|
+
const KEY_STEP = 2;
|
|
24
|
+
/** Container width, in rem, from which the sidebar is a pane rather than a sheet. */
|
|
25
|
+
const WIDE_REM = 64;
|
|
26
|
+
/** The split view a node belongs to. */
|
|
27
|
+
function rootOf(node) {
|
|
28
|
+
return node.closest("[data-split-view]");
|
|
29
|
+
}
|
|
30
|
+
/** The pane element named `pane` in `root`. */
|
|
31
|
+
function paneOf(root, pane) {
|
|
32
|
+
return root.querySelector(`[data-resizable-group] > [data-pane="${pane}"]`);
|
|
33
|
+
}
|
|
34
|
+
/** Panes `root` has collapsed, read off its `data-collapsed` tokens. */
|
|
35
|
+
function collapsedPanes(root) {
|
|
36
|
+
return (root.dataset.collapsed ?? "").split(" ").filter(Boolean);
|
|
37
|
+
}
|
|
38
|
+
/** A pane's stored share, or `undefined` while it still sits at its default width. */
|
|
39
|
+
function storedSize(root, pane) {
|
|
40
|
+
let raw = paneOf(root, pane)?.style.getPropertyValue(SIZE_PROPERTY).trim() ?? "";
|
|
41
|
+
let value = Number.parseFloat(raw);
|
|
42
|
+
return Number.isFinite(value) ? value : undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Writes the view's current layout to the cookie its root names. */
|
|
45
|
+
function persist(root) {
|
|
46
|
+
let cookie = root.dataset.cookie;
|
|
47
|
+
if (!cookie)
|
|
48
|
+
return;
|
|
49
|
+
let value = serializeSplitViewLayout({
|
|
50
|
+
sidebar: storedSize(root, "sidebar"),
|
|
51
|
+
list: storedSize(root, "list"),
|
|
52
|
+
collapsed: collapsedPanes(root),
|
|
53
|
+
});
|
|
54
|
+
writeCookie(cookie, encodeURIComponent(value));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Collapses or restores `pane` and remembers it. The list and the detail never both
|
|
58
|
+
* collapse: collapsing one brings the other back, so the view always shows a record.
|
|
59
|
+
*
|
|
60
|
+
* @param root The split view.
|
|
61
|
+
* @param pane The pane to change.
|
|
62
|
+
* @param collapsed Whether it ends collapsed.
|
|
63
|
+
*/
|
|
64
|
+
export function setSplitViewCollapsed(root, pane, collapsed) {
|
|
65
|
+
let panes = collapsedPanes(root).filter((name) => name !== pane);
|
|
66
|
+
if (collapsed) {
|
|
67
|
+
panes.push(pane);
|
|
68
|
+
if (pane !== "sidebar")
|
|
69
|
+
panes = panes.filter((name) => name === pane || name === "sidebar");
|
|
70
|
+
}
|
|
71
|
+
root.dataset.collapsed = panes.join(" ");
|
|
72
|
+
for (let toggle of root.ownerDocument.querySelectorAll(`[data-split-view-toggle="${root.id}"]`)) {
|
|
73
|
+
let name = toggle.getAttribute("data-pane");
|
|
74
|
+
toggle.setAttribute("aria-expanded", String(!panes.includes(name)));
|
|
75
|
+
}
|
|
76
|
+
persist(root);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Writes every expanded pane's measured share onto it, so a session starts from what the
|
|
80
|
+
* reader sees; a collapsed pane keeps the share it will expand back to.
|
|
81
|
+
*
|
|
82
|
+
* @returns The collapsed panes' stored shares, to put back once the session settles.
|
|
83
|
+
*/
|
|
84
|
+
function seedSizes(group, root) {
|
|
85
|
+
let width = group.getBoundingClientRect().width;
|
|
86
|
+
let collapsed = collapsedPanes(root);
|
|
87
|
+
let kept = new Map();
|
|
88
|
+
for (let panel of group.querySelectorAll(":scope > [data-resizable-panel]")) {
|
|
89
|
+
if (collapsed.includes(panel.dataset.pane)) {
|
|
90
|
+
kept.set(panel, panel.style.getPropertyValue(SIZE_PROPERTY));
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
let share = (panel.getBoundingClientRect().width / width) * 100;
|
|
94
|
+
panel.style.setProperty(SIZE_PROPERTY, `${Math.round(share * 100) / 100}%`);
|
|
95
|
+
}
|
|
96
|
+
return kept;
|
|
97
|
+
}
|
|
98
|
+
/** Puts back the shares {@link seedSizes} kept for collapsed panes. */
|
|
99
|
+
function restoreSizes(kept) {
|
|
100
|
+
for (let [panel, value] of kept) {
|
|
101
|
+
if (value === "")
|
|
102
|
+
panel.style.removeProperty(SIZE_PROPERTY);
|
|
103
|
+
else
|
|
104
|
+
panel.style.setProperty(SIZE_PROPERTY, value);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Moves the divider by `percent` of the view through a one-step session, as a drag of
|
|
109
|
+
* that distance would, then settles the layout the same way a released drag does.
|
|
110
|
+
*/
|
|
111
|
+
function nudge(handle, group, percent) {
|
|
112
|
+
let handles = [...group.querySelectorAll(":scope > [data-resizable-handle]")];
|
|
113
|
+
let panels = [...group.querySelectorAll(":scope > [data-resizable-panel]")];
|
|
114
|
+
let groupSize = group.getBoundingClientRect().width;
|
|
115
|
+
let session = new ResizeSession();
|
|
116
|
+
session.start({
|
|
117
|
+
handleIndex: handles.indexOf(handle),
|
|
118
|
+
groupSize,
|
|
119
|
+
pointerPosition: 0,
|
|
120
|
+
panels: panels.map((panel, index) => ({
|
|
121
|
+
id: panel.id || String(index),
|
|
122
|
+
size: Number.parseFloat(panel.style.getPropertyValue(SIZE_PROPERTY)) || 0,
|
|
123
|
+
min: Number(panel.getAttribute("data-resizable-min") ?? 0),
|
|
124
|
+
max: Number(panel.getAttribute("data-resizable-max") ?? 100),
|
|
125
|
+
})),
|
|
126
|
+
});
|
|
127
|
+
session.move((percent / 100) * groupSize);
|
|
128
|
+
session.end();
|
|
129
|
+
session.panels.forEach((panel, index) => panels[index]?.style.setProperty(SIZE_PROPERTY, `${Math.round(panel.size * 100) / 100}%`));
|
|
130
|
+
group.dispatchEvent(new ResizableLayoutChangeEvent(session.panels));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The split view's part of a divider, beside `resizeHandle()`: measures the panes before a
|
|
134
|
+
* drag starts, remembers the settled layout, moves the divider with ←/→, and collapses or
|
|
135
|
+
* restores the pane before it with Enter. Put it before `resizeHandle()` in `mix`.
|
|
136
|
+
*
|
|
137
|
+
* @param pane The pane before the divider, which Enter collapses.
|
|
138
|
+
* @returns A mixin descriptor for the divider.
|
|
139
|
+
* @example <div data-resizable-handle mix={[splitViewHandle("list"), resizeHandle("horizontal", session)]} />
|
|
140
|
+
*/
|
|
141
|
+
export const splitViewHandle = createMixin((handle) => {
|
|
142
|
+
let kept = new Map();
|
|
143
|
+
handle.addEventListener("insert", (event) => {
|
|
144
|
+
let group = event.node.parentElement;
|
|
145
|
+
let root = rootOf(event.node);
|
|
146
|
+
if (!group || !root)
|
|
147
|
+
return;
|
|
148
|
+
group.addEventListener("ui:resizable-layout-change", () => {
|
|
149
|
+
restoreSizes(kept);
|
|
150
|
+
kept = new Map();
|
|
151
|
+
persist(root);
|
|
152
|
+
}, { signal: handle.signal });
|
|
153
|
+
});
|
|
154
|
+
return (pane) => createElement(handle.element, {
|
|
155
|
+
mix: [
|
|
156
|
+
on("pointerdown", (event) => {
|
|
157
|
+
let node = event.currentTarget;
|
|
158
|
+
let root = rootOf(node);
|
|
159
|
+
if (node.parentElement && root)
|
|
160
|
+
kept = seedSizes(node.parentElement, root);
|
|
161
|
+
}),
|
|
162
|
+
on("keydown", (event) => {
|
|
163
|
+
let node = event.currentTarget;
|
|
164
|
+
let group = node.parentElement;
|
|
165
|
+
let root = rootOf(node);
|
|
166
|
+
if (!group || !root)
|
|
167
|
+
return;
|
|
168
|
+
if (event.key === "Enter") {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
setSplitViewCollapsed(root, pane, !collapsedPanes(root).includes(pane));
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
let step = { ArrowLeft: -KEY_STEP, ArrowRight: KEY_STEP }[event.key];
|
|
174
|
+
if (step === undefined)
|
|
175
|
+
return;
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
kept = seedSizes(group, root);
|
|
178
|
+
nudge(node, group, step);
|
|
179
|
+
}),
|
|
180
|
+
],
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* Collapses or restores a pane from a button. For the sidebar below the wide breakpoint
|
|
185
|
+
* the button's own `popovertarget` opens the sidebar as a sheet instead.
|
|
186
|
+
*
|
|
187
|
+
* @param viewId The split view's id.
|
|
188
|
+
* @param pane The pane the button collapses.
|
|
189
|
+
* @returns A mixin descriptor for the toggle button.
|
|
190
|
+
* @example <button data-pane="sidebar" mix={[splitViewToggle("inbox", "sidebar")]} />
|
|
191
|
+
*/
|
|
192
|
+
export const splitViewToggle = createMixin((handle) => (viewId, pane) => createElement(handle.element, {
|
|
193
|
+
mix: [
|
|
194
|
+
on("click", (event) => {
|
|
195
|
+
let root = event.currentTarget.ownerDocument.getElementById(viewId);
|
|
196
|
+
if (!root)
|
|
197
|
+
return;
|
|
198
|
+
if (pane === "sidebar") {
|
|
199
|
+
let rem = Number.parseFloat(getComputedStyle(root.ownerDocument.documentElement).fontSize);
|
|
200
|
+
if (root.getBoundingClientRect().width < WIDE_REM * rem)
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
setSplitViewCollapsed(root, pane, !collapsedPanes(root).includes(pane));
|
|
205
|
+
}),
|
|
206
|
+
],
|
|
207
|
+
}));
|
|
208
|
+
/** Session-storage key the list's scroll offset is kept under across full page loads. */
|
|
209
|
+
function scrollKey(list) {
|
|
210
|
+
return `ui-split-view:${list.id}:${list.ownerDocument.location.pathname}`;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Marks the item `offset` away from the current one as current and follows it. The mark is
|
|
214
|
+
* ahead of the page: the next render's markup takes it over, and when the navigation fails
|
|
215
|
+
* the mark returns to the item the page's markup had marked.
|
|
216
|
+
*
|
|
217
|
+
* @param list The list pane.
|
|
218
|
+
* @param offset How many items to move, negative for up.
|
|
219
|
+
* @param last The previous press, whose mark may still be ahead of its page.
|
|
220
|
+
* @param latest Whether `step` is still the latest press, read when its navigation fails.
|
|
221
|
+
* @returns The press just made, or `undefined` when there was nowhere to go.
|
|
222
|
+
*/
|
|
223
|
+
function step(list, offset, last, latest) {
|
|
224
|
+
let items = [
|
|
225
|
+
...list.querySelectorAll(`a[href][${SPLIT_VIEW_ITEM_ATTRIBUTE}]`),
|
|
226
|
+
];
|
|
227
|
+
if (items.length === 0)
|
|
228
|
+
return undefined;
|
|
229
|
+
let current = items.findIndex((item) => {
|
|
230
|
+
let value = item.getAttribute("aria-current");
|
|
231
|
+
return value !== null && value !== "false";
|
|
232
|
+
});
|
|
233
|
+
let next = items[current === -1 ? 0 : Math.min(Math.max(current + offset, 0), items.length - 1)];
|
|
234
|
+
if (!next || next === items[current])
|
|
235
|
+
return undefined;
|
|
236
|
+
let marked = items[current];
|
|
237
|
+
let origin = iife(() => {
|
|
238
|
+
if (last?.origin && last.to === marked)
|
|
239
|
+
return last.origin;
|
|
240
|
+
let value = marked?.getAttribute("aria-current");
|
|
241
|
+
return marked && value ? { item: marked, value } : undefined;
|
|
242
|
+
});
|
|
243
|
+
let made = { to: next, origin };
|
|
244
|
+
marked?.removeAttribute("aria-current");
|
|
245
|
+
next.setAttribute("aria-current", "page");
|
|
246
|
+
next.scrollIntoView({ block: "nearest" });
|
|
247
|
+
next.click();
|
|
248
|
+
list.ownerDocument.defaultView?.navigation?.transition?.finished.then(() => {
|
|
249
|
+
made.origin = undefined;
|
|
250
|
+
}, () => {
|
|
251
|
+
if (!latest(made) || next.getAttribute("aria-current") !== "page")
|
|
252
|
+
return;
|
|
253
|
+
next.removeAttribute("aria-current");
|
|
254
|
+
origin?.item.setAttribute("aria-current", origin.value);
|
|
255
|
+
});
|
|
256
|
+
return made;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Binds j/k to step through the list's items while the list keeps its scroll, keeps the
|
|
260
|
+
* list's scroll offset across full page loads, and closes the sidebar sheet when one of
|
|
261
|
+
* its links is followed.
|
|
262
|
+
*
|
|
263
|
+
* @param listId The list pane's id.
|
|
264
|
+
* @param sidebarId The sidebar pane's id, when the view has one.
|
|
265
|
+
* @param scope `"page"` answers j/k anywhere; `"view"` only while focus is inside the view.
|
|
266
|
+
* @returns A mixin descriptor for the view's key marker.
|
|
267
|
+
* @example <span hidden mix={[splitViewKeys("inbox-list", "inbox-sidebar", "page")]} />
|
|
268
|
+
*/
|
|
269
|
+
export const splitViewKeys = createMixin((handle) => {
|
|
270
|
+
let ids = { list: "", sidebar: "" };
|
|
271
|
+
let current = "page";
|
|
272
|
+
let last;
|
|
273
|
+
handle.addEventListener("insert", (event) => {
|
|
274
|
+
let document = event.node.ownerDocument;
|
|
275
|
+
let list = document.getElementById(ids.list);
|
|
276
|
+
if (!list)
|
|
277
|
+
return;
|
|
278
|
+
try {
|
|
279
|
+
let saved = sessionStorage.getItem(scrollKey(list));
|
|
280
|
+
if (saved !== null)
|
|
281
|
+
list.scrollTop = Number(saved);
|
|
282
|
+
}
|
|
283
|
+
catch { }
|
|
284
|
+
let save = () => {
|
|
285
|
+
try {
|
|
286
|
+
sessionStorage.setItem(scrollKey(list), String(list.scrollTop));
|
|
287
|
+
}
|
|
288
|
+
catch { }
|
|
289
|
+
};
|
|
290
|
+
list.addEventListener("scroll", save, { signal: handle.signal, passive: true });
|
|
291
|
+
document.addEventListener("keydown", (keystroke) => {
|
|
292
|
+
if (isClaimedKeystroke(keystroke))
|
|
293
|
+
return;
|
|
294
|
+
let target = keystroke.target instanceof Element ? keystroke.target : null;
|
|
295
|
+
if (current === "view" && !(target && rootOf(target) === rootOf(list)))
|
|
296
|
+
return;
|
|
297
|
+
let offset = matchesKeyCombo(keystroke, "j") ? 1 : 0;
|
|
298
|
+
if (matchesKeyCombo(keystroke, "k"))
|
|
299
|
+
offset = -1;
|
|
300
|
+
if (offset === 0)
|
|
301
|
+
return;
|
|
302
|
+
let made = step(list, offset, last, (press) => press === last);
|
|
303
|
+
if (!made)
|
|
304
|
+
return;
|
|
305
|
+
last = made;
|
|
306
|
+
keystroke.preventDefault();
|
|
307
|
+
}, { signal: handle.signal });
|
|
308
|
+
let sidebar = ids.sidebar ? document.getElementById(ids.sidebar) : null;
|
|
309
|
+
sidebar?.addEventListener("click", (click) => {
|
|
310
|
+
let target = click.target instanceof Element ? click.target : null;
|
|
311
|
+
if (target?.closest("a[href]") && sidebar.matches(":popover-open"))
|
|
312
|
+
sidebar.hidePopover();
|
|
313
|
+
}, { signal: handle.signal });
|
|
314
|
+
});
|
|
315
|
+
return (listId, sidebarId, scope) => {
|
|
316
|
+
ids = { list: listId, sidebar: sidebarId ?? "" };
|
|
317
|
+
current = scope;
|
|
318
|
+
};
|
|
319
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: moving one roving Tab stop through a status strip's bars with ←/→, Home and End needs a
|
|
3
|
+
* key listener. No-JS baseline: the server marks the newest bar as the strip's one Tab stop, so
|
|
4
|
+
* the strip costs a single Tab and that bar's tooltip still shows on focus and every bar on hover.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { MixinFactory } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Keyboard navigation for a status strip's bars: ←/→ step one period, Home and End jump to the
|
|
12
|
+
* oldest and newest, and the Tab stop follows focus, so the bar's tooltip follows too. Apply it
|
|
13
|
+
* to the strip, or to any element inside one, which then walks the enclosing strip.
|
|
14
|
+
*
|
|
15
|
+
* @example <span hidden mix={[statusStripKeys()]} />
|
|
16
|
+
*/
|
|
17
|
+
export declare const statusStripKeys: MixinFactory<HTMLElement, []>;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: moving one roving Tab stop through a status strip's bars with ←/→, Home and End needs a
|
|
3
|
+
* key listener. No-JS baseline: the server marks the newest bar as the strip's one Tab stop, so
|
|
4
|
+
* the strip costs a single Tab and that bar's tooltip still shows on focus and every bar on hover.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createMixin } from "remix/component";
|
|
10
|
+
import { focusItem, setRovingTabindex } from "../../utils/keyboard-nav.js";
|
|
11
|
+
/** The strip the mixin walks when its host sits inside one. */
|
|
12
|
+
const STRIP_SELECTOR = '[data-slot="status-strip"]';
|
|
13
|
+
/** One bar of the strip, oldest first in document order. */
|
|
14
|
+
const BAR_SELECTOR = '[data-slot="status-strip-bars"] > button';
|
|
15
|
+
/**
|
|
16
|
+
* Picks the bar a key moves focus to, or `undefined` for a key the strip leaves alone. Arrows
|
|
17
|
+
* stop at either end, and follow the strip's writing direction so → always moves rightwards.
|
|
18
|
+
*
|
|
19
|
+
* @param key The pressed key.
|
|
20
|
+
* @param index The focused bar's position, oldest first.
|
|
21
|
+
* @param count How many bars the strip draws.
|
|
22
|
+
* @param rtl Whether the strip lays out right to left.
|
|
23
|
+
* @returns The position to focus.
|
|
24
|
+
*/
|
|
25
|
+
function targetIndex(key, index, count, rtl) {
|
|
26
|
+
switch (key) {
|
|
27
|
+
case "Home":
|
|
28
|
+
return 0;
|
|
29
|
+
case "End":
|
|
30
|
+
return count - 1;
|
|
31
|
+
case "ArrowRight":
|
|
32
|
+
return Math.max(0, Math.min(count - 1, index + (rtl ? -1 : 1)));
|
|
33
|
+
case "ArrowLeft":
|
|
34
|
+
return Math.max(0, Math.min(count - 1, index + (rtl ? 1 : -1)));
|
|
35
|
+
default:
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Keyboard navigation for a status strip's bars: ←/→ step one period, Home and End jump to the
|
|
41
|
+
* oldest and newest, and the Tab stop follows focus, so the bar's tooltip follows too. Apply it
|
|
42
|
+
* to the strip, or to any element inside one, which then walks the enclosing strip.
|
|
43
|
+
*
|
|
44
|
+
* @example <span hidden mix={[statusStripKeys()]} />
|
|
45
|
+
*/
|
|
46
|
+
export const statusStripKeys = createMixin((handle) => {
|
|
47
|
+
let controller;
|
|
48
|
+
handle.addEventListener("insert", (event) => {
|
|
49
|
+
controller?.abort();
|
|
50
|
+
controller = new AbortController();
|
|
51
|
+
let signal = controller.signal;
|
|
52
|
+
let strip = event.node.closest(STRIP_SELECTOR) ?? event.node;
|
|
53
|
+
let bars = () => [...strip.querySelectorAll(BAR_SELECTOR)];
|
|
54
|
+
strip.addEventListener("focusin", (focus) => {
|
|
55
|
+
let all = bars();
|
|
56
|
+
if (focus.target instanceof HTMLElement && all.includes(focus.target)) {
|
|
57
|
+
setRovingTabindex(all, focus.target);
|
|
58
|
+
}
|
|
59
|
+
}, { signal });
|
|
60
|
+
strip.addEventListener("keydown", (key) => {
|
|
61
|
+
if (key.altKey || key.ctrlKey || key.metaKey || key.shiftKey)
|
|
62
|
+
return;
|
|
63
|
+
let all = bars();
|
|
64
|
+
let index = key.target instanceof HTMLElement ? all.indexOf(key.target) : -1;
|
|
65
|
+
if (index === -1)
|
|
66
|
+
return;
|
|
67
|
+
let rtl = getComputedStyle(strip).direction === "rtl";
|
|
68
|
+
let next = targetIndex(key.key, index, all.length, rtl);
|
|
69
|
+
if (next === undefined)
|
|
70
|
+
return;
|
|
71
|
+
key.preventDefault();
|
|
72
|
+
focusItem(all, all[next]);
|
|
73
|
+
}, { signal });
|
|
74
|
+
});
|
|
75
|
+
handle.addEventListener("remove", () => {
|
|
76
|
+
controller?.abort();
|
|
77
|
+
controller = undefined;
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: a form submits only from a button, so script is what saves a switch the moment
|
|
3
|
+
* it flips; this submits the form whenever one of its controls changes.
|
|
4
|
+
* No-JS baseline: the form keeps a Save button for the browser to submit it with.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { MixinFactory } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Applied to any element inside a form: submits that form through `requestSubmit` on every
|
|
12
|
+
* `change`, so the app's own submit handling (a frame, a fetch) takes the request.
|
|
13
|
+
*
|
|
14
|
+
* @example <span hidden mix={[submitOnChange()]} />
|
|
15
|
+
*/
|
|
16
|
+
export declare const submitOnChange: MixinFactory<HTMLElement>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: a form submits only from a button, so script is what saves a switch the moment
|
|
3
|
+
* it flips; this submits the form whenever one of its controls changes.
|
|
4
|
+
* No-JS baseline: the form keeps a Save button for the browser to submit it with.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import { createMixin } from "remix/component";
|
|
10
|
+
/**
|
|
11
|
+
* Applied to any element inside a form: submits that form through `requestSubmit` on every
|
|
12
|
+
* `change`, so the app's own submit handling (a frame, a fetch) takes the request.
|
|
13
|
+
*
|
|
14
|
+
* @example <span hidden mix={[submitOnChange()]} />
|
|
15
|
+
*/
|
|
16
|
+
export const submitOnChange = createMixin((handle) => {
|
|
17
|
+
let controller;
|
|
18
|
+
handle.addEventListener("insert", (event) => {
|
|
19
|
+
controller?.abort();
|
|
20
|
+
controller = new AbortController();
|
|
21
|
+
let form = event.node.closest("form");
|
|
22
|
+
form?.addEventListener("change", () => form.requestSubmit(), { signal: controller.signal });
|
|
23
|
+
});
|
|
24
|
+
handle.addEventListener("remove", () => {
|
|
25
|
+
controller?.abort();
|
|
26
|
+
controller = undefined;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why JS: HTML has no select-all checkbox, no indeterminate state outside script and no
|
|
3
|
+
* shift-click range. No-JS baseline: every row checkbox still toggles and submits with its
|
|
4
|
+
* form, and a checked row is tinted by CSS alone.
|
|
5
|
+
*
|
|
6
|
+
* @author [Sergio Xalambrí](https://sergiodxa.com)
|
|
7
|
+
* @copyright Sergio Xalambrí 2026
|
|
8
|
+
*/
|
|
9
|
+
import type { ElementProps, MixinFactory } from "remix/component";
|
|
10
|
+
/** Selector for a per-row checkbox, the contract any selectable list renders. */
|
|
11
|
+
export declare const SELECTION_ITEM_SELECTOR = "input[type=checkbox][data-selection-item]";
|
|
12
|
+
/** Selector for the checkbox that selects or clears every row at once. */
|
|
13
|
+
export declare const SELECTION_ALL_SELECTOR = "input[type=checkbox][data-selection-all]";
|
|
14
|
+
/**
|
|
15
|
+
* Keeps a table's selection checkboxes consistent: select-all checks or clears every enabled
|
|
16
|
+
* row, mirrors the rows as checked, indeterminate or clear, and a shift-click checks or clears
|
|
17
|
+
* every row between the last clicked one and this one. Each row it changes fires a bubbling
|
|
18
|
+
* `change`, as a click would, so a selection bar counting `[data-selection-item]:checked`
|
|
19
|
+
* hears every change; each row's `<tr>` carries `aria-selected` while checked.
|
|
20
|
+
*
|
|
21
|
+
* The host is the region it governs: a `<table>`, a wrapper, or a marker inside a table, which
|
|
22
|
+
* hands the work to its closest `<table>`.
|
|
23
|
+
*
|
|
24
|
+
* @example <Table mix={[tableSelection()]}>…</Table>
|
|
25
|
+
* @example <span hidden mix={[tableSelection()]} />
|
|
26
|
+
*/
|
|
27
|
+
export declare const tableSelection: MixinFactory<HTMLElement, [], ElementProps>;
|
|
28
|
+
/**
|
|
29
|
+
* Keeps `scope`'s row boxes true to the selection when a frame reload or navigation patches
|
|
30
|
+
* them against server HTML, until `signal` aborts. The patch matches rows by position and
|
|
31
|
+
* keeps each box's live check, so afterwards a box is checked exactly when it holds a record
|
|
32
|
+
* that was checked before; once a form submitted checked rows, its boxes take what the server
|
|
33
|
+
* rendered instead. `restored` runs after every such patch, even one that changed no box.
|
|
34
|
+
*
|
|
35
|
+
* @param scope The region holding the row boxes.
|
|
36
|
+
* @param signal Ends the watch once the binding leaves the document.
|
|
37
|
+
* @param restored Re-derives what the binding draws from the boxes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function keepSelection(scope: HTMLElement, signal: AbortSignal, restored: () => void): void;
|