@dxos/plugin-navtree 0.7.5-labs.c0e040f → 0.7.5-labs.d199c0f

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 (52) hide show
  1. package/dist/lib/browser/{chunk-SKZPY4LJ.mjs → chunk-GXNOX2XZ.mjs} +222 -80
  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-OZDS36WN.mjs → react-surface-SG4QBA2U.mjs} +2 -2
  7. package/dist/types/src/capabilities/app-graph-builder.d.ts +110 -110
  8. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  9. package/dist/types/src/capabilities/index.d.ts +124 -124
  10. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  11. package/dist/types/src/components/CommandsDialog.d.ts +1 -2
  12. package/dist/types/src/components/CommandsDialog.d.ts.map +1 -1
  13. package/dist/types/src/components/CommandsTrigger.d.ts +1 -2
  14. package/dist/types/src/components/CommandsTrigger.d.ts.map +1 -1
  15. package/dist/types/src/components/HaloButton.d.ts +1 -2
  16. package/dist/types/src/components/HaloButton.d.ts.map +1 -1
  17. package/dist/types/src/components/HaloButton.stories.d.ts +1 -2
  18. package/dist/types/src/components/HaloButton.stories.d.ts.map +1 -1
  19. package/dist/types/src/components/L0Menu.d.ts +1 -2
  20. package/dist/types/src/components/L0Menu.d.ts.map +1 -1
  21. package/dist/types/src/components/L1Panels.d.ts +8 -3
  22. package/dist/types/src/components/L1Panels.d.ts.map +1 -1
  23. package/dist/types/src/components/NavTree.d.ts +1 -2
  24. package/dist/types/src/components/NavTree.d.ts.map +1 -1
  25. package/dist/types/src/components/NavTreeContainer.d.ts +1 -1
  26. package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
  27. package/dist/types/src/components/NavTreeItemAction.d.ts +4 -4
  28. package/dist/types/src/components/NavTreeItemAction.d.ts.map +1 -1
  29. package/dist/types/src/components/NavTreeItemAction.stories.d.ts +2 -2
  30. package/dist/types/src/components/NavTreeItemColumns.d.ts +1 -1
  31. package/dist/types/src/components/NavTreeItemColumns.d.ts.map +1 -1
  32. package/dist/types/src/components/NotchStart.d.ts +1 -2
  33. package/dist/types/src/components/NotchStart.d.ts.map +1 -1
  34. package/dist/types/src/components/types.d.ts +2 -1
  35. package/dist/types/src/components/types.d.ts.map +1 -1
  36. package/dist/types/src/experimental/Tree.d.ts +8 -8
  37. package/dist/types/src/experimental/Tree.d.ts.map +1 -1
  38. package/dist/types/src/experimental/Tree.stories.d.ts +2 -3
  39. package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
  40. package/dist/types/src/stories/StorybookNavTree.d.ts +1 -2
  41. package/dist/types/src/stories/StorybookNavTree.d.ts.map +1 -1
  42. package/dist/types/src/util.d.ts +1 -1
  43. package/package.json +31 -30
  44. package/src/NavTreePlugin.tsx +2 -2
  45. package/src/components/L0Menu.tsx +176 -62
  46. package/src/components/L1Panels.tsx +25 -6
  47. package/src/components/NavTree.tsx +3 -3
  48. package/src/components/NavTreeContainer.tsx +9 -2
  49. package/src/components/types.ts +12 -10
  50. package/src/hooks.ts +1 -1
  51. package/dist/lib/browser/chunk-SKZPY4LJ.mjs.map +0 -7
  52. /package/dist/lib/browser/{react-surface-OZDS36WN.mjs.map → react-surface-SG4QBA2U.mjs.map} +0 -0
@@ -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,48 +464,130 @@ var L0Item = ({ item, parent, path, pinned }) => {
437
464
  } : {
438
465
  onClick: handleClick
439
466
  };
440
- const localizedString = toLocalizedString2(item.properties.label, t);
467
+ const localizedString = toLocalizedString3(item.properties.label, t);
441
468
  const hue = item.properties.hue ?? null;
442
- const avatarValue = useMemo2(() => type === "tab" ? getFirstTwoRenderableChars(localizedString).join("") : [], [
469
+ const avatarValue = useMemo2(() => type === "tab" ? getFirstTwoRenderableChars(localizedString).join("").toUpperCase() : [], [
443
470
  type,
444
471
  item.properties.label,
445
472
  t
446
473
  ]);
447
- return /* @__PURE__ */ React5.createElement(Tooltip.Root, {
448
- delayDuration: 0
449
- }, /* @__PURE__ */ React5.createElement(Tooltip.Trigger, {
450
- asChild: true
451
- }, /* @__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, {
452
548
  ...rootProps,
453
549
  "data-type": type,
454
- className: mx3('group/l0i dx-focus-ring-group grid overflow-hidden relative data[type!="collection"]:cursor-pointer app-no-drag', l0Breakpoints[item.properties.l0Breakpoint])
455
- }, type !== "collection" && /* @__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", {
456
553
  role: "none",
457
- className: mx3("absolute -z-[1] 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"),
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"),
458
556
  ...hue && {
459
557
  style: {
460
558
  background: `var(--dx-${hue}Surface)`
461
559
  }
462
560
  }
463
- }), /* @__PURE__ */ React5.createElement("div", {
464
- role: "none",
465
- className: "hidden group-aria-selected/l0i:block absolute inline-start-0 inset-block-4 is-1 bg-accentSurface rounded-ie"
466
- }), type === "tab" && item.properties.disposition !== "pin-end" ? /* @__PURE__ */ React5.createElement("span", {
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", {
467
567
  role: "img",
468
568
  className: "place-self-center text-3xl font-light",
469
- ...hue && {
470
- style: {
471
- color: `var(--dx-${hue}SurfaceText)`
472
- }
473
- }
569
+ ...hueFgStyle
474
570
  }, avatarValue) : item.properties.icon && /* @__PURE__ */ React5.createElement(Icon2, {
475
- icon: item.properties.icon,
571
+ icon: "ph--planet--regular",
476
572
  size: pinned ? 5 : 7,
477
- 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"
478
578
  }), /* @__PURE__ */ React5.createElement("span", {
479
579
  id: `${item.id}__label`,
480
580
  className: "sr-only"
481
- }, 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, {
482
591
  side: "right"
483
592
  }, localizedString, /* @__PURE__ */ React5.createElement(Tooltip.Arrow, null))));
484
593
  };
@@ -494,6 +603,27 @@ var L0Collection = ({ item, path, parent }) => {
494
603
  path
495
604
  ]);
496
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
+ ]);
497
627
  return /* @__PURE__ */ React5.createElement("div", {
498
628
  role: "group",
499
629
  className: "contents group/l0c",
@@ -504,15 +634,18 @@ var L0Collection = ({ item, path, parent }) => {
504
634
  key: collectionItem.id,
505
635
  item: collectionItem,
506
636
  parent: item,
507
- path: groupPath
637
+ path: groupPath,
638
+ ...item.properties.onRearrangeChildren && {
639
+ onRearrange: handleRearrange
640
+ }
508
641
  })));
509
642
  };
510
643
  var L0Menu = ({ topLevelItems, pinnedItems, parent, path }) => {
511
644
  return /* @__PURE__ */ React5.createElement(Tabs.Tablist, {
512
- 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"
513
- }, /* @__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", {
514
647
  role: "none",
515
- 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)]'
516
649
  }, topLevelItems.map((item) => {
517
650
  if (l0ItemType(item) === "collection") {
518
651
  return /* @__PURE__ */ React5.createElement(L0Collection, {
@@ -529,7 +662,9 @@ var L0Menu = ({ topLevelItems, pinnedItems, parent, path }) => {
529
662
  path
530
663
  });
531
664
  }
532
- })), /* @__PURE__ */ React5.createElement("div", {
665
+ })), /* @__PURE__ */ React5.createElement(ScrollArea.Scrollbar, {
666
+ orientation: "vertical"
667
+ }, /* @__PURE__ */ React5.createElement(ScrollArea.Thumb, null)))), /* @__PURE__ */ React5.createElement("div", {
533
668
  role: "none",
534
669
  className: "grid grid-cols-1 auto-rows-[--rail-action] pbs-2"
535
670
  }, pinnedItems.filter((item) => l0ItemType(item) !== "collection").map((item) => /* @__PURE__ */ React5.createElement(L0Item, {
@@ -553,18 +688,19 @@ var L0Menu = ({ topLevelItems, pinnedItems, parent, path }) => {
553
688
  // packages/plugins/plugin-navtree/src/components/L1Panels.tsx
554
689
  import React8, { useMemo as useMemo3 } from "react";
555
690
  import { useLayout } from "@dxos/app-framework";
556
- 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";
557
692
  import { Tree } from "@dxos/react-ui-list";
558
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";
559
695
 
560
696
  // packages/plugins/plugin-navtree/src/components/NavTreeItemColumns.tsx
561
697
  import React7, { Fragment, memo } from "react";
562
698
  import { isAction as isAction3 } from "@dxos/app-graph";
563
- 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";
564
700
 
565
701
  // packages/plugins/plugin-navtree/src/components/NavTreeItemAction.tsx
566
- import React6, { useRef } from "react";
567
- 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";
568
704
  import { DropdownMenu, MenuProvider } from "@dxos/react-ui-menu";
569
705
  import { hoverableControlItem, hoverableOpenControlItem, mx as mx4 } from "@dxos/react-ui-theme";
570
706
  var fallbackIcon = "ph--placeholder--regular";
@@ -573,8 +709,8 @@ var actionButtonProps = {
573
709
  density: "fine"
574
710
  };
575
711
  var NavTreeItemActionDropdownMenu = ({ label, icon, testId, menuActions, onAction }) => {
576
- const { t } = useTranslation4(NAVTREE_PLUGIN);
577
- const suppressNextTooltip = useRef(false);
712
+ const { t } = useTranslation5(NAVTREE_PLUGIN);
713
+ const suppressNextTooltip = useRef2(false);
578
714
  return /* @__PURE__ */ React6.createElement(MenuProvider, {
579
715
  onAction
580
716
  }, /* @__PURE__ */ React6.createElement(DropdownMenu.Root, {
@@ -588,7 +724,7 @@ var NavTreeItemActionDropdownMenu = ({ label, icon, testId, menuActions, onActio
588
724
  variant: "ghost",
589
725
  icon: icon ?? fallbackIcon,
590
726
  iconOnly: true,
591
- label: toLocalizedString3(label, t),
727
+ label: toLocalizedString4(label, t),
592
728
  "data-testid": testId,
593
729
  suppressNextTooltip
594
730
  }))));
@@ -620,9 +756,9 @@ var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, tes
620
756
  });
621
757
  };
622
758
  var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) => {
623
- const { t } = useTranslation4(NAVTREE_PLUGIN);
759
+ const { t } = useTranslation5(NAVTREE_PLUGIN);
624
760
  const monolithicAction = menuActions?.length === 1 && menuActions[0];
625
- const baseLabel = toLocalizedString3(monolithicAction ? monolithicAction.properties.label : props.label, t);
761
+ const baseLabel = toLocalizedString4(monolithicAction ? monolithicAction.properties.label : props.label, t);
626
762
  return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React6.createElement(NavTreeItemMonolithicAction, {
627
763
  baseLabel,
628
764
  parent: node,
@@ -643,7 +779,7 @@ var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) =>
643
779
 
644
780
  // packages/plugins/plugin-navtree/src/components/NavTreeItemColumns.tsx
645
781
  var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
646
- const { t } = useTranslation5(NAVTREE_PLUGIN);
782
+ const { t } = useTranslation6(NAVTREE_PLUGIN);
647
783
  const { getActions: getActions2, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
648
784
  const level = path.length - 2;
649
785
  const { actions: _actions, groupedActions } = getActions2(item);
@@ -651,7 +787,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
651
787
  const actions = (primaryAction?.properties?.disposition === "toolbar" ? secondaryActions : _actions).flatMap((action) => isAction3(action) ? [
652
788
  action
653
789
  ] : []).filter((action) => !action.properties?.hidden);
654
- 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;
655
791
  useLoadDescendents(item);
656
792
  useLoadDescendents(primaryAction && !isAction3(primaryAction) ? primaryAction : void 0);
657
793
  return /* @__PURE__ */ React7.createElement("div", {
@@ -659,7 +795,7 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
659
795
  className: "contents app-no-drag"
660
796
  }, primaryAction?.properties?.disposition === "toolbar" && !primaryAction?.properties?.disabled ? /* @__PURE__ */ React7.createElement(NavTreeItemAction, {
661
797
  testId: primaryAction.properties?.testId,
662
- label: toLocalizedString4(primaryAction.properties?.label, t),
798
+ label: toLocalizedString5(primaryAction.properties?.label, t),
663
799
  icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
664
800
  parent: item,
665
801
  monolithic: isAction3(primaryAction),
@@ -683,15 +819,15 @@ var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open }) => {
683
819
  });
684
820
 
685
821
  // packages/plugins/plugin-navtree/src/components/L1Panels.tsx
686
- var L1Panel = ({ item, path, currentItemId }) => {
822
+ var L1Panel = ({ item, path, currentItemId, onBack }) => {
687
823
  const layout = useLayout();
688
824
  const navTreeContext = useNavTreeContext();
689
- const { t } = useTranslation6(NAVTREE_PLUGIN);
825
+ const { t } = useTranslation7(NAVTREE_PLUGIN);
690
826
  return /* @__PURE__ */ React8.createElement(Tabs2.Tabpanel, {
691
827
  key: item.id,
692
828
  value: item.id,
693
829
  classNames: [
694
- "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)]",
695
831
  item.id === currentItemId && "grid"
696
832
  ],
697
833
  tabIndex: -1,
@@ -700,9 +836,18 @@ var L1Panel = ({ item, path, currentItemId }) => {
700
836
  }
701
837
  }, item.id === currentItemId && /* @__PURE__ */ React8.createElement(React8.Fragment, null, /* @__PURE__ */ React8.createElement("h2", {
702
838
  className: "flex items-center border-be border-separator pis-4 app-drag"
703
- }, /* @__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", {
704
849
  className: "flex-1 truncate cursor-default"
705
- }, toLocalizedString5(item.properties.label, t)), /* @__PURE__ */ React8.createElement(NavTreeItemColumns, {
850
+ }, toLocalizedString6(item.properties.label, t)), /* @__PURE__ */ React8.createElement(NavTreeItemColumns, {
706
851
  path,
707
852
  item,
708
853
  open: true
@@ -738,7 +883,7 @@ var L1PanelCollection = ({ item, path, currentItemId }) => {
738
883
  currentItemId
739
884
  })));
740
885
  };
741
- var L1Panels = ({ topLevelItems, path, currentItemId }) => {
886
+ var L1Panels = ({ topLevelItems, path, currentItemId, onBack }) => {
742
887
  return /* @__PURE__ */ React8.createElement(React8.Fragment, null, topLevelItems.map((item) => {
743
888
  const type = l0ItemType(item);
744
889
  switch (type) {
@@ -754,7 +899,8 @@ var L1Panels = ({ topLevelItems, path, currentItemId }) => {
754
899
  key: item.id,
755
900
  item,
756
901
  path,
757
- currentItemId
902
+ currentItemId,
903
+ onBack
758
904
  });
759
905
  default:
760
906
  return null;
@@ -765,8 +911,8 @@ var L1Panels = ({ topLevelItems, path, currentItemId }) => {
765
911
  // packages/plugins/plugin-navtree/src/components/NavTree.tsx
766
912
  var NAV_TREE_ITEM = "NavTreeItem";
767
913
  var NavTree = ({ id, root }) => {
768
- const { getItems, tab } = useNavTreeContext();
769
- 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));
770
916
  const topLevelCollections = getItems(root, "collection");
771
917
  const topLevelWorkspaces = getItems(root, "workspace");
772
918
  const topLevelNavigation = getItems(root, "navigation");
@@ -810,7 +956,8 @@ var NavTree = ({ id, root }) => {
810
956
  }), /* @__PURE__ */ React9.createElement(L1Panels, {
811
957
  topLevelItems,
812
958
  path,
813
- currentItemId: tab
959
+ currentItemId: tab,
960
+ onBack
814
961
  }))
815
962
  );
816
963
  };
@@ -820,7 +967,7 @@ import { lazy } from "@dxos/app-framework";
820
967
  var AppGraphBuilder = lazy(() => import("./app-graph-builder-BL7LRXCM.mjs"));
821
968
  var IntentResolver = lazy(() => import("./intent-resolver-U25VBFH3.mjs"));
822
969
  var Keyboard2 = lazy(() => import("./keyboard-MUBRTPI5.mjs"));
823
- var ReactSurface = lazy(() => import("./react-surface-OZDS36WN.mjs"));
970
+ var ReactSurface = lazy(() => import("./react-surface-SG4QBA2U.mjs"));
824
971
  var State = lazy(() => import("./state-IEFQTUPG.mjs"));
825
972
 
826
973
  // packages/plugins/plugin-navtree/src/components/NavTreeContainer.tsx
@@ -849,7 +996,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
849
996
  return graph.nodes(node ?? graph.root, {
850
997
  filter: (node2) => {
851
998
  return untracked(() => {
852
- const action = isActionLike2(node2);
999
+ const action = isAction4(node2);
853
1000
  if (!disposition) {
854
1001
  return !action || node2.properties.disposition === "item";
855
1002
  }
@@ -869,7 +1016,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
869
1016
  parentOf,
870
1017
  icon: node.properties.icon,
871
1018
  disabled: node.properties.disabled,
872
- className: mx5(node.properties.modified && "italic", node.properties.className),
1019
+ className: mx6(node.properties.modified && "italic", node.properties.className),
873
1020
  headingClassName: node.properties.headingClassName,
874
1021
  testId: node.properties.testId
875
1022
  };
@@ -906,7 +1053,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
906
1053
  }));
907
1054
  if (layout.active.length === 0) {
908
1055
  const [item] = getItems(node).filter((node2) => !isActionLike2(node2));
909
- if (item) {
1056
+ if (item && item.data) {
910
1057
  await dispatch(createIntent5(LayoutAction4.Open, {
911
1058
  part: "main",
912
1059
  subject: [
@@ -989,7 +1136,15 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
989
1136
  isCurrent,
990
1137
  isLg
991
1138
  ]);
992
- useEffect2(() => {
1139
+ const onBack = useCallback2(() => dispatch(createIntent5(LayoutAction4.RevertWorkspace, {
1140
+ part: "workspace",
1141
+ options: {
1142
+ revert: true
1143
+ }
1144
+ })), [
1145
+ dispatch
1146
+ ]);
1147
+ useEffect3(() => {
993
1148
  return monitorForElements({
994
1149
  canMonitor: ({ source }) => isTreeData(source.data),
995
1150
  onDrop: ({ location, source }) => {
@@ -1014,7 +1169,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1014
1169
  switch (operation) {
1015
1170
  case "rearrange": {
1016
1171
  const nextItems = sourceItems.map(({ data }) => data);
1017
- arrayMove(nextItems, sourceIndex, targetIndex);
1172
+ arrayMove2(nextItems, sourceIndex, targetIndex);
1018
1173
  void sourceParent?.properties.onRearrangeChildren?.(nextItems);
1019
1174
  break;
1020
1175
  }
@@ -1042,6 +1197,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1042
1197
  const navTreeContextValue = useMemo5(() => ({
1043
1198
  tab,
1044
1199
  onTabChange,
1200
+ onBack,
1045
1201
  getActions: getActions2,
1046
1202
  loadDescendents,
1047
1203
  renderItemEnd,
@@ -1057,6 +1213,7 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1057
1213
  }), [
1058
1214
  tab,
1059
1215
  onTabChange,
1216
+ onBack,
1060
1217
  getActions2,
1061
1218
  loadDescendents,
1062
1219
  renderItemEnd,
@@ -1078,21 +1235,6 @@ var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar })
1078
1235
  }));
1079
1236
  });
1080
1237
 
1081
- // packages/plugins/plugin-navtree/src/components/NavTreeDocumentTitle.tsx
1082
- import { useEffect as useEffect3 } from "react";
1083
- import { toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
1084
- var NavTreeDocumentTitle = ({ node }) => {
1085
- const { t } = useTranslation7(NAVTREE_PLUGIN);
1086
- useEffect3(() => {
1087
- document.title = node ? toLocalizedString6(node.properties.label, t) : t("current app name", {
1088
- ns: "appkit"
1089
- });
1090
- }, [
1091
- node?.properties?.label
1092
- ]);
1093
- return null;
1094
- };
1095
-
1096
1238
  export {
1097
1239
  CommandsDialogContent,
1098
1240
  CommandsTrigger,
@@ -1117,4 +1259,4 @@ export {
1117
1259
  ReactSurface,
1118
1260
  State
1119
1261
  };
1120
- //# sourceMappingURL=chunk-SKZPY4LJ.mjs.map
1262
+ //# sourceMappingURL=chunk-GXNOX2XZ.mjs.map