a11y-elements 1.0.1 → 1.0.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 +44 -6
- package/dist/a11y.css +66 -9
- package/dist/browser/all.js +17 -17
- package/dist/browser/{chunk-JFZTJO7H.js → chunk-2HQKZFJV.js} +2 -2
- package/dist/browser/{chunk-AHF64455.js → chunk-2TPJ5MVQ.js} +2 -2
- package/dist/browser/{chunk-ORDVOV7E.js → chunk-2X4DBANG.js} +2 -2
- package/dist/browser/{chunk-7YZP3GGZ.js → chunk-3AHPI6C5.js} +2 -2
- package/dist/browser/{chunk-D6ES5GYW.js → chunk-6BEWDDER.js} +2 -2
- package/dist/browser/{chunk-JTFESZPQ.js → chunk-6VUVGT2G.js} +3 -3
- package/dist/browser/{chunk-23IEROGQ.js → chunk-B6V4HID2.js} +6 -2
- package/dist/browser/chunk-B6V4HID2.js.map +1 -0
- package/dist/browser/{chunk-NLRXEMHB.js → chunk-F4KVDZS3.js} +38 -3
- package/dist/browser/chunk-F4KVDZS3.js.map +1 -0
- package/dist/browser/{chunk-LVKKZ4XP.js → chunk-FJCQ4PVG.js} +2 -2
- package/dist/browser/{chunk-6AIK32FI.js → chunk-GYM3EIL3.js} +46 -21
- package/dist/browser/chunk-GYM3EIL3.js.map +1 -0
- package/dist/browser/{chunk-GJIRWFLA.js → chunk-H25W66MH.js} +42 -1
- package/dist/browser/chunk-H25W66MH.js.map +1 -0
- package/dist/browser/{chunk-EMXZKQ32.js → chunk-HJUKOWFZ.js} +5 -3
- package/dist/browser/chunk-HJUKOWFZ.js.map +1 -0
- package/dist/browser/{chunk-6JAOKGVI.js → chunk-IJ6JK2XW.js} +2 -2
- package/dist/browser/{chunk-MKDICSZ3.js → chunk-OB2NQV77.js} +3 -3
- package/dist/browser/{chunk-O235WSRL.js → chunk-RGO5EYGG.js} +2 -2
- package/dist/browser/chunk-WKWX3MMT.js +233 -0
- package/dist/browser/chunk-WKWX3MMT.js.map +1 -0
- package/dist/browser/{chunk-7GCUNMAO.js → chunk-YYYJ6D77.js} +16 -2
- package/dist/browser/chunk-YYYJ6D77.js.map +1 -0
- package/dist/browser/overlays/blocking-loader/define.js +3 -3
- package/dist/browser/overlays/context-menu/define.js +5 -5
- package/dist/browser/overlays/drawer/define.js +4 -4
- package/dist/browser/overlays/dropdown/define.js +5 -5
- package/dist/browser/overlays/emergency-dialog/define.js +4 -4
- package/dist/browser/overlays/floating/define.js +2 -2
- package/dist/browser/overlays/modal/define.js +4 -4
- package/dist/browser/overlays/notification-banner/define.js +3 -3
- package/dist/browser/overlays/popover/define.js +4 -4
- package/dist/browser/overlays/snackbar/define.js +3 -3
- package/dist/browser/overlays/tooltip/define.js +4 -4
- package/dist/core/input-modality.d.ts +21 -0
- package/dist/core/input-modality.js +56 -0
- package/dist/core/input-modality.js.map +1 -0
- package/dist/core/overlay-registry.d.ts +12 -0
- package/dist/core/overlay-registry.js +55 -0
- package/dist/core/overlay-registry.js.map +1 -1
- package/dist/overlays/context-menu/context-menu.element.d.ts +2 -0
- package/dist/overlays/context-menu/context-menu.element.js +4 -0
- package/dist/overlays/context-menu/context-menu.element.js.map +1 -1
- package/dist/overlays/core/a11y-anchored-overlay-element.d.ts +16 -0
- package/dist/overlays/core/a11y-anchored-overlay-element.js +37 -1
- package/dist/overlays/core/a11y-anchored-overlay-element.js.map +1 -1
- package/dist/overlays/core/a11y-passive-overlay-element.d.ts +9 -0
- package/dist/overlays/core/a11y-passive-overlay-element.js +14 -0
- package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
- package/dist/overlays/notification-banner/notification-banner.element.d.ts +7 -1
- package/dist/overlays/notification-banner/notification-banner.element.js +9 -1
- package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
- package/dist/overlays/snackbar/snackbar.element.d.ts +20 -7
- package/dist/overlays/snackbar/snackbar.element.js +55 -20
- package/dist/overlays/snackbar/snackbar.element.js.map +1 -1
- package/dist/overlays/tooltip/tooltip.element.d.ts +32 -8
- package/dist/overlays/tooltip/tooltip.element.js +112 -18
- package/dist/overlays/tooltip/tooltip.element.js.map +1 -1
- package/package.json +1 -1
- package/dist/browser/chunk-23IEROGQ.js.map +0 -1
- package/dist/browser/chunk-6AIK32FI.js.map +0 -1
- package/dist/browser/chunk-7GCUNMAO.js.map +0 -1
- package/dist/browser/chunk-EMXZKQ32.js.map +0 -1
- package/dist/browser/chunk-GJIRWFLA.js.map +0 -1
- package/dist/browser/chunk-LIZBBXUV.js +0 -124
- package/dist/browser/chunk-LIZBBXUV.js.map +0 -1
- package/dist/browser/chunk-NLRXEMHB.js.map +0 -1
- /package/dist/browser/{chunk-JFZTJO7H.js.map → chunk-2HQKZFJV.js.map} +0 -0
- /package/dist/browser/{chunk-AHF64455.js.map → chunk-2TPJ5MVQ.js.map} +0 -0
- /package/dist/browser/{chunk-ORDVOV7E.js.map → chunk-2X4DBANG.js.map} +0 -0
- /package/dist/browser/{chunk-7YZP3GGZ.js.map → chunk-3AHPI6C5.js.map} +0 -0
- /package/dist/browser/{chunk-D6ES5GYW.js.map → chunk-6BEWDDER.js.map} +0 -0
- /package/dist/browser/{chunk-JTFESZPQ.js.map → chunk-6VUVGT2G.js.map} +0 -0
- /package/dist/browser/{chunk-LVKKZ4XP.js.map → chunk-FJCQ4PVG.js.map} +0 -0
- /package/dist/browser/{chunk-6JAOKGVI.js.map → chunk-IJ6JK2XW.js.map} +0 -0
- /package/dist/browser/{chunk-MKDICSZ3.js.map → chunk-OB2NQV77.js.map} +0 -0
- /package/dist/browser/{chunk-O235WSRL.js.map → chunk-RGO5EYGG.js.map} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
A11yPassiveOverlayElement
|
|
3
|
-
|
|
2
|
+
A11yPassiveOverlayElement,
|
|
3
|
+
PASSIVE_OVERLAY_POSITIONS
|
|
4
|
+
} from "./chunk-YYYJ6D77.js";
|
|
4
5
|
import {
|
|
5
6
|
h
|
|
6
7
|
} from "./chunk-KVUJT6BC.js";
|
|
@@ -12,8 +13,9 @@ import {
|
|
|
12
13
|
|
|
13
14
|
// src/overlays/snackbar/snackbar.element.ts
|
|
14
15
|
var SnackbarElement = class extends A11yPassiveOverlayElement {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
/** One container per position, created on first use. */
|
|
17
|
+
_containers = /* @__PURE__ */ new Map();
|
|
18
|
+
_active = [];
|
|
17
19
|
static get observedAttributes() {
|
|
18
20
|
return [...super.observedAttributes, "dismiss-label"];
|
|
19
21
|
}
|
|
@@ -34,21 +36,33 @@ var SnackbarElement = class extends A11yPassiveOverlayElement {
|
|
|
34
36
|
connectedCallback() {
|
|
35
37
|
super.connectedCallback();
|
|
36
38
|
this.classList.add("a11y-snackbar-region");
|
|
37
|
-
if (!this._bottomContainer) {
|
|
38
|
-
this._bottomContainer = doc.createElement("div");
|
|
39
|
-
this._bottomContainer.className = "a11y-snackbar-region__bottom";
|
|
40
|
-
this._topContainer = doc.createElement("div");
|
|
41
|
-
this._topContainer.className = "a11y-snackbar-region__top";
|
|
42
|
-
this.append(this._bottomContainer, this._topContainer);
|
|
43
|
-
}
|
|
44
39
|
this._drainQueue();
|
|
45
40
|
}
|
|
46
|
-
|
|
41
|
+
_container(position) {
|
|
42
|
+
let container = this._containers.get(position);
|
|
43
|
+
if (!container) {
|
|
44
|
+
container = doc.createElement("div");
|
|
45
|
+
container.className = `a11y-snackbar-region__stack${position === "top" || position === "bottom" ? ` a11y-snackbar-region__${position}` : ""}`;
|
|
46
|
+
container.dataset.position = position;
|
|
47
|
+
this._containers.set(position, container);
|
|
48
|
+
this.append(container);
|
|
49
|
+
}
|
|
50
|
+
return container;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Removes every showing toast (calling its `onClose`) and drops queued
|
|
54
|
+
* ones silently, without calling `onAction`.
|
|
55
|
+
*/
|
|
47
56
|
dismissAll() {
|
|
48
57
|
this._queue = [];
|
|
49
58
|
this._cancelAutoDismissTimers();
|
|
50
|
-
|
|
59
|
+
const toClose = this._active;
|
|
60
|
+
this._active = [];
|
|
51
61
|
this._activeCount = 0;
|
|
62
|
+
toClose.forEach(({ el, onClose }) => {
|
|
63
|
+
el.remove();
|
|
64
|
+
onClose?.();
|
|
65
|
+
});
|
|
52
66
|
}
|
|
53
67
|
_onRemoved() {
|
|
54
68
|
this.dismissAll();
|
|
@@ -61,14 +75,15 @@ var SnackbarElement = class extends A11yPassiveOverlayElement {
|
|
|
61
75
|
position: options.position,
|
|
62
76
|
duration: options.duration,
|
|
63
77
|
actionText: options.actionText,
|
|
64
|
-
onAction: options.onAction
|
|
78
|
+
onAction: options.onAction,
|
|
79
|
+
onClose: options.onClose
|
|
65
80
|
});
|
|
66
81
|
}
|
|
67
82
|
_showItem(item) {
|
|
68
83
|
const type = item.type ?? "info";
|
|
69
|
-
const position = item.position ?? "bottom";
|
|
84
|
+
const position = (item.position && PASSIVE_OVERLAY_POSITIONS.includes(item.position) ? item.position : void 0) ?? this._cssPosition("--a11y-snackbar-position", PASSIVE_OVERLAY_POSITIONS) ?? "bottom";
|
|
70
85
|
const duration = item.duration ?? (item.actionText ? 1e4 : 3e3);
|
|
71
|
-
const container =
|
|
86
|
+
const container = this._container(position);
|
|
72
87
|
const el = doc.createElement("div");
|
|
73
88
|
el.className = `a11y-snackbar a11y-snackbar--${type}`;
|
|
74
89
|
el.setAttribute("role", type === "error" ? "alert" : "status");
|
|
@@ -78,15 +93,25 @@ var SnackbarElement = class extends A11yPassiveOverlayElement {
|
|
|
78
93
|
if (item.actionText) el.append(h("button", { type: "button", class: "a11y-snackbar__action" }, item.actionText));
|
|
79
94
|
el.append(h("button", { type: "button", class: "a11y-snackbar__close", "aria-label": this.dismissLabel }, "\xD7"));
|
|
80
95
|
container.appendChild(el);
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
96
|
+
const entry = { el, onClose: item.onClose, cancelAutoDismiss: () => {
|
|
97
|
+
} };
|
|
98
|
+
this._active.push(entry);
|
|
99
|
+
const remove = () => {
|
|
100
|
+
if (!this._active.includes(entry)) return false;
|
|
101
|
+
entry.cancelAutoDismiss();
|
|
84
102
|
el.remove();
|
|
103
|
+
this._active = this._active.filter((a) => a !== entry);
|
|
85
104
|
this._onItemDismissed();
|
|
105
|
+
return true;
|
|
106
|
+
};
|
|
107
|
+
const dismiss = () => {
|
|
108
|
+
if (remove()) item.onClose?.();
|
|
86
109
|
};
|
|
110
|
+
entry.cancelAutoDismiss = this._autoDismiss(el, duration, dismiss);
|
|
87
111
|
el.querySelector(".a11y-snackbar__action")?.addEventListener("click", () => {
|
|
88
|
-
|
|
112
|
+
if (!remove()) return;
|
|
89
113
|
item.onAction?.();
|
|
114
|
+
item.onClose?.();
|
|
90
115
|
});
|
|
91
116
|
el.querySelector(".a11y-snackbar__close")?.addEventListener("click", dismiss);
|
|
92
117
|
}
|
|
@@ -112,4 +137,4 @@ export {
|
|
|
112
137
|
SnackbarElement,
|
|
113
138
|
notify
|
|
114
139
|
};
|
|
115
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-GYM3EIL3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/overlays/snackbar/snackbar.element.ts","../../src/overlays/snackbar/define.ts"],"sourcesContent":["import {\n A11yPassiveOverlayElement,\n PASSIVE_OVERLAY_POSITIONS,\n type PassiveOverlayItem,\n type PassiveOverlayPosition,\n} from '../core/a11y-passive-overlay-element.js';\nimport { getString } from '../../core/strings.js';\nimport { h, type Content } from '../../core/dom.js';\nimport { doc } from '../../core/safe-dom.js';\n\nexport type SnackbarType = 'info' | 'success' | 'error' | 'warning';\n\nexport interface NotifyOptions {\n type?: SnackbarType;\n /** Defaults to `--a11y-snackbar-position` from CSS, else `bottom`. */\n position?: PassiveOverlayPosition;\n duration?: number;\n actionText?: string;\n onAction?: () => void;\n /** Called once the toast is gone: × button, action button (after `onAction`), timeout or `dismissAll()`. */\n onClose?: () => void;\n /** Sets the concurrency limit for this and all future items — sticky on the shared region, same as the `max-stack` attribute. */\n maxStack?: number;\n}\n\ninterface SnackbarItem extends PassiveOverlayItem {\n type?: SnackbarType;\n onClose?: () => void;\n}\n\ninterface ActiveToast {\n el: HTMLElement;\n onClose?: () => void;\n cancelAutoDismiss: () => void;\n}\n\n/**\n * A toast notification region. Auto-dismisses after `duration`ms — default\n * 3000, or 10000 when the toast has an action button (time to reach it) —\n * paused while the toast is hovered or focused. Place one `<a11y-snackbar></a11y-snackbar>` anywhere in your page\n * (it portals itself to `document.body`), then call `.notify(message, options)`\n * on it — or skip placing one entirely and use the `notify()` convenience\n * export from this module, which finds-or-creates one automatically.\n *\n * Each toast shows at its `position` option, else at the position set in CSS\n * with `--a11y-snackbar-position` (`top`, `bottom`, `top-left`, `top-right`,\n * `bottom-left` or `bottom-right`; read when the toast is shown), else at the\n * bottom. Every toast has a round × close button in its top-right corner that\n * dismisses it early (without calling `onAction`). It's named by\n * `dismiss-label=\"…\"`, else `setStrings({ dismiss })`. `onClose` runs\n * whenever a toast that was shown goes away, timeout included.\n *\n * While the region stays in the page, toasts finish their own timers\n * regardless of navigation (call `dismissAll()` to clear them). Removing the\n * region from the document drops its toasts, queued ones included, and\n * cancels their timers; re-adding it starts empty.\n */\nexport class SnackbarElement extends A11yPassiveOverlayElement<SnackbarItem> {\n /** One container per position, created on first use. */\n private _containers = new Map<PassiveOverlayPosition, HTMLElement>();\n private _active: ActiveToast[] = [];\n\n static override get observedAttributes(): string[] {\n return [...super.observedAttributes, 'dismiss-label'];\n }\n\n /** The accessible name of each toast's close button. */\n get dismissLabel(): string {\n return this.stringAttr('dismiss-label', getString('dismiss'));\n }\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n super.attributeChangedCallback(name, oldValue, newValue);\n if (name === 'dismiss-label' && oldValue !== newValue) this._relabelDismissButtons();\n }\n\n protected override onStringsChange(): void {\n this._relabelDismissButtons();\n }\n\n private _relabelDismissButtons(): void {\n for (const btn of this.querySelectorAll('.a11y-snackbar__close')) btn.setAttribute('aria-label', this.dismissLabel);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.classList.add('a11y-snackbar-region');\n this._drainQueue();\n }\n\n private _container(position: PassiveOverlayPosition): HTMLElement {\n let container = this._containers.get(position);\n if (!container) {\n container = doc.createElement('div');\n // `__top` / `__bottom`: the class names of the two containers before corners existed.\n container.className = `a11y-snackbar-region__stack${position === 'top' || position === 'bottom' ? ` a11y-snackbar-region__${position}` : ''}`;\n container.dataset.position = position;\n this._containers.set(position, container);\n this.append(container);\n }\n return container;\n }\n\n /**\n * Removes every showing toast (calling its `onClose`) and drops queued\n * ones silently, without calling `onAction`.\n */\n dismissAll(): void {\n this._queue = [];\n this._cancelAutoDismissTimers();\n const toClose = this._active;\n this._active = [];\n this._activeCount = 0;\n toClose.forEach(({ el, onClose }) => {\n el.remove();\n onClose?.();\n });\n }\n\n protected override _onRemoved(): void {\n this.dismissAll();\n }\n\n notify(message: Content, options: NotifyOptions = {}): void {\n if (options.maxStack) this.setMaxStack(options.maxStack);\n this.enqueue({\n message,\n type: options.type,\n position: options.position,\n duration: options.duration,\n actionText: options.actionText,\n onAction: options.onAction,\n onClose: options.onClose,\n });\n }\n\n protected _showItem(item: SnackbarItem): void {\n const type = item.type ?? 'info';\n const position =\n (item.position && PASSIVE_OVERLAY_POSITIONS.includes(item.position) ? item.position : undefined) ??\n this._cssPosition('--a11y-snackbar-position', PASSIVE_OVERLAY_POSITIONS) ??\n 'bottom';\n const duration = item.duration ?? (item.actionText ? 10_000 : 3000);\n const container = this._container(position);\n\n const el = doc.createElement('div');\n el.className = `a11y-snackbar a11y-snackbar--${type}`;\n el.setAttribute('role', type === 'error' ? 'alert' : 'status');\n el.setAttribute('aria-live', type === 'error' ? 'assertive' : 'polite');\n el.setAttribute('aria-atomic', 'true');\n el.append(h('span', { class: 'a11y-snackbar__message' }, item.message));\n if (item.actionText) el.append(h('button', { type: 'button', class: 'a11y-snackbar__action' }, item.actionText));\n el.append(h('button', { type: 'button', class: 'a11y-snackbar__close', 'aria-label': this.dismissLabel }, '\\u00d7'));\n\n container.appendChild(el);\n\n const entry: ActiveToast = { el, onClose: item.onClose, cancelAutoDismiss: () => {} };\n this._active.push(entry);\n\n /** Takes the toast off screen and counts it out; false if it was already gone (e.g. `dismissAll()` ran). */\n const remove = (): boolean => {\n if (!this._active.includes(entry)) return false;\n entry.cancelAutoDismiss();\n el.remove();\n this._active = this._active.filter((a) => a !== entry);\n // Counted out before the callbacks run: a `dismissAll()` from there resets the count itself.\n this._onItemDismissed();\n return true;\n };\n const dismiss = (): void => {\n if (remove()) item.onClose?.();\n };\n\n entry.cancelAutoDismiss = this._autoDismiss(el, duration, dismiss);\n\n el.querySelector<HTMLButtonElement>('.a11y-snackbar__action')?.addEventListener('click', () => {\n if (!remove()) return;\n item.onAction?.();\n item.onClose?.();\n });\n el.querySelector<HTMLButtonElement>('.a11y-snackbar__close')?.addEventListener('click', dismiss);\n }\n}\n","import { defineElement } from '../../core/define-element.js';\nimport type { Content } from '../../core/dom.js';\nimport { SnackbarElement, type NotifyOptions } from './snackbar.element.js';\nimport { doc } from '../../core/safe-dom.js';\n\ndefineElement('a11y-snackbar', SnackbarElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-snackbar': SnackbarElement;\n }\n}\n\nexport { SnackbarElement, type NotifyOptions };\n\nlet cachedRegion: SnackbarElement | null = null;\n\nfunction getRegion(): SnackbarElement {\n const existing = doc.querySelector<SnackbarElement>('a11y-snackbar');\n if (existing) return existing;\n if (!cachedRegion || !cachedRegion.isConnected) {\n cachedRegion = doc.createElement('a11y-snackbar') as SnackbarElement;\n doc.body.appendChild(cachedRegion);\n }\n return cachedRegion;\n}\n\n/**\n * Convenience: finds (or creates) an `<a11y-snackbar>` region and shows a\n * toast in it. Skip this entirely and call `.notify()` on your own\n * `<a11y-snackbar>` element directly if you want explicit control over\n * where it lives in the DOM.\n */\nexport function notify(message: Content, options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MAAQ,CAAC;AAEnH,cAAU,YAAY,EAAE;AAExB,UAAM,QAAqB,EAAE,IAAI,SAAS,KAAK,SAAS,mBAAmB,MAAM;AAAA,IAAC,EAAE;AACpF,SAAK,QAAQ,KAAK,KAAK;AAGvB,UAAM,SAAS,MAAe;AAC5B,UAAI,CAAC,KAAK,QAAQ,SAAS,KAAK,EAAG,QAAO;AAC1C,YAAM,kBAAkB;AACxB,SAAG,OAAO;AACV,WAAK,UAAU,KAAK,QAAQ,OAAO,CAAC,MAAM,MAAM,KAAK;AAErD,WAAK,iBAAiB;AACtB,aAAO;AAAA,IACT;AACA,UAAM,UAAU,MAAY;AAC1B,UAAI,OAAO,EAAG,MAAK,UAAU;AAAA,IAC/B;AAEA,UAAM,oBAAoB,KAAK,aAAa,IAAI,UAAU,OAAO;AAEjE,OAAG,cAAiC,wBAAwB,GAAG,iBAAiB,SAAS,MAAM;AAC7F,UAAI,CAAC,OAAO,EAAG;AACf,WAAK,WAAW;AAChB,WAAK,UAAU;AAAA,IACjB,CAAC;AACD,OAAG,cAAiC,uBAAuB,GAAG,iBAAiB,SAAS,OAAO;AAAA,EACjG;AACF;;;ACjLA,cAAc,iBAAiB,eAAe;AAU9C,IAAI,eAAuC;AAE3C,SAAS,YAA6B;AACpC,QAAM,WAAW,IAAI,cAA+B,eAAe;AACnE,MAAI,SAAU,QAAO;AACrB,MAAI,CAAC,gBAAgB,CAAC,aAAa,aAAa;AAC9C,mBAAe,IAAI,cAAc,eAAe;AAChD,QAAI,KAAK,YAAY,YAAY;AAAA,EACnC;AACA,SAAO;AACT;AAQO,SAAS,OAAO,SAAkB,UAAyB,CAAC,GAAS;AAC1E,YAAU,EAAE,OAAO,SAAS,OAAO;AACrC;","names":[]}
|
|
@@ -46,6 +46,30 @@ function dismissAllOverlays() {
|
|
|
46
46
|
function recordPortalOrigin(overlay, origin) {
|
|
47
47
|
state.portalOrigins.set(overlay, origin);
|
|
48
48
|
}
|
|
49
|
+
function getPortalOrigin(overlay) {
|
|
50
|
+
return state.portalOrigins.get(overlay) ?? null;
|
|
51
|
+
}
|
|
52
|
+
var PASSIVE_REGION_CLASS = "a11y-passive-overlay-region";
|
|
53
|
+
function findOverlayChromeRoot(target, except) {
|
|
54
|
+
const body = doc.body;
|
|
55
|
+
let overlay = null;
|
|
56
|
+
for (let node = target; node; node = prop(node, "parentNode") ?? node.host ?? null) {
|
|
57
|
+
if (node === body) return null;
|
|
58
|
+
if (node instanceof Element && node !== except && (state.openOverlays.has(node) || node.classList.contains(PASSIVE_REGION_CLASS))) {
|
|
59
|
+
overlay = node;
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (let node = overlay; node; node = prop(node, "parentNode") ?? node.host ?? null) {
|
|
64
|
+
const parent = prop(node, "parentNode");
|
|
65
|
+
if (parent === body) return node;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function computedZIndex(el) {
|
|
70
|
+
const z = Number.parseInt(getComputedStyle(el).zIndex, 10);
|
|
71
|
+
return Number.isFinite(z) ? z : null;
|
|
72
|
+
}
|
|
49
73
|
function forgetPortalOrigin(overlay) {
|
|
50
74
|
state.portalOrigins.delete(overlay);
|
|
51
75
|
}
|
|
@@ -82,8 +106,11 @@ function inertOutside(keep, exempt) {
|
|
|
82
106
|
function releaseInert(el) {
|
|
83
107
|
if (state.inertedByLib.delete(el)) el.removeAttribute("inert");
|
|
84
108
|
}
|
|
109
|
+
var MODAL_LAYER_CLASS = "a11y-modal-layer-open";
|
|
110
|
+
var MODAL_LAYER_Z = "--a11y-z-modal-layer";
|
|
85
111
|
function syncInert() {
|
|
86
112
|
const top = state.inertLayers[state.inertLayers.length - 1];
|
|
113
|
+
syncModalLayer(top);
|
|
87
114
|
const wanted = /* @__PURE__ */ new Set();
|
|
88
115
|
if (top) {
|
|
89
116
|
for (const child of Array.from(doc.body.children)) {
|
|
@@ -100,6 +127,17 @@ function syncInert() {
|
|
|
100
127
|
state.inertedByLib.add(el);
|
|
101
128
|
}
|
|
102
129
|
}
|
|
130
|
+
function syncModalLayer(top) {
|
|
131
|
+
const root = doc.documentElement;
|
|
132
|
+
const z = top?.exempt ? computedZIndex(top.keep) : null;
|
|
133
|
+
if (z === null) {
|
|
134
|
+
root.classList.remove(MODAL_LAYER_CLASS);
|
|
135
|
+
root.style.removeProperty(MODAL_LAYER_Z);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
root.style.setProperty(MODAL_LAYER_Z, String(z));
|
|
139
|
+
root.classList.add(MODAL_LAYER_CLASS);
|
|
140
|
+
}
|
|
103
141
|
var NO_SCROLL_CLASS = "a11y-no-scroll";
|
|
104
142
|
var GUTTER_CLASS = "a11y-no-scroll--gutter";
|
|
105
143
|
function lockScroll() {
|
|
@@ -135,6 +173,9 @@ export {
|
|
|
135
173
|
isInsideOverlayOpenedAfter,
|
|
136
174
|
dismissAllOverlays,
|
|
137
175
|
recordPortalOrigin,
|
|
176
|
+
getPortalOrigin,
|
|
177
|
+
findOverlayChromeRoot,
|
|
178
|
+
computedZIndex,
|
|
138
179
|
forgetPortalOrigin,
|
|
139
180
|
removeOverlaysWithin,
|
|
140
181
|
inertOutside,
|
|
@@ -144,4 +185,4 @@ export {
|
|
|
144
185
|
emitOverlayOpen,
|
|
145
186
|
emitOverlayClose
|
|
146
187
|
};
|
|
147
|
-
//# sourceMappingURL=chunk-
|
|
188
|
+
//# sourceMappingURL=chunk-H25W66MH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/overlay-registry.ts"],"sourcesContent":["import { doc, prop } from './safe-dom.js';\n\n/**\n * Why an overlay closed: `'escape'`, a click on the `'backdrop'`, the ×\n * `'close-button'`, an `'outside-click'`, focus leaving a menu (`'focus-out'`),\n * a menu `'item'` being activated, `'dismiss-all'` (`dismissAllOverlays()`),\n * the element being `'removed'` from the document while open, or `'api'`:\n * `close()`, `open = false` or removing the `open` attribute.\n */\nexport type OverlayCloseReason =\n | 'escape'\n | 'backdrop'\n | 'close-button'\n | 'outside-click'\n | 'focus-out'\n | 'item'\n | 'api'\n | 'dismiss-all'\n | 'removed';\n\nexport interface OverlayOpenCloseDetail {\n /** The overlay's tag name. */\n name: string;\n /** The overlay element itself. */\n element?: Element;\n /** Only on `a11y-overlay-close`, for overlays opened with `open`. */\n reason?: OverlayCloseReason;\n}\n\nexport interface OverlayEventExtra {\n element?: Element;\n reason?: OverlayCloseReason;\n}\n\nexport const OVERLAY_OPEN_EVENT = 'a11y-overlay-open';\nexport const OVERLAY_CLOSE_EVENT = 'a11y-overlay-close';\n\ninterface Dismissible {\n close(reason?: OverlayCloseReason): void;\n}\n\ninterface SharedState {\n openOverlays: Set<Dismissible>;\n scrollLocks: number;\n /** Each body-mounted overlay → the parent it was authored in, for `removeOverlaysWithin()`. */\n portalOrigins: Map<Element, Node>;\n /** Open modal layers (`inertOutside()` calls), bottom to top: only the top one decides what's inert. */\n inertLayers: InertLayer[];\n /** Elements whose `inert` attribute this library set — the only ones it ever removes it from. */\n inertedByLib: Set<Element>;\n}\n\ninterface InertLayer {\n keep: Element;\n exempt?: (el: Element) => boolean;\n}\n\n/**\n * Page-wide state, stored on `globalThis` rather than in module scope: each\n * standalone `dist/browser/**\\/define.js` bundle inlines its own copy of this\n * module, so a module-scoped `Set` would give every bundle loaded on the\n * same page its own private registry (and its own scroll-lock count). A\n * `Symbol.for()` key is shared across all of them.\n */\nconst STATE_KEY = Symbol.for('a11y-elements/overlay-state');\nconst store = globalThis as unknown as Record<symbol, SharedState | undefined>;\nconst state: SharedState = (store[STATE_KEY] ??= {\n openOverlays: new Set(),\n scrollLocks: 0,\n portalOrigins: new Map(),\n inertLayers: [],\n inertedByLib: new Set(),\n});\n// A state object created by an older bundle on the same page predates these fields.\nstate.portalOrigins ??= new Map();\nstate.inertLayers ??= [];\nstate.inertedByLib ??= new Set();\n\n/**\n * Tracks every currently-open overlay instance so a consumer's own SPA\n * router (or anything else) can force-dismiss all of them, e.g. on\n * navigation — the framework-agnostic replacement for the old\n * `Lifecycle.onViewUnmount` global hook, which only `notification-banner`\n * used and `snackbar` deliberately opted out of. That asymmetry is\n * preserved: nothing here calls `dismissAllOverlays()` automatically, a\n * consumer wires it into their own navigation event if they want it.\n */\nexport function registerOpenOverlay(overlay: Dismissible): void {\n state.openOverlays.add(overlay);\n}\n\nexport function unregisterOpenOverlay(overlay: Dismissible): void {\n state.openOverlays.delete(overlay);\n}\n\n/** Open overlays registered after `overlay` (the set keeps opening order). */\nfunction openedAfter(overlay: Dismissible): Dismissible[] {\n const open = Array.from(state.openOverlays);\n const index = open.indexOf(overlay);\n return index === -1 ? [] : open.slice(index + 1);\n}\n\n/**\n * Whether another overlay was opened after `overlay` and is still open — so\n * a key press like Escape belongs to that one, the topmost, not to `overlay`.\n */\nexport function hasOverlayOpenedAfter(overlay: Dismissible): boolean {\n return openedAfter(overlay).length > 0;\n}\n\n/**\n * Whether `target` is inside an overlay opened after `overlay` (a dropdown in\n * a popover, a modal opened from it…). That overlay lives in its own chrome\n * on `<body>`, so a click in it is outside `overlay`'s DOM but not outside it\n * as far as the user is concerned.\n */\nexport function isInsideOverlayOpenedAfter(overlay: Dismissible, target: Node | null): boolean {\n const later = new Set<unknown>(openedAfter(overlay));\n if (later.size === 0) return false;\n for (let node: Node | null = target; node; node = prop(node, 'parentNode') ?? (node as ShadowRoot).host ?? null) {\n if (later.has(node)) return true;\n }\n return false;\n}\n\nexport function dismissAllOverlays(): void {\n for (const overlay of Array.from(state.openOverlays)) overlay.close('dismiss-all');\n}\n\n/** Remembers where an overlay was authored before it moved itself to `<body>`. */\nexport function recordPortalOrigin(overlay: Element, origin: Node): void {\n state.portalOrigins.set(overlay, origin);\n}\n\n/** Where `overlay` was authored before it moved itself to `<body>`, if it did. */\nexport function getPortalOrigin(overlay: Element): Node | null {\n return state.portalOrigins.get(overlay) ?? null;\n}\n\nconst PASSIVE_REGION_CLASS = 'a11y-passive-overlay-region';\n\n/**\n * The stacking root (the direct child of `<body>`: a modal's backdrop, an\n * anchored overlay's wrapper, a snackbar region…) of the nearest overlay that\n * `target` sits inside — an open overlay other than `except`, or a passive\n * region. `null` when `target` isn't inside one. Overlays opened from inside\n * another one stack themselves just above this root's z-index.\n */\nexport function findOverlayChromeRoot(target: Node | null, except?: unknown): HTMLElement | null {\n const body = doc.body;\n let overlay: Element | null = null;\n for (let node: Node | null = target; node; node = prop(node, 'parentNode') ?? (node as ShadowRoot).host ?? null) {\n if (node === body) return null;\n if (node instanceof Element && node !== except && (state.openOverlays.has(node as unknown as Dismissible) || node.classList.contains(PASSIVE_REGION_CLASS))) {\n overlay = node;\n break;\n }\n }\n for (let node: Node | null = overlay; node; node = prop(node, 'parentNode') ?? (node as ShadowRoot).host ?? null) {\n const parent: Node | null = prop(node, 'parentNode');\n if (parent === body) return node as HTMLElement;\n }\n return null;\n}\n\n/** An element's computed z-index as a number, or `null` when it's `auto` (or not set). */\nexport function computedZIndex(el: Element): number | null {\n const z = Number.parseInt(getComputedStyle(el).zIndex, 10);\n return Number.isFinite(z) ? z : null;\n}\n\n/** Drops the record once an overlay leaves the document for real, so it isn't kept alive. */\nexport function forgetPortalOrigin(overlay: Element): void {\n state.portalOrigins.delete(overlay);\n}\n\n/**\n * Overlays move themselves to `<body>`, so removing the subtree they were\n * authored in (a component unmount, an SPA navigation) leaves them behind.\n * Call this with that subtree's root to remove every overlay authored inside\n * it (or directly in it) — it works after `host` has left the document too.\n * Returns how many were removed.\n */\nexport function removeOverlaysWithin(host: Node): number {\n // An overlay authored inside another one (a tooltip in a modal) records that overlay as its\n // origin, which sits in <body>, not in `host`: keep going until no removed root contains one.\n const roots: Node[] = [host];\n let removed = 0;\n let found = true;\n while (found) {\n found = false;\n for (const [overlay, origin] of Array.from(state.portalOrigins)) {\n if (!roots.some((root) => root.contains(origin))) continue;\n overlay.remove(); // its disconnectedCallback tears it down and forgets it\n state.portalOrigins.delete(overlay);\n roots.push(overlay);\n removed++;\n found = true;\n }\n }\n return removed;\n}\n\n/**\n * Makes every child of `<body>` except `keep` (and those `exempt` keeps)\n * `inert`, so keyboard and assistive-tech users can't reach the page behind a\n * modal overlay — a dimmed backdrop only blocks the mouse, and `aria-modal`\n * alone still lets some screen readers wander out.\n *\n * Calls stack: each pushes a layer, and only the topmost open layer decides\n * what's inert, so closing a lower modal (or a modal under a blocking loader)\n * first leaves the page behind the top one inert. `inert` the consumer set\n * themselves is never removed. Returns a function that pops this layer.\n */\nexport function inertOutside(keep: Element, exempt?: (el: Element) => boolean): () => void {\n const layer: InertLayer = { keep, exempt };\n state.inertLayers.push(layer);\n syncInert();\n let released = false;\n return () => {\n if (released) return;\n released = true;\n const index = state.inertLayers.indexOf(layer);\n if (index !== -1) state.inertLayers.splice(index, 1);\n syncInert();\n };\n}\n\n/**\n * Removes the `inert` this library put on `el`, if any. Overlays call it as\n * they move into their open chrome: a closed overlay sits in `<body>`, so a\n * modal opened before it inerted it, and it would stay unusable when opened\n * from inside that modal.\n */\nexport function releaseInert(el: Element): void {\n if (state.inertedByLib.delete(el)) el.removeAttribute('inert');\n}\n\nconst MODAL_LAYER_CLASS = 'a11y-modal-layer-open';\nconst MODAL_LAYER_Z = '--a11y-z-modal-layer';\n\nfunction syncInert(): void {\n const top = state.inertLayers[state.inertLayers.length - 1];\n syncModalLayer(top);\n const wanted = new Set<Element>();\n if (top) {\n for (const child of Array.from(doc.body.children)) {\n if (child === top.keep || child.contains(top.keep) || top.exempt?.(child)) continue;\n wanted.add(child);\n }\n }\n for (const el of Array.from(state.inertedByLib)) {\n if (!wanted.has(el)) releaseInert(el);\n }\n for (const el of wanted) {\n if (el.hasAttribute('inert')) continue; // already inert, by us or by the consumer\n el.setAttribute('inert', '');\n state.inertedByLib.add(el);\n }\n}\n\n/**\n * While the topmost modal layer keeps passive regions (snackbar,\n * notification-banner) usable, exposes its z-index on `<html>` so their CSS\n * can stack them just above it instead of behind its backdrop. A layer that\n * inerts them too (a blocking loader) keeps them at their usual level.\n */\nfunction syncModalLayer(top: InertLayer | undefined): void {\n const root = doc.documentElement;\n const z = top?.exempt ? computedZIndex(top.keep) : null;\n if (z === null) {\n root.classList.remove(MODAL_LAYER_CLASS);\n root.style.removeProperty(MODAL_LAYER_Z);\n return;\n }\n root.style.setProperty(MODAL_LAYER_Z, String(z));\n root.classList.add(MODAL_LAYER_CLASS);\n}\n\nconst NO_SCROLL_CLASS = 'a11y-no-scroll';\nconst GUTTER_CLASS = 'a11y-no-scroll--gutter';\n\n/**\n * Reference-counted page scroll lock. Every scroll-locking overlay (modal,\n * drawer, emergency-dialog, blocking-loader) calls `lockScroll()` once on\n * show and `unlockScroll()` once when fully hidden, so closing one of two\n * stacked overlays doesn't unlock the page under the one still open.\n *\n * `overflow: hidden` removes a classic (non-overlay) scrollbar, which would\n * widen the page. The gutter class keeps that space reserved, but only when\n * hiding overflow actually widened the root: reserving it on a page without\n * a scrollbar would narrow the page instead. Comparing the root's width\n * before and after (rather than against `innerWidth`) isn't fooled by\n * fractional-zoom rounding or by a gutter the app already reserves.\n */\nexport function lockScroll(): void {\n if (state.scrollLocks++ !== 0) return;\n const root = doc.documentElement;\n const widthBefore = root.clientWidth;\n root.classList.add(NO_SCROLL_CLASS);\n if (root.clientWidth > widthBefore) root.classList.add(GUTTER_CLASS);\n}\n\nexport function unlockScroll(): void {\n if (state.scrollLocks === 0) return;\n if (--state.scrollLocks === 0) doc.documentElement.classList.remove(NO_SCROLL_CLASS, GUTTER_CLASS);\n}\n\n/**\n * Standardized replacement for the old `Overlays.overlayOpened/overlayClosed`\n * singleton, which was only called by 4 of the 10 concrete overlays. Every\n * `A11yOverlayElement` dispatches these uniformly. They bubble from the\n * overlay element (so a listener on it, or on `document`, sees them), or fire\n * on `document` when there's no element or it has already left the document.\n */\nfunction emitOverlayEvent(type: string, name: string, extra: OverlayEventExtra): boolean {\n const { element, reason } = extra;\n const detail: OverlayOpenCloseDetail = { name };\n if (element) detail.element = element;\n if (reason) detail.reason = reason;\n const target = element?.isConnected ? element : document;\n return target.dispatchEvent(new CustomEvent<OverlayOpenCloseDetail>(type, { bubbles: true, detail }));\n}\n\nexport function emitOverlayOpen(name: string, extra: Omit<OverlayEventExtra, 'reason'> = {}): boolean {\n return emitOverlayEvent(OVERLAY_OPEN_EVENT, name, extra);\n}\n\nexport function emitOverlayClose(name: string, extra: OverlayEventExtra = {}): boolean {\n return emitOverlayEvent(OVERLAY_CLOSE_EVENT, name, extra);\n}\n"],"mappings":";;;;;;AAkCO,IAAM,qBAAqB;AAC3B,IAAM,sBAAsB;AA6BnC,IAAM,YAAY,uBAAO,IAAI,6BAA6B;AAC1D,IAAM,QAAQ;AACd,IAAM,QAAsB,MAAM,SAAS,MAAM;AAAA,EAC/C,cAAc,oBAAI,IAAI;AAAA,EACtB,aAAa;AAAA,EACb,eAAe,oBAAI,IAAI;AAAA,EACvB,aAAa,CAAC;AAAA,EACd,cAAc,oBAAI,IAAI;AACxB;AAEA,MAAM,kBAAkB,oBAAI,IAAI;AAChC,MAAM,gBAAgB,CAAC;AACvB,MAAM,iBAAiB,oBAAI,IAAI;AAWxB,SAAS,oBAAoB,SAA4B;AAC9D,QAAM,aAAa,IAAI,OAAO;AAChC;AAEO,SAAS,sBAAsB,SAA4B;AAChE,QAAM,aAAa,OAAO,OAAO;AACnC;AAGA,SAAS,YAAY,SAAqC;AACxD,QAAM,OAAO,MAAM,KAAK,MAAM,YAAY;AAC1C,QAAM,QAAQ,KAAK,QAAQ,OAAO;AAClC,SAAO,UAAU,KAAK,CAAC,IAAI,KAAK,MAAM,QAAQ,CAAC;AACjD;AAMO,SAAS,sBAAsB,SAA+B;AACnE,SAAO,YAAY,OAAO,EAAE,SAAS;AACvC;AAQO,SAAS,2BAA2B,SAAsB,QAA8B;AAC7F,QAAM,QAAQ,IAAI,IAAa,YAAY,OAAO,CAAC;AACnD,MAAI,MAAM,SAAS,EAAG,QAAO;AAC7B,WAAS,OAAoB,QAAQ,MAAM,OAAO,KAAK,MAAM,YAAY,KAAM,KAAoB,QAA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iveOverlayElement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-YYYJ6D77.js";
|
|
4
4
|
import {
|
|
5
5
|
h
|
|
6
6
|
} from "./chunk-KVUJT6BC.js";
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
} from "./chunk-ED3UMYMY.js";
|
|
12
12
|
|
|
13
13
|
// src/overlays/notification-banner/notification-banner.element.ts
|
|
14
|
+
var POSITIONS = ["top", "bottom"];
|
|
14
15
|
var NotificationBannerElement = class extends A11yPassiveOverlayElement {
|
|
15
16
|
_topContainer;
|
|
16
17
|
_bottomContainer;
|
|
@@ -70,7 +71,8 @@ var NotificationBannerElement = class extends A11yPassiveOverlayElement {
|
|
|
70
71
|
}
|
|
71
72
|
_showItem(item) {
|
|
72
73
|
const type = item.type ?? "info";
|
|
73
|
-
const
|
|
74
|
+
const option = item.position;
|
|
75
|
+
const position = (option && POSITIONS.includes(option) ? option : void 0) ?? this._cssPosition("--a11y-notification-banner-position", POSITIONS) ?? "top";
|
|
74
76
|
const container = position === "top" ? this._topContainer : this._bottomContainer;
|
|
75
77
|
const el = doc.createElement("div");
|
|
76
78
|
el.className = `a11y-notification-banner a11y-notification-banner--${type}`;
|
|
@@ -126,4 +128,4 @@ export {
|
|
|
126
128
|
NotificationBannerElement,
|
|
127
129
|
showNotificationBanner
|
|
128
130
|
};
|
|
129
|
-
//# sourceMappingURL=chunk-
|
|
131
|
+
//# sourceMappingURL=chunk-HJUKOWFZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/overlays/notification-banner/notification-banner.element.ts","../../src/overlays/notification-banner/define.ts"],"sourcesContent":["import { A11yPassiveOverlayElement, type PassiveOverlayItem } from '../core/a11y-passive-overlay-element.js';\nimport { getString } from '../../core/strings.js';\nimport { h, type Content } from '../../core/dom.js';\nimport { doc } from '../../core/safe-dom.js';\n\nexport type NotificationBannerType = 'info' | 'success' | 'error' | 'warning';\n\nexport type NotificationBannerPosition = 'top' | 'bottom';\n\nconst POSITIONS: readonly NotificationBannerPosition[] = ['top', 'bottom'];\n\nexport interface NotificationBannerOptions {\n type?: NotificationBannerType;\n /** Defaults to `--a11y-notification-banner-position` from CSS, else `top`. */\n position?: NotificationBannerPosition;\n actionText?: string;\n onAction?: () => void;\n onClose?: () => void;\n /** Sets the concurrency limit for this and all future items — sticky on the shared region, same as the `max-stack` attribute. */\n maxStack?: number;\n}\n\ninterface NotificationBannerItem extends PassiveOverlayItem {\n type?: NotificationBannerType;\n onClose?: () => void;\n}\n\n/**\n * A persistent banner region (unlike `<a11y-snackbar>`, items never\n * auto-dismiss — they stay until the user dismisses them or `dismissAll()`\n * is called). Place one `<a11y-notification-banner>` in your page, then\n * call `.show(message, options)` on it — or use the `showNotificationBanner()`\n * convenience export, which finds-or-creates one automatically.\n *\n * `dismissAll()` is the framework-agnostic replacement for the old\n * `Lifecycle.onViewUnmount` auto-wiring (which assumed a specific SPA-router\n * service) — if you want banners cleared on navigation, call it yourself\n * from your own router's navigation hook. Unlike `<a11y-snackbar>` (whose\n * toasts finish their own timers regardless of navigation while the region\n * stays in the page), this asymmetry is intentional, not an oversight — a\n * banner is scoped to the page that raised it, a toast isn't.\n *\n * Each item's close button is named by `dismiss-label=\"…\"`, else\n * `setStrings({ dismiss })`.\n *\n * Each banner shows at its `position` option, else at the position set in\n * CSS with `--a11y-notification-banner-position` (`top` or `bottom`; read\n * when the banner is shown), else at the top.\n */\nexport class NotificationBannerElement extends A11yPassiveOverlayElement<NotificationBannerItem> {\n private _topContainer!: HTMLElement;\n private _bottomContainer!: HTMLElement;\n private _active: Array<{ el: HTMLElement; onClose?: () => void }> = [];\n\n static override get observedAttributes(): string[] {\n return [...super.observedAttributes, 'dismiss-label'];\n }\n\n /** The accessible name of each item's close button. */\n get dismissLabel(): string {\n return this.stringAttr('dismiss-label', getString('dismiss'));\n }\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n super.attributeChangedCallback(name, oldValue, newValue);\n if (name === 'dismiss-label' && oldValue !== newValue) this._relabelDismissButtons();\n }\n\n protected override onStringsChange(): void {\n this._relabelDismissButtons();\n }\n\n private _relabelDismissButtons(): void {\n for (const { el } of this._active) {\n el.querySelector('.a11y-notification-banner__close')?.setAttribute('aria-label', this.dismissLabel);\n }\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.classList.add('a11y-notification-banner-region');\n if (!this._topContainer) {\n this._topContainer = doc.createElement('div');\n this._topContainer.className = 'a11y-notification-banner-region__top';\n this._bottomContainer = doc.createElement('div');\n this._bottomContainer.className = 'a11y-notification-banner-region__bottom';\n this.append(this._topContainer, this._bottomContainer);\n }\n this._drainQueue();\n }\n\n show(message: Content, options: NotificationBannerOptions = {}): void {\n if (options.maxStack) this.setMaxStack(options.maxStack);\n this.enqueue({\n message,\n type: options.type,\n position: options.position,\n actionText: options.actionText,\n onAction: options.onAction,\n onClose: options.onClose,\n });\n }\n\n /** Force-dismisses every showing/queued item. Queued items never shown are dropped silently (no onClose); active ones get their onClose called. */\n dismissAll(): void {\n this._queue = [];\n const toClose = this._active;\n this._active = [];\n this._activeCount = 0;\n toClose.forEach(({ el, onClose }) => {\n el.remove();\n onClose?.();\n });\n }\n\n protected _showItem(item: NotificationBannerItem): void {\n const type = item.type ?? 'info';\n const option = item.position as NotificationBannerPosition | undefined;\n const position =\n (option && POSITIONS.includes(option) ? option : undefined) ??\n this._cssPosition('--a11y-notification-banner-position', POSITIONS) ??\n 'top';\n const container = position === 'top' ? this._topContainer : this._bottomContainer;\n\n const el = doc.createElement('div');\n el.className = `a11y-notification-banner a11y-notification-banner--${type}`;\n el.setAttribute('role', type === 'error' ? 'alert' : 'status');\n el.setAttribute('aria-live', type === 'error' ? 'assertive' : 'polite');\n el.append(\n h('span', { class: 'a11y-notification-banner__message' }, item.message),\n h(\n 'span',\n { class: 'a11y-notification-banner__actions' },\n item.actionText ? h('button', { type: 'button', class: 'a11y-notification-banner__action' }, item.actionText) : null,\n h('button', { type: 'button', class: 'a11y-notification-banner__close', 'aria-label': this.dismissLabel }, '\\u00d7'),\n ),\n );\n\n container.appendChild(el);\n\n const entry = { el, onClose: item.onClose };\n this._active.push(entry);\n\n const dismiss = (): void => {\n // Already gone: e.g. `onAction` called `dismissAll()`, which closed it and reset the count.\n if (!this._active.includes(entry)) return;\n el.remove();\n this._active = this._active.filter((a) => a !== entry);\n // Count it out before `onClose` runs: a `dismissAll()` from there resets the count itself.\n this._onItemDismissed();\n item.onClose?.();\n };\n\n if (item.actionText && item.onAction) {\n const actionBtn = el.querySelector<HTMLButtonElement>('.a11y-notification-banner__action');\n actionBtn?.addEventListener('click', () => {\n item.onAction?.();\n dismiss();\n });\n }\n\n el.querySelector<HTMLButtonElement>('.a11y-notification-banner__close')?.addEventListener('click', dismiss);\n }\n}\n","import { defineElement } from '../../core/define-element.js';\nimport type { Content } from '../../core/dom.js';\nimport { NotificationBannerElement, type NotificationBannerOptions } from './notification-banner.element.js';\nimport { doc } from '../../core/safe-dom.js';\n\ndefineElement('a11y-notification-banner', NotificationBannerElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-notification-banner': NotificationBannerElement;\n }\n}\n\nexport { NotificationBannerElement, type NotificationBannerOptions };\n\nlet cachedRegion: NotificationBannerElement | null = null;\n\nfunction getRegion(): NotificationBannerElement {\n const existing = doc.querySelector<NotificationBannerElement>('a11y-notification-banner');\n if (existing) return existing;\n if (!cachedRegion || !cachedRegion.isConnected) {\n cachedRegion = doc.createElement('a11y-notification-banner') as NotificationBannerElement;\n doc.body.appendChild(cachedRegion);\n }\n return cachedRegion;\n}\n\n/**\n * Convenience: finds (or creates) an `<a11y-notification-banner>` region and\n * shows a banner in it. Skip this entirely and call `.show()` on your own\n * `<a11y-notification-banner>` element directly if you want explicit control\n * over where it lives in the DOM.\n */\nexport function showNotificationBanner(message: Content, options: NotificationBannerOptions = {}): void {\n getRegion().show(message, options);\n}\n\nexport * from '../core/zero-build-exports.js';\n"],"mappings":";;;;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;AAErD,WAAK,iBAAiB;AACtB,WAAK,UAAU;AAAA,IACjB;AAEA,QAAI,KAAK,cAAc,KAAK,UAAU;AACpC,YAAM,YAAY,GAAG,cAAiC,mCAAmC;AACzF,iBAAW,iBAAiB,SAAS,MAAM;AACzC,aAAK,WAAW;AAChB,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH;AAEA,OAAG,cAAiC,kCAAkC,GAAG,iBAAiB,SAAS,OAAO;AAAA,EAC5G;AACF;;;AC9JA,cAAc,4BAA4B,yBAAyB;AAUnE,IAAI,eAAiD;AAErD,SAAS,YAAuC;AAC9C,QAAM,WAAW,IAAI,cAAyC,0BAA0B;AACxF,MAAI,SAAU,QAAO;AACrB,MAAI,CAAC,gBAAgB,CAAC,aAAa,aAAa;AAC9C,mBAAe,IAAI,cAAc,0BAA0B;AAC3D,QAAI,KAAK,YAAY,YAAY;AAAA,EACnC;AACA,SAAO;AACT;AAQO,SAAS,uBAAuB,SAAkB,UAAqC,CAAC,GAAS;AACtG,YAAU,EAAE,KAAK,SAAS,OAAO;AACnC;","names":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
registerOpenOverlay,
|
|
7
7
|
releaseInert,
|
|
8
8
|
unregisterOpenOverlay
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-H25W66MH.js";
|
|
10
10
|
import {
|
|
11
11
|
A11yElement,
|
|
12
12
|
doc
|
|
@@ -137,4 +137,4 @@ var A11yOverlayElement = class extends A11yElement {
|
|
|
137
137
|
export {
|
|
138
138
|
A11yOverlayElement
|
|
139
139
|
};
|
|
140
|
-
//# sourceMappingURL=chunk-
|
|
140
|
+
//# sourceMappingURL=chunk-IJ6JK2XW.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
A11yOverlayElement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IJ6JK2XW.js";
|
|
4
4
|
import {
|
|
5
5
|
focusReturnTarget
|
|
6
6
|
} from "./chunk-FNILKXCO.js";
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
inertOutside,
|
|
9
9
|
lockScroll,
|
|
10
10
|
unlockScroll
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-H25W66MH.js";
|
|
12
12
|
import {
|
|
13
13
|
h
|
|
14
14
|
} from "./chunk-KVUJT6BC.js";
|
|
@@ -74,4 +74,4 @@ defineElement("a11y-blocking-loader", BlockingLoaderElement);
|
|
|
74
74
|
export {
|
|
75
75
|
BlockingLoaderElement
|
|
76
76
|
};
|
|
77
|
-
//# sourceMappingURL=chunk-
|
|
77
|
+
//# sourceMappingURL=chunk-OB2NQV77.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
A11yAnchoredOverlayElement
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-F4KVDZS3.js";
|
|
4
4
|
import {
|
|
5
5
|
focusFromKeyboard,
|
|
6
6
|
focusReturnTarget,
|
|
@@ -150,4 +150,4 @@ var A11yMenuOverlayElement = class extends A11yAnchoredOverlayElement {
|
|
|
150
150
|
export {
|
|
151
151
|
A11yMenuOverlayElement
|
|
152
152
|
};
|
|
153
|
-
//# sourceMappingURL=chunk-
|
|
153
|
+
//# sourceMappingURL=chunk-RGO5EYGG.js.map
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import {
|
|
2
|
+
A11yAnchoredOverlayElement
|
|
3
|
+
} from "./chunk-F4KVDZS3.js";
|
|
4
|
+
import {
|
|
5
|
+
nextId
|
|
6
|
+
} from "./chunk-Q4TMA3P7.js";
|
|
7
|
+
import {
|
|
8
|
+
syncIdRef
|
|
9
|
+
} from "./chunk-FAEA66RR.js";
|
|
10
|
+
import {
|
|
11
|
+
defineElement,
|
|
12
|
+
doc
|
|
13
|
+
} from "./chunk-ED3UMYMY.js";
|
|
14
|
+
|
|
15
|
+
// src/core/input-modality.ts
|
|
16
|
+
var STATE_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/input-modality");
|
|
17
|
+
var store = globalThis;
|
|
18
|
+
var state = store[STATE_KEY] ??= { last: null, listening: false };
|
|
19
|
+
var MODIFIER_KEYS = /* @__PURE__ */ new Set(["Shift", "Control", "Alt", "Meta", "AltGraph", "CapsLock", "Fn"]);
|
|
20
|
+
function trackInputModality() {
|
|
21
|
+
if (state.listening || typeof document === "undefined") return;
|
|
22
|
+
state.listening = true;
|
|
23
|
+
doc.addEventListener(
|
|
24
|
+
"keydown",
|
|
25
|
+
(e) => {
|
|
26
|
+
if (e.ctrlKey || e.altKey || e.metaKey || MODIFIER_KEYS.has(e.key)) return;
|
|
27
|
+
state.last = "keyboard";
|
|
28
|
+
},
|
|
29
|
+
true
|
|
30
|
+
);
|
|
31
|
+
doc.addEventListener(
|
|
32
|
+
"pointerdown",
|
|
33
|
+
() => {
|
|
34
|
+
state.last = "pointer";
|
|
35
|
+
},
|
|
36
|
+
true
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function isKeyboardFocus(el) {
|
|
40
|
+
if (state.last) return state.last === "keyboard";
|
|
41
|
+
try {
|
|
42
|
+
return el.matches(":focus-visible");
|
|
43
|
+
} catch {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// src/overlays/tooltip/tooltip.element.ts
|
|
49
|
+
var LONG_PRESS_MS = 500;
|
|
50
|
+
var LONG_PRESS_MOVE_TOLERANCE = 10;
|
|
51
|
+
function isMouse(e) {
|
|
52
|
+
return e.pointerType === "mouse";
|
|
53
|
+
}
|
|
54
|
+
var TooltipElement = class extends A11yAnchoredOverlayElement {
|
|
55
|
+
static get observedAttributes() {
|
|
56
|
+
return [...super.observedAttributes, "show-delay", "hide-delay"];
|
|
57
|
+
}
|
|
58
|
+
_showTimer = null;
|
|
59
|
+
_hideTimer = null;
|
|
60
|
+
_boundAnchorEl = null;
|
|
61
|
+
_longPressTimer = null;
|
|
62
|
+
_longPressStart = null;
|
|
63
|
+
/** Set by a mouse press on the anchor: hover doesn't reopen the tooltip until the pointer leaves. */
|
|
64
|
+
_suppressed = false;
|
|
65
|
+
_onPointerEnter = (e) => {
|
|
66
|
+
if (isMouse(e) && !this._suppressed) this._scheduleShow();
|
|
67
|
+
};
|
|
68
|
+
_onPointerLeave = (e) => {
|
|
69
|
+
if (!isMouse(e)) return;
|
|
70
|
+
this._suppressed = false;
|
|
71
|
+
this._scheduleHide();
|
|
72
|
+
};
|
|
73
|
+
_onFocus = () => {
|
|
74
|
+
if (this._boundAnchorEl && isKeyboardFocus(this._boundAnchorEl)) this._scheduleShow();
|
|
75
|
+
};
|
|
76
|
+
_onBlur = () => this._scheduleHide();
|
|
77
|
+
_onPointerDown = (e) => {
|
|
78
|
+
this._clearTimers();
|
|
79
|
+
if (this.open) this.open = false;
|
|
80
|
+
if (isMouse(e)) {
|
|
81
|
+
this._suppressed = true;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const { clientX, clientY } = e;
|
|
85
|
+
this._longPressStart = { x: clientX ?? 0, y: clientY ?? 0 };
|
|
86
|
+
this._longPressTimer = setTimeout(() => {
|
|
87
|
+
this._longPressTimer = null;
|
|
88
|
+
this._longPressStart = null;
|
|
89
|
+
this.open = true;
|
|
90
|
+
}, LONG_PRESS_MS);
|
|
91
|
+
};
|
|
92
|
+
_onPointerMove = (e) => {
|
|
93
|
+
const start = this._longPressStart;
|
|
94
|
+
if (!this._longPressTimer || !start) return;
|
|
95
|
+
const { clientX, clientY } = e;
|
|
96
|
+
if (Math.hypot((clientX ?? 0) - start.x, (clientY ?? 0) - start.y) > LONG_PRESS_MOVE_TOLERANCE) this._cancelLongPress();
|
|
97
|
+
};
|
|
98
|
+
_onPointerEnd = () => this._cancelLongPress();
|
|
99
|
+
/**
|
|
100
|
+
* Android fires `contextmenu` on a long press, and its text selection may
|
|
101
|
+
* cancel the pointer right after: during a pending touch long press it opens
|
|
102
|
+
* the tooltip at once instead of showing the native menu.
|
|
103
|
+
*/
|
|
104
|
+
_onContextMenu = (e) => {
|
|
105
|
+
if (!this._longPressTimer) return;
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
this._cancelLongPress();
|
|
108
|
+
this.open = true;
|
|
109
|
+
};
|
|
110
|
+
_onWrapperEnter = (e) => {
|
|
111
|
+
if (isMouse(e)) this._clearTimers();
|
|
112
|
+
};
|
|
113
|
+
_onWrapperLeave = (e) => {
|
|
114
|
+
if (isMouse(e)) this._scheduleHide();
|
|
115
|
+
};
|
|
116
|
+
get showDelay() {
|
|
117
|
+
return this.numberAttr("show-delay", 300);
|
|
118
|
+
}
|
|
119
|
+
get hideDelay() {
|
|
120
|
+
return this.numberAttr("hide-delay", 100);
|
|
121
|
+
}
|
|
122
|
+
wantsFocusTrap() {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
onConnect() {
|
|
126
|
+
if (!this.id) this.id = nextId("a11y-tooltip");
|
|
127
|
+
trackInputModality();
|
|
128
|
+
this._bindAnchorListeners();
|
|
129
|
+
if (!this._boundAnchorEl) this.afterParse(() => this._bindAnchorListeners());
|
|
130
|
+
}
|
|
131
|
+
onDisconnect() {
|
|
132
|
+
this._unbindAnchorListeners();
|
|
133
|
+
this._clearTimers();
|
|
134
|
+
}
|
|
135
|
+
onAnchorChanged() {
|
|
136
|
+
super.onAnchorChanged();
|
|
137
|
+
if (this._connected) this._bindAnchorListeners();
|
|
138
|
+
}
|
|
139
|
+
_show() {
|
|
140
|
+
super._show();
|
|
141
|
+
const wrapper = this._wrapper;
|
|
142
|
+
if (!wrapper) return;
|
|
143
|
+
wrapper.addEventListener("pointerenter", this._onWrapperEnter);
|
|
144
|
+
wrapper.addEventListener("pointerleave", this._onWrapperLeave);
|
|
145
|
+
}
|
|
146
|
+
createWrapper() {
|
|
147
|
+
const el = super.createWrapper();
|
|
148
|
+
el.classList.add("a11y-tooltip-wrapper");
|
|
149
|
+
el.setAttribute("role", "tooltip");
|
|
150
|
+
return el;
|
|
151
|
+
}
|
|
152
|
+
getContentClass() {
|
|
153
|
+
return "a11y-tooltip-content";
|
|
154
|
+
}
|
|
155
|
+
/** Detaches from the anchor entirely (unlike `close()`, which just hides the current tooltip — it can still reopen on the next hover). */
|
|
156
|
+
dispose() {
|
|
157
|
+
this._unbindAnchorListeners();
|
|
158
|
+
this._clearTimers();
|
|
159
|
+
this.close();
|
|
160
|
+
}
|
|
161
|
+
_bindAnchorListeners() {
|
|
162
|
+
const anchor = this.anchorElement;
|
|
163
|
+
if (anchor === this._boundAnchorEl) return;
|
|
164
|
+
this._unbindAnchorListeners();
|
|
165
|
+
if (!anchor) return;
|
|
166
|
+
for (const [type, listener] of this._anchorListeners()) anchor.addEventListener(type, listener);
|
|
167
|
+
this._setDescribedBy(anchor, true);
|
|
168
|
+
this._boundAnchorEl = anchor;
|
|
169
|
+
}
|
|
170
|
+
_unbindAnchorListeners() {
|
|
171
|
+
const anchor = this._boundAnchorEl;
|
|
172
|
+
if (!anchor) return;
|
|
173
|
+
for (const [type, listener] of this._anchorListeners()) anchor.removeEventListener(type, listener);
|
|
174
|
+
this._suppressed = false;
|
|
175
|
+
this._setDescribedBy(anchor, false);
|
|
176
|
+
this._boundAnchorEl = null;
|
|
177
|
+
}
|
|
178
|
+
_anchorListeners() {
|
|
179
|
+
return [
|
|
180
|
+
["pointerenter", this._onPointerEnter],
|
|
181
|
+
["pointerleave", this._onPointerLeave],
|
|
182
|
+
["focus", this._onFocus],
|
|
183
|
+
["blur", this._onBlur],
|
|
184
|
+
["pointerdown", this._onPointerDown],
|
|
185
|
+
["pointermove", this._onPointerMove],
|
|
186
|
+
["pointerup", this._onPointerEnd],
|
|
187
|
+
["pointercancel", this._onPointerEnd],
|
|
188
|
+
["contextmenu", this._onContextMenu]
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
/** Adds/removes this tooltip's id in the anchor's `aria-describedby` token list, preserving any ids the consumer set. */
|
|
192
|
+
_setDescribedBy(anchor, present) {
|
|
193
|
+
syncIdRef(anchor, "aria-describedby", this.id, present);
|
|
194
|
+
}
|
|
195
|
+
_scheduleShow() {
|
|
196
|
+
this._clearTimers();
|
|
197
|
+
this._showTimer = setTimeout(() => {
|
|
198
|
+
this.open = true;
|
|
199
|
+
}, this.showDelay);
|
|
200
|
+
}
|
|
201
|
+
_scheduleHide() {
|
|
202
|
+
this._clearTimers();
|
|
203
|
+
this._hideTimer = setTimeout(() => {
|
|
204
|
+
this.open = false;
|
|
205
|
+
}, this.hideDelay);
|
|
206
|
+
}
|
|
207
|
+
_clearTimers() {
|
|
208
|
+
if (this._showTimer) {
|
|
209
|
+
clearTimeout(this._showTimer);
|
|
210
|
+
this._showTimer = null;
|
|
211
|
+
}
|
|
212
|
+
if (this._hideTimer) {
|
|
213
|
+
clearTimeout(this._hideTimer);
|
|
214
|
+
this._hideTimer = null;
|
|
215
|
+
}
|
|
216
|
+
this._cancelLongPress();
|
|
217
|
+
}
|
|
218
|
+
_cancelLongPress() {
|
|
219
|
+
if (this._longPressTimer) {
|
|
220
|
+
clearTimeout(this._longPressTimer);
|
|
221
|
+
this._longPressTimer = null;
|
|
222
|
+
}
|
|
223
|
+
this._longPressStart = null;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
// src/overlays/tooltip/define.ts
|
|
228
|
+
defineElement("a11y-tooltip", TooltipElement);
|
|
229
|
+
|
|
230
|
+
export {
|
|
231
|
+
TooltipElement
|
|
232
|
+
};
|
|
233
|
+
//# sourceMappingURL=chunk-WKWX3MMT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/input-modality.ts","../../src/overlays/tooltip/tooltip.element.ts","../../src/overlays/tooltip/define.ts"],"sourcesContent":["import { doc } from './safe-dom.js';\n\nexport type InputModality = 'keyboard' | 'pointer';\n\ninterface ModalityState {\n /** The kind of input the user last used on the page, `null` before any. */\n last: InputModality | null;\n listening: boolean;\n}\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone browser bundle inlines its own copy of this module, and\n * they must agree on what the user last did.\n */\nconst STATE_KEY = Symbol.for('a11y-elements/input-modality');\nconst store = globalThis as unknown as Record<symbol, ModalityState | undefined>;\nconst state: ModalityState = (store[STATE_KEY] ??= { last: null, listening: false });\n\nconst MODIFIER_KEYS = new Set(['Shift', 'Control', 'Alt', 'Meta', 'AltGraph', 'CapsLock', 'Fn']);\n\n/**\n * Starts tracking whether the last input was a keyboard or a pointer, with\n * capture-phase listeners on `document` installed once per page. Keys\n * pressed with Ctrl/Alt/Meta and lone modifier keys don't count (a shortcut\n * or a screenshot isn't keyboard navigation), like the browsers'\n * `:focus-visible` heuristic. A `preventDefault()`ed key still counts: an\n * Escape that closes a modal and sends focus back is keyboard navigation,\n * though Firefox then doesn't match `:focus-visible`.\n */\nexport function trackInputModality(): void {\n if (state.listening || typeof document === 'undefined') return;\n state.listening = true;\n doc.addEventListener(\n 'keydown',\n (e) => {\n if (e.ctrlKey || e.altKey || e.metaKey || MODIFIER_KEYS.has(e.key)) return;\n state.last = 'keyboard';\n },\n true,\n );\n doc.addEventListener(\n 'pointerdown',\n () => {\n state.last = 'pointer';\n },\n true,\n );\n}\n\n/** What the user last used, `null` before any input (or before `trackInputModality()`). */\nexport function lastInputModality(): InputModality | null {\n return state.last;\n}\n\n/**\n * Whether focus on `el` came from the keyboard: from the last input when\n * there was one, else (focus moved by script on load, `autofocus`) from the\n * browser's `:focus-visible`, and `true` where that selector is unsupported.\n */\nexport function isKeyboardFocus(el: Element): boolean {\n if (state.last) return state.last === 'keyboard';\n try {\n return el.matches(':focus-visible');\n } catch {\n return true;\n }\n}\n\n/** Forgets the last input. Tests only. */\nexport function resetInputModality(): void {\n state.last = null;\n}\n","import { syncIdRef } from '../../core/dom-sync.js';\nimport { A11yAnchoredOverlayElement } from '../core/a11y-anchored-overlay-element.js';\nimport { nextId } from '../../core/ids.js';\nimport { isKeyboardFocus, trackInputModality } from '../../core/input-modality.js';\n\n/** How long a touch or pen press must last to show the tooltip. */\nconst LONG_PRESS_MS = 500;\n/** How far (px) the pointer may move during that press before it counts as a scroll or drag instead. */\nconst LONG_PRESS_MOVE_TOLERANCE = 10;\n\nfunction isMouse(e: Event): boolean {\n return (e as PointerEvent).pointerType === 'mouse';\n}\n\n/**\n * A hover/focus-triggered tooltip anchored to a trigger element. Never\n * traps focus — shows after `show-delay`ms of mouse hover or keyboard focus\n * (focus after a key press, not after a click or tap; see `isKeyboardFocus()`), hides after `hide-delay`ms once the pointer/focus\n * leaves, debounced so a quick pass doesn't flash it. The anchor gets\n * `aria-describedby` pointing at this element, so screen readers announce\n * the tooltip text with it. Moving the pointer onto the tooltip itself keeps\n * it open, and Escape dismisses it (WCAG 1.4.13: hoverable + dismissible).\n *\n * Pressing the anchor closes it (and a mouse hover won't reopen it until the\n * pointer leaves). A tap neither hovers nor shows a focus ring, so it never\n * opens the tooltip; a touch or pen long press (500ms) does, until the next\n * tap elsewhere, the next press on the anchor, or Escape.\n *\n * ```html\n * <button id=\"save-btn\">Save</button>\n * <a11y-tooltip anchor=\"save-btn\">Saves your changes</a11y-tooltip>\n * ```\n */\nexport class TooltipElement extends A11yAnchoredOverlayElement {\n static override get observedAttributes(): string[] {\n return [...super.observedAttributes, 'show-delay', 'hide-delay'];\n }\n\n private _showTimer: ReturnType<typeof setTimeout> | null = null;\n private _hideTimer: ReturnType<typeof setTimeout> | null = null;\n private _boundAnchorEl: HTMLElement | null = null;\n private _longPressTimer: ReturnType<typeof setTimeout> | null = null;\n private _longPressStart: { x: number; y: number } | null = null;\n /** Set by a mouse press on the anchor: hover doesn't reopen the tooltip until the pointer leaves. */\n private _suppressed = false;\n\n private _onPointerEnter = (e: Event): void => {\n if (isMouse(e) && !this._suppressed) this._scheduleShow();\n };\n private _onPointerLeave = (e: Event): void => {\n if (!isMouse(e)) return;\n this._suppressed = false;\n this._scheduleHide();\n };\n private _onFocus = (): void => {\n if (this._boundAnchorEl && isKeyboardFocus(this._boundAnchorEl)) this._scheduleShow();\n };\n private _onBlur = (): void => this._scheduleHide();\n private _onPointerDown = (e: Event): void => {\n this._clearTimers();\n if (this.open) this.open = false;\n if (isMouse(e)) {\n this._suppressed = true;\n return;\n }\n const { clientX, clientY } = e as PointerEvent;\n this._longPressStart = { x: clientX ?? 0, y: clientY ?? 0 };\n this._longPressTimer = setTimeout(() => {\n this._longPressTimer = null;\n this._longPressStart = null;\n this.open = true;\n }, LONG_PRESS_MS);\n };\n private _onPointerMove = (e: Event): void => {\n const start = this._longPressStart;\n if (!this._longPressTimer || !start) return;\n const { clientX, clientY } = e as PointerEvent;\n if (Math.hypot((clientX ?? 0) - start.x, (clientY ?? 0) - start.y) > LONG_PRESS_MOVE_TOLERANCE) this._cancelLongPress();\n };\n private _onPointerEnd = (): void => this._cancelLongPress();\n /**\n * Android fires `contextmenu` on a long press, and its text selection may\n * cancel the pointer right after: during a pending touch long press it opens\n * the tooltip at once instead of showing the native menu.\n */\n private _onContextMenu = (e: Event): void => {\n if (!this._longPressTimer) return;\n e.preventDefault();\n this._cancelLongPress();\n this.open = true;\n };\n private _onWrapperEnter = (e: Event): void => {\n if (isMouse(e)) this._clearTimers();\n };\n private _onWrapperLeave = (e: Event): void => {\n if (isMouse(e)) this._scheduleHide();\n };\n\n get showDelay(): number {\n return this.numberAttr('show-delay', 300);\n }\n\n get hideDelay(): number {\n return this.numberAttr('hide-delay', 100);\n }\n\n protected override wantsFocusTrap(): boolean {\n return false;\n }\n\n protected override onConnect(): void {\n if (!this.id) this.id = nextId('a11y-tooltip');\n trackInputModality();\n this._bindAnchorListeners();\n // Anchor not parsed yet (tooltip authored before it, define script loaded synchronously).\n if (!this._boundAnchorEl) this.afterParse(() => this._bindAnchorListeners());\n }\n\n protected override onDisconnect(): void {\n this._unbindAnchorListeners();\n this._clearTimers();\n }\n\n protected override onAnchorChanged(): void {\n super.onAnchorChanged();\n if (this._connected) this._bindAnchorListeners();\n }\n\n protected override _show(): void {\n super._show();\n const wrapper = this._wrapper;\n if (!wrapper) return;\n wrapper.addEventListener('pointerenter', this._onWrapperEnter);\n wrapper.addEventListener('pointerleave', this._onWrapperLeave);\n }\n\n protected override createWrapper(): HTMLElement {\n const el = super.createWrapper();\n el.classList.add('a11y-tooltip-wrapper');\n el.setAttribute('role', 'tooltip');\n return el;\n }\n\n protected override getContentClass(): string {\n return 'a11y-tooltip-content';\n }\n\n /** Detaches from the anchor entirely (unlike `close()`, which just hides the current tooltip — it can still reopen on the next hover). */\n dispose(): void {\n this._unbindAnchorListeners();\n this._clearTimers();\n this.close();\n }\n\n private _bindAnchorListeners(): void {\n const anchor = this.anchorElement;\n if (anchor === this._boundAnchorEl) return;\n this._unbindAnchorListeners();\n if (!anchor) return;\n for (const [type, listener] of this._anchorListeners()) anchor.addEventListener(type, listener);\n this._setDescribedBy(anchor, true);\n this._boundAnchorEl = anchor;\n }\n\n private _unbindAnchorListeners(): void {\n const anchor = this._boundAnchorEl;\n if (!anchor) return;\n for (const [type, listener] of this._anchorListeners()) anchor.removeEventListener(type, listener);\n this._suppressed = false;\n this._setDescribedBy(anchor, false);\n this._boundAnchorEl = null;\n }\n\n private _anchorListeners(): Array<[string, (e: Event) => void]> {\n return [\n ['pointerenter', this._onPointerEnter],\n ['pointerleave', this._onPointerLeave],\n ['focus', this._onFocus],\n ['blur', this._onBlur],\n ['pointerdown', this._onPointerDown],\n ['pointermove', this._onPointerMove],\n ['pointerup', this._onPointerEnd],\n ['pointercancel', this._onPointerEnd],\n ['contextmenu', this._onContextMenu],\n ];\n }\n\n /** Adds/removes this tooltip's id in the anchor's `aria-describedby` token list, preserving any ids the consumer set. */\n private _setDescribedBy(anchor: HTMLElement, present: boolean): void {\n syncIdRef(anchor, 'aria-describedby', this.id, present);\n }\n\n private _scheduleShow(): void {\n this._clearTimers();\n this._showTimer = setTimeout(() => {\n this.open = true;\n }, this.showDelay);\n }\n\n private _scheduleHide(): void {\n this._clearTimers();\n this._hideTimer = setTimeout(() => {\n this.open = false;\n }, this.hideDelay);\n }\n\n private _clearTimers(): void {\n if (this._showTimer) {\n clearTimeout(this._showTimer);\n this._showTimer = null;\n }\n if (this._hideTimer) {\n clearTimeout(this._hideTimer);\n this._hideTimer = null;\n }\n this._cancelLongPress();\n }\n\n private _cancelLongPress(): void {\n if (this._longPressTimer) {\n clearTimeout(this._longPressTimer);\n this._longPressTimer = null;\n }\n this._longPressStart = null;\n }\n}\n","import { defineElement } from '../../core/define-element.js';\nimport { TooltipElement } from './tooltip.element.js';\n\ndefineElement('a11y-tooltip', TooltipElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-tooltip': TooltipElement;\n }\n}\n\nexport { TooltipElement };\nexport * from '../core/zero-build-exports.js';\n"],"mappings":";;;;;;;;;;;;;;;AAeA,IAAM,YAAY,uBAAO,IAAI,8BAA8B;AAC3D,IAAM,QAAQ;AACd,IAAM,QAAwB,MAAM,SAAS,MAAM,EAAE,MAAM,MAAM,WAAW,MAAM;AAElF,IAAM,gBAAgB,oBAAI,IAAI,CAAC,SAAS,WAAW,OAAO,QAAQ,YAAY,YAAY,IAAI,CAAC;AAWxF,SAAS,qBAA2B;AACzC,MAAI,MAAM,aAAa,OAAO,aAAa,YAAa;AACxD,QAAM,YAAY;AAClB,MAAI;AAAA,IACF;AAAA,IACA,CAAC,MAAM;AACL,UAAI,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,cAAc,IAAI,EAAE,GAAG,EAAG;AACpE,YAAM,OAAO;AAAA,IACf;AAAA,IACA;AAAA,EACF;AACA,MAAI;AAAA,IACF;AAAA,IACA,MAAM;AACJ,YAAM,OAAO;AAAA,IACf;AAAA,IACA;AAAA,EACF;AACF;AAYO,SAAS,gBAAgB,IAAsB;AACpD,MAAI,MAAM,KAAM,QAAO,MAAM,SAAS;AACtC,MAAI;AACF,WAAO,GAAG,QAAQ,gBAAgB;AAAA,EACpC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;AC7DA,IAAM,gBAAgB;AAEtB,IAAM,4BA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