/** * * 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 UniqueIdentifier } from '@dnd-kit/core'; import { type RefAttributes } from 'react'; import { type CommonProps } from '../_common/types'; import { type IconButton } from '../icon-button'; import { type Skeleton } from '../skeleton'; export type TreeItem = { id: UniqueIdentifier; canHaveSubItems: false; isSortable?: boolean; data: T; isSelected?: boolean; isSkeletonLoading?: boolean; skeletonProps?: React.ComponentProps; } | { id: UniqueIdentifier; canHaveSubItems: true; isCollapsed: boolean; subItems: TreeItem[]; isSortable?: boolean; data: T; isSelected?: boolean; isSkeletonLoading?: boolean; skeletonProps?: React.ComponentProps; }; export type TextItemData = { text: string; onTextClick?: () => void; actions: { icon: React.ReactNode; buttonProps: Omit, 'children' | 'as'>; }[]; }; export type DefaultTreeItem = TreeItem; export type FlattenedTreeItem = TreeItem & { depth: number; parentId: UniqueIdentifier | null; }; export type TreeItemComponent, TElement extends HTMLElement> = React.FC & RefAttributes>>; export type TreeItemComponentProps> = Omit; /** Parent item of this item */ parent: FlattenedTreeItem | null; /** If the item is should be rendered as a placeholder (for example, while dragging) */ isGhost?: boolean; /** If the item is collapsed */ isCollapsed?: boolean; /** Depth of the item in the tree */ depth: number; /** While dragging it makes sense to disable some interaction for all other items. */ shouldDisableInteraction?: boolean; /** True if sorting is disabled for this item. */ shouldDisableSorting?: boolean; /** True if dragged item is over this Node. */ isOver: boolean; /** True if dragged item is over the parent of this Node. */ isOverParent: boolean; /** True if this item is the last in the parent list */ isLastInParent: boolean; /** True if the item should be rendered as a indicator (for example, while dragging) */ isIndicator?: boolean; /** Width of the indentation */ indentationWidth: number; /** Function to call when the item is collapsed/expanded */ onCollapse?(): void; /** Function to set the ref of the element that should activate sorting */ setActivatorNodeRef: (node: HTMLElement | null) => void; /** Function to set the ref of the element that should be sorted (the wrapper element of the item) */ setNodeRef: (node: HTMLLIElement) => void; /** Props for the drag handle */ dragHandleProps?: Record; /** 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[], reason: ItemChangedReason) => void; /** All items in the tree */ items: FlattenedTreeItem[]; tabIndex?: number; ariaLevel?: number; ariaPosInSet?: number; ariaSetSize?: number; /** Function to call when the item receives focus */ onFocus?: () => void; }>, 'htmlAttributes'>; export type ItemChangedReason = { /** The item that was changed */ item: TreeItem; /** The reason for the change */ reason: 'collapsed' | 'expanded' | 'dropped' | 'selected' | 'other'; }; //# sourceMappingURL=tree-view-types.d.ts.map