@dxos/plugin-simple-layout 0.8.4-main.6fa680abb7 → 0.8.4-main.7996785055
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.
- package/dist/lib/browser/{chunk-MDPEKLKR.mjs → chunk-J5FQ32AV.mjs} +302 -209
- package/dist/lib/browser/chunk-J5FQ32AV.mjs.map +7 -0
- package/dist/lib/browser/chunk-XJVW3PRY.mjs +22 -0
- package/dist/lib/browser/chunk-XJVW3PRY.mjs.map +7 -0
- package/dist/lib/browser/close-OT5JOGVY.mjs +34 -0
- package/dist/lib/browser/close-OT5JOGVY.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +23 -22
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/open-4FQ44Z5G.mjs +31 -0
- package/dist/lib/browser/open-4FQ44Z5G.mjs.map +7 -0
- package/dist/lib/browser/operation-handler-OAD7LISD.mjs +16 -0
- package/dist/lib/browser/operation-handler-OAD7LISD.mjs.map +7 -0
- package/dist/lib/browser/{react-root-WVQYY2JA.mjs → react-root-6KIGPLUT.mjs} +2 -2
- package/dist/lib/browser/{react-surface-VLBR37ED.mjs → react-surface-JLIEQGOL.mjs} +2 -2
- package/dist/lib/browser/revert-workspace-DLE265AN.mjs +21 -0
- package/dist/lib/browser/revert-workspace-DLE265AN.mjs.map +7 -0
- package/dist/lib/browser/set-52HGTSH4.mjs +21 -0
- package/dist/lib/browser/set-52HGTSH4.mjs.map +7 -0
- package/dist/lib/browser/set-layout-mode-T6QI3DGU.mjs +11 -0
- package/dist/lib/browser/set-layout-mode-T6QI3DGU.mjs.map +7 -0
- package/dist/lib/browser/switch-workspace-5Y6T4BWJ.mjs +24 -0
- package/dist/lib/browser/switch-workspace-5Y6T4BWJ.mjs.map +7 -0
- package/dist/lib/browser/update-complementary-MX3TTVAB.mjs +31 -0
- package/dist/lib/browser/update-complementary-MX3TTVAB.mjs.map +7 -0
- package/dist/lib/browser/update-dialog-FPAPZXKO.mjs +29 -0
- package/dist/lib/browser/update-dialog-FPAPZXKO.mjs.map +7 -0
- package/dist/lib/browser/update-popover-6V5ZTIYN.mjs +33 -0
- package/dist/lib/browser/update-popover-6V5ZTIYN.mjs.map +7 -0
- package/dist/lib/browser/update-sidebar-WHDKYMV7.mjs +10 -0
- package/dist/lib/browser/update-sidebar-WHDKYMV7.mjs.map +7 -0
- package/dist/lib/browser/{url-handler-RBRONH7S.mjs → url-handler-GUJ3L7Y3.mjs} +24 -12
- package/dist/lib/browser/url-handler-GUJ3L7Y3.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-27K22G6S.mjs +23 -0
- package/dist/lib/node-esm/chunk-27K22G6S.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-DCKASLMP.mjs → chunk-EXNDYZTP.mjs} +302 -209
- package/dist/lib/node-esm/chunk-EXNDYZTP.mjs.map +7 -0
- package/dist/lib/node-esm/close-PEVHREL2.mjs +35 -0
- package/dist/lib/node-esm/close-PEVHREL2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +23 -22
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/open-LMJY7JCJ.mjs +32 -0
- package/dist/lib/node-esm/open-LMJY7JCJ.mjs.map +7 -0
- package/dist/lib/node-esm/operation-handler-A2DC4WHC.mjs +18 -0
- package/dist/lib/node-esm/operation-handler-A2DC4WHC.mjs.map +7 -0
- package/dist/lib/node-esm/{react-root-XBNDM7BE.mjs → react-root-5SCW2KTH.mjs} +2 -2
- package/dist/lib/node-esm/{react-surface-U5NHA367.mjs → react-surface-WLKB6AET.mjs} +2 -2
- package/dist/lib/node-esm/revert-workspace-XZXT64YA.mjs +22 -0
- package/dist/lib/node-esm/revert-workspace-XZXT64YA.mjs.map +7 -0
- package/dist/lib/node-esm/set-5I6LFH5L.mjs +22 -0
- package/dist/lib/node-esm/set-5I6LFH5L.mjs.map +7 -0
- package/dist/lib/node-esm/set-layout-mode-F5B6QLZM.mjs +13 -0
- package/dist/lib/node-esm/set-layout-mode-F5B6QLZM.mjs.map +7 -0
- package/dist/lib/node-esm/switch-workspace-PB6T2SGY.mjs +25 -0
- package/dist/lib/node-esm/switch-workspace-PB6T2SGY.mjs.map +7 -0
- package/dist/lib/node-esm/update-complementary-FTW423IY.mjs +32 -0
- package/dist/lib/node-esm/update-complementary-FTW423IY.mjs.map +7 -0
- package/dist/lib/node-esm/update-dialog-ID267DCL.mjs +30 -0
- package/dist/lib/node-esm/update-dialog-ID267DCL.mjs.map +7 -0
- package/dist/lib/node-esm/update-popover-RLHU2HF4.mjs +34 -0
- package/dist/lib/node-esm/update-popover-RLHU2HF4.mjs.map +7 -0
- package/dist/lib/node-esm/update-sidebar-BJ7HTNZ4.mjs +12 -0
- package/dist/lib/node-esm/update-sidebar-BJ7HTNZ4.mjs.map +7 -0
- package/dist/lib/node-esm/{url-handler-QSMCH3JB.mjs → url-handler-WMONO2T6.mjs} +24 -12
- package/dist/lib/node-esm/url-handler-WMONO2T6.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +1 -1
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler/index.d.ts +4 -0
- package/dist/types/src/capabilities/operation-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -1
- package/dist/types/src/components/ContentError.stories.d.ts +6 -1
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
- package/dist/types/src/components/Home/Home.d.ts.map +1 -1
- package/dist/types/src/components/Loading/Loading.d.ts +3 -0
- package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
- package/dist/types/src/components/{ContentLoading/ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
- package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
- package/dist/types/src/components/Loading/index.d.ts +2 -0
- package/dist/types/src/components/Loading/index.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -1
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -1
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts +9 -7
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +9 -4
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +9 -7
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +13 -5
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +10 -11
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/operations/close.d.ts +5 -0
- package/dist/types/src/operations/close.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/revert-workspace.d.ts +5 -0
- package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
- package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
- package/dist/types/src/operations/set.d.ts +5 -0
- package/dist/types/src/operations/set.d.ts.map +1 -0
- package/dist/types/src/operations/state-access.d.ts +8 -0
- package/dist/types/src/operations/state-access.d.ts.map +1 -0
- package/dist/types/src/operations/switch-workspace.d.ts +5 -0
- package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/update-complementary.d.ts +5 -0
- package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
- package/dist/types/src/operations/update-dialog.d.ts +5 -0
- package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
- package/dist/types/src/operations/update-popover.d.ts +5 -0
- package/dist/types/src/operations/update-popover.d.ts.map +1 -0
- package/dist/types/src/operations/update-sidebar.d.ts +5 -0
- package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +6 -1
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +29 -29
- package/src/SimpleLayoutPlugin.ts +3 -3
- package/src/capabilities/index.ts +1 -1
- package/src/capabilities/operation-handler/index.ts +9 -0
- package/src/capabilities/operation-handler/operation-handler.ts +14 -0
- package/src/capabilities/url-handler/url-handler.ts +15 -3
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Home/Home.tsx +27 -28
- package/src/components/{ContentLoading/ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
- package/src/components/{ContentLoading/ContentLoading.tsx → Loading/Loading.tsx} +1 -1
- package/src/components/{ContentLoading → Loading}/index.ts +1 -1
- package/src/components/MobileLayout/MobileLayout.stories.tsx +10 -6
- package/src/components/MobileLayout/MobileLayout.tsx +118 -49
- package/src/components/NavBranch/NavBranch.tsx +27 -30
- package/src/components/Popover/Popover.tsx +2 -12
- package/src/components/SimpleLayout/AppBar.stories.tsx +3 -3
- package/src/components/SimpleLayout/AppBar.tsx +58 -59
- package/src/components/SimpleLayout/Drawer.tsx +6 -6
- package/src/components/SimpleLayout/Main.tsx +15 -19
- package/src/components/SimpleLayout/NavBar.tsx +8 -9
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +41 -64
- package/src/components/SimpleLayout/SimpleLayout.tsx +29 -30
- package/src/components/index.ts +2 -1
- package/src/hooks/useAppBarProps.ts +6 -6
- package/src/hooks/useDrawerActions.ts +1 -1
- package/src/operations/close.ts +34 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/open.ts +32 -0
- package/src/operations/revert-workspace.ts +22 -0
- package/src/operations/set-layout-mode.ts +12 -0
- package/src/operations/set.ts +23 -0
- package/src/operations/state-access.ts +19 -0
- package/src/operations/switch-workspace.ts +26 -0
- package/src/operations/update-complementary.ts +34 -0
- package/src/operations/update-dialog.ts +28 -0
- package/src/operations/update-popover.ts +35 -0
- package/src/operations/update-sidebar.ts +12 -0
- package/src/translations.ts +2 -1
- package/dist/lib/browser/chunk-MDPEKLKR.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs +0 -194
- package/dist/lib/browser/operation-resolver-VTZ6HZ4B.mjs.map +0 -7
- package/dist/lib/browser/url-handler-RBRONH7S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-DCKASLMP.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs +0 -195
- package/dist/lib/node-esm/operation-resolver-R7CQ6ERU.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-QSMCH3JB.mjs.map +0 -7
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading/ContentLoading.d.ts +0 -3
- package/dist/types/src/components/ContentLoading/ContentLoading.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading/ContentLoading.stories.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading/index.d.ts +0 -2
- package/dist/types/src/components/ContentLoading/index.d.ts.map +0 -1
- package/src/capabilities/operation-resolver/index.ts +0 -10
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -202
- /package/dist/lib/browser/{react-root-WVQYY2JA.mjs.map → react-root-6KIGPLUT.mjs.map} +0 -0
- /package/dist/lib/browser/{react-surface-VLBR37ED.mjs.map → react-surface-JLIEQGOL.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-root-XBNDM7BE.mjs.map → react-root-5SCW2KTH.mjs.map} +0 -0
- /package/dist/lib/node-esm/{react-surface-U5NHA367.mjs.map → react-surface-WLKB6AET.mjs.map} +0 -0
|
@@ -7,12 +7,11 @@ import React, { useMemo } from 'react';
|
|
|
7
7
|
import { Surface } from '@dxos/app-framework/ui';
|
|
8
8
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { useNode } from '@dxos/plugin-graph';
|
|
10
|
-
import { ErrorFallback } from '@dxos/react-ui';
|
|
10
|
+
import { ErrorFallback, Panel } from '@dxos/react-ui';
|
|
11
11
|
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
12
|
-
import { mx } from '@dxos/ui-theme';
|
|
13
12
|
|
|
14
13
|
import { useAppBarProps, useNavbarActions, useSimpleLayoutState } from '../../hooks';
|
|
15
|
-
import {
|
|
14
|
+
import { Loading } from '../Loading';
|
|
16
15
|
import { useExpandPath } from '../hooks';
|
|
17
16
|
import { useMobileLayout } from '../MobileLayout';
|
|
18
17
|
|
|
@@ -32,7 +31,7 @@ export const Main = () => {
|
|
|
32
31
|
const { actions, onAction } = useNavbarActions();
|
|
33
32
|
const appBarProps = useAppBarProps();
|
|
34
33
|
|
|
35
|
-
const placeholder = useMemo(() => <
|
|
34
|
+
const placeholder = useMemo(() => <Loading />, []);
|
|
36
35
|
|
|
37
36
|
const { graph } = useAppGraph();
|
|
38
37
|
const node = useNode(graph, id);
|
|
@@ -53,18 +52,11 @@ export const Main = () => {
|
|
|
53
52
|
const showNavBar = !keyboardOpen && !state.isPopover && state.drawerState === 'closed';
|
|
54
53
|
|
|
55
54
|
return (
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
? 'grid-rows-[var(--dx-rail-action)_1fr_var(--dx-toolbar-size)]'
|
|
62
|
-
: 'grid-rows-[var(--dx-rail-action)_1fr]',
|
|
63
|
-
)}
|
|
64
|
-
{...attentionAttrs}
|
|
65
|
-
>
|
|
66
|
-
<AppBar {...appBarProps} />
|
|
67
|
-
<article className='h-full overflow-hidden bg-base-surface'>
|
|
55
|
+
<Panel.Root {...attentionAttrs} className='dx-document'>
|
|
56
|
+
<Panel.Toolbar asChild>
|
|
57
|
+
<AppBar {...appBarProps} />
|
|
58
|
+
</Panel.Toolbar>
|
|
59
|
+
<Panel.Content role='article' className='bg-base-surface'>
|
|
68
60
|
<Surface.Surface
|
|
69
61
|
key={id}
|
|
70
62
|
role='article'
|
|
@@ -73,9 +65,13 @@ export const Main = () => {
|
|
|
73
65
|
fallback={ErrorFallback}
|
|
74
66
|
placeholder={placeholder}
|
|
75
67
|
/>
|
|
76
|
-
</
|
|
77
|
-
{showNavBar &&
|
|
78
|
-
|
|
68
|
+
</Panel.Content>
|
|
69
|
+
{showNavBar && (
|
|
70
|
+
<Panel.Statusbar asChild>
|
|
71
|
+
<NavBar actions={actions} onAction={onAction} />
|
|
72
|
+
</Panel.Statusbar>
|
|
73
|
+
)}
|
|
74
|
+
</Panel.Root>
|
|
79
75
|
);
|
|
80
76
|
};
|
|
81
77
|
|
|
@@ -5,30 +5,29 @@
|
|
|
5
5
|
import { type Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
8
|
import { type ActionExecutor, type ActionGraphProps, Menu, useMenuActions } from '@dxos/react-ui-menu';
|
|
10
|
-
import {
|
|
9
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
11
10
|
|
|
12
11
|
const NAVBAR_NAME = 'SimpleLayout.NavBar';
|
|
13
12
|
|
|
14
|
-
export type NavBarProps =
|
|
13
|
+
export type NavBarProps = {
|
|
15
14
|
/** Action graph atom for the toolbar. */
|
|
16
15
|
actions: Atom.Atom<ActionGraphProps>;
|
|
17
16
|
/** Action executor callback. */
|
|
18
17
|
onAction?: ActionExecutor;
|
|
19
|
-
}
|
|
18
|
+
};
|
|
20
19
|
|
|
21
20
|
/**
|
|
22
21
|
* Presentational navbar component that renders a toolbar from an action graph.
|
|
23
22
|
*/
|
|
24
|
-
export const NavBar = ({
|
|
25
|
-
const
|
|
23
|
+
export const NavBar = composable<HTMLDivElement, NavBarProps>(({ actions, onAction, ...props }, forwardedRef) => {
|
|
24
|
+
const menuActions = useMenuActions(actions);
|
|
26
25
|
|
|
27
26
|
return (
|
|
28
|
-
<Menu.Root {...
|
|
29
|
-
<Menu.Toolbar
|
|
27
|
+
<Menu.Root {...menuActions} alwaysActive onAction={onAction}>
|
|
28
|
+
<Menu.Toolbar {...composableProps(props)} ref={forwardedRef} />
|
|
30
29
|
</Menu.Root>
|
|
31
30
|
);
|
|
32
|
-
};
|
|
31
|
+
});
|
|
33
32
|
|
|
34
33
|
NavBar.displayName = NAVBAR_NAME;
|
|
@@ -5,80 +5,69 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import { ActivationEvents,
|
|
8
|
+
import { ActivationEvents, Capability, Plugin } from '@dxos/app-framework';
|
|
9
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
-
import { AppActivationEvents
|
|
10
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
11
11
|
import { Collection } from '@dxos/echo';
|
|
12
|
-
import {
|
|
12
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
13
13
|
import { SearchPlugin } from '@dxos/plugin-search';
|
|
14
14
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
15
|
-
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
16
15
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
17
|
-
import { withLayout
|
|
18
|
-
import { translations as searchTranslation } from '@dxos/react-ui-
|
|
16
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
17
|
+
import { translations as searchTranslation } from '@dxos/react-ui-search';
|
|
19
18
|
|
|
20
|
-
import {
|
|
19
|
+
import { ReactRoot, ReactSurface, State } from '../../capabilities';
|
|
21
20
|
import { meta as pluginMeta } from '../../meta';
|
|
22
21
|
import { type SimpleLayoutPluginOptions } from '../../SimpleLayoutPlugin';
|
|
23
22
|
import { translations } from '../../translations';
|
|
23
|
+
import { SimpleLayoutEvents } from '../../types';
|
|
24
24
|
|
|
25
25
|
import { SimpleLayout } from './SimpleLayout';
|
|
26
26
|
|
|
27
|
-
const
|
|
28
|
-
AppPlugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
29
|
-
Plugin.addModule(({ isPopover = false }) => ({
|
|
30
|
-
id: Capability.getModuleTag(State),
|
|
31
|
-
activatesOn: ActivationEvents.Startup,
|
|
32
|
-
activatesAfter: [AppActivationEvents.LayoutReady],
|
|
33
|
-
activate: () => State({ initialState: { isPopover } } satisfies SimpleLayoutStateOptions),
|
|
34
|
-
})),
|
|
35
|
-
Plugin.addModule({
|
|
36
|
-
id: 'setup',
|
|
37
|
-
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
38
|
-
activate: Effect.fnUntraced(function* () {
|
|
39
|
-
const { invoke } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
40
|
-
yield* invoke(ClientOperation.CreateIdentity, {});
|
|
41
|
-
const { space: work } = yield* invoke(SpaceOperation.Create, { name: 'Work Space' });
|
|
42
|
-
const { space: sharedProject } = yield* invoke(SpaceOperation.Create, { name: 'Shared Project' });
|
|
43
|
-
|
|
44
|
-
// Add collections to Work Space.
|
|
45
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
46
|
-
target: work.db,
|
|
47
|
-
object: Collection.make({ name: 'Projects', objects: [] }),
|
|
48
|
-
});
|
|
49
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
50
|
-
target: work.db,
|
|
51
|
-
object: Collection.make({ name: 'Documents', objects: [] }),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// Add collections to Shared Project.
|
|
55
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
56
|
-
target: sharedProject.db,
|
|
57
|
-
object: Collection.make({ name: 'Tasks', objects: [] }),
|
|
58
|
-
});
|
|
59
|
-
yield* invoke(SpaceOperation.AddObject, {
|
|
60
|
-
target: sharedProject.db,
|
|
61
|
-
object: Collection.make({ name: 'Notes', objects: [] }),
|
|
62
|
-
});
|
|
63
|
-
}),
|
|
64
|
-
}),
|
|
65
|
-
Plugin.make,
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
const createPluginManager = ({ isPopover }: { isPopover: boolean }) => {
|
|
27
|
+
const createPluginManager = ({ isPopover }: { isPopover?: boolean }) => {
|
|
69
28
|
return withPluginManager({
|
|
29
|
+
setupEvents: [AppActivationEvents.SetupSettings],
|
|
70
30
|
plugins: [
|
|
71
31
|
...corePlugins(),
|
|
72
32
|
ClientPlugin({
|
|
73
33
|
types: [Collection.Collection],
|
|
34
|
+
onClientInitialized: ({ client }) =>
|
|
35
|
+
Effect.gen(function* () {
|
|
36
|
+
yield* Effect.promise(() => client.halo.createIdentity());
|
|
37
|
+
}),
|
|
74
38
|
}),
|
|
39
|
+
|
|
75
40
|
SearchPlugin(),
|
|
76
41
|
SpacePlugin({}),
|
|
77
|
-
|
|
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
|
+
activatesAfter: [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 }),
|
|
78
63
|
],
|
|
79
64
|
});
|
|
80
65
|
};
|
|
81
66
|
|
|
67
|
+
/**
|
|
68
|
+
* NOTE: To expose to iphone on network:
|
|
69
|
+
* `moon run storybook-react:serve dev -H 0.0.0.0`
|
|
70
|
+
*/
|
|
82
71
|
const meta = {
|
|
83
72
|
title: 'plugins/plugin-simple-layout/components/SimpleLayout',
|
|
84
73
|
component: SimpleLayout,
|
|
@@ -92,22 +81,10 @@ export default meta;
|
|
|
92
81
|
|
|
93
82
|
type Story = StoryObj<typeof meta>;
|
|
94
83
|
|
|
95
|
-
/**
|
|
96
|
-
* NOTE: To expose to iphone on network:
|
|
97
|
-
* `moon run storybook-react:serve dev -H 0.0.0.0`
|
|
98
|
-
*/
|
|
99
84
|
export const Default: Story = {
|
|
100
|
-
decorators: [
|
|
101
|
-
withTheme(),
|
|
102
|
-
withLayout({ layout: 'column', classNames: 'relative' }),
|
|
103
|
-
createPluginManager({ isPopover: false }),
|
|
104
|
-
],
|
|
85
|
+
decorators: [withLayout({ layout: 'column', classNames: 'relative' }), createPluginManager({})],
|
|
105
86
|
};
|
|
106
87
|
|
|
107
88
|
export const Popover: Story = {
|
|
108
|
-
decorators: [
|
|
109
|
-
withTheme(),
|
|
110
|
-
withLayout({ layout: 'column', classNames: 'relative' }),
|
|
111
|
-
createPluginManager({ isPopover: true }),
|
|
112
|
-
],
|
|
89
|
+
decorators: [withLayout({ layout: 'column', classNames: 'relative' }), createPluginManager({ isPopover: true })],
|
|
113
90
|
};
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useLayoutEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Splitter, type SplitterMode } from '@dxos/react-ui';
|
|
8
8
|
import { Mosaic } from '@dxos/react-ui-mosaic';
|
|
9
9
|
|
|
10
10
|
import { useSimpleLayoutState } from '../../hooks';
|
|
11
|
+
import { DebugOverlay } from '../DebugOverlay';
|
|
11
12
|
import { Dialog } from '../Dialog';
|
|
12
13
|
import { MobileLayout } from '../MobileLayout';
|
|
13
14
|
import { PopoverContent, PopoverRoot } from '../Popover';
|
|
@@ -15,45 +16,43 @@ import { PopoverContent, PopoverRoot } from '../Popover';
|
|
|
15
16
|
import { Drawer } from './Drawer';
|
|
16
17
|
import { Main } from './Main';
|
|
17
18
|
|
|
18
|
-
// TODO(burdon): Mobile/Desktop variance?
|
|
19
19
|
export const SimpleLayout = () => {
|
|
20
20
|
const { state } = useSimpleLayoutState();
|
|
21
21
|
const [keyboardOpen, setKeyboardOpen] = useState(false);
|
|
22
22
|
const [splitterMode, setSplitterMode] = useState<SplitterMode>('upper');
|
|
23
23
|
|
|
24
24
|
const drawerRef = useRef<HTMLDivElement>(null);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const drawerHasFocus = drawerRef.current?.contains(activeElement);
|
|
30
|
-
setSplitterMode(drawerHasFocus ? 'lower' : 'upper');
|
|
31
|
-
} else {
|
|
25
|
+
|
|
26
|
+
// Restore Splitter mode when keyboard closes.
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
if (!keyboardOpen) {
|
|
32
29
|
setSplitterMode(state.drawerState === 'closed' ? 'upper' : state.drawerState === 'open' ? 'both' : 'lower');
|
|
33
30
|
}
|
|
34
31
|
}, [state.drawerState, keyboardOpen]);
|
|
35
32
|
|
|
36
33
|
return (
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
classNames='
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<
|
|
45
|
-
<Splitter.
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
34
|
+
<DebugOverlay.Root enabled={false}>
|
|
35
|
+
<PopoverRoot>
|
|
36
|
+
<Mosaic.Root classNames='dx-container grid relative'>
|
|
37
|
+
<MobileLayout.Root
|
|
38
|
+
classNames='bg-toolbar-surface'
|
|
39
|
+
onKeyboardOpenChange={(nextKeyboardOpen) => setKeyboardOpen(nextKeyboardOpen)}
|
|
40
|
+
>
|
|
41
|
+
<MobileLayout.Panel safe={{ top: true, bottom: splitterMode === 'upper' }}>
|
|
42
|
+
<Splitter.Root mode={splitterMode} ratio={0.55}>
|
|
43
|
+
<Splitter.Panel position='upper'>
|
|
44
|
+
<Main />
|
|
45
|
+
</Splitter.Panel>
|
|
46
|
+
<Splitter.Panel position='lower' 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>
|
|
58
57
|
);
|
|
59
58
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
|
27
27
|
const stateAtom = useCapability(SimpleLayoutStateCapability);
|
|
28
28
|
const state = useAtomValue(stateAtom);
|
|
29
29
|
const { graph } = useAppGraph();
|
|
30
|
-
const {
|
|
30
|
+
const { invokePromise } = useOperationInvoker();
|
|
31
31
|
const runAction = useActionRunner();
|
|
32
32
|
|
|
33
33
|
// Derive activeId from state.
|
|
@@ -64,7 +64,7 @@ export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
|
64
64
|
const settingsAction = {
|
|
65
65
|
id: `appbar-settings-${alternateTreeNode.id}`,
|
|
66
66
|
type: Node.ActionType,
|
|
67
|
-
data: () => Effect.
|
|
67
|
+
data: () => Effect.promise(() => invokePromise(LayoutOperation.Open, { subject: [alternateTreeNode.id] })),
|
|
68
68
|
properties: {
|
|
69
69
|
label: alternateTreeNode.properties.label ?? alternateTreeNode.id,
|
|
70
70
|
icon: alternateTreeNode.properties.icon ?? 'ph--placeholder--regular',
|
|
@@ -91,15 +91,15 @@ export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
|
91
91
|
|
|
92
92
|
// If history is empty and this is a workspace, go to home.
|
|
93
93
|
if (state.history.length === 0 && isWorkspace) {
|
|
94
|
-
|
|
94
|
+
void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
95
95
|
} else {
|
|
96
96
|
// Otherwise, close (which will pop from history or clear active).
|
|
97
|
-
|
|
97
|
+
void invokePromise(LayoutOperation.Close, { subject: [state.active] });
|
|
98
98
|
}
|
|
99
99
|
} else {
|
|
100
|
-
|
|
100
|
+
void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
101
101
|
}
|
|
102
|
-
}, [graph,
|
|
102
|
+
}, [graph, invokePromise, state.active, state.history.length]);
|
|
103
103
|
|
|
104
104
|
// Compute popover anchor ID.
|
|
105
105
|
const popoverAnchorId = node && state.popoverAnchorId === `${meta.id}:${node.id}` ? state.popoverAnchorId : undefined;
|
|
@@ -47,7 +47,7 @@ export const useDrawerActions = (consumerName: string): DrawerActions => {
|
|
|
47
47
|
// Add companion tab actions.
|
|
48
48
|
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
49
49
|
idPrefix: 'drawer',
|
|
50
|
-
selectedVariant: state.companionVariant,
|
|
50
|
+
selectedVariant: state.drawerState !== 'closed' ? state.companionVariant : undefined,
|
|
51
51
|
updateState,
|
|
52
52
|
});
|
|
53
53
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
import { layoutStateAccess } from './state-access';
|
|
9
|
+
|
|
10
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.Close> = LayoutOperation.Close.pipe(
|
|
11
|
+
Operation.withHandler(
|
|
12
|
+
Effect.fnUntraced(function* () {
|
|
13
|
+
const { updateState } = yield* layoutStateAccess;
|
|
14
|
+
|
|
15
|
+
updateState((state) => {
|
|
16
|
+
if (state.history.length > 0) {
|
|
17
|
+
const newHistory = [...state.history];
|
|
18
|
+
const previousActive = newHistory.pop();
|
|
19
|
+
return {
|
|
20
|
+
...state,
|
|
21
|
+
active: previousActive,
|
|
22
|
+
history: newHistory,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
...state,
|
|
27
|
+
active: undefined,
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export default handler;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import { OperationHandlerSet } from '@dxos/operation';
|
|
4
|
+
|
|
5
|
+
export const SimpleLayoutOperationHandlerSet = OperationHandlerSet.lazy(
|
|
6
|
+
() => import('./close'),
|
|
7
|
+
() => import('./open'),
|
|
8
|
+
() => import('./revert-workspace'),
|
|
9
|
+
() => import('./set'),
|
|
10
|
+
() => import('./set-layout-mode'),
|
|
11
|
+
() => import('./switch-workspace'),
|
|
12
|
+
() => import('./update-complementary'),
|
|
13
|
+
() => import('./update-dialog'),
|
|
14
|
+
() => import('./update-popover'),
|
|
15
|
+
() => import('./update-sidebar'),
|
|
16
|
+
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
import { layoutStateAccess } from './state-access';
|
|
9
|
+
|
|
10
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.Open> = LayoutOperation.Open.pipe(
|
|
11
|
+
Operation.withHandler(
|
|
12
|
+
Effect.fnUntraced(function* (input) {
|
|
13
|
+
const { updateState } = yield* layoutStateAccess;
|
|
14
|
+
const id = input.subject[0];
|
|
15
|
+
|
|
16
|
+
updateState((state) => {
|
|
17
|
+
const newHistory = state.active ? [...state.history, state.active] : state.history;
|
|
18
|
+
const trimmedHistory =
|
|
19
|
+
newHistory.length > MAX_HISTORY_LENGTH ? newHistory.slice(-MAX_HISTORY_LENGTH) : newHistory;
|
|
20
|
+
return {
|
|
21
|
+
...state,
|
|
22
|
+
active: id,
|
|
23
|
+
history: trimmedHistory,
|
|
24
|
+
};
|
|
25
|
+
});
|
|
26
|
+
}),
|
|
27
|
+
),
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
export default handler;
|
|
31
|
+
|
|
32
|
+
const MAX_HISTORY_LENGTH = 50;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
import { layoutStateAccess } from './state-access';
|
|
9
|
+
|
|
10
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.RevertWorkspace> = LayoutOperation.RevertWorkspace.pipe(
|
|
11
|
+
Operation.withHandler(
|
|
12
|
+
Effect.fnUntraced(function* () {
|
|
13
|
+
const { getState } = yield* layoutStateAccess;
|
|
14
|
+
const state = getState();
|
|
15
|
+
yield* Operation.invoke(LayoutOperation.SwitchWorkspace, {
|
|
16
|
+
subject: state.previousWorkspace,
|
|
17
|
+
});
|
|
18
|
+
}),
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export default handler;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.SetLayoutMode> = LayoutOperation.SetLayoutMode.pipe(
|
|
9
|
+
Operation.withHandler(Effect.fnUntraced(function* () {})),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default handler;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
import { layoutStateAccess } from './state-access';
|
|
9
|
+
|
|
10
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.Set> = LayoutOperation.Set.pipe(
|
|
11
|
+
Operation.withHandler(
|
|
12
|
+
Effect.fnUntraced(function* (input) {
|
|
13
|
+
const { updateState } = yield* layoutStateAccess;
|
|
14
|
+
|
|
15
|
+
updateState((state) => ({
|
|
16
|
+
...state,
|
|
17
|
+
active: input.subject[0],
|
|
18
|
+
}));
|
|
19
|
+
}),
|
|
20
|
+
),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export default handler;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
6
|
+
|
|
7
|
+
import { type SimpleLayoutState, SimpleLayoutState as SimpleLayoutStateCapability } from '../types';
|
|
8
|
+
|
|
9
|
+
export const layoutStateAccess = Effect.gen(function* () {
|
|
10
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
11
|
+
const stateAtom = yield* Capability.get(SimpleLayoutStateCapability);
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
getState: () => registry.get(stateAtom),
|
|
15
|
+
updateState: (fn: (current: SimpleLayoutState) => SimpleLayoutState) => {
|
|
16
|
+
registry.set(stateAtom, fn(registry.get(stateAtom)));
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { isPinnedWorkspace, LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
import { layoutStateAccess } from './state-access';
|
|
9
|
+
|
|
10
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.SwitchWorkspace> = LayoutOperation.SwitchWorkspace.pipe(
|
|
11
|
+
Operation.withHandler(
|
|
12
|
+
Effect.fnUntraced(function* (input) {
|
|
13
|
+
const { updateState } = yield* layoutStateAccess;
|
|
14
|
+
|
|
15
|
+
updateState((state) => ({
|
|
16
|
+
...state,
|
|
17
|
+
previousWorkspace: !isPinnedWorkspace(state.workspace) ? state.workspace : state.previousWorkspace,
|
|
18
|
+
workspace: input.subject,
|
|
19
|
+
active: undefined,
|
|
20
|
+
history: [],
|
|
21
|
+
}));
|
|
22
|
+
}),
|
|
23
|
+
),
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
export default handler;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { getCompanionVariant, LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
import { layoutStateAccess } from './state-access';
|
|
9
|
+
|
|
10
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.UpdateComplementary> =
|
|
11
|
+
LayoutOperation.UpdateComplementary.pipe(
|
|
12
|
+
Operation.withHandler(
|
|
13
|
+
Effect.fnUntraced(function* (input) {
|
|
14
|
+
const { updateState } = yield* layoutStateAccess;
|
|
15
|
+
|
|
16
|
+
if (input.state === 'closed') {
|
|
17
|
+
updateState((state) => ({
|
|
18
|
+
...state,
|
|
19
|
+
drawerState: 'closed',
|
|
20
|
+
companionVariant: undefined,
|
|
21
|
+
}));
|
|
22
|
+
} else if (input.subject) {
|
|
23
|
+
const variant = getCompanionVariant(input.subject);
|
|
24
|
+
updateState((state) => ({
|
|
25
|
+
...state,
|
|
26
|
+
companionVariant: variant,
|
|
27
|
+
drawerState: input.state === 'expanded' ? 'expanded' : 'open',
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}),
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
export default handler;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { Operation } from '@dxos/operation';
|
|
7
|
+
|
|
8
|
+
import { layoutStateAccess } from './state-access';
|
|
9
|
+
|
|
10
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.UpdateDialog> = LayoutOperation.UpdateDialog.pipe(
|
|
11
|
+
Operation.withHandler(
|
|
12
|
+
Effect.fnUntraced(function* (input) {
|
|
13
|
+
const { updateState } = yield* layoutStateAccess;
|
|
14
|
+
|
|
15
|
+
updateState((state) => ({
|
|
16
|
+
...state,
|
|
17
|
+
dialogOpen: input.state ?? Boolean(input.subject),
|
|
18
|
+
dialogType: input.type ?? 'default',
|
|
19
|
+
dialogBlockAlign: input.blockAlign ?? 'center',
|
|
20
|
+
dialogOverlayClasses: input.overlayClasses,
|
|
21
|
+
dialogOverlayStyle: input.overlayStyle,
|
|
22
|
+
dialogContent: input.subject ? { component: input.subject, props: input.props } : undefined,
|
|
23
|
+
}));
|
|
24
|
+
}),
|
|
25
|
+
),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default handler;
|