sidenav.es5.js 61 KB

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