import { IgnoreAccents, MatchRange } from "../../utilities/diacritics.mjs"; import "../../utilities/index.mjs"; import { MaybeRefOrGetter } from "vue"; //#region src/composables/toHighlight/index.d.ts /** * A contiguous chunk of source text, flagged as matched or unmatched. * * @example * ```ts * import type { HighlightChunk } from '@vuetify/v0' * * const chunk: HighlightChunk = { text: 'Hello', match: true } * ``` */ interface HighlightChunk { text: string; match: boolean; } /** * Optional configuration for {@link toHighlight}. * * @example * ```ts * import { toHighlight } from '@vuetify/v0' * * const chunks = toHighlight('Hello World', 'WORLD', { * ignoreCase: true, * matchAll: true, * }) * ``` */ interface ToHighlightOptions { /** * Pre-computed `[start, end]` index pairs. * When non-empty, takes priority over `query`. `matchAll` is ignored. * Caller-supplied ranges are sorted and merged before chunking, so * unsorted or overlapping input is handled gracefully. */ matches?: MaybeRefOrGetter; /** * Highlight every occurrence (`true`) or only the first per term (`false`, default). * Ignored when `matches` is provided. */ matchAll?: MaybeRefOrGetter; /** Case-insensitive matching. Default `false`. */ ignoreCase?: MaybeRefOrGetter; /** * Folds accents before matching. `'query'` folds only the search term, * `'target'` only the text, `true` both sides. Default `false`. */ ignoreAccents?: MaybeRefOrGetter; } /** * Splits text into matched and unmatched chunks. * * Pure transformer — returns a plain array. Wrap the call in `computed()` for * reactive recomputation. * * Priority: `options.matches` (when non-empty) → `query` → no-match fallback. * * @param text The source string to split. * @param query One or more search terms. Empty strings are ignored. Case sensitivity controlled by `options.ignoreCase`. * @param options Optional `matches`, `matchAll`, `ignoreCase`, `ignoreAccents`. * @returns A `HighlightChunk[]` array. * * @see https://0.vuetifyjs.com/composables/transformers/to-highlight * * @example * ```ts * import { computed, shallowRef } from 'vue' * import { toHighlight } from '@vuetify/v0' * * const query = shallowRef('World') * const chunks = computed(() => toHighlight('Hello World', query)) * * console.log(chunks.value) * // [{ text: 'Hello ', match: false }, { text: 'World', match: true }] * ``` */ declare function toHighlight(text: MaybeRefOrGetter, query?: MaybeRefOrGetter, options?: ToHighlightOptions): HighlightChunk[]; //#endregion export { HighlightChunk, type MatchRange, ToHighlightOptions, toHighlight };