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