sidenav.mjs 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061
  1. import * as i1 from '@angular/cdk/scrolling';
  2. import { CdkScrollable, CdkScrollableModule } from '@angular/cdk/scrolling';
  3. import * as i5 from '@angular/common';
  4. import { DOCUMENT, CommonModule } from '@angular/common';
  5. import * as i0 from '@angular/core';
  6. import { InjectionToken, forwardRef, Component, ChangeDetectionStrategy, ViewEncapsulation, Inject, EventEmitter, Optional, Input, Output, ViewChild, QueryList, ContentChildren, ContentChild, NgModule } from '@angular/core';
  7. import { MatCommonModule } from '@angular/material/core';
  8. import * as i2 from '@angular/cdk/a11y';
  9. import * as i4 from '@angular/cdk/bidi';
  10. import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
  11. import { ESCAPE, hasModifierKey } from '@angular/cdk/keycodes';
  12. import * as i3 from '@angular/cdk/platform';
  13. import { Subject, fromEvent, merge } from 'rxjs';
  14. import { filter, map, mapTo, takeUntil, distinctUntilChanged, take, startWith, debounceTime } from 'rxjs/operators';
  15. import { trigger, state, style, transition, animate } from '@angular/animations';
  16. import { ANIMATION_MODULE_TYPE } from '@angular/platform-browser/animations';
  17. /**
  18. * Animations used by the Material drawers.
  19. * @docs-private
  20. */
  21. const matDrawerAnimations = {
  22. /** Animation that slides a drawer in and out. */
  23. transformDrawer: trigger('transform', [
  24. // We remove the `transform` here completely, rather than setting it to zero, because:
  25. // 1. Having a transform can cause elements with ripples or an animated
  26. // transform to shift around in Chrome with an RTL layout (see #10023).
  27. // 2. 3d transforms causes text to appear blurry on IE and Edge.
  28. state('open, open-instant', style({
  29. 'transform': 'none',
  30. 'visibility': 'visible',
  31. })),
  32. state('void', style({
  33. // Avoids the shadow showing up when closed in SSR.
  34. 'box-shadow': 'none',
  35. 'visibility': 'hidden',
  36. })),
  37. transition('void => open-instant', animate('0ms')),
  38. transition('void <=> open, open-instant => void', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)')),
  39. ]),
  40. };
  41. /**
  42. * Throws an exception when two MatDrawer are matching the same position.
  43. * @docs-private
  44. */
  45. function throwMatDuplicatedDrawerError(position) {
  46. throw Error(`A drawer was already declared for 'position="${position}"'`);
  47. }
  48. /** Configures whether drawers should use auto sizing by default. */
  49. const MAT_DRAWER_DEFAULT_AUTOSIZE = new InjectionToken('MAT_DRAWER_DEFAULT_AUTOSIZE', {
  50. providedIn: 'root',
  51. factory: MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY,
  52. });
  53. /**
  54. * Used to provide a drawer container to a drawer while avoiding circular references.
  55. * @docs-private
  56. */
  57. const MAT_DRAWER_CONTAINER = new InjectionToken('MAT_DRAWER_CONTAINER');
  58. /** @docs-private */
  59. function MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY() {
  60. return false;
  61. }
  62. class MatDrawerContent extends CdkScrollable {
  63. constructor(_changeDetectorRef, _container, elementRef, scrollDispatcher, ngZone) {
  64. super(elementRef, scrollDispatcher, ngZone);
  65. this._changeDetectorRef = _changeDetectorRef;
  66. this._container = _container;
  67. }
  68. ngAfterContentInit() {
  69. this._container._contentMarginChanges.subscribe(() => {
  70. this._changeDetectorRef.markForCheck();
  71. });
  72. }
  73. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatDrawerContent, deps: [{ token: i0.ChangeDetectorRef }, { token: forwardRef(() => MatDrawerContainer) }, { token: i0.ElementRef }, { token: i1.ScrollDispatcher }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
  74. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatDrawerContent, selector: "mat-drawer-content", host: { attributes: { "ngSkipHydration": "" }, properties: { "style.margin-left.px": "_container._contentMargins.left", "style.margin-right.px": "_container._contentMargins.right" }, classAttribute: "mat-drawer-content" }, providers: [
  75. {
  76. provide: CdkScrollable,
  77. useExisting: MatDrawerContent,
  78. },
  79. ], usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  80. }
  81. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatDrawerContent, decorators: [{
  82. type: Component,
  83. args: [{
  84. selector: 'mat-drawer-content',
  85. template: '<ng-content></ng-content>',
  86. host: {
  87. 'class': 'mat-drawer-content',
  88. '[style.margin-left.px]': '_container._contentMargins.left',
  89. '[style.margin-right.px]': '_container._contentMargins.right',
  90. 'ngSkipHydration': '',
  91. },
  92. changeDetection: ChangeDetectionStrategy.OnPush,
  93. encapsulation: ViewEncapsulation.None,
  94. providers: [
  95. {
  96. provide: CdkScrollable,
  97. useExisting: MatDrawerContent,
  98. },
  99. ],
  100. }]
  101. }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: MatDrawerContainer, decorators: [{
  102. type: Inject,
  103. args: [forwardRef(() => MatDrawerContainer)]
  104. }] }, { type: i0.ElementRef }, { type: i1.ScrollDispatcher }, { type: i0.NgZone }]; } });
  105. /**
  106. * This component corresponds to a drawer that can be opened on the drawer container.
  107. */
  108. class MatDrawer {
  109. /** The side that the drawer is attached to. */
  110. get position() {
  111. return this._position;
  112. }
  113. set position(value) {
  114. // Make sure we have a valid value.
  115. value = value === 'end' ? 'end' : 'start';
  116. if (value !== this._position) {
  117. // Static inputs in Ivy are set before the element is in the DOM.
  118. if (this._isAttached) {
  119. this._updatePositionInParent(value);
  120. }
  121. this._position = value;
  122. this.onPositionChanged.emit();
  123. }
  124. }
  125. /** Mode of the drawer; one of 'over', 'push' or 'side'. */
  126. get mode() {
  127. return this._mode;
  128. }
  129. set mode(value) {
  130. this._mode = value;
  131. this._updateFocusTrapState();
  132. this._modeChanged.next();
  133. }
  134. /** Whether the drawer can be closed with the escape key or by clicking on the backdrop. */
  135. get disableClose() {
  136. return this._disableClose;
  137. }
  138. set disableClose(value) {
  139. this._disableClose = coerceBooleanProperty(value);
  140. }
  141. /**
  142. * Whether the drawer should focus the first focusable element automatically when opened.
  143. * Defaults to false in when `mode` is set to `side`, otherwise defaults to `true`. If explicitly
  144. * enabled, focus will be moved into the sidenav in `side` mode as well.
  145. * @breaking-change 14.0.0 Remove boolean option from autoFocus. Use string or AutoFocusTarget
  146. * instead.
  147. */
  148. get autoFocus() {
  149. const value = this._autoFocus;
  150. // Note that usually we don't allow autoFocus to be set to `first-tabbable` in `side` mode,
  151. // because we don't know how the sidenav is being used, but in some cases it still makes
  152. // sense to do it. The consumer can explicitly set `autoFocus`.
  153. if (value == null) {
  154. if (this.mode === 'side') {
  155. return 'dialog';
  156. }
  157. else {
  158. return 'first-tabbable';
  159. }
  160. }
  161. return value;
  162. }
  163. set autoFocus(value) {
  164. if (value === 'true' || value === 'false' || value == null) {
  165. value = coerceBooleanProperty(value);
  166. }
  167. this._autoFocus = value;
  168. }
  169. /**
  170. * Whether the drawer is opened. We overload this because we trigger an event when it
  171. * starts or end.
  172. */
  173. get opened() {
  174. return this._opened;
  175. }
  176. set opened(value) {
  177. this.toggle(coerceBooleanProperty(value));
  178. }
  179. constructor(_elementRef, _focusTrapFactory, _focusMonitor, _platform, _ngZone, _interactivityChecker, _doc, _container) {
  180. this._elementRef = _elementRef;
  181. this._focusTrapFactory = _focusTrapFactory;
  182. this._focusMonitor = _focusMonitor;
  183. this._platform = _platform;
  184. this._ngZone = _ngZone;
  185. this._interactivityChecker = _interactivityChecker;
  186. this._doc = _doc;
  187. this._container = _container;
  188. this._elementFocusedBeforeDrawerWasOpened = null;
  189. /** Whether the drawer is initialized. Used for disabling the initial animation. */
  190. this._enableAnimations = false;
  191. this._position = 'start';
  192. this._mode = 'over';
  193. this._disableClose = false;
  194. this._opened = false;
  195. /** Emits whenever the drawer has started animating. */
  196. this._animationStarted = new Subject();
  197. /** Emits whenever the drawer is done animating. */
  198. this._animationEnd = new Subject();
  199. /** Current state of the sidenav animation. */
  200. this._animationState = 'void';
  201. /** Event emitted when the drawer open state is changed. */
  202. this.openedChange =
  203. // Note this has to be async in order to avoid some issues with two-bindings (see #8872).
  204. new EventEmitter(/* isAsync */ true);
  205. /** Event emitted when the drawer has been opened. */
  206. this._openedStream = this.openedChange.pipe(filter(o => o), map(() => { }));
  207. /** Event emitted when the drawer has started opening. */
  208. this.openedStart = this._animationStarted.pipe(filter(e => e.fromState !== e.toState && e.toState.indexOf('open') === 0), mapTo(undefined));
  209. /** Event emitted when the drawer has been closed. */
  210. this._closedStream = this.openedChange.pipe(filter(o => !o), map(() => { }));
  211. /** Event emitted when the drawer has started closing. */
  212. this.closedStart = this._animationStarted.pipe(filter(e => e.fromState !== e.toState && e.toState === 'void'), mapTo(undefined));
  213. /** Emits when the component is destroyed. */
  214. this._destroyed = new Subject();
  215. /** Event emitted when the drawer's position changes. */
  216. // tslint:disable-next-line:no-output-on-prefix
  217. this.onPositionChanged = new EventEmitter();
  218. /**
  219. * An observable that emits when the drawer mode changes. This is used by the drawer container to
  220. * to know when to when the mode changes so it can adapt the margins on the content.
  221. */
  222. this._modeChanged = new Subject();
  223. this.openedChange.subscribe((opened) => {
  224. if (opened) {
  225. if (this._doc) {
  226. this._elementFocusedBeforeDrawerWasOpened = this._doc.activeElement;
  227. }
  228. this._takeFocus();
  229. }
  230. else if (this._isFocusWithinDrawer()) {
  231. this._restoreFocus(this._openedVia || 'program');
  232. }
  233. });
  234. /**
  235. * Listen to `keydown` events outside the zone so that change detection is not run every
  236. * time a key is pressed. Instead we re-enter the zone only if the `ESC` key is pressed
  237. * and we don't have close disabled.
  238. */
  239. this._ngZone.runOutsideAngular(() => {
  240. fromEvent(this._elementRef.nativeElement, 'keydown')
  241. .pipe(filter(event => {
  242. return event.keyCode === ESCAPE && !this.disableClose && !hasModifierKey(event);
  243. }), takeUntil(this._destroyed))
  244. .subscribe(event => this._ngZone.run(() => {
  245. this.close();
  246. event.stopPropagation();
  247. event.preventDefault();
  248. }));
  249. });
  250. // We need a Subject with distinctUntilChanged, because the `done` event
  251. // fires twice on some browsers. See https://github.com/angular/angular/issues/24084
  252. this._animationEnd
  253. .pipe(distinctUntilChanged((x, y) => {
  254. return x.fromState === y.fromState && x.toState === y.toState;
  255. }))
  256. .subscribe((event) => {
  257. const { fromState, toState } = event;
  258. if ((toState.indexOf('open') === 0 && fromState === 'void') ||
  259. (toState === 'void' && fromState.indexOf('open') === 0)) {
  260. this.openedChange.emit(this._opened);
  261. }
  262. });
  263. }
  264. /**
  265. * Focuses the provided element. If the element is not focusable, it will add a tabIndex
  266. * attribute to forcefully focus it. The attribute is removed after focus is moved.
  267. * @param element The element to focus.
  268. */
  269. _forceFocus(element, options) {
  270. if (!this._interactivityChecker.isFocusable(element)) {
  271. element.tabIndex = -1;
  272. // The tabindex attribute should be removed to avoid navigating to that element again
  273. this._ngZone.runOutsideAngular(() => {
  274. const callback = () => {
  275. element.removeEventListener('blur', callback);
  276. element.removeEventListener('mousedown', callback);
  277. element.removeAttribute('tabindex');
  278. };
  279. element.addEventListener('blur', callback);
  280. element.addEventListener('mousedown', callback);
  281. });
  282. }
  283. element.focus(options);
  284. }
  285. /**
  286. * Focuses the first element that matches the given selector within the focus trap.
  287. * @param selector The CSS selector for the element to set focus to.
  288. */
  289. _focusByCssSelector(selector, options) {
  290. let elementToFocus = this._elementRef.nativeElement.querySelector(selector);
  291. if (elementToFocus) {
  292. this._forceFocus(elementToFocus, options);
  293. }
  294. }
  295. /**
  296. * Moves focus into the drawer. Note that this works even if
  297. * the focus trap is disabled in `side` mode.
  298. */
  299. _takeFocus() {
  300. if (!this._focusTrap) {
  301. return;
  302. }
  303. const element = this._elementRef.nativeElement;
  304. // When autoFocus is not on the sidenav, if the element cannot be focused or does
  305. // not exist, focus the sidenav itself so the keyboard navigation still works.
  306. // We need to check that `focus` is a function due to Universal.
  307. switch (this.autoFocus) {
  308. case false:
  309. case 'dialog':
  310. return;
  311. case true:
  312. case 'first-tabbable':
  313. this._focusTrap.focusInitialElementWhenReady().then(hasMovedFocus => {
  314. if (!hasMovedFocus && typeof this._elementRef.nativeElement.focus === 'function') {
  315. element.focus();
  316. }
  317. });
  318. break;
  319. case 'first-heading':
  320. this._focusByCssSelector('h1, h2, h3, h4, h5, h6, [role="heading"]');
  321. break;
  322. default:
  323. this._focusByCssSelector(this.autoFocus);
  324. break;
  325. }
  326. }
  327. /**
  328. * Restores focus to the element that was originally focused when the drawer opened.
  329. * If no element was focused at that time, the focus will be restored to the drawer.
  330. */
  331. _restoreFocus(focusOrigin) {
  332. if (this.autoFocus === 'dialog') {
  333. return;
  334. }
  335. if (this._elementFocusedBeforeDrawerWasOpened) {
  336. this._focusMonitor.focusVia(this._elementFocusedBeforeDrawerWasOpened, focusOrigin);
  337. }
  338. else {
  339. this._elementRef.nativeElement.blur();
  340. }
  341. this._elementFocusedBeforeDrawerWasOpened = null;
  342. }
  343. /** Whether focus is currently within the drawer. */
  344. _isFocusWithinDrawer() {
  345. const activeEl = this._doc.activeElement;
  346. return !!activeEl && this._elementRef.nativeElement.contains(activeEl);
  347. }
  348. ngAfterViewInit() {
  349. this._isAttached = true;
  350. this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
  351. this._updateFocusTrapState();
  352. // Only update the DOM position when the sidenav is positioned at
  353. // the end since we project the sidenav before the content by default.
  354. if (this._position === 'end') {
  355. this._updatePositionInParent('end');
  356. }
  357. }
  358. ngAfterContentChecked() {
  359. // Enable the animations after the lifecycle hooks have run, in order to avoid animating
  360. // drawers that are open by default. When we're on the server, we shouldn't enable the
  361. // animations, because we don't want the drawer to animate the first time the user sees
  362. // the page.
  363. if (this._platform.isBrowser) {
  364. this._enableAnimations = true;
  365. }
  366. }
  367. ngOnDestroy() {
  368. if (this._focusTrap) {
  369. this._focusTrap.destroy();
  370. }
  371. this._anchor?.remove();
  372. this._anchor = null;
  373. this._animationStarted.complete();
  374. this._animationEnd.complete();
  375. this._modeChanged.complete();
  376. this._destroyed.next();
  377. this._destroyed.complete();
  378. }
  379. /**
  380. * Open the drawer.
  381. * @param openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  382. * Used for focus management after the sidenav is closed.
  383. */
  384. open(openedVia) {
  385. return this.toggle(true, openedVia);
  386. }
  387. /** Close the drawer. */
  388. close() {
  389. return this.toggle(false);
  390. }
  391. /** Closes the drawer with context that the backdrop was clicked. */
  392. _closeViaBackdropClick() {
  393. // If the drawer is closed upon a backdrop click, we always want to restore focus. We
  394. // don't need to check whether focus is currently in the drawer, as clicking on the
  395. // backdrop causes blurs the active element.
  396. return this._setOpen(/* isOpen */ false, /* restoreFocus */ true, 'mouse');
  397. }
  398. /**
  399. * Toggle this drawer.
  400. * @param isOpen Whether the drawer should be open.
  401. * @param openedVia Whether the drawer was opened by a key press, mouse click or programmatically.
  402. * Used for focus management after the sidenav is closed.
  403. */
  404. toggle(isOpen = !this.opened, openedVia) {
  405. // If the focus is currently inside the drawer content and we are closing the drawer,
  406. // restore the focus to the initially focused element (when the drawer opened).
  407. if (isOpen && openedVia) {
  408. this._openedVia = openedVia;
  409. }
  410. const result = this._setOpen(isOpen,
  411. /* restoreFocus */ !isOpen && this._isFocusWithinDrawer(), this._openedVia || 'program');
  412. if (!isOpen) {
  413. this._openedVia = null;
  414. }
  415. return result;
  416. }
  417. /**
  418. * Toggles the opened state of the drawer.
  419. * @param isOpen Whether the drawer should open or close.
  420. * @param restoreFocus Whether focus should be restored on close.
  421. * @param focusOrigin Origin to use when restoring focus.
  422. */
  423. _setOpen(isOpen, restoreFocus, focusOrigin) {
  424. this._opened = isOpen;
  425. if (isOpen) {
  426. this._animationState = this._enableAnimations ? 'open' : 'open-instant';
  427. }
  428. else {
  429. this._animationState = 'void';
  430. if (restoreFocus) {
  431. this._restoreFocus(focusOrigin);
  432. }
  433. }
  434. this._updateFocusTrapState();
  435. return new Promise(resolve => {
  436. this.openedChange.pipe(take(1)).subscribe(open => resolve(open ? 'open' : 'close'));
  437. });
  438. }
  439. _getWidth() {
  440. return this._elementRef.nativeElement ? this._elementRef.nativeElement.offsetWidth || 0 : 0;
  441. }
  442. /** Updates the enabled state of the focus trap. */
  443. _updateFocusTrapState() {
  444. if (this._focusTrap) {
  445. // The focus trap is only enabled when the drawer is open in any mode other than side.
  446. this._focusTrap.enabled = this.opened && this.mode !== 'side';
  447. }
  448. }
  449. /**
  450. * Updates the position of the drawer in the DOM. We need to move the element around ourselves
  451. * when it's in the `end` position so that it comes after the content and the visual order
  452. * matches the tab order. We also need to be able to move it back to `start` if the sidenav
  453. * started off as `end` and was changed to `start`.
  454. */
  455. _updatePositionInParent(newPosition) {
  456. const element = this._elementRef.nativeElement;
  457. const parent = element.parentNode;
  458. if (newPosition === 'end') {
  459. if (!this._anchor) {
  460. this._anchor = this._doc.createComment('mat-drawer-anchor');
  461. parent.insertBefore(this._anchor, element);
  462. }
  463. parent.appendChild(element);
  464. }
  465. else if (this._anchor) {
  466. this._anchor.parentNode.insertBefore(element, this._anchor);
  467. }
  468. }
  469. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatDrawer, deps: [{ token: i0.ElementRef }, { token: i2.FocusTrapFactory }, { token: i2.FocusMonitor }, { token: i3.Platform }, { token: i0.NgZone }, { token: i2.InteractivityChecker }, { token: DOCUMENT, optional: true }, { token: MAT_DRAWER_CONTAINER, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
  470. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatDrawer, selector: "mat-drawer", inputs: { position: "position", mode: "mode", disableClose: "disableClose", autoFocus: "autoFocus", opened: "opened" }, outputs: { openedChange: "openedChange", _openedStream: "opened", openedStart: "openedStart", _closedStream: "closed", closedStart: "closedStart", onPositionChanged: "positionChanged" }, host: { attributes: { "tabIndex": "-1", "ngSkipHydration": "" }, listeners: { "@transform.start": "_animationStarted.next($event)", "@transform.done": "_animationEnd.next($event)" }, properties: { "attr.align": "null", "class.mat-drawer-end": "position === \"end\"", "class.mat-drawer-over": "mode === \"over\"", "class.mat-drawer-push": "mode === \"push\"", "class.mat-drawer-side": "mode === \"side\"", "class.mat-drawer-opened": "opened", "@transform": "_animationState" }, classAttribute: "mat-drawer" }, viewQueries: [{ propertyName: "_content", first: true, predicate: ["content"], descendants: true }], exportAs: ["matDrawer"], ngImport: i0, template: "<div class=\"mat-drawer-inner-container\" cdkScrollable #content>\r\n <ng-content></ng-content>\r\n</div>\r\n", dependencies: [{ kind: "directive", type: i1.CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }], animations: [matDrawerAnimations.transformDrawer], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  471. }
  472. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatDrawer, decorators: [{
  473. type: Component,
  474. args: [{ selector: 'mat-drawer', exportAs: 'matDrawer', animations: [matDrawerAnimations.transformDrawer], host: {
  475. 'class': 'mat-drawer',
  476. // must prevent the browser from aligning text based on value
  477. '[attr.align]': 'null',
  478. '[class.mat-drawer-end]': 'position === "end"',
  479. '[class.mat-drawer-over]': 'mode === "over"',
  480. '[class.mat-drawer-push]': 'mode === "push"',
  481. '[class.mat-drawer-side]': 'mode === "side"',
  482. '[class.mat-drawer-opened]': 'opened',
  483. 'tabIndex': '-1',
  484. '[@transform]': '_animationState',
  485. '(@transform.start)': '_animationStarted.next($event)',
  486. '(@transform.done)': '_animationEnd.next($event)',
  487. 'ngSkipHydration': '',
  488. }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<div class=\"mat-drawer-inner-container\" cdkScrollable #content>\r\n <ng-content></ng-content>\r\n</div>\r\n" }]
  489. }], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i2.FocusTrapFactory }, { type: i2.FocusMonitor }, { type: i3.Platform }, { type: i0.NgZone }, { type: i2.InteractivityChecker }, { type: undefined, decorators: [{
  490. type: Optional
  491. }, {
  492. type: Inject,
  493. args: [DOCUMENT]
  494. }] }, { type: MatDrawerContainer, decorators: [{
  495. type: Optional
  496. }, {
  497. type: Inject,
  498. args: [MAT_DRAWER_CONTAINER]
  499. }] }]; }, propDecorators: { position: [{
  500. type: Input
  501. }], mode: [{
  502. type: Input
  503. }], disableClose: [{
  504. type: Input
  505. }], autoFocus: [{
  506. type: Input
  507. }], opened: [{
  508. type: Input
  509. }], openedChange: [{
  510. type: Output
  511. }], _openedStream: [{
  512. type: Output,
  513. args: ['opened']
  514. }], openedStart: [{
  515. type: Output
  516. }], _closedStream: [{
  517. type: Output,
  518. args: ['closed']
  519. }], closedStart: [{
  520. type: Output
  521. }], onPositionChanged: [{
  522. type: Output,
  523. args: ['positionChanged']
  524. }], _content: [{
  525. type: ViewChild,
  526. args: ['content']
  527. }] } });
  528. /**
  529. * `<mat-drawer-container>` component.
  530. *
  531. * This is the parent component to one or two `<mat-drawer>`s that validates the state internally
  532. * and coordinates the backdrop and content styling.
  533. */
  534. class MatDrawerContainer {
  535. /** The drawer child with the `start` position. */
  536. get start() {
  537. return this._start;
  538. }
  539. /** The drawer child with the `end` position. */
  540. get end() {
  541. return this._end;
  542. }
  543. /**
  544. * Whether to automatically resize the container whenever
  545. * the size of any of its drawers changes.
  546. *
  547. * **Use at your own risk!** Enabling this option can cause layout thrashing by measuring
  548. * the drawers on every change detection cycle. Can be configured globally via the
  549. * `MAT_DRAWER_DEFAULT_AUTOSIZE` token.
  550. */
  551. get autosize() {
  552. return this._autosize;
  553. }
  554. set autosize(value) {
  555. this._autosize = coerceBooleanProperty(value);
  556. }
  557. /**
  558. * Whether the drawer container should have a backdrop while one of the sidenavs is open.
  559. * If explicitly set to `true`, the backdrop will be enabled for drawers in the `side`
  560. * mode as well.
  561. */
  562. get hasBackdrop() {
  563. if (this._backdropOverride == null) {
  564. return !this._start || this._start.mode !== 'side' || !this._end || this._end.mode !== 'side';
  565. }
  566. return this._backdropOverride;
  567. }
  568. set hasBackdrop(value) {
  569. this._backdropOverride = value == null ? null : coerceBooleanProperty(value);
  570. }
  571. /** Reference to the CdkScrollable instance that wraps the scrollable content. */
  572. get scrollable() {
  573. return this._userContent || this._content;
  574. }
  575. constructor(_dir, _element, _ngZone, _changeDetectorRef, viewportRuler, defaultAutosize = false, _animationMode) {
  576. this._dir = _dir;
  577. this._element = _element;
  578. this._ngZone = _ngZone;
  579. this._changeDetectorRef = _changeDetectorRef;
  580. this._animationMode = _animationMode;
  581. /** Drawers that belong to this container. */
  582. this._drawers = new QueryList();
  583. /** Event emitted when the drawer backdrop is clicked. */
  584. this.backdropClick = new EventEmitter();
  585. /** Emits when the component is destroyed. */
  586. this._destroyed = new Subject();
  587. /** Emits on every ngDoCheck. Used for debouncing reflows. */
  588. this._doCheckSubject = new Subject();
  589. /**
  590. * Margins to be applied to the content. These are used to push / shrink the drawer content when a
  591. * drawer is open. We use margin rather than transform even for push mode because transform breaks
  592. * fixed position elements inside of the transformed element.
  593. */
  594. this._contentMargins = { left: null, right: null };
  595. this._contentMarginChanges = new Subject();
  596. // If a `Dir` directive exists up the tree, listen direction changes
  597. // and update the left/right properties to point to the proper start/end.
  598. if (_dir) {
  599. _dir.change.pipe(takeUntil(this._destroyed)).subscribe(() => {
  600. this._validateDrawers();
  601. this.updateContentMargins();
  602. });
  603. }
  604. // Since the minimum width of the sidenav depends on the viewport width,
  605. // we need to recompute the margins if the viewport changes.
  606. viewportRuler
  607. .change()
  608. .pipe(takeUntil(this._destroyed))
  609. .subscribe(() => this.updateContentMargins());
  610. this._autosize = defaultAutosize;
  611. }
  612. ngAfterContentInit() {
  613. this._allDrawers.changes
  614. .pipe(startWith(this._allDrawers), takeUntil(this._destroyed))
  615. .subscribe((drawer) => {
  616. this._drawers.reset(drawer.filter(item => !item._container || item._container === this));
  617. this._drawers.notifyOnChanges();
  618. });
  619. this._drawers.changes.pipe(startWith(null)).subscribe(() => {
  620. this._validateDrawers();
  621. this._drawers.forEach((drawer) => {
  622. this._watchDrawerToggle(drawer);
  623. this._watchDrawerPosition(drawer);
  624. this._watchDrawerMode(drawer);
  625. });
  626. if (!this._drawers.length ||
  627. this._isDrawerOpen(this._start) ||
  628. this._isDrawerOpen(this._end)) {
  629. this.updateContentMargins();
  630. }
  631. this._changeDetectorRef.markForCheck();
  632. });
  633. // Avoid hitting the NgZone through the debounce timeout.
  634. this._ngZone.runOutsideAngular(() => {
  635. this._doCheckSubject
  636. .pipe(debounceTime(10), // Arbitrary debounce time, less than a frame at 60fps
  637. takeUntil(this._destroyed))
  638. .subscribe(() => this.updateContentMargins());
  639. });
  640. }
  641. ngOnDestroy() {
  642. this._contentMarginChanges.complete();
  643. this._doCheckSubject.complete();
  644. this._drawers.destroy();
  645. this._destroyed.next();
  646. this._destroyed.complete();
  647. }
  648. /** Calls `open` of both start and end drawers */
  649. open() {
  650. this._drawers.forEach(drawer => drawer.open());
  651. }
  652. /** Calls `close` of both start and end drawers */
  653. close() {
  654. this._drawers.forEach(drawer => drawer.close());
  655. }
  656. /**
  657. * Recalculates and updates the inline styles for the content. Note that this should be used
  658. * sparingly, because it causes a reflow.
  659. */
  660. updateContentMargins() {
  661. // 1. For drawers in `over` mode, they don't affect the content.
  662. // 2. For drawers in `side` mode they should shrink the content. We do this by adding to the
  663. // left margin (for left drawer) or right margin (for right the drawer).
  664. // 3. For drawers in `push` mode the should shift the content without resizing it. We do this by
  665. // adding to the left or right margin and simultaneously subtracting the same amount of
  666. // margin from the other side.
  667. let left = 0;
  668. let right = 0;
  669. if (this._left && this._left.opened) {
  670. if (this._left.mode == 'side') {
  671. left += this._left._getWidth();
  672. }
  673. else if (this._left.mode == 'push') {
  674. const width = this._left._getWidth();
  675. left += width;
  676. right -= width;
  677. }
  678. }
  679. if (this._right && this._right.opened) {
  680. if (this._right.mode == 'side') {
  681. right += this._right._getWidth();
  682. }
  683. else if (this._right.mode == 'push') {
  684. const width = this._right._getWidth();
  685. right += width;
  686. left -= width;
  687. }
  688. }
  689. // If either `right` or `left` is zero, don't set a style to the element. This
  690. // allows users to specify a custom size via CSS class in SSR scenarios where the
  691. // measured widths will always be zero. Note that we reset to `null` here, rather
  692. // than below, in order to ensure that the types in the `if` below are consistent.
  693. left = left || null;
  694. right = right || null;
  695. if (left !== this._contentMargins.left || right !== this._contentMargins.right) {
  696. this._contentMargins = { left, right };
  697. // Pull back into the NgZone since in some cases we could be outside. We need to be careful
  698. // to do it only when something changed, otherwise we can end up hitting the zone too often.
  699. this._ngZone.run(() => this._contentMarginChanges.next(this._contentMargins));
  700. }
  701. }
  702. ngDoCheck() {
  703. // If users opted into autosizing, do a check every change detection cycle.
  704. if (this._autosize && this._isPushed()) {
  705. // Run outside the NgZone, otherwise the debouncer will throw us into an infinite loop.
  706. this._ngZone.runOutsideAngular(() => this._doCheckSubject.next());
  707. }
  708. }
  709. /**
  710. * Subscribes to drawer events in order to set a class on the main container element when the
  711. * drawer is open and the backdrop is visible. This ensures any overflow on the container element
  712. * is properly hidden.
  713. */
  714. _watchDrawerToggle(drawer) {
  715. drawer._animationStarted
  716. .pipe(filter((event) => event.fromState !== event.toState), takeUntil(this._drawers.changes))
  717. .subscribe((event) => {
  718. // Set the transition class on the container so that the animations occur. This should not
  719. // be set initially because animations should only be triggered via a change in state.
  720. if (event.toState !== 'open-instant' && this._animationMode !== 'NoopAnimations') {
  721. this._element.nativeElement.classList.add('mat-drawer-transition');
  722. }
  723. this.updateContentMargins();
  724. this._changeDetectorRef.markForCheck();
  725. });
  726. if (drawer.mode !== 'side') {
  727. drawer.openedChange
  728. .pipe(takeUntil(this._drawers.changes))
  729. .subscribe(() => this._setContainerClass(drawer.opened));
  730. }
  731. }
  732. /**
  733. * Subscribes to drawer onPositionChanged event in order to
  734. * re-validate drawers when the position changes.
  735. */
  736. _watchDrawerPosition(drawer) {
  737. if (!drawer) {
  738. return;
  739. }
  740. // NOTE: We need to wait for the microtask queue to be empty before validating,
  741. // since both drawers may be swapping positions at the same time.
  742. drawer.onPositionChanged.pipe(takeUntil(this._drawers.changes)).subscribe(() => {
  743. this._ngZone.onMicrotaskEmpty.pipe(take(1)).subscribe(() => {
  744. this._validateDrawers();
  745. });
  746. });
  747. }
  748. /** Subscribes to changes in drawer mode so we can run change detection. */
  749. _watchDrawerMode(drawer) {
  750. if (drawer) {
  751. drawer._modeChanged
  752. .pipe(takeUntil(merge(this._drawers.changes, this._destroyed)))
  753. .subscribe(() => {
  754. this.updateContentMargins();
  755. this._changeDetectorRef.markForCheck();
  756. });
  757. }
  758. }
  759. /** Toggles the 'mat-drawer-opened' class on the main 'mat-drawer-container' element. */
  760. _setContainerClass(isAdd) {
  761. const classList = this._element.nativeElement.classList;
  762. const className = 'mat-drawer-container-has-open';
  763. if (isAdd) {
  764. classList.add(className);
  765. }
  766. else {
  767. classList.remove(className);
  768. }
  769. }
  770. /** Validate the state of the drawer children components. */
  771. _validateDrawers() {
  772. this._start = this._end = null;
  773. // Ensure that we have at most one start and one end drawer.
  774. this._drawers.forEach(drawer => {
  775. if (drawer.position == 'end') {
  776. if (this._end != null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  777. throwMatDuplicatedDrawerError('end');
  778. }
  779. this._end = drawer;
  780. }
  781. else {
  782. if (this._start != null && (typeof ngDevMode === 'undefined' || ngDevMode)) {
  783. throwMatDuplicatedDrawerError('start');
  784. }
  785. this._start = drawer;
  786. }
  787. });
  788. this._right = this._left = null;
  789. // Detect if we're LTR or RTL.
  790. if (this._dir && this._dir.value === 'rtl') {
  791. this._left = this._end;
  792. this._right = this._start;
  793. }
  794. else {
  795. this._left = this._start;
  796. this._right = this._end;
  797. }
  798. }
  799. /** Whether the container is being pushed to the side by one of the drawers. */
  800. _isPushed() {
  801. return ((this._isDrawerOpen(this._start) && this._start.mode != 'over') ||
  802. (this._isDrawerOpen(this._end) && this._end.mode != 'over'));
  803. }
  804. _onBackdropClicked() {
  805. this.backdropClick.emit();
  806. this._closeModalDrawersViaBackdrop();
  807. }
  808. _closeModalDrawersViaBackdrop() {
  809. // Close all open drawers where closing is not disabled and the mode is not `side`.
  810. [this._start, this._end]
  811. .filter(drawer => drawer && !drawer.disableClose && this._canHaveBackdrop(drawer))
  812. .forEach(drawer => drawer._closeViaBackdropClick());
  813. }
  814. _isShowingBackdrop() {
  815. return ((this._isDrawerOpen(this._start) && this._canHaveBackdrop(this._start)) ||
  816. (this._isDrawerOpen(this._end) && this._canHaveBackdrop(this._end)));
  817. }
  818. _canHaveBackdrop(drawer) {
  819. return drawer.mode !== 'side' || !!this._backdropOverride;
  820. }
  821. _isDrawerOpen(drawer) {
  822. return drawer != null && drawer.opened;
  823. }
  824. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatDrawerContainer, deps: [{ token: i4.Directionality, optional: true }, { token: i0.ElementRef }, { token: i0.NgZone }, { token: i0.ChangeDetectorRef }, { token: i1.ViewportRuler }, { token: MAT_DRAWER_DEFAULT_AUTOSIZE }, { token: ANIMATION_MODULE_TYPE, optional: true }], target: i0.ɵɵFactoryTarget.Component }); }
  825. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatDrawerContainer, selector: "mat-drawer-container", inputs: { autosize: "autosize", hasBackdrop: "hasBackdrop" }, outputs: { backdropClick: "backdropClick" }, host: { attributes: { "ngSkipHydration": "" }, properties: { "class.mat-drawer-container-explicit-backdrop": "_backdropOverride" }, classAttribute: "mat-drawer-container" }, providers: [
  826. {
  827. provide: MAT_DRAWER_CONTAINER,
  828. useExisting: MatDrawerContainer,
  829. },
  830. ], queries: [{ propertyName: "_content", first: true, predicate: MatDrawerContent, descendants: true }, { propertyName: "_allDrawers", predicate: MatDrawer, descendants: true }], viewQueries: [{ propertyName: "_userContent", first: true, predicate: MatDrawerContent, descendants: true }], exportAs: ["matDrawerContainer"], ngImport: i0, template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" *ngIf=\"hasBackdrop\"\n [class.mat-drawer-shown]=\"_isShowingBackdrop()\"></div>\n\n<ng-content select=\"mat-drawer\"></ng-content>\n\n<ng-content select=\"mat-drawer-content\">\n</ng-content>\n<mat-drawer-content *ngIf=\"!_content\">\n <ng-content></ng-content>\n</mat-drawer-content>\n", 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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}.cdk-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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.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)}.cdk-high-contrast-active .mat-drawer,.cdk-high-contrast-active [dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}.cdk-high-contrast-active [dir=rtl] .mat-drawer,.cdk-high-contrast-active .mat-drawer.mat-drawer-end{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[style*=\"visibility: hidden\"]{display:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.mat-sidenav-fixed{position:fixed}"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MatDrawerContent, selector: "mat-drawer-content" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  831. }
  832. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatDrawerContainer, decorators: [{
  833. type: Component,
  834. args: [{ selector: 'mat-drawer-container', exportAs: 'matDrawerContainer', host: {
  835. 'class': 'mat-drawer-container',
  836. '[class.mat-drawer-container-explicit-backdrop]': '_backdropOverride',
  837. 'ngSkipHydration': '',
  838. }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
  839. {
  840. provide: MAT_DRAWER_CONTAINER,
  841. useExisting: MatDrawerContainer,
  842. },
  843. ], template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" *ngIf=\"hasBackdrop\"\n [class.mat-drawer-shown]=\"_isShowingBackdrop()\"></div>\n\n<ng-content select=\"mat-drawer\"></ng-content>\n\n<ng-content select=\"mat-drawer-content\">\n</ng-content>\n<mat-drawer-content *ngIf=\"!_content\">\n <ng-content></ng-content>\n</mat-drawer-content>\n", 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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}.cdk-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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.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)}.cdk-high-contrast-active .mat-drawer,.cdk-high-contrast-active [dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}.cdk-high-contrast-active [dir=rtl] .mat-drawer,.cdk-high-contrast-active .mat-drawer.mat-drawer-end{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[style*=\"visibility: hidden\"]{display:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.mat-sidenav-fixed{position:fixed}"] }]
  844. }], ctorParameters: function () { return [{ type: i4.Directionality, decorators: [{
  845. type: Optional
  846. }] }, { type: i0.ElementRef }, { type: i0.NgZone }, { type: i0.ChangeDetectorRef }, { type: i1.ViewportRuler }, { type: undefined, decorators: [{
  847. type: Inject,
  848. args: [MAT_DRAWER_DEFAULT_AUTOSIZE]
  849. }] }, { type: undefined, decorators: [{
  850. type: Optional
  851. }, {
  852. type: Inject,
  853. args: [ANIMATION_MODULE_TYPE]
  854. }] }]; }, propDecorators: { _allDrawers: [{
  855. type: ContentChildren,
  856. args: [MatDrawer, {
  857. // We need to use `descendants: true`, because Ivy will no longer match
  858. // indirect descendants if it's left as false.
  859. descendants: true,
  860. }]
  861. }], _content: [{
  862. type: ContentChild,
  863. args: [MatDrawerContent]
  864. }], _userContent: [{
  865. type: ViewChild,
  866. args: [MatDrawerContent]
  867. }], autosize: [{
  868. type: Input
  869. }], hasBackdrop: [{
  870. type: Input
  871. }], backdropClick: [{
  872. type: Output
  873. }] } });
  874. class MatSidenavContent extends MatDrawerContent {
  875. constructor(changeDetectorRef, container, elementRef, scrollDispatcher, ngZone) {
  876. super(changeDetectorRef, container, elementRef, scrollDispatcher, ngZone);
  877. }
  878. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavContent, deps: [{ token: i0.ChangeDetectorRef }, { token: forwardRef(() => MatSidenavContainer) }, { token: i0.ElementRef }, { token: i1.ScrollDispatcher }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component }); }
  879. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatSidenavContent, selector: "mat-sidenav-content", host: { attributes: { "ngSkipHydration": "" }, properties: { "style.margin-left.px": "_container._contentMargins.left", "style.margin-right.px": "_container._contentMargins.right" }, classAttribute: "mat-drawer-content mat-sidenav-content" }, providers: [
  880. {
  881. provide: CdkScrollable,
  882. useExisting: MatSidenavContent,
  883. },
  884. ], usesInheritance: true, ngImport: i0, template: '<ng-content></ng-content>', isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  885. }
  886. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavContent, decorators: [{
  887. type: Component,
  888. args: [{
  889. selector: 'mat-sidenav-content',
  890. template: '<ng-content></ng-content>',
  891. host: {
  892. 'class': 'mat-drawer-content mat-sidenav-content',
  893. '[style.margin-left.px]': '_container._contentMargins.left',
  894. '[style.margin-right.px]': '_container._contentMargins.right',
  895. 'ngSkipHydration': '',
  896. },
  897. changeDetection: ChangeDetectionStrategy.OnPush,
  898. encapsulation: ViewEncapsulation.None,
  899. providers: [
  900. {
  901. provide: CdkScrollable,
  902. useExisting: MatSidenavContent,
  903. },
  904. ],
  905. }]
  906. }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: MatSidenavContainer, decorators: [{
  907. type: Inject,
  908. args: [forwardRef(() => MatSidenavContainer)]
  909. }] }, { type: i0.ElementRef }, { type: i1.ScrollDispatcher }, { type: i0.NgZone }]; } });
  910. class MatSidenav extends MatDrawer {
  911. constructor() {
  912. super(...arguments);
  913. this._fixedInViewport = false;
  914. this._fixedTopGap = 0;
  915. this._fixedBottomGap = 0;
  916. }
  917. /** Whether the sidenav is fixed in the viewport. */
  918. get fixedInViewport() {
  919. return this._fixedInViewport;
  920. }
  921. set fixedInViewport(value) {
  922. this._fixedInViewport = coerceBooleanProperty(value);
  923. }
  924. /**
  925. * The gap between the top of the sidenav and the top of the viewport when the sidenav is in fixed
  926. * mode.
  927. */
  928. get fixedTopGap() {
  929. return this._fixedTopGap;
  930. }
  931. set fixedTopGap(value) {
  932. this._fixedTopGap = coerceNumberProperty(value);
  933. }
  934. /**
  935. * The gap between the bottom of the sidenav and the bottom of the viewport when the sidenav is in
  936. * fixed mode.
  937. */
  938. get fixedBottomGap() {
  939. return this._fixedBottomGap;
  940. }
  941. set fixedBottomGap(value) {
  942. this._fixedBottomGap = coerceNumberProperty(value);
  943. }
  944. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenav, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
  945. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatSidenav, selector: "mat-sidenav", inputs: { fixedInViewport: "fixedInViewport", fixedTopGap: "fixedTopGap", fixedBottomGap: "fixedBottomGap" }, host: { attributes: { "tabIndex": "-1", "ngSkipHydration": "" }, properties: { "attr.align": "null", "class.mat-drawer-end": "position === \"end\"", "class.mat-drawer-over": "mode === \"over\"", "class.mat-drawer-push": "mode === \"push\"", "class.mat-drawer-side": "mode === \"side\"", "class.mat-drawer-opened": "opened", "class.mat-sidenav-fixed": "fixedInViewport", "style.top.px": "fixedInViewport ? fixedTopGap : null", "style.bottom.px": "fixedInViewport ? fixedBottomGap : null" }, classAttribute: "mat-drawer mat-sidenav" }, exportAs: ["matSidenav"], usesInheritance: true, ngImport: i0, template: "<div class=\"mat-drawer-inner-container\" cdkScrollable #content>\r\n <ng-content></ng-content>\r\n</div>\r\n", dependencies: [{ kind: "directive", type: i1.CdkScrollable, selector: "[cdk-scrollable], [cdkScrollable]" }], animations: [matDrawerAnimations.transformDrawer], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  946. }
  947. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenav, decorators: [{
  948. type: Component,
  949. args: [{ selector: 'mat-sidenav', exportAs: 'matSidenav', animations: [matDrawerAnimations.transformDrawer], host: {
  950. 'class': 'mat-drawer mat-sidenav',
  951. 'tabIndex': '-1',
  952. // must prevent the browser from aligning text based on value
  953. '[attr.align]': 'null',
  954. '[class.mat-drawer-end]': 'position === "end"',
  955. '[class.mat-drawer-over]': 'mode === "over"',
  956. '[class.mat-drawer-push]': 'mode === "push"',
  957. '[class.mat-drawer-side]': 'mode === "side"',
  958. '[class.mat-drawer-opened]': 'opened',
  959. '[class.mat-sidenav-fixed]': 'fixedInViewport',
  960. '[style.top.px]': 'fixedInViewport ? fixedTopGap : null',
  961. '[style.bottom.px]': 'fixedInViewport ? fixedBottomGap : null',
  962. 'ngSkipHydration': '',
  963. }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, template: "<div class=\"mat-drawer-inner-container\" cdkScrollable #content>\r\n <ng-content></ng-content>\r\n</div>\r\n" }]
  964. }], propDecorators: { fixedInViewport: [{
  965. type: Input
  966. }], fixedTopGap: [{
  967. type: Input
  968. }], fixedBottomGap: [{
  969. type: Input
  970. }] } });
  971. class MatSidenavContainer extends MatDrawerContainer {
  972. constructor() {
  973. super(...arguments);
  974. this._allDrawers = undefined;
  975. // We need an initializer here to avoid a TS error.
  976. this._content = undefined;
  977. }
  978. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavContainer, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
  979. static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.0.0", type: MatSidenavContainer, selector: "mat-sidenav-container", host: { attributes: { "ngSkipHydration": "" }, properties: { "class.mat-drawer-container-explicit-backdrop": "_backdropOverride" }, classAttribute: "mat-drawer-container mat-sidenav-container" }, providers: [
  980. {
  981. provide: MAT_DRAWER_CONTAINER,
  982. useExisting: MatSidenavContainer,
  983. },
  984. ], queries: [{ propertyName: "_content", first: true, predicate: MatSidenavContent, descendants: true }, { propertyName: "_allDrawers", predicate: MatSidenav, descendants: true }], exportAs: ["matSidenavContainer"], usesInheritance: true, ngImport: i0, template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" *ngIf=\"hasBackdrop\"\n [class.mat-drawer-shown]=\"_isShowingBackdrop()\"></div>\n\n<ng-content select=\"mat-sidenav\"></ng-content>\n\n<ng-content select=\"mat-sidenav-content\">\n</ng-content>\n<mat-sidenav-content *ngIf=\"!_content\">\n <ng-content></ng-content>\n</mat-sidenav-content>\n", 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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}.cdk-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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.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)}.cdk-high-contrast-active .mat-drawer,.cdk-high-contrast-active [dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}.cdk-high-contrast-active [dir=rtl] .mat-drawer,.cdk-high-contrast-active .mat-drawer.mat-drawer-end{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[style*=\"visibility: hidden\"]{display:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.mat-sidenav-fixed{position:fixed}"], dependencies: [{ kind: "directive", type: i5.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "component", type: MatSidenavContent, selector: "mat-sidenav-content" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
  985. }
  986. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavContainer, decorators: [{
  987. type: Component,
  988. args: [{ selector: 'mat-sidenav-container', exportAs: 'matSidenavContainer', host: {
  989. 'class': 'mat-drawer-container mat-sidenav-container',
  990. '[class.mat-drawer-container-explicit-backdrop]': '_backdropOverride',
  991. 'ngSkipHydration': '',
  992. }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [
  993. {
  994. provide: MAT_DRAWER_CONTAINER,
  995. useExisting: MatSidenavContainer,
  996. },
  997. ], template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" *ngIf=\"hasBackdrop\"\n [class.mat-drawer-shown]=\"_isShowingBackdrop()\"></div>\n\n<ng-content select=\"mat-sidenav\"></ng-content>\n\n<ng-content select=\"mat-sidenav-content\">\n</ng-content>\n<mat-sidenav-content *ngIf=\"!_content\">\n <ng-content></ng-content>\n</mat-sidenav-content>\n", 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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.25, 1);transition-property:background-color,visibility}.cdk-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:400ms;transition-timing-function:cubic-bezier(0.25, 0.8, 0.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)}.cdk-high-contrast-active .mat-drawer,.cdk-high-contrast-active [dir=rtl] .mat-drawer.mat-drawer-end{border-right:solid 1px currentColor}.cdk-high-contrast-active [dir=rtl] .mat-drawer,.cdk-high-contrast-active .mat-drawer.mat-drawer-end{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[style*=\"visibility: hidden\"]{display:none}.mat-drawer-inner-container{width:100%;height:100%;overflow:auto;-webkit-overflow-scrolling:touch}.mat-sidenav-fixed{position:fixed}"] }]
  998. }], propDecorators: { _allDrawers: [{
  999. type: ContentChildren,
  1000. args: [MatSidenav, {
  1001. // We need to use `descendants: true`, because Ivy will no longer match
  1002. // indirect descendants if it's left as false.
  1003. descendants: true,
  1004. }]
  1005. }], _content: [{
  1006. type: ContentChild,
  1007. args: [MatSidenavContent]
  1008. }] } });
  1009. class MatSidenavModule {
  1010. static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
  1011. static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavModule, declarations: [MatDrawer,
  1012. MatDrawerContainer,
  1013. MatDrawerContent,
  1014. MatSidenav,
  1015. MatSidenavContainer,
  1016. MatSidenavContent], imports: [CommonModule, MatCommonModule, CdkScrollableModule], exports: [CdkScrollableModule,
  1017. MatCommonModule,
  1018. MatDrawer,
  1019. MatDrawerContainer,
  1020. MatDrawerContent,
  1021. MatSidenav,
  1022. MatSidenavContainer,
  1023. MatSidenavContent] }); }
  1024. static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavModule, imports: [CommonModule, MatCommonModule, CdkScrollableModule, CdkScrollableModule,
  1025. MatCommonModule] }); }
  1026. }
  1027. i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.0.0", ngImport: i0, type: MatSidenavModule, decorators: [{
  1028. type: NgModule,
  1029. args: [{
  1030. imports: [CommonModule, MatCommonModule, CdkScrollableModule],
  1031. exports: [
  1032. CdkScrollableModule,
  1033. MatCommonModule,
  1034. MatDrawer,
  1035. MatDrawerContainer,
  1036. MatDrawerContent,
  1037. MatSidenav,
  1038. MatSidenavContainer,
  1039. MatSidenavContent,
  1040. ],
  1041. declarations: [
  1042. MatDrawer,
  1043. MatDrawerContainer,
  1044. MatDrawerContent,
  1045. MatSidenav,
  1046. MatSidenavContainer,
  1047. MatSidenavContent,
  1048. ],
  1049. }]
  1050. }] });
  1051. /**
  1052. * Generated bundle index. Do not edit.
  1053. */
  1054. export { MAT_DRAWER_DEFAULT_AUTOSIZE, MAT_DRAWER_DEFAULT_AUTOSIZE_FACTORY, MatDrawer, MatDrawerContainer, MatDrawerContent, MatSidenav, MatSidenavContainer, MatSidenavContent, MatSidenavModule, matDrawerAnimations, throwMatDuplicatedDrawerError };
  1055. //# sourceMappingURL=sidenav.mjs.map