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