Autocomplete works with array and objects
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
This commit is contained in:
8
dist/sigpro-ui.js
vendored
8
dist/sigpro-ui.js
vendored
@@ -667,7 +667,11 @@
|
||||
var val = (val2) => typeof val2 === "function" ? val2() : val2;
|
||||
var getBy = (item, field = "label") => item && typeof item === "object" ? item[field] : item;
|
||||
var cls = (...classes) => classes.filter(Boolean).join(" ").trim();
|
||||
var filterBy = (items, query, field = "label", q = String(query).toLowerCase()) => !query ? val(items) : val(items).filter((item) => String(item && typeof item === "object" ? item[field] : item).toLowerCase().includes(q));
|
||||
var filterBy = (items, query, field = "label") => {
|
||||
const q = String(val(query) || "").toLowerCase();
|
||||
const list = (val(items) || []).map((i) => typeof i === "object" ? i : { label: i, value: i });
|
||||
return !q ? list : list.filter((item) => String(item[field] || "").toLowerCase().includes(q));
|
||||
};
|
||||
var rand = (r) => `${r}-${Math.random().toString(36).slice(2, 9)}`;
|
||||
var hide = () => document.activeElement?.blur();
|
||||
var lang = {
|
||||
@@ -724,7 +728,7 @@
|
||||
onmousedown: (e) => e.preventDefault(),
|
||||
onclick: () => pick(item)
|
||||
}, getBy(item))
|
||||
]), (item) => getBy(item)),
|
||||
]), "value"),
|
||||
() => filtered().length === 0 ? h("li", { class: "p-4 opacity-50 text-center" }, "Sin resultados") : null
|
||||
]))
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user