import { __decorate } from "tslib";
import { Vue, Component, Prop, Emit } from 'vue-property-decorator';
import './design-view-toolbar.less';
let DesignViewToolBar = class DesignViewToolBar extends Vue {
    /**
     * 绘制内容
     *
     * @param {CreateElement} h
     * @memberof DesignViewToolBar
     */
    render(h) {
        return (<div class='design-view-toolbar'>
                {this.toolbarModels
                ? this.toolbarModels.map((item) => {
                    return this.renderToolBarItem(item);
                })
                : null}
            </div>);
    }
    /**
     * 工具栏项单击事件
     *
     * @param {*} { tag }
     * @param {*} e
     * @memberof DesignViewToolBar
     */
    itemClick(uiAction, e) { }
    /**
     * @description 获取项样式名
     * @param {IPSDEToolbarItem} item
     * @return {*}
     * @memberof DesignViewToolBar
     */
    getItemClass(item) {
        const css = item.getPSSysCss();
        return css ? css.cssName : '';
    }
    /**
     * @description 绘制图标
     * @memberof DesignViewToolBar
     */
    renderIcon(item) {
        const sysImg = item.getPSSysImage();
        if (sysImg) {
            const menuItem = { iconcls: sysImg.cssClass, icon: sysImg.imagePath };
            return (<div class='icon' on-click={(e) => this.itemClick({ tag: item.name }, e)}>
                    <menu-icon item={menuItem}/>
                </div>);
        }
    }
    /**
     * 绘制工具栏项
     *
     * @param {ToolbarItem} item
     * @memberof DesignViewToolBar
     */
    renderToolBarItem(item) {
        return (<div class='toolbar-item' title={item.caption}>
                {item.showIcon ? this.renderIcon(item) : null}
                {item.showCaption ? (<i-button class={this.getItemClass(item)} on-click={(e) => this.itemClick({ tag: item.name }, e)}>
                        <span class='caption'>{item.caption}</span>
                    </i-button>) : ('')}
            </div>);
    }
};
__decorate([
    Prop()
], DesignViewToolBar.prototype, "toolbarModels", void 0);
__decorate([
    Emit('item-click')
], DesignViewToolBar.prototype, "itemClick", null);
DesignViewToolBar = __decorate([
    Component
], DesignViewToolBar);
export { DesignViewToolBar };
