@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,188 @@
1
+ import { useRef, useState, useCallback, useEffect } from "react";
2
+ import Editor from "@monaco-editor/react";
3
+ import UIComponent from "../common/UIComponent";
4
+ import useUIInput, { UIInputProps } from "../common/UIInput";
5
+ //import CopyButton from "../ui/CopyButton";
6
+
7
+ type CodeEditorType = "sql" | "json" | "java" | "javascript" | "html" | "css" | "typescript" | "xml" | "yaml" | "markdown" | "plaintext";
8
+
9
+ const languageMap: Record<CodeEditorType, string> = {
10
+ sql: "sql",
11
+ json: "json",
12
+ java: "groovy",
13
+ javascript: "javascript",
14
+ html: "html",
15
+ css: "css",
16
+ typescript: "typescript",
17
+ xml: "xml",
18
+ yaml: "yaml",
19
+ markdown: "markdown",
20
+ plaintext: "plaintext",
21
+ };
22
+
23
+ type CodeEditorProps = UIInputProps & {
24
+ type?: CodeEditorType;
25
+ height?: number | string;
26
+ width?: number | string;
27
+ readOnly?: boolean;
28
+ immediate?: boolean;
29
+ showCopy?: boolean;
30
+ };
31
+
32
+ const CodeEditor = (props: CodeEditorProps) => {
33
+ const {
34
+ type = "plaintext",
35
+ height = 300,
36
+ width = "100%",
37
+ readOnly = false,
38
+ immediate = true,
39
+ showCopy = true,
40
+ } = props ?? {};
41
+
42
+ const editorRef = useRef<any>(null);
43
+ const valueRef = useRef<string>("");
44
+ const [fontSize, setFontSize] = useState(14);
45
+ const [error, setError] = useState("");
46
+
47
+ const language = languageMap[type] ?? type;
48
+
49
+ const onRefresh = () => {
50
+ setEditorValue(getValue());
51
+ };
52
+
53
+ const { initialValue, getValue, setValue } = useUIInput({ ...props, onRefresh });
54
+ valueRef.current = initialValue ?? "";
55
+ const [editorValue, setEditorValue] = useState(valueRef.current);
56
+
57
+ // Font size keyboard shortcuts
58
+ const handleKeyDown = useCallback((e: KeyboardEvent) => {
59
+ if (e.ctrlKey && e.key === "=") {
60
+ e.preventDefault();
61
+ setFontSize((prev) => Math.min(prev + 1, 40));
62
+ }
63
+ if (e.ctrlKey && e.key === "-") {
64
+ e.preventDefault();
65
+ setFontSize((prev) => Math.max(prev - 1, 8));
66
+ }
67
+ if (e.ctrlKey && e.key === "0") {
68
+ e.preventDefault();
69
+ setFontSize(14);
70
+ }
71
+ }, []);
72
+
73
+ useEffect(() => {
74
+ window.addEventListener("keydown", handleKeyDown);
75
+ return () => window.removeEventListener("keydown", handleKeyDown);
76
+ }, [handleKeyDown]);
77
+
78
+ // JSON-specific validation
79
+ const validateJson = (value: string) => {
80
+ if (!value.trim()) {
81
+ setError("");
82
+ return;
83
+ }
84
+ try {
85
+ JSON.parse(value);
86
+ setError("");
87
+ } catch (e: any) {
88
+ setError(e.message);
89
+ }
90
+ };
91
+
92
+ const handleEditorChange = (value?: string) => {
93
+ const safeValue = value ?? "";
94
+ setEditorValue(safeValue);
95
+
96
+ if (type === "json") {
97
+ validateJson(safeValue);
98
+ }
99
+
100
+ if (immediate) {
101
+ setValue(safeValue);
102
+ }
103
+ };
104
+
105
+ const handleEditorDidMount = (editor: any, monaco: any) => {
106
+ editorRef.current = editor;
107
+
108
+ if (type === "json") {
109
+ monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
110
+ validate: true,
111
+ allowComments: false,
112
+ schemas: [],
113
+ enableSchemaRequest: true,
114
+ });
115
+ }
116
+
117
+ editor.updateOptions({
118
+ minimap: { enabled: false },
119
+ fontSize,
120
+ lineNumbers: "on",
121
+ renderWhitespace: "selection",
122
+ folding: true,
123
+ bracketPairColorization: { enabled: true },
124
+ formatOnPaste: true,
125
+ formatOnType: true,
126
+ });
127
+ };
128
+
129
+ // Sync font size if editor already mounted
130
+ useEffect(() => {
131
+ editorRef.current?.updateOptions({ fontSize });
132
+ }, [fontSize]);
133
+
134
+ /*
135
+ //<CopyButton
136
+ // item={editorValue}
137
+ // copySize={15}
138
+ // copiedSize={10}
139
+ // classNameCopied="!px-[15px] !py-[10px]"
140
+ ///>
141
+ */
142
+
143
+ return (
144
+ <UIComponent {...(props ?? {})}>
145
+ <div className="relative w-full bg-white">
146
+ {showCopy && (
147
+ <div className="absolute top-2 right-4 z-50">
148
+ </div>
149
+ )}
150
+ <Editor
151
+ height={height}
152
+ width={width}
153
+ language={language}
154
+ value={editorValue}
155
+ onChange={handleEditorChange}
156
+ onMount={handleEditorDidMount}
157
+ theme="vs-dark"
158
+ options={{
159
+ readOnly,
160
+ domReadOnly: readOnly,
161
+ padding: { top: 10 },
162
+ selectOnLineNumbers: true,
163
+ automaticLayout: true,
164
+ minimap: { enabled: false },
165
+ fontSize,
166
+ wordWrap: "off",
167
+ lineNumbers: "on",
168
+ renderWhitespace: "selection",
169
+ folding: true,
170
+ bracketPairColorization: { enabled: true },
171
+ formatOnPaste: true,
172
+ formatOnType: true,
173
+ scrollBeyondLastLine: false,
174
+ smoothScrolling: true,
175
+ cursorBlinking: "smooth",
176
+ renderLineHighlight: "all",
177
+ scrollbar: { vertical: "visible", horizontal: "visible" },
178
+ }}
179
+ />
180
+ {error && type === "json" && (
181
+ <p className="text-red-500 text-xs mt-1 px-1">{error}</p>
182
+ )}
183
+ </div>
184
+ </UIComponent>
185
+ );
186
+ };
187
+
188
+ export default CodeEditor;
@@ -0,0 +1,9 @@
1
+ import { UIInputProps } from "../common/UIInput";
2
+ type DateProps = UIInputProps & {
3
+ required?: boolean;
4
+ immediate?: boolean;
5
+ min?: string;
6
+ max?: string;
7
+ };
8
+ declare const DateField: (props: DateProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default DateField;
@@ -0,0 +1,140 @@
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 DateField = (props) => {
6
+ const { name, immediate = true, min, max } = props !== null && props !== void 0 ? props : {};
7
+ const [focused, setFocused] = useState(false);
8
+ const [showCalendar, setShowCalendar] = useState(false);
9
+ const inputRef = useRef(null);
10
+ const calendarRef = useRef(null);
11
+ const valueRef = useRef("");
12
+ const className = "border rounded px-2 py-1 w-full";
13
+ const handleFocus = () => {
14
+ setFocused(true);
15
+ };
16
+ const handleBlur = () => {
17
+ if (!immediate) {
18
+ setValue(inputValue);
19
+ }
20
+ setFocused(false);
21
+ };
22
+ const onRefresh = () => {
23
+ setInputValue(getValue());
24
+ };
25
+ const { initialValue, getValue, setValue, binding } = useUIInput(Object.assign(Object.assign({}, props), { onRefresh }));
26
+ valueRef.current = initialValue !== null && initialValue !== void 0 ? initialValue : "";
27
+ const [inputValue, setInputValue] = useState(valueRef.current);
28
+ // Get current date for calendar navigation - use useMemo or direct calculation
29
+ const getCurrentDate = () => {
30
+ if (inputValue && inputValue.match(/^\d{4}-\d{2}-\d{2}$/)) {
31
+ // Parse ISO date string as local date to avoid timezone issues
32
+ const parts = inputValue.split('-');
33
+ const year = parseInt(parts[0], 10);
34
+ const month = parseInt(parts[1], 10) - 1; // Month is 0-indexed
35
+ const day = parseInt(parts[2], 10);
36
+ return new globalThis.Date(year, month, day);
37
+ }
38
+ return new globalThis.Date();
39
+ };
40
+ const [calendarDate, setCalendarDate] = useState(() => getCurrentDate());
41
+ const onChange = (e) => {
42
+ var _a;
43
+ const text = (_a = e.target.value) !== null && _a !== void 0 ? _a : "";
44
+ if (text !== inputValue) {
45
+ valueRef.current = text;
46
+ setInputValue(text);
47
+ // Update calendar date when user types a valid date
48
+ if (text && text.match(/^\d{4}-\d{2}-\d{2}$/)) {
49
+ const parts = text.split('-');
50
+ const year = parseInt(parts[0], 10);
51
+ const month = parseInt(parts[1], 10) - 1;
52
+ const day = parseInt(parts[2], 10);
53
+ setCalendarDate(new globalThis.Date(year, month, day));
54
+ }
55
+ }
56
+ if (immediate) {
57
+ setValue(text);
58
+ }
59
+ };
60
+ const toggleCalendar = () => {
61
+ setShowCalendar(!showCalendar);
62
+ if (!showCalendar) {
63
+ setCalendarDate(getCurrentDate());
64
+ }
65
+ };
66
+ const selectDate = (date) => {
67
+ const dateString = date.toISOString().split("T")[0];
68
+ valueRef.current = dateString;
69
+ setInputValue(dateString);
70
+ setValue(dateString);
71
+ setShowCalendar(false);
72
+ };
73
+ const previousMonth = () => {
74
+ const newDate = new globalThis.Date(calendarDate);
75
+ newDate.setMonth(newDate.getMonth() - 1);
76
+ setCalendarDate(newDate);
77
+ };
78
+ const nextMonth = () => {
79
+ const newDate = new globalThis.Date(calendarDate);
80
+ newDate.setMonth(newDate.getMonth() + 1);
81
+ setCalendarDate(newDate);
82
+ };
83
+ // Generate calendar days
84
+ const generateCalendarDays = () => {
85
+ const year = calendarDate.getFullYear();
86
+ const month = calendarDate.getMonth();
87
+ const firstDay = new globalThis.Date(year, month, 1);
88
+ const lastDay = new globalThis.Date(year, month + 1, 0);
89
+ const startingDayOfWeek = firstDay.getDay();
90
+ const daysInMonth = lastDay.getDate();
91
+ const days = [];
92
+ // Add empty cells for days before month starts
93
+ for (let i = 0; i < startingDayOfWeek; i++) {
94
+ days.push(null);
95
+ }
96
+ // Add days of month
97
+ for (let day = 1; day <= daysInMonth; day++) {
98
+ days.push(new globalThis.Date(year, month, day));
99
+ }
100
+ return days;
101
+ };
102
+ const isSelectedDate = (date) => {
103
+ if (!inputValue || !inputValue.match(/^\d{4}-\d{2}-\d{2}$/))
104
+ return false;
105
+ // Parse ISO date string as local date
106
+ const parts = inputValue.split('-');
107
+ const selectedYear = parseInt(parts[0], 10);
108
+ const selectedMonth = parseInt(parts[1], 10) - 1;
109
+ const selectedDay = parseInt(parts[2], 10);
110
+ return (date.getDate() === selectedDay &&
111
+ date.getMonth() === selectedMonth &&
112
+ date.getFullYear() === selectedYear);
113
+ };
114
+ const isToday = (date) => {
115
+ const today = new globalThis.Date();
116
+ return (date.getDate() === today.getDate() &&
117
+ date.getMonth() === today.getMonth() &&
118
+ date.getFullYear() === today.getFullYear());
119
+ };
120
+ const monthNames = [
121
+ "January", "February", "March", "April", "May", "June",
122
+ "July", "August", "September", "October", "November", "December"
123
+ ];
124
+ const dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
125
+ const calendarDays = generateCalendarDays();
126
+ return (_jsx(UIComponent, Object.assign({}, (props !== null && props !== void 0 ? props : {}), { children: _jsxs("div", { className: "relative", children: [_jsxs("div", { className: "flex gap-1", children: [_jsx("input", { type: "date", ref: inputRef, onChange: onChange, value: inputValue, onFocus: handleFocus, onBlur: handleBlur, className: className, min: min, max: max }), _jsx("button", { type: "button", onClick: toggleCalendar, className: "border rounded px-3 py-1 bg-white hover:bg-gray-50", children: "\uD83D\uDCC5" })] }), showCalendar && (_jsxs("div", { ref: calendarRef, className: "absolute z-10 mt-1 bg-white border rounded shadow-lg p-4", style: { minWidth: "280px" }, children: [_jsxs("div", { className: "flex justify-between items-center mb-4", children: [_jsx("button", { type: "button", onClick: previousMonth, className: "px-2 py-1 hover:bg-gray-100 rounded", children: "\u25C0" }), _jsxs("div", { className: "font-semibold", children: [monthNames[calendarDate.getMonth()], " ", calendarDate.getFullYear()] }), _jsx("button", { type: "button", onClick: nextMonth, className: "px-2 py-1 hover:bg-gray-100 rounded", children: "\u25B6" })] }), _jsx("div", { className: "grid grid-cols-7 gap-1 mb-2", children: dayNames.map((day) => (_jsx("div", { className: "text-center text-xs font-medium text-gray-600 py-1", children: day }, day))) }), _jsx("div", { className: "grid grid-cols-7 gap-1", children: calendarDays.map((date, index) => {
127
+ if (!date) {
128
+ return _jsx("div", { className: "aspect-square" }, index);
129
+ }
130
+ const selected = isSelectedDate(date);
131
+ const today = isToday(date);
132
+ return (_jsx("button", { type: "button", onClick: () => selectDate(date), className: `
133
+ aspect-square flex items-center justify-center rounded text-sm
134
+ ${selected ? "bg-blue-500 text-white font-semibold" : ""}
135
+ ${today && !selected ? "border-2 border-blue-500" : ""}
136
+ ${!selected && !today ? "hover:bg-gray-100" : ""}
137
+ `, children: date.getDate() }, index));
138
+ }) }), _jsx("div", { className: "mt-4 flex justify-end", children: _jsx("button", { type: "button", onClick: () => setShowCalendar(false), className: "px-3 py-1 text-sm border rounded hover:bg-gray-50", children: "Close" }) })] }))] }) })));
139
+ };
140
+ export default DateField;
@@ -0,0 +1,274 @@
1
+ import { useRef, useState } from "react";
2
+ import UIComponent from "../common/UIComponent";
3
+ import useUIInput, { UIInputProps } from "../common/UIInput";
4
+
5
+ type DateProps = UIInputProps & {
6
+ required?: boolean;
7
+ immediate?: boolean;
8
+ min?: string; // ISO date string
9
+ max?: string; // ISO date string
10
+ };
11
+
12
+ const DateField = (props: DateProps) => {
13
+ const { name, immediate = true, min, max } = props ?? {};
14
+ const [focused, setFocused] = useState(false);
15
+ const [showCalendar, setShowCalendar] = useState(false);
16
+ const inputRef = useRef<HTMLInputElement | null>(null);
17
+ const calendarRef = useRef<HTMLDivElement | null>(null);
18
+ const valueRef = useRef<string>("");
19
+ const className = "border rounded px-2 py-1 w-full";
20
+
21
+ const handleFocus = () => {
22
+ setFocused(true);
23
+ };
24
+
25
+ const handleBlur = () => {
26
+ if (!immediate) {
27
+ setValue(inputValue);
28
+ }
29
+ setFocused(false);
30
+ };
31
+
32
+ const onRefresh = () => {
33
+ setInputValue(getValue());
34
+ };
35
+
36
+ const { initialValue, getValue, setValue, binding } = useUIInput({
37
+ ...props,
38
+ onRefresh
39
+ });
40
+
41
+ valueRef.current = initialValue ?? "";
42
+ const [inputValue, setInputValue] = useState(valueRef.current);
43
+
44
+ // Get current date for calendar navigation - use useMemo or direct calculation
45
+ const getCurrentDate = () => {
46
+ if (inputValue && inputValue.match(/^\d{4}-\d{2}-\d{2}$/)) {
47
+ // Parse ISO date string as local date to avoid timezone issues
48
+ const parts = inputValue.split('-');
49
+ const year = parseInt(parts[0], 10);
50
+ const month = parseInt(parts[1], 10) - 1; // Month is 0-indexed
51
+ const day = parseInt(parts[2], 10);
52
+ return new globalThis.Date(year, month, day);
53
+ }
54
+ return new globalThis.Date();
55
+ };
56
+
57
+ const [calendarDate, setCalendarDate] = useState(() => getCurrentDate());
58
+
59
+ const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {
60
+ const text = e.target.value ?? "";
61
+
62
+ if (text !== inputValue) {
63
+ valueRef.current = text;
64
+ setInputValue(text);
65
+
66
+ // Update calendar date when user types a valid date
67
+ if (text && text.match(/^\d{4}-\d{2}-\d{2}$/)) {
68
+ const parts = text.split('-');
69
+ const year = parseInt(parts[0], 10);
70
+ const month = parseInt(parts[1], 10) - 1;
71
+ const day = parseInt(parts[2], 10);
72
+ setCalendarDate(new globalThis.Date(year, month, day));
73
+ }
74
+ }
75
+
76
+ if (immediate) {
77
+ setValue(text);
78
+ }
79
+ };
80
+
81
+ const toggleCalendar = () => {
82
+ setShowCalendar(!showCalendar);
83
+ if (!showCalendar) {
84
+ setCalendarDate(getCurrentDate());
85
+ }
86
+ };
87
+
88
+ const selectDate = (date: globalThis.Date) => {
89
+ const dateString = date.toISOString().split("T")[0];
90
+ valueRef.current = dateString;
91
+ setInputValue(dateString);
92
+ setValue(dateString);
93
+ setShowCalendar(false);
94
+ };
95
+
96
+ const previousMonth = () => {
97
+ const newDate = new globalThis.Date(calendarDate);
98
+ newDate.setMonth(newDate.getMonth() - 1);
99
+ setCalendarDate(newDate);
100
+ };
101
+
102
+ const nextMonth = () => {
103
+ const newDate = new globalThis.Date(calendarDate);
104
+ newDate.setMonth(newDate.getMonth() + 1);
105
+ setCalendarDate(newDate);
106
+ };
107
+
108
+ // Generate calendar days
109
+ const generateCalendarDays = () => {
110
+ const year = calendarDate.getFullYear();
111
+ const month = calendarDate.getMonth();
112
+
113
+ const firstDay = new globalThis.Date(year, month, 1);
114
+ const lastDay = new globalThis.Date(year, month + 1, 0);
115
+ const startingDayOfWeek = firstDay.getDay();
116
+ const daysInMonth = lastDay.getDate();
117
+
118
+ const days: (globalThis.Date | null)[] = [];
119
+
120
+ // Add empty cells for days before month starts
121
+ for (let i = 0; i < startingDayOfWeek; i++) {
122
+ days.push(null);
123
+ }
124
+
125
+ // Add days of month
126
+ for (let day = 1; day <= daysInMonth; day++) {
127
+ days.push(new globalThis.Date(year, month, day));
128
+ }
129
+
130
+ return days;
131
+ };
132
+
133
+ const isSelectedDate = (date: globalThis.Date) => {
134
+ if (!inputValue || !inputValue.match(/^\d{4}-\d{2}-\d{2}$/)) return false;
135
+ // Parse ISO date string as local date
136
+ const parts = inputValue.split('-');
137
+ const selectedYear = parseInt(parts[0], 10);
138
+ const selectedMonth = parseInt(parts[1], 10) - 1;
139
+ const selectedDay = parseInt(parts[2], 10);
140
+
141
+ return (
142
+ date.getDate() === selectedDay &&
143
+ date.getMonth() === selectedMonth &&
144
+ date.getFullYear() === selectedYear
145
+ );
146
+ };
147
+
148
+ const isToday = (date: globalThis.Date) => {
149
+ const today = new globalThis.Date();
150
+ return (
151
+ date.getDate() === today.getDate() &&
152
+ date.getMonth() === today.getMonth() &&
153
+ date.getFullYear() === today.getFullYear()
154
+ );
155
+ };
156
+
157
+ const monthNames = [
158
+ "January", "February", "March", "April", "May", "June",
159
+ "July", "August", "September", "October", "November", "December"
160
+ ];
161
+
162
+ const dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
163
+
164
+ const calendarDays = generateCalendarDays();
165
+
166
+ return (
167
+ <UIComponent {...(props ?? {})}>
168
+ <div className="relative">
169
+ <div className="flex gap-1">
170
+ <input
171
+ type="date"
172
+ ref={inputRef}
173
+ onChange={onChange}
174
+ value={inputValue}
175
+ onFocus={handleFocus}
176
+ onBlur={handleBlur}
177
+ className={className}
178
+ min={min}
179
+ max={max}
180
+ />
181
+ <button
182
+ type="button"
183
+ onClick={toggleCalendar}
184
+ className="border rounded px-3 py-1 bg-white hover:bg-gray-50"
185
+ >
186
+ 📅
187
+ </button>
188
+ </div>
189
+
190
+ {showCalendar && (
191
+ <div
192
+ ref={calendarRef}
193
+ className="absolute z-10 mt-1 bg-white border rounded shadow-lg p-4"
194
+ style={{ minWidth: "280px" }}
195
+ >
196
+ {/* Calendar Header */}
197
+ <div className="flex justify-between items-center mb-4">
198
+ <button
199
+ type="button"
200
+ onClick={previousMonth}
201
+ className="px-2 py-1 hover:bg-gray-100 rounded"
202
+ >
203
+ â—€
204
+ </button>
205
+ <div className="font-semibold">
206
+ {monthNames[calendarDate.getMonth()]} {calendarDate.getFullYear()}
207
+ </div>
208
+ <button
209
+ type="button"
210
+ onClick={nextMonth}
211
+ className="px-2 py-1 hover:bg-gray-100 rounded"
212
+ >
213
+ â–¶
214
+ </button>
215
+ </div>
216
+
217
+ {/* Day Names */}
218
+ <div className="grid grid-cols-7 gap-1 mb-2">
219
+ {dayNames.map((day) => (
220
+ <div
221
+ key={day}
222
+ className="text-center text-xs font-medium text-gray-600 py-1"
223
+ >
224
+ {day}
225
+ </div>
226
+ ))}
227
+ </div>
228
+
229
+ {/* Calendar Days */}
230
+ <div className="grid grid-cols-7 gap-1">
231
+ {calendarDays.map((date, index) => {
232
+ if (!date) {
233
+ return <div key={index} className="aspect-square" />;
234
+ }
235
+
236
+ const selected = isSelectedDate(date);
237
+ const today = isToday(date);
238
+
239
+ return (
240
+ <button
241
+ key={index}
242
+ type="button"
243
+ onClick={() => selectDate(date)}
244
+ className={`
245
+ aspect-square flex items-center justify-center rounded text-sm
246
+ ${selected ? "bg-blue-500 text-white font-semibold" : ""}
247
+ ${today && !selected ? "border-2 border-blue-500" : ""}
248
+ ${!selected && !today ? "hover:bg-gray-100" : ""}
249
+ `}
250
+ >
251
+ {date.getDate()}
252
+ </button>
253
+ );
254
+ })}
255
+ </div>
256
+
257
+ {/* Close Button */}
258
+ <div className="mt-4 flex justify-end">
259
+ <button
260
+ type="button"
261
+ onClick={() => setShowCalendar(false)}
262
+ className="px-3 py-1 text-sm border rounded hover:bg-gray-50"
263
+ >
264
+ Close
265
+ </button>
266
+ </div>
267
+ </div>
268
+ )}
269
+ </div>
270
+ </UIComponent>
271
+ );
272
+ };
273
+
274
+ export default DateField;
@@ -0,0 +1,2 @@
1
+ declare const DayPicker: () => import("react/jsx-runtime").JSX.Element;
2
+ export default DayPicker;
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ const DayPicker = () => {
3
+ return _jsx("div", { children: "DayPicker" });
4
+ };
5
+ export default DayPicker;
@@ -0,0 +1,5 @@
1
+ const DayPicker = () => {
2
+ return <div>DayPicker</div>;
3
+ };
4
+
5
+ export default DayPicker;
@@ -0,0 +1,8 @@
1
+ import { UIInputProps } from "../common/UIInput";
2
+ type HtmlCodeProps = UIInputProps & {
3
+ height?: number | string;
4
+ width?: number | string;
5
+ showCopy?: boolean;
6
+ };
7
+ declare const HtmlCode: (props: HtmlCodeProps) => import("react/jsx-runtime").JSX.Element;
8
+ export default HtmlCode;