forked from fanruan/fineui
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.0 KiB
83 lines
2.0 KiB
import { |
|
shortcut, |
|
extend, |
|
createWidget, |
|
Controller, |
|
Events, |
|
VerticalLayout, |
|
map |
|
} from "@/core"; |
|
import { Pane, ButtonGroup } from "@/base"; |
|
import { SingleSelectItem } from "../../button"; |
|
|
|
@shortcut() |
|
export class TextValueCheckComboPopup extends Pane { |
|
static xtype = "bi.text_value_check_combo_popup"; |
|
|
|
static EVENT_CHANGE = "EVENT_CHANGE"; |
|
|
|
_defaultConfig() { |
|
return extend(super._defaultConfig(...arguments), { |
|
baseCls: "bi-text-icon-popup", |
|
chooseType: ButtonGroup.CHOOSE_TYPE_SINGLE, |
|
}); |
|
} |
|
|
|
_init() { |
|
super._init(...arguments); |
|
const o = this.options; |
|
this.popup = createWidget({ |
|
type: ButtonGroup.xtype, |
|
items: this._formatItems(o.items), |
|
chooseType: o.chooseType, |
|
layouts: [ |
|
{ |
|
type: VerticalLayout.xtype, |
|
} |
|
], |
|
value: o.value, |
|
}); |
|
|
|
this.popup.on(Controller.EVENT_CHANGE, (...args) => { |
|
const [type, val, obj] = args; |
|
this.fireEvent(Controller.EVENT_CHANGE, ...args); |
|
if (type === Events.CLICK) { |
|
this.fireEvent(TextValueCheckComboPopup.EVENT_CHANGE, val, obj); |
|
} |
|
}); |
|
|
|
createWidget({ |
|
type: VerticalLayout.xtype, |
|
element: this, |
|
vgap: 5, |
|
items: [this.popup], |
|
}); |
|
} |
|
|
|
_formatItems(items) { |
|
const o = this.options; |
|
|
|
return map(items, (i, item) => extend( |
|
{ |
|
type: SingleSelectItem.xtype, |
|
cls: "bi-list-item", |
|
textAlign: o.textAlign, |
|
title: item.title || item.text, |
|
}, |
|
item |
|
)); |
|
} |
|
|
|
populate(items) { |
|
super.populate(...arguments); |
|
this.popup.populate(this._formatItems(items)); |
|
} |
|
|
|
getValue() { |
|
return this.popup.getValue(); |
|
} |
|
|
|
setValue(v) { |
|
this.popup.setValue(v); |
|
} |
|
}
|
|
|