UNPKG

react-mosaic-component2

Version:
93 lines (90 loc) 3.48 kB
import { DragDropManager } from 'dnd-core'; import React__default, { ReactElement } from 'react'; import { MosaicKey, TileRenderer, MosaicNode, ResizeOptions } from './types.js'; import 'immutability-helper'; interface MosaicBaseProps<T extends MosaicKey> { /** * Lookup function to convert `T` to a displayable `ReactElement` */ renderTile: TileRenderer<T>; /** * Called when a user initiates any change to the tree (removing, adding, moving, resizing, etc.) */ onChange?: (newNode: MosaicNode<T> | null) => void; /** * Called when a user completes a change (fires like above except for the interpolation during resizing) */ onRelease?: (newNode: MosaicNode<T> | null) => void; /** * Additional classes to affix to the root element * Default: 'mosaic-blueprint-theme' */ className?: string; /** * Options that control resizing * @see: [[ResizeOptions]] */ resize?: ResizeOptions; /** * View to display when the current value is `null` * default: Simple NonIdealState view */ zeroStateView?: ReactElement; /** * Override the mosaicId passed to `react-dnd` to control how drag and drop works with other components * Note: does not support updating after instantiation * default: Random UUID */ mosaicId?: string; /** * Make it possible to use different versions of Blueprint with `mosaic-blueprint-theme` * Note: does not support updating after instantiation * default: 'bp3' */ blueprintNamespace?: string; /** * Override the react-dnd provider to allow applications to inject an existing drag and drop context */ dragAndDropManager?: DragDropManager | undefined; } interface MosaicControlledProps<T extends MosaicKey> extends MosaicBaseProps<T> { /** * The tree to render */ value: MosaicNode<T> | null; onChange: (newNode: MosaicNode<T> | null) => void; } interface MosaicUncontrolledProps<T extends MosaicKey> extends MosaicBaseProps<T> { /** * The initial tree to render, can be modified by the user */ initialValue: MosaicNode<T> | null; } type MosaicProps<T extends MosaicKey> = MosaicControlledProps<T> | MosaicUncontrolledProps<T>; interface MosaicState<T extends MosaicKey> { currentNode: MosaicNode<T> | null; lastInitialValue: MosaicNode<T> | null; mosaicId: string; } declare class MosaicWithoutDragDropContext<T extends MosaicKey = string> extends React__default.PureComponent<MosaicProps<T>, MosaicState<T>> { static defaultProps: { onChange: () => undefined; zeroStateView: React__default.JSX.Element; className: string; blueprintNamespace: string; }; static getDerivedStateFromProps(nextProps: Readonly<MosaicProps<MosaicKey>>, prevState: MosaicState<MosaicKey>): Partial<MosaicState<MosaicKey>> | null; state: MosaicState<T>; render(): React__default.JSX.Element; private getRoot; private updateRoot; private replaceRoot; private actions; private readonly childContext; private renderTree; private validateTree; } declare class Mosaic<T extends MosaicKey = string> extends React__default.PureComponent<MosaicProps<T>> { render(): React__default.JSX.Element; } export { Mosaic, type MosaicBaseProps, type MosaicControlledProps, type MosaicProps, type MosaicState, type MosaicUncontrolledProps, MosaicWithoutDragDropContext };