@andes-ng/primitives 0.0.0-stage → 0.1.0-rc.2

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"andes-ng-primitives.mjs","sources":["../../../../packages/primitives/src/lib/button-primitive.ts","../../../../packages/primitives/src/lib/listbox/list-navigation.ts","../../../../packages/primitives/src/lib/choice-group/choice-group-types.ts","../../../../packages/primitives/src/lib/choice-group/choice-group.ts","../../../../packages/primitives/src/lib/choice-group/choice-group-item.ts","../../../../packages/primitives/src/lib/tree-navigation/tree-navigation-structure.ts","../../../../packages/primitives/src/lib/tree-navigation/tree-navigation.ts","../../../../packages/primitives/src/lib/tree-navigation/tree-navigation-item.ts","../../../../packages/primitives/src/lib/tree-navigation/tree-navigation-keys.ts","../../../../packages/primitives/src/lib/viewport/breakpoints.ts","../../../../packages/primitives/src/lib/viewport/resize-observer.ts","../../../../packages/primitives/src/lib/viewport/element-size.ts","../../../../packages/primitives/src/lib/viewport/container-breakpoint.ts","../../../../packages/primitives/src/lib/viewport/media-query.ts","../../../../packages/primitives/src/lib/form-control/control-status.ts","../../../../packages/primitives/src/lib/form-control/value-accessor.ts","../../../../packages/primitives/src/lib/form-control/form-control-base.ts","../../../../packages/primitives/src/lib/form-control/provide-value-accessor.ts","../../../../packages/primitives/src/lib/selection-model/checked-tree.ts","../../../../packages/primitives/src/lib/selection-model/selection-model.ts","../../../../packages/primitives/src/lib/overlay/overlay-config.ts","../../../../packages/primitives/src/lib/overlay/overlay-positioning.ts","../../../../packages/primitives/src/lib/overlay/overlay-inert.ts","../../../../packages/primitives/src/lib/overlay/overlay-primitive.ts","../../../../packages/primitives/src/lib/overlay/overlay-trigger-primitive.ts","../../../../packages/primitives/src/lib/overlay/overlay-content-primitive.ts","../../../../packages/primitives/src/lib/overlay/overlay-close-primitive.ts","../../../../packages/primitives/src/lib/listbox/list-navigation-item.ts","../../../../packages/primitives/src/lib/listbox/list-navigation-keys.ts","../../../../packages/primitives/src/andes-ng-primitives.ts"],"sourcesContent":["import {\n booleanAttribute,\n Directive,\n ElementRef,\n HOST_TAG_NAME,\n inject,\n input,\n} from '@angular/core';\nimport { takeUntilDestroyed } from '@angular/core/rxjs-interop';\nimport { fromEvent } from 'rxjs';\nimport { filter } from 'rxjs/operators';\n\n@Directive({\n selector: 'button[andesButtonPrimitive], a[andesButtonPrimitive]',\n host: {\n '[attr.tabindex]': 'disabled() ? -1 : undefined',\n '[attr.disabled]': '!isAnchor && disabled() ? \"\" : undefined',\n // Anchors have no native disabled state, so screen readers need\n // aria-disabled to announce it.\n '[attr.aria-disabled]': 'isAnchor && disabled() ? \"true\" : undefined',\n '[attr.data-disabled]': 'disabled() ? \"\" : undefined',\n },\n})\nexport class AndesButtonPrimitive {\n readonly disabled = input(false, { transform: booleanAttribute });\n\n protected readonly isAnchor = inject(HOST_TAG_NAME) === 'a';\n\n constructor() {\n if (this.isAnchor) {\n const elementRef = inject(ElementRef<HTMLAnchorElement>);\n fromEvent<MouseEvent>(elementRef.nativeElement, 'click')\n .pipe(\n filter(() => this.disabled()),\n takeUntilDestroyed(),\n )\n .subscribe((event) => {\n event.preventDefault();\n event.stopImmediatePropagation();\n });\n }\n }\n}\n","import {\n ActiveDescendantKeyManager,\n FocusKeyManager,\n ListKeyManager,\n} from '@angular/cdk/a11y';\nimport {\n computed,\n DestroyRef,\n inject,\n Injectable,\n Injector,\n signal,\n Signal,\n} from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\nimport {\n AndesListFocusMode,\n AndesListNavigationConfig,\n AndesListNavigationItemRef,\n AndesListOrientation,\n AndesListTextDirection,\n} from './list-navigation-types';\n\n/** The CDK's own typeahead debounce default, restated so consumers can reference it. */\nexport const ANDES_LIST_TYPEAHEAD_DEBOUNCE = 200;\n\n/** `Node.DOCUMENT_POSITION_*` values, inlined so this file never touches the `Node` global. */\nconst DOCUMENT_POSITION_DISCONNECTED = 1;\nconst DOCUMENT_POSITION_PRECEDING = 2;\nconst DOCUMENT_POSITION_FOLLOWING = 4;\n\ntype ItemKeyManager = ListKeyManager<AndesListNavigationItemRef>;\n\n/** Sorts registered items into DOM order, leaving detached items in registration order. */\nfunction sortByDocumentOrder(\n items: readonly AndesListNavigationItemRef[],\n): AndesListNavigationItemRef[] {\n return [...items].sort((a, b) => {\n const position = a.element.compareDocumentPosition(b.element);\n if (position & DOCUMENT_POSITION_DISCONNECTED) {\n return 0;\n }\n if (position & DOCUMENT_POSITION_FOLLOWING) {\n return -1;\n }\n if (position & DOCUMENT_POSITION_PRECEDING) {\n return 1;\n }\n return 0;\n });\n}\n\n/** Whether a key event is a plain printable character, i.e. typeahead input. */\nfunction isPrintableCharacter(event: KeyboardEvent): boolean {\n return (\n event.key?.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey\n );\n}\n\n/**\n * Shared list-navigation state for a listbox, menu, tablist or combobox popup: roving\n * tabindex or `aria-activedescendant` focus management, arrow-key navigation in either\n * orientation, `Home`/`End`, typeahead and disabled-item skipping.\n *\n * This is a thin, signal-shaped wrapper around Angular CDK's own `ListKeyManager` family\n * (`FocusKeyManager` for `roving-tabindex`, `ActiveDescendantKeyManager` for\n * `active-descendant`) — the key handling, typeahead buffering and wrap-around arithmetic\n * are the CDK's, not a reimplementation.\n *\n * It is a DI-scoped service, not a directive: provide it from the consuming component so\n * that every descendant item — including items rendered into a CDK overlay, which are\n * injector descendants but not DOM descendants — can inject the same instance.\n *\n * ```ts\n * @Component({\n * selector: 'andes-tabs',\n * providers: [AndesListNavigation],\n * template: `\n * <div role=\"tablist\" andesListNavigationKeys>\n * @for (tab of tabs(); track tab.value) {\n * <button role=\"tab\" type=\"button\" andesListNavigationItem [disabled]=\"tab.disabled\">\n * {{ tab.label }}\n * </button>\n * }\n * </div>\n * `,\n * })\n * export class AndesTabs {\n * protected readonly navigation = inject(AndesListNavigation);\n *\n * constructor() {\n * this.navigation.configure({ orientation: 'horizontal', wrap: true });\n * }\n * }\n * ```\n *\n * What this primitive deliberately does *not* do: it owns no selection state, sets no\n * `role`/`aria-selected`/`aria-checked`, and never interprets `Enter`, `Space` or `Escape`.\n * \"Active item\" is focus, not selection — a component that activates on focus (Tabs in\n * automatic-activation mode) reacts to {@link activeItem} in an `effect`, while one that\n * activates manually handles `Enter`/`Space` itself.\n */\n@Injectable()\nexport class AndesListNavigation {\n private readonly injector = inject(Injector);\n private readonly destroyRef = inject(DestroyRef);\n\n /** Which arrow keys navigate. */\n readonly orientation = signal<AndesListOrientation>('vertical');\n /** Whether navigation wraps around the ends of the list. */\n readonly wrap = signal(true);\n /** Whether typing characters moves the active item. */\n readonly typeahead = signal(true);\n /** How long to wait after the last keystroke before matching. */\n readonly typeaheadDebounce = signal(ANDES_LIST_TYPEAHEAD_DEBOUNCE);\n /** Whether `Home`/`End` jump to the first/last enabled item. */\n readonly homeAndEnd = signal(true);\n /** How the active item is surfaced to assistive technology. */\n readonly focusMode = signal<AndesListFocusMode>('roving-tabindex');\n /** Text direction used to mirror horizontal arrow keys. */\n readonly textDirection = signal<AndesListTextDirection>('ltr');\n /** Whether disabled items are skipped while navigating. */\n readonly skipDisabled = signal(true);\n\n private readonly _items = signal<readonly AndesListNavigationItemRef[]>([]);\n /** Every registered item, in DOM order. */\n readonly items: Signal<readonly AndesListNavigationItemRef[]> =\n this._items.asReadonly();\n\n private readonly _activeItem = signal<AndesListNavigationItemRef | null>(\n null,\n );\n /** The active item, or `null` when nothing is active yet. */\n readonly activeItem: Signal<AndesListNavigationItemRef | null> =\n this._activeItem.asReadonly();\n\n private readonly _activeIndex = signal(-1);\n /** Index of the active item within {@link items}, or `-1` when nothing is active. */\n readonly activeIndex: Signal<number> = this._activeIndex.asReadonly();\n\n /**\n * The `id` to publish as `aria-activedescendant`, or `null` in `roving-tabindex` mode\n * (where real focus already conveys the active item).\n */\n readonly activeDescendantId: Signal<string | null> = computed(() =>\n this.focusMode() === 'active-descendant'\n ? (this._activeItem()?.itemId ?? null)\n : null,\n );\n\n /**\n * The single item that should carry `tabindex=\"0\"` in `roving-tabindex` mode: the active\n * item, or — before anything is active — the first item the user can navigate to, so the\n * list is always reachable with one Tab press.\n */\n readonly rovingTabindexTarget: Signal<AndesListNavigationItemRef | null> =\n computed(() => {\n const active = this._activeItem();\n if (active && !this.shouldSkip(active)) {\n return active;\n }\n return this._items().find((item) => !this.shouldSkip(item)) ?? null;\n });\n\n private readonly _tabOut = new Subject<void>();\n /** Emits when `Tab` is pressed, so a menu or popup can close and hand focus back. */\n readonly tabOut: Observable<void> = this._tabOut.asObservable();\n\n private keyManager: ItemKeyManager | null = null;\n private keyManagerMode: AndesListFocusMode | null = null;\n private appliedTypeaheadDebounce: number | null = null;\n private destroyed = false;\n\n constructor() {\n this.destroyRef.onDestroy(() => {\n this.destroyed = true;\n this.keyManager?.destroy();\n this.keyManager = null;\n this._tabOut.complete();\n });\n }\n\n /** Applies any subset of the configuration options in one call. */\n configure(config: AndesListNavigationConfig): void {\n if (config.orientation !== undefined) {\n this.orientation.set(config.orientation);\n }\n if (config.wrap !== undefined) {\n this.wrap.set(config.wrap);\n }\n if (config.typeahead !== undefined) {\n this.typeahead.set(config.typeahead);\n }\n if (config.typeaheadDebounce !== undefined) {\n this.typeaheadDebounce.set(config.typeaheadDebounce);\n }\n if (config.homeAndEnd !== undefined) {\n this.homeAndEnd.set(config.homeAndEnd);\n }\n if (config.focusMode !== undefined) {\n this.focusMode.set(config.focusMode);\n }\n if (config.textDirection !== undefined) {\n this.textDirection.set(config.textDirection);\n }\n if (config.skipDisabled !== undefined) {\n this.skipDisabled.set(config.skipDisabled);\n }\n }\n\n /** Adds an item to the list. Called by {@link AndesListNavigationItem} on init. */\n register(item: AndesListNavigationItemRef): void {\n this._items.update((items) => sortByDocumentOrder([...items, item]));\n }\n\n /**\n * Removes an item from the list. Called by {@link AndesListNavigationItem} on destroy.\n * Removing the active item clears the active state rather than guessing a neighbour.\n */\n unregister(item: AndesListNavigationItemRef): void {\n this._items.update((items) => items.filter((entry) => entry !== item));\n // Items also unregister while the whole list is being torn down, where touching the\n // key manager would mean building one against an injector that is already gone.\n if (!this.destroyed && this._activeItem() === item) {\n this.clearActive();\n }\n }\n\n /**\n * Handles a `keydown` on whichever element owns keyboard focus for this list — the\n * tablist/menu in `roving-tabindex` mode, the text input in `active-descendant` mode.\n * {@link AndesListNavigationKeys} wires this up for you.\n *\n * Only navigation keys are consumed (and `preventDefault`ed); `Enter`, `Space` and\n * `Escape` are left entirely to the consumer.\n *\n * Note: this delegates to the CDK, which reads the (deprecated but universally\n * populated) `KeyboardEvent.keyCode`. Real browsers always set it; synthetic events in\n * unit tests must set it explicitly.\n */\n onKeydown(event: KeyboardEvent): void {\n const manager = this.resolveKeyManager();\n\n if (isPrintableCharacter(event)) {\n // Typing is off, so a character key is never ours to handle.\n if (!this.typeahead()) {\n return;\n }\n // Space activates an item; it may extend a typeahead query but must never start one.\n if (event.key === ' ' && !manager.isTyping()) {\n return;\n }\n }\n\n manager.onKeydown(event);\n this.syncActive(manager);\n }\n\n /** Moves the active item to the first enabled item. */\n focusFirst(): void {\n const manager = this.resolveKeyManager();\n manager.setFirstItemActive();\n this.syncActive(manager);\n }\n\n /** Moves the active item to the last enabled item. */\n focusLast(): void {\n const manager = this.resolveKeyManager();\n manager.setLastItemActive();\n this.syncActive(manager);\n }\n\n /** Moves the active item forwards, respecting {@link wrap} and {@link skipDisabled}. */\n focusNext(): void {\n const manager = this.resolveKeyManager();\n manager.setNextItemActive();\n this.syncActive(manager);\n }\n\n /** Moves the active item backwards, respecting {@link wrap} and {@link skipDisabled}. */\n focusPrevious(): void {\n const manager = this.resolveKeyManager();\n manager.setPreviousItemActive();\n this.syncActive(manager);\n }\n\n /** Makes a specific item active, applying the current focus mode's effects. */\n focusItem(item: AndesListNavigationItemRef | number): void {\n const manager = this.resolveKeyManager();\n manager.setActiveItem(item);\n this.syncActive(manager);\n }\n\n /**\n * Moves the active pointer without focusing the item — for restoring an active item\n * after the list is re-filtered, or for following a click/`focusin` that already moved\n * real focus. Being silent, it also skips scrolling the item into view; use\n * {@link focusItem} when the item should be revealed.\n */\n setActiveItemSilently(\n item: AndesListNavigationItemRef | number | null,\n ): void {\n const manager = this.resolveKeyManager();\n // `updateActiveItem` has no union overload, so the two cases have to be split.\n if (item === null || typeof item === 'number') {\n manager.updateActiveItem(item ?? -1);\n } else {\n manager.updateActiveItem(item);\n }\n this.syncActive(manager);\n }\n\n /** Clears the active item, e.g. when a popup closes. */\n clearActive(): void {\n this.setActiveItemSilently(null);\n }\n\n /** Whether a typeahead query is currently buffered. */\n isTyping(): boolean {\n return this.keyManager?.isTyping() ?? false;\n }\n\n /** Discards any buffered typeahead query. */\n cancelTypeahead(): void {\n this.keyManager?.cancelTypeahead();\n }\n\n private shouldSkip(item: AndesListNavigationItemRef): boolean {\n return this.skipDisabled() && item.isDisabled();\n }\n\n /**\n * Returns the CDK key manager for the current focus mode, creating it on first use and\n * rebuilding it (carrying the active item over) if the focus mode changes.\n */\n private resolveKeyManager(): ItemKeyManager {\n const mode = this.focusMode();\n\n if (!this.keyManager || this.keyManagerMode !== mode) {\n const previousActive = this._activeItem();\n this.keyManager?.destroy();\n\n const manager: ItemKeyManager =\n mode === 'active-descendant'\n ? new ActiveDescendantKeyManager<AndesListNavigationItemRef>(\n this._items,\n this.injector,\n )\n : new FocusKeyManager<AndesListNavigationItemRef>(\n this._items,\n this.injector,\n );\n\n // The CDK's default predicate reads a plain `item.disabled` boolean, which an item\n // directive with a signal input cannot provide — see AndesListNavigationItemRef.\n manager.skipPredicate((item) => this.shouldSkip(item));\n // Typeahead resolves asynchronously (it is debounced), so mirror its result too.\n manager.change.subscribe(() => this.syncActive(manager));\n manager.tabOut.subscribe(() => this._tabOut.next());\n\n this.keyManager = manager;\n this.keyManagerMode = mode;\n this.appliedTypeaheadDebounce = null;\n\n if (previousActive) {\n manager.updateActiveItem(previousActive);\n }\n }\n\n this.applyConfig(this.keyManager);\n return this.keyManager;\n }\n\n private applyConfig(manager: ItemKeyManager): void {\n const orientation = this.orientation();\n const horizontal = orientation === 'vertical' ? null : this.textDirection();\n\n manager.withWrap(this.wrap());\n manager.withVerticalOrientation(orientation !== 'horizontal');\n manager.withHorizontalOrientation(horizontal);\n manager.withHomeAndEnd(this.homeAndEnd());\n\n // `withTypeAhead` rebuilds the CDK's typeahead (dropping any buffered query), so only\n // call it when it has not been applied yet or the debounce actually changed. Turning\n // typeahead off is handled in `onKeydown` instead, since the CDK has no \"off\" switch.\n const debounce = this.typeaheadDebounce();\n if (this.typeahead() && this.appliedTypeaheadDebounce !== debounce) {\n manager.withTypeAhead(debounce);\n this.appliedTypeaheadDebounce = debounce;\n }\n }\n\n private syncActive(manager: ItemKeyManager): void {\n this._activeItem.set(manager.activeItem);\n this._activeIndex.set(manager.activeItemIndex ?? -1);\n }\n}\n","import type { Signal } from '@angular/core';\n\nimport type { AndesListNavigationItemRef } from '../listbox/list-navigation-types';\n\n/**\n * How many items can be selected at once.\n *\n * - `single` — at most one item; `value` is that item's value, or `null` when none is.\n * - `multiple` — any number of items; `value` is an array (`null` is read as empty).\n */\nexport type AndesChoiceMode = 'single' | 'multiple';\n\n/**\n * The value held by a choice group: one item's value (or `null`) in `single` mode, an array\n * of values in `multiple` mode. The two shapes share one type so `[(value)]` stays a single\n * binding whatever the mode.\n */\nexport type AndesChoiceValue<T> = T | readonly T[] | null;\n\n/**\n * The `role` of the group element. It selects a whole {@link AndesChoiceRoleMapping}, so one\n * primitive can serve every \"pick from a set\" pattern:\n *\n * - `radiogroup` — radio buttons and segmented controls.\n * - `tablist` — tabs.\n * - `toolbar` / `group` — toggle-button groups (`group` when it is not a toolbar).\n * - `listbox` — a listbox whose options are the choices.\n */\nexport type AndesChoiceGroupRole =\n 'radiogroup' | 'tablist' | 'toolbar' | 'group' | 'listbox';\n\n/** The `role` of each item; implied by the group's {@link AndesChoiceGroupRole}. */\nexport type AndesChoiceItemRole = 'radio' | 'tab' | 'button' | 'option';\n\n/** The ARIA attribute that carries an item's selected state under a given role. */\nexport type AndesChoiceStateAttribute =\n 'aria-checked' | 'aria-selected' | 'aria-pressed';\n\n/** The value of an item's `data-state` styling hook; which pair applies depends on its role. */\nexport type AndesChoiceDataState =\n | 'checked'\n | 'unchecked'\n | 'active'\n | 'inactive'\n | 'on'\n | 'off'\n | 'selected'\n | 'unselected';\n\n/**\n * Everything that differs between the patterns a choice group can render. Each\n * {@link AndesChoiceGroupRole} has a default mapping in {@link ANDES_CHOICE_ROLE_MAPPINGS};\n * the group's `roleMapping` input overrides single fields of it.\n */\nexport interface AndesChoiceRoleMapping {\n /** `role` set on every item. */\n readonly itemRole: AndesChoiceItemRole;\n /** The ARIA attribute that reports whether an item is selected. */\n readonly stateAttribute: AndesChoiceStateAttribute;\n /**\n * Whether activating the selected item in `single` mode clears it. Radios and tabs never\n * deselect; a toggle button does. (`multiple` mode always toggles.)\n */\n readonly toggles: boolean;\n /**\n * Whether keyboard navigation also selects the item it lands on, rather than waiting for\n * `Space`/`Enter`. Only meaningful in `single` mode.\n */\n readonly selectionFollowsFocus: boolean;\n /** Whether the role supports `aria-required`, which `required` is then published as. */\n readonly ariaRequired: boolean;\n /** Which arrow keys navigate when `orientation` is not set explicitly. */\n readonly orientation: 'horizontal' | 'vertical' | 'both';\n}\n\n/**\n * Default {@link AndesChoiceRoleMapping} for every {@link AndesChoiceGroupRole}, following\n * the WAI-ARIA Authoring Practices pattern of the same name.\n */\nexport const ANDES_CHOICE_ROLE_MAPPINGS: Readonly<\n Record<AndesChoiceGroupRole, AndesChoiceRoleMapping>\n> = {\n radiogroup: {\n itemRole: 'radio',\n stateAttribute: 'aria-checked',\n toggles: false,\n selectionFollowsFocus: true,\n ariaRequired: true,\n orientation: 'both',\n },\n tablist: {\n itemRole: 'tab',\n stateAttribute: 'aria-selected',\n toggles: false,\n selectionFollowsFocus: true,\n ariaRequired: false,\n orientation: 'horizontal',\n },\n toolbar: {\n itemRole: 'button',\n stateAttribute: 'aria-pressed',\n toggles: true,\n selectionFollowsFocus: false,\n ariaRequired: false,\n orientation: 'horizontal',\n },\n group: {\n itemRole: 'button',\n stateAttribute: 'aria-pressed',\n toggles: true,\n selectionFollowsFocus: false,\n ariaRequired: false,\n orientation: 'horizontal',\n },\n listbox: {\n itemRole: 'option',\n stateAttribute: 'aria-selected',\n toggles: false,\n selectionFollowsFocus: false,\n ariaRequired: true,\n orientation: 'vertical',\n },\n};\n\n/**\n * What the group needs to know about one of its items. {@link AndesChoiceItem} implements\n * it; the group only ever sees items through this contract, which is what lets the two\n * classes live in separate files without importing each other.\n */\nexport interface AndesChoiceItemRef extends AndesListNavigationItemRef {\n /** The value this item stands for, compared against the group's value. */\n readonly value: Signal<unknown>;\n}\n","import { Directionality } from '@angular/cdk/bidi';\nimport {\n booleanAttribute,\n computed,\n Directive,\n effect,\n ElementRef,\n inject,\n input,\n model,\n output,\n Signal,\n signal,\n untracked,\n} from '@angular/core';\n\nimport { AndesListNavigation } from '../listbox/list-navigation';\nimport type {\n AndesListOrientation,\n AndesListTextDirection,\n} from '../listbox/list-navigation-types';\nimport {\n ANDES_CHOICE_ROLE_MAPPINGS,\n AndesChoiceGroupRole,\n AndesChoiceItemRef,\n AndesChoiceMode,\n AndesChoiceRoleMapping,\n AndesChoiceValue,\n} from './choice-group-types';\n\n/** Whether a registered navigation item is one of this group's choice items. */\nfunction isChoiceItem(item: object): item is AndesChoiceItemRef {\n return 'value' in item && typeof item.value === 'function';\n}\n\n/** Space or Enter without a modifier: the keys that activate the focused item. */\nfunction isActivationKey(event: KeyboardEvent): boolean {\n return (\n (event.key === ' ' || event.key === 'Enter') &&\n !event.altKey &&\n !event.ctrlKey &&\n !event.metaKey &&\n !event.shiftKey\n );\n}\n\n/**\n * The shared behavior of every \"choose from a set\" control: one tab stop, arrow keys move\n * between items, and `Space`/`Enter` (or focus itself) select. It owns the selection and\n * the roving focus, and publishes the ARIA that goes with them; the consuming component\n * owns the markup and the styling.\n *\n * The same directive serves radio groups, segmented controls, tabs, toggle-button groups\n * and listbox-style pickers. What changes between them is only data — the group's\n * {@link role} picks a default {@link AndesChoiceRoleMapping} (item role, which `aria-*`\n * attribute carries the selected state, whether focus selects, which arrows navigate).\n *\n * Roving focus is {@link AndesListNavigation}'s: the group provides its own instance, so\n * items — including ones rendered by a descendant component — find it through DI, and\n * arrow-key movement, `Home`/`End`, wrap-around and disabled-item skipping are the shared\n * implementation rather than a per-component copy.\n *\n * ```html\n * <div andesChoiceGroup role=\"radiogroup\" [(value)]=\"size\" aria-label=\"Size\">\n * @for (option of options; track option.value) {\n * <button type=\"button\" andesChoiceItem [value]=\"option.value\" [disabled]=\"option.disabled\">\n * {{ option.label }}\n * </button>\n * }\n * </div>\n * ```\n *\n * `value` follows the user and the program alike: setting it (or binding `[value]`)\n * updates every item, but only the user's own selection fires {@link changed} — the\n * convention form-control wrappers need to tell the two apart.\n */\n@Directive({\n selector: '[andesChoiceGroup]',\n exportAs: 'andesChoiceGroup',\n providers: [AndesListNavigation],\n host: {\n '[attr.role]': 'role()',\n '[attr.aria-orientation]': 'ariaOrientation()',\n '[attr.aria-multiselectable]': 'ariaMultiselectable()',\n '[attr.aria-required]': 'ariaRequired()',\n '[attr.aria-disabled]': 'isDisabled() ? \"true\" : null',\n '[attr.data-disabled]': 'isDisabled() ? \"\" : null',\n '[attr.data-orientation]': 'resolvedOrientation()',\n '(keydown)': 'onKeydown($event)',\n '(keyup)': 'onKeyup($event)',\n '(focusout)': 'onFocusout($event)',\n },\n})\nexport class AndesChoiceGroup<T = unknown> {\n private readonly navigation = inject(AndesListNavigation);\n private readonly directionality = inject(Directionality);\n private readonly host =\n inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\n /**\n * The selected value: one item's value (or `null`) in `single` mode, an array in\n * `multiple` mode. Two-way bindable.\n */\n readonly value = model<AndesChoiceValue<T>>(null);\n\n /** Whether one or many items can be selected. Default `'single'`. */\n readonly mode = input<AndesChoiceMode>('single');\n\n /**\n * The ARIA role of the group, which also decides the role and selected-state attribute\n * of its items (see {@link AndesChoiceRoleMapping}). Default `'radiogroup'`.\n */\n readonly role = input<AndesChoiceGroupRole>('radiogroup');\n\n /**\n * Overrides individual fields of the mapping {@link role} selects, for the rare pattern\n * that sits between two of them — e.g. a `toolbar` of items that do not deselect.\n */\n readonly roleMapping = input<Partial<AndesChoiceRoleMapping>>();\n\n /**\n * Whether `single` mode must always keep a selection: activating the selected item then\n * does nothing instead of clearing it. Also published as `aria-required` on roles that\n * support it. Has no effect on `multiple` mode.\n */\n readonly required = input(false, { transform: booleanAttribute });\n\n /**\n * Whether activating the selected item clears it in `single` mode. Defaults to what the\n * {@link role} does natively — a toggle button deselects, a radio or tab does not.\n */\n readonly deselectable = input<boolean>();\n\n /** Disables every item: none can be focused, navigated to or selected. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n /**\n * Whether keyboard navigation selects the item it lands on (radio buttons, automatic\n * tabs) or only moves focus until `Space`/`Enter` (manual tabs, toggle groups). Defaults\n * to what the {@link role} does natively. Ignored in `multiple` mode, where moving\n * through the items must not change a selection.\n */\n readonly selectionFollowsFocus = input<boolean>();\n\n /**\n * Which arrow keys navigate: `horizontal` (mirrored for right-to-left), `vertical`, or\n * `both`. Defaults to what the {@link role} does natively.\n */\n readonly orientation = input<AndesListOrientation>();\n\n /** Whether navigation wraps from the last item to the first, and back. Default `true`. */\n readonly wrap = input(true, { transform: booleanAttribute });\n\n /**\n * Whether typing a character moves focus to the matching item. Off by default: only a\n * listbox-style picker usually wants it, and it would otherwise compete with `Space`.\n */\n readonly typeahead = input(false, { transform: booleanAttribute });\n\n /**\n * Overrides the text direction otherwise read from the surrounding `dir`, so a right-to-left\n * group can be forced inside a left-to-right page (and vice versa).\n */\n readonly textDirection = input<AndesListTextDirection>();\n\n /**\n * Decides whether two values are the same choice. Defaults to `Object.is`; supply one\n * when items stand for objects that are re-created between renders.\n */\n readonly compareWith = input<(a: T, b: T) => boolean>(Object.is);\n\n /**\n * Fires with the new value when the *user* changes the selection — by clicking, by\n * `Space`/`Enter`, or by navigating when selection follows focus. It does not fire for\n * writes to {@link value}. (Named `changed` so it cannot be mistaken for the native\n * `change` event that bubbles out of form controls placed inside.)\n */\n readonly changed = output<AndesChoiceValue<T>>();\n\n private readonly forcedDisabled = signal(false);\n\n /**\n * Whether the group is disabled, by its input or through {@link setDisabledState}.\n * Items read this to disable themselves.\n */\n readonly isDisabled: Signal<boolean> = computed(\n () => this.disabled() || this.forcedDisabled(),\n );\n\n /** The role mapping in effect: the {@link role}'s default with any overrides applied. */\n readonly mapping: Signal<AndesChoiceRoleMapping> = computed(() => ({\n ...(ANDES_CHOICE_ROLE_MAPPINGS[this.role()] ??\n ANDES_CHOICE_ROLE_MAPPINGS.radiogroup),\n ...this.roleMapping(),\n }));\n\n /** The orientation in effect, after falling back to the role's default. */\n protected readonly resolvedOrientation: Signal<AndesListOrientation> =\n computed(() => this.orientation() ?? this.mapping().orientation);\n\n /** The text direction in effect: the {@link textDirection} input, else the surrounding `dir`. */\n readonly direction: Signal<AndesListTextDirection> = computed(\n () => this.textDirection() ?? this.directionality.valueSignal(),\n );\n\n /** Whether activating the selected item clears it. `multiple` mode always toggles. */\n readonly toggles: Signal<boolean> = computed(\n () =>\n this.mode() === 'multiple' ||\n (this.deselectable() ?? this.mapping().toggles),\n );\n\n /** Whether navigating selects. Only ever true in `single` mode. */\n readonly followsFocus: Signal<boolean> = computed(\n () =>\n this.mode() === 'single' &&\n (this.selectionFollowsFocus() ?? this.mapping().selectionFollowsFocus),\n );\n\n /** The selected values as an array, whatever the mode. */\n readonly values: Signal<readonly T[]> = computed(() => {\n const value = this.value();\n if (value === null || value === undefined) {\n return [];\n }\n if (this.mode() === 'multiple') {\n return Array.isArray(value) ? (value as readonly T[]) : [value as T];\n }\n return [value as T];\n });\n\n /**\n * Every choice item registered with the group, in DOM order. Items register themselves,\n * so `@if`/`@for`-rendered items need no bookkeeping.\n */\n readonly items: Signal<readonly AndesChoiceItemRef[]> = computed(() =>\n this.navigation.items().filter(isChoiceItem),\n );\n\n /** The first selected item that can be focused: the one that carries the tab stop. */\n readonly selectedItem: Signal<AndesChoiceItemRef | null> = computed(() => {\n const values = this.values();\n if (values.length === 0) {\n return null;\n }\n return (\n this.items().find(\n (item) => !item.isDisabled() && this.isSelected(item.value() as T),\n ) ?? null\n );\n });\n\n protected readonly ariaOrientation = computed(() => {\n const orientation = this.resolvedOrientation();\n return this.role() === 'group' || orientation === 'both'\n ? null\n : orientation;\n });\n\n protected readonly ariaMultiselectable = computed(() =>\n this.role() === 'listbox' && this.mode() === 'multiple' ? 'true' : null,\n );\n\n protected readonly ariaRequired = computed(() =>\n this.required() && this.mapping().ariaRequired ? 'true' : null,\n );\n\n constructor() {\n // Navigation options are inputs of this directive, so they are pushed to the shared\n // list-navigation instance whenever any of them changes.\n effect(() => this.syncNavigation());\n\n // The tab stop belongs to the selected item, so that Tab re-enters the group where the\n // user left a choice rather than on whichever item was last focused. Only the identity of\n // the selected item is tracked: items registering or arrow-key focus moving do not\n // re-run this, which would drag the tab stop back mid-navigation.\n effect(() => {\n const selected = this.selectedItem();\n if (selected) {\n untracked(() => this.moveTabStopTo(selected));\n }\n });\n }\n\n /** Whether `value` is part of the current selection. */\n isSelected(value: T): boolean {\n const compare = this.compareWith();\n return this.values().some((selected) => compare(selected, value));\n }\n\n /**\n * Selects `value` as the user would: in `multiple` mode it is added, in `single` mode it\n * replaces the selection. Disabled groups and unknown values are ignored. Fires\n * {@link changed} when the selection actually changes.\n */\n select(value: T): void {\n if (this.isDisabled() || this.isSelected(value)) {\n return;\n }\n this.commit(this.mode() === 'multiple' ? [...this.values(), value] : value);\n }\n\n /**\n * Deselects `value` as the user would. In `single` mode this is refused when the group is\n * {@link required}. Fires {@link changed} when the selection actually changes.\n */\n deselect(value: T): void {\n if (this.isDisabled() || !this.isSelected(value)) {\n return;\n }\n if (this.mode() === 'multiple') {\n const compare = this.compareWith();\n this.commit(\n this.values().filter((selected) => !compare(selected, value)),\n );\n } else if (!this.required()) {\n this.commit(null);\n }\n }\n\n /** Selects `value` if it is not selected, otherwise deselects it. */\n toggle(value: T): void {\n if (this.isSelected(value)) {\n this.deselect(value);\n } else {\n this.select(value);\n }\n }\n\n /**\n * Empties the selection as the user would. Refused in `single` mode when the group is\n * {@link required}. Fires {@link changed} when the selection actually changes.\n */\n clear(): void {\n if (this.isDisabled() || this.values().length === 0) {\n return;\n }\n if (this.mode() === 'multiple') {\n this.commit([]);\n } else if (!this.required()) {\n this.commit(null);\n }\n }\n\n /**\n * Moves focus into the group: onto the selected item, or the first one that can take\n * focus — the same item a Tab press lands on.\n */\n focus(options?: FocusOptions): void {\n this.navigation.rovingTabindexTarget()?.element.focus(options);\n }\n\n /**\n * Disables the group from outside the template, for wrappers that implement\n * `ControlValueAccessor.setDisabledState`. Combined with the `disabled` input, so\n * either one disables the group.\n */\n setDisabledState(isDisabled: boolean): void {\n this.forcedDisabled.set(isDisabled);\n }\n\n /**\n * The user activated an item (click, `Space` or `Enter`). Called by\n * {@link AndesChoiceItem}; follows the toggle rules of the current mapping.\n * @internal\n */\n activate(item: AndesChoiceItemRef): void {\n if (this.isDisabled() || item.isDisabled()) {\n return;\n }\n const value = item.value() as T;\n if (this.mode() === 'multiple') {\n this.toggle(value);\n } else if (this.isSelected(value)) {\n if (this.toggles()) {\n this.deselect(value);\n }\n } else {\n this.select(value);\n }\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (this.isDisabled()) {\n return;\n }\n const item = this.itemFor(event.target);\n if (!item) {\n return;\n }\n\n if (isActivationKey(event) && !this.isTypingSpace(event)) {\n // Taking over the key (rather than leaving it to a native button's click) is what\n // makes a `<div role=\"radio\">` behave like a `<button>`, and keeps one code path for\n // both: the default action is cancelled so a button cannot also fire a click.\n event.preventDefault();\n this.activate(item);\n return;\n }\n\n this.syncNavigation();\n // Navigation continues from the item that actually holds focus, which can differ from\n // the tab stop after a programmatic value change moved the stop to the selection.\n this.moveTabStopTo(item);\n const before = this.navigation.activeItem();\n this.navigation.onKeydown(event);\n const after = this.navigation.activeItem();\n\n if (\n this.followsFocus() &&\n after &&\n after !== before &&\n isChoiceItem(after)\n ) {\n // Focus moves, selection follows; only ever to select, never to deselect.\n this.select(after.value() as T);\n }\n }\n\n protected onKeyup(event: KeyboardEvent): void {\n // A button clicks on the *release* of Space in some browsers, after keydown has already\n // activated the item; cancel that second activation.\n if (event.key === ' ' && !this.isDisabled() && this.itemFor(event.target)) {\n event.preventDefault();\n }\n }\n\n protected onFocusout(event: FocusEvent): void {\n const next = event.relatedTarget as Node | null;\n if (next && this.host.contains(next)) {\n return;\n }\n // Focus left the group: put the tab stop back on the selection, so manual-activation\n // tabs and toggle groups re-enter where the choice is, not where the user last browsed.\n const selected = this.selectedItem();\n if (selected) {\n this.moveTabStopTo(selected);\n }\n }\n\n private isTypingSpace(event: KeyboardEvent): boolean {\n return event.key === ' ' && this.navigation.isTyping();\n }\n\n private itemFor(target: EventTarget | null): AndesChoiceItemRef | undefined {\n return target\n ? this.items().find((item) => item.element.contains(target as Node))\n : undefined;\n }\n\n private moveTabStopTo(item: AndesChoiceItemRef): void {\n if (this.navigation.activeItem() !== item) {\n this.navigation.setActiveItemSilently(item);\n }\n }\n\n private commit(next: AndesChoiceValue<T>): void {\n this.value.set(next);\n this.changed.emit(next);\n }\n\n private syncNavigation(): void {\n this.navigation.configure({\n orientation: this.resolvedOrientation(),\n wrap: this.wrap(),\n typeahead: this.typeahead(),\n homeAndEnd: true,\n focusMode: 'roving-tabindex',\n textDirection: this.direction(),\n skipDisabled: true,\n });\n }\n}\n","import {\n booleanAttribute,\n computed,\n Directive,\n ElementRef,\n HOST_TAG_NAME,\n inject,\n input,\n OnDestroy,\n OnInit,\n Signal,\n} from '@angular/core';\n\nimport { AndesListNavigation } from '../listbox/list-navigation';\nimport { AndesChoiceGroup } from './choice-group';\nimport {\n AndesChoiceDataState,\n AndesChoiceItemRef,\n AndesChoiceStateAttribute,\n} from './choice-group-types';\n\nlet nextId = 0;\n\n/**\n * One choice inside an {@link AndesChoiceGroup}: a radio, a tab, a toggle button or an\n * option. Registers itself with the group on init and removes itself on destroy.\n *\n * It publishes the roving `tabindex`, the item `role`, the selected-state attribute the\n * group's role mapping calls for (`aria-checked`, `aria-selected` or `aria-pressed`), and\n * `data-state`/`data-disabled`/`data-active` hooks for styling. It sets no CSS.\n *\n * ```html\n * <button type=\"button\" andesChoiceItem value=\"list\" [controls]=\"'panel-list'\">List</button>\n * ```\n *\n * Put it on the element that takes keyboard focus. A `<button>` is the usual choice — it\n * gets native `disabled` for free — but any element works, since `Space` and `Enter` are\n * handled by the group instead of relying on a native click.\n */\n@Directive({\n selector: '[andesChoiceItem]',\n exportAs: 'andesChoiceItem',\n host: {\n '[attr.id]': 'itemId',\n '[attr.role]': 'role()',\n '[attr.aria-checked]':\n 'stateAttribute() === \"aria-checked\" ? selected() : null',\n '[attr.aria-selected]':\n 'stateAttribute() === \"aria-selected\" ? selected() : null',\n '[attr.aria-pressed]':\n 'stateAttribute() === \"aria-pressed\" ? selected() : null',\n '[attr.aria-controls]': 'controls() ?? null',\n '[attr.aria-disabled]': 'isDisabled() ? \"true\" : null',\n '[attr.disabled]': 'nativeDisabled && isDisabled() ? \"\" : null',\n '[attr.tabindex]': 'tabIndex()',\n '[attr.data-state]': 'dataState()',\n '[attr.data-disabled]': 'isDisabled() ? \"\" : null',\n '[attr.data-active]': 'active() ? \"\" : null',\n '(click)': 'onClick()',\n '(focusin)': 'onFocusin()',\n },\n})\nexport class AndesChoiceItem<T = unknown>\n implements AndesChoiceItemRef, OnInit, OnDestroy\n{\n private readonly group = inject<AndesChoiceGroup<T>>(AndesChoiceGroup);\n private readonly navigation = inject(AndesListNavigation);\n\n /** The value this item stands for. Compared with the group's value (see its `compareWith`). */\n readonly value = input.required<T>();\n\n /** Disables this item: it is skipped by navigation and cannot be selected. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n /**\n * The `id` of the element this item controls — the tab panel, for a tab. Published as\n * `aria-controls`; leaving it unset omits the attribute, which is right for patterns\n * that control nothing.\n */\n readonly controls = input<string>();\n\n /**\n * Text that typeahead matches against. Defaults to the item's own text content; set it\n * when the visible text is an icon or is split across elements.\n */\n readonly typeaheadLabel = input<string>();\n\n readonly element: HTMLElement =\n inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\n /** The item's DOM `id` — its own, when it has one, so authored ids are never replaced. */\n readonly itemId: string = this.element.id || `andes-choice-item-${nextId++}`;\n\n /** Only a native button has a `disabled` attribute worth setting; other elements get ARIA only. */\n protected readonly nativeDisabled = inject(HOST_TAG_NAME) === 'button';\n\n /** Whether the item is disabled, on its own or because its group is. */\n readonly isDisabled: Signal<boolean> = computed(\n () => this.disabled() || this.group.isDisabled(),\n );\n\n /** Whether this item is part of the group's selection. */\n readonly selected: Signal<boolean> = computed(() =>\n this.group.isSelected(this.value()),\n );\n\n /** Whether this item holds the group's roving focus (the one tab stop). */\n readonly active: Signal<boolean> = computed(\n () => this.navigation.activeItem() === this,\n );\n\n protected readonly role = computed(() => this.group.mapping().itemRole);\n protected readonly stateAttribute: Signal<AndesChoiceStateAttribute> =\n computed(() => this.group.mapping().stateAttribute);\n\n /** Styling hook whose vocabulary matches the role: checked, active (tab), on, or selected. */\n protected readonly dataState: Signal<AndesChoiceDataState> = computed(() => {\n const selected = this.selected();\n switch (this.stateAttribute()) {\n case 'aria-checked':\n return selected ? 'checked' : 'unchecked';\n case 'aria-pressed':\n return selected ? 'on' : 'off';\n default:\n if (this.role() === 'tab') {\n return selected ? 'active' : 'inactive';\n }\n return selected ? 'selected' : 'unselected';\n }\n });\n\n /** `0` on the one roving tab stop, `-1` on the rest (and on everything while disabled). */\n protected readonly tabIndex = computed(() =>\n this.navigation.rovingTabindexTarget() === this ? 0 : -1,\n );\n\n ngOnInit(): void {\n this.navigation.register(this);\n }\n\n ngOnDestroy(): void {\n this.navigation.unregister(this);\n }\n\n getLabel(): string {\n return this.typeaheadLabel() ?? (this.element.textContent ?? '').trim();\n }\n\n focus(): void {\n this.element.focus();\n }\n\n setActiveStyles(): void {\n // Only called for aria-activedescendant focus, which a choice group never uses: items\n // take real focus, and the active look is derived from `active` instead.\n }\n\n setInactiveStyles(): void {\n // See setActiveStyles.\n }\n\n protected onClick(): void {\n if (this.isDisabled()) {\n return;\n }\n // Some browsers do not focus a button on click; move the tab stop (and focus) here so\n // the keyboard continues from the item the pointer chose.\n this.navigation.setActiveItemSilently(this);\n this.element.focus({ preventScroll: true });\n this.group.activate(this);\n }\n\n /** Keeps the tab stop on whichever item the user reached, however they reached it. */\n protected onFocusin(): void {\n if (this.navigation.activeItem() !== this && !this.isDisabled()) {\n this.navigation.setActiveItemSilently(this);\n }\n }\n}\n","import type {\n AndesTreeNavigationKey,\n AndesTreeNavigationNode,\n AndesTreeNavigationNodeInfo,\n} from './tree-navigation-types';\n\n/**\n * One resolved node of the hierarchy. Mutable only while {@link buildTreeStructure} is wiring\n * it up; everything afterwards treats it as read-only.\n *\n * @internal\n */\nexport class TreeNodeRecord implements AndesTreeNavigationNodeInfo {\n parent: TreeNodeRecord | null = null;\n readonly children: TreeNodeRecord[] = [];\n level = 1;\n posInSet = 1;\n setSize = 1;\n expandable: boolean;\n\n readonly key: AndesTreeNavigationKey;\n readonly disabled: boolean;\n /** Typeahead text supplied with the node, if any. */\n readonly label: string | undefined;\n\n /** The `parentKey` the node was declared with, before it is checked against the known nodes. */\n readonly declaredParentKey: AndesTreeNavigationKey | null;\n private readonly declaredExpandable: boolean | undefined;\n\n constructor(node: AndesTreeNavigationNode) {\n this.key = node.key;\n this.declaredParentKey = node.parentKey ?? null;\n this.disabled = node.disabled ?? false;\n this.label = node.label;\n this.declaredExpandable = node.expandable;\n this.expandable = node.expandable ?? false;\n }\n\n get parentKey(): AndesTreeNavigationKey | null {\n return this.parent?.key ?? null;\n }\n\n /** Settles `expandable` once the children are known. */\n resolveExpandable(): void {\n this.expandable = this.declaredExpandable ?? this.children.length > 0;\n }\n}\n\n/** The hierarchy of every known node, independent of what is expanded. @internal */\nexport interface TreeStructure {\n readonly byKey: ReadonlyMap<AndesTreeNavigationKey, TreeNodeRecord>;\n readonly roots: readonly TreeNodeRecord[];\n}\n\n/**\n * Wires a flat list of nodes into a hierarchy.\n *\n * It follows `parentKey` links rather than list position, so parents need not precede their\n * children. A node whose parent is unknown (or itself) becomes a root; the first node wins when\n * a key repeats; and a cycle, which has no root to hang from, simply stays unreachable instead\n * of looping.\n *\n * @internal\n */\nexport function buildTreeStructure(\n nodes: readonly AndesTreeNavigationNode[],\n): TreeStructure {\n const byKey = new Map<AndesTreeNavigationKey, TreeNodeRecord>();\n for (const node of nodes) {\n if (!byKey.has(node.key)) {\n byKey.set(node.key, new TreeNodeRecord(node));\n }\n }\n\n // Link in list order so siblings keep the order they were given in.\n const roots: TreeNodeRecord[] = [];\n for (const record of byKey.values()) {\n const parentKey = record.declaredParentKey;\n const parent =\n parentKey === null || parentKey === record.key\n ? undefined\n : byKey.get(parentKey);\n if (parent) {\n record.parent = parent;\n parent.children.push(record);\n } else {\n roots.push(record);\n }\n }\n\n assignHierarchyFacts(roots);\n return { byKey, roots };\n}\n\n/** Levels, sibling positions and expandability, walked breadth first so depth costs nothing. */\nfunction assignHierarchyFacts(roots: readonly TreeNodeRecord[]): void {\n setSiblingFacts(roots);\n const queue: TreeNodeRecord[] = [...roots];\n for (let index = 0; index < queue.length; index++) {\n const record = queue[index];\n record.resolveExpandable();\n setSiblingFacts(record.children);\n for (const child of record.children) {\n child.level = record.level + 1;\n queue.push(child);\n }\n }\n}\n\nfunction setSiblingFacts(siblings: readonly TreeNodeRecord[]): void {\n siblings.forEach((sibling, index) => {\n sibling.posInSet = index + 1;\n sibling.setSize = siblings.length;\n });\n}\n\n/**\n * The nodes a user can reach, in reading order: depth first, descending only into expanded\n * nodes. Iterative, so a very deep tree cannot overflow the stack.\n *\n * @internal\n */\nexport function collectVisibleNodes(\n roots: readonly TreeNodeRecord[],\n expanded: ReadonlySet<AndesTreeNavigationKey>,\n): TreeNodeRecord[] {\n const visible: TreeNodeRecord[] = [];\n const stack: TreeNodeRecord[] = [];\n for (let index = roots.length - 1; index >= 0; index--) {\n stack.push(roots[index]);\n }\n while (stack.length > 0) {\n const record = stack.pop() as TreeNodeRecord;\n visible.push(record);\n if (record.children.length > 0 && expanded.has(record.key)) {\n for (let index = record.children.length - 1; index >= 0; index--) {\n stack.push(record.children[index]);\n }\n }\n }\n return visible;\n}\n","import {\n computed,\n DestroyRef,\n DOCUMENT,\n effect,\n inject,\n Injectable,\n PLATFORM_ID,\n signal,\n Signal,\n untracked,\n WritableSignal,\n} from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\n\nimport {\n buildTreeStructure,\n collectVisibleNodes,\n TreeNodeRecord,\n} from './tree-navigation-structure';\nimport {\n AndesTreeFocusMode,\n AndesTreeNavigationConfig,\n AndesTreeNavigationExpandChange,\n AndesTreeNavigationExpandedSource,\n AndesTreeNavigationItemRef,\n AndesTreeNavigationKey,\n AndesTreeNavigationNode,\n AndesTreeNavigationNodeInfo,\n AndesTreeNavigationNodeSource,\n AndesTreeNavigationRevealRequest,\n AndesTreeNavigationScope,\n AndesTreeOrientation,\n AndesTreeTextDirection,\n} from './tree-navigation-types';\n\n/** Default time a typeahead query stays buffered, matching the WAI-ARIA examples. */\nexport const ANDES_TREE_TYPEAHEAD_DEBOUNCE = 500;\n\n/** `Node.DOCUMENT_POSITION_*` values, inlined so this file never touches the `Node` global. */\nconst DOCUMENT_POSITION_DISCONNECTED = 1;\nconst DOCUMENT_POSITION_PRECEDING = 2;\n\ntype Direction = 1 | -1;\n\ntype Command = 'next' | 'previous' | 'open' | 'close';\n\n/** Whether `later` comes after `earlier` in the document (or cannot be compared at all). */\nfunction isInOrder(\n earlier: AndesTreeNavigationItemRef,\n later: AndesTreeNavigationItemRef,\n): boolean {\n const position = earlier.element.compareDocumentPosition(later.element);\n if (position & DOCUMENT_POSITION_DISCONNECTED) {\n return true;\n }\n return !(position & DOCUMENT_POSITION_PRECEDING);\n}\n\n/**\n * Returns the items in DOM order. Items normally register in DOM order already, so the common\n * case is one cheap pass that hands back the same array; only a real reorder pays for a sort.\n */\nfunction inDocumentOrder(\n items: readonly AndesTreeNavigationItemRef[],\n): readonly AndesTreeNavigationItemRef[] {\n for (let index = 1; index < items.length; index++) {\n if (!isInOrder(items[index - 1], items[index])) {\n return [...items].sort((a, b) =>\n isInOrder(a, b) ? (isInOrder(b, a) ? 0 : -1) : 1,\n );\n }\n }\n return items;\n}\n\n/** Whether a key event is a plain printable character, i.e. typeahead input. */\nfunction isPrintableCharacter(event: KeyboardEvent): boolean {\n return (\n event.key?.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey\n );\n}\n\n/**\n * Shared keyboard-navigation state for hierarchical widgets: trees, cascading pickers, menus\n * with fly-out submenus, grouped navigation. It owns the *visible-node* order (collapsed\n * subtrees are skipped), the active node, the expanded keys, the WAI-ARIA TreeView keys and\n * the ARIA facts (`aria-level`, `aria-posinset`, `aria-setsize`, `aria-expanded`) a node needs.\n *\n * It is a DI-scoped service, not a directive: provide it from the consuming component so that\n * every descendant item — including items rendered into a CDK overlay, which are injector\n * descendants but not DOM descendants — can inject the same instance.\n *\n * ```ts\n * @Component({\n * selector: 'andes-tree',\n * providers: [AndesTreeNavigation],\n * template: `\n * <ul role=\"tree\" andesTreeNavigationKeys>\n * @for (node of nodes(); track node.key) {\n * <li\n * role=\"treeitem\"\n * [andesTreeNavigationItem]=\"node.key\"\n * [parentKey]=\"node.parentKey\"\n * [disabled]=\"node.disabled\"\n * >\n * {{ node.title }}\n * </li>\n * }\n * </ul>\n * `,\n * })\n * export class AndesTree {\n * protected readonly navigation = inject(AndesTreeNavigation);\n * }\n * ```\n *\n * ### Where the structure comes from\n *\n * By default the structure is read from the registered items: each item names its key and its\n * parent, and their DOM order is the sibling order. That is exact for any tree that renders all\n * of its nodes. A **windowed** tree renders only the rows in view, so items come and go as the\n * user scrolls; for those, give the navigation the nodes directly with {@link setNodes}. Its\n * data order then drives everything, and rows that are not mounted are still part of the\n * keyboard order: moving onto one emits {@link revealRequested} so the list can scroll to it,\n * and the item takes focus the moment it mounts.\n *\n * ### What it deliberately does not do\n *\n * It owns no selection or checked state, sets no `role`, and never interprets `Enter` or\n * `Space` — activation is the consumer's. \"Active node\" is keyboard focus, not selection.\n */\n@Injectable()\nexport class AndesTreeNavigation {\n private readonly destroyRef = inject(DestroyRef);\n private readonly document = inject(DOCUMENT);\n private readonly isBrowser = inject(PLATFORM_ID) === 'browser';\n\n /** Which arrow keys move and which open/close. */\n readonly orientation = signal<AndesTreeOrientation>('vertical');\n /** Which nodes a move key walks over. */\n readonly scope = signal<AndesTreeNavigationScope>('tree');\n /** Whether moving past the first/last node wraps around. */\n readonly wrap = signal(false);\n /** Whether typing characters moves to the next matching node. */\n readonly typeahead = signal(true);\n /** How long a typeahead query stays buffered after the last keystroke. */\n readonly typeaheadDebounce = signal(ANDES_TREE_TYPEAHEAD_DEBOUNCE);\n /** Whether `Home`/`End` jump to the first/last node. */\n readonly homeAndEnd = signal(true);\n /** Whether `*` expands every sibling of the active node. */\n readonly expandSiblings = signal(true);\n /** How the active node is surfaced to assistive technology. */\n readonly focusMode = signal<AndesTreeFocusMode>('roving-tabindex');\n /** Text direction used to mirror the horizontal arrow keys. */\n readonly textDirection = signal<AndesTreeTextDirection>('ltr');\n /** Whether disabled nodes are skipped while navigating. */\n readonly skipDisabled = signal(true);\n /** Whether the keyboard may expand and collapse a disabled node. */\n readonly expandDisabled = signal(false);\n /** Whether the open key on a collapsed parent also steps into its first child. */\n readonly enterOnExpand = signal(false);\n /** Whether the close key on a child also collapses the parent it steps back to. */\n readonly collapseOnLeave = signal(false);\n\n private readonly source = signal<AndesTreeNavigationNodeSource | null>(null);\n private readonly registered = signal<readonly AndesTreeNavigationItemRef[]>(\n [],\n );\n private readonly orderVersion = signal(0);\n\n /**\n * Every registered item, in DOM order. Items that scroll out of a windowed tree are not in\n * here, which is why the navigation reads its structure from {@link setNodes} there.\n */\n readonly items: Signal<readonly AndesTreeNavigationItemRef[]> = computed(\n () => {\n this.orderVersion();\n return inDocumentOrder(this.registered());\n },\n );\n\n private readonly itemByKey = computed(() => {\n const byKey = new Map<AndesTreeNavigationKey, AndesTreeNavigationItemRef>();\n for (const item of this.registered()) {\n const key = item.itemKey();\n if (!byKey.has(key)) {\n byKey.set(key, item);\n }\n }\n return byKey;\n });\n\n private readonly itemByElement = computed(\n () => new Map(this.registered().map((item) => [item.element, item])),\n );\n\n private readonly nodes = computed<readonly AndesTreeNavigationNode[]>(() => {\n const source = this.source();\n if (source) {\n return source();\n }\n return this.items().map((item) => ({\n key: item.itemKey(),\n parentKey: item.itemParentKey(),\n disabled: item.isDisabled(),\n expandable: item.isExpandable(),\n }));\n });\n\n private readonly structure = computed(() => buildTreeStructure(this.nodes()));\n\n private readonly ownExpanded = signal<ReadonlySet<AndesTreeNavigationKey>>(\n new Set(),\n );\n private readonly expandedStore = signal<AndesTreeNavigationExpandedSource>(\n this.ownExpanded,\n );\n\n /** The keys of the expanded nodes. */\n readonly expandedKeys: Signal<ReadonlySet<AndesTreeNavigationKey>> = computed(\n () => {\n const value = this.expandedStore()();\n return Array.isArray(value)\n ? new Set<AndesTreeNavigationKey>(value)\n : (value as ReadonlySet<AndesTreeNavigationKey>);\n },\n );\n\n private readonly visible = computed(() =>\n collectVisibleNodes(this.structure().roots, this.expandedKeys()),\n );\n\n /**\n * The nodes a user can reach, in reading order: every node whose ancestors are all expanded.\n * This — not the DOM — is the order the arrow keys follow, so collapsed subtrees cost\n * nothing and an unmounted row still has its place. A virtual list renders a window of it.\n */\n readonly visibleNodes: Signal<readonly AndesTreeNavigationNodeInfo[]> =\n this.visible;\n\n private readonly visibleIndex = computed(() => {\n const index = new Map<AndesTreeNavigationKey, number>();\n this.visible().forEach((node, position) => index.set(node.key, position));\n return index;\n });\n\n private readonly _activeKey = signal<AndesTreeNavigationKey | null>(null);\n /** The active node's key, or `null` when nothing is active yet. */\n readonly activeKey: Signal<AndesTreeNavigationKey | null> =\n this._activeKey.asReadonly();\n\n /** The active node's mounted item, or `null` — also when the node is outside a window. */\n readonly activeItem: Signal<AndesTreeNavigationItemRef | null> = computed(\n () => {\n const key = this._activeKey();\n return key === null ? null : (this.itemByKey().get(key) ?? null);\n },\n );\n\n /** Index of the active node within {@link visibleNodes}, or `-1`. */\n readonly activeIndex: Signal<number> = computed(() => {\n const key = this._activeKey();\n return key === null ? -1 : (this.visibleIndex().get(key) ?? -1);\n });\n\n /**\n * The `id` to publish as `aria-activedescendant`, or `null` in `roving-tabindex` mode (where\n * real focus already conveys the active node) and while the active node has no mounted item.\n */\n readonly activeDescendantId: Signal<string | null> = computed(() =>\n this.focusMode() === 'active-descendant'\n ? (this.activeItem()?.itemId ?? null)\n : null,\n );\n\n /**\n * The node that should carry `tabindex=\"0\"` in `roving-tabindex` mode: the active node, or —\n * before anything is active, or once the active node is hidden or skipped — the first node\n * the user can navigate to, so the tree is always reachable with one Tab press.\n */\n readonly tabbableKey: Signal<AndesTreeNavigationKey | null> = computed(() => {\n const active = this._activeKey();\n if (active !== null && this.isNavigable(active)) {\n return active;\n }\n return this.visible().find((node) => !this.isSkipped(node))?.key ?? null;\n });\n\n /**\n * `0` when the tree has a tab stop but no mounted item to put it on — the tabbable node is\n * outside a windowed tree's rendered range — and `null` otherwise. Bind it to the\n * container's `tabindex` in virtualized templates; {@link AndesTreeNavigationKeys} forwards\n * focus on the container to the tabbable node, which scrolls it in.\n */\n readonly containerTabIndex: Signal<0 | null> = computed(() => {\n if (this.focusMode() !== 'roving-tabindex') {\n return null;\n }\n const key = this.tabbableKey();\n return key !== null && !this.itemByKey().has(key) ? 0 : null;\n });\n\n private readonly _expandedChange =\n new Subject<AndesTreeNavigationExpandChange>();\n /**\n * Emits whenever the navigation expands or collapses a node on the user's behalf — an arrow\n * key, `*`, or {@link expand}/{@link collapse}/{@link toggle}. This is where a lazy tree\n * starts loading children. {@link setExpanded} and `configure({ expanded })` are the consumer\n * speaking, so they do not echo back.\n */\n readonly expandedChange: Observable<AndesTreeNavigationExpandChange> =\n this._expandedChange.asObservable();\n\n private readonly _revealRequested =\n new Subject<AndesTreeNavigationRevealRequest>();\n /**\n * Emits when navigation lands on a node that has no mounted item (see {@link setNodes}).\n * Scroll the list to the given index; the item focuses itself when it mounts.\n */\n readonly revealRequested: Observable<AndesTreeNavigationRevealRequest> =\n this._revealRequested.asObservable();\n\n private readonly _tabOut = new Subject<void>();\n /** Emits when `Tab` is pressed, so a menu or popup can close and hand focus back. */\n readonly tabOut: Observable<void> = this._tabOut.asObservable();\n\n private typeaheadBuffer = '';\n private typeaheadTimer: ReturnType<typeof setTimeout> | null = null;\n /** The node focus should land on as soon as its item mounts. */\n private pendingFocusKey: AndesTreeNavigationKey | null = null;\n /** The parent to step into as soon as it has a child (`enterOnExpand` with lazy children). */\n private pendingEnterKey: AndesTreeNavigationKey | null = null;\n /** The active node's ancestors, nearest first, kept for when the node itself disappears. */\n private activeAncestry: readonly AndesTreeNavigationKey[] = [];\n /** Whether keyboard focus was last seen on one of this navigation's items. */\n private focusInside = false;\n private destroyed = false;\n\n constructor() {\n this.destroyRef.onDestroy(() => {\n this.destroyed = true;\n this.cancelTypeahead();\n this._expandedChange.complete();\n this._revealRequested.complete();\n this._tabOut.complete();\n });\n\n // The structure can change under the active node without any key being pressed: a\n // controlled `expanded` set collapses, a lazy child arrives, a row is deleted. Settle the\n // active node (and any step-into waiting for children) whenever that happens.\n effect(() => {\n this.visible();\n untracked(() => {\n this.reconcileActive();\n this.resolvePendingEnter();\n });\n });\n }\n\n /** Applies any subset of the configuration options in one call. */\n configure(config: AndesTreeNavigationConfig): void {\n if (config.orientation !== undefined) {\n this.orientation.set(config.orientation);\n }\n if (config.scope !== undefined) {\n this.scope.set(config.scope);\n }\n if (config.wrap !== undefined) {\n this.wrap.set(config.wrap);\n }\n if (config.typeahead !== undefined) {\n this.typeahead.set(config.typeahead);\n }\n if (config.typeaheadDebounce !== undefined) {\n this.typeaheadDebounce.set(config.typeaheadDebounce);\n }\n if (config.homeAndEnd !== undefined) {\n this.homeAndEnd.set(config.homeAndEnd);\n }\n if (config.expandSiblings !== undefined) {\n this.expandSiblings.set(config.expandSiblings);\n }\n if (config.focusMode !== undefined) {\n this.focusMode.set(config.focusMode);\n }\n if (config.textDirection !== undefined) {\n this.textDirection.set(config.textDirection);\n }\n if (config.skipDisabled !== undefined) {\n this.skipDisabled.set(config.skipDisabled);\n }\n if (config.expandDisabled !== undefined) {\n this.expandDisabled.set(config.expandDisabled);\n }\n if (config.enterOnExpand !== undefined) {\n this.enterOnExpand.set(config.enterOnExpand);\n }\n if (config.collapseOnLeave !== undefined) {\n this.collapseOnLeave.set(config.collapseOnLeave);\n }\n if (config.expanded !== undefined) {\n this.setExpanded(config.expanded);\n }\n }\n\n /**\n * Supplies the nodes in data order instead of reading them from the registered items — the\n * mode for windowed trees, and for any tree that wants to navigate nodes it has not rendered.\n * Pass `null` to go back to deriving the structure from items.\n *\n * The function runs inside a `computed`, so signals it reads (the node list, a loaded-children\n * map) keep the navigation up to date by themselves.\n */\n setNodes(source: AndesTreeNavigationNodeSource | null): void {\n this.source.set(source);\n }\n\n /**\n * Keeps the expanded keys in a signal the consumer owns, e.g. a component's `model()`, so\n * the state has one home and two-way binding just works. A `Set` and an array are both\n * accepted; whichever shape the signal holds is written back. Pass `null` to return to the\n * navigation's own store.\n */\n bindExpanded<K extends AndesTreeNavigationKey>(\n source: AndesTreeNavigationExpandedSource<K> | null,\n ): void {\n this.expandedStore.set(\n (source as AndesTreeNavigationExpandedSource | null) ?? this.ownExpanded,\n );\n }\n\n /** Adds an item to the tree. Called by `AndesTreeNavigationItem` on init. */\n register(item: AndesTreeNavigationItemRef): void {\n this.registered.update((items) => [...items, item]);\n }\n\n /**\n * Removes an item from the tree. Called by `AndesTreeNavigationItem` on destroy. If that item\n * was the active one, the reconcile that follows decides where the active node goes.\n */\n unregister(item: AndesTreeNavigationItemRef): void {\n this.registered.update((items) => items.filter((entry) => entry !== item));\n }\n\n /**\n * Re-reads the DOM order of the items. The order is re-checked whenever the tree's structure\n * changes, but moving existing elements around (re-sorting a `@for` list) changes no signal,\n * so call this after such a reorder. Trees fed by {@link setNodes} never need it.\n */\n refreshOrder(): void {\n this.orderVersion.update((version) => version + 1);\n }\n\n // ------------------------------------------------------------------ queries\n\n /** The hierarchy facts of a node, or `null` for a key the navigation does not know. */\n nodeInfo(key: AndesTreeNavigationKey): AndesTreeNavigationNodeInfo | null {\n return this.structure().byKey.get(key) ?? null;\n }\n\n /** Index of a node among the {@link visibleNodes}, or `-1` when it is hidden or unknown. */\n visibleIndexOf(key: AndesTreeNavigationKey): number {\n return this.visibleIndex().get(key) ?? -1;\n }\n\n /** The mounted item of a node, if it has one. */\n itemForKey(key: AndesTreeNavigationKey): AndesTreeNavigationItemRef | null {\n return this.itemByKey().get(key) ?? null;\n }\n\n /** Whether a node is expanded. */\n isExpanded(key: AndesTreeNavigationKey): boolean {\n return this.expandedKeys().has(key);\n }\n\n // ------------------------------------------------------------------ expansion\n\n /** Expands a node that can be expanded. Returns whether anything changed. */\n expand(key: AndesTreeNavigationKey): boolean {\n const node = this.structure().byKey.get(key);\n if (!node || !node.expandable || this.isExpanded(key)) {\n return false;\n }\n this.commitExpanded(new Set(this.expandedKeys()).add(key), true);\n return true;\n }\n\n /** Collapses a node. If the active node was inside it, the active node becomes this one. */\n collapse(key: AndesTreeNavigationKey): boolean {\n if (!this.isExpanded(key)) {\n return false;\n }\n const next = new Set(this.expandedKeys());\n next.delete(key);\n this.commitExpanded(next, true);\n return true;\n }\n\n /** Expands a collapsed node and collapses an expanded one. */\n toggle(key: AndesTreeNavigationKey): boolean {\n return this.isExpanded(key) ? this.collapse(key) : this.expand(key);\n }\n\n /** Expands every known node that can be expanded. */\n expandAll(): void {\n const next = new Set(this.expandedKeys());\n for (const node of this.structure().byKey.values()) {\n if (node.expandable) {\n next.add(node.key);\n }\n }\n this.commitExpanded(next, true);\n }\n\n /** Collapses every node. */\n collapseAll(): void {\n this.commitExpanded(new Set(), true);\n }\n\n /** Expands every ancestor of a node, so that the node becomes visible. */\n expandTo(key: AndesTreeNavigationKey): void {\n const next = new Set(this.expandedKeys());\n for (\n let ancestor = this.structure().byKey.get(key)?.parent ?? null;\n ancestor;\n ancestor = ancestor.parent\n ) {\n next.add(ancestor.key);\n }\n this.commitExpanded(next, true);\n }\n\n /**\n * Replaces the expanded keys. This is the consumer setting state, so it emits no\n * {@link expandedChange}.\n */\n setExpanded(keys: Iterable<AndesTreeNavigationKey>): void {\n this.commitExpanded(new Set(keys), false);\n }\n\n // ------------------------------------------------------------------ focus\n\n /**\n * Makes a visible, navigable node active and brings it into focus. In `roving-tabindex` mode\n * that moves real focus to its item; in `active-descendant` mode it scrolls the item into\n * view. If the node has no mounted item (a windowed tree) it is still made active, and\n * {@link revealRequested} asks the list to render it. Returns `false` for a hidden, unknown\n * or skipped node, leaving everything as it was.\n */\n focusKey(key: AndesTreeNavigationKey): boolean {\n if (!this.isNavigable(key)) {\n return false;\n }\n this.activate(key);\n const item = this.itemByKey().get(key);\n if (item) {\n this.applyFocus(item);\n } else {\n this.pendingFocusKey = key;\n this._revealRequested.next({ key, index: this.visibleIndexOf(key) });\n }\n return true;\n }\n\n /** Moves the active node to the first navigable node of the current scope. */\n focusFirst(): void {\n this.focusEdge(true);\n }\n\n /** Moves the active node to the last navigable node of the current scope. */\n focusLast(): void {\n this.focusEdge(false);\n }\n\n /** Moves the active node to the next navigable node, respecting {@link wrap}. */\n focusNext(): void {\n this.move(this.currentRecord(), 1);\n }\n\n /** Moves the active node to the previous navigable node, respecting {@link wrap}. */\n focusPrevious(): void {\n this.move(this.currentRecord(), -1);\n }\n\n /**\n * Moves the active pointer without focusing anything — for restoring the active node on\n * init (say, the selected one), or following a click that already moved real focus. Accepts\n * any known node, even one that is currently collapsed away. Returns `false` for an unknown\n * key.\n */\n setActiveKeySilently(key: AndesTreeNavigationKey | null): boolean {\n if (key === null) {\n this.clearActive();\n return true;\n }\n if (!this.structure().byKey.has(key)) {\n return false;\n }\n this.activate(key);\n return true;\n }\n\n /** Clears the active node, e.g. when a popup closes. */\n clearActive(): void {\n this.pendingFocusKey = null;\n this.pendingEnterKey = null;\n this.activeAncestry = [];\n this._activeKey.set(null);\n }\n\n /** Whether a typeahead query is currently buffered. */\n isTyping(): boolean {\n return this.typeaheadBuffer.length > 0;\n }\n\n /** Discards any buffered typeahead query. */\n cancelTypeahead(): void {\n this.clearTypeaheadTimer();\n this.typeaheadBuffer = '';\n }\n\n private clearTypeaheadTimer(): void {\n if (this.typeaheadTimer !== null) {\n clearTimeout(this.typeaheadTimer);\n this.typeaheadTimer = null;\n }\n }\n\n // ------------------------------------------------------------------ item hooks\n\n /**\n * Called by an item when real focus lands on it, so the active node follows the mouse or a\n * direct Tab and Tabbing away and back returns to the same place.\n */\n onItemFocusin(item: AndesTreeNavigationItemRef): void {\n this.focusInside = true;\n if (this.focusMode() !== 'roving-tabindex') {\n return;\n }\n const key = item.itemKey();\n if (this._activeKey() !== key && this.structure().byKey.has(key)) {\n this.activate(key);\n }\n }\n\n /**\n * Called by an item when it loses focus. Focus that merely moves to another node keeps the\n * \"focus is in the tree\" memory; so does an item that was removed while focused, which is\n * exactly the case where focus must be handed to an ancestor instead of being lost.\n */\n onItemFocusout(item: AndesTreeNavigationItemRef, event: FocusEvent): void {\n const next = event.relatedTarget as Element | null;\n if (next) {\n this.focusInside = this.itemByElement().has(next as HTMLElement);\n } else if (item.element.isConnected) {\n this.focusInside = false;\n }\n }\n\n /**\n * Called by an item once it has rendered, so a node that navigation reached before it was\n * mounted (a windowed tree) receives the focus it was promised.\n */\n onItemRendered(item: AndesTreeNavigationItemRef): void {\n if (\n this.pendingFocusKey !== null &&\n item.itemKey() === this.pendingFocusKey\n ) {\n this.pendingFocusKey = null;\n this.applyFocus(item);\n }\n }\n\n // ------------------------------------------------------------------ keyboard\n\n /**\n * Handles a `keydown` on whichever element owns keyboard focus for this tree — the tree or a\n * node in `roving-tabindex` mode, the input in `active-descendant` mode.\n * `AndesTreeNavigationKeys` wires this up for you.\n *\n * Only navigation keys are consumed (and `preventDefault`ed): the four arrows, `Home`, `End`,\n * `*` and typeahead characters. `Enter`, `Space` (outside a typeahead query) and `Escape`\n * are left entirely to the consumer, as are keys typed into a control nested inside a node\n * and any event a consumer handler already `preventDefault`ed — which is how a multi-select\n * tree claims `Shift`+arrow before the navigation sees it.\n */\n onKeydown(event: KeyboardEvent): void {\n if (\n event.defaultPrevented ||\n event.ctrlKey ||\n event.metaKey ||\n event.altKey\n ) {\n return;\n }\n if (event.key === 'Tab') {\n this._tabOut.next();\n return;\n }\n\n const origin = this.keyOrigin(event);\n if (origin === 'inside-node') {\n return;\n }\n if (origin !== null) {\n // Real focus is the source of truth in roving mode; catch up if a focus event was missed.\n if (this._activeKey() !== origin && this.structure().byKey.has(origin)) {\n this.activate(origin);\n }\n }\n\n const record = this.currentRecord();\n const handled = this.handleKey(event, record);\n if (handled) {\n event.preventDefault();\n }\n }\n\n // ------------------------------------------------------------------ internals\n\n private handleKey(\n event: KeyboardEvent,\n record: TreeNodeRecord | null,\n ): boolean {\n const command = this.commandFor(event.key);\n if (command === 'next') {\n return this.move(record, 1);\n }\n if (command === 'previous') {\n return this.move(record, -1);\n }\n if (command === 'open') {\n return this.open(record);\n }\n if (command === 'close') {\n return this.close(record);\n }\n if (event.key === 'Home' && this.homeAndEnd()) {\n return this.focusEdge(true, record);\n }\n if (event.key === 'End' && this.homeAndEnd()) {\n return this.focusEdge(false, record);\n }\n if (event.key === '*' && this.expandSiblings()) {\n return this.expandSiblingsOf(record);\n }\n if (isPrintableCharacter(event) && this.typeahead()) {\n // Space activates a node; it may extend a typeahead query but must never start one.\n if (event.key === ' ' && !this.isTyping()) {\n return false;\n }\n return this.matchTypeahead(event.key, record);\n }\n return false;\n }\n\n /** Maps an arrow key to what it means in the current orientation and direction. */\n private commandFor(key: string): Command | null {\n const rtl = this.textDirection() === 'rtl';\n if (this.orientation() === 'horizontal') {\n switch (key) {\n case 'ArrowRight':\n return rtl ? 'previous' : 'next';\n case 'ArrowLeft':\n return rtl ? 'next' : 'previous';\n case 'ArrowDown':\n return 'open';\n case 'ArrowUp':\n return 'close';\n }\n return null;\n }\n switch (key) {\n case 'ArrowDown':\n return 'next';\n case 'ArrowUp':\n return 'previous';\n case 'ArrowRight':\n return rtl ? 'close' : 'open';\n case 'ArrowLeft':\n return rtl ? 'open' : 'close';\n }\n return null;\n }\n\n /**\n * Where a key press came from: the key of the node whose item it was typed on, `null` for\n * the container itself, or `'inside-node'` for a control nested inside a node, whose keys\n * belong to that control.\n */\n private keyOrigin(\n event: KeyboardEvent,\n ): AndesTreeNavigationKey | 'inside-node' | null {\n const byElement = this.itemByElement();\n let element = event.target as Element | null;\n while (element) {\n const item = byElement.get(element as HTMLElement);\n if (item) {\n return item.element === event.target ? item.itemKey() : 'inside-node';\n }\n if (element === event.currentTarget) {\n break;\n }\n element = element.parentElement;\n }\n return null;\n }\n\n /** The active node's record, provided it is still visible. */\n private currentRecord(): TreeNodeRecord | null {\n const key = this._activeKey();\n if (key === null || !this.visibleIndex().has(key)) {\n return null;\n }\n return this.structure().byKey.get(key) ?? null;\n }\n\n private isSkipped(node: AndesTreeNavigationNodeInfo): boolean {\n return this.skipDisabled() && node.disabled;\n }\n\n private isNavigable(key: AndesTreeNavigationKey): boolean {\n if (!this.visibleIndex().has(key)) {\n return false;\n }\n const node = this.structure().byKey.get(key);\n return !!node && !this.isSkipped(node);\n }\n\n private canToggle(node: TreeNodeRecord): boolean {\n return !node.disabled || this.expandDisabled();\n }\n\n /** The nodes a move key walks over: everything visible, or just the active node's group. */\n private scopeList(record: TreeNodeRecord | null): readonly TreeNodeRecord[] {\n if (this.scope() === 'tree') {\n return this.visible();\n }\n return record\n ? (record.parent?.children ?? this.structure().roots)\n : this.structure().roots;\n }\n\n private indexInScope(\n list: readonly TreeNodeRecord[],\n record: TreeNodeRecord | null,\n ): number {\n if (!record) {\n return -1;\n }\n return this.scope() === 'tree'\n ? this.visibleIndexOf(record.key)\n : list.indexOf(record);\n }\n\n private move(record: TreeNodeRecord | null, direction: Direction): boolean {\n const list = this.scopeList(record);\n const from = this.indexInScope(list, record);\n const target =\n from === -1\n ? this.edgeOf(list, direction === 1)\n : this.stepFrom(list, from, direction);\n if (target) {\n this.focusKey(target.key);\n }\n return true;\n }\n\n private stepFrom(\n list: readonly TreeNodeRecord[],\n from: number,\n direction: Direction,\n ): TreeNodeRecord | null {\n const count = list.length;\n for (let step = 1; step < count; step++) {\n let index = from + direction * step;\n if (index < 0 || index >= count) {\n if (!this.wrap()) {\n return null;\n }\n index = ((index % count) + count) % count;\n }\n if (!this.isSkipped(list[index])) {\n return list[index];\n }\n }\n return null;\n }\n\n private edgeOf(\n list: readonly TreeNodeRecord[],\n first: boolean,\n ): TreeNodeRecord | null {\n if (first) {\n return list.find((node) => !this.isSkipped(node)) ?? null;\n }\n for (let index = list.length - 1; index >= 0; index--) {\n if (!this.isSkipped(list[index])) {\n return list[index];\n }\n }\n return null;\n }\n\n private focusEdge(first: boolean, record = this.currentRecord()): boolean {\n const target = this.edgeOf(this.scopeList(record), first);\n if (target) {\n this.focusKey(target.key);\n }\n return true;\n }\n\n private firstNavigableChild(node: TreeNodeRecord): TreeNodeRecord | null {\n return node.children.find((child) => !this.isSkipped(child)) ?? null;\n }\n\n /** Opens a collapsed parent, or steps into the first child of an open one. */\n private open(record: TreeNodeRecord | null): boolean {\n const vertical = this.orientation() === 'vertical';\n if (!record || !record.expandable) {\n // Sideways keys must not scroll a vertical tree, but a sideways bar leaves Down alone.\n return vertical;\n }\n if (!this.isExpanded(record.key)) {\n if (!this.canToggle(record)) {\n return true;\n }\n this.expand(record.key);\n if (this.enterOnExpand()) {\n this.stepIntoOrWait(record);\n }\n return true;\n }\n const child = this.firstNavigableChild(record);\n if (child) {\n this.focusKey(child.key);\n } else if (this.enterOnExpand()) {\n this.pendingEnterKey = record.key;\n }\n return true;\n }\n\n private stepIntoOrWait(record: TreeNodeRecord): void {\n // Children read from items only exist once they have rendered, so a parent that has none\n // yet is stepped into later, from `resolvePendingEnter`.\n const child = this.firstNavigableChild(\n this.structure().byKey.get(record.key) ?? record,\n );\n if (child) {\n this.focusKey(child.key);\n } else {\n this.pendingEnterKey = record.key;\n }\n }\n\n /** Closes an open parent, or steps out to the nearest navigable ancestor. */\n private close(record: TreeNodeRecord | null): boolean {\n const vertical = this.orientation() === 'vertical';\n if (!record) {\n return vertical;\n }\n if (\n record.expandable &&\n this.isExpanded(record.key) &&\n this.canToggle(record)\n ) {\n this.collapse(record.key);\n return true;\n }\n let parent = record.parent;\n while (parent && this.isSkipped(parent)) {\n parent = parent.parent;\n }\n if (!parent) {\n return vertical;\n }\n this.focusKey(parent.key);\n if (this.collapseOnLeave() && this.canToggle(parent)) {\n this.collapse(parent.key);\n }\n return true;\n }\n\n private expandSiblingsOf(record: TreeNodeRecord | null): boolean {\n if (!record) {\n return true;\n }\n const siblings = record.parent?.children ?? this.structure().roots;\n const next = new Set(this.expandedKeys());\n for (const sibling of siblings) {\n if (sibling.expandable && this.canToggle(sibling)) {\n next.add(sibling.key);\n }\n }\n this.commitExpanded(next, true);\n return true;\n }\n\n private matchTypeahead(\n character: string,\n record: TreeNodeRecord | null,\n ): boolean {\n this.clearTypeaheadTimer();\n this.typeaheadBuffer += character.toLocaleLowerCase();\n this.typeaheadTimer = setTimeout(\n () => this.cancelTypeahead(),\n this.typeaheadDebounce(),\n );\n\n const list = this.scopeList(record);\n if (list.length === 0) {\n return true;\n }\n const from = this.indexInScope(list, record);\n const buffer = this.typeaheadBuffer;\n const repeated =\n buffer.length > 1 && [...buffer].every((letter) => letter === buffer[0]);\n\n let target: TreeNodeRecord | null;\n if (repeated) {\n // \"aa\" is a prefix when some label starts with it, and otherwise the user cycling\n // through the \"a\" nodes.\n target =\n this.findByPrefix(list, buffer, Math.max(from, 0)) ??\n this.findByPrefix(list, buffer[0], from + 1);\n } else {\n // A single character searches from the *next* node so repeating it cycles; a longer\n // query refines from the current one, which may itself still match.\n target = this.findByPrefix(\n list,\n buffer,\n buffer.length === 1 ? from + 1 : Math.max(from, 0),\n );\n }\n if (target) {\n this.focusKey(target.key);\n }\n return true;\n }\n\n private findByPrefix(\n list: readonly TreeNodeRecord[],\n prefix: string,\n start: number,\n ): TreeNodeRecord | null {\n for (let step = 0; step < list.length; step++) {\n const node = list[(start + step) % list.length];\n if (\n !this.isSkipped(node) &&\n this.labelOf(node).trimStart().toLocaleLowerCase().startsWith(prefix)\n ) {\n return node;\n }\n }\n return null;\n }\n\n private labelOf(node: TreeNodeRecord): string {\n return node.label ?? this.itemByKey().get(node.key)?.getLabel() ?? '';\n }\n\n /** Records the active node and its ancestry, and drops waits that belonged to the old one. */\n private activate(key: AndesTreeNavigationKey): void {\n const ancestry: AndesTreeNavigationKey[] = [];\n for (\n let ancestor = this.structure().byKey.get(key)?.parent ?? null;\n ancestor;\n ancestor = ancestor.parent\n ) {\n ancestry.push(ancestor.key);\n }\n this.activeAncestry = ancestry;\n this.pendingFocusKey = null;\n this.pendingEnterKey = null;\n this._activeKey.set(key);\n }\n\n private applyFocus(item: AndesTreeNavigationItemRef): void {\n if (!this.isBrowser) {\n return;\n }\n if (this.focusMode() === 'roving-tabindex') {\n item.focus();\n } else {\n item.reveal();\n }\n }\n\n private currentStore(): WritableSignal<unknown> {\n return this.expandedStore() as WritableSignal<unknown>;\n }\n\n /**\n * Writes a new expanded set, optionally announcing what changed, and then makes sure the\n * active node is still somewhere a user can be.\n */\n private commitExpanded(\n next: ReadonlySet<AndesTreeNavigationKey>,\n announce: boolean,\n ): void {\n const current = this.expandedKeys();\n const changes: AndesTreeNavigationExpandChange[] = [];\n for (const key of next) {\n if (!current.has(key)) {\n changes.push({ key, expanded: true });\n }\n }\n for (const key of current) {\n if (!next.has(key)) {\n changes.push({ key, expanded: false });\n }\n }\n if (changes.length === 0) {\n return;\n }\n\n const store = this.currentStore();\n store.set(Array.isArray(untracked(store)) ? [...next] : new Set(next));\n if (announce && !this.destroyed) {\n changes.forEach((change) => this._expandedChange.next(change));\n }\n // Collapsing is synchronous on purpose: the active descendant is still mounted right now,\n // so focus can be handed to the ancestor before the browser would have dropped it.\n this.reconcileActive();\n }\n\n /**\n * Keeps the active node somewhere reachable. When it has been hidden by a collapse, it moves\n * to the nearest visible ancestor — and takes real focus along if the tree had it. When it\n * has been deleted from a node source, the same applies to its remembered ancestry. When an\n * item-derived node merely disappears, nothing is guessed and the active node is cleared:\n * an unmounted item is not evidence that the node is gone.\n */\n private reconcileActive(): void {\n const active = this._activeKey();\n if (this.destroyed || active === null || this.visibleIndex().has(active)) {\n return;\n }\n\n const byKey = this.structure().byKey;\n const record = byKey.get(active);\n let target: TreeNodeRecord | null = null;\n\n if (record) {\n target = record.parent;\n while (\n target &&\n (!this.visibleIndex().has(target.key) || this.isSkipped(target))\n ) {\n target = target.parent;\n }\n } else {\n for (const key of this.activeAncestry) {\n const ancestor = byKey.get(key);\n if (!ancestor || !this.visibleIndex().has(key)) {\n continue;\n }\n // From items, an ancestor only explains the disappearance if it is collapsed.\n if (\n !this.isSkipped(ancestor) &&\n (this.source() !== null || !this.isExpanded(key))\n ) {\n target = ancestor;\n }\n break;\n }\n }\n\n const hadFocus = this.hadFocus();\n if (!target) {\n this.clearActive();\n return;\n }\n if (hadFocus && this.focusMode() === 'roving-tabindex') {\n this.focusKey(target.key);\n } else {\n this.activate(target.key);\n }\n }\n\n /** Whether keyboard focus is on this tree right now, or was when its node was removed. */\n private hadFocus(): boolean {\n if (!this.isBrowser) {\n return false;\n }\n const focused = this.document.activeElement as HTMLElement | null;\n return this.focusInside || (!!focused && this.itemByElement().has(focused));\n }\n\n /** Finishes a step into a parent whose children were not there when the key was pressed. */\n private resolvePendingEnter(): void {\n const key = this.pendingEnterKey;\n if (key === null) {\n return;\n }\n const node = this.structure().byKey.get(key);\n if (!node || this._activeKey() !== key || !this.isExpanded(key)) {\n this.pendingEnterKey = null;\n return;\n }\n const child = this.firstNavigableChild(node);\n if (child) {\n this.pendingEnterKey = null;\n this.focusKey(child.key);\n }\n }\n}\n","import {\n afterNextRender,\n booleanAttribute,\n computed,\n Directive,\n ElementRef,\n inject,\n input,\n OnDestroy,\n OnInit,\n Signal,\n} from '@angular/core';\n\nimport { AndesTreeNavigation } from './tree-navigation';\nimport {\n AndesTreeNavigationItemRef,\n AndesTreeNavigationKey,\n} from './tree-navigation-types';\n\nlet nextId = 0;\n\n/** Accepts `undefined`, a number or a numeric attribute string; anything else means \"unset\". */\nfunction optionalNumber(\n value: number | string | null | undefined,\n): number | undefined {\n if (value === null || value === undefined || value === '') {\n return undefined;\n }\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : undefined;\n}\n\n/** Keeps \"not set\" distinct from `false`, so an unset input can fall back to the children. */\nfunction optionalBoolean(\n value: boolean | string | null | undefined,\n): boolean | undefined {\n return value === undefined || value === null\n ? undefined\n : booleanAttribute(value);\n}\n\n/**\n * One node of a tree governed by {@link AndesTreeNavigation}: a tree item, a menu item with a\n * submenu, a cascader option. It tells the navigation who it is (`key`), where it sits\n * (`parentKey`, or the enclosing item when items are nested in the template), whether it is\n * `disabled` or `expandable`, and in return receives everything a node needs as signals:\n * `ariaLevel`, `ariaPosinset`, `ariaSetsize`, `ariaExpanded`, `tabIndex`, `active`.\n *\n * It registers on init and unregisters on destroy, so `@if`/`@for`-driven trees and\n * windowed lists, whose items come and go as the user scrolls, need no bookkeeping.\n *\n * By default it also writes those facts to the host (`id`, `tabindex`, `aria-level`,\n * `aria-posinset`, `aria-setsize`, `aria-expanded`, `aria-disabled`, and `data-active`,\n * `data-disabled`, `data-expanded` hooks for styling). Roles and selection attributes\n * (`role=\"treeitem\"`, `aria-selected`, `aria-checked`) stay with the consuming component.\n * Turn the ARIA attributes off with `[manageAria]=\"false\"` when the component binds them itself.\n *\n * ```html\n * <!-- Flat rows, as a virtual list renders them -->\n * <div role=\"treeitem\"\n * [andesTreeNavigationItem]=\"row.key\"\n * [parentKey]=\"row.parentKey\"\n * [expandable]=\"row.hasChildren\">\n * {{ row.title }}\n * </div>\n *\n * <!-- Nested markup: the parent is the enclosing item -->\n * <li role=\"treeitem\" [andesTreeNavigationItem]=\"'docs'\">\n * Docs\n * <ul role=\"group\">\n * <li role=\"treeitem\" [andesTreeNavigationItem]=\"'docs/api'\">API</li>\n * </ul>\n * </li>\n * ```\n */\n@Directive({\n selector: '[andesTreeNavigationItem]',\n exportAs: 'andesTreeNavigationItem',\n host: {\n '[attr.id]': 'itemId',\n '[attr.tabindex]': 'tabIndex()',\n '[attr.aria-level]': 'manageAria() ? ariaLevel() : null',\n '[attr.aria-posinset]': 'manageAria() ? ariaPosinset() : null',\n '[attr.aria-setsize]': 'manageAria() ? ariaSetsize() : null',\n '[attr.aria-expanded]': 'manageAria() ? ariaExpanded() : null',\n '[attr.aria-disabled]': 'manageAria() && nodeDisabled() ? \"true\" : null',\n '[attr.data-active]': 'active() ? \"\" : null',\n '[attr.data-disabled]': 'nodeDisabled() ? \"\" : null',\n '[attr.data-expanded]': 'expanded() ? \"\" : null',\n '(focusin)': 'onFocusin()',\n '(focusout)': 'onFocusout($event)',\n },\n})\nexport class AndesTreeNavigationItem\n implements AndesTreeNavigationItemRef, OnInit, OnDestroy\n{\n /**\n * The node's unique key. Bound through the directive's own selector so the common case needs\n * no extra attribute: `[andesTreeNavigationItem]=\"node.key\"`.\n */\n readonly key = input.required<AndesTreeNavigationKey>({\n alias: 'andesTreeNavigationItem',\n });\n\n /**\n * Key of the parent node, or `null` for a root. Leave it unset when items are nested in the\n * template, in which case the enclosing item is the parent; set it for flat markup, where\n * nesting is expressed by data rather than by the DOM.\n */\n readonly parentKey = input<AndesTreeNavigationKey | null | undefined>(\n undefined,\n );\n\n /** Whether navigation skips the node. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n /**\n * Whether the node can be expanded. Leave it unset to derive it from \"has registered\n * children\"; set it for a parent whose children are not rendered yet (collapsed subtrees\n * that are not in the DOM, lazily loaded children), so that `ArrowRight` can open it.\n */\n readonly expandable = input<\n boolean | undefined,\n boolean | string | null | undefined\n >(undefined, { transform: optionalBoolean });\n\n /**\n * Text typeahead matches against. Defaults to the item's own text content, which is usually\n * right; set it when the visible text is decorative or split across elements.\n */\n readonly typeaheadLabel = input<string>();\n\n /**\n * Overrides `aria-level` for trees that render only a slice of the hierarchy and so cannot\n * count ancestors. By default the level is derived from the parent chain.\n */\n readonly level = input<\n number | undefined,\n number | string | null | undefined\n >(undefined, { transform: optionalNumber });\n\n /** Overrides `aria-posinset`, e.g. a server-side position in a paged list of siblings. */\n readonly posInSet = input<\n number | undefined,\n number | string | null | undefined\n >(undefined, { transform: optionalNumber });\n\n /** Overrides `aria-setsize`, e.g. the total sibling count of a partly loaded list. */\n readonly setSize = input<\n number | undefined,\n number | string | null | undefined\n >(undefined, { transform: optionalNumber });\n\n /**\n * Whether the directive writes `aria-level`, `aria-posinset`, `aria-setsize`,\n * `aria-expanded` and `aria-disabled` to the host. Turn it off when the component binds\n * them itself, from the signals below.\n */\n readonly manageAria = input(true, { transform: booleanAttribute });\n\n /** @internal Mirrors {@link key} under the name the navigation's item contract uses. */\n readonly itemKey: Signal<AndesTreeNavigationKey> = this.key;\n\n /** @internal Mirrors {@link disabled} under the name the navigation's item contract uses. */\n readonly isDisabled: Signal<boolean> = this.disabled;\n\n /** @internal Mirrors {@link expandable} under the name the navigation's item contract uses. */\n readonly isExpandable: Signal<boolean | undefined> = this.expandable;\n\n private readonly navigation = inject(AndesTreeNavigation);\n\n /** The enclosing item of the same tree, when the markup is nested. */\n private readonly enclosingItem = inject(AndesTreeNavigationItem, {\n optional: true,\n skipSelf: true,\n });\n\n readonly element: HTMLElement =\n inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\n /** The item's DOM `id` — its own, when it has one, so authored ids are never clobbered. */\n readonly itemId: string =\n this.element.id || `andes-tree-navigation-item-${nextId++}`;\n\n /** @internal The parent's key as the navigation should see it. */\n readonly itemParentKey: Signal<AndesTreeNavigationKey | null> = computed(\n () => {\n const explicit = this.parentKey();\n if (explicit !== undefined) {\n return explicit;\n }\n const enclosing = this.enclosingItem;\n return enclosing && enclosing.navigation === this.navigation\n ? enclosing.key()\n : null;\n },\n );\n\n private readonly info = computed(() => this.navigation.nodeInfo(this.key()));\n\n /** Whether this is the navigation's active node. */\n readonly active: Signal<boolean> = computed(\n () => this.navigation.activeKey() === this.key(),\n );\n\n /** Whether the navigation treats this node as disabled. */\n readonly nodeDisabled: Signal<boolean> = computed(\n () => this.info()?.disabled ?? this.disabled(),\n );\n\n /** Whether the node can be expanded: declared, or because it has children. */\n readonly isExpandableNode: Signal<boolean> = computed(\n () => this.info()?.expandable ?? false,\n );\n\n /** Whether the node is expanded. */\n readonly expanded: Signal<boolean> = computed(() =>\n this.navigation.expandedKeys().has(this.key()),\n );\n\n /** `aria-level`: 1 for a root. */\n readonly ariaLevel: Signal<number> = computed(\n () => this.level() ?? this.info()?.level ?? 1,\n );\n\n /** `aria-posinset`: 1-based position among all siblings, collapsed ones included. */\n readonly ariaPosinset: Signal<number> = computed(\n () => this.posInSet() ?? this.info()?.posInSet ?? 1,\n );\n\n /** `aria-setsize`: number of siblings, this node included. */\n readonly ariaSetsize: Signal<number> = computed(\n () => this.setSize() ?? this.info()?.setSize ?? 1,\n );\n\n /** `aria-expanded`: `true`/`false` on a parent, `null` on a leaf (the attribute is omitted). */\n readonly ariaExpanded: Signal<boolean | null> = computed(() =>\n this.isExpandableNode() ? this.expanded() : null,\n );\n\n /**\n * `0` on the one roving-tabindex target, `-1` on every other node, and absent entirely in\n * `active-descendant` mode, where nodes are not focusable at all.\n */\n readonly tabIndex: Signal<number | null> = computed(() => {\n if (this.navigation.focusMode() === 'active-descendant') {\n return null;\n }\n return this.navigation.tabbableKey() === this.key() ? 0 : -1;\n });\n\n constructor() {\n // Runs in the browser only. By then the element is attached, which is what a node the\n // navigation reached before it mounted needs in order to take focus.\n afterNextRender(() => this.navigation.onItemRendered(this));\n }\n\n ngOnInit(): void {\n this.navigation.register(this);\n }\n\n ngOnDestroy(): void {\n this.navigation.unregister(this);\n }\n\n getLabel(): string {\n return this.typeaheadLabel() ?? (this.element.textContent ?? '').trim();\n }\n\n focus(): void {\n this.element.focus();\n }\n\n /**\n * Scrolls the node into view without moving focus — what `active-descendant` mode needs,\n * since real focus never reaches the node.\n */\n reveal(): void {\n this.element.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });\n }\n\n /** Expands the node. A chevron button calls this. Returns whether anything changed. */\n expand(): boolean {\n return this.navigation.expand(this.key());\n }\n\n /** Collapses the node. Returns whether anything changed. */\n collapse(): boolean {\n return this.navigation.collapse(this.key());\n }\n\n /** Expands a collapsed node and collapses an expanded one. */\n toggle(): boolean {\n return this.navigation.toggle(this.key());\n }\n\n protected onFocusin(): void {\n this.navigation.onItemFocusin(this);\n }\n\n protected onFocusout(event: FocusEvent): void {\n this.navigation.onItemFocusout(this, event);\n }\n}\n","import { Directive, inject } from '@angular/core';\n\nimport { AndesTreeNavigation } from './tree-navigation';\n\n/**\n * Wires the keyboard-owning element of a tree to its {@link AndesTreeNavigation}: forwards\n * `keydown` to it and publishes `aria-activedescendant` when the tree is in `active-descendant`\n * mode.\n *\n * Put it on whichever element holds real DOM focus:\n *\n * - a tree whose nodes take focus — the `role=\"tree\"` element (keys bubble up from the nodes);\n * - a cascader or tree-select — the field or the `<input>`, which keeps focus the whole time;\n * - a menu — the `role=\"menu\"` popup.\n *\n * It only consumes navigation keys, so the consumer is free to bind its own `keydown` handler on\n * the same element for `Enter`, `Space` and `Escape`.\n *\n * In a windowed tree the tab stop can fall on a node that is not rendered. Binding\n * `[attr.tabindex]=\"navigation.containerTabIndex()\"` on the same element then keeps the tree\n * reachable with Tab, and this directive passes the focus on to the node, scrolling it in.\n *\n * ```html\n * <ul role=\"tree\" andesTreeNavigationKeys (keydown.enter)=\"activate()\">…</ul>\n * ```\n */\n@Directive({\n selector: '[andesTreeNavigationKeys]',\n host: {\n '(keydown)': 'onKeydown($event)',\n '(focusin)': 'onFocusin($event)',\n '[attr.aria-activedescendant]': 'navigation.activeDescendantId()',\n },\n})\nexport class AndesTreeNavigationKeys {\n protected readonly navigation = inject(AndesTreeNavigation);\n\n protected onKeydown(event: KeyboardEvent): void {\n this.navigation.onKeydown(event);\n }\n\n protected onFocusin(event: FocusEvent): void {\n if (event.target !== event.currentTarget) {\n return;\n }\n // Focus landed on the container itself, which only has a tab stop when the real one is a\n // node outside the rendered window.\n const key = this.navigation.tabbableKey();\n if (key !== null && this.navigation.containerTabIndex() === 0) {\n this.navigation.focusKey(key);\n }\n }\n}\n","import {\n computed,\n DestroyRef,\n inject,\n Injectable,\n InjectionToken,\n PLATFORM_ID,\n signal,\n Signal,\n} from '@angular/core';\n\n/** The names of Andes' responsive breakpoints. */\nexport type AndesBreakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';\n\n/** Breakpoint names, smallest first. */\nexport const ANDES_BREAKPOINT_NAMES: readonly AndesBreakpoint[] = [\n 'xs',\n 'sm',\n 'md',\n 'lg',\n 'xl',\n 'xxl',\n];\n\n/**\n * The minimum viewport (or container) width, in pixels, at which each breakpoint starts.\n * Breakpoints are cumulative and mobile-first: `md` applies from 768px up, until `lg` takes\n * over. One table shared by every component keeps \"mobile\" meaning the same width everywhere.\n */\nexport const ANDES_BREAKPOINTS: Readonly<Record<AndesBreakpoint, number>> = {\n xs: 0,\n sm: 576,\n md: 768,\n lg: 992,\n xl: 1200,\n xxl: 1600,\n};\n\n/**\n * The largest breakpoint whose minimum width fits `width`. Negative and `NaN` widths count as\n * `xs`.\n */\nexport function andesBreakpointForWidth(width: number): AndesBreakpoint {\n let current: AndesBreakpoint = 'xs';\n for (const name of ANDES_BREAKPOINT_NAMES) {\n if (width >= ANDES_BREAKPOINTS[name]) {\n current = name;\n }\n }\n return current;\n}\n\n/**\n * The breakpoint reported where the viewport cannot be measured (server rendering, browsers\n * without `matchMedia`). Override it to match your most common client so the server-rendered\n * markup is the one most users keep.\n */\nexport const ANDES_BREAKPOINT_SSR_DEFAULT = new InjectionToken<AndesBreakpoint>(\n 'ANDES_BREAKPOINT_SSR_DEFAULT',\n {\n providedIn: 'root',\n factory: () => 'lg',\n },\n);\n\nfunction indexOfBreakpoint(name: AndesBreakpoint): number {\n const index = ANDES_BREAKPOINT_NAMES.indexOf(name);\n if (index < 0) {\n throw new Error(`Unknown Andes breakpoint \"${String(name)}\".`);\n }\n return index;\n}\n\n/**\n * The current viewport breakpoint and ready-made \"at least / narrower than / in range\" signals,\n * shared by the whole application.\n *\n * It listens to one `matchMedia` query per breakpoint (never to `resize`), so nothing runs\n * while the viewport stays inside a breakpoint, and the listeners are removed with the root\n * injector. On the server, or where `matchMedia` does not exist, `active` holds\n * `ANDES_BREAKPOINT_SSR_DEFAULT` and never changes.\n *\n * The comparisons are half-open on purpose: `up(x)` is true from the start of `x`, `down(x)` is\n * true strictly before it, so `down(x)` is always `!up(x)` and `between(a, b)` ranges never\n * overlap or leave a gap when chained (`between('sm', 'md')` then `between('md', 'lg')`).\n */\n@Injectable({ providedIn: 'root' })\nexport class AndesBreakpoints {\n private readonly state = signal<AndesBreakpoint>(\n inject(ANDES_BREAKPOINT_SSR_DEFAULT),\n );\n private readonly comparisons = new Map<string, Signal<boolean>>();\n\n /** The largest breakpoint whose minimum width the viewport has reached. */\n readonly active: Signal<AndesBreakpoint> = this.state.asReadonly();\n\n constructor() {\n if (\n inject(PLATFORM_ID) !== 'browser' ||\n typeof window === 'undefined' ||\n typeof window.matchMedia !== 'function'\n ) {\n return;\n }\n\n const queries = ANDES_BREAKPOINT_NAMES.filter((name) => name !== 'xs').map(\n (name) => ({\n name,\n list: window.matchMedia(`(min-width: ${ANDES_BREAKPOINTS[name]}px)`),\n }),\n );\n const update = () => {\n let current: AndesBreakpoint = 'xs';\n for (const { name, list } of queries) {\n if (list.matches) {\n current = name;\n }\n }\n this.state.set(current);\n };\n update();\n\n for (const { list } of queries) {\n list.addEventListener('change', update);\n }\n inject(DestroyRef).onDestroy(() => {\n for (const { list } of queries) {\n list.removeEventListener('change', update);\n }\n });\n }\n\n /**\n * True once the viewport is at least as wide as `name` (`up('md')` is true from 768px).\n * `up('xs')` is always true. Repeated calls with the same name return the same signal.\n */\n up(name: AndesBreakpoint): Signal<boolean> {\n const index = indexOfBreakpoint(name);\n return this.memo(`up:${name}`, () =>\n computed(() => indexOfBreakpoint(this.state()) >= index),\n );\n }\n\n /**\n * True while the viewport is narrower than `name` (`down('lg')` is true below 992px, the\n * usual \"collapse on small screens\" test). `down('xs')` is always false.\n */\n down(name: AndesBreakpoint): Signal<boolean> {\n const index = indexOfBreakpoint(name);\n return this.memo(`down:${name}`, () =>\n computed(() => indexOfBreakpoint(this.state()) < index),\n );\n }\n\n /**\n * True from the start of `from` until the start of `to` (`between('sm', 'lg')` covers 576px\n * up to, but excluding, 992px). A range that is empty or reversed (`from` not below `to`) is\n * never true, rather than being silently swapped.\n */\n between(from: AndesBreakpoint, to: AndesBreakpoint): Signal<boolean> {\n const start = indexOfBreakpoint(from);\n const end = indexOfBreakpoint(to);\n return this.memo(`between:${from}:${to}`, () =>\n computed(() => {\n const current = indexOfBreakpoint(this.state());\n return current >= start && current < end;\n }),\n );\n }\n\n private memo(key: string, create: () => Signal<boolean>): Signal<boolean> {\n let existing = this.comparisons.get(key);\n if (!existing) {\n existing = create();\n this.comparisons.set(key, existing);\n }\n return existing;\n }\n}\n","import { DestroyRef, inject, Injectable, PLATFORM_ID } from '@angular/core';\n\n/** Which box of an element is measured. */\nexport type AndesElementBox = 'content-box' | 'border-box';\n\n/** A measured width and height, in CSS pixels. */\nexport interface AndesElementMeasure {\n readonly width: number;\n readonly height: number;\n}\n\n/** Options for {@link AndesResizeObserver.observe}. */\nexport interface AndesResizeObserveOptions {\n /**\n * The box to measure. `content-box` (default) excludes padding and border, which is what a\n * component laying out its children cares about; `border-box` is the space the element takes\n * in its parent.\n */\n readonly box?: AndesElementBox;\n}\n\ninterface Subscription {\n readonly element: Element;\n readonly callback: (measure: AndesElementMeasure) => void;\n /** Whether the first measurement has already been handed to the callback. */\n delivered: boolean;\n last: AndesElementMeasure | null;\n pending: AndesElementMeasure | null;\n closed: boolean;\n}\n\n/** One native observer and the subscriptions behind it. */\ninterface Channel {\n readonly box: AndesElementBox;\n observer: ResizeObserver | null;\n readonly subscriptions: Map<Element, Set<Subscription>>;\n}\n\nfunction sameMeasure(a: AndesElementMeasure, b: AndesElementMeasure): boolean {\n return a.width === b.width && a.height === b.height;\n}\n\n/**\n * Reads the physical width and height of an observed box. `borderBoxSize` reports logical\n * (inline/block) sizes, so in a vertical writing mode they are swapped back; the content box\n * comes from `contentRect`, which is already physical.\n */\nfunction measureEntry(\n entry: ResizeObserverEntry,\n box: AndesElementBox,\n): AndesElementMeasure {\n if (box === 'border-box') {\n const size = entry.borderBoxSize?.[0];\n if (size) {\n const mode =\n typeof getComputedStyle === 'function'\n ? getComputedStyle(entry.target).writingMode\n : '';\n const vertical =\n typeof mode === 'string' &&\n (mode.startsWith('vertical') || mode.startsWith('sideways'));\n return vertical\n ? { width: size.blockSize, height: size.inlineSize }\n : { width: size.inlineSize, height: size.blockSize };\n }\n const target = entry.target as HTMLElement;\n if (typeof target.offsetWidth === 'number') {\n return { width: target.offsetWidth, height: target.offsetHeight };\n }\n }\n return {\n width: entry.contentRect.width,\n height: entry.contentRect.height,\n };\n}\n\n/**\n * One shared `ResizeObserver` (per measured box) for every element Andes watches, instead of\n * each component creating, guarding and disconnecting its own.\n *\n * Why it is shared: a single observer delivers all changes of a frame together, and the\n * bookkeeping that is easy to get wrong in each component (server guard, missing\n * `ResizeObserver`, disconnect on destroy) lives here once. The native observer is created with\n * the first subscription and disconnected with the last, so an idle page holds none.\n *\n * Why it is coalesced: bursts of changes within a frame (a window being dragged, a loop of\n * layout-triggered resizes) are reduced to the latest measurement per subscription and\n * delivered in one animation frame, so consumers write their state once per frame. The first\n * measurement of a subscription is the exception and is delivered at once, otherwise the first\n * paint would show the unmeasured state for an extra frame.\n *\n * It does nothing on the server or where `ResizeObserver` does not exist.\n */\n@Injectable({ providedIn: 'root' })\nexport class AndesResizeObserver {\n private readonly browser = inject(PLATFORM_ID) === 'browser';\n private readonly channels: Record<AndesElementBox, Channel> = {\n 'content-box': {\n box: 'content-box',\n observer: null,\n subscriptions: new Map(),\n },\n 'border-box': {\n box: 'border-box',\n observer: null,\n subscriptions: new Map(),\n },\n };\n private frame: number | null = null;\n private readonly dirty = new Set<Subscription>();\n\n constructor() {\n inject(DestroyRef).onDestroy(() => {\n for (const channel of Object.values(this.channels)) {\n for (const subscriptions of channel.subscriptions.values()) {\n for (const subscription of subscriptions) {\n subscription.closed = true;\n }\n }\n channel.subscriptions.clear();\n channel.observer?.disconnect();\n channel.observer = null;\n }\n this.cancelFrame();\n this.dirty.clear();\n });\n }\n\n /**\n * Calls `callback` with the element's size now (once the browser reports it) and whenever it\n * changes. Returns the function that stops observing; calling it twice is harmless.\n */\n observe(\n element: Element,\n callback: (measure: AndesElementMeasure) => void,\n options: AndesResizeObserveOptions = {},\n ): () => void {\n if (!this.browser || typeof ResizeObserver === 'undefined') {\n return () => undefined;\n }\n const channel = this.channels[options.box ?? 'content-box'];\n const subscription: Subscription = {\n element,\n callback,\n delivered: false,\n last: null,\n pending: null,\n closed: false,\n };\n\n channel.observer ??= new ResizeObserver((entries) =>\n this.receive(channel, entries),\n );\n let siblings = channel.subscriptions.get(element);\n if (!siblings) {\n siblings = new Set();\n channel.subscriptions.set(element, siblings);\n } else {\n // The browser only reports an element's size when observation starts, so a late\n // subscriber to an already-watched element restarts it to get its first measurement.\n channel.observer.unobserve(element);\n }\n channel.observer.observe(element, { box: channel.box });\n siblings.add(subscription);\n\n return () => this.release(channel, subscription);\n }\n\n private release(channel: Channel, subscription: Subscription): void {\n if (subscription.closed) {\n return;\n }\n subscription.closed = true;\n subscription.pending = null;\n this.dirty.delete(subscription);\n\n const siblings = channel.subscriptions.get(subscription.element);\n siblings?.delete(subscription);\n if (siblings?.size === 0) {\n channel.subscriptions.delete(subscription.element);\n channel.observer?.unobserve(subscription.element);\n }\n if (channel.subscriptions.size === 0 && channel.observer) {\n channel.observer.disconnect();\n channel.observer = null;\n }\n if (this.dirty.size === 0) {\n this.cancelFrame();\n }\n }\n\n private receive(channel: Channel, entries: ResizeObserverEntry[]): void {\n for (const entry of entries) {\n const siblings = channel.subscriptions.get(entry.target);\n if (!siblings) {\n continue;\n }\n const measure = measureEntry(entry, channel.box);\n for (const subscription of siblings) {\n if (subscription.last && sameMeasure(subscription.last, measure)) {\n subscription.pending = null;\n this.dirty.delete(subscription);\n continue;\n }\n if (!subscription.delivered) {\n this.deliver(subscription, measure);\n } else {\n subscription.pending = measure;\n this.dirty.add(subscription);\n }\n }\n }\n if (this.dirty.size > 0) {\n this.scheduleFrame();\n }\n }\n\n private deliver(\n subscription: Subscription,\n measure: AndesElementMeasure,\n ): void {\n subscription.delivered = true;\n subscription.last = measure;\n subscription.pending = null;\n subscription.callback(measure);\n }\n\n private scheduleFrame(): void {\n if (this.frame !== null) {\n return;\n }\n if (typeof requestAnimationFrame !== 'function') {\n this.flush();\n return;\n }\n this.frame = requestAnimationFrame(() => {\n this.frame = null;\n this.flush();\n });\n }\n\n private cancelFrame(): void {\n if (this.frame !== null && typeof cancelAnimationFrame === 'function') {\n cancelAnimationFrame(this.frame);\n }\n this.frame = null;\n }\n\n private flush(): void {\n const batch = [...this.dirty];\n this.dirty.clear();\n for (const subscription of batch) {\n const measure = subscription.pending;\n if (subscription.closed || !measure) {\n continue;\n }\n if (subscription.last && sameMeasure(subscription.last, measure)) {\n subscription.pending = null;\n continue;\n }\n this.deliver(subscription, measure);\n }\n }\n}\n","import {\n assertInInjectionContext,\n computed,\n effect,\n ElementRef,\n inject,\n Injector,\n isSignal,\n PLATFORM_ID,\n signal,\n Signal,\n untracked,\n} from '@angular/core';\n\nimport {\n AndesElementBox,\n AndesElementMeasure,\n AndesResizeObserver,\n} from './resize-observer';\n\n/** What {@link andesElementSize} can watch: an element, its `ElementRef`, or a signal of either. */\nexport type AndesElementSizeTarget =\n | Element\n | ElementRef<Element>\n | Signal<Element | ElementRef<Element> | null | undefined>;\n\n/** Options for {@link andesElementSize}. */\nexport interface AndesElementSizeOptions {\n /**\n * The box to measure. `content-box` (default) is the room available to the element's\n * children; `border-box` is the space the element occupies in its parent.\n */\n readonly box?: AndesElementBox;\n /**\n * The size reported before the first measurement and on the server, where nothing can be\n * measured. Defaults to `0 x 0`. Use `measured` to tell a real zero from \"not measured yet\".\n */\n readonly initial?: AndesElementMeasure;\n /** The injector that owns the observation. Only needed outside an injection context. */\n readonly injector?: Injector;\n}\n\n/** The signals returned by {@link andesElementSize}. */\nexport interface AndesElementSizeRef {\n /** The element's width in CSS pixels. */\n readonly width: Signal<number>;\n /** The element's height in CSS pixels. */\n readonly height: Signal<number>;\n /** Width and height together, for reading both without two dependencies. */\n readonly size: Signal<AndesElementMeasure>;\n /**\n * False until the browser has reported a size for the current element, and again whenever the\n * element goes away or is swapped. Lets callers keep a server-rendered layout rather than\n * collapse to the `initial` size.\n */\n readonly measured: Signal<boolean>;\n}\n\nconst EMPTY: AndesElementMeasure = { width: 0, height: 0 };\n\nfunction resolveElement(\n value: Element | ElementRef<Element> | null | undefined,\n): Element | null {\n const element = value instanceof ElementRef ? value.nativeElement : value;\n return element && (element as Node).nodeType === 1 ? element : null;\n}\n\n/**\n * Tracks an element's size as signals. Replaces a hand-written `ResizeObserver` plus its\n * server guard and teardown.\n *\n * Observation starts when the element exists and stops when it goes away, is swapped for\n * another, or the owning injector is destroyed, so a signal target such as a `viewChild` can\n * come and go freely. All elements share one native observer and updates are coalesced to one\n * per animation frame (see `AndesResizeObserver`). On the server and where `ResizeObserver` is\n * missing nothing is observed and the signals keep `initial`.\n *\n * Must be called in an injection context unless `options.injector` is given.\n */\nexport function andesElementSize(\n target: AndesElementSizeTarget,\n options: AndesElementSizeOptions = {},\n): AndesElementSizeRef {\n if (!options.injector) {\n assertInInjectionContext(andesElementSize);\n }\n const injector = options.injector ?? inject(Injector);\n const initial = options.initial ?? EMPTY;\n const state = signal<AndesElementMeasure>(initial, {\n equal: (a, b) => a.width === b.width && a.height === b.height,\n });\n const measured = signal(false);\n const ref: AndesElementSizeRef = {\n width: computed(() => state().width),\n height: computed(() => state().height),\n size: state.asReadonly(),\n measured: measured.asReadonly(),\n };\n\n if (injector.get(PLATFORM_ID) !== 'browser') {\n return ref;\n }\n\n const observer = injector.get(AndesResizeObserver);\n const element = computed(() =>\n resolveElement(isSignal(target) ? target() : target),\n );\n\n effect(\n (onCleanup) => {\n const current = element();\n untracked(() => {\n state.set(initial);\n measured.set(false);\n });\n if (!current) {\n return;\n }\n const stop = observer.observe(\n current,\n (measure) => {\n state.set(measure);\n measured.set(true);\n },\n { box: options.box },\n );\n onCleanup(stop);\n },\n { injector },\n );\n\n return ref;\n}\n","import {\n assertInInjectionContext,\n computed,\n inject,\n Injector,\n isSignal,\n Signal,\n} from '@angular/core';\n\nimport {\n andesElementSize,\n AndesElementSizeOptions,\n AndesElementSizeTarget,\n} from './element-size';\n\n/** Options for {@link andesContainerBreakpoint}. */\nexport interface AndesContainerBreakpointOptions<K extends string> extends Pick<\n AndesElementSizeOptions,\n 'box' | 'injector'\n> {\n /**\n * The bucket reported before the element is measured and on the server. Defaults to the\n * smallest bucket, the safe choice for a \"collapse when narrow\" layout that is then expanded\n * once the real width is known.\n */\n readonly initial?: NoInfer<K>;\n}\n\n/**\n * The bucket whose minimum width is the largest one that `width` still reaches, or the\n * smallest bucket when `width` is below all of them. Throws on an empty map.\n */\nfunction bucketFor<K extends string>(\n buckets: Readonly<Record<K, number>>,\n width: number,\n): K {\n const entries = Object.entries(buckets) as [K, number][];\n if (entries.length === 0) {\n throw new Error('andesContainerBreakpoint needs at least one bucket.');\n }\n let smallest = entries[0];\n let best: [K, number] | null = null;\n for (const entry of entries) {\n if (entry[1] < smallest[1]) {\n smallest = entry;\n }\n if (width >= entry[1] && (best === null || entry[1] > best[1])) {\n best = entry;\n }\n }\n return (best ?? smallest)[0];\n}\n\n/**\n * The container-width bucket an element currently falls in, for components that adapt to the\n * room they are given rather than to the viewport (collapsing pagination, a grid row inside a\n * narrow sidebar).\n *\n * `buckets` maps a name to the minimum width at which it starts, mobile-first like the viewport\n * breakpoints, so `ANDES_BREAKPOINTS` works as is and `{ compact: 0, full: 480 }` is a\n * two-state switch. The signal changes only when the element crosses a threshold, not on every\n * pixel, so effects and templates reading it stay quiet while the element resizes inside a\n * bucket. Pass a signal for `buckets` when the thresholds come from inputs.\n *\n * Must be called in an injection context unless `options.injector` is given.\n */\nexport function andesContainerBreakpoint<K extends string>(\n element: AndesElementSizeTarget,\n buckets: Readonly<Record<K, number>> | Signal<Readonly<Record<K, number>>>,\n options: AndesContainerBreakpointOptions<K> = {},\n): Signal<K> {\n if (!options.injector) {\n assertInInjectionContext(andesContainerBreakpoint);\n }\n const injector = options.injector ?? inject(Injector);\n const sizing = andesElementSize(element, {\n box: options.box,\n injector,\n });\n const resolve = (): Readonly<Record<K, number>> =>\n isSignal(buckets) ? buckets() : buckets;\n\n return computed(() => {\n const current = resolve();\n if (!sizing.measured()) {\n return options.initial ?? bucketFor(current, -Infinity);\n }\n return bucketFor(current, sizing.width());\n });\n}\n","import {\n assertInInjectionContext,\n effect,\n inject,\n Injector,\n isSignal,\n PLATFORM_ID,\n signal,\n Signal,\n} from '@angular/core';\n\n/** Options for {@link andesMediaQuery} and the ready-made preference signals. */\nexport interface AndesMediaQueryOptions {\n /**\n * The value reported where the query cannot be evaluated: server rendering, or a browser\n * without `matchMedia`. It is also what the signal holds until the first evaluation. Defaults\n * to `false`, i.e. \"the condition does not hold\", which for preference queries means the\n * default experience.\n */\n readonly ssrDefault?: boolean;\n /**\n * The injector that owns the listener. Only needed when calling outside an injection context;\n * the listener is removed when this injector is destroyed.\n */\n readonly injector?: Injector;\n}\n\n/** `window.matchMedia`, or `null` where there is no browser window to ask. */\nfunction matchMediaFor(\n platformId: unknown,\n): ((query: string) => MediaQueryList) | null {\n if (\n platformId !== 'browser' ||\n typeof window === 'undefined' ||\n typeof window.matchMedia !== 'function'\n ) {\n return null;\n }\n return (query) => window.matchMedia(query);\n}\n\n/**\n * Whether a CSS media query currently matches, as a signal that stays in sync.\n *\n * The first value is read synchronously, so the first render already uses the right answer\n * instead of flashing the default. After that one `change` listener keeps it current; it is\n * removed when the query changes (a `Signal` query) and when the owning injector is destroyed.\n * Where `matchMedia` is unavailable the signal holds `ssrDefault` and nothing is registered.\n *\n * Must be called in an injection context unless `options.injector` is given.\n *\n * @param query A media query string, or a signal of one for queries that depend on an input.\n */\nexport function andesMediaQuery(\n query: string | Signal<string>,\n options: AndesMediaQueryOptions = {},\n): Signal<boolean> {\n if (!options.injector) {\n assertInInjectionContext(andesMediaQuery);\n }\n const injector = options.injector ?? inject(Injector);\n const ssrDefault = options.ssrDefault ?? false;\n const matchMedia = matchMediaFor(injector.get(PLATFORM_ID));\n const read = isSignal(query) ? query : () => query;\n\n const matches = signal(matchMedia ? matchMedia(read()).matches : ssrDefault);\n if (!matchMedia) {\n return matches.asReadonly();\n }\n\n effect(\n (onCleanup) => {\n const list = matchMedia(read());\n matches.set(list.matches);\n const listener = (event: MediaQueryListEvent) =>\n matches.set(event.matches);\n list.addEventListener('change', listener);\n onCleanup(() => list.removeEventListener('change', listener));\n },\n { injector },\n );\n\n return matches.asReadonly();\n}\n\n/**\n * Whether the user asked the system to reduce motion. Components consult it before running\n * non-essential animation or smooth scrolling.\n */\nexport function andesPrefersReducedMotion(\n options?: AndesMediaQueryOptions,\n): Signal<boolean> {\n return andesMediaQuery('(prefers-reduced-motion: reduce)', options);\n}\n\n/** Whether the system is set to a dark color scheme. */\nexport function andesPrefersDark(\n options?: AndesMediaQueryOptions,\n): Signal<boolean> {\n return andesMediaQuery('(prefers-color-scheme: dark)', options);\n}\n\n/** Whether the user asked for higher contrast than the default. */\nexport function andesPrefersContrast(\n options?: AndesMediaQueryOptions,\n): Signal<boolean> {\n return andesMediaQuery('(prefers-contrast: more)', options);\n}\n","import {\n computed,\n effect,\n inject,\n Injector,\n Signal,\n signal,\n untracked,\n} from '@angular/core';\nimport { NgControl, ValidationErrors } from '@angular/forms';\nimport { Observable } from 'rxjs';\n\n/**\n * The validation state of the Angular forms control bound to a component's host element,\n * exposed as signals so a template or `computed()` can react to it without subscribing to\n * anything.\n *\n * Every signal reads `false` / `null` while nothing is bound, so a component used outside a\n * form behaves exactly as if the control were valid and untouched.\n */\nexport interface AndesControlStatus {\n /** Whether a forms directive is bound to the host and has produced its control. */\n readonly bound: Signal<boolean>;\n /** The bound control failed validation. */\n readonly invalid: Signal<boolean>;\n /** The bound control passed validation (and has no async validator still running). */\n readonly valid: Signal<boolean>;\n /** The user has left the bound control at least once. */\n readonly touched: Signal<boolean>;\n /** The value of the bound control was changed from the UI. */\n readonly dirty: Signal<boolean>;\n /** An async validator is still running. */\n readonly pending: Signal<boolean>;\n /** The bound control is disabled on the forms side. */\n readonly disabled: Signal<boolean>;\n /** The bound control's current errors, or `null` when it has none. */\n readonly errors: Signal<ValidationErrors | null>;\n /**\n * `invalid` once the user has interacted (`touched` or `dirty`). This is the usual \"do not\n * shout at someone who has not typed yet\" rule, so a component can paint its error state\n * from it directly instead of the page wiring `aria-invalid` by hand.\n */\n readonly showError: Signal<boolean>;\n}\n\n/** What `injectAndesControlStatus` accepts. */\nexport interface AndesControlStatusOptions {\n /**\n * A signal that changes whenever the forms directive (re)registers this component as its\n * value accessor. Re-binding a `[formControl]` to a different control registers the accessor\n * again, and that is the only moment the status has a reason to re-subscribe, because\n * Angular offers no event for \"this directive now points at another control\".\n * `AndesValueAccessor` already supplies it.\n */\n readonly rebindOn?: Signal<unknown>;\n}\n\n/**\n * The `events` stream reactive forms put on every `AbstractControl`. Signal forms hand out a\n * stand-in control with no such stream, because its getters are already signals.\n */\ninterface ControlWithEvents {\n readonly events?: Observable<unknown>;\n}\n\n/**\n * Reads the status of the Angular forms control sitting on the same element as the calling\n * component or directive. Works unchanged with `formControl`, `formControlName`, `ngModel`\n * and signal forms' `[formField]`.\n *\n * Must run in an injection context (a field initializer or constructor).\n *\n * The `NgControl` is looked up lazily, from an effect, and never from the constructor. A\n * component that provides `NG_VALUE_ACCESSOR` cannot `inject(NgControl)` while it is being\n * constructed: the forms directive injects the accessor to build itself, so the two wait on\n * each other and Angular reports a circular dependency. By the time the first change\n * detection pass runs, both exist and the lookup is plain. The cost is that status reads\n * before that pass see the \"unbound\" defaults.\n *\n * ```ts\n * @Component({ ... })\n * class AndesTextbox {\n * private readonly status = injectAndesControlStatus();\n * protected readonly invalid = computed(() => this.status.showError());\n * }\n * ```\n */\nexport function injectAndesControlStatus(\n options: AndesControlStatusOptions = {},\n): AndesControlStatus {\n const injector = inject(Injector);\n const ngControl = signal<NgControl | null>(null);\n // Bumped on every control event so that the plain-property reads below are re-evaluated.\n const tick = signal(0);\n\n effect((onCleanup) => {\n options.rebindOn?.();\n untracked(() => {\n const found = injector.get(NgControl, null, {\n self: true,\n optional: true,\n });\n ngControl.set(found);\n const events = (found?.control as ControlWithEvents | null | undefined)\n ?.events;\n if (events) {\n const subscription = events.subscribe(() =>\n tick.update((count) => count + 1),\n );\n onCleanup(() => subscription.unsubscribe());\n }\n // The control may have been created between the last event and now.\n tick.update((count) => count + 1);\n });\n });\n\n /**\n * Reads one property off the bound `NgControl`. `tick` covers reactive forms (plain\n * properties), while the getters of signal forms' stand-in control read signals themselves\n * and so are tracked by the surrounding `computed`.\n */\n const read = <V>(pick: (control: NgControl) => V, fallback: V): Signal<V> =>\n computed(() => {\n tick();\n const control = ngControl();\n return control?.control ? pick(control) : fallback;\n });\n\n const invalid = read((control) => control.invalid === true, false);\n const touched = read((control) => control.touched === true, false);\n const dirty = read((control) => control.dirty === true, false);\n const pending = read((control) => control.pending === true, false);\n\n return {\n bound: read(() => true, false),\n invalid,\n valid: read((control) => control.valid === true, false),\n touched,\n dirty,\n pending,\n disabled: read((control) => control.disabled === true, false),\n errors: read((control) => control.errors ?? null, null),\n showError: computed(() => invalid() && (touched() || dirty())),\n };\n}\n","import {\n computed,\n DestroyRef,\n inject,\n signal,\n Signal,\n untracked,\n WritableSignal,\n} from '@angular/core';\nimport { ControlValueAccessor } from '@angular/forms';\n\nimport { AndesControlStatus, injectAndesControlStatus } from './control-status';\n\n/** What `AndesValueAccessor` needs to know about the component it serves. */\nexport interface AndesValueAccessorOptions<T> {\n /**\n * The signal that holds the control's value: usually the component's `model()`, but any\n * writable signal works, including a `linkedSignal`. The accessor writes to it for both\n * user commits and form writes, so there is one source of truth to render from.\n */\n readonly value: WritableSignal<T>;\n /**\n * The component's own `disabled` input. It is merged with the disabled state Angular forms\n * pushes in, so either side can disable the control, as with a native `<fieldset>`.\n */\n readonly disabled?: Signal<boolean>;\n /**\n * Decides whether a commit actually changes the value. A commit that does not is dropped,\n * so re-picking the selected option never marks the control dirty. Defaults to `Object.is`;\n * array and object values need their own comparison (see {@link andesShallowArrayEquals}).\n */\n readonly equals?: (previous: T, next: T) => boolean;\n /**\n * What a form's `null` / `undefined` (a `reset()`, an unset model) means for this control,\n * for example `''` for text or `[]` for a multi-select. Treated as immutable. Ignored when\n * `coerce` is given.\n */\n readonly emptyValue?: T;\n /**\n * Turns whatever a form writes into a value of type `T`, e.g. `String(value)` or clamping a\n * number. Takes precedence over `emptyValue`.\n */\n readonly coerce?: (raw: unknown) => T;\n /**\n * Runs after a form wrote a value, for state derived from it that is not itself the value:\n * the text shown in a field, a discarded draft. It runs on writes only, never on commits,\n * and nothing it does is reported back to the form.\n */\n readonly onWrite?: (value: T) => void;\n /** Runs each time the control is marked touched, so a component can surface it as an output. */\n readonly onTouch?: () => void;\n}\n\n/** A no-op that stands in for the callbacks Angular forms registers later. */\nfunction noop(): void {\n // Intentionally empty: a component outside any form has nobody to notify.\n}\n\n/**\n * Shallow, order-sensitive equality for array values, treating `null` / `undefined` as the\n * empty array. Pass it as `equals` for multi-value controls so that committing an array with\n * the same items does not count as a change.\n */\nexport function andesShallowArrayEquals<T>(\n previous: readonly T[] | null | undefined,\n next: readonly T[] | null | undefined,\n): boolean {\n if (previous === next) {\n return true;\n }\n const a = previous ?? [];\n const b = next ?? [];\n return a.length === b.length && a.every((item, index) => item === b[index]);\n}\n\n/**\n * The `ControlValueAccessor` plumbing every value-holding component re-implements, as one\n * object a component owns rather than inherits. Use it directly when the value signal is not\n * called `value` or the component already extends another class; extend\n * {@link AndesFormControlBase} when it is.\n *\n * It encodes the contract the duplicated code kept getting subtly wrong:\n *\n * - `commit()` sets the signal and tells the form, once, and only if the value changed;\n * - `writeValue()` sets the signal but never tells the form back, so `setValue()` /\n * `reset()` cannot loop;\n * - `disabled` is the component's input OR the form's state, whichever says so;\n * - `markTouched()` is forwarded every time, because `updateOn: 'blur'` controls only\n * publish their pending value from that call.\n *\n * Must be created in an injection context. After the component is destroyed it stops\n * notifying the form.\n *\n * ```ts\n * @Component({\n * selector: 'andes-switch',\n * providers: [provideAndesValueAccessor(() => AndesSwitch, (self) => self.accessor)],\n * })\n * class AndesSwitch {\n * readonly checked = model(false);\n * readonly disabled = input(false, { transform: booleanAttribute });\n * readonly accessor = new AndesValueAccessor({\n * value: this.checked,\n * disabled: this.disabled,\n * coerce: Boolean,\n * });\n *\n * protected toggle(): void {\n * this.accessor.commit(!this.checked());\n * }\n * }\n * ```\n */\nexport class AndesValueAccessor<T> implements ControlValueAccessor {\n private readonly options: AndesValueAccessorOptions<T>;\n private onChange: (value: T) => void = noop;\n private onTouched: () => void = noop;\n private destroyed = false;\n\n private readonly disabledByForm = signal(false);\n private readonly registrations = signal(0);\n\n /** The component's value signal, as passed in. */\n readonly value: WritableSignal<T>;\n\n /** The component's own `disabled` input OR'd with the state Angular forms pushed in. */\n readonly disabled: Signal<boolean>;\n\n /** The validation state of the bound forms control; see {@link AndesControlStatus}. */\n readonly status: AndesControlStatus;\n\n constructor(options: AndesValueAccessorOptions<T>) {\n this.options = options;\n this.value = options.value;\n this.disabled = computed(\n () => (options.disabled?.() ?? false) || this.disabledByForm(),\n );\n this.status = injectAndesControlStatus({ rebindOn: this.registrations });\n inject(DestroyRef).onDestroy(() => {\n this.destroyed = true;\n this.onChange = noop;\n this.onTouched = noop;\n });\n }\n\n /**\n * Applies a value chosen by the user: updates the signal and notifies Angular forms,\n * exactly once. Returns `false`, doing nothing, when `value` equals the current one.\n *\n * It does not look at `disabled`: the component decides whether an interaction may happen\n * at all, because only it knows which interactions count (a disabled control may still\n * scroll or expand).\n */\n commit(value: T): boolean {\n const equals = this.options.equals ?? Object.is;\n if (equals(untracked(this.value), value)) {\n return false;\n }\n this.value.set(value);\n this.onChange(value);\n return true;\n }\n\n /**\n * Tells Angular forms the user has left the control. Call it on blur, and when an\n * interaction ends without a blur (a popup closing). Safe to call repeatedly.\n */\n markTouched(): void {\n // A blur fired by the element being removed must not reach an output that is gone.\n if (this.destroyed) {\n return;\n }\n this.onTouched();\n this.options.onTouch?.();\n }\n\n /**\n * Called by Angular forms to put a value into the control. Updates the signal and runs\n * `onWrite`, and never reports back to the form.\n */\n writeValue(raw: unknown): void {\n const { coerce, emptyValue, onWrite } = this.options;\n let next: T;\n if (coerce) {\n next = coerce(raw);\n } else if (raw === null || raw === undefined) {\n next = emptyValue === undefined ? (raw as T) : emptyValue;\n } else {\n next = raw as T;\n }\n this.value.set(next);\n onWrite?.(next);\n }\n\n /** Called by Angular forms to receive value changes made by the user. */\n registerOnChange(fn: (value: T) => void): void {\n this.onChange = this.destroyed ? noop : fn;\n this.registrations.update((count) => count + 1);\n }\n\n /** Called by Angular forms to receive the touched notification. */\n registerOnTouched(fn: () => void): void {\n this.onTouched = this.destroyed ? noop : fn;\n }\n\n /** Called by Angular forms when the bound control is enabled or disabled. */\n setDisabledState(isDisabled: boolean): void {\n this.disabledByForm.set(isDisabled);\n }\n}\n","import {\n booleanAttribute,\n Directive,\n input,\n model,\n output,\n Signal,\n} from '@angular/core';\nimport { ControlValueAccessor } from '@angular/forms';\n\nimport { AndesControlStatus } from './control-status';\nimport { AndesValueAccessor } from './value-accessor';\n\n/**\n * Base class for a component whose state is a single `value` and that should work with every\n * kind of Angular form. It owns the `value` model, the `disabled` input, the\n * `ControlValueAccessor` methods and the status of the bound control, so a subclass only\n * renders the value and calls {@link commit} when the user changes it.\n *\n * ```ts\n * @Component({\n * selector: 'andes-rating',\n * providers: [provideAndesValueAccessor(() => AndesRating)],\n * })\n * class AndesRating extends AndesFormControlBase<number> {\n * protected emptyValue(): number {\n * return 0;\n * }\n * protected pick(stars: number): void {\n * this.commit(stars);\n * }\n * }\n * ```\n *\n * The class also satisfies signal forms' custom-control contract (`value` model, `disabled`\n * input, `touch` output). A subclass that omits `provideAndesValueAccessor` therefore binds\n * to `[formField]` natively and is simply not usable with reactive or template-driven forms;\n * one that provides it works with all of them, signal forms going through the accessor.\n *\n * It declares the `value` and `disabled` members itself, so a component whose value signal\n * has another name (`checked`, `pressed`) uses {@link AndesValueAccessor} directly instead.\n */\n@Directive()\nexport abstract class AndesFormControlBase<T> implements ControlValueAccessor {\n /**\n * The control's value. A `model()`, so `[(value)]` works beside any forms binding and a\n * user's pick and a form's write land in the same signal. Note that this means\n * `valueChange` also fires when a form writes a different value; `commit()` is what tells\n * the form about changes made by the user.\n */\n readonly value = model<T>(this.emptyValue());\n\n /** Disables the control. A disabled state pushed by Angular forms disables it as well. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n /**\n * Fires each time the user leaves the control. It is the touched signal of signal forms'\n * custom-control contract; reactive and template-driven forms are told through their\n * accessor callback instead.\n */\n readonly touch = output<void>();\n\n private readonly accessor: AndesValueAccessor<T>;\n\n /** `disabled` merged with the disabled state of the bound form control. */\n protected readonly isDisabled: Signal<boolean>;\n\n /** The validation state of the bound form control; see {@link AndesControlStatus}. */\n protected readonly status: AndesControlStatus;\n\n constructor() {\n this.accessor = new AndesValueAccessor<T>({\n value: this.value,\n disabled: this.disabled,\n coerce: (raw) => this.coerce(raw),\n equals: (previous, next) => this.equals(previous, next),\n onWrite: (written) => this.onWritten(written),\n onTouch: () => this.touch.emit(),\n });\n this.isDisabled = this.accessor.disabled;\n this.status = this.accessor.status;\n }\n\n /**\n * What the control holds before a form writes anything, and what a form's `null` /\n * `undefined` (a `reset()`) means: `''` for text, `[]` for a multi-select. A method rather\n * than a constant so that every control gets its own array or object. It runs while the\n * base class is being constructed, so it must not read the subclass's own fields.\n */\n protected abstract emptyValue(): T;\n\n /**\n * Applies a value chosen by the user and notifies Angular forms exactly once. Does nothing,\n * and returns `false`, when {@link equals} says nothing changed.\n */\n protected commit(value: T): boolean {\n return this.accessor.commit(value);\n }\n\n /** Reports that the user left the control. Call it on blur. */\n protected markTouched(): void {\n this.accessor.markTouched();\n }\n\n /**\n * Turns what a form writes into a `T`. By default `null` / `undefined` become the empty\n * value and everything else passes through unchanged. Override\n * it to normalize (`String(raw)`, clamping) or to make the empty value depend on inputs.\n */\n protected coerce(raw: unknown): T {\n return raw === null || raw === undefined ? this.emptyValue() : (raw as T);\n }\n\n /**\n * Whether two values are the same for the purpose of {@link commit}. `Object.is` by\n * default; override it for array and object values.\n */\n protected equals(previous: T, next: T): boolean {\n return Object.is(previous, next);\n }\n\n /**\n * Called after a form wrote a value, to refresh state derived from it. Never reported back\n * to the form.\n */\n protected onWritten(value: T): void {\n void value;\n }\n\n /** Called by Angular forms to write a value into the control; never echoes back. */\n writeValue(raw: unknown): void {\n this.accessor.writeValue(raw);\n }\n\n /** Called by Angular forms to receive value changes made by the user. */\n registerOnChange(fn: (value: T) => void): void {\n this.accessor.registerOnChange(fn);\n }\n\n /** Called by Angular forms to receive the touched notification. */\n registerOnTouched(fn: () => void): void {\n this.accessor.registerOnTouched(fn);\n }\n\n /** Called by Angular forms when the bound control is enabled or disabled. */\n setDisabledState(isDisabled: boolean): void {\n this.accessor.setDisabledState(isDisabled);\n }\n}\n","import { forwardRef, inject, Provider, Type } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\n\n/**\n * Registers a component as the `ControlValueAccessor` of the forms directive on its element,\n * replacing the `{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(...), multi: true }`\n * block each component repeated. The component is passed as a thunk so the class can be\n * referenced from its own decorator, which is what the `forwardRef` was for.\n *\n * With only the component, the component itself must implement `ControlValueAccessor`\n * (extending `AndesFormControlBase` does). Pass `select` to register a different object, such\n * as an `AndesValueAccessor` the component owns, so the component's public API does not grow\n * `writeValue` and friends.\n *\n * Because a value accessor is registered, signal forms' `[formField]` binds through it too,\n * so one provider covers `formControl`, `formControlName`, `ngModel` and `[formField]`.\n *\n * ```ts\n * @Component({\n * selector: 'andes-rating',\n * providers: [provideAndesValueAccessor(() => AndesRating)],\n * })\n * class AndesRating extends AndesFormControlBase<number> { ... }\n * ```\n */\nexport function provideAndesValueAccessor<C extends ControlValueAccessor>(\n component: () => Type<C>,\n): Provider;\nexport function provideAndesValueAccessor<C>(\n component: () => Type<C>,\n select: (instance: C) => ControlValueAccessor,\n): Provider;\nexport function provideAndesValueAccessor<C>(\n component: () => Type<C>,\n select?: (instance: C) => ControlValueAccessor,\n): Provider {\n if (!select) {\n return {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(component),\n multi: true,\n };\n }\n return {\n provide: NG_VALUE_ACCESSOR,\n useFactory: () => select(inject(component())),\n multi: true,\n };\n}\n","import { computed, isSignal, signal, Signal, untracked } from '@angular/core';\n\nimport type {\n AndesCheckedStrategy,\n AndesCheckedTreeConfig,\n AndesCheckState,\n AndesSelectionChange,\n AndesSelectionChangeSource,\n AndesSelectionState,\n} from './selection-model-types';\n\n/**\n * A tree flattened into parallel arrays in depth-first pre-order. Pre-order means a node's index\n * is always greater than its parent's, so walking the arrays forwards visits parents first and\n * backwards visits children first — both propagation directions become one linear pass, with no\n * recursion and no sorting.\n */\ninterface TreeIndex<T, K> {\n readonly keys: readonly K[];\n readonly nodes: readonly T[];\n /** Index of each node's parent, or -1 for a root. */\n readonly parents: Int32Array;\n readonly children: readonly (readonly number[])[];\n readonly byKey: ReadonlyMap<K, number>;\n}\n\ninterface CheckFlags {\n readonly checked: Uint8Array;\n readonly half: Uint8Array;\n}\n\nfunction identity<T>(value: T): unknown {\n return value;\n}\n\nfunction buildIndex<T, K>(\n roots: readonly T[],\n childrenOf: (node: T) => readonly T[] | null | undefined,\n keyOf: (node: T) => K,\n): TreeIndex<T, K> {\n const keys: K[] = [];\n const nodes: T[] = [];\n const parentList: number[] = [];\n const children: number[][] = [];\n const byKey = new Map<K, number>();\n\n // An explicit stack instead of recursion: a degenerate chain of thousands of nodes must not\n // overflow the call stack. Children are pushed in reverse so they pop in source order.\n const stack: { node: T; parent: number }[] = [];\n for (let i = roots.length - 1; i >= 0; i--) {\n stack.push({ node: roots[i], parent: -1 });\n }\n for (let entry = stack.pop(); entry; entry = stack.pop()) {\n const key = keyOf(entry.node);\n if (byKey.has(key)) {\n continue;\n }\n const index = keys.length;\n byKey.set(key, index);\n keys.push(key);\n nodes.push(entry.node);\n parentList.push(entry.parent);\n children.push([]);\n if (entry.parent >= 0) {\n children[entry.parent].push(index);\n }\n const kids = childrenOf(entry.node);\n if (kids) {\n for (let i = kids.length - 1; i >= 0; i--) {\n stack.push({ node: kids[i], parent: index });\n }\n }\n }\n\n return {\n keys,\n nodes,\n parents: Int32Array.from(parentList),\n children,\n byKey,\n };\n}\n\n/**\n * Turns the nodes a caller considers checked (`seed`) into the full state.\n *\n * Strict mode returns the seed untouched. Otherwise: a checked node checks all its unlocked\n * descendants (stopping at a locked node, whose subtree is cut off), then every unlocked parent\n * with at least one unlocked child is recomputed bottom-up — checked when all its unlocked\n * children are, mixed when only some are touched, unchecked otherwise. A parent whose children\n * are all locked has nothing to aggregate and keeps its seed. Locked nodes keep their seed.\n */\nfunction conduct<T, K>(\n index: TreeIndex<T, K>,\n locked: Uint8Array,\n seed: Uint8Array,\n strict: boolean,\n): CheckFlags {\n const size = index.keys.length;\n const checked = seed.slice();\n const half = new Uint8Array(size);\n if (strict) {\n return { checked, half };\n }\n\n for (let i = 0; i < size; i++) {\n const parent = index.parents[i];\n if (\n parent >= 0 &&\n !checked[i] &&\n !locked[i] &&\n !locked[parent] &&\n checked[parent]\n ) {\n checked[i] = 1;\n }\n }\n\n for (let i = size - 1; i >= 0; i--) {\n const kids = index.children[i];\n if (locked[i] || kids.length === 0) {\n continue;\n }\n let considered = 0;\n let all = true;\n let some = false;\n for (const child of kids) {\n if (locked[child]) {\n continue;\n }\n considered++;\n if (checked[child]) {\n some = true;\n } else {\n all = false;\n if (half[child]) {\n some = true;\n }\n }\n }\n if (considered === 0) {\n continue;\n }\n checked[i] = all ? 1 : 0;\n half[i] = !all && some ? 1 : 0;\n }\n return { checked, half };\n}\n\n/**\n * Check state for a hierarchy — a tree, a cascader with multiple values, or a table whose rows\n * have child rows — with parent/child propagation.\n *\n * Checking a node checks everything below it; a parent is checked once all its children are and\n * is `mixed` (half-checked) while only some are. The `strict` option turns propagation off so\n * every node is independent. Locked nodes (`isDisabled`) are islands: they keep their state and\n * neither receive nor pass on a cascade, so a parent aggregates only its unlocked children and\n * a partially locked parent can still be checked by its available children alone.\n *\n * The model stores keys, not nodes, because a checked value usually arrives from a form or a\n * lazy-loading source before (or without) the node being present. Keys that match no node are\n * kept and reported by `checkedKeys` until {@link prune} removes them, so a source list that\n * is temporarily empty or paged does not erase the value. The index is rebuilt once per\n * `nodes` change and every update is a single linear pass, which keeps a few thousand nodes\n * instantaneous.\n *\n * ```ts\n * readonly tree = new AndesCheckedTree<Folder, string>({\n * nodes: this.folders, // a signal\n * childrenOf: (folder) => folder.children,\n * keyOf: (folder) => folder.id,\n * strict: this.checkStrictly, // a signal input\n * onChange: (change) => this.checkedChange.emit(change),\n * });\n * // template: [checked]=\"tree.stateOf(id) === 'checked'\" [indeterminate]=\"tree.stateOf(id) === 'mixed'\"\n * ```\n */\nexport class AndesCheckedTree<T, K = T> {\n private readonly nodesSource: () => readonly T[];\n private readonly childrenOf: (node: T) => readonly T[] | null | undefined;\n private readonly keyOf: (node: T) => K;\n private readonly disabledPredicate: ((node: T) => boolean) | undefined;\n private readonly onChange:\n ((change: AndesSelectionChange<K>) => void) | undefined;\n\n private readonly raw = signal<readonly K[]>([]);\n private readonly lastChange = signal<AndesSelectionChange<K> | null>(null);\n\n private readonly index: Signal<TreeIndex<T, K>>;\n private readonly locked: Signal<Uint8Array>;\n private readonly flags: Signal<CheckFlags>;\n private readonly unknownKeys: Signal<readonly K[]>;\n\n /** Whether propagation is off. */\n readonly strict: Signal<boolean>;\n\n /** Every checked node's key, parents included, in tree order. */\n readonly checked: Signal<ReadonlySet<K>>;\n\n /** Keys of parents with some, but not all, unlocked children checked. Always empty when strict. */\n readonly halfChecked: Signal<ReadonlySet<K>>;\n\n /**\n * The checked value: {@link checked} in tree order, followed by keys that match no node\n * (kept until {@link prune}). This is what a form control or two-way binding holds.\n */\n readonly checkedKeys: Signal<readonly K[]>;\n\n /**\n * Summary over every unlocked node: `all` when each is checked, `none` when none is, `some`\n * otherwise. Drives a tree-wide \"select all\" checkbox.\n */\n readonly overallState: Signal<AndesSelectionState>;\n\n /** The most recent change, or `null`. A fresh object per change; see `AndesSelectionModel.changes`. */\n readonly changes: Signal<AndesSelectionChange<K> | null>;\n\n constructor(config: AndesCheckedTreeConfig<T, K>) {\n const nodes = config.nodes;\n this.nodesSource = typeof nodes === 'function' ? nodes : () => nodes;\n this.childrenOf = config.childrenOf;\n this.keyOf = config.keyOf ?? (identity as (node: T) => K);\n this.disabledPredicate = config.isDisabled;\n this.onChange = config.onChange;\n\n const strictSource = config.strict ?? false;\n this.strict = isSignal(strictSource)\n ? strictSource\n : signal(strictSource).asReadonly();\n\n this.index = computed(() =>\n buildIndex(this.nodesSource(), this.childrenOf, this.keyOf),\n );\n this.locked = computed(() => {\n const { nodes: list } = this.index();\n const result = new Uint8Array(list.length);\n const isDisabled = this.disabledPredicate;\n if (isDisabled) {\n list.forEach((node, i) => {\n result[i] = isDisabled(node) ? 1 : 0;\n });\n }\n return result;\n });\n this.flags = computed(() => {\n const index = this.index();\n const seed = new Uint8Array(index.keys.length);\n for (const key of this.raw()) {\n const position = index.byKey.get(key);\n if (position !== undefined) {\n seed[position] = 1;\n }\n }\n return conduct(index, this.locked(), seed, this.strict());\n });\n this.unknownKeys = computed(() => {\n const { byKey } = this.index();\n return this.raw().filter((key) => !byKey.has(key));\n });\n\n this.checked = computed(() => this.keysWhere(this.flags().checked));\n this.halfChecked = computed(() => this.keysWhere(this.flags().half));\n this.checkedKeys = computed(() => [\n ...this.checked(),\n ...this.unknownKeys(),\n ]);\n this.overallState = computed(() => {\n const locked = this.locked();\n const { checked } = this.flags();\n let considered = 0;\n let chosen = 0;\n for (let i = 0; i < checked.length; i++) {\n if (!locked[i]) {\n considered++;\n chosen += checked[i];\n }\n }\n if (chosen === 0) {\n return 'none';\n }\n return chosen === considered ? 'all' : 'some';\n });\n this.changes = this.lastChange.asReadonly();\n\n if (config.initial) {\n this.raw.set([...new Set(config.initial)]);\n }\n }\n\n /** Whether the tree has a node with this key. */\n has(key: K): boolean {\n return this.index().byKey.has(key);\n }\n\n /** The key of a node's parent, or `undefined` for roots and unknown keys. */\n parentKeyOf(key: K): K | undefined {\n const index = this.index();\n const position = index.byKey.get(key);\n const parent = position === undefined ? -1 : index.parents[position];\n return parent >= 0 ? index.keys[parent] : undefined;\n }\n\n /** The keys of a node's children, in source order; empty for leaves and unknown keys. */\n childKeysOf(key: K): readonly K[] {\n const index = this.index();\n const position = index.byKey.get(key);\n return position === undefined\n ? []\n : index.children[position].map((child) => index.keys[child]);\n }\n\n /** Whether the node is locked by `isDisabled`. Unknown keys are not locked. */\n isDisabled(key: K): boolean {\n const position = this.index().byKey.get(key);\n return position !== undefined && this.locked()[position] === 1;\n }\n\n /** Whether the node is fully checked. */\n isChecked(key: K): boolean {\n return this.stateOf(key) === 'checked';\n }\n\n /** Whether the node is a parent with only some of its children checked. */\n isHalfChecked(key: K): boolean {\n return this.stateOf(key) === 'mixed';\n }\n\n /** The node's state, shaped for `aria-checked`. Unknown keys are `unchecked`. */\n stateOf(key: K): AndesCheckState {\n const position = this.index().byKey.get(key);\n if (position === undefined) {\n return 'unchecked';\n }\n const { checked, half } = this.flags();\n if (checked[position]) {\n return 'checked';\n }\n return half[position] ? 'mixed' : 'unchecked';\n }\n\n /**\n * The checked keys narrowed to what a consumer wants reported: `all` (the default), `parent`\n * (a checked folder stands for its subtree) or `child` (leaves only). Strict mode has no\n * hierarchy to collapse, so it always reports everything. Keys with no node are appended\n * unchanged in every strategy because they cannot be classified.\n */\n checkedKeysByStrategy(strategy: AndesCheckedStrategy): readonly K[] {\n if (strategy === 'all' || this.strict()) {\n return this.checkedKeys();\n }\n const index = this.index();\n const { checked } = this.flags();\n const keys: K[] = [];\n for (let i = 0; i < index.keys.length; i++) {\n if (!checked[i]) {\n continue;\n }\n const parent = index.parents[i];\n const include =\n strategy === 'parent'\n ? parent < 0 || !checked[parent]\n : index.children[i].length === 0;\n if (include) {\n keys.push(index.keys[i]);\n }\n }\n return [...keys, ...this.unknownKeys()];\n }\n\n /**\n * Checks a node (and, unless strict, everything below it). Does nothing for an unknown key,\n * a locked node, or a node that is already checked.\n *\n * @returns whether the checked value changed.\n */\n check(key: K): boolean {\n return untracked(() => this.setNode(key, true));\n }\n\n /**\n * Unchecks a node, everything reachable below it and, unless strict, the ancestors that were\n * checked only because this node was — which then become `mixed` if siblings stay checked.\n * A `mixed` parent is unchecked too. Does nothing for an unknown or locked key, or a node\n * with nothing checked in it.\n *\n * @returns whether the checked value changed.\n */\n uncheck(key: K): boolean {\n return untracked(() => this.setNode(key, false));\n }\n\n /**\n * Flips a node: a `checked` node is unchecked; `unchecked` and `mixed` ones are checked, which\n * is what completes a half-checked parent on click.\n *\n * @returns whether the checked value changed.\n */\n toggle(key: K): boolean {\n return untracked(() => {\n const position = this.index().byKey.get(key);\n if (position === undefined) {\n return false;\n }\n return this.setNode(key, !this.flags().checked[position]);\n });\n }\n\n /**\n * Checks every unlocked node. Locked nodes keep their state.\n *\n * @returns whether the checked value changed.\n */\n checkAll(): boolean {\n return untracked(() => {\n const locked = this.locked();\n const seed = this.flags().checked.slice();\n for (let i = 0; i < seed.length; i++) {\n if (!locked[i]) {\n seed[i] = 1;\n }\n }\n return this.commit(seed, this.unknownKeys(), 'interaction');\n });\n }\n\n /**\n * Unchecks every unlocked node and forgets keys that match no node; a locked checked node\n * stays checked, since the user cannot change it.\n *\n * @returns whether the checked value changed.\n */\n clear(): boolean {\n return untracked(() => {\n const locked = this.locked();\n const seed = this.flags().checked.slice();\n for (let i = 0; i < seed.length; i++) {\n if (!locked[i]) {\n seed[i] = 0;\n }\n }\n return this.commit(seed, [], 'interaction');\n });\n }\n\n /**\n * Replaces the checked value, as a form or a two-way binding writes it in. The keys are taken\n * as the seed: unless strict, a listed parent checks its whole subtree and a parent whose\n * children are all listed becomes checked. Locking is ignored. Keys with no node are kept.\n *\n * Reports `source: 'programmatic'`.\n *\n * @returns whether the checked value changed.\n */\n setChecked(keys: readonly K[]): boolean {\n return untracked(() => {\n const { byKey } = this.index();\n const seed = new Uint8Array(byKey.size);\n const unknown = new Set<K>();\n for (const key of keys) {\n const position = byKey.get(key);\n if (position === undefined) {\n unknown.add(key);\n } else {\n seed[position] = 1;\n }\n }\n return this.commit(seed, [...unknown], 'programmatic');\n });\n }\n\n /**\n * Forgets keys that match no node. Call it after the source list shrinks and the leftover\n * value should not be reported any more. Reports `source: 'programmatic'`.\n *\n * @returns whether any key was dropped.\n */\n prune(): boolean {\n return untracked(() =>\n this.commit(this.flags().checked, [], 'programmatic'),\n );\n }\n\n private keysWhere(flags: Uint8Array): ReadonlySet<K> {\n const { keys } = this.index();\n const result = new Set<K>();\n for (let i = 0; i < keys.length; i++) {\n if (flags[i]) {\n result.add(keys[i]);\n }\n }\n return result;\n }\n\n private setNode(key: K, checked: boolean): boolean {\n const index = this.index();\n const position = index.byKey.get(key);\n const locked = this.locked();\n if (position === undefined || locked[position]) {\n return false;\n }\n const { checked: current, half } = this.flags();\n const already = checked\n ? current[position] === 1\n : current[position] === 0 && half[position] === 0;\n if (already) {\n return false;\n }\n\n const seed = current.slice();\n seed[position] = checked ? 1 : 0;\n if (!checked && !this.strict()) {\n // Clear what a cascade from this node reaches, then the ancestors, so that re-running\n // the cascade does not simply re-check the node from a parent that still says \"checked\".\n const pending = [position];\n for (let at = pending.pop(); at !== undefined; at = pending.pop()) {\n for (const child of index.children[at]) {\n if (!locked[child]) {\n seed[child] = 0;\n pending.push(child);\n }\n }\n }\n for (let p = index.parents[position]; p >= 0; p = index.parents[p]) {\n if (!locked[p]) {\n seed[p] = 0;\n }\n }\n }\n return this.commit(seed, this.unknownKeys(), 'interaction');\n }\n\n /**\n * The single write path: runs propagation on `seed`, stores the normalized keys (so the stored\n * value is always the full checked set, parents included) and publishes `{added, removed}`\n * relative to the previous `checkedKeys`.\n */\n private commit(\n seed: Uint8Array,\n unknown: readonly K[],\n source: AndesSelectionChangeSource,\n ): boolean {\n const index = this.index();\n const { checked } = conduct(index, this.locked(), seed, this.strict());\n const next: K[] = [];\n for (let i = 0; i < index.keys.length; i++) {\n if (checked[i]) {\n next.push(index.keys[i]);\n }\n }\n next.push(...unknown);\n\n const previous = this.checkedKeys();\n const before = new Set(previous);\n const after = new Set(next);\n const added = next.filter((key) => !before.has(key));\n const removed = previous.filter((key) => !after.has(key));\n if (added.length === 0 && removed.length === 0) {\n return false;\n }\n\n this.raw.set(next);\n const change: AndesSelectionChange<K> = { added, removed, source };\n this.lastChange.set(change);\n this.onChange?.(change);\n return true;\n }\n}\n","import { computed, isSignal, signal, Signal, untracked } from '@angular/core';\n\nimport type {\n AndesSelectionChange,\n AndesSelectionChangeSource,\n AndesSelectionMode,\n AndesSelectionModelConfig,\n AndesSelectionState,\n} from './selection-model-types';\n\n/** A growable set of items that answers \"is this one in it\", by key or by comparison. */\ninterface Lookup<T> {\n has(item: T): boolean;\n add(item: T): void;\n}\n\nfunction identity<T>(value: T): unknown {\n return value;\n}\n\n/** `SameValueZero`, the equality `Set` uses, so `keyOf` results compare like they hash. */\nfunction sameKey(a: unknown, b: unknown): boolean {\n return a === b || (a !== a && b !== b);\n}\n\nfunction isSameSequence<T>(a: readonly T[], b: readonly T[]): boolean {\n return a.length === b.length && a.every((item, index) => item === b[index]);\n}\n\n/**\n * A signal-based selection over a list of items: single or multiple, with a maximum, per-item\n * locking, object identity by key, change reporting, shift-click ranges and the tri-state\n * \"select all\" summary.\n *\n * It is plain TypeScript state — no DOM, no injection context — so any component, directive or\n * service can own one. The recurring shapes it replaces are a table's row selection, a\n * checkbox group, a transfer list's two panes, a multi-select's value and a list's selected\n * rows.\n *\n * Every mutating method returns whether the selection actually changed, so a caller can skip\n * emitting an output for a click that was blocked or redundant. Interaction methods\n * (`select`, `deselect`, `toggle`, `clear`, `selectAll`, `deselectAll`, `toggleAll`,\n * `invert`, `selectRange`) honor `isDisabled` and `max`; `setSelection` and `retainOnly` are\n * programmatic and do not.\n *\n * ```ts\n * readonly rows = signal<readonly Row[]>([]);\n * readonly selection = new AndesSelectionModel<Row>({\n * keyOf: (row) => row.id,\n * isDisabled: (row) => row.locked,\n * onChange: (change) => this.selectionChange.emit(change),\n * });\n * readonly headerState = computed(() => this.selection.stateOf(this.rows()));\n *\n * onRowClick(row: Row, event: MouseEvent) {\n * if (event.shiftKey && this.selection.anchor()) {\n * this.selection.selectRange(this.rows(), this.selection.anchor()!, row, !this.selection.isSelected(row));\n * } else {\n * this.selection.toggle(row);\n * }\n * }\n * ```\n */\nexport class AndesSelectionModel<T> {\n private readonly keyOf: ((item: T) => unknown) | undefined;\n private readonly compareWith: ((a: T, b: T) => boolean) | undefined;\n private readonly disabledPredicate: ((item: T) => boolean) | undefined;\n private readonly onChange:\n ((change: AndesSelectionChange<T>) => void) | undefined;\n\n private readonly raw = signal<readonly T[]>([]);\n private readonly lastChange = signal<AndesSelectionChange<T> | null>(null);\n private readonly anchorItem = signal<T | undefined>(undefined);\n\n /** Current mode. */\n readonly mode: Signal<AndesSelectionMode>;\n\n /** The effective limit of `multiple` mode, or `undefined` for none. */\n readonly max: Signal<number | undefined>;\n\n /**\n * The selected items in the order they were selected. Never longer than the mode and `max`\n * allow, even if those were lowered after items were selected: the extra, later items are\n * simply not part of the selection any more.\n */\n readonly selected: Signal<readonly T[]>;\n\n /** Number of selected items. */\n readonly size: Signal<number>;\n\n /** Whether nothing is selected. */\n readonly isEmpty: Signal<boolean>;\n\n /**\n * The most recent change, or `null` before the first one. Each change is a fresh object, so\n * an `effect` reading this runs once per change — including two consecutive changes that\n * add the same item. Unchanged calls never publish.\n */\n readonly changes: Signal<AndesSelectionChange<T> | null>;\n\n /**\n * The item the last interaction targeted — the starting point of a shift-click range.\n * Blocked interactions (a disabled item) leave it alone.\n */\n readonly anchor: Signal<T | undefined>;\n\n private readonly limit: Signal<number>;\n private readonly selectedLookup: Signal<Lookup<T>>;\n\n constructor(config: AndesSelectionModelConfig<T> = {}) {\n this.keyOf = config.keyOf;\n this.compareWith = config.keyOf ? undefined : config.compareWith;\n this.disabledPredicate = config.isDisabled;\n this.onChange = config.onChange;\n\n const modeSource = config.mode ?? 'multiple';\n const maxSource = config.max;\n this.mode = isSignal(modeSource)\n ? modeSource\n : signal<AndesSelectionMode>(modeSource).asReadonly();\n const rawMax = isSignal(maxSource)\n ? maxSource\n : signal<number | undefined>(maxSource).asReadonly();\n this.max = computed(() => {\n const value = rawMax();\n return value === undefined || Number.isNaN(value) || value === Infinity\n ? undefined\n : Math.max(0, Math.floor(value));\n });\n this.limit = computed(() =>\n this.mode() === 'single' ? 1 : (this.max() ?? Infinity),\n );\n\n this.selected = computed(() => {\n const items = this.raw();\n const limit = this.limit();\n return items.length > limit ? items.slice(0, limit) : items;\n });\n this.size = computed(() => this.selected().length);\n this.isEmpty = computed(() => this.size() === 0);\n this.selectedLookup = computed(() => this.createLookup(this.selected()));\n this.changes = this.lastChange.asReadonly();\n this.anchor = this.anchorItem.asReadonly();\n\n if (config.initial) {\n this.raw.set(this.clip(this.dedupe(config.initial)));\n }\n }\n\n /** Whether `item` is selected. Reactive when called from a `computed` or a template. */\n isSelected(item: T): boolean {\n return this.selectedLookup().has(item);\n }\n\n /** Whether `isDisabled` locks `item`. Reactive if the predicate reads signals. */\n isDisabled(item: T): boolean {\n return this.disabledPredicate?.(item) === true;\n }\n\n /**\n * Selects `item`. In `single` mode it replaces the current item, unless that one is locked.\n * In `multiple` mode it is refused once `max` is reached.\n *\n * @returns whether the selection changed.\n */\n select(item: T): boolean {\n return untracked(() => {\n if (this.isDisabled(item)) {\n return false;\n }\n this.anchorItem.set(item);\n return this.addOne(item);\n });\n }\n\n /**\n * Deselects `item`; a locked item stays selected.\n *\n * @returns whether the selection changed.\n */\n deselect(item: T): boolean {\n return untracked(() => {\n if (this.isDisabled(item)) {\n return false;\n }\n this.anchorItem.set(item);\n return this.removeOne(item);\n });\n }\n\n /**\n * Flips `item`. In `single` mode a selected item is deselected too, so a list can be\n * emptied by clicking its selected row; use `select` for radio behavior.\n *\n * @returns whether the selection changed.\n */\n toggle(item: T): boolean {\n return untracked(() => {\n if (this.isDisabled(item)) {\n return false;\n }\n this.anchorItem.set(item);\n return this.selectedLookup().has(item)\n ? this.removeOne(item)\n : this.addOne(item);\n });\n }\n\n /**\n * Deselects everything the user is allowed to change. Locked items stay: a \"clear\" button\n * must not silently drop a mandatory choice.\n *\n * @returns whether the selection changed.\n */\n clear(): boolean {\n return untracked(() =>\n this.apply(\n this.selected().filter((item) => this.isDisabled(item)),\n 'interaction',\n ),\n );\n }\n\n /**\n * Replaces the selection, as a form or a two-way binding writes a value in. Duplicates are\n * dropped (the first wins), the list is cut to what the mode and `max` allow, and locking\n * is ignored — a disabled option can still be pre-selected.\n *\n * Unlike the interaction methods this reports `source: 'programmatic'`.\n *\n * @returns whether membership changed. Swapping in new object instances for the same keys\n * updates `selected()` but returns `false` and publishes no change.\n */\n setSelection(items: readonly T[]): boolean {\n return untracked(() =>\n this.apply(this.clip(this.dedupe(items)), 'programmatic'),\n );\n }\n\n /**\n * Drops selected items that are not in `items`, keeping the order of the rest. Call it when\n * the source list loses entries and the selection must not point at ghosts. Locking is\n * ignored: a row that no longer exists cannot stay selected just because it was locked.\n *\n * @returns whether anything was dropped.\n */\n retainOnly(items: readonly T[]): boolean {\n return untracked(() => {\n const keep = this.createLookup(items);\n return this.apply(\n this.selected().filter((item) => keep.has(item)),\n 'programmatic',\n );\n });\n }\n\n /**\n * Selects every unlocked item of `items`. With `max` it fills the remaining room in list\n * order and stops, rather than refusing the whole call, so \"select all\" on a long list\n * still does something useful. Does nothing in `single` mode, where \"all\" has no meaning.\n *\n * @returns whether the selection changed.\n */\n selectAll(items: readonly T[]): boolean {\n return untracked(() => this.addMany(items));\n }\n\n /**\n * Deselects every unlocked item of `items`. Selected items outside `items`, and locked ones,\n * are untouched — which is what lets one pane's \"select none\" leave another pane alone.\n *\n * @returns whether the selection changed.\n */\n deselectAll(items: readonly T[]): boolean {\n return untracked(() => this.removeMany(items));\n }\n\n /**\n * The header checkbox's click: deselects the unlocked items of `items` when all of them are\n * selected, otherwise selects them. If selecting changes nothing because `max` is already\n * reached, it deselects instead, so the control can never get stuck in the mixed state.\n * Does nothing in `single` mode.\n *\n * @returns whether the selection changed.\n */\n toggleAll(items: readonly T[]): boolean {\n return untracked(() => {\n if (this.mode() === 'single') {\n return false;\n }\n if (this.stateOf(items) === 'all') {\n return this.removeMany(items);\n }\n return this.addMany(items) || this.removeMany(items);\n });\n }\n\n /**\n * Flips the selection of every unlocked item of `items`: selected ones are deselected and the\n * rest selected (a table's \"invert selection\"). Items outside `items` and locked items are\n * untouched. With `max`, newly selected items fill whatever room is left, in list order.\n * Does nothing in `single` mode.\n *\n * @returns whether the selection changed.\n */\n invert(items: readonly T[]): boolean {\n return untracked(() => {\n if (this.mode() === 'single') {\n return false;\n }\n const flippable = this.dedupe(items).filter(\n (item) => !this.isDisabled(item),\n );\n const chosen = this.selectedLookup();\n const doomed = this.createLookup(flippable.filter((i) => chosen.has(i)));\n const kept = this.selected().filter((item) => !doomed.has(item));\n const room = this.limit() - kept.length;\n const added = flippable\n .filter((item) => !chosen.has(item))\n .slice(0, room);\n return this.apply([...kept, ...added], 'interaction');\n });\n }\n\n /**\n * Applies shift-click semantics: every unlocked item between `from` and `to` (inclusive, in\n * the order of `items`, whichever comes first) is selected, or deselected with\n * `selected = false`. Callers pass the item that was last interacted with, normally\n * {@link anchor}, as `from`, and take `selected` from the item being clicked, so a range\n * extends whatever the click would have done on its own.\n *\n * `to` becomes the new anchor. If either item is not in `items` nothing happens; in `single`\n * mode only `to` is acted on.\n *\n * @returns whether the selection changed.\n */\n selectRange(items: readonly T[], from: T, to: T, selected = true): boolean {\n return untracked(() => {\n const start = items.findIndex((item) => this.same(item, from));\n const end = items.findIndex((item) => this.same(item, to));\n if (start === -1 || end === -1) {\n return false;\n }\n const target = items[end];\n if (!this.isDisabled(target)) {\n this.anchorItem.set(target);\n }\n if (this.mode() === 'single') {\n if (this.isDisabled(target)) {\n return false;\n }\n return selected ? this.addOne(target) : this.removeOne(target);\n }\n const range = items.slice(Math.min(start, end), Math.max(start, end) + 1);\n return selected ? this.addMany(range) : this.removeMany(range);\n });\n }\n\n /**\n * Summarizes the selection over `items`: `all` when every unlocked item is selected, `none`\n * when none is, `some` otherwise. Locked items and repeated items are not counted — a locked\n * item can never be changed by \"select all\", so counting it would leave the control\n * mixed forever. Items selected but absent from `items` are ignored, so a filtered page\n * reports on what it shows.\n *\n * With a `max` below the number of unlocked items `all` is unreachable; see {@link toggleAll}.\n *\n * Reactive: wrap it in `computed(() => model.stateOf(items()))` for a list signal.\n */\n stateOf(items: readonly T[]): AndesSelectionState {\n const selected = this.selectedLookup();\n const seen = this.createLookup();\n let considered = 0;\n let chosen = 0;\n for (const item of items) {\n if (seen.has(item)) {\n continue;\n }\n seen.add(item);\n if (this.isDisabled(item)) {\n continue;\n }\n considered++;\n if (selected.has(item)) {\n chosen++;\n }\n }\n if (chosen === 0) {\n return 'none';\n }\n return chosen === considered ? 'all' : 'some';\n }\n\n /** Whether {@link stateOf} is `all`: a \"select all\" checkbox is checked. */\n allSelected(items: readonly T[]): boolean {\n return this.stateOf(items) === 'all';\n }\n\n /**\n * Whether {@link stateOf} is `some`: a strict subset is selected, i.e. the checkbox is\n * indeterminate. It is `false` for an empty or complete selection.\n */\n someSelected(items: readonly T[]): boolean {\n return this.stateOf(items) === 'some';\n }\n\n /** Sets the shift-click anchor directly, for example after a programmatic focus move. */\n setAnchor(item: T | undefined): void {\n this.anchorItem.set(item);\n }\n\n private addOne(item: T): boolean {\n if (this.selectedLookup().has(item)) {\n return false;\n }\n const current = this.selected();\n if (this.mode() === 'single') {\n if (current.some((existing) => this.isDisabled(existing))) {\n return false;\n }\n return this.apply([item], 'interaction');\n }\n if (current.length >= this.limit()) {\n return false;\n }\n return this.apply([...current, item], 'interaction');\n }\n\n private removeOne(item: T): boolean {\n return this.apply(\n this.selected().filter((existing) => !this.same(existing, item)),\n 'interaction',\n );\n }\n\n private addMany(items: readonly T[]): boolean {\n if (this.mode() === 'single') {\n return false;\n }\n const current = this.selected();\n const known = this.createLookup(current);\n const room = this.limit() - current.length;\n const added: T[] = [];\n for (const item of items) {\n if (added.length >= room) {\n break;\n }\n if (this.isDisabled(item) || known.has(item)) {\n continue;\n }\n known.add(item);\n added.push(item);\n }\n return added.length > 0\n ? this.apply([...current, ...added], 'interaction')\n : false;\n }\n\n private removeMany(items: readonly T[]): boolean {\n const doomed = this.createLookup(\n items.filter((item) => !this.isDisabled(item)),\n );\n return this.apply(\n this.selected().filter((item) => !doomed.has(item)),\n 'interaction',\n );\n }\n\n /**\n * The single write path: derives `{added, removed}` by membership, stores the new array and\n * publishes the change. A call that only swaps instances or reorders members is stored but\n * stays silent.\n */\n private apply(\n next: readonly T[],\n source: AndesSelectionChangeSource,\n ): boolean {\n const previous = this.selected();\n const before = this.selectedLookup();\n const after = this.createLookup(next);\n const added = next.filter((item) => !before.has(item));\n const removed = previous.filter((item) => !after.has(item));\n\n if (added.length === 0 && removed.length === 0) {\n if (\n this.raw().length !== next.length ||\n !isSameSequence(previous, next)\n ) {\n this.raw.set(next);\n }\n return false;\n }\n\n this.raw.set(next);\n const change: AndesSelectionChange<T> = { added, removed, source };\n this.lastChange.set(change);\n this.onChange?.(change);\n return true;\n }\n\n private clip(items: readonly T[]): readonly T[] {\n const limit = this.limit();\n return items.length > limit ? items.slice(0, limit) : items;\n }\n\n private dedupe(items: readonly T[]): T[] {\n const seen = this.createLookup();\n const unique: T[] = [];\n for (const item of items) {\n if (!seen.has(item)) {\n seen.add(item);\n unique.push(item);\n }\n }\n return unique;\n }\n\n private same(a: T, b: T): boolean {\n if (this.keyOf) {\n return sameKey(this.keyOf(a), this.keyOf(b));\n }\n return this.compareWith ? this.compareWith(a, b) : sameKey(a, b);\n }\n\n private createLookup(items: readonly T[] = []): Lookup<T> {\n const compare = this.compareWith;\n if (compare) {\n const list = [...items];\n return {\n has: (item) => list.some((existing) => compare(existing, item)),\n add: (item) => void list.push(item),\n };\n }\n const keyOf = this.keyOf ?? identity;\n const keys = new Set<unknown>(items.map((item) => keyOf(item)));\n return {\n has: (item) => keys.has(keyOf(item)),\n add: (item) => void keys.add(keyOf(item)),\n };\n }\n}\n","import type { TemplateRef } from '@angular/core';\nimport type { ComponentType } from '@angular/cdk/overlay';\n\n/**\n * Named stacking layer. Each value maps 1:1 onto an `--andes-z-index-*` token in\n * `@andes-ng/tokens`, so overlay stacking is a token decision, not a magic number\n * picked per component.\n */\nexport type AndesOverlayLayer =\n 'dropdown' | 'overlay' | 'modal' | 'popover' | 'tooltip' | 'toast';\n\n/**\n * Numeric fallbacks that mirror the current `--andes-z-index-*` token values. They are\n * only used when `@andes-ng/tokens`' `theme.css` is not loaded, so an overlay still\n * stacks in the right order instead of collapsing to `auto`.\n */\nexport const ANDES_OVERLAY_Z_INDEX_FALLBACKS: Readonly<\n Record<AndesOverlayLayer, number>\n> = {\n dropdown: 1000,\n overlay: 1040,\n modal: 1050,\n popover: 1060,\n tooltip: 1070,\n toast: 1080,\n};\n\n/** The CSS value applied as `z-index` for a layer, token first, numeric fallback second. */\nexport function andesOverlayZIndex(layer: AndesOverlayLayer): string {\n return `var(--andes-z-index-${layer}, ${ANDES_OVERLAY_Z_INDEX_FALLBACKS[layer]})`;\n}\n\n/** The CSS value applied as the backdrop scrim's background. */\nexport const ANDES_OVERLAY_SCRIM =\n 'var(--andes-color-overlay, rgb(15 23 42 / 45%))';\n\n/** Side of the anchor an anchored overlay prefers to render on. */\nexport type AndesOverlaySide = 'top' | 'bottom' | 'left' | 'right';\n\n/** Alignment of an anchored overlay along its side. */\nexport type AndesOverlayAlign = 'start' | 'center' | 'end';\n\n/** Viewport edge an edge-anchored overlay (Drawer/Sheet) slides in from. */\nexport type AndesOverlayEdge = 'top' | 'right' | 'bottom' | 'left';\n\n/**\n * Anchor-relative positioning, for Popover / Tooltip / Dropdown Menu. Collision\n * handling (flip to the opposite side, then shift along the cross axis) is on by\n * default — an overlay that would render off-screen is a bug, not a variant.\n */\nexport interface AndesOverlayAnchoredPositioning {\n readonly kind: 'anchored';\n /** Preferred side. Default `'bottom'`. */\n readonly side?: AndesOverlaySide;\n /** Alignment along the side. Default `'center'`. */\n readonly align?: AndesOverlayAlign;\n /** Gap in px between anchor and overlay along the side axis. Default `0`. */\n readonly sideOffset?: number;\n /** Extra px offset along the alignment axis. Default `0`. */\n readonly alignOffset?: number;\n /** Flip to the opposite side when the preferred one does not fit. Default `true`. */\n readonly flip?: boolean;\n /**\n * When flipping, also try the two perpendicular sides once neither the preferred side\n * nor its opposite fits. Default `true`. A list dropping down from a field turns this\n * off: placed beside the field it no longer reads as that field's list, so it stays\n * above or below and is shifted into view instead.\n */\n readonly crossSideFallback?: boolean;\n /** Shift along the cross axis to stay on screen. Default `true`. */\n readonly shift?: boolean;\n /** Minimum px kept between the overlay and the viewport edge. Default `8`. */\n readonly viewportMargin?: number;\n /** Size the overlay to the anchor's width (Select/Combobox-style). Default `false`. */\n readonly matchAnchorWidth?: boolean;\n /** Never re-position after the first open, even on scroll. Default `false`. */\n readonly lockPosition?: boolean;\n}\n\n/** Viewport-centered positioning, for Dialog / Alert Dialog. */\nexport interface AndesOverlayCenteredPositioning {\n readonly kind: 'centered';\n}\n\n/** Edge-pinned positioning, for Drawer / Sheet. */\nexport interface AndesOverlayEdgePositioning {\n readonly kind: 'edge';\n /** Which viewport edge to pin to. Default `'right'`. */\n readonly edge?: AndesOverlayEdge;\n}\n\nexport type AndesOverlayPositioning =\n | AndesOverlayAnchoredPositioning\n | AndesOverlayCenteredPositioning\n | AndesOverlayEdgePositioning;\n\n/** Why an overlay closed. Forwarded to consumers so they can veto or branch on it. */\nexport type AndesOverlayCloseReason =\n | 'imperative'\n | 'escape-key'\n | 'outside-click'\n | 'backdrop-click'\n | 'close-button'\n | 'trigger'\n | 'destroyed';\n\n/** What receives focus when the overlay opens. */\nexport type AndesOverlayAutoFocus =\n /** The first tabbable element inside the overlay (honours `cdkFocusInitial`). */\n | 'first-tabbable'\n /** The overlay pane itself, via `tabindex=\"-1\"`. */\n | 'container'\n /** Nothing — focus stays where the user left it. Correct for Tooltip. */\n | 'none';\n\n/** ARIA role applied to the overlay content by `AndesOverlayContentPrimitive`. */\nexport type AndesOverlayRole =\n 'dialog' | 'alertdialog' | 'menu' | 'listbox' | 'tooltip' | 'none';\n\n/** Explicit sizing forwarded to the CDK overlay pane. */\nexport interface AndesOverlaySize {\n readonly width?: number | string;\n readonly height?: number | string;\n readonly minWidth?: number | string;\n readonly minHeight?: number | string;\n readonly maxWidth?: number | string;\n readonly maxHeight?: number | string;\n}\n\n/**\n * The full behavior contract of an andes-ng overlay. Every dismissal, focus and\n * scroll behavior is an independent flag: Dialog wants all of them, Tooltip wants\n * almost none, and Popover/Dropdown Menu sit in between.\n */\nexport interface AndesOverlayConfig {\n /** Stacking layer, sourced from `--andes-z-index-*`. */\n readonly layer: AndesOverlayLayer;\n /** How the overlay is placed. */\n readonly positioning: AndesOverlayPositioning;\n /** Keep Tab/Shift+Tab inside the overlay while it is open. */\n readonly trapFocus: boolean;\n /** Return focus to the trigger (or the element focused at open time) on close. */\n readonly restoreFocus: boolean;\n /** What receives focus when the overlay opens. */\n readonly autoFocus: AndesOverlayAutoFocus;\n /** Escape closes the overlay. Only the topmost open overlay reacts. */\n readonly closeOnEscape: boolean;\n /** A pointer event outside the overlay (or on its backdrop) closes it. */\n readonly closeOnOutsideClick: boolean;\n /** Block document scroll while open. */\n readonly lockScroll: boolean;\n /**\n * Mark everything outside the overlay `inert` while it is open, so a screen\n * reader browsing the page (not just tabbing through it) cannot reach content\n * behind a modal. `trapFocus` only governs Tab and `ariaModal` is a hint AT does\n * not universally honour, so a truly modal overlay needs this as well.\n *\n * Applies to every direct child of `<body>` except the one the overlay itself is\n * portalled into, and is reference-counted across nested overlays.\n *\n * On for the `dialog`, `alert-dialog` and `drawer` presets; off for the\n * non-modal `popover`, `menu` and `tooltip`, which must leave the page usable.\n */\n readonly inertBackground: boolean;\n /** Render a backdrop scrim using `--andes-color-overlay`. */\n readonly hasBackdrop: boolean;\n /** ARIA role for the content element. */\n readonly role: AndesOverlayRole;\n /** Whether the content element gets `aria-modal=\"true\"`. */\n readonly ariaModal: boolean;\n /** Extra classes on the CDK overlay pane. */\n readonly panelClass: string | readonly string[] | null;\n /** Extra classes on the backdrop, in addition to `andes-overlay-backdrop`. */\n readonly backdropClass: string | readonly string[] | null;\n /** Re-position on scroll. Only meaningful for anchored positioning. */\n readonly repositionOnScroll: boolean;\n /** Dispose the overlay on browser back/forward. */\n readonly disposeOnNavigation: boolean;\n /** Explicit pane sizing. */\n readonly size: AndesOverlaySize;\n}\n\n/**\n * Deliberately conservative defaults: no focus trap, no scroll lock, no backdrop,\n * no inert background. A consumer that forgets to configure gets the least\n * invasive overlay rather than one that silently hijacks the page.\n */\nexport const ANDES_OVERLAY_DEFAULT_CONFIG: AndesOverlayConfig = {\n layer: 'overlay',\n positioning: { kind: 'centered' },\n trapFocus: false,\n restoreFocus: true,\n autoFocus: 'none',\n closeOnEscape: true,\n closeOnOutsideClick: true,\n lockScroll: false,\n inertBackground: false,\n hasBackdrop: false,\n role: 'none',\n ariaModal: false,\n panelClass: null,\n backdropClass: null,\n repositionOnScroll: false,\n disposeOnNavigation: true,\n size: {},\n};\n\n/** The overlay flavours the five planned components map onto. */\nexport type AndesOverlayPreset =\n 'dialog' | 'alert-dialog' | 'drawer' | 'popover' | 'menu' | 'tooltip';\n\nconst DIALOG_PRESET: Partial<AndesOverlayConfig> = {\n layer: 'modal',\n positioning: { kind: 'centered' },\n trapFocus: true,\n restoreFocus: true,\n autoFocus: 'first-tabbable',\n closeOnEscape: true,\n closeOnOutsideClick: true,\n lockScroll: true,\n inertBackground: true,\n hasBackdrop: true,\n role: 'dialog',\n ariaModal: true,\n repositionOnScroll: false,\n};\n\n/**\n * Starting points, not policy: every consumer is expected to spread a preset and\n * then override. They exist so the five components do not each invent their own\n * answer to \"should a menu trap focus?\" independently.\n *\n * - `dialog` / `alert-dialog` / `drawer` are modal: trap, lock scroll, backdrop,\n * and an inert background so AT cannot reach the page behind them.\n * `alert-dialog` additionally refuses outside-click dismissal, per the WAI-ARIA\n * distinction between `dialog` and `alertdialog`.\n * - `drawer` sits on the `overlay` layer rather than `modal`, so a confirmation\n * dialog opened from inside a drawer stacks above it.\n * - `popover` and `menu` move focus into the overlay (both are click-opened and\n * contain interactive content, so keyboard users must be able to reach it) but do\n * not trap it: the page behind stays usable and scrollable, as with any non-modal\n * popover, and they leave the rest of the page readable by\n * assistive tech. Consumers that render a close button inside and want modal\n * semantics can flip `trapFocus` and `inertBackground` on together.\n * - `tooltip` moves nothing, traps nothing and restores nothing — it is a passive\n * hint attached to an element that already has focus.\n */\nexport const ANDES_OVERLAY_PRESETS: Readonly<\n Record<AndesOverlayPreset, Partial<AndesOverlayConfig>>\n> = {\n dialog: DIALOG_PRESET,\n 'alert-dialog': {\n ...DIALOG_PRESET,\n role: 'alertdialog',\n closeOnOutsideClick: false,\n },\n drawer: {\n ...DIALOG_PRESET,\n layer: 'overlay',\n positioning: { kind: 'edge', edge: 'right' },\n },\n popover: {\n layer: 'popover',\n positioning: {\n kind: 'anchored',\n side: 'bottom',\n align: 'center',\n sideOffset: 8,\n },\n trapFocus: false,\n restoreFocus: true,\n autoFocus: 'first-tabbable',\n closeOnEscape: true,\n closeOnOutsideClick: true,\n lockScroll: false,\n inertBackground: false,\n hasBackdrop: false,\n role: 'dialog',\n ariaModal: false,\n repositionOnScroll: true,\n },\n menu: {\n layer: 'dropdown',\n positioning: {\n kind: 'anchored',\n side: 'bottom',\n align: 'start',\n sideOffset: 4,\n },\n trapFocus: false,\n restoreFocus: true,\n autoFocus: 'first-tabbable',\n closeOnEscape: true,\n closeOnOutsideClick: true,\n lockScroll: false,\n inertBackground: false,\n hasBackdrop: false,\n role: 'menu',\n ariaModal: false,\n repositionOnScroll: true,\n },\n tooltip: {\n layer: 'tooltip',\n positioning: {\n kind: 'anchored',\n side: 'top',\n align: 'center',\n sideOffset: 6,\n },\n trapFocus: false,\n restoreFocus: false,\n autoFocus: 'none',\n closeOnEscape: true,\n closeOnOutsideClick: true,\n lockScroll: false,\n inertBackground: false,\n hasBackdrop: false,\n role: 'tooltip',\n ariaModal: false,\n repositionOnScroll: true,\n },\n};\n\n/** Reads a preset. A thin helper so consumers never hand-copy a preset's fields. */\nexport function andesOverlayPreset(\n preset: AndesOverlayPreset,\n): Partial<AndesOverlayConfig> {\n return ANDES_OVERLAY_PRESETS[preset];\n}\n\n/** What can be rendered into an overlay. */\nexport type AndesOverlayContent<C = unknown> =\n TemplateRef<C> | ComponentType<unknown>;\n\n/** Class applied to every andes-ng backdrop, as a styling hook for consumers. */\nexport const ANDES_OVERLAY_BACKDROP_CLASS = 'andes-overlay-backdrop';\n\n/** Class applied to every andes-ng overlay pane, as a styling hook for consumers. */\nexport const ANDES_OVERLAY_PANE_CLASS = 'andes-overlay-pane';\n\n/**\n * Attribute (empty value) the overlay primitive sets while an overlay is closing,\n * so a component can play an exit animation before the pane is removed.\n *\n * When `close()` is called, the attribute goes on the overlay pane, on each direct\n * element child of the pane (the root elements of the component's own panel\n * template, which is where emulated-encapsulation styles can reach it) and on the\n * backdrop, if there is one. The pane and backdrop also stop receiving pointer\n * events. The primitive then waits for every animation or transition running in\n * the pane (and on the backdrop) to finish, at most\n * {@link ANDES_OVERLAY_EXIT_TIMEOUT_MS}, before detaching.\n *\n * A component opts in by styling its panel root, for example\n *\n * ```css\n * .panel[data-andes-closing] {\n * animation: panel-exit 120ms ease-in forwards;\n * }\n * @media (prefers-reduced-motion: reduce) {\n * .panel[data-andes-closing] { animation: none; }\n * }\n * ```\n *\n * Use `animation-fill-mode: forwards` (or a transition) so the panel does not\n * snap back to full opacity between the end of the animation and the detach.\n * Without any exit style the close stays instant and synchronous, and it is also\n * instant when the user prefers reduced motion.\n *\n * While the attribute is present `isOpen()` is already `false`; focus is restored\n * and `closed` emits only after the pane is detached. If focus moved to another\n * element on the page during the exit, it stays there instead of returning to\n * the trigger. Opening again before then\n * removes the attribute and keeps the same pane, and neither `closed` nor `opened`\n * emits for the interrupted close.\n */\nexport const ANDES_OVERLAY_CLOSING_ATTRIBUTE = 'data-andes-closing';\n\n/**\n * Longest a close waits for exit animations before detaching the overlay anyway,\n * so a stalled or endless animation can never keep a closed overlay on screen.\n */\nexport const ANDES_OVERLAY_EXIT_TIMEOUT_MS = 300;\n","import type { Injector } from '@angular/core';\nimport {\n createFlexibleConnectedPositionStrategy,\n createGlobalPositionStrategy,\n type ConnectedPosition,\n type GlobalPositionStrategy,\n type PositionStrategy,\n} from '@angular/cdk/overlay';\n\nimport {\n type AndesOverlayAlign,\n type AndesOverlayConfig,\n type AndesOverlayEdge,\n type AndesOverlayPositioning,\n type AndesOverlaySide,\n} from './overlay-config';\n\nconst OPPOSITE_SIDE: Readonly<Record<AndesOverlaySide, AndesOverlaySide>> = {\n top: 'bottom',\n bottom: 'top',\n left: 'right',\n right: 'left',\n};\n\nconst CROSS_SIDES: Readonly<\n Record<AndesOverlaySide, readonly AndesOverlaySide[]>\n> = {\n top: ['right', 'left'],\n bottom: ['right', 'left'],\n left: ['bottom', 'top'],\n right: ['bottom', 'top'],\n};\n\n/**\n * Translates one andes-ng `side`/`align` pair into a CDK `ConnectedPosition`.\n *\n * `sideOffset` always pushes the overlay *away* from the anchor, so its sign\n * depends on the side; `alignOffset` shifts along the perpendicular axis.\n */\nexport function andesConnectedPosition(\n side: AndesOverlaySide,\n align: AndesOverlayAlign,\n sideOffset: number,\n alignOffset: number,\n): ConnectedPosition {\n const alignToX = { start: 'start', center: 'center', end: 'end' } as const;\n const alignToY = { start: 'top', center: 'center', end: 'bottom' } as const;\n\n switch (side) {\n case 'bottom':\n return {\n originX: alignToX[align],\n originY: 'bottom',\n overlayX: alignToX[align],\n overlayY: 'top',\n offsetX: alignOffset,\n offsetY: sideOffset,\n };\n case 'top':\n return {\n originX: alignToX[align],\n originY: 'top',\n overlayX: alignToX[align],\n overlayY: 'bottom',\n offsetX: alignOffset,\n offsetY: -sideOffset,\n };\n case 'right':\n return {\n originX: 'end',\n originY: alignToY[align],\n overlayX: 'start',\n overlayY: alignToY[align],\n offsetX: sideOffset,\n offsetY: alignOffset,\n };\n case 'left':\n return {\n originX: 'start',\n originY: alignToY[align],\n overlayX: 'end',\n overlayY: alignToY[align],\n offsetX: -sideOffset,\n offsetY: alignOffset,\n };\n }\n}\n\n/**\n * The preferred position first, then the fallbacks CDK walks when it does not fit:\n * the opposite side (a flip), then - unless `crossSideFallback` is off - the two\n * perpendicular sides (a last resort before CDK falls back to pushing the overlay into\n * view).\n */\nexport function andesConnectedPositions(\n side: AndesOverlaySide,\n align: AndesOverlayAlign,\n sideOffset: number,\n alignOffset: number,\n flip: boolean,\n crossSideFallback = true,\n): ConnectedPosition[] {\n const build = (candidate: AndesOverlaySide) =>\n andesConnectedPosition(candidate, align, sideOffset, alignOffset);\n\n if (!flip) {\n return [build(side)];\n }\n\n return [\n build(side),\n build(OPPOSITE_SIDE[side]),\n ...(crossSideFallback ? CROSS_SIDES[side].map(build) : []),\n ];\n}\n\nfunction applyEdge(\n strategy: GlobalPositionStrategy,\n edge: AndesOverlayEdge,\n): GlobalPositionStrategy {\n switch (edge) {\n case 'left':\n return strategy.top('0').left('0');\n case 'right':\n return strategy.top('0').right('0');\n case 'top':\n return strategy.top('0').left('0');\n case 'bottom':\n return strategy.bottom('0').left('0');\n }\n}\n\n/**\n * Builds the CDK position strategy for a config. Anchored positioning needs the\n * anchor element; without one it degrades to centered rather than throwing, so a\n * Popover whose trigger has not attached yet still renders somewhere sane.\n */\nexport function createAndesPositionStrategy(\n injector: Injector,\n positioning: AndesOverlayPositioning,\n anchor: HTMLElement | null,\n): PositionStrategy {\n if (positioning.kind === 'anchored' && anchor) {\n const {\n side = 'bottom',\n align = 'center',\n sideOffset = 0,\n alignOffset = 0,\n flip = true,\n crossSideFallback = true,\n shift = true,\n viewportMargin = 8,\n lockPosition = false,\n } = positioning;\n\n return createFlexibleConnectedPositionStrategy(injector, anchor)\n .withPositions(\n andesConnectedPositions(\n side,\n align,\n sideOffset,\n alignOffset,\n flip,\n crossSideFallback,\n ),\n )\n .withPush(shift)\n .withViewportMargin(viewportMargin)\n .withFlexibleDimensions(false)\n .withGrowAfterOpen(false)\n .withLockedPosition(lockPosition);\n }\n\n const strategy = createGlobalPositionStrategy(injector);\n\n if (positioning.kind === 'edge') {\n return applyEdge(strategy, positioning.edge ?? 'right');\n }\n\n return strategy.centerHorizontally().centerVertically();\n}\n\n/**\n * Sizing implied by the positioning, before the consumer's explicit `size` wins.\n * An edge-anchored panel spans the edge it is pinned to; nothing else implies a size.\n */\nexport function andesImpliedSize(\n positioning: AndesOverlayPositioning,\n): Pick<AndesOverlayConfig['size'], 'width' | 'height'> {\n if (positioning.kind !== 'edge') {\n return {};\n }\n\n const edge = positioning.edge ?? 'right';\n return edge === 'left' || edge === 'right'\n ? { height: '100%' }\n : { width: '100%' };\n}\n","import { DOCUMENT, inject, Injectable } from '@angular/core';\n\n/**\n * Handle for one overlay's claim on an inert background. Releasing it undoes\n * *that claim only*: elements another still-open overlay also depends on stay\n * inert. Releasing twice is a no-op, so a double `close()` cannot under-count.\n */\nexport interface AndesOverlayInertHandle {\n release(): void;\n}\n\n/**\n * Body children that render nothing, so marking them inert would be noise in the\n * DOM with no effect on what a screen reader can reach.\n */\nconst NON_RENDERED_TAGS: ReadonlySet<string> = new Set([\n 'SCRIPT',\n 'STYLE',\n 'LINK',\n 'TEMPLATE',\n 'NOSCRIPT',\n 'BASE',\n 'META',\n 'TITLE',\n]);\n\n/**\n * Selectors for body children that, unlike `NON_RENDERED_TAGS`, *do* render —\n * but are Angular CDK's own accessibility plumbing rather than page content, and\n * so must stay reachable by assistive tech no matter what overlay is open.\n *\n * CDK appends these directly to `<body>`, alongside the app root and the overlay\n * container, which puts them squarely in \"the background\" `inertBackgroundExcept`\n * would otherwise inert on every modal open.\n */\nconst NON_RENDERED_SELECTORS: readonly string[] = [\n // `LiveAnnouncer` posts text into this hidden node for screen readers to\n // announce (this is how `AndesToastService` speaks a toast). Inerting it makes\n // every announcement — every toast — silent for exactly as long as a modal is\n // open, with no visible symptom: the element still renders, just unreachable.\n '.cdk-live-announcer-element',\n // `AriaDescriber` stores the text a dynamically generated `aria-describedby`\n // points to here.\n '.cdk-describedby-message-container',\n];\n\n/** The CDK overlay container every andes-ng overlay portals into. */\nconst OVERLAY_CONTAINER_SELECTOR = '.cdk-overlay-container';\n\n/** Attribute we always apply: the standard, browser-enforced one. */\nconst INERT_ATTRIBUTE = 'inert';\n\n/**\n * Applied *in addition to* `inert`, and only when the current environment does\n * not implement `inert` at all. It is strictly weaker — it hides content from\n * assistive tech without making it non-interactive — so it is a fallback for\n * older browsers/AT, never the primary mechanism.\n */\nconst ARIA_HIDDEN_ATTRIBUTE = 'aria-hidden';\n\ninterface InertEntry {\n /** How many open overlays currently require this element to stay inert. */\n count: number;\n /** Attributes *we* added, and therefore the only ones we may remove. */\n readonly attributes: readonly string[];\n}\n\n/**\n * Reference-counted registry of \"everything outside the modal is inert\".\n *\n * ## Why this exists\n *\n * A focus trap only governs Tab. A screen-reader user in browse mode (VoiceOver's\n * `VO`-arrow, NVDA/JAWS virtual cursor) walks the accessibility tree directly and\n * happily reads — and activates — content behind an open modal. `aria-modal=\"true\"`\n * on the dialog is a *hint* that browsers and AT do not universally honour on its\n * own, which is why this primitive additionally marks the rest of the page inert.\n *\n * ## What gets marked\n *\n * Every **direct child of `<body>`** except the one containing the overlay itself.\n * Not `<body>`, because the overlay's own portal is rendered into the CDK overlay\n * container, which is itself a body child — inerting `<body>` would make the modal\n * unusable. Also excluded: CDK's own accessibility infrastructure (`LiveAnnouncer`,\n * `AriaDescriber`), which CDK likewise appends directly under `<body>` — see\n * `NON_RENDERED_SELECTORS` below.\n *\n * ## Nesting\n *\n * Every andes-ng overlay portals into the *same* CDK overlay container, so a\n * confirm dialog opened on top of a dialog needs the exact same background inert.\n * Rather than re-applying (and then prematurely releasing) it, each open overlay\n * takes a reference on the elements it needs; an element loses `inert` only when\n * the last overlay holding it closes. Closing the inner dialog therefore leaves\n * the outer dialog's background inert, and only the outermost close restores the\n * page.\n *\n * Exempting the shared container is not enough on its own, though: it would leave\n * the outer dialog — a sibling of the inner one inside that container — reachable\n * behind it. So a modal also claims every *other* child of the overlay container\n * (each earlier overlay's host wrapper and backdrop). Only what exists at open\n * time is claimed, which is exactly what lies beneath the new modal: a popover or\n * select opened later, from inside it, stays interactive. Those claims go through\n * the same reference count, so closing the inner dialog hands the outer one back\n * only once no other modal above it still holds it, in any closing order.\n *\n * ## What it refuses to touch\n *\n * An element that is *already* inert when we first see it is left alone entirely\n * and never tracked: something outside our control put it there for its own\n * reasons, and it is not ours to clear on close. Same for a pre-existing\n * `aria-hidden`.\n *\n * Provided in root because the reference count is a property of the document, not\n * of any one overlay instance — the same reason CDK's block-scroll strategy keeps\n * its own global count.\n */\n@Injectable({ providedIn: 'root' })\nexport class AndesOverlayInertRegistry {\n private readonly document = inject(DOCUMENT);\n private readonly entries = new Map<Element, InertEntry>();\n\n /**\n * The elements currently inert *because of us*. Elements that were already\n * inert for their own reasons are deliberately absent. Exposed so a consumer\n * (or a test) can assert on the primitive's footprint rather than on every\n * `[inert]` element in the document.\n */\n get inertElements(): readonly Element[] {\n return [...this.entries.keys()];\n }\n\n /**\n * Marks every direct child of `<body>` inert, except the subtrees the given\n * elements live in (the overlay's own pane and backdrop), plus every other\n * overlay already open in the CDK overlay container — the layers beneath this\n * one. Returns the handle that undoes exactly this claim.\n */\n inertBackgroundExcept(\n exemptElements: readonly (Element | null | undefined)[],\n ): AndesOverlayInertHandle {\n const exempt = new Set<Element>();\n for (const element of exemptElements) {\n const bodyChild = this.bodyChildOf(element);\n if (bodyChild) {\n exempt.add(bodyChild);\n }\n }\n\n const claimed: Element[] = [];\n const targets = [\n ...this.backgroundChildren(exempt),\n ...this.lowerOverlayLayers(exemptElements),\n ];\n for (const target of targets) {\n if (this.claim(target)) {\n claimed.push(target);\n }\n }\n\n let released = false;\n return {\n release: () => {\n if (released) {\n return;\n }\n released = true;\n for (const target of claimed) {\n this.release(target);\n }\n },\n };\n }\n\n /**\n * Takes a reference on one element. Returns whether the caller now holds one —\n * `false` for an element that was already inert before we ever saw it, which we\n * deliberately neither track nor modify.\n */\n private claim(target: Element): boolean {\n const existing = this.entries.get(target);\n if (existing) {\n existing.count++;\n return true;\n }\n\n if (target.hasAttribute(INERT_ATTRIBUTE)) {\n return false;\n }\n\n const attributes = [INERT_ATTRIBUTE];\n target.setAttribute(INERT_ATTRIBUTE, '');\n\n if (!this.supportsInert() && !target.hasAttribute(ARIA_HIDDEN_ATTRIBUTE)) {\n target.setAttribute(ARIA_HIDDEN_ATTRIBUTE, 'true');\n attributes.push(ARIA_HIDDEN_ATTRIBUTE);\n }\n\n this.entries.set(target, { count: 1, attributes });\n return true;\n }\n\n /** Drops one reference, clearing our attributes only when it was the last. */\n private release(target: Element): void {\n const entry = this.entries.get(target);\n if (!entry) {\n return;\n }\n entry.count--;\n if (entry.count > 0) {\n return;\n }\n for (const attribute of entry.attributes) {\n target.removeAttribute(attribute);\n }\n this.entries.delete(target);\n }\n\n private backgroundChildren(exempt: ReadonlySet<Element>): Element[] {\n return [...this.document.body.children].filter(\n (child) =>\n !exempt.has(child) &&\n !NON_RENDERED_TAGS.has(child.tagName) &&\n !this.isAccessibilityInfrastructure(child),\n );\n }\n\n /**\n * The children of the CDK overlay container holding the exempt elements, other\n * than the ones containing them: the host wrappers and backdrops of overlays\n * opened earlier, and so stacked beneath this one.\n */\n private lowerOverlayLayers(\n exemptElements: readonly (Element | null | undefined)[],\n ): Element[] {\n const own = exemptElements.filter(\n (element): element is Element => !!element,\n );\n const container = own\n .map((element) => element.closest(OVERLAY_CONTAINER_SELECTOR))\n .find((element): element is Element => !!element);\n if (!container) {\n return [];\n }\n return [...container.children].filter(\n (child) =>\n !own.some((element) => child.contains(element)) &&\n !NON_RENDERED_TAGS.has(child.tagName) &&\n !this.isAccessibilityInfrastructure(child),\n );\n }\n\n /**\n * True for a body child that is itself an accessibility mechanism rather than\n * page content — CDK's own (matched by class, since `NON_RENDERED_TAGS` only\n * matches by tag), or a live region a consumer appended directly under `<body>`\n * for the same reason CDK does: so it keeps announcing regardless of what else\n * on the page is inert.\n *\n * `aria-live=\"off\"` is excluded because it explicitly opts out of announcing —\n * exempting it would serve no one and would needlessly leave an otherwise\n * ordinary piece of background content out of the inert set.\n */\n private isAccessibilityInfrastructure(element: Element): boolean {\n if (NON_RENDERED_SELECTORS.some((selector) => element.matches(selector))) {\n return true;\n }\n const ariaLive = element.getAttribute('aria-live');\n return !!ariaLive && ariaLive !== 'off';\n }\n\n /**\n * Walks up from an element to the `<body>` child whose subtree contains it, so\n * exempting an overlay pane exempts the whole portal outlet it was rendered into.\n */\n private bodyChildOf(element: Element | null | undefined): Element | null {\n const body = this.document.body;\n let current = element ?? null;\n while (current && current.parentElement && current.parentElement !== body) {\n current = current.parentElement;\n }\n return current?.parentElement === body ? current : null;\n }\n\n private supportsInert(): boolean {\n const view = this.document.defaultView;\n return !!view && 'inert' in view.HTMLElement.prototype;\n }\n}\n","import {\n DestroyRef,\n DOCUMENT,\n ElementRef,\n inject,\n Injectable,\n Injector,\n signal,\n TemplateRef,\n ViewContainerRef,\n type Provider,\n} from '@angular/core';\nimport {\n ConfigurableFocusTrapFactory,\n type ConfigurableFocusTrap,\n} from '@angular/cdk/a11y';\nimport { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';\nimport {\n createBlockScrollStrategy,\n createNoopScrollStrategy,\n createOverlayRef,\n createRepositionScrollStrategy,\n type OverlayConfig,\n type OverlayRef,\n type ScrollStrategy,\n} from '@angular/cdk/overlay';\nimport { ComponentPortal, TemplatePortal } from '@angular/cdk/portal';\nimport { Subject, Subscription, type Observable } from 'rxjs';\n\nimport {\n andesOverlayZIndex,\n ANDES_OVERLAY_BACKDROP_CLASS,\n ANDES_OVERLAY_CLOSING_ATTRIBUTE,\n ANDES_OVERLAY_DEFAULT_CONFIG,\n ANDES_OVERLAY_EXIT_TIMEOUT_MS,\n ANDES_OVERLAY_PANE_CLASS,\n ANDES_OVERLAY_SCRIM,\n type AndesOverlayCloseReason,\n type AndesOverlayConfig,\n type AndesOverlayContent,\n} from './overlay-config';\nimport {\n AndesOverlayInertRegistry,\n type AndesOverlayInertHandle,\n} from './overlay-inert';\nimport {\n andesImpliedSize,\n createAndesPositionStrategy,\n} from './overlay-positioning';\n\nlet nextUniqueId = 0;\n\n/** Options accepted when opening an overlay. */\nexport interface AndesOverlayOpenOptions<C = unknown> {\n /** Template context, for `TemplateRef` content. */\n readonly context?: C;\n /**\n * View container used to instantiate `TemplateRef` content. Defaults to the one\n * available where `AndesOverlayPrimitive` was provided, which is what a compound\n * component wants; pass it explicitly only when opening a template that lives in\n * some other view.\n */\n readonly viewContainerRef?: ViewContainerRef;\n /** Injector for `ComponentType` content, so the component can inject the overlay. */\n readonly injector?: Injector;\n /**\n * Element focus returns to on close, overriding the registered trigger.\n */\n readonly restoreFocusTo?: HTMLElement | ElementRef<HTMLElement> | null;\n}\n\nfunction toElement(\n value: HTMLElement | ElementRef<HTMLElement> | null | undefined,\n): HTMLElement | null {\n if (!value) {\n return null;\n }\n return value instanceof ElementRef ? value.nativeElement : value;\n}\n\n/** A close that has been requested but whose pane is not detached yet. */\ninterface AndesOverlayPendingExit {\n readonly reason: AndesOverlayCloseReason;\n readonly restoreFocus: boolean;\n /** Elements carrying the closing attribute, to clear if the close is cancelled. */\n readonly marked: Element[];\n /** Inline `pointer-events` values overridden for the exit, to put back. */\n readonly pointerEvents: Map<HTMLElement, string>;\n readonly subscription: Subscription;\n timer: ReturnType<typeof setTimeout> | null;\n}\n\n/**\n * Only animations that will actually end are worth waiting for: one that already\n * finished (an enter animation held by `fill-mode`), was cancelled, or loops\n * forever (a spinner inside a dialog) would only ever run into the timeout.\n */\nfunction isSettling(animation: Animation): boolean {\n if (animation.playState !== 'running') {\n return false;\n }\n const endTime = animation.effect?.getComputedTiming().endTime;\n return typeof endTime === 'number' && Number.isFinite(endTime);\n}\n\nfunction toClassList(\n value: string | readonly string[] | null | undefined,\n): string[] {\n if (!value) {\n return [];\n }\n return typeof value === 'string' ? [value] : [...value];\n}\n\n/**\n * The shared overlay behavior primitive: portal rendering, positioning, focus\n * management, dismissal and stacking for every andes-ng overlay component.\n *\n * It is a thin, tokens-integrated wrapper around Angular CDK's `Overlay` and\n * `ConfigurableFocusTrap` rather than a reimplementation — the failure modes here\n * (focus escaping a trap, focus returning to the wrong element, stacking-context\n * bugs) are exactly the ones CDK already solves.\n *\n * ## Consuming it\n *\n * `AndesOverlayPrimitive` is deliberately *not* `providedIn: 'root'`. A compound\n * component provides one instance for itself, and its own sub-directives inject it\n * — Angular's equivalent of React context:\n *\n * ```ts\n * @Component({\n * selector: 'andes-dialog',\n * providers: [provideAndesOverlay()],\n * template: `\n * <ng-content select=\"[andesOverlayTrigger]\" />\n * <ng-template #content>\n * <div andesOverlayContent>\n * <h2 id=\"title\">Delete project</h2>\n * <button andesOverlayClose>Cancel</button>\n * </div>\n * </ng-template>\n * `,\n * })\n * export class AndesDialog {\n * private readonly overlay = inject(AndesOverlayPrimitive);\n * private readonly content = viewChild.required<TemplateRef<unknown>>('content');\n *\n * constructor() {\n * this.overlay.configure(andesOverlayPreset('dialog'));\n * }\n *\n * open() {\n * this.overlay.open(this.content());\n * }\n * }\n * ```\n *\n * ## Stacking\n *\n * Overlays are rendered inside CDK's overlay container (never as a native\n * `popover`, which would move them to the top layer where `z-index` is ignored and\n * ordering is by call time). `z-index` comes from `--andes-z-index-*` per layer, so\n * a Popover opened from inside a Dialog stacks above it without either component\n * hard-coding a number.\n *\n * ## Modality\n *\n * A modal overlay needs three separate things, and `aria-modal` is only the weakest\n * of them: `trapFocus` for Tab, `ariaModal` as a hint, and `inertBackground` to\n * actually mark every other body child `inert` so a screen reader's browse mode\n * cannot walk into the page behind it. The modal presets turn on all three.\n *\n * ## Exit animations\n *\n * `close()` does not always detach at once. It sets\n * {@link ANDES_OVERLAY_CLOSING_ATTRIBUTE} on the pane, its direct element children\n * and the backdrop, and detaches once the animations that starts have finished\n * (capped at {@link ANDES_OVERLAY_EXIT_TIMEOUT_MS}). With no exit animation, with\n * reduced motion, or where the browser cannot report animations, the close is\n * synchronous. `isOpen()` turns `false` immediately either way.\n */\n@Injectable()\nexport class AndesOverlayPrimitive {\n private readonly injector = inject(Injector);\n private readonly document = inject(DOCUMENT);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly inertRegistry = inject(AndesOverlayInertRegistry);\n private readonly hostViewContainerRef = inject(ViewContainerRef, {\n optional: true,\n });\n\n private readonly _config = signal<AndesOverlayConfig>(\n ANDES_OVERLAY_DEFAULT_CONFIG,\n );\n private readonly _isOpen = signal(false);\n private readonly _anchor = signal<HTMLElement | null>(null);\n private readonly _panelElement = signal<HTMLElement | null>(null);\n private readonly _backdropElement = signal<HTMLElement | null>(null);\n private readonly _contentElement = signal<HTMLElement | null>(null);\n private readonly _isBackgroundInert = signal(false);\n\n /** The resolved behavior configuration. */\n readonly config = this._config.asReadonly();\n /**\n * Whether the overlay is open. Turns `false` as soon as a close is requested,\n * even while the pane is still attached playing its exit animation.\n */\n readonly isOpen = this._isOpen.asReadonly();\n /** The registered trigger element, if any. */\n readonly anchor = this._anchor.asReadonly();\n /** The CDK overlay pane, while attached (including during its exit animation). */\n readonly panelElement = this._panelElement.asReadonly();\n /** The backdrop scrim, while open and if the config renders one. */\n readonly backdropElement = this._backdropElement.asReadonly();\n /** The element carrying `andesOverlayContent`, while open. */\n readonly contentElement = this._contentElement.asReadonly();\n /**\n * Whether this overlay currently holds the page's background inert. False for a\n * non-modal overlay, and false again as soon as it closes — even if an outer\n * overlay still keeps the background inert for its own sake.\n */\n readonly isBackgroundInert = this._isBackgroundInert.asReadonly();\n\n /**\n * Stable id shared by the trigger's `aria-controls`/`aria-describedby` and the\n * content element's `id`, so assistive tech can relate the two.\n */\n readonly contentId = `andes-overlay-${nextUniqueId++}`;\n\n private readonly _opened = new Subject<void>();\n private readonly _closed = new Subject<AndesOverlayCloseReason>();\n private readonly _keydown = new Subject<KeyboardEvent>();\n private readonly _outsidePointer = new Subject<MouseEvent>();\n\n /** Emits after the overlay has been attached. */\n readonly opened: Observable<void> = this._opened.asObservable();\n /**\n * Emits the reason after the overlay has been detached — after its exit\n * animation, if it has one. Not emitted for a close cancelled by re-opening.\n */\n readonly closed: Observable<AndesOverlayCloseReason> =\n this._closed.asObservable();\n /**\n * Keydown events reaching the open overlay. Only the topmost overlay receives\n * them. Dropdown Menu builds its arrow-key/typeahead navigation on this.\n */\n readonly keydownEvents: Observable<KeyboardEvent> =\n this._keydown.asObservable();\n /** Pointer events outside the open overlay, whether or not they close it. */\n readonly outsidePointerEvents: Observable<MouseEvent> =\n this._outsidePointer.asObservable();\n\n private overlayRef: OverlayRef | null = null;\n private focusTrap: ConfigurableFocusTrap | null = null;\n private inertHandle: AndesOverlayInertHandle | null = null;\n private focusOrigin: HTMLElement | null = null;\n private explicitRestoreTarget: HTMLElement | null = null;\n private openSubscriptions = new Subscription();\n private pendingExit: AndesOverlayPendingExit | null = null;\n private attachedContent: AndesOverlayContent<unknown> | null = null;\n private attachedContext: unknown = undefined;\n\n constructor() {\n inject(DestroyRef).onDestroy(() => {\n // No exit animation for a host that is going away: detach now, including\n // an overlay that was already part-way through closing.\n this.beginClose('destroyed', false);\n this.completeClose();\n this._opened.complete();\n this._closed.complete();\n this._keydown.complete();\n this._outsidePointer.complete();\n });\n }\n\n /**\n * Merges a partial configuration in. Intended to be called from a consuming\n * component's constructor with a preset, then again from an `effect` as its own\n * inputs change.\n *\n * While the overlay is open, `positioning`, `size` and `layer` are re-applied\n * immediately. The structural flags (`hasBackdrop`, `trapFocus`, `lockScroll`,\n * `inertBackground`, `autoFocus`) take effect on the next `open()`; the\n * dismissal flags (`closeOnEscape`, `closeOnOutsideClick`) are read at event\n * time and so apply immediately.\n */\n configure(patch: Partial<AndesOverlayConfig>): void {\n this._config.update((current) => ({ ...current, ...patch }));\n\n const ref = this.overlayRef;\n if (!ref) {\n return;\n }\n\n const config = this._config();\n this.applyLayerStyles(ref, config);\n ref.updateSize({ ...andesImpliedSize(config.positioning), ...config.size });\n ref.updatePositionStrategy(\n createAndesPositionStrategy(\n this.injector,\n config.positioning,\n this._anchor(),\n ),\n );\n }\n\n /**\n * Registers the element anchored positioning measures against, and the element\n * focus returns to on close. `AndesOverlayTriggerPrimitive` calls this for you.\n */\n registerAnchor(\n element: HTMLElement | ElementRef<HTMLElement> | null | undefined,\n ): void {\n this._anchor.set(toElement(element));\n }\n\n /** Registers the content element. `AndesOverlayContentPrimitive` calls this. */\n registerContent(\n element: HTMLElement | ElementRef<HTMLElement> | null | undefined,\n ): void {\n this._contentElement.set(toElement(element));\n }\n\n /**\n * Opens the overlay with the given content. A no-op if already open.\n *\n * Called while the overlay is still playing its exit animation with the same\n * content and context, it cancels the close and keeps the same pane, so the\n * panel does not flicker; with different content the old pane is detached first.\n */\n open<C>(\n content: AndesOverlayContent<C>,\n options: AndesOverlayOpenOptions<C> = {},\n ): void {\n if (this._isOpen()) {\n return;\n }\n\n if (this.pendingExit) {\n if (\n this.overlayRef &&\n content === this.attachedContent &&\n options.context === this.attachedContext\n ) {\n this.cancelExit(this.overlayRef, this.pendingExit, options);\n return;\n }\n this.completeClose();\n }\n\n const config = this._config();\n this.focusOrigin = this.activeElement();\n this.explicitRestoreTarget = toElement(options.restoreFocusTo);\n\n const ref = createOverlayRef(\n this.injector,\n this.buildOverlayConfig(config),\n );\n this.overlayRef = ref;\n this.applyLayerStyles(ref, config);\n\n if (content instanceof TemplateRef) {\n const viewContainerRef =\n options.viewContainerRef ?? this.hostViewContainerRef;\n if (!viewContainerRef) {\n ref.dispose();\n this.overlayRef = null;\n throw new Error(\n 'AndesOverlayPrimitive: opening a TemplateRef needs a ViewContainerRef. ' +\n 'Provide the primitive on a component or directive, or pass ' +\n '`viewContainerRef` to open().',\n );\n }\n ref.attach(\n new TemplatePortal(content, viewContainerRef, options.context),\n );\n } else {\n ref.attach(\n new ComponentPortal(content, null, options.injector ?? this.injector),\n );\n }\n\n ref.addPanelClass([\n ANDES_OVERLAY_PANE_CLASS,\n ...toClassList(config.panelClass),\n ]);\n this.styleBackdrop(ref, config);\n this.attachedContent = content;\n this.attachedContext = options.context;\n this._panelElement.set(ref.overlayElement);\n this._backdropElement.set(ref.backdropElement);\n this._isOpen.set(true);\n\n this.applyInertBackground(ref, config);\n this.wireDismissal(ref);\n this.installFocusManagement(ref, config);\n\n this._opened.next();\n }\n\n /**\n * Closes the overlay. A no-op if already closed or closing.\n *\n * `isOpen()` turns `false` at once. If the closing attribute starts an exit\n * animation, the pane stays attached until it ends; focus restoration and the\n * `closed` emission follow the detach.\n */\n close(reason: AndesOverlayCloseReason = 'imperative'): void {\n this.beginClose(reason, true);\n }\n\n /** Opens the overlay if closed, closes it if open. */\n toggle<C>(\n content: AndesOverlayContent<C>,\n options: AndesOverlayOpenOptions<C> = {},\n ): void {\n if (this._isOpen()) {\n this.close('trigger');\n } else {\n this.open(content, options);\n }\n }\n\n /** Recomputes the overlay's position. Cheap to call on resize or content change. */\n updatePosition(): void {\n this.overlayRef?.updatePosition();\n }\n\n /**\n * Moves focus to the first tabbable element inside the overlay. Exposed for\n * consumers that focus lazily — a Dropdown Menu opened by keyboard, say.\n */\n focusFirstTabbable(): void {\n this.focusTrap?.focusFirstTabbableElementWhenReady();\n }\n\n private beginClose(reason: AndesOverlayCloseReason, animate: boolean): void {\n if (!this._isOpen()) {\n return;\n }\n this._isOpen.set(false);\n\n this.openSubscriptions.unsubscribe();\n this.openSubscriptions = new Subscription();\n\n // Before restoring focus: an element inside an inert subtree cannot be\n // focused, so releasing late would silently drop focus on `document.body`.\n // Released at once rather than after the exit, so the page responds while\n // the overlay fades out.\n this.releaseInertBackground();\n\n this.focusTrap?.destroy();\n this.focusTrap = null;\n\n const exit: AndesOverlayPendingExit = {\n reason,\n restoreFocus: this._config().restoreFocus,\n marked: [],\n pointerEvents: new Map(),\n subscription: new Subscription(),\n timer: null,\n };\n this.pendingExit = exit;\n\n const ref = this.overlayRef;\n const running = ref && animate ? this.startExit(ref, exit) : [];\n if (!ref || running.length === 0) {\n this.completeClose();\n return;\n }\n\n const settle = () => {\n if (this.pendingExit === exit) {\n this.completeClose();\n }\n };\n // Something else detaching the overlay mid-exit (navigation, the content\n // view being destroyed) ends the wait.\n exit.subscription.add(ref.detachments().subscribe(settle));\n exit.timer = setTimeout(settle, ANDES_OVERLAY_EXIT_TIMEOUT_MS);\n void Promise.allSettled(\n running.map((animation) => animation.finished),\n ).then(settle);\n }\n\n /**\n * Marks the pane, its direct element children and the backdrop as closing and\n * returns the animations that marking started. Nothing is marked when the exit\n * would be skipped anyway: reduced motion, or no `getAnimations` (SSR, jsdom).\n */\n private startExit(\n ref: OverlayRef,\n exit: AndesOverlayPendingExit,\n ): Animation[] {\n const pane = ref.overlayElement;\n const backdrop = ref.backdropElement;\n if (\n typeof pane.getAnimations !== 'function' ||\n this.prefersReducedMotion()\n ) {\n return [];\n }\n\n const targets: Element[] = [pane, ...Array.from(pane.children)];\n if (backdrop) {\n targets.push(backdrop);\n }\n for (const target of targets) {\n target.setAttribute(ANDES_OVERLAY_CLOSING_ATTRIBUTE, '');\n exit.marked.push(target);\n }\n for (const element of [pane, backdrop]) {\n if (element) {\n exit.pointerEvents.set(\n element,\n element.style.getPropertyValue('pointer-events'),\n );\n element.style.setProperty('pointer-events', 'none');\n }\n }\n\n // `getAnimations()` flushes pending style changes, so animations and\n // transitions the attribute just triggered are already reported here.\n const animations = [\n ...pane.getAnimations({ subtree: true }),\n ...(backdrop?.getAnimations() ?? []),\n ];\n return animations.filter(isSettling);\n }\n\n /** Re-opening during the exit: undo the close on the pane that is still there. */\n private cancelExit<C>(\n ref: OverlayRef,\n exit: AndesOverlayPendingExit,\n options: AndesOverlayOpenOptions<C>,\n ): void {\n this.pendingExit = null;\n if (exit.timer !== null) {\n clearTimeout(exit.timer);\n }\n exit.subscription.unsubscribe();\n for (const element of exit.marked) {\n element.removeAttribute(ANDES_OVERLAY_CLOSING_ATTRIBUTE);\n }\n for (const [element, value] of exit.pointerEvents) {\n if (value) {\n element.style.setProperty('pointer-events', value);\n } else {\n element.style.removeProperty('pointer-events');\n }\n }\n\n const config = this._config();\n const pane = ref.overlayElement;\n // Focus usually never left the pane during the exit; then the original\n // origin is still the right place to return to later.\n const active = this.activeElement();\n const focusInside = !!active && pane.contains(active);\n if (active && !focusInside) {\n this.focusOrigin = active;\n }\n this.explicitRestoreTarget = toElement(options.restoreFocusTo);\n this._isOpen.set(true);\n\n this.applyInertBackground(ref, config);\n this.wireDismissal(ref);\n this.installFocusManagement(ref, config, !focusInside);\n }\n\n /** Detaches the overlay and finishes a requested close. */\n private completeClose(): void {\n const exit = this.pendingExit;\n if (!exit) {\n return;\n }\n this.pendingExit = null;\n // Only a close that actually waited on an exit animation can have lost focus\n // to the page in the meantime; measured while the pane is still attached.\n const focusMovedAway =\n exit.timer !== null && this.focusMovedOutside(this.overlayRef);\n if (exit.timer !== null) {\n clearTimeout(exit.timer);\n }\n exit.subscription.unsubscribe();\n\n this.overlayRef?.dispose();\n this.overlayRef = null;\n this.attachedContent = null;\n this.attachedContext = undefined;\n\n this._panelElement.set(null);\n this._backdropElement.set(null);\n this._contentElement.set(null);\n\n // Someone clicked or tabbed to something else on the page while the overlay\n // was fading out: pulling focus back to the trigger would undo that.\n if (exit.restoreFocus && !focusMovedAway) {\n this.restoreFocus();\n }\n this.focusOrigin = null;\n this.explicitRestoreTarget = null;\n\n this._closed.next(exit.reason);\n }\n\n /**\n * Whether focus now sits on a page element outside the pane. Focus inside the\n * pane (an Escape or close-button close) or dropped on `body` still restores.\n */\n private focusMovedOutside(ref: OverlayRef | null): boolean {\n const active = this.activeElement();\n if (!ref || !active || active === this.document.body) {\n return false;\n }\n return !ref.overlayElement.contains(active);\n }\n\n private prefersReducedMotion(): boolean {\n const view = this.document.defaultView;\n return (\n typeof view?.matchMedia === 'function' &&\n view.matchMedia('(prefers-reduced-motion: reduce)').matches\n );\n }\n\n private buildOverlayConfig(config: AndesOverlayConfig): OverlayConfig {\n return {\n positionStrategy: createAndesPositionStrategy(\n this.injector,\n config.positioning,\n this._anchor(),\n ),\n scrollStrategy: this.buildScrollStrategy(config),\n hasBackdrop: config.hasBackdrop,\n backdropClass: [\n ANDES_OVERLAY_BACKDROP_CLASS,\n ...toClassList(config.backdropClass),\n ],\n disposeOnNavigation: config.disposeOnNavigation,\n // Never use the native top layer: `popover` ignores `z-index` and orders by\n // call time, which would make the `--andes-z-index-*` scale meaningless.\n usePopover: false,\n ...andesImpliedSize(config.positioning),\n ...this.anchorWidth(config),\n ...config.size,\n };\n }\n\n private anchorWidth(\n config: AndesOverlayConfig,\n ): Pick<AndesOverlayConfig['size'], 'width'> {\n const anchor = this._anchor();\n const positioning = config.positioning;\n if (positioning.kind !== 'anchored' || !positioning.matchAnchorWidth) {\n return {};\n }\n return anchor ? { width: anchor.getBoundingClientRect().width } : {};\n }\n\n private buildScrollStrategy(config: AndesOverlayConfig): ScrollStrategy {\n if (config.lockScroll) {\n // CDK's block strategy is safe to nest: an inner overlay sees the scroll\n // block already applied, declines to re-apply it, and so cannot release it\n // early when it closes. The outermost overlay owns the lock.\n return createBlockScrollStrategy(this.injector);\n }\n if (config.repositionOnScroll) {\n return createRepositionScrollStrategy(this.injector);\n }\n return createNoopScrollStrategy();\n }\n\n private applyLayerStyles(ref: OverlayRef, config: AndesOverlayConfig): void {\n const zIndex = andesOverlayZIndex(config.layer);\n // CDK declares its own `z-index: 1000` inside `@layer cdk-overlay`, so an\n // unlayered inline value always wins without `!important`.\n ref.hostElement.style.setProperty('z-index', zIndex);\n ref.backdropElement?.style.setProperty('z-index', zIndex);\n }\n\n private styleBackdrop(ref: OverlayRef, config: AndesOverlayConfig): void {\n const backdrop = ref.backdropElement;\n if (!backdrop) {\n return;\n }\n backdrop.style.setProperty('z-index', andesOverlayZIndex(config.layer));\n backdrop.style.setProperty('background', ANDES_OVERLAY_SCRIM);\n }\n\n private wireDismissal(ref: OverlayRef): void {\n this.openSubscriptions.add(\n ref.keydownEvents().subscribe((event) => {\n this._keydown.next(event);\n if (\n event.keyCode !== ESCAPE ||\n hasModifierKey(event) ||\n !this._config().closeOnEscape\n ) {\n return;\n }\n event.preventDefault();\n this.close('escape-key');\n }),\n );\n\n this.openSubscriptions.add(\n ref.outsidePointerEvents().subscribe((event) => {\n this._outsidePointer.next(event);\n if (!this._config().closeOnOutsideClick) {\n return;\n }\n const target = event.target as Node | null;\n // A click on the trigger is the trigger's own business — closing here as\n // well would fight its toggle and leave the overlay flickering.\n const anchor = this._anchor();\n if (anchor && target && anchor.contains(target)) {\n return;\n }\n // The backdrop is technically \"outside\" the pane, but it has its own,\n // more precise close reason.\n if (target && ref.backdropElement?.contains(target)) {\n return;\n }\n this.close('outside-click');\n }),\n );\n\n this.openSubscriptions.add(\n ref.backdropClick().subscribe(() => {\n if (this._config().closeOnOutsideClick) {\n this.close('backdrop-click');\n }\n }),\n );\n\n // Safety net: something else detached the overlay (navigation, the content\n // view being destroyed). Run our own teardown so focus is still restored and\n // `isOpen` does not lie.\n this.openSubscriptions.add(\n ref.detachments().subscribe(() => this.beginClose('destroyed', false)),\n );\n }\n\n /**\n * Makes the page outside the overlay inert, so AT browsing the document — not\n * just tabbing through it — cannot reach content behind a modal. That includes\n * overlays already open beneath it in the same CDK container (an outer dialog).\n * The pane and backdrop are exempt, and the registry reference-counts across\n * nested overlays.\n */\n private applyInertBackground(\n ref: OverlayRef,\n config: AndesOverlayConfig,\n ): void {\n if (!config.inertBackground) {\n return;\n }\n this.inertHandle = this.inertRegistry.inertBackgroundExcept([\n ref.overlayElement,\n ref.hostElement,\n ref.backdropElement,\n ]);\n this._isBackgroundInert.set(true);\n }\n\n private releaseInertBackground(): void {\n this.inertHandle?.release();\n this.inertHandle = null;\n this._isBackgroundInert.set(false);\n }\n\n private installFocusManagement(\n ref: OverlayRef,\n config: AndesOverlayConfig,\n moveFocus = true,\n ): void {\n const needsTrapObject =\n config.trapFocus || config.autoFocus === 'first-tabbable';\n\n if (needsTrapObject) {\n // The trap brackets the whole pane, not just the content element, so a\n // consumer that renders siblings next to its content cannot leak focus.\n this.focusTrap = this.focusTrapFactory.create(ref.overlayElement);\n this.focusTrap.enabled = config.trapFocus;\n }\n\n if (!moveFocus) {\n return;\n }\n\n switch (config.autoFocus) {\n case 'first-tabbable':\n this.focusTrap?.focusInitialElementWhenReady();\n break;\n case 'container':\n ref.overlayElement.setAttribute('tabindex', '-1');\n ref.overlayElement.focus();\n break;\n case 'none':\n break;\n }\n }\n\n /**\n * Focus goes back to, in order: an explicit `restoreFocusTo`, the registered\n * trigger, the element that was focused when the overlay opened. Each candidate\n * is skipped if it is no longer in the document — a trigger inside a list row\n * that the overlay's own action deleted, say. If none survive, focus is left to\n * the browser's own fallback (`document.body`).\n */\n private restoreFocus(): void {\n const candidates = [\n this.explicitRestoreTarget,\n this._anchor(),\n this.focusOrigin,\n ];\n const target = candidates.find(\n (candidate): candidate is HTMLElement =>\n !!candidate && candidate.isConnected,\n );\n target?.focus();\n }\n\n private activeElement(): HTMLElement | null {\n const active = this.document.activeElement;\n return active instanceof HTMLElement ? active : null;\n }\n}\n\n/**\n * Providers a compound overlay component puts in its own `providers` array to own\n * one overlay instance, scoped to itself and injectable by its sub-directives.\n */\nexport function provideAndesOverlay(): Provider[] {\n return [AndesOverlayPrimitive];\n}\n","import { computed, Directive, ElementRef, inject, input } from '@angular/core';\n\nimport { AndesOverlayPrimitive } from './overlay-primitive';\n\n/**\n * How a trigger advertises its overlay to assistive tech.\n *\n * - `expanded` — `aria-haspopup` + `aria-expanded` + `aria-controls`. Correct for\n * Dialog, Drawer, Popover and Dropdown Menu, where the trigger opens something\n * the user then interacts with.\n * - `described-by` — `aria-describedby` pointing at the overlay. Correct for\n * Tooltip: the overlay describes the trigger, it is not a thing you open.\n * - `none` — the consumer wires its own ARIA.\n */\nexport type AndesOverlayAriaAttachment = 'expanded' | 'described-by' | 'none';\n\n/**\n * Marks an element as an overlay's trigger. Registers it as the positioning anchor\n * and as the element focus returns to on close, and keeps its ARIA state in sync.\n *\n * It intentionally does *not* bind a click handler: whether the overlay opens on\n * click, hover, focus or context menu is the consuming component's decision (and\n * differs across Dialog, Popover, Tooltip and Dropdown Menu). Call\n * `trigger.overlay.toggle(template)` from wherever that decision is made.\n */\n@Directive({\n selector: '[andesOverlayTrigger]',\n exportAs: 'andesOverlayTrigger',\n host: {\n '[attr.aria-haspopup]': 'ariaHasPopup()',\n '[attr.aria-expanded]': 'ariaExpanded()',\n '[attr.aria-controls]': 'ariaControls()',\n '[attr.aria-describedby]': 'ariaDescribedBy()',\n '[attr.data-state]': 'overlay.isOpen() ? \"open\" : \"closed\"',\n },\n})\nexport class AndesOverlayTriggerPrimitive {\n /** The overlay this trigger belongs to. */\n readonly overlay = inject(AndesOverlayPrimitive);\n\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n /** Which ARIA relationship to expose. Defaults to `expanded`. */\n readonly ariaAttachment = input<AndesOverlayAriaAttachment>('expanded');\n\n protected readonly ariaHasPopup = computed(() => {\n if (this.ariaAttachment() !== 'expanded') {\n return undefined;\n }\n const role = this.overlay.config().role;\n switch (role) {\n // `aria-haspopup=\"alertdialog\"` is not a valid token; `dialog` is.\n case 'alertdialog':\n return 'dialog';\n case 'dialog':\n case 'menu':\n case 'listbox':\n return role;\n default:\n return undefined;\n }\n });\n\n protected readonly ariaExpanded = computed(() =>\n this.ariaAttachment() === 'expanded'\n ? String(this.overlay.isOpen())\n : undefined,\n );\n\n protected readonly ariaControls = computed(() =>\n this.ariaAttachment() === 'expanded' && this.overlay.isOpen()\n ? this.overlay.contentId\n : undefined,\n );\n\n protected readonly ariaDescribedBy = computed(() =>\n this.ariaAttachment() === 'described-by' && this.overlay.isOpen()\n ? this.overlay.contentId\n : undefined,\n );\n\n constructor() {\n this.overlay.registerAnchor(this.elementRef);\n }\n}\n","import {\n computed,\n DestroyRef,\n Directive,\n ElementRef,\n inject,\n} from '@angular/core';\n\nimport { AndesOverlayPrimitive } from './overlay-primitive';\n\n/**\n * Marks the root element of an overlay's projected content. Applies the ARIA role\n * and the id the trigger points at, and reports the element back to the primitive\n * so consumers can measure or query it.\n *\n * The focus trap brackets the CDK pane rather than this element, so content can\n * safely render siblings (an arrow, a swipe handle) outside it.\n */\n@Directive({\n selector: '[andesOverlayContent]',\n exportAs: 'andesOverlayContent',\n host: {\n '[attr.id]': 'overlay.contentId',\n '[attr.role]': 'role()',\n '[attr.aria-modal]': 'ariaModal()',\n '[attr.tabindex]': 'tabIndex()',\n '[attr.data-state]': 'overlay.isOpen() ? \"open\" : \"closed\"',\n },\n})\nexport class AndesOverlayContentPrimitive {\n /** The overlay this content belongs to. */\n readonly overlay = inject(AndesOverlayPrimitive);\n\n private readonly elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n\n protected readonly role = computed(() => {\n const role = this.overlay.config().role;\n return role === 'none' ? undefined : role;\n });\n\n protected readonly ariaModal = computed(() =>\n this.overlay.config().ariaModal ? 'true' : undefined,\n );\n\n protected readonly tabIndex = computed(() =>\n this.overlay.config().autoFocus === 'container' ? '-1' : undefined,\n );\n\n constructor() {\n this.overlay.registerContent(this.elementRef);\n inject(DestroyRef).onDestroy(() => this.overlay.registerContent(null));\n }\n}\n","import { Directive, inject } from '@angular/core';\n\nimport { AndesOverlayPrimitive } from './overlay-primitive';\n\n/**\n * Closes the overlay when activated. Every modal overlay should render one of\n * these inside its content: Escape and outside-click are not reachable for touch\n * screen-reader users, so an in-content dismiss affordance is an accessibility\n * requirement, not a convenience.\n */\n@Directive({\n selector: '[andesOverlayClose]',\n exportAs: 'andesOverlayClose',\n host: {\n '(click)': 'close()',\n },\n})\nexport class AndesOverlayClosePrimitive {\n /** The overlay this control closes. */\n readonly overlay = inject(AndesOverlayPrimitive);\n\n protected close(): void {\n this.overlay.close('close-button');\n }\n}\n","import {\n booleanAttribute,\n computed,\n Directive,\n ElementRef,\n inject,\n input,\n OnDestroy,\n OnInit,\n Signal,\n} from '@angular/core';\n\nimport { AndesListNavigation } from './list-navigation';\nimport { AndesListNavigationItemRef } from './list-navigation-types';\n\nlet nextId = 0;\n\n/**\n * One navigable item inside a list governed by {@link AndesListNavigation}: an option, a\n * menu item or a tab. Registers itself with the parent on init and removes itself on\n * destroy, so `@if`/`@for`-driven lists and CDK-overlay popups work without any manual\n * bookkeeping.\n *\n * It manages only the mechanics of being navigable — the roving `tabindex`, a stable `id`\n * for `aria-activedescendant`, and `data-active`/`data-disabled` hooks for styling. Roles\n * and selection attributes (`role=\"option\"`, `aria-selected`, `aria-checked`) stay with the\n * consuming component.\n *\n * ```html\n * <button type=\"button\" andesListNavigationItem [disabled]=\"option.disabled\">\n * {{ option.label }}\n * </button>\n * ```\n */\n@Directive({\n selector: '[andesListNavigationItem]',\n host: {\n '[attr.id]': 'itemId',\n '[attr.tabindex]': 'tabIndex()',\n '[attr.data-active]': 'active() ? \"\" : null',\n '[attr.data-disabled]': 'disabled() ? \"\" : null',\n '(focusin)': 'onFocusin()',\n },\n})\nexport class AndesListNavigationItem\n implements AndesListNavigationItemRef, OnInit, OnDestroy\n{\n /** Whether the item is skipped while navigating. */\n readonly disabled = input(false, { transform: booleanAttribute });\n\n /**\n * Text typeahead matches against. Defaults to the item's own text content, which is\n * usually right; set it when the visible text is decorative or split across elements.\n */\n readonly typeaheadLabel = input<string>();\n\n /** @internal Mirrors {@link disabled} under the name the parent's item contract uses. */\n readonly isDisabled: Signal<boolean> = this.disabled;\n\n private readonly navigation = inject(AndesListNavigation);\n\n readonly element: HTMLElement =\n inject<ElementRef<HTMLElement>>(ElementRef).nativeElement;\n\n /** The item's DOM `id` — its own, when it has one, so authored ids are never clobbered. */\n readonly itemId: string =\n this.element.id || `andes-list-navigation-item-${nextId++}`;\n\n /** Whether this is the parent's active item. */\n readonly active = computed(() => this.navigation.activeItem() === this);\n\n /**\n * `0` on the one roving-tabindex target, `-1` on every other item, and absent entirely in\n * `active-descendant` mode, where items are not focusable at all.\n */\n protected readonly tabIndex = computed<number | null>(() => {\n if (this.navigation.focusMode() === 'active-descendant') {\n return null;\n }\n return this.navigation.rovingTabindexTarget() === this ? 0 : -1;\n });\n\n ngOnInit(): void {\n this.navigation.register(this);\n }\n\n ngOnDestroy(): void {\n this.navigation.unregister(this);\n }\n\n getLabel(): string {\n return this.typeaheadLabel() ?? (this.element.textContent ?? '').trim();\n }\n\n focus(): void {\n this.element.focus();\n }\n\n /**\n * The CDK's `Highlightable` hook, called only in `active-descendant` mode. Andes derives\n * the active *styling* from the parent's signal instead (see {@link active}), so that it\n * works identically in both focus modes; what is genuinely mode-specific is scrolling —\n * real focus never moves here, so the item has to bring itself into view.\n */\n setActiveStyles(): void {\n this.element.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });\n }\n\n /**\n * Counterpart to {@link setActiveStyles}. Nothing to undo: the active styling is derived\n * from the parent's signal, and scrolling is not reversible.\n */\n // eslint-disable-next-line @typescript-eslint/no-empty-function -- required by the CDK's `Highlightable` interface\n setInactiveStyles(): void {}\n\n /**\n * Keeps the roving `tabindex` on whichever item the user actually reached, including via\n * mouse or a direct Tab, so Tabbing away and back returns to the same place.\n */\n protected onFocusin(): void {\n if (\n this.navigation.focusMode() === 'roving-tabindex' &&\n this.navigation.activeItem() !== this\n ) {\n this.navigation.setActiveItemSilently(this);\n }\n }\n}\n","import { Directive, inject } from '@angular/core';\n\nimport { AndesListNavigation } from './list-navigation';\n\n/**\n * Wires the keyboard-owning element of a list to its {@link AndesListNavigation}: forwards\n * `keydown` to the key manager and publishes `aria-activedescendant` when the list is in\n * `active-descendant` mode.\n *\n * Put it on whichever element holds real DOM focus:\n *\n * - Tabs — the `role=\"tablist\"` element.\n * - Dropdown Menu — the `role=\"menu\"` popup.\n * - Select — the trigger while closed, or the `role=\"listbox\"` popup once focus moves into it.\n * - Combobox — the `<input>` itself, which keeps focus the whole time.\n *\n * It only consumes navigation keys, so the consumer is free to bind its own `keydown`\n * handler on the same element for `Enter`, `Space` and `Escape`.\n *\n * ```html\n * <input andesListNavigationKeys role=\"combobox\" (keydown.enter)=\"commit()\" />\n * ```\n */\n@Directive({\n selector: '[andesListNavigationKeys]',\n host: {\n '(keydown)': 'onKeydown($event)',\n '[attr.aria-activedescendant]': 'navigation.activeDescendantId()',\n },\n})\nexport class AndesListNavigationKeys {\n protected readonly navigation = inject(AndesListNavigation);\n\n protected onKeydown(event: KeyboardEvent): void {\n this.navigation.onKeydown(event);\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":["DOCUMENT_POSITION_DISCONNECTED","DOCUMENT_POSITION_PRECEDING","isPrintableCharacter","nextId","identity"],"mappings":";;;;;;;;;;;;MAuBa,oBAAoB,CAAA;IACtB,QAAQ,GAAG,KAAK,CAAC,KAAK,gFAAI,SAAS,EAAE,gBAAgB,EAAA,CAAG;AAE9C,IAAA,QAAQ,GAAG,MAAM,CAAC,aAAa,CAAC,KAAK,GAAG;AAE3D,IAAA,WAAA,GAAA;AACE,QAAA,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,MAAM,UAAU,GAAG,MAAM,EAAC,UAA6B,EAAC;AACxD,YAAA,SAAS,CAAa,UAAU,CAAC,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