@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,205 @@
1
+ import Editor from "@monaco-editor/react";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import CopyButton from "../../lib/components/CopyButton";
5
+ import UIComponent from "../common/UIComponent";
6
+ import useUIInput, { UIInputProps } from "../common/UIInput";
7
+
8
+ type JsonCodeProps = UIInputProps & {
9
+ height?: number | string;
10
+ width?: number | string;
11
+ showCopy?: boolean;
12
+ onParsed?: (value: any) => void;
13
+ };
14
+
15
+ const JsonCode = (props: JsonCodeProps) => {
16
+ const { height = 300, width = "100%", showCopy = true, onParsed } = props ?? {};
17
+
18
+ const pageContext = usePageContext();
19
+ const editorRef = useRef<any>(null);
20
+ const [fontSize, setFontSize] = useState(14);
21
+ const [error, setError] = useState("");
22
+ const [readOnly, setReadOnly] = useState(true);
23
+
24
+ const stringify = (val: any): string => {
25
+ if (val == null) return "";
26
+
27
+ try {
28
+ return typeof val === "string" ? val : JSON.stringify(val, null, 2);
29
+ } catch (error) {
30
+ console.error("Error stringifying value:", error);
31
+ return "";
32
+ }
33
+ };
34
+
35
+ const onRefresh = () => {
36
+ const val = getValue();
37
+ updateValue(val);
38
+ };
39
+
40
+ // Initialize once from pageContext — no buffering
41
+ const { initialValue, getValue, setValue } = useUIInput({ ...props, onRefresh });
42
+
43
+ const [editorValue, setEditorValue] = useState<string | null>(stringify(initialValue));
44
+
45
+ const updateValue = (value: any) => {
46
+ if (error != null && error !== "") {
47
+ // no updating of editor value if there's an error
48
+ return;
49
+ }
50
+
51
+ const strValue = stringify(value);
52
+ let strEditorValue = "";
53
+ try {
54
+ const parsedEditorValue = JSON.parse(editorValue ?? "");
55
+ strEditorValue = stringify(parsedEditorValue);
56
+ } catch (e) {}
57
+
58
+ const matched = strValue === strEditorValue;
59
+ // console.log("updateValue ", { value, strValue, strEditorValue, matched });
60
+
61
+ if (!matched) {
62
+ setEditorValue(strValue);
63
+ }
64
+ };
65
+
66
+ useEffect(() => {
67
+ const unsubscribe = pageContext?.dependsTo("editable", (val: any) => {
68
+ const isEditable = val === true || val === "true";
69
+ setReadOnly(!isEditable);
70
+ setError("");
71
+
72
+ if (!isEditable) {
73
+ const val = getValue();
74
+ updateValue(val);
75
+ }
76
+ });
77
+ return unsubscribe;
78
+ }, []);
79
+
80
+ useEffect(() => {
81
+ return () => {
82
+ // console.log("unmount");
83
+ editorRef.current = null;
84
+ };
85
+ }, []);
86
+
87
+ const handleKeyDown = useCallback((e: KeyboardEvent) => {
88
+ if (e.ctrlKey && e.key === "=") {
89
+ e.preventDefault();
90
+ setFontSize((prev) => Math.min(prev + 1, 40));
91
+ }
92
+ if (e.ctrlKey && e.key === "-") {
93
+ e.preventDefault();
94
+ setFontSize((prev) => Math.max(prev - 1, 8));
95
+ }
96
+ if (e.ctrlKey && e.key === "0") {
97
+ e.preventDefault();
98
+ setFontSize(14);
99
+ }
100
+ }, []);
101
+
102
+ useEffect(() => {
103
+ window.addEventListener("keydown", handleKeyDown);
104
+ return () => window.removeEventListener("keydown", handleKeyDown);
105
+ }, [handleKeyDown]);
106
+
107
+ useEffect(() => {
108
+ editorRef.current?.updateOptions({ fontSize });
109
+ }, [fontSize]);
110
+
111
+ useEffect(() => {
112
+ editorRef.current?.updateOptions({ readOnly, domReadOnly: readOnly });
113
+ }, [readOnly]);
114
+
115
+ const handleEditorChange = (value?: string) => {
116
+ if (readOnly) return;
117
+ const safeValue = value ?? "";
118
+ setEditorValue(safeValue);
119
+
120
+ try {
121
+ const parsed = JSON.parse(safeValue);
122
+ setValue(parsed); // write through to pageContext immediately
123
+ setError("");
124
+ onParsed?.(parsed);
125
+ } catch (e: any) {
126
+ setError(e.message);
127
+ }
128
+ };
129
+
130
+ const handleEditorDidMount = (editor: any, monaco: any) => {
131
+ editorRef.current = editor;
132
+
133
+ try {
134
+ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
135
+ validate: true,
136
+ allowComments: false,
137
+ schemas: [],
138
+ enableSchemaRequest: true,
139
+ });
140
+ } catch (e) {
141
+ console.warn("Monaco JSON diagnostics setup failed:", e);
142
+ }
143
+
144
+ editor.updateOptions({
145
+ minimap: { enabled: false },
146
+ fontSize,
147
+ lineNumbers: "on",
148
+ renderWhitespace: "selection",
149
+ folding: false,
150
+ bracketPairColorization: { enabled: true },
151
+ formatOnPaste: false,
152
+ formatOnType: false,
153
+ });
154
+ };
155
+
156
+ // useEffect(() => {
157
+ // console.log("editor value changed", editorValue, getValue());
158
+ // }, [editorValue]);
159
+
160
+ return (
161
+ <UIComponent {...(props ?? {})}>
162
+ <div className="relative w-full bg-white">
163
+ {showCopy && (
164
+ <div className="absolute top-2 right-4 z-50">
165
+ <CopyButton item={editorValue ?? ""} copySize={15} copiedSize={10} classNameCopied="!px-[15px] !py-[10px]" />
166
+ </div>
167
+ )}
168
+ <Editor
169
+ key="json-code-viewer"
170
+ height={height}
171
+ width={width}
172
+ language="json"
173
+ value={editorValue ?? ""}
174
+ onChange={handleEditorChange}
175
+ onMount={handleEditorDidMount}
176
+ theme="vs-dark"
177
+ options={{
178
+ readOnly,
179
+ domReadOnly: readOnly,
180
+ padding: { top: 10 },
181
+ selectOnLineNumbers: true,
182
+ automaticLayout: true,
183
+ minimap: { enabled: false },
184
+ fontSize,
185
+ wordWrap: "off",
186
+ lineNumbers: "on",
187
+ renderWhitespace: "selection",
188
+ folding: false,
189
+ bracketPairColorization: { enabled: true },
190
+ formatOnType: false,
191
+ formatOnPaste: false,
192
+ scrollBeyondLastLine: false,
193
+ smoothScrolling: true,
194
+ cursorBlinking: "smooth",
195
+ renderLineHighlight: "all",
196
+ scrollbar: { vertical: "visible", horizontal: "visible" },
197
+ }}
198
+ />
199
+ {error && !readOnly && <p className="text-red-500 text-xs mt-1 px-1">{error}</p>}
200
+ </div>
201
+ </UIComponent>
202
+ );
203
+ };
204
+
205
+ export default JsonCode;
@@ -0,0 +1,2 @@
1
+ declare const MonthPicker: () => import("react/jsx-runtime").JSX.Element;
2
+ export default MonthPicker;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const MonthPicker = () => {
3
+ return _jsx("div", { children: "MonthPicker" });
4
+ };
5
+ export default MonthPicker;
@@ -0,0 +1,5 @@
1
+ const MonthPicker = () => {
2
+ return <div>MonthPicker</div>;
3
+ };
4
+
5
+ export default MonthPicker;
@@ -0,0 +1,8 @@
1
+ import { UIInputProps } from "../common/UIInput";
2
+ type ScriptCodeProps = UIInputProps & {
3
+ height?: number | string;
4
+ width?: number | string;
5
+ showCopy?: boolean;
6
+ };
7
+ declare const ScriptCode: (props: ScriptCodeProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default ScriptCode;
@@ -0,0 +1,153 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Editor from "@monaco-editor/react";
3
+ import { useCallback, useEffect, useRef, useState } from "react";
4
+ import { usePageContext } from "../../core/PageContext";
5
+ import CopyButton from "../../lib/components/CopyButton";
6
+ import UIComponent from "../common/UIComponent";
7
+ import useUIInput from "../common/UIInput";
8
+ const ScriptCode = (props) => {
9
+ const { height = 300, width = "100%", showCopy = true } = props !== null && props !== void 0 ? props : {};
10
+ const pageContext = usePageContext();
11
+ const editorRef = useRef(null);
12
+ const [fontSize, setFontSize] = useState(14);
13
+ const [error, setError] = useState("");
14
+ const [readOnly, setReadOnly] = useState(true);
15
+ const onRefresh = () => {
16
+ const val = getValue();
17
+ setEditorValue(val !== null && val !== void 0 ? val : "");
18
+ };
19
+ const { initialValue, getValue, setValue } = useUIInput(Object.assign(Object.assign({}, props), { onRefresh }));
20
+ const [editorValue, setEditorValue] = useState(() => initialValue !== null && initialValue !== void 0 ? initialValue : "");
21
+ useEffect(() => {
22
+ const unsubscribe = pageContext === null || pageContext === void 0 ? void 0 : pageContext.dependsTo("editable", (val) => {
23
+ var _a;
24
+ const isEditable = val === true || val === "true";
25
+ setReadOnly(!isEditable);
26
+ if (!isEditable) {
27
+ setEditorValue((_a = getValue()) !== null && _a !== void 0 ? _a : "");
28
+ setError("");
29
+ }
30
+ });
31
+ return unsubscribe;
32
+ }, []);
33
+ useEffect(() => {
34
+ return () => {
35
+ editorRef.current = null;
36
+ };
37
+ }, []);
38
+ const handleKeyDown = useCallback((e) => {
39
+ if (e.ctrlKey && e.key === "=") {
40
+ e.preventDefault();
41
+ setFontSize((prev) => Math.min(prev + 1, 40));
42
+ }
43
+ if (e.ctrlKey && e.key === "-") {
44
+ e.preventDefault();
45
+ setFontSize((prev) => Math.max(prev - 1, 8));
46
+ }
47
+ if (e.ctrlKey && e.key === "0") {
48
+ e.preventDefault();
49
+ setFontSize(14);
50
+ }
51
+ }, []);
52
+ useEffect(() => {
53
+ window.addEventListener("keydown", handleKeyDown);
54
+ return () => window.removeEventListener("keydown", handleKeyDown);
55
+ }, [handleKeyDown]);
56
+ useEffect(() => {
57
+ var _a;
58
+ (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.updateOptions({ fontSize });
59
+ }, [fontSize]);
60
+ useEffect(() => {
61
+ var _a;
62
+ (_a = editorRef.current) === null || _a === void 0 ? void 0 : _a.updateOptions({ readOnly, domReadOnly: readOnly });
63
+ }, [readOnly]);
64
+ const validateScript = (code) => {
65
+ if (!code.trim()) {
66
+ setError("");
67
+ return;
68
+ }
69
+ const errors = [];
70
+ const lines = code.split("\n");
71
+ let braceCount = 0;
72
+ let parenCount = 0;
73
+ let bracketCount = 0;
74
+ for (let i = 0; i < lines.length; i++) {
75
+ const line = lines[i];
76
+ const lineNum = i + 1;
77
+ for (const char of line) {
78
+ if (char === "{")
79
+ braceCount++;
80
+ if (char === "}")
81
+ braceCount--;
82
+ if (char === "(")
83
+ parenCount++;
84
+ if (char === ")")
85
+ parenCount--;
86
+ if (char === "[")
87
+ bracketCount++;
88
+ if (char === "]")
89
+ bracketCount--;
90
+ }
91
+ if (line.trim().match(/^(let|const|var)\s+\w+\s*=.*[^;{}\s]$/)) {
92
+ errors.push(`Line ${lineNum}: Possible missing semicolon`);
93
+ }
94
+ if (line.includes("console.log") && !line.trim().endsWith(";") && !line.trim().endsWith("{")) {
95
+ errors.push(`Line ${lineNum}: Missing semicolon after console.log`);
96
+ }
97
+ }
98
+ if (braceCount !== 0)
99
+ errors.push(`Unmatched braces: ${braceCount > 0 ? "missing closing" : "missing opening"} brace(s)`);
100
+ if (parenCount !== 0)
101
+ errors.push(`Unmatched parentheses: ${parenCount > 0 ? "missing closing" : "missing opening"}`);
102
+ if (bracketCount !== 0)
103
+ errors.push(`Unmatched brackets: ${bracketCount > 0 ? "missing closing" : "missing opening"}`);
104
+ setError(errors.length > 0 ? errors.join("\n• ") : "");
105
+ };
106
+ const handleEditorChange = (value) => {
107
+ if (readOnly)
108
+ return;
109
+ const safeValue = value !== null && value !== void 0 ? value : "";
110
+ setEditorValue(safeValue);
111
+ setValue(safeValue); // JavaScript is always a string, write through immediately
112
+ validateScript(safeValue);
113
+ };
114
+ const handleEditorDidMount = (editor) => {
115
+ editorRef.current = editor;
116
+ editor.updateOptions({
117
+ minimap: { enabled: false },
118
+ fontSize,
119
+ lineNumbers: "on",
120
+ renderWhitespace: "selection",
121
+ folding: true,
122
+ bracketPairColorization: { enabled: true },
123
+ formatOnPaste: true,
124
+ formatOnType: true,
125
+ });
126
+ };
127
+ return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsxs("div", { className: "relative w-full bg-white", children: [showCopy && (_jsx("div", { className: "absolute top-2 right-4 z-50", children: _jsx(CopyButton, { item: editorValue, copySize: 15, copiedSize: 10, classNameCopied: "!px-[15px] !py-[10px]" }) })), _jsx(Editor, { height: height, width: width, language: "javascript", value: editorValue, onChange: handleEditorChange, onMount: handleEditorDidMount, theme: "vs-dark", options: {
128
+ readOnly,
129
+ domReadOnly: readOnly,
130
+ padding: { top: 10 },
131
+ selectOnLineNumbers: true,
132
+ automaticLayout: true,
133
+ minimap: { enabled: false },
134
+ fontSize,
135
+ wordWrap: "off",
136
+ lineNumbers: "on",
137
+ renderWhitespace: "selection",
138
+ folding: true,
139
+ bracketPairColorization: { enabled: true },
140
+ formatOnPaste: true,
141
+ formatOnType: true,
142
+ scrollBeyondLastLine: false,
143
+ smoothScrolling: true,
144
+ cursorBlinking: "smooth",
145
+ renderLineHighlight: "all",
146
+ autoIndent: "full",
147
+ suggestOnTriggerCharacters: true,
148
+ quickSuggestions: true,
149
+ parameterHints: { enabled: true },
150
+ scrollbar: { vertical: "visible", horizontal: "visible" },
151
+ } }, "script-code-editor"), error && !readOnly && _jsxs("div", { className: "mt-2 text-sm text-red-500 whitespace-pre-wrap", children: ["\u2022 ", error] })] }) })));
152
+ };
153
+ export default ScriptCode;
@@ -0,0 +1,195 @@
1
+ import Editor from "@monaco-editor/react";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { usePageContext } from "../../core/PageContext";
4
+ import CopyButton from "../../lib/components/CopyButton";
5
+ import UIComponent from "../common/UIComponent";
6
+ import useUIInput, { UIInputProps } from "../common/UIInput";
7
+
8
+ type ScriptCodeProps = UIInputProps & {
9
+ height?: number | string;
10
+ width?: number | string;
11
+ showCopy?: boolean;
12
+ };
13
+
14
+ const ScriptCode = (props: ScriptCodeProps) => {
15
+ const { height = 300, width = "100%", showCopy = true } = props ?? {};
16
+
17
+ const pageContext = usePageContext();
18
+ const editorRef = useRef<any>(null);
19
+ const [fontSize, setFontSize] = useState(14);
20
+ const [error, setError] = useState("");
21
+ const [readOnly, setReadOnly] = useState(true);
22
+
23
+ const onRefresh = () => {
24
+ const val = getValue();
25
+ setEditorValue(val ?? "");
26
+ };
27
+
28
+ const { initialValue, getValue, setValue } = useUIInput({ ...props, onRefresh });
29
+
30
+ const [editorValue, setEditorValue] = useState(() => initialValue ?? "");
31
+
32
+ useEffect(() => {
33
+ const unsubscribe = pageContext?.dependsTo("editable", (val: any) => {
34
+ const isEditable = val === true || val === "true";
35
+ setReadOnly(!isEditable);
36
+
37
+ if (!isEditable) {
38
+ setEditorValue(getValue() ?? "");
39
+ setError("");
40
+ }
41
+ });
42
+ return unsubscribe;
43
+ }, []);
44
+
45
+ useEffect(() => {
46
+ return () => {
47
+ editorRef.current = null;
48
+ };
49
+ }, []);
50
+
51
+ const handleKeyDown = useCallback((e: KeyboardEvent) => {
52
+ if (e.ctrlKey && e.key === "=") {
53
+ e.preventDefault();
54
+ setFontSize((prev) => Math.min(prev + 1, 40));
55
+ }
56
+ if (e.ctrlKey && e.key === "-") {
57
+ e.preventDefault();
58
+ setFontSize((prev) => Math.max(prev - 1, 8));
59
+ }
60
+ if (e.ctrlKey && e.key === "0") {
61
+ e.preventDefault();
62
+ setFontSize(14);
63
+ }
64
+ }, []);
65
+
66
+ useEffect(() => {
67
+ window.addEventListener("keydown", handleKeyDown);
68
+ return () => window.removeEventListener("keydown", handleKeyDown);
69
+ }, [handleKeyDown]);
70
+
71
+ useEffect(() => {
72
+ editorRef.current?.updateOptions({ fontSize });
73
+ }, [fontSize]);
74
+
75
+ useEffect(() => {
76
+ editorRef.current?.updateOptions({ readOnly, domReadOnly: readOnly });
77
+ }, [readOnly]);
78
+
79
+ const validateScript = (code: string) => {
80
+ if (!code.trim()) {
81
+ setError("");
82
+ return;
83
+ }
84
+
85
+ const errors: string[] = [];
86
+ const lines = code.split("\n");
87
+
88
+ let braceCount = 0;
89
+ let parenCount = 0;
90
+ let bracketCount = 0;
91
+
92
+ for (let i = 0; i < lines.length; i++) {
93
+ const line = lines[i];
94
+ const lineNum = i + 1;
95
+
96
+ for (const char of line) {
97
+ if (char === "{") braceCount++;
98
+ if (char === "}") braceCount--;
99
+ if (char === "(") parenCount++;
100
+ if (char === ")") parenCount--;
101
+ if (char === "[") bracketCount++;
102
+ if (char === "]") bracketCount--;
103
+ }
104
+
105
+ if (line.trim().match(/^(let|const|var)\s+\w+\s*=.*[^;{}\s]$/)) {
106
+ errors.push(`Line ${lineNum}: Possible missing semicolon`);
107
+ }
108
+
109
+ if (line.includes("console.log") && !line.trim().endsWith(";") && !line.trim().endsWith("{")) {
110
+ errors.push(`Line ${lineNum}: Missing semicolon after console.log`);
111
+ }
112
+ }
113
+
114
+ if (braceCount !== 0) errors.push(`Unmatched braces: ${braceCount > 0 ? "missing closing" : "missing opening"} brace(s)`);
115
+
116
+ if (parenCount !== 0) errors.push(`Unmatched parentheses: ${parenCount > 0 ? "missing closing" : "missing opening"}`);
117
+
118
+ if (bracketCount !== 0) errors.push(`Unmatched brackets: ${bracketCount > 0 ? "missing closing" : "missing opening"}`);
119
+
120
+ setError(errors.length > 0 ? errors.join("\n• ") : "");
121
+ };
122
+
123
+ const handleEditorChange = (value?: string) => {
124
+ if (readOnly) return;
125
+ const safeValue = value ?? "";
126
+ setEditorValue(safeValue);
127
+ setValue(safeValue); // JavaScript is always a string, write through immediately
128
+ validateScript(safeValue);
129
+ };
130
+
131
+ const handleEditorDidMount = (editor: any) => {
132
+ editorRef.current = editor;
133
+
134
+ editor.updateOptions({
135
+ minimap: { enabled: false },
136
+ fontSize,
137
+ lineNumbers: "on",
138
+ renderWhitespace: "selection",
139
+ folding: true,
140
+ bracketPairColorization: { enabled: true },
141
+ formatOnPaste: true,
142
+ formatOnType: true,
143
+ });
144
+ };
145
+
146
+ return (
147
+ <UIComponent {...(props ?? {})}>
148
+ <div className="relative w-full bg-white">
149
+ {showCopy && (
150
+ <div className="absolute top-2 right-4 z-50">
151
+ <CopyButton item={editorValue} copySize={15} copiedSize={10} classNameCopied="!px-[15px] !py-[10px]" />
152
+ </div>
153
+ )}
154
+ <Editor
155
+ key="script-code-editor"
156
+ height={height}
157
+ width={width}
158
+ language="javascript"
159
+ value={editorValue}
160
+ onChange={handleEditorChange}
161
+ onMount={handleEditorDidMount}
162
+ theme="vs-dark"
163
+ options={{
164
+ readOnly,
165
+ domReadOnly: readOnly,
166
+ padding: { top: 10 },
167
+ selectOnLineNumbers: true,
168
+ automaticLayout: true,
169
+ minimap: { enabled: false },
170
+ fontSize,
171
+ wordWrap: "off",
172
+ lineNumbers: "on",
173
+ renderWhitespace: "selection",
174
+ folding: true,
175
+ bracketPairColorization: { enabled: true },
176
+ formatOnPaste: true,
177
+ formatOnType: true,
178
+ scrollBeyondLastLine: false,
179
+ smoothScrolling: true,
180
+ cursorBlinking: "smooth",
181
+ renderLineHighlight: "all",
182
+ autoIndent: "full",
183
+ suggestOnTriggerCharacters: true,
184
+ quickSuggestions: true,
185
+ parameterHints: { enabled: true },
186
+ scrollbar: { vertical: "visible", horizontal: "visible" },
187
+ }}
188
+ />
189
+ {error && !readOnly && <div className="mt-2 text-sm text-red-500 whitespace-pre-wrap">• {error}</div>}
190
+ </div>
191
+ </UIComponent>
192
+ );
193
+ };
194
+
195
+ export default ScriptCode;
@@ -0,0 +1,14 @@
1
+ import { UIInputProps } from "../common/UIInput";
2
+ type SelectOption = {
3
+ label: string;
4
+ value: string;
5
+ };
6
+ type SelectFieldProps = UIInputProps & {
7
+ required?: boolean;
8
+ immediate?: boolean;
9
+ options?: SelectOption[];
10
+ placeholder?: string;
11
+ onChange?: (value: string) => void;
12
+ };
13
+ declare const SelectField: (props: SelectFieldProps) => import("react/jsx-runtime").JSX.Element;
14
+ export default SelectField;
@@ -0,0 +1,40 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useRef, useState } from "react";
3
+ import UIComponent from "../common/UIComponent";
4
+ import useUIInput from "../common/UIInput";
5
+ const SelectField = (props) => {
6
+ const { immediate = true, options = [], placeholder } = props !== null && props !== void 0 ? props : {};
7
+ const [focused, setFocused] = useState(false);
8
+ const selectRef = useRef(null);
9
+ const valueRef = useRef("");
10
+ const className = "border rounded px-2 py-1 w-full";
11
+ const handleFocus = () => {
12
+ setFocused(true);
13
+ };
14
+ const handleBlur = () => {
15
+ if (!immediate) {
16
+ setValue(selectValue);
17
+ }
18
+ setFocused(false);
19
+ };
20
+ const onRefresh = () => {
21
+ setSelectValue(getValue());
22
+ };
23
+ const { initialValue, getValue, setValue, binding } = useUIInput(Object.assign(Object.assign({}, props), { onRefresh }));
24
+ valueRef.current = initialValue !== null && initialValue !== void 0 ? initialValue : "";
25
+ const [selectValue, setSelectValue] = useState(valueRef.current);
26
+ const onChange = (e) => {
27
+ var _a, _b;
28
+ const text = (_a = e.target.value) !== null && _a !== void 0 ? _a : "";
29
+ if (text !== selectValue) {
30
+ valueRef.current = text;
31
+ setSelectValue(valueRef.current);
32
+ }
33
+ if (immediate) {
34
+ setValue(text);
35
+ }
36
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, text);
37
+ };
38
+ return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsxs("select", { ref: selectRef, onChange: onChange, value: selectValue, onFocus: handleFocus, onBlur: handleBlur, className: className, children: [placeholder && (_jsx("option", { value: "", disabled: true, children: placeholder })), options.map((opt) => (_jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }) })));
39
+ };
40
+ export default SelectField;