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