@angular/material
Version:
Angular Material
947 lines (941 loc) • 39.4 kB
JavaScript
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { A11yModule, FocusTrapFactory } from '@angular/cdk/a11y';
import { OverlayModule } from '@angular/cdk/overlay';
import { CommonModule } from '@angular/common';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, ContentChildren, ElementRef, EventEmitter, Inject, Input, NgModule, NgZone, Optional, Output, Renderer2, ViewEncapsulation, forwardRef } from '@angular/core';
import { MatCommonModule } from '@angular/material/core';
import { ScrollDispatchModule } from '@angular/cdk/scrolling';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { Directionality } from '@angular/cdk/bidi';
import { coerceBooleanProperty, coerceNumberProperty } from '@angular/cdk/coercion';
import { ESCAPE } from '@angular/cdk/keycodes';
import { DOCUMENT } from '@angular/platform-browser';
import { merge } from 'rxjs/observable/merge';
import { Subject } from 'rxjs/Subject';
import { RxChain, filter, first, startWith, takeUntil } from '@angular/cdk/rxjs';
import { __extends } from 'tslib';
import * as tslib_1 from 'tslib';
/**
* Throws an exception when two MatDrawer are matching the same position.
* @param {?} position
* @return {?}
*/
function throwMatDuplicatedDrawerError(position) {
throw Error("A drawer was already declared for 'position=\"" + position + "\"'");
}
/**
* Drawer toggle promise result.
* @deprecated
*/
var MatDrawerToggleResult = (function () {
/**
* @param {?} type
* @param {?} animationFinished
*/
function MatDrawerToggleResult(type, animationFinished) {
this.type = type;
this.animationFinished = animationFinished;
}
return MatDrawerToggleResult;
}());
var MatDrawerContent = (function () {
/**
* @param {?} _changeDetectorRef
* @param {?} _container
*/
function MatDrawerContent(_changeDetectorRef, _container) {
this._changeDetectorRef = _changeDetectorRef;
this._container = _container;
/**
* Margins to be applied to the content. These are used to push / shrink the drawer content when a
* drawer is open. We use margin rather than transform even for push mode because transform breaks
* fixed position elements inside of the transformed element.
*/
this._margins = { left: 0, right: 0 };
}
/**
* @return {?}
*/
MatDrawerContent.prototype.ngAfterContentInit = function () {
var _this = this;
this._container._contentMargins.subscribe(function (margins) {
_this._margins = margins;
_this._changeDetectorRef.markForCheck();
});
};
MatDrawerContent.decorators = [
{ type: Component, args: [{selector: 'mat-drawer-content',
template: '<ng-content></ng-content>',
host: {
'class': 'mat-drawer-content',
'[style.marginLeft.px]': '_margins.left',
'[style.marginRight.px]': '_margins.right',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
},] },
];
/**
* @nocollapse
*/
MatDrawerContent.ctorParameters = function () { return [
{ type: ChangeDetectorRef, },
{ type: MatDrawerContainer, decorators: [{ type: Inject, args: [forwardRef(function () { return MatDrawerContainer; }),] },] },
]; };
return MatDrawerContent;
}());
/**
* This component corresponds to a drawer that can be opened on the drawer container.
*/
var MatDrawer = (function () {
/**
* @param {?} _elementRef
* @param {?} _focusTrapFactory
* @param {?} _doc
*/
function MatDrawer(_elementRef, _focusTrapFactory, _doc) {
var _this = this;
this._elementRef = _elementRef;
this._focusTrapFactory = _focusTrapFactory;
this._doc = _doc;
this._elementFocusedBeforeDrawerWasOpened = null;
/**
* Whether the drawer is initialized. Used for disabling the initial animation.
*/
this._enableAnimations = false;
this._position = 'start';
this._mode = 'over';
this._disableClose = false;
/**
* Whether the drawer is opened.
*/
this._opened = false;
/**
* Emits whenever the drawer has started animating.
*/
this._animationStarted = new EventEmitter();
/**
* Whether the drawer is animating. Used to prevent overlapping animations.
*/
this._isAnimating = false;
/**
* Current state of the sidenav animation.
*/
this._animationState = 'void';
/**
* Event emitted when the drawer is fully opened.
*/
this.onOpen = new EventEmitter();
/**
* Event emitted when the drawer is fully closed.
*/
this.onClose = new EventEmitter();
/**
* Event emitted when the drawer's position changes.
*/
this.onPositionChanged = new EventEmitter();
/**
* @deprecated
*/
this.onAlignChanged = new EventEmitter();
/**
* An observable that emits when the drawer mode changes. This is used by the drawer container to
* to know when to when the mode changes so it can adapt the margins on the content.
*/
this._modeChanged = new Subject();
this.onOpen.subscribe(function () {
if (_this._doc) {
_this._elementFocusedBeforeDrawerWasOpened = _this._doc.activeElement;
}
if (_this._isFocusTrapEnabled && _this._focusTrap) {
_this._focusTrap.focusInitialElementWhenReady();
}
});
this.onClose.subscribe(function () { return _this._restoreFocus(); });
}
Object.defineProperty(MatDrawer.prototype, "position", {
/**
* The side that the drawer is attached to.
* @return {?}
*/
get: function () { return this._position; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) {
// Make sure we have a valid value.
value = value === 'end' ? 'end' : 'start';
if (value != this._position) {
this._position = value;
this.onAlignChanged.emit();
this.onPositionChanged.emit();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatDrawer.prototype, "align", {
/**
* @deprecated
* @return {?}
*/
get: function () { return this.position; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { this.position = value; },
enumerable: true,
configurable: true
});
Object.defineProperty(MatDrawer.prototype, "mode", {
/**
* Mode of the drawer; one of 'over', 'push' or 'side'.
* @return {?}
*/
get: function () { return this._mode; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) {
this._mode = value;
this._modeChanged.next();
},
enumerable: true,
configurable: true
});
Object.defineProperty(MatDrawer.prototype, "disableClose", {
/**
* Whether the drawer can be closed with the escape key or by clicking on the backdrop.
* @return {?}
*/
get: function () { return this._disableClose; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { this._disableClose = coerceBooleanProperty(value); },
enumerable: true,
configurable: true
});
Object.defineProperty(MatDrawer.prototype, "_isFocusTrapEnabled", {
/**
* @return {?}
*/
get: function () {
// The focus trap is only enabled when the drawer is open in any mode other than side.
return this.opened && this.mode !== 'side';
},
enumerable: true,
configurable: true
});
/**
* If focus is currently inside the drawer, restores it to where it was before the drawer
* opened.
* @return {?}
*/
MatDrawer.prototype._restoreFocus = function () {
var /** @type {?} */ activeEl = this._doc && this._doc.activeElement;
if (activeEl && this._elementRef.nativeElement.contains(activeEl)) {
if (this._elementFocusedBeforeDrawerWasOpened instanceof HTMLElement) {
this._elementFocusedBeforeDrawerWasOpened.focus();
}
else {
this._elementRef.nativeElement.blur();
}
}
this._elementFocusedBeforeDrawerWasOpened = null;
};
/**
* @return {?}
*/
MatDrawer.prototype.ngAfterContentInit = function () {
this._focusTrap = this._focusTrapFactory.create(this._elementRef.nativeElement);
this._focusTrap.enabled = this._isFocusTrapEnabled;
this._enableAnimations = true;
};
/**
* @return {?}
*/
MatDrawer.prototype.ngOnDestroy = function () {
if (this._focusTrap) {
this._focusTrap.destroy();
}
};
Object.defineProperty(MatDrawer.prototype, "opened", {
/**
* Whether the drawer is opened. We overload this because we trigger an event when it
* starts or end.
* @return {?}
*/
get: function () { return this._opened; },
/**
* @param {?} v
* @return {?}
*/
set: function (v) {
this.toggle(coerceBooleanProperty(v));
},
enumerable: true,
configurable: true
});
/**
* Open the drawer.
* @return {?}
*/
MatDrawer.prototype.open = function () {
return this.toggle(true);
};
/**
* Close the drawer.
* @return {?}
*/
MatDrawer.prototype.close = function () {
return this.toggle(false);
};
/**
* Toggle this drawer.
* @param {?=} isOpen Whether the drawer should be open.
* @return {?}
*/
MatDrawer.prototype.toggle = function (isOpen) {
var _this = this;
if (isOpen === void 0) { isOpen = !this.opened; }
if (!this._isAnimating) {
this._opened = isOpen;
if (isOpen) {
this._animationState = this._enableAnimations ? 'open' : 'open-instant';
}
else {
this._animationState = 'void';
}
this._currentTogglePromise = new Promise(function (resolve) {
first.call(isOpen ? _this.onOpen : _this.onClose).subscribe(resolve);
});
if (this._focusTrap) {
this._focusTrap.enabled = this._isFocusTrapEnabled;
}
}
// TODO(crisbeto): This promise is here for backwards-compatibility.
// It should be removed next time we do breaking changes in the drawer.
return ((this._currentTogglePromise));
};
/**
* Handles the keyboard events.
* \@docs-private
* @param {?} event
* @return {?}
*/
MatDrawer.prototype.handleKeydown = function (event) {
if (event.keyCode === ESCAPE && !this.disableClose) {
this.close();
event.stopPropagation();
}
};
/**
* @param {?} event
* @return {?}
*/
MatDrawer.prototype._onAnimationStart = function (event) {
this._isAnimating = true;
this._animationStarted.emit(event);
};
/**
* @param {?} event
* @return {?}
*/
MatDrawer.prototype._onAnimationEnd = function (event) {
var _this = this;
var fromState = event.fromState, toState = event.toState;
if (toState.indexOf('open') === 0 && fromState === 'void') {
this.onOpen.emit(new MatDrawerToggleResult('open', true));
}
else if (toState === 'void' && fromState.indexOf('open') === 0) {
this.onClose.emit(new MatDrawerToggleResult('close', true));
}
// Note: as of Angular 4.3, the animations module seems to fire the `start` callback before
// the end if animations are disabled. Make this call async to ensure that it still fires
// at the appropriate time.
Promise.resolve().then(function () {
_this._isAnimating = false;
_this._currentTogglePromise = null;
});
};
Object.defineProperty(MatDrawer.prototype, "_width", {
/**
* @return {?}
*/
get: function () {
return this._elementRef.nativeElement ? (this._elementRef.nativeElement.offsetWidth || 0) : 0;
},
enumerable: true,
configurable: true
});
MatDrawer.decorators = [
{ type: Component, args: [{selector: 'mat-drawer',
exportAs: 'matDrawer',
template: '<ng-content></ng-content>',
animations: [
trigger('transform', [
state('open, open-instant', style({
transform: 'translate3d(0, 0, 0)',
visibility: 'visible',
})),
state('void', style({
visibility: 'hidden',
})),
transition('void => open-instant', animate('0ms')),
transition('void <=> open, open-instant => void', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)'))
])
],
host: {
'class': 'mat-drawer',
'[@transform]': '_animationState',
'(@transform.start)': '_onAnimationStart($event)',
'(@transform.done)': '_onAnimationEnd($event)',
'(keydown)': 'handleKeydown($event)',
// must prevent the browser from aligning text based on value
'[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"',
'tabIndex': '-1',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
},] },
];
/**
* @nocollapse
*/
MatDrawer.ctorParameters = function () { return [
{ type: ElementRef, },
{ type: FocusTrapFactory, },
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] },] },
]; };
MatDrawer.propDecorators = {
'position': [{ type: Input },],
'align': [{ type: Input },],
'mode': [{ type: Input },],
'disableClose': [{ type: Input },],
'onOpen': [{ type: Output, args: ['open',] },],
'onClose': [{ type: Output, args: ['close',] },],
'onPositionChanged': [{ type: Output, args: ['positionChanged',] },],
'onAlignChanged': [{ type: Output, args: ['align-changed',] },],
'opened': [{ type: Input },],
};
return MatDrawer;
}());
/**
* <mat-drawer-container> component.
*
* This is the parent component to one or two <mat-drawer>s that validates the state internally
* and coordinates the backdrop and content styling.
*/
var MatDrawerContainer = (function () {
/**
* @param {?} _dir
* @param {?} _element
* @param {?} _renderer
* @param {?} _ngZone
* @param {?} _changeDetectorRef
*/
function MatDrawerContainer(_dir, _element, _renderer, _ngZone, _changeDetectorRef) {
var _this = this;
this._dir = _dir;
this._element = _element;
this._renderer = _renderer;
this._ngZone = _ngZone;
this._changeDetectorRef = _changeDetectorRef;
/**
* Event emitted when the drawer backdrop is clicked.
*/
this.backdropClick = new EventEmitter();
/**
* Emits when the component is destroyed.
*/
this._destroyed = new Subject();
this._contentMargins = new Subject();
// If a `Dir` directive exists up the tree, listen direction changes and update the left/right
// properties to point to the proper start/end.
if (_dir != null) {
takeUntil.call(_dir.change, this._destroyed).subscribe(function () { return _this._validateDrawers(); });
}
}
Object.defineProperty(MatDrawerContainer.prototype, "start", {
/**
* The drawer child with the `start` position.
* @return {?}
*/
get: function () { return this._start; },
enumerable: true,
configurable: true
});
Object.defineProperty(MatDrawerContainer.prototype, "end", {
/**
* The drawer child with the `end` position.
* @return {?}
*/
get: function () { return this._end; },
enumerable: true,
configurable: true
});
/**
* @return {?}
*/
MatDrawerContainer.prototype.ngAfterContentInit = function () {
var _this = this;
startWith.call(this._drawers.changes, null).subscribe(function () {
_this._validateDrawers();
_this._drawers.forEach(function (drawer) {
_this._watchDrawerToggle(drawer);
_this._watchDrawerPosition(drawer);
_this._watchDrawerMode(drawer);
});
if (!_this._drawers.length ||
_this._isDrawerOpen(_this._start) ||
_this._isDrawerOpen(_this._end)) {
_this._updateContentMargins();
}
_this._changeDetectorRef.markForCheck();
});
};
/**
* @return {?}
*/
MatDrawerContainer.prototype.ngOnDestroy = function () {
this._destroyed.next();
this._destroyed.complete();
};
/**
* Calls `open` of both start and end drawers
* @return {?}
*/
MatDrawerContainer.prototype.open = function () {
this._drawers.forEach(function (drawer) { return drawer.open(); });
};
/**
* Calls `close` of both start and end drawers
* @return {?}
*/
MatDrawerContainer.prototype.close = function () {
this._drawers.forEach(function (drawer) { return drawer.close(); });
};
/**
* Subscribes to drawer events in order to set a class on the main container element when the
* drawer is open and the backdrop is visible. This ensures any overflow on the container element
* is properly hidden.
* @param {?} drawer
* @return {?}
*/
MatDrawerContainer.prototype._watchDrawerToggle = function (drawer) {
var _this = this;
RxChain.from(drawer._animationStarted)
.call(takeUntil, this._drawers.changes)
.call(filter, function (event) { return event.fromState !== event.toState; })
.subscribe(function (event) {
// Set the transition class on the container so that the animations occur. This should not
// be set initially because animations should only be triggered via a change in state.
if (event.toState !== 'open-instant') {
_this._renderer.addClass(_this._element.nativeElement, 'mat-drawer-transition');
}
_this._updateContentMargins();
_this._changeDetectorRef.markForCheck();
});
if (drawer.mode !== 'side') {
takeUntil.call(merge(drawer.onOpen, drawer.onClose), this._drawers.changes).subscribe(function () {
return _this._setContainerClass(drawer.opened);
});
}
};
/**
* Subscribes to drawer onPositionChanged event in order to
* re-validate drawers when the position changes.
* @param {?} drawer
* @return {?}
*/
MatDrawerContainer.prototype._watchDrawerPosition = function (drawer) {
var _this = this;
if (!drawer) {
return;
}
// NOTE: We need to wait for the microtask queue to be empty before validating,
// since both drawers may be swapping positions at the same time.
takeUntil.call(drawer.onPositionChanged, this._drawers.changes).subscribe(function () {
first.call(_this._ngZone.onMicrotaskEmpty.asObservable()).subscribe(function () {
_this._validateDrawers();
});
});
};
/**
* Subscribes to changes in drawer mode so we can run change detection.
* @param {?} drawer
* @return {?}
*/
MatDrawerContainer.prototype._watchDrawerMode = function (drawer) {
var _this = this;
if (drawer) {
takeUntil.call(drawer._modeChanged, merge(this._drawers.changes, this._destroyed))
.subscribe(function () {
_this._updateContentMargins();
_this._changeDetectorRef.markForCheck();
});
}
};
/**
* Toggles the 'mat-drawer-opened' class on the main 'mat-drawer-container' element.
* @param {?} isAdd
* @return {?}
*/
MatDrawerContainer.prototype._setContainerClass = function (isAdd) {
if (isAdd) {
this._renderer.addClass(this._element.nativeElement, 'mat-drawer-opened');
}
else {
this._renderer.removeClass(this._element.nativeElement, 'mat-drawer-opened');
}
};
/**
* Validate the state of the drawer children components.
* @return {?}
*/
MatDrawerContainer.prototype._validateDrawers = function () {
var _this = this;
this._start = this._end = null;
// Ensure that we have at most one start and one end drawer.
this._drawers.forEach(function (drawer) {
if (drawer.position == 'end') {
if (_this._end != null) {
throwMatDuplicatedDrawerError('end');
}
_this._end = drawer;
}
else {
if (_this._start != null) {
throwMatDuplicatedDrawerError('start');
}
_this._start = drawer;
}
});
this._right = this._left = null;
// Detect if we're LTR or RTL.
if (this._dir == null || this._dir.value == 'ltr') {
this._left = this._start;
this._right = this._end;
}
else {
this._left = this._end;
this._right = this._start;
}
};
/**
* @return {?}
*/
MatDrawerContainer.prototype._onBackdropClicked = function () {
this.backdropClick.emit();
this._closeModalDrawer();
};
/**
* @return {?}
*/
MatDrawerContainer.prototype._closeModalDrawer = function () {
// Close all open drawers where closing is not disabled and the mode is not `side`.
[this._start, this._end]
.filter(function (drawer) { return drawer && !drawer.disableClose && drawer.mode !== 'side'; })
.forEach(function (drawer) { /** @type {?} */ return ((drawer)).close(); });
};
/**
* @return {?}
*/
MatDrawerContainer.prototype._isShowingBackdrop = function () {
return (this._isDrawerOpen(this._start) && ((this._start)).mode != 'side')
|| (this._isDrawerOpen(this._end) && ((this._end)).mode != 'side');
};
/**
* @param {?} drawer
* @return {?}
*/
MatDrawerContainer.prototype._isDrawerOpen = function (drawer) {
return drawer != null && drawer.opened;
};
/**
* Recalculates and updates the inline styles for the content. Note that this should be used
* sparingly, because it causes a reflow.
* @return {?}
*/
MatDrawerContainer.prototype._updateContentMargins = function () {
// 1. For drawers in `over` mode, they don't affect the content.
// 2. For drawers in `side` mode they should shrink the content. We do this by adding to the
// left margin (for left drawer) or right margin (for right the drawer).
// 3. For drawers in `push` mode the should shift the content without resizing it. We do this by
// adding to the left or right margin and simultaneously subtracting the same amount of
// margin from the other side.
var /** @type {?} */ left = 0;
var /** @type {?} */ right = 0;
if (this._left && this._left.opened) {
if (this._left.mode == 'side') {
left += this._left._width;
}
else if (this._left.mode == 'push') {
var /** @type {?} */ width = this._left._width;
left += width;
right -= width;
}
}
if (this._right && this._right.opened) {
if (this._right.mode == 'side') {
right += this._right._width;
}
else if (this._right.mode == 'push') {
var /** @type {?} */ width = this._right._width;
right += width;
left -= width;
}
}
this._contentMargins.next({ left: left, right: right });
};
MatDrawerContainer.decorators = [
{ type: Component, args: [{selector: 'mat-drawer-container',
exportAs: 'matDrawerContainer',
template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" [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\" cdkScrollable><ng-content></ng-content></mat-drawer-content>",
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-opened{overflow:hidden}.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 screen and (-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;min-width:5vw;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%,0,0)}.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.mat-drawer-opened:not(.mat-drawer-side),.mat-drawer.mat-drawer-opening:not(.mat-drawer-side){box-shadow:0 8px 10px -5px rgba(0,0,0,.2),0 16px 24px 2px rgba(0,0,0,.14),0 6px 30px 5px rgba(0,0,0,.12)}.mat-sidenav-fixed{position:fixed}"],
host: {
'class': 'mat-drawer-container',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
},] },
];
/**
* @nocollapse
*/
MatDrawerContainer.ctorParameters = function () { return [
{ type: Directionality, decorators: [{ type: Optional },] },
{ type: ElementRef, },
{ type: Renderer2, },
{ type: NgZone, },
{ type: ChangeDetectorRef, },
]; };
MatDrawerContainer.propDecorators = {
'_drawers': [{ type: ContentChildren, args: [MatDrawer,] },],
'_content': [{ type: ContentChild, args: [MatDrawerContent,] },],
'backdropClick': [{ type: Output },],
};
return MatDrawerContainer;
}());
var MatSidenavContent = (function (_super) {
__extends(MatSidenavContent, _super);
/**
* @param {?} changeDetectorRef
* @param {?} container
*/
function MatSidenavContent(changeDetectorRef, container) {
return _super.call(this, changeDetectorRef, container) || this;
}
MatSidenavContent.decorators = [
{ type: Component, args: [{selector: 'mat-sidenav-content',
template: '<ng-content></ng-content>',
host: {
'class': 'mat-drawer-content mat-sidenav-content',
'[style.marginLeft.px]': '_margins.left',
'[style.marginRight.px]': '_margins.right',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
},] },
];
/**
* @nocollapse
*/
MatSidenavContent.ctorParameters = function () { return [
{ type: ChangeDetectorRef, },
{ type: MatSidenavContainer, decorators: [{ type: Inject, args: [forwardRef(function () { return MatSidenavContainer; }),] },] },
]; };
return MatSidenavContent;
}(MatDrawerContent));
var MatSidenav = (function (_super) {
__extends(MatSidenav, _super);
function MatSidenav() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._fixedInViewport = false;
_this._fixedTopGap = 0;
_this._fixedBottomGap = 0;
return _this;
}
Object.defineProperty(MatSidenav.prototype, "fixedInViewport", {
/**
* Whether the sidenav is fixed in the viewport.
* @return {?}
*/
get: function () { return this._fixedInViewport; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { this._fixedInViewport = coerceBooleanProperty(value); },
enumerable: true,
configurable: true
});
Object.defineProperty(MatSidenav.prototype, "fixedTopGap", {
/**
* The gap between the top of the sidenav and the top of the viewport when the sidenav is in fixed
* mode.
* @return {?}
*/
get: function () { return this._fixedTopGap; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { this._fixedTopGap = coerceNumberProperty(value); },
enumerable: true,
configurable: true
});
Object.defineProperty(MatSidenav.prototype, "fixedBottomGap", {
/**
* The gap between the bottom of the sidenav and the bottom of the viewport when the sidenav is in
* fixed mode.
* @return {?}
*/
get: function () { return this._fixedBottomGap; },
/**
* @param {?} value
* @return {?}
*/
set: function (value) { this._fixedBottomGap = coerceNumberProperty(value); },
enumerable: true,
configurable: true
});
MatSidenav.decorators = [
{ type: Component, args: [{selector: 'mat-sidenav',
exportAs: 'matSidenav',
template: '<ng-content></ng-content>',
animations: [
trigger('transform', [
state('open, open-instant', style({
transform: 'translate3d(0, 0, 0)',
visibility: 'visible',
})),
state('void', style({
visibility: 'hidden',
})),
transition('void => open-instant', animate('0ms')),
transition('void <=> open, open-instant => void', animate('400ms cubic-bezier(0.25, 0.8, 0.25, 1)'))
])
],
host: {
'class': 'mat-drawer mat-sidenav',
'tabIndex': '-1',
'[@transform]': '_animationState',
'(@transform.start)': '_onAnimationStart($event)',
'(@transform.done)': '_onAnimationEnd($event)',
'(keydown)': 'handleKeydown($event)',
// must prevent the browser from aligning text based on value
'[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-sidenav-fixed]': 'fixedInViewport',
'[style.top.px]': 'fixedInViewport ? fixedTopGap : null',
'[style.bottom.px]': 'fixedInViewport ? fixedBottomGap : null',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
},] },
];
/**
* @nocollapse
*/
MatSidenav.ctorParameters = function () { return []; };
MatSidenav.propDecorators = {
'fixedInViewport': [{ type: Input },],
'fixedTopGap': [{ type: Input },],
'fixedBottomGap': [{ type: Input },],
};
return MatSidenav;
}(MatDrawer));
var MatSidenavContainer = (function (_super) {
__extends(MatSidenavContainer, _super);
function MatSidenavContainer() {
return _super !== null && _super.apply(this, arguments) || this;
}
MatSidenavContainer.decorators = [
{ type: Component, args: [{selector: 'mat-sidenav-container',
exportAs: 'matSidenavContainer',
template: "<div class=\"mat-drawer-backdrop\" (click)=\"_onBackdropClicked()\" [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>",
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-opened{overflow:hidden}.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 screen and (-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;min-width:5vw;outline:0;box-sizing:border-box;overflow-y:auto;transform:translate3d(-100%,0,0)}.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.mat-drawer-opened:not(.mat-drawer-side),.mat-drawer.mat-drawer-opening:not(.mat-drawer-side){box-shadow:0 8px 10px -5px rgba(0,0,0,.2),0 16px 24px 2px rgba(0,0,0,.14),0 6px 30px 5px rgba(0,0,0,.12)}.mat-sidenav-fixed{position:fixed}"],
host: {
'class': 'mat-drawer-container mat-sidenav-container',
},
changeDetection: ChangeDetectionStrategy.OnPush,
encapsulation: ViewEncapsulation.None,
preserveWhitespaces: false,
},] },
];
/**
* @nocollapse
*/
MatSidenavContainer.ctorParameters = function () { return []; };
MatSidenavContainer.propDecorators = {
'_drawers': [{ type: ContentChildren, args: [MatSidenav,] },],
'_content': [{ type: ContentChild, args: [MatSidenavContent,] },],
};
return MatSidenavContainer;
}(MatDrawerContainer));
var MatSidenavModule = (function () {
function MatSidenavModule() {
}
MatSidenavModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
MatCommonModule,
A11yModule,
OverlayModule,
ScrollDispatchModule,
],
exports: [
MatCommonModule,
MatDrawer,
MatDrawerContainer,
MatDrawerContent,
MatSidenav,
MatSidenavContainer,
MatSidenavContent,
],
declarations: [
MatDrawer,
MatDrawerContainer,
MatDrawerContent,
MatSidenav,
MatSidenavContainer,
MatSidenavContent,
],
},] },
];
/**
* @nocollapse
*/
MatSidenavModule.ctorParameters = function () { return []; };
return MatSidenavModule;
}());
/**
* Generated bundle index. Do not edit.
*/
export { MatSidenavModule, throwMatDuplicatedDrawerError, MatDrawerToggleResult, MatDrawerContent, MatDrawer, MatDrawerContainer, MatSidenavContent, MatSidenav, MatSidenavContainer };
//# sourceMappingURL=sidenav.es5.js.map