@dxos/plugin-navtree 0.9.1-staging.ee54ba693a → 0.11.0
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.
- package/PLUGIN.mdl +8 -6
- package/dist/lib/NavTreePlugin.mjs +40 -0
- package/dist/lib/NavTreePlugin.mjs.map +1 -0
- package/dist/lib/capabilities.mjs +11 -0
- package/dist/lib/capabilities.mjs.map +1 -0
- package/dist/lib/chunk-CommandsDialogContent.mjs +100 -0
- package/dist/lib/chunk-CommandsDialogContent.mjs.map +1 -0
- package/dist/lib/chunk-CommandsTrigger.mjs +27 -0
- package/dist/lib/chunk-CommandsTrigger.mjs.map +1 -0
- package/dist/lib/chunk-NavTreeDocumentTitle.mjs +17 -0
- package/dist/lib/chunk-NavTreeDocumentTitle.mjs.map +1 -0
- package/dist/lib/chunk-app-graph-builder.mjs +33 -0
- package/dist/lib/chunk-app-graph-builder.mjs.map +1 -0
- package/dist/lib/chunk-expose.mjs +31 -0
- package/dist/lib/chunk-expose.mjs.map +1 -0
- package/dist/lib/chunk-keyboard.mjs +49 -0
- package/dist/lib/chunk-keyboard.mjs.map +1 -0
- package/dist/lib/{neutral/chunk-IRQMJLRY.mjs → chunk-meta.mjs} +14 -23
- package/dist/lib/chunk-meta.mjs.map +1 -0
- package/dist/lib/chunk-operation-handler.mjs +11 -0
- package/dist/lib/chunk-operation-handler.mjs.map +1 -0
- package/dist/lib/chunk-react-surface.mjs +46 -0
- package/dist/lib/chunk-react-surface.mjs.map +1 -0
- package/dist/lib/chunk-state.mjs +106 -0
- package/dist/lib/chunk-state.mjs.map +1 -0
- package/dist/lib/chunk-types.mjs +26 -0
- package/dist/lib/chunk-types.mjs.map +1 -0
- package/dist/lib/chunk-util.mjs +51 -0
- package/dist/lib/chunk-util.mjs.map +1 -0
- package/dist/lib/components.mjs +723 -0
- package/dist/lib/components.mjs.map +1 -0
- package/dist/lib/containers.mjs +231 -0
- package/dist/lib/containers.mjs.map +1 -0
- package/dist/lib/hooks.mjs +162 -0
- package/dist/lib/hooks.mjs.map +1 -0
- package/dist/lib/index.mjs +4 -0
- package/dist/lib/meta.mjs +2 -0
- package/dist/lib/operations.mjs +7 -0
- package/dist/lib/operations.mjs.map +1 -0
- package/dist/lib/plugin.mjs +9 -0
- package/dist/lib/plugin.mjs.map +1 -0
- package/dist/lib/testing.mjs +397 -0
- package/dist/lib/testing.mjs.map +1 -0
- package/dist/lib/translations.mjs +17 -0
- package/dist/lib/translations.mjs.map +1 -0
- package/dist/lib/types.mjs +2 -0
- package/dist/types/src/NavTreePlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/app-graph-builder.d.ts +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +1 -1
- package/dist/types/src/capabilities/nav-tree-view-state.d.ts +12 -0
- package/dist/types/src/capabilities/nav-tree-view-state.d.ts.map +1 -0
- package/dist/types/src/capabilities/nav-tree-view-state.test.d.ts +2 -0
- package/dist/types/src/capabilities/nav-tree-view-state.test.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-handler.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +1 -1
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -1
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +3 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContext/NavTreeContext.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts +1 -1
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +5 -2
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -1
- package/dist/types/src/components/Sidebar/L1Tabs.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts +2 -0
- package/dist/types/src/containers/CommandsDialogContent/CommandsDialogContent.stories.d.ts.map +1 -1
- package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts +4 -1
- package/dist/types/src/containers/CommandsTrigger/CommandsTrigger.d.ts.map +1 -1
- package/dist/types/src/containers/NavTreeContainer/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts +5 -2
- package/dist/types/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts +0 -1
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.stories.d.ts.map +1 -1
- package/dist/types/src/experimental/visit-nodes.d.ts +3 -0
- package/dist/types/src/experimental/visit-nodes.d.ts.map +1 -0
- package/dist/types/src/hooks/useActions.d.ts +3 -1
- package/dist/types/src/hooks/useActions.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +2 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/NavTreeCapabilities.d.ts +1 -1
- package/dist/types/src/types/NavTreeCapabilities.d.ts.map +1 -1
- package/dist/types/src/types/schema.d.ts +1 -1
- package/dist/types/src/types/schema.d.ts.map +1 -1
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +47 -52
- package/src/NavTreePlugin.tsx +3 -1
- package/src/capabilities/nav-tree-view-state.test.ts +55 -0
- package/src/capabilities/nav-tree-view-state.ts +19 -0
- package/src/capabilities/{react-surface.tsx → react-surface.ts} +8 -9
- package/src/capabilities/state.ts +47 -38
- package/src/components/NavTree/NavTree.stories.tsx +26 -5
- package/src/components/NavTree/NavTree.tsx +10 -13
- package/src/components/NavTreeItem/NavTreeItemAction.tsx +1 -1
- package/src/components/Sidebar/L0Menu.tsx +9 -3
- package/src/components/Sidebar/L1Panel.tsx +52 -20
- package/src/components/Sidebar/L1Tabs.tsx +6 -0
- package/src/containers/CommandsDialogContent/CommandsDialogContent.tsx +49 -44
- package/src/containers/CommandsTrigger/CommandsTrigger.tsx +2 -0
- package/src/containers/NavTreeContainer/NavTreeContainer.tsx +17 -18
- package/src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.tsx +2 -0
- package/src/experimental/Tree.stories.tsx +2 -1
- package/src/experimental/Tree.tsx +2 -18
- package/src/experimental/visit-nodes.ts +27 -0
- package/src/hooks/useActions.ts +15 -4
- package/src/hooks/useNavTreeModel.ts +1 -1
- package/src/operations/expose.ts +2 -2
- package/src/testing/app-graph-builder.ts +1 -1
- package/src/translations.ts +3 -0
- package/src/types/NavTreeCapabilities.ts +1 -1
- package/src/types/schema.ts +1 -1
- package/src/util.ts +7 -9
- package/dist/lib/neutral/CommandsDialogContent-TEKBCQ3U.mjs +0 -112
- package/dist/lib/neutral/CommandsDialogContent-TEKBCQ3U.mjs.map +0 -7
- package/dist/lib/neutral/CommandsTrigger-HGCI22SP.mjs +0 -27
- package/dist/lib/neutral/CommandsTrigger-HGCI22SP.mjs.map +0 -7
- package/dist/lib/neutral/NavTreeContainer-ICDKC2GI.mjs +0 -12
- package/dist/lib/neutral/NavTreeContainer-ICDKC2GI.mjs.map +0 -7
- package/dist/lib/neutral/NavTreeDocumentTitle-RMERXZGK.mjs +0 -22
- package/dist/lib/neutral/NavTreeDocumentTitle-RMERXZGK.mjs.map +0 -7
- package/dist/lib/neutral/NavTreePlugin.mjs +0 -68
- package/dist/lib/neutral/NavTreePlugin.mjs.map +0 -7
- package/dist/lib/neutral/NavTreePlugin.node.mjs +0 -18
- package/dist/lib/neutral/NavTreePlugin.node.mjs.map +0 -7
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs +0 -16
- package/dist/lib/neutral/NavTreePlugin.workerd.mjs.map +0 -7
- package/dist/lib/neutral/app-graph-builder-2DYAIROU.mjs +0 -42
- package/dist/lib/neutral/app-graph-builder-2DYAIROU.mjs.map +0 -7
- package/dist/lib/neutral/capabilities/index.mjs +0 -17
- package/dist/lib/neutral/capabilities/index.mjs.map +0 -7
- package/dist/lib/neutral/chunk-4RN6TH36.mjs +0 -292
- package/dist/lib/neutral/chunk-4RN6TH36.mjs.map +0 -7
- package/dist/lib/neutral/chunk-BAVI2K7A.mjs +0 -27
- package/dist/lib/neutral/chunk-BAVI2K7A.mjs.map +0 -7
- package/dist/lib/neutral/chunk-EAN4K6OL.mjs +0 -8
- package/dist/lib/neutral/chunk-EAN4K6OL.mjs.map +0 -7
- package/dist/lib/neutral/chunk-IRQMJLRY.mjs.map +0 -7
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs +0 -10
- package/dist/lib/neutral/chunk-J5LGTIGS.mjs.map +0 -7
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs +0 -79
- package/dist/lib/neutral/chunk-JOSNCOV4.mjs.map +0 -7
- package/dist/lib/neutral/components/index.mjs +0 -814
- package/dist/lib/neutral/components/index.mjs.map +0 -7
- package/dist/lib/neutral/containers/index.mjs +0 -20
- package/dist/lib/neutral/containers/index.mjs.map +0 -7
- package/dist/lib/neutral/expose-HIBA2NQG.mjs +0 -38
- package/dist/lib/neutral/expose-HIBA2NQG.mjs.map +0 -7
- package/dist/lib/neutral/hooks/index.mjs +0 -181
- package/dist/lib/neutral/hooks/index.mjs.map +0 -7
- package/dist/lib/neutral/index.mjs +0 -34
- package/dist/lib/neutral/index.mjs.map +0 -7
- package/dist/lib/neutral/keyboard-JM2HCF5N.mjs +0 -58
- package/dist/lib/neutral/keyboard-JM2HCF5N.mjs.map +0 -7
- package/dist/lib/neutral/meta.json +0 -1
- package/dist/lib/neutral/meta.mjs +0 -12
- package/dist/lib/neutral/meta.mjs.map +0 -7
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs +0 -13
- package/dist/lib/neutral/operation-handler-ORDOJUL2.mjs.map +0 -7
- package/dist/lib/neutral/operations/index.mjs +0 -8
- package/dist/lib/neutral/operations/index.mjs.map +0 -7
- package/dist/lib/neutral/plugin.mjs +0 -16
- package/dist/lib/neutral/plugin.mjs.map +0 -7
- package/dist/lib/neutral/react-surface-QPMUEDZX.mjs +0 -48
- package/dist/lib/neutral/react-surface-QPMUEDZX.mjs.map +0 -7
- package/dist/lib/neutral/state-PDZU4PIP.mjs +0 -126
- package/dist/lib/neutral/state-PDZU4PIP.mjs.map +0 -7
- package/dist/lib/neutral/testing/index.mjs +0 -439
- package/dist/lib/neutral/testing/index.mjs.map +0 -7
- package/dist/lib/neutral/translations.mjs +0 -23
- package/dist/lib/neutral/translations.mjs.map +0 -7
- package/dist/lib/neutral/types/index.mjs +0 -10
- package/dist/lib/neutral/types/index.mjs.map +0 -7
- package/dist/types/src/NavTreePlugin.node.d.ts +0 -4
- package/dist/types/src/NavTreePlugin.node.d.ts.map +0 -1
- package/dist/types/src/NavTreePlugin.test.d.ts +0 -2
- package/dist/types/src/NavTreePlugin.test.d.ts.map +0 -1
- package/dist/types/src/NavTreePlugin.workerd.d.ts +0 -4
- package/dist/types/src/NavTreePlugin.workerd.d.ts.map +0 -1
- package/src/NavTreePlugin.node.ts +0 -17
- package/src/NavTreePlugin.test.ts +0 -27
- package/src/NavTreePlugin.workerd.ts +0 -16
- /package/src/components/NavTreeContext/{NavTreeContext.tsx → NavTreeContext.ts} +0 -0
package/PLUGIN.mdl
CHANGED
|
@@ -74,7 +74,7 @@ component NavTree
|
|
|
74
74
|
actions:
|
|
75
75
|
openChange(item: Node, path: string[], open: boolean)
|
|
76
76
|
tabChange(node: Node)
|
|
77
|
-
select(item: Node, path: string[], option: boolean)
|
|
77
|
+
select(item: Node, path: string[], option: boolean, shift: boolean)
|
|
78
78
|
back()
|
|
79
79
|
itemHover(item: Node)
|
|
80
80
|
layout: |
|
|
@@ -101,7 +101,7 @@ component NavTreeContainer
|
|
|
101
101
|
layout: LayoutState # active items, sidebar open/closed, mode
|
|
102
102
|
model: NavTreeModel
|
|
103
103
|
actions:
|
|
104
|
-
handleSelect(item: Node, path: string[], option: boolean)
|
|
104
|
+
handleSelect(item: Node, path: string[], option: boolean, shift: boolean)
|
|
105
105
|
handleOpenChange(item: Node, path: string[], open: boolean)
|
|
106
106
|
handleTabChange(node: Node)
|
|
107
107
|
handleBack()
|
|
@@ -197,7 +197,8 @@ feat F-3: Item Selection
|
|
|
197
197
|
|
|
198
198
|
req F-3.1:
|
|
199
199
|
when: user selects a non-current item
|
|
200
|
-
then: LayoutOperation.Open
|
|
200
|
+
then: LayoutOperation.Open is invoked with disposition 'solo' and the shift modifier forwarded
|
|
201
|
+
(the Open handler upgrades any disposition to 'add' when shift is held)
|
|
201
202
|
req F-3.2:
|
|
202
203
|
when: user option-clicks a currently active item
|
|
203
204
|
then: LayoutOperation.Close is invoked for that item
|
|
@@ -285,10 +286,11 @@ test T-3: Expose navigates to nested item
|
|
|
285
286
|
```
|
|
286
287
|
|
|
287
288
|
```mdl
|
|
288
|
-
test T-4: Select item
|
|
289
|
-
given:
|
|
289
|
+
test T-4: Select item
|
|
290
|
+
given: item not currently active
|
|
290
291
|
when: user selects a tree item
|
|
291
|
-
then: LayoutOperation.Open is invoked with the item id
|
|
292
|
+
then: LayoutOperation.Open is invoked with the item id, disposition 'solo' and the shift modifier
|
|
293
|
+
forwarded (shift-click therefore adds a plank instead of navigating)
|
|
292
294
|
```
|
|
293
295
|
|
|
294
296
|
```mdl
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ActivationEvent, ActivationEvents, Capabilities, Capability, Plugin } from "@dxos/app-framework";
|
|
2
|
+
import { meta } from "#meta";
|
|
3
|
+
import { AppActivationEvents, AppCapabilities, AppPlugin, LayoutOperation } from "@dxos/app-toolkit";
|
|
4
|
+
import { Graph } from "@dxos/plugin-graph";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import { AttentionEvents } from "@dxos/plugin-attention";
|
|
7
|
+
import { AppGraphBuilder, Keyboard, OperationHandler, ReactSurface, State } from "#capabilities";
|
|
8
|
+
import { translations } from "#translations";
|
|
9
|
+
import { NavTreeEvents } from "#types";
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/NavTreePlugin.tsx
|
|
12
|
+
var NavTreePlugin = Plugin.define(meta).pipe(AppPlugin.addAppGraphModule({ activate: AppGraphBuilder }), AppPlugin.addOperationHandlerModule({ activate: OperationHandler }), AppPlugin.addSurfaceModule({ activate: ReactSurface }), AppPlugin.addTranslationsModule({ translations }), Plugin.addModule({
|
|
13
|
+
id: "state",
|
|
14
|
+
activatesOn: ActivationEvent.allOf(AppActivationEvents.LayoutReady, AttentionEvents.AttentionReady),
|
|
15
|
+
firesAfterActivation: [NavTreeEvents.StateReady],
|
|
16
|
+
activate: State
|
|
17
|
+
}), Plugin.addModule({
|
|
18
|
+
id: "expose",
|
|
19
|
+
activatesOn: ActivationEvent.allOf(ActivationEvents.ProcessManagerReady, AppActivationEvents.AppGraphReady, AppActivationEvents.LayoutReady, NavTreeEvents.StateReady),
|
|
20
|
+
activate: Effect.fnUntraced(function* () {
|
|
21
|
+
const layout = yield* Capabilities.getAtomValue(AppCapabilities.Layout);
|
|
22
|
+
const { invokePromise } = yield* Capability.get(Capabilities.OperationInvoker);
|
|
23
|
+
const { graph } = yield* Capability.get(AppCapabilities.AppGraph);
|
|
24
|
+
if (invokePromise && layout.active.length === 1) Graph.waitForPath(graph, { target: layout.active[0] }, { timeout: 3e4 }).then(() => invokePromise(LayoutOperation.Expose, { subject: layout.active[0] })).catch(() => {});
|
|
25
|
+
return [];
|
|
26
|
+
})
|
|
27
|
+
}), Plugin.addModule({
|
|
28
|
+
id: "keyboard",
|
|
29
|
+
activatesOn: ActivationEvent.allOf(AppActivationEvents.AppGraphReady, ActivationEvents.ProcessManagerReady),
|
|
30
|
+
activate: Keyboard
|
|
31
|
+
}), AppPlugin.addPluginAssetModule({ asset: {
|
|
32
|
+
pluginId: meta.profile.key,
|
|
33
|
+
path: "PLUGIN.mdl",
|
|
34
|
+
content: "---\nid: org.dxos.plugin.navtree\nname: NavTreePlugin\nversion: 0.1.0\n---\n\nHierarchical navigation sidebar for `DXOS` Composer — renders the application graph as a collapsible tree, manages workspace tabs, exposes keyboard-driven command search, and handles drag-and-drop rearrangement of spaces, folders, and objects.\n\n## Extensions\n\nThe following extension dialects are used in this document.\nEach extension is defined in the Appendix or resolved via its URI.\n\n| Term | URI |\n|-------------|--------------------------------|\n| `type` | `org.dxos.mdl.type@1.0` |\n| `feat` | `org.dxos.mdl.feat@1.0` |\n| `test` | `org.dxos.mdl.test@1.0` |\n| `component` | `org.dxos.mdl.component@1.0` |\n| `op` | `org.dxos.mdl.op@1.0` |\n\n## Types\n\n```mdl\ntype NavTreeItemState\n fields:\n open: boolean # whether the tree node is expanded\n current: boolean # whether the node is in the active layout\n```\n\n```mdl\ntype KeyBinding\n fields:\n macos?: string\n windows?: string\n linux?: string\n ios?: string\n unknown?: string\n```\n\n```mdl\ntype NodeProperties\n fields:\n label: Label\n icon?: string\n iconHue?: string\n role?: string\n error?: string\n modified?: boolean\n palette?: string\n disabled?: boolean\n testId?: string\n position?: Position\n className?: string\n keyBinding?: string | KeyBinding\n persistenceClass?: string\n persistenceKey?: string\n```\n\n## Components\n\n```mdl\ncomponent NavTree\n desc: Root navigation tree that renders workspace tabs at the top level and a collapsible subtree for the active workspace.\n props:\n id: string # root node id (Node.RootId)\n root: Node # root of the application graph\n tab: string # currently active workspace tab id\n open: boolean # whether the navigation sidebar is open\n state:\n model: NavTreeModel # live tree model built from graph connections\n slots:\n itemEnd?: ReactNode # per-item trailing content (e.g. action badges)\n actions:\n openChange(item: Node, path: string[], open: boolean)\n tabChange(node: Node)\n select(item: Node, path: string[], option: boolean, shift: boolean)\n back()\n itemHover(item: Node)\n layout: |\n ┌─────────────────────────┐\n │ workspace tabs │\n │ [tab] [tab] [tab] │\n ├─────────────────────────┤\n │ collapsible tree │\n │ ▾ Space │\n │ ▾ Folder │\n │ • Object │\n │ • Object │\n │ • Object │\n └─────────────────────────┘\n```\n\n```mdl\ncomponent NavTreeContainer\n desc: Smart container that wires the NavTree to the app graph, layout state, and drag-and-drop monitor.\n props:\n tab: string\n popoverAnchorId?: string\n state:\n layout: LayoutState # active items, sidebar open/closed, mode\n model: NavTreeModel\n actions:\n handleSelect(item: Node, path: string[], option: boolean, shift: boolean)\n handleOpenChange(item: Node, path: string[], open: boolean)\n handleTabChange(node: Node)\n handleBack()\n handleDrop(source: TreeData, target: TreeData, instruction: Instruction)\n emits:\n onNavigate(subject: string | string[])\n layout: |\n ┌──────────────────────────┐\n │ NavTreeContext.Provider │\n │ └─ NavTree │\n └──────────────────────────┘\n```\n\n```mdl\ncomponent CommandsDialogContent\n desc: Full-screen command palette dialog — surfaces all graph actions, searchable by label.\n props:\n onClose?: () => void\n state:\n query: string\n results: Node[]\n actions:\n search(query: string) → Node[]\n execute(node: Node)\n layout: |\n ┌──────────────────────────┐\n │ [search input] │\n ├──────────────────────────┤\n │ result list │\n │ icon label shortcut │\n │ icon label │\n │ … │\n └──────────────────────────┘\n```\n\n```mdl\ncomponent CommandsTrigger\n desc: Search-input surface slot component — opens the commands dialog on click or ⌘K / Ctrl+K.\n slots:\n (none)\n actions:\n openCommandsDialog()\n```\n\n## Operations\n\n```mdl\nop expose\n desc: Expands tree nodes along the path to a subject and marks each as open so the item becomes visible in the NavTree.\n input:\n subject: string # attendable DXN or node id\n output: void\n effects: [echo:read]\n note: |\n Resolves the full ancestor path via expandAttendableId, calls Graph.expand per node,\n then sets each path segment open in NavTreeCapabilities.State.\n```\n\n## Features\n\n```mdl\nfeat F-1: Sidebar Navigation\n\n req F-1.1: NavTree renders all root-level graph connections as workspace tabs.\n req F-1.2:\n when: user selects a workspace tab\n then: LayoutOperation.SwitchWorkspace is invoked; subtree for that workspace is expanded\n req F-1.3:\n when: sidebar is closed and user selects a workspace tab\n then: sidebar opens (state transitions to expanded)\n req F-1.4:\n when: same active tab is clicked while sidebar is expanded\n then: sidebar collapses (state transitions to collapsed or closed on mobile)\n```\n\n```mdl\nfeat F-2: Tree Expand / Collapse\n\n req F-2.1: Tree items with children show an expand/collapse toggle.\n req F-2.2:\n when: user expands a node\n then: open state persisted to localStorage keyed by path; Graph.expand called for the node\n req F-2.3:\n when: plugin initialises after layout is ready\n then: all paths previously marked open are re-expanded from localStorage\n req F-2.4:\n when: op:expose is called\n then: all ancestors of the subject are expanded and marked open\n```\n\n```mdl\nfeat F-3: Item Selection\n\n req F-3.1:\n when: user selects a non-current item\n then: LayoutOperation.Open is invoked with disposition 'solo' and the shift modifier forwarded\n (the Open handler upgrades any disposition to 'add' when shift is held)\n req F-3.2:\n when: user option-clicks a currently active item\n then: LayoutOperation.Close is invoked for that item\n req F-3.3:\n when: user clicks a currently active item without option key\n then: LayoutOperation.ScrollIntoView is invoked\n req F-3.4:\n when: item has a default disposition action\n then: that action is run after navigation\n req F-3.5:\n when: navigation succeeds on mobile\n then: sidebar is closed automatically\n```\n\n```mdl\nfeat F-4: Drag and Drop\n\n req F-4.1: NavTree items can be dragged to rearrange within the same parent.\n req F-4.2: NavTree items can be dragged to copy or transfer to a different parent.\n req F-4.3:\n when: drop instruction is rearrange\n then: onRearrange callback on the parent node is called with the new order\n req F-4.4:\n when: drop instruction is copy\n then: onCopy callback on the target node is called\n req F-4.5:\n when: drop instruction is transfer\n then: onTransferStart and onTransferEnd callbacks are called on source and target parents\n req F-4.6:\n when: target node reports blockInstruction for an instruction type\n then: that instruction is blocked and the drop is not applied\n```\n\n```mdl\nfeat F-5: Keyboard Shortcuts\n\n req F-5.1: NavTree plugin registers keyboard shortcuts for all graph actions that declare a keyBinding property.\n req F-5.2: Graph is traversed on change (debounced 500 ms) to bind newly added shortcuts.\n req F-5.3: The commands dialog is opened via ⌘K (macOS) / Ctrl+K (Windows/Linux).\n req F-5.4:\n when: plugin deactivates\n then: Keyboard.singleton is destroyed and all shortcuts are unregistered\n```\n\n```mdl\nfeat F-6: State Persistence\n\n req F-6.1: Per-path open/current state is stored in an atom family keyed by path string.\n req F-6.2: Open state (not current) is persisted to localStorage on every change.\n req F-6.3: Current state reflects active layout items and is never persisted.\n req F-6.4:\n when: layout.active changes\n then: removed items are marked not-current; newly active items are marked current\n```\n\n## Acceptance\n\n```mdl\ntest T-1: Workspace tab switch\n given: two workspace tabs exist in the graph\n when: user clicks the second workspace tab\n then:\n - LayoutOperation.SwitchWorkspace is invoked with the tab's node id\n - sidebar transitions to expanded\n - subtree for the selected workspace is expanded\n```\n\n```mdl\ntest T-2: Tree node expand persists\n given: NavTree is rendered with a collapsed folder node\n when: user expands the folder\n then:\n - folder node state.open === true\n - localStorage entry updated for the folder's path\n - Graph.expand called for the folder node id\n```\n\n```mdl\ntest T-3: Expose navigates to nested item\n given: a deeply nested object id is active in the layout\n when: op:expose is called with that object id\n then:\n - all ancestor paths are marked open\n - Graph.expand is called for each ancestor\n```\n\n```mdl\ntest T-4: Select item\n given: item not currently active\n when: user selects a tree item\n then: LayoutOperation.Open is invoked with the item id, disposition 'solo' and the shift modifier\n forwarded (shift-click therefore adds a plank instead of navigating)\n```\n\n```mdl\ntest T-5: Command palette opens on keyboard shortcut\n given: NavTree is active\n when: user presses ⌘K (macOS) or Ctrl+K (Windows)\n then:\n - CommandsDialogContent is shown in the layout dialog slot\n - search input is focused\n```\n\n```mdl\ntest T-6: Drag-and-drop rearrange\n given: two sibling items in the same folder\n when: user drags the first item below the second\n then:\n - onRearrange callback is called with the reordered array\n - tree re-renders with the new order\n```\n\n---\n\n## Appendix: Extension Definitions\n\n```mdl\next type\n uri: org.dxos.mdl.type@1.0\n desc: A named data structure with typed fields and optional literals.\n fields:\n desc?: Prose\n fields?: FieldMap\n literals?: UnionList\n extends?: TypeRef[]\n```\n\n```mdl\next feat\n uri: org.dxos.mdl.feat@1.0\n desc: A named feature grouping one or more requirements.\n fields:\n desc?: Prose\n req: RequirementList\n nesting: self\n```\n\n```mdl\next test\n uri: org.dxos.mdl.test@1.0\n desc: An acceptance scenario expressed as given / when / then steps.\n fields:\n given?: Step | Step[]\n when?: Step | Step[]\n then: Step | Step[]\n tags?: TagList\n```\n\n```mdl\next component\n uri: org.dxos.mdl.component@1.0\n desc: A UI component with props, internal state, slots, actions, and events.\n fields:\n desc?: Prose\n props?: FieldMap\n state?: FieldMap\n slots?: FieldMap\n actions?: ActionMap\n emits?: EventMap\n layout?: CodeBlock\n```\n\n```mdl\next op\n uri: org.dxos.mdl.op@1.0\n desc: |\n A named operation with typed inputs, outputs, and declared errors.\n Pure ops have no effects or requires. Effectful ops declare both.\n fields:\n desc?: Prose\n input?: FieldMap\n output?: TypeExpr\n errors?: ErrorMap\n effects?: EffectList\n requires?: ServiceList\n note?: Prose\n```\n",
|
|
35
|
+
mimeType: "application/x-mdl"
|
|
36
|
+
} }), Plugin.make);
|
|
37
|
+
//#endregion
|
|
38
|
+
export { NavTreePlugin, NavTreePlugin as default };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=NavTreePlugin.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavTreePlugin.mjs","names":[],"sources":["../../src/NavTreePlugin.tsx"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { ActivationEvent, ActivationEvents, Capabilities, Capability, Plugin } from '@dxos/app-framework';\nimport { AppActivationEvents, AppCapabilities, AppPlugin, LayoutOperation } from '@dxos/app-toolkit';\nimport { AttentionEvents } from '@dxos/plugin-attention';\nimport { Graph } from '@dxos/plugin-graph';\n\nimport { AppGraphBuilder, Keyboard, OperationHandler, ReactSurface, State } from '#capabilities';\nimport { meta } from '#meta';\nimport { translations } from '#translations';\nimport { NavTreeEvents } from '#types';\n\n// eslint-disable-next-line import/no-relative-packages\nimport pluginSpec from '../PLUGIN.mdl?raw';\n\nexport const NavTreePlugin = Plugin.define(meta).pipe(\n AppPlugin.addAppGraphModule({ activate: AppGraphBuilder }),\n AppPlugin.addOperationHandlerModule({ activate: OperationHandler }),\n AppPlugin.addSurfaceModule({ activate: ReactSurface }),\n AppPlugin.addTranslationsModule({ translations }),\n Plugin.addModule({\n id: 'state',\n // Wait for AttentionReady too so the ViewState Manager (the expansion persistence backend) is available.\n activatesOn: ActivationEvent.allOf(AppActivationEvents.LayoutReady, AttentionEvents.AttentionReady),\n firesAfterActivation: [NavTreeEvents.StateReady],\n activate: State,\n }),\n Plugin.addModule({\n id: 'expose',\n activatesOn: ActivationEvent.allOf(\n ActivationEvents.ProcessManagerReady,\n AppActivationEvents.AppGraphReady,\n AppActivationEvents.LayoutReady,\n NavTreeEvents.StateReady,\n ),\n activate: Effect.fnUntraced(function* () {\n const layout = yield* Capabilities.getAtomValue(AppCapabilities.Layout);\n const { invokePromise } = yield* Capability.get(Capabilities.OperationInvoker);\n const { graph } = yield* Capability.get(AppCapabilities.AppGraph);\n if (invokePromise && layout.active.length === 1) {\n // TODO(wittjosiah): This should really be fired once the navtree renders for the first time.\n // That is the point at which the graph is expanded and the path should be available.\n void Graph.waitForPath(graph, { target: layout.active[0] }, { timeout: 30_000 })\n .then(() => invokePromise(LayoutOperation.Expose, { subject: layout.active[0] }))\n .catch(() => {});\n }\n\n return [];\n }),\n }),\n Plugin.addModule({\n id: 'keyboard',\n activatesOn: ActivationEvent.allOf(AppActivationEvents.AppGraphReady, ActivationEvents.ProcessManagerReady),\n activate: Keyboard,\n }),\n AppPlugin.addPluginAssetModule({\n asset: { pluginId: meta.profile.key, path: 'PLUGIN.mdl', content: pluginSpec, mimeType: 'application/x-mdl' },\n }),\n Plugin.make,\n);\n\nexport default NavTreePlugin;\n"],"mappings":";;;;;;;;;;;AAmBA,IAAa,gBAAgB,OAAO,OAAO,IAAI,CAAC,CAAC,KAC/C,UAAU,kBAAkB,EAAE,UAAU,gBAAgB,CAAC,GACzD,UAAU,0BAA0B,EAAE,UAAU,iBAAiB,CAAC,GAClE,UAAU,iBAAiB,EAAE,UAAU,aAAa,CAAC,GACrD,UAAU,sBAAsB,EAAE,aAAa,CAAC,GAChD,OAAO,UAAU;CACf,IAAI;CAEJ,aAAa,gBAAgB,MAAM,oBAAoB,aAAa,gBAAgB,cAAc;CAClG,sBAAsB,CAAC,cAAc,UAAU;CAC/C,UAAU;AACZ,CAAC,GACD,OAAO,UAAU;CACf,IAAI;CACJ,aAAa,gBAAgB,MAC3B,iBAAiB,qBACjB,oBAAoB,eACpB,oBAAoB,aACpB,cAAc,UAChB;CACA,UAAU,OAAO,WAAW,aAAa;EACvC,MAAM,SAAS,OAAO,aAAa,aAAa,gBAAgB,MAAM;EACtE,MAAM,EAAE,kBAAkB,OAAO,WAAW,IAAI,aAAa,gBAAgB;EAC7E,MAAM,EAAE,UAAU,OAAO,WAAW,IAAI,gBAAgB,QAAQ;EAChE,IAAI,iBAAiB,OAAO,OAAO,WAAW,GAG5C,MAAW,YAAY,OAAO,EAAE,QAAQ,OAAO,OAAO,GAAG,GAAG,EAAE,SAAS,IAAO,CAAC,CAAA,CAC5E,WAAW,cAAc,gBAAgB,QAAQ,EAAE,SAAS,OAAO,OAAO,GAAG,CAAC,CAAC,CAAA,CAC/E,YAAY,CAAC,CAAC;EAGnB,OAAO,CAAC;CACV,CAAC;AACH,CAAC,GACD,OAAO,UAAU;CACf,IAAI;CACJ,aAAa,gBAAgB,MAAM,oBAAoB,eAAe,iBAAiB,mBAAmB;CAC1G,UAAU;AACZ,CAAC,GACD,UAAU,qBAAqB,EAC7B,OAAO;CAAE,UAAU,KAAK,QAAQ;CAAK,MAAM;CAAc,SAAS;CAAY,UAAU;AAAoB,EAC9G,CAAC,GACD,OAAO,IACT"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Capability } from "@dxos/app-framework";
|
|
2
|
+
//#region src/capabilities/index.ts
|
|
3
|
+
var AppGraphBuilder = Capability.lazy("AppGraphBuilder", () => import("./chunk-app-graph-builder.mjs"));
|
|
4
|
+
var Keyboard = Capability.lazy("Keyboard", () => import("./chunk-keyboard.mjs"));
|
|
5
|
+
var OperationHandler = Capability.lazy("OperationHandler", () => import("./chunk-operation-handler.mjs"));
|
|
6
|
+
var ReactSurface = Capability.lazy("ReactSurface", () => import("./chunk-react-surface.mjs"));
|
|
7
|
+
var State = Capability.lazy("State", () => import("./chunk-state.mjs"));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { AppGraphBuilder, Keyboard, OperationHandler, ReactSurface, State };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=capabilities.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capabilities.mjs","names":[],"sources":["../../src/capabilities/index.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Capability } from '@dxos/app-framework';\nimport { OperationHandlerSet } from '@dxos/compute';\n\nexport const AppGraphBuilder = Capability.lazy('AppGraphBuilder', () => import('./app-graph-builder'));\nexport const Keyboard = Capability.lazy('Keyboard', () => import('./keyboard'));\nexport const OperationHandler = Capability.lazy<OperationHandlerSet.OperationHandlerSet>(\n 'OperationHandler',\n () => import('./operation-handler'),\n);\nexport const ReactSurface = Capability.lazy('ReactSurface', () => import('./react-surface'));\nexport const State = Capability.lazy('State', () => import('./state'));\n"],"mappings":";;AAOA,IAAa,kBAAkB,WAAW,KAAK,yBAAyB,OAAO,gCAAsB;AACrG,IAAa,WAAW,WAAW,KAAK,kBAAkB,OAAO,uBAAa;AAC9E,IAAa,mBAAmB,WAAW,KACzC,0BACM,OAAO,gCACf;AACA,IAAa,eAAe,WAAW,KAAK,sBAAsB,OAAO,4BAAkB;AAC3F,IAAa,QAAQ,WAAW,KAAK,eAAe,OAAO,oBAAU"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { getHostPlatform } from "@dxos/util";
|
|
2
|
+
import { KEY_BINDING, meta } from "#meta";
|
|
3
|
+
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
4
|
+
import { Graph, Node } from "@dxos/plugin-graph";
|
|
5
|
+
import { forwardRef, useMemo, useState } from "react";
|
|
6
|
+
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
7
|
+
import { useActionRunner, useActions } from "@dxos/plugin-graph/hooks";
|
|
8
|
+
import { Button, Dialog, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
9
|
+
import { osTranslations } from "@dxos/ui-theme";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
12
|
+
import { Keyboard, keySymbols } from "@dxos/keyboard";
|
|
13
|
+
import { SearchList, useSearchListResults } from "@dxos/react-ui-search";
|
|
14
|
+
//#region src/containers/CommandsDialogContent/CommandsDialogContent.tsx
|
|
15
|
+
var CommandsDialogContent = forwardRef(({ selected: initial }, forwardedRef) => {
|
|
16
|
+
const { t } = useTranslation(meta.profile.key);
|
|
17
|
+
const { invokePromise } = useOperationInvoker();
|
|
18
|
+
const runAction = useActionRunner();
|
|
19
|
+
const { graph } = useAppGraph();
|
|
20
|
+
const [selected, setSelected] = useState(initial);
|
|
21
|
+
const allActions = useMemo(() => {
|
|
22
|
+
const current = Keyboard.singleton.getCurrentContext();
|
|
23
|
+
const actionMap = /* @__PURE__ */ new Set();
|
|
24
|
+
const actions = [];
|
|
25
|
+
Graph.traverse(graph, {
|
|
26
|
+
relation: ["child", "action"],
|
|
27
|
+
visitor: (node, path) => {
|
|
28
|
+
const isActionLike = Node.isAction(node) || Node.isActionGroup(node);
|
|
29
|
+
const parentId = path.at(-2) ?? "";
|
|
30
|
+
const matches = current === parentId || current.startsWith(parentId + "/");
|
|
31
|
+
if (isActionLike && !actionMap.has(node.id) && matches) {
|
|
32
|
+
actionMap.add(node.id);
|
|
33
|
+
actions.push(node);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
actions.sort((a, b) => {
|
|
38
|
+
return toLocalizedString(a.properties.label, t)?.toLowerCase().localeCompare(toLocalizedString(b.properties.label, t)?.toLowerCase());
|
|
39
|
+
});
|
|
40
|
+
return actions;
|
|
41
|
+
}, [graph]);
|
|
42
|
+
const group = allActions.find(({ id }) => id === selected);
|
|
43
|
+
const groupActions = useActions(graph, group?.id);
|
|
44
|
+
const { results, handleSearch } = useSearchListResults({
|
|
45
|
+
items: Node.isActionGroup(group) ? groupActions : allActions,
|
|
46
|
+
extract: (action) => toLocalizedString(action.properties.label, t)
|
|
47
|
+
});
|
|
48
|
+
return /* @__PURE__ */ jsxs(Dialog.Content, {
|
|
49
|
+
ref: forwardedRef,
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ jsx(Dialog.Title, {
|
|
52
|
+
srOnly: true,
|
|
53
|
+
children: t("commands-dialog.title", { ns: meta.profile.key })
|
|
54
|
+
}),
|
|
55
|
+
/* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(SearchList.Root, {
|
|
56
|
+
onSearch: handleSearch,
|
|
57
|
+
children: [/* @__PURE__ */ jsx(SearchList.Input, { placeholder: t("command-list-input.placeholder") }), /* @__PURE__ */ jsx(SearchList.Viewport, { children: results.map((action) => {
|
|
58
|
+
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
59
|
+
return /* @__PURE__ */ jsx(SearchList.Item, {
|
|
60
|
+
value: action.id,
|
|
61
|
+
label: toLocalizedString(action.properties.label, t),
|
|
62
|
+
icon: action.properties.icon,
|
|
63
|
+
suffix: shortcut ? keySymbols(shortcut).join("") : void 0,
|
|
64
|
+
onSelect: () => {
|
|
65
|
+
if (action.properties.disabled) return;
|
|
66
|
+
if (Node.isActionGroup(action)) {
|
|
67
|
+
setSelected(action.id);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
invokePromise(LayoutOperation.UpdateDialog, { state: false });
|
|
71
|
+
setTimeout(() => {
|
|
72
|
+
const lookupId = group?.id ?? action.id;
|
|
73
|
+
const node = Graph.getConnections(graph, lookupId, Node.actionRelation("inbound"))[0];
|
|
74
|
+
if (node && Node.isAction(action)) runAction(action, {
|
|
75
|
+
parent: node,
|
|
76
|
+
caller: KEY_BINDING
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
classNames: "flex items-center gap-2",
|
|
81
|
+
disabled: action.properties.disabled,
|
|
82
|
+
...action.properties?.testId && { "data-testid": action.properties.testId }
|
|
83
|
+
}, action.id);
|
|
84
|
+
}) })]
|
|
85
|
+
}) }),
|
|
86
|
+
/* @__PURE__ */ jsx(Dialog.ActionBar, { children: /* @__PURE__ */ jsx(Dialog.Close, {
|
|
87
|
+
asChild: true,
|
|
88
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
89
|
+
classNames: "w-full",
|
|
90
|
+
children: t("close.label", { ns: osTranslations })
|
|
91
|
+
})
|
|
92
|
+
}) })
|
|
93
|
+
]
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
CommandsDialogContent.displayName = "CommandsDialogContent";
|
|
97
|
+
//#endregion
|
|
98
|
+
export { CommandsDialogContent as default };
|
|
99
|
+
|
|
100
|
+
//# sourceMappingURL=chunk-CommandsDialogContent.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-CommandsDialogContent.mjs","names":[],"sources":["../../src/containers/CommandsDialogContent/CommandsDialogContent.tsx"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { forwardRef, useMemo, useState } from 'react';\n\nimport { useOperationInvoker } from '@dxos/app-framework/ui';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { useAppGraph } from '@dxos/app-toolkit/ui';\nimport { Keyboard, keySymbols } from '@dxos/keyboard';\nimport { Graph, Node } from '@dxos/plugin-graph';\nimport { useActions } from '@dxos/plugin-graph/hooks';\nimport { useActionRunner } from '@dxos/plugin-graph/hooks';\nimport { Button, Dialog, toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { SearchList, useSearchListResults } from '@dxos/react-ui-search';\nimport { osTranslations } from '@dxos/ui-theme';\nimport { getHostPlatform } from '@dxos/util';\n\nimport { KEY_BINDING, meta } from '#meta';\n\nexport type CommandsDialogContentProps = {\n selected?: string;\n};\n\n// TODO(wittjosiah): This probably deserves its own plugin but for now it lives here w/ other navigation UI.\nexport const CommandsDialogContent = forwardRef<HTMLDivElement, CommandsDialogContentProps>(\n ({ selected: initial }, forwardedRef) => {\n const { t } = useTranslation(meta.profile.key);\n const { invokePromise } = useOperationInvoker();\n const runAction = useActionRunner();\n const { graph } = useAppGraph();\n const [selected, setSelected] = useState<string | undefined>(initial);\n\n // Traverse graph.\n // TODO(burdon): Factor out commonality with shortcut dialog.\n const allActions = useMemo(() => {\n // TODO(burdon): Get from navtree (not keyboard).\n const current = Keyboard.singleton.getCurrentContext();\n const actionMap = new Set<string>();\n const actions: Node.ActionLike[] = [];\n Graph.traverse(graph, {\n relation: ['child', 'action'],\n visitor: (node, path) => {\n const isActionLike = Node.isAction(node) || Node.isActionGroup(node);\n const parentId = path.at(-2) ?? '';\n const matches = current === parentId || current.startsWith(parentId + '/');\n if (isActionLike && !actionMap.has(node.id) && matches) {\n actionMap.add(node.id);\n actions.push(node);\n }\n },\n });\n\n actions.sort((a, b) => {\n return toLocalizedString(a.properties.label, t)\n ?.toLowerCase()\n .localeCompare(toLocalizedString(b.properties.label, t)?.toLowerCase());\n });\n\n return actions;\n }, [graph]);\n\n const group = allActions.find(({ id }) => id === selected);\n const groupActions = useActions(graph, group?.id);\n const actions = Node.isActionGroup(group) ? groupActions : allActions;\n\n const { results, handleSearch } = useSearchListResults({\n items: actions,\n extract: (action) => toLocalizedString(action.properties.label, t),\n });\n\n return (\n <Dialog.Content ref={forwardedRef}>\n <Dialog.Title srOnly>{t('commands-dialog.title', { ns: meta.profile.key })}</Dialog.Title>\n <Dialog.Body>\n <SearchList.Root onSearch={handleSearch}>\n <SearchList.Input placeholder={t('command-list-input.placeholder')} />\n <SearchList.Viewport>\n {results.map((action) => {\n const shortcut =\n typeof action.properties.keyBinding === 'string'\n ? action.properties.keyBinding\n : action.properties.keyBinding?.[getHostPlatform()];\n\n return (\n <SearchList.Item\n value={action.id}\n key={action.id}\n label={toLocalizedString(action.properties.label, t)}\n icon={action.properties.icon}\n suffix={shortcut ? keySymbols(shortcut).join('') : undefined}\n onSelect={() => {\n if (action.properties.disabled) {\n return;\n }\n\n if (Node.isActionGroup(action)) {\n setSelected(action.id);\n return;\n }\n\n void invokePromise(LayoutOperation.UpdateDialog, { state: false });\n setTimeout(() => {\n const lookupId = group?.id ?? action.id;\n const node = Graph.getConnections(graph, lookupId, Node.actionRelation('inbound'))[0];\n if (node && Node.isAction(action)) {\n void runAction(action, { parent: node, caller: KEY_BINDING });\n }\n });\n }}\n classNames='flex items-center gap-2'\n disabled={action.properties.disabled}\n {...(action.properties?.testId && {\n 'data-testid': action.properties.testId,\n })}\n />\n );\n })}\n </SearchList.Viewport>\n </SearchList.Root>\n </Dialog.Body>\n <Dialog.ActionBar>\n <Dialog.Close asChild>\n <Button classNames='w-full'>{t('close.label', { ns: osTranslations })}</Button>\n </Dialog.Close>\n </Dialog.ActionBar>\n </Dialog.Content>\n );\n },\n);\n\nCommandsDialogContent.displayName = 'CommandsDialogContent';\n"],"mappings":";;;;;;;;;;;;;;AAyBA,IAAa,wBAAwB,YAClC,EAAE,UAAU,WAAW,iBAAiB;CACvC,MAAM,EAAE,MAAM,eAAe,KAAK,QAAQ,GAAG;CAC7C,MAAM,EAAE,kBAAkB,oBAAoB;CAC9C,MAAM,YAAY,gBAAgB;CAClC,MAAM,EAAE,UAAU,YAAY;CAC9B,MAAM,CAAC,UAAU,eAAe,SAA6B,OAAO;CAIpE,MAAM,aAAa,cAAc;EAE/B,MAAM,UAAU,SAAS,UAAU,kBAAkB;EACrD,MAAM,4BAAY,IAAI,IAAY;EAClC,MAAM,UAA6B,CAAC;EACpC,MAAM,SAAS,OAAO;GACpB,UAAU,CAAC,SAAS,QAAQ;GAC5B,UAAU,MAAM,SAAS;IACvB,MAAM,eAAe,KAAK,SAAS,IAAI,KAAK,KAAK,cAAc,IAAI;IACnE,MAAM,WAAW,KAAK,GAAG,EAAE,KAAK;IAChC,MAAM,UAAU,YAAY,YAAY,QAAQ,WAAW,WAAW,GAAG;IACzE,IAAI,gBAAgB,CAAC,UAAU,IAAI,KAAK,EAAE,KAAK,SAAS;KACtD,UAAU,IAAI,KAAK,EAAE;KACrB,QAAQ,KAAK,IAAI;IACnB;GACF;EACF,CAAC;EAED,QAAQ,MAAM,GAAG,MAAM;GACrB,OAAO,kBAAkB,EAAE,WAAW,OAAO,CAAC,CAAA,EAC1C,YAAY,CAAA,CACb,cAAc,kBAAkB,EAAE,WAAW,OAAO,CAAC,CAAC,EAAE,YAAY,CAAC;EAC1E,CAAC;EAED,OAAO;CACT,GAAG,CAAC,KAAK,CAAC;CAEV,MAAM,QAAQ,WAAW,MAAM,EAAE,SAAS,OAAO,QAAQ;CACzD,MAAM,eAAe,WAAW,OAAO,OAAO,EAAE;CAGhD,MAAM,EAAE,SAAS,iBAAiB,qBAAqB;EACrD,OAHc,KAAK,cAAc,KAAK,IAAI,eAAe;EAIzD,UAAU,WAAW,kBAAkB,OAAO,WAAW,OAAO,CAAC;CACnE,CAAC;CAED,OACE,qBAAC,OAAO,SAAR;EAAgB,KAAK;YAArB;GACE,oBAAC,OAAO,OAAR;IAAc,QAAA;cAAQ,EAAE,yBAAyB,EAAE,IAAI,KAAK,QAAQ,IAAI,CAAC;GAAgB,CAAA;GACzF,oBAAC,OAAO,MAAR,EAAA,UACE,qBAAC,WAAW,MAAZ;IAAiB,UAAU;cAA3B,CACE,oBAAC,WAAW,OAAZ,EAAkB,aAAa,EAAE,gCAAgC,EAAI,CAAA,GACrE,oBAAC,WAAW,UAAZ,EAAA,UACG,QAAQ,KAAK,WAAW;KACvB,MAAM,WACJ,OAAO,OAAO,WAAW,eAAe,WACpC,OAAO,WAAW,aAClB,OAAO,WAAW,aAAa,gBAAgB;KAErD,OACE,oBAAC,WAAW,MAAZ;MACE,OAAO,OAAO;MAEd,OAAO,kBAAkB,OAAO,WAAW,OAAO,CAAC;MACnD,MAAM,OAAO,WAAW;MACxB,QAAQ,WAAW,WAAW,QAAQ,CAAC,CAAC,KAAK,EAAE,IAAI,KAAA;MACnD,gBAAgB;OACd,IAAI,OAAO,WAAW,UACpB;OAGF,IAAI,KAAK,cAAc,MAAM,GAAG;QAC9B,YAAY,OAAO,EAAE;QACrB;OACF;OAEA,cAAmB,gBAAgB,cAAc,EAAE,OAAO,MAAM,CAAC;OACjE,iBAAiB;QACf,MAAM,WAAW,OAAO,MAAM,OAAO;QACrC,MAAM,OAAO,MAAM,eAAe,OAAO,UAAU,KAAK,eAAe,SAAS,CAAC,CAAC,CAAC;QACnF,IAAI,QAAQ,KAAK,SAAS,MAAM,GAC9B,UAAe,QAAQ;SAAE,QAAQ;SAAM,QAAQ;QAAY,CAAC;OAEhE,CAAC;MACH;MACA,YAAW;MACX,UAAU,OAAO,WAAW;MAC5B,GAAK,OAAO,YAAY,UAAU,EAChC,eAAe,OAAO,WAAW,OACnC;KACD,GA5BM,OAAO,EA4Bb;IAEL,CAAC,EACkB,CAAA,CACN;MACN,CAAA;GACb,oBAAC,OAAO,WAAR,EAAA,UACE,oBAAC,OAAO,OAAR;IAAc,SAAA;cACZ,oBAAC,QAAD;KAAQ,YAAW;eAAU,EAAE,eAAe,EAAE,IAAI,eAAe,CAAC;IAAU,CAAA;GAClE,CAAA,EACE,CAAA;EACJ;;AAEpB,CACF;AAEA,sBAAsB,cAAc"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { COMMANDS_DIALOG, meta } from "#meta";
|
|
2
|
+
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
3
|
+
import "react";
|
|
4
|
+
import { Button, Icon, useTranslation } from "@dxos/react-ui";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
7
|
+
//#region src/containers/CommandsTrigger/CommandsTrigger.tsx
|
|
8
|
+
var CommandsTrigger = () => {
|
|
9
|
+
const { invokePromise } = useOperationInvoker();
|
|
10
|
+
const { t } = useTranslation(meta.profile.key);
|
|
11
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
12
|
+
classNames: "m-1 px-1 lg:px-2",
|
|
13
|
+
onClick: () => void invokePromise(LayoutOperation.UpdateDialog, {
|
|
14
|
+
subject: COMMANDS_DIALOG,
|
|
15
|
+
blockAlign: "start"
|
|
16
|
+
}),
|
|
17
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
18
|
+
className: "text-description font-normal grow text-start",
|
|
19
|
+
children: t("command-list-input.placeholder")
|
|
20
|
+
}), /* @__PURE__ */ jsx(Icon, { icon: "ph--magnifying-glass--regular" })]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
CommandsTrigger.displayName = "CommandsTrigger";
|
|
24
|
+
//#endregion
|
|
25
|
+
export { CommandsTrigger as default };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=chunk-CommandsTrigger.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-CommandsTrigger.mjs","names":[],"sources":["../../src/containers/CommandsTrigger/CommandsTrigger.tsx"],"sourcesContent":["//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { useOperationInvoker } from '@dxos/app-framework/ui';\nimport { LayoutOperation } from '@dxos/app-toolkit';\nimport { Button, Icon, useTranslation } from '@dxos/react-ui';\n\nimport { COMMANDS_DIALOG, meta } from '#meta';\n\n// TODO(thure): Refactor to be handled by a more appropriate plugin.\nexport const CommandsTrigger = () => {\n const { invokePromise } = useOperationInvoker();\n const { t } = useTranslation(meta.profile.key);\n return (\n <Button\n classNames='m-1 px-1 lg:px-2'\n onClick={() =>\n void invokePromise(LayoutOperation.UpdateDialog, { subject: COMMANDS_DIALOG, blockAlign: 'start' })\n }\n >\n <span className='text-description font-normal grow text-start'>{t('command-list-input.placeholder')}</span>\n <Icon icon='ph--magnifying-glass--regular' />\n </Button>\n );\n};\n\nCommandsTrigger.displayName = 'CommandsTrigger';\n"],"mappings":";;;;;;;AAaA,IAAa,wBAAwB;CACnC,MAAM,EAAE,kBAAkB,oBAAoB;CAC9C,MAAM,EAAE,MAAM,eAAe,KAAK,QAAQ,GAAG;CAC7C,OACE,qBAAC,QAAD;EACE,YAAW;EACX,eACE,KAAK,cAAc,gBAAgB,cAAc;GAAE,SAAS;GAAiB,YAAY;EAAQ,CAAC;YAHtG,CAME,oBAAC,QAAD;GAAM,WAAU;aAAgD,EAAE,gCAAgC;EAAQ,CAAA,GAC1G,oBAAC,MAAD,EAAM,MAAK,gCAAiC,CAAA,CACtC;;AAEZ;AAEA,gBAAgB,cAAc"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { meta } from "#meta";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
4
|
+
import { osTranslations } from "@dxos/ui-theme";
|
|
5
|
+
//#region src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.tsx
|
|
6
|
+
var NavTreeDocumentTitle = ({ node }) => {
|
|
7
|
+
const { t } = useTranslation(meta.profile.key);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
document.title = node ? toLocalizedString(node.properties.label, t) : t("current-app.name", { ns: osTranslations });
|
|
10
|
+
}, [node?.properties?.label]);
|
|
11
|
+
return null;
|
|
12
|
+
};
|
|
13
|
+
NavTreeDocumentTitle.displayName = "NavTreeDocumentTitle";
|
|
14
|
+
//#endregion
|
|
15
|
+
export { NavTreeDocumentTitle as default };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=chunk-NavTreeDocumentTitle.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-NavTreeDocumentTitle.mjs","names":[],"sources":["../../src/containers/NavTreeDocumentTitle/NavTreeDocumentTitle.tsx"],"sourcesContent":["//\n// Copyright 2023 DXOS.org\n//\nimport { useEffect } from 'react';\n\nimport { type Node } from '@dxos/app-graph';\nimport { toLocalizedString, useTranslation } from '@dxos/react-ui';\nimport { osTranslations } from '@dxos/ui-theme';\n\nimport { meta } from '#meta';\n\nexport const NavTreeDocumentTitle = ({ node }: { node?: Node.Node }) => {\n const { t } = useTranslation(meta.profile.key);\n useEffect(() => {\n document.title = node ? toLocalizedString(node.properties.label, t) : t('current-app.name', { ns: osTranslations });\n }, [node?.properties?.label]);\n return null;\n};\n\nNavTreeDocumentTitle.displayName = 'NavTreeDocumentTitle';\n"],"mappings":";;;;;AAWA,IAAa,wBAAwB,EAAE,WAAiC;CACtE,MAAM,EAAE,MAAM,eAAe,KAAK,QAAQ,GAAG;CAC7C,gBAAgB;EACd,SAAS,QAAQ,OAAO,kBAAkB,KAAK,WAAW,OAAO,CAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,eAAe,CAAC;CACpH,GAAG,CAAC,MAAM,YAAY,KAAK,CAAC;CAC5B,OAAO;AACT;AAEA,qBAAqB,cAAc"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Capability } from "@dxos/app-framework";
|
|
2
|
+
import { COMMANDS_DIALOG, meta } from "#meta";
|
|
3
|
+
import { AppCapabilities, LayoutOperation } from "@dxos/app-toolkit";
|
|
4
|
+
import { GraphBuilder, Node, NodeMatcher } from "@dxos/plugin-graph";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import { Operation } from "@dxos/compute";
|
|
7
|
+
//#region src/capabilities/app-graph-builder.ts
|
|
8
|
+
var app_graph_builder_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
9
|
+
const extensions = yield* GraphBuilder.createExtension({
|
|
10
|
+
id: "root",
|
|
11
|
+
match: NodeMatcher.whenRoot,
|
|
12
|
+
actions: () => Effect.succeed([Node.makeAction({
|
|
13
|
+
id: COMMANDS_DIALOG,
|
|
14
|
+
data: () => Operation.invoke(LayoutOperation.UpdateDialog, {
|
|
15
|
+
subject: COMMANDS_DIALOG,
|
|
16
|
+
blockAlign: "start"
|
|
17
|
+
}),
|
|
18
|
+
properties: {
|
|
19
|
+
label: ["open-commands.label", { ns: meta.profile.key }],
|
|
20
|
+
icon: "ph--magnifying-glass--regular",
|
|
21
|
+
keyBinding: {
|
|
22
|
+
macos: "meta+k",
|
|
23
|
+
windows: "ctrl+k"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})])
|
|
27
|
+
});
|
|
28
|
+
return Capability.contributes(AppCapabilities.AppGraphBuilder, extensions);
|
|
29
|
+
}));
|
|
30
|
+
//#endregion
|
|
31
|
+
export { app_graph_builder_default as default };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=chunk-app-graph-builder.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-app-graph-builder.mjs","names":[],"sources":["../../src/capabilities/app-graph-builder.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capability } from '@dxos/app-framework';\nimport { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';\nimport { Operation } from '@dxos/compute';\nimport { GraphBuilder, Node, NodeMatcher } from '@dxos/plugin-graph';\n\nimport { COMMANDS_DIALOG, meta } from '#meta';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const extensions = yield* GraphBuilder.createExtension({\n id: 'root',\n match: NodeMatcher.whenRoot,\n actions: () =>\n Effect.succeed([\n Node.makeAction({\n id: COMMANDS_DIALOG,\n data: () =>\n Operation.invoke(LayoutOperation.UpdateDialog, {\n subject: COMMANDS_DIALOG,\n blockAlign: 'start',\n }),\n properties: {\n label: ['open-commands.label', { ns: meta.profile.key }],\n icon: 'ph--magnifying-glass--regular',\n keyBinding: {\n macos: 'meta+k',\n windows: 'ctrl+k',\n },\n },\n }),\n ]),\n });\n\n return Capability.contributes(AppCapabilities.AppGraphBuilder, extensions);\n }),\n);\n"],"mappings":";;;;;;;AAaA,IAAA,4BAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,MAAM,aAAa,OAAO,aAAa,gBAAgB;EACrD,IAAI;EACJ,OAAO,YAAY;EACnB,eACE,OAAO,QAAQ,CACb,KAAK,WAAW;GACd,IAAI;GACJ,YACE,UAAU,OAAO,gBAAgB,cAAc;IAC7C,SAAS;IACT,YAAY;GACd,CAAC;GACH,YAAY;IACV,OAAO,CAAC,uBAAuB,EAAE,IAAI,KAAK,QAAQ,IAAI,CAAC;IACvD,MAAM;IACN,YAAY;KACV,OAAO;KACP,SAAS;IACX;GACF;EACF,CAAC,CACH,CAAC;CACL,CAAC;CAED,OAAO,WAAW,YAAY,gBAAgB,iBAAiB,UAAU;AAC3E,CAAC,CACH"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { r as State } from "./chunk-types.mjs";
|
|
2
|
+
import { Capability } from "@dxos/app-framework";
|
|
3
|
+
import { AppCapabilities, LayoutOperation } from "@dxos/app-toolkit";
|
|
4
|
+
import { Graph } from "@dxos/plugin-graph";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import { Operation } from "@dxos/compute";
|
|
8
|
+
import { log } from "@dxos/log";
|
|
9
|
+
import { Attention } from "@dxos/react-ui-attention";
|
|
10
|
+
//#region src/operations/expose.ts
|
|
11
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-navtree/src/operations/expose.ts";
|
|
12
|
+
var handler = LayoutOperation.Expose.pipe(Operation.withHandler(Effect.fnUntraced(function* ({ subject }) {
|
|
13
|
+
const { graph } = yield* Capability.get(AppCapabilities.AppGraph);
|
|
14
|
+
const { getItem, setItem } = yield* Capability.get(State);
|
|
15
|
+
const prefixes = Attention.expandAttendableId(subject);
|
|
16
|
+
for (const qualifiedId of prefixes) {
|
|
17
|
+
Graph.expand(graph, qualifiedId, "child");
|
|
18
|
+
const treePath = prefixes.slice(0, prefixes.indexOf(qualifiedId) + 1);
|
|
19
|
+
if (!getItem(treePath).open) setItem(treePath, "open", true);
|
|
20
|
+
}
|
|
21
|
+
if (Option.isNone(Graph.getNode(graph, subject))) log("Node not found after expansion", { subject }, {
|
|
22
|
+
"~LogMeta": "~LogMeta",
|
|
23
|
+
F: __dxlog_file,
|
|
24
|
+
L: 36,
|
|
25
|
+
S: this
|
|
26
|
+
});
|
|
27
|
+
})));
|
|
28
|
+
//#endregion
|
|
29
|
+
export { handler as default };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=chunk-expose.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-expose.mjs","names":[],"sources":["../../src/operations/expose.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport * as Option from 'effect/Option';\n\nimport { Capability } from '@dxos/app-framework';\nimport { AppCapabilities, LayoutOperation } from '@dxos/app-toolkit';\nimport { Operation } from '@dxos/compute';\nimport { log } from '@dxos/log';\nimport { Graph } from '@dxos/plugin-graph';\nimport { Attention } from '@dxos/react-ui-attention';\n\nimport { NavTreeCapabilities } from '../types';\n\nconst handler: Operation.WithHandler<typeof LayoutOperation.Expose> = LayoutOperation.Expose.pipe(\n Operation.withHandler(\n Effect.fnUntraced(function* ({ subject }) {\n const { graph } = yield* Capability.get(AppCapabilities.AppGraph);\n const { getItem, setItem } = yield* Capability.get(NavTreeCapabilities.State);\n\n const prefixes = Attention.expandAttendableId(subject);\n\n for (const qualifiedId of prefixes) {\n Graph.expand(graph, qualifiedId, 'child');\n\n const treePath = prefixes.slice(0, prefixes.indexOf(qualifiedId) + 1);\n const state = getItem(treePath);\n if (!state.open) {\n setItem(treePath, 'open', true);\n }\n }\n\n if (Option.isNone(Graph.getNode(graph, subject))) {\n log('Node not found after expansion', { subject });\n }\n }),\n ),\n);\n\nexport default handler;\n"],"mappings":";;;;;;;;;;;AAgBA,IAAM,UAAgE,gBAAgB,OAAO,KAC3F,UAAU,YACR,OAAO,WAAW,WAAW,EAAE,WAAW;CACxC,MAAM,EAAE,UAAU,OAAO,WAAW,IAAI,gBAAgB,QAAQ;CAChE,MAAM,EAAE,SAAS,YAAY,OAAO,WAAW,IAAI,KAAyB;CAE5E,MAAM,WAAW,UAAU,mBAAmB,OAAO;CAErD,KAAK,MAAM,eAAe,UAAU;EAClC,MAAM,OAAO,OAAO,aAAa,OAAO;EAExC,MAAM,WAAW,SAAS,MAAM,GAAG,SAAS,QAAQ,WAAW,IAAI,CAAC;EAEpE,IAAI,CADU,QAAQ,QACjB,CAAA,CAAM,MACT,QAAQ,UAAU,QAAQ,IAAI;CAElC;CAEA,IAAI,OAAO,OAAO,MAAM,QAAQ,OAAO,OAAO,CAAC,GAC7C,IAAI,kCAAkC,EAAE,QAAQ,GAAA;EAAA,YAAA;EAAA,GAAA;EAAA,GAAA;EAAA,GAAA;CAAA,CAAC;AAErD,CAAC,CACH,CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
2
|
+
import { getHostPlatform } from "@dxos/util";
|
|
3
|
+
import { KEY_BINDING } from "#meta";
|
|
4
|
+
import { AppCapabilities } from "@dxos/app-toolkit";
|
|
5
|
+
import { Graph, Node, runAction } from "@dxos/plugin-graph";
|
|
6
|
+
import * as Effect from "effect/Effect";
|
|
7
|
+
import { debounce } from "@dxos/async";
|
|
8
|
+
import { Keyboard } from "@dxos/keyboard";
|
|
9
|
+
//#region src/capabilities/keyboard.ts
|
|
10
|
+
var keyboard_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
11
|
+
const { graph } = yield* Capability.get(AppCapabilities.AppGraph);
|
|
12
|
+
const invoker = yield* Capability.get(Capabilities.OperationInvoker);
|
|
13
|
+
const pluginContext = yield* Capability.Service;
|
|
14
|
+
const visitor = (node, path) => {
|
|
15
|
+
let shortcut;
|
|
16
|
+
if (typeof node.properties.keyBinding === "object") {
|
|
17
|
+
const availablePlatforms = Object.keys(node.properties.keyBinding);
|
|
18
|
+
const platform = getHostPlatform();
|
|
19
|
+
shortcut = availablePlatforms.includes(platform) ? node.properties.keyBinding[platform] : platform === "ios" ? node.properties.keyBinding.macos : platform === "linux" || platform === "unknown" ? node.properties.keyBinding.windows : void 0;
|
|
20
|
+
} else shortcut = node.properties.keyBinding;
|
|
21
|
+
if (shortcut && Node.isAction(node)) Keyboard.singleton.getContext(path.slice(0, -1).join("/")).bind({
|
|
22
|
+
shortcut,
|
|
23
|
+
handler: () => void runAction(invoker, pluginContext, node, {
|
|
24
|
+
parent: node,
|
|
25
|
+
caller: KEY_BINDING
|
|
26
|
+
}),
|
|
27
|
+
data: node.properties.label
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
const syncBindings = () => {
|
|
31
|
+
Graph.traverse(graph, {
|
|
32
|
+
relation: ["child", "action"],
|
|
33
|
+
visitor
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const eventHandler = debounce(syncBindings, 500);
|
|
37
|
+
const unsubscribe = graph.onNodeChanged.on(eventHandler);
|
|
38
|
+
syncBindings();
|
|
39
|
+
Keyboard.singleton.initialize();
|
|
40
|
+
Keyboard.singleton.setCurrentContext(Node.RootId);
|
|
41
|
+
return Capability.contributes(Capabilities.Null, null, () => Effect.sync(() => {
|
|
42
|
+
unsubscribe();
|
|
43
|
+
Keyboard.singleton.destroy();
|
|
44
|
+
}));
|
|
45
|
+
}));
|
|
46
|
+
//#endregion
|
|
47
|
+
export { keyboard_default as default };
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=chunk-keyboard.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-keyboard.mjs","names":[],"sources":["../../src/capabilities/keyboard.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { AppCapabilities } from '@dxos/app-toolkit';\nimport { debounce } from '@dxos/async';\nimport { Keyboard } from '@dxos/keyboard';\nimport { Graph, Node, runAction } from '@dxos/plugin-graph';\nimport { getHostPlatform } from '@dxos/util';\n\nimport { KEY_BINDING } from '#meta';\n\nexport default Capability.makeModule(\n Effect.fnUntraced(function* () {\n const { graph } = yield* Capability.get(AppCapabilities.AppGraph);\n const invoker = yield* Capability.get(Capabilities.OperationInvoker);\n const pluginContext = yield* Capability.Service;\n\n // TODO(wittjosiah): Factor out.\n // TODO(wittjosiah): Handle removal of actions.\n const visitor = (node: Node.Node, path: string[]) => {\n let shortcut: string | undefined;\n if (typeof node.properties.keyBinding === 'object') {\n const availablePlatforms = Object.keys(node.properties.keyBinding);\n const platform = getHostPlatform();\n shortcut = availablePlatforms.includes(platform)\n ? node.properties.keyBinding[platform]\n : platform === 'ios'\n ? node.properties.keyBinding.macos // Fallback to macos if ios-specific bindings not provided.\n : platform === 'linux' || platform === 'unknown'\n ? node.properties.keyBinding.windows // Fallback to windows if platform-specific bindings not provided.\n : undefined;\n } else {\n shortcut = node.properties.keyBinding;\n }\n\n if (shortcut && Node.isAction(node)) {\n Keyboard.singleton.getContext(path.slice(0, -1).join('/')).bind({\n shortcut,\n handler: () => void runAction(invoker, pluginContext, node, { parent: node, caller: KEY_BINDING }),\n data: node.properties.label,\n });\n }\n };\n\n const syncBindings = () => {\n Graph.traverse(graph, { relation: ['child', 'action'], visitor });\n };\n\n const eventHandler = debounce(syncBindings, 500);\n\n const unsubscribe = graph.onNodeChanged.on(eventHandler);\n syncBindings();\n\n // TODO(burdon): Create context and plugin.\n Keyboard.singleton.initialize();\n Keyboard.singleton.setCurrentContext(Node.RootId);\n\n return Capability.contributes(Capabilities.Null, null, () =>\n Effect.sync(() => {\n unsubscribe();\n Keyboard.singleton.destroy();\n }),\n );\n }),\n);\n"],"mappings":";;;;;;;;;AAeA,IAAA,mBAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,MAAM,EAAE,UAAU,OAAO,WAAW,IAAI,gBAAgB,QAAQ;CAChE,MAAM,UAAU,OAAO,WAAW,IAAI,aAAa,gBAAgB;CACnE,MAAM,gBAAgB,OAAO,WAAW;CAIxC,MAAM,WAAW,MAAiB,SAAmB;EACnD,IAAI;EACJ,IAAI,OAAO,KAAK,WAAW,eAAe,UAAU;GAClD,MAAM,qBAAqB,OAAO,KAAK,KAAK,WAAW,UAAU;GACjE,MAAM,WAAW,gBAAgB;GACjC,WAAW,mBAAmB,SAAS,QAAQ,IAC3C,KAAK,WAAW,WAAW,YAC3B,aAAa,QACX,KAAK,WAAW,WAAW,QAC3B,aAAa,WAAW,aAAa,YACnC,KAAK,WAAW,WAAW,UAC3B,KAAA;EACV,OACE,WAAW,KAAK,WAAW;EAG7B,IAAI,YAAY,KAAK,SAAS,IAAI,GAChC,SAAS,UAAU,WAAW,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK;GAC9D;GACA,eAAe,KAAK,UAAU,SAAS,eAAe,MAAM;IAAE,QAAQ;IAAM,QAAQ;GAAY,CAAC;GACjG,MAAM,KAAK,WAAW;EACxB,CAAC;CAEL;CAEA,MAAM,qBAAqB;EACzB,MAAM,SAAS,OAAO;GAAE,UAAU,CAAC,SAAS,QAAQ;GAAG;EAAQ,CAAC;CAClE;CAEA,MAAM,eAAe,SAAS,cAAc,GAAG;CAE/C,MAAM,cAAc,MAAM,cAAc,GAAG,YAAY;CACvD,aAAa;CAGb,SAAS,UAAU,WAAW;CAC9B,SAAS,UAAU,kBAAkB,KAAK,MAAM;CAEhD,OAAO,WAAW,YAAY,aAAa,MAAM,YAC/C,OAAO,WAAW;EAChB,YAAY;EACZ,SAAS,UAAU,QAAQ;CAC7B,CAAC,CACH;AACF,CAAC,CACH"}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
// src/meta.ts
|
|
2
1
|
import { Plugin } from "@dxos/app-framework";
|
|
3
2
|
import { DXN } from "@dxos/keys";
|
|
4
|
-
|
|
5
|
-
// dx.config.ts
|
|
6
3
|
import { Config2 } from "@dxos/app-framework/config";
|
|
7
4
|
import { trim } from "@dxos/util";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
//#region dx.config.ts
|
|
6
|
+
var dx_config_default = Config2.make({ plugin: {
|
|
7
|
+
key: "org.dxos.plugin.navtree",
|
|
8
|
+
name: "Navtree",
|
|
9
|
+
author: "DXOS",
|
|
10
|
+
description: trim`
|
|
14
11
|
NavTreePlugin renders the application graph as a collapsible hierarchical tree in the Composer sidebar.
|
|
15
12
|
It manages workspace tabs at the root level and provides expand/collapse navigation for spaces, folders,
|
|
16
13
|
and objects, with open/current state persisted to localStorage across sessions.
|
|
@@ -25,21 +22,15 @@ var dx_config_default = Config2.make({
|
|
|
25
22
|
A commands dialog surfaces all discoverable graph actions as a searchable palette, making it the primary
|
|
26
23
|
keyboard-first entry point for power users.
|
|
27
24
|
`,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// src/meta.ts
|
|
25
|
+
spec: "PLUGIN.mdl",
|
|
26
|
+
tags: ["system"]
|
|
27
|
+
} });
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/meta.ts
|
|
36
30
|
var meta = Plugin.getMetaFromConfig(dx_config_default);
|
|
37
31
|
var KEY_BINDING = "KeyBinding";
|
|
38
32
|
var COMMANDS_DIALOG = DXN.make(`${meta.profile.key}.commandsDialog`);
|
|
33
|
+
//#endregion
|
|
34
|
+
export { KEY_BINDING as n, meta as r, COMMANDS_DIALOG as t };
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
meta,
|
|
42
|
-
KEY_BINDING,
|
|
43
|
-
COMMANDS_DIALOG
|
|
44
|
-
};
|
|
45
|
-
//# sourceMappingURL=chunk-IRQMJLRY.mjs.map
|
|
36
|
+
//# sourceMappingURL=chunk-meta.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-meta.mjs","names":[],"sources":["../../dx.config.ts","../../src/meta.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport { Config2 } from '@dxos/app-framework/config';\nimport { trim } from '@dxos/util';\n\nexport default Config2.make({\n plugin: {\n key: 'org.dxos.plugin.navtree',\n name: 'Navtree',\n author: 'DXOS',\n description: trim`\n NavTreePlugin renders the application graph as a collapsible hierarchical tree in the Composer sidebar.\n It manages workspace tabs at the root level and provides expand/collapse navigation for spaces, folders,\n and objects, with open/current state persisted to localStorage across sessions.\n\n The plugin wires drag-and-drop rearrangement and cross-parent transfer of tree items via Pragmatic DnD,\n and registers graph-action keyboard shortcuts (including the ⌘K / Ctrl+K command palette) through a\n global Keyboard singleton that tracks context as the user navigates.\n\n An operation handler for LayoutOperation.Expose expands ancestor paths on demand so that any\n programmatically activated item is scrolled into view in the tree.\n\n A commands dialog surfaces all discoverable graph actions as a searchable palette, making it the primary\n keyboard-first entry point for power users.\n `,\n spec: 'PLUGIN.mdl',\n tags: ['system'],\n },\n});\n","//\n// Copyright 2023 DXOS.org\n//\n\nimport { Plugin } from '@dxos/app-framework';\nimport { DXN } from '@dxos/keys';\n\nimport config from '../dx.config';\n\nexport const meta = Plugin.getMetaFromConfig(config);\n\n// TODO(wittjosiah): Factor out.\nexport const KEY_BINDING = 'KeyBinding';\n// TODO(wittjosiah): Factor out.\nexport const COMMANDS_DIALOG = DXN.make(`${meta.profile.key}.commandsDialog`);\n"],"mappings":";;;;;AAOA,IAAA,oBAAe,QAAQ,KAAK,EAC1B,QAAQ;CACN,KAAK;CACL,MAAM;CACN,QAAQ;CACR,aAAa,IAAI;;;;;;;;;;;;;;;CAejB,MAAM;CACN,MAAM,CAAC,QAAQ;AACjB,EACF,CAAC;;;ACrBD,IAAa,OAAO,OAAO,kBAAkB,iBAAM;AAGnD,IAAa,cAAc;AAE3B,IAAa,kBAAkB,IAAI,KAAK,GAAG,KAAK,QAAQ,IAAI,gBAAgB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
2
|
+
import * as Effect from "effect/Effect";
|
|
3
|
+
import { NavTreeOperationHandlerSet } from "#operations";
|
|
4
|
+
//#region src/capabilities/operation-handler.ts
|
|
5
|
+
var operation_handler_default = Capability.makeModule(Effect.fnUntraced(function* () {
|
|
6
|
+
return Capability.contributes(Capabilities.OperationHandler, NavTreeOperationHandlerSet);
|
|
7
|
+
}));
|
|
8
|
+
//#endregion
|
|
9
|
+
export { operation_handler_default as default };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=chunk-operation-handler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-operation-handler.mjs","names":[],"sources":["../../src/capabilities/operation-handler.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport type { OperationHandlerSet } from '@dxos/compute';\n\nimport { NavTreeOperationHandlerSet } from '#operations';\n\nexport default Capability.makeModule<OperationHandlerSet.OperationHandlerSet>(\n Effect.fnUntraced(function* () {\n return Capability.contributes(Capabilities.OperationHandler, NavTreeOperationHandlerSet);\n }),\n);\n"],"mappings":";;;;AAWA,IAAA,4BAAe,WAAW,WACxB,OAAO,WAAW,aAAa;CAC7B,OAAO,WAAW,YAAY,aAAa,kBAAkB,0BAA0B;AACzF,CAAC,CACH"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Capabilities, Capability } from "@dxos/app-framework";
|
|
2
|
+
import { Position } from "@dxos/util";
|
|
3
|
+
import { COMMANDS_DIALOG } from "#meta";
|
|
4
|
+
import { Node } from "@dxos/plugin-graph";
|
|
5
|
+
import * as Effect from "effect/Effect";
|
|
6
|
+
import { AppSurface } from "@dxos/app-toolkit/ui";
|
|
7
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
8
|
+
import { CommandsDialogContent, CommandsTrigger, NavTreeContainer, NavTreeDocumentTitle } from "#containers";
|
|
9
|
+
//#region src/capabilities/react-surface.ts
|
|
10
|
+
var react_surface_default = Capability.makeModule(() => Effect.succeed(Capability.contributes(Capabilities.ReactSurface, [
|
|
11
|
+
Surface.create({
|
|
12
|
+
id: COMMANDS_DIALOG,
|
|
13
|
+
filter: AppSurface.component(AppSurface.Dialog, COMMANDS_DIALOG),
|
|
14
|
+
component: CommandsDialogContent,
|
|
15
|
+
props: ({ data: { props }, ref }) => ({
|
|
16
|
+
...props,
|
|
17
|
+
ref
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
Surface.create({
|
|
21
|
+
id: "navigation",
|
|
22
|
+
filter: Surface.makeFilter(AppSurface.Navigation),
|
|
23
|
+
component: NavTreeContainer,
|
|
24
|
+
props: ({ data: { current, popoverAnchorId }, ref }) => ({
|
|
25
|
+
tab: current,
|
|
26
|
+
popoverAnchorId,
|
|
27
|
+
ref
|
|
28
|
+
})
|
|
29
|
+
}),
|
|
30
|
+
Surface.create({
|
|
31
|
+
id: "documentTitle",
|
|
32
|
+
filter: Surface.makeFilter(AppSurface.DocumentTitle),
|
|
33
|
+
component: NavTreeDocumentTitle,
|
|
34
|
+
props: ({ data: { subject } }) => ({ node: Node.isGraphNode(subject) ? subject : void 0 })
|
|
35
|
+
}),
|
|
36
|
+
Surface.create({
|
|
37
|
+
id: "searchInput",
|
|
38
|
+
filter: Surface.makeFilter(AppSurface.SearchInput),
|
|
39
|
+
position: Position.last,
|
|
40
|
+
component: CommandsTrigger
|
|
41
|
+
})
|
|
42
|
+
])));
|
|
43
|
+
//#endregion
|
|
44
|
+
export { react_surface_default as default };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=chunk-react-surface.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-react-surface.mjs","names":[],"sources":["../../src/capabilities/react-surface.ts"],"sourcesContent":["//\n// Copyright 2025 DXOS.org\n//\n\nimport * as Effect from 'effect/Effect';\nimport { type ComponentProps } from 'react';\n\nimport { Capabilities, Capability } from '@dxos/app-framework';\nimport { Surface } from '@dxos/app-framework/ui';\nimport { AppSurface } from '@dxos/app-toolkit/ui';\nimport { Node } from '@dxos/plugin-graph';\nimport { Position } from '@dxos/util';\n\nimport { CommandsDialogContent, CommandsTrigger, NavTreeContainer, NavTreeDocumentTitle } from '#containers';\nimport { COMMANDS_DIALOG } from '#meta';\n\nexport default Capability.makeModule(() =>\n Effect.succeed(\n Capability.contributes(Capabilities.ReactSurface, [\n Surface.create({\n id: COMMANDS_DIALOG,\n filter: AppSurface.component<ComponentProps<typeof CommandsDialogContent>>(AppSurface.Dialog, COMMANDS_DIALOG),\n component: CommandsDialogContent,\n props: ({ data: { props }, ref }) => ({ ...props, ref }),\n }),\n Surface.create({\n id: 'navigation',\n filter: Surface.makeFilter(AppSurface.Navigation),\n component: NavTreeContainer,\n props: ({ data: { current, popoverAnchorId }, ref }) => ({ tab: current, popoverAnchorId, ref }),\n }),\n Surface.create({\n id: 'documentTitle',\n filter: Surface.makeFilter(AppSurface.DocumentTitle),\n component: NavTreeDocumentTitle,\n props: ({ data: { subject } }) => ({ node: Node.isGraphNode(subject) ? subject : undefined }),\n }),\n Surface.create({\n id: 'searchInput',\n filter: Surface.makeFilter(AppSurface.SearchInput),\n position: Position.last,\n component: CommandsTrigger,\n }),\n ]),\n ),\n);\n"],"mappings":";;;;;;;;;AAgBA,IAAA,wBAAe,WAAW,iBACxB,OAAO,QACL,WAAW,YAAY,aAAa,cAAc;CAChD,QAAQ,OAAO;EACb,IAAI;EACJ,QAAQ,WAAW,UAAwD,WAAW,QAAQ,eAAe;EAC7G,WAAW;EACX,QAAQ,EAAE,MAAM,EAAE,SAAS,WAAW;GAAE,GAAG;GAAO;EAAI;CACxD,CAAC;CACD,QAAQ,OAAO;EACb,IAAI;EACJ,QAAQ,QAAQ,WAAW,WAAW,UAAU;EAChD,WAAW;EACX,QAAQ,EAAE,MAAM,EAAE,SAAS,mBAAmB,WAAW;GAAE,KAAK;GAAS;GAAiB;EAAI;CAChG,CAAC;CACD,QAAQ,OAAO;EACb,IAAI;EACJ,QAAQ,QAAQ,WAAW,WAAW,aAAa;EACnD,WAAW;EACX,QAAQ,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,KAAK,YAAY,OAAO,IAAI,UAAU,KAAA,EAAU;CAC7F,CAAC;CACD,QAAQ,OAAO;EACb,IAAI;EACJ,QAAQ,QAAQ,WAAW,WAAW,WAAW;EACjD,UAAU,SAAS;EACnB,WAAW;CACb,CAAC;AACH,CAAC,CACH,CACF"}
|