@principal-ade/dynamic-file-tree 0.2.32 → 0.2.33

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/dist/index.mjs CHANGED
@@ -1088,6 +1088,39 @@ import {
1088
1088
  } from "lucide-react";
1089
1089
  import React7, { useMemo as useMemo5, useRef as useRef4 } from "react";
1090
1090
  import { Tree as Tree2 } from "react-arborist";
1091
+
1092
+ // src/hooks/useNativeDragInterceptor.ts
1093
+ import { useLayoutEffect } from "react";
1094
+ var useNativeDragInterceptor = (containerRef) => {
1095
+ useLayoutEffect(() => {
1096
+ const container = containerRef.current;
1097
+ if (!container)
1098
+ return;
1099
+ const handler = (e) => {
1100
+ const target = e.target;
1101
+ const nativeDragElement = target.closest('[data-native-drag="true"]');
1102
+ if (nativeDragElement) {
1103
+ e.stopImmediatePropagation();
1104
+ const dragEvent = e;
1105
+ if (dragEvent.dataTransfer) {
1106
+ const dragData = nativeDragElement.getAttribute("data-drag-data");
1107
+ const dragText = nativeDragElement.getAttribute("data-drag-text");
1108
+ if (dragData) {
1109
+ dragEvent.dataTransfer.setData("application/x-panel-data", dragData);
1110
+ }
1111
+ if (dragText) {
1112
+ dragEvent.dataTransfer.setData("text/plain", dragText);
1113
+ }
1114
+ dragEvent.dataTransfer.effectAllowed = "copyMove";
1115
+ }
1116
+ }
1117
+ };
1118
+ container.addEventListener("dragstart", handler, true);
1119
+ return () => container.removeEventListener("dragstart", handler, true);
1120
+ }, [containerRef]);
1121
+ };
1122
+
1123
+ // src/components/GitStatusFileTree.tsx
1091
1124
  var GitStatusContext = React7.createContext(null);
1092
1125
  var getGitStatusDisplay2 = (status, theme) => {
1093
1126
  switch (status) {
@@ -1238,10 +1271,20 @@ var GitStatusFileTree = ({
1238
1271
  openByDefault,
1239
1272
  initialHeight = 600,
1240
1273
  autoHeight = false,
1241
- enableDragAndDrop = false
1274
+ enableDragAndDrop = false,
1275
+ enablePanelDrag = false,
1276
+ getDragConfig
1242
1277
  }) => {
1243
1278
  const dndProps = getDndProps(enableDragAndDrop);
1244
1279
  const parentDndManager = useParentDndManager();
1280
+ const getDefaultDragConfig = (nodePath, isFolder) => ({
1281
+ dataType: isFolder ? "directory-path" : "file-path",
1282
+ primaryData: nodePath,
1283
+ metadata: { isFolder },
1284
+ suggestedActions: ["insert-path", "open"],
1285
+ sourcePanel: "git-status-file-tree",
1286
+ dragPreview: nodePath.split("/").pop() || nodePath
1287
+ });
1245
1288
  const gitStatusMap = useMemo5(() => {
1246
1289
  const map = new Map;
1247
1290
  gitStatusData.forEach((item) => {
@@ -1271,6 +1314,8 @@ var GitStatusFileTree = ({
1271
1314
  const baseColor = theme.colors.primary || "#007bff";
1272
1315
  nameColor = baseColor + "80";
1273
1316
  }
1317
+ const isFolder = !!node.data.children;
1318
+ const dragConfig = enablePanelDrag ? getDragConfig ? getDragConfig(node.data.id, isFolder) : getDefaultDragConfig(node.data.id, isFolder) : undefined;
1274
1319
  const rightContent = gitDisplay ? /* @__PURE__ */ React7.createElement("div", {
1275
1320
  style: {
1276
1321
  display: "flex",
@@ -1302,7 +1347,8 @@ var GitStatusFileTree = ({
1302
1347
  if (onNodeHover) {
1303
1348
  onNodeHover(isHovered ? node2.data.id : null, !!node2.data.children);
1304
1349
  }
1305
- }
1350
+ },
1351
+ dragConfig
1306
1352
  });
1307
1353
  };
1308
1354
  const treeStructure = useMemo5(() => {
@@ -1362,6 +1408,7 @@ var GitStatusFileTree = ({
1362
1408
  return initialHeight;
1363
1409
  }, [autoHeight, treeData, openByDefault, initialHeight, rowHeight]);
1364
1410
  const [containerRef, containerHeight, isContainerReady] = useContainerHeight(calculatedHeight);
1411
+ useNativeDragInterceptor(containerRef);
1365
1412
  return /* @__PURE__ */ React7.createElement("div", {
1366
1413
  ref: containerRef,
1367
1414
  style: {
@@ -1975,37 +2022,6 @@ import { Package, FolderKanban, LayoutDashboard, Workflow, BookOpen, FolderOpen,
1975
2022
  import React13, { useMemo as useMemo9, useRef as useRef5 } from "react";
1976
2023
  import { Tree as Tree3 } from "react-arborist";
1977
2024
 
1978
- // src/hooks/useNativeDragInterceptor.ts
1979
- import { useLayoutEffect } from "react";
1980
- var useNativeDragInterceptor = (containerRef) => {
1981
- useLayoutEffect(() => {
1982
- const container = containerRef.current;
1983
- if (!container)
1984
- return;
1985
- const handler = (e) => {
1986
- const target = e.target;
1987
- const nativeDragElement = target.closest('[data-native-drag="true"]');
1988
- if (nativeDragElement) {
1989
- e.stopImmediatePropagation();
1990
- const dragEvent = e;
1991
- if (dragEvent.dataTransfer) {
1992
- const dragData = nativeDragElement.getAttribute("data-drag-data");
1993
- const dragText = nativeDragElement.getAttribute("data-drag-text");
1994
- if (dragData) {
1995
- dragEvent.dataTransfer.setData("application/x-panel-data", dragData);
1996
- }
1997
- if (dragText) {
1998
- dragEvent.dataTransfer.setData("text/plain", dragText);
1999
- }
2000
- dragEvent.dataTransfer.effectAllowed = "copyMove";
2001
- }
2002
- }
2003
- };
2004
- container.addEventListener("dragstart", handler, true);
2005
- return () => container.removeEventListener("dragstart", handler, true);
2006
- }, [containerRef]);
2007
- };
2008
-
2009
2025
  // src/utils/gitStatus.tsx
2010
2026
  import {
2011
2027
  Plus as Plus3,
@@ -1,6 +1,7 @@
1
1
  import type { Theme } from '@principal-ade/industry-theme';
2
2
  import { FileTree } from '@principal-ai/repository-abstraction';
3
3
  import React from 'react';
4
+ import { DragConfig } from './TreeNode';
4
5
  export type GitStatus = 'M' | 'A' | 'D' | 'R' | 'C' | 'U' | '??' | '!!' | 'AM' | 'MM' | null;
5
6
  export interface GitFileStatus {
6
7
  filePath: string;
@@ -27,6 +28,8 @@ export interface GitStatusFileTreeProps {
27
28
  initialHeight?: number;
28
29
  autoHeight?: boolean;
29
30
  enableDragAndDrop?: boolean;
31
+ enablePanelDrag?: boolean;
32
+ getDragConfig?: (nodePath: string, isFolder: boolean) => DragConfig | undefined;
30
33
  }
31
34
  export declare const GitStatusFileTree: React.FC<GitStatusFileTreeProps>;
32
35
  //# sourceMappingURL=GitStatusFileTree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"GitStatusFileTree.d.ts","sourceRoot":"","sources":["../../../src/components/GitStatusFileTree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAgB,MAAM,sCAAsC,CAAC;AAS9E,OAAO,KAA0B,MAAM,OAAO,CAAC;AAS/C,MAAM,MAAM,SAAS,GACjB,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,CAAC;AAGT,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,SAAS,CAAC;CACnB;AAmBD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,aAAa,EAAE,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpD,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,MA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AAW,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACpD,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACvF,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IACnE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,KAAK,UAAU,GAAG,SAAS,CAAC;CACjF;AA0JD,eAAO,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CAoQ9D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principal-ade/dynamic-file-tree",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "description": "React component for selective directory filtering and file tree visualization",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",