-import {debounce} from "../services/util";
+import {debounce} from '../services/util.ts';
+import {transitionHeight} from '../services/animations.ts';
+import {Component} from './component';
-class DropdownSearch {
+export class DropdownSearch extends Component {
setup() {
this.elem = this.$el;
this.runLocalSearch(input);
} else {
this.toggleLoading(true);
+ this.listContainerElem.innerHTML = '';
this.runAjaxSearch(input);
}
}
runLocalSearch(searchTerm) {
const listItems = this.listContainerElem.querySelectorAll(this.localSearchSelector);
- for (let listItem of listItems) {
+ for (const listItem of listItems) {
const match = !searchTerm || listItem.textContent.toLowerCase().includes(searchTerm);
listItem.style.display = match ? 'flex' : 'none';
listItem.classList.toggle('hidden', !match);
try {
const resp = await window.$http.get(this.getAjaxUrl(searchTerm));
+ const animate = transitionHeight(this.listContainerElem, 80);
this.listContainerElem.innerHTML = resp.data;
+ animate();
} catch (err) {
console.error(err);
}
}
}
-
-export default DropdownSearch;
\ No newline at end of file