@vuu-ui/vuu-shell 3.0.0 → 3.1.0-beta.1

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 (252) hide show
  1. package/package.json +22 -19
  2. package/src/ShellContextProvider.mjs +20 -0
  3. package/src/app-header/AppHeader.css.js +21 -0
  4. package/src/app-header/AppHeader.mjs +97 -0
  5. package/src/app-header/index.mjs +1 -0
  6. package/src/application-provider/ApplicationContext.mjs +9 -0
  7. package/src/application-provider/ApplicationProvider.mjs +77 -0
  8. package/src/application-provider/index.mjs +1 -0
  9. package/src/feature/Feature.mjs +37 -0
  10. package/src/feature/FeatureErrorBoundary.mjs +33 -0
  11. package/src/feature/Loader.mjs +5 -0
  12. package/src/feature/index.mjs +1 -0
  13. package/src/feature-and-layout-provider/FeatureAndLayoutProvider.mjs +42 -0
  14. package/src/feature-and-layout-provider/index.mjs +1 -0
  15. package/src/feature-list/FeatureList.css.js +62 -0
  16. package/src/feature-list/FeatureList.mjs +128 -0
  17. package/src/feature-list/index.mjs +1 -0
  18. package/src/get-layout-history.mjs +7 -0
  19. package/src/index.mjs +14 -0
  20. package/src/left-nav/LeftNav.css.js +177 -0
  21. package/src/left-nav/LeftNav.mjs +193 -0
  22. package/src/left-nav/index.mjs +1 -0
  23. package/src/login/LoginPanel.css.js +72 -0
  24. package/src/login/LoginPanel.mjs +124 -0
  25. package/src/login/VuuLogo.mjs +108 -0
  26. package/src/persistence-manager/LocalPersistenceManager.mjs +156 -0
  27. package/src/persistence-manager/PersistenceManager.mjs +0 -0
  28. package/src/persistence-manager/PersistenceProvider.mjs +14 -0
  29. package/src/persistence-manager/RemotePersistenceManager.mjs +123 -0
  30. package/src/persistence-manager/StaticPersistenceManager.mjs +53 -0
  31. package/src/persistence-manager/index.mjs +5 -0
  32. package/src/shell-layout-templates/context-panel/ContextPanel.css.js +66 -0
  33. package/src/shell-layout-templates/context-panel/ContextPanel.mjs +92 -0
  34. package/src/shell-layout-templates/context-panel/index.mjs +1 -0
  35. package/src/shell-layout-templates/full-height-left-panel/useFullHeightLeftPanel.mjs +44 -0
  36. package/src/shell-layout-templates/index.mjs +3 -0
  37. package/src/shell-layout-templates/inlay-left-panel/useInlayLeftPanel.mjs +68 -0
  38. package/src/shell-layout-templates/left-main-tabs/useLeftMainTabs.mjs +32 -0
  39. package/src/shell-layout-templates/side-panel/SidePanel.css.js +9 -0
  40. package/src/shell-layout-templates/side-panel/SidePanel.mjs +31 -0
  41. package/src/shell-layout-templates/side-panel/index.mjs +1 -0
  42. package/src/shell-layout-templates/simple-content-pane/useSimpleContentPane.mjs +38 -0
  43. package/src/shell-layout-templates/useShellLayout.mjs +15 -0
  44. package/src/shell.css.js +59 -0
  45. package/src/shell.mjs +108 -0
  46. package/src/theme-switch/ThemeSwitch.css.js +34 -0
  47. package/src/theme-switch/ThemeSwitch.mjs +50 -0
  48. package/src/theme-switch/index.mjs +1 -0
  49. package/src/user-settings/SettingsForm.css.js +10 -0
  50. package/src/user-settings/SettingsForm.mjs +141 -0
  51. package/src/user-settings/UserSettingsPanel.css.js +9 -0
  52. package/src/user-settings/UserSettingsPanel.mjs +29 -0
  53. package/src/user-settings/index.mjs +2 -0
  54. package/src/workspace-management/LayoutList.css.js +74 -0
  55. package/src/workspace-management/LayoutList.mjs +130 -0
  56. package/src/workspace-management/LayoutTile.css.js +31 -0
  57. package/src/workspace-management/LayoutTile.mjs +41 -0
  58. package/src/workspace-management/SaveLayoutPanel.css.js +123 -0
  59. package/src/workspace-management/SaveLayoutPanel.mjs +141 -0
  60. package/src/workspace-management/WorkspaceProvider.mjs +209 -0
  61. package/src/workspace-management/defaultWorkspaceJSON.mjs +88 -0
  62. package/src/workspace-management/index.mjs +5 -0
  63. package/src/workspace-management/screenshot-utils.mjs +13 -0
  64. package/src/workspace-management/useWorkspaceContextMenuItems.mjs +58 -0
  65. package/cjs/ShellContextProvider.js +0 -25
  66. package/cjs/ShellContextProvider.js.map +0 -1
  67. package/cjs/app-header/AppHeader.css.js +0 -6
  68. package/cjs/app-header/AppHeader.css.js.map +0 -1
  69. package/cjs/app-header/AppHeader.js +0 -118
  70. package/cjs/app-header/AppHeader.js.map +0 -1
  71. package/cjs/application-provider/ApplicationContext.js +0 -17
  72. package/cjs/application-provider/ApplicationContext.js.map +0 -1
  73. package/cjs/application-provider/ApplicationProvider.js +0 -102
  74. package/cjs/application-provider/ApplicationProvider.js.map +0 -1
  75. package/cjs/feature/Feature.js +0 -54
  76. package/cjs/feature/Feature.js.map +0 -1
  77. package/cjs/feature/FeatureErrorBoundary.js +0 -30
  78. package/cjs/feature/FeatureErrorBoundary.js.map +0 -1
  79. package/cjs/feature-and-layout-provider/FeatureAndLayoutProvider.js +0 -60
  80. package/cjs/feature-and-layout-provider/FeatureAndLayoutProvider.js.map +0 -1
  81. package/cjs/feature-list/FeatureList.css.js +0 -6
  82. package/cjs/feature-list/FeatureList.css.js.map +0 -1
  83. package/cjs/feature-list/FeatureList.js +0 -109
  84. package/cjs/feature-list/FeatureList.js.map +0 -1
  85. package/cjs/index.js +0 -71
  86. package/cjs/index.js.map +0 -1
  87. package/cjs/left-nav/LeftNav.css.js +0 -6
  88. package/cjs/left-nav/LeftNav.css.js.map +0 -1
  89. package/cjs/left-nav/LeftNav.js +0 -202
  90. package/cjs/left-nav/LeftNav.js.map +0 -1
  91. package/cjs/login/LoginPanel.css.js +0 -6
  92. package/cjs/login/LoginPanel.css.js.map +0 -1
  93. package/cjs/login/LoginPanel.js +0 -110
  94. package/cjs/login/LoginPanel.js.map +0 -1
  95. package/cjs/login/VuuLogo.js +0 -134
  96. package/cjs/login/VuuLogo.js.map +0 -1
  97. package/cjs/persistence-manager/LocalPersistenceManager.js +0 -193
  98. package/cjs/persistence-manager/LocalPersistenceManager.js.map +0 -1
  99. package/cjs/persistence-manager/PersistenceProvider.js +0 -21
  100. package/cjs/persistence-manager/PersistenceProvider.js.map +0 -1
  101. package/cjs/persistence-manager/RemotePersistenceManager.js +0 -165
  102. package/cjs/persistence-manager/RemotePersistenceManager.js.map +0 -1
  103. package/cjs/persistence-manager/StaticPersistenceManager.js +0 -73
  104. package/cjs/persistence-manager/StaticPersistenceManager.js.map +0 -1
  105. package/cjs/shell-layout-templates/context-panel/ContextPanel.css.js +0 -6
  106. package/cjs/shell-layout-templates/context-panel/ContextPanel.css.js.map +0 -1
  107. package/cjs/shell-layout-templates/context-panel/ContextPanel.js +0 -100
  108. package/cjs/shell-layout-templates/context-panel/ContextPanel.js.map +0 -1
  109. package/cjs/shell-layout-templates/full-height-left-panel/useFullHeightLeftPanel.js +0 -51
  110. package/cjs/shell-layout-templates/full-height-left-panel/useFullHeightLeftPanel.js.map +0 -1
  111. package/cjs/shell-layout-templates/inlay-left-panel/useInlayLeftPanel.js +0 -83
  112. package/cjs/shell-layout-templates/inlay-left-panel/useInlayLeftPanel.js.map +0 -1
  113. package/cjs/shell-layout-templates/left-main-tabs/useLeftMainTabs.js +0 -46
  114. package/cjs/shell-layout-templates/left-main-tabs/useLeftMainTabs.js.map +0 -1
  115. package/cjs/shell-layout-templates/side-panel/SidePanel.css.js +0 -6
  116. package/cjs/shell-layout-templates/side-panel/SidePanel.css.js.map +0 -1
  117. package/cjs/shell-layout-templates/side-panel/SidePanel.js +0 -36
  118. package/cjs/shell-layout-templates/side-panel/SidePanel.js.map +0 -1
  119. package/cjs/shell-layout-templates/simple-content-pane/useSimpleContentPane.js +0 -48
  120. package/cjs/shell-layout-templates/simple-content-pane/useSimpleContentPane.js.map +0 -1
  121. package/cjs/shell-layout-templates/useShellLayout.js +0 -23
  122. package/cjs/shell-layout-templates/useShellLayout.js.map +0 -1
  123. package/cjs/shell.css.js +0 -6
  124. package/cjs/shell.css.js.map +0 -1
  125. package/cjs/shell.js +0 -137
  126. package/cjs/shell.js.map +0 -1
  127. package/cjs/theme-switch/ThemeSwitch.css.js +0 -6
  128. package/cjs/theme-switch/ThemeSwitch.css.js.map +0 -1
  129. package/cjs/theme-switch/ThemeSwitch.js +0 -56
  130. package/cjs/theme-switch/ThemeSwitch.js.map +0 -1
  131. package/cjs/user-settings/SettingsForm.css.js +0 -6
  132. package/cjs/user-settings/SettingsForm.css.js.map +0 -1
  133. package/cjs/user-settings/SettingsForm.js +0 -168
  134. package/cjs/user-settings/SettingsForm.js.map +0 -1
  135. package/cjs/user-settings/UserSettingsPanel.css.js +0 -6
  136. package/cjs/user-settings/UserSettingsPanel.css.js.map +0 -1
  137. package/cjs/user-settings/UserSettingsPanel.js +0 -42
  138. package/cjs/user-settings/UserSettingsPanel.js.map +0 -1
  139. package/cjs/workspace-management/LayoutList.css.js +0 -6
  140. package/cjs/workspace-management/LayoutList.css.js.map +0 -1
  141. package/cjs/workspace-management/LayoutList.js +0 -116
  142. package/cjs/workspace-management/LayoutList.js.map +0 -1
  143. package/cjs/workspace-management/LayoutTile.css.js +0 -6
  144. package/cjs/workspace-management/LayoutTile.css.js.map +0 -1
  145. package/cjs/workspace-management/LayoutTile.js +0 -41
  146. package/cjs/workspace-management/LayoutTile.js.map +0 -1
  147. package/cjs/workspace-management/SaveLayoutPanel.css.js +0 -6
  148. package/cjs/workspace-management/SaveLayoutPanel.css.js.map +0 -1
  149. package/cjs/workspace-management/SaveLayoutPanel.js +0 -128
  150. package/cjs/workspace-management/SaveLayoutPanel.js.map +0 -1
  151. package/cjs/workspace-management/WorkspaceProvider.js +0 -265
  152. package/cjs/workspace-management/WorkspaceProvider.js.map +0 -1
  153. package/cjs/workspace-management/defaultWorkspaceJSON.js +0 -101
  154. package/cjs/workspace-management/defaultWorkspaceJSON.js.map +0 -1
  155. package/cjs/workspace-management/screenshot-utils.js +0 -25
  156. package/cjs/workspace-management/screenshot-utils.js.map +0 -1
  157. package/cjs/workspace-management/useWorkspaceContextMenuItems.js +0 -72
  158. package/cjs/workspace-management/useWorkspaceContextMenuItems.js.map +0 -1
  159. package/esm/ShellContextProvider.js +0 -23
  160. package/esm/ShellContextProvider.js.map +0 -1
  161. package/esm/app-header/AppHeader.css.js +0 -4
  162. package/esm/app-header/AppHeader.css.js.map +0 -1
  163. package/esm/app-header/AppHeader.js +0 -116
  164. package/esm/app-header/AppHeader.js.map +0 -1
  165. package/esm/application-provider/ApplicationContext.js +0 -15
  166. package/esm/application-provider/ApplicationContext.js.map +0 -1
  167. package/esm/application-provider/ApplicationProvider.js +0 -96
  168. package/esm/application-provider/ApplicationProvider.js.map +0 -1
  169. package/esm/feature/Feature.js +0 -52
  170. package/esm/feature/Feature.js.map +0 -1
  171. package/esm/feature/FeatureErrorBoundary.js +0 -28
  172. package/esm/feature/FeatureErrorBoundary.js.map +0 -1
  173. package/esm/feature-and-layout-provider/FeatureAndLayoutProvider.js +0 -56
  174. package/esm/feature-and-layout-provider/FeatureAndLayoutProvider.js.map +0 -1
  175. package/esm/feature-list/FeatureList.css.js +0 -4
  176. package/esm/feature-list/FeatureList.css.js.map +0 -1
  177. package/esm/feature-list/FeatureList.js +0 -107
  178. package/esm/feature-list/FeatureList.js.map +0 -1
  179. package/esm/index.js +0 -25
  180. package/esm/index.js.map +0 -1
  181. package/esm/left-nav/LeftNav.css.js +0 -4
  182. package/esm/left-nav/LeftNav.css.js.map +0 -1
  183. package/esm/left-nav/LeftNav.js +0 -200
  184. package/esm/left-nav/LeftNav.js.map +0 -1
  185. package/esm/login/LoginPanel.css.js +0 -4
  186. package/esm/login/LoginPanel.css.js.map +0 -1
  187. package/esm/login/LoginPanel.js +0 -108
  188. package/esm/login/LoginPanel.js.map +0 -1
  189. package/esm/login/VuuLogo.js +0 -132
  190. package/esm/login/VuuLogo.js.map +0 -1
  191. package/esm/persistence-manager/LocalPersistenceManager.js +0 -191
  192. package/esm/persistence-manager/LocalPersistenceManager.js.map +0 -1
  193. package/esm/persistence-manager/PersistenceProvider.js +0 -17
  194. package/esm/persistence-manager/PersistenceProvider.js.map +0 -1
  195. package/esm/persistence-manager/RemotePersistenceManager.js +0 -163
  196. package/esm/persistence-manager/RemotePersistenceManager.js.map +0 -1
  197. package/esm/persistence-manager/StaticPersistenceManager.js +0 -71
  198. package/esm/persistence-manager/StaticPersistenceManager.js.map +0 -1
  199. package/esm/shell-layout-templates/context-panel/ContextPanel.css.js +0 -4
  200. package/esm/shell-layout-templates/context-panel/ContextPanel.css.js.map +0 -1
  201. package/esm/shell-layout-templates/context-panel/ContextPanel.js +0 -98
  202. package/esm/shell-layout-templates/context-panel/ContextPanel.js.map +0 -1
  203. package/esm/shell-layout-templates/full-height-left-panel/useFullHeightLeftPanel.js +0 -49
  204. package/esm/shell-layout-templates/full-height-left-panel/useFullHeightLeftPanel.js.map +0 -1
  205. package/esm/shell-layout-templates/inlay-left-panel/useInlayLeftPanel.js +0 -81
  206. package/esm/shell-layout-templates/inlay-left-panel/useInlayLeftPanel.js.map +0 -1
  207. package/esm/shell-layout-templates/left-main-tabs/useLeftMainTabs.js +0 -44
  208. package/esm/shell-layout-templates/left-main-tabs/useLeftMainTabs.js.map +0 -1
  209. package/esm/shell-layout-templates/side-panel/SidePanel.css.js +0 -4
  210. package/esm/shell-layout-templates/side-panel/SidePanel.css.js.map +0 -1
  211. package/esm/shell-layout-templates/side-panel/SidePanel.js +0 -34
  212. package/esm/shell-layout-templates/side-panel/SidePanel.js.map +0 -1
  213. package/esm/shell-layout-templates/simple-content-pane/useSimpleContentPane.js +0 -46
  214. package/esm/shell-layout-templates/simple-content-pane/useSimpleContentPane.js.map +0 -1
  215. package/esm/shell-layout-templates/useShellLayout.js +0 -21
  216. package/esm/shell-layout-templates/useShellLayout.js.map +0 -1
  217. package/esm/shell.css.js +0 -4
  218. package/esm/shell.css.js.map +0 -1
  219. package/esm/shell.js +0 -135
  220. package/esm/shell.js.map +0 -1
  221. package/esm/theme-switch/ThemeSwitch.css.js +0 -4
  222. package/esm/theme-switch/ThemeSwitch.css.js.map +0 -1
  223. package/esm/theme-switch/ThemeSwitch.js +0 -54
  224. package/esm/theme-switch/ThemeSwitch.js.map +0 -1
  225. package/esm/user-settings/SettingsForm.css.js +0 -4
  226. package/esm/user-settings/SettingsForm.css.js.map +0 -1
  227. package/esm/user-settings/SettingsForm.js +0 -162
  228. package/esm/user-settings/SettingsForm.js.map +0 -1
  229. package/esm/user-settings/UserSettingsPanel.css.js +0 -4
  230. package/esm/user-settings/UserSettingsPanel.css.js.map +0 -1
  231. package/esm/user-settings/UserSettingsPanel.js +0 -40
  232. package/esm/user-settings/UserSettingsPanel.js.map +0 -1
  233. package/esm/workspace-management/LayoutList.css.js +0 -4
  234. package/esm/workspace-management/LayoutList.css.js.map +0 -1
  235. package/esm/workspace-management/LayoutList.js +0 -114
  236. package/esm/workspace-management/LayoutList.js.map +0 -1
  237. package/esm/workspace-management/LayoutTile.css.js +0 -4
  238. package/esm/workspace-management/LayoutTile.css.js.map +0 -1
  239. package/esm/workspace-management/LayoutTile.js +0 -39
  240. package/esm/workspace-management/LayoutTile.js.map +0 -1
  241. package/esm/workspace-management/SaveLayoutPanel.css.js +0 -4
  242. package/esm/workspace-management/SaveLayoutPanel.css.js.map +0 -1
  243. package/esm/workspace-management/SaveLayoutPanel.js +0 -126
  244. package/esm/workspace-management/SaveLayoutPanel.js.map +0 -1
  245. package/esm/workspace-management/WorkspaceProvider.js +0 -262
  246. package/esm/workspace-management/WorkspaceProvider.js.map +0 -1
  247. package/esm/workspace-management/defaultWorkspaceJSON.js +0 -95
  248. package/esm/workspace-management/defaultWorkspaceJSON.js.map +0 -1
  249. package/esm/workspace-management/screenshot-utils.js +0 -23
  250. package/esm/workspace-management/screenshot-utils.js.map +0 -1
  251. package/esm/workspace-management/useWorkspaceContextMenuItems.js +0 -70
  252. package/esm/workspace-management/useWorkspaceContextMenuItems.js.map +0 -1
@@ -0,0 +1,209 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { isLayoutJSON, resolveJSONPath } from "@vuu-ui/vuu-layout";
3
+ import { useNotifications } from "@vuu-ui/vuu-notifications";
4
+ import { VuuShellLocation, WorkspaceContext, logger } from "@vuu-ui/vuu-utils";
5
+ import { useCallback, useContext, useEffect, useRef, useState } from "react";
6
+ import { usePersistenceManager } from "../persistence-manager/index.mjs";
7
+ import { getWorkspaceWithLayoutJSON, loadingJSON } from "./defaultWorkspaceJSON.mjs";
8
+ const { info: info } = logger("useLayoutManager");
9
+ const ensureLayoutHasTitle = (layout, layoutMetadata)=>{
10
+ if (layout.props?.title !== void 0) return layout;
11
+ return {
12
+ ...layout,
13
+ props: {
14
+ ...layout.props,
15
+ title: layoutMetadata.name
16
+ }
17
+ };
18
+ };
19
+ const loadingApplicationJSON = {
20
+ workspaceJSON: loadingJSON
21
+ };
22
+ const WorkspaceProvider = ({ TabstripProps, children, layoutJSON, activeLayoutIndex, layoutPlaceholderJSON, showTabs, workspaceJSON: customWorkspaceJSON })=>{
23
+ const [layoutMetadata, setLayoutMetadata] = useState([]);
24
+ const [, forceRefresh] = useState({});
25
+ const { showNotification } = useNotifications();
26
+ const persistenceManager = usePersistenceManager();
27
+ const applicationJSONRef = useRef(loadingApplicationJSON);
28
+ const setApplicationJSON = useCallback((applicationJSON, rerender = true)=>{
29
+ applicationJSONRef.current = applicationJSON;
30
+ if (rerender) forceRefresh({});
31
+ }, []);
32
+ const setWorkspaceJSON = useCallback((workspaceJSON, rerender = true)=>{
33
+ setApplicationJSON({
34
+ ...applicationJSONRef.current,
35
+ workspaceJSON
36
+ }, rerender);
37
+ }, [
38
+ setApplicationJSON
39
+ ]);
40
+ const setApplicationSettings = useCallback((settings)=>{
41
+ setApplicationJSON({
42
+ ...applicationJSONRef.current,
43
+ settings: {
44
+ ...applicationJSONRef.current.settings,
45
+ ...settings
46
+ }
47
+ }, false);
48
+ }, [
49
+ setApplicationJSON
50
+ ]);
51
+ useEffect(()=>{
52
+ persistenceManager?.loadMetadata().then((metadata)=>{
53
+ setLayoutMetadata(metadata);
54
+ }).catch((error)=>{
55
+ showNotification({
56
+ content: "Could not load list of available layouts",
57
+ header: "Failed to Load Layouts",
58
+ status: "error",
59
+ type: "toast"
60
+ });
61
+ console.error("Error occurred while retrieving metadata", error);
62
+ });
63
+ persistenceManager?.loadApplicationJSON().then((applicationJSON)=>{
64
+ if (applicationJSON) {
65
+ info?.("applicationJSON loaded successfully");
66
+ setApplicationJSON(applicationJSON);
67
+ } else {
68
+ const workspaceJSON = getWorkspaceWithLayoutJSON(customWorkspaceJSON, layoutJSON, activeLayoutIndex, {
69
+ TabstripProps,
70
+ showTabs
71
+ });
72
+ info?.(`applicationJSON not found, getting defaultWorkspaceJSON,
73
+ ${JSON.stringify(workspaceJSON, null, 2)}
74
+ `);
75
+ setApplicationJSON({
76
+ workspaceJSON
77
+ });
78
+ }
79
+ }).catch((error)=>{
80
+ showNotification({
81
+ content: "Could not load your latest view",
82
+ header: "Failed to Load Layout",
83
+ status: "error",
84
+ type: "toast"
85
+ });
86
+ console.error("Error occurred while retrieving application layout", error);
87
+ });
88
+ }, [
89
+ TabstripProps,
90
+ activeLayoutIndex,
91
+ customWorkspaceJSON,
92
+ layoutJSON,
93
+ showNotification,
94
+ persistenceManager,
95
+ setApplicationJSON,
96
+ showTabs
97
+ ]);
98
+ const saveApplicationLayout = useCallback((layout)=>{
99
+ if (isLayoutJSON(layout)) {
100
+ setWorkspaceJSON(layout, false);
101
+ persistenceManager?.saveApplicationJSON(applicationJSONRef.current);
102
+ } else console.error("Tried to save invalid application layout", layout);
103
+ }, [
104
+ persistenceManager,
105
+ setWorkspaceJSON
106
+ ]);
107
+ const saveLayout = useCallback((metadata)=>{
108
+ let layoutToSave;
109
+ try {
110
+ const { workspaceJSON } = applicationJSONRef.current;
111
+ if (Array.isArray(workspaceJSON)) console.log("how do we identify the right thing to save");
112
+ else layoutToSave = resolveJSONPath(workspaceJSON, `#${VuuShellLocation.Workspace}.ACTIVE_CHILD`);
113
+ } catch (e) {}
114
+ if (layoutToSave && isLayoutJSON(layoutToSave)) persistenceManager?.createLayout(metadata, ensureLayoutHasTitle(layoutToSave, metadata)).then((metadata)=>{
115
+ showNotification({
116
+ content: `${metadata.name} saved successfully`,
117
+ header: "Layout Saved Successfully",
118
+ status: "success",
119
+ type: "toast"
120
+ });
121
+ setLayoutMetadata((prev)=>[
122
+ ...prev,
123
+ metadata
124
+ ]);
125
+ }).catch((error)=>{
126
+ showNotification({
127
+ content: `Failed to save layout ${metadata.name}`,
128
+ header: "Failed to Save Layout",
129
+ status: "error",
130
+ type: "toast"
131
+ });
132
+ console.error("Error occurred while saving layout", error);
133
+ });
134
+ else {
135
+ console.error("Tried to save invalid layout", layoutToSave);
136
+ showNotification({
137
+ content: "Cannot save invalid layout",
138
+ header: "Failed to Save Layout",
139
+ status: "error",
140
+ type: "toast"
141
+ });
142
+ }
143
+ }, [
144
+ showNotification,
145
+ persistenceManager
146
+ ]);
147
+ const saveApplicationSettings = useCallback((settings, key)=>{
148
+ const { settings: applicationSettings } = applicationJSONRef.current;
149
+ key ? setApplicationSettings({
150
+ ...applicationSettings,
151
+ [key]: settings
152
+ }) : setApplicationSettings(settings);
153
+ persistenceManager?.saveApplicationJSON(applicationJSONRef.current);
154
+ }, [
155
+ persistenceManager,
156
+ setApplicationSettings
157
+ ]);
158
+ const getApplicationSettings = useCallback((key)=>{
159
+ const { settings } = applicationJSONRef.current;
160
+ return key ? settings?.[key] : settings;
161
+ }, []);
162
+ const loadLayoutById = useCallback((id)=>{
163
+ persistenceManager?.loadLayout(id).then((layoutJson)=>{
164
+ const { workspaceJSON: currentLayout } = applicationJSONRef.current;
165
+ if (Array.isArray(currentLayout)) console.log("how do we deal witha amulti layoput");
166
+ else setWorkspaceJSON({
167
+ ...currentLayout,
168
+ children: (currentLayout.children || []).concat(layoutJson),
169
+ props: {
170
+ ...currentLayout.props,
171
+ active: currentLayout.children?.length ?? 0
172
+ }
173
+ });
174
+ }).catch((error)=>{
175
+ showNotification({
176
+ content: "Failed to load the requested layout",
177
+ header: "Failed to Load Layout",
178
+ status: "error",
179
+ type: "toast"
180
+ });
181
+ console.error("Error occurred while loading layout", error);
182
+ });
183
+ }, [
184
+ showNotification,
185
+ persistenceManager,
186
+ setWorkspaceJSON
187
+ ]);
188
+ return /*#__PURE__*/ jsx(WorkspaceContext.Provider, {
189
+ value: {
190
+ getApplicationSettings,
191
+ layoutMetadata,
192
+ layoutPlaceholderJSON,
193
+ saveLayout,
194
+ workspaceJSON: applicationJSONRef.current.workspaceJSON,
195
+ saveApplicationLayout,
196
+ saveApplicationSettings,
197
+ loadLayoutById
198
+ },
199
+ children: children
200
+ });
201
+ };
202
+ const useWorkspace = ()=>{
203
+ const { workspaceJSON = getWorkspaceWithLayoutJSON(), ...contextProps } = useContext(WorkspaceContext);
204
+ return {
205
+ ...contextProps,
206
+ workspaceJSON
207
+ };
208
+ };
209
+ export { WorkspaceProvider, useWorkspace };
@@ -0,0 +1,88 @@
1
+ import { VuuShellLocation } from "@vuu-ui/vuu-utils";
2
+ const warningLayout = {
3
+ type: "View",
4
+ props: {
5
+ style: {
6
+ height: "calc(100% - 6px)"
7
+ }
8
+ },
9
+ children: [
10
+ {
11
+ props: {
12
+ className: "vuuShell-warningPlaceholder"
13
+ },
14
+ type: "Placeholder"
15
+ }
16
+ ]
17
+ };
18
+ const loadingJSON = {
19
+ type: "Component",
20
+ id: "loading-main",
21
+ props: {}
22
+ };
23
+ const defaultWorkspaceJSON = {
24
+ type: "Stack",
25
+ id: VuuShellLocation.Workspace,
26
+ props: {
27
+ className: `${VuuShellLocation.Workspace}-tabs`,
28
+ TabstripProps: {
29
+ allowAddTab: true,
30
+ allowCloseTab: true,
31
+ allowRenameTab: true,
32
+ animateSelectionThumb: false,
33
+ "aria-label": "Workspace Tabs",
34
+ location: "workspace-tab",
35
+ variant: "primary"
36
+ },
37
+ preserve: true
38
+ }
39
+ };
40
+ const getStackWorkspaceJSON = (activeLayoutIndex)=>({
41
+ ...defaultWorkspaceJSON,
42
+ active: activeLayoutIndex ?? 0
43
+ });
44
+ const placeholderLayout = {
45
+ props: {
46
+ id: "tab1",
47
+ title: "Tab 1",
48
+ className: "vuuShell-Placeholder"
49
+ },
50
+ type: "Placeholder"
51
+ };
52
+ const getWorkspaceWithLayoutJSON = (customWorkspaceJSON, layoutJSON = placeholderLayout, activeLayoutIndex, stackProps)=>{
53
+ const stackWorkspace = getStackWorkspaceJSON(activeLayoutIndex);
54
+ if (Array.isArray(customWorkspaceJSON)) {
55
+ const workspace = customWorkspaceJSON.find((layout)=>layout.id === VuuShellLocation.Workspace);
56
+ if (workspace) return customWorkspaceJSON.map((ws)=>{
57
+ if (ws.id === VuuShellLocation.Workspace) return {
58
+ ...ws,
59
+ children: Array.isArray(layoutJSON) ? layoutJSON : [
60
+ layoutJSON
61
+ ]
62
+ };
63
+ return ws;
64
+ });
65
+ throw Error("Multiple workspaces have been provided but none has the workspace id");
66
+ }
67
+ if (customWorkspaceJSON) return {
68
+ ...customWorkspaceJSON,
69
+ children: Array.isArray(layoutJSON) ? layoutJSON : [
70
+ layoutJSON
71
+ ]
72
+ };
73
+ return {
74
+ ...stackWorkspace,
75
+ props: {
76
+ ...stackWorkspace.props,
77
+ ...stackProps,
78
+ TabstripProps: {
79
+ ...stackWorkspace.props?.TabstripProps,
80
+ ...stackProps?.TabstripProps
81
+ }
82
+ },
83
+ children: Array.isArray(layoutJSON) ? layoutJSON : [
84
+ layoutJSON
85
+ ]
86
+ };
87
+ };
88
+ export { defaultWorkspaceJSON, getStackWorkspaceJSON, getWorkspaceWithLayoutJSON, loadingJSON, warningLayout };
@@ -0,0 +1,5 @@
1
+ export * from "./SaveLayoutPanel.mjs";
2
+ export * from "./LayoutList.mjs";
3
+ export * from "./WorkspaceProvider.mjs";
4
+ export * from "./defaultWorkspaceJSON.mjs";
5
+ export * from "./useWorkspaceContextMenuItems.mjs";
@@ -0,0 +1,13 @@
1
+ import { toPng } from "html-to-image";
2
+ const takeScreenshot = (node)=>new Promise((resolve, reject)=>{
3
+ toPng(node, {
4
+ cacheBust: true
5
+ }).then((screenshot)=>{
6
+ if (!screenshot) reject(new Error("No Screenshot available"));
7
+ resolve(screenshot);
8
+ }).catch((error)=>{
9
+ console.error("the following error occurred while taking a screenshot of a DOMNode", error);
10
+ reject(new Error("Error taking screenshot"));
11
+ });
12
+ });
13
+ export { takeScreenshot };
@@ -0,0 +1,58 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useModal } from "@vuu-ui/vuu-ui-controls";
3
+ import { useCallback, useMemo } from "react";
4
+ import { SaveLayoutPanel } from "./SaveLayoutPanel.mjs";
5
+ import { useWorkspace } from "./WorkspaceProvider.mjs";
6
+ const useWorkspaceContextMenuItems = ()=>{
7
+ const { saveLayout } = useWorkspace();
8
+ const { showDialog, closeDialog } = useModal();
9
+ const handleCloseDialog = useCallback(()=>{
10
+ closeDialog();
11
+ }, [
12
+ closeDialog
13
+ ]);
14
+ const handleSave = useCallback((layoutMetadata)=>{
15
+ saveLayout(layoutMetadata);
16
+ closeDialog();
17
+ }, [
18
+ saveLayout,
19
+ closeDialog
20
+ ]);
21
+ const [buildMenuOptions, handleMenuAction] = useMemo(()=>[
22
+ (location, options)=>{
23
+ const locations = location.split(" ");
24
+ const menuDescriptors = [];
25
+ if (locations.includes("workspace-tab")) menuDescriptors.push({
26
+ label: "Save Layout",
27
+ id: "save-layout",
28
+ options
29
+ }, {
30
+ label: "Layout Settings",
31
+ id: "layout-settings",
32
+ options
33
+ });
34
+ return menuDescriptors;
35
+ },
36
+ (menuItemId, options)=>{
37
+ if ("save-layout" === menuItemId) {
38
+ showDialog(/*#__PURE__*/ jsx(SaveLayoutPanel, {
39
+ onCancel: handleCloseDialog,
40
+ onSave: handleSave,
41
+ componentId: options?.controlledComponentId,
42
+ defaultTitle: options?.controlledComponentTitle
43
+ }), "Save Layout", [], true);
44
+ return true;
45
+ }
46
+ return false;
47
+ }
48
+ ], [
49
+ handleCloseDialog,
50
+ handleSave,
51
+ showDialog
52
+ ]);
53
+ return {
54
+ buildMenuOptions,
55
+ handleMenuAction
56
+ };
57
+ };
58
+ export { useWorkspaceContextMenuItems };
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var vuuUtils = require('@vuu-ui/vuu-utils');
5
-
6
- const Provider = ({
7
- children,
8
- context,
9
- inheritedContext
10
- }) => {
11
- const mergedContext = {
12
- ...inheritedContext,
13
- ...context
14
- };
15
- return /* @__PURE__ */ jsxRuntime.jsx(vuuUtils.ShellContext.Provider, { value: mergedContext, children });
16
- };
17
- const ShellContextProvider = ({
18
- children,
19
- value
20
- }) => {
21
- return /* @__PURE__ */ jsxRuntime.jsx(vuuUtils.ShellContext.Consumer, { children: (context) => /* @__PURE__ */ jsxRuntime.jsx(Provider, { context: value, inheritedContext: context, children }) });
22
- };
23
-
24
- exports.ShellContextProvider = ShellContextProvider;
25
- //# sourceMappingURL=ShellContextProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ShellContextProvider.js","sources":["../../../packages/vuu-shell/src/ShellContextProvider.tsx"],"sourcesContent":["import { ShellContext, ShellContextProps } from \"@vuu-ui/vuu-utils\";\nimport { ReactElement, ReactNode } from \"react\";\n\nexport interface ShellProviderProps {\n children: ReactNode;\n value?: ShellContextProps;\n}\n\nconst Provider = ({\n children,\n context,\n inheritedContext,\n}: {\n children: ReactNode;\n context?: ShellContextProps;\n inheritedContext?: ShellContextProps;\n}) => {\n // TODO functions provided at multiple levels must be merged\n const mergedContext = {\n ...inheritedContext,\n ...context,\n };\n return (\n <ShellContext.Provider value={mergedContext}>\n {children}\n </ShellContext.Provider>\n );\n};\n\nexport const ShellContextProvider = ({\n children,\n value,\n}: ShellProviderProps): ReactElement => {\n return (\n <ShellContext.Consumer>\n {(context) => (\n <Provider context={value} inheritedContext={context}>\n {children}\n </Provider>\n )}\n </ShellContext.Consumer>\n );\n};\n"],"names":["ShellContext","jsx"],"mappings":";;;;;AAQA,MAAM,WAAW,CAAC;AAAA,EAChB,QAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAIM,KAAA;AAEJ,EAAA,MAAM,aAAgB,GAAA;AAAA,IACpB,GAAG,gBAAA;AAAA,IACH,GAAG;AAAA,GACL;AACA,EAAA,sCACGA,qBAAa,CAAA,QAAA,EAAb,EAAsB,KAAA,EAAO,eAC3B,QACH,EAAA,CAAA;AAEJ,CAAA;AAEO,MAAM,uBAAuB,CAAC;AAAA,EACnC,QAAA;AAAA,EACA;AACF,CAAwC,KAAA;AACtC,EAAA,uBACGC,cAAA,CAAAD,qBAAA,CAAa,QAAb,EAAA,EACE,QAAC,EAAA,CAAA,OAAA,qBACCC,cAAA,CAAA,QAAA,EAAA,EAAS,OAAS,EAAA,KAAA,EAAO,gBAAkB,EAAA,OAAA,EACzC,UACH,CAEJ,EAAA,CAAA;AAEJ;;;;"}
@@ -1,6 +0,0 @@
1
- 'use strict';
2
-
3
- var appHeaderCss = ".vuuAppHeader {\n --saltButton-borderRadius: 6px;\n --saltButton-text-color: var(--vuu-color-gray-50);\n --saltButton-padding: 12px;\n --vuuToolbarItem-height: 26px;\n --vuuOverflowContainer-gap: 8px;\n --vuuOverflowContainer-height: var(--vuuAppHeader-height, 42px);\n --vuu-icon-color: var(--vuu-color-gray-45);\n --vuu-icon-size: 16px;\n --vuuToolbar-borderWidth: 1px;\n --vuuToolbar-borderStyle: solid;\n --vuuToolbar-borderColor: var(--salt-separable-primary-borderColor);\n\n align-items: center;\n display: flex;\n justify-content: flex-end;\n}\n\n";
4
-
5
- module.exports = appHeaderCss;
6
- //# sourceMappingURL=AppHeader.css.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppHeader.css.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1,118 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var core = require('@salt-ds/core');
5
- var styles = require('@salt-ds/styles');
6
- var window = require('@salt-ds/window');
7
- var vuuLayout = require('@vuu-ui/vuu-layout');
8
- var vuuUiControls = require('@vuu-ui/vuu-ui-controls');
9
- var cx = require('clsx');
10
- var React = require('react');
11
- var PersistenceProvider = require('../persistence-manager/PersistenceProvider.js');
12
- require('../persistence-manager/LocalPersistenceManager.js');
13
- require('../persistence-manager/StaticPersistenceManager.js');
14
- var vuuNotifications = require('@vuu-ui/vuu-notifications');
15
- var ApplicationProvider = require('../application-provider/ApplicationProvider.js');
16
- var AppHeader$1 = require('./AppHeader.css.js');
17
-
18
- const classBase = "vuuAppHeader";
19
- const AppHeader = ({
20
- className: classNameProp,
21
- themeMode: _,
22
- ...htmlAttributes
23
- }) => {
24
- const targetWindow = window.useWindow();
25
- styles.useComponentCssInjection({
26
- testId: "vuu-app-header",
27
- css: AppHeader$1,
28
- window: targetWindow
29
- });
30
- const persistenceManager = PersistenceProvider.usePersistenceManager();
31
- const settingsButtonRef = React.useRef(null);
32
- const className = cx(classBase, classNameProp);
33
- const logout = ApplicationProvider.useLogout();
34
- const { showComponentInContextPanel } = vuuLayout.useLayoutOperation();
35
- const { showNotification } = vuuNotifications.useNotifications();
36
- const handleReset = React.useCallback(() => {
37
- persistenceManager?.clearUserSettings();
38
- showNotification({
39
- animationType: "slide-out",
40
- renderPostRefresh: true,
41
- type: vuuNotifications.NotificationType.Toast,
42
- header: "Success",
43
- content: "Settings cleared",
44
- status: "success"
45
- });
46
- location.reload();
47
- }, [persistenceManager, showNotification]);
48
- const handleShowSettings = React.useCallback(() => {
49
- showComponentInContextPanel(
50
- {
51
- type: "ApplicationSettings"
52
- },
53
- "Settings",
54
- () => settingsButtonRef.current?.focus()
55
- );
56
- }, [showComponentInContextPanel]);
57
- return /* @__PURE__ */ jsxRuntime.jsxs(
58
- vuuUiControls.Toolbar,
59
- {
60
- alignItems: "end",
61
- className,
62
- role: "banner",
63
- showSeparators: true,
64
- ...htmlAttributes,
65
- children: [
66
- /* @__PURE__ */ jsxRuntime.jsx(
67
- core.Button,
68
- {
69
- className: `${classBase}-menuItem`,
70
- appearance: "transparent",
71
- sentiment: "neutral",
72
- children: "Help"
73
- }
74
- ),
75
- /* @__PURE__ */ jsxRuntime.jsxs(
76
- core.Button,
77
- {
78
- appearance: "transparent",
79
- className: `${classBase}-menuItem`,
80
- onClick: handleReset,
81
- sentiment: "neutral",
82
- children: [
83
- "Reset ",
84
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-icon": "history" })
85
- ]
86
- }
87
- ),
88
- /* @__PURE__ */ jsxRuntime.jsxs(
89
- core.Button,
90
- {
91
- appearance: "transparent",
92
- className: `${classBase}-menuItem`,
93
- onClick: handleShowSettings,
94
- ref: settingsButtonRef,
95
- sentiment: "neutral",
96
- children: [
97
- "Settings ",
98
- /* @__PURE__ */ jsxRuntime.jsx("span", { "data-icon": "settings" })
99
- ]
100
- }
101
- ),
102
- /* @__PURE__ */ jsxRuntime.jsx(
103
- core.Button,
104
- {
105
- appearance: "transparent",
106
- className: `${classBase}-menuItem`,
107
- onClick: logout,
108
- sentiment: "neutral",
109
- children: "Log out"
110
- }
111
- )
112
- ]
113
- }
114
- );
115
- };
116
-
117
- exports.AppHeader = AppHeader;
118
- //# sourceMappingURL=AppHeader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AppHeader.js","sources":["../../../../packages/vuu-shell/src/app-header/AppHeader.tsx"],"sourcesContent":["import { Button } from \"@salt-ds/core\";\nimport { useComponentCssInjection } from \"@salt-ds/styles\";\nimport { useWindow } from \"@salt-ds/window\";\nimport { useLayoutOperation } from \"@vuu-ui/vuu-layout\";\nimport { Toolbar } from \"@vuu-ui/vuu-ui-controls\";\nimport type { ThemeMode } from \"@vuu-ui/vuu-utils\";\nimport cx from \"clsx\";\nimport { HTMLAttributes, useCallback, useRef } from \"react\";\nimport { usePersistenceManager } from \"../persistence-manager\";\nimport { NotificationType, useNotifications } from \"@vuu-ui/vuu-notifications\";\nimport { useLogout } from \"../application-provider\";\n\nimport appHeaderCss from \"./AppHeader.css\";\n\nconst classBase = \"vuuAppHeader\";\nexport interface AppHeaderProps extends HTMLAttributes<HTMLDivElement> {\n themeMode?: ThemeMode;\n}\n\nexport const AppHeader = ({\n className: classNameProp,\n themeMode: _,\n ...htmlAttributes\n}: AppHeaderProps) => {\n const targetWindow = useWindow();\n useComponentCssInjection({\n testId: \"vuu-app-header\",\n css: appHeaderCss,\n window: targetWindow,\n });\n\n const persistenceManager = usePersistenceManager();\n const settingsButtonRef = useRef<HTMLButtonElement>(null);\n\n const className = cx(classBase, classNameProp);\n const logout = useLogout();\n\n const { showComponentInContextPanel } = useLayoutOperation();\n const { showNotification } = useNotifications();\n\n const handleReset = useCallback(() => {\n persistenceManager?.clearUserSettings();\n showNotification({\n animationType: \"slide-out\",\n renderPostRefresh: true,\n type: NotificationType.Toast,\n header: \"Success\",\n content: \"Settings cleared\",\n status: \"success\",\n });\n location.reload();\n }, [persistenceManager, showNotification]);\n\n const handleShowSettings = useCallback(() => {\n showComponentInContextPanel(\n {\n type: \"ApplicationSettings\",\n },\n \"Settings\",\n () => settingsButtonRef.current?.focus(),\n );\n }, [showComponentInContextPanel]);\n\n return (\n <Toolbar\n alignItems=\"end\"\n className={className}\n role=\"banner\"\n showSeparators\n {...htmlAttributes}\n >\n <Button\n className={`${classBase}-menuItem`}\n appearance=\"transparent\"\n sentiment=\"neutral\"\n >\n Help\n </Button>\n <Button\n appearance=\"transparent\"\n className={`${classBase}-menuItem`}\n onClick={handleReset}\n sentiment=\"neutral\"\n >\n Reset <span data-icon=\"history\" />\n </Button>\n <Button\n appearance=\"transparent\"\n className={`${classBase}-menuItem`}\n onClick={handleShowSettings}\n ref={settingsButtonRef}\n sentiment=\"neutral\"\n >\n Settings <span data-icon=\"settings\" />\n </Button>\n <Button\n appearance=\"transparent\"\n className={`${classBase}-menuItem`}\n onClick={logout}\n sentiment=\"neutral\"\n >\n Log out\n </Button>\n </Toolbar>\n );\n};\n"],"names":["useWindow","useComponentCssInjection","appHeaderCss","usePersistenceManager","useRef","useLogout","useLayoutOperation","useNotifications","useCallback","NotificationType","jsxs","Toolbar","jsx","Button"],"mappings":"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"}
@@ -1,17 +0,0 @@
1
- 'use strict';
2
-
3
- var React = require('react');
4
-
5
- const Guest = {
6
- username: "unknown"
7
- };
8
- const ApplicationContext = React.createContext({
9
- onUserSettingChanged: (propertyName) => console.warn(
10
- `Cannot change setting '${propertyName}'.
11
- Did you forget to declare an ApplicationProvider ?`
12
- ),
13
- user: Guest
14
- });
15
-
16
- exports.ApplicationContext = ApplicationContext;
17
- //# sourceMappingURL=ApplicationContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ApplicationContext.js","sources":["../../../../packages/vuu-shell/src/application-provider/ApplicationContext.tsx"],"sourcesContent":["import type { Settings, VuuUser } from \"@vuu-ui/vuu-utils\";\nimport { VuuRowDataItemType } from \"@vuu-ui/vuu-protocol-types\";\nimport { createContext } from \"react\";\nimport { SettingsSchema } from \"../user-settings\";\n\nconst Guest: VuuUser = {\n username: \"unknown\",\n};\n\nexport interface ApplicationContextProps {\n onUserSettingChanged: (\n propertyName: string,\n value: VuuRowDataItemType,\n ) => void;\n logout?: () => void;\n userSettings?: Settings;\n userSettingsSchema?: SettingsSchema;\n user: VuuUser;\n}\n\nexport const ApplicationContext = createContext<ApplicationContextProps>({\n onUserSettingChanged: (propertyName: string) =>\n console.warn(\n `Cannot change setting '${propertyName}'.\\nDid you forget to declare an ApplicationProvider ?`,\n ),\n user: Guest,\n});\n"],"names":["createContext"],"mappings":";;;;AAKA,MAAM,KAAiB,GAAA;AAAA,EACrB,QAAU,EAAA;AACZ,CAAA;AAaO,MAAM,qBAAqBA,mBAAuC,CAAA;AAAA,EACvE,oBAAA,EAAsB,CAAC,YAAA,KACrB,OAAQ,CAAA,IAAA;AAAA,IACN,0BAA0B,YAAY,CAAA;AAAA,kDAAA;AAAA,GACxC;AAAA,EACF,IAAM,EAAA;AACR,CAAC;;;;"}
@@ -1,102 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var core = require('@salt-ds/core');
5
- var React = require('react');
6
- var ApplicationContext = require('./ApplicationContext.js');
7
- var PersistenceProvider = require('../persistence-manager/PersistenceProvider.js');
8
- require('../persistence-manager/LocalPersistenceManager.js');
9
- require('../persistence-manager/StaticPersistenceManager.js');
10
-
11
- const accentPurple = "purple";
12
- const getThemeMode = (mode = "light", userSettings) => {
13
- const themeMode = userSettings?.themeMode;
14
- if (themeMode === "light" || themeMode === "dark") {
15
- return themeMode;
16
- }
17
- return mode;
18
- };
19
- const ApplicationProvider = ({
20
- children,
21
- density: densityProp,
22
- logout,
23
- mode,
24
- theme,
25
- userSettingsSchema,
26
- user
27
- }) => {
28
- const { mode: inheritedMode, theme: inheritedTheme } = core.useTheme();
29
- const density = core.useDensity(densityProp);
30
- const persistenceManager = PersistenceProvider.usePersistenceManager();
31
- const context = React.useContext(ApplicationContext.ApplicationContext);
32
- const [userSettings, setSettings] = React.useState();
33
- React.useMemo(async () => {
34
- if (persistenceManager) {
35
- const userSettings2 = await persistenceManager.getUserSettings();
36
- setSettings(userSettings2);
37
- } else {
38
- setSettings({});
39
- }
40
- }, [persistenceManager]);
41
- const onUserSettingChanged = React.useCallback(
42
- (propertyName, value) => {
43
- setSettings((currentSettings) => {
44
- const newSettings = { ...currentSettings, [propertyName]: value };
45
- persistenceManager?.saveUserSettings(newSettings);
46
- return newSettings;
47
- });
48
- },
49
- [persistenceManager]
50
- );
51
- return userSettings ? /* @__PURE__ */ jsxRuntime.jsx(
52
- ApplicationContext.ApplicationContext.Provider,
53
- {
54
- value: {
55
- ...context,
56
- logout,
57
- onUserSettingChanged,
58
- userSettings,
59
- userSettingsSchema,
60
- user: user ?? context.user
61
- },
62
- children: /* @__PURE__ */ jsxRuntime.jsx(
63
- core.SaltProviderNext,
64
- {
65
- accent: accentPurple,
66
- corner: "rounded",
67
- theme: theme ?? inheritedTheme ?? "vuu-theme",
68
- density,
69
- mode: getThemeMode(mode ?? inheritedMode, userSettings),
70
- children
71
- }
72
- )
73
- }
74
- ) : null;
75
- };
76
- const useApplicationUser = () => {
77
- const { user } = React.useContext(ApplicationContext.ApplicationContext);
78
- return user;
79
- };
80
- const useApplicationSettings = () => {
81
- const { onUserSettingChanged, userSettings, userSettingsSchema } = React.useContext(ApplicationContext.ApplicationContext);
82
- return {
83
- onUserSettingChanged,
84
- userSettings,
85
- userSettingsSchema
86
- };
87
- };
88
- const useUserSetting = () => {
89
- const { userSettings } = React.useContext(ApplicationContext.ApplicationContext);
90
- return userSettings;
91
- };
92
- const useLogout = () => {
93
- const { logout } = React.useContext(ApplicationContext.ApplicationContext);
94
- return logout;
95
- };
96
-
97
- exports.ApplicationProvider = ApplicationProvider;
98
- exports.useApplicationSettings = useApplicationSettings;
99
- exports.useApplicationUser = useApplicationUser;
100
- exports.useLogout = useLogout;
101
- exports.useUserSetting = useUserSetting;
102
- //# sourceMappingURL=ApplicationProvider.js.map