import { type JSONPatchAdd, type JSONPatchCopy, type JSONPatchDocument, type JSONPatchMove, type JSONPatchRemove, type JSONPath } from 'immutable-json-patch'; import type { ArrayDocumentState, CaretPosition, DocumentState, ObjectDocumentState, OnExpand, RecursiveState, RecursiveStateFactory, Section, ValueDocumentState, VisibleSection } from '../types'; export type CreateRecursiveStateProps = { json: unknown | undefined; factory: RecursiveStateFactory; }; export declare function createRecursiveState({ json, factory }: CreateRecursiveStateProps): RecursiveState | undefined; export type CreateDocumentStateProps = { json: unknown | undefined; expand?: OnExpand; }; export declare function createDocumentState({ json, expand }: CreateDocumentStateProps): DocumentState | undefined; export declare function createArrayDocumentState({ expanded }?: { expanded: boolean; }): ArrayDocumentState; export declare function createObjectDocumentState({ expanded }?: { expanded: boolean; }): ObjectDocumentState; export declare function createValueDocumentState(): ValueDocumentState; export declare const documentStateFactory: RecursiveStateFactory; export declare function ensureRecursiveState(json: unknown, documentState: T | undefined, path: JSONPath, { createObjectDocumentState, createArrayDocumentState, createValueDocumentState }: RecursiveStateFactory): T; export declare function syncDocumentState(json: unknown, documentState: DocumentState | undefined, path?: JSONPath): DocumentState | undefined; /** * Invoke a callback function for every visible item in the array */ export declare function forEachVisibleIndex(jsonArray: Array, visibleSections: VisibleSection[], callback: (index: number) => void): void; export declare function expandVisibleSection(state: ArrayDocumentState, index: number): ArrayDocumentState; export declare function toRecursiveStatePath(json: unknown, path: JSONPath): JSONPath; /** * Expand all nodes along the given path, and expand invisible array sections if needed. * Then, optionally expand child nodes according to the provided callback. */ export declare function expandPath(json: unknown | undefined, documentState: DocumentState | undefined, path: JSONPath, callback: OnExpand): DocumentState | undefined; export declare function collapsePath(json: unknown, documentState: DocumentState | undefined, path: JSONPath, recursive: boolean): DocumentState | undefined; /** * Expand a section of items in an array */ export declare function expandSection(json: unknown, documentState: DocumentState | undefined, path: JSONPath, section: Section): DocumentState | undefined; export declare function syncKeys(actualKeys: string[], prevKeys?: string[]): string[]; /** * Apply patch operations to both json and state */ export declare function documentStatePatch(json: unknown, documentState: DocumentState | undefined, operations: JSONPatchDocument): { json: unknown; documentState: DocumentState | undefined; }; export declare function getInRecursiveState(json: unknown, documentState: T | undefined, path: JSONPath): T | undefined; export declare function setInRecursiveState(json: unknown, recursiveState: T | undefined, path: JSONPath, value: unknown, factory: RecursiveStateFactory): T | undefined; export declare function updateInRecursiveState(json: unknown, documentState: T | undefined, path: JSONPath, transform: (value: unknown, state: T) => T | undefined, factory: RecursiveStateFactory): T; export declare function setInDocumentState(json: unknown | undefined, documentState: T | undefined, path: JSONPath, value: unknown): T | undefined; export declare function updateInDocumentState(json: unknown | undefined, documentState: T | undefined, path: JSONPath, transform: (value: unknown, state: T) => T | undefined): T; export declare function deleteInDocumentState(json: unknown | undefined, documentState: T | undefined, path: JSONPath): T | undefined; export declare function documentStateAdd(json: unknown, documentState: DocumentState | undefined, operation: JSONPatchAdd, stateValue: DocumentState | undefined): DocumentState | undefined; export declare function documentStateRemove(json: unknown, documentState: DocumentState | undefined, operation: JSONPatchRemove): DocumentState | undefined; export declare function documentStateMoveOrCopy(json: unknown, documentState: DocumentState | undefined, operation: JSONPatchCopy | JSONPatchMove): DocumentState | undefined; /** * Shift visible sections in an Array with a specified offset */ export declare function shiftVisibleSections(visibleSections: VisibleSection[], index: number, offset: number): VisibleSection[]; export declare function getEnforceString(json: unknown, documentState: DocumentState | undefined, path: JSONPath): boolean; export declare function getNextKeys(keys: string[], key: string, includeKey?: boolean): string[]; /** * Get all paths which are visible and rendered */ export declare function getVisiblePaths(json: unknown, documentState: DocumentState | undefined): JSONPath[]; /** * Get all caret position which are visible and rendered: * before a node, at a key, at a value, appending an object/array */ export declare function getVisibleCaretPositions(json: unknown, documentState: DocumentState | undefined, includeInside?: boolean): CaretPosition[]; /** * Find the previous visible path. * This can be the last child of the previous object or array, or the parent of a first entry. */ export declare function getPreviousVisiblePath(json: unknown, documentState: DocumentState | undefined, path: JSONPath): JSONPath | undefined; /** * Find the next visible path. * This can be the next parent entry. */ export declare function getNextVisiblePath(json: unknown, documentState: DocumentState | undefined, path: JSONPath): JSONPath | undefined; /** * Expand recursively when the expanded contents is small enough, * else expand in a minimalistic way */ export declare function expandSmart(json: unknown | undefined, documentState: DocumentState | undefined, path: JSONPath, maxSize?: number): DocumentState | undefined; export declare function expandSmartIfCollapsed(json: unknown | undefined, documentState: DocumentState | undefined, path: JSONPath): DocumentState | undefined; /** * Expand the root array or object, and in case of an array, expand the first array item */ export declare function expandMinimal(relativePath: JSONPath): boolean; /** * Expand the root array or object */ export declare function expandSelf(relativePath: JSONPath): boolean; export declare function expandAll(): boolean; export declare function expandNone(): boolean;