Files
sigpro-ui/sigpro-helpers.js
natxocc 627bfd78ad
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 4s
Toast tiene el ancho para cada uno
2026-04-27 18:20:10 +02:00

8 lines
673 B
JavaScript

// Helpers
export const get = val => typeof val === "function" ? val() : val;
export const getBy = (item, field = 'label') => (item && typeof item === 'object') ? item[field] : item;
export const cls = (...classes) => classes.filter(Boolean).join(' ').trim();
export const isFn = f => typeof f === "function";
export const filterBy = (items, query, field = 'label', q = String(query).toLowerCase()) => !query ? get(items) : get(items).filter(item => String(item && typeof item === 'object' ? item[field] : item).toLowerCase().includes(q));
export const rand = (r) => `${r}-${Math.random().toString(36).slice(2, 9)}`
export const close = () => document.activeElement?.blur()