import { BasicButton } from "../../base/single/button/button.basic"; import { shortcut, extend } from "../../core"; /** * guy * 单选框item * @type {*|void|Object} */ @shortcut() export class SingleSelectRadioItem extends BasicButton { static xtype = "bi.single_select_radio_item"; static EVENT_CHANGE = "EVENT_CHANGE"; _defaultConfig() { return extend(super._defaultConfig(arguments), { extraCls: "bi-single-select-radio-item", attributes: { tabIndex: 1, }, height: BI.SIZE_CONSANTS.LIST_ITEM_HEIGHT, iconWrapperWidth: 16, textHgap: 10, }); } render() { const o = this.options; return { type: "bi.vertical_adapt", columnSize: [o.iconWrapperWidth || o.height, "fill"], items: [{ type: "bi.center_adapt", items: [{ type: "bi.radio", ref: _ref => { this.radio = _ref; }, }], }, { el: { type: "bi.label", ref: _ref => { this.text = _ref; }, cls: "list-item-text", textAlign: "left", whiteSpace: "nowrap", textHeight: o.height, height: o.height, hgap: o.hgap || o.textHgap, vgap: o.textVgap, lgap: o.textLgap, rgap: o.textRgap, text: o.text, keyword: o.keyword, value: o.value, py: o.py, }, }], }; } _setEnable(enable) { super._setEnable(...arguments); if (enable === true) { this.element.attr("tabIndex", 1); } else if (enable === false) { this.element.removeAttr("tabIndex"); } } doRedMark() { this.text.doRedMark(...arguments); } unRedMark() { this.text.unRedMark(...arguments); } doClick() { super.doClick(...arguments); if (this.isValid()) { this.fireEvent(SingleSelectRadioItem.EVENT_CHANGE, this.isSelected(), this); } } setSelected(v) { super.setSelected(...arguments); this.radio.setSelected(v); } }