@dxos/plugin-testing 0.0.0 → 0.8.4-main.52d7546f51
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-YHPXIILW.mjs +21 -0
- package/dist/lib/browser/chunk-YHPXIILW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +204 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/operation-resolver-FLU4ZARD.mjs +112 -0
- package/dist/lib/browser/operation-resolver-FLU4ZARD.mjs.map +7 -0
- package/dist/lib/browser/state-MIKI67FF.mjs +43 -0
- package/dist/lib/browser/state-MIKI67FF.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-OWK6XE6C.mjs +23 -0
- package/dist/lib/node-esm/chunk-OWK6XE6C.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +205 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/operation-resolver-NWF6KBHP.mjs +113 -0
- package/dist/lib/node-esm/operation-resolver-NWF6KBHP.mjs.map +7 -0
- package/dist/lib/node-esm/state-JQVVUKO2.mjs +44 -0
- package/dist/lib/node-esm/state-JQVVUKO2.mjs.map +7 -0
- package/dist/types/src/StorybookPlugin.d.ts +7 -0
- package/dist/types/src/StorybookPlugin.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +3 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +14 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +18 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/components/Layout.d.ts +6 -0
- package/dist/types/src/components/Layout.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +2 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/core.d.ts +14 -0
- package/dist/types/src/core.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +4 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +25 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +23 -16
- package/src/StorybookPlugin.ts +15 -14
- package/src/capabilities/operation-resolver/operation-resolver.ts +57 -40
- package/src/capabilities/state/state.tsx +20 -32
- package/src/components/Layout.tsx +109 -67
- package/src/core.ts +5 -11
- package/src/types/capabilities.ts +7 -2
package/package.json
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-testing",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.4-main.52d7546f51",
|
|
4
4
|
"description": "Plugin testing utils",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/dxos/dxos"
|
|
10
|
+
},
|
|
7
11
|
"license": "MIT",
|
|
8
12
|
"author": "DXOS.org",
|
|
9
13
|
"sideEffects": true,
|
|
@@ -21,32 +25,35 @@
|
|
|
21
25
|
"src"
|
|
22
26
|
],
|
|
23
27
|
"dependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@dxos/
|
|
27
|
-
"@dxos/
|
|
28
|
-
"@dxos/
|
|
29
|
-
"@dxos/plugin-
|
|
30
|
-
"@dxos/
|
|
31
|
-
"@dxos/plugin-
|
|
32
|
-
"@dxos/plugin-graph": "0.8.
|
|
28
|
+
"@effect-atom/atom": "^0.5.1",
|
|
29
|
+
"@effect-atom/atom-react": "^0.5.0",
|
|
30
|
+
"@dxos/app-framework": "0.8.4-main.52d7546f51",
|
|
31
|
+
"@dxos/operation": "0.8.4-main.52d7546f51",
|
|
32
|
+
"@dxos/app-toolkit": "0.8.4-main.52d7546f51",
|
|
33
|
+
"@dxos/plugin-attention": "0.8.4-main.52d7546f51",
|
|
34
|
+
"@dxos/plugin-client": "0.8.4-main.52d7546f51",
|
|
35
|
+
"@dxos/plugin-settings": "0.8.4-main.52d7546f51",
|
|
36
|
+
"@dxos/plugin-graph": "0.8.4-main.52d7546f51",
|
|
37
|
+
"@dxos/plugin-theme": "0.8.4-main.52d7546f51",
|
|
38
|
+
"@dxos/util": "0.8.4-main.52d7546f51",
|
|
39
|
+
"@dxos/react-ui-mosaic": "0.8.4-main.52d7546f51"
|
|
33
40
|
},
|
|
34
41
|
"devDependencies": {
|
|
35
42
|
"@types/react": "~19.2.7",
|
|
36
43
|
"@types/react-dom": "~19.2.3",
|
|
37
|
-
"effect": "3.19.
|
|
44
|
+
"effect": "3.19.16",
|
|
38
45
|
"react": "~19.2.3",
|
|
39
46
|
"react-dom": "~19.2.3",
|
|
40
47
|
"vite": "7.1.9",
|
|
41
|
-
"@dxos/react-ui": "0.8.
|
|
42
|
-
"@dxos/ui-theme": "0.
|
|
48
|
+
"@dxos/react-ui": "0.8.4-main.52d7546f51",
|
|
49
|
+
"@dxos/ui-theme": "0.8.4-main.52d7546f51"
|
|
43
50
|
},
|
|
44
51
|
"peerDependencies": {
|
|
45
|
-
"effect": "3.19.
|
|
52
|
+
"effect": "3.19.16",
|
|
46
53
|
"react": "~19.2.3",
|
|
47
54
|
"react-dom": "~19.2.3",
|
|
48
|
-
"@dxos/react-ui": "0.8.
|
|
49
|
-
"@dxos/ui-theme": "0.
|
|
55
|
+
"@dxos/react-ui": "0.8.4-main.52d7546f51",
|
|
56
|
+
"@dxos/ui-theme": "0.8.4-main.52d7546f51"
|
|
50
57
|
},
|
|
51
58
|
"publishConfig": {
|
|
52
59
|
"access": "public"
|
package/src/StorybookPlugin.ts
CHANGED
|
@@ -4,35 +4,36 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { ActivationEvents, Capabilities, Capability, Plugin } from '@dxos/app-framework';
|
|
8
|
+
import { AppActivationEvents, AppPlugin } from '@dxos/app-toolkit';
|
|
8
9
|
|
|
9
10
|
import { OperationResolver, State } from './capabilities';
|
|
10
11
|
import { Layout } from './components';
|
|
11
12
|
import { meta } from './meta';
|
|
12
|
-
import { type
|
|
13
|
+
import { type LayoutStateProps } from './types';
|
|
13
14
|
|
|
14
15
|
export type StorybookPluginOptions = {
|
|
15
|
-
initialState?: Partial<
|
|
16
|
+
initialState?: Partial<LayoutStateProps>;
|
|
16
17
|
};
|
|
17
18
|
|
|
18
19
|
export const StorybookPlugin = Plugin.define<StorybookPluginOptions>(meta).pipe(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
activate: () => State({ initialState }),
|
|
24
|
-
})),
|
|
25
|
-
Common.Plugin.addReactContextModule({
|
|
20
|
+
AppPlugin.addOperationResolverModule({
|
|
21
|
+
activate: OperationResolver,
|
|
22
|
+
}),
|
|
23
|
+
AppPlugin.addReactContextModule({
|
|
26
24
|
activate: () =>
|
|
27
25
|
Effect.succeed(
|
|
28
|
-
Capability.contributes(
|
|
26
|
+
Capability.contributes(Capabilities.ReactContext, {
|
|
29
27
|
id: 'storybook-layout',
|
|
30
28
|
context: Layout,
|
|
31
29
|
}),
|
|
32
30
|
),
|
|
33
31
|
}),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
Plugin.addModule(({ initialState }) => ({
|
|
33
|
+
id: Capability.getModuleTag(State),
|
|
34
|
+
activatesOn: ActivationEvents.Startup,
|
|
35
|
+
activatesAfter: [AppActivationEvents.LayoutReady],
|
|
36
|
+
activate: () => State({ initialState }),
|
|
37
|
+
})),
|
|
37
38
|
Plugin.make,
|
|
38
39
|
);
|
|
@@ -4,36 +4,49 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Effect from 'effect/Effect';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { Capabilities, Capability } from '@dxos/app-framework';
|
|
8
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
8
9
|
import { OperationResolver } from '@dxos/operation';
|
|
9
10
|
|
|
10
|
-
import { LayoutState } from '../../types';
|
|
11
|
+
import { LayoutState, type LayoutStateProps } from '../../types';
|
|
11
12
|
|
|
12
13
|
export default Capability.makeModule(
|
|
13
14
|
Effect.fnUntraced(function* () {
|
|
14
|
-
|
|
15
|
+
const registry = yield* Capability.get(Capabilities.AtomRegistry);
|
|
16
|
+
const stateAtom = yield* Capability.get(LayoutState);
|
|
17
|
+
|
|
18
|
+
const updateState = (fn: (state: LayoutStateProps) => Partial<LayoutStateProps>) => {
|
|
19
|
+
const current = registry.get(stateAtom);
|
|
20
|
+
registry.set(stateAtom, { ...current, ...fn(current) });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return Capability.contributes(Capabilities.OperationResolver, [
|
|
15
24
|
OperationResolver.make({
|
|
16
|
-
operation:
|
|
25
|
+
operation: LayoutOperation.UpdateSidebar,
|
|
17
26
|
handler: Effect.fnUntraced(function* ({ state }) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
updateState((layout) => {
|
|
28
|
+
const next = state ?? layout.sidebarState;
|
|
29
|
+
if (next !== layout.sidebarState) {
|
|
30
|
+
return { sidebarState: next };
|
|
31
|
+
}
|
|
32
|
+
return {};
|
|
33
|
+
});
|
|
23
34
|
}),
|
|
24
35
|
}),
|
|
25
36
|
OperationResolver.make({
|
|
26
|
-
operation:
|
|
37
|
+
operation: LayoutOperation.UpdateComplementary,
|
|
27
38
|
handler: Effect.fnUntraced(function* ({ state }) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
39
|
+
updateState((layout) => {
|
|
40
|
+
const next = state ?? layout.complementarySidebarState;
|
|
41
|
+
if (next !== layout.complementarySidebarState) {
|
|
42
|
+
return { complementarySidebarState: next };
|
|
43
|
+
}
|
|
44
|
+
return {};
|
|
45
|
+
});
|
|
33
46
|
}),
|
|
34
47
|
}),
|
|
35
48
|
OperationResolver.make({
|
|
36
|
-
operation:
|
|
49
|
+
operation: LayoutOperation.UpdateDialog,
|
|
37
50
|
handler: Effect.fnUntraced(function* ({
|
|
38
51
|
subject,
|
|
39
52
|
state,
|
|
@@ -43,38 +56,42 @@ export default Capability.makeModule(
|
|
|
43
56
|
overlayStyle,
|
|
44
57
|
props,
|
|
45
58
|
}) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
updateState(() => ({
|
|
60
|
+
dialogOpen: state ?? Boolean(subject),
|
|
61
|
+
dialogType: type ?? 'default',
|
|
62
|
+
dialogBlockAlign: blockAlign ?? 'center',
|
|
63
|
+
dialogOverlayClasses: overlayClasses,
|
|
64
|
+
dialogOverlayStyle: overlayStyle,
|
|
65
|
+
dialogContent: subject ? { component: subject, props } : null,
|
|
66
|
+
}));
|
|
53
67
|
}),
|
|
54
68
|
}),
|
|
55
69
|
OperationResolver.make({
|
|
56
|
-
operation:
|
|
70
|
+
operation: LayoutOperation.UpdatePopover,
|
|
57
71
|
handler: Effect.fnUntraced(function* (input) {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
const { subject, state, side, kind, props } = input;
|
|
73
|
+
updateState(() => {
|
|
74
|
+
const base: Partial<LayoutStateProps> = {
|
|
75
|
+
popoverKind: kind ?? 'base',
|
|
76
|
+
popoverTitle: kind === 'card' ? input.title : undefined,
|
|
77
|
+
popoverContent:
|
|
78
|
+
typeof subject === 'string' ? { component: subject, props } : subject ? { subject } : undefined,
|
|
79
|
+
popoverOpen: state ?? Boolean(subject),
|
|
80
|
+
popoverSide: side,
|
|
81
|
+
};
|
|
82
|
+
if ('variant' in input && input.variant === 'virtual') {
|
|
83
|
+
return { ...base, popoverVariant: 'virtual', popoverAnchor: input.anchor };
|
|
84
|
+
} else if ('anchorId' in input) {
|
|
85
|
+
return { ...base, popoverVariant: 'react', popoverAnchorId: input.anchorId };
|
|
86
|
+
}
|
|
87
|
+
return base;
|
|
88
|
+
});
|
|
71
89
|
}),
|
|
72
90
|
}),
|
|
73
91
|
OperationResolver.make({
|
|
74
|
-
operation:
|
|
92
|
+
operation: LayoutOperation.SwitchWorkspace,
|
|
75
93
|
handler: Effect.fnUntraced(function* ({ subject }) {
|
|
76
|
-
|
|
77
|
-
layout.workspace = subject;
|
|
94
|
+
updateState(() => ({ workspace: subject }));
|
|
78
95
|
}),
|
|
79
96
|
}),
|
|
80
97
|
]);
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
5
6
|
import * as Effect from 'effect/Effect';
|
|
6
7
|
|
|
7
|
-
import { Capability
|
|
8
|
-
import {
|
|
8
|
+
import { Capability } from '@dxos/app-framework';
|
|
9
|
+
import { AppCapabilities } from '@dxos/app-toolkit';
|
|
9
10
|
|
|
10
|
-
import { LayoutState } from '../../types';
|
|
11
|
+
import { LayoutState, type LayoutStateProps } from '../../types';
|
|
11
12
|
|
|
12
|
-
const defaultState:
|
|
13
|
+
const defaultState: LayoutStateProps = {
|
|
13
14
|
sidebarState: 'closed',
|
|
14
15
|
complementarySidebarState: 'closed',
|
|
15
16
|
dialogOpen: false,
|
|
@@ -17,37 +18,24 @@ const defaultState: LayoutState = {
|
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
export default Capability.makeModule(
|
|
20
|
-
Effect.fnUntraced(function* (props?: { initialState?: Partial<
|
|
21
|
+
Effect.fnUntraced(function* (props?: { initialState?: Partial<LayoutStateProps> }) {
|
|
21
22
|
const { initialState } = props ?? {};
|
|
22
|
-
const
|
|
23
|
+
const stateAtom = Atom.make<LayoutStateProps>({ ...defaultState, ...initialState });
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
-
get
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
},
|
|
37
|
-
get workspace() {
|
|
38
|
-
return state.workspace;
|
|
39
|
-
},
|
|
40
|
-
get active() {
|
|
41
|
-
return [];
|
|
42
|
-
},
|
|
43
|
-
get inactive() {
|
|
44
|
-
return [];
|
|
45
|
-
},
|
|
46
|
-
get scrollIntoView() {
|
|
47
|
-
return undefined;
|
|
48
|
-
},
|
|
25
|
+
const layoutAtom = Atom.make((get): AppCapabilities.Layout => {
|
|
26
|
+
const state = get(stateAtom);
|
|
27
|
+
return {
|
|
28
|
+
mode: 'storybook',
|
|
29
|
+
dialogOpen: state.dialogOpen,
|
|
30
|
+
sidebarOpen: state.sidebarState === 'expanded',
|
|
31
|
+
complementarySidebarOpen: state.complementarySidebarState === 'expanded',
|
|
32
|
+
workspace: state.workspace,
|
|
33
|
+
active: [],
|
|
34
|
+
inactive: [],
|
|
35
|
+
scrollIntoView: undefined,
|
|
36
|
+
};
|
|
49
37
|
});
|
|
50
38
|
|
|
51
|
-
return [Capability.contributes(LayoutState,
|
|
39
|
+
return [Capability.contributes(LayoutState, stateAtom), Capability.contributes(AppCapabilities.Layout, layoutAtom)];
|
|
52
40
|
}),
|
|
53
41
|
);
|
|
@@ -2,32 +2,46 @@
|
|
|
2
2
|
// Copyright 2023 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import
|
|
5
|
+
import { RegistryContext, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { type PropsWithChildren, useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
6
7
|
|
|
7
|
-
import { Surface, useCapability } from '@dxos/app-framework/
|
|
8
|
+
import { Surface, useCapability } from '@dxos/app-framework/ui';
|
|
8
9
|
import {
|
|
9
10
|
AlertDialog,
|
|
10
11
|
Dialog,
|
|
11
12
|
Main,
|
|
12
13
|
Popover,
|
|
13
14
|
type PopoverContentInteractOutsideEvent,
|
|
15
|
+
toLocalizedString,
|
|
14
16
|
useTranslation,
|
|
15
17
|
} from '@dxos/react-ui';
|
|
18
|
+
import { Card, Mosaic } from '@dxos/react-ui-mosaic';
|
|
16
19
|
import { descriptionMessage, mx } from '@dxos/ui-theme';
|
|
17
20
|
|
|
18
21
|
import { meta } from '../meta';
|
|
19
|
-
import { LayoutState } from '../types';
|
|
22
|
+
import { LayoutState, type LayoutStateProps } from '../types';
|
|
20
23
|
|
|
21
24
|
const debounce_delay = 100;
|
|
22
25
|
|
|
23
26
|
// TODO(wittjosiah): Support dialogs, tooltips, maybe toast.
|
|
24
27
|
export const Layout = ({ children }: PropsWithChildren<{}>) => {
|
|
28
|
+
const { t } = useTranslation(meta.id);
|
|
25
29
|
const trigger = useRef<HTMLButtonElement | null>(null);
|
|
26
|
-
const
|
|
30
|
+
const registry = useContext(RegistryContext);
|
|
31
|
+
const stateAtom = useCapability(LayoutState);
|
|
32
|
+
const layout = useAtomValue(stateAtom);
|
|
27
33
|
const [iter, setIter] = useState(0);
|
|
28
34
|
const [open, setOpen] = useState(false);
|
|
29
35
|
const debounceRef = useRef<NodeJS.Timeout | null>(null);
|
|
30
36
|
|
|
37
|
+
const updateState = useCallback(
|
|
38
|
+
(updates: Partial<LayoutStateProps>) => {
|
|
39
|
+
const current = registry.get(stateAtom);
|
|
40
|
+
registry.set(stateAtom, { ...current, ...updates });
|
|
41
|
+
},
|
|
42
|
+
[registry, stateAtom],
|
|
43
|
+
);
|
|
44
|
+
|
|
31
45
|
useEffect(() => {
|
|
32
46
|
setOpen(false);
|
|
33
47
|
if (debounceRef.current) {
|
|
@@ -41,77 +55,105 @@ export const Layout = ({ children }: PropsWithChildren<{}>) => {
|
|
|
41
55
|
}
|
|
42
56
|
}, [layout.popoverAnchor, layout.popoverContent, layout.popoverOpen]);
|
|
43
57
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
const handleClose = useCallback(() => {
|
|
59
|
+
setOpen(false);
|
|
60
|
+
updateState({
|
|
61
|
+
popoverOpen: false,
|
|
62
|
+
popoverAnchor: undefined,
|
|
63
|
+
popoverAnchorId: undefined,
|
|
64
|
+
popoverSide: undefined,
|
|
65
|
+
});
|
|
66
|
+
}, [updateState]);
|
|
67
|
+
|
|
68
|
+
const handleInteractOutside = useCallback(
|
|
69
|
+
(event: KeyboardEvent | PopoverContentInteractOutsideEvent) => {
|
|
70
|
+
if (
|
|
71
|
+
// TODO(thure): CodeMirror should not focus itself when it updates.
|
|
72
|
+
event.type === 'dismissableLayer.focusOutside' &&
|
|
73
|
+
(event.currentTarget as HTMLElement | undefined)?.classList.contains('cm-content')
|
|
74
|
+
) {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
} else {
|
|
77
|
+
handleClose();
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[handleClose],
|
|
81
|
+
);
|
|
59
82
|
|
|
60
83
|
const DialogRoot = layout.dialogType === 'alert' ? AlertDialog.Root : Dialog.Root;
|
|
61
84
|
const DialogOverlay = layout.dialogType === 'alert' ? AlertDialog.Overlay : Dialog.Overlay;
|
|
62
85
|
|
|
63
86
|
return (
|
|
64
87
|
<div role='none' className='fixed inset-0 flex overflow-hidden'>
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
<DialogRoot
|
|
76
|
-
modal={layout.dialogBlockAlign !== 'end'}
|
|
77
|
-
open={layout.dialogOpen}
|
|
78
|
-
onOpenChange={(nextOpen) => (layout.dialogOpen = nextOpen)}
|
|
79
|
-
>
|
|
80
|
-
{layout.dialogBlockAlign === 'end' ? (
|
|
81
|
-
<Surface
|
|
82
|
-
role='dialog'
|
|
83
|
-
data={layout.dialogContent}
|
|
84
|
-
limit={1}
|
|
85
|
-
fallback={ContentError}
|
|
86
|
-
placeholder={<div />}
|
|
87
|
-
/>
|
|
88
|
-
) : (
|
|
89
|
-
<DialogOverlay
|
|
90
|
-
blockAlign={layout.dialogBlockAlign}
|
|
91
|
-
classNames={layout.dialogOverlayClasses}
|
|
92
|
-
style={layout.dialogOverlayStyle}
|
|
93
|
-
>
|
|
94
|
-
<Surface role='dialog' data={layout.dialogContent} limit={1} fallback={ContentError} />
|
|
95
|
-
</DialogOverlay>
|
|
96
|
-
)}
|
|
97
|
-
</DialogRoot>
|
|
88
|
+
<Mosaic.Root>
|
|
89
|
+
<Popover.Root open={open}>
|
|
90
|
+
<Main.Root
|
|
91
|
+
navigationSidebarState={layout.sidebarState}
|
|
92
|
+
complementarySidebarState={layout.complementarySidebarState}
|
|
93
|
+
onNavigationSidebarStateChange={(next) => updateState({ sidebarState: next })}
|
|
94
|
+
onComplementarySidebarStateChange={(next) => updateState({ complementarySidebarState: next })}
|
|
95
|
+
>
|
|
96
|
+
{children}
|
|
97
|
+
</Main.Root>
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
onInteractOutside={handleInteractOutside}
|
|
104
|
-
onEscapeKeyDown={handleInteractOutside}
|
|
105
|
-
sticky='always'
|
|
106
|
-
hideWhenDetached
|
|
99
|
+
<DialogRoot
|
|
100
|
+
modal={layout.dialogBlockAlign !== 'end'}
|
|
101
|
+
open={layout.dialogOpen}
|
|
102
|
+
onOpenChange={(nextOpen) => updateState({ dialogOpen: nextOpen })}
|
|
107
103
|
>
|
|
108
|
-
|
|
109
|
-
<Surface
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
{layout.dialogBlockAlign === 'end' ? (
|
|
105
|
+
<Surface.Surface
|
|
106
|
+
role='dialog'
|
|
107
|
+
data={layout.dialogContent}
|
|
108
|
+
limit={1}
|
|
109
|
+
fallback={ContentError}
|
|
110
|
+
placeholder={<div />}
|
|
111
|
+
/>
|
|
112
|
+
) : (
|
|
113
|
+
<DialogOverlay
|
|
114
|
+
blockAlign={layout.dialogBlockAlign}
|
|
115
|
+
classNames={layout.dialogOverlayClasses}
|
|
116
|
+
style={layout.dialogOverlayStyle}
|
|
117
|
+
>
|
|
118
|
+
<Surface.Surface role='dialog' data={layout.dialogContent} limit={1} fallback={ContentError} />
|
|
119
|
+
</DialogOverlay>
|
|
120
|
+
)}
|
|
121
|
+
</DialogRoot>
|
|
122
|
+
|
|
123
|
+
<Popover.VirtualTrigger key={iter} virtualRef={trigger} />
|
|
124
|
+
<Popover.Portal>
|
|
125
|
+
<Popover.Content
|
|
126
|
+
side={layout.popoverSide}
|
|
127
|
+
onInteractOutside={handleInteractOutside}
|
|
128
|
+
onEscapeKeyDown={handleInteractOutside}
|
|
129
|
+
sticky='always'
|
|
130
|
+
hideWhenDetached
|
|
131
|
+
>
|
|
132
|
+
<Popover.Viewport>
|
|
133
|
+
{layout.popoverKind === 'card' && (
|
|
134
|
+
<Card.Root>
|
|
135
|
+
<Card.Toolbar>
|
|
136
|
+
{/* TODO(wittjosiah): Cleaner way to handle no drag handle in toolbar? */}
|
|
137
|
+
<span />
|
|
138
|
+
{layout.popoverTitle ? (
|
|
139
|
+
<Card.Title>{toLocalizedString(layout.popoverTitle, t)}</Card.Title>
|
|
140
|
+
) : (
|
|
141
|
+
<span />
|
|
142
|
+
)}
|
|
143
|
+
<Card.Close onClick={handleClose} />
|
|
144
|
+
</Card.Toolbar>
|
|
145
|
+
<Surface.Surface role='card--content' data={layout.popoverContent} limit={1} />
|
|
146
|
+
</Card.Root>
|
|
147
|
+
)}
|
|
148
|
+
{layout.popoverKind === 'base' && (
|
|
149
|
+
<Surface.Surface role='popover' data={layout.popoverContent} limit={1} />
|
|
150
|
+
)}
|
|
151
|
+
</Popover.Viewport>
|
|
152
|
+
<Popover.Arrow />
|
|
153
|
+
</Popover.Content>
|
|
154
|
+
</Popover.Portal>
|
|
155
|
+
</Popover.Root>
|
|
156
|
+
</Mosaic.Root>
|
|
115
157
|
</div>
|
|
116
158
|
);
|
|
117
159
|
};
|
package/src/core.ts
CHANGED
|
@@ -2,23 +2,17 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import { OperationPlugin, type Plugin, RuntimePlugin
|
|
5
|
+
import { OperationPlugin, type Plugin, RuntimePlugin } from '@dxos/app-framework';
|
|
6
6
|
import { AttentionPlugin } from '@dxos/plugin-attention';
|
|
7
7
|
import { ClientPlugin } from '@dxos/plugin-client';
|
|
8
8
|
import { GraphPlugin } from '@dxos/plugin-graph';
|
|
9
|
+
import { SettingsPlugin } from '@dxos/plugin-settings';
|
|
9
10
|
import { ThemePlugin } from '@dxos/plugin-theme';
|
|
10
11
|
import { defaultTx } from '@dxos/ui-theme';
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
ClientPlugin,
|
|
16
|
-
GraphPlugin,
|
|
17
|
-
OperationPlugin,
|
|
18
|
-
RuntimePlugin,
|
|
19
|
-
SettingsPlugin,
|
|
20
|
-
ThemePlugin,
|
|
21
|
-
};
|
|
13
|
+
// TODO(burdon): Remove this.
|
|
14
|
+
// Re-export common framework plugins.
|
|
15
|
+
export { AttentionPlugin, ClientPlugin, GraphPlugin, OperationPlugin, RuntimePlugin, SettingsPlugin, ThemePlugin };
|
|
22
16
|
|
|
23
17
|
/**
|
|
24
18
|
* Core plugins for testing/storybook environments.
|
|
@@ -2,11 +2,14 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
+
import { type Atom } from '@effect-atom/atom-react';
|
|
6
|
+
|
|
5
7
|
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { type Label } from '@dxos/react-ui';
|
|
6
9
|
|
|
7
10
|
import { meta } from '../meta';
|
|
8
11
|
|
|
9
|
-
export type
|
|
12
|
+
export type LayoutStateProps = {
|
|
10
13
|
sidebarState?: 'expanded' | 'collapsed' | 'closed';
|
|
11
14
|
complementarySidebarState?: 'expanded' | 'collapsed' | 'closed';
|
|
12
15
|
|
|
@@ -23,9 +26,11 @@ export type LayoutState = {
|
|
|
23
26
|
popoverVariant?: 'virtual' | 'react';
|
|
24
27
|
popoverAnchor?: HTMLButtonElement;
|
|
25
28
|
popoverAnchorId?: string;
|
|
29
|
+
popoverKind?: 'base' | 'card';
|
|
30
|
+
popoverTitle?: Label;
|
|
26
31
|
popoverContent?: any;
|
|
27
32
|
|
|
28
33
|
workspace: string;
|
|
29
34
|
};
|
|
30
35
|
|
|
31
|
-
export const LayoutState = Capability.make<
|
|
36
|
+
export const LayoutState = Capability.make<Atom.Writable<LayoutStateProps>>(`${meta.id}/state`);
|