@angular/cdk
Version:
Angular Material Component Development Kit
1 lines • 2.53 kB
Source Map (JSON)
{"version":3,"file":"_focus-key-manager-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/cdk/a11y/key-manager/focus-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 {ListKeyManager, ListKeyManagerOption} from './list-key-manager';\nimport {FocusOrigin} from '../focus-monitor/focus-monitor';\n\n/**\n * This is the interface for focusable items (used by the FocusKeyManager).\n * Each item must know how to focus itself, whether or not it is currently disabled\n * and be able to supply its label.\n */\nexport interface FocusableOption extends ListKeyManagerOption {\n /** Focuses the `FocusableOption`. */\n focus(origin?: FocusOrigin): void;\n}\n\nexport class FocusKeyManager<T> extends ListKeyManager<FocusableOption & T> {\n private _origin: FocusOrigin = 'program';\n\n /**\n * Sets the focus origin that will be passed in to the items for any subsequent `focus` calls.\n * @param origin Focus origin to be used when focusing items.\n */\n setFocusOrigin(origin: FocusOrigin): this {\n this._origin = origin;\n return this;\n }\n\n /**\n * Sets the active item to the item at the specified\n * index and focuses the newly active item.\n * @param index Index of the item to be set as active.\n */\n override setActiveItem(index: number): void;\n\n /**\n * Sets the active item to the item that is specified and focuses it.\n * @param item Item to be set as active.\n */\n override setActiveItem(item: T): void;\n\n /**\n * Sets the active item to the item that is specified and focuses it.\n * @param item Item to be set as active.\n */\n override setActiveItem(item: T | number): void;\n\n override setActiveItem(item: any): void {\n super.setActiveItem(item);\n\n if (this.activeItem) {\n this.activeItem.focus(this._origin);\n }\n }\n}\n"],"names":["FocusKeyManager","ListKeyManager","_origin","setFocusOrigin","origin","setActiveItem","item","activeItem","focus"],"mappings":";;AAqBM,MAAOA,eAAmB,SAAQC,cAAmC,CAAA;AACjEC,EAAAA,OAAO,GAAgB,SAAS;EAMxCC,cAAcA,CAACC,MAAmB,EAAA;IAChC,IAAI,CAACF,OAAO,GAAGE,MAAM;AACrB,IAAA,OAAO,IAAI;AACb;EAqBSC,aAAaA,CAACC,IAAS,EAAA;AAC9B,IAAA,KAAK,CAACD,aAAa,CAACC,IAAI,CAAC;IAEzB,IAAI,IAAI,CAACC,UAAU,EAAE;MACnB,IAAI,CAACA,UAAU,CAACC,KAAK,CAAC,IAAI,CAACN,OAAO,CAAC;AACrC;AACF;AACD;;;;"}