Files
sigpro-ui/sigpro-helpers.js
natxocc 5cfa3a231e
All checks were successful
Deploy Docs to Synology / deploy (push) Successful in 3s
Correct components errors
2026-04-29 17:49:29 +02:00

8 lines
672 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 hide = () => document.activeElement?.blur()