1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { ChangeDetectionStrategy, Component, Inject, ViewEncapsulation } from '@angular/core';
|
---|
9 | import { MAT_SNACK_BAR_DATA } from './snack-bar-config';
|
---|
10 | import { MatSnackBarRef } from './snack-bar-ref';
|
---|
11 | /**
|
---|
12 | * A component used to open as the default snack bar, matching material spec.
|
---|
13 | * This should only be used internally by the snack bar service.
|
---|
14 | */
|
---|
15 | export class SimpleSnackBar {
|
---|
16 | constructor(snackBarRef, data) {
|
---|
17 | this.snackBarRef = snackBarRef;
|
---|
18 | this.data = data;
|
---|
19 | }
|
---|
20 | /** Performs the action on the snack bar. */
|
---|
21 | action() {
|
---|
22 | this.snackBarRef.dismissWithAction();
|
---|
23 | }
|
---|
24 | /** If the action button should be shown. */
|
---|
25 | get hasAction() {
|
---|
26 | return !!this.data.action;
|
---|
27 | }
|
---|
28 | }
|
---|
29 | SimpleSnackBar.decorators = [
|
---|
30 | { type: Component, args: [{
|
---|
31 | selector: 'simple-snack-bar',
|
---|
32 | template: "<span>{{data.message}}</span>\n<div class=\"mat-simple-snackbar-action\" *ngIf=\"hasAction\">\n <button mat-button (click)=\"action()\">{{data.action}}</button>\n</div>\n",
|
---|
33 | encapsulation: ViewEncapsulation.None,
|
---|
34 | changeDetection: ChangeDetectionStrategy.OnPush,
|
---|
35 | host: {
|
---|
36 | 'class': 'mat-simple-snackbar',
|
---|
37 | },
|
---|
38 | styles: [".mat-simple-snackbar{display:flex;justify-content:space-between;align-items:center;line-height:20px;opacity:1}.mat-simple-snackbar-action{flex-shrink:0;margin:-8px -8px -8px 8px}.mat-simple-snackbar-action button{max-height:36px;min-width:0}[dir=rtl] .mat-simple-snackbar-action{margin-left:-8px;margin-right:8px}\n"]
|
---|
39 | },] }
|
---|
40 | ];
|
---|
41 | SimpleSnackBar.ctorParameters = () => [
|
---|
42 | { type: MatSnackBarRef },
|
---|
43 | { type: undefined, decorators: [{ type: Inject, args: [MAT_SNACK_BAR_DATA,] }] }
|
---|
44 | ];
|
---|
45 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2ltcGxlLXNuYWNrLWJhci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9zbmFjay1iYXIvc2ltcGxlLXNuYWNrLWJhci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7QUFFSCxPQUFPLEVBQUMsdUJBQXVCLEVBQUUsU0FBUyxFQUFFLE1BQU0sRUFBRSxpQkFBaUIsRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUM1RixPQUFPLEVBQUMsa0JBQWtCLEVBQUMsTUFBTSxvQkFBb0IsQ0FBQztBQUN0RCxPQUFPLEVBQUMsY0FBYyxFQUFDLE1BQU0saUJBQWlCLENBQUM7QUFhL0M7OztHQUdHO0FBV0gsTUFBTSxPQUFPLGNBQWM7SUFJekIsWUFDUyxXQUEyQyxFQUN0QixJQUFTO1FBRDlCLGdCQUFXLEdBQVgsV0FBVyxDQUFnQztRQUVsRCxJQUFJLENBQUMsSUFBSSxHQUFHLElBQUksQ0FBQztJQUNuQixDQUFDO0lBRUQsNENBQTRDO0lBQzVDLE1BQU07UUFDSixJQUFJLENBQUMsV0FBVyxDQUFDLGlCQUFpQixFQUFFLENBQUM7SUFDdkMsQ0FBQztJQUVELDRDQUE0QztJQUM1QyxJQUFJLFNBQVM7UUFDWCxPQUFPLENBQUMsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLE1BQU0sQ0FBQztJQUM1QixDQUFDOzs7WUE1QkYsU0FBUyxTQUFDO2dCQUNULFFBQVEsRUFBRSxrQkFBa0I7Z0JBQzVCLH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