import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FormPreviewComponent } from '../form-preview/form-preview.component';
import { CANVASDEFAULT } from '../model/attributeInfo';
import * as i0 from "@angular/core";
import * as i1 from "ng-devui";
import * as i2 from "../service/common.service";
import * as i3 from "../form-component/form-component.component";
import * as i4 from "../form-canvas/form-canvas.component";
import * as i5 from "../form-attribute/form-attribute.component";
export class FormBuilderComponent {
    constructor(dialogService, commonService) {
        this.dialogService = dialogService;
        this.commonService = commonService;
        this.canvasInfo = CANVASDEFAULT;
        this.sendBuilderString = new EventEmitter();
    }
    get inputLayout() {
        if (this.originalLayout) {
            return JSON.parse(this.originalLayout, this.commonService.reviver);
        }
        else {
            return null;
        }
    }
    openPreview() {
        const results = this.dialogService.open({
            id: 'dialog-service',
            width: '850px',
            maxHeight: '600px',
            title: '表单预览',
            content: FormPreviewComponent,
            backdropCloseable: true,
            dialogtype: "standard",
            onClose: () => {
                console.log('on dialog closed');
            },
            buttons: [
                {
                    cssClass: 'primary',
                    text: '确定',
                    disabled: false,
                    handler: ($event) => {
                        results.modalInstance.hide();
                    },
                },
                {
                    id: 'btn-cancel',
                    cssClass: 'common',
                    text: '取消',
                    handler: ($event) => {
                        results.modalInstance.hide();
                    },
                },
            ],
            data: this.canvasInfo,
        });
    }
    sendBuilderEvent() {
        this.sendBuilderString.emit(JSON.stringify(this.commonService.getPreviewData("op"), this.commonService.replacer));
    }
}
FormBuilderComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: FormBuilderComponent, deps: [{ token: i1.DialogService }, { token: i2.CommonService }], target: i0.ɵɵFactoryTarget.Component });
FormBuilderComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: FormBuilderComponent, selector: "form-builder", inputs: { originalLayout: "originalLayout" }, outputs: { sendBuilderString: "sendBuilderString" }, ngImport: i0, template: "<d-layout class=\"layout-wrapper\">\r\n    <d-header >\r\n      <div class=\"bottonbar\">\r\n        <d-button style=\"margin-right: 8px\" (btnClick)=\"sendBuilderEvent()\">\u4FDD\u5B58</d-button>\r\n        <d-button style=\"margin-right: 8px\" (btnClick)=\"openPreview()\">\u9884\u89C8</d-button>\r\n      </div>\r\n    </d-header>\r\n    <d-layout style=\"overflow: hidden;\">\r\n      <d-aside class=\"compbar\" style=\"min-width:232px\">\r\n        <form-component></form-component>\r\n      </d-aside>\r\n      <d-content style=\"overflow-y: hidden;\">\r\n        <form-canvas [originalLayout]=\"inputLayout\"></form-canvas>\r\n      </d-content>\r\n      <d-aside class=\"attributbar\">\r\n        <form-attribute></form-attribute>\r\n      </d-aside>\r\n    </d-layout>\r\n</d-layout>", styles: [".layout-wrapper{box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) var(--devui-light-shadow, rgba(37, 43, 58, .2));margin-top:36px;height:100%}.layout-wrapper:first-child{margin-top:0}d-header{line-height:40px;background-color:var(--devui-base-bg-dark, #252b3a);color:var(--devui-light-text, #ffffff)}d-aside{min-height:200px;min-width:350px;background-color:var(--devui-base-bg, #ffffff)}d-content{background-color:var(--devui-global-bg, #f7f8fa)}.bottonbar{display:flex;flex-direction:row-reverse;align-items:center;height:100%}.compbar{overflow:auto;display:flex;flex-direction:column}.attributbar{display:flex;flex-direction:column;overflow:auto}\n"], components: [{ type: i1.LayoutComponent, selector: "d-layout" }, { type: i1.HeaderComponent, selector: "d-header" }, { type: i1.ButtonComponent, selector: "d-button", inputs: ["id", "type", "bsStyle", "bsSize", "bsPosition", "bordered", "icon", "disabled", "showLoading", "width", "autofocus", "loadingTemplateRef"], outputs: ["btnClick"] }, { type: i1.AsideComponent, selector: "d-aside", exportAs: ["dAside"] }, { type: i3.FormComponentComponent, selector: "form-component" }, { type: i1.ContentComponent, selector: "d-content" }, { type: i4.FormCanvasComponent, selector: "form-canvas", inputs: ["originalLayout"] }, { type: i5.FormAttributeComponent, selector: " form-attribute" }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: FormBuilderComponent, decorators: [{
            type: Component,
            args: [{ selector: 'form-builder', template: "<d-layout class=\"layout-wrapper\">\r\n    <d-header >\r\n      <div class=\"bottonbar\">\r\n        <d-button style=\"margin-right: 8px\" (btnClick)=\"sendBuilderEvent()\">\u4FDD\u5B58</d-button>\r\n        <d-button style=\"margin-right: 8px\" (btnClick)=\"openPreview()\">\u9884\u89C8</d-button>\r\n      </div>\r\n    </d-header>\r\n    <d-layout style=\"overflow: hidden;\">\r\n      <d-aside class=\"compbar\" style=\"min-width:232px\">\r\n        <form-component></form-component>\r\n      </d-aside>\r\n      <d-content style=\"overflow-y: hidden;\">\r\n        <form-canvas [originalLayout]=\"inputLayout\"></form-canvas>\r\n      </d-content>\r\n      <d-aside class=\"attributbar\">\r\n        <form-attribute></form-attribute>\r\n      </d-aside>\r\n    </d-layout>\r\n</d-layout>", styles: [".layout-wrapper{box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) var(--devui-light-shadow, rgba(37, 43, 58, .2));margin-top:36px;height:100%}.layout-wrapper:first-child{margin-top:0}d-header{line-height:40px;background-color:var(--devui-base-bg-dark, #252b3a);color:var(--devui-light-text, #ffffff)}d-aside{min-height:200px;min-width:350px;background-color:var(--devui-base-bg, #ffffff)}d-content{background-color:var(--devui-global-bg, #f7f8fa)}.bottonbar{display:flex;flex-direction:row-reverse;align-items:center;height:100%}.compbar{overflow:auto;display:flex;flex-direction:column}.attributbar{display:flex;flex-direction:column;overflow:auto}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.DialogService }, { type: i2.CommonService }]; }, propDecorators: { originalLayout: [{
                type: Input,
                args: ["originalLayout"]
            }], sendBuilderString: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 