tp-react-elements 1.2.10 → 1.2.13
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.esm13.js +2 -2
- package/dist/_virtual/index.esm14.js +2 -2
- package/dist/_virtual/index.esm4.js +2 -2
- package/dist/_virtual/index.esm7.js +2 -2
- package/dist/components/Form/FormRender.esm.js +8 -8
- package/dist/components/FormComponents/FileUpload/MultiFileWithPreview.esm.js +49 -27
- package/dist/components/FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js +3 -0
- package/dist/components/FormComponents/index.esm.js +13 -27
- 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/Month/index.esm.js +1 -1
- package/package.json +1 -1
|
@@ -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 Month = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { Month 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 DateRange = {};
|
|
2
2
|
|
|
3
|
-
export {
|
|
3
|
+
export { DateRange as __exports };
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import React__default, { lazy, Suspense } from 'react';
|
|
3
|
-
import FormCheckBox from '../FormComponents/FormCheckBox/FormCheckBox.esm.js';
|
|
4
|
-
import FormCheckBoxGroup from '../FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
|
|
5
|
-
import FormNumberField from '../FormComponents/FormNumberField/FormNumberField.esm.js';
|
|
6
|
-
import FormNumberFieldDecimal from '../FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js';
|
|
7
|
-
import FormRadioGroup from '../FormComponents/FormRadioGroup/FormRadioGroup.esm.js';
|
|
8
|
-
import FormTextAreaField from '../FormComponents/FormTextAreaField/FormTextAreaField.esm.js';
|
|
9
|
-
import FormTextField from '../FormComponents/FormTextField/FormTextField.esm.js';
|
|
10
|
-
import PasswordField from '../FormComponents/PasswordField/PasswordField.esm.js';
|
|
11
3
|
import SingleSelect from '../FormComponents/Select/SingleSelect.esm.js';
|
|
12
4
|
import MultiSelectAutocomplete from '../FormComponents/Select/MultiSelectAutocomplete.esm.js';
|
|
13
5
|
import SingleSelectNonAutoComplete from '../FormComponents/Select/SingleSelectNonAutoComplete.esm.js';
|
|
@@ -16,6 +8,14 @@ import FormTextFieldWithSelect from '../FormComponents/FormTextFieldWithSelect/F
|
|
|
16
8
|
import DateRangePickerComponent from '../DateRangePicker/DateRangePicker.esm.js';
|
|
17
9
|
import RichTextEditorWrapper from '../FormComponents/RichTextEditor/RichTextEditorWrapper.esm.js';
|
|
18
10
|
import SingleSelectSearchApi from '../FormComponents/Select/SingleSelectSearchApi.esm.js';
|
|
11
|
+
import FormTextAreaField from '../FormComponents/FormTextAreaField/FormTextAreaField.esm.js';
|
|
12
|
+
import FormCheckBox from '../FormComponents/FormCheckBox/FormCheckBox.esm.js';
|
|
13
|
+
import FormRadioGroup from '../FormComponents/FormRadioGroup/FormRadioGroup.esm.js';
|
|
14
|
+
import FormCheckBoxGroup from '../FormComponents/FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
|
|
15
|
+
import FormNumberFieldDecimal from '../FormComponents/FormNumberField/FormNumberFieldDecimal.esm.js';
|
|
16
|
+
import FormNumberField from '../FormComponents/FormNumberField/FormNumberField.esm.js';
|
|
17
|
+
import PasswordField from '../FormComponents/PasswordField/PasswordField.esm.js';
|
|
18
|
+
import FormTextField from '../FormComponents/FormTextField/FormTextField.esm.js';
|
|
19
19
|
|
|
20
20
|
// Lazy-loaded heavy components
|
|
21
21
|
// const RichTextEditorWrapper = lazy(() =>
|
|
@@ -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'],
|
|
@@ -1,39 +1,25 @@
|
|
|
1
|
-
export { default as FormNumberField } from './FormNumberField/FormNumberField.esm.js';
|
|
2
|
-
export { default as FormNumberFieldDecimal } from './FormNumberField/FormNumberFieldDecimal.esm.js';
|
|
3
|
-
export { default as FormTextAreaField } from './FormTextAreaField/FormTextAreaField.esm.js';
|
|
4
|
-
export { default as FormTextField } from './FormTextField/FormTextField.esm.js';
|
|
5
|
-
export { default as PasswordField } from './PasswordField/PasswordField.esm.js';
|
|
6
|
-
export { default as FormCheckBox } from './FormCheckBox/FormCheckBox.esm.js';
|
|
7
1
|
export { default as SingleSelect } from './Select/SingleSelect.esm.js';
|
|
8
2
|
export { default as SingleSelectNonAutoComplete } from './Select/SingleSelectNonAutoComplete.esm.js';
|
|
9
3
|
export { default as SingleSelectSearchApi } from './Select/SingleSelectSearchApi.esm.js';
|
|
10
4
|
export { default as MultiSelectV1 } from './Select/MultiSelectv1.esm.js';
|
|
11
5
|
export { default as MultiSelectTable } from './Select/MultiSelectTable.esm.js';
|
|
6
|
+
export { default as DatepickerWrapperV2 } from './DatePicker/DatepickerWrapperV2.esm.js';
|
|
7
|
+
export { default as FormBottomField } from './FormBottomField/FormBottomField.esm.js';
|
|
8
|
+
export { default as FormCheckBox } from './FormCheckBox/FormCheckBox.esm.js';
|
|
12
9
|
export { default as FormCheckBoxGroup } from './FormCheckBoxGroup/FormCheckBoxGroup.esm.js';
|
|
10
|
+
export { default as FormErrorField } from './FormErrorField/FormErrorField.esm.js';
|
|
11
|
+
export { default as FormNumberField } from './FormNumberField/FormNumberField.esm.js';
|
|
12
|
+
export { default as FormNumberFieldDecimal } from './FormNumberField/FormNumberFieldDecimal.esm.js';
|
|
13
13
|
export { default as FormRadioGroup } from './FormRadioGroup/FormRadioGroup.esm.js';
|
|
14
|
-
export { default as DatepickerWrapperV2 } from './DatePicker/DatepickerWrapperV2.esm.js';
|
|
15
|
-
export { default as MonthPicker } from './DatePicker/MonthPicker.esm.js';
|
|
16
|
-
export { default as Monthpickerrender } from './DatePicker/Monthpickerrender.esm.js';
|
|
17
|
-
export { default as YearPickerField } from './YearPickerField/YearPickerField.esm.js';
|
|
18
|
-
export { default as TimePicker } from './TimePicker/TimePicker.esm.js';
|
|
19
14
|
export { default as FormRenderFileUpload } from './FileUpload/FormRenderFileUpload.esm.js';
|
|
20
15
|
export { default as FormRenderMultiFileUpload } from './FileUpload/FormRenderMultiFileUpload.esm.js';
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
import 'react';
|
|
24
|
-
import 'react-hook-form';
|
|
25
|
-
import 'dayjs';
|
|
26
|
-
export { default as FormBottomField } from './FormBottomField/FormBottomField.esm.js';
|
|
27
|
-
import '@mui/icons-material/Visibility';
|
|
28
|
-
import '@mui/icons-material/Close';
|
|
29
|
-
import '@mui/icons-material/NavigateBefore';
|
|
30
|
-
import '@mui/icons-material/NavigateNext';
|
|
31
|
-
import '@mui/icons-material/Delete';
|
|
32
|
-
import '@mui/icons-material/UploadFile';
|
|
33
|
-
import '@mui/icons-material/PictureAsPdf';
|
|
34
|
-
import '@mui/icons-material/TableChart';
|
|
35
|
-
import '@mui/icons-material/Description';
|
|
36
|
-
export { default as FormErrorField } from './FormErrorField/FormErrorField.esm.js';
|
|
16
|
+
export { default as FormTextAreaField } from './FormTextAreaField/FormTextAreaField.esm.js';
|
|
17
|
+
export { default as FormTextField } from './FormTextField/FormTextField.esm.js';
|
|
37
18
|
export { default as HelperText } from './HelperText/HelperText.esm.js';
|
|
19
|
+
export { default as MonthPicker } from './DatePicker/MonthPicker.esm.js';
|
|
20
|
+
export { default as Monthpickerrender } from './DatePicker/Monthpickerrender.esm.js';
|
|
21
|
+
export { default as PasswordField } from './PasswordField/PasswordField.esm.js';
|
|
38
22
|
export { default as RichTextEditor } from './RichTextEditor/RichTextEditor.esm.js';
|
|
39
23
|
export { default as RichTextEditorWrapper } from './RichTextEditor/RichTextEditorWrapper.esm.js';
|
|
24
|
+
export { default as TimePicker } from './TimePicker/TimePicker.esm.js';
|
|
25
|
+
export { default as YearPickerField } from './YearPickerField/YearPickerField.esm.js';
|
|
@@ -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 Month } from '../../../../../_virtual/index.
|
|
1
|
+
import { __exports as Month } from '../../../../../_virtual/index.esm14.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';
|