@dxos/plugin-simple-layout 0.8.4-main.3eb6e50203 → 0.8.4-main.422d1c7879
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/index.mjs +35 -56
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +35 -55
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +21 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +1 -1
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
- package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +2 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler.d.ts +12 -0
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +26 -21
- 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/Dialog/Dialog.d.ts.map +1 -1
- 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.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 +11 -0
- package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -0
- package/dist/types/src/components/NavBranch/index.d.ts +2 -0
- package/dist/types/src/components/NavBranch/index.d.ts.map +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts +5 -7
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +28 -21
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Drawer.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 +5 -7
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +28 -22
- 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 +26 -25
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/hooks.d.ts +4 -2
- package/dist/types/src/components/hooks.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +4 -5
- package/dist/types/src/hooks/actions.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +1 -1
- package/dist/types/src/hooks/useSimpleLayoutState.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 +26 -19
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +10 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -30
- package/src/SimpleLayoutPlugin.ts +16 -6
- package/src/capabilities/app-graph-builder.ts +21 -0
- package/src/capabilities/index.ts +13 -6
- package/src/capabilities/operation-handler.ts +14 -0
- package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +2 -2
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +16 -7
- package/src/capabilities/{state/state.tsx → state.tsx} +2 -2
- package/src/capabilities/url-handler.ts +161 -0
- package/src/components/ContentError.stories.tsx +7 -6
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +15 -4
- package/src/components/Home/Home.tsx +38 -32
- package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
- package/src/components/{ContentLoading.tsx → Loading/Loading.tsx} +2 -2
- package/src/components/Loading/index.ts +5 -0
- package/src/components/MobileLayout/MobileLayout.stories.tsx +38 -30
- package/src/components/MobileLayout/MobileLayout.tsx +118 -49
- package/src/components/NavBranch/NavBranch.tsx +128 -0
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +12 -8
- package/src/components/SimpleLayout/AppBar.stories.tsx +10 -11
- package/src/components/SimpleLayout/AppBar.tsx +56 -63
- package/src/components/SimpleLayout/Drawer.tsx +38 -36
- package/src/components/SimpleLayout/Main.tsx +22 -25
- package/src/components/SimpleLayout/NavBar.stories.tsx +8 -9
- package/src/components/SimpleLayout/NavBar.tsx +10 -17
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +45 -68
- package/src/components/SimpleLayout/SimpleLayout.tsx +33 -34
- package/src/components/hooks.ts +8 -8
- package/src/components/index.ts +3 -2
- package/src/hooks/actions.ts +17 -18
- package/src/hooks/useAppBarProps.ts +17 -14
- package/src/hooks/useCompanions.ts +1 -1
- package/src/hooks/useDrawerActions.ts +15 -13
- package/src/hooks/useNavbarActions.ts +13 -12
- package/src/hooks/useSimpleLayoutState.ts +1 -1
- package/src/meta.ts +1 -1
- package/src/operations/close.ts +34 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/open.ts +63 -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 +35 -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 +21 -19
- package/src/types/capabilities.ts +4 -4
- package/dist/lib/browser/chunk-7VLT3S46.mjs +0 -29
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +0 -7
- package/dist/lib/browser/chunk-O3BQBYMW.mjs +0 -1165
- package/dist/lib/browser/chunk-O3BQBYMW.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs +0 -205
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +0 -7
- package/dist/lib/browser/react-root-GPTKI5H2.mjs +0 -21
- package/dist/lib/browser/react-root-GPTKI5H2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LT5JJTPR.mjs +0 -41
- package/dist/lib/browser/react-surface-LT5JJTPR.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs +0 -66
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +0 -7
- package/dist/lib/browser/state-A3PGDWWZ.mjs +0 -48
- package/dist/lib/browser/state-A3PGDWWZ.mjs.map +0 -7
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs +0 -152
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UAWM4B2S.mjs +0 -1166
- package/dist/lib/node-esm/chunk-UAWM4B2S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs +0 -31
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs +0 -206
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-GRG2OAI2.mjs +0 -22
- package/dist/lib/node-esm/react-root-GRG2OAI2.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TCUSDIN2.mjs +0 -42
- package/dist/lib/node-esm/react-surface-TCUSDIN2.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs +0 -68
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +0 -7
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs +0 -49
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs +0 -153
- package/dist/lib/node-esm/url-handler-WBVVKVPC.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/capabilities/react-root/index.d.ts +0 -6
- package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +0 -3
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/index.d.ts +0 -13
- package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-handler/index.d.ts +0 -3
- package/dist/types/src/capabilities/url-handler/index.d.ts.map +0 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts +0 -12
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +0 -1
- package/dist/types/src/components/ContentError.d.ts +0 -5
- package/dist/types/src/components/ContentError.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading.d.ts +0 -3
- package/dist/types/src/components/ContentLoading.d.ts.map +0 -1
- package/dist/types/src/components/ContentLoading.stories.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts +0 -11
- package/dist/types/src/components/Workspace/Workspace.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/index.d.ts +0 -2
- package/dist/types/src/components/Workspace/index.d.ts.map +0 -1
- package/src/capabilities/operation-resolver/index.ts +0 -10
- package/src/capabilities/operation-resolver/operation-resolver.ts +0 -217
- package/src/capabilities/react-root/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/spotlight-dismiss/index.ts +0 -7
- package/src/capabilities/state/index.ts +0 -9
- package/src/capabilities/url-handler/index.ts +0 -7
- package/src/capabilities/url-handler/url-handler.ts +0 -157
- package/src/components/ContentError.tsx +0 -23
- package/src/components/Workspace/Workspace.tsx +0 -119
- /package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +0 -0
|
@@ -5,82 +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 { ActivationEvents,
|
|
8
|
+
import { ActivationEvents, Capability, Plugin } from '@dxos/app-framework';
|
|
9
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
-
import { AppActivationEvents
|
|
11
|
-
import {
|
|
10
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
11
|
+
import { Collection } from '@dxos/echo';
|
|
12
|
+
import { ClientPlugin } from '@dxos/plugin-client';
|
|
12
13
|
import { SearchPlugin } from '@dxos/plugin-search';
|
|
13
14
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
14
|
-
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
15
15
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
16
|
+
import { translations as searchTranslation } from '@dxos/react-ui-search';
|
|
17
|
+
import { withLayout } from '@dxos/react-ui/testing';
|
|
18
|
+
|
|
19
|
+
import { ReactRoot, ReactSurface, State } from '#capabilities';
|
|
20
|
+
import { meta as pluginMeta } from '#meta';
|
|
21
|
+
import { SimpleLayoutEvents } from '#types';
|
|
19
22
|
|
|
20
|
-
import { OperationResolver, type SimpleLayoutStateOptions, State } from '../../capabilities';
|
|
21
|
-
import { meta as pluginMeta } from '../../meta';
|
|
22
23
|
import { type SimpleLayoutPluginOptions } from '../../SimpleLayoutPlugin';
|
|
23
24
|
import { translations } from '../../translations';
|
|
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
|
+
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 }),
|
|
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
|
-
title: 'plugins/plugin-simple-layout/SimpleLayout',
|
|
72
|
+
title: 'plugins/plugin-simple-layout/components/SimpleLayout',
|
|
84
73
|
component: SimpleLayout,
|
|
85
74
|
parameters: {
|
|
86
75
|
layout: 'fullscreen',
|
|
@@ -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,58 +2,57 @@
|
|
|
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
|
-
import { useSimpleLayoutState } from '
|
|
10
|
+
import { useSimpleLayoutState } from '#hooks';
|
|
11
|
+
|
|
12
|
+
import { DebugOverlay } from '../DebugOverlay';
|
|
11
13
|
import { Dialog } from '../Dialog';
|
|
12
14
|
import { MobileLayout } from '../MobileLayout';
|
|
13
15
|
import { PopoverContent, PopoverRoot } from '../Popover';
|
|
14
|
-
|
|
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
|
-
const [splitterMode, setSplitterMode] = useState<SplitterMode>('
|
|
22
|
+
const [splitterMode, setSplitterMode] = useState<SplitterMode>('top');
|
|
23
23
|
|
|
24
24
|
const drawerRef = useRef<HTMLDivElement>(null);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
setSplitterMode(drawerHasFocus ? 'lower' : 'upper');
|
|
31
|
-
} else {
|
|
32
|
-
setSplitterMode(state.drawerState === 'closed' ? 'upper' : state.drawerState === 'open' ? 'both' : 'lower');
|
|
25
|
+
|
|
26
|
+
// Restore Splitter mode when keyboard closes.
|
|
27
|
+
useLayoutEffect(() => {
|
|
28
|
+
if (!keyboardOpen) {
|
|
29
|
+
setSplitterMode(state.drawerState === 'closed' ? 'top' : state.drawerState === 'open' ? 'split' : 'bottom');
|
|
33
30
|
}
|
|
34
31
|
}, [state.drawerState, keyboardOpen]);
|
|
35
32
|
|
|
36
33
|
return (
|
|
37
|
-
<
|
|
38
|
-
<
|
|
39
|
-
|
|
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>
|
|
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>
|
|
58
57
|
);
|
|
59
58
|
};
|
package/src/components/hooks.ts
CHANGED
|
@@ -6,21 +6,21 @@ import { useEffect } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Graph } from '@dxos/plugin-graph';
|
|
9
|
+
import { expandAttendableId } from '@dxos/react-ui-attention';
|
|
9
10
|
|
|
10
11
|
/**
|
|
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.
|
|
12
15
|
*/
|
|
13
|
-
export const
|
|
16
|
+
export const useExpandPath = (nodeId?: string) => {
|
|
14
17
|
const { graph } = useAppGraph();
|
|
15
18
|
|
|
16
19
|
useEffect(() => {
|
|
17
20
|
if (nodeId) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
Graph.getConnections(graph, nodeId, 'outbound').forEach((child) => {
|
|
22
|
-
Graph.expand(graph, child.id, 'outbound');
|
|
23
|
-
});
|
|
21
|
+
for (const prefix of expandAttendableId(nodeId)) {
|
|
22
|
+
Graph.expand(graph, prefix, 'child');
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
}, [nodeId, graph]);
|
|
26
26
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
export * from './
|
|
5
|
+
export * from './DebugOverlay';
|
|
6
6
|
export * from './Home';
|
|
7
|
+
export * from './Loading';
|
|
7
8
|
export * from './MobileLayout';
|
|
8
9
|
export * from './Popover';
|
|
9
10
|
export * from './SimpleLayout';
|
|
10
|
-
export * from './
|
|
11
|
+
export * from './NavBranch';
|
package/src/hooks/actions.ts
CHANGED
|
@@ -5,25 +5,24 @@
|
|
|
5
5
|
import { type Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
9
|
-
import { type AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
8
|
+
import { type AppCapabilities } from '@dxos/app-toolkit';
|
|
10
9
|
import { Node } from '@dxos/plugin-graph';
|
|
11
|
-
import {
|
|
10
|
+
import { getLinkedVariant } from '@dxos/react-ui-attention';
|
|
12
11
|
import { type ActionGraphProps } from '@dxos/react-ui-menu';
|
|
13
12
|
import { byPosition } from '@dxos/util';
|
|
14
13
|
|
|
15
|
-
import { type SimpleLayoutState } from '
|
|
14
|
+
import { type SimpleLayoutState } from '#types';
|
|
16
15
|
|
|
17
16
|
// TODO(wittjosiah): Factor out to shared location with plugin-deck.
|
|
18
|
-
export const PLANK_COMPANION_TYPE = 'dxos.
|
|
17
|
+
export const PLANK_COMPANION_TYPE = 'org.dxos.plugin.deck.plank-companion';
|
|
19
18
|
|
|
20
19
|
export type CompanionActionsConfig = {
|
|
21
20
|
/** Prefix for companion action IDs (e.g. 'navbar' or 'drawer') */
|
|
22
21
|
idPrefix: string;
|
|
23
22
|
/** Optional: highlight companion with this variant */
|
|
24
23
|
selectedVariant?: string;
|
|
25
|
-
/**
|
|
26
|
-
|
|
24
|
+
/** State updater for toggling the drawer. */
|
|
25
|
+
updateState: (fn: (state: SimpleLayoutState) => SimpleLayoutState) => void;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
28
|
/**
|
|
@@ -37,14 +36,14 @@ export const createCompanionActions = (
|
|
|
37
36
|
get: (atom: Atom.Atom<any>) => any,
|
|
38
37
|
config: CompanionActionsConfig,
|
|
39
38
|
): Pick<ActionGraphProps, 'nodes' | 'edges'> => {
|
|
40
|
-
const { idPrefix, selectedVariant,
|
|
39
|
+
const { idPrefix, selectedVariant, updateState } = config;
|
|
41
40
|
|
|
42
41
|
// Derive activeId from state atom.
|
|
43
42
|
const state = get(stateAtom);
|
|
44
43
|
const activeId = state.active ?? state.workspace;
|
|
45
44
|
|
|
46
45
|
// Get companions from graph connections for activeId.
|
|
47
|
-
const activeConnections = activeId ? get(graph.connections(activeId)) : [];
|
|
46
|
+
const activeConnections = activeId ? get(graph.connections(activeId, 'child')) : [];
|
|
48
47
|
const companions = activeConnections
|
|
49
48
|
.filter((node: Node.Node) => node.type === PLANK_COMPANION_TYPE)
|
|
50
49
|
.toSorted((a: Node.Node, b: Node.Node) => byPosition(a.properties, b.properties));
|
|
@@ -52,12 +51,8 @@ export const createCompanionActions = (
|
|
|
52
51
|
const nodes: ActionGraphProps['nodes'] = [];
|
|
53
52
|
const edges: ActionGraphProps['edges'] = [];
|
|
54
53
|
|
|
55
|
-
// Add companion actions.
|
|
56
|
-
// TODO(burdon): Cap at 6 items.
|
|
57
54
|
companions.forEach((companion: Node.Node) => {
|
|
58
|
-
|
|
59
|
-
const [, companionVariant] = companion.id.split(ATTENDABLE_PATH_SEPARATOR);
|
|
60
|
-
|
|
55
|
+
const companionVariant = getLinkedVariant(companion.id);
|
|
61
56
|
const companionAction = {
|
|
62
57
|
id: `${idPrefix}-companion-${companion.id}`,
|
|
63
58
|
type: Node.ActionType,
|
|
@@ -65,20 +60,24 @@ export const createCompanionActions = (
|
|
|
65
60
|
icon: companion.properties.icon ?? 'ph--placeholder--regular',
|
|
66
61
|
label: companion.properties.label,
|
|
67
62
|
iconOnly: true,
|
|
68
|
-
// Conditionally add variant highlighting.
|
|
69
63
|
...(selectedVariant !== undefined && {
|
|
70
64
|
variant: selectedVariant === companionVariant ? 'primary' : 'ghost',
|
|
71
65
|
}),
|
|
72
66
|
},
|
|
73
67
|
data: () =>
|
|
74
68
|
Effect.sync(() =>
|
|
75
|
-
|
|
76
|
-
|
|
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
|
+
};
|
|
77
76
|
}),
|
|
78
77
|
),
|
|
79
78
|
};
|
|
80
79
|
nodes.push(companionAction);
|
|
81
|
-
edges.push({ source: 'root', target: companionAction.id });
|
|
80
|
+
edges.push({ source: 'root', target: companionAction.id, relation: 'child' });
|
|
82
81
|
});
|
|
83
82
|
|
|
84
83
|
return { nodes, edges };
|
|
@@ -14,9 +14,9 @@ import { Graph, Node, useActionRunner, useNode } from '@dxos/plugin-graph';
|
|
|
14
14
|
import { toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
15
15
|
import { type ActionGraphProps } from '@dxos/react-ui-menu';
|
|
16
16
|
|
|
17
|
-
import { type AppBarProps } from '
|
|
18
|
-
import { meta } from '
|
|
19
|
-
import { SimpleLayoutState as SimpleLayoutStateCapability } from '
|
|
17
|
+
import { type AppBarProps } from '#components';
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
import { SimpleLayoutState as SimpleLayoutStateCapability } from '#types';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Hook that computes all AppBar props from the app graph.
|
|
@@ -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.
|
|
@@ -49,10 +49,14 @@ export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
|
49
49
|
['list-item', 'list-item-primary', 'heading-list-item'].includes(action.properties.disposition),
|
|
50
50
|
);
|
|
51
51
|
const nodes: ActionGraphProps['nodes'] = filtered as ActionGraphProps['nodes'];
|
|
52
|
-
const edges: ActionGraphProps['edges'] = filtered.map((action) => ({
|
|
52
|
+
const edges: ActionGraphProps['edges'] = filtered.map((action) => ({
|
|
53
|
+
source: 'root',
|
|
54
|
+
target: action.id,
|
|
55
|
+
relation: 'child',
|
|
56
|
+
}));
|
|
53
57
|
|
|
54
58
|
// Add alternate-tree action (e.g. Settings) from the workspace node.
|
|
55
|
-
const workspaceConnections = state.workspace ? get(graph.connections(state.workspace)) : [];
|
|
59
|
+
const workspaceConnections = state.workspace ? get(graph.connections(state.workspace, 'child')) : [];
|
|
56
60
|
const alternateTreeNode = workspaceConnections.find(
|
|
57
61
|
(node: Node.Node) => node.properties.disposition === 'alternate-tree',
|
|
58
62
|
);
|
|
@@ -60,14 +64,14 @@ export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
|
60
64
|
const settingsAction = {
|
|
61
65
|
id: `appbar-settings-${alternateTreeNode.id}`,
|
|
62
66
|
type: Node.ActionType,
|
|
63
|
-
data: () => Effect.
|
|
67
|
+
data: () => Effect.promise(() => invokePromise(LayoutOperation.Open, { subject: [alternateTreeNode.id] })),
|
|
64
68
|
properties: {
|
|
65
69
|
label: alternateTreeNode.properties.label ?? alternateTreeNode.id,
|
|
66
70
|
icon: alternateTreeNode.properties.icon ?? 'ph--placeholder--regular',
|
|
67
71
|
},
|
|
68
72
|
};
|
|
69
73
|
nodes.push(settingsAction);
|
|
70
|
-
edges.push({ source: 'root', target: settingsAction.id });
|
|
74
|
+
edges.push({ source: 'root', target: settingsAction.id, relation: 'child' });
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
return { nodes, edges };
|
|
@@ -87,19 +91,18 @@ export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
|
87
91
|
|
|
88
92
|
// If history is empty and this is a workspace, go to home.
|
|
89
93
|
if (state.history.length === 0 && isWorkspace) {
|
|
90
|
-
|
|
94
|
+
void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
91
95
|
} else {
|
|
92
96
|
// Otherwise, close (which will pop from history or clear active).
|
|
93
|
-
|
|
97
|
+
void invokePromise(LayoutOperation.Close, { subject: [state.active] });
|
|
94
98
|
}
|
|
95
99
|
} else {
|
|
96
|
-
|
|
100
|
+
void invokePromise(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
97
101
|
}
|
|
98
|
-
}, [graph,
|
|
102
|
+
}, [graph, invokePromise, state.active, state.history.length]);
|
|
99
103
|
|
|
100
104
|
// Compute popover anchor ID.
|
|
101
|
-
const popoverAnchorId =
|
|
102
|
-
node && state.popoverAnchorId === `dxos.org/ui/${meta.id}/${node.id}` ? state.popoverAnchorId : undefined;
|
|
105
|
+
const popoverAnchorId = node && state.popoverAnchorId === `${meta.id}:${node.id}` ? state.popoverAnchorId : undefined;
|
|
103
106
|
|
|
104
107
|
return {
|
|
105
108
|
title,
|
|
@@ -16,7 +16,7 @@ import { PLANK_COMPANION_TYPE } from './actions';
|
|
|
16
16
|
*/
|
|
17
17
|
export const useCompanions = (nodeId?: string) => {
|
|
18
18
|
const { graph } = useAppGraph();
|
|
19
|
-
const nodes = useConnections(graph, nodeId);
|
|
19
|
+
const nodes = useConnections(graph, nodeId, 'child');
|
|
20
20
|
const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
|
|
21
21
|
return useMemo(() => companions.toSorted((a, b) => byPosition(a.properties, b.properties)), [companions]);
|
|
22
22
|
};
|
|
@@ -6,15 +6,15 @@ import { Atom } from '@effect-atom/atom-react';
|
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
import { useCapability
|
|
9
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
10
10
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
11
11
|
import { Node, useActionRunner } from '@dxos/plugin-graph';
|
|
12
12
|
import { useTranslation } from '@dxos/react-ui';
|
|
13
13
|
import { type ActionExecutor, type ActionGraphProps, createGapSeparator } from '@dxos/react-ui-menu';
|
|
14
14
|
|
|
15
|
-
import { useMobileLayout } from '
|
|
16
|
-
import { meta } from '
|
|
17
|
-
import { SimpleLayoutState as SimpleLayoutStateCapability } from '
|
|
15
|
+
import { useMobileLayout } from '#components';
|
|
16
|
+
import { meta } from '#meta';
|
|
17
|
+
import { SimpleLayoutState as SimpleLayoutStateCapability } from '#types';
|
|
18
18
|
|
|
19
19
|
import { createCompanionActions } from './actions';
|
|
20
20
|
import { useSimpleLayoutState } from './useSimpleLayoutState';
|
|
@@ -34,7 +34,6 @@ export const useDrawerActions = (consumerName: string): DrawerActions => {
|
|
|
34
34
|
const stateAtom = useCapability(SimpleLayoutStateCapability);
|
|
35
35
|
const { graph } = useAppGraph();
|
|
36
36
|
const runAction = useActionRunner();
|
|
37
|
-
const { invokeSync } = useOperationInvoker();
|
|
38
37
|
const { updateState } = useSimpleLayoutState();
|
|
39
38
|
const { keyboardOpen } = useMobileLayout(consumerName);
|
|
40
39
|
|
|
@@ -48,8 +47,8 @@ export const useDrawerActions = (consumerName: string): DrawerActions => {
|
|
|
48
47
|
// Add companion tab actions.
|
|
49
48
|
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
50
49
|
idPrefix: 'drawer',
|
|
51
|
-
selectedVariant: state.companionVariant,
|
|
52
|
-
|
|
50
|
+
selectedVariant: state.drawerState !== 'closed' ? state.companionVariant : undefined,
|
|
51
|
+
updateState,
|
|
53
52
|
});
|
|
54
53
|
|
|
55
54
|
// Add gap separator before toolbar buttons.
|
|
@@ -65,14 +64,14 @@ export const useDrawerActions = (consumerName: string): DrawerActions => {
|
|
|
65
64
|
type: Node.ActionType,
|
|
66
65
|
properties: {
|
|
67
66
|
icon: isExpanded ? 'ph--arrow-down--regular' : 'ph--arrow-up--regular',
|
|
68
|
-
label: isExpanded ? t('collapse
|
|
67
|
+
label: isExpanded ? t('collapse-drawer.label') : t('expand-drawer.label'),
|
|
69
68
|
iconOnly: true,
|
|
70
69
|
},
|
|
71
70
|
data: () =>
|
|
72
71
|
Effect.sync(() => updateState((state) => ({ ...state, drawerState: isExpanded ? 'open' : 'expanded' }))),
|
|
73
72
|
};
|
|
74
73
|
nodes.push(toggleExpandAction);
|
|
75
|
-
edges.push({ source: 'root', target: toggleExpandAction.id });
|
|
74
|
+
edges.push({ source: 'root', target: toggleExpandAction.id, relation: 'child' });
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
// Add close button.
|
|
@@ -81,17 +80,20 @@ export const useDrawerActions = (consumerName: string): DrawerActions => {
|
|
|
81
80
|
type: Node.ActionType,
|
|
82
81
|
properties: {
|
|
83
82
|
icon: 'ph--x--regular',
|
|
84
|
-
label: t('close
|
|
83
|
+
label: t('close-drawer.label'),
|
|
85
84
|
iconOnly: true,
|
|
86
85
|
},
|
|
87
|
-
data: () =>
|
|
86
|
+
data: () =>
|
|
87
|
+
Effect.sync(() =>
|
|
88
|
+
updateState((state) => ({ ...state, drawerState: 'closed', companionVariant: undefined })),
|
|
89
|
+
),
|
|
88
90
|
};
|
|
89
91
|
nodes.push(closeAction);
|
|
90
|
-
edges.push({ source: 'root', target: closeAction.id });
|
|
92
|
+
edges.push({ source: 'root', target: closeAction.id, relation: 'child' });
|
|
91
93
|
|
|
92
94
|
return { nodes, edges };
|
|
93
95
|
}),
|
|
94
|
-
[graph, stateAtom,
|
|
96
|
+
[graph, stateAtom, updateState, keyboardOpen, t],
|
|
95
97
|
);
|
|
96
98
|
|
|
97
99
|
return { actions: actionsAtom, onAction: runAction };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useCapability
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
9
|
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
10
10
|
import { Node, useActionRunner } from '@dxos/plugin-graph';
|
|
11
11
|
import { useTranslation } from '@dxos/react-ui';
|
|
@@ -16,10 +16,11 @@ import {
|
|
|
16
16
|
createMenuItemGroup,
|
|
17
17
|
} from '@dxos/react-ui-menu';
|
|
18
18
|
|
|
19
|
-
import { meta } from '
|
|
20
|
-
import { SimpleLayoutState } from '
|
|
19
|
+
import { meta } from '#meta';
|
|
20
|
+
import { SimpleLayoutState } from '#types';
|
|
21
21
|
|
|
22
22
|
import { createCompanionActions } from './actions';
|
|
23
|
+
import { useSimpleLayoutState } from './useSimpleLayoutState';
|
|
23
24
|
|
|
24
25
|
const MAIN_MENU_GROUP_ID = 'navbar-main-menu';
|
|
25
26
|
|
|
@@ -38,8 +39,8 @@ export const useNavbarActions = (): NavbarActions => {
|
|
|
38
39
|
const { t } = useTranslation(meta.id);
|
|
39
40
|
const { graph } = useAppGraph();
|
|
40
41
|
const runAction = useActionRunner();
|
|
41
|
-
const { invokeSync } = useOperationInvoker();
|
|
42
42
|
const stateAtom = useCapability(SimpleLayoutState);
|
|
43
|
+
const { updateState } = useSimpleLayoutState();
|
|
43
44
|
|
|
44
45
|
// Create a computed atom that derives everything from graph connections and state.
|
|
45
46
|
const actionsAtom = useMemo(
|
|
@@ -48,7 +49,7 @@ export const useNavbarActions = (): NavbarActions => {
|
|
|
48
49
|
// Add companion actions.
|
|
49
50
|
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
50
51
|
idPrefix: 'navbar',
|
|
51
|
-
|
|
52
|
+
updateState,
|
|
52
53
|
});
|
|
53
54
|
|
|
54
55
|
// Add gap separator.
|
|
@@ -61,25 +62,25 @@ export const useNavbarActions = (): NavbarActions => {
|
|
|
61
62
|
variant: 'dropdownMenu',
|
|
62
63
|
icon: 'ph--list--regular',
|
|
63
64
|
iconOnly: true,
|
|
64
|
-
label: t('main
|
|
65
|
+
label: t('main-menu.label'),
|
|
65
66
|
testId: 'simpleLayoutPlugin.addSpace',
|
|
66
67
|
});
|
|
67
68
|
nodes.push(mainMenuGroup);
|
|
68
|
-
edges.push({ source: 'root', target: mainMenuGroup.id });
|
|
69
|
+
edges.push({ source: 'root', target: mainMenuGroup.id, relation: 'child' });
|
|
69
70
|
|
|
70
|
-
// Get menu actions from root
|
|
71
|
-
const
|
|
72
|
-
const menuActions =
|
|
71
|
+
// Get menu actions from root actions (on 'action' edge relation).
|
|
72
|
+
const rootActions = get(graph.actions(Node.RootId));
|
|
73
|
+
const menuActions = rootActions.filter((node) => node.properties.disposition === 'menu');
|
|
73
74
|
|
|
74
75
|
// Add menu actions as children of the dropdown group.
|
|
75
76
|
menuActions.forEach((menuAction) => {
|
|
76
77
|
nodes.push(menuAction as ActionGraphProps['nodes'][number]);
|
|
77
|
-
edges.push({ source: MAIN_MENU_GROUP_ID, target: menuAction.id });
|
|
78
|
+
edges.push({ source: MAIN_MENU_GROUP_ID, target: menuAction.id, relation: 'child' });
|
|
78
79
|
});
|
|
79
80
|
|
|
80
81
|
return { nodes, edges };
|
|
81
82
|
}),
|
|
82
|
-
[graph, stateAtom,
|
|
83
|
+
[graph, stateAtom, updateState, t],
|
|
83
84
|
);
|
|
84
85
|
|
|
85
86
|
return { actions: actionsAtom, onAction: runAction };
|
|
@@ -7,7 +7,7 @@ import { useCallback, useContext } from 'react';
|
|
|
7
7
|
|
|
8
8
|
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
9
|
|
|
10
|
-
import { SimpleLayoutState } from '
|
|
10
|
+
import { SimpleLayoutState } from '#types';
|
|
11
11
|
|
|
12
12
|
export type UseSimpleLayoutState = {
|
|
13
13
|
state: SimpleLayoutState;
|
package/src/meta.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type Plugin } from '@dxos/app-framework';
|
|
|
6
6
|
import { trim } from '@dxos/util';
|
|
7
7
|
|
|
8
8
|
export const meta: Plugin.Meta = {
|
|
9
|
-
id: 'dxos.
|
|
9
|
+
id: 'org.dxos.plugin.simple-layout',
|
|
10
10
|
name: 'Simple Layout',
|
|
11
11
|
description: trim`
|
|
12
12
|
Minimal layout plugin for simplified UI contexts like popover windows.
|