@dxos/plugin-deck 0.7.2-main.f1adc9f → 0.7.2

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 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";
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";
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";
@@ -360,11 +360,15 @@ 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";
363
364
  var PlankLoading = () => {
364
365
  return /* @__PURE__ */ React4.createElement("div", {
365
366
  role: "none",
366
367
  className: "grid place-items-center attention-surface"
367
- });
368
+ }, /* @__PURE__ */ React4.createElement(Status, {
369
+ indeterminate: true,
370
+ "aria-label": "Initializing"
371
+ }));
368
372
  };
369
373
 
370
374
  // packages/plugins/plugin-deck/src/components/DeckLayout/PlankError.tsx
@@ -518,7 +522,7 @@ var Fullscreen = ({ id }) => {
518
522
 
519
523
  // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
520
524
  import React10, { memo as memo2, useCallback, useLayoutEffect, useMemo as useMemo3, useRef } from "react";
521
- import { Surface as Surface6, useIntentDispatcher as useIntentDispatcher3, indexInPart, partLength, LayoutAction as LayoutAction2 } from "@dxos/app-framework";
525
+ import { Surface as Surface6, useIntentDispatcher as useIntentDispatcher3, indexInPart, partLength } from "@dxos/app-framework";
522
526
  import { debounce } from "@dxos/async";
523
527
  import { useGraph as useGraph5 } from "@dxos/plugin-graph";
524
528
  import { useAttendableAttributes } from "@dxos/react-ui-attention";
@@ -533,7 +537,7 @@ var useDeckContext = () => useContext2(DeckContext) ?? raise2(new Error("Missing
533
537
 
534
538
  // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
535
539
  var UNKNOWN_ID = "unknown_id";
536
- var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order }) => {
540
+ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order, last }) => {
537
541
  const dispatch = useIntentDispatcher3();
538
542
  const coordinate = useMemo3(() => ({
539
543
  part,
@@ -574,20 +578,13 @@ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, layoutMode, order
574
578
  }, []);
575
579
  useLayoutEffect(() => {
576
580
  if (scrollIntoView === coordinate.entryId) {
577
- const focusable = rootElement.current?.querySelector("input") || rootElement.current?.querySelector("button") || rootElement.current;
578
- focusable?.focus({
581
+ rootElement.current?.focus({
579
582
  preventScroll: true
580
583
  });
581
- layoutMode === "deck" && focusable?.scrollIntoView({
584
+ layoutMode === "deck" && rootElement.current?.scrollIntoView({
582
585
  behavior: "smooth",
583
586
  inline: "center"
584
587
  });
585
- void dispatch({
586
- action: LayoutAction2.SCROLL_INTO_VIEW,
587
- data: {
588
- id: void 0
589
- }
590
- });
591
588
  }
592
589
  }, [
593
590
  coordinate.entryId,
@@ -912,7 +909,8 @@ var DeckLayout = ({ layoutParts, toasts, overscroll, showHints, panels, onDismis
912
909
  layoutParts,
913
910
  part: "main",
914
911
  layoutMode,
915
- order: index * 2 + 1
912
+ order: index * 2 + 1,
913
+ last: index === layoutParts.main.length - 1
916
914
  }))))), /* @__PURE__ */ React14.createElement("div", {
917
915
  role: "none",
918
916
  className: isSoloModeLoaded ? "relative bg-deck overflow-hidden" : "sr-only",
@@ -1311,36 +1309,19 @@ var DeckPlugin = ({ observability } = {}) => {
1311
1309
  }
1312
1310
  };
1313
1311
  const handleSetLocation = (next) => {
1314
- const part = layout.values.layoutMode === "solo" ? "solo" : "main";
1315
- const ids = openIds2(next, [
1316
- part
1317
- ]);
1318
1312
  if (attentionPlugin) {
1319
1313
  const attended = attentionPlugin.provides.attention.attended;
1320
1314
  const [attendedId] = Array.from(attended);
1315
+ const ids = (layout.values.layoutMode === "deck" ? next.main : next.solo)?.map(({ id }) => id) ?? [];
1321
1316
  const isAttendedAvailable = !!attendedId && ids.includes(attendedId);
1322
1317
  if (!isAttendedAvailable) {
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
- }
1318
+ requestAnimationFrame(() => {
1319
+ const nextAttended = layout.values.layoutMode === "solo" ? next.solo?.[0].id : next.main?.[0]?.id;
1320
+ const article = document.querySelector(`article[data-attendable-id="${nextAttended}"]`);
1321
+ article?.focus();
1332
1322
  });
1333
1323
  }
1334
1324
  }
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;
1344
1325
  location.values.active = next;
1345
1326
  };
1346
1327
  return {
@@ -1453,11 +1434,11 @@ var DeckPlugin = ({ observability } = {}) => {
1453
1434
  filter: (node) => false,
1454
1435
  actions: () => [
1455
1436
  {
1456
- id: `${LayoutAction3.SET_LAYOUT_MODE}/fullscreen`,
1437
+ id: `${LayoutAction2.SET_LAYOUT_MODE}/fullscreen`,
1457
1438
  data: async () => {
1458
1439
  await intentPlugin?.provides.intent.dispatch({
1459
1440
  plugin: DECK_PLUGIN,
1460
- action: LayoutAction3.SET_LAYOUT_MODE,
1441
+ action: LayoutAction2.SET_LAYOUT_MODE,
1461
1442
  data: {
1462
1443
  layoutMode: "fullscreen"
1463
1444
  }
@@ -1520,46 +1501,27 @@ var DeckPlugin = ({ observability } = {}) => {
1520
1501
  intent: {
1521
1502
  resolver: (intent) => {
1522
1503
  switch (intent.action) {
1523
- case LayoutAction3.SET_LAYOUT: {
1504
+ case LayoutAction2.SET_LAYOUT: {
1524
1505
  return intent.data && handleSetLayout(intent.data);
1525
1506
  }
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
+ case LayoutAction2.SET_LAYOUT_MODE: {
1546
1508
  return batch(() => {
1547
1509
  if (!intent.data) {
1548
1510
  return;
1549
1511
  }
1550
1512
  if (intent.data?.revert) {
1551
- setMode(layoutModeHistory.values.pop() ?? "solo");
1513
+ layout.values.layoutMode = layoutModeHistory.values.pop() ?? "solo";
1552
1514
  return {
1553
1515
  data: true
1554
1516
  };
1555
1517
  }
1556
1518
  if (isLayoutMode(intent?.data?.layoutMode)) {
1557
1519
  layoutModeHistory.values.push(layout.values.layoutMode);
1558
- setMode(intent.data.layoutMode);
1520
+ layout.values.layoutMode = intent.data.layoutMode;
1559
1521
  } else {
1560
1522
  log.warn("Invalid layout mode", intent?.data?.layoutMode, {
1561
1523
  F: __dxlog_file,
1562
- L: 408,
1524
+ L: 379,
1563
1525
  S: void 0,
1564
1526
  C: (f, a) => f(...a)
1565
1527
  });
@@ -1569,11 +1531,9 @@ var DeckPlugin = ({ observability } = {}) => {
1569
1531
  };
1570
1532
  });
1571
1533
  }
1572
- case LayoutAction3.SCROLL_INTO_VIEW: {
1534
+ case LayoutAction2.SCROLL_INTO_VIEW: {
1573
1535
  layout.values.scrollIntoView = intent.data?.id ?? void 0;
1574
- return {
1575
- data: true
1576
- };
1536
+ return void 0;
1577
1537
  }
1578
1538
  case DeckAction.UPDATE_PLANK_SIZE: {
1579
1539
  const { id, size } = intent.data;
@@ -1615,7 +1575,7 @@ var DeckPlugin = ({ observability } = {}) => {
1615
1575
  return;
1616
1576
  }
1617
1577
  const processLayoutEntry = (partName, entryString, currentLayout) => {
1618
- const toggle = false;
1578
+ const toggle = true;
1619
1579
  const [id, path] = entryString.split(SLUG_PATH_SEPARATOR4);
1620
1580
  const layoutEntry = {
1621
1581
  id,
@@ -1656,7 +1616,7 @@ var DeckPlugin = ({ observability } = {}) => {
1656
1616
  intents: [
1657
1617
  newlyOpen.length > 0 ? [
1658
1618
  {
1659
- action: LayoutAction3.SCROLL_INTO_VIEW,
1619
+ action: LayoutAction2.SCROLL_INTO_VIEW,
1660
1620
  data: {
1661
1621
  id: newlyOpen[0]
1662
1622
  }
@@ -1701,7 +1661,7 @@ var DeckPlugin = ({ observability } = {}) => {
1701
1661
  if (data.scrollIntoView && layout.values.layoutMode === "deck") {
1702
1662
  intents.push([
1703
1663
  {
1704
- action: LayoutAction3.SCROLL_INTO_VIEW,
1664
+ action: LayoutAction2.SCROLL_INTO_VIEW,
1705
1665
  data: {
1706
1666
  id: data.id
1707
1667
  }
@@ -1772,6 +1732,12 @@ var DeckPlugin = ({ observability } = {}) => {
1772
1732
  data: true,
1773
1733
  intents: [
1774
1734
  [
1735
+ {
1736
+ action: LayoutAction2.SET_LAYOUT_MODE,
1737
+ data: {
1738
+ layoutMode: "solo"
1739
+ }
1740
+ },
1775
1741
  {
1776
1742
  action: NavigationAction3.OPEN,
1777
1743
  data: {
@@ -1781,12 +1747,6 @@ var DeckPlugin = ({ observability } = {}) => {
1781
1747
  ]
1782
1748
  }
1783
1749
  }
1784
- },
1785
- {
1786
- action: LayoutAction3.SET_LAYOUT_MODE,
1787
- data: {
1788
- layoutMode: "solo"
1789
- }
1790
1750
  }
1791
1751
  ]
1792
1752
  ]
@@ -1797,34 +1757,34 @@ var DeckPlugin = ({ observability } = {}) => {
1797
1757
  intents: [
1798
1758
  [
1799
1759
  {
1800
- action: NavigationAction3.OPEN,
1760
+ action: LayoutAction2.SET_LAYOUT_MODE,
1801
1761
  data: {
1802
- noToggle: true,
1803
- activeParts: {
1804
- main: [
1805
- entryId
1806
- ]
1807
- }
1762
+ layoutMode: "deck"
1808
1763
  }
1809
1764
  },
1810
1765
  {
1811
- action: LayoutAction3.SET_LAYOUT_MODE,
1766
+ action: NavigationAction3.CLOSE,
1812
1767
  data: {
1813
- layoutMode: "deck"
1768
+ activeParts: {
1769
+ solo: [
1770
+ entryId
1771
+ ]
1772
+ }
1814
1773
  }
1815
1774
  },
1816
1775
  {
1817
- action: NavigationAction3.CLOSE,
1776
+ action: NavigationAction3.OPEN,
1818
1777
  data: {
1778
+ noToggle: true,
1819
1779
  activeParts: {
1820
- solo: [
1780
+ main: [
1821
1781
  entryId
1822
1782
  ]
1823
1783
  }
1824
1784
  }
1825
1785
  },
1826
1786
  {
1827
- action: LayoutAction3.SCROLL_INTO_VIEW,
1787
+ action: LayoutAction2.SCROLL_INTO_VIEW,
1828
1788
  data: {
1829
1789
  id: entryId
1830
1790
  }