@dxos/plugin-navtree 0.8.4-main.84f28bd → 0.8.4-main.9735255

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 (204) hide show
  1. package/dist/lib/browser/app-graph-builder-RSMA6I22.mjs +43 -0
  2. package/dist/lib/browser/app-graph-builder-RSMA6I22.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-6YPQ625I.mjs +1293 -0
  4. package/dist/lib/browser/chunk-6YPQ625I.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-AGQDZBPL.mjs +23 -0
  6. package/dist/lib/browser/chunk-AGQDZBPL.mjs.map +7 -0
  7. package/dist/lib/browser/chunk-YKTYPINZ.mjs +19 -0
  8. package/dist/lib/browser/chunk-YKTYPINZ.mjs.map +7 -0
  9. package/dist/lib/browser/index.mjs +84 -96
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/{node-esm/keyboard-MOZWHFUM.mjs → browser/keyboard-32EH3N4K.mjs} +20 -20
  12. package/dist/lib/browser/keyboard-32EH3N4K.mjs.map +7 -0
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/operation-resolver-IB75DC5O.mjs +52 -0
  15. package/dist/lib/browser/operation-resolver-IB75DC5O.mjs.map +7 -0
  16. package/dist/lib/browser/react-surface-F6CVMS3Y.mjs +58 -0
  17. package/dist/lib/browser/react-surface-F6CVMS3Y.mjs.map +7 -0
  18. package/dist/lib/browser/state-EVYQOUI3.mjs +120 -0
  19. package/dist/lib/browser/state-EVYQOUI3.mjs.map +7 -0
  20. package/dist/types/src/NavTreePlugin.d.ts +2 -1
  21. package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
  22. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts +6 -0
  23. package/dist/types/src/capabilities/app-graph-builder/app-graph-builder.d.ts.map +1 -0
  24. package/dist/types/src/capabilities/app-graph-builder/index.d.ts +3 -0
  25. package/dist/types/src/capabilities/app-graph-builder/index.d.ts.map +1 -0
  26. package/dist/types/src/capabilities/index.d.ts +5 -105
  27. package/dist/types/src/capabilities/index.d.ts.map +1 -1
  28. package/dist/types/src/capabilities/keyboard/index.d.ts +3 -0
  29. package/dist/types/src/capabilities/keyboard/index.d.ts.map +1 -0
  30. package/dist/types/src/capabilities/keyboard/keyboard.d.ts +5 -0
  31. package/dist/types/src/capabilities/keyboard/keyboard.d.ts.map +1 -0
  32. package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
  33. package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
  34. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
  35. package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
  36. package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
  37. package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
  38. package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
  39. package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
  40. package/dist/types/src/capabilities/state/index.d.ts +3 -0
  41. package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
  42. package/dist/types/src/capabilities/state/state.d.ts +6 -0
  43. package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
  44. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts +3 -2
  45. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -1
  46. package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -1
  47. package/dist/types/src/components/NavTree/NavTree.d.ts +32 -3
  48. package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
  49. package/dist/types/src/components/NavTree/NavTree.stories.d.ts +29 -4
  50. package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
  51. package/dist/types/src/components/NavTreeContainer.d.ts +8 -1
  52. package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
  53. package/dist/types/src/components/NavTreeDocumentTitle.d.ts +1 -1
  54. package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
  55. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +6 -6
  56. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
  57. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +33 -4
  58. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -1
  59. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +2 -2
  60. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -1
  61. package/dist/types/src/components/Sidebar/L0Menu.d.ts +6 -4
  62. package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
  63. package/dist/types/src/components/Sidebar/L1Panel.d.ts +5 -6
  64. package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
  65. package/dist/types/src/components/Sidebar/L1Tabs.d.ts +12 -0
  66. package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -0
  67. package/dist/types/src/components/Sidebar/index.d.ts +1 -0
  68. package/dist/types/src/components/Sidebar/index.d.ts.map +1 -1
  69. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -1
  70. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts +8 -5
  71. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -1
  72. package/dist/types/src/components/index.d.ts +1 -1
  73. package/dist/types/src/components/index.d.ts.map +1 -1
  74. package/dist/types/src/components/types.d.ts +8 -8
  75. package/dist/types/src/components/types.d.ts.map +1 -1
  76. package/dist/types/src/experimental/Tree.d.ts +4 -5
  77. package/dist/types/src/experimental/Tree.d.ts.map +1 -1
  78. package/dist/types/src/experimental/Tree.stories.d.ts +7 -4
  79. package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
  80. package/dist/types/src/hooks.d.ts +32 -1
  81. package/dist/types/src/hooks.d.ts.map +1 -1
  82. package/dist/types/src/index.d.ts +1 -2
  83. package/dist/types/src/index.d.ts.map +1 -1
  84. package/dist/types/src/meta.d.ts +3 -4
  85. package/dist/types/src/meta.d.ts.map +1 -1
  86. package/dist/types/src/testing/app-graph-builder.d.ts +2 -3
  87. package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -1
  88. package/dist/types/src/testing/generator.d.ts +5 -6
  89. package/dist/types/src/testing/generator.d.ts.map +1 -1
  90. package/dist/types/src/testing/update-state.d.ts +2 -2
  91. package/dist/types/src/testing/update-state.d.ts.map +1 -1
  92. package/dist/types/src/translations.d.ts +1 -0
  93. package/dist/types/src/translations.d.ts.map +1 -1
  94. package/dist/types/src/types/capabilities.d.ts +16 -0
  95. package/dist/types/src/types/capabilities.d.ts.map +1 -0
  96. package/dist/types/src/types/events.d.ts +5 -0
  97. package/dist/types/src/types/events.d.ts.map +1 -0
  98. package/dist/types/src/types/index.d.ts +4 -0
  99. package/dist/types/src/types/index.d.ts.map +1 -0
  100. package/dist/types/src/{types.d.ts → types/schema.d.ts} +10 -9
  101. package/dist/types/src/types/schema.d.ts.map +1 -0
  102. package/dist/types/src/util.d.ts +8 -9
  103. package/dist/types/src/util.d.ts.map +1 -1
  104. package/dist/types/tsconfig.tsbuildinfo +1 -1
  105. package/package.json +55 -55
  106. package/src/NavTreePlugin.tsx +65 -83
  107. package/src/capabilities/app-graph-builder/app-graph-builder.ts +41 -0
  108. package/src/capabilities/app-graph-builder/index.ts +7 -0
  109. package/src/capabilities/index.ts +5 -9
  110. package/src/capabilities/keyboard/index.ts +7 -0
  111. package/src/capabilities/keyboard/keyboard.ts +65 -0
  112. package/src/capabilities/operation-resolver/index.ts +7 -0
  113. package/src/capabilities/operation-resolver/operation-resolver.ts +41 -0
  114. package/src/capabilities/react-surface/index.ts +7 -0
  115. package/src/capabilities/react-surface/react-surface.tsx +54 -0
  116. package/src/capabilities/state/index.ts +7 -0
  117. package/src/capabilities/state/state.ts +121 -0
  118. package/src/components/CommandsDialog/CommandsDialog.tsx +109 -98
  119. package/src/components/CommandsDialog/CommandsTrigger.tsx +8 -19
  120. package/src/components/NavTree/NavTree.stories.tsx +98 -93
  121. package/src/components/NavTree/NavTree.tsx +12 -18
  122. package/src/components/NavTreeContainer.tsx +281 -258
  123. package/src/components/NavTreeDocumentTitle.tsx +5 -4
  124. package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +20 -12
  125. package/src/components/NavTreeItem/NavTreeItemAction.tsx +28 -21
  126. package/src/components/NavTreeItem/NavTreeItemColumns.tsx +38 -32
  127. package/src/components/Sidebar/L0Menu.tsx +114 -139
  128. package/src/components/Sidebar/L1Panel.tsx +76 -99
  129. package/src/components/Sidebar/L1Tabs.tsx +33 -0
  130. package/src/components/Sidebar/index.ts +1 -0
  131. package/src/components/UserAccountAvatar/UserAccountAvatar.stories.tsx +9 -8
  132. package/src/components/UserAccountAvatar/UserAccountAvatar.tsx +20 -12
  133. package/src/components/index.ts +2 -1
  134. package/src/components/types.ts +9 -8
  135. package/src/experimental/Tree.stories.tsx +36 -38
  136. package/src/experimental/Tree.tsx +17 -35
  137. package/src/hooks.ts +54 -2
  138. package/src/index.ts +1 -2
  139. package/src/meta.ts +11 -8
  140. package/src/testing/app-graph-builder.ts +159 -234
  141. package/src/testing/generator.ts +20 -18
  142. package/src/testing/update-state.ts +6 -6
  143. package/src/translations.ts +1 -0
  144. package/src/types/capabilities.ts +21 -0
  145. package/src/types/events.ts +11 -0
  146. package/src/types/index.ts +7 -0
  147. package/src/{types.ts → types/schema.ts} +9 -8
  148. package/src/util.ts +14 -35
  149. package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs +0 -45
  150. package/dist/lib/browser/app-graph-builder-5J4LRWDX.mjs.map +0 -7
  151. package/dist/lib/browser/chunk-ERDGQTH5.mjs +0 -16
  152. package/dist/lib/browser/chunk-ERDGQTH5.mjs.map +0 -7
  153. package/dist/lib/browser/chunk-TZA65AKW.mjs +0 -1428
  154. package/dist/lib/browser/chunk-TZA65AKW.mjs.map +0 -7
  155. package/dist/lib/browser/chunk-WCARAZ7J.mjs +0 -15
  156. package/dist/lib/browser/chunk-WCARAZ7J.mjs.map +0 -7
  157. package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs +0 -47
  158. package/dist/lib/browser/intent-resolver-3XYN2CBU.mjs.map +0 -7
  159. package/dist/lib/browser/keyboard-QRS6WOQH.mjs +0 -51
  160. package/dist/lib/browser/keyboard-QRS6WOQH.mjs.map +0 -7
  161. package/dist/lib/browser/react-surface-N2HPMYCU.mjs +0 -51
  162. package/dist/lib/browser/react-surface-N2HPMYCU.mjs.map +0 -7
  163. package/dist/lib/browser/state-54DY3DOY.mjs +0 -117
  164. package/dist/lib/browser/state-54DY3DOY.mjs.map +0 -7
  165. package/dist/lib/node-esm/app-graph-builder-GY7GCTGU.mjs +0 -46
  166. package/dist/lib/node-esm/app-graph-builder-GY7GCTGU.mjs.map +0 -7
  167. package/dist/lib/node-esm/chunk-CY7QWR4R.mjs +0 -1429
  168. package/dist/lib/node-esm/chunk-CY7QWR4R.mjs.map +0 -7
  169. package/dist/lib/node-esm/chunk-P2JGW3WR.mjs +0 -18
  170. package/dist/lib/node-esm/chunk-P2JGW3WR.mjs.map +0 -7
  171. package/dist/lib/node-esm/chunk-V3QXFDDP.mjs +0 -16
  172. package/dist/lib/node-esm/chunk-V3QXFDDP.mjs.map +0 -7
  173. package/dist/lib/node-esm/index.mjs +0 -150
  174. package/dist/lib/node-esm/index.mjs.map +0 -7
  175. package/dist/lib/node-esm/intent-resolver-R7UNPSZY.mjs +0 -48
  176. package/dist/lib/node-esm/intent-resolver-R7UNPSZY.mjs.map +0 -7
  177. package/dist/lib/node-esm/keyboard-MOZWHFUM.mjs.map +0 -7
  178. package/dist/lib/node-esm/meta.json +0 -1
  179. package/dist/lib/node-esm/react-surface-EW5FDMW4.mjs +0 -52
  180. package/dist/lib/node-esm/react-surface-EW5FDMW4.mjs.map +0 -7
  181. package/dist/lib/node-esm/state-Z3OTRC2I.mjs +0 -118
  182. package/dist/lib/node-esm/state-Z3OTRC2I.mjs.map +0 -7
  183. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  184. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  185. package/dist/types/src/capabilities/capabilities.d.ts +0 -21
  186. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  187. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  188. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  189. package/dist/types/src/capabilities/keyboard.d.ts +0 -4
  190. package/dist/types/src/capabilities/keyboard.d.ts.map +0 -1
  191. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  192. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  193. package/dist/types/src/capabilities/state.d.ts +0 -20
  194. package/dist/types/src/capabilities/state.d.ts.map +0 -1
  195. package/dist/types/src/events.d.ts +0 -4
  196. package/dist/types/src/events.d.ts.map +0 -1
  197. package/dist/types/src/types.d.ts.map +0 -1
  198. package/src/capabilities/app-graph-builder.ts +0 -52
  199. package/src/capabilities/capabilities.ts +0 -20
  200. package/src/capabilities/intent-resolver.ts +0 -37
  201. package/src/capabilities/keyboard.ts +0 -59
  202. package/src/capabilities/react-surface.tsx +0 -45
  203. package/src/capabilities/state.ts +0 -104
  204. package/src/events.ts +0 -11
@@ -0,0 +1,33 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import React from 'react';
6
+
7
+ import { type Node } from '@dxos/app-graph';
8
+
9
+ import { l0ItemType } from '../../util';
10
+
11
+ import { L1Panel, type L1PanelProps } from './L1Panel';
12
+
13
+ export type L1TabsProps = Pick<L1PanelProps, 'open' | 'currentItemId' | 'onBack'> & {
14
+ path: string[];
15
+ topLevelItems: Node.Node[];
16
+ };
17
+
18
+ /**
19
+ * Each workspace is an L1 tab.
20
+ */
21
+ export const L1Tabs = ({ topLevelItems, onBack, ...props }: L1TabsProps) => {
22
+ return (
23
+ <>
24
+ {topLevelItems.map((item) => {
25
+ const type = l0ItemType(item);
26
+ if (type === 'tab') {
27
+ return <L1Panel key={item.id} item={item} {...props} onBack={onBack} />;
28
+ }
29
+ return null;
30
+ })}
31
+ </>
32
+ );
33
+ };
@@ -4,3 +4,4 @@
4
4
 
5
5
  export * from './L0Menu';
6
6
  export * from './L1Panel';
7
+ export * from './L1Tabs';
@@ -2,20 +2,21 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
5
+ import { type Meta, type StoryObj } from '@storybook/react-vite';
6
6
 
7
- import { type Meta } from '@storybook/react-vite';
8
-
9
- import { withTheme } from '@dxos/storybook-utils';
7
+ import { withTheme } from '@dxos/react-ui/testing';
10
8
 
11
9
  import { UserAccountAvatar } from './UserAccountAvatar';
12
10
 
13
- const meta: Meta<typeof UserAccountAvatar> = {
11
+ const meta = {
14
12
  title: 'plugins/plugin-navtree/UserAccountAvatar',
15
- component: UserAccountAvatar,
13
+
16
14
  decorators: [withTheme],
17
- };
15
+ component: UserAccountAvatar,
16
+ } satisfies Meta<typeof UserAccountAvatar>;
18
17
 
19
18
  export default meta;
20
19
 
21
- export const Default = {};
20
+ type Story = StoryObj<typeof meta>;
21
+
22
+ export const Default: Story = {};
@@ -7,6 +7,8 @@ import React from 'react';
7
7
  import { Avatar, type AvatarStatus, type Size } from '@dxos/react-ui';
8
8
  import { hexToFallback } from '@dxos/util';
9
9
 
10
+ import { L0ItemActiveTabIndicator } from '../Sidebar';
11
+
10
12
  export type UserAccountAvatarProps = {
11
13
  size?: Size;
12
14
  userId?: string;
@@ -19,17 +21,23 @@ export const UserAccountAvatar = ({ size, userId, hue, emoji, status }: UserAcco
19
21
  const fallbackValue = hexToFallback(userId ?? '0');
20
22
 
21
23
  return (
22
- <div className='grid place-items-center' data-joyride='welcome/account'>
23
- <Avatar.Root>
24
- <Avatar.Content
25
- variant='circle'
26
- size={size ?? 12}
27
- status={status ?? 'active'}
28
- hue={hue || fallbackValue.hue}
29
- fallback={emoji || fallbackValue.emoji}
30
- data-testid='treeView.userAccount'
31
- />
32
- </Avatar.Root>
33
- </div>
24
+ <>
25
+ <L0ItemActiveTabIndicator classNames='inset-block-6' />
26
+ <div
27
+ className='grid place-items-center dx-focus-ring-group-indicator rounded-full'
28
+ data-joyride='welcome/account'
29
+ >
30
+ <Avatar.Root>
31
+ <Avatar.Content
32
+ variant='circle'
33
+ size={size ?? 12}
34
+ status={status ?? 'active'}
35
+ hue={hue || fallbackValue.hue}
36
+ fallback={emoji || fallbackValue.emoji}
37
+ data-testid='treeView.userAccount'
38
+ />
39
+ </Avatar.Root>
40
+ </div>
41
+ </>
34
42
  );
35
43
  };
@@ -7,4 +7,5 @@ export * from './NavTree';
7
7
  export * from './NavTreeContainer';
8
8
  export * from './NavTreeContext';
9
9
  export * from './NavTreeDocumentTitle';
10
- export * from './types';
10
+
11
+ export type * from './types';
@@ -4,33 +4,34 @@
4
4
 
5
5
  import type { FC } from 'react';
6
6
 
7
- import type { Node } from '@dxos/app-graph';
7
+ import { type Node } from '@dxos/app-graph';
8
8
  import type { Density } from '@dxos/react-ui';
9
9
  import type { TreeProps } from '@dxos/react-ui-list';
10
10
  import type { MaybePromise } from '@dxos/util';
11
11
 
12
- import type { L1PanelProps } from './Sidebar';
13
12
  import type { FlattenedActions, NavTreeItemGraphNode } from '../types';
14
13
 
14
+ import type { L1PanelProps } from './Sidebar';
15
+
15
16
  export type NavTreeContextValue = Pick<
16
17
  TreeProps<NavTreeItemGraphNode, { disposition?: string; sort?: boolean }>,
17
- 'useItems' | 'getProps' | 'isCurrent' | 'isOpen' | 'canDrop' | 'onOpenChange' | 'onSelect'
18
+ 'useItems' | 'getProps' | 'useIsCurrent' | 'useIsOpen' | 'blockInstruction' | 'canDrop' | 'onOpenChange' | 'onSelect'
18
19
  > &
19
20
  Pick<L1PanelProps, 'onBack'> & {
20
21
  tab: string;
21
22
  topbar?: boolean;
22
23
  popoverAnchorId?: string;
23
- renderItemEnd?: FC<{ node: Node; open: boolean }>;
24
- getActions: (node: Node) => FlattenedActions;
25
- loadDescendents?: (node: Node) => MaybePromise<void>;
26
- isAlternateTree?: (path: string[], item: NavTreeItemGraphNode) => boolean;
24
+ renderItemEnd?: FC<{ node: Node.Node; open: boolean }>;
25
+ useActions: (node: Node.Node) => FlattenedActions;
26
+ loadDescendents?: (node: Node.Node) => MaybePromise<void>;
27
+ useIsAlternateTree?: (path: string[], item: NavTreeItemGraphNode) => boolean;
27
28
  setAlternateTree?: (path: string[], open: boolean) => void;
28
29
  onTabChange?: (node: NavTreeItemGraphNode) => void;
29
30
  };
30
31
 
31
32
  export type NavTreeItemColumnsProps = {
32
33
  path: string[];
33
- item: Node;
34
+ item: Node.Node;
34
35
  open: boolean;
35
36
  density?: Density;
36
37
  };
@@ -2,15 +2,13 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import '@dxos-theme';
6
-
7
- import { House, List, Planet, PlusCircle, Sailboat } from '@phosphor-icons/react';
8
5
  import { type Meta } from '@storybook/react-vite';
9
6
  import React, { type JSX, type PropsWithChildren, useEffect, useState } from 'react';
10
7
 
11
8
  import { faker } from '@dxos/random';
12
- import { modalSurface, mx } from '@dxos/react-ui-theme';
13
- import { withLayout, withTheme } from '@dxos/storybook-utils';
9
+ import { Icon, IconButton } from '@dxos/react-ui';
10
+ import { withLayout, withTheme } from '@dxos/react-ui/testing';
11
+ import { mx } from '@dxos/ui-theme';
14
12
 
15
13
  import { type ItemMap, Tree, type TreeNodeData, type TreeProps, visitNodes, visitor } from './Tree';
16
14
 
@@ -32,7 +30,7 @@ const Container = ({ children, sidebar }: PropsWithChildren<{ sidebar: JSX.Eleme
32
30
  <div className='flex'>
33
31
  {/* TODO(burdon): Custom thin scrollbar. */}
34
32
  {/* TODO(burdon): Horizontal scrolling within navtree? */}
35
- <div className='flex flex-col overflow-y-auto w-[300px] bg-neutral-100 dark:bg-neutral-950'>{sidebar}</div>
33
+ <div className='flex flex-col overflow-y-auto is-[300px] bg-neutral-100 dark:bg-neutral-950'>{sidebar}</div>
36
34
  <div className='flex flex-col grow overflow-hidden'>{children}</div>
37
35
  </div>
38
36
  );
@@ -48,7 +46,7 @@ const data: TreeNodeData[] = [
48
46
  id: faker.string.uuid(),
49
47
  title: 'plugins/Personal Space',
50
48
  color: 'text-green-400',
51
- Icon: House,
49
+ iconName: 'ph--house--regular',
52
50
  children: [
53
51
  {
54
52
  id: faker.string.uuid(),
@@ -83,7 +81,7 @@ const data: TreeNodeData[] = [
83
81
  {
84
82
  id: faker.string.uuid(),
85
83
  title: faker.commerce.productName(),
86
- Icon: Planet,
84
+ iconName: 'ph--planet--regular',
87
85
  children: [
88
86
  {
89
87
  id: faker.string.uuid(),
@@ -94,38 +92,17 @@ const data: TreeNodeData[] = [
94
92
  {
95
93
  id: faker.string.uuid(),
96
94
  title: faker.commerce.productName(),
97
- Icon: Sailboat,
95
+ iconName: 'ph--sailboat--regular',
98
96
  },
99
97
  {
100
98
  id: faker.string.uuid(),
101
99
  title: faker.commerce.productName(),
102
- Icon: Planet,
100
+ iconName: 'ph--planet--regular',
103
101
  },
104
102
  ],
105
103
  },
106
104
  ];
107
105
 
108
- export const Default = () => {
109
- return <Container sidebar={<Sidebar mutate />} />;
110
- };
111
-
112
- export const Visitor = () => {
113
- const [items] = useState(data);
114
- const root = items[0];
115
- const [openItems] = useState<ItemMap>({ [root.children![0].id]: true });
116
- return (
117
- <div className='flex flex-col'>
118
- {Array.from(visitor(root, openItems)).map(({ node: { id, title }, depth }) => (
119
- <div key={id} className='grid grid-cols-[40px_400px_400px] font-mono'>
120
- <div>{depth}</div>
121
- <div>{id}</div>
122
- <div>{title}</div>
123
- </div>
124
- ))}
125
- </div>
126
- );
127
- };
128
-
129
106
  const Sidebar = ({ mutate }: { mutate?: boolean }) => {
130
107
  const [items, setItems] = useState(data);
131
108
  const root = items[0];
@@ -181,7 +158,7 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
181
158
  setItems((items) => {
182
159
  items[0].children?.push({
183
160
  id: faker.string.uuid(),
184
- Icon: Planet,
161
+ iconName: 'ph--planet--regular',
185
162
  title: faker.commerce.productName(),
186
163
  });
187
164
 
@@ -212,21 +189,42 @@ const Sidebar = ({ mutate }: { mutate?: boolean }) => {
212
189
  />
213
190
  </div>
214
191
 
215
- <div className='flex items-center my-2 px-2 gap-2'>
216
- <PlusCircle onClick={handleCreateSpace} />
192
+ <div className='flex items-center my-2 pli-2 gap-2'>
193
+ <IconButton icon='ph--plus-circle--regular' iconOnly label='Create space' onClick={handleCreateSpace} />
217
194
  <span className='grow text-sm' onClick={handleCreateSpace}>
218
195
  New space
219
196
  </span>
220
- <List />
197
+ <Icon icon='ph--list--regular' />
221
198
  </div>
222
199
  </div>
223
200
  );
224
201
  };
225
202
 
226
- const meta: Meta = {
203
+ const meta = {
227
204
  title: 'plugins/plugin-navtree/experimental/Tree',
228
205
  component: Tree,
229
- decorators: [withTheme, withLayout({ fullscreen: true, classNames: modalSurface })],
230
- };
206
+ decorators: [withTheme, withLayout({ layout: 'column' })],
207
+ } satisfies Meta<typeof Tree>;
231
208
 
232
209
  export default meta;
210
+
211
+ export const Default = () => {
212
+ return <Container sidebar={<Sidebar mutate />} />;
213
+ };
214
+
215
+ export const Visitor = () => {
216
+ const [items] = useState(data);
217
+ const root = items[0];
218
+ const [openItems] = useState<ItemMap>({ [root.children![0].id]: true });
219
+ return (
220
+ <div className='flex flex-col'>
221
+ {Array.from(visitor(root, openItems)).map(({ node: { id, title }, depth }) => (
222
+ <div key={id} className='grid grid-cols-[40px_400px_400px] font-mono'>
223
+ <div>{depth}</div>
224
+ <div>{id}</div>
225
+ <div>{title}</div>
226
+ </div>
227
+ ))}
228
+ </div>
229
+ );
230
+ };
@@ -2,34 +2,25 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { CaretRight, Circle, File, Folder, type Icon, type IconProps, Plus, UserCircle } from '@phosphor-icons/react';
6
5
  import React, { type HTMLAttributes, type PropsWithChildren } from 'react';
7
6
 
8
- import { type ClassNameValue, type Size } from '@dxos/react-ui';
9
- import { getSize, mx } from '@dxos/react-ui-theme';
10
-
11
- // TODO(burdon): Rounded border if first/last.
12
- const styles = {
13
- hover: 'hover:bg-slate-400 dark:hover:bg-slate-800',
14
- selected: '!bg-slate-300 dark:!bg-slate-700',
15
- };
7
+ import { type ClassNameValue, Icon, type Size } from '@dxos/react-ui';
8
+ import { mx } from '@dxos/ui-theme';
16
9
 
17
10
  export const IconButton = ({
18
- Icon,
11
+ iconName,
19
12
  classNames,
20
13
  size = 4,
21
14
  onClick,
22
- ...props
23
15
  }: {
24
- Icon: Icon;
16
+ iconName: string;
25
17
  classNames?: ClassNameValue;
26
18
  size?: Size;
27
- } & Pick<IconProps, 'weight'> &
28
- Pick<HTMLAttributes<HTMLDivElement>, 'onClick'>) => {
19
+ } & Pick<HTMLAttributes<HTMLDivElement>, 'onClick'>) => {
29
20
  // TODO(burdon): Density aware.
30
21
  return (
31
- <div className={mx('flex w-6 h-6 items-center justify-center select-none', classNames)} onClick={onClick}>
32
- <Icon className={mx('cursor-pointer', getSize(size))} {...props} />
22
+ <div className={mx('flex is-6 bs-6 items-center justify-center select-none', classNames)} onClick={onClick}>
23
+ <Icon icon={iconName} classNames='cursor-pointer' size={size} />
33
24
  </div>
34
25
  );
35
26
  };
@@ -37,7 +28,7 @@ export const IconButton = ({
37
28
  export type TreeNodeData = {
38
29
  id: string;
39
30
  title: string;
40
- Icon?: Icon;
31
+ iconName?: string;
41
32
  color?: string;
42
33
  children?: TreeNodeData[];
43
34
  };
@@ -123,9 +114,8 @@ const StateIcon = ({ node, open, selected, active }: TreeNodeProps) => {
123
114
  // TODO(burdon): No animation if opening/closing folder.
124
115
  return (
125
116
  <IconButton
126
- Icon={isActive ? UserCircle : Circle}
117
+ iconName={isActive ? 'ph--user-circle--regular' : 'ph--circle--regular'}
127
118
  size={4}
128
- weight={selected?.[id] ? 'fill' : 'duotone'}
129
119
  classNames={mx(
130
120
  'text-slate-500',
131
121
  !isChildActive && 'opacity-0 transition duration-500',
@@ -143,7 +133,7 @@ const OpenIcon = ({
143
133
  return (
144
134
  (children?.length && open && (
145
135
  <IconButton
146
- Icon={CaretRight}
136
+ iconName='ph--caret-right--regular'
147
137
  size={3}
148
138
  classNames={mx('transition duration-200', open?.[id] ? 'rotate-90' : 'transform-none')}
149
139
  onClick={(ev) => {
@@ -157,23 +147,15 @@ const OpenIcon = ({
157
147
 
158
148
  // TODO(burdon): Drag handle,
159
149
  const ItemIcon = ({
160
- node: { children, Icon = children?.length ? Folder : File, color },
150
+ node: { children, iconName = children?.length ? 'ph--folder--regular' : 'ph--file--regular', color },
161
151
  }: Pick<TreeNodeProps, 'node'>) => {
162
- return (
163
- (Icon && (
164
- <IconButton
165
- Icon={Icon}
166
- classNames={color ?? 'text-neutral-700 dark:text-neutral-300'}
167
- weight={color ? 'duotone' : 'regular'}
168
- />
169
- )) || <div />
170
- );
152
+ return (iconName && <IconButton iconName={iconName} classNames={color ?? 'text-subdued'} />) || <div />;
171
153
  };
172
154
 
173
155
  const MenuItem = ({ node: { id }, onMenuAction }: Pick<TreeNodeProps, 'node' | 'onMenuAction'>) => {
174
156
  return (
175
157
  <IconButton
176
- Icon={Plus}
158
+ iconName='ph--plus--regular'
177
159
  classNames='invisible group-hover:visible'
178
160
  onClick={(ev) => {
179
161
  ev.stopPropagation();
@@ -211,9 +193,9 @@ export const TreeNodeRow = (props: TreeNodeProps & { className?: string }) => {
211
193
  <Grid
212
194
  style={{ paddingLeft: `${(depth - 1) * 24}px` }}
213
195
  className={mx(
214
- 'group w-full items-center cursor-pointer',
215
- styles.hover,
216
- selected?.[id] && styles.selected,
196
+ 'group is-full items-center cursor-pointer bg-hoverSurface',
197
+ // TODO(burdon): Use data-active.
198
+ selected?.[id] && 'bg-activeSurface',
217
199
  className,
218
200
  )}
219
201
  onClick={() => selected && onChangeSelected?.(id, !selected[id])}
@@ -256,7 +238,7 @@ export const TreeChildNodes = ({
256
238
  } = props;
257
239
  return (
258
240
  <div className={mx('flex flex-col mt-0.5 gap-0.5', className)}>
259
- {children?.map((child, i) => (
241
+ {children?.map((child) => (
260
242
  <TreeNode key={child.id} {...props} depth={depth + 1} node={child} ancestors={[...ancestors, props.node]} />
261
243
  ))}
262
244
  </div>
package/src/hooks.ts CHANGED
@@ -2,13 +2,16 @@
2
2
  // Copyright 2025 DXOS.org
3
3
  //
4
4
 
5
- import { useEffect } from 'react';
5
+ import { type Atom, useAtomValue } from '@effect-atom/atom-react';
6
+ import { useEffect, useMemo } from 'react';
6
7
 
8
+ import { useCapability } from '@dxos/app-framework/react';
7
9
  import { type Node } from '@dxos/app-graph';
8
10
 
9
11
  import { useNavTreeContext } from './components';
12
+ import { NavTreeCapabilities } from './types';
10
13
 
11
- export const useLoadDescendents = (root?: Node) => {
14
+ export const useLoadDescendents = (root?: Node.Node) => {
12
15
  const { loadDescendents } = useNavTreeContext();
13
16
  useEffect(() => {
14
17
  const frame = requestAnimationFrame(() => {
@@ -19,3 +22,52 @@ export const useLoadDescendents = (root?: Node) => {
19
22
  return () => cancelAnimationFrame(frame);
20
23
  }, [root]);
21
24
  };
25
+
26
+ export type UseNavTreeStateResult = {
27
+ getItem: (path: string[]) => NavTreeCapabilities.NavTreeItemState;
28
+ getItemAtom: (path: string[]) => Atom.Atom<NavTreeCapabilities.NavTreeItemState>;
29
+ setItem: (path: string[], key: 'open' | 'current' | 'alternateTree', next: boolean) => void;
30
+ };
31
+
32
+ /**
33
+ * Hook that provides access to navtree state functions.
34
+ * For reactive subscriptions, use `useNavTreeItemState` or `useAtomValue(getItemAtom(path))`.
35
+ */
36
+ export const useNavTreeState = (): UseNavTreeStateResult => {
37
+ return useCapability(NavTreeCapabilities.State);
38
+ };
39
+
40
+ /**
41
+ * Hook that subscribes to a single navtree item's state.
42
+ * Use this for fine-grained reactivity.
43
+ */
44
+ export const useNavTreeItemState = (path: string[]): NavTreeCapabilities.NavTreeItemState => {
45
+ const { getItemAtom } = useCapability(NavTreeCapabilities.State);
46
+ // Memoize the path to avoid creating new atoms on every render.
47
+ const pathKey = useMemo(() => path.join('~'), [path]);
48
+ const atom = useMemo(() => getItemAtom(path), [getItemAtom, pathKey]);
49
+ return useAtomValue(atom);
50
+ };
51
+
52
+ /**
53
+ * Hook that subscribes to the open state for a tree item.
54
+ * Designed to be passed to Tree component as useIsOpen prop.
55
+ */
56
+ export const useIsOpen = (path: string[], _item?: any): boolean => {
57
+ return useNavTreeItemState(path).open;
58
+ };
59
+
60
+ /**
61
+ * Hook that subscribes to the current state for a tree item.
62
+ * Designed to be passed to Tree component as useIsCurrent prop.
63
+ */
64
+ export const useIsCurrent = (path: string[], _item?: any): boolean => {
65
+ return useNavTreeItemState(path).current;
66
+ };
67
+
68
+ /**
69
+ * Hook that subscribes to the alternateTree state for a tree item.
70
+ */
71
+ export const useIsAlternateTree = (path: string[], _item?: any): boolean => {
72
+ return useNavTreeItemState(path).alternateTree ?? false;
73
+ };
package/src/index.ts CHANGED
@@ -2,8 +2,7 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- export { NavTreeCapabilities } from './capabilities';
6
- export { NavTreeEvents } from './events';
5
+ export { NavTreeCapabilities, NavTreeEvents } from './types';
7
6
  export * from './NavTreePlugin';
8
7
  export * from './meta';
9
8
  export * from './util';
package/src/meta.ts CHANGED
@@ -2,16 +2,19 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import { type PluginMeta } from '@dxos/app-framework';
5
+ import { type Plugin } from '@dxos/app-framework';
6
+ import { trim } from '@dxos/util';
6
7
 
7
- export const NAVTREE_PLUGIN = 'dxos.org/plugin/navtree';
8
+ export const meta: Plugin.Meta = {
9
+ id: 'dxos.org/plugin/navtree',
10
+ name: 'Navtree',
11
+ description: trim`
12
+ Hierarchical navigation tree for browsing spaces, folders, and objects.
13
+ Provides sidebar navigation with collapsible sections and quick access to workspace content.
14
+ `,
15
+ };
8
16
 
9
17
  // TODO(wittjosiah): Factor out.
10
18
  export const KEY_BINDING = 'KeyBinding';
11
19
  // TODO(wittjosiah): Factor out.
12
- export const COMMANDS_DIALOG = `${NAVTREE_PLUGIN}/CommandsDialog`;
13
-
14
- export const meta: PluginMeta = {
15
- id: NAVTREE_PLUGIN,
16
- name: 'Navtree',
17
- };
20
+ export const COMMANDS_DIALOG = `${meta.id}/CommandsDialog`;