@dxos/plugin-simple-layout 0.8.4-main.bc674ce → 0.8.4-main.c85a9c8dae
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-P77G4YTR.mjs → chunk-7VLT3S46.mjs} +3 -3
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +7 -0
- package/dist/lib/browser/chunk-TMZNLVT2.mjs +1170 -0
- package/dist/lib/browser/chunk-TMZNLVT2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -19
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-775UYAC2.mjs → operation-resolver-BYRIQOQT.mjs} +30 -28
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +7 -0
- package/dist/lib/browser/{react-root-KM55OMGJ.mjs → react-root-MMB575WY.mjs} +5 -5
- package/dist/lib/browser/react-root-MMB575WY.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-BABGAWGY.mjs → react-surface-M6CURANW.mjs} +10 -8
- package/dist/lib/browser/react-surface-M6CURANW.mjs.map +7 -0
- package/dist/lib/browser/{spotlight-dismiss-VSNOPETH.mjs → spotlight-dismiss-67PHYS5B.mjs} +3 -3
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +7 -0
- package/dist/lib/browser/{state-OUFTC2KV.mjs → state-A3PGDWWZ.mjs} +5 -4
- package/dist/lib/browser/state-A3PGDWWZ.mjs.map +7 -0
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs +152 -0
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs +1171 -0
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F5TEKVJG.mjs → chunk-VIDE5UMB.mjs} +3 -3
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -19
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-LDNYS3DI.mjs → operation-resolver-BDTFNCS2.mjs} +30 -28
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +7 -0
- package/dist/lib/node-esm/{react-root-36UYFEEB.mjs → react-root-ENZKVSY4.mjs} +5 -5
- package/dist/lib/node-esm/react-root-ENZKVSY4.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-CGHFVWU3.mjs → react-surface-ITVNQYLG.mjs} +10 -8
- package/dist/lib/node-esm/react-surface-ITVNQYLG.mjs.map +7 -0
- package/dist/lib/node-esm/{spotlight-dismiss-L5PCWIJG.mjs → spotlight-dismiss-RMLRZUVY.mjs} +3 -3
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +7 -0
- package/dist/lib/node-esm/{state-Q2ZA26W5.mjs → state-ZCFZTTPL.mjs} +5 -4
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs.map +7 -0
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs +153 -0
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts +1 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +1 -1
- package/dist/types/src/capabilities/state/index.d.ts +1 -1
- package/dist/types/src/capabilities/state/state.d.ts +1 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts +3 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -1
- package/dist/types/src/components/ContentError.stories.d.ts +1 -3
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/Home/Home.d.ts.map +1 -1
- 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/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts +26 -0
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +47 -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 +10 -3
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +4 -4
- 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.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/Workspace/Workspace.d.ts +3 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +20 -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/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 +36 -30
- package/src/SimpleLayoutPlugin.ts +10 -9
- package/src/capabilities/operation-resolver/operation-resolver.ts +24 -22
- package/src/capabilities/react-root/react-root.tsx +2 -2
- package/src/capabilities/react-surface/react-surface.tsx +6 -5
- package/src/capabilities/spotlight-dismiss/spotlight-dismiss.ts +2 -2
- package/src/capabilities/state/state.tsx +4 -3
- package/src/capabilities/url-handler/url-handler.ts +111 -34
- package/src/components/ContentError.stories.tsx +8 -7
- package/src/components/ContentLoading.stories.tsx +2 -2
- package/src/components/ContentLoading.tsx +1 -1
- package/src/components/Dialog/Dialog.tsx +5 -5
- package/src/components/Home/Home.tsx +41 -33
- package/src/components/MobileLayout/MobileLayout.stories.tsx +129 -0
- package/src/components/MobileLayout/MobileLayout.tsx +305 -0
- package/src/components/MobileLayout/index.ts +5 -0
- package/src/components/Popover/Popover.tsx +17 -7
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +94 -0
- package/src/components/SimpleLayout/Drawer.tsx +22 -68
- package/src/components/SimpleLayout/Main.tsx +40 -29
- package/src/components/SimpleLayout/NavBar.stories.tsx +131 -23
- package/src/components/SimpleLayout/NavBar.tsx +15 -47
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +20 -11
- package/src/components/SimpleLayout/SimpleLayout.tsx +38 -19
- package/src/components/SimpleLayout/index.ts +3 -0
- package/src/components/Workspace/Workspace.tsx +34 -24
- package/src/components/hooks.ts +4 -4
- package/src/components/index.ts +1 -0
- package/src/hooks/actions.ts +85 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useAppBarProps.ts +116 -0
- package/src/hooks/useCompanions.ts +8 -5
- package/src/hooks/useDrawerActions.ts +98 -0
- package/src/hooks/useNavbarActions.ts +86 -0
- package/src/hooks/useSimpleLayoutState.ts +5 -5
- package/src/types/capabilities.ts +10 -6
- 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.map +0 -7
- package/dist/lib/browser/operation-resolver-775UYAC2.mjs.map +0 -7
- package/dist/lib/browser/react-root-KM55OMGJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-BABGAWGY.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +0 -7
- 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.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.map +0 -7
- package/dist/lib/node-esm/react-root-36UYFEEB.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-CGHFVWU3.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +0 -7
- 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/components/ContentError.d.ts +0 -5
- package/dist/types/src/components/ContentError.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/src/components/ContentError.tsx +0 -23
- package/src/components/SimpleLayout/Banner.tsx +0 -113
|
@@ -0,0 +1,98 @@
|
|
|
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, useOperationInvoker } 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 { invokeSync } = useOperationInvoker();
|
|
38
|
+
const { updateState } = useSimpleLayoutState();
|
|
39
|
+
const { keyboardOpen } = useMobileLayout(consumerName);
|
|
40
|
+
|
|
41
|
+
// Create a computed atom that derives everything from graph connections and state.
|
|
42
|
+
const actionsAtom = useMemo(
|
|
43
|
+
() =>
|
|
44
|
+
Atom.make((get): ActionGraphProps => {
|
|
45
|
+
// Derive drawer state from state atom.
|
|
46
|
+
const state = get(stateAtom);
|
|
47
|
+
|
|
48
|
+
// Add companion tab actions.
|
|
49
|
+
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
50
|
+
idPrefix: 'drawer',
|
|
51
|
+
selectedVariant: state.companionVariant,
|
|
52
|
+
invokeSync,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Add gap separator before toolbar buttons.
|
|
56
|
+
const gapSeparator = createGapSeparator('drawer-gap');
|
|
57
|
+
nodes.push(...gapSeparator.nodes);
|
|
58
|
+
edges.push(...gapSeparator.edges);
|
|
59
|
+
|
|
60
|
+
// Add expand/collapse toggle button (hidden when keyboard is open).
|
|
61
|
+
if (!keyboardOpen) {
|
|
62
|
+
const isExpanded = state.drawerState === 'expanded';
|
|
63
|
+
const toggleExpandAction = {
|
|
64
|
+
id: 'drawer-toggle-expand',
|
|
65
|
+
type: Node.ActionType,
|
|
66
|
+
properties: {
|
|
67
|
+
icon: isExpanded ? 'ph--arrow-down--regular' : 'ph--arrow-up--regular',
|
|
68
|
+
label: isExpanded ? t('collapse drawer label') : t('expand drawer label'),
|
|
69
|
+
iconOnly: true,
|
|
70
|
+
},
|
|
71
|
+
data: () =>
|
|
72
|
+
Effect.sync(() => updateState((state) => ({ ...state, drawerState: isExpanded ? 'open' : 'expanded' }))),
|
|
73
|
+
};
|
|
74
|
+
nodes.push(toggleExpandAction);
|
|
75
|
+
edges.push({ source: 'root', target: toggleExpandAction.id, relation: 'child' });
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Add close button.
|
|
79
|
+
const closeAction = {
|
|
80
|
+
id: 'drawer-close',
|
|
81
|
+
type: Node.ActionType,
|
|
82
|
+
properties: {
|
|
83
|
+
icon: 'ph--x--regular',
|
|
84
|
+
label: t('close drawer label'),
|
|
85
|
+
iconOnly: true,
|
|
86
|
+
},
|
|
87
|
+
data: () => Effect.sync(() => updateState((state) => ({ ...state, drawerState: 'closed' }))),
|
|
88
|
+
};
|
|
89
|
+
nodes.push(closeAction);
|
|
90
|
+
edges.push({ source: 'root', target: closeAction.id, relation: 'child' });
|
|
91
|
+
|
|
92
|
+
return { nodes, edges };
|
|
93
|
+
}),
|
|
94
|
+
[graph, stateAtom, invokeSync, updateState, keyboardOpen, t],
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return { actions: actionsAtom, onAction: runAction };
|
|
98
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
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, useOperationInvoker } 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
|
+
|
|
24
|
+
const MAIN_MENU_GROUP_ID = 'navbar-main-menu';
|
|
25
|
+
|
|
26
|
+
export type NavbarActions = {
|
|
27
|
+
/** Action graph atom for the navbar. */
|
|
28
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
29
|
+
/** Action executor callback. */
|
|
30
|
+
onAction: ActionExecutor;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Builds the navbar actions including companion icons, separator, and main menu dropdown.
|
|
35
|
+
* Derives everything from graph connection atoms for proper reactivity.
|
|
36
|
+
*/
|
|
37
|
+
export const useNavbarActions = (): NavbarActions => {
|
|
38
|
+
const { t } = useTranslation(meta.id);
|
|
39
|
+
const { graph } = useAppGraph();
|
|
40
|
+
const runAction = useActionRunner();
|
|
41
|
+
const { invokeSync } = useOperationInvoker();
|
|
42
|
+
const stateAtom = useCapability(SimpleLayoutState);
|
|
43
|
+
|
|
44
|
+
// Create a computed atom that derives everything from graph connections and state.
|
|
45
|
+
const actionsAtom = useMemo(
|
|
46
|
+
() =>
|
|
47
|
+
Atom.make((get): ActionGraphProps => {
|
|
48
|
+
// Add companion actions.
|
|
49
|
+
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
50
|
+
idPrefix: 'navbar',
|
|
51
|
+
invokeSync,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Add gap separator.
|
|
55
|
+
const gapSeparator = createGapSeparator('navbar-gap');
|
|
56
|
+
nodes.push(...gapSeparator.nodes);
|
|
57
|
+
edges.push(...gapSeparator.edges);
|
|
58
|
+
|
|
59
|
+
// Add main menu dropdown group.
|
|
60
|
+
const mainMenuGroup = createMenuItemGroup(MAIN_MENU_GROUP_ID, {
|
|
61
|
+
variant: 'dropdownMenu',
|
|
62
|
+
icon: 'ph--list--regular',
|
|
63
|
+
iconOnly: true,
|
|
64
|
+
label: t('main menu label'),
|
|
65
|
+
testId: 'simpleLayoutPlugin.addSpace',
|
|
66
|
+
});
|
|
67
|
+
nodes.push(mainMenuGroup);
|
|
68
|
+
edges.push({ source: 'root', target: mainMenuGroup.id, relation: 'child' });
|
|
69
|
+
|
|
70
|
+
// Get menu actions from root actions (on 'action' edge relation).
|
|
71
|
+
const rootActions = get(graph.actions(Node.RootId));
|
|
72
|
+
const menuActions = rootActions.filter((node) => node.properties.disposition === 'menu');
|
|
73
|
+
|
|
74
|
+
// Add menu actions as children of the dropdown group.
|
|
75
|
+
menuActions.forEach((menuAction) => {
|
|
76
|
+
nodes.push(menuAction as ActionGraphProps['nodes'][number]);
|
|
77
|
+
edges.push({ source: MAIN_MENU_GROUP_ID, target: menuAction.id, relation: 'child' });
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return { nodes, edges };
|
|
81
|
+
}),
|
|
82
|
+
[graph, stateAtom, invokeSync, t],
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return { actions: actionsAtom, onAction: runAction };
|
|
86
|
+
};
|
|
@@ -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(
|
|
@@ -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
10
|
import { meta } from '../meta';
|
|
11
11
|
|
|
12
|
+
export type DrawerState = 'closed' | 'open' | 'expanded';
|
|
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
53
|
export const SimpleLayoutState = Capability.make<Atom.Writable<SimpleLayoutState>>(`${meta.id}/state`);
|
package/src/types/events.ts
CHANGED
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { type ActivationEvent
|
|
5
|
+
import { type ActivationEvent } from '@dxos/app-framework';
|
|
6
|
+
import { AppActivationEvents } from '@dxos/app-toolkit';
|
|
6
7
|
|
|
7
8
|
import { SimpleLayoutState } from './capabilities';
|
|
8
9
|
|
|
9
10
|
export namespace SimpleLayoutEvents {
|
|
10
11
|
/** Fired when SimpleLayoutState capability is ready. */
|
|
11
|
-
export const StateReady: ActivationEvent.ActivationEvent =
|
|
12
|
+
export const StateReady: ActivationEvent.ActivationEvent = AppActivationEvents.createStateEvent(
|
|
12
13
|
SimpleLayoutState.identifier,
|
|
13
14
|
);
|
|
14
15
|
}
|