@dxos/plugin-navtree 0.7.4-staging.f7e8224 → 0.7.5-main.499c70c

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.
@@ -7,11 +7,11 @@ import { extractInstruction, type Instruction } from '@atlaskit/pragmatic-drag-a
7
7
  import { untracked } from '@preact/signals-core';
8
8
  import React, { memo, useCallback, useEffect } from 'react';
9
9
 
10
- import { LayoutAction, NavigationAction, Surface, useIntentDispatcher } from '@dxos/app-framework';
10
+ import { createIntent, LayoutAction, NavigationAction, Surface, useIntentDispatcher } from '@dxos/app-framework';
11
11
  import { isAction, isActionLike, type Node } from '@dxos/app-graph';
12
12
  import { useGraph } from '@dxos/plugin-graph';
13
13
  import { isEchoObject, isSpace } from '@dxos/react-client/echo';
14
- import { ElevationProvider, useMediaQuery, useSidebars } from '@dxos/react-ui';
14
+ import { useMediaQuery, useSidebars } from '@dxos/react-ui';
15
15
  import { isTreeData, type TreeData, type PropsFromTreeItem } from '@dxos/react-ui-list';
16
16
  import { mx } from '@dxos/react-ui-theme';
17
17
  import { arrayMove } from '@dxos/util';
@@ -32,8 +32,8 @@ import {
32
32
  // TODO(thure): Is NavTree truly authoritative in this regard?
33
33
  export const NODE_TYPE = 'dxos/app-graph/node';
34
34
 
35
- const renderItemEnd = ({ node }: { node: Node }) => (
36
- <Surface role='navtree-item-end' data={{ object: node.data, id: node.id }} />
35
+ const renderItemEnd = ({ node, open }: { node: Node; open: boolean }) => (
36
+ <Surface role='navtree-item-end' data={{ id: node.id, subject: node.data, open }} limit={1} />
37
37
  );
38
38
 
39
39
  export type NavTreeContainerProps = {
@@ -43,7 +43,7 @@ export type NavTreeContainerProps = {
43
43
  export const NavTreeContainer = memo(({ isCurrent, popoverAnchorId, ...props }: NavTreeContainerProps) => {
44
44
  const { closeNavigationSidebar } = useSidebars(NAVTREE_PLUGIN);
45
45
  const [isLg] = useMediaQuery('lg', { ssr: false });
46
- const dispatch = useIntentDispatcher();
46
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
47
47
  const { graph } = useGraph();
48
48
 
49
49
  const getActions = useCallback((node: Node) => naturalGetActions(graph, node), [graph]);
@@ -124,28 +124,11 @@ export const NavTreeContainer = memo(({ isCurrent, popoverAnchorId, ...props }:
124
124
 
125
125
  const current = isCurrent(path, node);
126
126
  if (!current) {
127
- void dispatch({
128
- action: NavigationAction.OPEN,
129
- data: {
130
- activeParts: {
131
- main: [node.id],
132
- },
133
- },
134
- });
127
+ void dispatch(createIntent(NavigationAction.Open, { activeParts: { main: [node.id] } }));
135
128
  } else if (option) {
136
- void dispatch({
137
- action: NavigationAction.CLOSE,
138
- data: {
139
- activeParts: {
140
- main: [node.id],
141
- },
142
- },
143
- });
129
+ void dispatch(createIntent(NavigationAction.Close, { activeParts: { main: [node.id] } }));
144
130
  } else {
145
- void dispatch({
146
- action: LayoutAction.SCROLL_INTO_VIEW,
147
- data: { id: node.id },
148
- });
131
+ void dispatch(createIntent(LayoutAction.ScrollIntoView, { id: node.id }));
149
132
  }
150
133
 
151
134
  const defaultAction = graph.actions(node).find((action) => action.properties?.disposition === 'default');
@@ -220,35 +203,30 @@ export const NavTreeContainer = memo(({ isCurrent, popoverAnchorId, ...props }:
220
203
  }, [graph]);
221
204
 
222
205
  return (
223
- <ElevationProvider elevation='chrome'>
224
- <div
225
- role='none'
226
- className='grid grid-cols-1 grid-rows-[var(--rail-size)_1fr_min-content] bs-full overflow-hidden'
227
- >
228
- {/* TODO(wittjosiah): Factor out surfaces to layout? */}
229
- <div role='none' className='border-be border-separator'>
230
- <Surface role='search-input' limit={1} />
231
- </div>
232
-
233
- {/* TODO(thure): What gives this an inline `overflow: initial`? */}
234
- <div role='none' className='border-be border-separator !overflow-y-auto'>
235
- <NavTree
236
- id={graph.root.id}
237
- getActions={getActions}
238
- getItems={getItems}
239
- getProps={getProps}
240
- isCurrent={isCurrent}
241
- loadDescendents={loadDescendents}
242
- renderItemEnd={renderItemEnd}
243
- popoverAnchorId={popoverAnchorId}
244
- canDrop={canDrop}
245
- onSelect={handleSelect}
246
- {...props}
247
- />
248
- </div>
249
-
250
- <NavTreeFooter />
206
+ <div role='none' className='grid grid-cols-1 grid-rows-[var(--rail-size)_1fr_min-content] bs-full overflow-hidden'>
207
+ {/* TODO(wittjosiah): Factor out surfaces to layout? */}
208
+ <div role='none' className='border-be border-separator'>
209
+ <Surface role='search-input' limit={1} />
251
210
  </div>
252
- </ElevationProvider>
211
+
212
+ {/* TODO(thure): What gives this an inline `overflow: initial`? */}
213
+ <div role='none' className='border-be border-separator !overflow-y-auto'>
214
+ <NavTree
215
+ id={graph.root.id}
216
+ getActions={getActions}
217
+ getItems={getItems}
218
+ getProps={getProps}
219
+ isCurrent={isCurrent}
220
+ loadDescendents={loadDescendents}
221
+ renderItemEnd={renderItemEnd}
222
+ popoverAnchorId={popoverAnchorId}
223
+ canDrop={canDrop}
224
+ onSelect={handleSelect}
225
+ {...props}
226
+ />
227
+ </div>
228
+
229
+ <NavTreeFooter />
230
+ </div>
253
231
  );
254
232
  });
@@ -12,6 +12,7 @@ import {
12
12
  parseNavigationPlugin,
13
13
  useResolvePlugin,
14
14
  useIntentDispatcher,
15
+ createIntent,
15
16
  } from '@dxos/app-framework';
16
17
  import { useConfig } from '@dxos/react-client';
17
18
  import {
@@ -41,7 +42,7 @@ export const NavTreeFooter = (props: { layoutPart?: LayoutPart }) => {
41
42
  const config = useConfig();
42
43
  const { t } = useTranslation(NAVTREE_PLUGIN);
43
44
  const { navigationSidebarOpen } = useSidebars(NAVTREE_PLUGIN);
44
- const dispatch = useIntentDispatcher();
45
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
45
46
  const { version, timestamp, commitHash } = config.values.runtime?.app?.build ?? {};
46
47
  const navigationPlugin = useResolvePlugin(parseNavigationPlugin);
47
48
  const [_, v] = version?.match(VERSION_REGEX) ?? [];
@@ -126,7 +127,7 @@ export const NavTreeFooter = (props: { layoutPart?: LayoutPart }) => {
126
127
  data-testid='treeView.openSettings'
127
128
  data-joyride='welcome/settings'
128
129
  {...(!navigationSidebarOpen && { tabIndex: -1 })}
129
- onClick={() => dispatch({ action: SettingsAction.OPEN })}
130
+ onClick={() => dispatch(createIntent(SettingsAction.Open))}
130
131
  >
131
132
  <span className='sr-only'>{t('open settings label')}</span>
132
133
  <GearSix className={mx(getSize(5), 'rotate-90')} />
@@ -90,7 +90,7 @@ export const NavTreeItemActionDropdownMenu = ({
90
90
  </DropdownMenu.Trigger>
91
91
  </Tooltip.Trigger>
92
92
  <DropdownMenu.Portal>
93
- <DropdownMenu.Content classNames='z-[31]'>
93
+ <DropdownMenu.Content>
94
94
  <DropdownMenu.Viewport>
95
95
  {menuActions?.map((action) => {
96
96
  const shortcut = getShortcut(action);
@@ -144,7 +144,7 @@ const NavTreeItemActionContextMenuImpl = ({
144
144
  <ContextMenu.Root>
145
145
  <ContextMenu.Trigger asChild>{children}</ContextMenu.Trigger>
146
146
  <ContextMenu.Portal>
147
- <ContextMenu.Content classNames='z-[31]'>
147
+ <ContextMenu.Content>
148
148
  <ContextMenu.Viewport>
149
149
  {menuActions?.map((action) => {
150
150
  const shortcut = getShortcut(action);
@@ -241,7 +241,7 @@ export const NavTreeItemActionSearchList = ({
241
241
  </Tooltip.Trigger>
242
242
  <Dialog.Portal>
243
243
  <Dialog.Overlay>
244
- <Dialog.Content classNames='z-[31] is-full max-is-[24rem] pli-2 plb-1'>
244
+ <Dialog.Content classNames='is-full max-is-[24rem] pli-2 plb-1'>
245
245
  <SearchList.Root label={t('tree item searchlist input placeholder')}>
246
246
  <SearchList.Input placeholder={t('tree item searchlist input placeholder')} classNames='pli-3' />
247
247
  <SearchList.Content classNames='min-bs-[12rem] bs-[50dvh] max-bs-[30rem] overflow-auto'>
@@ -4,8 +4,8 @@
4
4
 
5
5
  import React from 'react';
6
6
 
7
- import { useIntentDispatcher, useResolvePlugin } from '@dxos/app-framework';
8
- import { ClientAction } from '@dxos/plugin-client/meta';
7
+ import { createIntent, useIntentDispatcher, useResolvePlugin } from '@dxos/app-framework';
8
+ import { ClientAction } from '@dxos/plugin-client/types';
9
9
  import { parseObservabilityPlugin } from '@dxos/plugin-observability';
10
10
  import { useIdentity } from '@dxos/react-client/halo';
11
11
 
@@ -15,7 +15,7 @@ import { HaloButton } from './HaloButton';
15
15
  export const NotchStart = () => {
16
16
  const identity = useIdentity();
17
17
  const observabilityPlugin = useResolvePlugin(parseObservabilityPlugin);
18
- const dispatch = useIntentDispatcher();
18
+ const { dispatchPromise: dispatch } = useIntentDispatcher();
19
19
  return (
20
20
  <HaloButton
21
21
  size={8}
@@ -23,7 +23,7 @@ export const NotchStart = () => {
23
23
  hue={identity?.profile?.data?.hue}
24
24
  emoji={identity?.profile?.data?.emoji}
25
25
  internal={observabilityPlugin?.provides?.observability?.group === 'dxos'}
26
- onClick={() => dispatch({ action: ClientAction.SHARE_IDENTITY })}
26
+ onClick={() => dispatch(createIntent(ClientAction.ShareIdentity))}
27
27
  />
28
28
  );
29
29
  };
package/src/meta.ts CHANGED
@@ -8,6 +8,8 @@ export const NAVTREE_PLUGIN = 'dxos.org/plugin/navtree';
8
8
 
9
9
  // TODO(wittjosiah): Factor out.
10
10
  export const KEY_BINDING = 'KeyBinding';
11
+ // TODO(wittjosiah): Factor out.
12
+ export const COMMANDS_DIALOG = `${NAVTREE_PLUGIN}/CommandsDialog`;
11
13
 
12
14
  export default {
13
15
  id: NAVTREE_PLUGIN,
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../src/meta.ts"],
4
- "sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport { type PluginMeta } from '@dxos/app-framework';\n\nexport const NAVTREE_PLUGIN = 'dxos.org/plugin/navtree';\n\n// TODO(wittjosiah): Factor out.\nexport const KEY_BINDING = 'KeyBinding';\n\nexport default {\n id: NAVTREE_PLUGIN,\n} satisfies PluginMeta;\n"],
5
- "mappings": ";AAMO,IAAMA,iBAAiB;AAGvB,IAAMC,cAAc;AAE3B,IAAA,eAAe;EACbC,IAAIF;AACN;",
6
- "names": ["NAVTREE_PLUGIN", "KEY_BINDING", "id"]
7
- }