import { NodeButton } from "../../../base/single/button/button.node"; import { shortcut, extend, createWidget, Controller } from "../../../core"; /** * Created by User on 2016/3/31. * * > + icon + 文本 * @class IconArrowNode * @extends NodeButton */ @shortcut() export class IconArrowNode extends NodeButton { static xtype = "bi.icon_arrow_node"; _defaultConfig() { const conf = super._defaultConfig(arguments); return extend(conf, { baseCls: `${conf.baseCls || ""} bi-icon-arrow-node bi-list-item`, logic: { dynamic: false, }, id: "", pId: "", open: false, height: 24, iconHeight: 12, iconWidth: 12, iconCls: "", iconWrapperWidth: 16, }); } _init() { super._init.apply(this, arguments); const o = this.options; this.checkbox = createWidget({ type: "bi.arrow_group_node_checkbox", expandIcon: o.expandIcon, collapseIcon: o.collapseIcon, width: 24, stopPropagation: true, }); const icon = createWidget({ type: "bi.icon_label", width: 24, cls: o.iconCls, iconWidth: o.iconWidth, iconHeight: o.iconHeight, }); createWidget({ type: "bi.label", textAlign: "left", whiteSpace: "nowrap", textHeight: o.height, height: o.height, hgap: o.hgap, text: o.text, value: o.value, py: o.py, keyword: o.keyword, }); this.checkbox.on(Controller.EVENT_CHANGE, type => { if (type === BI.Events.CLICK) { if (this.checkbox.isSelected()) { this.triggerExpand(); } else { this.triggerCollapse(); } } }); const type = BI.LogicFactory.createLogicTypeByDirection(BI.Direction.Left); const items = BI.LogicFactory.createLogicItemsByDirection(BI.Direction.Left, { width: o.iconWrapperWidth, el: this.checkbox, }, { width: 16, el: icon, }, this.text); createWidget(extend({ element: this, }, BI.LogicFactory.createLogic(type, extend(o.logic, { items, rgap: 5, })))); } doRedMark () { this.text.doRedMark(...arguments); } unRedMark() { this.text.unRedMark(...arguments); } doClick() { BI.IconArrowNode.superclass.doClick.apply(this, arguments); this.checkbox.setSelected(this.isSelected()); } setOpened(v) { BI.IconArrowNode.superclass.setOpened.apply(this, arguments); if (BI.isNotNull(this.checkbox)) { this.checkbox.setSelected(v); } } }