{"version":3,"file":"deja-js-component-message-box.mjs","sources":["../../../../projects/deja-js/component/message-box/message-box.component.ts","../../../../projects/deja-js/component/message-box/message-box.component.html","../../../../projects/deja-js/component/message-box/index.ts","../../../../projects/deja-js/component/message-box/deja-js-component-message-box.ts"],"sourcesContent":["/*\n *  @license\n *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.\n *\n *  Use of this source code is governed by an Apache-2.0 license that can be\n *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE\n */\n\nimport { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';\nimport { Component, ContentChild, EventEmitter, Input, OnInit, Output, TemplateRef, ViewEncapsulation } from '@angular/core';\nimport { DejaMessageBoxAction, DejaMessageBoxType } from '@deja-js/component/core';\n\n@Component({\n    encapsulation: ViewEncapsulation.None,\n    selector: 'deja-message-box',\n    styleUrls: ['./message-box.component.scss'],\n    templateUrl: './message-box.component.html'\n})\nexport class DejaMessageBoxComponent implements OnInit {\n    // eslint-disable-next-line @angular-eslint/no-output-native\n    @Output() public readonly close = new EventEmitter();\n\n    @Input() public type: DejaMessageBoxType;\n    @Input() public title: string;\n    @Input() public icon: string;\n    @Input() public actions: Array<DejaMessageBoxAction>;\n    /** Event Emmited when the close action is called */\n    @ContentChild('actionsTemplate') public actionsTemplate: TemplateRef<unknown>;\n\n    private _horizontal: boolean;\n\n    @Input()\n    public set horizontal(value: BooleanInput) {\n        this._horizontal = coerceBooleanProperty(value);\n    }\n\n    public get horizontal(): BooleanInput {\n        return this._horizontal;\n    }\n\n    private _showCloseIcon = false;\n    @Input()\n    public set showCloseIcon(value: BooleanInput) {\n        this._showCloseIcon = coerceBooleanProperty(value);\n    }\n\n    public get showCloseIcon(): BooleanInput {\n        return this._showCloseIcon;\n    }\n\n    public ngOnInit(): void {\n        if (!this.icon && this.type) {\n            this.icon = this.getIconFromType(this.type);\n        }\n\n        if (this.actions) {\n            this.actions.forEach(action => {\n                if (!action.icon && action.type) {\n                    action.icon = this.getIconFromType(action.type);\n                }\n            });\n        }\n    }\n\n    public onClose(): void {\n        this.close.emit();\n    }\n\n    private getIconFromType(type: 'info' | 'primary' | 'success' | 'warn' | 'danger'): string {\n        switch (type) {\n            case 'info':\n            case 'primary':\n                type = 'primary';\n                return 'info';\n            case 'success':\n                return 'done';\n            case 'warn':\n                return 'warning';\n            case 'danger':\n                return 'error';\n            default:\n                return null;\n        }\n    }\n}\n","<mat-card id=\"msgbox\" class=\"{{type}}\">\n    <mat-card-title *ngIf=\"icon || showCloseIcon\">\n        <mat-icon id=\"icon\" *ngIf=\"icon\">{{icon}}</mat-icon>\n        <span id=\"title\" *ngIf=\"!horizontal\">{{title}}</span>\n        <div class=\"header-actions\">\n            <button *ngIf=\"showCloseIcon\" mat-icon-button type=\"button\" class=\"close\" (click)=\"onClose()\">\n                <mat-icon>close</mat-icon>\n            </button>\n        </div>\n    </mat-card-title>\n    <mat-card-content>\n        <h2 id=\"title\" *ngIf=\"horizontal && title\">{{title}}</h2>\n        <ng-content></ng-content>\n    </mat-card-content>\n    <mat-card-actions *ngIf=\"actions\">\n        <span *ngFor=\"let action of actions\">\n            <button mat-button type=\"button\" *ngIf=\"action.text\" (click)=\"action.action()\" class=\"with-icon\" [attr.data-icon]=\"action.icon\">\n                {{action.text}}\n            </button>\n            <button mat-icon-button type=\"button\" *ngIf=\"action.icon && !action.text\" [class.action-button]=\"!action.type\" (click)=\"action.action()\">\n                <mat-icon *ngIf=\"action.icon\">{{action.icon}}</mat-icon>\n            </button>\n        </span>\n    </mat-card-actions>\n    <mat-card-actions *ngIf=\"!actions && actionsTemplate\">\n\t\t<ng-template [ngTemplateOutlet]=\"actionsTemplate\"></ng-template>\n\t</mat-card-actions>\n</mat-card>\n","/*\n *  @license\n *  Copyright Hôpitaux Universitaires de Genève. All Rights Reserved.\n *\n *  Use of this source code is governed by an Apache-2.0 license that can be\n *  found in the LICENSE file at https://github.com/DSI-HUG/dejajs-components/blob/master/LICENSE\n */\n\nimport { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\nimport { MatButtonModule } from '@angular/material/button';\nimport { MatCardModule } from '@angular/material/card';\nimport { MatIconModule } from '@angular/material/icon';\n\nimport { DejaMessageBoxComponent } from './message-box.component';\n\n@NgModule({\n    declarations: [\n        DejaMessageBoxComponent\n    ],\n    exports: [\n        DejaMessageBoxComponent\n    ],\n    imports: [\n        CommonModule,\n        MatButtonModule,\n        MatCardModule,\n        MatIconModule\n    ]\n})\nexport class DejaMessageBoxModule { }\n\nexport * from './message-box.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;AAMG;MAYU,uBAAuB,CAAA;AANpC,IAAA,WAAA,GAAA;;AAQ8B,QAAA,IAAA,CAAA,KAAK,GAAG,IAAI,YAAY,EAAE,CAAC;QAoB7C,IAAc,CAAA,cAAA,GAAG,KAAK,CAAC;AA4ClC,KAAA;IArDG,IACW,UAAU,CAAC,KAAmB,EAAA;AACrC,QAAA,IAAI,CAAC,WAAW,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;KACnD;AAED,IAAA,IAAW,UAAU,GAAA;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC;KAC3B;IAGD,IACW,aAAa,CAAC,KAAmB,EAAA;AACxC,QAAA,IAAI,CAAC,cAAc,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;KACtD;AAED,IAAA,IAAW,aAAa,GAAA;QACpB,OAAO,IAAI,CAAC,cAAc,CAAC;KAC9B;IAEM,QAAQ,GAAA;QACX,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE;YACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/C,SAAA;QAED,IAAI,IAAI,CAAC,OAAO,EAAE;AACd,YAAA,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM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