Types
All types are exported from react-simple-tree-menu.
import type { TreeMenuProps, TreeMenuHandle, TreeMenuItem, TreeMenuChildren, TreeMenuClassNames, TreeMenuLabels, TreeNode, TreeNodeObject, TreeNodeInArray, LocaleFunction, MatchSearchFunction, Item, UnflattenResult,} from 'react-simple-tree-menu';LocaleFunctionProps
Section titled “LocaleFunctionProps”Argument to LocaleFunction. The open index signature
is how arbitrary user-attached fields (url, icon, …) flow through.
interface LocaleFunctionProps { label: string; [name: string]: unknown;}TreeNode
Section titled “TreeNode”Object-format node. The enclosing object’s property name is the key;
index orders siblings inside walk(). key is forbidden here (lives on
the outer object). Extends LocaleFunctionProps so custom fields pass
through.
interface TreeNode extends LocaleFunctionProps { index: number; key?: never; nodes?: TreeNodeObject;}TreeNodeObject
Section titled “TreeNodeObject”Object data format. Keys become node keys.
interface TreeNodeObject { [name: string]: TreeNode;}TreeNodeInArray
Section titled “TreeNodeInArray”Array-format node. Ordered by array position, so index is forbidden.
Extends LocaleFunctionProps.
interface TreeNodeInArray extends LocaleFunctionProps { key: string; index?: never; nodes?: TreeNodeInArray[];}See Item under TreeMenu.
TreeMenuClassNames
Section titled “TreeMenuClassNames”See the classNames slot table.
TreeMenuLabels
Section titled “TreeMenuLabels”interface TreeMenuLabels { searchPlaceholder?: string; searchAriaLabel?: string;}LocaleFunction
Section titled “LocaleFunction”type LocaleFunction = (props: LocaleFunctionProps) => string;Receives the entire node (not just the label) so a transformer can branch on custom fields. Pass a stable reference — the internal walk memo keys on identity.
MatchSearchFunction
Section titled “MatchSearchFunction”interface MatchSearchFunctionProps extends LocaleFunctionProps { searchTerm: string;}
type MatchSearchFunction = (props: MatchSearchFunctionProps) => boolean;Same shape as the locale argument with searchTerm added. Also should
be a stable reference.
UnflattenResult<T>
Section titled “UnflattenResult<T>”Return type of unflatten:
interface UnflattenResult<T> { roots: T[]; childrenByParent: Map<string, T[]>;}