Newer
Older
import { Directive, HostListener, Input, TemplateRef } from "@angular/core";
import { MatDialog, MatDialogConfig, MatDialogRef } from 'src/sharedModules/angularMaterial.exports'
import { DialogFallbackCmp } from "./tmpl/tmpl.component"
type DialogSize = 's' | 'm' | 'l' | 'xl' | 'auto'
const sizeDict: Record<DialogSize, Partial<MatDialogConfig>> = {
's': {
width: '25vw',
height: '25vh'
},
'm': {
width: '50vw',
height: '50vh'
},
'l': {
width: '75vw',
height: '75vh'
},
'xl': {
width: '90vw',
height: '90vh'
selector: `[sxplr-dialog]`,
exportAs: 'sxplrDialog',
@Input('sxplr-dialog-size')
size: DialogSize = 'm'
onClick(data: any={}){
const tmpl = this.templateRef instanceof TemplateRef
? this.templateRef
: DialogFallbackCmp
this.#dialogRef = this.matDialog.open(tmpl, {
autoFocus: null,
data: {...this.data, ...data},
close(){
if (this.#dialogRef) {
this.#dialogRef.close()
this.#dialogRef = null
}
}