UNPKG

@lonli-lokli/react-mosaic-component

Version:
62 lines (59 loc) 2.85 kB
import { DropInfo, MosaicDropTargetPosition } from '../internalTypes.js'; import { v as MosaicKey, f as MosaicUpdate, g as MosaicUpdateSpec, M as MosaicNode, e as MosaicPath } from '../../types-D_JoxNST.js'; import 'immutability-helper'; import 'react'; /** * Used to prepare `update` for `immutability-helper` * @param mosaicUpdate * @returns {any} */ declare function buildSpecFromUpdate<T extends MosaicKey>(mosaicUpdate: MosaicUpdate<T>): MosaicUpdateSpec<T>; /** * Applies a list of updates to a tree and returns the new tree. * * @param tree The tree to be updated. * @param updates An array of MosaicUpdate objects. * @returns The new, updated tree. */ declare function updateTree<T extends MosaicKey>(tree: MosaicNode<T>, updates: MosaicUpdate<T>[]): MosaicNode<T>; /** * Creates a `MosaicUpdate<T>` to remove the node at `path` from `root` * @param root * @param path * @returns {{path: MosaicPath, spec: MosaicUpdateSpec<T>}} */ declare function createRemoveUpdate<T extends MosaicKey>(root: MosaicNode<T> | null, path: MosaicPath): MosaicUpdate<T>; /** * Creates a `MosaicUpdate<T>` to split the _leaf_ at `destinationPath` into a node of it and the node from `sourcePath` * placing the node from `sourcePath` in `position`. * @param root * @param sourcePath * @param destinationPath * @param dropInfo * @returns {MosaicUpdate<T>[]} */ declare function createDragToUpdates<T extends MosaicKey>(root: MosaicNode<T>, sourcePath: MosaicPath, destinationPath: MosaicPath, dropInfo: DropInfo): MosaicUpdate<T>[]; /** * Sets the splitPercentages to hide the node at `path` * @param root * @param path * @returns {{path: MosaicPath, spec: MosaicUpdateSpec<T>}} */ declare function createHideUpdate<T extends MosaicKey>(root: MosaicNode<T> | null, path: MosaicPath): MosaicUpdate<T>; /** * Sets the splitPercentages of node at `path` and all of its parents to expand the target node * @param path * @param percentage * @returns {{spec: MosaicUpdateSpec<T>, path: MosaicPath}} */ declare function createExpandUpdate<T extends MosaicKey>(path: MosaicPath, percentage: number): MosaicUpdate<T>; /** * Helper function to create an update that adds a new child to a split node * @param path Path to the split node * @param newChild The new child to add * @param insertIndex Index where to insert the new child (optional, defaults to end) * @returns MosaicUpdate to add the child */ declare function createAddChildUpdate<T extends MosaicKey>(path: MosaicPath, newChild: MosaicNode<T>, insertIndex?: number): MosaicUpdate<T>; declare function convertToDropInfo(position: MosaicDropTargetPosition | undefined, tabReorderIndex?: number): DropInfo; export { buildSpecFromUpdate, convertToDropInfo, createAddChildUpdate, createDragToUpdates, createExpandUpdate, createHideUpdate, createRemoveUpdate, updateTree };