import { ContextTrinity } from "../createTrinity/index.mjs"; import { ComputedRef, MaybeRefOrGetter, ShallowRef } from "vue"; //#region src/composables/createFilter/index.d.ts type Primitive = string | number | boolean; type FilterQuery = MaybeRefOrGetter; type FilterItem = Primitive | Record; type FilterMode = 'some' | 'every' | 'union' | 'intersection'; type FilterFunction = (query: Primitive | Primitive[], item: FilterItem) => boolean; interface FilterOptions { customFilter?: FilterFunction; keys?: MaybeRefOrGetter; mode?: FilterMode; } interface FilterResult { items: ComputedRef; } interface FilterContext { /** The filter mode */ mode: FilterMode; /** Keys to filter on for object items */ keys: MaybeRefOrGetter | undefined; /** Custom filter function */ customFilter: FilterFunction | undefined; /** Current query ref */ query: ShallowRef; /** * Apply filter to an array of items * * @param query The query to filter by * @param items The items to filter * @returns The filtered items as a computed ref */ apply: (query: FilterQuery, items: MaybeRefOrGetter) => FilterResult; } interface FilterContextOptions extends FilterOptions { namespace?: string; } /** * Creates a filter context with pre-configured options. * * @param options The filter options * @template Z The type of the items * @template E The type of the filter context * @returns A filter context * * @see https://0.vuetifyjs.com/composables/data/create-filter * * @example * ```ts * import { createFilter } from '@vuetify/v0' * * const filter = createFilter({ * mode: 'intersection', * keys: ['name', 'email'], * }) * * const { items } = filter.apply(query, users) * ``` */ declare function createFilter = FilterContext>(options?: FilterOptions): E; /** * Creates a filter context with dependency injection support. * * @param options The filter context options * @template Z The type of the items * @template E The type of the filter context * @returns A trinity tuple: [useContext, provideContext, defaultContext] * * @see https://0.vuetifyjs.com/composables/data/create-filter * * @example * ```ts * import { createFilterContext } from '@vuetify/v0' * * export const [useSearchFilter, provideSearchFilter, searchFilter] = createFilterContext({ * namespace: 'app:search', * mode: 'union', * keys: ['title', 'description'], * }) * * // In parent component * provideSearchFilter() * * // In child component * const filter = useSearchFilter() * const { items } = filter.apply(query, products) * ``` */ declare function createFilterContext = FilterContext>(_options?: FilterContextOptions): ContextTrinity; /** * Returns the current filter context from dependency injection. * * @param namespace The namespace for the filter context. Defaults to `'v0:filter'`. * @template Z The type of the items. * @template E The type of the filter context. * @returns The current filter context. * * @see https://0.vuetifyjs.com/composables/data/create-filter * * @example * ```vue * * ``` */ declare function useFilter = FilterContext>(namespace?: string): E; //#endregion export { FilterContext, FilterContextOptions, FilterFunction, FilterItem, FilterMode, FilterOptions, FilterQuery, FilterResult, Primitive, createFilter, createFilterContext, useFilter };