@tokenoftrust/storefront-runner 6.12.17 → 6.13.0
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.13.0",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -18,8 +18,11 @@ export interface DialogOptions {
|
|
|
18
18
|
doc: Document;
|
|
19
19
|
adapter?: HostAdapter;
|
|
20
20
|
title: string;
|
|
21
|
-
/**
|
|
22
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Trap Tab inside the dialog and mark it `aria-modal`. `"narrow"` does so only while the viewport
|
|
23
|
+
* is in the narrow bottom-sheet layout, re-evaluated on resize. Default false.
|
|
24
|
+
*/
|
|
25
|
+
modal?: boolean | "narrow";
|
|
23
26
|
/** Install the guarded double-Shift opener on mount. Default true (also needs the "shortcut" surface). */
|
|
24
27
|
shortcut?: boolean | { windowMs?: number; cooldownMs?: number };
|
|
25
28
|
/**
|
|
@@ -69,14 +72,19 @@ export function createDialog(options: DialogOptions): Dialog {
|
|
|
69
72
|
const closeBtn = h(doc, "button", { type: "button", "aria-label": "Close", text: "✕" });
|
|
70
73
|
const body = h(doc, "div", { class: "body" });
|
|
71
74
|
const element = h(doc, "div", { class: "dialog", role: "dialog", "aria-labelledby": titleId, hidden: true });
|
|
72
|
-
|
|
75
|
+
const NARROW_PX = 600;
|
|
76
|
+
const isModal = () => options.modal === true || (options.modal === "narrow" && win.innerWidth <= NARROW_PX);
|
|
77
|
+
const syncModal = () => {
|
|
78
|
+
if (isModal()) element.setAttribute("aria-modal", "true");
|
|
79
|
+
else element.removeAttribute("aria-modal");
|
|
80
|
+
};
|
|
81
|
+
syncModal();
|
|
73
82
|
const titlebar = h(doc, "div", { class: "titlebar" }, titleEl);
|
|
74
83
|
element.append(titlebar, body);
|
|
75
84
|
surface.root.append(element);
|
|
76
85
|
|
|
77
86
|
// ---- optional movement: a pure offset, so Reset is exact and the layout CSS stays the source of position
|
|
78
87
|
const MOVE_STEP = 48;
|
|
79
|
-
const NARROW_PX = 600;
|
|
80
88
|
let offset = { dx: 0, dy: 0 };
|
|
81
89
|
const applyOffset = () => {
|
|
82
90
|
// Keep the dialog on screen: clamp against its un-offset position.
|
|
@@ -155,7 +163,7 @@ export function createDialog(options: DialogOptions): Dialog {
|
|
|
155
163
|
api.close("escape");
|
|
156
164
|
return;
|
|
157
165
|
}
|
|
158
|
-
if (ke.key === "Tab" &&
|
|
166
|
+
if (ke.key === "Tab" && isModal() && own(ke)) {
|
|
159
167
|
const items = Array.from(element.querySelectorAll<HTMLElement>(FOCUSABLE));
|
|
160
168
|
const first = items[0];
|
|
161
169
|
const last = items[items.length - 1];
|
|
@@ -201,6 +209,8 @@ export function createDialog(options: DialogOptions): Dialog {
|
|
|
201
209
|
mounted = true;
|
|
202
210
|
surface.attach();
|
|
203
211
|
win.addEventListener("keydown", onKeyDown, true);
|
|
212
|
+
if (options.modal === "narrow") win.addEventListener("resize", syncModal);
|
|
213
|
+
syncModal();
|
|
204
214
|
syncShortcut();
|
|
205
215
|
return true;
|
|
206
216
|
},
|
|
@@ -209,6 +219,7 @@ export function createDialog(options: DialogOptions): Dialog {
|
|
|
209
219
|
if (open) api.close("unmount");
|
|
210
220
|
mounted = false;
|
|
211
221
|
win.removeEventListener("keydown", onKeyDown, true);
|
|
222
|
+
win.removeEventListener("resize", syncModal);
|
|
212
223
|
syncShortcut();
|
|
213
224
|
surface.detach();
|
|
214
225
|
},
|