UNPKG

@igo2/common

Version:
89 lines (83 loc) 7.67 kB
import * as i0 from '@angular/core'; import { Component, Injectable, NgModule } from '@angular/core'; import { NgTemplateOutlet, NgFor, NgIf, KeyValuePipe } from '@angular/common'; import * as i2 from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button'; import * as i1 from '@angular/material/dialog'; import { MatDialogTitle, MatDialogContent, MatDialogActions } from '@angular/material/dialog'; class JsonDialogComponent { dialogRef; title; data; ignoreKeys; constructor(dialogRef) { this.dialogRef = dialogRef; } isObject(val) { return typeof val === 'object' && !Array.isArray(val); } getKey(baseKey, key) { return (baseKey ? baseKey + '.' : '') + key; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: JsonDialogComponent, deps: [{ token: i1.MatDialogRef }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.15", type: JsonDialogComponent, isStandalone: true, selector: "igo-json-dialog", ngImport: i0, template: "<h1 mat-dialog-title>{{ title }}</h1>\n\n<div mat-dialog-content>\n <ng-container\n *ngTemplateOutlet=\"loopObject; context: { obj: data }\"\n ></ng-container>\n\n <ng-template #loopObject let-obj=\"obj\" let-baseKey=\"baseKey\">\n <ng-container *ngFor=\"let property of obj | keyvalue\">\n <ng-container\n *ngIf=\"ignoreKeys.indexOf(getKey(baseKey, property.key)) === -1\"\n >\n <ng-container *ngIf=\"isObject(property.value); else notObject\">\n <ng-container\n *ngTemplateOutlet=\"\n loopObject;\n context: {\n obj: property.value,\n baseKey: getKey(baseKey, property.key)\n }\n \"\n ></ng-container>\n </ng-container>\n\n <ng-template #notObject>\n <p>\n <span\n ><b>{{ getKey(baseKey, property.key) }}</b> : </span\n ><span class=\"propertyValue\" [innerHtml]=\"property.value\"></span>\n </p>\n </ng-template>\n </ng-container>\n </ng-container>\n </ng-template>\n</div>\n\n<div mat-dialog-actions>\n <button mat-button color=\"primary\" (click)=\"dialogRef.close(false)\">\n OK\n </button>\n</div>\n", dependencies: [{ kind: "directive", type: MatDialogTitle, selector: "[mat-dialog-title], [matDialogTitle]", inputs: ["id"], exportAs: ["matDialogTitle"] }, { kind: "directive", type: MatDialogContent, selector: "[mat-dialog-content], mat-dialog-content, [matDialogContent]" }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: NgFor, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: MatDialogActions, selector: "[mat-dialog-actions], mat-dialog-actions, [matDialogActions]", inputs: ["align"] }, { kind: "ngmodule", type: MatButtonModule }, { kind: "component", type: i2.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", exportAs: ["matButton"] }, { kind: "pipe", type: KeyValuePipe, name: "keyvalue" }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: JsonDialogComponent, decorators: [{ type: Component, args: [{ selector: 'igo-json-dialog', imports: [ MatDialogTitle, MatDialogContent, NgTemplateOutlet, NgFor, NgIf, MatDialogActions, MatButtonModule, KeyValuePipe ], template: "<h1 mat-dialog-title>{{ title }}</h1>\n\n<div mat-dialog-content>\n <ng-container\n *ngTemplateOutlet=\"loopObject; context: { obj: data }\"\n ></ng-container>\n\n <ng-template #loopObject let-obj=\"obj\" let-baseKey=\"baseKey\">\n <ng-container *ngFor=\"let property of obj | keyvalue\">\n <ng-container\n *ngIf=\"ignoreKeys.indexOf(getKey(baseKey, property.key)) === -1\"\n >\n <ng-container *ngIf=\"isObject(property.value); else notObject\">\n <ng-container\n *ngTemplateOutlet=\"\n loopObject;\n context: {\n obj: property.value,\n baseKey: getKey(baseKey, property.key)\n }\n \"\n ></ng-container>\n </ng-container>\n\n <ng-template #notObject>\n <p>\n <span\n ><b>{{ getKey(baseKey, property.key) }}</b> : </span\n ><span class=\"propertyValue\" [innerHtml]=\"property.value\"></span>\n </p>\n </ng-template>\n </ng-container>\n </ng-container>\n </ng-template>\n</div>\n\n<div mat-dialog-actions>\n <button mat-button color=\"primary\" (click)=\"dialogRef.close(false)\">\n OK\n </button>\n</div>\n" }] }], ctorParameters: () => [{ type: i1.MatDialogRef }] }); class JsonDialogService { dialog; constructor(dialog) { this.dialog = dialog; } open(title, data, ignoreKeys) { const dialogRef = this.dialog.open(JsonDialogComponent, { disableClose: false }); dialogRef.componentInstance.data = data; dialogRef.componentInstance.title = title; dialogRef.componentInstance.ignoreKeys = ignoreKeys ?? []; return dialogRef.afterClosed(); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: JsonDialogService, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Injectable }); static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: JsonDialogService }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: JsonDialogService, decorators: [{ type: Injectable }], ctorParameters: () => [{ type: i1.MatDialog }] }); class IgoJsonDialogModule { /** * @deprecated it has no effect */ static forRoot() { return { ngModule: IgoJsonDialogModule }; } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IgoJsonDialogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.15", ngImport: i0, type: IgoJsonDialogModule, imports: [JsonDialogComponent], exports: [JsonDialogComponent] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IgoJsonDialogModule, providers: [JsonDialogService], imports: [JsonDialogComponent] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IgoJsonDialogModule, decorators: [{ type: NgModule, args: [{ imports: [JsonDialogComponent], exports: [JsonDialogComponent], providers: [JsonDialogService] }] }] }); /** * Generated bundle index. Do not edit. */ export { IgoJsonDialogModule, JsonDialogComponent, JsonDialogService }; //# sourceMappingURL=igo2-common-json-dialog.mjs.map