@dxos/plugin-navtree 0.7.4 → 0.7.5-feature-compute.4d9d99a
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-OF4MMBLH.mjs +42 -0
- package/dist/lib/browser/app-graph-builder-OF4MMBLH.mjs.map +7 -0
- package/dist/lib/browser/chunk-IMGT2LAL.mjs +658 -0
- package/dist/lib/browser/chunk-IMGT2LAL.mjs.map +7 -0
- package/dist/lib/browser/{chunk-PSVCPL4T.mjs → chunk-KOXMEAOS.mjs} +5 -3
- package/dist/lib/browser/chunk-KOXMEAOS.mjs.map +7 -0
- package/dist/lib/browser/chunk-OI7AAA6Q.mjs +15 -0
- package/dist/lib/browser/chunk-OI7AAA6Q.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +106 -1212
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/intent-resolver-74JPWYBP.mjs +42 -0
- package/dist/lib/browser/intent-resolver-74JPWYBP.mjs.map +7 -0
- package/dist/lib/browser/keyboard-MUBRTPI5.mjs +46 -0
- package/dist/lib/browser/keyboard-MUBRTPI5.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react-surface-6QWXI53A.mjs +189 -0
- package/dist/lib/browser/react-surface-6QWXI53A.mjs.map +7 -0
- package/dist/lib/browser/state-HT65TAYL.mjs +111 -0
- package/dist/lib/browser/state-HT65TAYL.mjs.map +7 -0
- package/dist/types/src/NavTreePlugin.d.ts +1 -3
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/capabilities.d.ts +17 -0
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +195 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/keyboard.d.ts +4 -0
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +4 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/state.d.ts +17 -0
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/components/CommandsTrigger.d.ts.map +1 -1
- package/dist/types/src/components/NavTree.d.ts +2 -2
- package/dist/types/src/components/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeFooter.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItemAction.d.ts +4 -8
- package/dist/types/src/components/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts +0 -5
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +1 -1
- package/dist/types/src/components/NotchStart.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/events.d.ts +4 -0
- package/dist/types/src/events.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +3 -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/translations.d.ts +0 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types.d.ts +1 -1
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +31 -38
- package/src/NavTreePlugin.tsx +70 -287
- package/src/capabilities/app-graph-builder.ts +40 -0
- package/src/capabilities/capabilities.ts +18 -0
- package/src/capabilities/index.ts +13 -0
- package/src/capabilities/intent-resolver.ts +30 -0
- package/src/capabilities/keyboard.ts +54 -0
- package/src/capabilities/react-surface.tsx +82 -0
- package/src/capabilities/state.ts +100 -0
- package/src/components/CommandsDialog.tsx +3 -3
- package/src/components/CommandsTrigger.tsx +11 -8
- package/src/components/NavTree.tsx +6 -11
- package/src/components/NavTreeContainer.tsx +22 -56
- package/src/components/NavTreeFooter.tsx +21 -18
- package/src/components/NavTreeItemAction.stories.tsx +0 -2
- package/src/components/NavTreeItemAction.tsx +51 -317
- package/src/components/NotchStart.tsx +8 -7
- package/src/components/index.ts +1 -0
- package/src/events.ts +11 -0
- package/src/index.ts +3 -4
- package/src/meta.ts +3 -1
- package/src/translations.ts +0 -1
- package/src/types.ts +1 -1
- package/dist/lib/browser/chunk-PSVCPL4T.mjs.map +0 -7
- package/dist/lib/browser/meta.mjs +0 -11
- package/dist/lib/browser/meta.mjs.map +0 -7
|
@@ -2,24 +2,12 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import React, { type MutableRefObject, type PropsWithChildren, useRef, useState } from 'react';
|
|
5
|
+
import React, { type MutableRefObject, useRef } from 'react';
|
|
7
6
|
|
|
8
|
-
import { type Action, type
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
Dialog,
|
|
13
|
-
DropdownMenu,
|
|
14
|
-
ContextMenu,
|
|
15
|
-
Tooltip,
|
|
16
|
-
useTranslation,
|
|
17
|
-
toLocalizedString,
|
|
18
|
-
Icon,
|
|
19
|
-
} from '@dxos/react-ui';
|
|
20
|
-
import { SearchList } from '@dxos/react-ui-searchlist';
|
|
21
|
-
import { descriptionText, hoverableControlItem, hoverableOpenControlItem, mx } from '@dxos/react-ui-theme';
|
|
22
|
-
import { getHostPlatform } from '@dxos/util';
|
|
7
|
+
import { type Action, type Node } from '@dxos/app-graph';
|
|
8
|
+
import { useTranslation, toLocalizedString, IconButton } from '@dxos/react-ui';
|
|
9
|
+
import { DropdownMenu, MenuProvider, type MenuItem } from '@dxos/react-ui-menu';
|
|
10
|
+
import { hoverableControlItem, hoverableOpenControlItem, mx } from '@dxos/react-ui-theme';
|
|
23
11
|
|
|
24
12
|
import { NAVTREE_PLUGIN } from '../meta';
|
|
25
13
|
import { type ActionProperties } from '../types';
|
|
@@ -30,338 +18,84 @@ export type NavTreeItemActionMenuProps = ActionProperties & {
|
|
|
30
18
|
monolithic?: boolean;
|
|
31
19
|
menuActions?: Action[];
|
|
32
20
|
suppressNextTooltip?: MutableRefObject<boolean>;
|
|
33
|
-
menuOpen?: boolean;
|
|
34
|
-
defaultMenuOpen?: boolean;
|
|
35
|
-
onChangeMenuOpen?: (nextOpen: boolean) => void;
|
|
36
21
|
onAction?: (action: Action) => void;
|
|
37
22
|
};
|
|
38
23
|
|
|
39
|
-
const getShortcut = (action: ActionLike) => {
|
|
40
|
-
return typeof action.properties?.keyBinding === 'string'
|
|
41
|
-
? action.properties.keyBinding
|
|
42
|
-
: action.properties?.keyBinding?.[getHostPlatform()];
|
|
43
|
-
};
|
|
44
|
-
|
|
45
24
|
const fallbackIcon = 'ph--placeholder--regular';
|
|
46
25
|
|
|
26
|
+
const actionButtonProps = {
|
|
27
|
+
iconOnly: true,
|
|
28
|
+
size: 4 as const,
|
|
29
|
+
variant: 'ghost' as const,
|
|
30
|
+
density: 'fine' as const,
|
|
31
|
+
classNames: mx('shrink-0 !pli-2 pointer-fine:!pli-1', hoverableControlItem, hoverableOpenControlItem),
|
|
32
|
+
};
|
|
33
|
+
|
|
47
34
|
export const NavTreeItemActionDropdownMenu = ({
|
|
48
35
|
label,
|
|
49
36
|
icon,
|
|
50
37
|
testId,
|
|
51
|
-
defaultMenuOpen,
|
|
52
38
|
menuActions,
|
|
53
|
-
menuOpen,
|
|
54
|
-
suppressNextTooltip,
|
|
55
|
-
onChangeMenuOpen,
|
|
56
39
|
onAction,
|
|
57
40
|
}: NavTreeItemActionMenuProps) => {
|
|
58
41
|
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
59
|
-
|
|
60
|
-
const [optionsMenuOpen, setOptionsMenuOpen] = useControllableState({
|
|
61
|
-
prop: menuOpen,
|
|
62
|
-
defaultProp: defaultMenuOpen,
|
|
63
|
-
onChange: onChangeMenuOpen,
|
|
64
|
-
});
|
|
65
|
-
|
|
42
|
+
const suppressNextTooltip = useRef<boolean>(false);
|
|
66
43
|
return (
|
|
67
|
-
<
|
|
68
|
-
{
|
|
69
|
-
open: optionsMenuOpen,
|
|
70
|
-
onOpenChange: (nextOpen: boolean) => {
|
|
71
|
-
if (!nextOpen && suppressNextTooltip) {
|
|
72
|
-
suppressNextTooltip.current = true;
|
|
73
|
-
}
|
|
74
|
-
return setOptionsMenuOpen(nextOpen);
|
|
75
|
-
},
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
<Tooltip.Trigger asChild>
|
|
44
|
+
<MenuProvider onAction={onAction}>
|
|
45
|
+
<DropdownMenu.Root items={menuActions as MenuItem[]} suppressNextTooltip={suppressNextTooltip}>
|
|
79
46
|
<DropdownMenu.Trigger asChild>
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
47
|
+
<IconButton
|
|
48
|
+
{...actionButtonProps}
|
|
49
|
+
icon={icon ?? fallbackIcon}
|
|
50
|
+
label={toLocalizedString(label, t)}
|
|
84
51
|
data-testid={testId}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<span className='sr-only'>{toLocalizedString(label, t)}</span>
|
|
88
|
-
<Icon icon={icon ?? fallbackIcon} size={4} />
|
|
89
|
-
</Button>
|
|
52
|
+
suppressNextTooltip={suppressNextTooltip}
|
|
53
|
+
/>
|
|
90
54
|
</DropdownMenu.Trigger>
|
|
91
|
-
</
|
|
92
|
-
|
|
93
|
-
<DropdownMenu.Content classNames='z-[31]'>
|
|
94
|
-
<DropdownMenu.Viewport>
|
|
95
|
-
{menuActions?.map((action) => {
|
|
96
|
-
const shortcut = getShortcut(action);
|
|
97
|
-
return (
|
|
98
|
-
<DropdownMenu.Item
|
|
99
|
-
key={action.id}
|
|
100
|
-
onClick={(event) => {
|
|
101
|
-
if (action.properties?.disabled) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
event.stopPropagation();
|
|
105
|
-
// TODO(thure): Why does Dialog’s modal-ness cause issues if we don’t explicitly close the menu here?
|
|
106
|
-
if (suppressNextTooltip) {
|
|
107
|
-
suppressNextTooltip.current = true;
|
|
108
|
-
}
|
|
109
|
-
setOptionsMenuOpen(false);
|
|
110
|
-
onAction?.(action);
|
|
111
|
-
}}
|
|
112
|
-
classNames='gap-2'
|
|
113
|
-
disabled={action.properties?.disabled}
|
|
114
|
-
{...(action.properties?.testId && { 'data-testid': action.properties.testId })}
|
|
115
|
-
>
|
|
116
|
-
{action.properties?.icon && <Icon icon={action.properties!.icon} size={4} />}
|
|
117
|
-
<span className='grow truncate'>{toLocalizedString(action.properties!.label, t)}</span>
|
|
118
|
-
{shortcut && <span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>}
|
|
119
|
-
</DropdownMenu.Item>
|
|
120
|
-
);
|
|
121
|
-
})}
|
|
122
|
-
</DropdownMenu.Viewport>
|
|
123
|
-
<DropdownMenu.Arrow />
|
|
124
|
-
</DropdownMenu.Content>
|
|
125
|
-
</DropdownMenu.Portal>
|
|
126
|
-
</DropdownMenu.Root>
|
|
127
|
-
);
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
export const NavTreeItemActionContextMenu = (
|
|
131
|
-
props: PropsWithChildren<Pick<NavTreeItemActionMenuProps, 'menuActions' | 'onAction'>>,
|
|
132
|
-
) => {
|
|
133
|
-
return (props.menuActions?.length ?? 0) > 0 ? <NavTreeItemActionContextMenuImpl {...props} /> : <>{props.children}</>;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const NavTreeItemActionContextMenuImpl = ({
|
|
137
|
-
menuActions,
|
|
138
|
-
onAction,
|
|
139
|
-
children,
|
|
140
|
-
}: PropsWithChildren<Pick<NavTreeItemActionMenuProps, 'menuActions' | 'onAction'>>) => {
|
|
141
|
-
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
142
|
-
|
|
143
|
-
return (
|
|
144
|
-
<ContextMenu.Root>
|
|
145
|
-
<ContextMenu.Trigger asChild>{children}</ContextMenu.Trigger>
|
|
146
|
-
<ContextMenu.Portal>
|
|
147
|
-
<ContextMenu.Content classNames='z-[31]'>
|
|
148
|
-
<ContextMenu.Viewport>
|
|
149
|
-
{menuActions?.map((action) => {
|
|
150
|
-
const shortcut = getShortcut(action);
|
|
151
|
-
return (
|
|
152
|
-
<ContextMenu.Item
|
|
153
|
-
key={action.id}
|
|
154
|
-
onClick={(event) => {
|
|
155
|
-
if (action.properties?.disabled) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
event.stopPropagation();
|
|
159
|
-
onAction?.(action);
|
|
160
|
-
}}
|
|
161
|
-
classNames='gap-2'
|
|
162
|
-
disabled={action.properties?.disabled}
|
|
163
|
-
{...(action.properties?.testId && { 'data-testid': action.properties.testId })}
|
|
164
|
-
>
|
|
165
|
-
{action.properties?.icon && <Icon icon={action.properties?.icon} size={4} />}
|
|
166
|
-
<span className='grow truncate'>{toLocalizedString(action.properties!.label, t)}</span>
|
|
167
|
-
{shortcut && <span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>}
|
|
168
|
-
</ContextMenu.Item>
|
|
169
|
-
);
|
|
170
|
-
})}
|
|
171
|
-
</ContextMenu.Viewport>
|
|
172
|
-
<ContextMenu.Arrow />
|
|
173
|
-
</ContextMenu.Content>
|
|
174
|
-
</ContextMenu.Portal>
|
|
175
|
-
</ContextMenu.Root>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
export const NavTreeItemActionSearchList = ({
|
|
180
|
-
menuActions,
|
|
181
|
-
icon,
|
|
182
|
-
label,
|
|
183
|
-
testId,
|
|
184
|
-
suppressNextTooltip,
|
|
185
|
-
onAction,
|
|
186
|
-
}: Pick<
|
|
187
|
-
NavTreeItemActionMenuProps,
|
|
188
|
-
'icon' | 'menuActions' | 'testId' | 'label' | 'onAction' | 'suppressNextTooltip'
|
|
189
|
-
>) => {
|
|
190
|
-
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
191
|
-
|
|
192
|
-
const [optionsMenuOpen, setOptionsMenuOpen] = useState(false);
|
|
193
|
-
const button = useRef<HTMLButtonElement | null>(null);
|
|
194
|
-
|
|
195
|
-
// TODO(burdon): Optionally sort.
|
|
196
|
-
const sortedActions = menuActions?.sort(({ properties: p1 }, { properties: p2 }) => {
|
|
197
|
-
const t1 = toLocalizedString(p1!.label, t).toLowerCase();
|
|
198
|
-
const t2 = toLocalizedString(p2!.label, t).toLowerCase();
|
|
199
|
-
return t1.localeCompare(t2);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
// TODO(thure): Use LayoutPlugin’s global Dialog.
|
|
203
|
-
return (
|
|
204
|
-
<Dialog.Root
|
|
205
|
-
{...{
|
|
206
|
-
open: optionsMenuOpen,
|
|
207
|
-
onOpenChange: (nextOpen: boolean) => {
|
|
208
|
-
if (!nextOpen && suppressNextTooltip) {
|
|
209
|
-
suppressNextTooltip.current = true;
|
|
210
|
-
}
|
|
211
|
-
return setOptionsMenuOpen(nextOpen);
|
|
212
|
-
},
|
|
213
|
-
}}
|
|
214
|
-
>
|
|
215
|
-
<Tooltip.Trigger asChild>
|
|
216
|
-
<Dialog.Trigger asChild>
|
|
217
|
-
<Button
|
|
218
|
-
variant='ghost'
|
|
219
|
-
density='fine'
|
|
220
|
-
classNames={mx('shrink-0 !pli-2 pointer-fine:!pli-1', hoverableControlItem, hoverableOpenControlItem)}
|
|
221
|
-
data-testid={testId}
|
|
222
|
-
onKeyDownCapture={(event) => {
|
|
223
|
-
// TODO(thure): Why is only this `Button` affected and not `DropdownMenu.Trigger`’s?
|
|
224
|
-
if (button.current && button.current === event.target) {
|
|
225
|
-
switch (event.key) {
|
|
226
|
-
case 'Enter':
|
|
227
|
-
case ' ':
|
|
228
|
-
// Capture this event and stop propagation to the drag start handler.
|
|
229
|
-
event.stopPropagation();
|
|
230
|
-
setOptionsMenuOpen(true);
|
|
231
|
-
break;
|
|
232
|
-
default:
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}}
|
|
236
|
-
ref={button}
|
|
237
|
-
>
|
|
238
|
-
<Icon icon={icon ?? fallbackIcon} size={4} />
|
|
239
|
-
</Button>
|
|
240
|
-
</Dialog.Trigger>
|
|
241
|
-
</Tooltip.Trigger>
|
|
242
|
-
<Dialog.Portal>
|
|
243
|
-
<Dialog.Overlay>
|
|
244
|
-
<Dialog.Content classNames='z-[31] is-full max-is-[24rem] pli-2 plb-1'>
|
|
245
|
-
<SearchList.Root label={t('tree item searchlist input placeholder')}>
|
|
246
|
-
<SearchList.Input placeholder={t('tree item searchlist input placeholder')} classNames='pli-3' />
|
|
247
|
-
<SearchList.Content classNames='min-bs-[12rem] bs-[50dvh] max-bs-[30rem] overflow-auto'>
|
|
248
|
-
{sortedActions?.map((action) => {
|
|
249
|
-
const label = toLocalizedString(action.properties!.label, t);
|
|
250
|
-
const shortcut = getShortcut(action);
|
|
251
|
-
return (
|
|
252
|
-
<SearchList.Item
|
|
253
|
-
// TODO(burdon): Value should be id since label is not unique.
|
|
254
|
-
value={label}
|
|
255
|
-
key={action.id}
|
|
256
|
-
onSelect={() => {
|
|
257
|
-
if (action.properties?.disabled) {
|
|
258
|
-
return;
|
|
259
|
-
}
|
|
260
|
-
if (suppressNextTooltip) {
|
|
261
|
-
suppressNextTooltip.current = true;
|
|
262
|
-
}
|
|
263
|
-
setOptionsMenuOpen(false);
|
|
264
|
-
onAction?.(action);
|
|
265
|
-
}}
|
|
266
|
-
classNames='flex items-center gap-2 pli-2'
|
|
267
|
-
disabled={action.properties?.disabled}
|
|
268
|
-
{...(action.properties?.testId && { 'data-testid': action.properties.testId })}
|
|
269
|
-
>
|
|
270
|
-
{action.properties?.icon && <Icon icon={action.properties?.icon} size={4} />}
|
|
271
|
-
<span className='grow truncate'>{label}</span>
|
|
272
|
-
{shortcut && (
|
|
273
|
-
<span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>
|
|
274
|
-
)}
|
|
275
|
-
</SearchList.Item>
|
|
276
|
-
);
|
|
277
|
-
})}
|
|
278
|
-
</SearchList.Content>
|
|
279
|
-
<div role='none' className='flex items-center plb-2 pli-3'>
|
|
280
|
-
<span className={descriptionText}>{toLocalizedString(label, t)}</span>
|
|
281
|
-
</div>
|
|
282
|
-
</SearchList.Root>
|
|
283
|
-
</Dialog.Content>
|
|
284
|
-
</Dialog.Overlay>
|
|
285
|
-
</Dialog.Portal>
|
|
286
|
-
</Dialog.Root>
|
|
55
|
+
</DropdownMenu.Root>
|
|
56
|
+
</MenuProvider>
|
|
287
57
|
);
|
|
288
58
|
};
|
|
289
59
|
|
|
290
60
|
export const NavTreeItemMonolithicAction = ({
|
|
291
61
|
parent,
|
|
292
|
-
properties: { disabled, caller, testId,
|
|
62
|
+
properties: { disabled, caller, testId, icon } = { label: 'never' },
|
|
293
63
|
data: invoke,
|
|
294
|
-
|
|
295
|
-
|
|
64
|
+
baseLabel,
|
|
65
|
+
}: Action & { parent: Node; onAction?: (action: Action) => void; baseLabel: string }) => {
|
|
296
66
|
return (
|
|
297
|
-
<
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
>
|
|
312
|
-
<span className='sr-only'>{toLocalizedString(label, t)}</span>
|
|
313
|
-
<Icon icon={icon ?? fallbackIcon} size={4} />
|
|
314
|
-
</Button>
|
|
315
|
-
</Tooltip.Trigger>
|
|
67
|
+
<IconButton
|
|
68
|
+
{...actionButtonProps}
|
|
69
|
+
icon={icon ?? fallbackIcon}
|
|
70
|
+
label={baseLabel}
|
|
71
|
+
disabled={disabled}
|
|
72
|
+
onClick={(event) => {
|
|
73
|
+
if (disabled) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
event.stopPropagation();
|
|
77
|
+
void invoke?.(caller ? { node: parent, caller } : { node: parent });
|
|
78
|
+
}}
|
|
79
|
+
data-testid={testId}
|
|
80
|
+
/>
|
|
316
81
|
);
|
|
317
82
|
};
|
|
318
83
|
|
|
319
84
|
export const NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }: NavTreeItemActionMenuProps) => {
|
|
320
85
|
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
321
|
-
const suppressNextTooltip = useRef<boolean>(false);
|
|
322
|
-
const [triggerTooltipOpen, setTriggerTooltipOpen] = useState(false);
|
|
323
86
|
|
|
324
87
|
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
325
88
|
const baseLabel = toLocalizedString(monolithicAction ? monolithicAction.properties!.label : props.label, t);
|
|
326
89
|
|
|
327
|
-
return (
|
|
328
|
-
<
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}}
|
|
338
|
-
>
|
|
339
|
-
{baseLabel && (
|
|
340
|
-
<Tooltip.Portal>
|
|
341
|
-
<Tooltip.Content classNames='z-[31]' side='bottom'>
|
|
342
|
-
{baseLabel}
|
|
343
|
-
<Tooltip.Arrow />
|
|
344
|
-
</Tooltip.Content>
|
|
345
|
-
</Tooltip.Portal>
|
|
346
|
-
)}
|
|
347
|
-
{monolithic && menuActions?.length === 1 ? (
|
|
348
|
-
<NavTreeItemMonolithicAction parent={node} {...menuActions[0]} />
|
|
349
|
-
) : props.menuType === 'searchList' ? (
|
|
350
|
-
<NavTreeItemActionSearchList
|
|
351
|
-
{...props}
|
|
352
|
-
menuActions={menuActions}
|
|
353
|
-
suppressNextTooltip={suppressNextTooltip}
|
|
354
|
-
onAction={(action) => action.data?.(props.caller ? { node, caller: props.caller } : { node })}
|
|
355
|
-
/>
|
|
356
|
-
) : (
|
|
357
|
-
<NavTreeItemActionDropdownMenu
|
|
358
|
-
{...props}
|
|
359
|
-
parent={node}
|
|
360
|
-
menuActions={menuActions}
|
|
361
|
-
suppressNextTooltip={suppressNextTooltip}
|
|
362
|
-
onAction={(action) => action.data?.(props.caller ? { node, caller: props.caller } : { node })}
|
|
363
|
-
/>
|
|
364
|
-
)}
|
|
365
|
-
</Tooltip.Root>
|
|
90
|
+
return monolithic && menuActions?.length === 1 ? (
|
|
91
|
+
<NavTreeItemMonolithicAction baseLabel={baseLabel} parent={node} {...menuActions[0]} />
|
|
92
|
+
) : (
|
|
93
|
+
<NavTreeItemActionDropdownMenu
|
|
94
|
+
{...props}
|
|
95
|
+
label={baseLabel}
|
|
96
|
+
parent={node}
|
|
97
|
+
menuActions={menuActions}
|
|
98
|
+
onAction={(action) => action.data?.(props.caller ? { node, caller: props.caller } : { node })}
|
|
99
|
+
/>
|
|
366
100
|
);
|
|
367
101
|
};
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { useIntentDispatcher,
|
|
8
|
-
import { ClientAction } from '@dxos/plugin-client/
|
|
9
|
-
import {
|
|
7
|
+
import { createIntent, useIntentDispatcher, useCapabilities } from '@dxos/app-framework';
|
|
8
|
+
import { ClientAction } from '@dxos/plugin-client/types';
|
|
9
|
+
import { ObservabilityCapabilities } from '@dxos/plugin-observability';
|
|
10
10
|
import { useIdentity } from '@dxos/react-client/halo';
|
|
11
11
|
|
|
12
12
|
import { HaloButton } from './HaloButton';
|
|
@@ -14,16 +14,17 @@ import { HaloButton } from './HaloButton';
|
|
|
14
14
|
// TODO(thure): Refactor to be handled by a more appropriate plugin (ClientPlugin?).
|
|
15
15
|
export const NotchStart = () => {
|
|
16
16
|
const identity = useIdentity();
|
|
17
|
-
|
|
18
|
-
const
|
|
17
|
+
// TODO(wittjosiah): Can this be removed now?
|
|
18
|
+
const [observability] = useCapabilities(ObservabilityCapabilities.Observability);
|
|
19
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
19
20
|
return (
|
|
20
21
|
<HaloButton
|
|
21
22
|
size={8}
|
|
22
23
|
identityKey={identity?.identityKey.toHex()}
|
|
23
24
|
hue={identity?.profile?.data?.hue}
|
|
24
25
|
emoji={identity?.profile?.data?.emoji}
|
|
25
|
-
internal={
|
|
26
|
-
onClick={() => dispatch(
|
|
26
|
+
internal={observability?.group === 'dxos'}
|
|
27
|
+
onClick={() => dispatch(createIntent(ClientAction.ShareIdentity))}
|
|
27
28
|
/>
|
|
28
29
|
);
|
|
29
30
|
};
|
package/src/components/index.ts
CHANGED
package/src/events.ts
ADDED
package/src/index.ts
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default NavTreePlugin;
|
|
8
|
-
|
|
5
|
+
export { NavTreeCapabilities } from './capabilities';
|
|
6
|
+
export { NavTreeEvents } from './events';
|
|
9
7
|
export * from './NavTreePlugin';
|
|
8
|
+
export * from './meta';
|
|
10
9
|
export * from './util';
|
package/src/meta.ts
CHANGED
|
@@ -8,7 +8,9 @@ export const NAVTREE_PLUGIN = 'dxos.org/plugin/navtree';
|
|
|
8
8
|
|
|
9
9
|
// TODO(wittjosiah): Factor out.
|
|
10
10
|
export const KEY_BINDING = 'KeyBinding';
|
|
11
|
+
// TODO(wittjosiah): Factor out.
|
|
12
|
+
export const COMMANDS_DIALOG = `${NAVTREE_PLUGIN}/CommandsDialog`;
|
|
11
13
|
|
|
12
|
-
export
|
|
14
|
+
export const meta = {
|
|
13
15
|
id: NAVTREE_PLUGIN,
|
|
14
16
|
} satisfies PluginMeta;
|
package/src/translations.ts
CHANGED
|
@@ -20,7 +20,6 @@ export default [
|
|
|
20
20
|
'see release label': 'See release on GitHub',
|
|
21
21
|
'powered by dxos message': 'Powered by <dxos>DXOS</dxos>',
|
|
22
22
|
'tree item actions label': 'More actions',
|
|
23
|
-
'tree item searchlist input placeholder': 'Search for actions…',
|
|
24
23
|
'empty branch message': ' ',
|
|
25
24
|
},
|
|
26
25
|
},
|
package/src/types.ts
CHANGED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/meta.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const NAVTREE_PLUGIN = 'dxos.org/plugin/navtree';\n\n// TODO(wittjosiah): Factor out.\nexport const KEY_BINDING = 'KeyBinding';\n\nexport default {\n id: NAVTREE_PLUGIN,\n} satisfies PluginMeta;\n"],
|
|
5
|
-
"mappings": ";AAMO,IAAMA,iBAAiB;AAGvB,IAAMC,cAAc;AAE3B,IAAA,eAAe;EACbC,IAAIF;AACN;",
|
|
6
|
-
"names": ["NAVTREE_PLUGIN", "KEY_BINDING", "id"]
|
|
7
|
-
}
|