tp-react-elements-dev 1.12.20 → 1.12.22

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 (118) hide show
  1. package/dist/components/DeleteComponent/DeleteField.js +24 -0
  2. package/dist/components/Form/Form.styles.js +111 -0
  3. package/dist/components/Form/FormActiveSwitch.js +27 -0
  4. package/dist/components/Form/FormConstants.d.ts +1 -1
  5. package/dist/components/Form/FormConstants.d.ts.map +1 -1
  6. package/dist/components/Form/FormConstants.js +336 -0
  7. package/dist/components/Form/FormRender.d.ts +1 -1
  8. package/dist/components/Form/FormRender.d.ts.map +1 -1
  9. package/dist/components/Form/FormRender.js +96 -0
  10. package/dist/components/Form/FormRenderWrapper.d.ts +1 -1
  11. package/dist/components/Form/FormRenderWrapper.d.ts.map +1 -1
  12. package/dist/components/Form/FormRenderWrapper.js +13 -0
  13. package/dist/components/FormComponents/DatePicker/DateRangePicker.d.ts +1 -1
  14. package/dist/components/FormComponents/DatePicker/DateRangePicker.d.ts.map +1 -1
  15. package/dist/components/FormComponents/DatePicker/DatepickerWrapperV2.d.ts +1 -1
  16. package/dist/components/FormComponents/DatePicker/DatepickerWrapperV2.d.ts.map +1 -1
  17. package/dist/components/FormComponents/DatePicker/DatepickerWrapperV2.js +58 -0
  18. package/dist/components/FormComponents/DatePicker/MonthPicker.d.ts.map +1 -1
  19. package/dist/components/FormComponents/DatePicker/MonthPicker.js +48 -0
  20. package/dist/components/FormComponents/DatePicker/Monthpickerrender.d.ts +1 -1
  21. package/dist/components/FormComponents/DatePicker/Monthpickerrender.d.ts.map +1 -1
  22. package/dist/components/FormComponents/DatePicker/Monthpickerrender.js +61 -0
  23. package/dist/components/FormComponents/FileUpload/FormRenderFileUpload.d.ts +1 -1
  24. package/dist/components/FormComponents/FileUpload/FormRenderFileUpload.d.ts.map +1 -1
  25. package/dist/components/FormComponents/FileUpload/FormRenderFileUpload.js +86 -0
  26. package/dist/components/FormComponents/FileUpload/FormRenderMultiFileUpload.d.ts +1 -1
  27. package/dist/components/FormComponents/FileUpload/FormRenderMultiFileUpload.d.ts.map +1 -1
  28. package/dist/components/FormComponents/FileUpload/FormRenderMultiFileUpload.js +96 -0
  29. package/dist/components/FormComponents/FormBottomField/FormBottomField.d.ts +1 -1
  30. package/dist/components/FormComponents/FormBottomField/FormBottomField.d.ts.map +1 -1
  31. package/dist/components/FormComponents/FormBottomField/FormBottomField.js +9 -0
  32. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.d.ts +1 -1
  33. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.d.ts.map +1 -1
  34. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.js +10 -0
  35. package/dist/components/FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.d.ts +1 -1
  36. package/dist/components/FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.d.ts.map +1 -1
  37. package/dist/components/FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.js +23 -0
  38. package/dist/components/FormComponents/FormErrorField/FormErrorField.d.ts +1 -1
  39. package/dist/components/FormComponents/FormErrorField/FormErrorField.d.ts.map +1 -1
  40. package/dist/components/FormComponents/FormErrorField/FormErrorField.js +9 -0
  41. package/dist/components/FormComponents/FormNumberField/FormNumberField.d.ts +1 -1
  42. package/dist/components/FormComponents/FormNumberField/FormNumberField.d.ts.map +1 -1
  43. package/dist/components/FormComponents/FormNumberField/FormNumberField.js +49 -0
  44. package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.d.ts +1 -1
  45. package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.d.ts.map +1 -1
  46. package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.js +45 -0
  47. package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.d.ts +1 -1
  48. package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.d.ts.map +1 -1
  49. package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.js +26 -0
  50. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.d.ts +1 -1
  51. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.d.ts.map +1 -1
  52. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.js +31 -0
  53. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.styles.js +35 -0
  54. package/dist/components/FormComponents/FormTextField/FormTextField.d.ts +1 -1
  55. package/dist/components/FormComponents/FormTextField/FormTextField.d.ts.map +1 -1
  56. package/dist/components/FormComponents/FormTextField/FormTextField.js +46 -0
  57. package/dist/components/FormComponents/FormTextField/FormTextField.styles.js +22 -0
  58. package/dist/components/FormComponents/HelperText/HelperText.d.ts +1 -1
  59. package/dist/components/FormComponents/HelperText/HelperText.d.ts.map +1 -1
  60. package/dist/components/FormComponents/HelperText/HelperText.js +10 -0
  61. package/dist/components/FormComponents/PasswordField/PasswordField.d.ts +1 -1
  62. package/dist/components/FormComponents/PasswordField/PasswordField.d.ts.map +1 -1
  63. package/dist/components/FormComponents/PasswordField/PasswordField.js +49 -0
  64. package/dist/components/FormComponents/RichTextEditor/RichTextEditor.d.ts +1 -1
  65. package/dist/components/FormComponents/RichTextEditor/RichTextEditor.d.ts.map +1 -1
  66. package/dist/components/FormComponents/RichTextEditor/RichTextEditor.js +95 -0
  67. package/dist/components/FormComponents/RichTextEditor/RichTextEditorWrapper.d.ts +1 -1
  68. package/dist/components/FormComponents/RichTextEditor/RichTextEditorWrapper.d.ts.map +1 -1
  69. package/dist/components/FormComponents/RichTextEditor/RichTextEditorWrapper.js +11 -0
  70. package/dist/components/FormComponents/RichTextEditor/jodit.index.js +27 -0
  71. package/dist/components/FormComponents/Select/MultiSelectv1.d.ts +1 -1
  72. package/dist/components/FormComponents/Select/MultiSelectv1.d.ts.map +1 -1
  73. package/dist/components/FormComponents/Select/MultiSelectv1.js +157 -0
  74. package/dist/components/FormComponents/Select/SingleSelect.d.ts +1 -1
  75. package/dist/components/FormComponents/Select/SingleSelect.d.ts.map +1 -1
  76. package/dist/components/FormComponents/Select/SingleSelect.js +51 -0
  77. package/dist/components/FormComponents/Select/SingleSelectNonAutoComplete.d.ts +1 -1
  78. package/dist/components/FormComponents/Select/SingleSelectNonAutoComplete.d.ts.map +1 -1
  79. package/dist/components/FormComponents/Select/SingleSelectNonAutoComplete.js +27 -0
  80. package/dist/components/FormComponents/Select/SingleSelectSearchApi.js +204 -0
  81. package/dist/components/FormComponents/TimePicker/TimePicker.d.ts +1 -1
  82. package/dist/components/FormComponents/TimePicker/TimePicker.d.ts.map +1 -1
  83. package/dist/components/FormComponents/TimePicker/TimePicker.js +55 -0
  84. package/dist/components/FormComponents/YearPickerField/YearPickerField.js +82 -0
  85. package/dist/components/FormComponents/index.js +26 -0
  86. package/dist/components/Global.styles.js +79 -0
  87. package/dist/components/ModalField/ConfirmationDialog.js +48 -0
  88. package/dist/components/ModalField/ModalField.js +32 -0
  89. package/dist/components/SelectField/MultiSelectFieldComponent.js +129 -0
  90. package/dist/components/SessionTimeOut/SessionTimeOut.js +63 -0
  91. package/dist/index.d.ts +3 -3
  92. package/dist/index.d.ts.map +1 -1
  93. package/dist/index.js +16 -2673
  94. package/dist/lib/Constants/FormConstants.d.ts.map +1 -0
  95. package/dist/lib/Constants/FormConstants.js +54 -0
  96. package/dist/lib/Constants/FunctionConstants.d.ts.map +1 -0
  97. package/dist/lib/Constants/FunctionConstants.js +244 -0
  98. package/dist/{Utilities → lib}/Interface/FormInterface.d.ts +0 -1
  99. package/dist/lib/Interface/FormInterface.d.ts.map +1 -0
  100. package/dist/lib/index.d.ts +3 -2
  101. package/dist/lib/index.d.ts.map +1 -1
  102. package/dist/lib/index.js +4 -0
  103. package/dist/theme/index.js +64 -0
  104. package/dist/validation/schemas.js +60 -0
  105. package/package.json +6 -5
  106. package/dist/Utilities/Constants/FormConstants.d.ts.map +0 -1
  107. package/dist/Utilities/Constants/FunctionConstants.d.ts.map +0 -1
  108. package/dist/Utilities/Interface/FormInterface.d.ts.map +0 -1
  109. package/dist/Utilities/index.d.ts +0 -4
  110. package/dist/Utilities/index.d.ts.map +0 -1
  111. package/dist/index.esm.css +0 -1
  112. package/dist/index.esm.js +0 -2632
  113. package/dist/lib/constants.d.ts +0 -2
  114. package/dist/lib/constants.d.ts.map +0 -1
  115. package/dist/lib/hook-form.d.ts +0 -4
  116. package/dist/lib/hook-form.d.ts.map +0 -1
  117. /package/dist/{Utilities → lib}/Constants/FormConstants.d.ts +0 -0
  118. /package/dist/{Utilities → lib}/Constants/FunctionConstants.d.ts +0 -0
package/dist/index.js CHANGED
@@ -1,2673 +1,16 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var material = require('@mui/material');
5
- var CloseIcon = require('@mui/icons-material/Close');
6
- var styled = require('@emotion/styled');
7
- var React = require('react');
8
- var Yup = require('yup');
9
- var styles = require('@mui/material/styles');
10
- var react = require('@emotion/react');
11
- var ArrowDropDownSharpIcon = require('@mui/icons-material/ArrowDropDownSharp');
12
- var Container = require('@mui/material/Container');
13
- var xDatePickers = require('@mui/x-date-pickers');
14
- var AdapterDayjs = require('@mui/x-date-pickers/AdapterDayjs');
15
- var dayjs = require('dayjs');
16
- var reactHookForm = require('react-hook-form');
17
- var errorMessage = require('@hookform/error-message');
18
- var DatePicker = require('@mui/x-date-pickers/DatePicker');
19
- var iconsMaterial = require('@mui/icons-material');
20
- var JoditEditor = require('jodit-react');
21
- var jodit = require('jodit');
22
- var Checkbox = require('@mui/material/Checkbox');
23
- var FormControl = require('@mui/material/FormControl');
24
- var InputLabel = require('@mui/material/InputLabel');
25
- var ListItemText = require('@mui/material/ListItemText');
26
- var MenuItem = require('@mui/material/MenuItem');
27
- var OutlinedInput = require('@mui/material/OutlinedInput');
28
- var Select = require('@mui/material/Select');
29
- var LocalizationProvider = require('@mui/x-date-pickers/LocalizationProvider');
30
- var TimePicker = require('@mui/x-date-pickers/TimePicker');
31
- var reactIdleTimer = require('react-idle-timer');
32
- var XLSX = require('xlsx-js-style');
33
- var fileSaver = require('file-saver');
34
- require('crypto-js');
35
-
36
- function _interopNamespaceDefault(e) {
37
- var n = Object.create(null);
38
- if (e) {
39
- Object.keys(e).forEach(function (k) {
40
- if (k !== 'default') {
41
- var d = Object.getOwnPropertyDescriptor(e, k);
42
- Object.defineProperty(n, k, d.get ? d : {
43
- enumerable: true,
44
- get: function () { return e[k]; }
45
- });
46
- }
47
- });
48
- }
49
- n.default = e;
50
- return Object.freeze(n);
51
- }
52
-
53
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
54
- var Yup__namespace = /*#__PURE__*/_interopNamespaceDefault(Yup);
55
- var XLSX__namespace = /*#__PURE__*/_interopNamespaceDefault(XLSX);
56
-
57
- styled(material.Button) `
58
- border: 0;
59
- color: #fff;
60
- position: absolute;
61
- text-align: center;
62
- padding: 5px 12px;
63
- font-size: 13px;
64
- height: 30px;
65
- right: -38px;
66
- text-transform: none;
67
- z-index: 2;
68
- border-radius: 10px 0px 0px 10px;
69
- &:hover {
70
- right: 0px;
71
- }
72
- `;
73
- const SubmitButton = styled(material.Button) `
74
- text-transform: none;
75
- `;
76
- const CancelButton = styled(material.Button) `
77
- text-transform: none;
78
- color: #000;
79
- background: #ececee;
80
- &:hover {
81
- background: #0009;
82
- color: #fff;
83
- }
84
- `;
85
- const SaveAsDraftButton = styled(material.Button) `
86
- text-transform: none;
87
- font-size: 12px;
88
- background: orange;
89
- &:hover {
90
- background: orange;
91
- }
92
- `;
93
- styled(material.Typography) ``;
94
- styled(material.Grid, {
95
- shouldForwardProp: (prop) => prop !== "isActive" && prop !== "noOfColumn",
96
- }) `
97
- flex-direction: column;
98
- margin-bottom: 8px;
99
- min-width: 10%;
100
- padding-left: 0px;
101
- z-index: 2;
102
- padding-right: 0px;
103
- border: 1px solid #0003;
104
- font-size: 12px;
105
- padding: 6px;
106
- text-align: center;
107
- &:hover {
108
- cursor: pointer;
109
- }
110
- `;
111
- const DialogContainer = styled(material.Dialog) `
112
- position: fixed;
113
- top: -16px;
114
- left: 0;
115
- right: 0;
116
- bottom: auto;
117
- & .css-tlc64q-MuiPaper-root-MuiDialog-paper,
118
- .css-mbdu2s {
119
- max-width: 900px;
120
- }
121
- `;
122
- const DialogTitleWrapper = styled(material.DialogTitle) `
123
- padding: 8px 16px;
124
- display: flex;
125
- align-items: center;
126
- justify-content: space-between;
127
- font-size: 14px;
128
- cursor: move;
129
- border-bottom: 1px solid rgb(229 231 235 / 1);
130
- `;
131
-
132
- const ConfirmationDialog = ({ openConfirmDialog, handleCancel, onClickSubmit, text, Submit = "Submit", Cancel = "Cancel", buttonStyleProps, }) => {
133
- return (jsxRuntime.jsxs(material.Dialog, { open: openConfirmDialog, TransitionComponent: material.Slide, fullWidth: true, sx: {
134
- position: "fixed",
135
- top: "10%",
136
- left: 0,
137
- right: 0,
138
- bottom: "auto",
139
- "& .css-tlc64q-MuiPaper-root-MuiDialog-paper,.css-mbdu2s": {
140
- maxWidth: "500px",
141
- },
142
- zIndex: 40,
143
- }, "aria-labelledby": "draggable-dialog-title", children: [jsxRuntime.jsxs(material.DialogTitle, { sx: {
144
- // background: theme.palette.primary.main,
145
- // color: "#fff",
146
- padding: "8px 16px",
147
- display: "flex",
148
- alignItems: "center",
149
- justifyContent: "space-between",
150
- // fontFamily: "Roboto",
151
- fontSize: "14px",
152
- cursor: "move",
153
- borderBottom: "1px solid rgb(229 231 235 / 1)",
154
- }, children: [jsxRuntime.jsx("span", { children: "Confirmation Dailog" }), jsxRuntime.jsx(CloseIcon, { sx: { cursor: "pointer" }, onClick: () => handleCancel() })] }), jsxRuntime.jsxs(material.DialogContent, { style: { paddingTop: "20px", paddingBottom: 0 }, sx: {
155
- "& .pt-0": {
156
- paddingTop: 0,
157
- },
158
- }, children: [jsxRuntime.jsx(material.Typography, { children: text }), jsxRuntime.jsx(material.Grid, { container: true, gap: 3 })] }), jsxRuntime.jsx(material.DialogActions, { sx: { borderTop: "1px solid #e0e0e0", marginTop: 3 }, children: jsxRuntime.jsxs("div", { style: {
159
- display: "flex",
160
- justifyContent: "flex-end",
161
- gap: "8px",
162
- }, children: [jsxRuntime.jsx(SubmitButton, { variant: "contained", size: "small", type: "submit", onClick: () => onClickSubmit(), sx: {
163
- ...buttonStyleProps,
164
- }, children: Submit }), jsxRuntime.jsx(material.Button, { variant: "text",
165
- // color="error"
166
- size: "small", sx: {
167
- textTransform: "none",
168
- color: "#000",
169
- background: "#ececee",
170
- ":hover": { background: "#0009", color: "#fff" },
171
- }, onClick: () => handleCancel(), children: Cancel })] }) })] }));
172
- };
173
-
174
- const DeleteField = ({ onClickFn, tooltip = "Delete", text }) => {
175
- const [openDialog, setOpenDialog] = React.useState(false);
176
- const handleCancel = () => {
177
- setOpenDialog(false);
178
- };
179
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Tooltip, { title: jsxRuntime.jsx(material.Typography, { sx: { fontSize: "8px" }, children: tooltip }), children: jsxRuntime.jsx(material.Grid, { sx: { ":hover": { cursor: "pointer" } }, onClick: () => {
180
- setOpenDialog(true);
181
- }, children: jsxRuntime.jsx("i", { className: "flaticon-trash", style: {
182
- lineHeight: 1,
183
- fontSize: "11px",
184
- color: "red",
185
- marginTop: "10px",
186
- } }) }) }), jsxRuntime.jsx(ConfirmationDialog, { openConfirmDialog: openDialog, handleCancel: handleCancel, onClickSubmit: () => {
187
- handleCancel();
188
- onClickFn();
189
- }, text: text })] }));
190
- };
191
-
192
- const useFormValidatingContext = (formArray) => {
193
- const initialValues = {};
194
- const validationShape = {};
195
- const renderCustomError = (field) => {
196
- if (field.customValidation) {
197
- validationShape[field.name] = validationShape[field.name].test("custom-check", field.customErrorMessage || "Invalid value", (value) => {
198
- // Call the custom validation function if provided
199
- return field.customValidation ? field.customValidation(value) : true;
200
- });
201
- }
202
- };
203
- formArray.forEach((field) => {
204
- switch (field.inputType) {
205
- case "text":
206
- initialValues[field.name] = "";
207
- if (field.required && field.errorMessage) {
208
- validationShape[field.name] = Yup__namespace.string()
209
- .typeError(field.errorMessage)
210
- .required(field.errorMessage);
211
- renderCustomError(field);
212
- }
213
- renderCustomError(field);
214
- break;
215
- case "rich-text-editor":
216
- initialValues[field.name] = "";
217
- if (field.required && field.errorMessage) {
218
- validationShape[field.name] = Yup__namespace.string()
219
- .typeError(field.errorMessage)
220
- .required(field.errorMessage);
221
- renderCustomError(field);
222
- }
223
- renderCustomError(field);
224
- break;
225
- case "password":
226
- initialValues[field.name] = "";
227
- if (field.required && field.errorMessage) {
228
- validationShape[field.name] = Yup__namespace.string()
229
- .typeError(field.errorMessage)
230
- .required(field.errorMessage);
231
- renderCustomError(field);
232
- }
233
- renderCustomError(field);
234
- break;
235
- case "email":
236
- initialValues[field.name] = "";
237
- if (field.required && field.errorMessage) {
238
- validationShape[field.name] = Yup__namespace.string()
239
- .typeError(`Please enter ${field.label}`)
240
- .required(field.errorMessage)
241
- .test("valid-email", `Please enter valid Email`, (value) => {
242
- return /\@.*\..+/.test(value);
243
- });
244
- renderCustomError(field);
245
- }
246
- else {
247
- validationShape[field.name] = Yup__namespace.string()
248
- .typeError(`Please enter ${field.label}`)
249
- .test("valid-email", `Please enter valid Email`, (value) => {
250
- // Custom validation to check for at least one period after '@'
251
- return !value || /\@.*\..+/.test(value);
252
- });
253
- renderCustomError(field);
254
- }
255
- renderCustomError(field);
256
- break;
257
- case "multiEmail":
258
- initialValues[field.name] = "";
259
- if (field.required && field.errorMessage) {
260
- validationShape[field.name] = Yup__namespace.string()
261
- .typeError(`Please enter ${field.label}`)
262
- .required(field.errorMessage)
263
- .test("valid-email", `Please enter valid Email`, (value) => {
264
- if (!value)
265
- return false;
266
- const emails = value.split(";");
267
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
268
- return emails.every((email) => emailRegex.test(email.trim()));
269
- });
270
- renderCustomError(field);
271
- }
272
- else {
273
- validationShape[field.name] = Yup__namespace.string()
274
- .typeError(`Please enter ${field.label}`)
275
- .test("custom", `Please enter valid Email`, (value) => {
276
- // Custom validation to check for at least one period after '@'
277
- if (!value || value === "") {
278
- return true;
279
- }
280
- else {
281
- const emails = value.split(";");
282
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
283
- return emails.every((email) => emailRegex.test(email.trim()));
284
- }
285
- });
286
- renderCustomError(field);
287
- }
288
- renderCustomError(field);
289
- break;
290
- case "file":
291
- initialValues[field.name] = null;
292
- if (field.required && field.errorMessage) {
293
- validationShape[field.name] = Yup__namespace.mixed()
294
- .test("fileOrString", field?.errorMessage, (value) => {
295
- return (value instanceof File ||
296
- (typeof value === "string" && value.trim() !== ""));
297
- })
298
- .required(field.errorMessage);
299
- renderCustomError(field);
300
- }
301
- renderCustomError(field);
302
- break;
303
- case "multifile":
304
- initialValues[field.name] = null;
305
- if (field.required && field.errorMessage) {
306
- validationShape[field.name] = Yup__namespace.string()
307
- .test("hasAtLeastOneFile", field.errorMessage, (value) => {
308
- if (!value)
309
- return false;
310
- // Split by comma, trim, and filter out empty values
311
- const files = value
312
- .split(",")
313
- .map((f) => f.trim())
314
- .filter((f) => f !== "");
315
- return files.length > 0;
316
- })
317
- .required(field.errorMessage);
318
- renderCustomError(field);
319
- }
320
- renderCustomError(field);
321
- break;
322
- case "number":
323
- initialValues[field.name] = null;
324
- if (field.required && field.errorMessage) {
325
- validationShape[field.name] = Yup__namespace.number()
326
- .nullable()
327
- .typeError(field.errorMessage)
328
- .required(field.errorMessage);
329
- renderCustomError(field);
330
- }
331
- renderCustomError(field);
332
- break;
333
- case "checkbox":
334
- initialValues[field.name] = false;
335
- break;
336
- case "pincode":
337
- initialValues[field.name] = null;
338
- if (field.required && field.errorMessage) {
339
- validationShape[field.name] = Yup__namespace.number()
340
- .nullable()
341
- .typeError(`Please enter PinCode`)
342
- .required(field.errorMessage)
343
- .test("is-six-digits", `Please enter a 6-digit PinCode`, (value) => {
344
- if (value) {
345
- const stringValue = value.toString();
346
- return stringValue.length === 6;
347
- }
348
- return false;
349
- });
350
- renderCustomError(field);
351
- }
352
- renderCustomError(field);
353
- break;
354
- // case "phoneNumber":
355
- // initialValues[field.name] = null;
356
- // if (field.required && field.errorMessage) {
357
- // validationShape[field.name] = Yup.number()
358
- // .nullable()
359
- // .typeError(`Please enter Mobile Number`)
360
- // .required(field.errorMessage)
361
- // .test(
362
- // "is-two-digits",
363
- // `Please enter a 10-digit Mobile Number`,
364
- // (value) => {
365
- // if (value) {
366
- // const stringValue = value.toString();
367
- // return stringValue.length === 2;
368
- // }
369
- // return false;
370
- // }
371
- // );
372
- // renderCustomError(field)
373
- // } else {
374
- // validationShape[field.name] = Yup.number()
375
- // .nullable()
376
- // // .typeError(`Please enter Mobile Number`)
377
- // .test(
378
- // "is-two-digits",
379
- // `Please enter a 10-digit Mobile Number`,
380
- // (value: any) => {
381
- // return !value || value?.toString().length === 2;
382
- // }
383
- // );
384
- // renderCustomError(field)
385
- // }
386
- // break;
387
- case "phoneNumber":
388
- initialValues[field.name] = null;
389
- if (field.required) {
390
- validationShape[field.name] = Yup__namespace.number()
391
- .nullable()
392
- .typeError(`Please enter Mobile Number`)
393
- .required(field.errorMessage)
394
- .test("is-two-digits", `Please enter a 10-digit Mobile Number`, (value) => {
395
- if (value) {
396
- const stringValue = value.toString();
397
- return stringValue.length === 10;
398
- }
399
- return false;
400
- });
401
- renderCustomError(field);
402
- }
403
- else {
404
- validationShape[field.name] = Yup__namespace.string()
405
- .nullable()
406
- .typeError(``)
407
- .test("is-two-digits", `Please enter a 10-digit Mobile Number`, (value) => {
408
- if (value) {
409
- // Custom validation to check for at least one period after '@'
410
- const stringValue = value.toString();
411
- return stringValue.length === 10;
412
- }
413
- return true; // Skip validation if no value is present
414
- });
415
- renderCustomError(field);
416
- }
417
- break;
418
- case "select":
419
- initialValues[field.name] = "";
420
- if (field.required && field.errorMessage) {
421
- validationShape[field.name] = Yup__namespace.string()
422
- .typeError(`Select ${field.label}`)
423
- .required(field.errorMessage);
424
- renderCustomError(field);
425
- }
426
- renderCustomError(field);
427
- break;
428
- case "checkbox-group":
429
- case "radio-group":
430
- initialValues[field.name] = "";
431
- if (field.required && field.errorMessage) {
432
- validationShape[field.name] = Yup__namespace.string()
433
- .typeError(`Select ${field.label}`)
434
- .required(field.errorMessage);
435
- renderCustomError(field);
436
- }
437
- renderCustomError(field);
438
- break;
439
- case "multiselect":
440
- initialValues[field.name] = null;
441
- if (field.required && field.errorMessage) {
442
- validationShape[field.name] = validationShape[field.name] =
443
- Yup__namespace.string()
444
- .typeError(`Select atleast one ${field.label}`)
445
- .required(field.errorMessage);
446
- renderCustomError(field);
447
- }
448
- renderCustomError(field);
449
- break;
450
- case "datepicker":
451
- case "timepicker":
452
- initialValues[field.name] = null;
453
- if (field.required && field.errorMessage) {
454
- validationShape[field.name] = validationShape[field.name] =
455
- Yup__namespace.string()
456
- .typeError(`Select ${field.label}`)
457
- .required(field.errorMessage);
458
- renderCustomError(field);
459
- }
460
- renderCustomError(field);
461
- break;
462
- case "yearpicker":
463
- initialValues[field.name] = null;
464
- if (field.required && field.errorMessage) {
465
- validationShape[field.name] = validationShape[field.name] =
466
- Yup__namespace.string()
467
- .typeError(`Select ${field.label}`)
468
- .required(field.errorMessage);
469
- renderCustomError(field);
470
- }
471
- renderCustomError(field);
472
- break;
473
- case "monthpicker":
474
- initialValues[field.name] = null;
475
- if (field.required && field.errorMessage) {
476
- validationShape[field.name] = validationShape[field.name] =
477
- Yup__namespace.string()
478
- .typeError(`Select ${field.label}`)
479
- .required(field.errorMessage);
480
- renderCustomError(field);
481
- }
482
- renderCustomError(field);
483
- break;
484
- case "toggleSwitch":
485
- initialValues[field.name] = true;
486
- renderCustomError(field);
487
- break;
488
- case "dateRangePicker":
489
- const today = new Date();
490
- const day = String(today.getDate()).padStart(2, "0");
491
- const month = String(today.getMonth() + 1).padStart(2, "0"); // January is 0!
492
- const year = today.getFullYear();
493
- const formattedDate = `${day}/${month}/${year}`;
494
- const threeMonthsAgo = new Date(today);
495
- threeMonthsAgo.setMonth(today.getMonth() - (field.monthSpan ?? 3));
496
- const dayBeforeThreeMonths = String(threeMonthsAgo.getDate()).padStart(2, "0");
497
- const monthBeforeThreeMonths = String(threeMonthsAgo.getMonth() + 1).padStart(2, "0"); // January is 0!
498
- const yearBeforeThreeMonths = threeMonthsAgo.getFullYear();
499
- const formattedDateForThreeMonths = `${dayBeforeThreeMonths}/${monthBeforeThreeMonths}/${yearBeforeThreeMonths}`;
500
- initialValues["FromDate"] = formattedDateForThreeMonths;
501
- initialValues["ToDate"] = formattedDate;
502
- if (field.required && field.errorMessage) {
503
- validationShape[field.name] = validationShape[field.name] =
504
- Yup__namespace.string()
505
- .typeError(`Select ${field.label}`)
506
- .required(field.errorMessage);
507
- renderCustomError(field);
508
- }
509
- renderCustomError(field);
510
- break;
511
- default:
512
- initialValues[field.name] = null; // default value if inputType is not recognized
513
- if (field.required && field.errorMessage) {
514
- validationShape[field.name] = Yup__namespace.mixed().required(field.errorMessage);
515
- renderCustomError(field);
516
- }
517
- renderCustomError(field);
518
- break;
519
- }
520
- });
521
- const validationSchema = Yup__namespace.object().shape(validationShape);
522
- return { validationSchema, initialValues };
523
- };
524
-
525
- const customTheme = styles.createTheme({
526
- breakpoints: {
527
- values: {
528
- xs: 0,
529
- sm: 600,
530
- md: 900,
531
- lg: 1200,
532
- xl: 1536,
533
- },
534
- },
535
- typography: {},
536
- palette: {
537
- // primary: {
538
- // // main: 'linear-gradient(135deg, #6379c3 0%, #546ee5 60%)',
539
- // },
540
- // secondary: {
541
- // main: 'linear-gradient(135deg, #6379c3 0%, #546ee5 60%)',
542
- // },
543
- },
544
- components: {
545
- MuiInputLabel: {
546
- styleOverrides: {
547
- root: {
548
- fontSize: "12px",
549
- },
550
- },
551
- },
552
- MuiInputBase: {
553
- styleOverrides: {
554
- root: {
555
- fontSize: "12px",
556
- input: {
557
- padding: "6.38px 14px",
558
- },
559
- },
560
- },
561
- },
562
- MuiRadio: {
563
- styleOverrides: {
564
- root: {
565
- padding: "4px 4px 0 8px",
566
- },
567
- },
568
- },
569
- MuiSelect: {
570
- styleOverrides: {
571
- select: {
572
- padding: "6.38px 32px 6.38px 14px",
573
- },
574
- },
575
- },
576
- MuiButton: {
577
- styleOverrides: {
578
- root: {
579
- textTransform: "none",
580
- },
581
- },
582
- },
583
- },
584
- });
585
-
586
- var index$2 = /*#__PURE__*/Object.freeze({
587
- __proto__: null,
588
- customTheme: customTheme,
589
- default: customTheme
590
- });
591
-
592
- const FormComponent = styled(material.Grid)(({ theme }) => ({
593
- alignItems: "flex-start",
594
- flexWrap: "wrap",
595
- [theme.breakpoints.down("md")]: {
596
- flexDirection: "column",
597
- },
598
- }));
599
- styled(material.Box)(() => ({
600
- margin: "5px 0px",
601
- fontSize: "11px",
602
- backgroundColor: "#ffff",
603
- padding: "0.5em",
604
- border: "0px solid rgba(0, 0, 0, 0.125)",
605
- boxShadow: "0 1px 15px rgba(0,0,0,.04), 0 1px 6px rgba(0,0,0,.04)",
606
- borderRadius: "0.75rem",
607
- }));
608
- const Formitem = styled(material.Grid, {
609
- shouldForwardProp: (prop) => prop !== "isActive" && prop !== "noOfColumn",
610
- })(({ theme, noOfColumn }) => ({
611
- width: `calc(100%/${noOfColumn})`,
612
- flexDirection: "column",
613
- paddingLeft: "15px",
614
- paddingRight: "15px",
615
- marginBottom: theme.spacing(1),
616
- [theme.breakpoints.down("md")]: {
617
- width: "100%",
618
- },
619
- }));
620
- const ErrorMessageComponent = styled(material.Box)(() => ({
621
- color: "red",
622
- marginTop: "4px",
623
- fontSize: "11px",
624
- fontWeight: 500,
625
- }));
626
- styled(Container)(({ theme }) => ({
627
- [theme.breakpoints.up("sm")]: {
628
- padding: "16px 24px",
629
- },
630
- [theme.breakpoints.up("lg")]: {
631
- paddingLeft: "30px",
632
- paddingRight: "30px",
633
- },
634
- }));
635
- styled(material.Button)(() => ({
636
- color: "#fff",
637
- backgroundColor: "#00acc1",
638
- BorderColor: "#00acc1",
639
- }));
640
- styled(material.Button)(() => ({
641
- color: "#fff",
642
- backgroundColor: " #343a40",
643
- borderColor: "#343a40",
644
- }));
645
- styled(material.Grid)(() => ({
646
- alignItems: "start",
647
- gap: "1px",
648
- }));
649
- styled("text")(() => ({
650
- color: "red",
651
- }));
652
- styled(material.Box)(() => ({
653
- margin: "5px 0px",
654
- backgroundColor: "#ffff",
655
- paddingBlock: "0.5em",
656
- border: "0px solid rgba(0, 0, 0, 0.125)",
657
- boxShadow: "0 1px 15px rgba(0,0,0,.04), 0 1px 6px rgba(0,0,0,.04)",
658
- borderRadius: "0.75rem",
659
- overflow: "hidden",
660
- fontSize: "11px",
661
- }));
662
- styled(xDatePickers.DatePicker)(() => ({
663
- "& .MuiInputBase-input": {
664
- padding: "6.38px 14px",
665
- },
666
- }));
667
- styled(material.MenuItem)(() => ({
668
- fontSize: "11px",
669
- }));
670
- styled(material.Box)(() => ({
671
- maxHeight: "120px",
672
- overflow: "auto",
673
- position: "absolute",
674
- top: "100%",
675
- background: "#fff",
676
- zIndex: 1000,
677
- border: "1px solid #0001",
678
- }));
679
- styled(material.Typography)(() => ({
680
- fontSize: "13px",
681
- background: "#fff",
682
- padding: "5px 13px",
683
- zIndex: 1000,
684
- "&:hover": {
685
- backgroundColor: "#0001",
686
- cursor: "pointer",
687
- },
688
- }));
689
- styled(ArrowDropDownSharpIcon)(() => ({
690
- fontSize: "25px",
691
- position: "absolute",
692
- right: 0,
693
- color: "#0009",
694
- }));
695
-
696
- const renderLabel = (variant, props, showLabel = false) => (variant === "standard" || showLabel) && (jsxRuntime.jsxs("span", { className: "formInputlabel", style: { fontSize: "12px" }, children: [props.item.label, " ", props.item.required && jsxRuntime.jsx("span", { style: { color: "red" }, children: "*" })] }));
697
- function formatDateMonthAndYear(date) {
698
- // Check if date is a string
699
- if (typeof date !== "string") {
700
- throw new TypeError("Expected a string");
701
- }
702
- // Split the date string into month and year
703
- const [month, year] = date.split("/");
704
- // If the month has only one digit, prepend '0' to it
705
- const formattedMonth = month.length === 1 ? "0" + month : month;
706
- // Return the formatted date with day set to '01'
707
- return `${formattedMonth}/01/${year}`;
708
- }
709
- function parseCustomTime(timeString) {
710
- if (!timeString)
711
- return null; // Return null if empty
712
- const [timePart, msPart] = timeString.split(".");
713
- const [hours, minutes, seconds] = timePart.split(":").map(Number);
714
- const milliseconds = msPart
715
- ? Number(parseFloat(`0.${msPart}`).toFixed(3)) * 1000
716
- : 0;
717
- return dayjs()
718
- .hour(hours)
719
- .minute(minutes)
720
- .second(seconds)
721
- .millisecond(milliseconds);
722
- }
723
- /**
724
- * Formats a Day.js object into "HH:mm:ss.SSSSSSS"
725
- */
726
- function formatDayjsToCustomTime(date) {
727
- if (!date || !date.isValid())
728
- return "";
729
- const milliseconds = date.millisecond().toString().padEnd(7, "0");
730
- return `${date.format("HH:mm:ss")}.${milliseconds}`;
731
- }
732
- const extractDate = (inputDateString) => {
733
- const inputDate = new Date(inputDateString);
734
- if (!inputDateString) {
735
- return "";
736
- }
737
- // Extract day, month, and year components
738
- const day = inputDate.getDate();
739
- const month = inputDate.getMonth() + 1; // Months are zero-based
740
- const year = inputDate.getFullYear();
741
- // Format the components as DD/MM/YYYY
742
- const formattedDate = `${day}/${month}/${year}`;
743
- return formattedDate;
744
- };
745
-
746
- const FormErrorField = (props) => {
747
- return (jsxRuntime.jsx(ErrorMessageComponent, { children: jsxRuntime.jsx(errorMessage.ErrorMessage, { errors: props.errors, name: props.item.name }) }));
748
- };
749
-
750
- const HelperText = (props) => {
751
- return props?.item?.helperText ? (jsxRuntime.jsx("span", { style: {
752
- fontSize: "11px",
753
- color: "#3651d3",
754
- }, children: props?.item?.helperText })) : (jsxRuntime.jsx(jsxRuntime.Fragment, {}));
755
- };
756
-
757
- const FormBottomField = (props) => {
758
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(HelperText, { ...props }), jsxRuntime.jsx(FormErrorField, { ...props })] }));
759
- };
760
-
761
- const DatepickerWrapperV2 = ({ props, variant, }) => {
762
- const inputTextRef = React.useRef(null);
763
- const [open, setOpen] = React.useState(false);
764
- const handleToggle = () => {
765
- if (!open) {
766
- inputTextRef.current?.blur();
767
- }
768
- setOpen(!open);
769
- };
770
- const isError = !!props.errors?.[props.item.name];
771
- const isShowBorderError = isError && props.fieldError;
772
- return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(xDatePickers.LocalizationProvider, { dateAdapter: AdapterDayjs.AdapterDayjs, children: [renderLabel(variant, props), jsxRuntime.jsx(xDatePickers.DatePicker, { views: ["month", "year", "day"], label: variant !== "standard"
773
- ? `${props.item.label}${props.item.required ? " *" : ""}`
774
- : "", value: field.value
775
- ? typeof field.value === "string"
776
- ? dayjs(field.value, "DD/MM/YYYY")
777
- : dayjs(field.value)
778
- : null, className: "read-only", format: "DD/MM/YYYY", open: open, onOpen: handleToggle, onClose: handleToggle, minDate: props?.item?.minDate
779
- ? dayjs(props?.item?.minDate, "DD/MM/YYYY")
780
- : undefined, maxDate: props?.item?.maxDate
781
- ? dayjs(props?.item?.maxDate, "DD/MM/YYYY")
782
- : undefined, disabled: props.item.disable || false, onChange: (date) => {
783
- field.onChange(dayjs(date).format("DD/MM/YYYY"));
784
- props?.item?.onChangeFn &&
785
- props?.item?.onChangeFn(dayjs(date).format("DD/MM/YYYY"));
786
- }, slotProps: {
787
- textField: {
788
- onClick: () => handleToggle(),
789
- inputRef: inputTextRef,
790
- onBlur: (e) => {
791
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
792
- },
793
- inputProps: {
794
- input: { cursor: "pointer" },
795
- },
796
- error: isShowBorderError,
797
- sx: {
798
- "& .MuiPickersInputBase-sectionsContainer": {
799
- paddingTop: 1,
800
- paddingBottom: 1,
801
- "& span": {
802
- fontSize: "12px",
803
- },
804
- },
805
- "& .MuiFormLabel-root": {
806
- top: -10,
807
- },
808
- "& .MuiInputLabel-shrink": {
809
- top: 0,
810
- },
811
- },
812
- },
813
- } })] }), jsxRuntime.jsx(FormBottomField, { ...props })] })) }, props.item.name));
814
- };
815
-
816
- const Monthpickerrender = ({ props, variant, }) => {
817
- const ref = React.useRef(null);
818
- const [open, setOpen] = React.useState(false);
819
- const handleToggle = () => {
820
- if (!open) {
821
- ref.current?.blur();
822
- }
823
- setOpen(!open);
824
- };
825
- const isError = !!props.errors?.[props.item.name];
826
- const isShowBorderError = isError && props.fieldError;
827
- return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(xDatePickers.LocalizationProvider, { dateAdapter: AdapterDayjs.AdapterDayjs, children: [renderLabel(variant, props), jsxRuntime.jsx(DatePicker.DatePicker, { ref: ref, label: variant !== "standard" &&
828
- `${props.item.label}${props.item.required ? " *" : ""}`, views: ["month", "year"], disabled: props.item.disable, value: field.value
829
- ? dayjs(formatDateMonthAndYear(field.value || null))
830
- : null, slotProps: {
831
- textField: {
832
- onClick: () => handleToggle(),
833
- inputRef: ref,
834
- error: isShowBorderError,
835
- },
836
- }, disableOpenPicker: props.item.disable, open: open, onOpen: handleToggle, onClose: handleToggle, defaultValue: field.value, onChange: (date) => {
837
- field.onChange(dayjs(date).format("MM/YYYY"));
838
- props.setValue(dayjs(date).format("MM/YYYY"));
839
- }, sx: {
840
- "& .MuiPickersInputBase-sectionsContainer": {
841
- paddingTop: 1,
842
- paddingBottom: 1,
843
- "& span": {
844
- fontSize: "12px",
845
- },
846
- },
847
- "& input": {
848
- paddingRight: "0px !important",
849
- },
850
- "& button": {
851
- paddingLeft: "0px !important",
852
- paddingRight: "0px !important",
853
- },
854
- "& .MuiFormLabel-root": {
855
- top: -10,
856
- },
857
- "& .MuiInputLabel-shrink": {
858
- top: 0,
859
- },
860
- }, minDate: props.item.minDate
861
- ? dayjs(props.item.minDate, "MM/YYYY")
862
- : undefined, maxDate: props.item.maxDate
863
- ? dayjs(props.item.maxDate, "MM/YYYY")
864
- : undefined })] }), props?.item?.helperText && (jsxRuntime.jsxs("span", { style: {
865
- fontSize: "11px",
866
- color: "#3651d3",
867
- }, children: ["(", props?.item?.helperText, ")"] })), jsxRuntime.jsx(FormBottomField, { ...props })] })) }));
868
- };
869
-
870
- const FormRenderFileUpload = ({ props, variant, }) => {
871
- const isError = !!props.errors?.[props.item.name];
872
- const isShowBorderError = isError && props.fieldError;
873
- React.useEffect(() => {
874
- if (props.getValues(props.item.name) === null ||
875
- props.getValues(props.item.name) === undefined) {
876
- const element = document.getElementById(props.item.name);
877
- console.log(element, "elementelement");
878
- if (element) {
879
- element.value = ""; // Ensure it's an input element
880
- }
881
- }
882
- }, [props.getValues(props.item.name)]);
883
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(material.Box, { paddingLeft: "4px", sx: { ...props.item.sx }, children: [props.item?.label && (jsxRuntime.jsx(material.Box, { sx: { fontSize: "10px;" }, children: renderLabel(variant, props, true) })), jsxRuntime.jsx(material.TextField, { type: "file", id: props.item.name, error: isShowBorderError, inputProps: {
884
- accept: props.item.fileType === "excel"
885
- ? ".xls, .xlsx"
886
- : props.item.fileType === "pdf"
887
- ? ".pdf"
888
- : props.item.fileType === "zip"
889
- ? ".zip"
890
- : props.item.fileType === "all"
891
- ? ".pdf,.jpg,.jpeg,.png,.xls,.xlsx,.doc,.docx,.zip"
892
- : "",
893
- }, onChange: (event) => {
894
- const file = event.target?.files[0];
895
- console.log(file, "filefile");
896
- const fileName = file ? file.name : null;
897
- const allowedExtensions = {
898
- excel: ["xls", "xlsx"],
899
- pdf: ["pdf"],
900
- zip: ["zip"],
901
- all: [
902
- "pdf",
903
- "jpg",
904
- "jpeg",
905
- "png",
906
- "xls",
907
- "xlsx",
908
- "doc",
909
- "docx",
910
- "zip",
911
- ],
912
- image: ["jpg", "jpeg", "png"],
913
- };
914
- const fileExtension = fileName
915
- ? fileName.split(".").pop().toLowerCase()
916
- : null;
917
- const validExtensions = props.item.fileType === "excel"
918
- ? allowedExtensions.excel
919
- : props.item.fileType === "pdf"
920
- ? allowedExtensions.pdf
921
- : allowedExtensions.all;
922
- if (props.item?.fileType &&
923
- fileExtension &&
924
- !validExtensions.includes(fileExtension)) {
925
- props.item?.handleFileError
926
- ? props.item?.handleFileError(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`)
927
- : alert(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`);
928
- event.target.value = ""; // Clear the file input\
929
- props.setValue(props.item?.name, null);
930
- props.setValue(props.item?.name + "Name", "");
931
- return;
932
- }
933
- else if (event.target.files[0].size > (props.item.filesize || 20000000)) {
934
- const maxSizeMB = ((props.item.filesize || 20000000) /
935
- (1024 * 1024)).toFixed(2);
936
- props.item?.handleFileError
937
- ? props.item?.handleFileError(`File size should be less than ${maxSizeMB}MB`)
938
- : alert(`File size should be less than ${maxSizeMB}MB`);
939
- event.target.value = ""; // Clear the file input
940
- props.setValue(props.item?.name, null);
941
- props.setValue(props.item?.name + "Name", "");
942
- return;
943
- }
944
- props.setValue(props.item?.name, file);
945
- props.setValue(props.item?.name + "Name", fileName);
946
- }, sx: { width: "100%" } })] }), jsxRuntime.jsx(FormBottomField, { ...props })] }));
947
- };
948
-
949
- const FormRenderMultiFileUpload = ({ props, variant, }) => {
950
- // const getDocument: Document = document;
951
- React.useEffect(() => {
952
- if (props.getValues(props.item.name) === null ||
953
- props.getValues(props.item.name) === undefined) {
954
- const element = document.getElementById(props.item.name);
955
- console.log(element, "elementelement");
956
- if (element) {
957
- element.value = ""; // Ensure it's an input element
958
- }
959
- }
960
- }, [props.getValues(props.item.name)]);
961
- const isError = !!props.errors?.[props.item.name];
962
- const isShowBorderError = isError && props.fieldError;
963
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(material.Box, { paddingLeft: "4px", sx: { ...props.item.sx }, children: [props.item?.label && (jsxRuntime.jsx(material.Box, { sx: { fontSize: "10px;" }, children: renderLabel(variant, props, true) })), jsxRuntime.jsx(material.TextField, { type: "file", id: props.item.name, error: isShowBorderError, inputProps: {
964
- multiple: true,
965
- accept: props.item.fileType === "excel"
966
- ? ".xls,.xlsx"
967
- : props.item.fileType === "pdf"
968
- ? ".pdf"
969
- : props.item.fileType === "image"
970
- ? ".jpg,.jpeg,.png"
971
- : props.item.fileType === "all"
972
- ? ".pdf,.jpg,.jpeg,.png,.xls,.xlsx,.doc,.docx"
973
- : "",
974
- }, onChange: (event) => {
975
- const file = event.target.files;
976
- const fileName = file && file.length > 0
977
- ? Array.from(file)
978
- .map((item) => item.name)
979
- .join(",")
980
- : null;
981
- console.log(file, "filefile", file.length, fileName);
982
- const allowedExtensions = {
983
- excel: ["xls", "xlsx"],
984
- pdf: ["pdf"],
985
- image: ["jpg", "jpeg", "png"],
986
- all: [
987
- "pdf",
988
- "jpg",
989
- "jpeg",
990
- "png",
991
- "xls",
992
- "xlsx",
993
- "doc",
994
- "docx",
995
- "zip",
996
- ],
997
- zip: ["zip"],
998
- };
999
- let fileExtension = null;
1000
- if (fileName) {
1001
- const ext = fileName.split(".").pop();
1002
- if (ext) {
1003
- fileExtension = ext.toLowerCase();
1004
- }
1005
- }
1006
- const validExtensions = props.item.fileType === "excel"
1007
- ? allowedExtensions.excel
1008
- : props.item.fileType === "pdf"
1009
- ? allowedExtensions.pdf
1010
- : props.item.fileType === "image"
1011
- ? allowedExtensions.image
1012
- : allowedExtensions.all;
1013
- if (props.item?.fileType &&
1014
- fileExtension &&
1015
- !validExtensions.includes(fileExtension)) {
1016
- props.item?.handleFileError &&
1017
- props.item?.handleFileError(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`);
1018
- event.target.value = ""; // Clear the file input\
1019
- props.setValue(props.item?.name, null);
1020
- props.setValue(props.item?.name + "Name", "");
1021
- return;
1022
- }
1023
- else if (event.target.files[event.target.files.length - 1].size > 20000000) {
1024
- props.item?.handleFileError &&
1025
- props.item?.handleFileError(`File size should be less than 20MB`);
1026
- event.target.files = null; // Clear the file input
1027
- props.setValue(props.item?.name, null);
1028
- props.setValue(props.item?.name + "File", []);
1029
- return;
1030
- }
1031
- const fileArray = Array.from(file);
1032
- console.log(fileArray, "fileArrayfileArray");
1033
- props.setValue(props.item?.name, fileName);
1034
- props.setValue(props.item?.name + "File", fileArray);
1035
- }, sx: { width: "100%" } })] }), jsxRuntime.jsx(FormBottomField, { ...props })] }));
1036
- };
1037
-
1038
- const FormCheckBox = ({ props, variant: _variant, }) => {
1039
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("span", { className: "formInputlabel", style: { fontSize: "12px" }, children: [props.item.label, " ", props.item.required && jsxRuntime.jsx("span", { style: { color: "red" }, children: "*" })] }), jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsx(material.Checkbox, { ...field, checked: !!field.value, onChange: (e) => field.onChange(e.target.checked), sx: { width: "24px", height: "24px", ...props.item.sx } })) }), jsxRuntime.jsx(FormBottomField, { ...props })] }));
1040
- };
1041
-
1042
- const FormCheckBoxGroup = ({ props, variant, }) => {
1043
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(material.FormControl, { component: "fieldset", children: jsxRuntime.jsx(material.FormGroup, { row: true, children: props.item?.settings &&
1044
- props.item.settings.map((settings, i) => {
1045
- return (jsxRuntime.jsx(reactHookForm.Controller, { name: settings.name, control: props.control, render: ({ field }) => {
1046
- return (jsxRuntime.jsx(material.FormControlLabel, { control: jsxRuntime.jsx(material.Checkbox, { ...field, checked: field.value }), sx: {
1047
- ".MuiCheckbox-root": {
1048
- padding: "6px 2px 6px 8px",
1049
- ".css-imrjgg-MuiButtonBase-root-MuiCheckbox-root": {
1050
- color: "rgb(0, 0, 0) !important",
1051
- },
1052
- },
1053
- }, label: jsxRuntime.jsx(material.Typography, { variant: "subtitle2", fontSize: "11px", fontWeight: "normal !important", children: settings.label }), labelPlacement: "end" }));
1054
- } }, i));
1055
- }) }) }), jsxRuntime.jsx(FormBottomField, { ...props })] }));
1056
- };
1057
-
1058
- const FormNumberField = ({ props, variant, }) => {
1059
- const isError = !!props.errors?.[props.item.name];
1060
- const isShowBorderError = isError && props.fieldError;
1061
- const label = variant !== "standard"
1062
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1063
- : "";
1064
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => {
1065
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(material.TextField, { ...field, size: "small", label: label, error: isShowBorderError, value: props.getValues(props.item.name) || "", defaultValue: props.getValues(props.item.name) || null, onInput: (e) => {
1066
- e.target.value = e.target.value.replace(/[^0-9]/g, "");
1067
- if (e.target.value === "") {
1068
- e.target.value = null;
1069
- }
1070
- props?.item?.onChangeFn &&
1071
- props?.item?.onChangeFn(e.target.value);
1072
- props?.clearErrors && props?.clearErrors(props.item.name);
1073
- }, onBlur: (e) => {
1074
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1075
- }, sx: {
1076
- "& .css-1holvmy,.css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root,.css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
1077
- top: "-10px",
1078
- },
1079
- }, inputProps: {
1080
- pattern: "[0-9]*", // Only allow numbers
1081
- maxLength: props.item.maxLength || 20,
1082
- onInput: (e) => {
1083
- if (props?.item?.donotAllowSpace) {
1084
- const value = e.target.value;
1085
- e.target.value = value.replace(" ", "");
1086
- }
1087
- if (!props?.item?.allowSpecialChars) {
1088
- const value = e.target.value;
1089
- e.target.value = value.replace(/[^a-zA-Z0-9 ]/g, "");
1090
- } // Allow only alphanumeric and space
1091
- if (e.target.value.length === 1 && e.target.value === " ") {
1092
- e.target.value = "";
1093
- }
1094
- props.item.onInputProps && props.item.onInputProps(e);
1095
- },
1096
- }, disabled: props.item.disable }), jsxRuntime.jsx(FormBottomField, { ...props })] }));
1097
- } }, props.item.name) }));
1098
- };
1099
-
1100
- const FormNumberFieldDecimal = ({ props, variant, }) => {
1101
- const fixedLength = props.item.decimalFixedTo || 2;
1102
- const onInput = (e) => {
1103
- // Allow numbers, a single decimal point, and negation in the input
1104
- e.target.value = e.target.value.replace(/[^0-9.-]/g, "");
1105
- // Ensure only one decimal point is present
1106
- const decimalPointCount = e.target.value.split(".").length - 1;
1107
- if (decimalPointCount > 1) {
1108
- e.target.value = e.target.value.slice(0, -1);
1109
- }
1110
- // Ensure only two digits after the decimal point
1111
- const parts = e.target.value.split(".");
1112
- if (parts.length === fixedLength && parts[1].length > fixedLength) {
1113
- e.target.value = `${parts[0]}.${parts[1].slice(0, fixedLength)}`;
1114
- }
1115
- };
1116
- const label = variant !== "standard"
1117
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1118
- : "";
1119
- const isError = !!props.errors?.[props.item.name];
1120
- const isShowBorderError = isError && props.fieldError;
1121
- return (jsxRuntime.jsx(reactHookForm.Controller, { name: props.item.name, control: props.control, disabled: props.item?.disable, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(material.TextField, { type: "text", size: "small", label: label, error: isShowBorderError, ...field, onChange: () => props?.clearErrors && props?.clearErrors(props.item.name), sx: {
1122
- "& input": {
1123
- textAlign: "right",
1124
- },
1125
- "& .css-16hdwvj,.css-1idq7r3-MuiFormLabel-root-MuiInputLabel-root": {
1126
- top: "-5px",
1127
- },
1128
- }, onBlur: (e) => {
1129
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1130
- }, onInput: onInput, InputProps: {
1131
- inputProps: {
1132
- pattern: "[1-9]",
1133
- maxLength: 7,
1134
- },
1135
- } }), jsxRuntime.jsx(FormBottomField, { ...props })] })) }, props.item.name));
1136
- };
1137
-
1138
- const FormRadioGroup = ({ props, variant, }) => {
1139
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(material.FormControl, { component: "fieldset", children: jsxRuntime.jsx(reactHookForm.Controller, { name: props.item.name, control: props.control, render: ({ field }) => (jsxRuntime.jsx(material.RadioGroup, { value: field.value, onChange: (e) => {
1140
- field.onChange(e.target.value); // ✅ update form state
1141
- console.log(e.target.value, "radio value selected");
1142
- props.item.onChangeFn && props.item.onChangeFn(e.target.value); // optional handler
1143
- }, row: true, sx: {
1144
- gap: "8px",
1145
- }, children: props.item?.settings?.map((option, i) => (jsxRuntime.jsx(material.FormControlLabel, { value: option.name, control: jsxRuntime.jsx(material.Radio, { sx: {
1146
- padding: "6px 2px 6px 8px",
1147
- color: "black",
1148
- "&.Mui-checked": {
1149
- color: "#1976d2", // blue when selected
1150
- },
1151
- "& .MuiSvgIcon-root": {
1152
- fontSize: 16, // 🔹 this actually controls the radio icon size
1153
- },
1154
- } }), label: jsxRuntime.jsx(material.Typography, { fontSize: "11px", fontWeight: "normal !important", children: option.label }) }, i))) })) }) }), jsxRuntime.jsx(FormBottomField, { ...props })] }));
1155
- };
1156
-
1157
- const TextAreaField = styled(material.TextField)(() => ({
1158
- "& .css-1holvmy,.css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root, .css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
1159
- top: "-10px",
1160
- },
1161
- "& input": {
1162
- fontSize: "11px",
1163
- },
1164
- "& .css-2rul56-MuiFormLabel-root-MuiInputLabel-root": {
1165
- top: "-10px",
1166
- },
1167
- "& .css-12ciryo-MuiFormLabel-root-MuiInputLabel-root ": {},
1168
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input ": {
1169
- outline: "none",
1170
- border: "1px solid #ced4da", // Add this line to set border to none
1171
- },
1172
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input:focus ": {
1173
- outline: "none",
1174
- border: "none", // Set border to none when input is focused
1175
- },
1176
- "& .css-1y03twt-MuiInputBase-root-MuiOutlinedInput-root": {
1177
- padding: "5px 5px", // Set border to none when input is focused
1178
- fontSize: "11px",
1179
- },
1180
- "& textarea": {
1181
- fontSize: "11px",
1182
- // textTransform:'uppercase'
1183
- maxHeight: "500px !important",
1184
- overflow: "auto",
1185
- },
1186
- }));
1187
-
1188
- const FormTextAreaField = ({ props, variant, }) => {
1189
- const isError = !!props.errors?.[props.item.name];
1190
- const isShowBorderError = isError && props.fieldError;
1191
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(TextAreaField, { multiline: true, size: "small", InputProps: {
1192
- style: {
1193
- border: "none",
1194
- },
1195
- }, sx: {
1196
- ...props.item.sx,
1197
- }, minRows: props.item.minRows || 1, maxRows: props.item.maxRows || 100, placeholder: props.item.placeholder || "Type Something...", ...field, label: variant !== "standard"
1198
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1199
- : "", error: isShowBorderError, value: field.value || "", disabled: props.item.disable, inputProps: {
1200
- onInput: (e) => {
1201
- if (!props?.item?.allowSpecialChars) {
1202
- const value = e.target.value;
1203
- e.target.value = value.replace(/[^a-zA-Z0-9 ]/g, "");
1204
- } // Allow only alphanumeric and space
1205
- if (e.target.value.length === 1 && e.target.value === " ") {
1206
- e.target.value = "";
1207
- }
1208
- },
1209
- } }), jsxRuntime.jsx(FormBottomField, { ...props })] })) }, props.item.name) }));
1210
- };
1211
-
1212
- const FormTextFieldComponent = styled(material.TextField)(() => ({
1213
- "& .css-1holvmy,.css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root, .css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
1214
- top: "-10px",
1215
- },
1216
- "& .css-2rul56-MuiFormLabel-root-MuiInputLabel-root": {
1217
- top: "-10px",
1218
- },
1219
- "& .css-12ciryo-MuiFormLabel-root-MuiInputLabel-root ": {},
1220
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input ": {
1221
- outline: "none",
1222
- border: "1px solid #ced4da", // Add this line to set border to none
1223
- },
1224
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input:focus ": {
1225
- outline: "none",
1226
- border: "none", // Set border to none when input is focused
1227
- },
1228
- }));
1229
-
1230
- const FormTextField = ({ props, variant, }) => {
1231
- const isError = !!props.errors?.[props.item.name];
1232
- const isShowBorderError = isError && props.fieldError;
1233
- const label = variant !== "standard"
1234
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1235
- : "";
1236
- const onInput = (e) => {
1237
- if (props?.item?.donotAllowSpace) {
1238
- const value = e.target.value;
1239
- e.target.value = value.replace(" ", "");
1240
- }
1241
- if (!props?.item?.allowSpecialChars) {
1242
- const value = e.target.value;
1243
- e.target.value = value.replace(/[^a-zA-Z0-9 ]/g, "");
1244
- } // Allow only alphanumeric and space
1245
- if (e.target.value.length === 1 && e.target.value === " ") {
1246
- e.target.value = "";
1247
- }
1248
- props.item.onInputProps && props.item.onInputProps(e);
1249
- };
1250
- return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(FormTextFieldComponent, { ...field, fullWidth: true, error: isShowBorderError, label: label, placeholder: props.item.placeholder || "", InputProps: {
1251
- style: {
1252
- border: "none",
1253
- },
1254
- }, autoComplete: "off", sx: {
1255
- ...props.item.sx,
1256
- }, value: field.value || "", size: "small", disabled: props.item.disable, onBlur: (e) => {
1257
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1258
- }, inputProps: {
1259
- maxLength: props.item.maxLength || 100,
1260
- onInput: onInput,
1261
- onPaste: (e) => {
1262
- if (props.item.doNotAllowPaste) {
1263
- e.preventDefault();
1264
- }
1265
- },
1266
- } }), jsxRuntime.jsx(FormBottomField, { ...props })] })) }, props.item.name));
1267
- };
1268
-
1269
- const PasswordField = ({ props, variant, }) => {
1270
- const [showPassword, setShowPassword] = React.useState(false);
1271
- const handleTogglePasswordVisibility = () => {
1272
- setShowPassword((prevShowPassword) => !prevShowPassword);
1273
- };
1274
- const label = variant !== "standard"
1275
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1276
- : "";
1277
- const isError = !!props.errors?.[props.item.name];
1278
- const isShowBorderError = isError && props.fieldError;
1279
- return (jsxRuntime.jsx(material.Box, { position: "relative", children: jsxRuntime.jsxs(material.FormControl, { fullWidth: true, children: [" ", jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(material.Box, { sx: { position: "relative" }, children: [" ", renderLabel(variant, props), jsxRuntime.jsx(material.TextField, { size: "small", error: isShowBorderError, type: showPassword ? "text" : "password", autoComplete: props.item?.InputProps?.autoComplete || "off", placeholder: props.item.placeholder || "", ...field, label: label, sx: {
1280
- width: "100%",
1281
- "& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy": {
1282
- top: "-8px",
1283
- },
1284
- }, inputProps: {
1285
- maxLength: props.item.maxLength || 100,
1286
- onInput: (e) => {
1287
- props.item.onInputProps && props.item.onInputProps(e);
1288
- },
1289
- onPaste: (e) => {
1290
- if (props.item?.doNotAllowPaste) {
1291
- e.preventDefault();
1292
- }
1293
- },
1294
- }, value: field.value || null, disabled: props.item.disable }), jsxRuntime.jsx(material.IconButton, { sx: {
1295
- position: "absolute",
1296
- right: "14px",
1297
- top: variant === "standard" ? "70%" : "50%",
1298
- transform: "translateY(-50%)",
1299
- width: "25px",
1300
- }, "aria-label": "toggle password visibility", onClick: handleTogglePasswordVisibility, edge: "end", children: showPassword ? (jsxRuntime.jsx(iconsMaterial.Visibility, { sx: {
1301
- fontSize: "12px",
1302
- position: "absolute",
1303
- } })) : (jsxRuntime.jsx(iconsMaterial.VisibilityOff, { sx: {
1304
- fontSize: "12px",
1305
- position: "absolute",
1306
- } })) })] }), jsxRuntime.jsx(FormBottomField, { ...props })] })) })] }) }, props.item.name));
1307
- };
1308
-
1309
- const RichTextEditor = ({ props }) => {
1310
- const editor = React.useRef(null);
1311
- const [content, setContent] = React.useState("");
1312
- const value = props.getValues(props.item.name);
1313
- const config = {
1314
- readonly: false,
1315
- placeholder: props.item.placeholder || "Start typing...",
1316
- statusbar: false,
1317
- removeButtons: props.item.removeButtons,
1318
- style: {
1319
- "font-family": "Arial",
1320
- },
1321
- controls: {
1322
- font: {
1323
- list: {
1324
- Arial: "Arial",
1325
- ...props.item?.FontFamily,
1326
- },
1327
- },
1328
- fontsize: {
1329
- list: jodit.Jodit.atom(props.item.Fonts || [
1330
- 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1331
- 25, 26, 27, 28, 29, 30,
1332
- ]),
1333
- },
1334
- },
1335
- defaultFont: "Arial",
1336
- defaultFontSize: "11px",
1337
- askBeforePasteFromWord: false,
1338
- askBeforePasteHTML: false,
1339
- hotkeys: {
1340
- redo: "ctrl+z",
1341
- undo: "ctrl+y,ctrl+shift+z",
1342
- indent: "ctrl+]",
1343
- outdent: "ctrl+[",
1344
- bold: "ctrl+b",
1345
- italic: "ctrl+i",
1346
- removeFormat: "ctrl+shift+m",
1347
- insertOrderedList: "ctrl+shift+7",
1348
- insertUnorderedList: "ctrl+shift+8",
1349
- openSearchDialog: "ctrl+f",
1350
- openReplaceDialog: "ctrl+r",
1351
- },
1352
- events: {
1353
- processPaste: (_event, html) => {
1354
- const instance = editor.current;
1355
- if (instance?.editor) {
1356
- const joditEditor = instance.editor;
1357
- joditEditor.selection.insertHTML(html);
1358
- joditEditor.tempContent = joditEditor.getHTML();
1359
- }
1360
- },
1361
- afterPaste: () => {
1362
- const instance = editor.current;
1363
- if (instance?.editor) {
1364
- const joditEditor = instance.editor;
1365
- const el = document.createElement("div");
1366
- el.innerHTML = joditEditor.tempContent
1367
- ? joditEditor.tempContent
1368
- : joditEditor.getHTML();
1369
- joditEditor.setHTML(el.innerHTML);
1370
- joditEditor.tempContent = null;
1371
- }
1372
- },
1373
- },
1374
- ...props.item.sx,
1375
- };
1376
- React.useEffect(() => {
1377
- setContent(value);
1378
- }, [value]);
1379
- const handleBlur = (newContent) => {
1380
- if (newContent === "<p><br></p>") {
1381
- setContent(newContent);
1382
- props.setValue(props.item.name, "");
1383
- }
1384
- else {
1385
- setContent(newContent);
1386
- props.setValue(props.item.name, newContent);
1387
- }
1388
- props.item.onBlurFn && props.item.onBlurFn(newContent);
1389
- };
1390
- const handleChange = (newContent) => {
1391
- props.item.onChangeFn && props.item.onChangeFn(newContent);
1392
- };
1393
- return (jsxRuntime.jsx(JoditEditor, { ref: editor, value: content, config: config,
1394
- // tabIndex={1 as IJoditEditorProps["tabIndex"]}
1395
- onBlur: handleBlur, onChange: handleChange }));
1396
- };
1397
-
1398
- const RichTextEditorWrapper = ({ props, variant, }) => {
1399
- return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: () => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(RichTextEditor, { props: props }), jsxRuntime.jsx(FormBottomField, { ...props })] })) }, props.item.name));
1400
- };
1401
-
1402
- const ITEM_HEIGHT$1 = 48;
1403
- const ITEM_PADDING_TOP$1 = 3;
1404
- const MenuProps$1 = {
1405
- PaperProps: {
1406
- style: {
1407
- maxHeight: ITEM_HEIGHT$1 * 5.5 + ITEM_PADDING_TOP$1,
1408
- // width: 250,
1409
- },
1410
- },
1411
- autoFocus: false,
1412
- disableAutoFocusItem: true,
1413
- };
1414
- // const useStyles = makeStyles(() => ({
1415
- // option: {
1416
- // fontSize: "10px", // Adjust the font size as needed
1417
- // },
1418
- // option2: {
1419
- // fontSize: "11px",
1420
- // },
1421
- // }));
1422
- const extractValuesToArray$1 = (inputString) => {
1423
- const valuesArray = inputString?.split(",");
1424
- const trimmedArray = valuesArray?.map((value) => value.trim());
1425
- return trimmedArray;
1426
- };
1427
- function MultiSelectV1({ props, variant, }) {
1428
- const [personName, setPersonName] = React.useState(props.getValues(props.item.name)
1429
- ? extractValuesToArray$1(props.getValues(props.item.name))
1430
- : []);
1431
- const [searchText, setSearchText] = React.useState("");
1432
- const options = props.item?.options || [];
1433
- const [filterOptions, setFilterOptions] = React.useState(props.item.options || []);
1434
- const [selectAll, setSelectAll] = React.useState(false);
1435
- const textfieldRef = React.useRef(null);
1436
- const fieldValue = props.getValues(props.item.name);
1437
- const mappedIds = filterOptions.map((item) => item.value);
1438
- const filterIds = filterOptions.map((item) => item.value);
1439
- React.useEffect(() => {
1440
- if (searchText !== "") {
1441
- setFilterOptions(options.filter((item) => item.label.toLowerCase().includes(searchText.toLowerCase())));
1442
- }
1443
- else {
1444
- setFilterOptions(options);
1445
- }
1446
- }, [options, searchText]);
1447
- function hasExactMatch(array, value) {
1448
- return array.some((item) => item === value);
1449
- }
1450
- React.useEffect(() => {
1451
- if (fieldValue?.split(",").length !== filterOptions.length) {
1452
- setSelectAll(false);
1453
- }
1454
- else {
1455
- console.log(fieldValue?.split(","), 'fieldValue?.split(",")', filterIds);
1456
- if (fieldValue
1457
- ?.split(",")
1458
- .every((value) => hasExactMatch(filterIds, value))) {
1459
- setSelectAll(true);
1460
- }
1461
- }
1462
- }, [filterOptions, fieldValue]);
1463
- const handleChange = (event) => {
1464
- const { target: { value }, } = event;
1465
- setPersonName(typeof value === "string" ? value?.split(",") : value);
1466
- props.setValue(props.item.name, (typeof value === "string" ? value?.split(",") : value).join(","));
1467
- };
1468
- const selectedOptions = options.filter((item) => fieldValue?.split(",").some((value) => value === item.value));
1469
- const selectedValues = selectedOptions
1470
- .map((item) => item.label)
1471
- .join(" , ");
1472
- const isError = !!props.errors?.[props.item.name];
1473
- const isShowBorderError = isError && props.fieldError;
1474
- return (jsxRuntime.jsx(material.Box, { children: jsxRuntime.jsxs(FormControl, { fullWidth: true, sx: {
1475
- "& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy": {
1476
- top: "-10px",
1477
- },
1478
- "& .MuiFormLabel-root": {
1479
- top: -10,
1480
- },
1481
- "& .MuiInputLabel-shrink": {
1482
- top: 0,
1483
- },
1484
- }, children: [renderLabel(variant, props), variant !== "standard" ? (jsxRuntime.jsxs(InputLabel, { error: isShowBorderError, id: "demo-multiple-checkbox-label", children: [props.item.label, props.item.required ? " *" : ""] })) : (""), jsxRuntime.jsxs(Select, { labelId: "demo-multiple-checkbox-label", id: "demo-multiple-checkbox", multiple: true, sx: {
1485
- "& .MuiTypography-root": {
1486
- fontSize: "5px !important",
1487
- },
1488
- }, error: isShowBorderError, disabled: props.item.disable, value: props.getValues(props.item.name)
1489
- ? extractValuesToArray$1(props.getValues(props.item.name))
1490
- : [], onChange: handleChange, onOpen: () => {
1491
- setTimeout(() => {
1492
- if (textfieldRef.current) {
1493
- textfieldRef.current?.focus();
1494
- }
1495
- }, 0);
1496
- }, onClose: () => {
1497
- setSearchText("");
1498
- props?.item?.onCloseMenu && props?.item?.onCloseMenu();
1499
- }, input: jsxRuntime.jsx(OutlinedInput, { label: variant !== "standard" ? props.item.label : "" }), renderValue: (_selected) => (jsxRuntime.jsx(material.Tooltip, { title: selectedValues, children: jsxRuntime.jsx("span", { children: selectedOptions.length >
1500
- (props.item.multiSelectLabelLength || 3)
1501
- ? `${selectedOptions.length} Selected`
1502
- : selectedValues }) })), MenuProps: MenuProps$1, autoFocus: false, children: [jsxRuntime.jsx(material.Box, { sx: {
1503
- width: "100%",
1504
- position: "sticky",
1505
- top: "0px",
1506
- padding: "7px",
1507
- zIndex: 2,
1508
- height: "33px",
1509
- background: "#fff",
1510
- display: options.length === 0 ? "none" : undefined,
1511
- }, children: jsxRuntime.jsx(material.TextField, { inputRef: textfieldRef, autoFocus: true, value: searchText, sx: {
1512
- width: "100%",
1513
- }, placeholder: "Search...", onChange: (e) => {
1514
- setSearchText(e.target.value);
1515
- }, onKeyDown: (e) => {
1516
- if (e.key !== "Escape") {
1517
- e.stopPropagation();
1518
- }
1519
- } }) }), jsxRuntime.jsxs(MenuItem, { disabled: filterOptions.length === 0, sx: { zIndex: 0, fontSize: "5px !important" }, children: [jsxRuntime.jsx(Checkbox, { size: "small", checked: selectAll, onChange: () => {
1520
- setSelectAll(!selectAll);
1521
- const selectChanged = !selectAll;
1522
- if (!selectChanged) {
1523
- props.setValue(props.item.name, "");
1524
- }
1525
- else {
1526
- const allDataMapped = mappedIds.join(",");
1527
- console.log(allDataMapped, "allDataMapped");
1528
- props.setValue(props.item.name, allDataMapped);
1529
- }
1530
- } }), jsxRuntime.jsx(ListItemText, { primary: "Select All", sx: {
1531
- fontSize: "5px !important",
1532
- "& span": {
1533
- fontSize: "12px !important",
1534
- },
1535
- } })] }), filterOptions.length !== 0 ? (filterOptions.map((option) => (jsxRuntime.jsxs(MenuItem, { value: `${option.value}`, sx: { zIndex: 0, fontSize: "11px !important" }, children: [jsxRuntime.jsx(Checkbox, { checked: fieldValue
1536
- ?.split(",")
1537
- .some((value) => value === option.value), size: "small" }), jsxRuntime.jsx(ListItemText, { primary: option.label, sx: {
1538
- fontSize: "5px !important",
1539
- "& span": {
1540
- fontSize: "12px !important",
1541
- },
1542
- } })] }, option.value)))) : (jsxRuntime.jsx(MenuItem, { disabled: true, value: "NA", children: "No data Found" }, "NA"))] }), jsxRuntime.jsx(FormBottomField, { ...props })] }) }, props.item.name));
1543
- }
1544
-
1545
- const SingleSelect = ({ props, variant, }) => {
1546
- const isError = !!props.errors?.[props.item.name];
1547
- const isShowBorderError = isError && props.fieldError && !props.getValues(props.item.name);
1548
- const value = props.getValues(props.item.name)
1549
- ? props.item.options?.find((item) => item.value === props.getValues(props.item.name))
1550
- : null;
1551
- return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [renderLabel(variant, props), jsxRuntime.jsx(material.Autocomplete, { ...field, value: value, onChange: (_, newValue) => {
1552
- props.setValue(props?.item?.name, newValue?.value);
1553
- props?.item?.onChangeFn &&
1554
- props?.item?.onChangeFn(newValue?.value);
1555
- props?.clearErrors && props?.clearErrors(props?.item?.name);
1556
- }, onBlur: (e) => {
1557
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1558
- }, size: "small", sx: {
1559
- "& .MuiAutocomplete-input": {
1560
- padding: "0px 0px 0px 5px !important",
1561
- },
1562
- "& .css-erkti9-MuiFormLabel-root-MuiInputLabel-root,.css-8edmr2-MuiFormLabel-root-MuiInputLabel-root": {
1563
- top: "-3px",
1564
- },
1565
- "& .MuiAutocomplete-option": {
1566
- fontSize: "11px",
1567
- zIndex: 2000,
1568
- },
1569
- ...props.item.sx,
1570
- }, ListboxProps: {
1571
- onScroll: (event) => {
1572
- const listboxNode = event.currentTarget;
1573
- if (listboxNode.scrollTop + listboxNode.clientHeight ===
1574
- listboxNode.scrollHeight) ;
1575
- },
1576
- }, disabled: props.item.disable, options: props.item.options || [], slotProps: {
1577
- popper: {
1578
- sx: {
1579
- zIndex: 1401,
1580
- },
1581
- },
1582
- }, renderInput: (params) => {
1583
- return (jsxRuntime.jsx(material.Tooltip, { title: params.inputProps.value && params.inputProps.value, children: jsxRuntime.jsx(material.TextField, { ...params, placeholder: props.item.placeholder, error: isShowBorderError, label: variant !== "standard"
1584
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1585
- : "" }) }));
1586
- } }), jsxRuntime.jsx(FormBottomField, { ...props })] })) }, props.item.name));
1587
- };
1588
-
1589
- const SingleSelectNonAutoComplete = ({ props, variant, }) => {
1590
- const isError = !!props.errors?.[props.item.name];
1591
- const isShowBorderError = isError && props.fieldError;
1592
- return (jsxRuntime.jsxs(material.FormControl, { fullWidth: true, sx: {
1593
- position: "relative",
1594
- "& .MuiFormLabel-root": {
1595
- top: -10,
1596
- },
1597
- "& .MuiInputLabel-shrink": {
1598
- top: 0,
1599
- },
1600
- }, children: [renderLabel(variant, props), variant !== "standard" && (jsxRuntime.jsx(material.InputLabel, { error: isShowBorderError, id: "demo-simple-select-label", children: props.item.label })), jsxRuntime.jsx(material.Select, { labelId: "demo-simple-select-label", id: "demo-simple-select", value: props.getValues(props.item.name), label: variant !== "standard"
1601
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1602
- : "", onChange: (e) => props.setValue(props.item.name, e.target.value), onBlur: (e) => {
1603
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1604
- }, error: isShowBorderError, children: (props.item.options || []).map((item) => (jsxRuntime.jsx(material.MenuItem, { sx: {
1605
- fontSize: "11px", // Adjust the font size as needed
1606
- zIndex: 2000,
1607
- }, value: item.value, children: item.label }))) }), jsxRuntime.jsx(FormBottomField, { ...props })] }, props.item.name));
1608
- };
1609
-
1610
- function TimePickerFieldWrapper({ props, variant, }) {
1611
- const value = props.getValues(props.item.name);
1612
- const isError = !!props.errors?.[props.item.name];
1613
- const isShowBorderError = isError && props.fieldError;
1614
- return (jsxRuntime.jsxs(LocalizationProvider.LocalizationProvider, { dateAdapter: AdapterDayjs.AdapterDayjs, children: [jsxRuntime.jsx(reactHookForm.Controller, { name: "time", control: props.control, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [" ", renderLabel(variant, props), jsxRuntime.jsx(TimePicker.TimePicker, { ...field, value: value ? parseCustomTime(value) : null, onChange: (newTime) => {
1615
- const parsedTime = parseCustomTime(formatDayjsToCustomTime(newTime));
1616
- const min = props.item.minTime
1617
- ? parseCustomTime(props.item.minTime)
1618
- : null;
1619
- const max = props.item.maxTime
1620
- ? parseCustomTime(props.item.maxTime)
1621
- : null;
1622
- let finalTime = parsedTime;
1623
- if (min && parsedTime?.isBefore(min)) {
1624
- finalTime = min;
1625
- }
1626
- else if (max && parsedTime?.isAfter(max)) {
1627
- finalTime = max;
1628
- }
1629
- const formatted = formatDayjsToCustomTime(finalTime);
1630
- props.setValue(props.item.name, formatted);
1631
- props.item.onChangeFn && props.item.onChangeFn(formatted);
1632
- }, minTime: props.item.minTime
1633
- ? parseCustomTime(props.item.minTime) || undefined
1634
- : undefined, maxTime: props.item.maxTime
1635
- ? parseCustomTime(props.item.maxTime) || undefined
1636
- : undefined, label: props.variant === "standard" ? "" : props.item.label, disabled: props.item.disable, slotProps: {
1637
- textField: {
1638
- size: "small",
1639
- error: isShowBorderError,
1640
- inputProps: {
1641
- readOnly: true,
1642
- },
1643
- sx: {
1644
- "& .MuiPickersInputBase-sectionsContainer": {
1645
- paddingTop: 1,
1646
- paddingBottom: 1,
1647
- "& span": {
1648
- fontSize: "12px",
1649
- },
1650
- },
1651
- "& .MuiFormLabel-root": {
1652
- top: -3,
1653
- },
1654
- "& .MuiInputLabel-shrink": {
1655
- top: 0,
1656
- },
1657
- },
1658
- },
1659
- } })] })) }), jsxRuntime.jsx(ErrorMessageComponent, { children: jsxRuntime.jsx(errorMessage.ErrorMessage, { errors: props.errors, name: props.item.name }) })] }));
1660
- }
1661
-
1662
- const FormActiveSwitch = ({ props }) => {
1663
- const [active, setActive] = React.useState(true);
1664
- const { getValues, setValue, item } = props;
1665
- const defaultValue1 = item.value1 ?? "A";
1666
- const defaultValue2 = item.value2 ?? "I";
1667
- React.useEffect(() => {
1668
- const currentValue = getValues(item.name);
1669
- setActive(currentValue === defaultValue1);
1670
- }, [getValues, item.name, defaultValue1]);
1671
- const handleSwitchChange = React.useCallback(() => {
1672
- setActive((prevActive) => {
1673
- const newValue = !prevActive ? defaultValue1 : defaultValue2;
1674
- setValue(item.name, newValue);
1675
- return !prevActive;
1676
- });
1677
- }, [setValue, item.name, defaultValue1, defaultValue2]);
1678
- return (jsxRuntime.jsxs("div", { className: "m-form__input", children: [item.label && (jsxRuntime.jsx("span", { style: {
1679
- fontSize: "12px",
1680
- fontWeight: 400,
1681
- paddingRight: 10,
1682
- }, children: item.label })), jsxRuntime.jsxs("span", { className: "switch prestashop-switch fixed-width-lg", children: [jsxRuntime.jsx("input", { checked: active, id: `${item.name}_on`, name: item.name, type: "radio", value: "Active", onChange: handleSwitchChange }), jsxRuntime.jsx("label", { htmlFor: `${item.name}_on`, style: { textTransform: "none" }, children: item.label1 ?? "Active" }), jsxRuntime.jsx("input", { checked: !active, id: `${item.name}_off`, name: item.name, type: "radio", value: "In Active", onChange: handleSwitchChange }), jsxRuntime.jsx("label", { htmlFor: `${item.name}_off`, style: { textTransform: "none" }, children: item.label2 ?? "In Active" }), jsxRuntime.jsx("a", { className: "slide-button btn" })] })] }));
1683
- };
1684
-
1685
- // Main renderer function: decides which form field component to render
1686
- // based on the `inputType` defined in `props.item`
1687
- const RenderForm = (props) => {
1688
- // Variant is an optional property that controls UI style differences
1689
- const variant = props.variant || "";
1690
- // Switch between different input types and render the corresponding component
1691
- switch (props.item?.inputType) {
1692
- // Common text-based inputs
1693
- case "text":
1694
- case "multiEmail":
1695
- case "email":
1696
- return jsxRuntime.jsx(FormTextField, { props: props, variant: variant });
1697
- // Rich text editor
1698
- case "rich-text-editor":
1699
- return jsxRuntime.jsx(RichTextEditorWrapper, { props: props, variant: variant });
1700
- // Password field
1701
- case "password":
1702
- return jsxRuntime.jsx(PasswordField, { props: props, variant: variant });
1703
- // Dropdown select (auto-complete)
1704
- case "select":
1705
- return jsxRuntime.jsx(SingleSelect, { props: props, variant: variant });
1706
- // Dropdown select (non auto-complete)
1707
- case "select-v2":
1708
- return jsxRuntime.jsx(SingleSelectNonAutoComplete, { props: props, variant: variant });
1709
- // Numeric inputs (integer, pincode, phone)
1710
- case "number":
1711
- case "pincode":
1712
- case "phoneNumber":
1713
- return jsxRuntime.jsx(FormNumberField, { props: props, variant: variant });
1714
- // Decimal input
1715
- case "decimal":
1716
- return jsxRuntime.jsx(FormNumberFieldDecimal, { props: props, variant: variant });
1717
- // Checkbox group (multiple options)
1718
- case "checkbox-group":
1719
- return jsxRuntime.jsx(FormCheckBoxGroup, { props: props, variant: variant });
1720
- // Radio group (single option)
1721
- case "radio-group":
1722
- return jsxRuntime.jsx(FormRadioGroup, { props: props, variant: variant });
1723
- // Date picker
1724
- case "datepicker":
1725
- return jsxRuntime.jsx(DatepickerWrapperV2, { props: props, variant: variant });
1726
- // Time picker
1727
- case "timepicker":
1728
- return jsxRuntime.jsx(TimePickerFieldWrapper, { props: props, variant: variant });
1729
- // Date range picker - TEMPORARILY DISABLED
1730
- case "dateRangePicker":
1731
- return jsxRuntime.jsx("div", {});
1732
- // return <DateRangePickerComponent props={props} variant={variant} />;
1733
- // Month picker
1734
- case "monthpicker":
1735
- return jsxRuntime.jsx(Monthpickerrender, { props: props, variant: variant });
1736
- // Multi-select dropdown
1737
- case "multiselect":
1738
- return jsxRuntime.jsx(MultiSelectV1, { props: props, variant: variant });
1739
- // Single file upload
1740
- case "file":
1741
- return jsxRuntime.jsx(FormRenderFileUpload, { props: props, variant: variant });
1742
- // Multi file upload
1743
- case "multifile":
1744
- return jsxRuntime.jsx(FormRenderMultiFileUpload, { props: props, variant: variant });
1745
- // Single checkbox
1746
- case "checkbox":
1747
- return jsxRuntime.jsx(FormCheckBox, { props: props, variant: variant });
1748
- // Multi-line text input
1749
- case "textarea":
1750
- return jsxRuntime.jsx(FormTextAreaField, { props: props, variant: variant });
1751
- // Toggle switch (active/inactive)
1752
- case "toggleSwitch":
1753
- return jsxRuntime.jsx(FormActiveSwitch, { props: props }, props.item.name);
1754
- // Default case: if input type is not found, return nothing
1755
- default:
1756
- return jsxRuntime.jsx(jsxRuntime.Fragment, {});
1757
- }
1758
- };
1759
-
1760
- const FormRenderWrapper = ({ formArray, name = "", numberOfColumns = 3, form, variant = "", fieldError, }) => {
1761
- return (jsxRuntime.jsx(react.ThemeProvider, { theme: customTheme, children: jsxRuntime.jsx(FormComponent, { container: true, margin: "auto", children: formArray.map((item, i) => {
1762
- return (item.inputType && (jsxRuntime.jsx(Formitem, { container: true, sx: item.CustomProps, noOfColumn: item.numberOfColumns || numberOfColumns, children: item.inputType === "custom" ? item.FormCell : jsxRuntime.jsx(RenderForm, { item: item, register: form.register, control: form.control, errors: form.formState.errors, getValues: form.getValues, clearErrors: form.clearErrors, setValue: form.setValue, variant: variant, fieldError: fieldError }) }, `${name}_${i}`)));
1763
- }) }) }));
1764
- };
1765
-
1766
- const ModalField = ({ name, openModal, handleCancel, content, width = "900px", Transition = "", handleSubmit, styles = {}, saveButton: isSaveButton = false, submitButton = true, handleSaveButton = () => null, SubmitButtonName = "Submit", }) => {
1767
- const TransitionComponent = () => {
1768
- switch (Transition) {
1769
- case "Slide":
1770
- return material.Slide;
1771
- default:
1772
- return undefined;
1773
- }
1774
- };
1775
- return (jsxRuntime.jsxs(DialogContainer, { open: openModal, TransitionComponent: TransitionComponent(), fullWidth: true, "aria-labelledby": "draggable-dialog-title", sx: {
1776
- zIndex: 20,
1777
- "& .css-tlc64q-MuiPaper-root-MuiDialog-paper,.css-mbdu2s": {
1778
- maxWidth: width,
1779
- },
1780
- ...styles,
1781
- }, children: [jsxRuntime.jsxs(DialogTitleWrapper, { children: [jsxRuntime.jsx("span", { children: name }), jsxRuntime.jsx(CloseIcon, { sx: { cursor: "pointer" }, onClick: () => handleCancel() })] }), jsxRuntime.jsx(material.DialogContent, { style: { paddingTop: "20px", paddingBottom: 0 }, sx: {
1782
- "& .pt-0": {
1783
- paddingTop: 0,
1784
- },
1785
- }, children: content }), jsxRuntime.jsx(material.DialogActions, { sx: { borderTop: "1px solid #e0e0e0", marginTop: 3 }, children: jsxRuntime.jsxs("div", { style: {
1786
- display: "flex",
1787
- justifyContent: "flex-end",
1788
- gap: "8px",
1789
- }, children: [isSaveButton && (jsxRuntime.jsx(SaveAsDraftButton, { variant: "contained", size: "small", onClick: () => handleSaveButton(), children: "Save" })), submitButton && (jsxRuntime.jsx(SubmitButton, { variant: "contained", size: "small", onClick: () => handleSubmit(), children: SubmitButtonName })), jsxRuntime.jsx(CancelButton, { variant: "text", size: "small", onClick: () => handleCancel(), children: "Cancel" })] }) })] }));
1790
- };
1791
-
1792
- const ITEM_HEIGHT = 48;
1793
- const ITEM_PADDING_TOP = 3;
1794
- const MenuProps = {
1795
- PaperProps: {
1796
- style: {
1797
- maxHeight: ITEM_HEIGHT * 5.5 + ITEM_PADDING_TOP,
1798
- },
1799
- },
1800
- autoFocus: false,
1801
- disableAutoFocusItem: true,
1802
- };
1803
- const extractValuesToArray = (inputString) => {
1804
- const valuesArray = inputString?.split(",");
1805
- const trimmedArray = valuesArray?.map((value) => value.trim());
1806
- return trimmedArray;
1807
- };
1808
- function MultiSelectFieldComponent({ value, options, onChangeFn, disable = false, }) {
1809
- const [personName, setPersonName] = React__namespace.useState(value ? extractValuesToArray(value) : []);
1810
- const [searchText, setSearchText] = React.useState("");
1811
- const [filterOptions, setFilterOptions] = React.useState(options);
1812
- const [selectAll, setSelectAll] = React.useState(false);
1813
- const textfieldRef = React__namespace.useRef(null);
1814
- const fieldValue = value;
1815
- const mappedIds = filterOptions.map((item) => item.value);
1816
- const filterIds = filterOptions.map((item) => item.value);
1817
- React__namespace.useEffect(() => {
1818
- if (searchText !== "") {
1819
- setFilterOptions(options.filter((item) => item.label.toLowerCase().includes(searchText.toLowerCase())));
1820
- }
1821
- else {
1822
- setFilterOptions(options);
1823
- }
1824
- }, [options, searchText]);
1825
- function hasExactMatch(array, value) {
1826
- return array.some((item) => item === value);
1827
- }
1828
- React__namespace.useEffect(() => {
1829
- if (fieldValue?.split(",").length !== filterOptions.length) {
1830
- setSelectAll(false);
1831
- }
1832
- else {
1833
- if (fieldValue
1834
- ?.split(",")
1835
- .every((value) => hasExactMatch(filterIds, value))) {
1836
- setSelectAll(true);
1837
- }
1838
- }
1839
- }, [filterOptions, fieldValue]);
1840
- const handleChange = (event) => {
1841
- const { target: { value }, } = event;
1842
- setPersonName(typeof value === "string" ? value?.split(",") : value);
1843
- onChangeFn((typeof value === "string" ? value?.split(",") : value).join(","));
1844
- };
1845
- const selectedOptions = options.filter((item) => fieldValue?.split(",").some((value) => value === item.value));
1846
- const selectedValues = selectedOptions
1847
- .map((item) => item.label)
1848
- .join(" , ");
1849
- return (jsxRuntime.jsx(material.Box, { children: jsxRuntime.jsx(FormControl, { fullWidth: true, sx: {
1850
- "& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy": {
1851
- top: "-10px",
1852
- },
1853
- }, children: jsxRuntime.jsxs(Select, { labelId: "demo-multiple-checkbox-label", id: "demo-multiple-checkbox", multiple: true, sx: {
1854
- "& .MuiTypography-root": {
1855
- fontSize: "5px !important",
1856
- },
1857
- }, disabled: disable, value: value ? extractValuesToArray(value) : [], onChange: handleChange, onOpen: () => {
1858
- setTimeout(() => {
1859
- if (textfieldRef.current) {
1860
- textfieldRef.current?.focus();
1861
- }
1862
- }, 0);
1863
- }, onClose: () => {
1864
- setSearchText("");
1865
- }, renderValue: () => (jsxRuntime.jsx(material.Tooltip, { title: selectedValues, children: jsxRuntime.jsx("span", { children: selectedOptions.length > 3
1866
- ? `${selectedOptions.length} Selected`
1867
- : selectedValues }) })), MenuProps: MenuProps, autoFocus: false, children: [jsxRuntime.jsx(material.Box, { sx: {
1868
- width: "100%",
1869
- position: "sticky",
1870
- top: "0px",
1871
- padding: "7px",
1872
- zIndex: 2,
1873
- height: "33px",
1874
- background: "#fff",
1875
- display: options.length === 0 ? "none" : undefined,
1876
- }, children: jsxRuntime.jsx(material.TextField, { inputRef: textfieldRef, autoFocus: true, value: searchText, sx: {
1877
- width: "100%",
1878
- }, placeholder: "Search...", onChange: (e) => {
1879
- setSearchText(e.target.value);
1880
- }, onKeyDown: (e) => {
1881
- if (e.key !== "Escape") {
1882
- e.stopPropagation();
1883
- }
1884
- } }) }), jsxRuntime.jsxs(MenuItem, { disabled: filterOptions.length === 0, sx: { zIndex: 0, fontSize: "5px !important" }, children: [jsxRuntime.jsx(Checkbox, { size: "small", checked: selectAll, onChange: () => {
1885
- setSelectAll(!selectAll);
1886
- const selectChanged = !selectAll;
1887
- if (!selectChanged) {
1888
- onChangeFn("");
1889
- }
1890
- else {
1891
- const allDataMapped = mappedIds.join(",");
1892
- console.log(allDataMapped, "allDataMapped");
1893
- onChangeFn(allDataMapped);
1894
- }
1895
- } }), jsxRuntime.jsx(ListItemText, { primary: "Select All", sx: {
1896
- fontSize: "5px !important",
1897
- "& span": {
1898
- fontSize: "12px !important",
1899
- },
1900
- } })] }), filterOptions.length !== 0 ? (filterOptions.map((option) => (jsxRuntime.jsxs(MenuItem, { value: `${option.value}`, sx: { zIndex: 0, fontSize: "11px !important" }, children: [jsxRuntime.jsx(Checkbox, { checked: fieldValue
1901
- ?.split(",")
1902
- .some((value) => value === option.value), size: "small" }), jsxRuntime.jsx(ListItemText, { primary: option.label, sx: {
1903
- fontSize: "5px !important",
1904
- "& span": {
1905
- fontSize: "12px !important",
1906
- },
1907
- } })] }, option.value)))) : (jsxRuntime.jsx(MenuItem, { disabled: true, value: "NA", children: "No data Found" }, "NA"))] }) }) }));
1908
- }
1909
-
1910
- const secondsToMMSS = (totalSeconds) => {
1911
- const minutes = Math.floor(totalSeconds / 60);
1912
- const seconds = Math.floor(totalSeconds % 60);
1913
- const formattedMinutes = String(minutes).padStart(2, "0");
1914
- const formattedSeconds = String(seconds).padStart(2, "0");
1915
- return `${formattedMinutes}:${formattedSeconds}`;
1916
- };
1917
- const promptBeforeValue = 120000;
1918
- const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, handleSessionCancel, SubmitButtonName = "Submit", buttonStyleProps, }) => {
1919
- const [openConfirmModal, setOpenConfirmModal] = React.useState(false);
1920
- const expiryDetails = sessionTime;
1921
- const providedTimestamp = new Date(expiryDetails).getTime();
1922
- const currentTimestamp = new Date().getTime();
1923
- const remainingTime = providedTimestamp - currentTimestamp;
1924
- const timeout = remainingTime;
1925
- const promptBeforeIdle = Math.min(promptBeforeValue, timeout - 1000);
1926
- const [, setRemainingTimeInSeconds] = React.useState(Math.ceil(timeout / 1000));
1927
- const [formattedRemainingTime, setFormattedRemainingTime] = React.useState(secondsToMMSS(Math.ceil(timeout / 1000)));
1928
- const onIdle = () => {
1929
- if (sessionTime) {
1930
- onSessionExpire();
1931
- }
1932
- };
1933
- const handleSubmit = () => {
1934
- handleSubmitSession();
1935
- setOpenConfirmModal(false);
1936
- };
1937
- const handleCancel = () => {
1938
- handleSessionCancel();
1939
- setOpenConfirmModal(false);
1940
- };
1941
- const onPrompt = () => {
1942
- setOpenConfirmModal(true);
1943
- };
1944
- const { getRemainingTime } = reactIdleTimer.useIdleTimer({
1945
- onIdle,
1946
- onPrompt,
1947
- promptBeforeIdle,
1948
- timeout,
1949
- throttle: 1000, // Adjust throttle to reduce delays
1950
- });
1951
- React.useEffect(() => {
1952
- const interval = setInterval(() => {
1953
- const remainingSeconds = Math.ceil(getRemainingTime() / 1000);
1954
- setRemainingTimeInSeconds(promptBeforeIdle !== promptBeforeValue ? remainingSeconds : 0);
1955
- const formattedTime = secondsToMMSS(remainingSeconds);
1956
- setFormattedRemainingTime(promptBeforeIdle !== promptBeforeValue ? formattedTime : "00:00");
1957
- }, 1000); // Adjust interval to 1000 ms
1958
- return () => {
1959
- clearInterval(interval);
1960
- };
1961
- }, [promptBeforeIdle, getRemainingTime]);
1962
- const sessionMessage = `Your session will expire in ${formattedRemainingTime} seconds. Do you want to extend the session?`;
1963
- console.log(promptBeforeIdle, "promptBeforeIdle");
1964
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ConfirmationDialog, { openConfirmDialog: openConfirmModal, handleCancel: handleCancel, onClickSubmit: handleSubmit, text: sessionMessage, Submit: SubmitButtonName, buttonStyleProps: buttonStyleProps }) }));
1965
- };
1966
-
1967
- const toTitleCase = (str) => {
1968
- return str
1969
- .replace(/([A-Z])/g, " $1") // Insert space before capital letters
1970
- .replace(/^./, (match) => match.toUpperCase()) // Capitalize the first letter
1971
- .trim(); // Remove any leading or trailing spaces
1972
- };
1973
- const getMaxLength = (data, key) => {
1974
- const keyLength = key.length;
1975
- // Length of the key (column header)
1976
- const dataMaxLength = Math.max(...data.map((item) => (item[key] ? item[key].toString().length : 0)));
1977
- return Math.max(keyLength, dataMaxLength);
1978
- }; // Return the maximum of key length or data length };
1979
- const handleDownloadReactTableDataExcel = (fileName, rowData, columns = [], customColumns = [], HeaderBackGround = "FFF4694B", HeaderColor = "000000") => {
1980
- const EXCEL_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8";
1981
- const EXCEL_EXTENSION = ".xlsx";
1982
- // Exclude 'actions' column and columns with hideOnExcel: true
1983
- const visibleColumns1 = columns.filter((col) => col?.accessorKey !== "actions");
1984
- const visibleColumns = visibleColumns1.filter((col) => !col?.hideOnExcel || col?.hideOnExcel !== true);
1985
- const data = rowData;
1986
- // Map column headers and accessorKeys
1987
- const columnHeaders = visibleColumns.length > 0
1988
- ? visibleColumns.map((col) => col.header)
1989
- : Object.keys(data[0]); // Use data keys as headers if columns are not provided
1990
- const accessorKeys = visibleColumns.length > 0
1991
- ? visibleColumns.map((col) => col.accessorKey)
1992
- : Object.keys(data[0]); // Use data keys as accessor keys if columns are not provided
1993
- // Reformat data to include only visible columns
1994
- const formattedData = data.map((row) => {
1995
- const formattedRow = {};
1996
- accessorKeys.forEach((key) => {
1997
- formattedRow[key] = row[key] || "";
1998
- });
1999
- return formattedRow;
2000
- });
2001
- // Create worksheet
2002
- const ws = XLSX__namespace.utils.json_to_sheet(formattedData, { header: accessorKeys });
2003
- // Apply column headers styling dynamically
2004
- accessorKeys.forEach((key, index) => {
2005
- const colLetter = XLSX__namespace.utils.encode_col(index); // Excel column letter
2006
- const cellAddress = `${colLetter}1`; // Header row cell
2007
- const headerText = toTitleCase(columnHeaders[index]);
2008
- ws[cellAddress] = {
2009
- t: "s",
2010
- v: headerText,
2011
- s: {
2012
- fill: { patternType: "solid", fgColor: { rgb: HeaderBackGround } },
2013
- font: { bold: true, color: { rgb: HeaderColor }, sz: 12 },
2014
- alignment: { horizontal: "center" },
2015
- },
2016
- };
2017
- // Apply custom color to entire column based on excelColumnColor in the column definition
2018
- const col = visibleColumns.length > 0
2019
- ? visibleColumns[index]
2020
- : customColumns.length > 0 &&
2021
- customColumns.find((item) => item.accessorKey === key);
2022
- if (col && col.excelColumnColor) {
2023
- const columnColor = col.excelColumnColor;
2024
- const textColor = col.excelTextColor;
2025
- // Apply color to all rows in that column (from row 2 onward)
2026
- for (let rowIndex = 2; rowIndex <= formattedData.length + 1; rowIndex++) {
2027
- const cell = `${colLetter}${rowIndex}`;
2028
- ws[cell] = ws[cell] || {}; // Ensure cell exists
2029
- ws[cell].s = ws[cell].s || {}; // Ensure style exists
2030
- ws[cell].s.fill = {
2031
- patternType: "solid",
2032
- fgColor: { rgb: columnColor },
2033
- font: { color: { rgb: textColor } },
2034
- };
2035
- ws[cell].s.border = {
2036
- top: { style: "thin", color: { rgb: "000000" } }, // Black thin border
2037
- bottom: { style: "thin", color: { rgb: "000000" } },
2038
- left: { style: "thin", color: { rgb: "000000" } },
2039
- right: { style: "thin", color: { rgb: "000000" } },
2040
- };
2041
- }
2042
- }
2043
- });
2044
- // Set column widths dynamically or with defaults
2045
- const colWidths = visibleColumns.length > 0
2046
- ? accessorKeys.map((accessorKey) => {
2047
- // Find the corresponding column by accessorKey
2048
- const column = visibleColumns.find((col) => col.accessorKey === accessorKey);
2049
- // Check if `excelColumnSize` is defined for this column
2050
- if (column && column.excelColumnSize) {
2051
- return {
2052
- wch: parseInt(column.excelColumnSize.replace("px", "")) / 7,
2053
- };
2054
- }
2055
- else {
2056
- return { wch: getMaxLength(data, accessorKey) + 5 }; // Default column width
2057
- }
2058
- })
2059
- : customColumns.length > 0
2060
- ? accessorKeys.map((accessorKey) => {
2061
- // Find the corresponding column by accessorKey
2062
- const column = customColumns.find((col) => col.accessorKey === accessorKey);
2063
- // Check if `excelColumnSize` is defined for this column
2064
- if (column && column.excelColumnSize) {
2065
- return {
2066
- wch: parseInt(column.excelColumnSize.replace("px", "")) / 7,
2067
- };
2068
- }
2069
- else {
2070
- return { wch: getMaxLength(data, accessorKey) + 5 }; // Default column width
2071
- }
2072
- })
2073
- : accessorKeys.map((accessorKey) => {
2074
- // Find the corresponding column by accessorKey
2075
- const column = customColumns.find((col) => col.accessorKey === accessorKey);
2076
- // Check if `excelColumnSize` is defined for this column
2077
- if (column && column.excelColumnSize) {
2078
- return {
2079
- wch: parseInt(column.excelColumnSize.replace("px", "")) / 7,
2080
- };
2081
- }
2082
- else {
2083
- return { wch: getMaxLength(data, accessorKey) + 5 }; // Default column width
2084
- }
2085
- });
2086
- ws["!cols"] = colWidths;
2087
- // Create workbook and save it
2088
- const wb = XLSX__namespace.utils.book_new();
2089
- XLSX__namespace.utils.book_append_sheet(wb, ws, "Sheet1");
2090
- const eb = XLSX__namespace.write(wb, { bookType: "xlsx", type: "array" });
2091
- const blob = new Blob([eb], { type: EXCEL_TYPE });
2092
- fileSaver.saveAs(blob, fileName + EXCEL_EXTENSION);
2093
- };
2094
- function getUsernameFromEmail(email) {
2095
- return email.split("@")[0];
2096
- }
2097
- function getInitials(name) {
2098
- if (!name)
2099
- return "";
2100
- const words = name.trim().split(/\s+/); // split by any spaces
2101
- let initials = "";
2102
- for (let i = 0; i < words.length && initials.length < 2; i++) {
2103
- initials += words[i][0].toUpperCase();
2104
- }
2105
- return initials;
2106
- }
2107
- function findMenuHierarchy(menuData, currentUrl, URLProjectNameWithSlash) {
2108
- const url = currentUrl;
2109
- const pathname = url.pathname.replace(URLProjectNameWithSlash, "").toLowerCase() +
2110
- url.search.toLowerCase();
2111
- let result = [];
2112
- function traverse(menus, path = []) {
2113
- for (const menu of menus) {
2114
- const currentPath = [...path, menu];
2115
- const subMenusRaw = []
2116
- .concat(menu.SubMenu || [], menu.SubMenus || [])
2117
- .filter(Boolean);
2118
- // Match found
2119
- if (menu.Path && menu.Path.toLowerCase() === pathname) {
2120
- result = currentPath;
2121
- return true;
2122
- }
2123
- if (subMenusRaw.length > 0) {
2124
- if (traverse(subMenusRaw, currentPath)) {
2125
- return true;
2126
- }
2127
- }
2128
- }
2129
- return false;
2130
- }
2131
- traverse(menuData);
2132
- return result;
2133
- }
2134
- /**
2135
- * Calculates a date by adding/subtracting days from today or a base date
2136
- * @param dayOffset - Days to add (positive) or subtract (negative) (default: 0)
2137
- * @param baseDate - Base date in DD/MM/YYYY format (default: today)
2138
- * @returns Formatted date string in DD/MM/YYYY format
2139
- */
2140
- const getDesiredDate = (dayOffset = 0, baseDate = null) => {
2141
- const startDate = baseDate ? dayjs(baseDate, "DD/MM/YYYY") : dayjs();
2142
- if (!startDate.isValid()) {
2143
- throw new Error("Invalid date format. Please use DD/MM/YYYY.");
2144
- }
2145
- return startDate.add(dayOffset, "day").format("DD/MM/YYYY");
2146
- };
2147
- /**
2148
- * Calculates sum of numeric values for a specific property across array objects
2149
- * @param array - Array of objects to sum
2150
- * @param key - Property name to sum
2151
- * @returns Total sum of numeric values
2152
- */
2153
- function calculateTotalArrayValueTotal(array, key) {
2154
- if (!Array.isArray(array)) {
2155
- return 0;
2156
- }
2157
- return array.reduce((sum, item) => {
2158
- const value = Number(item[key]) || 0;
2159
- return sum + value;
2160
- }, 0);
2161
- }
2162
- /**
2163
- * Checks if first date comes before second date
2164
- * @param dateStr1 - First date in DD/MM/YYYY format
2165
- * @param dateStr2 - Second date in DD/MM/YYYY format
2166
- * @returns True if dateStr1 is before dateStr2
2167
- */
2168
- function checkIsDateIsBefore(dateStr1, dateStr2) {
2169
- const date1 = dayjs(dateStr1.trim(), "DD/MM/YYYY");
2170
- const date2 = dayjs(dateStr2.trim(), "DD/MM/YYYY");
2171
- if (!date1.isValid() || !date2.isValid()) {
2172
- throw new Error("Invalid date format. Please use DD/MM/YYYY.");
2173
- }
2174
- return date1.isBefore(date2);
2175
- }
2176
- /**
2177
- * Lightens a hex color by a specified percentage
2178
- * @param color - Hex color string (with or without #)
2179
- * @param percent - Percentage to lighten (0-100)
2180
- * @returns Lightened hex color string
2181
- */
2182
- function lightenColor(color, percent) {
2183
- const num = parseInt(color.replace("#", ""), 16);
2184
- const amt = Math.round(2.55 * percent);
2185
- const R = (num >> 16) + amt;
2186
- const G = ((num >> 8) & 0x00ff) + amt;
2187
- const B = (num & 0x0000ff) + amt;
2188
- return ("#" +
2189
- (0x1000000 +
2190
- (R < 255 ? (R < 1 ? 0 : R) : 255) * 0x10000 +
2191
- (G < 255 ? (G < 1 ? 0 : G) : 255) * 0x100 +
2192
- (B < 255 ? (B < 1 ? 0 : B) : 255))
2193
- .toString(16)
2194
- .slice(1));
2195
- }
2196
- /**
2197
- * Gets formatted date with optional day offset
2198
- * @param dayOffset - Days to add (positive) or subtract (negative) from today (default: 0)
2199
- * @returns Date string in DD/MM/YYYY format
2200
- */
2201
- function getFormattedDate(dayOffset = 0) {
2202
- return dayjs().add(dayOffset, "day").format("DD/MM/YYYY");
2203
- }
2204
-
2205
- // Utility Functions - Helper functions for form operations and data manipulation
2206
-
2207
- var index$1 = /*#__PURE__*/Object.freeze({
2208
- __proto__: null,
2209
- calculateTotalArrayValueTotal: calculateTotalArrayValueTotal,
2210
- checkIsDateIsBefore: checkIsDateIsBefore,
2211
- extractDate: extractDate,
2212
- findMenuHierarchy: findMenuHierarchy,
2213
- formatDateMonthAndYear: formatDateMonthAndYear,
2214
- formatDayjsToCustomTime: formatDayjsToCustomTime,
2215
- getDesiredDate: getDesiredDate,
2216
- getFormattedDate: getFormattedDate,
2217
- getInitials: getInitials,
2218
- getUsernameFromEmail: getUsernameFromEmail,
2219
- handleDownloadReactTableDataExcel: handleDownloadReactTableDataExcel,
2220
- lightenColor: lightenColor,
2221
- parseCustomTime: parseCustomTime,
2222
- renderLabel: renderLabel
2223
- });
2224
-
2225
- // import { ErrorMessage } from "@hookform/error-message";
2226
- // import {
2227
- // Autocomplete,
2228
- // Skeleton,
2229
- // Stack,
2230
- // TextField,
2231
- // Tooltip,
2232
- // Typography,
2233
- // } from "@mui/material";
2234
- // import { makeStyles } from "@mui/styles";
2235
- // import React, { useEffect, useState } from "react";
2236
- // import { Controller } from "react-hook-form";
2237
- // import { ErrorMessageComponent, OptionRender } from "../Form.styles";
2238
- // import { FormRenderProps } from "../../../Utilities/Interface/FormInterface";
2239
- // const useStyles = makeStyles((theme) => ({
2240
- // option: {
2241
- // fontSize: "11px", // Adjust the font size as needed
2242
- // },
2243
- // option2: {
2244
- // fontSize: "14px",
2245
- // },
2246
- // }));
2247
- // const SingleSelectSearchApi = ({ props }: { props: FormRenderProps }) => {
2248
- // const classes = useStyles();
2249
- // const [searchValue, setSearchValue] = useState<string>("");
2250
- // const [optionsFetched, setOptionsFetched] = useState([]);
2251
- // const [isLoading, setIsLoading] = useState<boolean>(false);
2252
- // console.log(
2253
- // props.getValues(props.item.name),
2254
- // "props.getValues(props.item.name)"
2255
- // );
2256
- // useEffect(() => {
2257
- // const controller = new AbortController();
2258
- // const signal = controller.signal;
2259
- // if (props?.item?.autoFIll && props.getValues(props.item.name)) {
2260
- // setSearchValue(props.getValues(props.item.name));
2261
- // setOptionsFetched([]);
2262
- // } else if (props.getValues(props.item.name)) {
2263
- // setSearchValue(props.getValues(props.item.name));
2264
- // }
2265
- // // if(searchValue!==''){
2266
- // setIsLoading(true);
2267
- // props.item.AxiosInstance.get(
2268
- // props.item.ApiInstance + `&${props.item.searchInstance}=${searchValue}`,
2269
- // {
2270
- // signal,
2271
- // headers: {
2272
- // Authorization: `Bearer ${props.item.tokenInstance}`,
2273
- // },
2274
- // }
2275
- // )
2276
- // .then((res) => {
2277
- // setOptionsFetched(res.data);
2278
- // setIsLoading(false);
2279
- // props.item.setLoadedPaginationOptions &&
2280
- // props.item.setLoadedPaginationOptions(res.data);
2281
- // })
2282
- // .catch((err) => {
2283
- // console.log(err, "error");
2284
- // });
2285
- // return () => controller.abort();
2286
- // // }
2287
- // }, [
2288
- // searchValue,
2289
- // props.getValues(props.item.name),
2290
- // props.item.ApiInstance,
2291
- // props?.item?.autoFIll,
2292
- // props?.item?.tokenInstance
2293
- // ]);
2294
- // useEffect(() => {
2295
- // if (props.item?.ApiInstanceReferal) {
2296
- // setSearchValue("");
2297
- // }
2298
- // }, [props.item?.ApiInstanceReferal]);
2299
- // const isOptionEqualToValue = (option: any, value: any) =>
2300
- // option?.value === value?.value; // Assuming there's a 'value' property in your options
2301
- // return (
2302
- // <Controller
2303
- // control={props.control}
2304
- // name={props.item.name}
2305
- // render={({ field }) => (
2306
- // <>
2307
- // <Autocomplete
2308
- // {...field}
2309
- // value={
2310
- // props.getValues(props.item.name)
2311
- // ? optionsFetched?.find(
2312
- // (item) => item?.value === props.getValues(props.item.name)
2313
- // )
2314
- // : null
2315
- // }
2316
- // onChange={(_, newValue) => {
2317
- // // field.onChange(newValue);
2318
- // props.setValue(props.item.name, newValue?.value);
2319
- // props?.item?.onChangeFn &&
2320
- // props?.item?.onChangeFn(newValue?.value);
2321
- // props?.clearErrors && props?.clearErrors(props.item.name);
2322
- // }}
2323
- // size="small"
2324
- // sx={{
2325
- // "& .MuiAutocomplete-input": {
2326
- // padding: "0px 0px 0px 5px !important",
2327
- // },
2328
- // "& .css-erkti9-MuiFormLabel-root-MuiInputLabel-root ": {
2329
- // top: "-5px",
2330
- // },
2331
- // }}
2332
- // disabled={props.item.disable}
2333
- // options={optionsFetched}
2334
- // classes={{
2335
- // option:
2336
- // props.item.size === "extrasmall"
2337
- // ? classes.option
2338
- // : classes.option2,
2339
- // }}
2340
- // getOptionLabel={(option) => option.label}
2341
- // renderInput={(params) => {
2342
- // return (
2343
- // <Tooltip
2344
- // title={params.inputProps.value && params.inputProps.value}
2345
- // >
2346
- // <TextField
2347
- // {...params}
2348
- // onChange={(e) => {
2349
- // setSearchValue(e.target.value);
2350
- // }}
2351
- // placeholder={props.item.placeholder}
2352
- // label={props.item.label}
2353
- // />
2354
- // </Tooltip>
2355
- // );
2356
- // }}
2357
- // PaperComponent={({ children }) => (
2358
- // <div
2359
- // style={{
2360
- // background: "#fff",
2361
- // }}
2362
- // >
2363
- // {isLoading ? (
2364
- // <Stack padding={2} spacing={1}>
2365
- // <Skeleton
2366
- // variant="rectangular"
2367
- // width={"100%"}
2368
- // height={20}
2369
- // />
2370
- // <Skeleton
2371
- // variant="rectangular"
2372
- // width={"100%"}
2373
- // height={20}
2374
- // />
2375
- // <Skeleton
2376
- // variant="rectangular"
2377
- // width={"100%"}
2378
- // height={20}
2379
- // />
2380
- // <Skeleton
2381
- // variant="rectangular"
2382
- // width={"100%"}
2383
- // height={20}
2384
- // />
2385
- // <Skeleton
2386
- // variant="rectangular"
2387
- // width={"100%"}
2388
- // height={20}
2389
- // />
2390
- // <Skeleton
2391
- // variant="rectangular"
2392
- // width={"100%"}
2393
- // height={20}
2394
- // />
2395
- // </Stack>
2396
- // ) : (
2397
- // children
2398
- // )}
2399
- // </div>
2400
- // )}
2401
- // isOptionEqualToValue={isOptionEqualToValue}
2402
- // />
2403
- // {props?.item?.helperText && (
2404
- // <span
2405
- // style={{
2406
- // fontSize: "11px",
2407
- // color: "#3651d3",
2408
- // }}
2409
- // >
2410
- // ({props?.item?.helperText})
2411
- // </span>
2412
- // )}
2413
- // <ErrorMessageComponent>
2414
- // <ErrorMessage errors={props.errors} name={props.item.name} />
2415
- // </ErrorMessageComponent>
2416
- // </>
2417
- // )}
2418
- // />
2419
- // );
2420
- // };
2421
- // export default SingleSelectSearchApi;
2422
- const SingleSelectSearchApi = () => {
2423
- return jsxRuntime.jsx("div", { children: "SingleSelectSearchApi" });
2424
- };
2425
-
2426
- const MonthPicker = ({ props }) => {
2427
- const [selectedMonths, setSelectedMonths] = React.useState([]);
2428
- const handleMonthChange = (date) => {
2429
- // Handle the selected months
2430
- setSelectedMonths((prevSelectedMonths) => {
2431
- const monthIndex = date.getMonth();
2432
- if (prevSelectedMonths.includes(monthIndex)) {
2433
- // If month is already selected, remove it
2434
- return prevSelectedMonths?.filter((month) => month !== monthIndex);
2435
- }
2436
- else {
2437
- // If month is not selected, add it
2438
- return [...prevSelectedMonths, monthIndex];
2439
- }
2440
- });
2441
- };
2442
- return (jsxRuntime.jsx(reactHookForm.Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(xDatePickers.LocalizationProvider, { dateAdapter: AdapterDayjs.AdapterDayjs, children: jsxRuntime.jsx(DatePicker.DatePicker, { value: field.value, onChange: handleMonthChange, slots: {
2443
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2444
- textField: (textFieldProps) => (jsxRuntime.jsx(material.TextField, { ...textFieldProps, fullWidth: true, disabled: props.item.disable || false, InputLabelProps: {
2445
- shrink: true,
2446
- }, error: props.errors, inputProps: {
2447
- min: props.item.minDate,
2448
- } })),
2449
- }, slotProps: {
2450
- textField: {
2451
- sx: {
2452
- "& .MuiPickersInputBase-sectionsContainer": {
2453
- paddingTop: 1,
2454
- paddingBottom: 1,
2455
- "& span": {
2456
- fontSize: "12px",
2457
- },
2458
- },
2459
- "& .MuiFormLabel-root": {
2460
- top: -10,
2461
- },
2462
- "& .MuiInputLabel-shrink": {
2463
- top: 0,
2464
- },
2465
- },
2466
- },
2467
- } }) }), jsxRuntime.jsx(material.FormGroup, { children: Array.from({ length: 12 }).map((_, index) => (jsxRuntime.jsx(material.FormControlLabel, { control: jsxRuntime.jsx(material.Checkbox, { checked: selectedMonths.includes(index), onChange: () => handleMonthChange(new Date(2000, index, 1)), color: "primary" }), label: new Date(2000, index, 1).toLocaleDateString(undefined, {
2468
- month: "short",
2469
- }) }, index))) })] })) }));
2470
- };
2471
-
2472
- // import FormBottomField from "../FormBottomField/FormBottomField";
2473
- // import { Box, TextField } from "@mui/material";
2474
- // import { LocalizationProvider } from "@mui/x-date-pickers";
2475
- // import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
2476
- // import dayjs from "dayjs";
2477
- // import DatePicker from "react-datepicker";
2478
- // import { Controller } from "react-hook-form";
2479
- // import { renderLabel } from "../../../Utilities/Constants/FormConstants";
2480
- // import {
2481
- // FormRenderProps,
2482
- // VariantProps,
2483
- // } from "../../../Utilities/Interface/FormInterface";
2484
- // const YearPickerField = ({
2485
- // props,
2486
- // variant,
2487
- // }: {
2488
- // props: FormRenderProps;
2489
- // variant: VariantProps;
2490
- // }) => {
2491
- // return (
2492
- // <Controller
2493
- // control={props.control}
2494
- // name={props.item.name}
2495
- // key={props.item.name}
2496
- // render={({ field }) => (
2497
- // <>
2498
- // <LocalizationProvider dateAdapter={AdapterDayjs}>
2499
- // {renderLabel(variant, props)}
2500
- // <Box
2501
- // sx={{
2502
- // "& .css-1holvmy, .css-kichxs-MuiFormLabel-root-MuiInputLabel-root":
2503
- // {
2504
- // top: "-10px",
2505
- // },
2506
- // }}
2507
- // >
2508
- // {" "}
2509
- // <DatePicker
2510
- // views={["year"]}
2511
- // value={
2512
- // field.value
2513
- // ? dayjs(field.value).format("YYYY-MM-DD")
2514
- // : undefined
2515
- // }
2516
- // onChange={(date: any) => field.onChange(date)}
2517
- // // minDate={}
2518
- // slotProps={{
2519
- // textField: {
2520
- // label: `${props.item.label}${props.item.required ? " *" : ""}`,
2521
- // variant: variant !== "standard" ? variant : undefined,
2522
- // },
2523
- // }}
2524
- // slots={{
2525
- // // eslint-disable-next-line @typescript-eslint/no-explicit-any
2526
- // textField: (textFieldProps: any) => (
2527
- // <TextField
2528
- // {...textFieldProps}
2529
- // fullWidth
2530
- // disabled={props.item.disable || false}
2531
- // InputLabelProps={{
2532
- // shrink: true,
2533
- // }}
2534
- // />
2535
- // ),
2536
- // }}
2537
- // />
2538
- // </Box>
2539
- // </LocalizationProvider>
2540
- // <FormBottomField {...props} />
2541
- // </>
2542
- // )}
2543
- // />
2544
- // );
2545
- // };
2546
- // export default YearPickerField;
2547
- const YearPickerField = () => {
2548
- return jsxRuntime.jsx("div", { children: "YearPickerField" });
2549
- };
2550
-
2551
- // Form Input Components - Individual form field components for advanced usage
2552
-
2553
- var index = /*#__PURE__*/Object.freeze({
2554
- __proto__: null,
2555
- DatepickerWrapperV2: DatepickerWrapperV2,
2556
- FormBottomField: FormBottomField,
2557
- FormCheckBox: FormCheckBox,
2558
- FormCheckBoxGroup: FormCheckBoxGroup,
2559
- FormErrorField: FormErrorField,
2560
- FormNumberField: FormNumberField,
2561
- FormNumberFieldDecimal: FormNumberFieldDecimal,
2562
- FormRadioGroup: FormRadioGroup,
2563
- FormRenderFileUpload: FormRenderFileUpload,
2564
- FormRenderMultiFileUpload: FormRenderMultiFileUpload,
2565
- FormTextAreaField: FormTextAreaField,
2566
- FormTextField: FormTextField,
2567
- HelperText: HelperText,
2568
- MonthPicker: MonthPicker,
2569
- Monthpickerrender: Monthpickerrender,
2570
- MultiSelectV1: MultiSelectV1,
2571
- PasswordField: PasswordField,
2572
- RichTextEditor: RichTextEditor,
2573
- RichTextEditorWrapper: RichTextEditorWrapper,
2574
- SingleSelect: SingleSelect,
2575
- SingleSelectNonAutoComplete: SingleSelectNonAutoComplete,
2576
- SingleSelectSearchApi: SingleSelectSearchApi,
2577
- TimePicker: TimePickerFieldWrapper,
2578
- YearPickerField: YearPickerField
2579
- });
2580
-
2581
- // Common validation schemas
2582
- const emailSchema = Yup__namespace
2583
- .string()
2584
- .email("Please enter a valid email address")
2585
- .required("Email is required");
2586
- const passwordSchema = Yup__namespace
2587
- .string()
2588
- .min(8, "Password must be at least 8 characters")
2589
- .matches(/[A-Z]/, "Password must contain at least one uppercase letter")
2590
- .matches(/[a-z]/, "Password must contain at least one lowercase letter")
2591
- .matches(/[0-9]/, "Password must contain at least one number")
2592
- .required("Password is required");
2593
- const phoneSchema = Yup__namespace
2594
- .string()
2595
- .matches(/^[+]?[1-9][\d]{0,15}$/, "Please enter a valid phone number")
2596
- .required("Phone number is required");
2597
- const requiredStringSchema = Yup__namespace
2598
- .string()
2599
- .required("This field is required");
2600
- const optionalStringSchema = Yup__namespace.string();
2601
- const numberSchema = Yup__namespace
2602
- .number()
2603
- .typeError("Please enter a valid number")
2604
- .required("This field is required");
2605
- const optionalNumberSchema = Yup__namespace
2606
- .number()
2607
- .typeError("Please enter a valid number");
2608
- const dateSchema = Yup__namespace
2609
- .date()
2610
- .typeError("Please enter a valid date")
2611
- .required("Date is required");
2612
- const urlSchema = Yup__namespace
2613
- .string()
2614
- .url("Please enter a valid URL")
2615
- .required("URL is required");
2616
- // Example form schemas
2617
- const loginSchema = Yup__namespace.object({
2618
- email: emailSchema,
2619
- password: Yup__namespace.string().required("Password is required"),
2620
- });
2621
- const registrationSchema = Yup__namespace.object({
2622
- firstName: requiredStringSchema,
2623
- lastName: requiredStringSchema,
2624
- email: emailSchema,
2625
- password: passwordSchema,
2626
- confirmPassword: Yup__namespace
2627
- .string()
2628
- .oneOf([Yup__namespace.ref("password")], "Passwords must match")
2629
- .required("Please confirm your password"),
2630
- });
2631
- const contactSchema = Yup__namespace.object({
2632
- name: requiredStringSchema,
2633
- email: emailSchema,
2634
- phone: phoneSchema.optional(),
2635
- message: requiredStringSchema,
2636
- });
2637
-
2638
- var schemas = /*#__PURE__*/Object.freeze({
2639
- __proto__: null,
2640
- contactSchema: contactSchema,
2641
- dateSchema: dateSchema,
2642
- emailSchema: emailSchema,
2643
- loginSchema: loginSchema,
2644
- numberSchema: numberSchema,
2645
- optionalNumberSchema: optionalNumberSchema,
2646
- optionalStringSchema: optionalStringSchema,
2647
- passwordSchema: passwordSchema,
2648
- phoneSchema: phoneSchema,
2649
- registrationSchema: registrationSchema,
2650
- requiredStringSchema: requiredStringSchema,
2651
- urlSchema: urlSchema
2652
- });
2653
-
2654
- exports.ConfirmationDialog = ConfirmationDialog;
2655
- exports.DeleteField = DeleteField;
2656
- exports.FormComponents = index;
2657
- exports.ModalField = ModalField;
2658
- exports.MultiSelectFieldComponent = MultiSelectFieldComponent;
2659
- exports.RenderForm = FormRenderWrapper;
2660
- exports.SessionTimeoutField = SessionTimeOut;
2661
- exports.Theme = index$2;
2662
- exports.Utils = index$1;
2663
- exports.ValidationSchemas = schemas;
2664
- exports.calculateTotalArrayValueTotal = calculateTotalArrayValueTotal;
2665
- exports.checkIsDateIsBefore = checkIsDateIsBefore;
2666
- exports.findMenuHierarchy = findMenuHierarchy;
2667
- exports.getDesiredDate = getDesiredDate;
2668
- exports.getFormattedDate = getFormattedDate;
2669
- exports.getInitials = getInitials;
2670
- exports.getUsernameFromEmail = getUsernameFromEmail;
2671
- exports.handleDownloadReactTableDataExcel = handleDownloadReactTableDataExcel;
2672
- exports.lightenColor = lightenColor;
2673
- exports.useFormValidatingContext = useFormValidatingContext;
1
+ export { default as DeleteField } from './components/DeleteComponent/DeleteField.js';
2
+ export { default as useFormValidatingContext } from './components/Form/FormConstants.js';
3
+ export { default as RenderForm } from './components/Form/FormRenderWrapper.js';
4
+ export { default as ConfirmationDialog } from './components/ModalField/ConfirmationDialog.js';
5
+ export { default as ModalField } from './components/ModalField/ModalField.js';
6
+ export { default as MultiSelectFieldComponent } from './components/SelectField/MultiSelectFieldComponent.js';
7
+ export { default as SessionTimeoutField } from './components/SessionTimeOut/SessionTimeOut.js';
8
+ import * as index$1 from './lib/index.js';
9
+ export { index$1 as Utils };
10
+ import * as index from './components/FormComponents/index.js';
11
+ export { index as FormComponents };
12
+ import * as schemas from './validation/schemas.js';
13
+ export { schemas as ValidationSchemas };
14
+ import * as index$2 from './theme/index.js';
15
+ export { index$2 as Theme };
16
+ export { calculateTotalArrayValueTotal, checkIsDateIsBefore, findMenuHierarchy, getDesiredDate, getFormattedDate, getInitials, getUsernameFromEmail, handleDownloadReactTableDataExcel, lightenColor } from './lib/Constants/FunctionConstants.js';