{"version":3,"file":"tree-view-types.mjs","names":[],"sources":["../../../src/tree-view/tree-view-types.ts"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport { type UniqueIdentifier } from '@dnd-kit/core';\nimport { type RefAttributes } from 'react';\n\nimport { type CommonProps } from '../_common/types';\nimport { type IconButton } from '../icon-button';\nimport { type Skeleton } from '../skeleton';\n\nexport type TreeItem<T> =\n  | {\n      id: UniqueIdentifier;\n      canHaveSubItems: false;\n      isSortable?: boolean;\n      data: T;\n      isSelected?: boolean;\n      isSkeletonLoading?: boolean;\n      skeletonProps?: React.ComponentProps<typeof Skeleton>;\n    }\n  | {\n      id: UniqueIdentifier;\n      canHaveSubItems: true;\n      isCollapsed: boolean;\n      subItems: TreeItem<T>[];\n      isSortable?: boolean;\n      data: T;\n      isSelected?: boolean;\n      isSkeletonLoading?: boolean;\n      skeletonProps?: React.ComponentProps<typeof Skeleton>;\n    };\n\nexport type TextItemData = {\n  text: string;\n  onTextClick?: () => void;\n  actions: {\n    icon: React.ReactNode;\n    buttonProps: Omit<\n      React.ComponentPropsWithoutRef<typeof IconButton>,\n      'children' | 'as'\n    >;\n  }[];\n};\nexport type DefaultTreeItem = TreeItem<TextItemData>;\n\nexport type FlattenedTreeItem<T> = TreeItem<T> & {\n  depth: number;\n  parentId: UniqueIdentifier | null;\n};\n\nexport type TreeItemComponent<\n  T extends Record<string, unknown>,\n  TElement extends HTMLElement,\n> = React.FC<\n  React.PropsWithChildren<TreeItemComponentProps<T> & RefAttributes<TElement>>\n>;\n\nexport type TreeItemComponentProps<T extends Record<string, unknown>> = Omit<\n  CommonProps<\n    'div',\n    {\n      /** The tree item data */\n      item: FlattenedTreeItem<T>;\n      /** Parent item of this item */\n      parent: FlattenedTreeItem<T> | null;\n\n      /** If the item is should be rendered as a placeholder (for example, while dragging) */\n      isGhost?: boolean;\n\n      /** If the item is collapsed */\n      isCollapsed?: boolean;\n\n      /** Depth of the item in the tree */\n      depth: number;\n\n      /** While dragging it makes sense to disable some interaction for all other items. */\n      shouldDisableInteraction?: boolean;\n\n      /** True if sorting is disabled for this item. */\n      shouldDisableSorting?: boolean;\n\n      /** True if dragged item is over this Node. */\n      isOver: boolean;\n\n      /** True if dragged item is over the parent of this Node. */\n      isOverParent: boolean;\n\n      /** True if this item is the last in the parent list */\n      isLastInParent: boolean;\n\n      /** True if the item should be rendered as a indicator (for example, while dragging) */\n      isIndicator?: boolean;\n\n      /** Width of the indentation */\n      indentationWidth: number;\n\n      /** Function to call when the item is collapsed/expanded */\n      onCollapse?(): void;\n\n      /** Function to set the ref of the element that should activate sorting */\n      setActivatorNodeRef: (node: HTMLElement | null) => void;\n\n      /** Function to set the ref of the element that should be sorted (the wrapper element of the item) */\n      setNodeRef: (node: HTMLLIElement) => void;\n\n      /** Props for the drag handle */\n      dragHandleProps?: Record<string, unknown>;\n\n      /** A list of trails to render before the item */\n      trails: ('none' | 'straight' | 'straight-curved' | 'curved')[];\n\n      /** Function to call when the item has changed */\n      onItemsChanged: (\n        newItems: FlattenedTreeItem<T>[],\n        reason: ItemChangedReason<T>,\n      ) => void;\n\n      /** All items in the tree */\n      items: FlattenedTreeItem<T>[];\n      tabIndex?: number;\n      ariaLevel?: number;\n      ariaPosInSet?: number;\n      ariaSetSize?: number;\n\n      /** Function to call when the item receives focus */\n      onFocus?: () => void;\n    }\n  >,\n  'htmlAttributes'\n>;\n\nexport type ItemChangedReason<T> = {\n  /** The item that was changed */\n  item: TreeItem<T>;\n  /** The reason for the change */\n  reason: 'collapsed' | 'expanded' | 'dropped' | 'selected' | 'other';\n};\n"],"mappings":""}