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