@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,78 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { useApp } from "../../core/AppContext";
4
+ import { DynamicComponent } from "../../core/DynamicComponent";
5
+ import { usePageContext } from "../../core/PageContext";
6
+ import useDependHandler from "../../core/UIDependHandler";
7
+ import UIComponent from "../common/UIComponent";
8
+ const ComponentView = (props) => {
9
+ const { id, name, depends, component } = props !== null && props !== void 0 ? props : {};
10
+ const [comp, setComp] = useState(null);
11
+ const [error, setError] = useState("");
12
+ const [forceUpdate, setForceUpdate] = useState({});
13
+ const { getComponentCache } = useApp();
14
+ const pageContext = usePageContext();
15
+ const getPreferredName = () => {
16
+ if (name == null || name.trim() === "") {
17
+ return depends;
18
+ }
19
+ return name;
20
+ };
21
+ const loadComponentById = async () => {
22
+ if (id != null && id.trim() !== "") {
23
+ const cache = await getComponentCache(id);
24
+ const template = cache.template;
25
+ setComp(template);
26
+ return template;
27
+ }
28
+ return null;
29
+ };
30
+ const loadComponentByName = () => {
31
+ const preferredName = getPreferredName();
32
+ if (preferredName != null && preferredName.trim() !== "") {
33
+ const info = pageContext === null || pageContext === void 0 ? void 0 : pageContext.get(preferredName);
34
+ const { component, attr = {} } = info !== null && info !== void 0 ? info : {};
35
+ if (component == null || component.trim() === "") {
36
+ return null;
37
+ }
38
+ return _jsx(DynamicComponent, { config: { component, attr } });
39
+ }
40
+ return null;
41
+ };
42
+ const loadStaticComponent = () => {
43
+ if (typeof component === "string") {
44
+ return _jsx(DynamicComponent, { config: { component } });
45
+ }
46
+ return component;
47
+ };
48
+ const onRefresh = () => {
49
+ setForceUpdate({});
50
+ };
51
+ useDependHandler({ name: depends, onRefresh });
52
+ useEffect(() => {
53
+ var _a;
54
+ const prefName = (_a = name !== null && name !== void 0 ? name : depends) !== null && _a !== void 0 ? _a : "";
55
+ const tmpl = loadStaticComponent();
56
+ if (tmpl != null) {
57
+ setComp(tmpl);
58
+ return;
59
+ }
60
+ loadComponentById()
61
+ .then((template) => {
62
+ if (template != null) {
63
+ setComp(template);
64
+ return;
65
+ }
66
+ const tmpl2 = loadComponentByName();
67
+ if (tmpl2 != null) {
68
+ setComp(tmpl2);
69
+ }
70
+ })
71
+ .catch((err) => {
72
+ console.log("error", err);
73
+ setError(err.message);
74
+ });
75
+ }, [forceUpdate]);
76
+ return _jsx(UIComponent, Object.assign({}, props, { children: error ? _jsx("div", { children: error }) : _jsx("div", { children: comp }) }));
77
+ };
78
+ export default ComponentView;
@@ -0,0 +1,102 @@
1
+ import { useEffect, useState } from "react";
2
+ import { useApp } from "../../core/AppContext";
3
+ import { DynamicComponent } from "../../core/DynamicComponent";
4
+ import { usePageContext } from "../../core/PageContext";
5
+ import useDependHandler from "../../core/UIDependHandler";
6
+ import UIComponent, { UIComponentProps } from "../common/UIComponent";
7
+
8
+ interface ComponentViewProps extends UIComponentProps {
9
+ // use for dynamic component rendering
10
+ id?: string;
11
+
12
+ // use to get value from page context
13
+ depends?: string;
14
+
15
+ // use to statically set the actual component
16
+ component?: React.ReactNode;
17
+ }
18
+
19
+ const ComponentView = (props: ComponentViewProps) => {
20
+ const { id, name, depends, component } = props ?? {};
21
+ const [comp, setComp] = useState<React.ReactNode | null>(null);
22
+ const [error, setError] = useState("");
23
+ const [forceUpdate, setForceUpdate] = useState({});
24
+ const { getComponentCache } = useApp();
25
+ const pageContext = usePageContext();
26
+
27
+ const getPreferredName = () => {
28
+ if (name == null || name.trim() === "") {
29
+ return depends;
30
+ }
31
+ return name;
32
+ };
33
+
34
+ const loadComponentById = async () => {
35
+ if (id != null && id.trim() !== "") {
36
+ const cache = await getComponentCache(id);
37
+ const template: React.ReactNode = cache.template;
38
+ setComp(template);
39
+ return template;
40
+ }
41
+ return null;
42
+ };
43
+
44
+ const loadComponentByName = () => {
45
+ const preferredName = getPreferredName();
46
+ if (preferredName != null && preferredName.trim() !== "") {
47
+ const info = pageContext?.get(preferredName) as { component: string; attr?: Record<string, any> };
48
+ const { component, attr = {} } = info ?? {};
49
+
50
+ if (component == null || component.trim() === "") {
51
+ return null;
52
+ }
53
+
54
+ return <DynamicComponent config={{ component, attr }} />;
55
+ }
56
+ return null;
57
+ };
58
+
59
+ const loadStaticComponent = () => {
60
+ if (typeof component === "string") {
61
+ return <DynamicComponent config={{ component }} />;
62
+ }
63
+ return component;
64
+ };
65
+
66
+ const onRefresh = () => {
67
+ setForceUpdate({});
68
+ };
69
+
70
+ useDependHandler({ name: depends, onRefresh });
71
+
72
+ useEffect(() => {
73
+ const prefName = name ?? depends ?? "";
74
+
75
+ const tmpl = loadStaticComponent();
76
+ if (tmpl != null) {
77
+ setComp(tmpl);
78
+ return;
79
+ }
80
+
81
+ loadComponentById()
82
+ .then((template) => {
83
+ if (template != null) {
84
+ setComp(template);
85
+ return;
86
+ }
87
+
88
+ const tmpl2 = loadComponentByName();
89
+ if (tmpl2 != null) {
90
+ setComp(tmpl2);
91
+ }
92
+ })
93
+ .catch((err) => {
94
+ console.log("error", err);
95
+ setError(err.message);
96
+ });
97
+ }, [forceUpdate]);
98
+
99
+ return <UIComponent {...props}>{error ? <div>{error}</div> : <div>{comp}</div>}</UIComponent>;
100
+ };
101
+
102
+ export default ComponentView;
@@ -0,0 +1,2 @@
1
+ declare const FilterView: (props: Record<string, any>) => import("react/jsx-runtime").JSX.Element | null;
2
+ export default FilterView;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import VPanel from "../../layouts/VPanel";
3
+ import { renderListDef } from "../../lib/utils/SectionProvider";
4
+ const FilterView = (props) => {
5
+ const { items = [] } = props !== null && props !== void 0 ? props : {};
6
+ if (items.length === 0)
7
+ return null;
8
+ const buildPanel = () => {
9
+ const comps = renderListDef(items);
10
+ return _jsx(VPanel, { gap: 8, children: comps });
11
+ };
12
+ return (_jsx(_Fragment, { children: _jsx("div", { children: buildPanel() }) }));
13
+ };
14
+ export default FilterView;
@@ -0,0 +1,21 @@
1
+ import VPanel from "../../layouts/VPanel";
2
+ import { renderListDef } from "../../lib/utils/SectionProvider";
3
+
4
+ const FilterView = (props: Record<string, any>) => {
5
+ const { items = [] } = props ?? {};
6
+
7
+ if (items.length === 0) return null;
8
+
9
+ const buildPanel = () => {
10
+ const comps = renderListDef(items);
11
+ return <VPanel gap={8}>{comps}</VPanel>;
12
+ };
13
+
14
+ return (
15
+ <>
16
+ <div>{buildPanel()}</div>
17
+ </>
18
+ );
19
+ };
20
+
21
+ export default FilterView;
@@ -0,0 +1,7 @@
1
+ type HtmlFormProps = {
2
+ label?: string;
3
+ depends?: string;
4
+ templateid?: string;
5
+ };
6
+ declare const HtmlForm: (props: HtmlFormProps) => import("react/jsx-runtime").JSX.Element;
7
+ export default HtmlForm;
@@ -0,0 +1,145 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DynamicComponent } from "../../core/DynamicComponent";
3
+ import { useApp } from "../../core/AppContext";
4
+ import useDependHandler from "../../core/UIDependHandler";
5
+ import { localAPI } from "@ramesesinc/lib/local-api";
6
+ import { useEffect, useMemo, useState } from "react";
7
+ import UIComponent from "../common/UIComponent";
8
+ import React from "react";
9
+ // ─────────────────────────────────────────────────────────────────────────────
10
+ // Attr Parser
11
+ // Handles both strict JSON {"key":"value"} and JS object literals {key: "value"}
12
+ // ─────────────────────────────────────────────────────────────────────────────
13
+ function parseAttr(attrStr) {
14
+ if (!attrStr)
15
+ return {};
16
+ try {
17
+ return JSON.parse(attrStr);
18
+ }
19
+ catch (_a) {
20
+ try {
21
+ // eslint-disable-next-line no-new-func
22
+ return new Function(`"use strict"; return (${attrStr})`)();
23
+ }
24
+ catch (_b) {
25
+ console.warn("HtmlForm: could not parse attr →", attrStr);
26
+ return {};
27
+ }
28
+ }
29
+ }
30
+ // ─────────────────────────────────────────────────────────────────────────────
31
+ // DOM Attribute → React Prop mapper
32
+ // ─────────────────────────────────────────────────────────────────────────────
33
+ const ATTR_MAP = {
34
+ class: "className",
35
+ colspan: "colSpan",
36
+ rowspan: "rowSpan",
37
+ for: "htmlFor",
38
+ tabindex: "tabIndex",
39
+ readonly: "readOnly",
40
+ maxlength: "maxLength",
41
+ cellpadding: "cellPadding",
42
+ cellspacing: "cellSpacing",
43
+ };
44
+ function styleStringToObject(styleStr) {
45
+ const style = {};
46
+ styleStr.split(";").forEach((rule) => {
47
+ const [prop, val] = rule.split(":").map((s) => s.trim());
48
+ if (prop && val) {
49
+ const camel = prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
50
+ style[camel] = val;
51
+ }
52
+ });
53
+ return style;
54
+ }
55
+ function domAttrsToProps(el) {
56
+ var _a;
57
+ const props = {};
58
+ for (const attr of Array.from(el.attributes)) {
59
+ if (["component", "attr"].includes(attr.name))
60
+ continue;
61
+ const reactName = (_a = ATTR_MAP[attr.name]) !== null && _a !== void 0 ? _a : attr.name;
62
+ props[reactName] = attr.name === "style"
63
+ ? styleStringToObject(attr.value)
64
+ : attr.value;
65
+ }
66
+ return props;
67
+ }
68
+ // ─────────────────────────────────────────────────────────────────────────────
69
+ // Table structural elements that cannot contain whitespace text nodes
70
+ // ─────────────────────────────────────────────────────────────────────────────
71
+ const TABLE_ELEMENTS = new Set(["table", "thead", "tbody", "tfoot", "tr", "colgroup"]);
72
+ // ─────────────────────────────────────────────────────────────────────────────
73
+ // DOM Walker
74
+ // Turns a DOM tree into a React element tree.
75
+ // Sentinel <span component="X" attr="..."> becomes <DynamicComponent config={...} />
76
+ // Everything else becomes a plain React element.
77
+ // ─────────────────────────────────────────────────────────────────────────────
78
+ let _keyIndex = 0;
79
+ const nextKey = () => `hf_${_keyIndex++}`;
80
+ function walkNode(node, parentTag) {
81
+ var _a;
82
+ if (node.nodeType === Node.TEXT_NODE) {
83
+ // Whitespace-only text nodes are invalid inside table structural elements
84
+ // and cause React's validateDOMNesting warning.
85
+ if (parentTag && TABLE_ELEMENTS.has(parentTag) && !((_a = node.textContent) === null || _a === void 0 ? void 0 : _a.trim())) {
86
+ return null;
87
+ }
88
+ return node.textContent || null;
89
+ }
90
+ if (node.nodeType === Node.ELEMENT_NODE) {
91
+ const el = node;
92
+ const tag = el.tagName.toLowerCase();
93
+ const componentName = el.getAttribute("component");
94
+ // ── Sentinel span → DynamicComponent ──────────────────────────────────
95
+ if (tag === "span" && componentName) {
96
+ const attr = parseAttr(el.getAttribute("attr"));
97
+ const config = { component: componentName, attr };
98
+ return (_jsx(DynamicComponent, { config: config }, nextKey()));
99
+ }
100
+ // ── Regular element → recurse ──────────────────────────────────────────
101
+ const props = Object.assign(Object.assign({}, domAttrsToProps(el)), { key: nextKey() });
102
+ const children = Array.from(el.childNodes)
103
+ .map((child) => walkNode(child, tag)) // pass current tag as parentTag
104
+ .filter((n) => n !== null && n !== undefined);
105
+ return children.length > 0
106
+ ? React.createElement(tag, props, ...children)
107
+ : React.createElement(tag, props);
108
+ }
109
+ return null;
110
+ }
111
+ // ─────────────────────────────────────────────────────────────────────────────
112
+ // HtmlForm
113
+ // ─────────────────────────────────────────────────────────────────────────────
114
+ const HtmlForm = (props) => {
115
+ const { depends, templateid } = props !== null && props !== void 0 ? props : {};
116
+ const [htmlTemplate, setHtmlTemplate] = useState("");
117
+ const { tenant, module } = useApp();
118
+ // ── Load raw HTML from html_forms ──────────────────────────────────────────
119
+ const loadHtmlContent = async (tempid) => {
120
+ var _a;
121
+ try {
122
+ const record = await localAPI.useMgmt(tenant, module).get("html_templates", tempid);
123
+ setHtmlTemplate((_a = record === null || record === void 0 ? void 0 : record.htmlCode) !== null && _a !== void 0 ? _a : "");
124
+ }
125
+ catch (error) {
126
+ console.error("HtmlForm: error loading html_forms →", error);
127
+ setHtmlTemplate("");
128
+ }
129
+ };
130
+ useDependHandler({ name: depends, onRefresh: () => { } });
131
+ useEffect(() => {
132
+ if (templateid === null || templateid === void 0 ? void 0 : templateid.trim())
133
+ loadHtmlContent(templateid);
134
+ }, [templateid]);
135
+ // ── Walk DOM → React tree (only re-runs when htmlTemplate changes) ─────────
136
+ const reactTree = useMemo(() => {
137
+ if (!htmlTemplate)
138
+ return null;
139
+ _keyIndex = 0;
140
+ const doc = new DOMParser().parseFromString(htmlTemplate, "text/html");
141
+ return Array.from(doc.body.childNodes).map((child) => walkNode(child));
142
+ }, [htmlTemplate]);
143
+ return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsx("div", { className: "h-[calc(100vh-80px)] overflow-y-auto overflow-x-auto", children: reactTree }) })));
144
+ };
145
+ export default HtmlForm;
@@ -0,0 +1,186 @@
1
+ import { DynamicComponent } from "../../core/DynamicComponent";
2
+ import { useApp } from "../../core/AppContext";
3
+ import useDependHandler from "../../core/UIDependHandler";
4
+ import { localAPI } from "@ramesesinc/lib/local-api";
5
+ import { useEffect, useMemo, useState } from "react";
6
+ import UIComponent from "../common/UIComponent";
7
+ import React from "react";
8
+
9
+ // ─────────────────────────────────────────────────────────────────────────────
10
+ // Types
11
+ // ─────────────────────────────────────────────────────────────────────────────
12
+
13
+ type HtmlFormProps = {
14
+ label?: string;
15
+ depends?: string;
16
+ templateid?: string;
17
+ };
18
+
19
+ type SentinelConfig = {
20
+ component: string;
21
+ attr: any;
22
+ };
23
+
24
+ // ─────────────────────────────────────────────────────────────────────────────
25
+ // Attr Parser
26
+ // Handles both strict JSON {"key":"value"} and JS object literals {key: "value"}
27
+ // ─────────────────────────────────────────────────────────────────────────────
28
+
29
+ function parseAttr(attrStr: string | null): any {
30
+ if (!attrStr) return {};
31
+ try {
32
+ return JSON.parse(attrStr);
33
+ } catch {
34
+ try {
35
+ // eslint-disable-next-line no-new-func
36
+ return new Function(`"use strict"; return (${attrStr})`)();
37
+ } catch {
38
+ console.warn("HtmlForm: could not parse attr →", attrStr);
39
+ return {};
40
+ }
41
+ }
42
+ }
43
+
44
+ // ─────────────────────────────────────────────────────────────────────────────
45
+ // DOM Attribute → React Prop mapper
46
+ // ─────────────────────────────────────────────────────────────────────────────
47
+
48
+ const ATTR_MAP: Record<string, string> = {
49
+ class: "className",
50
+ colspan: "colSpan",
51
+ rowspan: "rowSpan",
52
+ for: "htmlFor",
53
+ tabindex: "tabIndex",
54
+ readonly: "readOnly",
55
+ maxlength: "maxLength",
56
+ cellpadding: "cellPadding",
57
+ cellspacing: "cellSpacing",
58
+ };
59
+
60
+ function styleStringToObject(styleStr: string): Record<string, string> {
61
+ const style: Record<string, string> = {};
62
+ styleStr.split(";").forEach((rule) => {
63
+ const [prop, val] = rule.split(":").map((s) => s.trim());
64
+ if (prop && val) {
65
+ const camel = prop.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
66
+ style[camel] = val;
67
+ }
68
+ });
69
+ return style;
70
+ }
71
+
72
+ function domAttrsToProps(el: Element): Record<string, any> {
73
+ const props: Record<string, any> = {};
74
+ for (const attr of Array.from(el.attributes)) {
75
+ if (["component", "attr"].includes(attr.name)) continue;
76
+ const reactName = ATTR_MAP[attr.name] ?? attr.name;
77
+ props[reactName] = attr.name === "style"
78
+ ? styleStringToObject(attr.value)
79
+ : attr.value;
80
+ }
81
+ return props;
82
+ }
83
+
84
+ // ─────────────────────────────────────────────────────────────────────────────
85
+ // Table structural elements that cannot contain whitespace text nodes
86
+ // ─────────────────────────────────────────────────────────────────────────────
87
+
88
+ const TABLE_ELEMENTS = new Set(["table", "thead", "tbody", "tfoot", "tr", "colgroup"]);
89
+
90
+ // ─────────────────────────────────────────────────────────────────────────────
91
+ // DOM Walker
92
+ // Turns a DOM tree into a React element tree.
93
+ // Sentinel <span component="X" attr="..."> becomes <DynamicComponent config={...} />
94
+ // Everything else becomes a plain React element.
95
+ // ─────────────────────────────────────────────────────────────────────────────
96
+
97
+ let _keyIndex = 0;
98
+ const nextKey = () => `hf_${_keyIndex++}`;
99
+
100
+ function walkNode(node: ChildNode, parentTag?: string): React.ReactNode {
101
+ if (node.nodeType === Node.TEXT_NODE) {
102
+ // Whitespace-only text nodes are invalid inside table structural elements
103
+ // and cause React's validateDOMNesting warning.
104
+ if (parentTag && TABLE_ELEMENTS.has(parentTag) && !node.textContent?.trim()) {
105
+ return null;
106
+ }
107
+ return node.textContent || null;
108
+ }
109
+
110
+ if (node.nodeType === Node.ELEMENT_NODE) {
111
+ const el = node as Element;
112
+ const tag = el.tagName.toLowerCase();
113
+ const componentName = el.getAttribute("component");
114
+
115
+ // ── Sentinel span → DynamicComponent ──────────────────────────────────
116
+ if (tag === "span" && componentName) {
117
+ const attr: any = parseAttr(el.getAttribute("attr"));
118
+ const config: SentinelConfig = { component: componentName, attr };
119
+ return (
120
+ <DynamicComponent
121
+ key={nextKey()}
122
+ config={config}
123
+ />
124
+ );
125
+ }
126
+
127
+ // ── Regular element → recurse ──────────────────────────────────────────
128
+ const props = { ...domAttrsToProps(el), key: nextKey() };
129
+ const children: React.ReactNode[] = Array.from(el.childNodes)
130
+ .map((child) => walkNode(child, tag)) // pass current tag as parentTag
131
+ .filter((n) => n !== null && n !== undefined);
132
+
133
+ return children.length > 0
134
+ ? React.createElement(tag, props, ...children)
135
+ : React.createElement(tag, props);
136
+ }
137
+
138
+ return null;
139
+ }
140
+
141
+ // ─────────────────────────────────────────────────────────────────────────────
142
+ // HtmlForm
143
+ // ─────────────────────────────────────────────────────────────────────────────
144
+
145
+ const HtmlForm = (props: HtmlFormProps) => {
146
+ const { depends, templateid } = props ?? {};
147
+
148
+ const [htmlTemplate, setHtmlTemplate] = useState("");
149
+
150
+ const { tenant, module } = useApp();
151
+
152
+ // ── Load raw HTML from html_forms ──────────────────────────────────────────
153
+ const loadHtmlContent = async (tempid: string) => {
154
+ try {
155
+ const record = await localAPI.useMgmt(tenant!, module!).get("html_templates", tempid);
156
+ setHtmlTemplate(record?.htmlCode ?? "");
157
+ } catch (error) {
158
+ console.error("HtmlForm: error loading html_forms →", error);
159
+ setHtmlTemplate("");
160
+ }
161
+ };
162
+
163
+ useDependHandler({ name: depends, onRefresh: () => {} });
164
+
165
+ useEffect(() => {
166
+ if (templateid?.trim()) loadHtmlContent(templateid);
167
+ }, [templateid]);
168
+
169
+ // ── Walk DOM → React tree (only re-runs when htmlTemplate changes) ─────────
170
+ const reactTree = useMemo(() => {
171
+ if (!htmlTemplate) return null;
172
+ _keyIndex = 0;
173
+ const doc = new DOMParser().parseFromString(htmlTemplate, "text/html");
174
+ return Array.from(doc.body.childNodes).map((child) => walkNode(child));
175
+ }, [htmlTemplate]);
176
+
177
+ return (
178
+ <UIComponent {...(props ?? {})}>
179
+ <div className="h-[calc(100vh-80px)] overflow-y-auto overflow-x-auto">
180
+ {reactTree}
181
+ </div>
182
+ </UIComponent>
183
+ );
184
+ };
185
+
186
+ export default HtmlForm;
@@ -0,0 +1,9 @@
1
+ type HtmlLabelProps = {
2
+ label?: string;
3
+ depends?: string;
4
+ expr?: string;
5
+ templateid?: string;
6
+ data?: Record<string, any>;
7
+ };
8
+ declare const Html: (props: HtmlLabelProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default Html;
@@ -0,0 +1,85 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { localAPI } from "@ramesesinc/lib/local-api";
3
+ import { useEffect, useState } from "react";
4
+ import { useApp } from "../../core/AppContext";
5
+ import { usePageContext } from "../../core/PageContext";
6
+ import useDependHandler from "../../core/UIDependHandler";
7
+ import { render } from "../../lib/utils/ExprUtil";
8
+ import UIComponent from "../common/UIComponent";
9
+ const Html = (props) => {
10
+ const { depends, expr, templateid } = props !== null && props !== void 0 ? props : {};
11
+ const [htmlTemplate, setHtmlTemplate] = useState(""); // Store the raw template
12
+ const [renderedHtml, setRenderedHtml] = useState(""); // Store the rendered HTML
13
+ const [resData, setResData] = useState({});
14
+ const pageContext = usePageContext();
15
+ const binding = pageContext === null || pageContext === void 0 ? void 0 : pageContext.binding;
16
+ const { tenant, module } = useApp();
17
+ const loadHtmlContent = async (tempid) => {
18
+ var _a;
19
+ try {
20
+ const htmlContent = await localAPI.useMgmt(tenant, module).get("html_templates", tempid);
21
+ if (htmlContent != null) {
22
+ // Store the raw template
23
+ setHtmlTemplate(htmlContent.htmlCode);
24
+ // Fetch data from API
25
+ const data = (_a = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getAllData()) !== null && _a !== void 0 ? _a : {};
26
+ // Render the template with the data
27
+ const rendered = render(htmlContent.htmlCode, data);
28
+ setRenderedHtml(rendered);
29
+ }
30
+ else {
31
+ setHtmlTemplate("");
32
+ setRenderedHtml("");
33
+ }
34
+ }
35
+ catch (error) {
36
+ console.error("Error loading HTML template:", error);
37
+ setHtmlTemplate("");
38
+ setRenderedHtml("");
39
+ }
40
+ };
41
+ // Render the expression using ExprUtil
42
+ const renderExpression = (expression) => {
43
+ var _a;
44
+ if (!expression)
45
+ return "";
46
+ try {
47
+ const data = (_a = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getData()) !== null && _a !== void 0 ? _a : {};
48
+ return render(expression, { data });
49
+ }
50
+ catch (error) {
51
+ console.error("Expression render error:", error);
52
+ return expression;
53
+ }
54
+ };
55
+ const initialValue = renderExpression(expr !== null && expr !== void 0 ? expr : "");
56
+ const [value, setValue] = useState(initialValue);
57
+ const onRefresh = () => {
58
+ const newValue = renderExpression(expr !== null && expr !== void 0 ? expr : "");
59
+ setValue(newValue);
60
+ // Re-render the HTML template if data changes
61
+ if (htmlTemplate && resData) {
62
+ const rendered = render(htmlTemplate, resData);
63
+ setRenderedHtml(rendered);
64
+ }
65
+ };
66
+ useDependHandler({ name: depends, onRefresh });
67
+ useEffect(() => {
68
+ if (templateid != null && templateid.trim() !== "") {
69
+ loadHtmlContent(templateid);
70
+ }
71
+ }, [templateid]);
72
+ useEffect(() => {
73
+ const newValue = renderExpression(expr !== null && expr !== void 0 ? expr : "");
74
+ setValue(newValue);
75
+ }, [binding === null || binding === void 0 ? void 0 : binding.raw, expr]);
76
+ // Re-render template when data changes
77
+ useEffect(() => {
78
+ if (htmlTemplate && resData && Object.keys(resData).length > 0) {
79
+ const rendered = render(htmlTemplate, resData);
80
+ setRenderedHtml(rendered);
81
+ }
82
+ }, [resData, htmlTemplate]);
83
+ return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsx("div", { className: "h-[calc(100vh-80px)] overflow-y-auto overflow-x-auto", dangerouslySetInnerHTML: { __html: renderedHtml } }) })));
84
+ };
85
+ export default Html;