nereo-material
Version:
This project contains [Material Design](https://material.io/design/) components built with Angular and Angular Material. Its goal is to provide components that are not yet implemented in [Angular Material](https://material.angular.io/).
497 lines (477 loc) • 25.6 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { EventEmitter, Input, Output, Component, NgModule } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatTooltipModule } from '@angular/material/tooltip';
import { MatMenuModule } from '@angular/material/menu';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { MatCardModule } from '@angular/material/card';
import { MatListModule } from '@angular/material/list';
import { trigger, state, style, transition, animate, query, stagger, keyframes } from '@angular/animations';
var ContextualToolbarDisplayMode;
(function (ContextualToolbarDisplayMode) {
ContextualToolbarDisplayMode["icons"] = "icons";
ContextualToolbarDisplayMode["text"] = "text";
ContextualToolbarDisplayMode["all"] = "all";
})(ContextualToolbarDisplayMode || (ContextualToolbarDisplayMode = {}));
var ContextualToolbarComponent = /** @class */ (function () {
function ContextualToolbarComponent() {
this.displayMode = ContextualToolbarDisplayMode.icons;
this.selectedAction = new EventEmitter();
this.clearSelection = new EventEmitter();
this.classesToApply = {};
this.progressMessage = new BehaviorSubject(null);
}
ContextualToolbarComponent.prototype.ngOnInit = function () {
this.setContextualization();
};
ContextualToolbarComponent.prototype.showButtonIcon = function () {
console.log("Display Mode", this.displayMode);
return this.displayMode != ContextualToolbarDisplayMode.text;
};
ContextualToolbarComponent.prototype.showButtonText = function () {
return this.displayMode != ContextualToolbarDisplayMode.icons;
};
ContextualToolbarComponent.prototype.setContextualization = function () {
this.classesToApply = {
'page-contextual-toolbar': this.contextualizeTo != 'card',
'card-contextual-toolbar': this.contextualizeTo == 'card'
};
};
ContextualToolbarComponent.prototype.setProgress = function (progressMessage) {
this.progressMessage.next(progressMessage);
};
ContextualToolbarComponent.prototype.stopProgress = function () {
this.progressMessage.next(null);
};
ContextualToolbarComponent.prototype.actionSelected = function (action) {
this.selectedAction.emit(action);
};
ContextualToolbarComponent.prototype.clear = function () {
this.clearSelection.emit();
};
__decorate([
Input(),
__metadata("design:type", Number)
], ContextualToolbarComponent.prototype, "count", void 0);
__decorate([
Input(),
__metadata("design:type", Array)
], ContextualToolbarComponent.prototype, "actions", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ContextualToolbarComponent.prototype, "displayMode", void 0);
__decorate([
Input(),
__metadata("design:type", Array)
], ContextualToolbarComponent.prototype, "moreActions", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], ContextualToolbarComponent.prototype, "contextualizeTo", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], ContextualToolbarComponent.prototype, "selectedAction", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], ContextualToolbarComponent.prototype, "clearSelection", void 0);
ContextualToolbarComponent = __decorate([
Component({
selector: 'nm-contextual-toolbar',
template: "<mat-toolbar *ngIf=\"count > 0\" [ngClass]=\"classesToApply\">\n <ng-container *ngIf=\"progressMessage | async; then progressMode; else defaultMode\">\n </ng-container>\n <ng-template #defaultMode>\n <button mat-icon-button (click)=\"clear()\">\n <mat-icon>clear</mat-icon>\n </button>\n <span i18n=\"@@contextualSelectedItems\">{{count}} selected</span>\n\n <span class=\"spacer\"></span>\n \n <button mat-icon-button \n *ngFor=\"let action of actions\" \n (click)=\"actionSelected(action)\"\n [class.textButton]=\"showButtonText()\">\n <mat-icon [matTooltip]=\"action.tooltip ? action.tooltip : action.name\"\n *ngIf=\"showButtonIcon()\">{{action.icon}}</mat-icon>\n <span *ngIf=\"showButtonText()\">{{action.text}}</span>\n </button>\n \n <button mat-icon-button *ngIf=\"moreActions\" [matMenuTriggerFor]=\"menu\">\n <mat-icon matTooltip=\"more\" i18n-matTooltip=\"@@moreActions\">more_vert</mat-icon>\n </button>\n <mat-menu #menu=\"matMenu\" yPosition=\"below\">\n <button mat-menu-item \n *ngFor=\"let moreAction of moreActions\" \n (click)=\"actionSelected(moreAction.name)\">{{moreAction.tooltip ? moreAction.tooltip: moreAction.name}}</button>\n </mat-menu>\n </ng-template>\n <ng-template #progressMode>\n <mat-spinner [diameter]='24'></mat-spinner>\n {{ progressMessage | async }}\n <span class=\"spacer\"></span>\n </ng-template>\n</mat-toolbar>",
styles: [":host mat-toolbar{background-color:var(--primary-lighter,#f5f5f5)!important;color:var(--primary,#000);left:0;top:0;width:100%;z-index:999}:host mat-toolbar>div{align-items:center;display:flex;width:100%}:host .page-contextual-toolbar{position:fixed}:host .textButton{margin-right:16px;text-transform:uppercase;width:auto}:host .textButton ::ng-deep .mat-button-wrapper{align-items:center;display:flex;gap:4px}:host mat-spinner{margin-left:8px;margin-right:8px}:host .card-contextual-toolbar{position:absolute}:host .spacer{flex:1 1 auto}"]
}),
__metadata("design:paramtypes", [])
], ContextualToolbarComponent);
return ContextualToolbarComponent;
}());
var ContextualToolbarModule = /** @class */ (function () {
function ContextualToolbarModule() {
}
ContextualToolbarModule = __decorate([
NgModule({
imports: [
CommonModule,
MatToolbarModule,
MatButtonModule,
MatIconModule,
MatTooltipModule,
MatMenuModule,
MatProgressSpinnerModule
],
declarations: [ContextualToolbarComponent],
exports: [ContextualToolbarComponent]
})
], ContextualToolbarModule);
return ContextualToolbarModule;
}());
var BannerComponent = /** @class */ (function () {
function BannerComponent() {
this.mainActionClick = new EventEmitter();
this.secondaryActionClick = new EventEmitter();
}
BannerComponent.prototype.ngOnInit = function () {
};
BannerComponent.prototype.mainActionClicked = function () {
this.mainActionClick.emit();
};
BannerComponent.prototype.secondaryActionClicked = function () {
this.secondaryActionClick.emit();
};
__decorate([
Input(),
__metadata("design:type", Boolean)
], BannerComponent.prototype, "show", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], BannerComponent.prototype, "icon", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], BannerComponent.prototype, "firstSentence", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], BannerComponent.prototype, "secondSentence", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], BannerComponent.prototype, "mainActionText", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], BannerComponent.prototype, "secondaryActionText", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], BannerComponent.prototype, "mainActionClick", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], BannerComponent.prototype, "secondaryActionClick", void 0);
BannerComponent = __decorate([
Component({
selector: 'nm-banner',
template: "\n <mat-card *ngIf=\"show\">\n <mat-card-content>\n <mat-list>\n <mat-list-item>\n <mat-icon matListIcon color=\"primary\" *ngIf=\"icon\">{{icon}}</mat-icon>\n <div id=\"banner-text-container\">\n <p matLine>{{firstSentence}}</p>\n <p matLine *ngIf=\"secondSentence\">{{secondSentence}}</p>\n </div>\n </mat-list-item> \n </mat-list>\n <div id=\"banner-actions\">\n <button mat-button color=\"primary\" (click)=\"secondaryActionClicked()\" *ngIf=\"secondaryActionText\">{{secondaryActionText}}</button> \n <button mat-button color=\"primary\" (click)=\"mainActionClicked()\">{{mainActionText}}</button>\n </div>\n </mat-card-content>\n </mat-card>\n ",
styles: ["\n mat-card {\n height: 52px;\n padding: 0;\n }\n \n mat-card-content{\n align-items: center;\n display: flex;\n justify-content: space-between;\n margin: 0 auto;\n max-width: 90%;\n flex-wrap: wrap;\n }\n \n #banner-text-container {\n margin-left: 24px;\n }\n\n #banner-text-container p{\n font-size: 14px;\n margin: 3px 0;\n }\n\n #banner-actions button{\n text-transform: uppercase !important;\n }\n \n mat-card-content,\n mat-list,\n mat-list-item {\n height: 100% !important;\n padding: 0;\n }\n\n .mat-list, .mat-list-item, .mat-list-text{\n flex-direction: row !important;\n }\n\n @media(max-width:959px){\n mat-card {\n height: 112px;\n }\n \n mat-card-content,\n mat-list,\n mat-list-item {\n height: auto !important;\n max-width: 100% !important;\n width: 100% !important;\n } \n\n mat-list-item {\n margin: 12px 0 !important;\n }\n\n #banner-text-container {\n margin-left: 16px !important;\n }\n\n #banner-actions {\n justify-content: flex-end;\n display: flex;\n width: 100%;\n } \n }\n "]
}),
__metadata("design:paramtypes", [])
], BannerComponent);
return BannerComponent;
}());
var BannerModule = /** @class */ (function () {
function BannerModule() {
}
BannerModule = __decorate([
NgModule({
imports: [
CommonModule,
MatCardModule,
MatListModule,
MatIconModule,
MatButtonModule
],
declarations: [BannerComponent],
exports: [BannerComponent]
})
], BannerModule);
return BannerModule;
}());
var BackdropComponent = /** @class */ (function () {
function BackdropComponent() {
this.backLayerMinHeight = 56;
this.frontLayerMinHeight = 42;
}
BackdropComponent.prototype.reveal = function () {
var backLayer = this.getBackLayer();
var frontLayer = this.getFrontLayer();
var toolbar = this.getToolbar();
var from = frontLayer.offsetTop;
var to = toolbar.offsetHeight + backLayer.offsetHeight;
this.animateFrontLayerDown(frontLayer, from, to);
};
BackdropComponent.prototype.conceal = function () {
var frontLayer = this.getFrontLayer();
var from = frontLayer.offsetTop;
var to = this.backLayerMinHeight;
this.animateFrontLayerUp(frontLayer, from, to);
};
BackdropComponent.prototype.getBackLayer = function () {
return document.querySelector('nm-backdrop-back-layer-content');
};
BackdropComponent.prototype.getFrontLayer = function () {
return document.querySelector('nm-backdrop-front-layer');
};
BackdropComponent.prototype.getToolbar = function () {
return document.querySelector('mat-toolbar');
};
BackdropComponent.prototype.getWindowHeight = function () {
return document.documentElement.clientHeight;
};
// TODO Refactor animations to single function
BackdropComponent.prototype.animateFrontLayerDown = function (frontLayer, from, to) {
var pos = from;
var maxPos = this.getWindowHeight() - this.frontLayerMinHeight;
var interval = setInterval(frame, 3);
function frame() {
if (pos >= to || pos >= maxPos) {
if (to >= maxPos) {
frontLayer.style.top = maxPos + 'px';
}
else {
frontLayer.style.top = to + 'px';
}
clearInterval(interval);
}
else {
pos = to > from ? pos + 10 : pos - 10;
frontLayer.style.top = pos + 'px';
}
}
};
BackdropComponent.prototype.animateFrontLayerUp = function (frontLayer, from, to) {
var pos = from;
var interval = setInterval(frame, 3);
function frame() {
if (pos <= to) {
frontLayer.style.top = to + 'px';
clearInterval(interval);
}
else {
pos = to > from ? pos + 10 : pos - 10;
frontLayer.style.top = pos + 'px';
}
}
};
BackdropComponent = __decorate([
Component({
selector: 'nm-backdrop',
template: "\n <ng-content select=\"nm-backdrop-back-layer\"></ng-content>\n <ng-content select=\"nm-backdrop-front-layer\"></ng-content>\n ",
styles: ["\n :host {\n width: 100%;\n }\n "]
}),
__metadata("design:paramtypes", [])
], BackdropComponent);
return BackdropComponent;
}());
var BackdropBackLayerComponent = /** @class */ (function () {
function BackdropBackLayerComponent() {
}
BackdropBackLayerComponent = __decorate([
Component({
selector: 'nm-backdrop-back-layer',
template: "\n <ng-content select=\"nm-backdrop-back-layer-toolbar\"></ng-content>\n <ng-content select=\"nm-backdrop-back-layer-content\"></ng-content>\n ",
styles: ["\n :host {\n display: flex;\n flex-direction: column;\n height: 100%;\n min-height: 56px; \n width: 100%;\n }\n "]
})
], BackdropBackLayerComponent);
return BackdropBackLayerComponent;
}());
var BackdropBackLayerContentComponent = /** @class */ (function () {
function BackdropBackLayerContentComponent() {
}
BackdropBackLayerContentComponent = __decorate([
Component({
selector: 'nm-backdrop-back-layer-content',
template: "\n <ng-content></ng-content>\n ",
styles: ["\n :host{\n overflow-y: auto;\n }\n "]
})
], BackdropBackLayerContentComponent);
return BackdropBackLayerContentComponent;
}());
var BackdropBackLayerToolbarComponent = /** @class */ (function () {
function BackdropBackLayerToolbarComponent() {
}
BackdropBackLayerToolbarComponent = __decorate([
Component({
selector: 'nm-backdrop-back-layer-toolbar',
template: "<ng-content></ng-content>",
styles: [""]
})
], BackdropBackLayerToolbarComponent);
return BackdropBackLayerToolbarComponent;
}());
var BackdropFrontLayerComponent = /** @class */ (function () {
function BackdropFrontLayerComponent() {
}
BackdropFrontLayerComponent = __decorate([
Component({
selector: 'nm-backdrop-front-layer',
template: "\n <ng-content select=\"nm-backdrop-front-layer-subtitle\"></ng-content>\n <ng-content select=\"nm-backdrop-front-layer-content\"></ng-content> \n ",
styles: ["\n :host{\n border-top-left-radius: 16px;\n border-top-right-radius: 16px;\n bottom: 0;\n height: 100%;\n overflow: hidden; \n position: fixed;\n top: 56px;\n width: 100%;\n }\n "]
})
], BackdropFrontLayerComponent);
return BackdropFrontLayerComponent;
}());
var BackdropFrontLayerSubtitleComponent = /** @class */ (function () {
function BackdropFrontLayerSubtitleComponent() {
}
BackdropFrontLayerSubtitleComponent = __decorate([
Component({
selector: 'nm-backdrop-front-layer-subtitle',
template: "<ng-container>\n <ng-content select=\"mat-icon\" class=\"subtitle-icon\"></ng-content>\n <ng-content select=\"span\"></ng-content>\n <span class=\"spacer\"></span>\n <ng-content select=\"button\"></ng-content>\n </ng-container>",
styles: ["\n :host{\n align-items: center;\n display: flex;\n flex-direction: row;\n margin: 12px 16px; \n width: auto;\n }\n \n :host ::ng-deep mat-icon{\n margin-right: 8px;\n }\n\n :host ::ng-deep span {\n font-size: 1.2rem;\n }\n\n :host ::ng-deep .spacer {\n flex: 1 1 auto;\n }\n "]
})
], BackdropFrontLayerSubtitleComponent);
return BackdropFrontLayerSubtitleComponent;
}());
var BackdropFrontLayerContentComponent = /** @class */ (function () {
function BackdropFrontLayerContentComponent() {
}
BackdropFrontLayerContentComponent = __decorate([
Component({
selector: 'nm-backdrop-front-layer-content',
template: "<ng-content></ng-content>",
styles: ["\n :host{\n display: flex;\n height: 100%;\n overflow-y: auto;\n width: 100%;\n }\n "]
})
], BackdropFrontLayerContentComponent);
return BackdropFrontLayerContentComponent;
}());
var BackdropModule = /** @class */ (function () {
function BackdropModule() {
}
BackdropModule = __decorate([
NgModule({
imports: [
CommonModule,
],
declarations: [
BackdropComponent,
BackdropBackLayerComponent,
BackdropBackLayerContentComponent,
BackdropBackLayerToolbarComponent,
BackdropFrontLayerComponent,
BackdropFrontLayerSubtitleComponent,
BackdropFrontLayerContentComponent,
],
exports: [
BackdropComponent,
BackdropBackLayerComponent,
BackdropBackLayerContentComponent,
BackdropBackLayerToolbarComponent,
BackdropFrontLayerComponent,
BackdropFrontLayerSubtitleComponent,
BackdropFrontLayerContentComponent,
]
})
], BackdropModule);
return BackdropModule;
}());
var FabSpeedDialAnimation = [
trigger('fabButtonAnimation', [
state('inactive', style({
transform: 'rotate(0deg)'
})),
state('active', style({
transform: 'rotate(180deg)'
})),
transition('* <=> *', animate('200ms cubic-bezier(0.4, 0.0, 0.2, 1)')),
]),
trigger('speedDialStagger', [
transition('* => *', [
query(':enter', style({ opacity: 0 }), { optional: true }),
query(':enter', stagger('40ms', [
animate('200ms cubic-bezier(0.4, 0.0, 0.2, 1)', keyframes([
style({ opacity: 0, transform: 'translateY(10px)' }),
style({ opacity: 1, transform: 'translateY(0)' }),
]))
]), { optional: true }),
query(':leave', animate('200ms cubic-bezier(0.4, 0.0, 0.2, 1)', keyframes([
style({ opacity: 1 }),
style({ opacity: 0 }),
])), { optional: true })
])
])
];
var FabSpeedDialComponent = /** @class */ (function () {
function FabSpeedDialComponent() {
this.selectedAction = new EventEmitter();
this.showActions = false;
this.displayedIcon = '';
this.fabSpeedDialState = '';
this.isCorrectActionsNumber = true;
}
FabSpeedDialComponent.prototype.ngOnInit = function () {
this.displayedIcon = this.mainIcon;
this.checkActions();
};
FabSpeedDialComponent.prototype.checkActions = function () {
if (this.actions.length < 3) {
console.error('A speed dial should include at least three options.');
this.isCorrectActionsNumber = false;
}
else if (this.actions.length > 6) {
console.error('A speed dial should include no more than six options.');
this.isCorrectActionsNumber = false;
}
};
FabSpeedDialComponent.prototype.toggleSpeedDial = function () {
this.showActions = !this.showActions;
if (this.showActions) {
this.fabSpeedDialState = 'active';
this.displayedIcon = 'close';
document.getElementById('nm-fab-speed-dial-button-overlay').classList.add('nm-fab-speed-dial-overlay');
}
else {
this.fabSpeedDialState = 'inactive';
this.displayedIcon = this.mainIcon;
document.getElementById('nm-fab-speed-dial-button-overlay').classList.remove('nm-fab-speed-dial-overlay');
}
};
FabSpeedDialComponent.prototype.actionSelected = function (action) {
this.selectedAction.emit(action);
this.toggleSpeedDial();
};
__decorate([
Input(),
__metadata("design:type", String)
], FabSpeedDialComponent.prototype, "mainIcon", void 0);
__decorate([
Input(),
__metadata("design:type", Array)
], FabSpeedDialComponent.prototype, "actions", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], FabSpeedDialComponent.prototype, "selectedAction", void 0);
FabSpeedDialComponent = __decorate([
Component({
selector: 'nm-fab-speed-dial',
template: "\n\t\t<div *ngIf=\"isCorrectActionsNumber\">\n <div id=\"nm-fab-speed-dial-button-overlay\"></div>\n <div class=\"nm-fab-speed-dial-button-component\">\n <div *ngIf=\"showActions\" [@speedDialStagger]=\"actions.length\" class=\"nm-fab-speed-dial-menu-actions\">\n <div *ngFor=\"let action of actions\" class=\"nm-fab-speed-dial-mini-button\">\n <mat-card class=\"nm-fab-speed-dial-card-action\" *ngIf=\"action.name\">\n {{ action.name }}\n </mat-card>\n <button mat-mini-fab color=\"primary\" (click)=\"actionSelected(action)\"> \n <mat-icon>{{ action.icon }}</mat-icon>\n </button>\n </div>\n </div>\n <button mat-fab color=\"primary\" (click)=\"toggleSpeedDial()\">\n <mat-icon [@fabButtonAnimation]=\"{value: fabSpeedDialState}\">{{ displayedIcon }}</mat-icon>\n </button>\n </div>\n </div>\n\t\t",
animations: FabSpeedDialAnimation,
styles: ["\n .nm-fab-speed-dial-button-component {\n position: fixed;\n bottom: 16px;\n right: 16px;\n text-align: right;\n }\n .nm-fab-speed-dial-mini-button {\n display: flex;\n align-items: flex-end;\n margin-bottom: 16px;\n }\n .nm-fab-speed-dial-card-action {\n margin-right: 16px;\n padding: 12px;\n text-align: center;\n padding-right: 16px;\n padding-left: 16px;\n }\n .nm-fab-speed-dial-menu-actions {\n flex-direction: column-reverse;\n display: flex;\n align-items: flex-end;\n margin-right: 8px;\n position: relative;\n bottom: 56px;\n }\n .nm-fab-speed-dial-overlay {\n width: 100%;\n height: 100%;\n position: fixed;\n left: 0;\n top: 0;\n z-index: 0;\n\t\tbackground: rgba(0, 0, 0, 0.32);\n }\n "]
}),
__metadata("design:paramtypes", [])
], FabSpeedDialComponent);
return FabSpeedDialComponent;
}());
var FabSpeedDialModule = /** @class */ (function () {
function FabSpeedDialModule() {
}
FabSpeedDialModule = __decorate([
NgModule({
imports: [
CommonModule,
MatButtonModule,
MatIconModule,
MatCardModule
],
declarations: [FabSpeedDialComponent],
exports: [FabSpeedDialComponent]
})
], FabSpeedDialModule);
return FabSpeedDialModule;
}());
/*
* Public API Surface of nm
*/
/**
* Generated bundle index. Do not edit.
*/
export { BackdropBackLayerComponent, BackdropBackLayerContentComponent, BackdropBackLayerToolbarComponent, BackdropComponent, BackdropFrontLayerComponent, BackdropFrontLayerContentComponent, BackdropFrontLayerSubtitleComponent, BackdropModule, BannerComponent, BannerModule, ContextualToolbarComponent, ContextualToolbarDisplayMode, ContextualToolbarModule, FabSpeedDialComponent, FabSpeedDialModule, FabSpeedDialAnimation as ɵa };
//# sourceMappingURL=nereo-material.js.map