|
|
|
import { shortcut, extend, isKey, createWidget, isEmptyString } from "@/core";
|
|
|
|
import { Trigger } from "@/base";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 文字trigger
|
|
|
|
*
|
|
|
|
* Created by GUY on 2015/9/15.
|
|
|
|
* @class IconTextTrigger
|
|
|
|
* @extends Trigger
|
|
|
|
*/
|
|
|
|
@shortcut()
|
|
|
|
export class IconTextTrigger extends Trigger {
|
|
|
|
static xtype = "bi.icon_text_trigger"
|
|
|
|
|
|
|
|
_defaultConfig() {
|
|
|
|
const conf = super._defaultConfig(...arguments);
|
|
|
|
|
|
|
|
return extend(conf, {
|
|
|
|
baseCls: `${conf.baseCls || ""} bi-text-trigger`,
|
|
|
|
height: 24,
|
|
|
|
iconHeight: null,
|
|
|
|
iconWidth: null,
|
|
|
|
textCls: "",
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
_init() {
|
|
|
|
super._init(...arguments);
|
|
|
|
const o = this.options;
|
|
|
|
this.text = createWidget({
|
|
|
|
type: "bi.label",
|
|
|
|
cls: `select-text-label${isKey(o.textCls) ? (` ${o.textCls}`) : ""}`,
|
|
|
|
textAlign: "left",
|
|
|
|
height: o.height,
|
|
|
|
hgap: o.textHgap,
|
|
|
|
vgap: o.textVgap,
|
|
|
|
lgap: o.textLgap,
|
|
|
|
rgap: o.textRgap,
|
|
|
|
tgap: o.textTgap,
|
|
|
|
bgap: o.textBgap,
|
|
|
|
text: o.text,
|
|
|
|
});
|
|
|
|
this.trigerButton = createWidget({
|
|
|
|
type: "bi.trigger_icon_button",
|
|
|
|
width: o.triggerWidth || o.height,
|
|
|
|
});
|
|
|
|
|
|
|
|
createWidget({
|
|
|
|
element: this,
|
|
|
|
type: "bi.horizontal_fill",
|
|
|
|
columnSize: ["", "fill", ""],
|
|
|
|
ref: _ref => {
|
|
|
|
this.wrapper = _ref;
|
|
|
|
},
|
|
|
|
items: [{
|
|
|
|
el: {
|
|
|
|
type: "bi.icon_change_button",
|
|
|
|
cls: "icon-combo-trigger-icon",
|
|
|
|
width: o.triggerWidth || o.height,
|
|
|
|
iconCls: o.iconCls,
|
|
|
|
invisible: !o.iconCls,
|
|
|
|
ref: _ref => {
|
|
|
|
this.icon = _ref;
|
|
|
|
},
|
|
|
|
iconHeight: o.iconHeight,
|
|
|
|
iconWidth: o.iconWidth,
|
|
|
|
disableSelected: true,
|
|
|
|
},
|
|
|
|
}, {
|
|
|
|
el: this.text,
|
|
|
|
lgap: isEmptyString(o.iconCls) ? 5 : 0,
|
|
|
|
}, {
|
|
|
|
el: this.trigerButton,
|
|
|
|
}],
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
setValue(value) {
|
|
|
|
this.text.setValue(value);
|
|
|
|
}
|
|
|
|
|
|
|
|
setIcon(iconCls) {
|
|
|
|
this.icon.setIcon(iconCls);
|
|
|
|
this.icon.setVisible(!!iconCls);
|
|
|
|
}
|
|
|
|
|
|
|
|
setTextCls(cls) {
|
|
|
|
const o = this.options;
|
|
|
|
const oldCls = o.textCls;
|
|
|
|
o.textCls = cls;
|
|
|
|
this.text.element.removeClass(oldCls).addClass(cls);
|
|
|
|
}
|
|
|
|
|
|
|
|
setText(text) {
|
|
|
|
this.text.setText(text);
|
|
|
|
}
|
|
|
|
}
|