tp-react-elements 1.2.9 → 1.2.12
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/_virtual/index.esm11.js +2 -2
- package/dist/_virtual/index.esm12.js +2 -2
- package/dist/_virtual/index.esm13.js +2 -2
- package/dist/_virtual/index.esm4.js +2 -2
- package/dist/_virtual/index.esm6.js +2 -2
- package/dist/_virtual/index.esm7.js +2 -2
- package/dist/components/DateRangePicker/DateRangePicker.esm.js +10 -3
- package/dist/components/Form/FormConstants.esm.js +1 -0
- package/dist/components/FormComponents/FileUpload/MultiFileWithPreview.esm.js +49 -27
- package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js +2 -2
- package/dist/components/FormComponents/FormTextAreaField/FormTextAreaField.esm.js +6 -8
- package/dist/node_modules/react-date-range/dist/components/DateInput/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DateRangePicker/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DayCell/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/DefinedRange/index.esm.js +1 -1
- package/dist/node_modules/react-date-range/dist/components/Month/index.esm.js +1 -1
- package/package.json +1 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DayCell = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DayCell as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Month = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { Month as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DateInput = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateInput as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DateRangePicker = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateRangePicker as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DefinedRange = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DefinedRange as __exports };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var DateRange = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateRange as __exports };
|
|
@@ -2,7 +2,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useState, useEffect } from 'react';
|
|
3
3
|
import { Controller } from 'react-hook-form';
|
|
4
4
|
import { d as distExports } from '../../_virtual/index.esm.js';
|
|
5
|
-
import 'dayjs';
|
|
5
|
+
import dayjs from 'dayjs';
|
|
6
6
|
import { renderLabel } from '../../utils/Constants/FormConstants.esm.js';
|
|
7
7
|
import FormBottomField from '../FormComponents/FormBottomField/FormBottomField.esm.js';
|
|
8
8
|
import { Box, TextField, Popover } from '@mui/material';
|
|
@@ -89,12 +89,19 @@ const DateRangePickerComponent = ({ item, control, watch, setValue, getValues, c
|
|
|
89
89
|
if (selection.startDate &&
|
|
90
90
|
selection.endDate &&
|
|
91
91
|
selection.startDate?.getTime() !== selection.endDate?.getTime()) {
|
|
92
|
-
const dateObject = {
|
|
92
|
+
const dateObject = {
|
|
93
|
+
startDate: format(selection.startDate, 'dd/MM/yyyy'),
|
|
94
|
+
endDate: format(selection.endDate, 'dd/MM/yyyy'),
|
|
95
|
+
};
|
|
93
96
|
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
94
97
|
item.onChangeFn && item.onChangeFn(dateObject || null);
|
|
95
98
|
handleClose();
|
|
96
99
|
}
|
|
97
|
-
}, moveRangeOnFirstSelection: false, ranges: state,
|
|
100
|
+
}, moveRangeOnFirstSelection: false, ranges: state, minDate: item?.minDate
|
|
101
|
+
? dayjs(item?.minDate, item.DateFormat || 'DD/MM/YYYY').toDate()
|
|
102
|
+
: undefined, maxDate: item?.maxDate
|
|
103
|
+
? dayjs(item?.maxDate, item.DateFormat || 'DD/MM/YYYY').toDate()
|
|
104
|
+
: undefined, months: 2, direction: "horizontal", showDateDisplay: false, dateDisplayFormat: "dd/MM/yyyy", rangeColors: ['#4d73b1ff'] }) }), jsx(FormBottomField, { item,
|
|
98
105
|
control,
|
|
99
106
|
errors,
|
|
100
107
|
getValues,
|
|
@@ -129,6 +129,7 @@ const useFormValidatingContext = (formArray) => {
|
|
|
129
129
|
renderCustomError(field);
|
|
130
130
|
break;
|
|
131
131
|
case 'number':
|
|
132
|
+
case 'decimal':
|
|
132
133
|
initialValues[field.name] = null;
|
|
133
134
|
if (field.required && field.errorMessage) {
|
|
134
135
|
validationShape[field.name] = (validationShape[field.name] || Yup.number())
|
|
@@ -18,6 +18,7 @@ import DescriptionIcon from '@mui/icons-material/Description';
|
|
|
18
18
|
const MultiFileWithPreview = ({ props, variant, }) => {
|
|
19
19
|
const inputRef = useRef(null);
|
|
20
20
|
const watched = useWatch({ control: props.control, name: props.item.name });
|
|
21
|
+
const watchedFile = useWatch({ control: props.control, name: props.item.name + 'File' });
|
|
21
22
|
const [open, setOpen] = useState(false);
|
|
22
23
|
const [selectedFiles, setSelectedFiles] = useState([]);
|
|
23
24
|
const [currentFileIndex, setCurrentFileIndex] = useState(0);
|
|
@@ -37,41 +38,62 @@ const MultiFileWithPreview = ({ props, variant, }) => {
|
|
|
37
38
|
// Determine if this is single or multiple file mode
|
|
38
39
|
const isSingleFileMode = props.item.maxLength === 1;
|
|
39
40
|
useEffect(() => {
|
|
40
|
-
|
|
41
|
+
const isWatchedEmpty = watched === null || watched === undefined || watched === '';
|
|
42
|
+
const isWatchedFileEmpty = watchedFile === null || watchedFile === undefined || (Array.isArray(watchedFile) && watchedFile.length === 0);
|
|
43
|
+
if (isWatchedEmpty && isWatchedFileEmpty) {
|
|
41
44
|
if (inputRef.current)
|
|
42
45
|
inputRef.current.value = '';
|
|
46
|
+
setSelectedFiles([]);
|
|
47
|
+
return;
|
|
43
48
|
}
|
|
44
|
-
const looksLikeUrl = (s) => /^(https?:|blob:|data:|\/)/i.test(s);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (typeof watched[0] === 'object') {
|
|
53
|
-
// ✅ extract URLs from object arrays (image/url/path keys)
|
|
54
|
-
const urls = watched
|
|
55
|
-
.map((item) => {
|
|
49
|
+
const looksLikeUrl = (s) => typeof s === 'string' && /^(https?:|blob:|data:|\/)/i.test(s);
|
|
50
|
+
let files = [];
|
|
51
|
+
// Check watchedFile first
|
|
52
|
+
if (Array.isArray(watchedFile) && watchedFile.length > 0) {
|
|
53
|
+
files = watchedFile.map(f => {
|
|
54
|
+
if (f instanceof File)
|
|
55
|
+
return f;
|
|
56
|
+
if (typeof f === 'object' && f !== null) {
|
|
56
57
|
const possibleKeys = ['image', 'url', 'path', 'filePath'];
|
|
57
|
-
const key = possibleKeys.find((k) =>
|
|
58
|
-
return key ?
|
|
59
|
-
})
|
|
60
|
-
.filter((f) => f && looksLikeUrl(f));
|
|
61
|
-
if (urls.length) {
|
|
62
|
-
setSelectedFiles(urls);
|
|
58
|
+
const key = possibleKeys.find((k) => f[k]);
|
|
59
|
+
return key ? f[key]?.replace(/\\/g, '/').trim() : undefined;
|
|
63
60
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const normalized = watched
|
|
67
|
-
.map((f) => (f || '').toString().replace(/\\/g, '/').trim())
|
|
68
|
-
.filter((f) => looksLikeUrl(f));
|
|
69
|
-
if (normalized.length) {
|
|
70
|
-
setSelectedFiles(normalized);
|
|
61
|
+
if (typeof f === 'string') {
|
|
62
|
+
return f.replace(/\\/g, '/').trim(); // trust watchedFile strings directly
|
|
71
63
|
}
|
|
64
|
+
return undefined;
|
|
65
|
+
}).filter(Boolean);
|
|
66
|
+
}
|
|
67
|
+
else if (typeof watchedFile === 'string' && watchedFile.trim() !== '') {
|
|
68
|
+
files = watchedFile.split(',').map(s => s.replace(/\\/g, '/').trim()).filter(Boolean);
|
|
69
|
+
}
|
|
70
|
+
// Fallback to watched if files array is empty
|
|
71
|
+
if (files.length === 0) {
|
|
72
|
+
if (typeof watched === 'string' && watched.trim() !== '') {
|
|
73
|
+
const parts = watched.split(',').map(s => s.replace(/\\/g, '/').trim());
|
|
74
|
+
files = parts.filter(p => looksLikeUrl(p));
|
|
72
75
|
}
|
|
76
|
+
else if (Array.isArray(watched)) {
|
|
77
|
+
files = watched.map(item => {
|
|
78
|
+
if (item instanceof File)
|
|
79
|
+
return item;
|
|
80
|
+
if (typeof item === 'object' && item !== null) {
|
|
81
|
+
const possibleKeys = ['image', 'url', 'path', 'filePath'];
|
|
82
|
+
const key = possibleKeys.find((k) => item[k]);
|
|
83
|
+
return key ? item[key]?.replace(/\\/g, '/').trim() : undefined;
|
|
84
|
+
}
|
|
85
|
+
if (typeof item === 'string') {
|
|
86
|
+
const str = item.replace(/\\/g, '/').trim();
|
|
87
|
+
return looksLikeUrl(str) ? str : undefined;
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}).filter(Boolean);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
if (files.length > 0) {
|
|
94
|
+
setSelectedFiles(files);
|
|
73
95
|
}
|
|
74
|
-
}, [watched]);
|
|
96
|
+
}, [watched, watchedFile]);
|
|
75
97
|
const isError = !!props.errors?.[props.item.name];
|
|
76
98
|
const extensionMap = {
|
|
77
99
|
excel: ['xls', 'xlsx'],
|
|
@@ -21,9 +21,9 @@ const FormNumberFieldDecimal = ({ props, variant, }) => {
|
|
|
21
21
|
const label = variant !== 'standard' ? `${props.item.label}${props.item.required ? ' *' : ''}` : '';
|
|
22
22
|
const isError = !!props.errors?.[props.item.name];
|
|
23
23
|
const isShowBorderError = isError;
|
|
24
|
-
return (jsx(Controller, { name: props.item.name, control: props.control, disabled: props.item?.disable, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(TextField, { type: "text", size: "small", label: label, error: isShowBorderError, ...field, onChange: (e) => {
|
|
24
|
+
return (jsx(Controller, { name: props.item.name, control: props.control, disabled: props.item?.disable, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(TextField, { type: "text", size: "small", label: label, error: isShowBorderError, ...field, value: field.value ?? '', onChange: (e) => {
|
|
25
25
|
const sanitized = sanitizeDecimal(e.target.value ?? '');
|
|
26
|
-
const value = sanitized === '' ?
|
|
26
|
+
const value = sanitized === '' ? null : sanitized;
|
|
27
27
|
field.onChange(value);
|
|
28
28
|
props?.clearErrors && props?.clearErrors(props.item.name);
|
|
29
29
|
}, sx: {
|
|
@@ -22,23 +22,21 @@ import { renderLabel } from '../../../utils/Constants/FormConstants.esm.js';
|
|
|
22
22
|
* <FormTextAreaField props={formRenderProps} variant="outlined" />
|
|
23
23
|
*/
|
|
24
24
|
const FormTextAreaField = ({ props, variant, }) => {
|
|
25
|
-
/**
|
|
26
|
-
* Determines if the field has an error based on form validation
|
|
27
|
-
*/
|
|
28
|
-
const isError = !!props.errors?.[props.item.name];
|
|
29
|
-
const isShowBorderError = isError;
|
|
30
25
|
/**
|
|
31
26
|
* Renders the textarea component with validation support
|
|
32
27
|
*/
|
|
33
|
-
return (jsx(Fragment, { children: jsx(Controller, { control: props.control, name: props.item.name, render: ({ field }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Tooltip, { title: props.item.isTooltipEnable ?
|
|
28
|
+
return (jsx(Fragment, { children: jsx(Controller, { control: props.control, name: props.item.name, render: ({ field, fieldState }) => (jsxs(Fragment, { children: [renderLabel(variant, props), jsx(Tooltip, { title: props.item.isTooltipEnable ? field.value || '' : '', placement: "bottom-start", children: jsxs(Box, { sx: { width: '100%', position: 'relative' }, children: [jsx(TextAreaField, { multiline: true, size: "small", InputProps: {
|
|
34
29
|
style: {
|
|
35
30
|
border: 'none',
|
|
36
31
|
},
|
|
37
32
|
}, sx: {
|
|
38
33
|
...props.item.sx,
|
|
39
|
-
}, minRows: props.item.minRows || 1, maxRows: props.item.maxRows || 100, placeholder: props.item.placeholder || 'Type Something...', ...field,
|
|
34
|
+
}, minRows: props.item.minRows || 1, maxRows: props.item.maxRows || 100, placeholder: props.item.placeholder || 'Type Something...', ...field, onChange: (e) => {
|
|
35
|
+
field.onChange(e);
|
|
36
|
+
props?.clearErrors && props?.clearErrors(props.item.name);
|
|
37
|
+
}, label: variant !== 'standard'
|
|
40
38
|
? `${props.item.label}${props.item.required ? ' *' : ''}`
|
|
41
|
-
: '', error:
|
|
39
|
+
: '', error: !!fieldState.error, value: field.value || '', disabled: props.item.disable, inputProps: {
|
|
42
40
|
/**
|
|
43
41
|
* Handles input events with text restrictions
|
|
44
42
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DateInput } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DateInput } from '../../../../../_virtual/index.esm13.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireClassnames } from '../../../../classnames/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DateRange } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DateRange } from '../../../../../_virtual/index.esm7.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireCalendar } from '../Calendar/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DateRangePicker } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DateRangePicker } from '../../../../../_virtual/index.esm4.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireDateRange } from '../DateRange/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DayCell } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DayCell } from '../../../../../_virtual/index.esm11.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireClassnames } from '../../../../classnames/index.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as DefinedRange } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as DefinedRange } from '../../../../../_virtual/index.esm6.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireStyles } from '../../styles.esm.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __exports as Month } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as Month } from '../../../../../_virtual/index.esm12.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { __require as requirePropTypes } from '../../../../prop-types/index.esm.js';
|
|
4
4
|
import { __require as requireDayCell } from '../DayCell/index.esm.js';
|