import { __decorate } from "tslib";
import { PSDEFormDetail } from '@ibizstudio/api';
import { VueLifeCycleProcessing } from '../../../decorators';
import { Component, Prop } from 'vue-property-decorator';
import { DesignContainerBase } from '../design-container-base/design-container-base';
import './design-tab-panel.less';
/**
 * 其他表单项类型
 *
 * @export
 * @class DesignTabPanel
 * @extends {DragDesignItemBase}
 */
let DesignTabPanel = class DesignTabPanel extends DesignContainerBase {
    constructor() {
        super(...arguments);
        /**
         * 当前激活表单分页
         *
         * @type {IPSDEFormDetail}
         * @memberof DesignTabPanel
         */
        this.activateData = null;
    }
    /**
     * 激活数据变更
     *
     * @param {T} data
     * @memberof DesignTabPanel
     */
    activeChange(data) {
        if (data.itemtype === this.itemType && data.ppsdeformdetailid === this.data.psdeformdetailid) {
            this.activateData = data;
        }
    }
    async addPage() {
        const data = await this.getDraft(new PSDEFormDetail({ itemtype: this.itemType }));
        await this.create(data);
    }
    removePage(item) {
        this.remove(item.srfkey);
    }
    change(evt) {
        if (evt === null || evt === void 0 ? void 0 : evt.moved) {
            this.move(evt.moved);
        }
    }
    calcStyle() {
        super.calcStyle();
        if (this.style.height == null) {
            this.style.height = '200px';
        }
    }
    renderContent() {
        const style = {};
        const { padding } = this.data;
        const contentStyle = this.getContentStyle(this.data);
        return (<div key={this.data.srfkey} style={`padding: ${padding}px;${contentStyle}`} class={['ibz-design-tab-panel-container', 'drag-item-container', { active: this.active }]}>
                <design-tabs key='ibz-design-tab-panel' class='ibz-design-tab-panel' activeItem={this.activateData} list={this.list} on-active-item-change={(item) => this.setSelect(item)} on-remove-page={(item) => this.removePage(item)} on-add-page={() => this.addPage()} on-change={(e) => this.change(e)} renderTabItemContent={(_h, item) => {
                return (<ibz-design-tab-panel-content key={item.srfkey} ctx={this.ctx} data={item} parentData={this.data}/>);
            }}/>
            </div>);
    }
};
__decorate([
    Prop({ default: 'TABPAGE' })
], DesignTabPanel.prototype, "itemType", void 0);
DesignTabPanel = __decorate([
    Component({}),
    VueLifeCycleProcessing()
], DesignTabPanel);
export { DesignTabPanel };
