discourse/app/assets/javascripts/select-kit/addon/components/flair-chooser.js
David Taylor d1cc60c435
DEV: Convert select-kit components to native class syntax (#28489)
Changes made using the ember-native-class-codemod, plus some manual tweaks
2024-08-23 12:17:07 +01:00

33 lines
846 B
JavaScript

import { computed } from "@ember/object";
import { classNames } from "@ember-decorators/component";
import ComboBoxComponent from "select-kit/components/combo-box";
import {
pluginApiIdentifiers,
selectKitOptions,
} from "select-kit/components/select-kit";
@classNames("flair-chooser")
@selectKitOptions({
selectedNameComponent: "selected-flair",
})
@pluginApiIdentifiers(["flair-chooser"])
export default class FlairChooser extends ComboBoxComponent {
modifyComponentForRow() {
return "flair-row";
}
@computed("value", "content.[]", "selectKit.noneItem")
get selectedContent() {
const content = (this.content || []).findBy(
this.selectKit.valueProperty,
this.value
);
if (content) {
return this.selectKit.modifySelection(content);
} else {
return this.selectKit.noneItem;
}
}
}