@dxos/plugin-simple-layout 0.8.4-main.9735255 → 0.8.4-main.c351d160a8

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