UNPKG

@neo4j-ndl/react

Version:

React implementation of Neo4j Design System

75 lines 3.49 kB
/** * * 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 <http://www.gnu.org/licenses/>. */ import { type UniqueIdentifier } from '@dnd-kit/core'; import { type UseSortableArguments } from '@dnd-kit/sortable'; import { type FlattenedTreeItem, type ItemChangedReason, type TreeItemComponent } from './tree-view-types'; export interface TreeItemProps<T> { /** Number of child items */ childCount?: number; /** Whether this is a clone item */ clone?: boolean; /** Whether the item is collapsed */ collapsed?: boolean; /** Depth of the item in the tree */ depth: number; /** Whether interaction should be disabled */ shouldDisableInteraction?: boolean; /** Whether this is an indicator item */ indicator?: boolean; /** Width of the indentation */ indentationWidth: number; /** The tree item data */ item: FlattenedTreeItem<T>; /** Whether this is the last item in its parent */ isLast: boolean; /** Parent item of this item */ parent: FlattenedTreeItem<T> | null; /** Function to call when item is collapsed */ onCollapse?(id: UniqueIdentifier): void; /** Function to call when item is removed */ onRemove?(id: UniqueIdentifier): void; /** Function to set the wrapper ref */ wrapperRef?(node: HTMLLIElement): void; } type SortableTreeItemProps<T extends Record<string, unknown>, E extends HTMLElement> = TreeItemProps<T> & { id: UniqueIdentifier; /** The component to use for rendering the tree item */ TreeItemComponent: TreeItemComponent<T, E>; /** Whether sorting should be disabled for this item */ shouldDisableSorting?: boolean; /** Props for the sortable functionality */ sortableProps?: Omit<UseSortableArguments, 'id'>; /** Whether to keep the ghost item in place while dragging */ keepGhostInPlace?: boolean; /** A list of trails to render before the item */ trails: ('none' | 'straight' | 'straight-curved' | 'curved')[]; /** Function to call when the item has changed */ onItemsChanged: (newItems: FlattenedTreeItem<T>[], itemChangedReason: ItemChangedReason<T>) => void; /** All items in the tree */ items: FlattenedTreeItem<T>[]; tabIndex?: number; /** Function to call when the item receives focus */ onFocus?: () => void; }; declare const SortableTreeViewItemNotMemoized: <T extends Record<string, unknown>, E extends HTMLElement>({ id, depth, isLast, TreeItemComponent, parent, shouldDisableSorting, sortableProps, keepGhostInPlace, item, onCollapse, trails, onItemsChanged, items, tabIndex, onFocus, ...restProps }: SortableTreeItemProps<T, E>) => import("react/jsx-runtime").JSX.Element; export declare const SortableTreeViewItem: typeof SortableTreeViewItemNotMemoized; export {}; //# sourceMappingURL=TreeViewItem.d.ts.map