@ramesesinc/platform-core 0.1.5 → 0.1.8

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 (91) hide show
  1. package/dist/components/action/LookupPage.js +9 -31
  2. package/dist/components/action/ViewPage.d.ts +2 -0
  3. package/dist/components/action/ViewPage.js +25 -31
  4. package/dist/components/common/UIComponent.js +4 -3
  5. package/dist/components/index.d.ts +1 -1
  6. package/dist/components/index.js +1 -1
  7. package/dist/components/table/DataList.js +2 -2
  8. package/dist/components/view/PopupView.d.ts +13 -0
  9. package/dist/components/view/PopupView.js +25 -20
  10. package/dist/core/DataContext.d.ts +7 -4
  11. package/dist/core/DataContext.js +16 -4
  12. package/dist/core/Page.js +25 -26
  13. package/dist/core/PageCache.js +16 -3
  14. package/dist/core/PageContext.js +90 -18
  15. package/dist/core/PageViewContext.d.ts +13 -1
  16. package/dist/core/PageViewContext.js +89 -5
  17. package/dist/core/PopupContext.d.ts +49 -0
  18. package/dist/core/PopupContext.js +380 -0
  19. package/dist/core/RowContext.js +1 -1
  20. package/dist/core/WindowContext.d.ts +15 -0
  21. package/dist/core/WindowContext.js +28 -0
  22. package/dist/core/index.d.ts +16 -0
  23. package/dist/index.css +25 -7
  24. package/dist/lib/utils/BeanUtils.js +7 -7
  25. package/dist/templates/DataListTemplate.js +7 -2
  26. package/dist/templates/ExplorerTemplate.js +1 -1
  27. package/package.json +5 -5
  28. package/dist/components/action/AlertMessage.tsx +0 -38
  29. package/dist/components/action/Button.tsx +0 -230
  30. package/dist/components/action/CancelEdit.tsx +0 -40
  31. package/dist/components/action/DeleteData.tsx +0 -73
  32. package/dist/components/action/Edit.tsx +0 -40
  33. package/dist/components/action/LookupPage.tsx +0 -113
  34. package/dist/components/action/ProcessRunner.tsx +0 -337
  35. package/dist/components/action/Refresh.tsx +0 -35
  36. package/dist/components/action/SaveData.tsx +0 -74
  37. package/dist/components/action/SelectData.tsx +0 -47
  38. package/dist/components/action/Undo.tsx +0 -50
  39. package/dist/components/action/UpdateContext.tsx +0 -40
  40. package/dist/components/action/UpdateData.tsx +0 -49
  41. package/dist/components/action/ViewBackPage.tsx +0 -46
  42. package/dist/components/action/ViewPage.tsx +0 -141
  43. package/dist/components/common/UIComponent.tsx +0 -86
  44. package/dist/components/common/UIInput.tsx +0 -49
  45. package/dist/components/common/UIMenu.tsx +0 -91
  46. package/dist/components/index.ts +0 -51
  47. package/dist/components/input/CodeEditor.tsx +0 -188
  48. package/dist/components/input/DateField.tsx +0 -274
  49. package/dist/components/input/DayPicker.tsx +0 -5
  50. package/dist/components/input/HtmlCode.tsx +0 -203
  51. package/dist/components/input/JsonCode.tsx +0 -205
  52. package/dist/components/input/MonthPicker.tsx +0 -5
  53. package/dist/components/input/ScriptCode.tsx +0 -195
  54. package/dist/components/input/Select.tsx +0 -78
  55. package/dist/components/input/SqlCode.tsx +0 -162
  56. package/dist/components/input/StringDecision.tsx +0 -64
  57. package/dist/components/input/Text.tsx +0 -57
  58. package/dist/components/input/YearPicker.tsx +0 -81
  59. package/dist/components/list/IconMenu.tsx +0 -115
  60. package/dist/components/list/TabMenu.tsx +0 -127
  61. package/dist/components/list/TreeMenu.tsx +0 -279
  62. package/dist/components/list/TxnTaskList.tsx +0 -198
  63. package/dist/components/output/Label.tsx +0 -50
  64. package/dist/components/table/DataList.tsx +0 -820
  65. package/dist/components/table/DataTable.tsx +0 -572
  66. package/dist/components/table/ListHandler.ts +0 -276
  67. package/dist/components/table/TableContext.tsx +0 -122
  68. package/dist/components/view/ComponentView.tsx +0 -102
  69. package/dist/components/view/FilterView.tsx +0 -21
  70. package/dist/components/view/HtmlForm.tsx +0 -176
  71. package/dist/components/view/HtmlView.tsx +0 -98
  72. package/dist/components/view/IFrameView.tsx +0 -48
  73. package/dist/components/view/Modal.tsx +0 -72
  74. package/dist/components/view/PageView.tsx +0 -131
  75. package/dist/components/view/PopupView.tsx +0 -160
  76. package/dist/components/view/RootView.tsx +0 -109
  77. package/dist/components/view/WizardView.tsx +0 -48
  78. package/dist/lib/layouts/BorderLayout.tsx +0 -31
  79. package/dist/lib/layouts/CardLayout.tsx +0 -73
  80. package/dist/lib/layouts/CenterLayout.tsx +0 -20
  81. package/dist/lib/layouts/GridLayout.tsx +0 -20
  82. package/dist/lib/layouts/HPanel.tsx +0 -31
  83. package/dist/lib/layouts/HorizontalLayout.tsx +0 -29
  84. package/dist/lib/layouts/MainLayout.tsx +0 -16
  85. package/dist/lib/layouts/PageLayout.tsx +0 -29
  86. package/dist/lib/layouts/VPanel.tsx +0 -27
  87. package/dist/lib/layouts/XLayout.tsx +0 -29
  88. package/dist/lib/layouts/YLayout.tsx +0 -29
  89. package/dist/lib/layouts/index.ts +0 -13
  90. /package/dist/components/action/{UpdateContext.d.ts → UpdateState.d.ts} +0 -0
  91. /package/dist/components/action/{UpdateContext.js → UpdateState.js} +0 -0
@@ -1,38 +0,0 @@
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;
@@ -1,230 +0,0 @@
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 };
@@ -1,40 +0,0 @@
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;
@@ -1,73 +0,0 @@
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;
@@ -1,40 +0,0 @@
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 EditProps extends AbstractComponent {
11
- children?: React.ReactNode;
12
- className?: string;
13
- title?: string;
14
- }
15
-
16
- /* ------------------------------------------------------------------ */
17
- /* Component */
18
-
19
- const Edit = (props: EditProps) => {
20
- const { children, className = "", title } = props ?? {};
21
- const pageContext = usePageContext();
22
-
23
- /* ---------------------- Events ---------------------- */
24
- const handleClick = async () => {
25
- try {
26
- await pageContext?.set("editable", true);
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 || "Edit"}
36
- </button>
37
- );
38
- };
39
-
40
- export default Edit;
@@ -1,113 +0,0 @@
1
- "use client";
2
-
3
- import React, { forwardRef, memo, useImperativeHandle, useRef, useState } from "react";
4
- import { usePageContext } from "../../core/PageContext";
5
- import { getValue, substituteExpr } from "../../lib/utils/BeanUtils";
6
- import { AbstractComponent } from "../../types/component";
7
- import PopupView from "../view/PopupView";
8
-
9
- /* ------------------------------------------------------------------ */
10
- /* Types */
11
-
12
- interface LookupPageProps extends AbstractComponent {
13
- url: string;
14
- name?: string;
15
- result?: Record<string, any>;
16
- children?: React.ReactNode;
17
- className?: string;
18
- title?: string;
19
- icon?: string;
20
- opt?: Record<string, any>;
21
- iconOnly?: boolean; // ✅ added
22
- popupClassName?: string;
23
- }
24
-
25
- /* ------------------------------------------------------------------ */
26
- /* Component */
27
-
28
- const LookupPage = (props: LookupPageProps) => {
29
- const { url, name = "", result = null, children, className = "", title, icon, opt = {}, popupClassName = "", iconOnly = false } = props ?? {};
30
- const { data = {} } = opt;
31
-
32
- const pageContext = usePageContext();
33
- const [showPopup, setShowPopup] = useState(false);
34
- const [popupUrl, setPopupUrl] = useState("");
35
- const slotRef = useRef<ChildrenSlotHandle>(null);
36
-
37
- const onClose = () => {
38
- slotRef.current?.update(null);
39
- };
40
-
41
- /* ---------------------- Events ---------------------- */
42
- const handleClick = () => {
43
- if (!url) return;
44
- //combine data if specified and pageContext all data if specified
45
- const surl = substituteExpr(url, { ...pageContext?.getAllData(), ...data });
46
- setPopupUrl(surl);
47
- setShowPopup(true);
48
-
49
- const handler = {
50
- onSelect: (itm: any) => {
51
- let resdata = itm;
52
- if (result != null) {
53
- resdata = getValue(result, itm);
54
- }
55
- alert("item selected " + JSON.stringify(resdata));
56
- if (name) {
57
- pageContext.set(name, resdata);
58
- }
59
- onClose();
60
- //pageContext.refresh();
61
- },
62
- };
63
- //eventHandler={handler}
64
- slotRef.current?.update(<PopupView url={surl} onClose={onClose} eventHandler={handler} />);
65
- };
66
-
67
- const handleClosePopup = () => {
68
- setShowPopup(false);
69
- };
70
-
71
- /* ---------------------- Render ---------------------- */
72
- return (
73
- <>
74
- {iconOnly ? (
75
- <span onClick={handleClick} className={`cursor-pointer ${className}`}>
76
- {icon}
77
- </span>
78
- ) : (
79
- <button onClick={handleClick} className={`px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors ${className}`}>
80
- {icon && <span className="dl-action-icon">{icon}</span>}
81
- {title || "View Page"}
82
- </button>
83
- )}
84
-
85
- <ChildrenSlot ref={slotRef} />
86
- </>
87
- );
88
- };
89
-
90
- export default LookupPage;
91
-
92
- type ChildrenSlotHandle = {
93
- update: (content: React.ReactNode) => void;
94
- };
95
-
96
- const ChildrenSlot = memo(
97
- forwardRef<ChildrenSlotHandle>((_, ref) => {
98
- const [content, setContent] = useState<React.ReactNode>(null);
99
-
100
- useImperativeHandle(
101
- ref,
102
- () => ({
103
- update: (content: React.ReactNode) => {
104
- // console.log("view page children slot", content);
105
- setContent(content);
106
- },
107
- }),
108
- [],
109
- );
110
-
111
- return <>{content == null ? null : content}</>;
112
- }),
113
- );