@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
|
@@ -0,0 +1,1170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimpleLayoutState,
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-7VLT3S46.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/Home/Home.tsx
|
|
7
|
+
import React, { useCallback, useEffect as useEffect2, useMemo, useRef } from "react";
|
|
8
|
+
import { useOperationInvoker } from "@dxos/app-framework/ui";
|
|
9
|
+
import { LayoutOperation } from "@dxos/app-toolkit";
|
|
10
|
+
import { useAppGraph as useAppGraph2 } from "@dxos/app-toolkit/ui";
|
|
11
|
+
import { Node, useConnections } from "@dxos/plugin-graph";
|
|
12
|
+
import { Avatar, Icon, Panel, ScrollArea, Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
13
|
+
import { Card } from "@dxos/react-ui";
|
|
14
|
+
import { Mosaic } from "@dxos/react-ui-mosaic";
|
|
15
|
+
import { SearchList, useSearchListItem, useSearchListResults } from "@dxos/react-ui-searchlist";
|
|
16
|
+
import { mx } from "@dxos/ui-theme";
|
|
17
|
+
import { byPosition } from "@dxos/util";
|
|
18
|
+
|
|
19
|
+
// src/components/hooks.ts
|
|
20
|
+
import { useEffect } from "react";
|
|
21
|
+
import { useAppGraph } from "@dxos/app-toolkit/ui";
|
|
22
|
+
import { Graph } from "@dxos/plugin-graph";
|
|
23
|
+
var useLoadDescendents = (nodeId) => {
|
|
24
|
+
const { graph } = useAppGraph();
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (nodeId) {
|
|
27
|
+
Graph.expand(graph, nodeId, "child");
|
|
28
|
+
Graph.getConnections(graph, nodeId, "child").forEach((child) => {
|
|
29
|
+
Graph.expand(graph, child.id, "child");
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}, [
|
|
33
|
+
nodeId,
|
|
34
|
+
graph
|
|
35
|
+
]);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/components/Home/Home.tsx
|
|
39
|
+
var Home = (_) => {
|
|
40
|
+
const { t } = useTranslation(meta.id);
|
|
41
|
+
const userAccountItem = useItemsByDisposition("user-account")[0];
|
|
42
|
+
const pinnedItems = useItemsByDisposition("pin-end", true);
|
|
43
|
+
const workspaceItems = useItemsByDisposition("workspace");
|
|
44
|
+
useLoadDescendents(Node.RootId);
|
|
45
|
+
const items = useMemo(() => [
|
|
46
|
+
...userAccountItem ? [
|
|
47
|
+
userAccountItem
|
|
48
|
+
] : [],
|
|
49
|
+
...pinnedItems,
|
|
50
|
+
...workspaceItems
|
|
51
|
+
], [
|
|
52
|
+
userAccountItem,
|
|
53
|
+
pinnedItems,
|
|
54
|
+
workspaceItems
|
|
55
|
+
]);
|
|
56
|
+
const { results, handleSearch } = useSearchListResults({
|
|
57
|
+
items,
|
|
58
|
+
extract: (node) => toLocalizedString(node.properties.label, t)
|
|
59
|
+
});
|
|
60
|
+
return /* @__PURE__ */ React.createElement(SearchList.Root, {
|
|
61
|
+
onSearch: handleSearch
|
|
62
|
+
}, /* @__PURE__ */ React.createElement(Panel.Root, null, /* @__PURE__ */ React.createElement(Panel.Toolbar, {
|
|
63
|
+
asChild: true
|
|
64
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(SearchList.Input, {
|
|
65
|
+
placeholder: t("search placeholder"),
|
|
66
|
+
autoFocus: true
|
|
67
|
+
}))), /* @__PURE__ */ React.createElement(Panel.Content, {
|
|
68
|
+
asChild: true
|
|
69
|
+
}, /* @__PURE__ */ React.createElement(SearchList.Content, null, /* @__PURE__ */ React.createElement(Mosaic.Container, {
|
|
70
|
+
asChild: true
|
|
71
|
+
}, /* @__PURE__ */ React.createElement(ScrollArea.Root, {
|
|
72
|
+
orientation: "vertical"
|
|
73
|
+
}, /* @__PURE__ */ React.createElement(ScrollArea.Viewport, {
|
|
74
|
+
classNames: "p-2"
|
|
75
|
+
}, /* @__PURE__ */ React.createElement(Mosaic.Stack, {
|
|
76
|
+
items: results,
|
|
77
|
+
getId: (node) => node.id,
|
|
78
|
+
Tile: WorkspaceTile
|
|
79
|
+
}))))))));
|
|
80
|
+
};
|
|
81
|
+
var WorkspaceTile = (props) => {
|
|
82
|
+
const data = props.data;
|
|
83
|
+
const { t } = useTranslation(meta.id);
|
|
84
|
+
const { invokePromise } = useOperationInvoker();
|
|
85
|
+
const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
|
|
86
|
+
const name = toLocalizedString(data.properties.label, t);
|
|
87
|
+
const isSelected = selectedValue === data.id;
|
|
88
|
+
const cardRef = useRef(null);
|
|
89
|
+
useLoadDescendents(data.id);
|
|
90
|
+
const handleSelect = useCallback(() => invokePromise(LayoutOperation.SwitchWorkspace, {
|
|
91
|
+
subject: data.id
|
|
92
|
+
}), [
|
|
93
|
+
invokePromise,
|
|
94
|
+
data.id
|
|
95
|
+
]);
|
|
96
|
+
useEffect2(() => {
|
|
97
|
+
if (cardRef.current) {
|
|
98
|
+
registerItem(data.id, cardRef.current, handleSelect);
|
|
99
|
+
}
|
|
100
|
+
return () => unregisterItem(data.id);
|
|
101
|
+
}, [
|
|
102
|
+
data.id,
|
|
103
|
+
handleSelect,
|
|
104
|
+
registerItem,
|
|
105
|
+
unregisterItem
|
|
106
|
+
]);
|
|
107
|
+
useEffect2(() => {
|
|
108
|
+
if (isSelected && cardRef.current) {
|
|
109
|
+
cardRef.current.scrollIntoView({
|
|
110
|
+
block: "nearest",
|
|
111
|
+
behavior: "smooth"
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}, [
|
|
115
|
+
isSelected
|
|
116
|
+
]);
|
|
117
|
+
return /* @__PURE__ */ React.createElement(Card.Root, {
|
|
118
|
+
role: "button",
|
|
119
|
+
fullWidth: true,
|
|
120
|
+
tabIndex: -1,
|
|
121
|
+
"data-selected": isSelected,
|
|
122
|
+
classNames: mx("dx-focus-ring", isSelected && "bg-hover-overlay"),
|
|
123
|
+
onClick: handleSelect,
|
|
124
|
+
ref: cardRef
|
|
125
|
+
}, /* @__PURE__ */ React.createElement(Card.Toolbar, {
|
|
126
|
+
density: "coarse"
|
|
127
|
+
}, /* @__PURE__ */ React.createElement(Avatar.Root, null, /* @__PURE__ */ React.createElement(Avatar.Content, {
|
|
128
|
+
icon: data.properties.icon,
|
|
129
|
+
hue: data.properties.hue,
|
|
130
|
+
hueVariant: "transparent",
|
|
131
|
+
variant: "square",
|
|
132
|
+
size: 12,
|
|
133
|
+
fallback: name
|
|
134
|
+
}), /* @__PURE__ */ React.createElement(Avatar.Label, null, name), /* @__PURE__ */ React.createElement(Icon, {
|
|
135
|
+
icon: "ph--caret-right--regular"
|
|
136
|
+
}))));
|
|
137
|
+
};
|
|
138
|
+
var filterItems = (node, disposition) => {
|
|
139
|
+
return node.properties.disposition === disposition;
|
|
140
|
+
};
|
|
141
|
+
var useItemsByDisposition = (disposition, sort = false) => {
|
|
142
|
+
const { graph } = useAppGraph2();
|
|
143
|
+
const connections = useConnections(graph, Node.RootId, "child");
|
|
144
|
+
const filtered = connections.filter((node) => filterItems(node, disposition));
|
|
145
|
+
return sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
149
|
+
import React11, { useEffect as useEffect6, useRef as useRef4, useState as useState3 } from "react";
|
|
150
|
+
import { Splitter } from "@dxos/react-ui";
|
|
151
|
+
import { Mosaic as Mosaic3 } from "@dxos/react-ui-mosaic";
|
|
152
|
+
|
|
153
|
+
// src/hooks/useAppBarProps.ts
|
|
154
|
+
import { Atom, useAtomValue } from "@effect-atom/atom-react";
|
|
155
|
+
import * as Effect from "effect/Effect";
|
|
156
|
+
import * as Option from "effect/Option";
|
|
157
|
+
import { useCallback as useCallback2, useMemo as useMemo2 } from "react";
|
|
158
|
+
import { useCapability, useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/ui";
|
|
159
|
+
import { LayoutOperation as LayoutOperation2 } from "@dxos/app-toolkit";
|
|
160
|
+
import { useAppGraph as useAppGraph3 } from "@dxos/app-toolkit/ui";
|
|
161
|
+
import { Graph as Graph2, Node as Node2, useActionRunner, useNode } from "@dxos/plugin-graph";
|
|
162
|
+
import { toLocalizedString as toLocalizedString2, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
163
|
+
var useAppBarProps = () => {
|
|
164
|
+
const { t } = useTranslation2(meta.id);
|
|
165
|
+
const stateAtom = useCapability(SimpleLayoutState);
|
|
166
|
+
const state = useAtomValue(stateAtom);
|
|
167
|
+
const { graph } = useAppGraph3();
|
|
168
|
+
const { invokeSync } = useOperationInvoker2();
|
|
169
|
+
const runAction = useActionRunner();
|
|
170
|
+
const activeId = state.active ?? state.workspace;
|
|
171
|
+
const node = useNode(graph, activeId);
|
|
172
|
+
const title = node ? toLocalizedString2(node.properties.label, t) : void 0;
|
|
173
|
+
const actionsAtom = useMemo2(() => Atom.make((get) => {
|
|
174
|
+
const state2 = get(stateAtom);
|
|
175
|
+
const activeId2 = state2.active ?? state2.workspace;
|
|
176
|
+
const allActions = activeId2 ? get(graph.actions(activeId2)) : [];
|
|
177
|
+
const filtered = allActions.filter((action) => [
|
|
178
|
+
"list-item",
|
|
179
|
+
"list-item-primary",
|
|
180
|
+
"heading-list-item"
|
|
181
|
+
].includes(action.properties.disposition));
|
|
182
|
+
const nodes = filtered;
|
|
183
|
+
const edges = filtered.map((action) => ({
|
|
184
|
+
source: "root",
|
|
185
|
+
target: action.id,
|
|
186
|
+
relation: "child"
|
|
187
|
+
}));
|
|
188
|
+
const workspaceConnections = state2.workspace ? get(graph.connections(state2.workspace, "child")) : [];
|
|
189
|
+
const alternateTreeNode = workspaceConnections.find((node2) => node2.properties.disposition === "alternate-tree");
|
|
190
|
+
if (alternateTreeNode && activeId2 !== alternateTreeNode.id) {
|
|
191
|
+
const settingsAction = {
|
|
192
|
+
id: `appbar-settings-${alternateTreeNode.id}`,
|
|
193
|
+
type: Node2.ActionType,
|
|
194
|
+
data: () => Effect.sync(() => invokeSync(LayoutOperation2.Open, {
|
|
195
|
+
subject: [
|
|
196
|
+
alternateTreeNode.id
|
|
197
|
+
]
|
|
198
|
+
})),
|
|
199
|
+
properties: {
|
|
200
|
+
label: alternateTreeNode.properties.label ?? alternateTreeNode.id,
|
|
201
|
+
icon: alternateTreeNode.properties.icon ?? "ph--placeholder--regular"
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
nodes.push(settingsAction);
|
|
205
|
+
edges.push({
|
|
206
|
+
source: "root",
|
|
207
|
+
target: settingsAction.id,
|
|
208
|
+
relation: "child"
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
nodes,
|
|
213
|
+
edges
|
|
214
|
+
};
|
|
215
|
+
}), [
|
|
216
|
+
graph,
|
|
217
|
+
stateAtom
|
|
218
|
+
]);
|
|
219
|
+
const showBackButton = activeId !== void 0 && activeId !== Node2.RootId;
|
|
220
|
+
const onBack = useCallback2(() => {
|
|
221
|
+
if (state.active) {
|
|
222
|
+
const isWorkspace = Graph2.getNode(graph, state.active).pipe(Option.map((node2) => node2.properties.disposition === "workspace"), Option.getOrElse(() => false));
|
|
223
|
+
if (state.history.length === 0 && isWorkspace) {
|
|
224
|
+
invokeSync(LayoutOperation2.SwitchWorkspace, {
|
|
225
|
+
subject: Node2.RootId
|
|
226
|
+
});
|
|
227
|
+
} else {
|
|
228
|
+
invokeSync(LayoutOperation2.Close, {
|
|
229
|
+
subject: [
|
|
230
|
+
state.active
|
|
231
|
+
]
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
invokeSync(LayoutOperation2.SwitchWorkspace, {
|
|
236
|
+
subject: Node2.RootId
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
}, [
|
|
240
|
+
graph,
|
|
241
|
+
invokeSync,
|
|
242
|
+
state.active,
|
|
243
|
+
state.history.length
|
|
244
|
+
]);
|
|
245
|
+
const popoverAnchorId = node && state.popoverAnchorId === `dxos.org/ui/${meta.id}/${node.id}` ? state.popoverAnchorId : void 0;
|
|
246
|
+
return {
|
|
247
|
+
title,
|
|
248
|
+
actions: actionsAtom,
|
|
249
|
+
showBackButton,
|
|
250
|
+
popoverAnchorId,
|
|
251
|
+
onBack,
|
|
252
|
+
onAction: runAction
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// src/hooks/useCompanions.ts
|
|
257
|
+
import { useMemo as useMemo3 } from "react";
|
|
258
|
+
import { useAppGraph as useAppGraph4 } from "@dxos/app-toolkit/ui";
|
|
259
|
+
import { useConnections as useConnections2 } from "@dxos/plugin-graph";
|
|
260
|
+
import { byPosition as byPosition3 } from "@dxos/util";
|
|
261
|
+
|
|
262
|
+
// src/hooks/actions.ts
|
|
263
|
+
import * as Effect2 from "effect/Effect";
|
|
264
|
+
import { LayoutOperation as LayoutOperation3 } from "@dxos/app-toolkit";
|
|
265
|
+
import { Node as Node3 } from "@dxos/plugin-graph";
|
|
266
|
+
import { ATTENDABLE_PATH_SEPARATOR } from "@dxos/react-ui-attention";
|
|
267
|
+
import { byPosition as byPosition2 } from "@dxos/util";
|
|
268
|
+
var PLANK_COMPANION_TYPE = "dxos.org/plugin/deck/plank-companion";
|
|
269
|
+
var createCompanionActions = (graph, stateAtom, get, config) => {
|
|
270
|
+
const { idPrefix, selectedVariant, invokeSync } = config;
|
|
271
|
+
const state = get(stateAtom);
|
|
272
|
+
const activeId = state.active ?? state.workspace;
|
|
273
|
+
const activeConnections = activeId ? get(graph.connections(activeId, "child")) : [];
|
|
274
|
+
const companions = activeConnections.filter((node) => node.type === PLANK_COMPANION_TYPE).toSorted((a, b) => byPosition2(a.properties, b.properties));
|
|
275
|
+
const nodes = [];
|
|
276
|
+
const edges = [];
|
|
277
|
+
companions.forEach((companion) => {
|
|
278
|
+
const [, companionVariant] = companion.id.split(ATTENDABLE_PATH_SEPARATOR);
|
|
279
|
+
const companionAction = {
|
|
280
|
+
id: `${idPrefix}-companion-${companion.id}`,
|
|
281
|
+
type: Node3.ActionType,
|
|
282
|
+
properties: {
|
|
283
|
+
icon: companion.properties.icon ?? "ph--placeholder--regular",
|
|
284
|
+
label: companion.properties.label,
|
|
285
|
+
iconOnly: true,
|
|
286
|
+
// Conditionally add variant highlighting.
|
|
287
|
+
...selectedVariant !== void 0 && {
|
|
288
|
+
variant: selectedVariant === companionVariant ? "primary" : "ghost"
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
data: () => Effect2.sync(() => invokeSync(LayoutOperation3.Open, {
|
|
292
|
+
subject: [
|
|
293
|
+
companion.id
|
|
294
|
+
]
|
|
295
|
+
}))
|
|
296
|
+
};
|
|
297
|
+
nodes.push(companionAction);
|
|
298
|
+
edges.push({
|
|
299
|
+
source: "root",
|
|
300
|
+
target: companionAction.id,
|
|
301
|
+
relation: "child"
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
return {
|
|
305
|
+
nodes,
|
|
306
|
+
edges
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
// src/hooks/useCompanions.ts
|
|
311
|
+
var useCompanions = (nodeId) => {
|
|
312
|
+
const { graph } = useAppGraph4();
|
|
313
|
+
const nodes = useConnections2(graph, nodeId, "child");
|
|
314
|
+
const companions = nodes.filter((node) => node.type === PLANK_COMPANION_TYPE);
|
|
315
|
+
return useMemo3(() => companions.toSorted((a, b) => byPosition3(a.properties, b.properties)), [
|
|
316
|
+
companions
|
|
317
|
+
]);
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// src/hooks/useDrawerActions.ts
|
|
321
|
+
import { Atom as Atom2 } from "@effect-atom/atom-react";
|
|
322
|
+
import * as Effect3 from "effect/Effect";
|
|
323
|
+
import { useMemo as useMemo6 } from "react";
|
|
324
|
+
import { useCapability as useCapability3, useOperationInvoker as useOperationInvoker4 } from "@dxos/app-framework/ui";
|
|
325
|
+
import { useAppGraph as useAppGraph7 } from "@dxos/app-toolkit/ui";
|
|
326
|
+
import { Node as Node4, useActionRunner as useActionRunner2 } from "@dxos/plugin-graph";
|
|
327
|
+
import { useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
328
|
+
import { createGapSeparator } from "@dxos/react-ui-menu";
|
|
329
|
+
|
|
330
|
+
// src/components/ContentLoading.tsx
|
|
331
|
+
import React2 from "react";
|
|
332
|
+
var ContentLoading = () => {
|
|
333
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
334
|
+
role: "none",
|
|
335
|
+
className: "grid place-items-center dx-attention-surface"
|
|
336
|
+
});
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
// src/components/MobileLayout/MobileLayout.tsx
|
|
340
|
+
import { createContext } from "@radix-ui/react-context";
|
|
341
|
+
import React3, { forwardRef, useEffect as useEffect3, useState } from "react";
|
|
342
|
+
import { addEventListener, combine } from "@dxos/async";
|
|
343
|
+
import { log } from "@dxos/log";
|
|
344
|
+
import { mx as mx2 } from "@dxos/ui-theme";
|
|
345
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-simple-layout/src/components/MobileLayout/MobileLayout.tsx";
|
|
346
|
+
var MOBILE_LAYOUT_NAME = "MobileLayout";
|
|
347
|
+
var MOBILE_LAYOUT_ROOT_NAME = "MobileLayout.Root";
|
|
348
|
+
var MOBILE_LAYOUT_PANEL_NAME = "MobileLayout.Panel";
|
|
349
|
+
var [MobileLayoutProvider, useMobileLayout] = createContext(MOBILE_LAYOUT_NAME);
|
|
350
|
+
var MobileLayoutRoot = /* @__PURE__ */ forwardRef(({ classNames, children, transition = 250, onKeyboardOpenChange, ...props }, forwardedRef) => {
|
|
351
|
+
const { open: keyboardOpen } = useIOSKeyboard();
|
|
352
|
+
useAutoScroll();
|
|
353
|
+
useEffect3(() => onKeyboardOpenChange?.(keyboardOpen), [
|
|
354
|
+
onKeyboardOpenChange,
|
|
355
|
+
keyboardOpen
|
|
356
|
+
]);
|
|
357
|
+
useLockBodyScroll(keyboardOpen);
|
|
358
|
+
return /* @__PURE__ */ React3.createElement(MobileLayoutProvider, {
|
|
359
|
+
keyboardOpen
|
|
360
|
+
}, /* @__PURE__ */ React3.createElement("div", {
|
|
361
|
+
...props,
|
|
362
|
+
role: "none",
|
|
363
|
+
style: {
|
|
364
|
+
transition: `h-size ${transition}ms ease-out`,
|
|
365
|
+
blockSize: "calc(100vh - var(--kb-height, 0px))"
|
|
366
|
+
},
|
|
367
|
+
className: mx2("absolute top-0 left-0 right-0 flex flex-col", classNames),
|
|
368
|
+
ref: forwardedRef
|
|
369
|
+
}, children));
|
|
370
|
+
});
|
|
371
|
+
MobileLayoutRoot.displayName = MOBILE_LAYOUT_ROOT_NAME;
|
|
372
|
+
var MobileLayoutPanel = /* @__PURE__ */ forwardRef(({ classNames, children, safe, ...props }, forwardedRef) => {
|
|
373
|
+
return /* @__PURE__ */ React3.createElement("div", {
|
|
374
|
+
...props,
|
|
375
|
+
role: "none",
|
|
376
|
+
style: {
|
|
377
|
+
paddingTop: safe?.top ? "env(safe-area-inset-top)" : void 0,
|
|
378
|
+
paddingBottom: safe?.bottom ? `calc((1 - var(--kb-open, 0)) * env(safe-area-inset-bottom))` : void 0
|
|
379
|
+
},
|
|
380
|
+
className: mx2("relative h-full flex flex-col overflow-hidden", classNames),
|
|
381
|
+
ref: forwardedRef
|
|
382
|
+
}, children);
|
|
383
|
+
});
|
|
384
|
+
MobileLayoutPanel.displayName = MOBILE_LAYOUT_PANEL_NAME;
|
|
385
|
+
var MobileLayout = {
|
|
386
|
+
Root: MobileLayoutRoot,
|
|
387
|
+
Panel: MobileLayoutPanel
|
|
388
|
+
};
|
|
389
|
+
var useAutoScroll = () => {
|
|
390
|
+
useEffect3(() => {
|
|
391
|
+
return addEventListener(
|
|
392
|
+
document,
|
|
393
|
+
"focus",
|
|
394
|
+
(event) => {
|
|
395
|
+
const target = event.target;
|
|
396
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "DIV" && target.isContentEditable) {
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
target.focus({
|
|
399
|
+
preventScroll: true
|
|
400
|
+
});
|
|
401
|
+
const scrollX = window.scrollX;
|
|
402
|
+
const scrollY = window.scrollY;
|
|
403
|
+
requestAnimationFrame(() => {
|
|
404
|
+
window.scrollTo(scrollX, scrollY);
|
|
405
|
+
});
|
|
406
|
+
}
|
|
407
|
+
},
|
|
408
|
+
// Important: focus events don't bubble, so capture phase is required.
|
|
409
|
+
{
|
|
410
|
+
capture: true
|
|
411
|
+
}
|
|
412
|
+
);
|
|
413
|
+
}, []);
|
|
414
|
+
};
|
|
415
|
+
var useLockBodyScroll = (enabled) => {
|
|
416
|
+
useEffect3(() => {
|
|
417
|
+
if (!enabled) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
const isScrollable = (el, axis) => {
|
|
421
|
+
while (el && el !== document.body) {
|
|
422
|
+
const style = getComputedStyle(el);
|
|
423
|
+
if (axis === "y") {
|
|
424
|
+
const overflow = style.overflowY;
|
|
425
|
+
if ((overflow === "auto" || overflow === "scroll") && el.scrollHeight > el.clientHeight) {
|
|
426
|
+
return true;
|
|
427
|
+
}
|
|
428
|
+
} else {
|
|
429
|
+
const overflow = style.overflowX;
|
|
430
|
+
if ((overflow === "auto" || overflow === "scroll") && el.scrollWidth > el.clientWidth) {
|
|
431
|
+
return true;
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
el = el.parentElement;
|
|
435
|
+
}
|
|
436
|
+
return false;
|
|
437
|
+
};
|
|
438
|
+
let touchStartX = 0;
|
|
439
|
+
let touchStartY = 0;
|
|
440
|
+
return combine(
|
|
441
|
+
// Record initial touch position.
|
|
442
|
+
addEventListener(document, "touchstart", (event) => {
|
|
443
|
+
const touch = event.touches[0];
|
|
444
|
+
touchStartX = touch.clientX;
|
|
445
|
+
touchStartY = touch.clientY;
|
|
446
|
+
}, {
|
|
447
|
+
passive: true
|
|
448
|
+
}),
|
|
449
|
+
// Prevent scrolling the viewport.
|
|
450
|
+
addEventListener(document, "touchmove", (event) => {
|
|
451
|
+
const touch = event.touches[0];
|
|
452
|
+
const dx = Math.abs(touch.clientX - touchStartX);
|
|
453
|
+
const dy = Math.abs(touch.clientY - touchStartY);
|
|
454
|
+
if (!isScrollable(event.target, dx > dy ? "x" : "y")) {
|
|
455
|
+
event.preventDefault();
|
|
456
|
+
}
|
|
457
|
+
}, {
|
|
458
|
+
passive: false
|
|
459
|
+
})
|
|
460
|
+
);
|
|
461
|
+
}, [
|
|
462
|
+
enabled
|
|
463
|
+
]);
|
|
464
|
+
};
|
|
465
|
+
var useIOSKeyboard = () => {
|
|
466
|
+
const [open, setOpen] = useState(false);
|
|
467
|
+
const [height, setHeight] = useState(0);
|
|
468
|
+
useEffect3(() => {
|
|
469
|
+
const viewport = window.visualViewport;
|
|
470
|
+
if (!viewport) {
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const initialHeight = viewport.height ?? window.innerHeight;
|
|
474
|
+
const updateState = (keyboardHeight, keyboardOpen) => {
|
|
475
|
+
setOpen(keyboardOpen);
|
|
476
|
+
setHeight(keyboardHeight);
|
|
477
|
+
const vvh = initialHeight - keyboardHeight;
|
|
478
|
+
document.documentElement.style.setProperty("--vvh", `${vvh}px`);
|
|
479
|
+
document.documentElement.style.setProperty("--kb-height", `${keyboardHeight}px`);
|
|
480
|
+
document.documentElement.style.setProperty("--kb-open", keyboardOpen ? "1" : "0");
|
|
481
|
+
log.info("viewport size", {
|
|
482
|
+
initialHeight,
|
|
483
|
+
vvh,
|
|
484
|
+
keyboardHeight,
|
|
485
|
+
keyboardOpen
|
|
486
|
+
}, {
|
|
487
|
+
F: __dxlog_file,
|
|
488
|
+
L: 287,
|
|
489
|
+
S: void 0,
|
|
490
|
+
C: (f, a) => f(...a)
|
|
491
|
+
});
|
|
492
|
+
};
|
|
493
|
+
return combine(
|
|
494
|
+
// Handler for native iOS keyboard events (from KeyboardObserver.swift).
|
|
495
|
+
addEventListener(window, "keyboard", (event) => {
|
|
496
|
+
const { type, height: height2 } = event.detail;
|
|
497
|
+
log.info("keyboard event", {
|
|
498
|
+
type,
|
|
499
|
+
height: height2
|
|
500
|
+
}, {
|
|
501
|
+
F: __dxlog_file,
|
|
502
|
+
L: 297,
|
|
503
|
+
S: void 0,
|
|
504
|
+
C: (f, a) => f(...a)
|
|
505
|
+
});
|
|
506
|
+
updateState(height2, type === "show");
|
|
507
|
+
})
|
|
508
|
+
);
|
|
509
|
+
}, []);
|
|
510
|
+
return {
|
|
511
|
+
open,
|
|
512
|
+
height
|
|
513
|
+
};
|
|
514
|
+
};
|
|
515
|
+
|
|
516
|
+
// src/components/Popover/Popover.tsx
|
|
517
|
+
import { createContext as createContext2 } from "@radix-ui/react-context";
|
|
518
|
+
import React4, { useCallback as useCallback3, useEffect as useEffect4, useMemo as useMemo4, useRef as useRef2, useState as useState2 } from "react";
|
|
519
|
+
import { Surface } from "@dxos/app-framework/ui";
|
|
520
|
+
import { useObjectNavigate } from "@dxos/app-toolkit/ui";
|
|
521
|
+
import { Popover, toLocalizedString as toLocalizedString3, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
522
|
+
import { Card as Card2 } from "@dxos/react-ui";
|
|
523
|
+
var DEBOUNCE_DELAY = 40;
|
|
524
|
+
var [LayoutPopoverProvider, useLayoutPopoverContext] = createContext2("LayoutPopover");
|
|
525
|
+
var PopoverRoot = ({ children }) => {
|
|
526
|
+
const { state } = useSimpleLayoutState();
|
|
527
|
+
const [open, setOpen] = useState2(false);
|
|
528
|
+
const virtualRef = useRef2(null);
|
|
529
|
+
const [virtualIter, setVirtualIter] = useState2(0);
|
|
530
|
+
const debounceRef = useRef2(null);
|
|
531
|
+
useEffect4(() => {
|
|
532
|
+
setOpen(false);
|
|
533
|
+
if (state.popoverOpen) {
|
|
534
|
+
if (debounceRef.current) {
|
|
535
|
+
clearTimeout(debounceRef.current);
|
|
536
|
+
}
|
|
537
|
+
if (state.popoverAnchor && virtualRef.current !== state.popoverAnchor) {
|
|
538
|
+
virtualRef.current = state.popoverAnchor ?? null;
|
|
539
|
+
setVirtualIter((iter) => iter + 1);
|
|
540
|
+
}
|
|
541
|
+
debounceRef.current = setTimeout(() => setOpen(true), DEBOUNCE_DELAY);
|
|
542
|
+
}
|
|
543
|
+
}, [
|
|
544
|
+
state.popoverOpen,
|
|
545
|
+
state.popoverAnchorId,
|
|
546
|
+
state.popoverAnchor,
|
|
547
|
+
state.popoverContent
|
|
548
|
+
]);
|
|
549
|
+
return /* @__PURE__ */ React4.createElement(LayoutPopoverProvider, {
|
|
550
|
+
setOpen
|
|
551
|
+
}, /* @__PURE__ */ React4.createElement(Popover.Root, {
|
|
552
|
+
modal: false,
|
|
553
|
+
open
|
|
554
|
+
}, state.popoverAnchor && /* @__PURE__ */ React4.createElement(Popover.VirtualTrigger, {
|
|
555
|
+
key: virtualIter,
|
|
556
|
+
virtualRef
|
|
557
|
+
}), children));
|
|
558
|
+
};
|
|
559
|
+
var getPopoverSubject = (content) => content && typeof content === "object" && "subject" in content ? content.subject : content;
|
|
560
|
+
var PopoverContent = () => {
|
|
561
|
+
const { t } = useTranslation3(meta.id);
|
|
562
|
+
const { state, updateState } = useSimpleLayoutState();
|
|
563
|
+
const { setOpen } = useLayoutPopoverContext("PopoverContent");
|
|
564
|
+
const handleNavigate = useObjectNavigate(getPopoverSubject(state.popoverContent));
|
|
565
|
+
const handleClose = useCallback3(() => {
|
|
566
|
+
setOpen(false);
|
|
567
|
+
updateState((s) => ({
|
|
568
|
+
...s,
|
|
569
|
+
popoverOpen: false,
|
|
570
|
+
popoverAnchor: void 0,
|
|
571
|
+
popoverAnchorId: void 0,
|
|
572
|
+
popoverSide: void 0
|
|
573
|
+
}));
|
|
574
|
+
}, [
|
|
575
|
+
setOpen,
|
|
576
|
+
updateState
|
|
577
|
+
]);
|
|
578
|
+
const handleInteractOutside = useCallback3((event) => {
|
|
579
|
+
if (
|
|
580
|
+
// TODO(thure): CodeMirror should not focus itself when it updates.
|
|
581
|
+
event.type === "dismissableLayer.focusOutside" && event.currentTarget?.classList.contains("cm-content")
|
|
582
|
+
) {
|
|
583
|
+
event.preventDefault();
|
|
584
|
+
} else {
|
|
585
|
+
handleClose();
|
|
586
|
+
}
|
|
587
|
+
}, [
|
|
588
|
+
handleClose
|
|
589
|
+
]);
|
|
590
|
+
const collisionBoundaries = useMemo4(() => {
|
|
591
|
+
const closest = state.popoverAnchor?.closest("[data-popover-collision-boundary]");
|
|
592
|
+
return closest ? [
|
|
593
|
+
closest
|
|
594
|
+
] : [];
|
|
595
|
+
}, [
|
|
596
|
+
state.popoverAnchor
|
|
597
|
+
]);
|
|
598
|
+
return /* @__PURE__ */ React4.createElement(Popover.Portal, null, /* @__PURE__ */ React4.createElement(Popover.Content, {
|
|
599
|
+
side: state.popoverSide,
|
|
600
|
+
sticky: "always",
|
|
601
|
+
hideWhenDetached: true,
|
|
602
|
+
collisionBoundary: collisionBoundaries,
|
|
603
|
+
onInteractOutside: handleInteractOutside,
|
|
604
|
+
onEscapeKeyDown: handleInteractOutside
|
|
605
|
+
}, /* @__PURE__ */ React4.createElement(Popover.Viewport, null, state.popoverKind === "base" && /* @__PURE__ */ React4.createElement(Surface.Surface, {
|
|
606
|
+
role: "popover",
|
|
607
|
+
data: state.popoverContent,
|
|
608
|
+
limit: 1
|
|
609
|
+
}), state.popoverKind === "card" && /* @__PURE__ */ React4.createElement(Card2.Root, {
|
|
610
|
+
border: false,
|
|
611
|
+
classNames: "dx-card-popover"
|
|
612
|
+
}, /* @__PURE__ */ React4.createElement(Card2.Toolbar, null, /* @__PURE__ */ React4.createElement("span", null), state.popoverTitle ? /* @__PURE__ */ React4.createElement(Card2.Title, {
|
|
613
|
+
onClick: handleNavigate
|
|
614
|
+
}, toLocalizedString3(state.popoverTitle, t)) : /* @__PURE__ */ React4.createElement("span", null), /* @__PURE__ */ React4.createElement(Card2.CloseIconButton, {
|
|
615
|
+
onClick: handleClose
|
|
616
|
+
})), /* @__PURE__ */ React4.createElement(Surface.Surface, {
|
|
617
|
+
role: "card--content",
|
|
618
|
+
data: state.popoverContent,
|
|
619
|
+
limit: 1
|
|
620
|
+
}))), /* @__PURE__ */ React4.createElement(Popover.Arrow, null)));
|
|
621
|
+
};
|
|
622
|
+
|
|
623
|
+
// src/components/SimpleLayout/AppBar.tsx
|
|
624
|
+
import { useAtomValue as useAtomValue2 } from "@effect-atom/atom-react";
|
|
625
|
+
import React5, { Fragment } from "react";
|
|
626
|
+
import { IconButton, Popover as Popover2, Toolbar as Toolbar2, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
627
|
+
import { Menu, useMenuActions } from "@dxos/react-ui-menu";
|
|
628
|
+
import { mx as mx3, osTranslations } from "@dxos/ui-theme";
|
|
629
|
+
var APP_BAR_NAME = "SimpleLayout.AppBar";
|
|
630
|
+
var AppBar = ({ classNames, title, actions, showBackButton, popoverAnchorId, onAction, onBack }) => {
|
|
631
|
+
const { t } = useTranslation4(meta.id);
|
|
632
|
+
const menu = useMenuActions(actions);
|
|
633
|
+
const actionsValue = useAtomValue2(actions);
|
|
634
|
+
const hasActions = actionsValue.nodes.length > 0;
|
|
635
|
+
const { keyboardOpen } = useMobileLayout(APP_BAR_NAME);
|
|
636
|
+
const displayTitle = title ?? t("current app name", {
|
|
637
|
+
ns: osTranslations
|
|
638
|
+
});
|
|
639
|
+
const AnchorRoot = popoverAnchorId ? Popover2.Anchor : Fragment;
|
|
640
|
+
return /* @__PURE__ */ React5.createElement(Toolbar2.Root, {
|
|
641
|
+
role: "banner",
|
|
642
|
+
classNames: mx3("grid grid-cols-[var(--dx-rail-size)_1fr_var(--dx-rail-size)] items-center", "dx-density-fine", classNames)
|
|
643
|
+
}, keyboardOpen ? /* @__PURE__ */ React5.createElement(IconButton, {
|
|
644
|
+
variant: "ghost",
|
|
645
|
+
icon: "ph--x--regular",
|
|
646
|
+
iconOnly: true,
|
|
647
|
+
label: t("done label")
|
|
648
|
+
}) : showBackButton ? /* @__PURE__ */ React5.createElement(IconButton, {
|
|
649
|
+
variant: "ghost",
|
|
650
|
+
icon: "ph--caret-left--regular",
|
|
651
|
+
iconOnly: true,
|
|
652
|
+
label: t("back label"),
|
|
653
|
+
onClick: onBack
|
|
654
|
+
}) : /* @__PURE__ */ React5.createElement("div", null), /* @__PURE__ */ React5.createElement("h1", {
|
|
655
|
+
className: "text-center truncate font-thin uppercase"
|
|
656
|
+
}, displayTitle), hasActions ? /* @__PURE__ */ React5.createElement(AnchorRoot, null, /* @__PURE__ */ React5.createElement(Menu.Root, {
|
|
657
|
+
...menu,
|
|
658
|
+
caller: meta.id,
|
|
659
|
+
onAction
|
|
660
|
+
}, /* @__PURE__ */ React5.createElement(Menu.Trigger, {
|
|
661
|
+
asChild: true
|
|
662
|
+
}, /* @__PURE__ */ React5.createElement(IconButton, {
|
|
663
|
+
variant: "ghost",
|
|
664
|
+
icon: "ph--dots-three-vertical--regular",
|
|
665
|
+
iconOnly: true,
|
|
666
|
+
label: t("actions menu label")
|
|
667
|
+
})), /* @__PURE__ */ React5.createElement(Menu.Content, null))) : /* @__PURE__ */ React5.createElement("span", null));
|
|
668
|
+
};
|
|
669
|
+
AppBar.displayName = APP_BAR_NAME;
|
|
670
|
+
|
|
671
|
+
// src/components/SimpleLayout/Main.tsx
|
|
672
|
+
import React7, { useMemo as useMemo5 } from "react";
|
|
673
|
+
import { Surface as Surface2 } from "@dxos/app-framework/ui";
|
|
674
|
+
import { useAppGraph as useAppGraph5 } from "@dxos/app-toolkit/ui";
|
|
675
|
+
import { useNode as useNode2 } from "@dxos/plugin-graph";
|
|
676
|
+
import { ErrorFallback } from "@dxos/react-ui";
|
|
677
|
+
import { useAttentionAttributes } from "@dxos/react-ui-attention";
|
|
678
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
679
|
+
|
|
680
|
+
// src/components/SimpleLayout/NavBar.tsx
|
|
681
|
+
import React6 from "react";
|
|
682
|
+
import { Menu as Menu2, useMenuActions as useMenuActions2 } from "@dxos/react-ui-menu";
|
|
683
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
684
|
+
var NAVBAR_NAME = "SimpleLayout.NavBar";
|
|
685
|
+
var NavBar = ({ classNames, actions, onAction }) => {
|
|
686
|
+
const menu = useMenuActions2(actions);
|
|
687
|
+
return /* @__PURE__ */ React6.createElement(Menu2.Root, {
|
|
688
|
+
...menu,
|
|
689
|
+
alwaysActive: true,
|
|
690
|
+
onAction
|
|
691
|
+
}, /* @__PURE__ */ React6.createElement(Menu2.Toolbar, {
|
|
692
|
+
density: "coarse",
|
|
693
|
+
classNames: mx4(classNames)
|
|
694
|
+
}));
|
|
695
|
+
};
|
|
696
|
+
NavBar.displayName = NAVBAR_NAME;
|
|
697
|
+
|
|
698
|
+
// src/components/SimpleLayout/Main.tsx
|
|
699
|
+
var MAIN_NAME = "SimpleLayout.Main";
|
|
700
|
+
var Main = () => {
|
|
701
|
+
const { state } = useSimpleLayoutState();
|
|
702
|
+
const id = state.active ?? state.workspace;
|
|
703
|
+
const attentionAttrs = useAttentionAttributes(id);
|
|
704
|
+
const { keyboardOpen } = useMobileLayout(MAIN_NAME);
|
|
705
|
+
const { actions, onAction } = useNavbarActions();
|
|
706
|
+
const appBarProps = useAppBarProps();
|
|
707
|
+
const placeholder = useMemo5(() => /* @__PURE__ */ React7.createElement(ContentLoading, null), []);
|
|
708
|
+
const { graph } = useAppGraph5();
|
|
709
|
+
const node = useNode2(graph, id);
|
|
710
|
+
const data = useMemo5(() => {
|
|
711
|
+
return node && {
|
|
712
|
+
attendableId: id,
|
|
713
|
+
subject: node.data,
|
|
714
|
+
properties: node.properties,
|
|
715
|
+
popoverAnchorId: state.popoverAnchorId
|
|
716
|
+
};
|
|
717
|
+
}, [
|
|
718
|
+
id,
|
|
719
|
+
node,
|
|
720
|
+
node?.data,
|
|
721
|
+
node?.properties,
|
|
722
|
+
state.popoverAnchorId
|
|
723
|
+
]);
|
|
724
|
+
useLoadDescendents(id);
|
|
725
|
+
const showNavBar = !keyboardOpen && !state.isPopover && state.drawerState === "closed";
|
|
726
|
+
return /* @__PURE__ */ React7.createElement("div", {
|
|
727
|
+
role: "none",
|
|
728
|
+
className: mx5("h-full grid overflow-hidden bg-toolbar-surface", showNavBar ? "grid-rows-[var(--dx-rail-action)_1fr_var(--dx-toolbar-size)]" : "grid-rows-[var(--dx-rail-action)_1fr]"),
|
|
729
|
+
...attentionAttrs
|
|
730
|
+
}, /* @__PURE__ */ React7.createElement(AppBar, appBarProps), /* @__PURE__ */ React7.createElement("article", {
|
|
731
|
+
className: "h-full overflow-hidden bg-base-surface"
|
|
732
|
+
}, /* @__PURE__ */ React7.createElement(Surface2.Surface, {
|
|
733
|
+
key: id,
|
|
734
|
+
role: "article",
|
|
735
|
+
data,
|
|
736
|
+
limit: 1,
|
|
737
|
+
fallback: ErrorFallback,
|
|
738
|
+
placeholder
|
|
739
|
+
})), showNavBar && /* @__PURE__ */ React7.createElement(NavBar, {
|
|
740
|
+
classNames: "border-y border-subdued-separator",
|
|
741
|
+
actions,
|
|
742
|
+
onAction
|
|
743
|
+
}));
|
|
744
|
+
};
|
|
745
|
+
Main.displayName = MAIN_NAME;
|
|
746
|
+
|
|
747
|
+
// src/components/Workspace/Workspace.tsx
|
|
748
|
+
import React8, { useCallback as useCallback4, useEffect as useEffect5, useRef as useRef3 } from "react";
|
|
749
|
+
import { useOperationInvoker as useOperationInvoker3 } from "@dxos/app-framework/ui";
|
|
750
|
+
import { LayoutOperation as LayoutOperation4 } from "@dxos/app-toolkit";
|
|
751
|
+
import { useAppGraph as useAppGraph6 } from "@dxos/app-toolkit/ui";
|
|
752
|
+
import { useConnections as useConnections3 } from "@dxos/plugin-graph";
|
|
753
|
+
import { Avatar as Avatar2, Icon as Icon2, Panel as Panel2, ScrollArea as ScrollArea2, Toolbar as Toolbar3, toLocalizedString as toLocalizedString4, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
754
|
+
import { Card as Card3 } from "@dxos/react-ui";
|
|
755
|
+
import { Mosaic as Mosaic2 } from "@dxos/react-ui-mosaic";
|
|
756
|
+
import { SearchList as SearchList2, useSearchListItem as useSearchListItem2, useSearchListResults as useSearchListResults2 } from "@dxos/react-ui-searchlist";
|
|
757
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
758
|
+
var Workspace = ({ id }) => {
|
|
759
|
+
const { t } = useTranslation5(meta.id);
|
|
760
|
+
const { graph } = useAppGraph6();
|
|
761
|
+
useLoadDescendents(id);
|
|
762
|
+
const children = useConnections3(graph, id, "child");
|
|
763
|
+
const { results, handleSearch } = useSearchListResults2({
|
|
764
|
+
items: children,
|
|
765
|
+
extract: (child) => toLocalizedString4(child.properties.label, t)
|
|
766
|
+
});
|
|
767
|
+
return /* @__PURE__ */ React8.createElement(SearchList2.Root, {
|
|
768
|
+
onSearch: handleSearch
|
|
769
|
+
}, /* @__PURE__ */ React8.createElement(Panel2.Root, null, /* @__PURE__ */ React8.createElement(Panel2.Toolbar, {
|
|
770
|
+
asChild: true
|
|
771
|
+
}, /* @__PURE__ */ React8.createElement(Toolbar3.Root, null, /* @__PURE__ */ React8.createElement(SearchList2.Input, {
|
|
772
|
+
placeholder: t("search placeholder"),
|
|
773
|
+
autoFocus: true
|
|
774
|
+
}))), /* @__PURE__ */ React8.createElement(Panel2.Content, {
|
|
775
|
+
asChild: true
|
|
776
|
+
}, /* @__PURE__ */ React8.createElement(SearchList2.Content, null, /* @__PURE__ */ React8.createElement(Mosaic2.Container, {
|
|
777
|
+
asChild: true
|
|
778
|
+
}, /* @__PURE__ */ React8.createElement(ScrollArea2.Root, {
|
|
779
|
+
orientation: "vertical"
|
|
780
|
+
}, /* @__PURE__ */ React8.createElement(ScrollArea2.Viewport, {
|
|
781
|
+
classNames: "p-2"
|
|
782
|
+
}, /* @__PURE__ */ React8.createElement(Mosaic2.Stack, {
|
|
783
|
+
items: results,
|
|
784
|
+
getId: (child) => child.id,
|
|
785
|
+
Tile: WorkspaceChildTile
|
|
786
|
+
}))))))));
|
|
787
|
+
};
|
|
788
|
+
var WorkspaceChildTile = (props) => {
|
|
789
|
+
const data = props.data;
|
|
790
|
+
const { t } = useTranslation5(meta.id);
|
|
791
|
+
const { invokeSync } = useOperationInvoker3();
|
|
792
|
+
const ref = useRef3(null);
|
|
793
|
+
const { selectedValue, registerItem, unregisterItem } = useSearchListItem2();
|
|
794
|
+
const isSelected = selectedValue === data.id;
|
|
795
|
+
const name = toLocalizedString4(data.properties.label, t);
|
|
796
|
+
const handleSelect = useCallback4(() => invokeSync(LayoutOperation4.Open, {
|
|
797
|
+
subject: [
|
|
798
|
+
data.id
|
|
799
|
+
]
|
|
800
|
+
}), [
|
|
801
|
+
invokeSync,
|
|
802
|
+
data.id
|
|
803
|
+
]);
|
|
804
|
+
useEffect5(() => {
|
|
805
|
+
if (ref.current) {
|
|
806
|
+
registerItem(data.id, ref.current, handleSelect);
|
|
807
|
+
}
|
|
808
|
+
return () => unregisterItem(data.id);
|
|
809
|
+
}, [
|
|
810
|
+
data.id,
|
|
811
|
+
handleSelect,
|
|
812
|
+
registerItem,
|
|
813
|
+
unregisterItem
|
|
814
|
+
]);
|
|
815
|
+
useEffect5(() => {
|
|
816
|
+
if (isSelected && ref.current) {
|
|
817
|
+
ref.current.scrollIntoView({
|
|
818
|
+
block: "nearest",
|
|
819
|
+
behavior: "smooth"
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
}, [
|
|
823
|
+
isSelected
|
|
824
|
+
]);
|
|
825
|
+
return /* @__PURE__ */ React8.createElement(Card3.Root, {
|
|
826
|
+
ref,
|
|
827
|
+
role: "button",
|
|
828
|
+
fullWidth: true,
|
|
829
|
+
tabIndex: -1,
|
|
830
|
+
"data-selected": isSelected,
|
|
831
|
+
classNames: mx6("dx-focus-ring", isSelected && "bg-hover-overlay"),
|
|
832
|
+
onClick: handleSelect
|
|
833
|
+
}, /* @__PURE__ */ React8.createElement(Card3.Toolbar, {
|
|
834
|
+
density: "coarse"
|
|
835
|
+
}, /* @__PURE__ */ React8.createElement(Avatar2.Root, null, /* @__PURE__ */ React8.createElement(Avatar2.Content, {
|
|
836
|
+
hue: data.properties.hue,
|
|
837
|
+
icon: data.properties.icon,
|
|
838
|
+
hueVariant: "transparent",
|
|
839
|
+
variant: "square",
|
|
840
|
+
size: 12,
|
|
841
|
+
fallback: name
|
|
842
|
+
}), /* @__PURE__ */ React8.createElement(Avatar2.Label, null, name), /* @__PURE__ */ React8.createElement(Icon2, {
|
|
843
|
+
icon: "ph--caret-right--regular"
|
|
844
|
+
}))));
|
|
845
|
+
};
|
|
846
|
+
|
|
847
|
+
// src/hooks/useSimpleLayoutState.ts
|
|
848
|
+
import { RegistryContext, useAtomValue as useAtomValue3 } from "@effect-atom/atom-react";
|
|
849
|
+
import { useCallback as useCallback5, useContext } from "react";
|
|
850
|
+
import { useCapability as useCapability2 } from "@dxos/app-framework/ui";
|
|
851
|
+
var useSimpleLayoutState = () => {
|
|
852
|
+
const registry = useContext(RegistryContext);
|
|
853
|
+
const stateAtom = useCapability2(SimpleLayoutState);
|
|
854
|
+
const state = useAtomValue3(stateAtom);
|
|
855
|
+
const updateState = useCallback5((fn) => {
|
|
856
|
+
registry.set(stateAtom, fn(registry.get(stateAtom)));
|
|
857
|
+
}, [
|
|
858
|
+
registry,
|
|
859
|
+
stateAtom
|
|
860
|
+
]);
|
|
861
|
+
return {
|
|
862
|
+
state,
|
|
863
|
+
updateState
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
|
|
867
|
+
// src/hooks/useDrawerActions.ts
|
|
868
|
+
var useDrawerActions = (consumerName) => {
|
|
869
|
+
const { t } = useTranslation6(meta.id);
|
|
870
|
+
const stateAtom = useCapability3(SimpleLayoutState);
|
|
871
|
+
const { graph } = useAppGraph7();
|
|
872
|
+
const runAction = useActionRunner2();
|
|
873
|
+
const { invokeSync } = useOperationInvoker4();
|
|
874
|
+
const { updateState } = useSimpleLayoutState();
|
|
875
|
+
const { keyboardOpen } = useMobileLayout(consumerName);
|
|
876
|
+
const actionsAtom = useMemo6(() => Atom2.make((get) => {
|
|
877
|
+
const state = get(stateAtom);
|
|
878
|
+
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
879
|
+
idPrefix: "drawer",
|
|
880
|
+
selectedVariant: state.companionVariant,
|
|
881
|
+
invokeSync
|
|
882
|
+
});
|
|
883
|
+
const gapSeparator = createGapSeparator("drawer-gap");
|
|
884
|
+
nodes.push(...gapSeparator.nodes);
|
|
885
|
+
edges.push(...gapSeparator.edges);
|
|
886
|
+
if (!keyboardOpen) {
|
|
887
|
+
const isExpanded = state.drawerState === "expanded";
|
|
888
|
+
const toggleExpandAction = {
|
|
889
|
+
id: "drawer-toggle-expand",
|
|
890
|
+
type: Node4.ActionType,
|
|
891
|
+
properties: {
|
|
892
|
+
icon: isExpanded ? "ph--arrow-down--regular" : "ph--arrow-up--regular",
|
|
893
|
+
label: isExpanded ? t("collapse drawer label") : t("expand drawer label"),
|
|
894
|
+
iconOnly: true
|
|
895
|
+
},
|
|
896
|
+
data: () => Effect3.sync(() => updateState((state2) => ({
|
|
897
|
+
...state2,
|
|
898
|
+
drawerState: isExpanded ? "open" : "expanded"
|
|
899
|
+
})))
|
|
900
|
+
};
|
|
901
|
+
nodes.push(toggleExpandAction);
|
|
902
|
+
edges.push({
|
|
903
|
+
source: "root",
|
|
904
|
+
target: toggleExpandAction.id,
|
|
905
|
+
relation: "child"
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
const closeAction = {
|
|
909
|
+
id: "drawer-close",
|
|
910
|
+
type: Node4.ActionType,
|
|
911
|
+
properties: {
|
|
912
|
+
icon: "ph--x--regular",
|
|
913
|
+
label: t("close drawer label"),
|
|
914
|
+
iconOnly: true
|
|
915
|
+
},
|
|
916
|
+
data: () => Effect3.sync(() => updateState((state2) => ({
|
|
917
|
+
...state2,
|
|
918
|
+
drawerState: "closed"
|
|
919
|
+
})))
|
|
920
|
+
};
|
|
921
|
+
nodes.push(closeAction);
|
|
922
|
+
edges.push({
|
|
923
|
+
source: "root",
|
|
924
|
+
target: closeAction.id,
|
|
925
|
+
relation: "child"
|
|
926
|
+
});
|
|
927
|
+
return {
|
|
928
|
+
nodes,
|
|
929
|
+
edges
|
|
930
|
+
};
|
|
931
|
+
}), [
|
|
932
|
+
graph,
|
|
933
|
+
stateAtom,
|
|
934
|
+
invokeSync,
|
|
935
|
+
updateState,
|
|
936
|
+
keyboardOpen,
|
|
937
|
+
t
|
|
938
|
+
]);
|
|
939
|
+
return {
|
|
940
|
+
actions: actionsAtom,
|
|
941
|
+
onAction: runAction
|
|
942
|
+
};
|
|
943
|
+
};
|
|
944
|
+
|
|
945
|
+
// src/hooks/useNavbarActions.ts
|
|
946
|
+
import { Atom as Atom3 } from "@effect-atom/atom-react";
|
|
947
|
+
import { useMemo as useMemo7 } from "react";
|
|
948
|
+
import { useCapability as useCapability4, useOperationInvoker as useOperationInvoker5 } from "@dxos/app-framework/ui";
|
|
949
|
+
import { useAppGraph as useAppGraph8 } from "@dxos/app-toolkit/ui";
|
|
950
|
+
import { Node as Node5, useActionRunner as useActionRunner3 } from "@dxos/plugin-graph";
|
|
951
|
+
import { useTranslation as useTranslation7 } from "@dxos/react-ui";
|
|
952
|
+
import { createGapSeparator as createGapSeparator2, createMenuItemGroup } from "@dxos/react-ui-menu";
|
|
953
|
+
var MAIN_MENU_GROUP_ID = "navbar-main-menu";
|
|
954
|
+
var useNavbarActions = () => {
|
|
955
|
+
const { t } = useTranslation7(meta.id);
|
|
956
|
+
const { graph } = useAppGraph8();
|
|
957
|
+
const runAction = useActionRunner3();
|
|
958
|
+
const { invokeSync } = useOperationInvoker5();
|
|
959
|
+
const stateAtom = useCapability4(SimpleLayoutState);
|
|
960
|
+
const actionsAtom = useMemo7(() => Atom3.make((get) => {
|
|
961
|
+
const { nodes, edges } = createCompanionActions(graph, stateAtom, get, {
|
|
962
|
+
idPrefix: "navbar",
|
|
963
|
+
invokeSync
|
|
964
|
+
});
|
|
965
|
+
const gapSeparator = createGapSeparator2("navbar-gap");
|
|
966
|
+
nodes.push(...gapSeparator.nodes);
|
|
967
|
+
edges.push(...gapSeparator.edges);
|
|
968
|
+
const mainMenuGroup = createMenuItemGroup(MAIN_MENU_GROUP_ID, {
|
|
969
|
+
variant: "dropdownMenu",
|
|
970
|
+
icon: "ph--list--regular",
|
|
971
|
+
iconOnly: true,
|
|
972
|
+
label: t("main menu label"),
|
|
973
|
+
testId: "simpleLayoutPlugin.addSpace"
|
|
974
|
+
});
|
|
975
|
+
nodes.push(mainMenuGroup);
|
|
976
|
+
edges.push({
|
|
977
|
+
source: "root",
|
|
978
|
+
target: mainMenuGroup.id,
|
|
979
|
+
relation: "child"
|
|
980
|
+
});
|
|
981
|
+
const rootActions = get(graph.actions(Node5.RootId));
|
|
982
|
+
const menuActions = rootActions.filter((node) => node.properties.disposition === "menu");
|
|
983
|
+
menuActions.forEach((menuAction) => {
|
|
984
|
+
nodes.push(menuAction);
|
|
985
|
+
edges.push({
|
|
986
|
+
source: MAIN_MENU_GROUP_ID,
|
|
987
|
+
target: menuAction.id,
|
|
988
|
+
relation: "child"
|
|
989
|
+
});
|
|
990
|
+
});
|
|
991
|
+
return {
|
|
992
|
+
nodes,
|
|
993
|
+
edges
|
|
994
|
+
};
|
|
995
|
+
}), [
|
|
996
|
+
graph,
|
|
997
|
+
stateAtom,
|
|
998
|
+
invokeSync,
|
|
999
|
+
t
|
|
1000
|
+
]);
|
|
1001
|
+
return {
|
|
1002
|
+
actions: actionsAtom,
|
|
1003
|
+
onAction: runAction
|
|
1004
|
+
};
|
|
1005
|
+
};
|
|
1006
|
+
|
|
1007
|
+
// src/components/Dialog/Dialog.tsx
|
|
1008
|
+
import React9 from "react";
|
|
1009
|
+
import { Surface as Surface3 } from "@dxos/app-framework/ui";
|
|
1010
|
+
import { AlertDialog, Dialog as NaturalDialog } from "@dxos/react-ui";
|
|
1011
|
+
import { ErrorFallback as ErrorFallback2 } from "@dxos/react-ui";
|
|
1012
|
+
var Dialog = () => {
|
|
1013
|
+
const { state, updateState } = useSimpleLayoutState();
|
|
1014
|
+
const DialogRoot = state.dialogType === "alert" ? AlertDialog.Root : NaturalDialog.Root;
|
|
1015
|
+
const DialogOverlay = state.dialogType === "alert" ? AlertDialog.Overlay : NaturalDialog.Overlay;
|
|
1016
|
+
return /* @__PURE__ */ React9.createElement(DialogRoot, {
|
|
1017
|
+
modal: state.dialogBlockAlign !== "end",
|
|
1018
|
+
open: state.dialogOpen,
|
|
1019
|
+
onOpenChange: (nextOpen) => updateState((state2) => ({
|
|
1020
|
+
...state2,
|
|
1021
|
+
dialogOpen: nextOpen
|
|
1022
|
+
}))
|
|
1023
|
+
}, state.dialogBlockAlign === "end" ? /* @__PURE__ */ React9.createElement(Surface3.Surface, {
|
|
1024
|
+
role: "dialog",
|
|
1025
|
+
data: state.dialogContent,
|
|
1026
|
+
limit: 1,
|
|
1027
|
+
fallback: ErrorFallback2
|
|
1028
|
+
}) : /* @__PURE__ */ React9.createElement(DialogOverlay, {
|
|
1029
|
+
blockAlign: state.dialogBlockAlign,
|
|
1030
|
+
classNames: state.dialogOverlayClasses,
|
|
1031
|
+
style: state.dialogOverlayStyle
|
|
1032
|
+
}, /* @__PURE__ */ React9.createElement(Surface3.Surface, {
|
|
1033
|
+
role: "dialog",
|
|
1034
|
+
data: state.dialogContent,
|
|
1035
|
+
limit: 1,
|
|
1036
|
+
fallback: ErrorFallback2
|
|
1037
|
+
})));
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
// src/components/SimpleLayout/Drawer.tsx
|
|
1041
|
+
import React10, { useMemo as useMemo8 } from "react";
|
|
1042
|
+
import { Surface as Surface4 } from "@dxos/app-framework/ui";
|
|
1043
|
+
import { useAppGraph as useAppGraph9 } from "@dxos/app-toolkit/ui";
|
|
1044
|
+
import { useNode as useNode3 } from "@dxos/plugin-graph";
|
|
1045
|
+
import { ErrorFallback as ErrorFallback3, Panel as Panel3 } from "@dxos/react-ui";
|
|
1046
|
+
import { ATTENDABLE_PATH_SEPARATOR as ATTENDABLE_PATH_SEPARATOR2 } from "@dxos/react-ui-attention";
|
|
1047
|
+
import { Menu as Menu3, useMenuActions as useMenuActions3 } from "@dxos/react-ui-menu";
|
|
1048
|
+
var DRAWER_NAME = "SimpleLayout.Drawer";
|
|
1049
|
+
var Drawer = () => {
|
|
1050
|
+
const { graph } = useAppGraph9();
|
|
1051
|
+
const { state: layoutState } = useSimpleLayoutState();
|
|
1052
|
+
const placeholder = useMemo8(() => /* @__PURE__ */ React10.createElement(ContentLoading, null), []);
|
|
1053
|
+
const activeId = layoutState.active ?? layoutState.workspace;
|
|
1054
|
+
const companions = useCompanions(activeId);
|
|
1055
|
+
const { companionId, variant } = useSelectedCompanion(companions, layoutState.companionVariant);
|
|
1056
|
+
const node = useNode3(graph, companionId);
|
|
1057
|
+
const parentNode = useNode3(graph, activeId);
|
|
1058
|
+
const data = useMemo8(() => {
|
|
1059
|
+
return node && {
|
|
1060
|
+
attendableId: companionId,
|
|
1061
|
+
subject: node.data,
|
|
1062
|
+
companionTo: parentNode?.data,
|
|
1063
|
+
properties: node.properties,
|
|
1064
|
+
variant
|
|
1065
|
+
};
|
|
1066
|
+
}, [
|
|
1067
|
+
companionId,
|
|
1068
|
+
node,
|
|
1069
|
+
parentNode,
|
|
1070
|
+
variant
|
|
1071
|
+
]);
|
|
1072
|
+
const { actions, onAction } = useDrawerActions(DRAWER_NAME);
|
|
1073
|
+
const menu = useMenuActions3(actions);
|
|
1074
|
+
return /* @__PURE__ */ React10.createElement(Panel3.Root, null, /* @__PURE__ */ React10.createElement(Panel3.Toolbar, null, /* @__PURE__ */ React10.createElement(Menu3.Root, {
|
|
1075
|
+
...menu,
|
|
1076
|
+
alwaysActive: true,
|
|
1077
|
+
onAction
|
|
1078
|
+
}, /* @__PURE__ */ React10.createElement(Menu3.Toolbar, {
|
|
1079
|
+
density: "coarse"
|
|
1080
|
+
}))), /* @__PURE__ */ React10.createElement(Panel3.Content, {
|
|
1081
|
+
asChild: true
|
|
1082
|
+
}, /* @__PURE__ */ React10.createElement(Surface4.Surface, {
|
|
1083
|
+
role: "article",
|
|
1084
|
+
data,
|
|
1085
|
+
limit: 1,
|
|
1086
|
+
fallback: ErrorFallback3,
|
|
1087
|
+
placeholder
|
|
1088
|
+
})));
|
|
1089
|
+
};
|
|
1090
|
+
Drawer.displayName = DRAWER_NAME;
|
|
1091
|
+
var parseEntryId = (entryId) => {
|
|
1092
|
+
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR2);
|
|
1093
|
+
return {
|
|
1094
|
+
id,
|
|
1095
|
+
variant
|
|
1096
|
+
};
|
|
1097
|
+
};
|
|
1098
|
+
var useSelectedCompanion = (companions, preferredVariant) => {
|
|
1099
|
+
const selectedCompanion = useMemo8(() => {
|
|
1100
|
+
if (companions.length === 0) {
|
|
1101
|
+
return void 0;
|
|
1102
|
+
}
|
|
1103
|
+
if (preferredVariant) {
|
|
1104
|
+
const preferred = companions.find((c) => {
|
|
1105
|
+
const { variant: variant2 } = parseEntryId(c.id);
|
|
1106
|
+
return variant2 === preferredVariant;
|
|
1107
|
+
});
|
|
1108
|
+
if (preferred) {
|
|
1109
|
+
return preferred;
|
|
1110
|
+
}
|
|
1111
|
+
}
|
|
1112
|
+
return companions[0];
|
|
1113
|
+
}, [
|
|
1114
|
+
companions,
|
|
1115
|
+
preferredVariant
|
|
1116
|
+
]);
|
|
1117
|
+
const companionId = selectedCompanion?.id;
|
|
1118
|
+
const { variant } = parseEntryId(companionId ?? "");
|
|
1119
|
+
return {
|
|
1120
|
+
selectedCompanion,
|
|
1121
|
+
companionId,
|
|
1122
|
+
variant
|
|
1123
|
+
};
|
|
1124
|
+
};
|
|
1125
|
+
|
|
1126
|
+
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
1127
|
+
var SimpleLayout = () => {
|
|
1128
|
+
const { state } = useSimpleLayoutState();
|
|
1129
|
+
const [keyboardOpen, setKeyboardOpen] = useState3(false);
|
|
1130
|
+
const [splitterMode, setSplitterMode] = useState3("upper");
|
|
1131
|
+
const drawerRef = useRef4(null);
|
|
1132
|
+
useEffect6(() => {
|
|
1133
|
+
if (keyboardOpen) {
|
|
1134
|
+
const activeElement = document.activeElement;
|
|
1135
|
+
const drawerHasFocus = drawerRef.current?.contains(activeElement);
|
|
1136
|
+
setSplitterMode(drawerHasFocus ? "lower" : "upper");
|
|
1137
|
+
} else {
|
|
1138
|
+
setSplitterMode(state.drawerState === "closed" ? "upper" : state.drawerState === "open" ? "both" : "lower");
|
|
1139
|
+
}
|
|
1140
|
+
}, [
|
|
1141
|
+
state.drawerState,
|
|
1142
|
+
keyboardOpen
|
|
1143
|
+
]);
|
|
1144
|
+
return /* @__PURE__ */ React11.createElement(Mosaic3.Root, {
|
|
1145
|
+
classNames: "contents"
|
|
1146
|
+
}, /* @__PURE__ */ React11.createElement(MobileLayout.Root, {
|
|
1147
|
+
classNames: "bg-toolbar-surface",
|
|
1148
|
+
onKeyboardOpenChange: (keyboardOpen2) => setKeyboardOpen(keyboardOpen2)
|
|
1149
|
+
}, /* @__PURE__ */ React11.createElement(MobileLayout.Panel, {
|
|
1150
|
+
safe: {
|
|
1151
|
+
top: true,
|
|
1152
|
+
bottom: splitterMode === "upper"
|
|
1153
|
+
}
|
|
1154
|
+
}, /* @__PURE__ */ React11.createElement(PopoverRoot, null, /* @__PURE__ */ React11.createElement(Splitter.Root, {
|
|
1155
|
+
mode: splitterMode,
|
|
1156
|
+
ratio: 0.55
|
|
1157
|
+
}, /* @__PURE__ */ React11.createElement(Splitter.Panel, {
|
|
1158
|
+
position: "upper"
|
|
1159
|
+
}, /* @__PURE__ */ React11.createElement(Main, null)), /* @__PURE__ */ React11.createElement(Splitter.Panel, {
|
|
1160
|
+
position: "lower",
|
|
1161
|
+
ref: drawerRef
|
|
1162
|
+
}, /* @__PURE__ */ React11.createElement(Drawer, null))), /* @__PURE__ */ React11.createElement(Dialog, null), /* @__PURE__ */ React11.createElement(PopoverContent, null)))));
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
export {
|
|
1166
|
+
Home,
|
|
1167
|
+
SimpleLayout,
|
|
1168
|
+
Workspace
|
|
1169
|
+
};
|
|
1170
|
+
//# sourceMappingURL=chunk-TMZNLVT2.mjs.map
|