@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,50 @@
1
+ "use client";
2
+
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import { AbstractComponent } from "../../types/component";
5
+
6
+ /* ------------------------------------------------------------------ */
7
+ /* Types */
8
+
9
+ interface UndoProps extends AbstractComponent {
10
+ className?: string;
11
+ title?: string;
12
+ api: string;
13
+ data?: string;
14
+ }
15
+
16
+ /* ------------------------------------------------------------------ */
17
+ /* Component */
18
+
19
+ const Undo = (props: UndoProps) => {
20
+ const { className = "", title, api, data } = props ?? {};
21
+ const pageContext = usePageContext();
22
+
23
+ /* ---------------------- Events ---------------------- */
24
+ const handleClick = async () => {
25
+ try {
26
+ /*
27
+ if(!api) throw new Error("api not defined");
28
+ const allData = pageContext?.getAllData() ?? {};
29
+ if( data ) {
30
+ const d = getValue( data, allData );
31
+ await pageContext?.execService( api, d );
32
+ }
33
+ else {
34
+ await pageContext?.execService( api, allData );
35
+ }
36
+ */
37
+ } catch (err: any) {
38
+ alert(err.message);
39
+ }
40
+ };
41
+
42
+ /* ---------------------- Render ---------------------- */
43
+ return (
44
+ <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
45
+ {title || "Update Context"}
46
+ </button>
47
+ );
48
+ };
49
+
50
+ export default Undo;
@@ -0,0 +1,9 @@
1
+ import { AbstractComponent } from "../../types/component";
2
+ interface UpdateContextProps extends AbstractComponent {
3
+ source: string;
4
+ target: string;
5
+ className?: string;
6
+ title?: string;
7
+ }
8
+ declare const UpdateContext: (props: UpdateContextProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default UpdateContext;
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { usePageContext } from "../../core/PageContext";
4
+ /* ------------------------------------------------------------------ */
5
+ /* Component */
6
+ const UpdateContext = (props) => {
7
+ const { source, target, className = "", title } = props !== null && props !== void 0 ? props : {};
8
+ const pageContext = usePageContext();
9
+ /* ---------------------- Events ---------------------- */
10
+ const handleClick = () => {
11
+ var _a;
12
+ if (!source || !target)
13
+ return;
14
+ const allData = (_a = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getAllData()) !== null && _a !== void 0 ? _a : {};
15
+ const value = allData[source];
16
+ pageContext === null || pageContext === void 0 ? void 0 : pageContext.set(target, value);
17
+ };
18
+ /* ---------------------- Render ---------------------- */
19
+ return (_jsx("button", { onClick: handleClick, className: `px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`, children: title || "Update Context" }));
20
+ };
21
+ export default UpdateContext;
@@ -0,0 +1,40 @@
1
+ "use client";
2
+
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import { AbstractComponent } from "../../types/component";
5
+
6
+ /* ------------------------------------------------------------------ */
7
+ /* Types */
8
+
9
+ interface UpdateContextProps extends AbstractComponent {
10
+ source: string;
11
+ target: string;
12
+ className?: string;
13
+ title?: string;
14
+ }
15
+
16
+ /* ------------------------------------------------------------------ */
17
+ /* Component */
18
+
19
+ const UpdateContext = (props: UpdateContextProps) => {
20
+ const { source, target, className = "", title } = props ?? {};
21
+
22
+ const pageContext = usePageContext();
23
+
24
+ /* ---------------------- Events ---------------------- */
25
+ const handleClick = () => {
26
+ if (!source || !target) return;
27
+ const allData = pageContext?.getAllData() ?? {};
28
+ const value = allData[source];
29
+ pageContext?.set(target, value);
30
+ };
31
+
32
+ /* ---------------------- Render ---------------------- */
33
+ return (
34
+ <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
35
+ {title || "Update Context"}
36
+ </button>
37
+ );
38
+ };
39
+
40
+ export default UpdateContext;
@@ -0,0 +1,9 @@
1
+ import { AbstractComponent } from "../../types/component";
2
+ interface UpdateDataProps extends AbstractComponent {
3
+ className?: string;
4
+ title?: string;
5
+ api: string;
6
+ data?: string;
7
+ }
8
+ declare const UpdateData: (props: UpdateDataProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default UpdateData;
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import { getValue } from "../../lib/utils/BeanUtils";
5
+ /* ------------------------------------------------------------------ */
6
+ /* Component */
7
+ const UpdateData = (props) => {
8
+ const { className = "", title, api, data } = props !== null && props !== void 0 ? props : {};
9
+ const pageContext = usePageContext();
10
+ /* ---------------------- Events ---------------------- */
11
+ const handleClick = async () => {
12
+ var _a, _b;
13
+ try {
14
+ if (!api)
15
+ throw new Error("api not defined");
16
+ if (data) {
17
+ const allData = (_a = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getAllData()) !== null && _a !== void 0 ? _a : {};
18
+ const d = getValue(data, allData);
19
+ await (pageContext === null || pageContext === void 0 ? void 0 : pageContext.execService(api, d));
20
+ }
21
+ else {
22
+ const vdata = (_b = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getData()) !== null && _b !== void 0 ? _b : {};
23
+ await (pageContext === null || pageContext === void 0 ? void 0 : pageContext.execService(api, vdata));
24
+ }
25
+ }
26
+ catch (err) {
27
+ alert(err.message);
28
+ }
29
+ };
30
+ /* ---------------------- Render ---------------------- */
31
+ return (_jsx("button", { onClick: handleClick, className: `px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`, children: title || "Update Context" }));
32
+ };
33
+ export default UpdateData;
@@ -0,0 +1,49 @@
1
+ "use client";
2
+
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import { getValue } from "../../lib/utils/BeanUtils";
5
+ import { AbstractComponent } from "../../types/component";
6
+
7
+ /* ------------------------------------------------------------------ */
8
+ /* Types */
9
+
10
+ interface UpdateDataProps extends AbstractComponent {
11
+ className?: string;
12
+ title?: string;
13
+ api: string;
14
+ data?: string;
15
+ }
16
+
17
+ /* ------------------------------------------------------------------ */
18
+ /* Component */
19
+
20
+ const UpdateData = (props: UpdateDataProps) => {
21
+ const { className = "", title, api, data } = props ?? {};
22
+ const pageContext = usePageContext();
23
+
24
+ /* ---------------------- Events ---------------------- */
25
+ const handleClick = async () => {
26
+ try {
27
+ if (!api) throw new Error("api not defined");
28
+ if (data) {
29
+ const allData = pageContext?.getAllData() ?? {};
30
+ const d = getValue(data, allData);
31
+ await pageContext?.execService(api, d);
32
+ } else {
33
+ const vdata = pageContext?.getData() ?? {};
34
+ await pageContext?.execService(api, vdata);
35
+ }
36
+ } catch (err: any) {
37
+ alert(err.message);
38
+ }
39
+ };
40
+
41
+ /* ---------------------- Render ---------------------- */
42
+ return (
43
+ <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
44
+ {title || "Update Context"}
45
+ </button>
46
+ );
47
+ };
48
+
49
+ export default UpdateData;
@@ -0,0 +1,9 @@
1
+ import { AbstractComponent } from "../../types/component";
2
+ interface ViewBackPageProps extends AbstractComponent {
3
+ className?: string;
4
+ title?: string;
5
+ icon?: string;
6
+ opt?: Record<string, any>;
7
+ }
8
+ declare const ViewBackPage: (props: ViewBackPageProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default ViewBackPage;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { usePageViewContext } from "../../core/PageViewContext";
4
+ /* ------------------------------------------------------------------ */
5
+ /* Component */
6
+ const ViewBackPage = (props) => {
7
+ const { className = "", title, icon, opt = {} } = props !== null && props !== void 0 ? props : {};
8
+ const pageView = usePageViewContext();
9
+ /* ---------------------- Events ---------------------- */
10
+ const handleClick = () => {
11
+ pageView === null || pageView === void 0 ? void 0 : pageView.popPage();
12
+ };
13
+ const hasBackPage = () => {
14
+ return pageView == null ? false : pageView.hasBackPage();
15
+ };
16
+ /* ---------------------- Render ---------------------- */
17
+ return (_jsx(_Fragment, { children: hasBackPage() && (_jsxs("button", { onClick: handleClick, className: `px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`, children: [icon && _jsx("span", { className: "dl-action-icon", children: icon }), title || "Back"] })) }));
18
+ };
19
+ export default ViewBackPage;
@@ -0,0 +1,46 @@
1
+ "use client";
2
+
3
+ import { usePageViewContext } from "../../core/PageViewContext";
4
+ import { AbstractComponent } from "../../types/component";
5
+
6
+ /* ------------------------------------------------------------------ */
7
+ /* Types */
8
+
9
+ interface ViewBackPageProps extends AbstractComponent {
10
+ className?: string;
11
+ title?: string;
12
+ icon?: string;
13
+ opt?: Record<string, any>;
14
+ }
15
+
16
+ /* ------------------------------------------------------------------ */
17
+ /* Component */
18
+
19
+ const ViewBackPage = (props: ViewBackPageProps) => {
20
+ const { className = "", title, icon, opt = {} } = props ?? {};
21
+
22
+ const pageView = usePageViewContext();
23
+
24
+ /* ---------------------- Events ---------------------- */
25
+ const handleClick = () => {
26
+ pageView?.popPage();
27
+ };
28
+
29
+ const hasBackPage = () => {
30
+ return pageView == null ? false : pageView.hasBackPage();
31
+ };
32
+
33
+ /* ---------------------- Render ---------------------- */
34
+ return (
35
+ <>
36
+ {hasBackPage() && (
37
+ <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
38
+ {icon && <span className="dl-action-icon">{icon}</span>}
39
+ {title || "Back"}
40
+ </button>
41
+ )}
42
+ </>
43
+ );
44
+ };
45
+
46
+ export default ViewBackPage;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { AbstractComponent } from "../../types/component";
3
+ interface ViewPageProps extends AbstractComponent {
4
+ url: string;
5
+ mode?: "popup" | "window";
6
+ className?: string;
7
+ title?: string;
8
+ icon?: string | React.ReactNode;
9
+ opt?: Record<string, any>;
10
+ iconOnly?: boolean;
11
+ popupClassName?: string;
12
+ }
13
+ declare const ViewPage: (props: ViewPageProps) => import("react/jsx-runtime").JSX.Element;
14
+ export default ViewPage;
@@ -0,0 +1,88 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { forwardRef, memo, useImperativeHandle, useRef, useState } from "react";
4
+ import { useDataContext } from "../../core/DataContext";
5
+ import { usePageContext } from "../../core/PageContext";
6
+ import { usePageViewContext } from "../../core/PageViewContext";
7
+ import { substituteExpr } from "../../lib/utils/BeanUtils";
8
+ import { getUrlPageParams, parseHashUrl } from "../../lib/utils/PageUtils";
9
+ import PopupView from "../view/PopupView";
10
+ /* ------------------------------------------------------------------ */
11
+ /* Component */
12
+ const ViewPage = (props) => {
13
+ const { url, mode, className = "", title, icon, opt = {}, popupClassName = "", iconOnly = false } = props !== null && props !== void 0 ? props : {};
14
+ const { data = {} } = opt;
15
+ const dataContext = useDataContext();
16
+ const pageView = usePageViewContext();
17
+ const pageContext = usePageContext();
18
+ const slotRef = useRef(null);
19
+ /* ---------------------- Events ---------------------- */
20
+ const onClose = () => {
21
+ var _a;
22
+ (_a = slotRef.current) === null || _a === void 0 ? void 0 : _a.update(null);
23
+ };
24
+ const handleClick = (e) => {
25
+ var _a;
26
+ e.preventDefault();
27
+ if (!url)
28
+ return;
29
+ const getUrlParams = () => {
30
+ let result = null;
31
+ if (pageView.isStandalone()) {
32
+ const { params } = parseHashUrl(url);
33
+ result = params;
34
+ }
35
+ else {
36
+ const { params } = getUrlPageParams();
37
+ result = params;
38
+ }
39
+ return result !== null && result !== void 0 ? result : {};
40
+ };
41
+ const getUrlData = () => {
42
+ let result = null;
43
+ if (dataContext == null) {
44
+ // use data received from props
45
+ const fullData = Object.assign(Object.assign({}, pageContext.getAllData()), data);
46
+ result = fullData;
47
+ }
48
+ else {
49
+ result = dataContext.getData();
50
+ }
51
+ return result !== null && result !== void 0 ? result : {};
52
+ };
53
+ const urlParams = getUrlParams();
54
+ const urlData = getUrlData();
55
+ const surl = substituteExpr(url, Object.assign(Object.assign({}, urlParams), urlData));
56
+ if (mode === "popup") {
57
+ const handler = {
58
+ onSave: (itm) => {
59
+ onClose();
60
+ pageContext.notifyDepends();
61
+ },
62
+ refresh: () => {
63
+ pageContext.notifyDepends();
64
+ },
65
+ };
66
+ (_a = slotRef.current) === null || _a === void 0 ? void 0 : _a.update(_jsx(PopupView, { url: surl, onClose: onClose, eventHandler: handler }));
67
+ }
68
+ else if (mode === "window") {
69
+ pageView.setPage(surl, { mode });
70
+ }
71
+ else {
72
+ pageView.pushPage(surl);
73
+ }
74
+ };
75
+ /* ---------------------- Render ---------------------- */
76
+ return (_jsxs(_Fragment, { children: [iconOnly ? (_jsx("span", { onClick: handleClick, className: `cursor-pointer ${className}`, children: icon })) : (_jsxs("button", { onClick: handleClick, className: `px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`, children: [icon && _jsx("span", { className: "dl-action-icon", children: icon }), title || "View Page"] })), _jsx(ChildrenSlot, { ref: slotRef })] }));
77
+ };
78
+ export default ViewPage;
79
+ const ChildrenSlot = memo(forwardRef((_, ref) => {
80
+ const [content, setContent] = useState(null);
81
+ useImperativeHandle(ref, () => ({
82
+ update: (content) => {
83
+ // console.log("view page children slot", content);
84
+ setContent(content);
85
+ },
86
+ }), []);
87
+ return _jsx(_Fragment, { children: content == null ? null : content });
88
+ }));
@@ -0,0 +1,141 @@
1
+ "use client";
2
+
3
+ import React, { forwardRef, memo, useImperativeHandle, useRef, useState } from "react";
4
+ import { useDataContext } from "../../core/DataContext";
5
+ import { usePageContext } from "../../core/PageContext";
6
+ import { usePageViewContext } from "../../core/PageViewContext";
7
+ import { substituteExpr } from "../../lib/utils/BeanUtils";
8
+ import { getUrlPageParams, parseHashUrl } from "../../lib/utils/PageUtils";
9
+ import { AbstractComponent } from "../../types/component";
10
+ import PopupView from "../view/PopupView";
11
+
12
+ /* ------------------------------------------------------------------ */
13
+ /* Types */
14
+
15
+ interface ViewPageProps extends AbstractComponent {
16
+ url: string;
17
+ mode?: "popup" | "window";
18
+ className?: string;
19
+ title?: string;
20
+ icon?: string | React.ReactNode;
21
+ opt?: Record<string, any>;
22
+ iconOnly?: boolean;
23
+ popupClassName?: string;
24
+ }
25
+
26
+ /* ------------------------------------------------------------------ */
27
+ /* Component */
28
+
29
+ const ViewPage = (props: ViewPageProps) => {
30
+ const { url, mode, className = "", title, icon, opt = {}, popupClassName = "", iconOnly = false } = props ?? {};
31
+ const { data = {} } = opt;
32
+
33
+ const dataContext = useDataContext();
34
+ const pageView = usePageViewContext();
35
+ const pageContext = usePageContext();
36
+ const slotRef = useRef<ChildrenSlotHandle>(null);
37
+
38
+ /* ---------------------- Events ---------------------- */
39
+
40
+ const onClose = () => {
41
+ slotRef.current?.update(null);
42
+ };
43
+
44
+ const handleClick = (e: React.MouseEvent) => {
45
+ e.preventDefault();
46
+
47
+ if (!url) return;
48
+
49
+ const getUrlParams = () => {
50
+ let result = null;
51
+ if (pageView.isStandalone()) {
52
+ const { params } = parseHashUrl(url);
53
+ result = params;
54
+ } else {
55
+ const { params } = getUrlPageParams();
56
+ result = params;
57
+ }
58
+ return result ?? {};
59
+ };
60
+
61
+ const getUrlData = () => {
62
+ let result = null;
63
+ if (dataContext == null) {
64
+ // use data received from props
65
+ const fullData = {
66
+ ...pageContext.getAllData(),
67
+ ...data,
68
+ };
69
+ result = fullData;
70
+ } else {
71
+ result = dataContext.getData();
72
+ }
73
+ return result ?? {};
74
+ };
75
+
76
+ const urlParams = getUrlParams();
77
+ const urlData = getUrlData();
78
+ const surl = substituteExpr(url, { ...urlParams, ...urlData });
79
+
80
+ if (mode === "popup") {
81
+ const handler = {
82
+ onSave: (itm: any) => {
83
+ onClose();
84
+ pageContext.notifyDepends();
85
+ },
86
+ refresh: () => {
87
+ pageContext.notifyDepends();
88
+ },
89
+ };
90
+
91
+ slotRef.current?.update(<PopupView url={surl} onClose={onClose} eventHandler={handler} />);
92
+ } else if (mode === "window") {
93
+ pageView.setPage(surl, { mode });
94
+ } else {
95
+ pageView.pushPage(surl);
96
+ }
97
+ };
98
+
99
+ /* ---------------------- Render ---------------------- */
100
+ return (
101
+ <>
102
+ {iconOnly ? (
103
+ <span onClick={handleClick} className={`cursor-pointer ${className}`}>
104
+ {icon}
105
+ </span>
106
+ ) : (
107
+ <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
108
+ {icon && <span className="dl-action-icon">{icon}</span>}
109
+ {title || "View Page"}
110
+ </button>
111
+ )}
112
+
113
+ <ChildrenSlot ref={slotRef} />
114
+ </>
115
+ );
116
+ };
117
+
118
+ export default ViewPage;
119
+
120
+ type ChildrenSlotHandle = {
121
+ update: (content: React.ReactNode) => void;
122
+ };
123
+
124
+ const ChildrenSlot = memo(
125
+ forwardRef<ChildrenSlotHandle>((_, ref) => {
126
+ const [content, setContent] = useState<React.ReactNode>(null);
127
+
128
+ useImperativeHandle(
129
+ ref,
130
+ () => ({
131
+ update: (content: React.ReactNode) => {
132
+ // console.log("view page children slot", content);
133
+ setContent(content);
134
+ },
135
+ }),
136
+ [],
137
+ );
138
+
139
+ return <>{content == null ? null : content}</>;
140
+ }),
141
+ );
@@ -0,0 +1,11 @@
1
+ export type UIComponentProps = {
2
+ name?: string;
3
+ title?: string;
4
+ depends?: string;
5
+ visibleWhen?: string;
6
+ children?: React.ReactNode;
7
+ labelPosition?: "top" | "left";
8
+ style?: string;
9
+ };
10
+ declare const UIComponent: (props: UIComponentProps) => import("react/jsx-runtime").JSX.Element | null;
11
+ export default UIComponent;
@@ -0,0 +1,52 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import { usePageContext } from "../../core/PageContext";
4
+ const UIComponent = (props) => {
5
+ var _a;
6
+ const { name, title, depends, children, visibleWhen, labelPosition = "top", style } = props !== null && props !== void 0 ? props : {};
7
+ const pageContext = usePageContext();
8
+ const evaluateVisible = () => {
9
+ var _a;
10
+ if (!visibleWhen)
11
+ return true;
12
+ try {
13
+ const context = (_a = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getAllData()) !== null && _a !== void 0 ? _a : {};
14
+ const stripped = visibleWhen.replace(/^\s*\{([\s\S]*)\}\s*$/, "$1").trim();
15
+ const jsExpr = stripped.replace(/\{\{([\s\S]+?)\}\}/g, (_, path) => {
16
+ const val = path
17
+ .trim()
18
+ .split(".")
19
+ .reduce((obj, key) => obj === null || obj === void 0 ? void 0 : obj[key], context);
20
+ return JSON.stringify(val !== null && val !== void 0 ? val : null);
21
+ });
22
+ // eslint-disable-next-line no-new-func
23
+ return Boolean(new Function(`return (${jsExpr})`)());
24
+ }
25
+ catch (e) {
26
+ console.warn("visibleWhen eval error:", e);
27
+ return true;
28
+ }
29
+ };
30
+ const [visible, setVisible] = useState(() => evaluateVisible());
31
+ const dependHandler = (val) => {
32
+ // for visibleWhen
33
+ setVisible(evaluateVisible());
34
+ };
35
+ useEffect(() => {
36
+ const unsubscribe = pageContext === null || pageContext === void 0 ? void 0 : pageContext.dependsTo(depends || "", dependHandler);
37
+ return unsubscribe;
38
+ }, [depends]);
39
+ // Re-evaluate when binding changes (same pattern as Label)
40
+ useEffect(() => {
41
+ setVisible(evaluateVisible());
42
+ }, [(_a = pageContext === null || pageContext === void 0 ? void 0 : pageContext.binding) === null || _a === void 0 ? void 0 : _a.raw, visibleWhen]);
43
+ if (!visible)
44
+ return null;
45
+ // Top layout (default)
46
+ if (labelPosition === "top") {
47
+ return (_jsxs("div", { className: "flex flex-col gap-1 mb-4", children: [title && (_jsx("label", { htmlFor: name, className: "text-sm font-medium text-gray-700", children: title })), children] }));
48
+ }
49
+ // Left layout
50
+ return (_jsxs("div", { className: "flex items-center gap-2 mb-4", children: [title && (_jsx("label", { htmlFor: name, className: "text-sm font-medium text-gray-700 min-w-[50px]", children: title })), _jsx("div", { className: "flex-1", children: children })] }));
51
+ };
52
+ export default UIComponent;