a11y-elements 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. package/README.md +1139 -10
  2. package/dist/a11y.css +146 -12
  3. package/dist/browser/{accessibility-components → components}/anchor/define.js +136 -12
  4. package/dist/browser/components/anchor/define.js.map +1 -0
  5. package/dist/browser/{accessibility-components → components}/avatar/define.js +103 -10
  6. package/dist/browser/components/avatar/define.js.map +1 -0
  7. package/dist/browser/{accessibility-components → components}/checkbox/define.js +92 -7
  8. package/dist/browser/components/checkbox/define.js.map +1 -0
  9. package/dist/browser/components/focusable/define.js +199 -0
  10. package/dist/browser/components/focusable/define.js.map +1 -0
  11. package/dist/browser/components/input/define.js +669 -0
  12. package/dist/browser/components/input/define.js.map +1 -0
  13. package/dist/browser/components/label/define.js +262 -0
  14. package/dist/browser/components/label/define.js.map +1 -0
  15. package/dist/browser/{accessibility-components → components}/picture/define.js +92 -5
  16. package/dist/browser/components/picture/define.js.map +1 -0
  17. package/dist/browser/components/progress/define.js +227 -0
  18. package/dist/browser/components/progress/define.js.map +1 -0
  19. package/dist/browser/{accessibility-components → components}/radio-group/define.js +92 -6
  20. package/dist/browser/components/radio-group/define.js.map +1 -0
  21. package/dist/browser/{accessibility-components → components}/select/define.js +92 -6
  22. package/dist/browser/components/select/define.js.map +1 -0
  23. package/dist/browser/{accessibility-components → components}/skeleton/define.js +93 -7
  24. package/dist/browser/components/skeleton/define.js.map +1 -0
  25. package/dist/browser/{accessibility-components → components}/spinner/define.js +100 -8
  26. package/dist/browser/components/spinner/define.js.map +1 -0
  27. package/dist/browser/{accessibility-components → components}/switch/define.js +92 -6
  28. package/dist/browser/components/switch/define.js.map +1 -0
  29. package/dist/browser/components/textarea/define.js +669 -0
  30. package/dist/browser/components/textarea/define.js.map +1 -0
  31. package/dist/browser/components/visually-hidden/define.js +183 -0
  32. package/dist/browser/components/visually-hidden/define.js.map +1 -0
  33. package/dist/browser/overlays/blocking-loader/define.js +170 -13
  34. package/dist/browser/overlays/blocking-loader/define.js.map +1 -1
  35. package/dist/browser/overlays/context-menu/define.js +283 -121
  36. package/dist/browser/overlays/context-menu/define.js.map +1 -1
  37. package/dist/browser/overlays/drawer/define.js +190 -13
  38. package/dist/browser/overlays/drawer/define.js.map +1 -1
  39. package/dist/browser/overlays/dropdown/define.js +283 -121
  40. package/dist/browser/overlays/dropdown/define.js.map +1 -1
  41. package/dist/browser/overlays/emergency-dialog/define.js +190 -13
  42. package/dist/browser/overlays/emergency-dialog/define.js.map +1 -1
  43. package/dist/browser/overlays/modal/define.js +190 -14
  44. package/dist/browser/overlays/modal/define.js.map +1 -1
  45. package/dist/browser/overlays/notification-banner/define.js +171 -15
  46. package/dist/browser/overlays/notification-banner/define.js.map +1 -1
  47. package/dist/browser/overlays/popover/define.js +172 -11
  48. package/dist/browser/overlays/popover/define.js.map +1 -1
  49. package/dist/browser/overlays/snackbar/define.js +148 -15
  50. package/dist/browser/overlays/snackbar/define.js.map +1 -1
  51. package/dist/browser/overlays/tooltip/define.js +189 -14
  52. package/dist/browser/overlays/tooltip/define.js.map +1 -1
  53. package/dist/{accessibility-components → components}/anchor/anchor.element.d.ts +12 -4
  54. package/dist/{accessibility-components → components}/anchor/anchor.element.js +56 -11
  55. package/dist/components/anchor/anchor.element.js.map +1 -0
  56. package/dist/{accessibility-components → components}/anchor/define.d.ts +1 -0
  57. package/dist/{accessibility-components → components}/anchor/define.js +2 -0
  58. package/dist/components/anchor/define.js.map +1 -0
  59. package/dist/{accessibility-components → components}/avatar/avatar.element.d.ts +2 -0
  60. package/dist/{accessibility-components → components}/avatar/avatar.element.js +10 -3
  61. package/dist/components/avatar/avatar.element.js.map +1 -0
  62. package/dist/{accessibility-components → components}/avatar/define.d.ts +1 -0
  63. package/dist/{accessibility-components → components}/avatar/define.js +2 -0
  64. package/dist/components/avatar/define.js.map +1 -0
  65. package/dist/{accessibility-components → components}/checkbox/checkbox.element.js +0 -2
  66. package/dist/components/checkbox/checkbox.element.js.map +1 -0
  67. package/dist/{accessibility-components → components}/checkbox/define.d.ts +1 -0
  68. package/dist/{accessibility-components → components}/checkbox/define.js +2 -0
  69. package/dist/components/checkbox/define.js.map +1 -0
  70. package/dist/{accessibility-components → components}/focusable/define.d.ts +1 -0
  71. package/dist/{accessibility-components → components}/focusable/define.js +2 -0
  72. package/dist/components/focusable/define.js.map +1 -0
  73. package/dist/components/focusable/focusable.element.js.map +1 -0
  74. package/dist/components/input/define.d.ts +9 -0
  75. package/dist/components/input/define.js +9 -0
  76. package/dist/components/input/define.js.map +1 -0
  77. package/dist/components/input/input.element.d.ts +22 -0
  78. package/dist/components/input/input.element.js +23 -0
  79. package/dist/components/input/input.element.js.map +1 -0
  80. package/dist/components/label/define.d.ts +8 -0
  81. package/dist/components/label/define.js +8 -0
  82. package/dist/components/label/define.js.map +1 -0
  83. package/dist/components/label/label.element.d.ts +32 -0
  84. package/dist/components/label/label.element.js +62 -0
  85. package/dist/components/label/label.element.js.map +1 -0
  86. package/dist/{accessibility-components → components}/picture/define.d.ts +1 -0
  87. package/dist/{accessibility-components → components}/picture/define.js +2 -0
  88. package/dist/components/picture/define.js.map +1 -0
  89. package/dist/components/picture/picture.element.js.map +1 -0
  90. package/dist/{accessibility-components → components}/progress/define.d.ts +1 -0
  91. package/dist/{accessibility-components → components}/progress/define.js +2 -0
  92. package/dist/components/progress/define.js.map +1 -0
  93. package/dist/{accessibility-components → components}/progress/progress.element.d.ts +1 -0
  94. package/dist/{accessibility-components → components}/progress/progress.element.js +5 -1
  95. package/dist/components/progress/progress.element.js.map +1 -0
  96. package/dist/{accessibility-components → components}/radio-group/define.d.ts +1 -0
  97. package/dist/{accessibility-components → components}/radio-group/define.js +2 -0
  98. package/dist/components/radio-group/define.js.map +1 -0
  99. package/dist/{accessibility-components → components}/radio-group/radio-group.element.js +0 -1
  100. package/dist/components/radio-group/radio-group.element.js.map +1 -0
  101. package/dist/{accessibility-components → components}/select/define.d.ts +1 -0
  102. package/dist/{accessibility-components → components}/select/define.js +2 -0
  103. package/dist/components/select/define.js.map +1 -0
  104. package/dist/{accessibility-components → components}/select/select.element.js +0 -1
  105. package/dist/components/select/select.element.js.map +1 -0
  106. package/dist/{accessibility-components → components}/skeleton/define.d.ts +1 -0
  107. package/dist/{accessibility-components → components}/skeleton/define.js +2 -0
  108. package/dist/components/skeleton/define.js.map +1 -0
  109. package/dist/components/skeleton/skeleton.element.js.map +1 -0
  110. package/dist/{accessibility-components → components}/spinner/define.d.ts +1 -0
  111. package/dist/{accessibility-components → components}/spinner/define.js +2 -0
  112. package/dist/components/spinner/define.js.map +1 -0
  113. package/dist/{accessibility-components → components}/spinner/spinner.element.d.ts +1 -0
  114. package/dist/{accessibility-components → components}/spinner/spinner.element.js +5 -1
  115. package/dist/components/spinner/spinner.element.js.map +1 -0
  116. package/dist/{accessibility-components → components}/switch/define.d.ts +1 -0
  117. package/dist/{accessibility-components → components}/switch/define.js +2 -0
  118. package/dist/components/switch/define.js.map +1 -0
  119. package/dist/{accessibility-components → components}/switch/switch.element.js +0 -1
  120. package/dist/components/switch/switch.element.js.map +1 -0
  121. package/dist/components/textarea/define.d.ts +9 -0
  122. package/dist/components/textarea/define.js +9 -0
  123. package/dist/components/textarea/define.js.map +1 -0
  124. package/dist/components/textarea/textarea.element.d.ts +18 -0
  125. package/dist/components/textarea/textarea.element.js +19 -0
  126. package/dist/components/textarea/textarea.element.js.map +1 -0
  127. package/dist/{accessibility-components → components}/visually-hidden/define.d.ts +1 -0
  128. package/dist/{accessibility-components → components}/visually-hidden/define.js +2 -0
  129. package/dist/components/visually-hidden/define.js.map +1 -0
  130. package/dist/components/visually-hidden/visually-hidden.element.js.map +1 -0
  131. package/dist/core/a11y-element.d.ts +29 -1
  132. package/dist/core/a11y-element.js +65 -2
  133. package/dist/core/a11y-element.js.map +1 -1
  134. package/dist/core/a11y-field-element.d.ts +76 -0
  135. package/dist/core/a11y-field-element.js +220 -0
  136. package/dist/core/a11y-field-element.js.map +1 -0
  137. package/dist/core/a11y-overlay-element.d.ts +3 -1
  138. package/dist/core/a11y-overlay-element.js +12 -4
  139. package/dist/core/a11y-overlay-element.js.map +1 -1
  140. package/dist/core/a11y-wrapper-element.js +1 -0
  141. package/dist/core/a11y-wrapper-element.js.map +1 -1
  142. package/dist/core/dom-sync.d.ts +6 -0
  143. package/dist/core/dom-sync.js +13 -0
  144. package/dist/core/dom-sync.js.map +1 -1
  145. package/dist/core/field.d.ts +80 -0
  146. package/dist/core/field.js +256 -0
  147. package/dist/core/field.js.map +1 -0
  148. package/dist/core/focus-trap.d.ts +14 -0
  149. package/dist/core/focus-trap.js +85 -4
  150. package/dist/core/focus-trap.js.map +1 -1
  151. package/dist/core/ids.d.ts +2 -0
  152. package/dist/core/ids.js +18 -0
  153. package/dist/core/ids.js.map +1 -0
  154. package/dist/core/index.d.ts +4 -0
  155. package/dist/core/index.js +4 -0
  156. package/dist/core/index.js.map +1 -1
  157. package/dist/core/overlay-registry.d.ts +12 -0
  158. package/dist/core/overlay-registry.js +29 -1
  159. package/dist/core/overlay-registry.js.map +1 -1
  160. package/dist/core/strings.d.ts +39 -0
  161. package/dist/core/strings.js +47 -0
  162. package/dist/core/strings.js.map +1 -0
  163. package/dist/overlays/blocking-loader/blocking-loader.element.d.ts +1 -0
  164. package/dist/overlays/blocking-loader/blocking-loader.element.js +8 -2
  165. package/dist/overlays/blocking-loader/blocking-loader.element.js.map +1 -1
  166. package/dist/overlays/blocking-loader/define.d.ts +3 -2
  167. package/dist/overlays/blocking-loader/define.js +4 -3
  168. package/dist/overlays/blocking-loader/define.js.map +1 -1
  169. package/dist/overlays/context-menu/define.d.ts +2 -1
  170. package/dist/overlays/context-menu/define.js +3 -2
  171. package/dist/overlays/context-menu/define.js.map +1 -1
  172. package/dist/overlays/core/a11y-menu-overlay-element.js +2 -1
  173. package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
  174. package/dist/overlays/core/a11y-modal-overlay-element.d.ts +7 -0
  175. package/dist/overlays/core/a11y-modal-overlay-element.js +19 -2
  176. package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -1
  177. package/dist/overlays/core/a11y-passive-overlay-element.d.ts +11 -3
  178. package/dist/overlays/core/a11y-passive-overlay-element.js +40 -13
  179. package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -1
  180. package/dist/overlays/drawer/define.d.ts +2 -1
  181. package/dist/overlays/drawer/define.js +3 -2
  182. package/dist/overlays/drawer/define.js.map +1 -1
  183. package/dist/overlays/drawer/drawer.element.js +0 -1
  184. package/dist/overlays/drawer/drawer.element.js.map +1 -1
  185. package/dist/overlays/dropdown/define.d.ts +2 -1
  186. package/dist/overlays/dropdown/define.js +3 -2
  187. package/dist/overlays/dropdown/define.js.map +1 -1
  188. package/dist/overlays/emergency-dialog/define.d.ts +2 -1
  189. package/dist/overlays/emergency-dialog/define.js +3 -2
  190. package/dist/overlays/emergency-dialog/define.js.map +1 -1
  191. package/dist/overlays/emergency-dialog/emergency-dialog.element.js +0 -1
  192. package/dist/overlays/emergency-dialog/emergency-dialog.element.js.map +1 -1
  193. package/dist/overlays/modal/define.d.ts +2 -1
  194. package/dist/overlays/modal/define.js +3 -2
  195. package/dist/overlays/modal/define.js.map +1 -1
  196. package/dist/overlays/modal/modal.element.js +0 -2
  197. package/dist/overlays/modal/modal.element.js.map +1 -1
  198. package/dist/overlays/notification-banner/define.d.ts +2 -0
  199. package/dist/overlays/notification-banner/define.js +3 -0
  200. package/dist/overlays/notification-banner/define.js.map +1 -1
  201. package/dist/overlays/notification-banner/notification-banner.element.d.ts +11 -0
  202. package/dist/overlays/notification-banner/notification-banner.element.js +27 -1
  203. package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -1
  204. package/dist/overlays/popover/define.d.ts +2 -1
  205. package/dist/overlays/popover/define.js +3 -2
  206. package/dist/overlays/popover/define.js.map +1 -1
  207. package/dist/overlays/popover/popover.element.js +0 -1
  208. package/dist/overlays/popover/popover.element.js.map +1 -1
  209. package/dist/overlays/snackbar/define.d.ts +2 -0
  210. package/dist/overlays/snackbar/define.js +3 -0
  211. package/dist/overlays/snackbar/define.js.map +1 -1
  212. package/dist/overlays/snackbar/snackbar.element.d.ts +1 -1
  213. package/dist/overlays/tooltip/define.d.ts +2 -1
  214. package/dist/overlays/tooltip/define.js +3 -2
  215. package/dist/overlays/tooltip/define.js.map +1 -1
  216. package/dist/overlays/tooltip/tooltip.element.js +2 -7
  217. package/dist/overlays/tooltip/tooltip.element.js.map +1 -1
  218. package/package.json +9 -9
  219. package/dist/accessibility-components/anchor/anchor.element.js.map +0 -1
  220. package/dist/accessibility-components/anchor/define.js.map +0 -1
  221. package/dist/accessibility-components/avatar/avatar.element.js.map +0 -1
  222. package/dist/accessibility-components/avatar/define.js.map +0 -1
  223. package/dist/accessibility-components/checkbox/checkbox.element.js.map +0 -1
  224. package/dist/accessibility-components/checkbox/define.js.map +0 -1
  225. package/dist/accessibility-components/focusable/define.js.map +0 -1
  226. package/dist/accessibility-components/focusable/focusable.element.js.map +0 -1
  227. package/dist/accessibility-components/picture/define.js.map +0 -1
  228. package/dist/accessibility-components/picture/picture.element.js.map +0 -1
  229. package/dist/accessibility-components/progress/define.js.map +0 -1
  230. package/dist/accessibility-components/progress/progress.element.js.map +0 -1
  231. package/dist/accessibility-components/radio-group/define.js.map +0 -1
  232. package/dist/accessibility-components/radio-group/radio-group.element.js.map +0 -1
  233. package/dist/accessibility-components/select/define.js.map +0 -1
  234. package/dist/accessibility-components/select/select.element.js.map +0 -1
  235. package/dist/accessibility-components/skeleton/define.js.map +0 -1
  236. package/dist/accessibility-components/skeleton/skeleton.element.js.map +0 -1
  237. package/dist/accessibility-components/spinner/define.js.map +0 -1
  238. package/dist/accessibility-components/spinner/spinner.element.js.map +0 -1
  239. package/dist/accessibility-components/switch/define.js.map +0 -1
  240. package/dist/accessibility-components/switch/switch.element.js.map +0 -1
  241. package/dist/accessibility-components/visually-hidden/define.js.map +0 -1
  242. package/dist/accessibility-components/visually-hidden/visually-hidden.element.js.map +0 -1
  243. package/dist/browser/accessibility-components/anchor/define.js.map +0 -1
  244. package/dist/browser/accessibility-components/avatar/define.js.map +0 -1
  245. package/dist/browser/accessibility-components/checkbox/define.js.map +0 -1
  246. package/dist/browser/accessibility-components/focusable/define.js +0 -113
  247. package/dist/browser/accessibility-components/focusable/define.js.map +0 -1
  248. package/dist/browser/accessibility-components/picture/define.js.map +0 -1
  249. package/dist/browser/accessibility-components/progress/define.js +0 -135
  250. package/dist/browser/accessibility-components/progress/define.js.map +0 -1
  251. package/dist/browser/accessibility-components/radio-group/define.js.map +0 -1
  252. package/dist/browser/accessibility-components/select/define.js.map +0 -1
  253. package/dist/browser/accessibility-components/skeleton/define.js.map +0 -1
  254. package/dist/browser/accessibility-components/spinner/define.js.map +0 -1
  255. package/dist/browser/accessibility-components/switch/define.js.map +0 -1
  256. package/dist/browser/accessibility-components/visually-hidden/define.js +0 -97
  257. package/dist/browser/accessibility-components/visually-hidden/define.js.map +0 -1
  258. /package/dist/{accessibility-components → components}/checkbox/checkbox.element.d.ts +0 -0
  259. /package/dist/{accessibility-components → components}/focusable/focusable.element.d.ts +0 -0
  260. /package/dist/{accessibility-components → components}/focusable/focusable.element.js +0 -0
  261. /package/dist/{accessibility-components → components}/picture/picture.element.d.ts +0 -0
  262. /package/dist/{accessibility-components → components}/picture/picture.element.js +0 -0
  263. /package/dist/{accessibility-components → components}/radio-group/radio-group.element.d.ts +0 -0
  264. /package/dist/{accessibility-components → components}/select/select.element.d.ts +0 -0
  265. /package/dist/{accessibility-components → components}/skeleton/skeleton.element.d.ts +0 -0
  266. /package/dist/{accessibility-components → components}/skeleton/skeleton.element.js +0 -0
  267. /package/dist/{accessibility-components → components}/switch/switch.element.d.ts +0 -0
  268. /package/dist/{accessibility-components → components}/visually-hidden/visually-hidden.element.d.ts +0 -0
  269. /package/dist/{accessibility-components → components}/visually-hidden/visually-hidden.element.js +0 -0
@@ -1,17 +1,87 @@
1
+ // src/core/strings.ts
2
+ var DEFAULT_STRINGS = Object.freeze({
3
+ opensInNewTab: "(opens in new tab)",
4
+ navigatedTo: "Navigated to {name}",
5
+ closeDialog: "Close dialog",
6
+ dismiss: "Dismiss",
7
+ loading: "Loading",
8
+ progress: "Progress",
9
+ avatar: "Avatar",
10
+ characterCount: "{count} / {max}",
11
+ charactersRemaining: "{count} characters remaining",
12
+ characterRemaining: "{count} character remaining"
13
+ });
14
+ var STRINGS_CHANGE_EVENT = "a11y-strings-change";
15
+ var STRINGS_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/strings");
16
+ var store = globalThis;
17
+ var strings = store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS };
18
+ for (const [key, value] of Object.entries(DEFAULT_STRINGS)) strings[key] ??= value;
19
+ function setStrings(partial) {
20
+ for (const [key, value] of Object.entries(partial)) {
21
+ if (key in DEFAULT_STRINGS && typeof value === "string") strings[key] = value;
22
+ }
23
+ document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));
24
+ }
25
+ function resetStrings() {
26
+ Object.assign(strings, DEFAULT_STRINGS);
27
+ document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));
28
+ }
29
+
1
30
  // src/core/a11y-element.ts
2
31
  var A11yElement = class extends HTMLElement {
3
32
  _connected = false;
4
33
  _listeners = [];
5
34
  _updating = false;
35
+ /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */
36
+ _cssVarOwned = /* @__PURE__ */ new Map();
37
+ /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */
38
+ _stringsListener = null;
6
39
  connectedCallback() {
40
+ this._initConnect();
7
41
  this._connected = true;
8
42
  this.update();
9
43
  }
10
44
  disconnectedCallback() {
11
45
  this._connected = false;
12
46
  this._cleanupListeners();
47
+ if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);
48
+ this._stringsListener = null;
13
49
  this.onDisconnect?.();
14
50
  }
51
+ /**
52
+ * Connect-time setup shared by every base class. Every `connectedCallback`
53
+ * override that doesn't call super must call this itself, before setting
54
+ * `_connected` (so replayed setters only write attributes, and the normal
55
+ * connect path then acts on them).
56
+ */
57
+ _initConnect() {
58
+ this._upgradeProperties();
59
+ this._watchStrings();
60
+ }
61
+ /**
62
+ * A property set on the element before its class was defined (e.g.
63
+ * `el.open = true` before a lazy-loaded bundle runs) is an own property
64
+ * that shadows the class accessor. Replay each one through the setter.
65
+ */
66
+ _upgradeProperties() {
67
+ for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
68
+ for (const name of Object.getOwnPropertyNames(proto)) {
69
+ if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;
70
+ const self = this;
71
+ const value = self[name];
72
+ delete self[name];
73
+ self[name] = value;
74
+ }
75
+ }
76
+ }
77
+ /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */
78
+ _watchStrings() {
79
+ if (!this.onStringsChange || this._stringsListener) return;
80
+ this._stringsListener = () => {
81
+ if (this._connected) this.onStringsChange?.();
82
+ };
83
+ document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);
84
+ }
15
85
  attributeChangedCallback(_name, oldValue, newValue) {
16
86
  if (oldValue === newValue || !this._connected) return;
17
87
  this.update();
@@ -67,9 +137,23 @@ var A11yElement = class extends HTMLElement {
67
137
  if (value) this.setAttribute(name, "");
68
138
  else this.removeAttribute(name);
69
139
  }
70
- /** Sets or removes a CSS custom property on this element depending on truthiness of `value`. */
140
+ /**
141
+ * Sets a CSS custom property on this element while `value` is truthy. When
142
+ * it isn't, only a property this method set itself is undone — restored to
143
+ * the consumer's own inline value from before (or removed if there was
144
+ * none) — so a consumer's `style="--a11y-…: …"` survives when the matching
145
+ * attribute is absent.
146
+ */
71
147
  setCssVar(name, value) {
72
- if (value) this.style.setProperty(name, value);
148
+ if (value) {
149
+ if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));
150
+ this.style.setProperty(name, value);
151
+ return;
152
+ }
153
+ if (!this._cssVarOwned.has(name)) return;
154
+ const previous = this._cssVarOwned.get(name);
155
+ this._cssVarOwned.delete(name);
156
+ if (previous) this.style.setProperty(name, previous);
73
157
  else this.style.removeProperty(name);
74
158
  }
75
159
  };
@@ -78,8 +162,9 @@ var A11yElement = class extends HTMLElement {
78
162
  var OVERLAY_OPEN_EVENT = "a11y-overlay-open";
79
163
  var OVERLAY_CLOSE_EVENT = "a11y-overlay-close";
80
164
  var STATE_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/overlay-state");
81
- var store = globalThis;
82
- var state = store[STATE_KEY] ??= { openOverlays: /* @__PURE__ */ new Set(), scrollLocks: 0 };
165
+ var store2 = globalThis;
166
+ var state = store2[STATE_KEY] ??= { openOverlays: /* @__PURE__ */ new Set(), scrollLocks: 0, portalOrigins: /* @__PURE__ */ new Map() };
167
+ state.portalOrigins ??= /* @__PURE__ */ new Map();
83
168
  function registerOpenOverlay(overlay) {
84
169
  state.openOverlays.add(overlay);
85
170
  }
@@ -89,6 +174,22 @@ function unregisterOpenOverlay(overlay) {
89
174
  function dismissAllOverlays() {
90
175
  for (const overlay of Array.from(state.openOverlays)) overlay.close();
91
176
  }
177
+ function recordPortalOrigin(overlay, origin) {
178
+ state.portalOrigins.set(overlay, origin);
179
+ }
180
+ function forgetPortalOrigin(overlay) {
181
+ state.portalOrigins.delete(overlay);
182
+ }
183
+ function removeOverlaysWithin(host) {
184
+ let removed = 0;
185
+ for (const [overlay, origin] of Array.from(state.portalOrigins)) {
186
+ if (!host.contains(origin)) continue;
187
+ overlay.remove();
188
+ state.portalOrigins.delete(overlay);
189
+ removed++;
190
+ }
191
+ return removed;
192
+ }
92
193
  function emitOverlayOpen(name) {
93
194
  return document.dispatchEvent(
94
195
  new CustomEvent(OVERLAY_OPEN_EVENT, { bubbles: true, detail: { name } })
@@ -121,6 +222,7 @@ var A11yOverlayElement = class extends A11yElement {
121
222
  }
122
223
  connectedCallback() {
123
224
  if (this._internalMove) return;
225
+ this._initConnect();
124
226
  this._connected = true;
125
227
  this._portalToBody();
126
228
  this.onConnect?.();
@@ -139,6 +241,7 @@ var A11yOverlayElement = class extends A11yElement {
139
241
  }
140
242
  }
141
243
  unregisterOpenOverlay(this);
244
+ forgetPortalOrigin(this);
142
245
  super.disconnectedCallback();
143
246
  }
144
247
  attributeChangedCallback(name, oldValue, newValue) {
@@ -166,7 +269,10 @@ var A11yOverlayElement = class extends A11yElement {
166
269
  this.open = false;
167
270
  }
168
271
  _portalToBody() {
169
- if (this.parentNode !== document.body) this._moveSelfTo(document.body);
272
+ const origin = this.parentNode;
273
+ if (origin === document.body) return;
274
+ this._moveSelfTo(document.body);
275
+ if (origin instanceof Element) recordPortalOrigin(this, origin);
170
276
  }
171
277
  /**
172
278
  * Moves `this` to be the last child of `newParent`, suppressing the
@@ -205,12 +311,49 @@ var A11yOverlayElement = class extends A11yElement {
205
311
  };
206
312
 
207
313
  // src/core/focus-trap.ts
208
- var FOCUSABLE_SELECTOR = 'button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';
314
+ var FOCUSABLE_SELECTOR = [
315
+ "a[href]",
316
+ "area[href]",
317
+ "button:not(:disabled)",
318
+ 'input:not(:disabled):not([type="hidden"])',
319
+ "select:not(:disabled)",
320
+ "textarea:not(:disabled)",
321
+ "details > summary:first-of-type",
322
+ "iframe",
323
+ "audio[controls]",
324
+ "video[controls]",
325
+ '[contenteditable]:not([contenteditable="false"])',
326
+ "[tabindex]"
327
+ ].join(", ");
209
328
  function isTabbable(el) {
329
+ if (Number(el.getAttribute("tabindex")) < 0) return false;
210
330
  if (el.closest("[hidden], [inert]")) return false;
211
331
  if (typeof el.checkVisibility === "function") return el.checkVisibility({ visibilityProperty: true });
212
332
  return true;
213
333
  }
334
+ var POINTER_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/last-pressed");
335
+ var pointerStore = globalThis;
336
+ var pointerState = pointerStore[POINTER_KEY] ??= { lastPressed: null, listening: false };
337
+ if (!pointerState.listening && typeof document !== "undefined") {
338
+ pointerState.listening = true;
339
+ document.addEventListener(
340
+ "pointerdown",
341
+ (event) => {
342
+ const target = event.target instanceof Element ? event.target : null;
343
+ pointerState.lastPressed = target?.closest(FOCUSABLE_SELECTOR) ?? null;
344
+ },
345
+ true
346
+ );
347
+ }
348
+ function focusReturnTarget() {
349
+ const active = document.activeElement;
350
+ if (active && active !== document.body && active !== document.documentElement) return active;
351
+ const pressed = pointerState.lastPressed;
352
+ return pressed?.isConnected ? pressed : active;
353
+ }
354
+ var STACK_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/focus-trap-stack");
355
+ var stackStore = globalThis;
356
+ var activeTraps = stackStore[STACK_KEY] ??= [];
214
357
  var FocusTrapHelper = class {
215
358
  _container;
216
359
  _previousActiveElement = null;
@@ -240,7 +383,7 @@ var FocusTrapHelper = class {
240
383
  }
241
384
  activate() {
242
385
  if (this._isActive) return;
243
- this._previousActiveElement = document.activeElement;
386
+ this._previousActiveElement = focusReturnTarget();
244
387
  this._focusableElements = this._getFocusableElements();
245
388
  if (this._focusableElements.length > 0) {
246
389
  this._firstFocusableElement = this._focusableElements[0] ?? null;
@@ -250,14 +393,17 @@ var FocusTrapHelper = class {
250
393
  this._container.focus();
251
394
  this._firstFocusableElement = this._container;
252
395
  }
253
- this._container.addEventListener("keydown", this._boundKeyDown);
396
+ document.addEventListener("keydown", this._boundKeyDown);
397
+ activeTraps.push(this);
254
398
  this._inertTarget = this._resolveInertTarget();
255
399
  if (this._inertTarget) this._inertTarget.inert = true;
256
400
  this._isActive = true;
257
401
  }
258
402
  deactivate() {
259
403
  if (!this._isActive) return;
260
- this._container.removeEventListener("keydown", this._boundKeyDown);
404
+ document.removeEventListener("keydown", this._boundKeyDown);
405
+ const index = activeTraps.indexOf(this);
406
+ if (index !== -1) activeTraps.splice(index, 1);
261
407
  if (this._inertTarget) this._inertTarget.inert = false;
262
408
  this._inertTarget = null;
263
409
  if (this._container.getAttribute("tabindex") === "-1") {
@@ -281,7 +427,20 @@ var FocusTrapHelper = class {
281
427
  this._firstFocusableElement = this._focusableElements[0] ?? null;
282
428
  }
283
429
  }
430
+ /**
431
+ * Whether this trap should handle `event`: it must be the topmost trap, and
432
+ * the key press must come from inside it — or from <body>/<html>, where
433
+ * focus lands after a click on non-focusable content inside the trap. A key
434
+ * press from elsewhere (e.g. a non-trapping dropdown opened above a modal)
435
+ * is left alone.
436
+ */
437
+ _ownsEvent(event) {
438
+ if (activeTraps[activeTraps.length - 1] !== this) return false;
439
+ const target = event.target;
440
+ return !target || target === document || target === document.body || target === document.documentElement || this._container.contains(target);
441
+ }
284
442
  _handleKeyDown(event) {
443
+ if (!this._ownsEvent(event)) return;
285
444
  switch (event.key) {
286
445
  case "Tab":
287
446
  this._handleTabKey(event);
@@ -593,7 +752,6 @@ var PopoverElement = class extends A11yAnchoredOverlayElement {
593
752
  static get observedAttributes() {
594
753
  return [...super.observedAttributes, "interactive", "trap-focus"];
595
754
  }
596
- onClose;
597
755
  wantsFocusTrap() {
598
756
  const explicit = this.getAttribute("trap-focus");
599
757
  if (explicit !== null) return explicit !== "false";
@@ -620,6 +778,9 @@ if (!customElements.get("a11y-popover")) {
620
778
  }
621
779
  export {
622
780
  PopoverElement,
623
- dismissAllOverlays
781
+ dismissAllOverlays,
782
+ removeOverlaysWithin,
783
+ resetStrings,
784
+ setStrings
624
785
  };
625
786
  //# sourceMappingURL=define.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/a11y-element.ts","../../../../src/core/overlay-registry.ts","../../../../src/core/a11y-overlay-element.ts","../../../../src/core/focus-trap.ts","../../../../src/core/transition.ts","../../../../src/overlays/core/a11y-anchored-overlay-element.ts","../../../../src/overlays/popover/popover.element.ts","../../../../src/overlays/popover/define.ts"],"sourcesContent":["import type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n\n connectedCallback(): void {\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n this.onDisconnect?.();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /** Sets or removes a CSS custom property on this element depending on truthiness of `value`. */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) this.style.setProperty(name, value);\n else this.style.removeProperty(name);\n }\n}\n","export interface OverlayOpenCloseDetail {\n name: string;\n}\n\nexport const OVERLAY_OPEN_EVENT = 'a11y-overlay-open';\nexport const OVERLAY_CLOSE_EVENT = 'a11y-overlay-close';\n\ninterface Dismissible {\n close(): void;\n}\n\ninterface SharedState {\n openOverlays: Set<Dismissible>;\n scrollLocks: number;\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] ??= { openOverlays: new Set(), scrollLocks: 0 });\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\nexport function dismissAllOverlays(): void {\n for (const overlay of Array.from(state.openOverlays)) overlay.close();\n}\n\nconst NO_SCROLL_CLASS = 'a11y-no-scroll';\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 */\nexport function lockScroll(): void {\n if (state.scrollLocks++ === 0) document.documentElement.classList.add(NO_SCROLL_CLASS);\n}\n\nexport function unlockScroll(): void {\n if (state.scrollLocks === 0) return;\n if (--state.scrollLocks === 0) document.documentElement.classList.remove(NO_SCROLL_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` now dispatches these uniformly on `document`.\n */\nexport function emitOverlayOpen(name: string): boolean {\n return document.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(OVERLAY_OPEN_EVENT, { bubbles: true, detail: { name } }),\n );\n}\n\nexport function emitOverlayClose(name: string): boolean {\n return document.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(OVERLAY_CLOSE_EVENT, { bubbles: true, detail: { name } }),\n );\n}\n","import { A11yElement } from './a11y-element.js';\nimport { registerOpenOverlay, unregisterOpenOverlay, emitOverlayOpen, emitOverlayClose } from './overlay-registry.js';\n\n/**\n * Base for the overlay family (modal, drawer, popover, tooltip, snackbar,\n * blocking-loader, …). Declarative-first: the `open` attribute/property is\n * the primary interface — `<a11y-modal open>` behaves like native\n * `<dialog open>` — with `show()`/`close()` as thin convenience wrappers\n * around that same attribute, not a separate imperative lifecycle.\n *\n * Unlike `A11yElement`, this base does **not** drive `innerHTML` from a\n * `render()` string on every attribute change: many overlays (modal, popover,\n * tooltip) wrap real consumer-authored light-DOM children as their content,\n * and blowing away `innerHTML` would destroy that content. Instead, each\n * concrete overlay is fully responsible for its own DOM in `_show()`/`_hide()`\n * — some build/replace generated markup (blocking-loader), some wrap existing\n * children in backdrop/wrapper chrome (modal), some manage a list of\n * programmatically-created items (snackbar). `_onShown()`/`_onHidden()` are\n * the small pieces of behavior every overlay needs regardless: standardized\n * `a11y-overlay-open`/`a11y-overlay-close` events (the old code only fired\n * its equivalent inconsistently — 4 of 10 overlays) and registration with\n * the dismiss-all registry.\n *\n * Body-mounting: on connect, the element moves itself to be a direct child\n * of `document.body` if it isn't already — matching the old framework's\n * constructor-time force-mount — so a `position: fixed` backdrop/wrapper\n * isn't clipped or offset by an ancestor's `overflow`/`transform`. This\n * happens once, independent of `open`/`_show()`/`_hide()` churn.\n *\n * **Reparenting `this`** (modal/anchored overlays move `this` into\n * wrapper/backdrop chrome they build): moving an already-connected custom\n * element to a *different* parent — even one that's also already connected —\n * still fires `disconnectedCallback` then `connectedCallback` again (the DOM\n * spec's insertion algorithm removes-then-inserts when a node already has a\n * parent; this is not specific to jsdom). Left unguarded, that nested\n * `connectedCallback` calls `_show()` again while the outer `_show()` call\n * that triggered the move is still on the stack — infinite recursion (a real\n * bug this hit once). Subclasses must move `this` via `_moveSelfTo()` below,\n * never a raw `appendChild`/`insertBefore` — it suppresses exactly that\n * reentrant churn.\n */\nexport abstract class A11yOverlayElement extends A11yElement {\n static get observedAttributes(): string[] {\n return ['open'];\n }\n\n protected _isShowing = false;\n /**\n * True while `disconnectedCallback` tears down an overlay the consumer\n * removed from the document — `_hide()` implementations must then leave\n * `this` detached instead of moving it back to `document.body`.\n */\n protected _detaching = false;\n private _internalMove = false;\n\n get open(): boolean {\n return this.boolAttr('open');\n }\n\n set open(value: boolean) {\n this.setBoolAttr('open', value);\n }\n\n override connectedCallback(): void {\n if (this._internalMove) return; // reparented by our own _moveSelfTo() — not a real connect event\n this._connected = true;\n this._portalToBody();\n this.onConnect?.();\n if (!this.open) return;\n // `<a11y-modal open>` upgraded mid-parse (define script loaded\n // synchronously ahead of the markup) connects before its children are\n // parsed — defer the initial show until the document is, so `_show()`\n // sees the real content (heading, focusable elements).\n if (document.readyState === 'loading') this.afterParse(() => this._showIfStillOpen());\n else this._show();\n }\n\n override disconnectedCallback(): void {\n if (this._internalMove) return; // reparented by our own _moveSelfTo() — not a real disconnect event\n if (this._isShowing) {\n this._detaching = true;\n try {\n this._hide({ immediate: true });\n } finally {\n this._detaching = false;\n }\n }\n unregisterOpenOverlay(this);\n super.disconnectedCallback();\n }\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n if (name !== 'open') {\n this.onAttributeChanged?.(name);\n return;\n }\n if (newValue !== null) this._show();\n else this._hide();\n }\n\n /**\n * Runs on every *real* connect (not the internal reparenting `_moveSelfTo()`\n * does) — the counterpart of `onDisconnect()`. Subclasses wire anchor/\n * trigger listeners here rather than overriding `connectedCallback`.\n */\n protected onConnect?(): void;\n\n /** Called for every observed attribute other than `open` that changes while connected. */\n protected onAttributeChanged?(name: string): void;\n\n /** Runs `callback` once the document has finished parsing (never, if it already has — call sites handle that case directly). */\n protected afterParse(callback: () => void): void {\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', callback, { once: true });\n }\n\n private _showIfStillOpen(): void {\n if (this._connected && this.open && !this._isShowing) this._show();\n }\n\n /** Convenience wrapper — identical to `element.open = true`. */\n show(): void {\n this.open = true;\n }\n\n /** Convenience wrapper — identical to `element.open = false`. */\n close(): void {\n this.open = false;\n }\n\n private _portalToBody(): void {\n if (this.parentNode !== document.body) this._moveSelfTo(document.body);\n }\n\n /**\n * Moves `this` to be the last child of `newParent`, suppressing the\n * connected/disconnected lifecycle churn that a plain `appendChild` would\n * trigger (see the class doc). Use this — never a raw `appendChild`/\n * `insertBefore` on `this` — anywhere a subclass reparents itself while\n * building or tearing down wrapper/backdrop chrome.\n */\n protected _moveSelfTo(newParent: Node): void {\n this._internalMove = true;\n try {\n newParent.appendChild(this);\n } finally {\n this._internalMove = false;\n }\n }\n\n /** Build/animate in whatever DOM this overlay needs, then call `_onShown()`. */\n protected abstract _show(): void;\n\n /**\n * Tear down this overlay's DOM, then call `_onHidden()`. Implementations\n * should gate real removal on a `transitionend` event (not a timeout) to\n * match the CSS-driven animate-out contract, except when `immediate` is\n * set (used when the element is forcibly removed from the document while\n * still open — no animation to wait for).\n */\n protected abstract _hide(opts?: { immediate?: boolean }): void;\n\n protected _onShown(name: string = this.tagName.toLowerCase()): void {\n this._isShowing = true;\n registerOpenOverlay(this);\n emitOverlayOpen(name);\n }\n\n protected _onHidden(name: string = this.tagName.toLowerCase()): void {\n this._isShowing = false;\n unregisterOpenOverlay(this);\n emitOverlayClose(name);\n }\n\n /**\n * Unused by overlays — content is managed explicitly by each concrete\n * overlay in `_show()`/`_hide()`, never auto-replaced from a template\n * string, so that consumer-authored light-DOM children survive. Present\n * only to satisfy `A11yElement`'s abstract contract.\n */\n protected override render(): string {\n return '';\n }\n}\n","type KeyboardEventHandler = (event: KeyboardEvent) => void;\n\nconst FOCUSABLE_SELECTOR =\n 'button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])';\n\nexport interface IFocusTrapOptions {\n escapeDeactivates?: boolean;\n returnFocusOnDeactivate?: boolean;\n onDeactivate?: () => void;\n /**\n * An element (or selector resolving to one) to mark `inert` while the trap\n * is active, so assistive tech can't reach content behind the trap.\n * Defaults to `null` (no side effect) — the old implementation hardcoded\n * `document.querySelector('#app')`, which assumed every consumer had a\n * single a11y-shell element with that exact id. A library meant to be\n * dropped into arbitrary HTML can't assume that, so this is opt-in.\n */\n inertTarget?: HTMLElement | string | null;\n}\n\nexport interface IFocusTrapHelperParams {\n container: HTMLElement;\n options?: IFocusTrapOptions;\n}\n\n/**\n * Whether a selector-matched element can actually take focus right now:\n * not inside a `hidden`/`inert` subtree, and (where the browser supports\n * `checkVisibility()`) actually rendered — `display: none`, `visibility:\n * hidden` or a collapsed `<details>` would otherwise become a Tab stop\n * that silently swallows the key press.\n */\nfunction isTabbable(el: HTMLElement): boolean {\n if (el.closest('[hidden], [inert]')) return false;\n if (typeof el.checkVisibility === 'function') return el.checkVisibility({ visibilityProperty: true });\n return true;\n}\n\nexport class FocusTrapHelper {\n private _container: HTMLElement;\n private _previousActiveElement: HTMLElement | null = null;\n private _focusableElements: HTMLElement[] | null = null;\n private _firstFocusableElement: HTMLElement | null = null;\n private _boundKeyDown: KeyboardEventHandler;\n private _options: IFocusTrapOptions;\n private _inertTarget: HTMLElement | null = null;\n private _isActive = false;\n\n constructor({ container, options = {} }: IFocusTrapHelperParams) {\n this._container = container;\n this._options = {\n escapeDeactivates: options.escapeDeactivates ?? true,\n returnFocusOnDeactivate: options.returnFocusOnDeactivate ?? true,\n onDeactivate: options.onDeactivate,\n inertTarget: options.inertTarget ?? null,\n };\n this._boundKeyDown = this._handleKeyDown.bind(this);\n }\n\n private _getFocusableElements(): HTMLElement[] {\n return Array.from(this._container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)).filter(isTabbable);\n }\n\n private _resolveInertTarget(): HTMLElement | null {\n const target = this._options.inertTarget;\n if (!target) return null;\n return typeof target === 'string' ? document.querySelector<HTMLElement>(target) : target;\n }\n\n public activate(): void {\n if (this._isActive) return;\n\n this._previousActiveElement = document.activeElement as HTMLElement;\n this._focusableElements = this._getFocusableElements();\n\n if (this._focusableElements.length > 0) {\n this._firstFocusableElement = this._focusableElements[0] ?? null;\n this._firstFocusableElement?.focus();\n } else {\n this._container.setAttribute('tabindex', '-1');\n this._container.focus();\n this._firstFocusableElement = this._container;\n }\n\n this._container.addEventListener('keydown', this._boundKeyDown);\n\n this._inertTarget = this._resolveInertTarget();\n if (this._inertTarget) this._inertTarget.inert = true;\n\n this._isActive = true;\n }\n\n public deactivate(): void {\n if (!this._isActive) return;\n\n this._container.removeEventListener('keydown', this._boundKeyDown);\n\n if (this._inertTarget) this._inertTarget.inert = false;\n this._inertTarget = null;\n\n if (this._container.getAttribute('tabindex') === '-1') {\n this._container.removeAttribute('tabindex');\n }\n\n if (this._options.returnFocusOnDeactivate && this._previousActiveElement?.focus) {\n this._previousActiveElement.focus();\n }\n\n this._focusableElements = null;\n this._firstFocusableElement = null;\n this._previousActiveElement = null;\n\n this._isActive = false;\n }\n\n public getIsActive(): boolean {\n return this._isActive;\n }\n\n public updateFocusableElements(): void {\n if (!this._isActive) return;\n\n this._focusableElements = this._getFocusableElements();\n\n if (this._focusableElements.length > 0) {\n this._firstFocusableElement = this._focusableElements[0] ?? null;\n }\n }\n\n private _handleKeyDown(event: KeyboardEvent): void {\n switch (event.key) {\n case 'Tab':\n this._handleTabKey(event);\n break;\n case 'Escape':\n if (this._options.escapeDeactivates) {\n event.preventDefault();\n this._options.onDeactivate?.();\n }\n break;\n }\n }\n\n /**\n * Drives every Tab/Shift+Tab press manually instead of only intercepting\n * at the first/last boundary and otherwise trusting the browser's native\n * tab order to match `_focusableElements`' DOM order. Safari on macOS, by\n * default, excludes buttons/links from the native Tab order entirely (only\n * text inputs get native tab stops) — so a boundary-only trap can let\n * focus silently escape once native Tab skips past what this class thinks\n * is the last focusable element. Owning every Tab press removes that\n * dependency on any browser's native tab-stop behavior altogether.\n */\n private _handleTabKey(event: KeyboardEvent): void {\n // Re-queried on every press, so content added/removed/shown/hidden\n // inside the trap after activation is always reachable (and nothing\n // stale is).\n this.updateFocusableElements();\n if (!this._focusableElements || this._focusableElements.length === 0) {\n event.preventDefault(); // nothing to move to — keep focus on the container rather than letting it escape\n return;\n }\n\n event.preventDefault();\n\n const elements = this._focusableElements;\n const currentIndex = elements.indexOf(document.activeElement as HTMLElement);\n\n const nextIndex = event.shiftKey\n ? currentIndex <= 0\n ? elements.length - 1\n : currentIndex - 1\n : currentIndex === -1 || currentIndex === elements.length - 1\n ? 0\n : currentIndex + 1;\n\n elements[nextIndex]?.focus();\n }\n}\n","function toMs(value: string): number {\n const n = parseFloat(value);\n if (Number.isNaN(n)) return 0;\n return value.trim().endsWith('ms') ? n : n * 1000;\n}\n\n/** Longest `transition-duration + transition-delay` pair currently computed for `el`, in ms. */\nfunction longestTransitionMs(el: Element): number {\n const style = getComputedStyle(el);\n const durations = style.transitionDuration.split(',').map(toMs);\n const delays = style.transitionDelay.split(',').map(toMs);\n return durations.reduce((max, d, i) => Math.max(max, d + (delays[i % delays.length] ?? 0)), 0);\n}\n\n/**\n * Calls `done` once `el`'s own close transition has finished, and returns a\n * function that cancels the wait (without calling `done`).\n *\n * A bare `transitionend` listener isn't enough on its own:\n * - it never fires when there's no transition at all — the default\n * stylesheet not loaded, a `0s` duration, or a reduced-motion reset\n * (`transition: none`) — which would leave the overlay stuck half-closed;\n * - it bubbles, so a descendant's unrelated transition (e.g. a hovered\n * button's background fade) would end the wait early.\n *\n * So: no computed transition → `done` runs synchronously; otherwise the\n * first `transitionend` targeting `el` itself, with a timeout fallback\n * slightly past the computed duration in case the event is never delivered.\n */\nexport function whenTransitionDone(el: Element, done: () => void): () => void {\n const ms = longestTransitionMs(el);\n if (ms <= 0) {\n done();\n return () => {};\n }\n\n let settled = false;\n const settle = (run: boolean): void => {\n if (settled) return;\n settled = true;\n el.removeEventListener('transitionend', onEnd);\n clearTimeout(timer);\n if (run) done();\n };\n const onEnd = (e: Event): void => {\n if (e.target === el) settle(true);\n };\n\n el.addEventListener('transitionend', onEnd);\n const timer = setTimeout(() => settle(true), ms + 50);\n return () => settle(false);\n}\n","import { A11yOverlayElement } from '../../core/a11y-overlay-element.js';\nimport { FocusTrapHelper, type IFocusTrapOptions } from '../../core/focus-trap.js';\nimport { whenTransitionDone } from '../../core/transition.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 ? document.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 = document.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 document.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 requestAnimationFrame(() => wrapper.classList.add('a11y-is-open'));\n if (!this._isShowing) this._onShown();\n }\n\n protected override _hide(opts?: { immediate?: boolean }): void {\n this._unbindActiveListeners();\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(document.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(): void {\n this._focusTrap?.deactivate();\n this._focusTrap = null;\n this._unbindDismissListeners();\n this._unbindRepositionListeners();\n }\n\n private _teardownChrome(): void {\n this._unbindActiveListeners();\n this._moveSelfTo(document.body);\n this._wrapper?.remove();\n this._wrapper = null;\n }\n\n protected _focusTrapOptions(): IFocusTrapOptions {\n return { onDeactivate: () => this.close() };\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 = document.documentElement.clientWidth;\n const viewportHeight = document.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 this.close();\n };\n // Deferred so the same click/tap that opened the overlay doesn't immediately close it.\n this._outsideClickTimer = setTimeout(() => {\n document.addEventListener('click', this._boundOutsideClick!);\n }, 0);\n\n if (!this.wantsFocusTrap()) {\n this._boundKeyDown = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') this.close();\n };\n document.addEventListener('keydown', this._boundKeyDown);\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 document.removeEventListener('click', this._boundOutsideClick);\n this._boundOutsideClick = null;\n }\n if (this._boundKeyDown) {\n document.removeEventListener('keydown', this._boundKeyDown);\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","import { A11yAnchoredOverlayElement } from '../core/a11y-anchored-overlay-element.js';\n\n/**\n * Content anchored to a trigger element. `interactive` controls both the\n * ARIA role (`dialog` vs `region`) and whether it traps focus by default —\n * an explicit `trap-focus`/`trap-focus=\"false\"` attribute always wins over\n * that default.\n *\n * ```html\n * <button id=\"info-btn\">Info</button>\n * <a11y-popover anchor=\"info-btn\" interactive><p>…</p></a11y-popover>\n * ```\n */\nexport class PopoverElement extends A11yAnchoredOverlayElement {\n static override get observedAttributes(): string[] {\n return [...super.observedAttributes, 'interactive', 'trap-focus'];\n }\n\n onClose?: () => void;\n\n protected override wantsFocusTrap(): boolean {\n // A plain boolean attribute can only express \"force true\" via presence —\n // this needs tri-state (unset / force true / force false) to let an\n // explicit trap-focus=\"false\" win over interactive, so it's read by value.\n const explicit = this.getAttribute('trap-focus');\n if (explicit !== null) return explicit !== 'false';\n return this.boolAttr('interactive');\n }\n\n protected override createWrapper(): HTMLElement {\n const el = super.createWrapper();\n el.classList.add('a11y-popover-wrapper');\n el.setAttribute('role', this.boolAttr('interactive') ? 'dialog' : 'region');\n return el;\n }\n\n protected override getContentClass(): string {\n return 'a11y-popover-content';\n }\n\n protected override _onHidden(name?: string): void {\n super._onHidden(name);\n this.onClose?.();\n }\n}\n","import { PopoverElement } from './popover.element.js';\n\nif (!customElements.get('a11y-popover')) {\n customElements.define('a11y-popover', PopoverElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-popover': PopoverElement;\n }\n}\n\nexport { PopoverElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach it too.\nexport { dismissAllOverlays } from '../../core/overlay-registry.js';\n"],"mappings":";AAuBO,IAAe,cAAf,cAAmC,YAAY;AAAA,EAC1C,aAAa;AAAA,EACf,aAAyB,CAAC;AAAA,EAC1B,YAAY;AAAA,EAEpB,oBAA0B;AACxB,SAAK,aAAa;AAClB,SAAK,OAAO;AAAA,EACd;AAAA,EAEA,uBAA6B;AAC3B,SAAK,aAAa;AAClB,SAAK,kBAAkB;AACvB,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,yBAAyB,OAAe,UAAyB,UAA+B;AAC9F,QAAI,aAAa,YAAY,CAAC,KAAK,WAAY;AAC/C,SAAK,OAAO;AAAA,EACd;AAAA,EAEU,SAAe;AAGvB,QAAI,KAAK,UAAW;AACpB,SAAK,YAAY;AACjB,QAAI;AACF,WAAK,kBAAkB;AACvB,WAAK,iBAAiB;AACtB,WAAK,YAAY,OAAO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,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/overlay-registry.ts","../../../../src/core/a11y-overlay-element.ts","../../../../src/core/focus-trap.ts","../../../../src/core/transition.ts","../../../../src/overlays/core/a11y-anchored-overlay-element.ts","../../../../src/overlays/popover/popover.element.ts","../../../../src/overlays/popover/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","export interface OverlayOpenCloseDetail {\n name: string;\n}\n\nexport const OVERLAY_OPEN_EVENT = 'a11y-overlay-open';\nexport const OVERLAY_CLOSE_EVENT = 'a11y-overlay-close';\n\ninterface Dismissible {\n close(): 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}\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] ??= { openOverlays: new Set(), scrollLocks: 0, portalOrigins: new Map() });\n// A state object created by an older bundle on the same page predates this field.\nstate.portalOrigins ??= new Map();\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\nexport function dismissAllOverlays(): void {\n for (const overlay of Array.from(state.openOverlays)) overlay.close();\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 let removed = 0;\n for (const [overlay, origin] of Array.from(state.portalOrigins)) {\n if (!host.contains(origin)) continue;\n overlay.remove(); // its disconnectedCallback tears it down and forgets it\n state.portalOrigins.delete(overlay);\n removed++;\n }\n return removed;\n}\n\nconst NO_SCROLL_CLASS = 'a11y-no-scroll';\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 */\nexport function lockScroll(): void {\n if (state.scrollLocks++ === 0) document.documentElement.classList.add(NO_SCROLL_CLASS);\n}\n\nexport function unlockScroll(): void {\n if (state.scrollLocks === 0) return;\n if (--state.scrollLocks === 0) document.documentElement.classList.remove(NO_SCROLL_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` now dispatches these uniformly on `document`.\n */\nexport function emitOverlayOpen(name: string): boolean {\n return document.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(OVERLAY_OPEN_EVENT, { bubbles: true, detail: { name } }),\n );\n}\n\nexport function emitOverlayClose(name: string): boolean {\n return document.dispatchEvent(\n new CustomEvent<OverlayOpenCloseDetail>(OVERLAY_CLOSE_EVENT, { bubbles: true, detail: { name } }),\n );\n}\n","import { A11yElement } from './a11y-element.js';\nimport {\n registerOpenOverlay,\n unregisterOpenOverlay,\n emitOverlayOpen,\n emitOverlayClose,\n recordPortalOrigin,\n forgetPortalOrigin,\n} from './overlay-registry.js';\n\n/**\n * Base for the overlay family (modal, drawer, popover, tooltip, snackbar,\n * blocking-loader, …). Declarative-first: the `open` attribute/property is\n * the primary interface — `<a11y-modal open>` behaves like native\n * `<dialog open>` — with `show()`/`close()` as thin convenience wrappers\n * around that same attribute, not a separate imperative lifecycle.\n *\n * Unlike `A11yElement`, this base does **not** drive `innerHTML` from a\n * `render()` string on every attribute change: many overlays (modal, popover,\n * tooltip) wrap real consumer-authored light-DOM children as their content,\n * and blowing away `innerHTML` would destroy that content. Instead, each\n * concrete overlay is fully responsible for its own DOM in `_show()`/`_hide()`\n * — some build/replace generated markup (blocking-loader), some wrap existing\n * children in backdrop/wrapper chrome (modal), some manage a list of\n * programmatically-created items (snackbar). `_onShown()`/`_onHidden()` are\n * the small pieces of behavior every overlay needs regardless: standardized\n * `a11y-overlay-open`/`a11y-overlay-close` events (the old code only fired\n * its equivalent inconsistently — 4 of 10 overlays) and registration with\n * the dismiss-all registry.\n *\n * Body-mounting: on connect, the element moves itself to be a direct child\n * of `document.body` if it isn't already — matching the old framework's\n * constructor-time force-mount — so a `position: fixed` backdrop/wrapper\n * isn't clipped or offset by an ancestor's `overflow`/`transform`. This\n * happens once, independent of `open`/`_show()`/`_hide()` churn. The\n * parent it left is recorded, so `removeOverlaysWithin(host)` can remove it\n * along with the subtree it was authored in.\n *\n * **Reparenting `this`** (modal/anchored overlays move `this` into\n * wrapper/backdrop chrome they build): moving an already-connected custom\n * element to a *different* parent — even one that's also already connected —\n * still fires `disconnectedCallback` then `connectedCallback` again (the DOM\n * spec's insertion algorithm removes-then-inserts when a node already has a\n * parent; this is not specific to jsdom). Left unguarded, that nested\n * `connectedCallback` calls `_show()` again while the outer `_show()` call\n * that triggered the move is still on the stack — infinite recursion (a real\n * bug this hit once). Subclasses must move `this` via `_moveSelfTo()` below,\n * never a raw `appendChild`/`insertBefore` — it suppresses exactly that\n * reentrant churn.\n */\nexport abstract class A11yOverlayElement extends A11yElement {\n static get observedAttributes(): string[] {\n return ['open'];\n }\n\n protected _isShowing = false;\n /**\n * True while `disconnectedCallback` tears down an overlay the consumer\n * removed from the document — `_hide()` implementations must then leave\n * `this` detached instead of moving it back to `document.body`.\n */\n protected _detaching = false;\n private _internalMove = false;\n\n get open(): boolean {\n return this.boolAttr('open');\n }\n\n set open(value: boolean) {\n this.setBoolAttr('open', value);\n }\n\n override connectedCallback(): void {\n if (this._internalMove) return; // reparented by our own _moveSelfTo() — not a real connect event\n this._initConnect();\n this._connected = true;\n this._portalToBody();\n this.onConnect?.();\n if (!this.open) return;\n // `<a11y-modal open>` upgraded mid-parse (define script loaded\n // synchronously ahead of the markup) connects before its children are\n // parsed — defer the initial show until the document is, so `_show()`\n // sees the real content (heading, focusable elements).\n if (document.readyState === 'loading') this.afterParse(() => this._showIfStillOpen());\n else this._show();\n }\n\n override disconnectedCallback(): void {\n if (this._internalMove) return; // reparented by our own _moveSelfTo() — not a real disconnect event\n if (this._isShowing) {\n this._detaching = true;\n try {\n this._hide({ immediate: true });\n } finally {\n this._detaching = false;\n }\n }\n unregisterOpenOverlay(this);\n forgetPortalOrigin(this);\n super.disconnectedCallback();\n }\n\n override attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n if (name !== 'open') {\n this.onAttributeChanged?.(name);\n return;\n }\n if (newValue !== null) this._show();\n else this._hide();\n }\n\n /**\n * Runs on every *real* connect (not the internal reparenting `_moveSelfTo()`\n * does) — the counterpart of `onDisconnect()`. Subclasses wire anchor/\n * trigger listeners here rather than overriding `connectedCallback`.\n */\n protected onConnect?(): void;\n\n /** Called for every observed attribute other than `open` that changes while connected. */\n protected onAttributeChanged?(name: string): void;\n\n /** Runs `callback` once the document has finished parsing (never, if it already has — call sites handle that case directly). */\n protected afterParse(callback: () => void): void {\n if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', callback, { once: true });\n }\n\n private _showIfStillOpen(): void {\n if (this._connected && this.open && !this._isShowing) this._show();\n }\n\n /** Convenience wrapper — identical to `element.open = true`. */\n show(): void {\n this.open = true;\n }\n\n /** Convenience wrapper — identical to `element.open = false`. */\n close(): void {\n this.open = false;\n }\n\n private _portalToBody(): void {\n const origin = this.parentNode;\n if (origin === document.body) return;\n this._moveSelfTo(document.body);\n if (origin instanceof Element) recordPortalOrigin(this, origin);\n }\n\n /**\n * Moves `this` to be the last child of `newParent`, suppressing the\n * connected/disconnected lifecycle churn that a plain `appendChild` would\n * trigger (see the class doc). Use this — never a raw `appendChild`/\n * `insertBefore` on `this` — anywhere a subclass reparents itself while\n * building or tearing down wrapper/backdrop chrome.\n */\n protected _moveSelfTo(newParent: Node): void {\n this._internalMove = true;\n try {\n newParent.appendChild(this);\n } finally {\n this._internalMove = false;\n }\n }\n\n /** Build/animate in whatever DOM this overlay needs, then call `_onShown()`. */\n protected abstract _show(): void;\n\n /**\n * Tear down this overlay's DOM, then call `_onHidden()`. Implementations\n * should gate real removal on a `transitionend` event (not a timeout) to\n * match the CSS-driven animate-out contract, except when `immediate` is\n * set (used when the element is forcibly removed from the document while\n * still open — no animation to wait for).\n */\n protected abstract _hide(opts?: { immediate?: boolean }): void;\n\n protected _onShown(name: string = this.tagName.toLowerCase()): void {\n this._isShowing = true;\n registerOpenOverlay(this);\n emitOverlayOpen(name);\n }\n\n protected _onHidden(name: string = this.tagName.toLowerCase()): void {\n this._isShowing = false;\n unregisterOpenOverlay(this);\n emitOverlayClose(name);\n }\n\n /**\n * Unused by overlays — content is managed explicitly by each concrete\n * overlay in `_show()`/`_hide()`, never auto-replaced from a template\n * string, so that consumer-authored light-DOM children survive. Present\n * only to satisfy `A11yElement`'s abstract contract.\n */\n protected override render(): string {\n return '';\n }\n}\n","type KeyboardEventHandler = (event: KeyboardEvent) => void;\n\n/** Everything that can be a Tab stop; `isTabbable()` then drops what's hidden or has a negative `tabindex`. */\nconst FOCUSABLE_SELECTOR = [\n 'a[href]',\n 'area[href]',\n 'button:not(:disabled)',\n 'input:not(:disabled):not([type=\"hidden\"])',\n 'select:not(:disabled)',\n 'textarea:not(:disabled)',\n 'details > summary:first-of-type',\n 'iframe',\n 'audio[controls]',\n 'video[controls]',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]',\n].join(', ');\n\nexport interface IFocusTrapOptions {\n escapeDeactivates?: boolean;\n returnFocusOnDeactivate?: boolean;\n onDeactivate?: () => void;\n /**\n * An element (or selector resolving to one) to mark `inert` while the trap\n * is active, so assistive tech can't reach content behind the trap.\n * Defaults to `null` (no side effect) — the old implementation hardcoded\n * `document.querySelector('#app')`, which assumed every consumer had a\n * single a11y-shell element with that exact id. A library meant to be\n * dropped into arbitrary HTML can't assume that, so this is opt-in.\n */\n inertTarget?: HTMLElement | string | null;\n}\n\nexport interface IFocusTrapHelperParams {\n container: HTMLElement;\n options?: IFocusTrapOptions;\n}\n\n/**\n * Whether a selector-matched element can actually take focus right now:\n * not inside a `hidden`/`inert` subtree, and (where the browser supports\n * `checkVisibility()`) actually rendered — `display: none`, `visibility:\n * hidden` or a collapsed `<details>` would otherwise become a Tab stop\n * that silently swallows the key press.\n */\nfunction isTabbable(el: HTMLElement): boolean {\n // A negative tabindex takes even a native control out of the Tab order.\n if (Number(el.getAttribute('tabindex')) < 0) return false;\n if (el.closest('[hidden], [inert]')) return false;\n if (typeof el.checkVisibility === 'function') return el.checkVisibility({ visibilityProperty: true });\n return true;\n}\n\ninterface PointerState {\n /** The focusable element (or its closest focusable ancestor) the pointer last pressed. */\n lastPressed: HTMLElement | null;\n listening: boolean;\n}\n\n/**\n * Safari (and Firefox on macOS) don't focus a button or link on click, so an\n * overlay opened from a click sees `document.activeElement === <body>` and\n * would have nowhere to return focus. One capture-phase `pointerdown`\n * listener, shared page-wide like the trap stack below, remembers the\n * focusable element that was pressed instead.\n */\nconst POINTER_KEY = Symbol.for('a11y-elements/last-pressed');\nconst pointerStore = globalThis as unknown as Record<symbol, PointerState | undefined>;\nconst pointerState: PointerState = (pointerStore[POINTER_KEY] ??= { lastPressed: null, listening: false });\nif (!pointerState.listening && typeof document !== 'undefined') {\n pointerState.listening = true;\n document.addEventListener(\n 'pointerdown',\n (event) => {\n const target = event.target instanceof Element ? event.target : null;\n pointerState.lastPressed = target?.closest<HTMLElement>(FOCUSABLE_SELECTOR) ?? null;\n },\n true,\n );\n}\n\n/**\n * Where focus should go back to when an overlay that's opening now closes:\n * the focused element, or — when that's just `<body>` because the browser\n * didn't focus a clicked trigger — the element that was last pressed.\n */\nexport function focusReturnTarget(): HTMLElement | null {\n const active = document.activeElement as HTMLElement | null;\n if (active && active !== document.body && active !== document.documentElement) return active;\n const pressed = pointerState.lastPressed;\n return pressed?.isConnected ? pressed : active;\n}\n\n/**\n * Page-wide stack of active traps, on `globalThis` for the same reason as\n * `overlay-registry.ts`' state: each standalone browser bundle inlines its\n * own copy of this module. Only the top trap handles keys, so stacked\n * overlays (a modal opened from a modal) don't both react to one Escape.\n */\nconst STACK_KEY = Symbol.for('a11y-elements/focus-trap-stack');\nconst stackStore = globalThis as unknown as Record<symbol, FocusTrapHelper[] | undefined>;\nconst activeTraps: FocusTrapHelper[] = (stackStore[STACK_KEY] ??= []);\n\nexport class FocusTrapHelper {\n private _container: HTMLElement;\n private _previousActiveElement: HTMLElement | null = null;\n private _focusableElements: HTMLElement[] | null = null;\n private _firstFocusableElement: HTMLElement | null = null;\n private _boundKeyDown: KeyboardEventHandler;\n private _options: IFocusTrapOptions;\n private _inertTarget: HTMLElement | null = null;\n private _isActive = false;\n\n constructor({ container, options = {} }: IFocusTrapHelperParams) {\n this._container = container;\n this._options = {\n escapeDeactivates: options.escapeDeactivates ?? true,\n returnFocusOnDeactivate: options.returnFocusOnDeactivate ?? true,\n onDeactivate: options.onDeactivate,\n inertTarget: options.inertTarget ?? null,\n };\n this._boundKeyDown = this._handleKeyDown.bind(this);\n }\n\n private _getFocusableElements(): HTMLElement[] {\n return Array.from(this._container.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)).filter(isTabbable);\n }\n\n private _resolveInertTarget(): HTMLElement | null {\n const target = this._options.inertTarget;\n if (!target) return null;\n return typeof target === 'string' ? document.querySelector<HTMLElement>(target) : target;\n }\n\n public activate(): void {\n if (this._isActive) return;\n\n this._previousActiveElement = focusReturnTarget();\n this._focusableElements = this._getFocusableElements();\n\n if (this._focusableElements.length > 0) {\n this._firstFocusableElement = this._focusableElements[0] ?? null;\n this._firstFocusableElement?.focus();\n } else {\n this._container.setAttribute('tabindex', '-1');\n this._container.focus();\n this._firstFocusableElement = this._container;\n }\n\n // On `document`, not the container: clicking non-focusable content inside\n // the trap (text, padding) moves focus to <body>, and a container\n // listener would then never see Escape/Tab again.\n document.addEventListener('keydown', this._boundKeyDown);\n activeTraps.push(this);\n\n this._inertTarget = this._resolveInertTarget();\n if (this._inertTarget) this._inertTarget.inert = true;\n\n this._isActive = true;\n }\n\n public deactivate(): void {\n if (!this._isActive) return;\n\n document.removeEventListener('keydown', this._boundKeyDown);\n const index = activeTraps.indexOf(this);\n if (index !== -1) activeTraps.splice(index, 1);\n\n if (this._inertTarget) this._inertTarget.inert = false;\n this._inertTarget = null;\n\n if (this._container.getAttribute('tabindex') === '-1') {\n this._container.removeAttribute('tabindex');\n }\n\n if (this._options.returnFocusOnDeactivate && this._previousActiveElement?.focus) {\n this._previousActiveElement.focus();\n }\n\n this._focusableElements = null;\n this._firstFocusableElement = null;\n this._previousActiveElement = null;\n\n this._isActive = false;\n }\n\n public getIsActive(): boolean {\n return this._isActive;\n }\n\n public updateFocusableElements(): void {\n if (!this._isActive) return;\n\n this._focusableElements = this._getFocusableElements();\n\n if (this._focusableElements.length > 0) {\n this._firstFocusableElement = this._focusableElements[0] ?? null;\n }\n }\n\n /**\n * Whether this trap should handle `event`: it must be the topmost trap, and\n * the key press must come from inside it — or from <body>/<html>, where\n * focus lands after a click on non-focusable content inside the trap. A key\n * press from elsewhere (e.g. a non-trapping dropdown opened above a modal)\n * is left alone.\n */\n private _ownsEvent(event: KeyboardEvent): boolean {\n if (activeTraps[activeTraps.length - 1] !== this) return false;\n const target = event.target as Node | null;\n return (\n !target ||\n target === document ||\n target === document.body ||\n target === document.documentElement ||\n this._container.contains(target)\n );\n }\n\n private _handleKeyDown(event: KeyboardEvent): void {\n if (!this._ownsEvent(event)) return;\n switch (event.key) {\n case 'Tab':\n this._handleTabKey(event);\n break;\n case 'Escape':\n if (this._options.escapeDeactivates) {\n event.preventDefault();\n this._options.onDeactivate?.();\n }\n break;\n }\n }\n\n /**\n * Drives every Tab/Shift+Tab press manually instead of only intercepting\n * at the first/last boundary and otherwise trusting the browser's native\n * tab order to match `_focusableElements`' DOM order. Safari on macOS, by\n * default, excludes buttons/links from the native Tab order entirely (only\n * text inputs get native tab stops) — so a boundary-only trap can let\n * focus silently escape once native Tab skips past what this class thinks\n * is the last focusable element. Owning every Tab press removes that\n * dependency on any browser's native tab-stop behavior altogether.\n */\n private _handleTabKey(event: KeyboardEvent): void {\n // Re-queried on every press, so content added/removed/shown/hidden\n // inside the trap after activation is always reachable (and nothing\n // stale is).\n this.updateFocusableElements();\n if (!this._focusableElements || this._focusableElements.length === 0) {\n event.preventDefault(); // nothing to move to — keep focus on the container rather than letting it escape\n return;\n }\n\n event.preventDefault();\n\n const elements = this._focusableElements;\n const currentIndex = elements.indexOf(document.activeElement as HTMLElement);\n\n const nextIndex = event.shiftKey\n ? currentIndex <= 0\n ? elements.length - 1\n : currentIndex - 1\n : currentIndex === -1 || currentIndex === elements.length - 1\n ? 0\n : currentIndex + 1;\n\n elements[nextIndex]?.focus();\n }\n}\n","function toMs(value: string): number {\n const n = parseFloat(value);\n if (Number.isNaN(n)) return 0;\n return value.trim().endsWith('ms') ? n : n * 1000;\n}\n\n/** Longest `transition-duration + transition-delay` pair currently computed for `el`, in ms. */\nfunction longestTransitionMs(el: Element): number {\n const style = getComputedStyle(el);\n const durations = style.transitionDuration.split(',').map(toMs);\n const delays = style.transitionDelay.split(',').map(toMs);\n return durations.reduce((max, d, i) => Math.max(max, d + (delays[i % delays.length] ?? 0)), 0);\n}\n\n/**\n * Calls `done` once `el`'s own close transition has finished, and returns a\n * function that cancels the wait (without calling `done`).\n *\n * A bare `transitionend` listener isn't enough on its own:\n * - it never fires when there's no transition at all — the default\n * stylesheet not loaded, a `0s` duration, or a reduced-motion reset\n * (`transition: none`) — which would leave the overlay stuck half-closed;\n * - it bubbles, so a descendant's unrelated transition (e.g. a hovered\n * button's background fade) would end the wait early.\n *\n * So: no computed transition → `done` runs synchronously; otherwise the\n * first `transitionend` targeting `el` itself, with a timeout fallback\n * slightly past the computed duration in case the event is never delivered.\n */\nexport function whenTransitionDone(el: Element, done: () => void): () => void {\n const ms = longestTransitionMs(el);\n if (ms <= 0) {\n done();\n return () => {};\n }\n\n let settled = false;\n const settle = (run: boolean): void => {\n if (settled) return;\n settled = true;\n el.removeEventListener('transitionend', onEnd);\n clearTimeout(timer);\n if (run) done();\n };\n const onEnd = (e: Event): void => {\n if (e.target === el) settle(true);\n };\n\n el.addEventListener('transitionend', onEnd);\n const timer = setTimeout(() => settle(true), ms + 50);\n return () => settle(false);\n}\n","import { A11yOverlayElement } from '../../core/a11y-overlay-element.js';\nimport { FocusTrapHelper, type IFocusTrapOptions } from '../../core/focus-trap.js';\nimport { whenTransitionDone } from '../../core/transition.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 ? document.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 = document.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 document.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 requestAnimationFrame(() => wrapper.classList.add('a11y-is-open'));\n if (!this._isShowing) this._onShown();\n }\n\n protected override _hide(opts?: { immediate?: boolean }): void {\n this._unbindActiveListeners();\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(document.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(): void {\n this._focusTrap?.deactivate();\n this._focusTrap = null;\n this._unbindDismissListeners();\n this._unbindRepositionListeners();\n }\n\n private _teardownChrome(): void {\n this._unbindActiveListeners();\n this._moveSelfTo(document.body);\n this._wrapper?.remove();\n this._wrapper = null;\n }\n\n protected _focusTrapOptions(): IFocusTrapOptions {\n return { onDeactivate: () => this.close() };\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 = document.documentElement.clientWidth;\n const viewportHeight = document.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 this.close();\n };\n // Deferred so the same click/tap that opened the overlay doesn't immediately close it.\n this._outsideClickTimer = setTimeout(() => {\n document.addEventListener('click', this._boundOutsideClick!);\n }, 0);\n\n if (!this.wantsFocusTrap()) {\n this._boundKeyDown = (e: KeyboardEvent): void => {\n if (e.key === 'Escape') this.close();\n };\n document.addEventListener('keydown', this._boundKeyDown);\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 document.removeEventListener('click', this._boundOutsideClick);\n this._boundOutsideClick = null;\n }\n if (this._boundKeyDown) {\n document.removeEventListener('keydown', this._boundKeyDown);\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","import { A11yAnchoredOverlayElement } from '../core/a11y-anchored-overlay-element.js';\n\n/**\n * Content anchored to a trigger element. `interactive` controls both the\n * ARIA role (`dialog` vs `region`) and whether it traps focus by default —\n * an explicit `trap-focus`/`trap-focus=\"false\"` attribute always wins over\n * that default.\n *\n * ```html\n * <button id=\"info-btn\">Info</button>\n * <a11y-popover anchor=\"info-btn\" interactive><p>…</p></a11y-popover>\n * ```\n */\nexport class PopoverElement extends A11yAnchoredOverlayElement {\n static override get observedAttributes(): string[] {\n return [...super.observedAttributes, 'interactive', 'trap-focus'];\n }\n\n declare onClose?: () => void;\n\n protected override wantsFocusTrap(): boolean {\n // A plain boolean attribute can only express \"force true\" via presence —\n // this needs tri-state (unset / force true / force false) to let an\n // explicit trap-focus=\"false\" win over interactive, so it's read by value.\n const explicit = this.getAttribute('trap-focus');\n if (explicit !== null) return explicit !== 'false';\n return this.boolAttr('interactive');\n }\n\n protected override createWrapper(): HTMLElement {\n const el = super.createWrapper();\n el.classList.add('a11y-popover-wrapper');\n el.setAttribute('role', this.boolAttr('interactive') ? 'dialog' : 'region');\n return el;\n }\n\n protected override getContentClass(): string {\n return 'a11y-popover-content';\n }\n\n protected override _onHidden(name?: string): void {\n super._onHidden(name);\n this.onClose?.();\n }\n}\n","import { PopoverElement } from './popover.element.js';\n\nif (!customElements.get('a11y-popover')) {\n customElements.define('a11y-popover', PopoverElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-popover': PopoverElement;\n }\n}\n\nexport { PopoverElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\nexport { dismissAllOverlays, removeOverlaysWithin } from '../../core/overlay-registry.js';\n"],"mappings":";AA8BO,IAAM,kBAAyC,OAAO,OAAO;AAAA,EAClE,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AACtB,CAAC;AAGM,IAAM,uBAAuB;AAQpC,IAAM,cAAc,uBAAO,IAAI,uBAAuB;AACtD,IAAM,QAAQ;AACd,IAAM,UAAwB,MAAM,WAAW,MAAM,EAAE,GAAG,gBAAgB;AAE1E,WAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,eAAe,EAAoC,SAAQ,GAAG,MAAM;AAGvG,SAAS,WAAW,SAAqC;AAC9D,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QA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