@particle-academy/react-fancy 5.42.0 → 5.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +62 -0
- package/dist/button.cjs +3 -3
- package/dist/button.js +1 -1
- package/dist/{chunk-FQLL2JI7.js → chunk-G4WYCWIQ.js} +3 -3
- package/dist/{chunk-FQLL2JI7.js.map → chunk-G4WYCWIQ.js.map} +1 -1
- package/dist/{chunk-RMJGF7MN.cjs → chunk-ICQJ6475.cjs} +7 -6
- package/dist/chunk-ICQJ6475.cjs.map +1 -0
- package/dist/{chunk-46IPQEUP.js → chunk-JJRD3WX3.js} +7 -6
- package/dist/chunk-JJRD3WX3.js.map +1 -0
- package/dist/{chunk-DCDW3LW6.js → chunk-JVGJHIIQ.js} +3 -3
- package/dist/{chunk-DCDW3LW6.js.map → chunk-JVGJHIIQ.js.map} +1 -1
- package/dist/{chunk-IWQ3ZFLZ.cjs → chunk-K4NHVCY6.cjs} +15 -15
- package/dist/{chunk-IWQ3ZFLZ.cjs.map → chunk-K4NHVCY6.cjs.map} +1 -1
- package/dist/{chunk-MTUH2X3W.cjs → chunk-MQ4ULIOU.cjs} +4 -4
- package/dist/{chunk-MTUH2X3W.cjs.map → chunk-MQ4ULIOU.cjs.map} +1 -1
- package/dist/{chunk-5Q7EQQTT.cjs → chunk-MRARASNZ.cjs} +4 -4
- package/dist/{chunk-5Q7EQQTT.cjs.map → chunk-MRARASNZ.cjs.map} +1 -1
- package/dist/{chunk-2OMB3OOR.js → chunk-P7WMYJ5I.js} +3 -3
- package/dist/{chunk-2OMB3OOR.js.map → chunk-P7WMYJ5I.js.map} +1 -1
- package/dist/{chunk-YLPVTEUH.js → chunk-SF5OAVGD.js} +3 -3
- package/dist/{chunk-YLPVTEUH.js.map → chunk-SF5OAVGD.js.map} +1 -1
- package/dist/{chunk-FJ2GMQLC.cjs → chunk-UUBHUSUP.cjs} +6 -6
- package/dist/{chunk-FJ2GMQLC.cjs.map → chunk-UUBHUSUP.cjs.map} +1 -1
- package/dist/{chunk-7VLRHXLQ.cjs → chunk-WN45ZE37.cjs} +171 -50
- package/dist/chunk-WN45ZE37.cjs.map +1 -0
- package/dist/{chunk-NUPQJ5SJ.js → chunk-ZVXOL5H3.js} +173 -52
- package/dist/chunk-ZVXOL5H3.js.map +1 -0
- package/dist/index.cjs +33 -33
- package/dist/index.js +7 -7
- package/dist/json-editor.cjs +13 -13
- package/dist/json-editor.js +2 -2
- package/dist/magic-wand.cjs +3 -3
- package/dist/magic-wand.js +2 -2
- package/dist/prompt-input.cjs +3 -3
- package/dist/prompt-input.js +2 -2
- package/dist/reason-tag.cjs +3 -3
- package/dist/reason-tag.js +2 -2
- package/dist/tree-nav.cjs +4 -3
- package/dist/tree-nav.d.cts +14 -7
- package/dist/tree-nav.d.ts +14 -7
- package/dist/tree-nav.js +2 -1
- package/package.json +1 -1
- package/dist/chunk-46IPQEUP.js.map +0 -1
- package/dist/chunk-7VLRHXLQ.cjs.map +0 -1
- package/dist/chunk-NUPQJ5SJ.js.map +0 -1
- package/dist/chunk-RMJGF7MN.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/TreeNav/TreeNav.context.ts","../src/components/TreeNav/tree-store.ts","../src/components/TreeNav/TreeNode.tsx","../src/components/TreeNav/TreeNav.tsx"],"names":["createContext","useContext","useSyncExternalStore","jsxs","jsx","cn","useRef","useCallback","useEffect","memo","useState","useMemo","useLayoutEffect","VirtualList"],"mappings":";;;;;;;AAGO,IAAM,cAAA,GAAiBA,oBAA0C,IAAI,CAAA;AAErE,SAAS,UAAA,GAAkC;AAChD,EAAA,MAAM,GAAA,GAAMC,iBAAW,cAAc,CAAA;AACrC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,sDAAsD,CAAA;AAAA,EACxE;AACA,EAAA,OAAO,GAAA;AACT;ACKO,SAAS,gBAAgB,OAAA,E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,EAAG,EAAE,CAAA;AAEL,EAAA,MAAM,cAAc,SAAA,IAAa,mBAAA;AAEjC,EAAA,uBACEH,cAAAA,CAAC,cAAA,CAAe,QAAA,EAAf,EAAwB,KAAA,EAAO,GAAA,EAC9B,QAAA,kBAAAA,cAAAA,CAAC,oBAAA,CAAqB,QAAA,EAArB,EAA8B,KAAA,EAAO,WACpC,QAAA,kBAAAA,cAAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,2BAAA,EAA0B,EAAA;AAAA,MAC1B,mCAAA,EAAmC,aAAa,EAAA,GAAK,MAAA;AAAA,MACrD,SAAA,EAAWC,oBAAA,CAAG,oCAAA,EAAsC,SAAS,CAAA;AAAA,MAC7D,SAAA,EAAW,cAAc,aAAA,GAAgB,MAAA;AAAA,MAExC,uCACCD,cAAAA;AAAA,QAACS,6BAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAO,IAAA;AAAA,UACP,MAAA;AAAA,UACA,iBAAA,EAAmB,SAAA;AAAA,UACnB,SAAA,EAAW,CAAC,GAAA,qBAAQT,cAAAA,CAAC,QAAA,EAAA,EAAS,IAAA,EAAM,GAAA,CAAI,IAAA,EAAM,KAAA,EAAO,GAAA,CAAI,KAAA,EAAO;AAAA;AAAA,OAClE,GAEA,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,qBAASA,cAAAA,CAAC,QAAA,EAAA,EAAuB,IAAA,EAAY,KAAA,EAAO,CAAA,EAAA,EAA5B,IAAA,CAAK,EAA0B,CAAE;AAAA;AAAA,KAG1E,CAAA,EACF,CAAA;AAEJ;AAEA,WAAA,CAAY,WAAA,GAAc,SAAA;AAEnB,IAAM,OAAA,GAAU,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa;AAAA,EAChD,IAAA,EAAM;AACR,CAAC","file":"chunk-WN45ZE37.cjs","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { TreeNavContextValue } from \"./TreeNav.types\";\n\nexport const TreeNavContext = createContext<TreeNavContextValue | null>(null);\n\nexport function useTreeNav(): TreeNavContextValue {\n const ctx = useContext(TreeNavContext);\n if (!ctx) {\n throw new Error(\"useTreeNav must be used within a <TreeNav> component\");\n }\n return ctx;\n}\n","import { createContext, useContext, useSyncExternalStore } from \"react\";\nimport type { DragState, DropPosition, TreeNodeData } from \"./TreeNav.types\";\n\n/** What changes as someone clicks, toggles and drags — the state rows subscribe to. */\nexport interface TreeState {\n selectedId?: string;\n expanded: ReadonlySet<string>;\n dragState: DragState;\n}\n\nexport interface TreeStore {\n get(): TreeState;\n set(next: TreeState): void;\n subscribe(listener: () => void): () => void;\n}\n\nexport function createTreeStore(initial: TreeState): TreeStore {\n let state = initial;\n const listeners = new Set<() => void>();\n return {\n get: () => state,\n set(next) {\n state = next;\n for (const listener of listeners) listener();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\n/**\n * Everything a row needs that does NOT change on a click. Handlers are stable\n * (they read the latest props and state when called), so this value only changes\n * when the tree's data or configuration does.\n *\n * Kept apart from the public `TreeNavContext` on purpose: that one still carries\n * live `selectedId` / `expandedIds` for `useTreeNav()` callers, and any component\n * reading it re-renders on every click. Rows no longer read it — which is the\n * whole fix: a click used to re-render every row in the tree.\n */\nexport interface TreeInternals {\n store: TreeStore;\n nodes: TreeNodeData[];\n select: (node: TreeNodeData) => void;\n toggle: (id: string) => void;\n expandNode: (id: string) => void;\n setDragState: (state: DragState) => void;\n contextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;\n moveNode?: (sourceId: string, targetId: string, position: DropPosition) => void;\n externalDrop?: (event: React.DragEvent, target: TreeNodeData, position: DropPosition) => void;\n indentSize: number;\n showIcons: boolean;\n draggable: boolean;\n dragCursor: \"grab\" | \"none\";\n acceptExternalDrops: boolean;\n /** Rows are rendered flat by a virtual list, so a row never renders its children. */\n flat: boolean;\n}\n\nexport const TreeInternalsContext = createContext<TreeInternals | null>(null);\n\nexport function useTreeInternals(): TreeInternals {\n const internals = useContext(TreeInternalsContext);\n if (!internals) throw new Error(\"TreeNav.Node must be used within a <TreeNav> component\");\n return internals;\n}\n\n/** Subscribe to ONE derived value; the row re-renders only when that value changes. */\nexport function useTreeSlice<T>(select: (state: TreeState) => T): T {\n const { store } = useTreeInternals();\n return useSyncExternalStore(\n store.subscribe,\n () => select(store.get()),\n () => select(store.get()),\n );\n}\n","import { memo, useRef, useEffect, useCallback } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useTreeInternals, useTreeSlice } from \"./tree-store\";\nimport type { TreeNodeProps, TreeNodeData, DropPosition } from \"./TreeNav.types\";\n\nconst EXT_COLORS: Record<string, string> = {\n ts: \"#3178c6\",\n tsx: \"#3178c6\",\n js: \"#f7df1e\",\n jsx: \"#f7df1e\",\n php: \"#777bb4\",\n html: \"#e34c26\",\n htm: \"#e34c26\",\n css: \"#264de4\",\n json: \"#a1a1aa\",\n md: \"#71717a\",\n yaml: \"#cb171e\",\n yml: \"#cb171e\",\n};\n\nfunction FileIcon({ ext }: { ext?: string }) {\n const color = (ext && EXT_COLORS[ext.toLowerCase()]) || \"#71717a\";\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n <path d=\"M4 1h5.5L13 4.5V14a1 1 0 01-1 1H4a1 1 0 01-1-1V2a1 1 0 011-1z\" stroke={color} strokeWidth=\"1.2\" />\n <path d=\"M9 1v4h4\" stroke={color} strokeWidth=\"1.2\" />\n </svg>\n );\n}\n\nfunction FolderIcon({ open }: { open: boolean }) {\n if (open) {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n <path d=\"M1.5 3.5a1 1 0 011-1h3l1.5 1.5H13a1 1 0 011 1V5H2.5V3.5z\" fill=\"#fbbf24\" />\n <path d=\"M1 6h13l-1.5 7.5H2.5L1 6z\" fill=\"#fbbf24\" opacity=\"0.7\" />\n </svg>\n );\n }\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n <path d=\"M1.5 3a1 1 0 011-1h3l1.5 1.5H13a1 1 0 011 1v8a1 1 0 01-1 1H2.5a1 1 0 01-1-1V3z\" fill=\"#fbbf24\" />\n </svg>\n );\n}\n\nfunction ChevronIcon({ open }: { open: boolean }) {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn(\"shrink-0 transition-transform duration-150\", open && \"rotate-90\")}\n >\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Utilities\n// ---------------------------------------------------------------------------\n\nfunction isDescendantOf(\n nodes: TreeNodeData[],\n ancestorId: string,\n targetId: string,\n): boolean {\n function findNode(haystack: TreeNodeData[], id: string): TreeNodeData | undefined {\n for (const n of haystack) {\n if (n.id === id) return n;\n if (n.children) {\n const found = findNode(n.children, id);\n if (found) return found;\n }\n }\n return undefined;\n }\n\n function hasDescendant(node: TreeNodeData, id: string): boolean {\n if (!node.children) return false;\n for (const child of node.children) {\n if (child.id === id) return true;\n if (hasDescendant(child, id)) return true;\n }\n return false;\n }\n\n const ancestor = findNode(nodes, ancestorId);\n return ancestor ? hasDescendant(ancestor, targetId) : false;\n}\n\nfunction computeDropPosition(\n e: React.DragEvent,\n isFolder: boolean,\n): DropPosition {\n const rect = e.currentTarget.getBoundingClientRect();\n const offsetY = e.clientY - rect.top;\n const third = rect.height / 3;\n\n if (offsetY < third) return \"before\";\n if (offsetY > third * 2) return \"after\";\n return isFolder ? \"inside\" : \"after\";\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\n\n/**\n * One row (and, when nested, its expanded children).\n *\n * Reads what changes on a click — selection, expansion, drag — as per-row slices\n * of a store, so a click re-renders only the rows whose slice changed. It used to\n * read one context holding all of it, so every click re-rendered every row:\n * 175-267 ms per click on a 5,000-node tree. `memo` keeps a parent's re-render\n * from reaching rows whose `node` and `depth` did not change.\n */\nfunction TreeNodeImpl({ node, depth }: TreeNodeProps) {\n const {\n store, nodes, select, toggle, expandNode, setDragState, contextMenu, moveNode, externalDrop,\n indentSize, showIcons, draggable, dragCursor, acceptExternalDrops, flat,\n } = useTreeInternals();\n\n const isFolder = node.type === \"folder\" || (node.children && node.children.length > 0);\n const isExpanded = useTreeSlice((s) => s.expanded.has(node.id));\n const isSelected = useTreeSlice((s) => s.selectedId === node.id);\n const isDragging = useTreeSlice((s) => s.dragState.draggedNodeId === node.id);\n const dropPosition = useTreeSlice((s) =>\n s.dragState.dropTargetId === node.id ? s.dragState.dropPosition : null,\n );\n const isDropTarget = dropPosition !== null;\n const paddingLeft = depth * indentSize + 4;\n\n // Auto-expand timer for folders during drag\n const autoExpandTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearAutoExpand = useCallback(() => {\n if (autoExpandTimer.current) {\n clearTimeout(autoExpandTimer.current);\n autoExpandTimer.current = null;\n }\n }, []);\n\n useEffect(() => clearAutoExpand, [clearAutoExpand]);\n\n // ---------------------------------------------------------------------------\n // Click handlers\n // ---------------------------------------------------------------------------\n\n const handleClick = () => {\n if (node.disabled) return;\n if (isFolder) {\n toggle(node.id);\n }\n select(node);\n };\n\n const handleContextMenu = (e: React.MouseEvent) => {\n if (contextMenu) {\n e.preventDefault();\n contextMenu(e, node);\n }\n };\n\n // ---------------------------------------------------------------------------\n // Drag source handlers\n // ---------------------------------------------------------------------------\n\n const handleDragStart = useCallback((e: React.DragEvent) => {\n e.dataTransfer.setData(\"text/plain\", node.id);\n e.dataTransfer.effectAllowed = \"move\";\n // Set state async so the browser captures the element for the drag ghost first\n requestAnimationFrame(() => {\n setDragState({ draggedNodeId: node.id, dropTargetId: null, dropPosition: null });\n });\n }, [node.id, setDragState]);\n\n const handleDragEnd = useCallback(() => {\n clearAutoExpand();\n setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });\n }, [clearAutoExpand, setDragState]);\n\n // ---------------------------------------------------------------------------\n // Drop target handlers (on outer div). Drag state is read from the store when\n // the event fires, so a row does not re-render as a drag moves elsewhere.\n // ---------------------------------------------------------------------------\n\n const handleDragOver = useCallback((e: React.DragEvent) => {\n const { dragState } = store.get();\n const isExternalDrag = !dragState.draggedNodeId;\n if (isExternalDrag) {\n // External drop accepted only when host opted in.\n if (!acceptExternalDrops) return;\n } else {\n const sourceId = dragState.draggedNodeId!;\n if (sourceId === node.id) return;\n if (isDescendantOf(nodes, sourceId, node.id)) return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n e.dataTransfer.dropEffect = isExternalDrag ? \"copy\" : \"move\";\n\n const position = computeDropPosition(e, !!isFolder);\n\n // Auto-expand collapsed folders when hovering \"inside\"\n if (isFolder && !store.get().expanded.has(node.id) && position === \"inside\") {\n if (!autoExpandTimer.current) {\n autoExpandTimer.current = setTimeout(() => {\n expandNode(node.id);\n autoExpandTimer.current = null;\n }, 500);\n }\n } else {\n clearAutoExpand();\n }\n\n if (dragState.dropTargetId !== node.id || dragState.dropPosition !== position) {\n setDragState({ draggedNodeId: dragState.draggedNodeId, dropTargetId: node.id, dropPosition: position });\n }\n }, [store, acceptExternalDrops, node.id, isFolder, nodes, setDragState, expandNode, clearAutoExpand]);\n\n const handleDragLeave = useCallback((e: React.DragEvent) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node)) {\n clearAutoExpand();\n const { dragState } = store.get();\n if (dragState.dropTargetId === node.id) {\n setDragState({ ...dragState, dropTargetId: null, dropPosition: null });\n }\n }\n }, [store, node.id, setDragState, clearAutoExpand]);\n\n const handleDrop = useCallback((e: React.DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n clearAutoExpand();\n\n const { dragState } = store.get();\n const sourceId = dragState.draggedNodeId;\n const position = dragState.dropPosition ?? computeDropPosition(e, !!isFolder);\n\n if (sourceId) {\n // Internal node move.\n if (sourceId === node.id) return;\n if (isDescendantOf(nodes, sourceId, node.id)) return;\n moveNode?.(sourceId, node.id, position);\n } else if (acceptExternalDrops) {\n // External drop — files, items from other components, etc.\n externalDrop?.(e, node, position);\n }\n\n setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });\n }, [store, node, isFolder, nodes, moveNode, acceptExternalDrops, externalDrop, setDragState, clearAutoExpand]);\n\n // ---------------------------------------------------------------------------\n // Render\n // ---------------------------------------------------------------------------\n\n const canDrag = draggable && !node.disabled;\n const dropEnabled = draggable || acceptExternalDrops;\n\n return (\n <div\n data-react-fancy-tree-node=\"\"\n onDragOver={dropEnabled ? handleDragOver : undefined}\n onDragLeave={dropEnabled ? handleDragLeave : undefined}\n onDrop={dropEnabled ? handleDrop : undefined}\n >\n {/* Before drop indicator */}\n {isDropTarget && dropPosition === \"before\" && (\n <div\n data-react-fancy-tree-drop-indicator=\"before\"\n className=\"pointer-events-none h-0.5 rounded-full bg-blue-500\"\n style={{ marginLeft: paddingLeft }}\n />\n )}\n\n <button\n type=\"button\"\n draggable={canDrag}\n onDragStart={canDrag ? handleDragStart : undefined}\n onDragEnd={canDrag ? handleDragEnd : undefined}\n onClick={handleClick}\n onContextMenu={handleContextMenu}\n disabled={node.disabled}\n className={cn(\n \"flex w-full items-center gap-1 rounded-md py-0.5 text-left text-[13px] transition-colors\",\n isSelected\n ? \"bg-blue-500/15 text-blue-600 dark:text-blue-400\"\n : \"text-zinc-700 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800\",\n node.disabled && \"pointer-events-none opacity-40\",\n isDragging && \"opacity-50\",\n // Grab affordance. By default (`dragCursor=\"none\"`) the row keeps its\n // normal click cursor on hover — no open-hand \"move me\" cursor before\n // any drag — and only shows the closed-hand `grabbing` cursor while a\n // drag is actually underway (mousedown/drag). `dragCursor=\"grab\"` opts\n // back into the always-on grab cursor for whole-row drag handles (#14).\n canDrag &&\n (dragCursor === \"grab\" ? \"cursor-grab active:cursor-grabbing\" : \"active:cursor-grabbing\"),\n isDropTarget && dropPosition === \"inside\" && \"bg-blue-500/10 ring-1 ring-blue-500/30 ring-inset\",\n )}\n style={{ paddingLeft }}\n >\n {isFolder && <ChevronIcon open={isExpanded} />}\n {!isFolder && <span className=\"w-3.5 shrink-0\" />}\n {showIcons && (\n node.icon ?? (isFolder\n ? <FolderIcon open={isExpanded} />\n : <FileIcon ext={node.ext ?? node.label.split(\".\").pop()} />)\n )}\n <span className=\"truncate\">{node.label}</span>\n </button>\n\n {/* After drop indicator */}\n {isDropTarget && dropPosition === \"after\" && (\n <div\n data-react-fancy-tree-drop-indicator=\"after\"\n className=\"pointer-events-none h-0.5 rounded-full bg-blue-500\"\n style={{ marginLeft: paddingLeft }}\n />\n )}\n\n {/* A virtual list renders rows flat, so a row never renders its own children there. */}\n {!flat && isFolder && isExpanded && node.children && (\n <div data-react-fancy-tree-node-children=\"\">\n {node.children.map((child) => (\n <TreeNode key={child.id} node={child} depth={depth + 1} />\n ))}\n </div>\n )}\n </div>\n );\n}\n\nexport const TreeNode = memo(TreeNodeImpl);\n\nTreeNode.displayName = \"TreeNode\";\n","import { useMemo, useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { VirtualList } from \"../VirtualList\";\nimport { TreeNavContext } from \"./TreeNav.context\";\nimport { TreeNode } from \"./TreeNode\";\nimport { createTreeStore, TreeInternalsContext, type TreeInternals } from \"./tree-store\";\nimport type { TreeNavProps, TreeNodeData, DragState } from \"./TreeNav.types\";\n\nfunction collectFolderIds(nodes: TreeNodeData[]): string[] {\n const ids: string[] = [];\n for (const node of nodes) {\n if (node.children && node.children.length > 0) {\n ids.push(node.id);\n ids.push(...collectFolderIds(node.children));\n }\n }\n return ids;\n}\n\nconst EMPTY_DRAG_STATE: DragState = {\n draggedNodeId: null,\n dropTargetId: null,\n dropPosition: null,\n};\n\ninterface FlatRow {\n id: string;\n node: TreeNodeData;\n depth: number;\n}\n\n/** The rows currently visible — every node, descending only into expanded folders. */\nfunction flattenVisible(nodes: TreeNodeData[], expanded: ReadonlySet<string>): FlatRow[] {\n const rows: FlatRow[] = [];\n const walk = (list: TreeNodeData[], depth: number) => {\n for (const node of list) {\n rows.push({ id: node.id, node, depth });\n const isFolder = node.type === \"folder\" || (node.children && node.children.length > 0);\n if (isFolder && node.children && expanded.has(node.id)) walk(node.children, depth + 1);\n }\n };\n walk(nodes, 0);\n return rows;\n}\n\nfunction TreeNavRoot({\n nodes,\n selectedId,\n onSelect,\n onNodeContextMenu,\n draggable = false,\n onNodeMove,\n acceptExternalDrops = false,\n onExternalDrop,\n expandedIds: controlledExpanded,\n defaultExpandedIds,\n onExpandedChange,\n defaultExpandAll = false,\n indentSize = 16,\n showIcons = true,\n dragCursor = \"none\",\n virtualize = false,\n height = 400,\n rowHeight = 26,\n className,\n}: TreeNavProps) {\n const [internalExpanded, setInternalExpanded] = useState<string[]>(() => {\n if (defaultExpandedIds) return defaultExpandedIds;\n if (defaultExpandAll) return collectFolderIds(nodes);\n return [];\n });\n\n const isControlled = controlledExpanded !== undefined;\n const expandedIds = isControlled ? controlledExpanded : internalExpanded;\n // One Set per change, so a row's \"am I expanded?\" is a lookup, not a scan.\n const expanded = useMemo(() => new Set(expandedIds), [expandedIds]);\n\n const [dragState, setDragState] = useState<DragState>(EMPTY_DRAG_STATE);\n\n /*\n * The latest props and state, for handlers that must stay STABLE. A handler\n * whose identity changes on every click would change the context rows read,\n * and re-render every row — the exact cost this component is avoiding.\n */\n const latest = useRef({ expandedIds, isControlled, onExpandedChange, onSelect, onNodeContextMenu, onNodeMove, onExternalDrop });\n latest.current = { expandedIds, isControlled, onExpandedChange, onSelect, onNodeContextMenu, onNodeMove, onExternalDrop };\n\n const setExpanded = useCallback((next: string[]) => {\n if (!latest.current.isControlled) setInternalExpanded(next);\n latest.current.onExpandedChange?.(next);\n }, []);\n\n const toggle = useCallback(\n (id: string) => {\n const current = latest.current.expandedIds;\n setExpanded(current.includes(id) ? current.filter((v) => v !== id) : [...current, id]);\n },\n [setExpanded],\n );\n\n const expandNode = useCallback(\n (id: string) => {\n const current = latest.current.expandedIds;\n if (!current.includes(id)) setExpanded([...current, id]);\n },\n [setExpanded],\n );\n\n const select = useCallback((node: TreeNodeData) => latest.current.onSelect?.(node.id, node), []);\n const contextMenu = useCallback(\n (e: React.MouseEvent, node: TreeNodeData) => latest.current.onNodeContextMenu?.(e, node),\n [],\n );\n const moveNode = useCallback(\n (sourceId: string, targetId: string, position: Parameters<NonNullable<TreeNavProps[\"onNodeMove\"]>>[2]) =>\n latest.current.onNodeMove?.(sourceId, targetId, position),\n [],\n );\n const externalDrop = useCallback(\n (event: React.DragEvent, target: TreeNodeData, position: Parameters<NonNullable<TreeNavProps[\"onExternalDrop\"]>>[2]) =>\n latest.current.onExternalDrop?.(event, target, position),\n [],\n );\n\n // What rows subscribe to. Seeded with this render's values so the first paint\n // is right; kept current after each render that changes them.\n const [store] = useState(() => createTreeStore({ selectedId, expanded, dragState }));\n useLayoutEffect(() => {\n const current = store.get();\n if (current.selectedId !== selectedId || current.expanded !== expanded || current.dragState !== dragState) {\n store.set({ selectedId, expanded, dragState });\n }\n }, [store, selectedId, expanded, dragState]);\n\n const hasContextMenu = onNodeContextMenu !== undefined;\n const internals = useMemo<TreeInternals>(\n () => ({\n store,\n nodes,\n select,\n toggle,\n expandNode,\n setDragState,\n // Present only when the host gave one: a row then claims the right-click.\n contextMenu: hasContextMenu ? contextMenu : undefined,\n moveNode,\n externalDrop,\n indentSize,\n showIcons,\n draggable,\n dragCursor,\n acceptExternalDrops,\n flat: virtualize,\n }),\n [store, nodes, select, toggle, expandNode, hasContextMenu, contextMenu, moveNode, externalDrop,\n indentSize, showIcons, draggable, dragCursor, acceptExternalDrops, virtualize],\n );\n\n // Unchanged public context, still live for `useTreeNav()` callers. Rows no\n // longer read it, so its changing on a click re-renders only those callers.\n const ctx = useMemo(\n () => ({\n selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons,\n draggable, dragCursor, dragState, setDragState, onNodeMove, acceptExternalDrops, onExternalDrop, nodes, expandNode,\n }),\n [selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons,\n draggable, dragCursor, dragState, onNodeMove, acceptExternalDrops, onExternalDrop, nodes, expandNode],\n );\n\n const rows = useMemo(\n () => (virtualize ? flattenVisible(nodes, expanded) : []),\n [virtualize, nodes, expanded],\n );\n\n const handleDragEnd = useCallback(() => {\n setDragState(EMPTY_DRAG_STATE);\n }, []);\n\n const dropEnabled = draggable || acceptExternalDrops;\n\n return (\n <TreeNavContext.Provider value={ctx}>\n <TreeInternalsContext.Provider value={internals}>\n <nav\n data-react-fancy-tree-nav=\"\"\n data-react-fancy-tree-nav-virtual={virtualize ? \"\" : undefined}\n className={cn(\"flex flex-col gap-0.5 py-1 text-sm\", className)}\n onDragEnd={dropEnabled ? handleDragEnd : undefined}\n >\n {virtualize ? (\n <VirtualList\n items={rows}\n height={height}\n estimateRowHeight={rowHeight}\n renderRow={(row) => <TreeNode node={row.node} depth={row.depth} />}\n />\n ) : (\n nodes.map((node) => <TreeNode key={node.id} node={node} depth={0} />)\n )}\n </nav>\n </TreeInternalsContext.Provider>\n </TreeNavContext.Provider>\n );\n}\n\nTreeNavRoot.displayName = \"TreeNav\";\n\nexport const TreeNav = Object.assign(TreeNavRoot, {\n Node: TreeNode,\n});\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { VirtualList } from './chunk-Z4CW3U6C.js';
|
|
1
2
|
import { cn } from './chunk-MMW2JGKZ.js';
|
|
2
|
-
import { createContext,
|
|
3
|
-
import {
|
|
3
|
+
import { createContext, memo, useRef, useCallback, useEffect, useState, useMemo, useLayoutEffect, useContext, useSyncExternalStore } from 'react';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
5
|
|
|
5
6
|
var TreeNavContext = createContext(null);
|
|
6
7
|
function useTreeNav() {
|
|
@@ -10,6 +11,35 @@ function useTreeNav() {
|
|
|
10
11
|
}
|
|
11
12
|
return ctx;
|
|
12
13
|
}
|
|
14
|
+
function createTreeStore(initial) {
|
|
15
|
+
let state = initial;
|
|
16
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
17
|
+
return {
|
|
18
|
+
get: () => state,
|
|
19
|
+
set(next) {
|
|
20
|
+
state = next;
|
|
21
|
+
for (const listener of listeners) listener();
|
|
22
|
+
},
|
|
23
|
+
subscribe(listener) {
|
|
24
|
+
listeners.add(listener);
|
|
25
|
+
return () => listeners.delete(listener);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
var TreeInternalsContext = createContext(null);
|
|
30
|
+
function useTreeInternals() {
|
|
31
|
+
const internals = useContext(TreeInternalsContext);
|
|
32
|
+
if (!internals) throw new Error("TreeNav.Node must be used within a <TreeNav> component");
|
|
33
|
+
return internals;
|
|
34
|
+
}
|
|
35
|
+
function useTreeSlice(select) {
|
|
36
|
+
const { store } = useTreeInternals();
|
|
37
|
+
return useSyncExternalStore(
|
|
38
|
+
store.subscribe,
|
|
39
|
+
() => select(store.get()),
|
|
40
|
+
() => select(store.get())
|
|
41
|
+
);
|
|
42
|
+
}
|
|
13
43
|
var EXT_COLORS = {
|
|
14
44
|
ts: "#3178c6",
|
|
15
45
|
tsx: "#3178c6",
|
|
@@ -87,32 +117,33 @@ function computeDropPosition(e, isFolder) {
|
|
|
87
117
|
if (offsetY > third * 2) return "after";
|
|
88
118
|
return isFolder ? "inside" : "after";
|
|
89
119
|
}
|
|
90
|
-
function
|
|
120
|
+
function TreeNodeImpl({ node, depth }) {
|
|
91
121
|
const {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
expandedIds,
|
|
122
|
+
store,
|
|
123
|
+
nodes,
|
|
124
|
+
select,
|
|
96
125
|
toggle,
|
|
126
|
+
expandNode,
|
|
127
|
+
setDragState,
|
|
128
|
+
contextMenu,
|
|
129
|
+
moveNode,
|
|
130
|
+
externalDrop,
|
|
97
131
|
indentSize,
|
|
98
132
|
showIcons,
|
|
99
133
|
draggable,
|
|
100
134
|
dragCursor,
|
|
101
|
-
dragState,
|
|
102
|
-
setDragState,
|
|
103
|
-
onNodeMove,
|
|
104
135
|
acceptExternalDrops,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
expandNode
|
|
108
|
-
} = useTreeNav();
|
|
136
|
+
flat
|
|
137
|
+
} = useTreeInternals();
|
|
109
138
|
const isFolder = node.type === "folder" || node.children && node.children.length > 0;
|
|
110
|
-
const isExpanded =
|
|
111
|
-
const isSelected = selectedId === node.id;
|
|
139
|
+
const isExpanded = useTreeSlice((s) => s.expanded.has(node.id));
|
|
140
|
+
const isSelected = useTreeSlice((s) => s.selectedId === node.id);
|
|
141
|
+
const isDragging = useTreeSlice((s) => s.dragState.draggedNodeId === node.id);
|
|
142
|
+
const dropPosition = useTreeSlice(
|
|
143
|
+
(s) => s.dragState.dropTargetId === node.id ? s.dragState.dropPosition : null
|
|
144
|
+
);
|
|
145
|
+
const isDropTarget = dropPosition !== null;
|
|
112
146
|
const paddingLeft = depth * indentSize + 4;
|
|
113
|
-
const isDragging = dragState.draggedNodeId === node.id;
|
|
114
|
-
const isDropTarget = dragState.dropTargetId === node.id;
|
|
115
|
-
const dropPosition = isDropTarget ? dragState.dropPosition : null;
|
|
116
147
|
const autoExpandTimer = useRef(null);
|
|
117
148
|
const clearAutoExpand = useCallback(() => {
|
|
118
149
|
if (autoExpandTimer.current) {
|
|
@@ -126,12 +157,12 @@ function TreeNode({ node, depth }) {
|
|
|
126
157
|
if (isFolder) {
|
|
127
158
|
toggle(node.id);
|
|
128
159
|
}
|
|
129
|
-
|
|
160
|
+
select(node);
|
|
130
161
|
};
|
|
131
162
|
const handleContextMenu = (e) => {
|
|
132
|
-
if (
|
|
163
|
+
if (contextMenu) {
|
|
133
164
|
e.preventDefault();
|
|
134
|
-
|
|
165
|
+
contextMenu(e, node);
|
|
135
166
|
}
|
|
136
167
|
};
|
|
137
168
|
const handleDragStart = useCallback((e) => {
|
|
@@ -145,8 +176,9 @@ function TreeNode({ node, depth }) {
|
|
|
145
176
|
clearAutoExpand();
|
|
146
177
|
setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });
|
|
147
178
|
}, [clearAutoExpand, setDragState]);
|
|
148
|
-
const isExternalDrag = !dragState.draggedNodeId;
|
|
149
179
|
const handleDragOver = useCallback((e) => {
|
|
180
|
+
const { dragState } = store.get();
|
|
181
|
+
const isExternalDrag = !dragState.draggedNodeId;
|
|
150
182
|
if (isExternalDrag) {
|
|
151
183
|
if (!acceptExternalDrops) return;
|
|
152
184
|
} else {
|
|
@@ -158,7 +190,7 @@ function TreeNode({ node, depth }) {
|
|
|
158
190
|
e.stopPropagation();
|
|
159
191
|
e.dataTransfer.dropEffect = isExternalDrag ? "copy" : "move";
|
|
160
192
|
const position = computeDropPosition(e, !!isFolder);
|
|
161
|
-
if (isFolder && !
|
|
193
|
+
if (isFolder && !store.get().expanded.has(node.id) && position === "inside") {
|
|
162
194
|
if (!autoExpandTimer.current) {
|
|
163
195
|
autoExpandTimer.current = setTimeout(() => {
|
|
164
196
|
expandNode(node.id);
|
|
@@ -171,30 +203,32 @@ function TreeNode({ node, depth }) {
|
|
|
171
203
|
if (dragState.dropTargetId !== node.id || dragState.dropPosition !== position) {
|
|
172
204
|
setDragState({ draggedNodeId: dragState.draggedNodeId, dropTargetId: node.id, dropPosition: position });
|
|
173
205
|
}
|
|
174
|
-
}, [
|
|
206
|
+
}, [store, acceptExternalDrops, node.id, isFolder, nodes, setDragState, expandNode, clearAutoExpand]);
|
|
175
207
|
const handleDragLeave = useCallback((e) => {
|
|
176
208
|
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
177
209
|
clearAutoExpand();
|
|
210
|
+
const { dragState } = store.get();
|
|
178
211
|
if (dragState.dropTargetId === node.id) {
|
|
179
212
|
setDragState({ ...dragState, dropTargetId: null, dropPosition: null });
|
|
180
213
|
}
|
|
181
214
|
}
|
|
182
|
-
}, [
|
|
215
|
+
}, [store, node.id, setDragState, clearAutoExpand]);
|
|
183
216
|
const handleDrop = useCallback((e) => {
|
|
184
217
|
e.preventDefault();
|
|
185
218
|
e.stopPropagation();
|
|
186
219
|
clearAutoExpand();
|
|
220
|
+
const { dragState } = store.get();
|
|
187
221
|
const sourceId = dragState.draggedNodeId;
|
|
188
222
|
const position = dragState.dropPosition ?? computeDropPosition(e, !!isFolder);
|
|
189
223
|
if (sourceId) {
|
|
190
224
|
if (sourceId === node.id) return;
|
|
191
225
|
if (isDescendantOf(nodes, sourceId, node.id)) return;
|
|
192
|
-
|
|
226
|
+
moveNode?.(sourceId, node.id, position);
|
|
193
227
|
} else if (acceptExternalDrops) {
|
|
194
|
-
|
|
228
|
+
externalDrop?.(e, node, position);
|
|
195
229
|
}
|
|
196
230
|
setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });
|
|
197
|
-
}, [
|
|
231
|
+
}, [store, node, isFolder, nodes, moveNode, acceptExternalDrops, externalDrop, setDragState, clearAutoExpand]);
|
|
198
232
|
const canDrag = draggable && !node.disabled;
|
|
199
233
|
const dropEnabled = draggable || acceptExternalDrops;
|
|
200
234
|
return /* @__PURE__ */ jsxs(
|
|
@@ -253,11 +287,12 @@ function TreeNode({ node, depth }) {
|
|
|
253
287
|
style: { marginLeft: paddingLeft }
|
|
254
288
|
}
|
|
255
289
|
),
|
|
256
|
-
isFolder && isExpanded && node.children && /* @__PURE__ */ jsx("div", { "data-react-fancy-tree-node-children": "", children: node.children.map((child) => /* @__PURE__ */ jsx(TreeNode, { node: child, depth: depth + 1 }, child.id)) })
|
|
290
|
+
!flat && isFolder && isExpanded && node.children && /* @__PURE__ */ jsx("div", { "data-react-fancy-tree-node-children": "", children: node.children.map((child) => /* @__PURE__ */ jsx(TreeNode, { node: child, depth: depth + 1 }, child.id)) })
|
|
257
291
|
]
|
|
258
292
|
}
|
|
259
293
|
);
|
|
260
294
|
}
|
|
295
|
+
var TreeNode = memo(TreeNodeImpl);
|
|
261
296
|
TreeNode.displayName = "TreeNode";
|
|
262
297
|
function collectFolderIds(nodes) {
|
|
263
298
|
const ids = [];
|
|
@@ -274,6 +309,18 @@ var EMPTY_DRAG_STATE = {
|
|
|
274
309
|
dropTargetId: null,
|
|
275
310
|
dropPosition: null
|
|
276
311
|
};
|
|
312
|
+
function flattenVisible(nodes, expanded) {
|
|
313
|
+
const rows = [];
|
|
314
|
+
const walk = (list, depth) => {
|
|
315
|
+
for (const node of list) {
|
|
316
|
+
rows.push({ id: node.id, node, depth });
|
|
317
|
+
const isFolder = node.type === "folder" || node.children && node.children.length > 0;
|
|
318
|
+
if (isFolder && node.children && expanded.has(node.id)) walk(node.children, depth + 1);
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
walk(nodes, 0);
|
|
322
|
+
return rows;
|
|
323
|
+
}
|
|
277
324
|
function TreeNavRoot({
|
|
278
325
|
nodes,
|
|
279
326
|
selectedId,
|
|
@@ -290,6 +337,9 @@ function TreeNavRoot({
|
|
|
290
337
|
indentSize = 16,
|
|
291
338
|
showIcons = true,
|
|
292
339
|
dragCursor = "none",
|
|
340
|
+
virtualize = false,
|
|
341
|
+
height = 400,
|
|
342
|
+
rowHeight = 26,
|
|
293
343
|
className
|
|
294
344
|
}) {
|
|
295
345
|
const [internalExpanded, setInternalExpanded] = useState(() => {
|
|
@@ -299,31 +349,86 @@ function TreeNavRoot({
|
|
|
299
349
|
});
|
|
300
350
|
const isControlled = controlledExpanded !== void 0;
|
|
301
351
|
const expandedIds = isControlled ? controlledExpanded : internalExpanded;
|
|
352
|
+
const expanded = useMemo(() => new Set(expandedIds), [expandedIds]);
|
|
353
|
+
const [dragState, setDragState] = useState(EMPTY_DRAG_STATE);
|
|
354
|
+
const latest = useRef({ expandedIds, isControlled, onExpandedChange, onSelect, onNodeContextMenu, onNodeMove, onExternalDrop });
|
|
355
|
+
latest.current = { expandedIds, isControlled, onExpandedChange, onSelect, onNodeContextMenu, onNodeMove, onExternalDrop };
|
|
356
|
+
const setExpanded = useCallback((next) => {
|
|
357
|
+
if (!latest.current.isControlled) setInternalExpanded(next);
|
|
358
|
+
latest.current.onExpandedChange?.(next);
|
|
359
|
+
}, []);
|
|
302
360
|
const toggle = useCallback(
|
|
303
361
|
(id) => {
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
setInternalExpanded(next);
|
|
307
|
-
}
|
|
308
|
-
onExpandedChange?.(next);
|
|
362
|
+
const current = latest.current.expandedIds;
|
|
363
|
+
setExpanded(current.includes(id) ? current.filter((v) => v !== id) : [...current, id]);
|
|
309
364
|
},
|
|
310
|
-
[
|
|
365
|
+
[setExpanded]
|
|
311
366
|
);
|
|
312
367
|
const expandNode = useCallback(
|
|
313
368
|
(id) => {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
if (!isControlled) {
|
|
317
|
-
setInternalExpanded(next);
|
|
318
|
-
}
|
|
319
|
-
onExpandedChange?.(next);
|
|
369
|
+
const current = latest.current.expandedIds;
|
|
370
|
+
if (!current.includes(id)) setExpanded([...current, id]);
|
|
320
371
|
},
|
|
321
|
-
[
|
|
372
|
+
[setExpanded]
|
|
373
|
+
);
|
|
374
|
+
const select = useCallback((node) => latest.current.onSelect?.(node.id, node), []);
|
|
375
|
+
const contextMenu = useCallback(
|
|
376
|
+
(e, node) => latest.current.onNodeContextMenu?.(e, node),
|
|
377
|
+
[]
|
|
378
|
+
);
|
|
379
|
+
const moveNode = useCallback(
|
|
380
|
+
(sourceId, targetId, position) => latest.current.onNodeMove?.(sourceId, targetId, position),
|
|
381
|
+
[]
|
|
382
|
+
);
|
|
383
|
+
const externalDrop = useCallback(
|
|
384
|
+
(event, target, position) => latest.current.onExternalDrop?.(event, target, position),
|
|
385
|
+
[]
|
|
386
|
+
);
|
|
387
|
+
const [store] = useState(() => createTreeStore({ selectedId, expanded, dragState }));
|
|
388
|
+
useLayoutEffect(() => {
|
|
389
|
+
const current = store.get();
|
|
390
|
+
if (current.selectedId !== selectedId || current.expanded !== expanded || current.dragState !== dragState) {
|
|
391
|
+
store.set({ selectedId, expanded, dragState });
|
|
392
|
+
}
|
|
393
|
+
}, [store, selectedId, expanded, dragState]);
|
|
394
|
+
const hasContextMenu = onNodeContextMenu !== void 0;
|
|
395
|
+
const internals = useMemo(
|
|
396
|
+
() => ({
|
|
397
|
+
store,
|
|
398
|
+
nodes,
|
|
399
|
+
select,
|
|
400
|
+
toggle,
|
|
401
|
+
expandNode,
|
|
402
|
+
setDragState,
|
|
403
|
+
// Present only when the host gave one: a row then claims the right-click.
|
|
404
|
+
contextMenu: hasContextMenu ? contextMenu : void 0,
|
|
405
|
+
moveNode,
|
|
406
|
+
externalDrop,
|
|
407
|
+
indentSize,
|
|
408
|
+
showIcons,
|
|
409
|
+
draggable,
|
|
410
|
+
dragCursor,
|
|
411
|
+
acceptExternalDrops,
|
|
412
|
+
flat: virtualize
|
|
413
|
+
}),
|
|
414
|
+
[
|
|
415
|
+
store,
|
|
416
|
+
nodes,
|
|
417
|
+
select,
|
|
418
|
+
toggle,
|
|
419
|
+
expandNode,
|
|
420
|
+
hasContextMenu,
|
|
421
|
+
contextMenu,
|
|
422
|
+
moveNode,
|
|
423
|
+
externalDrop,
|
|
424
|
+
indentSize,
|
|
425
|
+
showIcons,
|
|
426
|
+
draggable,
|
|
427
|
+
dragCursor,
|
|
428
|
+
acceptExternalDrops,
|
|
429
|
+
virtualize
|
|
430
|
+
]
|
|
322
431
|
);
|
|
323
|
-
const [dragState, setDragState] = useState(EMPTY_DRAG_STATE);
|
|
324
|
-
const handleDragEnd = useCallback(() => {
|
|
325
|
-
setDragState(EMPTY_DRAG_STATE);
|
|
326
|
-
}, []);
|
|
327
432
|
const ctx = useMemo(
|
|
328
433
|
() => ({
|
|
329
434
|
selectedId,
|
|
@@ -361,16 +466,32 @@ function TreeNavRoot({
|
|
|
361
466
|
expandNode
|
|
362
467
|
]
|
|
363
468
|
);
|
|
469
|
+
const rows = useMemo(
|
|
470
|
+
() => virtualize ? flattenVisible(nodes, expanded) : [],
|
|
471
|
+
[virtualize, nodes, expanded]
|
|
472
|
+
);
|
|
473
|
+
const handleDragEnd = useCallback(() => {
|
|
474
|
+
setDragState(EMPTY_DRAG_STATE);
|
|
475
|
+
}, []);
|
|
364
476
|
const dropEnabled = draggable || acceptExternalDrops;
|
|
365
|
-
return /* @__PURE__ */ jsx(TreeNavContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
|
|
477
|
+
return /* @__PURE__ */ jsx(TreeNavContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(TreeInternalsContext.Provider, { value: internals, children: /* @__PURE__ */ jsx(
|
|
366
478
|
"nav",
|
|
367
479
|
{
|
|
368
480
|
"data-react-fancy-tree-nav": "",
|
|
481
|
+
"data-react-fancy-tree-nav-virtual": virtualize ? "" : void 0,
|
|
369
482
|
className: cn("flex flex-col gap-0.5 py-1 text-sm", className),
|
|
370
483
|
onDragEnd: dropEnabled ? handleDragEnd : void 0,
|
|
371
|
-
children:
|
|
484
|
+
children: virtualize ? /* @__PURE__ */ jsx(
|
|
485
|
+
VirtualList,
|
|
486
|
+
{
|
|
487
|
+
items: rows,
|
|
488
|
+
height,
|
|
489
|
+
estimateRowHeight: rowHeight,
|
|
490
|
+
renderRow: (row) => /* @__PURE__ */ jsx(TreeNode, { node: row.node, depth: row.depth })
|
|
491
|
+
}
|
|
492
|
+
) : nodes.map((node) => /* @__PURE__ */ jsx(TreeNode, { node, depth: 0 }, node.id))
|
|
372
493
|
}
|
|
373
|
-
) });
|
|
494
|
+
) }) });
|
|
374
495
|
}
|
|
375
496
|
TreeNavRoot.displayName = "TreeNav";
|
|
376
497
|
var TreeNav = Object.assign(TreeNavRoot, {
|
|
@@ -378,5 +499,5 @@ var TreeNav = Object.assign(TreeNavRoot, {
|
|
|
378
499
|
});
|
|
379
500
|
|
|
380
501
|
export { TreeNav, useTreeNav };
|
|
381
|
-
//# sourceMappingURL=chunk-
|
|
382
|
-
//# sourceMappingURL=chunk-
|
|
502
|
+
//# sourceMappingURL=chunk-ZVXOL5H3.js.map
|
|
503
|
+
//# sourceMappingURL=chunk-ZVXOL5H3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/TreeNav/TreeNav.context.ts","../src/components/TreeNav/tree-store.ts","../src/components/TreeNav/TreeNode.tsx","../src/components/TreeNav/TreeNav.tsx"],"names":["createContext","useContext","useRef","useCallback","jsx"],"mappings":";;;;;AAGO,IAAM,cAAA,GAAiB,cAA0C,IAAI,CAAA;AAErE,SAAS,UAAA,GAAkC;AAChD,EAAA,MAAM,GAAA,GAAM,WAAW,cAAc,CAAA;AACrC,EAAA,IAAI,CAAC,GAAA,EAAK;AACR,IAAA,MAAM,IAAI,MAAM,sDAAsD,CAAA;AAAA,EACxE;AACA,EAAA,OAAO,GAAA;AACT;ACKO,SAAS,gBAAgB,OAAA,EAA+B;AAC7D,EAAA,IAAI,KAAA,GAAQ,OAAA;AACZ,EAAA,MAAM,SAAA,uBAAgB,GAAA,EAAgB;AACtC,EAAA,OAAO;AAAA,IACL,KAAK,MAAM,KAAA;AAAA,IACX,IAAI,IAAA,EAAM;AACR,MAAA,KAAA,GAAQ,IAAA;AACR,MAAA,KAAA,MAAW,QAAA,IAAY,WAAW,QAAA,EAAS;AAAA,IAC7C,CAAA;AAAA,IACA,UAAU,QAAA,EAAU;AAClB,MAAA,SAAA,CAAU,IAAI,QAAQ,CAAA;AACtB,MAAA,OAAO,MAAM,SAAA,CAAU,MAAA,CAAO,QAAQ,CAAA;AAAA,IACxC;AAAA,GACF;AACF;AA+BO,IAAM,oBAAA,GAAuBA,cAAoC,IAAI,CAAA;AAErE,SAAS,gBAAA,GAAkC;AAChD,EAAA,MAAM,SAAA,GAAYC,WAAW,oBAAoB,CAAA;AACjD,EAAA,IAAI,CAAC,SAAA,EAAW,MAAM,IAAI,MAAM,wDAAwD,CAAA;AACxF,EAAA,OAAO,SAAA;AACT;AAGO,SAAS,aAAgB,MAAA,EAAoC;AAClE,E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AAAA;AAAA,OAClE,GAEA,KAAA,CAAM,GAAA,CAAI,CAAC,IAAA,qBAASA,GAAAA,CAAC,QAAA,EAAA,EAAuB,IAAA,EAAY,KAAA,EAAO,CAAA,EAAA,EAA5B,IAAA,CAAK,EAA0B,CAAE;AAAA;AAAA,KAG1E,CAAA,EACF,CAAA;AAEJ;AAEA,WAAA,CAAY,WAAA,GAAc,SAAA;AAEnB,IAAM,OAAA,GAAU,MAAA,CAAO,MAAA,CAAO,WAAA,EAAa;AAAA,EAChD,IAAA,EAAM;AACR,CAAC","file":"chunk-ZVXOL5H3.js","sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { TreeNavContextValue } from \"./TreeNav.types\";\n\nexport const TreeNavContext = createContext<TreeNavContextValue | null>(null);\n\nexport function useTreeNav(): TreeNavContextValue {\n const ctx = useContext(TreeNavContext);\n if (!ctx) {\n throw new Error(\"useTreeNav must be used within a <TreeNav> component\");\n }\n return ctx;\n}\n","import { createContext, useContext, useSyncExternalStore } from \"react\";\nimport type { DragState, DropPosition, TreeNodeData } from \"./TreeNav.types\";\n\n/** What changes as someone clicks, toggles and drags — the state rows subscribe to. */\nexport interface TreeState {\n selectedId?: string;\n expanded: ReadonlySet<string>;\n dragState: DragState;\n}\n\nexport interface TreeStore {\n get(): TreeState;\n set(next: TreeState): void;\n subscribe(listener: () => void): () => void;\n}\n\nexport function createTreeStore(initial: TreeState): TreeStore {\n let state = initial;\n const listeners = new Set<() => void>();\n return {\n get: () => state,\n set(next) {\n state = next;\n for (const listener of listeners) listener();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n\n/**\n * Everything a row needs that does NOT change on a click. Handlers are stable\n * (they read the latest props and state when called), so this value only changes\n * when the tree's data or configuration does.\n *\n * Kept apart from the public `TreeNavContext` on purpose: that one still carries\n * live `selectedId` / `expandedIds` for `useTreeNav()` callers, and any component\n * reading it re-renders on every click. Rows no longer read it — which is the\n * whole fix: a click used to re-render every row in the tree.\n */\nexport interface TreeInternals {\n store: TreeStore;\n nodes: TreeNodeData[];\n select: (node: TreeNodeData) => void;\n toggle: (id: string) => void;\n expandNode: (id: string) => void;\n setDragState: (state: DragState) => void;\n contextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;\n moveNode?: (sourceId: string, targetId: string, position: DropPosition) => void;\n externalDrop?: (event: React.DragEvent, target: TreeNodeData, position: DropPosition) => void;\n indentSize: number;\n showIcons: boolean;\n draggable: boolean;\n dragCursor: \"grab\" | \"none\";\n acceptExternalDrops: boolean;\n /** Rows are rendered flat by a virtual list, so a row never renders its children. */\n flat: boolean;\n}\n\nexport const TreeInternalsContext = createContext<TreeInternals | null>(null);\n\nexport function useTreeInternals(): TreeInternals {\n const internals = useContext(TreeInternalsContext);\n if (!internals) throw new Error(\"TreeNav.Node must be used within a <TreeNav> component\");\n return internals;\n}\n\n/** Subscribe to ONE derived value; the row re-renders only when that value changes. */\nexport function useTreeSlice<T>(select: (state: TreeState) => T): T {\n const { store } = useTreeInternals();\n return useSyncExternalStore(\n store.subscribe,\n () => select(store.get()),\n () => select(store.get()),\n );\n}\n","import { memo, useRef, useEffect, useCallback } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { useTreeInternals, useTreeSlice } from \"./tree-store\";\nimport type { TreeNodeProps, TreeNodeData, DropPosition } from \"./TreeNav.types\";\n\nconst EXT_COLORS: Record<string, string> = {\n ts: \"#3178c6\",\n tsx: \"#3178c6\",\n js: \"#f7df1e\",\n jsx: \"#f7df1e\",\n php: \"#777bb4\",\n html: \"#e34c26\",\n htm: \"#e34c26\",\n css: \"#264de4\",\n json: \"#a1a1aa\",\n md: \"#71717a\",\n yaml: \"#cb171e\",\n yml: \"#cb171e\",\n};\n\nfunction FileIcon({ ext }: { ext?: string }) {\n const color = (ext && EXT_COLORS[ext.toLowerCase()]) || \"#71717a\";\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n <path d=\"M4 1h5.5L13 4.5V14a1 1 0 01-1 1H4a1 1 0 01-1-1V2a1 1 0 011-1z\" stroke={color} strokeWidth=\"1.2\" />\n <path d=\"M9 1v4h4\" stroke={color} strokeWidth=\"1.2\" />\n </svg>\n );\n}\n\nfunction FolderIcon({ open }: { open: boolean }) {\n if (open) {\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n <path d=\"M1.5 3.5a1 1 0 011-1h3l1.5 1.5H13a1 1 0 011 1V5H2.5V3.5z\" fill=\"#fbbf24\" />\n <path d=\"M1 6h13l-1.5 7.5H2.5L1 6z\" fill=\"#fbbf24\" opacity=\"0.7\" />\n </svg>\n );\n }\n return (\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" fill=\"none\" className=\"shrink-0\">\n <path d=\"M1.5 3a1 1 0 011-1h3l1.5 1.5H13a1 1 0 011 1v8a1 1 0 01-1 1H2.5a1 1 0 01-1-1V3z\" fill=\"#fbbf24\" />\n </svg>\n );\n}\n\nfunction ChevronIcon({ open }: { open: boolean }) {\n return (\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n className={cn(\"shrink-0 transition-transform duration-150\", open && \"rotate-90\")}\n >\n <polyline points=\"9 18 15 12 9 6\" />\n </svg>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Utilities\n// ---------------------------------------------------------------------------\n\nfunction isDescendantOf(\n nodes: TreeNodeData[],\n ancestorId: string,\n targetId: string,\n): boolean {\n function findNode(haystack: TreeNodeData[], id: string): TreeNodeData | undefined {\n for (const n of haystack) {\n if (n.id === id) return n;\n if (n.children) {\n const found = findNode(n.children, id);\n if (found) return found;\n }\n }\n return undefined;\n }\n\n function hasDescendant(node: TreeNodeData, id: string): boolean {\n if (!node.children) return false;\n for (const child of node.children) {\n if (child.id === id) return true;\n if (hasDescendant(child, id)) return true;\n }\n return false;\n }\n\n const ancestor = findNode(nodes, ancestorId);\n return ancestor ? hasDescendant(ancestor, targetId) : false;\n}\n\nfunction computeDropPosition(\n e: React.DragEvent,\n isFolder: boolean,\n): DropPosition {\n const rect = e.currentTarget.getBoundingClientRect();\n const offsetY = e.clientY - rect.top;\n const third = rect.height / 3;\n\n if (offsetY < third) return \"before\";\n if (offsetY > third * 2) return \"after\";\n return isFolder ? \"inside\" : \"after\";\n}\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\n\n/**\n * One row (and, when nested, its expanded children).\n *\n * Reads what changes on a click — selection, expansion, drag — as per-row slices\n * of a store, so a click re-renders only the rows whose slice changed. It used to\n * read one context holding all of it, so every click re-rendered every row:\n * 175-267 ms per click on a 5,000-node tree. `memo` keeps a parent's re-render\n * from reaching rows whose `node` and `depth` did not change.\n */\nfunction TreeNodeImpl({ node, depth }: TreeNodeProps) {\n const {\n store, nodes, select, toggle, expandNode, setDragState, contextMenu, moveNode, externalDrop,\n indentSize, showIcons, draggable, dragCursor, acceptExternalDrops, flat,\n } = useTreeInternals();\n\n const isFolder = node.type === \"folder\" || (node.children && node.children.length > 0);\n const isExpanded = useTreeSlice((s) => s.expanded.has(node.id));\n const isSelected = useTreeSlice((s) => s.selectedId === node.id);\n const isDragging = useTreeSlice((s) => s.dragState.draggedNodeId === node.id);\n const dropPosition = useTreeSlice((s) =>\n s.dragState.dropTargetId === node.id ? s.dragState.dropPosition : null,\n );\n const isDropTarget = dropPosition !== null;\n const paddingLeft = depth * indentSize + 4;\n\n // Auto-expand timer for folders during drag\n const autoExpandTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n const clearAutoExpand = useCallback(() => {\n if (autoExpandTimer.current) {\n clearTimeout(autoExpandTimer.current);\n autoExpandTimer.current = null;\n }\n }, []);\n\n useEffect(() => clearAutoExpand, [clearAutoExpand]);\n\n // ---------------------------------------------------------------------------\n // Click handlers\n // ---------------------------------------------------------------------------\n\n const handleClick = () => {\n if (node.disabled) return;\n if (isFolder) {\n toggle(node.id);\n }\n select(node);\n };\n\n const handleContextMenu = (e: React.MouseEvent) => {\n if (contextMenu) {\n e.preventDefault();\n contextMenu(e, node);\n }\n };\n\n // ---------------------------------------------------------------------------\n // Drag source handlers\n // ---------------------------------------------------------------------------\n\n const handleDragStart = useCallback((e: React.DragEvent) => {\n e.dataTransfer.setData(\"text/plain\", node.id);\n e.dataTransfer.effectAllowed = \"move\";\n // Set state async so the browser captures the element for the drag ghost first\n requestAnimationFrame(() => {\n setDragState({ draggedNodeId: node.id, dropTargetId: null, dropPosition: null });\n });\n }, [node.id, setDragState]);\n\n const handleDragEnd = useCallback(() => {\n clearAutoExpand();\n setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });\n }, [clearAutoExpand, setDragState]);\n\n // ---------------------------------------------------------------------------\n // Drop target handlers (on outer div). Drag state is read from the store when\n // the event fires, so a row does not re-render as a drag moves elsewhere.\n // ---------------------------------------------------------------------------\n\n const handleDragOver = useCallback((e: React.DragEvent) => {\n const { dragState } = store.get();\n const isExternalDrag = !dragState.draggedNodeId;\n if (isExternalDrag) {\n // External drop accepted only when host opted in.\n if (!acceptExternalDrops) return;\n } else {\n const sourceId = dragState.draggedNodeId!;\n if (sourceId === node.id) return;\n if (isDescendantOf(nodes, sourceId, node.id)) return;\n }\n\n e.preventDefault();\n e.stopPropagation();\n e.dataTransfer.dropEffect = isExternalDrag ? \"copy\" : \"move\";\n\n const position = computeDropPosition(e, !!isFolder);\n\n // Auto-expand collapsed folders when hovering \"inside\"\n if (isFolder && !store.get().expanded.has(node.id) && position === \"inside\") {\n if (!autoExpandTimer.current) {\n autoExpandTimer.current = setTimeout(() => {\n expandNode(node.id);\n autoExpandTimer.current = null;\n }, 500);\n }\n } else {\n clearAutoExpand();\n }\n\n if (dragState.dropTargetId !== node.id || dragState.dropPosition !== position) {\n setDragState({ draggedNodeId: dragState.draggedNodeId, dropTargetId: node.id, dropPosition: position });\n }\n }, [store, acceptExternalDrops, node.id, isFolder, nodes, setDragState, expandNode, clearAutoExpand]);\n\n const handleDragLeave = useCallback((e: React.DragEvent) => {\n if (!e.currentTarget.contains(e.relatedTarget as Node)) {\n clearAutoExpand();\n const { dragState } = store.get();\n if (dragState.dropTargetId === node.id) {\n setDragState({ ...dragState, dropTargetId: null, dropPosition: null });\n }\n }\n }, [store, node.id, setDragState, clearAutoExpand]);\n\n const handleDrop = useCallback((e: React.DragEvent) => {\n e.preventDefault();\n e.stopPropagation();\n clearAutoExpand();\n\n const { dragState } = store.get();\n const sourceId = dragState.draggedNodeId;\n const position = dragState.dropPosition ?? computeDropPosition(e, !!isFolder);\n\n if (sourceId) {\n // Internal node move.\n if (sourceId === node.id) return;\n if (isDescendantOf(nodes, sourceId, node.id)) return;\n moveNode?.(sourceId, node.id, position);\n } else if (acceptExternalDrops) {\n // External drop — files, items from other components, etc.\n externalDrop?.(e, node, position);\n }\n\n setDragState({ draggedNodeId: null, dropTargetId: null, dropPosition: null });\n }, [store, node, isFolder, nodes, moveNode, acceptExternalDrops, externalDrop, setDragState, clearAutoExpand]);\n\n // ---------------------------------------------------------------------------\n // Render\n // ---------------------------------------------------------------------------\n\n const canDrag = draggable && !node.disabled;\n const dropEnabled = draggable || acceptExternalDrops;\n\n return (\n <div\n data-react-fancy-tree-node=\"\"\n onDragOver={dropEnabled ? handleDragOver : undefined}\n onDragLeave={dropEnabled ? handleDragLeave : undefined}\n onDrop={dropEnabled ? handleDrop : undefined}\n >\n {/* Before drop indicator */}\n {isDropTarget && dropPosition === \"before\" && (\n <div\n data-react-fancy-tree-drop-indicator=\"before\"\n className=\"pointer-events-none h-0.5 rounded-full bg-blue-500\"\n style={{ marginLeft: paddingLeft }}\n />\n )}\n\n <button\n type=\"button\"\n draggable={canDrag}\n onDragStart={canDrag ? handleDragStart : undefined}\n onDragEnd={canDrag ? handleDragEnd : undefined}\n onClick={handleClick}\n onContextMenu={handleContextMenu}\n disabled={node.disabled}\n className={cn(\n \"flex w-full items-center gap-1 rounded-md py-0.5 text-left text-[13px] transition-colors\",\n isSelected\n ? \"bg-blue-500/15 text-blue-600 dark:text-blue-400\"\n : \"text-zinc-700 hover:bg-zinc-100 dark:text-zinc-300 dark:hover:bg-zinc-800\",\n node.disabled && \"pointer-events-none opacity-40\",\n isDragging && \"opacity-50\",\n // Grab affordance. By default (`dragCursor=\"none\"`) the row keeps its\n // normal click cursor on hover — no open-hand \"move me\" cursor before\n // any drag — and only shows the closed-hand `grabbing` cursor while a\n // drag is actually underway (mousedown/drag). `dragCursor=\"grab\"` opts\n // back into the always-on grab cursor for whole-row drag handles (#14).\n canDrag &&\n (dragCursor === \"grab\" ? \"cursor-grab active:cursor-grabbing\" : \"active:cursor-grabbing\"),\n isDropTarget && dropPosition === \"inside\" && \"bg-blue-500/10 ring-1 ring-blue-500/30 ring-inset\",\n )}\n style={{ paddingLeft }}\n >\n {isFolder && <ChevronIcon open={isExpanded} />}\n {!isFolder && <span className=\"w-3.5 shrink-0\" />}\n {showIcons && (\n node.icon ?? (isFolder\n ? <FolderIcon open={isExpanded} />\n : <FileIcon ext={node.ext ?? node.label.split(\".\").pop()} />)\n )}\n <span className=\"truncate\">{node.label}</span>\n </button>\n\n {/* After drop indicator */}\n {isDropTarget && dropPosition === \"after\" && (\n <div\n data-react-fancy-tree-drop-indicator=\"after\"\n className=\"pointer-events-none h-0.5 rounded-full bg-blue-500\"\n style={{ marginLeft: paddingLeft }}\n />\n )}\n\n {/* A virtual list renders rows flat, so a row never renders its own children there. */}\n {!flat && isFolder && isExpanded && node.children && (\n <div data-react-fancy-tree-node-children=\"\">\n {node.children.map((child) => (\n <TreeNode key={child.id} node={child} depth={depth + 1} />\n ))}\n </div>\n )}\n </div>\n );\n}\n\nexport const TreeNode = memo(TreeNodeImpl);\n\nTreeNode.displayName = \"TreeNode\";\n","import { useMemo, useCallback, useLayoutEffect, useRef, useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\nimport { VirtualList } from \"../VirtualList\";\nimport { TreeNavContext } from \"./TreeNav.context\";\nimport { TreeNode } from \"./TreeNode\";\nimport { createTreeStore, TreeInternalsContext, type TreeInternals } from \"./tree-store\";\nimport type { TreeNavProps, TreeNodeData, DragState } from \"./TreeNav.types\";\n\nfunction collectFolderIds(nodes: TreeNodeData[]): string[] {\n const ids: string[] = [];\n for (const node of nodes) {\n if (node.children && node.children.length > 0) {\n ids.push(node.id);\n ids.push(...collectFolderIds(node.children));\n }\n }\n return ids;\n}\n\nconst EMPTY_DRAG_STATE: DragState = {\n draggedNodeId: null,\n dropTargetId: null,\n dropPosition: null,\n};\n\ninterface FlatRow {\n id: string;\n node: TreeNodeData;\n depth: number;\n}\n\n/** The rows currently visible — every node, descending only into expanded folders. */\nfunction flattenVisible(nodes: TreeNodeData[], expanded: ReadonlySet<string>): FlatRow[] {\n const rows: FlatRow[] = [];\n const walk = (list: TreeNodeData[], depth: number) => {\n for (const node of list) {\n rows.push({ id: node.id, node, depth });\n const isFolder = node.type === \"folder\" || (node.children && node.children.length > 0);\n if (isFolder && node.children && expanded.has(node.id)) walk(node.children, depth + 1);\n }\n };\n walk(nodes, 0);\n return rows;\n}\n\nfunction TreeNavRoot({\n nodes,\n selectedId,\n onSelect,\n onNodeContextMenu,\n draggable = false,\n onNodeMove,\n acceptExternalDrops = false,\n onExternalDrop,\n expandedIds: controlledExpanded,\n defaultExpandedIds,\n onExpandedChange,\n defaultExpandAll = false,\n indentSize = 16,\n showIcons = true,\n dragCursor = \"none\",\n virtualize = false,\n height = 400,\n rowHeight = 26,\n className,\n}: TreeNavProps) {\n const [internalExpanded, setInternalExpanded] = useState<string[]>(() => {\n if (defaultExpandedIds) return defaultExpandedIds;\n if (defaultExpandAll) return collectFolderIds(nodes);\n return [];\n });\n\n const isControlled = controlledExpanded !== undefined;\n const expandedIds = isControlled ? controlledExpanded : internalExpanded;\n // One Set per change, so a row's \"am I expanded?\" is a lookup, not a scan.\n const expanded = useMemo(() => new Set(expandedIds), [expandedIds]);\n\n const [dragState, setDragState] = useState<DragState>(EMPTY_DRAG_STATE);\n\n /*\n * The latest props and state, for handlers that must stay STABLE. A handler\n * whose identity changes on every click would change the context rows read,\n * and re-render every row — the exact cost this component is avoiding.\n */\n const latest = useRef({ expandedIds, isControlled, onExpandedChange, onSelect, onNodeContextMenu, onNodeMove, onExternalDrop });\n latest.current = { expandedIds, isControlled, onExpandedChange, onSelect, onNodeContextMenu, onNodeMove, onExternalDrop };\n\n const setExpanded = useCallback((next: string[]) => {\n if (!latest.current.isControlled) setInternalExpanded(next);\n latest.current.onExpandedChange?.(next);\n }, []);\n\n const toggle = useCallback(\n (id: string) => {\n const current = latest.current.expandedIds;\n setExpanded(current.includes(id) ? current.filter((v) => v !== id) : [...current, id]);\n },\n [setExpanded],\n );\n\n const expandNode = useCallback(\n (id: string) => {\n const current = latest.current.expandedIds;\n if (!current.includes(id)) setExpanded([...current, id]);\n },\n [setExpanded],\n );\n\n const select = useCallback((node: TreeNodeData) => latest.current.onSelect?.(node.id, node), []);\n const contextMenu = useCallback(\n (e: React.MouseEvent, node: TreeNodeData) => latest.current.onNodeContextMenu?.(e, node),\n [],\n );\n const moveNode = useCallback(\n (sourceId: string, targetId: string, position: Parameters<NonNullable<TreeNavProps[\"onNodeMove\"]>>[2]) =>\n latest.current.onNodeMove?.(sourceId, targetId, position),\n [],\n );\n const externalDrop = useCallback(\n (event: React.DragEvent, target: TreeNodeData, position: Parameters<NonNullable<TreeNavProps[\"onExternalDrop\"]>>[2]) =>\n latest.current.onExternalDrop?.(event, target, position),\n [],\n );\n\n // What rows subscribe to. Seeded with this render's values so the first paint\n // is right; kept current after each render that changes them.\n const [store] = useState(() => createTreeStore({ selectedId, expanded, dragState }));\n useLayoutEffect(() => {\n const current = store.get();\n if (current.selectedId !== selectedId || current.expanded !== expanded || current.dragState !== dragState) {\n store.set({ selectedId, expanded, dragState });\n }\n }, [store, selectedId, expanded, dragState]);\n\n const hasContextMenu = onNodeContextMenu !== undefined;\n const internals = useMemo<TreeInternals>(\n () => ({\n store,\n nodes,\n select,\n toggle,\n expandNode,\n setDragState,\n // Present only when the host gave one: a row then claims the right-click.\n contextMenu: hasContextMenu ? contextMenu : undefined,\n moveNode,\n externalDrop,\n indentSize,\n showIcons,\n draggable,\n dragCursor,\n acceptExternalDrops,\n flat: virtualize,\n }),\n [store, nodes, select, toggle, expandNode, hasContextMenu, contextMenu, moveNode, externalDrop,\n indentSize, showIcons, draggable, dragCursor, acceptExternalDrops, virtualize],\n );\n\n // Unchanged public context, still live for `useTreeNav()` callers. Rows no\n // longer read it, so its changing on a click re-renders only those callers.\n const ctx = useMemo(\n () => ({\n selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons,\n draggable, dragCursor, dragState, setDragState, onNodeMove, acceptExternalDrops, onExternalDrop, nodes, expandNode,\n }),\n [selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons,\n draggable, dragCursor, dragState, onNodeMove, acceptExternalDrops, onExternalDrop, nodes, expandNode],\n );\n\n const rows = useMemo(\n () => (virtualize ? flattenVisible(nodes, expanded) : []),\n [virtualize, nodes, expanded],\n );\n\n const handleDragEnd = useCallback(() => {\n setDragState(EMPTY_DRAG_STATE);\n }, []);\n\n const dropEnabled = draggable || acceptExternalDrops;\n\n return (\n <TreeNavContext.Provider value={ctx}>\n <TreeInternalsContext.Provider value={internals}>\n <nav\n data-react-fancy-tree-nav=\"\"\n data-react-fancy-tree-nav-virtual={virtualize ? \"\" : undefined}\n className={cn(\"flex flex-col gap-0.5 py-1 text-sm\", className)}\n onDragEnd={dropEnabled ? handleDragEnd : undefined}\n >\n {virtualize ? (\n <VirtualList\n items={rows}\n height={height}\n estimateRowHeight={rowHeight}\n renderRow={(row) => <TreeNode node={row.node} depth={row.depth} />}\n />\n ) : (\n nodes.map((node) => <TreeNode key={node.id} node={node} depth={0} />)\n )}\n </nav>\n </TreeInternalsContext.Provider>\n </TreeNavContext.Provider>\n );\n}\n\nTreeNavRoot.displayName = \"TreeNav\";\n\nexport const TreeNav = Object.assign(TreeNavRoot, {\n Node: TreeNode,\n});\n"]}
|