discourse/app/assets/javascripts/select-kit/addon/components/flair-chooser.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

33 lines
846 B
JavaScript
Raw Normal View History

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;
}
}
}