a11y-elements 0.2.0 → 0.3.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 (89) hide show
  1. package/README.md +259 -16
  2. package/dist/a11y.css +200 -0
  3. package/dist/browser/components/anchor/define.js +13 -1
  4. package/dist/browser/components/anchor/define.js.map +1 -1
  5. package/dist/browser/components/avatar/define.js +13 -1
  6. package/dist/browser/components/avatar/define.js.map +1 -1
  7. package/dist/browser/components/checkbox/define.js +13 -1
  8. package/dist/browser/components/checkbox/define.js.map +1 -1
  9. package/dist/browser/components/checkbox-group/define.js +394 -0
  10. package/dist/browser/components/checkbox-group/define.js.map +1 -0
  11. package/dist/browser/components/file-input/define.js +1069 -0
  12. package/dist/browser/components/file-input/define.js.map +1 -0
  13. package/dist/browser/components/focusable/define.js +13 -1
  14. package/dist/browser/components/focusable/define.js.map +1 -1
  15. package/dist/browser/components/input/define.js +34 -6
  16. package/dist/browser/components/input/define.js.map +1 -1
  17. package/dist/browser/components/label/define.js +13 -1
  18. package/dist/browser/components/label/define.js.map +1 -1
  19. package/dist/browser/components/picture/define.js +171 -3
  20. package/dist/browser/components/picture/define.js.map +1 -1
  21. package/dist/browser/components/progress/define.js +13 -1
  22. package/dist/browser/components/progress/define.js.map +1 -1
  23. package/dist/browser/components/radio-group/define.js +15 -1
  24. package/dist/browser/components/radio-group/define.js.map +1 -1
  25. package/dist/browser/components/select/define.js +13 -1
  26. package/dist/browser/components/select/define.js.map +1 -1
  27. package/dist/browser/components/skeleton/define.js +13 -1
  28. package/dist/browser/components/skeleton/define.js.map +1 -1
  29. package/dist/browser/components/spinner/define.js +13 -1
  30. package/dist/browser/components/spinner/define.js.map +1 -1
  31. package/dist/browser/components/switch/define.js +13 -1
  32. package/dist/browser/components/switch/define.js.map +1 -1
  33. package/dist/browser/components/textarea/define.js +34 -6
  34. package/dist/browser/components/textarea/define.js.map +1 -1
  35. package/dist/browser/components/visually-hidden/define.js +13 -1
  36. package/dist/browser/components/visually-hidden/define.js.map +1 -1
  37. package/dist/browser/overlays/blocking-loader/define.js +13 -1
  38. package/dist/browser/overlays/blocking-loader/define.js.map +1 -1
  39. package/dist/browser/overlays/context-menu/define.js +19 -3
  40. package/dist/browser/overlays/context-menu/define.js.map +1 -1
  41. package/dist/browser/overlays/drawer/define.js +18 -2
  42. package/dist/browser/overlays/drawer/define.js.map +1 -1
  43. package/dist/browser/overlays/dropdown/define.js +19 -3
  44. package/dist/browser/overlays/dropdown/define.js.map +1 -1
  45. package/dist/browser/overlays/emergency-dialog/define.js +18 -2
  46. package/dist/browser/overlays/emergency-dialog/define.js.map +1 -1
  47. package/dist/browser/overlays/modal/define.js +18 -2
  48. package/dist/browser/overlays/modal/define.js.map +1 -1
  49. package/dist/browser/overlays/notification-banner/define.js +13 -1
  50. package/dist/browser/overlays/notification-banner/define.js.map +1 -1
  51. package/dist/browser/overlays/popover/define.js +18 -2
  52. package/dist/browser/overlays/popover/define.js.map +1 -1
  53. package/dist/browser/overlays/snackbar/define.js +13 -1
  54. package/dist/browser/overlays/snackbar/define.js.map +1 -1
  55. package/dist/browser/overlays/tooltip/define.js +18 -2
  56. package/dist/browser/overlays/tooltip/define.js.map +1 -1
  57. package/dist/components/checkbox-group/checkbox-group.element.d.ts +51 -0
  58. package/dist/components/checkbox-group/checkbox-group.element.js +189 -0
  59. package/dist/components/checkbox-group/checkbox-group.element.js.map +1 -0
  60. package/dist/components/checkbox-group/define.d.ts +8 -0
  61. package/dist/components/checkbox-group/define.js +8 -0
  62. package/dist/components/checkbox-group/define.js.map +1 -0
  63. package/dist/components/file-input/define.d.ts +9 -0
  64. package/dist/components/file-input/define.js +9 -0
  65. package/dist/components/file-input/define.js.map +1 -0
  66. package/dist/components/file-input/file-input.element.d.ts +95 -0
  67. package/dist/components/file-input/file-input.element.js +471 -0
  68. package/dist/components/file-input/file-input.element.js.map +1 -0
  69. package/dist/components/label/label.element.d.ts +1 -1
  70. package/dist/components/label/label.element.js +1 -1
  71. package/dist/components/picture/define.d.ts +1 -0
  72. package/dist/components/picture/define.js.map +1 -1
  73. package/dist/components/picture/picture.element.d.ts +72 -6
  74. package/dist/components/picture/picture.element.js +201 -9
  75. package/dist/components/picture/picture.element.js.map +1 -1
  76. package/dist/components/radio-group/radio-group.element.js +4 -0
  77. package/dist/components/radio-group/radio-group.element.js.map +1 -1
  78. package/dist/core/a11y-field-element.d.ts +17 -7
  79. package/dist/core/a11y-field-element.js +25 -5
  80. package/dist/core/a11y-field-element.js.map +1 -1
  81. package/dist/core/focus-trap.d.ts +8 -0
  82. package/dist/core/focus-trap.js +13 -1
  83. package/dist/core/focus-trap.js.map +1 -1
  84. package/dist/core/strings.d.ts +24 -0
  85. package/dist/core/strings.js +12 -0
  86. package/dist/core/strings.js.map +1 -1
  87. package/dist/overlays/core/a11y-menu-overlay-element.js +2 -2
  88. package/dist/overlays/core/a11y-menu-overlay-element.js.map +1 -1
  89. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/a11y-wrapper-element.ts","../../../../src/core/dom-sync.ts","../../../../src/components/checkbox/checkbox.element.ts","../../../../src/components/checkbox/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","import { A11yElement } from './a11y-element.js';\n\n/**\n * Base for elements that enhance real, consumer-authored light-DOM children\n * instead of generating their own markup from a template string — e.g. a\n * `<a11y-picture>` wrapping a real `<picture>`/`<img>`/`<figcaption>`, or\n * `<a11y-select>` wrapping a real `<select>`/`<option>`s.\n *\n * Unlike `A11yElement`, this never sets `innerHTML` from a `render()`\n * string — that would destroy the author's children — so it opts out of the\n * normal render pipeline and instead re-syncs (`_sync()`) from two sources:\n *\n * - **This element's own observed attributes** (e.g. `label`, `legend`),\n * listed via `static observedAttributes` same as any other element —\n * these re-sync *synchronously*, matching every other element in this\n * library, so `el.setAttribute('label', 'x')` takes effect immediately.\n * - **Everything else** (children added/removed, an attribute changing on\n * one of *those* children) — light DOM has no `slotchange`, so a\n * `MutationObserver` is the equivalent, necessarily asynchronous (a real\n * microtask/task delay after the mutation).\n *\n * `_sync()` runs inside that `MutationObserver` callback, so every DOM write\n * it makes must be guarded (see `core/dom-sync.ts`) — `setAttribute`/\n * `classList.add`/`textContent =` all queue a mutation record even when the\n * value is unchanged, and an unguarded write would retrigger the observer\n * forever.\n */\nexport abstract class A11yWrapperElement extends A11yElement {\n private _observer: MutationObserver | null = null;\n /** Nodes already given their listeners since the last connect — see `wireOnce()`. */\n private _wiredNodes = new WeakSet<Node>();\n\n override connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this._sync();\n this._observer = new MutationObserver(() => this._sync());\n this._observer.observe(this, this.observerInit());\n }\n\n override disconnectedCallback(): void {\n this._observer?.disconnect();\n this._observer = null;\n super.disconnectedCallback(); // removes every `listen()` listener…\n this._wiredNodes = new WeakSet(); // …so the next connect must wire them again\n }\n\n override attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this._sync();\n }\n\n /**\n * Runs `wire` the first time `node` is seen since this element was last\n * connected. `_sync()` runs on every mutation, so listener setup must be\n * idempotent — but those listeners (added via `listen()`) are all removed\n * on disconnect, so the \"already wired\" memory must reset with them, or a\n * reparented element (disconnect + connect) would silently stop firing.\n */\n protected wireOnce(node: Node, wire: () => void): void {\n if (this._wiredNodes.has(node)) return;\n this._wiredNodes.add(node);\n wire();\n }\n\n /** What to watch for changes worth re-syncing on. Override for a narrower/wider scope. */\n protected observerInit(): MutationObserverInit {\n return { childList: true, subtree: true, attributes: true };\n }\n\n /** Re-derive this element's own attributes/classes from its current children. */\n protected abstract _sync(): void;\n\n /** Unused — content is the author's own children, never replaced. */\n protected override render(): string {\n return '';\n }\n}\n","/**\n * Guarded DOM writes for use inside `A11yWrapperElement._sync()` methods (or\n * anywhere else re-syncing against a live MutationObserver).\n *\n * `setAttribute`/`removeAttribute`/`classList.add`/`classList.remove`/\n * `textContent =` all queue a mutation record unconditionally — even when\n * the value being written is identical to what's already there. Call one of\n * these unguarded inside a MutationObserver callback that's itself watching\n * the element being written to, and every \"no-op\" write retriggers the\n * observer, forever. These helpers check first, so a `_sync()` call that\n * changes nothing produces zero mutations and the observer loop terminates.\n */\n\nexport function syncText(el: Element, text: string): void {\n if (el.textContent !== text) el.textContent = text;\n}\n\nexport function syncAttr(el: Element, name: string, value: string | null | undefined): void {\n if (value == null) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else if (el.getAttribute(name) !== value) {\n el.setAttribute(name, value);\n }\n}\n\nexport function syncClass(el: Element, name: string, present: boolean): void {\n if (el.classList.contains(name) !== present) el.classList.toggle(name, present);\n}\n\n/**\n * Adds or removes one id in an id-reference list attribute (`aria-describedby`,\n * `aria-labelledby`, …), keeping every other token — typically ids the\n * consumer set — in place. Removes the attribute once the list is empty.\n */\nexport function syncIdRef(el: Element, name: string, id: string, present: boolean): void {\n const ids = (el.getAttribute(name) ?? '').split(/\\s+/).filter(Boolean);\n const has = ids.includes(id);\n if (has === present) return;\n const next = present ? [...ids, id] : ids.filter((token) => token !== id);\n syncAttr(el, name, next.length ? next.join(' ') : null);\n}\n","import { A11yWrapperElement } from '../../core/a11y-wrapper-element.js';\nimport { syncClass, syncText } from '../../core/dom-sync.js';\n\n/**\n * Enhances a real `<input type=\"checkbox\">` authored by the consumer with a\n * wrapping `<label>` (for native click-the-label-to-toggle + implicit\n * accessible naming — a custom element can't itself *be* a `<label>`) and a\n * visible label span.\n *\n * ```html\n * <a11y-checkbox label=\"Accept terms\">\n * <input type=\"checkbox\" name=\"terms\" required>\n * </a11y-checkbox>\n * ```\n *\n * The input is never regenerated — id/name/value/checked/disabled/required\n * are plain native HTML attributes the consumer already controls directly,\n * so there's nothing to keep in sync and no risk of an unrelated re-render\n * wiping out a user's live checked state. `indeterminate` (no HTML attribute\n * equivalent) and `onChange` are the two things this element adds.\n *\n * Every DOM write in `_sync()` goes through the guarded `dom-sync` helpers:\n * `setAttribute`/`classList.add`/`textContent =` all queue a mutation record\n * even when the value is unchanged, and `_sync()` itself runs inside a\n * `MutationObserver` callback watching this subtree — an unguarded write\n * would retrigger the observer forever.\n */\nexport class CheckboxElement extends A11yWrapperElement {\n static get observedAttributes(): string[] {\n return ['label', 'indeterminate'];\n }\n\n\n /** Called with the input's current `checked` state on every native `change` event. */\n declare onChange?: (checked: boolean) => void;\n\n getValue(): boolean {\n return this._input()?.checked ?? false;\n }\n\n setValue(checked: boolean): void {\n const input = this._input();\n if (input) input.checked = checked;\n }\n\n private _input(): HTMLInputElement | null {\n return this.querySelector('input[type=\"checkbox\"]');\n }\n\n protected override _sync(): void {\n const input = this._input();\n if (!input) return;\n\n const wrapper = this._ensureWrapper(input);\n syncClass(input, 'a11y-checkbox__input', true);\n input.indeterminate = this.boolAttr('indeterminate'); // IDL-only property, never reflected — safe unguarded\n this._syncLabel(wrapper);\n\n this.wireOnce(input, () => this.listen(input, 'change', () => this.onChange?.(input.checked)));\n }\n\n private _ensureWrapper(input: HTMLInputElement): HTMLLabelElement {\n const existing = input.closest<HTMLLabelElement>('label.a11y-checkbox');\n if (existing && existing.parentElement === this) return existing;\n\n const wrapper = document.createElement('label');\n wrapper.className = 'a11y-checkbox';\n input.replaceWith(wrapper);\n wrapper.appendChild(input);\n return wrapper;\n }\n\n private _syncLabel(wrapper: HTMLLabelElement): void {\n const text = this.optionalStringAttr('label');\n let span = wrapper.querySelector<HTMLElement>('.a11y-checkbox__label');\n if (!text) {\n span?.remove();\n return;\n }\n if (!span) {\n span = document.createElement('span');\n span.className = 'a11y-checkbox__label';\n wrapper.appendChild(span);\n }\n syncText(span, text);\n }\n}\n","import { CheckboxElement } from './checkbox.element.js';\n\nif (!customElements.get('a11y-checkbox')) {\n customElements.define('a11y-checkbox', CheckboxElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-checkbox': CheckboxElement;\n }\n}\n\nexport { CheckboxElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\n"],"mappings":";AA8BO,IAAM,kBAAyC,OAAO,OAAO;AAAA,EAClE,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SAAS;AAAA,EACT,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,oBAAoB;AACtB,CAAC;AAGM,IAAM,uBAAuB;AAQpC,IAAM,cAAc,uBAAO,IAAI,uBAAuB;AACtD,IAAM,QAAQ;AACd,IAAM,UAAwB,MAAM,WAAW,MAAM,EAAE,GAAG,gBAAgB;AAE1E,WAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,eAAe,EAAoC,SAAQ,GAAG,MAAM;AAGvG,SAAS,WAAW,SAAqC;AAC9D,aAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,OAAO,GAAgD;AAC/F,QAAI,OAAO,mBAAmB,OAAO,UAAU,SAAU,SAAQ,GAAG,IAAI;AAAA,EAC1E;AACA,WAAS,cAAc,IAAI,MAAM,oBAAoB,CAAC;AACxD;AAGO,SAAS,eAAqB;AACnC,SAAO,OAAO,SAAS,eAAe;AACtC,WAAS,cAAc,IAAI,MAAM,oBAAoB,CA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;AACzB,YAAQ,YAAY,KAAK;AACzB,WAAO;AAAA,EACT;AAAA,EAEQ,WAAW,SAAiC;AAClD,UAAM,OAAO,KAAK,mBAAmB,OAAO;AAC5C,QAAI,OAAO,QAAQ,cAA2B,uBAAuB;AACrE,QAAI,CAAC,MAAM;AACT,YAAM,OAAO;AACb;AAAA,IACF;AACA,QAAI,CAAC,MAAM;AACT,aAAO,SAAS,cAAc,MAAM;AACpC,WAAK,YAAY;AACjB,cAAQ,YAAY,IAAI;AAAA,IAC1B;AACA,aAAS,MAAM,IAAI;AAAA,EACrB;AACF;;;ACpFA,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AACxC,iBAAe,OAAO,iBAAiB,eAAe;AACxD;","names":[]}
1
+ {"version":3,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/a11y-wrapper-element.ts","../../../../src/core/dom-sync.ts","../../../../src/components/checkbox/checkbox.element.ts","../../../../src/components/checkbox/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n /** The generated \"Select all\" checkbox of `<a11y-checkbox-group select-all>`. */\n selectAll: string;\n /** The browse button of `<a11y-file-input>`. */\n browseFiles: string;\n /** The drag & drop prompt next to `<a11y-file-input>`'s browse button. */\n dropFiles: string;\n /** Accessible name of `<a11y-file-input>`'s list of selected files. */\n selectedFiles: string;\n /** Visible text of each remove button of `<a11y-file-input>`. */\n remove: string;\n /** Accessible name of each remove button of `<a11y-file-input>`; `{name}` is the file name. */\n removeFile: string;\n /** Announced when `<a11y-file-input>` adds one file; `{name}` is its name. */\n fileAdded: string;\n /** Announced when `<a11y-file-input>` adds several files; `{count}` is how many. */\n filesAdded: string;\n /** Announced when `<a11y-file-input>` removes a file; `{name}` is its name. */\n fileRemoved: string;\n /** Shown and announced for a file `accept` rules out; `{name}` is its name. */\n fileTypeRejected: string;\n /** Shown and announced for a file over `max-size`; `{name}`, `{maxSize}`. */\n fileSizeRejected: string;\n /** Shown and announced for a file past `max-files`; `{name}`, `{max}`. */\n fileCountRejected: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n selectAll: 'Select all',\n browseFiles: 'Browse files',\n dropFiles: 'or drop files here',\n selectedFiles: 'Selected files',\n remove: 'Remove',\n removeFile: 'Remove {name}',\n fileAdded: '{name} added',\n filesAdded: '{count} files added',\n fileRemoved: '{name} removed',\n fileTypeRejected: '{name} wasn’t added: this type of file isn’t allowed',\n fileSizeRejected: '{name} wasn’t added: it’s larger than {maxSize}',\n fileCountRejected: '{name} wasn’t added: too many files (maximum {max})',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","import { A11yElement } from './a11y-element.js';\n\n/**\n * Base for elements that enhance real, consumer-authored light-DOM children\n * instead of generating their own markup from a template string — e.g. a\n * `<a11y-picture>` wrapping a real `<picture>`/`<img>`/`<figcaption>`, or\n * `<a11y-select>` wrapping a real `<select>`/`<option>`s.\n *\n * Unlike `A11yElement`, this never sets `innerHTML` from a `render()`\n * string — that would destroy the author's children — so it opts out of the\n * normal render pipeline and instead re-syncs (`_sync()`) from two sources:\n *\n * - **This element's own observed attributes** (e.g. `label`, `legend`),\n * listed via `static observedAttributes` same as any other element —\n * these re-sync *synchronously*, matching every other element in this\n * library, so `el.setAttribute('label', 'x')` takes effect immediately.\n * - **Everything else** (children added/removed, an attribute changing on\n * one of *those* children) — light DOM has no `slotchange`, so a\n * `MutationObserver` is the equivalent, necessarily asynchronous (a real\n * microtask/task delay after the mutation).\n *\n * `_sync()` runs inside that `MutationObserver` callback, so every DOM write\n * it makes must be guarded (see `core/dom-sync.ts`) — `setAttribute`/\n * `classList.add`/`textContent =` all queue a mutation record even when the\n * value is unchanged, and an unguarded write would retrigger the observer\n * forever.\n */\nexport abstract class A11yWrapperElement extends A11yElement {\n private _observer: MutationObserver | null = null;\n /** Nodes already given their listeners since the last connect — see `wireOnce()`. */\n private _wiredNodes = new WeakSet<Node>();\n\n override connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this._sync();\n this._observer = new MutationObserver(() => this._sync());\n this._observer.observe(this, this.observerInit());\n }\n\n override disconnectedCallback(): void {\n this._observer?.disconnect();\n this._observer = null;\n super.disconnectedCallback(); // removes every `listen()` listener…\n this._wiredNodes = new WeakSet(); // …so the next connect must wire them again\n }\n\n override attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this._sync();\n }\n\n /**\n * Runs `wire` the first time `node` is seen since this element was last\n * connected. `_sync()` runs on every mutation, so listener setup must be\n * idempotent — but those listeners (added via `listen()`) are all removed\n * on disconnect, so the \"already wired\" memory must reset with them, or a\n * reparented element (disconnect + connect) would silently stop firing.\n */\n protected wireOnce(node: Node, wire: () => void): void {\n if (this._wiredNodes.has(node)) return;\n this._wiredNodes.add(node);\n wire();\n }\n\n /** What to watch for changes worth re-syncing on. Override for a narrower/wider scope. */\n protected observerInit(): MutationObserverInit {\n return { childList: true, subtree: true, attributes: true };\n }\n\n /** Re-derive this element's own attributes/classes from its current children. */\n protected abstract _sync(): void;\n\n /** Unused — content is the author's own children, never replaced. */\n protected override render(): string {\n return '';\n }\n}\n","/**\n * Guarded DOM writes for use inside `A11yWrapperElement._sync()` methods (or\n * anywhere else re-syncing against a live MutationObserver).\n *\n * `setAttribute`/`removeAttribute`/`classList.add`/`classList.remove`/\n * `textContent =` all queue a mutation record unconditionally — even when\n * the value being written is identical to what's already there. Call one of\n * these unguarded inside a MutationObserver callback that's itself watching\n * the element being written to, and every \"no-op\" write retriggers the\n * observer, forever. These helpers check first, so a `_sync()` call that\n * changes nothing produces zero mutations and the observer loop terminates.\n */\n\nexport function syncText(el: Element, text: string): void {\n if (el.textContent !== text) el.textContent = text;\n}\n\nexport function syncAttr(el: Element, name: string, value: string | null | undefined): void {\n if (value == null) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else if (el.getAttribute(name) !== value) {\n el.setAttribute(name, value);\n }\n}\n\nexport function syncClass(el: Element, name: string, present: boolean): void {\n if (el.classList.contains(name) !== present) el.classList.toggle(name, present);\n}\n\n/**\n * Adds or removes one id in an id-reference list attribute (`aria-describedby`,\n * `aria-labelledby`, …), keeping every other token — typically ids the\n * consumer set — in place. Removes the attribute once the list is empty.\n */\nexport function syncIdRef(el: Element, name: string, id: string, present: boolean): void {\n const ids = (el.getAttribute(name) ?? '').split(/\\s+/).filter(Boolean);\n const has = ids.includes(id);\n if (has === present) return;\n const next = present ? [...ids, id] : ids.filter((token) => token !== id);\n syncAttr(el, name, next.length ? next.join(' ') : null);\n}\n","import { A11yWrapperElement } from '../../core/a11y-wrapper-element.js';\nimport { syncClass, syncText } from '../../core/dom-sync.js';\n\n/**\n * Enhances a real `<input type=\"checkbox\">` authored by the consumer with a\n * wrapping `<label>` (for native click-the-label-to-toggle + implicit\n * accessible naming — a custom element can't itself *be* a `<label>`) and a\n * visible label span.\n *\n * ```html\n * <a11y-checkbox label=\"Accept terms\">\n * <input type=\"checkbox\" name=\"terms\" required>\n * </a11y-checkbox>\n * ```\n *\n * The input is never regenerated — id/name/value/checked/disabled/required\n * are plain native HTML attributes the consumer already controls directly,\n * so there's nothing to keep in sync and no risk of an unrelated re-render\n * wiping out a user's live checked state. `indeterminate` (no HTML attribute\n * equivalent) and `onChange` are the two things this element adds.\n *\n * Every DOM write in `_sync()` goes through the guarded `dom-sync` helpers:\n * `setAttribute`/`classList.add`/`textContent =` all queue a mutation record\n * even when the value is unchanged, and `_sync()` itself runs inside a\n * `MutationObserver` callback watching this subtree — an unguarded write\n * would retrigger the observer forever.\n */\nexport class CheckboxElement extends A11yWrapperElement {\n static get observedAttributes(): string[] {\n return ['label', 'indeterminate'];\n }\n\n\n /** Called with the input's current `checked` state on every native `change` event. */\n declare onChange?: (checked: boolean) => void;\n\n getValue(): boolean {\n return this._input()?.checked ?? false;\n }\n\n setValue(checked: boolean): void {\n const input = this._input();\n if (input) input.checked = checked;\n }\n\n private _input(): HTMLInputElement | null {\n return this.querySelector('input[type=\"checkbox\"]');\n }\n\n protected override _sync(): void {\n const input = this._input();\n if (!input) return;\n\n const wrapper = this._ensureWrapper(input);\n syncClass(input, 'a11y-checkbox__input', true);\n input.indeterminate = this.boolAttr('indeterminate'); // IDL-only property, never reflected — safe unguarded\n this._syncLabel(wrapper);\n\n this.wireOnce(input, () => this.listen(input, 'change', () => this.onChange?.(input.checked)));\n }\n\n private _ensureWrapper(input: HTMLInputElement): HTMLLabelElement {\n const existing = input.closest<HTMLLabelElement>('label.a11y-checkbox');\n if (existing && existing.parentElement === this) return existing;\n\n const wrapper = document.createElement('label');\n wrapper.className = 'a11y-checkbox';\n input.replaceWith(wrapper);\n wrapper.appendChild(input);\n return wrapper;\n }\n\n private _syncLabel(wrapper: HTMLLabelElement): void {\n const text = this.optionalStringAttr('label');\n let span = wrapper.querySelector<HTMLElement>('.a11y-checkbox__label');\n if (!text) {\n span?.remove();\n return;\n }\n if (!span) {\n span = document.createElement('span');\n span.className = 'a11y-checkbox__label';\n wrapper.appendChild(span);\n }\n syncText(span, text);\n }\n}\n","import { CheckboxElement } from './checkbox.element.js';\n\nif (!customElements.get('a11y-checkbox')) {\n customElements.define('a11y-checkbox', CheckboxElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-checkbox': CheckboxElement;\n }\n}\n\nexport { CheckboxElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\n"],"mappings":";AAsDO,I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,WAAK,YAAY;AACjB,cAAQ,YAAY,IAAI;AAAA,IAC1B;AACA,aAAS,MAAM,IAAI;AAAA,EACrB;AACF;;;ACpFA,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AACxC,iBAAe,OAAO,iBAAiB,eAAe;AACxD;","names":[]}
@@ -0,0 +1,394 @@
1
+ // src/core/strings.ts
2
+ var DEFAULT_STRINGS = Object.freeze({
3
+ opensInNewTab: "(opens in new tab)",
4
+ navigatedTo: "Navigated to {name}",
5
+ closeDialog: "Close dialog",
6
+ dismiss: "Dismiss",
7
+ loading: "Loading",
8
+ progress: "Progress",
9
+ avatar: "Avatar",
10
+ characterCount: "{count} / {max}",
11
+ charactersRemaining: "{count} characters remaining",
12
+ characterRemaining: "{count} character remaining",
13
+ selectAll: "Select all",
14
+ browseFiles: "Browse files",
15
+ dropFiles: "or drop files here",
16
+ selectedFiles: "Selected files",
17
+ remove: "Remove",
18
+ removeFile: "Remove {name}",
19
+ fileAdded: "{name} added",
20
+ filesAdded: "{count} files added",
21
+ fileRemoved: "{name} removed",
22
+ fileTypeRejected: "{name} wasn\u2019t added: this type of file isn\u2019t allowed",
23
+ fileSizeRejected: "{name} wasn\u2019t added: it\u2019s larger than {maxSize}",
24
+ fileCountRejected: "{name} wasn\u2019t added: too many files (maximum {max})"
25
+ });
26
+ var STRINGS_CHANGE_EVENT = "a11y-strings-change";
27
+ var STRINGS_KEY = /* @__PURE__ */ Symbol.for("a11y-elements/strings");
28
+ var store = globalThis;
29
+ var strings = store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS };
30
+ for (const [key, value] of Object.entries(DEFAULT_STRINGS)) strings[key] ??= value;
31
+ function setStrings(partial) {
32
+ for (const [key, value] of Object.entries(partial)) {
33
+ if (key in DEFAULT_STRINGS && typeof value === "string") strings[key] = value;
34
+ }
35
+ document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));
36
+ }
37
+ function resetStrings() {
38
+ Object.assign(strings, DEFAULT_STRINGS);
39
+ document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));
40
+ }
41
+ function getString(key) {
42
+ return strings[key];
43
+ }
44
+
45
+ // src/core/a11y-element.ts
46
+ var A11yElement = class extends HTMLElement {
47
+ _connected = false;
48
+ _listeners = [];
49
+ _updating = false;
50
+ /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */
51
+ _cssVarOwned = /* @__PURE__ */ new Map();
52
+ /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */
53
+ _stringsListener = null;
54
+ connectedCallback() {
55
+ this._initConnect();
56
+ this._connected = true;
57
+ this.update();
58
+ }
59
+ disconnectedCallback() {
60
+ this._connected = false;
61
+ this._cleanupListeners();
62
+ if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);
63
+ this._stringsListener = null;
64
+ this.onDisconnect?.();
65
+ }
66
+ /**
67
+ * Connect-time setup shared by every base class. Every `connectedCallback`
68
+ * override that doesn't call super must call this itself, before setting
69
+ * `_connected` (so replayed setters only write attributes, and the normal
70
+ * connect path then acts on them).
71
+ */
72
+ _initConnect() {
73
+ this._upgradeProperties();
74
+ this._watchStrings();
75
+ }
76
+ /**
77
+ * A property set on the element before its class was defined (e.g.
78
+ * `el.open = true` before a lazy-loaded bundle runs) is an own property
79
+ * that shadows the class accessor. Replay each one through the setter.
80
+ */
81
+ _upgradeProperties() {
82
+ for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {
83
+ for (const name of Object.getOwnPropertyNames(proto)) {
84
+ if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;
85
+ const self = this;
86
+ const value = self[name];
87
+ delete self[name];
88
+ self[name] = value;
89
+ }
90
+ }
91
+ }
92
+ /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */
93
+ _watchStrings() {
94
+ if (!this.onStringsChange || this._stringsListener) return;
95
+ this._stringsListener = () => {
96
+ if (this._connected) this.onStringsChange?.();
97
+ };
98
+ document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);
99
+ }
100
+ attributeChangedCallback(_name, oldValue, newValue) {
101
+ if (oldValue === newValue || !this._connected) return;
102
+ this.update();
103
+ }
104
+ update() {
105
+ if (this._updating) return;
106
+ this._updating = true;
107
+ try {
108
+ this._cleanupListeners();
109
+ this.onBeforeRender?.();
110
+ this.innerHTML = String(this.render());
111
+ this.onAfterRender?.();
112
+ } finally {
113
+ this._updating = false;
114
+ }
115
+ }
116
+ /**
117
+ * Adds a listener and tracks it for automatic removal on the next render
118
+ * and on disconnect — the direct replacement for the old framework's
119
+ * `[el, type, handler]` cleanup-array convention.
120
+ */
121
+ listen(target, type, handler, options) {
122
+ target.addEventListener(type, handler, options);
123
+ this._listeners.push([target, type, handler, options]);
124
+ }
125
+ _cleanupListeners() {
126
+ for (const [target, type, handler, options] of this._listeners) {
127
+ target.removeEventListener(type, handler, options);
128
+ }
129
+ this._listeners = [];
130
+ }
131
+ /** Dispatches a bubbling CustomEvent from this element. */
132
+ emit(type, detail) {
133
+ return this.dispatchEvent(new CustomEvent(type, { bubbles: true, detail }));
134
+ }
135
+ // --- small attribute-reflection helpers, shared across components ---
136
+ stringAttr(name, fallback = "") {
137
+ return this.getAttribute(name) ?? fallback;
138
+ }
139
+ optionalStringAttr(name) {
140
+ return this.getAttribute(name) ?? void 0;
141
+ }
142
+ boolAttr(name) {
143
+ return this.hasAttribute(name);
144
+ }
145
+ numberAttr(name, fallback) {
146
+ const value = this.getAttribute(name);
147
+ if (value == null) return fallback;
148
+ const parsed = Number(value);
149
+ return Number.isNaN(parsed) ? fallback : parsed;
150
+ }
151
+ setBoolAttr(name, value) {
152
+ if (value) this.setAttribute(name, "");
153
+ else this.removeAttribute(name);
154
+ }
155
+ /**
156
+ * Sets a CSS custom property on this element while `value` is truthy. When
157
+ * it isn't, only a property this method set itself is undone — restored to
158
+ * the consumer's own inline value from before (or removed if there was
159
+ * none) — so a consumer's `style="--a11y-…: …"` survives when the matching
160
+ * attribute is absent.
161
+ */
162
+ setCssVar(name, value) {
163
+ if (value) {
164
+ if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));
165
+ this.style.setProperty(name, value);
166
+ return;
167
+ }
168
+ if (!this._cssVarOwned.has(name)) return;
169
+ const previous = this._cssVarOwned.get(name);
170
+ this._cssVarOwned.delete(name);
171
+ if (previous) this.style.setProperty(name, previous);
172
+ else this.style.removeProperty(name);
173
+ }
174
+ };
175
+
176
+ // src/core/a11y-wrapper-element.ts
177
+ var A11yWrapperElement = class extends A11yElement {
178
+ _observer = null;
179
+ /** Nodes already given their listeners since the last connect — see `wireOnce()`. */
180
+ _wiredNodes = /* @__PURE__ */ new WeakSet();
181
+ connectedCallback() {
182
+ this._initConnect();
183
+ this._connected = true;
184
+ this._sync();
185
+ this._observer = new MutationObserver(() => this._sync());
186
+ this._observer.observe(this, this.observerInit());
187
+ }
188
+ disconnectedCallback() {
189
+ this._observer?.disconnect();
190
+ this._observer = null;
191
+ super.disconnectedCallback();
192
+ this._wiredNodes = /* @__PURE__ */ new WeakSet();
193
+ }
194
+ attributeChangedCallback(_name, oldValue, newValue) {
195
+ if (oldValue === newValue || !this._connected) return;
196
+ this._sync();
197
+ }
198
+ /**
199
+ * Runs `wire` the first time `node` is seen since this element was last
200
+ * connected. `_sync()` runs on every mutation, so listener setup must be
201
+ * idempotent — but those listeners (added via `listen()`) are all removed
202
+ * on disconnect, so the "already wired" memory must reset with them, or a
203
+ * reparented element (disconnect + connect) would silently stop firing.
204
+ */
205
+ wireOnce(node, wire) {
206
+ if (this._wiredNodes.has(node)) return;
207
+ this._wiredNodes.add(node);
208
+ wire();
209
+ }
210
+ /** What to watch for changes worth re-syncing on. Override for a narrower/wider scope. */
211
+ observerInit() {
212
+ return { childList: true, subtree: true, attributes: true };
213
+ }
214
+ /** Unused — content is the author's own children, never replaced. */
215
+ render() {
216
+ return "";
217
+ }
218
+ };
219
+
220
+ // src/core/dom-sync.ts
221
+ function syncText(el, text) {
222
+ if (el.textContent !== text) el.textContent = text;
223
+ }
224
+ function syncAttr(el, name, value) {
225
+ if (value == null) {
226
+ if (el.hasAttribute(name)) el.removeAttribute(name);
227
+ } else if (el.getAttribute(name) !== value) {
228
+ el.setAttribute(name, value);
229
+ }
230
+ }
231
+ function syncClass(el, name, present) {
232
+ if (el.classList.contains(name) !== present) el.classList.toggle(name, present);
233
+ }
234
+
235
+ // src/components/checkbox-group/checkbox-group.element.ts
236
+ var SELECT_ALL_INPUT_CLASS = "a11y-checkbox-group__select-all-input";
237
+ var CheckboxGroupElement = class extends A11yWrapperElement {
238
+ static get observedAttributes() {
239
+ return ["legend", "aria-label", "disabled", "select-all", "select-all-label"];
240
+ }
241
+ /** True while select-all toggles options, so their `change` events don't each call `onChange`. */
242
+ _bulkUpdating = false;
243
+ getValue() {
244
+ return this._options().filter((input) => input.checked).map((input) => input.value);
245
+ }
246
+ /** Checks exactly the options whose value is in `values` and unchecks the rest. */
247
+ setValue(values) {
248
+ for (const input of this._options()) input.checked = values.includes(input.value);
249
+ this._syncSelectAll();
250
+ }
251
+ /** Checks every enabled option. Silent, like `setValue()`: no events, no `onChange`. */
252
+ selectAll() {
253
+ this._setAllEnabled(true);
254
+ }
255
+ /** Unchecks every enabled option. Silent, like `setValue()`: no events, no `onChange`. */
256
+ unselectAll() {
257
+ this._setAllEnabled(false);
258
+ }
259
+ _fieldset() {
260
+ return this.querySelector("fieldset.a11y-checkbox-group");
261
+ }
262
+ _selectAllInput() {
263
+ return this._fieldset()?.querySelector(`.${SELECT_ALL_INPUT_CLASS}`) ?? null;
264
+ }
265
+ _options() {
266
+ const fieldset = this._fieldset();
267
+ if (!fieldset) return [];
268
+ return [...fieldset.querySelectorAll(`input[type="checkbox"]:not(.${SELECT_ALL_INPUT_CLASS})`)];
269
+ }
270
+ _enabledOptions() {
271
+ return this._options().filter((input) => !input.matches(":disabled"));
272
+ }
273
+ onStringsChange() {
274
+ this._sync();
275
+ }
276
+ _sync() {
277
+ if (!this.querySelector('input[type="checkbox"]')) return;
278
+ const fieldset = this._ensureFieldset();
279
+ for (const input of this._options()) {
280
+ syncClass(input, "a11y-checkbox__input", true);
281
+ const label = input.closest("label");
282
+ if (label && fieldset.contains(label)) syncClass(label, "a11y-checkbox", true);
283
+ }
284
+ syncAttr(fieldset, "disabled", this.boolAttr("disabled") ? "" : null);
285
+ this._syncLegend(fieldset);
286
+ this._syncSelectAllControl(fieldset);
287
+ this._syncSelectAll();
288
+ this.wireOnce(
289
+ fieldset,
290
+ () => this.listen(fieldset, "change", (e) => {
291
+ const target = e.target;
292
+ if (!target.matches('input[type="checkbox"]')) return;
293
+ if (target.classList.contains(SELECT_ALL_INPUT_CLASS)) {
294
+ this._toggleAllFromUser(target.checked);
295
+ return;
296
+ }
297
+ this._syncSelectAll();
298
+ if (!this._bulkUpdating) this.onChange?.(this.getValue());
299
+ })
300
+ );
301
+ }
302
+ _ensureFieldset() {
303
+ const existing = this._fieldset();
304
+ if (existing) return existing;
305
+ const fieldset = document.createElement("fieldset");
306
+ fieldset.className = "a11y-checkbox-group";
307
+ while (this.firstChild) fieldset.appendChild(this.firstChild);
308
+ this.appendChild(fieldset);
309
+ return fieldset;
310
+ }
311
+ _syncLegend(fieldset) {
312
+ const legendText = this.optionalStringAttr("legend");
313
+ const ariaLabel = this.optionalStringAttr("aria-label");
314
+ let legend = fieldset.querySelector(".a11y-checkbox-group__legend");
315
+ if (legendText) {
316
+ if (!legend) {
317
+ legend = document.createElement("legend");
318
+ legend.className = "a11y-checkbox-group__legend";
319
+ fieldset.prepend(legend);
320
+ }
321
+ syncText(legend, legendText);
322
+ syncAttr(fieldset, "aria-label", null);
323
+ } else {
324
+ legend?.remove();
325
+ syncAttr(fieldset, "aria-label", ariaLabel);
326
+ }
327
+ }
328
+ /** Builds/removes the select-all `<label>` and keeps it right after the legend (or first). */
329
+ _syncSelectAllControl(fieldset) {
330
+ let wrapper = fieldset.querySelector(".a11y-checkbox-group__select-all");
331
+ if (!this.boolAttr("select-all")) {
332
+ wrapper?.remove();
333
+ return;
334
+ }
335
+ if (!wrapper) {
336
+ wrapper = document.createElement("label");
337
+ wrapper.className = "a11y-checkbox a11y-checkbox-group__select-all";
338
+ const input = document.createElement("input");
339
+ input.type = "checkbox";
340
+ input.className = `a11y-checkbox__input ${SELECT_ALL_INPUT_CLASS}`;
341
+ const span = document.createElement("span");
342
+ span.className = "a11y-checkbox__label";
343
+ wrapper.append(input, span);
344
+ }
345
+ const legend = fieldset.querySelector(".a11y-checkbox-group__legend");
346
+ const expectedPrevious = legend ?? null;
347
+ if (wrapper.parentElement !== fieldset || wrapper.previousElementSibling !== expectedPrevious) {
348
+ if (legend) legend.after(wrapper);
349
+ else fieldset.prepend(wrapper);
350
+ }
351
+ syncText(wrapper.querySelector(".a11y-checkbox__label"), this.stringAttr("select-all-label", getString("selectAll")));
352
+ }
353
+ /** Mirrors the enabled options onto the select-all input: checked / indeterminate / unchecked. */
354
+ _syncSelectAll() {
355
+ const selectAll = this._selectAllInput();
356
+ if (!selectAll) return;
357
+ const enabled = this._enabledOptions();
358
+ const checkedCount = enabled.filter((input) => input.checked).length;
359
+ selectAll.checked = enabled.length > 0 && checkedCount === enabled.length;
360
+ selectAll.indeterminate = checkedCount > 0 && checkedCount < enabled.length;
361
+ selectAll.disabled = enabled.length === 0;
362
+ }
363
+ _setAllEnabled(checked) {
364
+ const changed = this._enabledOptions().filter((input) => input.checked !== checked);
365
+ for (const input of changed) input.checked = checked;
366
+ this._syncSelectAll();
367
+ return changed;
368
+ }
369
+ /** A select-all click: toggles every enabled option, fires their native events, then `onChange` once. */
370
+ _toggleAllFromUser(checked) {
371
+ const changed = this._setAllEnabled(checked);
372
+ this._bulkUpdating = true;
373
+ try {
374
+ for (const input of changed) {
375
+ input.dispatchEvent(new Event("input", { bubbles: true, composed: true }));
376
+ input.dispatchEvent(new Event("change", { bubbles: true }));
377
+ }
378
+ } finally {
379
+ this._bulkUpdating = false;
380
+ }
381
+ if (changed.length > 0) this.onChange?.(this.getValue());
382
+ }
383
+ };
384
+
385
+ // src/components/checkbox-group/define.ts
386
+ if (!customElements.get("a11y-checkbox-group")) {
387
+ customElements.define("a11y-checkbox-group", CheckboxGroupElement);
388
+ }
389
+ export {
390
+ CheckboxGroupElement,
391
+ resetStrings,
392
+ setStrings
393
+ };
394
+ //# sourceMappingURL=define.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/core/strings.ts","../../../../src/core/a11y-element.ts","../../../../src/core/a11y-wrapper-element.ts","../../../../src/core/dom-sync.ts","../../../../src/components/checkbox-group/checkbox-group.element.ts","../../../../src/components/checkbox-group/define.ts"],"sourcesContent":["/**\n * The library's built-in, user-facing strings — text that ends up in\n * accessible names and announcements — so a consumer can translate them.\n *\n * Precedence, per element: an instance attribute (e.g. `close-label`) wins,\n * then whatever `setStrings()` set, then these English defaults.\n */\nexport interface A11yStrings {\n /** Appended to a new-tab link's accessible name by `<a11y-anchor>`. */\n opensInNewTab: string;\n /** `<a11y-anchor>`'s same-page jump announcement; `{name}` is the target's name. */\n navigatedTo: string;\n /** The close button of `<a11y-modal>`, `<a11y-drawer>` and `<a11y-emergency-dialog>`. */\n closeDialog: string;\n /** The close button of each `<a11y-notification-banner>` item. */\n dismiss: string;\n /** Default label of `<a11y-spinner>` and `<a11y-blocking-loader>`. */\n loading: string;\n /** Default accessible name of `<a11y-progress>`. */\n progress: string;\n /** Last-resort accessible name of `<a11y-avatar>`. */\n avatar: string;\n /** Visible text of an `<a11y-counter>`; `{count}` is the current length, `{max}` the `maxlength`. */\n characterCount: string;\n /** What an `<a11y-counter>` announces near the limit; `{count}` is the number of characters left. */\n charactersRemaining: string;\n /** `charactersRemaining` when exactly one character is left. */\n characterRemaining: string;\n /** The generated \"Select all\" checkbox of `<a11y-checkbox-group select-all>`. */\n selectAll: string;\n /** The browse button of `<a11y-file-input>`. */\n browseFiles: string;\n /** The drag & drop prompt next to `<a11y-file-input>`'s browse button. */\n dropFiles: string;\n /** Accessible name of `<a11y-file-input>`'s list of selected files. */\n selectedFiles: string;\n /** Visible text of each remove button of `<a11y-file-input>`. */\n remove: string;\n /** Accessible name of each remove button of `<a11y-file-input>`; `{name}` is the file name. */\n removeFile: string;\n /** Announced when `<a11y-file-input>` adds one file; `{name}` is its name. */\n fileAdded: string;\n /** Announced when `<a11y-file-input>` adds several files; `{count}` is how many. */\n filesAdded: string;\n /** Announced when `<a11y-file-input>` removes a file; `{name}` is its name. */\n fileRemoved: string;\n /** Shown and announced for a file `accept` rules out; `{name}` is its name. */\n fileTypeRejected: string;\n /** Shown and announced for a file over `max-size`; `{name}`, `{maxSize}`. */\n fileSizeRejected: string;\n /** Shown and announced for a file past `max-files`; `{name}`, `{max}`. */\n fileCountRejected: string;\n}\n\nexport const DEFAULT_STRINGS: Readonly<A11yStrings> = Object.freeze({\n opensInNewTab: '(opens in new tab)',\n navigatedTo: 'Navigated to {name}',\n closeDialog: 'Close dialog',\n dismiss: 'Dismiss',\n loading: 'Loading',\n progress: 'Progress',\n avatar: 'Avatar',\n characterCount: '{count} / {max}',\n charactersRemaining: '{count} characters remaining',\n characterRemaining: '{count} character remaining',\n selectAll: 'Select all',\n browseFiles: 'Browse files',\n dropFiles: 'or drop files here',\n selectedFiles: 'Selected files',\n remove: 'Remove',\n removeFile: 'Remove {name}',\n fileAdded: '{name} added',\n filesAdded: '{count} files added',\n fileRemoved: '{name} removed',\n fileTypeRejected: '{name} wasn’t added: this type of file isn’t allowed',\n fileSizeRejected: '{name} wasn’t added: it’s larger than {maxSize}',\n fileCountRejected: '{name} wasn’t added: too many files (maximum {max})',\n});\n\n/** Dispatched on `document` whenever `setStrings()`/`resetStrings()` runs, so mounted elements can relabel themselves. */\nexport const STRINGS_CHANGE_EVENT = 'a11y-strings-change';\n\n/**\n * Page-wide, on `globalThis` for the same reason as the overlay registry:\n * each standalone `dist/browser/**\\/define.js` bundle inlines its own copy of\n * this module, and `setStrings()` called through one bundle must reach the\n * elements every other bundle defined.\n */\nconst STRINGS_KEY = Symbol.for('a11y-elements/strings');\nconst store = globalThis as unknown as Record<symbol, A11yStrings | undefined>;\nconst strings: A11yStrings = (store[STRINGS_KEY] ??= { ...DEFAULT_STRINGS });\n// A store created by an older bundle on the same page predates newer keys.\nfor (const [key, value] of Object.entries(DEFAULT_STRINGS) as [keyof A11yStrings, string][]) strings[key] ??= value;\n\n/** Overrides some or all built-in strings, page-wide. Elements already on the page update right away. */\nexport function setStrings(partial: Partial<A11yStrings>): void {\n for (const [key, value] of Object.entries(partial) as [keyof A11yStrings, string | undefined][]) {\n if (key in DEFAULT_STRINGS && typeof value === 'string') strings[key] = value;\n }\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\n/** Restores every built-in string to its English default. */\nexport function resetStrings(): void {\n Object.assign(strings, DEFAULT_STRINGS);\n document.dispatchEvent(new Event(STRINGS_CHANGE_EVENT));\n}\n\nexport function getString(key: keyof A11yStrings): string {\n return strings[key];\n}\n\n/** Replaces each `{key}` placeholder with `values[key]`; placeholders without a value are left as is. */\nexport function formatString(template: string, values: Record<string, string>): string {\n return template.replace(/\\{(\\w+)\\}/g, (match, key: string) => (key in values ? values[key]! : match));\n}\n","import { STRINGS_CHANGE_EVENT } from './strings.js';\nimport type { Raw } from './template.js';\n\ntype Listener = [target: EventTarget, type: string, handler: EventListener, options?: AddEventListenerOptions | boolean];\n\n/**\n * Base class for every element in this library. Light DOM only — elements\n * render real child markup styled by the consumer's own CSS, not a shadow\n * root.\n *\n * Lifecycle mirrors the old `onBeforeRender -> innerHTML = template ->\n * onAfterRender` pipeline this library used to run through a proprietary\n * framework, just mapped onto native custom-element callbacks:\n *\n * connectedCallback -> first update()\n * attributeChangedCallback -> update() for any observed attribute change\n * disconnectedCallback -> remove all tracked listeners, then onDisconnect()\n * setStrings() -> onStringsChange(), for subclasses that define it\n *\n * Subclasses list attributes to watch via `static observedAttributes` and\n * implement `render()` to return the markup for `this.innerHTML`. Attribute/\n * property setters that need to reflect into the DOM should just mutate the\n * attribute — `attributeChangedCallback` re-renders synchronously while\n * connected, so state and DOM never drift out of sync across a render.\n */\nexport abstract class A11yElement extends HTMLElement {\n protected _connected = false;\n private _listeners: Listener[] = [];\n private _updating = false;\n /** CSS vars `setCssVar()` currently owns → the consumer's inline value it replaced ('' if none). */\n private _cssVarOwned = new Map<string, string>();\n /** The `document` listener `_watchStrings()` added, if any — outside `listen()`, whose listeners every render clears. */\n private _stringsListener: EventListener | null = null;\n\n connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this.update();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this._cleanupListeners();\n if (this._stringsListener) document.removeEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n this._stringsListener = null;\n this.onDisconnect?.();\n }\n\n /**\n * Connect-time setup shared by every base class. Every `connectedCallback`\n * override that doesn't call super must call this itself, before setting\n * `_connected` (so replayed setters only write attributes, and the normal\n * connect path then acts on them).\n */\n protected _initConnect(): void {\n this._upgradeProperties();\n this._watchStrings();\n }\n\n /**\n * A property set on the element before its class was defined (e.g.\n * `el.open = true` before a lazy-loaded bundle runs) is an own property\n * that shadows the class accessor. Replay each one through the setter.\n */\n private _upgradeProperties(): void {\n for (let proto = Object.getPrototypeOf(this); proto && proto !== HTMLElement.prototype; proto = Object.getPrototypeOf(proto)) {\n for (const name of Object.getOwnPropertyNames(proto)) {\n if (!Object.prototype.hasOwnProperty.call(this, name) || !Object.getOwnPropertyDescriptor(proto, name)?.set) continue;\n const self = this as unknown as Record<string, unknown>;\n const value = self[name];\n delete self[name];\n self[name] = value;\n }\n }\n }\n\n /** Subscribes `onStringsChange()` (when defined) to `setStrings()` until disconnect. */\n private _watchStrings(): void {\n if (!this.onStringsChange || this._stringsListener) return;\n this._stringsListener = () => {\n if (this._connected) this.onStringsChange?.();\n };\n document.addEventListener(STRINGS_CHANGE_EVENT, this._stringsListener);\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this.update();\n }\n\n protected update(): void {\n // Re-entrancy guard: a listener/hook that itself mutates an observed\n // attribute during render must not trigger a nested render.\n if (this._updating) return;\n this._updating = true;\n try {\n this._cleanupListeners();\n this.onBeforeRender?.();\n this.innerHTML = String(this.render());\n this.onAfterRender?.();\n } finally {\n this._updating = false;\n }\n }\n\n /** Returns the markup to set as `this.innerHTML` on every render — a plain string, or an `html\\`...\\`` result. */\n protected abstract render(): string | Raw;\n\n /** Runs before `render()`. Typical use: set root-level classes/ARIA/CSS custom properties. */\n protected onBeforeRender?(): void;\n\n /** Runs after `render()` replaces `innerHTML`. Typical use: query into fresh markup, wire listeners, set DOM-only properties. */\n protected onAfterRender?(): void;\n\n /** Runs once, after listener cleanup, when the element leaves the DOM. */\n protected onDisconnect?(): void;\n\n /** Runs after `setStrings()`/`resetStrings()` while connected. Define it to re-apply any built-in string this element shows. */\n protected onStringsChange?(): void;\n\n /**\n * Adds a listener and tracks it for automatic removal on the next render\n * and on disconnect — the direct replacement for the old framework's\n * `[el, type, handler]` cleanup-array convention.\n */\n protected listen(\n target: EventTarget,\n type: string,\n handler: EventListener,\n options?: AddEventListenerOptions | boolean,\n ): void {\n target.addEventListener(type, handler, options);\n this._listeners.push([target, type, handler, options]);\n }\n\n private _cleanupListeners(): void {\n for (const [target, type, handler, options] of this._listeners) {\n target.removeEventListener(type, handler, options);\n }\n this._listeners = [];\n }\n\n /** Dispatches a bubbling CustomEvent from this element. */\n protected emit<T = unknown>(type: string, detail?: T): boolean {\n return this.dispatchEvent(new CustomEvent<T>(type, { bubbles: true, detail: detail as T }));\n }\n\n // --- small attribute-reflection helpers, shared across components ---\n\n protected stringAttr(name: string, fallback = ''): string {\n return this.getAttribute(name) ?? fallback;\n }\n\n protected optionalStringAttr(name: string): string | undefined {\n return this.getAttribute(name) ?? undefined;\n }\n\n protected boolAttr(name: string): boolean {\n return this.hasAttribute(name);\n }\n\n protected numberAttr(name: string, fallback: number): number {\n const value = this.getAttribute(name);\n if (value == null) return fallback;\n const parsed = Number(value);\n return Number.isNaN(parsed) ? fallback : parsed;\n }\n\n protected setBoolAttr(name: string, value: boolean): void {\n if (value) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n /**\n * Sets a CSS custom property on this element while `value` is truthy. When\n * it isn't, only a property this method set itself is undone — restored to\n * the consumer's own inline value from before (or removed if there was\n * none) — so a consumer's `style=\"--a11y-…: …\"` survives when the matching\n * attribute is absent.\n */\n protected setCssVar(name: string, value: string | null | undefined): void {\n if (value) {\n if (!this._cssVarOwned.has(name)) this._cssVarOwned.set(name, this.style.getPropertyValue(name));\n this.style.setProperty(name, value);\n return;\n }\n if (!this._cssVarOwned.has(name)) return;\n const previous = this._cssVarOwned.get(name)!;\n this._cssVarOwned.delete(name);\n if (previous) this.style.setProperty(name, previous);\n else this.style.removeProperty(name);\n }\n}\n","import { A11yElement } from './a11y-element.js';\n\n/**\n * Base for elements that enhance real, consumer-authored light-DOM children\n * instead of generating their own markup from a template string — e.g. a\n * `<a11y-picture>` wrapping a real `<picture>`/`<img>`/`<figcaption>`, or\n * `<a11y-select>` wrapping a real `<select>`/`<option>`s.\n *\n * Unlike `A11yElement`, this never sets `innerHTML` from a `render()`\n * string — that would destroy the author's children — so it opts out of the\n * normal render pipeline and instead re-syncs (`_sync()`) from two sources:\n *\n * - **This element's own observed attributes** (e.g. `label`, `legend`),\n * listed via `static observedAttributes` same as any other element —\n * these re-sync *synchronously*, matching every other element in this\n * library, so `el.setAttribute('label', 'x')` takes effect immediately.\n * - **Everything else** (children added/removed, an attribute changing on\n * one of *those* children) — light DOM has no `slotchange`, so a\n * `MutationObserver` is the equivalent, necessarily asynchronous (a real\n * microtask/task delay after the mutation).\n *\n * `_sync()` runs inside that `MutationObserver` callback, so every DOM write\n * it makes must be guarded (see `core/dom-sync.ts`) — `setAttribute`/\n * `classList.add`/`textContent =` all queue a mutation record even when the\n * value is unchanged, and an unguarded write would retrigger the observer\n * forever.\n */\nexport abstract class A11yWrapperElement extends A11yElement {\n private _observer: MutationObserver | null = null;\n /** Nodes already given their listeners since the last connect — see `wireOnce()`. */\n private _wiredNodes = new WeakSet<Node>();\n\n override connectedCallback(): void {\n this._initConnect();\n this._connected = true;\n this._sync();\n this._observer = new MutationObserver(() => this._sync());\n this._observer.observe(this, this.observerInit());\n }\n\n override disconnectedCallback(): void {\n this._observer?.disconnect();\n this._observer = null;\n super.disconnectedCallback(); // removes every `listen()` listener…\n this._wiredNodes = new WeakSet(); // …so the next connect must wire them again\n }\n\n override attributeChangedCallback(_name: string, oldValue: string | null, newValue: string | null): void {\n if (oldValue === newValue || !this._connected) return;\n this._sync();\n }\n\n /**\n * Runs `wire` the first time `node` is seen since this element was last\n * connected. `_sync()` runs on every mutation, so listener setup must be\n * idempotent — but those listeners (added via `listen()`) are all removed\n * on disconnect, so the \"already wired\" memory must reset with them, or a\n * reparented element (disconnect + connect) would silently stop firing.\n */\n protected wireOnce(node: Node, wire: () => void): void {\n if (this._wiredNodes.has(node)) return;\n this._wiredNodes.add(node);\n wire();\n }\n\n /** What to watch for changes worth re-syncing on. Override for a narrower/wider scope. */\n protected observerInit(): MutationObserverInit {\n return { childList: true, subtree: true, attributes: true };\n }\n\n /** Re-derive this element's own attributes/classes from its current children. */\n protected abstract _sync(): void;\n\n /** Unused — content is the author's own children, never replaced. */\n protected override render(): string {\n return '';\n }\n}\n","/**\n * Guarded DOM writes for use inside `A11yWrapperElement._sync()` methods (or\n * anywhere else re-syncing against a live MutationObserver).\n *\n * `setAttribute`/`removeAttribute`/`classList.add`/`classList.remove`/\n * `textContent =` all queue a mutation record unconditionally — even when\n * the value being written is identical to what's already there. Call one of\n * these unguarded inside a MutationObserver callback that's itself watching\n * the element being written to, and every \"no-op\" write retriggers the\n * observer, forever. These helpers check first, so a `_sync()` call that\n * changes nothing produces zero mutations and the observer loop terminates.\n */\n\nexport function syncText(el: Element, text: string): void {\n if (el.textContent !== text) el.textContent = text;\n}\n\nexport function syncAttr(el: Element, name: string, value: string | null | undefined): void {\n if (value == null) {\n if (el.hasAttribute(name)) el.removeAttribute(name);\n } else if (el.getAttribute(name) !== value) {\n el.setAttribute(name, value);\n }\n}\n\nexport function syncClass(el: Element, name: string, present: boolean): void {\n if (el.classList.contains(name) !== present) el.classList.toggle(name, present);\n}\n\n/**\n * Adds or removes one id in an id-reference list attribute (`aria-describedby`,\n * `aria-labelledby`, …), keeping every other token — typically ids the\n * consumer set — in place. Removes the attribute once the list is empty.\n */\nexport function syncIdRef(el: Element, name: string, id: string, present: boolean): void {\n const ids = (el.getAttribute(name) ?? '').split(/\\s+/).filter(Boolean);\n const has = ids.includes(id);\n if (has === present) return;\n const next = present ? [...ids, id] : ids.filter((token) => token !== id);\n syncAttr(el, name, next.length ? next.join(' ') : null);\n}\n","import { A11yWrapperElement } from '../../core/a11y-wrapper-element.js';\nimport { syncAttr, syncClass, syncText } from '../../core/dom-sync.js';\nimport { getString } from '../../core/strings.js';\n\nconst SELECT_ALL_INPUT_CLASS = 'a11y-checkbox-group__select-all-input';\n\n/**\n * Enhances a set of real, consumer-authored `<input type=\"checkbox\">`\n * options (each typically inside its own `<label>`) with a wrapping\n * `<fieldset>`/`<legend>` — the multi-select counterpart of\n * `<a11y-radio-group>`. Options reuse `<a11y-checkbox>`'s styling\n * (`.a11y-checkbox` on the label, `.a11y-checkbox__input` on the input).\n *\n * `select-all` adds a generated \"Select all\" checkbox after the legend: it's\n * checked when every enabled option is, `indeterminate` when only some are,\n * and toggles every enabled option at once. It has no `name`, so it's never\n * submitted with the form. Disabled options keep their own state.\n *\n * ```html\n * <a11y-checkbox-group legend=\"Toppings\" select-all>\n * <label><input type=\"checkbox\" name=\"toppings\" value=\"cheese\"> Cheese</label>\n * <label><input type=\"checkbox\" name=\"toppings\" value=\"ham\"> Ham</label>\n * </a11y-checkbox-group>\n * ```\n *\n * The select-all label: `select-all-label=\"…\"`, else `setStrings({ selectAll })`.\n */\nexport class CheckboxGroupElement extends A11yWrapperElement {\n static get observedAttributes(): string[] {\n return ['legend', 'aria-label', 'disabled', 'select-all', 'select-all-label'];\n }\n\n /** Called with the checked values once per user action — including one select-all click that changes many options. */\n declare onChange?: (values: string[]) => void;\n\n /** True while select-all toggles options, so their `change` events don't each call `onChange`. */\n private _bulkUpdating = false;\n\n getValue(): string[] {\n return this._options()\n .filter((input) => input.checked)\n .map((input) => input.value);\n }\n\n /** Checks exactly the options whose value is in `values` and unchecks the rest. */\n setValue(values: string[]): void {\n for (const input of this._options()) input.checked = values.includes(input.value);\n this._syncSelectAll();\n }\n\n /** Checks every enabled option. Silent, like `setValue()`: no events, no `onChange`. */\n selectAll(): void {\n this._setAllEnabled(true);\n }\n\n /** Unchecks every enabled option. Silent, like `setValue()`: no events, no `onChange`. */\n unselectAll(): void {\n this._setAllEnabled(false);\n }\n\n private _fieldset(): HTMLFieldSetElement | null {\n return this.querySelector('fieldset.a11y-checkbox-group');\n }\n\n private _selectAllInput(): HTMLInputElement | null {\n return this._fieldset()?.querySelector<HTMLInputElement>(`.${SELECT_ALL_INPUT_CLASS}`) ?? null;\n }\n\n private _options(): HTMLInputElement[] {\n const fieldset = this._fieldset();\n if (!fieldset) return [];\n return [...fieldset.querySelectorAll<HTMLInputElement>(`input[type=\"checkbox\"]:not(.${SELECT_ALL_INPUT_CLASS})`)];\n }\n\n private _enabledOptions(): HTMLInputElement[] {\n return this._options().filter((input) => !input.matches(':disabled'));\n }\n\n protected override onStringsChange(): void {\n this._sync();\n }\n\n protected override _sync(): void {\n if (!this.querySelector('input[type=\"checkbox\"]')) return;\n\n const fieldset = this._ensureFieldset();\n for (const input of this._options()) {\n syncClass(input, 'a11y-checkbox__input', true);\n const label = input.closest('label');\n if (label && fieldset.contains(label)) syncClass(label, 'a11y-checkbox', true);\n }\n\n syncAttr(fieldset, 'disabled', this.boolAttr('disabled') ? '' : null);\n this._syncLegend(fieldset);\n this._syncSelectAllControl(fieldset);\n this._syncSelectAll();\n\n this.wireOnce(fieldset, () =>\n this.listen(fieldset, 'change', (e) => {\n const target = e.target as HTMLInputElement;\n if (!target.matches('input[type=\"checkbox\"]')) return;\n if (target.classList.contains(SELECT_ALL_INPUT_CLASS)) {\n this._toggleAllFromUser(target.checked);\n return;\n }\n this._syncSelectAll();\n if (!this._bulkUpdating) this.onChange?.(this.getValue());\n }),\n );\n }\n\n private _ensureFieldset(): HTMLFieldSetElement {\n const existing = this._fieldset();\n if (existing) return existing;\n\n const fieldset = document.createElement('fieldset');\n fieldset.className = 'a11y-checkbox-group';\n // Move every existing child (the consumer's option markup) into it.\n while (this.firstChild) fieldset.appendChild(this.firstChild);\n this.appendChild(fieldset);\n return fieldset;\n }\n\n private _syncLegend(fieldset: HTMLFieldSetElement): void {\n const legendText = this.optionalStringAttr('legend');\n const ariaLabel = this.optionalStringAttr('aria-label');\n let legend = fieldset.querySelector<HTMLLegendElement>('.a11y-checkbox-group__legend');\n\n if (legendText) {\n if (!legend) {\n legend = document.createElement('legend');\n legend.className = 'a11y-checkbox-group__legend';\n fieldset.prepend(legend);\n }\n syncText(legend, legendText);\n syncAttr(fieldset, 'aria-label', null); // <legend> already provides an accessible name natively\n } else {\n legend?.remove();\n syncAttr(fieldset, 'aria-label', ariaLabel);\n }\n }\n\n /** Builds/removes the select-all `<label>` and keeps it right after the legend (or first). */\n private _syncSelectAllControl(fieldset: HTMLFieldSetElement): void {\n let wrapper = fieldset.querySelector<HTMLLabelElement>('.a11y-checkbox-group__select-all');\n if (!this.boolAttr('select-all')) {\n wrapper?.remove();\n return;\n }\n\n if (!wrapper) {\n wrapper = document.createElement('label');\n wrapper.className = 'a11y-checkbox a11y-checkbox-group__select-all';\n const input = document.createElement('input');\n input.type = 'checkbox';\n input.className = `a11y-checkbox__input ${SELECT_ALL_INPUT_CLASS}`;\n const span = document.createElement('span');\n span.className = 'a11y-checkbox__label';\n wrapper.append(input, span);\n }\n\n const legend = fieldset.querySelector('.a11y-checkbox-group__legend');\n const expectedPrevious = legend ?? null;\n if (wrapper.parentElement !== fieldset || wrapper.previousElementSibling !== expectedPrevious) {\n if (legend) legend.after(wrapper);\n else fieldset.prepend(wrapper);\n }\n\n syncText(wrapper.querySelector('.a11y-checkbox__label')!, this.stringAttr('select-all-label', getString('selectAll')));\n }\n\n /** Mirrors the enabled options onto the select-all input: checked / indeterminate / unchecked. */\n private _syncSelectAll(): void {\n const selectAll = this._selectAllInput();\n if (!selectAll) return;\n const enabled = this._enabledOptions();\n const checkedCount = enabled.filter((input) => input.checked).length;\n // IDL-only properties (never reflected) — safe to write unguarded.\n selectAll.checked = enabled.length > 0 && checkedCount === enabled.length;\n selectAll.indeterminate = checkedCount > 0 && checkedCount < enabled.length;\n selectAll.disabled = enabled.length === 0;\n }\n\n private _setAllEnabled(checked: boolean): HTMLInputElement[] {\n const changed = this._enabledOptions().filter((input) => input.checked !== checked);\n for (const input of changed) input.checked = checked;\n this._syncSelectAll();\n return changed;\n }\n\n /** A select-all click: toggles every enabled option, fires their native events, then `onChange` once. */\n private _toggleAllFromUser(checked: boolean): void {\n const changed = this._setAllEnabled(checked);\n this._bulkUpdating = true;\n try {\n for (const input of changed) {\n input.dispatchEvent(new Event('input', { bubbles: true, composed: true }));\n input.dispatchEvent(new Event('change', { bubbles: true }));\n }\n } finally {\n this._bulkUpdating = false;\n }\n if (changed.length > 0) this.onChange?.(this.getValue());\n }\n}\n","import { CheckboxGroupElement } from './checkbox-group.element.js';\n\nif (!customElements.get('a11y-checkbox-group')) {\n customElements.define('a11y-checkbox-group', CheckboxGroupElement);\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'a11y-checkbox-group': CheckboxGroupElement;\n }\n}\n\nexport { CheckboxGroupElement };\n// Re-exported so zero-build `<script type=\"module\">` users can reach them too.\nexport { resetStrings, setStrings } from '../../core/strings.js';\n"],"mappings":";AAsDO,IAAM,kBAAyC,OAAO,OAAO;AAAA,EAClE,eAAe;AAAA,EACf,aAAa;AAAA,EACb,aAAa;AAAA,EACb,SA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