@dxos/plugin-simple-layout 0.0.0 → 0.8.4-main.1c7ec43d41

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 (207) hide show
  1. package/dist/lib/browser/SimpleLayoutPlugin-Q5BZE6KD.mjs +50 -0
  2. package/dist/lib/browser/SimpleLayoutPlugin-Q5BZE6KD.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +25 -0
  4. package/dist/lib/browser/index.mjs.map +7 -0
  5. package/dist/lib/browser/meta.json +1 -0
  6. package/dist/lib/browser/translations.mjs +34 -0
  7. package/dist/lib/browser/translations.mjs.map +7 -0
  8. package/dist/lib/node-esm/SimpleLayoutPlugin-OD45TNPO.mjs +52 -0
  9. package/dist/lib/node-esm/SimpleLayoutPlugin-OD45TNPO.mjs.map +7 -0
  10. package/dist/lib/node-esm/index.mjs +27 -0
  11. package/dist/lib/node-esm/index.mjs.map +7 -0
  12. package/dist/lib/node-esm/meta.json +1 -0
  13. package/dist/lib/node-esm/translations.mjs +36 -0
  14. package/dist/lib/node-esm/translations.mjs.map +7 -0
  15. package/dist/types/src/SimpleLayoutPlugin.d.ts +8 -0
  16. package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -0
  17. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  18. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  19. package/dist/types/src/capabilities/index.d.ts +22 -0
  20. package/dist/types/src/capabilities/index.d.ts.map +1 -0
  21. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  22. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  23. package/dist/types/src/capabilities/react-root.d.ts +9 -0
  24. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  25. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  26. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  27. package/dist/types/src/capabilities/spotlight-dismiss.d.ts +14 -0
  28. package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
  29. package/dist/types/src/capabilities/state.d.ts +19 -0
  30. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  31. package/dist/types/src/capabilities/url-handler.d.ts +12 -0
  32. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
  33. package/dist/types/src/components/ContentError.stories.d.ts +46 -0
  34. package/dist/types/src/components/ContentError.stories.d.ts.map +1 -0
  35. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
  36. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
  37. package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
  38. package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
  39. package/dist/types/src/components/Dialog/Dialog.d.ts +3 -0
  40. package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -0
  41. package/dist/types/src/components/Dialog/index.d.ts +2 -0
  42. package/dist/types/src/components/Dialog/index.d.ts.map +1 -0
  43. package/dist/types/src/components/Home/Home.d.ts +7 -0
  44. package/dist/types/src/components/Home/Home.d.ts.map +1 -0
  45. package/dist/types/src/components/Home/index.d.ts +2 -0
  46. package/dist/types/src/components/Home/index.d.ts.map +1 -0
  47. package/dist/types/src/components/Loading/Loading.d.ts +3 -0
  48. package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
  49. package/dist/types/src/components/Loading/Loading.stories.d.ts +13 -0
  50. package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
  51. package/dist/types/src/components/Loading/index.d.ts +2 -0
  52. package/dist/types/src/components/Loading/index.d.ts.map +1 -0
  53. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +35 -0
  54. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -0
  55. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts +7 -0
  56. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -0
  57. package/dist/types/src/components/MobileLayout/index.d.ts +2 -0
  58. package/dist/types/src/components/MobileLayout/index.d.ts.map +1 -0
  59. package/dist/types/src/components/NavBranch/NavBranch.d.ts +11 -0
  60. package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -0
  61. package/dist/types/src/components/NavBranch/index.d.ts +2 -0
  62. package/dist/types/src/components/NavBranch/index.d.ts.map +1 -0
  63. package/dist/types/src/components/Popover/Popover.d.ts +4 -0
  64. package/dist/types/src/components/Popover/Popover.d.ts.map +1 -0
  65. package/dist/types/src/components/Popover/index.d.ts +2 -0
  66. package/dist/types/src/components/Popover/index.d.ts.map +1 -0
  67. package/dist/types/src/components/SimpleLayout/AppBar.d.ts +24 -0
  68. package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
  69. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +54 -0
  70. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -0
  71. package/dist/types/src/components/SimpleLayout/Drawer.d.ts +6 -0
  72. package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -0
  73. package/dist/types/src/components/SimpleLayout/Main.d.ts +6 -0
  74. package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -0
  75. package/dist/types/src/components/SimpleLayout/NavBar.d.ts +16 -0
  76. package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -0
  77. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +49 -0
  78. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -0
  79. package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts +3 -0
  80. package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -0
  81. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +48 -0
  82. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -0
  83. package/dist/types/src/components/SimpleLayout/index.d.ts +5 -0
  84. package/dist/types/src/components/SimpleLayout/index.d.ts.map +1 -0
  85. package/dist/types/src/components/hooks.d.ts +7 -0
  86. package/dist/types/src/components/hooks.d.ts.map +1 -0
  87. package/dist/types/src/components/index.d.ts +8 -0
  88. package/dist/types/src/components/index.d.ts.map +1 -0
  89. package/dist/types/src/hooks/actions.d.ts +19 -0
  90. package/dist/types/src/hooks/actions.d.ts.map +1 -0
  91. package/dist/types/src/hooks/index.d.ts +7 -0
  92. package/dist/types/src/hooks/index.d.ts.map +1 -0
  93. package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
  94. package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
  95. package/dist/types/src/hooks/useCompanions.d.ts +12 -0
  96. package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
  97. package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
  98. package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
  99. package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
  100. package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
  101. package/dist/types/src/hooks/useSimpleLayoutState.d.ts +7 -0
  102. package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -0
  103. package/dist/types/src/index.d.ts +4 -0
  104. package/dist/types/src/index.d.ts.map +1 -0
  105. package/dist/types/src/meta.d.ts +3 -0
  106. package/dist/types/src/meta.d.ts.map +1 -0
  107. package/dist/types/src/operations/close.d.ts +5 -0
  108. package/dist/types/src/operations/close.d.ts.map +1 -0
  109. package/dist/types/src/operations/index.d.ts +3 -0
  110. package/dist/types/src/operations/index.d.ts.map +1 -0
  111. package/dist/types/src/operations/open.d.ts +5 -0
  112. package/dist/types/src/operations/open.d.ts.map +1 -0
  113. package/dist/types/src/operations/revert-workspace.d.ts +5 -0
  114. package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
  115. package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
  116. package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
  117. package/dist/types/src/operations/set.d.ts +5 -0
  118. package/dist/types/src/operations/set.d.ts.map +1 -0
  119. package/dist/types/src/operations/state-access.d.ts +8 -0
  120. package/dist/types/src/operations/state-access.d.ts.map +1 -0
  121. package/dist/types/src/operations/switch-workspace.d.ts +5 -0
  122. package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
  123. package/dist/types/src/operations/update-complementary.d.ts +5 -0
  124. package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
  125. package/dist/types/src/operations/update-dialog.d.ts +5 -0
  126. package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
  127. package/dist/types/src/operations/update-popover.d.ts +5 -0
  128. package/dist/types/src/operations/update-popover.d.ts.map +1 -0
  129. package/dist/types/src/operations/update-sidebar.d.ts +5 -0
  130. package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
  131. package/dist/types/src/translations.d.ts +32 -0
  132. package/dist/types/src/translations.d.ts.map +1 -0
  133. package/dist/types/src/types/capabilities.d.ts +44 -0
  134. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  135. package/dist/types/src/types/events.d.ts +6 -0
  136. package/dist/types/src/types/events.d.ts.map +1 -0
  137. package/dist/types/src/types/index.d.ts +3 -0
  138. package/dist/types/src/types/index.d.ts.map +1 -0
  139. package/dist/types/tsconfig.tsbuildinfo +1 -0
  140. package/package.json +58 -29
  141. package/src/SimpleLayoutPlugin.ts +39 -11
  142. package/src/capabilities/app-graph-builder.ts +21 -0
  143. package/src/capabilities/index.ts +13 -3
  144. package/src/capabilities/operation-handler.ts +14 -0
  145. package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +4 -4
  146. package/src/capabilities/react-surface.tsx +50 -0
  147. package/src/{hooks/useSpotlightDismiss.ts → capabilities/spotlight-dismiss.ts} +31 -40
  148. package/src/capabilities/state.tsx +52 -0
  149. package/src/capabilities/url-handler.ts +161 -0
  150. package/src/components/ContentError.stories.tsx +9 -8
  151. package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
  152. package/src/components/DebugOverlay/index.ts +5 -0
  153. package/src/components/Dialog/Dialog.tsx +26 -15
  154. package/src/components/Home/Home.tsx +80 -80
  155. package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +5 -5
  156. package/src/components/{ContentLoading.tsx → Loading/Loading.tsx} +2 -2
  157. package/src/components/Loading/index.ts +5 -0
  158. package/src/components/MobileLayout/MobileLayout.stories.tsx +133 -0
  159. package/src/components/MobileLayout/MobileLayout.tsx +374 -0
  160. package/src/components/MobileLayout/index.ts +5 -0
  161. package/src/components/NavBranch/NavBranch.tsx +124 -0
  162. package/src/components/NavBranch/index.ts +5 -0
  163. package/src/components/Popover/Popover.tsx +49 -27
  164. package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
  165. package/src/components/SimpleLayout/AppBar.tsx +94 -0
  166. package/src/components/SimpleLayout/Drawer.tsx +104 -0
  167. package/src/components/SimpleLayout/Main.tsx +54 -61
  168. package/src/components/SimpleLayout/NavBar.stories.tsx +164 -0
  169. package/src/components/SimpleLayout/NavBar.tsx +19 -83
  170. package/src/components/SimpleLayout/SimpleLayout.stories.tsx +44 -61
  171. package/src/components/SimpleLayout/SimpleLayout.tsx +45 -8
  172. package/src/components/SimpleLayout/index.ts +3 -0
  173. package/src/components/hooks.ts +26 -0
  174. package/src/components/index.ts +4 -1
  175. package/src/hooks/actions.ts +84 -0
  176. package/src/hooks/index.ts +6 -1
  177. package/src/hooks/useAppBarProps.ts +95 -0
  178. package/src/hooks/useCompanions.ts +22 -0
  179. package/src/hooks/useDrawerActions.ts +100 -0
  180. package/src/hooks/useNavbarActions.ts +87 -0
  181. package/src/hooks/useSimpleLayoutState.ts +30 -0
  182. package/src/index.ts +7 -1
  183. package/src/meta.ts +2 -1
  184. package/src/operations/close.ts +34 -0
  185. package/src/operations/index.ts +16 -0
  186. package/src/operations/open.ts +63 -0
  187. package/src/operations/revert-workspace.ts +22 -0
  188. package/src/operations/set-layout-mode.ts +12 -0
  189. package/src/operations/set.ts +23 -0
  190. package/src/operations/state-access.ts +19 -0
  191. package/src/operations/switch-workspace.ts +26 -0
  192. package/src/operations/update-complementary.ts +35 -0
  193. package/src/operations/update-dialog.ts +28 -0
  194. package/src/operations/update-popover.ts +35 -0
  195. package/src/operations/update-sidebar.ts +12 -0
  196. package/src/translations.ts +21 -13
  197. package/src/types/capabilities.ts +23 -7
  198. package/src/types/events.ts +15 -0
  199. package/src/types/index.ts +1 -0
  200. package/src/capabilities/operation-resolver/index.ts +0 -10
  201. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -135
  202. package/src/capabilities/react-root/index.ts +0 -7
  203. package/src/capabilities/state/index.ts +0 -9
  204. package/src/capabilities/state/state.tsx +0 -60
  205. package/src/components/ContentError.tsx +0 -23
  206. package/src/components/SimpleLayout/Banner.tsx +0 -60
  207. package/src/components/SimpleLayout/NavBarstories.tsx +0 -59
@@ -2,96 +2,32 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
+ import { type Atom } from '@effect-atom/atom-react';
5
6
  import React from 'react';
6
7
 
7
- import { useAppGraph } from '@dxos/app-framework/react';
8
- import { Node, useActionRunner, useConnections } from '@dxos/plugin-graph';
9
- import {
10
- Avatar,
11
- Button,
12
- ButtonGroup,
13
- DensityProvider,
14
- IconButton,
15
- type Size,
16
- Tooltip,
17
- useTranslation,
18
- } from '@dxos/react-ui';
19
- import { DropdownMenu, MenuProvider } from '@dxos/react-ui-menu';
20
- import { mx, surfaceZIndex } from '@dxos/ui-theme';
8
+ import { type ActionExecutor, type ActionGraphProps, Menu, useMenuActions } from '@dxos/react-ui-menu';
9
+ import { composable, composableProps } from '@dxos/ui-theme';
21
10
 
22
- import { meta } from '../../meta';
23
-
24
- const buttonProps = {
25
- iconOnly: true,
26
- size: 6 as Size,
27
- classNames: 'aspect-square',
28
- };
11
+ const NAVBAR_NAME = 'SimpleLayout.NavBar';
29
12
 
30
13
  export type NavBarProps = {
31
- activeId?: string;
32
- onActiveIdChange?: (nextActiveId: string | null) => void;
14
+ /** Action graph atom for the toolbar. */
15
+ actions: Atom.Atom<ActionGraphProps>;
16
+ /** Action executor callback. */
17
+ onAction?: ActionExecutor;
33
18
  };
34
19
 
35
- export const NavBar = ({ activeId, onActiveIdChange }: NavBarProps) => {
36
- const { t } = useTranslation(meta.id);
37
- const { graph } = useAppGraph();
38
- const runAction = useActionRunner();
39
-
40
- const connections = useConnections(graph, Node.RootId);
41
- const menuActions = connections.filter((node) => node.properties.disposition === 'menu');
42
-
43
- const isBrowseActive = activeId !== 'notifications' && activeId !== 'profile';
20
+ /**
21
+ * Presentational navbar component that renders a toolbar from an action graph.
22
+ */
23
+ export const NavBar = composable<HTMLDivElement, NavBarProps>(({ actions, onAction, ...props }, forwardedRef) => {
24
+ const menuActions = useMenuActions(actions);
44
25
 
45
26
  return (
46
- <DensityProvider density='coarse'>
47
- <nav
48
- className={mx(
49
- 'fixed inset-inline-0',
50
- 'grid grid-cols-[min-content_min-content] gap-2 place-content-center',
51
- 'block-end-[--dx-mobile-bottombar-inset-bottom,0px] bs-[--dx-mobile-bottombar-content-height,64px]',
52
- 'bg-baseSurface border-bs border-separator',
53
- surfaceZIndex({ level: 'menu' }),
54
- )}
55
- >
56
- <ButtonGroup>
57
- <IconButton
58
- {...buttonProps}
59
- label={t('browse label')}
60
- icon='ph--squares-four--regular'
61
- onClick={() => onActiveIdChange?.(null)}
62
- variant={isBrowseActive ? 'primary' : 'default'}
63
- {...(isBrowseActive && { 'aria-current': 'location' })}
64
- />
65
- <IconButton
66
- {...buttonProps}
67
- label={t('notifications label')}
68
- icon='ph--bell-simple--regular'
69
- onClick={() => onActiveIdChange?.('notifications')}
70
- variant={activeId === 'notifications' ? 'primary' : 'default'}
71
- {...(activeId === 'notifications' && { 'aria-current': 'location' })}
72
- />
73
- <Button
74
- variant={activeId === 'profile' ? 'primary' : 'default'}
75
- onClick={() => onActiveIdChange?.('profile')}
76
- classNames={buttonProps.classNames}
77
- >
78
- <span className='sr-only'>{t('profile label')}</span>
79
- <Avatar.Root>
80
- <Avatar.Label classNames='sr-only'>Profile display name</Avatar.Label>
81
- <Avatar.Content size={8} status='active' hue='cyan' fallback='🗿' />
82
- </Avatar.Root>
83
- </Button>
84
- </ButtonGroup>
85
- <MenuProvider onAction={runAction}>
86
- <DropdownMenu.Root items={menuActions}>
87
- <Tooltip.Trigger asChild content={t('app menu label')} side='right'>
88
- <DropdownMenu.Trigger asChild data-testid='spacePlugin.addSpace'>
89
- <IconButton {...buttonProps} icon='ph--plus--regular' label={t('main menu label')} />
90
- </DropdownMenu.Trigger>
91
- </Tooltip.Trigger>
92
- </DropdownMenu.Root>
93
- </MenuProvider>
94
- </nav>
95
- </DensityProvider>
27
+ <Menu.Root {...menuActions} alwaysActive onAction={onAction}>
28
+ <Menu.Toolbar {...composableProps(props)} ref={forwardedRef} />
29
+ </Menu.Root>
96
30
  );
97
- };
31
+ });
32
+
33
+ NavBar.displayName = NAVBAR_NAME;
@@ -5,88 +5,71 @@
5
5
  import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
  import * as Effect from 'effect/Effect';
7
7
 
8
- import { Capability, Common, Plugin } from '@dxos/app-framework';
8
+ import { ActivationEvents, Capability, Plugin } from '@dxos/app-framework';
9
9
  import { withPluginManager } from '@dxos/app-framework/testing';
10
- import { ClientOperation, ClientPlugin } from '@dxos/plugin-client';
10
+ import { AppActivationEvents } from '@dxos/app-toolkit/events';
11
+ import { Collection } from '@dxos/echo';
12
+ import { ClientPlugin } from '@dxos/plugin-client';
11
13
  import { SearchPlugin } from '@dxos/plugin-search';
12
14
  import { SpacePlugin } from '@dxos/plugin-space';
13
- import { SpaceOperation } from '@dxos/plugin-space/types';
14
15
  import { corePlugins } from '@dxos/plugin-testing';
15
- import { withTheme } from '@dxos/react-ui/testing';
16
- import { translations as searchTranslation } from '@dxos/react-ui-searchlist';
17
- import { Collection } from '@dxos/schema';
16
+ import { translations as searchTranslation } from '@dxos/react-ui-search/translations';
17
+ import { withLayout } from '@dxos/react-ui/testing';
18
18
 
19
- import { OperationResolver, type SimpleLayoutStateOptions, State } from '../../capabilities';
20
- import { meta as pluginMeta } from '../../meta';
21
- import { type SimpleLayoutPluginOptions } from '../../SimpleLayoutPlugin';
22
- import { translations } from '../../translations';
19
+ import { ReactRoot, ReactSurface, State } from '#capabilities';
20
+ import { meta as pluginMeta } from '#meta';
21
+ import { translations } from '#translations';
22
+ import { SimpleLayoutEvents } from '#types';
23
23
 
24
+ import { type SimpleLayoutPluginOptions } from '../../SimpleLayoutPlugin';
24
25
  import { SimpleLayout } from './SimpleLayout';
25
26
 
26
- const TestPlugin = Plugin.define<SimpleLayoutPluginOptions>(pluginMeta).pipe(
27
- Plugin.addModule(({ isPopover = false }) => ({
28
- id: Capability.getModuleTag(State),
29
- activatesOn: Common.ActivationEvent.Startup,
30
- activatesAfter: [Common.ActivationEvent.LayoutReady],
31
- activate: () => State({ initialState: { isPopover } } satisfies SimpleLayoutStateOptions),
32
- })),
33
- Common.Plugin.addOperationResolverModule({ activate: OperationResolver }),
34
- Plugin.addModule({
35
- id: 'setup',
36
- activatesOn: Common.ActivationEvent.OperationInvokerReady,
37
- activate: Effect.fnUntraced(function* () {
38
- const { invoke } = yield* Capability.get(Common.Capability.OperationInvoker);
39
- yield* invoke(ClientOperation.CreateIdentity, {});
40
- const { space: work } = yield* invoke(SpaceOperation.Create, { name: 'Work Space' });
41
- const { space: sharedProject } = yield* invoke(SpaceOperation.Create, { name: 'Shared Project' });
42
-
43
- // Add collections to Work Space.
44
- yield* invoke(SpaceOperation.AddObject, {
45
- target: work.db,
46
- object: Collection.make({ name: 'Projects', objects: [] }),
47
- });
48
- yield* invoke(SpaceOperation.AddObject, {
49
- target: work.db,
50
- object: Collection.make({ name: 'Documents', objects: [] }),
51
- });
52
-
53
- // Add collections to Shared Project.
54
- yield* invoke(SpaceOperation.AddObject, {
55
- target: sharedProject.db,
56
- object: Collection.make({ name: 'Tasks', objects: [] }),
57
- });
58
- yield* invoke(SpaceOperation.AddObject, {
59
- target: sharedProject.db,
60
- object: Collection.make({ name: 'Notes', objects: [] }),
61
- });
62
- }),
63
- }),
64
- Plugin.make,
65
- );
66
-
67
- const createPluginManager = ({ isPopover }: { isPopover: boolean }) => {
27
+ const createPluginManager = ({ isPopover }: { isPopover?: boolean }) => {
68
28
  return withPluginManager({
29
+ setupEvents: [AppActivationEvents.SetupSettings],
69
30
  plugins: [
70
31
  ...corePlugins(),
71
32
  ClientPlugin({
33
+ types: [Collection.Collection],
72
34
  onClientInitialized: ({ client }) =>
73
35
  Effect.gen(function* () {
74
36
  yield* Effect.promise(() => client.halo.createIdentity());
75
- yield* Effect.promise(async () => {
76
- await client.spaces.create({ name: 'Work Space' });
77
- await client.spaces.create({ name: 'Shared Project' });
78
- });
79
37
  }),
80
38
  }),
81
- SpacePlugin({}),
39
+
82
40
  SearchPlugin(),
83
- TestPlugin({ isPopover }),
41
+ SpacePlugin({}),
42
+
43
+ // TODO(burdon): This should be factored ouf from SimpleLayoutPlugin.
44
+ Plugin.define<SimpleLayoutPluginOptions>(pluginMeta).pipe(
45
+ Plugin.addModule(({ isPopover = false }) => ({
46
+ id: Capability.getModuleTag(State),
47
+ activatesOn: ActivationEvents.Startup,
48
+ firesAfterActivation: [SimpleLayoutEvents.StateReady, AppActivationEvents.LayoutReady],
49
+ activate: () => State({ initialState: { isPopover } }),
50
+ })),
51
+ Plugin.addModule({
52
+ id: Capability.getModuleTag(ReactRoot),
53
+ activatesOn: ActivationEvents.Startup,
54
+ activate: ReactRoot,
55
+ }),
56
+ Plugin.addModule({
57
+ id: Capability.getModuleTag(ReactSurface),
58
+ activatesOn: ActivationEvents.Startup,
59
+ activate: ReactSurface,
60
+ }),
61
+ Plugin.make,
62
+ )({ isPopover }),
84
63
  ],
85
64
  });
86
65
  };
87
66
 
67
+ /**
68
+ * NOTE: To expose to iphone on network:
69
+ * `moon run storybook-react:serve dev -H 0.0.0.0`
70
+ */
88
71
  const meta = {
89
- title: 'plugins/plugin-simple-layout/SimpleLayout',
72
+ title: 'plugins/plugin-simple-layout/components/SimpleLayout',
90
73
  component: SimpleLayout,
91
74
  parameters: {
92
75
  layout: 'fullscreen',
@@ -99,9 +82,9 @@ export default meta;
99
82
  type Story = StoryObj<typeof meta>;
100
83
 
101
84
  export const Default: Story = {
102
- decorators: [withTheme, createPluginManager({ isPopover: false })],
85
+ decorators: [withLayout({ layout: 'column', classNames: 'relative' }), createPluginManager({})],
103
86
  };
104
87
 
105
88
  export const Popover: Story = {
106
- decorators: [withTheme, createPluginManager({ isPopover: true })],
89
+ decorators: [withLayout({ layout: 'column', classNames: 'relative' }), createPluginManager({ isPopover: true })],
107
90
  };
@@ -2,20 +2,57 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import React from 'react';
5
+ import React, { useLayoutEffect, useRef, useState } from 'react';
6
6
 
7
+ import { Splitter, type SplitterMode } from '@dxos/react-ui';
8
+ import { Mosaic } from '@dxos/react-ui-mosaic';
9
+
10
+ import { useSimpleLayoutState } from '#hooks';
11
+
12
+ import { DebugOverlay } from '../DebugOverlay';
7
13
  import { Dialog } from '../Dialog';
14
+ import { MobileLayout } from '../MobileLayout';
8
15
  import { PopoverContent, PopoverRoot } from '../Popover';
9
-
16
+ import { Drawer } from './Drawer';
10
17
  import { Main } from './Main';
11
18
 
12
- // TODO(wittjosiah): Support toast.
13
19
  export const SimpleLayout = () => {
20
+ const { state } = useSimpleLayoutState();
21
+ const [keyboardOpen, setKeyboardOpen] = useState(false);
22
+ const [splitterMode, setSplitterMode] = useState<SplitterMode>('top');
23
+
24
+ const drawerRef = useRef<HTMLDivElement>(null);
25
+
26
+ // Restore Splitter mode when keyboard closes.
27
+ useLayoutEffect(() => {
28
+ if (!keyboardOpen) {
29
+ setSplitterMode(state.drawerState === 'closed' ? 'top' : state.drawerState === 'open' ? 'split' : 'bottom');
30
+ }
31
+ }, [state.drawerState, keyboardOpen]);
32
+
14
33
  return (
15
- <PopoverRoot>
16
- <Main />
17
- <Dialog />
18
- <PopoverContent />
19
- </PopoverRoot>
34
+ <DebugOverlay.Root enabled={false}>
35
+ <PopoverRoot>
36
+ <Mosaic.Root>
37
+ <MobileLayout.Root
38
+ classNames='dx-container grid relative bg-toolbar-surface'
39
+ onKeyboardOpenChange={(nextKeyboardOpen) => setKeyboardOpen(nextKeyboardOpen)}
40
+ >
41
+ <MobileLayout.Panel safe={{ top: true, bottom: splitterMode === 'top' }}>
42
+ <Splitter.Root mode={splitterMode} ratio={0.55}>
43
+ <Splitter.Panel position='top'>
44
+ <Main />
45
+ </Splitter.Panel>
46
+ <Splitter.Panel position='bottom' ref={drawerRef}>
47
+ <Drawer />
48
+ </Splitter.Panel>
49
+ </Splitter.Root>
50
+ <Dialog />
51
+ <PopoverContent />
52
+ </MobileLayout.Panel>
53
+ </MobileLayout.Root>
54
+ </Mosaic.Root>
55
+ </PopoverRoot>
56
+ </DebugOverlay.Root>
20
57
  );
21
58
  };
@@ -2,4 +2,7 @@
2
2
  // Copyright 2026 DXOS.org
3
3
  //
4
4
 
5
+ export * from './AppBar';
6
+ export * from './Main';
7
+ export * from './NavBar';
5
8
  export * from './SimpleLayout';
@@ -0,0 +1,26 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useEffect } from 'react';
6
+
7
+ import { useAppGraph } from '@dxos/app-toolkit/ui';
8
+ import { Graph } from '@dxos/plugin-graph';
9
+ import { expandAttendableId } from '@dxos/react-ui-attention';
10
+
11
+ /**
12
+ * Expand graph nodes along the full path from root to the given node ID.
13
+ * Walks each progressive prefix, ensuring ancestor nodes are materialized
14
+ * before attempting to access their children.
15
+ */
16
+ export const useExpandPath = (nodeId?: string) => {
17
+ const { graph } = useAppGraph();
18
+
19
+ useEffect(() => {
20
+ if (nodeId) {
21
+ for (const prefix of expandAttendableId(nodeId)) {
22
+ Graph.expand(graph, prefix, 'child');
23
+ }
24
+ }
25
+ }, [nodeId, graph]);
26
+ };
@@ -2,7 +2,10 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './ContentLoading';
5
+ export * from './DebugOverlay';
6
6
  export * from './Home';
7
+ export * from './Loading';
8
+ export * from './MobileLayout';
7
9
  export * from './Popover';
8
10
  export * from './SimpleLayout';
11
+ export * from './NavBranch';
@@ -0,0 +1,84 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { type Atom } from '@effect-atom/atom-react';
6
+ import * as Effect from 'effect/Effect';
7
+
8
+ import { type AppCapabilities } from '@dxos/app-toolkit';
9
+ import { Node } from '@dxos/plugin-graph';
10
+ import { getLinkedVariant } from '@dxos/react-ui-attention';
11
+ import { type ActionGraphProps } from '@dxos/react-ui-menu';
12
+ import { byPosition } from '@dxos/util';
13
+
14
+ import { type SimpleLayoutState } from '#types';
15
+
16
+ // TODO(wittjosiah): Factor out to shared location with plugin-deck.
17
+ export const PLANK_COMPANION_TYPE = 'org.dxos.plugin.deck.plank-companion';
18
+
19
+ export type CompanionActionsConfig = {
20
+ /** Prefix for companion action IDs (e.g. 'navbar' or 'drawer') */
21
+ idPrefix: string;
22
+ /** Optional: highlight companion with this variant */
23
+ selectedVariant?: string;
24
+ /** State updater for toggling the drawer. */
25
+ updateState: (fn: (state: SimpleLayoutState) => SimpleLayoutState) => void;
26
+ };
27
+
28
+ /**
29
+ * Creates action graph nodes and edges for companion actions.
30
+ * Shared logic between useNavbarActions and useDrawerActions.
31
+ */
32
+ // TODO(burdon): Use builder pattern.
33
+ export const createCompanionActions = (
34
+ graph: AppCapabilities.AppGraph['graph'],
35
+ stateAtom: Atom.Atom<SimpleLayoutState>,
36
+ get: (atom: Atom.Atom<any>) => any,
37
+ config: CompanionActionsConfig,
38
+ ): Pick<ActionGraphProps, 'nodes' | 'edges'> => {
39
+ const { idPrefix, selectedVariant, updateState } = config;
40
+
41
+ // Derive activeId from state atom.
42
+ const state = get(stateAtom);
43
+ const activeId = state.active ?? state.workspace;
44
+
45
+ // Get companions from graph connections for activeId.
46
+ const activeConnections = activeId ? get(graph.connections(activeId, 'child')) : [];
47
+ const companions = activeConnections
48
+ .filter((node: Node.Node) => node.type === PLANK_COMPANION_TYPE)
49
+ .toSorted((a: Node.Node, b: Node.Node) => byPosition(a.properties, b.properties));
50
+
51
+ const nodes: ActionGraphProps['nodes'] = [];
52
+ const edges: ActionGraphProps['edges'] = [];
53
+
54
+ companions.forEach((companion: Node.Node) => {
55
+ const companionVariant = getLinkedVariant(companion.id);
56
+ const companionAction = {
57
+ id: `${idPrefix}-companion-${companion.id}`,
58
+ type: Node.ActionType,
59
+ properties: {
60
+ icon: companion.properties.icon ?? 'ph--placeholder--regular',
61
+ label: companion.properties.label,
62
+ iconOnly: true,
63
+ ...(selectedVariant !== undefined && {
64
+ variant: selectedVariant === companionVariant ? 'primary' : 'ghost',
65
+ }),
66
+ },
67
+ data: () =>
68
+ Effect.sync(() =>
69
+ updateState((current) => {
70
+ const closing = current.companionVariant === companionVariant && current.drawerState !== 'closed';
71
+ return {
72
+ ...current,
73
+ companionVariant: closing ? undefined : companionVariant,
74
+ drawerState: closing ? 'closed' : 'open',
75
+ };
76
+ }),
77
+ ),
78
+ };
79
+ nodes.push(companionAction);
80
+ edges.push({ source: 'root', target: companionAction.id, relation: 'child' });
81
+ });
82
+
83
+ return { nodes, edges };
84
+ };
@@ -2,4 +2,9 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- export * from './useSpotlightDismiss';
5
+ export * from './useAppBarProps';
6
+ export * from './useCompanions';
7
+ export * from './actions';
8
+ export * from './useDrawerActions';
9
+ export * from './useNavbarActions';
10
+ export * from './useSimpleLayoutState';
@@ -0,0 +1,95 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Atom, useAtomValue } from '@effect-atom/atom-react';
6
+ import * as Option from 'effect/Option';
7
+ import { useCallback, useMemo } from 'react';
8
+
9
+ import { useCapability, useOperationInvoker } from '@dxos/app-framework/ui';
10
+ import { LayoutOperation } from '@dxos/app-toolkit';
11
+ import { useAppGraph } from '@dxos/app-toolkit/ui';
12
+ import { Graph, Node, useActionRunner, useNode } from '@dxos/plugin-graph';
13
+ import { toLocalizedString, useTranslation } from '@dxos/react-ui';
14
+ import { type ActionGraphProps } from '@dxos/react-ui-menu';
15
+
16
+ import { type AppBarProps } from '#components';
17
+ import { meta } from '#meta';
18
+ import { SimpleLayoutState as SimpleLayoutStateCapability } from '#types';
19
+
20
+ /**
21
+ * Hook that computes all AppBar props from the app graph.
22
+ * Derives activeId from state atom. Returns props ready to spread into the AppBar component.
23
+ */
24
+ export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
25
+ const { t } = useTranslation(meta.id);
26
+ const stateAtom = useCapability(SimpleLayoutStateCapability);
27
+ const state = useAtomValue(stateAtom);
28
+ const { graph } = useAppGraph();
29
+ const { invokePromise } = useOperationInvoker();
30
+ const runAction = useActionRunner();
31
+
32
+ // Derive activeId from state.
33
+ const activeId = state.active ?? state.workspace;
34
+ const node = useNode(graph, activeId);
35
+
36
+ // Compute title from node label.
37
+ const title = node ? toLocalizedString(node.properties.label, t) : undefined;
38
+
39
+ // Build actions atom filtering by disposition.
40
+ // Derive activeId from state atom so we don't need to recreate this atom when it changes.
41
+ const actionsAtom = useMemo(
42
+ () =>
43
+ Atom.make((get): ActionGraphProps => {
44
+ const state = get(stateAtom);
45
+ const activeId = state.active ?? state.workspace;
46
+ const allActions = activeId ? get(graph.actions(activeId)) : [];
47
+ const filtered = allActions.filter((action) =>
48
+ ['list-item', 'list-item-primary', 'heading-list-item'].includes(action.properties.disposition),
49
+ );
50
+ const nodes: ActionGraphProps['nodes'] = filtered as ActionGraphProps['nodes'];
51
+ const edges: ActionGraphProps['edges'] = filtered.map((action) => ({
52
+ source: 'root',
53
+ target: action.id,
54
+ relation: 'child',
55
+ }));
56
+
57
+ return { nodes, edges };
58
+ }),
59
+ [graph, stateAtom],
60
+ );
61
+
62
+ // Back button logic.
63
+ const showBackButton = activeId !== undefined && activeId !== Node.RootId;
64
+
65
+ const onBack = useCallback(() => {
66
+ if (state.active) {
67
+ const isWorkspace = Graph.getNode(graph, state.active).pipe(
68
+ Option.map((node) => node.properties.disposition === 'workspace'),
69
+ Option.getOrElse(() => false),
70
+ );
71
+
72
+ // If history is empty and this is a workspace, go to home.
73
+ if (state.history.length === 0 && isWorkspace) {
74
+ void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
75
+ } else {
76
+ // Otherwise, close (which will pop from history or clear active).
77
+ void invokePromise(LayoutOperation.Close, { subject: [state.active] });
78
+ }
79
+ } else {
80
+ void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
81
+ }
82
+ }, [graph, invokePromise, state.active, state.history.length]);
83
+
84
+ // Compute popover anchor ID.
85
+ const popoverAnchorId = node && state.popoverAnchorId === `${meta.id}:${node.id}` ? state.popoverAnchorId : undefined;
86
+
87
+ return {
88
+ title,
89
+ actions: actionsAtom,
90
+ showBackButton,
91
+ popoverAnchorId,
92
+ onBack: onBack,
93
+ onAction: runAction,
94
+ };
95
+ };
@@ -0,0 +1,22 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { useMemo } from 'react';
6
+
7
+ import { useAppGraph } from '@dxos/app-toolkit/ui';
8
+ import { useConnections } from '@dxos/plugin-graph';
9
+ import { byPosition } from '@dxos/util';
10
+
11
+ import { PLANK_COMPANION_TYPE } from './actions';
12
+
13
+ /**
14
+ * @deprecated Adopt the pattern from useNavbarActions (deriving from graph atoms)
15
+ * or merge the Drawer companion display into the NavBar component.
16
+ */
17
+ export const useCompanions = (nodeId?: string) => {
18
+ const { graph } = useAppGraph();
19
+ const nodes = useConnections(graph, nodeId, 'child');
20
+ const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
21
+ return useMemo(() => companions.toSorted((a, b) => byPosition(a.properties, b.properties)), [companions]);
22
+ };