tp-react-elements-dev 1.5.1 → 1.5.3
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/Form/FormRender.d.ts +3 -0
- package/dist/index.esm.js +49 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +49 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -52233,21 +52233,60 @@ const DatepickerWrapperV2 = ({ props }) => {
|
|
|
52233
52233
|
const FormRenderFileUpload = ({ props }) => {
|
|
52234
52234
|
var _a, _b, _c;
|
|
52235
52235
|
React$1.useEffect(() => {
|
|
52236
|
-
if (props.getValues(props.item.name) === null ||
|
|
52236
|
+
if (props.getValues(props.item.name) === null ||
|
|
52237
|
+
props.getValues(props.item.name) === undefined) {
|
|
52237
52238
|
const element = document.getElementById(props.item.name);
|
|
52238
|
-
console.log(element,
|
|
52239
|
+
console.log(element, "elementelement");
|
|
52239
52240
|
if (element) {
|
|
52240
|
-
element.value =
|
|
52241
|
+
element.value = ""; // Ensure it's an input element
|
|
52241
52242
|
}
|
|
52242
52243
|
}
|
|
52243
52244
|
}, [props.getValues(props.item.name)]);
|
|
52244
|
-
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(Box, Object.assign({ paddingLeft: "4px" }, { children: [((_a = props.item) === null || _a === void 0 ? void 0 : _a.label) && jsxRuntimeExports.jsx(Box, Object.assign({ sx: { fontSize: "10px;" } }, { children: renderLabel((_b = props.item) === null || _b === void 0 ? void 0 : _b.label, (_c = props.item) === null || _c === void 0 ? void 0 : _c.required) })), jsxRuntimeExports.jsx(TextField, { type: "file", id: props.item.name, inputProps: {
|
|
52245
|
-
|
|
52246
|
-
|
|
52245
|
+
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(Box, Object.assign({ paddingLeft: "4px" }, { children: [((_a = props.item) === null || _a === void 0 ? void 0 : _a.label) && (jsxRuntimeExports.jsx(Box, Object.assign({ sx: { fontSize: "10px;" } }, { children: renderLabel((_b = props.item) === null || _b === void 0 ? void 0 : _b.label, (_c = props.item) === null || _c === void 0 ? void 0 : _c.required) }))), jsxRuntimeExports.jsx(TextField, { type: "file", id: props.item.name, inputProps: {
|
|
52246
|
+
accept: props.item.fileType === "excel"
|
|
52247
|
+
? ".xls, .xlsx"
|
|
52248
|
+
: props.item.fileType === "pdf"
|
|
52249
|
+
? ".pdf"
|
|
52250
|
+
: props.item.fileType === "all"
|
|
52251
|
+
? ".pdf,.jpg,.jpeg,.png,.xls,.xlsx,.doc,.docx"
|
|
52252
|
+
: "",
|
|
52253
|
+
}, onChange: (event) => {
|
|
52254
|
+
var _a, _b, _c, _d, _e, _f;
|
|
52255
|
+
const file = event.target.files[0];
|
|
52247
52256
|
const fileName = file ? file.name : null;
|
|
52248
|
-
|
|
52249
|
-
|
|
52250
|
-
|
|
52257
|
+
const allowedExtensions = {
|
|
52258
|
+
excel: ["xls", "xlsx"],
|
|
52259
|
+
pdf: ["pdf"],
|
|
52260
|
+
all: ["pdf", "jpg", "jpeg", "png", "xls", "xlsx", "doc", "docx"],
|
|
52261
|
+
};
|
|
52262
|
+
const fileExtension = fileName
|
|
52263
|
+
? fileName.split(".").pop().toLowerCase()
|
|
52264
|
+
: null;
|
|
52265
|
+
const validExtensions = props.item.fileType === "excel"
|
|
52266
|
+
? allowedExtensions.excel
|
|
52267
|
+
: props.item.fileType === "pdf"
|
|
52268
|
+
? allowedExtensions.pdf
|
|
52269
|
+
: allowedExtensions.all;
|
|
52270
|
+
if (((_a = props.item) === null || _a === void 0 ? void 0 : _a.fileType) &&
|
|
52271
|
+
fileExtension &&
|
|
52272
|
+
!validExtensions.includes(fileExtension)) {
|
|
52273
|
+
((_b = props.item) === null || _b === void 0 ? void 0 : _b.handleFileError) && ((_c = props.item) === null || _c === void 0 ? void 0 : _c.handleFileError(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`));
|
|
52274
|
+
event.target.value = ""; // Clear the file input
|
|
52275
|
+
return;
|
|
52276
|
+
}
|
|
52277
|
+
// Proceed if valid
|
|
52278
|
+
props.setValue((_d = props.item) === null || _d === void 0 ? void 0 : _d.name, file);
|
|
52279
|
+
props.setValue(((_e = props.item) === null || _e === void 0 ? void 0 : _e.name) + "Name", fileName);
|
|
52280
|
+
(_f = props === null || props === void 0 ? void 0 : props.item) === null || _f === void 0 ? void 0 : _f.onChangeInput({
|
|
52281
|
+
[props.item.name]: file,
|
|
52282
|
+
[props.item.name + "Name"]: fileName,
|
|
52283
|
+
});
|
|
52284
|
+
// props.setValue(props.item?.name, file);
|
|
52285
|
+
// props.setValue(props.item?.name + "Name", fileName);
|
|
52286
|
+
// props?.item?.onChangeInput({
|
|
52287
|
+
// [props.item.name]: file,
|
|
52288
|
+
// [props.item.name + "Name"]: fileName,
|
|
52289
|
+
// });
|
|
52251
52290
|
}, sx: { width: "100%" } })] })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
|
|
52252
52291
|
};
|
|
52253
52292
|
|
|
@@ -52745,9 +52784,7 @@ const RenderForm = (props) => {
|
|
|
52745
52784
|
// textTransform:'uppercase'
|
|
52746
52785
|
maxHeight: "500px !important",
|
|
52747
52786
|
overflow: "auto",
|
|
52748
|
-
} }, props.item.sx), minRows: props.item.minRows || 1,
|
|
52749
|
-
// maxRows={2}
|
|
52750
|
-
placeholder: props.item.placeholder || "Type Something..." }, field, { label: `${props.item.label}${props.item.required ? " *" : ""}`, value: field.value || "", disabled: props.item.disable, inputProps: {
|
|
52787
|
+
} }, props.item.sx), minRows: props.item.minRows || 1, maxRows: props.item.maxRows || null, placeholder: props.item.placeholder || "Type Something..." }, field, { label: `${props.item.label}${props.item.required ? " *" : ""}`, value: field.value || "", disabled: props.item.disable, inputProps: {
|
|
52751
52788
|
onInput: (e) => {
|
|
52752
52789
|
var _a;
|
|
52753
52790
|
if (!((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.allowSpecialChars)) {
|