/*!
*
* Copyright (c) "Neo4j"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
import { type CommonProps, type TooltipObjectProps } from '../../_common/types';
import { Menu } from '../../menu';
import { type SelectionMode } from './selection';
type RootProps = {
/** The aria-label for the tree. Required for accessibility, unless using ariaLabelledby. Pass null to omit. */
ariaLabel: string | null;
/** The aria-labelledby for the tree. Pass a string of space-separated IDs of elements that label the tree. */
ariaLabelledby?: string;
/** The children of the tree. Should be TreeView.Item components or TreeView.SkeletonItem components only. */
children?: React.ReactNode;
/** Initially selected item ids for an uncontrolled root-managed selection. */
defaultSelectedIds?: string[];
/** Selected item ids. Makes the tree manage selection itself, instead of each item managing its own. */
selectedIds?: string[];
/** Selection mode for the tree. Defaults to "single". */
selectionMode?: SelectionMode;
/** Callback called with the complete next selection whenever the tree manages selection. Fires once per interaction. */
onSelectedIdsChange?: (selectedIds: string[]) => void;
};
type ItemProps = {
/** Nested TreeView.Item or TreeView.SkeletonItem elements rendered as sub-items in a collapsible group. */
children?: React.ReactNode;
/** The label content displayed in the item row. */
title?: React.ReactNode;
/** Default expansion for uncontrolled items */
defaultExpanded?: boolean;
/** Whether the item has children. Decides if the item should render a chevron for expansion. Needed for lazy loading. */
hasChildren?: boolean;
/** Identifies the item. Required when the tree manages selection via `selectedIds`. */
id?: string;
/** Whether the item is disabled */
isDisabled?: boolean;
/** Whether the item is expanded. Makes the item controlled. */
isExpanded?: boolean;
/** Whether the item is in an indeterminate state. Only meaningful in multi-select mode for parent nodes. */
isIndeterminate?: boolean;
/** Whether the item is loading. Applies aria-busy="true" to the item. */
isLoading?: boolean;
/** Whether the item can be selected. Defaults to true when the tree manages selection, and otherwise to whether `onSelectedChange` is set. */
isSelectable?: boolean;
/** Whether the item is selected. Ignored when the tree manages selection via `selectedIds`. */
isSelected?: boolean;
/** Leading visual for the item. */
leadingVisual?: React.ReactNode;
/** Trailing content for the item. Shown after the children but before the action menu. */
trailingContent?: React.ReactNode;
/** ReactNode containing Menu.Item elements to render in an action menu. When provided, an action button is rendered. */
actionMenuItems?: React.ReactNode;
/** Props forwarded to the Menu sub-components (anchorRef, onClose). */
actionMenuProps?: React.ComponentProps;
/** Content rendered inside the tooltip. When provided, the item is wrapped in a Tooltip. */
tooltipContent?: React.ReactNode;
/** Props forwarded to the Tooltip sub-components (root, trigger, content). */
tooltipProps?: TooltipObjectProps;
/** Callback called when the item is expanded/collapsed. */
onExpandedChange?: (isExpanded: boolean) => void;
/** Callback called when the item is selected/deselected. Receives the new selected state. Ignored when the tree manages selection via `selectedIds`. */
onSelectedChange?: (isSelected: boolean) => void;
};
type SkeletonItemProps = {
/** The number of rows to render. */
rows?: number;
};
/**
* @remarks
* Selection can be managed per item, with `isSelected` and `onSelectedChange`
* on each `TreeView.Item`, or by the tree itself, by passing `selectedIds` (or
* `defaultSelectedIds`) together with `onSelectedIdsChange`. When the tree
* manages selection, every item needs an `id`, and each item's own
* `isSelected` and `onSelectedChange` are ignored.
*
* The available selection modes are:
*
* - `single` — one item at a time. An unmodified click selects the clicked item and never clears it.
* - `multiple` — multi-select with checkboxes. An unmodified click toggles an item, and `Shift` repeats that across a range without clearing anything outside it.
* - `multiple-replace` — multi-select without checkboxes. An unmodified click selects only that item, `Cmd`/`Ctrl` toggles it and moves the anchor, and `Shift` extends from that anchor while retaining its selection snapshot. `Shift` + arrow extends the range.
*/
declare const TreeView: (({ children, defaultSelectedIds, selectedIds: selectedIdsProp, selectionMode, ariaLabel, ariaLabelledby, className, style, htmlAttributes, onSelectedIdsChange, ref, ...restProps }: CommonProps<"div", RootProps>) => import("react/jsx-runtime").JSX.Element) & {
Item: ({ actionMenuItems, children, defaultExpanded, hasChildren: hasChildrenProp, id: idProp, isDisabled, isExpanded: isExpandedProp, isIndeterminate, isLoading, isSelectable: isSelectableProp, isSelected: isSelectedProp, leadingVisual, title, tooltipContent, tooltipProps, trailingContent, onExpandedChange, onSelectedChange, actionMenuProps, className, style, htmlAttributes, ref, ...restProps }: CommonProps<"div", ItemProps>) => import("react/jsx-runtime").JSX.Element;
SkeletonItem: ({ rows, className, style, htmlAttributes, ref, ...restProps }: CommonProps<"div", SkeletonItemProps>) => import("react/jsx-runtime").JSX.Element;
};
export { TreeView };
//# sourceMappingURL=TreeView.d.ts.map