tp-react-elements-dev 1.12.21 → 1.12.23

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 (119) 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.js +48 -0
  19. package/dist/components/FormComponents/DatePicker/Monthpickerrender.d.ts +1 -1
  20. package/dist/components/FormComponents/DatePicker/Monthpickerrender.d.ts.map +1 -1
  21. package/dist/components/FormComponents/DatePicker/Monthpickerrender.js +61 -0
  22. package/dist/components/FormComponents/FileUpload/FormRenderFileUpload.d.ts +1 -1
  23. package/dist/components/FormComponents/FileUpload/FormRenderFileUpload.d.ts.map +1 -1
  24. package/dist/components/FormComponents/FileUpload/FormRenderFileUpload.js +86 -0
  25. package/dist/components/FormComponents/FileUpload/FormRenderMultiFileUpload.d.ts +1 -1
  26. package/dist/components/FormComponents/FileUpload/FormRenderMultiFileUpload.d.ts.map +1 -1
  27. package/dist/components/FormComponents/FileUpload/FormRenderMultiFileUpload.js +96 -0
  28. package/dist/components/FormComponents/FormBottomField/FormBottomField.d.ts +1 -1
  29. package/dist/components/FormComponents/FormBottomField/FormBottomField.d.ts.map +1 -1
  30. package/dist/components/FormComponents/FormBottomField/FormBottomField.js +9 -0
  31. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.d.ts +1 -1
  32. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.d.ts.map +1 -1
  33. package/dist/components/FormComponents/FormCheckBox/FormCheckBox.js +10 -0
  34. package/dist/components/FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.d.ts +1 -1
  35. package/dist/components/FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.d.ts.map +1 -1
  36. package/dist/components/FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.js +23 -0
  37. package/dist/components/FormComponents/FormErrorField/FormErrorField.d.ts +1 -1
  38. package/dist/components/FormComponents/FormErrorField/FormErrorField.d.ts.map +1 -1
  39. package/dist/components/FormComponents/FormErrorField/FormErrorField.js +9 -0
  40. package/dist/components/FormComponents/FormNumberField/FormNumberField.d.ts +1 -1
  41. package/dist/components/FormComponents/FormNumberField/FormNumberField.d.ts.map +1 -1
  42. package/dist/components/FormComponents/FormNumberField/FormNumberField.js +49 -0
  43. package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.d.ts +1 -1
  44. package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.d.ts.map +1 -1
  45. package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.js +45 -0
  46. package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.d.ts +1 -1
  47. package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.d.ts.map +1 -1
  48. package/dist/components/FormComponents/FormRadioGroup/FormRadioGroup.js +26 -0
  49. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.d.ts +1 -1
  50. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.d.ts.map +1 -1
  51. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.js +31 -0
  52. package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.styles.js +35 -0
  53. package/dist/components/FormComponents/FormTextField/FormTextField.d.ts +1 -1
  54. package/dist/components/FormComponents/FormTextField/FormTextField.d.ts.map +1 -1
  55. package/dist/components/FormComponents/FormTextField/FormTextField.js +46 -0
  56. package/dist/components/FormComponents/FormTextField/FormTextField.styles.js +22 -0
  57. package/dist/components/FormComponents/HelperText/HelperText.d.ts +1 -1
  58. package/dist/components/FormComponents/HelperText/HelperText.d.ts.map +1 -1
  59. package/dist/components/FormComponents/HelperText/HelperText.js +10 -0
  60. package/dist/components/FormComponents/PasswordField/PasswordField.d.ts +1 -1
  61. package/dist/components/FormComponents/PasswordField/PasswordField.d.ts.map +1 -1
  62. package/dist/components/FormComponents/PasswordField/PasswordField.js +49 -0
  63. package/dist/components/FormComponents/RichTextEditor/RichTextEditor.d.ts +1 -1
  64. package/dist/components/FormComponents/RichTextEditor/RichTextEditor.d.ts.map +1 -1
  65. package/dist/components/FormComponents/RichTextEditor/RichTextEditor.js +95 -0
  66. package/dist/components/FormComponents/RichTextEditor/RichTextEditorWrapper.d.ts +1 -1
  67. package/dist/components/FormComponents/RichTextEditor/RichTextEditorWrapper.d.ts.map +1 -1
  68. package/dist/components/FormComponents/RichTextEditor/RichTextEditorWrapper.js +11 -0
  69. package/dist/components/FormComponents/RichTextEditor/jodit.index.js +27 -0
  70. package/dist/components/FormComponents/Select/MultiSelectv1.d.ts +1 -1
  71. package/dist/components/FormComponents/Select/MultiSelectv1.d.ts.map +1 -1
  72. package/dist/components/FormComponents/Select/MultiSelectv1.js +157 -0
  73. package/dist/components/FormComponents/Select/SingleSelect.d.ts +1 -1
  74. package/dist/components/FormComponents/Select/SingleSelect.d.ts.map +1 -1
  75. package/dist/components/FormComponents/Select/SingleSelect.js +51 -0
  76. package/dist/components/FormComponents/Select/SingleSelectNonAutoComplete.d.ts +1 -1
  77. package/dist/components/FormComponents/Select/SingleSelectNonAutoComplete.d.ts.map +1 -1
  78. package/dist/components/FormComponents/Select/SingleSelectNonAutoComplete.js +27 -0
  79. package/dist/components/FormComponents/Select/SingleSelectSearchApi.js +204 -0
  80. package/dist/components/FormComponents/TimePicker/TimePicker.d.ts +1 -1
  81. package/dist/components/FormComponents/TimePicker/TimePicker.d.ts.map +1 -1
  82. package/dist/components/FormComponents/TimePicker/TimePicker.js +55 -0
  83. package/dist/components/FormComponents/YearPickerField/YearPickerField.js +82 -0
  84. package/dist/components/FormComponents/index.js +26 -0
  85. package/dist/components/Global.styles.js +79 -0
  86. package/dist/components/ModalField/ConfirmationDialog.js +48 -0
  87. package/dist/components/ModalField/ModalField.js +32 -0
  88. package/dist/components/SelectField/MultiSelectFieldComponent.js +129 -0
  89. package/dist/components/SessionTimeOut/SessionTimeOut.js +63 -0
  90. package/dist/index.d.ts +3 -3
  91. package/dist/index.d.ts.map +1 -1
  92. package/dist/index.js +16 -2648
  93. package/dist/lib/Constants/FormConstants.d.ts.map +1 -0
  94. package/dist/lib/Constants/FormConstants.js +54 -0
  95. package/dist/lib/Constants/FunctionConstants.d.ts.map +1 -0
  96. package/dist/lib/Constants/FunctionConstants.js +244 -0
  97. package/dist/lib/Interface/FormInterface.d.ts.map +1 -0
  98. package/dist/lib/index.d.ts +3 -2
  99. package/dist/lib/index.d.ts.map +1 -1
  100. package/dist/lib/index.js +4 -0
  101. package/dist/theme/index.js +64 -0
  102. package/dist/validation/schemas.js +60 -0
  103. package/package.json +8 -6
  104. package/dist/Utilities/Constants/FormConstants.d.ts.map +0 -1
  105. package/dist/Utilities/Constants/FunctionConstants.d.ts.map +0 -1
  106. package/dist/Utilities/Interface/FormInterface.d.ts.map +0 -1
  107. package/dist/Utilities/index.d.ts +0 -4
  108. package/dist/Utilities/index.d.ts.map +0 -1
  109. package/dist/index.esm.css +0 -1
  110. package/dist/index.esm.js +0 -2607
  111. package/dist/lib/cache-buster.d.ts +0 -2
  112. package/dist/lib/cache-buster.d.ts.map +0 -1
  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
  119. /package/dist/{Utilities → lib}/Interface/FormInterface.d.ts +0 -0
package/dist/index.esm.js DELETED
@@ -1,2607 +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
- "& .MuiFormLabel-root": {
777
- top: -10,
778
- },
779
- "& .MuiInputLabel-shrink": {
780
- top: 0,
781
- },
782
- },
783
- },
784
- } })] }), jsx(FormBottomField, { ...props })] })) }, props.item.name));
785
- };
786
-
787
- const Monthpickerrender = ({ props, variant, }) => {
788
- const ref = useRef(null);
789
- const [open, setOpen] = useState(false);
790
- const handleToggle = () => {
791
- if (!open) {
792
- ref.current?.blur();
793
- }
794
- setOpen(!open);
795
- };
796
- const isError = !!props.errors?.[props.item.name];
797
- const isShowBorderError = isError && props.fieldError;
798
- 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" &&
799
- `${props.item.label}${props.item.required ? " *" : ""}`, views: ["month", "year"], disabled: props.item.disable, value: field.value
800
- ? dayjs(formatDateMonthAndYear(field.value || null))
801
- : null, slotProps: {
802
- textField: {
803
- onClick: () => handleToggle(),
804
- inputRef: ref,
805
- error: isShowBorderError,
806
- },
807
- }, disableOpenPicker: props.item.disable, open: open, onOpen: handleToggle, onClose: handleToggle, defaultValue: field.value, onChange: (date) => {
808
- field.onChange(dayjs(date).format("MM/YYYY"));
809
- props.setValue(dayjs(date).format("MM/YYYY"));
810
- }, sx: {
811
- "& .css-1holvmy,.css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
812
- top: "-10px",
813
- },
814
- "& input": {
815
- paddingRight: "0px !important",
816
- },
817
- "& button": {
818
- paddingLeft: "0px !important",
819
- paddingRight: "0px !important",
820
- },
821
- "& .MuiFormLabel-root": {
822
- top: -10,
823
- },
824
- "& .MuiInputLabel-shrink": {
825
- top: 0,
826
- },
827
- }, minDate: props.item.minDate
828
- ? dayjs(props.item.minDate, "MM/YYYY")
829
- : undefined, maxDate: props.item.maxDate
830
- ? dayjs(props.item.maxDate, "MM/YYYY")
831
- : undefined })] }), props?.item?.helperText && (jsxs("span", { style: {
832
- fontSize: "11px",
833
- color: "#3651d3",
834
- }, children: ["(", props?.item?.helperText, ")"] })), jsx(FormBottomField, { ...props })] })) }));
835
- };
836
-
837
- const FormRenderFileUpload = ({ props, variant, }) => {
838
- const isError = !!props.errors?.[props.item.name];
839
- const isShowBorderError = isError && props.fieldError;
840
- useEffect(() => {
841
- if (props.getValues(props.item.name) === null ||
842
- props.getValues(props.item.name) === undefined) {
843
- const element = document.getElementById(props.item.name);
844
- console.log(element, "elementelement");
845
- if (element) {
846
- element.value = ""; // Ensure it's an input element
847
- }
848
- }
849
- }, [props.getValues(props.item.name)]);
850
- 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: {
851
- accept: props.item.fileType === "excel"
852
- ? ".xls, .xlsx"
853
- : props.item.fileType === "pdf"
854
- ? ".pdf"
855
- : props.item.fileType === "zip"
856
- ? ".zip"
857
- : props.item.fileType === "all"
858
- ? ".pdf,.jpg,.jpeg,.png,.xls,.xlsx,.doc,.docx,.zip"
859
- : "",
860
- }, onChange: (event) => {
861
- const file = event.target?.files[0];
862
- console.log(file, "filefile");
863
- const fileName = file ? file.name : null;
864
- const allowedExtensions = {
865
- excel: ["xls", "xlsx"],
866
- pdf: ["pdf"],
867
- zip: ["zip"],
868
- all: [
869
- "pdf",
870
- "jpg",
871
- "jpeg",
872
- "png",
873
- "xls",
874
- "xlsx",
875
- "doc",
876
- "docx",
877
- "zip",
878
- ],
879
- image: ["jpg", "jpeg", "png"],
880
- };
881
- const fileExtension = fileName
882
- ? fileName.split(".").pop().toLowerCase()
883
- : null;
884
- const validExtensions = props.item.fileType === "excel"
885
- ? allowedExtensions.excel
886
- : props.item.fileType === "pdf"
887
- ? allowedExtensions.pdf
888
- : allowedExtensions.all;
889
- if (props.item?.fileType &&
890
- fileExtension &&
891
- !validExtensions.includes(fileExtension)) {
892
- props.item?.handleFileError
893
- ? props.item?.handleFileError(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`)
894
- : alert(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`);
895
- event.target.value = ""; // Clear the file input\
896
- props.setValue(props.item?.name, null);
897
- props.setValue(props.item?.name + "Name", "");
898
- return;
899
- }
900
- else if (event.target.files[0].size > (props.item.filesize || 20000000)) {
901
- const maxSizeMB = ((props.item.filesize || 20000000) /
902
- (1024 * 1024)).toFixed(2);
903
- props.item?.handleFileError
904
- ? props.item?.handleFileError(`File size should be less than ${maxSizeMB}MB`)
905
- : alert(`File size should be less than ${maxSizeMB}MB`);
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
- props.setValue(props.item?.name, file);
912
- props.setValue(props.item?.name + "Name", fileName);
913
- }, sx: { width: "100%" } })] }), jsx(FormBottomField, { ...props })] }));
914
- };
915
-
916
- const FormRenderMultiFileUpload = ({ props, variant, }) => {
917
- // const getDocument: Document = document;
918
- useEffect(() => {
919
- if (props.getValues(props.item.name) === null ||
920
- props.getValues(props.item.name) === undefined) {
921
- const element = document.getElementById(props.item.name);
922
- console.log(element, "elementelement");
923
- if (element) {
924
- element.value = ""; // Ensure it's an input element
925
- }
926
- }
927
- }, [props.getValues(props.item.name)]);
928
- const isError = !!props.errors?.[props.item.name];
929
- const isShowBorderError = isError && props.fieldError;
930
- 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: {
931
- multiple: true,
932
- accept: props.item.fileType === "excel"
933
- ? ".xls,.xlsx"
934
- : props.item.fileType === "pdf"
935
- ? ".pdf"
936
- : props.item.fileType === "image"
937
- ? ".jpg,.jpeg,.png"
938
- : props.item.fileType === "all"
939
- ? ".pdf,.jpg,.jpeg,.png,.xls,.xlsx,.doc,.docx"
940
- : "",
941
- }, onChange: (event) => {
942
- const file = event.target.files;
943
- const fileName = file && file.length > 0
944
- ? Array.from(file)
945
- .map((item) => item.name)
946
- .join(",")
947
- : null;
948
- console.log(file, "filefile", file.length, fileName);
949
- const allowedExtensions = {
950
- excel: ["xls", "xlsx"],
951
- pdf: ["pdf"],
952
- image: ["jpg", "jpeg", "png"],
953
- all: [
954
- "pdf",
955
- "jpg",
956
- "jpeg",
957
- "png",
958
- "xls",
959
- "xlsx",
960
- "doc",
961
- "docx",
962
- "zip",
963
- ],
964
- zip: ["zip"],
965
- };
966
- let fileExtension = null;
967
- if (fileName) {
968
- const ext = fileName.split(".").pop();
969
- if (ext) {
970
- fileExtension = ext.toLowerCase();
971
- }
972
- }
973
- const validExtensions = props.item.fileType === "excel"
974
- ? allowedExtensions.excel
975
- : props.item.fileType === "pdf"
976
- ? allowedExtensions.pdf
977
- : props.item.fileType === "image"
978
- ? allowedExtensions.image
979
- : allowedExtensions.all;
980
- if (props.item?.fileType &&
981
- fileExtension &&
982
- !validExtensions.includes(fileExtension)) {
983
- props.item?.handleFileError &&
984
- props.item?.handleFileError(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`);
985
- event.target.value = ""; // Clear the file input\
986
- props.setValue(props.item?.name, null);
987
- props.setValue(props.item?.name + "Name", "");
988
- return;
989
- }
990
- else if (event.target.files[event.target.files.length - 1].size > 20000000) {
991
- props.item?.handleFileError &&
992
- props.item?.handleFileError(`File size should be less than 20MB`);
993
- event.target.files = null; // Clear the file input
994
- props.setValue(props.item?.name, null);
995
- props.setValue(props.item?.name + "File", []);
996
- return;
997
- }
998
- const fileArray = Array.from(file);
999
- console.log(fileArray, "fileArrayfileArray");
1000
- props.setValue(props.item?.name, fileName);
1001
- props.setValue(props.item?.name + "File", fileArray);
1002
- }, sx: { width: "100%" } })] }), jsx(FormBottomField, { ...props })] }));
1003
- };
1004
-
1005
- const FormCheckBox = ({ props, variant: _variant, }) => {
1006
- 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 })] }));
1007
- };
1008
-
1009
- const FormCheckBoxGroup = ({ props, variant, }) => {
1010
- return (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(FormControl, { component: "fieldset", children: jsx(FormGroup, { row: true, children: props.item?.settings &&
1011
- props.item.settings.map((settings, i) => {
1012
- return (jsx(Controller, { name: settings.name, control: props.control, render: ({ field }) => {
1013
- return (jsx(FormControlLabel, { control: jsx(Checkbox, { ...field, checked: field.value }), sx: {
1014
- ".MuiCheckbox-root": {
1015
- padding: "6px 2px 6px 8px",
1016
- ".css-imrjgg-MuiButtonBase-root-MuiCheckbox-root": {
1017
- color: "rgb(0, 0, 0) !important",
1018
- },
1019
- },
1020
- }, label: jsx(Typography, { variant: "subtitle2", fontSize: "11px", fontWeight: "normal !important", children: settings.label }), labelPlacement: "end" }));
1021
- } }, i));
1022
- }) }) }), jsx(FormBottomField, { ...props })] }));
1023
- };
1024
-
1025
- const FormNumberField = ({ props, variant, }) => {
1026
- const isError = !!props.errors?.[props.item.name];
1027
- const isShowBorderError = isError && props.fieldError;
1028
- const label = variant !== "standard"
1029
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1030
- : "";
1031
- return (jsx(Fragment, { children: jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => {
1032
- 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) => {
1033
- e.target.value = e.target.value.replace(/[^0-9]/g, "");
1034
- if (e.target.value === "") {
1035
- e.target.value = null;
1036
- }
1037
- props?.item?.onChangeFn &&
1038
- props?.item?.onChangeFn(e.target.value);
1039
- props?.clearErrors && props?.clearErrors(props.item.name);
1040
- }, onBlur: (e) => {
1041
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1042
- }, sx: {
1043
- "& .css-1holvmy,.css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root,.css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
1044
- top: "-10px",
1045
- },
1046
- }, inputProps: {
1047
- pattern: "[0-9]*", // Only allow numbers
1048
- maxLength: props.item.maxLength || 20,
1049
- onInput: (e) => {
1050
- if (props?.item?.donotAllowSpace) {
1051
- const value = e.target.value;
1052
- e.target.value = value.replace(" ", "");
1053
- }
1054
- if (!props?.item?.allowSpecialChars) {
1055
- const value = e.target.value;
1056
- e.target.value = value.replace(/[^a-zA-Z0-9 ]/g, "");
1057
- } // Allow only alphanumeric and space
1058
- if (e.target.value.length === 1 && e.target.value === " ") {
1059
- e.target.value = "";
1060
- }
1061
- props.item.onInputProps && props.item.onInputProps(e);
1062
- },
1063
- }, disabled: props.item.disable }), jsx(FormBottomField, { ...props })] }));
1064
- } }, props.item.name) }));
1065
- };
1066
-
1067
- const FormNumberFieldDecimal = ({ props, variant, }) => {
1068
- const fixedLength = props.item.decimalFixedTo || 2;
1069
- const onInput = (e) => {
1070
- // Allow numbers, a single decimal point, and negation in the input
1071
- e.target.value = e.target.value.replace(/[^0-9.-]/g, "");
1072
- // Ensure only one decimal point is present
1073
- const decimalPointCount = e.target.value.split(".").length - 1;
1074
- if (decimalPointCount > 1) {
1075
- e.target.value = e.target.value.slice(0, -1);
1076
- }
1077
- // Ensure only two digits after the decimal point
1078
- const parts = e.target.value.split(".");
1079
- if (parts.length === fixedLength && parts[1].length > fixedLength) {
1080
- e.target.value = `${parts[0]}.${parts[1].slice(0, fixedLength)}`;
1081
- }
1082
- };
1083
- const label = variant !== "standard"
1084
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1085
- : "";
1086
- const isError = !!props.errors?.[props.item.name];
1087
- const isShowBorderError = isError && props.fieldError;
1088
- 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: {
1089
- "& input": {
1090
- textAlign: "right",
1091
- },
1092
- "& .css-16hdwvj,.css-1idq7r3-MuiFormLabel-root-MuiInputLabel-root": {
1093
- top: "-5px",
1094
- },
1095
- }, onBlur: (e) => {
1096
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1097
- }, onInput: onInput, InputProps: {
1098
- inputProps: {
1099
- pattern: "[1-9]",
1100
- maxLength: 7,
1101
- },
1102
- } }), jsx(FormBottomField, { ...props })] })) }, props.item.name));
1103
- };
1104
-
1105
- const FormRadioGroup = ({ props, variant, }) => {
1106
- 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) => {
1107
- field.onChange(e.target.value); // ✅ update form state
1108
- console.log(e.target.value, "radio value selected");
1109
- props.item.onChangeFn && props.item.onChangeFn(e.target.value); // optional handler
1110
- }, row: true, sx: {
1111
- gap: "8px",
1112
- }, children: props.item?.settings?.map((option, i) => (jsx(FormControlLabel, { value: option.name, control: jsx(Radio, { sx: {
1113
- padding: "6px 2px 6px 8px",
1114
- color: "black",
1115
- "&.Mui-checked": {
1116
- color: "#1976d2", // blue when selected
1117
- },
1118
- "& .MuiSvgIcon-root": {
1119
- fontSize: 16, // 🔹 this actually controls the radio icon size
1120
- },
1121
- } }), label: jsx(Typography, { fontSize: "11px", fontWeight: "normal !important", children: option.label }) }, i))) })) }) }), jsx(FormBottomField, { ...props })] }));
1122
- };
1123
-
1124
- const TextAreaField = styled(TextField)(() => ({
1125
- "& .css-1holvmy,.css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root, .css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
1126
- top: "-10px",
1127
- },
1128
- "& input": {
1129
- fontSize: "11px",
1130
- },
1131
- "& .css-2rul56-MuiFormLabel-root-MuiInputLabel-root": {
1132
- top: "-10px",
1133
- },
1134
- "& .css-12ciryo-MuiFormLabel-root-MuiInputLabel-root ": {},
1135
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input ": {
1136
- outline: "none",
1137
- border: "1px solid #ced4da", // Add this line to set border to none
1138
- },
1139
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input:focus ": {
1140
- outline: "none",
1141
- border: "none", // Set border to none when input is focused
1142
- },
1143
- "& .css-1y03twt-MuiInputBase-root-MuiOutlinedInput-root": {
1144
- padding: "5px 5px", // Set border to none when input is focused
1145
- fontSize: "11px",
1146
- },
1147
- "& textarea": {
1148
- fontSize: "11px",
1149
- // textTransform:'uppercase'
1150
- maxHeight: "500px !important",
1151
- overflow: "auto",
1152
- },
1153
- }));
1154
-
1155
- const FormTextAreaField = ({ props, variant, }) => {
1156
- const isError = !!props.errors?.[props.item.name];
1157
- const isShowBorderError = isError && props.fieldError;
1158
- 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: {
1159
- style: {
1160
- border: "none",
1161
- },
1162
- }, sx: {
1163
- ...props.item.sx,
1164
- }, minRows: props.item.minRows || 1, maxRows: props.item.maxRows || 100, placeholder: props.item.placeholder || "Type Something...", ...field, label: variant !== "standard"
1165
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1166
- : "", error: isShowBorderError, value: field.value || "", disabled: props.item.disable, inputProps: {
1167
- onInput: (e) => {
1168
- if (!props?.item?.allowSpecialChars) {
1169
- const value = e.target.value;
1170
- e.target.value = value.replace(/[^a-zA-Z0-9 ]/g, "");
1171
- } // Allow only alphanumeric and space
1172
- if (e.target.value.length === 1 && e.target.value === " ") {
1173
- e.target.value = "";
1174
- }
1175
- },
1176
- } }), jsx(FormBottomField, { ...props })] })) }, props.item.name) }));
1177
- };
1178
-
1179
- const FormTextFieldComponent = styled(TextField)(() => ({
1180
- "& .css-1holvmy,.css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root, .css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
1181
- top: "-10px",
1182
- },
1183
- "& .css-2rul56-MuiFormLabel-root-MuiInputLabel-root": {
1184
- top: "-10px",
1185
- },
1186
- "& .css-12ciryo-MuiFormLabel-root-MuiInputLabel-root ": {},
1187
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input ": {
1188
- outline: "none",
1189
- border: "1px solid #ced4da", // Add this line to set border to none
1190
- },
1191
- "& .css-1gq5vhi-MuiInputBase-root-MuiOutlinedInput-root input:focus ": {
1192
- outline: "none",
1193
- border: "none", // Set border to none when input is focused
1194
- },
1195
- }));
1196
-
1197
- const FormTextField = ({ props, variant, }) => {
1198
- const isError = !!props.errors?.[props.item.name];
1199
- const isShowBorderError = isError && props.fieldError;
1200
- const label = variant !== "standard"
1201
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1202
- : "";
1203
- const onInput = (e) => {
1204
- if (props?.item?.donotAllowSpace) {
1205
- const value = e.target.value;
1206
- e.target.value = value.replace(" ", "");
1207
- }
1208
- if (!props?.item?.allowSpecialChars) {
1209
- const value = e.target.value;
1210
- e.target.value = value.replace(/[^a-zA-Z0-9 ]/g, "");
1211
- } // Allow only alphanumeric and space
1212
- if (e.target.value.length === 1 && e.target.value === " ") {
1213
- e.target.value = "";
1214
- }
1215
- props.item.onInputProps && props.item.onInputProps(e);
1216
- };
1217
- 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: {
1218
- style: {
1219
- border: "none",
1220
- },
1221
- }, autoComplete: "off", sx: {
1222
- ...props.item.sx,
1223
- }, value: field.value || "", size: "small", disabled: props.item.disable, onBlur: (e) => {
1224
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1225
- }, inputProps: {
1226
- maxLength: props.item.maxLength || 100,
1227
- onInput: onInput,
1228
- onPaste: (e) => {
1229
- if (props.item.doNotAllowPaste) {
1230
- e.preventDefault();
1231
- }
1232
- },
1233
- } }), jsx(FormBottomField, { ...props })] })) }, props.item.name));
1234
- };
1235
-
1236
- const PasswordField = ({ props, variant, }) => {
1237
- const [showPassword, setShowPassword] = useState(false);
1238
- const handleTogglePasswordVisibility = () => {
1239
- setShowPassword((prevShowPassword) => !prevShowPassword);
1240
- };
1241
- const label = variant !== "standard"
1242
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1243
- : "";
1244
- const isError = !!props.errors?.[props.item.name];
1245
- const isShowBorderError = isError && props.fieldError;
1246
- 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: {
1247
- width: "100%",
1248
- "& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy": {
1249
- top: "-8px",
1250
- },
1251
- }, inputProps: {
1252
- maxLength: props.item.maxLength || 100,
1253
- onInput: (e) => {
1254
- props.item.onInputProps && props.item.onInputProps(e);
1255
- },
1256
- onPaste: (e) => {
1257
- if (props.item?.doNotAllowPaste) {
1258
- e.preventDefault();
1259
- }
1260
- },
1261
- }, value: field.value || null, disabled: props.item.disable }), jsx(IconButton, { sx: {
1262
- position: "absolute",
1263
- right: "14px",
1264
- top: variant === "standard" ? "70%" : "50%",
1265
- transform: "translateY(-50%)",
1266
- width: "25px",
1267
- }, "aria-label": "toggle password visibility", onClick: handleTogglePasswordVisibility, edge: "end", children: showPassword ? (jsx(Visibility, { sx: {
1268
- fontSize: "12px",
1269
- position: "absolute",
1270
- } })) : (jsx(VisibilityOff, { sx: {
1271
- fontSize: "12px",
1272
- position: "absolute",
1273
- } })) })] }), jsx(FormBottomField, { ...props })] })) })] }) }, props.item.name));
1274
- };
1275
-
1276
- const RichTextEditor = ({ props }) => {
1277
- const editor = useRef(null);
1278
- const [content, setContent] = useState("");
1279
- const value = props.getValues(props.item.name);
1280
- const config = {
1281
- readonly: false,
1282
- placeholder: props.item.placeholder || "Start typing...",
1283
- statusbar: false,
1284
- removeButtons: props.item.removeButtons,
1285
- style: {
1286
- "font-family": "Arial",
1287
- },
1288
- controls: {
1289
- font: {
1290
- list: {
1291
- Arial: "Arial",
1292
- ...props.item?.FontFamily,
1293
- },
1294
- },
1295
- fontsize: {
1296
- list: Jodit.atom(props.item.Fonts || [
1297
- 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1298
- 25, 26, 27, 28, 29, 30,
1299
- ]),
1300
- },
1301
- },
1302
- defaultFont: "Arial",
1303
- defaultFontSize: "11px",
1304
- askBeforePasteFromWord: false,
1305
- askBeforePasteHTML: false,
1306
- hotkeys: {
1307
- redo: "ctrl+z",
1308
- undo: "ctrl+y,ctrl+shift+z",
1309
- indent: "ctrl+]",
1310
- outdent: "ctrl+[",
1311
- bold: "ctrl+b",
1312
- italic: "ctrl+i",
1313
- removeFormat: "ctrl+shift+m",
1314
- insertOrderedList: "ctrl+shift+7",
1315
- insertUnorderedList: "ctrl+shift+8",
1316
- openSearchDialog: "ctrl+f",
1317
- openReplaceDialog: "ctrl+r",
1318
- },
1319
- events: {
1320
- processPaste: (_event, html) => {
1321
- const instance = editor.current;
1322
- if (instance?.editor) {
1323
- const joditEditor = instance.editor;
1324
- joditEditor.selection.insertHTML(html);
1325
- joditEditor.tempContent = joditEditor.getHTML();
1326
- }
1327
- },
1328
- afterPaste: () => {
1329
- const instance = editor.current;
1330
- if (instance?.editor) {
1331
- const joditEditor = instance.editor;
1332
- const el = document.createElement("div");
1333
- el.innerHTML = joditEditor.tempContent
1334
- ? joditEditor.tempContent
1335
- : joditEditor.getHTML();
1336
- joditEditor.setHTML(el.innerHTML);
1337
- joditEditor.tempContent = null;
1338
- }
1339
- },
1340
- },
1341
- ...props.item.sx,
1342
- };
1343
- useEffect(() => {
1344
- setContent(value);
1345
- }, [value]);
1346
- const handleBlur = (newContent) => {
1347
- if (newContent === "<p><br></p>") {
1348
- setContent(newContent);
1349
- props.setValue(props.item.name, "");
1350
- }
1351
- else {
1352
- setContent(newContent);
1353
- props.setValue(props.item.name, newContent);
1354
- }
1355
- props.item.onBlurFn && props.item.onBlurFn(newContent);
1356
- };
1357
- const handleChange = (newContent) => {
1358
- props.item.onChangeFn && props.item.onChangeFn(newContent);
1359
- };
1360
- return (jsx(JoditEditor, { ref: editor, value: content, config: config,
1361
- // tabIndex={1 as IJoditEditorProps["tabIndex"]}
1362
- onBlur: handleBlur, onChange: handleChange }));
1363
- };
1364
-
1365
- const RichTextEditorWrapper = ({ props, variant, }) => {
1366
- 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));
1367
- };
1368
-
1369
- const ITEM_HEIGHT$1 = 48;
1370
- const ITEM_PADDING_TOP$1 = 3;
1371
- const MenuProps$1 = {
1372
- PaperProps: {
1373
- style: {
1374
- maxHeight: ITEM_HEIGHT$1 * 5.5 + ITEM_PADDING_TOP$1,
1375
- // width: 250,
1376
- },
1377
- },
1378
- autoFocus: false,
1379
- disableAutoFocusItem: true,
1380
- };
1381
- // const useStyles = makeStyles(() => ({
1382
- // option: {
1383
- // fontSize: "10px", // Adjust the font size as needed
1384
- // },
1385
- // option2: {
1386
- // fontSize: "11px",
1387
- // },
1388
- // }));
1389
- const extractValuesToArray$1 = (inputString) => {
1390
- const valuesArray = inputString?.split(",");
1391
- const trimmedArray = valuesArray?.map((value) => value.trim());
1392
- return trimmedArray;
1393
- };
1394
- function MultiSelectV1({ props, variant, }) {
1395
- const [personName, setPersonName] = React__default.useState(props.getValues(props.item.name)
1396
- ? extractValuesToArray$1(props.getValues(props.item.name))
1397
- : []);
1398
- const [searchText, setSearchText] = useState("");
1399
- const options = props.item?.options || [];
1400
- const [filterOptions, setFilterOptions] = useState(props.item.options || []);
1401
- const [selectAll, setSelectAll] = useState(false);
1402
- const textfieldRef = React__default.useRef(null);
1403
- const fieldValue = props.getValues(props.item.name);
1404
- const mappedIds = filterOptions.map((item) => item.value);
1405
- const filterIds = filterOptions.map((item) => item.value);
1406
- React__default.useEffect(() => {
1407
- if (searchText !== "") {
1408
- setFilterOptions(options.filter((item) => item.label.toLowerCase().includes(searchText.toLowerCase())));
1409
- }
1410
- else {
1411
- setFilterOptions(options);
1412
- }
1413
- }, [options, searchText]);
1414
- function hasExactMatch(array, value) {
1415
- return array.some((item) => item === value);
1416
- }
1417
- React__default.useEffect(() => {
1418
- if (fieldValue?.split(",").length !== filterOptions.length) {
1419
- setSelectAll(false);
1420
- }
1421
- else {
1422
- console.log(fieldValue?.split(","), 'fieldValue?.split(",")', filterIds);
1423
- if (fieldValue
1424
- ?.split(",")
1425
- .every((value) => hasExactMatch(filterIds, value))) {
1426
- setSelectAll(true);
1427
- }
1428
- }
1429
- }, [filterOptions, fieldValue]);
1430
- const handleChange = (event) => {
1431
- const { target: { value }, } = event;
1432
- setPersonName(typeof value === "string" ? value?.split(",") : value);
1433
- props.setValue(props.item.name, (typeof value === "string" ? value?.split(",") : value).join(","));
1434
- };
1435
- const selectedOptions = options.filter((item) => fieldValue?.split(",").some((value) => value === item.value));
1436
- const selectedValues = selectedOptions
1437
- .map((item) => item.label)
1438
- .join(" , ");
1439
- const isError = !!props.errors?.[props.item.name];
1440
- const isShowBorderError = isError && props.fieldError;
1441
- return (jsx(Box, { children: jsxs(FormControl$1, { fullWidth: true, sx: {
1442
- "& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy": {
1443
- top: "-10px",
1444
- },
1445
- "& .MuiFormLabel-root": {
1446
- top: -10,
1447
- },
1448
- "& .MuiInputLabel-shrink": {
1449
- top: 0,
1450
- },
1451
- }, 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: {
1452
- "& .MuiTypography-root": {
1453
- fontSize: "5px !important",
1454
- },
1455
- }, error: isShowBorderError, disabled: props.item.disable, value: props.getValues(props.item.name)
1456
- ? extractValuesToArray$1(props.getValues(props.item.name))
1457
- : [], onChange: handleChange, onOpen: () => {
1458
- setTimeout(() => {
1459
- if (textfieldRef.current) {
1460
- textfieldRef.current?.focus();
1461
- }
1462
- }, 0);
1463
- }, onClose: () => {
1464
- setSearchText("");
1465
- props?.item?.onCloseMenu && props?.item?.onCloseMenu();
1466
- }, input: jsx(OutlinedInput, { label: variant !== "standard" ? props.item.label : "" }), renderValue: (_selected) => (jsx(Tooltip, { title: selectedValues, children: jsx("span", { children: selectedOptions.length >
1467
- (props.item.multiSelectLabelLength || 3)
1468
- ? `${selectedOptions.length} Selected`
1469
- : selectedValues }) })), MenuProps: MenuProps$1, autoFocus: false, children: [jsx(Box, { sx: {
1470
- width: "100%",
1471
- position: "sticky",
1472
- top: "0px",
1473
- padding: "7px",
1474
- zIndex: 2,
1475
- height: "33px",
1476
- background: "#fff",
1477
- display: options.length === 0 ? "none" : undefined,
1478
- }, children: jsx(TextField, { inputRef: textfieldRef, autoFocus: true, value: searchText, sx: {
1479
- width: "100%",
1480
- }, placeholder: "Search...", onChange: (e) => {
1481
- setSearchText(e.target.value);
1482
- }, onKeyDown: (e) => {
1483
- if (e.key !== "Escape") {
1484
- e.stopPropagation();
1485
- }
1486
- } }) }), jsxs(MenuItem$1, { disabled: filterOptions.length === 0, sx: { zIndex: 0, fontSize: "5px !important" }, children: [jsx(Checkbox$1, { size: "small", checked: selectAll, onChange: () => {
1487
- setSelectAll(!selectAll);
1488
- const selectChanged = !selectAll;
1489
- if (!selectChanged) {
1490
- props.setValue(props.item.name, "");
1491
- }
1492
- else {
1493
- const allDataMapped = mappedIds.join(",");
1494
- console.log(allDataMapped, "allDataMapped");
1495
- props.setValue(props.item.name, allDataMapped);
1496
- }
1497
- } }), jsx(ListItemText, { primary: "Select All", sx: {
1498
- fontSize: "5px !important",
1499
- "& span": {
1500
- fontSize: "12px !important",
1501
- },
1502
- } })] }), filterOptions.length !== 0 ? (filterOptions.map((option) => (jsxs(MenuItem$1, { value: `${option.value}`, sx: { zIndex: 0, fontSize: "11px !important" }, children: [jsx(Checkbox$1, { checked: fieldValue
1503
- ?.split(",")
1504
- .some((value) => value === option.value), size: "small" }), jsx(ListItemText, { primary: option.label, sx: {
1505
- fontSize: "5px !important",
1506
- "& span": {
1507
- fontSize: "12px !important",
1508
- },
1509
- } })] }, option.value)))) : (jsx(MenuItem$1, { disabled: true, value: "NA", children: "No data Found" }, "NA"))] }), jsx(FormBottomField, { ...props })] }) }, props.item.name));
1510
- }
1511
-
1512
- const SingleSelect = ({ props, variant, }) => {
1513
- const isError = !!props.errors?.[props.item.name];
1514
- const isShowBorderError = isError && props.fieldError && !props.getValues(props.item.name);
1515
- const value = props.getValues(props.item.name)
1516
- ? props.item.options?.find((item) => item.value === props.getValues(props.item.name))
1517
- : null;
1518
- 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) => {
1519
- props.setValue(props?.item?.name, newValue?.value);
1520
- props?.item?.onChangeFn &&
1521
- props?.item?.onChangeFn(newValue?.value);
1522
- props?.clearErrors && props?.clearErrors(props?.item?.name);
1523
- }, onBlur: (e) => {
1524
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1525
- }, size: "small", sx: {
1526
- "& .MuiAutocomplete-input": {
1527
- padding: "0px 0px 0px 5px !important",
1528
- },
1529
- "& .css-erkti9-MuiFormLabel-root-MuiInputLabel-root,.css-8edmr2-MuiFormLabel-root-MuiInputLabel-root": {
1530
- top: "-3px",
1531
- },
1532
- "& .MuiAutocomplete-option": {
1533
- fontSize: "11px",
1534
- zIndex: 2000,
1535
- },
1536
- ...props.item.sx,
1537
- }, ListboxProps: {
1538
- onScroll: (event) => {
1539
- const listboxNode = event.currentTarget;
1540
- if (listboxNode.scrollTop + listboxNode.clientHeight ===
1541
- listboxNode.scrollHeight) ;
1542
- },
1543
- }, disabled: props.item.disable, options: props.item.options || [], slotProps: {
1544
- popper: {
1545
- sx: {
1546
- zIndex: 1401,
1547
- },
1548
- },
1549
- }, renderInput: (params) => {
1550
- return (jsx(Tooltip, { title: params.inputProps.value && params.inputProps.value, children: jsx(TextField, { ...params, placeholder: props.item.placeholder, error: isShowBorderError, label: variant !== "standard"
1551
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1552
- : "" }) }));
1553
- } }), jsx(FormBottomField, { ...props })] })) }, props.item.name));
1554
- };
1555
-
1556
- const SingleSelectNonAutoComplete = ({ props, variant, }) => {
1557
- const isError = !!props.errors?.[props.item.name];
1558
- const isShowBorderError = isError && props.fieldError;
1559
- return (jsxs(FormControl, { fullWidth: true, sx: {
1560
- position: "relative",
1561
- "& .MuiFormLabel-root": {
1562
- top: -10,
1563
- },
1564
- "& .MuiInputLabel-shrink": {
1565
- top: 0,
1566
- },
1567
- }, 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"
1568
- ? `${props.item.label}${props.item.required ? " *" : ""}`
1569
- : "", onChange: (e) => props.setValue(props.item.name, e.target.value), onBlur: (e) => {
1570
- props?.item?.onBlurFn && props?.item?.onBlurFn(e);
1571
- }, error: isShowBorderError, children: (props.item.options || []).map((item) => (jsx(MenuItem, { sx: {
1572
- fontSize: "11px", // Adjust the font size as needed
1573
- zIndex: 2000,
1574
- }, value: item.value, children: item.label }))) }), jsx(FormBottomField, { ...props })] }, props.item.name));
1575
- };
1576
-
1577
- function TimePickerFieldWrapper({ props, variant, }) {
1578
- const value = props.getValues(props.item.name);
1579
- const isError = !!props.errors?.[props.item.name];
1580
- const isShowBorderError = isError && props.fieldError;
1581
- 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) => {
1582
- const parsedTime = parseCustomTime(formatDayjsToCustomTime(newTime));
1583
- const min = props.item.minTime
1584
- ? parseCustomTime(props.item.minTime)
1585
- : null;
1586
- const max = props.item.maxTime
1587
- ? parseCustomTime(props.item.maxTime)
1588
- : null;
1589
- let finalTime = parsedTime;
1590
- if (min && parsedTime?.isBefore(min)) {
1591
- finalTime = min;
1592
- }
1593
- else if (max && parsedTime?.isAfter(max)) {
1594
- finalTime = max;
1595
- }
1596
- const formatted = formatDayjsToCustomTime(finalTime);
1597
- props.setValue(props.item.name, formatted);
1598
- props.item.onChangeFn && props.item.onChangeFn(formatted);
1599
- }, minTime: props.item.minTime
1600
- ? parseCustomTime(props.item.minTime) || undefined
1601
- : undefined, maxTime: props.item.maxTime
1602
- ? parseCustomTime(props.item.maxTime) || undefined
1603
- : undefined, label: props.variant === "standard" ? "" : props.item.label, disabled: props.item.disable, slotProps: {
1604
- textField: {
1605
- size: "small",
1606
- error: isShowBorderError,
1607
- inputProps: {
1608
- readOnly: true,
1609
- },
1610
- sx: {
1611
- "& .MuiFormLabel-root": {
1612
- top: -3,
1613
- },
1614
- "& .MuiInputLabel-shrink": {
1615
- top: 0,
1616
- },
1617
- },
1618
- },
1619
- } })] })) }), jsx(ErrorMessageComponent, { children: jsx(ErrorMessage, { errors: props.errors, name: props.item.name }) })] }));
1620
- }
1621
-
1622
- const FormActiveSwitch = ({ props }) => {
1623
- const [active, setActive] = useState(true);
1624
- const { getValues, setValue, item } = props;
1625
- const defaultValue1 = item.value1 ?? "A";
1626
- const defaultValue2 = item.value2 ?? "I";
1627
- useEffect(() => {
1628
- const currentValue = getValues(item.name);
1629
- setActive(currentValue === defaultValue1);
1630
- }, [getValues, item.name, defaultValue1]);
1631
- const handleSwitchChange = useCallback(() => {
1632
- setActive((prevActive) => {
1633
- const newValue = !prevActive ? defaultValue1 : defaultValue2;
1634
- setValue(item.name, newValue);
1635
- return !prevActive;
1636
- });
1637
- }, [setValue, item.name, defaultValue1, defaultValue2]);
1638
- return (jsxs("div", { className: "m-form__input", children: [item.label && (jsx("span", { style: {
1639
- fontSize: "12px",
1640
- fontWeight: 400,
1641
- paddingRight: 10,
1642
- }, 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" })] })] }));
1643
- };
1644
-
1645
- // Main renderer function: decides which form field component to render
1646
- // based on the `inputType` defined in `props.item`
1647
- const RenderForm = (props) => {
1648
- // Variant is an optional property that controls UI style differences
1649
- const variant = props.variant || "";
1650
- // Switch between different input types and render the corresponding component
1651
- switch (props.item?.inputType) {
1652
- // Common text-based inputs
1653
- case "text":
1654
- case "multiEmail":
1655
- case "email":
1656
- return jsx(FormTextField, { props: props, variant: variant });
1657
- // Rich text editor
1658
- case "rich-text-editor":
1659
- return jsx(RichTextEditorWrapper, { props: props, variant: variant });
1660
- // Password field
1661
- case "password":
1662
- return jsx(PasswordField, { props: props, variant: variant });
1663
- // Dropdown select (auto-complete)
1664
- case "select":
1665
- return jsx(SingleSelect, { props: props, variant: variant });
1666
- // Dropdown select (non auto-complete)
1667
- case "select-v2":
1668
- return jsx(SingleSelectNonAutoComplete, { props: props, variant: variant });
1669
- // Numeric inputs (integer, pincode, phone)
1670
- case "number":
1671
- case "pincode":
1672
- case "phoneNumber":
1673
- return jsx(FormNumberField, { props: props, variant: variant });
1674
- // Decimal input
1675
- case "decimal":
1676
- return jsx(FormNumberFieldDecimal, { props: props, variant: variant });
1677
- // Checkbox group (multiple options)
1678
- case "checkbox-group":
1679
- return jsx(FormCheckBoxGroup, { props: props, variant: variant });
1680
- // Radio group (single option)
1681
- case "radio-group":
1682
- return jsx(FormRadioGroup, { props: props, variant: variant });
1683
- // Date picker
1684
- case "datepicker":
1685
- return jsx(DatepickerWrapperV2, { props: props, variant: variant });
1686
- // Time picker
1687
- case "timepicker":
1688
- return jsx(TimePickerFieldWrapper, { props: props, variant: variant });
1689
- // Date range picker - TEMPORARILY DISABLED
1690
- case "dateRangePicker":
1691
- return jsx("div", {});
1692
- // return <DateRangePickerComponent props={props} variant={variant} />;
1693
- // Month picker
1694
- case "monthpicker":
1695
- return jsx(Monthpickerrender, { props: props, variant: variant });
1696
- // Multi-select dropdown
1697
- case "multiselect":
1698
- return jsx(MultiSelectV1, { props: props, variant: variant });
1699
- // Single file upload
1700
- case "file":
1701
- return jsx(FormRenderFileUpload, { props: props, variant: variant });
1702
- // Multi file upload
1703
- case "multifile":
1704
- return jsx(FormRenderMultiFileUpload, { props: props, variant: variant });
1705
- // Single checkbox
1706
- case "checkbox":
1707
- return jsx(FormCheckBox, { props: props, variant: variant });
1708
- // Multi-line text input
1709
- case "textarea":
1710
- return jsx(FormTextAreaField, { props: props, variant: variant });
1711
- // Toggle switch (active/inactive)
1712
- case "toggleSwitch":
1713
- return jsx(FormActiveSwitch, { props: props }, props.item.name);
1714
- // Default case: if input type is not found, return nothing
1715
- default:
1716
- return jsx(Fragment, {});
1717
- }
1718
- };
1719
-
1720
- const FormRenderWrapper = ({ formArray, name = "", numberOfColumns = 3, form, variant = "", fieldError, }) => {
1721
- return (jsx(ThemeProvider, { theme: customTheme, children: jsx(FormComponent, { container: true, margin: "auto", children: formArray.map((item, i) => {
1722
- return (item.inputType && (jsx(Formitem, { container: true, sx: item.CustomProps, noOfColumn: item.numberOfColumns || numberOfColumns, children: 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}`)));
1723
- }) }) }));
1724
- };
1725
-
1726
- const ModalField = ({ name, openModal, handleCancel, content, width = "900px", Transition = "", handleSubmit, styles = {}, saveButton: isSaveButton = false, submitButton = true, handleSaveButton = () => null, SubmitButtonName = "Submit", }) => {
1727
- const TransitionComponent = () => {
1728
- switch (Transition) {
1729
- case "Slide":
1730
- return Slide;
1731
- default:
1732
- return undefined;
1733
- }
1734
- };
1735
- return (jsxs(DialogContainer, { open: openModal, TransitionComponent: TransitionComponent(), fullWidth: true, "aria-labelledby": "draggable-dialog-title", sx: {
1736
- zIndex: 20,
1737
- "& .css-tlc64q-MuiPaper-root-MuiDialog-paper,.css-mbdu2s": {
1738
- maxWidth: width,
1739
- },
1740
- ...styles,
1741
- }, children: [jsxs(DialogTitleWrapper, { children: [jsx("span", { children: name }), jsx(CloseIcon, { sx: { cursor: "pointer" }, onClick: () => handleCancel() })] }), jsx(DialogContent, { style: { paddingTop: "20px", paddingBottom: 0 }, sx: {
1742
- "& .pt-0": {
1743
- paddingTop: 0,
1744
- },
1745
- }, children: content }), jsx(DialogActions, { sx: { borderTop: "1px solid #e0e0e0", marginTop: 3 }, children: jsxs("div", { style: {
1746
- display: "flex",
1747
- justifyContent: "flex-end",
1748
- gap: "8px",
1749
- }, 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" })] }) })] }));
1750
- };
1751
-
1752
- const ITEM_HEIGHT = 48;
1753
- const ITEM_PADDING_TOP = 3;
1754
- const MenuProps = {
1755
- PaperProps: {
1756
- style: {
1757
- maxHeight: ITEM_HEIGHT * 5.5 + ITEM_PADDING_TOP,
1758
- },
1759
- },
1760
- autoFocus: false,
1761
- disableAutoFocusItem: true,
1762
- };
1763
- const extractValuesToArray = (inputString) => {
1764
- const valuesArray = inputString?.split(",");
1765
- const trimmedArray = valuesArray?.map((value) => value.trim());
1766
- return trimmedArray;
1767
- };
1768
- function MultiSelectFieldComponent({ value, options, onChangeFn, disable = false, }) {
1769
- const [personName, setPersonName] = React.useState(value ? extractValuesToArray(value) : []);
1770
- const [searchText, setSearchText] = useState("");
1771
- const [filterOptions, setFilterOptions] = useState(options);
1772
- const [selectAll, setSelectAll] = useState(false);
1773
- const textfieldRef = React.useRef(null);
1774
- const fieldValue = value;
1775
- const mappedIds = filterOptions.map((item) => item.value);
1776
- const filterIds = filterOptions.map((item) => item.value);
1777
- React.useEffect(() => {
1778
- if (searchText !== "") {
1779
- setFilterOptions(options.filter((item) => item.label.toLowerCase().includes(searchText.toLowerCase())));
1780
- }
1781
- else {
1782
- setFilterOptions(options);
1783
- }
1784
- }, [options, searchText]);
1785
- function hasExactMatch(array, value) {
1786
- return array.some((item) => item === value);
1787
- }
1788
- React.useEffect(() => {
1789
- if (fieldValue?.split(",").length !== filterOptions.length) {
1790
- setSelectAll(false);
1791
- }
1792
- else {
1793
- if (fieldValue
1794
- ?.split(",")
1795
- .every((value) => hasExactMatch(filterIds, value))) {
1796
- setSelectAll(true);
1797
- }
1798
- }
1799
- }, [filterOptions, fieldValue]);
1800
- const handleChange = (event) => {
1801
- const { target: { value }, } = event;
1802
- setPersonName(typeof value === "string" ? value?.split(",") : value);
1803
- onChangeFn((typeof value === "string" ? value?.split(",") : value).join(","));
1804
- };
1805
- const selectedOptions = options.filter((item) => fieldValue?.split(",").some((value) => value === item.value));
1806
- const selectedValues = selectedOptions
1807
- .map((item) => item.label)
1808
- .join(" , ");
1809
- return (jsx(Box, { children: jsx(FormControl$1, { fullWidth: true, sx: {
1810
- "& .css-kichxs-MuiFormLabel-root-MuiInputLabel-root,.css-1holvmy": {
1811
- top: "-10px",
1812
- },
1813
- }, children: jsxs(Select, { labelId: "demo-multiple-checkbox-label", id: "demo-multiple-checkbox", multiple: true, sx: {
1814
- "& .MuiTypography-root": {
1815
- fontSize: "5px !important",
1816
- },
1817
- }, disabled: disable, value: value ? extractValuesToArray(value) : [], onChange: handleChange, onOpen: () => {
1818
- setTimeout(() => {
1819
- if (textfieldRef.current) {
1820
- textfieldRef.current?.focus();
1821
- }
1822
- }, 0);
1823
- }, onClose: () => {
1824
- setSearchText("");
1825
- }, renderValue: () => (jsx(Tooltip, { title: selectedValues, children: jsx("span", { children: selectedOptions.length > 3
1826
- ? `${selectedOptions.length} Selected`
1827
- : selectedValues }) })), MenuProps: MenuProps, autoFocus: false, children: [jsx(Box, { sx: {
1828
- width: "100%",
1829
- position: "sticky",
1830
- top: "0px",
1831
- padding: "7px",
1832
- zIndex: 2,
1833
- height: "33px",
1834
- background: "#fff",
1835
- display: options.length === 0 ? "none" : undefined,
1836
- }, children: jsx(TextField, { inputRef: textfieldRef, autoFocus: true, value: searchText, sx: {
1837
- width: "100%",
1838
- }, placeholder: "Search...", onChange: (e) => {
1839
- setSearchText(e.target.value);
1840
- }, onKeyDown: (e) => {
1841
- if (e.key !== "Escape") {
1842
- e.stopPropagation();
1843
- }
1844
- } }) }), jsxs(MenuItem$1, { disabled: filterOptions.length === 0, sx: { zIndex: 0, fontSize: "5px !important" }, children: [jsx(Checkbox$1, { size: "small", checked: selectAll, onChange: () => {
1845
- setSelectAll(!selectAll);
1846
- const selectChanged = !selectAll;
1847
- if (!selectChanged) {
1848
- onChangeFn("");
1849
- }
1850
- else {
1851
- const allDataMapped = mappedIds.join(",");
1852
- console.log(allDataMapped, "allDataMapped");
1853
- onChangeFn(allDataMapped);
1854
- }
1855
- } }), jsx(ListItemText, { primary: "Select All", sx: {
1856
- fontSize: "5px !important",
1857
- "& span": {
1858
- fontSize: "12px !important",
1859
- },
1860
- } })] }), filterOptions.length !== 0 ? (filterOptions.map((option) => (jsxs(MenuItem$1, { value: `${option.value}`, sx: { zIndex: 0, fontSize: "11px !important" }, children: [jsx(Checkbox$1, { checked: fieldValue
1861
- ?.split(",")
1862
- .some((value) => value === option.value), size: "small" }), jsx(ListItemText, { primary: option.label, sx: {
1863
- fontSize: "5px !important",
1864
- "& span": {
1865
- fontSize: "12px !important",
1866
- },
1867
- } })] }, option.value)))) : (jsx(MenuItem$1, { disabled: true, value: "NA", children: "No data Found" }, "NA"))] }) }) }));
1868
- }
1869
-
1870
- const secondsToMMSS = (totalSeconds) => {
1871
- const minutes = Math.floor(totalSeconds / 60);
1872
- const seconds = Math.floor(totalSeconds % 60);
1873
- const formattedMinutes = String(minutes).padStart(2, "0");
1874
- const formattedSeconds = String(seconds).padStart(2, "0");
1875
- return `${formattedMinutes}:${formattedSeconds}`;
1876
- };
1877
- const promptBeforeValue = 120000;
1878
- const SessionTimeOut = ({ sessionTime, handleSubmitSession, onSessionExpire, handleSessionCancel, SubmitButtonName = "Submit", buttonStyleProps, }) => {
1879
- const [openConfirmModal, setOpenConfirmModal] = useState(false);
1880
- const expiryDetails = sessionTime;
1881
- const providedTimestamp = new Date(expiryDetails).getTime();
1882
- const currentTimestamp = new Date().getTime();
1883
- const remainingTime = providedTimestamp - currentTimestamp;
1884
- const timeout = remainingTime;
1885
- const promptBeforeIdle = Math.min(promptBeforeValue, timeout - 1000);
1886
- const [, setRemainingTimeInSeconds] = useState(Math.ceil(timeout / 1000));
1887
- const [formattedRemainingTime, setFormattedRemainingTime] = useState(secondsToMMSS(Math.ceil(timeout / 1000)));
1888
- const onIdle = () => {
1889
- if (sessionTime) {
1890
- onSessionExpire();
1891
- }
1892
- };
1893
- const handleSubmit = () => {
1894
- handleSubmitSession();
1895
- setOpenConfirmModal(false);
1896
- };
1897
- const handleCancel = () => {
1898
- handleSessionCancel();
1899
- setOpenConfirmModal(false);
1900
- };
1901
- const onPrompt = () => {
1902
- setOpenConfirmModal(true);
1903
- };
1904
- const { getRemainingTime } = useIdleTimer({
1905
- onIdle,
1906
- onPrompt,
1907
- promptBeforeIdle,
1908
- timeout,
1909
- throttle: 1000, // Adjust throttle to reduce delays
1910
- });
1911
- useEffect(() => {
1912
- const interval = setInterval(() => {
1913
- const remainingSeconds = Math.ceil(getRemainingTime() / 1000);
1914
- setRemainingTimeInSeconds(promptBeforeIdle !== promptBeforeValue ? remainingSeconds : 0);
1915
- const formattedTime = secondsToMMSS(remainingSeconds);
1916
- setFormattedRemainingTime(promptBeforeIdle !== promptBeforeValue ? formattedTime : "00:00");
1917
- }, 1000); // Adjust interval to 1000 ms
1918
- return () => {
1919
- clearInterval(interval);
1920
- };
1921
- }, [promptBeforeIdle, getRemainingTime]);
1922
- const sessionMessage = `Your session will expire in ${formattedRemainingTime} seconds. Do you want to extend the session?`;
1923
- console.log(promptBeforeIdle, "promptBeforeIdle");
1924
- return (jsx(Fragment, { children: jsx(ConfirmationDialog, { openConfirmDialog: openConfirmModal, handleCancel: handleCancel, onClickSubmit: handleSubmit, text: sessionMessage, Submit: SubmitButtonName, buttonStyleProps: buttonStyleProps }) }));
1925
- };
1926
-
1927
- const toTitleCase = (str) => {
1928
- return str
1929
- .replace(/([A-Z])/g, " $1") // Insert space before capital letters
1930
- .replace(/^./, (match) => match.toUpperCase()) // Capitalize the first letter
1931
- .trim(); // Remove any leading or trailing spaces
1932
- };
1933
- const getMaxLength = (data, key) => {
1934
- const keyLength = key.length;
1935
- // Length of the key (column header)
1936
- const dataMaxLength = Math.max(...data.map((item) => (item[key] ? item[key].toString().length : 0)));
1937
- return Math.max(keyLength, dataMaxLength);
1938
- }; // Return the maximum of key length or data length };
1939
- const handleDownloadReactTableDataExcel = (fileName, rowData, columns = [], customColumns = [], HeaderBackGround = "FFF4694B", HeaderColor = "000000") => {
1940
- const EXCEL_TYPE = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8";
1941
- const EXCEL_EXTENSION = ".xlsx";
1942
- // Exclude 'actions' column and columns with hideOnExcel: true
1943
- const visibleColumns1 = columns.filter((col) => col?.accessorKey !== "actions");
1944
- const visibleColumns = visibleColumns1.filter((col) => !col?.hideOnExcel || col?.hideOnExcel !== true);
1945
- const data = rowData;
1946
- // Map column headers and accessorKeys
1947
- const columnHeaders = visibleColumns.length > 0
1948
- ? visibleColumns.map((col) => col.header)
1949
- : Object.keys(data[0]); // Use data keys as headers if columns are not provided
1950
- const accessorKeys = visibleColumns.length > 0
1951
- ? visibleColumns.map((col) => col.accessorKey)
1952
- : Object.keys(data[0]); // Use data keys as accessor keys if columns are not provided
1953
- // Reformat data to include only visible columns
1954
- const formattedData = data.map((row) => {
1955
- const formattedRow = {};
1956
- accessorKeys.forEach((key) => {
1957
- formattedRow[key] = row[key] || "";
1958
- });
1959
- return formattedRow;
1960
- });
1961
- // Create worksheet
1962
- const ws = XLSX.utils.json_to_sheet(formattedData, { header: accessorKeys });
1963
- // Apply column headers styling dynamically
1964
- accessorKeys.forEach((key, index) => {
1965
- const colLetter = XLSX.utils.encode_col(index); // Excel column letter
1966
- const cellAddress = `${colLetter}1`; // Header row cell
1967
- const headerText = toTitleCase(columnHeaders[index]);
1968
- ws[cellAddress] = {
1969
- t: "s",
1970
- v: headerText,
1971
- s: {
1972
- fill: { patternType: "solid", fgColor: { rgb: HeaderBackGround } },
1973
- font: { bold: true, color: { rgb: HeaderColor }, sz: 12 },
1974
- alignment: { horizontal: "center" },
1975
- },
1976
- };
1977
- // Apply custom color to entire column based on excelColumnColor in the column definition
1978
- const col = visibleColumns.length > 0
1979
- ? visibleColumns[index]
1980
- : customColumns.length > 0 &&
1981
- customColumns.find((item) => item.accessorKey === key);
1982
- if (col && col.excelColumnColor) {
1983
- const columnColor = col.excelColumnColor;
1984
- const textColor = col.excelTextColor;
1985
- // Apply color to all rows in that column (from row 2 onward)
1986
- for (let rowIndex = 2; rowIndex <= formattedData.length + 1; rowIndex++) {
1987
- const cell = `${colLetter}${rowIndex}`;
1988
- ws[cell] = ws[cell] || {}; // Ensure cell exists
1989
- ws[cell].s = ws[cell].s || {}; // Ensure style exists
1990
- ws[cell].s.fill = {
1991
- patternType: "solid",
1992
- fgColor: { rgb: columnColor },
1993
- font: { color: { rgb: textColor } },
1994
- };
1995
- ws[cell].s.border = {
1996
- top: { style: "thin", color: { rgb: "000000" } }, // Black thin border
1997
- bottom: { style: "thin", color: { rgb: "000000" } },
1998
- left: { style: "thin", color: { rgb: "000000" } },
1999
- right: { style: "thin", color: { rgb: "000000" } },
2000
- };
2001
- }
2002
- }
2003
- });
2004
- // Set column widths dynamically or with defaults
2005
- const colWidths = visibleColumns.length > 0
2006
- ? accessorKeys.map((accessorKey) => {
2007
- // Find the corresponding column by accessorKey
2008
- const column = visibleColumns.find((col) => col.accessorKey === accessorKey);
2009
- // Check if `excelColumnSize` is defined for this column
2010
- if (column && column.excelColumnSize) {
2011
- return {
2012
- wch: parseInt(column.excelColumnSize.replace("px", "")) / 7,
2013
- };
2014
- }
2015
- else {
2016
- return { wch: getMaxLength(data, accessorKey) + 5 }; // Default column width
2017
- }
2018
- })
2019
- : customColumns.length > 0
2020
- ? accessorKeys.map((accessorKey) => {
2021
- // Find the corresponding column by accessorKey
2022
- const column = customColumns.find((col) => col.accessorKey === accessorKey);
2023
- // Check if `excelColumnSize` is defined for this column
2024
- if (column && column.excelColumnSize) {
2025
- return {
2026
- wch: parseInt(column.excelColumnSize.replace("px", "")) / 7,
2027
- };
2028
- }
2029
- else {
2030
- return { wch: getMaxLength(data, accessorKey) + 5 }; // Default column width
2031
- }
2032
- })
2033
- : accessorKeys.map((accessorKey) => {
2034
- // Find the corresponding column by accessorKey
2035
- const column = customColumns.find((col) => col.accessorKey === accessorKey);
2036
- // Check if `excelColumnSize` is defined for this column
2037
- if (column && column.excelColumnSize) {
2038
- return {
2039
- wch: parseInt(column.excelColumnSize.replace("px", "")) / 7,
2040
- };
2041
- }
2042
- else {
2043
- return { wch: getMaxLength(data, accessorKey) + 5 }; // Default column width
2044
- }
2045
- });
2046
- ws["!cols"] = colWidths;
2047
- // Create workbook and save it
2048
- const wb = XLSX.utils.book_new();
2049
- XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
2050
- const eb = XLSX.write(wb, { bookType: "xlsx", type: "array" });
2051
- const blob = new Blob([eb], { type: EXCEL_TYPE });
2052
- saveAs(blob, fileName + EXCEL_EXTENSION);
2053
- };
2054
- function getUsernameFromEmail(email) {
2055
- return email.split("@")[0];
2056
- }
2057
- function getInitials(name) {
2058
- if (!name)
2059
- return "";
2060
- const words = name.trim().split(/\s+/); // split by any spaces
2061
- let initials = "";
2062
- for (let i = 0; i < words.length && initials.length < 2; i++) {
2063
- initials += words[i][0].toUpperCase();
2064
- }
2065
- return initials;
2066
- }
2067
- function findMenuHierarchy(menuData, currentUrl, URLProjectNameWithSlash) {
2068
- const url = currentUrl;
2069
- const pathname = url.pathname.replace(URLProjectNameWithSlash, "").toLowerCase() +
2070
- url.search.toLowerCase();
2071
- let result = [];
2072
- function traverse(menus, path = []) {
2073
- for (const menu of menus) {
2074
- const currentPath = [...path, menu];
2075
- const subMenusRaw = []
2076
- .concat(menu.SubMenu || [], menu.SubMenus || [])
2077
- .filter(Boolean);
2078
- // Match found
2079
- if (menu.Path && menu.Path.toLowerCase() === pathname) {
2080
- result = currentPath;
2081
- return true;
2082
- }
2083
- if (subMenusRaw.length > 0) {
2084
- if (traverse(subMenusRaw, currentPath)) {
2085
- return true;
2086
- }
2087
- }
2088
- }
2089
- return false;
2090
- }
2091
- traverse(menuData);
2092
- return result;
2093
- }
2094
- /**
2095
- * Calculates a date by adding/subtracting days from today or a base date
2096
- * @param dayOffset - Days to add (positive) or subtract (negative) (default: 0)
2097
- * @param baseDate - Base date in DD/MM/YYYY format (default: today)
2098
- * @returns Formatted date string in DD/MM/YYYY format
2099
- */
2100
- const getDesiredDate = (dayOffset = 0, baseDate = null) => {
2101
- const startDate = baseDate ? dayjs(baseDate, "DD/MM/YYYY") : dayjs();
2102
- if (!startDate.isValid()) {
2103
- throw new Error("Invalid date format. Please use DD/MM/YYYY.");
2104
- }
2105
- return startDate.add(dayOffset, "day").format("DD/MM/YYYY");
2106
- };
2107
- /**
2108
- * Calculates sum of numeric values for a specific property across array objects
2109
- * @param array - Array of objects to sum
2110
- * @param key - Property name to sum
2111
- * @returns Total sum of numeric values
2112
- */
2113
- function calculateTotalArrayValueTotal(array, key) {
2114
- if (!Array.isArray(array)) {
2115
- return 0;
2116
- }
2117
- return array.reduce((sum, item) => {
2118
- const value = Number(item[key]) || 0;
2119
- return sum + value;
2120
- }, 0);
2121
- }
2122
- /**
2123
- * Checks if first date comes before second date
2124
- * @param dateStr1 - First date in DD/MM/YYYY format
2125
- * @param dateStr2 - Second date in DD/MM/YYYY format
2126
- * @returns True if dateStr1 is before dateStr2
2127
- */
2128
- function checkIsDateIsBefore(dateStr1, dateStr2) {
2129
- const date1 = dayjs(dateStr1.trim(), "DD/MM/YYYY");
2130
- const date2 = dayjs(dateStr2.trim(), "DD/MM/YYYY");
2131
- if (!date1.isValid() || !date2.isValid()) {
2132
- throw new Error("Invalid date format. Please use DD/MM/YYYY.");
2133
- }
2134
- return date1.isBefore(date2);
2135
- }
2136
- /**
2137
- * Lightens a hex color by a specified percentage
2138
- * @param color - Hex color string (with or without #)
2139
- * @param percent - Percentage to lighten (0-100)
2140
- * @returns Lightened hex color string
2141
- */
2142
- function lightenColor(color, percent) {
2143
- const num = parseInt(color.replace("#", ""), 16);
2144
- const amt = Math.round(2.55 * percent);
2145
- const R = (num >> 16) + amt;
2146
- const G = ((num >> 8) & 0x00ff) + amt;
2147
- const B = (num & 0x0000ff) + amt;
2148
- return ("#" +
2149
- (0x1000000 +
2150
- (R < 255 ? (R < 1 ? 0 : R) : 255) * 0x10000 +
2151
- (G < 255 ? (G < 1 ? 0 : G) : 255) * 0x100 +
2152
- (B < 255 ? (B < 1 ? 0 : B) : 255))
2153
- .toString(16)
2154
- .slice(1));
2155
- }
2156
- /**
2157
- * Gets formatted date with optional day offset
2158
- * @param dayOffset - Days to add (positive) or subtract (negative) from today (default: 0)
2159
- * @returns Date string in DD/MM/YYYY format
2160
- */
2161
- function getFormattedDate(dayOffset = 0) {
2162
- return dayjs().add(dayOffset, "day").format("DD/MM/YYYY");
2163
- }
2164
-
2165
- // Utility Functions - Helper functions for form operations and data manipulation
2166
-
2167
- var index$1 = /*#__PURE__*/Object.freeze({
2168
- __proto__: null,
2169
- calculateTotalArrayValueTotal: calculateTotalArrayValueTotal,
2170
- checkIsDateIsBefore: checkIsDateIsBefore,
2171
- extractDate: extractDate,
2172
- findMenuHierarchy: findMenuHierarchy,
2173
- formatDateMonthAndYear: formatDateMonthAndYear,
2174
- formatDayjsToCustomTime: formatDayjsToCustomTime,
2175
- getDesiredDate: getDesiredDate,
2176
- getFormattedDate: getFormattedDate,
2177
- getInitials: getInitials,
2178
- getUsernameFromEmail: getUsernameFromEmail,
2179
- handleDownloadReactTableDataExcel: handleDownloadReactTableDataExcel,
2180
- lightenColor: lightenColor,
2181
- parseCustomTime: parseCustomTime,
2182
- renderLabel: renderLabel
2183
- });
2184
-
2185
- // import { ErrorMessage } from "@hookform/error-message";
2186
- // import {
2187
- // Autocomplete,
2188
- // Skeleton,
2189
- // Stack,
2190
- // TextField,
2191
- // Tooltip,
2192
- // Typography,
2193
- // } from "@mui/material";
2194
- // import { makeStyles } from "@mui/styles";
2195
- // import React, { useEffect, useState } from "react";
2196
- // import { Controller } from "react-hook-form";
2197
- // import { ErrorMessageComponent, OptionRender } from "../Form.styles";
2198
- // import { FormRenderProps } from "../../../Utilities/Interface/FormInterface";
2199
- // const useStyles = makeStyles((theme) => ({
2200
- // option: {
2201
- // fontSize: "11px", // Adjust the font size as needed
2202
- // },
2203
- // option2: {
2204
- // fontSize: "14px",
2205
- // },
2206
- // }));
2207
- // const SingleSelectSearchApi = ({ props }: { props: FormRenderProps }) => {
2208
- // const classes = useStyles();
2209
- // const [searchValue, setSearchValue] = useState<string>("");
2210
- // const [optionsFetched, setOptionsFetched] = useState([]);
2211
- // const [isLoading, setIsLoading] = useState<boolean>(false);
2212
- // console.log(
2213
- // props.getValues(props.item.name),
2214
- // "props.getValues(props.item.name)"
2215
- // );
2216
- // useEffect(() => {
2217
- // const controller = new AbortController();
2218
- // const signal = controller.signal;
2219
- // if (props?.item?.autoFIll && props.getValues(props.item.name)) {
2220
- // setSearchValue(props.getValues(props.item.name));
2221
- // setOptionsFetched([]);
2222
- // } else if (props.getValues(props.item.name)) {
2223
- // setSearchValue(props.getValues(props.item.name));
2224
- // }
2225
- // // if(searchValue!==''){
2226
- // setIsLoading(true);
2227
- // props.item.AxiosInstance.get(
2228
- // props.item.ApiInstance + `&${props.item.searchInstance}=${searchValue}`,
2229
- // {
2230
- // signal,
2231
- // headers: {
2232
- // Authorization: `Bearer ${props.item.tokenInstance}`,
2233
- // },
2234
- // }
2235
- // )
2236
- // .then((res) => {
2237
- // setOptionsFetched(res.data);
2238
- // setIsLoading(false);
2239
- // props.item.setLoadedPaginationOptions &&
2240
- // props.item.setLoadedPaginationOptions(res.data);
2241
- // })
2242
- // .catch((err) => {
2243
- // console.log(err, "error");
2244
- // });
2245
- // return () => controller.abort();
2246
- // // }
2247
- // }, [
2248
- // searchValue,
2249
- // props.getValues(props.item.name),
2250
- // props.item.ApiInstance,
2251
- // props?.item?.autoFIll,
2252
- // props?.item?.tokenInstance
2253
- // ]);
2254
- // useEffect(() => {
2255
- // if (props.item?.ApiInstanceReferal) {
2256
- // setSearchValue("");
2257
- // }
2258
- // }, [props.item?.ApiInstanceReferal]);
2259
- // const isOptionEqualToValue = (option: any, value: any) =>
2260
- // option?.value === value?.value; // Assuming there's a 'value' property in your options
2261
- // return (
2262
- // <Controller
2263
- // control={props.control}
2264
- // name={props.item.name}
2265
- // render={({ field }) => (
2266
- // <>
2267
- // <Autocomplete
2268
- // {...field}
2269
- // value={
2270
- // props.getValues(props.item.name)
2271
- // ? optionsFetched?.find(
2272
- // (item) => item?.value === props.getValues(props.item.name)
2273
- // )
2274
- // : null
2275
- // }
2276
- // onChange={(_, newValue) => {
2277
- // // field.onChange(newValue);
2278
- // props.setValue(props.item.name, newValue?.value);
2279
- // props?.item?.onChangeFn &&
2280
- // props?.item?.onChangeFn(newValue?.value);
2281
- // props?.clearErrors && props?.clearErrors(props.item.name);
2282
- // }}
2283
- // size="small"
2284
- // sx={{
2285
- // "& .MuiAutocomplete-input": {
2286
- // padding: "0px 0px 0px 5px !important",
2287
- // },
2288
- // "& .css-erkti9-MuiFormLabel-root-MuiInputLabel-root ": {
2289
- // top: "-5px",
2290
- // },
2291
- // }}
2292
- // disabled={props.item.disable}
2293
- // options={optionsFetched}
2294
- // classes={{
2295
- // option:
2296
- // props.item.size === "extrasmall"
2297
- // ? classes.option
2298
- // : classes.option2,
2299
- // }}
2300
- // getOptionLabel={(option) => option.label}
2301
- // renderInput={(params) => {
2302
- // return (
2303
- // <Tooltip
2304
- // title={params.inputProps.value && params.inputProps.value}
2305
- // >
2306
- // <TextField
2307
- // {...params}
2308
- // onChange={(e) => {
2309
- // setSearchValue(e.target.value);
2310
- // }}
2311
- // placeholder={props.item.placeholder}
2312
- // label={props.item.label}
2313
- // />
2314
- // </Tooltip>
2315
- // );
2316
- // }}
2317
- // PaperComponent={({ children }) => (
2318
- // <div
2319
- // style={{
2320
- // background: "#fff",
2321
- // }}
2322
- // >
2323
- // {isLoading ? (
2324
- // <Stack padding={2} spacing={1}>
2325
- // <Skeleton
2326
- // variant="rectangular"
2327
- // width={"100%"}
2328
- // height={20}
2329
- // />
2330
- // <Skeleton
2331
- // variant="rectangular"
2332
- // width={"100%"}
2333
- // height={20}
2334
- // />
2335
- // <Skeleton
2336
- // variant="rectangular"
2337
- // width={"100%"}
2338
- // height={20}
2339
- // />
2340
- // <Skeleton
2341
- // variant="rectangular"
2342
- // width={"100%"}
2343
- // height={20}
2344
- // />
2345
- // <Skeleton
2346
- // variant="rectangular"
2347
- // width={"100%"}
2348
- // height={20}
2349
- // />
2350
- // <Skeleton
2351
- // variant="rectangular"
2352
- // width={"100%"}
2353
- // height={20}
2354
- // />
2355
- // </Stack>
2356
- // ) : (
2357
- // children
2358
- // )}
2359
- // </div>
2360
- // )}
2361
- // isOptionEqualToValue={isOptionEqualToValue}
2362
- // />
2363
- // {props?.item?.helperText && (
2364
- // <span
2365
- // style={{
2366
- // fontSize: "11px",
2367
- // color: "#3651d3",
2368
- // }}
2369
- // >
2370
- // ({props?.item?.helperText})
2371
- // </span>
2372
- // )}
2373
- // <ErrorMessageComponent>
2374
- // <ErrorMessage errors={props.errors} name={props.item.name} />
2375
- // </ErrorMessageComponent>
2376
- // </>
2377
- // )}
2378
- // />
2379
- // );
2380
- // };
2381
- // export default SingleSelectSearchApi;
2382
- const SingleSelectSearchApi = () => {
2383
- return jsx("div", { children: "SingleSelectSearchApi" });
2384
- };
2385
-
2386
- const MonthPicker = ({ props }) => {
2387
- const [selectedMonths, setSelectedMonths] = useState([]);
2388
- const handleMonthChange = (date) => {
2389
- // Handle the selected months
2390
- setSelectedMonths((prevSelectedMonths) => {
2391
- const monthIndex = date.getMonth();
2392
- if (prevSelectedMonths.includes(monthIndex)) {
2393
- // If month is already selected, remove it
2394
- return prevSelectedMonths?.filter((month) => month !== monthIndex);
2395
- }
2396
- else {
2397
- // If month is not selected, add it
2398
- return [...prevSelectedMonths, monthIndex];
2399
- }
2400
- });
2401
- };
2402
- 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: {
2403
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
2404
- textField: (textFieldProps) => (jsx(TextField, { ...textFieldProps, fullWidth: true, disabled: props.item.disable || false, InputLabelProps: {
2405
- shrink: true,
2406
- }, error: props.errors, inputProps: {
2407
- min: props.item.minDate,
2408
- } })),
2409
- }, slotProps: {
2410
- textField: {
2411
- sx: {
2412
- "& .MuiFormLabel-root": {
2413
- top: -10,
2414
- },
2415
- "& .MuiInputLabel-shrink": {
2416
- top: 0,
2417
- },
2418
- },
2419
- },
2420
- } }) }), 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, {
2421
- month: "short",
2422
- }) }, index))) })] })) }));
2423
- };
2424
-
2425
- // import FormBottomField from "../FormBottomField/FormBottomField";
2426
- // import { Box, TextField } from "@mui/material";
2427
- // import { LocalizationProvider } from "@mui/x-date-pickers";
2428
- // import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
2429
- // import dayjs from "dayjs";
2430
- // import DatePicker from "react-datepicker";
2431
- // import { Controller } from "react-hook-form";
2432
- // import { renderLabel } from "../../../Utilities/Constants/FormConstants";
2433
- // import {
2434
- // FormRenderProps,
2435
- // VariantProps,
2436
- // } from "../../../Utilities/Interface/FormInterface";
2437
- // const YearPickerField = ({
2438
- // props,
2439
- // variant,
2440
- // }: {
2441
- // props: FormRenderProps;
2442
- // variant: VariantProps;
2443
- // }) => {
2444
- // return (
2445
- // <Controller
2446
- // control={props.control}
2447
- // name={props.item.name}
2448
- // key={props.item.name}
2449
- // render={({ field }) => (
2450
- // <>
2451
- // <LocalizationProvider dateAdapter={AdapterDayjs}>
2452
- // {renderLabel(variant, props)}
2453
- // <Box
2454
- // sx={{
2455
- // "& .css-1holvmy, .css-kichxs-MuiFormLabel-root-MuiInputLabel-root":
2456
- // {
2457
- // top: "-10px",
2458
- // },
2459
- // }}
2460
- // >
2461
- // {" "}
2462
- // <DatePicker
2463
- // views={["year"]}
2464
- // value={
2465
- // field.value
2466
- // ? dayjs(field.value).format("YYYY-MM-DD")
2467
- // : undefined
2468
- // }
2469
- // onChange={(date: any) => field.onChange(date)}
2470
- // // minDate={}
2471
- // slotProps={{
2472
- // textField: {
2473
- // label: `${props.item.label}${props.item.required ? " *" : ""}`,
2474
- // variant: variant !== "standard" ? variant : undefined,
2475
- // },
2476
- // }}
2477
- // slots={{
2478
- // // eslint-disable-next-line @typescript-eslint/no-explicit-any
2479
- // textField: (textFieldProps: any) => (
2480
- // <TextField
2481
- // {...textFieldProps}
2482
- // fullWidth
2483
- // disabled={props.item.disable || false}
2484
- // InputLabelProps={{
2485
- // shrink: true,
2486
- // }}
2487
- // />
2488
- // ),
2489
- // }}
2490
- // />
2491
- // </Box>
2492
- // </LocalizationProvider>
2493
- // <FormBottomField {...props} />
2494
- // </>
2495
- // )}
2496
- // />
2497
- // );
2498
- // };
2499
- // export default YearPickerField;
2500
- const YearPickerField = () => {
2501
- return jsx("div", { children: "YearPickerField" });
2502
- };
2503
-
2504
- // Form Input Components - Individual form field components for advanced usage
2505
-
2506
- var index = /*#__PURE__*/Object.freeze({
2507
- __proto__: null,
2508
- DatepickerWrapperV2: DatepickerWrapperV2,
2509
- FormBottomField: FormBottomField,
2510
- FormCheckBox: FormCheckBox,
2511
- FormCheckBoxGroup: FormCheckBoxGroup,
2512
- FormErrorField: FormErrorField,
2513
- FormNumberField: FormNumberField,
2514
- FormNumberFieldDecimal: FormNumberFieldDecimal,
2515
- FormRadioGroup: FormRadioGroup,
2516
- FormRenderFileUpload: FormRenderFileUpload,
2517
- FormRenderMultiFileUpload: FormRenderMultiFileUpload,
2518
- FormTextAreaField: FormTextAreaField,
2519
- FormTextField: FormTextField,
2520
- HelperText: HelperText,
2521
- MonthPicker: MonthPicker,
2522
- Monthpickerrender: Monthpickerrender,
2523
- MultiSelectV1: MultiSelectV1,
2524
- PasswordField: PasswordField,
2525
- RichTextEditor: RichTextEditor,
2526
- RichTextEditorWrapper: RichTextEditorWrapper,
2527
- SingleSelect: SingleSelect,
2528
- SingleSelectNonAutoComplete: SingleSelectNonAutoComplete,
2529
- SingleSelectSearchApi: SingleSelectSearchApi,
2530
- TimePicker: TimePickerFieldWrapper,
2531
- YearPickerField: YearPickerField
2532
- });
2533
-
2534
- // Common validation schemas
2535
- const emailSchema = Yup
2536
- .string()
2537
- .email("Please enter a valid email address")
2538
- .required("Email is required");
2539
- const passwordSchema = Yup
2540
- .string()
2541
- .min(8, "Password must be at least 8 characters")
2542
- .matches(/[A-Z]/, "Password must contain at least one uppercase letter")
2543
- .matches(/[a-z]/, "Password must contain at least one lowercase letter")
2544
- .matches(/[0-9]/, "Password must contain at least one number")
2545
- .required("Password is required");
2546
- const phoneSchema = Yup
2547
- .string()
2548
- .matches(/^[+]?[1-9][\d]{0,15}$/, "Please enter a valid phone number")
2549
- .required("Phone number is required");
2550
- const requiredStringSchema = Yup
2551
- .string()
2552
- .required("This field is required");
2553
- const optionalStringSchema = Yup.string();
2554
- const numberSchema = Yup
2555
- .number()
2556
- .typeError("Please enter a valid number")
2557
- .required("This field is required");
2558
- const optionalNumberSchema = Yup
2559
- .number()
2560
- .typeError("Please enter a valid number");
2561
- const dateSchema = Yup
2562
- .date()
2563
- .typeError("Please enter a valid date")
2564
- .required("Date is required");
2565
- const urlSchema = Yup
2566
- .string()
2567
- .url("Please enter a valid URL")
2568
- .required("URL is required");
2569
- // Example form schemas
2570
- const loginSchema = Yup.object({
2571
- email: emailSchema,
2572
- password: Yup.string().required("Password is required"),
2573
- });
2574
- const registrationSchema = Yup.object({
2575
- firstName: requiredStringSchema,
2576
- lastName: requiredStringSchema,
2577
- email: emailSchema,
2578
- password: passwordSchema,
2579
- confirmPassword: Yup
2580
- .string()
2581
- .oneOf([Yup.ref("password")], "Passwords must match")
2582
- .required("Please confirm your password"),
2583
- });
2584
- const contactSchema = Yup.object({
2585
- name: requiredStringSchema,
2586
- email: emailSchema,
2587
- phone: phoneSchema.optional(),
2588
- message: requiredStringSchema,
2589
- });
2590
-
2591
- var schemas = /*#__PURE__*/Object.freeze({
2592
- __proto__: null,
2593
- contactSchema: contactSchema,
2594
- dateSchema: dateSchema,
2595
- emailSchema: emailSchema,
2596
- loginSchema: loginSchema,
2597
- numberSchema: numberSchema,
2598
- optionalNumberSchema: optionalNumberSchema,
2599
- optionalStringSchema: optionalStringSchema,
2600
- passwordSchema: passwordSchema,
2601
- phoneSchema: phoneSchema,
2602
- registrationSchema: registrationSchema,
2603
- requiredStringSchema: requiredStringSchema,
2604
- urlSchema: urlSchema
2605
- });
2606
-
2607
- 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 };