@dxos/plugin-deck 0.7.5-main.9d26e3a → 0.7.5-main.b19bfc8

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 (188) hide show
  1. package/dist/lib/browser/app-graph-builder-IYHAGFA3.mjs +151 -0
  2. package/dist/lib/browser/app-graph-builder-IYHAGFA3.mjs.map +7 -0
  3. package/dist/lib/browser/check-app-scheme-S3EYUPMF.mjs +33 -0
  4. package/dist/lib/browser/check-app-scheme-S3EYUPMF.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-22AQ5IVX.mjs +17 -0
  6. package/dist/lib/browser/chunk-22AQ5IVX.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-CYE6QZBQ.mjs +128 -0
  8. package/dist/lib/browser/chunk-CYE6QZBQ.mjs.map +7 -0
  9. package/dist/lib/browser/chunk-DIM5INBX.mjs +24 -0
  10. package/dist/lib/browser/chunk-DIM5INBX.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-DIXE74SK.mjs +1097 -0
  12. package/dist/lib/browser/chunk-DIXE74SK.mjs.map +7 -0
  13. package/dist/lib/browser/chunk-KANJBSIX.mjs +97 -0
  14. package/dist/lib/browser/chunk-KANJBSIX.mjs.map +7 -0
  15. package/dist/lib/browser/{chunk-GVOGPULO.mjs → chunk-N7TEPFVR.mjs} +5 -4
  16. package/dist/lib/browser/chunk-N7TEPFVR.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +104 -1776
  18. package/dist/lib/browser/index.mjs.map +4 -4
  19. package/dist/lib/browser/intent-resolver-MWUADUNI.mjs +488 -0
  20. package/dist/lib/browser/intent-resolver-MWUADUNI.mjs.map +7 -0
  21. package/dist/lib/browser/meta.json +1 -1
  22. package/dist/lib/browser/react-root-IELFERPV.mjs +45 -0
  23. package/dist/lib/browser/react-root-IELFERPV.mjs.map +7 -0
  24. package/dist/lib/browser/react-surface-WL45R43W.mjs +39 -0
  25. package/dist/lib/browser/react-surface-WL45R43W.mjs.map +7 -0
  26. package/dist/lib/browser/settings-YONG3QB7.mjs +28 -0
  27. package/dist/lib/browser/settings-YONG3QB7.mjs.map +7 -0
  28. package/dist/lib/browser/state-MZZL5S2D.mjs +124 -0
  29. package/dist/lib/browser/state-MZZL5S2D.mjs.map +7 -0
  30. package/dist/lib/browser/tools-5LDJNU56.mjs +51 -0
  31. package/dist/lib/browser/tools-5LDJNU56.mjs.map +7 -0
  32. package/dist/lib/browser/types.mjs +16 -4
  33. package/dist/lib/browser/url-handler-MVHTKUYA.mjs +72 -0
  34. package/dist/lib/browser/url-handler-MVHTKUYA.mjs.map +7 -0
  35. package/dist/types/src/DeckPlugin.d.ts +1 -5
  36. package/dist/types/src/DeckPlugin.d.ts.map +1 -1
  37. package/dist/types/src/capabilities/app-graph-builder.d.ts +181 -0
  38. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  39. package/dist/types/src/capabilities/capabilities.d.ts +142 -0
  40. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -0
  41. package/dist/types/src/capabilities/check-app-scheme.d.ts +4 -0
  42. package/dist/types/src/capabilities/check-app-scheme.d.ts.map +1 -0
  43. package/dist/types/src/capabilities/index.d.ts +190 -0
  44. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  45. package/dist/types/src/capabilities/intent-resolver.d.ts +4 -0
  46. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -0
  47. package/dist/types/src/capabilities/react-root.d.ts +7 -0
  48. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  49. package/dist/types/src/capabilities/react-surface.d.ts +4 -0
  50. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  51. package/dist/types/src/capabilities/settings.d.ts +4 -0
  52. package/dist/types/src/capabilities/settings.d.ts.map +1 -0
  53. package/dist/types/src/capabilities/state.d.ts +79 -0
  54. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  55. package/dist/types/src/capabilities/tools.d.ts +10 -0
  56. package/dist/types/src/capabilities/tools.d.ts.map +1 -0
  57. package/dist/types/src/capabilities/url-handler.d.ts +4 -0
  58. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
  59. package/dist/types/src/components/DeckLayout/ActiveNode.d.ts +1 -2
  60. package/dist/types/src/components/DeckLayout/ActiveNode.d.ts.map +1 -1
  61. package/dist/types/src/components/DeckLayout/Banner.d.ts +5 -0
  62. package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -0
  63. package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts +1 -4
  64. package/dist/types/src/components/DeckLayout/ComplementarySidebar.d.ts.map +1 -1
  65. package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts +1 -2
  66. package/dist/types/src/components/DeckLayout/ContentEmpty.d.ts.map +1 -1
  67. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +2 -7
  68. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
  69. package/dist/types/src/components/DeckLayout/Fallback.d.ts +1 -2
  70. package/dist/types/src/components/DeckLayout/Fallback.d.ts.map +1 -1
  71. package/dist/types/src/components/DeckLayout/Fullscreen.d.ts +1 -2
  72. package/dist/types/src/components/DeckLayout/Fullscreen.d.ts.map +1 -1
  73. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts +3 -3
  74. package/dist/types/src/components/DeckLayout/NodePlankHeading.d.ts.map +1 -1
  75. package/dist/types/src/components/DeckLayout/Plank.d.ts +8 -6
  76. package/dist/types/src/components/DeckLayout/Plank.d.ts.map +1 -1
  77. package/dist/types/src/components/DeckLayout/PlankControls.d.ts +2 -2
  78. package/dist/types/src/components/DeckLayout/PlankControls.d.ts.map +1 -1
  79. package/dist/types/src/components/DeckLayout/PlankError.d.ts +6 -6
  80. package/dist/types/src/components/DeckLayout/PlankError.d.ts.map +1 -1
  81. package/dist/types/src/components/DeckLayout/PlankLoading.d.ts +1 -2
  82. package/dist/types/src/components/DeckLayout/PlankLoading.d.ts.map +1 -1
  83. package/dist/types/src/components/DeckLayout/Sidebar.d.ts +1 -6
  84. package/dist/types/src/components/DeckLayout/Sidebar.d.ts.map +1 -1
  85. package/dist/types/src/components/DeckLayout/SidebarButton.d.ts +7 -0
  86. package/dist/types/src/components/DeckLayout/SidebarButton.d.ts.map +1 -0
  87. package/dist/types/src/components/DeckLayout/StatusBar.d.ts +1 -2
  88. package/dist/types/src/components/DeckLayout/StatusBar.d.ts.map +1 -1
  89. package/dist/types/src/components/DeckLayout/Toast.d.ts +2 -3
  90. package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
  91. package/dist/types/src/components/DeckLayout/Topbar.d.ts +2 -0
  92. package/dist/types/src/components/DeckLayout/Topbar.d.ts.map +1 -0
  93. package/dist/types/src/components/LayoutSettings.d.ts +1 -2
  94. package/dist/types/src/components/LayoutSettings.d.ts.map +1 -1
  95. package/dist/types/src/components/fragments.d.ts +4 -0
  96. package/dist/types/src/components/fragments.d.ts.map +1 -0
  97. package/dist/types/src/components/index.d.ts +0 -2
  98. package/dist/types/src/components/index.d.ts.map +1 -1
  99. package/dist/types/src/events.d.ts +5 -0
  100. package/dist/types/src/events.d.ts.map +1 -0
  101. package/dist/types/src/hooks/useMainSize.d.ts +2 -2
  102. package/dist/types/src/hooks/useNode.d.ts.map +1 -1
  103. package/dist/types/src/index.d.ts +3 -2
  104. package/dist/types/src/index.d.ts.map +1 -1
  105. package/dist/types/src/layout.d.ts +5 -19
  106. package/dist/types/src/layout.d.ts.map +1 -1
  107. package/dist/types/src/meta.d.ts +4 -4
  108. package/dist/types/src/meta.d.ts.map +1 -1
  109. package/dist/types/src/translations.d.ts +4 -2
  110. package/dist/types/src/translations.d.ts.map +1 -1
  111. package/dist/types/src/types.d.ts +121 -20
  112. package/dist/types/src/types.d.ts.map +1 -1
  113. package/dist/types/src/util/index.d.ts +4 -2
  114. package/dist/types/src/util/index.d.ts.map +1 -1
  115. package/dist/types/src/util/layoutAppliesTopbar.d.ts +2 -0
  116. package/dist/types/src/util/layoutAppliesTopbar.d.ts.map +1 -0
  117. package/dist/types/src/util/set-active.d.ts +9 -0
  118. package/dist/types/src/util/set-active.d.ts.map +1 -0
  119. package/dist/types/src/util/useBreakpoints.d.ts +2 -0
  120. package/dist/types/src/util/useBreakpoints.d.ts.map +1 -0
  121. package/dist/types/src/util/useHoistStatusbar.d.ts +2 -0
  122. package/dist/types/src/util/useHoistStatusbar.d.ts.map +1 -0
  123. package/dist/types/tsconfig.tsbuildinfo +1 -1
  124. package/package.json +32 -37
  125. package/src/DeckPlugin.ts +87 -0
  126. package/src/capabilities/app-graph-builder.ts +113 -0
  127. package/src/capabilities/capabilities.ts +15 -0
  128. package/src/capabilities/check-app-scheme.ts +44 -0
  129. package/src/capabilities/index.ts +17 -0
  130. package/src/capabilities/intent-resolver.ts +368 -0
  131. package/src/capabilities/react-root.tsx +46 -0
  132. package/src/capabilities/react-surface.tsx +31 -0
  133. package/src/capabilities/settings.ts +21 -0
  134. package/src/capabilities/state.ts +107 -0
  135. package/src/capabilities/tools.ts +61 -0
  136. package/src/capabilities/url-handler.ts +65 -0
  137. package/src/components/DeckLayout/ActiveNode.tsx +2 -3
  138. package/src/components/DeckLayout/Banner.tsx +37 -0
  139. package/src/components/DeckLayout/ComplementarySidebar.tsx +142 -59
  140. package/src/components/DeckLayout/ContentEmpty.tsx +9 -4
  141. package/src/components/DeckLayout/DeckLayout.tsx +151 -99
  142. package/src/components/DeckLayout/Fullscreen.tsx +2 -3
  143. package/src/components/DeckLayout/NodePlankHeading.tsx +64 -77
  144. package/src/components/DeckLayout/Plank.tsx +35 -43
  145. package/src/components/DeckLayout/PlankControls.tsx +12 -11
  146. package/src/components/DeckLayout/PlankError.tsx +6 -5
  147. package/src/components/DeckLayout/Sidebar.tsx +19 -9
  148. package/src/components/DeckLayout/SidebarButton.tsx +68 -0
  149. package/src/components/DeckLayout/StatusBar.tsx +6 -12
  150. package/src/components/DeckLayout/Toast.tsx +2 -2
  151. package/src/components/DeckLayout/Topbar.tsx +11 -0
  152. package/src/components/LayoutSettings.tsx +8 -8
  153. package/src/components/fragments.ts +14 -0
  154. package/src/components/index.ts +0 -2
  155. package/src/events.ts +12 -0
  156. package/src/hooks/useMainSize.ts +3 -3
  157. package/src/hooks/useNode.ts +3 -1
  158. package/src/index.ts +3 -4
  159. package/src/layout.ts +43 -212
  160. package/src/meta.ts +3 -2
  161. package/src/translations.ts +8 -6
  162. package/src/types.ts +104 -36
  163. package/src/util/index.ts +4 -2
  164. package/src/util/layoutAppliesTopbar.ts +7 -0
  165. package/src/util/set-active.ts +47 -0
  166. package/src/util/useBreakpoints.ts +11 -0
  167. package/src/util/useHoistStatusbar.ts +20 -0
  168. package/dist/lib/browser/chunk-GVOGPULO.mjs.map +0 -7
  169. package/dist/lib/browser/chunk-ZC3K6C2W.mjs +0 -37
  170. package/dist/lib/browser/chunk-ZC3K6C2W.mjs.map +0 -7
  171. package/dist/lib/browser/meta.mjs +0 -9
  172. package/dist/lib/browser/meta.mjs.map +0 -7
  173. package/dist/types/src/components/DeckContext.d.ts +0 -8
  174. package/dist/types/src/components/DeckContext.d.ts.map +0 -1
  175. package/dist/types/src/components/LayoutContext.d.ts +0 -5
  176. package/dist/types/src/components/LayoutContext.d.ts.map +0 -1
  177. package/dist/types/src/layout.test.d.ts +0 -2
  178. package/dist/types/src/layout.test.d.ts.map +0 -1
  179. package/dist/types/src/util/check-app-scheme.d.ts +0 -2
  180. package/dist/types/src/util/check-app-scheme.d.ts.map +0 -1
  181. package/dist/types/src/util/layout-parts.d.ts +0 -7
  182. package/dist/types/src/util/layout-parts.d.ts.map +0 -1
  183. package/src/DeckPlugin.tsx +0 -623
  184. package/src/components/DeckContext.ts +0 -14
  185. package/src/components/LayoutContext.ts +0 -12
  186. package/src/layout.test.ts +0 -380
  187. package/src/util/check-app-scheme.ts +0 -21
  188. package/src/util/layout-parts.ts +0 -12
@@ -0,0 +1,107 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes } from '@dxos/app-framework';
6
+ import { invariant } from '@dxos/invariant';
7
+ import { create } from '@dxos/live-object';
8
+ import { LocalStorageStore } from '@dxos/local-storage';
9
+ import { type SidebarState } from '@dxos/react-ui';
10
+
11
+ import { DeckCapabilities } from './capabilities';
12
+ import { DECK_PLUGIN } from '../meta';
13
+ import { getMode, type Deck, type DeckState } from '../types';
14
+
15
+ const boolean = /true|false/;
16
+
17
+ // TODO(thure, 18 Feb 2025): Remove after the next release.
18
+
19
+ const migrateSidebarStateDefaults = {
20
+ [`${DECK_PLUGIN}/complementary-sidebar-state`]: 'expanded',
21
+ [`${DECK_PLUGIN}/sidebar-state`]: 'collapsed',
22
+ };
23
+
24
+ const migrateSidebarState = () => {
25
+ Object.entries(migrateSidebarStateDefaults).forEach(([key, defaultValue]) => {
26
+ if (boolean.test(localStorage.getItem(key) ?? 'never')) {
27
+ localStorage.setItem(key, defaultValue);
28
+ }
29
+ });
30
+ };
31
+
32
+ export default () => {
33
+ migrateSidebarState();
34
+
35
+ const state = new LocalStorageStore<DeckState>(DECK_PLUGIN, {
36
+ sidebarState: 'expanded',
37
+ complementarySidebarState: 'collapsed',
38
+ complementarySidebarPanel: undefined,
39
+ dialogContent: null,
40
+ dialogOpen: false,
41
+ dialogBlockAlign: undefined,
42
+ dialogType: undefined,
43
+ popoverContent: null,
44
+ popoverAnchorId: undefined,
45
+ popoverOpen: false,
46
+ toasts: [],
47
+ currentUndoId: undefined,
48
+ activeDeck: 'default',
49
+ previousDeck: 'default',
50
+ decks: {
51
+ default: {
52
+ initialized: false,
53
+ active: [],
54
+ inactive: [],
55
+ fullscreen: false,
56
+ solo: undefined,
57
+ plankSizing: {},
58
+ },
59
+ },
60
+ get deck() {
61
+ const deck = this.decks[this.activeDeck];
62
+ invariant(deck, `Deck not found: ${this.activeDeck}`);
63
+ return deck;
64
+ },
65
+ previousMode: {},
66
+ scrollIntoView: undefined,
67
+ });
68
+
69
+ state
70
+ .prop({ key: 'sidebarState', type: LocalStorageStore.enum<SidebarState>() })
71
+ .prop({ key: 'complementarySidebarState', type: LocalStorageStore.enum<SidebarState>() })
72
+ .prop({ key: 'decks', type: LocalStorageStore.json<Record<string, Deck>>() })
73
+ .prop({ key: 'activeDeck', type: LocalStorageStore.string() })
74
+ .prop({ key: 'previousDeck', type: LocalStorageStore.string() });
75
+
76
+ const layout = create<Capabilities.Layout>({
77
+ get mode() {
78
+ return getMode(state.values.deck);
79
+ },
80
+ get dialogOpen() {
81
+ return state.values.dialogOpen;
82
+ },
83
+ get sidebarOpen() {
84
+ return state.values.sidebarState === 'expanded';
85
+ },
86
+ get complementarySidebarOpen() {
87
+ return state.values.complementarySidebarState === 'expanded';
88
+ },
89
+ get workspace() {
90
+ return state.values.activeDeck;
91
+ },
92
+ get active() {
93
+ return state.values.deck.solo ? [state.values.deck.solo] : state.values.deck.active;
94
+ },
95
+ get inactive() {
96
+ return state.values.deck.inactive;
97
+ },
98
+ get scrollIntoView() {
99
+ return state.values.scrollIntoView;
100
+ },
101
+ });
102
+
103
+ return [
104
+ contributes(DeckCapabilities.DeckState, state.values, () => state.close()),
105
+ contributes(Capabilities.Layout, layout),
106
+ ];
107
+ };
@@ -0,0 +1,61 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import {
6
+ contributes,
7
+ createIntent,
8
+ Capabilities,
9
+ LayoutAction,
10
+ type PromiseIntentDispatcher,
11
+ } from '@dxos/app-framework';
12
+ import { defineTool, ToolResult } from '@dxos/artifact';
13
+ import { S } from '@dxos/echo-schema';
14
+ import { invariant } from '@dxos/invariant';
15
+
16
+ // TODO(burdon): Factor out.
17
+ declare global {
18
+ interface ToolContextExtensions {
19
+ dispatch?: PromiseIntentDispatcher;
20
+ pivotId?: string;
21
+ }
22
+ }
23
+
24
+ export default () =>
25
+ contributes(Capabilities.Tools, [
26
+ defineTool({
27
+ name: 'show',
28
+ // TODO(ZaymonFC): We should update the prompt to teach the LLM the difference between object ids and fully qualified ids.
29
+ description:
30
+ 'Show an item in the app. Use this tool to open an artifact. When supplying IDs to show, they must be fully qualified like space:object.',
31
+ // TODO(wittjosiah): Refactor Layout/Navigation/Deck actions so that they can be used directly.
32
+ schema: S.Struct({
33
+ id: S.String.annotations({
34
+ description: 'The ID of the item to show.',
35
+ }),
36
+ pivotId: S.optional(
37
+ S.String.annotations({
38
+ description: 'The ID of the chat. If provided, the item will be added after the pivot item.',
39
+ }),
40
+ ),
41
+ }),
42
+ execute: async ({ id }, { extensions }) => {
43
+ invariant(extensions?.dispatch, 'No intent dispatcher');
44
+ const { data, error } = await extensions.dispatch(
45
+ createIntent(LayoutAction.Open, {
46
+ subject: [id],
47
+ part: 'main',
48
+ options: {
49
+ pivotId: extensions.pivotId,
50
+ positioning: 'end',
51
+ },
52
+ }),
53
+ );
54
+ if (error) {
55
+ return ToolResult.Error(error.message);
56
+ }
57
+
58
+ return ToolResult.Success(data);
59
+ },
60
+ }),
61
+ ]);
@@ -0,0 +1,65 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Capabilities, contributes, createIntent, LayoutAction, type PluginsContext } from '@dxos/app-framework';
6
+ import { scheduledEffect } from '@dxos/echo-signals/core';
7
+
8
+ import { DeckCapabilities } from './capabilities';
9
+
10
+ // TODO(wittjosiah): Cleanup the url handling. May justify introducing routing capabilities.
11
+ export default async (context: PluginsContext) => {
12
+ const { dispatchPromise: dispatch } = context.requestCapability(Capabilities.IntentDispatcher) ?? {};
13
+ const state = context.requestCapability(DeckCapabilities.MutableDeckState);
14
+
15
+ const handleNavigation = async () => {
16
+ const pathname = window.location.pathname;
17
+ if (pathname === '/reset') {
18
+ state.activeDeck = 'default';
19
+ state.decks = {
20
+ default: {
21
+ initialized: false,
22
+ active: [],
23
+ inactive: [],
24
+ fullscreen: false,
25
+ solo: undefined,
26
+ plankSizing: {},
27
+ },
28
+ };
29
+ window.location.pathname = '/';
30
+ return;
31
+ }
32
+
33
+ const [_, nextDeck, nextSolo] = pathname.split('/');
34
+ if (nextDeck && nextDeck !== state.activeDeck) {
35
+ await dispatch(createIntent(LayoutAction.SwitchWorkspace, { part: 'workspace', subject: nextDeck }));
36
+ }
37
+
38
+ if (nextSolo && nextSolo !== state.deck.solo) {
39
+ await dispatch(
40
+ createIntent(LayoutAction.SetLayoutMode, { part: 'mode', subject: nextSolo, options: { mode: 'solo' } }),
41
+ );
42
+ } else if (!nextSolo && state.deck.solo) {
43
+ await dispatch(createIntent(LayoutAction.SetLayoutMode, { part: 'mode', options: { mode: 'deck' } }));
44
+ }
45
+ };
46
+
47
+ await handleNavigation();
48
+ window.addEventListener('popstate', handleNavigation);
49
+
50
+ const unsubscribe = scheduledEffect(
51
+ () => ({ solo: state.deck.solo, activeDeck: state.activeDeck }),
52
+ ({ solo, activeDeck }) => {
53
+ const path = solo ? `/${activeDeck}/${solo}` : `/${activeDeck}`;
54
+ if (window.location.pathname !== path) {
55
+ // TODO(thure): In some browsers, this only preserves the most recent state change, even though this is not `history.replace`…
56
+ history.pushState(null, '', `${path}${window.location.search}`);
57
+ }
58
+ },
59
+ );
60
+
61
+ return contributes(Capabilities.Null, null, () => {
62
+ window.removeEventListener('popstate', handleNavigation);
63
+ unsubscribe();
64
+ });
65
+ };
@@ -4,8 +4,7 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { Surface } from '@dxos/app-framework';
8
- import { useGraph } from '@dxos/plugin-graph';
7
+ import { Surface, useAppGraph } from '@dxos/app-framework';
9
8
  import { useAttended } from '@dxos/react-ui-attention';
10
9
 
11
10
  import { useNode, useNodeActionExpander } from '../../hooks';
@@ -13,7 +12,7 @@ import { useNode, useNodeActionExpander } from '../../hooks';
13
12
  // TODO(burdon): Factor out to effect in plugin set document title.
14
13
  export const ActiveNode = () => {
15
14
  const [id] = useAttended();
16
- const { graph } = useGraph();
15
+ const { graph } = useAppGraph();
17
16
  const activeNode = useNode(graph, id);
18
17
  useNodeActionExpander(activeNode);
19
18
 
@@ -0,0 +1,37 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { Surface } from '@dxos/app-framework';
8
+ import { type ThemedClassName } from '@dxos/react-ui';
9
+ import { mx } from '@dxos/react-ui-theme';
10
+
11
+ import { CloseSidebarButton, ToggleSidebarButton } from './SidebarButton';
12
+
13
+ export const Banner = ({ variant, classNames }: ThemedClassName<{ variant?: 'topbar' | 'sidebar' }>) => {
14
+ return (
15
+ <header
16
+ className={mx(
17
+ 'flex items-stretch relative plb-1 pis-1 pie-2',
18
+ variant === 'topbar' &&
19
+ 'fixed inset-inline-0 block-start-[env(safe-area-inset-top)] bs-[--rail-size] border-be border-separator',
20
+ classNames,
21
+ )}
22
+ >
23
+ {variant === 'sidebar' ? <CloseSidebarButton /> : <ToggleSidebarButton />}
24
+ <span className='self-center grow mis-1'>Composer</span>
25
+ {variant === 'topbar' && (
26
+ <div role='none' className='absolute inset-0 pointer-events-none'>
27
+ <div role='none' className='grid bs-full pointer-fine:p-1 max-is-md mli-auto pointer-events-auto'>
28
+ <Surface role='search-input' limit={1} />
29
+ </div>
30
+ </div>
31
+ )}
32
+ <span role='none' className='grow' />
33
+ <Surface role='header-end' limit={1} />
34
+ <Surface role='notch-start' limit={1} />
35
+ </header>
36
+ );
37
+ };
@@ -2,89 +2,172 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import React, { useMemo } from 'react';
5
+ import React, { useCallback, useEffect, useMemo, useState, type MouseEvent } from 'react';
6
6
 
7
7
  import {
8
8
  createIntent,
9
- type LayoutCoordinate,
10
- NavigationAction,
11
- SLUG_PATH_SEPARATOR,
9
+ LayoutAction,
12
10
  Surface,
11
+ useAppGraph,
12
+ useCapabilities,
13
+ useCapability,
13
14
  useIntentDispatcher,
14
15
  } from '@dxos/app-framework';
15
- import { useGraph } from '@dxos/plugin-graph';
16
- import { Main, ScrollArea } from '@dxos/react-ui';
16
+ import { Main, useTranslation, toLocalizedString, IconButton, ScrollArea } from '@dxos/react-ui';
17
17
  import { useAttended } from '@dxos/react-ui-attention';
18
- import { railGridHorizontal, StackContext } from '@dxos/react-ui-stack';
19
- import { mx } from '@dxos/react-ui-theme';
18
+ import { Tabs } from '@dxos/react-ui-tabs';
20
19
 
21
- import { NodePlankHeading } from './NodePlankHeading';
22
20
  import { PlankContentError } from './PlankError';
23
21
  import { PlankLoading } from './PlankLoading';
24
- import { useNode, useNodeActionExpander } from '../../hooks';
25
- import { type Panel } from '../../types';
26
- import { useLayout } from '../LayoutContext';
22
+ import { ToggleComplementarySidebarButton } from './SidebarButton';
23
+ import { DeckCapabilities } from '../../capabilities';
24
+ import { useNode } from '../../hooks';
25
+ import { DECK_PLUGIN } from '../../meta';
26
+ import { layoutAppliesTopbar, useBreakpoints, useHoistStatusbar } from '../../util';
27
27
 
28
28
  export type ComplementarySidebarProps = {
29
- panels: Panel[];
30
29
  current?: string;
31
30
  };
32
31
 
33
- export const ComplementarySidebar = ({ panels, current }: ComplementarySidebarProps) => {
34
- const { popoverAnchorId } = useLayout();
35
- const attended = useAttended();
36
- const panel = (panels.find((p) => p.id === current) ?? panels[0])?.id;
37
- const id = attended[0] ? `${attended[0]}${SLUG_PATH_SEPARATOR}${panel}` : undefined;
38
- const { graph } = useGraph();
39
- const node = useNode(graph, id);
32
+ export const ComplementarySidebar = ({ current }: ComplementarySidebarProps) => {
33
+ const { t } = useTranslation(DECK_PLUGIN);
40
34
  const { dispatchPromise: dispatch } = useIntentDispatcher();
41
- useNodeActionExpander(node);
35
+ const layout = useCapability(DeckCapabilities.MutableDeckState);
36
+ const attended = useAttended();
37
+ const { graph } = useAppGraph();
38
+ const node = useNode(graph, attended[0]);
39
+ const breakpoint = useBreakpoints();
40
+ const topbar = layoutAppliesTopbar(breakpoint);
41
+ const hoistStatusbar = useHoistStatusbar(breakpoint);
42
42
 
43
- const actions = useMemo(
44
- () =>
45
- panels.map(({ id, label, icon }) => ({
46
- id: `complementary-${id}`,
47
- data: () => {
48
- void dispatch(createIntent(NavigationAction.Open, { activeParts: { complementary: id } }));
49
- },
50
- properties: {
51
- label,
52
- icon,
53
- menuItemType: 'toggle',
54
- isChecked: panel === id,
55
- },
56
- })),
57
- [panel],
43
+ const panels = useCapabilities(DeckCapabilities.ComplementaryPanel);
44
+ const availablePanels = panels.filter((panel) => {
45
+ if (!node || !panel.filter) {
46
+ return true;
47
+ }
48
+
49
+ return panel.filter(node);
50
+ });
51
+ const activePanelId = availablePanels.find((panel) => panel.id === current)?.id ?? availablePanels[0]?.id;
52
+ const [internalValue, setInternalValue] = useState(activePanelId);
53
+
54
+ useEffect(() => {
55
+ setInternalValue(activePanelId);
56
+ }, [activePanelId]);
57
+
58
+ const handleTabClick = useCallback(
59
+ (event: MouseEvent) => {
60
+ const nextValue = event.currentTarget.getAttribute('data-value') as string;
61
+ if (nextValue === activePanelId) {
62
+ layout.complementarySidebarState = layout.complementarySidebarState === 'expanded' ? 'collapsed' : 'expanded';
63
+ } else {
64
+ setInternalValue(nextValue);
65
+ layout.complementarySidebarState = 'expanded';
66
+ void dispatch(createIntent(LayoutAction.UpdateComplementary, { part: 'complementary', subject: nextValue }));
67
+ }
68
+ },
69
+ [layout, activePanelId, dispatch],
58
70
  );
59
71
 
60
- // TODO(wittjosiah): Ensure that id is always defined.
61
- const coordinate: LayoutCoordinate = useMemo(() => ({ entryId: id ?? 'unknown', part: 'complementary' }), [id]);
72
+ const data = useMemo(
73
+ () =>
74
+ node && {
75
+ id: node.id,
76
+ subject: node.data,
77
+ workspace: layout.activeDeck,
78
+ popoverAnchorId: layout.popoverAnchorId,
79
+ },
80
+ [node, layout.popoverAnchorId],
81
+ );
62
82
 
63
83
  // TODO(burdon): Scroll area should be controlled by surface.
64
84
  return (
65
- <Main.ComplementarySidebar>
66
- <StackContext.Provider value={{ size: 'contain', orientation: 'horizontal', rail: true }}>
67
- <div role='none' className={mx(railGridHorizontal, 'grid grid-cols-[100%] bs-full')}>
68
- <NodePlankHeading coordinate={coordinate} node={node} popoverAnchorId={popoverAnchorId} actions={actions} />
69
- <ScrollArea.Root>
70
- <ScrollArea.Viewport>
71
- {node && (
72
- <Surface
73
- key={id}
74
- role={`complementary--${panel}`}
75
- limit={1}
76
- data={{ id, subject: node.properties.object ?? node.properties.space, popoverAnchorId }}
77
- fallback={PlankContentError}
78
- placeholder={<PlankLoading />}
85
+ <Main.ComplementarySidebar
86
+ classNames={[
87
+ topbar && 'block-start-[calc(env(safe-area-inset-top)+var(--rail-size))]',
88
+ hoistStatusbar && 'block-end-[--statusbar-size]',
89
+ ]}
90
+ >
91
+ <Tabs.Root
92
+ orientation='vertical'
93
+ verticalVariant='stateless'
94
+ value={internalValue}
95
+ attendableId={attended[0]}
96
+ classNames='contents'
97
+ >
98
+ <div
99
+ role='none'
100
+ className='absolute z-[1] inset-block-0 inline-end-0 !is-[--r0-size] pbs-[env(safe-area-inset-top)] pbe-[env(safe-area-inset-bottom)] border-is border-separator grid grid-cols-1 grid-rows-[1fr_min-content] bg-baseSurface contain-layout app-drag'
101
+ >
102
+ <Tabs.Tablist classNames='grid grid-cols-1 auto-rows-[--rail-action] p-1 gap-1 !overflow-y-auto'>
103
+ {availablePanels.map((panel) => (
104
+ <Tabs.Tab key={panel.id} value={panel.id} asChild>
105
+ <IconButton
106
+ label={toLocalizedString(panel.label, t)}
107
+ icon={panel.icon}
108
+ size={5}
109
+ iconOnly
110
+ tooltipSide='left'
111
+ data-value={panel.id}
112
+ variant={
113
+ activePanelId === panel.id
114
+ ? layout.complementarySidebarState === 'expanded'
115
+ ? 'primary'
116
+ : 'default'
117
+ : 'ghost'
118
+ }
119
+ onClick={handleTabClick}
79
120
  />
80
- )}
81
- <ScrollArea.Scrollbar orientation='vertical'>
82
- <ScrollArea.Thumb />
83
- </ScrollArea.Scrollbar>
84
- </ScrollArea.Viewport>
85
- </ScrollArea.Root>
121
+ </Tabs.Tab>
122
+ ))}
123
+ </Tabs.Tablist>
124
+ {!hoistStatusbar && (
125
+ <div role='none' className='grid grid-cols-1 auto-rows-[--rail-item] p-1 overflow-y-auto'>
126
+ <Surface role='status-bar--r0-footer' limit={1} />
127
+ </div>
128
+ )}
129
+ <div role='none' className='hidden lg:grid grid-cols-1 auto-rows-[--rail-action] p-1'>
130
+ <ToggleComplementarySidebarButton />
131
+ </div>
86
132
  </div>
87
- </StackContext.Provider>
133
+ {availablePanels.map((panel) => (
134
+ <Tabs.Tabpanel
135
+ key={panel.id}
136
+ value={panel.id}
137
+ classNames='absolute data-[state="inactive"]:-z-[1] inset-block-0 inline-start-0 is-[calc(100%-var(--r0-size))] lg:is-[--r1-size] grid grid-cols-1 grid-rows-[var(--rail-size)_1fr_min-content] pbs-[env(safe-area-inset-top)]'
138
+ {...(layout.complementarySidebarState !== 'expanded' && { inert: 'true' })}
139
+ >
140
+ {panel.id === activePanelId && data && (
141
+ <>
142
+ <h2 className='flex items-center pli-2 border-separator border-be'>
143
+ {toLocalizedString(panel.label, t)}
144
+ </h2>
145
+ <ScrollArea.Root>
146
+ <ScrollArea.Viewport>
147
+ <Surface
148
+ role={`complementary--${activePanelId}`}
149
+ data={data}
150
+ fallback={PlankContentError}
151
+ placeholder={<PlankLoading />}
152
+ />
153
+ </ScrollArea.Viewport>
154
+ <ScrollArea.Scrollbar orientation='vertical'>
155
+ <ScrollArea.Thumb />
156
+ </ScrollArea.Scrollbar>
157
+ </ScrollArea.Root>
158
+ {!hoistStatusbar && (
159
+ <div
160
+ role='contentinfo'
161
+ className='flex flex-wrap justify-center items-center border-bs border-separator pbs-1 pbe-[max(env(safe-area-inset-bottom),0.25rem)]'
162
+ >
163
+ <Surface role='status-bar--r1-footer' limit={1} />
164
+ </div>
165
+ )}
166
+ </>
167
+ )}
168
+ </Tabs.Tabpanel>
169
+ ))}
170
+ </Tabs.Root>
88
171
  </Main.ComplementarySidebar>
89
172
  );
90
173
  };
@@ -6,16 +6,21 @@ import React from 'react';
6
6
 
7
7
  import { Surface } from '@dxos/app-framework';
8
8
 
9
+ import { ToggleSidebarButton } from './SidebarButton';
10
+ import { layoutAppliesTopbar, useBreakpoints } from '../../util';
11
+ import { fixedSidebarToggleStyles } from '../fragments';
12
+
9
13
  export const ContentEmpty = () => {
14
+ const breakpoint = useBreakpoints();
15
+ const topbar = layoutAppliesTopbar(breakpoint);
10
16
  return (
11
17
  <div
12
18
  role='none'
13
- className='min-bs-screen is-dvw sm:is-full flex items-center justify-center p-8'
19
+ className='grid place-items-center p-8 relative bg-deck'
14
20
  data-testid='layoutPlugin.firstRunMessage'
15
21
  >
16
- <div role='none' className='grid place-items-center grid-rows-[min-content_min-content]'>
17
- <Surface role='keyshortcuts' />
18
- </div>
22
+ <Surface role='keyshortcuts' />
23
+ {!topbar && <ToggleSidebarButton variant='default' classNames={fixedSidebarToggleStyles} />}
19
24
  </div>
20
25
  );
21
26
  };