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