@dxos/plugin-simple-layout 0.8.4-main.3eb6e50203 → 0.8.4-main.422d1c7879
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/browser/index.mjs +35 -56
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +35 -55
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +21 -6
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
- package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
- package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +1 -1
- package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
- package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +2 -2
- package/dist/types/src/capabilities/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler.d.ts +12 -0
- package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +26 -21
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
- package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
- package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
- package/dist/types/src/components/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.map +1 -1
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -1
- 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 +5 -7
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +28 -21
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +5 -7
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +28 -22
- 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/hooks.d.ts +4 -2
- package/dist/types/src/components/hooks.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +3 -2
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +4 -5
- package/dist/types/src/hooks/actions.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -1
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +1 -1
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
- package/dist/types/src/operations/close.d.ts +5 -0
- package/dist/types/src/operations/close.d.ts.map +1 -0
- package/dist/types/src/operations/index.d.ts +3 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/src/operations/open.d.ts +5 -0
- package/dist/types/src/operations/open.d.ts.map +1 -0
- package/dist/types/src/operations/revert-workspace.d.ts +5 -0
- package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
- package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
- package/dist/types/src/operations/set.d.ts +5 -0
- package/dist/types/src/operations/set.d.ts.map +1 -0
- package/dist/types/src/operations/state-access.d.ts +8 -0
- package/dist/types/src/operations/state-access.d.ts.map +1 -0
- package/dist/types/src/operations/switch-workspace.d.ts +5 -0
- package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
- package/dist/types/src/operations/update-complementary.d.ts +5 -0
- package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
- package/dist/types/src/operations/update-dialog.d.ts +5 -0
- package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
- package/dist/types/src/operations/update-popover.d.ts +5 -0
- package/dist/types/src/operations/update-popover.d.ts.map +1 -0
- package/dist/types/src/operations/update-sidebar.d.ts +5 -0
- package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +26 -19
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +10 -2
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +41 -30
- package/src/SimpleLayoutPlugin.ts +16 -6
- 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} +2 -2
- package/src/capabilities/{react-surface/react-surface.tsx → react-surface.tsx} +16 -7
- package/src/capabilities/{state/state.tsx → state.tsx} +2 -2
- package/src/capabilities/url-handler.ts +161 -0
- package/src/components/ContentError.stories.tsx +7 -6
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +15 -4
- package/src/components/Home/Home.tsx +38 -32
- package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +4 -4
- 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 +38 -30
- package/src/components/MobileLayout/MobileLayout.tsx +118 -49
- package/src/components/NavBranch/NavBranch.tsx +128 -0
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +12 -8
- package/src/components/SimpleLayout/AppBar.stories.tsx +10 -11
- package/src/components/SimpleLayout/AppBar.tsx +56 -63
- package/src/components/SimpleLayout/Drawer.tsx +38 -36
- package/src/components/SimpleLayout/Main.tsx +22 -25
- package/src/components/SimpleLayout/NavBar.stories.tsx +8 -9
- package/src/components/SimpleLayout/NavBar.tsx +10 -17
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +45 -68
- package/src/components/SimpleLayout/SimpleLayout.tsx +33 -34
- package/src/components/hooks.ts +8 -8
- package/src/components/index.ts +3 -2
- package/src/hooks/actions.ts +17 -18
- package/src/hooks/useAppBarProps.ts +17 -14
- package/src/hooks/useCompanions.ts +1 -1
- package/src/hooks/useDrawerActions.ts +15 -13
- package/src/hooks/useNavbarActions.ts +13 -12
- package/src/hooks/useSimpleLayoutState.ts +1 -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 +4 -4
- package/dist/lib/browser/chunk-7VLT3S46.mjs +0 -29
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +0 -7
- package/dist/lib/browser/chunk-O3BQBYMW.mjs +0 -1165
- package/dist/lib/browser/chunk-O3BQBYMW.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs +0 -205
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +0 -7
- package/dist/lib/browser/react-root-GPTKI5H2.mjs +0 -21
- package/dist/lib/browser/react-root-GPTKI5H2.mjs.map +0 -7
- package/dist/lib/browser/react-surface-LT5JJTPR.mjs +0 -41
- package/dist/lib/browser/react-surface-LT5JJTPR.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs +0 -66
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +0 -7
- package/dist/lib/browser/state-A3PGDWWZ.mjs +0 -48
- package/dist/lib/browser/state-A3PGDWWZ.mjs.map +0 -7
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs +0 -152
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-UAWM4B2S.mjs +0 -1166
- package/dist/lib/node-esm/chunk-UAWM4B2S.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs +0 -31
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs +0 -206
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-GRG2OAI2.mjs +0 -22
- package/dist/lib/node-esm/react-root-GRG2OAI2.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TCUSDIN2.mjs +0 -42
- package/dist/lib/node-esm/react-surface-TCUSDIN2.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs +0 -68
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +0 -7
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs +0 -49
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs +0 -153
- package/dist/lib/node-esm/url-handler-WBVVKVPC.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 -12
- 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/Workspace/Workspace.d.ts +0 -11
- 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 -217
- package/src/capabilities/react-root/index.ts +0 -7
- package/src/capabilities/react-surface/index.ts +0 -7
- 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 -157
- package/src/components/ContentError.tsx +0 -23
- package/src/components/Workspace/Workspace.tsx +0 -119
- /package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +0 -0
|
@@ -6,11 +6,12 @@ import { createContext } from '@radix-ui/react-context';
|
|
|
6
6
|
import React, { type PropsWithChildren, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { Surface } from '@dxos/app-framework/ui';
|
|
9
|
+
import { AppSurface } from '@dxos/app-toolkit/ui';
|
|
9
10
|
import { Popover, type PopoverContentInteractOutsideEvent, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
10
|
-
import { Card } from '@dxos/react-ui
|
|
11
|
+
import { Card } from '@dxos/react-ui';
|
|
11
12
|
|
|
12
|
-
import { useSimpleLayoutState } from '
|
|
13
|
-
import { meta } from '
|
|
13
|
+
import { useSimpleLayoutState } from '#hooks';
|
|
14
|
+
import { meta } from '#meta';
|
|
14
15
|
|
|
15
16
|
const DEBOUNCE_DELAY = 40;
|
|
16
17
|
|
|
@@ -57,7 +58,6 @@ export const PopoverContent = () => {
|
|
|
57
58
|
const { t } = useTranslation(meta.id);
|
|
58
59
|
const { state, updateState } = useSimpleLayoutState();
|
|
59
60
|
const { setOpen } = useLayoutPopoverContext('PopoverContent');
|
|
60
|
-
|
|
61
61
|
const handleClose = useCallback(() => {
|
|
62
62
|
setOpen(false);
|
|
63
63
|
updateState((s) => ({
|
|
@@ -100,16 +100,20 @@ export const PopoverContent = () => {
|
|
|
100
100
|
onEscapeKeyDown={handleInteractOutside}
|
|
101
101
|
>
|
|
102
102
|
<Popover.Viewport>
|
|
103
|
-
{state.popoverKind === 'base' &&
|
|
103
|
+
{state.popoverKind === 'base' && state.popoverContent && 'component' in state.popoverContent && (
|
|
104
|
+
<Surface.Surface type={AppSurface.Popover} data={state.popoverContent} limit={1} />
|
|
105
|
+
)}
|
|
104
106
|
{state.popoverKind === 'card' && (
|
|
105
|
-
<Card.Root border={false} classNames='
|
|
107
|
+
<Card.Root border={false} classNames='dx-card-popover'>
|
|
106
108
|
<Card.Toolbar>
|
|
107
109
|
{/* TODO(wittjosiah): Cleaner way to handle no drag handle in toolbar? */}
|
|
108
110
|
<span />
|
|
109
111
|
{state.popoverTitle ? <Card.Title>{toLocalizedString(state.popoverTitle, t)}</Card.Title> : <span />}
|
|
110
|
-
<Card.
|
|
112
|
+
<Card.CloseIconButton onClick={handleClose} />
|
|
111
113
|
</Card.Toolbar>
|
|
112
|
-
|
|
114
|
+
{state.popoverContent && 'subject' in state.popoverContent && (
|
|
115
|
+
<Surface.Surface type={AppSurface.Card} data={state.popoverContent} limit={1} />
|
|
116
|
+
)}
|
|
113
117
|
</Card.Root>
|
|
114
118
|
)}
|
|
115
119
|
</Popover.Viewport>
|
|
@@ -7,13 +7,12 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
import { type Mock, expect, fn, screen, userEvent, within } from 'storybook/test';
|
|
9
9
|
|
|
10
|
-
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
10
|
import { type ActionGraphProps, createMenuAction } from '@dxos/react-ui-menu';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
12
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
13
13
|
|
|
14
14
|
import { translations } from '../../translations';
|
|
15
15
|
import { MobileLayout } from '../MobileLayout';
|
|
16
|
-
|
|
17
16
|
import { AppBar, type AppBarProps } from './AppBar';
|
|
18
17
|
|
|
19
18
|
const buildEmptyActions = (): ActionGraphProps => ({ nodes: [], edges: [] });
|
|
@@ -21,29 +20,29 @@ const buildEmptyActions = (): ActionGraphProps => ({ nodes: [], edges: [] });
|
|
|
21
20
|
const buildDefaultActions = (): ActionGraphProps => {
|
|
22
21
|
const result: ActionGraphProps = { nodes: [], edges: [] };
|
|
23
22
|
const actions = [
|
|
24
|
-
createMenuAction('action-edit', () => console.log('Edit'), {
|
|
23
|
+
createMenuAction('action-edit.menu', () => console.log('Edit'), {
|
|
25
24
|
icon: 'ph--pencil--regular',
|
|
26
25
|
label: 'Edit',
|
|
27
26
|
}),
|
|
28
|
-
createMenuAction('action-share', () => console.log('Share'), {
|
|
27
|
+
createMenuAction('action-share.menu', () => console.log('Share'), {
|
|
29
28
|
icon: 'ph--share--regular',
|
|
30
29
|
label: 'Share',
|
|
31
30
|
}),
|
|
32
|
-
createMenuAction('action-delete', () => console.log('Delete'), {
|
|
31
|
+
createMenuAction('action-delete.menu', () => console.log('Delete'), {
|
|
33
32
|
icon: 'ph--trash--regular',
|
|
34
33
|
label: 'Delete',
|
|
35
34
|
}),
|
|
36
35
|
];
|
|
37
36
|
result.nodes.push(...actions);
|
|
38
|
-
result.edges.push(...actions.map((a) => ({ source: 'root', target: a.id })));
|
|
37
|
+
result.edges.push(...actions.map((a) => ({ source: 'root', target: a.id, relation: 'child' })));
|
|
39
38
|
return result;
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
type
|
|
41
|
+
type DefaultStoryProps = Omit<AppBarProps, 'actions'> & {
|
|
43
42
|
actions: ActionGraphProps;
|
|
44
43
|
};
|
|
45
44
|
|
|
46
|
-
const DefaultStory = ({ actions: actionsProp, ...props }:
|
|
45
|
+
const DefaultStory = ({ actions: actionsProp, ...props }: DefaultStoryProps) => {
|
|
47
46
|
const actions = useMemo(() => Atom.make(actionsProp).pipe(Atom.keepAlive), [actionsProp]);
|
|
48
47
|
return (
|
|
49
48
|
<MobileLayout.Root>
|
|
@@ -53,7 +52,7 @@ const DefaultStory = ({ actions: actionsProp, ...props }: StoryProps) => {
|
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
const meta = {
|
|
56
|
-
title: 'plugins/plugin-simple-layout/AppBar',
|
|
55
|
+
title: 'plugins/plugin-simple-layout/components/AppBar',
|
|
57
56
|
render: DefaultStory,
|
|
58
57
|
decorators: [
|
|
59
58
|
withTheme(),
|
|
@@ -71,7 +70,7 @@ const meta = {
|
|
|
71
70
|
|
|
72
71
|
export default meta;
|
|
73
72
|
|
|
74
|
-
type Story = StoryObj<
|
|
73
|
+
type Story = StoryObj<DefaultStoryProps>;
|
|
75
74
|
|
|
76
75
|
export const Default: Story = {
|
|
77
76
|
tags: ['test'],
|
|
@@ -104,7 +103,7 @@ export const Default: Story = {
|
|
|
104
103
|
const editAction = await screen.findByRole('menuitem', { name: /edit/i });
|
|
105
104
|
await userEvent.click(editAction);
|
|
106
105
|
await expect(args.onAction).toHaveBeenCalledTimes(1);
|
|
107
|
-
await expect((args.onAction as Mock).mock.calls[0][0]).toHaveProperty('id', 'action-edit');
|
|
106
|
+
await expect((args.onAction as Mock).mock.calls[0][0]).toHaveProperty('id', 'action-edit.menu');
|
|
108
107
|
},
|
|
109
108
|
};
|
|
110
109
|
|
|
@@ -5,22 +5,17 @@
|
|
|
5
5
|
import { type Atom, useAtomValue } from '@effect-atom/atom-react';
|
|
6
6
|
import React, { Fragment } from 'react';
|
|
7
7
|
|
|
8
|
-
import { IconButton, Popover,
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
MenuProvider,
|
|
14
|
-
useMenuActions,
|
|
15
|
-
} from '@dxos/react-ui-menu';
|
|
16
|
-
import { mx, osTranslations } from '@dxos/ui-theme';
|
|
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';
|
|
17
13
|
|
|
18
|
-
import { meta } from '../../meta';
|
|
19
14
|
import { useMobileLayout } from '../MobileLayout';
|
|
20
15
|
|
|
21
16
|
const APP_BAR_NAME = 'SimpleLayout.AppBar';
|
|
22
17
|
|
|
23
|
-
export type AppBarProps =
|
|
18
|
+
export type AppBarProps = {
|
|
24
19
|
/** Title/label to display in the banner. */
|
|
25
20
|
title?: string;
|
|
26
21
|
/** Action graph atom for the dropdown menu. */
|
|
@@ -33,69 +28,67 @@ export type AppBarProps = ThemedClassName<{
|
|
|
33
28
|
onAction?: ActionExecutor;
|
|
34
29
|
/** Callback when back button is clicked. */
|
|
35
30
|
onBack?: () => void;
|
|
36
|
-
}
|
|
31
|
+
};
|
|
37
32
|
|
|
38
33
|
/**
|
|
39
34
|
* AppBar component that renders a title, optional back button, and actions dropdown.
|
|
40
35
|
*/
|
|
41
|
-
export const AppBar = (
|
|
42
|
-
classNames,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
onBack,
|
|
49
|
-
}: AppBarProps) => {
|
|
50
|
-
const { t } = useTranslation(meta.id);
|
|
51
|
-
const menu = useMenuActions(actions);
|
|
52
|
-
const actionsValue = useAtomValue(actions);
|
|
53
|
-
const hasActions = actionsValue.nodes.length > 0;
|
|
54
|
-
const { keyboardOpen } = useMobileLayout(APP_BAR_NAME);
|
|
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);
|
|
55
43
|
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
// Fall back to app name if no title provided.
|
|
45
|
+
const displayTitle = title ?? t('current-app.name', { ns: osTranslations });
|
|
58
46
|
|
|
59
|
-
|
|
60
|
-
|
|
47
|
+
// Wrap the menu trigger with Popover.Anchor when the popoverAnchorId is set.
|
|
48
|
+
const AnchorRoot = popoverAnchorId ? Popover.Anchor : Fragment;
|
|
61
49
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<
|
|
82
|
-
|
|
83
|
-
|
|
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>
|
|
84
76
|
<IconButton
|
|
85
77
|
variant='ghost'
|
|
86
78
|
icon='ph--dots-three-vertical--regular'
|
|
87
79
|
iconOnly
|
|
88
|
-
label={t('actions
|
|
80
|
+
label={t('actions-menu.label')}
|
|
89
81
|
/>
|
|
90
|
-
</
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
82
|
+
</Menu.Trigger>
|
|
83
|
+
<Menu.Content />
|
|
84
|
+
</Menu.Root>
|
|
85
|
+
</AnchorRoot>
|
|
86
|
+
) : (
|
|
87
|
+
<span />
|
|
88
|
+
)}
|
|
89
|
+
</Toolbar.Root>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
100
93
|
|
|
101
94
|
AppBar.displayName = APP_BAR_NAME;
|
|
@@ -5,15 +5,15 @@
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
-
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { AppSurface, useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { type Node, useNode } from '@dxos/plugin-graph';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
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';
|
|
13
13
|
|
|
14
|
-
import { useCompanions, useDrawerActions, useSimpleLayoutState } from '
|
|
15
|
-
|
|
16
|
-
import {
|
|
14
|
+
import { useCompanions, useDrawerActions, useSimpleLayoutState } from '#hooks';
|
|
15
|
+
|
|
16
|
+
import { Loading } from '../Loading';
|
|
17
17
|
|
|
18
18
|
const DRAWER_NAME = 'SimpleLayout.Drawer';
|
|
19
19
|
|
|
@@ -24,7 +24,7 @@ export const Drawer = () => {
|
|
|
24
24
|
const { graph } = useAppGraph();
|
|
25
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
30
|
const activeId = layoutState.active ?? layoutState.workspace;
|
|
@@ -36,40 +36,45 @@ export const Drawer = () => {
|
|
|
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
|
// Get drawer actions (tabs + toolbar buttons).
|
|
52
53
|
const { actions, onAction } = useDrawerActions(DRAWER_NAME);
|
|
53
|
-
const
|
|
54
|
+
const menuActions = useMenuActions(actions);
|
|
54
55
|
|
|
55
56
|
return (
|
|
56
|
-
<
|
|
57
|
-
<
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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}
|
|
70
|
+
/>
|
|
71
|
+
</Panel.Content>
|
|
72
|
+
</Panel.Root>
|
|
62
73
|
);
|
|
63
74
|
};
|
|
64
75
|
|
|
65
76
|
Drawer.displayName = DRAWER_NAME;
|
|
66
77
|
|
|
67
|
-
/** Parse entry ID to extract primary ID and variant. */
|
|
68
|
-
const parseEntryId = (entryId: string) => {
|
|
69
|
-
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
70
|
-
return { id, variant };
|
|
71
|
-
};
|
|
72
|
-
|
|
73
78
|
/**
|
|
74
79
|
* Resolves which companion to show based on variant preference.
|
|
75
80
|
* Falls back to first available if preferred variant not available.
|
|
@@ -82,10 +87,7 @@ const useSelectedCompanion = (companions: Node.Node[], preferredVariant?: string
|
|
|
82
87
|
|
|
83
88
|
// Try to find companion matching the preferred variant.
|
|
84
89
|
if (preferredVariant) {
|
|
85
|
-
const preferred = companions.find((c) =>
|
|
86
|
-
const { variant } = parseEntryId(c.id);
|
|
87
|
-
return variant === preferredVariant;
|
|
88
|
-
});
|
|
90
|
+
const preferred = companions.find((c) => getLinkedVariant(c.id) === preferredVariant);
|
|
89
91
|
if (preferred) {
|
|
90
92
|
return preferred;
|
|
91
93
|
}
|
|
@@ -96,7 +98,7 @@ const useSelectedCompanion = (companions: Node.Node[], preferredVariant?: string
|
|
|
96
98
|
}, [companions, preferredVariant]);
|
|
97
99
|
|
|
98
100
|
const companionId = selectedCompanion?.id;
|
|
99
|
-
const
|
|
101
|
+
const variant = companionId ? getLinkedVariant(companionId) : undefined;
|
|
100
102
|
|
|
101
103
|
return { selectedCompanion, companionId, variant };
|
|
102
104
|
};
|
|
@@ -5,17 +5,16 @@
|
|
|
5
5
|
import React, { useMemo } from 'react';
|
|
6
6
|
|
|
7
7
|
import { Surface } from '@dxos/app-framework/ui';
|
|
8
|
-
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
8
|
+
import { AppSurface, useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
9
|
import { useNode } from '@dxos/plugin-graph';
|
|
10
|
+
import { ErrorFallback, Panel } from '@dxos/react-ui';
|
|
10
11
|
import { useAttentionAttributes } from '@dxos/react-ui-attention';
|
|
11
|
-
import { mx } from '@dxos/ui-theme';
|
|
12
12
|
|
|
13
|
-
import { useAppBarProps, useNavbarActions, useSimpleLayoutState } from '
|
|
14
|
-
import { ContentError } from '../ContentError';
|
|
15
|
-
import { ContentLoading } from '../ContentLoading';
|
|
16
|
-
import { useLoadDescendents } from '../hooks';
|
|
17
|
-
import { useMobileLayout } from '../MobileLayout/MobileLayout';
|
|
13
|
+
import { useAppBarProps, useNavbarActions, useSimpleLayoutState } from '#hooks';
|
|
18
14
|
|
|
15
|
+
import { useExpandPath } from '../hooks';
|
|
16
|
+
import { Loading } from '../Loading';
|
|
17
|
+
import { useMobileLayout } from '../MobileLayout';
|
|
19
18
|
import { AppBar } from './AppBar';
|
|
20
19
|
import { NavBar } from './NavBar';
|
|
21
20
|
|
|
@@ -32,7 +31,7 @@ export const Main = () => {
|
|
|
32
31
|
const { actions, onAction } = useNavbarActions();
|
|
33
32
|
const appBarProps = useAppBarProps();
|
|
34
33
|
|
|
35
|
-
const placeholder = useMemo(() => <
|
|
34
|
+
const placeholder = useMemo(() => <Loading />, []);
|
|
36
35
|
|
|
37
36
|
const { graph } = useAppGraph();
|
|
38
37
|
const node = useNode(graph, id);
|
|
@@ -47,34 +46,32 @@ export const Main = () => {
|
|
|
47
46
|
);
|
|
48
47
|
}, [id, node, node?.data, node?.properties, state.popoverAnchorId]);
|
|
49
48
|
|
|
50
|
-
|
|
51
|
-
useLoadDescendents(id);
|
|
49
|
+
useExpandPath(id);
|
|
52
50
|
|
|
53
51
|
// TODO(burdon): BUG: When showing ANY statusbar the size progressively shrinks when the keyboard opens/closes.
|
|
54
52
|
const showNavBar = !keyboardOpen && !state.isPopover && state.drawerState === 'closed';
|
|
55
53
|
|
|
56
54
|
return (
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)}
|
|
63
|
-
{...attentionAttrs}
|
|
64
|
-
>
|
|
65
|
-
<AppBar {...appBarProps} />
|
|
66
|
-
<article className='bs-full overflow-hidden bg-baseSurface'>
|
|
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'>
|
|
67
60
|
<Surface.Surface
|
|
68
61
|
key={id}
|
|
69
|
-
|
|
62
|
+
type={AppSurface.Article}
|
|
70
63
|
data={data}
|
|
71
64
|
limit={1}
|
|
72
|
-
fallback={
|
|
65
|
+
fallback={ErrorFallback}
|
|
73
66
|
placeholder={placeholder}
|
|
74
67
|
/>
|
|
75
|
-
</
|
|
76
|
-
{showNavBar &&
|
|
77
|
-
|
|
68
|
+
</Panel.Content>
|
|
69
|
+
{showNavBar && (
|
|
70
|
+
<Panel.Statusbar asChild>
|
|
71
|
+
<NavBar actions={actions} onAction={onAction} />
|
|
72
|
+
</Panel.Statusbar>
|
|
73
|
+
)}
|
|
74
|
+
</Panel.Root>
|
|
78
75
|
);
|
|
79
76
|
};
|
|
80
77
|
|
|
@@ -7,12 +7,11 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
import { type Mock, expect, fn, screen, userEvent, within } from 'storybook/test';
|
|
9
9
|
|
|
10
|
-
import { withTheme } from '@dxos/react-ui/testing';
|
|
11
10
|
import { type ActionGraphProps, createGapSeparator, createMenuAction, createMenuItemGroup } from '@dxos/react-ui-menu';
|
|
11
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
12
12
|
import { withRegistry } from '@dxos/storybook-utils';
|
|
13
13
|
|
|
14
14
|
import { translations } from '../../translations';
|
|
15
|
-
|
|
16
15
|
import { NavBar } from './NavBar';
|
|
17
16
|
|
|
18
17
|
const MAIN_MENU_GROUP_ID = 'navbar-main-menu';
|
|
@@ -39,7 +38,7 @@ const buildCompanionOnlyActions = (): ActionGraphProps => {
|
|
|
39
38
|
}),
|
|
40
39
|
];
|
|
41
40
|
result.nodes.push(...companions);
|
|
42
|
-
result.edges.push(...companions.map((c) => ({ source: 'root', target: c.id })));
|
|
41
|
+
result.edges.push(...companions.map((c) => ({ source: 'root', target: c.id, relation: 'child' })));
|
|
43
42
|
return result;
|
|
44
43
|
};
|
|
45
44
|
|
|
@@ -81,18 +80,18 @@ const buildDefaultActions = (): ActionGraphProps => {
|
|
|
81
80
|
];
|
|
82
81
|
result.nodes.push(...companions, ...gapSeparator.nodes, mainMenuGroup, ...menuActions);
|
|
83
82
|
result.edges.push(
|
|
84
|
-
...companions.map((c) => ({ source: 'root', target: c.id })),
|
|
83
|
+
...companions.map((c) => ({ source: 'root', target: c.id, relation: 'child' })),
|
|
85
84
|
...gapSeparator.edges,
|
|
86
|
-
{ source: 'root', target: mainMenuGroup.id },
|
|
87
|
-
...menuActions.map((action) => ({ source: MAIN_MENU_GROUP_ID, target: action.id })),
|
|
85
|
+
{ source: 'root', target: mainMenuGroup.id, relation: 'child' },
|
|
86
|
+
...menuActions.map((action) => ({ source: MAIN_MENU_GROUP_ID, target: action.id, relation: 'child' })),
|
|
88
87
|
);
|
|
89
88
|
return result;
|
|
90
89
|
};
|
|
91
90
|
|
|
92
91
|
const meta = {
|
|
93
|
-
title: 'plugins/plugin-simple-layout/NavBar',
|
|
92
|
+
title: 'plugins/plugin-simple-layout/components/NavBar',
|
|
94
93
|
component: NavBar,
|
|
95
|
-
decorators: [withTheme(), withRegistry],
|
|
94
|
+
decorators: [withTheme(), withLayout({ layout: 'fullscreen' }), withRegistry],
|
|
96
95
|
parameters: {
|
|
97
96
|
layout: 'fullscreen',
|
|
98
97
|
translations,
|
|
@@ -106,7 +105,7 @@ type Story = StoryObj<typeof meta>;
|
|
|
106
105
|
const DefaultStory = ({ onAction }: { onAction: (action: { id: string }) => void }) => {
|
|
107
106
|
const actions = useMemo(() => Atom.make(buildDefaultActions()).pipe(Atom.keepAlive), []);
|
|
108
107
|
|
|
109
|
-
return <NavBar classNames='border-
|
|
108
|
+
return <NavBar classNames='border-y border-separator' actions={actions} onAction={onAction} />;
|
|
110
109
|
};
|
|
111
110
|
|
|
112
111
|
export const Default: Story = {
|
|
@@ -5,36 +5,29 @@
|
|
|
5
5
|
import { type Atom } from '@effect-atom/atom-react';
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { type
|
|
9
|
-
import {
|
|
10
|
-
type ActionExecutor,
|
|
11
|
-
type ActionGraphProps,
|
|
12
|
-
MenuProvider,
|
|
13
|
-
ToolbarMenu,
|
|
14
|
-
useMenuActions,
|
|
15
|
-
} from '@dxos/react-ui-menu';
|
|
16
|
-
import { mx } from '@dxos/ui-theme';
|
|
8
|
+
import { type ActionExecutor, type ActionGraphProps, Menu, useMenuActions } from '@dxos/react-ui-menu';
|
|
9
|
+
import { composable, composableProps } from '@dxos/ui-theme';
|
|
17
10
|
|
|
18
11
|
const NAVBAR_NAME = 'SimpleLayout.NavBar';
|
|
19
12
|
|
|
20
|
-
export type NavBarProps =
|
|
13
|
+
export type NavBarProps = {
|
|
21
14
|
/** Action graph atom for the toolbar. */
|
|
22
15
|
actions: Atom.Atom<ActionGraphProps>;
|
|
23
16
|
/** Action executor callback. */
|
|
24
17
|
onAction?: ActionExecutor;
|
|
25
|
-
}
|
|
18
|
+
};
|
|
26
19
|
|
|
27
20
|
/**
|
|
28
21
|
* Presentational navbar component that renders a toolbar from an action graph.
|
|
29
22
|
*/
|
|
30
|
-
export const NavBar = ({
|
|
31
|
-
const
|
|
23
|
+
export const NavBar = composable<HTMLDivElement, NavBarProps>(({ actions, onAction, ...props }, forwardedRef) => {
|
|
24
|
+
const menuActions = useMenuActions(actions);
|
|
32
25
|
|
|
33
26
|
return (
|
|
34
|
-
<
|
|
35
|
-
<
|
|
36
|
-
</
|
|
27
|
+
<Menu.Root {...menuActions} alwaysActive onAction={onAction}>
|
|
28
|
+
<Menu.Toolbar {...composableProps(props)} ref={forwardedRef} />
|
|
29
|
+
</Menu.Root>
|
|
37
30
|
);
|
|
38
|
-
};
|
|
31
|
+
});
|
|
39
32
|
|
|
40
33
|
NavBar.displayName = NAVBAR_NAME;
|