@dxos/plugin-deck 0.8.4-main.3f58842 → 0.8.4-main.406dc2a

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 (141) hide show
  1. package/dist/lib/browser/{app-graph-builder-JTFSDT2I.mjs → app-graph-builder-YYP67JHW.mjs} +17 -16
  2. package/dist/lib/browser/app-graph-builder-YYP67JHW.mjs.map +7 -0
  3. package/dist/lib/browser/{check-app-scheme-57U62A3A.mjs → check-app-scheme-GCOL6YDT.mjs} +6 -6
  4. package/dist/lib/browser/check-app-scheme-GCOL6YDT.mjs.map +7 -0
  5. package/dist/lib/browser/{chunk-F5BQOOEG.mjs → chunk-7I6H3N4Q.mjs} +8 -6
  6. package/dist/lib/browser/chunk-7I6H3N4Q.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-HUWUYTOI.mjs +16 -0
  8. package/dist/lib/browser/chunk-HUWUYTOI.mjs.map +7 -0
  9. package/dist/lib/browser/{chunk-D7KTFCUV.mjs → chunk-JQKOS2HB.mjs} +530 -493
  10. package/dist/lib/browser/chunk-JQKOS2HB.mjs.map +7 -0
  11. package/dist/lib/browser/chunk-MHP4GPX5.mjs +11 -0
  12. package/dist/lib/browser/chunk-MHP4GPX5.mjs.map +7 -0
  13. package/dist/lib/browser/{chunk-QDZO4AJ4.mjs → chunk-RJP5R7PY.mjs} +15 -15
  14. package/dist/lib/browser/chunk-RJP5R7PY.mjs.map +7 -0
  15. package/dist/lib/browser/{chunk-JFTXENFN.mjs → chunk-VX7MMQOW.mjs} +9 -9
  16. package/dist/lib/browser/chunk-VX7MMQOW.mjs.map +7 -0
  17. package/dist/lib/browser/index.mjs +20 -14
  18. package/dist/lib/browser/index.mjs.map +3 -3
  19. package/dist/lib/browser/{intent-resolver-P2OBK5HK.mjs → intent-resolver-7XNOEPVN.mjs} +21 -18
  20. package/dist/lib/browser/intent-resolver-7XNOEPVN.mjs.map +7 -0
  21. package/dist/lib/browser/meta.json +1 -1
  22. package/dist/lib/browser/{react-root-PO64J7ML.mjs → react-root-OJEF7YCH.mjs} +11 -11
  23. package/dist/lib/browser/react-root-OJEF7YCH.mjs.map +7 -0
  24. package/dist/lib/browser/{react-surface-E45YOVF5.mjs → react-surface-XN2NJYHO.mjs} +13 -13
  25. package/dist/lib/browser/react-surface-XN2NJYHO.mjs.map +7 -0
  26. package/dist/lib/browser/{settings-6AJZPZPM.mjs → settings-M3KSKRAP.mjs} +7 -6
  27. package/dist/lib/browser/{settings-6AJZPZPM.mjs.map → settings-M3KSKRAP.mjs.map} +3 -3
  28. package/dist/lib/browser/state-6ZSDTF6Q.mjs +12 -0
  29. package/dist/lib/browser/toolkit-L7C3UAEU.mjs +63 -0
  30. package/dist/lib/browser/toolkit-L7C3UAEU.mjs.map +7 -0
  31. package/dist/lib/browser/types/index.mjs +2 -2
  32. package/dist/lib/browser/{url-handler-7L7M6IKH.mjs → url-handler-EHTLXZRR.mjs} +7 -7
  33. package/dist/lib/browser/url-handler-EHTLXZRR.mjs.map +7 -0
  34. package/dist/types/src/DeckPlugin.d.ts +1 -1
  35. package/dist/types/src/DeckPlugin.d.ts.map +1 -1
  36. package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
  37. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
  38. package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
  39. package/dist/types/src/capabilities/check-app-scheme.d.ts +1 -1
  40. package/dist/types/src/capabilities/check-app-scheme.d.ts.map +1 -1
  41. package/dist/types/src/capabilities/index.d.ts +9 -9
  42. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  43. package/dist/types/src/capabilities/intent-resolver.d.ts +1 -1
  44. package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
  45. package/dist/types/src/capabilities/react-root.d.ts +2 -2
  46. package/dist/types/src/capabilities/react-root.d.ts.map +1 -1
  47. package/dist/types/src/capabilities/react-surface.d.ts +1 -1
  48. package/dist/types/src/capabilities/settings.d.ts +1 -1
  49. package/dist/types/src/capabilities/settings.d.ts.map +1 -1
  50. package/dist/types/src/capabilities/state.d.ts +5 -2
  51. package/dist/types/src/capabilities/state.d.ts.map +1 -1
  52. package/dist/types/src/capabilities/toolkit.d.ts +6 -0
  53. package/dist/types/src/capabilities/toolkit.d.ts.map +1 -0
  54. package/dist/types/src/capabilities/tools.d.ts +1 -1
  55. package/dist/types/src/capabilities/tools.d.ts.map +1 -1
  56. package/dist/types/src/capabilities/url-handler.d.ts +1 -1
  57. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -1
  58. package/dist/types/src/components/DeckLayout/Banner.d.ts.map +1 -1
  59. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts +2 -3
  60. package/dist/types/src/components/DeckLayout/DeckLayout.d.ts.map +1 -1
  61. package/dist/types/src/components/DeckLayout/DeckLayout.stories.d.ts +74 -0
  62. package/dist/types/src/components/DeckLayout/DeckLayout.stories.d.ts.map +1 -0
  63. package/dist/types/src/components/DeckLayout/DeckMain.d.ts +3 -0
  64. package/dist/types/src/components/DeckLayout/DeckMain.d.ts.map +1 -0
  65. package/dist/types/src/components/DeckLayout/Toast.d.ts +5 -0
  66. package/dist/types/src/components/DeckLayout/Toast.d.ts.map +1 -1
  67. package/dist/types/src/components/DeckSettings/DeckSettings.d.ts.map +1 -1
  68. package/dist/types/src/components/Plank/Plank.d.ts +1 -1
  69. package/dist/types/src/components/Plank/Plank.d.ts.map +1 -1
  70. package/dist/types/src/components/Plank/Plank.stories.d.ts +86 -5
  71. package/dist/types/src/components/Plank/Plank.stories.d.ts.map +1 -1
  72. package/dist/types/src/components/Plank/PlankError.d.ts.map +1 -1
  73. package/dist/types/src/components/Plank/PlankHeading.d.ts +1 -1
  74. package/dist/types/src/components/Plank/PlankHeading.d.ts.map +1 -1
  75. package/dist/types/src/components/Sidebar/ComplementarySidebar.d.ts.map +1 -1
  76. package/dist/types/src/events.d.ts.map +1 -1
  77. package/dist/types/src/hooks/useDeckCompanions.d.ts.map +1 -1
  78. package/dist/types/src/hooks/useHoistStatusbar.d.ts.map +1 -1
  79. package/dist/types/src/hooks/useNodeActionExpander.d.ts.map +1 -1
  80. package/dist/types/src/meta.d.ts +0 -1
  81. package/dist/types/src/meta.d.ts.map +1 -1
  82. package/dist/types/src/translations.d.ts +2 -0
  83. package/dist/types/src/translations.d.ts.map +1 -1
  84. package/dist/types/src/types/schema.d.ts +4 -3
  85. package/dist/types/src/types/schema.d.ts.map +1 -1
  86. package/dist/types/tsconfig.tsbuildinfo +1 -1
  87. package/package.json +45 -41
  88. package/src/DeckPlugin.ts +64 -59
  89. package/src/capabilities/app-graph-builder.ts +13 -11
  90. package/src/capabilities/capabilities.ts +3 -3
  91. package/src/capabilities/check-app-scheme.ts +3 -3
  92. package/src/capabilities/index.ts +2 -1
  93. package/src/capabilities/intent-resolver.ts +21 -17
  94. package/src/capabilities/react-root.tsx +4 -3
  95. package/src/capabilities/react-surface.tsx +5 -5
  96. package/src/capabilities/settings.ts +2 -1
  97. package/src/capabilities/state.ts +9 -5
  98. package/src/capabilities/toolkit.ts +57 -0
  99. package/src/capabilities/tools.ts +10 -7
  100. package/src/capabilities/url-handler.ts +3 -2
  101. package/src/components/DeckLayout/Banner.tsx +3 -3
  102. package/src/components/DeckLayout/ContentEmpty.tsx +1 -1
  103. package/src/components/DeckLayout/DeckLayout.stories.tsx +64 -0
  104. package/src/components/DeckLayout/DeckLayout.tsx +10 -279
  105. package/src/components/DeckLayout/DeckMain.tsx +285 -0
  106. package/src/components/DeckLayout/Fallback.tsx +2 -2
  107. package/src/components/DeckLayout/Toast.tsx +27 -2
  108. package/src/components/DeckSettings/DeckSettings.tsx +80 -65
  109. package/src/components/Plank/Plank.stories.tsx +9 -10
  110. package/src/components/Plank/Plank.tsx +32 -15
  111. package/src/components/Plank/PlankControls.tsx +3 -3
  112. package/src/components/Plank/PlankError.tsx +3 -2
  113. package/src/components/Plank/PlankHeading.tsx +10 -9
  114. package/src/components/Sidebar/ComplementarySidebar.tsx +9 -8
  115. package/src/components/Sidebar/Sidebar.tsx +2 -2
  116. package/src/components/Sidebar/SidebarButton.tsx +6 -6
  117. package/src/events.ts +2 -2
  118. package/src/hooks/useDeckCompanions.ts +2 -2
  119. package/src/hooks/useHoistStatusbar.ts +4 -3
  120. package/src/hooks/useNodeActionExpander.ts +1 -1
  121. package/src/meta.ts +1 -3
  122. package/src/translations.ts +2 -0
  123. package/src/types/schema.ts +5 -3
  124. package/dist/lib/browser/app-graph-builder-JTFSDT2I.mjs.map +0 -7
  125. package/dist/lib/browser/check-app-scheme-57U62A3A.mjs.map +0 -7
  126. package/dist/lib/browser/chunk-D7KTFCUV.mjs.map +0 -7
  127. package/dist/lib/browser/chunk-F5BQOOEG.mjs.map +0 -7
  128. package/dist/lib/browser/chunk-JFTXENFN.mjs.map +0 -7
  129. package/dist/lib/browser/chunk-M57WD3V6.mjs +0 -16
  130. package/dist/lib/browser/chunk-M57WD3V6.mjs.map +0 -7
  131. package/dist/lib/browser/chunk-QDZO4AJ4.mjs.map +0 -7
  132. package/dist/lib/browser/chunk-Z5KITAZW.mjs +0 -13
  133. package/dist/lib/browser/chunk-Z5KITAZW.mjs.map +0 -7
  134. package/dist/lib/browser/intent-resolver-P2OBK5HK.mjs.map +0 -7
  135. package/dist/lib/browser/react-root-PO64J7ML.mjs.map +0 -7
  136. package/dist/lib/browser/react-surface-E45YOVF5.mjs.map +0 -7
  137. package/dist/lib/browser/state-MVDYX77Y.mjs +0 -12
  138. package/dist/lib/browser/tools-TKQDPCHJ.mjs +0 -88
  139. package/dist/lib/browser/tools-TKQDPCHJ.mjs.map +0 -7
  140. package/dist/lib/browser/url-handler-7L7M6IKH.mjs.map +0 -7
  141. /package/dist/lib/browser/{state-MVDYX77Y.mjs.map → state-6ZSDTF6Q.mjs.map} +0 -0
@@ -0,0 +1,285 @@
1
+ //
2
+ // Copyright 2023 DXOS.org
3
+ //
4
+
5
+ import { untracked } from '@preact/signals-core';
6
+ import React, { Fragment, type UIEvent, useCallback, useEffect, useMemo, useRef } from 'react';
7
+
8
+ import {
9
+ Capabilities,
10
+ LayoutAction,
11
+ createIntent,
12
+ useCapability,
13
+ useIntentDispatcher,
14
+ usePluginManager,
15
+ } from '@dxos/app-framework';
16
+ import { AttentionCapabilities } from '@dxos/plugin-attention';
17
+ import { Main, type MainProps, useMediaQuery, useOnTransition } from '@dxos/react-ui';
18
+ import { DEFAULT_HORIZONTAL_SIZE, Stack, StackContext } from '@dxos/react-ui-stack';
19
+ import { mainPaddingTransitions, mx } from '@dxos/react-ui-theme';
20
+
21
+ import { DeckCapabilities } from '../../capabilities';
22
+ import { useBreakpoints, useHoistStatusbar } from '../../hooks';
23
+ import { meta } from '../../meta';
24
+ import { type DeckSettingsProps, getMode } from '../../types';
25
+ import { calculateOverscroll, layoutAppliesTopbar } from '../../util';
26
+ import { fixedComplementarySidebarToggleStyles, fixedSidebarToggleStyles } from '../fragments';
27
+ import { Plank } from '../Plank';
28
+ import { ComplementarySidebar, Sidebar, ToggleComplementarySidebarButton, ToggleSidebarButton } from '../Sidebar';
29
+
30
+ import { ContentEmpty } from './ContentEmpty';
31
+ import { StatusBar } from './StatusBar';
32
+ import { Topbar } from './Topbar';
33
+
34
+ export const DeckMain = () => {
35
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
36
+ const settings = useCapability(Capabilities.SettingsStore).getStore<DeckSettingsProps>(meta.id)?.value;
37
+ const context = useCapability(DeckCapabilities.MutableDeckState);
38
+ const { sidebarState, complementarySidebarState, complementarySidebarPanel, deck } = context;
39
+ const { active, activeCompanions, fullscreen, solo, plankSizing } = deck;
40
+ const layoutMode = getMode(deck);
41
+ const breakpoint = useBreakpoints();
42
+ const topbar = layoutAppliesTopbar(breakpoint, layoutMode);
43
+ const hoistStatusbar = useHoistStatusbar(breakpoint, layoutMode);
44
+ const pluginManager = usePluginManager();
45
+
46
+ const scrollLeftRef = useRef<number>(null);
47
+ const deckRef = useRef<HTMLDivElement>(null);
48
+
49
+ // Ensure the first plank is attended when the deck is first rendered.
50
+ useEffect(() => {
51
+ // NOTE: Not `useAttended` so that the layout component is not re-rendered when the attended list changes.
52
+ const attended = untracked(() => {
53
+ const attention = pluginManager.context.getCapability(AttentionCapabilities.Attention);
54
+ return attention.current;
55
+ });
56
+ const firstId = solo ?? active[0];
57
+ if (attended.length === 0 && firstId) {
58
+ // TODO(wittjosiah): Focusing the type button is a workaround.
59
+ // If the plank is directly focused on first load the focus ring appears.
60
+ document.querySelector<HTMLElement>(`article[data-attendable-id="${firstId}"] button`)?.focus();
61
+ }
62
+ }, []);
63
+
64
+ // Not using `breakpoint` to avoid firing when breakpoint changes between tablet and desktop.
65
+ // `ssr: false` to avoid using fallback values and flashing into solo mode on startup.
66
+ const [isNotMobile] = useMediaQuery('md');
67
+ const shouldRevert = useRef(false);
68
+ useEffect(() => {
69
+ if (!isNotMobile && getMode(deck) === 'deck') {
70
+ // NOTE: Not `useAttended` so that the layout component is not re-rendered when the attended list changes.
71
+ const attended = untracked(() => {
72
+ const attention = pluginManager.context.getCapability(AttentionCapabilities.Attention);
73
+ return attention.current;
74
+ });
75
+
76
+ shouldRevert.current = true;
77
+ void dispatch(
78
+ createIntent(LayoutAction.SetLayoutMode, { part: 'mode', subject: attended[0], options: { mode: 'solo' } }),
79
+ );
80
+ } else if (isNotMobile && getMode(deck) === 'solo' && shouldRevert.current) {
81
+ void dispatch(createIntent(LayoutAction.SetLayoutMode, { part: 'mode', options: { revert: true } }));
82
+ }
83
+ }, [isNotMobile, deck, dispatch]);
84
+
85
+ // When deck is disabled in settings, set to solo mode if the current layout mode is deck.
86
+ // TODO(thure): Applying this as an effect should be avoided over emitting the intent only when the setting changes.
87
+ useEffect(() => {
88
+ if (settings?.enableDeck && layoutMode === 'deck') {
89
+ void dispatch(
90
+ createIntent(LayoutAction.SetLayoutMode, { part: 'mode', subject: active[0], options: { mode: 'solo' } }),
91
+ );
92
+ }
93
+ }, [settings?.enableDeck, dispatch, active, layoutMode]);
94
+
95
+ /**
96
+ * Clear scroll restoration state if the window is resized.
97
+ */
98
+ const handleResize = useCallback(() => {
99
+ scrollLeftRef.current = null;
100
+ }, []);
101
+
102
+ useEffect(() => {
103
+ window.addEventListener('resize', handleResize);
104
+ return () => window.removeEventListener('resize', handleResize);
105
+ }, [handleResize]);
106
+
107
+ const restoreScroll = useCallback(() => {
108
+ if (deckRef.current && scrollLeftRef.current != null) {
109
+ deckRef.current.scrollLeft = scrollLeftRef.current;
110
+ }
111
+ }, []);
112
+ useOnTransition(layoutMode, (mode) => mode !== 'deck', 'deck', restoreScroll);
113
+
114
+ /**
115
+ * Save scroll position as the user scrolls.
116
+ */
117
+ const handleScroll = useCallback(
118
+ (event: UIEvent) => {
119
+ if (!solo && event.currentTarget === event.target) {
120
+ scrollLeftRef.current = (event.target as HTMLDivElement).scrollLeft;
121
+ }
122
+ },
123
+ [solo],
124
+ );
125
+
126
+ const isEmpty = !solo && active.length === 0;
127
+
128
+ const padding = useMemo(() => {
129
+ if (!solo && settings?.overscroll === 'centering') {
130
+ return calculateOverscroll(active.length);
131
+ }
132
+ return {};
133
+ }, [solo, settings?.overscroll, deck]);
134
+
135
+ const mainPosition = useMemo(
136
+ () => [
137
+ 'grid !block-start-[env(safe-area-inset-top)]',
138
+ topbar && '!block-start-[calc(env(safe-area-inset-top)+var(--rail-size))]',
139
+ hoistStatusbar && 'lg:block-end-[--statusbar-size]',
140
+ ],
141
+ [topbar, hoistStatusbar],
142
+ );
143
+
144
+ const { order, itemsCount }: { order: Record<string, number>; itemsCount: number } = useMemo(() => {
145
+ return active.reduce(
146
+ (acc: { order: Record<string, number>; itemsCount: number }, entryId) => {
147
+ acc.order[entryId] = acc.itemsCount + 1;
148
+ acc.itemsCount += activeCompanions?.[entryId] ? 3 : 2;
149
+ return acc;
150
+ },
151
+ { order: {}, itemsCount: 0 },
152
+ );
153
+ }, [active, activeCompanions]);
154
+
155
+ return (
156
+ <Main.Root
157
+ navigationSidebarState={fullscreen ? 'closed' : context.sidebarState}
158
+ onNavigationSidebarStateChange={(next) => (context.sidebarState = next)}
159
+ complementarySidebarState={fullscreen ? 'closed' : context.complementarySidebarState}
160
+ onComplementarySidebarStateChange={(next) => (context.complementarySidebarState = next)}
161
+ >
162
+ {/* Left sidebar. */}
163
+ <Sidebar />
164
+
165
+ {/* Right sidebar. */}
166
+ <ComplementarySidebar current={complementarySidebarPanel} />
167
+
168
+ {/* Dialog overlay to dismiss dialogs. */}
169
+ <Main.Overlay />
170
+
171
+ {/* No content. */}
172
+ {isEmpty && (
173
+ <Main.Content bounce handlesFocus classNames={mainPosition}>
174
+ <ContentEmpty />
175
+ </Main.Content>
176
+ )}
177
+
178
+ {/* Solo/deck mode. */}
179
+ {!isEmpty && (
180
+ <Main.Content
181
+ bounce
182
+ handlesFocus
183
+ classNames={mainPosition}
184
+ style={
185
+ {
186
+ '--main-spacing': settings?.encapsulatedPlanks ? '0.75rem' : '0',
187
+ '--dx-main-sidebarWidth':
188
+ sidebarState === 'expanded'
189
+ ? 'var(--nav-sidebar-size)'
190
+ : sidebarState === 'collapsed'
191
+ ? 'var(--l0-size)'
192
+ : '0',
193
+ '--dx-main-complementaryWidth':
194
+ complementarySidebarState === 'expanded'
195
+ ? 'var(--complementary-sidebar-size)'
196
+ : complementarySidebarState === 'collapsed'
197
+ ? 'var(--rail-size)'
198
+ : '0',
199
+ '--dx-main-contentFirstWidth': `${plankSizing[active[0] ?? 'never'] ?? DEFAULT_HORIZONTAL_SIZE}rem`,
200
+ '--dx-main-contentLastWidth': `${plankSizing[active[(active.length ?? 1) - 1] ?? 'never'] ?? DEFAULT_HORIZONTAL_SIZE}rem`,
201
+ } as MainProps['style']
202
+ }
203
+ >
204
+ <div
205
+ role='none'
206
+ className={!solo ? 'relative bg-deckSurface overflow-hidden' : 'sr-only'}
207
+ {...(solo && { inert: true })}
208
+ >
209
+ {!topbar && !fullscreen && <ToggleSidebarButton classNames={fixedSidebarToggleStyles} />}
210
+ {!topbar && !fullscreen && (
211
+ <ToggleComplementarySidebarButton classNames={fixedComplementarySidebarToggleStyles} />
212
+ )}
213
+ <Stack
214
+ ref={deckRef}
215
+ orientation='horizontal'
216
+ size='contain'
217
+ itemsCount={itemsCount - 1}
218
+ classNames={[
219
+ 'absolute inset-block-[--main-spacing] -inset-inline-px bs-[calc(100%-2*var(--main-spacing))]',
220
+ mainPaddingTransitions,
221
+ ]}
222
+ style={padding}
223
+ onScroll={handleScroll}
224
+ >
225
+ {active.map((entryId) => (
226
+ <Fragment key={entryId}>
227
+ <PlankSeparator order={order[entryId] - 1} encapsulate={!!settings?.enableDeck} />
228
+ <Plank
229
+ id={entryId}
230
+ companionId={activeCompanions?.[entryId]}
231
+ part='deck'
232
+ order={order[entryId]}
233
+ active={active}
234
+ layoutMode={layoutMode}
235
+ settings={settings}
236
+ />
237
+ </Fragment>
238
+ ))}
239
+ </Stack>
240
+ </div>
241
+ <div
242
+ role='none'
243
+ className={solo ? 'relative overflow-hidden bg-deckSurface' : 'sr-only'}
244
+ {...(!solo && { inert: true })}
245
+ >
246
+ {!topbar && !fullscreen && <ToggleSidebarButton classNames={fixedSidebarToggleStyles} />}
247
+ {!topbar && !fullscreen && (
248
+ <ToggleComplementarySidebarButton classNames={fixedComplementarySidebarToggleStyles} />
249
+ )}
250
+ <StackContext.Provider
251
+ value={{
252
+ orientation: 'horizontal',
253
+ size: 'contain',
254
+ rail: true,
255
+ }}
256
+ >
257
+ <Plank
258
+ id={solo}
259
+ companionId={solo ? activeCompanions?.[solo] : undefined}
260
+ part='solo'
261
+ layoutMode={layoutMode}
262
+ settings={settings}
263
+ />
264
+ </StackContext.Provider>
265
+ </div>
266
+ </Main.Content>
267
+ )}
268
+
269
+ {/* Topbar. */}
270
+ {topbar && <Topbar />}
271
+
272
+ {/* Status bar. */}
273
+ {hoistStatusbar && <StatusBar showHints={settings?.showHints} />}
274
+ </Main.Root>
275
+ );
276
+ };
277
+
278
+ const PlankSeparator = ({ order, encapsulate }: { order: number; encapsulate?: boolean }) =>
279
+ order > 0 ? (
280
+ <span
281
+ role='separator'
282
+ className={mx('row-span-2 bg-deckSurface', encapsulate ? 'is-0' : 'is-4')}
283
+ style={{ gridColumn: order }}
284
+ />
285
+ ) : null;
@@ -7,10 +7,10 @@ import React from 'react';
7
7
  import { useTranslation } from '@dxos/react-ui';
8
8
  import { errorText, mx } from '@dxos/react-ui-theme';
9
9
 
10
- import { DECK_PLUGIN } from '../../meta';
10
+ import { meta } from '../../meta';
11
11
 
12
12
  export const Fallback = () => {
13
- const { t } = useTranslation(DECK_PLUGIN);
13
+ const { t } = useTranslation(meta.id);
14
14
 
15
15
  return (
16
16
  <div role='none' className='min-bs-screen is-full flex items-center justify-center p-8'>
@@ -14,7 +14,7 @@ import {
14
14
  useTranslation,
15
15
  } from '@dxos/react-ui';
16
16
 
17
- import { DECK_PLUGIN } from '../../meta';
17
+ import { meta } from '../../meta';
18
18
 
19
19
  // TODO(wittjosiah): Render remaining duration as a progress bar within the toast.
20
20
  export const Toast = ({
@@ -29,7 +29,7 @@ export const Toast = ({
29
29
  onAction,
30
30
  onOpenChange,
31
31
  }: LayoutAction.Toast & Pick<ToastRootProps, 'onOpenChange'>) => {
32
- const { t } = useTranslation(DECK_PLUGIN);
32
+ const { t } = useTranslation(meta.id);
33
33
 
34
34
  return (
35
35
  <NaturalToast.Root data-testid={id} defaultOpen duration={duration} onOpenChange={onOpenChange}>
@@ -59,3 +59,28 @@ export const Toast = ({
59
59
  </NaturalToast.Root>
60
60
  );
61
61
  };
62
+
63
+ export type ToasterProps = {
64
+ toasts?: LayoutAction.Toast[];
65
+ onDismissToast?: (id: string) => void;
66
+ };
67
+
68
+ export const Toaster = ({ toasts, onDismissToast }: ToasterProps) => {
69
+ return (
70
+ <>
71
+ {toasts?.map((toast) => (
72
+ <Toast
73
+ {...toast}
74
+ key={toast.id}
75
+ onOpenChange={(open) => {
76
+ if (!open) {
77
+ onDismissToast?.(toast.id);
78
+ }
79
+
80
+ return open;
81
+ }}
82
+ />
83
+ ))}
84
+ </>
85
+ );
86
+ };
@@ -5,9 +5,9 @@
5
5
  import React from 'react';
6
6
 
7
7
  import { Input, Select, useTranslation } from '@dxos/react-ui';
8
- import { DeprecatedFormContainer, DeprecatedFormInput } from '@dxos/react-ui-form';
8
+ import { ControlGroup, ControlItemInput, ControlPage, ControlSection } from '@dxos/react-ui-form';
9
9
 
10
- import { DECK_PLUGIN } from '../../meta';
10
+ import { meta } from '../../meta';
11
11
  import {
12
12
  type DeckSettingsProps,
13
13
  type NewPlankPositioning,
@@ -19,70 +19,85 @@ import {
19
19
  const isSocket = !!(globalThis as any).__args;
20
20
 
21
21
  export const DeckSettings = ({ settings }: { settings: DeckSettingsProps }) => {
22
- const { t } = useTranslation(DECK_PLUGIN);
22
+ const { t } = useTranslation(meta.id);
23
23
 
24
24
  return (
25
- <DeprecatedFormContainer>
26
- <DeprecatedFormInput label={t('settings enable deck label')}>
27
- <Input.Switch checked={settings.enableDeck} onCheckedChange={(checked) => (settings.enableDeck = checked)} />
28
- </DeprecatedFormInput>
29
- <DeprecatedFormInput label={t('select new plank positioning label')}>
30
- <Select.Root
31
- disabled={!settings.enableDeck}
32
- value={settings.newPlankPositioning ?? 'start'}
33
- onValueChange={(value) => (settings.newPlankPositioning = value as NewPlankPositioning)}
34
- >
35
- <Select.TriggerButton placeholder={t('select new plank positioning placeholder')} />
36
- <Select.Portal>
37
- <Select.Content>
38
- <Select.Viewport>
39
- {NewPlankPositions.map((position) => (
40
- <Select.Option key={position} value={position}>
41
- {t(`settings new plank position ${position} label`)}
42
- </Select.Option>
43
- ))}
44
- </Select.Viewport>
45
- </Select.Content>
46
- </Select.Portal>
47
- </Select.Root>
48
- </DeprecatedFormInput>
49
- <DeprecatedFormInput label={t('settings overscroll label')}>
50
- <Select.Root
51
- disabled={!settings.enableDeck}
52
- value={settings.overscroll ?? 'none'}
53
- onValueChange={(value) => (settings.overscroll = value as Overscroll)}
54
- >
55
- <Select.TriggerButton placeholder={t('select overscroll placeholder')} />
56
- <Select.Portal>
57
- <Select.Content>
58
- <Select.Viewport>
59
- {OverscrollOptions.map((option) => (
60
- <Select.Option key={option} value={option}>
61
- {t(`settings overscroll ${option} label`)}
62
- </Select.Option>
63
- ))}
64
- </Select.Viewport>
65
- </Select.Content>
66
- </Select.Portal>
67
- </Select.Root>
68
- </DeprecatedFormInput>
69
- <DeprecatedFormInput label={t('settings enable statusbar label')}>
70
- <Input.Switch
71
- checked={settings.enableStatusbar}
72
- onCheckedChange={(checked) => (settings.enableStatusbar = checked)}
73
- />
74
- </DeprecatedFormInput>
75
- <DeprecatedFormInput label={t('settings show hints label')}>
76
- <Input.Switch checked={settings.showHints} onCheckedChange={(checked) => (settings.showHints = checked)} />
77
- </DeprecatedFormInput>
78
- {!isSocket && (
79
- <DeprecatedFormInput label={t('settings native redirect label')}>
80
- <Input.Switch
81
- checked={settings.enableNativeRedirect}
82
- onCheckedChange={(checked) => (settings.enableNativeRedirect = checked)}
83
- />
84
- </DeprecatedFormInput>
85
- )}
86
- </DeprecatedFormContainer>
25
+ <ControlPage>
26
+ <ControlSection title={t('settings title', { ns: meta.id })}>
27
+ <ControlGroup>
28
+ <ControlItemInput title={t('settings enable deck label')}>
29
+ <Input.Switch
30
+ checked={settings.enableDeck}
31
+ onCheckedChange={(checked) => (settings.enableDeck = checked)}
32
+ />
33
+ </ControlItemInput>
34
+ <ControlItemInput title={t('settings encapsulated planks label')}>
35
+ <Input.Switch
36
+ checked={settings.encapsulatedPlanks ?? false}
37
+ onCheckedChange={(checked) => (settings.encapsulatedPlanks = checked)}
38
+ />
39
+ </ControlItemInput>
40
+ <ControlItemInput title={t('select new plank positioning label')}>
41
+ <Select.Root
42
+ disabled={!settings.enableDeck}
43
+ value={settings.newPlankPositioning ?? 'start'}
44
+ onValueChange={(value) => (settings.newPlankPositioning = value as NewPlankPositioning)}
45
+ >
46
+ <Select.TriggerButton placeholder={t('select new plank positioning placeholder')} />
47
+ <Select.Portal>
48
+ <Select.Content>
49
+ <Select.Viewport>
50
+ {NewPlankPositions.map((position) => (
51
+ <Select.Option key={position} value={position}>
52
+ {t(`settings new plank position ${position} label`)}
53
+ </Select.Option>
54
+ ))}
55
+ </Select.Viewport>
56
+ <Select.Arrow />
57
+ </Select.Content>
58
+ </Select.Portal>
59
+ </Select.Root>
60
+ </ControlItemInput>
61
+ <ControlItemInput title={t('settings overscroll label')}>
62
+ <Select.Root
63
+ disabled={!settings.enableDeck}
64
+ value={settings.overscroll ?? 'none'}
65
+ onValueChange={(value) => (settings.overscroll = value as Overscroll)}
66
+ >
67
+ <Select.TriggerButton placeholder={t('select overscroll placeholder')} />
68
+ <Select.Portal>
69
+ <Select.Content>
70
+ <Select.Viewport>
71
+ {OverscrollOptions.map((option) => (
72
+ <Select.Option key={option} value={option}>
73
+ {t(`settings overscroll ${option} label`)}
74
+ </Select.Option>
75
+ ))}
76
+ </Select.Viewport>
77
+ <Select.Arrow />
78
+ </Select.Content>
79
+ </Select.Portal>
80
+ </Select.Root>
81
+ </ControlItemInput>
82
+ <ControlItemInput title={t('settings enable statusbar label')}>
83
+ <Input.Switch
84
+ checked={settings.enableStatusbar}
85
+ onCheckedChange={(checked) => (settings.enableStatusbar = checked)}
86
+ />
87
+ </ControlItemInput>
88
+ <ControlItemInput title={t('settings show hints label')}>
89
+ <Input.Switch checked={settings.showHints} onCheckedChange={(checked) => (settings.showHints = checked)} />
90
+ </ControlItemInput>
91
+ {!isSocket && (
92
+ <ControlItemInput title={t('settings native redirect label')}>
93
+ <Input.Switch
94
+ checked={settings.enableNativeRedirect}
95
+ onCheckedChange={(checked) => (settings.enableNativeRedirect = checked)}
96
+ />
97
+ </ControlItemInput>
98
+ )}
99
+ </ControlGroup>
100
+ </ControlSection>
101
+ </ControlPage>
87
102
  );
88
103
  };
@@ -2,23 +2,22 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { type StoryObj, type Meta } from '@storybook/react-vite';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
8
6
  import React from 'react';
9
7
 
10
8
  import { IntentPlugin, SettingsPlugin } from '@dxos/app-framework';
11
9
  import { withPluginManager } from '@dxos/app-framework/testing';
12
10
  import { AttentionPlugin } from '@dxos/plugin-attention';
13
11
  import { GraphPlugin } from '@dxos/plugin-graph';
12
+ import { withTheme } from '@dxos/react-ui/testing';
14
13
  import { Stack } from '@dxos/react-ui-stack';
15
- import { withTheme, withLayout } from '@dxos/storybook-utils';
16
14
 
17
- import { Plank, type PlankProps } from './Plank';
18
15
  import { DeckStateFactory } from '../../capabilities';
19
16
  import { translations } from '../../translations';
20
17
 
21
- const meta: Meta<PlankProps> = {
18
+ import { Plank } from './Plank';
19
+
20
+ const meta = {
22
21
  title: 'plugins/plugin-deck/Plank',
23
22
  component: Plank,
24
23
  render: (args) => {
@@ -29,21 +28,21 @@ const meta: Meta<PlankProps> = {
29
28
  );
30
29
  },
31
30
  decorators: [
31
+ withTheme,
32
32
  withPluginManager({
33
33
  plugins: [AttentionPlugin(), SettingsPlugin(), IntentPlugin(), GraphPlugin()],
34
34
  capabilities: () => DeckStateFactory(),
35
35
  }),
36
- withTheme,
37
- withLayout({ fullscreen: true }),
38
36
  ],
39
37
  parameters: {
38
+ layout: 'fullscreen',
40
39
  translations,
41
40
  },
42
- };
41
+ } satisfies Meta<typeof Plank>;
43
42
 
44
43
  export default meta;
45
44
 
46
- type Story = StoryObj<PlankProps>;
45
+ type Story = StoryObj<typeof meta>;
47
46
 
48
47
  // TODO(burdon): Need to define surface provider?
49
48
  export const Default: Story = {
@@ -16,23 +16,24 @@ import {
16
16
  LayoutAction,
17
17
  Surface,
18
18
  createIntent,
19
- useCapability,
20
19
  useAppGraph,
20
+ useCapability,
21
21
  useIntentDispatcher,
22
22
  } from '@dxos/app-framework';
23
23
  import { debounce } from '@dxos/async';
24
- import { useNode, type Node } from '@dxos/plugin-graph';
24
+ import { type Node, useNode } from '@dxos/plugin-graph';
25
25
  import { ATTENDABLE_PATH_SEPARATOR, useAttentionAttributes } from '@dxos/react-ui-attention';
26
26
  import { StackItem, railGridHorizontal } from '@dxos/react-ui-stack';
27
27
  import { mainIntrinsicSize, mx } from '@dxos/react-ui-theme';
28
28
 
29
+ import { DeckCapabilities } from '../../capabilities';
30
+ import { useCompanions, useMainSize } from '../../hooks';
31
+ import { parseEntryId } from '../../layout';
32
+ import { DeckAction, type DeckSettingsProps, type LayoutMode, type ResolvedPart } from '../../types';
33
+
29
34
  import { PlankContentError, PlankError } from './PlankError';
30
35
  import { PlankHeading } from './PlankHeading';
31
36
  import { PlankLoading } from './PlankLoading';
32
- import { DeckCapabilities } from '../../capabilities';
33
- import { useMainSize, useCompanions } from '../../hooks';
34
- import { parseEntryId } from '../../layout';
35
- import { DeckAction, type LayoutMode, type ResolvedPart, type DeckSettingsProps } from '../../types';
36
37
 
37
38
  const UNKNOWN_ID = 'unknown_id';
38
39
 
@@ -67,7 +68,11 @@ export const Plank = memo(({ id = UNKNOWN_ID, companionId, ...props }: PlankProp
67
68
  const hasCompanion = !!(companionId && currentCompanion);
68
69
 
69
70
  return (
70
- <PlankContainer solo={props.part === 'solo'} companion={hasCompanion}>
71
+ <PlankContainer
72
+ solo={props.part === 'solo'}
73
+ companion={hasCompanion}
74
+ encapsulate={!!props.settings?.encapsulatedPlanks}
75
+ >
71
76
  <PlankComponent
72
77
  id={id}
73
78
  node={node}
@@ -91,7 +96,12 @@ export const Plank = memo(({ id = UNKNOWN_ID, companionId, ...props }: PlankProp
91
96
  );
92
97
  });
93
98
 
94
- const PlankContainer = ({ children, solo, companion }: PropsWithChildren<{ solo: boolean; companion: boolean }>) => {
99
+ const PlankContainer = ({
100
+ children,
101
+ solo,
102
+ companion,
103
+ encapsulate,
104
+ }: PropsWithChildren<{ solo: boolean; companion: boolean; encapsulate: boolean }>) => {
95
105
  const sizeAttrs = useMainSize();
96
106
  if (!solo) {
97
107
  return children;
@@ -101,7 +111,13 @@ const PlankContainer = ({ children, solo, companion }: PropsWithChildren<{ solo:
101
111
  return (
102
112
  <div
103
113
  role='none'
104
- className={mx('absolute inset-0 grid', companion && 'grid-cols-[1fr_1fr]', railGridHorizontal, mainIntrinsicSize)}
114
+ className={mx(
115
+ 'absolute inset-[--main-spacing] grid',
116
+ encapsulate && 'border border-separator rounded overflow-hidden',
117
+ companion && 'grid-cols-[6fr_4fr]',
118
+ railGridHorizontal,
119
+ mainIntrinsicSize,
120
+ )}
105
121
  {...sizeAttrs}
106
122
  >
107
123
  {children}
@@ -170,11 +186,7 @@ const PlankComponent = memo(
170
186
 
171
187
  useLayoutEffect(() => {
172
188
  if (scrollIntoView === id) {
173
- // TODO(wittjosiah): When focused on page load, the focus is always visible.
174
- // Forcing focus to something smaller than the plank prevents large focus ring in the interim.
175
- const focusable = rootElement.current?.querySelector('button') || rootElement.current;
176
- focusable?.focus({ preventScroll: true });
177
- layoutMode === 'deck' && focusable?.scrollIntoView({ behavior: 'smooth', inline: 'center' });
189
+ layoutMode === 'deck' && rootElement.current?.scrollIntoView({ behavior: 'smooth', inline: 'center' });
178
190
  // Clear the scroll into view state once it has been actioned.
179
191
  void dispatch(createIntent(LayoutAction.ScrollIntoView, { part: 'current', subject: undefined }));
180
192
  }
@@ -189,13 +201,15 @@ const PlankComponent = memo(
189
201
  const data = useMemo(
190
202
  () =>
191
203
  node && {
204
+ attendableId: id,
192
205
  subject: node.data,
193
206
  companionTo: primary?.data,
207
+ properties: node.properties,
194
208
  variant,
195
209
  path,
196
210
  popoverAnchorId,
197
211
  },
198
- [node, node?.data, path, popoverAnchorId, primary?.data, variant],
212
+ [node, node?.data, node?.properties, path, popoverAnchorId, primary?.data, variant],
199
213
  );
200
214
 
201
215
  // TODO(wittjosiah): Change prop to accept a component.
@@ -211,6 +225,9 @@ const PlankComponent = memo(
211
225
  part === 'deck' && (companioned === 'companion' ? '!border-separator border-ie' : '!border-separator border-li'),
212
226
  part.startsWith('solo-') && 'row-span-2 grid-rows-subgrid min-is-0',
213
227
  part === 'solo-companion' && '!border-separator border-is',
228
+ settings?.encapsulatedPlanks &&
229
+ !part.startsWith('solo') &&
230
+ 'mli-[--main-spacing] !border-separator border rounded overflow-hidden',
214
231
  );
215
232
 
216
233
  return (