@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,29 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ type HorizontalLayoutProps = {
4
+ layoutid?: string;
5
+ className?: string;
6
+ gap?: number;
7
+ left?: ReactNode;
8
+ right?: ReactNode;
9
+ children?: ReactNode;
10
+ };
11
+
12
+ const HorizontalLayout = ({ layoutid, className, gap = 0, left, right, children }: HorizontalLayoutProps) => {
13
+
14
+ const preferredLayoutId = ((layoutid ?? '') ? layoutid : 'horizontallayout');
15
+
16
+ return (
17
+ <div className={`${preferredLayoutId}-container ${className ?? ""} flex flex-row h-full gap-${gap}`}>
18
+ {left}
19
+
20
+ <div className="flex-1">
21
+ {children}
22
+ </div>
23
+
24
+ {right}
25
+ </div>
26
+ );
27
+ };
28
+
29
+ export default HorizontalLayout;
@@ -0,0 +1,16 @@
1
+ // src/layouts/MainLayout.tsx
2
+ import { ReactNode } from "react";
3
+
4
+ interface MainLayoutProps {
5
+ children: ReactNode;
6
+ }
7
+
8
+ export const MainLayout = ({ children }: MainLayoutProps) => {
9
+ return (
10
+ <div className="min-h-screen flex flex-col">
11
+ <main className="flex-1">{children}</main>
12
+ </div>
13
+ );
14
+ };
15
+
16
+ export default MainLayout;
@@ -0,0 +1,29 @@
1
+ import React, { ReactNode } from "react";
2
+
3
+ type PageLayoutProps = {
4
+ layoutid?: string;
5
+ className?: string;
6
+ gap?: number;
7
+ header?: ReactNode;
8
+ footer?: ReactNode;
9
+ children?: ReactNode;
10
+ };
11
+
12
+ const PageLayout = ({ layoutid, className, gap = 0, header, footer, children }: PageLayoutProps) => {
13
+
14
+ const preferredLayoutId = ((layoutid ?? '') ? layoutid : 'pagelayout');
15
+
16
+ return (
17
+ <div className={`${preferredLayoutId}-container ${className ?? ""} flex flex-col h-full gap-${gap}`}>
18
+ {header}
19
+
20
+ <div className="flex-1">
21
+ {children}
22
+ </div>
23
+
24
+ {footer}
25
+ </div>
26
+ );
27
+ };
28
+
29
+ export default PageLayout;
@@ -0,0 +1,27 @@
1
+ "use client";
2
+
3
+ import React, { CSSProperties, ReactNode } from "react";
4
+
5
+ interface VPanelProps {
6
+ children?: ReactNode;
7
+ gap?: number | string; // spacing between items
8
+ style?: CSSProperties; // custom styles
9
+ className?: string; // optional tailwind or other class
10
+ }
11
+
12
+ const VPanel: React.FC<VPanelProps> = ({ children, gap = 0, style, className }) => {
13
+ const panelStyle: CSSProperties = {
14
+ display: "flex",
15
+ flexDirection: "column",
16
+ gap: gap,
17
+ ...style,
18
+ };
19
+
20
+ return (
21
+ <div style={panelStyle} className={className}>
22
+ {children}
23
+ </div>
24
+ );
25
+ };
26
+
27
+ export default VPanel;
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+
3
+ type XLayoutAlignment = "left" | "center" | "right";
4
+
5
+ type XLayoutProps = {
6
+ className?: string;
7
+ gap?: number;
8
+ align?: XLayoutAlignment;
9
+ children?: React.ReactNode;
10
+ };
11
+
12
+ const XLayout: React.FC<XLayoutProps> = ({
13
+ className,
14
+ gap = 2,
15
+ align = "left",
16
+ children,
17
+ }) => {
18
+ let justifyClass = "justify-start"; // default = left
19
+ if (align === "center") justifyClass = "justify-center";
20
+ if (align === "right") justifyClass = "justify-end";
21
+
22
+ return (
23
+ <div className={`${className ?? ""} flex flex-row gap-${gap} ${justifyClass}`.trim()}>
24
+ {children}
25
+ </div>
26
+ );
27
+ };
28
+
29
+ export default XLayout;
@@ -0,0 +1,29 @@
1
+ import React from "react";
2
+
3
+ type YLayoutAlignment = "top" | "center" | "bottom";
4
+
5
+ type YLayoutProps = {
6
+ className?: string;
7
+ gap?: number;
8
+ align?: YLayoutAlignment;
9
+ children?: React.ReactNode;
10
+ };
11
+
12
+ const YLayout: React.FC<YLayoutProps> = ({
13
+ className,
14
+ gap = 2,
15
+ align = "top",
16
+ children,
17
+ }) => {
18
+ let justifyClass = "justify-start"; // default = left
19
+ if (align === "center") justifyClass = "justify-center";
20
+ if (align === "bottom") justifyClass = "justify-end";
21
+
22
+ return (
23
+ <div className={`${className ?? ""} flex flex-col gap-${gap} ${justifyClass}`.trim()}>
24
+ {children}
25
+ </div>
26
+ );
27
+ };
28
+
29
+ export default YLayout;
@@ -0,0 +1,3 @@
1
+ export declare const getValue: (path: string | Record<string, any>, data: any) => any;
2
+ export declare const replaceValues: (obj: any, source: any) => any;
3
+ export declare const substituteExpr: (expression: string, source: any) => string;
@@ -0,0 +1,75 @@
1
+ export const getValue = (path, data) => {
2
+ if (path == null)
3
+ return undefined;
4
+ // If path is an object, recursively resolve all its values
5
+ if (typeof path === "object") {
6
+ const resolved = {};
7
+ for (const key in path) {
8
+ resolved[key] = getValue(path[key], data);
9
+ }
10
+ return resolved;
11
+ }
12
+ if (typeof path !== "string")
13
+ return undefined;
14
+ if (!path.includes("{"))
15
+ return path;
16
+ // If the entire string is a single placeholder e.g. "{vdata}" or "{vdata.company.name}"
17
+ // return the raw value instead of a string replacement
18
+ const singlePlaceholder = path.match(/^\{([^}]+)\}$/);
19
+ if (singlePlaceholder) {
20
+ const tokens = singlePlaceholder[1].split(".").filter(Boolean);
21
+ let current = data;
22
+ for (const token of tokens) {
23
+ if (current == null)
24
+ return undefined;
25
+ current = current[token];
26
+ }
27
+ return current !== undefined ? current : undefined;
28
+ }
29
+ // If the string contains placeholders mixed with other text e.g. "Hello {name}!"
30
+ // fall back to string replacement
31
+ return path.replace(/\{([^}]+)\}/g, (match, subPath) => {
32
+ const tokens = subPath.split(".").filter(Boolean);
33
+ let current = data;
34
+ for (const token of tokens) {
35
+ if (current == null)
36
+ return match;
37
+ current = current[token];
38
+ }
39
+ return current !== undefined ? current : match;
40
+ });
41
+ };
42
+ export const replaceValues = (obj, source) => {
43
+ // Handle null or undefined
44
+ if (obj === null || obj === undefined) {
45
+ return obj;
46
+ }
47
+ // Handle primitives (numbers, booleans)
48
+ if (typeof obj !== 'object' && typeof obj !== 'string') {
49
+ return obj;
50
+ }
51
+ // Handle strings - use getValue to resolve any templates
52
+ if (typeof obj === 'string') {
53
+ // getValue already handles both {id} and "text {id} more text" patterns
54
+ return getValue(obj, source);
55
+ }
56
+ // Handle arrays
57
+ if (Array.isArray(obj)) {
58
+ return obj.map(item => replaceValues(item, source));
59
+ }
60
+ // Handle objects - recursively replace all values
61
+ const result = {};
62
+ for (const key in obj) {
63
+ if (obj.hasOwnProperty(key)) {
64
+ result[key] = replaceValues(obj[key], source);
65
+ }
66
+ }
67
+ return result;
68
+ };
69
+ export const substituteExpr = (expression, source) => {
70
+ if (!expression || typeof expression !== 'string') {
71
+ return expression;
72
+ }
73
+ // Use getValue which already handles the replacement logic
74
+ return getValue(expression, source);
75
+ };
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ export type ComponentLoaderFunc = (name: string) => React.ComponentType<any>;
3
+ /**
4
+ * Loads components (blocks) with caching: local → package → error
5
+ */
6
+ export declare class ComponentLoader {
7
+ private static defaultLoader;
8
+ private static cache;
9
+ /** Set default loader for components */
10
+ static setDefaultLoader(loader: ComponentLoaderFunc): void;
11
+ /** Get component by name (uses cache) */
12
+ static get(name: string): React.ComponentType<any>;
13
+ }
@@ -0,0 +1,26 @@
1
+ // src/lib/utils/ComponentLoader.tsx
2
+ import React from "react";
3
+ /**
4
+ * Loads components (blocks) with caching: local → package → error
5
+ */
6
+ export class ComponentLoader {
7
+ /** Set default loader for components */
8
+ static setDefaultLoader(loader) {
9
+ this.defaultLoader = loader;
10
+ }
11
+ /** Get component by name (uses cache) */
12
+ static get(name) {
13
+ if (this.cache[name])
14
+ return this.cache[name];
15
+ if (!this.defaultLoader) {
16
+ const fallback = () => React.createElement("div", { style: { color: "red", padding: 8 } }, `Component "${name}" not found: no loader registered`);
17
+ this.cache[name] = fallback;
18
+ return fallback;
19
+ }
20
+ const Comp = this.defaultLoader(name);
21
+ this.cache[name] = Comp;
22
+ return Comp;
23
+ }
24
+ }
25
+ ComponentLoader.defaultLoader = null;
26
+ ComponentLoader.cache = {};
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Renders an expression template with the provided data
3
+ * @param expr - The expression template string
4
+ * @param data - The data object to use for rendering
5
+ * @returns The rendered string
6
+ */
7
+ export declare const render: (expr: string, data: any) => string;
@@ -0,0 +1,44 @@
1
+ // import nunjucks from "nunjucks";
2
+ const nunjucks = require("nunjucks");
3
+ let _nunjucksEnv = null;
4
+ const getNunjucksEnv = () => {
5
+ if (!_nunjucksEnv) {
6
+ _nunjucksEnv = new nunjucks.Environment(null, {
7
+ autoescape: false,
8
+ tags: {
9
+ variableStart: "{{",
10
+ variableEnd: "}}",
11
+ },
12
+ });
13
+ }
14
+ return _nunjucksEnv;
15
+ };
16
+ /**
17
+ * Renders an expression template with the provided data
18
+ * @param expr - The expression template string
19
+ * @param data - The data object to use for rendering
20
+ * @returns The rendered string
21
+ */
22
+ export const render = (expr, data) => {
23
+ if (!expr)
24
+ return "";
25
+ try {
26
+ return getNunjucksEnv().renderString(expr, data);
27
+ }
28
+ catch (error) {
29
+ console.error("Expression render error:", error);
30
+ return expr;
31
+ }
32
+ };
33
+ // import Mustache from "mustache";
34
+ // // Disable HTML escaping since you control the source
35
+ // Mustache.escape = (text) => text;
36
+ // export const render = (expr: string, data: any): string => {
37
+ // if (!expr) return "";
38
+ // try {
39
+ // return Mustache.render(expr, data);
40
+ // } catch (error) {
41
+ // console.error("Expression render error:", error);
42
+ // return expr;
43
+ // }
44
+ // };
@@ -0,0 +1,6 @@
1
+ export interface ParsedHashUrl {
2
+ page: string;
3
+ params: Record<string, string>;
4
+ }
5
+ export declare function parseHashUrl(url: string): ParsedHashUrl;
6
+ export declare function getUrlPageParams(): ParsedHashUrl;
@@ -0,0 +1,121 @@
1
+ /*
2
+ export const substitute = (template: string, data: any) => {
3
+ if (typeof template !== "string") return template;
4
+
5
+ return template.replace(/\{([^}]+)\}/g, (_, path) => {
6
+ const value = getValue(path, data);
7
+ return value !== undefined ? value : "";
8
+ });
9
+ };
10
+ */
11
+ export function parseHashUrl(url) {
12
+ const result = {};
13
+ // Remove leading slash
14
+ const cleaned = url.startsWith("/") ? url.slice(1) : url;
15
+ // Split by '#' to get segments
16
+ const segments = cleaned.split("#");
17
+ // If only one segment, params go to root level, page is the path
18
+ if (segments.length === 1) {
19
+ const [path, queryString] = segments[0].split("?");
20
+ if (queryString) {
21
+ parseParams(queryString).forEach(([key, value]) => {
22
+ result[key] = value;
23
+ });
24
+ }
25
+ return { page: path, params: result };
26
+ }
27
+ // Parse all segments first
28
+ const parsed = segments.map((segment) => {
29
+ const [path, queryString] = segment.split("?");
30
+ const params = queryString ? Object.fromEntries(parseParams(queryString)) : {};
31
+ return { path, params };
32
+ });
33
+ const lastIndex = parsed.length - 1;
34
+ const page = parsed[lastIndex].path;
35
+ // Collect all keys that will exist in the result:
36
+ // - group names (non-last segment paths)
37
+ // - last segment's param keys (always flat)
38
+ // - non-last segments' param keys (candidates for flattening)
39
+ const lastParams = parsed[lastIndex].params;
40
+ const groupNames = new Set(parsed.slice(0, lastIndex).map((s) => s.path));
41
+ const lastParamKeys = new Set(Object.keys(lastParams));
42
+ // Build a flat key registry to detect conflicts
43
+ // Start with group names and last segment keys
44
+ const reservedKeys = new Set([...groupNames, ...lastParamKeys]);
45
+ // For each non-last segment, decide: flatten or nest
46
+ // Process in order, updating reservedKeys as we go
47
+ const segmentDecisions = [];
48
+ for (let i = 0; i < lastIndex; i++) {
49
+ const { path, params } = parsed[i];
50
+ const paramKeys = Object.keys(params);
51
+ // Can flatten if none of the param keys conflict with already reserved keys
52
+ // and the path name itself won't be lost (path is already in reservedKeys as a group name,
53
+ // but we only add it if nesting — so check param keys against reservedKeys excluding own path)
54
+ const canFlatten = paramKeys.every((k) => !reservedKeys.has(k));
55
+ if (canFlatten) {
56
+ // Remove the group name from reserved (we won't be using it as a key)
57
+ reservedKeys.delete(path);
58
+ // Add flattened keys to reserved
59
+ paramKeys.forEach((k) => reservedKeys.add(k));
60
+ segmentDecisions.push({ path, params, flatten: true });
61
+ }
62
+ else {
63
+ segmentDecisions.push({ path, params, flatten: false });
64
+ }
65
+ }
66
+ // Build result
67
+ for (const { path, params, flatten } of segmentDecisions) {
68
+ if (flatten) {
69
+ Object.assign(result, params);
70
+ }
71
+ else {
72
+ result[path] = params;
73
+ }
74
+ }
75
+ // Last segment always flat at root
76
+ Object.assign(result, lastParams);
77
+ return { page, params: result };
78
+ }
79
+ function parseParams(queryString) {
80
+ return queryString.split("&").map((pair) => {
81
+ const [key, value] = pair.split("=");
82
+ return [decodeURIComponent(key), decodeURIComponent(value !== null && value !== void 0 ? value : "")];
83
+ });
84
+ }
85
+ export function getUrlPageParams() {
86
+ return parseHashUrl(window.location.href);
87
+ }
88
+ // export type ParsedPage = {
89
+ // pagename: string;
90
+ // params: Record<string, string>;
91
+ // };
92
+ // export const parseUrl = (url: string): ParsedPage[] => {
93
+ // const urlObj = url.startsWith("http") ? new URL(url) : new URL(url, window.location.origin);
94
+ // const pages: ParsedPage[] = [];
95
+ // // ---- main page ----
96
+ // const mainParams: Record<string, string> = {};
97
+ // urlObj.searchParams.forEach((value, key) => {
98
+ // mainParams[key] = value;
99
+ // });
100
+ // pages.push({
101
+ // pagename: urlObj.pathname.substring(1) || "home",
102
+ // params: mainParams,
103
+ // });
104
+ // // ---- hash page (next page) ----
105
+ // if (urlObj.hash) {
106
+ // const rawHash = urlObj.hash.substring(1); // remove #
107
+ // const [hashPath, hashQuery] = rawHash.split("?", 2);
108
+ // const hashParams: Record<string, string> = {};
109
+ // if (hashQuery) {
110
+ // const searchParams = new URLSearchParams(hashQuery);
111
+ // searchParams.forEach((value, key) => {
112
+ // hashParams[key] = value;
113
+ // });
114
+ // }
115
+ // pages.push({
116
+ // pagename: hashPath || "home",
117
+ // params: hashParams,
118
+ // });
119
+ // }
120
+ // return pages;
121
+ // };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ export type ComponentLoader = (name: string) => React.ComponentType<any>;
3
+ export declare class ResourceLoader {
4
+ private static loaders;
5
+ private static defaultLoader;
6
+ private static cache;
7
+ static registerLoader(key: string, loader: ComponentLoader): void;
8
+ static setDefaultLoader(loader: ComponentLoader): void;
9
+ static getTemplate(name: string, loaderKey?: string): React.ComponentClass<{}, any> | React.FunctionComponent<{}>;
10
+ static getComponent(name: string): React.ComponentClass<{}, any> | React.FunctionComponent<{}>;
11
+ }
@@ -0,0 +1,37 @@
1
+ // src/lib/utils/ResourceLoader.tsx
2
+ import dynamic from "next/dynamic";
3
+ import React from "react";
4
+ export class ResourceLoader {
5
+ static registerLoader(key, loader) {
6
+ this.loaders[key] = loader;
7
+ }
8
+ static setDefaultLoader(loader) {
9
+ this.defaultLoader = loader;
10
+ }
11
+ static getTemplate(name, loaderKey = "default") {
12
+ const cacheKey = `${loaderKey}:${name}`;
13
+ if (this.cache[cacheKey])
14
+ return this.cache[cacheKey];
15
+ const loader = loaderKey === "default" ? this.defaultLoader : this.loaders[loaderKey];
16
+ if (!loader) {
17
+ const Fallback = dynamic(() => Promise.resolve({
18
+ default: () => React.createElement("div", { style: { color: "red" } }, `No loader registered for "${loaderKey}"`),
19
+ }));
20
+ this.cache[cacheKey] = Fallback;
21
+ return Fallback;
22
+ }
23
+ const Comp = loader(name);
24
+ // this is temporary it should be cloned
25
+ // if (loaderKey != "component") {
26
+ // this.cache[cacheKey] = Comp;
27
+ // }
28
+ return Comp;
29
+ }
30
+ // Convenience helpers
31
+ static getComponent(name) {
32
+ return this.getTemplate(name, "component");
33
+ }
34
+ }
35
+ ResourceLoader.loaders = {};
36
+ ResourceLoader.defaultLoader = null;
37
+ ResourceLoader.cache = {};
@@ -0,0 +1,5 @@
1
+ import React from "react";
2
+ export declare const SectionProvider: (attr?: Record<string, any>) => {
3
+ getSection: (name: string) => React.ReactNode;
4
+ };
5
+ export declare const renderListDef: (list?: Record<string, any>[]) => React.ReactNode[];
@@ -0,0 +1,39 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { DynamicComponent } from "../../core/DynamicComponent";
3
+ import HPanel from "../../layouts/HPanel";
4
+ export const SectionProvider = (attr = {}) => {
5
+ const sections = {};
6
+ return {
7
+ getSection: (name) => {
8
+ if (!sections[name]) {
9
+ const sectionDef = attr[name];
10
+ if (sectionDef == null)
11
+ return null;
12
+ if (Array.isArray(sectionDef)) {
13
+ sections[name] = renderListDef(sectionDef);
14
+ }
15
+ else if (sectionDef != null && typeof sectionDef === "object") {
16
+ sections[name] = renderListDef([sectionDef]);
17
+ }
18
+ else {
19
+ sections[name] = [_jsx(DynamicComponent, { config: { component: sectionDef.toString(), attr: {} } })];
20
+ }
21
+ }
22
+ return sections[name];
23
+ },
24
+ };
25
+ };
26
+ export const renderListDef = (list = []) => {
27
+ const results = [];
28
+ for (const [index, it] of list.entries()) {
29
+ if (Array.isArray(it)) {
30
+ const subItems = renderListDef(it);
31
+ results.push(_jsx(HPanel, { gap: 8, children: subItems }, index));
32
+ }
33
+ else {
34
+ const item = it;
35
+ results.push(_jsx(DynamicComponent, { config: item }, index));
36
+ }
37
+ }
38
+ return results;
39
+ };
File without changes
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ // import dynamic from "next/dynamic";
3
+ // import React from "react";
4
+ // import { ResourceLoader } from "./ResourceLoader";
5
+ // const isDev = process.env.NODE_ENV === "development";
6
+ // console.log("dev mode, is", isDev);
7
+ // const packageLoaders: Record<string, () => Promise<any>> = {
8
+ // "@ramesesinc/platform-core": () => import("@ramesesinc/platform-core"),
9
+ // "@ramesesinc/client": () => import("@ramesesinc/client"),
10
+ // };
11
+ // const templateLoaders: Record<string, () => Promise<any>> = isDev
12
+ // ? { "@/templates": () => import("@/templates"), ...packageLoaders }
13
+ // : { ...packageLoaders, "@/templates": () => import("@/templates") };
14
+ // const componentLoaders: Record<string, () => Promise<any>> = isDev
15
+ // ? { "@/components": () => import("@/components"), ...packageLoaders }
16
+ // : { ...packageLoaders, "@/components": () => import("@/components") };
17
+ // /* ======================== Template Loader ======================== */
18
+ // const templateLoader = (name: string) =>
19
+ // dynamic(async () => {
20
+ // for (const loader of Object.values(templateLoaders)) {
21
+ // try {
22
+ // const mod = await loader();
23
+ // const Temp = (mod as Record<string, any>)[name];
24
+ // if (Temp) {
25
+ // let hasSelectionHandling = false;
26
+ // try {
27
+ // hasSelectionHandling = Temp.hasSelectionHandling ?? false;
28
+ // } catch (err) {}
29
+ // return { default: Temp, hasSelectionHandling };
30
+ // }
31
+ // } catch (err) {
32
+ // console.log("template loader Error", name, err);
33
+ // }
34
+ // }
35
+ // // fallback → template not found in any path
36
+ // return {
37
+ // default: () =>
38
+ // React.createElement(
39
+ // "div",
40
+ // {
41
+ // style: { color: "red", padding: "8px", border: "1px solid red" },
42
+ // },
43
+ // `Template "${name}" is not registered`,
44
+ // ),
45
+ // };
46
+ // });
47
+ // /* ======================== Component Loader ======================== */
48
+ // const componentLoader = (name: string) =>
49
+ // dynamic(async () => {
50
+ // for (const loader of Object.values(componentLoaders)) {
51
+ // try {
52
+ // const mod = await loader();
53
+ // const Comp = (mod as Record<string, any>)[name];
54
+ // if (Comp) {
55
+ // return { default: Comp };
56
+ // }
57
+ // } catch (err) {
58
+ // console.log("component loader Error", name, err);
59
+ // }
60
+ // }
61
+ // return {
62
+ // default: () =>
63
+ // React.createElement(
64
+ // "div",
65
+ // {
66
+ // style: { color: "red", padding: "8px", border: "1px solid red" },
67
+ // },
68
+ // `Component "${name}" is not registered`,
69
+ // ),
70
+ // };
71
+ // });
72
+ // // const actionLoader = (name: string) =>
73
+ // // dynamic(async () => {
74
+ // // try {
75
+ // // // 1️⃣ local component
76
+ // // const mod = await import(`@/actions`);
77
+ // // return { default: mod[name as keyof typeof mod] };
78
+ // // } catch {
79
+ // // try {
80
+ // // // 2️⃣ package component
81
+ // // const pkg = await import("@ramesesinc/react-ui");
82
+ // // const Comp = (pkg as Record<string, any>)[name];
83
+ // // if (!Comp) throw new Error();
84
+ // // return { default: Comp };
85
+ // // } catch {
86
+ // // // 3️⃣ neither found → throw
87
+ // // throw new Error(`Component "${name}" not found in local components or "@ramesesinc/react-ui"`);
88
+ // // }
89
+ // // }
90
+ // // });
91
+ // /* ---------------- Register loaders ---------------- */
92
+ // ResourceLoader.setDefaultLoader(templateLoader);
93
+ // ResourceLoader.registerLoader("component", componentLoader);
94
+ // // ResourceLoader.registerLoader("action", actionLoader);
95
+ // export default ResourceLoader;