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 3ec2024466
select-kit refactoring
* improve events naming/handling
* do not explicitly check for true/Fasle
* make sure header is re-computed on toggle
2018-01-11 09:39:51 +01:00

43 lines
1.1 KiB
JavaScript

import computed from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({
layoutName: "select-kit/templates/components/select-kit/select-kit-header",
classNames: ["select-kit-header", "select-box-kit-header"],
classNameBindings: ["isFocused"],
attributeBindings: [
"tabindex",
"ariaLabel:aria-label",
"ariaHasPopup:aria-haspopup",
"title",
"value:data-value",
"name:data-name",
],
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 Ember.makeArray(icon).concat(icons).filter(i => !Ember.isEmpty(i));
},
click() {
this.sendAction("toggle");
}
});