@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
package/dist/index.js ADDED
@@ -0,0 +1,69 @@
1
+ // ========================Core========================
2
+ export { AppProvider, useApp } from "./core/AppContext";
3
+ export { AuthProvider, useAuth } from "./core/AuthContext";
4
+ export { PageProvider, usePageContext } from "./core/PageContext";
5
+ export { getComponent } from "./core/ComponentCache";
6
+ export { getHtml } from "./core/HtmlCache";
7
+ export { getPage } from "./core/PageCache";
8
+ export { usePageRegistry } from "./core/PageRegistry";
9
+ export { StepHandler } from "./core/StepHandler";
10
+ export { PageHook, PageServerHook } from "./core/page-helper";
11
+ export { PageViewProvider, usePageViewContext } from "./core/PageViewContext";
12
+ export { default as DynamicIcon } from "./core/DynamicIcon";
13
+ export { default as Page } from "./core/Page";
14
+ export { default as RowContext, RowProvider, useRowContext } from "./core/RowContext";
15
+ export { default as UIDependHandler } from "./core/UIDependHandler";
16
+ export { useUrlParams } from "./hooks/useUrlParams";
17
+ // ========================Templates========================
18
+ export { default as BasicTemplate } from "./templates/BasicTemplate";
19
+ export { default as DataListTemplate } from "./templates/DataListTemplate";
20
+ export { default as ExplorerTemplate } from "./templates/ExplorerTemplate";
21
+ export { default as TxnFormTemplate } from "./templates/TxnFormTemplate";
22
+ export { default as WizardTemplate } from "./templates/WizardTemplate";
23
+ // ========================Layouts========================
24
+ export { default as BorderLayout } from "./layouts/BorderLayout";
25
+ export { default as CardLayout } from "./layouts/CardLayout";
26
+ export { default as CenterLayout } from "./layouts/CenterLayout";
27
+ export { default as GridLayout } from "./layouts/GridLayout";
28
+ export { default as HorizontalLayout } from "./layouts/HorizontalLayout";
29
+ export { default as HPanel } from "./layouts/HPanel";
30
+ export { default as MainLayout } from "./layouts/MainLayout";
31
+ export { default as PageLayout } from "./layouts/PageLayout";
32
+ export { default as VPanel } from "./layouts/VPanel";
33
+ export { default as XLayout } from "./layouts/XLayout";
34
+ export { default as YLayout } from "./layouts/YLayout";
35
+ //inputs
36
+ export { default as DateField } from "./components/input/DateField";
37
+ export { default as DayPicker } from "./components/input/DayPicker";
38
+ export { default as JsonCode } from "./components/input/JsonCode";
39
+ export { default as MonthPicker } from "./components/input/MonthPicker";
40
+ export { default as Select } from "./components/input/Select";
41
+ export { default as Text } from "./components/input/Text";
42
+ //conditions
43
+ export { default as StringDecision } from "./components/input/StringDecision";
44
+ //export { default as YearPicker } from "./input/YearPicker";
45
+ export { default as TabMenu } from "./components/list/TabMenu";
46
+ export { default as TreeMenu } from "./components/list/TreeMenu";
47
+ export { default as Label } from "./components/output/Label";
48
+ export { default as DataList } from "./components/table/DataList";
49
+ //views
50
+ export { default as ComponentView } from "./components/view/ComponentView";
51
+ export { default as FilterView } from "./components/view/FilterView";
52
+ export { default as HtmlView } from "./components/view/HtmlView";
53
+ export { default as IFrameView } from "./components/view/IFrameView";
54
+ export { default as RootView } from "./components/view/RootView";
55
+ export { default as WizardView } from "./components/view/WizardView";
56
+ //actions
57
+ export { default as AlertMessage } from "./components/action/AlertMessage";
58
+ export { default as Edit } from "./components/action/Edit";
59
+ export { default as SaveData } from "./components/action/SaveData";
60
+ export { default as UpdateContext } from "./components/action/UpdateContext";
61
+ export { default as ViewBackPage } from "./components/action/ViewBackPage";
62
+ export { default as ViewPage } from "./components/action/ViewPage";
63
+ export { default as PageView } from "./components/view/PageView";
64
+ //lists
65
+ export { default as IconMenu } from "./components/list/IconMenu";
66
+ export { default as TxnTaskList } from "./components/list/TxnTaskList";
67
+ export { handlePlatformRoute } from "./lib/PlatformRoute";
68
+ export { ResourceLoader } from "./lib/utils/ResourceLoader";
69
+ export { default as WebPlatform } from "./lib/WebPlatform";
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from "react";
2
+ type BorderLayoutProps = {
3
+ layoutid?: string;
4
+ className?: string;
5
+ vgap?: number;
6
+ hgap?: number;
7
+ north?: ReactNode;
8
+ south?: ReactNode;
9
+ east?: ReactNode;
10
+ west?: ReactNode;
11
+ children?: ReactNode;
12
+ };
13
+ declare const BorderLayout: ({ layoutid, className, vgap, hgap, north, south, east, west, children }: BorderLayoutProps) => import("react/jsx-runtime").JSX.Element;
14
+ export default BorderLayout;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import HorizontalLayout from "./HorizontalLayout";
3
+ import PageLayout from "./PageLayout";
4
+ const BorderLayout = ({ layoutid, className, vgap = 0, hgap = 0, north, south, east, west, children }) => {
5
+ const preferredLayoutId = (layoutid !== null && layoutid !== void 0 ? layoutid : "") ? layoutid : "borderlayout";
6
+ return (_jsx(PageLayout, { layoutid: `${preferredLayoutId}`, className: className, gap: vgap, header: north, footer: south, children: _jsx(HorizontalLayout, { layoutid: `${preferredLayoutId}-center`, gap: hgap, left: west, right: east, children: children }) }));
7
+ };
8
+ export default BorderLayout;
@@ -0,0 +1,27 @@
1
+ import { ReactNode } from "react";
2
+ export interface CardProps {
3
+ name: string;
4
+ element: ReactNode;
5
+ }
6
+ /**
7
+ * Card is a declarative wrapper for CardLayout.
8
+ * It does not render UI by itself, only provides data (name + element).
9
+ */
10
+ export declare function Card(_props: CardProps): null;
11
+ type CardLayoutRefModel = {
12
+ getName: () => string | null;
13
+ getElement: () => ReactNode;
14
+ validate: () => void;
15
+ };
16
+ export type CardLayoutRef = {
17
+ current?: CardLayoutRefModel;
18
+ };
19
+ type CardLayoutProps = {
20
+ ref?: CardLayoutRef;
21
+ layoutid?: string;
22
+ className?: string;
23
+ children: ReactNode;
24
+ value: string;
25
+ };
26
+ declare const CardLayout: ({ ref, layoutid, className, children, value }: CardLayoutProps) => import("react/jsx-runtime").JSX.Element;
27
+ export default CardLayout;
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { Suspense } from "react";
3
+ /**
4
+ * Card is a declarative wrapper for CardLayout.
5
+ * It does not render UI by itself, only provides data (name + element).
6
+ */
7
+ export function Card(_props) {
8
+ return null;
9
+ }
10
+ const CardLayout = ({ ref, layoutid, className, children, value = "default" }) => {
11
+ const preferredLayoutId = (layoutid !== null && layoutid !== void 0 ? layoutid : "") ? layoutid : "cardlayout";
12
+ // Extract only <Card> children
13
+ const cards = React.Children.toArray(children).filter((child) => React.isValidElement(child) && child.type === Card);
14
+ const activeCard = cards.find((c) => c.props.name === value);
15
+ if (ref != null) {
16
+ ref.current = {
17
+ getName: () => (activeCard ? activeCard.props.name : null),
18
+ getElement: () => (activeCard ? activeCard.props.element : null),
19
+ validate: () => {
20
+ if (activeCard == null || activeCard.props.element == null) {
21
+ return;
22
+ }
23
+ const elem = activeCard.props.element;
24
+ const props = elem.props;
25
+ if (props.binding != null) {
26
+ const result = props.binding.validate();
27
+ if (result != null) {
28
+ throw Error(result);
29
+ }
30
+ }
31
+ },
32
+ };
33
+ }
34
+ return (_jsx("div", { className: `${preferredLayoutId}-container ${className !== null && className !== void 0 ? className : ""} flex flex-col h-full`, children: _jsx(Suspense, { fallback: _jsx("div", { children: "Loading..." }), children: activeCard ? activeCard.props.element : null }) }));
35
+ };
36
+ export default CardLayout;
@@ -0,0 +1,8 @@
1
+ import { ReactNode } from "react";
2
+ type CenterLayoutProps = {
3
+ layoutid?: string;
4
+ className?: string;
5
+ children?: ReactNode;
6
+ };
7
+ declare const CenterLayout: ({ layoutid, className, children }: CenterLayoutProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default CenterLayout;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const CenterLayout = ({ layoutid, className, children }) => {
3
+ const preferredLayoutId = ((layoutid !== null && layoutid !== void 0 ? layoutid : '') ? layoutid : 'pagelayout');
4
+ return (_jsx("div", { className: `${preferredLayoutId}-container ${className !== null && className !== void 0 ? className : ''} flex items-center justify-center w-full h-full`, children: children }));
5
+ };
6
+ export default CenterLayout;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from "react";
2
+ type GridLayoutProps = {
3
+ className?: string;
4
+ cols?: number;
5
+ gap?: number;
6
+ children?: ReactNode;
7
+ };
8
+ declare const GridLayout: ({ className, cols, gap, children }: GridLayoutProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default GridLayout;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const GridLayout = ({ className, cols = 3, gap = 1, children }) => {
3
+ return (_jsx("div", { className: `${className !== null && className !== void 0 ? className : ''} grid gap-${gap}`, style: { gridTemplateColumns: `repeat(${cols}, 1fr)` }, children: children }));
4
+ };
5
+ export default GridLayout;
@@ -0,0 +1,11 @@
1
+ import React, { CSSProperties, ReactNode } from "react";
2
+ interface HPanelProps {
3
+ children?: ReactNode;
4
+ gap?: number | string;
5
+ style?: CSSProperties;
6
+ className?: string;
7
+ alignItems?: CSSProperties["alignItems"];
8
+ justifyContent?: CSSProperties["justifyContent"];
9
+ }
10
+ declare const HPanel: React.FC<HPanelProps>;
11
+ export default HPanel;
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ const HPanel = ({ children, gap = 0, style, className, alignItems = "center", justifyContent = "flex-start" }) => {
4
+ const panelStyle = Object.assign({ display: "flex", flexDirection: "row", gap: gap, alignItems,
5
+ justifyContent }, style);
6
+ return (_jsx("div", { style: panelStyle, className: className, children: children }));
7
+ };
8
+ export default HPanel;
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ type HorizontalLayoutProps = {
3
+ layoutid?: string;
4
+ className?: string;
5
+ gap?: number;
6
+ left?: ReactNode;
7
+ right?: ReactNode;
8
+ children?: ReactNode;
9
+ };
10
+ declare const HorizontalLayout: ({ layoutid, className, gap, left, right, children }: HorizontalLayoutProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default HorizontalLayout;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const HorizontalLayout = ({ layoutid, className, gap = 0, left, right, children }) => {
3
+ const preferredLayoutId = ((layoutid !== null && layoutid !== void 0 ? layoutid : '') ? layoutid : 'horizontallayout');
4
+ return (_jsxs("div", { className: `${preferredLayoutId}-container ${className !== null && className !== void 0 ? className : ""} flex flex-row h-full gap-${gap}`, children: [left, _jsx("div", { className: "flex-1", children: children }), right] }));
5
+ };
6
+ export default HorizontalLayout;
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ interface MainLayoutProps {
3
+ children: ReactNode;
4
+ }
5
+ export declare const MainLayout: ({ children }: MainLayoutProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default MainLayout;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ export const MainLayout = ({ children }) => {
3
+ return (_jsx("div", { className: "min-h-screen flex flex-col", children: _jsx("main", { className: "flex-1", children: children }) }));
4
+ };
5
+ export default MainLayout;
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from "react";
2
+ type PageLayoutProps = {
3
+ layoutid?: string;
4
+ className?: string;
5
+ gap?: number;
6
+ header?: ReactNode;
7
+ footer?: ReactNode;
8
+ children?: ReactNode;
9
+ };
10
+ declare const PageLayout: ({ layoutid, className, gap, header, footer, children }: PageLayoutProps) => import("react/jsx-runtime").JSX.Element;
11
+ export default PageLayout;
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ const PageLayout = ({ layoutid, className, gap = 0, header, footer, children }) => {
3
+ const preferredLayoutId = ((layoutid !== null && layoutid !== void 0 ? layoutid : '') ? layoutid : 'pagelayout');
4
+ return (_jsxs("div", { className: `${preferredLayoutId}-container ${className !== null && className !== void 0 ? className : ""} flex flex-col h-full gap-${gap}`, children: [header, _jsx("div", { className: "flex-1", children: children }), footer] }));
5
+ };
6
+ export default PageLayout;
@@ -0,0 +1,9 @@
1
+ import React, { CSSProperties, ReactNode } from "react";
2
+ interface VPanelProps {
3
+ children?: ReactNode;
4
+ gap?: number | string;
5
+ style?: CSSProperties;
6
+ className?: string;
7
+ }
8
+ declare const VPanel: React.FC<VPanelProps>;
9
+ export default VPanel;
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ const VPanel = ({ children, gap = 0, style, className }) => {
4
+ const panelStyle = Object.assign({ display: "flex", flexDirection: "column", gap: gap }, style);
5
+ return (_jsx("div", { style: panelStyle, className: className, children: children }));
6
+ };
7
+ export default VPanel;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ type XLayoutAlignment = "left" | "center" | "right";
3
+ type XLayoutProps = {
4
+ className?: string;
5
+ gap?: number;
6
+ align?: XLayoutAlignment;
7
+ children?: React.ReactNode;
8
+ };
9
+ declare const XLayout: React.FC<XLayoutProps>;
10
+ export default XLayout;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const XLayout = ({ className, gap = 2, align = "left", children, }) => {
3
+ let justifyClass = "justify-start"; // default = left
4
+ if (align === "center")
5
+ justifyClass = "justify-center";
6
+ if (align === "right")
7
+ justifyClass = "justify-end";
8
+ return (_jsx("div", { className: `${className !== null && className !== void 0 ? className : ""} flex flex-row gap-${gap} ${justifyClass}`.trim(), children: children }));
9
+ };
10
+ export default XLayout;
@@ -0,0 +1,10 @@
1
+ import React from "react";
2
+ type YLayoutAlignment = "top" | "center" | "bottom";
3
+ type YLayoutProps = {
4
+ className?: string;
5
+ gap?: number;
6
+ align?: YLayoutAlignment;
7
+ children?: React.ReactNode;
8
+ };
9
+ declare const YLayout: React.FC<YLayoutProps>;
10
+ export default YLayout;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const YLayout = ({ className, gap = 2, align = "top", children, }) => {
3
+ let justifyClass = "justify-start"; // default = left
4
+ if (align === "center")
5
+ justifyClass = "justify-center";
6
+ if (align === "bottom")
7
+ justifyClass = "justify-end";
8
+ return (_jsx("div", { className: `${className !== null && className !== void 0 ? className : ""} flex flex-col gap-${gap} ${justifyClass}`.trim(), children: children }));
9
+ };
10
+ export default YLayout;
@@ -0,0 +1,5 @@
1
+ import { NextRequest, NextResponse } from "next/server";
2
+ export declare const config: {
3
+ matcher: string[];
4
+ };
5
+ export declare function handlePlatformRoute(request: NextRequest): Promise<NextResponse<unknown>>;
@@ -0,0 +1,288 @@
1
+ import { localAPI } from "@ramesesinc/lib/local-api";
2
+ import * as mgmt from "@ramesesinc/lib/mgmt-api";
3
+ import * as server from "@ramesesinc/lib/server-actions";
4
+ import { NextResponse } from "next/server";
5
+ import WebPlatform from "./WebPlatform";
6
+ export const config = {
7
+ matcher: [
8
+ // Match everything EXCEPT:
9
+ // - Next.js internals (/_next/*)
10
+ // - Static assets in public (/assets/*, /_res/*, /favicon.ico)
11
+ "/((?!_next|assets|_res|favicon.ico).*)",
12
+ ],
13
+ };
14
+ export async function handlePlatformRoute(request) {
15
+ var _a;
16
+ const { pathname, origin } = request.nextUrl;
17
+ if (!pathname) {
18
+ return NextResponse.next();
19
+ }
20
+ // const hostHeader = request.headers.get("host") || "";
21
+ // const [ hostName ] = hostHeader.split(':');
22
+ // const [ subHostName ] = hostName.split('.');
23
+ // const tenantID = String(subHostName);
24
+ const s_pathname = resolvePathName(pathname);
25
+ const [prefix, xpathInfo] = resolvePathInfo(WebPlatform.CONTEXT_PATH, s_pathname);
26
+ const getPlatformInfo = async () => {
27
+ try {
28
+ const info = await mgmt.mgmtAPI.getPlatform();
29
+ return info;
30
+ }
31
+ catch (err) {
32
+ console.error(err);
33
+ return {};
34
+ }
35
+ };
36
+ const platformInfo = await getPlatformInfo();
37
+ const multi_tenant = String(platformInfo.multi_tenant) === "false" ? false : true;
38
+ const tenant_name = (_a = platformInfo.tenant_name) !== null && _a !== void 0 ? _a : "";
39
+ const prettifyPathInfo = (path) => {
40
+ if (!multi_tenant && tenant_name === "") {
41
+ return NextResponse.json({ error: "tenant_name must be provided" }, { status: 405 });
42
+ }
43
+ if (path === "/") {
44
+ if (!multi_tenant) {
45
+ return prettifyPathInfo(`/${tenant_name}`);
46
+ }
47
+ }
48
+ if (path.startsWith("/login")) {
49
+ if (!multi_tenant) {
50
+ return prettifyPathInfo(`/${tenant_name}${path}`);
51
+ }
52
+ }
53
+ return path;
54
+ };
55
+ const n_pathInfo = prettifyPathInfo(xpathInfo);
56
+ if (typeof n_pathInfo === "object")
57
+ return n_pathInfo;
58
+ const pathInfo = n_pathInfo.replace(/\/+/g, "/");
59
+ const is_module = WebPlatform.isModulePath(prefix);
60
+ const is_sysmgmt = WebPlatform.isSysMgmtPath(prefix);
61
+ const [, groupID, moduleID] = pathInfo.split("/");
62
+ // console.log({ prefix, pathInfo, groupID, moduleID });
63
+ const hostConf = new HostConfig();
64
+ if (isReservedPath(pathInfo)) {
65
+ //console.log({ pathInfo, groupID });
66
+ if (pathInfo === "/api/localapi" || pathInfo.startsWith("/api/localapi/")) {
67
+ return handleLocalAPI(request, pathInfo);
68
+ }
69
+ if (pathInfo === "/api" || pathInfo.startsWith("/api/")) {
70
+ return NextResponse.next();
71
+ }
72
+ if (groupID === "localapi") {
73
+ return handleLocalAPI(request, pathInfo);
74
+ }
75
+ if (is_sysmgmt) {
76
+ if (groupID === "_res") {
77
+ const { status, error, host } = await hostConf.findConnectionInfo(`${tenant_name}`, "sysmgmt");
78
+ if (error) {
79
+ return NextResponse.json({ error }, { status });
80
+ }
81
+ const newPath = resolvePathName(`${prefix}${pathInfo}`);
82
+ const target = new URL(newPath, host);
83
+ if (request.nextUrl.search) {
84
+ target.search = request.nextUrl.search;
85
+ }
86
+ return NextResponse.rewrite(target);
87
+ }
88
+ }
89
+ else if (is_module && moduleID) {
90
+ const { status, error, weburi } = await hostConf.findModuleInfo(groupID, moduleID);
91
+ if (error) {
92
+ return NextResponse.json({ error }, { status });
93
+ }
94
+ const newPath = resolvePathName(`${prefix}${pathInfo}`);
95
+ const target = new URL(newPath, weburi);
96
+ if (request.nextUrl.search) {
97
+ target.search = request.nextUrl.search;
98
+ }
99
+ return NextResponse.rewrite(target);
100
+ }
101
+ return NextResponse.next();
102
+ }
103
+ let [, tenantID] = pathInfo.split("/");
104
+ if ((tenantID !== null && tenantID !== void 0 ? tenantID : "") === "")
105
+ tenantID = tenant_name;
106
+ if (!tenantID) {
107
+ return NextResponse.json({ error: "path should start with /your-tenant-name" }, { status: 500 });
108
+ }
109
+ if (!hasSession(request)) {
110
+ const newPath = resolvePathToRedirect(false, prefix, "/login", tenantID);
111
+ if (newPath === s_pathname) {
112
+ const url = request.nextUrl.clone();
113
+ url.pathname = newPath;
114
+ return NextResponse.rewrite(url);
115
+ }
116
+ else {
117
+ const url = new URL(newPath, origin);
118
+ // url.searchParams.set("redirect", s_pathname + (request.nextUrl.search ?? ''));
119
+ return NextResponse.redirect(url);
120
+ }
121
+ }
122
+ const newPath = resolvePathToRedirect(true, prefix, pathInfo, tenantID);
123
+ let target = request.nextUrl.clone();
124
+ target.pathname = newPath;
125
+ if (WebPlatform.isModulePath(newPath)) {
126
+ const { status, error, weburi } = await hostConf.findModuleInfo(tenantID, String(moduleID));
127
+ if (error) {
128
+ return NextResponse.json({ error }, { status });
129
+ }
130
+ target = new URL(newPath, weburi);
131
+ target.pathname = newPath;
132
+ }
133
+ else if (is_sysmgmt) {
134
+ const { status, error, host } = await hostConf.findConnectionInfo(tenantID, "sysmgmt");
135
+ if (error) {
136
+ return NextResponse.json({ error }, { status });
137
+ }
138
+ target = new URL(newPath, host);
139
+ target.pathname = newPath;
140
+ }
141
+ if (request.nextUrl.search) {
142
+ target.search = request.nextUrl.search;
143
+ }
144
+ if (newPath === s_pathname) {
145
+ return NextResponse.rewrite(target);
146
+ }
147
+ else {
148
+ return NextResponse.redirect(target);
149
+ }
150
+ }
151
+ function resolvePathName(pathname) {
152
+ if (pathname.startsWith("//")) {
153
+ return resolvePathName(pathname.substring(1));
154
+ }
155
+ else if (pathname.startsWith("/")) {
156
+ return pathname;
157
+ }
158
+ else {
159
+ return `/${pathname}`;
160
+ }
161
+ }
162
+ function resolvePathInfo(prefix, pathname) {
163
+ // pathname-pattern: /:prefix/:path+
164
+ let s_prefix = resolvePathName(prefix);
165
+ let s_pathname = resolvePathName(pathname);
166
+ if (!s_pathname.startsWith(s_prefix)) {
167
+ s_pathname = `${s_prefix}${s_pathname}`;
168
+ }
169
+ if (WebPlatform.isModulePath(s_pathname)) {
170
+ s_prefix = "/modules";
171
+ }
172
+ else if (s_pathname.startsWith("/sysmgmt/")) {
173
+ s_prefix = "/sysmgmt";
174
+ }
175
+ const s_path = s_pathname.substring(s_prefix.length);
176
+ const result = [s_prefix, s_path];
177
+ if (!s_path.startsWith("/")) {
178
+ result[1] = `/${s_path}`;
179
+ }
180
+ return result;
181
+ }
182
+ function isReservedPath(pathInfo) {
183
+ const s_pathInfo = resolvePathName(pathInfo);
184
+ const paths = [
185
+ "/_next/", // NextJS internals
186
+ "/_res/", // public /_res/:path+
187
+ "/assets/", // public /assets/:path+
188
+ "/favicon.ico", // public /favicon.ico
189
+ "/localapi/", // public API but with key
190
+ "/api/", // public API
191
+ ];
192
+ return paths.some((path) => s_pathInfo.startsWith(path));
193
+ }
194
+ function handleLocalAPI(request, pathInfo) {
195
+ let reqApiKey = null;
196
+ for (const [key, value] of request.headers) {
197
+ if (key === "x-local_api_key" || key === "X-LOCAL_API_KEY") {
198
+ reqApiKey = value;
199
+ }
200
+ }
201
+ // pathInfo-pattern: /localapi/:path+
202
+ const pass = localAPI.isPermitted(request, reqApiKey);
203
+ if (pass) {
204
+ // verified
205
+ const newUrl = request.nextUrl.clone();
206
+ newUrl.pathname = resolvePathName(pathInfo);
207
+ return NextResponse.rewrite(newUrl);
208
+ }
209
+ return NextResponse.json({ error: "Unauthorized - Invalid Local API Key" }, { status: 401 });
210
+ }
211
+ function hasSession(request) {
212
+ var _a;
213
+ const token = (_a = request.cookies.get("session")) === null || _a === void 0 ? void 0 : _a.value;
214
+ return Boolean(token);
215
+ }
216
+ function resolvePathToRedirect(has_session, prefix, pathInfo, groupID) {
217
+ const s_pathInfo = resolvePathName(pathInfo !== null && pathInfo !== void 0 ? pathInfo : "");
218
+ if (s_pathInfo === "" || s_pathInfo === "/") {
219
+ return resolvePathToRedirect(has_session, prefix, `/login`, groupID);
220
+ }
221
+ if (has_session) {
222
+ if (s_pathInfo.endsWith("/login")) {
223
+ const tenantID = groupID ? groupID : WebPlatform.TENANT_NAME;
224
+ return resolvePathToRedirect(has_session, prefix, `/${tenantID}`, tenantID);
225
+ }
226
+ }
227
+ else {
228
+ if (s_pathInfo === "/login") {
229
+ const tenantID = groupID ? groupID : WebPlatform.TENANT_NAME;
230
+ return resolvePathToRedirect(has_session, prefix, `/${tenantID}${s_pathInfo}`, tenantID);
231
+ }
232
+ }
233
+ return resolvePathName(`${prefix}${s_pathInfo}`);
234
+ }
235
+ class HostConfig {
236
+ constructor() {
237
+ this.conns = {};
238
+ this.modules = {};
239
+ }
240
+ async findConnectionInfo(tenantID, connID) {
241
+ try {
242
+ const skey = `${tenantID}-${connID}`;
243
+ const info = this.conns[skey];
244
+ if (info)
245
+ return info;
246
+ const uc = mgmt.useConnection({ tenant: tenantID });
247
+ const result = await uc.get(connID);
248
+ const { _id, host } = result !== null && result !== void 0 ? result : {};
249
+ if (_id == null) {
250
+ return { status: 400, error: `Bad Request - ${connID} connection not found` };
251
+ }
252
+ if (host == null || host === "") {
253
+ return { status: 400, error: `Bad Request - ${connID} connection must have a host configuration` };
254
+ }
255
+ this.conns[skey] = result;
256
+ return result;
257
+ }
258
+ catch (err) {
259
+ const e = server.getError(err);
260
+ console.log("[err] findConnectionInfo =>", e);
261
+ return { status: 500, error: `Internal Server Error - ${e.message}` };
262
+ }
263
+ }
264
+ async findModuleInfo(tenantID, moduleID) {
265
+ try {
266
+ const skey = `${tenantID}-${moduleID}`;
267
+ const info = this.modules[skey];
268
+ if (info)
269
+ return info;
270
+ const um = mgmt.useModule({ tenant: tenantID });
271
+ const result = await um.post(moduleID, { projection: { weburi: 1 } });
272
+ const { _id, weburi } = result !== null && result !== void 0 ? result : {};
273
+ if (_id == null) {
274
+ return { status: 400, error: `Bad Request - ${moduleID} module not found` };
275
+ }
276
+ if (weburi == null || weburi === "") {
277
+ return { status: 400, error: `Bad Request - ${moduleID} module must have a weburi` };
278
+ }
279
+ this.modules[skey] = result;
280
+ return result;
281
+ }
282
+ catch (err) {
283
+ const e = server.getError(err);
284
+ console.error("[err] findModuleInfo =>", e);
285
+ return { status: 500, error: `Internal Server Error - ${e.message}` };
286
+ }
287
+ }
288
+ }
@@ -0,0 +1,13 @@
1
+ export declare const WebPlatform: {
2
+ CONTEXT_PATH: string;
3
+ TENANT_NAME: string;
4
+ MODULE_NAME: string;
5
+ MGMT_SERVER_URI: string | null;
6
+ env: (name: string, defaultValue?: any) => any;
7
+ getResourcePath: (pathname: string) => string;
8
+ resolvePathName: (pathname: string) => string;
9
+ isModulePath: (pathname: string) => boolean;
10
+ isSysMgmtPath: (pathname: string) => boolean;
11
+ getSegments: (pathname: string) => string;
12
+ };
13
+ export default WebPlatform;