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