@dxos/plugin-simple-layout 0.8.4-main.69d29f4 → 0.8.4-main.6fa680abb7

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