/// import { Input, MenuItem } from '../index.js'; import { type SxProps, type Theme } from '@mui/material/styles'; import { PopperProps } from '@mui/material/Popper'; export type TreeNodeIcon = { fileId: string; width?: number | string; height?: number | string; }; export type ExtendableObject = T extends Record ? T & Record : never; export type OnTreeMountedParams = { state: TreeMapper; tree: TreeNode[]; selectedTree: TreeNode[]; }; export type TreeDropdownProps = { onMounted?: (params: OnTreeMountedParams) => void; onChange?: (tree: TreeNode[]) => void; multiple?: boolean; anchorEl: HTMLElement | null; placement?: PopperProps['placement']; sx?: SxProps; treeDefinition: TreeDefinition; exposeOnlySelectedTree?: boolean; IconComponent?: React.ComponentType<{ fileId: string; width?: number | string; height?: number | string; }>; }; export type TreeDropdownRef = { treeMapper: TreeMapper; getFullTree: () => TreeNode[]; getSelectedTree: () => TreeNode[]; toggleAll: (selected: boolean) => void; }; export type TreeNode = ExtendableObject<{ id: string; label?: React.ReactNode; hintText?: React.ReactNode; icon?: TreeNodeIcon; iconComponent?: React.ReactNode; itemProps?: React.ComponentProps; renderItem?: (params: { nodeProps: TreeNode; checked?: boolean; indeterminate?: boolean; onSelect: (e: React.ChangeEvent) => void; }) => React.ReactNode; }> & TreeDefinition; export type TreeDefinition = { header?: React.ReactNode; footer?: React.ReactNode; /** * [Optional] Used to determine the level of the node in the tree * It will appear as data attribute over the list element. * ``` *
...
* ``` */ levelKey?: string; searchProps?: { /** * ### [Required For Search, unless `filterItem` is provided] * The function to get the value of the item for the search */ getValues?: (item: TreeNode) => string[]; /** * [Optional] Advanced filtering hook. Given an item and the (lowercased) search * text, return the item (optionally with a pruned subtree) to keep it, or `null` * to drop it. Takes precedence over `getValues` when provided. */ filterItem?: (item: TreeNode, searchText: string) => TreeNode | null; onChange?: (e: React.ChangeEvent) => void; noResultsText?: React.ReactNode; inputProps?: React.ComponentProps; }; children?: TreeNode[]; disablePromotion?: boolean; status?: `${SelectedState}`; }; export declare enum SelectedState { CHECKED = "CHECKED", UNCHECKED = "UNCHECKED", INDETERMINATE = "INDETERMINATE" } export type SelectedItems = { [key: string]: `${SelectedState}`; }; export type TreeMapper = { [nodeKey: string]: { status: `${SelectedState}`; _parents?: string[]; }; };