@dxos/plugin-simple-layout 0.8.4-main.21d9917 → 0.8.4-main.2244d791bb
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-CLPGTNWJ.mjs → chunk-7VLT3S46.mjs} +3 -3
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +7 -0
- package/dist/lib/browser/chunk-U632CHRU.mjs +1167 -0
- package/dist/lib/browser/chunk-U632CHRU.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +27 -20
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-LTB63NKP.mjs → operation-resolver-BYRIQOQT.mjs} +66 -29
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +7 -0
- package/dist/lib/browser/{react-root-6ARAPH3O.mjs → react-root-ZQTWLJYR.mjs} +5 -5
- package/dist/lib/browser/react-root-ZQTWLJYR.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-SO7B23GS.mjs → react-surface-IOYDLMNR.mjs} +10 -8
- package/dist/lib/browser/react-surface-IOYDLMNR.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-H4IGICBB.mjs → state-A3PGDWWZ.mjs} +8 -5
- 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-UXFYLQJA.mjs +1168 -0
- package/dist/lib/node-esm/chunk-UXFYLQJA.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-MUVVYBUE.mjs → chunk-VIDE5UMB.mjs} +3 -3
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +27 -20
- 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-7O6O7T4Q.mjs → operation-resolver-BDTFNCS2.mjs} +66 -29
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +7 -0
- package/dist/lib/node-esm/{react-root-2CPA2ZUS.mjs → react-root-FMAUHDJI.mjs} +5 -5
- package/dist/lib/node-esm/react-root-FMAUHDJI.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-FKAV56MO.mjs → react-surface-ZAZRIKZQ.mjs} +10 -8
- package/dist/lib/node-esm/react-surface-ZAZRIKZQ.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-QIU2LMLT.mjs → state-ZCFZTTPL.mjs} +8 -5
- 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.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/spotlight-dismiss.d.ts.map +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 +2 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -1
- package/dist/types/src/components/ContentError.stories.d.ts +6 -0
- 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/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 +9 -0
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Main.d.ts +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +13 -3
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +13 -9
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +10 -0
- 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/hooks.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 +5 -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 +12 -0
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
- 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/translations.d.ts +6 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +8 -3
- 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 +35 -30
- package/src/SimpleLayoutPlugin.ts +10 -9
- package/src/capabilities/operation-resolver/operation-resolver.ts +65 -26
- 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 +6 -3
- package/src/capabilities/url-handler/url-handler.ts +111 -34
- package/src/components/ContentError.stories.tsx +1 -1
- package/src/components/ContentLoading.stories.tsx +1 -1
- package/src/components/Dialog/Dialog.tsx +4 -4
- package/src/components/Home/Home.tsx +23 -20
- package/src/components/MobileLayout/MobileLayout.stories.tsx +125 -0
- package/src/components/MobileLayout/MobileLayout.tsx +305 -0
- package/src/components/MobileLayout/index.ts +5 -0
- package/src/components/Popover/Popover.tsx +4 -4
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +97 -0
- package/src/components/SimpleLayout/Drawer.tsx +102 -0
- package/src/components/SimpleLayout/Main.tsx +44 -44
- package/src/components/SimpleLayout/NavBar.stories.tsx +129 -24
- package/src/components/SimpleLayout/NavBar.tsx +24 -58
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +22 -9
- package/src/components/SimpleLayout/SimpleLayout.tsx +45 -6
- package/src/components/SimpleLayout/index.ts +3 -0
- package/src/components/Workspace/Workspace.tsx +16 -11
- package/src/components/hooks.ts +9 -13
- package/src/components/index.ts +1 -0
- package/src/hooks/actions.ts +85 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useAppBarProps.ts +112 -0
- package/src/hooks/useCompanions.ts +22 -0
- package/src/hooks/useDrawerActions.ts +98 -0
- package/src/hooks/useNavbarActions.ts +86 -0
- package/src/hooks/useSimpleLayoutState.ts +5 -5
- package/src/translations.ts +6 -0
- package/src/types/capabilities.ts +12 -3
- package/src/types/events.ts +3 -2
- package/dist/lib/browser/chunk-CLPGTNWJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FK4M7GJV.mjs +0 -613
- package/dist/lib/browser/chunk-FK4M7GJV.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs.map +0 -7
- package/dist/lib/browser/react-root-6ARAPH3O.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SO7B23GS.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +0 -7
- package/dist/lib/browser/state-H4IGICBB.mjs.map +0 -7
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs +0 -54
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs +0 -614
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MUVVYBUE.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-FKAV56MO.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +0 -7
- package/dist/lib/node-esm/state-QIU2LMLT.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs +0 -55
- package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs.map +0 -7
- 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/SimpleLayout/Banner.tsx +0 -82
|
@@ -2,73 +2,39 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
5
6
|
import React from 'react';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { type ThemedClassName } from '@dxos/react-ui';
|
|
9
|
+
import {
|
|
10
|
+
type ActionExecutor,
|
|
11
|
+
type ActionGraphProps,
|
|
12
|
+
MenuProvider,
|
|
13
|
+
ToolbarMenu,
|
|
14
|
+
useMenuActions,
|
|
15
|
+
} from '@dxos/react-ui-menu';
|
|
11
16
|
import { mx } from '@dxos/ui-theme';
|
|
12
17
|
|
|
13
|
-
|
|
18
|
+
const NAVBAR_NAME = 'SimpleLayout.NavBar';
|
|
14
19
|
|
|
15
20
|
export type NavBarProps = ThemedClassName<{
|
|
16
|
-
|
|
17
|
-
|
|
21
|
+
/** Action graph atom for the toolbar. */
|
|
22
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
23
|
+
/** Action executor callback. */
|
|
24
|
+
onAction?: ActionExecutor;
|
|
18
25
|
}>;
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const connections = useConnections(graph, Node.RootId);
|
|
26
|
-
const menuActions = connections.filter((node) => node.properties.disposition === 'menu');
|
|
27
|
-
|
|
28
|
-
const isBrowseActive = activeId !== 'notifications' && activeId !== 'profile';
|
|
27
|
+
/**
|
|
28
|
+
* Presentational navbar component that renders a toolbar from an action graph.
|
|
29
|
+
*/
|
|
30
|
+
export const NavBar = ({ classNames, actions, onAction }: NavBarProps) => {
|
|
31
|
+
const menu = useMenuActions(actions);
|
|
29
32
|
|
|
30
33
|
return (
|
|
31
|
-
<
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
<Tooltip.Trigger asChild content={t('app menu label')}>
|
|
35
|
-
<DropdownMenu.Trigger asChild data-testid='spacePlugin.addSpace'>
|
|
36
|
-
<IconButton icon='ph--plus--regular' iconOnly label={t('main menu label')} />
|
|
37
|
-
</DropdownMenu.Trigger>
|
|
38
|
-
</Tooltip.Trigger>
|
|
39
|
-
</DropdownMenu.Root>
|
|
40
|
-
</MenuProvider>
|
|
41
|
-
{/*
|
|
42
|
-
<ButtonGroup>
|
|
43
|
-
<IconButton
|
|
44
|
-
{...buttonProps}
|
|
45
|
-
label={t('browse label')}
|
|
46
|
-
icon='ph--squares-four--regular'
|
|
47
|
-
onClick={() => onActiveIdChange?.(null)}
|
|
48
|
-
variant={isBrowseActive ? 'primary' : 'default'}
|
|
49
|
-
{...(isBrowseActive && { 'aria-current': 'location' })}
|
|
50
|
-
/>
|
|
51
|
-
<IconButton
|
|
52
|
-
{...buttonProps}
|
|
53
|
-
label={t('notifications label')}
|
|
54
|
-
icon='ph--bell-simple--regular'
|
|
55
|
-
onClick={() => onActiveIdChange?.('notifications')}
|
|
56
|
-
variant={activeId === 'notifications' ? 'primary' : 'default'}
|
|
57
|
-
{...(activeId === 'notifications' && { 'aria-current': 'location' })}
|
|
58
|
-
/>
|
|
59
|
-
<Button
|
|
60
|
-
variant={activeId === 'profile' ? 'primary' : 'default'}
|
|
61
|
-
onClick={() => onActiveIdChange?.('profile')}
|
|
62
|
-
classNames={buttonProps.classNames}
|
|
63
|
-
>
|
|
64
|
-
<span className='sr-only'>{t('profile label')}</span>
|
|
65
|
-
<Avatar.Root>
|
|
66
|
-
<Avatar.Label classNames='sr-only'>Profile display name</Avatar.Label>
|
|
67
|
-
<Avatar.Content size={8} status='active' hue='cyan' fallback='🗿' />
|
|
68
|
-
</Avatar.Root>
|
|
69
|
-
</Button>
|
|
70
|
-
</ButtonGroup>
|
|
71
|
-
*/}
|
|
72
|
-
</Toolbar.Root>
|
|
34
|
+
<MenuProvider {...menu} onAction={onAction} alwaysActive>
|
|
35
|
+
<ToolbarMenu density='coarse' classNames={mx(classNames)} />
|
|
36
|
+
</MenuProvider>
|
|
73
37
|
);
|
|
74
38
|
};
|
|
39
|
+
|
|
40
|
+
NavBar.displayName = NAVBAR_NAME;
|
|
@@ -5,14 +5,15 @@
|
|
|
5
5
|
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
6
|
import * as Effect from 'effect/Effect';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { ActivationEvents, Capabilities, Capability, Plugin } from '@dxos/app-framework';
|
|
9
9
|
import { withPluginManager } from '@dxos/app-framework/testing';
|
|
10
|
+
import { AppActivationEvents, AppPlugin } from '@dxos/app-toolkit';
|
|
10
11
|
import { ClientOperation, ClientPlugin } from '@dxos/plugin-client';
|
|
11
12
|
import { SearchPlugin } from '@dxos/plugin-search';
|
|
12
13
|
import { SpacePlugin } from '@dxos/plugin-space';
|
|
13
14
|
import { SpaceOperation } from '@dxos/plugin-space/types';
|
|
14
15
|
import { corePlugins } from '@dxos/plugin-testing';
|
|
15
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
16
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
16
17
|
import { translations as searchTranslation } from '@dxos/react-ui-searchlist';
|
|
17
18
|
import { Collection } from '@dxos/schema';
|
|
18
19
|
|
|
@@ -24,18 +25,18 @@ import { translations } from '../../translations';
|
|
|
24
25
|
import { SimpleLayout } from './SimpleLayout';
|
|
25
26
|
|
|
26
27
|
const TestPlugin = Plugin.define<SimpleLayoutPluginOptions>(pluginMeta).pipe(
|
|
28
|
+
AppPlugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
27
29
|
Plugin.addModule(({ isPopover = false }) => ({
|
|
28
30
|
id: Capability.getModuleTag(State),
|
|
29
|
-
activatesOn:
|
|
30
|
-
activatesAfter: [
|
|
31
|
+
activatesOn: ActivationEvents.Startup,
|
|
32
|
+
activatesAfter: [AppActivationEvents.LayoutReady],
|
|
31
33
|
activate: () => State({ initialState: { isPopover } } satisfies SimpleLayoutStateOptions),
|
|
32
34
|
})),
|
|
33
|
-
Common.Plugin.addOperationResolverModule({ activate: OperationResolver }),
|
|
34
35
|
Plugin.addModule({
|
|
35
36
|
id: 'setup',
|
|
36
|
-
activatesOn:
|
|
37
|
+
activatesOn: ActivationEvents.OperationInvokerReady,
|
|
37
38
|
activate: Effect.fnUntraced(function* () {
|
|
38
|
-
const { invoke } = yield* Capability.get(
|
|
39
|
+
const { invoke } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
39
40
|
yield* invoke(ClientOperation.CreateIdentity, {});
|
|
40
41
|
const { space: work } = yield* invoke(SpaceOperation.Create, { name: 'Work Space' });
|
|
41
42
|
const { space: sharedProject } = yield* invoke(SpaceOperation.Create, { name: 'Shared Project' });
|
|
@@ -91,10 +92,22 @@ export default meta;
|
|
|
91
92
|
|
|
92
93
|
type Story = StoryObj<typeof meta>;
|
|
93
94
|
|
|
95
|
+
/**
|
|
96
|
+
* NOTE: To expose to iphone on network:
|
|
97
|
+
* `moon run storybook-react:serve dev -H 0.0.0.0`
|
|
98
|
+
*/
|
|
94
99
|
export const Default: Story = {
|
|
95
|
-
decorators: [
|
|
100
|
+
decorators: [
|
|
101
|
+
withTheme(),
|
|
102
|
+
withLayout({ layout: 'column', classNames: 'relative' }),
|
|
103
|
+
createPluginManager({ isPopover: false }),
|
|
104
|
+
],
|
|
96
105
|
};
|
|
97
106
|
|
|
98
107
|
export const Popover: Story = {
|
|
99
|
-
decorators: [
|
|
108
|
+
decorators: [
|
|
109
|
+
withTheme(),
|
|
110
|
+
withLayout({ layout: 'column', classNames: 'relative' }),
|
|
111
|
+
createPluginManager({ isPopover: true }),
|
|
112
|
+
],
|
|
100
113
|
};
|
|
@@ -2,19 +2,58 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React from 'react';
|
|
5
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
6
6
|
|
|
7
|
+
import { Splitter, type SplitterMode } from '@dxos/react-ui';
|
|
8
|
+
import { Mosaic } from '@dxos/react-ui-mosaic';
|
|
9
|
+
|
|
10
|
+
import { useSimpleLayoutState } from '../../hooks';
|
|
7
11
|
import { Dialog } from '../Dialog';
|
|
12
|
+
import { MobileLayout } from '../MobileLayout';
|
|
8
13
|
import { PopoverContent, PopoverRoot } from '../Popover';
|
|
9
14
|
|
|
15
|
+
import { Drawer } from './Drawer';
|
|
10
16
|
import { Main } from './Main';
|
|
11
17
|
|
|
18
|
+
// TODO(burdon): Mobile/Desktop variance?
|
|
12
19
|
export const SimpleLayout = () => {
|
|
20
|
+
const { state } = useSimpleLayoutState();
|
|
21
|
+
const [keyboardOpen, setKeyboardOpen] = useState(false);
|
|
22
|
+
const [splitterMode, setSplitterMode] = useState<SplitterMode>('upper');
|
|
23
|
+
|
|
24
|
+
const drawerRef = useRef<HTMLDivElement>(null);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (keyboardOpen) {
|
|
27
|
+
// Determine which panel has focus and expand that one.
|
|
28
|
+
const activeElement = document.activeElement;
|
|
29
|
+
const drawerHasFocus = drawerRef.current?.contains(activeElement);
|
|
30
|
+
setSplitterMode(drawerHasFocus ? 'lower' : 'upper');
|
|
31
|
+
} else {
|
|
32
|
+
setSplitterMode(state.drawerState === 'closed' ? 'upper' : state.drawerState === 'open' ? 'both' : 'lower');
|
|
33
|
+
}
|
|
34
|
+
}, [state.drawerState, keyboardOpen]);
|
|
35
|
+
|
|
13
36
|
return (
|
|
14
|
-
<
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
37
|
+
<Mosaic.Root classNames='contents'>
|
|
38
|
+
<MobileLayout.Root
|
|
39
|
+
classNames='bg-toolbarSurface'
|
|
40
|
+
onKeyboardOpenChange={(keyboardOpen: boolean) => setKeyboardOpen(keyboardOpen)}
|
|
41
|
+
>
|
|
42
|
+
<MobileLayout.Panel safe={{ top: true, bottom: splitterMode === 'upper' }}>
|
|
43
|
+
<PopoverRoot>
|
|
44
|
+
<Splitter.Root mode={splitterMode} ratio={0.55}>
|
|
45
|
+
<Splitter.Panel position='upper'>
|
|
46
|
+
<Main />
|
|
47
|
+
</Splitter.Panel>
|
|
48
|
+
<Splitter.Panel position='lower' ref={drawerRef}>
|
|
49
|
+
<Drawer />
|
|
50
|
+
</Splitter.Panel>
|
|
51
|
+
</Splitter.Root>
|
|
52
|
+
<Dialog />
|
|
53
|
+
<PopoverContent />
|
|
54
|
+
</PopoverRoot>
|
|
55
|
+
</MobileLayout.Panel>
|
|
56
|
+
</MobileLayout.Root>
|
|
57
|
+
</Mosaic.Root>
|
|
19
58
|
);
|
|
20
59
|
};
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
8
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
10
|
import { type Node, useConnections } from '@dxos/plugin-graph';
|
|
10
|
-
import { Avatar, Icon, Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
11
|
-
import { Card,
|
|
11
|
+
import { Avatar, Icon, Layout, ScrollArea, Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Card, Mosaic, type MosaicStackTileComponent } from '@dxos/react-ui-mosaic';
|
|
12
13
|
import { SearchList, useSearchListItem, useSearchListResults } from '@dxos/react-ui-searchlist';
|
|
13
14
|
import { mx } from '@dxos/ui-theme';
|
|
14
15
|
|
|
@@ -20,9 +21,10 @@ export type WorkspaceProps = {
|
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
/**
|
|
23
|
-
*
|
|
24
|
+
* Displays the contents of a workspace disposition graph node as a searchable list.
|
|
25
|
+
* Shows direct children of the workspace with icons and labels,
|
|
26
|
+
* allowing users to filter via search and navigate by selecting an item.
|
|
24
27
|
*/
|
|
25
|
-
// TODO(burdon): Rename or motivate name in comment.
|
|
26
28
|
export const Workspace = ({ id }: WorkspaceProps) => {
|
|
27
29
|
const { t } = useTranslation(meta.id);
|
|
28
30
|
const { graph } = useAppGraph();
|
|
@@ -46,9 +48,11 @@ export const Workspace = ({ id }: WorkspaceProps) => {
|
|
|
46
48
|
</Toolbar.Root>
|
|
47
49
|
<SearchList.Content>
|
|
48
50
|
<Mosaic.Container asChild>
|
|
49
|
-
<
|
|
50
|
-
<
|
|
51
|
-
|
|
51
|
+
<ScrollArea.Root orientation='vertical'>
|
|
52
|
+
<ScrollArea.Viewport classNames='p-2'>
|
|
53
|
+
<Mosaic.Stack items={results} getId={(child) => child.id} Tile={WorkspaceChildTile} />
|
|
54
|
+
</ScrollArea.Viewport>
|
|
55
|
+
</ScrollArea.Root>
|
|
52
56
|
</Mosaic.Container>
|
|
53
57
|
</SearchList.Content>
|
|
54
58
|
</SearchList.Root>
|
|
@@ -56,7 +60,8 @@ export const Workspace = ({ id }: WorkspaceProps) => {
|
|
|
56
60
|
);
|
|
57
61
|
};
|
|
58
62
|
|
|
59
|
-
const WorkspaceChildTile:
|
|
63
|
+
const WorkspaceChildTile: MosaicStackTileComponent<Node.Node> = (props) => {
|
|
64
|
+
const data = props.data;
|
|
60
65
|
const { t } = useTranslation(meta.id);
|
|
61
66
|
const { invokeSync } = useOperationInvoker();
|
|
62
67
|
const ref = useRef<HTMLDivElement>(null);
|
|
@@ -66,7 +71,7 @@ const WorkspaceChildTile: StackTileComponent<Node.Node> = ({ data }) => {
|
|
|
66
71
|
const name = toLocalizedString(data.properties.label, t);
|
|
67
72
|
|
|
68
73
|
const handleSelect = useCallback(
|
|
69
|
-
() => invokeSync(
|
|
74
|
+
() => invokeSync(LayoutOperation.Open, { subject: [data.id] }),
|
|
70
75
|
[invokeSync, data.id],
|
|
71
76
|
);
|
|
72
77
|
|
package/src/components/hooks.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { useEffect } from 'react';
|
|
6
6
|
|
|
7
|
-
import { useAppGraph } from '@dxos/app-
|
|
7
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
8
|
import { Graph } from '@dxos/plugin-graph';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -14,17 +14,13 @@ export const useLoadDescendents = (nodeId?: string) => {
|
|
|
14
14
|
const { graph } = useAppGraph();
|
|
15
15
|
|
|
16
16
|
useEffect(() => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Graph.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
return () => cancelAnimationFrame(frame);
|
|
17
|
+
if (nodeId) {
|
|
18
|
+
// First level: expand the node itself.
|
|
19
|
+
Graph.expand(graph, nodeId, 'outbound');
|
|
20
|
+
// Second level: expand each child.
|
|
21
|
+
Graph.getConnections(graph, nodeId, 'outbound').forEach((child) => {
|
|
22
|
+
Graph.expand(graph, child.id, 'outbound');
|
|
23
|
+
});
|
|
24
|
+
}
|
|
29
25
|
}, [nodeId, graph]);
|
|
30
26
|
};
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
|
|
8
|
+
import { type Capabilities } from '@dxos/app-framework';
|
|
9
|
+
import { type AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';
|
|
10
|
+
import { Node } from '@dxos/plugin-graph';
|
|
11
|
+
import { ATTENDABLE_PATH_SEPARATOR } from '@dxos/react-ui-attention';
|
|
12
|
+
import { type ActionGraphProps } from '@dxos/react-ui-menu';
|
|
13
|
+
import { byPosition } from '@dxos/util';
|
|
14
|
+
|
|
15
|
+
import { type SimpleLayoutState } from '../types';
|
|
16
|
+
|
|
17
|
+
// TODO(wittjosiah): Factor out to shared location with plugin-deck.
|
|
18
|
+
export const PLANK_COMPANION_TYPE = 'dxos.org/plugin/deck/plank-companion';
|
|
19
|
+
|
|
20
|
+
export type CompanionActionsConfig = {
|
|
21
|
+
/** Prefix for companion action IDs (e.g. 'navbar' or 'drawer') */
|
|
22
|
+
idPrefix: string;
|
|
23
|
+
/** Optional: highlight companion with this variant */
|
|
24
|
+
selectedVariant?: string;
|
|
25
|
+
/** invokeSync function for dispatching operations */
|
|
26
|
+
invokeSync: Capabilities.OperationInvoker['invokeSync'];
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Creates action graph nodes and edges for companion actions.
|
|
31
|
+
* Shared logic between useNavbarActions and useDrawerActions.
|
|
32
|
+
*/
|
|
33
|
+
// TODO(burdon): Use builder pattern.
|
|
34
|
+
export const createCompanionActions = (
|
|
35
|
+
graph: AppCapabilities.AppGraph['graph'],
|
|
36
|
+
stateAtom: Atom.Atom<SimpleLayoutState>,
|
|
37
|
+
get: (atom: Atom.Atom<any>) => any,
|
|
38
|
+
config: CompanionActionsConfig,
|
|
39
|
+
): Pick<ActionGraphProps, 'nodes' | 'edges'> => {
|
|
40
|
+
const { idPrefix, selectedVariant, invokeSync } = config;
|
|
41
|
+
|
|
42
|
+
// Derive activeId from state atom.
|
|
43
|
+
const state = get(stateAtom);
|
|
44
|
+
const activeId = state.active ?? state.workspace;
|
|
45
|
+
|
|
46
|
+
// Get companions from graph connections for activeId.
|
|
47
|
+
const activeConnections = activeId ? get(graph.connections(activeId)) : [];
|
|
48
|
+
const companions = activeConnections
|
|
49
|
+
.filter((node: Node.Node) => node.type === PLANK_COMPANION_TYPE)
|
|
50
|
+
.toSorted((a: Node.Node, b: Node.Node) => byPosition(a.properties, b.properties));
|
|
51
|
+
|
|
52
|
+
const nodes: ActionGraphProps['nodes'] = [];
|
|
53
|
+
const edges: ActionGraphProps['edges'] = [];
|
|
54
|
+
|
|
55
|
+
// Add companion actions.
|
|
56
|
+
// TODO(burdon): Cap at 6 items.
|
|
57
|
+
companions.forEach((companion: Node.Node) => {
|
|
58
|
+
// Extract variant for highlighting if needed.
|
|
59
|
+
const [, companionVariant] = companion.id.split(ATTENDABLE_PATH_SEPARATOR);
|
|
60
|
+
|
|
61
|
+
const companionAction = {
|
|
62
|
+
id: `${idPrefix}-companion-${companion.id}`,
|
|
63
|
+
type: Node.ActionType,
|
|
64
|
+
properties: {
|
|
65
|
+
icon: companion.properties.icon ?? 'ph--placeholder--regular',
|
|
66
|
+
label: companion.properties.label,
|
|
67
|
+
iconOnly: true,
|
|
68
|
+
// Conditionally add variant highlighting.
|
|
69
|
+
...(selectedVariant !== undefined && {
|
|
70
|
+
variant: selectedVariant === companionVariant ? 'primary' : 'ghost',
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
data: () =>
|
|
74
|
+
Effect.sync(() =>
|
|
75
|
+
invokeSync(LayoutOperation.Open, {
|
|
76
|
+
subject: [companion.id],
|
|
77
|
+
}),
|
|
78
|
+
),
|
|
79
|
+
};
|
|
80
|
+
nodes.push(companionAction);
|
|
81
|
+
edges.push({ source: 'root', target: companionAction.id });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return { nodes, edges };
|
|
85
|
+
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import * as Effect from 'effect/Effect';
|
|
7
|
+
import * as Option from 'effect/Option';
|
|
8
|
+
import { useCallback, useMemo } from 'react';
|
|
9
|
+
|
|
10
|
+
import { useCapability, useOperationInvoker } from '@dxos/app-framework/ui';
|
|
11
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
12
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
13
|
+
import { Graph, Node, useActionRunner, useNode } from '@dxos/plugin-graph';
|
|
14
|
+
import { toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
15
|
+
import { type ActionGraphProps } from '@dxos/react-ui-menu';
|
|
16
|
+
|
|
17
|
+
import { type AppBarProps } from '../components';
|
|
18
|
+
import { meta } from '../meta';
|
|
19
|
+
import { SimpleLayoutState as SimpleLayoutStateCapability } from '../types';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Hook that computes all AppBar props from the app graph.
|
|
23
|
+
* Derives activeId from state atom. Returns props ready to spread into the AppBar component.
|
|
24
|
+
*/
|
|
25
|
+
export const useAppBarProps = (): Omit<AppBarProps, 'classNames'> => {
|
|
26
|
+
const { t } = useTranslation(meta.id);
|
|
27
|
+
const stateAtom = useCapability(SimpleLayoutStateCapability);
|
|
28
|
+
const state = useAtomValue(stateAtom);
|
|
29
|
+
const { graph } = useAppGraph();
|
|
30
|
+
const { invokeSync } = useOperationInvoker();
|
|
31
|
+
const runAction = useActionRunner();
|
|
32
|
+
|
|
33
|
+
// Derive activeId from state.
|
|
34
|
+
const activeId = state.active ?? state.workspace;
|
|
35
|
+
const node = useNode(graph, activeId);
|
|
36
|
+
|
|
37
|
+
// Compute title from node label.
|
|
38
|
+
const title = node ? toLocalizedString(node.properties.label, t) : undefined;
|
|
39
|
+
|
|
40
|
+
// Build actions atom filtering by disposition.
|
|
41
|
+
// Derive activeId from state atom so we don't need to recreate this atom when it changes.
|
|
42
|
+
const actionsAtom = useMemo(
|
|
43
|
+
() =>
|
|
44
|
+
Atom.make((get): ActionGraphProps => {
|
|
45
|
+
const state = get(stateAtom);
|
|
46
|
+
const activeId = state.active ?? state.workspace;
|
|
47
|
+
const allActions = activeId ? get(graph.actions(activeId)) : [];
|
|
48
|
+
const filtered = allActions.filter((action) =>
|
|
49
|
+
['list-item', 'list-item-primary', 'heading-list-item'].includes(action.properties.disposition),
|
|
50
|
+
);
|
|
51
|
+
const nodes: ActionGraphProps['nodes'] = filtered as ActionGraphProps['nodes'];
|
|
52
|
+
const edges: ActionGraphProps['edges'] = filtered.map((action) => ({ source: 'root', target: action.id }));
|
|
53
|
+
|
|
54
|
+
// Add alternate-tree action (e.g. Settings) from the workspace node.
|
|
55
|
+
const workspaceConnections = state.workspace ? get(graph.connections(state.workspace)) : [];
|
|
56
|
+
const alternateTreeNode = workspaceConnections.find(
|
|
57
|
+
(node: Node.Node) => node.properties.disposition === 'alternate-tree',
|
|
58
|
+
);
|
|
59
|
+
if (alternateTreeNode && activeId !== alternateTreeNode.id) {
|
|
60
|
+
const settingsAction = {
|
|
61
|
+
id: `appbar-settings-${alternateTreeNode.id}`,
|
|
62
|
+
type: Node.ActionType,
|
|
63
|
+
data: () => Effect.sync(() => invokeSync(LayoutOperation.Open, { subject: [alternateTreeNode.id] })),
|
|
64
|
+
properties: {
|
|
65
|
+
label: alternateTreeNode.properties.label ?? alternateTreeNode.id,
|
|
66
|
+
icon: alternateTreeNode.properties.icon ?? 'ph--placeholder--regular',
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
nodes.push(settingsAction);
|
|
70
|
+
edges.push({ source: 'root', target: settingsAction.id });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return { nodes, edges };
|
|
74
|
+
}),
|
|
75
|
+
[graph, stateAtom],
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Back button logic.
|
|
79
|
+
const showBackButton = activeId !== undefined && activeId !== Node.RootId;
|
|
80
|
+
|
|
81
|
+
const onBack = useCallback(() => {
|
|
82
|
+
if (state.active) {
|
|
83
|
+
const isWorkspace = Graph.getNode(graph, state.active).pipe(
|
|
84
|
+
Option.map((node) => node.properties.disposition === 'workspace'),
|
|
85
|
+
Option.getOrElse(() => false),
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// If history is empty and this is a workspace, go to home.
|
|
89
|
+
if (state.history.length === 0 && isWorkspace) {
|
|
90
|
+
invokeSync(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
91
|
+
} else {
|
|
92
|
+
// Otherwise, close (which will pop from history or clear active).
|
|
93
|
+
invokeSync(LayoutOperation.Close, { subject: [state.active] });
|
|
94
|
+
}
|
|
95
|
+
} else {
|
|
96
|
+
invokeSync(LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
97
|
+
}
|
|
98
|
+
}, [graph, invokeSync, state.active, state.history.length]);
|
|
99
|
+
|
|
100
|
+
// Compute popover anchor ID.
|
|
101
|
+
const popoverAnchorId =
|
|
102
|
+
node && state.popoverAnchorId === `dxos.org/ui/${meta.id}/${node.id}` ? state.popoverAnchorId : undefined;
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
title,
|
|
106
|
+
actions: actionsAtom,
|
|
107
|
+
showBackButton,
|
|
108
|
+
popoverAnchorId,
|
|
109
|
+
onBack: onBack,
|
|
110
|
+
onAction: runAction,
|
|
111
|
+
};
|
|
112
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { useConnections } from '@dxos/plugin-graph';
|
|
9
|
+
import { byPosition } from '@dxos/util';
|
|
10
|
+
|
|
11
|
+
import { PLANK_COMPANION_TYPE } from './actions';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Adopt the pattern from useNavbarActions (deriving from graph atoms)
|
|
15
|
+
* or merge the Drawer companion display into the NavBar component.
|
|
16
|
+
*/
|
|
17
|
+
export const useCompanions = (nodeId?: string) => {
|
|
18
|
+
const { graph } = useAppGraph();
|
|
19
|
+
const nodes = useConnections(graph, nodeId);
|
|
20
|
+
const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
|
|
21
|
+
return useMemo(() => companions.toSorted((a, b) => byPosition(a.properties, b.properties)), [companions]);
|
|
22
|
+
};
|