@dxos/plugin-navtree 0.6.13-main.ed424a1 → 0.6.13
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/{chunk-PSVCPL4T.mjs → chunk-U7MTKDFQ.mjs} +1 -1
- package/dist/lib/browser/chunk-U7MTKDFQ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +44 -57
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/components/CommandsDialog.d.ts.map +1 -1
- package/dist/types/src/components/NavBarStart.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContainer.d.ts +1 -1
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/stories/Graph.stories.d.ts +1 -1
- package/dist/types/src/stories/Graph.stories.d.ts.map +1 -1
- package/package.json +30 -31
- package/src/NavTreePlugin.tsx +4 -2
- package/src/components/CommandsDialog.tsx +4 -2
- package/src/components/NavBarStart.tsx +4 -2
- package/src/components/NavTreeContainer.tsx +64 -78
- package/src/components/NavTreeFooter.tsx +1 -1
- package/src/experimental/Tree.tsx +2 -2
- package/src/meta.ts +1 -3
- package/src/stories/Graph.stories.tsx +2 -2
- package/dist/lib/browser/chunk-PSVCPL4T.mjs.map +0 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CommandsDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/CommandsDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CommandsDialog.d.ts","sourceRoot":"","sources":["../../../../src/components/CommandsDialog.tsx"],"names":[],"mappings":"AAKA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAcjD,eAAO,MAAM,qBAAqB,0BAA2B;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,sBA8FjF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavBarStart.d.ts","sourceRoot":"","sources":["../../../../src/components/NavBarStart.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NavBarStart.d.ts","sourceRoot":"","sources":["../../../../src/components/NavBarStart.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,OAAO,EAAY,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAQtD,eAAO,MAAM,WAAW,oCAAqC;IAAE,UAAU,EAAE,IAAI,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,sBAgC1G,CAAC"}
|
|
@@ -6,7 +6,7 @@ export declare const NavTreeContainer: ({ root, activeIds, openItemIds, onOpenIt
|
|
|
6
6
|
activeIds: Set<string>;
|
|
7
7
|
openItemIds: Record<string, true>;
|
|
8
8
|
onOpenItemIdsChange: (nextOpenItemIds: Record<string, true>) => void;
|
|
9
|
-
attended: string
|
|
9
|
+
attended: Set<string>;
|
|
10
10
|
popoverAnchorId?: string;
|
|
11
11
|
}) => React.JSX.Element;
|
|
12
12
|
//# sourceMappingURL=NavTreeContainer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavTreeContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/NavTreeContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA+C,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"NavTreeContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/NavTreeContainer.tsx"],"names":[],"mappings":"AAIA,OAAO,KAA+C,MAAM,OAAO,CAAC;AA0BpE,OAAO,EAML,KAAK,oBAAoB,EAG1B,MAAM,SAAS,CAAC;AAGjB,eAAO,MAAM,SAAS,wBAAwB,CAAC;AAM/C,eAAO,MAAM,gBAAgB,sFAO1B;IACD,IAAI,EAAE,oBAAoB,CAAC;IAC3B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAClC,mBAAmB,EAAE,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC;IACrE,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,sBA2TA,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/meta.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAGxD,eAAO,MAAM,WAAW,eAAe,CAAC;;;;AAExC,wBAEE"}
|
|
@@ -2,7 +2,7 @@ import '@dxos-theme';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
declare const _default: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({
|
|
5
|
+
component: ({ id, items, current, attended, open, type, popoverAnchorId, onNavigate, onItemOpenChange, renderPresence, onOver, onDrop, onMove, onDragEnd, resolveItemLevel, indentation, loadDescendents, classNames, }: import("@dxos/react-ui-navtree").NavTreeProps) => React.JSX.Element;
|
|
6
6
|
decorators: import("@storybook/react/*").Decorator[];
|
|
7
7
|
};
|
|
8
8
|
export default _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Graph.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Graph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAA4B,MAAM,OAAO,CAAC
|
|
1
|
+
{"version":3,"file":"Graph.stories.d.ts","sourceRoot":"","sources":["../../../../src/stories/Graph.stories.tsx"],"names":[],"mappings":"AAIA,OAAO,aAAa,CAAC;AAGrB,OAAO,KAA4B,MAAM,OAAO,CAAC;;;;;;AA+HjD,wBAIE;AAEF,eAAO,MAAM,OAAO;wBACE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE;CAMxC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-navtree",
|
|
3
|
-
"version": "0.6.13
|
|
3
|
+
"version": "0.6.13",
|
|
4
4
|
"description": "DXOS Surface plugin for a tree view visualization of the graph.",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -31,26 +31,25 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@preact/signals-core": "^1.6.0",
|
|
33
33
|
"date-fns": "^3.3.1",
|
|
34
|
-
"@dxos/app-
|
|
35
|
-
"@dxos/app-
|
|
36
|
-
"@dxos/
|
|
37
|
-
"@dxos/
|
|
38
|
-
"@dxos/echo-schema": "0.6.13
|
|
39
|
-
"@dxos/keyboard": "0.6.13
|
|
40
|
-
"@dxos/local-storage": "0.6.13
|
|
41
|
-
"@dxos/
|
|
42
|
-
"@dxos/
|
|
43
|
-
"@dxos/plugin-graph": "0.6.13
|
|
44
|
-
"@dxos/plugin-observability": "0.6.13
|
|
45
|
-
"@dxos/plugin-theme": "0.6.13
|
|
46
|
-
"@dxos/protocols": "0.6.13
|
|
47
|
-
"@dxos/react-
|
|
48
|
-
"@dxos/react-ui-
|
|
49
|
-
"@dxos/react-
|
|
50
|
-
"@dxos/react-ui-
|
|
51
|
-
"@dxos/
|
|
52
|
-
"@dxos/react-ui-searchlist": "0.6.13
|
|
53
|
-
"@dxos/util": "0.6.13-main.ed424a1"
|
|
34
|
+
"@dxos/app-graph": "0.6.13",
|
|
35
|
+
"@dxos/app-framework": "0.6.13",
|
|
36
|
+
"@dxos/debug": "0.6.13",
|
|
37
|
+
"@dxos/async": "0.6.13",
|
|
38
|
+
"@dxos/echo-schema": "0.6.13",
|
|
39
|
+
"@dxos/keyboard": "0.6.13",
|
|
40
|
+
"@dxos/local-storage": "0.6.13",
|
|
41
|
+
"@dxos/log": "0.6.13",
|
|
42
|
+
"@dxos/plugin-client": "0.6.13",
|
|
43
|
+
"@dxos/plugin-graph": "0.6.13",
|
|
44
|
+
"@dxos/plugin-observability": "0.6.13",
|
|
45
|
+
"@dxos/plugin-theme": "0.6.13",
|
|
46
|
+
"@dxos/protocols": "0.6.13",
|
|
47
|
+
"@dxos/react-ui-deck": "0.6.13",
|
|
48
|
+
"@dxos/react-ui-mosaic": "0.6.13",
|
|
49
|
+
"@dxos/react-client": "0.6.13",
|
|
50
|
+
"@dxos/react-ui-navtree": "0.6.13",
|
|
51
|
+
"@dxos/util": "0.6.13",
|
|
52
|
+
"@dxos/react-ui-searchlist": "0.6.13"
|
|
54
53
|
},
|
|
55
54
|
"devDependencies": {
|
|
56
55
|
"@phosphor-icons/react": "^2.1.5",
|
|
@@ -58,19 +57,19 @@
|
|
|
58
57
|
"@types/react-dom": "~18.2.0",
|
|
59
58
|
"react": "~18.2.0",
|
|
60
59
|
"react-dom": "~18.2.0",
|
|
61
|
-
"vite": "5.4
|
|
62
|
-
"@dxos/echo-signals": "0.6.13
|
|
63
|
-
"@dxos/
|
|
64
|
-
"@dxos/react-ui": "0.6.13
|
|
65
|
-
"@dxos/
|
|
66
|
-
"@dxos/storybook-utils": "0.6.13
|
|
60
|
+
"vite": "^5.3.4",
|
|
61
|
+
"@dxos/echo-signals": "0.6.13",
|
|
62
|
+
"@dxos/react-ui": "0.6.13",
|
|
63
|
+
"@dxos/react-ui-theme": "0.6.13",
|
|
64
|
+
"@dxos/random": "0.6.13",
|
|
65
|
+
"@dxos/storybook-utils": "0.6.13"
|
|
67
66
|
},
|
|
68
67
|
"peerDependencies": {
|
|
69
68
|
"@phosphor-icons/react": "^2.1.5",
|
|
70
|
-
"react": "
|
|
71
|
-
"react-dom": "
|
|
72
|
-
"@dxos/react-ui": "0.6.13
|
|
73
|
-
"@dxos/react-ui-theme": "0.6.13
|
|
69
|
+
"react": "^18.0.0",
|
|
70
|
+
"react-dom": "^18.0.0",
|
|
71
|
+
"@dxos/react-ui": "0.6.13",
|
|
72
|
+
"@dxos/react-ui-theme": "0.6.13"
|
|
74
73
|
},
|
|
75
74
|
"publishConfig": {
|
|
76
75
|
"access": "public"
|
package/src/NavTreePlugin.tsx
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { MagnifyingGlass, type IconProps } from '@phosphor-icons/react';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
8
|
import {
|
|
@@ -154,7 +155,7 @@ export const NavTreePlugin = (): PluginDefinition<NavTreePluginProvides> => {
|
|
|
154
155
|
activeIds={data.activeIds as Set<string>}
|
|
155
156
|
openItemIds={state.values.openItemIds}
|
|
156
157
|
onOpenItemIdsChange={handleOpenItemIdsChange}
|
|
157
|
-
attended={data.attended as string
|
|
158
|
+
attended={data.attended as Set<string>}
|
|
158
159
|
popoverAnchorId={data.popoverAnchorId as string}
|
|
159
160
|
/>
|
|
160
161
|
);
|
|
@@ -242,7 +243,8 @@ export const NavTreePlugin = (): PluginDefinition<NavTreePluginProvides> => {
|
|
|
242
243
|
},
|
|
243
244
|
properties: {
|
|
244
245
|
label: ['open commands label', { ns: NAVTREE_PLUGIN }],
|
|
245
|
-
icon:
|
|
246
|
+
icon: (props: IconProps) => <MagnifyingGlass {...props} />,
|
|
247
|
+
iconSymbol: 'ph--magnifying-glass--regular',
|
|
246
248
|
keyBinding: {
|
|
247
249
|
macos: 'meta+k',
|
|
248
250
|
windows: 'ctrl+k',
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { DotOutline } from '@phosphor-icons/react';
|
|
5
6
|
import React, { useMemo, useState } from 'react';
|
|
6
7
|
|
|
7
8
|
import { useIntentDispatcher, LayoutAction } from '@dxos/app-framework';
|
|
8
9
|
import { type ActionLike, isActionGroup, isAction } from '@dxos/app-graph';
|
|
9
10
|
import { Keyboard, keySymbols } from '@dxos/keyboard';
|
|
10
11
|
import { useGraph } from '@dxos/plugin-graph';
|
|
11
|
-
import { Button, Dialog,
|
|
12
|
+
import { Button, Dialog, useTranslation, toLocalizedString } from '@dxos/react-ui';
|
|
12
13
|
import { SearchList } from '@dxos/react-ui-searchlist';
|
|
13
14
|
import { descriptionText, mx } from '@dxos/react-ui-theme';
|
|
14
15
|
import { getHostPlatform } from '@dxos/util';
|
|
@@ -69,6 +70,7 @@ export const CommandsDialogContent = ({ selected: initial }: { selected?: string
|
|
|
69
70
|
typeof action.properties.keyBinding === 'string'
|
|
70
71
|
? action.properties.keyBinding
|
|
71
72
|
: action.properties.keyBinding?.[getHostPlatform()];
|
|
73
|
+
const Icon = action.properties.icon ?? DotOutline;
|
|
72
74
|
return (
|
|
73
75
|
<SearchList.Item
|
|
74
76
|
value={label}
|
|
@@ -93,7 +95,7 @@ export const CommandsDialogContent = ({ selected: initial }: { selected?: string
|
|
|
93
95
|
disabled={action.properties.disabled}
|
|
94
96
|
{...(action.properties?.testId && { 'data-testid': action.properties.testId })}
|
|
95
97
|
>
|
|
96
|
-
<Icon
|
|
98
|
+
<Icon size={4} className={mx(!action.properties.icon && 'invisible')} />
|
|
97
99
|
<span className='grow truncate'>{label}</span>
|
|
98
100
|
{shortcut && <span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>}
|
|
99
101
|
</SearchList.Item>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { DotsThreeVertical } from '@phosphor-icons/react';
|
|
5
6
|
import React, { Fragment } from 'react';
|
|
6
7
|
|
|
7
8
|
import { getGraph, type Node } from '@dxos/app-graph';
|
|
@@ -21,6 +22,7 @@ export const NavBarStart = ({ activeNode, popoverAnchorId }: { activeNode: Node;
|
|
|
21
22
|
? Popover.Anchor
|
|
22
23
|
: Fragment;
|
|
23
24
|
|
|
25
|
+
const Icon = activeNode.properties?.icon ?? DotsThreeVertical;
|
|
24
26
|
const graph = getGraph(activeNode);
|
|
25
27
|
const actions = graph.actions(activeNode);
|
|
26
28
|
const label = toLocalizedString(activeNode.properties?.label, t);
|
|
@@ -31,10 +33,10 @@ export const NavBarStart = ({ activeNode, popoverAnchorId }: { activeNode: Node;
|
|
|
31
33
|
<>
|
|
32
34
|
<ActionRoot>
|
|
33
35
|
<PlankHeading.ActionsMenu
|
|
34
|
-
|
|
36
|
+
Icon={Icon}
|
|
35
37
|
attendableId={activeNode.id}
|
|
36
38
|
triggerLabel={menuTriggerLabel}
|
|
37
|
-
actions={
|
|
39
|
+
actions={actions}
|
|
38
40
|
onAction={(action) =>
|
|
39
41
|
typeof action.data === 'function' && action.data({ node: action as Node, caller: TREE_ITEM_MAIN_HEADING })
|
|
40
42
|
}
|
|
@@ -4,21 +4,26 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { type ReactNode, useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
NavigationAction,
|
|
9
|
+
LayoutAction,
|
|
10
|
+
Surface,
|
|
11
|
+
SLUG_PATH_SEPARATOR,
|
|
12
|
+
SLUG_COLLECTION_INDICATOR,
|
|
13
|
+
useIntentDispatcher,
|
|
14
|
+
} from '@dxos/app-framework';
|
|
8
15
|
import { getGraph, isAction, isActionLike } from '@dxos/app-graph';
|
|
9
16
|
import { ElevationProvider, useMediaQuery, useSidebars } from '@dxos/react-ui';
|
|
10
|
-
import {
|
|
11
|
-
import { type MosaicDropEvent, type MosaicMoveEvent, Mosaic, Path } from '@dxos/react-ui-mosaic';
|
|
17
|
+
import { type MosaicDropEvent, type MosaicMoveEvent, Path } from '@dxos/react-ui-mosaic';
|
|
12
18
|
import {
|
|
13
|
-
getLevel,
|
|
14
19
|
NavTree,
|
|
15
|
-
type NavTreeActionsNode,
|
|
16
|
-
type NavTreeItemMoveDetails,
|
|
17
20
|
type NavTreeItemNode,
|
|
18
21
|
type NavTreeNode,
|
|
22
|
+
getLevel,
|
|
23
|
+
type NavTreeActionsNode,
|
|
19
24
|
type NavTreeProps,
|
|
25
|
+
type NavTreeItemMoveDetails,
|
|
20
26
|
} from '@dxos/react-ui-navtree';
|
|
21
|
-
import { ghostHover, mx } from '@dxos/react-ui-theme';
|
|
22
27
|
import { arrayMove } from '@dxos/util';
|
|
23
28
|
|
|
24
29
|
import { NavTreeFooter } from './NavTreeFooter';
|
|
@@ -28,10 +33,10 @@ import {
|
|
|
28
33
|
expandChildren,
|
|
29
34
|
getChildren,
|
|
30
35
|
getParent,
|
|
31
|
-
resolveMigrationOperation,
|
|
32
|
-
treeItemsFromRootNode,
|
|
33
36
|
type NavTreeItem,
|
|
34
37
|
type NavTreeItemGraphNode,
|
|
38
|
+
resolveMigrationOperation,
|
|
39
|
+
treeItemsFromRootNode,
|
|
35
40
|
} from '../util';
|
|
36
41
|
|
|
37
42
|
// TODO(thure): Is NavTree truly authoritative in this regard?
|
|
@@ -53,8 +58,7 @@ export const NavTreeContainer = ({
|
|
|
53
58
|
activeIds: Set<string>;
|
|
54
59
|
openItemIds: Record<string, true>;
|
|
55
60
|
onOpenItemIdsChange: (nextOpenItemIds: Record<string, true>) => void;
|
|
56
|
-
|
|
57
|
-
attended: string[];
|
|
61
|
+
attended: Set<string>;
|
|
58
62
|
popoverAnchorId?: string;
|
|
59
63
|
}) => {
|
|
60
64
|
const { closeNavigationSidebar } = useSidebars(NAVTREE_PLUGIN);
|
|
@@ -62,6 +66,7 @@ export const NavTreeContainer = ({
|
|
|
62
66
|
const dispatch = useIntentDispatcher();
|
|
63
67
|
|
|
64
68
|
const graph = useMemo(() => getGraph(root), [root]);
|
|
69
|
+
|
|
65
70
|
const items = treeItemsFromRootNode(graph, root, openItemIds);
|
|
66
71
|
|
|
67
72
|
const loadDescendents = useCallback(
|
|
@@ -91,12 +96,19 @@ export const NavTreeContainer = ({
|
|
|
91
96
|
await dispatch({
|
|
92
97
|
action: NavigationAction.OPEN,
|
|
93
98
|
data: {
|
|
94
|
-
activeParts:
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
activeParts: node.data?.comments
|
|
100
|
+
? {
|
|
101
|
+
main: [node.id],
|
|
102
|
+
complementary: [`${node.id}${SLUG_PATH_SEPARATOR}comments${SLUG_COLLECTION_INDICATOR}`],
|
|
103
|
+
}
|
|
104
|
+
: {
|
|
105
|
+
main: [node.id],
|
|
106
|
+
},
|
|
97
107
|
},
|
|
98
108
|
});
|
|
99
109
|
|
|
110
|
+
await dispatch({ action: LayoutAction.SCROLL_INTO_VIEW, data: { id: node.id } });
|
|
111
|
+
|
|
100
112
|
const defaultAction = actions?.find((action) => action.properties?.disposition === 'default');
|
|
101
113
|
if (isAction(defaultAction)) {
|
|
102
114
|
void (defaultAction.data as () => void)();
|
|
@@ -149,6 +161,7 @@ export const NavTreeContainer = ({
|
|
|
149
161
|
({ active, over, details }: MosaicMoveEvent<number, NavTreeItemMoveDetails>) => {
|
|
150
162
|
const levelOffset = Math.floor((details?.delta?.x ?? 0) / 16);
|
|
151
163
|
const overPosition = over.position ?? 0;
|
|
164
|
+
|
|
152
165
|
const nextItems = arrayMove(
|
|
153
166
|
items,
|
|
154
167
|
items.findIndex(({ id }) => id === active.item.id),
|
|
@@ -157,7 +170,9 @@ export const NavTreeContainer = ({
|
|
|
157
170
|
|
|
158
171
|
const previousItem: NavTreeItem | undefined = nextItems[overPosition - 1];
|
|
159
172
|
const nextItem: NavTreeItem | undefined = nextItems[overPosition + 1];
|
|
173
|
+
|
|
160
174
|
const activeNode = 'node' in active.item ? (active.item as NavTreeItem).node : undefined;
|
|
175
|
+
|
|
161
176
|
if (!activeNode || !previousItem || !previousItem.path) {
|
|
162
177
|
// console.log('[reject]', !activeNode, !previousItem, !previousItem.path);
|
|
163
178
|
// log.warn('Top-level rearrange before the first item of the NavTree is unsupported at this time.');
|
|
@@ -165,8 +180,11 @@ export const NavTreeContainer = ({
|
|
|
165
180
|
}
|
|
166
181
|
|
|
167
182
|
const overLevel = resolveItemLevel(overPosition, active.item.id, levelOffset);
|
|
183
|
+
|
|
168
184
|
const previousLevel = getLevel(previousItem.path);
|
|
185
|
+
|
|
169
186
|
// console.log('[over]', overLevel, previousLevel, levelOffset);
|
|
187
|
+
|
|
170
188
|
if (previousLevel === overLevel - 1) {
|
|
171
189
|
if (Path.hasChild(previousItem.id, active.item.id)) {
|
|
172
190
|
// Previous is already parent of Active, rearrange.
|
|
@@ -233,9 +251,9 @@ export const NavTreeContainer = ({
|
|
|
233
251
|
if (Path.first(over.path) !== root.id) {
|
|
234
252
|
return undefined;
|
|
235
253
|
}
|
|
236
|
-
|
|
237
254
|
const { levelOffset = 0 } = details;
|
|
238
255
|
const overPosition = over.position ?? 0;
|
|
256
|
+
|
|
239
257
|
const nextItems = arrayMove(
|
|
240
258
|
items,
|
|
241
259
|
items.findIndex(({ id }) => id === active.item.id),
|
|
@@ -244,11 +262,13 @@ export const NavTreeContainer = ({
|
|
|
244
262
|
|
|
245
263
|
const activeNode = 'node' in active.item ? (active.item as NavTreeItem).node : undefined;
|
|
246
264
|
const activeParentId = Path.parent(active.item.id);
|
|
265
|
+
|
|
247
266
|
if (!activeNode) {
|
|
248
267
|
return undefined;
|
|
249
268
|
}
|
|
250
269
|
|
|
251
270
|
const activeParent = getParent(graph, activeNode, (active.item as NavTreeItem).path ?? []);
|
|
271
|
+
|
|
252
272
|
if (operation === 'rearrange') {
|
|
253
273
|
void activeParent?.properties.onRearrangeChildren?.(
|
|
254
274
|
nextItems.filter(({ id }) => Path.hasChild(activeParentId, id)).map(({ node }) => node.data),
|
|
@@ -257,8 +277,11 @@ export const NavTreeContainer = ({
|
|
|
257
277
|
} else {
|
|
258
278
|
const previousItem: NavTreeItem | undefined = nextItems[overPosition - 1];
|
|
259
279
|
const nextItem: NavTreeItem | undefined = nextItems[overPosition + 1];
|
|
280
|
+
|
|
260
281
|
const overLevel = resolveItemLevel(overPosition, active.item.id, levelOffset);
|
|
282
|
+
|
|
261
283
|
const previousLevel = getLevel(previousItem.path);
|
|
284
|
+
|
|
262
285
|
if (operation === 'copy') {
|
|
263
286
|
if (previousLevel === overLevel - 1) {
|
|
264
287
|
void previousItem.node.properties.onCopy?.(activeNode, 0);
|
|
@@ -321,72 +344,35 @@ export const NavTreeContainer = ({
|
|
|
321
344
|
onOpenItemIdsChange({ ...openItemIds });
|
|
322
345
|
}, [onOpenItemIdsChange, openItemIds]);
|
|
323
346
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return (
|
|
334
|
-
<div className='bs-full overflow-hidden row-span-3 grid grid-cols-1 grid-rows-[min-content_1fr_min-content]'>
|
|
335
|
-
<div className='flex items-center p-2'>Items: {items.length}</div>
|
|
347
|
+
return (
|
|
348
|
+
<ElevationProvider elevation='chrome'>
|
|
349
|
+
<div
|
|
350
|
+
role='none'
|
|
351
|
+
className='bs-full overflow-hidden row-span-3 grid grid-cols-1 grid-rows-[min-content_1fr_min-content]'
|
|
352
|
+
>
|
|
353
|
+
<Surface role='search-input' limit={1} />
|
|
354
|
+
{/* TODO(thure): what gives this an inline `overflow: initial`? */}
|
|
336
355
|
<div role='none' className='!overflow-y-auto'>
|
|
337
|
-
<
|
|
338
|
-
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
}
|
|
349
|
-
|
|
356
|
+
<NavTree
|
|
357
|
+
id={root.id}
|
|
358
|
+
items={items}
|
|
359
|
+
current={activeIds}
|
|
360
|
+
attended={attended}
|
|
361
|
+
type={NODE_TYPE}
|
|
362
|
+
open={openItemIds}
|
|
363
|
+
onNavigate={handleNavigate}
|
|
364
|
+
onItemOpenChange={handleItemOpenChange}
|
|
365
|
+
onMove={handleMove}
|
|
366
|
+
onDrop={handleDrop}
|
|
367
|
+
onDragEnd={handleDragEnd}
|
|
368
|
+
popoverAnchorId={popoverAnchorId}
|
|
369
|
+
renderPresence={renderPresence}
|
|
370
|
+
resolveItemLevel={resolveItemLevel}
|
|
371
|
+
loadDescendents={loadDescendents}
|
|
372
|
+
/>
|
|
350
373
|
</div>
|
|
351
374
|
<NavTreeFooter />
|
|
352
375
|
</div>
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
return (
|
|
357
|
-
<Mosaic.Root>
|
|
358
|
-
<Mosaic.DragOverlay />
|
|
359
|
-
<ElevationProvider elevation='chrome'>
|
|
360
|
-
<div
|
|
361
|
-
role='none'
|
|
362
|
-
className='bs-full overflow-hidden row-span-3 grid grid-cols-1 grid-rows-[min-content_1fr_min-content]'
|
|
363
|
-
>
|
|
364
|
-
<Surface role='search-input' limit={1} />
|
|
365
|
-
|
|
366
|
-
{/* TODO(thure): what gives this an inline `overflow: initial`? */}
|
|
367
|
-
<div role='none' className='!overflow-y-auto'>
|
|
368
|
-
<NavTree
|
|
369
|
-
id={root.id}
|
|
370
|
-
items={items}
|
|
371
|
-
current={activeIds}
|
|
372
|
-
attended={attended}
|
|
373
|
-
type={NODE_TYPE}
|
|
374
|
-
loadDescendents={loadDescendents}
|
|
375
|
-
popoverAnchorId={popoverAnchorId}
|
|
376
|
-
renderPresence={renderPresence}
|
|
377
|
-
resolveItemLevel={resolveItemLevel}
|
|
378
|
-
open={openItemIds}
|
|
379
|
-
onNavigate={handleNavigate}
|
|
380
|
-
onItemOpenChange={handleItemOpenChange}
|
|
381
|
-
onMove={handleMove}
|
|
382
|
-
onDrop={handleDrop}
|
|
383
|
-
onDragEnd={handleDragEnd}
|
|
384
|
-
/>
|
|
385
|
-
</div>
|
|
386
|
-
|
|
387
|
-
<NavTreeFooter />
|
|
388
|
-
</div>
|
|
389
|
-
</ElevationProvider>
|
|
390
|
-
</Mosaic.Root>
|
|
376
|
+
</ElevationProvider>
|
|
391
377
|
);
|
|
392
378
|
};
|
|
@@ -35,7 +35,7 @@ const buttonStyles = 'pli-1.5 text-xs font-normal';
|
|
|
35
35
|
const repo = 'https://github.com/dxos/dxos';
|
|
36
36
|
|
|
37
37
|
export const NavTreeFooter = (props: { layoutPart?: LayoutPart }) => {
|
|
38
|
-
const layoutPart = useDefaultValue(props.layoutPart,
|
|
38
|
+
const layoutPart = useDefaultValue(props.layoutPart, 'sidebar');
|
|
39
39
|
const config = useConfig();
|
|
40
40
|
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
41
41
|
const { navigationSidebarOpen } = useSidebars(NAVTREE_PLUGIN);
|
|
@@ -6,7 +6,7 @@ import { CaretRight, Circle, File, Folder, type Icon, type IconProps, Plus, User
|
|
|
6
6
|
import React, { type HTMLAttributes, type PropsWithChildren } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type ClassNameValue, type Size } from '@dxos/react-ui';
|
|
9
|
-
import {
|
|
9
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
10
10
|
|
|
11
11
|
// TODO(burdon): Rounded border if first/last.
|
|
12
12
|
const styles = {
|
|
@@ -29,7 +29,7 @@ export const IconButton = ({
|
|
|
29
29
|
// TODO(burdon): Density aware.
|
|
30
30
|
return (
|
|
31
31
|
<div className={mx('flex w-6 h-6 items-center justify-center select-none', classNames)} onClick={onClick}>
|
|
32
|
-
<Icon className=
|
|
32
|
+
<Icon size={size} className='cursor-pointer' {...props} />
|
|
33
33
|
</div>
|
|
34
34
|
);
|
|
35
35
|
};
|
package/src/meta.ts
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type PluginMeta } from '@dxos/app-framework';
|
|
6
|
-
|
|
7
5
|
export const NAVTREE_PLUGIN = 'dxos.org/plugin/navtree';
|
|
8
6
|
|
|
9
7
|
// TODO(wittjosiah): Factor out.
|
|
@@ -11,4 +9,4 @@ export const KEY_BINDING = 'KeyBinding';
|
|
|
11
9
|
|
|
12
10
|
export default {
|
|
13
11
|
id: NAVTREE_PLUGIN,
|
|
14
|
-
}
|
|
12
|
+
};
|
|
@@ -8,7 +8,7 @@ import { batch } from '@preact/signals-core';
|
|
|
8
8
|
import React, { useMemo, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { Graph } from '@dxos/app-graph';
|
|
11
|
-
import {
|
|
11
|
+
import { registerSignalRuntime } from '@dxos/echo-signals/react';
|
|
12
12
|
import { faker } from '@dxos/random';
|
|
13
13
|
import { Treegrid } from '@dxos/react-ui';
|
|
14
14
|
import { Mosaic, Path, type MosaicDropEvent, type MosaicMoveEvent, type MosaicOperation } from '@dxos/react-ui-mosaic';
|
|
@@ -19,7 +19,7 @@ import { arrayMove } from '@dxos/util';
|
|
|
19
19
|
import { type NavTreeItemGraphNode, treeItemsFromRootNode } from '../util';
|
|
20
20
|
|
|
21
21
|
faker.seed(3);
|
|
22
|
-
|
|
22
|
+
registerSignalRuntime();
|
|
23
23
|
|
|
24
24
|
const createGraph = () => {
|
|
25
25
|
const graph = new Graph();
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const NAVTREE_PLUGIN = 'dxos.org/plugin/navtree';\n\n// TODO(wittjosiah): Factor out.\nexport const KEY_BINDING = 'KeyBinding';\n\nexport default {\n id: NAVTREE_PLUGIN,\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,iBAAiB;AAGvB,IAAMC,cAAc;AAE3B,IAAA,eAAe;EACbC,IAAIF;AACN;",
|
|
6
|
-
"names": ["NAVTREE_PLUGIN", "KEY_BINDING", "id"]
|
|
7
|
-
}
|