{"version":3,"file":"TreeView.mjs","names":[],"sources":["../../../src/tree-view/TreeView.tsx"],"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 {\n  type Announcements,\n  closestCenter,\n  defaultDropAnimation,\n  DndContext,\n  type DragEndEvent,\n  type DragMoveEvent,\n  type DragOverEvent,\n  DragOverlay,\n  type DragStartEvent,\n  type DropAnimation,\n  KeyboardSensor,\n  MeasuringStrategy,\n  PointerSensor,\n  type UniqueIdentifier,\n  useSensor,\n  useSensors,\n} from '@dnd-kit/core';\nimport {\n  arrayMove,\n  SortableContext,\n  verticalListSortingStrategy,\n} from '@dnd-kit/sortable';\nimport type React from 'react';\nimport { useCallback, useMemo, useRef, useState } from 'react';\nimport { createPortal } from 'react-dom';\n\nimport { type HtmlAttributes } from '../_common/types';\nimport { sortableTreeKeyboardCoordinates } from './tree-view-keyboard-coordinates';\nimport {\n  type FlattenedTreeItem,\n  type ItemChangedReason,\n  type TreeItem,\n  type TreeItemComponent,\n} from './tree-view-types';\nimport {\n  buildTree,\n  flattenTree,\n  getProjection,\n  removeChildrenOf,\n  type SensorContext,\n  transformToString,\n} from './tree-view-utils';\nimport { TreeItemWrapper } from './TreeItemWrapper';\nimport { SortableTreeViewItem } from './TreeViewItem';\nimport { TreeViewTextItem } from './TreeViewTextItem';\n\nconst indentationWidth = 20;\nconst ACTIVE_PLACEHOLDER_ID = 'ndl-active-tree-item';\n\nconst dropAnimationConfig: DropAnimation = {\n  easing: 'ease-out',\n  keyframes({ transform }) {\n    return [\n      {\n        opacity: 1,\n        transform: transformToString(transform.initial),\n      },\n      {\n        opacity: 0,\n        transform: transformToString({\n          ...transform.final,\n          // oxlint-disable-next-line id-length\n          y: transform.final.y + 5,\n          // oxlint-disable-next-line id-length\n          x: transform.final.x + 5,\n        }),\n      },\n    ];\n  },\n  sideEffects({ active }) {\n    active.node.animate([{ opacity: 0 }, { opacity: 1 }], {\n      duration: defaultDropAnimation.duration,\n      easing: defaultDropAnimation.easing,\n    });\n  },\n};\n\nexport interface TreeViewProps<\n  T extends Record<string, unknown>,\n  E extends HTMLElement,\n> extends React.HTMLAttributes<HTMLOListElement> {\n  /** The items to be displayed in the tree view */\n  items: TreeItem<T>[];\n  /** A function that is called when the items in the tree view change */\n  onItemsChanged: (\n    newItems: TreeItem<T>[],\n    itemChangedReason: ItemChangedReason<T>,\n  ) => void;\n  /** The component to use for the tree items, if not provided the default component will be used */\n  TreeItemComponent?: TreeItemComponent<T, E>;\n  /** HTML attributes */\n  htmlAttributes?: HtmlAttributes<'ol'>;\n}\n\nconst TreeViewComponent = function TreeView<\n  T extends Record<string, unknown>,\n  E extends HTMLElement,\n>({\n  items,\n  TreeItemComponent,\n  onItemsChanged,\n  htmlAttributes,\n  ...restProps\n}: TreeViewProps<T, E>) {\n  const flattenItems = useMemo(() => flattenTree(items), [items]);\n  const [activeId, setActiveId] = useState<UniqueIdentifier | null>(null);\n  const [overId, setOverId] = useState<UniqueIdentifier | null>(null);\n  const [focusedRowId, setFocusedRowId] = useState<UniqueIdentifier | null>(\n    null,\n  );\n\n  const [currentPosition, setCurrentPosition] = useState<{\n    parentId: UniqueIdentifier | null;\n    overId: UniqueIdentifier;\n  } | null>(null);\n  const [offsetLeft, setOffsetLeft] = useState(0);\n\n  /* ------------------------------ Setup of Data ------------------------------ */\n\n  const flattenedAndRemovedCollapsedItems = useMemo(() => {\n    const collapsedItemsIds = flattenItems\n      .filter((item) => item.canHaveSubItems && item.isCollapsed)\n      .map((item) => item.id);\n\n    return removeChildrenOf(\n      [...flattenItems],\n      activeId !== null ? [activeId, ...collapsedItemsIds] : collapsedItemsIds,\n    );\n  }, [activeId, flattenItems]);\n\n  const activeItem = useMemo(\n    () => (activeId ? flattenItems.find(({ id }) => id === activeId) : null),\n    [activeId, flattenItems],\n  );\n\n  const flattenedAndRemovedCollapsedItemsWithActive = useMemo(() => {\n    const collapsedItems = flattenItems.reduce<UniqueIdentifier[]>(\n      (acc, item) => {\n        if (item.canHaveSubItems && item.isCollapsed) {\n          return [...acc, item.id];\n        }\n        return acc;\n      },\n      [],\n    );\n\n    const ItemsWithCollapsedRemoved = removeChildrenOf(\n      flattenItems,\n      activeId ? [activeId, ...collapsedItems] : collapsedItems,\n    );\n    const newArray: FlattenedTreeItem<T>[] = [];\n    for (const item of ItemsWithCollapsedRemoved) {\n      newArray.push(item);\n      if (item.id === activeId) {\n        newArray.push({\n          ...item,\n          id: ACTIVE_PLACEHOLDER_ID,\n        });\n      }\n    }\n\n    return newArray;\n  }, [flattenItems, activeId]);\n\n  if (activeItem?.canHaveSubItems && !activeItem?.isCollapsed) {\n    flattenedAndRemovedCollapsedItems.push({\n      ...activeItem,\n      id: ACTIVE_PLACEHOLDER_ID,\n    });\n  }\n\n  const sensorContext: SensorContext<T> = useRef({\n    items: flattenedAndRemovedCollapsedItemsWithActive,\n    offset: offsetLeft,\n  });\n\n  const coordinateGetter = useMemo(() => {\n    sensorContext.current.items = flattenedAndRemovedCollapsedItemsWithActive;\n    sensorContext.current.offset = offsetLeft;\n\n    return sortableTreeKeyboardCoordinates<T>(\n      sensorContext,\n      true,\n      indentationWidth,\n    );\n  }, [flattenedAndRemovedCollapsedItemsWithActive, offsetLeft]);\n\n  const sensors = useSensors(\n    useSensor(PointerSensor),\n    useSensor(KeyboardSensor, {\n      coordinateGetter: coordinateGetter,\n    }),\n  );\n\n  const projected = useMemo(\n    () =>\n      activeId && overId\n        ? getProjection(\n            flattenedAndRemovedCollapsedItemsWithActive,\n            activeId,\n            overId,\n            offsetLeft,\n            indentationWidth,\n          )\n        : null,\n    [activeId, overId, flattenedAndRemovedCollapsedItemsWithActive, offsetLeft],\n  );\n\n  const hasSelectableItems = useMemo(\n    () => flattenItems.some((item) => item.isSelected !== undefined),\n    [flattenItems],\n  );\n\n  const itemAriaData = useMemo(() => {\n    const visibleItems = flattenedAndRemovedCollapsedItemsWithActive.filter(\n      (item) => item.id !== ACTIVE_PLACEHOLDER_ID,\n    );\n\n    return visibleItems.reduce<\n      Record<UniqueIdentifier, { posInSet: number; setSize: number }>\n    >((acc, item) => {\n      const siblings = visibleItems.filter(\n        (sibling) => sibling.parentId === item.parentId,\n      );\n\n      acc[item.id] = {\n        posInSet: siblings.findIndex((sibling) => sibling.id === item.id) + 1,\n        setSize: siblings.length,\n      };\n\n      return acc;\n    }, {});\n  }, [flattenedAndRemovedCollapsedItemsWithActive]);\n\n  /* ------------------------------ Handlers ------------------------------ */\n  function handleDragStart({ active }: DragStartEvent) {\n    const activeId = active.id;\n    setActiveId(activeId);\n    setOverId(activeId);\n\n    const activeItem = flattenItems.find(({ id }) => id === activeId);\n    if (activeItem) {\n      setCurrentPosition({\n        overId: activeId,\n        parentId: activeItem.parentId,\n      });\n    }\n\n    document.body.style.setProperty('cursor', 'grabbing');\n  }\n\n  function handleDragMove({ delta }: DragMoveEvent) {\n    setOffsetLeft(delta.x);\n  }\n\n  function handleDragOver({ over }: DragOverEvent) {\n    setOverId(over?.id ?? null);\n  }\n\n  function resetState() {\n    setOverId(null);\n    setActiveId(null);\n    setOffsetLeft(0);\n    setCurrentPosition(null);\n\n    document.body.style.setProperty('cursor', '');\n  }\n\n  const handleDragEnd = useCallback(\n    (event: DragEndEvent) => {\n      const { active, over } = event;\n      resetState();\n      let overIndex = flattenItems.findIndex((item) => item.id === over?.id);\n\n      if (over?.id === ACTIVE_PLACEHOLDER_ID) {\n        overIndex = flattenItems.findIndex((item) => item.id === active.id);\n      }\n      if (projected && over) {\n        const { depth, parentId } = projected;\n        const clonedItems: FlattenedTreeItem<T>[] = [...flattenItems];\n\n        const parentIndex = clonedItems.findIndex(\n          (item) => item.id === parentId,\n        );\n        const activeIndex = clonedItems.findIndex(({ id }) => id === active.id);\n        const activeTreeItem = clonedItems[activeIndex];\n\n        clonedItems[activeIndex] = { ...activeTreeItem, depth, parentId };\n        const parentItem = clonedItems[parentIndex];\n        if (parentItem && parentItem.canHaveSubItems) {\n          clonedItems[parentIndex] = { ...parentItem, isCollapsed: false };\n        }\n        const newItems = buildTree(\n          arrayMove(clonedItems, activeIndex, overIndex),\n        );\n\n        onItemsChanged(newItems, {\n          item: activeTreeItem,\n          reason: 'dropped',\n        });\n      }\n    },\n    [flattenItems, onItemsChanged, projected],\n  );\n\n  function handleToggleCollapse(id: UniqueIdentifier) {\n    const item = flattenItems.find((item) => item.id === id);\n    if (!item || item.canHaveSubItems !== true) {\n      return;\n    }\n\n    onItemsChanged(\n      buildTree(\n        flattenItems.map((item) => {\n          if (item.id === id && item.canHaveSubItems === true) {\n            return { ...item, isCollapsed: !item.isCollapsed };\n          }\n          return item;\n        }),\n      ),\n      {\n        item,\n        reason: item.isCollapsed ? 'expanded' : 'collapsed',\n      },\n    );\n  }\n\n  function handleDragCancel() {\n    resetState();\n  }\n\n  /* ------------------------------ Keyboard functions ------------------------------ */\n  const getMovementAnnouncement = (\n    eventName: string,\n    activeId: UniqueIdentifier,\n    overId?: UniqueIdentifier,\n  ) => {\n    if (overId && projected) {\n      if (eventName !== 'onDragEnd') {\n        if (\n          currentPosition &&\n          projected.parentId === currentPosition.parentId &&\n          overId === currentPosition.overId\n        ) {\n          return;\n        } else {\n          setCurrentPosition({\n            overId,\n            parentId: projected.parentId,\n          });\n        }\n      }\n\n      const clonedItems: FlattenedTreeItem<T>[] = [\n        ...flattenedAndRemovedCollapsedItemsWithActive,\n      ];\n      const overIndex = clonedItems.findIndex(({ id }) => id === overId);\n      const activeIndex = clonedItems.findIndex(({ id }) => id === activeId);\n      const sortedItems = arrayMove(clonedItems, activeIndex, overIndex);\n\n      const previousItem = sortedItems[overIndex - 1];\n\n      let announcement;\n      const movedVerb = eventName === 'onDragEnd' ? 'dropped' : 'moved';\n      const nestedVerb = eventName === 'onDragEnd' ? 'dropped' : 'nested';\n\n      if (!previousItem) {\n        const nextItem = sortedItems[overIndex + 1];\n        announcement = `${activeId} was ${movedVerb} before ${nextItem.id}.`;\n      } else {\n        if (projected.depth > previousItem.depth) {\n          announcement = `${activeId} was ${nestedVerb} under ${previousItem.id}.`;\n        } else {\n          let previousSibling: FlattenedTreeItem<T> | undefined = previousItem;\n          while (previousSibling && projected.depth < previousSibling.depth) {\n            const parentId: UniqueIdentifier | null = previousSibling.parentId;\n            previousSibling = sortedItems.find(({ id }) => id === parentId);\n          }\n\n          if (previousSibling) {\n            announcement = `${activeId} was ${movedVerb} after ${previousSibling.id}.`;\n          }\n        }\n      }\n\n      return announcement;\n    }\n\n    return;\n  };\n\n  const announcements: Announcements = {\n    onDragCancel({ active }) {\n      return `Moving was cancelled. ${active.id} was dropped in its original position.`;\n    },\n    onDragEnd({ active, over }) {\n      return getMovementAnnouncement('onDragEnd', active.id, over?.id);\n    },\n    onDragMove({ active, over }) {\n      return getMovementAnnouncement('onDragMove', active.id, over?.id);\n    },\n    onDragOver({ active, over }) {\n      return getMovementAnnouncement('onDragOver', active.id, over?.id);\n    },\n    onDragStart({ active }) {\n      return `Picked up ${active.id}.`;\n    },\n  };\n  /* ------------------------------ Visual ------------------------------ */\n  function getTrailList() {\n    const trails: Record<\n      UniqueIdentifier,\n      ('none' | 'straight' | 'straight-curved' | 'curved')[]\n    > = {};\n    // Loop through the items in reverse\n    [...flattenedAndRemovedCollapsedItemsWithActive]\n      .reverse()\n      .forEach((item, itemIndex, reversedList) => {\n        const trailList: (\n          | 'none'\n          | 'straight'\n          | 'straight-curved'\n          | 'curved'\n        )[] = [];\n        const nextItem = reversedList[itemIndex - 1];\n        // Loop through the depth of the item\n\n        for (let trailDepth = 0; trailDepth < item.depth; trailDepth++) {\n          // Not closest to the item so should be straight or none\n          if (trailDepth < item.depth - 1) {\n            if (nextItem === undefined) {\n              trailList.push('none');\n              continue;\n            } else if (trails[nextItem?.id][trailDepth] === 'none') {\n              trailList.push('none');\n              continue;\n            } else if (nextItem && nextItem.depth <= trailDepth) {\n              trailList.push('none');\n              continue;\n            }\n            trailList.push('straight');\n          } else {\n            if (\n              (nextItem && trails[nextItem?.id][trailDepth] === 'none') ||\n              nextItem === undefined ||\n              nextItem.depth <= trailDepth\n            ) {\n              trailList.push('curved');\n            } else {\n              trailList.push('straight-curved');\n            }\n          }\n        }\n        trails[item.id] = trailList;\n      });\n    return trails;\n  }\n\n  const measuring = {\n    droppable: {\n      strategy: MeasuringStrategy.Always,\n    },\n  };\n\n  const trails = getTrailList();\n  const rowIdWithFocus =\n    focusedRowId ?? flattenedAndRemovedCollapsedItemsWithActive[0]?.id;\n  return (\n    <DndContext\n      accessibility={{ announcements }}\n      sensors={sensors}\n      collisionDetection={closestCenter}\n      onDragEnd={handleDragEnd}\n      onDragStart={handleDragStart}\n      onDragMove={handleDragMove}\n      onDragOver={handleDragOver}\n      onDragCancel={handleDragCancel}\n      measuring={measuring}\n    >\n      <SortableContext\n        items={flattenedAndRemovedCollapsedItemsWithActive.map(\n          (item) => item.id,\n        )}\n        strategy={verticalListSortingStrategy}\n      >\n        <ol\n          className=\"ndl-tree-view-list\"\n          role=\"tree\"\n          aria-multiselectable={hasSelectableItems ? true : undefined}\n          {...restProps}\n          {...htmlAttributes}\n        >\n          {flattenedAndRemovedCollapsedItemsWithActive.map((item) => (\n            <SortableTreeViewItem<T, E>\n              key={item.id}\n              depth={\n                item.id === activeId && projected ? projected.depth : item.depth\n              }\n              indentationWidth={indentationWidth}\n              item={item}\n              isLast={false}\n              parent={\n                flattenItems.find(\n                  (flatItem) => flatItem.id === item.parentId,\n                ) ?? null\n              }\n              id={item.id}\n              trails={trails[item.id]}\n              keepGhostInPlace={item.id === ACTIVE_PLACEHOLDER_ID}\n              TreeItemComponent={\n                TreeItemComponent === undefined\n                  ? (TreeViewTextItem as TreeItemComponent<T, E>)\n                  : TreeItemComponent\n              }\n              onCollapse={() => handleToggleCollapse(item.id)}\n              onItemsChanged={(newItems, itemChangedReason) =>\n                onItemsChanged(buildTree(newItems), itemChangedReason)\n              }\n              items={flattenItems}\n              ariaLevel={\n                item.id === ACTIVE_PLACEHOLDER_ID ? undefined : item.depth + 1\n              }\n              ariaPosInSet={\n                item.id === ACTIVE_PLACEHOLDER_ID\n                  ? undefined\n                  : itemAriaData[item.id]?.posInSet\n              }\n              ariaSetSize={\n                item.id === ACTIVE_PLACEHOLDER_ID\n                  ? undefined\n                  : itemAriaData[item.id]?.setSize\n              }\n              tabIndex={item.id === rowIdWithFocus ? 0 : -1}\n              onFocus={() => setFocusedRowId(item.id)}\n              shouldDisableSorting={item.isSortable === false}\n            />\n          ))}\n        </ol>\n        {/* Portal is used to show the item the user drags */}\n        {createPortal(\n          <DragOverlay dropAnimation={dropAnimationConfig}></DragOverlay>,\n          document.body,\n        )}\n      </SortableContext>\n    </DndContext>\n  );\n};\n\nconst TreeViewComponents = {\n  SortableTreeViewItem,\n  TreeItemWrapper,\n  TreeViewTextItem,\n};\n\n/**\n * @deprecated Use `TreeView` from `@neo4j-ndl/react/next` instead. This component is no longer maintained.\n */\nexport const TreeView = Object.assign(TreeViewComponent, TreeViewComponents);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuHE;CACA;CACA;CACA;;AAvDF,MAAM,mBAAmB;AACzB,MAAM,wBAAwB;AAE9B,MAAM,sBAAqC;CACzC,QAAQ;CACR,UAAU,EAAE,aAAa;EACvB,OAAO,CACL;GACE,SAAS;GACT,WAAW,kBAAkB,UAAU,OAAO;EAChD,GACA;GACE,SAAS;GACT,WAAW,kBAAA,eAAA,eAAA,CAAA,GACN,UAAU,KAAA,GAAA,CAAA,GAAA;IAEb,GAAG,UA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