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/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,KAAK,OAAO,CAAC;AACrC,WAAK,gBAAgB;AAAA,IACvB,UAAE;AACA,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBU,OACR,QACA,MACA,SACA,SAC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kB,IAAI,eAAe,KAAK,gBAAgB;AAC/D,UAAI,KAAK,cAAe,MAAK,gBAAgB,QAAQ,KAAK,aAAa;AACvE,WAAK,gBAAgB,QAAQ,OAAO;AAAA,IACtC;AAAA,EACF;AAAA,EAEQ,6BAAmC;AACzC,QAAI,KAAK,kBAAkB;AACzB,aAAO,oBAAoB,UAAU,KAAK,kBAAkB,IAAI;AAChE,aAAO,oBAAoB,UAAU,KAAK,gBAAgB;AAC1D,WAAK,mBAAmB;AAAA,IAC1B;AACA,SAAK,iBAAiB,WAAW;AACjC,SAAK,kBAAkB;AAAA,EACzB;AACF;;;ACxSO,IAAM,iBAAN,cAA6B,2BAA2B;AAAA,EAC7D,WAAoB,qBAA+B;AACjD,WAAO,CAAC,GAAG,MAAM,oBAAoB,eAAe,YAAY;AAAA,EAClE;AAAA,EAEA;AAAA,EAEmB,iBAA0B;AAI3C,UAAM,WAAW,KAAK,aAAa,YAAY;AAC/C,QAAI,aAAa,KAAM,QAAO,aAAa;AAC3C,WAAO,KAAK,SAAS,aAAa;AAAA,EACpC;AAAA,EAEmB,gBAA6B;AAC9C,UAAM,KAAK,MAAM,cAAc;AAC/B,OAAG,UAAU,IAAI,sBAAsB;AACvC,OAAG,aAAa,QAAQ,KAAK,SAAS,aAAa,IAAI,WAAW,QAAQ;AAC1E,WAAO;AAAA,EACT;AAAA,EAEmB,kBAA0B;AAC3C,WAAO;AAAA,EACT;AAAA,EAEmB,UAAU,MAAqB;AAChD,UAAM,UAAU,IAAI;AACpB,SAAK,UAAU;AAAA,EACjB;AACF;;;AC1CA,IAAI,CAAC,eAAe,IAAI,cAAc,GAAG;AACvC,iBAAe,OAAO,gBAAgB,cAAc;AACtD;","names":[]}
@@ -0,0 +1,268 @@
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/overlays/core/a11y-passive-overlay-element.ts
78
+ var A11yPassiveOverlayElement = class extends A11yElement {
79
+ _queue = [];
80
+ _activeCount = 0;
81
+ _maxStack = 1;
82
+ connectedCallback() {
83
+ this._connected = true;
84
+ if (this.parentNode !== document.body) document.body.appendChild(this);
85
+ this.setAttribute("aria-live", "polite");
86
+ this.setAttribute("aria-atomic", "false");
87
+ this.setAttribute("aria-relevant", "additions removals");
88
+ this.classList.add("a11y-passive-overlay-region");
89
+ }
90
+ setMaxStack(n) {
91
+ this._maxStack = Math.max(1, n);
92
+ }
93
+ enqueue(item) {
94
+ if (this._activeCount < this._maxStack) {
95
+ this._activeCount++;
96
+ this._showItem(item);
97
+ } else {
98
+ this._queue.push(item);
99
+ }
100
+ }
101
+ _onItemDismissed() {
102
+ this._activeCount--;
103
+ if (this._queue.length > 0 && this._activeCount < this._maxStack) {
104
+ const next = this._queue.shift();
105
+ this._activeCount++;
106
+ this._showItem(next);
107
+ }
108
+ }
109
+ /**
110
+ * Removes `element` and calls `onDone` after `duration`ms of it being
111
+ * *unattended*: the countdown pauses while the pointer is over the item or
112
+ * focus is inside it (e.g. on its action button), and resumes with the
113
+ * remaining time once both leave (WCAG 2.2.1 — a user reading or reaching
114
+ * for a toast mustn't have it vanish under them). Returns a function that
115
+ * cancels the auto-dismiss entirely.
116
+ */
117
+ _autoDismiss(element, duration, onDone) {
118
+ let remaining = duration;
119
+ let startedAt = 0;
120
+ let timer = null;
121
+ let hovered = false;
122
+ let focused = false;
123
+ const run = () => {
124
+ startedAt = Date.now();
125
+ timer = setTimeout(() => {
126
+ cancel();
127
+ element.remove();
128
+ onDone();
129
+ }, remaining);
130
+ };
131
+ const pause = () => {
132
+ if (!timer) return;
133
+ clearTimeout(timer);
134
+ timer = null;
135
+ remaining = Math.max(0, remaining - (Date.now() - startedAt));
136
+ };
137
+ const refresh = () => {
138
+ if (hovered || focused) pause();
139
+ else if (!timer) run();
140
+ };
141
+ const onEnter = () => {
142
+ hovered = true;
143
+ refresh();
144
+ };
145
+ const onLeave = () => {
146
+ hovered = false;
147
+ refresh();
148
+ };
149
+ const onFocusIn = () => {
150
+ focused = true;
151
+ refresh();
152
+ };
153
+ const onFocusOut = (e) => {
154
+ if (element.contains(e.relatedTarget)) return;
155
+ focused = false;
156
+ refresh();
157
+ };
158
+ const cancel = () => {
159
+ if (timer) clearTimeout(timer);
160
+ timer = null;
161
+ element.removeEventListener("mouseenter", onEnter);
162
+ element.removeEventListener("mouseleave", onLeave);
163
+ element.removeEventListener("focusin", onFocusIn);
164
+ element.removeEventListener("focusout", onFocusOut);
165
+ };
166
+ element.addEventListener("mouseenter", onEnter);
167
+ element.addEventListener("mouseleave", onLeave);
168
+ element.addEventListener("focusin", onFocusIn);
169
+ element.addEventListener("focusout", onFocusOut);
170
+ run();
171
+ return cancel;
172
+ }
173
+ /** Unused — items are appended/removed directly by `_showItem`, never generated from a template. */
174
+ render() {
175
+ return "";
176
+ }
177
+ };
178
+
179
+ // src/core/template.ts
180
+ function raw(value) {
181
+ return { __html: value, toString: () => value };
182
+ }
183
+ function isRaw(value) {
184
+ return typeof value === "object" && value !== null && "__html" in value;
185
+ }
186
+ function escape(value) {
187
+ if (value == null || value === false) return "";
188
+ if (isRaw(value)) return value.__html;
189
+ if (Array.isArray(value)) return value.map(escape).join("");
190
+ return String(value).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
191
+ }
192
+ function html(strings, ...values) {
193
+ return raw(strings.reduce((out, part, i) => out + part + escape(values[i]), ""));
194
+ }
195
+
196
+ // src/overlays/snackbar/snackbar.element.ts
197
+ var SnackbarElement = class extends A11yPassiveOverlayElement {
198
+ _bottomContainer;
199
+ _topContainer;
200
+ connectedCallback() {
201
+ super.connectedCallback();
202
+ this.classList.add("a11y-snackbar-region");
203
+ if (!this._bottomContainer) {
204
+ this._bottomContainer = document.createElement("div");
205
+ this._bottomContainer.className = "a11y-snackbar-region__bottom";
206
+ this._topContainer = document.createElement("div");
207
+ this._topContainer.className = "a11y-snackbar-region__top";
208
+ this.append(this._bottomContainer, this._topContainer);
209
+ }
210
+ }
211
+ notify(message, options = {}) {
212
+ if (options.maxStack) this.setMaxStack(options.maxStack);
213
+ this.enqueue({
214
+ message,
215
+ type: options.type,
216
+ position: options.position,
217
+ duration: options.duration,
218
+ actionText: options.actionText,
219
+ onAction: options.onAction
220
+ });
221
+ }
222
+ _showItem(item) {
223
+ const type = item.type ?? "info";
224
+ const position = item.position ?? "bottom";
225
+ const duration = item.duration ?? (item.actionText ? 1e4 : 3e3);
226
+ const container = position === "bottom" ? this._bottomContainer : this._topContainer;
227
+ const el = document.createElement("div");
228
+ el.className = `a11y-snackbar a11y-snackbar--${type}`;
229
+ el.setAttribute("role", type === "error" ? "alert" : "status");
230
+ el.setAttribute("aria-live", type === "error" ? "assertive" : "polite");
231
+ el.setAttribute("aria-atomic", "true");
232
+ el.innerHTML = String(html`
233
+ <span>${item.message}</span>
234
+ ${item.actionText ? html`<button type="button">${item.actionText}</button>` : ""}
235
+ `);
236
+ container.appendChild(el);
237
+ const cancelAutoDismiss = this._autoDismiss(el, duration, () => this._onItemDismissed());
238
+ el.querySelector("button")?.addEventListener("click", () => {
239
+ cancelAutoDismiss();
240
+ el.remove();
241
+ this._onItemDismissed();
242
+ item.onAction?.();
243
+ });
244
+ }
245
+ };
246
+
247
+ // src/overlays/snackbar/define.ts
248
+ if (!customElements.get("a11y-snackbar")) {
249
+ customElements.define("a11y-snackbar", SnackbarElement);
250
+ }
251
+ var cachedRegion = null;
252
+ function getRegion() {
253
+ const existing = document.querySelector("a11y-snackbar");
254
+ if (existing) return existing;
255
+ if (!cachedRegion || !cachedRegion.isConnected) {
256
+ cachedRegion = document.createElement("a11y-snackbar");
257
+ document.body.appendChild(cachedRegion);
258
+ }
259
+ return cachedRegion;
260
+ }
261
+ function notify(message, options = {}) {
262
+ getRegion().notify(message, options);
263
+ }
264
+ export {
265
+ SnackbarElement,
266
+ notify
267
+ };
268
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/a11y-element.ts","../../../../src/overlays/core/a11y-passive-overlay-element.ts","../../../../src/core/template.ts","../../../../src/overlays/snackbar/snackbar.element.ts","../../../../src/overlays/snackbar/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","import { A11yElement } from '../../core/a11y-element.js';\n\nexport type PassiveOverlayPosition = 'top' | 'bottom' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';\n\nexport interface PassiveOverlayItem {\n message: string;\n position?: PassiveOverlayPosition;\n duration?: number;\n actionText?: string;\n onAction?: () => void;\n}\n\n/**\n * Base for \"region\" overlays (snackbar, notification-banner) that don't fit\n * the single open/close model `A11yOverlayElement` covers — a passive region\n * is a persistent live-region container the consumer places once in their\n * HTML, and items are shown/dismissed inside it continuously via `enqueue()`\n * (bounded-concurrency FIFO: at most `maxStack` items shown at once, the\n * rest queued), not toggled as a whole.\n */\nexport abstract class A11yPassiveOverlayElement<TItem extends PassiveOverlayItem = PassiveOverlayItem> extends A11yElement {\n protected _queue: TItem[] = [];\n protected _activeCount = 0;\n private _maxStack = 1;\n\n override connectedCallback(): void {\n this._connected = true;\n if (this.parentNode !== document.body) document.body.appendChild(this);\n this.setAttribute('aria-live', 'polite');\n this.setAttribute('aria-atomic', 'false');\n this.setAttribute('aria-relevant', 'additions removals');\n this.classList.add('a11y-passive-overlay-region');\n }\n\n setMaxStack(n: number): void {\n this._maxStack = Math.max(1, n);\n }\n\n protected enqueue(item: TItem): void {\n if (this._activeCount < this._maxStack) {\n this._activeCount++;\n this._showItem(item);\n } else {\n this._queue.push(item);\n }\n }\n\n protected _onItemDismissed(): void {\n this._activeCount--;\n if (this._queue.length > 0 && this._activeCount < this._maxStack) {\n const next = this._queue.shift()!;\n this._activeCount++;\n this._showItem(next);\n }\n }\n\n protected abstract _showItem(item: TItem): void;\n\n /**\n * Removes `element` and calls `onDone` after `duration`ms of it being\n * *unattended*: the countdown pauses while the pointer is over the item or\n * focus is inside it (e.g. on its action button), and resumes with the\n * remaining time once both leave (WCAG 2.2.1 — a user reading or reaching\n * for a toast mustn't have it vanish under them). Returns a function that\n * cancels the auto-dismiss entirely.\n */\n protected _autoDismiss(element: HTMLElement, duration: number, onDone: () => void): () => void {\n let remaining = duration;\n let startedAt = 0;\n let timer: ReturnType<typeof setTimeout> | null = null;\n let hovered = false;\n let focused = false;\n\n const run = (): void => {\n startedAt = Date.now();\n timer = setTimeout(() => {\n cancel();\n element.remove();\n onDone();\n }, remaining);\n };\n const pause = (): void => {\n if (!timer) return;\n clearTimeout(timer);\n timer = null;\n remaining = Math.max(0, remaining - (Date.now() - startedAt));\n };\n const refresh = (): void => {\n if (hovered || focused) pause();\n else if (!timer) run();\n };\n const onEnter = (): void => { hovered = true; refresh(); };\n const onLeave = (): void => { hovered = false; refresh(); };\n const onFocusIn = (): void => { focused = true; refresh(); };\n const onFocusOut = (e: FocusEvent): void => {\n if (element.contains(e.relatedTarget as Node | null)) return;\n focused = false;\n refresh();\n };\n const cancel = (): void => {\n if (timer) clearTimeout(timer);\n timer = null;\n element.removeEventListener('mouseenter', onEnter);\n element.removeEventListener('mouseleave', onLeave);\n element.removeEventListener('focusin', onFocusIn);\n element.removeEventListener('focusout', onFocusOut);\n };\n\n element.addEventListener('mouseenter', onEnter);\n element.addEventListener('mouseleave', onLeave);\n element.addEventListener('focusin', onFocusIn);\n element.addEventListener('focusout', onFocusOut);\n run();\n return cancel;\n }\n\n /** Unused — items are appended/removed directly by `_showItem`, never generated from a template. */\n protected override render(): string {\n return '';\n }\n}\n","/**\n * Pre-trusted HTML: opts out of auto-escaping when interpolated into an\n * `html` tagged template, and stringifies back to that exact markup when\n * assigned to `innerHTML` or concatenated. `html\\`...\\`` itself returns one\n * of these, which is what makes nesting `html` calls inside another `html`\n * call safe by construction — the inner result is never re-escaped, no\n * caller discipline (remembering to wrap it) required.\n */\nexport interface Raw {\n readonly __html: string;\n toString(): string;\n}\n\n/** Wraps a string as pre-trusted HTML. Use only for markup you built yourself — never for raw user input. */\nexport function raw(value: string): Raw {\n return { __html: value, toString: () => value };\n}\n\nfunction isRaw(value: unknown): value is Raw {\n return typeof value === 'object' && value !== null && '__html' in value;\n}\n\nfunction escape(value: unknown): string {\n if (value == null || value === false) return '';\n if (isRaw(value)) return value.__html;\n if (Array.isArray(value)) return value.map(escape).join('');\n return String(value)\n .replace(/&/g, '&amp;')\n .replace(/</g, '&lt;')\n .replace(/>/g, '&gt;')\n .replace(/\"/g, '&quot;')\n .replace(/'/g, '&#39;');\n}\n\n/**\n * Tagged template for building element markup. Literal template parts are\n * trusted structure; every interpolated value is HTML-escaped by default\n * (falsy values render as nothing, so `${cond && '<span>…</span>'}`-style\n * conditionals work without a directive attribute). Returns a `Raw`, so\n * nesting `html\\`...\\`` inside another `html\\`...\\`` template composes\n * safely without needing an explicit `raw()` wrapper.\n */\nexport function html(strings: TemplateStringsArray, ...values: unknown[]): Raw {\n return raw(strings.reduce((out, part, i) => out + part + escape(values[i]), ''));\n}\n\n/**\n * A `name=\"value\"` HTML attribute, with a leading space, escaped — or\n * nothing at all when `value` is `null`/`undefined`/`false`/`''`. Meant for\n * building conditional attribute lists inline:\n * `` html`<input${attr('id', id)}${flag('disabled', disabled)}>` ``\n */\nexport function attr(name: string, value: unknown): Raw {\n if (value == null || value === false || value === '') return raw('');\n return raw(` ${name}=\"${escape(value)}\"`);\n}\n\n/** A bare boolean attribute (e.g. `disabled`, `checked`), with a leading space, present only when `condition` is true. */\nexport function flag(name: string, condition: boolean | undefined): Raw {\n return raw(condition ? ` ${name}` : '');\n}\n","import { A11yPassiveOverlayElement, type PassiveOverlayItem } from '../core/a11y-passive-overlay-element.js';\nimport { html } from '../../core/template.js';\n\nexport type SnackbarType = 'info' | 'success' | 'error' | 'warning';\n\nexport interface NotifyOptions {\n type?: SnackbarType;\n position?: 'top' | 'bottom';\n duration?: number;\n actionText?: string;\n onAction?: () => void;\n /** Raises the concurrency limit for this and all future items — sticky on the shared region, matching the old singleton's behavior. */\n maxStack?: number;\n}\n\ninterface SnackbarItem extends PassiveOverlayItem {\n type?: SnackbarType;\n}\n\n/**\n * A toast notification region. Auto-dismisses after `duration`ms — default\n * 3000, or 10000 when the toast has an action button (time to reach it) —\n * paused while the toast is hovered or focused. Place one `<a11y-snackbar></a11y-snackbar>` anywhere in your page\n * (it portals itself to `document.body`), then call `.notify(message, options)`\n * on it — or skip placing one entirely and use the `notify()` convenience\n * export from this module, which finds-or-creates one automatically.\n */\nexport class SnackbarElement extends A11yPassiveOverlayElement<SnackbarItem> {\n private _bottomContainer!: HTMLElement;\n private _topContainer!: HTMLElement;\n\n override connectedCallback(): void {\n super.connectedCallback();\n this.classList.add('a11y-snackbar-region');\n if (!this._bottomContainer) {\n this._bottomContainer = document.createElement('div');\n this._bottomContainer.className = 'a11y-snackbar-region__bottom';\n this._topContainer = document.createElement('div');\n this._topContainer.className = 'a11y-snackbar-region__top';\n this.append(this._bottomContainer, this._topContainer);\n }\n }\n\n notify(message: string, options: NotifyOptions = {}): void {\n if (options.maxStack) this.setMaxStack(options.maxStack);\n this.enqueue({\n message,\n type: options.type,\n position: options.position,\n duration: options.duration,\n actionText: options.actionText,\n onAction: options.onAction,\n });\n }\n\n protected _showItem(item: SnackbarItem): void {\n const type = item.type ?? 'info';\n const position = item.position ?? 'bottom';\n const duration = item.duration ?? (item.actionText ? 10_000 : 3000);\n const container = position === 'bottom' ? this._bottomContainer : this._topContainer;\n\n const el = document.createElement('div');\n el.className = `a11y-snackbar a11y-snackbar--${type}`;\n el.setAttribute('role', type === 'error' ? 'alert' : 'status');\n el.setAttribute('aria-live', type === 'error' ? 'assertive' : 'polite');\n el.setAttribute('aria-atomic', 'true');\n el.innerHTML = String(html`\n <span>${item.message}</span>\n ${item.actionText ? html`<button type=\"button\">${item.actionText}</button>` : ''}\n `);\n\n container.appendChild(el);\n\n const cancelAutoDismiss = this._autoDismiss(el, duration, () => this._onItemDismissed());\n\n el.querySelector<HTMLButtonElement>('button')?.addEventListener('click', () => {\n cancelAutoDismiss();\n el.remove();\n this._onItemDismissed();\n item.onAction?.();\n });\n }\n}\n","import { SnackbarElement, type NotifyOptions } from './snackbar.element.js';\n\nif (!customElements.get('a11y-snackbar')) {\n customElements.define('a11y-snackbar', SnackbarElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-snackbar': SnackbarElement;\n }\n}\n\nexport { SnackbarElement, type NotifyOptions };\n\nlet cachedRegion: SnackbarElement | null = null;\n\nfunction getRegion(): SnackbarElement {\n const existing = document.querySelector<SnackbarElement>('a11y-snackbar');\n if (existing) return existing;\n if (!cachedRegion || !cachedRegion.isConnected) {\n cachedRegion = document.createElement('a11y-snackbar') as SnackbarElement;\n document.body.appendChild(cachedRegion);\n }\n return cachedRegion;\n}\n\n/**\n * Convenience: finds (or creates) an `<a11y-snackbar>` region and shows a\n * toast in it. Skip this entirely and call `.notify()` on your own\n * `<a11y-snackbar>` element directly if you want explicit control over\n * where it lives in the DOM.\n */\nexport function notify(message: string, options: NotifyOptions = {}): void {\n getRegion().notify(message, options);\n}\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,KAAK,OAAO,CAAC;AACrC,WAAK,gBAAgB;AAAA,IACvB,UAAE;AACA,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAmBU,OACR,QACA,MACA,SACA,SACM;AACN,WAAO,iBAAiB,MAAM,SAAS,OAAO;AAC9C,SAAK,WAAW,KAAK,CAAC,QAAQ,MAAM,SAAS,OAAO,CAAC;AAAA,EACvD;AAAA,EAEQ,oBAA0B;AAChC,eAAW,CAAC,QAAQ,MAAM,SAAS,OAAO,KAAK,KAAK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