UNPKG

@selenite/commons

Version:

This typescript package provides a set of frequently used utilities, types and svelte actions for building projects with Typescript and Svelte.

22 lines (21 loc) 760 B
import type { HTMLInputAttributes } from 'svelte/elements'; import type { StringArrayKeys, StringKeys } from '../type'; export interface Filter<T, K extends keyof T = keyof T> { key: K; value: unknown; active?: boolean; } export type FilterDefinition<T> = { key: keyof T; type?: HTMLInputAttributes['type']; }; export declare function getActiveFilters<T>(filters?: Iterable<Filter<T>>): Map<keyof T, Set<unknown>>; export declare function filterItems<T>({ items, filters }?: { items?: Iterable<T>; filters?: Iterable<Filter<T>>; }): T[]; export declare function getQueriedItems<T>({ items, query, queriedKeys }: { items?: Iterable<T>; query?: string; queriedKeys?: Iterable<StringKeys<T> | StringArrayKeys<T>>; }): T[];