@dxos/plugin-navtree 0.8.4-main.67995b8 → 0.8.4-main.a4bbb77
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-BCXDEDN7.mjs} +9 -9
- package/dist/lib/browser/app-graph-builder-BCXDEDN7.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WEMCSQI7.mjs → chunk-6AZKY5WZ.mjs} +125 -124
- package/dist/lib/browser/chunk-6AZKY5WZ.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 +6 -10
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-3XYN2CBU.mjs → intent-resolver-G6COWRWW.mjs} +6 -6
- package/dist/lib/browser/{intent-resolver-3XYN2CBU.mjs.map → intent-resolver-G6COWRWW.mjs.map} +3 -3
- package/dist/lib/browser/{keyboard-QRS6WOQH.mjs → keyboard-AHSAWKXA.mjs} +4 -4
- package/dist/lib/browser/{keyboard-QRS6WOQH.mjs.map → keyboard-AHSAWKXA.mjs.map} +2 -2
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-JSJ5SQX5.mjs → react-surface-FOCB4Y5R.mjs} +10 -10
- package/dist/lib/browser/react-surface-FOCB4Y5R.mjs.map +7 -0
- package/dist/lib/browser/{state-54DY3DOY.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 +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 +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.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +26 -3
- 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 -4
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +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/L1Tabs.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 +8 -5
- 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/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 +10 -4
- 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/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 +50 -49
- package/src/NavTreePlugin.tsx +75 -76
- package/src/capabilities/app-graph-builder.ts +5 -5
- package/src/capabilities/capabilities.ts +2 -2
- package/src/capabilities/intent-resolver.ts +1 -1
- package/src/capabilities/keyboard.ts +2 -2
- package/src/capabilities/react-surface.tsx +5 -5
- package/src/capabilities/state.ts +4 -3
- package/src/components/CommandsDialog/CommandsDialog.tsx +5 -5
- package/src/components/CommandsDialog/CommandsTrigger.tsx +3 -3
- package/src/components/NavTree/NavTree.stories.tsx +21 -18
- package/src/components/NavTree/NavTree.tsx +4 -0
- package/src/components/NavTreeContainer.tsx +41 -15
- package/src/components/NavTreeDocumentTitle.tsx +2 -2
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +4 -6
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +5 -5
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +7 -6
- package/src/components/Sidebar/L0Menu.tsx +51 -50
- package/src/components/Sidebar/L1Panel.tsx +18 -20
- package/src/components/Sidebar/L1Tabs.tsx +1 -0
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -8
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
- package/src/components/types.ts +3 -2
- package/src/events.ts +2 -2
- package/src/experimental/Tree.stories.tsx +29 -28
- package/src/experimental/Tree.tsx +5 -22
- package/src/meta.ts +5 -7
- package/src/testing/app-graph-builder.ts +1 -1
- package/src/util.ts +2 -20
- package/dist/lib/browser/app-graph-builder-5J4LRWDX.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-WEMCSQI7.mjs.map +0 -7
- package/dist/lib/browser/react-surface-JSJ5SQX5.mjs.map +0 -7
- package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
|
@@ -3,34 +3,35 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { monitorForElements } from '@atlaskit/pragmatic-drag-and-drop/element/adapter';
|
|
6
|
-
import {
|
|
6
|
+
import { type Instruction, extractInstruction } from '@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item';
|
|
7
7
|
import { untracked } from '@preact/signals-core';
|
|
8
8
|
import React, { memo, useCallback, useEffect, useMemo } from 'react';
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
-
createIntent,
|
|
12
11
|
LayoutAction,
|
|
13
12
|
Surface,
|
|
13
|
+
createIntent,
|
|
14
14
|
useAppGraph,
|
|
15
15
|
useCapability,
|
|
16
16
|
useIntentDispatcher,
|
|
17
17
|
useLayout,
|
|
18
18
|
} from '@dxos/app-framework';
|
|
19
|
-
import {
|
|
19
|
+
import { type Node, ROOT_ID, type ReadableGraph, isAction, isActionLike } from '@dxos/app-graph';
|
|
20
20
|
import { PLANK_COMPANION_TYPE } from '@dxos/plugin-deck/types';
|
|
21
|
-
import { useConnections } from '@dxos/plugin-graph';
|
|
21
|
+
import { useConnections, useActions as useGraphActions } from '@dxos/plugin-graph';
|
|
22
22
|
import { useMediaQuery, useSidebars } from '@dxos/react-ui';
|
|
23
|
-
import {
|
|
23
|
+
import { type TreeData, type TreeItemDataProps, isTreeData } from '@dxos/react-ui-list';
|
|
24
24
|
import { mx } from '@dxos/react-ui-theme';
|
|
25
25
|
import { arrayMove, byPosition } from '@dxos/util';
|
|
26
26
|
|
|
27
|
+
import { NavTreeCapabilities } from '../capabilities';
|
|
28
|
+
import { meta } from '../meta';
|
|
29
|
+
import { type FlattenedActions, type NavTreeItemGraphNode } from '../types';
|
|
30
|
+
import { getChildren, getParent, resolveMigrationOperation } from '../util';
|
|
31
|
+
|
|
27
32
|
import { NAV_TREE_ITEM, NavTree } from './NavTree';
|
|
28
33
|
import { NavTreeContext } from './NavTreeContext';
|
|
29
34
|
import { type NavTreeContextValue } from './types';
|
|
30
|
-
import { NavTreeCapabilities } from '../capabilities';
|
|
31
|
-
import { NAVTREE_PLUGIN } from '../meta';
|
|
32
|
-
import { type NavTreeItemGraphNode } from '../types';
|
|
33
|
-
import { getChildren, getParent, getActions as naturalGetActions, resolveMigrationOperation } from '../util';
|
|
34
35
|
|
|
35
36
|
// TODO(thure): Is NavTree truly authoritative in this regard?
|
|
36
37
|
export const NODE_TYPE = 'dxos/app-graph/node';
|
|
@@ -40,7 +41,9 @@ const renderItemEnd = ({ node, open }: { node: Node; open: boolean }) => (
|
|
|
40
41
|
);
|
|
41
42
|
|
|
42
43
|
const getChildrenFilter = (node: Node): node is Node =>
|
|
43
|
-
untracked(
|
|
44
|
+
untracked(
|
|
45
|
+
() => !isActionLike(node) && node.type !== PLANK_COMPANION_TYPE && node.properties.disposition !== 'hidden',
|
|
46
|
+
);
|
|
44
47
|
|
|
45
48
|
const filterItems = (node: Node, disposition?: string) => {
|
|
46
49
|
if (!disposition && (node.properties.disposition === 'hidden' || node.properties.disposition === 'alternate-tree')) {
|
|
@@ -64,6 +67,31 @@ const useItems = (node?: Node, options?: { disposition?: string; sort?: boolean
|
|
|
64
67
|
return options?.sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
65
68
|
};
|
|
66
69
|
|
|
70
|
+
const useActions = (node: Node): FlattenedActions => {
|
|
71
|
+
const { graph } = useAppGraph();
|
|
72
|
+
const actions = useGraphActions(graph, node.id);
|
|
73
|
+
|
|
74
|
+
return useMemo(
|
|
75
|
+
() =>
|
|
76
|
+
actions.reduce(
|
|
77
|
+
(acc: FlattenedActions, arg) => {
|
|
78
|
+
if (arg.properties.disposition === 'item') {
|
|
79
|
+
return acc;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
acc.actions.push(arg);
|
|
83
|
+
if (!isAction(arg)) {
|
|
84
|
+
const actionGroup = graph.getActions(arg.id);
|
|
85
|
+
acc.groupedActions[arg.id] = actionGroup;
|
|
86
|
+
}
|
|
87
|
+
return acc;
|
|
88
|
+
},
|
|
89
|
+
{ actions: [], groupedActions: {} },
|
|
90
|
+
),
|
|
91
|
+
[actions],
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
|
|
67
95
|
export type NavTreeContainerProps = {
|
|
68
96
|
popoverAnchorId?: string;
|
|
69
97
|
topbar?: boolean;
|
|
@@ -75,9 +103,7 @@ export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeC
|
|
|
75
103
|
const { graph } = useAppGraph();
|
|
76
104
|
const { isOpen, isCurrent, isAlternateTree, setItem } = useCapability(NavTreeCapabilities.State);
|
|
77
105
|
const layout = useLayout();
|
|
78
|
-
const { navigationSidebarState } = useSidebars(
|
|
79
|
-
|
|
80
|
-
const getActions = useCallback((node: Node) => naturalGetActions(graph, node), [graph]);
|
|
106
|
+
const { navigationSidebarState } = useSidebars(meta.id);
|
|
81
107
|
|
|
82
108
|
const getProps = useCallback(
|
|
83
109
|
(node: Node, path: string[]): TreeItemDataProps => {
|
|
@@ -269,7 +295,7 @@ export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeC
|
|
|
269
295
|
() => ({
|
|
270
296
|
useItems,
|
|
271
297
|
tab,
|
|
272
|
-
|
|
298
|
+
useActions,
|
|
273
299
|
loadDescendents,
|
|
274
300
|
renderItemEnd,
|
|
275
301
|
popoverAnchorId,
|
|
@@ -287,7 +313,7 @@ export const NavTreeContainer = memo(({ tab, popoverAnchorId, topbar }: NavTreeC
|
|
|
287
313
|
}),
|
|
288
314
|
[
|
|
289
315
|
tab,
|
|
290
|
-
|
|
316
|
+
useActions,
|
|
291
317
|
loadDescendents,
|
|
292
318
|
renderItemEnd,
|
|
293
319
|
popoverAnchorId,
|
|
@@ -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
|
|
|
@@ -39,20 +37,20 @@ const menuActions = faker.helpers.multiple(
|
|
|
39
37
|
{ count: 20 },
|
|
40
38
|
);
|
|
41
39
|
|
|
42
|
-
const meta
|
|
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
|
},
|
|
55
|
-
}
|
|
53
|
+
} satisfies Meta<typeof NavTreeItemAction>;
|
|
56
54
|
|
|
57
55
|
export default meta;
|
|
58
56
|
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
import { type Action, type Node } from '@dxos/app-graph';
|
|
8
|
-
import {
|
|
9
|
-
import { DropdownMenu,
|
|
8
|
+
import { IconButton, toLocalizedString, useDensityContext, useTranslation } from '@dxos/react-ui';
|
|
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>
|
|
@@ -93,7 +93,7 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
93
93
|
};
|
|
94
94
|
|
|
95
95
|
export const NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }: NavTreeItemActionMenuProps) => {
|
|
96
|
-
const { t } = useTranslation(
|
|
96
|
+
const { t } = useTranslation(meta.id);
|
|
97
97
|
|
|
98
98
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
99
99
|
const baseLabel = toLocalizedString(monolithicAction ? monolithicAction.properties!.label : props.label, t);
|
|
@@ -5,21 +5,22 @@
|
|
|
5
5
|
import React, { Fragment, memo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { isAction } from '@dxos/app-graph';
|
|
8
|
-
import { DensityProvider, Popover,
|
|
8
|
+
import { DensityProvider, Popover, Treegrid, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
|
-
import { NavTreeItemAction } from './NavTreeItemAction';
|
|
11
10
|
import { useLoadDescendents } from '../../hooks';
|
|
12
|
-
import {
|
|
11
|
+
import { meta } from '../../meta';
|
|
13
12
|
import { NAV_TREE_ITEM } from '../NavTree';
|
|
14
13
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
15
14
|
import { type NavTreeItemColumnsProps } from '../types';
|
|
16
15
|
|
|
16
|
+
import { NavTreeItemAction } from './NavTreeItemAction';
|
|
17
|
+
|
|
17
18
|
export const NavTreeItemColumns = memo(({ path, item, open, density = 'fine' }: NavTreeItemColumnsProps) => {
|
|
18
|
-
const { t } = useTranslation(
|
|
19
|
-
const {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
|
+
const { useActions, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
20
21
|
|
|
21
22
|
const level = path.length - 2;
|
|
22
|
-
const { actions: _actions, groupedActions } =
|
|
23
|
+
const { actions: _actions, groupedActions } = useActions(item);
|
|
23
24
|
const [primaryAction, ...secondaryActions] = _actions.toSorted((a, _b) =>
|
|
24
25
|
a.properties?.disposition === 'list-item-primary' ? -1 : 1,
|
|
25
26
|
);
|
|
@@ -12,9 +12,9 @@ import {
|
|
|
12
12
|
extractClosestEdge,
|
|
13
13
|
} from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
|
|
14
14
|
import React, {
|
|
15
|
-
forwardRef,
|
|
16
15
|
type MouseEvent,
|
|
17
16
|
type PropsWithChildren,
|
|
17
|
+
forwardRef,
|
|
18
18
|
useCallback,
|
|
19
19
|
useLayoutEffect,
|
|
20
20
|
useMemo,
|
|
@@ -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 {
|
|
28
|
-
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';
|
|
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';
|
|
@@ -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)]'
|
|
@@ -56,7 +56,7 @@ export const L1Panel = ({ open, path, item, currentItemId, onBack }: L1PanelProp
|
|
|
56
56
|
]}
|
|
57
57
|
tabIndex={-1}
|
|
58
58
|
aria-label={title}
|
|
59
|
-
{...(!open && { inert:
|
|
59
|
+
{...(!open && { inert: true })}
|
|
60
60
|
>
|
|
61
61
|
{item.id === currentItemId && (
|
|
62
62
|
<>
|
|
@@ -123,31 +123,29 @@ const L1PanelHeader = ({ item, path, onBack }: L1PanelProps) => {
|
|
|
123
123
|
<div className='flex is-full items-center border-be border-subduedSeparator app-drag density-coarse'>
|
|
124
124
|
<div className='is-6' />
|
|
125
125
|
<h2 className='flex-1 truncate min-is-0'>{title}</h2>
|
|
126
|
-
|
|
127
|
-
|
|
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 && (
|
|
128
138
|
<IconButton
|
|
139
|
+
data-testid='treeView.alternateTreeButton'
|
|
129
140
|
variant='ghost'
|
|
130
|
-
icon='ph--
|
|
141
|
+
icon={alternateTree.properties.icon ?? 'ph--placeholder--regular'}
|
|
131
142
|
iconOnly
|
|
132
143
|
size={5}
|
|
133
|
-
label={
|
|
144
|
+
label={toLocalizedString(alternateTree.properties.label ?? alternateTree.id, t)}
|
|
134
145
|
classNames={[hoverableControlItem, hoverableOpenControlItem, 'pointer-fine:pli-1']}
|
|
135
|
-
onClick={
|
|
146
|
+
onClick={handleOpen}
|
|
136
147
|
/>
|
|
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>
|
|
148
|
+
))}
|
|
151
149
|
<NavTreeItemColumns open path={path} item={item} density='coarse' />
|
|
152
150
|
</div>
|
|
153
151
|
);
|
|
@@ -9,6 +9,7 @@ import { type Node } from '@dxos/app-graph';
|
|
|
9
9
|
import { useLoadDescendents } from '../../hooks';
|
|
10
10
|
import { l0ItemType } from '../../util';
|
|
11
11
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
12
|
+
|
|
12
13
|
import { L1Panel, type L1PanelProps } from './L1Panel';
|
|
13
14
|
|
|
14
15
|
export type L1TabsProps = Pick<L1PanelProps, 'open' | 'currentItemId' | 'onBack'> & {
|
|
@@ -2,20 +2,21 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { withTheme } from '@dxos/storybook-utils';
|
|
7
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
10
8
|
|
|
11
9
|
import { UserAccountAvatar } from './UserAccountAvatar';
|
|
12
10
|
|
|
13
|
-
const meta
|
|
11
|
+
const meta = {
|
|
14
12
|
title: 'plugins/plugin-navtree/UserAccountAvatar',
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
decorators: [withTheme],
|
|
17
|
-
|
|
15
|
+
component: UserAccountAvatar,
|
|
16
|
+
} satisfies Meta<typeof UserAccountAvatar>;
|
|
18
17
|
|
|
19
18
|
export default meta;
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
type Story = StoryObj<typeof meta>;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {};
|
|
@@ -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/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;
|
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
|
}
|