import Component from 'flarum/Component'; import LoadingIndicator from 'flarum/components/LoadingIndicator'; import ItemList from 'flarum/utils/ItemList'; import classList from 'flarum/utils/classList'; import icon from 'flarum/helpers/icon'; import DiscussionsSearchSource from 'flarum/components/DiscussionsSearchSource'; import UsersSearchSource from 'flarum/components/UsersSearchSource'; /** * The `Search` component displays a menu of as-you-type results from a variety * of sources. * * The search box will be 'activated' if the app's current controller implements * a `searching` method that returns a truthy value. If this is the case, an 'x' * button will be shown next to the search field, and clicking it will call the * `clearSearch` method on the controller. */ export default class Search extends Component { constructor(...args) { super(...args); /** * The value of the search input. * * @type {Function} */ this.value = m.prop(); /** * Whether or not the search input has focus. * * @type {Boolean} */ this.hasFocus = false; /** * An array of SearchSources. * * @type {SearchSource[]} */ this.sources = this.sourceItems().toArray(); /** * The number of sources that are still loading results. * * @type {Integer} */ this.loadingSources = 0; /** * A list of queries that have been searched for. * * @type {Array} */ this.searched = []; /** * The index of the currently-selected