/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Directive, Input, ContentChildren, QueryList, } from '@angular/core'; import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { CdkAccordion } from '@angular/cdk/accordion'; import { FocusKeyManager } from '@angular/cdk/a11y'; import { startWith } from 'rxjs/operators'; import { MAT_ACCORDION, } from './accordion-base'; import { MatExpansionPanelHeader } from './expansion-panel-header'; import * as i0 from "@angular/core"; /** * Directive for a Material Design Accordion. */ export class MatAccordion extends CdkAccordion { constructor() { super(...arguments); /** Headers belonging to this accordion. */ this._ownHeaders = new QueryList(); this._hideToggle = false; /** * Display mode used for all expansion panels in the accordion. Currently two display * modes exist: * default - a gutter-like spacing is placed around any expanded panel, placing the expanded * panel at a different elevation from the rest of the accordion. * flat - no spacing is placed around expanded panels, showing all panels at the same * elevation. */ this.displayMode = 'default'; /** The position of the expansion indicator. */ this.togglePosition = 'after'; } /** Whether the expansion indicator should be hidden. */ get hideToggle() { return this._hideToggle; } set hideToggle(show) { this._hideToggle = coerceBooleanProperty(show); } ngAfterContentInit() { this._headers.changes .pipe(startWith(this._headers)) .subscribe((headers) => { this._ownHeaders.reset(headers.filter(header => header.panel.accordion === this)); this._ownHeaders.notifyOnChanges(); }); this._keyManager = new FocusKeyManager(this._ownHeaders).withWrap().withHomeAndEnd(); } /** Handles keyboard events coming in from the panel headers. */ _handleHeaderKeydown(event) { this._keyManager.onKeydown(event); } _handleHeaderFocus(header) { this._keyManager.updateActiveItem(header); } ngOnDestroy() { super.ngOnDestroy(); this._keyManager?.destroy(); this._ownHeaders.destroy(); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatAccordion, deps: null, target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: MatAccordion, selector: "mat-accordion", inputs: { multi: "multi", hideToggle: "hideToggle", displayMode: "displayMode", togglePosition: "togglePosition" }, host: { properties: { "class.mat-accordion-multi": "this.multi" }, classAttribute: "mat-accordion" }, providers: [ { provide: MAT_ACCORDION, useExisting: MatAccordion, }, ], queries: [{ propertyName: "_headers", predicate: MatExpansionPanelHeader, descendants: true }], exportAs: ["matAccordion"], usesInheritance: true, ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: MatAccordion, decorators: [{ type: Directive, args: [{ selector: 'mat-accordion', exportAs: 'matAccordion', inputs: ['multi'], providers: [ { provide: MAT_ACCORDION, useExisting: MatAccordion, }, ], host: { class: 'mat-accordion', // Class binding which is only used by the test harness as there is no other // way for the harness to detect if multiple panel support is enabled. '[class.mat-accordion-multi]': 'this.multi', }, }] }], propDecorators: { _headers: [{ type: ContentChildren, args: [MatExpansionPanelHeader, { descendants: true }] }], hideToggle: [{ type: Input }], displayMode: [{ type: Input }], togglePosition: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3JkaW9uLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vLi4vc3JjL21hdGVyaWFsL2V4cGFuc2lvbi9hY2NvcmRpb24udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7OztHQU1HO0FBRUgsT0FBTyxFQUNMLFNBQVMsRUFDVCxLQUFLLEVBQ0wsZUFBZSxFQUNmLFNBQVMsR0FHVixNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQWUscUJBQXFCLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUMxRSxPQUFPLEVBQUMsWUFBWSxFQUFDLE1BQU0sd0JBQXdCLENBQUM7QUFDcEQsT0FBTyxFQUFDLGVBQWUsRUFBQyxNQUFNLG1CQUFtQixDQUFDO0FBQ2xELE9BQU8sRU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