/** * @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 { Output, Directive, EventEmitter, Input, Optional, ChangeDetectorRef, SkipSelf, Inject, } from '@angular/core'; import { UniqueSelectionDispatcher } from '@angular/cdk/collections'; import { CDK_ACCORDION, CdkAccordion } from './accordion'; import { coerceBooleanProperty } from '@angular/cdk/coercion'; import { Subscription } from 'rxjs'; import * as i0 from "@angular/core"; import * as i1 from "@angular/cdk/collections"; import * as i2 from "./accordion"; /** Used to generate unique ID for each accordion item. */ let nextId = 0; /** * An basic directive expected to be extended and decorated as a component. Sets up all * events and attributes needed to be managed by a CdkAccordion parent. */ export class CdkAccordionItem { /** Whether the AccordionItem is expanded. */ get expanded() { return this._expanded; } set expanded(expanded) { expanded = coerceBooleanProperty(expanded); // Only emit events and update the internal value if the value changes. if (this._expanded !== expanded) { this._expanded = expanded; this.expandedChange.emit(expanded); if (expanded) { this.opened.emit(); /** * In the unique selection dispatcher, the id parameter is the id of the CdkAccordionItem, * the name value is the id of the accordion. */ const accordionId = this.accordion ? this.accordion.id : this.id; this._expansionDispatcher.notify(this.id, accordionId); } else { this.closed.emit(); } // Ensures that the animation will run when the value is set outside of an `@Input`. // This includes cases like the open, close and toggle methods. this._changeDetectorRef.markForCheck(); } } /** Whether the AccordionItem is disabled. */ get disabled() { return this._disabled; } set disabled(disabled) { this._disabled = coerceBooleanProperty(disabled); } constructor(accordion, _changeDetectorRef, _expansionDispatcher) { this.accordion = accordion; this._changeDetectorRef = _changeDetectorRef; this._expansionDispatcher = _expansionDispatcher; /** Subscription to openAll/closeAll events. */ this._openCloseAllSubscription = Subscription.EMPTY; /** Event emitted every time the AccordionItem is closed. */ this.closed = new EventEmitter(); /** Event emitted every time the AccordionItem is opened. */ this.opened = new EventEmitter(); /** Event emitted when the AccordionItem is destroyed. */ this.destroyed = new EventEmitter(); /** * Emits whenever the expanded state of the accordion changes. * Primarily used to facilitate two-way binding. * @docs-private */ this.expandedChange = new EventEmitter(); /** The unique AccordionItem id. */ this.id = `cdk-accordion-child-${nextId++}`; this._expanded = false; this._disabled = false; /** Unregister function for _expansionDispatcher. */ this._removeUniqueSelectionListener = () => { }; this._removeUniqueSelectionListener = _expansionDispatcher.listen((id, accordionId) => { if (this.accordion && !this.accordion.multi && this.accordion.id === accordionId && this.id !== id) { this.expanded = false; } }); // When an accordion item is hosted in an accordion, subscribe to open/close events. if (this.accordion) { this._openCloseAllSubscription = this._subscribeToOpenCloseAllActions(); } } /** Emits an event for the accordion item being destroyed. */ ngOnDestroy() { this.opened.complete(); this.closed.complete(); this.destroyed.emit(); this.destroyed.complete(); this._removeUniqueSelectionListener(); this._openCloseAllSubscription.unsubscribe(); } /** Toggles the expanded state of the accordion item. */ toggle() { if (!this.disabled) { this.expanded = !this.expanded; } } /** Sets the expanded state of the accordion item to false. */ close() { if (!this.disabled) { this.expanded = false; } } /** Sets the expanded state of the accordion item to true. */ open() { if (!this.disabled) { this.expanded = true; } } _subscribeToOpenCloseAllActions() { return this.accordion._openCloseAllActions.subscribe(expanded => { // Only change expanded state if item is enabled if (!this.disabled) { this.expanded = expanded; } }); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkAccordionItem, deps: [{ token: CDK_ACCORDION, optional: true, skipSelf: true }, { token: i0.ChangeDetectorRef }, { token: i1.UniqueSelectionDispatcher }], target: i0.ɵɵFactoryTarget.Directive }); } static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.1.1", type: CdkAccordionItem, selector: "cdk-accordion-item, [cdkAccordionItem]", inputs: { expanded: "expanded", disabled: "disabled" }, outputs: { closed: "closed", opened: "opened", destroyed: "destroyed", expandedChange: "expandedChange" }, providers: [ // Provide `CDK_ACCORDION` as undefined to prevent nested accordion items from // registering to the same accordion. { provide: CDK_ACCORDION, useValue: undefined }, ], exportAs: ["cdkAccordionItem"], ngImport: i0 }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: CdkAccordionItem, decorators: [{ type: Directive, args: [{ selector: 'cdk-accordion-item, [cdkAccordionItem]', exportAs: 'cdkAccordionItem', providers: [ // Provide `CDK_ACCORDION` as undefined to prevent nested accordion items from // registering to the same accordion. { provide: CDK_ACCORDION, useValue: undefined }, ], }] }], ctorParameters: function () { return [{ type: i2.CdkAccordion, decorators: [{ type: Optional }, { type: Inject, args: [CDK_ACCORDION] }, { type: SkipSelf }] }, { type: i0.ChangeDetectorRef }, { type: i1.UniqueSelectionDispatcher }]; }, propDecorators: { closed: [{ type: Output }], opened: [{ type: Output }], destroyed: [{ type: Output }], expandedChange: [{ type: Output }], expanded: [{ type: Input }], disabled: [{ type: Input }] } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3JkaW9uLWl0ZW0uanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi9zcmMvY2RrL2FjY29yZGlvbi9hY2NvcmRpb24taXRlbS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQ0wsTUFBTSxFQUNOLFNBQVMsRUFDVCxZQUFZLEVBQ1osS0FBSyxFQUVMLFFBQVEsRUFDUixpQkFBaUIsRUFDakIsUUFBUSxFQUNSLE1BQU0sR0FDUCxNQUFNLGVBQWUsQ0FBQztBQUN2QixPQUFPLEVBQUMseUJBQXlCLEVBQUMsTUFBTSwwQkFBMEIsQ0FBQztBQUNuRSxPQUFPLEVBQUMsYUFBYSxFQUFFLFlBQVksRUFBQyxNQUFNLGFBQWEsQ0FBQztBQUN4RCxPQUFPLEVBQWUscUJBQXFCLEVBQUMsTUFBTSx1QkFBdUIsQ0FBQztBQUMxRSxPQUFPLEVBQUMsWUFBWSxFQUFDLE1BQU0sTUFBTSxDQUFDOzs7O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