import clsx from 'clsx'; import React, { forwardRef } from 'react'; import type { TreeItemComponentProps, FlattenedItem } from '../../types'; import './FolderTreeItemWrapper.css'; function flattenParents( parent: FlattenedItem | null ): FlattenedItem[] { if (!parent) return []; return [...flattenParents(parent.parent), parent]; } export const FolderTreeItemWrapper = forwardRef< HTMLDivElement, React.PropsWithChildren> >((props, ref) => { const { clone, depth, disableSelection, disableInteraction, disableSorting, ghost, handleProps, indentationWidth, indicator, collapsed, onCollapse, onRemove, item, wrapperRef, style, isLast, parent, hideCollapseButton, childCount, manualDrag, showDragHandle, disableCollapseOnItemClick, className, contentClassName, isOver, isOverParent, ...rest } = props; const flattenedParents = flattenParents(parent); return (
  • {flattenedParents.map((item) => (
    ))}
    {manualDrag && showDragHandle && !disableSorting && (
    )} {!manualDrag && !hideCollapseButton && !!onCollapse && !!childCount && (
  • ); }) as ( p: React.PropsWithChildren< TreeItemComponentProps & React.RefAttributes > ) => React.ReactElement;