@dxos/plugin-navtree 0.8.3-staging.0fa589b → 0.8.4-main.1068cf700f

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 (185) hide show
  1. package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs +44 -0
  2. package/dist/lib/browser/app-graph-builder-XGA4GPGL.mjs.map +7 -0
  3. package/dist/lib/browser/chunk-63YLDLLE.mjs +1373 -0
  4. package/dist/lib/browser/chunk-63YLDLLE.mjs.map +7 -0
  5. package/dist/lib/browser/chunk-X2HDG62A.mjs +23 -0
  6. package/dist/lib/browser/chunk-X2HDG62A.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 +89 -100
  10. package/dist/lib/browser/index.mjs.map +4 -4
  11. package/dist/lib/browser/{keyboard-DDFATRUG.mjs → keyboard-46XQHY2O.mjs} +21 -19
  12. package/dist/lib/browser/keyboard-46XQHY2O.mjs.map +7 -0
  13. package/dist/lib/browser/meta.json +1 -1
  14. package/dist/lib/browser/operation-resolver-NNNDII45.mjs +53 -0
  15. package/dist/lib/browser/operation-resolver-NNNDII45.mjs.map +7 -0
  16. package/dist/lib/browser/react-surface-APSEG23H.mjs +59 -0
  17. package/dist/lib/browser/react-surface-APSEG23H.mjs.map +7 -0
  18. package/dist/lib/browser/state-M5YUCIQU.mjs +121 -0
  19. package/dist/lib/browser/state-M5YUCIQU.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 +6 -7
  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 +23 -6
  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 +14 -13
  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 +56 -55
  106. package/src/NavTreePlugin.tsx +64 -84
  107. package/src/capabilities/app-graph-builder/app-graph-builder.ts +42 -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 +66 -0
  112. package/src/capabilities/operation-resolver/index.ts +7 -0
  113. package/src/capabilities/operation-resolver/operation-resolver.ts +42 -0
  114. package/src/capabilities/react-surface/index.ts +7 -0
  115. package/src/capabilities/react-surface/react-surface.tsx +55 -0
  116. package/src/capabilities/state/index.ts +7 -0
  117. package/src/capabilities/state/state.ts +122 -0
  118. package/src/components/CommandsDialog/CommandsDialog.tsx +108 -98
  119. package/src/components/CommandsDialog/CommandsTrigger.tsx +8 -19
  120. package/src/components/NavTree/NavTree.stories.tsx +100 -94
  121. package/src/components/NavTree/NavTree.tsx +12 -18
  122. package/src/components/NavTreeContainer.tsx +283 -259
  123. package/src/components/NavTreeDocumentTitle.tsx +5 -4
  124. package/src/components/NavTreeItem/NavTreeItemAction.stories.tsx +21 -13
  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 +115 -143
  128. package/src/components/Sidebar/L1Panel.tsx +177 -122
  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 +77 -85
  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 +7 -4
  144. package/src/types/capabilities.ts +21 -0
  145. package/src/types/events.ts +12 -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-P7AY3K72.mjs +0 -45
  150. package/dist/lib/browser/app-graph-builder-P7AY3K72.mjs.map +0 -7
  151. package/dist/lib/browser/chunk-33VLL4IJ.mjs +0 -15
  152. package/dist/lib/browser/chunk-33VLL4IJ.mjs.map +0 -7
  153. package/dist/lib/browser/chunk-IEW3JD5C.mjs +0 -16
  154. package/dist/lib/browser/chunk-IEW3JD5C.mjs.map +0 -7
  155. package/dist/lib/browser/chunk-ZJPL4XJD.mjs +0 -1429
  156. package/dist/lib/browser/chunk-ZJPL4XJD.mjs.map +0 -7
  157. package/dist/lib/browser/intent-resolver-NAYKKAOP.mjs +0 -47
  158. package/dist/lib/browser/intent-resolver-NAYKKAOP.mjs.map +0 -7
  159. package/dist/lib/browser/keyboard-DDFATRUG.mjs.map +0 -7
  160. package/dist/lib/browser/react-surface-H3JRTVNU.mjs +0 -51
  161. package/dist/lib/browser/react-surface-H3JRTVNU.mjs.map +0 -7
  162. package/dist/lib/browser/state-J6AKZRB4.mjs +0 -117
  163. package/dist/lib/browser/state-J6AKZRB4.mjs.map +0 -7
  164. package/dist/types/src/capabilities/app-graph-builder.d.ts +0 -4
  165. package/dist/types/src/capabilities/app-graph-builder.d.ts.map +0 -1
  166. package/dist/types/src/capabilities/capabilities.d.ts +0 -21
  167. package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
  168. package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
  169. package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
  170. package/dist/types/src/capabilities/keyboard.d.ts +0 -4
  171. package/dist/types/src/capabilities/keyboard.d.ts.map +0 -1
  172. package/dist/types/src/capabilities/react-surface.d.ts +0 -4
  173. package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
  174. package/dist/types/src/capabilities/state.d.ts +0 -20
  175. package/dist/types/src/capabilities/state.d.ts.map +0 -1
  176. package/dist/types/src/events.d.ts +0 -4
  177. package/dist/types/src/events.d.ts.map +0 -1
  178. package/dist/types/src/types.d.ts.map +0 -1
  179. package/src/capabilities/app-graph-builder.ts +0 -52
  180. package/src/capabilities/capabilities.ts +0 -20
  181. package/src/capabilities/intent-resolver.ts +0 -37
  182. package/src/capabilities/keyboard.ts +0 -59
  183. package/src/capabilities/react-surface.tsx +0 -45
  184. package/src/capabilities/state.ts +0 -104
  185. package/src/events.ts +0 -11
@@ -0,0 +1,122 @@
1
+ //
2
+ // Copyright 2025 DXOS.org
3
+ //
4
+
5
+ import { Atom } from '@effect-atom/atom-react';
6
+ import * as Effect from 'effect/Effect';
7
+
8
+ import { Capabilities, Capability } from '@dxos/app-framework';
9
+ import { AppCapabilities } from '@dxos/app-toolkit';
10
+ import { Path } from '@dxos/react-ui-list';
11
+
12
+ import { meta } from '../../meta';
13
+ import { type NavTreeCapabilities as NC, NavTreeCapabilities } from '../../types';
14
+
15
+ const KEY = `${meta.id}/state/v1`;
16
+
17
+ /** Default item state for new entries. */
18
+ const defaultItemState: NC.NavTreeItemState = { open: false, current: false, alternateTree: false };
19
+
20
+ /** Default state entries for initial tree structure. */
21
+ // TODO(thure): Initialize these dynamically.
22
+ const defaultStateEntries: [string, NC.NavTreeItemState][] = [
23
+ ['root', { open: true, current: false }],
24
+ ['root~dxos.org/plugin/space-spaces', { open: true, current: false }],
25
+ ['root~dxos.org/plugin/files', { open: true, current: false }],
26
+ ];
27
+
28
+ const getInitialState = (): Map<string, NC.NavTreeItemState> => {
29
+ const stringified = localStorage.getItem(KEY);
30
+ if (!stringified) {
31
+ return new Map(defaultStateEntries);
32
+ }
33
+
34
+ try {
35
+ const cached: [string, { open: boolean; current: boolean }][] = JSON.parse(stringified);
36
+ return new Map(cached.map(([key, value]) => [key, { open: value.open, current: false }]));
37
+ } catch {
38
+ return new Map(defaultStateEntries);
39
+ }
40
+ };
41
+
42
+ export default Capability.makeModule(
43
+ Effect.fnUntraced(function* () {
44
+ const registry = yield* Capability.get(Capabilities.AtomRegistry);
45
+ const layoutAtom = yield* Capability.get(AppCapabilities.Layout);
46
+
47
+ // Backing state for persistence (not reactive).
48
+ const backingState = getInitialState();
49
+
50
+ // Per-path atom family for fine-grained reactivity.
51
+ // keepAlive prevents atoms from being garbage collected when components unmount,
52
+ // ensuring state is preserved across deletion/restoration cycles.
53
+ const itemAtomFamily = Atom.family((pathString: string) =>
54
+ Atom.make<NC.NavTreeItemState>(backingState.get(pathString) ?? { ...defaultItemState }).pipe(Atom.keepAlive),
55
+ );
56
+
57
+ const getItemAtom = (path: string[]): Atom.Atom<NC.NavTreeItemState> => {
58
+ const pathString = Path.create(...path);
59
+ return itemAtomFamily(pathString);
60
+ };
61
+
62
+ const getItem = (path: string[]): NC.NavTreeItemState => {
63
+ return registry.get(getItemAtom(path));
64
+ };
65
+
66
+ const setItem = (path: string[], key: 'open' | 'current' | 'alternateTree', next: boolean) => {
67
+ const pathString = Path.create(...path);
68
+ const atom = itemAtomFamily(pathString);
69
+ const currentValue = registry.get(atom);
70
+ const newValue = { ...currentValue, [key]: next };
71
+
72
+ // Update the atom.
73
+ registry.set(atom, newValue);
74
+
75
+ // Update backing state and persist to localStorage.
76
+ backingState.set(pathString, newValue);
77
+ localStorage.setItem(KEY, JSON.stringify(Array.from(backingState.entries())));
78
+ };
79
+
80
+ // Subscribe to layout changes to update current state.
81
+ let previous: string[] = [];
82
+ const unsubscribe = registry.subscribe(layoutAtom, (layout) => {
83
+ const removed = previous.filter((id) => !layout.active.includes(id));
84
+ previous = layout.active;
85
+
86
+ const handleUpdate = () => {
87
+ // Mark removed items as not current.
88
+ removed.forEach((id) => {
89
+ const keys = Array.from(backingState.keys()).filter((key) => Path.last(key) === id);
90
+ keys.forEach((key) => {
91
+ setItem(Path.parts(key), 'current', false);
92
+ });
93
+ });
94
+
95
+ // Mark active items as current.
96
+ layout.active.forEach((id: string) => {
97
+ const keys = Array.from(new Set([...backingState.keys(), id])).filter((key) => Path.last(key) === id);
98
+ keys.forEach((key) => {
99
+ setItem(Path.parts(key), 'current', true);
100
+ });
101
+ });
102
+ };
103
+
104
+ // TODO(wittjosiah): This is setTimeout because there's a race between the keys being initialized.
105
+ // Keys are initialized on the first render of an item in the navtree.
106
+ // This could be avoided if the location was a path as well and not just an id.
107
+ const timeout = setTimeout(handleUpdate, 500);
108
+ handleUpdate();
109
+ return () => clearTimeout(timeout);
110
+ });
111
+
112
+ return Capability.contributes(
113
+ NavTreeCapabilities.State,
114
+ {
115
+ getItem,
116
+ getItemAtom,
117
+ setItem,
118
+ },
119
+ () => Effect.sync(() => unsubscribe()),
120
+ );
121
+ }),
122
+ );
@@ -2,117 +2,127 @@
2
2
  // Copyright 2023 DXOS.org
3
3
  //
4
4
 
5
- import React, { useMemo, useState } from 'react';
5
+ import React, { forwardRef, useMemo, useState } from 'react';
6
6
 
7
- import { createIntent, LayoutAction, useAppGraph, useIntentDispatcher } from '@dxos/app-framework';
8
- import { type ActionLike, isAction, isActionGroup } from '@dxos/app-graph';
7
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
8
+ import { LayoutOperation } from '@dxos/app-toolkit';
9
+ import { useAppGraph } from '@dxos/app-toolkit/ui';
9
10
  import { Keyboard, keySymbols } from '@dxos/keyboard';
11
+ import { Graph, Node, useActionRunner } from '@dxos/plugin-graph';
10
12
  import { useActions } from '@dxos/plugin-graph';
11
- import { Button, Dialog, Icon, useTranslation, toLocalizedString } from '@dxos/react-ui';
12
- import { SearchList } from '@dxos/react-ui-searchlist';
13
- import {
14
- cardDialogContent,
15
- cardDialogHeader,
16
- cardDialogPaddedOverflow,
17
- cardDialogSearchListRoot,
18
- } from '@dxos/react-ui-stack';
19
- import { descriptionText, mx } from '@dxos/react-ui-theme';
13
+ import { Button, Dialog, toLocalizedString, useTranslation } from '@dxos/react-ui';
14
+ import { SearchList, useSearchListResults } from '@dxos/react-ui-searchlist';
15
+ import { osTranslations } from '@dxos/ui-theme';
20
16
  import { getHostPlatform } from '@dxos/util';
21
17
 
22
- import { KEY_BINDING, NAVTREE_PLUGIN } from '../../meta';
18
+ import { KEY_BINDING, meta } from '../../meta';
19
+
20
+ export type CommandsDialogContentProps = {
21
+ selected?: string;
22
+ };
23
23
 
24
24
  // TODO(wittjosiah): This probably deserves its own plugin but for now it lives here w/ other navigation UI.
25
- export const CommandsDialogContent = ({ selected: initial }: { selected?: string }) => {
26
- const { t } = useTranslation(NAVTREE_PLUGIN);
27
- const [selected, setSelected] = useState<string | undefined>(initial);
28
- const { dispatchPromise: dispatch } = useIntentDispatcher();
29
- const { graph } = useAppGraph();
25
+ export const CommandsDialogContent = forwardRef<HTMLDivElement, CommandsDialogContentProps>(
26
+ ({ selected: initial }, forwardedRef) => {
27
+ const { t } = useTranslation(meta.id);
28
+ const { invokeSync } = useOperationInvoker();
29
+ const runAction = useActionRunner();
30
+ const { graph } = useAppGraph();
31
+ const [selected, setSelected] = useState<string | undefined>(initial);
30
32
 
31
- // Traverse graph.
32
- // TODO(burdon): Factor out commonality with shortcut dialog.
33
- const allActions = useMemo(() => {
34
- // TODO(burdon): Get from navtree (not keyboard).
35
- const current = Keyboard.singleton.getCurrentContext();
36
- const actionMap = new Set<string>();
37
- const actions: ActionLike[] = [];
38
- graph.traverse({
39
- visitor: (node, path) => {
40
- if (
41
- (isAction(node) || isActionGroup(node)) &&
42
- !actionMap.has(node.id) &&
43
- current.startsWith(path.slice(0, -1).join('/'))
44
- ) {
45
- actionMap.add(node.id);
46
- actions.push(node);
47
- }
48
- },
49
- });
33
+ // Traverse graph.
34
+ // TODO(burdon): Factor out commonality with shortcut dialog.
35
+ const allActions = useMemo(() => {
36
+ // TODO(burdon): Get from navtree (not keyboard).
37
+ const current = Keyboard.singleton.getCurrentContext();
38
+ const actionMap = new Set<string>();
39
+ const actions: Node.ActionLike[] = [];
40
+ Graph.traverse(graph, {
41
+ visitor: (node, path) => {
42
+ if (
43
+ (Node.isAction(node) || Node.isActionGroup(node)) &&
44
+ !actionMap.has(node.id) &&
45
+ current.startsWith(path.slice(0, -1).join('/'))
46
+ ) {
47
+ actionMap.add(node.id);
48
+ actions.push(node);
49
+ }
50
+ },
51
+ });
50
52
 
51
- actions.sort((a, b) => {
52
- return toLocalizedString(a.properties.label, t)
53
- ?.toLowerCase()
54
- .localeCompare(toLocalizedString(b.properties.label, t)?.toLowerCase());
55
- });
53
+ actions.sort((a, b) => {
54
+ return toLocalizedString(a.properties.label, t)
55
+ ?.toLowerCase()
56
+ .localeCompare(toLocalizedString(b.properties.label, t)?.toLowerCase());
57
+ });
56
58
 
57
- return actions;
58
- }, [graph]);
59
+ return actions;
60
+ }, [graph]);
59
61
 
60
- const group = allActions.find(({ id }) => id === selected);
61
- const groupActions = useActions(graph, group?.id);
62
- const actions = isActionGroup(group) ? groupActions : allActions;
62
+ const group = allActions.find(({ id }) => id === selected);
63
+ const groupActions = useActions(graph, group?.id);
64
+ const actions = Node.isActionGroup(group) ? groupActions : allActions;
63
65
 
64
- return (
65
- <Dialog.Content classNames={cardDialogContent}>
66
- <Dialog.Title classNames={cardDialogHeader}>{t('commands dialog title', { ns: NAVTREE_PLUGIN })}</Dialog.Title>
66
+ const { results, handleSearch } = useSearchListResults({
67
+ items: actions,
68
+ extract: (action) => toLocalizedString(action.properties.label, t),
69
+ });
67
70
 
68
- {/* TODO(burdon): BUG: Overscrolls container. */}
69
- <SearchList.Root label={t('command list input placeholder')} classNames={cardDialogSearchListRoot}>
70
- <SearchList.Input placeholder={t('command list input placeholder')} />
71
- <SearchList.Content classNames={cardDialogPaddedOverflow}>
72
- {actions?.map((action) => {
73
- const label = toLocalizedString(action.properties.label, t);
74
- const shortcut =
75
- typeof action.properties.keyBinding === 'string'
76
- ? action.properties.keyBinding
77
- : action.properties.keyBinding?.[getHostPlatform()];
78
- return (
79
- <SearchList.Item
80
- value={label}
81
- key={action.id}
82
- onSelect={() => {
83
- if (action.properties.disabled) {
84
- return;
85
- }
71
+ return (
72
+ <Dialog.Content ref={forwardedRef}>
73
+ <Dialog.Title>{t('commands dialog title', { ns: meta.id })}</Dialog.Title>
74
+ <SearchList.Root onSearch={handleSearch}>
75
+ <SearchList.Content>
76
+ <SearchList.Input placeholder={t('command list input placeholder')} />
77
+ <SearchList.Viewport>
78
+ {results.map((action) => {
79
+ const shortcut =
80
+ typeof action.properties.keyBinding === 'string'
81
+ ? action.properties.keyBinding
82
+ : action.properties.keyBinding?.[getHostPlatform()];
86
83
 
87
- if (isActionGroup(action)) {
88
- setSelected(action.id);
89
- return;
90
- }
84
+ return (
85
+ <SearchList.Item
86
+ value={action.id}
87
+ key={action.id}
88
+ label={toLocalizedString(action.properties.label, t)}
89
+ icon={action.properties.icon}
90
+ suffix={shortcut ? keySymbols(shortcut).join('') : undefined}
91
+ onSelect={() => {
92
+ if (action.properties.disabled) {
93
+ return;
94
+ }
91
95
 
92
- void dispatch(createIntent(LayoutAction.UpdateDialog, { part: 'dialog', options: { state: false } }));
93
- setTimeout(() => {
94
- const node = graph.getConnections(group?.id ?? action.id, 'inbound')[0];
95
- void (node && isAction(action) && action.data({ parent: node, caller: KEY_BINDING }));
96
- });
97
- }}
98
- classNames='flex items-center gap-2'
99
- disabled={action.properties.disabled}
100
- {...(action.properties?.testId && { 'data-testid': action.properties.testId })}
101
- >
102
- <Icon icon={action.properties.icon} size={4} />
103
- <span className='grow truncate'>{label}</span>
104
- {shortcut && <span className={mx('shrink-0', descriptionText)}>{keySymbols(shortcut).join('')}</span>}
105
- </SearchList.Item>
106
- );
107
- })}
108
- </SearchList.Content>
109
- </SearchList.Root>
96
+ if (Node.isActionGroup(action)) {
97
+ setSelected(action.id);
98
+ return;
99
+ }
110
100
 
111
- <div role='none' className='pli-cardSpacingInline pbe-cardSpacingBlock'>
112
- <Dialog.Close asChild>
113
- <Button classNames='is-full'>{t('close label', { ns: 'os' })}</Button>
114
- </Dialog.Close>
115
- </div>
116
- </Dialog.Content>
117
- );
118
- };
101
+ invokeSync(LayoutOperation.UpdateDialog, { state: false });
102
+ setTimeout(() => {
103
+ const node = Graph.getConnections(graph, group?.id ?? action.id, 'inbound')[0];
104
+ if (node && Node.isAction(action)) {
105
+ void runAction(action, { parent: node, caller: KEY_BINDING });
106
+ }
107
+ });
108
+ }}
109
+ classNames='flex items-center gap-2'
110
+ disabled={action.properties.disabled}
111
+ {...(action.properties?.testId && {
112
+ 'data-testid': action.properties.testId,
113
+ })}
114
+ />
115
+ );
116
+ })}
117
+ </SearchList.Viewport>
118
+ </SearchList.Content>
119
+ </SearchList.Root>
120
+ <div role='none' className='pli-cardSpacingInline pbe-cardSpacingBlock'>
121
+ <Dialog.Close asChild>
122
+ <Button classNames='is-full'>{t('close label', { ns: osTranslations })}</Button>
123
+ </Dialog.Close>
124
+ </div>
125
+ </Dialog.Content>
126
+ );
127
+ },
128
+ );
@@ -2,36 +2,25 @@
2
2
  // Copyright 2024 DXOS.org
3
3
  //
4
4
 
5
- import { MagnifyingGlass } from '@phosphor-icons/react';
6
5
  import React from 'react';
7
6
 
8
- import { createIntent, LayoutAction, useIntentDispatcher } from '@dxos/app-framework';
9
- import { Button, useTranslation } from '@dxos/react-ui';
10
- import { getSize } from '@dxos/react-ui-theme';
7
+ import { useOperationInvoker } from '@dxos/app-framework/ui';
8
+ import { LayoutOperation } from '@dxos/app-toolkit';
9
+ import { Button, Icon, useTranslation } from '@dxos/react-ui';
11
10
 
12
- import { COMMANDS_DIALOG, NAVTREE_PLUGIN } from '../../meta';
11
+ import { COMMANDS_DIALOG, meta } from '../../meta';
13
12
 
14
13
  // TODO(thure): Refactor to be handled by a more appropriate plugin.
15
14
  export const CommandsTrigger = () => {
16
- const { dispatchPromise: dispatch } = useIntentDispatcher();
17
- const { t } = useTranslation(NAVTREE_PLUGIN);
15
+ const { invokeSync } = useOperationInvoker();
16
+ const { t } = useTranslation(meta.id);
18
17
  return (
19
18
  <Button
20
19
  classNames='m-1 pli-1 lg:pli-2'
21
- onClick={() =>
22
- dispatch(
23
- createIntent(LayoutAction.UpdateDialog, {
24
- part: 'dialog',
25
- subject: COMMANDS_DIALOG,
26
- options: {
27
- blockAlign: 'start',
28
- },
29
- }),
30
- )
31
- }
20
+ onClick={() => invokeSync(LayoutOperation.UpdateDialog, { subject: COMMANDS_DIALOG, blockAlign: 'start' })}
32
21
  >
33
22
  <span className='text-description font-normal grow text-start'>{t('command list input placeholder')}</span>
34
- <MagnifyingGlass className={getSize(5)} />
23
+ <Icon icon='ph--magnifying-glass--regular' size={5} />
35
24
  </Button>
36
25
  );
37
26
  };