@dxos/plugin-navtree 0.8.2-staging.7ac8446 → 0.8.3-main.672df60
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/dist/lib/browser/{app-graph-builder-26D3MUCA.mjs → app-graph-builder-P7AY3K72.mjs} +7 -6
- package/dist/lib/browser/app-graph-builder-P7AY3K72.mjs.map +7 -0
- package/dist/lib/browser/{chunk-4RQJXI4D.mjs → chunk-33VLL4IJ.mjs} +2 -2
- package/dist/lib/browser/chunk-33VLL4IJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-MFAWMFJC.mjs +1418 -0
- package/dist/lib/browser/chunk-MFAWMFJC.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +6 -11
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/{intent-resolver-BZMUS24C.mjs → intent-resolver-NAYKKAOP.mjs} +7 -7
- package/dist/lib/browser/intent-resolver-NAYKKAOP.mjs.map +7 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs +51 -0
- package/dist/lib/browser/keyboard-DDFATRUG.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{react-surface-3HCM3SHJ.mjs → react-surface-HGA3TAQU.mjs} +3 -3
- package/dist/lib/browser/{state-M5UJ3MHL.mjs → state-R2UMYAHN.mjs} +18 -12
- package/dist/lib/browser/state-R2UMYAHN.mjs.map +7 -0
- package/dist/types/src/capabilities/app-graph-builder.d.ts +2 -179
- package/dist/types/src/capabilities/app-graph-builder.d.ts.map +1 -1
- package/dist/types/src/capabilities/capabilities.d.ts +7 -4
- package/dist/types/src/capabilities/capabilities.d.ts.map +1 -1
- package/dist/types/src/capabilities/index.d.ts +38 -183
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/keyboard.d.ts +2 -2
- package/dist/types/src/capabilities/keyboard.d.ts.map +1 -1
- package/dist/types/src/capabilities/state.d.ts +9 -6
- package/dist/types/src/capabilities/state.d.ts.map +1 -1
- package/dist/types/src/components/CommandsDialog/CommandsDialog.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/CommandsTrigger.d.ts.map +1 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts +3 -0
- package/dist/types/src/components/CommandsDialog/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts +8 -0
- package/dist/types/src/components/NavTree/NavTree.stories.d.ts.map +1 -0
- package/dist/types/src/components/NavTree/index.d.ts +2 -0
- package/dist/types/src/components/NavTree/index.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeContainer.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeContext.d.ts.map +1 -1
- package/dist/types/src/components/NavTreeDocumentTitle.d.ts.map +1 -1
- package/dist/types/src/components/{NavTreeItemAction.d.ts → NavTreeItem/NavTreeItemAction.d.ts} +3 -5
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts +8 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemAction.stories.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts +4 -0
- package/dist/types/src/components/NavTreeItem/NavTreeItemColumns.d.ts.map +1 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts +3 -0
- package/dist/types/src/components/NavTreeItem/index.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts +13 -0
- package/dist/types/src/components/Sidebar/L0Menu.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts +15 -0
- package/dist/types/src/components/Sidebar/L1Panel.d.ts.map +1 -0
- package/dist/types/src/components/Sidebar/index.d.ts +3 -0
- package/dist/types/src/components/Sidebar/index.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.d.ts → UserAccountAvatar/UserAccountAvatar.d.ts} +1 -1
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.d.ts.map +1 -0
- package/dist/types/src/components/{UserAccountAvatar.stories.d.ts → UserAccountAvatar/UserAccountAvatar.stories.d.ts} +1 -2
- package/dist/types/src/components/UserAccountAvatar/UserAccountAvatar.stories.d.ts.map +1 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts +2 -0
- package/dist/types/src/components/UserAccountAvatar/index.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +0 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/components/types.d.ts +20 -14
- package/dist/types/src/components/types.d.ts.map +1 -1
- package/dist/types/src/experimental/Tree.d.ts.map +1 -1
- package/dist/types/src/hooks.d.ts.map +1 -1
- package/dist/types/src/testing/app-graph-builder.d.ts +3 -0
- package/dist/types/src/testing/app-graph-builder.d.ts.map +1 -0
- package/dist/types/src/testing/generator.d.ts +7 -6
- package/dist/types/src/testing/generator.d.ts.map +1 -1
- package/dist/types/src/testing/index.d.ts +1 -0
- package/dist/types/src/testing/index.d.ts.map +1 -1
- package/dist/types/src/testing/update-state.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +1 -0
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/util.d.ts +7 -10
- package/dist/types/src/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +42 -32
- package/src/NavTreePlugin.tsx +2 -2
- package/src/capabilities/app-graph-builder.ts +38 -28
- package/src/capabilities/capabilities.ts +5 -4
- package/src/capabilities/intent-resolver.ts +8 -7
- package/src/capabilities/keyboard.ts +37 -32
- package/src/capabilities/state.ts +23 -17
- package/src/components/{CommandsDialog.tsx → CommandsDialog/CommandsDialog.tsx} +8 -7
- package/src/components/{CommandsTrigger.tsx → CommandsDialog/CommandsTrigger.tsx} +1 -1
- package/src/components/CommandsDialog/index.ts +6 -0
- package/src/components/NavTree/NavTree.stories.tsx +159 -0
- package/src/components/NavTree/NavTree.tsx +62 -0
- package/src/components/NavTree/index.ts +5 -0
- package/src/components/NavTreeContainer.tsx +85 -67
- package/src/components/NavTreeContext.tsx +1 -1
- package/src/components/{NavTreeItemAction.stories.tsx → NavTreeItem/NavTreeItemAction.stories.tsx} +12 -6
- package/src/components/{NavTreeItemAction.tsx → NavTreeItem/NavTreeItemAction.tsx} +19 -22
- package/src/components/NavTreeItem/NavTreeItemColumns.tsx +73 -0
- package/src/components/NavTreeItem/index.ts +6 -0
- package/src/components/{L0Menu.tsx → Sidebar/L0Menu.tsx} +186 -131
- package/src/components/Sidebar/L1Panel.tsx +175 -0
- package/src/components/Sidebar/index.ts +6 -0
- package/src/components/{UserAccountAvatar.stories.tsx → UserAccountAvatar/UserAccountAvatar.stories.tsx} +5 -5
- package/src/components/{UserAccountAvatar.tsx → UserAccountAvatar/UserAccountAvatar.tsx} +7 -7
- package/src/components/UserAccountAvatar/index.ts +5 -0
- package/src/components/index.ts +0 -1
- package/src/components/types.ts +20 -15
- package/src/testing/app-graph-builder.ts +224 -0
- package/src/testing/generator.ts +15 -12
- package/src/testing/index.ts +1 -0
- package/src/translations.ts +1 -0
- package/src/util.ts +10 -32
- package/dist/lib/browser/app-graph-builder-26D3MUCA.mjs.map +0 -7
- package/dist/lib/browser/chunk-4RQJXI4D.mjs.map +0 -7
- package/dist/lib/browser/chunk-DN43QXSX.mjs +0 -1222
- package/dist/lib/browser/chunk-DN43QXSX.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-BZMUS24C.mjs.map +0 -7
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs +0 -46
- package/dist/lib/browser/keyboard-IQXHKUWM.mjs.map +0 -7
- package/dist/lib/browser/state-M5UJ3MHL.mjs.map +0 -7
- package/dist/types/src/components/CommandsDialog.d.ts.map +0 -1
- package/dist/types/src/components/CommandsTrigger.d.ts.map +0 -1
- package/dist/types/src/components/L0Menu.d.ts +0 -10
- package/dist/types/src/components/L0Menu.d.ts.map +0 -1
- package/dist/types/src/components/L1Panels.d.ts +0 -14
- package/dist/types/src/components/L1Panels.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.d.ts +0 -5
- package/dist/types/src/components/NavTree.d.ts.map +0 -1
- package/dist/types/src/components/NavTree.stories.d.ts +0 -7
- package/dist/types/src/components/NavTree.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts +0 -41
- package/dist/types/src/components/NavTreeItemAction.stories.d.ts.map +0 -1
- package/dist/types/src/components/NavTreeItemColumns.d.ts +0 -4
- package/dist/types/src/components/NavTreeItemColumns.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.d.ts.map +0 -1
- package/dist/types/src/components/UserAccountAvatar.stories.d.ts.map +0 -1
- package/dist/types/src/stories/Graph.stories.d.ts +0 -7
- package/dist/types/src/stories/Graph.stories.d.ts.map +0 -1
- package/dist/types/src/stories/StorybookNavTree.d.ts +0 -4
- package/dist/types/src/stories/StorybookNavTree.d.ts.map +0 -1
- package/src/components/L1Panels.tsx +0 -115
- package/src/components/NavTree.stories.tsx +0 -107
- package/src/components/NavTree.tsx +0 -51
- package/src/components/NavTreeItemColumns.tsx +0 -71
- package/src/stories/Graph.stories.tsx +0 -130
- package/src/stories/StorybookNavTree.tsx +0 -63
- /package/dist/lib/browser/{react-surface-3HCM3SHJ.mjs.map → react-surface-HGA3TAQU.mjs.map} +0 -0
- /package/dist/types/src/components/{CommandsDialog.d.ts → CommandsDialog/CommandsDialog.d.ts} +0 -0
- /package/dist/types/src/components/{CommandsTrigger.d.ts → CommandsDialog/CommandsTrigger.d.ts} +0 -0
|
@@ -0,0 +1,1418 @@
|
|
|
1
|
+
import {
|
|
2
|
+
NavTreeCapabilities
|
|
3
|
+
} from "./chunk-33VLL4IJ.mjs";
|
|
4
|
+
import {
|
|
5
|
+
COMMANDS_DIALOG,
|
|
6
|
+
KEY_BINDING,
|
|
7
|
+
NAVTREE_PLUGIN
|
|
8
|
+
} from "./chunk-IEW3JD5C.mjs";
|
|
9
|
+
|
|
10
|
+
// packages/plugins/plugin-navtree/src/components/CommandsDialog/CommandsDialog.tsx
|
|
11
|
+
import { useSignals as _useSignals } from "@preact-signals/safe-react/tracking";
|
|
12
|
+
import React, { useMemo, useState } from "react";
|
|
13
|
+
import { createIntent, LayoutAction, useAppGraph, useIntentDispatcher } from "@dxos/app-framework";
|
|
14
|
+
import { isAction, isActionGroup } from "@dxos/app-graph";
|
|
15
|
+
import { Keyboard, keySymbols } from "@dxos/keyboard";
|
|
16
|
+
import { useActions } from "@dxos/plugin-graph";
|
|
17
|
+
import { Button, Dialog, Icon, useTranslation, toLocalizedString } from "@dxos/react-ui";
|
|
18
|
+
import { SearchList } from "@dxos/react-ui-searchlist";
|
|
19
|
+
import { descriptionText, mx } from "@dxos/react-ui-theme";
|
|
20
|
+
import { getHostPlatform } from "@dxos/util";
|
|
21
|
+
var CommandsDialogContent = ({ selected: initial }) => {
|
|
22
|
+
var _effect = _useSignals();
|
|
23
|
+
try {
|
|
24
|
+
const { t } = useTranslation(NAVTREE_PLUGIN);
|
|
25
|
+
const [selected, setSelected] = useState(initial);
|
|
26
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher();
|
|
27
|
+
const { graph } = useAppGraph();
|
|
28
|
+
const allActions = useMemo(() => {
|
|
29
|
+
const current = Keyboard.singleton.getCurrentContext();
|
|
30
|
+
const actionMap = /* @__PURE__ */ new Set();
|
|
31
|
+
const actions2 = [];
|
|
32
|
+
graph.traverse({
|
|
33
|
+
visitor: (node, path) => {
|
|
34
|
+
if ((isAction(node) || isActionGroup(node)) && !actionMap.has(node.id) && current.startsWith(path.slice(0, -1).join("/"))) {
|
|
35
|
+
actionMap.add(node.id);
|
|
36
|
+
actions2.push(node);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
actions2.sort((a, b) => {
|
|
41
|
+
return toLocalizedString(a.properties.label, t)?.toLowerCase().localeCompare(toLocalizedString(b.properties.label, t)?.toLowerCase());
|
|
42
|
+
});
|
|
43
|
+
return actions2;
|
|
44
|
+
}, [
|
|
45
|
+
graph
|
|
46
|
+
]);
|
|
47
|
+
const group = allActions.find(({ id }) => id === selected);
|
|
48
|
+
const groupActions = useActions(graph, group?.id);
|
|
49
|
+
const actions = isActionGroup(group) ? groupActions : allActions;
|
|
50
|
+
return /* @__PURE__ */ React.createElement(Dialog.Content, {
|
|
51
|
+
classNames: [
|
|
52
|
+
"md:max-is-[30rem] overflow-hidden mbs-12"
|
|
53
|
+
]
|
|
54
|
+
}, /* @__PURE__ */ React.createElement(Dialog.Title, null, t("commands dialog title", {
|
|
55
|
+
ns: NAVTREE_PLUGIN
|
|
56
|
+
})), /* @__PURE__ */ React.createElement(SearchList.Root, {
|
|
57
|
+
label: t("command list input placeholder"),
|
|
58
|
+
classNames: "flex flex-col grow overflow-hidden my-2"
|
|
59
|
+
}, /* @__PURE__ */ React.createElement(SearchList.Input, {
|
|
60
|
+
placeholder: t("command list input placeholder"),
|
|
61
|
+
classNames: "px-1 my-2"
|
|
62
|
+
}), /* @__PURE__ */ React.createElement(SearchList.Content, {
|
|
63
|
+
classNames: "max-bs-[24rem] overflow-auto"
|
|
64
|
+
}, actions?.map((action) => {
|
|
65
|
+
const label = toLocalizedString(action.properties.label, t);
|
|
66
|
+
const shortcut = typeof action.properties.keyBinding === "string" ? action.properties.keyBinding : action.properties.keyBinding?.[getHostPlatform()];
|
|
67
|
+
return /* @__PURE__ */ React.createElement(SearchList.Item, {
|
|
68
|
+
value: label,
|
|
69
|
+
key: action.id,
|
|
70
|
+
onSelect: () => {
|
|
71
|
+
if (action.properties.disabled) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
if (isActionGroup(action)) {
|
|
75
|
+
setSelected(action.id);
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
void dispatch(createIntent(LayoutAction.UpdateDialog, {
|
|
79
|
+
part: "dialog",
|
|
80
|
+
options: {
|
|
81
|
+
state: false
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
setTimeout(() => {
|
|
85
|
+
const node = graph.getConnections(group?.id ?? action.id, "inbound")[0];
|
|
86
|
+
void (node && isAction(action) && action.data({
|
|
87
|
+
parent: node,
|
|
88
|
+
caller: KEY_BINDING
|
|
89
|
+
}));
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
classNames: "flex items-center gap-2",
|
|
93
|
+
disabled: action.properties.disabled,
|
|
94
|
+
...action.properties?.testId && {
|
|
95
|
+
"data-testid": action.properties.testId
|
|
96
|
+
}
|
|
97
|
+
}, /* @__PURE__ */ React.createElement(Icon, {
|
|
98
|
+
icon: action.properties.icon,
|
|
99
|
+
size: 4
|
|
100
|
+
}), /* @__PURE__ */ React.createElement("span", {
|
|
101
|
+
className: "grow truncate"
|
|
102
|
+
}, label), shortcut && /* @__PURE__ */ React.createElement("span", {
|
|
103
|
+
className: mx("shrink-0", descriptionText)
|
|
104
|
+
}, keySymbols(shortcut).join("")));
|
|
105
|
+
}))), /* @__PURE__ */ React.createElement(Dialog.Close, {
|
|
106
|
+
asChild: true
|
|
107
|
+
}, /* @__PURE__ */ React.createElement(Button, {
|
|
108
|
+
variant: "primary",
|
|
109
|
+
classNames: "mbs-2"
|
|
110
|
+
}, t("close label", {
|
|
111
|
+
ns: "os"
|
|
112
|
+
}))));
|
|
113
|
+
} finally {
|
|
114
|
+
_effect.f();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// packages/plugins/plugin-navtree/src/components/CommandsDialog/CommandsTrigger.tsx
|
|
119
|
+
import { useSignals as _useSignals2 } from "@preact-signals/safe-react/tracking";
|
|
120
|
+
import { MagnifyingGlass } from "@phosphor-icons/react";
|
|
121
|
+
import React2 from "react";
|
|
122
|
+
import { createIntent as createIntent2, LayoutAction as LayoutAction2, useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
123
|
+
import { Button as Button2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
124
|
+
import { getSize } from "@dxos/react-ui-theme";
|
|
125
|
+
var CommandsTrigger = () => {
|
|
126
|
+
var _effect = _useSignals2();
|
|
127
|
+
try {
|
|
128
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher2();
|
|
129
|
+
const { t } = useTranslation2(NAVTREE_PLUGIN);
|
|
130
|
+
return /* @__PURE__ */ React2.createElement(Button2, {
|
|
131
|
+
classNames: "m-1 pli-1 lg:pli-2",
|
|
132
|
+
onClick: () => dispatch(createIntent2(LayoutAction2.UpdateDialog, {
|
|
133
|
+
part: "dialog",
|
|
134
|
+
subject: COMMANDS_DIALOG,
|
|
135
|
+
options: {
|
|
136
|
+
blockAlign: "start"
|
|
137
|
+
}
|
|
138
|
+
}))
|
|
139
|
+
}, /* @__PURE__ */ React2.createElement("span", {
|
|
140
|
+
className: "text-description font-normal grow text-start"
|
|
141
|
+
}, t("command list input placeholder")), /* @__PURE__ */ React2.createElement(MagnifyingGlass, {
|
|
142
|
+
className: getSize(5)
|
|
143
|
+
}));
|
|
144
|
+
} finally {
|
|
145
|
+
_effect.f();
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
// packages/plugins/plugin-navtree/src/util.ts
|
|
150
|
+
import { isAction as isAction2, isActionLike } from "@dxos/app-graph";
|
|
151
|
+
import { isNonNullable } from "@dxos/util";
|
|
152
|
+
var getParent = (graph, node, path) => {
|
|
153
|
+
const parentId = path[path.length - 2];
|
|
154
|
+
return graph.getConnections(node.id, "inbound").find((n) => n.id === parentId);
|
|
155
|
+
};
|
|
156
|
+
var getPersistenceParent = (graph, node, path, persistenceClass) => {
|
|
157
|
+
if (node.properties.acceptPersistenceClass?.has(persistenceClass)) {
|
|
158
|
+
return node;
|
|
159
|
+
} else {
|
|
160
|
+
const parent = getParent(graph, node, path);
|
|
161
|
+
return parent ? getPersistenceParent(graph, parent, path.slice(0, path.length - 1), persistenceClass) : null;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
var resolveMigrationOperation = (graph, activeNode, destinationPath, destinationRelatedNode) => {
|
|
165
|
+
const activeClass = activeNode.properties.persistenceClass;
|
|
166
|
+
if (destinationRelatedNode && activeClass) {
|
|
167
|
+
const persistenceParent = getPersistenceParent(graph, destinationRelatedNode, destinationPath, activeClass);
|
|
168
|
+
if (persistenceParent) {
|
|
169
|
+
const activeKey = activeNode.properties.persistenceKey;
|
|
170
|
+
if (activeKey && persistenceParent?.properties.acceptPersistenceKey) {
|
|
171
|
+
return persistenceParent.properties.acceptPersistenceKey.has(activeKey) && persistenceParent.properties.onTransferStart ? "transfer" : persistenceParent.properties.onCopy ? "copy" : "reject";
|
|
172
|
+
} else {
|
|
173
|
+
return "reject";
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
return "reject";
|
|
177
|
+
}
|
|
178
|
+
} else {
|
|
179
|
+
return "reject";
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
var sortActions = (actions) => actions.sort((a, b) => {
|
|
183
|
+
if (a.properties.disposition === b.properties.disposition) {
|
|
184
|
+
return 0;
|
|
185
|
+
}
|
|
186
|
+
if (a.properties.disposition === "list-item-primary") {
|
|
187
|
+
return -1;
|
|
188
|
+
}
|
|
189
|
+
return 1;
|
|
190
|
+
});
|
|
191
|
+
var getChildren = (graph, node, path = []) => {
|
|
192
|
+
return graph.getConnections(node.id, "outbound").map((n) => {
|
|
193
|
+
const nextPath = [
|
|
194
|
+
...path,
|
|
195
|
+
node.id
|
|
196
|
+
];
|
|
197
|
+
return nextPath.includes(n.id) ? void 0 : n;
|
|
198
|
+
}).filter(isNonNullable);
|
|
199
|
+
};
|
|
200
|
+
var getActions = (graph, node) => {
|
|
201
|
+
return graph.getActions(node.id).reduce((acc, arg) => {
|
|
202
|
+
if (arg.properties.disposition === "item") {
|
|
203
|
+
return acc;
|
|
204
|
+
}
|
|
205
|
+
acc.actions.push(arg);
|
|
206
|
+
if (!isAction2(arg)) {
|
|
207
|
+
const actionGroup = graph.getActions(arg.id);
|
|
208
|
+
acc.groupedActions[arg.id] = actionGroup;
|
|
209
|
+
}
|
|
210
|
+
return acc;
|
|
211
|
+
}, {
|
|
212
|
+
actions: [],
|
|
213
|
+
groupedActions: {}
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
var l0ItemType = (item) => {
|
|
217
|
+
if (item.properties.disposition === "collection") {
|
|
218
|
+
return "collection";
|
|
219
|
+
} else if (isActionLike(item)) {
|
|
220
|
+
return "action";
|
|
221
|
+
} else if (item.properties.disposition === "navigation") {
|
|
222
|
+
return "link";
|
|
223
|
+
} else {
|
|
224
|
+
return "tab";
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeContainer.tsx
|
|
229
|
+
import { useSignals as _useSignals9 } from "@preact-signals/safe-react/tracking";
|
|
230
|
+
import { monitorForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
231
|
+
import { extractInstruction } from "@atlaskit/pragmatic-drag-and-drop-hitbox/tree-item";
|
|
232
|
+
import { untracked } from "@preact/signals-core";
|
|
233
|
+
import React9, { memo as memo2, useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo5 } from "react";
|
|
234
|
+
import { createIntent as createIntent3, LayoutAction as LayoutAction3, Surface, useAppGraph as useAppGraph2, useCapability, useIntentDispatcher as useIntentDispatcher3, useLayout } from "@dxos/app-framework";
|
|
235
|
+
import { isAction as isAction4, isActionLike as isActionLike2, ROOT_ID } from "@dxos/app-graph";
|
|
236
|
+
import { PLANK_COMPANION_TYPE } from "@dxos/plugin-deck/types";
|
|
237
|
+
import { useConnections } from "@dxos/plugin-graph";
|
|
238
|
+
import { isEchoObject, isSpace } from "@dxos/react-client/echo";
|
|
239
|
+
import { useMediaQuery as useMediaQuery2, useSidebars } from "@dxos/react-ui";
|
|
240
|
+
import { isTreeData } from "@dxos/react-ui-list";
|
|
241
|
+
import { mx as mx5 } from "@dxos/react-ui-theme";
|
|
242
|
+
import { arrayMove as arrayMove2, byPosition } from "@dxos/util";
|
|
243
|
+
|
|
244
|
+
// packages/plugins/plugin-navtree/src/components/NavTree/NavTree.tsx
|
|
245
|
+
import { useSignals as _useSignals8 } from "@preact-signals/safe-react/tracking";
|
|
246
|
+
import React8, { useMemo as useMemo4 } from "react";
|
|
247
|
+
import { Tabs as Tabs3 } from "@dxos/react-ui-tabs";
|
|
248
|
+
|
|
249
|
+
// packages/plugins/plugin-navtree/src/hooks.ts
|
|
250
|
+
import { useEffect as useEffect2 } from "react";
|
|
251
|
+
|
|
252
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeContext.tsx
|
|
253
|
+
import { createContext, useContext } from "react";
|
|
254
|
+
import { raise } from "@dxos/debug";
|
|
255
|
+
var NavTreeContext = /* @__PURE__ */ createContext(null);
|
|
256
|
+
var useNavTreeContext = () => useContext(NavTreeContext) ?? raise(new Error("Missing NavTreeContext"));
|
|
257
|
+
|
|
258
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeDocumentTitle.tsx
|
|
259
|
+
import { useEffect } from "react";
|
|
260
|
+
import { toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
261
|
+
var NavTreeDocumentTitle = ({ node }) => {
|
|
262
|
+
const { t } = useTranslation3(NAVTREE_PLUGIN);
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
document.title = node ? toLocalizedString2(node.properties.label, t) : t("current app name", {
|
|
265
|
+
ns: "appkit"
|
|
266
|
+
});
|
|
267
|
+
}, [
|
|
268
|
+
node?.properties?.label
|
|
269
|
+
]);
|
|
270
|
+
return null;
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
// packages/plugins/plugin-navtree/src/hooks.ts
|
|
274
|
+
var useLoadDescendents = (root) => {
|
|
275
|
+
const { loadDescendents } = useNavTreeContext();
|
|
276
|
+
useEffect2(() => {
|
|
277
|
+
const frame = requestAnimationFrame(() => {
|
|
278
|
+
if (root) {
|
|
279
|
+
void loadDescendents?.(root);
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
return () => cancelAnimationFrame(frame);
|
|
283
|
+
}, [
|
|
284
|
+
root
|
|
285
|
+
]);
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L0Menu.tsx
|
|
289
|
+
import { useSignals as _useSignals4 } from "@preact-signals/safe-react/tracking";
|
|
290
|
+
import { combine } from "@atlaskit/pragmatic-drag-and-drop/combine";
|
|
291
|
+
import { draggable, dropTargetForElements } from "@atlaskit/pragmatic-drag-and-drop/element/adapter";
|
|
292
|
+
import { preserveOffsetOnSource } from "@atlaskit/pragmatic-drag-and-drop/element/preserve-offset-on-source";
|
|
293
|
+
import { scrollJustEnoughIntoView } from "@atlaskit/pragmatic-drag-and-drop/element/scroll-just-enough-into-view";
|
|
294
|
+
import { attachClosestEdge, extractClosestEdge } from "@atlaskit/pragmatic-drag-and-drop-hitbox/closest-edge";
|
|
295
|
+
import React4, { forwardRef, useCallback, useLayoutEffect, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
296
|
+
import { invariant } from "@dxos/invariant";
|
|
297
|
+
import { Icon as Icon2, IconButton, ListItem, ScrollArea, Tooltip, toLocalizedString as toLocalizedString3, useMediaQuery, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
298
|
+
import { MenuProvider, DropdownMenu } from "@dxos/react-ui-menu";
|
|
299
|
+
import { Tabs } from "@dxos/react-ui-tabs";
|
|
300
|
+
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
301
|
+
import { arrayMove, getFirstTwoRenderableChars } from "@dxos/util";
|
|
302
|
+
|
|
303
|
+
// packages/plugins/plugin-navtree/src/components/UserAccountAvatar/UserAccountAvatar.tsx
|
|
304
|
+
import { useSignals as _useSignals3 } from "@preact-signals/safe-react/tracking";
|
|
305
|
+
import React3 from "react";
|
|
306
|
+
import { Avatar } from "@dxos/react-ui";
|
|
307
|
+
import { hexToFallback } from "@dxos/util";
|
|
308
|
+
var UserAccountAvatar = ({ size, userId, hue, emoji, status }) => {
|
|
309
|
+
var _effect = _useSignals3();
|
|
310
|
+
try {
|
|
311
|
+
const fallbackValue = hexToFallback(userId ?? "0");
|
|
312
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
313
|
+
className: "grid place-items-center",
|
|
314
|
+
"data-joyride": "welcome/account"
|
|
315
|
+
}, /* @__PURE__ */ React3.createElement(Avatar.Root, null, /* @__PURE__ */ React3.createElement(Avatar.Content, {
|
|
316
|
+
variant: "circle",
|
|
317
|
+
size: size ?? 12,
|
|
318
|
+
status: status ?? "active",
|
|
319
|
+
hue: hue || fallbackValue.hue,
|
|
320
|
+
fallback: emoji || fallbackValue.emoji,
|
|
321
|
+
"data-testid": "treeView.userAccount"
|
|
322
|
+
})));
|
|
323
|
+
} finally {
|
|
324
|
+
_effect.f();
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L0Menu.tsx
|
|
329
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/plugins/plugin-navtree/src/components/Sidebar/L0Menu.tsx";
|
|
330
|
+
var useL0ItemClick = ({ item, parent, path }, type) => {
|
|
331
|
+
const { tab, isCurrent, onSelect, onTabChange } = useNavTreeContext();
|
|
332
|
+
const [isLg] = useMediaQuery("lg", {
|
|
333
|
+
ssr: false
|
|
334
|
+
});
|
|
335
|
+
return useCallback((event) => {
|
|
336
|
+
switch (type) {
|
|
337
|
+
case "action": {
|
|
338
|
+
const { data: invoke, properties: { caller } } = item;
|
|
339
|
+
return invoke?.(caller ? {
|
|
340
|
+
node: parent,
|
|
341
|
+
caller
|
|
342
|
+
} : {
|
|
343
|
+
node: parent
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
case "tab":
|
|
347
|
+
return onTabChange?.(item);
|
|
348
|
+
case "link":
|
|
349
|
+
return onSelect?.({
|
|
350
|
+
item,
|
|
351
|
+
path,
|
|
352
|
+
current: !isCurrent(path, item),
|
|
353
|
+
option: event.altKey
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
}, [
|
|
357
|
+
item,
|
|
358
|
+
parent,
|
|
359
|
+
type,
|
|
360
|
+
tab,
|
|
361
|
+
isCurrent,
|
|
362
|
+
onSelect,
|
|
363
|
+
onTabChange,
|
|
364
|
+
isLg
|
|
365
|
+
]);
|
|
366
|
+
};
|
|
367
|
+
var l0Breakpoints = {
|
|
368
|
+
lg: "hidden lg:grid"
|
|
369
|
+
};
|
|
370
|
+
var L0ItemRoot = /* @__PURE__ */ forwardRef(({ item, parent, path, children }, forwardedRef) => {
|
|
371
|
+
var _effect = _useSignals4();
|
|
372
|
+
try {
|
|
373
|
+
const { getProps } = useNavTreeContext();
|
|
374
|
+
const { id, testId } = getProps?.(item, path) ?? {};
|
|
375
|
+
const type = l0ItemType(item);
|
|
376
|
+
const itemPath = useMemo2(() => [
|
|
377
|
+
...path,
|
|
378
|
+
item.id
|
|
379
|
+
], [
|
|
380
|
+
item.id,
|
|
381
|
+
path
|
|
382
|
+
]);
|
|
383
|
+
const { t } = useTranslation4(NAVTREE_PLUGIN);
|
|
384
|
+
const localizedString = toLocalizedString3(item.properties.label, t);
|
|
385
|
+
const handleClick = useL0ItemClick({
|
|
386
|
+
item,
|
|
387
|
+
parent,
|
|
388
|
+
path: itemPath
|
|
389
|
+
}, type);
|
|
390
|
+
const rootProps = type === "tab" ? {
|
|
391
|
+
value: item.id,
|
|
392
|
+
tabIndex: 0,
|
|
393
|
+
onClick: handleClick,
|
|
394
|
+
"data-testid": testId,
|
|
395
|
+
"data-itemid": id
|
|
396
|
+
} : type !== "collection" ? {
|
|
397
|
+
onClick: handleClick,
|
|
398
|
+
"data-testid": testId,
|
|
399
|
+
"data-itemid": id
|
|
400
|
+
} : {
|
|
401
|
+
onClick: handleClick
|
|
402
|
+
};
|
|
403
|
+
const Root = type === "collection" ? "h2" : type === "tab" ? Tabs.TabPrimitive : "button";
|
|
404
|
+
return /* @__PURE__ */ React4.createElement(Tooltip.Trigger, {
|
|
405
|
+
asChild: true,
|
|
406
|
+
delayDuration: 0,
|
|
407
|
+
side: "right",
|
|
408
|
+
content: localizedString
|
|
409
|
+
}, /* @__PURE__ */ React4.createElement(Root, {
|
|
410
|
+
...rootProps,
|
|
411
|
+
"data-type": type,
|
|
412
|
+
className: mx2('group/l0item flex w-full justify-center items-center relative data[type!="collection"]:cursor-pointer app-no-drag dx-focus-ring-group', l0Breakpoints[item.properties.l0Breakpoint]),
|
|
413
|
+
ref: forwardedRef
|
|
414
|
+
}, children));
|
|
415
|
+
} finally {
|
|
416
|
+
_effect.f();
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
var L0Avator = ({ item }) => {
|
|
420
|
+
var _effect = _useSignals4();
|
|
421
|
+
try {
|
|
422
|
+
const { t } = useTranslation4(NAVTREE_PLUGIN);
|
|
423
|
+
const type = l0ItemType(item);
|
|
424
|
+
const hue = item.properties.hue ?? null;
|
|
425
|
+
const hueFgStyle = hue && {
|
|
426
|
+
style: {
|
|
427
|
+
color: `var(--dx-${hue}SurfaceText)`
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
const localizedString = toLocalizedString3(item.properties.label, t);
|
|
431
|
+
const avatarValue = useMemo2(() => type === "tab" ? getFirstTwoRenderableChars(localizedString).join("").toUpperCase() : [], [
|
|
432
|
+
type,
|
|
433
|
+
item.properties.label,
|
|
434
|
+
t
|
|
435
|
+
]);
|
|
436
|
+
return /* @__PURE__ */ React4.createElement("span", {
|
|
437
|
+
role: "img",
|
|
438
|
+
className: "place-self-center text-xl font-light",
|
|
439
|
+
...hueFgStyle
|
|
440
|
+
}, avatarValue);
|
|
441
|
+
} finally {
|
|
442
|
+
_effect.f();
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
var L0Item = ({ item, parent, path, pinned, onRearrange }) => {
|
|
446
|
+
var _effect = _useSignals4();
|
|
447
|
+
try {
|
|
448
|
+
const { t } = useTranslation4(NAVTREE_PLUGIN);
|
|
449
|
+
const itemElement = useRef(null);
|
|
450
|
+
const [closestEdge, setEdge] = useState2(null);
|
|
451
|
+
const type = l0ItemType(item);
|
|
452
|
+
const localizedString = toLocalizedString3(item.properties.label, t);
|
|
453
|
+
const hue = item.properties.hue ?? null;
|
|
454
|
+
const hueFgStyle = hue && {
|
|
455
|
+
style: {
|
|
456
|
+
color: `var(--dx-${hue}SurfaceText)`
|
|
457
|
+
}
|
|
458
|
+
};
|
|
459
|
+
useLayoutEffect(() => {
|
|
460
|
+
if (!itemElement.current || !onRearrange) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
return combine(draggable({
|
|
464
|
+
element: itemElement.current,
|
|
465
|
+
getInitialData: () => ({
|
|
466
|
+
id: item.id,
|
|
467
|
+
type: "l0Item"
|
|
468
|
+
}),
|
|
469
|
+
onGenerateDragPreview: ({ nativeSetDragImage, source, location }) => {
|
|
470
|
+
document.body.setAttribute("data-drag-preview", "true");
|
|
471
|
+
const element = source.element.querySelector("[data-frame]");
|
|
472
|
+
scrollJustEnoughIntoView({
|
|
473
|
+
element
|
|
474
|
+
});
|
|
475
|
+
const { x, y } = preserveOffsetOnSource({
|
|
476
|
+
element,
|
|
477
|
+
input: location.current.input
|
|
478
|
+
})({
|
|
479
|
+
container: element.offsetParent ?? document.body
|
|
480
|
+
});
|
|
481
|
+
nativeSetDragImage?.(element, x, y);
|
|
482
|
+
},
|
|
483
|
+
onDragStart: () => {
|
|
484
|
+
document.body.removeAttribute("data-drag-preview");
|
|
485
|
+
itemElement.current.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "active");
|
|
486
|
+
},
|
|
487
|
+
onDrop: () => {
|
|
488
|
+
itemElement.current.closest("[data-drag-autoscroll]")?.setAttribute("data-drag-autoscroll", "idle");
|
|
489
|
+
}
|
|
490
|
+
}), dropTargetForElements({
|
|
491
|
+
element: itemElement.current,
|
|
492
|
+
getData: ({ input, element }) => {
|
|
493
|
+
return attachClosestEdge({
|
|
494
|
+
id: item.id,
|
|
495
|
+
type: "l0Item"
|
|
496
|
+
}, {
|
|
497
|
+
input,
|
|
498
|
+
element,
|
|
499
|
+
allowedEdges: [
|
|
500
|
+
"top",
|
|
501
|
+
"bottom"
|
|
502
|
+
]
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
onDragEnter: ({ self, source }) => {
|
|
506
|
+
if (source.data.type === self.data.type) {
|
|
507
|
+
setEdge(extractClosestEdge(self.data));
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
onDrag: ({ self, source }) => {
|
|
511
|
+
if (source.data.type === self.data.type) {
|
|
512
|
+
setEdge(extractClosestEdge(self.data));
|
|
513
|
+
}
|
|
514
|
+
},
|
|
515
|
+
onDragLeave: () => setEdge(null),
|
|
516
|
+
onDrop: ({ self, source }) => {
|
|
517
|
+
setEdge(null);
|
|
518
|
+
if (source.data.type === self.data.type) {
|
|
519
|
+
onRearrange(source.data, self.data, extractClosestEdge(self.data));
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}));
|
|
523
|
+
}, [
|
|
524
|
+
item,
|
|
525
|
+
onRearrange
|
|
526
|
+
]);
|
|
527
|
+
return /* @__PURE__ */ React4.createElement(L0ItemRoot, {
|
|
528
|
+
ref: itemElement,
|
|
529
|
+
item,
|
|
530
|
+
parent,
|
|
531
|
+
path
|
|
532
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
533
|
+
role: "none",
|
|
534
|
+
"data-frame": true,
|
|
535
|
+
className: mx2(
|
|
536
|
+
"flex justify-center items-center dx-focus-ring-group-indicator transition-colors rounded",
|
|
537
|
+
// TODO(burdon): Create reusable button/component and/or create var for size.
|
|
538
|
+
pinned ? "bg-transparent w-[50px] p-2 group-hover/l0item:bg-activeSurface" : "bg-activeSurface w-[50px] h-[50px]"
|
|
539
|
+
),
|
|
540
|
+
...hue && {
|
|
541
|
+
style: {
|
|
542
|
+
background: `var(--dx-${hue}Surface)`
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}, item.properties.icon && /* @__PURE__ */ React4.createElement(Icon2, {
|
|
546
|
+
icon: item.properties.icon,
|
|
547
|
+
size: pinned ? 5 : 6,
|
|
548
|
+
...hueFgStyle
|
|
549
|
+
}) || type === "tab" && item.properties.disposition !== "pin-end" && /* @__PURE__ */ React4.createElement(L0Avator, {
|
|
550
|
+
item
|
|
551
|
+
})), /* @__PURE__ */ React4.createElement("div", {
|
|
552
|
+
role: "none",
|
|
553
|
+
className: "hidden group-aria-selected/l0item:block absolute inline-start-0 inset-block-4 is-1 bg-accentSurface rounded-ie"
|
|
554
|
+
}), /* @__PURE__ */ React4.createElement("span", {
|
|
555
|
+
id: `${item.id}__label`,
|
|
556
|
+
className: "sr-only"
|
|
557
|
+
}, localizedString), onRearrange && closestEdge && /* @__PURE__ */ React4.createElement(ListItem.DropIndicator, {
|
|
558
|
+
edge: closestEdge
|
|
559
|
+
}));
|
|
560
|
+
} finally {
|
|
561
|
+
_effect.f();
|
|
562
|
+
}
|
|
563
|
+
};
|
|
564
|
+
var L0Collection = ({ item, path }) => {
|
|
565
|
+
var _effect = _useSignals4();
|
|
566
|
+
try {
|
|
567
|
+
const navTreeContext = useNavTreeContext();
|
|
568
|
+
useLoadDescendents(item);
|
|
569
|
+
const collectionItems = navTreeContext.useItems(item);
|
|
570
|
+
const groupPath = useMemo2(() => [
|
|
571
|
+
...path,
|
|
572
|
+
item.id
|
|
573
|
+
], [
|
|
574
|
+
item.id,
|
|
575
|
+
path
|
|
576
|
+
]);
|
|
577
|
+
const { id, testId } = navTreeContext.getProps?.(item, path) ?? {};
|
|
578
|
+
const handleRearrange = useCallback((source, target, closestEdge) => {
|
|
579
|
+
invariant(item.properties.onRearrangeChildren, void 0, {
|
|
580
|
+
F: __dxlog_file,
|
|
581
|
+
L: 266,
|
|
582
|
+
S: void 0,
|
|
583
|
+
A: [
|
|
584
|
+
"item.properties.onRearrangeChildren",
|
|
585
|
+
""
|
|
586
|
+
]
|
|
587
|
+
});
|
|
588
|
+
const sourceIndex = collectionItems.findIndex((i) => i.id === source.id);
|
|
589
|
+
const targetIndex = collectionItems.findIndex((i) => i.id === target.id);
|
|
590
|
+
const insertIndex = source.id === target.id ? sourceIndex : targetIndex + (sourceIndex < targetIndex ? closestEdge === "top" ? -1 : 0 : closestEdge === "bottom" ? 1 : 0);
|
|
591
|
+
const nextOrder = arrayMove([
|
|
592
|
+
...collectionItems
|
|
593
|
+
], sourceIndex, insertIndex);
|
|
594
|
+
return item.properties.onRearrangeChildren(nextOrder);
|
|
595
|
+
}, [
|
|
596
|
+
collectionItems,
|
|
597
|
+
item.properties.onRearrangeChildren
|
|
598
|
+
]);
|
|
599
|
+
return /* @__PURE__ */ React4.createElement("div", {
|
|
600
|
+
role: "group",
|
|
601
|
+
className: "contents group/l0c",
|
|
602
|
+
"aria-labelledby": `${item.id}__label`,
|
|
603
|
+
"data-itemid": id,
|
|
604
|
+
"data-testid": testId
|
|
605
|
+
}, collectionItems.map((collectionItem) => /* @__PURE__ */ React4.createElement(L0Item, {
|
|
606
|
+
key: collectionItem.id,
|
|
607
|
+
item: collectionItem,
|
|
608
|
+
parent: item,
|
|
609
|
+
path: groupPath,
|
|
610
|
+
...item.properties.onRearrangeChildren && {
|
|
611
|
+
onRearrange: handleRearrange
|
|
612
|
+
}
|
|
613
|
+
})));
|
|
614
|
+
} finally {
|
|
615
|
+
_effect.f();
|
|
616
|
+
}
|
|
617
|
+
};
|
|
618
|
+
var L0Menu = ({ menuActions, topLevelItems, pinnedItems, userAccountItem, parent, path }) => {
|
|
619
|
+
var _effect = _useSignals4();
|
|
620
|
+
try {
|
|
621
|
+
const { t } = useTranslation4(NAVTREE_PLUGIN);
|
|
622
|
+
return /* @__PURE__ */ React4.createElement(Tabs.Tablist, {
|
|
623
|
+
classNames: [
|
|
624
|
+
"group/l0 absolute z-[1] inset-block-0 inline-start-0 rounded-is-lg",
|
|
625
|
+
"grid grid-cols-[var(--l0-size)] grid-rows-[var(--rail-size)_1fr_min-content_var(--l0-size)] gap-1 contain-layout",
|
|
626
|
+
"!is-[--l0-size] bg-baseSurface border-ie border-subduedSeparator app-drag pbe-[env(safe-area-inset-bottom)]"
|
|
627
|
+
]
|
|
628
|
+
}, /* @__PURE__ */ React4.createElement("div", {
|
|
629
|
+
role: "none",
|
|
630
|
+
className: "flex justify-center p-1"
|
|
631
|
+
}, /* @__PURE__ */ React4.createElement(MenuProvider, null, /* @__PURE__ */ React4.createElement(DropdownMenu.Root, {
|
|
632
|
+
group: parent,
|
|
633
|
+
items: menuActions
|
|
634
|
+
}, /* @__PURE__ */ React4.createElement(DropdownMenu.Trigger, {
|
|
635
|
+
asChild: true
|
|
636
|
+
}, /* @__PURE__ */ React4.createElement(IconButton, {
|
|
637
|
+
iconOnly: true,
|
|
638
|
+
icon: "ph--dots-three--regular",
|
|
639
|
+
size: 5,
|
|
640
|
+
label: t("app menu label"),
|
|
641
|
+
tooltipSide: "right",
|
|
642
|
+
classNames: "w-[50px] _bg-primary-500",
|
|
643
|
+
"data-testid": "spacePlugin.addSpace"
|
|
644
|
+
}))))), /* @__PURE__ */ React4.createElement(ScrollArea.Root, null, /* @__PURE__ */ React4.createElement(ScrollArea.Viewport, null, /* @__PURE__ */ React4.createElement("div", {
|
|
645
|
+
role: "none",
|
|
646
|
+
className: mx2([
|
|
647
|
+
"flex flex-col gap-2 pbs-1",
|
|
648
|
+
'[body[data-platform="darwin"]_&]:pbs-[calc(30px+0.25rem)]',
|
|
649
|
+
'[body[data-platform="ios"]_&]:pbs-[max(env(safe-area-inset-top),0.25rem)]'
|
|
650
|
+
])
|
|
651
|
+
}, topLevelItems.map((item) => {
|
|
652
|
+
if (l0ItemType(item) === "collection") {
|
|
653
|
+
return /* @__PURE__ */ React4.createElement(L0Collection, {
|
|
654
|
+
key: item.id,
|
|
655
|
+
item,
|
|
656
|
+
parent,
|
|
657
|
+
path
|
|
658
|
+
});
|
|
659
|
+
} else {
|
|
660
|
+
return /* @__PURE__ */ React4.createElement(L0Item, {
|
|
661
|
+
key: item.id,
|
|
662
|
+
item,
|
|
663
|
+
parent,
|
|
664
|
+
path
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
})), /* @__PURE__ */ React4.createElement(ScrollArea.Scrollbar, {
|
|
668
|
+
orientation: "vertical"
|
|
669
|
+
}, /* @__PURE__ */ React4.createElement(ScrollArea.Thumb, null)))), /* @__PURE__ */ React4.createElement("div", {
|
|
670
|
+
role: "none",
|
|
671
|
+
className: "grid grid-cols-1 auto-rows-[--rail-action] pbs-2"
|
|
672
|
+
}, pinnedItems.filter((item) => l0ItemType(item) !== "collection").map((item) => /* @__PURE__ */ React4.createElement(L0Item, {
|
|
673
|
+
key: item.id,
|
|
674
|
+
item,
|
|
675
|
+
parent,
|
|
676
|
+
path,
|
|
677
|
+
pinned: true
|
|
678
|
+
}))), userAccountItem && /* @__PURE__ */ React4.createElement("div", {
|
|
679
|
+
role: "none",
|
|
680
|
+
className: "grid app-no-drag"
|
|
681
|
+
}, /* @__PURE__ */ React4.createElement(L0ItemRoot, {
|
|
682
|
+
key: userAccountItem.id,
|
|
683
|
+
item: userAccountItem,
|
|
684
|
+
parent,
|
|
685
|
+
path
|
|
686
|
+
}, /* @__PURE__ */ React4.createElement(UserAccountAvatar, {
|
|
687
|
+
userId: userAccountItem.properties.userId,
|
|
688
|
+
hue: userAccountItem.properties.hue,
|
|
689
|
+
emoji: userAccountItem.properties.emoji,
|
|
690
|
+
status: userAccountItem.properties.status,
|
|
691
|
+
size: 11
|
|
692
|
+
}))), /* @__PURE__ */ React4.createElement("div", {
|
|
693
|
+
role: "none",
|
|
694
|
+
className: 'hidden [body[data-platform="darwin"]_&]:block absolute block-start-0 is-[calc(var(--l0-size)-1px)] bs-[calc(40px+0.25rem)]',
|
|
695
|
+
style: {
|
|
696
|
+
background: "linear-gradient(to bottom, var(--dx-sidebarSurface) 0%, var(--dx-sidebarSurface) 70%, transparent 100%)"
|
|
697
|
+
}
|
|
698
|
+
}));
|
|
699
|
+
} finally {
|
|
700
|
+
_effect.f();
|
|
701
|
+
}
|
|
702
|
+
};
|
|
703
|
+
|
|
704
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L1Panel.tsx
|
|
705
|
+
import { useSignals as _useSignals7 } from "@preact-signals/safe-react/tracking";
|
|
706
|
+
import React7, { useCallback as useCallback2, useMemo as useMemo3 } from "react";
|
|
707
|
+
import { Button as Button3, Icon as Icon3, IconButton as IconButton3, toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
708
|
+
import { Tree } from "@dxos/react-ui-list";
|
|
709
|
+
import { Tabs as Tabs2 } from "@dxos/react-ui-tabs";
|
|
710
|
+
import { hoverableControlItem as hoverableControlItem2, hoverableOpenControlItem as hoverableOpenControlItem2, mx as mx4 } from "@dxos/react-ui-theme";
|
|
711
|
+
|
|
712
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeItem/NavTreeItemAction.tsx
|
|
713
|
+
import { useSignals as _useSignals5 } from "@preact-signals/safe-react/tracking";
|
|
714
|
+
import React5 from "react";
|
|
715
|
+
import { useTranslation as useTranslation5, toLocalizedString as toLocalizedString4, IconButton as IconButton2, useDensityContext } from "@dxos/react-ui";
|
|
716
|
+
import { DropdownMenu as DropdownMenu2, MenuProvider as MenuProvider2 } from "@dxos/react-ui-menu";
|
|
717
|
+
import { hoverableControlItem, hoverableOpenControlItem, mx as mx3 } from "@dxos/react-ui-theme";
|
|
718
|
+
var fallbackIcon = "ph--placeholder--regular";
|
|
719
|
+
var fineActionButtonProps = {
|
|
720
|
+
size: 4,
|
|
721
|
+
density: "fine"
|
|
722
|
+
};
|
|
723
|
+
var coarseActionButtonProps = {
|
|
724
|
+
size: 5,
|
|
725
|
+
density: "coarse"
|
|
726
|
+
};
|
|
727
|
+
var NavTreeItemActionDropdownMenu = ({ parent, label, icon, testId, menuActions, caller }) => {
|
|
728
|
+
var _effect = _useSignals5();
|
|
729
|
+
try {
|
|
730
|
+
const { t } = useTranslation5(NAVTREE_PLUGIN);
|
|
731
|
+
const density = useDensityContext();
|
|
732
|
+
return /* @__PURE__ */ React5.createElement(MenuProvider2, null, /* @__PURE__ */ React5.createElement(DropdownMenu2.Root, {
|
|
733
|
+
group: parent,
|
|
734
|
+
items: menuActions,
|
|
735
|
+
caller
|
|
736
|
+
}, /* @__PURE__ */ React5.createElement(DropdownMenu2.Trigger, {
|
|
737
|
+
asChild: true
|
|
738
|
+
}, /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
739
|
+
...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
|
|
740
|
+
classNames: mx3("shrink-0 pli-2 pointer-fine:pli-1", hoverableControlItem, hoverableOpenControlItem),
|
|
741
|
+
variant: "ghost",
|
|
742
|
+
icon: icon ?? fallbackIcon,
|
|
743
|
+
iconOnly: true,
|
|
744
|
+
label: toLocalizedString4(label, t),
|
|
745
|
+
"data-testid": testId
|
|
746
|
+
}))));
|
|
747
|
+
} finally {
|
|
748
|
+
_effect.f();
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
var NavTreeItemMonolithicAction = ({ parent, properties: { disabled, caller, testId, icon, variant = "ghost", iconOnly = true } = {
|
|
752
|
+
label: "never"
|
|
753
|
+
}, data: invoke, baseLabel }) => {
|
|
754
|
+
var _effect = _useSignals5();
|
|
755
|
+
try {
|
|
756
|
+
const density = useDensityContext();
|
|
757
|
+
return /* @__PURE__ */ React5.createElement(IconButton2, {
|
|
758
|
+
...density === "coarse" ? coarseActionButtonProps : fineActionButtonProps,
|
|
759
|
+
variant,
|
|
760
|
+
classNames: mx3("shrink-0", hoverableControlItem, hoverableOpenControlItem, iconOnly ? "pli-2 pointer-fine:pli-1" : "p-2 pointer-fine:p-2 mie-1"),
|
|
761
|
+
icon: icon ?? fallbackIcon,
|
|
762
|
+
iconOnly,
|
|
763
|
+
label: baseLabel,
|
|
764
|
+
disabled,
|
|
765
|
+
onClick: (event) => {
|
|
766
|
+
if (disabled) {
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
event.stopPropagation();
|
|
770
|
+
void invoke?.(caller ? {
|
|
771
|
+
parent,
|
|
772
|
+
caller
|
|
773
|
+
} : {
|
|
774
|
+
parent
|
|
775
|
+
});
|
|
776
|
+
},
|
|
777
|
+
"data-testid": testId
|
|
778
|
+
});
|
|
779
|
+
} finally {
|
|
780
|
+
_effect.f();
|
|
781
|
+
}
|
|
782
|
+
};
|
|
783
|
+
var NavTreeItemAction = ({ monolithic, menuActions, parent: node, ...props }) => {
|
|
784
|
+
var _effect = _useSignals5();
|
|
785
|
+
try {
|
|
786
|
+
const { t } = useTranslation5(NAVTREE_PLUGIN);
|
|
787
|
+
const monolithicAction = menuActions?.length === 1 && menuActions[0];
|
|
788
|
+
const baseLabel = toLocalizedString4(monolithicAction ? monolithicAction.properties.label : props.label, t);
|
|
789
|
+
return monolithic && menuActions?.length === 1 ? /* @__PURE__ */ React5.createElement(NavTreeItemMonolithicAction, {
|
|
790
|
+
baseLabel,
|
|
791
|
+
parent: node,
|
|
792
|
+
...menuActions[0]
|
|
793
|
+
}) : /* @__PURE__ */ React5.createElement(NavTreeItemActionDropdownMenu, {
|
|
794
|
+
...props,
|
|
795
|
+
label: baseLabel,
|
|
796
|
+
parent: node,
|
|
797
|
+
menuActions
|
|
798
|
+
});
|
|
799
|
+
} finally {
|
|
800
|
+
_effect.f();
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
804
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeItem/NavTreeItemColumns.tsx
|
|
805
|
+
import { useSignals as _useSignals6 } from "@preact-signals/safe-react/tracking";
|
|
806
|
+
import React6, { Fragment, memo } from "react";
|
|
807
|
+
import { isAction as isAction3 } from "@dxos/app-graph";
|
|
808
|
+
import { DensityProvider, Popover, toLocalizedString as toLocalizedString5, Treegrid, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
809
|
+
var NavTreeItemColumns = /* @__PURE__ */ memo(({ path, item, open, density = "fine" }) => {
|
|
810
|
+
var _effect = _useSignals6();
|
|
811
|
+
try {
|
|
812
|
+
const { t } = useTranslation6(NAVTREE_PLUGIN);
|
|
813
|
+
const { getActions: getActions2, renderItemEnd: ItemEnd, popoverAnchorId } = useNavTreeContext();
|
|
814
|
+
const level = path.length - 2;
|
|
815
|
+
const { actions: _actions, groupedActions } = getActions2(item);
|
|
816
|
+
const [primaryAction, ...secondaryActions] = _actions.toSorted((a, b) => a.properties?.disposition === "list-item-primary" ? -1 : 1);
|
|
817
|
+
const actions = (primaryAction?.properties?.disposition === "list-item-primary" ? secondaryActions : _actions).flatMap((action) => isAction3(action) ? [
|
|
818
|
+
action
|
|
819
|
+
] : []).filter((action) => !action.properties?.hidden);
|
|
820
|
+
const ActionRoot = popoverAnchorId === `dxos.org/ui/${NAV_TREE_ITEM}/${item.id}` ? Popover.Anchor : Fragment;
|
|
821
|
+
useLoadDescendents(item);
|
|
822
|
+
useLoadDescendents(primaryAction && !isAction3(primaryAction) ? primaryAction : void 0);
|
|
823
|
+
return /* @__PURE__ */ React6.createElement(DensityProvider, {
|
|
824
|
+
density
|
|
825
|
+
}, /* @__PURE__ */ React6.createElement("div", {
|
|
826
|
+
role: "none",
|
|
827
|
+
className: "contents app-no-drag"
|
|
828
|
+
}, primaryAction?.properties?.disposition === "list-item-primary" && !primaryAction?.properties?.disabled ? /* @__PURE__ */ React6.createElement(NavTreeItemAction, {
|
|
829
|
+
testId: primaryAction.properties?.testId,
|
|
830
|
+
label: toLocalizedString5(primaryAction.properties?.label, t),
|
|
831
|
+
icon: primaryAction.properties?.icon ?? "ph--placeholder--regular",
|
|
832
|
+
parent: item,
|
|
833
|
+
monolithic: isAction3(primaryAction),
|
|
834
|
+
menuActions: isAction3(primaryAction) ? [
|
|
835
|
+
primaryAction
|
|
836
|
+
] : groupedActions[primaryAction.id],
|
|
837
|
+
menuType: primaryAction.properties?.menuType,
|
|
838
|
+
caller: NAV_TREE_ITEM
|
|
839
|
+
}) : /* @__PURE__ */ React6.createElement(Treegrid.Cell, null), /* @__PURE__ */ React6.createElement(ActionRoot, null, actions.length > 0 ? /* @__PURE__ */ React6.createElement(NavTreeItemAction, {
|
|
840
|
+
testId: `navtree.treeItem.actionsLevel${level}`,
|
|
841
|
+
label: t("tree item actions label"),
|
|
842
|
+
icon: "ph--dots-three-vertical--regular",
|
|
843
|
+
parent: item,
|
|
844
|
+
menuActions: actions,
|
|
845
|
+
menuType: "dropdown",
|
|
846
|
+
caller: NAV_TREE_ITEM
|
|
847
|
+
}) : /* @__PURE__ */ React6.createElement(Treegrid.Cell, null)), ItemEnd && /* @__PURE__ */ React6.createElement(ItemEnd, {
|
|
848
|
+
node: item,
|
|
849
|
+
open
|
|
850
|
+
})));
|
|
851
|
+
} finally {
|
|
852
|
+
_effect.f();
|
|
853
|
+
}
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
// packages/plugins/plugin-navtree/src/components/Sidebar/L1Panel.tsx
|
|
857
|
+
var headingBackButtonLabel = "inset-0 min-is-0 truncate flex items-center pis-2";
|
|
858
|
+
var TitleButton = ({ title, onClick }) => {
|
|
859
|
+
var _effect = _useSignals7();
|
|
860
|
+
try {
|
|
861
|
+
return /* @__PURE__ */ React7.createElement(Button3, {
|
|
862
|
+
variant: "ghost",
|
|
863
|
+
classNames: "pli-1 flex-1 group text-start justify-start bs-[--rail-action] font-normal",
|
|
864
|
+
onClick
|
|
865
|
+
}, /* @__PURE__ */ React7.createElement(Icon3, {
|
|
866
|
+
icon: "ph--caret-left--bold",
|
|
867
|
+
size: 3
|
|
868
|
+
}), /* @__PURE__ */ React7.createElement("span", {
|
|
869
|
+
className: mx4(headingBackButtonLabel)
|
|
870
|
+
}, title));
|
|
871
|
+
} finally {
|
|
872
|
+
_effect.f();
|
|
873
|
+
}
|
|
874
|
+
};
|
|
875
|
+
var L1Panel = ({ open, item, path, currentItemId, onBack }) => {
|
|
876
|
+
var _effect = _useSignals7();
|
|
877
|
+
try {
|
|
878
|
+
const { isAlternateTree, setAlternateTree, ...navTreeContext } = useNavTreeContext();
|
|
879
|
+
const { t } = useTranslation7(NAVTREE_PLUGIN);
|
|
880
|
+
const alternateTree = navTreeContext.useItems(item, {
|
|
881
|
+
disposition: "alternate-tree"
|
|
882
|
+
})[0];
|
|
883
|
+
const alternatePath = useMemo3(() => [
|
|
884
|
+
...path,
|
|
885
|
+
item.id
|
|
886
|
+
], [
|
|
887
|
+
item.id,
|
|
888
|
+
path
|
|
889
|
+
]);
|
|
890
|
+
const handleOpen = useCallback2(() => setAlternateTree?.(alternatePath, true), [
|
|
891
|
+
alternatePath,
|
|
892
|
+
setAlternateTree
|
|
893
|
+
]);
|
|
894
|
+
const isAlternate = isAlternateTree?.(alternatePath, item) ?? false;
|
|
895
|
+
const useAlternateItems = useCallback2((node, { disposition } = {}) => {
|
|
896
|
+
return navTreeContext.useItems(node, {
|
|
897
|
+
disposition,
|
|
898
|
+
sort: node?.id === alternateTree.id
|
|
899
|
+
});
|
|
900
|
+
}, [
|
|
901
|
+
navTreeContext,
|
|
902
|
+
alternateTree
|
|
903
|
+
]);
|
|
904
|
+
const handleBack = useCallback2(() => {
|
|
905
|
+
if (isAlternate) {
|
|
906
|
+
setAlternateTree?.(alternatePath, false);
|
|
907
|
+
} else {
|
|
908
|
+
onBack?.();
|
|
909
|
+
}
|
|
910
|
+
}, [
|
|
911
|
+
isAlternate,
|
|
912
|
+
onBack,
|
|
913
|
+
alternatePath,
|
|
914
|
+
setAlternateTree
|
|
915
|
+
]);
|
|
916
|
+
const title = toLocalizedString6(item.properties.label, t);
|
|
917
|
+
const backCapable = item.id.startsWith("!") || isAlternate;
|
|
918
|
+
return /* @__PURE__ */ React7.createElement(Tabs2.Tabpanel, {
|
|
919
|
+
key: item.id,
|
|
920
|
+
value: item.id,
|
|
921
|
+
classNames: [
|
|
922
|
+
"absolute inset-block-0 inline-end-0",
|
|
923
|
+
"is-[calc(100%-var(--l0-size))] lg:is-[--l1-size] grid-cols-1 grid-rows-[var(--rail-size)_1fr]",
|
|
924
|
+
"pbs-[env(safe-area-inset-top)]",
|
|
925
|
+
item.id === currentItemId && "grid"
|
|
926
|
+
],
|
|
927
|
+
tabIndex: -1,
|
|
928
|
+
"aria-label": title,
|
|
929
|
+
...!open && {
|
|
930
|
+
inert: "true"
|
|
931
|
+
}
|
|
932
|
+
}, item.id === currentItemId && /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement("h2", {
|
|
933
|
+
className: "flex items-center border-be border-subduedSeparator app-drag pli-1"
|
|
934
|
+
}, backCapable ? /* @__PURE__ */ React7.createElement(TitleButton, {
|
|
935
|
+
title,
|
|
936
|
+
onClick: handleBack
|
|
937
|
+
}) : /* @__PURE__ */ React7.createElement("span", {
|
|
938
|
+
className: "flex-1 truncate min-is-0 pis-6"
|
|
939
|
+
}, title), alternateTree && !isAlternate && /* @__PURE__ */ React7.createElement(IconButton3, {
|
|
940
|
+
variant: "ghost",
|
|
941
|
+
classNames: mx4("shrink-0", hoverableControlItem2, hoverableOpenControlItem2, "pli-2 pointer-fine:pli-1"),
|
|
942
|
+
iconOnly: true,
|
|
943
|
+
size: 5,
|
|
944
|
+
density: "coarse",
|
|
945
|
+
icon: alternateTree.properties.icon ?? "ph--placeholder--regular",
|
|
946
|
+
label: toLocalizedString6(alternateTree.properties.label ?? alternateTree.id, t),
|
|
947
|
+
"data-testid": "treeView.alternateTreeButton",
|
|
948
|
+
onClick: handleOpen
|
|
949
|
+
}), /* @__PURE__ */ React7.createElement(NavTreeItemColumns, {
|
|
950
|
+
path,
|
|
951
|
+
item,
|
|
952
|
+
open: true,
|
|
953
|
+
density: "coarse"
|
|
954
|
+
})), /* @__PURE__ */ React7.createElement("div", {
|
|
955
|
+
role: "none",
|
|
956
|
+
className: "overflow-y-auto"
|
|
957
|
+
}, isAlternate ? /* @__PURE__ */ React7.createElement(Tree, {
|
|
958
|
+
...navTreeContext,
|
|
959
|
+
useItems: useAlternateItems,
|
|
960
|
+
id: alternateTree.id,
|
|
961
|
+
root: alternateTree,
|
|
962
|
+
path: alternatePath,
|
|
963
|
+
levelOffset: 5,
|
|
964
|
+
gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
|
|
965
|
+
renderColumns: NavTreeItemColumns
|
|
966
|
+
}) : /* @__PURE__ */ React7.createElement(Tree, {
|
|
967
|
+
...navTreeContext,
|
|
968
|
+
id: item.id,
|
|
969
|
+
root: item,
|
|
970
|
+
path,
|
|
971
|
+
levelOffset: 5,
|
|
972
|
+
draggable: true,
|
|
973
|
+
gridTemplateColumns: "[tree-row-start] 1fr min-content min-content min-content [tree-row-end]",
|
|
974
|
+
renderColumns: NavTreeItemColumns
|
|
975
|
+
}))));
|
|
976
|
+
} finally {
|
|
977
|
+
_effect.f();
|
|
978
|
+
}
|
|
979
|
+
};
|
|
980
|
+
var L1PanelCollection = ({ item, path, ...props }) => {
|
|
981
|
+
var _effect = _useSignals7();
|
|
982
|
+
try {
|
|
983
|
+
const { useItems: useItems2 } = useNavTreeContext();
|
|
984
|
+
useLoadDescendents(item);
|
|
985
|
+
const collectionItems = useItems2(item);
|
|
986
|
+
const groupPath = useMemo3(() => [
|
|
987
|
+
...path,
|
|
988
|
+
item.id
|
|
989
|
+
], [
|
|
990
|
+
item.id,
|
|
991
|
+
path
|
|
992
|
+
]);
|
|
993
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, collectionItems.filter((item2) => l0ItemType(item2) === "tab").map((item2) => /* @__PURE__ */ React7.createElement(L1Panel, {
|
|
994
|
+
key: item2.id,
|
|
995
|
+
item: item2,
|
|
996
|
+
path: groupPath,
|
|
997
|
+
...props
|
|
998
|
+
})));
|
|
999
|
+
} finally {
|
|
1000
|
+
_effect.f();
|
|
1001
|
+
}
|
|
1002
|
+
};
|
|
1003
|
+
var L1Panels = ({ topLevelItems, onBack, ...props }) => {
|
|
1004
|
+
var _effect = _useSignals7();
|
|
1005
|
+
try {
|
|
1006
|
+
return /* @__PURE__ */ React7.createElement(React7.Fragment, null, topLevelItems.map((item) => {
|
|
1007
|
+
const type = l0ItemType(item);
|
|
1008
|
+
switch (type) {
|
|
1009
|
+
case "collection":
|
|
1010
|
+
return /* @__PURE__ */ React7.createElement(L1PanelCollection, {
|
|
1011
|
+
key: item.id,
|
|
1012
|
+
item,
|
|
1013
|
+
...props
|
|
1014
|
+
});
|
|
1015
|
+
case "tab":
|
|
1016
|
+
return /* @__PURE__ */ React7.createElement(L1Panel, {
|
|
1017
|
+
key: item.id,
|
|
1018
|
+
item,
|
|
1019
|
+
...props,
|
|
1020
|
+
onBack
|
|
1021
|
+
});
|
|
1022
|
+
default:
|
|
1023
|
+
return null;
|
|
1024
|
+
}
|
|
1025
|
+
}));
|
|
1026
|
+
} finally {
|
|
1027
|
+
_effect.f();
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
// packages/plugins/plugin-navtree/src/components/NavTree/NavTree.tsx
|
|
1032
|
+
var NAV_TREE_ITEM = "NavTreeItem";
|
|
1033
|
+
var NavTree = ({ id, root, ...props }) => {
|
|
1034
|
+
var _effect = _useSignals8();
|
|
1035
|
+
try {
|
|
1036
|
+
const { tab, useItems: useItems2, onBack } = useNavTreeContext();
|
|
1037
|
+
const topLevelActions = useItems2(root, {
|
|
1038
|
+
disposition: "menu",
|
|
1039
|
+
sort: true
|
|
1040
|
+
});
|
|
1041
|
+
const topLevelCollections = useItems2(root, {
|
|
1042
|
+
disposition: "collection"
|
|
1043
|
+
});
|
|
1044
|
+
const topLevelWorkspaces = useItems2(root, {
|
|
1045
|
+
disposition: "workspace"
|
|
1046
|
+
});
|
|
1047
|
+
const topLevelNavigation = useItems2(root, {
|
|
1048
|
+
disposition: "navigation"
|
|
1049
|
+
});
|
|
1050
|
+
const l0Items = useMemo4(() => [
|
|
1051
|
+
// prettier-ignore
|
|
1052
|
+
...topLevelCollections,
|
|
1053
|
+
...topLevelWorkspaces,
|
|
1054
|
+
...topLevelNavigation
|
|
1055
|
+
], [
|
|
1056
|
+
topLevelCollections,
|
|
1057
|
+
topLevelWorkspaces,
|
|
1058
|
+
topLevelNavigation
|
|
1059
|
+
]);
|
|
1060
|
+
const pinnedItems = useItems2(root, {
|
|
1061
|
+
disposition: "pin-end",
|
|
1062
|
+
sort: true
|
|
1063
|
+
});
|
|
1064
|
+
const userAccountItem = useItems2(root, {
|
|
1065
|
+
disposition: "user-account"
|
|
1066
|
+
})[0];
|
|
1067
|
+
const topLevelItems = useMemo4(() => [
|
|
1068
|
+
// prettier-ignore
|
|
1069
|
+
...l0Items,
|
|
1070
|
+
...pinnedItems,
|
|
1071
|
+
...userAccountItem ? [
|
|
1072
|
+
userAccountItem
|
|
1073
|
+
] : []
|
|
1074
|
+
], [
|
|
1075
|
+
l0Items,
|
|
1076
|
+
pinnedItems,
|
|
1077
|
+
userAccountItem
|
|
1078
|
+
]);
|
|
1079
|
+
useLoadDescendents(root);
|
|
1080
|
+
const path = useMemo4(() => [
|
|
1081
|
+
id
|
|
1082
|
+
], [
|
|
1083
|
+
id
|
|
1084
|
+
]);
|
|
1085
|
+
return /* @__PURE__ */ React8.createElement(Tabs3.Root, {
|
|
1086
|
+
value: tab,
|
|
1087
|
+
orientation: "vertical",
|
|
1088
|
+
verticalVariant: "stateless",
|
|
1089
|
+
classNames: "relative"
|
|
1090
|
+
}, /* @__PURE__ */ React8.createElement(L0Menu, {
|
|
1091
|
+
menuActions: topLevelActions,
|
|
1092
|
+
topLevelItems: l0Items,
|
|
1093
|
+
pinnedItems,
|
|
1094
|
+
userAccountItem,
|
|
1095
|
+
path,
|
|
1096
|
+
parent: root
|
|
1097
|
+
}), /* @__PURE__ */ React8.createElement(L1Panels, {
|
|
1098
|
+
topLevelItems,
|
|
1099
|
+
path,
|
|
1100
|
+
currentItemId: tab,
|
|
1101
|
+
onBack,
|
|
1102
|
+
...props
|
|
1103
|
+
}));
|
|
1104
|
+
} finally {
|
|
1105
|
+
_effect.f();
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
// packages/plugins/plugin-navtree/src/capabilities/index.ts
|
|
1110
|
+
import { lazy } from "@dxos/app-framework";
|
|
1111
|
+
var AppGraphBuilder = lazy(() => import("./app-graph-builder-P7AY3K72.mjs"));
|
|
1112
|
+
var IntentResolver = lazy(() => import("./intent-resolver-NAYKKAOP.mjs"));
|
|
1113
|
+
var Keyboard2 = lazy(() => import("./keyboard-DDFATRUG.mjs"));
|
|
1114
|
+
var ReactSurface = lazy(() => import("./react-surface-HGA3TAQU.mjs"));
|
|
1115
|
+
var State = lazy(() => import("./state-R2UMYAHN.mjs"));
|
|
1116
|
+
|
|
1117
|
+
// packages/plugins/plugin-navtree/src/components/NavTreeContainer.tsx
|
|
1118
|
+
var NODE_TYPE = "dxos/app-graph/node";
|
|
1119
|
+
var renderItemEnd = ({ node, open }) => /* @__PURE__ */ React9.createElement(Surface, {
|
|
1120
|
+
role: "navtree-item-end",
|
|
1121
|
+
data: {
|
|
1122
|
+
id: node.id,
|
|
1123
|
+
subject: node.data,
|
|
1124
|
+
open
|
|
1125
|
+
},
|
|
1126
|
+
limit: 1
|
|
1127
|
+
});
|
|
1128
|
+
var getChildrenFilter = (node) => untracked(() => !isActionLike2(node) && node.type !== PLANK_COMPANION_TYPE);
|
|
1129
|
+
var filterItems = (node, disposition) => {
|
|
1130
|
+
if (!disposition && (node.properties.disposition === "hidden" || node.properties.disposition === "alternate-tree")) {
|
|
1131
|
+
return false;
|
|
1132
|
+
} else if (!disposition) {
|
|
1133
|
+
const action = isAction4(node);
|
|
1134
|
+
return !action || node.properties.disposition === "item";
|
|
1135
|
+
} else {
|
|
1136
|
+
return node.properties.disposition === disposition;
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
var getItems = (graph, node, disposition) => {
|
|
1140
|
+
return graph.getConnections(node?.id ?? ROOT_ID, "outbound").filter((node2) => filterItems(node2, disposition));
|
|
1141
|
+
};
|
|
1142
|
+
var useItems = (node, options) => {
|
|
1143
|
+
const { graph } = useAppGraph2();
|
|
1144
|
+
const connections = useConnections(graph, node?.id ?? ROOT_ID).filter((node2) => filterItems(node2, options?.disposition));
|
|
1145
|
+
return options?.sort ? connections.toSorted((a, b) => byPosition(a.properties, b.properties)) : connections;
|
|
1146
|
+
};
|
|
1147
|
+
var NavTreeContainer = /* @__PURE__ */ memo2(({ tab, popoverAnchorId, topbar }) => {
|
|
1148
|
+
var _effect = _useSignals9();
|
|
1149
|
+
try {
|
|
1150
|
+
const [isLg] = useMediaQuery2("lg", {
|
|
1151
|
+
ssr: false
|
|
1152
|
+
});
|
|
1153
|
+
const { dispatchPromise: dispatch } = useIntentDispatcher3();
|
|
1154
|
+
const { graph } = useAppGraph2();
|
|
1155
|
+
const { isOpen, isCurrent, isAlternateTree, setItem } = useCapability(NavTreeCapabilities.State);
|
|
1156
|
+
const layout = useLayout();
|
|
1157
|
+
const { navigationSidebarState } = useSidebars(NAVTREE_PLUGIN);
|
|
1158
|
+
const getActions2 = useCallback3((node) => getActions(graph, node), [
|
|
1159
|
+
graph
|
|
1160
|
+
]);
|
|
1161
|
+
const getProps = useCallback3((node, path) => {
|
|
1162
|
+
const children = getChildren(graph, node, path).filter(getChildrenFilter);
|
|
1163
|
+
const parentOf = children.length > 0 ? children.map(({ id }) => id) : node.properties.role === "branch" ? [] : void 0;
|
|
1164
|
+
return {
|
|
1165
|
+
id: node.id,
|
|
1166
|
+
label: node.properties.label ?? node.id,
|
|
1167
|
+
parentOf,
|
|
1168
|
+
icon: node.properties.icon,
|
|
1169
|
+
disabled: node.properties.disabled,
|
|
1170
|
+
className: mx5(node.properties.modified && "italic", node.properties.className),
|
|
1171
|
+
headingClassName: node.properties.headingClassName,
|
|
1172
|
+
testId: node.properties.testId
|
|
1173
|
+
};
|
|
1174
|
+
}, [
|
|
1175
|
+
graph
|
|
1176
|
+
]);
|
|
1177
|
+
const loadDescendents = useCallback3((node) => {
|
|
1178
|
+
graph.expand(node.id, "outbound");
|
|
1179
|
+
graph.getConnections(node.id, "outbound").forEach((child) => {
|
|
1180
|
+
graph.expand(child.id, "outbound");
|
|
1181
|
+
});
|
|
1182
|
+
}, [
|
|
1183
|
+
graph
|
|
1184
|
+
]);
|
|
1185
|
+
const handleOpenChange = useCallback3(({ item: { id }, path, open }) => {
|
|
1186
|
+
setItem(path, "open", open);
|
|
1187
|
+
graph.expand(id, "outbound");
|
|
1188
|
+
}, [
|
|
1189
|
+
graph
|
|
1190
|
+
]);
|
|
1191
|
+
const handleTabChange = useCallback3(async (node) => {
|
|
1192
|
+
await dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
|
|
1193
|
+
part: "sidebar",
|
|
1194
|
+
options: {
|
|
1195
|
+
state: node.id === tab ? navigationSidebarState === "expanded" ? isLg ? "collapsed" : "closed" : "expanded" : "expanded"
|
|
1196
|
+
}
|
|
1197
|
+
}));
|
|
1198
|
+
await dispatch(createIntent3(LayoutAction3.SwitchWorkspace, {
|
|
1199
|
+
part: "workspace",
|
|
1200
|
+
subject: node.id
|
|
1201
|
+
}));
|
|
1202
|
+
if (layout.active.length === 0) {
|
|
1203
|
+
const [item] = getItems(graph, node).filter((node2) => !isActionLike2(node2));
|
|
1204
|
+
if (item && item.data) {
|
|
1205
|
+
await dispatch(createIntent3(LayoutAction3.Open, {
|
|
1206
|
+
part: "main",
|
|
1207
|
+
subject: [
|
|
1208
|
+
item.id
|
|
1209
|
+
]
|
|
1210
|
+
}));
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}, [
|
|
1214
|
+
dispatch,
|
|
1215
|
+
layout.active,
|
|
1216
|
+
tab,
|
|
1217
|
+
navigationSidebarState,
|
|
1218
|
+
isLg
|
|
1219
|
+
]);
|
|
1220
|
+
const canDrop = useCallback3((source, target) => {
|
|
1221
|
+
const sourceNode = source.item;
|
|
1222
|
+
const targetNode = target.item;
|
|
1223
|
+
if (isSpace(targetNode.data)) {
|
|
1224
|
+
return isEchoObject(sourceNode.data) || isSpace(sourceNode.data);
|
|
1225
|
+
} else if (isEchoObject(targetNode.data)) {
|
|
1226
|
+
return isEchoObject(sourceNode.data);
|
|
1227
|
+
} else {
|
|
1228
|
+
return false;
|
|
1229
|
+
}
|
|
1230
|
+
}, []);
|
|
1231
|
+
const handleSelect = useCallback3(({ item: node, path, option }) => {
|
|
1232
|
+
if (!node.data) {
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
if (isAction4(node)) {
|
|
1236
|
+
const [parent] = graph.getConnections(node.id, "inbound");
|
|
1237
|
+
void (parent && node.data({
|
|
1238
|
+
parent,
|
|
1239
|
+
caller: NAV_TREE_ITEM
|
|
1240
|
+
}));
|
|
1241
|
+
return;
|
|
1242
|
+
}
|
|
1243
|
+
const current = isCurrent(path, node);
|
|
1244
|
+
if (!current) {
|
|
1245
|
+
void dispatch(createIntent3(LayoutAction3.Open, {
|
|
1246
|
+
part: "main",
|
|
1247
|
+
subject: [
|
|
1248
|
+
node.id
|
|
1249
|
+
],
|
|
1250
|
+
options: {
|
|
1251
|
+
key: node.properties.key
|
|
1252
|
+
}
|
|
1253
|
+
}));
|
|
1254
|
+
} else if (option) {
|
|
1255
|
+
void dispatch(createIntent3(LayoutAction3.Close, {
|
|
1256
|
+
part: "main",
|
|
1257
|
+
subject: [
|
|
1258
|
+
node.id
|
|
1259
|
+
],
|
|
1260
|
+
options: {
|
|
1261
|
+
state: false
|
|
1262
|
+
}
|
|
1263
|
+
}));
|
|
1264
|
+
} else {
|
|
1265
|
+
void dispatch(createIntent3(LayoutAction3.ScrollIntoView, {
|
|
1266
|
+
part: "current",
|
|
1267
|
+
subject: node.id
|
|
1268
|
+
}));
|
|
1269
|
+
}
|
|
1270
|
+
const defaultAction = graph.getActions(node.id).find((action) => action.properties?.disposition === "default");
|
|
1271
|
+
if (isAction4(defaultAction)) {
|
|
1272
|
+
void defaultAction.data();
|
|
1273
|
+
}
|
|
1274
|
+
if (!isLg) {
|
|
1275
|
+
void dispatch(createIntent3(LayoutAction3.UpdateSidebar, {
|
|
1276
|
+
part: "sidebar",
|
|
1277
|
+
options: {
|
|
1278
|
+
state: "closed"
|
|
1279
|
+
}
|
|
1280
|
+
}));
|
|
1281
|
+
}
|
|
1282
|
+
}, [
|
|
1283
|
+
graph,
|
|
1284
|
+
dispatch,
|
|
1285
|
+
isCurrent,
|
|
1286
|
+
isLg
|
|
1287
|
+
]);
|
|
1288
|
+
const handleBack = useCallback3(() => dispatch(createIntent3(LayoutAction3.RevertWorkspace, {
|
|
1289
|
+
part: "workspace",
|
|
1290
|
+
options: {
|
|
1291
|
+
revert: true
|
|
1292
|
+
}
|
|
1293
|
+
})), [
|
|
1294
|
+
dispatch
|
|
1295
|
+
]);
|
|
1296
|
+
useEffect3(() => {
|
|
1297
|
+
return monitorForElements({
|
|
1298
|
+
canMonitor: ({ source }) => isTreeData(source.data),
|
|
1299
|
+
onDrop: ({ location, source }) => {
|
|
1300
|
+
if (!location.current.dropTargets.length) {
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
const target = location.current.dropTargets[0];
|
|
1304
|
+
const instruction = extractInstruction(target.data);
|
|
1305
|
+
if (instruction !== null && instruction.type !== "instruction-blocked") {
|
|
1306
|
+
const sourceNode = source.data.item;
|
|
1307
|
+
const targetNode = target.data.item;
|
|
1308
|
+
const sourcePath = source.data.path;
|
|
1309
|
+
const targetPath = target.data.path;
|
|
1310
|
+
const operation = sourcePath.slice(0, -1).join() === targetPath.slice(0, -1).join() && instruction.type !== "make-child" ? "rearrange" : resolveMigrationOperation(graph, sourceNode, targetPath, targetNode);
|
|
1311
|
+
const sourceParent = getParent(graph, sourceNode, sourcePath);
|
|
1312
|
+
const targetParent = getParent(graph, targetNode, targetPath);
|
|
1313
|
+
const sourceItems = getItems(graph, sourceParent);
|
|
1314
|
+
const targetItems = getItems(graph, targetParent);
|
|
1315
|
+
const sourceIndex = sourceItems.findIndex(({ id }) => id === sourceNode.id);
|
|
1316
|
+
const targetIndex = targetItems.findIndex(({ id }) => id === targetNode.id);
|
|
1317
|
+
const migrationIndex = instruction.type === "make-child" ? void 0 : instruction.type === "reorder-below" ? targetIndex + 1 : targetIndex;
|
|
1318
|
+
switch (operation) {
|
|
1319
|
+
case "rearrange": {
|
|
1320
|
+
const nextItems = sourceItems.map(({ data }) => data);
|
|
1321
|
+
arrayMove2(nextItems, sourceIndex, targetIndex);
|
|
1322
|
+
void sourceParent?.properties.onRearrangeChildren?.(nextItems);
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
case "copy": {
|
|
1326
|
+
const target2 = instruction.type === "make-child" ? targetNode : targetParent;
|
|
1327
|
+
void target2?.properties.onCopy?.(sourceNode, migrationIndex);
|
|
1328
|
+
break;
|
|
1329
|
+
}
|
|
1330
|
+
case "transfer": {
|
|
1331
|
+
const target2 = instruction.type === "make-child" ? targetNode : targetParent;
|
|
1332
|
+
if (!target2?.properties.onTransferStart || !sourceParent?.properties.onTransferEnd) {
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1335
|
+
void target2?.properties.onTransferStart(sourceNode, migrationIndex);
|
|
1336
|
+
void sourceParent?.properties.onTransferEnd?.(sourceNode, target2);
|
|
1337
|
+
break;
|
|
1338
|
+
}
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
});
|
|
1343
|
+
}, [
|
|
1344
|
+
graph
|
|
1345
|
+
]);
|
|
1346
|
+
const setAlternateTree = useCallback3((path, open) => {
|
|
1347
|
+
setItem(path, "alternateTree", open);
|
|
1348
|
+
}, [
|
|
1349
|
+
setItem
|
|
1350
|
+
]);
|
|
1351
|
+
const navTreeContextValue = useMemo5(() => ({
|
|
1352
|
+
useItems,
|
|
1353
|
+
tab,
|
|
1354
|
+
getActions: getActions2,
|
|
1355
|
+
loadDescendents,
|
|
1356
|
+
renderItemEnd,
|
|
1357
|
+
popoverAnchorId,
|
|
1358
|
+
topbar,
|
|
1359
|
+
getProps,
|
|
1360
|
+
isCurrent,
|
|
1361
|
+
isOpen,
|
|
1362
|
+
canDrop,
|
|
1363
|
+
isAlternateTree,
|
|
1364
|
+
setAlternateTree,
|
|
1365
|
+
onTabChange: handleTabChange,
|
|
1366
|
+
onOpenChange: handleOpenChange,
|
|
1367
|
+
onSelect: handleSelect,
|
|
1368
|
+
onBack: handleBack
|
|
1369
|
+
}), [
|
|
1370
|
+
tab,
|
|
1371
|
+
getActions2,
|
|
1372
|
+
loadDescendents,
|
|
1373
|
+
renderItemEnd,
|
|
1374
|
+
popoverAnchorId,
|
|
1375
|
+
topbar,
|
|
1376
|
+
getProps,
|
|
1377
|
+
isCurrent,
|
|
1378
|
+
isOpen,
|
|
1379
|
+
canDrop,
|
|
1380
|
+
isAlternateTree,
|
|
1381
|
+
setAlternateTree,
|
|
1382
|
+
handleTabChange,
|
|
1383
|
+
handleOpenChange,
|
|
1384
|
+
handleSelect,
|
|
1385
|
+
handleBack
|
|
1386
|
+
]);
|
|
1387
|
+
return /* @__PURE__ */ React9.createElement(NavTreeContext.Provider, {
|
|
1388
|
+
value: navTreeContextValue
|
|
1389
|
+
}, /* @__PURE__ */ React9.createElement(NavTree, {
|
|
1390
|
+
id: ROOT_ID,
|
|
1391
|
+
root: graph.root,
|
|
1392
|
+
open: layout.sidebarOpen
|
|
1393
|
+
}));
|
|
1394
|
+
} finally {
|
|
1395
|
+
_effect.f();
|
|
1396
|
+
}
|
|
1397
|
+
});
|
|
1398
|
+
|
|
1399
|
+
export {
|
|
1400
|
+
CommandsDialogContent,
|
|
1401
|
+
CommandsTrigger,
|
|
1402
|
+
getParent,
|
|
1403
|
+
getPersistenceParent,
|
|
1404
|
+
resolveMigrationOperation,
|
|
1405
|
+
sortActions,
|
|
1406
|
+
getChildren,
|
|
1407
|
+
getActions,
|
|
1408
|
+
l0ItemType,
|
|
1409
|
+
NODE_TYPE,
|
|
1410
|
+
NavTreeContainer,
|
|
1411
|
+
NavTreeDocumentTitle,
|
|
1412
|
+
AppGraphBuilder,
|
|
1413
|
+
IntentResolver,
|
|
1414
|
+
Keyboard2 as Keyboard,
|
|
1415
|
+
ReactSurface,
|
|
1416
|
+
State
|
|
1417
|
+
};
|
|
1418
|
+
//# sourceMappingURL=chunk-MFAWMFJC.mjs.map
|