@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.
- package/dist/components/action/AlertMessage.d.ts +8 -0
- package/dist/components/action/AlertMessage.js +19 -0
- package/dist/components/action/AlertMessage.tsx +38 -0
- package/dist/components/action/Button.d.ts +21 -0
- package/dist/components/action/Button.js +139 -0
- package/dist/components/action/Button.tsx +230 -0
- package/dist/components/action/CancelEdit.d.ts +9 -0
- package/dist/components/action/CancelEdit.js +21 -0
- package/dist/components/action/CancelEdit.tsx +40 -0
- package/dist/components/action/DeleteData.d.ts +13 -0
- package/dist/components/action/DeleteData.js +43 -0
- package/dist/components/action/DeleteData.tsx +73 -0
- package/dist/components/action/Edit.d.ts +9 -0
- package/dist/components/action/Edit.js +21 -0
- package/dist/components/action/Edit.tsx +40 -0
- package/dist/components/action/LookupPage.d.ts +16 -0
- package/dist/components/action/LookupPage.js +62 -0
- package/dist/components/action/LookupPage.tsx +113 -0
- package/dist/components/action/ProcessRunner.d.ts +62 -0
- package/dist/components/action/ProcessRunner.js +156 -0
- package/dist/components/action/ProcessRunner.tsx +337 -0
- package/dist/components/action/Refresh.d.ts +7 -0
- package/dist/components/action/Refresh.js +17 -0
- package/dist/components/action/Refresh.tsx +35 -0
- package/dist/components/action/SaveData.d.ts +10 -0
- package/dist/components/action/SaveData.js +54 -0
- package/dist/components/action/SaveData.tsx +74 -0
- package/dist/components/action/SelectData.d.ts +8 -0
- package/dist/components/action/SelectData.js +29 -0
- package/dist/components/action/SelectData.tsx +47 -0
- package/dist/components/action/Undo.d.ts +9 -0
- package/dist/components/action/Undo.js +31 -0
- package/dist/components/action/Undo.tsx +50 -0
- package/dist/components/action/UpdateContext.d.ts +9 -0
- package/dist/components/action/UpdateContext.js +21 -0
- package/dist/components/action/UpdateContext.tsx +40 -0
- package/dist/components/action/UpdateData.d.ts +9 -0
- package/dist/components/action/UpdateData.js +33 -0
- package/dist/components/action/UpdateData.tsx +49 -0
- package/dist/components/action/ViewBackPage.d.ts +9 -0
- package/dist/components/action/ViewBackPage.js +19 -0
- package/dist/components/action/ViewBackPage.tsx +46 -0
- package/dist/components/action/ViewPage.d.ts +14 -0
- package/dist/components/action/ViewPage.js +88 -0
- package/dist/components/action/ViewPage.tsx +141 -0
- package/dist/components/common/UIComponent.d.ts +11 -0
- package/dist/components/common/UIComponent.js +52 -0
- package/dist/components/common/UIComponent.tsx +84 -0
- package/dist/components/common/UIInput.d.ts +12 -0
- package/dist/components/common/UIInput.js +37 -0
- package/dist/components/common/UIInput.tsx +49 -0
- package/dist/components/common/UIMenu.d.ts +23 -0
- package/dist/components/common/UIMenu.js +61 -0
- package/dist/components/common/UIMenu.tsx +91 -0
- package/dist/components/index.d.ts +37 -0
- package/dist/components/index.js +44 -0
- package/dist/components/index.ts +51 -0
- package/dist/components/input/CodeEditor.d.ts +12 -0
- package/dist/components/input/CodeEditor.js +132 -0
- package/dist/components/input/CodeEditor.tsx +188 -0
- package/dist/components/input/DateField.d.ts +9 -0
- package/dist/components/input/DateField.js +140 -0
- package/dist/components/input/DateField.tsx +274 -0
- package/dist/components/input/DayPicker.d.ts +2 -0
- package/dist/components/input/DayPicker.js +5 -0
- package/dist/components/input/DayPicker.tsx +5 -0
- package/dist/components/input/HtmlCode.d.ts +8 -0
- package/dist/components/input/HtmlCode.js +157 -0
- package/dist/components/input/HtmlCode.tsx +203 -0
- package/dist/components/input/JsonCode.d.ts +9 -0
- package/dist/components/input/JsonCode.js +159 -0
- package/dist/components/input/JsonCode.tsx +205 -0
- package/dist/components/input/MonthPicker.d.ts +2 -0
- package/dist/components/input/MonthPicker.js +5 -0
- package/dist/components/input/MonthPicker.tsx +5 -0
- package/dist/components/input/ScriptCode.d.ts +8 -0
- package/dist/components/input/ScriptCode.js +153 -0
- package/dist/components/input/ScriptCode.tsx +195 -0
- package/dist/components/input/Select.d.ts +14 -0
- package/dist/components/input/Select.js +40 -0
- package/dist/components/input/Select.tsx +78 -0
- package/dist/components/input/SqlCode.d.ts +8 -0
- package/dist/components/input/SqlCode.js +121 -0
- package/dist/components/input/SqlCode.tsx +162 -0
- package/dist/components/input/StringDecision.d.ts +2 -0
- package/dist/components/input/StringDecision.js +34 -0
- package/dist/components/input/StringDecision.tsx +64 -0
- package/dist/components/input/Text.d.ts +7 -0
- package/dist/components/input/Text.js +39 -0
- package/dist/components/input/Text.tsx +57 -0
- package/dist/components/input/YearPicker.d.ts +8 -0
- package/dist/components/input/YearPicker.js +44 -0
- package/dist/components/input/YearPicker.tsx +81 -0
- package/dist/components/list/IconMenu.d.ts +14 -0
- package/dist/components/list/IconMenu.js +72 -0
- package/dist/components/list/IconMenu.tsx +115 -0
- package/dist/components/list/TabMenu.d.ts +10 -0
- package/dist/components/list/TabMenu.js +72 -0
- package/dist/components/list/TabMenu.tsx +127 -0
- package/dist/components/list/TreeMenu.d.ts +14 -0
- package/dist/components/list/TreeMenu.js +207 -0
- package/dist/components/list/TreeMenu.tsx +279 -0
- package/dist/components/list/TxnTaskList.d.ts +2 -0
- package/dist/components/list/TxnTaskList.js +77 -0
- package/dist/components/list/TxnTaskList.tsx +198 -0
- package/dist/components/output/Label.d.ts +8 -0
- package/dist/components/output/Label.js +33 -0
- package/dist/components/output/Label.tsx +51 -0
- package/dist/components/table/DataList.d.ts +88 -0
- package/dist/components/table/DataList.js +361 -0
- package/dist/components/table/DataList.tsx +782 -0
- package/dist/components/table/DataTable.d.ts +46 -0
- package/dist/components/table/DataTable.js +253 -0
- package/dist/components/table/DataTable.tsx +572 -0
- package/dist/components/table/ListHandler.d.ts +42 -0
- package/dist/components/table/ListHandler.js +197 -0
- package/dist/components/table/ListHandler.ts +276 -0
- package/dist/components/table/TableContext.d.ts +33 -0
- package/dist/components/table/TableContext.js +57 -0
- package/dist/components/table/TableContext.tsx +122 -0
- package/dist/components/view/ComponentView.d.ts +8 -0
- package/dist/components/view/ComponentView.js +78 -0
- package/dist/components/view/ComponentView.tsx +102 -0
- package/dist/components/view/FilterView.d.ts +2 -0
- package/dist/components/view/FilterView.js +14 -0
- package/dist/components/view/FilterView.tsx +21 -0
- package/dist/components/view/HtmlForm.d.ts +7 -0
- package/dist/components/view/HtmlForm.js +145 -0
- package/dist/components/view/HtmlForm.tsx +186 -0
- package/dist/components/view/HtmlView.d.ts +9 -0
- package/dist/components/view/HtmlView.js +85 -0
- package/dist/components/view/HtmlView.tsx +114 -0
- package/dist/components/view/IFrameView.d.ts +2 -0
- package/dist/components/view/IFrameView.js +34 -0
- package/dist/components/view/IFrameView.tsx +48 -0
- package/dist/components/view/Modal.d.ts +14 -0
- package/dist/components/view/Modal.js +28 -0
- package/dist/components/view/Modal.tsx +72 -0
- package/dist/components/view/PageView.d.ts +9 -0
- package/dist/components/view/PageView.js +90 -0
- package/dist/components/view/PageView.tsx +131 -0
- package/dist/components/view/PopupView.d.ts +9 -0
- package/dist/components/view/PopupView.js +91 -0
- package/dist/components/view/PopupView.tsx +160 -0
- package/dist/components/view/RootView.d.ts +8 -0
- package/dist/components/view/RootView.js +75 -0
- package/dist/components/view/RootView.tsx +109 -0
- package/dist/components/view/WizardView.d.ts +6 -0
- package/dist/components/view/WizardView.js +34 -0
- package/dist/components/view/WizardView.tsx +48 -0
- package/dist/core/AppContext.d.ts +25 -0
- package/dist/core/AppContext.js +159 -0
- package/dist/core/AuthContext.d.ts +13 -0
- package/dist/core/AuthContext.js +80 -0
- package/dist/core/ComponentCache.d.ts +15 -0
- package/dist/core/ComponentCache.js +25 -0
- package/dist/core/DataContext.d.ts +20 -0
- package/dist/core/DataContext.js +41 -0
- package/dist/core/DynamicComponent.d.ts +12 -0
- package/dist/core/DynamicComponent.js +30 -0
- package/dist/core/DynamicIcon.d.ts +6 -0
- package/dist/core/DynamicIcon.js +48 -0
- package/dist/core/DynamicTemplate.d.ts +4 -0
- package/dist/core/DynamicTemplate.js +17 -0
- package/dist/core/ErrorMessage.d.ts +5 -0
- package/dist/core/ErrorMessage.js +7 -0
- package/dist/core/EventHandler.d.ts +3 -0
- package/dist/core/EventHandler.js +1 -0
- package/dist/core/HtmlCache.d.ts +6 -0
- package/dist/core/HtmlCache.js +17 -0
- package/dist/core/Page.d.ts +6 -0
- package/dist/core/Page.js +141 -0
- package/dist/core/PageCache.d.ts +15 -0
- package/dist/core/PageCache.js +26 -0
- package/dist/core/PageContext.d.ts +49 -0
- package/dist/core/PageContext.js +207 -0
- package/dist/core/PageRegistry.d.ts +7 -0
- package/dist/core/PageRegistry.js +11 -0
- package/dist/core/PageViewContext.d.ts +45 -0
- package/dist/core/PageViewContext.js +277 -0
- package/dist/core/Panel.d.ts +16 -0
- package/dist/core/Panel.js +39 -0
- package/dist/core/RowContext.d.ts +11 -0
- package/dist/core/RowContext.js +16 -0
- package/dist/core/StepHandler.d.ts +9 -0
- package/dist/core/StepHandler.js +39 -0
- package/dist/core/UIDependHandler.d.ts +6 -0
- package/dist/core/UIDependHandler.js +31 -0
- package/dist/core/auth/index.d.ts +18 -0
- package/dist/core/auth/index.js +187 -0
- package/dist/core/auth/session.d.ts +4 -0
- package/dist/core/auth/session.js +45 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.js +1 -0
- package/dist/core/page-helper.d.ts +27 -0
- package/dist/core/page-helper.js +47 -0
- package/dist/hooks/useUrlParams.d.ts +11 -0
- package/dist/hooks/useUrlParams.js +164 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +69 -0
- package/dist/layouts/BorderLayout.d.ts +14 -0
- package/dist/layouts/BorderLayout.js +8 -0
- package/dist/layouts/CardLayout.d.ts +27 -0
- package/dist/layouts/CardLayout.js +36 -0
- package/dist/layouts/CenterLayout.d.ts +8 -0
- package/dist/layouts/CenterLayout.js +6 -0
- package/dist/layouts/GridLayout.d.ts +9 -0
- package/dist/layouts/GridLayout.js +5 -0
- package/dist/layouts/HPanel.d.ts +11 -0
- package/dist/layouts/HPanel.js +8 -0
- package/dist/layouts/HorizontalLayout.d.ts +11 -0
- package/dist/layouts/HorizontalLayout.js +6 -0
- package/dist/layouts/MainLayout.d.ts +6 -0
- package/dist/layouts/MainLayout.js +5 -0
- package/dist/layouts/PageLayout.d.ts +11 -0
- package/dist/layouts/PageLayout.js +6 -0
- package/dist/layouts/VPanel.d.ts +9 -0
- package/dist/layouts/VPanel.js +7 -0
- package/dist/layouts/XLayout.d.ts +10 -0
- package/dist/layouts/XLayout.js +10 -0
- package/dist/layouts/YLayout.d.ts +10 -0
- package/dist/layouts/YLayout.js +10 -0
- package/dist/lib/PlatformRoute.d.ts +5 -0
- package/dist/lib/PlatformRoute.js +288 -0
- package/dist/lib/WebPlatform.d.ts +13 -0
- package/dist/lib/WebPlatform.js +124 -0
- package/dist/lib/components/ActivityBar.d.ts +13 -0
- package/dist/lib/components/ActivityBar.js +39 -0
- package/dist/lib/components/CopyButton.d.ts +8 -0
- package/dist/lib/components/CopyButton.js +50 -0
- package/dist/lib/components/Header.d.ts +2 -0
- package/dist/lib/components/Header.js +74 -0
- package/dist/lib/components/QuickActionMenu.d.ts +18 -0
- package/dist/lib/components/QuickActionMenu.js +50 -0
- package/dist/lib/components/UserButton.d.ts +11 -0
- package/dist/lib/components/UserButton.js +66 -0
- package/dist/lib/layouts/BorderLayout.tsx +31 -0
- package/dist/lib/layouts/CardLayout.tsx +73 -0
- package/dist/lib/layouts/CenterLayout.tsx +20 -0
- package/dist/lib/layouts/GridLayout.tsx +20 -0
- package/dist/lib/layouts/HPanel.tsx +31 -0
- package/dist/lib/layouts/HorizontalLayout.tsx +29 -0
- package/dist/lib/layouts/MainLayout.tsx +16 -0
- package/dist/lib/layouts/PageLayout.tsx +29 -0
- package/dist/lib/layouts/VPanel.tsx +27 -0
- package/dist/lib/layouts/XLayout.tsx +29 -0
- package/dist/lib/layouts/YLayout.tsx +29 -0
- package/dist/lib/utils/BeanUtils.d.ts +3 -0
- package/dist/lib/utils/BeanUtils.js +75 -0
- package/dist/lib/utils/ComponentLoader.d.ts +13 -0
- package/dist/lib/utils/ComponentLoader.js +26 -0
- package/dist/lib/utils/ExprUtil.d.ts +7 -0
- package/dist/lib/utils/ExprUtil.js +44 -0
- package/dist/lib/utils/PageUtils.d.ts +6 -0
- package/dist/lib/utils/PageUtils.js +121 -0
- package/dist/lib/utils/ResourceLoader.d.ts +11 -0
- package/dist/lib/utils/ResourceLoader.js +37 -0
- package/dist/lib/utils/SectionProvider.d.ts +5 -0
- package/dist/lib/utils/SectionProvider.js +39 -0
- package/dist/lib/utils/initResourceLoader.d.ts +0 -0
- package/dist/lib/utils/initResourceLoader.js +95 -0
- package/dist/styles/index.css +38 -0
- package/dist/templates/BasicTemplate.d.ts +2 -0
- package/dist/templates/BasicTemplate.js +14 -0
- package/dist/templates/CrudFormTemplate.d.ts +2 -0
- package/dist/templates/CrudFormTemplate.js +38 -0
- package/dist/templates/DataListTemplate.d.ts +2 -0
- package/dist/templates/DataListTemplate.js +13 -0
- package/dist/templates/ExplorerTemplate.d.ts +10 -0
- package/dist/templates/ExplorerTemplate.js +17 -0
- package/dist/templates/TxnFormTemplate.d.ts +2 -0
- package/dist/templates/TxnFormTemplate.js +66 -0
- package/dist/templates/WizardTemplate.d.ts +9 -0
- package/dist/templates/WizardTemplate.js +37 -0
- package/dist/templates/index.d.ts +5 -0
- package/dist/templates/index.js +5 -0
- package/dist/types/action.d.ts +8 -0
- package/dist/types/action.js +1 -0
- package/dist/types/component.d.ts +18 -0
- package/dist/types/component.js +1 -0
- package/dist/types/list.d.ts +14 -0
- package/dist/types/list.js +1 -0
- package/dist/types/template.d.ts +6 -0
- package/dist/types/template.js +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
const resolveContextPath = () => {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
const path = ((_b = ((_a = process.env.CONTEXT_PATH) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_APP_CONTEXT_PATH)) !== null && _b !== void 0 ? _b : "").trim();
|
|
5
|
+
if (path === '') {
|
|
6
|
+
return '/';
|
|
7
|
+
}
|
|
8
|
+
else if (!path.startsWith("/")) {
|
|
9
|
+
return `/${path}`;
|
|
10
|
+
}
|
|
11
|
+
return path;
|
|
12
|
+
};
|
|
13
|
+
const resolveTenantName = () => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
const name = ((_b = ((_a = process.env.TENANT_NAME) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_TENANT_NAME)) !== null && _b !== void 0 ? _b : "").trim();
|
|
16
|
+
return (name === '' ? 'base' : name);
|
|
17
|
+
};
|
|
18
|
+
const resolveModuleName = () => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const name = ((_b = ((_a = process.env.MODULE_NAME) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_MODULE_NAME)) !== null && _b !== void 0 ? _b : '').trim();
|
|
21
|
+
return name;
|
|
22
|
+
};
|
|
23
|
+
const resolvePathName = (contextPath, module, pathname) => {
|
|
24
|
+
if (pathname.startsWith('//')) {
|
|
25
|
+
return resolvePathName(contextPath, module, pathname.substring(1));
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
let newPath = pathname;
|
|
29
|
+
if (!pathname.startsWith('/')) {
|
|
30
|
+
newPath = `/${pathname}`;
|
|
31
|
+
}
|
|
32
|
+
let prefix = [contextPath, module].filter(str => str != null && str.trim() !== '').join('/');
|
|
33
|
+
if (prefix.startsWith('//'))
|
|
34
|
+
prefix = prefix.substring(1);
|
|
35
|
+
if (!prefix.startsWith('/'))
|
|
36
|
+
prefix = `/${prefix}`;
|
|
37
|
+
if (newPath.startsWith(prefix))
|
|
38
|
+
return newPath;
|
|
39
|
+
return resolvePathName(contextPath, module, `${prefix}${newPath}`);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const getResourcePath = (contextPath, module, pathname) => {
|
|
43
|
+
if (pathname.startsWith('//')) {
|
|
44
|
+
return getResourcePath(contextPath, module, pathname.substring(1));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
let newPath = pathname;
|
|
48
|
+
if (pathname.startsWith('/')) {
|
|
49
|
+
newPath = pathname.substring(1);
|
|
50
|
+
}
|
|
51
|
+
let prefix = [contextPath, '_res', module ? module : null].join('/');
|
|
52
|
+
if (prefix.startsWith('//')) {
|
|
53
|
+
prefix = prefix.substring(1);
|
|
54
|
+
}
|
|
55
|
+
if (!prefix.startsWith('/')) {
|
|
56
|
+
prefix = `/${prefix}`;
|
|
57
|
+
}
|
|
58
|
+
if (newPath.startsWith(prefix)) {
|
|
59
|
+
return newPath;
|
|
60
|
+
}
|
|
61
|
+
return `${prefix}${newPath}`;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const getSegmentsImpl = (pathname) => {
|
|
65
|
+
const valueOf = (parts, index) => {
|
|
66
|
+
try {
|
|
67
|
+
return parts[index];
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
if (pathname.startsWith('/modules/')) {
|
|
74
|
+
const re = new RegExp('^/modules/([^/]+)/([^/]+)/.*$');
|
|
75
|
+
const match = pathname.match(re);
|
|
76
|
+
const tenant = valueOf(match, 1);
|
|
77
|
+
const moduleid = valueOf(match, 2);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const re = new RegExp('^/([^/]+)/([^/]+)/.*$');
|
|
81
|
+
const match = pathname.match(re);
|
|
82
|
+
const tenant = valueOf(match, 1);
|
|
83
|
+
const moduleid = valueOf(match, 2);
|
|
84
|
+
}
|
|
85
|
+
return '';
|
|
86
|
+
};
|
|
87
|
+
export const WebPlatform = {
|
|
88
|
+
CONTEXT_PATH: resolveContextPath(),
|
|
89
|
+
TENANT_NAME: resolveTenantName(),
|
|
90
|
+
MODULE_NAME: resolveModuleName(),
|
|
91
|
+
MGMT_SERVER_URI: ((_b = ((_a = process.env.MGMT_SERVER_URI) !== null && _a !== void 0 ? _a : process.env.NEXT_PUBLIC_MGMT_SERVER_URI)) !== null && _b !== void 0 ? _b : null),
|
|
92
|
+
env: (name, defaultValue) => {
|
|
93
|
+
const key_1 = name;
|
|
94
|
+
const key_2 = `next_public_${key_1}`.toUpperCase();
|
|
95
|
+
const value = (process.env[key_1] || process.env[key_2]);
|
|
96
|
+
return (value !== null && value !== void 0 ? value : defaultValue);
|
|
97
|
+
},
|
|
98
|
+
getResourcePath: (pathname) => {
|
|
99
|
+
return getResourcePath(resolveContextPath(), resolveModuleName(), pathname);
|
|
100
|
+
},
|
|
101
|
+
resolvePathName: (pathname) => {
|
|
102
|
+
return resolvePathName(resolveContextPath(), resolveModuleName(), pathname);
|
|
103
|
+
},
|
|
104
|
+
isModulePath: (pathname) => {
|
|
105
|
+
let sPath = pathname;
|
|
106
|
+
if (sPath.startsWith('//'))
|
|
107
|
+
sPath = sPath.substring(1);
|
|
108
|
+
if (!sPath.startsWith('/'))
|
|
109
|
+
sPath = `/${sPath}`;
|
|
110
|
+
return sPath.startsWith('/modules');
|
|
111
|
+
},
|
|
112
|
+
isSysMgmtPath: (pathname) => {
|
|
113
|
+
let sPath = pathname;
|
|
114
|
+
if (sPath.startsWith('//'))
|
|
115
|
+
sPath = sPath.substring(1);
|
|
116
|
+
if (!sPath.startsWith('/'))
|
|
117
|
+
sPath = `/${sPath}`;
|
|
118
|
+
return sPath.startsWith('/sysmgmt');
|
|
119
|
+
},
|
|
120
|
+
getSegments: (pathname) => {
|
|
121
|
+
return getSegmentsImpl(pathname);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
export default WebPlatform;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ActivityBarProps = {
|
|
2
|
+
value: string;
|
|
3
|
+
handler: (item: Record<string, any>) => void;
|
|
4
|
+
};
|
|
5
|
+
export type ActivityItem = {
|
|
6
|
+
id: string;
|
|
7
|
+
icon: React.ReactNode;
|
|
8
|
+
label: string;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
};
|
|
11
|
+
export declare const getResourcePath: (name: string) => string;
|
|
12
|
+
declare function ActivityBar({ value, handler }: ActivityBarProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default ActivityBar;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import WebPlatform from "../WebPlatform";
|
|
4
|
+
export const getResourcePath = (name) => {
|
|
5
|
+
return WebPlatform.getResourcePath(`icons/${name}`);
|
|
6
|
+
};
|
|
7
|
+
const items = [
|
|
8
|
+
{ id: "mainmenu", label: "Main Menu", icon: _jsx("img", { src: getResourcePath("hamburger-menu.png"), width: 24 }) },
|
|
9
|
+
{ id: "dashboard", label: "Dashboard", icon: _jsx("img", { src: getResourcePath("dashboard.png"), width: 24 }) },
|
|
10
|
+
{ id: "main", label: "Transactions", icon: _jsx("img", { src: getResourcePath("txn.png"), width: 24 }) },
|
|
11
|
+
{ id: "mgmt", label: "Management", icon: _jsx("img", { src: getResourcePath("mgmt.png"), width: 24 }) },
|
|
12
|
+
{ id: "sysmgmt", label: "System Management", icon: _jsx("img", { src: getResourcePath("settings.png"), width: 24 }) },
|
|
13
|
+
];
|
|
14
|
+
function ActivityBar({ value, handler }) {
|
|
15
|
+
items.map((item) => {
|
|
16
|
+
item.heightClassNames = "h-12";
|
|
17
|
+
item.hoverClassNames = "hover:bg-gray-200 ";
|
|
18
|
+
item.selectedClassNames = "";
|
|
19
|
+
if (item.id === value) {
|
|
20
|
+
item.selectedClassNames = "border-l-[3px] border-blue-500";
|
|
21
|
+
}
|
|
22
|
+
if (item.id === "mainmenu") {
|
|
23
|
+
item.heightClassNames = "h-[60px]";
|
|
24
|
+
item.hoverClassNames = "hover:bg-blue-100";
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const handleClick = (item) => {
|
|
28
|
+
if (item.id === "mainmenu") {
|
|
29
|
+
// do nothing
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (handler != null) {
|
|
33
|
+
const newItem = Object.assign({}, item);
|
|
34
|
+
handler(newItem);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return (_jsx("div", { className: "flex flex-col items-center w-12 h-screen border-r bg-gray-50", children: items.map((item) => (_jsx("button", { className: `w-12 ${item.heightClassNames} flex items-center justify-center transition-colors ${item.selectedClassNames} ${item.hoverClassNames}`.trim(), title: item.label, onClick: () => handleClick(item), children: _jsx("div", { className: `transition-transform transform hover:scale-100`, children: item.icon }) }, item.id))) }));
|
|
38
|
+
}
|
|
39
|
+
export default ActivityBar;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
declare const CopyButton: ({ item, className, copySize, copiedSize, classNameCopied, }: {
|
|
2
|
+
item?: string | Record<string, any>;
|
|
3
|
+
className?: string;
|
|
4
|
+
copySize?: number;
|
|
5
|
+
copiedSize?: number;
|
|
6
|
+
classNameCopied?: string;
|
|
7
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default CopyButton;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Copy, CopyCheck } from "lucide-react";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { Button } from "seti-ramesesv1";
|
|
5
|
+
const CopyButton = ({ item, className, copySize = 20, copiedSize = 10, classNameCopied, }) => {
|
|
6
|
+
const [copied, setCopied] = useState(false);
|
|
7
|
+
const copyData = async () => {
|
|
8
|
+
if (!item) {
|
|
9
|
+
alert("No data to copy.");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
try {
|
|
13
|
+
let dataToCopy = "";
|
|
14
|
+
// ✅ Handle string or object
|
|
15
|
+
if (typeof item === "string") {
|
|
16
|
+
try {
|
|
17
|
+
const parsed = JSON.parse(item); // if it's valid JSON string
|
|
18
|
+
dataToCopy = JSON.stringify(parsed, null, 2); // pretty print
|
|
19
|
+
}
|
|
20
|
+
catch (_a) {
|
|
21
|
+
dataToCopy = item; // copy raw string if not JSON
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else if (typeof item === "object") {
|
|
25
|
+
dataToCopy = JSON.stringify(item, null, 2);
|
|
26
|
+
}
|
|
27
|
+
// ✅ Clipboard support check
|
|
28
|
+
if (!navigator.clipboard || !navigator.clipboard.writeText) {
|
|
29
|
+
console.warn("Clipboard API not available, using fallback.");
|
|
30
|
+
const textArea = document.createElement("textarea");
|
|
31
|
+
textArea.value = dataToCopy;
|
|
32
|
+
document.body.appendChild(textArea);
|
|
33
|
+
textArea.select();
|
|
34
|
+
document.execCommand("copy");
|
|
35
|
+
document.body.removeChild(textArea);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
await navigator.clipboard.writeText(dataToCopy);
|
|
39
|
+
}
|
|
40
|
+
setCopied(true);
|
|
41
|
+
setTimeout(() => setCopied(false), 800);
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
console.error("Failed to copy data:", err);
|
|
45
|
+
alert("Failed to copy data.");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return (_jsx("div", { className: "flex flex-col items-center justify-center", children: !copied ? (_jsx(Button, { onClick: copyData, className: `flex items-center justify-center !px-3 !bg-gray-300 !text-black/80 ${className}`, children: _jsx(Copy, { size: copySize }) })) : (_jsx("div", { className: `bg-gray-200/80 px-[17px] py-[13px] rounded-lg ${classNameCopied}`, children: _jsx(CopyCheck, { size: copiedSize, className: "animate-ping" }) })) }));
|
|
49
|
+
};
|
|
50
|
+
export default CopyButton;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { moduleClient } from "@ramesesinc/lib/local-api";
|
|
4
|
+
import { Bell, LogOut, User } from "lucide-react";
|
|
5
|
+
import { useRouter } from "next/navigation";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
import { useApp } from "../../core/AppContext";
|
|
8
|
+
import { useAuth } from "../../core/AuthContext";
|
|
9
|
+
import HorizontalLayout from "../../layouts/HorizontalLayout";
|
|
10
|
+
import WebPlatform from "../WebPlatform";
|
|
11
|
+
import { getResourcePath } from "./ActivityBar";
|
|
12
|
+
import QuickActionMenu from "./QuickActionMenu";
|
|
13
|
+
import UserButton from "./UserButton";
|
|
14
|
+
const Header = () => {
|
|
15
|
+
var _a;
|
|
16
|
+
const app = useApp();
|
|
17
|
+
const auth = useAuth();
|
|
18
|
+
const router = useRouter();
|
|
19
|
+
const [, reload] = useState("");
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
reload(new Date().toISOString().slice(0, 19));
|
|
22
|
+
}, [auth.sessionId, app.tenant, app.module]);
|
|
23
|
+
const iconClass = "w-[12px] h-[12px] text-gray-600";
|
|
24
|
+
const menuItems = [
|
|
25
|
+
{
|
|
26
|
+
label: "Profile",
|
|
27
|
+
icon: _jsx(User, { className: iconClass }),
|
|
28
|
+
onClick: () => console.log("Navigate to profile"),
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: "Logout",
|
|
32
|
+
icon: _jsx(LogOut, { className: iconClass }),
|
|
33
|
+
onClick: async () => {
|
|
34
|
+
try {
|
|
35
|
+
await auth.signOut();
|
|
36
|
+
window.location.href = `/${app.tenant}/login`;
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
console.error(err);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
const actionMenuHandler = {
|
|
45
|
+
getItems: async () => {
|
|
46
|
+
var _a;
|
|
47
|
+
try {
|
|
48
|
+
const list = await moduleClient((_a = app.tenant) !== null && _a !== void 0 ? _a : "").getModules();
|
|
49
|
+
list.map((item) => (item.id = item._id));
|
|
50
|
+
return list;
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.log(err);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
onSelect: async (item) => {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
if (app.tenant != null && item.id != null) {
|
|
60
|
+
const activityId = (_b = (_a = item.defaultpage) !== null && _a !== void 0 ? _a : auth.activityId) !== null && _b !== void 0 ? _b : "main";
|
|
61
|
+
const newPath = `/${app.tenant}/${item.id}/${activityId}`;
|
|
62
|
+
router.push(newPath);
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
const handleIcon = () => {
|
|
67
|
+
router.push(`/${app.tenant}`);
|
|
68
|
+
};
|
|
69
|
+
const logoPath = WebPlatform.getResourcePath("logo.png");
|
|
70
|
+
const leftView = (_jsxs("div", { className: "flex justify-center items-center gap-2", children: [_jsx("img", { src: logoPath, alt: "", className: "h-[28px] cursor-pointer", onClick: handleIcon }), app.module && _jsx("span", { className: "font-bold text-[22px] text-gray-500 pb-1", children: (_a = app.module) === null || _a === void 0 ? void 0 : _a.toUpperCase() })] }));
|
|
71
|
+
const rightView = (_jsxs("div", { className: "flex items-center gap-2", children: [auth.sessionId && (_jsxs("div", { className: "relative cursor-pointer", children: [_jsx(Bell, { className: "text-gray-600 w-[20px] h-[18px]" }), _jsx("span", { className: "absolute top-0 right-0 w-2 h-2 bg-red-500 rounded-full" })] })), auth.sessionId && _jsx(QuickActionMenu, { handler: actionMenuHandler }), auth.sessionId && (_jsx("a", { href: `/sysmgmt/${app.tenant}/${app.module}`, target: "_blank", rel: "noopener noreferrer", className: "flex items-center justify-center rounded-full hover:bg-gray-100", title: "System Management", children: _jsx("img", { src: getResourcePath("settings.png"), width: 18 }) })), auth.sessionId && _jsx(UserButton, { menuItems: menuItems })] }));
|
|
72
|
+
return (_jsx(HorizontalLayout, { left: leftView, right: rightView, className: "h-[60px] min-h-[60px] max-h-[60px] items-center px-8 py-2 border-b border-gray-200" }));
|
|
73
|
+
};
|
|
74
|
+
export default Header;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
export type QuickActionMenuItem = {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
short?: string;
|
|
6
|
+
defaultpage?: string;
|
|
7
|
+
icon?: string;
|
|
8
|
+
iconRenderer?: ReactNode;
|
|
9
|
+
};
|
|
10
|
+
type QuickActionHandler = {
|
|
11
|
+
getItems: () => Promise<QuickActionMenuItem[] | null>;
|
|
12
|
+
onSelect: (item: QuickActionMenuItem) => Promise<void>;
|
|
13
|
+
};
|
|
14
|
+
type QuickActionMenuProps = {
|
|
15
|
+
handler: QuickActionHandler;
|
|
16
|
+
};
|
|
17
|
+
declare const QuickActionMenu: ({ handler }: QuickActionMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export default QuickActionMenu;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useBinding } from "@ramesesinc/client";
|
|
3
|
+
import { Package } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import WebPlatform from "../WebPlatform";
|
|
6
|
+
const QuickActionMenu = ({ handler }) => {
|
|
7
|
+
const [open, setOpen] = useState(false);
|
|
8
|
+
const [items, setItems] = useState([]);
|
|
9
|
+
const menuRef = useRef(null);
|
|
10
|
+
const binding = useBinding();
|
|
11
|
+
const handleOpenActions = async () => {
|
|
12
|
+
const list = await handler.getItems();
|
|
13
|
+
if (list != null) {
|
|
14
|
+
list.map((item) => {
|
|
15
|
+
var _a;
|
|
16
|
+
item.short = (_a = item.short) !== null && _a !== void 0 ? _a : item.title;
|
|
17
|
+
});
|
|
18
|
+
list.sort((a, b) => {
|
|
19
|
+
return a.title.localeCompare(b.title);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
setItems(list !== null && list !== void 0 ? list : []);
|
|
23
|
+
setOpen(!open);
|
|
24
|
+
};
|
|
25
|
+
// Close menu on click outside
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
const handleClickOutside = (event) => {
|
|
28
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
29
|
+
setOpen(false);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
33
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
34
|
+
}, []);
|
|
35
|
+
const handleItemClick = async (item) => {
|
|
36
|
+
setOpen(false);
|
|
37
|
+
if (item != null) {
|
|
38
|
+
await handler.onSelect(item);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const getIconRenderer = (item) => {
|
|
42
|
+
if (item.icon == null || item.icon === "") {
|
|
43
|
+
return _jsx(Package, { className: "w-[36px] h-[36px] object-contain" });
|
|
44
|
+
}
|
|
45
|
+
return _jsx("img", { src: item.icon, alt: "", className: "w-[36px] h-[36px] object-contain" });
|
|
46
|
+
};
|
|
47
|
+
const menuIconPath = WebPlatform.getResourcePath("icons/grid-menu.png");
|
|
48
|
+
return (_jsxs("div", { className: "relative inline-block", ref: menuRef, children: [_jsx("button", { title: "Quick Actions", className: `appearance-none flex items-center gap-1 rounded ${open ? "bg-gray-200" : "hover:bg-gray-100"} px-1 py-1 transition`, onClick: handleOpenActions, children: _jsx("img", { src: menuIconPath, alt: "", className: "w-[20px] h-[20px]" }) }), open && (_jsxs("div", { className: "fixed right-2 w-[330px] flex flex-col bg-white border border-gray-200 rounded-lg shadow-lg z-20 p-2", children: [_jsx("span", { className: "text-[0.6em] font-extrabold text-gray-400", children: "MODULES" }), _jsx("div", { className: "grid grid-cols-3 pt-1 gap-1", children: items.map((item) => (_jsxs("button", { title: item.title, onClick: () => handleItemClick(item), className: "appearance-none w-[100px] h-[90px] flex flex-col items-center justify-center p-1 bg-gray-50 border border-gray-100 rounded-lg hover:bg-blue-50 transition", children: [getIconRenderer(item), _jsx("span", { className: "text-[0.8em] font-semibold text-gray-500 text-center truncate w-full", children: item.short })] }, `quick-action:${item.id}`))) })] }))] }));
|
|
49
|
+
};
|
|
50
|
+
export default QuickActionMenu;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type MenuItem = {
|
|
3
|
+
label: string;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
icon?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
type UserButtonProps = {
|
|
8
|
+
menuItems: MenuItem[];
|
|
9
|
+
};
|
|
10
|
+
declare const UserButton: ({ menuItems }: UserButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default UserButton;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useBinding } from "@ramesesinc/client";
|
|
3
|
+
import { ChevronDown } from "lucide-react";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { useApp } from "../../core/AppContext";
|
|
6
|
+
import * as session from "../../core/auth/session";
|
|
7
|
+
import { useAuth } from "../../core/AuthContext";
|
|
8
|
+
import WebPlatform from "../WebPlatform";
|
|
9
|
+
const UserButton = ({ menuItems }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const app = useApp();
|
|
12
|
+
const auth = useAuth();
|
|
13
|
+
const binding = useBinding();
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
|
+
const [user, setUser] = useState(null);
|
|
16
|
+
const menuRef = useRef(null);
|
|
17
|
+
const handleOpenAction = async () => {
|
|
18
|
+
var _a;
|
|
19
|
+
let userInfo = null;
|
|
20
|
+
try {
|
|
21
|
+
if (auth.sessionId) {
|
|
22
|
+
const tokenInfo = await session.verifyToken(auth.sessionId);
|
|
23
|
+
const { INFO } = (tokenInfo !== null && tokenInfo !== void 0 ? tokenInfo : {});
|
|
24
|
+
if (INFO != null) {
|
|
25
|
+
// auth_post_enabled is set to false
|
|
26
|
+
// use the returned INFO as the user info
|
|
27
|
+
userInfo = INFO;
|
|
28
|
+
}
|
|
29
|
+
else if ((tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.USERID) != null) {
|
|
30
|
+
userInfo = await session.getUser(tokenInfo.USERID, (_a = app.tenant) !== null && _a !== void 0 ? _a : "");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
userInfo = { fullname: "USER" };
|
|
36
|
+
}
|
|
37
|
+
setUser(userInfo);
|
|
38
|
+
setOpen(!open);
|
|
39
|
+
};
|
|
40
|
+
// Close menu on click outside
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
const handleClickOutside = (event) => {
|
|
43
|
+
if (menuRef.current && !menuRef.current.contains(event.target)) {
|
|
44
|
+
setOpen(false);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
48
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
49
|
+
}, []);
|
|
50
|
+
const handleItemClick = (item) => {
|
|
51
|
+
try {
|
|
52
|
+
if (item && item.onClick != null) {
|
|
53
|
+
item.onClick();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
setOpen(false);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const userIconPath = WebPlatform.getResourcePath("assets/HB.jpg");
|
|
61
|
+
return (_jsxs("div", { className: "relative inline-block", ref: menuRef, children: [_jsxs("button", { onClick: (e) => {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
handleOpenAction();
|
|
64
|
+
}, className: `appearance-none flex items-center gap-1 rounded-full ${open ? "bg-gray-200" : "bg-gray-100 hover:bg-gray-200"} px-1 py-1 transition`, children: [_jsx("img", { src: userIconPath, alt: "", className: "w-[24px] h-[24px] rounded-full object-cover" }), _jsx(ChevronDown, { className: `w-[12px] h-[12px] text-gray-600 transition-transform ${open ? "rotate-180" : ""}` })] }), open && (_jsx("div", { className: "absolute right-0 w-[270px] bg-white border border-gray-200 rounded-lg shadow-lg z-20", children: _jsxs("ul", { className: "px-2 py-2 text-sm text-gray-700", children: [user && (_jsxs(_Fragment, { children: [_jsxs("li", { className: "flex items-center gap-2 py-1 pl-1 pb-2 cursor-default", children: [_jsx("img", { src: userIconPath, alt: "", className: "w-[32px] h-[32px] rounded-full object-cover" }), _jsxs("div", { className: "flex flex-col max-w-[190px]", children: [_jsx("span", { className: "text-[0.9em] font-semibold leading-[10px] truncate block", children: user.fullname }), _jsx("span", { className: "text-[0.7em] font-semibold text-gray-400 truncate block", children: (_a = user.title) !== null && _a !== void 0 ? _a : "-" })] }), _jsx("div", { className: "flex-1" })] }), _jsx("li", { className: "border-[1px] border-t border-gray-100" }), _jsx("li", { className: "pt-1" })] })), menuItems.map((item) => (_jsxs("li", { className: "flex items-center gap-2 px-2 py-1 hover:bg-gray-100 hover:rounded-lg cursor-pointer", onClick: () => handleItemClick(item), children: [item.icon, _jsx("span", { children: item.label })] }, item.label)))] }) }))] }));
|
|
65
|
+
};
|
|
66
|
+
export default UserButton;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import HorizontalLayout from "./HorizontalLayout";
|
|
3
|
+
import PageLayout from "./PageLayout";
|
|
4
|
+
|
|
5
|
+
type BorderLayoutProps = {
|
|
6
|
+
layoutid?: string;
|
|
7
|
+
className?: string;
|
|
8
|
+
vgap?: number;
|
|
9
|
+
hgap?: number;
|
|
10
|
+
|
|
11
|
+
north?: ReactNode;
|
|
12
|
+
south?: ReactNode;
|
|
13
|
+
east?: ReactNode;
|
|
14
|
+
west?: ReactNode;
|
|
15
|
+
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const BorderLayout = ({ layoutid, className, vgap = 0, hgap = 0, north, south, east, west, children }: BorderLayoutProps) => {
|
|
20
|
+
const preferredLayoutId = layoutid ?? "" ? layoutid : "borderlayout";
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<PageLayout layoutid={`${preferredLayoutId}`} className={className} gap={vgap} header={north} footer={south}>
|
|
24
|
+
<HorizontalLayout layoutid={`${preferredLayoutId}-center`} gap={hgap} left={west} right={east}>
|
|
25
|
+
{children}
|
|
26
|
+
</HorizontalLayout>
|
|
27
|
+
</PageLayout>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default BorderLayout;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { UIControl } from "@ramesesinc/client";
|
|
2
|
+
import React, { ReactElement, ReactNode, Suspense } from "react";
|
|
3
|
+
|
|
4
|
+
export interface CardProps {
|
|
5
|
+
name: string;
|
|
6
|
+
element: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Card is a declarative wrapper for CardLayout.
|
|
10
|
+
* It does not render UI by itself, only provides data (name + element).
|
|
11
|
+
*/
|
|
12
|
+
export function Card(_props: CardProps): null {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type CardLayoutRefModel = {
|
|
17
|
+
getName: () => string | null;
|
|
18
|
+
getElement: () => ReactNode;
|
|
19
|
+
validate: () => void;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export type CardLayoutRef = {
|
|
23
|
+
current?: CardLayoutRefModel;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type CardLayoutProps = {
|
|
27
|
+
ref?: CardLayoutRef;
|
|
28
|
+
layoutid?: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
|
|
32
|
+
value: string;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const CardLayout = ({ ref, layoutid, className, children, value = "default" }: CardLayoutProps) => {
|
|
36
|
+
const preferredLayoutId = (layoutid ?? "") ? layoutid : "cardlayout";
|
|
37
|
+
|
|
38
|
+
// Extract only <Card> children
|
|
39
|
+
const cards: ReactElement<CardProps>[] = React.Children.toArray(children).filter(
|
|
40
|
+
(child): child is ReactElement<CardProps> => React.isValidElement(child) && child.type === Card,
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const activeCard = cards.find((c) => c.props.name === value);
|
|
44
|
+
|
|
45
|
+
if (ref != null) {
|
|
46
|
+
ref.current = {
|
|
47
|
+
getName: () => (activeCard ? activeCard.props.name : null),
|
|
48
|
+
getElement: () => (activeCard ? activeCard.props.element : null),
|
|
49
|
+
validate: () => {
|
|
50
|
+
if (activeCard == null || activeCard.props.element == null) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const elem = activeCard.props.element;
|
|
55
|
+
const props = (elem as ReactElement<UIControl>).props;
|
|
56
|
+
if (props.binding != null) {
|
|
57
|
+
const result = props.binding.validate();
|
|
58
|
+
if (result != null) {
|
|
59
|
+
throw Error(result);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div className={`${preferredLayoutId}-container ${className ?? ""} flex flex-col h-full`}>
|
|
68
|
+
<Suspense fallback={<div>Loading...</div>}>{activeCard ? activeCard.props.element : null}</Suspense>
|
|
69
|
+
</div>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default CardLayout;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type CenterLayoutProps = {
|
|
4
|
+
layoutid?: string;
|
|
5
|
+
className?: string;
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const CenterLayout = ({ layoutid, className, children }: CenterLayoutProps) => {
|
|
10
|
+
|
|
11
|
+
const preferredLayoutId = ((layoutid ?? '') ? layoutid : 'pagelayout');
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className={`${preferredLayoutId}-container ${className ?? ''} flex items-center justify-center w-full h-full`}>
|
|
15
|
+
{children}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default CenterLayout;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
|
|
3
|
+
type GridLayoutProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
cols?: number;
|
|
6
|
+
gap?: number;
|
|
7
|
+
|
|
8
|
+
children?: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const GridLayout = ({ className, cols = 3, gap = 1, children }: GridLayoutProps) => {
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div className={`${className ?? ''} grid gap-${gap}`} style={{gridTemplateColumns: `repeat(${cols}, 1fr)`}}>
|
|
15
|
+
{children}
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default GridLayout;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { CSSProperties, ReactNode } from "react";
|
|
4
|
+
|
|
5
|
+
interface HPanelProps {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
gap?: number | string; // spacing between items
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
className?: string;
|
|
10
|
+
alignItems?: CSSProperties["alignItems"]; // flex alignment
|
|
11
|
+
justifyContent?: CSSProperties["justifyContent"];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const HPanel: React.FC<HPanelProps> = ({ children, gap = 0, style, className, alignItems = "center", justifyContent = "flex-start" }) => {
|
|
15
|
+
const panelStyle: CSSProperties = {
|
|
16
|
+
display: "flex",
|
|
17
|
+
flexDirection: "row",
|
|
18
|
+
gap: gap,
|
|
19
|
+
alignItems,
|
|
20
|
+
justifyContent,
|
|
21
|
+
...style,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div style={panelStyle} className={className}>
|
|
26
|
+
{children}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default HPanel;
|