@itwin/presentation-hierarchies-react
Version:
React components based on `@itwin/presentation-hierarchies`
56 lines • 2.86 kB
TypeScript
import "./TreeNodeRenderer.css";
import { ComponentPropsWithoutRef, ReactElement, RefAttributes } from "react";
import { TreeNode } from "@itwin/itwinui-react";
import { PresentationHierarchyNode } from "../TreeNode.js";
import { HierarchyLevelDetails, UseTreeResult } from "../UseTree.js";
import { RenderedTreeNode } from "./TreeRenderer.js";
/** @public */
type TreeNodeProps = ComponentPropsWithoutRef<typeof TreeNode>;
/** @public */
interface TreeNodeRendererOwnProps {
/** Node that is rendered. */
node: RenderedTreeNode;
/** Action to perform when the filter button is clicked for this node. */
onFilterClick?: (hierarchyLevelDetails: HierarchyLevelDetails) => void;
/** Returns an icon for a given node. */
getIcon?: (node: PresentationHierarchyNode) => ReactElement | undefined;
/** Returns a label for a given node. */
getLabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;
/** Returns sublabel for a given node. */
getSublabel?: (node: PresentationHierarchyNode) => ReactElement | undefined;
/** Action to perform when the node is clicked. */
onNodeClick?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
/** Action to perform when a key is pressed when the node is hovered on. */
onNodeKeyDown?: (node: PresentationHierarchyNode, isSelected: boolean, event: React.KeyboardEvent<HTMLElement>) => void;
/** A callback to reload a hierarchy level when an error occurs and `retry` button is clicked. */
reloadTree?: (options: {
parentNodeId: string | undefined;
state: "reset";
}) => void;
/** CSS class name for the action buttons. */
actionButtonsClassName?: string;
/** Tree node size. Should match the size passed to `TreeRenderer` component. */
size?: "default" | "small";
/**
* Configures filter buttons visibility.
*
* Options:
* - `show-on-hover` - show filter buttons when hovering over node, or the node is in focus.
* - `hide` - hide filter buttons, but will show them if the filter is applied.
*
* Default value: `show-on-hover`
*/
filterButtonsVisibility?: "show-on-hover" | "hide";
}
/** @public */
type TreeNodeRendererProps = Pick<UseTreeResult, "expandNode"> & Partial<Pick<UseTreeResult, "getHierarchyLevelDetails">> & Omit<TreeNodeProps, "label" | "onExpanded" | "onSelected" | "icon"> & TreeNodeRendererOwnProps;
/**
* A component that renders `RenderedTreeNode` using the `TreeNode` component from `@itwin/itwinui-react`.
*
* @see `TreeRenderer`
* @see https://itwinui.bentley.com/docs/tree
* @public
*/
export declare const TreeNodeRenderer: React.ForwardRefExoticComponent<TreeNodeRendererProps & RefAttributes<HTMLDivElement>>;
export {};
//# sourceMappingURL=TreeNodeRenderer.d.ts.map