@dxos/plugin-simple-layout 0.8.4-main.9735255 → 0.8.4-main.abd8ff62ef
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/SimpleLayoutPlugin-Q5BZE6KD.mjs +50 -0
- package/dist/lib/browser/SimpleLayoutPlugin-Q5BZE6KD.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +18 -96
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/translations.mjs +34 -0
- package/dist/lib/browser/translations.mjs.map +7 -0
- package/dist/lib/node-esm/SimpleLayoutPlugin-OD45TNPO.mjs +52 -0
- package/dist/lib/node-esm/SimpleLayoutPlugin-OD45TNPO.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +18 -95
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/translations.mjs +36 -0
- package/dist/lib/node-esm/translations.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts +2 -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 +27 -22
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/types/src/components/Home/Home.d.ts.map +1 -1
- package/dist/types/src/components/Loading/Loading.d.ts +3 -0
- package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
- package/dist/types/src/components/{ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
- package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
- package/dist/types/src/components/Loading/index.d.ts +2 -0
- package/dist/types/src/components/Loading/index.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +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 +24 -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 +4 -7
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts +4 -7
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +13 -8
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +32 -26
- 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/index.d.ts +3 -1
- package/dist/types/src/index.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 -20
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +17 -8
- 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 +54 -30
- package/src/SimpleLayoutPlugin.ts +26 -14
- 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 +50 -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 +9 -8
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +17 -6
- package/src/components/Home/Home.tsx +51 -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 +124 -0
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +13 -9
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +94 -0
- package/src/components/SimpleLayout/Drawer.tsx +44 -91
- package/src/components/SimpleLayout/Main.tsx +40 -34
- package/src/components/SimpleLayout/NavBar.stories.tsx +132 -24
- package/src/components/SimpleLayout/NavBar.tsx +18 -51
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +46 -60
- package/src/components/SimpleLayout/SimpleLayout.tsx +41 -23
- 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 +95 -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/index.ts +7 -1
- package/src/meta.ts +1 -1
- package/src/operations/close.ts +34 -0
- package/src/operations/index.ts +16 -0
- package/src/operations/open.ts +63 -0
- package/src/operations/revert-workspace.ts +22 -0
- package/src/operations/set-layout-mode.ts +12 -0
- package/src/operations/set.ts +23 -0
- package/src/operations/state-access.ts +19 -0
- package/src/operations/switch-workspace.ts +26 -0
- package/src/operations/update-complementary.ts +35 -0
- package/src/operations/update-dialog.ts +28 -0
- package/src/operations/update-popover.ts +35 -0
- package/src/operations/update-sidebar.ts +12 -0
- package/src/translations.ts +21 -19
- package/src/types/capabilities.ts +14 -10
- 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,144 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { Atom } from '@effect-atom/atom-react';
|
|
6
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
import { type Mock, expect, fn, screen, userEvent, within } from 'storybook/test';
|
|
9
|
+
|
|
10
|
+
import { type ActionGraphProps, createMenuAction } from '@dxos/react-ui-menu';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
|
+
import { withRegistry } from '@dxos/storybook-utils';
|
|
13
|
+
|
|
14
|
+
import { translations } from '#translations';
|
|
15
|
+
|
|
16
|
+
import { MobileLayout } from '../MobileLayout';
|
|
17
|
+
import { AppBar, type AppBarProps } from './AppBar';
|
|
18
|
+
|
|
19
|
+
const buildEmptyActions = (): ActionGraphProps => ({ nodes: [], edges: [] });
|
|
20
|
+
|
|
21
|
+
const buildDefaultActions = (): ActionGraphProps => {
|
|
22
|
+
const result: ActionGraphProps = { nodes: [], edges: [] };
|
|
23
|
+
const actions = [
|
|
24
|
+
createMenuAction('action-edit.menu', () => console.log('Edit'), {
|
|
25
|
+
icon: 'ph--pencil--regular',
|
|
26
|
+
label: 'Edit',
|
|
27
|
+
}),
|
|
28
|
+
createMenuAction('action-share.menu', () => console.log('Share'), {
|
|
29
|
+
icon: 'ph--share--regular',
|
|
30
|
+
label: 'Share',
|
|
31
|
+
}),
|
|
32
|
+
createMenuAction('action-delete.menu', () => console.log('Delete'), {
|
|
33
|
+
icon: 'ph--trash--regular',
|
|
34
|
+
label: 'Delete',
|
|
35
|
+
}),
|
|
36
|
+
];
|
|
37
|
+
result.nodes.push(...actions);
|
|
38
|
+
result.edges.push(...actions.map((a) => ({ source: 'root', target: a.id, relation: 'child' })));
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type DefaultStoryProps = Omit<AppBarProps, 'actions'> & {
|
|
43
|
+
actions: ActionGraphProps;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const DefaultStory = ({ actions: actionsProp, ...props }: DefaultStoryProps) => {
|
|
47
|
+
const actions = useMemo(() => Atom.make(actionsProp).pipe(Atom.keepAlive), [actionsProp]);
|
|
48
|
+
return (
|
|
49
|
+
<MobileLayout.Root>
|
|
50
|
+
<AppBar {...props} actions={actions} />
|
|
51
|
+
</MobileLayout.Root>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const meta = {
|
|
56
|
+
title: 'plugins/plugin-simple-layout/components/AppBar',
|
|
57
|
+
render: DefaultStory,
|
|
58
|
+
decorators: [
|
|
59
|
+
withTheme(),
|
|
60
|
+
withLayout({
|
|
61
|
+
layout: 'column',
|
|
62
|
+
classNames: 'relative',
|
|
63
|
+
}),
|
|
64
|
+
withRegistry,
|
|
65
|
+
],
|
|
66
|
+
parameters: {
|
|
67
|
+
layout: 'fullscreen',
|
|
68
|
+
translations,
|
|
69
|
+
},
|
|
70
|
+
} satisfies Meta<typeof DefaultStory>;
|
|
71
|
+
|
|
72
|
+
export default meta;
|
|
73
|
+
|
|
74
|
+
type Story = StoryObj<DefaultStoryProps>;
|
|
75
|
+
|
|
76
|
+
export const Default: Story = {
|
|
77
|
+
tags: ['test'],
|
|
78
|
+
args: {
|
|
79
|
+
actions: buildDefaultActions(),
|
|
80
|
+
title: 'Document Title',
|
|
81
|
+
showBackButton: true,
|
|
82
|
+
onAction: fn(),
|
|
83
|
+
onBack: fn(),
|
|
84
|
+
},
|
|
85
|
+
play: async ({ args, canvasElement }) => {
|
|
86
|
+
const canvas = within(canvasElement);
|
|
87
|
+
|
|
88
|
+
// Verify the banner renders with the correct title.
|
|
89
|
+
await expect(canvas.getByRole('banner')).toBeInTheDocument();
|
|
90
|
+
await expect(canvas.getByText('Document Title')).toBeInTheDocument();
|
|
91
|
+
|
|
92
|
+
// Test back button click.
|
|
93
|
+
const backButton = canvas.getByRole('button', { name: /back/i });
|
|
94
|
+
await expect(backButton).toBeInTheDocument();
|
|
95
|
+
await userEvent.click(backButton);
|
|
96
|
+
await expect(args.onBack).toHaveBeenCalledTimes(1);
|
|
97
|
+
|
|
98
|
+
// Test actions menu opens and action fires.
|
|
99
|
+
const menuTrigger = canvas.getByRole('button', { name: /actions/i });
|
|
100
|
+
await expect(menuTrigger).toBeInTheDocument();
|
|
101
|
+
await userEvent.click(menuTrigger);
|
|
102
|
+
|
|
103
|
+
// Wait for menu to open and click an action (menu items render in a portal).
|
|
104
|
+
const editAction = await screen.findByRole('menuitem', { name: /edit/i });
|
|
105
|
+
await userEvent.click(editAction);
|
|
106
|
+
await expect(args.onAction).toHaveBeenCalledTimes(1);
|
|
107
|
+
await expect((args.onAction as Mock).mock.calls[0][0]).toHaveProperty('id', 'action-edit.menu');
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const NoBackButton: Story = {
|
|
112
|
+
args: {
|
|
113
|
+
actions: buildDefaultActions(),
|
|
114
|
+
title: 'Home',
|
|
115
|
+
showBackButton: false,
|
|
116
|
+
onAction: (action) => console.log('Action:', action.id),
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const LongTitle: Story = {
|
|
121
|
+
args: {
|
|
122
|
+
actions: buildDefaultActions(),
|
|
123
|
+
title: 'This is a very long document title that should be truncated when it exceeds the available space',
|
|
124
|
+
showBackButton: true,
|
|
125
|
+
onBack: () => console.log('Back clicked'),
|
|
126
|
+
onAction: (action) => console.log('Action:', action.id),
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export const NoActions: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
actions: buildEmptyActions(),
|
|
133
|
+
title: 'Empty Document',
|
|
134
|
+
showBackButton: true,
|
|
135
|
+
onBack: () => console.log('Back clicked'),
|
|
136
|
+
onAction: (action) => console.log('Action:', action.id),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const Empty: Story = {
|
|
141
|
+
args: {
|
|
142
|
+
actions: buildEmptyActions(),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
6
|
+
import React, { Fragment } from 'react';
|
|
7
|
+
|
|
8
|
+
import { IconButton, Popover, Toolbar, useTranslation } from '@dxos/react-ui';
|
|
9
|
+
import { type ActionExecutor, type ActionGraphProps, Menu, useMenuActions } from '@dxos/react-ui-menu';
|
|
10
|
+
import { composable, composableProps, osTranslations } from '@dxos/ui-theme';
|
|
11
|
+
|
|
12
|
+
import { meta } from '#meta';
|
|
13
|
+
|
|
14
|
+
import { useMobileLayout } from '../MobileLayout';
|
|
15
|
+
|
|
16
|
+
const APP_BAR_NAME = 'SimpleLayout.AppBar';
|
|
17
|
+
|
|
18
|
+
export type AppBarProps = {
|
|
19
|
+
/** Title/label to display in the banner. */
|
|
20
|
+
title?: string;
|
|
21
|
+
/** Action graph atom for the dropdown menu. */
|
|
22
|
+
actions: Atom.Atom<ActionGraphProps>;
|
|
23
|
+
/** Whether to show the back button. */
|
|
24
|
+
showBackButton?: boolean;
|
|
25
|
+
/** Popover anchor ID for the dropdown trigger. */
|
|
26
|
+
popoverAnchorId?: string;
|
|
27
|
+
/** Action executor callback. */
|
|
28
|
+
onAction?: ActionExecutor;
|
|
29
|
+
/** Callback when back button is clicked. */
|
|
30
|
+
onBack?: () => void;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* AppBar component that renders a title, optional back button, and actions dropdown.
|
|
35
|
+
*/
|
|
36
|
+
export const AppBar = composable<HTMLDivElement, AppBarProps>(
|
|
37
|
+
({ classNames, title, actions, showBackButton, popoverAnchorId, onAction, onBack, ...props }, forwardedRef) => {
|
|
38
|
+
const { t } = useTranslation(meta.id);
|
|
39
|
+
const menuActions = useMenuActions(actions);
|
|
40
|
+
const actionsValue = useAtomValue(actions);
|
|
41
|
+
const hasActions = actionsValue.nodes.length > 0;
|
|
42
|
+
const { keyboardOpen } = useMobileLayout(APP_BAR_NAME);
|
|
43
|
+
|
|
44
|
+
// Fall back to app name if no title provided.
|
|
45
|
+
const displayTitle = title ?? t('current-app.name', { ns: osTranslations });
|
|
46
|
+
|
|
47
|
+
// Wrap the menu trigger with Popover.Anchor when the popoverAnchorId is set.
|
|
48
|
+
const AnchorRoot = popoverAnchorId ? Popover.Anchor : Fragment;
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Toolbar.Root
|
|
52
|
+
{...composableProps(props, {
|
|
53
|
+
role: 'banner',
|
|
54
|
+
classNames: 'grid grid-cols-[var(--dx-rail-size)_1fr_var(--dx-rail-size)] items-center dx-density-fine',
|
|
55
|
+
})}
|
|
56
|
+
ref={forwardedRef}
|
|
57
|
+
>
|
|
58
|
+
{keyboardOpen ? (
|
|
59
|
+
<IconButton variant='ghost' icon='ph--x--regular' iconOnly label={t('done.label')} />
|
|
60
|
+
) : showBackButton ? (
|
|
61
|
+
<IconButton
|
|
62
|
+
variant='ghost'
|
|
63
|
+
icon='ph--caret-left--regular'
|
|
64
|
+
iconOnly
|
|
65
|
+
label={t('back.label')}
|
|
66
|
+
onClick={onBack}
|
|
67
|
+
/>
|
|
68
|
+
) : (
|
|
69
|
+
<div />
|
|
70
|
+
)}
|
|
71
|
+
<h1 className='text-center truncate font-thin uppercase'>{displayTitle}</h1>
|
|
72
|
+
{hasActions ? (
|
|
73
|
+
<AnchorRoot>
|
|
74
|
+
<Menu.Root {...menuActions} caller={meta.id} onAction={onAction}>
|
|
75
|
+
<Menu.Trigger asChild>
|
|
76
|
+
<IconButton
|
|
77
|
+
variant='ghost'
|
|
78
|
+
icon='ph--dots-three-vertical--regular'
|
|
79
|
+
iconOnly
|
|
80
|
+
label={t('actions-menu.label')}
|
|
81
|
+
/>
|
|
82
|
+
</Menu.Trigger>
|
|
83
|
+
<Menu.Content />
|
|
84
|
+
</Menu.Root>
|
|
85
|
+
</AnchorRoot>
|
|
86
|
+
) : (
|
|
87
|
+
<span />
|
|
88
|
+
)}
|
|
89
|
+
</Toolbar.Root>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
AppBar.displayName = APP_BAR_NAME;
|
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, {
|
|
5
|
+
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { AppSurface, useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
9
|
import { type Node, useNode } from '@dxos/plugin-graph';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { ErrorFallback, Panel } from '@dxos/react-ui';
|
|
11
|
+
import { getLinkedVariant } from '@dxos/react-ui-attention';
|
|
12
|
+
import { Menu, useMenuActions } from '@dxos/react-ui-menu';
|
|
11
13
|
|
|
12
|
-
import { useCompanions, useSimpleLayoutState } from '
|
|
13
|
-
|
|
14
|
-
import {
|
|
15
|
-
import { ContentLoading } from '../ContentLoading';
|
|
14
|
+
import { useCompanions, useDrawerActions, useSimpleLayoutState } from '#hooks';
|
|
15
|
+
|
|
16
|
+
import { Loading } from '../Loading';
|
|
16
17
|
|
|
17
18
|
const DRAWER_NAME = 'SimpleLayout.Drawer';
|
|
18
19
|
|
|
@@ -20,105 +21,60 @@ const DRAWER_NAME = 'SimpleLayout.Drawer';
|
|
|
20
21
|
* Companion drawer component.
|
|
21
22
|
*/
|
|
22
23
|
export const Drawer = () => {
|
|
23
|
-
const { t } = useTranslation(meta.id);
|
|
24
|
-
const { state, updateState } = useSimpleLayoutState();
|
|
25
24
|
const { graph } = useAppGraph();
|
|
25
|
+
const { state: layoutState } = useSimpleLayoutState();
|
|
26
26
|
|
|
27
|
-
const placeholder = useMemo(() => <
|
|
27
|
+
const placeholder = useMemo(() => <Loading />, []);
|
|
28
28
|
|
|
29
29
|
// Get all companions for the current active (primary) item.
|
|
30
|
-
const activeId =
|
|
30
|
+
const activeId = layoutState.active ?? layoutState.workspace;
|
|
31
31
|
const companions = useCompanions(activeId);
|
|
32
|
-
const { companionId, variant } = useSelectedCompanion(companions,
|
|
32
|
+
const { companionId, variant } = useSelectedCompanion(companions, layoutState.companionVariant);
|
|
33
33
|
|
|
34
34
|
// Get node for the selected companion.
|
|
35
35
|
const node = useNode(graph, companionId);
|
|
36
36
|
const parentNode = useNode(graph, activeId);
|
|
37
37
|
|
|
38
38
|
// Build Surface data for the companion content.
|
|
39
|
-
const data = useMemo(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
const data = useMemo<AppSurface.ArticleData | undefined>(() => {
|
|
40
|
+
if (!node || !companionId) {
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
attendableId: companionId,
|
|
45
|
+
subject: node.data,
|
|
46
|
+
companionTo: parentNode?.data,
|
|
47
|
+
properties: node.properties,
|
|
48
|
+
variant,
|
|
49
|
+
};
|
|
49
50
|
}, [companionId, node, parentNode, variant]);
|
|
50
51
|
|
|
51
|
-
//
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const [, companionVariant] = companion.id.split(ATTENDABLE_PATH_SEPARATOR);
|
|
55
|
-
updateState((s) => ({ ...s, companionVariant }));
|
|
56
|
-
},
|
|
57
|
-
[updateState],
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Handle expand/collapse toggle.
|
|
61
|
-
const handleToggleExpand = useCallback(() => {
|
|
62
|
-
updateState((s) => ({
|
|
63
|
-
...s,
|
|
64
|
-
drawerState: s.drawerState === 'full' ? 'expanded' : 'full',
|
|
65
|
-
}));
|
|
66
|
-
}, [updateState]);
|
|
67
|
-
|
|
68
|
-
// Handle close.
|
|
69
|
-
const handleClose = useCallback(() => {
|
|
70
|
-
updateState((s) => ({ ...s, drawerState: 'closed' }));
|
|
71
|
-
}, [updateState]);
|
|
72
|
-
|
|
73
|
-
const drawerState = state.drawerState ?? 'closed';
|
|
74
|
-
if (drawerState === 'closed') {
|
|
75
|
-
return null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const isFullyExpanded = drawerState === 'full';
|
|
52
|
+
// Get drawer actions (tabs + toolbar buttons).
|
|
53
|
+
const { actions, onAction } = useDrawerActions(DRAWER_NAME);
|
|
54
|
+
const menuActions = useMenuActions(actions);
|
|
79
55
|
|
|
80
56
|
return (
|
|
81
|
-
<
|
|
82
|
-
<Toolbar
|
|
83
|
-
{
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
variant={companionId === companion.id ? 'primary' : 'ghost'}
|
|
95
|
-
onClick={() => handleTabClick(companion)}
|
|
96
|
-
/>
|
|
97
|
-
))}
|
|
98
|
-
</div>
|
|
99
|
-
<Toolbar.Separator variant='gap' />
|
|
100
|
-
<Toolbar.IconButton
|
|
101
|
-
icon={isFullyExpanded ? 'ph--arrow-down--regular' : 'ph--arrow-up--regular'}
|
|
102
|
-
iconOnly
|
|
103
|
-
label={isFullyExpanded ? t('collapse drawer label') : t('expand drawer label')}
|
|
104
|
-
onClick={handleToggleExpand}
|
|
57
|
+
<Panel.Root>
|
|
58
|
+
<Panel.Toolbar>
|
|
59
|
+
<Menu.Root {...menuActions} alwaysActive onAction={onAction}>
|
|
60
|
+
<Menu.Toolbar />
|
|
61
|
+
</Menu.Root>
|
|
62
|
+
</Panel.Toolbar>
|
|
63
|
+
<Panel.Content>
|
|
64
|
+
<Surface.Surface
|
|
65
|
+
type={AppSurface.Article}
|
|
66
|
+
data={data}
|
|
67
|
+
limit={1}
|
|
68
|
+
fallback={ErrorFallback}
|
|
69
|
+
placeholder={placeholder}
|
|
105
70
|
/>
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{/* TODO(burdon): Fix containment. */}
|
|
109
|
-
<Surface role='article' data={data} limit={1} fallback={ContentError} placeholder={placeholder} />
|
|
110
|
-
</NaturalMain.Drawer>
|
|
71
|
+
</Panel.Content>
|
|
72
|
+
</Panel.Root>
|
|
111
73
|
);
|
|
112
74
|
};
|
|
113
75
|
|
|
114
76
|
Drawer.displayName = DRAWER_NAME;
|
|
115
77
|
|
|
116
|
-
/** Parse entry ID to extract primary ID and variant. */
|
|
117
|
-
const parseEntryId = (entryId: string) => {
|
|
118
|
-
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
119
|
-
return { id, variant };
|
|
120
|
-
};
|
|
121
|
-
|
|
122
78
|
/**
|
|
123
79
|
* Resolves which companion to show based on variant preference.
|
|
124
80
|
* Falls back to first available if preferred variant not available.
|
|
@@ -131,10 +87,7 @@ const useSelectedCompanion = (companions: Node.Node[], preferredVariant?: string
|
|
|
131
87
|
|
|
132
88
|
// Try to find companion matching the preferred variant.
|
|
133
89
|
if (preferredVariant) {
|
|
134
|
-
const preferred = companions.find((c) =>
|
|
135
|
-
const { variant } = parseEntryId(c.id);
|
|
136
|
-
return variant === preferredVariant;
|
|
137
|
-
});
|
|
90
|
+
const preferred = companions.find((c) => getLinkedVariant(c.id) === preferredVariant);
|
|
138
91
|
if (preferred) {
|
|
139
92
|
return preferred;
|
|
140
93
|
}
|
|
@@ -145,7 +98,7 @@ const useSelectedCompanion = (companions: Node.Node[], preferredVariant?: string
|
|
|
145
98
|
}, [companions, preferredVariant]);
|
|
146
99
|
|
|
147
100
|
const companionId = selectedCompanion?.id;
|
|
148
|
-
const
|
|
101
|
+
const variant = companionId ? getLinkedVariant(companionId) : undefined;
|
|
149
102
|
|
|
150
103
|
return { selectedCompanion, companionId, variant };
|
|
151
104
|
};
|
|
@@ -4,17 +4,18 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
+
import { AppSurface, useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
9
|
import { useNode } from '@dxos/plugin-graph';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { ErrorFallback, Panel } from '@dxos/react-ui';
|
|
11
|
+
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
11
12
|
|
|
12
|
-
import { useSimpleLayoutState } from '
|
|
13
|
-
import { ContentError } from '../ContentError';
|
|
14
|
-
import { ContentLoading } from '../ContentLoading';
|
|
15
|
-
import { useLoadDescendents } from '../hooks';
|
|
13
|
+
import { useAppBarProps, useNavbarActions, useSimpleLayoutState } from '#hooks';
|
|
16
14
|
|
|
17
|
-
import {
|
|
15
|
+
import { useExpandPath } from '../hooks';
|
|
16
|
+
import { Loading } from '../Loading';
|
|
17
|
+
import { useMobileLayout } from '../MobileLayout';
|
|
18
|
+
import { AppBar } from './AppBar';
|
|
18
19
|
import { NavBar } from './NavBar';
|
|
19
20
|
|
|
20
21
|
const MAIN_NAME = 'SimpleLayout.Main';
|
|
@@ -24,15 +25,16 @@ const MAIN_NAME = 'SimpleLayout.Main';
|
|
|
24
25
|
*/
|
|
25
26
|
export const Main = () => {
|
|
26
27
|
const { state } = useSimpleLayoutState();
|
|
27
|
-
const { graph } = useAppGraph();
|
|
28
28
|
const id = state.active ?? state.workspace;
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
const attentionAttrs = useAttentionAttributes(id);
|
|
30
|
+
const { keyboardOpen } = useMobileLayout(MAIN_NAME);
|
|
31
|
+
const { actions, onAction } = useNavbarActions();
|
|
32
|
+
const appBarProps = useAppBarProps();
|
|
33
33
|
|
|
34
|
-
const placeholder = useMemo(() => <
|
|
34
|
+
const placeholder = useMemo(() => <Loading />, []);
|
|
35
35
|
|
|
36
|
+
const { graph } = useAppGraph();
|
|
37
|
+
const node = useNode(graph, id);
|
|
36
38
|
const data = useMemo(() => {
|
|
37
39
|
return (
|
|
38
40
|
node && {
|
|
@@ -44,28 +46,32 @@ export const Main = () => {
|
|
|
44
46
|
);
|
|
45
47
|
}, [id, node, node?.data, node?.properties, state.popoverAnchorId]);
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
useExpandPath(id);
|
|
50
|
+
|
|
51
|
+
// TODO(burdon): BUG: When showing ANY statusbar the size progressively shrinks when the keyboard opens/closes.
|
|
52
|
+
const showNavBar = !keyboardOpen && !state.isPopover && state.drawerState === 'closed';
|
|
49
53
|
|
|
50
54
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
55
|
+
<Panel.Root {...attentionAttrs} className='dx-document'>
|
|
56
|
+
<Panel.Toolbar asChild>
|
|
57
|
+
<AppBar {...appBarProps} />
|
|
58
|
+
</Panel.Toolbar>
|
|
59
|
+
<Panel.Content role='article' className='bg-base-surface'>
|
|
60
|
+
<Surface.Surface
|
|
61
|
+
key={id}
|
|
62
|
+
type={AppSurface.Article}
|
|
63
|
+
data={data}
|
|
64
|
+
limit={1}
|
|
65
|
+
fallback={ErrorFallback}
|
|
66
|
+
placeholder={placeholder}
|
|
67
|
+
/>
|
|
68
|
+
</Panel.Content>
|
|
69
|
+
{showNavBar && (
|
|
70
|
+
<Panel.Statusbar asChild>
|
|
71
|
+
<NavBar actions={actions} onAction={onAction} />
|
|
72
|
+
</Panel.Statusbar>
|
|
73
|
+
)}
|
|
74
|
+
</Panel.Root>
|
|
69
75
|
);
|
|
70
76
|
};
|
|
71
77
|
|