@ramesesinc/platform-core 0.1.0

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 (285) hide show
  1. package/dist/components/action/AlertMessage.d.ts +8 -0
  2. package/dist/components/action/AlertMessage.js +19 -0
  3. package/dist/components/action/AlertMessage.tsx +38 -0
  4. package/dist/components/action/Button.d.ts +21 -0
  5. package/dist/components/action/Button.js +139 -0
  6. package/dist/components/action/Button.tsx +230 -0
  7. package/dist/components/action/CancelEdit.d.ts +9 -0
  8. package/dist/components/action/CancelEdit.js +21 -0
  9. package/dist/components/action/CancelEdit.tsx +40 -0
  10. package/dist/components/action/DeleteData.d.ts +13 -0
  11. package/dist/components/action/DeleteData.js +43 -0
  12. package/dist/components/action/DeleteData.tsx +73 -0
  13. package/dist/components/action/Edit.d.ts +9 -0
  14. package/dist/components/action/Edit.js +21 -0
  15. package/dist/components/action/Edit.tsx +40 -0
  16. package/dist/components/action/LookupPage.d.ts +16 -0
  17. package/dist/components/action/LookupPage.js +62 -0
  18. package/dist/components/action/LookupPage.tsx +113 -0
  19. package/dist/components/action/ProcessRunner.d.ts +62 -0
  20. package/dist/components/action/ProcessRunner.js +156 -0
  21. package/dist/components/action/ProcessRunner.tsx +337 -0
  22. package/dist/components/action/Refresh.d.ts +7 -0
  23. package/dist/components/action/Refresh.js +17 -0
  24. package/dist/components/action/Refresh.tsx +35 -0
  25. package/dist/components/action/SaveData.d.ts +10 -0
  26. package/dist/components/action/SaveData.js +54 -0
  27. package/dist/components/action/SaveData.tsx +74 -0
  28. package/dist/components/action/SelectData.d.ts +8 -0
  29. package/dist/components/action/SelectData.js +29 -0
  30. package/dist/components/action/SelectData.tsx +47 -0
  31. package/dist/components/action/Undo.d.ts +9 -0
  32. package/dist/components/action/Undo.js +31 -0
  33. package/dist/components/action/Undo.tsx +50 -0
  34. package/dist/components/action/UpdateContext.d.ts +9 -0
  35. package/dist/components/action/UpdateContext.js +21 -0
  36. package/dist/components/action/UpdateContext.tsx +40 -0
  37. package/dist/components/action/UpdateData.d.ts +9 -0
  38. package/dist/components/action/UpdateData.js +33 -0
  39. package/dist/components/action/UpdateData.tsx +49 -0
  40. package/dist/components/action/ViewBackPage.d.ts +9 -0
  41. package/dist/components/action/ViewBackPage.js +19 -0
  42. package/dist/components/action/ViewBackPage.tsx +46 -0
  43. package/dist/components/action/ViewPage.d.ts +14 -0
  44. package/dist/components/action/ViewPage.js +88 -0
  45. package/dist/components/action/ViewPage.tsx +141 -0
  46. package/dist/components/common/UIComponent.d.ts +11 -0
  47. package/dist/components/common/UIComponent.js +52 -0
  48. package/dist/components/common/UIComponent.tsx +84 -0
  49. package/dist/components/common/UIInput.d.ts +12 -0
  50. package/dist/components/common/UIInput.js +37 -0
  51. package/dist/components/common/UIInput.tsx +49 -0
  52. package/dist/components/common/UIMenu.d.ts +23 -0
  53. package/dist/components/common/UIMenu.js +61 -0
  54. package/dist/components/common/UIMenu.tsx +91 -0
  55. package/dist/components/index.d.ts +37 -0
  56. package/dist/components/index.js +44 -0
  57. package/dist/components/index.ts +51 -0
  58. package/dist/components/input/CodeEditor.d.ts +12 -0
  59. package/dist/components/input/CodeEditor.js +132 -0
  60. package/dist/components/input/CodeEditor.tsx +188 -0
  61. package/dist/components/input/DateField.d.ts +9 -0
  62. package/dist/components/input/DateField.js +140 -0
  63. package/dist/components/input/DateField.tsx +274 -0
  64. package/dist/components/input/DayPicker.d.ts +2 -0
  65. package/dist/components/input/DayPicker.js +5 -0
  66. package/dist/components/input/DayPicker.tsx +5 -0
  67. package/dist/components/input/HtmlCode.d.ts +8 -0
  68. package/dist/components/input/HtmlCode.js +157 -0
  69. package/dist/components/input/HtmlCode.tsx +203 -0
  70. package/dist/components/input/JsonCode.d.ts +9 -0
  71. package/dist/components/input/JsonCode.js +159 -0
  72. package/dist/components/input/JsonCode.tsx +205 -0
  73. package/dist/components/input/MonthPicker.d.ts +2 -0
  74. package/dist/components/input/MonthPicker.js +5 -0
  75. package/dist/components/input/MonthPicker.tsx +5 -0
  76. package/dist/components/input/ScriptCode.d.ts +8 -0
  77. package/dist/components/input/ScriptCode.js +153 -0
  78. package/dist/components/input/ScriptCode.tsx +195 -0
  79. package/dist/components/input/Select.d.ts +14 -0
  80. package/dist/components/input/Select.js +40 -0
  81. package/dist/components/input/Select.tsx +78 -0
  82. package/dist/components/input/SqlCode.d.ts +8 -0
  83. package/dist/components/input/SqlCode.js +121 -0
  84. package/dist/components/input/SqlCode.tsx +162 -0
  85. package/dist/components/input/StringDecision.d.ts +2 -0
  86. package/dist/components/input/StringDecision.js +34 -0
  87. package/dist/components/input/StringDecision.tsx +64 -0
  88. package/dist/components/input/Text.d.ts +7 -0
  89. package/dist/components/input/Text.js +39 -0
  90. package/dist/components/input/Text.tsx +57 -0
  91. package/dist/components/input/YearPicker.d.ts +8 -0
  92. package/dist/components/input/YearPicker.js +44 -0
  93. package/dist/components/input/YearPicker.tsx +81 -0
  94. package/dist/components/list/IconMenu.d.ts +14 -0
  95. package/dist/components/list/IconMenu.js +72 -0
  96. package/dist/components/list/IconMenu.tsx +115 -0
  97. package/dist/components/list/TabMenu.d.ts +10 -0
  98. package/dist/components/list/TabMenu.js +72 -0
  99. package/dist/components/list/TabMenu.tsx +127 -0
  100. package/dist/components/list/TreeMenu.d.ts +14 -0
  101. package/dist/components/list/TreeMenu.js +207 -0
  102. package/dist/components/list/TreeMenu.tsx +279 -0
  103. package/dist/components/list/TxnTaskList.d.ts +2 -0
  104. package/dist/components/list/TxnTaskList.js +77 -0
  105. package/dist/components/list/TxnTaskList.tsx +198 -0
  106. package/dist/components/output/Label.d.ts +8 -0
  107. package/dist/components/output/Label.js +33 -0
  108. package/dist/components/output/Label.tsx +51 -0
  109. package/dist/components/table/DataList.d.ts +88 -0
  110. package/dist/components/table/DataList.js +361 -0
  111. package/dist/components/table/DataList.tsx +782 -0
  112. package/dist/components/table/DataTable.d.ts +46 -0
  113. package/dist/components/table/DataTable.js +253 -0
  114. package/dist/components/table/DataTable.tsx +572 -0
  115. package/dist/components/table/ListHandler.d.ts +42 -0
  116. package/dist/components/table/ListHandler.js +197 -0
  117. package/dist/components/table/ListHandler.ts +276 -0
  118. package/dist/components/table/TableContext.d.ts +33 -0
  119. package/dist/components/table/TableContext.js +57 -0
  120. package/dist/components/table/TableContext.tsx +122 -0
  121. package/dist/components/view/ComponentView.d.ts +8 -0
  122. package/dist/components/view/ComponentView.js +78 -0
  123. package/dist/components/view/ComponentView.tsx +102 -0
  124. package/dist/components/view/FilterView.d.ts +2 -0
  125. package/dist/components/view/FilterView.js +14 -0
  126. package/dist/components/view/FilterView.tsx +21 -0
  127. package/dist/components/view/HtmlForm.d.ts +7 -0
  128. package/dist/components/view/HtmlForm.js +145 -0
  129. package/dist/components/view/HtmlForm.tsx +186 -0
  130. package/dist/components/view/HtmlView.d.ts +9 -0
  131. package/dist/components/view/HtmlView.js +85 -0
  132. package/dist/components/view/HtmlView.tsx +114 -0
  133. package/dist/components/view/IFrameView.d.ts +2 -0
  134. package/dist/components/view/IFrameView.js +34 -0
  135. package/dist/components/view/IFrameView.tsx +48 -0
  136. package/dist/components/view/Modal.d.ts +14 -0
  137. package/dist/components/view/Modal.js +28 -0
  138. package/dist/components/view/Modal.tsx +72 -0
  139. package/dist/components/view/PageView.d.ts +9 -0
  140. package/dist/components/view/PageView.js +90 -0
  141. package/dist/components/view/PageView.tsx +131 -0
  142. package/dist/components/view/PopupView.d.ts +9 -0
  143. package/dist/components/view/PopupView.js +91 -0
  144. package/dist/components/view/PopupView.tsx +160 -0
  145. package/dist/components/view/RootView.d.ts +8 -0
  146. package/dist/components/view/RootView.js +75 -0
  147. package/dist/components/view/RootView.tsx +109 -0
  148. package/dist/components/view/WizardView.d.ts +6 -0
  149. package/dist/components/view/WizardView.js +34 -0
  150. package/dist/components/view/WizardView.tsx +48 -0
  151. package/dist/core/AppContext.d.ts +25 -0
  152. package/dist/core/AppContext.js +159 -0
  153. package/dist/core/AuthContext.d.ts +13 -0
  154. package/dist/core/AuthContext.js +80 -0
  155. package/dist/core/ComponentCache.d.ts +15 -0
  156. package/dist/core/ComponentCache.js +25 -0
  157. package/dist/core/DataContext.d.ts +20 -0
  158. package/dist/core/DataContext.js +41 -0
  159. package/dist/core/DynamicComponent.d.ts +12 -0
  160. package/dist/core/DynamicComponent.js +30 -0
  161. package/dist/core/DynamicIcon.d.ts +6 -0
  162. package/dist/core/DynamicIcon.js +48 -0
  163. package/dist/core/DynamicTemplate.d.ts +4 -0
  164. package/dist/core/DynamicTemplate.js +17 -0
  165. package/dist/core/ErrorMessage.d.ts +5 -0
  166. package/dist/core/ErrorMessage.js +7 -0
  167. package/dist/core/EventHandler.d.ts +3 -0
  168. package/dist/core/EventHandler.js +1 -0
  169. package/dist/core/HtmlCache.d.ts +6 -0
  170. package/dist/core/HtmlCache.js +17 -0
  171. package/dist/core/Page.d.ts +6 -0
  172. package/dist/core/Page.js +141 -0
  173. package/dist/core/PageCache.d.ts +15 -0
  174. package/dist/core/PageCache.js +26 -0
  175. package/dist/core/PageContext.d.ts +49 -0
  176. package/dist/core/PageContext.js +207 -0
  177. package/dist/core/PageRegistry.d.ts +7 -0
  178. package/dist/core/PageRegistry.js +11 -0
  179. package/dist/core/PageViewContext.d.ts +45 -0
  180. package/dist/core/PageViewContext.js +277 -0
  181. package/dist/core/Panel.d.ts +16 -0
  182. package/dist/core/Panel.js +39 -0
  183. package/dist/core/RowContext.d.ts +11 -0
  184. package/dist/core/RowContext.js +16 -0
  185. package/dist/core/StepHandler.d.ts +9 -0
  186. package/dist/core/StepHandler.js +39 -0
  187. package/dist/core/UIDependHandler.d.ts +6 -0
  188. package/dist/core/UIDependHandler.js +31 -0
  189. package/dist/core/auth/index.d.ts +18 -0
  190. package/dist/core/auth/index.js +187 -0
  191. package/dist/core/auth/session.d.ts +4 -0
  192. package/dist/core/auth/session.js +45 -0
  193. package/dist/core/index.d.ts +3 -0
  194. package/dist/core/index.js +1 -0
  195. package/dist/core/page-helper.d.ts +27 -0
  196. package/dist/core/page-helper.js +47 -0
  197. package/dist/hooks/useUrlParams.d.ts +11 -0
  198. package/dist/hooks/useUrlParams.js +164 -0
  199. package/dist/index.d.ts +65 -0
  200. package/dist/index.js +69 -0
  201. package/dist/layouts/BorderLayout.d.ts +14 -0
  202. package/dist/layouts/BorderLayout.js +8 -0
  203. package/dist/layouts/CardLayout.d.ts +27 -0
  204. package/dist/layouts/CardLayout.js +36 -0
  205. package/dist/layouts/CenterLayout.d.ts +8 -0
  206. package/dist/layouts/CenterLayout.js +6 -0
  207. package/dist/layouts/GridLayout.d.ts +9 -0
  208. package/dist/layouts/GridLayout.js +5 -0
  209. package/dist/layouts/HPanel.d.ts +11 -0
  210. package/dist/layouts/HPanel.js +8 -0
  211. package/dist/layouts/HorizontalLayout.d.ts +11 -0
  212. package/dist/layouts/HorizontalLayout.js +6 -0
  213. package/dist/layouts/MainLayout.d.ts +6 -0
  214. package/dist/layouts/MainLayout.js +5 -0
  215. package/dist/layouts/PageLayout.d.ts +11 -0
  216. package/dist/layouts/PageLayout.js +6 -0
  217. package/dist/layouts/VPanel.d.ts +9 -0
  218. package/dist/layouts/VPanel.js +7 -0
  219. package/dist/layouts/XLayout.d.ts +10 -0
  220. package/dist/layouts/XLayout.js +10 -0
  221. package/dist/layouts/YLayout.d.ts +10 -0
  222. package/dist/layouts/YLayout.js +10 -0
  223. package/dist/lib/PlatformRoute.d.ts +5 -0
  224. package/dist/lib/PlatformRoute.js +288 -0
  225. package/dist/lib/WebPlatform.d.ts +13 -0
  226. package/dist/lib/WebPlatform.js +124 -0
  227. package/dist/lib/components/ActivityBar.d.ts +13 -0
  228. package/dist/lib/components/ActivityBar.js +39 -0
  229. package/dist/lib/components/CopyButton.d.ts +8 -0
  230. package/dist/lib/components/CopyButton.js +50 -0
  231. package/dist/lib/components/Header.d.ts +2 -0
  232. package/dist/lib/components/Header.js +74 -0
  233. package/dist/lib/components/QuickActionMenu.d.ts +18 -0
  234. package/dist/lib/components/QuickActionMenu.js +50 -0
  235. package/dist/lib/components/UserButton.d.ts +11 -0
  236. package/dist/lib/components/UserButton.js +66 -0
  237. package/dist/lib/layouts/BorderLayout.tsx +31 -0
  238. package/dist/lib/layouts/CardLayout.tsx +73 -0
  239. package/dist/lib/layouts/CenterLayout.tsx +20 -0
  240. package/dist/lib/layouts/GridLayout.tsx +20 -0
  241. package/dist/lib/layouts/HPanel.tsx +31 -0
  242. package/dist/lib/layouts/HorizontalLayout.tsx +29 -0
  243. package/dist/lib/layouts/MainLayout.tsx +16 -0
  244. package/dist/lib/layouts/PageLayout.tsx +29 -0
  245. package/dist/lib/layouts/VPanel.tsx +27 -0
  246. package/dist/lib/layouts/XLayout.tsx +29 -0
  247. package/dist/lib/layouts/YLayout.tsx +29 -0
  248. package/dist/lib/utils/BeanUtils.d.ts +3 -0
  249. package/dist/lib/utils/BeanUtils.js +75 -0
  250. package/dist/lib/utils/ComponentLoader.d.ts +13 -0
  251. package/dist/lib/utils/ComponentLoader.js +26 -0
  252. package/dist/lib/utils/ExprUtil.d.ts +7 -0
  253. package/dist/lib/utils/ExprUtil.js +44 -0
  254. package/dist/lib/utils/PageUtils.d.ts +6 -0
  255. package/dist/lib/utils/PageUtils.js +121 -0
  256. package/dist/lib/utils/ResourceLoader.d.ts +11 -0
  257. package/dist/lib/utils/ResourceLoader.js +37 -0
  258. package/dist/lib/utils/SectionProvider.d.ts +5 -0
  259. package/dist/lib/utils/SectionProvider.js +39 -0
  260. package/dist/lib/utils/initResourceLoader.d.ts +0 -0
  261. package/dist/lib/utils/initResourceLoader.js +95 -0
  262. package/dist/styles/index.css +38 -0
  263. package/dist/templates/BasicTemplate.d.ts +2 -0
  264. package/dist/templates/BasicTemplate.js +14 -0
  265. package/dist/templates/CrudFormTemplate.d.ts +2 -0
  266. package/dist/templates/CrudFormTemplate.js +38 -0
  267. package/dist/templates/DataListTemplate.d.ts +2 -0
  268. package/dist/templates/DataListTemplate.js +13 -0
  269. package/dist/templates/ExplorerTemplate.d.ts +10 -0
  270. package/dist/templates/ExplorerTemplate.js +17 -0
  271. package/dist/templates/TxnFormTemplate.d.ts +2 -0
  272. package/dist/templates/TxnFormTemplate.js +66 -0
  273. package/dist/templates/WizardTemplate.d.ts +9 -0
  274. package/dist/templates/WizardTemplate.js +37 -0
  275. package/dist/templates/index.d.ts +5 -0
  276. package/dist/templates/index.js +5 -0
  277. package/dist/types/action.d.ts +8 -0
  278. package/dist/types/action.js +1 -0
  279. package/dist/types/component.d.ts +18 -0
  280. package/dist/types/component.js +1 -0
  281. package/dist/types/list.d.ts +14 -0
  282. package/dist/types/list.js +1 -0
  283. package/dist/types/template.d.ts +6 -0
  284. package/dist/types/template.js +1 -0
  285. package/package.json +56 -0
@@ -0,0 +1,207 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useBinding } from "@ramesesinc/client";
4
+ import { localAPI } from "@ramesesinc/lib/local-api";
5
+ import { createContext, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
6
+ import { parseHashUrl } from "../lib/utils/PageUtils";
7
+ import { useApp } from "./AppContext";
8
+ import { DataBindingProvider } from "./DataContext";
9
+ import { usePageViewContext } from "./PageViewContext";
10
+ const contextStack = [];
11
+ /* ------------------ Context ------------------ */
12
+ const PageContext = createContext({
13
+ parentContext: null,
14
+ getData: () => ({}),
15
+ setData: () => { },
16
+ dependsTo: () => () => { },
17
+ notifyDepends: () => { },
18
+ set: () => { },
19
+ get: () => undefined,
20
+ binding: {},
21
+ uuid: "",
22
+ stack: [],
23
+ getDataApiHandler: () => null,
24
+ setDataApiHandler: () => { },
25
+ buildParams: () => ({}),
26
+ execService: async () => ({}),
27
+ getAllData: () => ({}),
28
+ getMgmt: async () => ({}),
29
+ postMgmt: async () => ({}),
30
+ setPageParams: () => { },
31
+ getPageParams: () => ({}),
32
+ getPath: () => "",
33
+ getUrlParams: () => ({}),
34
+ });
35
+ export const PageProvider = ({ handle, children }) => {
36
+ const [uuid] = useState(() => "PageProvider-" + Math.random().toString(36).slice(2));
37
+ // console.log("PageContext paths", uuid, paths);
38
+ const parentContext = useContext(PageContext);
39
+ const pageView = usePageViewContext();
40
+ const binding = useBinding();
41
+ // setup the selectedPath from the handle
42
+ useMemo(() => {
43
+ const path = handle === null || handle === void 0 ? void 0 : handle.getSelectedPath();
44
+ binding.set("selectedPage", path);
45
+ return path;
46
+ }, [handle]);
47
+ // for DEV purposes only
48
+ useMemo(() => {
49
+ const dependHandler = () => {
50
+ // console.log("selectedPage changed => ", binding.get("selectedPage"));
51
+ };
52
+ binding.dependsTo("selectedPage", dependHandler);
53
+ }, []);
54
+ const dataApiHandler = useRef(null);
55
+ const { tenant, module } = useApp();
56
+ const providerRef = {
57
+ set: (name, value) => {
58
+ set(name, value);
59
+ },
60
+ get: (name) => {
61
+ return get(name);
62
+ },
63
+ };
64
+ const getPath = () => {
65
+ const path = get("selectedPage");
66
+ return path !== null && path !== void 0 ? path : "";
67
+ };
68
+ const getUrlParams = () => {
69
+ const path = getPath();
70
+ const targets = [];
71
+ if (path != null && path.trim() !== "") {
72
+ targets.push(path);
73
+ }
74
+ const collectPath = (ctx, targets) => {
75
+ if (ctx == null)
76
+ return;
77
+ const currentCtx = ctx;
78
+ if (typeof currentCtx.getPath === "function") {
79
+ const path = currentCtx.getPath();
80
+ if (path != null && path.trim() !== "") {
81
+ targets.push(path);
82
+ }
83
+ }
84
+ collectPath(currentCtx.parentContext, targets);
85
+ };
86
+ collectPath(parentContext, targets);
87
+ const fullPath = targets.reverse().join("#");
88
+ const { params } = parseHashUrl(fullPath);
89
+ return params;
90
+ };
91
+ /* ------------------ Data ------------------ */
92
+ const getData = () => {
93
+ return binding.getData();
94
+ };
95
+ const setData = (value, mode) => {
96
+ binding.setData(value, mode !== null && mode !== void 0 ? mode : "read");
97
+ };
98
+ /* ------------------ Reactive deps ------------------ */
99
+ const dependsTo = (name, callback) => {
100
+ return binding.dependsTo(name, callback);
101
+ };
102
+ const notifyDepends = (name) => {
103
+ binding.notifyDepends(name);
104
+ const { refresh } = pageView.getEventHandler();
105
+ // console.log("pageview event handler", refresh, pageView.getEventHandler());
106
+ if (refresh && typeof refresh === "function") {
107
+ refresh();
108
+ }
109
+ };
110
+ /* ------------------ Internal props setter ------------------ */
111
+ const set = (name, value) => {
112
+ if (name === "data") {
113
+ binding.setData(value);
114
+ }
115
+ else {
116
+ binding.set(name, value);
117
+ }
118
+ };
119
+ const get = (name) => {
120
+ if (name === "data") {
121
+ return binding.getData();
122
+ }
123
+ const val = binding.get(name);
124
+ // console.log("page context get", name, val, binding.getData());
125
+ return val;
126
+ };
127
+ const buildParams = (inputParams, queryParams) => {
128
+ return inputParams;
129
+ };
130
+ const execService = async (path, params) => {
131
+ const result = await localAPI.exec(`/services/exec/${tenant}/${module}/${path}`, params);
132
+ if (result.error) {
133
+ // throw new Error(result.error.message); to be uncomment
134
+ console.log("execService error", result.error);
135
+ }
136
+ return result;
137
+ };
138
+ const getMgmt = async (collection, action) => {
139
+ const result = await localAPI.useMgmt(tenant, module).get(collection, action);
140
+ return result;
141
+ };
142
+ const postMgmt = async (collection, action, params) => {
143
+ const result = await localAPI.useMgmt(tenant, module).post(collection, action, params);
144
+ return result;
145
+ };
146
+ const setPageParams = (params) => {
147
+ binding.set("pageParams", params);
148
+ };
149
+ const getPageParams = () => {
150
+ return binding.get("pageParams");
151
+ };
152
+ /* ------------------ Context value ------------------ */
153
+ const values = {
154
+ parentContext,
155
+ getData,
156
+ setData,
157
+ set,
158
+ get,
159
+ dependsTo,
160
+ notifyDepends,
161
+ binding,
162
+ uuid,
163
+ stack: [],
164
+ getDataApiHandler: () => dataApiHandler.current,
165
+ setDataApiHandler: (handler) => {
166
+ dataApiHandler.current = handler;
167
+ },
168
+ buildParams,
169
+ execService,
170
+ getMgmt,
171
+ postMgmt,
172
+ getAllData: () => {
173
+ const allData = Object.assign(Object.assign({}, binding.getUiData()), { data: binding.getData(), pageParams: getPageParams() });
174
+ return allData;
175
+ },
176
+ setPageParams,
177
+ getPageParams,
178
+ getPath,
179
+ getUrlParams,
180
+ };
181
+ const stack = [...((parentContext === null || parentContext === void 0 ? void 0 : parentContext.stack) || []), Object.assign({}, values)];
182
+ // Push/pop to global stack for demonstration
183
+ useEffect(() => {
184
+ const idx = contextStack.length;
185
+ const parent = idx > 0 ? contextStack[idx - 1] : null;
186
+ values.parentContext = parent;
187
+ contextStack.push(values);
188
+ return () => {
189
+ const index = contextStack.findIndex((c) => c.uuid === values.uuid);
190
+ if (index >= 0)
191
+ contextStack.splice(index, 1);
192
+ };
193
+ }, []);
194
+ const contextValue = values;
195
+ const dataBindingValue = Object.assign(Object.assign({}, contextValue), { getBinding: () => binding });
196
+ useLayoutEffect(() => {
197
+ if (handle == null)
198
+ return;
199
+ handle.init(contextValue);
200
+ }, []);
201
+ return (_jsx(PageContext.Provider, { value: contextValue, children: _jsx(DataBindingProvider, { handler: dataBindingValue, children: children }) }));
202
+ };
203
+ /* ------------------ Hook ------------------ */
204
+ export const usePageContext = () => {
205
+ const ctx = useContext(PageContext);
206
+ return ctx;
207
+ };
@@ -0,0 +1,7 @@
1
+ export type PageRegistry = {
2
+ get: (name: string, config?: {
3
+ tenant?: string;
4
+ module?: string;
5
+ }) => Promise<Record<string, any>>;
6
+ };
7
+ export declare const usePageRegistry: () => PageRegistry;
@@ -0,0 +1,11 @@
1
+ import { localAPI } from "@ramesesinc/lib/local-api";
2
+ export const usePageRegistry = () => {
3
+ const reg = {
4
+ get: async (name, config) => {
5
+ var _a, _b;
6
+ const result = await localAPI.useMgmt((_a = config.tenant) !== null && _a !== void 0 ? _a : "", (_b = config.module) !== null && _b !== void 0 ? _b : "").get("pages", name);
7
+ return result;
8
+ },
9
+ };
10
+ return reg;
11
+ };
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import { EventHandler } from ".";
3
+ export type PageOptions = {
4
+ mode?: "window" | "popup";
5
+ [key: string]: any;
6
+ };
7
+ export type PageViewContextValue = {
8
+ uuid: string;
9
+ parentContext: PageViewContextValue | null;
10
+ stack: PageViewContextValue[];
11
+ paths: string[];
12
+ setPage: (page: string | null, options?: PageOptions) => void;
13
+ setSelectedPage: (page: string | null) => void;
14
+ getSelectedPage: () => string | null;
15
+ pushPage: (page: string) => void;
16
+ popPage: () => void;
17
+ hasBackPage: () => boolean;
18
+ isStandalone: () => boolean;
19
+ hasSelectionHandling: () => boolean;
20
+ setSelectionHandling: (hasHandling: boolean) => void;
21
+ getOriginalLocationInfo: () => PageChainInfo | null;
22
+ getEventHandler: () => EventHandler | null;
23
+ };
24
+ export type PageViewHandle = {
25
+ init: (ref: PageViewContextValue) => void;
26
+ renderPage: (page: string | null) => void;
27
+ isStandalone: () => boolean;
28
+ };
29
+ export type PageSelectionHandler = {};
30
+ type PageChainInfo = {
31
+ path: string;
32
+ base: string;
33
+ page: string;
34
+ options: PageOptions;
35
+ };
36
+ type PageViewProviderProps = {
37
+ paths: string[];
38
+ handle: PageViewHandle;
39
+ children: React.ReactNode;
40
+ prefix?: string;
41
+ eventHandler?: EventHandler | null;
42
+ };
43
+ export declare const PageViewProvider: React.FC<PageViewProviderProps>;
44
+ export declare const usePageViewContext: () => PageViewContextValue;
45
+ export {};
@@ -0,0 +1,277 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import { useApp } from "./AppContext";
5
+ /* ------------------ Global Stack ------------------ */
6
+ const contextStack = [];
7
+ /* ------------------ Context ------------------ */
8
+ const PageViewContext = createContext({
9
+ uuid: "",
10
+ parentContext: null,
11
+ stack: [],
12
+ paths: [],
13
+ setPage: () => { },
14
+ getSelectedPage: () => null,
15
+ pushPage: () => { },
16
+ popPage: () => { },
17
+ setSelectedPage: () => { },
18
+ hasBackPage: () => false,
19
+ isStandalone: () => false,
20
+ hasSelectionHandling: () => false,
21
+ setSelectionHandling: () => null,
22
+ getOriginalLocationInfo: () => null,
23
+ getEventHandler: () => null,
24
+ });
25
+ export const PageViewProvider = ({ paths, handle, children, prefix = "page", eventHandler = {}, }) => {
26
+ const parentContext = useContext(PageViewContext);
27
+ const [uuid] = useState(() => `${prefix}-${Math.random().toString(36).slice(2)}`);
28
+ const app = useApp();
29
+ const [hasSelectionHandling, setSelectionHandling] = useState(false);
30
+ const isStandalone = useCallback(() => {
31
+ return handle == null ? true : handle.isStandalone();
32
+ }, [handle]);
33
+ const getLocationInfo = useCallback(() => {
34
+ var _a, _b;
35
+ const result = {
36
+ root: "",
37
+ path: "",
38
+ base: "",
39
+ };
40
+ try {
41
+ if (window == null)
42
+ return result;
43
+ const pathname = window.location.pathname;
44
+ let paths = pathname.split("/");
45
+ result.root = paths.slice(0, -1).join("/");
46
+ paths.length = 0;
47
+ paths = [pathname];
48
+ const query = (_a = window.location.search) !== null && _a !== void 0 ? _a : "";
49
+ if (query.length > 0) {
50
+ if (!query.startsWith("?")) {
51
+ paths.push("?");
52
+ }
53
+ paths.push(query);
54
+ }
55
+ const finalBasePaths = [];
56
+ finalBasePaths.push(paths.join(""));
57
+ const hash = (_b = window.location.hash) !== null && _b !== void 0 ? _b : "";
58
+ if (hash.length > 0) {
59
+ if (!hash.startsWith("#")) {
60
+ paths.push("#");
61
+ }
62
+ paths.push(hash);
63
+ }
64
+ let [, ...anchors] = hash.split("#");
65
+ anchors = anchors.slice(0, -1);
66
+ if (anchors.length > 0) {
67
+ finalBasePaths.push("#" + anchors.join("#"));
68
+ }
69
+ result.base = finalBasePaths.join("");
70
+ result.path = paths.join("");
71
+ return result;
72
+ }
73
+ catch (err) {
74
+ console.log("Error getting path location info:", err);
75
+ return result;
76
+ }
77
+ }, []);
78
+ const originalLocInfo = useMemo(() => {
79
+ const [, selectedPath] = paths;
80
+ const standalone = isStandalone();
81
+ const chainInfo = { base: "", path: "", page: "" };
82
+ if (standalone) {
83
+ chainInfo.path = selectedPath !== null && selectedPath !== void 0 ? selectedPath : "";
84
+ chainInfo.page = chainInfo.path;
85
+ }
86
+ else {
87
+ const loc = getLocationInfo();
88
+ chainInfo.base = loc.base;
89
+ chainInfo.path = [loc.path, selectedPath].filter(Boolean).join("#");
90
+ }
91
+ // console.log("pageview original loc info ", chainInfo);
92
+ return chainInfo;
93
+ }, [paths, handle]);
94
+ const [pageChain, setPageChain] = useState(() => {
95
+ var _a;
96
+ const [, selectedPath] = paths;
97
+ const standalone = isStandalone();
98
+ const chainInfo = { path: "", base: "", page: "", options: {} };
99
+ const result = { current: chainInfo, previous: null };
100
+ if (standalone) {
101
+ chainInfo.path = selectedPath !== null && selectedPath !== void 0 ? selectedPath : "";
102
+ chainInfo.page = chainInfo.path;
103
+ }
104
+ else {
105
+ const loc = getLocationInfo();
106
+ chainInfo.path = [loc.path, selectedPath].filter(Boolean).join("#");
107
+ chainInfo.base = loc.base;
108
+ if (loc.base !== "") {
109
+ chainInfo.page = (_a = loc.base.split("/").at(-1)) !== null && _a !== void 0 ? _a : "";
110
+ }
111
+ }
112
+ return result;
113
+ });
114
+ const handleRef = useRef(handle);
115
+ useLayoutEffect(() => {
116
+ handleRef.current = handle;
117
+ }, [handle]);
118
+ useEffect(() => {
119
+ const standalone = isStandalone();
120
+ // console.log("pageChain changed", uuid, standalone, pageChain);
121
+ }, [pageChain]);
122
+ const setSelectedPage = (page) => {
123
+ const chainInfo = pageChain.current;
124
+ const newChainInfo = Object.assign(Object.assign({}, chainInfo), { page });
125
+ if (page == null || page === "") {
126
+ // do nothing
127
+ }
128
+ else {
129
+ newChainInfo.path = newChainInfo.base + "#" + page;
130
+ newChainInfo.page = page;
131
+ }
132
+ pageChain.current = newChainInfo;
133
+ };
134
+ const setPage = (page, options = {}) => {
135
+ var _a;
136
+ if (page == null || page.trim() === "") {
137
+ return;
138
+ }
139
+ const standalone = isStandalone();
140
+ const pageOptions = options !== null && options !== void 0 ? options : {};
141
+ const { mode = "default" } = pageOptions;
142
+ const locInfo = getLocationInfo();
143
+ const { current: currentChain, previous: previousChain } = pageChain;
144
+ const newChainInfo = { path: "", base: "", page: "", options: pageOptions };
145
+ const newPageChain = { current: newChainInfo, previous: null };
146
+ if (mode != null && mode === "window") {
147
+ newChainInfo.page = page;
148
+ newChainInfo.base = locInfo.root;
149
+ newChainInfo.path = locInfo.root + "/" + page;
150
+ newPageChain.previous = { current: currentChain, previous: previousChain };
151
+ }
152
+ else {
153
+ newChainInfo.page = page;
154
+ newChainInfo.base = originalLocInfo.base;
155
+ newChainInfo.path = [originalLocInfo.base, page].filter(Boolean).join("#");
156
+ }
157
+ setPageChain((prev) => (Object.assign({}, newPageChain)));
158
+ if (!standalone) {
159
+ history.pushState(null, "", newChainInfo.path);
160
+ }
161
+ (_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.renderPage(page);
162
+ };
163
+ const pushPage = (page) => {
164
+ var _a;
165
+ if (page == null)
166
+ return;
167
+ const standalone = isStandalone();
168
+ // console.log("pushPage (pageChain)", uuid, prefix, pageChain, standalone, parentContext);
169
+ const { current: chainInfo, previous: prevChain } = pageChain;
170
+ if (standalone && (chainInfo.path == null || chainInfo.path === "")) {
171
+ Object.assign(chainInfo, { path: paths[0], base: "", page: paths[0] });
172
+ }
173
+ const newChainInfo = {
174
+ path: [chainInfo.path, page].filter(Boolean).join("#"),
175
+ base: chainInfo.path,
176
+ page: page,
177
+ };
178
+ const newPageChain = {
179
+ current: newChainInfo,
180
+ previous: { current: chainInfo, previous: prevChain },
181
+ };
182
+ setPageChain(newPageChain);
183
+ if (!standalone) {
184
+ history.pushState(null, "", newChainInfo.path);
185
+ }
186
+ (_a = handleRef.current) === null || _a === void 0 ? void 0 : _a.renderPage(page);
187
+ };
188
+ const popPage = () => {
189
+ var _a, _b, _c;
190
+ // console.log("popPage (pageChain)", uuid, prefix, pageChain);
191
+ const { previous: prevChain } = pageChain;
192
+ if (prevChain == null) {
193
+ return;
194
+ }
195
+ const standalone = isStandalone();
196
+ const current = (_a = prevChain === null || prevChain === void 0 ? void 0 : prevChain.current) !== null && _a !== void 0 ? _a : {};
197
+ const { path, options = {} } = current;
198
+ if (path == null || path === "") {
199
+ return;
200
+ }
201
+ // extract page from path
202
+ let page = "";
203
+ if (prefix === "root") {
204
+ let newPath = path.split("#")[0].split("?")[0];
205
+ const idx = newPath.lastIndexOf("/");
206
+ if (idx >= 0) {
207
+ newPath = path.substring(idx + 1);
208
+ }
209
+ page = newPath;
210
+ // console.log("popPage 1.1", uuid, page);
211
+ }
212
+ else {
213
+ const [, ...anchors] = path.split("#");
214
+ page = (_b = anchors.at(-1)) !== null && _b !== void 0 ? _b : "";
215
+ if (page === "") {
216
+ page = path;
217
+ }
218
+ }
219
+ const newPageChain = Object.assign({}, prevChain);
220
+ setPageChain(newPageChain);
221
+ if (!standalone) {
222
+ history.pushState(null, "", path);
223
+ }
224
+ (_c = handleRef.current) === null || _c === void 0 ? void 0 : _c.renderPage(page);
225
+ };
226
+ const hasBackPage = () => {
227
+ const { previous } = pageChain;
228
+ if (previous == null)
229
+ return false;
230
+ const { path } = previous.current;
231
+ return path != null && path !== "";
232
+ };
233
+ const values = {
234
+ parentContext,
235
+ uuid,
236
+ stack: [...((parentContext === null || parentContext === void 0 ? void 0 : parentContext.stack) || [])],
237
+ paths,
238
+ setPage,
239
+ setSelectedPage,
240
+ getSelectedPage: () => {
241
+ const { current } = pageChain;
242
+ return current === null || current === void 0 ? void 0 : current.path;
243
+ },
244
+ pushPage,
245
+ popPage,
246
+ hasBackPage,
247
+ isStandalone,
248
+ hasSelectionHandling: () => hasSelectionHandling,
249
+ setSelectionHandling,
250
+ getOriginalLocationInfo: () => (Object.assign({}, originalLocInfo)),
251
+ getEventHandler: () => {
252
+ return eventHandler !== null && eventHandler !== void 0 ? eventHandler : {};
253
+ },
254
+ };
255
+ useEffect(() => {
256
+ const idx = contextStack.length;
257
+ const parent = idx > 0 ? contextStack[idx - 1] : null;
258
+ values.parentContext = parent;
259
+ contextStack.push(values);
260
+ return () => {
261
+ const index = contextStack.findIndex((c) => c.uuid === values.uuid);
262
+ if (index >= 0)
263
+ contextStack.splice(index, 1);
264
+ };
265
+ }, []);
266
+ const stack = [...((parentContext === null || parentContext === void 0 ? void 0 : parentContext.stack) || []), Object.assign({}, values)];
267
+ values.stack = stack;
268
+ useLayoutEffect(() => {
269
+ handle === null || handle === void 0 ? void 0 : handle.init(values);
270
+ }, []);
271
+ return _jsx(PageViewContext.Provider, { value: values, children: children });
272
+ };
273
+ /* ------------------ Hook ------------------ */
274
+ export const usePageViewContext = () => {
275
+ const ctx = useContext(PageViewContext);
276
+ return ctx;
277
+ };
@@ -0,0 +1,16 @@
1
+ interface PanelContent {
2
+ component?: string;
3
+ attr?: Record<string, any>;
4
+ elements?: PanelContent[];
5
+ styles?: Record<string, any>;
6
+ orientation?: "vertical" | "horizontal";
7
+ [key: string]: any;
8
+ }
9
+ interface PanelProps {
10
+ content: PanelContent | PanelContent[] | null;
11
+ orientation?: "vertical" | "horizontal";
12
+ styles?: Record<string, any>;
13
+ className?: string;
14
+ }
15
+ declare const Panel: ({ content, orientation, styles, className }: PanelProps) => import("react/jsx-runtime").JSX.Element | null;
16
+ export default Panel;
@@ -0,0 +1,39 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { DynamicComponent } from "./DynamicComponent";
14
+ const Panel = ({ content, orientation = "vertical", styles = {}, className = "" }) => {
15
+ if (content == undefined || content == null) {
16
+ return null;
17
+ }
18
+ return (_jsx("div", { className: className, style: styles, children: renderContent(content, orientation) }));
19
+ };
20
+ const renderContent = (content, orientation = "vertical") => {
21
+ //console.log(content)
22
+ // 1. Array → flex container, each item rendered recursively with flipped orientation for nested arrays
23
+ if (Array.isArray(content)) {
24
+ const isHorizontal = orientation === "horizontal";
25
+ return (_jsx("div", { style: { display: "flex", flexDirection: isHorizontal ? "row" : "column", gap: 12, flexWrap: "wrap" }, children: content.map((item, i) => Array.isArray(item) ? (_jsx("div", { children: renderContent(item, isHorizontal ? "vertical" : "horizontal") }, i)) : (_jsx("div", { children: renderContent(item, orientation) }, i))) }));
26
+ }
27
+ // 2. Object with `component` → DynamicComponent
28
+ if (content && typeof content === "object" && content.component) {
29
+ const { component, attr } = content;
30
+ return _jsx(DynamicComponent, { config: { component, attr } });
31
+ }
32
+ // 3. Object without `component` → Panel with nested elements
33
+ if (content && typeof content === "object") {
34
+ const { elements, styles, className, orientation: innerOrientation } = content, rest = __rest(content, ["elements", "styles", "className", "orientation"]);
35
+ return (_jsx(Panel, { content: elements || null, orientation: innerOrientation || orientation, styles: Object.assign(Object.assign({}, styles), rest), className: className || "" }));
36
+ }
37
+ return null;
38
+ };
39
+ export default Panel;
@@ -0,0 +1,11 @@
1
+ interface RowContextType {
2
+ getData: () => Record<string, any>;
3
+ }
4
+ interface RowProviderProps {
5
+ data: Record<string, any>;
6
+ children: React.ReactNode;
7
+ }
8
+ declare const RowContext: import("react").Context<RowContextType | null>;
9
+ export declare const useRowContext: () => RowContextType | null;
10
+ export declare const RowProvider: ({ data, children }: RowProviderProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default RowContext;
@@ -0,0 +1,16 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ import { DataBindingProvider, useCreateContextValue } from "./DataContext";
4
+ const RowContext = createContext(null);
5
+ export const useRowContext = () => {
6
+ const context = useContext(RowContext);
7
+ return context;
8
+ };
9
+ export const RowProvider = ({ data, children }) => {
10
+ const dataWrapper = useCreateContextValue(data !== null && data !== void 0 ? data : {});
11
+ const values = {
12
+ getData: () => dataWrapper.getData(),
13
+ };
14
+ return (_jsx(RowContext.Provider, { value: values, children: _jsx(DataBindingProvider, { handler: dataWrapper, children: children }) }));
15
+ };
16
+ export default RowContext;
@@ -0,0 +1,9 @@
1
+ export type StepActionHandler = {
2
+ getCurrentIndex: () => number;
3
+ getLastIndex: () => number;
4
+ hasPrev: () => boolean;
5
+ hasNext: () => boolean;
6
+ next: () => void;
7
+ back: () => void;
8
+ };
9
+ export declare const StepHandler: (items: Record<string, any>[], callback: (item: Record<string, any>) => void) => StepActionHandler;
@@ -0,0 +1,39 @@
1
+ export const StepHandler = (items, callback) => {
2
+ let currentIndex = 0;
3
+ let lastIndex = 0; // max index visited
4
+ const hasPrev = () => {
5
+ if (items.length == 0)
6
+ return false;
7
+ if (currentIndex - 1 < 0)
8
+ return false;
9
+ return true;
10
+ };
11
+ const hasNext = () => {
12
+ if (items.length == 0)
13
+ return false;
14
+ if (currentIndex + 1 >= items.length)
15
+ return false;
16
+ return true;
17
+ };
18
+ const next = () => {
19
+ currentIndex++;
20
+ if (currentIndex > lastIndex) {
21
+ lastIndex = currentIndex;
22
+ }
23
+ const selected = items[currentIndex];
24
+ callback(selected);
25
+ };
26
+ const back = () => {
27
+ currentIndex--;
28
+ const selected = items[currentIndex];
29
+ callback(selected);
30
+ };
31
+ return {
32
+ getCurrentIndex: () => currentIndex,
33
+ getLastIndex: () => lastIndex,
34
+ hasPrev,
35
+ hasNext,
36
+ next,
37
+ back,
38
+ };
39
+ };