@dxos/plugin-navtree 0.8.4-main.fd6878d → 0.8.4-staging.60fe92afc8
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/PLUGIN.mdl +376 -0
- 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 +68 -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-MDGKDQMZ.mjs +37 -0
- package/dist/lib/neutral/chunk-MDGKDQMZ.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 +805 -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 +178 -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-HMTMA33N.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-Q5XMAG7Z.mjs +50 -0
- package/dist/lib/neutral/react-surface-Q5XMAG7Z.mjs.map +7 -0
- package/dist/lib/neutral/state-VVJEWUHM.mjs +126 -0
- package/dist/lib/neutral/state-VVJEWUHM.mjs.map +7 -0
- package/dist/lib/neutral/testing/index.mjs +439 -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 -105
- 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 +25 -5
- 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 +33 -4
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +1 -1
- 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 -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 +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 -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 +3 -4
- 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 +11 -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 +4 -4
- 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} +14 -9
- 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 +124 -62
- package/src/NavTreePlugin.node.ts +17 -0
- package/src/NavTreePlugin.test.ts +27 -0
- package/src/NavTreePlugin.tsx +56 -87
- package/src/NavTreePlugin.workerd.ts +16 -0
- package/src/capabilities/app-graph-builder.ts +34 -44
- 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 +112 -106
- package/src/components/NavTree/NavTree.tsx +69 -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 +25 -19
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +78 -54
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +40 -51
- package/src/components/Sidebar/L0Menu.tsx +182 -210
- package/src/components/Sidebar/L1Panel.tsx +185 -110
- package/src/components/Sidebar/L1Tabs.tsx +18 -34
- 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 +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 +5 -4
- package/src/containers/NavTreeDocumentTitle/index.ts +5 -0
- package/src/containers/index.ts +12 -0
- package/src/experimental/Tree.stories.tsx +105 -110
- package/src/experimental/Tree.tsx +7 -24
- package/src/hooks/index.ts +8 -0
- package/src/hooks/useActions.ts +44 -0
- package/src/hooks/useLoadDescendents.ts +23 -0
- package/src/hooks/useNavTreeModel.ts +120 -0
- package/src/hooks/useNavTreeState.ts +35 -0
- package/src/index.ts +1 -3
- package/src/meta.ts +26 -8
- 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 +169 -238
- package/src/testing/generator.ts +36 -39
- 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} +13 -8
- package/src/util.ts +28 -17
- package/src/vite-env.d.ts +10 -0
- package/dist/lib/browser/app-graph-builder-6JDBQ25U.mjs +0 -45
- package/dist/lib/browser/app-graph-builder-6JDBQ25U.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-SNGLGBFJ.mjs +0 -1469
- package/dist/lib/browser/chunk-SNGLGBFJ.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/index.mjs +0 -148
- package/dist/lib/browser/index.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-N35ZIHFD.mjs +0 -47
- package/dist/lib/browser/intent-resolver-N35ZIHFD.mjs.map +0 -7
- package/dist/lib/browser/keyboard-HMTMA33N.mjs.map +0 -7
- package/dist/lib/browser/meta.json +0 -1
- package/dist/lib/browser/react-surface-WKWXMM2N.mjs +0 -51
- package/dist/lib/browser/react-surface-WKWXMM2N.mjs.map +0 -7
- package/dist/lib/browser/state-P5DGL7KS.mjs +0 -117
- package/dist/lib/browser/state-P5DGL7KS.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 -337
- 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
|
@@ -2,19 +2,21 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
6
|
-
import { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
7
|
-
import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';
|
|
8
|
-
import { scrollJustEnoughIntoView } from '@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view';
|
|
9
5
|
import {
|
|
10
6
|
type Edge,
|
|
11
7
|
attachClosestEdge,
|
|
12
8
|
extractClosestEdge,
|
|
13
9
|
} from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
10
|
+
import { combine } from '@atlaskit/pragmatic-drag-and-drop/combine';
|
|
11
|
+
import { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
12
|
+
import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';
|
|
13
|
+
import { scrollJustEnoughIntoView } from '@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view';
|
|
14
|
+
import { useAtomValue } from '@effect-atom/atom-react';
|
|
14
15
|
import React, {
|
|
15
16
|
type MouseEvent,
|
|
16
17
|
type PropsWithChildren,
|
|
17
18
|
forwardRef,
|
|
19
|
+
memo,
|
|
18
20
|
useCallback,
|
|
19
21
|
useLayoutEffect,
|
|
20
22
|
useMemo,
|
|
@@ -23,16 +25,28 @@ import React, {
|
|
|
23
25
|
} from 'react';
|
|
24
26
|
|
|
25
27
|
import { type Node } from '@dxos/app-graph';
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
28
|
+
import { DxAvatar } from '@dxos/lit-ui/react';
|
|
29
|
+
import { useActionRunner } from '@dxos/plugin-graph';
|
|
30
|
+
import {
|
|
31
|
+
Icon,
|
|
32
|
+
IconButton,
|
|
33
|
+
ListItem,
|
|
34
|
+
ScrollArea,
|
|
35
|
+
type ThemedClassName,
|
|
36
|
+
Tooltip,
|
|
37
|
+
toLocalizedString,
|
|
38
|
+
useMediaQuery,
|
|
39
|
+
useTranslation,
|
|
40
|
+
} from '@dxos/react-ui';
|
|
41
|
+
import { Menu, type MenuItem } from '@dxos/react-ui-menu';
|
|
29
42
|
import type { StackItemRearrangeHandler } from '@dxos/react-ui-stack';
|
|
30
43
|
import { Tabs } from '@dxos/react-ui-tabs';
|
|
31
|
-
import { mx } from '@dxos/
|
|
32
|
-
import { arrayMove
|
|
44
|
+
import { mx } from '@dxos/ui-theme';
|
|
45
|
+
import { arrayMove } from '@dxos/util';
|
|
46
|
+
|
|
47
|
+
import { useNavTreeState } from '#hooks';
|
|
48
|
+
import { meta } from '#meta';
|
|
33
49
|
|
|
34
|
-
import { useLoadDescendents } from '../../hooks';
|
|
35
|
-
import { NAVTREE_PLUGIN } from '../../meta';
|
|
36
50
|
import { l0ItemType } from '../../util';
|
|
37
51
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
38
52
|
import { UserAccountAvatar } from '../UserAccountAvatar';
|
|
@@ -47,43 +61,41 @@ type L0ItemData = {
|
|
|
47
61
|
};
|
|
48
62
|
|
|
49
63
|
type L0ItemRootProps = {
|
|
50
|
-
item: Node
|
|
51
|
-
parent?: Node
|
|
64
|
+
item: Node.Node;
|
|
65
|
+
parent?: Node.Node;
|
|
52
66
|
path: string[];
|
|
67
|
+
onMouseEnter?: () => void;
|
|
53
68
|
};
|
|
54
69
|
|
|
55
70
|
type L0ItemProps = L0ItemRootProps & {
|
|
56
|
-
item: Node
|
|
57
|
-
parent?: Node
|
|
71
|
+
item: Node.Node;
|
|
72
|
+
parent?: Node.Node;
|
|
58
73
|
path: string[];
|
|
59
74
|
pinned?: boolean;
|
|
60
75
|
onRearrange?: StackItemRearrangeHandler<L0ItemData>;
|
|
76
|
+
onItemHover?: (params: { item: Node.Node }) => void;
|
|
61
77
|
};
|
|
62
78
|
|
|
63
79
|
const useL0ItemClick = ({ item, parent, path }: L0ItemProps, type: string) => {
|
|
64
|
-
const {
|
|
65
|
-
const
|
|
80
|
+
const { onSelect, onTabChange } = useNavTreeContext();
|
|
81
|
+
const { getItem } = useNavTreeState();
|
|
82
|
+
const [isLg] = useMediaQuery('lg');
|
|
83
|
+
const runAction = useActionRunner();
|
|
66
84
|
|
|
67
85
|
return useCallback(
|
|
68
86
|
(event: MouseEvent) => {
|
|
69
87
|
switch (type) {
|
|
70
88
|
case 'action': {
|
|
71
|
-
const {
|
|
72
|
-
|
|
73
|
-
properties: { caller },
|
|
74
|
-
} = item;
|
|
75
|
-
|
|
76
|
-
return invoke?.(caller ? { node: parent, caller } : { node: parent });
|
|
89
|
+
const { properties: { caller } = {} } = item;
|
|
90
|
+
return void runAction(item as Node.Action, caller ? { parent, path, caller } : { parent, path });
|
|
77
91
|
}
|
|
78
|
-
|
|
79
92
|
case 'tab':
|
|
80
93
|
return onTabChange?.(item);
|
|
81
|
-
|
|
82
94
|
case 'link':
|
|
83
|
-
return onSelect?.({ item, path, current: !
|
|
95
|
+
return onSelect?.({ item, path, current: !getItem(path).current, option: event.altKey });
|
|
84
96
|
}
|
|
85
97
|
},
|
|
86
|
-
[item, parent, type,
|
|
98
|
+
[item, parent, type, getItem, onSelect, onTabChange, isLg, runAction],
|
|
87
99
|
);
|
|
88
100
|
};
|
|
89
101
|
|
|
@@ -91,74 +103,61 @@ const l0Breakpoints: Record<string, string> = {
|
|
|
91
103
|
lg: 'hidden lg:grid',
|
|
92
104
|
};
|
|
93
105
|
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
</Tooltip.Trigger>
|
|
130
|
-
);
|
|
131
|
-
},
|
|
106
|
+
const L0ItemRoot = memo(
|
|
107
|
+
forwardRef<HTMLButtonElement, PropsWithChildren<L0ItemRootProps>>(
|
|
108
|
+
({ item, parent, path, onMouseEnter, children }, forwardedRef) => {
|
|
109
|
+
const { t } = useTranslation(meta.id);
|
|
110
|
+
const { model } = useNavTreeContext();
|
|
111
|
+
const itemPath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
112
|
+
const { id, testId } = useAtomValue(model.itemProps(itemPath));
|
|
113
|
+
const localizedString = toLocalizedString(item.properties.label, t);
|
|
114
|
+
|
|
115
|
+
const type = l0ItemType(item);
|
|
116
|
+
const handleClick = useL0ItemClick({ item, parent, path: itemPath }, type);
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<Tooltip.Trigger asChild delayDuration={0} side='right' content={localizedString}>
|
|
120
|
+
<Tabs.TabPrimitive
|
|
121
|
+
className={mx(
|
|
122
|
+
'group/l0item flex w-full justify-center items-center relative',
|
|
123
|
+
'dx-app-no-drag dx-focus-ring-group data[type!="collection"]:cursor-pointer',
|
|
124
|
+
l0Breakpoints[item.properties.l0Breakpoint],
|
|
125
|
+
)}
|
|
126
|
+
tabIndex={type === 'tab' ? 0 : undefined}
|
|
127
|
+
data-type={type}
|
|
128
|
+
data-testid={testId}
|
|
129
|
+
data-object-id={id}
|
|
130
|
+
value={item.id}
|
|
131
|
+
onClick={handleClick}
|
|
132
|
+
onMouseEnter={onMouseEnter}
|
|
133
|
+
ref={forwardedRef}
|
|
134
|
+
>
|
|
135
|
+
{children}
|
|
136
|
+
</Tabs.TabPrimitive>
|
|
137
|
+
</Tooltip.Trigger>
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
),
|
|
132
141
|
);
|
|
133
142
|
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
[type, item.properties.label, t],
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<span role='img' className='place-self-center text-xl font-light' {...hueFgStyle}>
|
|
147
|
-
{avatarValue}
|
|
148
|
-
</span>
|
|
149
|
-
);
|
|
150
|
-
};
|
|
143
|
+
export const L0ItemActiveTabIndicator = ({ classNames }: ThemedClassName<{}>) => (
|
|
144
|
+
<div
|
|
145
|
+
className={mx(
|
|
146
|
+
'hidden group-aria-selected/l0item:block absolute start-0 h-6 w-1.5 bg-accent-bg rounded-sm',
|
|
147
|
+
classNames,
|
|
148
|
+
)}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
151
|
|
|
152
152
|
// TODO(burdon): Factor out pinned (non-draggable) items.
|
|
153
|
-
const L0Item = ({ item, parent, path, pinned, onRearrange }: L0ItemProps) => {
|
|
154
|
-
const { t } = useTranslation(
|
|
155
|
-
const itemElement = useRef<
|
|
153
|
+
const L0Item = memo(({ item, parent, path, pinned, onRearrange, onItemHover }: L0ItemProps) => {
|
|
154
|
+
const { t } = useTranslation(meta.id);
|
|
155
|
+
const itemElement = useRef<HTMLButtonElement | null>(null);
|
|
156
156
|
const [closestEdge, setEdge] = useState<Edge | null>(null);
|
|
157
157
|
const localizedString = toLocalizedString(item.properties.label, t);
|
|
158
158
|
const hue = item.properties.hue ?? null;
|
|
159
159
|
|
|
160
160
|
useLayoutEffect(() => {
|
|
161
|
-
// NOTE(thure): This is copied from StackItem, perhaps this should be DRYed out.
|
|
162
161
|
if (!itemElement.current || !onRearrange) {
|
|
163
162
|
return;
|
|
164
163
|
}
|
|
@@ -213,178 +212,160 @@ const L0Item = ({ item, parent, path, pinned, onRearrange }: L0ItemProps) => {
|
|
|
213
212
|
);
|
|
214
213
|
}, [item, onRearrange]);
|
|
215
214
|
|
|
215
|
+
const handleMouseEnter = useCallback(() => onItemHover?.({ item }), [item, onItemHover]);
|
|
216
|
+
|
|
216
217
|
return (
|
|
217
|
-
<L0ItemRoot ref={itemElement} item={item} parent={parent} path={path}>
|
|
218
|
+
<L0ItemRoot ref={itemElement} item={item} parent={parent} path={path} onMouseEnter={handleMouseEnter}>
|
|
218
219
|
<div
|
|
219
|
-
role='none'
|
|
220
220
|
data-frame={true}
|
|
221
|
-
{...(hue && { style: { background: `var(--
|
|
221
|
+
{...(hue && { style: { background: `var(--color-${hue}-surface)` } })}
|
|
222
222
|
className={mx(
|
|
223
|
-
|
|
223
|
+
'flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded-sm',
|
|
224
224
|
pinned
|
|
225
|
-
? 'p-2 group-hover/l0item:bg-
|
|
226
|
-
: '
|
|
225
|
+
? 'p-2 group-hover/l0item:bg-current-surface'
|
|
226
|
+
: 'w-(--dx-l0-avatar-size) h-(--dx-l0-avatar-size) bg-current-surface',
|
|
227
227
|
)}
|
|
228
228
|
>
|
|
229
229
|
<ItemAvatar item={item} />
|
|
230
230
|
</div>
|
|
231
|
-
<
|
|
232
|
-
role='none'
|
|
233
|
-
className='hidden group-aria-selected/l0item:block absolute inline-start-0 inset-block-2 is-1 bg-accentSurface rounded-ie'
|
|
234
|
-
/>
|
|
231
|
+
<L0ItemActiveTabIndicator />
|
|
235
232
|
<span id={`${item.id}__label`} className='sr-only'>
|
|
236
233
|
{localizedString}
|
|
237
234
|
</span>
|
|
238
235
|
{closestEdge && <ListItem.DropIndicator edge={closestEdge} />}
|
|
239
236
|
</L0ItemRoot>
|
|
240
237
|
);
|
|
241
|
-
};
|
|
238
|
+
});
|
|
242
239
|
|
|
243
240
|
const ItemAvatar = ({ item }: Pick<L0ItemProps, 'item'>) => {
|
|
244
|
-
const
|
|
241
|
+
const { t } = useTranslation(meta.id);
|
|
242
|
+
|
|
243
|
+
// Actions.
|
|
245
244
|
if (item.properties.icon) {
|
|
246
245
|
const hue = item.properties.hue ?? null;
|
|
247
|
-
const hueFgStyle = hue && { style: { color: `var(--
|
|
248
|
-
return <Icon icon={item.properties.icon} size={
|
|
246
|
+
const hueFgStyle = hue && { style: { color: `var(--color-${hue}-fg)` } };
|
|
247
|
+
return <Icon icon={item.properties.icon} size={6} {...hueFgStyle} />;
|
|
249
248
|
}
|
|
250
249
|
|
|
250
|
+
const type = l0ItemType(item);
|
|
251
251
|
if (type === 'tab' && item.properties.disposition !== 'pin-end') {
|
|
252
|
-
|
|
252
|
+
const hue = item.properties.hue ?? null;
|
|
253
|
+
const localizedString = toLocalizedString(item.properties.label, t);
|
|
254
|
+
return <DxAvatar hue={hue} hueVariant='surface' variant='square' size={12} fallback={localizedString} />;
|
|
253
255
|
}
|
|
254
256
|
|
|
255
257
|
return null;
|
|
256
258
|
};
|
|
257
259
|
|
|
258
260
|
//
|
|
259
|
-
//
|
|
261
|
+
// L0Menu
|
|
260
262
|
//
|
|
261
263
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
264
|
+
export type L0MenuProps = {
|
|
265
|
+
menuActions: MenuItem[];
|
|
266
|
+
topLevelItems: Node.Node[];
|
|
267
|
+
pinnedItems: Node.Node[];
|
|
268
|
+
userAccountItem?: Node.Node;
|
|
269
|
+
parent?: Node.Node;
|
|
270
|
+
path: string[];
|
|
271
|
+
onItemHover?: (params: { item: Node.Node }) => void;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
export const L0Menu = ({
|
|
275
|
+
menuActions,
|
|
276
|
+
topLevelItems,
|
|
277
|
+
pinnedItems,
|
|
278
|
+
userAccountItem,
|
|
279
|
+
parent,
|
|
280
|
+
path,
|
|
281
|
+
onItemHover,
|
|
282
|
+
}: L0MenuProps) => {
|
|
283
|
+
const { t } = useTranslation(meta.id);
|
|
284
|
+
const runAction = useActionRunner();
|
|
285
|
+
const handleAction = useCallback(
|
|
286
|
+
(action: Node.Action, params: Node.InvokeProps) => {
|
|
287
|
+
void runAction(action, params);
|
|
288
|
+
},
|
|
289
|
+
[runAction],
|
|
290
|
+
);
|
|
268
291
|
|
|
269
292
|
const handleRearrange = useCallback<StackItemRearrangeHandler<L0ItemData>>(
|
|
270
293
|
(source, target, closestEdge) => {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
294
|
+
const sourceItem = topLevelItems.find((i) => i.id === source.id);
|
|
295
|
+
if (!sourceItem?.properties.onRearrange) {
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
const sourceIndex = topLevelItems.findIndex((i) => i.id === source.id);
|
|
300
|
+
const targetIndex = topLevelItems.findIndex((i) => i.id === target.id);
|
|
274
301
|
const insertIndex =
|
|
275
302
|
source.id === target.id
|
|
276
303
|
? sourceIndex
|
|
277
304
|
: targetIndex +
|
|
278
305
|
(sourceIndex < targetIndex ? (closestEdge === 'top' ? -1 : 0) : closestEdge === 'bottom' ? 1 : 0);
|
|
279
|
-
const nextOrder = arrayMove([...
|
|
280
|
-
return
|
|
306
|
+
const nextOrder = arrayMove([...topLevelItems], sourceIndex, insertIndex);
|
|
307
|
+
return sourceItem.properties.onRearrange(nextOrder.map((item) => item.data));
|
|
281
308
|
},
|
|
282
|
-
[
|
|
309
|
+
[topLevelItems],
|
|
283
310
|
);
|
|
284
311
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
role='group'
|
|
288
|
-
className='contents group/l0c'
|
|
289
|
-
aria-labelledby={`${item.id}__label`}
|
|
290
|
-
data-itemid={id}
|
|
291
|
-
data-testid={testId}
|
|
292
|
-
>
|
|
293
|
-
{collectionItems.map((collectionItem) => (
|
|
294
|
-
<L0Item
|
|
295
|
-
key={collectionItem.id}
|
|
296
|
-
item={collectionItem}
|
|
297
|
-
parent={item}
|
|
298
|
-
path={groupPath}
|
|
299
|
-
{...(item.properties.onRearrangeChildren && { onRearrange: handleRearrange })}
|
|
300
|
-
/>
|
|
301
|
-
))}
|
|
302
|
-
</div>
|
|
303
|
-
);
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
//
|
|
307
|
-
// L0Menu
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
export type L0MenuProps = {
|
|
311
|
-
menuActions: MenuItem[];
|
|
312
|
-
topLevelItems: Node<any>[];
|
|
313
|
-
pinnedItems: Node<any>[];
|
|
314
|
-
userAccountItem?: Node<any>;
|
|
315
|
-
parent?: Node<any>;
|
|
316
|
-
path: string[];
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }: L0MenuProps) => {
|
|
320
|
-
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
312
|
+
// Check if any items have onRearrange to enable drag-and-drop.
|
|
313
|
+
const hasRearrangeableItems = topLevelItems.some((item) => item.properties.onRearrange);
|
|
321
314
|
|
|
322
315
|
return (
|
|
323
316
|
<Tabs.Tablist
|
|
317
|
+
data-tauri-drag-region
|
|
324
318
|
classNames={[
|
|
325
|
-
'group/l0 absolute z-[1] inset-
|
|
326
|
-
'grid grid-cols-[var(--l0-size)] grid-rows-[var(--rail-size)_1fr_min-content_var(--l0-size)] contain-layout',
|
|
327
|
-
'
|
|
319
|
+
'group/l0 absolute z-[1] inset-y-0 start-0 rounded-is',
|
|
320
|
+
'grid grid-cols-[var(--dx-l0-size)] grid-rows-[var(--dx-rail-size)_1fr_min-content_var(--dx-l0-size)] dx-contain-layout',
|
|
321
|
+
'w-(--dx-l0-size) bg-l0-surface dx-app-drag pb-[env(safe-area-inset-bottom)]',
|
|
322
|
+
'[body[data-platform="macos"]_&]:pt-[30px]',
|
|
323
|
+
'[body[data-platform="ios"]_&]:pt-[max(env(safe-area-inset-top),0.25rem)]',
|
|
328
324
|
]}
|
|
329
325
|
>
|
|
330
326
|
{/* TODO(wittjosiah): Use L0Item trigger. */}
|
|
331
|
-
<
|
|
332
|
-
<
|
|
333
|
-
<
|
|
334
|
-
<
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
</DropdownMenu.Trigger>
|
|
348
|
-
</Tooltip.Trigger>
|
|
349
|
-
</DropdownMenu.Root>
|
|
350
|
-
</MenuProvider>
|
|
327
|
+
<Menu.Root onAction={handleAction}>
|
|
328
|
+
<Menu.Trigger asChild data-testid='spacePlugin.addSpace'>
|
|
329
|
+
<div className='grid place-items-center'>
|
|
330
|
+
<IconButton
|
|
331
|
+
density='lg'
|
|
332
|
+
variant='ghost'
|
|
333
|
+
size={5}
|
|
334
|
+
icon='ph--list--regular'
|
|
335
|
+
iconOnly
|
|
336
|
+
square
|
|
337
|
+
label={t('app-menu.label')}
|
|
338
|
+
/>
|
|
339
|
+
</div>
|
|
340
|
+
</Menu.Trigger>
|
|
341
|
+
<Menu.Content group={parent} items={menuActions} />
|
|
342
|
+
</Menu.Root>
|
|
351
343
|
|
|
352
344
|
{/* Space list. */}
|
|
353
|
-
<ScrollArea.Root>
|
|
354
|
-
<ScrollArea.Viewport>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
return <L0Collection key={item.id} item={item} parent={parent} path={path} />;
|
|
366
|
-
} else {
|
|
367
|
-
return <L0Item key={item.id} item={item} parent={parent} path={path} />;
|
|
368
|
-
}
|
|
369
|
-
})}
|
|
370
|
-
</div>
|
|
371
|
-
<ScrollArea.Scrollbar orientation='vertical'>
|
|
372
|
-
<ScrollArea.Thumb />
|
|
373
|
-
</ScrollArea.Scrollbar>
|
|
345
|
+
<ScrollArea.Root centered thin orientation='vertical'>
|
|
346
|
+
<ScrollArea.Viewport classNames='flex flex-col gap-2 py-1'>
|
|
347
|
+
{topLevelItems.map((item) => (
|
|
348
|
+
<L0Item
|
|
349
|
+
key={item.id}
|
|
350
|
+
item={item}
|
|
351
|
+
parent={parent}
|
|
352
|
+
path={path}
|
|
353
|
+
onItemHover={onItemHover}
|
|
354
|
+
{...(hasRearrangeableItems && { onRearrange: handleRearrange })}
|
|
355
|
+
/>
|
|
356
|
+
))}
|
|
374
357
|
</ScrollArea.Viewport>
|
|
375
358
|
</ScrollArea.Root>
|
|
376
359
|
|
|
377
360
|
{/* Actions. */}
|
|
378
|
-
<div
|
|
379
|
-
{pinnedItems
|
|
380
|
-
.
|
|
381
|
-
|
|
382
|
-
<L0Item key={item.id} item={item} parent={parent} path={path} pinned />
|
|
383
|
-
))}
|
|
361
|
+
<div className='grid grid-cols-1 auto-rows-(--dx-rail-action) pt-2'>
|
|
362
|
+
{pinnedItems.map((item) => (
|
|
363
|
+
<L0Item key={item.id} item={item} parent={parent} path={path} pinned />
|
|
364
|
+
))}
|
|
384
365
|
</div>
|
|
385
366
|
|
|
386
367
|
{userAccountItem && (
|
|
387
|
-
<div
|
|
368
|
+
<div className='grid dx-app-no-drag'>
|
|
388
369
|
<L0ItemRoot key={userAccountItem.id} item={userAccountItem} parent={parent} path={path}>
|
|
389
370
|
<UserAccountAvatar
|
|
390
371
|
userId={userAccountItem.properties.userId}
|
|
@@ -396,15 +377,6 @@ export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountIte
|
|
|
396
377
|
</L0ItemRoot>
|
|
397
378
|
</div>
|
|
398
379
|
)}
|
|
399
|
-
|
|
400
|
-
<div
|
|
401
|
-
role='none'
|
|
402
|
-
className='hidden [body[data-platform="darwin"]_&]:block absolute block-start-0 is-[calc(var(--l0-size)-1px)] bs-[calc(40px+0.25rem)]'
|
|
403
|
-
style={{
|
|
404
|
-
background:
|
|
405
|
-
'linear-gradient(to bottom, var(--dx-sidebarSurface) 0%, var(--dx-sidebarSurface) 70%, transparent 100%)',
|
|
406
|
-
}}
|
|
407
|
-
/>
|
|
408
380
|
</Tabs.Tablist>
|
|
409
381
|
);
|
|
410
382
|
};
|