@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.cjs +23 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -5317,12 +5317,18 @@ function useDropdown() {
|
|
|
5317
5317
|
}
|
|
5318
5318
|
function DropdownTrigger({ children }) {
|
|
5319
5319
|
const { setOpen, open, anchorRef } = useDropdown();
|
|
5320
|
-
return
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5320
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5321
|
+
"span",
|
|
5322
|
+
{
|
|
5323
|
+
ref: anchorRef,
|
|
5324
|
+
"data-react-fancy-dropdown-trigger": "",
|
|
5325
|
+
className: "inline-flex",
|
|
5326
|
+
onClick: () => setOpen(!open),
|
|
5327
|
+
"aria-expanded": open,
|
|
5328
|
+
"aria-haspopup": "menu",
|
|
5329
|
+
children
|
|
5330
|
+
}
|
|
5331
|
+
);
|
|
5326
5332
|
}
|
|
5327
5333
|
DropdownTrigger.displayName = "DropdownTrigger";
|
|
5328
5334
|
function useAnimation({
|
|
@@ -10559,7 +10565,7 @@ function ChevronIcon({ open }) {
|
|
|
10559
10565
|
);
|
|
10560
10566
|
}
|
|
10561
10567
|
function TreeNode({ node, depth }) {
|
|
10562
|
-
const { selectedId, onSelect, expandedIds, toggle, indentSize, showIcons } = useTreeNav();
|
|
10568
|
+
const { selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons } = useTreeNav();
|
|
10563
10569
|
const isFolder = node.type === "folder" || node.children && node.children.length > 0;
|
|
10564
10570
|
const isExpanded = expandedIds.includes(node.id);
|
|
10565
10571
|
const isSelected = selectedId === node.id;
|
|
@@ -10571,12 +10577,19 @@ function TreeNode({ node, depth }) {
|
|
|
10571
10577
|
}
|
|
10572
10578
|
onSelect?.(node.id, node);
|
|
10573
10579
|
};
|
|
10580
|
+
const handleContextMenu = (e) => {
|
|
10581
|
+
if (onNodeContextMenu) {
|
|
10582
|
+
e.preventDefault();
|
|
10583
|
+
onNodeContextMenu(e, node);
|
|
10584
|
+
}
|
|
10585
|
+
};
|
|
10574
10586
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-react-fancy-tree-node": "", children: [
|
|
10575
10587
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
10576
10588
|
"button",
|
|
10577
10589
|
{
|
|
10578
10590
|
type: "button",
|
|
10579
10591
|
onClick: handleClick,
|
|
10592
|
+
onContextMenu: handleContextMenu,
|
|
10580
10593
|
disabled: node.disabled,
|
|
10581
10594
|
className: cn(
|
|
10582
10595
|
"flex w-full items-center gap-1 rounded-md py-0.5 text-left text-[13px] transition-colors",
|
|
@@ -10610,6 +10623,7 @@ function TreeNavRoot({
|
|
|
10610
10623
|
nodes,
|
|
10611
10624
|
selectedId,
|
|
10612
10625
|
onSelect,
|
|
10626
|
+
onNodeContextMenu,
|
|
10613
10627
|
expandedIds: controlledExpanded,
|
|
10614
10628
|
defaultExpandedIds,
|
|
10615
10629
|
onExpandedChange,
|
|
@@ -10636,8 +10650,8 @@ function TreeNavRoot({
|
|
|
10636
10650
|
[expandedIds, isControlled, onExpandedChange]
|
|
10637
10651
|
);
|
|
10638
10652
|
const ctx = react.useMemo(
|
|
10639
|
-
() => ({ selectedId, onSelect, expandedIds, toggle, indentSize, showIcons }),
|
|
10640
|
-
[selectedId, onSelect, expandedIds, toggle, indentSize, showIcons]
|
|
10653
|
+
() => ({ selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons }),
|
|
10654
|
+
[selectedId, onSelect, onNodeContextMenu, expandedIds, toggle, indentSize, showIcons]
|
|
10641
10655
|
);
|
|
10642
10656
|
return /* @__PURE__ */ jsxRuntime.jsx(TreeNavContext.Provider, { value: ctx, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
10643
10657
|
"nav",
|