@dxos/plugin-navtree 0.8.4-main.c1de068 → 0.8.4-main.dedc0f3
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-5J4LRWDX.mjs → app-graph-builder-6JDBQ25U.mjs} +3 -3
- package/dist/lib/browser/{app-graph-builder-5J4LRWDX.mjs.map → app-graph-builder-6JDBQ25U.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-SICQTLXC.mjs → chunk-ZKVY35IG.mjs} +190 -163
- package/dist/lib/browser/chunk-ZKVY35IG.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +4 -5
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-3XYN2CBU.mjs → intent-resolver-N35ZIHFD.mjs} +2 -2
- package/dist/lib/browser/{intent-resolver-3XYN2CBU.mjs.map → intent-resolver-N35ZIHFD.mjs.map} +3 -3
- package/dist/lib/browser/{keyboard-QRS6WOQH.mjs → keyboard-HMTMA33N.mjs} +1 -1
- package/dist/lib/browser/{keyboard-QRS6WOQH.mjs.map → keyboard-HMTMA33N.mjs.map} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-WURHCBQQ.mjs → react-surface-5PZ4XJT7.mjs} +2 -2
- package/dist/lib/browser/{react-surface-WURHCBQQ.mjs.map → react-surface-5PZ4XJT7.mjs.map} +1 -1
- package/dist/lib/browser/{state-54DY3DOY.mjs → state-P5DGL7KS.mjs} +1 -1
- package/dist/lib/browser/state-P5DGL7KS.mjs.map +7 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +6 -6
- 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 +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +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/NavTree/NavTree.d.ts +2 -2
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +25 -2
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +32 -3
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +5 -6
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +12 -0
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +8 -4
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +2 -2
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +6 -2
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +1 -2
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +40 -39
- package/src/NavTreePlugin.tsx +5 -5
- package/src/capabilities/app-graph-builder.ts +2 -2
- package/src/capabilities/intent-resolver.ts +1 -1
- package/src/capabilities/keyboard.ts +2 -2
- package/src/capabilities/react-surface.tsx +1 -1
- package/src/capabilities/state.ts +3 -2
- package/src/components/CommandsDialog/CommandsDialog.tsx +2 -2
- package/src/components/CommandsDialog/CommandsTrigger.tsx +1 -1
- package/src/components/NavTree/NavTree.stories.tsx +5 -5
- package/src/components/NavTree/NavTree.tsx +3 -3
- package/src/components/NavTreeContainer.tsx +40 -14
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +2 -2
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +2 -2
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +7 -7
- package/src/components/Sidebar/L0Menu.tsx +2 -2
- package/src/components/Sidebar/L1Panel.tsx +70 -92
- package/src/components/Sidebar/L1Tabs.tsx +58 -0
- package/src/components/Sidebar/index.ts +1 -0
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +6 -4
- package/src/components/types.ts +3 -2
- package/src/experimental/Tree.stories.tsx +5 -3
- package/src/testing/app-graph-builder.ts +1 -1
- package/src/translations.ts +1 -0
- package/src/util.ts +2 -20
- package/dist/lib/browser/chunk-SICQTLXC.mjs.map +0 -7
- package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
|
@@ -5,68 +5,45 @@
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Node } from '@dxos/app-graph';
|
|
8
|
-
import {
|
|
8
|
+
import { IconButton, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
import { Tree } from '@dxos/react-ui-list';
|
|
10
10
|
import { Tabs } from '@dxos/react-ui-tabs';
|
|
11
|
-
import { hoverableControlItem, hoverableOpenControlItem
|
|
11
|
+
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/react-ui-theme';
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
import { NAVTREE_PLUGIN } from '../../meta';
|
|
15
|
-
import { l0ItemType } from '../../util';
|
|
13
|
+
import { meta } from '../../meta';
|
|
16
14
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
17
15
|
import { NavTreeItemColumns } from '../NavTreeItem';
|
|
18
16
|
|
|
19
|
-
const headingBackButtonLabel = 'inset-0 min-is-0 truncate flex items-center pis-2';
|
|
20
|
-
|
|
21
|
-
const TitleButton = ({ title, onClick }: { title: string } & Pick<ButtonProps, 'onClick'>) => {
|
|
22
|
-
return (
|
|
23
|
-
<Button
|
|
24
|
-
variant='ghost'
|
|
25
|
-
classNames='pli-1 flex-1 group text-start justify-start bs-[--rail-action] font-normal'
|
|
26
|
-
onClick={onClick}
|
|
27
|
-
>
|
|
28
|
-
<Icon icon='ph--caret-left--bold' size={3} />
|
|
29
|
-
<span className={mx(headingBackButtonLabel)}>{title}</span>
|
|
30
|
-
</Button>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
17
|
export type L1PanelProps = {
|
|
35
18
|
open?: boolean;
|
|
36
|
-
item: Node<any>;
|
|
37
19
|
path: string[];
|
|
20
|
+
item: Node<any>;
|
|
38
21
|
currentItemId: string;
|
|
39
22
|
onBack?: () => void;
|
|
40
23
|
};
|
|
41
24
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Space or settings panel.
|
|
27
|
+
*/
|
|
28
|
+
export const L1Panel = ({ open, path, item, currentItemId, onBack }: L1PanelProps) => {
|
|
29
|
+
const { t } = useTranslation(meta.id);
|
|
30
|
+
const { isAlternateTree, ...navTreeContext } = useNavTreeContext();
|
|
31
|
+
// NOTE(burdon): I'm very uneasy about this pattern of declaring hooks as context props.
|
|
32
|
+
const { useItems } = navTreeContext;
|
|
33
|
+
const title = toLocalizedString(item.properties.label, t);
|
|
45
34
|
|
|
46
35
|
// TODO(wittjosiah): Support multiple alternate trees.
|
|
47
|
-
const alternateTree =
|
|
36
|
+
const alternateTree = useItems(item, { disposition: 'alternate-tree' })[0];
|
|
48
37
|
const alternatePath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
49
|
-
const handleOpen = useCallback(() => setAlternateTree?.(alternatePath, true), [alternatePath, setAlternateTree]);
|
|
50
38
|
const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
|
|
51
39
|
const useAlternateItems = useCallback(
|
|
52
40
|
(node?: Node, { disposition }: { disposition?: string } = {}) => {
|
|
53
41
|
// TODO(wittjosiah): Sorting is expensive, limit to necessary items for now.
|
|
54
|
-
return
|
|
42
|
+
return useItems(node, { disposition, sort: node?.id === alternateTree.id });
|
|
55
43
|
},
|
|
56
|
-
[
|
|
44
|
+
[alternateTree, useItems],
|
|
57
45
|
);
|
|
58
46
|
|
|
59
|
-
const handleBack = useCallback(() => {
|
|
60
|
-
if (isAlternate) {
|
|
61
|
-
setAlternateTree?.(alternatePath, false);
|
|
62
|
-
} else {
|
|
63
|
-
onBack?.();
|
|
64
|
-
}
|
|
65
|
-
}, [isAlternate, onBack, alternatePath, setAlternateTree]);
|
|
66
|
-
|
|
67
|
-
const title = toLocalizedString(item.properties.label, t);
|
|
68
|
-
const backCapable = item.id.startsWith('!') || isAlternate;
|
|
69
|
-
|
|
70
47
|
return (
|
|
71
48
|
<Tabs.Tabpanel
|
|
72
49
|
key={item.id}
|
|
@@ -83,26 +60,7 @@ const L1Panel = ({ open, item, path, currentItemId, onBack }: L1PanelProps) => {
|
|
|
83
60
|
>
|
|
84
61
|
{item.id === currentItemId && (
|
|
85
62
|
<>
|
|
86
|
-
<
|
|
87
|
-
{backCapable ? (
|
|
88
|
-
<TitleButton title={title} onClick={handleBack} />
|
|
89
|
-
) : (
|
|
90
|
-
<span className='flex-1 truncate min-is-0 pis-6'>{title}</span>
|
|
91
|
-
)}
|
|
92
|
-
{alternateTree && !isAlternate && (
|
|
93
|
-
<IconButton
|
|
94
|
-
variant='ghost'
|
|
95
|
-
classNames={['shrink-0', hoverableControlItem, hoverableOpenControlItem, 'pli-2 pointer-fine:pli-1']}
|
|
96
|
-
iconOnly
|
|
97
|
-
size={5}
|
|
98
|
-
icon={alternateTree.properties.icon ?? 'ph--placeholder--regular'}
|
|
99
|
-
label={toLocalizedString(alternateTree.properties.label ?? alternateTree.id, t)}
|
|
100
|
-
data-testid='treeView.alternateTreeButton'
|
|
101
|
-
onClick={handleOpen}
|
|
102
|
-
/>
|
|
103
|
-
)}
|
|
104
|
-
<NavTreeItemColumns path={path} item={item} open density='coarse' />
|
|
105
|
-
</h2>
|
|
63
|
+
<L1PanelHeader path={path} item={item} currentItemId={currentItemId} onBack={onBack} />
|
|
106
64
|
<div role='none' className='overflow-y-auto'>
|
|
107
65
|
{isAlternate ? (
|
|
108
66
|
<Tree
|
|
@@ -134,41 +92,61 @@ const L1Panel = ({ open, item, path, currentItemId, onBack }: L1PanelProps) => {
|
|
|
134
92
|
);
|
|
135
93
|
};
|
|
136
94
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
{collectionItems
|
|
145
|
-
.filter((item) => l0ItemType(item) === 'tab')
|
|
146
|
-
.map((item) => (
|
|
147
|
-
<L1Panel key={item.id} item={item} path={groupPath} {...props} />
|
|
148
|
-
))}
|
|
149
|
-
</>
|
|
150
|
-
);
|
|
151
|
-
};
|
|
95
|
+
/**
|
|
96
|
+
* Header row.
|
|
97
|
+
*/
|
|
98
|
+
const L1PanelHeader = ({ item, path, onBack }: L1PanelProps) => {
|
|
99
|
+
const { t } = useTranslation(meta.id);
|
|
100
|
+
const { isAlternateTree, setAlternateTree, ...navTreeContext } = useNavTreeContext();
|
|
101
|
+
const title = toLocalizedString(item.properties.label, t);
|
|
152
102
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
path
|
|
156
|
-
|
|
103
|
+
// TODO(wittjosiah): Support multiple alternate trees.
|
|
104
|
+
const alternateTree = navTreeContext.useItems(item, { disposition: 'alternate-tree' })[0];
|
|
105
|
+
const alternatePath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
106
|
+
const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
|
|
107
|
+
const backCapable = item.id.startsWith('!') || isAlternate;
|
|
108
|
+
|
|
109
|
+
const handleOpen = useCallback(() => {
|
|
110
|
+
setAlternateTree?.(alternatePath, true);
|
|
111
|
+
}, [alternatePath, setAlternateTree]);
|
|
157
112
|
|
|
158
|
-
|
|
113
|
+
const handleBack = useCallback(() => {
|
|
114
|
+
if (isAlternate) {
|
|
115
|
+
setAlternateTree?.(alternatePath, false);
|
|
116
|
+
} else {
|
|
117
|
+
onBack?.();
|
|
118
|
+
}
|
|
119
|
+
}, [isAlternate, alternatePath, setAlternateTree, onBack]);
|
|
120
|
+
|
|
121
|
+
// TODO(burdon): Reuse same grid as tree?
|
|
159
122
|
return (
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
123
|
+
<div className='flex is-full items-center border-be border-subduedSeparator app-drag density-coarse'>
|
|
124
|
+
<div className='is-6' />
|
|
125
|
+
<h2 className='flex-1 truncate min-is-0'>{title}</h2>
|
|
126
|
+
{(backCapable && (
|
|
127
|
+
<IconButton
|
|
128
|
+
variant='ghost'
|
|
129
|
+
icon='ph--arrow-u-down-left--regular'
|
|
130
|
+
iconOnly
|
|
131
|
+
size={5}
|
|
132
|
+
label={t('button back')}
|
|
133
|
+
classNames={[hoverableControlItem, hoverableOpenControlItem, 'pointer-fine:pli-1']}
|
|
134
|
+
onClick={handleBack}
|
|
135
|
+
/>
|
|
136
|
+
)) ||
|
|
137
|
+
(alternateTree && !isAlternate && (
|
|
138
|
+
<IconButton
|
|
139
|
+
data-testid='treeView.alternateTreeButton'
|
|
140
|
+
variant='ghost'
|
|
141
|
+
icon={alternateTree.properties.icon ?? 'ph--placeholder--regular'}
|
|
142
|
+
iconOnly
|
|
143
|
+
size={5}
|
|
144
|
+
label={toLocalizedString(alternateTree.properties.label ?? alternateTree.id, t)}
|
|
145
|
+
classNames={[hoverableControlItem, hoverableOpenControlItem, 'pointer-fine:pli-1']}
|
|
146
|
+
onClick={handleOpen}
|
|
147
|
+
/>
|
|
148
|
+
))}
|
|
149
|
+
<NavTreeItemColumns open path={path} item={item} density='coarse' />
|
|
150
|
+
</div>
|
|
173
151
|
);
|
|
174
152
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
|
+
|
|
9
|
+
import { useLoadDescendents } from '../../hooks';
|
|
10
|
+
import { l0ItemType } from '../../util';
|
|
11
|
+
import { useNavTreeContext } from '../NavTreeContext';
|
|
12
|
+
|
|
13
|
+
import { L1Panel, type L1PanelProps } from './L1Panel';
|
|
14
|
+
|
|
15
|
+
export type L1TabsProps = Pick<L1PanelProps, 'open' | 'currentItemId' | 'onBack'> & {
|
|
16
|
+
path: string[];
|
|
17
|
+
topLevelItems: Node<any>[];
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Each space is an L1 tab.
|
|
22
|
+
*/
|
|
23
|
+
export const L1Tabs = ({ topLevelItems, onBack, ...props }: L1TabsProps) => {
|
|
24
|
+
return (
|
|
25
|
+
<>
|
|
26
|
+
{topLevelItems.map((item) => {
|
|
27
|
+
const type = l0ItemType(item);
|
|
28
|
+
switch (type) {
|
|
29
|
+
case 'tab':
|
|
30
|
+
return <L1Panel key={item.id} item={item} {...props} onBack={onBack} />;
|
|
31
|
+
case 'collection':
|
|
32
|
+
return <L1PanelCollection key={item.id} item={item} {...props} />;
|
|
33
|
+
default:
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
})}
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
const L1PanelCollection = ({ item, path, ...props }: L1PanelProps) => {
|
|
45
|
+
const { useItems } = useNavTreeContext();
|
|
46
|
+
useLoadDescendents(item);
|
|
47
|
+
const collectionItems = useItems(item);
|
|
48
|
+
const groupPath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
49
|
+
return (
|
|
50
|
+
<>
|
|
51
|
+
{collectionItems
|
|
52
|
+
.filter((item) => l0ItemType(item) === 'tab')
|
|
53
|
+
.map((item) => (
|
|
54
|
+
<L1Panel key={item.id} item={item} path={groupPath} {...props} />
|
|
55
|
+
))}
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -4,18 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
|
|
9
9
|
import { withTheme } from '@dxos/storybook-utils';
|
|
10
10
|
|
|
11
11
|
import { UserAccountAvatar } from './UserAccountAvatar';
|
|
12
12
|
|
|
13
|
-
const meta
|
|
13
|
+
const meta = {
|
|
14
14
|
title: 'plugins/plugin-navtree/UserAccountAvatar',
|
|
15
15
|
component: UserAccountAvatar,
|
|
16
16
|
decorators: [withTheme],
|
|
17
|
-
}
|
|
17
|
+
} satisfies Meta<typeof UserAccountAvatar>;
|
|
18
18
|
|
|
19
19
|
export default meta;
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
|
|
23
|
+
export const Default: Story = {};
|
package/src/components/types.ts
CHANGED
|
@@ -9,9 +9,10 @@ import type { Density } from '@dxos/react-ui';
|
|
|
9
9
|
import type { TreeProps } from '@dxos/react-ui-list';
|
|
10
10
|
import type { MaybePromise } from '@dxos/util';
|
|
11
11
|
|
|
12
|
-
import type { L1PanelProps } from './Sidebar';
|
|
13
12
|
import type { FlattenedActions, NavTreeItemGraphNode } from '../types';
|
|
14
13
|
|
|
14
|
+
import type { L1PanelProps } from './Sidebar';
|
|
15
|
+
|
|
15
16
|
export type NavTreeContextValue = Pick<
|
|
16
17
|
TreeProps<NavTreeItemGraphNode, { disposition?: string; sort?: boolean }>,
|
|
17
18
|
'useItems' | 'getProps' | 'isCurrent' | 'isOpen' | 'canDrop' | 'onOpenChange' | 'onSelect'
|
|
@@ -21,7 +22,7 @@ export type NavTreeContextValue = Pick<
|
|
|
21
22
|
topbar?: boolean;
|
|
22
23
|
popoverAnchorId?: string;
|
|
23
24
|
renderItemEnd?: FC<{ node: Node; open: boolean }>;
|
|
24
|
-
|
|
25
|
+
useActions: (node: Node) => FlattenedActions;
|
|
25
26
|
loadDescendents?: (node: Node) => MaybePromise<void>;
|
|
26
27
|
isAlternateTree?: (path: string[], item: NavTreeItemGraphNode) => boolean;
|
|
27
28
|
setAlternateTree?: (path: string[], open: boolean) => void;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { type Meta } from '@storybook/react-vite';
|
|
7
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
8
|
import React, { type JSX, type PropsWithChildren, useEffect, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
import { faker } from '@dxos/random';
|
|
@@ -223,10 +223,12 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
|
|
|
223
223
|
);
|
|
224
224
|
};
|
|
225
225
|
|
|
226
|
-
const meta
|
|
226
|
+
const meta = {
|
|
227
227
|
title: 'plugins/plugin-navtree/experimental/Tree',
|
|
228
228
|
component: Tree,
|
|
229
229
|
decorators: [withTheme, withLayout({ fullscreen: true, classNames: modalSurface })],
|
|
230
|
-
}
|
|
230
|
+
} satisfies Meta<typeof Tree>;
|
|
231
231
|
|
|
232
232
|
export default meta;
|
|
233
|
+
|
|
234
|
+
type Story = StoryObj<typeof meta>;
|
|
@@ -7,7 +7,7 @@ import { Option, pipe } from 'effect';
|
|
|
7
7
|
|
|
8
8
|
import { type PluginContext } from '@dxos/app-framework';
|
|
9
9
|
import { log } from '@dxos/log';
|
|
10
|
-
import {
|
|
10
|
+
import { type BuilderExtensions, ROOT_ID, createExtension } from '@dxos/plugin-graph';
|
|
11
11
|
import { faker } from '@dxos/random';
|
|
12
12
|
|
|
13
13
|
export const storybookGraphBuilders = (context: PluginContext): BuilderExtensions => {
|
package/src/translations.ts
CHANGED
package/src/util.ts
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type Action, type Node, type ReadableGraph,
|
|
5
|
+
import { type Action, type Node, type ReadableGraph, isActionLike } from '@dxos/app-graph';
|
|
6
6
|
import { isNonNullable } from '@dxos/util';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
8
|
+
import { type NavTreeItemGraphNode } from './types';
|
|
9
9
|
|
|
10
10
|
export const getParent = (
|
|
11
11
|
graph: ReadableGraph,
|
|
@@ -88,24 +88,6 @@ export const getChildren = (
|
|
|
88
88
|
.filter(isNonNullable) as NavTreeItemGraphNode[];
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
export const getActions = (graph: ReadableGraph, node: Node): FlattenedActions => {
|
|
92
|
-
return graph.getActions(node.id).reduce(
|
|
93
|
-
(acc: FlattenedActions, arg) => {
|
|
94
|
-
if (arg.properties.disposition === 'item') {
|
|
95
|
-
return acc;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
acc.actions.push(arg);
|
|
99
|
-
if (!isAction(arg)) {
|
|
100
|
-
const actionGroup = graph.getActions(arg.id);
|
|
101
|
-
acc.groupedActions[arg.id] = actionGroup;
|
|
102
|
-
}
|
|
103
|
-
return acc;
|
|
104
|
-
},
|
|
105
|
-
{ actions: [], groupedActions: {} },
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
91
|
export const l0ItemType = (item: Node<any>) => {
|
|
110
92
|
if (item.properties.disposition === 'collection') {
|
|
111
93
|
return 'collection';
|