import type { FocusGroupItem } from "./focusgroup-items.js"; import type { FocusGroup } from "./focusgroup.js"; /** * @import { * FocusGroupItem, * FocusGroupUpdateInfo, * } from "./focusgroup-items.js" * @import { FocusGroup } from "./focusgroup.js" */ /** * The default `FocusGroupItemCollection` implementation used by the polyfill. * * Discovers items via a shadow-aware `TreeWalker`. After construction, call * `observe(focusGroup)` to start a `MutationObserver` on the owner subtree; * mutation batches are translated into `FocusGroupUpdateInfo` payloads * passed to `focusGroup.update()`, filtering out cross-group polyfill-managed * tabindex writes and owner-proxy noise. */ export declare class TreeWalkerItemCollection { #private; /** * Unique id used by `FocusGroup` to tag decorated items via the * `data-fg-item` attribute. Used here to disambiguate items of this group * from items of overlapping groups (possible via shadow-DOM slotting). * @type {string} */ id: string; /** * First descendant with the `focusgroupstart` attribute (shadow-aware), * or the first item as fallback, or `null` if none exist. `FocusGroup` * reads this to choose the initial tab stop after decoration. * @returns {HTMLElement | null} */ get start(): HTMLElement | null; /** * @param {HTMLElement!} owner - The focus group owner element. */ constructor(owner: HTMLElement); /** * Starts observing the owner subtree for mutations. Each relevant batch * is delivered to `focusGroup.update(info)`. Call this once, after the * paired `FocusGroup` has been constructed. * * @param {FocusGroup} focusGroup */ observe(focusGroup: FocusGroup): void; /** * Releases the mutation observer and removes it from the global flush * registry. Called from `FocusGroup#disconnect()`; safe to call directly. */ disconnect(): void; /** * Flushes this collection's mutation observer by calling `takeRecords()`, * dropping any pending records (typically caused by polyfill-managed * attribute writes during decoration). Called by `FocusGroup` after writing * `tabindex`/`data-fg-*` to avoid re-entering `#handleItemsMutate`. */ flush(): void; /** * Discovers items in the owner subtree and writes the marker attributes * (`data-fg-item`, `data-fg-seg`, `data-fg-segs`). Heavy walk — uses the * full candidacy filter (`isKeyboardFocusable` + ownership) and respects * nested-focusgroup opt-out subtrees and segmentor boundaries. * * After this call, `items()` will yield the marked items, and * `isItem()` / the persistent walker (used by `first/last/next/previous`) * will recognize them. */ decorate(): void; /** * Yields all items previously marked by `decorate()` in document order. * Light walk — iterates only `data-fg-item="${id}"` nodes via the * persistent walker (which rejects foreign-focusgroup subtrees). Reads * `segmentBoundary` from the DOM marker. * * @returns {Generator} */ items(): Generator; /** * Clears all marker attributes (`data-fg-item`, `data-fg-seg`, * `data-fg-segs`) written by `decorate()`. Light walk over marked nodes. */ undecorate(): void; /** * Whether `el` is the first item of a non-initial segment (i.e. the item * that immediately follows a segmentor in document order). * @param {HTMLElement} el * @returns {boolean} */ isSegmentStart(el: HTMLElement): boolean; /** * Whether `a` and `b` belong to the same segment. * @param {HTMLElement} a * @param {HTMLElement} b * @returns {boolean} */ sameSegment(a: HTMLElement, b: HTMLElement): boolean; /** @returns {HTMLElement | null} The first item, or null. */ first(): HTMLElement | null; /** @returns {HTMLElement | null} The last item, or null. */ last(): HTMLElement | null; /** * @param {HTMLElement} current * @returns {HTMLElement | null} */ next(current: HTMLElement): HTMLElement | null; /** * @param {HTMLElement} current * @returns {HTMLElement | null} */ previous(current: HTMLElement): HTMLElement | null; /** * @param {Element} element * @returns {boolean} Whether `element` is currently an item of this group. */ contains(element: Element): boolean; /** * Strict membership: is `element` currently a decorated item of *this* * collection? * @param {Element} element * @returns {boolean} */ isItem(element: Element): boolean; }