@particle-academy/react-fancy 1.8.2 → 1.9.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/dist/index.d.cts CHANGED
@@ -2083,6 +2083,8 @@ interface TreeNavProps {
2083
2083
  selectedId?: string;
2084
2084
  /** Callback when a node is selected */
2085
2085
  onSelect?: (id: string, node: TreeNodeData) => void;
2086
+ /** Callback when a node is right-clicked */
2087
+ onNodeContextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;
2086
2088
  /** Controlled expanded node IDs */
2087
2089
  expandedIds?: string[];
2088
2090
  /** Default expanded node IDs (uncontrolled) */
@@ -2101,6 +2103,7 @@ interface TreeNavProps {
2101
2103
  interface TreeNavContextValue {
2102
2104
  selectedId?: string;
2103
2105
  onSelect?: (id: string, node: TreeNodeData) => void;
2106
+ onNodeContextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;
2104
2107
  expandedIds: string[];
2105
2108
  toggle: (id: string) => void;
2106
2109
  indentSize: number;
@@ -2117,7 +2120,7 @@ declare namespace TreeNode {
2117
2120
  var displayName: string;
2118
2121
  }
2119
2122
 
2120
- declare function TreeNavRoot({ nodes, selectedId, onSelect, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
2123
+ declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
2121
2124
  declare namespace TreeNavRoot {
2122
2125
  var displayName: string;
2123
2126
  }
package/dist/index.d.ts CHANGED
@@ -2083,6 +2083,8 @@ interface TreeNavProps {
2083
2083
  selectedId?: string;
2084
2084
  /** Callback when a node is selected */
2085
2085
  onSelect?: (id: string, node: TreeNodeData) => void;
2086
+ /** Callback when a node is right-clicked */
2087
+ onNodeContextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;
2086
2088
  /** Controlled expanded node IDs */
2087
2089
  expandedIds?: string[];
2088
2090
  /** Default expanded node IDs (uncontrolled) */
@@ -2101,6 +2103,7 @@ interface TreeNavProps {
2101
2103
  interface TreeNavContextValue {
2102
2104
  selectedId?: string;
2103
2105
  onSelect?: (id: string, node: TreeNodeData) => void;
2106
+ onNodeContextMenu?: (e: React.MouseEvent, node: TreeNodeData) => void;
2104
2107
  expandedIds: string[];
2105
2108
  toggle: (id: string) => void;
2106
2109
  indentSize: number;
@@ -2117,7 +2120,7 @@ declare namespace TreeNode {
2117
2120
  var displayName: string;
2118
2121
  }
2119
2122
 
2120
- declare function TreeNavRoot({ nodes, selectedId, onSelect, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
2123
+ declare function TreeNavRoot({ nodes, selectedId, onSelect, onNodeContextMenu, expandedIds: controlledExpanded, defaultExpandedIds, onExpandedChange, defaultExpandAll, indentSize, showIcons, className, }: TreeNavProps): react_jsx_runtime.JSX.Element;
2121
2124
  declare namespace TreeNavRoot {
2122
2125
  var displayName: string;
2123
2126
  }
package/dist/index.js CHANGED
@@ -10255,7 +10255,7 @@ function ChevronIcon({ open }) {
10255
10255
  );
10256
10256
  }
10257
10257
  function TreeNode({ node, depth }) {
10258
- const { selectedId, onSelect, expandedIds, toggle, indentSize, showIcons } = useTreeNav();
10258
+ const { selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons } = useTreeNav();
10259
10259
  const isFolder = node.type === "folder" || node.children && node.children.length > 0;
10260
10260
  const isExpanded = expandedIds.includes(node.id);
10261
10261
  const isSelected = selectedId === node.id;
@@ -10267,12 +10267,19 @@ function TreeNode({ node, depth }) {
10267
10267
  }
10268
10268
  onSelect?.(node.id, node);
10269
10269
  };
10270
+ const handleContextMenu = (e) => {
10271
+ if (onNodeContextMenu) {
10272
+ e.preventDefault();
10273
+ onNodeContextMenu(e, node);
10274
+ }
10275
+ };
10270
10276
  return /* @__PURE__ */ jsxs("div", { "data-react-fancy-tree-node": "", children: [
10271
10277
  /* @__PURE__ */ jsxs(
10272
10278
  "button",
10273
10279
  {
10274
10280
  type: "button",
10275
10281
  onClick: handleClick,
10282
+ onContextMenu: handleContextMenu,
10276
10283
  disabled: node.disabled,
10277
10284
  className: cn(
10278
10285
  "flex w-full items-center gap-1 rounded-md py-0.5 text-left text-[13px] transition-colors",
@@ -10306,6 +10313,7 @@ function TreeNavRoot({
10306
10313
  nodes,
10307
10314
  selectedId,
10308
10315
  onSelect,
10316
+ onNodeContextMenu,
10309
10317
  expandedIds: controlledExpanded,
10310
10318
  defaultExpandedIds,
10311
10319
  onExpandedChange,
@@ -10332,8 +10340,8 @@ function TreeNavRoot({
10332
10340
  [expandedIds, isControlled, onExpandedChange]
10333
10341
  );
10334
10342
  const ctx = useMemo(
10335
- () => ({ selectedId, onSelect, expandedIds, toggle, indentSize, showIcons }),
10336
- [selectedId, onSelect, expandedIds, toggle, indentSize, showIcons]
10343
+ () => ({ selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons }),
10344
+ [selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons]
10337
10345
  );
10338
10346
  return /* @__PURE__ */ jsx(TreeNavContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
10339
10347
  "nav",