@dxos/plugin-deck 0.6.14-main.f49f251 → 0.6.14-staging.4b6f9cf

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.
Files changed (40) hide show
  1. package/dist/lib/browser/chunk-NIRHDTX4.mjs +17 -0
  2. package/dist/lib/browser/chunk-NIRHDTX4.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +387 -379
  4. package/dist/lib/browser/index.mjs.map +4 -4
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/types.mjs +11 -0
  7. package/dist/lib/browser/types.mjs.map +7 -0
  8. package/dist/types/src/DeckPlugin.d.ts.map +1 -1
  9. package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts +4 -3
  10. package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +1 -1
  11. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +3 -8
  12. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
  13. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts +3 -4
  14. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts.map +1 -1
  15. package/dist/types/src/components/DeckLayout/Plank.d.ts +4 -4
  16. package/dist/types/src/components/DeckLayout/Plank.d.ts.map +1 -1
  17. package/dist/types/src/components/DeckLayout/PlankControls.d.ts +19 -0
  18. package/dist/types/src/components/DeckLayout/PlankControls.d.ts.map +1 -0
  19. package/dist/types/src/components/DeckLayout/PlankError.d.ts +1 -2
  20. package/dist/types/src/components/DeckLayout/PlankError.d.ts.map +1 -1
  21. package/dist/types/src/translations.d.ts +7 -4
  22. package/dist/types/src/translations.d.ts.map +1 -1
  23. package/dist/types/src/types.d.ts +13 -1
  24. package/dist/types/src/types.d.ts.map +1 -1
  25. package/dist/types/src/util/overscroll.d.ts +1 -2
  26. package/dist/types/src/util/overscroll.d.ts.map +1 -1
  27. package/package.json +34 -27
  28. package/src/DeckPlugin.tsx +18 -32
  29. package/src/components/DeckLayout/ComplementarySidebar.tsx +27 -45
  30. package/src/components/DeckLayout/DeckLayout.tsx +141 -137
  31. package/src/components/DeckLayout/NodePlankHeading.tsx +30 -17
  32. package/src/components/DeckLayout/Plank.tsx +62 -96
  33. package/src/components/DeckLayout/PlankControls.tsx +133 -0
  34. package/src/components/DeckLayout/PlankError.tsx +6 -8
  35. package/src/components/DeckLayout/PlankLoading.tsx +1 -1
  36. package/src/components/DeckLayout/Toast.tsx +1 -1
  37. package/src/components/LayoutSettings.tsx +13 -13
  38. package/src/translations.ts +11 -9
  39. package/src/types.ts +15 -0
  40. package/src/util/overscroll.ts +9 -30
package/src/types.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  //
4
4
 
5
5
  import type {
6
+ Plugin,
6
7
  GraphBuilderProvides,
7
8
  IntentResolverProvides,
8
9
  LayoutProvides,
@@ -11,6 +12,7 @@ import type {
11
12
  SurfaceProvides,
12
13
  TranslationsProvides,
13
14
  } from '@dxos/app-framework';
15
+ import { type Label } from '@dxos/react-ui';
14
16
 
15
17
  // TODO(Zan): In the future we should consider adding new planks adjacent to the attended plank.
16
18
  export const NewPlankPositions = ['start', 'end'] as const;
@@ -19,6 +21,19 @@ export type NewPlankPositioning = (typeof NewPlankPositions)[number];
19
21
  export const OverscrollOptions = ['none', 'centering'] as const;
20
22
  export type Overscroll = (typeof OverscrollOptions)[number];
21
23
 
24
+ // TODO(wittjosiah): Include a predicate for whether the panel is visible for the current subject.
25
+ export type Panel = { id: string; label: Label; icon: string };
26
+
27
+ // TODO(wittjosiah): Is this generic enough to be in the app framework?
28
+ export type PanelProvides = {
29
+ complementary: {
30
+ panels: Panel[];
31
+ };
32
+ };
33
+
34
+ export const parsePanelPlugin = (plugin?: Plugin) =>
35
+ Array.isArray((plugin?.provides as any).complementary?.panels) ? (plugin as Plugin<PanelProvides>) : undefined;
36
+
22
37
  export type DeckSettingsProps = {
23
38
  showHints: boolean;
24
39
  customSlots: boolean;
@@ -4,9 +4,6 @@
4
4
 
5
5
  import type { CSSProperties } from 'react';
6
6
 
7
- import { type LayoutEntry } from '@dxos/app-framework';
8
- import { PLANK_DEFAULTS } from '@dxos/react-ui-deck';
9
-
10
7
  /**
11
8
  * ┌────────────────────────────────────────────────────────────────────────────────────────────────────┐
12
9
  * | Overscroll Padding Calculation for Centering Planks on Screen. │
@@ -52,39 +49,21 @@ import { PLANK_DEFAULTS } from '@dxos/react-ui-deck';
52
49
  * └────────────────────────────────────────────────────────────────────────────────────────────────────┘
53
50
  */
54
51
  export const calculateOverscroll = (
55
- planks: LayoutEntry[] | undefined,
56
- plankSizing: Record<string, number>,
57
- sidebarOpen: boolean,
58
- complementarySidebarOpen: boolean,
52
+ planksCount: number,
59
53
  ): Pick<CSSProperties, 'paddingInlineStart' | 'paddingInlineEnd'> | undefined => {
60
- if (!planks?.length) {
54
+ if (!planksCount) {
61
55
  return { paddingInlineStart: 0, paddingInlineEnd: 0 };
62
56
  }
63
-
64
- // TODO(Zan): Move complementary sidebar size (360px), sidebar size (270px), plank resize handle size (20px) to CSS variables.
65
- const sidebarWidth = sidebarOpen ? '270px' : '0px';
66
- const complementarySidebarWidth = complementarySidebarOpen ? '360px' : '0px';
67
-
68
- const getPlankSize = (id: string) => (plankSizing[id] ?? PLANK_DEFAULTS.size).toFixed(2) + 'rem';
69
-
70
- if (planks.length === 1) {
71
- // Center the plank in the content area.
72
- const plank = planks[0];
73
- const plankSize = getPlankSize(plank.id);
74
- const overscrollPadding = `max(0px, calc(((100dvw - ${sidebarWidth} - ${complementarySidebarWidth} - (${plankSize} + 20px)) / 2)))`;
75
-
57
+ if (planksCount === 1) {
58
+ const overscrollPadding =
59
+ 'max(0px, calc(((100dvw - var(--dx-main-sidebarWidth) - var(--dx-main-complementaryWidth) - (var(--dx-main-contentFirstWidth) + 1px)) / 2)))';
76
60
  return { paddingInlineStart: overscrollPadding, paddingInlineEnd: overscrollPadding };
77
61
  } else {
78
- // Center the plank on the screen.
79
- const first = planks[0];
80
- const firstSize = getPlankSize(first.id);
81
-
82
- const last = planks[planks.length - 1];
83
- const lastSize = getPlankSize(last.id);
84
-
85
62
  return {
86
- paddingInlineStart: `max(0px, calc(((100dvw - (${firstSize} + 20px)) / 2) - ${sidebarWidth}))`,
87
- paddingInlineEnd: `max(0px, calc(((100dvw - (${lastSize} + 20px)) / 2) - ${complementarySidebarWidth}))`,
63
+ paddingInlineStart:
64
+ 'max(0px, calc(((100dvw - (var(--dx-main-contentFirstWidth) + 1px)) / 2) - var(--dx-main-sidebarWidth)))',
65
+ paddingInlineEnd:
66
+ 'max(0px, calc(((100dvw - (var(--dx-main-contentLastWidth) + 1px)) / 2) - var(--dx-main-complementaryWidth)))',
88
67
  };
89
68
  }
90
69
  };