This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/select-kit/components/select-kit/select-kit-header.js.es6
Joffrey JAFFEUX 3287ac77e0
FIX: reverts combobox placeholder and introduces noneLabel
noneLabels works almost like none but instead of actually adding a row in the list, it will only change the text displayed in the header, when there's no selection.
2018-03-29 13:42:00 +02:00

46 lines
1.2 KiB
JavaScript

import computed from "ember-addons/ember-computed-decorators";
const { isEmpty, makeArray } = Ember;
export default Ember.Component.extend({
layoutName: "select-kit/templates/components/select-kit/select-kit-header",
classNames: ["select-kit-header"],
classNameBindings: ["isFocused", "isNone"],
attributeBindings: [
"tabindex",
"ariaLabel:aria-label",
"ariaHasPopup:aria-haspopup",
"title",
"value:data-value",
"name:data-name",
],
isNone: Ember.computed.none("computedContent.value"),
ariaHasPopup: true,
ariaLabel: Ember.computed.or("computedContent.ariaLabel", "title"),
@computed("computedContent.title", "name")
title(computedContentTitle, name) {
if (computedContentTitle) return computedContentTitle;
if (name) return name;
return null;
},
label: Ember.computed.or("computedContent.label", "title", "name"),
name: Ember.computed.alias("computedContent.name"),
value: Ember.computed.alias("computedContent.value"),
@computed("computedContent.icon", "computedContent.icons")
icons(icon, icons) {
return makeArray(icon).concat(icons).filter(i => !isEmpty(i));
},
click() {
this.sendAction("onToggle");
}
});