1
0
Fork 0
mirror of https://github.com/eosswedenorg/apt synced 2026-06-16 04:34:56 +02:00
apt/assets/js/modules/alpine_search.js

36 lines
703 B
JavaScript

import pkg_idx from './pkg_idx'
// Alpine search component
export default () => ({
show: false,
query: "",
getResults() {
if (this.query.length < 1) {
return [];
}
var results = pkg_idx.search(this.query).slice(0, 10);
var list = results.map(function (item) {
return package_data.filter(function (v, i, arr) {
return v.id == item.ref;
})[0];
});
this.open();
return list;
},
toggle() {
this.show = ! this.show;
},
open() {
this.show = true;
},
close() {
this.show = false;
},
isOpen() {
return this.show;
}
})