@dxos/plugin-deck 0.6.8-main.3be982f → 0.6.8-staging.63bcb81

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.
@@ -26,11 +26,11 @@ var SURFACE_PREFIX = "surface:";
26
26
 
27
27
  // packages/plugins/plugin-deck/src/components/DeckLayout/DeckLayout.tsx
28
28
  import { Sidebar as MenuIcon } from "@phosphor-icons/react";
29
- import React12, { useMemo as useMemo2 } from "react";
29
+ import React12, { useEffect as useEffect5, useMemo as useMemo2, useRef as useRef2 } from "react";
30
30
  import { SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR3, Surface as Surface8, firstIdInPart, usePlugin } from "@dxos/app-framework";
31
31
  import { Button as Button3, Dialog, Main as Main3, Popover as Popover2, useTranslation as useTranslation5 } from "@dxos/react-ui";
32
32
  import { Deck } from "@dxos/react-ui-deck";
33
- import { getSize, mx as mx4 } from "@dxos/react-ui-theme";
33
+ import { getSize } from "@dxos/react-ui-theme";
34
34
 
35
35
  // packages/plugins/plugin-deck/src/components/DeckLayout/ActiveNode.tsx
36
36
  import React from "react";
@@ -390,7 +390,7 @@ var Fullscreen = ({ id }) => {
390
390
 
391
391
  // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
392
392
  import { Plus } from "@phosphor-icons/react";
393
- import React9, { useCallback } from "react";
393
+ import React9, { useCallback, useLayoutEffect, useRef } from "react";
394
394
  import { LayoutAction as LayoutAction2, NavigationAction as NavigationAction2, Surface as Surface6, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
395
395
  import { debounce } from "@dxos/async";
396
396
  import { useGraph as useGraph5 } from "@dxos/plugin-graph";
@@ -412,7 +412,12 @@ var Plank = ({ entry, layoutParts, part, resizeable, flatDeck, searchEnabled, cl
412
412
  const { plankSizing } = useDeckContext();
413
413
  const { graph } = useGraph5();
414
414
  const node = useNode(graph, entry.id);
415
+ const rootElement = useRef(null);
415
416
  const attendableAttrs = createAttendableAttributes2(entry.id);
417
+ const coordinate = {
418
+ part,
419
+ entryId: entry.id
420
+ };
416
421
  const size = plankSizing?.[entry.id];
417
422
  const setSize = useCallback(debounce((newSize) => {
418
423
  void dispatch({
@@ -426,26 +431,37 @@ var Plank = ({ entry, layoutParts, part, resizeable, flatDeck, searchEnabled, cl
426
431
  dispatch,
427
432
  entry.id
428
433
  ]);
429
- const coordinate = {
430
- part,
431
- entryId: entry.id
432
- };
434
+ const handleKeyDown = useCallback((event) => {
435
+ if (event.target === event.currentTarget && event.key === "Escape") {
436
+ rootElement.current?.closest("main")?.focus();
437
+ }
438
+ }, []);
439
+ useLayoutEffect(() => {
440
+ if (scrollIntoView === entry.id) {
441
+ rootElement.current?.scrollIntoView({
442
+ behavior: "smooth",
443
+ inline: "center"
444
+ });
445
+ }
446
+ }, [
447
+ scrollIntoView
448
+ ]);
433
449
  return /* @__PURE__ */ React9.createElement(NaturalPlank.Root, {
434
450
  size,
435
- setSize
436
- }, /* @__PURE__ */ React9.createElement(NaturalPlank.Content, {
451
+ setSize,
452
+ classNames,
437
453
  ...attendableAttrs,
454
+ onKeyDown: handleKeyDown,
455
+ ref: rootElement
456
+ }, /* @__PURE__ */ React9.createElement(NaturalPlank.Content, {
438
457
  classNames: [
439
- !flatDeck && "surface-base",
440
- classNames
441
- ],
442
- scrollIntoViewOnMount: entry.id === scrollIntoView,
443
- suppressAutofocus: entry.id === NAV_ID || !!node?.properties?.managesAutofocus
458
+ !flatDeck && "surface-base"
459
+ ]
444
460
  }, node ? /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(NodePlankHeading, {
461
+ id: entry.id,
462
+ node,
445
463
  layoutPart: coordinate.part,
446
464
  layoutParts,
447
- node,
448
- id: entry.id,
449
465
  popoverAnchorId,
450
466
  flatDeck
451
467
  }), /* @__PURE__ */ React9.createElement(Surface6, {
@@ -583,18 +599,15 @@ var getEffectivePart = (partName, layoutMode) => layoutMode === "solo" && partNa
583
599
 
584
600
  // packages/plugins/plugin-deck/src/util/overscroll.ts
585
601
  import { PLANK_DEFAULTS } from "@dxos/react-ui-deck";
586
- var calculateOverscroll = (layoutMode, sidebarOpen, complementarySidebarOpen, layoutParts, plankSizing, overscroll) => {
587
- if (!(layoutMode === "deck" && overscroll === "centering")) {
588
- return;
589
- }
590
- if (!layoutParts.main || layoutParts.main.length === 0) {
602
+ var calculateOverscroll = (planks, plankSizing, sidebarOpen, complementarySidebarOpen) => {
603
+ if (!planks?.length) {
591
604
  return;
592
605
  }
593
606
  const sidebarWidth = sidebarOpen ? "270px" : "0px";
594
607
  const complementarySidebarWidth = complementarySidebarOpen ? "360px" : "0px";
595
608
  const getPlankSize = (id) => (plankSizing[id] ?? PLANK_DEFAULTS.size).toFixed(2) + "rem";
596
- if (layoutParts.main.length === 1) {
597
- const plank = layoutParts.main[0];
609
+ if (planks.length === 1) {
610
+ const plank = planks[0];
598
611
  const plankSize = getPlankSize(plank.id);
599
612
  const overscrollPadding = `max(0px, calc(((100dvw - ${sidebarWidth} - ${complementarySidebarWidth} - (${plankSize} + 20px)) / 2)))`;
600
613
  return {
@@ -602,25 +615,24 @@ var calculateOverscroll = (layoutMode, sidebarOpen, complementarySidebarOpen, la
602
615
  paddingRight: overscrollPadding
603
616
  };
604
617
  } else {
605
- const firstPlank = layoutParts.main[0];
606
- const firstPlankInlineSize = getPlankSize(firstPlank.id);
607
- const paddingLeft = `max(0px, calc(((100dvw - (${firstPlankInlineSize} + 20px)) / 2) - ${sidebarWidth}))`;
608
- const lastPlank = layoutParts.main[layoutParts.main.length - 1];
609
- const lastPlankInlineSize = getPlankSize(lastPlank.id);
610
- const paddingRight = `max(0px, calc(((100dvw - (${lastPlankInlineSize} + 20px)) / 2) - ${complementarySidebarWidth}))`;
618
+ const first = planks[0];
619
+ const firstSize = getPlankSize(first.id);
620
+ const last = planks[planks.length - 1];
621
+ const lastSize = getPlankSize(last.id);
611
622
  return {
612
- paddingLeft,
613
- paddingRight
623
+ paddingLeft: `max(0px, calc(((100dvw - (${firstSize} + 20px)) / 2) - ${sidebarWidth}))`,
624
+ paddingRight: `max(0px, calc(((100dvw - (${lastSize} + 20px)) / 2) - ${complementarySidebarWidth}))`
614
625
  };
615
626
  }
616
627
  };
617
628
 
618
629
  // packages/plugins/plugin-deck/src/components/DeckLayout/DeckLayout.tsx
619
- var DeckLayout = ({ showHintsFooter, toasts, onDismissToast, flatDeck, attention, layoutParts, slots, overscroll }) => {
630
+ var DeckLayout = ({ layoutParts, attention, toasts, flatDeck, overscroll, showHintsFooter, slots, onDismissToast }) => {
620
631
  const context = useLayout();
621
632
  const { layoutMode, sidebarOpen, complementarySidebarOpen, dialogOpen, dialogContent, dialogBlockAlign, popoverOpen, popoverContent, popoverAnchorId } = context;
622
633
  const { t } = useTranslation5(DECK_PLUGIN);
623
634
  const { plankSizing } = useDeckContext();
635
+ const searchPlugin = usePlugin("dxos.org/plugin/search");
624
636
  const fullScreenSlug = useMemo2(() => firstIdInPart(layoutParts, "fullScreen"), [
625
637
  layoutParts
626
638
  ]);
@@ -632,11 +644,35 @@ var DeckLayout = ({ showHintsFooter, toasts, onDismissToast, flatDeck, attention
632
644
  }, [
633
645
  layoutParts
634
646
  ]);
635
- const searchEnabled = !!usePlugin("dxos.org/plugin/search");
636
647
  const activeId = useMemo2(() => Array.from(attention.attended ?? [])[0], [
637
648
  attention.attended
638
649
  ]);
639
- const overscrollAmount = calculateOverscroll(layoutMode, sidebarOpen, complementarySidebarOpen, layoutParts, plankSizing, overscroll);
650
+ const deckRef = useRef2(null);
651
+ useEffect5(() => {
652
+ if (layoutMode === "deck" && activeId) {
653
+ }
654
+ }, [
655
+ layoutMode,
656
+ activeId
657
+ ]);
658
+ const parts = useMemo2(() => {
659
+ const parts2 = [
660
+ ...layoutParts.main ?? []
661
+ ];
662
+ for (const part of layoutParts.solo ?? []) {
663
+ if (!parts2.find((entry) => entry.id === part.id)) {
664
+ parts2.push(part);
665
+ }
666
+ }
667
+ return parts2;
668
+ }, [
669
+ layoutParts.main,
670
+ layoutParts.solo
671
+ ]);
672
+ const showPlank = (part) => {
673
+ return layoutMode === "deck" || layoutParts.solo?.find((entry) => entry.id === part.id);
674
+ };
675
+ const padding = layoutMode === "deck" && overscroll === "centering" ? calculateOverscroll(layoutParts.main, plankSizing, sidebarOpen, complementarySidebarOpen) : {};
640
676
  if (layoutMode === "fullscreen") {
641
677
  return /* @__PURE__ */ React12.createElement(Fullscreen, {
642
678
  id: fullScreenSlug
@@ -699,57 +735,39 @@ var DeckLayout = ({ showHintsFooter, toasts, onDismissToast, flatDeck, attention
699
735
  id: complementarySlug,
700
736
  layoutParts,
701
737
  flatDeck
702
- }), /* @__PURE__ */ React12.createElement(Main3.Overlay, null), layoutMode === "deck" && layoutParts.main && layoutParts.main.length > 0 && /* @__PURE__ */ React12.createElement(Main3.Content, {
738
+ }), /* @__PURE__ */ React12.createElement(Main3.Overlay, null), parts.length === 0 && /* @__PURE__ */ React12.createElement(Main3.Content, {
739
+ handlesFocus: true
740
+ }, /* @__PURE__ */ React12.createElement(ContentEmpty, null)), parts.length !== 0 && /* @__PURE__ */ React12.createElement(Main3.Content, {
703
741
  bounce: true,
704
- classNames: [
705
- "grid",
706
- "block-end-[--statusbar-size]"
707
- ]
742
+ classNames: "grid block-end-[--statusbar-size]",
743
+ handlesFocus: true
708
744
  }, /* @__PURE__ */ React12.createElement("div", {
709
745
  role: "none",
710
- className: "relative"
711
- }, /* @__PURE__ */ React12.createElement(Deck.Root, {
712
- classNames: mx4("absolute inset-0", !flatDeck && "surface-deck", slots?.wallpaper?.classNames, slots?.deck?.classNames, "transition-[padding] duration-200 ease-in-out"),
713
- style: {
714
- ...overscrollAmount
715
- }
716
- }, layoutParts.main.map((layoutEntry) => {
717
- return /* @__PURE__ */ React12.createElement(Plank, {
718
- key: layoutEntry.id,
719
- entry: layoutEntry,
720
- layoutParts,
721
- part: "main",
722
- resizeable: true,
723
- flatDeck,
724
- searchEnabled
725
- });
726
- })))), layoutMode === "solo" && layoutParts.solo && layoutParts.solo.length > 0 && /* @__PURE__ */ React12.createElement(Main3.Content, {
727
- bounce: true,
728
- classNames: [
729
- "grid",
730
- "block-end-[--statusbar-size]"
731
- ]
746
+ className: layoutMode === "solo" ? "contents" : "relative"
732
747
  }, /* @__PURE__ */ React12.createElement(Deck.Root, {
748
+ ref: deckRef,
749
+ solo: layoutMode === "solo",
750
+ style: padding,
733
751
  classNames: [
734
752
  !flatDeck && "surface-deck",
735
- slots?.wallpaper?.classNames,
736
- slots?.deck?.classNames
737
- ],
738
- solo: true
739
- }, layoutParts.solo.map((layoutEntry) => {
740
- return /* @__PURE__ */ React12.createElement(Plank, {
741
- key: layoutEntry.id,
742
- entry: layoutEntry,
743
- layoutParts,
744
- part: "solo",
745
- flatDeck,
746
- classNames: slots?.plank?.classNames
747
- });
748
- }))), (layoutMode === "solo" && (!layoutParts.solo || layoutParts.solo.length === 0) || layoutMode === "deck" && (!layoutParts.main || layoutParts.main.length === 0)) && /* @__PURE__ */ React12.createElement(Main3.Content, null, /* @__PURE__ */ React12.createElement(ContentEmpty, null)), /* @__PURE__ */ React12.createElement(Main3.Content, {
749
- role: "none",
750
- classNames: [
751
- "fixed inset-inline-0 block-end-0 z-[2]"
753
+ layoutMode === "deck" && [
754
+ "absolute inset-0",
755
+ "transition-[padding] duration-200 ease-in-out",
756
+ slots?.wallpaper?.classNames
757
+ ]
752
758
  ]
759
+ }, parts.map((layoutEntry) => /* @__PURE__ */ React12.createElement(Plank, {
760
+ key: layoutEntry.id,
761
+ entry: layoutEntry,
762
+ layoutParts,
763
+ part: layoutMode === "solo" && layoutEntry.id === activeId ? "solo" : "main",
764
+ flatDeck,
765
+ searchEnabled: !!searchPlugin,
766
+ resizeable: layoutMode === "deck",
767
+ classNames: showPlank(layoutEntry) ? "" : "hidden"
768
+ }))))), /* @__PURE__ */ React12.createElement(Main3.Content, {
769
+ role: "none",
770
+ classNames: "fixed inset-inline-0 block-end-0 z-[2]"
753
771
  }, /* @__PURE__ */ React12.createElement(Surface8, {
754
772
  role: "status-bar",
755
773
  limit: 1
@@ -1044,12 +1062,6 @@ var appScheme = "composer://";
1044
1062
  var customSlots = {
1045
1063
  wallpaper: {
1046
1064
  classNames: "bg-cover bg-no-repeat dark:bg-[url(https://cdn.midjourney.com/3865ba61-f98a-4d94-b91a-1763ead01f4f/0_0.jpeg)]"
1047
- },
1048
- deck: {
1049
- classNames: "px-96 bg-neutral-50 __dark:bg-neutral-950 dark:bg-transparent dark:opacity-95"
1050
- },
1051
- plank: {
1052
- classNames: "mx-1 bg-neutral-25 dark:bg-neutral-900"
1053
1065
  }
1054
1066
  };
1055
1067
  setAutoFreeze(false);
@@ -1224,7 +1236,21 @@ var DeckPlugin = ({ observability } = {}) => {
1224
1236
  checkAppScheme(appScheme);
1225
1237
  }
1226
1238
  handleNavigation = async () => {
1227
- const layoutFromUri = uriToSoloPart(window.location.pathname);
1239
+ const pathname = window.location.pathname;
1240
+ if (pathname === "/reset") {
1241
+ location.values.active = {
1242
+ sidebar: [
1243
+ {
1244
+ id: NAV_ID
1245
+ }
1246
+ ]
1247
+ };
1248
+ location.values.closed = [];
1249
+ layout.values.layoutMode = "solo";
1250
+ window.location.pathname = "/";
1251
+ return;
1252
+ }
1253
+ const layoutFromUri = uriToSoloPart(pathname);
1228
1254
  if (!layoutFromUri) {
1229
1255
  return;
1230
1256
  }
@@ -1269,7 +1295,9 @@ var DeckPlugin = ({ observability } = {}) => {
1269
1295
  builder: () => {
1270
1296
  return createExtension({
1271
1297
  id: DECK_PLUGIN,
1272
- filter: (node) => node.id === "root",
1298
+ // NOTE(Zan): This is currently disabled.
1299
+ // TODO(Zan): Fullscreen needs to know the active node and provide that to the layout part.
1300
+ filter: (node) => false,
1273
1301
  actions: () => [
1274
1302
  {
1275
1303
  id: `${LayoutAction3.SET_LAYOUT_MODE}/fullscreen`,
@@ -1312,9 +1340,9 @@ var DeckPlugin = ({ observability } = {}) => {
1312
1340
  attended: /* @__PURE__ */ new Set()
1313
1341
  },
1314
1342
  layoutParts: location.values.active,
1343
+ showHintsFooter: settings.values.showFooter,
1315
1344
  overscroll: settings.values.overscroll,
1316
1345
  flatDeck: settings.values.flatDeck,
1317
- showHintsFooter: settings.values.showFooter,
1318
1346
  slots: settings.values.customSlots ? customSlots : void 0,
1319
1347
  toasts: layout.values.toasts,
1320
1348
  onDismissToast: (id) => {
@@ -1364,7 +1392,7 @@ var DeckPlugin = ({ observability } = {}) => {
1364
1392
  } else {
1365
1393
  log.warn("Invalid layout mode", intent?.data?.layoutMode, {
1366
1394
  F: __dxlog_file,
1367
- L: 384,
1395
+ L: 390,
1368
1396
  S: void 0,
1369
1397
  C: (f, a) => f(...a)
1370
1398
  });
@@ -1417,8 +1445,8 @@ var DeckPlugin = ({ observability } = {}) => {
1417
1445
  if (!intent.data || !intent.data?.activeParts) {
1418
1446
  return;
1419
1447
  }
1420
- const newPlankPositioning = settings.values.newPlankPositioning;
1421
1448
  const processLayoutEntry = (partName, entryString, currentLayout) => {
1449
+ const toggle = true;
1422
1450
  const [id, path] = entryString.split(SLUG_PATH_SEPARATOR5);
1423
1451
  const layoutEntry = {
1424
1452
  id,
@@ -1427,14 +1455,14 @@ var DeckPlugin = ({ observability } = {}) => {
1427
1455
  } : {}
1428
1456
  };
1429
1457
  const effectivePart = getEffectivePart(partName, layoutMode);
1430
- if (layoutMode === "deck" && effectivePart === "main" && currentLayout[effectivePart]?.some((entry) => entry.id === id) && !intent.data?.noToggle) {
1458
+ if (toggle && layoutMode === "deck" && effectivePart === "main" && currentLayout[effectivePart]?.some((entry) => entry.id === id) && !intent.data?.noToggle) {
1431
1459
  return closeEntry(currentLayout, {
1432
1460
  part: effectivePart,
1433
1461
  entryId: id
1434
1462
  });
1435
1463
  } else {
1436
1464
  return openEntry(currentLayout, effectivePart, layoutEntry, {
1437
- positioning: newPlankPositioning
1465
+ positioning: settings.values.newPlankPositioning
1438
1466
  });
1439
1467
  }
1440
1468
  };
@@ -1562,11 +1590,10 @@ var DeckPlugin = ({ observability } = {}) => {
1562
1590
  if (isLayoutAdjustment(intent.data)) {
1563
1591
  const adjustment = intent.data;
1564
1592
  if (adjustment.type === "increment-end" || adjustment.type === "increment-start") {
1565
- const nextActive = incrementPlank(location.values.active, {
1593
+ location.values.active = incrementPlank(location.values.active, {
1566
1594
  type: adjustment.type,
1567
1595
  layoutCoordinate: adjustment.layoutCoordinate
1568
1596
  });
1569
- location.values.active = nextActive;
1570
1597
  }
1571
1598
  if (adjustment.type === "solo") {
1572
1599
  const entryId = adjustment.layoutCoordinate.entryId;