a11y-elements 0.1.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 (222) hide show
  1. package/LICENSE.txt +22 -0
  2. package/README.md +141 -0
  3. package/dist/a11y.css +1019 -0
  4. package/dist/accessibility-components/anchor/anchor.element.d.ts +28 -0
  5. package/dist/accessibility-components/anchor/anchor.element.js +87 -0
  6. package/dist/accessibility-components/anchor/anchor.element.js.map +1 -0
  7. package/dist/accessibility-components/anchor/define.d.ts +7 -0
  8. package/dist/accessibility-components/anchor/define.js +6 -0
  9. package/dist/accessibility-components/anchor/define.js.map +1 -0
  10. package/dist/accessibility-components/avatar/avatar.element.d.ts +21 -0
  11. package/dist/accessibility-components/avatar/avatar.element.js +73 -0
  12. package/dist/accessibility-components/avatar/avatar.element.js.map +1 -0
  13. package/dist/accessibility-components/avatar/define.d.ts +7 -0
  14. package/dist/accessibility-components/avatar/define.js +6 -0
  15. package/dist/accessibility-components/avatar/define.js.map +1 -0
  16. package/dist/accessibility-components/checkbox/checkbox.element.d.ts +36 -0
  17. package/dist/accessibility-components/checkbox/checkbox.element.js +79 -0
  18. package/dist/accessibility-components/checkbox/checkbox.element.js.map +1 -0
  19. package/dist/accessibility-components/checkbox/define.d.ts +7 -0
  20. package/dist/accessibility-components/checkbox/define.js +6 -0
  21. package/dist/accessibility-components/checkbox/define.js.map +1 -0
  22. package/dist/accessibility-components/focusable/define.d.ts +7 -0
  23. package/dist/accessibility-components/focusable/define.js +6 -0
  24. package/dist/accessibility-components/focusable/define.js.map +1 -0
  25. package/dist/accessibility-components/focusable/focusable.element.d.ts +30 -0
  26. package/dist/accessibility-components/focusable/focusable.element.js +52 -0
  27. package/dist/accessibility-components/focusable/focusable.element.js.map +1 -0
  28. package/dist/accessibility-components/picture/define.d.ts +7 -0
  29. package/dist/accessibility-components/picture/define.js +6 -0
  30. package/dist/accessibility-components/picture/define.js.map +1 -0
  31. package/dist/accessibility-components/picture/picture.element.d.ts +23 -0
  32. package/dist/accessibility-components/picture/picture.element.js +43 -0
  33. package/dist/accessibility-components/picture/picture.element.js.map +1 -0
  34. package/dist/accessibility-components/progress/define.d.ts +7 -0
  35. package/dist/accessibility-components/progress/define.js +6 -0
  36. package/dist/accessibility-components/progress/define.js.map +1 -0
  37. package/dist/accessibility-components/progress/progress.element.d.ts +20 -0
  38. package/dist/accessibility-components/progress/progress.element.js +44 -0
  39. package/dist/accessibility-components/progress/progress.element.js.map +1 -0
  40. package/dist/accessibility-components/radio-group/define.d.ts +7 -0
  41. package/dist/accessibility-components/radio-group/define.js +6 -0
  42. package/dist/accessibility-components/radio-group/define.js.map +1 -0
  43. package/dist/accessibility-components/radio-group/radio-group.element.d.ts +27 -0
  44. package/dist/accessibility-components/radio-group/radio-group.element.js +82 -0
  45. package/dist/accessibility-components/radio-group/radio-group.element.js.map +1 -0
  46. package/dist/accessibility-components/select/define.d.ts +7 -0
  47. package/dist/accessibility-components/select/define.js +6 -0
  48. package/dist/accessibility-components/select/define.js.map +1 -0
  49. package/dist/accessibility-components/select/select.element.d.ts +25 -0
  50. package/dist/accessibility-components/select/select.element.js +67 -0
  51. package/dist/accessibility-components/select/select.element.js.map +1 -0
  52. package/dist/accessibility-components/skeleton/define.d.ts +7 -0
  53. package/dist/accessibility-components/skeleton/define.js +6 -0
  54. package/dist/accessibility-components/skeleton/define.js.map +1 -0
  55. package/dist/accessibility-components/skeleton/skeleton.element.d.ts +16 -0
  56. package/dist/accessibility-components/skeleton/skeleton.element.js +40 -0
  57. package/dist/accessibility-components/skeleton/skeleton.element.js.map +1 -0
  58. package/dist/accessibility-components/spinner/define.d.ts +7 -0
  59. package/dist/accessibility-components/spinner/define.js +6 -0
  60. package/dist/accessibility-components/spinner/define.js.map +1 -0
  61. package/dist/accessibility-components/spinner/spinner.element.d.ts +21 -0
  62. package/dist/accessibility-components/spinner/spinner.element.js +60 -0
  63. package/dist/accessibility-components/spinner/spinner.element.js.map +1 -0
  64. package/dist/accessibility-components/switch/define.d.ts +7 -0
  65. package/dist/accessibility-components/switch/define.js +6 -0
  66. package/dist/accessibility-components/switch/define.js.map +1 -0
  67. package/dist/accessibility-components/switch/switch.element.d.ts +22 -0
  68. package/dist/accessibility-components/switch/switch.element.js +65 -0
  69. package/dist/accessibility-components/switch/switch.element.js.map +1 -0
  70. package/dist/accessibility-components/visually-hidden/define.d.ts +7 -0
  71. package/dist/accessibility-components/visually-hidden/define.js +6 -0
  72. package/dist/accessibility-components/visually-hidden/define.js.map +1 -0
  73. package/dist/accessibility-components/visually-hidden/visually-hidden.element.d.ts +16 -0
  74. package/dist/accessibility-components/visually-hidden/visually-hidden.element.js +24 -0
  75. package/dist/accessibility-components/visually-hidden/visually-hidden.element.js.map +1 -0
  76. package/dist/browser/accessibility-components/anchor/define.js +192 -0
  77. package/dist/browser/accessibility-components/anchor/define.js.map +1 -0
  78. package/dist/browser/accessibility-components/avatar/define.js +159 -0
  79. package/dist/browser/accessibility-components/avatar/define.js.map +1 -0
  80. package/dist/browser/accessibility-components/checkbox/define.js +186 -0
  81. package/dist/browser/accessibility-components/checkbox/define.js.map +1 -0
  82. package/dist/browser/accessibility-components/focusable/define.js +113 -0
  83. package/dist/browser/accessibility-components/focusable/define.js.map +1 -0
  84. package/dist/browser/accessibility-components/picture/define.js +156 -0
  85. package/dist/browser/accessibility-components/picture/define.js.map +1 -0
  86. package/dist/browser/accessibility-components/progress/define.js +135 -0
  87. package/dist/browser/accessibility-components/progress/define.js.map +1 -0
  88. package/dist/browser/accessibility-components/radio-group/define.js +204 -0
  89. package/dist/browser/accessibility-components/radio-group/define.js.map +1 -0
  90. package/dist/browser/accessibility-components/select/define.js +184 -0
  91. package/dist/browser/accessibility-components/select/define.js.map +1 -0
  92. package/dist/browser/accessibility-components/skeleton/define.js +136 -0
  93. package/dist/browser/accessibility-components/skeleton/define.js.map +1 -0
  94. package/dist/browser/accessibility-components/spinner/define.js +156 -0
  95. package/dist/browser/accessibility-components/spinner/define.js.map +1 -0
  96. package/dist/browser/accessibility-components/switch/define.js +192 -0
  97. package/dist/browser/accessibility-components/switch/define.js.map +1 -0
  98. package/dist/browser/accessibility-components/visually-hidden/define.js +97 -0
  99. package/dist/browser/accessibility-components/visually-hidden/define.js.map +1 -0
  100. package/dist/browser/overlays/blocking-loader/define.js +351 -0
  101. package/dist/browser/overlays/blocking-loader/define.js.map +1 -0
  102. package/dist/browser/overlays/context-menu/define.js +774 -0
  103. package/dist/browser/overlays/context-menu/define.js.map +1 -0
  104. package/dist/browser/overlays/drawer/define.js +529 -0
  105. package/dist/browser/overlays/drawer/define.js.map +1 -0
  106. package/dist/browser/overlays/dropdown/define.js +770 -0
  107. package/dist/browser/overlays/dropdown/define.js.map +1 -0
  108. package/dist/browser/overlays/emergency-dialog/define.js +525 -0
  109. package/dist/browser/overlays/emergency-dialog/define.js.map +1 -0
  110. package/dist/browser/overlays/modal/define.js +523 -0
  111. package/dist/browser/overlays/modal/define.js.map +1 -0
  112. package/dist/browser/overlays/notification-banner/define.js +289 -0
  113. package/dist/browser/overlays/notification-banner/define.js.map +1 -0
  114. package/dist/browser/overlays/popover/define.js +625 -0
  115. package/dist/browser/overlays/popover/define.js.map +1 -0
  116. package/dist/browser/overlays/snackbar/define.js +268 -0
  117. package/dist/browser/overlays/snackbar/define.js.map +1 -0
  118. package/dist/browser/overlays/tooltip/define.js +707 -0
  119. package/dist/browser/overlays/tooltip/define.js.map +1 -0
  120. package/dist/core/a11y-element.d.ts +53 -0
  121. package/dist/core/a11y-element.js +104 -0
  122. package/dist/core/a11y-element.js.map +1 -0
  123. package/dist/core/a11y-form-element.d.ts +23 -0
  124. package/dist/core/a11y-form-element.js +30 -0
  125. package/dist/core/a11y-form-element.js.map +1 -0
  126. package/dist/core/a11y-overlay-element.d.ts +100 -0
  127. package/dist/core/a11y-overlay-element.js +160 -0
  128. package/dist/core/a11y-overlay-element.js.map +1 -0
  129. package/dist/core/a11y-wrapper-element.d.ts +48 -0
  130. package/dist/core/a11y-wrapper-element.js +70 -0
  131. package/dist/core/a11y-wrapper-element.js.map +1 -0
  132. package/dist/core/dom-sync.d.ts +15 -0
  133. package/dist/core/dom-sync.js +30 -0
  134. package/dist/core/dom-sync.js.map +1 -0
  135. package/dist/core/focus-trap.d.ts +47 -0
  136. package/dist/core/focus-trap.js +138 -0
  137. package/dist/core/focus-trap.js.map +1 -0
  138. package/dist/core/index.d.ts +9 -0
  139. package/dist/core/index.js +10 -0
  140. package/dist/core/index.js.map +1 -0
  141. package/dist/core/overlay-registry.d.ts +36 -0
  142. package/dist/core/overlay-registry.js +60 -0
  143. package/dist/core/overlay-registry.js.map +1 -0
  144. package/dist/core/template.d.ts +32 -0
  145. package/dist/core/template.js +48 -0
  146. package/dist/core/template.js.map +1 -0
  147. package/dist/core/transition.d.ts +16 -0
  148. package/dist/core/transition.js +53 -0
  149. package/dist/core/transition.js.map +1 -0
  150. package/dist/overlays/blocking-loader/blocking-loader.element.d.ts +29 -0
  151. package/dist/overlays/blocking-loader/blocking-loader.element.js +77 -0
  152. package/dist/overlays/blocking-loader/blocking-loader.element.js.map +1 -0
  153. package/dist/overlays/blocking-loader/define.d.ts +9 -0
  154. package/dist/overlays/blocking-loader/define.js +10 -0
  155. package/dist/overlays/blocking-loader/define.js.map +1 -0
  156. package/dist/overlays/context-menu/context-menu.element.d.ts +31 -0
  157. package/dist/overlays/context-menu/context-menu.element.js +86 -0
  158. package/dist/overlays/context-menu/context-menu.element.js.map +1 -0
  159. package/dist/overlays/context-menu/define.d.ts +8 -0
  160. package/dist/overlays/context-menu/define.js +8 -0
  161. package/dist/overlays/context-menu/define.js.map +1 -0
  162. package/dist/overlays/core/a11y-anchored-overlay-element.d.ts +68 -0
  163. package/dist/overlays/core/a11y-anchored-overlay-element.js +276 -0
  164. package/dist/overlays/core/a11y-anchored-overlay-element.js.map +1 -0
  165. package/dist/overlays/core/a11y-menu-overlay-element.d.ts +46 -0
  166. package/dist/overlays/core/a11y-menu-overlay-element.js +152 -0
  167. package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -0
  168. package/dist/overlays/core/a11y-modal-overlay-element.d.ts +44 -0
  169. package/dist/overlays/core/a11y-modal-overlay-element.js +163 -0
  170. package/dist/overlays/core/a11y-modal-overlay-element.js.map +1 -0
  171. package/dist/overlays/core/a11y-passive-overlay-element.d.ts +38 -0
  172. package/dist/overlays/core/a11y-passive-overlay-element.js +108 -0
  173. package/dist/overlays/core/a11y-passive-overlay-element.js.map +1 -0
  174. package/dist/overlays/drawer/define.d.ts +8 -0
  175. package/dist/overlays/drawer/define.js +8 -0
  176. package/dist/overlays/drawer/define.js.map +1 -0
  177. package/dist/overlays/drawer/drawer.element.d.ts +19 -0
  178. package/dist/overlays/drawer/drawer.element.js +37 -0
  179. package/dist/overlays/drawer/drawer.element.js.map +1 -0
  180. package/dist/overlays/dropdown/define.d.ts +8 -0
  181. package/dist/overlays/dropdown/define.js +8 -0
  182. package/dist/overlays/dropdown/define.js.map +1 -0
  183. package/dist/overlays/dropdown/dropdown.element.d.ts +30 -0
  184. package/dist/overlays/dropdown/dropdown.element.js +82 -0
  185. package/dist/overlays/dropdown/dropdown.element.js.map +1 -0
  186. package/dist/overlays/emergency-dialog/define.d.ts +8 -0
  187. package/dist/overlays/emergency-dialog/define.js +8 -0
  188. package/dist/overlays/emergency-dialog/define.js.map +1 -0
  189. package/dist/overlays/emergency-dialog/emergency-dialog.element.d.ts +23 -0
  190. package/dist/overlays/emergency-dialog/emergency-dialog.element.js +38 -0
  191. package/dist/overlays/emergency-dialog/emergency-dialog.element.js.map +1 -0
  192. package/dist/overlays/modal/define.d.ts +8 -0
  193. package/dist/overlays/modal/define.js +8 -0
  194. package/dist/overlays/modal/define.js.map +1 -0
  195. package/dist/overlays/modal/modal.element.d.ts +26 -0
  196. package/dist/overlays/modal/modal.element.js +42 -0
  197. package/dist/overlays/modal/modal.element.js.map +1 -0
  198. package/dist/overlays/notification-banner/define.d.ts +14 -0
  199. package/dist/overlays/notification-banner/define.js +26 -0
  200. package/dist/overlays/notification-banner/define.js.map +1 -0
  201. package/dist/overlays/notification-banner/notification-banner.element.d.ts +39 -0
  202. package/dist/overlays/notification-banner/notification-banner.element.js +88 -0
  203. package/dist/overlays/notification-banner/notification-banner.element.js.map +1 -0
  204. package/dist/overlays/popover/define.d.ts +8 -0
  205. package/dist/overlays/popover/define.js +8 -0
  206. package/dist/overlays/popover/define.js.map +1 -0
  207. package/dist/overlays/popover/popover.element.d.ts +20 -0
  208. package/dist/overlays/popover/popover.element.js +41 -0
  209. package/dist/overlays/popover/popover.element.js.map +1 -0
  210. package/dist/overlays/snackbar/define.d.ts +14 -0
  211. package/dist/overlays/snackbar/define.js +26 -0
  212. package/dist/overlays/snackbar/define.js.map +1 -0
  213. package/dist/overlays/snackbar/snackbar.element.d.ts +30 -0
  214. package/dist/overlays/snackbar/snackbar.element.js +61 -0
  215. package/dist/overlays/snackbar/snackbar.element.js.map +1 -0
  216. package/dist/overlays/tooltip/define.d.ts +8 -0
  217. package/dist/overlays/tooltip/define.js +8 -0
  218. package/dist/overlays/tooltip/define.js.map +1 -0
  219. package/dist/overlays/tooltip/tooltip.element.d.ts +41 -0
  220. package/dist/overlays/tooltip/tooltip.element.js +133 -0
  221. package/dist/overlays/tooltip/tooltip.element.js.map +1 -0
  222. package/package.json +93 -0
@@ -0,0 +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/core/a11y-menu-overlay-element.ts","../../../../src/overlays/context-menu/context-menu.element.ts","../../../../src/overlays/context-menu/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 './a11y-anchored-overlay-element.js';\n\n/**\n * Base for menu-shaped anchored overlays (dropdown, context menu): roving\n * tabindex over `[role=\"menuitem\"]` children instead of a focus trap, with\n * Arrow/Home/End navigation and Enter/Space activating the focused item.\n *\n * Items are the consumer's own light-DOM children — no `MenuItem[]`/\n * `onSelect` config to keep in sync. Each item is a real element the\n * consumer can attach their own `click` listener to directly; Enter/Space\n * on the focused item triggers a real synthetic `.click()` on it (same\n * \"keyboard activation = real click\" pattern as `FocusableElement`), and\n * this element auto-closes after any enabled item is clicked, by mouse or\n * keyboard — the one piece of behavior that's still the menu's own to own.\n *\n * Listener (un)binding is manual, not via `this.listen()`: the wrapper is a\n * fresh element built by `_show()` on every open, and `this.listen()`'s\n * cleanup only runs on disconnect — across many open/close cycles that would\n * accumulate dead entries. Binding/unbinding explicitly in `_show()`/`_hide()`\n * (matching `A11yAnchoredOverlayElement`'s own dismiss/reposition listeners)\n * keeps each cycle self-contained.\n *\n * Focus returns to whatever was focused when the menu opened (normally its\n * trigger) when it closes while focus is still inside it — Escape, item\n * activation — but not when focus already moved elsewhere (Tab away, a\n * click on another control).\n */\nexport abstract class A11yMenuOverlayElement extends A11yAnchoredOverlayElement {\n private _boundMenuKeyDown: ((e: KeyboardEvent) => void) | null = null;\n private _boundFocusOut: ((e: FocusEvent) => void) | null = null;\n private _boundClick: ((e: MouseEvent) => void) | null = null;\n private _returnFocusTo: HTMLElement | null = null;\n\n /** Menus always use roving tabindex, never a focus trap. */\n protected override wantsFocusTrap(): boolean {\n return false;\n }\n\n protected override createWrapper(): HTMLElement {\n const el = super.createWrapper();\n el.setAttribute('role', 'menu');\n return el;\n }\n\n protected override _show(): void {\n // Captured once per open cycle (a re-show while already open keeps the original).\n if (!this._returnFocusTo) this._returnFocusTo = document.activeElement as HTMLElement | null;\n this._unbindMenuKeyboardHandling(); // re-shown while open: drop the previous wrapper's handlers\n super._show();\n this._initRovingTabindex();\n this._bindMenuKeyboardHandling();\n this._focusFirstEnabledItem();\n }\n\n protected override _hide(opts?: { immediate?: boolean }): void {\n const focusWasInside = !!this._wrapper?.contains(document.activeElement);\n this._unbindMenuKeyboardHandling(); // before moving focus, so our own focusout handler doesn't fire\n const returnTo = this._returnFocusTo;\n this._returnFocusTo = null;\n if (focusWasInside && returnTo?.isConnected && !this._detaching) returnTo.focus();\n super._hide(opts);\n }\n\n private _items(): HTMLElement[] {\n return Array.from(this.querySelectorAll<HTMLElement>('[role=\"menuitem\"]'));\n }\n\n private _enabledItems(): HTMLElement[] {\n return this._items().filter((el) => el.getAttribute('aria-disabled') !== 'true');\n }\n\n private _initRovingTabindex(): void {\n this._items().forEach((el, i) => el.setAttribute('tabindex', i === 0 ? '0' : '-1'));\n }\n\n private _focusFirstEnabledItem(): void {\n const target = this._enabledItems()[0];\n if (target) {\n target.focus();\n return;\n }\n // Nothing to roving-tabindex onto — fall back to focusing the menu\n // wrapper itself so focus doesn't stay stranded on whatever triggered\n // the menu, mirroring FocusTrapHelper's empty-container fallback.\n if (this._wrapper) {\n this._wrapper.setAttribute('tabindex', '-1');\n this._wrapper.focus();\n }\n }\n\n private _focusItemAt(items: HTMLElement[], index: number): void {\n items.forEach((el) => el.setAttribute('tabindex', '-1'));\n const target = items[index];\n if (!target) return;\n target.setAttribute('tabindex', '0');\n target.focus();\n }\n\n private _bindMenuKeyboardHandling(): void {\n if (!this._wrapper) return;\n const wrapper = this._wrapper;\n\n this._boundMenuKeyDown = (e: KeyboardEvent): void => {\n const items = this._enabledItems();\n if (items.length === 0) return;\n const currentIndex = items.indexOf(document.activeElement as HTMLElement);\n\n switch (e.key) {\n case 'ArrowDown':\n e.preventDefault();\n this._focusItemAt(items, (currentIndex + 1) % items.length);\n break;\n case 'ArrowUp':\n e.preventDefault();\n this._focusItemAt(items, (currentIndex - 1 + items.length) % items.length);\n break;\n case 'Home':\n e.preventDefault();\n this._focusItemAt(items, 0);\n break;\n case 'End':\n e.preventDefault();\n this._focusItemAt(items, items.length - 1);\n break;\n case 'Enter':\n case ' ':\n if (currentIndex >= 0) {\n e.preventDefault();\n items[currentIndex]!.click();\n }\n break;\n }\n };\n\n this._boundFocusOut = (e: FocusEvent): void => {\n const related = e.relatedTarget as Node | null;\n if (related && !wrapper.contains(related)) this.close();\n };\n\n this._boundClick = (e: MouseEvent): void => {\n const item = (e.target as HTMLElement).closest<HTMLElement>('[role=\"menuitem\"]');\n if (item && item.getAttribute('aria-disabled') !== 'true') this.close();\n };\n\n wrapper.addEventListener('keydown', this._boundMenuKeyDown);\n wrapper.addEventListener('focusout', this._boundFocusOut);\n wrapper.addEventListener('click', this._boundClick);\n }\n\n private _unbindMenuKeyboardHandling(): void {\n if (this._wrapper && this._boundMenuKeyDown) this._wrapper.removeEventListener('keydown', this._boundMenuKeyDown);\n if (this._wrapper && this._boundFocusOut) this._wrapper.removeEventListener('focusout', this._boundFocusOut);\n if (this._wrapper && this._boundClick) this._wrapper.removeEventListener('click', this._boundClick);\n this._boundMenuKeyDown = null;\n this._boundFocusOut = null;\n this._boundClick = null;\n }\n}\n","import { A11yMenuOverlayElement } from '../core/a11y-menu-overlay-element.js';\n\n/**\n * A menu that opens at the mouse position on right-click (`contextmenu`) of\n * a trigger element, replacing the browser's native context menu there.\n *\n * ```html\n * <div id=\"canvas\">Right-click me</div>\n * <a11y-context-menu trigger=\"canvas\">\n * <div role=\"menuitem\">Copy</div>\n * <div role=\"menuitem\">Paste</div>\n * </a11y-context-menu>\n * ```\n */\nexport class ContextMenuElement extends A11yMenuOverlayElement {\n static override get observedAttributes(): string[] {\n return [...super.observedAttributes, 'trigger'];\n }\n\n private _triggerEl: HTMLElement | null = null;\n private _boundTriggerEl: HTMLElement | null = null;\n private _boundContextMenu = (e: MouseEvent): void => {\n e.preventDefault();\n this.setAnchorPoint(e.clientX, e.clientY);\n // Re-right-clicking while already open repositions in place rather than\n // no-op'ing (the `open` attribute wouldn't change, so attributeChangedCallback\n // wouldn't fire) — _show() itself already guards on an existing wrapper.\n if (this.open) this._show();\n else this.open = true;\n };\n\n /** The element whose `contextmenu` event opens this menu: an explicit `.triggerElement` property, or the `trigger=\"<id>\"` attribute. */\n get triggerElement(): HTMLElement | null {\n if (this._triggerEl) return this._triggerEl;\n const id = this.getAttribute('trigger');\n return id ? document.getElementById(id) : null;\n }\n\n set triggerElement(el: HTMLElement | null) {\n this._triggerEl = el;\n this._bindTrigger();\n }\n\n protected override onConnect(): void {\n this._bindTrigger();\n // Trigger not parsed yet (menu authored before it, define script loaded synchronously).\n if (!this._boundTriggerEl) this.afterParse(() => this._bindTrigger());\n }\n\n protected override onDisconnect(): void {\n this._unbindTrigger();\n }\n\n protected override onAttributeChanged(name: string): void {\n super.onAttributeChanged(name);\n if (name === 'trigger') this._bindTrigger();\n }\n\n protected override createWrapper(): HTMLElement {\n const el = super.createWrapper();\n el.classList.add('a11y-context-menu-wrapper');\n return el;\n }\n\n protected override getContentClass(): string {\n return 'a11y-context-menu-content';\n }\n\n /** Detaches from the trigger entirely (unlike `close()`, which just hides the current menu — it can still reopen on the next right-click). */\n dispose(): void {\n this._unbindTrigger();\n this.close();\n }\n\n private _bindTrigger(): void {\n const trigger = this.triggerElement;\n if (this._boundTriggerEl === trigger) return;\n this._unbindTrigger();\n if (!trigger) return;\n trigger.addEventListener('contextmenu', this._boundContextMenu);\n this._boundTriggerEl = trigger;\n }\n\n private _unbindTrigger(): void {\n if (!this._boundTriggerEl) return;\n this._boundTriggerEl.removeEventListener('contextmenu', this._boundContextMenu);\n this._boundTriggerEl = null;\n }\n}\n","import { ContextMenuElement } from './context-menu.element.js';\n\nif (!customElements.get('a11y-context-menu')) {\n customElements.define('a11y-context-menu', ContextMenuElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-context-menu': ContextMenuElement;\n }\n}\n\nexport { ContextMenuElement };\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;AAC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,eAAe,KAAK,iBAAiB;AAC9E,SAAK,kBAAkB;AAAA,EACzB;AACF;;;ACtFA,IAAI,CAAC,eAAe,IAAI,mBAAmB,GAAG;AAC5C,iBAAe,OAAO,qBAAqB,kBAAkB;AAC/D;","names":[]}
@@ -0,0 +1,529 @@
1
+ // src/core/a11y-element.ts
2
+ var A11yElement = class extends HTMLElement {
3
+ _connected = false;
4
+ _listeners = [];
5
+ _updating = false;
6
+ connectedCallback() {
7
+ this._connected = true;
8
+ this.update();
9
+ }
10
+ disconnectedCallback() {
11
+ this._connected = false;
12
+ this._cleanupListeners();
13
+ this.onDisconnect?.();
14
+ }
15
+ attributeChangedCallback(_name, oldValue, newValue) {
16
+ if (oldValue === newValue || !this._connected) return;
17
+ this.update();
18
+ }
19
+ update() {
20
+ if (this._updating) return;
21
+ this._updating = true;
22
+ try {
23
+ this._cleanupListeners();
24
+ this.onBeforeRender?.();
25
+ this.innerHTML = String(this.render());
26
+ this.onAfterRender?.();
27
+ } finally {
28
+ this._updating = false;
29
+ }
30
+ }
31
+ /**
32
+ * Adds a listener and tracks it for automatic removal on the next render
33
+ * and on disconnect — the direct replacement for the old framework's
34
+ * `[el, type, handler]` cleanup-array convention.
35
+ */
36
+ listen(target, type, handler, options) {
37
+ target.addEventListener(type, handler, options);
38
+ this._listeners.push([target, type, handler, options]);
39
+ }
40
+ _cleanupListeners() {
41
+ for (const [target, type, handler, options] of this._listeners) {
42
+ target.removeEventListener(type, handler, options);
43
+ }
44
+ this._listeners = [];
45
+ }
46
+ /** Dispatches a bubbling CustomEvent from this element. */
47
+ emit(type, detail) {
48
+ return this.dispatchEvent(new CustomEvent(type, { bubbles: true, detail }));
49
+ }
50
+ // --- small attribute-reflection helpers, shared across components ---
51
+ stringAttr(name, fallback = "") {
52
+ return this.getAttribute(name) ?? fallback;
53
+ }
54
+ optionalStringAttr(name) {
55
+ return this.getAttribute(name) ?? void 0;
56
+ }
57
+ boolAttr(name) {
58
+ return this.hasAttribute(name);
59
+ }
60
+ numberAttr(name, fallback) {
61
+ const value = this.getAttribute(name);
62
+ if (value == null) return fallback;
63
+ const parsed = Number(value);
64
+ return Number.isNaN(parsed) ? fallback : parsed;
65
+ }
66
+ setBoolAttr(name, value) {
67
+ if (value) this.setAttribute(name, "");
68
+ else this.removeAttribute(name);
69
+ }
70
+ /** Sets or removes a CSS custom property on this element depending on truthiness of `value`. */
71
+ setCssVar(name, value) {
72
+ if (value) this.style.setProperty(name, value);
73
+ else this.style.removeProperty(name);
74
+ }
75
+ };
76
+
77
+ // src/core/overlay-registry.ts
78
+ var OVERLAY_OPEN_EVENT = "a11y-overlay-open";
79
+ var OVERLAY_CLOSE_EVENT = "a11y-overlay-close";
80
+ 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 };
83
+ function registerOpenOverlay(overlay) {
84
+ state.openOverlays.add(overlay);
85
+ }
86
+ function unregisterOpenOverlay(overlay) {
87
+ state.openOverlays.delete(overlay);
88
+ }
89
+ function dismissAllOverlays() {
90
+ for (const overlay of Array.from(state.openOverlays)) overlay.close();
91
+ }
92
+ var NO_SCROLL_CLASS = "a11y-no-scroll";
93
+ function lockScroll() {
94
+ if (state.scrollLocks++ === 0) document.documentElement.classList.add(NO_SCROLL_CLASS);
95
+ }
96
+ function unlockScroll() {
97
+ if (state.scrollLocks === 0) return;
98
+ if (--state.scrollLocks === 0) document.documentElement.classList.remove(NO_SCROLL_CLASS);
99
+ }
100
+ function emitOverlayOpen(name) {
101
+ return document.dispatchEvent(
102
+ new CustomEvent(OVERLAY_OPEN_EVENT, { bubbles: true, detail: { name } })
103
+ );
104
+ }
105
+ function emitOverlayClose(name) {
106
+ return document.dispatchEvent(
107
+ new CustomEvent(OVERLAY_CLOSE_EVENT, { bubbles: true, detail: { name } })
108
+ );
109
+ }
110
+
111
+ // src/core/a11y-overlay-element.ts
112
+ var A11yOverlayElement = class extends A11yElement {
113
+ static get observedAttributes() {
114
+ return ["open"];
115
+ }
116
+ _isShowing = false;
117
+ /**
118
+ * True while `disconnectedCallback` tears down an overlay the consumer
119
+ * removed from the document — `_hide()` implementations must then leave
120
+ * `this` detached instead of moving it back to `document.body`.
121
+ */
122
+ _detaching = false;
123
+ _internalMove = false;
124
+ get open() {
125
+ return this.boolAttr("open");
126
+ }
127
+ set open(value) {
128
+ this.setBoolAttr("open", value);
129
+ }
130
+ connectedCallback() {
131
+ if (this._internalMove) return;
132
+ this._connected = true;
133
+ this._portalToBody();
134
+ this.onConnect?.();
135
+ if (!this.open) return;
136
+ if (document.readyState === "loading") this.afterParse(() => this._showIfStillOpen());
137
+ else this._show();
138
+ }
139
+ disconnectedCallback() {
140
+ if (this._internalMove) return;
141
+ if (this._isShowing) {
142
+ this._detaching = true;
143
+ try {
144
+ this._hide({ immediate: true });
145
+ } finally {
146
+ this._detaching = false;
147
+ }
148
+ }
149
+ unregisterOpenOverlay(this);
150
+ super.disconnectedCallback();
151
+ }
152
+ attributeChangedCallback(name, oldValue, newValue) {
153
+ if (oldValue === newValue || !this._connected) return;
154
+ if (name !== "open") {
155
+ this.onAttributeChanged?.(name);
156
+ return;
157
+ }
158
+ if (newValue !== null) this._show();
159
+ else this._hide();
160
+ }
161
+ /** Runs `callback` once the document has finished parsing (never, if it already has — call sites handle that case directly). */
162
+ afterParse(callback) {
163
+ if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", callback, { once: true });
164
+ }
165
+ _showIfStillOpen() {
166
+ if (this._connected && this.open && !this._isShowing) this._show();
167
+ }
168
+ /** Convenience wrapper — identical to `element.open = true`. */
169
+ show() {
170
+ this.open = true;
171
+ }
172
+ /** Convenience wrapper — identical to `element.open = false`. */
173
+ close() {
174
+ this.open = false;
175
+ }
176
+ _portalToBody() {
177
+ if (this.parentNode !== document.body) this._moveSelfTo(document.body);
178
+ }
179
+ /**
180
+ * Moves `this` to be the last child of `newParent`, suppressing the
181
+ * connected/disconnected lifecycle churn that a plain `appendChild` would
182
+ * trigger (see the class doc). Use this — never a raw `appendChild`/
183
+ * `insertBefore` on `this` — anywhere a subclass reparents itself while
184
+ * building or tearing down wrapper/backdrop chrome.
185
+ */
186
+ _moveSelfTo(newParent) {
187
+ this._internalMove = true;
188
+ try {
189
+ newParent.appendChild(this);
190
+ } finally {
191
+ this._internalMove = false;
192
+ }
193
+ }
194
+ _onShown(name = this.tagName.toLowerCase()) {
195
+ this._isShowing = true;
196
+ registerOpenOverlay(this);
197
+ emitOverlayOpen(name);
198
+ }
199
+ _onHidden(name = this.tagName.toLowerCase()) {
200
+ this._isShowing = false;
201
+ unregisterOpenOverlay(this);
202
+ emitOverlayClose(name);
203
+ }
204
+ /**
205
+ * Unused by overlays — content is managed explicitly by each concrete
206
+ * overlay in `_show()`/`_hide()`, never auto-replaced from a template
207
+ * string, so that consumer-authored light-DOM children survive. Present
208
+ * only to satisfy `A11yElement`'s abstract contract.
209
+ */
210
+ render() {
211
+ return "";
212
+ }
213
+ };
214
+
215
+ // src/core/focus-trap.ts
216
+ var FOCUSABLE_SELECTOR = 'button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex="-1"])';
217
+ function isTabbable(el) {
218
+ if (el.closest("[hidden], [inert]")) return false;
219
+ if (typeof el.checkVisibility === "function") return el.checkVisibility({ visibilityProperty: true });
220
+ return true;
221
+ }
222
+ var FocusTrapHelper = class {
223
+ _container;
224
+ _previousActiveElement = null;
225
+ _focusableElements = null;
226
+ _firstFocusableElement = null;
227
+ _boundKeyDown;
228
+ _options;
229
+ _inertTarget = null;
230
+ _isActive = false;
231
+ constructor({ container, options = {} }) {
232
+ this._container = container;
233
+ this._options = {
234
+ escapeDeactivates: options.escapeDeactivates ?? true,
235
+ returnFocusOnDeactivate: options.returnFocusOnDeactivate ?? true,
236
+ onDeactivate: options.onDeactivate,
237
+ inertTarget: options.inertTarget ?? null
238
+ };
239
+ this._boundKeyDown = this._handleKeyDown.bind(this);
240
+ }
241
+ _getFocusableElements() {
242
+ return Array.from(this._container.querySelectorAll(FOCUSABLE_SELECTOR)).filter(isTabbable);
243
+ }
244
+ _resolveInertTarget() {
245
+ const target = this._options.inertTarget;
246
+ if (!target) return null;
247
+ return typeof target === "string" ? document.querySelector(target) : target;
248
+ }
249
+ activate() {
250
+ if (this._isActive) return;
251
+ this._previousActiveElement = document.activeElement;
252
+ this._focusableElements = this._getFocusableElements();
253
+ if (this._focusableElements.length > 0) {
254
+ this._firstFocusableElement = this._focusableElements[0] ?? null;
255
+ this._firstFocusableElement?.focus();
256
+ } else {
257
+ this._container.setAttribute("tabindex", "-1");
258
+ this._container.focus();
259
+ this._firstFocusableElement = this._container;
260
+ }
261
+ this._container.addEventListener("keydown", this._boundKeyDown);
262
+ this._inertTarget = this._resolveInertTarget();
263
+ if (this._inertTarget) this._inertTarget.inert = true;
264
+ this._isActive = true;
265
+ }
266
+ deactivate() {
267
+ if (!this._isActive) return;
268
+ this._container.removeEventListener("keydown", this._boundKeyDown);
269
+ if (this._inertTarget) this._inertTarget.inert = false;
270
+ this._inertTarget = null;
271
+ if (this._container.getAttribute("tabindex") === "-1") {
272
+ this._container.removeAttribute("tabindex");
273
+ }
274
+ if (this._options.returnFocusOnDeactivate && this._previousActiveElement?.focus) {
275
+ this._previousActiveElement.focus();
276
+ }
277
+ this._focusableElements = null;
278
+ this._firstFocusableElement = null;
279
+ this._previousActiveElement = null;
280
+ this._isActive = false;
281
+ }
282
+ getIsActive() {
283
+ return this._isActive;
284
+ }
285
+ updateFocusableElements() {
286
+ if (!this._isActive) return;
287
+ this._focusableElements = this._getFocusableElements();
288
+ if (this._focusableElements.length > 0) {
289
+ this._firstFocusableElement = this._focusableElements[0] ?? null;
290
+ }
291
+ }
292
+ _handleKeyDown(event) {
293
+ switch (event.key) {
294
+ case "Tab":
295
+ this._handleTabKey(event);
296
+ break;
297
+ case "Escape":
298
+ if (this._options.escapeDeactivates) {
299
+ event.preventDefault();
300
+ this._options.onDeactivate?.();
301
+ }
302
+ break;
303
+ }
304
+ }
305
+ /**
306
+ * Drives every Tab/Shift+Tab press manually instead of only intercepting
307
+ * at the first/last boundary and otherwise trusting the browser's native
308
+ * tab order to match `_focusableElements`' DOM order. Safari on macOS, by
309
+ * default, excludes buttons/links from the native Tab order entirely (only
310
+ * text inputs get native tab stops) — so a boundary-only trap can let
311
+ * focus silently escape once native Tab skips past what this class thinks
312
+ * is the last focusable element. Owning every Tab press removes that
313
+ * dependency on any browser's native tab-stop behavior altogether.
314
+ */
315
+ _handleTabKey(event) {
316
+ this.updateFocusableElements();
317
+ if (!this._focusableElements || this._focusableElements.length === 0) {
318
+ event.preventDefault();
319
+ return;
320
+ }
321
+ event.preventDefault();
322
+ const elements = this._focusableElements;
323
+ const currentIndex = elements.indexOf(document.activeElement);
324
+ const nextIndex = event.shiftKey ? currentIndex <= 0 ? elements.length - 1 : currentIndex - 1 : currentIndex === -1 || currentIndex === elements.length - 1 ? 0 : currentIndex + 1;
325
+ elements[nextIndex]?.focus();
326
+ }
327
+ };
328
+
329
+ // src/core/transition.ts
330
+ function toMs(value) {
331
+ const n = parseFloat(value);
332
+ if (Number.isNaN(n)) return 0;
333
+ return value.trim().endsWith("ms") ? n : n * 1e3;
334
+ }
335
+ function longestTransitionMs(el) {
336
+ const style = getComputedStyle(el);
337
+ const durations = style.transitionDuration.split(",").map(toMs);
338
+ const delays = style.transitionDelay.split(",").map(toMs);
339
+ return durations.reduce((max, d, i) => Math.max(max, d + (delays[i % delays.length] ?? 0)), 0);
340
+ }
341
+ function whenTransitionDone(el, done) {
342
+ const ms = longestTransitionMs(el);
343
+ if (ms <= 0) {
344
+ done();
345
+ return () => {
346
+ };
347
+ }
348
+ let settled = false;
349
+ const settle = (run) => {
350
+ if (settled) return;
351
+ settled = true;
352
+ el.removeEventListener("transitionend", onEnd);
353
+ clearTimeout(timer);
354
+ if (run) done();
355
+ };
356
+ const onEnd = (e) => {
357
+ if (e.target === el) settle(true);
358
+ };
359
+ el.addEventListener("transitionend", onEnd);
360
+ const timer = setTimeout(() => settle(true), ms + 50);
361
+ return () => settle(false);
362
+ }
363
+
364
+ // src/overlays/core/a11y-modal-overlay-element.ts
365
+ var titleIdCounter = 0;
366
+ var A11yModalOverlayElement = class extends A11yOverlayElement {
367
+ static get observedAttributes() {
368
+ return ["open", "non-dismissible", "dialog-label"];
369
+ }
370
+ _backdrop = null;
371
+ _wrapper = null;
372
+ _focusTrap = null;
373
+ _closeButton = null;
374
+ /** Completes a close whose transition is still running — see `_flushPendingHide()`. */
375
+ _pendingHide = null;
376
+ _cancelHideWait = null;
377
+ get dismissible() {
378
+ return !this.boolAttr("non-dismissible");
379
+ }
380
+ get dialogLabel() {
381
+ return this.stringAttr("dialog-label");
382
+ }
383
+ createBackdrop() {
384
+ const el = document.createElement("div");
385
+ el.className = "a11y-modal-overlay";
386
+ return el;
387
+ }
388
+ createWrapper() {
389
+ const el = document.createElement("div");
390
+ el.className = "a11y-modal-wrapper";
391
+ el.setAttribute("role", "dialog");
392
+ el.setAttribute("aria-modal", "true");
393
+ return el;
394
+ }
395
+ getContentClass() {
396
+ return "a11y-modal-content";
397
+ }
398
+ focusTrapOptions() {
399
+ return { onDeactivate: () => this.close() };
400
+ }
401
+ _show() {
402
+ this._flushPendingHide();
403
+ if (this._wrapper) return;
404
+ lockScroll();
405
+ if (this.dismissible) this._prependCloseButton();
406
+ const { backdrop, wrapper } = this._buildDom();
407
+ this._backdrop = backdrop;
408
+ this._wrapper = wrapper;
409
+ this._labelWrapper(wrapper);
410
+ if (this.dismissible) {
411
+ backdrop.addEventListener("click", (e) => {
412
+ if (e.target === backdrop) this.close();
413
+ });
414
+ }
415
+ this._focusTrap = new FocusTrapHelper({ container: wrapper, options: this.focusTrapOptions() });
416
+ this._focusTrap.activate();
417
+ requestAnimationFrame(() => {
418
+ backdrop.classList.add("a11y-is-open");
419
+ wrapper.classList.add("a11y-is-open");
420
+ });
421
+ this._onShown();
422
+ }
423
+ _hide(opts) {
424
+ const backdrop = this._backdrop;
425
+ const wrapper = this._wrapper;
426
+ if (!backdrop || !wrapper) {
427
+ if (opts?.immediate) this._flushPendingHide();
428
+ return;
429
+ }
430
+ this._focusTrap?.deactivate();
431
+ this._focusTrap = null;
432
+ this._backdrop = null;
433
+ this._wrapper = null;
434
+ const finish = () => {
435
+ this._pendingHide = null;
436
+ this._cancelHideWait = null;
437
+ unlockScroll();
438
+ this._closeButton?.remove();
439
+ this._closeButton = null;
440
+ this.classList.remove(this.getContentClass());
441
+ if (!this._detaching) this._moveSelfTo(document.body);
442
+ wrapper.remove();
443
+ backdrop.remove();
444
+ this._onHidden();
445
+ };
446
+ this._pendingHide = finish;
447
+ if (opts?.immediate) {
448
+ finish();
449
+ return;
450
+ }
451
+ wrapper.classList.remove("a11y-is-open");
452
+ backdrop.classList.remove("a11y-is-open");
453
+ this._cancelHideWait = whenTransitionDone(wrapper, finish);
454
+ }
455
+ _flushPendingHide() {
456
+ const finish = this._pendingHide;
457
+ if (!finish) return;
458
+ this._cancelHideWait?.();
459
+ finish();
460
+ }
461
+ _prependCloseButton() {
462
+ const btn = document.createElement("button");
463
+ btn.type = "button";
464
+ btn.className = "a11y-modal-close-button";
465
+ btn.innerHTML = "&times;";
466
+ btn.setAttribute("aria-label", "Close dialog");
467
+ btn.addEventListener("click", () => this.close());
468
+ this.prepend(btn);
469
+ this._closeButton = btn;
470
+ }
471
+ _buildDom() {
472
+ const backdrop = this.createBackdrop();
473
+ const wrapper = this.createWrapper();
474
+ backdrop.appendChild(wrapper);
475
+ document.body.appendChild(backdrop);
476
+ this.classList.add(this.getContentClass());
477
+ this._moveSelfTo(wrapper);
478
+ return { backdrop, wrapper };
479
+ }
480
+ _labelWrapper(wrapper) {
481
+ if (this.dialogLabel) {
482
+ wrapper.setAttribute("aria-label", this.dialogLabel);
483
+ return;
484
+ }
485
+ const heading = this.querySelector("h1, h2, h3, h4, h5, h6");
486
+ if (!heading) return;
487
+ if (!heading.id) heading.id = `a11y-dialog-title-${++titleIdCounter}`;
488
+ wrapper.setAttribute("aria-labelledby", heading.id);
489
+ }
490
+ };
491
+
492
+ // src/overlays/drawer/drawer.element.ts
493
+ var DrawerElement = class extends A11yModalOverlayElement {
494
+ static get observedAttributes() {
495
+ return [...super.observedAttributes, "edge"];
496
+ }
497
+ onClose;
498
+ get edge() {
499
+ const value = this.getAttribute("edge");
500
+ return value === "left" || value === "top" || value === "bottom" ? value : "right";
501
+ }
502
+ createBackdrop() {
503
+ const el = super.createBackdrop();
504
+ el.className = "a11y-drawer-backdrop";
505
+ return el;
506
+ }
507
+ createWrapper() {
508
+ const el = super.createWrapper();
509
+ el.className = `a11y-drawer-wrapper a11y-drawer-wrapper--${this.edge}`;
510
+ return el;
511
+ }
512
+ getContentClass() {
513
+ return "a11y-drawer-content";
514
+ }
515
+ _onHidden(name) {
516
+ super._onHidden(name);
517
+ this.onClose?.();
518
+ }
519
+ };
520
+
521
+ // src/overlays/drawer/define.ts
522
+ if (!customElements.get("a11y-drawer")) {
523
+ customElements.define("a11y-drawer", DrawerElement);
524
+ }
525
+ export {
526
+ DrawerElement,
527
+ dismissAllOverlays
528
+ };
529
+ //# sourceMappingURL=define.js.map