@dxos/plugin-simple-layout 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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 +44 -64
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +44 -63
- 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/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 +35 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts +7 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/index.d.ts +2 -0
- package/dist/types/src/components/MobileLayout/index.d.ts.map +1 -0
- 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 +28 -0
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +54 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts +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 +17 -8
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +35 -25
- 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/SimpleLayout/index.d.ts +3 -0
- package/dist/types/src/components/SimpleLayout/index.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 +4 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +19 -0
- package/dist/types/src/hooks/actions.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
- package/dist/types/src/hooks/useCompanions.d.ts +5 -1
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +3 -3
- 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 +7 -6
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -30
- package/src/SimpleLayoutPlugin.ts +24 -13
- 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} +4 -4
- package/src/capabilities/react-surface.tsx +51 -0
- package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +2 -2
- package/src/capabilities/{state/state.tsx → state.tsx} +6 -5
- package/src/capabilities/url-handler.ts +161 -0
- package/src/components/ContentError.stories.tsx +8 -7
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +6 -6
- package/src/components/Home/Home.tsx +50 -43
- package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +5 -5
- 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 +133 -0
- package/src/components/MobileLayout/MobileLayout.tsx +374 -0
- package/src/components/MobileLayout/index.ts +5 -0
- package/src/components/NavBranch/NavBranch.tsx +127 -0
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +9 -9
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +93 -0
- package/src/components/SimpleLayout/Drawer.tsx +27 -82
- package/src/components/SimpleLayout/Main.tsx +40 -34
- package/src/components/SimpleLayout/NavBar.stories.tsx +131 -23
- package/src/components/SimpleLayout/NavBar.tsx +18 -51
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +45 -57
- package/src/components/SimpleLayout/SimpleLayout.tsx +40 -22
- package/src/components/SimpleLayout/index.ts +3 -0
- package/src/components/hooks.ts +9 -9
- package/src/components/index.ts +4 -2
- package/src/hooks/actions.ts +84 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useAppBarProps.ts +115 -0
- package/src/hooks/useCompanions.ts +8 -5
- package/src/hooks/useDrawerActions.ts +100 -0
- package/src/hooks/useNavbarActions.ts +87 -0
- package/src/hooks/useSimpleLayoutState.ts +5 -5
- 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 +12 -8
- package/src/types/events.ts +3 -2
- package/dist/lib/browser/chunk-LR3EE3VB.mjs +0 -789
- package/dist/lib/browser/chunk-LR3EE3VB.mjs.map +0 -7
- package/dist/lib/browser/chunk-P77G4YTR.mjs +0 -29
- package/dist/lib/browser/chunk-P77G4YTR.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-775UYAC2.mjs +0 -203
- package/dist/lib/browser/operation-resolver-775UYAC2.mjs.map +0 -7
- package/dist/lib/browser/react-root-KM55OMGJ.mjs +0 -21
- package/dist/lib/browser/react-root-KM55OMGJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-BABGAWGY.mjs +0 -39
- package/dist/lib/browser/react-surface-BABGAWGY.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs +0 -66
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +0 -7
- package/dist/lib/browser/state-OUFTC2KV.mjs +0 -47
- package/dist/lib/browser/state-OUFTC2KV.mjs.map +0 -7
- package/dist/lib/browser/url-handler-DOUFQIAC.mjs +0 -54
- package/dist/lib/browser/url-handler-DOUFQIAC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5TEKVJG.mjs +0 -31
- package/dist/lib/node-esm/chunk-F5TEKVJG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HB2B3LLG.mjs +0 -790
- package/dist/lib/node-esm/chunk-HB2B3LLG.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-LDNYS3DI.mjs +0 -204
- package/dist/lib/node-esm/operation-resolver-LDNYS3DI.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-36UYFEEB.mjs +0 -22
- package/dist/lib/node-esm/react-root-36UYFEEB.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-CGHFVWU3.mjs +0 -40
- package/dist/lib/node-esm/react-surface-CGHFVWU3.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs +0 -68
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +0 -7
- package/dist/lib/node-esm/state-Q2ZA26W5.mjs +0 -48
- package/dist/lib/node-esm/state-Q2ZA26W5.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-DVAZZEUO.mjs +0 -55
- package/dist/lib/node-esm/url-handler-DVAZZEUO.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 -10
- 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/SimpleLayout/Banner.d.ts +0 -8
- package/dist/types/src/components/SimpleLayout/Banner.d.ts.map +0 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts +0 -9
- 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 -215
- package/src/capabilities/react-root/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- package/src/capabilities/react-surface/react-surface.tsx +0 -40
- 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 -80
- package/src/components/ContentError.tsx +0 -23
- package/src/components/SimpleLayout/Banner.tsx +0 -113
- package/src/components/Workspace/Workspace.tsx +0 -115
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import { useMemo } from 'react';
|
|
8
|
+
|
|
9
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
10
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
11
|
+
import { Node, useActionRunner } from '@dxos/plugin-graph';
|
|
12
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
13
|
+
import { type ActionExecutor, type ActionGraphProps, createGapSeparator } from '@dxos/react-ui-menu';
|
|
14
|
+
|
|
15
|
+
import { useMobileLayout } from '#components';
|
|
16
|
+
import { meta } from '#meta';
|
|
17
|
+
import { SimpleLayoutState as SimpleLayoutStateCapability } from '#types';
|
|
18
|
+
|
|
19
|
+
import { createCompanionActions } from './actions';
|
|
20
|
+
import { useSimpleLayoutState } from './useSimpleLayoutState';
|
|
21
|
+
|
|
22
|
+
export type DrawerActions = {
|
|
23
|
+
/** Action graph atom for the drawer. */
|
|
24
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
25
|
+
/** Action executor callback. */
|
|
26
|
+
onAction: ActionExecutor;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Builds the drawer actions including companion tabs and toolbar buttons.
|
|
31
|
+
*/
|
|
32
|
+
export const useDrawerActions = (consumerName: string): DrawerActions => {
|
|
33
|
+
const { t } = useTranslation(meta.id);
|
|
34
|
+
const stateAtom = useCapability(SimpleLayoutStateCapability);
|
|
35
|
+
const { graph } = useAppGraph();
|
|
36
|
+
const runAction = useActionRunner();
|
|
37
|
+
const { updateState } = useSimpleLayoutState();
|
|
38
|
+
const { keyboardOpen } = useMobileLayout(consumerName);
|
|
39
|
+
|
|
40
|
+
// Create a computed atom that derives everything from graph connections and state.
|
|
41
|
+
const actionsAtom = useMemo(
|
|
42
|
+
() =>
|
|
43
|
+
Atom.make((get): ActionGraphProps => {
|
|
44
|
+
// Derive drawer state from state atom.
|
|
45
|
+
const state = get(stateAtom);
|
|
46
|
+
|
|
47
|
+
// Add companion tab actions.
|
|
48
|
+
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
49
|
+
idPrefix: 'drawer',
|
|
50
|
+
selectedVariant: state.drawerState !== 'closed' ? state.companionVariant : undefined,
|
|
51
|
+
updateState,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Add gap separator before toolbar buttons.
|
|
55
|
+
const gapSeparator = createGapSeparator('drawer-gap');
|
|
56
|
+
nodes.push(...gapSeparator.nodes);
|
|
57
|
+
edges.push(...gapSeparator.edges);
|
|
58
|
+
|
|
59
|
+
// Add expand/collapse toggle button (hidden when keyboard is open).
|
|
60
|
+
if (!keyboardOpen) {
|
|
61
|
+
const isExpanded = state.drawerState === 'expanded';
|
|
62
|
+
const toggleExpandAction = {
|
|
63
|
+
id: 'drawer-toggle-expand',
|
|
64
|
+
type: Node.ActionType,
|
|
65
|
+
properties: {
|
|
66
|
+
icon: isExpanded ? 'ph--arrow-down--regular' : 'ph--arrow-up--regular',
|
|
67
|
+
label: isExpanded ? t('collapse-drawer.label') : t('expand-drawer.label'),
|
|
68
|
+
iconOnly: true,
|
|
69
|
+
},
|
|
70
|
+
data: () =>
|
|
71
|
+
Effect.sync(() => updateState((state) => ({ ...state, drawerState: isExpanded ? 'open' : 'expanded' }))),
|
|
72
|
+
};
|
|
73
|
+
nodes.push(toggleExpandAction);
|
|
74
|
+
edges.push({ source: 'root', target: toggleExpandAction.id, relation: 'child' });
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Add close button.
|
|
78
|
+
const closeAction = {
|
|
79
|
+
id: 'drawer-close',
|
|
80
|
+
type: Node.ActionType,
|
|
81
|
+
properties: {
|
|
82
|
+
icon: 'ph--x--regular',
|
|
83
|
+
label: t('close-drawer.label'),
|
|
84
|
+
iconOnly: true,
|
|
85
|
+
},
|
|
86
|
+
data: () =>
|
|
87
|
+
Effect.sync(() =>
|
|
88
|
+
updateState((state) => ({ ...state, drawerState: 'closed', companionVariant: undefined })),
|
|
89
|
+
),
|
|
90
|
+
};
|
|
91
|
+
nodes.push(closeAction);
|
|
92
|
+
edges.push({ source: 'root', target: closeAction.id, relation: 'child' });
|
|
93
|
+
|
|
94
|
+
return { nodes, edges };
|
|
95
|
+
}),
|
|
96
|
+
[graph, stateAtom, updateState, keyboardOpen, t],
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
return { actions: actionsAtom, onAction: runAction };
|
|
100
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
10
|
+
import { Node, useActionRunner } from '@dxos/plugin-graph';
|
|
11
|
+
import { useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import {
|
|
13
|
+
type ActionExecutor,
|
|
14
|
+
type ActionGraphProps,
|
|
15
|
+
createGapSeparator,
|
|
16
|
+
createMenuItemGroup,
|
|
17
|
+
} from '@dxos/react-ui-menu';
|
|
18
|
+
|
|
19
|
+
import { meta } from '#meta';
|
|
20
|
+
import { SimpleLayoutState } from '#types';
|
|
21
|
+
|
|
22
|
+
import { createCompanionActions } from './actions';
|
|
23
|
+
import { useSimpleLayoutState } from './useSimpleLayoutState';
|
|
24
|
+
|
|
25
|
+
const MAIN_MENU_GROUP_ID = 'navbar-main-menu';
|
|
26
|
+
|
|
27
|
+
export type NavbarActions = {
|
|
28
|
+
/** Action graph atom for the navbar. */
|
|
29
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
30
|
+
/** Action executor callback. */
|
|
31
|
+
onAction: ActionExecutor;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Builds the navbar actions including companion icons, separator, and main menu dropdown.
|
|
36
|
+
* Derives everything from graph connection atoms for proper reactivity.
|
|
37
|
+
*/
|
|
38
|
+
export const useNavbarActions = (): NavbarActions => {
|
|
39
|
+
const { t } = useTranslation(meta.id);
|
|
40
|
+
const { graph } = useAppGraph();
|
|
41
|
+
const runAction = useActionRunner();
|
|
42
|
+
const stateAtom = useCapability(SimpleLayoutState);
|
|
43
|
+
const { updateState } = useSimpleLayoutState();
|
|
44
|
+
|
|
45
|
+
// Create a computed atom that derives everything from graph connections and state.
|
|
46
|
+
const actionsAtom = useMemo(
|
|
47
|
+
() =>
|
|
48
|
+
Atom.make((get): ActionGraphProps => {
|
|
49
|
+
// Add companion actions.
|
|
50
|
+
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
51
|
+
idPrefix: 'navbar',
|
|
52
|
+
updateState,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Add gap separator.
|
|
56
|
+
const gapSeparator = createGapSeparator('navbar-gap');
|
|
57
|
+
nodes.push(...gapSeparator.nodes);
|
|
58
|
+
edges.push(...gapSeparator.edges);
|
|
59
|
+
|
|
60
|
+
// Add main menu dropdown group.
|
|
61
|
+
const mainMenuGroup = createMenuItemGroup(MAIN_MENU_GROUP_ID, {
|
|
62
|
+
variant: 'dropdownMenu',
|
|
63
|
+
icon: 'ph--list--regular',
|
|
64
|
+
iconOnly: true,
|
|
65
|
+
label: t('main-menu.label'),
|
|
66
|
+
testId: 'simpleLayoutPlugin.addSpace',
|
|
67
|
+
});
|
|
68
|
+
nodes.push(mainMenuGroup);
|
|
69
|
+
edges.push({ source: 'root', target: mainMenuGroup.id, relation: 'child' });
|
|
70
|
+
|
|
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');
|
|
74
|
+
|
|
75
|
+
// Add menu actions as children of the dropdown group.
|
|
76
|
+
menuActions.forEach((menuAction) => {
|
|
77
|
+
nodes.push(menuAction as ActionGraphProps['nodes'][number]);
|
|
78
|
+
edges.push({ source: MAIN_MENU_GROUP_ID, target: menuAction.id, relation: 'child' });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return { nodes, edges };
|
|
82
|
+
}),
|
|
83
|
+
[graph, stateAtom, updateState, t],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return { actions: actionsAtom, onAction: runAction };
|
|
87
|
+
};
|
|
@@ -5,18 +5,18 @@
|
|
|
5
5
|
import { RegistryContext, useAtomValue } from '@effect-atom/atom-react';
|
|
6
6
|
import { useCallback, useContext } from 'react';
|
|
7
7
|
|
|
8
|
-
import { useCapability } from '@dxos/app-framework/
|
|
8
|
+
import { useCapability } from '@dxos/app-framework/ui';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { SimpleLayoutState } from '#types';
|
|
11
11
|
|
|
12
|
-
export type
|
|
12
|
+
export type UseSimpleLayoutState = {
|
|
13
13
|
state: SimpleLayoutState;
|
|
14
14
|
updateState: (fn: (current: SimpleLayoutState) => SimpleLayoutState) => void;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const useSimpleLayoutState = ():
|
|
17
|
+
export const useSimpleLayoutState = (): UseSimpleLayoutState => {
|
|
18
18
|
const registry = useContext(RegistryContext);
|
|
19
|
-
const stateAtom = useCapability(
|
|
19
|
+
const stateAtom = useCapability(SimpleLayoutState);
|
|
20
20
|
const state = useAtomValue(stateAtom);
|
|
21
21
|
|
|
22
22
|
const updateState = useCallback(
|
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.
|
|
@@ -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,63 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
|
+
import {
|
|
7
|
+
AppCapabilities,
|
|
8
|
+
LayoutOperation,
|
|
9
|
+
createEdgeExistenceChecker,
|
|
10
|
+
validateNavigationTarget,
|
|
11
|
+
} from '@dxos/app-toolkit';
|
|
12
|
+
import { Context } from '@dxos/context';
|
|
13
|
+
import { Operation } from '@dxos/operation';
|
|
14
|
+
import { ClientCapabilities } from '@dxos/plugin-client/types';
|
|
15
|
+
|
|
16
|
+
import { layoutStateAccess } from './state-access';
|
|
17
|
+
|
|
18
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.Open> = LayoutOperation.Open.pipe(
|
|
19
|
+
Operation.withHandler(
|
|
20
|
+
Effect.fnUntraced(function* (input) {
|
|
21
|
+
const { graph } = yield* Capability.get(AppCapabilities.AppGraph);
|
|
22
|
+
const { updateState } = yield* layoutStateAccess;
|
|
23
|
+
const id = input.subject[0];
|
|
24
|
+
|
|
25
|
+
// Validate navigation target, redirecting to 404 if not found.
|
|
26
|
+
const capabilities = yield* Capability.Service;
|
|
27
|
+
const pathResolvers = capabilities.getAll(AppCapabilities.NavigationPathResolver);
|
|
28
|
+
const checkRemoteExistence = yield* Capability.get(ClientCapabilities.Client).pipe(
|
|
29
|
+
Effect.map((client) =>
|
|
30
|
+
createEdgeExistenceChecker((spaceId, body) => client.edge.http.execQuery(new Context(), spaceId, body)),
|
|
31
|
+
),
|
|
32
|
+
Effect.catchAll(() => Effect.succeed(undefined)),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const validatedId =
|
|
36
|
+
input.navigation === 'immediate'
|
|
37
|
+
? id
|
|
38
|
+
: yield* validateNavigationTarget({
|
|
39
|
+
graph,
|
|
40
|
+
subjectId: id,
|
|
41
|
+
pathResolvers,
|
|
42
|
+
checkRemoteExistence,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
updateState((state) => {
|
|
46
|
+
const newHistory = state.active ? [...state.history, state.active] : state.history;
|
|
47
|
+
const trimmedHistory =
|
|
48
|
+
newHistory.length > MAX_HISTORY_LENGTH ? newHistory.slice(-MAX_HISTORY_LENGTH) : newHistory;
|
|
49
|
+
return {
|
|
50
|
+
...state,
|
|
51
|
+
active: validatedId,
|
|
52
|
+
history: trimmedHistory,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return [validatedId];
|
|
57
|
+
}),
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export default handler;
|
|
62
|
+
|
|
63
|
+
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,35 @@
|
|
|
1
|
+
// Copyright 2025 DXOS.org
|
|
2
|
+
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
|
|
5
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
6
|
+
import { getLinkedVariant } from '@dxos/react-ui-attention';
|
|
7
|
+
import { Operation } from '@dxos/operation';
|
|
8
|
+
|
|
9
|
+
import { layoutStateAccess } from './state-access';
|
|
10
|
+
|
|
11
|
+
const handler: Operation.WithHandler<typeof LayoutOperation.UpdateComplementary> =
|
|
12
|
+
LayoutOperation.UpdateComplementary.pipe(
|
|
13
|
+
Operation.withHandler(
|
|
14
|
+
Effect.fnUntraced(function* (input) {
|
|
15
|
+
const { updateState } = yield* layoutStateAccess;
|
|
16
|
+
|
|
17
|
+
if (input.state === 'closed') {
|
|
18
|
+
updateState((state) => ({
|
|
19
|
+
...state,
|
|
20
|
+
drawerState: 'closed',
|
|
21
|
+
companionVariant: undefined,
|
|
22
|
+
}));
|
|
23
|
+
} else if (input.subject) {
|
|
24
|
+
const variant = getLinkedVariant(input.subject);
|
|
25
|
+
updateState((state) => ({
|
|
26
|
+
...state,
|
|
27
|
+
companionVariant: variant,
|
|
28
|
+
drawerState: input.state === 'expanded' ? 'expanded' : 'open',
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
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;
|
|
@@ -0,0 +1,35 @@
|
|
|
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.UpdatePopover> = LayoutOperation.UpdatePopover.pipe(
|
|
11
|
+
Operation.withHandler(
|
|
12
|
+
Effect.fnUntraced(function* (input) {
|
|
13
|
+
const { updateState } = yield* layoutStateAccess;
|
|
14
|
+
|
|
15
|
+
updateState((state) => ({
|
|
16
|
+
...state,
|
|
17
|
+
popoverOpen: input.state ?? Boolean(input.subject),
|
|
18
|
+
popoverKind: input.kind ?? 'base',
|
|
19
|
+
popoverTitle: input.kind === 'card' ? input.title : undefined,
|
|
20
|
+
popoverContent:
|
|
21
|
+
typeof input.subject === 'string'
|
|
22
|
+
? { component: input.subject, props: input.props }
|
|
23
|
+
: input.subject
|
|
24
|
+
? { subject: input.subject }
|
|
25
|
+
: undefined,
|
|
26
|
+
popoverSide: input.side,
|
|
27
|
+
popoverVariant: input.variant,
|
|
28
|
+
popoverAnchor: input.variant === 'virtual' ? input.anchor : state.popoverAnchor,
|
|
29
|
+
popoverAnchorId: input.variant !== 'virtual' ? input.anchorId : state.popoverAnchorId,
|
|
30
|
+
}));
|
|
31
|
+
}),
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
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.UpdateSidebar> = LayoutOperation.UpdateSidebar.pipe(
|
|
9
|
+
Operation.withHandler(() => Effect.void),
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default handler;
|
package/src/translations.ts
CHANGED
|
@@ -3,31 +3,33 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
|
+
import { translations as searchTranslations } from '@dxos/react-ui-search';
|
|
6
7
|
|
|
7
|
-
import { meta } from '
|
|
8
|
+
import { meta } from '#meta';
|
|
8
9
|
|
|
9
10
|
export const translations = [
|
|
11
|
+
...searchTranslations,
|
|
10
12
|
{
|
|
11
13
|
'en-US': {
|
|
12
14
|
[meta.id]: {
|
|
13
|
-
'plugin
|
|
14
|
-
'settings
|
|
15
|
-
'workspaces
|
|
16
|
-
'settings
|
|
17
|
-
'back
|
|
18
|
-
'browse
|
|
19
|
-
'notifications
|
|
20
|
-
'profile
|
|
21
|
-
'app
|
|
22
|
-
'main
|
|
23
|
-
'companions
|
|
24
|
-
'error
|
|
25
|
-
'
|
|
26
|
-
'drawer
|
|
27
|
-
'
|
|
28
|
-
'
|
|
29
|
-
'
|
|
30
|
-
'
|
|
15
|
+
'plugin.name': 'Simple layout',
|
|
16
|
+
'settings.title': 'Simple layout settings',
|
|
17
|
+
'workspaces.heading': 'Workspaces',
|
|
18
|
+
'settings.heading': 'Settings',
|
|
19
|
+
'back.label': 'Back',
|
|
20
|
+
'browse.label': 'Browse',
|
|
21
|
+
'notifications.label': 'Notifications',
|
|
22
|
+
'profile.label': 'Profile',
|
|
23
|
+
'app-menu.label': 'App menu',
|
|
24
|
+
'main-menu.label': 'Main menu',
|
|
25
|
+
'companions-menu.label': 'Companions',
|
|
26
|
+
'error-fallback.message': 'An error occurred',
|
|
27
|
+
'drawer.label': 'Drawer',
|
|
28
|
+
'close-drawer.label': 'Close drawer',
|
|
29
|
+
'expand-drawer.label': 'Expand drawer',
|
|
30
|
+
'collapse-drawer.label': 'Collapse drawer',
|
|
31
|
+
'actions-menu.label': 'Actions',
|
|
32
|
+
'done.label': 'Done',
|
|
31
33
|
},
|
|
32
34
|
},
|
|
33
35
|
},
|
|
@@ -5,15 +5,21 @@
|
|
|
5
5
|
import { type Atom } from '@effect-atom/atom-react';
|
|
6
6
|
|
|
7
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
|
-
import { type
|
|
8
|
+
import { type Label } from '@dxos/react-ui';
|
|
9
9
|
|
|
10
|
-
import { meta } from '
|
|
10
|
+
import { meta } from '#meta';
|
|
11
|
+
|
|
12
|
+
export type DrawerState = 'closed' | 'open' | 'expanded';
|
|
11
13
|
|
|
12
14
|
// TODO(wittjosiah): Handle toasts.
|
|
13
15
|
export type SimpleLayoutState = {
|
|
14
16
|
/** Data to be passed to the main content Surface. */
|
|
15
17
|
content?: any;
|
|
16
18
|
|
|
19
|
+
previousWorkspace: string;
|
|
20
|
+
workspace: string;
|
|
21
|
+
active?: string;
|
|
22
|
+
|
|
17
23
|
dialogOpen: boolean;
|
|
18
24
|
dialogType?: 'default' | 'alert';
|
|
19
25
|
dialogBlockAlign?: 'start' | 'center' | 'end';
|
|
@@ -31,9 +37,9 @@ export type SimpleLayoutState = {
|
|
|
31
37
|
popoverTitle?: Label;
|
|
32
38
|
popoverContent?: any;
|
|
33
39
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
40
|
+
/** Bottom drawer state. */
|
|
41
|
+
drawerState: DrawerState;
|
|
42
|
+
|
|
37
43
|
/** Stack of previously active item IDs for back navigation. */
|
|
38
44
|
history: string[];
|
|
39
45
|
|
|
@@ -42,8 +48,6 @@ export type SimpleLayoutState = {
|
|
|
42
48
|
|
|
43
49
|
/** Variant of the companion to display in the drawer (e.g., "comments", "assistant-chat"). */
|
|
44
50
|
companionVariant?: string;
|
|
45
|
-
/** State of the companion drawer. */
|
|
46
|
-
drawerState?: DrawerState;
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
export const SimpleLayoutState = Capability.make<Atom.Writable<SimpleLayoutState>>(`${meta.id}
|
|
53
|
+
export const SimpleLayoutState = Capability.make<Atom.Writable<SimpleLayoutState>>(`${meta.id}.state`);
|