material-sidenav.umd.js 64 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562
  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/animations'), require('@angular/cdk/a11y'), require('@angular/cdk/bidi'), require('@angular/cdk/coercion'), require('@angular/cdk/keycodes'), require('@angular/cdk/platform'), require('@angular/cdk/scrolling'), require('@angular/common'), require('@angular/core'), require('rxjs'), require('rxjs/operators'), require('@angular/platform-browser/animations'), require('@angular/material/core')) :
  10. typeof define === 'function' && define.amd ? define('@angular/material/sidenav', ['exports', '@angular/animations', '@angular/cdk/a11y', '@angular/cdk/bidi', '@angular/cdk/coercion', '@angular/cdk/keycodes', '@angular/cdk/platform', '@angular/cdk/scrolling', '@angular/common', '@angular/core', 'rxjs', 'rxjs/operators', '@angular/platform-browser/animations', '@angular/material/core'], factory) :
  11. (factory((global.ng = global.ng || {}, global.ng.material = global.ng.material || {}, global.ng.material.sidenav = {}),global.ng.animations,global.ng.cdk.a11y,global.ng.cdk.bidi,global.ng.cdk.coercion,global.ng.cdk.keycodes,global.ng.cdk.platform,global.ng.cdk.scrolling,global.ng.common,global.ng.core,global.rxjs,global.rxjs.operators,global.ng.platformBrowser.animations,global.ng.material.core));
  12. }(this, (function (exports,animations,a11y,bidi,coercion,keycodes,platform,scrolling,common,core,rxjs,operators,animations$1,core$1) { '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. * Animations used by the Material drawers.
  43. * \@docs-private
  44. * @type {?}
  45. */
  46. var matDrawerAnimations = {
  47. /**
  48. * Animation that slides a drawer in and out.
  49. */
  50. transformDrawer: animations.trigger('transform', [
  51. // We remove the `transform` here completely, rather than setting it to zero, because:
  52. // 1. Having a transform can cause elements with ripples or an animated
  53. // transform to shift around in Chrome with an RTL layout (see #10023).
  54. // 2. 3d transforms causes text to appear blurry on IE and Edge.
  55. animations.state('open, open-instant', animations.style({
  56. 'transform': 'none',
  57. 'visibility': 'visible',
  58. })),
  59. animations.state('void', animations.style({
  60. // Avoids the shadow showing up when closed in SSR.
  61. 'box-shadow': 'none',
  62. 'visibility': 'hidden',
  63. })),
  64. animations.transition('void => open-instant', animations.animate('0ms')),
  65. animations.transition('void <=> open, open-instant => void', animations.animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)'))
  66. ])
  67. };
  68. /**
  69. * @fileoverview added by tsickle
  70. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  71. */
  72. /**
  73. * Throws an exception when two MatDrawer are matching the same position.
  74. * \@docs-private
  75. * @param {?} position
  76. * @return {?}
  77. */
  78. function throwMatDuplicatedDrawerError(position) {
  79. throw Error("A drawer was already declared for 'position=\"" + position + "\"'");
  80. }
  81. /**
  82. * Configures whether drawers should use auto sizing by default.
  83. * @type {?}
  84. */
  85. var MAT_DRAWER_DEFAULT_AUTOSIZE = new core.InjectionToken('MAT_DRAWER_DEFAULT_AUTOSIZE', {
  86. providedIn: 'root',
  87. factory: MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY,
  88. });
  89. /**
  90. * \@docs-private
  91. * @return {?}
  92. */
  93. function MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY() {
  94. return false;
  95. }
  96. var MatDrawerContent = /** @class */ (function (_super) {
  97. __extends(MatDrawerContent, _super);
  98. function MatDrawerContent(_changeDetectorRef, _container, elementRef, scrollDispatcher, ngZone) {
  99. var _this = _super.call(this, elementRef, scrollDispatcher, ngZone) || this;
  100. _this._changeDetectorRef = _changeDetectorRef;
  101. _this._container = _container;
  102. return _this;
  103. }
  104. /**
  105. * @return {?}
  106. */
  107. MatDrawerContent.prototype.ngAfterContentInit = /**
  108. * @return {?}
  109. */
  110. function () {
  111. var _this = this;
  112. this._container._contentMarginChanges.subscribe((/**
  113. * @return {?}
  114. */
  115. function () {
  116. _this._changeDetectorRef.markForCheck();
  117. }));
  118. };
  119. MatDrawerContent.decorators = [
  120. { type: core.Component, args: [{selector: 'mat-drawer-content',
  121. template: '<ng-content></ng-content>',
  122. host: {
  123. 'class': 'mat-drawer-content',
  124. '[style.margin-left.px]': '_container._contentMargins.left',
  125. '[style.margin-right.px]': '_container._contentMargins.right',
  126. },
  127. changeDetection: core.ChangeDetectionStrategy.OnPush,
  128. encapsulation: core.ViewEncapsulation.None,
  129. },] },
  130. ];
  131. /** @nocollapse */
  132. MatDrawerContent.ctorParameters = function () { return [
  133. { type: core.ChangeDetectorRef },
  134. { type: MatDrawerContainer, decorators: [{ type: core.Inject, args: [core.forwardRef((/**
  135. * @return {?}
  136. */
  137. function () { return MatDrawerContainer; })),] }] },
  138. { type: core.ElementRef },
  139. { type: scrolling.ScrollDispatcher },
  140. { type: core.NgZone }
  141. ]; };
  142. return MatDrawerContent;
  143. }(scrolling.CdkScrollable));
  144. /**
  145. * This component corresponds to a drawer that can be opened on the drawer container.
  146. */
  147. var MatDrawer = /** @class */ (function () {
  148. function MatDrawer(_elementRef, _focusTrapFactory, _focusMonitor, _platform, _ngZone, _doc) {
  149. var _this = this;
  150. this._elementRef = _elementRef;
  151. this._focusTrapFactory = _focusTrapFactory;
  152. this._focusMonitor = _focusMonitor;
  153. this._platform = _platform;
  154. this._ngZone = _ngZone;
  155. this._doc = _doc;
  156. this._elementFocusedBeforeDrawerWasOpened = null;
  157. /**
  158. * Whether the drawer is initialized. Used for disabling the initial animation.
  159. */
  160. this._enableAnimations = false;
  161. this._position = 'start';
  162. this._mode = 'over';
  163. this._disableClose = false;
  164. this._autoFocus = true;
  165. /**
  166. * Emits whenever the drawer has started animating.
  167. */
  168. this._animationStarted = new rxjs.Subject();
  169. /**
  170. * Emits whenever the drawer is done animating.
  171. */
  172. this._animationEnd = new rxjs.Subject();
  173. /**
  174. * Current state of the sidenav animation.
  175. */
  176. // @HostBinding is used in the class as it is expected to be extended. Since @Component decorator
  177. // metadata is not inherited by child classes, instead the host binding data is defined in a way
  178. // that can be inherited.
  179. // tslint:disable:no-host-decorator-in-concrete
  180. this._animationState = 'void';
  181. /**
  182. * Event emitted when the drawer open state is changed.
  183. */
  184. this.openedChange =
  185. // Note this has to be async in order to avoid some issues with two-bindings (see #8872).
  186. new core.EventEmitter(/* isAsync */ true);
  187. /**
  188. * Emits when the component is destroyed.
  189. */
  190. this._destroyed = new rxjs.Subject();
  191. /**
  192. * Event emitted when the drawer's position changes.
  193. */
  194. // tslint:disable-next-line:no-output-on-prefix
  195. this.onPositionChanged = new core.EventEmitter();
  196. /**
  197. * An observable that emits when the drawer mode changes. This is used by the drawer container to
  198. * to know when to when the mode changes so it can adapt the margins on the content.
  199. */
  200. this._modeChanged = new rxjs.Subject();
  201. this._opened = false;
  202. this.openedChange.subscribe((/**
  203. * @param {?} opened
  204. * @return {?}
  205. */
  206. function (opened) {
  207. if (opened) {
  208. if (_this._doc) {
  209. _this._elementFocusedBeforeDrawerWasOpened = (/** @type {?} */ (_this._doc.activeElement));
  210. }
  211. if (_this._isFocusTrapEnabled && _this._focusTrap) {
  212. _this._trapFocus();
  213. }
  214. }
  215. else {
  216. _this._restoreFocus();
  217. }
  218. }));
  219. /**
  220. * Listen to `keydown` events outside the zone so that change detection is not run every
  221. * time a key is pressed. Instead we re-enter the zone only if the `ESC` key is pressed
  222. * and we don't have close disabled.
  223. */
  224. this._ngZone.runOutsideAngular((/**
  225. * @return {?}
  226. */
  227. function () {
  228. ((/** @type {?} */ (rxjs.fromEvent(_this._elementRef.nativeElement, 'keydown')))).pipe(operators.filter((/**
  229. * @param {?} event
  230. * @return {?}
  231. */
  232. function (event) {
  233. return event.keyCode === keycodes.ESCAPE && !_this.disableClose && !keycodes.hasModifierKey(event);
  234. })), operators.takeUntil(_this._destroyed)).subscribe((/**
  235. * @param {?} event
  236. * @return {?}
  237. */
  238. function (event) { return _this._ngZone.run((/**
  239. * @return {?}
  240. */
  241. function () {
  242. _this.close();
  243. event.stopPropagation();
  244. event.preventDefault();
  245. })); }));
  246. }));
  247. // We need a Subject with distinctUntilChanged, because the `done` event
  248. // fires twice on some browsers. See https://github.com/angular/angular/issues/24084
  249. this._animationEnd.pipe(operators.distinctUntilChanged((/**
  250. * @param {?} x
  251. * @param {?} y
  252. * @return {?}
  253. */
  254. function (x, y) {
  255. return x.fromState === y.fromState && x.toState === y.toState;
  256. }))).subscribe((/**
  257. * @param {?} event
  258. * @return {?}
  259. */
  260. function (event) {
  261. var fromState = event.fromState, toState = event.toState;
  262. if ((toState.indexOf('open') === 0 && fromState === 'void') ||
  263. (toState === 'void' && fromState.indexOf('open') === 0)) {
  264. _this.openedChange.emit(_this._opened);
  265. }
  266. }));
  267. }
  268. Object.defineProperty(MatDrawer.prototype, "position", {
  269. /** The side that the drawer is attached to. */
  270. get: /**
  271. * The side that the drawer is attached to.
  272. * @return {?}
  273. */
  274. function () { return this._position; },
  275. set: /**
  276. * @param {?} value
  277. * @return {?}
  278. */
  279. function (value) {
  280. // Make sure we have a valid value.
  281. value = value === 'end' ? 'end' : 'start';
  282. if (value != this._position) {
  283. this._position = value;
  284. this.onPositionChanged.emit();
  285. }
  286. },
  287. enumerable: true,
  288. configurable: true
  289. });
  290. Object.defineProperty(MatDrawer.prototype, "mode", {
  291. /** Mode of the drawer; one of 'over', 'push' or 'side'. */
  292. get: /**
  293. * Mode of the drawer; one of 'over', 'push' or 'side'.
  294. * @return {?}
  295. */
  296. function () { return this._mode; },
  297. set: /**
  298. * @param {?} value
  299. * @return {?}
  300. */
  301. function (value) {
  302. this._mode = value;
  303. this._updateFocusTrapState();
  304. this._modeChanged.next();
  305. },
  306. enumerable: true,
  307. configurable: true
  308. });
  309. Object.defineProperty(MatDrawer.prototype, "disableClose", {
  310. /** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */
  311. get: /**
  312. * Whether the drawer can be closed with the escape key or by clicking on the backdrop.
  313. * @return {?}
  314. */
  315. function () { return this._disableClose; },
  316. set: /**
  317. * @param {?} value
  318. * @return {?}
  319. */
  320. function (value) { this._disableClose = coercion.coerceBooleanProperty(value); },
  321. enumerable: true,
  322. configurable: true
  323. });
  324. Object.defineProperty(MatDrawer.prototype, "autoFocus", {
  325. /** Whether the drawer should focus the first focusable element automatically when opened. */
  326. get: /**
  327. * Whether the drawer should focus the first focusable element automatically when opened.
  328. * @return {?}
  329. */
  330. function () { return this._autoFocus; },
  331. set: /**
  332. * @param {?} value
  333. * @return {?}
  334. */
  335. function (value) { this._autoFocus = coercion.coerceBooleanProperty(value); },
  336. enumerable: true,
  337. configurable: true
  338. });
  339. Object.defineProperty(MatDrawer.prototype, "_openedStream", {
  340. /** Event emitted when the drawer has been opened. */
  341. get: /**
  342. * Event emitted when the drawer has been opened.
  343. * @return {?}
  344. */
  345. function () {
  346. return this.openedChange.pipe(operators.filter((/**
  347. * @param {?} o
  348. * @return {?}
  349. */
  350. function (o) { return o; })), operators.map((/**
  351. * @return {?}
  352. */
  353. function () { })));
  354. },
  355. enumerable: true,
  356. configurable: true
  357. });
  358. Object.defineProperty(MatDrawer.prototype, "openedStart", {
  359. /** Event emitted when the drawer has started opening. */
  360. get: /**
  361. * Event emitted when the drawer has started opening.
  362. * @return {?}
  363. */
  364. function () {
  365. return this._animationStarted.pipe(operators.filter((/**
  366. * @param {?} e
  367. * @return {?}
  368. */
  369. function (e) { return e.fromState !== e.toState && e.toState.indexOf('open') === 0; })), operators.map((/**
  370. * @return {?}
  371. */
  372. function () { })));
  373. },
  374. enumerable: true,
  375. configurable: true
  376. });
  377. Object.defineProperty(MatDrawer.prototype, "_closedStream", {
  378. /** Event emitted when the drawer has been closed. */
  379. get: /**
  380. * Event emitted when the drawer has been closed.
  381. * @return {?}
  382. */
  383. function () {
  384. return this.openedChange.pipe(operators.filter((/**
  385. * @param {?} o
  386. * @return {?}
  387. */
  388. function (o) { return !o; })), operators.map((/**
  389. * @return {?}
  390. */
  391. function () { })));
  392. },
  393. enumerable: true,
  394. configurable: true
  395. });
  396. Object.defineProperty(MatDrawer.prototype, "closedStart", {
  397. /** Event emitted when the drawer has started closing. */
  398. get: /**
  399. * Event emitted when the drawer has started closing.
  400. * @return {?}
  401. */
  402. function () {
  403. return this._animationStarted.pipe(operators.filter((/**
  404. * @param {?} e
  405. * @return {?}
  406. */
  407. function (e) { return e.fromState !== e.toState && e.toState === 'void'; })), operators.map((/**
  408. * @return {?}
  409. */
  410. function () { })));
  411. },
  412. enumerable: true,
  413. configurable: true
  414. });
  415. Object.defineProperty(MatDrawer.prototype, "_isFocusTrapEnabled", {
  416. get: /**
  417. * @return {?}
  418. */
  419. function () {
  420. // The focus trap is only enabled when the drawer is open in any mode other than side.
  421. return this.opened && this.mode !== 'side';
  422. },
  423. enumerable: true,
  424. configurable: true
  425. });
  426. /** Traps focus inside the drawer. */
  427. /**
  428. * Traps focus inside the drawer.
  429. * @private
  430. * @return {?}
  431. */
  432. MatDrawer.prototype._trapFocus = /**
  433. * Traps focus inside the drawer.
  434. * @private
  435. * @return {?}
  436. */
  437. function () {
  438. var _this = this;
  439. if (!this.autoFocus) {
  440. return;
  441. }
  442. this._focusTrap.focusInitialElementWhenReady().then((/**
  443. * @param {?} hasMovedFocus
  444. * @return {?}
  445. */
  446. function (hasMovedFocus) {
  447. // If there were no focusable elements, focus the sidenav itself so the keyboard navigation
  448. // still works. We need to check that `focus` is a function due to Universal.
  449. if (!hasMovedFocus && typeof _this._elementRef.nativeElement.focus === 'function') {
  450. _this._elementRef.nativeElement.focus();
  451. }
  452. }));
  453. };
  454. /**
  455. * If focus is currently inside the drawer, restores it to where it was before the drawer
  456. * opened.
  457. */
  458. /**
  459. * If focus is currently inside the drawer, restores it to where it was before the drawer
  460. * opened.
  461. * @private
  462. * @return {?}
  463. */
  464. MatDrawer.prototype._restoreFocus = /**
  465. * If focus is currently inside the drawer, restores it to where it was before the drawer
  466. * opened.
  467. * @private
  468. * @return {?}
  469. */
  470. function () {
  471. if (!this.autoFocus) {
  472. return;
  473. }
  474. /** @type {?} */
  475. var activeEl = this._doc && this._doc.activeElement;
  476. if (activeEl && this._elementRef.nativeElement.contains(activeEl)) {
  477. if (this._elementFocusedBeforeDrawerWasOpened instanceof HTMLElement) {
  478. this._focusMonitor.focusVia(this._elementFocusedBeforeDrawerWasOpened, this._openedVia);
  479. }
  480. else {
  481. this._elementRef.nativeElement.blur();
  482. }
  483. }
  484. this._elementFocusedBeforeDrawerWasOpened = null;
  485. this._openedVia = null;
  486. };
  487. /**
  488. * @return {?}
  489. */
  490. MatDrawer.prototype.ngAfterContentInit = /**
  491. * @return {?}
  492. */
  493. function () {
  494. this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
  495. this._updateFocusTrapState();
  496. };
  497. /**
  498. * @return {?}
  499. */
  500. MatDrawer.prototype.ngAfterContentChecked = /**
  501. * @return {?}
  502. */
  503. function () {
  504. // Enable the animations after the lifecycle hooks have run, in order to avoid animating
  505. // drawers that are open by default. When we're on the server, we shouldn't enable the
  506. // animations, because we don't want the drawer to animate the first time the user sees
  507. // the page.
  508. if (this._platform.isBrowser) {
  509. this._enableAnimations = true;
  510. }
  511. };
  512. /**
  513. * @return {?}
  514. */
  515. MatDrawer.prototype.ngOnDestroy = /**
  516. * @return {?}
  517. */
  518. function () {
  519. if (this._focusTrap) {
  520. this._focusTrap.destroy();
  521. }
  522. this._animationStarted.complete();
  523. this._animationEnd.complete();
  524. this._modeChanged.complete();
  525. this._destroyed.next();
  526. this._destroyed.complete();
  527. };
  528. Object.defineProperty(MatDrawer.prototype, "opened", {
  529. /**
  530. * Whether the drawer is opened. We overload this because we trigger an event when it
  531. * starts or end.
  532. */
  533. get: /**
  534. * Whether the drawer is opened. We overload this because we trigger an event when it
  535. * starts or end.
  536. * @return {?}
  537. */
  538. function () { return this._opened; },
  539. set: /**
  540. * @param {?} value
  541. * @return {?}
  542. */
  543. function (value) { this.toggle(coercion.coerceBooleanProperty(value)); },
  544. enumerable: true,
  545. configurable: true
  546. });
  547. /**
  548. * Open the drawer.
  549. * @param openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  550. * Used for focus management after the sidenav is closed.
  551. */
  552. /**
  553. * Open the drawer.
  554. * @param {?=} openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  555. * Used for focus management after the sidenav is closed.
  556. * @return {?}
  557. */
  558. MatDrawer.prototype.open = /**
  559. * Open the drawer.
  560. * @param {?=} openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  561. * Used for focus management after the sidenav is closed.
  562. * @return {?}
  563. */
  564. function (openedVia) {
  565. return this.toggle(true, openedVia);
  566. };
  567. /** Close the drawer. */
  568. /**
  569. * Close the drawer.
  570. * @return {?}
  571. */
  572. MatDrawer.prototype.close = /**
  573. * Close the drawer.
  574. * @return {?}
  575. */
  576. function () {
  577. return this.toggle(false);
  578. };
  579. /**
  580. * Toggle this drawer.
  581. * @param isOpen Whether the drawer should be open.
  582. * @param openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  583. * Used for focus management after the sidenav is closed.
  584. */
  585. /**
  586. * Toggle this drawer.
  587. * @param {?=} isOpen Whether the drawer should be open.
  588. * @param {?=} openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  589. * Used for focus management after the sidenav is closed.
  590. * @return {?}
  591. */
  592. MatDrawer.prototype.toggle = /**
  593. * Toggle this drawer.
  594. * @param {?=} isOpen Whether the drawer should be open.
  595. * @param {?=} openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  596. * Used for focus management after the sidenav is closed.
  597. * @return {?}
  598. */
  599. function (isOpen, openedVia) {
  600. var _this = this;
  601. if (isOpen === void 0) { isOpen = !this.opened; }
  602. if (openedVia === void 0) { openedVia = 'program'; }
  603. this._opened = isOpen;
  604. if (isOpen) {
  605. this._animationState = this._enableAnimations ? 'open' : 'open-instant';
  606. this._openedVia = openedVia;
  607. }
  608. else {
  609. this._animationState = 'void';
  610. this._restoreFocus();
  611. }
  612. this._updateFocusTrapState();
  613. return new Promise((/**
  614. * @param {?} resolve
  615. * @return {?}
  616. */
  617. function (resolve) {
  618. _this.openedChange.pipe(operators.take(1)).subscribe((/**
  619. * @param {?} open
  620. * @return {?}
  621. */
  622. function (open) { return resolve(open ? 'open' : 'close'); }));
  623. }));
  624. };
  625. Object.defineProperty(MatDrawer.prototype, "_width", {
  626. get: /**
  627. * @return {?}
  628. */
  629. function () {
  630. return this._elementRef.nativeElement ? (this._elementRef.nativeElement.offsetWidth || 0) : 0;
  631. },
  632. enumerable: true,
  633. configurable: true
  634. });
  635. /** Updates the enabled state of the focus trap. */
  636. /**
  637. * Updates the enabled state of the focus trap.
  638. * @private
  639. * @return {?}
  640. */
  641. MatDrawer.prototype._updateFocusTrapState = /**
  642. * Updates the enabled state of the focus trap.
  643. * @private
  644. * @return {?}
  645. */
  646. function () {
  647. if (this._focusTrap) {
  648. this._focusTrap.enabled = this._isFocusTrapEnabled;
  649. }
  650. };
  651. // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
  652. // In Ivy the `host` bindings will be merged when this class is extended, whereas in
  653. // ViewEngine they're overwritten.
  654. // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
  655. // tslint:disable-next-line:no-host-decorator-in-concrete
  656. // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
  657. // In Ivy the `host` bindings will be merged when this class is extended, whereas in
  658. // ViewEngine they're overwritten.
  659. // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
  660. // tslint:disable-next-line:no-host-decorator-in-concrete
  661. /**
  662. * @param {?} event
  663. * @return {?}
  664. */
  665. MatDrawer.prototype._animationStartListener =
  666. // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
  667. // In Ivy the `host` bindings will be merged when this class is extended, whereas in
  668. // ViewEngine they're overwritten.
  669. // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
  670. // tslint:disable-next-line:no-host-decorator-in-concrete
  671. /**
  672. * @param {?} event
  673. * @return {?}
  674. */
  675. function (event) {
  676. this._animationStarted.next(event);
  677. };
  678. // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
  679. // In Ivy the `host` bindings will be merged when this class is extended, whereas in
  680. // ViewEngine they're overwritten.
  681. // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
  682. // tslint:disable-next-line:no-host-decorator-in-concrete
  683. // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
  684. // In Ivy the `host` bindings will be merged when this class is extended, whereas in
  685. // ViewEngine they're overwritten.
  686. // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
  687. // tslint:disable-next-line:no-host-decorator-in-concrete
  688. /**
  689. * @param {?} event
  690. * @return {?}
  691. */
  692. MatDrawer.prototype._animationDoneListener =
  693. // We have to use a `HostListener` here in order to support both Ivy and ViewEngine.
  694. // In Ivy the `host` bindings will be merged when this class is extended, whereas in
  695. // ViewEngine they're overwritten.
  696. // TODO(crisbeto): we move this back into `host` once Ivy is turned on by default.
  697. // tslint:disable-next-line:no-host-decorator-in-concrete
  698. /**
  699. * @param {?} event
  700. * @return {?}
  701. */
  702. function (event) {
  703. this._animationEnd.next(event);
  704. };
  705. MatDrawer.decorators = [
  706. { type: core.Component, args: [{selector: 'mat-drawer',
  707. exportAs: 'matDrawer',
  708. template: "<div class=\"mat-drawer-inner-container\"><ng-content></ng-content></div>",
  709. animations: [matDrawerAnimations.transformDrawer],
  710. host: {
  711. 'class': 'mat-drawer',
  712. // must prevent the browser from aligning text based on value
  713. '[attr.align]': 'null',
  714. '[class.mat-drawer-end]': 'position === "end"',
  715. '[class.mat-drawer-over]': 'mode === "over"',
  716. '[class.mat-drawer-push]': 'mode === "push"',
  717. '[class.mat-drawer-side]': 'mode === "side"',
  718. '[class.mat-drawer-opened]': 'opened',
  719. 'tabIndex': '-1',
  720. },
  721. changeDetection: core.ChangeDetectionStrategy.OnPush,
  722. encapsulation: core.ViewEncapsulation.None,
  723. },] },
  724. ];
  725. /** @nocollapse */
  726. MatDrawer.ctorParameters = function () { return [
  727. { type: core.ElementRef },
  728. { type: a11y.FocusTrapFactory },
  729. { type: a11y.FocusMonitor },
  730. { type: platform.Platform },
  731. { type: core.NgZone },
  732. { type: undefined, decorators: [{ type: core.Optional }, { type: core.Inject, args: [common.DOCUMENT,] }] }
  733. ]; };
  734. MatDrawer.propDecorators = {
  735. position: [{ type: core.Input }],
  736. mode: [{ type: core.Input }],
  737. disableClose: [{ type: core.Input }],
  738. autoFocus: [{ type: core.Input }],
  739. _animationState: [{ type: core.HostBinding, args: ['@transform',] }],
  740. openedChange: [{ type: core.Output }],
  741. _openedStream: [{ type: core.Output, args: ['opened',] }],
  742. openedStart: [{ type: core.Output }],
  743. _closedStream: [{ type: core.Output, args: ['closed',] }],
  744. closedStart: [{ type: core.Output }],
  745. onPositionChanged: [{ type: core.Output, args: ['positionChanged',] }],
  746. opened: [{ type: core.Input }],
  747. _animationStartListener: [{ type: core.HostListener, args: ['@transform.start', ['$event'],] }],
  748. _animationDoneListener: [{ type: core.HostListener, args: ['@transform.done', ['$event'],] }]
  749. };
  750. return MatDrawer;
  751. }());
  752. /**
  753. * `<mat-drawer-container>` component.
  754. *
  755. * This is the parent component to one or two `<mat-drawer>`s that validates the state internally
  756. * and coordinates the backdrop and content styling.
  757. */
  758. var MatDrawerContainer = /** @class */ (function () {
  759. function MatDrawerContainer(_dir, _element, _ngZone, _changeDetectorRef, viewportRuler, defaultAutosize, _animationMode) {
  760. var _this = this;
  761. if (defaultAutosize === void 0) { defaultAutosize = false; }
  762. this._dir = _dir;
  763. this._element = _element;
  764. this._ngZone = _ngZone;
  765. this._changeDetectorRef = _changeDetectorRef;
  766. this._animationMode = _animationMode;
  767. /**
  768. * Event emitted when the drawer backdrop is clicked.
  769. */
  770. this.backdropClick = new core.EventEmitter();
  771. /**
  772. * Emits when the component is destroyed.
  773. */
  774. this._destroyed = new rxjs.Subject();
  775. /**
  776. * Emits on every ngDoCheck. Used for debouncing reflows.
  777. */
  778. this._doCheckSubject = new rxjs.Subject();
  779. /**
  780. * Margins to be applied to the content. These are used to push / shrink the drawer content when a
  781. * drawer is open. We use margin rather than transform even for push mode because transform breaks
  782. * fixed position elements inside of the transformed element.
  783. */
  784. this._contentMargins = { left: null, right: null };
  785. this._contentMarginChanges = new rxjs.Subject();
  786. // If a `Dir` directive exists up the tree, listen direction changes
  787. // and update the left/right properties to point to the proper start/end.
  788. if (_dir) {
  789. _dir.change.pipe(operators.takeUntil(this._destroyed)).subscribe((/**
  790. * @return {?}
  791. */
  792. function () {
  793. _this._validateDrawers();
  794. _this.updateContentMargins();
  795. }));
  796. }
  797. // Since the minimum width of the sidenav depends on the viewport width,
  798. // we need to recompute the margins if the viewport changes.
  799. viewportRuler.change()
  800. .pipe(operators.takeUntil(this._destroyed))
  801. .subscribe((/**
  802. * @return {?}
  803. */
  804. function () { return _this.updateContentMargins(); }));
  805. this._autosize = defaultAutosize;
  806. }
  807. Object.defineProperty(MatDrawerContainer.prototype, "start", {
  808. /** The drawer child with the `start` position. */
  809. get: /**
  810. * The drawer child with the `start` position.
  811. * @return {?}
  812. */
  813. function () { return this._start; },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(MatDrawerContainer.prototype, "end", {
  818. /** The drawer child with the `end` position. */
  819. get: /**
  820. * The drawer child with the `end` position.
  821. * @return {?}
  822. */
  823. function () { return this._end; },
  824. enumerable: true,
  825. configurable: true
  826. });
  827. Object.defineProperty(MatDrawerContainer.prototype, "autosize", {
  828. /**
  829. * Whether to automatically resize the container whenever
  830. * the size of any of its drawers changes.
  831. *
  832. * **Use at your own risk!** Enabling this option can cause layout thrashing by measuring
  833. * the drawers on every change detection cycle. Can be configured globally via the
  834. * `MAT_DRAWER_DEFAULT_AUTOSIZE` token.
  835. */
  836. get: /**
  837. * Whether to automatically resize the container whenever
  838. * the size of any of its drawers changes.
  839. *
  840. * **Use at your own risk!** Enabling this option can cause layout thrashing by measuring
  841. * the drawers on every change detection cycle. Can be configured globally via the
  842. * `MAT_DRAWER_DEFAULT_AUTOSIZE` token.
  843. * @return {?}
  844. */
  845. function () { return this._autosize; },
  846. set: /**
  847. * @param {?} value
  848. * @return {?}
  849. */
  850. function (value) { this._autosize = coercion.coerceBooleanProperty(value); },
  851. enumerable: true,
  852. configurable: true
  853. });
  854. Object.defineProperty(MatDrawerContainer.prototype, "hasBackdrop", {
  855. /**
  856. * Whether the drawer container should have a backdrop while one of the sidenavs is open.
  857. * If explicitly set to `true`, the backdrop will be enabled for drawers in the `side`
  858. * mode as well.
  859. */
  860. get: /**
  861. * Whether the drawer container should have a backdrop while one of the sidenavs is open.
  862. * If explicitly set to `true`, the backdrop will be enabled for drawers in the `side`
  863. * mode as well.
  864. * @return {?}
  865. */
  866. function () {
  867. if (this._backdropOverride == null) {
  868. return !this._start || this._start.mode !== 'side' || !this._end || this._end.mode !== 'side';
  869. }
  870. return this._backdropOverride;
  871. },
  872. set: /**
  873. * @param {?} value
  874. * @return {?}
  875. */
  876. function (value) {
  877. this._backdropOverride = value == null ? null : coercion.coerceBooleanProperty(value);
  878. },
  879. enumerable: true,
  880. configurable: true
  881. });
  882. Object.defineProperty(MatDrawerContainer.prototype, "scrollable", {
  883. /** Reference to the CdkScrollable instance that wraps the scrollable content. */
  884. get: /**
  885. * Reference to the CdkScrollable instance that wraps the scrollable content.
  886. * @return {?}
  887. */
  888. function () {
  889. return this._userContent || this._content;
  890. },
  891. enumerable: true,
  892. configurable: true
  893. });
  894. /**
  895. * @return {?}
  896. */
  897. MatDrawerContainer.prototype.ngAfterContentInit = /**
  898. * @return {?}
  899. */
  900. function () {
  901. var _this = this;
  902. this._drawers.changes.pipe(operators.startWith(null)).subscribe((/**
  903. * @return {?}
  904. */
  905. function () {
  906. _this._validateDrawers();
  907. _this._drawers.forEach((/**
  908. * @param {?} drawer
  909. * @return {?}
  910. */
  911. function (drawer) {
  912. _this._watchDrawerToggle(drawer);
  913. _this._watchDrawerPosition(drawer);
  914. _this._watchDrawerMode(drawer);
  915. }));
  916. if (!_this._drawers.length ||
  917. _this._isDrawerOpen(_this._start) ||
  918. _this._isDrawerOpen(_this._end)) {
  919. _this.updateContentMargins();
  920. }
  921. _this._changeDetectorRef.markForCheck();
  922. }));
  923. this._doCheckSubject.pipe(operators.debounceTime(10), // Arbitrary debounce time, less than a frame at 60fps
  924. operators.takeUntil(this._destroyed)).subscribe((/**
  925. * @return {?}
  926. */
  927. function () { return _this.updateContentMargins(); }));
  928. };
  929. /**
  930. * @return {?}
  931. */
  932. MatDrawerContainer.prototype.ngOnDestroy = /**
  933. * @return {?}
  934. */
  935. function () {
  936. this._contentMarginChanges.complete();
  937. this._doCheckSubject.complete();
  938. this._destroyed.next();
  939. this._destroyed.complete();
  940. };
  941. /** Calls `open` of both start and end drawers */
  942. /**
  943. * Calls `open` of both start and end drawers
  944. * @return {?}
  945. */
  946. MatDrawerContainer.prototype.open = /**
  947. * Calls `open` of both start and end drawers
  948. * @return {?}
  949. */
  950. function () {
  951. this._drawers.forEach((/**
  952. * @param {?} drawer
  953. * @return {?}
  954. */
  955. function (drawer) { return drawer.open(); }));
  956. };
  957. /** Calls `close` of both start and end drawers */
  958. /**
  959. * Calls `close` of both start and end drawers
  960. * @return {?}
  961. */
  962. MatDrawerContainer.prototype.close = /**
  963. * Calls `close` of both start and end drawers
  964. * @return {?}
  965. */
  966. function () {
  967. this._drawers.forEach((/**
  968. * @param {?} drawer
  969. * @return {?}
  970. */
  971. function (drawer) { return drawer.close(); }));
  972. };
  973. /**
  974. * Recalculates and updates the inline styles for the content. Note that this should be used
  975. * sparingly, because it causes a reflow.
  976. */
  977. /**
  978. * Recalculates and updates the inline styles for the content. Note that this should be used
  979. * sparingly, because it causes a reflow.
  980. * @return {?}
  981. */
  982. MatDrawerContainer.prototype.updateContentMargins = /**
  983. * Recalculates and updates the inline styles for the content. Note that this should be used
  984. * sparingly, because it causes a reflow.
  985. * @return {?}
  986. */
  987. function () {
  988. var _this = this;
  989. // 1. For drawers in `over` mode, they don't affect the content.
  990. // 2. For drawers in `side` mode they should shrink the content. We do this by adding to the
  991. // left margin (for left drawer) or right margin (for right the drawer).
  992. // 3. For drawers in `push` mode the should shift the content without resizing it. We do this by
  993. // adding to the left or right margin and simultaneously subtracting the same amount of
  994. // margin from the other side.
  995. /** @type {?} */
  996. var left = 0;
  997. /** @type {?} */
  998. var right = 0;
  999. if (this._left && this._left.opened) {
  1000. if (this._left.mode == 'side') {
  1001. left += this._left._width;
  1002. }
  1003. else if (this._left.mode == 'push') {
  1004. /** @type {?} */
  1005. var width = this._left._width;
  1006. left += width;
  1007. right -= width;
  1008. }
  1009. }
  1010. if (this._right && this._right.opened) {
  1011. if (this._right.mode == 'side') {
  1012. right += this._right._width;
  1013. }
  1014. else if (this._right.mode == 'push') {
  1015. /** @type {?} */
  1016. var width = this._right._width;
  1017. right += width;
  1018. left -= width;
  1019. }
  1020. }
  1021. // If either `right` or `left` is zero, don't set a style to the element. This
  1022. // allows users to specify a custom size via CSS class in SSR scenarios where the
  1023. // measured widths will always be zero. Note that we reset to `null` here, rather
  1024. // than below, in order to ensure that the types in the `if` below are consistent.
  1025. left = left || (/** @type {?} */ (null));
  1026. right = right || (/** @type {?} */ (null));
  1027. if (left !== this._contentMargins.left || right !== this._contentMargins.right) {
  1028. this._contentMargins = { left: left, right: right };
  1029. // Pull back into the NgZone since in some cases we could be outside. We need to be careful
  1030. // to do it only when something changed, otherwise we can end up hitting the zone too often.
  1031. this._ngZone.run((/**
  1032. * @return {?}
  1033. */
  1034. function () { return _this._contentMarginChanges.next(_this._contentMargins); }));
  1035. }
  1036. };
  1037. /**
  1038. * @return {?}
  1039. */
  1040. MatDrawerContainer.prototype.ngDoCheck = /**
  1041. * @return {?}
  1042. */
  1043. function () {
  1044. var _this = this;
  1045. // If users opted into autosizing, do a check every change detection cycle.
  1046. if (this._autosize && this._isPushed()) {
  1047. // Run outside the NgZone, otherwise the debouncer will throw us into an infinite loop.
  1048. this._ngZone.runOutsideAngular((/**
  1049. * @return {?}
  1050. */
  1051. function () { return _this._doCheckSubject.next(); }));
  1052. }
  1053. };
  1054. /**
  1055. * Subscribes to drawer events in order to set a class on the main container element when the
  1056. * drawer is open and the backdrop is visible. This ensures any overflow on the container element
  1057. * is properly hidden.
  1058. */
  1059. /**
  1060. * Subscribes to drawer events in order to set a class on the main container element when the
  1061. * drawer is open and the backdrop is visible. This ensures any overflow on the container element
  1062. * is properly hidden.
  1063. * @private
  1064. * @param {?} drawer
  1065. * @return {?}
  1066. */
  1067. MatDrawerContainer.prototype._watchDrawerToggle = /**
  1068. * Subscribes to drawer events in order to set a class on the main container element when the
  1069. * drawer is open and the backdrop is visible. This ensures any overflow on the container element
  1070. * is properly hidden.
  1071. * @private
  1072. * @param {?} drawer
  1073. * @return {?}
  1074. */
  1075. function (drawer) {
  1076. var _this = this;
  1077. drawer._animationStarted.pipe(operators.filter((/**
  1078. * @param {?} event
  1079. * @return {?}
  1080. */
  1081. function (event) { return event.fromState !== event.toState; })), operators.takeUntil(this._drawers.changes))
  1082. .subscribe((/**
  1083. * @param {?} event
  1084. * @return {?}
  1085. */
  1086. function (event) {
  1087. // Set the transition class on the container so that the animations occur. This should not
  1088. // be set initially because animations should only be triggered via a change in state.
  1089. if (event.toState !== 'open-instant' && _this._animationMode !== 'NoopAnimations') {
  1090. _this._element.nativeElement.classList.add('mat-drawer-transition');
  1091. }
  1092. _this.updateContentMargins();
  1093. _this._changeDetectorRef.markForCheck();
  1094. }));
  1095. if (drawer.mode !== 'side') {
  1096. drawer.openedChange.pipe(operators.takeUntil(this._drawers.changes)).subscribe((/**
  1097. * @return {?}
  1098. */
  1099. function () {
  1100. return _this._setContainerClass(drawer.opened);
  1101. }));
  1102. }
  1103. };
  1104. /**
  1105. * Subscribes to drawer onPositionChanged event in order to
  1106. * re-validate drawers when the position changes.
  1107. */
  1108. /**
  1109. * Subscribes to drawer onPositionChanged event in order to
  1110. * re-validate drawers when the position changes.
  1111. * @private
  1112. * @param {?} drawer
  1113. * @return {?}
  1114. */
  1115. MatDrawerContainer.prototype._watchDrawerPosition = /**
  1116. * Subscribes to drawer onPositionChanged event in order to
  1117. * re-validate drawers when the position changes.
  1118. * @private
  1119. * @param {?} drawer
  1120. * @return {?}
  1121. */
  1122. function (drawer) {
  1123. var _this = this;
  1124. if (!drawer) {
  1125. return;
  1126. }
  1127. // NOTE: We need to wait for the microtask queue to be empty before validating,
  1128. // since both drawers may be swapping positions at the same time.
  1129. drawer.onPositionChanged.pipe(operators.takeUntil(this._drawers.changes)).subscribe((/**
  1130. * @return {?}
  1131. */
  1132. function () {
  1133. _this._ngZone.onMicrotaskEmpty.asObservable().pipe(operators.take(1)).subscribe((/**
  1134. * @return {?}
  1135. */
  1136. function () {
  1137. _this._validateDrawers();
  1138. }));
  1139. }));
  1140. };
  1141. /** Subscribes to changes in drawer mode so we can run change detection. */
  1142. /**
  1143. * Subscribes to changes in drawer mode so we can run change detection.
  1144. * @private
  1145. * @param {?} drawer
  1146. * @return {?}
  1147. */
  1148. MatDrawerContainer.prototype._watchDrawerMode = /**
  1149. * Subscribes to changes in drawer mode so we can run change detection.
  1150. * @private
  1151. * @param {?} drawer
  1152. * @return {?}
  1153. */
  1154. function (drawer) {
  1155. var _this = this;
  1156. if (drawer) {
  1157. drawer._modeChanged.pipe(operators.takeUntil(rxjs.merge(this._drawers.changes, this._destroyed)))
  1158. .subscribe((/**
  1159. * @return {?}
  1160. */
  1161. function () {
  1162. _this.updateContentMargins();
  1163. _this._changeDetectorRef.markForCheck();
  1164. }));
  1165. }
  1166. };
  1167. /** Toggles the 'mat-drawer-opened' class on the main 'mat-drawer-container' element. */
  1168. /**
  1169. * Toggles the 'mat-drawer-opened' class on the main 'mat-drawer-container' element.
  1170. * @private
  1171. * @param {?} isAdd
  1172. * @return {?}
  1173. */
  1174. MatDrawerContainer.prototype._setContainerClass = /**
  1175. * Toggles the 'mat-drawer-opened' class on the main 'mat-drawer-container' element.
  1176. * @private
  1177. * @param {?} isAdd
  1178. * @return {?}
  1179. */
  1180. function (isAdd) {
  1181. /** @type {?} */
  1182. var classList = this._element.nativeElement.classList;
  1183. /** @type {?} */
  1184. var className = 'mat-drawer-container-has-open';
  1185. if (isAdd) {
  1186. classList.add(className);
  1187. }
  1188. else {
  1189. classList.remove(className);
  1190. }
  1191. };
  1192. /** Validate the state of the drawer children components. */
  1193. /**
  1194. * Validate the state of the drawer children components.
  1195. * @private
  1196. * @return {?}
  1197. */
  1198. MatDrawerContainer.prototype._validateDrawers = /**
  1199. * Validate the state of the drawer children components.
  1200. * @private
  1201. * @return {?}
  1202. */
  1203. function () {
  1204. var _this = this;
  1205. this._start = this._end = null;
  1206. // Ensure that we have at most one start and one end drawer.
  1207. this._drawers.forEach((/**
  1208. * @param {?} drawer
  1209. * @return {?}
  1210. */
  1211. function (drawer) {
  1212. if (drawer.position == 'end') {
  1213. if (_this._end != null) {
  1214. throwMatDuplicatedDrawerError('end');
  1215. }
  1216. _this._end = drawer;
  1217. }
  1218. else {
  1219. if (_this._start != null) {
  1220. throwMatDuplicatedDrawerError('start');
  1221. }
  1222. _this._start = drawer;
  1223. }
  1224. }));
  1225. this._right = this._left = null;
  1226. // Detect if we're LTR or RTL.
  1227. if (this._dir && this._dir.value === 'rtl') {
  1228. this._left = this._end;
  1229. this._right = this._start;
  1230. }
  1231. else {
  1232. this._left = this._start;
  1233. this._right = this._end;
  1234. }
  1235. };
  1236. /** Whether the container is being pushed to the side by one of the drawers. */
  1237. /**
  1238. * Whether the container is being pushed to the side by one of the drawers.
  1239. * @private
  1240. * @return {?}
  1241. */
  1242. MatDrawerContainer.prototype._isPushed = /**
  1243. * Whether the container is being pushed to the side by one of the drawers.
  1244. * @private
  1245. * @return {?}
  1246. */
  1247. function () {
  1248. return (this._isDrawerOpen(this._start) && this._start.mode != 'over') ||
  1249. (this._isDrawerOpen(this._end) && this._end.mode != 'over');
  1250. };
  1251. /**
  1252. * @return {?}
  1253. */
  1254. MatDrawerContainer.prototype._onBackdropClicked = /**
  1255. * @return {?}
  1256. */
  1257. function () {
  1258. this.backdropClick.emit();
  1259. this._closeModalDrawer();
  1260. };
  1261. /**
  1262. * @return {?}
  1263. */
  1264. MatDrawerContainer.prototype._closeModalDrawer = /**
  1265. * @return {?}
  1266. */
  1267. function () {
  1268. var _this = this;
  1269. // Close all open drawers where closing is not disabled and the mode is not `side`.
  1270. [this._start, this._end]
  1271. .filter((/**
  1272. * @param {?} drawer
  1273. * @return {?}
  1274. */
  1275. function (drawer) { return drawer && !drawer.disableClose && _this._canHaveBackdrop(drawer); }))
  1276. .forEach((/**
  1277. * @param {?} drawer
  1278. * @return {?}
  1279. */
  1280. function (drawer) { return (/** @type {?} */ (drawer)).close(); }));
  1281. };
  1282. /**
  1283. * @return {?}
  1284. */
  1285. MatDrawerContainer.prototype._isShowingBackdrop = /**
  1286. * @return {?}
  1287. */
  1288. function () {
  1289. return (this._isDrawerOpen(this._start) && this._canHaveBackdrop(this._start)) ||
  1290. (this._isDrawerOpen(this._end) && this._canHaveBackdrop(this._end));
  1291. };
  1292. /**
  1293. * @private
  1294. * @param {?} drawer
  1295. * @return {?}
  1296. */
  1297. MatDrawerContainer.prototype._canHaveBackdrop = /**
  1298. * @private
  1299. * @param {?} drawer
  1300. * @return {?}
  1301. */
  1302. function (drawer) {
  1303. return drawer.mode !== 'side' || !!this._backdropOverride;
  1304. };
  1305. /**
  1306. * @private
  1307. * @param {?} drawer
  1308. * @return {?}
  1309. */
  1310. MatDrawerContainer.prototype._isDrawerOpen = /**
  1311. * @private
  1312. * @param {?} drawer
  1313. * @return {?}
  1314. */
  1315. function (drawer) {
  1316. return drawer != null && drawer.opened;
  1317. };
  1318. MatDrawerContainer.decorators = [
  1319. { type: core.Component, args: [{selector: 'mat-drawer-container',
  1320. exportAs: 'matDrawerContainer',
  1321. template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" *ngIf=\"hasBackdrop\" [class.mat-drawer-shown]=\"_isShowingBackdrop()\"></div><ng-content select=\"mat-drawer\"></ng-content><ng-content select=\"mat-drawer-content\"></ng-content><mat-drawer-content *ngIf=\"!_content\"><ng-content></ng-content></mat-drawer-content>",
  1322. styles: [".mat-drawer-container{position:relative;z-index:1;box-sizing:border-box;-webkit-overflow-scrolling:touch;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:.4s;transition-timing-function:cubic-bezier(.25,.8,.25,1);transition-property:background-color,visibility}@media (-ms-high-contrast:active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-transition .mat-drawer-content{transition-duration:.4s;transition-timing-function:cubic-bezier(.25,.8,.25,1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%,0,0)}@media (-ms-high-contrast:active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media (-ms-high-contrast:active){.mat-drawer.mat-drawer-end,[dir=rtl] .mat-drawer{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%,0,0)}[dir=rtl] .mat-drawer{transform:translate3d(100%,0,0)}[dir=rtl] .mat-drawer.mat-drawer-end{left:0;right:auto;transform:translate3d(-100%,0,0)}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.mat-sidenav-fixed{position:fixed}"],
  1323. host: {
  1324. 'class': 'mat-drawer-container',
  1325. '[class.mat-drawer-container-explicit-backdrop]': '_backdropOverride',
  1326. },
  1327. changeDetection: core.ChangeDetectionStrategy.OnPush,
  1328. encapsulation: core.ViewEncapsulation.None,
  1329. },] },
  1330. ];
  1331. /** @nocollapse */
  1332. MatDrawerContainer.ctorParameters = function () { return [
  1333. { type: bidi.Directionality, decorators: [{ type: core.Optional }] },
  1334. { type: core.ElementRef },
  1335. { type: core.NgZone },
  1336. { type: core.ChangeDetectorRef },
  1337. { type: scrolling.ViewportRuler },
  1338. { type: undefined, decorators: [{ type: core.Inject, args: [MAT_DRAWER_DEFAULT_AUTOSIZE,] }] },
  1339. { type: String, decorators: [{ type: core.Optional }, { type: core.Inject, args: [animations$1.ANIMATION_MODULE_TYPE,] }] }
  1340. ]; };
  1341. MatDrawerContainer.propDecorators = {
  1342. _drawers: [{ type: core.ContentChildren, args: [MatDrawer,] }],
  1343. _content: [{ type: core.ContentChild, args: [MatDrawerContent, { static: false },] }],
  1344. _userContent: [{ type: core.ViewChild, args: [MatDrawerContent, { static: false },] }],
  1345. autosize: [{ type: core.Input }],
  1346. hasBackdrop: [{ type: core.Input }],
  1347. backdropClick: [{ type: core.Output }]
  1348. };
  1349. return MatDrawerContainer;
  1350. }());
  1351. /**
  1352. * @fileoverview added by tsickle
  1353. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1354. */
  1355. var MatSidenavContent = /** @class */ (function (_super) {
  1356. __extends(MatSidenavContent, _super);
  1357. function MatSidenavContent(changeDetectorRef, container, elementRef, scrollDispatcher, ngZone) {
  1358. return _super.call(this, changeDetectorRef, container, elementRef, scrollDispatcher, ngZone) || this;
  1359. }
  1360. MatSidenavContent.decorators = [
  1361. { type: core.Component, args: [{selector: 'mat-sidenav-content',
  1362. template: '<ng-content></ng-content>',
  1363. host: {
  1364. 'class': 'mat-drawer-content mat-sidenav-content',
  1365. '[style.margin-left.px]': '_container._contentMargins.left',
  1366. '[style.margin-right.px]': '_container._contentMargins.right',
  1367. },
  1368. changeDetection: core.ChangeDetectionStrategy.OnPush,
  1369. encapsulation: core.ViewEncapsulation.None,
  1370. },] },
  1371. ];
  1372. /** @nocollapse */
  1373. MatSidenavContent.ctorParameters = function () { return [
  1374. { type: core.ChangeDetectorRef },
  1375. { type: MatSidenavContainer, decorators: [{ type: core.Inject, args: [core.forwardRef((/**
  1376. * @return {?}
  1377. */
  1378. function () { return MatSidenavContainer; })),] }] },
  1379. { type: core.ElementRef },
  1380. { type: scrolling.ScrollDispatcher },
  1381. { type: core.NgZone }
  1382. ]; };
  1383. return MatSidenavContent;
  1384. }(MatDrawerContent));
  1385. var MatSidenav = /** @class */ (function (_super) {
  1386. __extends(MatSidenav, _super);
  1387. function MatSidenav() {
  1388. var _this = _super !== null && _super.apply(this, arguments) || this;
  1389. _this._fixedInViewport = false;
  1390. _this._fixedTopGap = 0;
  1391. _this._fixedBottomGap = 0;
  1392. return _this;
  1393. }
  1394. Object.defineProperty(MatSidenav.prototype, "fixedInViewport", {
  1395. /** Whether the sidenav is fixed in the viewport. */
  1396. get: /**
  1397. * Whether the sidenav is fixed in the viewport.
  1398. * @return {?}
  1399. */
  1400. function () { return this._fixedInViewport; },
  1401. set: /**
  1402. * @param {?} value
  1403. * @return {?}
  1404. */
  1405. function (value) { this._fixedInViewport = coercion.coerceBooleanProperty(value); },
  1406. enumerable: true,
  1407. configurable: true
  1408. });
  1409. Object.defineProperty(MatSidenav.prototype, "fixedTopGap", {
  1410. /**
  1411. * The gap between the top of the sidenav and the top of the viewport when the sidenav is in fixed
  1412. * mode.
  1413. */
  1414. get: /**
  1415. * The gap between the top of the sidenav and the top of the viewport when the sidenav is in fixed
  1416. * mode.
  1417. * @return {?}
  1418. */
  1419. function () { return this._fixedTopGap; },
  1420. set: /**
  1421. * @param {?} value
  1422. * @return {?}
  1423. */
  1424. function (value) { this._fixedTopGap = coercion.coerceNumberProperty(value); },
  1425. enumerable: true,
  1426. configurable: true
  1427. });
  1428. Object.defineProperty(MatSidenav.prototype, "fixedBottomGap", {
  1429. /**
  1430. * The gap between the bottom of the sidenav and the bottom of the viewport when the sidenav is in
  1431. * fixed mode.
  1432. */
  1433. get: /**
  1434. * The gap between the bottom of the sidenav and the bottom of the viewport when the sidenav is in
  1435. * fixed mode.
  1436. * @return {?}
  1437. */
  1438. function () { return this._fixedBottomGap; },
  1439. set: /**
  1440. * @param {?} value
  1441. * @return {?}
  1442. */
  1443. function (value) { this._fixedBottomGap = coercion.coerceNumberProperty(value); },
  1444. enumerable: true,
  1445. configurable: true
  1446. });
  1447. MatSidenav.decorators = [
  1448. { type: core.Component, args: [{selector: 'mat-sidenav',
  1449. exportAs: 'matSidenav',
  1450. template: "<div class=\"mat-drawer-inner-container\"><ng-content></ng-content></div>",
  1451. animations: [matDrawerAnimations.transformDrawer],
  1452. host: {
  1453. 'class': 'mat-drawer mat-sidenav',
  1454. 'tabIndex': '-1',
  1455. // must prevent the browser from aligning text based on value
  1456. '[attr.align]': 'null',
  1457. '[class.mat-drawer-end]': 'position === "end"',
  1458. '[class.mat-drawer-over]': 'mode === "over"',
  1459. '[class.mat-drawer-push]': 'mode === "push"',
  1460. '[class.mat-drawer-side]': 'mode === "side"',
  1461. '[class.mat-drawer-opened]': 'opened',
  1462. '[class.mat-sidenav-fixed]': 'fixedInViewport',
  1463. '[style.top.px]': 'fixedInViewport ? fixedTopGap : null',
  1464. '[style.bottom.px]': 'fixedInViewport ? fixedBottomGap : null',
  1465. },
  1466. changeDetection: core.ChangeDetectionStrategy.OnPush,
  1467. encapsulation: core.ViewEncapsulation.None,
  1468. },] },
  1469. ];
  1470. MatSidenav.propDecorators = {
  1471. fixedInViewport: [{ type: core.Input }],
  1472. fixedTopGap: [{ type: core.Input }],
  1473. fixedBottomGap: [{ type: core.Input }]
  1474. };
  1475. return MatSidenav;
  1476. }(MatDrawer));
  1477. var MatSidenavContainer = /** @class */ (function (_super) {
  1478. __extends(MatSidenavContainer, _super);
  1479. function MatSidenavContainer() {
  1480. return _super !== null && _super.apply(this, arguments) || this;
  1481. }
  1482. MatSidenavContainer.decorators = [
  1483. { type: core.Component, args: [{selector: 'mat-sidenav-container',
  1484. exportAs: 'matSidenavContainer',
  1485. template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" *ngIf=\"hasBackdrop\" [class.mat-drawer-shown]=\"_isShowingBackdrop()\"></div><ng-content select=\"mat-sidenav\"></ng-content><ng-content select=\"mat-sidenav-content\"></ng-content><mat-sidenav-content *ngIf=\"!_content\" cdkScrollable><ng-content></ng-content></mat-sidenav-content>",
  1486. styles: [".mat-drawer-container{position:relative;z-index:1;box-sizing:border-box;-webkit-overflow-scrolling:touch;display:block;overflow:hidden}.mat-drawer-container[fullscreen]{top:0;left:0;right:0;bottom:0;position:absolute}.mat-drawer-container[fullscreen].mat-drawer-container-has-open{overflow:hidden}.mat-drawer-container.mat-drawer-container-explicit-backdrop .mat-drawer-side{z-index:3}.mat-drawer-container.ng-animate-disabled .mat-drawer-backdrop,.mat-drawer-container.ng-animate-disabled .mat-drawer-content,.ng-animate-disabled .mat-drawer-container .mat-drawer-backdrop,.ng-animate-disabled .mat-drawer-container .mat-drawer-content{transition:none}.mat-drawer-backdrop{top:0;left:0;right:0;bottom:0;position:absolute;display:block;z-index:3;visibility:hidden}.mat-drawer-backdrop.mat-drawer-shown{visibility:visible}.mat-drawer-transition .mat-drawer-backdrop{transition-duration:.4s;transition-timing-function:cubic-bezier(.25,.8,.25,1);transition-property:background-color,visibility}@media (-ms-high-contrast:active){.mat-drawer-backdrop{opacity:.5}}.mat-drawer-content{position:relative;z-index:1;display:block;height:100%;overflow:auto}.mat-drawer-transition .mat-drawer-content{transition-duration:.4s;transition-timing-function:cubic-bezier(.25,.8,.25,1);transition-property:transform,margin-left,margin-right}.mat-drawer{position:relative;z-index:4;display:block;position:absolute;top:0;bottom:0;z-index:3;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%,0,0)}@media (-ms-high-contrast:active){.mat-drawer,[dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}}@media (-ms-high-contrast:active){.mat-drawer.mat-drawer-end,[dir=rtl] .mat-drawer{border-left:solid 1px currentColor;border-right:none}}.mat-drawer.mat-drawer-side{z-index:2}.mat-drawer.mat-drawer-end{right:0;transform:translate3d(100%,0,0)}[dir=rtl] .mat-drawer{transform:translate3d(100%,0,0)}[dir=rtl] .mat-drawer.mat-drawer-end{left:0;right:auto;transform:translate3d(-100%,0,0)}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.mat-sidenav-fixed{position:fixed}"],
  1487. host: {
  1488. 'class': 'mat-drawer-container mat-sidenav-container',
  1489. '[class.mat-drawer-container-explicit-backdrop]': '_backdropOverride',
  1490. },
  1491. changeDetection: core.ChangeDetectionStrategy.OnPush,
  1492. encapsulation: core.ViewEncapsulation.None,
  1493. },] },
  1494. ];
  1495. MatSidenavContainer.propDecorators = {
  1496. _drawers: [{ type: core.ContentChildren, args: [MatSidenav,] }],
  1497. _content: [{ type: core.ContentChild, args: [MatSidenavContent, { static: false },] }]
  1498. };
  1499. return MatSidenavContainer;
  1500. }(MatDrawerContainer));
  1501. /**
  1502. * @fileoverview added by tsickle
  1503. * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
  1504. */
  1505. var MatSidenavModule = /** @class */ (function () {
  1506. function MatSidenavModule() {
  1507. }
  1508. MatSidenavModule.decorators = [
  1509. { type: core.NgModule, args: [{
  1510. imports: [
  1511. common.CommonModule,
  1512. core$1.MatCommonModule,
  1513. scrolling.ScrollingModule,
  1514. platform.PlatformModule,
  1515. ],
  1516. exports: [
  1517. core$1.MatCommonModule,
  1518. MatDrawer,
  1519. MatDrawerContainer,
  1520. MatDrawerContent,
  1521. MatSidenav,
  1522. MatSidenavContainer,
  1523. MatSidenavContent,
  1524. ],
  1525. declarations: [
  1526. MatDrawer,
  1527. MatDrawerContainer,
  1528. MatDrawerContent,
  1529. MatSidenav,
  1530. MatSidenavContainer,
  1531. MatSidenavContent,
  1532. ],
  1533. },] },
  1534. ];
  1535. return MatSidenavModule;
  1536. }());
  1537. exports.MatSidenavModule = MatSidenavModule;
  1538. exports.throwMatDuplicatedDrawerError = throwMatDuplicatedDrawerError;
  1539. exports.MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY = MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY;
  1540. exports.MAT_DRAWER_DEFAULT_AUTOSIZE = MAT_DRAWER_DEFAULT_AUTOSIZE;
  1541. exports.MatDrawerContent = MatDrawerContent;
  1542. exports.MatDrawer = MatDrawer;
  1543. exports.MatDrawerContainer = MatDrawerContainer;
  1544. exports.MatSidenavContent = MatSidenavContent;
  1545. exports.MatSidenav = MatSidenav;
  1546. exports.MatSidenavContainer = MatSidenavContainer;
  1547. exports.matDrawerAnimations = matDrawerAnimations;
  1548. Object.defineProperty(exports, '__esModule', { value: true });
  1549. })));
  1550. //# sourceMappingURL=material-sidenav.umd.js.map