UNPKG

@angular/material

Version:
10 lines (9 loc) 11.6 kB
/** * @license * Copyright Google LLC 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 */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/cdk/overlay"),require("@angular/cdk/portal"),require("@angular/cdk/a11y"),require("@angular/cdk/layout"),require("@angular/material/core"),require("rxjs/operators/take"),require("rxjs/operators/takeUntil"),require("rxjs/Subject"),require("@angular/animations")):"function"==typeof define&&define.amd?define(["exports","@angular/core","@angular/common","@angular/cdk/overlay","@angular/cdk/portal","@angular/cdk/a11y","@angular/cdk/layout","@angular/material/core","rxjs/operators/take","rxjs/operators/takeUntil","rxjs/Subject","@angular/animations"],e):e((t.ng=t.ng||{},t.ng.material=t.ng.material||{},t.ng.material.snackBar=t.ng.material.snackBar||{}),t.ng.core,t.ng.common,t.ng.cdk.overlay,t.ng.cdk.portal,t.ng.cdk.a11y,t.ng.cdk.layout,t.ng.material.core,t.Rx.operators,t.Rx.operators,t.Rx,t.ng.animations)}(this,function(t,e,n,a,o,i,r,s,c,p,l,u){"use strict";function d(t,e){function n(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function m(t){return f({},new k,t)}var h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])},f=Object.assign||function(t){for(var e,n=1,a=arguments.length;n<a;n++){e=arguments[n];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},_=function(){function t(t,e){var n=this;this._overlayRef=e,this._afterDismissed=new l.Subject,this._afterOpened=new l.Subject,this._onAction=new l.Subject,this._dismissedByAction=!1,this.containerInstance=t,this.onAction().subscribe(function(){return n.dismiss()}),t._onExit.subscribe(function(){return n._finishDismiss()})}return t.prototype.dismiss=function(){this._afterDismissed.closed||this.containerInstance.exit(),clearTimeout(this._durationTimeoutId)},t.prototype.dismissWithAction=function(){this._onAction.closed||(this._dismissedByAction=!0,this._onAction.next(),this._onAction.complete())},t.prototype.closeWithAction=function(){this.dismissWithAction()},t.prototype._dismissAfter=function(t){var e=this;this._durationTimeoutId=setTimeout(function(){return e.dismiss()},t)},t.prototype._open=function(){this._afterOpened.closed||(this._afterOpened.next(),this._afterOpened.complete())},t.prototype._finishDismiss=function(){this._overlayRef.dispose(),this._onAction.closed||this._onAction.complete(),this._afterDismissed.next({dismissedByAction:this._dismissedByAction}),this._afterDismissed.complete(),this._dismissedByAction=!1},t.prototype.afterDismissed=function(){return this._afterDismissed.asObservable()},t.prototype.afterOpened=function(){return this.containerInstance._onEnter},t.prototype.onAction=function(){return this._onAction.asObservable()},t}(),y=new e.InjectionToken("MatSnackBarData"),k=function(){function t(){this.politeness="assertive",this.announcementMessage="",this.duration=0,this.direction="ltr",this.data=null,this.horizontalPosition="center",this.verticalPosition="bottom"}return t}(),b=s.AnimationDurations.ENTERING+" "+s.AnimationCurves.DECELERATION_CURVE,g=s.AnimationDurations.EXITING+" "+s.AnimationCurves.ACCELERATION_CURVE,v={contentFade:u.trigger("contentFade",[u.transition(":enter",[u.style({opacity:"0"}),u.animate(s.AnimationDurations.COMPLEX+" "+s.AnimationCurves.STANDARD_CURVE)])]),snackBarState:u.trigger("state",[u.state("visible-top, visible-bottom",u.style({transform:"translateY(0%)"})),u.transition("visible-top => hidden-top, visible-bottom => hidden-bottom",u.animate(g)),u.transition("void => visible-top, void => visible-bottom",u.animate(b))])},C=function(){function t(t,e){this.snackBarRef=t,this.data=e}return t.prototype.action=function(){this.snackBarRef.dismissWithAction()},Object.defineProperty(t.prototype,"hasAction",{get:function(){return!!this.data.action},enumerable:!0,configurable:!0}),t.decorators=[{type:e.Component,args:[{selector:"simple-snack-bar",template:'{{data.message}} <button class="mat-simple-snackbar-action" *ngIf="hasAction" (click)="action()">{{data.action}}</button>',styles:[".mat-simple-snackbar{display:flex;justify-content:space-between;line-height:20px;opacity:1}.mat-simple-snackbar-action{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;cursor:pointer;outline:0;border:none;-webkit-tap-highlight-color:transparent;background:0 0;flex-shrink:0;margin-left:48px}[dir=rtl] .mat-simple-snackbar-action{margin-right:48px;margin-left:0}"],encapsulation:e.ViewEncapsulation.None,preserveWhitespaces:!1,changeDetection:e.ChangeDetectionStrategy.OnPush,animations:[v.contentFade],host:{"[@contentFade]":"",class:"mat-simple-snackbar"}}]}],t.ctorParameters=function(){return[{type:_},{type:void 0,decorators:[{type:e.Inject,args:[y]}]}]},t}(),A=function(t){function n(e,n,a){var o=t.call(this)||this;return o._ngZone=e,o._elementRef=n,o._changeDetectorRef=a,o._destroyed=!1,o._onExit=new l.Subject,o._onEnter=new l.Subject,o._animationState="void",o}return d(n,t),n.prototype.attachComponentPortal=function(t){if(this._portalOutlet.hasAttached())throw Error("Attempting to attach snack bar content after content is already attached");var e=this._elementRef.nativeElement;return(this.snackBarConfig.panelClass||this.snackBarConfig.extraClasses)&&(this._setCssClasses(this.snackBarConfig.panelClass),this._setCssClasses(this.snackBarConfig.extraClasses)),"center"===this.snackBarConfig.horizontalPosition&&e.classList.add("mat-snack-bar-center"),"top"===this.snackBarConfig.verticalPosition&&e.classList.add("mat-snack-bar-top"),this._portalOutlet.attachComponentPortal(t)},n.prototype.attachTemplatePortal=function(){throw Error("Not yet implemented")},n.prototype.onAnimationEnd=function(t){var e=t.fromState,n=t.toState;if(("void"===n&&"void"!==e||n.startsWith("hidden"))&&this._completeExit(),n.startsWith("visible")){var a=this._onEnter;this._ngZone.run(function(){a.next(),a.complete()})}},n.prototype.enter=function(){this._destroyed||(this._animationState="visible-"+this.snackBarConfig.verticalPosition,this._changeDetectorRef.detectChanges())},n.prototype.exit=function(){return this._animationState="hidden-"+this.snackBarConfig.verticalPosition,this._onExit},n.prototype.ngOnDestroy=function(){this._destroyed=!0,this._completeExit()},n.prototype._completeExit=function(){var t=this;this._ngZone.onMicrotaskEmpty.asObservable().pipe(c.take(1)).subscribe(function(){t._onExit.next(),t._onExit.complete()})},n.prototype._setCssClasses=function(t){if(t){var e=this._elementRef.nativeElement;Array.isArray(t)?t.forEach(function(t){return e.classList.add(t)}):e.classList.add(t)}},n.decorators=[{type:e.Component,args:[{selector:"snack-bar-container",template:"<ng-template cdkPortalOutlet></ng-template>",styles:[".mat-snack-bar-container{border-radius:2px;box-sizing:border-box;display:block;margin:24px;max-width:568px;min-width:288px;padding:14px 24px;transform:translateY(100%) translateY(24px)}.mat-snack-bar-container.mat-snack-bar-center{margin:0;transform:translateY(100%)}.mat-snack-bar-container.mat-snack-bar-top{transform:translateY(-100%) translateY(-24px)}.mat-snack-bar-container.mat-snack-bar-top.mat-snack-bar-center{transform:translateY(-100%)}@media screen and (-ms-high-contrast:active){.mat-snack-bar-container{border:solid 1px}}.mat-snack-bar-handset{width:100%}.mat-snack-bar-handset .mat-snack-bar-container{margin:0;max-width:inherit;width:100%}"],changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,preserveWhitespaces:!1,animations:[v.snackBarState],host:{role:"alert",class:"mat-snack-bar-container","[@state]":"_animationState","(@state.done)":"onAnimationEnd($event)"}}]}],n.ctorParameters=function(){return[{type:e.NgZone},{type:e.ElementRef},{type:e.ChangeDetectorRef}]},n.propDecorators={_portalOutlet:[{type:e.ViewChild,args:[o.CdkPortalOutlet]}]},n}(o.BasePortalOutlet),B=function(){function t(t,e,n,a,o){this._overlay=t,this._live=e,this._injector=n,this._breakpointObserver=a,this._parentSnackBar=o,this._snackBarRefAtThisLevel=null}return Object.defineProperty(t.prototype,"_openedSnackBarRef",{get:function(){var t=this._parentSnackBar;return t?t._openedSnackBarRef:this._snackBarRefAtThisLevel},set:function(t){this._parentSnackBar?this._parentSnackBar._openedSnackBarRef=t:this._snackBarRefAtThisLevel=t},enumerable:!0,configurable:!0}),t.prototype.openFromComponent=function(t,e){var n=this,a=m(e),o=this._attach(t,a);return o.afterDismissed().subscribe(function(){n._openedSnackBarRef==o&&(n._openedSnackBarRef=null)}),this._openedSnackBarRef?(this._openedSnackBarRef.afterDismissed().subscribe(function(){o.containerInstance.enter()}),this._openedSnackBarRef.dismiss()):o.containerInstance.enter(),a.duration&&a.duration>0&&o.afterOpened().subscribe(function(){return o._dismissAfter(a.duration)}),a.announcementMessage&&this._live.announce(a.announcementMessage,a.politeness),this._openedSnackBarRef=o,this._openedSnackBarRef},t.prototype.open=function(t,e,n){void 0===e&&(e="");var a=m(n);return a.data={message:t,action:e},a.announcementMessage=t,this.openFromComponent(C,a)},t.prototype.dismiss=function(){this._openedSnackBarRef&&this._openedSnackBarRef.dismiss()},t.prototype._attachSnackBarContainer=function(t,e){var n=new o.ComponentPortal(A,e.viewContainerRef),a=t.attach(n);return a.instance.snackBarConfig=e,a.instance},t.prototype._attach=function(t,e){var n=this._createOverlay(e),a=this._attachSnackBarContainer(n,e),i=new _(a,n),s=this._createInjector(e,i),l=new o.ComponentPortal(t,void 0,s),u=a.attachComponentPortal(l);return i.instance=u.instance,this._breakpointObserver.observe(r.Breakpoints.Handset).pipe(p.takeUntil(n.detachments().pipe(c.take(1)))).subscribe(function(t){t.matches?n.overlayElement.classList.add("mat-snack-bar-handset"):n.overlayElement.classList.remove("mat-snack-bar-handset")}),i},t.prototype._createOverlay=function(t){var e=new a.OverlayConfig;e.direction=t.direction;var n=this._overlay.position().global(),o="rtl"===t.direction,i="left"===t.horizontalPosition||"start"===t.horizontalPosition&&!o||"end"===t.horizontalPosition&&o,r=!i&&"center"!==t.horizontalPosition;return i?n.left("0"):r?n.right("0"):n.centerHorizontally(),"top"===t.verticalPosition?n.top("0"):n.bottom("0"),e.positionStrategy=n,this._overlay.create(e)},t.prototype._createInjector=function(t,e){var n=t&&t.viewContainerRef&&t.viewContainerRef.injector,a=new WeakMap;return a.set(_,e),a.set(y,t.data),new o.PortalInjector(n||this._injector,a)},t.decorators=[{type:e.Injectable}],t.ctorParameters=function(){return[{type:a.Overlay},{type:i.LiveAnnouncer},{type:e.Injector},{type:r.BreakpointObserver},{type:t,decorators:[{type:e.Optional},{type:e.SkipSelf}]}]},t}(),S=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[a.OverlayModule,o.PortalModule,n.CommonModule,s.MatCommonModule,r.LayoutModule],exports:[A,s.MatCommonModule],declarations:[A,C],entryComponents:[A,C],providers:[B,i.LIVE_ANNOUNCER_PROVIDER]}]}],t.ctorParameters=function(){return[]},t}();t.MatSnackBarModule=S,t.MatSnackBar=B,t.MatSnackBarContainer=A,t.MAT_SNACK_BAR_DATA=y,t.MatSnackBarConfig=k,t.MatSnackBarRef=_,t.SimpleSnackBar=C,t.SHOW_ANIMATION=b,t.HIDE_ANIMATION=g,t.matSnackBarAnimations=v,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=material-snack-bar.umd.min.js.map