@asup/tree-of-nodes
Version:
REACT Typescript Treeview component
69 lines (67 loc) • 2.4 kB
TypeScript
import { Key, CSSProperties, RefAttributes, ForwardRefExoticComponent, ReactNode } from "react";
import { JSX } from "react/jsx-runtime";
export interface INodeUpdate {
success: boolean;
ErrorText?: string;
}
export interface TreeNodeBase {
id: Key;
label: string;
parentId?: Key;
}
export interface TreeNodeData<T> extends TreeNodeBase {
data: T;
}
declare const getAncestors: (id: Key | Key[], included: TreeNodeBase[], hierarchyNodes: TreeNodeBase[]) => TreeNodeBase[];
interface WordEntryProps {
id: Key;
className?: string;
editing?: boolean;
saving?: boolean;
sendEscape?: () => void;
setValue?: (ret: string) => void;
spellCheck?: "true" | "false";
style?: CSSProperties;
value?: string;
}
export const WordEntry: ForwardRefExoticComponent<WordEntryProps & RefAttributes<HTMLInputElement>>;
interface TreeNodeProps {
id: Key;
indentLevel?: number;
canRemove?: boolean;
canRename?: boolean;
canAddChildren?: boolean;
canRemoveChildren?: boolean;
canRenameChildren?: boolean;
refresh?: () => void;
}
export const TreeNode: {
({ id, canRemove, canRename, canAddChildren, canRemoveChildren, canRenameChildren, }: TreeNodeProps): ReactNode;
displayName: string;
};
interface TreeOfNodesProps<T> {
alwaysShowSelected?: "always" | "first";
canAddChildren?: boolean;
canRemoveChildren?: boolean;
canRemoveRoot?: boolean;
canRenameChildren?: boolean;
canRenameRoot?: boolean;
handleSelect?: (ret: Key | Key[]) => void;
id: string;
initiallyExpandedNodes?: Key[];
nodeHighlight?: string;
nodeList: TreeNodeData<T>[];
onAdd?: (parentId: Key, newName: string) => Promise<INodeUpdate>;
onRemove?: (childId: Key) => Promise<INodeUpdate>;
onRename?: (childId: Key, newName: string) => Promise<INodeUpdate>;
roots: Key[];
selected?: Key | Key[];
showCheckBox?: boolean;
spellCheck?: "true" | "false";
textHighlight?: string;
}
export const TreeOfNodes: {
<T>({ alwaysShowSelected, canAddChildren, canRemoveChildren, canRemoveRoot, canRenameChildren, canRenameRoot, handleSelect, id, initiallyExpandedNodes, nodeHighlight, nodeList, onAdd, onRemove, onRename, roots, selected, showCheckBox, spellCheck, textHighlight, }: TreeOfNodesProps<T>): JSX.Element;
displayName: string;
};
//# sourceMappingURL=tree-of-nodes.d.ts.map