@dxos/plugin-navtree 0.7.4 → 0.7.5-main.937ce75

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.
Files changed (37) hide show
  1. package/dist/lib/browser/{chunk-PSVCPL4T.mjs → chunk-VAXG4OAG.mjs} +3 -1
  2. package/dist/lib/browser/chunk-VAXG4OAG.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +165 -352
  4. package/dist/lib/browser/index.mjs.map +3 -3
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/meta.mjs +3 -1
  7. package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
  8. package/dist/types/src/components/CommandsTrigger.d.ts.map +1 -1
  9. package/dist/types/src/components/NavTree.d.ts +2 -2
  10. package/dist/types/src/components/NavTree.d.ts.map +1 -1
  11. package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
  12. package/dist/types/src/components/NavTreeFooter.d.ts.map +1 -1
  13. package/dist/types/src/components/NavTreeItemAction.d.ts +4 -8
  14. package/dist/types/src/components/NavTreeItemAction.d.ts.map +1 -1
  15. package/dist/types/src/components/NavTreeItemAction.stories.d.ts +0 -5
  16. package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +1 -1
  17. package/dist/types/src/meta.d.ts +1 -0
  18. package/dist/types/src/meta.d.ts.map +1 -1
  19. package/dist/types/src/translations.d.ts +0 -1
  20. package/dist/types/src/translations.d.ts.map +1 -1
  21. package/dist/types/src/types.d.ts +1 -1
  22. package/dist/types/src/types.d.ts.map +1 -1
  23. package/dist/types/tsconfig.tsbuildinfo +1 -0
  24. package/package.json +30 -29
  25. package/src/NavTreePlugin.tsx +67 -62
  26. package/src/components/CommandsDialog.tsx +3 -3
  27. package/src/components/CommandsTrigger.tsx +10 -7
  28. package/src/components/NavTree.tsx +6 -11
  29. package/src/components/NavTreeContainer.tsx +32 -54
  30. package/src/components/NavTreeFooter.tsx +3 -2
  31. package/src/components/NavTreeItemAction.stories.tsx +0 -2
  32. package/src/components/NavTreeItemAction.tsx +53 -316
  33. package/src/components/NotchStart.tsx +4 -4
  34. package/src/meta.ts +2 -0
  35. package/src/translations.ts +0 -1
  36. package/src/types.ts +1 -1
  37. package/dist/lib/browser/chunk-PSVCPL4T.mjs.map +0 -7
@@ -1,22 +1,23 @@
1
1
  import {
2
+ COMMANDS_DIALOG,
2
3
  KEY_BINDING,
3
4
  NAVTREE_PLUGIN,
4
5
  meta_default
5
- } from "./chunk-PSVCPL4T.mjs";
6
+ } from "./chunk-VAXG4OAG.mjs";
6
7
 
7
8
  // packages/plugins/plugin-navtree/src/NavTreePlugin.tsx
8
9
  import { effect } from "@preact/signals-core";
9
10
  import React9 from "react";
10
- import { LayoutAction as LayoutAction4, NavigationAction as NavigationAction2, parseGraphPlugin, parseIntentPlugin, parseLayoutPlugin, parseNavigationPlugin as parseNavigationPlugin2, resolvePlugin } from "@dxos/app-framework";
11
+ import { createIntent as createIntent6, createResolver, createSurface, LayoutAction as LayoutAction4, NavigationAction as NavigationAction2, parseGraphPlugin, parseIntentPlugin, parseLayoutPlugin, parseNavigationPlugin as parseNavigationPlugin2, resolvePlugin } from "@dxos/app-framework";
11
12
  import { createExtension, isAction as isAction5, isGraphNode } from "@dxos/app-graph";
12
13
  import { Keyboard as Keyboard2 } from "@dxos/keyboard";
13
14
  import { create } from "@dxos/live-object";
14
15
  import { Path } from "@dxos/react-ui-mosaic";
15
- import { getHostPlatform as getHostPlatform3 } from "@dxos/util";
16
+ import { getHostPlatform as getHostPlatform2 } from "@dxos/util";
16
17
 
17
18
  // packages/plugins/plugin-navtree/src/components/CommandsDialog.tsx
18
19
  import React, { useMemo, useState } from "react";
19
- import { useIntentDispatcher, LayoutAction } from "@dxos/app-framework";
20
+ import { useIntentDispatcher, LayoutAction, createIntent } from "@dxos/app-framework";
20
21
  import { isActionGroup, isAction } from "@dxos/app-graph";
21
22
  import { Keyboard, keySymbols } from "@dxos/keyboard";
22
23
  import { useGraph } from "@dxos/plugin-graph";
@@ -27,7 +28,7 @@ import { getHostPlatform } from "@dxos/util";
27
28
  var CommandsDialogContent = ({ selected: initial }) => {
28
29
  const { t } = useTranslation(NAVTREE_PLUGIN);
29
30
  const [selected, setSelected] = useState(initial);
30
- const dispatch = useIntentDispatcher();
31
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
31
32
  const { graph } = useGraph();
32
33
  const allActions = useMemo(() => {
33
34
  const current = Keyboard.singleton.getCurrentContext();
@@ -78,13 +79,10 @@ var CommandsDialogContent = ({ selected: initial }) => {
78
79
  setSelected(action.id);
79
80
  return;
80
81
  }
81
- void dispatch({
82
- action: LayoutAction.SET_LAYOUT,
83
- data: {
84
- element: "dialog",
85
- state: false
86
- }
87
- });
82
+ void dispatch(createIntent(LayoutAction.SetLayout, {
83
+ element: "dialog",
84
+ state: false
85
+ }));
88
86
  setTimeout(() => {
89
87
  const node = graph.nodes(group ?? action, {
90
88
  relation: "inbound"
@@ -125,177 +123,42 @@ import { Popover, toLocalizedString as toLocalizedString3, Treegrid, useTranslat
125
123
  import { Tree } from "@dxos/react-ui-list";
126
124
 
127
125
  // packages/plugins/plugin-navtree/src/components/NavTreeItemAction.tsx
128
- import { useControllableState } from "@radix-ui/react-use-controllable-state";
129
- import React2, { useRef, useState as useState2 } from "react";
130
- import { keySymbols as keySymbols2 } from "@dxos/keyboard";
131
- import { Button as Button2, Dialog as Dialog2, DropdownMenu, ContextMenu, Tooltip, useTranslation as useTranslation2, toLocalizedString as toLocalizedString2, Icon as Icon2 } from "@dxos/react-ui";
132
- import { SearchList as SearchList2 } from "@dxos/react-ui-searchlist";
133
- import { descriptionText as descriptionText2, hoverableControlItem, hoverableOpenControlItem, mx as mx2 } from "@dxos/react-ui-theme";
134
- import { getHostPlatform as getHostPlatform2 } from "@dxos/util";
135
- var getShortcut = (action) => {
136
- return typeof action.properties?.keyBinding === "string" ? action.properties.keyBinding : action.properties?.keyBinding?.[getHostPlatform2()];
137
- };
126
+ import React2, { useRef } from "react";
127
+ import { useTranslation as useTranslation2, toLocalizedString as toLocalizedString2, IconButton } from "@dxos/react-ui";
128
+ import { DropdownMenu } from "@dxos/react-ui-menu";
129
+ import { hoverableControlItem, hoverableOpenControlItem, mx as mx2 } from "@dxos/react-ui-theme";
138
130
  var fallbackIcon = "ph--placeholder--regular";
139
- var NavTreeItemActionDropdownMenu = ({ label, icon, testId, defaultMenuOpen, menuActions, menuOpen, suppressNextTooltip, onChangeMenuOpen, onAction }) => {
131
+ var actionButtonProps = {
132
+ iconOnly: true,
133
+ size: 4,
134
+ variant: "ghost",
135
+ density: "fine",
136
+ classNames: mx2("shrink-0 !pli-2 pointer-fine:!pli-1", hoverableControlItem, hoverableOpenControlItem)
137
+ };
138
+ var NavTreeItemActionDropdownMenu = ({ label, icon, testId, menuActions, onAction }) => {
140
139
  const { t } = useTranslation2(NAVTREE_PLUGIN);
141
- const [optionsMenuOpen, setOptionsMenuOpen] = useControllableState({
142
- prop: menuOpen,
143
- defaultProp: defaultMenuOpen,
144
- onChange: onChangeMenuOpen
145
- });
140
+ const suppressNextTooltip = useRef(false);
146
141
  return /* @__PURE__ */ React2.createElement(DropdownMenu.Root, {
147
- open: optionsMenuOpen,
148
- onOpenChange: (nextOpen) => {
149
- if (!nextOpen && suppressNextTooltip) {
150
- suppressNextTooltip.current = true;
151
- }
152
- return setOptionsMenuOpen(nextOpen);
153
- }
154
- }, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
155
- asChild: true
142
+ actions: menuActions,
143
+ onAction,
144
+ suppressNextTooltip
156
145
  }, /* @__PURE__ */ React2.createElement(DropdownMenu.Trigger, {
157
146
  asChild: true
158
- }, /* @__PURE__ */ React2.createElement(Button2, {
159
- variant: "ghost",
160
- density: "fine",
161
- classNames: mx2("shrink-0 !pli-2 pointer-fine:!pli-1", hoverableControlItem, hoverableOpenControlItem),
162
- "data-testid": testId,
163
- "aria-label": t("tree item actions label")
164
- }, /* @__PURE__ */ React2.createElement("span", {
165
- className: "sr-only"
166
- }, toLocalizedString2(label, t)), /* @__PURE__ */ React2.createElement(Icon2, {
147
+ }, /* @__PURE__ */ React2.createElement(IconButton, {
148
+ ...actionButtonProps,
167
149
  icon: icon ?? fallbackIcon,
168
- size: 4
169
- })))), /* @__PURE__ */ React2.createElement(DropdownMenu.Portal, null, /* @__PURE__ */ React2.createElement(DropdownMenu.Content, {
170
- classNames: "z-[31]"
171
- }, /* @__PURE__ */ React2.createElement(DropdownMenu.Viewport, null, menuActions?.map((action) => {
172
- const shortcut = getShortcut(action);
173
- return /* @__PURE__ */ React2.createElement(DropdownMenu.Item, {
174
- key: action.id,
175
- onClick: (event) => {
176
- if (action.properties?.disabled) {
177
- return;
178
- }
179
- event.stopPropagation();
180
- if (suppressNextTooltip) {
181
- suppressNextTooltip.current = true;
182
- }
183
- setOptionsMenuOpen(false);
184
- onAction?.(action);
185
- },
186
- classNames: "gap-2",
187
- disabled: action.properties?.disabled,
188
- ...action.properties?.testId && {
189
- "data-testid": action.properties.testId
190
- }
191
- }, action.properties?.icon && /* @__PURE__ */ React2.createElement(Icon2, {
192
- icon: action.properties.icon,
193
- size: 4
194
- }), /* @__PURE__ */ React2.createElement("span", {
195
- className: "grow truncate"
196
- }, toLocalizedString2(action.properties.label, t)), shortcut && /* @__PURE__ */ React2.createElement("span", {
197
- className: mx2("shrink-0", descriptionText2)
198
- }, keySymbols2(shortcut).join("")));
199
- })), /* @__PURE__ */ React2.createElement(DropdownMenu.Arrow, null))));
200
- };
201
- var NavTreeItemActionSearchList = ({ menuActions, icon, label, testId, suppressNextTooltip, onAction }) => {
202
- const { t } = useTranslation2(NAVTREE_PLUGIN);
203
- const [optionsMenuOpen, setOptionsMenuOpen] = useState2(false);
204
- const button = useRef(null);
205
- const sortedActions = menuActions?.sort(({ properties: p1 }, { properties: p2 }) => {
206
- const t1 = toLocalizedString2(p1.label, t).toLowerCase();
207
- const t2 = toLocalizedString2(p2.label, t).toLowerCase();
208
- return t1.localeCompare(t2);
209
- });
210
- return /* @__PURE__ */ React2.createElement(Dialog2.Root, {
211
- open: optionsMenuOpen,
212
- onOpenChange: (nextOpen) => {
213
- if (!nextOpen && suppressNextTooltip) {
214
- suppressNextTooltip.current = true;
215
- }
216
- return setOptionsMenuOpen(nextOpen);
217
- }
218
- }, /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
219
- asChild: true
220
- }, /* @__PURE__ */ React2.createElement(Dialog2.Trigger, {
221
- asChild: true
222
- }, /* @__PURE__ */ React2.createElement(Button2, {
223
- variant: "ghost",
224
- density: "fine",
225
- classNames: mx2("shrink-0 !pli-2 pointer-fine:!pli-1", hoverableControlItem, hoverableOpenControlItem),
150
+ label: toLocalizedString2(label, t),
226
151
  "data-testid": testId,
227
- onKeyDownCapture: (event) => {
228
- if (button.current && button.current === event.target) {
229
- switch (event.key) {
230
- case "Enter":
231
- case " ":
232
- event.stopPropagation();
233
- setOptionsMenuOpen(true);
234
- break;
235
- default:
236
- }
237
- }
238
- },
239
- ref: button
240
- }, /* @__PURE__ */ React2.createElement(Icon2, {
241
- icon: icon ?? fallbackIcon,
242
- size: 4
243
- })))), /* @__PURE__ */ React2.createElement(Dialog2.Portal, null, /* @__PURE__ */ React2.createElement(Dialog2.Overlay, null, /* @__PURE__ */ React2.createElement(Dialog2.Content, {
244
- classNames: "z-[31] is-full max-is-[24rem] pli-2 plb-1"
245
- }, /* @__PURE__ */ React2.createElement(SearchList2.Root, {
246
- label: t("tree item searchlist input placeholder")
247
- }, /* @__PURE__ */ React2.createElement(SearchList2.Input, {
248
- placeholder: t("tree item searchlist input placeholder"),
249
- classNames: "pli-3"
250
- }), /* @__PURE__ */ React2.createElement(SearchList2.Content, {
251
- classNames: "min-bs-[12rem] bs-[50dvh] max-bs-[30rem] overflow-auto"
252
- }, sortedActions?.map((action) => {
253
- const label2 = toLocalizedString2(action.properties.label, t);
254
- const shortcut = getShortcut(action);
255
- return /* @__PURE__ */ React2.createElement(SearchList2.Item, {
256
- // TODO(burdon): Value should be id since label is not unique.
257
- value: label2,
258
- key: action.id,
259
- onSelect: () => {
260
- if (action.properties?.disabled) {
261
- return;
262
- }
263
- if (suppressNextTooltip) {
264
- suppressNextTooltip.current = true;
265
- }
266
- setOptionsMenuOpen(false);
267
- onAction?.(action);
268
- },
269
- classNames: "flex items-center gap-2 pli-2",
270
- disabled: action.properties?.disabled,
271
- ...action.properties?.testId && {
272
- "data-testid": action.properties.testId
273
- }
274
- }, action.properties?.icon && /* @__PURE__ */ React2.createElement(Icon2, {
275
- icon: action.properties?.icon,
276
- size: 4
277
- }), /* @__PURE__ */ React2.createElement("span", {
278
- className: "grow truncate"
279
- }, label2), shortcut && /* @__PURE__ */ React2.createElement("span", {
280
- className: mx2("shrink-0", descriptionText2)
281
- }, keySymbols2(shortcut).join("")));
282
- })), /* @__PURE__ */ React2.createElement("div", {
283
- role: "none",
284
- className: "flex items-center plb-2 pli-3"
285
- }, /* @__PURE__ */ React2.createElement("span", {
286
- className: descriptionText2
287
- }, toLocalizedString2(label, t))))))));
152
+ suppressNextTooltip
153
+ })));
288
154
  };
289
- var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, testId, label, icon } = {
155
+ var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, testId, icon } = {
290
156
  label: "never"
291
- }, data: invoke }) => {
292
- const { t } = useTranslation2(NAVTREE_PLUGIN);
293
- return /* @__PURE__ */ React2.createElement(Tooltip.Trigger, {
294
- asChild: true
295
- }, /* @__PURE__ */ React2.createElement(Button2, {
296
- variant: "ghost",
297
- density: "fine",
298
- classNames: mx2("shrink-0 !pli-2 pointer-fine:!pli-1", hoverableControlItem, hoverableOpenControlItem),
157
+ }, data: invoke, baseLabel }) => {
158
+ return /* @__PURE__ */ React2.createElement(IconButton, {
159
+ ...actionButtonProps,
160
+ icon: icon ?? fallbackIcon,
161
+ label: baseLabel,
299
162
  disabled,
300
163
  onClick: (event) => {
301
164
  if (disabled) {
@@ -310,69 +173,39 @@ var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, tes
310
173
  });
311
174
  },
312
175
  "data-testid": testId
313
- }, /* @__PURE__ */ React2.createElement("span", {
314
- className: "sr-only"
315
- }, toLocalizedString2(label, t)), /* @__PURE__ */ React2.createElement(Icon2, {
316
- icon: icon ?? fallbackIcon,
317
- size: 4
318
- })));
176
+ });
319
177
  };
320
178
  var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) => {
321
179
  const { t } = useTranslation2(NAVTREE_PLUGIN);
322
- const suppressNextTooltip = useRef(false);
323
- const [triggerTooltipOpen, setTriggerTooltipOpen] = useState2(false);
324
180
  const monolithicAction = menuActions?.length === 1 && menuActions[0];
325
181
  const baseLabel = toLocalizedString2(monolithicAction ? monolithicAction.properties.label : props.label, t);
326
- return /* @__PURE__ */ React2.createElement(Tooltip.Root, {
327
- open: triggerTooltipOpen,
328
- onOpenChange: (nextOpen) => {
329
- if (suppressNextTooltip.current) {
330
- setTriggerTooltipOpen(false);
331
- suppressNextTooltip.current = false;
332
- } else {
333
- setTriggerTooltipOpen(nextOpen);
334
- }
335
- }
336
- }, baseLabel && /* @__PURE__ */ React2.createElement(Tooltip.Portal, null, /* @__PURE__ */ React2.createElement(Tooltip.Content, {
337
- classNames: "z-[31]",
338
- side: "bottom"
339
- }, baseLabel, /* @__PURE__ */ React2.createElement(Tooltip.Arrow, null))), monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React2.createElement(NavTreeItemMonolithicAction, {
182
+ return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React2.createElement(NavTreeItemMonolithicAction, {
183
+ baseLabel,
340
184
  parent: node,
341
185
  ...menuActions[0]
342
- }) : props.menuType === "searchList" ? /* @__PURE__ */ React2.createElement(NavTreeItemActionSearchList, {
343
- ...props,
344
- menuActions,
345
- suppressNextTooltip,
346
- onAction: (action) => action.data?.(props.caller ? {
347
- node,
348
- caller: props.caller
349
- } : {
350
- node
351
- })
352
186
  }) : /* @__PURE__ */ React2.createElement(NavTreeItemActionDropdownMenu, {
353
187
  ...props,
188
+ label: baseLabel,
354
189
  parent: node,
355
190
  menuActions,
356
- suppressNextTooltip,
357
191
  onAction: (action) => action.data?.(props.caller ? {
358
192
  node,
359
193
  caller: props.caller
360
194
  } : {
361
195
  node
362
196
  })
363
- }));
197
+ });
364
198
  };
365
199
 
366
200
  // packages/plugins/plugin-navtree/src/components/NavTree.tsx
367
201
  var NAV_TREE_ITEM = "NavTreeItem";
368
202
  var NavTree = ({ getActions: getActions2, loadDescendents, renderItemEnd: renderItemEnd2, popoverAnchorId, ...props }) => {
369
- const renderColumns = useCallback(({ item, path, menuOpen, setMenuOpen }) => {
203
+ const renderColumns = useCallback(({ item, path, open }) => {
370
204
  return /* @__PURE__ */ React3.createElement(NavTreeColumns, {
371
205
  path,
372
206
  node: item,
373
207
  getActions: getActions2,
374
- menuOpen,
375
- setMenuOpen,
208
+ open,
376
209
  loadDescendents,
377
210
  renderItemEnd: renderItemEnd2,
378
211
  popoverAnchorId
@@ -389,7 +222,7 @@ var NavTree = ({ getActions: getActions2, loadDescendents, renderItemEnd: render
389
222
  renderColumns
390
223
  });
391
224
  };
392
- var NavTreeColumns = ({ path, node, getActions: getActions2, menuOpen, setMenuOpen, loadDescendents, renderItemEnd: ItemEnd, popoverAnchorId }) => {
225
+ var NavTreeColumns = ({ path, node, getActions: getActions2, open, loadDescendents, renderItemEnd: ItemEnd, popoverAnchorId }) => {
393
226
  const { t } = useTranslation3(NAVTREE_PLUGIN);
394
227
  const level = path.length - 2;
395
228
  const { actions: _actions, groupedActions } = getActions2(node);
@@ -427,11 +260,10 @@ var NavTreeColumns = ({ path, node, getActions: getActions2, menuOpen, setMenuOp
427
260
  parent: node,
428
261
  menuActions: actions,
429
262
  menuType: "dropdown",
430
- caller: NAV_TREE_ITEM,
431
- menuOpen,
432
- onChangeMenuOpen: setMenuOpen
263
+ caller: NAV_TREE_ITEM
433
264
  }) : /* @__PURE__ */ React3.createElement(Treegrid.Cell, null)), ItemEnd && /* @__PURE__ */ React3.createElement(ItemEnd, {
434
- node
265
+ node,
266
+ open
435
267
  }));
436
268
  };
437
269
 
@@ -440,11 +272,11 @@ import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/ad
440
272
  import { extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
441
273
  import { untracked } from "@preact/signals-core";
442
274
  import React5, { memo, useCallback as useCallback2, useEffect as useEffect2 } from "react";
443
- import { LayoutAction as LayoutAction2, NavigationAction, Surface, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
275
+ import { createIntent as createIntent3, LayoutAction as LayoutAction2, NavigationAction, Surface, useIntentDispatcher as useIntentDispatcher3 } from "@dxos/app-framework";
444
276
  import { isAction as isAction4, isActionLike } from "@dxos/app-graph";
445
277
  import { useGraph as useGraph2 } from "@dxos/plugin-graph";
446
278
  import { isEchoObject, isSpace } from "@dxos/react-client/echo";
447
- import { ElevationProvider, useMediaQuery, useSidebars as useSidebars2 } from "@dxos/react-ui";
279
+ import { useMediaQuery, useSidebars as useSidebars2 } from "@dxos/react-ui";
448
280
  import { isTreeData } from "@dxos/react-ui-list";
449
281
  import { mx as mx4 } from "@dxos/react-ui-theme";
450
282
  import { arrayMove } from "@dxos/util";
@@ -453,9 +285,9 @@ import { arrayMove } from "@dxos/util";
453
285
  import { ArrowSquareOut, GearSix, Warning } from "@phosphor-icons/react";
454
286
  import { formatDistance } from "date-fns/formatDistance";
455
287
  import React4 from "react";
456
- import { SettingsAction, parseNavigationPlugin, useResolvePlugin, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
288
+ import { SettingsAction, parseNavigationPlugin, useResolvePlugin, useIntentDispatcher as useIntentDispatcher2, createIntent as createIntent2 } from "@dxos/app-framework";
457
289
  import { useConfig } from "@dxos/react-client";
458
- import { Button as Button3, Link, Message, Popover as Popover2, Tooltip as Tooltip2, Trans, useDefaultValue, useSidebars, useTranslation as useTranslation4 } from "@dxos/react-ui";
290
+ import { Button as Button2, Link, Message, Popover as Popover2, Tooltip, Trans, useDefaultValue, useSidebars, useTranslation as useTranslation4 } from "@dxos/react-ui";
459
291
  import { LayoutControls } from "@dxos/react-ui-stack";
460
292
  import { getSize, mx as mx3 } from "@dxos/react-ui-theme";
461
293
  var buttonStyles = "pli-1.5 text-xs font-normal";
@@ -466,7 +298,7 @@ var NavTreeFooter = (props) => {
466
298
  const config = useConfig();
467
299
  const { t } = useTranslation4(NAVTREE_PLUGIN);
468
300
  const { navigationSidebarOpen } = useSidebars(NAVTREE_PLUGIN);
469
- const dispatch = useIntentDispatcher2();
301
+ const { dispatchPromise: dispatch } = useIntentDispatcher2();
470
302
  const { version, timestamp, commitHash } = config.values.runtime?.app?.build ?? {};
471
303
  const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
472
304
  const [_, v] = version?.match(VERSION_REGEX) ?? [];
@@ -477,7 +309,7 @@ var NavTreeFooter = (props) => {
477
309
  className: mx3("flex bs-[--rail-size] pbe-[env(safe-area-inset-bottom)] box-content justify-end", layoutPart === "complementary" && "md:justify-end flex-row-reverse")
478
310
  }, /* @__PURE__ */ React4.createElement(Popover2.Root, null, /* @__PURE__ */ React4.createElement(Popover2.Trigger, {
479
311
  asChild: true
480
- }, /* @__PURE__ */ React4.createElement(Button3, {
312
+ }, /* @__PURE__ */ React4.createElement(Button2, {
481
313
  variant: "ghost",
482
314
  classNames: buttonStyles,
483
315
  ...!navigationSidebarOpen && {
@@ -527,9 +359,9 @@ var NavTreeFooter = (props) => {
527
359
  variant: "neutral"
528
360
  })
529
361
  }
530
- }))), /* @__PURE__ */ React4.createElement(Popover2.Arrow, null)))), /* @__PURE__ */ React4.createElement(Tooltip2.Root, null, /* @__PURE__ */ React4.createElement(Tooltip2.Trigger, {
362
+ }))), /* @__PURE__ */ React4.createElement(Popover2.Arrow, null)))), /* @__PURE__ */ React4.createElement(Tooltip.Root, null, /* @__PURE__ */ React4.createElement(Tooltip.Trigger, {
531
363
  asChild: true
532
- }, /* @__PURE__ */ React4.createElement(Button3, {
364
+ }, /* @__PURE__ */ React4.createElement(Button2, {
533
365
  variant: "ghost",
534
366
  classNames: buttonStyles,
535
367
  "data-testid": "treeView.openSettings",
@@ -537,16 +369,14 @@ var NavTreeFooter = (props) => {
537
369
  ...!navigationSidebarOpen && {
538
370
  tabIndex: -1
539
371
  },
540
- onClick: () => dispatch({
541
- action: SettingsAction.OPEN
542
- })
372
+ onClick: () => dispatch(createIntent2(SettingsAction.Open))
543
373
  }, /* @__PURE__ */ React4.createElement("span", {
544
374
  className: "sr-only"
545
375
  }, t("open settings label")), /* @__PURE__ */ React4.createElement(GearSix, {
546
376
  className: mx3(getSize(5), "rotate-90")
547
- }))), /* @__PURE__ */ React4.createElement(Tooltip2.Portal, null, /* @__PURE__ */ React4.createElement(Tooltip2.Content, {
377
+ }))), /* @__PURE__ */ React4.createElement(Tooltip.Portal, null, /* @__PURE__ */ React4.createElement(Tooltip.Content, {
548
378
  classNames: "z-[12]"
549
- }, t("open settings label"), /* @__PURE__ */ React4.createElement(Tooltip2.Arrow, null)))), navigationPlugin?.meta.id === "dxos.org/plugin/deck" && /* @__PURE__ */ React4.createElement(LayoutControls, {
379
+ }, t("open settings label"), /* @__PURE__ */ React4.createElement(Tooltip.Arrow, null)))), navigationPlugin?.meta.id === "dxos.org/plugin/deck" && /* @__PURE__ */ React4.createElement(LayoutControls, {
550
380
  variant: "hide-disabled",
551
381
  capabilities: {
552
382
  incrementStart: false,
@@ -647,19 +477,21 @@ var expandActions = (graph, node) => {
647
477
 
648
478
  // packages/plugins/plugin-navtree/src/components/NavTreeContainer.tsx
649
479
  var NODE_TYPE = "dxos/app-graph/node";
650
- var renderItemEnd = ({ node }) => /* @__PURE__ */ React5.createElement(Surface, {
480
+ var renderItemEnd = ({ node, open }) => /* @__PURE__ */ React5.createElement(Surface, {
651
481
  role: "navtree-item-end",
652
482
  data: {
653
- object: node.data,
654
- id: node.id
655
- }
483
+ id: node.id,
484
+ subject: node.data,
485
+ open
486
+ },
487
+ limit: 1
656
488
  });
657
489
  var NavTreeContainer = /* @__PURE__ */ memo(({ isCurrent, popoverAnchorId, ...props }) => {
658
490
  const { closeNavigationSidebar } = useSidebars2(NAVTREE_PLUGIN);
659
491
  const [isLg] = useMediaQuery("lg", {
660
492
  ssr: false
661
493
  });
662
- const dispatch = useIntentDispatcher3();
494
+ const { dispatchPromise: dispatch } = useIntentDispatcher3();
663
495
  const { graph } = useGraph2();
664
496
  const getActions2 = useCallback2((node) => getActions(graph, node), [
665
497
  graph
@@ -734,34 +566,25 @@ var NavTreeContainer = /* @__PURE__ */ memo(({ isCurrent, popoverAnchorId, ...pr
734
566
  }
735
567
  const current = isCurrent(path, node);
736
568
  if (!current) {
737
- void dispatch({
738
- action: NavigationAction.OPEN,
739
- data: {
740
- activeParts: {
741
- main: [
742
- node.id
743
- ]
744
- }
569
+ void dispatch(createIntent3(NavigationAction.Open, {
570
+ activeParts: {
571
+ main: [
572
+ node.id
573
+ ]
745
574
  }
746
- });
575
+ }));
747
576
  } else if (option) {
748
- void dispatch({
749
- action: NavigationAction.CLOSE,
750
- data: {
751
- activeParts: {
752
- main: [
753
- node.id
754
- ]
755
- }
577
+ void dispatch(createIntent3(NavigationAction.Close, {
578
+ activeParts: {
579
+ main: [
580
+ node.id
581
+ ]
756
582
  }
757
- });
583
+ }));
758
584
  } else {
759
- void dispatch({
760
- action: LayoutAction2.SCROLL_INTO_VIEW,
761
- data: {
762
- id: node.id
763
- }
764
- });
585
+ void dispatch(createIntent3(LayoutAction2.ScrollIntoView, {
586
+ id: node.id
587
+ }));
765
588
  }
766
589
  const defaultAction = graph.actions(node).find((action) => action.properties?.disposition === "default");
767
590
  if (isAction4(defaultAction)) {
@@ -827,9 +650,7 @@ var NavTreeContainer = /* @__PURE__ */ memo(({ isCurrent, popoverAnchorId, ...pr
827
650
  }, [
828
651
  graph
829
652
  ]);
830
- return /* @__PURE__ */ React5.createElement(ElevationProvider, {
831
- elevation: "chrome"
832
- }, /* @__PURE__ */ React5.createElement("div", {
653
+ return /* @__PURE__ */ React5.createElement("div", {
833
654
  role: "none",
834
655
  className: "grid grid-cols-1 grid-rows-[var(--rail-size)_1fr_min-content] bs-full overflow-hidden"
835
656
  }, /* @__PURE__ */ React5.createElement("div", {
@@ -853,7 +674,7 @@ var NavTreeContainer = /* @__PURE__ */ memo(({ isCurrent, popoverAnchorId, ...pr
853
674
  canDrop,
854
675
  onSelect: handleSelect,
855
676
  ...props
856
- })), /* @__PURE__ */ React5.createElement(NavTreeFooter, null)));
677
+ })), /* @__PURE__ */ React5.createElement(NavTreeFooter, null));
857
678
  });
858
679
 
859
680
  // packages/plugins/plugin-navtree/src/components/NavTreeDocumentTitle.tsx
@@ -873,8 +694,8 @@ var NavTreeDocumentTitle = ({ node }) => {
873
694
 
874
695
  // packages/plugins/plugin-navtree/src/components/NotchStart.tsx
875
696
  import React7 from "react";
876
- import { useIntentDispatcher as useIntentDispatcher4, useResolvePlugin as useResolvePlugin2 } from "@dxos/app-framework";
877
- import { ClientAction } from "@dxos/plugin-client/meta";
697
+ import { createIntent as createIntent4, useIntentDispatcher as useIntentDispatcher4, useResolvePlugin as useResolvePlugin2 } from "@dxos/app-framework";
698
+ import { ClientAction } from "@dxos/plugin-client/types";
878
699
  import { parseObservabilityPlugin } from "@dxos/plugin-observability";
879
700
  import { useIdentity } from "@dxos/react-client/halo";
880
701
 
@@ -911,38 +732,33 @@ var HaloButton = (props) => {
911
732
  var NotchStart = () => {
912
733
  const identity = useIdentity();
913
734
  const observabilityPlugin = useResolvePlugin2(parseObservabilityPlugin);
914
- const dispatch = useIntentDispatcher4();
735
+ const { dispatchPromise: dispatch } = useIntentDispatcher4();
915
736
  return /* @__PURE__ */ React7.createElement(HaloButton, {
916
737
  size: 8,
917
738
  identityKey: identity?.identityKey.toHex(),
918
739
  hue: identity?.profile?.data?.hue,
919
740
  emoji: identity?.profile?.data?.emoji,
920
741
  internal: observabilityPlugin?.provides?.observability?.group === "dxos",
921
- onClick: () => dispatch({
922
- action: ClientAction.SHARE_IDENTITY
923
- })
742
+ onClick: () => dispatch(createIntent4(ClientAction.ShareIdentity))
924
743
  });
925
744
  };
926
745
 
927
746
  // packages/plugins/plugin-navtree/src/components/CommandsTrigger.tsx
928
747
  import { MagnifyingGlass } from "@phosphor-icons/react";
929
748
  import React8 from "react";
930
- import { LayoutAction as LayoutAction3, useIntent } from "@dxos/app-framework";
931
- import { Button as Button4, useTranslation as useTranslation6 } from "@dxos/react-ui";
749
+ import { createIntent as createIntent5, LayoutAction as LayoutAction3, useIntentDispatcher as useIntentDispatcher5 } from "@dxos/app-framework";
750
+ import { Button as Button3, useTranslation as useTranslation6 } from "@dxos/react-ui";
932
751
  import { getSize as getSize2 } from "@dxos/react-ui-theme";
933
752
  var CommandsTrigger = () => {
934
- const { dispatch } = useIntent();
753
+ const { dispatchPromise: dispatch } = useIntentDispatcher5();
935
754
  const { t } = useTranslation6(NAVTREE_PLUGIN);
936
- return /* @__PURE__ */ React8.createElement(Button4, {
755
+ return /* @__PURE__ */ React8.createElement(Button3, {
937
756
  classNames: "w-full h-full !rounded-none",
938
- onClick: () => dispatch({
939
- action: LayoutAction3.SET_LAYOUT,
940
- data: {
941
- element: "dialog",
942
- component: `${NAVTREE_PLUGIN}/Commands`,
943
- dialogBlockAlign: "start"
944
- }
945
- })
757
+ onClick: () => dispatch(createIntent5(LayoutAction3.SetLayout, {
758
+ element: "dialog",
759
+ component: COMMANDS_DIALOG,
760
+ dialogBlockAlign: "start"
761
+ }))
946
762
  }, /* @__PURE__ */ React8.createElement("span", {
947
763
  className: "text-description font-normal grow text-start"
948
764
  }, t("command list input placeholder")), /* @__PURE__ */ React8.createElement(MagnifyingGlass, {
@@ -967,7 +783,6 @@ var translations_default = [
967
783
  "see release label": "See release on GitHub",
968
784
  "powered by dxos message": "Powered by <dxos>DXOS</dxos>",
969
785
  "tree item actions label": "More actions",
970
- "tree item searchlist input placeholder": "Search for actions\u2026",
971
786
  "empty branch message": "\xA0"
972
787
  }
973
788
  }
@@ -1048,7 +863,7 @@ var NavTreePlugin = () => {
1048
863
  };
1049
864
  return {
1050
865
  meta: meta_default,
1051
- ready: async (plugins) => {
866
+ ready: async ({ plugins }) => {
1052
867
  const layout = resolvePlugin(plugins, parseLayoutPlugin)?.provides.layout;
1053
868
  const location = resolvePlugin(plugins, parseNavigationPlugin2)?.provides.location;
1054
869
  graphPlugin = resolvePlugin(plugins, parseGraphPlugin);
@@ -1057,15 +872,11 @@ var NavTreePlugin = () => {
1057
872
  return;
1058
873
  }
1059
874
  const soloPart = location?.active.solo?.[0];
1060
- const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatch;
875
+ const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
1061
876
  if (dispatch && soloPart) {
1062
- void dispatch({
1063
- plugin: NAVTREE_PLUGIN,
1064
- action: NavigationAction2.EXPOSE,
1065
- data: {
1066
- id: soloPart.id
1067
- }
1068
- });
877
+ void dispatch(createIntent6(NavigationAction2.Expose, {
878
+ id: soloPart.id
879
+ }));
1069
880
  }
1070
881
  let previous = [];
1071
882
  unsubscribe = effect(() => {
@@ -1096,7 +907,7 @@ var NavTreePlugin = () => {
1096
907
  let shortcut;
1097
908
  if (typeof node.properties.keyBinding === "object") {
1098
909
  const availablePlatforms = Object.keys(node.properties.keyBinding);
1099
- const platform = getHostPlatform3();
910
+ const platform = getHostPlatform2();
1100
911
  shortcut = availablePlatforms.includes(platform) ? node.properties.keyBinding[platform] : platform === "ios" ? node.properties.keyBinding.macos : platform === "linux" || platform === "unknown" ? node.properties.keyBinding.windows : void 0;
1101
912
  } else {
1102
913
  shortcut = node.properties.keyBinding;
@@ -1143,81 +954,83 @@ var NavTreePlugin = () => {
1143
954
  }
1144
955
  },
1145
956
  surface: {
1146
- component: ({ data, role }) => {
1147
- switch (data.component) {
1148
- case `${NAVTREE_PLUGIN}/Commands`: {
1149
- const selected = typeof data.subject === "string" ? data.subject : void 0;
1150
- return /* @__PURE__ */ React9.createElement(CommandsDialogContent, {
1151
- selected
1152
- });
1153
- }
1154
- }
1155
- switch (role) {
1156
- case "navigation":
1157
- return /* @__PURE__ */ React9.createElement(NavTreeContainer, {
1158
- isOpen,
1159
- isCurrent,
1160
- onOpenChange: handleOpenChange,
1161
- popoverAnchorId: data.popoverAnchorId
1162
- });
1163
- case "document-title": {
1164
- return /* @__PURE__ */ React9.createElement(NavTreeDocumentTitle, {
1165
- node: isGraphNode(data.activeNode) ? data.activeNode : void 0
1166
- });
1167
- }
1168
- case "notch-start":
1169
- return /* @__PURE__ */ React9.createElement(NotchStart, null);
1170
- case "search-input":
1171
- return {
1172
- node: /* @__PURE__ */ React9.createElement(CommandsTrigger, null),
1173
- disposition: "fallback"
1174
- };
1175
- }
1176
- return null;
1177
- }
957
+ definitions: () => [
958
+ createSurface({
959
+ id: COMMANDS_DIALOG,
960
+ role: "dialog",
961
+ filter: (data) => data.component === COMMANDS_DIALOG,
962
+ component: ({ data }) => /* @__PURE__ */ React9.createElement(CommandsDialogContent, {
963
+ selected: data.subject
964
+ })
965
+ }),
966
+ createSurface({
967
+ id: `${NAVTREE_PLUGIN}/navigation`,
968
+ role: "navigation",
969
+ component: ({ data }) => /* @__PURE__ */ React9.createElement(NavTreeContainer, {
970
+ isOpen,
971
+ isCurrent,
972
+ onOpenChange: handleOpenChange,
973
+ popoverAnchorId: data.popoverAnchorId
974
+ })
975
+ }),
976
+ createSurface({
977
+ id: `${NAVTREE_PLUGIN}/document-title`,
978
+ role: "document-title",
979
+ component: ({ data }) => /* @__PURE__ */ React9.createElement(NavTreeDocumentTitle, {
980
+ node: isGraphNode(data.subject) ? data.subject : void 0
981
+ })
982
+ }),
983
+ createSurface({
984
+ id: `${NAVTREE_PLUGIN}/notch-start`,
985
+ role: "notch-start",
986
+ component: () => /* @__PURE__ */ React9.createElement(NotchStart, null)
987
+ }),
988
+ createSurface({
989
+ id: `${NAVTREE_PLUGIN}/search-input`,
990
+ role: "search-input",
991
+ disposition: "fallback",
992
+ component: () => /* @__PURE__ */ React9.createElement(CommandsTrigger, null)
993
+ })
994
+ ]
1178
995
  },
1179
996
  intent: {
1180
- resolver: async (intent) => {
1181
- switch (intent.action) {
1182
- case NavigationAction2.EXPOSE: {
1183
- if (graph && intent.data?.id) {
1184
- const path = await graph.waitForPath({
1185
- target: intent.data.id
1186
- });
1187
- [
1188
- ...Array(path.length)
1189
- ].forEach((_, index) => {
1190
- const subpath = path.slice(0, index);
1191
- const value = getItem(subpath);
1192
- if (!value.open) {
1193
- setItem(subpath, "open", true);
1194
- }
1195
- });
1196
- }
1197
- break;
1198
- }
997
+ resolvers: ({ plugins }) => {
998
+ const graph2 = resolvePlugin(plugins, parseGraphPlugin)?.provides.graph;
999
+ if (!graph2) {
1000
+ return [];
1199
1001
  }
1002
+ return createResolver(NavigationAction2.Expose, async ({ id }) => {
1003
+ const path = await graph2.waitForPath({
1004
+ target: id
1005
+ });
1006
+ [
1007
+ ...Array(path.length)
1008
+ ].forEach((_, index) => {
1009
+ const subpath = path.slice(0, index);
1010
+ const value = getItem(subpath);
1011
+ if (!value.open) {
1012
+ setItem(subpath, "open", true);
1013
+ }
1014
+ });
1015
+ });
1200
1016
  }
1201
1017
  },
1202
1018
  graph: {
1203
1019
  builder: (plugins) => {
1204
- const intentPlugin = resolvePlugin(plugins, parseIntentPlugin);
1020
+ const dispatch = resolvePlugin(plugins, parseIntentPlugin)?.provides.intent.dispatchPromise;
1205
1021
  return [
1206
1022
  createExtension({
1207
1023
  id: NAVTREE_PLUGIN,
1208
1024
  filter: (node) => node.id === "root",
1209
1025
  actions: () => [
1210
1026
  {
1211
- id: "dxos.org/plugin/navtree/open-commands",
1027
+ id: COMMANDS_DIALOG,
1212
1028
  data: async () => {
1213
- await intentPlugin?.provides.intent.dispatch({
1214
- action: LayoutAction4.SET_LAYOUT,
1215
- data: {
1216
- element: "dialog",
1217
- component: `${NAVTREE_PLUGIN}/Commands`,
1218
- dialogBlockAlign: "start"
1219
- }
1220
- });
1029
+ await dispatch?.(createIntent6(LayoutAction4.SetLayout, {
1030
+ element: "dialog",
1031
+ component: COMMANDS_DIALOG,
1032
+ dialogBlockAlign: "start"
1033
+ }));
1221
1034
  },
1222
1035
  properties: {
1223
1036
  label: [