@angular/cdk 20.1.0-next.1 → 20.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/a11y/index.d.ts +6 -6
  2. package/{a11y-module.d-DBHGyKoh.d.ts → a11y-module.d--J1yhM7R.d.ts} +1 -1
  3. package/{activedescendant-key-manager.d-Bjic5obv.d.ts → activedescendant-key-manager.d-DLNLWTtr.d.ts} +8 -1
  4. package/dialog/index.d.ts +2 -2
  5. package/fesm2022/{a11y-module-DHa4AVFz.mjs → a11y-module-BPzgKr79.mjs} +2 -2
  6. package/fesm2022/{a11y-module-DHa4AVFz.mjs.map → a11y-module-BPzgKr79.mjs.map} +1 -1
  7. package/fesm2022/a11y.mjs +3 -3
  8. package/fesm2022/activedescendant-key-manager-CZAE5aFC.mjs.map +1 -1
  9. package/fesm2022/cdk.mjs +1 -1
  10. package/fesm2022/cdk.mjs.map +1 -1
  11. package/fesm2022/dialog.mjs +3 -3
  12. package/fesm2022/dialog.mjs.map +1 -1
  13. package/fesm2022/focus-key-manager-CPmlyB_c.mjs.map +1 -1
  14. package/fesm2022/{focus-monitor-DLjkiju1.mjs → focus-monitor-DUe99AIS.mjs} +5 -10
  15. package/fesm2022/focus-monitor-DUe99AIS.mjs.map +1 -0
  16. package/fesm2022/list-key-manager-C7tp3RbG.mjs.map +1 -1
  17. package/fesm2022/menu.mjs +38 -25
  18. package/fesm2022/menu.mjs.map +1 -1
  19. package/fesm2022/scrolling.mjs +1 -1
  20. package/fesm2022/scrolling.mjs.map +1 -1
  21. package/fesm2022/text-field.mjs +1 -1
  22. package/fesm2022/text-field.mjs.map +1 -1
  23. package/fesm2022/tree.mjs +1 -1
  24. package/fesm2022/tree.mjs.map +1 -1
  25. package/{focus-key-manager.d-BIKDy8oD.d.ts → focus-key-manager.d-DBw2_DcY.d.ts} +7 -2
  26. package/{focus-monitor.d-CvvJeQRc.d.ts → focus-monitor.d-2iZxjw4R.d.ts} +1 -3
  27. package/{list-key-manager.d-BlK3jyRn.d.ts → list-key-manager.d-CkFcwXee.d.ts} +5 -0
  28. package/listbox/index.d.ts +2 -2
  29. package/menu/index.d.ts +27 -17
  30. package/package.json +1 -1
  31. package/schematics/ng-add/index.js +1 -1
  32. package/stepper/index.d.ts +3 -3
  33. package/text-field/index.d.ts +1 -1
  34. package/fesm2022/focus-monitor-DLjkiju1.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"list-key-manager-C7tp3RbG.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/src/cdk/a11y/key-manager/list-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 {\n DOWN_ARROW,\n END,\n HOME,\n LEFT_ARROW,\n PAGE_DOWN,\n PAGE_UP,\n RIGHT_ARROW,\n TAB,\n UP_ARROW,\n hasModifierKey,\n} from '../../keycodes';\nimport {EffectRef, Injector, QueryList, Signal, effect, isSignal, signal} from '@angular/core';\nimport {Subject, Subscription} from 'rxjs';\nimport {Typeahead} from './typeahead';\n\n/** This interface is for items that can be passed to a ListKeyManager. */\nexport interface ListKeyManagerOption {\n /** Whether the option is disabled. */\n disabled?: boolean;\n\n /** Gets the label for this option. */\n getLabel?(): string;\n}\n\n/** Modifier keys handled by the ListKeyManager. */\nexport type ListKeyManagerModifierKey = 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey';\n\n/**\n * This class manages keyboard events for selectable lists. If you pass it a query list\n * of items, it will set the active item correctly when arrow events occur.\n */\nexport class ListKeyManager<T extends ListKeyManagerOption> {\n private _activeItemIndex = signal(-1);\n private _activeItem = signal<T | null>(null);\n private _wrap = false;\n private _typeaheadSubscription = Subscription.EMPTY;\n private _itemChangesSubscription?: Subscription;\n private _vertical = true;\n private _horizontal: 'ltr' | 'rtl' | null;\n private _allowedModifierKeys: ListKeyManagerModifierKey[] = [];\n private _homeAndEnd = false;\n private _pageUpAndDown = {enabled: false, delta: 10};\n private _effectRef: EffectRef | undefined;\n private _typeahead?: Typeahead<T>;\n\n /**\n * Predicate function that can be used to check whether an item should be skipped\n * by the key manager. By default, disabled items are skipped.\n */\n private _skipPredicateFn = (item: T) => item.disabled;\n\n constructor(items: QueryList<T> | T[] | readonly T[]);\n constructor(items: Signal<T[]> | Signal<readonly T[]>, injector: Injector);\n constructor(\n private _items: QueryList<T> | T[] | readonly T[] | Signal<T[]> | Signal<readonly T[]>,\n injector?: Injector,\n ) {\n // We allow for the items to be an array 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._itemChangesSubscription = _items.changes.subscribe((newItems: QueryList<T>) =>\n this._itemsChanged(newItems.toArray()),\n );\n } else if (isSignal(_items)) {\n if (!injector && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw new Error('ListKeyManager constructed with a signal must receive an injector');\n }\n\n this._effectRef = effect(() => this._itemsChanged(_items()), {injector});\n }\n }\n\n /**\n * Stream that emits any time the TAB key is pressed, so components can react\n * when focus is shifted off of the list.\n */\n readonly tabOut = new Subject<void>();\n\n /** Stream that emits whenever the active item of the list manager changes. */\n readonly change = new Subject<number>();\n\n /**\n * Sets the predicate function that determines which items should be skipped by the\n * list key manager.\n * @param predicate Function that determines whether the given item should be skipped.\n */\n skipPredicate(predicate: (item: T) => boolean): this {\n this._skipPredicateFn = predicate;\n return this;\n }\n\n /**\n * Configures wrapping mode, which determines whether the active item will wrap to\n * the other end of list when there are no more items in the given direction.\n * @param shouldWrap Whether the list should wrap when reaching the end.\n */\n withWrap(shouldWrap = true): this {\n this._wrap = shouldWrap;\n return this;\n }\n\n /**\n * Configures whether the key manager should be able to move the selection vertically.\n * @param enabled Whether vertical selection should be enabled.\n */\n withVerticalOrientation(enabled: boolean = true): this {\n this._vertical = enabled;\n return this;\n }\n\n /**\n * Configures the key manager to move the selection horizontally.\n * Passing in `null` will disable horizontal movement.\n * @param direction Direction in which the selection can be moved.\n */\n withHorizontalOrientation(direction: 'ltr' | 'rtl' | null): this {\n this._horizontal = direction;\n return this;\n }\n\n /**\n * Modifier keys which are allowed to be held down and whose default actions will be prevented\n * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.\n */\n withAllowedModifierKeys(keys: ListKeyManagerModifierKey[]): this {\n this._allowedModifierKeys = keys;\n return this;\n }\n\n /**\n * Turns on typeahead mode which allows users to set the active item by typing.\n * @param debounceInterval Time to wait after the last keystroke before setting the active item.\n */\n withTypeAhead(debounceInterval: number = 200): this {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const items = this._getItemsArray();\n if (items.length > 0 && items.some(item => typeof item.getLabel !== 'function')) {\n throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');\n }\n }\n\n this._typeaheadSubscription.unsubscribe();\n\n const items = this._getItemsArray();\n this._typeahead = new Typeahead(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.setActiveItem(item);\n });\n\n return this;\n }\n\n /** Cancels the current typeahead sequence. */\n cancelTypeahead(): this {\n this._typeahead?.reset();\n return this;\n }\n\n /**\n * Configures the key manager to activate the first and last items\n * respectively when the Home or End key is pressed.\n * @param enabled Whether pressing the Home or End key activates the first/last item.\n */\n withHomeAndEnd(enabled: boolean = true): this {\n this._homeAndEnd = enabled;\n return this;\n }\n\n /**\n * Configures the key manager to activate every 10th, configured or first/last element in up/down direction\n * respectively when the Page-Up or Page-Down key is pressed.\n * @param enabled Whether pressing the Page-Up or Page-Down key activates the first/last item.\n * @param delta Whether pressing the Home or End key activates the first/last item.\n */\n withPageUpDown(enabled: boolean = true, delta: number = 10): this {\n this._pageUpAndDown = {enabled, delta};\n return this;\n }\n\n /**\n * Sets the active item to the item at the index specified.\n * @param index The index of the item to be set as active.\n */\n setActiveItem(index: number): void;\n\n /**\n * Sets the active item to the specified item.\n * @param item The item to be set as active.\n */\n setActiveItem(item: T): void;\n\n setActiveItem(item: any): void {\n const previousActiveItem = this._activeItem();\n\n this.updateActiveItem(item);\n\n if (this._activeItem() !== previousActiveItem) {\n this.change.next(this._activeItemIndex());\n }\n }\n\n /**\n * Sets the active item depending on the key event passed in.\n * @param event Keyboard event to be used for determining which element should be active.\n */\n onKeydown(event: KeyboardEvent): void {\n const keyCode = event.keyCode;\n const modifiers: ListKeyManagerModifierKey[] = ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'];\n const isModifierAllowed = modifiers.every(modifier => {\n return !event[modifier] || this._allowedModifierKeys.indexOf(modifier) > -1;\n });\n\n switch (keyCode) {\n case TAB:\n this.tabOut.next();\n return;\n\n case DOWN_ARROW:\n if (this._vertical && isModifierAllowed) {\n this.setNextItemActive();\n break;\n } else {\n return;\n }\n\n case UP_ARROW:\n if (this._vertical && isModifierAllowed) {\n this.setPreviousItemActive();\n break;\n } else {\n return;\n }\n\n case RIGHT_ARROW:\n if (this._horizontal && isModifierAllowed) {\n this._horizontal === 'rtl' ? this.setPreviousItemActive() : this.setNextItemActive();\n break;\n } else {\n return;\n }\n\n case LEFT_ARROW:\n if (this._horizontal && isModifierAllowed) {\n this._horizontal === 'rtl' ? this.setNextItemActive() : this.setPreviousItemActive();\n break;\n } else {\n return;\n }\n\n case HOME:\n if (this._homeAndEnd && isModifierAllowed) {\n this.setFirstItemActive();\n break;\n } else {\n return;\n }\n\n case END:\n if (this._homeAndEnd && isModifierAllowed) {\n this.setLastItemActive();\n break;\n } else {\n return;\n }\n\n case PAGE_UP:\n if (this._pageUpAndDown.enabled && isModifierAllowed) {\n const targetIndex = this._activeItemIndex() - this._pageUpAndDown.delta;\n this._setActiveItemByIndex(targetIndex > 0 ? targetIndex : 0, 1);\n break;\n } else {\n return;\n }\n\n case PAGE_DOWN:\n if (this._pageUpAndDown.enabled && isModifierAllowed) {\n const targetIndex = this._activeItemIndex() + this._pageUpAndDown.delta;\n const itemsLength = this._getItemsArray().length;\n this._setActiveItemByIndex(targetIndex < itemsLength ? targetIndex : itemsLength - 1, -1);\n break;\n } else {\n return;\n }\n\n default:\n if (isModifierAllowed || hasModifierKey(event, 'shiftKey')) {\n this._typeahead?.handleKey(event);\n }\n\n // Note that we return here, in order to avoid preventing\n // the default action of non-navigational keys.\n return;\n }\n\n this._typeahead?.reset();\n event.preventDefault();\n }\n\n /** Index of the currently active item. */\n get activeItemIndex(): number | null {\n return this._activeItemIndex();\n }\n\n /** The active item. */\n get activeItem(): T | null {\n return this._activeItem();\n }\n\n /** Gets whether the user is currently typing into the manager using the typeahead feature. */\n isTyping(): boolean {\n return !!this._typeahead && this._typeahead.isTyping();\n }\n\n /** Sets the active item to the first enabled item in the list. */\n setFirstItemActive(): void {\n this._setActiveItemByIndex(0, 1);\n }\n\n /** Sets the active item to the last enabled item in the list. */\n setLastItemActive(): void {\n this._setActiveItemByIndex(this._getItemsArray().length - 1, -1);\n }\n\n /** Sets the active item to the next enabled item in the list. */\n setNextItemActive(): void {\n this._activeItemIndex() < 0 ? this.setFirstItemActive() : this._setActiveItemByDelta(1);\n }\n\n /** Sets the active item to a previous enabled item in the list. */\n setPreviousItemActive(): void {\n this._activeItemIndex() < 0 && this._wrap\n ? this.setLastItemActive()\n : this._setActiveItemByDelta(-1);\n }\n\n /**\n * Allows setting the active without any other effects.\n * @param index Index of the item to be set as active.\n */\n updateActiveItem(index: number): void;\n\n /**\n * Allows setting the active item without any other effects.\n * @param item Item to be set as active.\n */\n updateActiveItem(item: T): void;\n\n updateActiveItem(item: any): void {\n const itemArray = this._getItemsArray();\n const index = typeof item === 'number' ? item : itemArray.indexOf(item);\n const activeItem = itemArray[index];\n\n // Explicitly check for `null` and `undefined` because other falsy values are valid.\n this._activeItem.set(activeItem == null ? null : activeItem);\n this._activeItemIndex.set(index);\n this._typeahead?.setCurrentSelectedItemIndex(index);\n }\n\n /** Cleans up the key manager. */\n destroy() {\n this._typeaheadSubscription.unsubscribe();\n this._itemChangesSubscription?.unsubscribe();\n this._effectRef?.destroy();\n this._typeahead?.destroy();\n this.tabOut.complete();\n this.change.complete();\n }\n\n /**\n * This method sets the active item, given a list of items and the delta between the\n * currently active item and the new active item. It will calculate differently\n * depending on whether wrap mode is turned on.\n */\n private _setActiveItemByDelta(delta: -1 | 1): void {\n this._wrap ? this._setActiveInWrapMode(delta) : this._setActiveInDefaultMode(delta);\n }\n\n /**\n * Sets the active item properly given \"wrap\" mode. In other words, it will continue to move\n * down the list until it finds an item that is not disabled, and it will wrap if it\n * encounters either end of the list.\n */\n private _setActiveInWrapMode(delta: -1 | 1): void {\n const items = this._getItemsArray();\n\n for (let i = 1; i <= items.length; i++) {\n const index = (this._activeItemIndex() + delta * i + items.length) % items.length;\n const item = items[index];\n\n if (!this._skipPredicateFn(item)) {\n this.setActiveItem(index);\n return;\n }\n }\n }\n\n /**\n * Sets the active item properly given the default mode. In other words, it will\n * continue to move down the list until it finds an item that is not disabled. If\n * it encounters either end of the list, it will stop and not wrap.\n */\n private _setActiveInDefaultMode(delta: -1 | 1): void {\n this._setActiveItemByIndex(this._activeItemIndex() + delta, delta);\n }\n\n /**\n * Sets the active item to the first enabled item starting at the index specified. If the\n * item is disabled, it will move in the fallbackDelta direction until it either\n * finds an enabled item or encounters the end of the list.\n */\n private _setActiveItemByIndex(index: number, fallbackDelta: -1 | 1): void {\n const items = this._getItemsArray();\n\n if (!items[index]) {\n return;\n }\n\n while (this._skipPredicateFn(items[index])) {\n index += fallbackDelta;\n\n if (!items[index]) {\n return;\n }\n }\n\n this.setActiveItem(index);\n }\n\n /** Returns the items as an array. */\n private _getItemsArray(): T[] | readonly T[] {\n if (isSignal(this._items)) {\n return this._items();\n }\n\n return this._items instanceof QueryList ? this._items.toArray() : this._items;\n }\n\n /** Callback for when the items have changed. */\n private _itemsChanged(newItems: T[] | readonly T[]) {\n this._typeahead?.setItems(newItems);\n const activeItem = this._activeItem();\n if (activeItem) {\n const newIndex = newItems.indexOf(activeItem);\n\n if (newIndex > -1 && newIndex !== this._activeItemIndex()) {\n this._activeItemIndex.set(newIndex);\n this._typeahead?.setCurrentSelectedItemIndex(newIndex);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAoCA;;;AAGG;MACU,cAAc,CAAA;AAuBf,IAAA,MAAA;AAtBF,IAAA,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7B,IAAA,WAAW,GAAG,MAAM,CAAW,IAAI,CAAC;IACpC,KAAK,GAAG,KAAK;AACb,IAAA,sBAAsB,GAAG,YAAY,CAAC,KAAK;AAC3C,IAAA,wBAAwB;IACxB,SAAS,GAAG,IAAI;AAChB,IAAA,WAAW;IACX,oBAAoB,GAAgC,EAAE;IACtD,WAAW,GAAG,KAAK;IACnB,cAAc,GAAG,EAAC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAC;AAC5C,IAAA,UAAU;AACV,IAAA,UAAU;AAElB;;;AAGG;IACK,gBAAgB,GAAG,CAAC,IAAO,KAAK,IAAI,CAAC,QAAQ;IAIrD,WACU,CAAA,MAA8E,EACtF,QAAmB,EAAA;QADX,IAAM,CAAA,MAAA,GAAN,MAAM;;;;AAMd,QAAA,IAAI,MAAM,YAAY,SAAS,EAAE;YAC/B,IAAI,CAAC,wBAAwB,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,QAAsB,KAC9E,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CACvC;;AACI,aAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE;AAC3B,YAAA,IAAI,CAAC,QAAQ,KAAK,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,CAAC,EAAE;AAChE,gBAAA,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC;;YAGtF,IAAI,CAAC,UAAU,GAA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BAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE;YAC1C,KAAK,IAAI,aAAa;AAEtB,YAAA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACjB;;;AAIJ,QAAA,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC;;;IAInB,cAAc,GAAA;AACpB,QAAA,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;AACzB,YAAA,OAAO,IAAI,CAAC,MAAM,EAAE;;QAGtB,OAAO,IAAI,CAAC,MAAM,YAAY,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM;;;AAIvE,IAAA,aAAa,CAAC,QAA4B,EAAA;AAChD,QAAA,IAAI,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC;AACnC,QAAA,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE;QACrC,IAAI,UAAU,EAAE;YACd,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;AAE7C,YAAA,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAI,QAAQ,KAAK,IAAI,CAAC,gBAAgB,EAAE,EAAE;AACzD,gBAAA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;AACnC,gBAAA,IAAI,CAAC,UAAU,EAAE,2BAA2B,CAAC,QAAQ,CAAC;;;;AAI7D;;;;"}
1
+ {"version":3,"file":"list-key-manager-C7tp3RbG.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-46c76129e412/bin/src/cdk/a11y/key-manager/list-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 {\n DOWN_ARROW,\n END,\n HOME,\n LEFT_ARROW,\n PAGE_DOWN,\n PAGE_UP,\n RIGHT_ARROW,\n TAB,\n UP_ARROW,\n hasModifierKey,\n} from '../../keycodes';\nimport {EffectRef, Injector, QueryList, Signal, effect, isSignal, signal} from '@angular/core';\nimport {Subject, Subscription} from 'rxjs';\nimport {Typeahead} from './typeahead';\n\n/** This interface is for items that can be passed to a ListKeyManager. */\nexport interface ListKeyManagerOption {\n /** Whether the option is disabled. */\n disabled?: boolean;\n\n /** Gets the label for this option. */\n getLabel?(): string;\n}\n\n/** Modifier keys handled by the ListKeyManager. */\nexport type ListKeyManagerModifierKey = 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey';\n\n/**\n * This class manages keyboard events for selectable lists. If you pass it a query list\n * of items, it will set the active item correctly when arrow events occur.\n */\nexport class ListKeyManager<T extends ListKeyManagerOption> {\n private _activeItemIndex = signal(-1);\n private _activeItem = signal<T | null>(null);\n private _wrap = false;\n private _typeaheadSubscription = Subscription.EMPTY;\n private _itemChangesSubscription?: Subscription;\n private _vertical = true;\n private _horizontal: 'ltr' | 'rtl' | null;\n private _allowedModifierKeys: ListKeyManagerModifierKey[] = [];\n private _homeAndEnd = false;\n private _pageUpAndDown = {enabled: false, delta: 10};\n private _effectRef: EffectRef | undefined;\n private _typeahead?: Typeahead<T>;\n\n /**\n * Predicate function that can be used to check whether an item should be skipped\n * by the key manager. By default, disabled items are skipped.\n */\n private _skipPredicateFn = (item: T) => item.disabled;\n\n constructor(items: QueryList<T> | T[] | readonly T[]);\n constructor(items: Signal<T[]> | Signal<readonly T[]>, injector: Injector);\n constructor(\n private _items: QueryList<T> | T[] | readonly T[] | Signal<T[]> | Signal<readonly T[]>,\n injector?: Injector,\n ) {\n // We allow for the items to be an array 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._itemChangesSubscription = _items.changes.subscribe((newItems: QueryList<T>) =>\n this._itemsChanged(newItems.toArray()),\n );\n } else if (isSignal(_items)) {\n if (!injector && (typeof ngDevMode === 'undefined' || ngDevMode)) {\n throw new Error('ListKeyManager constructed with a signal must receive an injector');\n }\n\n this._effectRef = effect(() => this._itemsChanged(_items()), {injector});\n }\n }\n\n /**\n * Stream that emits any time the TAB key is pressed, so components can react\n * when focus is shifted off of the list.\n */\n readonly tabOut = new Subject<void>();\n\n /** Stream that emits whenever the active item of the list manager changes. */\n readonly change = new Subject<number>();\n\n /**\n * Sets the predicate function that determines which items should be skipped by the\n * list key manager.\n * @param predicate Function that determines whether the given item should be skipped.\n */\n skipPredicate(predicate: (item: T) => boolean): this {\n this._skipPredicateFn = predicate;\n return this;\n }\n\n /**\n * Configures wrapping mode, which determines whether the active item will wrap to\n * the other end of list when there are no more items in the given direction.\n * @param shouldWrap Whether the list should wrap when reaching the end.\n */\n withWrap(shouldWrap = true): this {\n this._wrap = shouldWrap;\n return this;\n }\n\n /**\n * Configures whether the key manager should be able to move the selection vertically.\n * @param enabled Whether vertical selection should be enabled.\n */\n withVerticalOrientation(enabled: boolean = true): this {\n this._vertical = enabled;\n return this;\n }\n\n /**\n * Configures the key manager to move the selection horizontally.\n * Passing in `null` will disable horizontal movement.\n * @param direction Direction in which the selection can be moved.\n */\n withHorizontalOrientation(direction: 'ltr' | 'rtl' | null): this {\n this._horizontal = direction;\n return this;\n }\n\n /**\n * Modifier keys which are allowed to be held down and whose default actions will be prevented\n * as the user is pressing the arrow keys. Defaults to not allowing any modifier keys.\n */\n withAllowedModifierKeys(keys: ListKeyManagerModifierKey[]): this {\n this._allowedModifierKeys = keys;\n return this;\n }\n\n /**\n * Turns on typeahead mode which allows users to set the active item by typing.\n * @param debounceInterval Time to wait after the last keystroke before setting the active item.\n */\n withTypeAhead(debounceInterval: number = 200): this {\n if (typeof ngDevMode === 'undefined' || ngDevMode) {\n const items = this._getItemsArray();\n if (items.length > 0 && items.some(item => typeof item.getLabel !== 'function')) {\n throw Error('ListKeyManager items in typeahead mode must implement the `getLabel` method.');\n }\n }\n\n this._typeaheadSubscription.unsubscribe();\n\n const items = this._getItemsArray();\n this._typeahead = new Typeahead(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.setActiveItem(item);\n });\n\n return this;\n }\n\n /** Cancels the current typeahead sequence. */\n cancelTypeahead(): this {\n this._typeahead?.reset();\n return this;\n }\n\n /**\n * Configures the key manager to activate the first and last items\n * respectively when the Home or End key is pressed.\n * @param enabled Whether pressing the Home or End key activates the first/last item.\n */\n withHomeAndEnd(enabled: boolean = true): this {\n this._homeAndEnd = enabled;\n return this;\n }\n\n /**\n * Configures the key manager to activate every 10th, configured or first/last element in up/down direction\n * respectively when the Page-Up or Page-Down key is pressed.\n * @param enabled Whether pressing the Page-Up or Page-Down key activates the first/last item.\n * @param delta Whether pressing the Home or End key activates the first/last item.\n */\n withPageUpDown(enabled: boolean = true, delta: number = 10): this {\n this._pageUpAndDown = {enabled, delta};\n return this;\n }\n\n /**\n * Sets the active item to the item at the index specified.\n * @param index The index of the item to be set as active.\n */\n setActiveItem(index: number): void;\n\n /**\n * Sets the active item to the specified item.\n * @param item The item to be set as active.\n */\n setActiveItem(item: T): void;\n\n /**\n * Sets the active item to the specified item.\n * @param item The item to be set as active.\n */\n setActiveItem(item: T | number): void;\n\n setActiveItem(item: any): void {\n const previousActiveItem = this._activeItem();\n\n this.updateActiveItem(item);\n\n if (this._activeItem() !== previousActiveItem) {\n this.change.next(this._activeItemIndex());\n }\n }\n\n /**\n * Sets the active item depending on the key event passed in.\n * @param event Keyboard event to be used for determining which element should be active.\n */\n onKeydown(event: KeyboardEvent): void {\n const keyCode = event.keyCode;\n const modifiers: ListKeyManagerModifierKey[] = ['altKey', 'ctrlKey', 'metaKey', 'shiftKey'];\n const isModifierAllowed = modifiers.every(modifier => {\n return !event[modifier] || this._allowedModifierKeys.indexOf(modifier) > -1;\n });\n\n switch (keyCode) {\n case TAB:\n this.tabOut.next();\n return;\n\n case DOWN_ARROW:\n if (this._vertical && isModifierAllowed) {\n this.setNextItemActive();\n break;\n } else {\n return;\n }\n\n case UP_ARROW:\n if (this._vertical && isModifierAllowed) {\n this.setPreviousItemActive();\n break;\n } else {\n return;\n }\n\n case RIGHT_ARROW:\n if (this._horizontal && isModifierAllowed) {\n this._horizontal === 'rtl' ? this.setPreviousItemActive() : this.setNextItemActive();\n break;\n } else {\n return;\n }\n\n case LEFT_ARROW:\n if (this._horizontal && isModifierAllowed) {\n this._horizontal === 'rtl' ? this.setNextItemActive() : this.setPreviousItemActive();\n break;\n } else {\n return;\n }\n\n case HOME:\n if (this._homeAndEnd && isModifierAllowed) {\n this.setFirstItemActive();\n break;\n } else {\n return;\n }\n\n case END:\n if (this._homeAndEnd && isModifierAllowed) {\n this.setLastItemActive();\n break;\n } else {\n return;\n }\n\n case PAGE_UP:\n if (this._pageUpAndDown.enabled && isModifierAllowed) {\n const targetIndex = this._activeItemIndex() - this._pageUpAndDown.delta;\n this._setActiveItemByIndex(targetIndex > 0 ? targetIndex : 0, 1);\n break;\n } else {\n return;\n }\n\n case PAGE_DOWN:\n if (this._pageUpAndDown.enabled && isModifierAllowed) {\n const targetIndex = this._activeItemIndex() + this._pageUpAndDown.delta;\n const itemsLength = this._getItemsArray().length;\n this._setActiveItemByIndex(targetIndex < itemsLength ? targetIndex : itemsLength - 1, -1);\n break;\n } else {\n return;\n }\n\n default:\n if (isModifierAllowed || hasModifierKey(event, 'shiftKey')) {\n this._typeahead?.handleKey(event);\n }\n\n // Note that we return here, in order to avoid preventing\n // the default action of non-navigational keys.\n return;\n }\n\n this._typeahead?.reset();\n event.preventDefault();\n }\n\n /** Index of the currently active item. */\n get activeItemIndex(): number | null {\n return this._activeItemIndex();\n }\n\n /** The active item. */\n get activeItem(): T | null {\n return this._activeItem();\n }\n\n /** Gets whether the user is currently typing into the manager using the typeahead feature. */\n isTyping(): boolean {\n return !!this._typeahead && this._typeahead.isTyping();\n }\n\n /** Sets the active item to the first enabled item in the list. */\n setFirstItemActive(): void {\n this._setActiveItemByIndex(0, 1);\n }\n\n /** Sets the active item to the last enabled item in the list. */\n setLastItemActive(): void {\n this._setActiveItemByIndex(this._getItemsArray().length - 1, -1);\n }\n\n /** Sets the active item to the next enabled item in the list. */\n setNextItemActive(): void {\n this._activeItemIndex() < 0 ? this.setFirstItemActive() : this._setActiveItemByDelta(1);\n }\n\n /** Sets the active item to a previous enabled item in the list. */\n setPreviousItemActive(): void {\n this._activeItemIndex() < 0 && this._wrap\n ? this.setLastItemActive()\n : this._setActiveItemByDelta(-1);\n }\n\n /**\n * Allows setting the active without any other effects.\n * @param index Index of the item to be set as active.\n */\n updateActiveItem(index: number): void;\n\n /**\n * Allows setting the active item without any other effects.\n * @param item Item to be set as active.\n */\n updateActiveItem(item: T): void;\n\n updateActiveItem(item: any): void {\n const itemArray = this._getItemsArray();\n const index = typeof item === 'number' ? item : itemArray.indexOf(item);\n const activeItem = itemArray[index];\n\n // Explicitly check for `null` and `undefined` because other falsy values are valid.\n this._activeItem.set(activeItem == null ? null : activeItem);\n this._activeItemIndex.set(index);\n this._typeahead?.setCurrentSelectedItemIndex(index);\n }\n\n /** Cleans up the key manager. */\n destroy() {\n this._typeaheadSubscription.unsubscribe();\n this._itemChangesSubscription?.unsubscribe();\n this._effectRef?.destroy();\n this._typeahead?.destroy();\n this.tabOut.complete();\n this.change.complete();\n }\n\n /**\n * This method sets the active item, given a list of items and the delta between the\n * currently active item and the new active item. It will calculate differently\n * depending on whether wrap mode is turned on.\n */\n private _setActiveItemByDelta(delta: -1 | 1): void {\n this._wrap ? this._setActiveInWrapMode(delta) : this._setActiveInDefaultMode(delta);\n }\n\n /**\n * Sets the active item properly given \"wrap\" mode. In other words, it will continue to move\n * down the list until it finds an item that is not disabled, and it will wrap if it\n * encounters either end of the list.\n */\n private _setActiveInWrapMode(delta: -1 | 1): void {\n const items = this._getItemsArray();\n\n for (let i = 1; i <= items.length; i++) {\n const index = (this._activeItemIndex() + delta * i + items.length) % items.length;\n const item = items[index];\n\n if (!this._skipPredicateFn(item)) {\n this.setActiveItem(index);\n return;\n }\n }\n }\n\n /**\n * Sets the active item properly given the default mode. In other words, it will\n * continue to move down the list until it finds an item that is not disabled. If\n * it encounters either end of the list, it will stop and not wrap.\n */\n private _setActiveInDefaultMode(delta: -1 | 1): void {\n this._setActiveItemByIndex(this._activeItemIndex() + delta, delta);\n }\n\n /**\n * Sets the active item to the first enabled item starting at the index specified. If the\n * item is disabled, it will move in the fallbackDelta direction until it either\n * finds an enabled item or encounters the end of the list.\n */\n private _setActiveItemByIndex(index: number, fallbackDelta: -1 | 1): void {\n const items = this._getItemsArray();\n\n if (!items[index]) {\n return;\n }\n\n while (this._skipPredicateFn(items[index])) {\n index += fallbackDelta;\n\n if (!items[index]) {\n return;\n }\n }\n\n this.setActiveItem(index);\n }\n\n /** Returns the items as an array. */\n private _getItemsArray(): T[] | readonly T[] {\n if (isSignal(this._items)) {\n return this._items();\n }\n\n return this._items instanceof QueryList ? this._items.toArray() : this._items;\n }\n\n /** Callback for when the items have changed. */\n private _itemsChanged(newItems: T[] | readonly T[]) {\n this._typeahead?.setItems(newItems);\n const activeItem = this._activeItem();\n if (activeItem) {\n const newIndex = newItems.indexOf(activeItem);\n\n if (newIndex > -1 && newIndex !== this._activeItemIndex()) {\n this._activeItemIndex.set(newIndex);\n this._typeahead?.setCurrentSelectedItemIndex(newIndex);\n }\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAoCA;;;AAGG;MACU,cAAc,CAAA;AAuBf,IAAA,MAAA;AAtBF,IAAA,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;AAC7B,IAAA,WAAW,GAAG,MAAM,CAAW,IAAI,CAAC;IACpC,KAAK,GAAG,KAAK;AACb,IAAA,sBAAsB,GAAG,YAAY,CAAC,KAAK;AAC3C,IAAA,wBAAwB;IACxB,SAAS,GAAG,IAAI;AAChB,IAAA,WAAW;IACX,oBAAoB,GAAgC,EAAE;IACtD,WAA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M,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE;QACrC,IAAI,UAAU,EAAE;YACd,MAAM,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;AAE7C,YAAA,IAAI,QAAQ,GAAG,CAAC,CAAC,IAAI,QAAQ,KAAK,IAAI,CAAC,gBAAgB,EAAE,EAAE;AACzD,gBAAA,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;AACnC,gBAAA,IAAI,CAAC,UAAU,EAAE,2BAA2B,CAAC,QAAQ,CAAC;;;;AAI7D;;;;"}
package/fesm2022/menu.mjs CHANGED
@@ -7,7 +7,7 @@ import { _ as _IdGenerator } from './id-generator-LuoRZSid.mjs';
7
7
  import { o as createRepositionScrollStrategy, c as createOverlayRef, i as OverlayConfig, h as createFlexibleConnectedPositionStrategy, g as STANDARD_DROPDOWN_BELOW_POSITIONS, S as STANDARD_DROPDOWN_ADJACENT_POSITIONS, t as OverlayModule } from './overlay-module-Bd2UplUU.mjs';
8
8
  import { TemplatePortal } from './portal.mjs';
9
9
  import { c as ENTER, S as SPACE, U as UP_ARROW, D as DOWN_ARROW, L as LEFT_ARROW, R as RIGHT_ARROW, T as TAB, g as ESCAPE } from './keycodes-CpHkExLC.mjs';
10
- import { I as InputModalityDetector, F as FocusMonitor } from './focus-monitor-DLjkiju1.mjs';
10
+ import { I as InputModalityDetector, F as FocusMonitor } from './focus-monitor-DUe99AIS.mjs';
11
11
  import { D as Directionality } from './directionality-CChdj3az.mjs';
12
12
  import { hasModifierKey } from './keycodes.mjs';
13
13
  import { _ as _getEventTarget } from './shadow-dom-B0oHn41l.mjs';
@@ -210,6 +210,27 @@ const MENU_SCROLL_STRATEGY = new InjectionToken('cdk-menu-scroll-strategy', {
210
210
  return () => createRepositionScrollStrategy(injector);
211
211
  },
212
212
  });
213
+ /** Tracks the last open menu trigger across the entire application. */
214
+ class MenuTracker {
215
+ /** The last open menu trigger. */
216
+ static _openMenuTrigger;
217
+ /**
218
+ * Close the previous open menu and set the given one as being open.
219
+ * @param trigger The trigger for the currently open Menu.
220
+ */
221
+ update(trigger) {
222
+ if (MenuTracker._openMenuTrigger !== trigger) {
223
+ MenuTracker._openMenuTrigger?.close();
224
+ MenuTracker._openMenuTrigger = trigger;
225
+ }
226
+ }
227
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: MenuTracker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
228
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: MenuTracker, providedIn: 'root' });
229
+ }
230
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: MenuTracker, decorators: [{
231
+ type: Injectable,
232
+ args: [{ providedIn: 'root' }]
233
+ }] });
213
234
  /**
214
235
  * Abstract directive that implements shared logic common to all menu triggers.
215
236
  * This class can be extended to create custom menu trigger types.
@@ -569,6 +590,8 @@ class CdkMenuTrigger extends CdkMenuTriggerBase {
569
590
  _renderer = inject(Renderer2);
570
591
  _injector = inject(Injector);
571
592
  _cleanupMouseenter;
593
+ /** The app's menu tracking registry */
594
+ _menuTracker = inject(MenuTracker);
572
595
  /** The parent menu this trigger belongs to. */
573
596
  _parentMenu = inject(CDK_MENU, { optional: true });
574
597
  /** The menu aim service used by this menu. */
@@ -588,6 +611,9 @@ class CdkMenuTrigger extends CdkMenuTriggerBase {
588
611
  }
589
612
  /** Open the attached menu. */
590
613
  open() {
614
+ if (!this._parentMenu) {
615
+ this._menuTracker.update(this);
616
+ }
591
617
  if (!this.isOpen() && this.menuTemplateRef != null) {
592
618
  this.opened.next();
593
619
  this.overlayRef =
@@ -1243,6 +1269,13 @@ class CdkMenuBase extends CdkMenuGroup {
1243
1269
  this.keyManager.setFocusOrigin(focusOrigin);
1244
1270
  this.keyManager.setLastItemActive();
1245
1271
  }
1272
+ /**
1273
+ * Sets the active item to the item at the specified index and focuses the newly active item.
1274
+ * @param item The index of the item to be set as active, or the CdkMenuItem instance.
1275
+ */
1276
+ setActiveMenuItem(item) {
1277
+ this.keyManager?.setActiveItem(item);
1278
+ }
1246
1279
  /** Gets the tabindex for this menu. */
1247
1280
  _getTabIndex() {
1248
1281
  return this._tabIndexSignal();
@@ -1719,27 +1752,6 @@ const CONTEXT_MENU_POSITIONS = STANDARD_DROPDOWN_BELOW_POSITIONS.map(position =>
1719
1752
  const offsetY = position.overlayY === 'top' ? 2 : -2;
1720
1753
  return { ...position, offsetX, offsetY };
1721
1754
  });
1722
- /** Tracks the last open context menu trigger across the entire application. */
1723
- class ContextMenuTracker {
1724
- /** The last open context menu trigger. */
1725
- static _openContextMenuTrigger;
1726
- /**
1727
- * Close the previous open context menu and set the given one as being open.
1728
- * @param trigger The trigger for the currently open Context Menu.
1729
- */
1730
- update(trigger) {
1731
- if (ContextMenuTracker._openContextMenuTrigger !== trigger) {
1732
- ContextMenuTracker._openContextMenuTrigger?.close();
1733
- ContextMenuTracker._openContextMenuTrigger = trigger;
1734
- }
1735
- }
1736
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: ContextMenuTracker, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1737
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: ContextMenuTracker, providedIn: 'root' });
1738
- }
1739
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: ContextMenuTracker, decorators: [{
1740
- type: Injectable,
1741
- args: [{ providedIn: 'root' }]
1742
- }] });
1743
1755
  /**
1744
1756
  * A directive that opens a menu when a user right-clicks within its host element.
1745
1757
  * It is aware of nested context menus and will trigger only the lowest level non-disabled context menu.
@@ -1747,7 +1759,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
1747
1759
  class CdkContextMenuTrigger extends CdkMenuTriggerBase {
1748
1760
  _injector = inject(Injector);
1749
1761
  _directionality = inject(Directionality, { optional: true });
1750
- _contextMenuTracker = inject(ContextMenuTracker);
1762
+ /** The app's menu tracking registry */
1763
+ _menuTracker = inject(MenuTracker);
1751
1764
  _changeDetectorRef = inject(ChangeDetectorRef);
1752
1765
  /** Whether the context menu is disabled. */
1753
1766
  disabled = false;
@@ -1779,7 +1792,7 @@ class CdkContextMenuTrigger extends CdkMenuTriggerBase {
1779
1792
  // Otherwise, any context menus attached to containing elements would *also* open,
1780
1793
  // resulting in multiple stacked context menus being displayed.
1781
1794
  event.stopPropagation();
1782
- this._contextMenuTracker.update(this);
1795
+ this._menuTracker.update(this);
1783
1796
  this._open(event, { x: event.clientX, y: event.clientY });
1784
1797
  // A context menu can be triggered via a mouse right click or a keyboard shortcut.
1785
1798
  if (event.button === 2) {
@@ -1955,5 +1968,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImpor
1955
1968
  }]
1956
1969
  }] });
1957
1970
 
1958
- export { CDK_MENU, CdkContextMenuTrigger, CdkMenu, CdkMenuBar, CdkMenuBase, CdkMenuGroup, CdkMenuItem, CdkMenuItemCheckbox, CdkMenuItemRadio, CdkMenuItemSelectable, CdkMenuModule, CdkMenuTrigger, CdkMenuTriggerBase, CdkTargetMenuAim, ContextMenuTracker, FocusNext, MENU_AIM, MENU_SCROLL_STRATEGY, MENU_STACK, MENU_TRIGGER, MenuStack, PARENT_OR_NEW_INLINE_MENU_STACK_PROVIDER, PARENT_OR_NEW_MENU_STACK_PROVIDER, PointerFocusTracker, TargetMenuAim };
1971
+ export { CDK_MENU, CdkContextMenuTrigger, CdkMenu, CdkMenuBar, CdkMenuBase, CdkMenuGroup, CdkMenuItem, CdkMenuItemCheckbox, CdkMenuItemRadio, CdkMenuItemSelectable, CdkMenuModule, CdkMenuTrigger, CdkMenuTriggerBase, CdkTargetMenuAim, MenuTracker as ContextMenuTracker, FocusNext, MENU_AIM, MENU_SCROLL_STRATEGY, MENU_STACK, MENU_TRIGGER, MenuStack, MenuTracker, PARENT_OR_NEW_INLINE_MENU_STACK_PROVIDER, PARENT_OR_NEW_MENU_STACK_PROVIDER, PointerFocusTracker, TargetMenuAim };
1959
1972
  //# sourceMappingURL=menu.mjs.map