2017-11-21 05:53:09 -05:00
|
|
|
import SingleSelectComponent from "select-kit/components/single-select";
|
2018-06-15 11:03:24 -04:00
|
|
|
import {
|
|
|
|
on,
|
2019-11-07 16:38:28 -05:00
|
|
|
default as discourseComputed
|
|
|
|
} from "discourse-common/utils/decorators";
|
2017-10-19 15:51:08 -04:00
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
export default SingleSelectComponent.extend({
|
|
|
|
pluginApiIdentifiers: ["combo-box"],
|
2017-10-19 15:51:08 -04:00
|
|
|
classNames: "combobox combo-box",
|
|
|
|
autoFilterable: true,
|
|
|
|
headerComponent: "combo-box/combo-box-header",
|
|
|
|
|
2018-04-12 04:56:32 -04:00
|
|
|
caretUpIcon: "caret-up",
|
|
|
|
caretDownIcon: "caret-down",
|
2017-10-19 15:51:08 -04:00
|
|
|
clearable: false,
|
|
|
|
|
2017-11-21 05:53:09 -05:00
|
|
|
computeHeaderContent() {
|
2019-01-19 04:05:51 -05:00
|
|
|
let content = this._super(...arguments);
|
2019-05-27 04:15:39 -04:00
|
|
|
content.hasSelection = this.hasSelection;
|
2017-11-21 05:53:09 -05:00
|
|
|
return content;
|
|
|
|
},
|
|
|
|
|
2019-11-07 16:38:28 -05:00
|
|
|
@discourseComputed("isExpanded", "caretUpIcon", "caretDownIcon")
|
2018-03-22 06:29:55 -04:00
|
|
|
caretIcon(isExpanded, caretUpIcon, caretDownIcon) {
|
|
|
|
return isExpanded ? caretUpIcon : caretDownIcon;
|
|
|
|
},
|
|
|
|
|
2019-05-10 11:12:10 -04:00
|
|
|
@on("didUpdateAttrs", "init")
|
2017-10-20 09:41:00 -04:00
|
|
|
_setComboBoxOptions() {
|
2019-05-27 04:15:39 -04:00
|
|
|
this.headerComponentOptions.setProperties({
|
|
|
|
clearable: this.clearable
|
2017-11-09 13:57:53 -05:00
|
|
|
});
|
2017-10-19 15:51:08 -04:00
|
|
|
}
|
|
|
|
});
|