@dxos/plugin-simple-layout 0.8.4-main.937b3ca → 0.8.4-main.9be5663bfe

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.
Files changed (247) hide show
  1. package/dist/lib/browser/index.mjs +44 -58
  2. package/dist/lib/browser/index.mjs.map +4 -4
  3. package/dist/lib/browser/meta.json +1 -1
  4. package/dist/lib/node-esm/index.mjs +44 -57
  5. package/dist/lib/node-esm/index.mjs.map +4 -4
  6. package/dist/lib/node-esm/meta.json +1 -1
  7. package/dist/types/src/SimpleLayoutPlugin.d.ts +1 -1
  8. package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
  9. package/dist/types/src/capabilities/app-graph-builder.d.ts +6 -0
  10. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -0
  11. package/dist/types/src/capabilities/index.d.ts +21 -6
  12. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  13. package/dist/types/src/capabilities/operation-handler.d.ts +6 -0
  14. package/dist/types/src/capabilities/operation-handler.d.ts.map +1 -0
  15. package/dist/types/src/capabilities/{react-root/react-root.d.ts → react-root.d.ts} +1 -1
  16. package/dist/types/src/capabilities/react-root.d.ts.map +1 -0
  17. package/dist/types/src/capabilities/react-surface.d.ts +5 -0
  18. package/dist/types/src/capabilities/react-surface.d.ts.map +1 -0
  19. package/dist/types/src/capabilities/{spotlight-dismiss/spotlight-dismiss.d.ts → spotlight-dismiss.d.ts} +1 -1
  20. package/dist/types/src/capabilities/spotlight-dismiss.d.ts.map +1 -0
  21. package/dist/types/src/capabilities/{state/state.d.ts → state.d.ts} +2 -2
  22. package/dist/types/src/capabilities/state.d.ts.map +1 -0
  23. package/dist/types/src/capabilities/url-handler.d.ts +12 -0
  24. package/dist/types/src/capabilities/url-handler.d.ts.map +1 -0
  25. package/dist/types/src/components/ContentError.stories.d.ts +26 -15
  26. package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
  27. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts +19 -0
  28. package/dist/types/src/components/DebugOverlay/DebugOverlay.d.ts.map +1 -0
  29. package/dist/types/src/components/DebugOverlay/index.d.ts +2 -0
  30. package/dist/types/src/components/DebugOverlay/index.d.ts.map +1 -0
  31. package/dist/types/src/components/Home/Home.d.ts.map +1 -1
  32. package/dist/types/src/components/Loading/Loading.d.ts +3 -0
  33. package/dist/types/src/components/Loading/Loading.d.ts.map +1 -0
  34. package/dist/types/src/components/{ContentLoading.stories.d.ts → Loading/Loading.stories.d.ts} +1 -1
  35. package/dist/types/src/components/Loading/Loading.stories.d.ts.map +1 -0
  36. package/dist/types/src/components/Loading/index.d.ts +2 -0
  37. package/dist/types/src/components/Loading/index.d.ts.map +1 -0
  38. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +35 -0
  39. package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -0
  40. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts +7 -0
  41. package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -0
  42. package/dist/types/src/components/MobileLayout/index.d.ts +2 -0
  43. package/dist/types/src/components/MobileLayout/index.d.ts.map +1 -0
  44. package/dist/types/src/components/NavBranch/NavBranch.d.ts +11 -0
  45. package/dist/types/src/components/NavBranch/NavBranch.d.ts.map +1 -0
  46. package/dist/types/src/components/NavBranch/index.d.ts +2 -0
  47. package/dist/types/src/components/NavBranch/index.d.ts.map +1 -0
  48. package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
  49. package/dist/types/src/components/SimpleLayout/AppBar.d.ts +24 -0
  50. package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
  51. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +54 -0
  52. package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -0
  53. package/dist/types/src/components/SimpleLayout/Drawer.d.ts +9 -0
  54. package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -0
  55. package/dist/types/src/components/SimpleLayout/Main.d.ts +1 -1
  56. package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
  57. package/dist/types/src/components/SimpleLayout/NavBar.d.ts +14 -6
  58. package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
  59. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +31 -21
  60. package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
  61. package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
  62. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +26 -15
  63. package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
  64. package/dist/types/src/components/SimpleLayout/index.d.ts +3 -0
  65. package/dist/types/src/components/SimpleLayout/index.d.ts.map +1 -1
  66. package/dist/types/src/components/hooks.d.ts +4 -2
  67. package/dist/types/src/components/hooks.d.ts.map +1 -1
  68. package/dist/types/src/components/index.d.ts +4 -2
  69. package/dist/types/src/components/index.d.ts.map +1 -1
  70. package/dist/types/src/hooks/actions.d.ts +19 -0
  71. package/dist/types/src/hooks/actions.d.ts.map +1 -0
  72. package/dist/types/src/hooks/index.d.ts +5 -0
  73. package/dist/types/src/hooks/index.d.ts.map +1 -1
  74. package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
  75. package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
  76. package/dist/types/src/hooks/useCompanions.d.ts +12 -0
  77. package/dist/types/src/hooks/useCompanions.d.ts.map +1 -0
  78. package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
  79. package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
  80. package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
  81. package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
  82. package/dist/types/src/hooks/useSimpleLayoutState.d.ts +3 -3
  83. package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
  84. package/dist/types/src/operations/close.d.ts +5 -0
  85. package/dist/types/src/operations/close.d.ts.map +1 -0
  86. package/dist/types/src/operations/index.d.ts +3 -0
  87. package/dist/types/src/operations/index.d.ts.map +1 -0
  88. package/dist/types/src/operations/open.d.ts +5 -0
  89. package/dist/types/src/operations/open.d.ts.map +1 -0
  90. package/dist/types/src/operations/revert-workspace.d.ts +5 -0
  91. package/dist/types/src/operations/revert-workspace.d.ts.map +1 -0
  92. package/dist/types/src/operations/set-layout-mode.d.ts +5 -0
  93. package/dist/types/src/operations/set-layout-mode.d.ts.map +1 -0
  94. package/dist/types/src/operations/set.d.ts +5 -0
  95. package/dist/types/src/operations/set.d.ts.map +1 -0
  96. package/dist/types/src/operations/state-access.d.ts +8 -0
  97. package/dist/types/src/operations/state-access.d.ts.map +1 -0
  98. package/dist/types/src/operations/switch-workspace.d.ts +5 -0
  99. package/dist/types/src/operations/switch-workspace.d.ts.map +1 -0
  100. package/dist/types/src/operations/update-complementary.d.ts +5 -0
  101. package/dist/types/src/operations/update-complementary.d.ts.map +1 -0
  102. package/dist/types/src/operations/update-dialog.d.ts +5 -0
  103. package/dist/types/src/operations/update-dialog.d.ts.map +1 -0
  104. package/dist/types/src/operations/update-popover.d.ts +5 -0
  105. package/dist/types/src/operations/update-popover.d.ts.map +1 -0
  106. package/dist/types/src/operations/update-sidebar.d.ts +5 -0
  107. package/dist/types/src/operations/update-sidebar.d.ts.map +1 -0
  108. package/dist/types/src/translations.d.ts +26 -13
  109. package/dist/types/src/translations.d.ts.map +1 -1
  110. package/dist/types/src/types/capabilities.d.ts +18 -5
  111. package/dist/types/src/types/capabilities.d.ts.map +1 -1
  112. package/dist/types/src/types/events.d.ts.map +1 -1
  113. package/dist/types/tsconfig.tsbuildinfo +1 -1
  114. package/package.json +46 -30
  115. package/src/SimpleLayoutPlugin.ts +24 -13
  116. package/src/capabilities/app-graph-builder.ts +21 -0
  117. package/src/capabilities/index.ts +13 -6
  118. package/src/capabilities/operation-handler.ts +14 -0
  119. package/src/capabilities/{react-root/react-root.tsx → react-root.tsx} +4 -4
  120. package/src/capabilities/react-surface.tsx +50 -0
  121. package/src/capabilities/{spotlight-dismiss/spotlight-dismiss.ts → spotlight-dismiss.ts} +2 -2
  122. package/src/capabilities/{state/state.tsx → state.tsx} +8 -5
  123. package/src/capabilities/url-handler.ts +161 -0
  124. package/src/components/ContentError.stories.tsx +8 -7
  125. package/src/components/DebugOverlay/DebugOverlay.tsx +96 -0
  126. package/src/components/DebugOverlay/index.ts +5 -0
  127. package/src/components/Dialog/Dialog.tsx +6 -6
  128. package/src/components/Home/Home.tsx +51 -43
  129. package/src/components/{ContentLoading.stories.tsx → Loading/Loading.stories.tsx} +5 -5
  130. package/src/components/{ContentLoading.tsx → Loading/Loading.tsx} +2 -2
  131. package/src/components/Loading/index.ts +5 -0
  132. package/src/components/MobileLayout/MobileLayout.stories.tsx +133 -0
  133. package/src/components/MobileLayout/MobileLayout.tsx +374 -0
  134. package/src/components/MobileLayout/index.ts +5 -0
  135. package/src/components/NavBranch/NavBranch.tsx +128 -0
  136. package/src/components/{Workspace → NavBranch}/index.ts +1 -1
  137. package/src/components/Popover/Popover.tsx +10 -9
  138. package/src/components/SimpleLayout/AppBar.stories.tsx +143 -0
  139. package/src/components/SimpleLayout/AppBar.tsx +94 -0
  140. package/src/components/SimpleLayout/Drawer.tsx +98 -0
  141. package/src/components/SimpleLayout/Main.tsx +45 -48
  142. package/src/components/SimpleLayout/NavBar.stories.tsx +131 -27
  143. package/src/components/SimpleLayout/NavBar.tsx +21 -62
  144. package/src/components/SimpleLayout/SimpleLayout.stories.tsx +45 -55
  145. package/src/components/SimpleLayout/SimpleLayout.tsx +45 -7
  146. package/src/components/SimpleLayout/index.ts +3 -0
  147. package/src/components/hooks.ts +10 -14
  148. package/src/components/index.ts +4 -2
  149. package/src/hooks/actions.ts +84 -0
  150. package/src/hooks/index.ts +5 -0
  151. package/src/hooks/useAppBarProps.ts +115 -0
  152. package/src/hooks/useCompanions.ts +22 -0
  153. package/src/hooks/useDrawerActions.ts +100 -0
  154. package/src/hooks/useNavbarActions.ts +87 -0
  155. package/src/hooks/useSimpleLayoutState.ts +5 -5
  156. package/src/meta.ts +1 -1
  157. package/src/operations/close.ts +34 -0
  158. package/src/operations/index.ts +16 -0
  159. package/src/operations/open.ts +63 -0
  160. package/src/operations/revert-workspace.ts +22 -0
  161. package/src/operations/set-layout-mode.ts +12 -0
  162. package/src/operations/set.ts +23 -0
  163. package/src/operations/state-access.ts +19 -0
  164. package/src/operations/switch-workspace.ts +26 -0
  165. package/src/operations/update-complementary.ts +35 -0
  166. package/src/operations/update-dialog.ts +28 -0
  167. package/src/operations/update-popover.ts +35 -0
  168. package/src/operations/update-sidebar.ts +12 -0
  169. package/src/translations.ts +21 -13
  170. package/src/types/capabilities.ts +16 -7
  171. package/src/types/events.ts +3 -2
  172. package/dist/lib/browser/chunk-CLPGTNWJ.mjs +0 -29
  173. package/dist/lib/browser/chunk-CLPGTNWJ.mjs.map +0 -7
  174. package/dist/lib/browser/chunk-FK4M7GJV.mjs +0 -613
  175. package/dist/lib/browser/chunk-FK4M7GJV.mjs.map +0 -7
  176. package/dist/lib/browser/operation-resolver-LTB63NKP.mjs +0 -168
  177. package/dist/lib/browser/operation-resolver-LTB63NKP.mjs.map +0 -7
  178. package/dist/lib/browser/react-root-6ARAPH3O.mjs +0 -21
  179. package/dist/lib/browser/react-root-6ARAPH3O.mjs.map +0 -7
  180. package/dist/lib/browser/react-surface-SO7B23GS.mjs +0 -39
  181. package/dist/lib/browser/react-surface-SO7B23GS.mjs.map +0 -7
  182. package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs +0 -66
  183. package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +0 -7
  184. package/dist/lib/browser/state-H4IGICBB.mjs +0 -45
  185. package/dist/lib/browser/state-H4IGICBB.mjs.map +0 -7
  186. package/dist/lib/browser/url-handler-7CFGTLNG.mjs +0 -54
  187. package/dist/lib/browser/url-handler-7CFGTLNG.mjs.map +0 -7
  188. package/dist/lib/node-esm/chunk-EGFZAVBD.mjs +0 -614
  189. package/dist/lib/node-esm/chunk-EGFZAVBD.mjs.map +0 -7
  190. package/dist/lib/node-esm/chunk-MUVVYBUE.mjs +0 -31
  191. package/dist/lib/node-esm/chunk-MUVVYBUE.mjs.map +0 -7
  192. package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs +0 -169
  193. package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs.map +0 -7
  194. package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs +0 -22
  195. package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs.map +0 -7
  196. package/dist/lib/node-esm/react-surface-FKAV56MO.mjs +0 -40
  197. package/dist/lib/node-esm/react-surface-FKAV56MO.mjs.map +0 -7
  198. package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs +0 -68
  199. package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +0 -7
  200. package/dist/lib/node-esm/state-QIU2LMLT.mjs +0 -46
  201. package/dist/lib/node-esm/state-QIU2LMLT.mjs.map +0 -7
  202. package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs +0 -55
  203. package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs.map +0 -7
  204. package/dist/types/src/capabilities/operation-resolver/index.d.ts +0 -3
  205. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +0 -1
  206. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +0 -5
  207. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +0 -1
  208. package/dist/types/src/capabilities/react-root/index.d.ts +0 -6
  209. package/dist/types/src/capabilities/react-root/index.d.ts.map +0 -1
  210. package/dist/types/src/capabilities/react-root/react-root.d.ts.map +0 -1
  211. package/dist/types/src/capabilities/react-surface/index.d.ts +0 -3
  212. package/dist/types/src/capabilities/react-surface/index.d.ts.map +0 -1
  213. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +0 -5
  214. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +0 -1
  215. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +0 -3
  216. package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +0 -1
  217. package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +0 -1
  218. package/dist/types/src/capabilities/state/index.d.ts +0 -13
  219. package/dist/types/src/capabilities/state/index.d.ts.map +0 -1
  220. package/dist/types/src/capabilities/state/state.d.ts.map +0 -1
  221. package/dist/types/src/capabilities/url-handler/index.d.ts +0 -3
  222. package/dist/types/src/capabilities/url-handler/index.d.ts.map +0 -1
  223. package/dist/types/src/capabilities/url-handler/url-handler.d.ts +0 -10
  224. package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +0 -1
  225. package/dist/types/src/components/ContentError.d.ts +0 -5
  226. package/dist/types/src/components/ContentError.d.ts.map +0 -1
  227. package/dist/types/src/components/ContentLoading.d.ts +0 -3
  228. package/dist/types/src/components/ContentLoading.d.ts.map +0 -1
  229. package/dist/types/src/components/ContentLoading.stories.d.ts.map +0 -1
  230. package/dist/types/src/components/SimpleLayout/Banner.d.ts +0 -8
  231. package/dist/types/src/components/SimpleLayout/Banner.d.ts.map +0 -1
  232. package/dist/types/src/components/Workspace/Workspace.d.ts +0 -9
  233. package/dist/types/src/components/Workspace/Workspace.d.ts.map +0 -1
  234. package/dist/types/src/components/Workspace/index.d.ts +0 -2
  235. package/dist/types/src/components/Workspace/index.d.ts.map +0 -1
  236. package/src/capabilities/operation-resolver/index.ts +0 -10
  237. package/src/capabilities/operation-resolver/operation-resolver.ts +0 -178
  238. package/src/capabilities/react-root/index.ts +0 -7
  239. package/src/capabilities/react-surface/index.ts +0 -7
  240. package/src/capabilities/react-surface/react-surface.tsx +0 -40
  241. package/src/capabilities/spotlight-dismiss/index.ts +0 -7
  242. package/src/capabilities/state/index.ts +0 -9
  243. package/src/capabilities/url-handler/index.ts +0 -7
  244. package/src/capabilities/url-handler/url-handler.ts +0 -80
  245. package/src/components/ContentError.tsx +0 -23
  246. package/src/components/SimpleLayout/Banner.tsx +0 -82
  247. 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
- };