blob: b15eb344e9212b5548b304b4ba839e0e60ef4eda [file] [log] [blame]
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/cdk/portal"),require("@angular/material/core"),require("@angular/material/dialog"),require("@angular/cdk/overlay"),require("@angular/cdk/a11y"),require("@angular/common"),require("@angular/animations"),require("rxjs"),require("rxjs/operators"),require("@angular/cdk/bidi")):"function"==typeof define&&define.amd?define("@covalent/core/side-sheet",["exports","@angular/core","@angular/cdk/portal","@angular/material/core","@angular/material/dialog","@angular/cdk/overlay","@angular/cdk/a11y","@angular/common","@angular/animations","rxjs","rxjs/operators","@angular/cdk/bidi"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).covalent=e.covalent||{},e.covalent.core=e.covalent.core||{},e.covalent.core["side-sheet"]={}),e.ng.core,e.ng.cdk.portal,e.ng.material.core,e.ng.material.dialog,e.ng.cdk.overlay,e.ng.cdk.a11y,e.ng.common,e.ng.animations,e.rxjs,e.rxjs.operators,e.ng.cdk.bidi)}(this,(function(e,t,n,i,o,a,r,s,l,c,d,p){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */var u=function(e,t){return(u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function h(e,t){function n(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}Object.create;function f(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var i,o,a=n.call(e),r=[];try{for(;(void 0===t||t-- >0)&&!(i=a.next()).done;)r.push(i.value)}catch(e){o={error:e}}finally{try{i&&!i.done&&(n=a.return)&&n.call(a)}finally{if(o)throw o.error}}return r}function y(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}Object.create;var m={sideSheetContainer:l.trigger("sideSheetContainer",[l.state("void, exit",l.style({transform:"translateX(100%)"})),l.state("enter",l.style({transform:"translateX(0%)",opacity:1})),l.transition("* => enter",l.animate(i.AnimationDurations.ENTERING+" "+i.AnimationCurves.ACCELERATION_CURVE,l.style({transform:"translateX(0)",opacity:1}))),l.transition("* => void, * => exit",l.animate(i.AnimationDurations.EXITING+" "+i.AnimationCurves.ACCELERATION_CURVE,l.style({transform:"translateX(100%)"})))])},_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return h(t,e),t}(o.MatDialogConfig);function v(){for(var e="undefined"!=typeof document&&document?document.activeElement:null;e&&e.shadowRoot;){var t=e.shadowRoot.activeElement;if(t===e)break;e=t}return e}var S=function(e){function n(n,i,o,a,r,s){var l=e.call(this)||this;return l._elementRef=n,l._focusTrapFactory=i,l._changeDetectorRef=o,l._config=r,l._focusMonitor=s,l._animationStateChanged=new t.EventEmitter,l._elementFocusedBeforeSideSheetWasOpened=null,l._closeInteractionType=null,l.attachDomPortal=function(e){return l._portalOutlet.attachDomPortal(e)},l._ariaLabelledBy=r.ariaLabelledBy||null,l._document=a,l}return h(n,e),n.prototype._initializeWithAttachedContent=function(){this._setupFocusTrap(),this._capturePreviouslyFocusedElement()},n.prototype.attachComponentPortal=function(e){return this._portalOutlet.attachComponentPortal(e)},n.prototype.attachTemplatePortal=function(e){return this._portalOutlet.attachTemplatePortal(e)},n.prototype._recaptureFocus=function(){this._containsFocus()||this._trapFocus()},n.prototype._trapFocus=function(){var e=this,t=this._elementRef.nativeElement;this._config.autoFocus?this._focusTrap.focusInitialElementWhenReady().then((function(t){t||e._focusSideSheetContainer()})):this._containsFocus()||t.focus()},n.prototype._restoreFocus=function(){var e=this._elementFocusedBeforeSideSheetWasOpened;if(this._config.restoreFocus&&e&&"function"==typeof e.focus){var t=v(),n=this._elementRef.nativeElement;t&&t!==this._document.body&&t!==n&&!n.contains(t)||(this._focusMonitor?(this._focusMonitor.focusVia(e,this._closeInteractionType),this._closeInteractionType=null):e.focus())}this._focusTrap&&this._focusTrap.destroy()},n.prototype._setupFocusTrap=function(){this._focusTrap=this._focusTrapFactory.create(this._elementRef.nativeElement)},n.prototype._capturePreviouslyFocusedElement=function(){this._document&&(this._elementFocusedBeforeSideSheetWasOpened=v())},n.prototype._focusSideSheetContainer=function(){this._elementRef.nativeElement.focus&&this._elementRef.nativeElement.focus()},n.prototype._containsFocus=function(){var e=this._elementRef.nativeElement,t=v();return e===t||e.contains(t)},n}(n.BasePortalOutlet);S.decorators=[{type:t.Directive}],S.ctorParameters=function(){return[{type:t.ElementRef},{type:r.FocusTrapFactory},{type:t.ChangeDetectorRef},{type:void 0,decorators:[{type:t.Optional},{type:t.Inject,args:[s.DOCUMENT]}]},{type:_},{type:r.FocusMonitor}]},S.propDecorators={_portalOutlet:[{type:t.ViewChild,args:[n.CdkPortalOutlet,{static:!0}]}]};var g=function(e){function t(){var t=e.apply(this,y(arguments))||this;return t._state="enter",t}return h(t,e),t.prototype._onAnimationDone=function(e){var t=e.toState,n=e.totalTime;"enter"===t?(this._trapFocus(),this._animationStateChanged.next({state:"opened",totalTime:n})):"exit"===t&&(this._restoreFocus(),this._animationStateChanged.next({state:"closed",totalTime:n}))},t.prototype._onAnimationStart=function(e){var t=e.toState,n=e.totalTime;"enter"===t?this._animationStateChanged.next({state:"opening",totalTime:n}):"exit"!==t&&"void"!==t||this._animationStateChanged.next({state:"closing",totalTime:n})},t.prototype._startExitAnimation=function(){this._state="exit",this._changeDetectorRef.markForCheck()},t}(S);g.decorators=[{type:t.Component,args:[{selector:"td-side-sheet-container",template:"\n <ng-template cdkPortalOutlet></ng-template>\n ",encapsulation:t.ViewEncapsulation.None,changeDetection:t.ChangeDetectionStrategy.Default,animations:[m.sideSheetContainer],host:{class:"td-side-sheet-container",tabindex:"-1","aria-modal":"true","[id]":"_id","[attr.role]":"_config.role","[attr.aria-labelledby]":"_config.ariaLabel ? null : _ariaLabelledBy","[attr.aria-label]":"_config.ariaLabel","[attr.aria-describedby]":"_config.ariaDescribedBy || null","[@sideSheetContainer]":"_state","(@sideSheetContainer.start)":"_onAnimationStart($event)","(@sideSheetContainer.done)":"_onAnimationDone($event)"},styles:[".td-side-sheet-container{background-color:#fff;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);box-sizing:border-box;display:block;height:100%;max-height:inherit;min-height:inherit;outline:0;overflow:auto;padding:24px;width:100%}.td-side-sheet-wrapper{-ms-flex-direction:column;display:-ms-flexbox;display:flex;flex-direction:column;height:100%}.td-side-sheet-content{-ms-flex:1;-webkit-overflow-scrolling:touch;flex:1;margin:0 -24px;overflow:auto;padding:0 24px}.td-side-sheet-title{margin:-16px 0 20px}.td-side-sheet-actions,.td-side-sheet-title{-ms-flex-align:center;align-items:center;display:-ms-flexbox;display:flex}.td-side-sheet-actions{-ms-flex-pack:justify;-ms-flex-wrap:wrap;box-sizing:content-box;flex-wrap:wrap;justify-content:space-between;margin:0 -16px -24px;padding:8px 0}.td-side-sheet-actions[align=end]{-ms-flex-pack:end;justify-content:flex-end}.td-side-sheet-actions[align=center]{-ms-flex-pack:center;justify-content:center}.td-side-sheet-actions .mat-button-base+.mat-button-base,.td-side-sheet-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:8px}[dir=rtl] .td-side-sheet-actions .mat-button-base+.mat-button-base,[dir=rtl] .td-side-sheet-actions .mat-mdc-button-base+.mat-mdc-button-base{margin-left:0;margin-right:8px}"]}]}];var C=0,b=function(e){function t(t,n,i){void 0===i&&(i="td-side-sheet-"+C++);var o=e.call(this,t,n,i)||this;return o.overlayRef=t,o._containerInstance=n,o.id=i,o}return h(t,e),t}(o.MatDialogRef);function x(e,t,n){return void 0!==e._containerInstance&&(e._containerInstance._closeInteractionType=t),e.close(n)}var R=function(){function e(e,t,n,i,o,a,r){this._overlay=e,this._injector=t,this._defaultOptions=n,this._parentSideSheet=i,this._sideSheetRefConstructor=o,this._sideSheetContainerType=a,this._sideSheetDataToken=r,this._openSideSheetsAtThisLevel=[],this._afterAllClosedAtThisLevel=new c.Subject,this._afterOpenedAtThisLevel=new c.Subject,this.defaultSidebarConfig={minWidth:"400px",maxWidth:"100vw"}}return Object.defineProperty(e.prototype,"openSideSheets",{get:function(){return this._parentSideSheet?this._parentSideSheet.openSideSheets:this._openSideSheetsAtThisLevel},enumerable:!1,configurable:!0}),e.prototype.open=function(e,t){var n=this;t=Object.assign(Object.assign(Object.assign({},this._defaultOptions||new _),this.defaultSidebarConfig),t);var o=this._createOverlay(t),a=this._attachSideSheetContainer(o,t),r=this._attachSideSheetContent(e,a,o,t),s=this.openSideSheets.slice(-1)[0],l=null==s?void 0:s.overlayRef;return(null==l?void 0:l.overlayElement)&&(l.overlayElement.style.transition=i.AnimationDurations.COMPLEX+" "+i.AnimationCurves.DECELERATION_CURVE,l.overlayElement.style.minWidth=window.innerWidth+"px"),r._containerInstance._animationStateChanged.pipe(d.filter((function(e){return"closing"===e.state&&!(!s||!l)})),d.take(1)).subscribe((function(){l.overlayElement.style.transition=i.AnimationDurations.EXITING+" "+i.AnimationCurves.DECELERATION_CURVE,s.updateSize()})),this.openSideSheets.push(r),r.afterClosed().pipe(d.take(1)).subscribe((function(){return n._removeOpenSideSheet(r)})),a._initializeWithAttachedContent(),r},e.prototype.ngOnDestroy=function(){this._closeSideSheets(this._openSideSheetsAtThisLevel),this._afterAllClosedAtThisLevel.complete(),this._afterOpenedAtThisLevel.complete(),this._animationStateSubscriptions&&this._animationStateSubscriptions.unsubscribe()},e.prototype.closeAll=function(){this._closeSideSheets(this.openSideSheets)},e.prototype._createOverlay=function(e){var t=new a.OverlayConfig({positionStrategy:this._overlay.position().global(),scrollStrategy:this._overlay.scrollStrategies.block(),panelClass:e.panelClass,hasBackdrop:e.hasBackdrop,direction:e.direction,minWidth:e.minWidth,minHeight:e.minHeight,maxWidth:e.maxWidth}),n=this._overlay.create(t);return n.getConfig().positionStrategy.right("0px"),n},e.prototype._attachSideSheetContainer=function(e,i){var o=i&&i.viewContainerRef&&i.viewContainerRef.injector,a=t.Injector.create({parent:o||this._injector,providers:[{provide:_,useValue:i}]}),r=new n.ComponentPortal(this._sideSheetContainerType,i.viewContainerRef,a,i.componentFactoryResolver);return e.attach(r).instance},e.prototype._attachSideSheetContent=function(e,i,o,a){var r=new this._sideSheetRefConstructor(o,i,a.id);if(e instanceof t.TemplateRef)i.attachTemplatePortal(new n.TemplatePortal(e,null,{$implicit:a.data,sideSheetRef:r}));else{var s=this._createInjector(a,r,i),l=i.attach(new n.ComponentPortal(e,a.viewContainerRef,s));r.componentInstance=l.instance}return r.updateSize(a.width,a.height),r},e.prototype._createInjector=function(e,n,i){var o=e&&e.viewContainerRef&&e.viewContainerRef.injector,a=[{provide:this._sideSheetContainerType,useValue:i},{provide:this._sideSheetDataToken,useValue:e.data},{provide:this._sideSheetRefConstructor,useValue:n}];return!e.direction||o&&o.get(p.Directionality,null,t.InjectFlags.Optional)||a.push({provide:p.Directionality,useValue:{value:e.direction,change:c.of()}}),t.Injector.create({parent:o||this._injector,providers:a})},e.prototype._removeOpenSideSheet=function(e){var t=this.openSideSheets.indexOf(e);t>-1&&this.openSideSheets.splice(t,1)},e.prototype._closeSideSheets=function(e){for(var t=e.length;t--;)e[t].close()},e}();R.decorators=[{type:t.Directive}],R.ctorParameters=function(){return[{type:a.Overlay},{type:t.Injector},{type:void 0},{type:void 0},{type:t.Type},{type:t.Type},{type:t.InjectionToken}]};var T=function(e){function t(t,n,i,a){return e.call(this,t,n,i,a,b,g,o.MAT_DIALOG_DATA)||this}return h(t,e),t}(R);T.decorators=[{type:t.Injectable}],T.ctorParameters=function(){return[{type:a.Overlay},{type:t.Injector},{type:_,decorators:[{type:t.Optional},{type:t.Inject,args:[o.MAT_DIALOG_DEFAULT_OPTIONS]}]},{type:T,decorators:[{type:t.Optional},{type:t.SkipSelf}]}]};var O=0,E=function(){function e(e,t,n){this.dialogRef=e,this._elementRef=t,this._dialog=n,this.type="button"}return e.prototype.ngOnInit=function(){this.dialogRef||(this.dialogRef=j(this._elementRef,this._dialog.openSideSheets))},e.prototype.ngOnChanges=function(e){var t=e._CovalentSideSheetClose||e._CovalentSideSheetCloseResult;t&&(this.dialogResult=t.currentValue)},e.prototype._onButtonClick=function(e){x(this.dialogRef,0===e.screenX&&0===e.screenY?"keyboard":"mouse",this.dialogResult)},e}();E.decorators=[{type:t.Directive,args:[{selector:"[td-side-sheet-close], [CovalentSideSheetClose]",exportAs:"CovalentSideSheetClose",host:{"(click)":"_onButtonClick($event)","[attr.aria-label]":"ariaLabel || null","[attr.type]":"type"}}]}],E.ctorParameters=function(){return[{type:b,decorators:[{type:t.Optional}]},{type:t.ElementRef},{type:T}]},E.propDecorators={ariaLabel:[{type:t.Input,args:["aria-label"]}],type:[{type:t.Input}],dialogResult:[{type:t.Input,args:["td-side-sheet-close"]}],_CovalentSideSheetClose:[{type:t.Input,args:["CovalentSideSheetClose"]}]};var A=function(){function e(e,t,n){this._dialogRef=e,this._elementRef=t,this._dialog=n,this.id="td-side-sheet-title-"+O++}return e.prototype.ngOnInit=function(){var e=this;this._dialogRef?Promise.resolve().then((function(){var t=e._dialogRef._containerInstance;t&&!t._ariaLabelledBy&&(t._ariaLabelledBy=e.id)})):this._dialogRef=j(this._elementRef,this._dialog.openSideSheets)},e}();A.decorators=[{type:t.Directive,args:[{selector:"[td-side-sheet-title], [CovalentSideSheetTitle]",exportAs:"CovalentSideSheetTitle",host:{class:"td-side-sheet-title","[id]":"id"}}]}],A.ctorParameters=function(){return[{type:b,decorators:[{type:t.Optional}]},{type:t.ElementRef},{type:T}]},A.propDecorators={id:[{type:t.Input}]};var w=function(){};w.decorators=[{type:t.Directive,args:[{selector:"[td-side-sheet-content], td-side-sheet-content, [CovalentSideSheetContent]",host:{class:"td-side-sheet-content"}}]}];var I=function(){};I.decorators=[{type:t.Directive,args:[{selector:"[td-side-sheet-actions], td-side-sheet-actions, [CovalentSideSheetActions]",host:{class:"td-side-sheet-actions"}}]}];var D=function(){};function j(e,t){for(var n=e.nativeElement.parentElement;n&&!n.classList.contains("td-side-sheet-container");)n=n.parentElement;return n?t.find((function(e){return e.id===n.id})):null}D.decorators=[{type:t.Directive,args:[{selector:"[td-side-sheet-wrapper], td-side-sheet-wrapper, [CovalentSideSheetWrapper]",host:{class:"td-side-sheet-wrapper"}}]}];var k=function(){};k.decorators=[{type:t.NgModule,args:[{declarations:[g,I,E,w,A,D],exports:[I,E,w,A,D],imports:[n.PortalModule,o.MatDialogModule,i.MatCommonModule],providers:[T]}]}],e.CovalentSideSheet=T,e.CovalentSideSheetActions=I,e.CovalentSideSheetClose=E,e.CovalentSideSheetConfig=_,e.CovalentSideSheetContent=w,e.CovalentSideSheetModule=k,e.CovalentSideSheetRef=b,e.CovalentSideSheetTitle=A,e.CovalentSideSheetWrapper=D,e._CovalentSideSheetBase=R,e._closeSideSheetVia=x,ea=S,eb=g,ec=m,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=covalent-core-side-sheet.umd.min.js.map