@particle-academy/react-fancy 1.8.1 → 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
@@ -757,7 +757,7 @@ interface DropdownSeparatorProps {
757
757
  className?: string;
758
758
  }
759
759
 
760
- declare function DropdownTrigger({ children }: DropdownTriggerProps): ReactElement<Record<string, unknown>, string | react.JSXElementConstructor<any>>;
760
+ declare function DropdownTrigger({ children }: DropdownTriggerProps): react_jsx_runtime.JSX.Element;
761
761
  declare namespace DropdownTrigger {
762
762
  var displayName: string;
763
763
  }
@@ -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
@@ -757,7 +757,7 @@ interface DropdownSeparatorProps {
757
757
  className?: string;
758
758
  }
759
759
 
760
- declare function DropdownTrigger({ children }: DropdownTriggerProps): ReactElement<Record<string, unknown>, string | react.JSXElementConstructor<any>>;
760
+ declare function DropdownTrigger({ children }: DropdownTriggerProps): react_jsx_runtime.JSX.Element;
761
761
  declare namespace DropdownTrigger {
762
762
  var displayName: string;
763
763
  }
@@ -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
@@ -5007,12 +5007,18 @@ function useDropdown() {
5007
5007
  }
5008
5008
  function DropdownTrigger({ children }) {
5009
5009
  const { setOpen, open, anchorRef } = useDropdown();
5010
- return cloneElement(children, {
5011
- ref: anchorRef,
5012
- onClick: () => setOpen(!open),
5013
- "aria-expanded": open,
5014
- "aria-haspopup": "menu"
5015
- });
5010
+ return /* @__PURE__ */ jsx(
5011
+ "span",
5012
+ {
5013
+ ref: anchorRef,
5014
+ "data-react-fancy-dropdown-trigger": "",
5015
+ className: "inline-flex",
5016
+ onClick: () => setOpen(!open),
5017
+ "aria-expanded": open,
5018
+ "aria-haspopup": "menu",
5019
+ children
5020
+ }
5021
+ );
5016
5022
  }
5017
5023
  DropdownTrigger.displayName = "DropdownTrigger";
5018
5024
  function useAnimation({
@@ -10249,7 +10255,7 @@ function ChevronIcon({ open }) {
10249
10255
  );
10250
10256
  }
10251
10257
  function TreeNode({ node, depth }) {
10252
- const { selectedId, onSelect, expandedIds, toggle, indentSize, showIcons } = useTreeNav();
10258
+ const { selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons } = useTreeNav();
10253
10259
  const isFolder = node.type === "folder" || node.children && node.children.length > 0;
10254
10260
  const isExpanded = expandedIds.includes(node.id);
10255
10261
  const isSelected = selectedId === node.id;
@@ -10261,12 +10267,19 @@ function TreeNode({ node, depth }) {
10261
10267
  }
10262
10268
  onSelect?.(node.id, node);
10263
10269
  };
10270
+ const handleContextMenu = (e) => {
10271
+ if (onNodeContextMenu) {
10272
+ e.preventDefault();
10273
+ onNodeContextMenu(e, node);
10274
+ }
10275
+ };
10264
10276
  return /* @__PURE__ */ jsxs("div", { "data-react-fancy-tree-node": "", children: [
10265
10277
  /* @__PURE__ */ jsxs(
10266
10278
  "button",
10267
10279
  {
10268
10280
  type: "button",
10269
10281
  onClick: handleClick,
10282
+ onContextMenu: handleContextMenu,
10270
10283
  disabled: node.disabled,
10271
10284
  className: cn(
10272
10285
  "flex w-full items-center gap-1 rounded-md py-0.5 text-left text-[13px] transition-colors",
@@ -10300,6 +10313,7 @@ function TreeNavRoot({
10300
10313
  nodes,
10301
10314
  selectedId,
10302
10315
  onSelect,
10316
+ onNodeContextMenu,
10303
10317
  expandedIds: controlledExpanded,
10304
10318
  defaultExpandedIds,
10305
10319
  onExpandedChange,
@@ -10326,8 +10340,8 @@ function TreeNavRoot({
10326
10340
  [expandedIds, isControlled, onExpandedChange]
10327
10341
  );
10328
10342
  const ctx = useMemo(
10329
- () => ({ selectedId, onSelect, expandedIds, toggle, indentSize, showIcons }),
10330
- [selectedId, onSelect, expandedIds, toggle, indentSize, showIcons]
10343
+ () => ({ selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons }),
10344
+ [selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons]
10331
10345
  );
10332
10346
  return /* @__PURE__ */ jsx(TreeNavContext.Provider, { value: ctx, children: /* @__PURE__ */ jsx(
10333
10347
  "nav",