@dxos/plugin-navtree 0.8.3-staging.0fa589b → 0.8.4-main.1068cf700f
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 +89 -100
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/{keyboard-DDFATRUG.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 -105
- 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 +32 -3
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +29 -4
- 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 +33 -4
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +2 -2
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +6 -4
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +6 -7
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts +12 -0
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.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/index.d.ts +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +8 -8
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts +4 -5
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts +23 -6
- 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 +3 -4
- 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/translations.d.ts +14 -13
- package/dist/types/src/translations.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} +10 -9
- package/dist/types/src/types/schema.d.ts.map +1 -0
- package/dist/types/src/util.d.ts +8 -9
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +56 -55
- package/src/NavTreePlugin.tsx +64 -84
- 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 +108 -98
- package/src/components/CommandsDialog/CommandsTrigger.tsx +8 -19
- package/src/components/NavTree/NavTree.stories.tsx +100 -94
- package/src/components/NavTree/NavTree.tsx +12 -18
- package/src/components/NavTreeContainer.tsx +283 -259
- package/src/components/NavTreeDocumentTitle.tsx +5 -4
- package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +21 -13
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +28 -21
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +38 -32
- package/src/components/Sidebar/L0Menu.tsx +115 -143
- package/src/components/Sidebar/L1Panel.tsx +177 -122
- package/src/components/Sidebar/L1Tabs.tsx +33 -0
- package/src/components/Sidebar/index.ts +1 -0
- package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -8
- package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
- package/src/components/index.ts +2 -1
- package/src/components/types.ts +9 -8
- package/src/experimental/Tree.stories.tsx +77 -85
- package/src/experimental/Tree.tsx +17 -35
- package/src/hooks.ts +54 -2
- package/src/index.ts +1 -2
- package/src/meta.ts +11 -8
- package/src/testing/app-graph-builder.ts +159 -234
- package/src/testing/generator.ts +20 -18
- package/src/testing/update-state.ts +6 -6
- package/src/translations.ts +7 -4
- 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} +9 -8
- package/src/util.ts +14 -35
- package/dist/lib/browser/app-graph-builder-P7AY3K72.mjs +0 -45
- package/dist/lib/browser/app-graph-builder-P7AY3K72.mjs.map +0 -7
- package/dist/lib/browser/chunk-33VLL4IJ.mjs +0 -15
- package/dist/lib/browser/chunk-33VLL4IJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-IEW3JD5C.mjs +0 -16
- package/dist/lib/browser/chunk-IEW3JD5C.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZJPL4XJD.mjs +0 -1429
- package/dist/lib/browser/chunk-ZJPL4XJD.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-NAYKKAOP.mjs +0 -47
- package/dist/lib/browser/intent-resolver-NAYKKAOP.mjs.map +0 -7
- package/dist/lib/browser/keyboard-DDFATRUG.mjs.map +0 -7
- package/dist/lib/browser/react-surface-H3JRTVNU.mjs +0 -51
- package/dist/lib/browser/react-surface-H3JRTVNU.mjs.map +0 -7
- package/dist/lib/browser/state-J6AKZRB4.mjs +0 -117
- package/dist/lib/browser/state-J6AKZRB4.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 -52
- 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 -104
- package/src/events.ts +0 -11
|
@@ -2,13 +2,15 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import '@
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { type
|
|
8
|
+
import { RuntimePlugin } from '@dxos/app-framework';
|
|
9
|
+
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { type Node } from '@dxos/app-graph';
|
|
11
|
+
import { corePlugins } from '@dxos/plugin-testing';
|
|
10
12
|
import { faker } from '@dxos/random';
|
|
11
|
-
import {
|
|
13
|
+
import { withTheme } from '@dxos/react-ui/testing';
|
|
12
14
|
|
|
13
15
|
import { NavTreeItemAction, type NavTreeItemActionMenuProps } from './NavTreeItemAction';
|
|
14
16
|
|
|
@@ -20,7 +22,7 @@ const parent = {
|
|
|
20
22
|
label: faker.lorem.words(2),
|
|
21
23
|
icon: 'ph--circle--regular',
|
|
22
24
|
},
|
|
23
|
-
} satisfies NodeArg<any>;
|
|
25
|
+
} satisfies Node.NodeArg<any>;
|
|
24
26
|
|
|
25
27
|
// TODO(burdon): Factor out across tests.
|
|
26
28
|
const menuActions = faker.helpers.multiple(
|
|
@@ -28,31 +30,37 @@ const menuActions = faker.helpers.multiple(
|
|
|
28
30
|
({
|
|
29
31
|
id: faker.string.uuid(),
|
|
30
32
|
type: 'action',
|
|
31
|
-
data: () =>
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
data: () =>
|
|
34
|
+
Effect.sync(() => {
|
|
35
|
+
console.log('invoke');
|
|
36
|
+
}),
|
|
34
37
|
properties: {
|
|
35
38
|
label: faker.lorem.words(2),
|
|
36
39
|
icon: 'ph--circle--regular',
|
|
37
40
|
},
|
|
38
|
-
}) satisfies NodeArg<any>,
|
|
41
|
+
}) satisfies Node.NodeArg<any>,
|
|
39
42
|
{ count: 20 },
|
|
40
43
|
);
|
|
41
44
|
|
|
42
|
-
const meta
|
|
45
|
+
const meta = {
|
|
43
46
|
title: 'plugins/plugin-navtree/NavTreeItemAction',
|
|
44
47
|
component: NavTreeItemAction,
|
|
45
|
-
decorators: [withTheme, withLayout()],
|
|
46
48
|
args: {
|
|
47
49
|
icon: 'ph--list--regular',
|
|
48
50
|
parent,
|
|
49
51
|
menuActions,
|
|
50
52
|
label: 'Select action',
|
|
51
53
|
} satisfies Partial<NavTreeItemActionMenuProps>,
|
|
54
|
+
decorators: [
|
|
55
|
+
withTheme(),
|
|
56
|
+
withPluginManager({
|
|
57
|
+
plugins: [...corePlugins(), RuntimePlugin()],
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
52
60
|
parameters: {
|
|
53
61
|
layout: 'centered',
|
|
54
62
|
},
|
|
55
|
-
}
|
|
63
|
+
} satisfies Meta<typeof NavTreeItemAction>;
|
|
56
64
|
|
|
57
65
|
export default meta;
|
|
58
66
|
|
|
@@ -4,19 +4,20 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
7
|
+
import { type Node } from '@dxos/app-graph';
|
|
8
|
+
import { useActionRunner } from '@dxos/plugin-graph';
|
|
9
|
+
import { IconButton, toLocalizedString, useDensityContext, useTranslation } from '@dxos/react-ui';
|
|
10
|
+
import { DropdownMenu, type MenuItem, MenuProvider } from '@dxos/react-ui-menu';
|
|
11
|
+
import { hoverableControlItem, hoverableOpenControlItem } from '@dxos/ui-theme';
|
|
11
12
|
|
|
12
|
-
import {
|
|
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';
|
|
@@ -38,15 +39,17 @@ export const NavTreeItemActionDropdownMenu = ({
|
|
|
38
39
|
menuActions,
|
|
39
40
|
caller,
|
|
40
41
|
}: NavTreeItemActionMenuProps) => {
|
|
41
|
-
const { t } = useTranslation(
|
|
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
|
|
48
51
|
{...(density === 'coarse' ? coarseActionButtonProps : fineActionButtonProps)}
|
|
49
|
-
classNames={
|
|
52
|
+
classNames={['shrink-0 pli-2 pointer-fine:pli-1', hoverableControlItem, hoverableOpenControlItem]}
|
|
50
53
|
variant='ghost'
|
|
51
54
|
icon={icon ?? fallbackIcon}
|
|
52
55
|
iconOnly
|
|
@@ -59,33 +62,37 @@ 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)}
|
|
72
78
|
variant={variant}
|
|
73
|
-
classNames={
|
|
79
|
+
classNames={[
|
|
74
80
|
'shrink-0',
|
|
75
81
|
hoverableControlItem,
|
|
76
82
|
hoverableOpenControlItem,
|
|
77
83
|
iconOnly ? 'pli-2 pointer-fine:pli-1' : 'p-2 pointer-fine:p-2 mie-1',
|
|
78
|
-
|
|
84
|
+
]}
|
|
79
85
|
icon={icon ?? fallbackIcon}
|
|
80
86
|
iconOnly={iconOnly}
|
|
81
87
|
label={baseLabel}
|
|
82
88
|
disabled={disabled}
|
|
83
89
|
onClick={(event) => {
|
|
90
|
+
event.stopPropagation();
|
|
84
91
|
if (disabled) {
|
|
85
92
|
return;
|
|
86
93
|
}
|
|
87
|
-
|
|
88
|
-
void
|
|
94
|
+
|
|
95
|
+
void runAction(props, caller ? { parent, caller } : { parent });
|
|
89
96
|
}}
|
|
90
97
|
data-testid={testId}
|
|
91
98
|
/>
|
|
@@ -93,7 +100,7 @@ export const NavTreeItemMonolithicAction = ({
|
|
|
93
100
|
};
|
|
94
101
|
|
|
95
102
|
export const NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }: NavTreeItemActionMenuProps) => {
|
|
96
|
-
const { t } = useTranslation(
|
|
103
|
+
const { t } = useTranslation(meta.id);
|
|
97
104
|
|
|
98
105
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
99
106
|
const baseLabel = toLocalizedString(monolithicAction ? monolithicAction.properties!.label : props.label, t);
|
|
@@ -4,55 +4,57 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { Fragment, memo } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { Node } from '@dxos/app-graph';
|
|
8
|
+
import { 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
|
-
import type
|
|
14
|
+
import { type NavTreeItemColumnsProps } from '../types';
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
19
|
-
const { getActions, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
16
|
+
import { NavTreeItemAction } from './NavTreeItemAction';
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
export const NavTreeItemColumns = memo(({ path, item, open }: NavTreeItemColumnsProps) => {
|
|
19
|
+
const { t } = useTranslation(meta.id);
|
|
20
|
+
const { useActions, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
22
21
|
|
|
23
|
-
const
|
|
24
|
-
const
|
|
22
|
+
const level = path.length - 2;
|
|
23
|
+
const { actions: _actions, groupedActions } = useActions(item);
|
|
24
|
+
const [primaryAction, ...secondaryActions] = _actions.toSorted((a, _b) =>
|
|
25
25
|
a.properties?.disposition === 'list-item-primary' ? -1 : 1,
|
|
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
|
-
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
33
|
-
|
|
34
32
|
useLoadDescendents(item);
|
|
35
|
-
useLoadDescendents(primaryAction && !isAction(primaryAction) ? primaryAction : undefined);
|
|
33
|
+
useLoadDescendents(primaryAction && !Node.isAction(primaryAction) ? (primaryAction as Node.Node) : undefined);
|
|
34
|
+
|
|
35
|
+
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
36
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)}
|
|
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
|
/>
|
|
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
|
});
|