UNPKG

@dvcol/neo-svelte

Version:

Neomorphic ui library for svelte 5

18 lines (17 loc) 691 B
import { isSection } from './neo-list.model.js'; const itemMatch = (item, search) => item.label?.toLowerCase().includes(search) || item.description?.toLowerCase().includes(search); export const itemSearchFilter = (item, search) => { if (item?.hidden) return false; const pattern = search?.trim().toLowerCase(); if (!pattern?.length) return true; if (isSection(item)) return item.items?.some(i => itemMatch(i, pattern)); return !!itemMatch(item, pattern); }; export const itemLabelSort = (a, b, reverse) => { if (!a?.label || !b?.label) return 0; return reverse ? a.label.localeCompare(b.label) : b.label.localeCompare(a.label); };