@dxos/plugin-simple-layout 0.8.4-main.69d29f4 → 0.8.4-main.74a063c4e0
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 -58
- 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 -57
- 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 -15
- 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 +9 -0
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Main.d.ts +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +18 -6
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +35 -21
- 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 -15
- 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 +5 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
- package/dist/types/src/hooks/useCompanions.d.ts +12 -0
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +3 -3
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
- package/dist/types/src/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 -13
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +18 -5
- 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 +50 -0
- package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +2 -2
- package/src/capabilities/{state/state.tsx → state.tsx} +8 -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 +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 +128 -0
- package/src/components/{Workspace → NavBranch}/index.ts +1 -1
- package/src/components/Popover/Popover.tsx +10 -9
- package/src/components/SimpleLayout/AppBar.stories.tsx +143 -0
- package/src/components/SimpleLayout/AppBar.tsx +94 -0
- package/src/components/SimpleLayout/Drawer.tsx +98 -0
- package/src/components/SimpleLayout/Main.tsx +45 -48
- package/src/components/SimpleLayout/NavBar.stories.tsx +131 -27
- package/src/components/SimpleLayout/NavBar.tsx +21 -62
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +45 -55
- package/src/components/SimpleLayout/SimpleLayout.tsx +45 -7
- package/src/components/SimpleLayout/index.ts +3 -0
- package/src/components/hooks.ts +10 -14
- package/src/components/index.ts +4 -2
- package/src/hooks/actions.ts +84 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useAppBarProps.ts +115 -0
- package/src/hooks/useCompanions.ts +22 -0
- 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 -13
- package/src/types/capabilities.ts +16 -7
- package/src/types/events.ts +3 -2
- package/dist/lib/browser/chunk-CLPGTNWJ.mjs +0 -29
- package/dist/lib/browser/chunk-CLPGTNWJ.mjs.map +0 -7
- package/dist/lib/browser/chunk-FK4M7GJV.mjs +0 -613
- package/dist/lib/browser/chunk-FK4M7GJV.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs +0 -168
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs.map +0 -7
- package/dist/lib/browser/react-root-6ARAPH3O.mjs +0 -21
- package/dist/lib/browser/react-root-6ARAPH3O.mjs.map +0 -7
- package/dist/lib/browser/react-surface-SO7B23GS.mjs +0 -39
- package/dist/lib/browser/react-surface-SO7B23GS.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-H4IGICBB.mjs +0 -45
- package/dist/lib/browser/state-H4IGICBB.mjs.map +0 -7
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs +0 -54
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs +0 -614
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-MUVVYBUE.mjs +0 -31
- package/dist/lib/node-esm/chunk-MUVVYBUE.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs +0 -169
- package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs +0 -22
- package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-FKAV56MO.mjs +0 -40
- package/dist/lib/node-esm/react-surface-FKAV56MO.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-QIU2LMLT.mjs +0 -46
- package/dist/lib/node-esm/state-QIU2LMLT.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs +0 -55
- package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs.map +0 -7
- package/dist/types/src/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 -178
- 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 -82
- package/src/components/Workspace/Workspace.tsx +0 -115
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useMemo } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Common } from '@dxos/app-framework';
|
|
8
|
-
import { useAppGraph, useOperationInvoker } from '@dxos/app-framework/react';
|
|
9
|
-
import { Graph, Node } from '@dxos/plugin-graph';
|
|
10
|
-
import { IconButton, type ThemedClassName, Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
11
|
-
import { mx, osTranslations } from '@dxos/ui-theme';
|
|
12
|
-
|
|
13
|
-
import { useSimpleLayoutState } from '../../hooks';
|
|
14
|
-
import { meta } from '../../meta';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Check if an item is a direct child of a workspace or collection.
|
|
18
|
-
* Returns true if any parent node has disposition 'workspace' or 'collection'.
|
|
19
|
-
*/
|
|
20
|
-
const isWorkspaceOrCollectionChild = (graph: Graph.ReadableGraph, itemId: string): boolean => {
|
|
21
|
-
const parents = Graph.getConnections(graph, itemId, 'inbound');
|
|
22
|
-
return parents.some(
|
|
23
|
-
(node) => node.properties.disposition === 'workspace' || node.properties.disposition === 'collection',
|
|
24
|
-
);
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export type BannerProps = ThemedClassName<{
|
|
28
|
-
node?: Node.Node;
|
|
29
|
-
}>;
|
|
30
|
-
|
|
31
|
-
export const Banner = ({ node, classNames }: BannerProps) => {
|
|
32
|
-
const { t } = useTranslation(meta.id);
|
|
33
|
-
const { state } = useSimpleLayoutState();
|
|
34
|
-
const { invokePromise } = useOperationInvoker();
|
|
35
|
-
const { graph } = useAppGraph();
|
|
36
|
-
|
|
37
|
-
const label = (node && toLocalizedString(node.properties.label, t)) ?? t('current app name', { ns: osTranslations });
|
|
38
|
-
|
|
39
|
-
// Check if current active item is a top-level workspace/collection child.
|
|
40
|
-
const isTopLevelItem = useMemo(() => {
|
|
41
|
-
if (!state.active) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
return isWorkspaceOrCollectionChild(graph, state.active);
|
|
45
|
-
}, [graph, state.active]);
|
|
46
|
-
|
|
47
|
-
const handleClick = useCallback(async () => {
|
|
48
|
-
if (state.active) {
|
|
49
|
-
// If history is empty and this is a top-level item, go to home.
|
|
50
|
-
if (state.history.length === 0 && isTopLevelItem) {
|
|
51
|
-
await invokePromise(Common.LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
52
|
-
} else {
|
|
53
|
-
// Otherwise, close (which will pop from history or clear active).
|
|
54
|
-
await invokePromise(Common.LayoutOperation.Close, { subject: [state.active] });
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
await invokePromise(Common.LayoutOperation.SwitchWorkspace, { subject: Node.RootId });
|
|
58
|
-
}
|
|
59
|
-
}, [invokePromise, state.active, state.history.length, isTopLevelItem]);
|
|
60
|
-
|
|
61
|
-
if (!node) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<Toolbar.Root role='banner' classNames={mx('grid grid-cols-[var(--rail-size)_1fr_var(--rail-size)]', classNames)}>
|
|
67
|
-
{node.id !== Node.RootId ? (
|
|
68
|
-
<IconButton
|
|
69
|
-
iconOnly
|
|
70
|
-
variant='ghost'
|
|
71
|
-
icon='ph--caret-left--regular'
|
|
72
|
-
label={t('back label')}
|
|
73
|
-
onClick={handleClick}
|
|
74
|
-
/>
|
|
75
|
-
) : (
|
|
76
|
-
<div />
|
|
77
|
-
)}
|
|
78
|
-
<h1 className={'grow text-center truncate font-medium'}>{label}</h1>
|
|
79
|
-
<IconButton iconOnly variant='ghost' icon='ph--dots-three-vertical--regular' label={t('menu label')} />
|
|
80
|
-
</Toolbar.Root>
|
|
81
|
-
);
|
|
82
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// Copyright 2025 DXOS.org
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import React, { useCallback, useEffect, useRef } from 'react';
|
|
6
|
-
|
|
7
|
-
import { Common } from '@dxos/app-framework';
|
|
8
|
-
import { useAppGraph, useOperationInvoker } from '@dxos/app-framework/react';
|
|
9
|
-
import { type Node, useConnections } from '@dxos/plugin-graph';
|
|
10
|
-
import { Avatar, Icon, Toolbar, toLocalizedString, useTranslation } from '@dxos/react-ui';
|
|
11
|
-
import { Card, Layout, Mosaic, type StackTileComponent } from '@dxos/react-ui-mosaic';
|
|
12
|
-
import { SearchList, useSearchListItem, useSearchListResults } from '@dxos/react-ui-searchlist';
|
|
13
|
-
import { mx } from '@dxos/ui-theme';
|
|
14
|
-
|
|
15
|
-
import { meta } from '../../meta';
|
|
16
|
-
import { useLoadDescendents } from '../hooks';
|
|
17
|
-
|
|
18
|
-
export type WorkspaceProps = {
|
|
19
|
-
id: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
// TODO(burdon): Rename or motivate name in comment.
|
|
26
|
-
export const Workspace = ({ id }: WorkspaceProps) => {
|
|
27
|
-
const { t } = useTranslation(meta.id);
|
|
28
|
-
const { graph } = useAppGraph();
|
|
29
|
-
|
|
30
|
-
// Expand the workspace node to load its children.
|
|
31
|
-
useLoadDescendents(id);
|
|
32
|
-
|
|
33
|
-
// Get direct children of the workspace node.
|
|
34
|
-
const children = useConnections(graph, id, 'outbound');
|
|
35
|
-
|
|
36
|
-
const { results, handleSearch } = useSearchListResults({
|
|
37
|
-
items: children,
|
|
38
|
-
extract: (child) => toLocalizedString(child.properties.label, t),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<Layout.Main toolbar>
|
|
43
|
-
<SearchList.Root onSearch={handleSearch}>
|
|
44
|
-
<Toolbar.Root>
|
|
45
|
-
<SearchList.Input placeholder={t('search placeholder')} autoFocus />
|
|
46
|
-
</Toolbar.Root>
|
|
47
|
-
<SearchList.Content>
|
|
48
|
-
<Mosaic.Container asChild>
|
|
49
|
-
<Mosaic.Viewport padding>
|
|
50
|
-
<Mosaic.Stack items={results} getId={(child) => child.id} Tile={WorkspaceChildTile} />
|
|
51
|
-
</Mosaic.Viewport>
|
|
52
|
-
</Mosaic.Container>
|
|
53
|
-
</SearchList.Content>
|
|
54
|
-
</SearchList.Root>
|
|
55
|
-
</Layout.Main>
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const WorkspaceChildTile: StackTileComponent<Node.Node> = ({ data }) => {
|
|
60
|
-
const { t } = useTranslation(meta.id);
|
|
61
|
-
const { invokeSync } = useOperationInvoker();
|
|
62
|
-
const ref = useRef<HTMLDivElement>(null);
|
|
63
|
-
const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
|
|
64
|
-
const isSelected = selectedValue === data.id;
|
|
65
|
-
|
|
66
|
-
const name = toLocalizedString(data.properties.label, t);
|
|
67
|
-
|
|
68
|
-
const handleSelect = useCallback(
|
|
69
|
-
() => invokeSync(Common.LayoutOperation.Open, { subject: [data.id] }),
|
|
70
|
-
[invokeSync, data.id],
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
// Register this item with the search context.
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (ref.current) {
|
|
76
|
-
registerItem(data.id, ref.current, handleSelect);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
return () => unregisterItem(data.id);
|
|
80
|
-
}, [data.id, handleSelect, registerItem, unregisterItem]);
|
|
81
|
-
|
|
82
|
-
// Scroll into view when selected.
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (isSelected && ref.current) {
|
|
85
|
-
ref.current.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
86
|
-
}
|
|
87
|
-
}, [isSelected]);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<Card.Root
|
|
91
|
-
ref={ref}
|
|
92
|
-
role='button'
|
|
93
|
-
fullWidth
|
|
94
|
-
tabIndex={-1} // TODO(burdon): Use Mosaic.Focus.
|
|
95
|
-
data-selected={isSelected}
|
|
96
|
-
classNames={mx('dx-focus-ring', isSelected && 'bg-hoverOverlay')}
|
|
97
|
-
onClick={handleSelect}
|
|
98
|
-
>
|
|
99
|
-
<Card.Toolbar density='coarse'>
|
|
100
|
-
<Avatar.Root>
|
|
101
|
-
<Avatar.Content
|
|
102
|
-
hue={data.properties.hue}
|
|
103
|
-
icon={data.properties.icon}
|
|
104
|
-
hueVariant='transparent'
|
|
105
|
-
variant='square'
|
|
106
|
-
size={12}
|
|
107
|
-
fallback={name}
|
|
108
|
-
/>
|
|
109
|
-
<Avatar.Label>{name}</Avatar.Label>
|
|
110
|
-
<Icon icon='ph--caret-right--regular' />
|
|
111
|
-
</Avatar.Root>
|
|
112
|
-
</Card.Toolbar>
|
|
113
|
-
</Card.Root>
|
|
114
|
-
);
|
|
115
|
-
};
|