@dxos/plugin-navtree 0.8.4-main.3f58842 → 0.8.4-main.4a85c3132b
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/lib/browser/CommandsDialogContent-A27AKTHH.mjs +111 -0
- package/dist/lib/browser/CommandsDialogContent-A27AKTHH.mjs.map +7 -0
- package/dist/lib/browser/CommandsTrigger-HBZYQCGV.mjs +33 -0
- package/dist/lib/browser/CommandsTrigger-HBZYQCGV.mjs.map +7 -0
- package/dist/lib/browser/NavTreeContainer-B5K4FUJS.mjs +12 -0
- package/dist/lib/browser/NavTreeContainer-B5K4FUJS.mjs.map +7 -0
- package/dist/lib/browser/NavTreeDocumentTitle-GEE3URWH.mjs +26 -0
- package/dist/lib/browser/NavTreeDocumentTitle-GEE3URWH.mjs.map +7 -0
- package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs +44 -0
- package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs.map +7 -0
- package/dist/lib/browser/chunk-DQCYMXEU.mjs +1426 -0
- package/dist/lib/browser/chunk-DQCYMXEU.mjs.map +7 -0
- package/dist/lib/browser/chunk-H3OJ4WLF.mjs +14 -0
- package/dist/lib/browser/chunk-H3OJ4WLF.mjs.map +7 -0
- package/dist/lib/browser/chunk-X2HDG62A.mjs +23 -0
- package/dist/lib/browser/chunk-X2HDG62A.mjs.map +7 -0
- package/dist/lib/browser/chunk-YKTYPINZ.mjs +19 -0
- package/dist/lib/browser/chunk-YKTYPINZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +88 -96
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{keyboard-QRS6WOQH.mjs → keyboard-OJZC54PK.mjs} +22 -19
- package/dist/lib/browser/keyboard-OJZC54PK.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-BNAMYOHF.mjs +53 -0
- package/dist/lib/browser/operation-resolver-BNAMYOHF.mjs.map +7 -0
- package/dist/lib/browser/react-surface-AYHOAJ4I.mjs +59 -0
- package/dist/lib/browser/react-surface-AYHOAJ4I.mjs.map +7 -0
- package/dist/lib/browser/state-AC3EETN7.mjs +131 -0
- package/dist/lib/browser/state-AC3EETN7.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +2 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -105
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard/index.d.ts +3 -0
- package/dist/types/src/capabilities/keyboard/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/keyboard/keyboard.d.ts +5 -0
- package/dist/types/src/capabilities/keyboard/keyboard.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +3 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +6 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts +12 -5
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +27 -5
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +6 -6
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +33 -4
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +2 -2
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +10 -5
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +4 -8
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +13 -0
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +8 -5
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +0 -3
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +8 -16
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts +6 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts +3 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts +3 -0
- package/dist/types/src/containers/CommandsTrigger/index.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts +9 -0
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts +3 -0
- package/dist/types/src/containers/NavTreeContainer/index.d.ts.map +1 -0
- package/dist/types/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.d.ts +1 -1
- package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts +3 -0
- package/dist/types/src/containers/NavTreeDocumentTitle/index.d.ts.map +1 -0
- package/dist/types/src/containers/index.d.ts +7 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/experimental/Tree.d.ts +1 -2
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +23 -6
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/hooks/index.d.ts +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useActions.d.ts +7 -0
- package/dist/types/src/hooks/useActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts +6 -0
- package/dist/types/src/hooks/useLoadDescendents.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts +7 -0
- package/dist/types/src/hooks/useNavTreeModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts +22 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +3 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +5 -6
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts +2 -2
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +16 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/schema.d.ts} +10 -9
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +12 -9
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -53
- package/src/NavTreePlugin.tsx +64 -84
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +42 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/keyboard/index.ts +7 -0
- package/src/capabilities/keyboard/keyboard.ts +66 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +44 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +53 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +149 -0
- package/src/components/NavTree/NavTree.stories.tsx +105 -98
- package/src/components/NavTree/NavTree.tsx +69 -34
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +21 -13
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +39 -33
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +66 -36
- package/src/components/Sidebar/L0Menu.tsx +170 -179
- package/src/components/Sidebar/L1Panel.tsx +248 -134
- package/src/components/Sidebar/L1Tabs.tsx +43 -0
- package/src/components/Sidebar/index.ts +1 -0
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -9
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
- package/src/components/index.ts +1 -3
- package/src/components/types.ts +15 -19
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +133 -0
- package/src/containers/CommandsDialogContent/index.ts +7 -0
- package/src/containers/CommandsTrigger/CommandsTrigger.tsx +26 -0
- package/src/containers/CommandsTrigger/index.ts +7 -0
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +270 -0
- package/src/containers/NavTreeContainer/index.ts +7 -0
- package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +5 -4
- package/src/containers/NavTreeDocumentTitle/index.ts +7 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +78 -83
- package/src/experimental/Tree.tsx +6 -23
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActions.ts +38 -0
- package/src/hooks/useLoadDescendents.ts +23 -0
- package/src/hooks/useNavTreeModel.ts +112 -0
- package/src/hooks/useNavTreeState.ts +42 -0
- package/src/index.ts +1 -2
- package/src/meta.ts +11 -8
- package/src/testing/app-graph-builder.ts +159 -234
- package/src/testing/generator.ts +20 -18
- package/src/testing/update-state.ts +6 -6
- package/src/translations.ts +1 -0
- package/src/types/capabilities.ts +21 -0
- package/src/types/events.ts +12 -0
- package/src/types/index.ts +7 -0
- package/src/{types.ts → types/schema.ts} +9 -8
- package/src/util.ts +26 -33
- package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs +0 -45
- package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
- package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
- package/dist/lib/browser/chunk-SICQTLXC.mjs +0 -1442
- package/dist/lib/browser/chunk-SICQTLXC.mjs.map +0 -7
- package/dist/lib/browser/chunk-WCARAZ7J.mjs +0 -15
- package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs +0 -47
- package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs.map +0 -7
- package/dist/lib/browser/keyboard-QRS6WOQH.mjs.map +0 -7
- package/dist/lib/browser/react-surface-WURHCBQQ.mjs +0 -51
- package/dist/lib/browser/react-surface-WURHCBQQ.mjs.map +0 -7
- package/dist/lib/browser/state-54DY3DOY.mjs +0 -117
- package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -21
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/keyboard.d.ts +0 -4
- package/dist/types/src/capabilities/keyboard.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/state.d.ts +0 -20
- package/dist/types/src/capabilities/state.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +0 -5
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/CommandsDialog/index.d.ts +0 -3
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeContainer.d.ts +0 -9
- package/dist/types/src/components/NavTreeContainer.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/hooks.d.ts +0 -3
- package/dist/types/src/hooks.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -52
- package/src/capabilities/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -37
- package/src/capabilities/keyboard.ts +0 -59
- package/src/capabilities/react-surface.tsx +0 -45
- package/src/capabilities/state.ts +0 -104
- package/src/components/CommandsDialog/CommandsDialog.tsx +0 -118
- package/src/components/CommandsDialog/CommandsTrigger.tsx +0 -35
- package/src/components/CommandsDialog/index.ts +0 -6
- package/src/components/NavTreeContainer.tsx +0 -313
- package/src/events.ts +0 -11
- package/src/hooks.ts +0 -21
- /package/dist/types/src/{components/CommandsDialog → containers/CommandsTrigger}/CommandsTrigger.d.ts +0 -0
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
|
+
import { useActionRunner } from '@dxos/plugin-graph';
|
|
9
|
+
import { IconButton, toLocalizedString, useDensityContext, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { Menu, type MenuItem } from '@dxos/react-ui-menu';
|
|
11
|
+
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/ui-theme';
|
|
11
12
|
|
|
12
|
-
import {
|
|
13
|
+
import { meta } from '../../meta';
|
|
13
14
|
import { type ActionProperties } from '../../types';
|
|
14
15
|
|
|
15
16
|
export type NavTreeItemActionMenuProps = ActionProperties & {
|
|
16
|
-
parent: Node;
|
|
17
|
+
parent: Node.Node;
|
|
17
18
|
caller?: string;
|
|
18
19
|
monolithic?: boolean;
|
|
19
|
-
menuActions?: Action[];
|
|
20
|
+
menuActions?: Node.Action[];
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const fallbackIcon = 'ph--placeholder--regular';
|
|
@@ -38,34 +39,38 @@ export const NavTreeItemActionDropdownMenu = ({
|
|
|
38
39
|
menuActions,
|
|
39
40
|
caller,
|
|
40
41
|
}: NavTreeItemActionMenuProps) => {
|
|
41
|
-
const { t } = useTranslation(
|
|
42
|
+
const { t } = useTranslation(meta.id);
|
|
42
43
|
const density = useDensityContext();
|
|
44
|
+
const runAction = useActionRunner();
|
|
45
|
+
|
|
43
46
|
return (
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
</MenuProvider>
|
|
47
|
+
<Menu.Root caller={caller} onAction={runAction}>
|
|
48
|
+
<Menu.Trigger asChild>
|
|
49
|
+
<IconButton
|
|
50
|
+
{...(density === 'coarse' ? coarseActionButtonProps : fineActionButtonProps)}
|
|
51
|
+
classNames={['shrink-0 px-2 pointer-fine:px-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
52
|
+
variant='ghost'
|
|
53
|
+
icon={icon ?? fallbackIcon}
|
|
54
|
+
iconOnly
|
|
55
|
+
label={toLocalizedString(label, t)}
|
|
56
|
+
data-testid={testId}
|
|
57
|
+
/>
|
|
58
|
+
</Menu.Trigger>
|
|
59
|
+
<Menu.Content group={parent} items={menuActions as MenuItem[]} />
|
|
60
|
+
</Menu.Root>
|
|
59
61
|
);
|
|
60
62
|
};
|
|
61
63
|
|
|
62
|
-
export const NavTreeItemMonolithicAction = (
|
|
63
|
-
parent,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
export const NavTreeItemMonolithicAction = (
|
|
65
|
+
props: Node.Action & { parent: Node.Node; onAction?: (action: Node.Action) => void; baseLabel: string },
|
|
66
|
+
) => {
|
|
67
|
+
const {
|
|
68
|
+
parent,
|
|
69
|
+
properties: { disabled, caller, testId, icon, variant = 'ghost', iconOnly = true } = { label: 'never' },
|
|
70
|
+
baseLabel,
|
|
71
|
+
} = props;
|
|
68
72
|
const density = useDensityContext();
|
|
73
|
+
const runAction = useActionRunner();
|
|
69
74
|
return (
|
|
70
75
|
<IconButton
|
|
71
76
|
{...(density === 'coarse' ? coarseActionButtonProps : fineActionButtonProps)}
|
|
@@ -74,18 +79,19 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
74
79
|
'shrink-0',
|
|
75
80
|
hoverableControlItem,
|
|
76
81
|
hoverableOpenControlItem,
|
|
77
|
-
iconOnly ? '
|
|
82
|
+
iconOnly ? 'px-2 pointer-fine:px-1' : 'p-2 pointer-fine:p-2 me-1',
|
|
78
83
|
]}
|
|
79
84
|
icon={icon ?? fallbackIcon}
|
|
80
85
|
iconOnly={iconOnly}
|
|
81
86
|
label={baseLabel}
|
|
82
87
|
disabled={disabled}
|
|
83
88
|
onClick={(event) => {
|
|
89
|
+
event.stopPropagation();
|
|
84
90
|
if (disabled) {
|
|
85
91
|
return;
|
|
86
92
|
}
|
|
87
|
-
|
|
88
|
-
void
|
|
93
|
+
|
|
94
|
+
void runAction(props, caller ? { parent, caller } : { parent });
|
|
89
95
|
}}
|
|
90
96
|
data-testid={testId}
|
|
91
97
|
/>
|
|
@@ -93,7 +99,7 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
93
99
|
};
|
|
94
100
|
|
|
95
101
|
export const NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }: NavTreeItemActionMenuProps) => {
|
|
96
|
-
const { t } = useTranslation(
|
|
102
|
+
const { t } = useTranslation(meta.id);
|
|
97
103
|
|
|
98
104
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
99
105
|
const baseLabel = toLocalizedString(monolithicAction ? monolithicAction.properties!.label : props.label, t);
|
|
@@ -2,57 +2,83 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { Fragment, memo } from 'react';
|
|
5
|
+
import React, { Fragment, memo, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { Node } from '@dxos/app-graph';
|
|
8
|
+
import { Popover, Treegrid, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { NAVTREE_PLUGIN } from '../../meta';
|
|
10
|
+
import { useActions } from '../../hooks';
|
|
11
|
+
import { meta } from '../../meta';
|
|
13
12
|
import { NAV_TREE_ITEM } from '../NavTree';
|
|
14
13
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
15
|
-
import type
|
|
14
|
+
import { type NavTreeItemColumnsProps } from '../types';
|
|
15
|
+
|
|
16
|
+
import { NavTreeItemAction } from './NavTreeItemAction';
|
|
16
17
|
|
|
17
|
-
export const NavTreeItemColumns = memo(({ path, item, open
|
|
18
|
-
const { t } = useTranslation(
|
|
19
|
-
const {
|
|
18
|
+
export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumnsProps) => {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
|
+
const { renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
20
21
|
|
|
21
22
|
const level = path.length - 2;
|
|
23
|
+
const { actions: actionsProp, groupedActions } = useActions(item);
|
|
24
|
+
const sortedActions = useMemo(
|
|
25
|
+
() =>
|
|
26
|
+
actionsProp.toSorted((actionA, actionB) => {
|
|
27
|
+
const primaryA = actionA.properties?.disposition === 'list-item-primary';
|
|
28
|
+
const primaryB = actionB.properties?.disposition === 'list-item-primary';
|
|
29
|
+
if (primaryA && !primaryB) {
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
32
|
+
if (primaryB && !primaryA) {
|
|
33
|
+
return 1;
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}),
|
|
37
|
+
[actionsProp],
|
|
38
|
+
);
|
|
39
|
+
const [primaryAction, ...secondaryActions] = sortedActions;
|
|
22
40
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
41
|
+
const actions = useMemo(
|
|
42
|
+
() =>
|
|
43
|
+
(primaryAction?.properties?.disposition === 'list-item-primary' ? secondaryActions : sortedActions)
|
|
44
|
+
.flatMap((action) => (Node.isAction(action) ? [action] : []))
|
|
45
|
+
.filter((a) => ['list-item', 'list-item-primary'].includes(a.properties?.disposition)),
|
|
46
|
+
[sortedActions, primaryAction],
|
|
26
47
|
);
|
|
27
48
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
const primaryMenuActions = useMemo(
|
|
50
|
+
() =>
|
|
51
|
+
primaryAction
|
|
52
|
+
? Node.isAction(primaryAction)
|
|
53
|
+
? [primaryAction]
|
|
54
|
+
: groupedActions[primaryAction?.id ?? '']
|
|
55
|
+
: undefined,
|
|
56
|
+
[primaryAction, groupedActions],
|
|
57
|
+
);
|
|
31
58
|
|
|
32
59
|
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
33
60
|
|
|
34
|
-
useLoadDescendents(item);
|
|
35
|
-
useLoadDescendents(primaryAction && !isAction(primaryAction) ? primaryAction : undefined);
|
|
36
|
-
|
|
37
61
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
<div role='none' className='contents dx-app-no-drag'>
|
|
63
|
+
{primaryAction?.properties?.disposition === 'list-item-primary' && !primaryAction?.properties?.disabled ? (
|
|
64
|
+
<Treegrid.Cell classNames='contents'>
|
|
41
65
|
<NavTreeItemAction
|
|
42
66
|
testId={primaryAction.properties?.testId}
|
|
43
67
|
label={toLocalizedString(primaryAction.properties?.label, t)}
|
|
44
68
|
icon={primaryAction.properties?.icon ?? 'ph--placeholder--regular'}
|
|
45
69
|
parent={item}
|
|
46
|
-
monolithic={isAction(primaryAction)}
|
|
47
|
-
menuActions={
|
|
70
|
+
monolithic={Node.isAction(primaryAction)}
|
|
71
|
+
menuActions={primaryMenuActions}
|
|
48
72
|
menuType={primaryAction.properties?.menuType}
|
|
49
73
|
caller={NAV_TREE_ITEM}
|
|
50
74
|
/>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
75
|
+
</Treegrid.Cell>
|
|
76
|
+
) : (
|
|
77
|
+
<Treegrid.Cell role='none' />
|
|
78
|
+
)}
|
|
79
|
+
<ActionRoot>
|
|
80
|
+
{actions.length > 0 ? (
|
|
81
|
+
<Treegrid.Cell classNames='contents'>
|
|
56
82
|
<NavTreeItemAction
|
|
57
83
|
testId={`navtree.treeItem.actionsLevel${level}`}
|
|
58
84
|
label={t('tree item actions label')}
|
|
@@ -62,12 +88,16 @@ export const NavTreeItemColumns = memo(({ path, item, open, density = 'fine' }:
|
|
|
62
88
|
menuType='dropdown'
|
|
63
89
|
caller={NAV_TREE_ITEM}
|
|
64
90
|
/>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
91
|
+
</Treegrid.Cell>
|
|
92
|
+
) : (
|
|
93
|
+
<Treegrid.Cell role='none' />
|
|
94
|
+
)}
|
|
95
|
+
</ActionRoot>
|
|
96
|
+
{ItemEnd && (
|
|
97
|
+
<Treegrid.Cell classNames='contents'>
|
|
98
|
+
<ItemEnd node={item} open={open} />
|
|
99
|
+
</Treegrid.Cell>
|
|
100
|
+
)}
|
|
101
|
+
</div>
|
|
72
102
|
);
|
|
73
103
|
});
|