| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- /**
- * @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
- */
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/cdk/coercion'), require('@angular/core'), require('rxjs'), require('@angular/cdk/collections')) :
- typeof define === 'function' && define.amd ? define('@angular/cdk/accordion', ['exports', '@angular/cdk/coercion', '@angular/core', 'rxjs', '@angular/cdk/collections'], factory) :
- (factory((global.ng = global.ng || {}, global.ng.cdk = global.ng.cdk || {}, global.ng.cdk.accordion = {}),global.ng.cdk.coercion,global.ng.core,global.rxjs,global.ng.cdk.collections));
- }(this, (function (exports,coercion,core,rxjs,collections) { 'use strict';
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Used to generate unique ID for each accordion.
- * @type {?}
- */
- var nextId = 0;
- /**
- * Directive whose purpose is to manage the expanded state of CdkAccordionItem children.
- */
- var CdkAccordion = /** @class */ (function () {
- function CdkAccordion() {
- /**
- * Emits when the state of the accordion changes
- */
- this._stateChanges = new rxjs.Subject();
- /**
- * Stream that emits true/false when openAll/closeAll is triggered.
- */
- this._openCloseAllActions = new rxjs.Subject();
- /**
- * A readonly id value to use for unique selection coordination.
- */
- this.id = "cdk-accordion-" + nextId++;
- this._multi = false;
- }
- Object.defineProperty(CdkAccordion.prototype, "multi", {
- /** Whether the accordion should allow multiple expanded accordion items simultaneously. */
- get: /**
- * Whether the accordion should allow multiple expanded accordion items simultaneously.
- * @return {?}
- */
- function () { return this._multi; },
- set: /**
- * @param {?} multi
- * @return {?}
- */
- function (multi) { this._multi = coercion.coerceBooleanProperty(multi); },
- enumerable: true,
- configurable: true
- });
- /** Opens all enabled accordion items in an accordion where multi is enabled. */
- /**
- * Opens all enabled accordion items in an accordion where multi is enabled.
- * @return {?}
- */
- CdkAccordion.prototype.openAll = /**
- * Opens all enabled accordion items in an accordion where multi is enabled.
- * @return {?}
- */
- function () {
- this._openCloseAll(true);
- };
- /** Closes all enabled accordion items in an accordion where multi is enabled. */
- /**
- * Closes all enabled accordion items in an accordion where multi is enabled.
- * @return {?}
- */
- CdkAccordion.prototype.closeAll = /**
- * Closes all enabled accordion items in an accordion where multi is enabled.
- * @return {?}
- */
- function () {
- this._openCloseAll(false);
- };
- /**
- * @param {?} changes
- * @return {?}
- */
- CdkAccordion.prototype.ngOnChanges = /**
- * @param {?} changes
- * @return {?}
- */
- function (changes) {
- this._stateChanges.next(changes);
- };
- /**
- * @return {?}
- */
- CdkAccordion.prototype.ngOnDestroy = /**
- * @return {?}
- */
- function () {
- this._stateChanges.complete();
- };
- /**
- * @private
- * @param {?} expanded
- * @return {?}
- */
- CdkAccordion.prototype._openCloseAll = /**
- * @private
- * @param {?} expanded
- * @return {?}
- */
- function (expanded) {
- if (this.multi) {
- this._openCloseAllActions.next(expanded);
- }
- };
- CdkAccordion.decorators = [
- { type: core.Directive, args: [{
- selector: 'cdk-accordion, [cdkAccordion]',
- exportAs: 'cdkAccordion',
- },] },
- ];
- CdkAccordion.propDecorators = {
- multi: [{ type: core.Input }]
- };
- return CdkAccordion;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- /**
- * Used to generate unique ID for each accordion item.
- * @type {?}
- */
- var nextId$1 = 0;
- var ɵ0 = undefined;
- /**
- * 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.
- */
- var CdkAccordionItem = /** @class */ (function () {
- function CdkAccordionItem(accordion, _changeDetectorRef, _expansionDispatcher) {
- var _this = this;
- this.accordion = accordion;
- this._changeDetectorRef = _changeDetectorRef;
- this._expansionDispatcher = _expansionDispatcher;
- /**
- * Subscription to openAll/closeAll events.
- */
- this._openCloseAllSubscription = rxjs.Subscription.EMPTY;
- /**
- * Event emitted every time the AccordionItem is closed.
- */
- this.closed = new core.EventEmitter();
- /**
- * Event emitted every time the AccordionItem is opened.
- */
- this.opened = new core.EventEmitter();
- /**
- * Event emitted when the AccordionItem is destroyed.
- */
- this.destroyed = new core.EventEmitter();
- /**
- * Emits whenever the expanded state of the accordion changes.
- * Primarily used to facilitate two-way binding.
- * \@docs-private
- */
- this.expandedChange = new core.EventEmitter();
- /**
- * The unique AccordionItem id.
- */
- this.id = "cdk-accordion-child-" + nextId$1++;
- this._expanded = false;
- this._disabled = false;
- /**
- * Unregister function for _expansionDispatcher.
- */
- this._removeUniqueSelectionListener = (/**
- * @return {?}
- */
- function () { });
- this._removeUniqueSelectionListener =
- _expansionDispatcher.listen((/**
- * @param {?} id
- * @param {?} accordionId
- * @return {?}
- */
- function (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();
- }
- }
- Object.defineProperty(CdkAccordionItem.prototype, "expanded", {
- /** Whether the AccordionItem is expanded. */
- get: /**
- * Whether the AccordionItem is expanded.
- * @return {?}
- */
- function () { return this._expanded; },
- set: /**
- * @param {?} expanded
- * @return {?}
- */
- function (expanded) {
- expanded = coercion.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.
- * @type {?}
- */
- var 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();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(CdkAccordionItem.prototype, "disabled", {
- /** Whether the AccordionItem is disabled. */
- get: /**
- * Whether the AccordionItem is disabled.
- * @return {?}
- */
- function () { return this._disabled; },
- set: /**
- * @param {?} disabled
- * @return {?}
- */
- function (disabled) { this._disabled = coercion.coerceBooleanProperty(disabled); },
- enumerable: true,
- configurable: true
- });
- /** Emits an event for the accordion item being destroyed. */
- /**
- * Emits an event for the accordion item being destroyed.
- * @return {?}
- */
- CdkAccordionItem.prototype.ngOnDestroy = /**
- * Emits an event for the accordion item being destroyed.
- * @return {?}
- */
- function () {
- 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. */
- /**
- * Toggles the expanded state of the accordion item.
- * @return {?}
- */
- CdkAccordionItem.prototype.toggle = /**
- * Toggles the expanded state of the accordion item.
- * @return {?}
- */
- function () {
- if (!this.disabled) {
- this.expanded = !this.expanded;
- }
- };
- /** Sets the expanded state of the accordion item to false. */
- /**
- * Sets the expanded state of the accordion item to false.
- * @return {?}
- */
- CdkAccordionItem.prototype.close = /**
- * Sets the expanded state of the accordion item to false.
- * @return {?}
- */
- function () {
- if (!this.disabled) {
- this.expanded = false;
- }
- };
- /** Sets the expanded state of the accordion item to true. */
- /**
- * Sets the expanded state of the accordion item to true.
- * @return {?}
- */
- CdkAccordionItem.prototype.open = /**
- * Sets the expanded state of the accordion item to true.
- * @return {?}
- */
- function () {
- if (!this.disabled) {
- this.expanded = true;
- }
- };
- /**
- * @private
- * @return {?}
- */
- CdkAccordionItem.prototype._subscribeToOpenCloseAllActions = /**
- * @private
- * @return {?}
- */
- function () {
- var _this = this;
- return this.accordion._openCloseAllActions.subscribe((/**
- * @param {?} expanded
- * @return {?}
- */
- function (expanded) {
- // Only change expanded state if item is enabled
- if (!_this.disabled) {
- _this.expanded = expanded;
- }
- }));
- };
- CdkAccordionItem.decorators = [
- { type: core.Directive, args: [{
- selector: 'cdk-accordion-item, [cdkAccordionItem]',
- exportAs: 'cdkAccordionItem',
- providers: [
- // Provide CdkAccordion as undefined to prevent nested accordion items from registering
- // to the same accordion.
- { provide: CdkAccordion, useValue: ɵ0 },
- ],
- },] },
- ];
- /** @nocollapse */
- CdkAccordionItem.ctorParameters = function () { return [
- { type: CdkAccordion, decorators: [{ type: core.Optional }, { type: core.SkipSelf }] },
- { type: core.ChangeDetectorRef },
- { type: collections.UniqueSelectionDispatcher }
- ]; };
- CdkAccordionItem.propDecorators = {
- closed: [{ type: core.Output }],
- opened: [{ type: core.Output }],
- destroyed: [{ type: core.Output }],
- expandedChange: [{ type: core.Output }],
- expanded: [{ type: core.Input }],
- disabled: [{ type: core.Input }]
- };
- return CdkAccordionItem;
- }());
- /**
- * @fileoverview added by tsickle
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
- */
- var CdkAccordionModule = /** @class */ (function () {
- function CdkAccordionModule() {
- }
- CdkAccordionModule.decorators = [
- { type: core.NgModule, args: [{
- exports: [CdkAccordion, CdkAccordionItem],
- declarations: [CdkAccordion, CdkAccordionItem],
- },] },
- ];
- return CdkAccordionModule;
- }());
- exports.CdkAccordionItem = CdkAccordionItem;
- exports.CdkAccordion = CdkAccordion;
- exports.CdkAccordionModule = CdkAccordionModule;
- Object.defineProperty(exports, '__esModule', { value: true });
- })));
- //# sourceMappingURL=cdk-accordion.umd.js.map
|