@dxos/plugin-simple-layout 0.8.4-main.9735255 → 0.8.4-main.c85a9c8dae
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/{chunk-P77G4YTR.mjs → chunk-7VLT3S46.mjs} +3 -3
- package/dist/lib/browser/chunk-7VLT3S46.mjs.map +7 -0
- package/dist/lib/browser/chunk-TMZNLVT2.mjs +1170 -0
- package/dist/lib/browser/chunk-TMZNLVT2.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +20 -19
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/{operation-resolver-775UYAC2.mjs → operation-resolver-BYRIQOQT.mjs} +30 -28
- package/dist/lib/browser/operation-resolver-BYRIQOQT.mjs.map +7 -0
- package/dist/lib/browser/{react-root-KM55OMGJ.mjs → react-root-MMB575WY.mjs} +5 -5
- package/dist/lib/browser/react-root-MMB575WY.mjs.map +7 -0
- package/dist/lib/browser/{react-surface-BABGAWGY.mjs → react-surface-M6CURANW.mjs} +10 -8
- package/dist/lib/browser/react-surface-M6CURANW.mjs.map +7 -0
- package/dist/lib/browser/{spotlight-dismiss-VSNOPETH.mjs → spotlight-dismiss-67PHYS5B.mjs} +3 -3
- package/dist/lib/browser/spotlight-dismiss-67PHYS5B.mjs.map +7 -0
- package/dist/lib/browser/{state-OUFTC2KV.mjs → state-A3PGDWWZ.mjs} +5 -4
- package/dist/lib/browser/state-A3PGDWWZ.mjs.map +7 -0
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs +152 -0
- package/dist/lib/browser/url-handler-HTIUY6WL.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs +1171 -0
- package/dist/lib/node-esm/chunk-FLOYBAHE.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-F5TEKVJG.mjs → chunk-VIDE5UMB.mjs} +3 -3
- package/dist/lib/node-esm/chunk-VIDE5UMB.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +20 -19
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/{operation-resolver-LDNYS3DI.mjs → operation-resolver-BDTFNCS2.mjs} +30 -28
- package/dist/lib/node-esm/operation-resolver-BDTFNCS2.mjs.map +7 -0
- package/dist/lib/node-esm/{react-root-36UYFEEB.mjs → react-root-ENZKVSY4.mjs} +5 -5
- package/dist/lib/node-esm/react-root-ENZKVSY4.mjs.map +7 -0
- package/dist/lib/node-esm/{react-surface-CGHFVWU3.mjs → react-surface-ITVNQYLG.mjs} +10 -8
- package/dist/lib/node-esm/react-surface-ITVNQYLG.mjs.map +7 -0
- package/dist/lib/node-esm/{spotlight-dismiss-L5PCWIJG.mjs → spotlight-dismiss-RMLRZUVY.mjs} +3 -3
- package/dist/lib/node-esm/spotlight-dismiss-RMLRZUVY.mjs.map +7 -0
- package/dist/lib/node-esm/{state-Q2ZA26W5.mjs → state-ZCFZTTPL.mjs} +5 -4
- package/dist/lib/node-esm/state-ZCFZTTPL.mjs.map +7 -0
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs +153 -0
- package/dist/lib/node-esm/url-handler-WBVVKVPC.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +2 -2
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts +1 -1
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts +1 -1
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +2 -2
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts +1 -1
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +1 -1
- package/dist/types/src/capabilities/state/index.d.ts +1 -1
- package/dist/types/src/capabilities/state/state.d.ts +1 -1
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts +3 -1
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -1
- package/dist/types/src/components/ContentError.stories.d.ts +1 -3
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -1
- package/dist/types/src/components/Home/Home.d.ts.map +1 -1
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts +35 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts +7 -0
- package/dist/types/src/components/MobileLayout/MobileLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/MobileLayout/index.d.ts +2 -0
- package/dist/types/src/components/MobileLayout/index.d.ts.map +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts +26 -0
- package/dist/types/src/components/SimpleLayout/AppBar.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts +47 -0
- package/dist/types/src/components/SimpleLayout/AppBar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts +1 -1
- package/dist/types/src/components/SimpleLayout/Drawer.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +10 -3
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +4 -4
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -1
- package/dist/types/src/components/SimpleLayout/index.d.ts +3 -0
- package/dist/types/src/components/SimpleLayout/index.d.ts.map +1 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts +3 -1
- package/dist/types/src/components/Workspace/Workspace.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/hooks/actions.d.ts +20 -0
- package/dist/types/src/hooks/actions.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -1
- package/dist/types/src/hooks/useAppBarProps.d.ts +7 -0
- package/dist/types/src/hooks/useAppBarProps.d.ts.map +1 -0
- package/dist/types/src/hooks/useCompanions.d.ts +5 -1
- package/dist/types/src/hooks/useCompanions.d.ts.map +1 -1
- package/dist/types/src/hooks/useDrawerActions.d.ts +13 -0
- package/dist/types/src/hooks/useDrawerActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts +14 -0
- package/dist/types/src/hooks/useNavbarActions.d.ts.map +1 -0
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +3 -3
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -1
- package/dist/types/src/types/capabilities.d.ts +7 -6
- package/dist/types/src/types/capabilities.d.ts.map +1 -1
- package/dist/types/src/types/events.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +36 -30
- package/src/SimpleLayoutPlugin.ts +10 -9
- package/src/capabilities/operation-resolver/operation-resolver.ts +24 -22
- package/src/capabilities/react-root/react-root.tsx +2 -2
- package/src/capabilities/react-surface/react-surface.tsx +6 -5
- package/src/capabilities/spotlight-dismiss/spotlight-dismiss.ts +2 -2
- package/src/capabilities/state/state.tsx +4 -3
- package/src/capabilities/url-handler/url-handler.ts +111 -34
- package/src/components/ContentError.stories.tsx +8 -7
- package/src/components/ContentLoading.stories.tsx +2 -2
- package/src/components/ContentLoading.tsx +1 -1
- package/src/components/Dialog/Dialog.tsx +5 -5
- package/src/components/Home/Home.tsx +41 -33
- package/src/components/MobileLayout/MobileLayout.stories.tsx +129 -0
- package/src/components/MobileLayout/MobileLayout.tsx +305 -0
- package/src/components/MobileLayout/index.ts +5 -0
- package/src/components/Popover/Popover.tsx +17 -7
- package/src/components/SimpleLayout/AppBar.stories.tsx +144 -0
- package/src/components/SimpleLayout/AppBar.tsx +94 -0
- package/src/components/SimpleLayout/Drawer.tsx +22 -68
- package/src/components/SimpleLayout/Main.tsx +40 -29
- package/src/components/SimpleLayout/NavBar.stories.tsx +131 -23
- package/src/components/SimpleLayout/NavBar.tsx +15 -47
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +20 -11
- package/src/components/SimpleLayout/SimpleLayout.tsx +38 -19
- package/src/components/SimpleLayout/index.ts +3 -0
- package/src/components/Workspace/Workspace.tsx +34 -24
- package/src/components/hooks.ts +4 -4
- package/src/components/index.ts +1 -0
- package/src/hooks/actions.ts +85 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useAppBarProps.ts +116 -0
- package/src/hooks/useCompanions.ts +8 -5
- package/src/hooks/useDrawerActions.ts +98 -0
- package/src/hooks/useNavbarActions.ts +86 -0
- package/src/hooks/useSimpleLayoutState.ts +5 -5
- package/src/types/capabilities.ts +10 -6
- package/src/types/events.ts +3 -2
- package/dist/lib/browser/chunk-LR3EE3VB.mjs +0 -789
- package/dist/lib/browser/chunk-LR3EE3VB.mjs.map +0 -7
- package/dist/lib/browser/chunk-P77G4YTR.mjs.map +0 -7
- package/dist/lib/browser/operation-resolver-775UYAC2.mjs.map +0 -7
- package/dist/lib/browser/react-root-KM55OMGJ.mjs.map +0 -7
- package/dist/lib/browser/react-surface-BABGAWGY.mjs.map +0 -7
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +0 -7
- package/dist/lib/browser/state-OUFTC2KV.mjs.map +0 -7
- package/dist/lib/browser/url-handler-DOUFQIAC.mjs +0 -54
- package/dist/lib/browser/url-handler-DOUFQIAC.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-F5TEKVJG.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-HB2B3LLG.mjs +0 -790
- package/dist/lib/node-esm/chunk-HB2B3LLG.mjs.map +0 -7
- package/dist/lib/node-esm/operation-resolver-LDNYS3DI.mjs.map +0 -7
- package/dist/lib/node-esm/react-root-36UYFEEB.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-CGHFVWU3.mjs.map +0 -7
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +0 -7
- package/dist/lib/node-esm/state-Q2ZA26W5.mjs.map +0 -7
- package/dist/lib/node-esm/url-handler-DVAZZEUO.mjs +0 -55
- package/dist/lib/node-esm/url-handler-DVAZZEUO.mjs.map +0 -7
- package/dist/types/src/components/ContentError.d.ts +0 -5
- package/dist/types/src/components/ContentError.d.ts.map +0 -1
- package/dist/types/src/components/SimpleLayout/Banner.d.ts +0 -8
- package/dist/types/src/components/SimpleLayout/Banner.d.ts.map +0 -1
- package/src/components/ContentError.tsx +0 -23
- package/src/components/SimpleLayout/Banner.tsx +0 -113
|
@@ -1,789 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SimpleLayoutState,
|
|
3
|
-
meta
|
|
4
|
-
} from "./chunk-P77G4YTR.mjs";
|
|
5
|
-
|
|
6
|
-
// src/components/Home/Home.tsx
|
|
7
|
-
import React, { useCallback, useEffect as useEffect2, useMemo, useRef } from "react";
|
|
8
|
-
import { Common } from "@dxos/app-framework";
|
|
9
|
-
import { useAppGraph as useAppGraph2, useOperationInvoker } from "@dxos/app-framework/react";
|
|
10
|
-
import { Node, useConnections } from "@dxos/plugin-graph";
|
|
11
|
-
import { Avatar, Icon, Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
12
|
-
import { Card, Layout, Mosaic } from "@dxos/react-ui-mosaic";
|
|
13
|
-
import { SearchList, useSearchListItem, useSearchListResults } from "@dxos/react-ui-searchlist";
|
|
14
|
-
import { mx } from "@dxos/ui-theme";
|
|
15
|
-
import { byPosition } from "@dxos/util";
|
|
16
|
-
|
|
17
|
-
// src/components/hooks.ts
|
|
18
|
-
import { useEffect } from "react";
|
|
19
|
-
import { useAppGraph } from "@dxos/app-framework/react";
|
|
20
|
-
import { Graph } from "@dxos/plugin-graph";
|
|
21
|
-
var useLoadDescendents = (nodeId) => {
|
|
22
|
-
const { graph } = useAppGraph();
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
if (nodeId) {
|
|
25
|
-
Graph.expand(graph, nodeId, "outbound");
|
|
26
|
-
Graph.getConnections(graph, nodeId, "outbound").forEach((child) => {
|
|
27
|
-
Graph.expand(graph, child.id, "outbound");
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}, [
|
|
31
|
-
nodeId,
|
|
32
|
-
graph
|
|
33
|
-
]);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// src/components/Home/Home.tsx
|
|
37
|
-
var Home = (_) => {
|
|
38
|
-
const { t } = useTranslation(meta.id);
|
|
39
|
-
const userAccountItem = useItemsByDisposition("user-account")[0];
|
|
40
|
-
const pinnedItems = useItemsByDisposition("pin-end", true);
|
|
41
|
-
const workspaceItems = useItemsByDisposition("workspace");
|
|
42
|
-
useLoadDescendents(Node.RootId);
|
|
43
|
-
const items = useMemo(() => [
|
|
44
|
-
...userAccountItem ? [
|
|
45
|
-
userAccountItem
|
|
46
|
-
] : [],
|
|
47
|
-
...pinnedItems,
|
|
48
|
-
...workspaceItems
|
|
49
|
-
], [
|
|
50
|
-
userAccountItem,
|
|
51
|
-
pinnedItems,
|
|
52
|
-
workspaceItems
|
|
53
|
-
]);
|
|
54
|
-
const { results, handleSearch } = useSearchListResults({
|
|
55
|
-
items,
|
|
56
|
-
extract: (node) => toLocalizedString(node.properties.label, t)
|
|
57
|
-
});
|
|
58
|
-
return /* @__PURE__ */ React.createElement(Layout.Main, {
|
|
59
|
-
toolbar: true
|
|
60
|
-
}, /* @__PURE__ */ React.createElement(SearchList.Root, {
|
|
61
|
-
onSearch: handleSearch
|
|
62
|
-
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(SearchList.Input, {
|
|
63
|
-
placeholder: t("search placeholder"),
|
|
64
|
-
autoFocus: true
|
|
65
|
-
})), /* @__PURE__ */ React.createElement(SearchList.Content, null, /* @__PURE__ */ React.createElement(Mosaic.Container, {
|
|
66
|
-
asChild: true
|
|
67
|
-
}, /* @__PURE__ */ React.createElement(Mosaic.Viewport, {
|
|
68
|
-
padding: true
|
|
69
|
-
}, /* @__PURE__ */ React.createElement(Mosaic.Stack, {
|
|
70
|
-
items: results,
|
|
71
|
-
getId: (node) => node.id,
|
|
72
|
-
Tile: WorkspaceTile
|
|
73
|
-
}))))));
|
|
74
|
-
};
|
|
75
|
-
var WorkspaceTile = ({ data }) => {
|
|
76
|
-
const { t } = useTranslation(meta.id);
|
|
77
|
-
const { invokePromise } = useOperationInvoker();
|
|
78
|
-
const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
|
|
79
|
-
const ref = useRef(null);
|
|
80
|
-
const handleSelect = useCallback(() => invokePromise(Common.LayoutOperation.SwitchWorkspace, {
|
|
81
|
-
subject: data.id
|
|
82
|
-
}), [
|
|
83
|
-
invokePromise,
|
|
84
|
-
data.id
|
|
85
|
-
]);
|
|
86
|
-
useLoadDescendents(data.id);
|
|
87
|
-
const name = toLocalizedString(data.properties.label, t);
|
|
88
|
-
const isSelected = selectedValue === data.id;
|
|
89
|
-
useEffect2(() => {
|
|
90
|
-
if (ref.current) {
|
|
91
|
-
registerItem(data.id, ref.current, handleSelect);
|
|
92
|
-
}
|
|
93
|
-
return () => unregisterItem(data.id);
|
|
94
|
-
}, [
|
|
95
|
-
data.id,
|
|
96
|
-
handleSelect,
|
|
97
|
-
registerItem,
|
|
98
|
-
unregisterItem
|
|
99
|
-
]);
|
|
100
|
-
useEffect2(() => {
|
|
101
|
-
if (isSelected && ref.current) {
|
|
102
|
-
ref.current.scrollIntoView({
|
|
103
|
-
block: "nearest",
|
|
104
|
-
behavior: "smooth"
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}, [
|
|
108
|
-
isSelected
|
|
109
|
-
]);
|
|
110
|
-
return /* @__PURE__ */ React.createElement(Card.Root, {
|
|
111
|
-
ref,
|
|
112
|
-
role: "button",
|
|
113
|
-
fullWidth: true,
|
|
114
|
-
tabIndex: -1,
|
|
115
|
-
"data-selected": isSelected,
|
|
116
|
-
classNames: mx("dx-focus-ring", isSelected && "bg-hoverOverlay"),
|
|
117
|
-
onClick: handleSelect
|
|
118
|
-
}, /* @__PURE__ */ React.createElement(Card.Toolbar, {
|
|
119
|
-
density: "coarse"
|
|
120
|
-
}, /* @__PURE__ */ React.createElement(Avatar.Root, null, /* @__PURE__ */ React.createElement(Avatar.Content, {
|
|
121
|
-
icon: data.properties.icon,
|
|
122
|
-
hue: data.properties.hue,
|
|
123
|
-
hueVariant: "transparent",
|
|
124
|
-
variant: "square",
|
|
125
|
-
size: 12,
|
|
126
|
-
fallback: name
|
|
127
|
-
}), /* @__PURE__ */ React.createElement(Avatar.Label, null, name), /* @__PURE__ */ React.createElement(Icon, {
|
|
128
|
-
icon: "ph--caret-right--regular"
|
|
129
|
-
}))));
|
|
130
|
-
};
|
|
131
|
-
var filterItems = (node, disposition) => {
|
|
132
|
-
return node.properties.disposition === disposition;
|
|
133
|
-
};
|
|
134
|
-
var useItemsByDisposition = (disposition, sort = false) => {
|
|
135
|
-
const { graph } = useAppGraph2();
|
|
136
|
-
const connections = useConnections(graph, Node.RootId);
|
|
137
|
-
const filtered = connections.filter((node) => filterItems(node, disposition));
|
|
138
|
-
return sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
142
|
-
import React10, { useCallback as useCallback6 } from "react";
|
|
143
|
-
import { Main as NaturalMain3 } from "@dxos/react-ui";
|
|
144
|
-
import { Mosaic as Mosaic2 } from "@dxos/react-ui-mosaic";
|
|
145
|
-
|
|
146
|
-
// src/hooks/useCompanions.ts
|
|
147
|
-
import { useMemo as useMemo2 } from "react";
|
|
148
|
-
import { useAppGraph as useAppGraph3 } from "@dxos/app-framework/react";
|
|
149
|
-
import { useConnections as useConnections2 } from "@dxos/plugin-graph";
|
|
150
|
-
import { byPosition as byPosition2 } from "@dxos/util";
|
|
151
|
-
var PLANK_COMPANION_TYPE = "dxos.org/plugin/deck/plank-companion";
|
|
152
|
-
var useCompanions = (id) => {
|
|
153
|
-
const { graph } = useAppGraph3();
|
|
154
|
-
const nodes = useConnections2(graph, id);
|
|
155
|
-
const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
|
|
156
|
-
return useMemo2(() => companions.toSorted((a, b) => byPosition2(a.properties, b.properties)), [
|
|
157
|
-
companions
|
|
158
|
-
]);
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
// src/hooks/useSimpleLayoutState.ts
|
|
162
|
-
import { RegistryContext, useAtomValue } from "@effect-atom/atom-react";
|
|
163
|
-
import { useCallback as useCallback2, useContext } from "react";
|
|
164
|
-
import { useCapability } from "@dxos/app-framework/react";
|
|
165
|
-
var useSimpleLayoutState = () => {
|
|
166
|
-
const registry = useContext(RegistryContext);
|
|
167
|
-
const stateAtom = useCapability(SimpleLayoutState);
|
|
168
|
-
const state = useAtomValue(stateAtom);
|
|
169
|
-
const updateState = useCallback2((fn) => {
|
|
170
|
-
registry.set(stateAtom, fn(registry.get(stateAtom)));
|
|
171
|
-
}, [
|
|
172
|
-
registry,
|
|
173
|
-
stateAtom
|
|
174
|
-
]);
|
|
175
|
-
return {
|
|
176
|
-
state,
|
|
177
|
-
updateState
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
// src/components/Dialog/Dialog.tsx
|
|
182
|
-
import React3 from "react";
|
|
183
|
-
import { Surface } from "@dxos/app-framework/react";
|
|
184
|
-
import { AlertDialog, Dialog as NaturalDialog } from "@dxos/react-ui";
|
|
185
|
-
|
|
186
|
-
// src/components/ContentError.tsx
|
|
187
|
-
import React2 from "react";
|
|
188
|
-
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
189
|
-
import { descriptionMessage, mx as mx2 } from "@dxos/ui-theme";
|
|
190
|
-
var ContentError = ({ error }) => {
|
|
191
|
-
const { t } = useTranslation2(meta.id);
|
|
192
|
-
const errorString = error?.toString() ?? "";
|
|
193
|
-
return /* @__PURE__ */ React2.createElement("div", {
|
|
194
|
-
role: "none",
|
|
195
|
-
className: "grid place-items-center overflow-y-auto attention-surface"
|
|
196
|
-
}, /* @__PURE__ */ React2.createElement("p", {
|
|
197
|
-
role: "alert",
|
|
198
|
-
className: mx2(descriptionMessage, "p-2 break-all rounded-sm")
|
|
199
|
-
}, error ? errorString : t("error fallback message")));
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
// src/components/Dialog/Dialog.tsx
|
|
203
|
-
var Dialog = () => {
|
|
204
|
-
const { state, updateState } = useSimpleLayoutState();
|
|
205
|
-
const DialogRoot = state.dialogType === "alert" ? AlertDialog.Root : NaturalDialog.Root;
|
|
206
|
-
const DialogOverlay = state.dialogType === "alert" ? AlertDialog.Overlay : NaturalDialog.Overlay;
|
|
207
|
-
return /* @__PURE__ */ React3.createElement(DialogRoot, {
|
|
208
|
-
modal: state.dialogBlockAlign !== "end",
|
|
209
|
-
open: state.dialogOpen,
|
|
210
|
-
onOpenChange: (nextOpen) => updateState((s) => ({
|
|
211
|
-
...s,
|
|
212
|
-
dialogOpen: nextOpen
|
|
213
|
-
}))
|
|
214
|
-
}, state.dialogBlockAlign === "end" ? /* @__PURE__ */ React3.createElement(Surface, {
|
|
215
|
-
role: "dialog",
|
|
216
|
-
data: state.dialogContent,
|
|
217
|
-
limit: 1,
|
|
218
|
-
fallback: ContentError
|
|
219
|
-
}) : /* @__PURE__ */ React3.createElement(DialogOverlay, {
|
|
220
|
-
blockAlign: state.dialogBlockAlign,
|
|
221
|
-
classNames: state.dialogOverlayClasses,
|
|
222
|
-
style: state.dialogOverlayStyle
|
|
223
|
-
}, /* @__PURE__ */ React3.createElement(Surface, {
|
|
224
|
-
role: "dialog",
|
|
225
|
-
data: state.dialogContent,
|
|
226
|
-
limit: 1,
|
|
227
|
-
fallback: ContentError
|
|
228
|
-
})));
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
// src/components/Popover/Popover.tsx
|
|
232
|
-
import { createContext } from "@radix-ui/react-context";
|
|
233
|
-
import React4, { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef2, useState } from "react";
|
|
234
|
-
import { Surface as Surface2 } from "@dxos/app-framework/react";
|
|
235
|
-
import { Popover, toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
236
|
-
import { Card as Card2 } from "@dxos/react-ui-mosaic";
|
|
237
|
-
var DEBOUNCE_DELAY = 40;
|
|
238
|
-
var [LayoutPopoverProvider, useLayoutPopoverContext] = createContext("LayoutPopover");
|
|
239
|
-
var PopoverRoot = ({ children }) => {
|
|
240
|
-
const { state } = useSimpleLayoutState();
|
|
241
|
-
const [open, setOpen] = useState(false);
|
|
242
|
-
const virtualRef = useRef2(null);
|
|
243
|
-
const [virtualIter, setVirtualIter] = useState(0);
|
|
244
|
-
const debounceRef = useRef2(null);
|
|
245
|
-
useEffect3(() => {
|
|
246
|
-
setOpen(false);
|
|
247
|
-
if (state.popoverOpen) {
|
|
248
|
-
if (debounceRef.current) {
|
|
249
|
-
clearTimeout(debounceRef.current);
|
|
250
|
-
}
|
|
251
|
-
if (state.popoverAnchor && virtualRef.current !== state.popoverAnchor) {
|
|
252
|
-
virtualRef.current = state.popoverAnchor ?? null;
|
|
253
|
-
setVirtualIter((iter) => iter + 1);
|
|
254
|
-
}
|
|
255
|
-
debounceRef.current = setTimeout(() => setOpen(true), DEBOUNCE_DELAY);
|
|
256
|
-
}
|
|
257
|
-
}, [
|
|
258
|
-
state.popoverOpen,
|
|
259
|
-
state.popoverAnchorId,
|
|
260
|
-
state.popoverAnchor,
|
|
261
|
-
state.popoverContent
|
|
262
|
-
]);
|
|
263
|
-
return /* @__PURE__ */ React4.createElement(LayoutPopoverProvider, {
|
|
264
|
-
setOpen
|
|
265
|
-
}, /* @__PURE__ */ React4.createElement(Popover.Root, {
|
|
266
|
-
modal: false,
|
|
267
|
-
open
|
|
268
|
-
}, state.popoverAnchor && /* @__PURE__ */ React4.createElement(Popover.VirtualTrigger, {
|
|
269
|
-
key: virtualIter,
|
|
270
|
-
virtualRef
|
|
271
|
-
}), children));
|
|
272
|
-
};
|
|
273
|
-
var PopoverContent = () => {
|
|
274
|
-
const { t } = useTranslation3(meta.id);
|
|
275
|
-
const { state, updateState } = useSimpleLayoutState();
|
|
276
|
-
const { setOpen } = useLayoutPopoverContext("PopoverContent");
|
|
277
|
-
const handleClose = useCallback3(() => {
|
|
278
|
-
setOpen(false);
|
|
279
|
-
updateState((s) => ({
|
|
280
|
-
...s,
|
|
281
|
-
popoverOpen: false,
|
|
282
|
-
popoverAnchor: void 0,
|
|
283
|
-
popoverAnchorId: void 0,
|
|
284
|
-
popoverSide: void 0
|
|
285
|
-
}));
|
|
286
|
-
}, [
|
|
287
|
-
setOpen,
|
|
288
|
-
updateState
|
|
289
|
-
]);
|
|
290
|
-
const handleInteractOutside = useCallback3((event) => {
|
|
291
|
-
if (
|
|
292
|
-
// TODO(thure): CodeMirror should not focus itself when it updates.
|
|
293
|
-
event.type === "dismissableLayer.focusOutside" && event.currentTarget?.classList.contains("cm-content")
|
|
294
|
-
) {
|
|
295
|
-
event.preventDefault();
|
|
296
|
-
} else {
|
|
297
|
-
handleClose();
|
|
298
|
-
}
|
|
299
|
-
}, [
|
|
300
|
-
handleClose
|
|
301
|
-
]);
|
|
302
|
-
const collisionBoundaries = useMemo3(() => {
|
|
303
|
-
const closest = state.popoverAnchor?.closest("[data-popover-collision-boundary]");
|
|
304
|
-
return closest ? [
|
|
305
|
-
closest
|
|
306
|
-
] : [];
|
|
307
|
-
}, [
|
|
308
|
-
state.popoverAnchor
|
|
309
|
-
]);
|
|
310
|
-
return /* @__PURE__ */ React4.createElement(Popover.Portal, null, /* @__PURE__ */ React4.createElement(Popover.Content, {
|
|
311
|
-
side: state.popoverSide,
|
|
312
|
-
sticky: "always",
|
|
313
|
-
hideWhenDetached: true,
|
|
314
|
-
collisionBoundary: collisionBoundaries,
|
|
315
|
-
onInteractOutside: handleInteractOutside,
|
|
316
|
-
onEscapeKeyDown: handleInteractOutside
|
|
317
|
-
}, /* @__PURE__ */ React4.createElement(Popover.Viewport, null, state.popoverKind === "card" && /* @__PURE__ */ React4.createElement(Card2.Root, null, /* @__PURE__ */ React4.createElement(Card2.Toolbar, null, /* @__PURE__ */ React4.createElement("span", null), state.popoverTitle ? /* @__PURE__ */ React4.createElement(Card2.Title, null, toLocalizedString2(state.popoverTitle, t)) : /* @__PURE__ */ React4.createElement("span", null), /* @__PURE__ */ React4.createElement(Card2.Close, {
|
|
318
|
-
onClick: handleClose
|
|
319
|
-
})), /* @__PURE__ */ React4.createElement(Surface2, {
|
|
320
|
-
role: "card--content",
|
|
321
|
-
data: state.popoverContent,
|
|
322
|
-
limit: 1
|
|
323
|
-
})), state.popoverKind === "base" && /* @__PURE__ */ React4.createElement(Surface2, {
|
|
324
|
-
role: "popover",
|
|
325
|
-
data: state.popoverContent,
|
|
326
|
-
limit: 1
|
|
327
|
-
})), /* @__PURE__ */ React4.createElement(Popover.Arrow, null)));
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
// src/components/SimpleLayout/Drawer.tsx
|
|
331
|
-
import React6, { useCallback as useCallback4, useMemo as useMemo4 } from "react";
|
|
332
|
-
import { Surface as Surface3, useAppGraph as useAppGraph4 } from "@dxos/app-framework/react";
|
|
333
|
-
import { useNode } from "@dxos/plugin-graph";
|
|
334
|
-
import { IconButton, Main as NaturalMain, Toolbar as Toolbar2, toLocalizedString as toLocalizedString3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
335
|
-
import { ATTENDABLE_PATH_SEPARATOR } from "@dxos/react-ui-attention";
|
|
336
|
-
|
|
337
|
-
// src/components/ContentLoading.tsx
|
|
338
|
-
import React5 from "react";
|
|
339
|
-
var ContentLoading = () => {
|
|
340
|
-
return /* @__PURE__ */ React5.createElement("div", {
|
|
341
|
-
role: "none",
|
|
342
|
-
className: "grid place-items-center attention-surface"
|
|
343
|
-
});
|
|
344
|
-
};
|
|
345
|
-
|
|
346
|
-
// src/components/SimpleLayout/Drawer.tsx
|
|
347
|
-
var DRAWER_NAME = "SimpleLayout.Drawer";
|
|
348
|
-
var Drawer = () => {
|
|
349
|
-
const { t } = useTranslation4(meta.id);
|
|
350
|
-
const { state, updateState } = useSimpleLayoutState();
|
|
351
|
-
const { graph } = useAppGraph4();
|
|
352
|
-
const placeholder = useMemo4(() => /* @__PURE__ */ React6.createElement(ContentLoading, null), []);
|
|
353
|
-
const activeId = state.active ?? state.workspace;
|
|
354
|
-
const companions = useCompanions(activeId);
|
|
355
|
-
const { companionId, variant } = useSelectedCompanion(companions, state.companionVariant);
|
|
356
|
-
const node = useNode(graph, companionId);
|
|
357
|
-
const parentNode = useNode(graph, activeId);
|
|
358
|
-
const data = useMemo4(() => {
|
|
359
|
-
return node && {
|
|
360
|
-
attendableId: companionId,
|
|
361
|
-
subject: node.data,
|
|
362
|
-
companionTo: parentNode?.data,
|
|
363
|
-
properties: node.properties,
|
|
364
|
-
variant
|
|
365
|
-
};
|
|
366
|
-
}, [
|
|
367
|
-
companionId,
|
|
368
|
-
node,
|
|
369
|
-
parentNode,
|
|
370
|
-
variant
|
|
371
|
-
]);
|
|
372
|
-
const handleTabClick = useCallback4((companion) => {
|
|
373
|
-
const [, companionVariant] = companion.id.split(ATTENDABLE_PATH_SEPARATOR);
|
|
374
|
-
updateState((s) => ({
|
|
375
|
-
...s,
|
|
376
|
-
companionVariant
|
|
377
|
-
}));
|
|
378
|
-
}, [
|
|
379
|
-
updateState
|
|
380
|
-
]);
|
|
381
|
-
const handleToggleExpand = useCallback4(() => {
|
|
382
|
-
updateState((s) => ({
|
|
383
|
-
...s,
|
|
384
|
-
drawerState: s.drawerState === "full" ? "expanded" : "full"
|
|
385
|
-
}));
|
|
386
|
-
}, [
|
|
387
|
-
updateState
|
|
388
|
-
]);
|
|
389
|
-
const handleClose = useCallback4(() => {
|
|
390
|
-
updateState((s) => ({
|
|
391
|
-
...s,
|
|
392
|
-
drawerState: "closed"
|
|
393
|
-
}));
|
|
394
|
-
}, [
|
|
395
|
-
updateState
|
|
396
|
-
]);
|
|
397
|
-
const drawerState = state.drawerState ?? "closed";
|
|
398
|
-
if (drawerState === "closed") {
|
|
399
|
-
return null;
|
|
400
|
-
}
|
|
401
|
-
const isFullyExpanded = drawerState === "full";
|
|
402
|
-
return /* @__PURE__ */ React6.createElement(NaturalMain.Drawer, {
|
|
403
|
-
label: t("drawer label")
|
|
404
|
-
}, /* @__PURE__ */ React6.createElement(Toolbar2.Root, null, /* @__PURE__ */ React6.createElement("div", {
|
|
405
|
-
role: "tablist",
|
|
406
|
-
className: "flex-1 min-is-0 overflow-x-auto scrollbar-none flex gap-1"
|
|
407
|
-
}, companions.map((companion) => /* @__PURE__ */ React6.createElement(IconButton, {
|
|
408
|
-
key: companion.id,
|
|
409
|
-
role: "tab",
|
|
410
|
-
"aria-selected": companionId === companion.id,
|
|
411
|
-
icon: companion.properties.icon,
|
|
412
|
-
iconOnly: true,
|
|
413
|
-
label: toLocalizedString3(companion.properties.label, t),
|
|
414
|
-
variant: companionId === companion.id ? "primary" : "ghost",
|
|
415
|
-
onClick: () => handleTabClick(companion)
|
|
416
|
-
}))), /* @__PURE__ */ React6.createElement(Toolbar2.Separator, {
|
|
417
|
-
variant: "gap"
|
|
418
|
-
}), /* @__PURE__ */ React6.createElement(Toolbar2.IconButton, {
|
|
419
|
-
icon: isFullyExpanded ? "ph--arrow-down--regular" : "ph--arrow-up--regular",
|
|
420
|
-
iconOnly: true,
|
|
421
|
-
label: isFullyExpanded ? t("collapse drawer label") : t("expand drawer label"),
|
|
422
|
-
onClick: handleToggleExpand
|
|
423
|
-
}), /* @__PURE__ */ React6.createElement(Toolbar2.IconButton, {
|
|
424
|
-
icon: "ph--x--regular",
|
|
425
|
-
iconOnly: true,
|
|
426
|
-
label: t("close drawer label"),
|
|
427
|
-
onClick: handleClose
|
|
428
|
-
})), /* @__PURE__ */ React6.createElement(Surface3, {
|
|
429
|
-
role: "article",
|
|
430
|
-
data,
|
|
431
|
-
limit: 1,
|
|
432
|
-
fallback: ContentError,
|
|
433
|
-
placeholder
|
|
434
|
-
}));
|
|
435
|
-
};
|
|
436
|
-
Drawer.displayName = DRAWER_NAME;
|
|
437
|
-
var parseEntryId = (entryId) => {
|
|
438
|
-
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
439
|
-
return {
|
|
440
|
-
id,
|
|
441
|
-
variant
|
|
442
|
-
};
|
|
443
|
-
};
|
|
444
|
-
var useSelectedCompanion = (companions, preferredVariant) => {
|
|
445
|
-
const selectedCompanion = useMemo4(() => {
|
|
446
|
-
if (companions.length === 0) {
|
|
447
|
-
return void 0;
|
|
448
|
-
}
|
|
449
|
-
if (preferredVariant) {
|
|
450
|
-
const preferred = companions.find((c) => {
|
|
451
|
-
const { variant: variant2 } = parseEntryId(c.id);
|
|
452
|
-
return variant2 === preferredVariant;
|
|
453
|
-
});
|
|
454
|
-
if (preferred) {
|
|
455
|
-
return preferred;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
return companions[0];
|
|
459
|
-
}, [
|
|
460
|
-
companions,
|
|
461
|
-
preferredVariant
|
|
462
|
-
]);
|
|
463
|
-
const companionId = selectedCompanion?.id;
|
|
464
|
-
const { variant } = parseEntryId(companionId ?? "");
|
|
465
|
-
return {
|
|
466
|
-
selectedCompanion,
|
|
467
|
-
companionId,
|
|
468
|
-
variant
|
|
469
|
-
};
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
// src/components/SimpleLayout/Main.tsx
|
|
473
|
-
import React9, { useMemo as useMemo6 } from "react";
|
|
474
|
-
import { Surface as Surface4, useAppGraph as useAppGraph7 } from "@dxos/app-framework/react";
|
|
475
|
-
import { useNode as useNode2 } from "@dxos/plugin-graph";
|
|
476
|
-
import { Main as NaturalMain2, useSidebars } from "@dxos/react-ui";
|
|
477
|
-
import { mx as mx5 } from "@dxos/ui-theme";
|
|
478
|
-
|
|
479
|
-
// src/components/SimpleLayout/Banner.tsx
|
|
480
|
-
import React7, { Fragment, useCallback as useCallback5, useMemo as useMemo5 } from "react";
|
|
481
|
-
import { Common as Common2 } from "@dxos/app-framework";
|
|
482
|
-
import { useAppGraph as useAppGraph5, useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/react";
|
|
483
|
-
import { Graph as Graph2, Node as Node2, useActionRunner, useActions } from "@dxos/plugin-graph";
|
|
484
|
-
import { IconButton as IconButton2, Popover as Popover2, Toolbar as Toolbar3, toLocalizedString as toLocalizedString4, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
485
|
-
import { DropdownMenu, MenuProvider } from "@dxos/react-ui-menu";
|
|
486
|
-
import { mx as mx3, osTranslations } from "@dxos/ui-theme";
|
|
487
|
-
var isWorkspaceOrCollectionChild = (graph, itemId) => {
|
|
488
|
-
const parents = Graph2.getConnections(graph, itemId, "inbound");
|
|
489
|
-
return parents.some((node) => node.properties.disposition === "workspace" || node.properties.disposition === "collection");
|
|
490
|
-
};
|
|
491
|
-
var Banner = ({ node, classNames }) => {
|
|
492
|
-
const { t } = useTranslation5(meta.id);
|
|
493
|
-
const { state } = useSimpleLayoutState();
|
|
494
|
-
const { invokePromise } = useOperationInvoker2();
|
|
495
|
-
const { graph } = useAppGraph5();
|
|
496
|
-
const runAction = useActionRunner();
|
|
497
|
-
const label = (node && toLocalizedString4(node.properties.label, t)) ?? t("current app name", {
|
|
498
|
-
ns: osTranslations
|
|
499
|
-
});
|
|
500
|
-
const allActions = useActions(graph, node?.id);
|
|
501
|
-
const actions = useMemo5(() => {
|
|
502
|
-
return allActions.filter((a) => [
|
|
503
|
-
"list-item",
|
|
504
|
-
"list-item-primary",
|
|
505
|
-
"heading-list-item"
|
|
506
|
-
].includes(a.properties.disposition));
|
|
507
|
-
}, [
|
|
508
|
-
allActions
|
|
509
|
-
]);
|
|
510
|
-
const isTopLevelItem = useMemo5(() => {
|
|
511
|
-
if (!state.active) {
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
return isWorkspaceOrCollectionChild(graph, state.active);
|
|
515
|
-
}, [
|
|
516
|
-
graph,
|
|
517
|
-
state.active
|
|
518
|
-
]);
|
|
519
|
-
const handleClick = useCallback5(async () => {
|
|
520
|
-
if (state.active) {
|
|
521
|
-
if (state.history.length === 0 && isTopLevelItem) {
|
|
522
|
-
await invokePromise(Common2.LayoutOperation.SwitchWorkspace, {
|
|
523
|
-
subject: Node2.RootId
|
|
524
|
-
});
|
|
525
|
-
} else {
|
|
526
|
-
await invokePromise(Common2.LayoutOperation.Close, {
|
|
527
|
-
subject: [
|
|
528
|
-
state.active
|
|
529
|
-
]
|
|
530
|
-
});
|
|
531
|
-
}
|
|
532
|
-
} else {
|
|
533
|
-
await invokePromise(Common2.LayoutOperation.SwitchWorkspace, {
|
|
534
|
-
subject: Node2.RootId
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
}, [
|
|
538
|
-
invokePromise,
|
|
539
|
-
state.active,
|
|
540
|
-
state.history.length,
|
|
541
|
-
isTopLevelItem
|
|
542
|
-
]);
|
|
543
|
-
const AnchorRoot = node && state.popoverAnchorId === `dxos.org/ui/${meta.id}/${node.id}` ? Popover2.Anchor : Fragment;
|
|
544
|
-
if (!node) {
|
|
545
|
-
return null;
|
|
546
|
-
}
|
|
547
|
-
return /* @__PURE__ */ React7.createElement(Toolbar3.Root, {
|
|
548
|
-
role: "banner",
|
|
549
|
-
classNames: mx3("grid grid-cols-[var(--rail-size)_1fr_var(--rail-size)]", classNames)
|
|
550
|
-
}, node.id !== Node2.RootId ? /* @__PURE__ */ React7.createElement(IconButton2, {
|
|
551
|
-
iconOnly: true,
|
|
552
|
-
variant: "ghost",
|
|
553
|
-
icon: "ph--caret-left--regular",
|
|
554
|
-
label: t("back label"),
|
|
555
|
-
onClick: handleClick
|
|
556
|
-
}) : /* @__PURE__ */ React7.createElement("div", null), /* @__PURE__ */ React7.createElement("h1", {
|
|
557
|
-
className: "grow text-center truncate font-medium"
|
|
558
|
-
}, label), actions.length > 0 ? /* @__PURE__ */ React7.createElement(AnchorRoot, null, /* @__PURE__ */ React7.createElement(MenuProvider, {
|
|
559
|
-
onAction: runAction
|
|
560
|
-
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
561
|
-
items: actions,
|
|
562
|
-
caller: meta.id
|
|
563
|
-
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
564
|
-
asChild: true
|
|
565
|
-
}, /* @__PURE__ */ React7.createElement(IconButton2, {
|
|
566
|
-
iconOnly: true,
|
|
567
|
-
variant: "ghost",
|
|
568
|
-
icon: "ph--dots-three-vertical--regular",
|
|
569
|
-
label: t("actions menu label")
|
|
570
|
-
}))))) : /* @__PURE__ */ React7.createElement("span", null));
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
// src/components/SimpleLayout/NavBar.tsx
|
|
574
|
-
import React8 from "react";
|
|
575
|
-
import { Common as Common3 } from "@dxos/app-framework";
|
|
576
|
-
import { useAppGraph as useAppGraph6, useOperationInvoker as useOperationInvoker3 } from "@dxos/app-framework/react";
|
|
577
|
-
import { Node as Node3, useActionRunner as useActionRunner2, useConnections as useConnections3 } from "@dxos/plugin-graph";
|
|
578
|
-
import { IconButton as IconButton3, Toolbar as Toolbar4, Tooltip, toLocalizedString as toLocalizedString5, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
579
|
-
import { DropdownMenu as DropdownMenu2, MenuProvider as MenuProvider2 } from "@dxos/react-ui-menu";
|
|
580
|
-
import { mx as mx4 } from "@dxos/ui-theme";
|
|
581
|
-
var NAVBAR_NAME = "SimpleLayout.NavBar";
|
|
582
|
-
var NavBar = ({ classNames, activeId }) => {
|
|
583
|
-
const { t } = useTranslation6(meta.id);
|
|
584
|
-
const { graph } = useAppGraph6();
|
|
585
|
-
const runAction = useActionRunner2();
|
|
586
|
-
const { invokePromise } = useOperationInvoker3();
|
|
587
|
-
const connections = useConnections3(graph, Node3.RootId);
|
|
588
|
-
const menuActions = connections.filter((node) => node.properties.disposition === "menu");
|
|
589
|
-
const companions = useCompanions(activeId);
|
|
590
|
-
return /* @__PURE__ */ React8.createElement(Toolbar4.Root, {
|
|
591
|
-
classNames: mx4("justify-center", classNames)
|
|
592
|
-
}, companions.map((companion) => /* @__PURE__ */ React8.createElement(Toolbar4.IconButton, {
|
|
593
|
-
key: companion.id,
|
|
594
|
-
icon: companion.properties.icon ?? "ph--placeholder--regular",
|
|
595
|
-
iconOnly: true,
|
|
596
|
-
label: toLocalizedString5(companion.properties.label, t),
|
|
597
|
-
onClick: () => {
|
|
598
|
-
void invokePromise(Common3.LayoutOperation.Open, {
|
|
599
|
-
subject: [
|
|
600
|
-
companion.id
|
|
601
|
-
]
|
|
602
|
-
});
|
|
603
|
-
}
|
|
604
|
-
})), /* @__PURE__ */ React8.createElement(Toolbar4.Separator, {
|
|
605
|
-
variant: "gap"
|
|
606
|
-
}), /* @__PURE__ */ React8.createElement(MenuProvider2, {
|
|
607
|
-
onAction: runAction
|
|
608
|
-
}, /* @__PURE__ */ React8.createElement(DropdownMenu2.Root, {
|
|
609
|
-
items: menuActions
|
|
610
|
-
}, /* @__PURE__ */ React8.createElement(Tooltip.Trigger, {
|
|
611
|
-
asChild: true,
|
|
612
|
-
content: t("app menu label")
|
|
613
|
-
}, /* @__PURE__ */ React8.createElement(DropdownMenu2.Trigger, {
|
|
614
|
-
asChild: true,
|
|
615
|
-
"data-testid": "simpleLayoutPlugin.addSpace"
|
|
616
|
-
}, /* @__PURE__ */ React8.createElement(IconButton3, {
|
|
617
|
-
icon: "ph--plus--regular",
|
|
618
|
-
iconOnly: true,
|
|
619
|
-
label: t("main menu label")
|
|
620
|
-
}))))));
|
|
621
|
-
};
|
|
622
|
-
NavBar.displayName = NAVBAR_NAME;
|
|
623
|
-
|
|
624
|
-
// src/components/SimpleLayout/Main.tsx
|
|
625
|
-
var MAIN_NAME = "SimpleLayout.Main";
|
|
626
|
-
var Main = () => {
|
|
627
|
-
const { state } = useSimpleLayoutState();
|
|
628
|
-
const { graph } = useAppGraph7();
|
|
629
|
-
const id = state.active ?? state.workspace;
|
|
630
|
-
const node = useNode2(graph, id);
|
|
631
|
-
useLoadDescendents(id);
|
|
632
|
-
const placeholder = useMemo6(() => /* @__PURE__ */ React9.createElement(ContentLoading, null), []);
|
|
633
|
-
const data = useMemo6(() => {
|
|
634
|
-
return node && {
|
|
635
|
-
attendableId: id,
|
|
636
|
-
subject: node.data,
|
|
637
|
-
properties: node.properties,
|
|
638
|
-
popoverAnchorId: state.popoverAnchorId
|
|
639
|
-
};
|
|
640
|
-
}, [
|
|
641
|
-
id,
|
|
642
|
-
node,
|
|
643
|
-
node?.data,
|
|
644
|
-
node?.properties,
|
|
645
|
-
state.popoverAnchorId
|
|
646
|
-
]);
|
|
647
|
-
const { drawerState } = useSidebars(MAIN_NAME);
|
|
648
|
-
const showNavBar = !state.isPopover && drawerState === "closed";
|
|
649
|
-
return /* @__PURE__ */ React9.createElement(NaturalMain2.Content, {
|
|
650
|
-
bounce: true,
|
|
651
|
-
classNames: mx5("bs-full", "pbs-[env(safe-area-inset-top)] pbe-[env(safe-area-inset-bottom)]")
|
|
652
|
-
}, /* @__PURE__ */ React9.createElement("div", {
|
|
653
|
-
role: "none",
|
|
654
|
-
className: mx5("grid bs-full overflow-hidden", showNavBar ? "grid-rows-[min-content_1fr_min-content]" : "grid-rows-[min-content_1fr]")
|
|
655
|
-
}, /* @__PURE__ */ React9.createElement(Banner, {
|
|
656
|
-
classNames: "border-be border-separator",
|
|
657
|
-
node
|
|
658
|
-
}), /* @__PURE__ */ React9.createElement("article", {
|
|
659
|
-
className: "bs-full overflow-hidden"
|
|
660
|
-
}, /* @__PURE__ */ React9.createElement(Surface4, {
|
|
661
|
-
key: id,
|
|
662
|
-
role: "article",
|
|
663
|
-
data,
|
|
664
|
-
limit: 1,
|
|
665
|
-
fallback: ContentError,
|
|
666
|
-
placeholder
|
|
667
|
-
})), showNavBar && /* @__PURE__ */ React9.createElement(NavBar, {
|
|
668
|
-
classNames: "border-bs border-separator",
|
|
669
|
-
activeId: id
|
|
670
|
-
})));
|
|
671
|
-
};
|
|
672
|
-
Main.displayName = MAIN_NAME;
|
|
673
|
-
|
|
674
|
-
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
675
|
-
var SimpleLayout = () => {
|
|
676
|
-
const { state, updateState } = useSimpleLayoutState();
|
|
677
|
-
const handleDrawerStateChange = useCallback6((nextState) => {
|
|
678
|
-
updateState((s) => ({
|
|
679
|
-
...s,
|
|
680
|
-
drawerState: nextState
|
|
681
|
-
}));
|
|
682
|
-
}, [
|
|
683
|
-
updateState
|
|
684
|
-
]);
|
|
685
|
-
return /* @__PURE__ */ React10.createElement(Mosaic2.Root, null, /* @__PURE__ */ React10.createElement(NaturalMain3.Root, {
|
|
686
|
-
drawerState: state.drawerState ?? "closed",
|
|
687
|
-
onDrawerStateChange: handleDrawerStateChange
|
|
688
|
-
}, /* @__PURE__ */ React10.createElement(PopoverRoot, null, /* @__PURE__ */ React10.createElement(Main, null), /* @__PURE__ */ React10.createElement(Drawer, null), /* @__PURE__ */ React10.createElement(Dialog, null), /* @__PURE__ */ React10.createElement(PopoverContent, null))));
|
|
689
|
-
};
|
|
690
|
-
|
|
691
|
-
// src/components/Workspace/Workspace.tsx
|
|
692
|
-
import React11, { useCallback as useCallback7, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
693
|
-
import { Common as Common4 } from "@dxos/app-framework";
|
|
694
|
-
import { useAppGraph as useAppGraph8, useOperationInvoker as useOperationInvoker4 } from "@dxos/app-framework/react";
|
|
695
|
-
import { useConnections as useConnections4 } from "@dxos/plugin-graph";
|
|
696
|
-
import { Avatar as Avatar2, Icon as Icon2, Toolbar as Toolbar5, toLocalizedString as toLocalizedString6, useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
697
|
-
import { Card as Card3, Layout as Layout2, Mosaic as Mosaic3 } from "@dxos/react-ui-mosaic";
|
|
698
|
-
import { SearchList as SearchList2, useSearchListItem as useSearchListItem2, useSearchListResults as useSearchListResults2 } from "@dxos/react-ui-searchlist";
|
|
699
|
-
import { mx as mx6 } from "@dxos/ui-theme";
|
|
700
|
-
var Workspace = ({ id }) => {
|
|
701
|
-
const { t } = useTranslation7(meta.id);
|
|
702
|
-
const { graph } = useAppGraph8();
|
|
703
|
-
useLoadDescendents(id);
|
|
704
|
-
const children = useConnections4(graph, id, "outbound");
|
|
705
|
-
const { results, handleSearch } = useSearchListResults2({
|
|
706
|
-
items: children,
|
|
707
|
-
extract: (child) => toLocalizedString6(child.properties.label, t)
|
|
708
|
-
});
|
|
709
|
-
return /* @__PURE__ */ React11.createElement(Layout2.Main, {
|
|
710
|
-
toolbar: true
|
|
711
|
-
}, /* @__PURE__ */ React11.createElement(SearchList2.Root, {
|
|
712
|
-
onSearch: handleSearch
|
|
713
|
-
}, /* @__PURE__ */ React11.createElement(Toolbar5.Root, null, /* @__PURE__ */ React11.createElement(SearchList2.Input, {
|
|
714
|
-
placeholder: t("search placeholder"),
|
|
715
|
-
autoFocus: true
|
|
716
|
-
})), /* @__PURE__ */ React11.createElement(SearchList2.Content, null, /* @__PURE__ */ React11.createElement(Mosaic3.Container, {
|
|
717
|
-
asChild: true
|
|
718
|
-
}, /* @__PURE__ */ React11.createElement(Mosaic3.Viewport, {
|
|
719
|
-
padding: true
|
|
720
|
-
}, /* @__PURE__ */ React11.createElement(Mosaic3.Stack, {
|
|
721
|
-
items: results,
|
|
722
|
-
getId: (child) => child.id,
|
|
723
|
-
Tile: WorkspaceChildTile
|
|
724
|
-
}))))));
|
|
725
|
-
};
|
|
726
|
-
var WorkspaceChildTile = ({ data }) => {
|
|
727
|
-
const { t } = useTranslation7(meta.id);
|
|
728
|
-
const { invokeSync } = useOperationInvoker4();
|
|
729
|
-
const ref = useRef3(null);
|
|
730
|
-
const { selectedValue, registerItem, unregisterItem } = useSearchListItem2();
|
|
731
|
-
const isSelected = selectedValue === data.id;
|
|
732
|
-
const name = toLocalizedString6(data.properties.label, t);
|
|
733
|
-
const handleSelect = useCallback7(() => invokeSync(Common4.LayoutOperation.Open, {
|
|
734
|
-
subject: [
|
|
735
|
-
data.id
|
|
736
|
-
]
|
|
737
|
-
}), [
|
|
738
|
-
invokeSync,
|
|
739
|
-
data.id
|
|
740
|
-
]);
|
|
741
|
-
useEffect4(() => {
|
|
742
|
-
if (ref.current) {
|
|
743
|
-
registerItem(data.id, ref.current, handleSelect);
|
|
744
|
-
}
|
|
745
|
-
return () => unregisterItem(data.id);
|
|
746
|
-
}, [
|
|
747
|
-
data.id,
|
|
748
|
-
handleSelect,
|
|
749
|
-
registerItem,
|
|
750
|
-
unregisterItem
|
|
751
|
-
]);
|
|
752
|
-
useEffect4(() => {
|
|
753
|
-
if (isSelected && ref.current) {
|
|
754
|
-
ref.current.scrollIntoView({
|
|
755
|
-
block: "nearest",
|
|
756
|
-
behavior: "smooth"
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
}, [
|
|
760
|
-
isSelected
|
|
761
|
-
]);
|
|
762
|
-
return /* @__PURE__ */ React11.createElement(Card3.Root, {
|
|
763
|
-
ref,
|
|
764
|
-
role: "button",
|
|
765
|
-
fullWidth: true,
|
|
766
|
-
tabIndex: -1,
|
|
767
|
-
"data-selected": isSelected,
|
|
768
|
-
classNames: mx6("dx-focus-ring", isSelected && "bg-hoverOverlay"),
|
|
769
|
-
onClick: handleSelect
|
|
770
|
-
}, /* @__PURE__ */ React11.createElement(Card3.Toolbar, {
|
|
771
|
-
density: "coarse"
|
|
772
|
-
}, /* @__PURE__ */ React11.createElement(Avatar2.Root, null, /* @__PURE__ */ React11.createElement(Avatar2.Content, {
|
|
773
|
-
hue: data.properties.hue,
|
|
774
|
-
icon: data.properties.icon,
|
|
775
|
-
hueVariant: "transparent",
|
|
776
|
-
variant: "square",
|
|
777
|
-
size: 12,
|
|
778
|
-
fallback: name
|
|
779
|
-
}), /* @__PURE__ */ React11.createElement(Avatar2.Label, null, name), /* @__PURE__ */ React11.createElement(Icon2, {
|
|
780
|
-
icon: "ph--caret-right--regular"
|
|
781
|
-
}))));
|
|
782
|
-
};
|
|
783
|
-
|
|
784
|
-
export {
|
|
785
|
-
Home,
|
|
786
|
-
SimpleLayout,
|
|
787
|
-
Workspace
|
|
788
|
-
};
|
|
789
|
-
//# sourceMappingURL=chunk-LR3EE3VB.mjs.map
|