@dxos/plugin-simple-layout 0.8.4-main.bc674ce → 0.8.4-main.bcb3aa67d6
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 +44 -64
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node-esm/index.mjs +44 -63
- 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/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 +28 -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 +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 +17 -8
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +35 -25
- 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/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 +7 -6
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +46 -30
- package/src/SimpleLayoutPlugin.ts +24 -13
- 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 +51 -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 +8 -7
- package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
- package/src/components/DebugOverlay/index.ts +5 -0
- package/src/components/Dialog/Dialog.tsx +6 -6
- package/src/components/Home/Home.tsx +50 -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 +127 -0
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +9 -9
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +93 -0
- package/src/components/SimpleLayout/Drawer.tsx +27 -82
- package/src/components/SimpleLayout/Main.tsx +40 -34
- package/src/components/SimpleLayout/NavBar.stories.tsx +131 -23
- package/src/components/SimpleLayout/NavBar.tsx +18 -51
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +45 -57
- package/src/components/SimpleLayout/SimpleLayout.tsx +40 -22
- 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 +115 -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/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 +12 -8
- 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
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
|
-
import { Surface } from '@dxos/app-framework/
|
|
7
|
+
import { Surface } from '@dxos/app-framework/ui';
|
|
8
8
|
import { AlertDialog, Dialog as NaturalDialog } from '@dxos/react-ui';
|
|
9
|
+
import { ErrorFallback } from '@dxos/react-ui';
|
|
9
10
|
|
|
10
|
-
import { useSimpleLayoutState } from '
|
|
11
|
-
import { ContentError } from '../ContentError';
|
|
11
|
+
import { useSimpleLayoutState } from '#hooks';
|
|
12
12
|
|
|
13
13
|
export const Dialog = () => {
|
|
14
14
|
const { state, updateState } = useSimpleLayoutState();
|
|
@@ -20,17 +20,17 @@ export const Dialog = () => {
|
|
|
20
20
|
<DialogRoot
|
|
21
21
|
modal={state.dialogBlockAlign !== 'end'}
|
|
22
22
|
open={state.dialogOpen}
|
|
23
|
-
onOpenChange={(nextOpen) => updateState((
|
|
23
|
+
onOpenChange={(nextOpen) => updateState((state) => ({ ...state, dialogOpen: nextOpen }))}
|
|
24
24
|
>
|
|
25
25
|
{state.dialogBlockAlign === 'end' ? (
|
|
26
|
-
<Surface role='dialog' data={state.dialogContent} limit={1} fallback={
|
|
26
|
+
<Surface.Surface role='dialog' data={state.dialogContent} limit={1} fallback={ErrorFallback} />
|
|
27
27
|
) : (
|
|
28
28
|
<DialogOverlay
|
|
29
29
|
blockAlign={state.dialogBlockAlign}
|
|
30
30
|
classNames={state.dialogOverlayClasses}
|
|
31
31
|
style={state.dialogOverlayStyle}
|
|
32
32
|
>
|
|
33
|
-
<Surface role='dialog' data={state.dialogContent} limit={1} fallback={
|
|
33
|
+
<Surface.Surface role='dialog' data={state.dialogContent} limit={1} fallback={ErrorFallback} />
|
|
34
34
|
</DialogOverlay>
|
|
35
35
|
)}
|
|
36
36
|
</DialogRoot>
|
|
@@ -4,17 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { useOperationInvoker } from '@dxos/app-framework/ui';
|
|
8
|
+
import { LayoutOperation } from '@dxos/app-toolkit';
|
|
9
|
+
import { useAppGraph } from '@dxos/app-toolkit/ui';
|
|
9
10
|
import { Node, useConnections } from '@dxos/plugin-graph';
|
|
10
|
-
import { Avatar, Icon,
|
|
11
|
-
import { Card
|
|
12
|
-
import {
|
|
11
|
+
import { Avatar, Icon, ScrollArea, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
12
|
+
import { Card } from '@dxos/react-ui';
|
|
13
|
+
import { Mosaic, type MosaicStackTileComponent } from '@dxos/react-ui-mosaic';
|
|
14
|
+
import { SearchPanel, useSearchListItem, useSearchListResults } from '@dxos/react-ui-search';
|
|
13
15
|
import { mx } from '@dxos/ui-theme';
|
|
14
|
-
import { byPosition } from '@dxos/util';
|
|
16
|
+
import { byPosition, getHostPlatform, isTauri } from '@dxos/util';
|
|
15
17
|
|
|
16
|
-
import { meta } from '
|
|
17
|
-
import {
|
|
18
|
+
import { meta } from '#meta';
|
|
19
|
+
import { useExpandPath } from '../hooks';
|
|
18
20
|
|
|
19
21
|
export type HomeProps = {};
|
|
20
22
|
|
|
@@ -26,7 +28,7 @@ export const Home = (_: HomeProps) => {
|
|
|
26
28
|
const userAccountItem = useItemsByDisposition('user-account')[0];
|
|
27
29
|
const pinnedItems = useItemsByDisposition('pin-end', true);
|
|
28
30
|
const workspaceItems = useItemsByDisposition('workspace');
|
|
29
|
-
|
|
31
|
+
useExpandPath(Node.RootId);
|
|
30
32
|
|
|
31
33
|
const items = useMemo(
|
|
32
34
|
() => [...(userAccountItem ? [userAccountItem] : []), ...pinnedItems, ...workspaceItems],
|
|
@@ -38,44 +40,47 @@ export const Home = (_: HomeProps) => {
|
|
|
38
40
|
extract: (node) => toLocalizedString(node.properties.label, t),
|
|
39
41
|
});
|
|
40
42
|
|
|
43
|
+
const autoFocus = !isTauri() || getHostPlatform() !== 'ios';
|
|
44
|
+
|
|
41
45
|
return (
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
<SearchPanel onSearch={handleSearch}>
|
|
47
|
+
<Mosaic.Container asChild>
|
|
48
|
+
<ScrollArea.Root centered padding thin>
|
|
49
|
+
<ScrollArea.Viewport>
|
|
50
|
+
<Mosaic.Stack
|
|
51
|
+
classNames='gap-1'
|
|
52
|
+
draggable={false}
|
|
53
|
+
items={results}
|
|
54
|
+
getId={(item) => item.id}
|
|
55
|
+
Tile={WorkspaceTile}
|
|
56
|
+
/>
|
|
57
|
+
</ScrollArea.Viewport>
|
|
58
|
+
</ScrollArea.Root>
|
|
59
|
+
</Mosaic.Container>
|
|
60
|
+
</SearchPanel>
|
|
56
61
|
);
|
|
57
62
|
};
|
|
58
63
|
|
|
59
|
-
const WorkspaceTile:
|
|
64
|
+
const WorkspaceTile: MosaicStackTileComponent<Node.Node> = (props) => {
|
|
65
|
+
const data = props.data;
|
|
60
66
|
const { t } = useTranslation(meta.id);
|
|
61
67
|
const { invokePromise } = useOperationInvoker();
|
|
62
68
|
const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
|
|
63
|
-
const
|
|
69
|
+
const name = toLocalizedString(data.properties.label, t);
|
|
70
|
+
const isSelected = selectedValue === data.id;
|
|
71
|
+
const cardRef = useRef<HTMLDivElement>(null);
|
|
72
|
+
|
|
73
|
+
useExpandPath(data.id);
|
|
64
74
|
|
|
65
75
|
const handleSelect = useCallback(
|
|
66
|
-
() => invokePromise(
|
|
76
|
+
() => invokePromise(LayoutOperation.SwitchWorkspace, { subject: data.id }),
|
|
67
77
|
[invokePromise, data.id],
|
|
68
78
|
);
|
|
69
79
|
|
|
70
|
-
useLoadDescendents(data.id);
|
|
71
|
-
|
|
72
|
-
const name = toLocalizedString(data.properties.label, t);
|
|
73
|
-
const isSelected = selectedValue === data.id;
|
|
74
|
-
|
|
75
80
|
// Register this workspace with the search context.
|
|
76
81
|
useEffect(() => {
|
|
77
|
-
if (
|
|
78
|
-
registerItem(data.id,
|
|
82
|
+
if (cardRef.current) {
|
|
83
|
+
registerItem(data.id, cardRef.current, handleSelect);
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
return () => unregisterItem(data.id);
|
|
@@ -83,32 +88,32 @@ const WorkspaceTile: StackTileComponent<Node.Node> = ({ data }) => {
|
|
|
83
88
|
|
|
84
89
|
// Scroll into view when selected.
|
|
85
90
|
useEffect(() => {
|
|
86
|
-
if (isSelected &&
|
|
87
|
-
|
|
91
|
+
if (isSelected && cardRef.current) {
|
|
92
|
+
cardRef.current.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
88
93
|
}
|
|
89
94
|
}, [isSelected]);
|
|
90
95
|
|
|
91
96
|
return (
|
|
92
97
|
<Card.Root
|
|
93
|
-
ref={ref}
|
|
94
98
|
role='button'
|
|
95
99
|
fullWidth
|
|
96
100
|
tabIndex={-1} // TODO(burdon): Use Mosaic.Focus.
|
|
97
101
|
data-selected={isSelected}
|
|
98
|
-
classNames={mx('dx-focus-ring', isSelected && 'bg-
|
|
102
|
+
classNames={mx('dx-focus-ring', isSelected && 'bg-hover-overlay')}
|
|
99
103
|
onClick={handleSelect}
|
|
104
|
+
ref={cardRef}
|
|
100
105
|
>
|
|
101
|
-
<Card.Toolbar density='
|
|
106
|
+
<Card.Toolbar density='fine'>
|
|
102
107
|
<Avatar.Root>
|
|
103
108
|
<Avatar.Content
|
|
104
109
|
icon={data.properties.icon}
|
|
105
110
|
hue={data.properties.hue}
|
|
106
111
|
hueVariant='transparent'
|
|
107
112
|
variant='square'
|
|
108
|
-
size={
|
|
113
|
+
size={8}
|
|
109
114
|
fallback={name}
|
|
110
115
|
/>
|
|
111
|
-
<Avatar.Label>{name}</Avatar.Label>
|
|
116
|
+
<Avatar.Label classNames='cursor-pointer'>{name}</Avatar.Label>
|
|
112
117
|
<Icon icon='ph--caret-right--regular' />
|
|
113
118
|
</Avatar.Root>
|
|
114
119
|
</Card.Toolbar>
|
|
@@ -124,7 +129,9 @@ const filterItems = (node: Node.Node, disposition: string) => {
|
|
|
124
129
|
/** Returns root-level items filtered by disposition. */
|
|
125
130
|
const useItemsByDisposition = (disposition: string, sort = false) => {
|
|
126
131
|
const { graph } = useAppGraph();
|
|
127
|
-
const connections = useConnections(graph, Node.RootId);
|
|
128
|
-
|
|
129
|
-
|
|
132
|
+
const connections = useConnections(graph, Node.RootId, 'child');
|
|
133
|
+
return useMemo(() => {
|
|
134
|
+
const filtered = connections.filter((node) => filterItems(node, disposition));
|
|
135
|
+
return sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
136
|
+
}, [connections, disposition, sort]);
|
|
130
137
|
};
|
|
@@ -6,16 +6,16 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
|
6
6
|
|
|
7
7
|
import { withTheme } from '@dxos/react-ui/testing';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { Loading } from './Loading';
|
|
10
10
|
|
|
11
11
|
const meta = {
|
|
12
|
-
title: 'plugins/plugin-simple-layout/
|
|
13
|
-
component:
|
|
14
|
-
decorators: [withTheme],
|
|
12
|
+
title: 'plugins/plugin-simple-layout/components/Loading',
|
|
13
|
+
component: Loading,
|
|
14
|
+
decorators: [withTheme()],
|
|
15
15
|
parameters: {
|
|
16
16
|
layout: 'centered',
|
|
17
17
|
},
|
|
18
|
-
} satisfies Meta<typeof
|
|
18
|
+
} satisfies Meta<typeof Loading>;
|
|
19
19
|
|
|
20
20
|
export default meta;
|
|
21
21
|
|
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
|
|
7
7
|
// TODO(burdon): Show skeleton: https://github.com/dxos/dxos/issues/8259
|
|
8
|
-
export const
|
|
9
|
-
return <div role='none' className='grid place-items-center attention-surface' />;
|
|
8
|
+
export const Loading = () => {
|
|
9
|
+
return <div role='none' className='grid place-items-center dx-attention-surface' />;
|
|
10
10
|
};
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2025 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import { type Meta, type StoryObj } from '@storybook/react-vite';
|
|
6
|
+
import React, { type PropsWithChildren, useEffect, useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import { addEventListener, combine } from '@dxos/async';
|
|
9
|
+
import { Column, Flex, Input, Panel, Splitter, type SplitterMode, Toolbar } from '@dxos/react-ui';
|
|
10
|
+
import { withLayout, withTheme } from '@dxos/react-ui/testing';
|
|
11
|
+
|
|
12
|
+
import { MobileLayout, type MobileLayoutRootProps } from './MobileLayout';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Simulate ios keyboard.
|
|
16
|
+
*/
|
|
17
|
+
const WithKeyboard = ({ children }: PropsWithChildren) => {
|
|
18
|
+
const [keyboardOpen, setKeyboardOpen] = useState(false);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
return combine(
|
|
22
|
+
addEventListener(document, 'focusin', (event: FocusEvent) => {
|
|
23
|
+
const target = event.target as HTMLElement;
|
|
24
|
+
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
|
|
25
|
+
setKeyboardOpen(true);
|
|
26
|
+
}
|
|
27
|
+
}),
|
|
28
|
+
addEventListener(document, 'focusout', (event: FocusEvent) => {
|
|
29
|
+
const target = event.target as HTMLElement;
|
|
30
|
+
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA' || target.isContentEditable) {
|
|
31
|
+
setKeyboardOpen(false);
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
);
|
|
35
|
+
}, []);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const keyboardHeight = keyboardOpen ? 300 : 0;
|
|
39
|
+
document.documentElement.style.setProperty('--kb-height', `${keyboardHeight}px`);
|
|
40
|
+
document.documentElement.style.setProperty('--kb-open', keyboardOpen ? '1' : '0');
|
|
41
|
+
|
|
42
|
+
// Dispatch custom keyboard event that useIOSKeyboard listens for.
|
|
43
|
+
window.dispatchEvent(
|
|
44
|
+
new CustomEvent('keyboard', {
|
|
45
|
+
detail: {
|
|
46
|
+
type: keyboardOpen ? 'show' : 'hide',
|
|
47
|
+
height: keyboardHeight,
|
|
48
|
+
duration: 300,
|
|
49
|
+
},
|
|
50
|
+
}),
|
|
51
|
+
);
|
|
52
|
+
}, [keyboardOpen]);
|
|
53
|
+
|
|
54
|
+
return <div className='h-screen relative'>{children}</div>;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const StoryPanel = ({ children, label }: PropsWithChildren<{ label: string }>) => {
|
|
58
|
+
return (
|
|
59
|
+
<Panel.Root>
|
|
60
|
+
<Panel.Toolbar asChild>
|
|
61
|
+
<Toolbar.Root>
|
|
62
|
+
{label}
|
|
63
|
+
<Toolbar.Separator />
|
|
64
|
+
{children}
|
|
65
|
+
</Toolbar.Root>
|
|
66
|
+
</Panel.Toolbar>
|
|
67
|
+
<Panel.Content asChild>
|
|
68
|
+
<Column.Root gutter='xs' classNames='py-form-chrome'>
|
|
69
|
+
<Column.Content>
|
|
70
|
+
<Flex column>
|
|
71
|
+
<Input.Root>
|
|
72
|
+
<Input.TextInput placeholder={label} />
|
|
73
|
+
</Input.Root>
|
|
74
|
+
</Flex>
|
|
75
|
+
</Column.Content>
|
|
76
|
+
</Column.Root>
|
|
77
|
+
</Panel.Content>
|
|
78
|
+
</Panel.Root>
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const DefaultStory = () => {
|
|
83
|
+
const [splitterMode, setSplitterMode] = useState<SplitterMode>('upper');
|
|
84
|
+
const [keyboardOpen, setKeyboardOpen] = useState(false);
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
setSplitterMode(splitterMode === 'both' ? 'lower' : splitterMode);
|
|
88
|
+
}, [keyboardOpen]);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<WithKeyboard>
|
|
92
|
+
<MobileLayout.Root onKeyboardOpenChange={setKeyboardOpen}>
|
|
93
|
+
<MobileLayout.Panel safe={{ top: true, bottom: splitterMode === 'upper' }}>
|
|
94
|
+
<Splitter.Root mode={splitterMode} ratio={0.5}>
|
|
95
|
+
<Splitter.Panel position='upper'>
|
|
96
|
+
<StoryPanel label='Main'>
|
|
97
|
+
{splitterMode === 'upper' && (
|
|
98
|
+
<Toolbar.IconButton icon='ph--plus--regular' label='Open' onClick={() => setSplitterMode('both')} />
|
|
99
|
+
)}
|
|
100
|
+
</StoryPanel>
|
|
101
|
+
</Splitter.Panel>
|
|
102
|
+
<Splitter.Panel position='lower'>
|
|
103
|
+
<StoryPanel label='Drawer'>
|
|
104
|
+
<Toolbar.IconButton
|
|
105
|
+
icon={splitterMode === 'lower' ? 'ph--arrow-down--regular' : 'ph--arrow-up--regular'}
|
|
106
|
+
label={splitterMode === 'lower' ? 'Collapse' : 'Expand'}
|
|
107
|
+
onClick={() => setSplitterMode((splitterMode) => (splitterMode === 'both' ? 'lower' : 'both'))}
|
|
108
|
+
/>
|
|
109
|
+
<Toolbar.IconButton icon='ph--x--regular' label='Close' onClick={() => setSplitterMode('upper')} />
|
|
110
|
+
</StoryPanel>
|
|
111
|
+
</Splitter.Panel>
|
|
112
|
+
</Splitter.Root>
|
|
113
|
+
</MobileLayout.Panel>
|
|
114
|
+
</MobileLayout.Root>
|
|
115
|
+
</WithKeyboard>
|
|
116
|
+
);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const meta: Meta<MobileLayoutRootProps> = {
|
|
120
|
+
title: 'plugins/plugin-simple-layout/components/MobileLayout',
|
|
121
|
+
component: MobileLayout.Root,
|
|
122
|
+
render: DefaultStory,
|
|
123
|
+
decorators: [withTheme(), withLayout({ layout: 'column', classNames: 'relative' })],
|
|
124
|
+
parameters: {
|
|
125
|
+
layout: 'fullscreen',
|
|
126
|
+
},
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export default meta;
|
|
130
|
+
|
|
131
|
+
type Story = StoryObj<MobileLayoutRootProps>;
|
|
132
|
+
|
|
133
|
+
export const Default: Story = {};
|