@dxos/plugin-simple-layout 0.0.0 → 0.8.4-main.69d29f4
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-CLPGTNWJ.mjs +29 -0
- package/dist/lib/browser/chunk-CLPGTNWJ.mjs.map +7 -0
- package/dist/lib/browser/chunk-FK4M7GJV.mjs +613 -0
- package/dist/lib/browser/chunk-FK4M7GJV.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +94 -0
- package/dist/lib/browser/index.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -0
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs +168 -0
- package/dist/lib/browser/operation-resolver-LTB63NKP.mjs.map +7 -0
- package/dist/lib/browser/react-root-6ARAPH3O.mjs +21 -0
- package/dist/lib/browser/react-root-6ARAPH3O.mjs.map +7 -0
- package/dist/lib/browser/react-surface-SO7B23GS.mjs +39 -0
- package/dist/lib/browser/react-surface-SO7B23GS.mjs.map +7 -0
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs +66 -0
- package/dist/lib/browser/spotlight-dismiss-VSNOPETH.mjs.map +7 -0
- package/dist/lib/browser/state-H4IGICBB.mjs +45 -0
- package/dist/lib/browser/state-H4IGICBB.mjs.map +7 -0
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs +54 -0
- package/dist/lib/browser/url-handler-7CFGTLNG.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs +614 -0
- package/dist/lib/node-esm/chunk-EGFZAVBD.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-MUVVYBUE.mjs +31 -0
- package/dist/lib/node-esm/chunk-MUVVYBUE.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +95 -0
- package/dist/lib/node-esm/index.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -0
- package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs +169 -0
- package/dist/lib/node-esm/operation-resolver-7O6O7T4Q.mjs.map +7 -0
- package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs +22 -0
- package/dist/lib/node-esm/react-root-2CPA2ZUS.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-FKAV56MO.mjs +40 -0
- package/dist/lib/node-esm/react-surface-FKAV56MO.mjs.map +7 -0
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs +68 -0
- package/dist/lib/node-esm/spotlight-dismiss-L5PCWIJG.mjs.map +7 -0
- package/dist/lib/node-esm/state-QIU2LMLT.mjs +46 -0
- package/dist/lib/node-esm/state-QIU2LMLT.mjs.map +7 -0
- package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs +55 -0
- package/dist/lib/node-esm/url-handler-4LYP3JM7.mjs.map +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts +7 -0
- package/dist/types/src/SimpleLayoutPlugin.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +7 -0
- package/dist/types/src/capabilities/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root/index.d.ts +6 -0
- package/dist/types/src/capabilities/react-root/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-root/react-root.d.ts +9 -0
- package/dist/types/src/capabilities/react-root/react-root.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts +3 -0
- package/dist/types/src/capabilities/spotlight-dismiss/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts +14 -0
- package/dist/types/src/capabilities/spotlight-dismiss/spotlight-dismiss.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/index.d.ts +13 -0
- package/dist/types/src/capabilities/state/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/state/state.d.ts +19 -0
- package/dist/types/src/capabilities/state/state.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler/index.d.ts +3 -0
- package/dist/types/src/capabilities/url-handler/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts +10 -0
- package/dist/types/src/capabilities/url-handler/url-handler.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.d.ts +5 -0
- package/dist/types/src/components/ContentError.d.ts.map +1 -0
- package/dist/types/src/components/ContentError.stories.d.ts +35 -0
- package/dist/types/src/components/ContentError.stories.d.ts.map +1 -0
- package/dist/types/src/components/ContentLoading.d.ts +3 -0
- package/dist/types/src/components/ContentLoading.d.ts.map +1 -0
- package/dist/types/src/components/ContentLoading.stories.d.ts +13 -0
- package/dist/types/src/components/ContentLoading.stories.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts +3 -0
- package/dist/types/src/components/Dialog/Dialog.d.ts.map +1 -0
- package/dist/types/src/components/Dialog/index.d.ts +2 -0
- package/dist/types/src/components/Dialog/index.d.ts.map +1 -0
- package/dist/types/src/components/Home/Home.d.ts +7 -0
- package/dist/types/src/components/Home/Home.d.ts.map +1 -0
- package/dist/types/src/components/Home/index.d.ts +2 -0
- package/dist/types/src/components/Home/index.d.ts.map +1 -0
- package/dist/types/src/components/Popover/Popover.d.ts +4 -0
- package/dist/types/src/components/Popover/Popover.d.ts.map +1 -0
- package/dist/types/src/components/Popover/index.d.ts +2 -0
- package/dist/types/src/components/Popover/index.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Banner.d.ts +8 -0
- package/dist/types/src/components/SimpleLayout/Banner.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/Main.d.ts +9 -0
- package/dist/types/src/components/SimpleLayout/Main.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts +8 -0
- package/dist/types/src/components/SimpleLayout/NavBar.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts +39 -0
- package/dist/types/src/components/SimpleLayout/NavBar.stories.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts +3 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts +37 -0
- package/dist/types/src/components/SimpleLayout/SimpleLayout.stories.d.ts.map +1 -0
- package/dist/types/src/components/SimpleLayout/index.d.ts +2 -0
- package/dist/types/src/components/SimpleLayout/index.d.ts.map +1 -0
- package/dist/types/src/components/Workspace/Workspace.d.ts +9 -0
- package/dist/types/src/components/Workspace/Workspace.d.ts.map +1 -0
- package/dist/types/src/components/Workspace/index.d.ts +2 -0
- package/dist/types/src/components/Workspace/index.d.ts.map +1 -0
- package/dist/types/src/components/hooks.d.ts +5 -0
- package/dist/types/src/components/hooks.d.ts.map +1 -0
- package/dist/types/src/components/index.d.ts +6 -0
- package/dist/types/src/components/index.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +2 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts +7 -0
- package/dist/types/src/hooks/useSimpleLayoutState.d.ts.map +1 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +3 -0
- package/dist/types/src/meta.d.ts.map +1 -0
- package/dist/types/src/translations.d.ts +20 -0
- package/dist/types/src/translations.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +31 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/events.d.ts +6 -0
- package/dist/types/src/types/events.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +3 -0
- package/dist/types/src/types/index.d.ts.map +1 -0
- package/dist/types/tsconfig.tsbuildinfo +1 -0
- package/package.json +29 -24
- package/src/SimpleLayoutPlugin.ts +20 -4
- package/src/capabilities/index.ts +3 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +82 -39
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +40 -0
- package/src/capabilities/spotlight-dismiss/index.ts +7 -0
- package/src/{hooks/useSpotlightDismiss.ts → capabilities/spotlight-dismiss/spotlight-dismiss.ts} +31 -40
- package/src/capabilities/state/state.tsx +21 -32
- package/src/capabilities/url-handler/index.ts +7 -0
- package/src/capabilities/url-handler/url-handler.ts +80 -0
- package/src/components/Dialog/Dialog.tsx +14 -14
- package/src/components/Home/Home.tsx +53 -61
- package/src/components/Popover/Popover.tsx +45 -27
- package/src/components/SimpleLayout/Banner.tsx +50 -28
- package/src/components/SimpleLayout/Main.tsx +40 -44
- package/src/components/SimpleLayout/NavBar.tsx +18 -41
- package/src/components/SimpleLayout/SimpleLayout.stories.tsx +2 -9
- package/src/components/SimpleLayout/SimpleLayout.tsx +0 -1
- package/src/components/Workspace/Workspace.tsx +115 -0
- package/src/components/Workspace/index.ts +5 -0
- package/src/components/hooks.ts +30 -0
- package/src/components/index.ts +1 -0
- package/src/hooks/index.ts +1 -1
- package/src/hooks/useSimpleLayoutState.ts +30 -0
- package/src/types/capabilities.ts +8 -1
- package/src/types/events.ts +14 -0
- package/src/types/index.ts +1 -0
- /package/src/components/SimpleLayout/{NavBarstories.tsx → NavBar.stories.tsx} +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// src/meta.ts
|
|
2
|
+
import { trim } from "@dxos/util";
|
|
3
|
+
var meta = {
|
|
4
|
+
id: "dxos.org/plugin/simple-layout",
|
|
5
|
+
name: "Simple Layout",
|
|
6
|
+
description: trim`
|
|
7
|
+
Minimal layout plugin for simplified UI contexts like popover windows.
|
|
8
|
+
Provides basic content rendering without sidebars or complex navigation.
|
|
9
|
+
`,
|
|
10
|
+
icon: "ph--layout--regular"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/types/capabilities.ts
|
|
14
|
+
import { Capability } from "@dxos/app-framework";
|
|
15
|
+
var SimpleLayoutState = Capability.make(`${meta.id}/state`);
|
|
16
|
+
|
|
17
|
+
// src/types/events.ts
|
|
18
|
+
import { Common } from "@dxos/app-framework";
|
|
19
|
+
(function(SimpleLayoutEvents2) {
|
|
20
|
+
SimpleLayoutEvents2.StateReady = Common.ActivationEvent.createStateEvent(SimpleLayoutState.identifier);
|
|
21
|
+
})(SimpleLayoutEvents || (SimpleLayoutEvents = {}));
|
|
22
|
+
var SimpleLayoutEvents;
|
|
23
|
+
|
|
24
|
+
export {
|
|
25
|
+
meta,
|
|
26
|
+
SimpleLayoutState,
|
|
27
|
+
SimpleLayoutEvents
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=chunk-CLPGTNWJ.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/meta.ts", "../../../src/types/capabilities.ts", "../../../src/types/events.ts"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Plugin } from '@dxos/app-framework';\nimport { trim } from '@dxos/util';\n\nexport const meta: Plugin.Meta = {\n id: 'dxos.org/plugin/simple-layout',\n name: 'Simple Layout',\n description: trim`\n Minimal layout plugin for simplified UI contexts like popover windows.\n Provides basic content rendering without sidebars or complex navigation.\n `,\n icon: 'ph--layout--regular',\n};\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type Atom } from '@effect-atom/atom-react';\n\nimport { Capability } from '@dxos/app-framework';\nimport { type Label } from '@dxos/react-ui';\n\nimport { meta } from '../meta';\n\n// TODO(wittjosiah): Handle toasts.\nexport type SimpleLayoutState = {\n /** Data to be passed to the main content Surface. */\n content?: any;\n\n dialogOpen: boolean;\n dialogType?: 'default' | 'alert';\n dialogBlockAlign?: 'start' | 'center' | 'end';\n dialogOverlayClasses?: string;\n dialogOverlayStyle?: Record<string, any>;\n /** Data to be passed to the dialog Surface. */\n dialogContent?: any;\n\n popoverOpen?: boolean;\n popoverSide?: 'top' | 'right' | 'bottom' | 'left';\n popoverVariant?: 'virtual' | 'react';\n popoverAnchor?: HTMLButtonElement;\n popoverAnchorId?: string;\n popoverKind?: 'base' | 'card';\n popoverTitle?: Label;\n popoverContent?: any;\n\n workspace: string;\n previousWorkspace: string;\n active?: string;\n /** Stack of previously active item IDs for back navigation. */\n history: string[];\n\n /** Whether running in popover window context (hides mobile-specific UI). */\n isPopover?: boolean;\n};\n\nexport const SimpleLayoutState = Capability.make<Atom.Writable<SimpleLayoutState>>(`${meta.id}/state`);\n", "//\n// Copyright 2025 DXOS.org\n//\n\nimport { type ActivationEvent, Common } from '@dxos/app-framework';\n\nimport { SimpleLayoutState } from './capabilities';\n\nexport namespace SimpleLayoutEvents {\n /** Fired when SimpleLayoutState capability is ready. */\n export const StateReady: ActivationEvent.ActivationEvent = Common.ActivationEvent.createStateEvent(\n SimpleLayoutState.identifier,\n );\n}\n"],
|
|
5
|
+
"mappings": ";AAKA,SAASA,YAAY;AAEd,IAAMC,OAAoB;EAC/BC,IAAI;EACJC,MAAM;EACNC,aAAaC;;;;EAIbC,MAAM;AACR;;;ACTA,SAASC,kBAAkB;AAqCpB,IAAMC,oBAAoBC,WAAWC,KAAuC,GAAGC,KAAKC,EAAE,QAAQ;;;ACvCrG,SAA+BC,cAAc;UAI5BC,qBAAAA;sBAEFC,aAA8CC,OAAOC,gBAAgBC,iBAChFC,kBAAkBC,UAAU;AAEhC,GALiBN,uBAAAA,qBAAAA,CAAAA,EAAAA;;",
|
|
6
|
+
"names": ["trim", "meta", "id", "name", "description", "trim", "icon", "Capability", "SimpleLayoutState", "Capability", "make", "meta", "id", "Common", "SimpleLayoutEvents", "StateReady", "Common", "ActivationEvent", "createStateEvent", "SimpleLayoutState", "identifier"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,613 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SimpleLayoutState,
|
|
3
|
+
meta
|
|
4
|
+
} from "./chunk-CLPGTNWJ.mjs";
|
|
5
|
+
|
|
6
|
+
// src/components/Home/Home.tsx
|
|
7
|
+
import React, { useCallback, useEffect as useEffect2, useMemo, useRef } from "react";
|
|
8
|
+
import { Common } from "@dxos/app-framework";
|
|
9
|
+
import { useAppGraph as useAppGraph2, useOperationInvoker } from "@dxos/app-framework/react";
|
|
10
|
+
import { Node, useConnections } from "@dxos/plugin-graph";
|
|
11
|
+
import { Avatar, Icon, Toolbar, toLocalizedString, useTranslation } from "@dxos/react-ui";
|
|
12
|
+
import { Card, Layout, Mosaic } from "@dxos/react-ui-mosaic";
|
|
13
|
+
import { SearchList, useSearchListItem, useSearchListResults } from "@dxos/react-ui-searchlist";
|
|
14
|
+
import { mx } from "@dxos/ui-theme";
|
|
15
|
+
import { byPosition } from "@dxos/util";
|
|
16
|
+
|
|
17
|
+
// src/components/hooks.ts
|
|
18
|
+
import { useEffect } from "react";
|
|
19
|
+
import { useAppGraph } from "@dxos/app-framework/react";
|
|
20
|
+
import { Graph } from "@dxos/plugin-graph";
|
|
21
|
+
var useLoadDescendents = (nodeId) => {
|
|
22
|
+
const { graph } = useAppGraph();
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const frame = requestAnimationFrame(() => {
|
|
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
|
+
return () => cancelAnimationFrame(frame);
|
|
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
|
+
useLoadDescendents(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(Layout.Main, {
|
|
62
|
+
toolbar: true
|
|
63
|
+
}, /* @__PURE__ */ React.createElement(SearchList.Root, {
|
|
64
|
+
onSearch: handleSearch
|
|
65
|
+
}, /* @__PURE__ */ React.createElement(Toolbar.Root, null, /* @__PURE__ */ React.createElement(SearchList.Input, {
|
|
66
|
+
placeholder: t("search placeholder"),
|
|
67
|
+
autoFocus: true
|
|
68
|
+
})), /* @__PURE__ */ React.createElement(SearchList.Content, null, /* @__PURE__ */ React.createElement(Mosaic.Container, {
|
|
69
|
+
asChild: true
|
|
70
|
+
}, /* @__PURE__ */ React.createElement(Mosaic.Viewport, {
|
|
71
|
+
padding: true
|
|
72
|
+
}, /* @__PURE__ */ React.createElement(Mosaic.Stack, {
|
|
73
|
+
items: results,
|
|
74
|
+
getId: (node) => node.id,
|
|
75
|
+
Tile: WorkspaceTile
|
|
76
|
+
}))))));
|
|
77
|
+
};
|
|
78
|
+
var WorkspaceTile = ({ data }) => {
|
|
79
|
+
const { t } = useTranslation(meta.id);
|
|
80
|
+
const { invokePromise } = useOperationInvoker();
|
|
81
|
+
const { selectedValue, registerItem, unregisterItem } = useSearchListItem();
|
|
82
|
+
const ref = useRef(null);
|
|
83
|
+
const handleSelect = useCallback(() => invokePromise(Common.LayoutOperation.SwitchWorkspace, {
|
|
84
|
+
subject: data.id
|
|
85
|
+
}), [
|
|
86
|
+
invokePromise,
|
|
87
|
+
data.id
|
|
88
|
+
]);
|
|
89
|
+
useLoadDescendents(data.id);
|
|
90
|
+
const name = toLocalizedString(data.properties.label, t);
|
|
91
|
+
const isSelected = selectedValue === data.id;
|
|
92
|
+
useEffect2(() => {
|
|
93
|
+
if (ref.current) {
|
|
94
|
+
registerItem(data.id, ref.current, handleSelect);
|
|
95
|
+
}
|
|
96
|
+
return () => unregisterItem(data.id);
|
|
97
|
+
}, [
|
|
98
|
+
data.id,
|
|
99
|
+
handleSelect,
|
|
100
|
+
registerItem,
|
|
101
|
+
unregisterItem
|
|
102
|
+
]);
|
|
103
|
+
useEffect2(() => {
|
|
104
|
+
if (isSelected && ref.current) {
|
|
105
|
+
ref.current.scrollIntoView({
|
|
106
|
+
block: "nearest",
|
|
107
|
+
behavior: "smooth"
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}, [
|
|
111
|
+
isSelected
|
|
112
|
+
]);
|
|
113
|
+
return /* @__PURE__ */ React.createElement(Card.Root, {
|
|
114
|
+
ref,
|
|
115
|
+
role: "button",
|
|
116
|
+
fullWidth: true,
|
|
117
|
+
tabIndex: -1,
|
|
118
|
+
"data-selected": isSelected,
|
|
119
|
+
classNames: mx("dx-focus-ring", isSelected && "bg-hoverOverlay"),
|
|
120
|
+
onClick: handleSelect
|
|
121
|
+
}, /* @__PURE__ */ React.createElement(Card.Toolbar, {
|
|
122
|
+
density: "coarse"
|
|
123
|
+
}, /* @__PURE__ */ React.createElement(Avatar.Root, null, /* @__PURE__ */ React.createElement(Avatar.Content, {
|
|
124
|
+
icon: data.properties.icon,
|
|
125
|
+
hue: data.properties.hue,
|
|
126
|
+
hueVariant: "transparent",
|
|
127
|
+
variant: "square",
|
|
128
|
+
size: 12,
|
|
129
|
+
fallback: name
|
|
130
|
+
}), /* @__PURE__ */ React.createElement(Avatar.Label, null, name), /* @__PURE__ */ React.createElement(Icon, {
|
|
131
|
+
icon: "ph--caret-right--regular"
|
|
132
|
+
}))));
|
|
133
|
+
};
|
|
134
|
+
var filterItems = (node, disposition) => {
|
|
135
|
+
return node.properties.disposition === disposition;
|
|
136
|
+
};
|
|
137
|
+
var useItemsByDisposition = (disposition, sort = false) => {
|
|
138
|
+
const { graph } = useAppGraph2();
|
|
139
|
+
const connections = useConnections(graph, Node.RootId);
|
|
140
|
+
const filtered = connections.filter((node) => filterItems(node, disposition));
|
|
141
|
+
return sort ? filtered.toSorted((a, b) => byPosition(a.properties, b.properties)) : filtered;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
145
|
+
import React9 from "react";
|
|
146
|
+
|
|
147
|
+
// src/components/Dialog/Dialog.tsx
|
|
148
|
+
import React3 from "react";
|
|
149
|
+
import { Surface } from "@dxos/app-framework/react";
|
|
150
|
+
import { AlertDialog, Dialog as NaturalDialog } from "@dxos/react-ui";
|
|
151
|
+
|
|
152
|
+
// src/hooks/useSimpleLayoutState.ts
|
|
153
|
+
import { RegistryContext, useAtomValue } from "@effect-atom/atom-react";
|
|
154
|
+
import { useCallback as useCallback2, useContext } from "react";
|
|
155
|
+
import { useCapability } from "@dxos/app-framework/react";
|
|
156
|
+
var useSimpleLayoutState = () => {
|
|
157
|
+
const registry = useContext(RegistryContext);
|
|
158
|
+
const stateAtom = useCapability(SimpleLayoutState);
|
|
159
|
+
const state = useAtomValue(stateAtom);
|
|
160
|
+
const updateState = useCallback2((fn) => {
|
|
161
|
+
registry.set(stateAtom, fn(registry.get(stateAtom)));
|
|
162
|
+
}, [
|
|
163
|
+
registry,
|
|
164
|
+
stateAtom
|
|
165
|
+
]);
|
|
166
|
+
return {
|
|
167
|
+
state,
|
|
168
|
+
updateState
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
// src/components/ContentError.tsx
|
|
173
|
+
import React2 from "react";
|
|
174
|
+
import { useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
175
|
+
import { descriptionMessage, mx as mx2 } from "@dxos/ui-theme";
|
|
176
|
+
var ContentError = ({ error }) => {
|
|
177
|
+
const { t } = useTranslation2(meta.id);
|
|
178
|
+
const errorString = error?.toString() ?? "";
|
|
179
|
+
return /* @__PURE__ */ React2.createElement("div", {
|
|
180
|
+
role: "none",
|
|
181
|
+
className: "grid place-items-center overflow-y-auto attention-surface"
|
|
182
|
+
}, /* @__PURE__ */ React2.createElement("p", {
|
|
183
|
+
role: "alert",
|
|
184
|
+
className: mx2(descriptionMessage, "p-2 break-all rounded-sm")
|
|
185
|
+
}, error ? errorString : t("error fallback message")));
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// src/components/Dialog/Dialog.tsx
|
|
189
|
+
var Dialog = () => {
|
|
190
|
+
const { state, updateState } = useSimpleLayoutState();
|
|
191
|
+
const DialogRoot = state.dialogType === "alert" ? AlertDialog.Root : NaturalDialog.Root;
|
|
192
|
+
const DialogOverlay = state.dialogType === "alert" ? AlertDialog.Overlay : NaturalDialog.Overlay;
|
|
193
|
+
return /* @__PURE__ */ React3.createElement(DialogRoot, {
|
|
194
|
+
modal: state.dialogBlockAlign !== "end",
|
|
195
|
+
open: state.dialogOpen,
|
|
196
|
+
onOpenChange: (nextOpen) => updateState((s) => ({
|
|
197
|
+
...s,
|
|
198
|
+
dialogOpen: nextOpen
|
|
199
|
+
}))
|
|
200
|
+
}, state.dialogBlockAlign === "end" ? /* @__PURE__ */ React3.createElement(Surface, {
|
|
201
|
+
role: "dialog",
|
|
202
|
+
data: state.dialogContent,
|
|
203
|
+
limit: 1,
|
|
204
|
+
fallback: ContentError
|
|
205
|
+
}) : /* @__PURE__ */ React3.createElement(DialogOverlay, {
|
|
206
|
+
blockAlign: state.dialogBlockAlign,
|
|
207
|
+
classNames: state.dialogOverlayClasses,
|
|
208
|
+
style: state.dialogOverlayStyle
|
|
209
|
+
}, /* @__PURE__ */ React3.createElement(Surface, {
|
|
210
|
+
role: "dialog",
|
|
211
|
+
data: state.dialogContent,
|
|
212
|
+
limit: 1,
|
|
213
|
+
fallback: ContentError
|
|
214
|
+
})));
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
// src/components/Popover/Popover.tsx
|
|
218
|
+
import { createContext } from "@radix-ui/react-context";
|
|
219
|
+
import React4, { useCallback as useCallback3, useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState } from "react";
|
|
220
|
+
import { Surface as Surface2 } from "@dxos/app-framework/react";
|
|
221
|
+
import { Popover, toLocalizedString as toLocalizedString2, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
222
|
+
import { Card as Card2 } from "@dxos/react-ui-mosaic";
|
|
223
|
+
var DEBOUNCE_DELAY = 40;
|
|
224
|
+
var [LayoutPopoverProvider, useLayoutPopoverContext] = createContext("LayoutPopover");
|
|
225
|
+
var PopoverRoot = ({ children }) => {
|
|
226
|
+
const { state } = useSimpleLayoutState();
|
|
227
|
+
const [open, setOpen] = useState(false);
|
|
228
|
+
const virtualRef = useRef2(null);
|
|
229
|
+
const [virtualIter, setVirtualIter] = useState(0);
|
|
230
|
+
const debounceRef = useRef2(null);
|
|
231
|
+
useEffect3(() => {
|
|
232
|
+
setOpen(false);
|
|
233
|
+
if (state.popoverOpen) {
|
|
234
|
+
if (debounceRef.current) {
|
|
235
|
+
clearTimeout(debounceRef.current);
|
|
236
|
+
}
|
|
237
|
+
if (state.popoverAnchor && virtualRef.current !== state.popoverAnchor) {
|
|
238
|
+
virtualRef.current = state.popoverAnchor ?? null;
|
|
239
|
+
setVirtualIter((iter) => iter + 1);
|
|
240
|
+
}
|
|
241
|
+
debounceRef.current = setTimeout(() => setOpen(true), DEBOUNCE_DELAY);
|
|
242
|
+
}
|
|
243
|
+
}, [
|
|
244
|
+
state.popoverOpen,
|
|
245
|
+
state.popoverAnchorId,
|
|
246
|
+
state.popoverAnchor,
|
|
247
|
+
state.popoverContent
|
|
248
|
+
]);
|
|
249
|
+
return /* @__PURE__ */ React4.createElement(LayoutPopoverProvider, {
|
|
250
|
+
setOpen
|
|
251
|
+
}, /* @__PURE__ */ React4.createElement(Popover.Root, {
|
|
252
|
+
modal: false,
|
|
253
|
+
open
|
|
254
|
+
}, state.popoverAnchor && /* @__PURE__ */ React4.createElement(Popover.VirtualTrigger, {
|
|
255
|
+
key: virtualIter,
|
|
256
|
+
virtualRef
|
|
257
|
+
}), children));
|
|
258
|
+
};
|
|
259
|
+
var PopoverContent = () => {
|
|
260
|
+
const { t } = useTranslation3(meta.id);
|
|
261
|
+
const { state, updateState } = useSimpleLayoutState();
|
|
262
|
+
const { setOpen } = useLayoutPopoverContext("PopoverContent");
|
|
263
|
+
const handleClose = useCallback3(() => {
|
|
264
|
+
setOpen(false);
|
|
265
|
+
updateState((s) => ({
|
|
266
|
+
...s,
|
|
267
|
+
popoverOpen: false,
|
|
268
|
+
popoverAnchor: void 0,
|
|
269
|
+
popoverAnchorId: void 0,
|
|
270
|
+
popoverSide: void 0
|
|
271
|
+
}));
|
|
272
|
+
}, [
|
|
273
|
+
setOpen,
|
|
274
|
+
updateState
|
|
275
|
+
]);
|
|
276
|
+
const handleInteractOutside = useCallback3((event) => {
|
|
277
|
+
if (
|
|
278
|
+
// TODO(thure): CodeMirror should not focus itself when it updates.
|
|
279
|
+
event.type === "dismissableLayer.focusOutside" && event.currentTarget?.classList.contains("cm-content")
|
|
280
|
+
) {
|
|
281
|
+
event.preventDefault();
|
|
282
|
+
} else {
|
|
283
|
+
handleClose();
|
|
284
|
+
}
|
|
285
|
+
}, [
|
|
286
|
+
handleClose
|
|
287
|
+
]);
|
|
288
|
+
const collisionBoundaries = useMemo2(() => {
|
|
289
|
+
const closest = state.popoverAnchor?.closest("[data-popover-collision-boundary]");
|
|
290
|
+
return closest ? [
|
|
291
|
+
closest
|
|
292
|
+
] : [];
|
|
293
|
+
}, [
|
|
294
|
+
state.popoverAnchor
|
|
295
|
+
]);
|
|
296
|
+
return /* @__PURE__ */ React4.createElement(Popover.Portal, null, /* @__PURE__ */ React4.createElement(Popover.Content, {
|
|
297
|
+
side: state.popoverSide,
|
|
298
|
+
sticky: "always",
|
|
299
|
+
hideWhenDetached: true,
|
|
300
|
+
collisionBoundary: collisionBoundaries,
|
|
301
|
+
onInteractOutside: handleInteractOutside,
|
|
302
|
+
onEscapeKeyDown: handleInteractOutside
|
|
303
|
+
}, /* @__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, {
|
|
304
|
+
onClick: handleClose
|
|
305
|
+
})), /* @__PURE__ */ React4.createElement(Surface2, {
|
|
306
|
+
role: "card--content",
|
|
307
|
+
data: state.popoverContent,
|
|
308
|
+
limit: 1
|
|
309
|
+
})), state.popoverKind === "base" && /* @__PURE__ */ React4.createElement(Surface2, {
|
|
310
|
+
role: "popover",
|
|
311
|
+
data: state.popoverContent,
|
|
312
|
+
limit: 1
|
|
313
|
+
})), /* @__PURE__ */ React4.createElement(Popover.Arrow, null)));
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// src/components/SimpleLayout/Main.tsx
|
|
317
|
+
import React8, { useCallback as useCallback5, useMemo as useMemo4 } from "react";
|
|
318
|
+
import { Surface as Surface3, useAppGraph as useAppGraph5 } from "@dxos/app-framework/react";
|
|
319
|
+
import { log } from "@dxos/log";
|
|
320
|
+
import { useNode } from "@dxos/plugin-graph";
|
|
321
|
+
import { Main as NaturalMain } from "@dxos/react-ui";
|
|
322
|
+
import { ATTENDABLE_PATH_SEPARATOR } from "@dxos/react-ui-attention";
|
|
323
|
+
import { Mosaic as Mosaic2 } from "@dxos/react-ui-mosaic";
|
|
324
|
+
import { mx as mx5 } from "@dxos/ui-theme";
|
|
325
|
+
|
|
326
|
+
// src/components/ContentLoading.tsx
|
|
327
|
+
import React5 from "react";
|
|
328
|
+
var ContentLoading = () => {
|
|
329
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
330
|
+
role: "none",
|
|
331
|
+
className: "grid place-items-center attention-surface"
|
|
332
|
+
});
|
|
333
|
+
};
|
|
334
|
+
|
|
335
|
+
// src/components/SimpleLayout/Banner.tsx
|
|
336
|
+
import React6, { useCallback as useCallback4, useMemo as useMemo3 } from "react";
|
|
337
|
+
import { Common as Common2 } from "@dxos/app-framework";
|
|
338
|
+
import { useAppGraph as useAppGraph3, useOperationInvoker as useOperationInvoker2 } from "@dxos/app-framework/react";
|
|
339
|
+
import { Graph as Graph2, Node as Node2 } from "@dxos/plugin-graph";
|
|
340
|
+
import { IconButton, Toolbar as Toolbar2, toLocalizedString as toLocalizedString3, useTranslation as useTranslation4 } from "@dxos/react-ui";
|
|
341
|
+
import { mx as mx3, osTranslations } from "@dxos/ui-theme";
|
|
342
|
+
var isWorkspaceOrCollectionChild = (graph, itemId) => {
|
|
343
|
+
const parents = Graph2.getConnections(graph, itemId, "inbound");
|
|
344
|
+
return parents.some((node) => node.properties.disposition === "workspace" || node.properties.disposition === "collection");
|
|
345
|
+
};
|
|
346
|
+
var Banner = ({ node, classNames }) => {
|
|
347
|
+
const { t } = useTranslation4(meta.id);
|
|
348
|
+
const { state } = useSimpleLayoutState();
|
|
349
|
+
const { invokePromise } = useOperationInvoker2();
|
|
350
|
+
const { graph } = useAppGraph3();
|
|
351
|
+
const label = (node && toLocalizedString3(node.properties.label, t)) ?? t("current app name", {
|
|
352
|
+
ns: osTranslations
|
|
353
|
+
});
|
|
354
|
+
const isTopLevelItem = useMemo3(() => {
|
|
355
|
+
if (!state.active) {
|
|
356
|
+
return false;
|
|
357
|
+
}
|
|
358
|
+
return isWorkspaceOrCollectionChild(graph, state.active);
|
|
359
|
+
}, [
|
|
360
|
+
graph,
|
|
361
|
+
state.active
|
|
362
|
+
]);
|
|
363
|
+
const handleClick = useCallback4(async () => {
|
|
364
|
+
if (state.active) {
|
|
365
|
+
if (state.history.length === 0 && isTopLevelItem) {
|
|
366
|
+
await invokePromise(Common2.LayoutOperation.SwitchWorkspace, {
|
|
367
|
+
subject: Node2.RootId
|
|
368
|
+
});
|
|
369
|
+
} else {
|
|
370
|
+
await invokePromise(Common2.LayoutOperation.Close, {
|
|
371
|
+
subject: [
|
|
372
|
+
state.active
|
|
373
|
+
]
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
} else {
|
|
377
|
+
await invokePromise(Common2.LayoutOperation.SwitchWorkspace, {
|
|
378
|
+
subject: Node2.RootId
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}, [
|
|
382
|
+
invokePromise,
|
|
383
|
+
state.active,
|
|
384
|
+
state.history.length,
|
|
385
|
+
isTopLevelItem
|
|
386
|
+
]);
|
|
387
|
+
if (!node) {
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
return /* @__PURE__ */ React6.createElement(Toolbar2.Root, {
|
|
391
|
+
role: "banner",
|
|
392
|
+
classNames: mx3("grid grid-cols-[var(--rail-size)_1fr_var(--rail-size)]", classNames)
|
|
393
|
+
}, node.id !== Node2.RootId ? /* @__PURE__ */ React6.createElement(IconButton, {
|
|
394
|
+
iconOnly: true,
|
|
395
|
+
variant: "ghost",
|
|
396
|
+
icon: "ph--caret-left--regular",
|
|
397
|
+
label: t("back label"),
|
|
398
|
+
onClick: handleClick
|
|
399
|
+
}) : /* @__PURE__ */ React6.createElement("div", null), /* @__PURE__ */ React6.createElement("h1", {
|
|
400
|
+
className: "grow text-center truncate font-medium"
|
|
401
|
+
}, label), /* @__PURE__ */ React6.createElement(IconButton, {
|
|
402
|
+
iconOnly: true,
|
|
403
|
+
variant: "ghost",
|
|
404
|
+
icon: "ph--dots-three-vertical--regular",
|
|
405
|
+
label: t("menu label")
|
|
406
|
+
}));
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
// src/components/SimpleLayout/NavBar.tsx
|
|
410
|
+
import React7 from "react";
|
|
411
|
+
import { useAppGraph as useAppGraph4 } from "@dxos/app-framework/react";
|
|
412
|
+
import { Node as Node3, useActionRunner, useConnections as useConnections2 } from "@dxos/plugin-graph";
|
|
413
|
+
import { IconButton as IconButton2, Toolbar as Toolbar3, Tooltip, useTranslation as useTranslation5 } from "@dxos/react-ui";
|
|
414
|
+
import { DropdownMenu, MenuProvider } from "@dxos/react-ui-menu";
|
|
415
|
+
import { mx as mx4 } from "@dxos/ui-theme";
|
|
416
|
+
var NavBar = ({ classNames, activeId, onActiveIdChange }) => {
|
|
417
|
+
const { t } = useTranslation5(meta.id);
|
|
418
|
+
const { graph } = useAppGraph4();
|
|
419
|
+
const runAction = useActionRunner();
|
|
420
|
+
const connections = useConnections2(graph, Node3.RootId);
|
|
421
|
+
const menuActions = connections.filter((node) => node.properties.disposition === "menu");
|
|
422
|
+
const isBrowseActive = activeId !== "notifications" && activeId !== "profile";
|
|
423
|
+
return /* @__PURE__ */ React7.createElement(Toolbar3.Root, {
|
|
424
|
+
classNames: mx4("justify-center", classNames)
|
|
425
|
+
}, /* @__PURE__ */ React7.createElement(MenuProvider, {
|
|
426
|
+
onAction: runAction
|
|
427
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Root, {
|
|
428
|
+
items: menuActions
|
|
429
|
+
}, /* @__PURE__ */ React7.createElement(Tooltip.Trigger, {
|
|
430
|
+
asChild: true,
|
|
431
|
+
content: t("app menu label")
|
|
432
|
+
}, /* @__PURE__ */ React7.createElement(DropdownMenu.Trigger, {
|
|
433
|
+
asChild: true,
|
|
434
|
+
"data-testid": "spacePlugin.addSpace"
|
|
435
|
+
}, /* @__PURE__ */ React7.createElement(IconButton2, {
|
|
436
|
+
icon: "ph--plus--regular",
|
|
437
|
+
iconOnly: true,
|
|
438
|
+
label: t("main menu label")
|
|
439
|
+
}))))));
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// src/components/SimpleLayout/Main.tsx
|
|
443
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/plugins/plugin-simple-layout/src/components/SimpleLayout/Main.tsx";
|
|
444
|
+
var Main = () => {
|
|
445
|
+
const { state } = useSimpleLayoutState();
|
|
446
|
+
const id = state.active ?? state.workspace;
|
|
447
|
+
const showNavBar = !state.isPopover;
|
|
448
|
+
const { graph } = useAppGraph5();
|
|
449
|
+
const node = useNode(graph, id);
|
|
450
|
+
const placeholder = useMemo4(() => /* @__PURE__ */ React8.createElement(ContentLoading, null), []);
|
|
451
|
+
const data = useMemo4(() => {
|
|
452
|
+
const { variant } = parseEntryId(id);
|
|
453
|
+
return node && {
|
|
454
|
+
attendableId: id,
|
|
455
|
+
subject: node.data,
|
|
456
|
+
properties: node.properties,
|
|
457
|
+
popoverAnchorId: state.popoverAnchorId,
|
|
458
|
+
variant
|
|
459
|
+
};
|
|
460
|
+
}, [
|
|
461
|
+
id,
|
|
462
|
+
node,
|
|
463
|
+
node?.data,
|
|
464
|
+
node?.properties,
|
|
465
|
+
state.popoverAnchorId
|
|
466
|
+
]);
|
|
467
|
+
const handleActiveIdChange = useCallback5((nextActiveId) => {
|
|
468
|
+
log.info("navigate", {
|
|
469
|
+
nextActiveId
|
|
470
|
+
}, {
|
|
471
|
+
F: __dxlog_file,
|
|
472
|
+
L: 48,
|
|
473
|
+
S: void 0,
|
|
474
|
+
C: (f, a) => f(...a)
|
|
475
|
+
});
|
|
476
|
+
}, []);
|
|
477
|
+
return /* @__PURE__ */ React8.createElement(Mosaic2.Root, null, /* @__PURE__ */ React8.createElement(NaturalMain.Root, {
|
|
478
|
+
complementarySidebarState: "closed",
|
|
479
|
+
navigationSidebarState: "closed"
|
|
480
|
+
}, /* @__PURE__ */ React8.createElement(NaturalMain.Content, {
|
|
481
|
+
bounce: true,
|
|
482
|
+
classNames: mx5("dx-mobile-main dx-mobile-main-scroll-area--flush", "grid bs-full overflow-hidden", showNavBar ? "grid-rows-[min-content_1fr_min-content]" : "grid-rows-[min-content_1fr]")
|
|
483
|
+
}, /* @__PURE__ */ React8.createElement(Banner, {
|
|
484
|
+
classNames: "border-be border-separator",
|
|
485
|
+
node
|
|
486
|
+
}), /* @__PURE__ */ React8.createElement("article", {
|
|
487
|
+
className: "contents"
|
|
488
|
+
}, /* @__PURE__ */ React8.createElement(Surface3, {
|
|
489
|
+
key: id,
|
|
490
|
+
role: "article",
|
|
491
|
+
data,
|
|
492
|
+
limit: 1,
|
|
493
|
+
fallback: ContentError,
|
|
494
|
+
placeholder
|
|
495
|
+
})), showNavBar && /* @__PURE__ */ React8.createElement(NavBar, {
|
|
496
|
+
classNames: "border-bs border-separator",
|
|
497
|
+
activeId: id,
|
|
498
|
+
onActiveIdChange: handleActiveIdChange
|
|
499
|
+
}))));
|
|
500
|
+
};
|
|
501
|
+
var parseEntryId = (entryId) => {
|
|
502
|
+
const [id, variant] = entryId.split(ATTENDABLE_PATH_SEPARATOR);
|
|
503
|
+
return {
|
|
504
|
+
id,
|
|
505
|
+
variant
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
Main.displayName = "SimpleLayout.Main";
|
|
509
|
+
|
|
510
|
+
// src/components/SimpleLayout/SimpleLayout.tsx
|
|
511
|
+
var SimpleLayout = () => {
|
|
512
|
+
return /* @__PURE__ */ React9.createElement(PopoverRoot, null, /* @__PURE__ */ React9.createElement(Main, null), /* @__PURE__ */ React9.createElement(Dialog, null), /* @__PURE__ */ React9.createElement(PopoverContent, null));
|
|
513
|
+
};
|
|
514
|
+
|
|
515
|
+
// src/components/Workspace/Workspace.tsx
|
|
516
|
+
import React10, { useCallback as useCallback6, useEffect as useEffect4, useRef as useRef3 } from "react";
|
|
517
|
+
import { Common as Common3 } from "@dxos/app-framework";
|
|
518
|
+
import { useAppGraph as useAppGraph6, useOperationInvoker as useOperationInvoker3 } from "@dxos/app-framework/react";
|
|
519
|
+
import { useConnections as useConnections3 } from "@dxos/plugin-graph";
|
|
520
|
+
import { Avatar as Avatar2, Icon as Icon2, Toolbar as Toolbar4, toLocalizedString as toLocalizedString4, useTranslation as useTranslation6 } from "@dxos/react-ui";
|
|
521
|
+
import { Card as Card3, Layout as Layout2, Mosaic as Mosaic3 } from "@dxos/react-ui-mosaic";
|
|
522
|
+
import { SearchList as SearchList2, useSearchListItem as useSearchListItem2, useSearchListResults as useSearchListResults2 } from "@dxos/react-ui-searchlist";
|
|
523
|
+
import { mx as mx6 } from "@dxos/ui-theme";
|
|
524
|
+
var Workspace = ({ id }) => {
|
|
525
|
+
const { t } = useTranslation6(meta.id);
|
|
526
|
+
const { graph } = useAppGraph6();
|
|
527
|
+
useLoadDescendents(id);
|
|
528
|
+
const children = useConnections3(graph, id, "outbound");
|
|
529
|
+
const { results, handleSearch } = useSearchListResults2({
|
|
530
|
+
items: children,
|
|
531
|
+
extract: (child) => toLocalizedString4(child.properties.label, t)
|
|
532
|
+
});
|
|
533
|
+
return /* @__PURE__ */ React10.createElement(Layout2.Main, {
|
|
534
|
+
toolbar: true
|
|
535
|
+
}, /* @__PURE__ */ React10.createElement(SearchList2.Root, {
|
|
536
|
+
onSearch: handleSearch
|
|
537
|
+
}, /* @__PURE__ */ React10.createElement(Toolbar4.Root, null, /* @__PURE__ */ React10.createElement(SearchList2.Input, {
|
|
538
|
+
placeholder: t("search placeholder"),
|
|
539
|
+
autoFocus: true
|
|
540
|
+
})), /* @__PURE__ */ React10.createElement(SearchList2.Content, null, /* @__PURE__ */ React10.createElement(Mosaic3.Container, {
|
|
541
|
+
asChild: true
|
|
542
|
+
}, /* @__PURE__ */ React10.createElement(Mosaic3.Viewport, {
|
|
543
|
+
padding: true
|
|
544
|
+
}, /* @__PURE__ */ React10.createElement(Mosaic3.Stack, {
|
|
545
|
+
items: results,
|
|
546
|
+
getId: (child) => child.id,
|
|
547
|
+
Tile: WorkspaceChildTile
|
|
548
|
+
}))))));
|
|
549
|
+
};
|
|
550
|
+
var WorkspaceChildTile = ({ data }) => {
|
|
551
|
+
const { t } = useTranslation6(meta.id);
|
|
552
|
+
const { invokeSync } = useOperationInvoker3();
|
|
553
|
+
const ref = useRef3(null);
|
|
554
|
+
const { selectedValue, registerItem, unregisterItem } = useSearchListItem2();
|
|
555
|
+
const isSelected = selectedValue === data.id;
|
|
556
|
+
const name = toLocalizedString4(data.properties.label, t);
|
|
557
|
+
const handleSelect = useCallback6(() => invokeSync(Common3.LayoutOperation.Open, {
|
|
558
|
+
subject: [
|
|
559
|
+
data.id
|
|
560
|
+
]
|
|
561
|
+
}), [
|
|
562
|
+
invokeSync,
|
|
563
|
+
data.id
|
|
564
|
+
]);
|
|
565
|
+
useEffect4(() => {
|
|
566
|
+
if (ref.current) {
|
|
567
|
+
registerItem(data.id, ref.current, handleSelect);
|
|
568
|
+
}
|
|
569
|
+
return () => unregisterItem(data.id);
|
|
570
|
+
}, [
|
|
571
|
+
data.id,
|
|
572
|
+
handleSelect,
|
|
573
|
+
registerItem,
|
|
574
|
+
unregisterItem
|
|
575
|
+
]);
|
|
576
|
+
useEffect4(() => {
|
|
577
|
+
if (isSelected && ref.current) {
|
|
578
|
+
ref.current.scrollIntoView({
|
|
579
|
+
block: "nearest",
|
|
580
|
+
behavior: "smooth"
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
}, [
|
|
584
|
+
isSelected
|
|
585
|
+
]);
|
|
586
|
+
return /* @__PURE__ */ React10.createElement(Card3.Root, {
|
|
587
|
+
ref,
|
|
588
|
+
role: "button",
|
|
589
|
+
fullWidth: true,
|
|
590
|
+
tabIndex: -1,
|
|
591
|
+
"data-selected": isSelected,
|
|
592
|
+
classNames: mx6("dx-focus-ring", isSelected && "bg-hoverOverlay"),
|
|
593
|
+
onClick: handleSelect
|
|
594
|
+
}, /* @__PURE__ */ React10.createElement(Card3.Toolbar, {
|
|
595
|
+
density: "coarse"
|
|
596
|
+
}, /* @__PURE__ */ React10.createElement(Avatar2.Root, null, /* @__PURE__ */ React10.createElement(Avatar2.Content, {
|
|
597
|
+
hue: data.properties.hue,
|
|
598
|
+
icon: data.properties.icon,
|
|
599
|
+
hueVariant: "transparent",
|
|
600
|
+
variant: "square",
|
|
601
|
+
size: 12,
|
|
602
|
+
fallback: name
|
|
603
|
+
}), /* @__PURE__ */ React10.createElement(Avatar2.Label, null, name), /* @__PURE__ */ React10.createElement(Icon2, {
|
|
604
|
+
icon: "ph--caret-right--regular"
|
|
605
|
+
}))));
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
export {
|
|
609
|
+
Home,
|
|
610
|
+
SimpleLayout,
|
|
611
|
+
Workspace
|
|
612
|
+
};
|
|
613
|
+
//# sourceMappingURL=chunk-FK4M7GJV.mjs.map
|