@dxos/plugin-navtree 0.8.2-main.5ca3450 → 0.8.2-main.600d381

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 (105) hide show
  1. package/dist/lib/browser/{chunk-FBQKXPOR.mjs → chunk-ZULGSU3L.mjs} +239 -204
  2. package/dist/lib/browser/chunk-ZULGSU3L.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +2 -2
  4. package/dist/lib/browser/index.mjs.map +2 -2
  5. package/dist/lib/browser/{keyboard-IQXHKUWM.mjs → keyboard-2KXRP22I.mjs} +2 -2
  6. package/dist/lib/browser/{keyboard-IQXHKUWM.mjs.map → keyboard-2KXRP22I.mjs.map} +3 -3
  7. package/dist/lib/browser/meta.json +1 -1
  8. package/dist/lib/browser/{react-surface-FQEYRV4Q.mjs → react-surface-BVZN7664.mjs} +2 -2
  9. package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -0
  10. package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -0
  11. package/dist/types/src/components/CommandsDialog/index.d.ts +3 -0
  12. package/dist/types/src/components/CommandsDialog/index.d.ts.map +1 -0
  13. package/dist/types/src/components/NavTree/NavTree.d.ts +8 -0
  14. package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -0
  15. package/dist/types/src/components/NavTree/NavTree.stories.d.ts +8 -0
  16. package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -0
  17. package/dist/types/src/components/NavTree/index.d.ts +2 -0
  18. package/dist/types/src/components/NavTree/index.d.ts.map +1 -0
  19. package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
  20. package/dist/types/src/components/NavTreeContext.d.ts.map +1 -1
  21. package/dist/types/src/components/{NavTreeItemAction.d.ts → NavTreeItem/NavTreeItemAction.d.ts} +2 -3
  22. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -0
  23. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +8 -0
  24. package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -0
  25. package/dist/types/src/components/{NavTreeItemColumns.d.ts → NavTreeItem/NavTreeItemColumns.d.ts} +1 -1
  26. package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -0
  27. package/dist/types/src/components/NavTreeItem/index.d.ts +3 -0
  28. package/dist/types/src/components/NavTreeItem/index.d.ts.map +1 -0
  29. package/dist/types/src/components/Sidebar/L0Menu.d.ts +13 -0
  30. package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -0
  31. package/dist/types/src/components/Sidebar/L1Panel.d.ts +15 -0
  32. package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -0
  33. package/dist/types/src/components/Sidebar/index.d.ts +3 -0
  34. package/dist/types/src/components/Sidebar/index.d.ts.map +1 -0
  35. package/dist/types/src/components/{UserAccountAvatar.d.ts → UserAccountAvatar/UserAccountAvatar.d.ts} +1 -1
  36. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -0
  37. package/dist/types/src/components/{UserAccountAvatar.stories.d.ts → UserAccountAvatar/UserAccountAvatar.stories.d.ts} +1 -2
  38. package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -0
  39. package/dist/types/src/components/UserAccountAvatar/index.d.ts +2 -0
  40. package/dist/types/src/components/UserAccountAvatar/index.d.ts.map +1 -0
  41. package/dist/types/src/components/index.d.ts +0 -1
  42. package/dist/types/src/components/index.d.ts.map +1 -1
  43. package/dist/types/src/components/types.d.ts +14 -15
  44. package/dist/types/src/components/types.d.ts.map +1 -1
  45. package/dist/types/src/testing/app-graph-builder.d.ts +11 -0
  46. package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -0
  47. package/dist/types/src/testing/generator.d.ts +1 -0
  48. package/dist/types/src/testing/generator.d.ts.map +1 -1
  49. package/dist/types/src/testing/index.d.ts +1 -0
  50. package/dist/types/src/testing/index.d.ts.map +1 -1
  51. package/dist/types/src/translations.d.ts +1 -1
  52. package/dist/types/src/util.d.ts +1 -1
  53. package/package.json +32 -31
  54. package/src/capabilities/keyboard.ts +1 -1
  55. package/src/components/{CommandsDialog.tsx → CommandsDialog/CommandsDialog.tsx} +2 -2
  56. package/src/components/{CommandsTrigger.tsx → CommandsDialog/CommandsTrigger.tsx} +1 -1
  57. package/src/components/CommandsDialog/index.ts +6 -0
  58. package/src/components/NavTree/NavTree.stories.tsx +87 -0
  59. package/src/components/{NavTree.tsx → NavTree/NavTree.tsx} +24 -11
  60. package/src/components/NavTree/index.ts +5 -0
  61. package/src/components/NavTreeContainer.tsx +35 -16
  62. package/src/components/NavTreeContext.tsx +1 -1
  63. package/src/components/{NavTreeItemAction.stories.tsx → NavTreeItem/NavTreeItemAction.stories.tsx} +12 -6
  64. package/src/components/{NavTreeItemAction.tsx → NavTreeItem/NavTreeItemAction.tsx} +13 -14
  65. package/src/components/{NavTreeItemColumns.tsx → NavTreeItem/NavTreeItemColumns.tsx} +5 -5
  66. package/src/components/NavTreeItem/index.ts +6 -0
  67. package/src/components/{L0Menu.tsx → Sidebar/L0Menu.tsx} +182 -129
  68. package/src/components/{L1Panels.tsx → Sidebar/L1Panel.tsx} +29 -48
  69. package/src/components/Sidebar/index.ts +6 -0
  70. package/src/components/{UserAccountAvatar.stories.tsx → UserAccountAvatar/UserAccountAvatar.stories.tsx} +5 -5
  71. package/src/components/{UserAccountAvatar.tsx → UserAccountAvatar/UserAccountAvatar.tsx} +6 -6
  72. package/src/components/UserAccountAvatar/index.ts +5 -0
  73. package/src/components/index.ts +0 -1
  74. package/src/components/types.ts +13 -15
  75. package/src/testing/app-graph-builder.ts +158 -0
  76. package/src/testing/generator.ts +2 -1
  77. package/src/testing/index.ts +1 -0
  78. package/src/translations.ts +1 -1
  79. package/dist/lib/browser/chunk-FBQKXPOR.mjs.map +0 -7
  80. package/dist/types/src/components/CommandsDialog.d.ts.map +0 -1
  81. package/dist/types/src/components/CommandsTrigger.d.ts.map +0 -1
  82. package/dist/types/src/components/L0Menu.d.ts +0 -10
  83. package/dist/types/src/components/L0Menu.d.ts.map +0 -1
  84. package/dist/types/src/components/L1Panels.d.ts +0 -14
  85. package/dist/types/src/components/L1Panels.d.ts.map +0 -1
  86. package/dist/types/src/components/NavTree.d.ts +0 -5
  87. package/dist/types/src/components/NavTree.d.ts.map +0 -1
  88. package/dist/types/src/components/NavTree.stories.d.ts +0 -7
  89. package/dist/types/src/components/NavTree.stories.d.ts.map +0 -1
  90. package/dist/types/src/components/NavTreeItemAction.d.ts.map +0 -1
  91. package/dist/types/src/components/NavTreeItemAction.stories.d.ts +0 -41
  92. package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +0 -1
  93. package/dist/types/src/components/NavTreeItemColumns.d.ts.map +0 -1
  94. package/dist/types/src/components/UserAccountAvatar.d.ts.map +0 -1
  95. package/dist/types/src/components/UserAccountAvatar.stories.d.ts.map +0 -1
  96. package/dist/types/src/stories/Graph.stories.d.ts +0 -7
  97. package/dist/types/src/stories/Graph.stories.d.ts.map +0 -1
  98. package/dist/types/src/stories/StorybookNavTree.d.ts +0 -4
  99. package/dist/types/src/stories/StorybookNavTree.d.ts.map +0 -1
  100. package/src/components/NavTree.stories.tsx +0 -107
  101. package/src/stories/Graph.stories.tsx +0 -130
  102. package/src/stories/StorybookNavTree.tsx +0 -63
  103. /package/dist/lib/browser/{react-surface-FQEYRV4Q.mjs.map → react-surface-BVZN7664.mjs.map} +0 -0
  104. /package/dist/types/src/components/{CommandsDialog.d.ts → CommandsDialog/CommandsDialog.d.ts} +0 -0
  105. /package/dist/types/src/components/{CommandsTrigger.d.ts → CommandsDialog/CommandsTrigger.d.ts} +0 -0
@@ -7,88 +7,92 @@ import { draggable, dropTargetForElements } from '@atlaskit/pragmatic-drag-and-d
7
7
  import { preserveOffsetOnSource } from '@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source';
8
8
  import { scrollJustEnoughIntoView } from '@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view';
9
9
  import {
10
- attachClosestEdge,
11
10
  type Edge,
11
+ attachClosestEdge,
12
12
  extractClosestEdge,
13
13
  } from '@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge';
14
- import React, { type MouseEvent, useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
14
+ import React, {
15
+ forwardRef,
16
+ type MouseEvent,
17
+ type PropsWithChildren,
18
+ useCallback,
19
+ useLayoutEffect,
20
+ useMemo,
21
+ useRef,
22
+ useState,
23
+ } from 'react';
15
24
 
16
- import { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';
17
25
  import { type Node } from '@dxos/app-graph';
18
26
  import { invariant } from '@dxos/invariant';
19
27
  import {
20
- Popover,
28
+ Icon,
29
+ IconButton,
30
+ ListItem,
21
31
  ScrollArea,
22
- toLocalizedString,
23
32
  Tooltip,
33
+ toLocalizedString,
24
34
  useMediaQuery,
25
- useSidebars,
26
35
  useTranslation,
27
- ListItem,
28
- Icon,
29
36
  } from '@dxos/react-ui';
37
+ import { MenuProvider, DropdownMenu, type MenuItem } from '@dxos/react-ui-menu';
30
38
  import type { StackItemRearrangeHandler } from '@dxos/react-ui-stack';
31
39
  import { Tabs } from '@dxos/react-ui-tabs';
32
40
  import { mx } from '@dxos/react-ui-theme';
33
41
  import { arrayMove, getFirstTwoRenderableChars } from '@dxos/util';
34
42
 
35
- import { useNavTreeContext } from './NavTreeContext';
36
- import { UserAccountAvatar } from './UserAccountAvatar';
37
- import { useLoadDescendents } from '../hooks';
38
- import { NAVTREE_PLUGIN } from '../meta';
39
- import { l0ItemType } from '../util';
43
+ import { useLoadDescendents } from '../../hooks';
44
+ import { NAVTREE_PLUGIN } from '../../meta';
45
+ import { l0ItemType } from '../../util';
46
+ import { useNavTreeContext } from '../NavTreeContext';
47
+ import { UserAccountAvatar } from '../UserAccountAvatar';
48
+
49
+ //
50
+ // L0Item
51
+ //
52
+
53
+ type L0ItemData = {
54
+ id: L0ItemProps['item']['id'];
55
+ type: 'l0Item';
56
+ };
40
57
 
41
- type L0ItemData = { id: L0ItemProps['item']['id']; type: 'l0Item' };
58
+ type L0ItemRootProps = {
59
+ item: Node<any>;
60
+ parent?: Node<any>;
61
+ path: string[];
62
+ };
42
63
 
43
- type L0ItemProps = {
64
+ type L0ItemProps = L0ItemRootProps & {
44
65
  item: Node<any>;
45
66
  parent?: Node<any>;
46
67
  path: string[];
47
68
  pinned?: boolean;
48
- userAccount?: boolean;
49
69
  onRearrange?: StackItemRearrangeHandler<L0ItemData>;
50
70
  };
51
71
 
52
72
  const useL0ItemClick = ({ item, parent, path }: L0ItemProps, type: string) => {
53
- const { tab, onTabChange, onSelect, isCurrent } = useNavTreeContext();
54
- const { dispatchPromise: dispatch } = useIntentDispatcher();
55
- const { navigationSidebarState } = useSidebars(NAVTREE_PLUGIN);
73
+ const { tab, isCurrent, onSelect, onTabChange } = useNavTreeContext();
56
74
  const [isLg] = useMediaQuery('lg', { ssr: false });
57
75
 
58
76
  return useCallback(
59
77
  (event: MouseEvent) => {
60
78
  switch (type) {
61
- case 'tab':
62
- // TODO(thure): This dispatch should rightly be in `onTabChange`, but that callback wasn’t reacting to changes
63
- // to its dependencies.
64
- void dispatch(
65
- createIntent(LayoutAction.UpdateSidebar, {
66
- part: 'sidebar',
67
- options: {
68
- state:
69
- item.id === tab
70
- ? navigationSidebarState === 'expanded'
71
- ? isLg
72
- ? 'collapsed'
73
- : 'closed'
74
- : 'expanded'
75
- : 'expanded',
76
- },
77
- }),
78
- );
79
- return onTabChange?.(item);
80
- case 'link':
81
- return onSelect?.({ item, path, current: !isCurrent(path, item), option: event.altKey });
82
79
  case 'action': {
83
80
  const {
84
81
  data: invoke,
85
82
  properties: { caller },
86
83
  } = item;
84
+
87
85
  return invoke?.(caller ? { node: parent, caller } : { node: parent });
88
86
  }
87
+
88
+ case 'tab':
89
+ return onTabChange?.(item);
90
+
91
+ case 'link':
92
+ return onSelect?.({ item, path, current: !isCurrent(path, item), option: event.altKey });
89
93
  }
90
94
  },
91
- [item, type, onSelect, isCurrent, parent, tab, navigationSidebarState, isLg, dispatch],
95
+ [item, parent, type, tab, isCurrent, onSelect, onTabChange, isLg],
92
96
  );
93
97
  };
94
98
 
@@ -96,28 +100,70 @@ const l0Breakpoints: Record<string, string> = {
96
100
  lg: 'hidden lg:grid',
97
101
  };
98
102
 
99
- const L0Item = ({ item, parent, path, pinned, userAccount, onRearrange }: L0ItemProps) => {
103
+ const L0ItemRoot = forwardRef<HTMLElement, PropsWithChildren<L0ItemRootProps>>(
104
+ ({ item, parent, path, children }, forwardedRef) => {
105
+ const { getProps } = useNavTreeContext();
106
+ const { id, testId } = getProps?.(item, path) ?? {};
107
+ const type = l0ItemType(item);
108
+ const itemPath = useMemo(() => [...path, item.id], [item.id, path]);
109
+
110
+ const { t } = useTranslation(NAVTREE_PLUGIN);
111
+ const localizedString = toLocalizedString(item.properties.label, t);
112
+
113
+ const handleClick = useL0ItemClick({ item, parent, path: itemPath }, type);
114
+ const rootProps =
115
+ type === 'tab'
116
+ ? { value: item.id, tabIndex: 0, onClick: handleClick, 'data-testid': testId, 'data-itemid': id }
117
+ : type !== 'collection'
118
+ ? { onClick: handleClick, 'data-testid': testId, 'data-itemid': id }
119
+ : { onClick: handleClick };
120
+
121
+ const Root = type === 'collection' ? 'h2' : type === 'tab' ? Tabs.TabPrimitive : 'button';
122
+
123
+ return (
124
+ <Tooltip.Trigger asChild delayDuration={0} side='right' content={localizedString}>
125
+ <Root
126
+ {...(rootProps as any)}
127
+ data-type={type}
128
+ className={mx(
129
+ 'group/l0item flex w-full justify-center items-center relative data[type!="collection"]:cursor-pointer app-no-drag dx-focus-ring-group',
130
+ l0Breakpoints[item.properties.l0Breakpoint],
131
+ )}
132
+ ref={forwardedRef}
133
+ >
134
+ {children}
135
+ </Root>
136
+ </Tooltip.Trigger>
137
+ );
138
+ },
139
+ );
140
+
141
+ const L0Avator = ({ item }: Pick<L0ItemProps, 'item'>) => {
100
142
  const { t } = useTranslation(NAVTREE_PLUGIN);
101
- const itemElement = useRef<HTMLElement | null>(null);
102
- const [closestEdge, setEdge] = useState<Edge | null>(null);
103
143
  const type = l0ItemType(item);
104
- const itemPath = useMemo(() => [...path, item.id], [item.id, path]);
105
- const { getProps, popoverAnchorId } = useNavTreeContext();
106
- const { id, testId } = getProps?.(item, path) ?? {};
107
- const Root = type === 'collection' ? 'h2' : type === 'tab' ? Tabs.TabPrimitive : 'button';
108
- const handleClick = useL0ItemClick({ item, path: itemPath, parent }, type);
109
- const rootProps =
110
- type === 'tab'
111
- ? { value: item.id, tabIndex: 0, onClick: handleClick, 'data-testid': testId, 'data-itemid': id }
112
- : type !== 'collection'
113
- ? { onClick: handleClick, 'data-testid': testId, 'data-itemid': id }
114
- : { onClick: handleClick };
115
- const localizedString = toLocalizedString(item.properties.label, t);
116
144
  const hue = item.properties.hue ?? null;
145
+ const hueFgStyle = hue && { style: { color: `var(--dx-${hue}SurfaceText)` } };
146
+ const localizedString = toLocalizedString(item.properties.label, t);
117
147
  const avatarValue = useMemo(
118
148
  () => (type === 'tab' ? getFirstTwoRenderableChars(localizedString).join('').toUpperCase() : []),
119
149
  [type, item.properties.label, t],
120
150
  );
151
+
152
+ return (
153
+ <span role='img' className='place-self-center text-xl font-light' {...hueFgStyle}>
154
+ {avatarValue}
155
+ </span>
156
+ );
157
+ };
158
+
159
+ // TODO(burdon): Factor out pinned (non-draggable) items.
160
+ const L0Item = ({ item, parent, path, pinned, onRearrange }: L0ItemProps) => {
161
+ const { t } = useTranslation(NAVTREE_PLUGIN);
162
+ const itemElement = useRef<HTMLElement | null>(null);
163
+ const [closestEdge, setEdge] = useState<Edge | null>(null);
164
+ const type = l0ItemType(item);
165
+ const localizedString = toLocalizedString(item.properties.label, t);
166
+ const hue = item.properties.hue ?? null;
121
167
  const hueFgStyle = hue && { style: { color: `var(--dx-${hue}SurfaceText)` } };
122
168
 
123
169
  useLayoutEffect(() => {
@@ -125,6 +171,7 @@ const L0Item = ({ item, parent, path, pinned, userAccount, onRearrange }: L0Item
125
171
  if (!itemElement.current || !onRearrange) {
126
172
  return;
127
173
  }
174
+
128
175
  return combine(
129
176
  draggable({
130
177
  element: itemElement.current,
@@ -175,77 +222,40 @@ const L0Item = ({ item, parent, path, pinned, userAccount, onRearrange }: L0Item
175
222
  );
176
223
  }, [item, onRearrange]);
177
224
 
178
- const l0ItemTrigger = (
179
- <Root
180
- {...(rootProps as any)}
181
- data-type={type}
182
- className={mx(
183
- 'group/l0i dx-focus-ring-group grid relative data[type!="collection"]:cursor-pointer app-no-drag',
184
- l0Breakpoints[item.properties.l0Breakpoint],
185
- )}
186
- ref={itemElement}
187
- >
188
- {userAccount ? (
189
- <UserAccountAvatar
190
- userId={item.properties.userId}
191
- hue={item.properties.hue}
192
- emoji={item.properties.emoji}
193
- status={item.properties.status}
194
- />
195
- ) : (
196
- <div
197
- role='none'
198
- data-frame={true}
199
- className={mx(
200
- 'absolute grid dx-focus-ring-group-indicator transition-colors',
201
- type === 'tab' || pinned ? 'rounded' : 'rounded-full',
202
- pinned
203
- ? 'bg-transparent group-hover/l0i:bg-groupSurface inset-inline-3 inset-block-0.5'
204
- : 'bg-groupSurface inset-inline-3 inset-block-2',
205
- )}
206
- {...(hue && { style: { background: `var(--dx-${hue}Surface)` } })}
207
- >
208
- {(item.properties.icon && (
209
- <Icon icon={item.properties.icon} size={pinned ? 5 : 7} classNames='place-self-center' {...hueFgStyle} />
210
- )) ||
211
- (type === 'tab' && item.properties.disposition !== 'pin-end' ? (
212
- <span role='img' className='place-self-center text-3xl font-light' {...hueFgStyle}>
213
- {avatarValue}
214
- </span>
215
- ) : (
216
- item.properties.icon && (
217
- <Icon icon='ph--planet--regular' size={pinned ? 5 : 7} classNames='place-self-center' {...hueFgStyle} />
218
- )
219
- ))}
220
- </div>
221
- )}
225
+ return (
226
+ <L0ItemRoot ref={itemElement} item={item} parent={parent} path={path}>
222
227
  <div
223
228
  role='none'
224
- className='hidden group-aria-selected/l0i:block absolute inline-start-0 inset-block-4 is-1 bg-accentSurface rounded-ie'
229
+ data-frame={true}
230
+ className={mx(
231
+ 'flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded',
232
+ // TODO(burdon): Create reusable button/component and/or create var for size.
233
+ pinned
234
+ ? 'bg-transparent w-[50px] p-2 group-hover/l0item:bg-groupSurface'
235
+ : 'bg-groupSurface w-[50px] h-[50px]',
236
+ )}
237
+ {...(hue && { style: { background: `var(--dx-${hue}Surface)` } })}
238
+ >
239
+ {(item.properties.icon && <Icon icon={item.properties.icon} size={pinned ? 5 : 6} {...hueFgStyle} />) ||
240
+ (type === 'tab' && item.properties.disposition !== 'pin-end' && <L0Avator item={item} />)}
241
+ </div>
242
+ <div
243
+ role='none'
244
+ className='hidden group-aria-selected/l0item:block absolute inline-start-0 inset-block-4 is-1 bg-accentSurface rounded-ie'
225
245
  />
226
246
  <span id={`${item.id}__label`} className='sr-only'>
227
247
  {localizedString}
228
248
  </span>
229
249
  {onRearrange && closestEdge && <ListItem.DropIndicator edge={closestEdge} />}
230
- </Root>
231
- );
232
-
233
- return popoverAnchorId === id ? (
234
- <Popover.Anchor asChild>{l0ItemTrigger}</Popover.Anchor>
235
- ) : (
236
- <Tooltip.Root delayDuration={0}>
237
- <Tooltip.Trigger asChild>{l0ItemTrigger}</Tooltip.Trigger>
238
- <Tooltip.Portal>
239
- <Tooltip.Content side='right'>
240
- {localizedString}
241
- <Tooltip.Arrow />
242
- </Tooltip.Content>
243
- </Tooltip.Portal>
244
- </Tooltip.Root>
250
+ </L0ItemRoot>
245
251
  );
246
252
  };
247
253
 
248
- const L0Collection = ({ item, path, parent }: L0ItemProps) => {
254
+ //
255
+ // L0Collection
256
+ //
257
+
258
+ const L0Collection = ({ item, path }: L0ItemProps) => {
249
259
  const navTreeContext = useNavTreeContext();
250
260
  useLoadDescendents(item);
251
261
  const collectionItems = navTreeContext.getItems(item);
@@ -266,6 +276,7 @@ const L0Collection = ({ item, path, parent }: L0ItemProps) => {
266
276
  },
267
277
  [collectionItems, item.properties.onRearrangeChildren],
268
278
  );
279
+
269
280
  return (
270
281
  <div
271
282
  role='group'
@@ -287,26 +298,57 @@ const L0Collection = ({ item, path, parent }: L0ItemProps) => {
287
298
  );
288
299
  };
289
300
 
290
- export const L0Menu = ({
291
- topLevelItems,
292
- pinnedItems,
293
- userAccountItem,
294
- parent,
295
- path,
296
- }: {
301
+ //
302
+ // L0Menu
303
+ //
304
+
305
+ export type L0MenuProps = {
306
+ menuActions: MenuItem[];
297
307
  topLevelItems: Node<any>[];
298
308
  pinnedItems: Node<any>[];
299
309
  userAccountItem: Node<any>;
300
310
  parent?: Node<any>;
301
311
  path: string[];
302
- }) => {
312
+ };
313
+
314
+ export const L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }: L0MenuProps) => {
315
+ const { t } = useTranslation(NAVTREE_PLUGIN);
316
+
303
317
  return (
304
- <Tabs.Tablist classNames='group/l0 absolute z-[1] inset-block-0 inline-start-0 rounded-is-lg grid grid-cols-[var(--l0-size)] grid-rows-[1fr_min-content_var(--l0-size)] contain-layout !is-[--l0-size] bg-baseSurface border-ie border-separator app-drag pbe-[env(safe-area-inset-bottom)]'>
318
+ <Tabs.Tablist
319
+ classNames={[
320
+ 'group/l0 absolute z-[1] inset-block-0 inline-start-0 rounded-is-lg',
321
+ 'grid grid-cols-[var(--l0-size)] grid-rows-[var(--rail-size)_1fr_min-content_var(--l0-size)] gap-1 contain-layout',
322
+ '!is-[--l0-size] bg-baseSurface border-ie border-separator app-drag pbe-[env(safe-area-inset-bottom)]',
323
+ ]}
324
+ >
325
+ <div role='none' className='flex justify-center p-1'>
326
+ <MenuProvider>
327
+ <DropdownMenu.Root group={parent} items={menuActions}>
328
+ <DropdownMenu.Trigger asChild>
329
+ {/* TODO(wittjosiah): Use L0Item trigger. */}
330
+ {/* TODO(burdon): Replace with Sigil. */}
331
+ <IconButton
332
+ iconOnly
333
+ icon='ph--dots-three--regular'
334
+ size={5}
335
+ label={t('app menu label')}
336
+ classNames='w-[50px] _bg-primary-500'
337
+ />
338
+ </DropdownMenu.Trigger>
339
+ </DropdownMenu.Root>
340
+ </MenuProvider>
341
+ </div>
342
+
305
343
  <ScrollArea.Root>
306
344
  <ScrollArea.Viewport>
307
345
  <div
308
346
  role='none'
309
- className='grid auto-rows-[calc(var(--l0-size)-.5rem)] plb-1 [body[data-platform="darwin"]_&]:pbs-[calc(30px+0.25rem)] [body[data-platform="ios"]_&]:pbs-[max(env(safe-area-inset-top),0.25rem)]'
347
+ className={mx([
348
+ 'flex flex-col gap-2',
349
+ '[body[data-platform="darwin"]_&]:pbs-[calc(30px+0.25rem)]',
350
+ '[body[data-platform="ios"]_&]:pbs-[max(env(safe-area-inset-top),0.25rem)]',
351
+ ])}
310
352
  >
311
353
  {topLevelItems.map((item) => {
312
354
  if (l0ItemType(item) === 'collection') {
@@ -321,6 +363,7 @@ export const L0Menu = ({
321
363
  </ScrollArea.Scrollbar>
322
364
  </ScrollArea.Viewport>
323
365
  </ScrollArea.Root>
366
+
324
367
  <div role='none' className='grid grid-cols-1 auto-rows-[--rail-action] pbs-2'>
325
368
  {pinnedItems
326
369
  .filter((item) => l0ItemType(item) !== 'collection')
@@ -328,11 +371,21 @@ export const L0Menu = ({
328
371
  <L0Item key={item.id} item={item} parent={parent} path={path} pinned />
329
372
  ))}
330
373
  </div>
374
+
331
375
  {userAccountItem && (
332
- <div role='none' className='grid py-2 app-no-drag'>
333
- <L0Item key={userAccountItem.id} item={userAccountItem} parent={parent} path={path} userAccount />
376
+ <div role='none' className='grid app-no-drag'>
377
+ <L0ItemRoot key={userAccountItem.id} item={userAccountItem} parent={parent} path={path}>
378
+ <UserAccountAvatar
379
+ userId={userAccountItem.properties.userId}
380
+ hue={userAccountItem.properties.hue}
381
+ emoji={userAccountItem.properties.emoji}
382
+ status={userAccountItem.properties.status}
383
+ size={11}
384
+ />
385
+ </L0ItemRoot>
334
386
  </div>
335
387
  )}
388
+
336
389
  <div
337
390
  role='none'
338
391
  className='hidden [body[data-platform="darwin"]_&]:block absolute block-start-0 is-[calc(var(--l0-size)-1px)] bs-[calc(40px+0.25rem)]'
@@ -4,7 +4,6 @@
4
4
 
5
5
  import React, { useCallback, useMemo } from 'react';
6
6
 
7
- import { useLayout } from '@dxos/app-framework';
8
7
  import { type Node } from '@dxos/app-graph';
9
8
  import { Button, type ButtonProps, Icon, IconButton, toLocalizedString, useTranslation } from '@dxos/react-ui';
10
9
  import { Tree } from '@dxos/react-ui-list';
@@ -12,24 +11,16 @@ import { Tabs } from '@dxos/react-ui-tabs';
12
11
  import { hoverableControlItem, hoverableOpenControlItem, mx } from '@dxos/react-ui-theme';
13
12
  import { byPosition } from '@dxos/util';
14
13
 
15
- import { useNavTreeContext } from './NavTreeContext';
16
- import { NavTreeItemColumns } from './NavTreeItemColumns';
17
- import { useLoadDescendents } from '../hooks';
18
- import { NAVTREE_PLUGIN } from '../meta';
19
- import { l0ItemType } from '../util';
14
+ import { useLoadDescendents } from '../../hooks';
15
+ import { NAVTREE_PLUGIN } from '../../meta';
16
+ import { l0ItemType } from '../../util';
17
+ import { useNavTreeContext } from '../NavTreeContext';
18
+ import { NavTreeItemColumns } from '../NavTreeItem';
20
19
 
21
- export type L1PanelProps = {
22
- item: Node<any>;
23
- path: string[];
24
- currentItemId: string;
25
- onBack?: () => void;
26
- };
27
-
28
- const headingBackButtonLabel =
29
- 'absolute inset-0 min-is-0 truncate flex items-center pis-6 transition-[transform,opacity] ease-in-out duration-200';
20
+ const headingBackButtonLabel = 'absolute inset-0 min-is-0 truncate flex items-center pis-6';
30
21
 
22
+ // TODO(burdon): Figure out better L1 back navigation.
31
23
  const HeadingBackButton = ({ title, onClick }: { title: string } & Pick<ButtonProps, 'onClick'>) => {
32
- const { t } = useTranslation(NAVTREE_PLUGIN);
33
24
  return (
34
25
  <Button
35
26
  variant='ghost'
@@ -37,28 +28,20 @@ const HeadingBackButton = ({ title, onClick }: { title: string } & Pick<ButtonPr
37
28
  onClick={onClick}
38
29
  >
39
30
  <Icon icon='ph--caret-left--bold' size={3} />
40
- <span
41
- className={mx(
42
- headingBackButtonLabel,
43
- 'translate-y-2 opacity-0 group-hover:translate-y-0 group-hover:opacity-100 group-focus:translate-y-0 group-focus:opacity-100',
44
- )}
45
- >
46
- {t('back label')}
47
- </span>
48
- <span
49
- className={mx(
50
- headingBackButtonLabel,
51
- 'translate-y-0 opacity-100 group-hover:-translate-y-2 group-hover:opacity-0 group-focus:-translate-y-2 group-focus:opacity-0',
52
- )}
53
- >
54
- {title}
55
- </span>
31
+ <span className={mx(headingBackButtonLabel)}>{title}</span>
56
32
  </Button>
57
33
  );
58
34
  };
59
35
 
60
- const L1Panel = ({ item, path, currentItemId, onBack }: L1PanelProps) => {
61
- const layout = useLayout();
36
+ export type L1PanelProps = {
37
+ open?: boolean;
38
+ item: Node<any>;
39
+ path: string[];
40
+ currentItemId: string;
41
+ onBack?: () => void;
42
+ };
43
+
44
+ const L1Panel = ({ open, item, path, currentItemId, onBack }: L1PanelProps) => {
62
45
  const { isAlternateTree, setAlternateTree, ...navTreeContext } = useNavTreeContext();
63
46
  const { t } = useTranslation(NAVTREE_PLUGIN);
64
47
 
@@ -95,12 +78,14 @@ const L1Panel = ({ item, path, currentItemId, onBack }: L1PanelProps) => {
95
78
  key={item.id}
96
79
  value={item.id}
97
80
  classNames={[
98
- 'absolute inset-block-0 inline-end-0 is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr] pbs-[env(safe-area-inset-top)]',
81
+ 'absolute inset-block-0 inline-end-0',
82
+ 'is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr]',
83
+ 'pbs-[env(safe-area-inset-top)]',
99
84
  item.id === currentItemId && 'grid',
100
85
  ]}
101
86
  tabIndex={-1}
102
87
  aria-label={title}
103
- {...(!layout.sidebarOpen && { inert: 'true' })}
88
+ {...(!open && { inert: 'true' })}
104
89
  >
105
90
  {item.id === currentItemId && (
106
91
  <>
@@ -156,7 +141,7 @@ const L1Panel = ({ item, path, currentItemId, onBack }: L1PanelProps) => {
156
141
  );
157
142
  };
158
143
 
159
- const L1PanelCollection = ({ item, path, currentItemId }: L1PanelProps) => {
144
+ const L1PanelCollection = ({ item, path, ...props }: L1PanelProps) => {
160
145
  const { getItems } = useNavTreeContext();
161
146
  useLoadDescendents(item);
162
147
  const collectionItems = getItems(item);
@@ -166,31 +151,27 @@ const L1PanelCollection = ({ item, path, currentItemId }: L1PanelProps) => {
166
151
  {collectionItems
167
152
  .filter((item) => l0ItemType(item) === 'tab')
168
153
  .map((item) => (
169
- <L1Panel key={item.id} item={item} path={groupPath} currentItemId={currentItemId} />
154
+ <L1Panel key={item.id} item={item} path={groupPath} {...props} />
170
155
  ))}
171
156
  </>
172
157
  );
173
158
  };
174
159
 
175
- export const L1Panels = ({
176
- topLevelItems,
177
- path,
178
- currentItemId,
179
- onBack,
180
- }: Pick<L1PanelProps, 'onBack'> & {
160
+ export type L1PanelsProps = Pick<L1PanelProps, 'open' | 'currentItemId' | 'onBack'> & {
181
161
  topLevelItems: Node<any>[];
182
162
  path: string[];
183
- currentItemId: string;
184
- }) => {
163
+ };
164
+
165
+ export const L1Panels = ({ topLevelItems, onBack, ...props }: L1PanelsProps) => {
185
166
  return (
186
167
  <>
187
168
  {topLevelItems.map((item) => {
188
169
  const type = l0ItemType(item);
189
170
  switch (type) {
190
171
  case 'collection':
191
- return <L1PanelCollection key={item.id} item={item} path={path} currentItemId={currentItemId} />;
172
+ return <L1PanelCollection key={item.id} item={item} {...props} />;
192
173
  case 'tab':
193
- return <L1Panel key={item.id} item={item} path={path} currentItemId={currentItemId} onBack={onBack} />;
174
+ return <L1Panel key={item.id} item={item} {...props} onBack={onBack} />;
194
175
  default:
195
176
  return null;
196
177
  }
@@ -0,0 +1,6 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './L0Menu';
6
+ export * from './L1Panel';
@@ -5,17 +5,17 @@
5
5
  import '@dxos-theme';
6
6
 
7
7
  import { type Meta } from '@storybook/react';
8
- import React from 'react';
9
8
 
10
- import { UserAccountAvatar } from './UserAccountAvatar';
9
+ import { withTheme } from '@dxos/storybook-utils';
11
10
 
12
- export const Default = (props: any) => {
13
- return <UserAccountAvatar {...props} />;
14
- };
11
+ import { UserAccountAvatar } from './UserAccountAvatar';
15
12
 
16
13
  const meta: Meta<typeof UserAccountAvatar> = {
17
14
  title: 'plugins/plugin-navtree/UserAccountAvatar',
18
15
  component: UserAccountAvatar,
16
+ decorators: [withTheme],
19
17
  };
20
18
 
21
19
  export default meta;
20
+
21
+ export const Default = {};
@@ -15,18 +15,18 @@ export type UserAccountAvatarProps = {
15
15
  status?: AvatarStatus;
16
16
  };
17
17
 
18
- export const UserAccountAvatar = (props: UserAccountAvatarProps) => {
19
- const fallbackValue = hexToFallback(props.userId ?? '0');
18
+ export const UserAccountAvatar = ({ size, userId, hue, emoji, status }: UserAccountAvatarProps) => {
19
+ const fallbackValue = hexToFallback(userId ?? '0');
20
20
 
21
21
  return (
22
22
  <div className='grid place-items-center' data-joyride='welcome/account'>
23
23
  <Avatar.Root>
24
24
  <Avatar.Content
25
25
  variant='circle'
26
- size={props.size ?? 12}
27
- status={props.status ?? 'active'}
28
- hue={props.hue || fallbackValue.hue}
29
- fallback={props.emoji || fallbackValue.emoji}
26
+ size={size ?? 12}
27
+ status={status ?? 'active'}
28
+ hue={hue || fallbackValue.hue}
29
+ fallback={emoji || fallbackValue.emoji}
30
30
  data-testid='treeView.userAccount'
31
31
  />
32
32
  </Avatar.Root>
@@ -0,0 +1,5 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ export * from './UserAccountAvatar';
@@ -3,7 +3,6 @@
3
3
  //
4
4
 
5
5
  export * from './CommandsDialog';
6
- export * from './CommandsTrigger';
7
6
  export * from './NavTree';
8
7
  export * from './NavTreeContainer';
9
8
  export * from './NavTreeContext';