import { Component, Input, TemplateRef, ViewChild } from '@angular/core';
import { map } from 'rxjs/operators';
import { DataTable2ColumnComponent } from './data-table-column.component';
import * as i0 from "@angular/core";
import * as i1 from "../../../data/providers/data.service";
import * as i2 from "@clr/angular";
import * as i3 from "@angular/common";
import * as i4 from "../dropdown/dropdown.component";
import * as i5 from "../dropdown/dropdown-menu.component";
import * as i6 from "../dropdown/dropdown-trigger.directive";
import * as i7 from "../object-tree/object-tree.component";
import * as i8 from "@ngx-translate/core";
import * as i9 from "../../pipes/locale-date.pipe";
export class DataTableCustomFieldColumnComponent extends DataTable2ColumnComponent {
    constructor(dataService) {
        super();
        this.dataService = dataService;
        this.uiLanguage$ = this.dataService.client
            .uiState()
            .stream$.pipe(map(({ uiState }) => uiState.language));
    }
    ngOnInit() {
        this.uiLanguage$.subscribe(uiLanguage => {
            this.heading =
                Array.isArray(this.customField.label) && this.customField.label.length > 0
                    ? this.customField.label.find(l => l.languageCode === uiLanguage)?.value ??
                        this.customField.name
                    : this.customField.name;
        });
        this.hiddenByDefault = true;
        this.sort = this.sorts?.get(this.customField.name);
        this.id = this.customField.name;
        super.ngOnInit();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: DataTableCustomFieldColumnComponent, deps: [{ token: i1.DataService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.2", type: DataTableCustomFieldColumnComponent, selector: "vdr-dt2-custom-field-column", inputs: { customField: "customField", sorts: "sorts" }, viewQueries: [{ propertyName: "template", first: true, predicate: TemplateRef, descendants: true }], exportAs: ["row"], usesInheritance: true, ngImport: i0, template: "<ng-template let-item=\"item\">\n    <ng-container\n        *ngIf=\"item.customFields[customField.name] == null || item.customFields[customField.name] === ''\"\n    >\n        <span class=\"empty\">-</span>\n    </ng-container>\n    <ng-container *ngIf=\"item.customFields[customField.name] != null\">\n        <ng-container [ngSwitch]=\"customField.type\">\n            <ng-container *ngSwitchCase=\"'boolean'\">\n                <clr-icon\n                    *ngIf=\"item.customFields[customField.name]\"\n                    shape=\"check\"\n                    class=\"color-success-700\"\n                ></clr-icon>\n                <clr-icon *ngIf=\"!item.customFields[customField.name]\" shape=\"times\"></clr-icon>\n            </ng-container>\n            <ng-container *ngSwitchCase=\"'datetime'\">\n                {{ item.customFields[customField.name] | localeDate }}\n            </ng-container>\n            <ng-container *ngSwitchCase=\"'text'\">\n                {{ item.customFields[customField.name] | slice : 0 : 50 }}\n            </ng-container>\n            <ng-container *ngSwitchCase=\"'relation'\">\n                <vdr-dropdown>\n                    <button\n                        class=\"btn btn-link btn-icon\"\n                        vdrDropdownTrigger\n                        [title]=\"'common.details' | translate\"\n                    >\n                        <clr-icon shape=\"details\"></clr-icon>\n                    </button>\n                    <vdr-dropdown-menu>\n                        <div class=\"result-detail\">\n                            <vdr-object-tree [value]=\"item.customFields[customField.name]\"></vdr-object-tree>\n                        </div>\n                    </vdr-dropdown-menu>\n                </vdr-dropdown>\n            </ng-container>\n            <ng-container *ngSwitchDefault>\n                {{ item.customFields[customField.name] }}\n            </ng-container>\n        </ng-container>\n    </ng-container>\n</ng-template>\n", styles: [".empty{color:var(--color-weight-300)}\n"], dependencies: [{ kind: "directive", type: i2.ClrIconCustomTag, selector: "clr-icon" }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i3.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "component", type: i4.DropdownComponent, selector: "vdr-dropdown", inputs: ["manualToggle"] }, { kind: "component", type: i5.DropdownMenuComponent, selector: "vdr-dropdown-menu", inputs: ["vdrPosition", "customClasses"] }, { kind: "directive", type: i6.DropdownTriggerDirective, selector: "[vdrDropdownTrigger]" }, { kind: "component", type: i7.ObjectTreeComponent, selector: "vdr-object-tree", inputs: ["value", "isArrayItem"] }, { kind: "pipe", type: i3.SlicePipe, name: "slice" }, { kind: "pipe", type: i8.TranslatePipe, name: "translate" }, { kind: "pipe", type: i9.LocaleDatePipe, name: "localeDate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.2", ngImport: i0, type: DataTableCustomFieldColumnComponent, decorators: [{
            type: Component,
            args: [{ selector: 'vdr-dt2-custom-field-column', exportAs: 'row', template: "<ng-template let-item=\"item\">\n    <ng-container\n        *ngIf=\"item.customFields[customField.name] == null || item.customFields[customField.name] === ''\"\n    >\n        <span class=\"empty\">-</span>\n    </ng-container>\n    <ng-container *ngIf=\"item.customFields[customField.name] != null\">\n        <ng-container [ngSwitch]=\"customField.type\">\n            <ng-container *ngSwitchCase=\"'boolean'\">\n                <clr-icon\n                    *ngIf=\"item.customFields[customField.name]\"\n                    shape=\"check\"\n                    class=\"color-success-700\"\n                ></clr-icon>\n                <clr-icon *ngIf=\"!item.customFields[customField.name]\" shape=\"times\"></clr-icon>\n            </ng-container>\n            <ng-container *ngSwitchCase=\"'datetime'\">\n                {{ item.customFields[customField.name] | localeDate }}\n            </ng-container>\n            <ng-container *ngSwitchCase=\"'text'\">\n                {{ item.customFields[customField.name] | slice : 0 : 50 }}\n            </ng-container>\n            <ng-container *ngSwitchCase=\"'relation'\">\n                <vdr-dropdown>\n                    <button\n                        class=\"btn btn-link btn-icon\"\n                        vdrDropdownTrigger\n                        [title]=\"'common.details' | translate\"\n                    >\n                        <clr-icon shape=\"details\"></clr-icon>\n                    </button>\n                    <vdr-dropdown-menu>\n                        <div class=\"result-detail\">\n                            <vdr-object-tree [value]=\"item.customFields[customField.name]\"></vdr-object-tree>\n                        </div>\n                    </vdr-dropdown-menu>\n                </vdr-dropdown>\n            </ng-container>\n            <ng-container *ngSwitchDefault>\n                {{ item.customFields[customField.name] }}\n            </ng-container>\n        </ng-container>\n    </ng-container>\n</ng-template>\n", styles: [".empty{color:var(--color-weight-300)}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.DataService }]; }, propDecorators: { customField: [{
                type: Input
            }], sorts: [{
                type: Input
            }], template: [{
                type: ViewChild,
                args: [TemplateRef, { static: false }]
            }] } });
//# sourceMappingURL=data:application/json;base64, 