@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,8 @@
1
+ import { AbstractComponent } from "../../types/component";
2
+ interface AlertMessageProps extends AbstractComponent {
3
+ expr: string;
4
+ className?: string;
5
+ title?: string;
6
+ }
7
+ declare const AlertMessage: (props: AlertMessageProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default AlertMessage;
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import { render } from "../../lib/utils/ExprUtil";
5
+ /* ------------------------------------------------------------------ */
6
+ /* Component */
7
+ const AlertMessage = (props) => {
8
+ const { expr, className = "", title } = props !== null && props !== void 0 ? props : {};
9
+ const pageContext = usePageContext();
10
+ /* ---------------------- Events ---------------------- */
11
+ const handleClick = () => {
12
+ if (expr) {
13
+ alert(render(expr, pageContext === null || pageContext === void 0 ? void 0 : pageContext.getAllData()));
14
+ }
15
+ };
16
+ /* ---------------------- Render ---------------------- */
17
+ 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 || "Alert" }));
18
+ };
19
+ export default AlertMessage;
@@ -0,0 +1,38 @@
1
+ "use client";
2
+
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import { render } from "../../lib/utils/ExprUtil";
5
+ import { AbstractComponent } from "../../types/component";
6
+
7
+ /* ------------------------------------------------------------------ */
8
+ /* Types */
9
+
10
+ interface AlertMessageProps extends AbstractComponent {
11
+ expr: string;
12
+ className?: string;
13
+ title?: string;
14
+ }
15
+
16
+ /* ------------------------------------------------------------------ */
17
+ /* Component */
18
+
19
+ const AlertMessage = (props: AlertMessageProps) => {
20
+ const { expr, className = "", title } = props ?? {};
21
+ const pageContext = usePageContext();
22
+
23
+ /* ---------------------- Events ---------------------- */
24
+ const handleClick = () => {
25
+ if (expr) {
26
+ alert(render(expr, pageContext?.getAllData()));
27
+ }
28
+ };
29
+
30
+ /* ---------------------- Render ---------------------- */
31
+ return (
32
+ <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
33
+ {title || "Alert"}
34
+ </button>
35
+ );
36
+ };
37
+
38
+ export default AlertMessage;
@@ -0,0 +1,21 @@
1
+ import { UIButtonControl } from "@ramesesinc/client";
2
+ import { ReactNode } from "react";
3
+ interface BaseButtonProps extends UIButtonControl {
4
+ children?: ReactNode;
5
+ title?: string;
6
+ icon?: ReactNode;
7
+ iconOrientation?: "left" | "right" | "top" | "bottom";
8
+ loader?: ReactNode | (() => ReactNode);
9
+ loaderLabel?: string;
10
+ variant?: "primary" | "secondary" | "danger" | "text" | "contained" | "outlined";
11
+ radius?: "none" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full";
12
+ size?: "sm" | "md" | "lg";
13
+ type?: "button" | "submit";
14
+ isLoading?: boolean;
15
+ actionid?: string;
16
+ actionParams?: Record<string, any>;
17
+ }
18
+ declare const Button: (props: BaseButtonProps) => import("react/jsx-runtime").JSX.Element;
19
+ declare const Submit: (props: BaseButtonProps) => import("react/jsx-runtime").JSX.Element;
20
+ export default Button;
21
+ export { Button, Submit };
@@ -0,0 +1,139 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { getError, mergeCN } from "@ramesesinc/client";
3
+ import { useState } from "react";
4
+ import { useApp } from "../../core/AppContext";
5
+ import { usePageContext } from "../../core/PageContext";
6
+ const RADIUS_STYLES = {
7
+ none: "rounded-none",
8
+ md: "rounded-md",
9
+ lg: "rounded-lg",
10
+ xl: "rounded-xl",
11
+ "2xl": "rounded-2xl",
12
+ "3xl": "rounded-3xl",
13
+ full: "rounded-full",
14
+ };
15
+ const BaseButton = ({ binding, className = "", title, disabled = false, immediate = false, onClick, children, icon, iconOrientation = "left", loader, loaderLabel, variant = "text", radius = "md", size = "md", isLoading = false, actionid, actionParams, }) => {
16
+ const pageContext = usePageContext();
17
+ binding = pageContext.binding;
18
+ const { tenant, module } = useApp();
19
+ // --- Style Calculation ---
20
+ const baseStyles = "inline-flex items-center justify-center px-4 py-[4px] text-md font-medium shadow-sm transition-all duration-150 ease-in-out space-x-2";
21
+ const focusStyles = "focus:outline-none focus:ring-2 focus:ring-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2";
22
+ const variantStyles = {
23
+ primary: "border border-transparent bg-blue-500 text-blue-50 hover:bg-blue-600 focus:ring-blue-500",
24
+ secondary: "border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus:ring-indigo-300",
25
+ danger: "border border-transparent bg-red-600 text-white hover:bg-red-700 focus:ring-red-400",
26
+ text: "border border-transparent bg-transparent text-blue-600 hover:bg-blue-50 focus:ring-indigo-300",
27
+ contained: "border border-transparent bg-blue-500 text-blue-50 hover:bg-blue-600 focus:ring-blue-500",
28
+ outlined: "border bg-transparent border-blue-500 text-blue-600 hover:bg-blue-50 focus:ring-indigo-300",
29
+ };
30
+ const disabledStyles = "opacity-70 cursor-not-allowed";
31
+ const isVertical = iconOrientation === "top" || iconOrientation === "bottom";
32
+ const flexDirectionClass = isVertical ? "flex-col" : "flex-row";
33
+ // Gap is needed if an icon is present OR if no custom loader is provided (fallback uses a spinner).
34
+ const gapClass = icon || (isLoading && !loader) ? (isVertical ? "gap-1" : "gap-2") : "";
35
+ let roundingStyle = RADIUS_STYLES[radius || "md"];
36
+ if (roundingStyle == null) {
37
+ roundingStyle = RADIUS_STYLES["md"];
38
+ }
39
+ const finalClassNames = mergeCN(baseStyles, focusStyles, variantStyles[variant], flexDirectionClass, gapClass, roundingStyle, `${disabled || isLoading ? disabledStyles : ""}`, className !== null && className !== void 0 ? className : "");
40
+ const [internalLoading, setInternalLoading] = useState(false);
41
+ const loading = isLoading || internalLoading;
42
+ // --- Content Calculation ---
43
+ // This is the main logic block that determines what to display.
44
+ let content;
45
+ if (loading) {
46
+ // LOADING STATE
47
+ if (loader) {
48
+ // If a custom loader is provided, use it.
49
+ content = typeof loader === "function" ? loader() : loader;
50
+ }
51
+ else {
52
+ // Fallback loader: Spinner + original title
53
+ content = (_jsxs(_Fragment, { children: [_jsxs("svg", { className: "animate-spin h-5 w-5", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), _jsx("span", { children: loaderLabel !== null && loaderLabel !== void 0 ? loaderLabel : children })] }));
54
+ }
55
+ }
56
+ else {
57
+ // NORMAL STATE
58
+ content = (_jsxs(_Fragment, { children: [icon && (iconOrientation === "left" || iconOrientation === "top") && icon, _jsx("span", { children: title || children }), icon && (iconOrientation === "right" || iconOrientation === "bottom") && icon] }));
59
+ }
60
+ const handleClick = (event) => {
61
+ if (loading || disabled)
62
+ return;
63
+ try {
64
+ setInternalLoading(true);
65
+ if (!immediate && binding) {
66
+ const validationResult = binding.validate();
67
+ if (validationResult != null && validationResult !== "") {
68
+ return;
69
+ }
70
+ }
71
+ if (onClick != null) {
72
+ const result = onClick === null || onClick === void 0 ? void 0 : onClick(event);
73
+ if (result != null && typeof result.then === "function") {
74
+ result
75
+ .then(() => {
76
+ // successful execution
77
+ })
78
+ .catch((err) => {
79
+ const e = getError(err);
80
+ binding === null || binding === void 0 ? void 0 : binding.setError(e.message);
81
+ });
82
+ }
83
+ }
84
+ else if (actionid != null && actionid.trim() !== "") {
85
+ Promise.resolve()
86
+ .then(async () => {
87
+ // const actionFunc = await ResourceLoader.getAction(actionid || "");
88
+ // const opt = { tenant, module };
89
+ // const params = { ...actionParams, opt };
90
+ // resolveParams(params ?? {});
91
+ // const result = await actionFunc(params);
92
+ // console.log("result", result);
93
+ })
94
+ .catch((err) => {
95
+ console.log("action error", err);
96
+ const e = getError(err);
97
+ binding === null || binding === void 0 ? void 0 : binding.setError(e.message);
98
+ });
99
+ }
100
+ }
101
+ catch (err) {
102
+ console.log("err", err);
103
+ const e = getError(err);
104
+ binding === null || binding === void 0 ? void 0 : binding.setError(e.message);
105
+ }
106
+ finally {
107
+ setInternalLoading(false);
108
+ }
109
+ };
110
+ const resolveParams = (source) => {
111
+ Object.entries(source || {}).forEach(([key, value]) => {
112
+ if (value != null && typeof value === "string" && value.startsWith("{") && value.endsWith("}")) {
113
+ const name = value.slice(1, -1);
114
+ if (name === "data") {
115
+ source[key] = binding === null || binding === void 0 ? void 0 : binding.getData();
116
+ }
117
+ else {
118
+ source[key] = binding === null || binding === void 0 ? void 0 : binding.get(name);
119
+ }
120
+ }
121
+ else if (value != null && typeof value === "object") {
122
+ resolveParams(value);
123
+ }
124
+ });
125
+ };
126
+ return (_jsx("button", { type: "submit", onClick: handleClick, className: finalClassNames, disabled: disabled || loading, children: content }));
127
+ };
128
+ // Button
129
+ const Button = (props) => {
130
+ const { variant = "text" } = props !== null && props !== void 0 ? props : {};
131
+ return _jsx(BaseButton, Object.assign({}, props, { variant: variant, type: "button" }));
132
+ };
133
+ // Submit
134
+ const Submit = (props) => {
135
+ const { variant = "primary" } = props !== null && props !== void 0 ? props : {};
136
+ return _jsx(BaseButton, Object.assign({}, props, { variant: variant, type: "submit" }));
137
+ };
138
+ export default Button;
139
+ export { Button, Submit };
@@ -0,0 +1,230 @@
1
+ import { getError, mergeCN, UIButtonControl } from "@ramesesinc/client";
2
+ import React, { ReactNode, useState } from "react";
3
+ import { useApp } from "../../core/AppContext";
4
+ import { usePageContext } from "../../core/PageContext";
5
+
6
+ const RADIUS_STYLES = {
7
+ none: "rounded-none",
8
+ md: "rounded-md",
9
+ lg: "rounded-lg",
10
+ xl: "rounded-xl",
11
+ "2xl": "rounded-2xl",
12
+ "3xl": "rounded-3xl",
13
+ full: "rounded-full",
14
+ };
15
+
16
+ interface BaseButtonProps extends UIButtonControl {
17
+ children?: ReactNode;
18
+ title?: string;
19
+ icon?: ReactNode;
20
+ iconOrientation?: "left" | "right" | "top" | "bottom";
21
+
22
+ loader?: ReactNode | (() => ReactNode);
23
+ loaderLabel?: string;
24
+
25
+ variant?: "primary" | "secondary" | "danger" | "text" | "contained" | "outlined";
26
+
27
+ radius?: "none" | "md" | "lg" | "xl" | "2xl" | "3xl" | "full";
28
+
29
+ size?: "sm" | "md" | "lg";
30
+
31
+ type?: "button" | "submit";
32
+
33
+ isLoading?: boolean;
34
+
35
+ actionid?: string;
36
+ actionParams?: Record<string, any>;
37
+ }
38
+
39
+ const BaseButton = ({
40
+ binding,
41
+ className = "",
42
+ title,
43
+ disabled = false,
44
+ immediate = false,
45
+ onClick,
46
+
47
+ children,
48
+
49
+ icon,
50
+ iconOrientation = "left",
51
+ loader,
52
+ loaderLabel,
53
+
54
+ variant = "text",
55
+ radius = "md",
56
+ size = "md",
57
+
58
+ isLoading = false,
59
+ actionid,
60
+ actionParams,
61
+ }: BaseButtonProps) => {
62
+ const pageContext = usePageContext();
63
+ binding = pageContext.binding;
64
+ const { tenant, module } = useApp();
65
+
66
+ // --- Style Calculation ---
67
+ const baseStyles =
68
+ "inline-flex items-center justify-center px-4 py-[4px] text-md font-medium shadow-sm transition-all duration-150 ease-in-out space-x-2";
69
+ const focusStyles =
70
+ "focus:outline-none focus:ring-2 focus:ring-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2";
71
+
72
+ const variantStyles = {
73
+ primary: "border border-transparent bg-blue-500 text-blue-50 hover:bg-blue-600 focus:ring-blue-500",
74
+ secondary: "border border-gray-300 bg-white text-gray-700 hover:bg-gray-50 focus:ring-indigo-300",
75
+ danger: "border border-transparent bg-red-600 text-white hover:bg-red-700 focus:ring-red-400",
76
+
77
+ text: "border border-transparent bg-transparent text-blue-600 hover:bg-blue-50 focus:ring-indigo-300",
78
+ contained: "border border-transparent bg-blue-500 text-blue-50 hover:bg-blue-600 focus:ring-blue-500",
79
+ outlined: "border bg-transparent border-blue-500 text-blue-600 hover:bg-blue-50 focus:ring-indigo-300",
80
+ };
81
+
82
+ const disabledStyles = "opacity-70 cursor-not-allowed";
83
+ const isVertical = iconOrientation === "top" || iconOrientation === "bottom";
84
+ const flexDirectionClass = isVertical ? "flex-col" : "flex-row";
85
+
86
+ // Gap is needed if an icon is present OR if no custom loader is provided (fallback uses a spinner).
87
+ const gapClass = icon || (isLoading && !loader) ? (isVertical ? "gap-1" : "gap-2") : "";
88
+
89
+ let roundingStyle = RADIUS_STYLES[radius || "md"];
90
+ if (roundingStyle == null) {
91
+ roundingStyle = RADIUS_STYLES["md"];
92
+ }
93
+
94
+ const finalClassNames = mergeCN(
95
+ baseStyles,
96
+ focusStyles,
97
+ variantStyles[variant],
98
+ flexDirectionClass,
99
+ gapClass,
100
+ roundingStyle,
101
+ `${disabled || isLoading ? disabledStyles : ""}`,
102
+ className ?? "",
103
+ );
104
+
105
+ const [internalLoading, setInternalLoading] = useState(false);
106
+
107
+ const loading = isLoading || internalLoading;
108
+
109
+ // --- Content Calculation ---
110
+ // This is the main logic block that determines what to display.
111
+ let content: ReactNode;
112
+
113
+ if (loading) {
114
+ // LOADING STATE
115
+ if (loader) {
116
+ // If a custom loader is provided, use it.
117
+ content = typeof loader === "function" ? loader() : loader;
118
+ } else {
119
+ // Fallback loader: Spinner + original title
120
+ content = (
121
+ <>
122
+ <svg className="animate-spin h-5 w-5" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
123
+ <circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
124
+ <path
125
+ className="opacity-75"
126
+ fill="currentColor"
127
+ d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
128
+ ></path>
129
+ </svg>
130
+ <span>{loaderLabel ?? children}</span>
131
+ </>
132
+ );
133
+ }
134
+ } else {
135
+ // NORMAL STATE
136
+ content = (
137
+ <>
138
+ {icon && (iconOrientation === "left" || iconOrientation === "top") && icon}
139
+ <span>{title || children}</span>
140
+ {icon && (iconOrientation === "right" || iconOrientation === "bottom") && icon}
141
+ </>
142
+ );
143
+ }
144
+
145
+ const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {
146
+ if (loading || disabled) return;
147
+
148
+ try {
149
+ setInternalLoading(true);
150
+
151
+ if (!immediate && binding) {
152
+ const validationResult = binding.validate();
153
+ if (validationResult != null && validationResult !== "") {
154
+ return;
155
+ }
156
+ }
157
+
158
+ if (onClick != null) {
159
+ const result = onClick?.(event);
160
+ if (result != null && typeof result.then === "function") {
161
+ result
162
+ .then(() => {
163
+ // successful execution
164
+ })
165
+ .catch((err: any) => {
166
+ const e = getError(err);
167
+ binding?.setError(e.message);
168
+ });
169
+ }
170
+ } else if (actionid != null && actionid.trim() !== "") {
171
+ Promise.resolve()
172
+ .then(async () => {
173
+ // const actionFunc = await ResourceLoader.getAction(actionid || "");
174
+ // const opt = { tenant, module };
175
+ // const params = { ...actionParams, opt };
176
+ // resolveParams(params ?? {});
177
+ // const result = await actionFunc(params);
178
+ // console.log("result", result);
179
+ })
180
+ .catch((err: any) => {
181
+ console.log("action error", err);
182
+ const e = getError(err);
183
+ binding?.setError(e.message);
184
+ });
185
+ }
186
+ } catch (err) {
187
+ console.log("err", err);
188
+ const e = getError(err);
189
+ binding?.setError(e.message);
190
+ } finally {
191
+ setInternalLoading(false);
192
+ }
193
+ };
194
+
195
+ const resolveParams = (source: Record<string, any>) => {
196
+ Object.entries(source || {}).forEach(([key, value]) => {
197
+ if (value != null && typeof value === "string" && value.startsWith("{") && value.endsWith("}")) {
198
+ const name = value.slice(1, -1);
199
+ if (name === "data") {
200
+ source[key] = binding?.getData();
201
+ } else {
202
+ source[key] = binding?.get(name);
203
+ }
204
+ } else if (value != null && typeof value === "object") {
205
+ resolveParams(value);
206
+ }
207
+ });
208
+ };
209
+
210
+ return (
211
+ <button type="submit" onClick={handleClick} className={finalClassNames} disabled={disabled || loading}>
212
+ {content}
213
+ </button>
214
+ );
215
+ };
216
+
217
+ // Button
218
+ const Button = (props: BaseButtonProps) => {
219
+ const { variant = "text" } = props ?? {};
220
+ return <BaseButton {...props} variant={variant} type="button" />;
221
+ };
222
+
223
+ // Submit
224
+ const Submit = (props: BaseButtonProps) => {
225
+ const { variant = "primary" } = props ?? {};
226
+ return <BaseButton {...props} variant={variant} type="submit" />;
227
+ };
228
+
229
+ export default Button;
230
+ export { Button, Submit };
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { AbstractComponent } from "../../types/component";
3
+ interface CancelEditProps extends AbstractComponent {
4
+ children?: React.ReactNode;
5
+ className?: string;
6
+ title?: string;
7
+ }
8
+ declare const CancelEdit: (props: CancelEditProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default CancelEdit;
@@ -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 CancelEdit = (props) => {
7
+ const { children, className = "", title } = props !== null && props !== void 0 ? props : {};
8
+ const pageContext = usePageContext();
9
+ /* ---------------------- Events ---------------------- */
10
+ const handleClick = async () => {
11
+ try {
12
+ await (pageContext === null || pageContext === void 0 ? void 0 : pageContext.set("mode", "read"));
13
+ }
14
+ catch (err) {
15
+ alert(err.message);
16
+ }
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: children || title || "Cancel Edit" }));
20
+ };
21
+ export default CancelEdit;
@@ -0,0 +1,40 @@
1
+ "use client";
2
+
3
+ import React from "react";
4
+ import { usePageContext } from "../../core/PageContext";
5
+ import { AbstractComponent } from "../../types/component";
6
+
7
+ /* ------------------------------------------------------------------ */
8
+ /* Types */
9
+
10
+ interface CancelEditProps extends AbstractComponent {
11
+ children?: React.ReactNode;
12
+ className?: string;
13
+ title?: string;
14
+ }
15
+
16
+ /* ------------------------------------------------------------------ */
17
+ /* Component */
18
+
19
+ const CancelEdit = (props: CancelEditProps) => {
20
+ const { children, className = "", title } = props ?? {};
21
+ const pageContext = usePageContext();
22
+
23
+ /* ---------------------- Events ---------------------- */
24
+ const handleClick = async () => {
25
+ try {
26
+ await pageContext?.set("mode", "read");
27
+ } catch (err: any) {
28
+ alert(err.message);
29
+ }
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
+ {children || title || "Cancel Edit"}
36
+ </button>
37
+ );
38
+ };
39
+
40
+ export default CancelEdit;
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ import { AbstractComponent } from "../../types/component";
3
+ interface DeleteDataProps extends AbstractComponent {
4
+ api: string;
5
+ className?: string;
6
+ title?: string;
7
+ icon?: string | React.ReactNode;
8
+ opt?: Record<string, any>;
9
+ iconOnly?: boolean;
10
+ params: Record<string, any>;
11
+ }
12
+ declare const DeleteData: (props: DeleteDataProps) => import("react/jsx-runtime").JSX.Element;
13
+ export default DeleteData;
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import { usePageViewContext } from "../../core/PageViewContext";
5
+ import { useRowContext } from "../../core/RowContext";
6
+ import { getValue } from "../../lib/utils/BeanUtils";
7
+ import { getUrlPageParams } from "../../lib/utils/PageUtils";
8
+ /* ------------------------------------------------------------------ */
9
+ /* Component */
10
+ const DeleteData = (props) => {
11
+ const { api, className = "", title, icon, opt = {}, params, iconOnly = false } = props !== null && props !== void 0 ? props : {};
12
+ const { data = {} } = opt;
13
+ const rowContext = useRowContext();
14
+ const pageView = usePageViewContext();
15
+ const pageContext = usePageContext();
16
+ /* ---------------------- Events ---------------------- */
17
+ const handleClick = async () => {
18
+ var _a, _b;
19
+ try {
20
+ if (!api)
21
+ throw new Error("api not defined");
22
+ if (data) {
23
+ const allData = (_a = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getAllData()) !== null && _a !== void 0 ? _a : {};
24
+ const urlParams = getUrlPageParams();
25
+ const d = getValue(params, Object.assign(Object.assign(Object.assign({}, allData), urlParams === null || urlParams === void 0 ? void 0 : urlParams.params), data));
26
+ await (pageContext === null || pageContext === void 0 ? void 0 : pageContext.execService(api, d));
27
+ }
28
+ else {
29
+ const vdata = (_b = pageContext === null || pageContext === void 0 ? void 0 : pageContext.getData()) !== null && _b !== void 0 ? _b : {};
30
+ const urlParams = getUrlPageParams();
31
+ const d = getValue(params, Object.assign(Object.assign({}, urlParams === null || urlParams === void 0 ? void 0 : urlParams.params), vdata));
32
+ await (pageContext === null || pageContext === void 0 ? void 0 : pageContext.execService(api, vdata));
33
+ }
34
+ // pageContext?.refresh();
35
+ }
36
+ catch (err) {
37
+ alert(err.message);
38
+ }
39
+ };
40
+ /* ---------------------- Render ---------------------- */
41
+ return (_jsx(_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 || "Remove"] })) }));
42
+ };
43
+ export default DeleteData;
@@ -0,0 +1,73 @@
1
+ "use client";
2
+
3
+ import React from "react";
4
+ import { usePageContext } from "../../core/PageContext";
5
+ import { usePageViewContext } from "../../core/PageViewContext";
6
+ import { useRowContext } from "../../core/RowContext";
7
+ import { getValue } from "../../lib/utils/BeanUtils";
8
+ import { getUrlPageParams } from "../../lib/utils/PageUtils";
9
+ import { AbstractComponent } from "../../types/component";
10
+
11
+ /* ------------------------------------------------------------------ */
12
+ /* Types */
13
+
14
+ interface DeleteDataProps extends AbstractComponent {
15
+ api: string;
16
+ className?: string;
17
+ title?: string;
18
+ icon?: string | React.ReactNode;
19
+ opt?: Record<string, any>;
20
+ iconOnly?: boolean;
21
+ params: Record<string, any>;
22
+ }
23
+
24
+ /* ------------------------------------------------------------------ */
25
+ /* Component */
26
+
27
+ const DeleteData = (props: DeleteDataProps) => {
28
+ const { api, className = "", title, icon, opt = {}, params, iconOnly = false } = props ?? {};
29
+ const { data = {} } = opt;
30
+
31
+ const rowContext = useRowContext();
32
+ const pageView = usePageViewContext();
33
+ const pageContext = usePageContext();
34
+
35
+ /* ---------------------- Events ---------------------- */
36
+ const handleClick = async () => {
37
+ try {
38
+ if (!api) throw new Error("api not defined");
39
+ if (data) {
40
+ const allData = pageContext?.getAllData() ?? {};
41
+ const urlParams = getUrlPageParams();
42
+ const d = getValue(params, { ...allData, ...urlParams?.params, ...data });
43
+ await pageContext?.execService(api, d);
44
+ } else {
45
+ const vdata = pageContext?.getData() ?? {};
46
+ const urlParams = getUrlPageParams();
47
+ const d = getValue(params, { ...urlParams?.params, ...vdata });
48
+ await pageContext?.execService(api, vdata);
49
+ }
50
+ // pageContext?.refresh();
51
+ } catch (err: any) {
52
+ alert(err.message);
53
+ }
54
+ };
55
+
56
+ /* ---------------------- Render ---------------------- */
57
+ return (
58
+ <>
59
+ {iconOnly ? (
60
+ <span onClick={handleClick} className={`cursor-pointer ${className}`}>
61
+ {icon}
62
+ </span>
63
+ ) : (
64
+ <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
65
+ {icon && <span className="dl-action-icon">{icon}</span>}
66
+ {title || "Remove"}
67
+ </button>
68
+ )}
69
+ </>
70
+ );
71
+ };
72
+
73
+ export default DeleteData;