@dxos/plugin-navtree 0.8.4-main.dedc0f3 → 0.8.4-main.ead640a
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-6JDBQ25U.mjs → app-graph-builder-YAPMENYT.mjs} +10 -9
- package/dist/lib/browser/app-graph-builder-YAPMENYT.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZKVY35IG.mjs → chunk-IMFXKPSB.mjs} +115 -102
- package/dist/lib/browser/chunk-IMFXKPSB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WCARAZ7J.mjs → chunk-LPAREX6J.mjs} +4 -4
- package/dist/lib/browser/chunk-LPAREX6J.mjs.map +7 -0
- package/dist/lib/browser/chunk-ZENLR72O.mjs +14 -0
- package/dist/lib/browser/chunk-ZENLR72O.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +5 -7
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-N35ZIHFD.mjs → intent-resolver-TCQXGF6U.mjs} +6 -6
- package/dist/lib/browser/intent-resolver-TCQXGF6U.mjs.map +7 -0
- package/dist/lib/browser/{keyboard-HMTMA33N.mjs → keyboard-AHSAWKXA.mjs} +4 -4
- package/dist/lib/browser/{keyboard-HMTMA33N.mjs.map → keyboard-AHSAWKXA.mjs.map} +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-5PZ4XJT7.mjs → react-surface-AH2TP73M.mjs} +10 -10
- package/dist/lib/browser/react-surface-AH2TP73M.mjs.map +7 -0
- package/dist/lib/browser/{state-P5DGL7KS.mjs → state-2Q623V7U.mjs} +7 -7
- package/dist/lib/browser/state-2Q623V7U.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +1 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +12 -9
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +1 -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.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +1 -2
- 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 +2 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +1 -2
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
- package/dist/types/src/events.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts +1 -2
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +2 -3
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -3
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +1 -1
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +4 -3
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -47
- package/src/NavTreePlugin.tsx +70 -71
- package/src/capabilities/app-graph-builder.ts +6 -5
- package/src/capabilities/capabilities.ts +2 -2
- package/src/capabilities/intent-resolver.ts +1 -1
- package/src/capabilities/react-surface.tsx +4 -4
- package/src/capabilities/state.ts +2 -2
- package/src/components/CommandsDialog/CommandsDialog.tsx +3 -3
- package/src/components/CommandsDialog/CommandsTrigger.tsx +2 -2
- package/src/components/NavTree/NavTree.stories.tsx +61 -47
- package/src/components/NavTree/NavTree.tsx +4 -0
- package/src/components/NavTreeContainer.tsx +13 -6
- package/src/components/NavTreeDocumentTitle.tsx +2 -2
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +2 -4
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +5 -4
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +27 -21
- package/src/components/Sidebar/L0Menu.tsx +50 -49
- package/src/components/Sidebar/L1Panel.tsx +7 -8
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +3 -4
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
- package/src/events.ts +2 -2
- package/src/experimental/Tree.stories.tsx +24 -28
- package/src/experimental/Tree.tsx +5 -22
- package/src/meta.ts +5 -7
- package/src/testing/app-graph-builder.ts +9 -8
- package/src/testing/generator.ts +2 -2
- package/src/types.ts +4 -3
- package/dist/lib/browser/app-graph-builder-6JDBQ25U.mjs.map +0 -7
- package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
- package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
- package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZKVY35IG.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-N35ZIHFD.mjs.map +0 -7
- package/dist/lib/browser/react-surface-5PZ4XJT7.mjs.map +0 -7
- package/dist/lib/browser/state-P5DGL7KS.mjs.map +0 -7
|
@@ -25,7 +25,7 @@ import { mx } from '@dxos/react-ui-theme';
|
|
|
25
25
|
import { arrayMove, byPosition } from '@dxos/util';
|
|
26
26
|
|
|
27
27
|
import { NavTreeCapabilities } from '../capabilities';
|
|
28
|
-
import {
|
|
28
|
+
import { meta } from '../meta';
|
|
29
29
|
import { type FlattenedActions, type NavTreeItemGraphNode } from '../types';
|
|
30
30
|
import { getChildren, getParent, resolveMigrationOperation } from '../util';
|
|
31
31
|
|
|
@@ -98,12 +98,12 @@ export type NavTreeContainerProps = {
|
|
|
98
98
|
} & Pick<NavTreeContextValue, 'tab'>;
|
|
99
99
|
|
|
100
100
|
export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeContainerProps) => {
|
|
101
|
-
const [isLg] = useMediaQuery('lg'
|
|
101
|
+
const [isLg] = useMediaQuery('lg');
|
|
102
102
|
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
103
103
|
const { graph } = useAppGraph();
|
|
104
104
|
const { isOpen, isCurrent, isAlternateTree, setItem } = useCapability(NavTreeCapabilities.State);
|
|
105
105
|
const layout = useLayout();
|
|
106
|
-
const { navigationSidebarState } = useSidebars(
|
|
106
|
+
const { navigationSidebarState } = useSidebars(meta.id);
|
|
107
107
|
|
|
108
108
|
const getProps = useCallback(
|
|
109
109
|
(node: Node, path: string[]): TreeItemDataProps => {
|
|
@@ -112,12 +112,13 @@ export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeC
|
|
|
112
112
|
children.length > 0 ? children.map(({ id }) => id) : node.properties.role === 'branch' ? [] : undefined;
|
|
113
113
|
return {
|
|
114
114
|
id: node.id,
|
|
115
|
-
label: node.properties.label ?? node.id,
|
|
116
115
|
parentOf,
|
|
117
|
-
icon: node.properties.icon,
|
|
118
116
|
disabled: node.properties.disabled,
|
|
119
|
-
|
|
117
|
+
label: node.properties.label ?? node.id,
|
|
118
|
+
className: mx(node.properties.className, node.properties.modified && 'italic'), // TODO(burdon): Italic?
|
|
120
119
|
headingClassName: node.properties.headingClassName,
|
|
120
|
+
icon: node.properties.icon,
|
|
121
|
+
iconClassName: node.properties.iconClassName,
|
|
121
122
|
testId: node.properties.testId,
|
|
122
123
|
};
|
|
123
124
|
},
|
|
@@ -179,6 +180,10 @@ export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeC
|
|
|
179
180
|
return target.item.properties.canDrop?.(source) ?? false;
|
|
180
181
|
}, []);
|
|
181
182
|
|
|
183
|
+
const canSelect = useCallback(({ item }: { item: Node }) => {
|
|
184
|
+
return item.properties.selectable ?? true;
|
|
185
|
+
}, []);
|
|
186
|
+
|
|
182
187
|
const handleSelect = useCallback(
|
|
183
188
|
({ item: node, path, option }: { item: Node; path: string[]; option: boolean }) => {
|
|
184
189
|
if (!node.data) {
|
|
@@ -304,6 +309,7 @@ export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeC
|
|
|
304
309
|
isCurrent,
|
|
305
310
|
isOpen,
|
|
306
311
|
canDrop,
|
|
312
|
+
canSelect,
|
|
307
313
|
isAlternateTree,
|
|
308
314
|
setAlternateTree,
|
|
309
315
|
onTabChange: handleTabChange,
|
|
@@ -322,6 +328,7 @@ export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeC
|
|
|
322
328
|
isCurrent,
|
|
323
329
|
isOpen,
|
|
324
330
|
canDrop,
|
|
331
|
+
canSelect,
|
|
325
332
|
isAlternateTree,
|
|
326
333
|
setAlternateTree,
|
|
327
334
|
handleTabChange,
|
|
@@ -6,10 +6,10 @@ import { useEffect } from 'react';
|
|
|
6
6
|
import { type Node } from '@dxos/app-graph';
|
|
7
7
|
import { toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { meta } from '../meta';
|
|
10
10
|
|
|
11
11
|
export const NavTreeDocumentTitle = ({ node }: { node?: Node }) => {
|
|
12
|
-
const { t } = useTranslation(
|
|
12
|
+
const { t } = useTranslation(meta.id);
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
document.title = node ? toLocalizedString(node.properties.label, t) : t('current app name', { ns: 'appkit' });
|
|
15
15
|
}, [node?.properties?.label]);
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
|
|
9
7
|
import { type NodeArg } from '@dxos/app-graph';
|
|
10
8
|
import { faker } from '@dxos/random';
|
|
11
|
-
import {
|
|
9
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
10
|
|
|
13
11
|
import { NavTreeItemAction, type NavTreeItemActionMenuProps } from './NavTreeItemAction';
|
|
14
12
|
|
|
@@ -42,13 +40,13 @@ const menuActions = faker.helpers.multiple(
|
|
|
42
40
|
const meta = {
|
|
43
41
|
title: 'plugins/plugin-navtree/NavTreeItemAction',
|
|
44
42
|
component: NavTreeItemAction,
|
|
45
|
-
decorators: [withTheme, withLayout()],
|
|
46
43
|
args: {
|
|
47
44
|
icon: 'ph--list--regular',
|
|
48
45
|
parent,
|
|
49
46
|
menuActions,
|
|
50
47
|
label: 'Select action',
|
|
51
48
|
} satisfies Partial<NavTreeItemActionMenuProps>,
|
|
49
|
+
decorators: [withTheme],
|
|
52
50
|
parameters: {
|
|
53
51
|
layout: 'centered',
|
|
54
52
|
},
|
|
@@ -9,7 +9,7 @@ import { IconButton, toLocalizedString, useDensityContext, useTranslation } from
|
|
|
9
9
|
import { DropdownMenu, type MenuItem, MenuProvider } from '@dxos/react-ui-menu';
|
|
10
10
|
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
12
|
-
import {
|
|
12
|
+
import { meta } from '../../meta';
|
|
13
13
|
import { type ActionProperties } from '../../types';
|
|
14
14
|
|
|
15
15
|
export type NavTreeItemActionMenuProps = ActionProperties & {
|
|
@@ -38,7 +38,7 @@ export const NavTreeItemActionDropdownMenu = ({
|
|
|
38
38
|
menuActions,
|
|
39
39
|
caller,
|
|
40
40
|
}: NavTreeItemActionMenuProps) => {
|
|
41
|
-
const { t } = useTranslation(
|
|
41
|
+
const { t } = useTranslation(meta.id);
|
|
42
42
|
const density = useDensityContext();
|
|
43
43
|
return (
|
|
44
44
|
<MenuProvider>
|
|
@@ -81,10 +81,11 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
81
81
|
label={baseLabel}
|
|
82
82
|
disabled={disabled}
|
|
83
83
|
onClick={(event) => {
|
|
84
|
+
event.stopPropagation();
|
|
84
85
|
if (disabled) {
|
|
85
86
|
return;
|
|
86
87
|
}
|
|
87
|
-
|
|
88
|
+
|
|
88
89
|
void invoke?.(caller ? { parent, caller } : { parent });
|
|
89
90
|
}}
|
|
90
91
|
data-testid={testId}
|
|
@@ -93,7 +94,7 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
93
94
|
};
|
|
94
95
|
|
|
95
96
|
export const NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }: NavTreeItemActionMenuProps) => {
|
|
96
|
-
const { t } = useTranslation(
|
|
97
|
+
const { t } = useTranslation(meta.id);
|
|
97
98
|
|
|
98
99
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
99
100
|
const baseLabel = toLocalizedString(monolithicAction ? monolithicAction.properties!.label : props.label, t);
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
import React, { Fragment, memo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { isAction } from '@dxos/app-graph';
|
|
8
|
-
import {
|
|
8
|
+
import { Popover, Treegrid, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
10
|
import { useLoadDescendents } from '../../hooks';
|
|
11
|
-
import {
|
|
11
|
+
import { meta } from '../../meta';
|
|
12
12
|
import { NAV_TREE_ITEM } from '../NavTree';
|
|
13
13
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
14
14
|
import { type NavTreeItemColumnsProps } from '../types';
|
|
15
15
|
|
|
16
16
|
import { NavTreeItemAction } from './NavTreeItemAction';
|
|
17
17
|
|
|
18
|
-
export const NavTreeItemColumns = memo(({ path, item, open
|
|
19
|
-
const { t } = useTranslation(
|
|
18
|
+
export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumnsProps) => {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
20
|
const { useActions, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
21
21
|
|
|
22
22
|
const level = path.length - 2;
|
|
@@ -29,15 +29,15 @@ export const NavTreeItemColumns = memo(({ path, item, open, density = 'fine' }:
|
|
|
29
29
|
.flatMap((action) => (isAction(action) ? [action] : []))
|
|
30
30
|
.filter((a) => ['list-item', 'list-item-primary'].includes(a.properties?.disposition));
|
|
31
31
|
|
|
32
|
-
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
33
|
-
|
|
34
32
|
useLoadDescendents(item);
|
|
35
33
|
useLoadDescendents(primaryAction && !isAction(primaryAction) ? primaryAction : undefined);
|
|
36
34
|
|
|
35
|
+
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
36
|
+
|
|
37
37
|
return (
|
|
38
|
-
<
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
<div role='none' className='contents app-no-drag'>
|
|
39
|
+
{primaryAction?.properties?.disposition === 'list-item-primary' && !primaryAction?.properties?.disabled ? (
|
|
40
|
+
<Treegrid.Cell classNames='contents'>
|
|
41
41
|
<NavTreeItemAction
|
|
42
42
|
testId={primaryAction.properties?.testId}
|
|
43
43
|
label={toLocalizedString(primaryAction.properties?.label, t)}
|
|
@@ -48,11 +48,13 @@ export const NavTreeItemColumns = memo(({ path, item, open, density = 'fine' }:
|
|
|
48
48
|
menuType={primaryAction.properties?.menuType}
|
|
49
49
|
caller={NAV_TREE_ITEM}
|
|
50
50
|
/>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
</Treegrid.Cell>
|
|
52
|
+
) : (
|
|
53
|
+
<Treegrid.Cell role='none' />
|
|
54
|
+
)}
|
|
55
|
+
<ActionRoot>
|
|
56
|
+
{actions.length > 0 ? (
|
|
57
|
+
<Treegrid.Cell classNames='contents'>
|
|
56
58
|
<NavTreeItemAction
|
|
57
59
|
testId={`navtree.treeItem.actionsLevel${level}`}
|
|
58
60
|
label={t('tree item actions label')}
|
|
@@ -62,12 +64,16 @@ export const NavTreeItemColumns = memo(({ path, item, open, density = 'fine' }:
|
|
|
62
64
|
menuType='dropdown'
|
|
63
65
|
caller={NAV_TREE_ITEM}
|
|
64
66
|
/>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
</Treegrid.Cell>
|
|
68
|
+
) : (
|
|
69
|
+
<Treegrid.Cell role='none' />
|
|
70
|
+
)}
|
|
71
|
+
</ActionRoot>
|
|
72
|
+
{ItemEnd && (
|
|
73
|
+
<Treegrid.Cell classNames='contents'>
|
|
74
|
+
<ItemEnd node={item} open={open} />
|
|
75
|
+
</Treegrid.Cell>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
72
78
|
);
|
|
73
79
|
});
|
|
@@ -24,15 +24,25 @@ import React, {
|
|
|
24
24
|
|
|
25
25
|
import { type Node } from '@dxos/app-graph';
|
|
26
26
|
import { invariant } from '@dxos/invariant';
|
|
27
|
-
import {
|
|
27
|
+
import { DxAvatar } from '@dxos/lit-ui/react';
|
|
28
|
+
import {
|
|
29
|
+
Icon,
|
|
30
|
+
ListItem,
|
|
31
|
+
ScrollArea,
|
|
32
|
+
type ThemedClassName,
|
|
33
|
+
Tooltip,
|
|
34
|
+
toLocalizedString,
|
|
35
|
+
useMediaQuery,
|
|
36
|
+
useTranslation,
|
|
37
|
+
} from '@dxos/react-ui';
|
|
28
38
|
import { DropdownMenu, type MenuItem, MenuProvider } from '@dxos/react-ui-menu';
|
|
29
39
|
import type { StackItemRearrangeHandler } from '@dxos/react-ui-stack';
|
|
30
40
|
import { Tabs } from '@dxos/react-ui-tabs';
|
|
31
41
|
import { mx } from '@dxos/react-ui-theme';
|
|
32
|
-
import { arrayMove
|
|
42
|
+
import { arrayMove } from '@dxos/util';
|
|
33
43
|
|
|
34
44
|
import { useLoadDescendents } from '../../hooks';
|
|
35
|
-
import {
|
|
45
|
+
import { meta } from '../../meta';
|
|
36
46
|
import { l0ItemType } from '../../util';
|
|
37
47
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
38
48
|
import { UserAccountAvatar } from '../UserAccountAvatar';
|
|
@@ -62,7 +72,7 @@ type L0ItemProps = L0ItemRootProps & {
|
|
|
62
72
|
|
|
63
73
|
const useL0ItemClick = ({ item, parent, path }: L0ItemProps, type: string) => {
|
|
64
74
|
const { tab, isCurrent, onSelect, onTabChange } = useNavTreeContext();
|
|
65
|
-
const [isLg] = useMediaQuery('lg'
|
|
75
|
+
const [isLg] = useMediaQuery('lg');
|
|
66
76
|
|
|
67
77
|
return useCallback(
|
|
68
78
|
(event: MouseEvent) => {
|
|
@@ -103,7 +113,7 @@ const L0ItemRoot = forwardRef<HTMLElement, PropsWithChildren<L0ItemRootProps>>(
|
|
|
103
113
|
const type = l0ItemType(item);
|
|
104
114
|
const itemPath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
105
115
|
|
|
106
|
-
const { t } = useTranslation(
|
|
116
|
+
const { t } = useTranslation(meta.id);
|
|
107
117
|
const localizedString = toLocalizedString(item.properties.label, t);
|
|
108
118
|
|
|
109
119
|
const handleClick = useL0ItemClick({ item, parent, path: itemPath }, type);
|
|
@@ -112,46 +122,36 @@ const L0ItemRoot = forwardRef<HTMLElement, PropsWithChildren<L0ItemRootProps>>(
|
|
|
112
122
|
? { value: item.id, tabIndex: 0, onClick: handleClick, 'data-testid': testId, 'data-itemid': id }
|
|
113
123
|
: type !== 'collection'
|
|
114
124
|
? { onClick: handleClick, 'data-testid': testId, 'data-itemid': id }
|
|
115
|
-
: { onClick: handleClick };
|
|
116
|
-
|
|
117
|
-
const Root = type === 'collection' ? 'h2' : type === 'tab' ? Tabs.TabPrimitive : 'button';
|
|
125
|
+
: { onClick: handleClick, role: 'button' };
|
|
118
126
|
|
|
119
127
|
return (
|
|
120
128
|
<Tooltip.Trigger asChild delayDuration={0} side='right' content={localizedString}>
|
|
121
|
-
<
|
|
129
|
+
<Tabs.TabPrimitive
|
|
122
130
|
{...(rootProps as any)}
|
|
123
131
|
data-type={type}
|
|
124
132
|
className={mx(l0ItemRoot, l0Breakpoints[item.properties.l0Breakpoint])}
|
|
125
133
|
ref={forwardedRef}
|
|
126
134
|
>
|
|
127
135
|
{children}
|
|
128
|
-
</
|
|
136
|
+
</Tabs.TabPrimitive>
|
|
129
137
|
</Tooltip.Trigger>
|
|
130
138
|
);
|
|
131
139
|
},
|
|
132
140
|
);
|
|
133
141
|
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
);
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<span role='img' className='place-self-center text-xl font-light' {...hueFgStyle}>
|
|
147
|
-
{avatarValue}
|
|
148
|
-
</span>
|
|
149
|
-
);
|
|
150
|
-
};
|
|
142
|
+
export const L0ItemActiveTabIndicator = ({ classNames }: ThemedClassName<{}>) => (
|
|
143
|
+
<div
|
|
144
|
+
role='none'
|
|
145
|
+
className={mx(
|
|
146
|
+
'hidden group-aria-selected/l0item:block absolute inline-start-0 inset-block-2 is-1 bg-accentSurface rounded-ie',
|
|
147
|
+
classNames,
|
|
148
|
+
)}
|
|
149
|
+
/>
|
|
150
|
+
);
|
|
151
151
|
|
|
152
152
|
// TODO(burdon): Factor out pinned (non-draggable) items.
|
|
153
153
|
const L0Item = ({ item, parent, path, pinned, onRearrange }: L0ItemProps) => {
|
|
154
|
-
const { t } = useTranslation(
|
|
154
|
+
const { t } = useTranslation(meta.id);
|
|
155
155
|
const itemElement = useRef<HTMLElement | null>(null);
|
|
156
156
|
const [closestEdge, setEdge] = useState<Edge | null>(null);
|
|
157
157
|
const localizedString = toLocalizedString(item.properties.label, t);
|
|
@@ -228,10 +228,7 @@ const L0Item = ({ item, parent, path, pinned, onRearrange }: L0ItemProps) => {
|
|
|
228
228
|
>
|
|
229
229
|
<ItemAvatar item={item} />
|
|
230
230
|
</div>
|
|
231
|
-
<
|
|
232
|
-
role='none'
|
|
233
|
-
className='hidden group-aria-selected/l0item:block absolute inline-start-0 inset-block-2 is-1 bg-accentSurface rounded-ie'
|
|
234
|
-
/>
|
|
231
|
+
<L0ItemActiveTabIndicator />
|
|
235
232
|
<span id={`${item.id}__label`} className='sr-only'>
|
|
236
233
|
{localizedString}
|
|
237
234
|
</span>
|
|
@@ -241,15 +238,18 @@ const L0Item = ({ item, parent, path, pinned, onRearrange }: L0ItemProps) => {
|
|
|
241
238
|
};
|
|
242
239
|
|
|
243
240
|
const ItemAvatar = ({ item }: Pick<L0ItemProps, 'item'>) => {
|
|
241
|
+
const { t } = useTranslation(meta.id);
|
|
244
242
|
const type = l0ItemType(item);
|
|
245
243
|
if (item.properties.icon) {
|
|
246
244
|
const hue = item.properties.hue ?? null;
|
|
247
245
|
const hueFgStyle = hue && { style: { color: `var(--dx-${hue}SurfaceText)` } };
|
|
248
|
-
return <Icon icon={item.properties.icon} size={
|
|
246
|
+
return <Icon icon={item.properties.icon} size={6} {...hueFgStyle} />;
|
|
249
247
|
}
|
|
250
248
|
|
|
251
249
|
if (type === 'tab' && item.properties.disposition !== 'pin-end') {
|
|
252
|
-
|
|
250
|
+
const hue = item.properties.hue ?? null;
|
|
251
|
+
const localizedString = toLocalizedString(item.properties.label, t);
|
|
252
|
+
return <DxAvatar hue={hue} hueVariant='surface' variant='square' size={12} fallback={localizedString} />;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
return null;
|
|
@@ -317,7 +317,7 @@ export type L0MenuProps = {
|
|
|
317
317
|
};
|
|
318
318
|
|
|
319
319
|
export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }: L0MenuProps) => {
|
|
320
|
-
const { t } = useTranslation(
|
|
320
|
+
const { t } = useTranslation(meta.id);
|
|
321
321
|
|
|
322
322
|
return (
|
|
323
323
|
<Tabs.Tablist
|
|
@@ -331,20 +331,22 @@ export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountIte
|
|
|
331
331
|
<MenuProvider>
|
|
332
332
|
<DropdownMenu.Root group={parent} items={menuActions}>
|
|
333
333
|
<Tooltip.Trigger content={t('app menu label')} side='right' asChild>
|
|
334
|
-
<
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
<div
|
|
339
|
-
role='none'
|
|
340
|
-
className={mx(
|
|
341
|
-
l0ItemContent,
|
|
342
|
-
'is-[--rail-action] bs-[--rail-action] group-hover/l0item:bg-hoverSurface',
|
|
343
|
-
)}
|
|
334
|
+
<Tabs.TabPrimitive value='options' asChild role='button'>
|
|
335
|
+
<DropdownMenu.Trigger
|
|
336
|
+
data-testid='spacePlugin.addSpace'
|
|
337
|
+
className={mx(l0ItemRoot, 'grid place-items-center dx-focus-ring-group')}
|
|
344
338
|
>
|
|
345
|
-
<
|
|
346
|
-
|
|
347
|
-
|
|
339
|
+
<div
|
|
340
|
+
role='none'
|
|
341
|
+
className={mx(
|
|
342
|
+
l0ItemContent,
|
|
343
|
+
'is-[--rail-action] bs-[--rail-action] group-hover/l0item:bg-hoverSurface',
|
|
344
|
+
)}
|
|
345
|
+
>
|
|
346
|
+
<Icon icon='ph--list--regular' size={5} />
|
|
347
|
+
</div>
|
|
348
|
+
</DropdownMenu.Trigger>
|
|
349
|
+
</Tabs.TabPrimitive>
|
|
348
350
|
</Tooltip.Trigger>
|
|
349
351
|
</DropdownMenu.Root>
|
|
350
352
|
</MenuProvider>
|
|
@@ -396,7 +398,6 @@ export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountIte
|
|
|
396
398
|
</L0ItemRoot>
|
|
397
399
|
</div>
|
|
398
400
|
)}
|
|
399
|
-
|
|
400
401
|
<div
|
|
401
402
|
role='none'
|
|
402
403
|
className='hidden [body[data-platform="darwin"]_&]:block absolute block-start-0 is-[calc(var(--l0-size)-1px)] bs-[calc(40px+0.25rem)]'
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import React, { useCallback, useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Node } from '@dxos/app-graph';
|
|
8
|
-
import { IconButton, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
8
|
+
import { DensityProvider, 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
11
|
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/react-ui-theme';
|
|
@@ -28,11 +28,10 @@ export type L1PanelProps = {
|
|
|
28
28
|
export const L1Panel = ({ open, path, item, currentItemId, onBack }: L1PanelProps) => {
|
|
29
29
|
const { t } = useTranslation(meta.id);
|
|
30
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
31
|
const title = toLocalizedString(item.properties.label, t);
|
|
34
32
|
|
|
35
33
|
// TODO(wittjosiah): Support multiple alternate trees.
|
|
34
|
+
const { useItems } = navTreeContext;
|
|
36
35
|
const alternateTree = useItems(item, { disposition: 'alternate-tree' })[0];
|
|
37
36
|
const alternatePath = useMemo(() => [...path, item.id], [item.id, path]);
|
|
38
37
|
const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
|
|
@@ -56,22 +55,22 @@ export const L1Panel = ({ open, path, item, currentItemId, onBack }: L1PanelProp
|
|
|
56
55
|
]}
|
|
57
56
|
tabIndex={-1}
|
|
58
57
|
aria-label={title}
|
|
59
|
-
{...(!open && { inert:
|
|
58
|
+
{...(!open && { inert: true })}
|
|
60
59
|
>
|
|
61
60
|
{item.id === currentItemId && (
|
|
62
|
-
|
|
61
|
+
<DensityProvider density='fine'>
|
|
63
62
|
<L1PanelHeader path={path} item={item} currentItemId={currentItemId} onBack={onBack} />
|
|
64
63
|
<div role='none' className='overflow-y-auto'>
|
|
65
64
|
{isAlternate ? (
|
|
66
65
|
<Tree
|
|
67
66
|
{...navTreeContext}
|
|
68
|
-
useItems={useAlternateItems}
|
|
69
67
|
id={alternateTree.id}
|
|
70
68
|
root={alternateTree}
|
|
71
69
|
path={alternatePath}
|
|
72
70
|
levelOffset={5}
|
|
73
71
|
gridTemplateColumns='[tree-row-start] 1fr min-content min-content min-content [tree-row-end]'
|
|
74
72
|
renderColumns={NavTreeItemColumns}
|
|
73
|
+
useItems={useAlternateItems}
|
|
75
74
|
/>
|
|
76
75
|
) : (
|
|
77
76
|
<Tree
|
|
@@ -80,13 +79,13 @@ export const L1Panel = ({ open, path, item, currentItemId, onBack }: L1PanelProp
|
|
|
80
79
|
root={item}
|
|
81
80
|
path={path}
|
|
82
81
|
levelOffset={5}
|
|
83
|
-
draggable
|
|
84
82
|
gridTemplateColumns='[tree-row-start] 1fr min-content min-content min-content [tree-row-end]'
|
|
85
83
|
renderColumns={NavTreeItemColumns}
|
|
84
|
+
draggable
|
|
86
85
|
/>
|
|
87
86
|
)}
|
|
88
87
|
</div>
|
|
89
|
-
|
|
88
|
+
</DensityProvider>
|
|
90
89
|
)}
|
|
91
90
|
</Tabs.Tabpanel>
|
|
92
91
|
);
|
|
@@ -2,18 +2,17 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@dxos-theme';
|
|
6
|
-
|
|
7
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
8
6
|
|
|
9
|
-
import { withTheme } from '@dxos/
|
|
7
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
10
8
|
|
|
11
9
|
import { UserAccountAvatar } from './UserAccountAvatar';
|
|
12
10
|
|
|
13
11
|
const meta = {
|
|
14
12
|
title: 'plugins/plugin-navtree/UserAccountAvatar',
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
decorators: [withTheme],
|
|
15
|
+
component: UserAccountAvatar,
|
|
17
16
|
} satisfies Meta<typeof UserAccountAvatar>;
|
|
18
17
|
|
|
19
18
|
export default meta;
|
|
@@ -7,6 +7,8 @@ import React from 'react';
|
|
|
7
7
|
import { Avatar, type AvatarStatus, type Size } from '@dxos/react-ui';
|
|
8
8
|
import { hexToFallback } from '@dxos/util';
|
|
9
9
|
|
|
10
|
+
import { L0ItemActiveTabIndicator } from '../Sidebar';
|
|
11
|
+
|
|
10
12
|
export type UserAccountAvatarProps = {
|
|
11
13
|
size?: Size;
|
|
12
14
|
userId?: string;
|
|
@@ -19,17 +21,23 @@ export const UserAccountAvatar = ({ size, userId, hue, emoji, status }: UserAcco
|
|
|
19
21
|
const fallbackValue = hexToFallback(userId ?? '0');
|
|
20
22
|
|
|
21
23
|
return (
|
|
22
|
-
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
24
|
+
<>
|
|
25
|
+
<L0ItemActiveTabIndicator classNames='inset-block-6' />
|
|
26
|
+
<div
|
|
27
|
+
className='grid place-items-center dx-focus-ring-group-indicator rounded-full'
|
|
28
|
+
data-joyride='welcome/account'
|
|
29
|
+
>
|
|
30
|
+
<Avatar.Root>
|
|
31
|
+
<Avatar.Content
|
|
32
|
+
variant='circle'
|
|
33
|
+
size={size ?? 12}
|
|
34
|
+
status={status ?? 'active'}
|
|
35
|
+
hue={hue || fallbackValue.hue}
|
|
36
|
+
fallback={emoji || fallbackValue.emoji}
|
|
37
|
+
data-testid='treeView.userAccount'
|
|
38
|
+
/>
|
|
39
|
+
</Avatar.Root>
|
|
40
|
+
</div>
|
|
41
|
+
</>
|
|
34
42
|
);
|
|
35
43
|
};
|
package/src/events.ts
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
import { Events } from '@dxos/app-framework';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { meta } from './meta';
|
|
8
8
|
|
|
9
9
|
export namespace NavTreeEvents {
|
|
10
|
-
export const StateReady = Events.createStateEvent(
|
|
10
|
+
export const StateReady = Events.createStateEvent(meta.id);
|
|
11
11
|
}
|
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
6
|
-
|
|
7
|
-
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
5
|
+
import { type Meta } from '@storybook/react-vite';
|
|
8
6
|
import React, { type JSX, type PropsWithChildren, useEffect, useState } from 'react';
|
|
9
7
|
|
|
10
8
|
import { faker } from '@dxos/random';
|
|
11
9
|
import { Icon, IconButton } from '@dxos/react-ui';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
import { mx } from '@dxos/react-ui-theme';
|
|
14
12
|
|
|
15
13
|
import { type ItemMap, Tree, type TreeNodeData, type TreeProps, visitNodes, visitor } from './Tree';
|
|
16
14
|
|
|
@@ -105,27 +103,6 @@ const data: TreeNodeData[] = [
|
|
|
105
103
|
},
|
|
106
104
|
];
|
|
107
105
|
|
|
108
|
-
export const Default = () => {
|
|
109
|
-
return <Container sidebar={<Sidebar mutate />} />;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
export const Visitor = () => {
|
|
113
|
-
const [items] = useState(data);
|
|
114
|
-
const root = items[0];
|
|
115
|
-
const [openItems] = useState<ItemMap>({ [root.children![0].id]: true });
|
|
116
|
-
return (
|
|
117
|
-
<div className='flex flex-col'>
|
|
118
|
-
{Array.from(visitor(root, openItems)).map(({ node: { id, title }, depth }) => (
|
|
119
|
-
<div key={id} className='grid grid-cols-[40px_400px_400px] font-mono'>
|
|
120
|
-
<div>{depth}</div>
|
|
121
|
-
<div>{id}</div>
|
|
122
|
-
<div>{title}</div>
|
|
123
|
-
</div>
|
|
124
|
-
))}
|
|
125
|
-
</div>
|
|
126
|
-
);
|
|
127
|
-
};
|
|
128
|
-
|
|
129
106
|
const Sidebar = ({ mutate }: { mutate?: boolean }) => {
|
|
130
107
|
const [items, setItems] = useState(data);
|
|
131
108
|
const root = items[0];
|
|
@@ -226,9 +203,28 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
|
|
|
226
203
|
const meta = {
|
|
227
204
|
title: 'plugins/plugin-navtree/experimental/Tree',
|
|
228
205
|
component: Tree,
|
|
229
|
-
decorators: [withTheme, withLayout({
|
|
206
|
+
decorators: [withTheme, withLayout({ container: 'column' })],
|
|
230
207
|
} satisfies Meta<typeof Tree>;
|
|
231
208
|
|
|
232
209
|
export default meta;
|
|
233
210
|
|
|
234
|
-
|
|
211
|
+
export const Default = () => {
|
|
212
|
+
return <Container sidebar={<Sidebar mutate />} />;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export const Visitor = () => {
|
|
216
|
+
const [items] = useState(data);
|
|
217
|
+
const root = items[0];
|
|
218
|
+
const [openItems] = useState<ItemMap>({ [root.children![0].id]: true });
|
|
219
|
+
return (
|
|
220
|
+
<div className='flex flex-col'>
|
|
221
|
+
{Array.from(visitor(root, openItems)).map(({ node: { id, title }, depth }) => (
|
|
222
|
+
<div key={id} className='grid grid-cols-[40px_400px_400px] font-mono'>
|
|
223
|
+
<div>{depth}</div>
|
|
224
|
+
<div>{id}</div>
|
|
225
|
+
<div>{title}</div>
|
|
226
|
+
</div>
|
|
227
|
+
))}
|
|
228
|
+
</div>
|
|
229
|
+
);
|
|
230
|
+
};
|