tp-react-elements-dev 1.10.15 → 1.10.17

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/index.js CHANGED
@@ -59297,38 +59297,40 @@ const DatepickerWrapperV2 = ({ props, variant }) => {
59297
59297
  };
59298
59298
  return (jsxRuntimeExports.jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => {
59299
59299
  var _a, _b, _c, _d, _e, _f;
59300
- return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDayjs }, { children: [renderLabel(variant, props), jsxRuntimeExports.jsx(DatePicker, { label: variant !== "standard" ? `${props.item.label}${props.item.required ? ' *' : ''}` : '', value: typeof field.value === "string"
59301
- ? dayjs(field.value, "DD/MM/YYYY")
59302
- : (field.value === null || field.value === undefined) && null, open: open, className: "read-only", format: "DD/MM/YYYY", disabled: props.item.disable || false, onChange: (date) => {
59300
+ return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsxs(LocalizationProvider, Object.assign({ dateAdapter: AdapterDayjs }, { children: [renderLabel(variant, props), jsxRuntimeExports.jsx(DatePicker, { views: ["month", "year", "day"],
59301
+ // disabled={disabled}
59302
+ label: variant !== "standard"
59303
+ ? `${props.item.label}${props.item.required ? " *" : ""}`
59304
+ : "", value: field.value
59305
+ ? typeof field.value === "string"
59306
+ ? dayjs(field.value, "DD/MM/YYYY")
59307
+ : dayjs(field.value)
59308
+ : null, className: "read-only", format: "DD/MM/YYYY", open: open, onOpen: handleToggle, onClose: handleToggle, minDate: ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.minDate)
59309
+ ? dayjs((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.minDate, "DD/MM/YYYY")
59310
+ : null, maxDate: ((_c = props === null || props === void 0 ? void 0 : props.item) === null || _c === void 0 ? void 0 : _c.maxDate)
59311
+ ? dayjs((_d = props === null || props === void 0 ? void 0 : props.item) === null || _d === void 0 ? void 0 : _d.maxDate, "DD/MM/YYYY")
59312
+ : null, disabled: props.item.disable || false, onChange: (date) => {
59303
59313
  var _a, _b;
59304
59314
  field.onChange(dayjs(date).format("DD/MM/YYYY"));
59305
59315
  ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onChangeFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onChangeFn());
59306
- }, onOpen: handleToggle, onClose: handleToggle, slotProps: {
59316
+ }, slotProps: {
59307
59317
  textField: {
59308
- // style: { input: { cursor: "pointer" } },
59318
+ style: { input: { cursor: "pointer" } },
59309
59319
  onClick: () => handleToggle(),
59310
59320
  inputRef: inputTextRef,
59311
59321
  onBlur: (e) => {
59312
59322
  var _a, _b;
59313
59323
  ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.onBlurFn) && ((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.onBlurFn(e));
59314
- }
59315
- // onFocus: () => inputTextRef.current?.blur(),
59316
- },
59317
- }, sx: {
59318
- "& .css-lqj8pz-MuiFormLabel-root-MuiInputLabel-root,.css-zy8vme,.css-1holvmy,.css-kichxs-MuiFormLabel-root-MuiInputLabel-root": {
59319
- top: "-10px !important",
59320
- },
59321
- "& input:hover": {
59322
- cursor: "pointer",
59324
+ },
59323
59325
  },
59324
- }, minDate: ((_a = props === null || props === void 0 ? void 0 : props.item) === null || _a === void 0 ? void 0 : _a.minDate) ? dayjs((_b = props === null || props === void 0 ? void 0 : props.item) === null || _b === void 0 ? void 0 : _b.minDate, 'DD/MM/YYYY') : null, maxDate: ((_c = props === null || props === void 0 ? void 0 : props.item) === null || _c === void 0 ? void 0 : _c.maxDate) ? dayjs((_d = props === null || props === void 0 ? void 0 : props.item) === null || _d === void 0 ? void 0 : _d.maxDate, 'DD/MM/YYYY') : null })] })), ((_e = props === null || props === void 0 ? void 0 : props.item) === null || _e === void 0 ? void 0 : _e.helperText) && (jsxRuntimeExports.jsxs("span", Object.assign({ style: {
59326
+ } })] })), ((_e = props === null || props === void 0 ? void 0 : props.item) === null || _e === void 0 ? void 0 : _e.helperText) && (jsxRuntimeExports.jsxs("span", Object.assign({ style: {
59325
59327
  fontSize: "11px",
59326
59328
  color: "#3651d3",
59327
59329
  } }, { children: ["(", (_f = props === null || props === void 0 ? void 0 : props.item) === null || _f === void 0 ? void 0 : _f.helperText, ")"] }))), !(props === null || props === void 0 ? void 0 : props.getValues(props.item.name)) && (jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) }))] }));
59328
59330
  } }, props.item.name));
59329
59331
  };
59330
59332
 
59331
- const FormRenderFileUpload = ({ props, variant }) => {
59333
+ const FormRenderFileUpload = ({ props, variant, }) => {
59332
59334
  var _a;
59333
59335
  React$1.useEffect(() => {
59334
59336
  if (props.getValues(props.item.name) === null ||
@@ -59345,17 +59347,31 @@ const FormRenderFileUpload = ({ props, variant }) => {
59345
59347
  ? ".xls, .xlsx"
59346
59348
  : props.item.fileType === "pdf"
59347
59349
  ? ".pdf"
59348
- : props.item.fileType === "all"
59349
- ? ".pdf,.jpg,.jpeg,.png,.xls,.xlsx,.doc,.docx"
59350
- : "",
59350
+ : props.item.fileType === "zip"
59351
+ ? ".zip"
59352
+ : props.item.fileType === "all"
59353
+ ? ".pdf,.jpg,.jpeg,.png,.xls,.xlsx,.doc,.docx,.zip"
59354
+ : "",
59351
59355
  }, onChange: (event) => {
59352
59356
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
59353
59357
  const file = event.target.files[0];
59358
+ console.log(file, "filefile");
59354
59359
  const fileName = file ? file.name : null;
59355
59360
  const allowedExtensions = {
59356
59361
  excel: ["xls", "xlsx"],
59357
59362
  pdf: ["pdf"],
59358
- all: ["pdf", "jpg", "jpeg", "png", "xls", "xlsx", "doc", "docx"],
59363
+ zip: ["zip"],
59364
+ all: [
59365
+ "pdf",
59366
+ "jpg",
59367
+ "jpeg",
59368
+ "png",
59369
+ "xls",
59370
+ "xlsx",
59371
+ "doc",
59372
+ "docx",
59373
+ "zip",
59374
+ ],
59359
59375
  };
59360
59376
  const fileExtension = fileName
59361
59377
  ? fileName.split(".").pop().toLowerCase()
@@ -59365,19 +59381,23 @@ const FormRenderFileUpload = ({ props, variant }) => {
59365
59381
  : props.item.fileType === "pdf"
59366
59382
  ? allowedExtensions.pdf
59367
59383
  : allowedExtensions.all;
59384
+ console.log(fileExtension, fileName, "sksjsjs");
59368
59385
  if (((_a = props.item) === null || _a === void 0 ? void 0 : _a.fileType) &&
59369
59386
  fileExtension &&
59370
59387
  !validExtensions.includes(fileExtension)) {
59371
- ((_b = props.item) === null || _b === void 0 ? void 0 : _b.handleFileError) &&
59372
- ((_c = props.item) === null || _c === void 0 ? void 0 : _c.handleFileError(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`));
59388
+ ((_b = props.item) === null || _b === void 0 ? void 0 : _b.handleFileError)
59389
+ ? (_c = props.item) === null || _c === void 0 ? void 0 : _c.handleFileError(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`)
59390
+ : alert(`Please upload ${allowedExtensions[props.item.fileType].join(",")} Files only`);
59373
59391
  event.target.value = ""; // Clear the file input\
59374
59392
  props.setValue((_d = props.item) === null || _d === void 0 ? void 0 : _d.name, null);
59375
59393
  props.setValue(((_e = props.item) === null || _e === void 0 ? void 0 : _e.name) + "Name", "");
59376
59394
  return;
59377
59395
  }
59378
- else if (event.target.files[0].size > 20000000) {
59379
- ((_f = props.item) === null || _f === void 0 ? void 0 : _f.handleFileError) &&
59380
- ((_g = props.item) === null || _g === void 0 ? void 0 : _g.handleFileError(`File size should be less than 20MB`));
59396
+ else if (event.target.files[0].size > (props.item.filesize || 20000000)) {
59397
+ const maxSizeMB = ((props.item.filesize || 20000000) /
59398
+ (1024 * 1024)).toFixed(2);
59399
+ ((_f = props.item) === null || _f === void 0 ? void 0 : _f.handleFileError) ?
59400
+ (_g = props.item) === null || _g === void 0 ? void 0 : _g.handleFileError(`File size should be less than ${maxSizeMB}MB`) : alert(`File size should be less than ${maxSizeMB}MB`);
59381
59401
  event.target.value = ""; // Clear the file input
59382
59402
  props.setValue((_h = props.item) === null || _h === void 0 ? void 0 : _h.name, null);
59383
59403
  props.setValue(((_j = props.item) === null || _j === void 0 ? void 0 : _j.name) + "Name", "");
@@ -59396,7 +59416,7 @@ const FormRenderFileUpload = ({ props, variant }) => {
59396
59416
  // [props.item.name]: file,
59397
59417
  // [props.item.name + "Name"]: fileName,
59398
59418
  // });
59399
- }, sx: { width: "100%" } })] })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
59419
+ }, helperText: props.item.helperText, sx: { width: "100%" } })] })), jsxRuntimeExports.jsx(ErrorMessageComponent, { children: jsxRuntimeExports.jsx(s, { errors: props.errors, name: props.item.name }) })] }));
59400
59420
  };
59401
59421
 
59402
59422
  const useStyles = makeStyles((theme) => ({