@dxos/plugin-navtree 0.8.2-main.f11618f → 0.8.2-main.fbd8ed0
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/{app-graph-builder-26D3MUCA.mjs → app-graph-builder-P7AY3K72.mjs} +7 -6
- package/dist/lib/browser/app-graph-builder-P7AY3K72.mjs.map +7 -0
- package/dist/lib/browser/{chunk-FHOAKMRS.mjs → chunk-UM2C5XK3.mjs} +352 -360
- package/dist/lib/browser/chunk-UM2C5XK3.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-OBGGMBVJ.mjs → intent-resolver-PW7B76HO.mjs} +6 -6
- package/dist/lib/browser/intent-resolver-PW7B76HO.mjs.map +7 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs +51 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-DWMOF2TM.mjs → react-surface-M3CAS7ZP.mjs} +2 -2
- package/dist/lib/browser/{state-EW62QYEN.mjs → state-3UBYOTQT.mjs} +2 -2
- package/dist/lib/browser/state-3UBYOTQT.mjs.map +7 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +4 -180
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +2 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +2 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts +3 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/index.d.ts +2 -0
- package/dist/types/src/components/NavTree/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContext.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeItemAction.d.ts → NavTreeItem/NavTreeItemAction.d.ts} +2 -3
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +8 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -0
- package/dist/types/src/components/{NavTreeItemColumns.d.ts → NavTreeItem/NavTreeItemColumns.d.ts} +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts +3 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +13 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +15 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +3 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.d.ts → UserAccountAvatar/UserAccountAvatar.d.ts} +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.stories.d.ts → UserAccountAvatar/UserAccountAvatar.stories.d.ts} +1 -2
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts +2 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +17 -15
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/hooks.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts +3 -0
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/testing/generator.d.ts +5 -4
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -1
- package/dist/types/src/util.d.ts +7 -10
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -31
- package/src/NavTreePlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +38 -28
- package/src/capabilities/intent-resolver.ts +8 -7
- package/src/capabilities/keyboard.ts +37 -32
- package/src/capabilities/state.ts +3 -3
- package/src/components/{CommandsDialog.tsx → CommandsDialog/CommandsDialog.tsx} +8 -7
- package/src/components/{CommandsTrigger.tsx → CommandsDialog/CommandsTrigger.tsx} +1 -1
- package/src/components/CommandsDialog/index.ts +6 -0
- package/src/components/NavTree/NavTree.stories.tsx +159 -0
- package/src/components/NavTree/NavTree.tsx +62 -0
- package/src/components/NavTree/index.ts +5 -0
- package/src/components/NavTreeContainer.tsx +85 -79
- package/src/components/NavTreeContext.tsx +1 -1
- package/src/components/{NavTreeItemAction.stories.tsx → NavTreeItem/NavTreeItemAction.stories.tsx} +12 -6
- package/src/components/{NavTreeItemAction.tsx → NavTreeItem/NavTreeItemAction.tsx} +13 -14
- package/src/components/{NavTreeItemColumns.tsx → NavTreeItem/NavTreeItemColumns.tsx} +5 -5
- package/src/components/NavTreeItem/index.ts +6 -0
- package/src/components/{L0Menu.tsx → Sidebar/L0Menu.tsx} +188 -131
- package/src/components/{L1Panels.tsx → Sidebar/L1Panel.tsx} +40 -65
- package/src/components/Sidebar/index.ts +6 -0
- package/src/components/{UserAccountAvatar.stories.tsx → UserAccountAvatar/UserAccountAvatar.stories.tsx} +5 -5
- package/src/components/{UserAccountAvatar.tsx → UserAccountAvatar/UserAccountAvatar.tsx} +6 -6
- package/src/components/UserAccountAvatar/index.ts +5 -0
- package/src/components/index.ts +0 -1
- package/src/components/types.ts +17 -16
- package/src/hooks.ts +12 -11
- package/src/testing/app-graph-builder.ts +224 -0
- package/src/testing/generator.ts +12 -9
- package/src/testing/index.ts +1 -0
- package/src/translations.ts +1 -1
- package/src/util.ts +10 -32
- package/dist/lib/browser/app-graph-builder-26D3MUCA.mjs.map +0 -7
- package/dist/lib/browser/chunk-FHOAKMRS.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-OBGGMBVJ.mjs.map +0 -7
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs +0 -46
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs.map +0 -7
- package/dist/lib/browser/state-EW62QYEN.mjs.map +0 -7
- package/dist/types/src/components/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/L0Menu.d.ts +0 -10
- package/dist/types/src/components/L0Menu.d.ts.map +0 -1
- package/dist/types/src/components/L1Panels.d.ts +0 -14
- package/dist/types/src/components/L1Panels.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.d.ts +0 -5
- package/dist/types/src/components/NavTree.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.stories.d.ts +0 -7
- package/dist/types/src/components/NavTree.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts +0 -41
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemColumns.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Graph.stories.d.ts +0 -7
- package/dist/types/src/stories/Graph.stories.d.ts.map +0 -1
- package/dist/types/src/stories/StorybookNavTree.d.ts +0 -4
- package/dist/types/src/stories/StorybookNavTree.d.ts.map +0 -1
- package/src/components/NavTree.stories.tsx +0 -107
- package/src/components/NavTree.tsx +0 -51
- package/src/stories/Graph.stories.tsx +0 -130
- package/src/stories/StorybookNavTree.tsx +0 -63
- /package/dist/lib/browser/{react-surface-DWMOF2TM.mjs.map → react-surface-M3CAS7ZP.mjs.map} +0 -0
- /package/dist/types/src/components/{CommandsDialog.d.ts → CommandsDialog/CommandsDialog.d.ts} +0 -0
- /package/dist/types/src/components/{CommandsTrigger.d.ts → CommandsDialog/CommandsTrigger.d.ts} +0 -0
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
8
|
-
import { extractInstruction, type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
9
|
-
import { type Meta } from '@storybook/react';
|
|
10
|
-
import React, { useEffect } from 'react';
|
|
11
|
-
|
|
12
|
-
import { isActionLike, type NodeArg } from '@dxos/app-graph';
|
|
13
|
-
import { live, type Live } from '@dxos/live-object';
|
|
14
|
-
import { faker } from '@dxos/random';
|
|
15
|
-
import { isTreeData, type TreeData } from '@dxos/react-ui-list';
|
|
16
|
-
import { Path } from '@dxos/react-ui-list';
|
|
17
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
18
|
-
|
|
19
|
-
import { StorybookNavTree } from '../stories/StorybookNavTree';
|
|
20
|
-
import { createTree, updateState } from '../testing';
|
|
21
|
-
|
|
22
|
-
faker.seed(1234);
|
|
23
|
-
|
|
24
|
-
const tree = live<NodeArg<any>>(createTree());
|
|
25
|
-
const state = new Map<string, Live<{ open: boolean; current: boolean }>>();
|
|
26
|
-
|
|
27
|
-
const meta: Meta<typeof StorybookNavTree> = {
|
|
28
|
-
title: 'plugins/plugin-navtree/NavTree',
|
|
29
|
-
component: StorybookNavTree,
|
|
30
|
-
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
31
|
-
render: (args) => {
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
return monitorForElements({
|
|
34
|
-
canMonitor: ({ source }) => isTreeData(source),
|
|
35
|
-
onDrop: ({ location, source }) => {
|
|
36
|
-
// Didn't drop on anything.
|
|
37
|
-
if (!location.current.dropTargets.length) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const target = location.current.dropTargets[0];
|
|
42
|
-
const instruction: Instruction | null = extractInstruction(target.data);
|
|
43
|
-
if (instruction !== null) {
|
|
44
|
-
updateState({
|
|
45
|
-
state: tree,
|
|
46
|
-
instruction,
|
|
47
|
-
source: source.data as TreeData,
|
|
48
|
-
target: target.data as TreeData,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
|
-
return <StorybookNavTree {...args} />;
|
|
56
|
-
},
|
|
57
|
-
args: {
|
|
58
|
-
id: tree.id,
|
|
59
|
-
getActions: (arg: NodeArg<any>) => ({
|
|
60
|
-
actions: arg.nodes?.filter((node) => isActionLike(node)) ?? [],
|
|
61
|
-
groupedActions: {},
|
|
62
|
-
}),
|
|
63
|
-
getItems: (testItem?: any) => {
|
|
64
|
-
return testItem?.nodes ?? tree.nodes ?? [];
|
|
65
|
-
},
|
|
66
|
-
getProps: (testItem: NodeArg<any>) => ({
|
|
67
|
-
id: testItem.id,
|
|
68
|
-
label: testItem.properties?.label ?? testItem.id,
|
|
69
|
-
icon: testItem.properties?.icon,
|
|
70
|
-
...((testItem.nodes?.length ?? 0) > 0 && {
|
|
71
|
-
parentOf: testItem.nodes!.map(({ id }) => id),
|
|
72
|
-
}),
|
|
73
|
-
}),
|
|
74
|
-
isOpen: (_path: string[]) => {
|
|
75
|
-
const path = Path.create(..._path);
|
|
76
|
-
const value = state.get(path) ?? live({ open: false, current: false });
|
|
77
|
-
if (!state.has(path)) {
|
|
78
|
-
state.set(path, value);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return value.open;
|
|
82
|
-
},
|
|
83
|
-
isCurrent: (_path: string[]) => {
|
|
84
|
-
const path = Path.create(..._path);
|
|
85
|
-
const value = state.get(path) ?? live({ open: false, current: false });
|
|
86
|
-
if (!state.has(path)) {
|
|
87
|
-
state.set(path, value);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return value.current;
|
|
91
|
-
},
|
|
92
|
-
onOpenChange: ({ path: _path, open }) => {
|
|
93
|
-
const path = Path.create(..._path);
|
|
94
|
-
const object = state.get(path);
|
|
95
|
-
object!.open = open;
|
|
96
|
-
},
|
|
97
|
-
onSelect: ({ path: _path, current }) => {
|
|
98
|
-
const path = Path.create(..._path);
|
|
99
|
-
const object = state.get(path);
|
|
100
|
-
object!.current = current;
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export default meta;
|
|
106
|
-
|
|
107
|
-
export const Default = {};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2024 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Tabs } from '@dxos/react-ui-tabs';
|
|
8
|
-
import { byPosition } from '@dxos/util';
|
|
9
|
-
|
|
10
|
-
import { L0Menu } from './L0Menu';
|
|
11
|
-
import { L1Panels } from './L1Panels';
|
|
12
|
-
import { useNavTreeContext } from './NavTreeContext';
|
|
13
|
-
import { type NavTreeProps } from './types';
|
|
14
|
-
import { useLoadDescendents } from '../hooks';
|
|
15
|
-
|
|
16
|
-
export const NAV_TREE_ITEM = 'NavTreeItem';
|
|
17
|
-
|
|
18
|
-
export const NavTree = ({ id, root }: NavTreeProps) => {
|
|
19
|
-
const { tab, getItems, onBack } = useNavTreeContext();
|
|
20
|
-
const topLevelActions = getItems(root, 'item').toSorted((a, b) => byPosition(a.properties, b.properties));
|
|
21
|
-
const topLevelCollections = getItems(root, 'collection');
|
|
22
|
-
const topLevelWorkspaces = getItems(root, 'workspace');
|
|
23
|
-
const topLevelNavigation = getItems(root, 'navigation');
|
|
24
|
-
const l0Items = useMemo(
|
|
25
|
-
() => [...topLevelActions, ...topLevelCollections, ...topLevelWorkspaces, ...topLevelNavigation],
|
|
26
|
-
[topLevelActions, topLevelCollections, topLevelWorkspaces, topLevelNavigation],
|
|
27
|
-
);
|
|
28
|
-
const pinnedItems = getItems(root, 'pin-end').toSorted((a, b) => byPosition(a.properties, b.properties));
|
|
29
|
-
const userAccountItem = getItems(root, 'user-account')[0];
|
|
30
|
-
const topLevelItems = useMemo(
|
|
31
|
-
() => [...l0Items, ...pinnedItems, userAccountItem],
|
|
32
|
-
[l0Items, pinnedItems, userAccountItem],
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
useLoadDescendents(root);
|
|
36
|
-
const path = useMemo(() => [id], [id]);
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
// NOTE(thure): 74px (rather than rem) is intentional in order to match the size of macOS windowing controls
|
|
40
|
-
<Tabs.Root value={tab} orientation='vertical' verticalVariant='stateless' classNames='relative'>
|
|
41
|
-
<L0Menu
|
|
42
|
-
topLevelItems={l0Items}
|
|
43
|
-
pinnedItems={pinnedItems}
|
|
44
|
-
userAccountItem={userAccountItem}
|
|
45
|
-
path={path}
|
|
46
|
-
parent={root}
|
|
47
|
-
/>
|
|
48
|
-
<L1Panels topLevelItems={topLevelItems} path={path} currentItemId={tab} onBack={onBack} />
|
|
49
|
-
</Tabs.Root>
|
|
50
|
-
);
|
|
51
|
-
};
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2023 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
|
-
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
8
|
-
import { extractInstruction, type Instruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
9
|
-
import { batch } from '@preact/signals-core';
|
|
10
|
-
import { type Meta } from '@storybook/react';
|
|
11
|
-
import React, { useEffect } from 'react';
|
|
12
|
-
|
|
13
|
-
import { Graph, ROOT_ID, type Node } from '@dxos/app-graph';
|
|
14
|
-
import { registerSignalsRuntime } from '@dxos/echo-signals/react';
|
|
15
|
-
import { live, type Live } from '@dxos/live-object';
|
|
16
|
-
import { faker } from '@dxos/random';
|
|
17
|
-
import { isTreeData, type PropsFromTreeItem } from '@dxos/react-ui-list';
|
|
18
|
-
import { Path } from '@dxos/react-ui-list';
|
|
19
|
-
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
20
|
-
|
|
21
|
-
import { StorybookNavTree } from './StorybookNavTree';
|
|
22
|
-
import { getActions, getChildren } from '../util';
|
|
23
|
-
|
|
24
|
-
faker.seed(3);
|
|
25
|
-
registerSignalsRuntime();
|
|
26
|
-
|
|
27
|
-
const createGraph = () => {
|
|
28
|
-
const graph = new Graph();
|
|
29
|
-
|
|
30
|
-
batch(() => {
|
|
31
|
-
(graph as any)._addNode({
|
|
32
|
-
id: ROOT_ID,
|
|
33
|
-
nodes: [...Array(2)].map((_, i) => ({
|
|
34
|
-
id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
|
|
35
|
-
properties: { index: `a${i}`, label: faker.lorem.words(2), description: faker.lorem.sentence() },
|
|
36
|
-
nodes: [...Array(2)].map((_, j) => ({
|
|
37
|
-
id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
|
|
38
|
-
properties: { index: `a${j}`, label: faker.lorem.words(2), description: faker.lorem.sentence() },
|
|
39
|
-
nodes: [...Array(2)].map((_, k) => ({
|
|
40
|
-
id: faker.string.hexadecimal({ length: 4 }).slice(2).toUpperCase(),
|
|
41
|
-
properties: { index: `a${k}`, label: faker.lorem.words(2), description: faker.lorem.sentence() },
|
|
42
|
-
})),
|
|
43
|
-
})),
|
|
44
|
-
})),
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
return graph;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
const graph = createGraph();
|
|
52
|
-
const state = new Map<string, Live<{ open: boolean; current: boolean }>>();
|
|
53
|
-
|
|
54
|
-
export const Default = {};
|
|
55
|
-
|
|
56
|
-
const meta: Meta<typeof StorybookNavTree> = {
|
|
57
|
-
title: 'plugins/plugin-navtree/Graph',
|
|
58
|
-
component: StorybookNavTree,
|
|
59
|
-
decorators: [withTheme, withLayout({ tooltips: true })],
|
|
60
|
-
render: (args) => {
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
return monitorForElements({
|
|
63
|
-
canMonitor: ({ source }) => isTreeData(source.data),
|
|
64
|
-
onDrop: ({ location, source }) => {
|
|
65
|
-
// Didn't drop on anything.
|
|
66
|
-
if (!location.current.dropTargets.length) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const target = location.current.dropTargets[0];
|
|
71
|
-
|
|
72
|
-
const instruction: Instruction | null = extractInstruction(target.data);
|
|
73
|
-
if (instruction !== null) {
|
|
74
|
-
// TODO(wittjosiah): Implement drop logic.
|
|
75
|
-
console.log('update', instruction);
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
}, []);
|
|
80
|
-
|
|
81
|
-
return <StorybookNavTree {...args} />;
|
|
82
|
-
},
|
|
83
|
-
args: {
|
|
84
|
-
root: graph.root,
|
|
85
|
-
id: graph.root.id,
|
|
86
|
-
getActions: (node: Node) => getActions(graph, node),
|
|
87
|
-
getItems: (node?: Node) => graph.nodes(node ?? graph.root),
|
|
88
|
-
getProps: (node: Node, path: string[]) => {
|
|
89
|
-
const children = getChildren(graph, node, undefined, path);
|
|
90
|
-
const parentOf =
|
|
91
|
-
children.length > 0 ? children.map(({ id }) => id) : node.properties.role === 'branch' ? [] : undefined;
|
|
92
|
-
return {
|
|
93
|
-
id: node.id,
|
|
94
|
-
label: node.properties.label ?? node.id,
|
|
95
|
-
icon: node.properties.icon,
|
|
96
|
-
parentOf,
|
|
97
|
-
} satisfies PropsFromTreeItem;
|
|
98
|
-
},
|
|
99
|
-
isOpen: (_path: string[]) => {
|
|
100
|
-
const path = Path.create(..._path);
|
|
101
|
-
const value = state.get(path) ?? live({ open: false, current: false });
|
|
102
|
-
if (!state.has(path)) {
|
|
103
|
-
state.set(path, value);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return value.open;
|
|
107
|
-
},
|
|
108
|
-
isCurrent: (_path: string[]) => {
|
|
109
|
-
const path = Path.create(..._path);
|
|
110
|
-
const value = state.get(path) ?? live({ open: false, current: false });
|
|
111
|
-
if (!state.has(path)) {
|
|
112
|
-
state.set(path, value);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return value.current;
|
|
116
|
-
},
|
|
117
|
-
onOpenChange: ({ path: _path, open }) => {
|
|
118
|
-
const path = Path.create(..._path);
|
|
119
|
-
const object = state.get(path);
|
|
120
|
-
object!.open = open;
|
|
121
|
-
},
|
|
122
|
-
onSelect: ({ path: _path, current }) => {
|
|
123
|
-
const path = Path.create(..._path);
|
|
124
|
-
const object = state.get(path);
|
|
125
|
-
object!.current = current;
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export default meta;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useMemo, useState } from 'react';
|
|
6
|
-
|
|
7
|
-
import { NavTree, NavTreeContext, type NavTreeContextValue, type NavTreeProps } from '../components';
|
|
8
|
-
import { type NavTreeItemGraphNode } from '../types';
|
|
9
|
-
|
|
10
|
-
export const StorybookNavTree = ({
|
|
11
|
-
getActions,
|
|
12
|
-
loadDescendents,
|
|
13
|
-
renderItemEnd,
|
|
14
|
-
popoverAnchorId,
|
|
15
|
-
getItems,
|
|
16
|
-
getProps,
|
|
17
|
-
isCurrent,
|
|
18
|
-
canDrop,
|
|
19
|
-
onSelect,
|
|
20
|
-
isOpen,
|
|
21
|
-
onOpenChange,
|
|
22
|
-
...props
|
|
23
|
-
}: NavTreeProps & NavTreeContextValue) => {
|
|
24
|
-
const [tab, setTab] = useState('never');
|
|
25
|
-
|
|
26
|
-
const contextValue = useMemo(
|
|
27
|
-
() => ({
|
|
28
|
-
tab,
|
|
29
|
-
onTabChange: (node: NavTreeItemGraphNode) => setTab(node.id),
|
|
30
|
-
getActions,
|
|
31
|
-
loadDescendents,
|
|
32
|
-
renderItemEnd,
|
|
33
|
-
popoverAnchorId,
|
|
34
|
-
getItems,
|
|
35
|
-
getProps,
|
|
36
|
-
isCurrent,
|
|
37
|
-
isOpen,
|
|
38
|
-
onOpenChange,
|
|
39
|
-
canDrop,
|
|
40
|
-
onSelect,
|
|
41
|
-
}),
|
|
42
|
-
[
|
|
43
|
-
tab,
|
|
44
|
-
setTab,
|
|
45
|
-
getActions,
|
|
46
|
-
loadDescendents,
|
|
47
|
-
renderItemEnd,
|
|
48
|
-
popoverAnchorId,
|
|
49
|
-
getItems,
|
|
50
|
-
getProps,
|
|
51
|
-
isCurrent,
|
|
52
|
-
isOpen,
|
|
53
|
-
onOpenChange,
|
|
54
|
-
canDrop,
|
|
55
|
-
onSelect,
|
|
56
|
-
],
|
|
57
|
-
);
|
|
58
|
-
return (
|
|
59
|
-
<NavTreeContext.Provider value={contextValue}>
|
|
60
|
-
<NavTree {...props} />
|
|
61
|
-
</NavTreeContext.Provider>
|
|
62
|
-
);
|
|
63
|
-
};
|
|
File without changes
|
/package/dist/types/src/components/{CommandsDialog.d.ts → CommandsDialog/CommandsDialog.d.ts}
RENAMED
|
File without changes
|
/package/dist/types/src/components/{CommandsTrigger.d.ts → CommandsDialog/CommandsTrigger.d.ts}
RENAMED
|
File without changes
|