import { MaybeElementRef } from "../toElement/index.mjs"; import { ObserverReturn } from "../createObserver/index.mjs"; //#region src/composables/useMutationObserver/index.d.ts interface ObservableNodeList { readonly length: number; item: (index: number) => Node | null; forEach: (callback: (node: Node, index: number, list: ObservableNodeList) => void) => void; [Symbol.iterator]: () => Iterator; } interface MutationObserverRecord { type: 'attributes' | 'childList' | 'characterData'; target: Node; addedNodes: ObservableNodeList; removedNodes: ObservableNodeList; previousSibling: Node | null; nextSibling: Node | null; attributeName: string | null; attributeNamespace: string | null; oldValue: string | null; } interface UseMutationObserverOptions { immediate?: boolean; once?: boolean; childList?: boolean; attributes?: boolean; characterData?: boolean; subtree?: boolean; attributeOldValue?: boolean; characterDataOldValue?: boolean; attributeFilter?: string[]; } interface UseMutationObserverReturn extends ObserverReturn {} /** * A composable that uses the Mutation Observer API to detect changes in the DOM. * * @param target The element to observe. * @param callback The callback to execute when a mutation is observed. * @param options The options for the Mutation Observer. * @returns An object with methods to control the observer. * * @see https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver * @see https://0.vuetifyjs.com/composables/system/use-mutation-observer * * @example * ```ts * import { ref } from 'vue' * import { useMutationObserver } from '@vuetify/v0' * * const container = ref() * * const { pause, resume, isPaused } = useMutationObserver( * container, * (mutations) => { * mutations.forEach((mutation) => { * if (mutation.type === 'childList') { * console.log('Children changed:', mutation.addedNodes, mutation.removedNodes) * } else if (mutation.type === 'attributes') { * console.log('Attribute changed:', mutation.attributeName) * } * }) * }, * { * childList: true, * attributes: true, * subtree: true * } * ) * * // Pause observation * pause() * * // Resume observation * resume() * ``` */ declare function useMutationObserver(target: MaybeElementRef, callback: (entries: MutationObserverRecord[]) => void, options?: UseMutationObserverOptions): UseMutationObserverReturn; //#endregion export { MutationObserverRecord, ObservableNodeList, UseMutationObserverOptions, UseMutationObserverReturn, useMutationObserver };