@dxos/plugin-navtree 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d
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-TZA65AKW.mjs → chunk-SNGLGBFJ.mjs} +211 -170
- package/dist/lib/browser/chunk-SNGLGBFJ.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/{node-esm/keyboard-MOZWHFUM.mjs.map → browser/keyboard-HMTMA33N.mjs.map} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-N2HPMYCU.mjs → react-surface-WKWXMM2N.mjs} +2 -2
- package/dist/lib/browser/{react-surface-N2HPMYCU.mjs.map → react-surface-WKWXMM2N.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.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.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 +1 -1
- 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/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/index.d.ts +1 -1
- package/dist/types/src/components/index.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.d.ts +5 -5
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- 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 +39 -40
- 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 +3 -5
- package/src/components/NavTree/NavTree.stories.tsx +3 -3
- package/src/components/NavTree/NavTree.tsx +3 -3
- package/src/components/NavTreeContainer.tsx +39 -16
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +6 -6
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +7 -7
- package/src/components/Sidebar/L0Menu.tsx +2 -2
- package/src/components/Sidebar/L1Panel.tsx +72 -92
- package/src/components/Sidebar/L1Tabs.tsx +58 -0
- package/src/components/Sidebar/index.ts +1 -0
- package/src/components/index.ts +1 -1
- package/src/components/types.ts +3 -2
- package/src/experimental/Tree.stories.tsx +8 -8
- package/src/experimental/Tree.tsx +15 -16
- 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-TZA65AKW.mjs.map +0 -7
- package/dist/lib/browser/keyboard-QRS6WOQH.mjs.map +0 -7
- package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
- package/dist/lib/node-esm/app-graph-builder-GY7GCTGU.mjs +0 -46
- package/dist/lib/node-esm/app-graph-builder-GY7GCTGU.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-CY7QWR4R.mjs +0 -1429
- package/dist/lib/node-esm/chunk-CY7QWR4R.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-P2JGW3WR.mjs +0 -18
- package/dist/lib/node-esm/chunk-P2JGW3WR.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-V3QXFDDP.mjs +0 -16
- package/dist/lib/node-esm/chunk-V3QXFDDP.mjs.map +0 -7
- package/dist/lib/node-esm/index.mjs +0 -150
- package/dist/lib/node-esm/index.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-R7UNPSZY.mjs +0 -48
- package/dist/lib/node-esm/intent-resolver-R7UNPSZY.mjs.map +0 -7
- package/dist/lib/node-esm/keyboard-MOZWHFUM.mjs +0 -52
- package/dist/lib/node-esm/meta.json +0 -1
- package/dist/lib/node-esm/react-surface-EW5FDMW4.mjs +0 -52
- package/dist/lib/node-esm/react-surface-EW5FDMW4.mjs.map +0 -7
- package/dist/lib/node-esm/state-Z3OTRC2I.mjs +0 -118
- package/dist/lib/node-esm/state-Z3OTRC2I.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={mx('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,63 @@ 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]);
|
|
112
|
+
|
|
113
|
+
const handleBack = useCallback(() => {
|
|
114
|
+
if (isAlternate) {
|
|
115
|
+
setAlternateTree?.(alternatePath, false);
|
|
116
|
+
} else {
|
|
117
|
+
onBack?.();
|
|
118
|
+
}
|
|
119
|
+
}, [isAlternate, alternatePath, setAlternateTree, onBack]);
|
|
157
120
|
|
|
158
|
-
|
|
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
|
+
<div>
|
|
127
|
+
{(backCapable && (
|
|
128
|
+
<IconButton
|
|
129
|
+
variant='ghost'
|
|
130
|
+
icon='ph--arrow-u-down-left--regular'
|
|
131
|
+
iconOnly
|
|
132
|
+
size={5}
|
|
133
|
+
label={t('button back')}
|
|
134
|
+
classNames={[hoverableControlItem, hoverableOpenControlItem, 'pointer-fine:pli-1']}
|
|
135
|
+
onClick={handleBack}
|
|
136
|
+
/>
|
|
137
|
+
)) ||
|
|
138
|
+
(alternateTree && !isAlternate && (
|
|
139
|
+
<IconButton
|
|
140
|
+
data-testid='treeView.alternateTreeButton'
|
|
141
|
+
variant='ghost'
|
|
142
|
+
icon={alternateTree.properties.icon ?? 'ph--placeholder--regular'}
|
|
143
|
+
iconOnly
|
|
144
|
+
size={5}
|
|
145
|
+
label={toLocalizedString(alternateTree.properties.label ?? alternateTree.id, t)}
|
|
146
|
+
classNames={[hoverableControlItem, hoverableOpenControlItem, 'pointer-fine:pli-1']}
|
|
147
|
+
onClick={handleOpen}
|
|
148
|
+
/>
|
|
149
|
+
)) || <div />}
|
|
150
|
+
</div>
|
|
151
|
+
<NavTreeItemColumns open path={path} item={item} density='coarse' />
|
|
152
|
+
</div>
|
|
173
153
|
);
|
|
174
154
|
};
|
|
@@ -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
|
+
};
|
package/src/components/index.ts
CHANGED
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,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import '@dxos-theme';
|
|
6
6
|
|
|
7
|
-
import { House, List, Planet, PlusCircle, Sailboat } from '@phosphor-icons/react';
|
|
8
7
|
import { type Meta } from '@storybook/react-vite';
|
|
9
8
|
import React, { type JSX, type PropsWithChildren, useEffect, useState } from 'react';
|
|
10
9
|
|
|
11
10
|
import { faker } from '@dxos/random';
|
|
11
|
+
import { Icon, IconButton } from '@dxos/react-ui';
|
|
12
12
|
import { modalSurface, mx } from '@dxos/react-ui-theme';
|
|
13
13
|
import { withLayout, withTheme } from '@dxos/storybook-utils';
|
|
14
14
|
|
|
@@ -48,7 +48,7 @@ const data: TreeNodeData[] = [
|
|
|
48
48
|
id: faker.string.uuid(),
|
|
49
49
|
title: 'plugins/Personal Space',
|
|
50
50
|
color: 'text-green-400',
|
|
51
|
-
|
|
51
|
+
iconName: 'ph--house--regular',
|
|
52
52
|
children: [
|
|
53
53
|
{
|
|
54
54
|
id: faker.string.uuid(),
|
|
@@ -83,7 +83,7 @@ const data: TreeNodeData[] = [
|
|
|
83
83
|
{
|
|
84
84
|
id: faker.string.uuid(),
|
|
85
85
|
title: faker.commerce.productName(),
|
|
86
|
-
|
|
86
|
+
iconName: 'ph--planet--regular',
|
|
87
87
|
children: [
|
|
88
88
|
{
|
|
89
89
|
id: faker.string.uuid(),
|
|
@@ -94,12 +94,12 @@ const data: TreeNodeData[] = [
|
|
|
94
94
|
{
|
|
95
95
|
id: faker.string.uuid(),
|
|
96
96
|
title: faker.commerce.productName(),
|
|
97
|
-
|
|
97
|
+
iconName: 'ph--sailboat--regular',
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
100
|
id: faker.string.uuid(),
|
|
101
101
|
title: faker.commerce.productName(),
|
|
102
|
-
|
|
102
|
+
iconName: 'ph--planet--regular',
|
|
103
103
|
},
|
|
104
104
|
],
|
|
105
105
|
},
|
|
@@ -181,7 +181,7 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
|
|
|
181
181
|
setItems((items) => {
|
|
182
182
|
items[0].children?.push({
|
|
183
183
|
id: faker.string.uuid(),
|
|
184
|
-
|
|
184
|
+
iconName: 'ph--planet--regular',
|
|
185
185
|
title: faker.commerce.productName(),
|
|
186
186
|
});
|
|
187
187
|
|
|
@@ -213,11 +213,11 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
|
|
|
213
213
|
</div>
|
|
214
214
|
|
|
215
215
|
<div className='flex items-center my-2 px-2 gap-2'>
|
|
216
|
-
<
|
|
216
|
+
<IconButton icon='ph--plus-circle--regular' iconOnly label='Create space' onClick={handleCreateSpace} />
|
|
217
217
|
<span className='grow text-sm' onClick={handleCreateSpace}>
|
|
218
218
|
New space
|
|
219
219
|
</span>
|
|
220
|
-
<
|
|
220
|
+
<Icon icon='ph--list--regular' />
|
|
221
221
|
</div>
|
|
222
222
|
</div>
|
|
223
223
|
);
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { CaretRight, Circle, File, Folder, type Icon, type IconProps, Plus, UserCircle } from '@phosphor-icons/react';
|
|
6
5
|
import React, { type HTMLAttributes, type PropsWithChildren } from 'react';
|
|
7
6
|
|
|
8
|
-
import { type ClassNameValue, type Size } from '@dxos/react-ui';
|
|
9
|
-
import {
|
|
7
|
+
import { type ClassNameValue, Icon, type Size } from '@dxos/react-ui';
|
|
8
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
10
9
|
|
|
11
10
|
// TODO(burdon): Rounded border if first/last.
|
|
12
11
|
const styles = {
|
|
@@ -15,21 +14,21 @@ const styles = {
|
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export const IconButton = ({
|
|
18
|
-
|
|
17
|
+
iconName,
|
|
19
18
|
classNames,
|
|
20
19
|
size = 4,
|
|
21
20
|
onClick,
|
|
22
|
-
|
|
21
|
+
weight = 'regular',
|
|
23
22
|
}: {
|
|
24
|
-
|
|
23
|
+
iconName: string;
|
|
25
24
|
classNames?: ClassNameValue;
|
|
26
25
|
size?: Size;
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
weight?: 'regular' | 'duotone' | 'fill';
|
|
27
|
+
} & Pick<HTMLAttributes<HTMLDivElement>, 'onClick'>) => {
|
|
29
28
|
// TODO(burdon): Density aware.
|
|
30
29
|
return (
|
|
31
30
|
<div className={mx('flex w-6 h-6 items-center justify-center select-none', classNames)} onClick={onClick}>
|
|
32
|
-
<Icon
|
|
31
|
+
<Icon icon={iconName} classNames='cursor-pointer' size={size} />
|
|
33
32
|
</div>
|
|
34
33
|
);
|
|
35
34
|
};
|
|
@@ -37,7 +36,7 @@ export const IconButton = ({
|
|
|
37
36
|
export type TreeNodeData = {
|
|
38
37
|
id: string;
|
|
39
38
|
title: string;
|
|
40
|
-
|
|
39
|
+
iconName?: string;
|
|
41
40
|
color?: string;
|
|
42
41
|
children?: TreeNodeData[];
|
|
43
42
|
};
|
|
@@ -123,7 +122,7 @@ const StateIcon = ({ node, open, selected, active }: TreeNodeProps) => {
|
|
|
123
122
|
// TODO(burdon): No animation if opening/closing folder.
|
|
124
123
|
return (
|
|
125
124
|
<IconButton
|
|
126
|
-
|
|
125
|
+
iconName={isActive ? 'ph--user-circle--regular' : 'ph--circle--regular'}
|
|
127
126
|
size={4}
|
|
128
127
|
weight={selected?.[id] ? 'fill' : 'duotone'}
|
|
129
128
|
classNames={mx(
|
|
@@ -143,7 +142,7 @@ const OpenIcon = ({
|
|
|
143
142
|
return (
|
|
144
143
|
(children?.length && open && (
|
|
145
144
|
<IconButton
|
|
146
|
-
|
|
145
|
+
iconName='ph--caret-right--regular'
|
|
147
146
|
size={3}
|
|
148
147
|
classNames={mx('transition duration-200', open?.[id] ? 'rotate-90' : 'transform-none')}
|
|
149
148
|
onClick={(ev) => {
|
|
@@ -157,12 +156,12 @@ const OpenIcon = ({
|
|
|
157
156
|
|
|
158
157
|
// TODO(burdon): Drag handle,
|
|
159
158
|
const ItemIcon = ({
|
|
160
|
-
node: { children,
|
|
159
|
+
node: { children, iconName = children?.length ? 'ph--folder--regular' : 'ph--file--regular', color },
|
|
161
160
|
}: Pick<TreeNodeProps, 'node'>) => {
|
|
162
161
|
return (
|
|
163
|
-
(
|
|
162
|
+
(iconName && (
|
|
164
163
|
<IconButton
|
|
165
|
-
|
|
164
|
+
iconName={iconName}
|
|
166
165
|
classNames={color ?? 'text-neutral-700 dark:text-neutral-300'}
|
|
167
166
|
weight={color ? 'duotone' : 'regular'}
|
|
168
167
|
/>
|
|
@@ -173,7 +172,7 @@ const ItemIcon = ({
|
|
|
173
172
|
const MenuItem = ({ node: { id }, onMenuAction }: Pick<TreeNodeProps, 'node' | 'onMenuAction'>) => {
|
|
174
173
|
return (
|
|
175
174
|
<IconButton
|
|
176
|
-
|
|
175
|
+
iconName='ph--plus--regular'
|
|
177
176
|
classNames='invisible group-hover:visible'
|
|
178
177
|
onClick={(ev) => {
|
|
179
178
|
ev.stopPropagation();
|
|
@@ -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';
|