@angular/cdk
Version:
Angular Material Component Development Kit
1 lines • 23.8 kB
Source Map (JSON)
{"version":3,"file":"_tree-key-manager-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/a11y/key-manager/tree-key-manager.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {InjectionToken, QueryList} from '@angular/core';\nimport {coerceObservable} from '../../coercion/private';\nimport {Observable, Subject, Subscription, isObservable, of as observableOf} from 'rxjs';\nimport {take} from 'rxjs/operators';\nimport {\n TreeKeyManagerFactory,\n TreeKeyManagerItem,\n TreeKeyManagerOptions,\n TreeKeyManagerStrategy,\n} from './tree-key-manager-strategy';\nimport {Typeahead} from './typeahead';\n\n/**\n * This class manages keyboard events for trees. If you pass it a QueryList or other list of tree\n * items, it will set the active item, focus, handle expansion and typeahead correctly when\n * keyboard events occur.\n */\nexport class TreeKeyManager<T extends TreeKeyManagerItem> implements TreeKeyManagerStrategy<T> {\n /** The index of the currently active (focused) item. */\n private _activeItemIndex = -1;\n /** The currently active (focused) item. */\n private _activeItem: T | null = null;\n /** Whether or not we activate the item when it's focused. */\n private _shouldActivationFollowFocus = false;\n /**\n * The orientation that the tree is laid out in. In `rtl` mode, the behavior of Left and\n * Right arrow are switched.\n */\n private _horizontalOrientation: 'ltr' | 'rtl' = 'ltr';\n\n /**\n * Predicate function that can be used to check whether an item should be skipped\n * by the key manager.\n *\n * The default value for this doesn't skip any elements in order to keep tree items focusable\n * when disabled. This aligns with ARIA guidelines:\n * https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#focusabilityofdisabledcontrols.\n */\n private _skipPredicateFn = (_item: T) => false;\n\n /** Function to determine equivalent items. */\n private _trackByFn: (item: T) => unknown = (item: T) => item;\n\n /** Synchronous cache of the items to manage. */\n private _items: T[] = [];\n\n private _typeahead?: Typeahead<T>;\n private _typeaheadSubscription = Subscription.EMPTY;\n\n private _hasInitialFocused = false;\n\n private _initializeFocus(): void {\n if (this._hasInitialFocused || this._items.length === 0) {\n return;\n }\n\n let activeIndex = 0;\n for (let i = 0; i < this._items.length; i++) {\n if (!this._skipPredicateFn(this._items[i]) && !this._isItemDisabled(this._items[i])) {\n activeIndex = i;\n break;\n }\n }\n\n const activeItem = this._items[activeIndex];\n\n // Use `makeFocusable` here, because we want the item to just be focusable, not actually\n // capture the focus since the user isn't interacting with it. See #29628.\n if (activeItem.makeFocusable) {\n this._activeItem?.unfocus();\n this._activeItemIndex = activeIndex;\n this._activeItem = activeItem;\n this._typeahead?.setCurrentSelectedItemIndex(activeIndex);\n activeItem.makeFocusable();\n } else {\n // Backwards compatibility for items that don't implement `makeFocusable`.\n this.focusItem(activeIndex);\n }\n\n this._hasInitialFocused = true;\n }\n\n /**\n *\n * @param items List of TreeKeyManager options. Can be synchronous or asynchronous.\n * @param config Optional configuration options. By default, use 'ltr' horizontal orientation. By\n * default, do not skip any nodes. By default, key manager only calls `focus` method when items\n * are focused and does not call `activate`. If `typeaheadDefaultInterval` is `true`, use a\n * default interval of 200ms.\n */\n constructor(items: Observable<T[]> | QueryList<T> | T[], config: TreeKeyManagerOptions<T>) {\n // We allow for the items to be an array or Observable because, in some cases, the consumer may\n // not have access to a QueryList of the items they want to manage (e.g. when the\n // items aren't being collected via `ViewChildren` or `ContentChildren`).\n if (items instanceof QueryList) {\n this._items = items.toArray();\n items.changes.subscribe((newItems: QueryList<T>) => {\n this._items = newItems.toArray();\n this._typeahead?.setItems(this._items);\n this._updateActiveItemIndex(this._items);\n this._initializeFocus();\n });\n } else if (isObservable(items)) {\n items.subscribe(newItems => {\n this._items = newItems;\n this._typeahead?.setItems(newItems);\n this._updateActiveItemIndex(newItems);\n this._initializeFocus();\n });\n } else {\n this._items = items;\n this._initializeFocus();\n }\n\n if (typeof config.shouldActivationFollowFocus === 'boolean') {\n this._shouldActivationFollowFocus = config.shouldActivationFollowFocus;\n }\n if (config.horizontalOrientation) {\n this._horizontalOrientation = config.horizontalOrientation;\n }\n if (config.skipPredicate) {\n this._skipPredicateFn = config.skipPredicate;\n }\n if (config.trackBy) {\n this._trackByFn = config.trackBy;\n }\n if (typeof config.typeAheadDebounceInterval !== 'undefined') {\n this._setTypeAhead(config.typeAheadDebounceInterval);\n }\n }\n\n /** Stream that emits any time the focused item changes. */\n readonly change = new Subject<T | null>();\n\n /** Cleans up the key manager. */\n destroy() {\n this._typeaheadSubscription.unsubscribe();\n this._typeahead?.destroy();\n this.change.complete();\n }\n\n /**\n * Handles a keyboard event on the tree.\n * @param event Keyboard event that represents the user interaction with the tree.\n */\n onKeydown(event: KeyboardEvent) {\n const key = event.key;\n\n switch (key) {\n case 'Tab':\n // Return early here, in order to allow Tab to actually tab out of the tree\n return;\n\n case 'ArrowDown':\n this._focusNextItem();\n break;\n\n case 'ArrowUp':\n this._focusPreviousItem();\n break;\n\n case 'ArrowRight':\n this._horizontalOrientation === 'rtl'\n ? this._collapseCurrentItem()\n : this._expandCurrentItem();\n break;\n\n case 'ArrowLeft':\n this._horizontalOrientation === 'rtl'\n ? this._expandCurrentItem()\n : this._collapseCurrentItem();\n break;\n\n case 'Home':\n this._focusFirstItem();\n break;\n\n case 'End':\n this._focusLastItem();\n break;\n\n case 'Enter':\n case ' ':\n this._activateCurrentItem();\n break;\n\n default:\n if (event.key === '*') {\n this._expandAllItemsAtCurrentItemLevel();\n break;\n }\n\n this._typeahead?.handleKey(event);\n // Return here, in order to avoid preventing the default action of non-navigational\n // keys or resetting the buffer of pressed letters.\n return;\n }\n\n // Reset the typeahead since the user has used a navigational key.\n this._typeahead?.reset();\n event.preventDefault();\n }\n\n /** Index of the currently active item. */\n getActiveItemIndex(): number | null {\n return this._activeItemIndex;\n }\n\n /** The currently active item. */\n getActiveItem(): T | null {\n return this._activeItem;\n }\n\n /** Focus the first available item. */\n private _focusFirstItem(): void {\n this.focusItem(this._findNextAvailableItemIndex(-1));\n }\n\n /** Focus the last available item. */\n private _focusLastItem(): void {\n this.focusItem(this._findPreviousAvailableItemIndex(this._items.length));\n }\n\n /** Focus the next available item. */\n private _focusNextItem(): void {\n this.focusItem(this._findNextAvailableItemIndex(this._activeItemIndex));\n }\n\n /** Focus the previous available item. */\n private _focusPreviousItem(): void {\n this.focusItem(this._findPreviousAvailableItemIndex(this._activeItemIndex));\n }\n\n /**\n * Focus the provided item by index.\n * @param index The index of the item to focus.\n * @param options Additional focusing options.\n */\n focusItem(index: number, options?: {emitChangeEvent?: boolean}): void;\n focusItem(item: T, options?: {emitChangeEvent?: boolean}): void;\n focusItem(itemOrIndex: number | T, options?: {emitChangeEvent?: boolean}): void;\n focusItem(itemOrIndex: number | T, options: {emitChangeEvent?: boolean} = {}) {\n // Set default options\n options.emitChangeEvent ??= true;\n\n let index =\n typeof itemOrIndex === 'number'\n ? itemOrIndex\n : this._items.findIndex(item => this._trackByFn(item) === this._trackByFn(itemOrIndex));\n if (index < 0 || index >= this._items.length) {\n return;\n }\n const activeItem = this._items[index];\n\n // If we're just setting the same item, don't re-call activate or focus\n if (\n this._activeItem !== null &&\n this._trackByFn(activeItem) === this._trackByFn(this._activeItem)\n ) {\n return;\n }\n\n const previousActiveItem = this._activeItem;\n this._activeItem = activeItem ?? null;\n this._activeItemIndex = index;\n this._typeahead?.setCurrentSelectedItemIndex(index);\n\n this._activeItem?.focus();\n previousActiveItem?.unfocus();\n\n if (options.emitChangeEvent) {\n this.change.next(this._activeItem);\n }\n\n if (this._shouldActivationFollowFocus) {\n this._activateCurrentItem();\n }\n }\n\n private _updateActiveItemIndex(newItems: T[]) {\n const activeItem = this._activeItem;\n if (!activeItem) {\n return;\n }\n\n const newIndex = newItems.findIndex(\n item => this._trackByFn(item) === this._trackByFn(activeItem),\n );\n\n if (newIndex > -1 && newIndex !== this._activeItemIndex) {\n this._activeItemIndex = newIndex;\n this._typeahead?.setCurrentSelectedItemIndex(newIndex);\n }\n }\n\n private _setTypeAhead(debounceInterval: number | boolean) {\n this._typeahead = new Typeahead(this._items, {\n debounceInterval: typeof debounceInterval === 'number' ? debounceInterval : undefined,\n skipPredicate: item => this._skipPredicateFn(item),\n });\n\n this._typeaheadSubscription = this._typeahead.selectedItem.subscribe(item => {\n this.focusItem(item);\n });\n }\n\n private _findNextAvailableItemIndex(startingIndex: number) {\n for (let i = startingIndex + 1; i < this._items.length; i++) {\n if (!this._skipPredicateFn(this._items[i])) {\n return i;\n }\n }\n return startingIndex;\n }\n\n private _findPreviousAvailableItemIndex(startingIndex: number) {\n for (let i = startingIndex - 1; i >= 0; i--) {\n if (!this._skipPredicateFn(this._items[i])) {\n return i;\n }\n }\n return startingIndex;\n }\n\n /**\n * If the item is already expanded, we collapse the item. Otherwise, we will focus the parent.\n */\n private _collapseCurrentItem() {\n if (!this._activeItem) {\n return;\n }\n\n if (this._isCurrentItemExpanded()) {\n this._activeItem.collapse();\n } else {\n const parent = this._activeItem.getParent();\n if (!parent || this._skipPredicateFn(parent as T)) {\n return;\n }\n this.focusItem(parent as T);\n }\n }\n\n /**\n * If the item is already collapsed, we expand the item. Otherwise, we will focus the first child.\n */\n private _expandCurrentItem() {\n if (!this._activeItem) {\n return;\n }\n\n if (!this._isCurrentItemExpanded()) {\n this._activeItem.expand();\n } else {\n coerceObservable(this._activeItem.getChildren())\n .pipe(take(1))\n .subscribe(children => {\n const firstChild = children.find(child => !this._skipPredicateFn(child as T));\n if (!firstChild) {\n return;\n }\n this.focusItem(firstChild as T);\n });\n }\n }\n\n private _isCurrentItemExpanded() {\n if (!this._activeItem) {\n return false;\n }\n return typeof this._activeItem.isExpanded === 'boolean'\n ? this._activeItem.isExpanded\n : this._activeItem.isExpanded();\n }\n\n private _isItemDisabled(item: TreeKeyManagerItem) {\n return typeof item.isDisabled === 'boolean' ? item.isDisabled : item.isDisabled?.();\n }\n\n /** For all items that are the same level as the current item, we expand those items. */\n private _expandAllItemsAtCurrentItemLevel() {\n if (!this._activeItem) {\n return;\n }\n\n const parent = this._activeItem.getParent();\n let itemsToExpand;\n if (!parent) {\n itemsToExpand = observableOf(this._items.filter(item => item.getParent() === null));\n } else {\n itemsToExpand = coerceObservable(parent.getChildren());\n }\n\n itemsToExpand.pipe(take(1)).subscribe(items => {\n for (const item of items) {\n item.expand();\n }\n });\n }\n\n private _activateCurrentItem() {\n this._activeItem?.activate();\n }\n}\n\n/** Injection token that determines the key manager to use. */\nexport const TREE_KEY_MANAGER = new InjectionToken<TreeKeyManagerFactory<any>>('tree-key-manager', {\n providedIn: 'root',\n factory: () => (items, options) => new TreeKeyManager(items, options),\n});\n"],"names":["TreeKeyManager","_activeItemIndex","_activeItem","_shouldActivationFollowFocus","_horizontalOrientation","_skipPredicateFn","_item","_trackByFn","item","_items","_typeahead","_typeaheadSubscription","Subscription","EMPTY","_hasInitialFocused","_initializeFocus","length","activeIndex","i","_isItemDisabled","activeItem","makeFocusable","unfocus","setCurrentSelectedItemIndex","focusItem","constructor","items","config","QueryList","toArray","changes","subscribe","newItems","setItems","_updateActiveItemIndex","isObservable","shouldActivationFollowFocus","horizontalOrientation","skipPredicate","trackBy","typeAheadDebounceInterval","_setTypeAhead","change","Subject","destroy","unsubscribe","complete","onKeydown","event","key","_focusNextItem","_focusPreviousItem","_collapseCurrentItem","_expandCurrentItem","_focusFirstItem","_focusLastItem","_activateCurrentItem","_expandAllItemsAtCurrentItemLevel","handleKey","reset","preventDefault","getActiveItemIndex","getActiveItem","_findNextAvailableItemIndex","_findPreviousAvailableItemIndex","itemOrIndex","options","emitChangeEvent","index","findIndex","previousActiveItem","focus","next","newIndex","debounceInterval","Typeahead","undefined","selectedItem","startingIndex","_isCurrentItemExpanded","collapse","parent","getParent","expand","coerceObservable","getChildren","pipe","take","children","firstChild","find","child","isExpanded","isDisabled","itemsToExpand","observableOf","filter","activate","TREE_KEY_MANAGER","InjectionToken","providedIn","factory"],"mappings":";;;;;;MAyBaA,cAAc,CAAA;EAEjBC,gBAAgB,GAAG,CAAC,CAAC;AAErBC,EAAAA,WAAW,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