@djangocfg/ui-tools 2.1.416 → 2.1.417
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/audio-player/index.cjs +2099 -0
- package/dist/audio-player/index.cjs.map +1 -0
- package/dist/audio-player/index.css +65 -0
- package/dist/audio-player/index.css.map +1 -0
- package/dist/audio-player/index.d.cts +174 -0
- package/dist/audio-player/index.d.ts +174 -0
- package/dist/audio-player/index.mjs +2076 -0
- package/dist/audio-player/index.mjs.map +1 -0
- package/dist/composer-registry/index.cjs +45 -0
- package/dist/composer-registry/index.cjs.map +1 -0
- package/dist/composer-registry/index.d.cts +73 -0
- package/dist/composer-registry/index.d.ts +73 -0
- package/dist/composer-registry/index.mjs +39 -0
- package/dist/composer-registry/index.mjs.map +1 -0
- package/dist/tree/index.cjs +85 -63
- package/dist/tree/index.cjs.map +1 -1
- package/dist/tree/index.d.cts +15 -1
- package/dist/tree/index.d.ts +15 -1
- package/dist/tree/index.mjs +86 -64
- package/dist/tree/index.mjs.map +1 -1
- package/package.json +14 -9
- package/src/tools/chat/composer/Composer.tsx +8 -8
- package/src/tools/chat/context/ChatProvider.tsx +13 -78
- package/src/tools/chat/hooks/useAutoFocusOnStreamEnd.ts +12 -15
- package/src/tools/chat/hooks/useFocusOnEmptyClick.ts +4 -5
- package/src/tools/chat/launcher/header/ChatHeader.tsx +14 -19
- package/src/tools/chat/launcher/header/ChatHeaderActionButton.tsx +8 -12
- package/src/tools/data/Tree/TreeRoot.tsx +33 -109
- package/src/tools/data/Tree/components/TreeRow.tsx +11 -0
- package/src/tools/data/Tree/context/TreeContext.tsx +22 -3
- package/src/tools/data/Tree/context/menu/index.ts +1 -0
- package/src/tools/data/Tree/context/menu/render.tsx +75 -0
- package/src/tools/data/Tree/context/menu/use-resolved-menu.ts +16 -2
- package/src/tools/data/Tree/index.tsx +1 -0
- package/src/tools/data/Tree/types/index.ts +1 -1
- package/src/tools/data/Tree/types/root-props.ts +16 -0
- package/src/tools/dev/OpenapiViewer/components/DocsLayout/EndpointDoc/Header/MetaActions.tsx +6 -9
- package/src/tools/dev/OpenapiViewer/components/DocsLayout/index.tsx +2 -4
- package/src/tools/input/SpeechRecognition/widgets/VoiceComposerSlot.tsx +11 -12
- package/src/tools/integration/ComposerRegistry/index.ts +105 -0
- package/src/tools/media/AudioPlayer/Player.tsx +2 -0
- package/src/tools/media/AudioPlayer/PlayerShell.tsx +37 -22
- package/src/tools/media/AudioPlayer/lazy.tsx +30 -42
- package/src/tools/media/AudioPlayer/parts/Controls/IconButton.tsx +10 -11
- package/src/tools/media/AudioPlayer/parts/Controls/VolumeControl.tsx +52 -115
- package/src/tools/media/AudioPlayer/types.ts +15 -0
package/dist/tree/index.d.cts
CHANGED
|
@@ -300,9 +300,23 @@ interface TreeRootProps<T> {
|
|
|
300
300
|
* adapter for hotkeys / DnD.
|
|
301
301
|
*/
|
|
302
302
|
defaultMenuItems?: TreeBuiltinAction[];
|
|
303
|
+
/**
|
|
304
|
+
* Imperative handle for outer code. The provided ref receives a
|
|
305
|
+
* stable handle to `useTreeActions` once Tree mounts. Lets host
|
|
306
|
+
* components trigger `refresh(id)` / `refreshAll()` from outside
|
|
307
|
+
* Tree (e.g. after a transport-level mutation completes).
|
|
308
|
+
*/
|
|
309
|
+
actionsRef?: React.MutableRefObject<TreeActionsHandle | null>;
|
|
303
310
|
className?: string;
|
|
304
311
|
style?: CSSProperties;
|
|
305
312
|
}
|
|
313
|
+
/** Subset of `useTreeActions()` exposed via `<TreeRoot actionsRef={…}>`. */
|
|
314
|
+
interface TreeActionsHandle {
|
|
315
|
+
refresh: (id: string) => Promise<void>;
|
|
316
|
+
refreshAll: () => Promise<void>;
|
|
317
|
+
expandAll: () => void;
|
|
318
|
+
collapseAll: () => void;
|
|
319
|
+
}
|
|
306
320
|
|
|
307
321
|
/**
|
|
308
322
|
* High-level entry point. Wraps Provider + (optional) search bar + content.
|
|
@@ -958,4 +972,4 @@ interface TreeEmptyAreaProps {
|
|
|
958
972
|
*/
|
|
959
973
|
declare function TreeEmptyArea({ className }: TreeEmptyAreaProps): react_jsx_runtime.JSX.Element;
|
|
960
974
|
|
|
961
|
-
export { type ChildCache, type ChildEntry, type ChildEntryStatus, DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, type DemoNode, FinderTree, FlatRow, type FlattenInput, type PersistedTreeState, type ResolvedAppearance, TREE_DND_MIME, TreeRoot as Tree, type TreeAccentIntensity, type TreeActivateOptions, type TreeActivationMode, type TreeAdapter, type TreeAppearance, type TreeBuiltinAction, TreeChevron, type TreeChevronProps, TreeContent, type TreeContentProps, TreeContextMenuActionsResolver, TreeContextMenuItem, TreeContextMenuSlot, type TreeContextValue, type TreeDensity, TreeDropIndicator, type TreeDropIndicatorProps, TreeEmpty, TreeEmptyArea, type TreeEmptyAreaProps, type TreeEmptyProps, TreeError, type TreeErrorProps, TreeIcon, type TreeIconProps, TreeIndentGuides, type TreeIndentGuidesProps, TreeItemId, TreeLabel, type TreeLabelProps, type TreeLabels, type TreeLoadChildren, type TreeMovePosition, TreeNode, TreeProvider, type TreeProviderProps, type TreeRadius, TreeRenameInput, type TreeRenameInputProps, TreeRoot, type TreeRootProps, TreeRow, type TreeRowProps, TreeRowRenderProps, TreeRowSlot, TreeSearchInput, type TreeSearchInputProps, type TreeSelectionMode, TreeSkeleton, type TreeSkeletonProps, type UseTreeFinderHotkeysOptions, type UseTreeKeyboardOptions, type UseTreeTypeAheadOptions, appearanceToStyle, autoSelectRange, clearTreeState, createChildCache, createDemoTree, TreeRoot as default, defaultCanDrop, flattenTree, loadTreeState, resolveAppearance, resolveChildren, resolveDropZone, saveTreeState, splitFileName, useTreeActions, useTreeClipboard, useTreeContext, useTreeDnd, useTreeExpansion, useTreeFinderHotkeys, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRename, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead };
|
|
975
|
+
export { type ChildCache, type ChildEntry, type ChildEntryStatus, DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, type DemoNode, FinderTree, FlatRow, type FlattenInput, type PersistedTreeState, type ResolvedAppearance, TREE_DND_MIME, TreeRoot as Tree, type TreeAccentIntensity, type TreeActionsHandle, type TreeActivateOptions, type TreeActivationMode, type TreeAdapter, type TreeAppearance, type TreeBuiltinAction, TreeChevron, type TreeChevronProps, TreeContent, type TreeContentProps, TreeContextMenuActionsResolver, TreeContextMenuItem, TreeContextMenuSlot, type TreeContextValue, type TreeDensity, TreeDropIndicator, type TreeDropIndicatorProps, TreeEmpty, TreeEmptyArea, type TreeEmptyAreaProps, type TreeEmptyProps, TreeError, type TreeErrorProps, TreeIcon, type TreeIconProps, TreeIndentGuides, type TreeIndentGuidesProps, TreeItemId, TreeLabel, type TreeLabelProps, type TreeLabels, type TreeLoadChildren, type TreeMovePosition, TreeNode, TreeProvider, type TreeProviderProps, type TreeRadius, TreeRenameInput, type TreeRenameInputProps, TreeRoot, type TreeRootProps, TreeRow, type TreeRowProps, TreeRowRenderProps, TreeRowSlot, TreeSearchInput, type TreeSearchInputProps, type TreeSelectionMode, TreeSkeleton, type TreeSkeletonProps, type UseTreeFinderHotkeysOptions, type UseTreeKeyboardOptions, type UseTreeTypeAheadOptions, appearanceToStyle, autoSelectRange, clearTreeState, createChildCache, createDemoTree, TreeRoot as default, defaultCanDrop, flattenTree, loadTreeState, resolveAppearance, resolveChildren, resolveDropZone, saveTreeState, splitFileName, useTreeActions, useTreeClipboard, useTreeContext, useTreeDnd, useTreeExpansion, useTreeFinderHotkeys, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRename, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead };
|
package/dist/tree/index.d.ts
CHANGED
|
@@ -300,9 +300,23 @@ interface TreeRootProps<T> {
|
|
|
300
300
|
* adapter for hotkeys / DnD.
|
|
301
301
|
*/
|
|
302
302
|
defaultMenuItems?: TreeBuiltinAction[];
|
|
303
|
+
/**
|
|
304
|
+
* Imperative handle for outer code. The provided ref receives a
|
|
305
|
+
* stable handle to `useTreeActions` once Tree mounts. Lets host
|
|
306
|
+
* components trigger `refresh(id)` / `refreshAll()` from outside
|
|
307
|
+
* Tree (e.g. after a transport-level mutation completes).
|
|
308
|
+
*/
|
|
309
|
+
actionsRef?: React.MutableRefObject<TreeActionsHandle | null>;
|
|
303
310
|
className?: string;
|
|
304
311
|
style?: CSSProperties;
|
|
305
312
|
}
|
|
313
|
+
/** Subset of `useTreeActions()` exposed via `<TreeRoot actionsRef={…}>`. */
|
|
314
|
+
interface TreeActionsHandle {
|
|
315
|
+
refresh: (id: string) => Promise<void>;
|
|
316
|
+
refreshAll: () => Promise<void>;
|
|
317
|
+
expandAll: () => void;
|
|
318
|
+
collapseAll: () => void;
|
|
319
|
+
}
|
|
306
320
|
|
|
307
321
|
/**
|
|
308
322
|
* High-level entry point. Wraps Provider + (optional) search bar + content.
|
|
@@ -958,4 +972,4 @@ interface TreeEmptyAreaProps {
|
|
|
958
972
|
*/
|
|
959
973
|
declare function TreeEmptyArea({ className }: TreeEmptyAreaProps): react_jsx_runtime.JSX.Element;
|
|
960
974
|
|
|
961
|
-
export { type ChildCache, type ChildEntry, type ChildEntryStatus, DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, type DemoNode, FinderTree, FlatRow, type FlattenInput, type PersistedTreeState, type ResolvedAppearance, TREE_DND_MIME, TreeRoot as Tree, type TreeAccentIntensity, type TreeActivateOptions, type TreeActivationMode, type TreeAdapter, type TreeAppearance, type TreeBuiltinAction, TreeChevron, type TreeChevronProps, TreeContent, type TreeContentProps, TreeContextMenuActionsResolver, TreeContextMenuItem, TreeContextMenuSlot, type TreeContextValue, type TreeDensity, TreeDropIndicator, type TreeDropIndicatorProps, TreeEmpty, TreeEmptyArea, type TreeEmptyAreaProps, type TreeEmptyProps, TreeError, type TreeErrorProps, TreeIcon, type TreeIconProps, TreeIndentGuides, type TreeIndentGuidesProps, TreeItemId, TreeLabel, type TreeLabelProps, type TreeLabels, type TreeLoadChildren, type TreeMovePosition, TreeNode, TreeProvider, type TreeProviderProps, type TreeRadius, TreeRenameInput, type TreeRenameInputProps, TreeRoot, type TreeRootProps, TreeRow, type TreeRowProps, TreeRowRenderProps, TreeRowSlot, TreeSearchInput, type TreeSearchInputProps, type TreeSelectionMode, TreeSkeleton, type TreeSkeletonProps, type UseTreeFinderHotkeysOptions, type UseTreeKeyboardOptions, type UseTreeTypeAheadOptions, appearanceToStyle, autoSelectRange, clearTreeState, createChildCache, createDemoTree, TreeRoot as default, defaultCanDrop, flattenTree, loadTreeState, resolveAppearance, resolveChildren, resolveDropZone, saveTreeState, splitFileName, useTreeActions, useTreeClipboard, useTreeContext, useTreeDnd, useTreeExpansion, useTreeFinderHotkeys, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRename, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead };
|
|
975
|
+
export { type ChildCache, type ChildEntry, type ChildEntryStatus, DEFAULT_TREE_APPEARANCE, DEFAULT_TREE_LABELS, type DemoNode, FinderTree, FlatRow, type FlattenInput, type PersistedTreeState, type ResolvedAppearance, TREE_DND_MIME, TreeRoot as Tree, type TreeAccentIntensity, type TreeActionsHandle, type TreeActivateOptions, type TreeActivationMode, type TreeAdapter, type TreeAppearance, type TreeBuiltinAction, TreeChevron, type TreeChevronProps, TreeContent, type TreeContentProps, TreeContextMenuActionsResolver, TreeContextMenuItem, TreeContextMenuSlot, type TreeContextValue, type TreeDensity, TreeDropIndicator, type TreeDropIndicatorProps, TreeEmpty, TreeEmptyArea, type TreeEmptyAreaProps, type TreeEmptyProps, TreeError, type TreeErrorProps, TreeIcon, type TreeIconProps, TreeIndentGuides, type TreeIndentGuidesProps, TreeItemId, TreeLabel, type TreeLabelProps, type TreeLabels, type TreeLoadChildren, type TreeMovePosition, TreeNode, TreeProvider, type TreeProviderProps, type TreeRadius, TreeRenameInput, type TreeRenameInputProps, TreeRoot, type TreeRootProps, TreeRow, type TreeRowProps, TreeRowRenderProps, TreeRowSlot, TreeSearchInput, type TreeSearchInputProps, type TreeSelectionMode, TreeSkeleton, type TreeSkeletonProps, type UseTreeFinderHotkeysOptions, type UseTreeKeyboardOptions, type UseTreeTypeAheadOptions, appearanceToStyle, autoSelectRange, clearTreeState, createChildCache, createDemoTree, TreeRoot as default, defaultCanDrop, flattenTree, loadTreeState, resolveAppearance, resolveChildren, resolveDropZone, saveTreeState, splitFileName, useTreeActions, useTreeClipboard, useTreeContext, useTreeDnd, useTreeExpansion, useTreeFinderHotkeys, useTreeFocus, useTreeKeyboard, useTreeLabels, useTreeRename, useTreeRows, useTreeSearch, useTreeSelection, useTreeTypeAhead };
|
package/dist/tree/index.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import { __name } from '../chunk-PAWJFY3S.mjs';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { createContext, memo, useRef, useCallback, useMemo, useEffect, useState, useReducer, Fragment as Fragment$1 } from 'react';
|
|
4
4
|
import { cn } from '@djangocfg/ui-core/lib';
|
|
5
|
-
import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuSeparator, ContextMenuItem, ContextMenuShortcut } from '@djangocfg/ui-core/components';
|
|
6
5
|
import { getDialog } from '@djangocfg/ui-core/lib/dialog-service';
|
|
7
6
|
import { CornerUpLeft, Pencil, Copy, Scissors, Trash2, FilePlus, FolderPlus, ChevronDown, ChevronRight, FolderOpen, Folder, File, Loader2, Search, X, AlertCircle } from 'lucide-react';
|
|
8
|
-
import {
|
|
7
|
+
import { ContextMenu, ContextMenuTrigger, ContextMenuContent, ContextMenuSeparator, ContextMenuItem, ContextMenuShortcut } from '@djangocfg/ui-core/components';
|
|
8
|
+
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
9
9
|
import { useSensors, useSensor, PointerSensor, KeyboardSensor, DndContext, useDraggable, useDroppable } from '@dnd-kit/core';
|
|
10
10
|
import { useHotkey } from '@djangocfg/ui-core/hooks';
|
|
11
11
|
|
|
@@ -1048,6 +1048,47 @@ function useResolvedMenu(opts) {
|
|
|
1048
1048
|
]);
|
|
1049
1049
|
}
|
|
1050
1050
|
__name(useResolvedMenu, "useResolvedMenu");
|
|
1051
|
+
function renderItemsAsContextMenu(rowProps, items, trigger) {
|
|
1052
|
+
return /* @__PURE__ */ jsxs(ContextMenu, { children: [
|
|
1053
|
+
/* @__PURE__ */ jsx(ContextMenuTrigger, { asChild: true, children: trigger }),
|
|
1054
|
+
/* @__PURE__ */ jsx(ContextMenuContent, { children: items.map((item, idx) => {
|
|
1055
|
+
if (item === "separator") {
|
|
1056
|
+
return /* @__PURE__ */ jsx(ContextMenuSeparator, {}, `sep-${idx}`);
|
|
1057
|
+
}
|
|
1058
|
+
const Icon = item.icon;
|
|
1059
|
+
return /* @__PURE__ */ jsxs(
|
|
1060
|
+
ContextMenuItem,
|
|
1061
|
+
{
|
|
1062
|
+
disabled: item.disabled,
|
|
1063
|
+
variant: item.destructive ? "destructive" : void 0,
|
|
1064
|
+
onSelect: () => item.onSelect(rowProps),
|
|
1065
|
+
children: [
|
|
1066
|
+
Icon ? /* @__PURE__ */ jsx(Icon, {}) : null,
|
|
1067
|
+
item.label,
|
|
1068
|
+
item.shortcut ? /* @__PURE__ */ jsx(ContextMenuShortcut, { children: item.shortcut }) : null
|
|
1069
|
+
]
|
|
1070
|
+
},
|
|
1071
|
+
item.id
|
|
1072
|
+
);
|
|
1073
|
+
}) })
|
|
1074
|
+
] });
|
|
1075
|
+
}
|
|
1076
|
+
__name(renderItemsAsContextMenu, "renderItemsAsContextMenu");
|
|
1077
|
+
function tidyMenuItems(items) {
|
|
1078
|
+
const out = [];
|
|
1079
|
+
for (const it of items) {
|
|
1080
|
+
if (it === "separator") {
|
|
1081
|
+
if (out.length === 0) continue;
|
|
1082
|
+
if (out[out.length - 1] === "separator") continue;
|
|
1083
|
+
out.push(it);
|
|
1084
|
+
} else {
|
|
1085
|
+
out.push(it);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
while (out.length > 0 && out[out.length - 1] === "separator") out.pop();
|
|
1089
|
+
return out;
|
|
1090
|
+
}
|
|
1091
|
+
__name(tidyMenuItems, "tidyMenuItems");
|
|
1051
1092
|
|
|
1052
1093
|
// src/tools/data/Tree/data/dnd.ts
|
|
1053
1094
|
function resolveDropZone(input) {
|
|
@@ -1412,6 +1453,20 @@ function TreeProvider(props) {
|
|
|
1412
1453
|
copyToClipboard: clipboard.copyToClipboard,
|
|
1413
1454
|
pasteFromClipboard: clipboard.pasteFromClipboard
|
|
1414
1455
|
});
|
|
1456
|
+
const finalRenderContextMenu = useMemo(
|
|
1457
|
+
() => {
|
|
1458
|
+
if (renderContextMenu) return renderContextMenu;
|
|
1459
|
+
const resolve = resolvedContextMenuActions;
|
|
1460
|
+
if (!resolve) return void 0;
|
|
1461
|
+
return (rowProps, trigger) => {
|
|
1462
|
+
const items = resolve(rowProps);
|
|
1463
|
+
const cleaned = items ? tidyMenuItems(items) : null;
|
|
1464
|
+
if (!cleaned || cleaned.length === 0) return trigger;
|
|
1465
|
+
return renderItemsAsContextMenu(rowProps, cleaned, trigger);
|
|
1466
|
+
};
|
|
1467
|
+
},
|
|
1468
|
+
[renderContextMenu, resolvedContextMenuActions]
|
|
1469
|
+
);
|
|
1415
1470
|
const value = useMemo(
|
|
1416
1471
|
() => ({
|
|
1417
1472
|
// state
|
|
@@ -1453,7 +1508,7 @@ function TreeProvider(props) {
|
|
|
1453
1508
|
renderIcon,
|
|
1454
1509
|
renderLabel,
|
|
1455
1510
|
renderActions,
|
|
1456
|
-
renderContextMenu,
|
|
1511
|
+
renderContextMenu: finalRenderContextMenu,
|
|
1457
1512
|
adapter,
|
|
1458
1513
|
resolvedContextMenuActions,
|
|
1459
1514
|
getNodeById: /* @__PURE__ */ __name((id) => nodeById.get(id), "getNodeById"),
|
|
@@ -1490,7 +1545,7 @@ function TreeProvider(props) {
|
|
|
1490
1545
|
renderIcon,
|
|
1491
1546
|
renderLabel,
|
|
1492
1547
|
renderActions,
|
|
1493
|
-
|
|
1548
|
+
finalRenderContextMenu,
|
|
1494
1549
|
adapter,
|
|
1495
1550
|
resolvedContextMenuActions,
|
|
1496
1551
|
nodeById,
|
|
@@ -1917,6 +1972,9 @@ function TreeRowRaw({ row, className }) {
|
|
|
1917
1972
|
},
|
|
1918
1973
|
...dnd.active ? draggable.listeners : {},
|
|
1919
1974
|
...dnd.active ? draggable.attributes : {},
|
|
1975
|
+
onMouseDown: (e) => {
|
|
1976
|
+
if (e.button === 0) e.preventDefault();
|
|
1977
|
+
},
|
|
1920
1978
|
onClick: handleClick,
|
|
1921
1979
|
onDoubleClick: handleDoubleClick,
|
|
1922
1980
|
onContextMenu: handleContextMenu,
|
|
@@ -2766,47 +2824,6 @@ function useTreeFinderHotkeys(opts) {
|
|
|
2766
2824
|
return { ref };
|
|
2767
2825
|
}
|
|
2768
2826
|
__name(useTreeFinderHotkeys, "useTreeFinderHotkeys");
|
|
2769
|
-
function renderItemsAsContextMenu(rowProps, items, trigger) {
|
|
2770
|
-
return /* @__PURE__ */ jsxs(ContextMenu, { children: [
|
|
2771
|
-
/* @__PURE__ */ jsx(ContextMenuTrigger, { asChild: true, children: trigger }),
|
|
2772
|
-
/* @__PURE__ */ jsx(ContextMenuContent, { children: items.map((item, idx) => {
|
|
2773
|
-
if (item === "separator") {
|
|
2774
|
-
return /* @__PURE__ */ jsx(ContextMenuSeparator, {}, `sep-${idx}`);
|
|
2775
|
-
}
|
|
2776
|
-
const Icon = item.icon;
|
|
2777
|
-
return /* @__PURE__ */ jsxs(
|
|
2778
|
-
ContextMenuItem,
|
|
2779
|
-
{
|
|
2780
|
-
disabled: item.disabled,
|
|
2781
|
-
variant: item.destructive ? "destructive" : void 0,
|
|
2782
|
-
onSelect: () => item.onSelect(rowProps),
|
|
2783
|
-
children: [
|
|
2784
|
-
Icon ? /* @__PURE__ */ jsx(Icon, {}) : null,
|
|
2785
|
-
item.label,
|
|
2786
|
-
item.shortcut ? /* @__PURE__ */ jsx(ContextMenuShortcut, { children: item.shortcut }) : null
|
|
2787
|
-
]
|
|
2788
|
-
},
|
|
2789
|
-
item.id
|
|
2790
|
-
);
|
|
2791
|
-
}) })
|
|
2792
|
-
] });
|
|
2793
|
-
}
|
|
2794
|
-
__name(renderItemsAsContextMenu, "renderItemsAsContextMenu");
|
|
2795
|
-
function tidyMenuItems(items) {
|
|
2796
|
-
const out = [];
|
|
2797
|
-
for (const it of items) {
|
|
2798
|
-
if (it === "separator") {
|
|
2799
|
-
if (out.length === 0) continue;
|
|
2800
|
-
if (out[out.length - 1] === "separator") continue;
|
|
2801
|
-
out.push(it);
|
|
2802
|
-
} else {
|
|
2803
|
-
out.push(it);
|
|
2804
|
-
}
|
|
2805
|
-
}
|
|
2806
|
-
while (out.length > 0 && out[out.length - 1] === "separator") out.pop();
|
|
2807
|
-
return out;
|
|
2808
|
-
}
|
|
2809
|
-
__name(tidyMenuItems, "tidyMenuItems");
|
|
2810
2827
|
function TreeRoot(props) {
|
|
2811
2828
|
const {
|
|
2812
2829
|
data,
|
|
@@ -2840,6 +2857,7 @@ function TreeRoot(props) {
|
|
|
2840
2857
|
persistSelection = false,
|
|
2841
2858
|
adapter,
|
|
2842
2859
|
defaultMenuItems,
|
|
2860
|
+
actionsRef,
|
|
2843
2861
|
className,
|
|
2844
2862
|
style
|
|
2845
2863
|
} = props;
|
|
@@ -2882,7 +2900,8 @@ function TreeRoot(props) {
|
|
|
2882
2900
|
enableSearch,
|
|
2883
2901
|
enableTypeAhead,
|
|
2884
2902
|
enableFinderHotkeys,
|
|
2885
|
-
renderRow
|
|
2903
|
+
renderRow,
|
|
2904
|
+
actionsRef
|
|
2886
2905
|
}
|
|
2887
2906
|
)
|
|
2888
2907
|
}
|
|
@@ -2895,10 +2914,29 @@ function TreeRootShell({
|
|
|
2895
2914
|
enableSearch,
|
|
2896
2915
|
enableTypeAhead,
|
|
2897
2916
|
enableFinderHotkeys,
|
|
2898
|
-
renderRow
|
|
2917
|
+
renderRow,
|
|
2918
|
+
actionsRef
|
|
2899
2919
|
}) {
|
|
2900
2920
|
const containerRef = useRef(null);
|
|
2901
2921
|
const ctx = useTreeContext();
|
|
2922
|
+
useEffect(() => {
|
|
2923
|
+
if (!actionsRef) return;
|
|
2924
|
+
actionsRef.current = {
|
|
2925
|
+
refresh: ctx.refresh,
|
|
2926
|
+
refreshAll: ctx.refreshAll,
|
|
2927
|
+
expandAll: ctx.expandAll,
|
|
2928
|
+
collapseAll: ctx.collapseAll
|
|
2929
|
+
};
|
|
2930
|
+
return () => {
|
|
2931
|
+
if (actionsRef.current) actionsRef.current = null;
|
|
2932
|
+
};
|
|
2933
|
+
}, [
|
|
2934
|
+
actionsRef,
|
|
2935
|
+
ctx.refresh,
|
|
2936
|
+
ctx.refreshAll,
|
|
2937
|
+
ctx.expandAll,
|
|
2938
|
+
ctx.collapseAll
|
|
2939
|
+
]);
|
|
2902
2940
|
const isMulti = ctx.selectionMode === "multiple";
|
|
2903
2941
|
const { ref: keyboardRef } = useTreeKeyboard({
|
|
2904
2942
|
rows: ctx.flatRows,
|
|
@@ -2975,21 +3013,6 @@ function TreeRootShell({
|
|
|
2975
3013
|
onMatch: onTypeAheadMatch,
|
|
2976
3014
|
enabled: enableTypeAhead
|
|
2977
3015
|
});
|
|
2978
|
-
const finalRenderContextMenu = useMemo(() => {
|
|
2979
|
-
if (ctx.renderContextMenu) return ctx.renderContextMenu;
|
|
2980
|
-
const resolve = ctx.resolvedContextMenuActions;
|
|
2981
|
-
if (!resolve) return void 0;
|
|
2982
|
-
return (rowProps, trigger) => {
|
|
2983
|
-
const items = resolve(rowProps);
|
|
2984
|
-
const cleaned = items ? tidyMenuItems(items) : null;
|
|
2985
|
-
if (!cleaned || cleaned.length === 0) return trigger;
|
|
2986
|
-
return renderItemsAsContextMenu(rowProps, cleaned, trigger);
|
|
2987
|
-
};
|
|
2988
|
-
}, [ctx.renderContextMenu, ctx.resolvedContextMenuActions]);
|
|
2989
|
-
const childCtx = useMemo(
|
|
2990
|
-
() => ({ ...ctx, renderContextMenu: finalRenderContextMenu }),
|
|
2991
|
-
[ctx, finalRenderContextMenu]
|
|
2992
|
-
);
|
|
2993
3016
|
const treeBody = /* @__PURE__ */ jsxs(
|
|
2994
3017
|
"div",
|
|
2995
3018
|
{
|
|
@@ -3015,8 +3038,7 @@ function TreeRootShell({
|
|
|
3015
3038
|
]
|
|
3016
3039
|
}
|
|
3017
3040
|
);
|
|
3018
|
-
|
|
3019
|
-
return /* @__PURE__ */ jsx(TreeDndProvider, { children: body });
|
|
3041
|
+
return /* @__PURE__ */ jsx(TreeDndProvider, { children: treeBody });
|
|
3020
3042
|
}
|
|
3021
3043
|
__name(TreeRootShell, "TreeRootShell");
|
|
3022
3044
|
var TreeRoot_default = TreeRoot;
|