@ramesesinc/platform-core 0.1.6 → 0.1.9

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 (90) 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 +3 -0
  6. package/dist/components/index.js +1 -0
  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 +7 -7
  14. package/dist/core/PageContext.js +17 -7
  15. package/dist/core/PageViewContext.d.ts +13 -1
  16. package/dist/core/PageViewContext.js +75 -2
  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 +17 -0
  23. package/dist/core/index.js +1 -0
  24. package/dist/index.css +25 -7
  25. package/dist/lib/utils/BeanUtils.js +7 -7
  26. package/dist/templates/DataListTemplate.js +7 -2
  27. package/dist/templates/ExplorerTemplate.js +1 -1
  28. package/package.json +5 -5
  29. package/dist/components/action/AlertMessage.tsx +0 -38
  30. package/dist/components/action/Button.tsx +0 -230
  31. package/dist/components/action/CancelEdit.tsx +0 -40
  32. package/dist/components/action/DeleteData.tsx +0 -73
  33. package/dist/components/action/Edit.tsx +0 -40
  34. package/dist/components/action/LookupPage.tsx +0 -113
  35. package/dist/components/action/ProcessRunner.tsx +0 -337
  36. package/dist/components/action/Refresh.tsx +0 -35
  37. package/dist/components/action/SaveData.tsx +0 -74
  38. package/dist/components/action/SelectData.tsx +0 -47
  39. package/dist/components/action/Undo.tsx +0 -50
  40. package/dist/components/action/UpdateData.tsx +0 -49
  41. package/dist/components/action/UpdateState.tsx +0 -40
  42. package/dist/components/action/ViewBackPage.tsx +0 -46
  43. package/dist/components/action/ViewPage.tsx +0 -141
  44. package/dist/components/common/UIComponent.tsx +0 -86
  45. package/dist/components/common/UIInput.tsx +0 -49
  46. package/dist/components/common/UIMenu.tsx +0 -91
  47. package/dist/components/index.ts +0 -51
  48. package/dist/components/input/CodeEditor.tsx +0 -188
  49. package/dist/components/input/DateField.tsx +0 -274
  50. package/dist/components/input/DayPicker.tsx +0 -5
  51. package/dist/components/input/HtmlCode.tsx +0 -203
  52. package/dist/components/input/JsonCode.tsx +0 -205
  53. package/dist/components/input/MonthPicker.tsx +0 -5
  54. package/dist/components/input/ScriptCode.tsx +0 -195
  55. package/dist/components/input/Select.tsx +0 -78
  56. package/dist/components/input/SqlCode.tsx +0 -162
  57. package/dist/components/input/StringDecision.tsx +0 -64
  58. package/dist/components/input/Text.tsx +0 -57
  59. package/dist/components/input/YearPicker.tsx +0 -81
  60. package/dist/components/list/IconMenu.tsx +0 -115
  61. package/dist/components/list/TabMenu.tsx +0 -127
  62. package/dist/components/list/TreeMenu.tsx +0 -279
  63. package/dist/components/list/TxnTaskList.tsx +0 -198
  64. package/dist/components/output/Label.tsx +0 -50
  65. package/dist/components/table/DataList.tsx +0 -820
  66. package/dist/components/table/DataTable.tsx +0 -572
  67. package/dist/components/table/ListHandler.ts +0 -276
  68. package/dist/components/table/TableContext.tsx +0 -122
  69. package/dist/components/view/ComponentView.tsx +0 -102
  70. package/dist/components/view/FilterView.tsx +0 -21
  71. package/dist/components/view/HtmlForm.tsx +0 -176
  72. package/dist/components/view/HtmlView.tsx +0 -98
  73. package/dist/components/view/IFrameView.tsx +0 -48
  74. package/dist/components/view/Modal.tsx +0 -72
  75. package/dist/components/view/PageView.tsx +0 -131
  76. package/dist/components/view/PopupView.tsx +0 -160
  77. package/dist/components/view/RootView.tsx +0 -109
  78. package/dist/components/view/WizardView.tsx +0 -48
  79. package/dist/lib/layouts/BorderLayout.tsx +0 -31
  80. package/dist/lib/layouts/CardLayout.tsx +0 -73
  81. package/dist/lib/layouts/CenterLayout.tsx +0 -20
  82. package/dist/lib/layouts/GridLayout.tsx +0 -20
  83. package/dist/lib/layouts/HPanel.tsx +0 -31
  84. package/dist/lib/layouts/HorizontalLayout.tsx +0 -29
  85. package/dist/lib/layouts/MainLayout.tsx +0 -16
  86. package/dist/lib/layouts/PageLayout.tsx +0 -29
  87. package/dist/lib/layouts/VPanel.tsx +0 -27
  88. package/dist/lib/layouts/XLayout.tsx +0 -29
  89. package/dist/lib/layouts/YLayout.tsx +0 -29
  90. package/dist/lib/layouts/index.ts +0 -13
@@ -1,64 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { usePageContext } from "../../core/PageContext";
3
- import UIComponent from "../common/UIComponent";
4
-
5
- const operators = [
6
- { label: "Matches", value: "matches" },
7
- { label: "Equals", value: "equals" },
8
- { label: "Not Equals", value: "neq" },
9
- ];
10
-
11
- const StringDecision = (props: Record<string, any>) => {
12
- const { name } = props ?? {};
13
- const [inputOp, setInputOp] = useState("");
14
- const [inputValue, setInputValue] = useState("");
15
- const pageContext = usePageContext();
16
- const binding = pageContext?.binding;
17
-
18
- const inputClassName = "border rounded px-2 py-1 w-full";
19
- const selectClassName =
20
- "px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:bg-gray-100 disabled:cursor-not-allowed";
21
-
22
- const handleChangeOperator = (e: React.ChangeEvent<HTMLSelectElement>) => {
23
- setInputOp(e.target.value);
24
- };
25
-
26
- const handleChangeValue = (e: React.ChangeEvent<HTMLInputElement>) => {
27
- setInputValue(e.target.value);
28
- };
29
-
30
- useEffect(() => {
31
- if (name && inputOp && inputValue) {
32
- pageContext?.set(name, { [inputOp]: inputValue });
33
- } else if (name && (!inputOp || !inputValue)) {
34
- pageContext?.set(name, null);
35
- }
36
- }, [name, inputOp, inputValue, pageContext, binding]);
37
-
38
- return (
39
- <UIComponent {...(props ?? {})}>
40
- <div className="flex gap-4 items-center justify-center">
41
- <select value={inputOp} onChange={handleChangeOperator} className={selectClassName}>
42
- <option value="">Select operator</option>
43
- {operators.map((op) => (
44
- <option key={op.value} value={op.value}>
45
- {op.label}
46
- </option>
47
- ))}
48
- </select>
49
- {/* <Select
50
- options={operators}
51
- placeholder="Select operator"
52
- onChange={(value: string) => setInputOp(value)}
53
- name={""}
54
- onRefresh={function (): void {
55
- throw new Error("Function not implemented.");
56
- }}
57
- /> */}
58
- <input type="text" value={inputValue} onChange={handleChangeValue} className={inputClassName} placeholder="Enter value" />
59
- </div>
60
- </UIComponent>
61
- );
62
- };
63
-
64
- export default StringDecision;
@@ -1,57 +0,0 @@
1
- import { useRef, useState } from "react";
2
- import UIComponent from "../common/UIComponent";
3
- import useUIInput, { UIInputProps } from "../common/UIInput";
4
-
5
- type TextFieldProps = UIInputProps & {
6
- required?: boolean;
7
- immediate?: boolean;
8
- };
9
-
10
- const TextField = (props: TextFieldProps) => {
11
- const { name, immediate = true } = props ?? {};
12
- const [focused, setFocused] = useState(false);
13
- const inputRef = useRef<HTMLInputElement | null>(null);
14
- const valueRef = useRef<string>("");
15
-
16
- const className = "border rounded px-2 py-1 w-full";
17
-
18
- const handleFocus = () => {
19
- setFocused(true);
20
- };
21
-
22
- const handleBlur = () => {
23
- if (!immediate) {
24
- setValue(inputValue);
25
- }
26
- setFocused(false);
27
- };
28
-
29
- const onRefresh = () => {
30
- setInputValue(getValue());
31
- };
32
-
33
- const { initialValue, getValue, setValue, binding } = useUIInput({ ...props, onRefresh });
34
- valueRef.current = initialValue ?? "";
35
- const [inputValue, setInputValue] = useState(valueRef.current);
36
-
37
- const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
38
- const text = e.target.value ?? "";
39
-
40
- if (text !== inputValue) {
41
- valueRef.current = text;
42
- setInputValue(valueRef.current);
43
- }
44
-
45
- if (immediate) {
46
- setValue(text);
47
- }
48
- };
49
-
50
- return (
51
- <UIComponent {...(props ?? {})}>
52
- <input type="text" ref={inputRef} onChange={onChange} value={inputValue} onFocus={handleFocus} onBlur={handleBlur} className={className} />
53
- </UIComponent>
54
- );
55
- };
56
-
57
- export default TextField;
@@ -1,81 +0,0 @@
1
- import { useEffect, useRef, useState } from "react";
2
- import UIComponent from "../common/UIComponent";
3
- import useUIInput, { UIInputProps } from "../common/UIInput";
4
-
5
- type YearPickerProps = UIInputProps & {
6
- min?: number;
7
- max?: number;
8
- immediate?: boolean;
9
- };
10
-
11
- const YearPicker = (props: YearPickerProps) => {
12
- const { min = 1900, max, immediate = true } = props ?? {};
13
- const valueRef = useRef<string>("");
14
- const [focused, setFocused] = useState(false);
15
-
16
- // Set default max to current year if not provided
17
- const currentYear = new Date().getFullYear();
18
- const maxYear = max || currentYear;
19
-
20
- // Generate array of years (descending order)
21
- const years = Array.from({ length: maxYear - min + 1 }, (_, i) => maxYear - i);
22
-
23
- const onRefresh = () => {
24
- setInputValue(getValue());
25
- };
26
-
27
- const { initialValue, getValue, setValue } = useUIInput({ ...props, onRefresh });
28
- valueRef.current = initialValue ?? "";
29
- const [inputValue, setInputValue] = useState(valueRef.current);
30
-
31
- const handleChange = (e: React.ChangeEvent<HTMLSelectElement>) => {
32
- const year = e.target.value;
33
-
34
- if (year !== inputValue) {
35
- valueRef.current = year;
36
- setInputValue(valueRef.current);
37
- }
38
-
39
- if (immediate) {
40
- setValue(year);
41
- }
42
- };
43
-
44
- const handleFocus = () => {
45
- setFocused(true);
46
- };
47
-
48
- const handleBlur = () => {
49
- if (!immediate) {
50
- setValue(inputValue);
51
- }
52
- setFocused(false);
53
- };
54
-
55
- useEffect(() => {
56
- // console.log("inputValue", inputValue);
57
- }, [inputValue]);
58
-
59
- return (
60
- <UIComponent {...(props ?? {})}>
61
- <div className="flex flex-col gap-1">
62
- <select
63
- value={inputValue}
64
- onChange={handleChange}
65
- onFocus={handleFocus}
66
- onBlur={handleBlur}
67
- className="px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 disabled:bg-gray-100 disabled:cursor-not-allowed"
68
- >
69
- <option value="">Select year</option>
70
- {years.map((year) => (
71
- <option key={year} value={year}>
72
- {year}
73
- </option>
74
- ))}
75
- </select>
76
- </div>
77
- </UIComponent>
78
- );
79
- };
80
-
81
- export default YearPicker;
@@ -1,115 +0,0 @@
1
- "use client";
2
-
3
- import clsx from "clsx";
4
- import { useState } from "react";
5
- import { twMerge } from "tailwind-merge";
6
- import DynamicIcon from "../../core/DynamicIcon";
7
- import { usePageContext } from "../../core/PageContext";
8
- import { usePageViewContext } from "../../core/PageViewContext";
9
- import { AbstractComponent } from "../../types/component";
10
- import useUIMenu, { MenuGroup, MenuItem } from "../common/UIMenu";
11
-
12
- /* ------------------------------------------------------------------ */
13
- /* Types */
14
-
15
- interface IconMenuProps extends AbstractComponent {
16
- name?: string;
17
- items?: MenuGroup[];
18
- data?: Record<string, any>;
19
- menugroup?: string;
20
- depends?: string;
21
- columns?: number;
22
- size?: "sm" | "md" | "lg";
23
- style?: string;
24
- }
25
-
26
- /* ------------------------------------------------------------------ */
27
- /* Size config */
28
-
29
- const sizeConfig = {
30
- sm: { tile: "w-20 h-20", icon: 24, label: "text-xs", gap: "gap-2" },
31
- md: { tile: "w-28 h-28", icon: 32, label: "text-sm", gap: "gap-3" },
32
- lg: { tile: "w-36 h-36", icon: 40, label: "text-base", gap: "gap-4" },
33
- };
34
-
35
- /* ------------------------------------------------------------------ */
36
- /* Component */
37
-
38
- const IconMenu = (props: IconMenuProps) => {
39
- const { name, menugroup, depends, items: itemsProp, data, columns = 5, size = "md", style = "" } = props ?? {};
40
- const pageContext = usePageContext();
41
- const pageView = usePageViewContext();
42
- const contextKey = name ?? depends ?? "";
43
- const [activeItem, setActiveItem] = useState<string | null>(null);
44
-
45
- const defaultPopupClass = `bg-white rounded-lg shadow-xl w-[90%] h-[90%] flex flex-col`;
46
- const finalPopupClass = twMerge(clsx(defaultPopupClass, style));
47
-
48
- // useUIMenu always returns MenuGroup[]
49
- const { items } = useUIMenu({ menugroup, items: itemsProp, data });
50
-
51
- const cfg = sizeConfig[size];
52
-
53
- /* ---------------------- Events ---------------------- */
54
- const handleItemClick = (item: MenuItem) => {
55
- if (!item.page || item.page === activeItem) return;
56
- if (item.mode == "window") {
57
- const oldHref = window.location.href;
58
- const nidx = oldHref.lastIndexOf("/");
59
- if (nidx > 0) {
60
- const newUrl = oldHref.substring(0, nidx) + "/" + item.page;
61
- window.location.href = newUrl;
62
- }
63
- } else {
64
- setActiveItem(item.page);
65
- if (contextKey && contextKey !== "selectedPage") {
66
- pageContext?.set(contextKey, item.page);
67
- } else {
68
- pageView?.setPage(item.page);
69
- }
70
- }
71
- };
72
-
73
- /* ---------------------- Shared button ---------------------- */
74
- const renderButton = (item: MenuItem, index: number) => (
75
- <button
76
- key={index}
77
- onClick={() => handleItemClick(item)}
78
- className={`
79
- ${cfg.tile}
80
- flex flex-col items-center justify-center gap-2
81
- rounded-2xl select-none cursor-pointer
82
- transition-all duration-200 ease-out
83
- focus:outline-none
84
- text-gray-600 hover:bg-gray-100 hover:text-gray-900
85
- `}
86
- >
87
- <DynamicIcon icon={item.icon} size={cfg.icon} />
88
- <span className={`${cfg.label} font-semibold leading-tight text-center px-1 truncate w-full`}>{item.title}</span>
89
- </button>
90
- );
91
-
92
- /* ---------------------- Render ---------------------- */
93
- return (
94
- <div className="flex flex-col gap-6 p-4">
95
- {(items as MenuGroup[]).map((group, groupIndex) => {
96
- // Flat item — no group structure
97
- if (!Array.isArray(group.items)) {
98
- return renderButton(group as unknown as MenuItem, groupIndex);
99
- }
100
-
101
- // Grouped with category title
102
- return (
103
- <div key={groupIndex} className="flex flex-col gap-2">
104
- {group.title && <span className="text-xs font-semibold text-gray-400 uppercase tracking-widest px-1">{group.title}</span>}
105
- <div className={`grid ${cfg.gap} justify-items-center`} style={{ gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }}>
106
- {group.items.map((item, index) => renderButton(item, index))}
107
- </div>
108
- </div>
109
- );
110
- })}
111
- </div>
112
- );
113
- };
114
-
115
- export default IconMenu;
@@ -1,127 +0,0 @@
1
- import { useEffect, useState } from "react";
2
- import { usePageContext } from "../../core/PageContext";
3
- import { usePageViewContext } from "../../core/PageViewContext";
4
- import useDependHandler from "../../core/UIDependHandler";
5
- import HPanel from "../../layouts/HPanel";
6
- import VPanel from "../../layouts/VPanel";
7
-
8
- type TabMenuProps = {
9
- name?: string;
10
- depends?: string;
11
- items?: Record<string, any>[];
12
- data?: Record<string, any>;
13
- menugroup?: string;
14
- orientation?: "horizontal" | "vertical";
15
- };
16
-
17
- type TabMenuItemProps = {
18
- id: string;
19
- title: string;
20
- key: string;
21
- component?: string;
22
- attr?: Record<string, any>;
23
- index: number;
24
- selected?: boolean;
25
- onClick: (item: Record<string, any>) => void;
26
- [key: string]: any;
27
- };
28
-
29
- const TabMenu = (props: TabMenuProps) => {
30
- const { name, depends, items = [], data, menugroup, orientation = "horizontal" } = props ?? {};
31
- const [selectedIndex, setSelectedIndex] = useState(-1);
32
- const [refreshKey, setRefreshKey] = useState(0);
33
- const pageContext = usePageContext();
34
- const pageView = usePageViewContext();
35
- const contextKey = name ?? depends ?? "";
36
-
37
- const resolvedItems = items.map((item: any, index: number) => ({
38
- ...item,
39
- key: item.id ?? Math.random().toString(36).substring(2, 15),
40
- index,
41
- }));
42
-
43
- const onRefresh = () => setRefreshKey((k) => k + 1);
44
- useDependHandler({ name: depends, onRefresh });
45
-
46
- const handleClick = (item: Record<string, any>) => {
47
- setSelectedIndex(item.index);
48
-
49
- if (item.page != null && item.page.trim() !== "") {
50
- pageView.setPage(item.page);
51
- } else if (contextKey != null && contextKey.trim() !== "") {
52
- const selItem = { ...item };
53
- delete selItem.id;
54
- delete selItem.title;
55
- delete selItem.index;
56
- delete selItem.key;
57
- delete selItem.selected;
58
- delete selItem.onClick;
59
- pageContext.set(contextKey, selItem); // ← sets "selectedTask" = "new_application_list"
60
- }
61
- };
62
-
63
- useEffect(() => {
64
- if (resolvedItems != null && resolvedItems.length > 0 && selectedIndex === -1) {
65
- handleClick(resolvedItems[0]);
66
- }
67
- }, [resolvedItems]);
68
-
69
- const render = () => {
70
- if (resolvedItems.length === 0) return null;
71
-
72
- const elems = resolvedItems.map((it) => {
73
- const item = it as unknown as TabMenuItemProps;
74
- item.selected = item.index === selectedIndex;
75
- return <TabMenuItem {...item} key={item.key} onClick={handleClick} />;
76
- });
77
-
78
- if (orientation === "vertical") {
79
- return (
80
- <div className="border-r border-gray-200">
81
- <VPanel gap={25}>{elems}</VPanel>
82
- </div>
83
- );
84
- }
85
-
86
- return (
87
- <div className="w-full">
88
- <HPanel gap={25}>{elems}</HPanel>
89
- </div>
90
- );
91
- };
92
-
93
- return <div>{render()}</div>;
94
- };
95
-
96
- export default TabMenu;
97
-
98
- /* ------------------------------------------------------------------ */
99
- /* TabMenuItem */
100
-
101
- const TabMenuItem = (props: TabMenuItemProps) => {
102
- const { title, onClick } = props ?? {};
103
-
104
- const handleClick = () => onClick(props);
105
-
106
- const render = () => {
107
- if (props.selected) {
108
- return (
109
- <div onClick={handleClick} className="relative px-4 py-3 cursor-pointer text-sm transition-all duration-200 text-gray-900 font-semibold">
110
- {title}
111
- <span className="absolute bottom-0 left-0 w-full h-[2px] rounded-full bg-gray-900" />
112
- </div>
113
- );
114
- }
115
-
116
- return (
117
- <div
118
- onClick={handleClick}
119
- className="relative px-4 py-3 cursor-pointer text-sm transition-all duration-200 text-gray-500 font-normal hover:text-gray-600"
120
- >
121
- {title}
122
- </div>
123
- );
124
- };
125
-
126
- return <div onClick={handleClick}>{render()}</div>;
127
- };