@dxos/plugin-deck 0.7.1-staging.8709ba7 → 0.7.2-main.f1adc9f

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.
@@ -12,7 +12,7 @@ import {
12
12
  import { batch } from "@preact/signals-core";
13
13
  import { setAutoFreeze } from "immer";
14
14
  import React16 from "react";
15
- import { IntentAction, LayoutAction as LayoutAction2, NavigationAction as NavigationAction3, parseGraphPlugin, parseIntentPlugin, resolvePlugin, Toast as ToastSchema, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR4, isLayoutParts, isLayoutAdjustment, isLayoutMode, openIds as openIds2, filterPlugins } from "@dxos/app-framework";
15
+ import { IntentAction, LayoutAction as LayoutAction3, NavigationAction as NavigationAction3, parseGraphPlugin, parseIntentPlugin, resolvePlugin, Toast as ToastSchema, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR4, isLayoutParts, isLayoutAdjustment, isLayoutMode, openIds as openIds2, filterPlugins } from "@dxos/app-framework";
16
16
  import { create, getTypename, isReactiveObject } from "@dxos/echo-schema";
17
17
  import { scheduledEffect } from "@dxos/echo-signals/core";
18
18
  import { LocalStorageStore } from "@dxos/local-storage";
@@ -125,7 +125,7 @@ var ActiveNode = () => {
125
125
  import React6, { useMemo as useMemo2 } from "react";
126
126
  import { NavigationAction as NavigationAction2, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR2, Surface as Surface3, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
127
127
  import { useGraph as useGraph3 } from "@dxos/plugin-graph";
128
- import { Main } from "@dxos/react-ui";
128
+ import { Main, ScrollArea } from "@dxos/react-ui";
129
129
  import { useAttended as useAttended2 } from "@dxos/react-ui-attention";
130
130
  import { railGridHorizontal, StackContext } from "@dxos/react-ui-stack";
131
131
  import { mx as mx2 } from "@dxos/react-ui-theme";
@@ -176,7 +176,7 @@ var PlankControls = /* @__PURE__ */ forwardRef(({ onClick, variant = "default",
176
176
  label: isSolo ? t("show deck plank label") : t("show solo plank label"),
177
177
  classNames: buttonClassNames,
178
178
  onClick: () => onClick?.("solo"),
179
- icon: isSolo ? "ph--vibrate--regular" : "ph--arrows-out--regular"
179
+ icon: isSolo ? "ph--arrow-u-down-left--regular" : "ph--arrows-out--regular"
180
180
  }), !isSolo && can.solo && /* @__PURE__ */ React2.createElement(React2.Fragment, null, /* @__PURE__ */ React2.createElement(PlankControl, {
181
181
  label: t("increment start label"),
182
182
  disabled: !can.incrementStart,
@@ -360,15 +360,11 @@ import { descriptionText, mx } from "@dxos/react-ui-theme";
360
360
 
361
361
  // packages/plugins/plugin-deck/src/components/DeckLayout/PlankLoading.tsx
362
362
  import React4 from "react";
363
- import { Status } from "@dxos/react-ui";
364
363
  var PlankLoading = () => {
365
364
  return /* @__PURE__ */ React4.createElement("div", {
366
365
  role: "none",
367
366
  className: "grid place-items-center attention-surface"
368
- }, /* @__PURE__ */ React4.createElement(Status, {
369
- indeterminate: true,
370
- "aria-label": "Initializing"
371
- }));
367
+ });
372
368
  };
373
369
 
374
370
  // packages/plugins/plugin-deck/src/components/DeckLayout/PlankError.tsx
@@ -443,15 +439,13 @@ var ComplementarySidebar = ({ panels, current }) => {
443
439
  }
444
440
  }, /* @__PURE__ */ React6.createElement("div", {
445
441
  role: "none",
446
- className: mx2(railGridHorizontal, "grid-cols-1 bs-full")
442
+ className: mx2(railGridHorizontal, "grid grid-cols-[100%] bs-full")
447
443
  }, /* @__PURE__ */ React6.createElement(NodePlankHeading, {
448
444
  coordinate,
449
445
  node,
450
446
  popoverAnchorId,
451
447
  actions
452
- }), /* @__PURE__ */ React6.createElement("div", {
453
- className: "divide-y divide-separator overflow-x-hidden overflow-y-scroll"
454
- }, node && /* @__PURE__ */ React6.createElement(Surface3, {
448
+ }), /* @__PURE__ */ React6.createElement(ScrollArea.Root, null, /* @__PURE__ */ React6.createElement(ScrollArea.Viewport, null, node && /* @__PURE__ */ React6.createElement(Surface3, {
455
449
  key: id,
456
450
  role: `complementary--${panel}`,
457
451
  limit: 1,
@@ -462,7 +456,9 @@ var ComplementarySidebar = ({ panels, current }) => {
462
456
  },
463
457
  fallback: PlankContentError,
464
458
  placeholder: /* @__PURE__ */ React6.createElement(PlankLoading, null)
465
- })))));
459
+ }), /* @__PURE__ */ React6.createElement(ScrollArea.Scrollbar, {
460
+ orientation: "vertical"
461
+ }, /* @__PURE__ */ React6.createElement(ScrollArea.Thumb, null)))))));
466
462
  };
467
463
 
468
464
  // packages/plugins/plugin-deck/src/components/DeckLayout/ContentEmpty.tsx
@@ -522,7 +518,7 @@ var Fullscreen = ({ id }) => {
522
518
 
523
519
  // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
524
520
  import React10, { memo as memo2, useCallback, useLayoutEffect, useMemo as useMemo3, useRef } from "react";
525
- import { Surface as Surface6, useIntentDispatcher as useIntentDispatcher3, indexInPart, partLength } from "@dxos/app-framework";
521
+ import { Surface as Surface6, useIntentDispatcher as useIntentDispatcher3, indexInPart, partLength, LayoutAction as LayoutAction2 } from "@dxos/app-framework";
526
522
  import { debounce } from "@dxos/async";
527
523
  import { useGraph as useGraph5 } from "@dxos/plugin-graph";
528
524
  import { useAttendableAttributes } from "@dxos/react-ui-attention";
@@ -537,7 +533,7 @@ var useDeckContext = () => useContext2(DeckContext) ?? raise2(new Error("Missing
537
533
 
538
534
  // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
539
535
  var UNKNOWN_ID = "unknown_id";
540
- var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order, last }) => {
536
+ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order }) => {
541
537
  const dispatch = useIntentDispatcher3();
542
538
  const coordinate = useMemo3(() => ({
543
539
  part,
@@ -578,13 +574,20 @@ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order
578
574
  }, []);
579
575
  useLayoutEffect(() => {
580
576
  if (scrollIntoView === coordinate.entryId) {
581
- rootElement.current?.focus({
577
+ const focusable = rootElement.current?.querySelector("input") || rootElement.current?.querySelector("button") || rootElement.current;
578
+ focusable?.focus({
582
579
  preventScroll: true
583
580
  });
584
- layoutMode === "deck" && rootElement.current?.scrollIntoView({
581
+ layoutMode === "deck" && focusable?.scrollIntoView({
585
582
  behavior: "smooth",
586
583
  inline: "center"
587
584
  });
585
+ void dispatch({
586
+ action: LayoutAction2.SCROLL_INTO_VIEW,
587
+ data: {
588
+ id: void 0
589
+ }
590
+ });
588
591
  }
589
592
  }, [
590
593
  coordinate.entryId,
@@ -638,6 +641,7 @@ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order
638
641
  canIncrementEnd,
639
642
  popoverAnchorId
640
643
  }), /* @__PURE__ */ React10.createElement(Surface6, {
644
+ key: node.id,
641
645
  role: "article",
642
646
  data,
643
647
  limit: 1,
@@ -908,8 +912,7 @@ var DeckLayout = ({ layoutParts, toasts, overscroll, showHints, panels, onDismis
908
912
  layoutParts,
909
913
  part: "main",
910
914
  layoutMode,
911
- order: index * 2 + 1,
912
- last: index === layoutParts.main.length - 1
915
+ order: index * 2 + 1
913
916
  }))))), /* @__PURE__ */ React14.createElement("div", {
914
917
  role: "none",
915
918
  className: isSoloModeLoaded ? "relative bg-deck overflow-hidden" : "sr-only",
@@ -1189,7 +1192,7 @@ var translations_default = [
1189
1192
  "pin end label": "Pin to the right sidebar",
1190
1193
  "increment start label": "Move to the left",
1191
1194
  "increment end label": "Move to the right",
1192
- "show deck plank label": "Show deck",
1195
+ "show deck plank label": "Return to deck",
1193
1196
  "show solo plank label": "Maximize",
1194
1197
  "close label": "Close",
1195
1198
  "minify label": "Minify",
@@ -1308,19 +1311,36 @@ var DeckPlugin = ({ observability } = {}) => {
1308
1311
  }
1309
1312
  };
1310
1313
  const handleSetLocation = (next) => {
1314
+ const part = layout.values.layoutMode === "solo" ? "solo" : "main";
1315
+ const ids = openIds2(next, [
1316
+ part
1317
+ ]);
1311
1318
  if (attentionPlugin) {
1312
1319
  const attended = attentionPlugin.provides.attention.attended;
1313
1320
  const [attendedId] = Array.from(attended);
1314
- const ids = (layout.values.layoutMode === "deck" ? next.main : next.solo)?.map(({ id }) => id) ?? [];
1315
1321
  const isAttendedAvailable = !!attendedId && ids.includes(attendedId);
1316
1322
  if (!isAttendedAvailable) {
1317
- requestAnimationFrame(() => {
1318
- const nextAttended = layout.values.layoutMode === "solo" ? next.solo?.[0].id : next.main?.[0]?.id;
1319
- const article = document.querySelector(`article[data-attendable-id="${nextAttended}"]`);
1320
- article?.focus();
1323
+ const currentIds = location.values.active[part]?.map(({ id }) => id) ?? [];
1324
+ const attendedIndex = currentIds.indexOf(attendedId);
1325
+ const index = attendedIndex === -1 ? 0 : attendedIndex >= ids.length ? ids.length - 1 : attendedIndex;
1326
+ const nextAttended = next[part]?.[index].id;
1327
+ void intentPlugin?.provides.intent.dispatch({
1328
+ action: LayoutAction3.SCROLL_INTO_VIEW,
1329
+ data: {
1330
+ id: nextAttended
1331
+ }
1321
1332
  });
1322
1333
  }
1323
1334
  }
1335
+ const current = openIds2(location.values.active, [
1336
+ part
1337
+ ]);
1338
+ const removed = current.filter((id) => !ids.includes(id));
1339
+ const closed = Array.from(/* @__PURE__ */ new Set([
1340
+ ...location.values.closed.filter((id) => !ids.includes(id)),
1341
+ ...removed
1342
+ ]));
1343
+ location.values.closed = closed;
1324
1344
  location.values.active = next;
1325
1345
  };
1326
1346
  return {
@@ -1433,11 +1453,11 @@ var DeckPlugin = ({ observability } = {}) => {
1433
1453
  filter: (node) => false,
1434
1454
  actions: () => [
1435
1455
  {
1436
- id: `${LayoutAction2.SET_LAYOUT_MODE}/fullscreen`,
1456
+ id: `${LayoutAction3.SET_LAYOUT_MODE}/fullscreen`,
1437
1457
  data: async () => {
1438
1458
  await intentPlugin?.provides.intent.dispatch({
1439
1459
  plugin: DECK_PLUGIN,
1440
- action: LayoutAction2.SET_LAYOUT_MODE,
1460
+ action: LayoutAction3.SET_LAYOUT_MODE,
1441
1461
  data: {
1442
1462
  layoutMode: "fullscreen"
1443
1463
  }
@@ -1500,27 +1520,46 @@ var DeckPlugin = ({ observability } = {}) => {
1500
1520
  intent: {
1501
1521
  resolver: (intent) => {
1502
1522
  switch (intent.action) {
1503
- case LayoutAction2.SET_LAYOUT: {
1523
+ case LayoutAction3.SET_LAYOUT: {
1504
1524
  return intent.data && handleSetLayout(intent.data);
1505
1525
  }
1506
- case LayoutAction2.SET_LAYOUT_MODE: {
1526
+ case LayoutAction3.SET_LAYOUT_MODE: {
1527
+ const setMode = (mode) => {
1528
+ const next = openIds2(location.values.active, mode === "solo" ? [
1529
+ "solo"
1530
+ ] : [
1531
+ "main"
1532
+ ]);
1533
+ const current = openIds2(location.values.active, layout.values.layoutMode === "solo" ? [
1534
+ "solo"
1535
+ ] : [
1536
+ "main"
1537
+ ]);
1538
+ const removed = current.filter((id) => !next.includes(id));
1539
+ const closed = Array.from(/* @__PURE__ */ new Set([
1540
+ ...location.values.closed.filter((id) => !next.includes(id)),
1541
+ ...removed
1542
+ ]));
1543
+ location.values.closed = closed;
1544
+ layout.values.layoutMode = mode;
1545
+ };
1507
1546
  return batch(() => {
1508
1547
  if (!intent.data) {
1509
1548
  return;
1510
1549
  }
1511
1550
  if (intent.data?.revert) {
1512
- layout.values.layoutMode = layoutModeHistory.values.pop() ?? "solo";
1551
+ setMode(layoutModeHistory.values.pop() ?? "solo");
1513
1552
  return {
1514
1553
  data: true
1515
1554
  };
1516
1555
  }
1517
1556
  if (isLayoutMode(intent?.data?.layoutMode)) {
1518
1557
  layoutModeHistory.values.push(layout.values.layoutMode);
1519
- layout.values.layoutMode = intent.data.layoutMode;
1558
+ setMode(intent.data.layoutMode);
1520
1559
  } else {
1521
1560
  log.warn("Invalid layout mode", intent?.data?.layoutMode, {
1522
1561
  F: __dxlog_file,
1523
- L: 379,
1562
+ L: 408,
1524
1563
  S: void 0,
1525
1564
  C: (f, a) => f(...a)
1526
1565
  });
@@ -1530,9 +1569,11 @@ var DeckPlugin = ({ observability } = {}) => {
1530
1569
  };
1531
1570
  });
1532
1571
  }
1533
- case LayoutAction2.SCROLL_INTO_VIEW: {
1572
+ case LayoutAction3.SCROLL_INTO_VIEW: {
1534
1573
  layout.values.scrollIntoView = intent.data?.id ?? void 0;
1535
- return void 0;
1574
+ return {
1575
+ data: true
1576
+ };
1536
1577
  }
1537
1578
  case DeckAction.UPDATE_PLANK_SIZE: {
1538
1579
  const { id, size } = intent.data;
@@ -1574,7 +1615,7 @@ var DeckPlugin = ({ observability } = {}) => {
1574
1615
  return;
1575
1616
  }
1576
1617
  const processLayoutEntry = (partName, entryString, currentLayout) => {
1577
- const toggle = true;
1618
+ const toggle = false;
1578
1619
  const [id, path] = entryString.split(SLUG_PATH_SEPARATOR4);
1579
1620
  const layoutEntry = {
1580
1621
  id,
@@ -1615,7 +1656,7 @@ var DeckPlugin = ({ observability } = {}) => {
1615
1656
  intents: [
1616
1657
  newlyOpen.length > 0 ? [
1617
1658
  {
1618
- action: LayoutAction2.SCROLL_INTO_VIEW,
1659
+ action: LayoutAction3.SCROLL_INTO_VIEW,
1619
1660
  data: {
1620
1661
  id: newlyOpen[0]
1621
1662
  }
@@ -1660,7 +1701,7 @@ var DeckPlugin = ({ observability } = {}) => {
1660
1701
  if (data.scrollIntoView && layout.values.layoutMode === "deck") {
1661
1702
  intents.push([
1662
1703
  {
1663
- action: LayoutAction2.SCROLL_INTO_VIEW,
1704
+ action: LayoutAction3.SCROLL_INTO_VIEW,
1664
1705
  data: {
1665
1706
  id: data.id
1666
1707
  }
@@ -1731,12 +1772,6 @@ var DeckPlugin = ({ observability } = {}) => {
1731
1772
  data: true,
1732
1773
  intents: [
1733
1774
  [
1734
- {
1735
- action: LayoutAction2.SET_LAYOUT_MODE,
1736
- data: {
1737
- layoutMode: "solo"
1738
- }
1739
- },
1740
1775
  {
1741
1776
  action: NavigationAction3.OPEN,
1742
1777
  data: {
@@ -1746,6 +1781,12 @@ var DeckPlugin = ({ observability } = {}) => {
1746
1781
  ]
1747
1782
  }
1748
1783
  }
1784
+ },
1785
+ {
1786
+ action: LayoutAction3.SET_LAYOUT_MODE,
1787
+ data: {
1788
+ layoutMode: "solo"
1789
+ }
1749
1790
  }
1750
1791
  ]
1751
1792
  ]
@@ -1756,34 +1797,34 @@ var DeckPlugin = ({ observability } = {}) => {
1756
1797
  intents: [
1757
1798
  [
1758
1799
  {
1759
- action: LayoutAction2.SET_LAYOUT_MODE,
1760
- data: {
1761
- layoutMode: "deck"
1762
- }
1763
- },
1764
- {
1765
- action: NavigationAction3.CLOSE,
1800
+ action: NavigationAction3.OPEN,
1766
1801
  data: {
1802
+ noToggle: true,
1767
1803
  activeParts: {
1768
- solo: [
1804
+ main: [
1769
1805
  entryId
1770
1806
  ]
1771
1807
  }
1772
1808
  }
1773
1809
  },
1774
1810
  {
1775
- action: NavigationAction3.OPEN,
1811
+ action: LayoutAction3.SET_LAYOUT_MODE,
1812
+ data: {
1813
+ layoutMode: "deck"
1814
+ }
1815
+ },
1816
+ {
1817
+ action: NavigationAction3.CLOSE,
1776
1818
  data: {
1777
- noToggle: true,
1778
1819
  activeParts: {
1779
- main: [
1820
+ solo: [
1780
1821
  entryId
1781
1822
  ]
1782
1823
  }
1783
1824
  }
1784
1825
  },
1785
1826
  {
1786
- action: LayoutAction2.SCROLL_INTO_VIEW,
1827
+ action: LayoutAction3.SCROLL_INTO_VIEW,
1787
1828
  data: {
1788
1829
  id: entryId
1789
1830
  }