siam-ui-utils 2.0.24 → 2.0.26
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/.prettierrc +7 -0
- package/eslint.config.js +41 -0
- package/index.html +12 -0
- package/package.json +68 -59
- package/src/App.css +42 -0
- package/src/App.jsx +79 -0
- package/src/archivos-adjuntos/dropzone-uploader-dni-digital/index.jsx +142 -143
- package/src/archivos-adjuntos/index.jsx +135 -133
- package/src/archivos-adjuntos/simple-line-icons.css +778 -0
- package/src/assets/css/vendor/bootstrap.min.css +6 -0
- package/src/assets/css/vendor/bootstrap.rtl.only.min.css +1428 -0
- package/src/index.css +74 -0
- package/src/index.js +7 -7
- package/src/main.jsx +7 -0
- package/src/react-notifications/Notification.jsx +89 -0
- package/src/react-notifications/NotificationContainer.jsx +53 -0
- package/src/react-notifications/NotificationManager.js +135 -0
- package/src/react-notifications/Notifications.jsx +66 -0
- package/src/react-notifications/index.js +5 -0
- package/vite.config.ts +9 -5
- package/.eslintrc.json +0 -25
- package/src/IntlMessages.tsx +0 -11
|
@@ -1,139 +1,141 @@
|
|
|
1
1
|
/* eslint-disable react/prop-types */
|
|
2
|
-
import React, { useEffect, useState } from 'react'
|
|
3
|
-
import { getDroppedOrSelectedFiles } from 'html5-file-selector'
|
|
4
|
-
import Dropzone from 'react-dropzone-uploader'
|
|
5
|
-
import { NotificationManager } from 'react-notifications'
|
|
6
|
-
import 'react-dropzone-uploader/dist/styles.css'
|
|
7
|
-
import { IconButtonSvg, pdfImage } from '../iconos'
|
|
8
|
-
import './dropzone-uploader.css'
|
|
2
|
+
import React, { useEffect, useState } from 'react';
|
|
3
|
+
import { getDroppedOrSelectedFiles } from 'html5-file-selector';
|
|
4
|
+
import Dropzone from 'react-dropzone-uploader';
|
|
5
|
+
import { NotificationManager } from 'react-notifications';
|
|
6
|
+
import 'react-dropzone-uploader/dist/styles.css';
|
|
7
|
+
import { IconButtonSvg, pdfImage } from '../iconos';
|
|
8
|
+
import './dropzone-uploader.css';
|
|
9
|
+
import './simple-line-icons.css';
|
|
9
10
|
|
|
10
|
-
const maxSize = 7
|
|
11
|
+
const maxSize = 7;
|
|
11
12
|
export const DropzoneUploader = ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
onChangeFiles,
|
|
14
|
+
totalFiles,
|
|
15
|
+
maxFiles = 3,
|
|
16
|
+
accept = 'image/*, application/pdf',
|
|
17
|
+
capture = null,
|
|
18
|
+
nameFileLabel = 'Subir archivos',
|
|
19
|
+
classNames = '',
|
|
20
|
+
maxFileSize = maxSize,
|
|
19
21
|
}) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<div className='dropzone-upload-previewContainer'>
|
|
58
|
-
{meta.type === 'application/pdf' ? (
|
|
59
|
-
<>
|
|
60
|
-
<IconButtonSvg
|
|
61
|
-
className='form-control flex'
|
|
62
|
-
svg={pdfImage}
|
|
63
|
-
svgOver={pdfImage}
|
|
64
|
-
height='1.6rem'
|
|
65
|
-
width='1.6rem'
|
|
66
|
-
title={meta.name}
|
|
67
|
-
/>
|
|
68
|
-
<p>
|
|
69
|
-
{meta.name.length > 17
|
|
70
|
-
? meta.name.substring(0, 17) + '...'
|
|
71
|
-
: meta.name}
|
|
72
|
-
</p>
|
|
73
|
-
</>
|
|
74
|
-
) : (
|
|
75
|
-
<>
|
|
76
|
-
<img
|
|
77
|
-
className='dropzone-upload-previewImage'
|
|
78
|
-
src={meta.previewUrl}
|
|
79
|
-
alt={meta.name}
|
|
80
|
-
/>
|
|
81
|
-
<p>
|
|
82
|
-
{meta.name.length > 17
|
|
83
|
-
? meta.name.substring(0, 17) + '...'
|
|
84
|
-
: meta.name}
|
|
85
|
-
</p>
|
|
86
|
-
</>
|
|
87
|
-
)}
|
|
88
|
-
<p>{(meta.size / 1024).toFixed(2)} .Kb</p>
|
|
89
|
-
<button
|
|
90
|
-
onClick={remove}
|
|
91
|
-
className='dropzone-upload-delete-btn simple-icon-trash'
|
|
92
|
-
></button>
|
|
93
|
-
</div>
|
|
94
|
-
)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const Input = ({ accept, onFiles, getFilesFromEvent }) => {
|
|
98
|
-
const text =
|
|
99
|
-
totalFilesDU > 0
|
|
100
|
-
? `${maxFiles - totalFilesDU} archivo/s más`
|
|
101
|
-
: nameFileLabel
|
|
102
|
-
return (
|
|
103
|
-
<label className='dropzone-upload-button'>
|
|
104
|
-
{text}
|
|
105
|
-
<input
|
|
106
|
-
style={{ display: 'none' }}
|
|
107
|
-
type='file'
|
|
108
|
-
accept={accept}
|
|
109
|
-
capture={capture}
|
|
110
|
-
multiple
|
|
111
|
-
onChange={(e) => {
|
|
112
|
-
getFilesFromEvent(e).then((chosenFiles) => {
|
|
113
|
-
onFiles(chosenFiles)
|
|
114
|
-
})
|
|
115
|
-
}}
|
|
116
|
-
/>
|
|
117
|
-
</label>
|
|
118
|
-
)
|
|
119
|
-
}
|
|
120
|
-
useEffect(() => {
|
|
121
|
-
setTotalFilesDU(totalFiles)
|
|
122
|
-
}, [totalFiles])
|
|
123
|
-
|
|
22
|
+
const [files, setFiles] = useState([]);
|
|
23
|
+
const [totalFilesDU, setTotalFilesDU] = useState(totalFiles);
|
|
24
|
+
const handleChangeStatus = ({ file }, status) => {
|
|
25
|
+
if (status == 'done') {
|
|
26
|
+
const filesTemp = files;
|
|
27
|
+
filesTemp.push(file);
|
|
28
|
+
setFiles(filesTemp);
|
|
29
|
+
onChangeFiles(files);
|
|
30
|
+
setTotalFilesDU(files.length);
|
|
31
|
+
} else if (status == 'removed') {
|
|
32
|
+
const filesTemp = files;
|
|
33
|
+
const index = files.indexOf(file);
|
|
34
|
+
if (index > -1) {
|
|
35
|
+
filesTemp.splice(index, 1);
|
|
36
|
+
}
|
|
37
|
+
setFiles(filesTemp);
|
|
38
|
+
onChangeFiles(files);
|
|
39
|
+
setTotalFilesDU(files.length);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
const getFilesFromEvent = (e) => {
|
|
43
|
+
return new Promise((resolve) => {
|
|
44
|
+
getDroppedOrSelectedFiles(e).then((chosenFiles) => {
|
|
45
|
+
resolve(chosenFiles.map((f) => f.fileObject));
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const CustomPreview = ({ fileWithMeta }) => {
|
|
50
|
+
const { meta, remove } = fileWithMeta;
|
|
51
|
+
if (meta.size / (1024 * 1024) > maxFileSize) {
|
|
52
|
+
NotificationManager.error(
|
|
53
|
+
'El archivo supera el tamaño máximo',
|
|
54
|
+
'Advertencia',
|
|
55
|
+
);
|
|
56
|
+
remove();
|
|
57
|
+
}
|
|
124
58
|
return (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
59
|
+
<div className="dropzone-upload-previewContainer">
|
|
60
|
+
{meta.type === 'application/pdf' ? (
|
|
61
|
+
<>
|
|
62
|
+
<IconButtonSvg
|
|
63
|
+
className="form-control flex"
|
|
64
|
+
svg={pdfImage}
|
|
65
|
+
svgOver={pdfImage}
|
|
66
|
+
height="1.6rem"
|
|
67
|
+
width="1.6rem"
|
|
68
|
+
title={meta.name}
|
|
69
|
+
/>
|
|
70
|
+
<p>
|
|
71
|
+
{meta.name.length > 17
|
|
72
|
+
? meta.name.substring(0, 17) + '...'
|
|
73
|
+
: meta.name}
|
|
74
|
+
</p>
|
|
75
|
+
</>
|
|
76
|
+
) : (
|
|
77
|
+
<>
|
|
78
|
+
<img
|
|
79
|
+
className="dropzone-upload-previewImage"
|
|
80
|
+
src={meta.previewUrl}
|
|
81
|
+
alt={meta.name}
|
|
136
82
|
/>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
83
|
+
<p>
|
|
84
|
+
{meta.name.length > 17
|
|
85
|
+
? meta.name.substring(0, 17) + '...'
|
|
86
|
+
: meta.name}
|
|
87
|
+
</p>
|
|
88
|
+
</>
|
|
89
|
+
)}
|
|
90
|
+
<p>{(meta.size / 1024).toFixed(2)} .Kb</p>
|
|
91
|
+
<button
|
|
92
|
+
onClick={remove}
|
|
93
|
+
className="dropzone-upload-delete-btn simple-icon-trash"
|
|
94
|
+
></button>
|
|
95
|
+
</div>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const Input = ({ accept, onFiles, getFilesFromEvent }) => {
|
|
100
|
+
const text =
|
|
101
|
+
totalFilesDU > 0
|
|
102
|
+
? `${maxFiles - totalFilesDU} archivo/s más`
|
|
103
|
+
: nameFileLabel;
|
|
104
|
+
return (
|
|
105
|
+
<label className="dropzone-upload-button">
|
|
106
|
+
{text}
|
|
107
|
+
<input
|
|
108
|
+
style={{ display: 'none' }}
|
|
109
|
+
type="file"
|
|
110
|
+
accept={accept}
|
|
111
|
+
capture={capture}
|
|
112
|
+
multiple
|
|
113
|
+
onChange={(e) => {
|
|
114
|
+
getFilesFromEvent(e).then((chosenFiles) => {
|
|
115
|
+
onFiles(chosenFiles);
|
|
116
|
+
});
|
|
117
|
+
}}
|
|
118
|
+
/>
|
|
119
|
+
</label>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
setTotalFilesDU(totalFiles);
|
|
124
|
+
}, [totalFiles]);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div className={`${classNames}`}>
|
|
128
|
+
<Dropzone
|
|
129
|
+
disableUpload={false}
|
|
130
|
+
maxFiles={totalFilesDU < maxFiles ? maxFiles : 0}
|
|
131
|
+
maxSize={maxFileSize} // en megas
|
|
132
|
+
InputComponent={Input}
|
|
133
|
+
PreviewComponent={CustomPreview}
|
|
134
|
+
classNames={{ dropzone: 'dropzone-upload-frame' }}
|
|
135
|
+
onChangeStatus={handleChangeStatus}
|
|
136
|
+
getFilesFromEvent={getFilesFromEvent}
|
|
137
|
+
accept={accept}
|
|
138
|
+
/>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
};
|