@dxos/plugin-deck 0.6.14-main.8b352a0 → 0.6.14-staging.54a8bab

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.
@@ -0,0 +1,17 @@
1
+ // packages/plugins/plugin-deck/src/types.ts
2
+ var NewPlankPositions = [
3
+ "start",
4
+ "end"
5
+ ];
6
+ var OverscrollOptions = [
7
+ "none",
8
+ "centering"
9
+ ];
10
+ var parsePanelPlugin = (plugin) => Array.isArray(plugin?.provides.complementary?.panels) ? plugin : void 0;
11
+
12
+ export {
13
+ NewPlankPositions,
14
+ OverscrollOptions,
15
+ parsePanelPlugin
16
+ };
17
+ //# sourceMappingURL=chunk-NIRHDTX4.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/types.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport type {\n Plugin,\n GraphBuilderProvides,\n IntentResolverProvides,\n LayoutProvides,\n LocationProvides,\n SettingsProvides,\n SurfaceProvides,\n TranslationsProvides,\n} from '@dxos/app-framework';\nimport { type Label } from '@dxos/react-ui';\n\n// TODO(Zan): In the future we should consider adding new planks adjacent to the attended plank.\nexport const NewPlankPositions = ['start', 'end'] as const;\nexport type NewPlankPositioning = (typeof NewPlankPositions)[number];\n\nexport const OverscrollOptions = ['none', 'centering'] as const;\nexport type Overscroll = (typeof OverscrollOptions)[number];\n\n// TODO(wittjosiah): Include a predicate for whether the panel is visible for the current subject.\nexport type Panel = { id: string; label: Label; icon: string };\n\n// TODO(wittjosiah): Is this generic enough to be in the app framework?\nexport type PanelProvides = {\n complementary: {\n panels: Panel[];\n };\n};\n\nexport const parsePanelPlugin = (plugin?: Plugin) =>\n Array.isArray((plugin?.provides as any).complementary?.panels) ? (plugin as Plugin<PanelProvides>) : undefined;\n\nexport type DeckSettingsProps = {\n showHints: boolean;\n customSlots: boolean;\n flatDeck: boolean;\n enableNativeRedirect: boolean;\n disableDeck: boolean;\n newPlankPositioning: NewPlankPositioning;\n overscroll: Overscroll;\n};\n\nexport type DeckPluginProvides = SurfaceProvides &\n IntentResolverProvides &\n GraphBuilderProvides &\n TranslationsProvides &\n SettingsProvides<DeckSettingsProps> &\n LayoutProvides &\n LocationProvides;\n"],
5
+ "mappings": ";AAiBO,IAAMA,oBAAoB;EAAC;EAAS;;AAGpC,IAAMC,oBAAoB;EAAC;EAAQ;;AAanC,IAAMC,mBAAmB,CAACC,WAC/BC,MAAMC,QAASF,QAAQG,SAAiBC,eAAeC,MAAAA,IAAWL,SAAmCM;",
6
+ "names": ["NewPlankPositions", "OverscrollOptions", "parsePanelPlugin", "plugin", "Array", "isArray", "provides", "complementary", "panels", "undefined"]
7
+ }
@@ -2,12 +2,17 @@ import {
2
2
  DECK_PLUGIN,
3
3
  meta_default
4
4
  } from "./chunk-GVOGPULO.mjs";
5
+ import {
6
+ NewPlankPositions,
7
+ OverscrollOptions,
8
+ parsePanelPlugin
9
+ } from "./chunk-NIRHDTX4.mjs";
5
10
 
6
11
  // packages/plugins/plugin-deck/src/DeckPlugin.tsx
7
12
  import { batch } from "@preact/signals-core";
8
13
  import { setAutoFreeze } from "immer";
9
14
  import React15 from "react";
10
- import { IntentAction, LayoutAction as LayoutAction3, NavigationAction as NavigationAction4, parseGraphPlugin, parseIntentPlugin, resolvePlugin, Toast as ToastSchema, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR4, isLayoutParts, isLayoutAdjustment, isLayoutMode, openIds as openIds2 } from "@dxos/app-framework";
15
+ import { IntentAction, LayoutAction as LayoutAction3, NavigationAction as NavigationAction4, parseGraphPlugin, parseIntentPlugin, resolvePlugin, Toast as ToastSchema, SLUG_PATH_SEPARATOR as SLUG_PATH_SEPARATOR4, isLayoutParts, isLayoutAdjustment, isLayoutMode, openIds as openIds2, filterPlugins } from "@dxos/app-framework";
11
16
  import { create, getTypename, isReactiveObject } from "@dxos/echo-schema";
12
17
  import { scheduledEffect } from "@dxos/echo-signals/core";
13
18
  import { LocalStorageStore } from "@dxos/local-storage";
@@ -318,38 +323,16 @@ var LayoutContext = createContext(null);
318
323
  var useLayout = () => useContext(LayoutContext) ?? raise(new Error("Missing LayoutContext"));
319
324
 
320
325
  // packages/plugins/plugin-deck/src/components/DeckLayout/ComplementarySidebar.tsx
321
- var panels = [
322
- {
323
- id: "settings",
324
- icon: "ph--gear--regular"
325
- },
326
- {
327
- id: "comments",
328
- icon: "ph--chat-text--regular"
329
- },
330
- {
331
- id: "automation",
332
- icon: "ph--atom--regular"
333
- },
334
- {
335
- id: "debug",
336
- icon: "ph--bug--regular"
337
- }
338
- ];
339
- var getPanel = (id) => {
340
- const panel = panels.find((p) => p.id === id) ?? panels[0];
341
- return panel.id;
342
- };
343
- var ComplementarySidebar = ({ panel, flatDeck }) => {
326
+ var ComplementarySidebar = ({ panels, current, flatDeck }) => {
344
327
  const { popoverAnchorId } = useLayout();
345
328
  const attended = useAttended2();
346
- const part = getPanel(panel);
347
- const id = attended[0] ? `${attended[0]}${SLUG_PATH_SEPARATOR2}${part}` : void 0;
329
+ const panel = (panels.find((p) => p.id === current) ?? panels[0])?.id;
330
+ const id = attended[0] ? `${attended[0]}${SLUG_PATH_SEPARATOR2}${panel}` : void 0;
348
331
  const { graph } = useGraph3();
349
332
  const node = useNode(graph, id);
350
333
  const dispatch = useIntentDispatcher2();
351
334
  useNodeActionExpander(node);
352
- const actions = useMemo2(() => panels.map(({ id: id2, icon }) => ({
335
+ const actions = useMemo2(() => panels.map(({ id: id2, label, icon }) => ({
353
336
  id: `complementary-${id2}`,
354
337
  data: () => {
355
338
  void dispatch({
@@ -362,18 +345,13 @@ var ComplementarySidebar = ({ panel, flatDeck }) => {
362
345
  });
363
346
  },
364
347
  properties: {
365
- label: [
366
- `open ${id2} label`,
367
- {
368
- ns: DECK_PLUGIN
369
- }
370
- ],
348
+ label,
371
349
  icon,
372
350
  menuItemType: "toggle",
373
- isChecked: part === id2
351
+ isChecked: panel === id2
374
352
  }
375
353
  })), [
376
- part
354
+ panel
377
355
  ]);
378
356
  const coordinate = useMemo2(() => ({
379
357
  entryId: id ?? "unknown",
@@ -394,7 +372,8 @@ var ComplementarySidebar = ({ panel, flatDeck }) => {
394
372
  className: "row-span-2 divide-y divide-separator overflow-x-hidden overflow-y-scroll"
395
373
  }, node && /* @__PURE__ */ React5.createElement(Surface3, {
396
374
  key: id,
397
- role: `complementary--${part}`,
375
+ role: `complementary--${panel}`,
376
+ limit: 1,
398
377
  data: {
399
378
  id,
400
379
  subject: node.properties.object ?? node.properties.space,
@@ -478,39 +457,38 @@ var DeckContext = createContext2(null);
478
457
  var useDeckContext = () => useContext2(DeckContext) ?? raise2(new Error("Missing DeckContext"));
479
458
 
480
459
  // packages/plugins/plugin-deck/src/components/DeckLayout/Plank.tsx
460
+ var UNKNOWN_ID = "unknown_id";
481
461
  var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, flatDeck, searchEnabled, layoutMode }) => {
482
462
  const { t } = useTranslation4(DECK_PLUGIN);
483
463
  const dispatch = useIntentDispatcher3();
484
- const { popoverAnchorId, scrollIntoView } = useLayout();
485
- const { plankSizing } = useDeckContext();
486
- const { graph } = useGraph5();
487
- const node = useNode(graph, entry.id);
488
- const rootElement = useRef(null);
489
- const resizeable = layoutMode === "deck";
490
- const attendableAttrs = useAttendableAttributes(entry.id);
491
464
  const coordinate = useMemo3(() => ({
492
465
  part,
493
- entryId: entry.id
466
+ entryId: entry?.id ?? UNKNOWN_ID
494
467
  }), [
495
- entry.id,
468
+ entry?.id,
496
469
  part
497
470
  ]);
471
+ const { popoverAnchorId, scrollIntoView } = useLayout();
472
+ const { plankSizing } = useDeckContext();
473
+ const { graph } = useGraph5();
474
+ const node = useNode(graph, entry?.id);
475
+ const rootElement = useRef(null);
476
+ const resizeable = layoutMode === "deck";
477
+ const attendableAttrs = useAttendableAttributes(coordinate.entryId);
498
478
  const index = indexInPart(layoutParts, coordinate);
499
479
  const length = partLength(layoutParts, part);
500
480
  const canIncrementStart = part === "main" && index !== void 0 && index > 0 && length !== void 0 && length > 1;
501
481
  const canIncrementEnd = part === "main" && index !== void 0 && index < length - 1 && length !== void 0;
502
- const size = plankSizing?.[entry.id];
503
- const setSize = useCallback(debounce((newSize) => {
504
- void dispatch({
505
- action: DeckAction.UPDATE_PLANK_SIZE,
506
- data: {
507
- id: entry.id,
508
- size: newSize
509
- }
510
- });
511
- }, 200), [
482
+ const size = plankSizing?.[coordinate.entryId];
483
+ const setSize = useCallback(debounce((newSize) => dispatch({
484
+ action: DeckAction.UPDATE_PLANK_SIZE,
485
+ data: {
486
+ id: coordinate.entryId,
487
+ size: newSize
488
+ }
489
+ }), 200), [
512
490
  dispatch,
513
- entry.id
491
+ coordinate.entryId
514
492
  ]);
515
493
  const handleKeyDown = useCallback((event) => {
516
494
  if (event.target === event.currentTarget && event.key === "Escape") {
@@ -518,7 +496,7 @@ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, flatDeck, searchE
518
496
  }
519
497
  }, []);
520
498
  useLayoutEffect(() => {
521
- if (scrollIntoView === entry.id) {
499
+ if (scrollIntoView === coordinate.entryId) {
522
500
  rootElement.current?.focus({
523
501
  preventScroll: true
524
502
  });
@@ -528,14 +506,15 @@ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, flatDeck, searchE
528
506
  });
529
507
  }
530
508
  }, [
509
+ coordinate.entryId,
531
510
  scrollIntoView,
532
511
  layoutMode
533
512
  ]);
534
513
  const isSolo = layoutMode === "solo" && part === "solo";
535
- const isSuppressed = layoutMode === "solo" && part !== "solo" || layoutMode === "deck" && part === "solo";
514
+ const isSuppressed = layoutMode === "solo" && part !== "solo" || layoutMode === "deck" && part === "solo" || coordinate.entryId === UNKNOWN_ID;
536
515
  const sizeAttrs = useMainSize();
537
516
  const data = useMemo3(() => node && {
538
- ...entry.path ? {
517
+ ...entry?.path ? {
539
518
  subject: node.data,
540
519
  path: entry.path
541
520
  } : {
@@ -544,7 +523,11 @@ var Plank = /* @__PURE__ */ memo2(({ entry, layoutParts, part, flatDeck, searchE
544
523
  coordinate,
545
524
  popoverAnchorId
546
525
  }, [
547
- node
526
+ node,
527
+ node?.data,
528
+ entry?.path,
529
+ coordinate,
530
+ popoverAnchorId
548
531
  ]);
549
532
  const placeholder = useMemo3(() => /* @__PURE__ */ React9.createElement(PlankLoading, null), []);
550
533
  return /* @__PURE__ */ React9.createElement(NaturalPlank.Root, {
@@ -754,7 +737,7 @@ var calculateOverscroll = (planks, plankSizing, sidebarOpen, complementarySideba
754
737
  };
755
738
 
756
739
  // packages/plugins/plugin-deck/src/components/DeckLayout/DeckLayout.tsx
757
- var DeckLayout = ({ layoutParts, toasts, flatDeck, overscroll, showHints, slots, onDismissToast }) => {
740
+ var DeckLayout = ({ layoutParts, toasts, flatDeck, overscroll, showHints, slots, panels, onDismissToast }) => {
758
741
  const context = useLayout();
759
742
  const { layoutMode, sidebarOpen, complementarySidebarOpen, dialogOpen, dialogContent, dialogBlockAlign, popoverOpen, popoverContent, popoverAnchorId } = context;
760
743
  const { t } = useTranslation5(DECK_PLUGIN);
@@ -858,7 +841,8 @@ var DeckLayout = ({ layoutParts, toasts, flatDeck, overscroll, showHints, slots,
858
841
  })), /* @__PURE__ */ React13.createElement(Sidebar, {
859
842
  layoutParts
860
843
  }), /* @__PURE__ */ React13.createElement(ComplementarySidebar, {
861
- panel: layoutParts.complementary?.[0].id,
844
+ panels,
845
+ current: layoutParts.complementary?.[0].id,
862
846
  flatDeck
863
847
  }), /* @__PURE__ */ React13.createElement(Main3.Overlay, null), isEmpty && /* @__PURE__ */ React13.createElement(Main3.Content, {
864
848
  handlesFocus: true
@@ -881,9 +865,7 @@ var DeckLayout = ({ layoutParts, toasts, flatDeck, overscroll, showHints, slots,
881
865
  onScroll: handleScroll,
882
866
  ref: deckRef
883
867
  }, /* @__PURE__ */ React13.createElement(Plank, {
884
- entry: layoutParts.solo?.[0] ?? {
885
- id: "unknown-solo"
886
- },
868
+ entry: layoutParts.solo?.[0],
887
869
  layoutParts,
888
870
  part: "solo",
889
871
  layoutMode,
@@ -931,23 +913,11 @@ var DeckLayout = ({ layoutParts, toasts, flatDeck, overscroll, showHints, slots,
931
913
  // packages/plugins/plugin-deck/src/components/LayoutSettings.tsx
932
914
  import React14 from "react";
933
915
  import { Input, Select, useTranslation as useTranslation6 } from "@dxos/react-ui";
934
- import { FormInput } from "@dxos/react-ui-data";
935
-
936
- // packages/plugins/plugin-deck/src/types.ts
937
- var NewPlankPositions = [
938
- "start",
939
- "end"
940
- ];
941
- var OverscrollOptions = [
942
- "none",
943
- "centering"
944
- ];
945
-
946
- // packages/plugins/plugin-deck/src/components/LayoutSettings.tsx
916
+ import { DeprecatedFormInput } from "@dxos/react-ui-data";
947
917
  var isSocket = !!globalThis.__args;
948
918
  var LayoutSettings = ({ settings }) => {
949
919
  const { t } = useTranslation6(DECK_PLUGIN);
950
- return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(FormInput, {
920
+ return /* @__PURE__ */ React14.createElement(React14.Fragment, null, /* @__PURE__ */ React14.createElement(DeprecatedFormInput, {
951
921
  label: t("select new plank positioning label")
952
922
  }, /* @__PURE__ */ React14.createElement(Select.Root, {
953
923
  value: settings.newPlankPositioning ?? "start",
@@ -957,7 +927,7 @@ var LayoutSettings = ({ settings }) => {
957
927
  }), /* @__PURE__ */ React14.createElement(Select.Portal, null, /* @__PURE__ */ React14.createElement(Select.Content, null, /* @__PURE__ */ React14.createElement(Select.Viewport, null, NewPlankPositions.map((position) => /* @__PURE__ */ React14.createElement(Select.Option, {
958
928
  key: position,
959
929
  value: position
960
- }, t(`settings new plank position ${position} label`)))))))), /* @__PURE__ */ React14.createElement(FormInput, {
930
+ }, t(`settings new plank position ${position} label`)))))))), /* @__PURE__ */ React14.createElement(DeprecatedFormInput, {
961
931
  label: t("settings overscroll label")
962
932
  }, /* @__PURE__ */ React14.createElement(Select.Root, {
963
933
  value: settings.overscroll ?? "none",
@@ -967,22 +937,22 @@ var LayoutSettings = ({ settings }) => {
967
937
  }), /* @__PURE__ */ React14.createElement(Select.Portal, null, /* @__PURE__ */ React14.createElement(Select.Content, null, /* @__PURE__ */ React14.createElement(Select.Viewport, null, OverscrollOptions.map((option) => /* @__PURE__ */ React14.createElement(Select.Option, {
968
938
  key: option,
969
939
  value: option
970
- }, t(`settings overscroll ${option} label`)))))))), /* @__PURE__ */ React14.createElement(FormInput, {
940
+ }, t(`settings overscroll ${option} label`)))))))), /* @__PURE__ */ React14.createElement(DeprecatedFormInput, {
971
941
  label: t("settings show hints label")
972
942
  }, /* @__PURE__ */ React14.createElement(Input.Switch, {
973
943
  checked: settings.showHints,
974
944
  onCheckedChange: (checked) => settings.showHints = checked
975
- })), !isSocket && /* @__PURE__ */ React14.createElement(FormInput, {
945
+ })), !isSocket && /* @__PURE__ */ React14.createElement(DeprecatedFormInput, {
976
946
  label: t("settings native redirect label")
977
947
  }, /* @__PURE__ */ React14.createElement(Input.Switch, {
978
948
  checked: settings.enableNativeRedirect,
979
949
  onCheckedChange: (checked) => settings.enableNativeRedirect = checked
980
- })), /* @__PURE__ */ React14.createElement(FormInput, {
950
+ })), /* @__PURE__ */ React14.createElement(DeprecatedFormInput, {
981
951
  label: t("settings custom slots")
982
952
  }, /* @__PURE__ */ React14.createElement(Input.Switch, {
983
953
  checked: settings.customSlots,
984
954
  onCheckedChange: (checked) => settings.customSlots = checked
985
- })), /* @__PURE__ */ React14.createElement(FormInput, {
955
+ })), /* @__PURE__ */ React14.createElement(DeprecatedFormInput, {
986
956
  label: t("settings flat deck")
987
957
  }, /* @__PURE__ */ React14.createElement(Input.Switch, {
988
958
  checked: settings.flatDeck,
@@ -1170,12 +1140,7 @@ var translations_default = [
1170
1140
  "select overscroll placeholder": "Select plank overscrolling behavior",
1171
1141
  "settings overscroll centering label": "Centering",
1172
1142
  "settings overscroll none label": "None",
1173
- "settings flat deck": "Flatten deck appearance",
1174
- // ComplementarySidebar
1175
- "open settings label": "Show settings",
1176
- "open comments label": "Show Comments",
1177
- "open automation label": "Show Automation",
1178
- "open debug label": "Show Debug"
1143
+ "settings flat deck": "Flatten deck appearance"
1179
1144
  }
1180
1145
  }
1181
1146
  }
@@ -1204,6 +1169,7 @@ var DeckPlugin = ({ observability } = {}) => {
1204
1169
  const unsubscriptionCallbacks = [];
1205
1170
  let currentUndoId;
1206
1171
  let handleNavigation;
1172
+ const panels = [];
1207
1173
  const settings = new LocalStorageStore("dxos.org/settings/layout", {
1208
1174
  showHints: false,
1209
1175
  customSlots: false,
@@ -1334,6 +1300,7 @@ var DeckPlugin = ({ observability } = {}) => {
1334
1300
  key: "closed",
1335
1301
  type: LocalStorageStore.json()
1336
1302
  });
1303
+ panels.push(...filterPlugins(plugins, parsePanelPlugin).flatMap((plugin) => plugin.provides.complementary.panels));
1337
1304
  unsubscriptionCallbacks.push(clientPlugin?.provides.client.shell.onReset(() => {
1338
1305
  layout.expunge();
1339
1306
  location.expunge();
@@ -1460,6 +1427,7 @@ var DeckPlugin = ({ observability } = {}) => {
1460
1427
  flatDeck: settings.values.flatDeck,
1461
1428
  slots: settings.values.customSlots ? customSlots : void 0,
1462
1429
  toasts: layout.values.toasts,
1430
+ panels,
1463
1431
  onDismissToast: (id) => {
1464
1432
  const index = layout.values.toasts.findIndex((toast) => toast.id === id);
1465
1433
  if (index !== -1) {
@@ -1507,7 +1475,7 @@ var DeckPlugin = ({ observability } = {}) => {
1507
1475
  } else {
1508
1476
  log.warn("Invalid layout mode", intent?.data?.layoutMode, {
1509
1477
  F: __dxlog_file,
1510
- L: 392,
1478
+ L: 406,
1511
1479
  S: void 0,
1512
1480
  C: (f, a) => f(...a)
1513
1481
  });