@dxos/plugin-deck 0.6.8-staging.77f93a3 → 0.6.8-staging.dec6b33

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,7 +26,7 @@ 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";
@@ -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,14 +431,14 @@ 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
- };
433
- const ref = useRef(null);
434
+ const handleKeyDown = useCallback((event) => {
435
+ if (event.target === event.currentTarget && event.key === "Escape") {
436
+ rootElement.current?.closest("main")?.focus();
437
+ }
438
+ }, []);
434
439
  useLayoutEffect(() => {
435
440
  if (scrollIntoView === entry.id) {
436
- ref.current?.scrollIntoView({
441
+ rootElement.current?.scrollIntoView({
437
442
  behavior: "smooth",
438
443
  inline: "center"
439
444
  });
@@ -443,13 +448,14 @@ var Plank = ({ entry, layoutParts, part, resizeable, flatDeck, searchEnabled, cl
443
448
  ]);
444
449
  return /* @__PURE__ */ React9.createElement(NaturalPlank.Root, {
445
450
  size,
446
- setSize
447
- }, /* @__PURE__ */ React9.createElement(NaturalPlank.Content, {
451
+ setSize,
452
+ classNames,
448
453
  ...attendableAttrs,
449
- ref,
454
+ onKeyDown: handleKeyDown,
455
+ ref: rootElement
456
+ }, /* @__PURE__ */ React9.createElement(NaturalPlank.Content, {
450
457
  classNames: [
451
- !flatDeck && "surface-base",
452
- classNames
458
+ !flatDeck && "surface-base"
453
459
  ]
454
460
  }, node ? /* @__PURE__ */ React9.createElement(React9.Fragment, null, /* @__PURE__ */ React9.createElement(NodePlankHeading, {
455
461
  id: entry.id,
@@ -593,18 +599,15 @@ var getEffectivePart = (partName, layoutMode) => layoutMode === "solo" && partNa
593
599
 
594
600
  // packages/plugins/plugin-deck/src/util/overscroll.ts
595
601
  import { PLANK_DEFAULTS } from "@dxos/react-ui-deck";
596
- var calculateOverscroll = (layoutMode, layoutParts, plankSizing, sidebarOpen, complementarySidebarOpen, overscroll) => {
597
- if (!(layoutMode === "deck" && overscroll === "centering")) {
598
- return;
599
- }
600
- if (!layoutParts.main || layoutParts.main.length === 0) {
602
+ var calculateOverscroll = (planks, plankSizing, sidebarOpen, complementarySidebarOpen) => {
603
+ if (!planks?.length) {
601
604
  return;
602
605
  }
603
606
  const sidebarWidth = sidebarOpen ? "270px" : "0px";
604
607
  const complementarySidebarWidth = complementarySidebarOpen ? "360px" : "0px";
605
608
  const getPlankSize = (id) => (plankSizing[id] ?? PLANK_DEFAULTS.size).toFixed(2) + "rem";
606
- if (layoutParts.main.length === 1) {
607
- const plank = layoutParts.main[0];
609
+ if (planks.length === 1) {
610
+ const plank = planks[0];
608
611
  const plankSize = getPlankSize(plank.id);
609
612
  const overscrollPadding = `max(0px, calc(((100dvw - ${sidebarWidth} - ${complementarySidebarWidth} - (${plankSize} + 20px)) / 2)))`;
610
613
  return {
@@ -612,26 +615,24 @@ var calculateOverscroll = (layoutMode, layoutParts, plankSizing, sidebarOpen, co
612
615
  paddingRight: overscrollPadding
613
616
  };
614
617
  } else {
615
- const firstPlank = layoutParts.main[0];
616
- const firstPlankInlineSize = getPlankSize(firstPlank.id);
617
- const paddingLeft = `max(0px, calc(((100dvw - (${firstPlankInlineSize} + 20px)) / 2) - ${sidebarWidth}))`;
618
- const lastPlank = layoutParts.main[layoutParts.main.length - 1];
619
- const lastPlankInlineSize = getPlankSize(lastPlank.id);
620
- 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);
621
622
  return {
622
- paddingLeft,
623
- paddingRight
623
+ paddingLeft: `max(0px, calc(((100dvw - (${firstSize} + 20px)) / 2) - ${sidebarWidth}))`,
624
+ paddingRight: `max(0px, calc(((100dvw - (${lastSize} + 20px)) / 2) - ${complementarySidebarWidth}))`
624
625
  };
625
626
  }
626
627
  };
627
628
 
628
629
  // packages/plugins/plugin-deck/src/components/DeckLayout/DeckLayout.tsx
629
- var DeckLayout = ({ showHintsFooter, toasts, onDismissToast, flatDeck, attention, layoutParts, slots, overscroll }) => {
630
+ var DeckLayout = ({ layoutParts, attention, toasts, flatDeck, overscroll, showHintsFooter, slots, onDismissToast }) => {
630
631
  const context = useLayout();
631
632
  const { layoutMode, sidebarOpen, complementarySidebarOpen, dialogOpen, dialogContent, dialogBlockAlign, popoverOpen, popoverContent, popoverAnchorId } = context;
632
633
  const { t } = useTranslation5(DECK_PLUGIN);
633
634
  const { plankSizing } = useDeckContext();
634
- const searchEnabled = !!usePlugin("dxos.org/plugin/search");
635
+ const searchPlugin = usePlugin("dxos.org/plugin/search");
635
636
  const fullScreenSlug = useMemo2(() => firstIdInPart(layoutParts, "fullScreen"), [
636
637
  layoutParts
637
638
  ]);
@@ -646,8 +647,32 @@ var DeckLayout = ({ showHintsFooter, toasts, onDismissToast, flatDeck, attention
646
647
  const activeId = useMemo2(() => Array.from(attention.attended ?? [])[0], [
647
648
  attention.attended
648
649
  ]);
649
- const overscrollAmount = calculateOverscroll(layoutMode, layoutParts, plankSizing, sidebarOpen, complementarySidebarOpen, overscroll);
650
- const isEmpty = layoutMode === "solo" && (!layoutParts.solo || layoutParts.solo.length === 0) || layoutMode === "deck" && (!layoutParts.main || layoutParts.main.length === 0);
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) : {};
651
676
  if (layoutMode === "fullscreen") {
652
677
  return /* @__PURE__ */ React12.createElement(Fullscreen, {
653
678
  id: fullScreenSlug
@@ -710,13 +735,19 @@ var DeckLayout = ({ showHintsFooter, toasts, onDismissToast, flatDeck, attention
710
735
  id: complementarySlug,
711
736
  layoutParts,
712
737
  flatDeck
713
- }), /* @__PURE__ */ React12.createElement(Main3.Overlay, null), isEmpty && /* @__PURE__ */ React12.createElement(Main3.Content, null, /* @__PURE__ */ React12.createElement(ContentEmpty, null)), !isEmpty && /* @__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, {
714
741
  bounce: true,
715
- classNames: [
716
- "grid",
717
- "block-end-[--statusbar-size]"
718
- ]
742
+ classNames: "grid block-end-[--statusbar-size]",
743
+ handlesFocus: true
744
+ }, /* @__PURE__ */ React12.createElement("div", {
745
+ role: "none",
746
+ className: layoutMode === "solo" ? "contents" : "relative"
719
747
  }, /* @__PURE__ */ React12.createElement(Deck.Root, {
748
+ ref: deckRef,
749
+ solo: layoutMode === "solo",
750
+ style: padding,
720
751
  classNames: [
721
752
  !flatDeck && "surface-deck",
722
753
  layoutMode === "deck" && [
@@ -724,34 +755,19 @@ var DeckLayout = ({ showHintsFooter, toasts, onDismissToast, flatDeck, attention
724
755
  "transition-[padding] duration-200 ease-in-out",
725
756
  slots?.wallpaper?.classNames
726
757
  ]
727
- ],
728
- solo: layoutMode === "solo",
729
- style: {
730
- ...overscrollAmount
731
- }
732
- }, layoutMode === "solo" && layoutParts.solo?.map((layoutEntry) => {
733
- return /* @__PURE__ */ React12.createElement(Plank, {
734
- key: layoutEntry.id,
735
- entry: layoutEntry,
736
- layoutParts,
737
- part: "solo",
738
- flatDeck
739
- });
740
- }), layoutMode === "deck" && layoutParts.main?.map((layoutEntry) => {
741
- return /* @__PURE__ */ React12.createElement(Plank, {
742
- key: layoutEntry.id,
743
- entry: layoutEntry,
744
- layoutParts,
745
- part: "main",
746
- resizeable: true,
747
- flatDeck,
748
- searchEnabled
749
- });
750
- }))), /* @__PURE__ */ React12.createElement(Main3.Content, {
751
- role: "none",
752
- classNames: [
753
- "fixed inset-inline-0 block-end-0 z-[2]"
754
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]"
755
771
  }, /* @__PURE__ */ React12.createElement(Surface8, {
756
772
  role: "status-bar",
757
773
  limit: 1
@@ -1279,7 +1295,9 @@ var DeckPlugin = ({ observability } = {}) => {
1279
1295
  builder: () => {
1280
1296
  return createExtension({
1281
1297
  id: DECK_PLUGIN,
1282
- 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,
1283
1301
  actions: () => [
1284
1302
  {
1285
1303
  id: `${LayoutAction3.SET_LAYOUT_MODE}/fullscreen`,
@@ -1322,9 +1340,9 @@ var DeckPlugin = ({ observability } = {}) => {
1322
1340
  attended: /* @__PURE__ */ new Set()
1323
1341
  },
1324
1342
  layoutParts: location.values.active,
1343
+ showHintsFooter: settings.values.showFooter,
1325
1344
  overscroll: settings.values.overscroll,
1326
1345
  flatDeck: settings.values.flatDeck,
1327
- showHintsFooter: settings.values.showFooter,
1328
1346
  slots: settings.values.customSlots ? customSlots : void 0,
1329
1347
  toasts: layout.values.toasts,
1330
1348
  onDismissToast: (id) => {
@@ -1374,7 +1392,7 @@ var DeckPlugin = ({ observability } = {}) => {
1374
1392
  } else {
1375
1393
  log.warn("Invalid layout mode", intent?.data?.layoutMode, {
1376
1394
  F: __dxlog_file,
1377
- L: 388,
1395
+ L: 390,
1378
1396
  S: void 0,
1379
1397
  C: (f, a) => f(...a)
1380
1398
  });
@@ -1428,7 +1446,7 @@ var DeckPlugin = ({ observability } = {}) => {
1428
1446
  return;
1429
1447
  }
1430
1448
  const processLayoutEntry = (partName, entryString, currentLayout) => {
1431
- const toggle = false;
1449
+ const toggle = true;
1432
1450
  const [id, path] = entryString.split(SLUG_PATH_SEPARATOR5);
1433
1451
  const layoutEntry = {
1434
1452
  id,