material-expansion.umd.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. /**
  2. * @license
  3. * Copyright Google LLC All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. (function (global, factory) {
  9. typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/animations'), require('@angular/cdk/accordion'), require('@angular/cdk/coercion'), require('@angular/cdk/collections'), require('@angular/cdk/portal'), require('@angular/common'), require('@angular/platform-browser/animations'), require('rxjs'), require('rxjs/operators'), require('@angular/cdk/a11y'), require('@angular/cdk/keycodes')) :
  10. typeof define === 'function' && define.amd ? define('@angular/material/expansion', ['exports', '@angular/core', '@angular/animations', '@angular/cdk/accordion', '@angular/cdk/coercion', '@angular/cdk/collections', '@angular/cdk/portal', '@angular/common', '@angular/platform-browser/animations', 'rxjs', 'rxjs/operators', '@angular/cdk/a11y', '@angular/cdk/keycodes'], factory) :
  11. (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.expansion = {}),global.ng.core,global.ng.animations,global.ng.cdk.accordion,global.ng.cdk.coercion,global.ng.cdk.collections,global.ng.cdk.portal,global.ng.common,global.ng.platformBrowser.animations,global.rxjs,global.rxjs.operators,global.ng.cdk.a11y,global.ng.cdk.keycodes));
  12. }(this, (function (exports,core,animations,accordion,coercion,collections,portal,common,animations$1,rxjs,operators,a11y,keycodes) { 'use strict';
  13. /*! *****************************************************************************
  14. Copyright (c) Microsoft Corporation. All rights reserved.
  15. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  16. this file except in compliance with the License. You may obtain a copy of the
  17. License at http://www.apache.org/licenses/LICENSE-2.0
  18. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  19. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  20. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  21. MERCHANTABLITY OR NON-INFRINGEMENT.
  22. See the Apache Version 2.0 License for specific language governing permissions
  23. and limitations under the License.
  24. ***************************************************************************** */
  25. /* global Reflect, Promise */
  26. var extendStatics = function(d, b) {
  27. extendStatics = Object.setPrototypeOf ||
  28. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  29. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  30. return extendStatics(d, b);
  31. };
  32. function __extends(d, b) {
  33. extendStatics(d, b);
  34. function __() { this.constructor = d; }
  35. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  36. }
  37. /**
  38. * @fileoverview added by tsickle
  39. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  40. */
  41. /**
  42. * Token used to provide a `MatAccordion` to `MatExpansionPanel`.
  43. * Used primarily to avoid circular imports between `MatAccordion` and `MatExpansionPanel`.
  44. * @type {?}
  45. */
  46. var MAT_ACCORDION = new core.InjectionToken('MAT_ACCORDION');
  47. /**
  48. * @fileoverview added by tsickle
  49. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  50. */
  51. /**
  52. * Time and timing curve for expansion panel animations.
  53. * @type {?}
  54. */
  55. var EXPANSION_PANEL_ANIMATION_TIMING = '225ms cubic-bezier(0.4,0.0,0.2,1)';
  56. /**
  57. * Animations used by the Material expansion panel.
  58. *
  59. * A bug in angular animation's `state` when ViewContainers are moved using ViewContainerRef.move()
  60. * causes the animation state of moved components to become `void` upon exit, and not update again
  61. * upon reentry into the DOM. This can lead a to situation for the expansion panel where the state
  62. * of the panel is `expanded` or `collapsed` but the animation state is `void`.
  63. *
  64. * To correctly handle animating to the next state, we animate between `void` and `collapsed` which
  65. * are defined to have the same styles. Since angular animates from the current styles to the
  66. * destination state's style definition, in situations where we are moving from `void`'s styles to
  67. * `collapsed` this acts a noop since no style values change.
  68. *
  69. * In the case where angular's animation state is out of sync with the expansion panel's state, the
  70. * expansion panel being `expanded` and angular animations being `void`, the animation from the
  71. * `expanded`'s effective styles (though in a `void` animation state) to the collapsed state will
  72. * occur as expected.
  73. *
  74. * Angular Bug: https://github.com/angular/angular/issues/18847
  75. *
  76. * \@docs-private
  77. * @type {?}
  78. */
  79. var matExpansionAnimations = {
  80. /**
  81. * Animation that rotates the indicator arrow.
  82. */
  83. indicatorRotate: animations.trigger('indicatorRotate', [
  84. animations.state('collapsed, void', animations.style({ transform: 'rotate(0deg)' })),
  85. animations.state('expanded', animations.style({ transform: 'rotate(180deg)' })),
  86. animations.transition('expanded <=> collapsed, void => collapsed', animations.animate(EXPANSION_PANEL_ANIMATION_TIMING)),
  87. ]),
  88. /**
  89. * Animation that expands and collapses the panel header height.
  90. */
  91. expansionHeaderHeight: animations.trigger('expansionHeight', [
  92. animations.state('collapsed, void', animations.style({
  93. height: '{{collapsedHeight}}',
  94. }), {
  95. params: { collapsedHeight: '48px' },
  96. }),
  97. animations.state('expanded', animations.style({
  98. height: '{{expandedHeight}}'
  99. }), {
  100. params: { expandedHeight: '64px' }
  101. }),
  102. animations.transition('expanded <=> collapsed, void => collapsed', animations.group([
  103. animations.query('@indicatorRotate', animations.animateChild(), { optional: true }),
  104. animations.animate(EXPANSION_PANEL_ANIMATION_TIMING),
  105. ])),
  106. ]),
  107. /**
  108. * Animation that expands and collapses the panel content.
  109. */
  110. bodyExpansion: animations.trigger('bodyExpansion', [
  111. animations.state('collapsed, void', animations.style({ height: '0px', visibility: 'hidden' })),
  112. animations.state('expanded', animations.style({ height: '*', visibility: 'visible' })),
  113. animations.transition('expanded <=> collapsed, void => collapsed', animations.animate(EXPANSION_PANEL_ANIMATION_TIMING)),
  114. ])
  115. };
  116. /**
  117. * @fileoverview added by tsickle
  118. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  119. */
  120. /**
  121. * Expansion panel content that will be rendered lazily
  122. * after the panel is opened for the first time.
  123. */
  124. var MatExpansionPanelContent = /** @class */ (function () {
  125. function MatExpansionPanelContent(_template) {
  126. this._template = _template;
  127. }
  128. MatExpansionPanelContent.decorators = [
  129. { type: core.Directive, args: [{
  130. selector: 'ng-template[matExpansionPanelContent]'
  131. },] },
  132. ];
  133. /** @nocollapse */
  134. MatExpansionPanelContent.ctorParameters = function () { return [
  135. { type: core.TemplateRef }
  136. ]; };
  137. return MatExpansionPanelContent;
  138. }());
  139. /**
  140. * @fileoverview added by tsickle
  141. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  142. */
  143. /**
  144. * Counter for generating unique element ids.
  145. * @type {?}
  146. */
  147. var uniqueId = 0;
  148. /**
  149. * Injection token that can be used to configure the defalt
  150. * options for the expansion panel component.
  151. * @type {?}
  152. */
  153. var MAT_EXPANSION_PANEL_DEFAULT_OPTIONS = new core.InjectionToken('MAT_EXPANSION_PANEL_DEFAULT_OPTIONS');
  154. var ɵ0 = undefined;
  155. /**
  156. * `<mat-expansion-panel>`
  157. *
  158. * This component can be used as a single element to show expandable content, or as one of
  159. * multiple children of an element with the MatAccordion directive attached.
  160. */
  161. var MatExpansionPanel = /** @class */ (function (_super) {
  162. __extends(MatExpansionPanel, _super);
  163. function MatExpansionPanel(accordion$$1, _changeDetectorRef, _uniqueSelectionDispatcher, _viewContainerRef, _document, _animationMode, defaultOptions) {
  164. var _this = _super.call(this, accordion$$1, _changeDetectorRef, _uniqueSelectionDispatcher) || this;
  165. _this._viewContainerRef = _viewContainerRef;
  166. _this._animationMode = _animationMode;
  167. _this._hideToggle = false;
  168. /**
  169. * An event emitted after the body's expansion animation happens.
  170. */
  171. _this.afterExpand = new core.EventEmitter();
  172. /**
  173. * An event emitted after the body's collapse animation happens.
  174. */
  175. _this.afterCollapse = new core.EventEmitter();
  176. /**
  177. * Stream that emits for changes in `\@Input` properties.
  178. */
  179. _this._inputChanges = new rxjs.Subject();
  180. /**
  181. * ID for the associated header element. Used for a11y labelling.
  182. */
  183. _this._headerId = "mat-expansion-panel-header-" + uniqueId++;
  184. /**
  185. * Stream of body animation done events.
  186. */
  187. _this._bodyAnimationDone = new rxjs.Subject();
  188. _this.accordion = accordion$$1;
  189. _this._document = _document;
  190. // We need a Subject with distinctUntilChanged, because the `done` event
  191. // fires twice on some browsers. See https://github.com/angular/angular/issues/24084
  192. _this._bodyAnimationDone.pipe(operators.distinctUntilChanged((/**
  193. * @param {?} x
  194. * @param {?} y
  195. * @return {?}
  196. */
  197. function (x, y) {
  198. return x.fromState === y.fromState && x.toState === y.toState;
  199. }))).subscribe((/**
  200. * @param {?} event
  201. * @return {?}
  202. */
  203. function (event) {
  204. if (event.fromState !== 'void') {
  205. if (event.toState === 'expanded') {
  206. _this.afterExpand.emit();
  207. }
  208. else if (event.toState === 'collapsed') {
  209. _this.afterCollapse.emit();
  210. }
  211. }
  212. }));
  213. if (defaultOptions) {
  214. _this.hideToggle = defaultOptions.hideToggle;
  215. }
  216. return _this;
  217. }
  218. Object.defineProperty(MatExpansionPanel.prototype, "hideToggle", {
  219. /** Whether the toggle indicator should be hidden. */
  220. get: /**
  221. * Whether the toggle indicator should be hidden.
  222. * @return {?}
  223. */
  224. function () {
  225. return this._hideToggle || (this.accordion && this.accordion.hideToggle);
  226. },
  227. set: /**
  228. * @param {?} value
  229. * @return {?}
  230. */
  231. function (value) {
  232. this._hideToggle = coercion.coerceBooleanProperty(value);
  233. },
  234. enumerable: true,
  235. configurable: true
  236. });
  237. Object.defineProperty(MatExpansionPanel.prototype, "togglePosition", {
  238. /** The position of the expansion indicator. */
  239. get: /**
  240. * The position of the expansion indicator.
  241. * @return {?}
  242. */
  243. function () {
  244. return this._togglePosition || (this.accordion && this.accordion.togglePosition);
  245. },
  246. set: /**
  247. * @param {?} value
  248. * @return {?}
  249. */
  250. function (value) {
  251. this._togglePosition = value;
  252. },
  253. enumerable: true,
  254. configurable: true
  255. });
  256. /** Determines whether the expansion panel should have spacing between it and its siblings. */
  257. /**
  258. * Determines whether the expansion panel should have spacing between it and its siblings.
  259. * @return {?}
  260. */
  261. MatExpansionPanel.prototype._hasSpacing = /**
  262. * Determines whether the expansion panel should have spacing between it and its siblings.
  263. * @return {?}
  264. */
  265. function () {
  266. if (this.accordion) {
  267. // We don't need to subscribe to the `stateChanges` of the parent accordion because each time
  268. // the [displayMode] input changes, the change detection will also cover the host bindings
  269. // of this expansion panel.
  270. return (this.expanded ? this.accordion.displayMode : this._getExpandedState()) === 'default';
  271. }
  272. return false;
  273. };
  274. /** Gets the expanded state string. */
  275. /**
  276. * Gets the expanded state string.
  277. * @return {?}
  278. */
  279. MatExpansionPanel.prototype._getExpandedState = /**
  280. * Gets the expanded state string.
  281. * @return {?}
  282. */
  283. function () {
  284. return this.expanded ? 'expanded' : 'collapsed';
  285. };
  286. /**
  287. * @return {?}
  288. */
  289. MatExpansionPanel.prototype.ngAfterContentInit = /**
  290. * @return {?}
  291. */
  292. function () {
  293. var _this = this;
  294. if (this._lazyContent) {
  295. // Render the content as soon as the panel becomes open.
  296. this.opened.pipe(operators.startWith((/** @type {?} */ (null))), operators.filter((/**
  297. * @return {?}
  298. */
  299. function () { return _this.expanded && !_this._portal; })), operators.take(1)).subscribe((/**
  300. * @return {?}
  301. */
  302. function () {
  303. _this._portal = new portal.TemplatePortal(_this._lazyContent._template, _this._viewContainerRef);
  304. }));
  305. }
  306. };
  307. /**
  308. * @param {?} changes
  309. * @return {?}
  310. */
  311. MatExpansionPanel.prototype.ngOnChanges = /**
  312. * @param {?} changes
  313. * @return {?}
  314. */
  315. function (changes) {
  316. this._inputChanges.next(changes);
  317. };
  318. /**
  319. * @return {?}
  320. */
  321. MatExpansionPanel.prototype.ngOnDestroy = /**
  322. * @return {?}
  323. */
  324. function () {
  325. _super.prototype.ngOnDestroy.call(this);
  326. this._bodyAnimationDone.complete();
  327. this._inputChanges.complete();
  328. };
  329. /** Checks whether the expansion panel's content contains the currently-focused element. */
  330. /**
  331. * Checks whether the expansion panel's content contains the currently-focused element.
  332. * @return {?}
  333. */
  334. MatExpansionPanel.prototype._containsFocus = /**
  335. * Checks whether the expansion panel's content contains the currently-focused element.
  336. * @return {?}
  337. */
  338. function () {
  339. if (this._body) {
  340. /** @type {?} */
  341. var focusedElement = this._document.activeElement;
  342. /** @type {?} */
  343. var bodyElement = this._body.nativeElement;
  344. return focusedElement === bodyElement || bodyElement.contains(focusedElement);
  345. }
  346. return false;
  347. };
  348. MatExpansionPanel.decorators = [
  349. { type: core.Component, args: [{styles: [".mat-expansion-panel{box-sizing:content-box;display:block;margin:0;border-radius:4px;overflow:hidden;transition:margin 225ms cubic-bezier(.4,0,.2,1),box-shadow 280ms cubic-bezier(.4,0,.2,1)}.mat-accordion .mat-expansion-panel:not(.mat-expanded),.mat-accordion .mat-expansion-panel:not(.mat-expansion-panel-spacing){border-radius:0}.mat-accordion .mat-expansion-panel:first-of-type{border-top-right-radius:4px;border-top-left-radius:4px}.mat-accordion .mat-expansion-panel:last-of-type{border-bottom-right-radius:4px;border-bottom-left-radius:4px}@media (-ms-high-contrast:active){.mat-expansion-panel{outline:solid 1px}}.mat-expansion-panel._mat-animation-noopable,.mat-expansion-panel.ng-animate-disabled,.ng-animate-disabled .mat-expansion-panel{transition:none}.mat-expansion-panel-content{display:flex;flex-direction:column;overflow:visible}.mat-expansion-panel-body{padding:0 24px 16px}.mat-expansion-panel-spacing{margin:16px 0}.mat-accordion>.mat-expansion-panel-spacing:first-child,.mat-accordion>:first-child:not(.mat-expansion-panel) .mat-expansion-panel-spacing{margin-top:0}.mat-accordion>.mat-expansion-panel-spacing:last-child,.mat-accordion>:last-child:not(.mat-expansion-panel) .mat-expansion-panel-spacing{margin-bottom:0}.mat-action-row{border-top-style:solid;border-top-width:1px;display:flex;flex-direction:row;justify-content:flex-end;padding:16px 8px 16px 24px}.mat-action-row button.mat-button-base{margin-left:8px}[dir=rtl] .mat-action-row button.mat-button-base{margin-left:0;margin-right:8px}"],
  350. selector: 'mat-expansion-panel',
  351. exportAs: 'matExpansionPanel',
  352. template: "<ng-content select=\"mat-expansion-panel-header\"></ng-content><div class=\"mat-expansion-panel-content\" role=\"region\" [@bodyExpansion]=\"_getExpandedState()\" (@bodyExpansion.done)=\"_bodyAnimationDone.next($event)\" [attr.aria-labelledby]=\"_headerId\" [id]=\"id\" #body><div class=\"mat-expansion-panel-body\"><ng-content></ng-content><ng-template [cdkPortalOutlet]=\"_portal\"></ng-template></div><ng-content select=\"mat-action-row\"></ng-content></div>",
  353. encapsulation: core.ViewEncapsulation.None,
  354. changeDetection: core.ChangeDetectionStrategy.OnPush,
  355. inputs: ['disabled', 'expanded'],
  356. outputs: ['opened', 'closed', 'expandedChange'],
  357. animations: [matExpansionAnimations.bodyExpansion],
  358. providers: [
  359. // Provide MatAccordion as undefined to prevent nested expansion panels from registering
  360. // to the same accordion.
  361. { provide: MAT_ACCORDION, useValue: ɵ0 },
  362. ],
  363. host: {
  364. 'class': 'mat-expansion-panel',
  365. '[class.mat-expanded]': 'expanded',
  366. '[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
  367. '[class.mat-expansion-panel-spacing]': '_hasSpacing()',
  368. }
  369. },] },
  370. ];
  371. /** @nocollapse */
  372. MatExpansionPanel.ctorParameters = function () { return [
  373. { type: undefined, decorators: [{ type: core.Optional }, { type: core.SkipSelf }, { type: core.Inject, args: [MAT_ACCORDION,] }] },
  374. { type: core.ChangeDetectorRef },
  375. { type: collections.UniqueSelectionDispatcher },
  376. { type: core.ViewContainerRef },
  377. { type: undefined, decorators: [{ type: core.Inject, args: [common.DOCUMENT,] }] },
  378. { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [animations$1.ANIMATION_MODULE_TYPE,] }] },
  379. { type: undefined, decorators: [{ type: core.Inject, args: [MAT_EXPANSION_PANEL_DEFAULT_OPTIONS,] }, { type: core.Optional }] }
  380. ]; };
  381. MatExpansionPanel.propDecorators = {
  382. hideToggle: [{ type: core.Input }],
  383. togglePosition: [{ type: core.Input }],
  384. afterExpand: [{ type: core.Output }],
  385. afterCollapse: [{ type: core.Output }],
  386. _lazyContent: [{ type: core.ContentChild, args: [MatExpansionPanelContent, { static: false },] }],
  387. _body: [{ type: core.ViewChild, args: ['body', { static: false },] }]
  388. };
  389. return MatExpansionPanel;
  390. }(accordion.CdkAccordionItem));
  391. var MatExpansionPanelActionRow = /** @class */ (function () {
  392. function MatExpansionPanelActionRow() {
  393. }
  394. MatExpansionPanelActionRow.decorators = [
  395. { type: core.Directive, args: [{
  396. selector: 'mat-action-row',
  397. host: {
  398. class: 'mat-action-row'
  399. }
  400. },] },
  401. ];
  402. return MatExpansionPanelActionRow;
  403. }());
  404. /**
  405. * @fileoverview added by tsickle
  406. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  407. */
  408. /**
  409. * `<mat-expansion-panel-header>`
  410. *
  411. * This component corresponds to the header element of an `<mat-expansion-panel>`.
  412. */
  413. var MatExpansionPanelHeader = /** @class */ (function () {
  414. function MatExpansionPanelHeader(panel, _element, _focusMonitor, _changeDetectorRef, defaultOptions) {
  415. var _this = this;
  416. this.panel = panel;
  417. this._element = _element;
  418. this._focusMonitor = _focusMonitor;
  419. this._changeDetectorRef = _changeDetectorRef;
  420. this._parentChangeSubscription = rxjs.Subscription.EMPTY;
  421. /**
  422. * Whether Angular animations in the panel header should be disabled.
  423. */
  424. this._animationsDisabled = true;
  425. /** @type {?} */
  426. var accordionHideToggleChange = panel.accordion ?
  427. panel.accordion._stateChanges.pipe(operators.filter((/**
  428. * @param {?} changes
  429. * @return {?}
  430. */
  431. function (changes) { return !!(changes['hideToggle'] || changes['togglePosition']); }))) :
  432. rxjs.EMPTY;
  433. // Since the toggle state depends on an @Input on the panel, we
  434. // need to subscribe and trigger change detection manually.
  435. this._parentChangeSubscription =
  436. rxjs.merge(panel.opened, panel.closed, accordionHideToggleChange, panel._inputChanges.pipe(operators.filter((/**
  437. * @param {?} changes
  438. * @return {?}
  439. */
  440. function (changes) {
  441. return !!(changes['hideToggle'] ||
  442. changes['disabled'] ||
  443. changes['togglePosition']);
  444. }))))
  445. .subscribe((/**
  446. * @return {?}
  447. */
  448. function () { return _this._changeDetectorRef.markForCheck(); }));
  449. // Avoids focus being lost if the panel contained the focused element and was closed.
  450. panel.closed
  451. .pipe(operators.filter((/**
  452. * @return {?}
  453. */
  454. function () { return panel._containsFocus(); })))
  455. .subscribe((/**
  456. * @return {?}
  457. */
  458. function () { return _focusMonitor.focusVia(_element, 'program'); }));
  459. _focusMonitor.monitor(_element).subscribe((/**
  460. * @param {?} origin
  461. * @return {?}
  462. */
  463. function (origin) {
  464. if (origin && panel.accordion) {
  465. panel.accordion._handleHeaderFocus(_this);
  466. }
  467. }));
  468. if (defaultOptions) {
  469. this.expandedHeight = defaultOptions.expandedHeight;
  470. this.collapsedHeight = defaultOptions.collapsedHeight;
  471. }
  472. }
  473. /**
  474. * @return {?}
  475. */
  476. MatExpansionPanelHeader.prototype._animationStarted = /**
  477. * @return {?}
  478. */
  479. function () {
  480. // Currently the `expansionHeight` animation has a `void => collapsed` transition which is
  481. // there to work around a bug in Angular (see #13088), however this introduces a different
  482. // issue. The new transition will cause the header to animate in on init (see #16067), if the
  483. // consumer has set a header height that is different from the default one. We work around it
  484. // by disabling animations on the header and re-enabling them after the first animation has run.
  485. // Note that Angular dispatches animation events even if animations are disabled. Ideally this
  486. // wouldn't be necessary if we remove the `void => collapsed` transition, but we have to wait
  487. // for https://github.com/angular/angular/issues/18847 to be resolved.
  488. this._animationsDisabled = false;
  489. };
  490. Object.defineProperty(MatExpansionPanelHeader.prototype, "disabled", {
  491. /**
  492. * Whether the associated panel is disabled. Implemented as a part of `FocusableOption`.
  493. * @docs-private
  494. */
  495. get: /**
  496. * Whether the associated panel is disabled. Implemented as a part of `FocusableOption`.
  497. * \@docs-private
  498. * @return {?}
  499. */
  500. function () {
  501. return this.panel.disabled;
  502. },
  503. enumerable: true,
  504. configurable: true
  505. });
  506. /** Toggles the expanded state of the panel. */
  507. /**
  508. * Toggles the expanded state of the panel.
  509. * @return {?}
  510. */
  511. MatExpansionPanelHeader.prototype._toggle = /**
  512. * Toggles the expanded state of the panel.
  513. * @return {?}
  514. */
  515. function () {
  516. this.panel.toggle();
  517. };
  518. /** Gets whether the panel is expanded. */
  519. /**
  520. * Gets whether the panel is expanded.
  521. * @return {?}
  522. */
  523. MatExpansionPanelHeader.prototype._isExpanded = /**
  524. * Gets whether the panel is expanded.
  525. * @return {?}
  526. */
  527. function () {
  528. return this.panel.expanded;
  529. };
  530. /** Gets the expanded state string of the panel. */
  531. /**
  532. * Gets the expanded state string of the panel.
  533. * @return {?}
  534. */
  535. MatExpansionPanelHeader.prototype._getExpandedState = /**
  536. * Gets the expanded state string of the panel.
  537. * @return {?}
  538. */
  539. function () {
  540. return this.panel._getExpandedState();
  541. };
  542. /** Gets the panel id. */
  543. /**
  544. * Gets the panel id.
  545. * @return {?}
  546. */
  547. MatExpansionPanelHeader.prototype._getPanelId = /**
  548. * Gets the panel id.
  549. * @return {?}
  550. */
  551. function () {
  552. return this.panel.id;
  553. };
  554. /** Gets the toggle position for the header. */
  555. /**
  556. * Gets the toggle position for the header.
  557. * @return {?}
  558. */
  559. MatExpansionPanelHeader.prototype._getTogglePosition = /**
  560. * Gets the toggle position for the header.
  561. * @return {?}
  562. */
  563. function () {
  564. return this.panel.togglePosition;
  565. };
  566. /** Gets whether the expand indicator should be shown. */
  567. /**
  568. * Gets whether the expand indicator should be shown.
  569. * @return {?}
  570. */
  571. MatExpansionPanelHeader.prototype._showToggle = /**
  572. * Gets whether the expand indicator should be shown.
  573. * @return {?}
  574. */
  575. function () {
  576. return !this.panel.hideToggle && !this.panel.disabled;
  577. };
  578. /** Handle keydown event calling to toggle() if appropriate. */
  579. /**
  580. * Handle keydown event calling to toggle() if appropriate.
  581. * @param {?} event
  582. * @return {?}
  583. */
  584. MatExpansionPanelHeader.prototype._keydown = /**
  585. * Handle keydown event calling to toggle() if appropriate.
  586. * @param {?} event
  587. * @return {?}
  588. */
  589. function (event) {
  590. switch (event.keyCode) {
  591. // Toggle for space and enter keys.
  592. case keycodes.SPACE:
  593. case keycodes.ENTER:
  594. if (!keycodes.hasModifierKey(event)) {
  595. event.preventDefault();
  596. this._toggle();
  597. }
  598. break;
  599. default:
  600. if (this.panel.accordion) {
  601. this.panel.accordion._handleHeaderKeydown(event);
  602. }
  603. return;
  604. }
  605. };
  606. /**
  607. * Focuses the panel header. Implemented as a part of `FocusableOption`.
  608. * @param origin Origin of the action that triggered the focus.
  609. * @docs-private
  610. */
  611. /**
  612. * Focuses the panel header. Implemented as a part of `FocusableOption`.
  613. * \@docs-private
  614. * @param {?=} origin Origin of the action that triggered the focus.
  615. * @param {?=} options
  616. * @return {?}
  617. */
  618. MatExpansionPanelHeader.prototype.focus = /**
  619. * Focuses the panel header. Implemented as a part of `FocusableOption`.
  620. * \@docs-private
  621. * @param {?=} origin Origin of the action that triggered the focus.
  622. * @param {?=} options
  623. * @return {?}
  624. */
  625. function (origin, options) {
  626. if (origin === void 0) { origin = 'program'; }
  627. this._focusMonitor.focusVia(this._element, origin, options);
  628. };
  629. /**
  630. * @return {?}
  631. */
  632. MatExpansionPanelHeader.prototype.ngOnDestroy = /**
  633. * @return {?}
  634. */
  635. function () {
  636. this._parentChangeSubscription.unsubscribe();
  637. this._focusMonitor.stopMonitoring(this._element);
  638. };
  639. MatExpansionPanelHeader.decorators = [
  640. { type: core.Component, args: [{selector: 'mat-expansion-panel-header',
  641. styles: [".mat-expansion-panel-header{display:flex;flex-direction:row;align-items:center;padding:0 24px;border-radius:inherit}.mat-expansion-panel-header:focus,.mat-expansion-panel-header:hover{outline:0}.mat-expansion-panel-header.mat-expanded:focus,.mat-expansion-panel-header.mat-expanded:hover{background:inherit}.mat-expansion-panel-header:not([aria-disabled=true]){cursor:pointer}.mat-expansion-panel-header.mat-expansion-toggle-indicator-before{flex-direction:row-reverse}.mat-expansion-panel-header.mat-expansion-toggle-indicator-before .mat-expansion-indicator{margin:0 16px 0 0}[dir=rtl] .mat-expansion-panel-header.mat-expansion-toggle-indicator-before .mat-expansion-indicator{margin:0 0 0 16px}.mat-content{display:flex;flex:1;flex-direction:row;overflow:hidden}.mat-expansion-panel-header-description,.mat-expansion-panel-header-title{display:flex;flex-grow:1;margin-right:16px}[dir=rtl] .mat-expansion-panel-header-description,[dir=rtl] .mat-expansion-panel-header-title{margin-right:0;margin-left:16px}.mat-expansion-panel-header-description{flex-grow:2}.mat-expansion-indicator::after{border-style:solid;border-width:0 2px 2px 0;content:'';display:inline-block;padding:3px;transform:rotate(45deg);vertical-align:middle}"],
  642. template: "<span class=\"mat-content\"><ng-content select=\"mat-panel-title\"></ng-content><ng-content select=\"mat-panel-description\"></ng-content><ng-content></ng-content></span><span [@indicatorRotate]=\"_getExpandedState()\" *ngIf=\"_showToggle()\" class=\"mat-expansion-indicator\"></span>",
  643. encapsulation: core.ViewEncapsulation.None,
  644. changeDetection: core.ChangeDetectionStrategy.OnPush,
  645. animations: [
  646. matExpansionAnimations.indicatorRotate,
  647. matExpansionAnimations.expansionHeaderHeight
  648. ],
  649. host: {
  650. 'class': 'mat-expansion-panel-header',
  651. 'role': 'button',
  652. '[attr.id]': 'panel._headerId',
  653. '[attr.tabindex]': 'disabled ? -1 : 0',
  654. '[attr.aria-controls]': '_getPanelId()',
  655. '[attr.aria-expanded]': '_isExpanded()',
  656. '[attr.aria-disabled]': 'panel.disabled',
  657. '[class.mat-expanded]': '_isExpanded()',
  658. '[class.mat-expansion-toggle-indicator-after]': "_getTogglePosition() === 'after'",
  659. '[class.mat-expansion-toggle-indicator-before]': "_getTogglePosition() === 'before'",
  660. '(click)': '_toggle()',
  661. '(keydown)': '_keydown($event)',
  662. '[@.disabled]': '_animationsDisabled',
  663. '(@expansionHeight.start)': '_animationStarted()',
  664. '[@expansionHeight]': "{\n value: _getExpandedState(),\n params: {\n collapsedHeight: collapsedHeight,\n expandedHeight: expandedHeight\n }\n }",
  665. },
  666. },] },
  667. ];
  668. /** @nocollapse */
  669. MatExpansionPanelHeader.ctorParameters = function () { return [
  670. { type: MatExpansionPanel, decorators: [{ type: core.Host }] },
  671. { type: core.ElementRef },
  672. { type: a11y.FocusMonitor },
  673. { type: core.ChangeDetectorRef },
  674. { type: undefined, decorators: [{ type: core.Inject, args: [MAT_EXPANSION_PANEL_DEFAULT_OPTIONS,] }, { type: core.Optional }] }
  675. ]; };
  676. MatExpansionPanelHeader.propDecorators = {
  677. expandedHeight: [{ type: core.Input }],
  678. collapsedHeight: [{ type: core.Input }]
  679. };
  680. return MatExpansionPanelHeader;
  681. }());
  682. /**
  683. * `<mat-panel-description>`
  684. *
  685. * This directive is to be used inside of the MatExpansionPanelHeader component.
  686. */
  687. var MatExpansionPanelDescription = /** @class */ (function () {
  688. function MatExpansionPanelDescription() {
  689. }
  690. MatExpansionPanelDescription.decorators = [
  691. { type: core.Directive, args: [{
  692. selector: 'mat-panel-description',
  693. host: {
  694. class: 'mat-expansion-panel-header-description'
  695. }
  696. },] },
  697. ];
  698. return MatExpansionPanelDescription;
  699. }());
  700. /**
  701. * `<mat-panel-title>`
  702. *
  703. * This directive is to be used inside of the MatExpansionPanelHeader component.
  704. */
  705. var MatExpansionPanelTitle = /** @class */ (function () {
  706. function MatExpansionPanelTitle() {
  707. }
  708. MatExpansionPanelTitle.decorators = [
  709. { type: core.Directive, args: [{
  710. selector: 'mat-panel-title',
  711. host: {
  712. class: 'mat-expansion-panel-header-title'
  713. }
  714. },] },
  715. ];
  716. return MatExpansionPanelTitle;
  717. }());
  718. /**
  719. * @fileoverview added by tsickle
  720. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  721. */
  722. /**
  723. * Directive for a Material Design Accordion.
  724. */
  725. var MatAccordion = /** @class */ (function (_super) {
  726. __extends(MatAccordion, _super);
  727. function MatAccordion() {
  728. var _this = _super !== null && _super.apply(this, arguments) || this;
  729. _this._hideToggle = false;
  730. /**
  731. * Display mode used for all expansion panels in the accordion. Currently two display
  732. * modes exist:
  733. * default - a gutter-like spacing is placed around any expanded panel, placing the expanded
  734. * panel at a different elevation from the rest of the accordion.
  735. * flat - no spacing is placed around expanded panels, showing all panels at the same
  736. * elevation.
  737. */
  738. _this.displayMode = 'default';
  739. /**
  740. * The position of the expansion indicator.
  741. */
  742. _this.togglePosition = 'after';
  743. return _this;
  744. }
  745. Object.defineProperty(MatAccordion.prototype, "hideToggle", {
  746. /** Whether the expansion indicator should be hidden. */
  747. get: /**
  748. * Whether the expansion indicator should be hidden.
  749. * @return {?}
  750. */
  751. function () { return this._hideToggle; },
  752. set: /**
  753. * @param {?} show
  754. * @return {?}
  755. */
  756. function (show) { this._hideToggle = coercion.coerceBooleanProperty(show); },
  757. enumerable: true,
  758. configurable: true
  759. });
  760. /**
  761. * @return {?}
  762. */
  763. MatAccordion.prototype.ngAfterContentInit = /**
  764. * @return {?}
  765. */
  766. function () {
  767. this._keyManager = new a11y.FocusKeyManager(this._headers).withWrap();
  768. };
  769. /** Handles keyboard events coming in from the panel headers. */
  770. /**
  771. * Handles keyboard events coming in from the panel headers.
  772. * @param {?} event
  773. * @return {?}
  774. */
  775. MatAccordion.prototype._handleHeaderKeydown = /**
  776. * Handles keyboard events coming in from the panel headers.
  777. * @param {?} event
  778. * @return {?}
  779. */
  780. function (event) {
  781. var keyCode = event.keyCode;
  782. /** @type {?} */
  783. var manager = this._keyManager;
  784. if (keyCode === keycodes.HOME) {
  785. if (!keycodes.hasModifierKey(event)) {
  786. manager.setFirstItemActive();
  787. event.preventDefault();
  788. }
  789. }
  790. else if (keyCode === keycodes.END) {
  791. if (!keycodes.hasModifierKey(event)) {
  792. manager.setLastItemActive();
  793. event.preventDefault();
  794. }
  795. }
  796. else {
  797. this._keyManager.onKeydown(event);
  798. }
  799. };
  800. /**
  801. * @param {?} header
  802. * @return {?}
  803. */
  804. MatAccordion.prototype._handleHeaderFocus = /**
  805. * @param {?} header
  806. * @return {?}
  807. */
  808. function (header) {
  809. this._keyManager.updateActiveItem(header);
  810. };
  811. MatAccordion.decorators = [
  812. { type: core.Directive, args: [{
  813. selector: 'mat-accordion',
  814. exportAs: 'matAccordion',
  815. inputs: ['multi'],
  816. providers: [{
  817. provide: MAT_ACCORDION,
  818. useExisting: MatAccordion
  819. }],
  820. host: {
  821. class: 'mat-accordion'
  822. }
  823. },] },
  824. ];
  825. MatAccordion.propDecorators = {
  826. _headers: [{ type: core.ContentChildren, args: [MatExpansionPanelHeader, { descendants: true },] }],
  827. hideToggle: [{ type: core.Input }],
  828. displayMode: [{ type: core.Input }],
  829. togglePosition: [{ type: core.Input }]
  830. };
  831. return MatAccordion;
  832. }(accordion.CdkAccordion));
  833. /**
  834. * @fileoverview added by tsickle
  835. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  836. */
  837. var MatExpansionModule = /** @class */ (function () {
  838. function MatExpansionModule() {
  839. }
  840. MatExpansionModule.decorators = [
  841. { type: core.NgModule, args: [{
  842. imports: [common.CommonModule, accordion.CdkAccordionModule, portal.PortalModule],
  843. exports: [
  844. MatAccordion,
  845. MatExpansionPanel,
  846. MatExpansionPanelActionRow,
  847. MatExpansionPanelHeader,
  848. MatExpansionPanelTitle,
  849. MatExpansionPanelDescription,
  850. MatExpansionPanelContent,
  851. ],
  852. declarations: [
  853. MatAccordion,
  854. MatExpansionPanel,
  855. MatExpansionPanelActionRow,
  856. MatExpansionPanelHeader,
  857. MatExpansionPanelTitle,
  858. MatExpansionPanelDescription,
  859. MatExpansionPanelContent,
  860. ],
  861. },] },
  862. ];
  863. return MatExpansionModule;
  864. }());
  865. exports.MatExpansionModule = MatExpansionModule;
  866. exports.MatAccordion = MatAccordion;
  867. exports.MAT_ACCORDION = MAT_ACCORDION;
  868. exports.MAT_EXPANSION_PANEL_DEFAULT_OPTIONS = MAT_EXPANSION_PANEL_DEFAULT_OPTIONS;
  869. exports.MatExpansionPanel = MatExpansionPanel;
  870. exports.MatExpansionPanelActionRow = MatExpansionPanelActionRow;
  871. exports.MatExpansionPanelHeader = MatExpansionPanelHeader;
  872. exports.MatExpansionPanelDescription = MatExpansionPanelDescription;
  873. exports.MatExpansionPanelTitle = MatExpansionPanelTitle;
  874. exports.MatExpansionPanelContent = MatExpansionPanelContent;
  875. exports.EXPANSION_PANEL_ANIMATION_TIMING = EXPANSION_PANEL_ANIMATION_TIMING;
  876. exports.matExpansionAnimations = matExpansionAnimations;
  877. Object.defineProperty(exports, '__esModule', { value: true });
  878. })));
  879. //# sourceMappingURL=material-expansion.umd.js.map