@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
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React from 'react';
|
|
6
|
-
|
|
7
|
-
import { LayoutAction, createIntent, useIntentDispatcher } from '@dxos/app-framework';
|
|
8
|
-
import { Button, Icon, useTranslation } from '@dxos/react-ui';
|
|
9
|
-
|
|
10
|
-
import { COMMANDS_DIALOG, meta } from '../../meta';
|
|
11
|
-
|
|
12
|
-
// TODO(thure): Refactor to be handled by a more appropriate plugin.
|
|
13
|
-
export const CommandsTrigger = () => {
|
|
14
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
15
|
-
const { t } = useTranslation(meta.id);
|
|
16
|
-
return (
|
|
17
|
-
<Button
|
|
18
|
-
classNames='m-1 pli-1 lg:pli-2'
|
|
19
|
-
onClick={() =>
|
|
20
|
-
dispatch(
|
|
21
|
-
createIntent(LayoutAction.UpdateDialog, {
|
|
22
|
-
part: 'dialog',
|
|
23
|
-
subject: COMMANDS_DIALOG,
|
|
24
|
-
options: {
|
|
25
|
-
blockAlign: 'start',
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
)
|
|
29
|
-
}
|
|
30
|
-
>
|
|
31
|
-
<span className='text-description font-normal grow text-start'>{t('command list input placeholder')}</span>
|
|
32
|
-
<Icon icon='ph--magnifying-glass--regular' size={5} />
|
|
33
|
-
</Button>
|
|
34
|
-
);
|
|
35
|
-
};
|
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
6
|
-
import { type Instruction, extractInstruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
7
|
-
import { untracked } from '@preact/signals-core';
|
|
8
|
-
import React, { memo, useCallback, useEffect, useMemo } from 'react';
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
LayoutAction,
|
|
12
|
-
Surface,
|
|
13
|
-
createIntent,
|
|
14
|
-
useAppGraph,
|
|
15
|
-
useCapability,
|
|
16
|
-
useIntentDispatcher,
|
|
17
|
-
useLayout,
|
|
18
|
-
} from '@dxos/app-framework';
|
|
19
|
-
import { type Node, ROOT_ID, type ReadableGraph, isAction, isActionLike } from '@dxos/app-graph';
|
|
20
|
-
import { PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
|
|
21
|
-
import { useConnections, useActions as useGraphActions } from '@dxos/plugin-graph';
|
|
22
|
-
import { useMediaQuery, useSidebars } from '@dxos/react-ui';
|
|
23
|
-
import { type TreeData, type TreeItemDataProps, isTreeData } from '@dxos/react-ui-list';
|
|
24
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
25
|
-
import { arrayMove, byPosition } from '@dxos/util';
|
|
26
|
-
|
|
27
|
-
import { NavTreeCapabilities } from '../capabilities';
|
|
28
|
-
import { meta } from '../meta';
|
|
29
|
-
import { type FlattenedActions, type NavTreeItemGraphNode } from '../types';
|
|
30
|
-
import { getChildren, getParent, resolveMigrationOperation } from '../util';
|
|
31
|
-
|
|
32
|
-
import { NAV_TREE_ITEM, NavTree } from './NavTree';
|
|
33
|
-
import { NavTreeContext } from './NavTreeContext';
|
|
34
|
-
import { type NavTreeContextValue } from './types';
|
|
35
|
-
|
|
36
|
-
// TODO(thure): Is NavTree truly authoritative in this regard?
|
|
37
|
-
export const NODE_TYPE = 'dxos/app-graph/node';
|
|
38
|
-
|
|
39
|
-
const renderItemEnd = ({ node, open }: { node: Node; open: boolean }) => (
|
|
40
|
-
<Surface role='navtree-item-end' data={{ id: node.id, subject: node.data, open }} limit={1} />
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const getChildrenFilter = (node: Node): node is Node =>
|
|
44
|
-
untracked(
|
|
45
|
-
() => !isActionLike(node) && node.type !== PLANK_COMPANION_TYPE && node.properties.disposition !== 'hidden',
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
const filterItems = (node: Node, disposition?: string) => {
|
|
49
|
-
if (!disposition && (node.properties.disposition === 'hidden' || node.properties.disposition === 'alternate-tree')) {
|
|
50
|
-
return false;
|
|
51
|
-
} else if (!disposition) {
|
|
52
|
-
const action = isAction(node);
|
|
53
|
-
return !action || node.properties.disposition === 'item';
|
|
54
|
-
} else {
|
|
55
|
-
return node.properties.disposition === disposition;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getItems = (graph: ReadableGraph, node?: Node, disposition?: string) => {
|
|
60
|
-
return graph.getConnections(node?.id ?? ROOT_ID, 'outbound').filter((node) => filterItems(node, disposition));
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const useItems = (node?: Node, options?: { disposition?: string; sort?: boolean }) => {
|
|
64
|
-
const { graph } = useAppGraph();
|
|
65
|
-
const connections = useConnections(graph, node?.id ?? ROOT_ID);
|
|
66
|
-
const filtered = connections.filter((node) => filterItems(node, options?.disposition));
|
|
67
|
-
return options?.sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const useActions = (node: Node): FlattenedActions => {
|
|
71
|
-
const { graph } = useAppGraph();
|
|
72
|
-
const actions = useGraphActions(graph, node.id);
|
|
73
|
-
|
|
74
|
-
return useMemo(
|
|
75
|
-
() =>
|
|
76
|
-
actions.reduce(
|
|
77
|
-
(acc: FlattenedActions, arg) => {
|
|
78
|
-
if (arg.properties.disposition === 'item') {
|
|
79
|
-
return acc;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
acc.actions.push(arg);
|
|
83
|
-
if (!isAction(arg)) {
|
|
84
|
-
const actionGroup = graph.getActions(arg.id);
|
|
85
|
-
acc.groupedActions[arg.id] = actionGroup;
|
|
86
|
-
}
|
|
87
|
-
return acc;
|
|
88
|
-
},
|
|
89
|
-
{ actions: [], groupedActions: {} },
|
|
90
|
-
),
|
|
91
|
-
[actions],
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export type NavTreeContainerProps = {
|
|
96
|
-
popoverAnchorId?: string;
|
|
97
|
-
topbar?: boolean;
|
|
98
|
-
} & Pick<NavTreeContextValue, 'tab'>;
|
|
99
|
-
|
|
100
|
-
export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeContainerProps) => {
|
|
101
|
-
const [isLg] = useMediaQuery('lg');
|
|
102
|
-
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
103
|
-
const { graph } = useAppGraph();
|
|
104
|
-
const { isOpen, isCurrent, isAlternateTree, setItem } = useCapability(NavTreeCapabilities.State);
|
|
105
|
-
const layout = useLayout();
|
|
106
|
-
const { navigationSidebarState } = useSidebars(meta.id);
|
|
107
|
-
|
|
108
|
-
const getProps = useCallback(
|
|
109
|
-
(node: Node, path: string[]): TreeItemDataProps => {
|
|
110
|
-
const children = getChildren(graph, node, path).filter(getChildrenFilter);
|
|
111
|
-
const parentOf =
|
|
112
|
-
children.length > 0 ? children.map(({ id }) => id) : node.properties.role === 'branch' ? [] : undefined;
|
|
113
|
-
return {
|
|
114
|
-
id: node.id,
|
|
115
|
-
parentOf,
|
|
116
|
-
disabled: node.properties.disabled,
|
|
117
|
-
label: node.properties.label ?? node.id,
|
|
118
|
-
className: mx(node.properties.className, node.properties.modified && 'italic'), // TODO(burdon): Italic?
|
|
119
|
-
headingClassName: node.properties.headingClassName,
|
|
120
|
-
icon: node.properties.icon,
|
|
121
|
-
iconClassName: node.properties.iconClassName,
|
|
122
|
-
testId: node.properties.testId,
|
|
123
|
-
};
|
|
124
|
-
},
|
|
125
|
-
[graph],
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
const loadDescendents = useCallback(
|
|
129
|
-
(node: Node) => {
|
|
130
|
-
graph.expand(node.id, 'outbound');
|
|
131
|
-
// Load one level deeper, which resolves some juddering observed on open/close.
|
|
132
|
-
graph.getConnections(node.id, 'outbound').forEach((child) => {
|
|
133
|
-
graph.expand(child.id, 'outbound');
|
|
134
|
-
});
|
|
135
|
-
},
|
|
136
|
-
[graph],
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
const handleOpenChange = useCallback(
|
|
140
|
-
({ item: { id }, path, open }: { item: Node; path: string[]; open: boolean }) => {
|
|
141
|
-
// TODO(thure): This might become a localstorage leak; openItemIds that no longer exist should be removed from this map.
|
|
142
|
-
setItem(path, 'open', open);
|
|
143
|
-
graph.expand(id, 'outbound');
|
|
144
|
-
},
|
|
145
|
-
[graph],
|
|
146
|
-
);
|
|
147
|
-
|
|
148
|
-
const handleTabChange = useCallback(
|
|
149
|
-
async (node: NavTreeItemGraphNode) => {
|
|
150
|
-
await dispatch(
|
|
151
|
-
createIntent(LayoutAction.UpdateSidebar, {
|
|
152
|
-
part: 'sidebar',
|
|
153
|
-
options: {
|
|
154
|
-
state:
|
|
155
|
-
node.id === tab
|
|
156
|
-
? navigationSidebarState === 'expanded'
|
|
157
|
-
? isLg
|
|
158
|
-
? 'collapsed'
|
|
159
|
-
: 'closed'
|
|
160
|
-
: 'expanded'
|
|
161
|
-
: 'expanded',
|
|
162
|
-
},
|
|
163
|
-
}),
|
|
164
|
-
);
|
|
165
|
-
|
|
166
|
-
await dispatch(createIntent(LayoutAction.SwitchWorkspace, { part: 'workspace', subject: node.id }));
|
|
167
|
-
|
|
168
|
-
// Open the first item if the workspace is empty.
|
|
169
|
-
if (layout.active.length === 0) {
|
|
170
|
-
const [item] = getItems(graph, node).filter((node) => !isActionLike(node));
|
|
171
|
-
if (item && item.data) {
|
|
172
|
-
await dispatch(createIntent(LayoutAction.Open, { part: 'main', subject: [item.id] }));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
},
|
|
176
|
-
[dispatch, layout.active, tab, navigationSidebarState, isLg],
|
|
177
|
-
);
|
|
178
|
-
|
|
179
|
-
const canDrop = useCallback(({ source, target }: { source: TreeData; target: TreeData }) => {
|
|
180
|
-
return target.item.properties.canDrop?.(source) ?? false;
|
|
181
|
-
}, []);
|
|
182
|
-
|
|
183
|
-
const canSelect = useCallback(({ item }: { item: Node }) => {
|
|
184
|
-
return item.properties.selectable ?? true;
|
|
185
|
-
}, []);
|
|
186
|
-
|
|
187
|
-
const handleSelect = useCallback(
|
|
188
|
-
({ item: node, path, option }: { item: Node; path: string[]; option: boolean }) => {
|
|
189
|
-
if (!node.data) {
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
if (isAction(node)) {
|
|
194
|
-
const [parent] = graph.getConnections(node.id, 'inbound');
|
|
195
|
-
void (parent && node.data({ parent, caller: NAV_TREE_ITEM }));
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const current = isCurrent(path, node);
|
|
200
|
-
if (!current) {
|
|
201
|
-
void dispatch(
|
|
202
|
-
createIntent(LayoutAction.Open, {
|
|
203
|
-
part: 'main',
|
|
204
|
-
subject: [node.id],
|
|
205
|
-
options: { key: node.properties.key },
|
|
206
|
-
}),
|
|
207
|
-
);
|
|
208
|
-
} else if (option) {
|
|
209
|
-
void dispatch(
|
|
210
|
-
createIntent(LayoutAction.Close, { part: 'main', subject: [node.id], options: { state: false } }),
|
|
211
|
-
);
|
|
212
|
-
} else {
|
|
213
|
-
void dispatch(createIntent(LayoutAction.ScrollIntoView, { part: 'current', subject: node.id }));
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const defaultAction = graph.getActions(node.id).find((action) => action.properties?.disposition === 'default');
|
|
217
|
-
if (isAction(defaultAction)) {
|
|
218
|
-
void (defaultAction.data as () => void)();
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
if (!isLg) {
|
|
222
|
-
void dispatch(createIntent(LayoutAction.UpdateSidebar, { part: 'sidebar', options: { state: 'closed' } }));
|
|
223
|
-
}
|
|
224
|
-
},
|
|
225
|
-
[graph, dispatch, isCurrent, isLg],
|
|
226
|
-
);
|
|
227
|
-
|
|
228
|
-
const handleBack = useCallback(
|
|
229
|
-
() => dispatch(createIntent(LayoutAction.RevertWorkspace, { part: 'workspace', options: { revert: true } })),
|
|
230
|
-
[dispatch],
|
|
231
|
-
);
|
|
232
|
-
|
|
233
|
-
// TODO(wittjosiah): Factor out hook.
|
|
234
|
-
useEffect(() => {
|
|
235
|
-
return monitorForElements({
|
|
236
|
-
canMonitor: ({ source }) => isTreeData(source.data),
|
|
237
|
-
onDrop: ({ location, source }) => {
|
|
238
|
-
// Didn't drop on anything.
|
|
239
|
-
if (!location.current.dropTargets.length) {
|
|
240
|
-
return;
|
|
241
|
-
}
|
|
242
|
-
const target = location.current.dropTargets[0];
|
|
243
|
-
const instruction: Instruction | null = extractInstruction(target.data);
|
|
244
|
-
if (instruction !== null && instruction.type !== 'instruction-blocked') {
|
|
245
|
-
const sourceNode = source.data.item as NavTreeItemGraphNode;
|
|
246
|
-
const targetNode = target.data.item as NavTreeItemGraphNode;
|
|
247
|
-
const sourcePath = source.data.path as string[];
|
|
248
|
-
const targetPath = target.data.path as string[];
|
|
249
|
-
const operation =
|
|
250
|
-
sourcePath.slice(0, -1).join() === targetPath.slice(0, -1).join() && instruction.type !== 'make-child'
|
|
251
|
-
? 'rearrange'
|
|
252
|
-
: resolveMigrationOperation(graph, sourceNode, targetPath, targetNode);
|
|
253
|
-
const sourceParent = getParent(graph, sourceNode, sourcePath);
|
|
254
|
-
const targetParent = getParent(graph, targetNode, targetPath);
|
|
255
|
-
const sourceItems = getItems(graph, sourceParent);
|
|
256
|
-
const targetItems = getItems(graph, targetParent);
|
|
257
|
-
const sourceIndex = sourceItems.findIndex(({ id }) => id === sourceNode.id);
|
|
258
|
-
const targetIndex = targetItems.findIndex(({ id }) => id === targetNode.id);
|
|
259
|
-
const migrationIndex =
|
|
260
|
-
instruction.type === 'make-child'
|
|
261
|
-
? undefined
|
|
262
|
-
: instruction.type === 'reorder-below'
|
|
263
|
-
? targetIndex + 1
|
|
264
|
-
: targetIndex;
|
|
265
|
-
switch (operation) {
|
|
266
|
-
case 'rearrange': {
|
|
267
|
-
const nextItems = sourceItems.map(({ data }) => data);
|
|
268
|
-
arrayMove(nextItems, sourceIndex, targetIndex);
|
|
269
|
-
void sourceParent?.properties.onRearrangeChildren?.(nextItems);
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
case 'copy': {
|
|
273
|
-
const target = instruction.type === 'make-child' ? targetNode : targetParent;
|
|
274
|
-
void target?.properties.onCopy?.(sourceNode, migrationIndex);
|
|
275
|
-
break;
|
|
276
|
-
}
|
|
277
|
-
case 'transfer': {
|
|
278
|
-
const target = instruction.type === 'make-child' ? targetNode : targetParent;
|
|
279
|
-
if (!target?.properties.onTransferStart || !sourceParent?.properties.onTransferEnd) {
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
void target?.properties.onTransferStart(sourceNode, migrationIndex);
|
|
283
|
-
void sourceParent?.properties.onTransferEnd?.(sourceNode, target);
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
},
|
|
289
|
-
});
|
|
290
|
-
}, [graph]);
|
|
291
|
-
|
|
292
|
-
const setAlternateTree = useCallback(
|
|
293
|
-
(path: string[], open: boolean) => {
|
|
294
|
-
setItem(path, 'alternateTree', open);
|
|
295
|
-
},
|
|
296
|
-
[setItem],
|
|
297
|
-
);
|
|
298
|
-
|
|
299
|
-
const navTreeContextValue = useMemo(
|
|
300
|
-
() => ({
|
|
301
|
-
useItems,
|
|
302
|
-
tab,
|
|
303
|
-
useActions,
|
|
304
|
-
loadDescendents,
|
|
305
|
-
renderItemEnd,
|
|
306
|
-
popoverAnchorId,
|
|
307
|
-
topbar,
|
|
308
|
-
getProps,
|
|
309
|
-
isCurrent,
|
|
310
|
-
isOpen,
|
|
311
|
-
canDrop,
|
|
312
|
-
canSelect,
|
|
313
|
-
isAlternateTree,
|
|
314
|
-
setAlternateTree,
|
|
315
|
-
onTabChange: handleTabChange,
|
|
316
|
-
onOpenChange: handleOpenChange,
|
|
317
|
-
onSelect: handleSelect,
|
|
318
|
-
onBack: handleBack,
|
|
319
|
-
}),
|
|
320
|
-
[
|
|
321
|
-
tab,
|
|
322
|
-
useActions,
|
|
323
|
-
loadDescendents,
|
|
324
|
-
renderItemEnd,
|
|
325
|
-
popoverAnchorId,
|
|
326
|
-
topbar,
|
|
327
|
-
getProps,
|
|
328
|
-
isCurrent,
|
|
329
|
-
isOpen,
|
|
330
|
-
canDrop,
|
|
331
|
-
canSelect,
|
|
332
|
-
isAlternateTree,
|
|
333
|
-
setAlternateTree,
|
|
334
|
-
handleTabChange,
|
|
335
|
-
handleOpenChange,
|
|
336
|
-
handleSelect,
|
|
337
|
-
handleBack,
|
|
338
|
-
],
|
|
339
|
-
);
|
|
340
|
-
|
|
341
|
-
return (
|
|
342
|
-
<NavTreeContext.Provider value={navTreeContextValue}>
|
|
343
|
-
<NavTree id={ROOT_ID} root={graph.root} open={layout.sidebarOpen} />
|
|
344
|
-
</NavTreeContext.Provider>
|
|
345
|
-
);
|
|
346
|
-
});
|
package/src/events.ts
DELETED
package/src/hooks.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import { useEffect } from 'react';
|
|
6
|
-
|
|
7
|
-
import { type Node } from '@dxos/app-graph';
|
|
8
|
-
|
|
9
|
-
import { useNavTreeContext } from './components';
|
|
10
|
-
|
|
11
|
-
export const useLoadDescendents = (root?: Node) => {
|
|
12
|
-
const { loadDescendents } = useNavTreeContext();
|
|
13
|
-
useEffect(() => {
|
|
14
|
-
const frame = requestAnimationFrame(() => {
|
|
15
|
-
if (root) {
|
|
16
|
-
void loadDescendents?.(root);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
return () => cancelAnimationFrame(frame);
|
|
20
|
-
}, [root]);
|
|
21
|
-
};
|
|
File without changes
|