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.
Files changed (81) hide show
  1. package/README.md +44 -6
  2. package/dist/a11y.css +66 -9
  3. package/dist/browser/all.js +17 -17
  4. package/dist/browser/{chunk-JFZTJO7H.js → chunk-2HQKZFJV.js} +2 -2
  5. package/dist/browser/{chunk-AHF64455.js → chunk-2TPJ5MVQ.js} +2 -2
  6. package/dist/browser/{chunk-ORDVOV7E.js → chunk-2X4DBANG.js} +2 -2
  7. package/dist/browser/{chunk-7YZP3GGZ.js → chunk-3AHPI6C5.js} +2 -2
  8. package/dist/browser/{chunk-D6ES5GYW.js → chunk-6BEWDDER.js} +2 -2
  9. package/dist/browser/{chunk-JTFESZPQ.js → chunk-6VUVGT2G.js} +3 -3
  10. package/dist/browser/{chunk-23IEROGQ.js → chunk-B6V4HID2.js} +6 -2
  11. package/dist/browser/chunk-B6V4HID2.js.map +1 -0
  12. package/dist/browser/{chunk-NLRXEMHB.js → chunk-F4KVDZS3.js} +38 -3
  13. package/dist/browser/chunk-F4KVDZS3.js.map +1 -0
  14. package/dist/browser/{chunk-LVKKZ4XP.js → chunk-FJCQ4PVG.js} +2 -2
  15. package/dist/browser/{chunk-6AIK32FI.js → chunk-GYM3EIL3.js} +46 -21
  16. package/dist/browser/chunk-GYM3EIL3.js.map +1 -0
  17. package/dist/browser/{chunk-GJIRWFLA.js → chunk-H25W66MH.js} +42 -1
  18. package/dist/browser/chunk-H25W66MH.js.map +1 -0
  19. package/dist/browser/{chunk-EMXZKQ32.js → chunk-HJUKOWFZ.js} +5 -3
  20. package/dist/browser/chunk-HJUKOWFZ.js.map +1 -0
  21. package/dist/browser/{chunk-6JAOKGVI.js → chunk-IJ6JK2XW.js} +2 -2
  22. package/dist/browser/{chunk-MKDICSZ3.js → chunk-OB2NQV77.js} +3 -3
  23. package/dist/browser/{chunk-O235WSRL.js → chunk-RGO5EYGG.js} +2 -2
  24. package/dist/browser/chunk-WKWX3MMT.js +233 -0
  25. package/dist/browser/chunk-WKWX3MMT.js.map +1 -0
  26. package/dist/browser/{chunk-7GCUNMAO.js → chunk-YYYJ6D77.js} +16 -2
  27. package/dist/browser/chunk-YYYJ6D77.js.map +1 -0
  28. package/dist/browser/overlays/blocking-loader/define.js +3 -3
  29. package/dist/browser/overlays/context-menu/define.js +5 -5
  30. package/dist/browser/overlays/drawer/define.js +4 -4
  31. package/dist/browser/overlays/dropdown/define.js +5 -5
  32. package/dist/browser/overlays/emergency-dialog/define.js +4 -4
  33. package/dist/browser/overlays/floating/define.js +2 -2
  34. package/dist/browser/overlays/modal/define.js +4 -4
  35. package/dist/browser/overlays/notification-banner/define.js +3 -3
  36. package/dist/browser/overlays/popover/define.js +4 -4
  37. package/dist/browser/overlays/snackbar/define.js +3 -3
  38. package/dist/browser/overlays/tooltip/define.js +4 -4
  39. package/dist/core/input-modality.d.ts +21 -0
  40. package/dist/core/input-modality.js +56 -0
  41. package/dist/core/input-modality.js.map +1 -0
  42. package/dist/core/overlay-registry.d.ts +12 -0
  43. package/dist/core/overlay-registry.js +55 -0
  44. package/dist/core/overlay-registry.js.map +1 -1
  45. package/dist/overlays/context-menu/context-menu.element.d.ts +2 -0
  46. package/dist/overlays/context-menu/context-menu.element.js +4 -0
  47. package/dist/overlays/context-menu/context-menu.element.js.map +1 -1
  48. package/dist/overlays/core/a11y-anchored-overlay-element.d.ts +16 -0
  49. package/dist/overlays/core/a11y-anchored-overlay-element.js +37 -1
  50. package/dist/overlays/core/a11y-anchored-overlay-element.js.map +1 -1
  51. package/dist/overlays/core/a11y-passive-overlay-element.d.ts +9 -0
  52. package/dist/overlays/core/a11y-passive-overlay-element.js +14 -0
  53. package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
  54. package/dist/overlays/notification-banner/notification-banner.element.d.ts +7 -1
  55. package/dist/overlays/notification-banner/notification-banner.element.js +9 -1
  56. package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
  57. package/dist/overlays/snackbar/snackbar.element.d.ts +20 -7
  58. package/dist/overlays/snackbar/snackbar.element.js +55 -20
  59. package/dist/overlays/snackbar/snackbar.element.js.map +1 -1
  60. package/dist/overlays/tooltip/tooltip.element.d.ts +32 -8
  61. package/dist/overlays/tooltip/tooltip.element.js +112 -18
  62. package/dist/overlays/tooltip/tooltip.element.js.map +1 -1
  63. package/package.json +1 -1
  64. package/dist/browser/chunk-23IEROGQ.js.map +0 -1
  65. package/dist/browser/chunk-6AIK32FI.js.map +0 -1
  66. package/dist/browser/chunk-7GCUNMAO.js.map +0 -1
  67. package/dist/browser/chunk-EMXZKQ32.js.map +0 -1
  68. package/dist/browser/chunk-GJIRWFLA.js.map +0 -1
  69. package/dist/browser/chunk-LIZBBXUV.js +0 -124
  70. package/dist/browser/chunk-LIZBBXUV.js.map +0 -1
  71. package/dist/browser/chunk-NLRXEMHB.js.map +0 -1
  72. /package/dist/browser/{chunk-JFZTJO7H.js.map → chunk-2HQKZFJV.js.map} +0 -0
  73. /package/dist/browser/{chunk-AHF64455.js.map → chunk-2TPJ5MVQ.js.map} +0 -0
  74. /package/dist/browser/{chunk-ORDVOV7E.js.map → chunk-2X4DBANG.js.map} +0 -0
  75. /package/dist/browser/{chunk-7YZP3GGZ.js.map → chunk-3AHPI6C5.js.map} +0 -0
  76. /package/dist/browser/{chunk-D6ES5GYW.js.map → chunk-6BEWDDER.js.map} +0 -0
  77. /package/dist/browser/{chunk-JTFESZPQ.js.map → chunk-6VUVGT2G.js.map} +0 -0
  78. /package/dist/browser/{chunk-LVKKZ4XP.js.map → chunk-FJCQ4PVG.js.map} +0 -0
  79. /package/dist/browser/{chunk-6JAOKGVI.js.map → chunk-IJ6JK2XW.js.map} +0 -0
  80. /package/dist/browser/{chunk-MKDICSZ3.js.map → chunk-OB2NQV77.js.map} +0 -0
  81. /package/dist/browser/{chunk-O235WSRL.js.map → chunk-RGO5EYGG.js.map} +0 -0
@@ -1,14 +1,27 @@
1
1
  import { syncIdRef } from '../../core/dom-sync.js';
2
2
  import { A11yAnchoredOverlayElement } from '../core/a11y-anchored-overlay-element.js';
3
3
  import { nextId } from '../../core/ids.js';
4
+ import { isKeyboardFocus, trackInputModality } from '../../core/input-modality.js';
5
+ /** How long a touch or pen press must last to show the tooltip. */
6
+ const LONG_PRESS_MS = 500;
7
+ /** How far (px) the pointer may move during that press before it counts as a scroll or drag instead. */
8
+ const LONG_PRESS_MOVE_TOLERANCE = 10;
9
+ function isMouse(e) {
10
+ return e.pointerType === 'mouse';
11
+ }
4
12
  /**
5
13
  * A hover/focus-triggered tooltip anchored to a trigger element. Never
6
- * traps focus — shows after `show-delay`ms of hover/focus, hides after
7
- * `hide-delay`ms once the pointer/focus leaves, debounced so a quick pass
8
- * doesn't flash it. The anchor gets `aria-describedby` pointing at this
9
- * element, so screen readers announce the tooltip text with it. Moving the
10
- * pointer onto the tooltip itself keeps it open, and Escape dismisses it
11
- * (WCAG 1.4.13: hoverable + dismissible).
14
+ * traps focus — shows after `show-delay`ms of mouse hover or keyboard focus
15
+ * (focus after a key press, not after a click or tap; see `isKeyboardFocus()`), hides after `hide-delay`ms once the pointer/focus
16
+ * leaves, debounced so a quick pass doesn't flash it. The anchor gets
17
+ * `aria-describedby` pointing at this element, so screen readers announce
18
+ * the tooltip text with it. Moving the pointer onto the tooltip itself keeps
19
+ * it open, and Escape dismisses it (WCAG 1.4.13: hoverable + dismissible).
20
+ *
21
+ * Pressing the anchor closes it (and a mouse hover won't reopen it until the
22
+ * pointer leaves). A tap neither hovers nor shows a focus ring, so it never
23
+ * opens the tooltip; a touch or pen long press (500ms) does, until the next
24
+ * tap elsewhere, the next press on the anchor, or Escape.
12
25
  *
13
26
  * ```html
14
27
  * <button id="save-btn">Save</button>
@@ -22,8 +35,70 @@ export class TooltipElement extends A11yAnchoredOverlayElement {
22
35
  _showTimer = null;
23
36
  _hideTimer = null;
24
37
  _boundAnchorEl = null;
25
- _boundShow = () => this._scheduleShow();
26
- _boundHide = () => this._scheduleHide();
38
+ _longPressTimer = null;
39
+ _longPressStart = null;
40
+ /** Set by a mouse press on the anchor: hover doesn't reopen the tooltip until the pointer leaves. */
41
+ _suppressed = false;
42
+ _onPointerEnter = (e) => {
43
+ if (isMouse(e) && !this._suppressed)
44
+ this._scheduleShow();
45
+ };
46
+ _onPointerLeave = (e) => {
47
+ if (!isMouse(e))
48
+ return;
49
+ this._suppressed = false;
50
+ this._scheduleHide();
51
+ };
52
+ _onFocus = () => {
53
+ if (this._boundAnchorEl && isKeyboardFocus(this._boundAnchorEl))
54
+ this._scheduleShow();
55
+ };
56
+ _onBlur = () => this._scheduleHide();
57
+ _onPointerDown = (e) => {
58
+ this._clearTimers();
59
+ if (this.open)
60
+ this.open = false;
61
+ if (isMouse(e)) {
62
+ this._suppressed = true;
63
+ return;
64
+ }
65
+ const { clientX, clientY } = e;
66
+ this._longPressStart = { x: clientX ?? 0, y: clientY ?? 0 };
67
+ this._longPressTimer = setTimeout(() => {
68
+ this._longPressTimer = null;
69
+ this._longPressStart = null;
70
+ this.open = true;
71
+ }, LONG_PRESS_MS);
72
+ };
73
+ _onPointerMove = (e) => {
74
+ const start = this._longPressStart;
75
+ if (!this._longPressTimer || !start)
76
+ return;
77
+ const { clientX, clientY } = e;
78
+ if (Math.hypot((clientX ?? 0) - start.x, (clientY ?? 0) - start.y) > LONG_PRESS_MOVE_TOLERANCE)
79
+ this._cancelLongPress();
80
+ };
81
+ _onPointerEnd = () => this._cancelLongPress();
82
+ /**
83
+ * Android fires `contextmenu` on a long press, and its text selection may
84
+ * cancel the pointer right after: during a pending touch long press it opens
85
+ * the tooltip at once instead of showing the native menu.
86
+ */
87
+ _onContextMenu = (e) => {
88
+ if (!this._longPressTimer)
89
+ return;
90
+ e.preventDefault();
91
+ this._cancelLongPress();
92
+ this.open = true;
93
+ };
94
+ _onWrapperEnter = (e) => {
95
+ if (isMouse(e))
96
+ this._clearTimers();
97
+ };
98
+ _onWrapperLeave = (e) => {
99
+ if (isMouse(e))
100
+ this._scheduleHide();
101
+ };
27
102
  get showDelay() {
28
103
  return this.numberAttr('show-delay', 300);
29
104
  }
@@ -36,6 +111,7 @@ export class TooltipElement extends A11yAnchoredOverlayElement {
36
111
  onConnect() {
37
112
  if (!this.id)
38
113
  this.id = nextId('a11y-tooltip');
114
+ trackInputModality();
39
115
  this._bindAnchorListeners();
40
116
  // Anchor not parsed yet (tooltip authored before it, define script loaded synchronously).
41
117
  if (!this._boundAnchorEl)
@@ -55,8 +131,8 @@ export class TooltipElement extends A11yAnchoredOverlayElement {
55
131
  const wrapper = this._wrapper;
56
132
  if (!wrapper)
57
133
  return;
58
- wrapper.addEventListener('mouseenter', () => this._clearTimers());
59
- wrapper.addEventListener('mouseleave', this._boundHide);
134
+ wrapper.addEventListener('pointerenter', this._onWrapperEnter);
135
+ wrapper.addEventListener('pointerleave', this._onWrapperLeave);
60
136
  }
61
137
  createWrapper() {
62
138
  const el = super.createWrapper();
@@ -80,10 +156,8 @@ export class TooltipElement extends A11yAnchoredOverlayElement {
80
156
  this._unbindAnchorListeners();
81
157
  if (!anchor)
82
158
  return;
83
- anchor.addEventListener('mouseenter', this._boundShow);
84
- anchor.addEventListener('focus', this._boundShow);
85
- anchor.addEventListener('mouseleave', this._boundHide);
86
- anchor.addEventListener('blur', this._boundHide);
159
+ for (const [type, listener] of this._anchorListeners())
160
+ anchor.addEventListener(type, listener);
87
161
  this._setDescribedBy(anchor, true);
88
162
  this._boundAnchorEl = anchor;
89
163
  }
@@ -91,13 +165,25 @@ export class TooltipElement extends A11yAnchoredOverlayElement {
91
165
  const anchor = this._boundAnchorEl;
92
166
  if (!anchor)
93
167
  return;
94
- anchor.removeEventListener('mouseenter', this._boundShow);
95
- anchor.removeEventListener('focus', this._boundShow);
96
- anchor.removeEventListener('mouseleave', this._boundHide);
97
- anchor.removeEventListener('blur', this._boundHide);
168
+ for (const [type, listener] of this._anchorListeners())
169
+ anchor.removeEventListener(type, listener);
170
+ this._suppressed = false;
98
171
  this._setDescribedBy(anchor, false);
99
172
  this._boundAnchorEl = null;
100
173
  }
174
+ _anchorListeners() {
175
+ return [
176
+ ['pointerenter', this._onPointerEnter],
177
+ ['pointerleave', this._onPointerLeave],
178
+ ['focus', this._onFocus],
179
+ ['blur', this._onBlur],
180
+ ['pointerdown', this._onPointerDown],
181
+ ['pointermove', this._onPointerMove],
182
+ ['pointerup', this._onPointerEnd],
183
+ ['pointercancel', this._onPointerEnd],
184
+ ['contextmenu', this._onContextMenu],
185
+ ];
186
+ }
101
187
  /** Adds/removes this tooltip's id in the anchor's `aria-describedby` token list, preserving any ids the consumer set. */
102
188
  _setDescribedBy(anchor, present) {
103
189
  syncIdRef(anchor, 'aria-describedby', this.id, present);
@@ -123,6 +209,14 @@ export class TooltipElement extends A11yAnchoredOverlayElement {
123
209
  clearTimeout(this._hideTimer);
124
210
  this._hideTimer = null;
125
211
  }
212
+ this._cancelLongPress();
213
+ }
214
+ _cancelLongPress() {
215
+ if (this._longPressTimer) {
216
+ clearTimeout(this._longPressTimer);
217
+ this._longPressTimer = null;
218
+ }
219
+ this._longPressStart = null;
126
220
  }
127
221
  }
128
222
  //# sourceMappingURL=tooltip.element.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tooltip.element.js","sourceRoot":"","sources":["../../../src/overlays/tooltip/tooltip.element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0CAA0C,CAAC;AACtF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,cAAe,SAAQ,0BAA0B;IAC5D,MAAM,KAAc,kBAAkB;QACpC,OAAO,CAAC,GAAG,KAAK,CAAC,kBAAkB,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;IACnE,CAAC;IAEO,UAAU,GAAyC,IAAI,CAAC;IACxD,UAAU,GAAyC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AM,EAAE,kBAAkB,EAAE,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACnB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAEO,aAAa;QACnB,IAAI,CAAC,YAAY,EAAE,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,GAAG,EAAE;YAChC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QACpB,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACrB,CAAC;IAEO,YAAY;QAClB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;QACD,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;QACD,IAAI,CAAC,gBAAgB,EAAE,CAAC;IAC1B,CAAC;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YACzB,YAAY,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YACnC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC9B,CAAC;QACD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;IAC9B,CAAC;CACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "a11y-elements",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Framework-agnostic accessibility Custom Elements (Web Components) — behavior, not a themed UI kit.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/overlays/context-menu/context-menu.element.ts","../../src/overlays/context-menu/define.ts"],"sourcesContent":["import { A11yMenuOverlayElement } from '../core/a11y-menu-overlay-element.js';\nimport { doc } from '../../core/safe-dom.js';\n\n/**\n * A menu that opens at the mouse position on right-click (`contextmenu`) of\n * a trigger element, replacing the browser's native context menu there.\n *\n * ```html\n * <div id=\"canvas\">Right-click me</div>\n * <a11y-context-menu trigger=\"canvas\">\n * <div role=\"menuitem\">Copy</div>\n * <div role=\"menuitem\">Paste</div>\n * </a11y-context-menu>\n * ```\n */\nexport class ContextMenuElement extends A11yMenuOverlayElement {\n static override get observedAttributes(): string[] {\n return [...super.observedAttributes, 'trigger'];\n }\n\n private _triggerEl: HTMLElement | null = null;\n private _boundTriggerEl: HTMLElement | null = null;\n private _boundContextMenu = (e: MouseEvent): void => {\n e.preventDefault();\n this.setAnchorPoint(e.clientX, e.clientY);\n // Re-right-clicking while already open repositions in place rather than\n // no-op'ing (the `open` attribute wouldn't change, so attributeChangedCallback\n // wouldn't fire) — _show() itself already guards on an existing wrapper.\n if (this.open) this._show();\n else this.open = true;\n };\n\n /** The element whose `contextmenu` event opens this menu: an explicit `.triggerElement` property, or the `trigger=\"<id>\"` attribute. */\n get triggerElement(): HTMLElement | null {\n if (this._triggerEl) return this._triggerEl;\n const id = this.getAttribute('trigger');\n return id ? doc.getElementById(id) : null;\n }\n\n set triggerElement(el: HTMLElement | null) {\n this._triggerEl = el;\n this._bindTrigger();\n }\n\n protected override onConnect(): void {\n this._bindTrigger();\n // Trigger not parsed yet (menu authored before it, define script loaded synchronously).\n if (!this._boundTriggerEl) this.afterParse(() => this._bindTrigger());\n }\n\n protected override onDisconnect(): void {\n this._unbindTrigger();\n }\n\n protected override onAttributeChanged(name: string): void {\n super.onAttributeChanged(name);\n if (name === 'trigger') this._bindTrigger();\n }\n\n protected override createWrapper(): HTMLElement {\n const el = super.createWrapper();\n el.classList.add('a11y-context-menu-wrapper');\n return el;\n }\n\n protected override getContentClass(): string {\n return 'a11y-context-menu-content';\n }\n\n /** Detaches from the trigger entirely (unlike `close()`, which just hides the current menu — it can still reopen on the next right-click). */\n dispose(): void {\n this._unbindTrigger();\n this.close();\n }\n\n private _bindTrigger(): void {\n const trigger = this.triggerElement;\n if (this._boundTriggerEl === trigger) return;\n this._unbindTrigger();\n if (!trigger) return;\n trigger.addEventListener('contextmenu', this._boundContextMenu);\n this._boundTriggerEl = trigger;\n }\n\n private _unbindTrigger(): void {\n if (!this._boundTriggerEl) return;\n this._boundTriggerEl.removeEventListener('contextmenu', this._boundContextMenu);\n this._boundTriggerEl = null;\n }\n}\n","import { defineElement } from '../../core/define-element.js';\nimport { ContextMenuElement } from './context-menu.element.js';\n\ndefineElement('a11y-context-menu', ContextMenuElement);\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-context-menu': ContextMenuElement;\n }\n}\n\nexport { ContextMenuElement };\nexport * from '../core/zero-build-exports.js';\n"],"mappings":";;;;;;;;;AAeO,IAAM,qBAAN,cAAiC,uBAAuB;AAAA,EAC7D,WAAoB,qBAA+B;AACjD,WAAO,CAAC,GAAG,MAAM,oBAAoB,SAAS;AAAA,EAChD;AAAA,EAEQ,aAAiC;AAAA,EACjC,kBAAsC;AAAA,EACtC,oBAAoB,CAAC,MAAwB;AACnD,MAAE,eAAe;AACjB,SAAK,eAAe,EAAE,SAAS,EAAE,OAAO;AAIxC,QAAI,KAAK,KAAM,MAAK,MAAM;AAAA,QACrB,MAAK,OAAO;AAAA,EACnB;AAAA;AAAA,EAGA,IAAI,iBAAqC;AACvC,QAAI,KAAK,WAAY,QAAO,KAAK;AACjC,UAAM,KAAK,KAAK,aAAa,SAAS;AACtC,WAAO,KAAK,IAAI,eAAe,EAAE,IAAI;AAAA,EACvC;AAAA,EAEA,IAAI,eAAe,IAAwB;AACzC,SAAK,aAAa;AAClB,SAAK,aAAa;AAAA,EACpB;AAAA,EAEmB,YAAkB;AACnC,SAAK,aAAa;AAElB,QAAI,CAAC,KAAK,gBAAiB,MAAK,WAAW,MAAM,KAAK,aAAa,CAAC;AAAA,EACtE;AAAA,EAEmB,eAAqB;AACtC,SAAK,eAAe;AAAA,EACtB;AAAA,EAEmB,mBAAmB,MAAoB;AACxD,UAAM,mBAAmB,IAAI;AAC7B,QAAI,SAAS,UAAW,MAAK,aAAa;AAAA,EAC5C;AAAA,EAEmB,gBAA6B;AAC9C,UAAM,KAAK,MAAM,cAAc;AAC/B,OAAG,UAAU,IAAI,2BAA2B;AAC5C,WAAO;AAAA,EACT;AAAA,EAEmB,kBAA0B;AAC3C,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,UAAgB;AACd,SAAK,eAAe;AACpB,SAAK,MAAM;AAAA,EACb;AAAA,EAEQ,eAAqB;AAC3B,UAAM,UAAU,KAAK;AACrB,QAAI,KAAK,oBAAoB,QAAS;AACtC,SAAK,eAAe;AACpB,QAAI,CAAC,QAAS;AACd,YAAQ,iBAAiB,eAAe,KAAK,iBAAiB;AAC9D,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAEQ,iBAAuB;AAC7B,QAAI,CAAC,KAAK,gBAAiB;AAC3B,SAAK,gBAAgB,oBAAoB,eAAe,KAAK,iBAAiB;AAC9E,SAAK,kBAAkB;AAAA,EACzB;AACF;;;ACtFA,cAAc,qBAAqB,kBAAkB;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/overlays/snackbar/snackbar.element.ts","../../src/overlays/snackbar/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 SnackbarType = 'info' | 'success' | 'error' | 'warning';\n\nexport interface NotifyOptions {\n type?: SnackbarType;\n position?: 'top' | 'bottom';\n duration?: number;\n actionText?: string;\n onAction?: () => 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}\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 * 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 })`.\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 private _bottomContainer!: HTMLElement;\n private _topContainer!: HTMLElement;\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 if (!this._bottomContainer) {\n this._bottomContainer = doc.createElement('div');\n this._bottomContainer.className = 'a11y-snackbar-region__bottom';\n this._topContainer = doc.createElement('div');\n this._topContainer.className = 'a11y-snackbar-region__top';\n this.append(this._bottomContainer, this._topContainer);\n }\n this._drainQueue();\n }\n\n /** Removes every showing toast and drops queued ones, without calling `onAction`. */\n dismissAll(): void {\n this._queue = [];\n this._cancelAutoDismissTimers();\n this.querySelectorAll('.a11y-snackbar').forEach((toast) => toast.remove());\n this._activeCount = 0;\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 });\n }\n\n protected _showItem(item: SnackbarItem): void {\n const type = item.type ?? 'info';\n const position = item.position ?? 'bottom';\n const duration = item.duration ?? (item.actionText ? 10_000 : 3000);\n const container = position === 'bottom' ? this._bottomContainer : this._topContainer;\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 cancelAutoDismiss = this._autoDismiss(el, duration, () => this._onItemDismissed());\n\n const dismiss = (): void => {\n cancelAutoDismiss();\n el.remove();\n this._onItemDismissed();\n };\n\n el.querySelector<HTMLButtonElement>('.a11y-snackbar__action')?.addEventListener('click', () => {\n dismiss();\n item.onAction?.();\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: NotifyOptions = {}): void {\n getRegion().notify(message, options);\n}\n\nexport * from '../core/zero-build-exports.js';\n"],"mappings":";;;;;;;;;;;;;AAsCO,IAAM,kBAAN,cAA8B,0BAAwC;AAAA,EACnE;AAAA,EACA;AAAA,EAER,WAAoB,qBAA+B;AACjD,WAAO,CAAC,GAAG,MAAM,oBAAoB,eAAe;AAAA,EACtD;AAAA;AAAA,EAGA,IAAI,eAAuB;AACzB,WAAO,KAAK,WAAW,iBAAiB,UAAU,SAAS,CAAC;AAAA,EAC9D;AAAA,EAES,yBAAyB,MAAc,UAAyB,UAA+B;AACtG,UAAM,yBAAyB,MAAM,UAAU,QAAQ;AACvD,QAAI,SAAS,mBAAmB,aAAa,SAAU,MAAK,uBAAuB;AAAA,EACrF;AAAA,EAEmB,kBAAwB;AACzC,SAAK,uBAAuB;AAAA,EAC9B;AAAA,EAEQ,yBAA+B;AACrC,eAAW,OAAO,KAAK,iBAAiB,uBAAuB,EAAG,KAAI,aAAa,cAAc,KAAK,YAAY;AAAA,EACpH;AAAA,EAES,oBAA0B;AACjC,UAAM,kBAAkB;AACxB,SAAK,UAAU,IAAI,sBAAsB;AACzC,QAAI,CAAC,KAAK,kBAAkB;AAC1B,WAAK,mBAAmB,IAAI,cA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AwB,GAAG,KAAK,UAAU,CAAC;AAC/G,OAAG,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,OAAO,wBAAwB,cAAc,KAAK,aAAa,GAAG,MAAQ,CAAC;AAEnH,cAAU,YAAY,EAAE;AAExB,UAAM,oBAAoB,KAAK,aAAa,IAAI,UAAU,MAAM,KAAK,iBAAiB,CAAC;AAEvF,UAAM,UAAU,MAAY;AAC1B,wBAAkB;AAClB,SAAG,OAAO;AACV,WAAK,iBAAiB;AAAA,IACxB;AAEA,OAAG,cAAiC,wBAAwB,GAAG,iBAAiB,SAAS,MAAM;AAC7F,cAAQ;AACR,WAAK,WAAW;AAAA,IAClB,CAAC;AACD,OAAG,cAAiC,uBAAuB,GAAG,iBAAiB,SAAS,OAAO;AAAA,EACjG;AACF;;;AC/HA,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":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/overlays/core/a11y-passive-overlay-element.ts"],"sourcesContent":["import { A11yElement } from '../../core/a11y-element.js';\nimport { forgetPortalOrigin, recordPortalOrigin } from '../../core/overlay-registry.js';\nimport type { Content } from '../../core/dom.js';\nimport { doc } from '../../core/safe-dom.js';\n\nconst DEFAULT_MAX_STACK = 3;\n/** setTimeout's limit: longer (or `Infinity`) delays overflow to 0 and fire at once. */\nconst MAX_TIMEOUT_MS = 2_147_483_647;\n\nexport type PassiveOverlayPosition = 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport interface PassiveOverlayItem {\n /** Text, nodes, or markup from `raw()`/`trustedRaw()`. */\n message: Content;\n position?: PassiveOverlayPosition;\n duration?: number;\n actionText?: string;\n onAction?: () => void;\n}\n\n/**\n * Base for \"region\" overlays (snackbar, notification-banner) that don't fit\n * the single open/close model `A11yOverlayElement` covers — a passive region\n * is a persistent live-region container the consumer places once in their\n * HTML, and items are shown/dismissed inside it continuously via `enqueue()`\n * (bounded-concurrency FIFO: at most `max-stack` items — default 3 — shown\n * at once, the rest queued), not toggled as a whole.\n *\n * Items only show while the region is in the document: one enqueued while\n * it's detached waits in the queue. When the region is removed (and not\n * just moved: the check runs a microtask later), every pending auto-dismiss\n * timer is cancelled and `_onRemoved()` runs, so nothing keeps firing for a\n * page that's gone.\n */\nexport abstract class A11yPassiveOverlayElement<TItem extends PassiveOverlayItem = PassiveOverlayItem> extends A11yElement {\n static get observedAttributes(): string[] {\n return ['max-stack'];\n }\n\n protected _queue: TItem[] = [];\n protected _activeCount = 0;\n /** Cancel functions of every running `_autoDismiss()` countdown. */\n private _autoDismissCancels = new Set<() => void>();\n\n override connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n const origin = this.parentNode;\n if (origin !== doc.body) {\n doc.body.appendChild(this);\n // Recorded only now: that move ran a nested disconnect, which forgets the origin.\n if (origin instanceof Element) recordPortalOrigin(this, origin);\n }\n this.setAttribute('aria-live', 'polite');\n this.setAttribute('aria-atomic', 'false');\n this.setAttribute('aria-relevant', 'additions removals');\n this.classList.add('a11y-passive-overlay-region');\n }\n\n override disconnectedCallback(): void {\n forgetPortalOrigin(this);\n super.disconnectedCallback();\n // A move (including our own portal to <body> above) disconnects and\n // reconnects synchronously; only tear down if we're still out afterwards.\n queueMicrotask(() => {\n if (!this.isConnected) this._onRemoved();\n });\n }\n\n /**\n * Runs once the region has been removed from the document (not just moved).\n * The base cancels every pending auto-dismiss timer; subclasses may also\n * drop their items.\n */\n protected _onRemoved(): void {\n this._cancelAutoDismissTimers();\n }\n\n /** Stops every pending `_autoDismiss()` countdown without dismissing anything. */\n protected _cancelAutoDismissTimers(): void {\n for (const cancel of Array.from(this._autoDismissCancels)) cancel();\n }\n\n /** Never re-renders (that would wipe the item containers) — a raised `max-stack` just shows queued items. */\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue) return;\n if (name === 'max-stack') this._drainQueue();\n }\n\n /** How many items may show at once (`max-stack` attribute, default 3); the rest wait in a FIFO queue. */\n get maxStack(): number {\n return Math.max(1, Math.floor(this.numberAttr('max-stack', DEFAULT_MAX_STACK)));\n }\n\n set maxStack(n: number) {\n this.setAttribute('max-stack', String(Math.max(1, n)));\n }\n\n /** Alias for `el.maxStack = n`. */\n setMaxStack(n: number): void {\n this.maxStack = n;\n }\n\n protected enqueue(item: TItem): void {\n this._queue.push(item);\n this._drainQueue();\n }\n\n protected _onItemDismissed(): void {\n this._activeCount--;\n this._drainQueue();\n }\n\n /** Shows queued items up to `maxStack` — only while connected (subclasses call this once their containers exist). */\n protected _drainQueue(): void {\n if (!this.isConnected) return;\n while (this._queue.length > 0 && this._activeCount < this.maxStack) {\n const next = this._queue.shift()!;\n this._activeCount++;\n this._showItem(next);\n }\n }\n\n protected abstract _showItem(item: TItem): void;\n\n /**\n * Removes `element` and calls `onDone` after `duration`ms of it being\n * *unattended*: the countdown pauses while the pointer is over the item or\n * focus is inside it (e.g. on its action button), and resumes with the\n * remaining time once both leave (WCAG 2.2.1 — a user reading or reaching\n * for a toast mustn't have it vanish under them). Returns a function that\n * cancels the auto-dismiss entirely.\n */\n protected _autoDismiss(element: HTMLElement, duration: number, onDone: () => void): () => void {\n let remaining = duration;\n let startedAt = 0;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let hovered = false;\n let focused = false;\n\n const run = (): void => {\n if (remaining > MAX_TIMEOUT_MS) return; // `Infinity` or longer than a timer can wait: never auto-dismiss\n startedAt = Date.now();\n timer = setTimeout(() => {\n cancel();\n element.remove();\n onDone();\n }, remaining);\n };\n const pause = (): void => {\n if (!timer) return;\n clearTimeout(timer);\n timer = null;\n remaining = Math.max(0, remaining - (Date.now() - startedAt));\n };\n const refresh = (): void => {\n if (hovered || focused) pause();\n else if (!timer) run();\n };\n const onEnter = (): void => { hovered = true; refresh(); };\n const onLeave = (): void => { hovered = false; refresh(); };\n const onFocusIn = (): void => { focused = true; refresh(); };\n const onFocusOut = (e: FocusEvent): void => {\n if (element.contains(e.relatedTarget as Node | null)) return;\n focused = false;\n refresh();\n };\n const cancel = (): void => {\n this._autoDismissCancels.delete(cancel);\n if (timer) clearTimeout(timer);\n timer = null;\n element.removeEventListener('mouseenter', onEnter);\n element.removeEventListener('mouseleave', onLeave);\n element.removeEventListener('focusin', onFocusIn);\n element.removeEventListener('focusout', onFocusOut);\n };\n\n element.addEventListener('mouseenter', onEnter);\n element.addEventListener('mouseleave', onLeave);\n element.addEventListener('focusin', onFocusIn);\n element.addEventListener('focusout', onFocusOut);\n this._autoDismissCancels.add(cancel);\n run();\n return cancel;\n }\n\n /** Unused — items are appended/removed directly by `_showItem`, never generated from a template. */\n protected override render(): null {\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;AAKA,IAAM,oBAAoB;AAE1B,IAAM,iBAAiB;AA2BhB,IAAe,4BAAf,cAAwG,YAAY;AAAA,EACzH,WAAW,qBAA+B;AACxC,WAAO,CAAC,WAAW;AAAA,EACrB;AAAA,EAEU,SAAkB,CAAC;AAAA,EACnB,eAAe;AAAA;AAAA,EAEjB,sBAAsB,oBAAI,IAAgB;AAAA,EAEzC,oBAA0B;AACjC,SAAK,aAAa;AAClB,SAAK,aAAa;AAClB,UAAM,SAAS,KAAK;AACpB,QAAI,WAAW,IAAI,MAAM;AACvB,UAAI,KAAK,YAAY,IAAI;AAEzB,UAAI,kBAAkB,QAAS,oBAAmB,MAAM,MAAM;AAAA,IAChE;AACA,SAAK,aAAa,aAAa,QAAQ;AACvC,SAAK,aAAa,eAAe,OAAO;AACxC,SAAK,aAAa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C,SAAK,oBAAoB,IAAI,MAAM;AACnC,QAAI;AACJ,WAAO;AAAA,EACT;AAAA;AAAA,EAGmB,SAAe;AAChC,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +0,0 @@
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 interface NotificationBannerOptions {\n type?: NotificationBannerType;\n position?: 'top' | 'bottom';\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 */\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 position = item.position ?? '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":";;;;;;;;;;;;;AAwCO,IAAM,4BAAN,cAAwC,0BAAkD;AAAA,EACvF;AAAA,EACA;AAAA,EACA,UAA4D,CAAC;AAAA,EAErE,WAAoB,qBAA+B;AACjD,WAAO,CAAC,GAAG,MAAM,oBAAoB,eAAe;AAAA,EACtD;AAAA;AAAA,EAGA,IAAI,eAAuB;AACzB,WAAO,KAAK,WAAW,iBAAiB,UAAU,SAAS,CAAC;AAAA,EAC9D;AAAA,EAES,yBAAyB,MAAc,UAAyB,UAA+B;AACtG,UAAM,yBAAyB,MAAM,UAAU,QAAQ;AACvD,QAAI,SAAS,mBAAmB,aAAa,SAAU,MAAK,uBAAuB;AAAA,EACrF;AAAA,EAEmB,kBAAwB;AACzC,SAAK,uBAAuB;AAAA,EAC9B;AAAA,EAEQ,yBAA+B;AACrC,eAAW,EAAE,GAAG,KAAK,KAAK,SAAS;AACjC,SAAG,cAAc,kCAAkC,GAAG,aAAa,cAAc,KAAK,YAAY;AAAA,IACpG;AAAA,EACF;AAAA,EAES,oBAA0B;AACjC,UAAM,kBAAkB;AACxB,SAAK,UAAU,IAAI,iCAAiC;AACpD,QAAI,CAAC,KAAK,eAAe;AACvB,WAAK,gBAAgB,IAAI,cAAc,KAAK;AAC5C,WAAK,cAAc,YAAY;AAC/B,WAAK,mBAAmB,IAAI,cAAc,KAAK;AAC/C,WAAK,iBAAiB,YAAY;AAClC,WAAK,OAAO,KAAK,eAAe,KAAK,gBAAgB;AAAA,IACvD;AACA,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,KAAK,SAAkB,UAAqC,CAAC,GAAS;AACpE,QAAI,QAAQ,SAAU,MAAK,YAAY,QAAQ,QAAQ;AACvD,SAAK,QAAQ;AAAA,MACX;AAAA,MACA,MAAM,QAAQ;AAAA,MACd,UAAU,QAAQ;AAAA,MAClB,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K,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;;;ACjJA,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":[]}
@@ -1 +0,0 @@
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/** 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\nfunction syncInert(): void {\n const top = state.inertLayers[state.inertLayers.length - 1];\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\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;AA6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AAI,GAAG,aAAa,OAAO,EAAG;AAC9B,OAAG,aAAa,SAAS,EAAE;AAC3B,UAAM,aAAa,IAAI,EAAE;AAAA,EAC3B;AACF;AAEA,IAAM,kBAAkB;AACxB,IAAM,eAAe;AAed,SAAS,aAAmB;AACjC,MAAI,MAAM,kBAAkB,EAAG;AAC/B,QAAM,OAAO,IAAI;AACjB,QAAM,cAAc,KAAK;AACzB,OAAK,UAAU,IAAI,eAAe;AAClC,MAAI,KAAK,cAAc,YAAa,MAAK,UAAU,IAAI,YAAY;AACrE;AAEO,SAAS,eAAqB;AACnC,MAAI,MAAM,gBAAgB,EAAG;AAC7B,MAAI,EAAE,MAAM,gBAAgB,EAAG,KAAI,gBAAgB,UAAU,OAAO,iBAAiB,YAAY;AACnG;AASA,SAAS,iBAAiB,MAAc,MAAc,OAAmC;AACvF,QAAM,EAAE,SAAS,OAAO,IAAI;AAC5B,QAAM,SAAiC,EAAE,KAAK;AAC9C,MAAI,QAAS,QAAO,UAAU;AAC9B,MAAI,OAAQ,QAAO,SAAS;AAC5B,QAAM,SAAS,SAAS,cAAc,UAAU;AAChD,SAAO,OAAO,cAAc,IAAI,YAAoC,MAAM,EAAE,SAAS,MAAM,OAAO,CAAC,CAAC;AACtG;AAEO,SAAS,gBAAgB,MAAc,QAA2C,CAAC,GAAY;AACpG,SAAO,iBAAiB,oBAAoB,MAAM,KAAK;AACzD;AAEO,SAAS,iBAAiB,MAAc,QAA2B,CAAC,GAAY;AACrF,SAAO,iBAAiB,qBAAqB,MAAM,KAAK;AAC1D;","names":[]}
@@ -1,124 +0,0 @@
1
- import {
2
- A11yAnchoredOverlayElement
3
- } from "./chunk-NLRXEMHB.js";
4
- import {
5
- nextId
6
- } from "./chunk-Q4TMA3P7.js";
7
- import {
8
- syncIdRef
9
- } from "./chunk-FAEA66RR.js";
10
- import {
11
- defineElement
12
- } from "./chunk-ED3UMYMY.js";
13
-
14
- // src/overlays/tooltip/tooltip.element.ts
15
- var TooltipElement = class extends A11yAnchoredOverlayElement {
16
- static get observedAttributes() {
17
- return [...super.observedAttributes, "show-delay", "hide-delay"];
18
- }
19
- _showTimer = null;
20
- _hideTimer = null;
21
- _boundAnchorEl = null;
22
- _boundShow = () => this._scheduleShow();
23
- _boundHide = () => this._scheduleHide();
24
- get showDelay() {
25
- return this.numberAttr("show-delay", 300);
26
- }
27
- get hideDelay() {
28
- return this.numberAttr("hide-delay", 100);
29
- }
30
- wantsFocusTrap() {
31
- return false;
32
- }
33
- onConnect() {
34
- if (!this.id) this.id = nextId("a11y-tooltip");
35
- this._bindAnchorListeners();
36
- if (!this._boundAnchorEl) this.afterParse(() => this._bindAnchorListeners());
37
- }
38
- onDisconnect() {
39
- this._unbindAnchorListeners();
40
- this._clearTimers();
41
- }
42
- onAnchorChanged() {
43
- super.onAnchorChanged();
44
- if (this._connected) this._bindAnchorListeners();
45
- }
46
- _show() {
47
- super._show();
48
- const wrapper = this._wrapper;
49
- if (!wrapper) return;
50
- wrapper.addEventListener("mouseenter", () => this._clearTimers());
51
- wrapper.addEventListener("mouseleave", this._boundHide);
52
- }
53
- createWrapper() {
54
- const el = super.createWrapper();
55
- el.classList.add("a11y-tooltip-wrapper");
56
- el.setAttribute("role", "tooltip");
57
- return el;
58
- }
59
- getContentClass() {
60
- return "a11y-tooltip-content";
61
- }
62
- /** Detaches from the anchor entirely (unlike `close()`, which just hides the current tooltip — it can still reopen on the next hover). */
63
- dispose() {
64
- this._unbindAnchorListeners();
65
- this._clearTimers();
66
- this.close();
67
- }
68
- _bindAnchorListeners() {
69
- const anchor = this.anchorElement;
70
- if (anchor === this._boundAnchorEl) return;
71
- this._unbindAnchorListeners();
72
- if (!anchor) return;
73
- anchor.addEventListener("mouseenter", this._boundShow);
74
- anchor.addEventListener("focus", this._boundShow);
75
- anchor.addEventListener("mouseleave", this._boundHide);
76
- anchor.addEventListener("blur", this._boundHide);
77
- this._setDescribedBy(anchor, true);
78
- this._boundAnchorEl = anchor;
79
- }
80
- _unbindAnchorListeners() {
81
- const anchor = this._boundAnchorEl;
82
- if (!anchor) return;
83
- anchor.removeEventListener("mouseenter", this._boundShow);
84
- anchor.removeEventListener("focus", this._boundShow);
85
- anchor.removeEventListener("mouseleave", this._boundHide);
86
- anchor.removeEventListener("blur", this._boundHide);
87
- this._setDescribedBy(anchor, false);
88
- this._boundAnchorEl = null;
89
- }
90
- /** Adds/removes this tooltip's id in the anchor's `aria-describedby` token list, preserving any ids the consumer set. */
91
- _setDescribedBy(anchor, present) {
92
- syncIdRef(anchor, "aria-describedby", this.id, present);
93
- }
94
- _scheduleShow() {
95
- this._clearTimers();
96
- this._showTimer = setTimeout(() => {
97
- this.open = true;
98
- }, this.showDelay);
99
- }
100
- _scheduleHide() {
101
- this._clearTimers();
102
- this._hideTimer = setTimeout(() => {
103
- this.open = false;
104
- }, this.hideDelay);
105
- }
106
- _clearTimers() {
107
- if (this._showTimer) {
108
- clearTimeout(this._showTimer);
109
- this._showTimer = null;
110
- }
111
- if (this._hideTimer) {
112
- clearTimeout(this._hideTimer);
113
- this._hideTimer = null;
114
- }
115
- }
116
- };
117
-
118
- // src/overlays/tooltip/define.ts
119
- defineElement("a11y-tooltip", TooltipElement);
120
-
121
- export {
122
- TooltipElement
123
- };
124
- //# sourceMappingURL=chunk-LIZBBXUV.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/overlays/tooltip/tooltip.element.ts","../../src/overlays/tooltip/define.ts"],"sourcesContent":["import { syncIdRef } from '../../core/dom-sync.js';\nimport { A11yAnchoredOverlayElement } from '../core/a11y-anchored-overlay-element.js';\nimport { nextId } from '../../core/ids.js';\n\n/**\n * A hover/focus-triggered tooltip anchored to a trigger element. Never\n * traps focus — shows after `show-delay`ms of hover/focus, hides after\n * `hide-delay`ms once the pointer/focus leaves, debounced so a quick pass\n * doesn't flash it. The anchor gets `aria-describedby` pointing at this\n * element, so screen readers announce the tooltip text with it. Moving the\n * pointer onto the tooltip itself keeps it open, and Escape dismisses it\n * (WCAG 1.4.13: hoverable + dismissible).\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 _boundShow = (): void => this._scheduleShow();\n private _boundHide = (): void => this._scheduleHide();\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 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('mouseenter', () => this._clearTimers());\n wrapper.addEventListener('mouseleave', this._boundHide);\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 anchor.addEventListener('mouseenter', this._boundShow);\n anchor.addEventListener('focus', this._boundShow);\n anchor.addEventListener('mouseleave', this._boundHide);\n anchor.addEventListener('blur', this._boundHide);\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 anchor.removeEventListener('mouseenter', this._boundShow);\n anchor.removeEventListener('focus', this._boundShow);\n anchor.removeEventListener('mouseleave', this._boundHide);\n anchor.removeEventListener('blur', this._boundHide);\n this._setDescribedBy(anchor, false);\n this._boundAnchorEl = null;\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 }\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":";;;;;;;;;;;;;;AAkBO,IAAM,iBAAN,cAA6B,2BAA2B;AAAA,EAC7D,WAAoB,qBAA+B;AACjD,WAAO,CAAC,GAAG,MAAM,oBAAoB,cAAc,YAAY;AAAA,EACjE;AAAA,EAEQ,aAAmD;AAAA,EACnD,aAAmD;AAAA,EACnD,iBAAqC;AAAA,EACrC,aAAa,MAAY,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iBAAiB,SAAS,KAAK,UAAU;AAChD,WAAO,iBAAiB,cAAc,KAAK,UAAU;AACrD,WAAO,iBAAiB,QAAQ,KAAK,UAAU;AAC/C,SAAK,gBAAgB,QAAQ,IAAI;AACjC,SAAK,iBAAiB;AAAA,EACxB;AAAA,EAEQ,yBAA+B;AACrC,UAAM,SAAS,KAAK;AACpB,QAAI,CAAC,OAAQ;AACb,WAAO,oBAAoB,cAAc,KAAK,UAAU;AACxD,WAAO,oBAAoB,SAAS,KAAK,UAAU;AACnD,WAAO,oBAAoB,cAAc,KAAK,UAAU;AACxD,WAAO,oBAAoB,QAAQ,KAAK,UAAU;AAClD,SAAK,gBAAgB,QAAQ,KAAK;AAClC,SAAK,iBAAiB;AAAA,EACxB;AAAA;AAAA,EAGQ,gBAAgB,QAAqB,SAAwB;AACnE,cAAU,QAAQ,oBAAoB,KAAK,IAAI,OAAO;AAAA,EACxD;AAAA,EAEQ,gBAAsB;AAC5B,SAAK,aAAa;AAClB,SAAK,aAAa,WAAW,MAAM;AACjC,WAAK,OAAO;AAAA,IACd,GAAG,KAAK,SAAS;AAAA,EACnB;AAAA,EAEQ,gBAAsB;AAC5B,SAAK,aAAa;AAClB,SAAK,aAAa,WAAW,MAAM;AACjC,WAAK,OAAO;AAAA,IACd,GAAG,KAAK,SAAS;AAAA,EACnB;AAAA,EAEQ,eAAqB;AAC3B,QAAI,KAAK,YAAY;AACnB,mBAAa,KAAK,UAAU;AAC5B,WAAK,aAAa;AAAA,IACpB;AACA,QAAI,KAAK,YAAY;AACnB,mBAAa,KAAK,UAAU;AAC5B,WAAK,aAAa;AAAA,IACpB;AAAA,EACF;AACF;;;ACtIA,cAAc,gBAAgB,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/overlays/core/a11y-anchored-overlay-element.ts"],"sourcesContent":["import { A11yOverlayElement } from '../../core/a11y-overlay-element.js';\nimport { hasOverlayOpenedAfter, isInsideOverlayOpenedAfter } from '../../core/overlay-registry.js';\nimport { FocusTrapHelper, type IFocusTrapOptions } from '../../core/focus-trap.js';\nimport { whenTransitionDone } from '../../core/transition.js';\nimport { doc } from '../../core/safe-dom.js';\n\nexport type AnchoredSide = 'top' | 'bottom' | 'left' | 'right';\nexport type AnchoredAlign = 'start' | 'end';\nexport type AnchoredPlacement = AnchoredSide | `${AnchoredSide}-${AnchoredAlign}`;\n\n/**\n * Base for overlays positioned relative to an anchor element or point\n * (popover, tooltip, dropdown, and — via `A11yMenuOverlayElement` —\n * dropdown-menu/context-menu). `this` (the custom element, holding the\n * consumer's own light-DOM content) is moved into a `wrapper` div appended\n * to `document.body` on show, and moved back out before the wrapper is torn\n * down on hide — the same portal dance `A11yOverlayElement` documents,\n * scoped to this overlay family's extra positioning chrome.\n *\n * The flip/clamp positioning math and the deferred-outside-click dismissal\n * are ported near-verbatim from the old framework version — both were\n * already framework-free hand-rolled DOM/geometry code with nothing to do\n * with the old base classes.\n */\nexport abstract class A11yAnchoredOverlayElement extends A11yOverlayElement {\n static override get observedAttributes(): string[] {\n return ['open', 'anchor', 'placement', 'offset'];\n }\n\n protected _wrapper: HTMLElement | null = null;\n private _anchorEl: HTMLElement | null = null;\n private _anchorRect: DOMRect | null = null;\n private _focusTrap: FocusTrapHelper | null = null;\n private _boundOutsideClick: ((e: MouseEvent) => void) | null = null;\n private _outsideClickTimer: ReturnType<typeof setTimeout> | null = null;\n private _boundKeyDown: ((e: KeyboardEvent) => void) | null = null;\n private _boundReposition: (() => void) | null = null;\n private _resizeObserver: ResizeObserver | null = null;\n private _pendingHide: (() => void) | null = null;\n private _cancelHideWait: (() => void) | null = null;\n\n /** The element to anchor to: an explicit `.anchorElement` property, or the `anchor=\"<id>\"` attribute. */\n get anchorElement(): HTMLElement | null {\n if (this._anchorEl) return this._anchorEl;\n const id = this.getAttribute('anchor');\n return id ? doc.getElementById(id) : null;\n }\n\n set anchorElement(el: HTMLElement | null) {\n this._anchorEl = el;\n this._anchorRect = null;\n this.onAnchorChanged();\n }\n\n /**\n * Called whenever the anchor may have changed (`anchor` attribute,\n * `.anchorElement` property). Subclasses that wire listeners/ARIA onto the\n * anchor re-bind here — call `super.onAnchorChanged()`.\n */\n protected onAnchorChanged(): void {\n if (this._wrapper) this.updatePosition();\n }\n\n protected override onAttributeChanged(name: string): void {\n if (name === 'anchor') this.onAnchorChanged();\n else if (this._wrapper) this.updatePosition(); // placement / offset\n }\n\n /** Anchors to a fixed viewport point instead of an element (used by context menus). */\n protected setAnchorPoint(x: number, y: number): void {\n this._anchorEl = null;\n this._anchorRect = new DOMRect(x, y, 0, 0);\n }\n\n get placement(): AnchoredPlacement {\n return (this.getAttribute('placement') as AnchoredPlacement | null) ?? 'bottom';\n }\n\n get offset(): number {\n return this.numberAttr('offset', 8);\n }\n\n /** Override to force focus-trapping on/off/conditional (menus always force it off; popovers derive it from `interactive`). */\n protected wantsFocusTrap(): boolean {\n return this.boolAttr('trap-focus');\n }\n\n protected createWrapper(): HTMLElement {\n const el = doc.createElement('div');\n el.className = 'a11y-anchored-overlay-wrapper';\n return el;\n }\n\n protected getContentClass(): string {\n return 'a11y-anchored-overlay-content';\n }\n\n protected override _show(): void {\n // Reopened mid-close: complete that close first (see A11yModalOverlayElement).\n this._flushPendingHide();\n // Re-shown while already open (e.g. a context menu re-right-clicked\n // elsewhere): drop the current chrome and its listeners, then rebuild.\n if (this._wrapper) this._teardownChrome();\n\n const wrapper = this.createWrapper();\n doc.body.appendChild(wrapper);\n this.classList.add(this.getContentClass());\n this._moveSelfTo(wrapper); // see A11yOverlayElement's class doc on why this isn't a raw appendChild\n this._wrapper = wrapper;\n\n this.updatePosition();\n this._bindDismissListeners(wrapper);\n this._bindRepositionListeners(wrapper);\n\n if (this.wantsFocusTrap()) {\n this._focusTrap = new FocusTrapHelper({ container: wrapper, options: this._focusTrapOptions() });\n this._focusTrap.activate();\n }\n\n // Skipped if closed before the frame: adding it then would animate a closing overlay back in.\n requestAnimationFrame(() => {\n if (this._wrapper === wrapper) wrapper.classList.add('a11y-is-open');\n });\n if (!this._isShowing) this._onShown();\n }\n\n protected override _hide(opts?: { immediate?: boolean }): void {\n // Focus already moved elsewhere on the page (e.g. the outside click that closes this landed\n // on a text field): leave it there rather than pulling it back to the trigger.\n const active = doc.activeElement;\n const focusMovedAway = !!this._wrapper && !!active && active !== doc.body && !this._wrapper.contains(active);\n this._unbindActiveListeners({ returnFocus: !focusMovedAway });\n\n const wrapper = this._wrapper;\n if (!wrapper) {\n if (this._pendingHide) {\n if (opts?.immediate) this._flushPendingHide();\n } else if (this._isShowing) {\n this._onHidden();\n }\n return;\n }\n this._wrapper = null;\n\n const finish = (): void => {\n this._pendingHide = null;\n this._cancelHideWait = null;\n this.classList.remove(this.getContentClass());\n // Detach from the wrapper before it's removed — unless the consumer is\n // removing this element from the document, which must stay removed.\n if (!this._detaching) this._moveSelfTo(doc.body);\n wrapper.remove();\n this._onHidden();\n };\n this._pendingHide = finish;\n\n if (opts?.immediate) {\n finish();\n return;\n }\n wrapper.classList.remove('a11y-is-open');\n this._cancelHideWait = whenTransitionDone(wrapper, finish);\n }\n\n private _flushPendingHide(): void {\n const finish = this._pendingHide;\n if (!finish) return;\n this._cancelHideWait?.();\n finish();\n }\n\n private _unbindActiveListeners(opts?: { returnFocus?: boolean }): void {\n this._focusTrap?.deactivate(opts);\n this._focusTrap = null;\n this._unbindDismissListeners();\n this._unbindRepositionListeners();\n }\n\n private _teardownChrome(): void {\n this._unbindActiveListeners();\n this._moveSelfTo(doc.body);\n this._wrapper?.remove();\n this._wrapper = null;\n }\n\n protected _focusTrapOptions(): IFocusTrapOptions {\n return { onDeactivate: () => this.close('escape') };\n }\n\n updatePosition(): void {\n const anchorRect = this._getAnchorRect();\n if (!anchorRect || !this._wrapper) return;\n\n const wrapperRect = this._wrapper.getBoundingClientRect();\n const viewportWidth = doc.documentElement.clientWidth;\n const viewportHeight = doc.documentElement.clientHeight;\n\n const { placement, top, left } = this._computePosition(anchorRect, wrapperRect, viewportWidth, viewportHeight);\n\n this._wrapper.setAttribute('data-placement', placement);\n this._wrapper.style.top = `${top}px`;\n this._wrapper.style.left = `${left}px`;\n }\n\n private _getAnchorRect(): DOMRect | null {\n if (this.anchorElement) return this.anchorElement.getBoundingClientRect();\n return this._anchorRect;\n }\n\n private _computePosition(\n anchorRect: DOMRect,\n wrapperRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): { placement: string; top: number; left: number } {\n const offset = this.offset;\n const [side, align] = this.placement.split('-') as [AnchoredSide, AnchoredAlign | undefined];\n\n const opposite: Record<AnchoredSide, AnchoredSide> = { top: 'bottom', bottom: 'top', left: 'right', right: 'left' };\n\n const fits = (s: AnchoredSide): boolean => {\n switch (s) {\n case 'top':\n return anchorRect.top - offset - wrapperRect.height >= 0;\n case 'bottom':\n return anchorRect.bottom + offset + wrapperRect.height <= viewportHeight;\n case 'left':\n return anchorRect.left - offset - wrapperRect.width >= 0;\n case 'right':\n return anchorRect.right + offset + wrapperRect.width <= viewportWidth;\n }\n };\n\n const resolvedSide = !fits(side) && fits(opposite[side]) ? opposite[side] : side;\n\n let top: number;\n let left: number;\n\n if (resolvedSide === 'top' || resolvedSide === 'bottom') {\n top = resolvedSide === 'top' ? anchorRect.top - offset - wrapperRect.height : anchorRect.bottom + offset;\n left = this._alignCrossAxis(align, anchorRect.left, anchorRect.right, wrapperRect.width);\n left = this._clamp(left, offset, viewportWidth - wrapperRect.width - offset);\n } else {\n left = resolvedSide === 'left' ? anchorRect.left - offset - wrapperRect.width : anchorRect.right + offset;\n top = this._alignCrossAxis(align, anchorRect.top, anchorRect.bottom, wrapperRect.height);\n top = this._clamp(top, offset, viewportHeight - wrapperRect.height - offset);\n }\n\n const placement = align ? `${resolvedSide}-${align}` : resolvedSide;\n return { placement, top, left };\n }\n\n private _alignCrossAxis(align: AnchoredAlign | undefined, anchorStart: number, anchorEnd: number, wrapperSize: number): number {\n if (align === 'start') return anchorStart;\n if (align === 'end') return anchorEnd - wrapperSize;\n return anchorStart + (anchorEnd - anchorStart) / 2 - wrapperSize / 2;\n }\n\n private _clamp(value: number, min: number, max: number): number {\n if (max < min) return min;\n return Math.min(Math.max(value, min), max);\n }\n\n private _bindDismissListeners(wrapper: HTMLElement): void {\n this._boundOutsideClick = (e: MouseEvent): void => {\n const target = e.target as Node;\n if (wrapper.contains(target) || this.anchorElement?.contains(target)) return;\n if (isInsideOverlayOpenedAfter(this, target)) return; // e.g. a dropdown opened from inside this popover\n this.close('outside-click');\n };\n // Deferred so the same click/tap that opened the overlay doesn't immediately close it.\n // Capture phase: decided before the click's own handlers run — a menu item's handler closes\n // its dropdown, and once closed the dropdown no longer counts as \"opened on top of this one\".\n this._outsideClickTimer = setTimeout(() => {\n doc.addEventListener('click', this._boundOutsideClick!, true);\n }, 0);\n\n if (!this.wantsFocusTrap()) {\n // Capture phase, before a focus trap's own document listener: Escape\n // dismisses this overlay only (e.g. a tooltip on a button inside a\n // modal), and `preventDefault()` tells every other handler it's taken.\n this._boundKeyDown = (e: KeyboardEvent): void => {\n if (e.key !== 'Escape' || e.defaultPrevented) return;\n // Capture listeners run in the order they were added, i.e. oldest overlay first:\n // leave Escape to whatever was opened on top of this one.\n if (hasOverlayOpenedAfter(this)) return;\n e.preventDefault();\n this.close('escape');\n };\n doc.addEventListener('keydown', this._boundKeyDown, true);\n }\n }\n\n private _unbindDismissListeners(): void {\n if (this._outsideClickTimer) {\n clearTimeout(this._outsideClickTimer);\n this._outsideClickTimer = null;\n }\n if (this._boundOutsideClick) {\n doc.removeEventListener('click', this._boundOutsideClick, true);\n this._boundOutsideClick = null;\n }\n if (this._boundKeyDown) {\n doc.removeEventListener('keydown', this._boundKeyDown, true);\n this._boundKeyDown = null;\n }\n }\n\n private _bindRepositionListeners(wrapper: HTMLElement): void {\n this._boundReposition = () => this.updatePosition();\n window.addEventListener('scroll', this._boundReposition, true);\n window.addEventListener('resize', this._boundReposition);\n\n if (typeof ResizeObserver !== 'undefined') {\n this._resizeObserver = new ResizeObserver(this._boundReposition);\n if (this.anchorElement) this._resizeObserver.observe(this.anchorElement);\n this._resizeObserver.observe(wrapper);\n }\n }\n\n private _unbindRepositionListeners(): void {\n if (this._boundReposition) {\n window.removeEventListener('scroll', this._boundReposition, true);\n window.removeEventListener('resize', this._boundReposition);\n this._boundReposition = null;\n }\n this._resizeObserver?.disconnect();\n this._resizeObserver = null;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,IAAe,6BAAf,cAAkD,mBAAmB;AAAA,EAC1E,WAAoB,qBAA+B;AACjD,WAAO,CAAC,QAAQ,UAAU,aAAa,QAAQ;AAAA,EACjD;AAAA,EAEU,WAA+B;AAAA,EACjC,YAAgC;AAAA,EAChC,cAA8B;AAAA,EAC9B,aAAqC;AAAA,EACrC,qBAAuD;AAAA,EACvD,qBAA2D;AAAA,EAC3D,gBAAqD;AAAA,EACrD,mBAAwC;AAAA,EACxC,kBAAyC;AAAA,EACzC,eAAoC;AAAA,EACpC,kBAAuC;AAAA;AAAA,EAG/C,IAAI,gBAAoC;AACtC,QAAI,KAAK,UAAW,QAAO,KAAK;AAChC,UAAM,KAAK,KAAK,aAAa,QAAQ;AACrC,WAAO,KAAK,IAAI,eAAe,EAAE,IAAI;AAAA,EACvC;AAAA,EAEA,IAAI,cAAc,IAAwB;AACxC,SAAK,YAAY;AACjB,SAAK,cAAc;AACnB,SAAK,gBAAgB;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,kBAAwB;AAChC,QAAI,KAAK,SAAU,MAAK,eAAe;AAAA,EACzC;AAAA,EAEmB,mBAAmB,MAAoB;AACxD,QAAI,SAAS,SAAU,MAAK,gBAAgB;AAAA,aACnC,KAAK,SAAU,MAAK,eAAe;AAAA,EAC9C;AAAA;AAAA,EAGU,eAAe,GAAW,GAAiB;AACnD,SAAK,YAAY;AACjB,SAAK,cAAc,IAAI,QAAQ,GAAG,GAAG,GAAG,CAAC;AAAA,EAC3C;AAAA,EAEA,IAAI,YAA+B;AACjC,WAAQ,KA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