@dxos/plugin-navtree 0.7.5-labs.ea4b4c2 → 0.7.5-labs.f400bbc

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 (59) hide show
  1. package/dist/lib/browser/{chunk-54MPRXMH.mjs → chunk-GXNOX2XZ.mjs} +232 -79
  2. package/dist/lib/browser/chunk-GXNOX2XZ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +3 -3
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/{react-surface-LNRTNSM6.mjs → react-surface-SG4QBA2U.mjs} +2 -2
  7. package/dist/lib/browser/{state-65TQKYX7.mjs → state-IEFQTUPG.mjs} +2 -2
  8. package/dist/lib/browser/state-IEFQTUPG.mjs.map +7 -0
  9. package/dist/types/src/capabilities/app-graph-builder.d.ts +110 -110
  10. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  11. package/dist/types/src/capabilities/index.d.ts +124 -124
  12. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  13. package/dist/types/src/components/CommandsDialog.d.ts +1 -2
  14. package/dist/types/src/components/CommandsDialog.d.ts.map +1 -1
  15. package/dist/types/src/components/CommandsTrigger.d.ts +1 -2
  16. package/dist/types/src/components/CommandsTrigger.d.ts.map +1 -1
  17. package/dist/types/src/components/HaloButton.d.ts +1 -2
  18. package/dist/types/src/components/HaloButton.d.ts.map +1 -1
  19. package/dist/types/src/components/HaloButton.stories.d.ts +1 -2
  20. package/dist/types/src/components/HaloButton.stories.d.ts.map +1 -1
  21. package/dist/types/src/components/L0Menu.d.ts +1 -2
  22. package/dist/types/src/components/L0Menu.d.ts.map +1 -1
  23. package/dist/types/src/components/L1Panels.d.ts +8 -3
  24. package/dist/types/src/components/L1Panels.d.ts.map +1 -1
  25. package/dist/types/src/components/NavTree.d.ts +1 -2
  26. package/dist/types/src/components/NavTree.d.ts.map +1 -1
  27. package/dist/types/src/components/NavTreeContainer.d.ts +1 -1
  28. package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
  29. package/dist/types/src/components/NavTreeItemAction.d.ts +4 -4
  30. package/dist/types/src/components/NavTreeItemAction.d.ts.map +1 -1
  31. package/dist/types/src/components/NavTreeItemAction.stories.d.ts +2 -2
  32. package/dist/types/src/components/NavTreeItemColumns.d.ts +1 -1
  33. package/dist/types/src/components/NavTreeItemColumns.d.ts.map +1 -1
  34. package/dist/types/src/components/NotchStart.d.ts +1 -2
  35. package/dist/types/src/components/NotchStart.d.ts.map +1 -1
  36. package/dist/types/src/components/types.d.ts +2 -1
  37. package/dist/types/src/components/types.d.ts.map +1 -1
  38. package/dist/types/src/experimental/Tree.d.ts +8 -8
  39. package/dist/types/src/experimental/Tree.d.ts.map +1 -1
  40. package/dist/types/src/experimental/Tree.stories.d.ts +2 -3
  41. package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
  42. package/dist/types/src/stories/StorybookNavTree.d.ts +1 -2
  43. package/dist/types/src/stories/StorybookNavTree.d.ts.map +1 -1
  44. package/dist/types/src/util.d.ts +1 -1
  45. package/package.json +31 -31
  46. package/src/NavTreePlugin.tsx +2 -2
  47. package/src/capabilities/state.ts +1 -1
  48. package/src/components/L0Menu.tsx +177 -55
  49. package/src/components/L1Panels.tsx +25 -6
  50. package/src/components/NavTree.stories.tsx +1 -1
  51. package/src/components/NavTree.tsx +3 -3
  52. package/src/components/NavTreeContainer.tsx +9 -2
  53. package/src/components/types.ts +12 -10
  54. package/src/hooks.ts +1 -1
  55. package/src/stories/Graph.stories.tsx +1 -1
  56. package/src/util.ts +2 -2
  57. package/dist/lib/browser/chunk-54MPRXMH.mjs.map +0 -7
  58. package/dist/lib/browser/state-65TQKYX7.mjs.map +0 -7
  59. /package/dist/lib/browser/{react-surface-LNRTNSM6.mjs.map → react-surface-SG4QBA2U.mjs.map} +0 -0
@@ -187,7 +187,7 @@ var NotchStart = () => {
187
187
 
188
188
  // packages/plugins/plugin-navtree/src/util.ts
189
189
  import { ACTION_TYPE, ACTION_GROUP_TYPE, isAction as isAction2, isActionLike } from "@dxos/app-graph";
190
- import { nonNullable } from "@dxos/util";
190
+ import { isNonNullable } from "@dxos/util";
191
191
  var getParent = (graph, node, path) => {
192
192
  const parentId = path[path.length - 2];
193
193
  return graph.nodes(node, {
@@ -239,7 +239,7 @@ var getChildren = (graph, node, filter, path = []) => {
239
239
  node.id
240
240
  ];
241
241
  return nextPath.includes(n.id) ? void 0 : n;
242
- }).filter(nonNullable);
242
+ }).filter(isNonNullable);
243
243
  };
244
244
  var getActions = (graph, node) => {
245
245
  return graph.actions(node).reduce((acc, arg) => {
@@ -313,14 +313,14 @@ var getFirstTwoRenderableChars = (label) => {
313
313
  import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
314
314
  import { extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
315
315
  import { untracked } from "@preact/signals-core";
316
- import React10, { memo as memo2, useCallback as useCallback2, useEffect as useEffect2, useMemo as useMemo5 } from "react";
316
+ import React10, { memo as memo2, useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo5 } from "react";
317
317
  import { createIntent as createIntent5, LayoutAction as LayoutAction4, Surface, useAppGraph as useAppGraph2, useCapability, useIntentDispatcher as useIntentDispatcher5, useLayout as useLayout2 } from "@dxos/app-framework";
318
318
  import { isAction as isAction4, isActionLike as isActionLike2 } from "@dxos/app-graph";
319
319
  import { isEchoObject, isSpace } from "@dxos/react-client/echo";
320
320
  import { useMediaQuery as useMediaQuery2 } from "@dxos/react-ui";
321
321
  import { isTreeData } from "@dxos/react-ui-list";
322
- import { mx as mx5 } from "@dxos/react-ui-theme";
323
- import { arrayMove } from "@dxos/util";
322
+ import { mx as mx6 } from "@dxos/react-ui-theme";
323
+ import { arrayMove as arrayMove2 } from "@dxos/util";
324
324
 
325
325
  // packages/plugins/plugin-navtree/src/components/NavTree.tsx
326
326
  import React9, { useMemo as useMemo4 } from "react";
@@ -328,11 +328,18 @@ import { Tabs as Tabs3 } from "@dxos/react-ui-tabs";
328
328
  import { byPosition } from "@dxos/util";
329
329
 
330
330
  // packages/plugins/plugin-navtree/src/components/L0Menu.tsx
331
- import React5, { useCallback, useMemo as useMemo2 } from "react";
331
+ import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
332
+ import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
333
+ import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
334
+ import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
335
+ import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
336
+ import React5, { useCallback, useLayoutEffect, useMemo as useMemo2, useRef, useState as useState2 } from "react";
332
337
  import { createIntent as createIntent4, LayoutAction as LayoutAction3, useIntentDispatcher as useIntentDispatcher4 } from "@dxos/app-framework";
333
- import { Icon as Icon2, toLocalizedString as toLocalizedString2, Tooltip, useMediaQuery, useSidebars, useTranslation as useTranslation3 } from "@dxos/react-ui";
338
+ import { invariant } from "@dxos/invariant";
339
+ import { Popover, ScrollArea, toLocalizedString as toLocalizedString3, Tooltip, useMediaQuery, useSidebars, useTranslation as useTranslation4, ListItem, Icon as Icon2 } from "@dxos/react-ui";
334
340
  import { Tabs } from "@dxos/react-ui-tabs";
335
341
  import { mx as mx3 } from "@dxos/react-ui-theme";
342
+ import { arrayMove } from "@dxos/util";
336
343
 
337
344
  // packages/plugins/plugin-navtree/src/components/NavTreeContext.tsx
338
345
  import { createContext, useContext } from "react";
@@ -341,10 +348,27 @@ var NavTreeContext = /* @__PURE__ */ createContext(null);
341
348
  var useNavTreeContext = () => useContext(NavTreeContext) ?? raise(new Error("NavTreeContext not found"));
342
349
 
343
350
  // packages/plugins/plugin-navtree/src/hooks.ts
351
+ import { useEffect as useEffect2 } from "react";
352
+
353
+ // packages/plugins/plugin-navtree/src/components/NavTreeDocumentTitle.tsx
344
354
  import { useEffect } from "react";
355
+ import { toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } from "@dxos/react-ui";
356
+ var NavTreeDocumentTitle = ({ node }) => {
357
+ const { t } = useTranslation3(NAVTREE_PLUGIN);
358
+ useEffect(() => {
359
+ document.title = node ? toLocalizedString2(node.properties.label, t) : t("current app name", {
360
+ ns: "appkit"
361
+ });
362
+ }, [
363
+ node?.properties?.label
364
+ ]);
365
+ return null;
366
+ };
367
+
368
+ // packages/plugins/plugin-navtree/src/hooks.ts
345
369
  var useLoadDescendents = (root) => {
346
370
  const { loadDescendents } = useNavTreeContext();
347
- useEffect(() => {
371
+ useEffect2(() => {
348
372
  const frame = requestAnimationFrame(() => {
349
373
  if (root) {
350
374
  void loadDescendents?.(root);
@@ -357,6 +381,7 @@ var useLoadDescendents = (root) => {
357
381
  };
358
382
 
359
383
  // packages/plugins/plugin-navtree/src/components/L0Menu.tsx
384
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-navtree/src/components/L0Menu.tsx";
360
385
  var useL0ItemClick = ({ item, parent, path }, type) => {
361
386
  const { tab, onTabChange, onSelect, isCurrent } = useNavTreeContext();
362
387
  const { dispatchPromise: dispatch } = useIntentDispatcher4();
@@ -406,8 +431,10 @@ var useL0ItemClick = ({ item, parent, path }, type) => {
406
431
  var l0Breakpoints = {
407
432
  lg: "hidden lg:grid"
408
433
  };
409
- var L0Item = ({ item, parent, path, pinned }) => {
410
- const { t } = useTranslation3(NAVTREE_PLUGIN);
434
+ var L0Item = ({ item, parent, path, pinned, onRearrange }) => {
435
+ const { t } = useTranslation4(NAVTREE_PLUGIN);
436
+ const itemElement = useRef(null);
437
+ const [closestEdge, setEdge] = useState2(null);
411
438
  const type = l0ItemType(item);
412
439
  const itemPath = useMemo2(() => [
413
440
  ...path,
@@ -416,7 +443,7 @@ var L0Item = ({ item, parent, path, pinned }) => {
416
443
  item.id,
417
444
  path
418
445
  ]);
419
- const { getProps } = useNavTreeContext();
446
+ const { getProps, popoverAnchorId } = useNavTreeContext();
420
447
  const { id, testId } = getProps?.(item, path) ?? {};
421
448
  const Root = type === "collection" ? "h2" : type === "tab" ? Tabs.TabPrimitive : "button";
422
449
  const handleClick = useL0ItemClick({
@@ -437,37 +464,130 @@ var L0Item = ({ item, parent, path, pinned }) => {
437
464
  } : {
438
465
  onClick: handleClick
439
466
  };
440
- const localizedString = toLocalizedString2(item.properties.label, t);
441
- const avatarValue = useMemo2(() => type === "tab" ? getFirstTwoRenderableChars(localizedString).join("") : [], [
467
+ const localizedString = toLocalizedString3(item.properties.label, t);
468
+ const hue = item.properties.hue ?? null;
469
+ const avatarValue = useMemo2(() => type === "tab" ? getFirstTwoRenderableChars(localizedString).join("").toUpperCase() : [], [
442
470
  type,
443
471
  item.properties.label,
444
472
  t
445
473
  ]);
446
- return /* @__PURE__ */ React5.createElement(Tooltip.Root, {
447
- delayDuration: 0
448
- }, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
449
- asChild: true
450
- }, /* @__PURE__ */ React5.createElement(Root, {
474
+ const hueFgStyle = hue && {
475
+ style: {
476
+ color: `var(--dx-${hue}SurfaceText)`
477
+ }
478
+ };
479
+ useLayoutEffect(() => {
480
+ if (!itemElement.current || !onRearrange) {
481
+ return;
482
+ }
483
+ return combine(draggable({
484
+ element: itemElement.current,
485
+ getInitialData: () => ({
486
+ id: item.id,
487
+ type: "l0Item"
488
+ }),
489
+ onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
490
+ document.body.setAttribute("data-drag-preview", "true");
491
+ const element = source.element.querySelector("[data-frame]");
492
+ scrollJustEnoughIntoView({
493
+ element
494
+ });
495
+ const { x, y } = preserveOffsetOnSource({
496
+ element,
497
+ input: location.current.input
498
+ })({
499
+ container: element.offsetParent ?? document.body
500
+ });
501
+ nativeSetDragImage?.(element, x, y);
502
+ },
503
+ onDragStart: () => {
504
+ document.body.removeAttribute("data-drag-preview");
505
+ itemElement.current.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
506
+ },
507
+ onDrop: () => {
508
+ itemElement.current.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
509
+ }
510
+ }), dropTargetForElements({
511
+ element: itemElement.current,
512
+ getData: ({ input, element }) => {
513
+ return attachClosestEdge({
514
+ id: item.id,
515
+ type: "l0Item"
516
+ }, {
517
+ input,
518
+ element,
519
+ allowedEdges: [
520
+ "top",
521
+ "bottom"
522
+ ]
523
+ });
524
+ },
525
+ onDragEnter: ({ self, source }) => {
526
+ if (source.data.type === self.data.type) {
527
+ setEdge(extractClosestEdge(self.data));
528
+ }
529
+ },
530
+ onDrag: ({ self, source }) => {
531
+ if (source.data.type === self.data.type) {
532
+ setEdge(extractClosestEdge(self.data));
533
+ }
534
+ },
535
+ onDragLeave: () => setEdge(null),
536
+ onDrop: ({ self, source }) => {
537
+ setEdge(null);
538
+ if (source.data.type === self.data.type) {
539
+ onRearrange(source.data, self.data, extractClosestEdge(self.data));
540
+ }
541
+ }
542
+ }));
543
+ }, [
544
+ item,
545
+ onRearrange
546
+ ]);
547
+ const l0ItemTrigger = /* @__PURE__ */ React5.createElement(Root, {
451
548
  ...rootProps,
452
549
  "data-type": type,
453
- className: mx3('group/l0i dx-focus-ring-group grid overflow-hidden relative data[type!="collection"]:cursor-pointer app-no-drag', l0Breakpoints[item.properties.l0Breakpoint])
454
- }, type !== "collection" && /* @__PURE__ */ React5.createElement("div", {
455
- role: "none",
456
- className: mx3("absolute -z-[1] group-hover/l0i:bg-input dx-focus-ring-group-indicator transition-colors", type === "tab" || pinned ? "rounded" : "rounded-full", pinned ? "bg-transparent inset-inline-3 inset-block-0" : "bg-input inset-inline-3 inset-block-2")
457
- }), /* @__PURE__ */ React5.createElement("div", {
550
+ className: mx3('group/l0i dx-focus-ring-group grid relative data[type!="collection"]:cursor-pointer app-no-drag', l0Breakpoints[item.properties.l0Breakpoint]),
551
+ ref: itemElement
552
+ }, /* @__PURE__ */ React5.createElement("div", {
458
553
  role: "none",
459
- className: "hidden group-aria-selected/l0i:block absolute inline-start-0 inset-block-4 is-1 bg-accentSurface rounded-ie"
460
- }), type === "tab" && item.properties.disposition !== "pin-end" ? /* @__PURE__ */ React5.createElement("span", {
554
+ "data-frame": true,
555
+ className: mx3("absolute grid dx-focus-ring-group-indicator transition-colors", type === "tab" || pinned ? "rounded" : "rounded-full", pinned ? "bg-transparent group-hover/l0i:bg-groupSurface inset-inline-3 inset-block-0.5" : "bg-groupSurface inset-inline-3 inset-block-2"),
556
+ ...hue && {
557
+ style: {
558
+ background: `var(--dx-${hue}Surface)`
559
+ }
560
+ }
561
+ }, item.properties.icon && /* @__PURE__ */ React5.createElement(Icon2, {
562
+ icon: item.properties.icon,
563
+ size: pinned ? 5 : 7,
564
+ classNames: "place-self-center",
565
+ ...hueFgStyle
566
+ }) || (type === "tab" && item.properties.disposition !== "pin-end" ? /* @__PURE__ */ React5.createElement("span", {
461
567
  role: "img",
462
- className: "place-self-center text-3xl font-light"
568
+ className: "place-self-center text-3xl font-light",
569
+ ...hueFgStyle
463
570
  }, avatarValue) : item.properties.icon && /* @__PURE__ */ React5.createElement(Icon2, {
464
- icon: item.properties.icon,
571
+ icon: "ph--planet--regular",
465
572
  size: pinned ? 5 : 7,
466
- classNames: "place-self-center"
573
+ classNames: "place-self-center",
574
+ ...hueFgStyle
575
+ }))), /* @__PURE__ */ React5.createElement("div", {
576
+ role: "none",
577
+ className: "hidden group-aria-selected/l0i:block absolute inline-start-0 inset-block-4 is-1 bg-accentSurface rounded-ie"
467
578
  }), /* @__PURE__ */ React5.createElement("span", {
468
579
  id: `${item.id}__label`,
469
580
  className: "sr-only"
470
- }, localizedString))), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, {
581
+ }, localizedString), onRearrange && closestEdge && /* @__PURE__ */ React5.createElement(ListItem.DropIndicator, {
582
+ edge: closestEdge
583
+ }));
584
+ return popoverAnchorId === id ? /* @__PURE__ */ React5.createElement(Popover.Anchor, {
585
+ asChild: true
586
+ }, l0ItemTrigger) : /* @__PURE__ */ React5.createElement(Tooltip.Root, {
587
+ delayDuration: 0
588
+ }, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
589
+ asChild: true
590
+ }, l0ItemTrigger), /* @__PURE__ */ React5.createElement(Tooltip.Portal, null, /* @__PURE__ */ React5.createElement(Tooltip.Content, {
471
591
  side: "right"
472
592
  }, localizedString, /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null))));
473
593
  };
@@ -483,6 +603,27 @@ var L0Collection = ({ item, path, parent }) => {
483
603
  path
484
604
  ]);
485
605
  const { id, testId } = navTreeContext.getProps?.(item, path) ?? {};
606
+ const handleRearrange = useCallback((source, target, closestEdge) => {
607
+ invariant(item.properties.onRearrangeChildren, void 0, {
608
+ F: __dxlog_file,
609
+ L: 246,
610
+ S: void 0,
611
+ A: [
612
+ "item.properties.onRearrangeChildren",
613
+ ""
614
+ ]
615
+ });
616
+ const sourceIndex = collectionItems.findIndex((i) => i.id === source.id);
617
+ const targetIndex = collectionItems.findIndex((i) => i.id === target.id);
618
+ const insertIndex = source.id === target.id ? sourceIndex : targetIndex + (sourceIndex < targetIndex ? closestEdge === "top" ? -1 : 0 : closestEdge === "bottom" ? 1 : 0);
619
+ const nextOrder = arrayMove([
620
+ ...collectionItems
621
+ ], sourceIndex, insertIndex);
622
+ return item.properties.onRearrangeChildren(nextOrder);
623
+ }, [
624
+ collectionItems,
625
+ item.properties.onRearrangeChildren
626
+ ]);
486
627
  return /* @__PURE__ */ React5.createElement("div", {
487
628
  role: "group",
488
629
  className: "contents group/l0c",
@@ -493,15 +634,18 @@ var L0Collection = ({ item, path, parent }) => {
493
634
  key: collectionItem.id,
494
635
  item: collectionItem,
495
636
  parent: item,
496
- path: groupPath
637
+ path: groupPath,
638
+ ...item.properties.onRearrangeChildren && {
639
+ onRearrange: handleRearrange
640
+ }
497
641
  })));
498
642
  };
499
643
  var L0Menu = ({ topLevelItems, pinnedItems, parent, path }) => {
500
644
  return /* @__PURE__ */ React5.createElement(Tabs.Tablist, {
501
- classNames: "group/l0 absolute z-[1] inset-block-0 inline-start-0 rounded-is-lg grid grid-cols-[var(--l0-size)] grid-rows-[1fr_min-content_var(--l0-size)] contain-layout !is-[--l0-size] bg-baseSurface border-ie border-separator app-drag"
502
- }, /* @__PURE__ */ React5.createElement("div", {
645
+ classNames: "group/l0 absolute z-[1] inset-block-0 inline-start-0 rounded-is-lg grid grid-cols-[var(--l0-size)] grid-rows-[1fr_min-content_var(--l0-size)] contain-layout !is-[--l0-size] bg-baseSurface border-ie border-separator app-drag pbe-[env(safe-area-inset-bottom)]"
646
+ }, /* @__PURE__ */ React5.createElement(ScrollArea.Root, null, /* @__PURE__ */ React5.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React5.createElement("div", {
503
647
  role: "none",
504
- className: 'grid auto-rows-[calc(var(--l0-size)-.5rem)] min-bs-0 !overflow-y-auto plb-1 [body[data-platform="darwin"]_&]:pbs-[calc(30px+0.25rem)]'
648
+ className: 'grid auto-rows-[calc(var(--l0-size)-.5rem)] plb-1 [body[data-platform="darwin"]_&]:pbs-[calc(30px+0.25rem)] [body[data-platform="ios"]_&]:pbs-[max(env(safe-area-inset-top),0.25rem)]'
505
649
  }, topLevelItems.map((item) => {
506
650
  if (l0ItemType(item) === "collection") {
507
651
  return /* @__PURE__ */ React5.createElement(L0Collection, {
@@ -518,7 +662,9 @@ var L0Menu = ({ topLevelItems, pinnedItems, parent, path }) => {
518
662
  path
519
663
  });
520
664
  }
521
- })), /* @__PURE__ */ React5.createElement("div", {
665
+ })), /* @__PURE__ */ React5.createElement(ScrollArea.Scrollbar, {
666
+ orientation: "vertical"
667
+ }, /* @__PURE__ */ React5.createElement(ScrollArea.Thumb, null)))), /* @__PURE__ */ React5.createElement("div", {
522
668
  role: "none",
523
669
  className: "grid grid-cols-1 auto-rows-[--rail-action] pbs-2"
524
670
  }, pinnedItems.filter((item) => l0ItemType(item) !== "collection").map((item) => /* @__PURE__ */ React5.createElement(L0Item, {
@@ -542,18 +688,19 @@ var L0Menu = ({ topLevelItems, pinnedItems, parent, path }) => {
542
688
  // packages/plugins/plugin-navtree/src/components/L1Panels.tsx
543
689
  import React8, { useMemo as useMemo3 } from "react";
544
690
  import { useLayout } from "@dxos/app-framework";
545
- import { toLocalizedString as toLocalizedString5, useTranslation as useTranslation6 } from "@dxos/react-ui";
691
+ import { IconButton as IconButton2, toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
546
692
  import { Tree } from "@dxos/react-ui-list";
547
693
  import { Tabs as Tabs2 } from "@dxos/react-ui-tabs";
694
+ import { hoverableControlItem as hoverableControlItem2, hoverableOpenControlItem as hoverableOpenControlItem2, mx as mx5 } from "@dxos/react-ui-theme";
548
695
 
549
696
  // packages/plugins/plugin-navtree/src/components/NavTreeItemColumns.tsx
550
697
  import React7, { Fragment, memo } from "react";
551
698
  import { isAction as isAction3 } from "@dxos/app-graph";
552
- import { Popover, toLocalizedString as toLocalizedString4, Treegrid, useTranslation as useTranslation5 } from "@dxos/react-ui";
699
+ import { Popover as Popover2, toLocalizedString as toLocalizedString5, Treegrid, useTranslation as useTranslation6 } from "@dxos/react-ui";
553
700
 
554
701
  // packages/plugins/plugin-navtree/src/components/NavTreeItemAction.tsx
555
- import React6, { useRef } from "react";
556
- import { useTranslation as useTranslation4, toLocalizedString as toLocalizedString3, IconButton } from "@dxos/react-ui";
702
+ import React6, { useRef as useRef2 } from "react";
703
+ import { useTranslation as useTranslation5, toLocalizedString as toLocalizedString4, IconButton } from "@dxos/react-ui";
557
704
  import { DropdownMenu, MenuProvider } from "@dxos/react-ui-menu";
558
705
  import { hoverableControlItem, hoverableOpenControlItem, mx as mx4 } from "@dxos/react-ui-theme";
559
706
  var fallbackIcon = "ph--placeholder--regular";
@@ -562,8 +709,8 @@ var actionButtonProps = {
562
709
  density: "fine"
563
710
  };
564
711
  var NavTreeItemActionDropdownMenu = ({ label, icon, testId, menuActions, onAction }) => {
565
- const { t } = useTranslation4(NAVTREE_PLUGIN);
566
- const suppressNextTooltip = useRef(false);
712
+ const { t } = useTranslation5(NAVTREE_PLUGIN);
713
+ const suppressNextTooltip = useRef2(false);
567
714
  return /* @__PURE__ */ React6.createElement(MenuProvider, {
568
715
  onAction
569
716
  }, /* @__PURE__ */ React6.createElement(DropdownMenu.Root, {
@@ -577,7 +724,7 @@ var NavTreeItemActionDropdownMenu = ({ label, icon, testId, menuActions, onActio
577
724
  variant: "ghost",
578
725
  icon: icon ?? fallbackIcon,
579
726
  iconOnly: true,
580
- label: toLocalizedString3(label, t),
727
+ label: toLocalizedString4(label, t),
581
728
  "data-testid": testId,
582
729
  suppressNextTooltip
583
730
  }))));
@@ -609,9 +756,9 @@ var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, tes
609
756
  });
610
757
  };
611
758
  var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) => {
612
- const { t } = useTranslation4(NAVTREE_PLUGIN);
759
+ const { t } = useTranslation5(NAVTREE_PLUGIN);
613
760
  const monolithicAction = menuActions?.length === 1 && menuActions[0];
614
- const baseLabel = toLocalizedString3(monolithicAction ? monolithicAction.properties.label : props.label, t);
761
+ const baseLabel = toLocalizedString4(monolithicAction ? monolithicAction.properties.label : props.label, t);
615
762
  return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React6.createElement(NavTreeItemMonolithicAction, {
616
763
  baseLabel,
617
764
  parent: node,
@@ -632,7 +779,7 @@ var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) =>
632
779
 
633
780
  // packages/plugins/plugin-navtree/src/components/NavTreeItemColumns.tsx
634
781
  var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
635
- const { t } = useTranslation5(NAVTREE_PLUGIN);
782
+ const { t } = useTranslation6(NAVTREE_PLUGIN);
636
783
  const { getActions: getActions2, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
637
784
  const level = path.length - 2;
638
785
  const { actions: _actions, groupedActions } = getActions2(item);
@@ -640,7 +787,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
640
787
  const actions = (primaryAction?.properties?.disposition === "toolbar" ? secondaryActions : _actions).flatMap((action) => isAction3(action) ? [
641
788
  action
642
789
  ] : []).filter((action) => !action.properties?.hidden);
643
- const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
790
+ const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover2.Anchor : Fragment;
644
791
  useLoadDescendents(item);
645
792
  useLoadDescendents(primaryAction && !isAction3(primaryAction) ? primaryAction : void 0);
646
793
  return /* @__PURE__ */ React7.createElement("div", {
@@ -648,7 +795,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
648
795
  className: "contents app-no-drag"
649
796
  }, primaryAction?.properties?.disposition === "toolbar" && !primaryAction?.properties?.disabled ? /* @__PURE__ */ React7.createElement(NavTreeItemAction, {
650
797
  testId: primaryAction.properties?.testId,
651
- label: toLocalizedString4(primaryAction.properties?.label, t),
798
+ label: toLocalizedString5(primaryAction.properties?.label, t),
652
799
  icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
653
800
  parent: item,
654
801
  monolithic: isAction3(primaryAction),
@@ -672,15 +819,15 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
672
819
  });
673
820
 
674
821
  // packages/plugins/plugin-navtree/src/components/L1Panels.tsx
675
- var L1Panel = ({ item, path, currentItemId }) => {
822
+ var L1Panel = ({ item, path, currentItemId, onBack }) => {
676
823
  const layout = useLayout();
677
824
  const navTreeContext = useNavTreeContext();
678
- const { t } = useTranslation6(NAVTREE_PLUGIN);
825
+ const { t } = useTranslation7(NAVTREE_PLUGIN);
679
826
  return /* @__PURE__ */ React8.createElement(Tabs2.Tabpanel, {
680
827
  key: item.id,
681
828
  value: item.id,
682
829
  classNames: [
683
- "absolute inset-block-0 inline-end-0 is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr]",
830
+ "absolute inset-block-0 inline-end-0 is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr] pbs-[env(safe-area-inset-top)]",
684
831
  item.id === currentItemId && "grid"
685
832
  ],
686
833
  tabIndex: -1,
@@ -689,9 +836,18 @@ var L1Panel = ({ item, path, currentItemId }) => {
689
836
  }
690
837
  }, item.id === currentItemId && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("h2", {
691
838
  className: "flex items-center border-be border-separator pis-4 app-drag"
692
- }, /* @__PURE__ */ React8.createElement("span", {
839
+ }, item.properties.disposition === "pin-end" && /* @__PURE__ */ React8.createElement(IconButton2, {
840
+ label: t("back label"),
841
+ iconOnly: true,
842
+ icon: "ph--caret-left--regular",
843
+ size: 5,
844
+ density: "fine",
845
+ variant: "ghost",
846
+ classNames: mx5("shrink-0 mie-2 !p-0", "pointer-fine:pli-1", hoverableControlItem2, hoverableOpenControlItem2),
847
+ onClick: onBack
848
+ }), /* @__PURE__ */ React8.createElement("span", {
693
849
  className: "flex-1 truncate cursor-default"
694
- }, toLocalizedString5(item.properties.label, t)), /* @__PURE__ */ React8.createElement(NavTreeItemColumns, {
850
+ }, toLocalizedString6(item.properties.label, t)), /* @__PURE__ */ React8.createElement(NavTreeItemColumns, {
695
851
  path,
696
852
  item,
697
853
  open: true
@@ -727,7 +883,7 @@ var L1PanelCollection = ({ item, path, currentItemId }) => {
727
883
  currentItemId
728
884
  })));
729
885
  };
730
- var L1Panels = ({ topLevelItems, path, currentItemId }) => {
886
+ var L1Panels = ({ topLevelItems, path, currentItemId, onBack }) => {
731
887
  return /* @__PURE__ */ React8.createElement(React8.Fragment, null, topLevelItems.map((item) => {
732
888
  const type = l0ItemType(item);
733
889
  switch (type) {
@@ -743,7 +899,8 @@ var L1Panels = ({ topLevelItems, path, currentItemId }) => {
743
899
  key: item.id,
744
900
  item,
745
901
  path,
746
- currentItemId
902
+ currentItemId,
903
+ onBack
747
904
  });
748
905
  default:
749
906
  return null;
@@ -754,8 +911,8 @@ var L1Panels = ({ topLevelItems, path, currentItemId }) => {
754
911
  // packages/plugins/plugin-navtree/src/components/NavTree.tsx
755
912
  var NAV_TREE_ITEM = "NavTreeItem";
756
913
  var NavTree = ({ id, root }) => {
757
- const { getItems, tab } = useNavTreeContext();
758
- const topLevelActions = getItems(root, "item");
914
+ const { tab, getItems, onBack } = useNavTreeContext();
915
+ const topLevelActions = getItems(root, "item").toSorted((a, b) => byPosition(a.properties, b.properties));
759
916
  const topLevelCollections = getItems(root, "collection");
760
917
  const topLevelWorkspaces = getItems(root, "workspace");
761
918
  const topLevelNavigation = getItems(root, "navigation");
@@ -799,7 +956,8 @@ var NavTree = ({ id, root }) => {
799
956
  }), /* @__PURE__ */ React9.createElement(L1Panels, {
800
957
  topLevelItems,
801
958
  path,
802
- currentItemId: tab
959
+ currentItemId: tab,
960
+ onBack
803
961
  }))
804
962
  );
805
963
  };
@@ -809,8 +967,8 @@ import { lazy } from "@dxos/app-framework";
809
967
  var AppGraphBuilder = lazy(() => import("./app-graph-builder-BL7LRXCM.mjs"));
810
968
  var IntentResolver = lazy(() => import("./intent-resolver-U25VBFH3.mjs"));
811
969
  var Keyboard2 = lazy(() => import("./keyboard-MUBRTPI5.mjs"));
812
- var ReactSurface = lazy(() => import("./react-surface-LNRTNSM6.mjs"));
813
- var State = lazy(() => import("./state-65TQKYX7.mjs"));
970
+ var ReactSurface = lazy(() => import("./react-surface-SG4QBA2U.mjs"));
971
+ var State = lazy(() => import("./state-IEFQTUPG.mjs"));
814
972
 
815
973
  // packages/plugins/plugin-navtree/src/components/NavTreeContainer.tsx
816
974
  var NODE_TYPE = "dxos/app-graph/node";
@@ -838,7 +996,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
838
996
  return graph.nodes(node ?? graph.root, {
839
997
  filter: (node2) => {
840
998
  return untracked(() => {
841
- const action = isActionLike2(node2);
999
+ const action = isAction4(node2);
842
1000
  if (!disposition) {
843
1001
  return !action || node2.properties.disposition === "item";
844
1002
  }
@@ -858,7 +1016,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
858
1016
  parentOf,
859
1017
  icon: node.properties.icon,
860
1018
  disabled: node.properties.disabled,
861
- className: mx5(node.properties.modified && "italic", node.properties.className),
1019
+ className: mx6(node.properties.modified && "italic", node.properties.className),
862
1020
  headingClassName: node.properties.headingClassName,
863
1021
  testId: node.properties.testId
864
1022
  };
@@ -895,7 +1053,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
895
1053
  }));
896
1054
  if (layout.active.length === 0) {
897
1055
  const [item] = getItems(node).filter((node2) => !isActionLike2(node2));
898
- if (item) {
1056
+ if (item && item.data) {
899
1057
  await dispatch(createIntent5(LayoutAction4.Open, {
900
1058
  part: "main",
901
1059
  subject: [
@@ -978,7 +1136,15 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
978
1136
  isCurrent,
979
1137
  isLg
980
1138
  ]);
981
- useEffect2(() => {
1139
+ const onBack = useCallback2(() => dispatch(createIntent5(LayoutAction4.RevertWorkspace, {
1140
+ part: "workspace",
1141
+ options: {
1142
+ revert: true
1143
+ }
1144
+ })), [
1145
+ dispatch
1146
+ ]);
1147
+ useEffect3(() => {
982
1148
  return monitorForElements({
983
1149
  canMonitor: ({ source }) => isTreeData(source.data),
984
1150
  onDrop: ({ location, source }) => {
@@ -1003,7 +1169,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1003
1169
  switch (operation) {
1004
1170
  case "rearrange": {
1005
1171
  const nextItems = sourceItems.map(({ data }) => data);
1006
- arrayMove(nextItems, sourceIndex, targetIndex);
1172
+ arrayMove2(nextItems, sourceIndex, targetIndex);
1007
1173
  void sourceParent?.properties.onRearrangeChildren?.(nextItems);
1008
1174
  break;
1009
1175
  }
@@ -1031,6 +1197,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1031
1197
  const navTreeContextValue = useMemo5(() => ({
1032
1198
  tab,
1033
1199
  onTabChange,
1200
+ onBack,
1034
1201
  getActions: getActions2,
1035
1202
  loadDescendents,
1036
1203
  renderItemEnd,
@@ -1046,6 +1213,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1046
1213
  }), [
1047
1214
  tab,
1048
1215
  onTabChange,
1216
+ onBack,
1049
1217
  getActions2,
1050
1218
  loadDescendents,
1051
1219
  renderItemEnd,
@@ -1067,21 +1235,6 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1067
1235
  }));
1068
1236
  });
1069
1237
 
1070
- // packages/plugins/plugin-navtree/src/components/NavTreeDocumentTitle.tsx
1071
- import { useEffect as useEffect3 } from "react";
1072
- import { toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
1073
- var NavTreeDocumentTitle = ({ node }) => {
1074
- const { t } = useTranslation7(NAVTREE_PLUGIN);
1075
- useEffect3(() => {
1076
- document.title = node ? toLocalizedString6(node.properties.label, t) : t("current app name", {
1077
- ns: "appkit"
1078
- });
1079
- }, [
1080
- node?.properties?.label
1081
- ]);
1082
- return null;
1083
- };
1084
-
1085
1238
  export {
1086
1239
  CommandsDialogContent,
1087
1240
  CommandsTrigger,
@@ -1106,4 +1259,4 @@ export {
1106
1259
  ReactSurface,
1107
1260
  State
1108
1261
  };
1109
- //# sourceMappingURL=chunk-54MPRXMH.mjs.map
1262
+ //# sourceMappingURL=chunk-GXNOX2XZ.mjs.map