@dxos/plugin-navtree 0.8.4-main.ead640a → 0.8.4-main.effb148878
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/LICENSE +102 -5
- package/README.md +1 -1
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs +112 -0
- package/dist/lib/neutral/CommandsDialogContent-UBGIQ5FI.mjs.map +7 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs +27 -0
- package/dist/lib/neutral/CommandsTrigger-BH5WLMHK.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs +12 -0
- package/dist/lib/neutral/NavTreeContainer-6AR4BFDD.mjs.map +7 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs +22 -0
- package/dist/lib/neutral/NavTreeDocumentTitle-H3E6ZLYE.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.mjs +56 -0
- package/dist/lib/neutral/NavTreePlugin.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs +18 -0
- package/dist/lib/neutral/NavTreePlugin.node.mjs.map +7 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs +16 -0
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs.map +7 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs +42 -0
- package/dist/lib/neutral/app-graph-builder-Z347LKSF.mjs.map +7 -0
- package/dist/lib/neutral/capabilities/index.mjs +17 -0
- package/dist/lib/neutral/capabilities/index.mjs.map +7 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs +273 -0
- package/dist/lib/neutral/chunk-5OPDKH6B.mjs.map +7 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +10 -0
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +7 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs +79 -0
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs.map +7 -0
- package/dist/lib/neutral/chunk-RWLAJYUL.mjs +35 -0
- package/dist/lib/neutral/chunk-RWLAJYUL.mjs.map +7 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs +8 -0
- package/dist/lib/neutral/chunk-T7QS2EFI.mjs.map +7 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs +27 -0
- package/dist/lib/neutral/chunk-ZSWYB7JW.mjs.map +7 -0
- package/dist/lib/neutral/components/index.mjs +879 -0
- package/dist/lib/neutral/components/index.mjs.map +7 -0
- package/dist/lib/neutral/containers/index.mjs +20 -0
- package/dist/lib/neutral/containers/index.mjs.map +7 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs +38 -0
- package/dist/lib/neutral/expose-26FV4W5D.mjs.map +7 -0
- package/dist/lib/neutral/hooks/index.mjs +169 -0
- package/dist/lib/neutral/hooks/index.mjs.map +7 -0
- package/dist/lib/neutral/index.mjs +34 -0
- package/dist/lib/neutral/index.mjs.map +7 -0
- package/dist/lib/{browser/keyboard-AHSAWKXA.mjs → neutral/keyboard-EJ65BVTC.mjs} +25 -20
- package/dist/lib/neutral/keyboard-EJ65BVTC.mjs.map +7 -0
- package/dist/lib/neutral/meta.json +1 -0
- package/dist/lib/neutral/meta.mjs +12 -0
- package/dist/lib/neutral/meta.mjs.map +7 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs +13 -0
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs.map +7 -0
- package/dist/lib/neutral/operations/index.mjs +8 -0
- package/dist/lib/neutral/operations/index.mjs.map +7 -0
- package/dist/lib/neutral/plugin.mjs +16 -0
- package/dist/lib/neutral/plugin.mjs.map +7 -0
- package/dist/lib/neutral/react-surface-EWCZMKVX.mjs +50 -0
- package/dist/lib/neutral/react-surface-EWCZMKVX.mjs.map +7 -0
- package/dist/lib/neutral/state-VVITVXWM.mjs +127 -0
- package/dist/lib/neutral/state-VVITVXWM.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +433 -0
- package/dist/lib/neutral/testing/index.mjs.map +7 -0
- package/dist/lib/neutral/translations.mjs +23 -0
- package/dist/lib/neutral/translations.mjs.map +7 -0
- package/dist/lib/neutral/types/index.mjs +10 -0
- package/dist/lib/neutral/types/index.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +3 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/NavTreePlugin.node.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.node.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.test.d.ts +2 -0
- package/dist/types/src/NavTreePlugin.test.d.ts.map +1 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts +4 -0
- package/dist/types/src/NavTreePlugin.workerd.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +4 -2
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +7 -108
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +3 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +3 -2
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +4 -18
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts +11 -4
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +10 -12
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeContext.d.ts → NavTreeContext/NavTreeContext.d.ts} +1 -1
- package/dist/types/src/components/NavTreeContext/NavTreeContext.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts +2 -0
- package/dist/types/src/components/NavTreeContext/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +13 -9
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +3 -2
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +8 -5
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +4 -7
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +5 -4
- package/dist/types/src/components/Sidebar/L1Tabs.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.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 -17
- 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/CommandsDialogContent.stories.d.ts +28 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts.map +1 -0
- package/dist/types/src/containers/CommandsDialogContent/index.d.ts +2 -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 +2 -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 +2 -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 +2 -2
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +18 -4
- 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 +5 -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 +18 -0
- package/dist/types/src/hooks/useNavTreeState.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +1 -3
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/operations/expose.d.ts +5 -0
- package/dist/types/src/operations/expose.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/plugin.d.ts +4 -0
- package/dist/types/src/plugin.d.ts.map +1 -0
- 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 +8 -11
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/NavTreeCapabilities.d.ts +13 -0
- package/dist/types/src/types/NavTreeCapabilities.d.ts.map +1 -0
- package/dist/types/src/types/NavTreeEvents.d.ts +3 -0
- package/dist/types/src/types/NavTreeEvents.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} +7 -7
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +12 -8
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +126 -59
- package/src/NavTreePlugin.node.ts +17 -0
- package/src/NavTreePlugin.test.ts +27 -0
- package/src/NavTreePlugin.tsx +41 -77
- package/src/NavTreePlugin.workerd.ts +16 -0
- package/src/capabilities/app-graph-builder.ts +34 -45
- package/src/capabilities/index.ts +10 -8
- package/src/capabilities/keyboard.ts +58 -51
- package/src/capabilities/operation-handler.ts +16 -0
- package/src/capabilities/react-surface.tsx +46 -38
- package/src/capabilities/state.ts +132 -84
- package/src/components/NavTree/NavTree.stories.tsx +51 -57
- package/src/components/NavTree/NavTree.tsx +65 -33
- package/src/components/{NavTreeContext.tsx → NavTreeContext/NavTreeContext.tsx} +1 -1
- package/src/components/NavTreeContext/index.ts +5 -0
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +23 -15
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +75 -52
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +46 -20
- package/src/components/Sidebar/L0Menu.tsx +155 -184
- package/src/components/Sidebar/L1Panel.tsx +203 -102
- package/src/components/Sidebar/L1Tabs.tsx +18 -34
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +2 -3
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +1 -1
- package/src/components/index.ts +1 -3
- package/src/components/types.ts +13 -19
- package/src/containers/CommandsDialogContent/CommandsDialogContent.stories.tsx +46 -0
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +127 -0
- package/src/containers/CommandsDialogContent/index.ts +5 -0
- package/src/containers/CommandsTrigger/CommandsTrigger.tsx +28 -0
- package/src/containers/CommandsTrigger/index.ts +5 -0
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +271 -0
- package/src/containers/NavTreeContainer/index.ts +6 -0
- package/src/{components → containers/NavTreeDocumentTitle}/NavTreeDocumentTitle.tsx +4 -3
- package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +82 -85
- package/src/experimental/Tree.tsx +4 -4
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActions.ts +34 -0
- package/src/hooks/useLoadDescendents.ts +23 -0
- package/src/hooks/useNavTreeModel.ts +118 -0
- package/src/hooks/useNavTreeState.ts +35 -0
- package/src/index.ts +1 -3
- package/src/meta.ts +23 -4
- package/src/operations/expose.ts +42 -0
- package/src/operations/index.ts +7 -0
- package/src/plugin.ts +11 -0
- package/src/testing/app-graph-builder.ts +167 -239
- package/src/testing/generator.ts +35 -38
- package/src/testing/update-state.ts +6 -6
- package/src/translations.ts +8 -10
- package/src/types/NavTreeCapabilities.ts +21 -0
- package/src/types/NavTreeEvents.ts +12 -0
- package/src/types/index.ts +8 -0
- package/src/{types.ts → types/schema.ts} +6 -6
- package/src/util.ts +28 -17
- package/dist/lib/browser/app-graph-builder-YAPMENYT.mjs +0 -46
- package/dist/lib/browser/app-graph-builder-YAPMENYT.mjs.map +0 -7
- package/dist/lib/browser/chunk-IMFXKPSB.mjs +0 -1482
- package/dist/lib/browser/chunk-IMFXKPSB.mjs.map +0 -7
- package/dist/lib/browser/chunk-LPAREX6J.mjs +0 -15
- package/dist/lib/browser/chunk-LPAREX6J.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZENLR72O.mjs +0 -14
- package/dist/lib/browser/chunk-ZENLR72O.mjs.map +0 -7
- package/dist/lib/browser/index.mjs +0 -146
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-TCQXGF6U.mjs +0 -47
- package/dist/lib/browser/intent-resolver-TCQXGF6U.mjs.map +0 -7
- package/dist/lib/browser/keyboard-AHSAWKXA.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-AH2TP73M.mjs +0 -51
- package/dist/lib/browser/react-surface-AH2TP73M.mjs.map +0 -7
- package/dist/lib/browser/state-2Q623V7U.mjs +0 -117
- package/dist/lib/browser/state-2Q623V7U.mjs.map +0 -7
- 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/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/NavTreeContext.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/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -37
- 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 -346
- 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
|
@@ -6,7 +6,7 @@ import { createContext, useContext } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { raise } from '@dxos/debug';
|
|
8
8
|
|
|
9
|
-
import { type NavTreeContextValue } from '
|
|
9
|
+
import { type NavTreeContextValue } from '../types';
|
|
10
10
|
|
|
11
11
|
export const NavTreeContext = createContext<NavTreeContextValue | null>(null);
|
|
12
12
|
|
|
@@ -3,42 +3,46 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { ProcessManagerPlugin } from '@dxos/app-framework';
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { type Node } from '@dxos/app-graph';
|
|
11
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
12
|
+
import { random } from '@dxos/random';
|
|
10
13
|
|
|
11
14
|
import { NavTreeItemAction, type NavTreeItemActionMenuProps } from './NavTreeItemAction';
|
|
12
15
|
|
|
13
16
|
const parent = {
|
|
14
|
-
id:
|
|
17
|
+
id: random.string.uuid(),
|
|
15
18
|
type: 'node',
|
|
16
19
|
data: null,
|
|
17
20
|
properties: {
|
|
18
|
-
label:
|
|
21
|
+
label: random.lorem.words(2),
|
|
19
22
|
icon: 'ph--circle--regular',
|
|
20
23
|
},
|
|
21
|
-
} satisfies NodeArg<any>;
|
|
24
|
+
} satisfies Node.NodeArg<any>;
|
|
22
25
|
|
|
23
26
|
// TODO(burdon): Factor out across tests.
|
|
24
|
-
const menuActions =
|
|
27
|
+
const menuActions = random.helpers.multiple(
|
|
25
28
|
() =>
|
|
26
29
|
({
|
|
27
|
-
id:
|
|
30
|
+
id: random.string.uuid(),
|
|
28
31
|
type: 'action',
|
|
29
|
-
data: () =>
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
data: () =>
|
|
33
|
+
Effect.sync(() => {
|
|
34
|
+
console.log('invoke');
|
|
35
|
+
}),
|
|
32
36
|
properties: {
|
|
33
|
-
label:
|
|
37
|
+
label: random.lorem.words(2),
|
|
34
38
|
icon: 'ph--circle--regular',
|
|
35
39
|
},
|
|
36
|
-
}) satisfies NodeArg<any>,
|
|
40
|
+
}) satisfies Node.NodeArg<any>,
|
|
37
41
|
{ count: 20 },
|
|
38
42
|
);
|
|
39
43
|
|
|
40
44
|
const meta = {
|
|
41
|
-
title: 'plugins/plugin-navtree/NavTreeItemAction',
|
|
45
|
+
title: 'plugins/plugin-navtree/components/NavTreeItemAction',
|
|
42
46
|
component: NavTreeItemAction,
|
|
43
47
|
args: {
|
|
44
48
|
icon: 'ph--list--regular',
|
|
@@ -46,7 +50,11 @@ const meta = {
|
|
|
46
50
|
menuActions,
|
|
47
51
|
label: 'Select action',
|
|
48
52
|
} satisfies Partial<NavTreeItemActionMenuProps>,
|
|
49
|
-
decorators: [
|
|
53
|
+
decorators: [
|
|
54
|
+
withPluginManager({
|
|
55
|
+
plugins: [...corePlugins(), ProcessManagerPlugin()],
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
50
58
|
parameters: {
|
|
51
59
|
layout: 'centered',
|
|
52
60
|
},
|
|
@@ -2,79 +2,96 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useCallback } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
|
+
import { useActionRunner } from '@dxos/plugin-graph';
|
|
8
9
|
import { IconButton, toLocalizedString, useDensityContext, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { composable, composableProps } from '@dxos/react-ui';
|
|
11
|
+
import { Menu, type MenuItem } from '@dxos/react-ui-menu';
|
|
12
|
+
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/ui-theme';
|
|
11
13
|
|
|
12
|
-
import { meta } from '
|
|
13
|
-
import { type ActionProperties } from '
|
|
14
|
+
import { meta } from '#meta';
|
|
15
|
+
import { type ActionProperties } from '#types';
|
|
14
16
|
|
|
15
|
-
|
|
16
|
-
parent: Node;
|
|
17
|
-
caller?: string;
|
|
18
|
-
monolithic?: boolean;
|
|
19
|
-
menuActions?: Action[];
|
|
20
|
-
};
|
|
17
|
+
const fallbackIcon = 'ph--circle-dashed--regular';
|
|
21
18
|
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const fineActionButtonProps = {
|
|
19
|
+
const mdActionButtonProps = {
|
|
25
20
|
size: 4 as const,
|
|
26
|
-
density: '
|
|
21
|
+
density: 'md' as const,
|
|
27
22
|
};
|
|
28
|
-
|
|
23
|
+
|
|
24
|
+
const lgActionButtonProps = {
|
|
29
25
|
size: 5 as const,
|
|
30
|
-
density: '
|
|
26
|
+
density: 'lg' as const,
|
|
31
27
|
};
|
|
32
28
|
|
|
33
|
-
export
|
|
34
|
-
parent
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
menuActions
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
export type NavTreeItemActionMenuProps = ActionProperties & {
|
|
30
|
+
parent: Node.Node;
|
|
31
|
+
path?: string[];
|
|
32
|
+
caller?: string;
|
|
33
|
+
monolithic?: boolean;
|
|
34
|
+
menuActions?: Node.Action[];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const NavTreeItemActionDropdownMenu = composable<HTMLButtonElement, NavTreeItemActionMenuProps>(
|
|
38
|
+
({ parent, path, label, icon, testId, menuActions, caller, ...props }, forwardedRef) => {
|
|
39
|
+
const { t } = useTranslation(meta.id);
|
|
40
|
+
const density = useDensityContext();
|
|
41
|
+
const runAction = useActionRunner();
|
|
42
|
+
const handleAction = useCallback(
|
|
43
|
+
(action: Node.Action, params: Node.InvokeProps = {}) => runAction(action, { ...params, path }),
|
|
44
|
+
[runAction, path],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<Menu.Root caller={caller} onAction={handleAction}>
|
|
49
|
+
<Menu.Trigger asChild>
|
|
47
50
|
<IconButton
|
|
48
|
-
{...(density === '
|
|
49
|
-
|
|
51
|
+
{...(density === 'lg' ? lgActionButtonProps : mdActionButtonProps)}
|
|
52
|
+
{...composableProps(props)}
|
|
53
|
+
classNames={['shrink-0 px-2 pointer-fine:px-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
50
54
|
variant='ghost'
|
|
51
55
|
icon={icon ?? fallbackIcon}
|
|
52
56
|
iconOnly
|
|
53
57
|
label={toLocalizedString(label, t)}
|
|
54
58
|
data-testid={testId}
|
|
59
|
+
ref={forwardedRef}
|
|
55
60
|
/>
|
|
56
|
-
</
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
+
</Menu.Trigger>
|
|
62
|
+
<Menu.Content group={parent} items={menuActions as MenuItem[]} />
|
|
63
|
+
</Menu.Root>
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
);
|
|
61
67
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
NavTreeItemActionDropdownMenu.displayName = 'NavTreeItemActionDropdownMenu';
|
|
69
|
+
|
|
70
|
+
export const NavTreeItemMonolithicAction = (
|
|
71
|
+
props: Node.Action & {
|
|
72
|
+
parent: Node.Node;
|
|
73
|
+
path?: string[];
|
|
74
|
+
onAction?: (action: Node.Action) => void;
|
|
75
|
+
baseLabel: string;
|
|
76
|
+
},
|
|
77
|
+
) => {
|
|
78
|
+
const {
|
|
79
|
+
parent,
|
|
80
|
+
path,
|
|
81
|
+
properties: { disabled, caller, testId, icon, variant = 'ghost', iconOnly = true } = { label: 'never' },
|
|
82
|
+
baseLabel,
|
|
83
|
+
} = props;
|
|
68
84
|
const density = useDensityContext();
|
|
85
|
+
const runAction = useActionRunner();
|
|
69
86
|
return (
|
|
70
87
|
<IconButton
|
|
71
|
-
{...(density === '
|
|
88
|
+
{...(density === 'lg' ? lgActionButtonProps : mdActionButtonProps)}
|
|
72
89
|
variant={variant}
|
|
73
90
|
classNames={[
|
|
74
91
|
'shrink-0',
|
|
75
92
|
hoverableControlItem,
|
|
76
93
|
hoverableOpenControlItem,
|
|
77
|
-
iconOnly ? '
|
|
94
|
+
iconOnly ? 'px-2 pointer-fine:px-1' : 'p-2 pointer-fine:p-2 me-1',
|
|
78
95
|
]}
|
|
79
96
|
icon={icon ?? fallbackIcon}
|
|
80
97
|
iconOnly={iconOnly}
|
|
@@ -86,22 +103,28 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
86
103
|
return;
|
|
87
104
|
}
|
|
88
105
|
|
|
89
|
-
void
|
|
106
|
+
void runAction(props, caller ? { parent, caller, path } : { parent, path });
|
|
90
107
|
}}
|
|
91
108
|
data-testid={testId}
|
|
92
109
|
/>
|
|
93
110
|
);
|
|
94
111
|
};
|
|
95
112
|
|
|
96
|
-
export const NavTreeItemAction = ({
|
|
113
|
+
export const NavTreeItemAction = ({
|
|
114
|
+
monolithic,
|
|
115
|
+
menuActions,
|
|
116
|
+
menuType,
|
|
117
|
+
parent,
|
|
118
|
+
path,
|
|
119
|
+
...props
|
|
120
|
+
}: NavTreeItemActionMenuProps) => {
|
|
97
121
|
const { t } = useTranslation(meta.id);
|
|
98
122
|
|
|
99
123
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
100
124
|
const baseLabel = toLocalizedString(monolithicAction ? monolithicAction.properties!.label : props.label, t);
|
|
101
|
-
|
|
102
125
|
return monolithic && menuActions?.length === 1 ? (
|
|
103
|
-
<NavTreeItemMonolithicAction baseLabel={baseLabel} parent={
|
|
126
|
+
<NavTreeItemMonolithicAction baseLabel={baseLabel} parent={parent} path={path} {...menuActions[0]} />
|
|
104
127
|
) : (
|
|
105
|
-
<NavTreeItemActionDropdownMenu {...props} label={baseLabel} parent={
|
|
128
|
+
<NavTreeItemActionDropdownMenu {...props} label={baseLabel} parent={parent} path={path} menuActions={menuActions} />
|
|
106
129
|
);
|
|
107
130
|
};
|
|
@@ -2,49 +2,74 @@
|
|
|
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 {
|
|
7
|
+
import { Node } from '@dxos/app-graph';
|
|
8
8
|
import { Popover, Treegrid, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
|
-
import {
|
|
11
|
-
import { meta } from '
|
|
10
|
+
import { useActions } from '#hooks';
|
|
11
|
+
import { meta } from '#meta';
|
|
12
|
+
|
|
12
13
|
import { NAV_TREE_ITEM } from '../NavTree';
|
|
13
14
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
14
15
|
import { type NavTreeItemColumnsProps } from '../types';
|
|
15
|
-
|
|
16
16
|
import { NavTreeItemAction } from './NavTreeItemAction';
|
|
17
17
|
|
|
18
18
|
export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumnsProps) => {
|
|
19
19
|
const { t } = useTranslation(meta.id);
|
|
20
|
-
const {
|
|
20
|
+
const { renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
21
21
|
|
|
22
22
|
const level = path.length - 2;
|
|
23
|
-
const { actions:
|
|
24
|
-
const
|
|
25
|
-
|
|
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],
|
|
26
38
|
);
|
|
39
|
+
const [primaryAction, ...secondaryActions] = sortedActions;
|
|
27
40
|
|
|
28
|
-
const actions = (
|
|
29
|
-
|
|
30
|
-
|
|
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],
|
|
47
|
+
);
|
|
31
48
|
|
|
32
|
-
|
|
33
|
-
|
|
49
|
+
const primaryMenuActions = useMemo(
|
|
50
|
+
() =>
|
|
51
|
+
primaryAction
|
|
52
|
+
? Node.isAction(primaryAction)
|
|
53
|
+
? [primaryAction]
|
|
54
|
+
: groupedActions[primaryAction?.id ?? '']
|
|
55
|
+
: undefined,
|
|
56
|
+
[primaryAction, groupedActions],
|
|
57
|
+
);
|
|
34
58
|
|
|
35
|
-
const ActionRoot = popoverAnchorId ===
|
|
59
|
+
const ActionRoot = popoverAnchorId === `${NAV_TREE_ITEM}:${item.id}` ? Popover.Anchor : Fragment;
|
|
36
60
|
|
|
37
61
|
return (
|
|
38
|
-
<div
|
|
62
|
+
<div className='contents dx-app-no-drag'>
|
|
39
63
|
{primaryAction?.properties?.disposition === 'list-item-primary' && !primaryAction?.properties?.disabled ? (
|
|
40
64
|
<Treegrid.Cell classNames='contents'>
|
|
41
65
|
<NavTreeItemAction
|
|
42
66
|
testId={primaryAction.properties?.testId}
|
|
43
67
|
label={toLocalizedString(primaryAction.properties?.label, t)}
|
|
44
|
-
icon={primaryAction.properties?.icon ?? 'ph--
|
|
68
|
+
icon={primaryAction.properties?.icon ?? 'ph--circle-dashed--regular'}
|
|
45
69
|
parent={item}
|
|
46
|
-
|
|
47
|
-
|
|
70
|
+
path={path}
|
|
71
|
+
monolithic={Node.isAction(primaryAction)}
|
|
72
|
+
menuActions={primaryMenuActions}
|
|
48
73
|
menuType={primaryAction.properties?.menuType}
|
|
49
74
|
caller={NAV_TREE_ITEM}
|
|
50
75
|
/>
|
|
@@ -57,9 +82,10 @@ export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumns
|
|
|
57
82
|
<Treegrid.Cell classNames='contents'>
|
|
58
83
|
<NavTreeItemAction
|
|
59
84
|
testId={`navtree.treeItem.actionsLevel${level}`}
|
|
60
|
-
label={t('tree
|
|
85
|
+
label={t('tree-item-actions.label')}
|
|
61
86
|
icon='ph--dots-three-vertical--regular'
|
|
62
87
|
parent={item}
|
|
88
|
+
path={path}
|
|
63
89
|
menuActions={actions}
|
|
64
90
|
menuType='dropdown'
|
|
65
91
|
caller={NAV_TREE_ITEM}
|