@dxos/plugin-navtree 0.8.4-main.406dc2a → 0.8.4-main.52d7546f51
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-XGA4GPGL.mjs +44 -0
- package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs.map +7 -0
- package/dist/lib/browser/chunk-63YLDLLE.mjs +1373 -0
- package/dist/lib/browser/chunk-63YLDLLE.mjs.map +7 -0
- package/dist/lib/browser/chunk-X2HDG62A.mjs +23 -0
- package/dist/lib/browser/chunk-X2HDG62A.mjs.map +7 -0
- package/dist/lib/browser/chunk-YKTYPINZ.mjs +19 -0
- package/dist/lib/browser/chunk-YKTYPINZ.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +83 -91
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{keyboard-AHSAWKXA.mjs → keyboard-46XQHY2O.mjs} +21 -19
- package/dist/lib/browser/keyboard-46XQHY2O.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-NNNDII45.mjs +53 -0
- package/dist/lib/browser/operation-resolver-NNNDII45.mjs.map +7 -0
- package/dist/lib/browser/react-surface-APSEG23H.mjs +59 -0
- package/dist/lib/browser/react-surface-APSEG23H.mjs.map +7 -0
- package/dist/lib/browser/state-M5YUCIQU.mjs +121 -0
- package/dist/lib/browser/state-M5YUCIQU.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +2 -1
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
- package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -108
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard/index.d.ts +3 -0
- package/dist/types/src/capabilities/keyboard/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/keyboard/keyboard.d.ts +5 -0
- package/dist/types/src/capabilities/keyboard/keyboard.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +3 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +6 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +3 -2
- package/dist/types/src/components/CommandsDialog/CommandsDialog.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 +30 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +4 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContainer.d.ts +8 -1
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +6 -6
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +2 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +4 -4
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +2 -2
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +2 -2
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +7 -7
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +15 -4
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/hooks.d.ts +32 -1
- package/dist/types/src/hooks.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -2
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/testing/generator.d.ts +5 -6
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts +2 -2
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +16 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +5 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +4 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/src/{types.d.ts → types/schema.d.ts} +7 -7
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +7 -7
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +54 -52
- package/src/NavTreePlugin.tsx +53 -72
- package/src/capabilities/app-graph-builder/app-graph-builder.ts +42 -0
- package/src/capabilities/app-graph-builder/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/keyboard/index.ts +7 -0
- package/src/capabilities/keyboard/keyboard.ts +66 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +42 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +55 -0
- package/src/capabilities/state/index.ts +7 -0
- package/src/capabilities/state/state.ts +122 -0
- package/src/components/CommandsDialog/CommandsDialog.tsx +107 -97
- package/src/components/CommandsDialog/CommandsTrigger.tsx +4 -13
- package/src/components/NavTree/NavTree.stories.tsx +36 -44
- package/src/components/NavTree/NavTree.tsx +5 -15
- package/src/components/NavTreeContainer.tsx +255 -263
- package/src/components/NavTreeDocumentTitle.tsx +3 -2
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +17 -7
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +18 -12
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +5 -5
- package/src/components/Sidebar/L0Menu.tsx +69 -98
- package/src/components/Sidebar/L1Panel.tsx +151 -72
- package/src/components/Sidebar/L1Tabs.tsx +6 -31
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/types.ts +7 -7
- package/src/experimental/Tree.stories.tsx +45 -54
- package/src/experimental/Tree.tsx +3 -3
- package/src/hooks.ts +54 -2
- package/src/index.ts +1 -2
- package/src/meta.ts +7 -2
- package/src/testing/app-graph-builder.ts +159 -235
- package/src/testing/generator.ts +19 -17
- package/src/testing/update-state.ts +6 -6
- package/src/types/capabilities.ts +21 -0
- package/src/types/events.ts +12 -0
- package/src/types/index.ts +7 -0
- package/src/{types.ts → types/schema.ts} +6 -6
- package/src/util.ts +13 -16
- package/dist/lib/browser/app-graph-builder-YAPMENYT.mjs +0 -46
- package/dist/lib/browser/app-graph-builder-YAPMENYT.mjs.map +0 -7
- package/dist/lib/browser/chunk-IMFXKPSB.mjs +0 -1482
- package/dist/lib/browser/chunk-IMFXKPSB.mjs.map +0 -7
- package/dist/lib/browser/chunk-LPAREX6J.mjs +0 -15
- package/dist/lib/browser/chunk-LPAREX6J.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZENLR72O.mjs +0 -14
- package/dist/lib/browser/chunk-ZENLR72O.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-TCQXGF6U.mjs +0 -47
- package/dist/lib/browser/intent-resolver-TCQXGF6U.mjs.map +0 -7
- package/dist/lib/browser/keyboard-AHSAWKXA.mjs.map +0 -7
- package/dist/lib/browser/react-surface-AH2TP73M.mjs +0 -51
- package/dist/lib/browser/react-surface-AH2TP73M.mjs.map +0 -7
- package/dist/lib/browser/state-2Q623V7U.mjs +0 -117
- package/dist/lib/browser/state-2Q623V7U.mjs.map +0 -7
- package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -21
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/keyboard.d.ts +0 -4
- package/dist/types/src/capabilities/keyboard.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/state.d.ts +0 -20
- package/dist/types/src/capabilities/state.d.ts.map +0 -1
- package/dist/types/src/events.d.ts +0 -4
- package/dist/types/src/events.d.ts.map +0 -1
- package/dist/types/src/types.d.ts.map +0 -1
- package/src/capabilities/app-graph-builder.ts +0 -53
- package/src/capabilities/capabilities.ts +0 -20
- package/src/capabilities/intent-resolver.ts +0 -37
- package/src/capabilities/keyboard.ts +0 -59
- package/src/capabilities/react-surface.tsx +0 -45
- package/src/capabilities/state.ts +0 -105
- package/src/events.ts +0 -11
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
|
+
import { useActionRunner } from '@dxos/plugin-graph';
|
|
8
9
|
import { IconButton, toLocalizedString, useDensityContext, useTranslation } from '@dxos/react-ui';
|
|
9
10
|
import { DropdownMenu, type MenuItem, MenuProvider } from '@dxos/react-ui-menu';
|
|
10
|
-
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/
|
|
11
|
+
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/ui-theme';
|
|
11
12
|
|
|
12
13
|
import { meta } from '../../meta';
|
|
13
14
|
import { type ActionProperties } from '../../types';
|
|
14
15
|
|
|
15
16
|
export type NavTreeItemActionMenuProps = ActionProperties & {
|
|
16
|
-
parent: Node;
|
|
17
|
+
parent: Node.Node;
|
|
17
18
|
caller?: string;
|
|
18
19
|
monolithic?: boolean;
|
|
19
|
-
menuActions?: Action[];
|
|
20
|
+
menuActions?: Node.Action[];
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
const fallbackIcon = 'ph--placeholder--regular';
|
|
@@ -40,8 +41,10 @@ export const NavTreeItemActionDropdownMenu = ({
|
|
|
40
41
|
}: NavTreeItemActionMenuProps) => {
|
|
41
42
|
const { t } = useTranslation(meta.id);
|
|
42
43
|
const density = useDensityContext();
|
|
44
|
+
const runAction = useActionRunner();
|
|
45
|
+
|
|
43
46
|
return (
|
|
44
|
-
<MenuProvider>
|
|
47
|
+
<MenuProvider onAction={runAction}>
|
|
45
48
|
<DropdownMenu.Root group={parent} items={menuActions as MenuItem[]} caller={caller}>
|
|
46
49
|
<DropdownMenu.Trigger asChild>
|
|
47
50
|
<IconButton
|
|
@@ -59,13 +62,16 @@ export const NavTreeItemActionDropdownMenu = ({
|
|
|
59
62
|
);
|
|
60
63
|
};
|
|
61
64
|
|
|
62
|
-
export const NavTreeItemMonolithicAction = (
|
|
63
|
-
parent,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
export const NavTreeItemMonolithicAction = (
|
|
66
|
+
props: Node.Action & { parent: Node.Node; onAction?: (action: Node.Action) => void; baseLabel: string },
|
|
67
|
+
) => {
|
|
68
|
+
const {
|
|
69
|
+
parent,
|
|
70
|
+
properties: { disabled, caller, testId, icon, variant = 'ghost', iconOnly = true } = { label: 'never' },
|
|
71
|
+
baseLabel,
|
|
72
|
+
} = props;
|
|
68
73
|
const density = useDensityContext();
|
|
74
|
+
const runAction = useActionRunner();
|
|
69
75
|
return (
|
|
70
76
|
<IconButton
|
|
71
77
|
{...(density === 'coarse' ? coarseActionButtonProps : fineActionButtonProps)}
|
|
@@ -86,7 +92,7 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
86
92
|
return;
|
|
87
93
|
}
|
|
88
94
|
|
|
89
|
-
void
|
|
95
|
+
void runAction(props, caller ? { parent, caller } : { parent });
|
|
90
96
|
}}
|
|
91
97
|
data-testid={testId}
|
|
92
98
|
/>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { Fragment, memo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Node } from '@dxos/app-graph';
|
|
8
8
|
import { Popover, Treegrid, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
10
|
import { useLoadDescendents } from '../../hooks';
|
|
@@ -26,11 +26,11 @@ export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumns
|
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const actions = (primaryAction?.properties?.disposition === 'list-item-primary' ? secondaryActions : _actions)
|
|
29
|
-
.flatMap((action) => (isAction(action) ? [action] : []))
|
|
29
|
+
.flatMap((action) => (Node.isAction(action) ? [action] : []))
|
|
30
30
|
.filter((a) => ['list-item', 'list-item-primary'].includes(a.properties?.disposition));
|
|
31
31
|
|
|
32
32
|
useLoadDescendents(item);
|
|
33
|
-
useLoadDescendents(primaryAction && !isAction(primaryAction) ? primaryAction : undefined);
|
|
33
|
+
useLoadDescendents(primaryAction && !Node.isAction(primaryAction) ? (primaryAction as Node.Node) : undefined);
|
|
34
34
|
|
|
35
35
|
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
36
36
|
|
|
@@ -43,8 +43,8 @@ export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumns
|
|
|
43
43
|
label={toLocalizedString(primaryAction.properties?.label, t)}
|
|
44
44
|
icon={primaryAction.properties?.icon ?? 'ph--placeholder--regular'}
|
|
45
45
|
parent={item}
|
|
46
|
-
monolithic={isAction(primaryAction)}
|
|
47
|
-
menuActions={isAction(primaryAction) ? [primaryAction] : groupedActions[primaryAction
|
|
46
|
+
monolithic={Node.isAction(primaryAction)}
|
|
47
|
+
menuActions={Node.isAction(primaryAction) ? [primaryAction] : groupedActions[primaryAction?.id ?? '']}
|
|
48
48
|
menuType={primaryAction.properties?.menuType}
|
|
49
49
|
caller={NAV_TREE_ITEM}
|
|
50
50
|
/>
|
|
@@ -23,8 +23,8 @@ import React, {
|
|
|
23
23
|
} from 'react';
|
|
24
24
|
|
|
25
25
|
import { type Node } from '@dxos/app-graph';
|
|
26
|
-
import { invariant } from '@dxos/invariant';
|
|
27
26
|
import { DxAvatar } from '@dxos/lit-ui/react';
|
|
27
|
+
import { useActionRunner } from '@dxos/plugin-graph';
|
|
28
28
|
import {
|
|
29
29
|
Icon,
|
|
30
30
|
ListItem,
|
|
@@ -38,10 +38,10 @@ import {
|
|
|
38
38
|
import { DropdownMenu, type MenuItem, MenuProvider } from '@dxos/react-ui-menu';
|
|
39
39
|
import type { StackItemRearrangeHandler } from '@dxos/react-ui-stack';
|
|
40
40
|
import { Tabs } from '@dxos/react-ui-tabs';
|
|
41
|
-
import { mx } from '@dxos/
|
|
41
|
+
import { mx } from '@dxos/ui-theme';
|
|
42
42
|
import { arrayMove } from '@dxos/util';
|
|
43
43
|
|
|
44
|
-
import {
|
|
44
|
+
import { useNavTreeState } from '../../hooks';
|
|
45
45
|
import { meta } from '../../meta';
|
|
46
46
|
import { l0ItemType } from '../../util';
|
|
47
47
|
import { useNavTreeContext } from '../NavTreeContext';
|
|
@@ -57,43 +57,41 @@ type L0ItemData = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
type L0ItemRootProps = {
|
|
60
|
-
item: Node
|
|
61
|
-
parent?: Node
|
|
60
|
+
item: Node.Node;
|
|
61
|
+
parent?: Node.Node;
|
|
62
62
|
path: string[];
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
type L0ItemProps = L0ItemRootProps & {
|
|
66
|
-
item: Node
|
|
67
|
-
parent?: Node
|
|
66
|
+
item: Node.Node;
|
|
67
|
+
parent?: Node.Node;
|
|
68
68
|
path: string[];
|
|
69
69
|
pinned?: boolean;
|
|
70
70
|
onRearrange?: StackItemRearrangeHandler<L0ItemData>;
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
const useL0ItemClick = ({ item, parent, path }: L0ItemProps, type: string) => {
|
|
74
|
-
const { tab,
|
|
74
|
+
const { tab, onSelect, onTabChange } = useNavTreeContext();
|
|
75
|
+
const { getItem } = useNavTreeState();
|
|
75
76
|
const [isLg] = useMediaQuery('lg');
|
|
77
|
+
const runAction = useActionRunner();
|
|
76
78
|
|
|
77
79
|
return useCallback(
|
|
78
80
|
(event: MouseEvent) => {
|
|
79
81
|
switch (type) {
|
|
80
82
|
case 'action': {
|
|
81
|
-
const {
|
|
82
|
-
|
|
83
|
-
properties: { caller },
|
|
84
|
-
} = item;
|
|
85
|
-
|
|
86
|
-
return invoke?.(caller ? { node: parent, caller } : { node: parent });
|
|
83
|
+
const { properties: { caller } = {} } = item;
|
|
84
|
+
return void runAction(item as Node.Action, caller ? { parent, caller } : { parent });
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
case 'tab':
|
|
90
88
|
return onTabChange?.(item);
|
|
91
89
|
|
|
92
90
|
case 'link':
|
|
93
|
-
return onSelect?.({ item, path, current: !
|
|
91
|
+
return onSelect?.({ item, path, current: !getItem(path).current, option: event.altKey });
|
|
94
92
|
}
|
|
95
93
|
},
|
|
96
|
-
[item, parent, type, tab,
|
|
94
|
+
[item, parent, type, tab, getItem, onSelect, onTabChange, isLg, runAction],
|
|
97
95
|
);
|
|
98
96
|
};
|
|
99
97
|
|
|
@@ -102,7 +100,7 @@ const l0Breakpoints: Record<string, string> = {
|
|
|
102
100
|
};
|
|
103
101
|
|
|
104
102
|
const l0ItemRoot =
|
|
105
|
-
'group/l0item flex
|
|
103
|
+
'group/l0item flex is-full justify-center items-center relative data[type!="collection"]:cursor-pointer app-no-drag dx-focus-ring-group';
|
|
106
104
|
|
|
107
105
|
const l0ItemContent = 'flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded-sm';
|
|
108
106
|
|
|
@@ -119,10 +117,8 @@ const L0ItemRoot = forwardRef<HTMLElement, PropsWithChildren<L0ItemRootProps>>(
|
|
|
119
117
|
const handleClick = useL0ItemClick({ item, parent, path: itemPath }, type);
|
|
120
118
|
const rootProps =
|
|
121
119
|
type === 'tab'
|
|
122
|
-
? { value: item.id, tabIndex: 0, onClick: handleClick, 'data-testid': testId, 'data-
|
|
123
|
-
:
|
|
124
|
-
? { onClick: handleClick, 'data-testid': testId, 'data-itemid': id }
|
|
125
|
-
: { onClick: handleClick, role: 'button' };
|
|
120
|
+
? { value: item.id, tabIndex: 0, onClick: handleClick, 'data-testid': testId, 'data-object-id': id }
|
|
121
|
+
: { onClick: handleClick, 'data-testid': testId, 'data-object-id': id };
|
|
126
122
|
|
|
127
123
|
return (
|
|
128
124
|
<Tooltip.Trigger asChild delayDuration={0} side='right' content={localizedString}>
|
|
@@ -256,68 +252,50 @@ const ItemAvatar = ({ item }: Pick<L0ItemProps, 'item'>) => {
|
|
|
256
252
|
};
|
|
257
253
|
|
|
258
254
|
//
|
|
259
|
-
//
|
|
255
|
+
// L0Menu
|
|
260
256
|
//
|
|
261
257
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
258
|
+
export type L0MenuProps = {
|
|
259
|
+
menuActions: MenuItem[];
|
|
260
|
+
topLevelItems: Node.Node[];
|
|
261
|
+
pinnedItems: Node.Node[];
|
|
262
|
+
userAccountItem?: Node.Node;
|
|
263
|
+
parent?: Node.Node;
|
|
264
|
+
path: string[];
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }: L0MenuProps) => {
|
|
268
|
+
const { t } = useTranslation(meta.id);
|
|
269
|
+
const runAction = useActionRunner();
|
|
270
|
+
const handleAction = useCallback(
|
|
271
|
+
(action: Node.Action, params: Node.InvokeProps) => {
|
|
272
|
+
void runAction(action, params);
|
|
273
|
+
},
|
|
274
|
+
[runAction],
|
|
275
|
+
);
|
|
268
276
|
|
|
269
277
|
const handleRearrange = useCallback<StackItemRearrangeHandler<L0ItemData>>(
|
|
270
278
|
(source, target, closestEdge) => {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
279
|
+
const sourceItem = topLevelItems.find((i) => i.id === source.id);
|
|
280
|
+
if (!sourceItem?.properties.onRearrange) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const sourceIndex = topLevelItems.findIndex((i) => i.id === source.id);
|
|
285
|
+
const targetIndex = topLevelItems.findIndex((i) => i.id === target.id);
|
|
274
286
|
const insertIndex =
|
|
275
287
|
source.id === target.id
|
|
276
288
|
? sourceIndex
|
|
277
289
|
: targetIndex +
|
|
278
290
|
(sourceIndex < targetIndex ? (closestEdge === 'top' ? -1 : 0) : closestEdge === 'bottom' ? 1 : 0);
|
|
279
|
-
const nextOrder = arrayMove([...
|
|
280
|
-
return
|
|
291
|
+
const nextOrder = arrayMove([...topLevelItems], sourceIndex, insertIndex);
|
|
292
|
+
return sourceItem.properties.onRearrange(nextOrder.map((item) => item.data));
|
|
281
293
|
},
|
|
282
|
-
[
|
|
294
|
+
[topLevelItems],
|
|
283
295
|
);
|
|
284
296
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
role='group'
|
|
288
|
-
className='contents group/l0c'
|
|
289
|
-
aria-labelledby={`${item.id}__label`}
|
|
290
|
-
data-itemid={id}
|
|
291
|
-
data-testid={testId}
|
|
292
|
-
>
|
|
293
|
-
{collectionItems.map((collectionItem) => (
|
|
294
|
-
<L0Item
|
|
295
|
-
key={collectionItem.id}
|
|
296
|
-
item={collectionItem}
|
|
297
|
-
parent={item}
|
|
298
|
-
path={groupPath}
|
|
299
|
-
{...(item.properties.onRearrangeChildren && { onRearrange: handleRearrange })}
|
|
300
|
-
/>
|
|
301
|
-
))}
|
|
302
|
-
</div>
|
|
303
|
-
);
|
|
304
|
-
};
|
|
305
|
-
|
|
306
|
-
//
|
|
307
|
-
// L0Menu
|
|
308
|
-
//
|
|
309
|
-
|
|
310
|
-
export type L0MenuProps = {
|
|
311
|
-
menuActions: MenuItem[];
|
|
312
|
-
topLevelItems: Node<any>[];
|
|
313
|
-
pinnedItems: Node<any>[];
|
|
314
|
-
userAccountItem?: Node<any>;
|
|
315
|
-
parent?: Node<any>;
|
|
316
|
-
path: string[];
|
|
317
|
-
};
|
|
318
|
-
|
|
319
|
-
export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }: L0MenuProps) => {
|
|
320
|
-
const { t } = useTranslation(meta.id);
|
|
297
|
+
// Check if any items have onRearrange to enable drag-and-drop.
|
|
298
|
+
const hasRearrangeableItems = topLevelItems.some((item) => item.properties.onRearrange);
|
|
321
299
|
|
|
322
300
|
return (
|
|
323
301
|
<Tabs.Tablist
|
|
@@ -328,19 +306,23 @@ export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountIte
|
|
|
328
306
|
]}
|
|
329
307
|
>
|
|
330
308
|
{/* TODO(wittjosiah): Use L0Item trigger. */}
|
|
331
|
-
<MenuProvider>
|
|
309
|
+
<MenuProvider onAction={handleAction}>
|
|
332
310
|
<DropdownMenu.Root group={parent} items={menuActions}>
|
|
333
311
|
<Tooltip.Trigger content={t('app menu label')} side='right' asChild>
|
|
334
312
|
<Tabs.TabPrimitive value='options' asChild role='button'>
|
|
335
313
|
<DropdownMenu.Trigger
|
|
336
314
|
data-testid='spacePlugin.addSpace'
|
|
337
|
-
className={mx(
|
|
315
|
+
className={mx(
|
|
316
|
+
l0ItemRoot,
|
|
317
|
+
'grid place-items-center dx-focus-ring-group',
|
|
318
|
+
'[body[data-platform="macos"]_&]:mt-[30px]',
|
|
319
|
+
)}
|
|
338
320
|
>
|
|
339
321
|
<div
|
|
340
322
|
role='none'
|
|
341
323
|
className={mx(
|
|
342
324
|
l0ItemContent,
|
|
343
|
-
'
|
|
325
|
+
'bs-[--rail-action] is-[--rail-action] group-hover/l0item:bg-hoverSurface',
|
|
344
326
|
)}
|
|
345
327
|
>
|
|
346
328
|
<Icon icon='ph--list--regular' size={5} />
|
|
@@ -352,37 +334,34 @@ export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountIte
|
|
|
352
334
|
</MenuProvider>
|
|
353
335
|
|
|
354
336
|
{/* Space list. */}
|
|
355
|
-
<ScrollArea.Root>
|
|
337
|
+
<ScrollArea.Root thin orientation='vertical'>
|
|
356
338
|
<ScrollArea.Viewport>
|
|
357
339
|
<div
|
|
358
340
|
role='none'
|
|
359
341
|
className={mx([
|
|
360
342
|
'flex flex-col gap-1 pbs-1',
|
|
361
|
-
'[body[data-platform="
|
|
343
|
+
'[body[data-platform="macos"]_&]:pbs-[30px]',
|
|
362
344
|
'[body[data-platform="ios"]_&]:pbs-[max(env(safe-area-inset-top),0.25rem)]',
|
|
363
345
|
])}
|
|
364
346
|
>
|
|
365
|
-
{topLevelItems.map((item) =>
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
347
|
+
{topLevelItems.map((item) => (
|
|
348
|
+
<L0Item
|
|
349
|
+
key={item.id}
|
|
350
|
+
item={item}
|
|
351
|
+
parent={parent}
|
|
352
|
+
path={path}
|
|
353
|
+
{...(hasRearrangeableItems && { onRearrange: handleRearrange })}
|
|
354
|
+
/>
|
|
355
|
+
))}
|
|
372
356
|
</div>
|
|
373
|
-
<ScrollArea.Scrollbar orientation='vertical'>
|
|
374
|
-
<ScrollArea.Thumb />
|
|
375
|
-
</ScrollArea.Scrollbar>
|
|
376
357
|
</ScrollArea.Viewport>
|
|
377
358
|
</ScrollArea.Root>
|
|
378
359
|
|
|
379
360
|
{/* Actions. */}
|
|
380
361
|
<div role='none' className='grid grid-cols-1 auto-rows-[--rail-action] pbs-2'>
|
|
381
|
-
{pinnedItems
|
|
382
|
-
.
|
|
383
|
-
|
|
384
|
-
<L0Item key={item.id} item={item} parent={parent} path={path} pinned />
|
|
385
|
-
))}
|
|
362
|
+
{pinnedItems.map((item) => (
|
|
363
|
+
<L0Item key={item.id} item={item} parent={parent} path={path} pinned />
|
|
364
|
+
))}
|
|
386
365
|
</div>
|
|
387
366
|
|
|
388
367
|
{userAccountItem && (
|
|
@@ -398,14 +377,6 @@ export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountIte
|
|
|
398
377
|
</L0ItemRoot>
|
|
399
378
|
</div>
|
|
400
379
|
)}
|
|
401
|
-
<div
|
|
402
|
-
role='none'
|
|
403
|
-
className='hidden [body[data-platform="darwin"]_&]:block absolute block-start-0 is-[calc(var(--l0-size)-1px)] bs-[calc(40px+0.25rem)]'
|
|
404
|
-
style={{
|
|
405
|
-
background:
|
|
406
|
-
'linear-gradient(to bottom, var(--dx-sidebarSurface) 0%, var(--dx-sidebarSurface) 70%, transparent 100%)',
|
|
407
|
-
}}
|
|
408
|
-
/>
|
|
409
380
|
</Tabs.Tablist>
|
|
410
381
|
);
|
|
411
382
|
};
|