siam-ui-utils 2.0.25 → 2.0.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siam-ui-utils",
3
- "version": "2.0.25",
3
+ "version": "2.0.27",
4
4
  "keywords": [
5
5
  "ampf-react",
6
6
  "ampf-utils",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@types/react-intl": "^3.0.0",
27
+ "events": "^3.3.0",
27
28
  "html5-file-selector": "^2.1.0",
28
29
  "prop-types": "^15.8.1",
29
30
  "react": "^18.3.1",
@@ -41,14 +42,17 @@
41
42
  "vite-plugin-commonjs": "^0.10.3"
42
43
  },
43
44
  "devDependencies": {
45
+ "@eslint/js": "^9.9.0",
44
46
  "@testing-library/dom": "^10.4.0",
45
47
  "@testing-library/jest-dom": "^6.4.8",
46
48
  "@testing-library/react": "^16.0.0",
49
+ "@types/react": "^18.3.3",
50
+ "@types/react-dom": "^18.3.0",
47
51
  "@types/react-router-dom": "^5.3.3",
48
52
  "@typescript-eslint/parser": "^8.2.0",
49
53
  "@vitejs/plugin-react": "^4.3.1",
50
54
  "copyfiles": "^2.4.1",
51
- "eslint": "^8.57.0",
55
+ "eslint": "^9.9.0",
52
56
  "eslint-config-airbnb": "^19.0.4",
53
57
  "eslint-config-prettier": "^8.8.0",
54
58
  "eslint-config-react-app": "^7.0.1",
@@ -56,6 +60,9 @@
56
60
  "eslint-plugin-jsx-a11y": "^6.7.1",
57
61
  "eslint-plugin-prettier": "^4.2.1",
58
62
  "eslint-plugin-react": "^7.33.0",
63
+ "eslint-plugin-react-hooks": "^5.1.0-rc.0",
64
+ "eslint-plugin-react-refresh": "^0.4.9",
65
+ "sass-embedded": "^1.79.4",
59
66
  "vite": "^5.3.4",
60
67
  "vite-plugin-eslint": "^1.8.1",
61
68
  "vitest": "^2.0.5"
package/src/App.css ADDED
@@ -0,0 +1,42 @@
1
+ #root {
2
+ max-width: 1280px;
3
+ margin: 0 auto;
4
+ padding: 2rem;
5
+ text-align: center;
6
+ }
7
+
8
+ .logo {
9
+ height: 6em;
10
+ padding: 1.5em;
11
+ will-change: filter;
12
+ transition: filter 300ms;
13
+ }
14
+ .logo:hover {
15
+ filter: drop-shadow(0 0 2em #646cffaa);
16
+ }
17
+ .logo.react:hover {
18
+ filter: drop-shadow(0 0 2em #61dafbaa);
19
+ }
20
+
21
+ @keyframes logo-spin {
22
+ from {
23
+ transform: rotate(0deg);
24
+ }
25
+ to {
26
+ transform: rotate(360deg);
27
+ }
28
+ }
29
+
30
+ @media (prefers-reduced-motion: no-preference) {
31
+ a:nth-of-type(2) .logo {
32
+ animation: logo-spin infinite 20s linear;
33
+ }
34
+ }
35
+
36
+ .card {
37
+ padding: 2em;
38
+ }
39
+
40
+ .read-the-docs {
41
+ color: #888;
42
+ }
package/src/App.jsx CHANGED
@@ -6,9 +6,11 @@ import {
6
6
  AccordionItem,
7
7
  } from 'reactstrap';
8
8
  import { TomarFoto, DropzoneUploader, DropzoneUploaderDniDigital } from './';
9
+ import './index.css';
10
+ import './App.css';
9
11
  import './assets/css/vendor/bootstrap.min.css';
10
12
 
11
- function App() {
13
+ const App = () => {
12
14
  const [open, setOpen] = useState('0');
13
15
  const toggle = (id) => {
14
16
  if (open === id) {
@@ -56,16 +58,19 @@ function App() {
56
58
  <AccordionBody accordionId="3">
57
59
  <DropzoneUploaderDniDigital
58
60
  totalFiles={0}
59
- maxFiles={1}
61
+ maxFiles={2}
60
62
  onChangeFiles={() => {
61
63
  console.log('onChange');
62
64
  }}
65
+ onMaxFileSizeError={() => {
66
+ console.log('MAXIMO ARCHIVO PERMITIDO :>> ');
67
+ }}
63
68
  />
64
69
  </AccordionBody>
65
70
  </AccordionItem>
66
71
  </Accordion>
67
72
  </div>
68
73
  );
69
- }
74
+ };
70
75
 
71
76
  export default App;
@@ -1,153 +1,151 @@
1
1
  /* eslint-disable react/prop-types */
2
- import { useState } from 'react'
3
-
4
- import { Button } from 'reactstrap'
5
-
6
- import { getDroppedOrSelectedFiles } from 'html5-file-selector'
7
- import Dropzone from 'react-dropzone-uploader'
8
- import 'react-dropzone-uploader/dist/styles.css'
9
- import { NotificationManager } from 'react-notifications'
10
- import { pdfImage, IconButtonSvg } from '../../iconos'
11
- import '../dropzone-uploader.css'
2
+ import { useState } from 'react';
3
+ import { Button } from 'reactstrap';
4
+ import { getDroppedOrSelectedFiles } from 'html5-file-selector';
5
+ import Dropzone from 'react-dropzone-uploader';
6
+ import 'react-dropzone-uploader/dist/styles.css';
7
+ import { pdfImage, IconButtonSvg } from '../../iconos';
8
+ import '../dropzone-uploader.css';
12
9
 
13
10
  export const DropzoneUploaderDniDigital = ({
14
- accept = 'image/*, application/pdf',
15
- classNames = '',
16
- onChangeFiles,
17
- totalFiles,
18
- label = 'Cargar Dni',
19
- maxSize = 2,
11
+ accept = 'image/*, application/pdf',
12
+ classNames = '',
13
+ onChangeFiles,
14
+ totalFiles,
15
+ label = 'Cargar Dni',
16
+ maxSize = 2,
17
+ onMaxFileSizeError = () => {
18
+ alert('El archivo supera el tamaño máximo');
19
+ },
20
20
  }) => {
21
- const [files, setFiles] = useState([])
21
+ const [files, setFiles] = useState([]);
22
22
 
23
- const handleChangeStatus = ({ file }, status) => {
24
- if (status === 'done') {
25
- const filesTemp = [...files]
26
- filesTemp.push(file)
27
- setFiles(filesTemp)
28
- onChangeFiles(filesTemp)
29
- } else if (status === 'removed') {
30
- const filesTemp = [...files]
31
- const index = filesTemp.indexOf(file)
32
- if (index > -1) {
33
- filesTemp.splice(index, 1)
34
- }
35
- setFiles(filesTemp)
36
- onChangeFiles(filesTemp)
37
- }
38
- }
23
+ const handleChangeStatus = ({ file }, status) => {
24
+ if (status === 'done') {
25
+ const filesTemp = [...files];
26
+ filesTemp.push(file);
27
+ setFiles(filesTemp);
28
+ onChangeFiles(filesTemp);
29
+ } else if (status === 'removed') {
30
+ const filesTemp = [...files];
31
+ const index = filesTemp.indexOf(file);
32
+ if (index > -1) {
33
+ filesTemp.splice(index, 1);
34
+ }
35
+ setFiles(filesTemp);
36
+ onChangeFiles(filesTemp);
37
+ }
38
+ };
39
39
 
40
- const getFilesFromEvent = (e) => {
41
- return new Promise((resolve) => {
42
- getDroppedOrSelectedFiles(e).then((chosenFiles) => {
43
- resolve(chosenFiles.map((f) => f.fileObject))
44
- })
45
- })
46
- }
40
+ const getFilesFromEvent = (e) => {
41
+ return new Promise((resolve) => {
42
+ getDroppedOrSelectedFiles(e).then((chosenFiles) => {
43
+ resolve(chosenFiles.map((f) => f.fileObject));
44
+ });
45
+ });
46
+ };
47
47
 
48
- const CustomPreview = ({ fileWithMeta }) => {
49
- const { meta, remove } = fileWithMeta
50
- if (meta.size / (1024 * 1024) > maxSize) {
51
- NotificationManager.error(
52
- 'El archivo supera el tamaño máximo',
53
- 'Advertencia'
54
- )
55
- remove()
56
- }
57
- return (
58
- <div
59
- className='dropzone-upload-previewContainer'
60
- style={{ width: '100%', display: 'flex', alignItems: 'center' }}
61
- >
62
- {meta.type === 'application/pdf' ? (
63
- <>
64
- <IconButtonSvg
65
- className='form-control flex'
66
- svg={pdfImage}
67
- svgOver={pdfImage}
68
- height='1.6rem'
69
- width='1.6rem'
70
- title={meta.name}
71
- />
72
- <p style={{ paddingRight: '1rem' }}>
73
- {meta.name.length > 17
74
- ? meta.name.substring(0, 17) + '...'
75
- : meta.name}
76
- </p>
77
- </>
78
- ) : (
79
- <>
80
- <img
81
- className='dropzone-upload-previewImage mt-1'
82
- src={meta.previewUrl}
83
- alt={meta.name}
84
- style={{
85
- width: '110px',
86
- height: '110px',
87
- objectFit: 'cover',
88
- marginRight: '0.5rem',
89
- }}
90
- />
91
- <div className='dropzone-upload-file-name-container'>
92
- <p className='dropzone-upload-file-name' title={meta.name}>
93
- {meta.name}
94
- </p>
95
- </div>
96
- </>
97
- )}
98
- <button
99
- style={{ marginTop: '0rem' }}
100
- onClick={remove}
101
- className='dropzone-upload-delete-btn simple-icon-trash'
102
- ></button>
103
- </div>
104
- )
105
- }
48
+ const CustomPreview = ({ fileWithMeta }) => {
49
+ const { meta, remove } = fileWithMeta;
50
+ console.log('meta.size :>> ', meta.size);
51
+ if (meta.size / (1024 * 1024) > maxSize) {
52
+ onMaxFileSizeError();
53
+ remove();
54
+ }
55
+ return (
56
+ <div
57
+ className="dropzone-upload-previewContainer"
58
+ style={{ width: '100%', display: 'flex', alignItems: 'center' }}
59
+ >
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 style={{ paddingRight: '1rem' }}>
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 mt-1"
80
+ src={meta.previewUrl}
81
+ alt={meta.name}
82
+ style={{
83
+ width: '110px',
84
+ height: '110px',
85
+ objectFit: 'cover',
86
+ marginRight: '0.5rem',
87
+ }}
88
+ />
89
+ <div className="dropzone-upload-file-name-container">
90
+ <p className="dropzone-upload-file-name" title={meta.name}>
91
+ {meta.name}
92
+ </p>
93
+ </div>
94
+ </>
95
+ )}
96
+ <button
97
+ style={{ marginTop: '0rem' }}
98
+ onClick={remove}
99
+ className="dropzone-upload-delete-btn simple-icon-trash"
100
+ ></button>
101
+ </div>
102
+ );
103
+ };
106
104
 
107
- const Input = ({ accept, onFiles, getFilesFromEvent }) => {
108
- const text = totalFiles > 0 ? `${2 - totalFiles} archivos más` : `${label}`
109
- return (
110
- <>
111
- <Button
112
- outline
113
- block
114
- size='xs'
115
- className='mt-5 ml-5'
116
- onClick={() => document.getElementById('fileInput').click()}
117
- >
118
- {text}
119
- <input
120
- id='fileInput'
121
- style={{ display: 'none' }}
122
- type='file'
123
- accept={accept}
124
- multiple
125
- onChange={(e) => {
126
- getFilesFromEvent(e).then((chosenFiles) => {
127
- onFiles(chosenFiles)
128
- })
129
- }}
130
- />
131
- </Button>
132
- </>
133
- )
134
- }
105
+ const Input = ({ accept, onFiles, getFilesFromEvent }) => {
106
+ const text = totalFiles > 0 ? `${2 - totalFiles} archivos más` : `${label}`;
107
+ return (
108
+ <>
109
+ <Button
110
+ outline
111
+ block
112
+ size="xs"
113
+ className="mt-5 ml-5"
114
+ onClick={() => document.getElementById('fileInput').click()}
115
+ >
116
+ {text}
117
+ <input
118
+ id="fileInput"
119
+ style={{ display: 'none' }}
120
+ type="file"
121
+ accept={accept}
122
+ multiple
123
+ onChange={(e) => {
124
+ getFilesFromEvent(e).then((chosenFiles) => {
125
+ onFiles(chosenFiles);
126
+ });
127
+ }}
128
+ />
129
+ </Button>
130
+ </>
131
+ );
132
+ };
135
133
 
136
- return (
137
- <div className={classNames}>
138
- <Dropzone
139
- disableUpload={false}
140
- maxFiles={totalFiles < 2 ? 2 : 0}
141
- maxSize={maxSize} // en megas
142
- InputComponent={Input}
143
- PreviewComponent={CustomPreview}
144
- classNames={{ dropzone: 'dropzone-upload-frame' }}
145
- onChangeStatus={handleChangeStatus}
146
- getFilesFromEvent={getFilesFromEvent}
147
- accept={accept}
148
- />
149
- </div>
150
- )
151
- }
134
+ return (
135
+ <div className={classNames}>
136
+ <Dropzone
137
+ disableUpload={false}
138
+ maxFiles={totalFiles < 2 ? 2 : 0}
139
+ maxSize={maxSize} // en megas
140
+ InputComponent={Input}
141
+ PreviewComponent={CustomPreview}
142
+ classNames={{ dropzone: 'dropzone-upload-frame' }}
143
+ onChangeStatus={handleChangeStatus}
144
+ getFilesFromEvent={getFilesFromEvent}
145
+ accept={accept}
146
+ />
147
+ </div>
148
+ );
149
+ };
152
150
 
153
- export default DropzoneUploaderDniDigital
151
+ export default DropzoneUploaderDniDigital;
@@ -2,7 +2,6 @@
2
2
  import React, { useEffect, useState } from 'react';
3
3
  import { getDroppedOrSelectedFiles } from 'html5-file-selector';
4
4
  import Dropzone from 'react-dropzone-uploader';
5
- import { NotificationManager } from 'react-notifications';
6
5
  import 'react-dropzone-uploader/dist/styles.css';
7
6
  import { IconButtonSvg, pdfImage } from '../iconos';
8
7
  import './dropzone-uploader.css';
@@ -18,6 +17,9 @@ export const DropzoneUploader = ({
18
17
  nameFileLabel = 'Subir archivos',
19
18
  classNames = '',
20
19
  maxFileSize = maxSize,
20
+ onMaxFileSizeError = () => {
21
+ alert('El archivo supera el tamaño máximo');
22
+ },
21
23
  }) => {
22
24
  const [files, setFiles] = useState([]);
23
25
  const [totalFilesDU, setTotalFilesDU] = useState(totalFiles);
@@ -49,10 +51,7 @@ export const DropzoneUploader = ({
49
51
  const CustomPreview = ({ fileWithMeta }) => {
50
52
  const { meta, remove } = fileWithMeta;
51
53
  if (meta.size / (1024 * 1024) > maxFileSize) {
52
- NotificationManager.error(
53
- 'El archivo supera el tamaño máximo',
54
- 'Advertencia',
55
- );
54
+ onMaxFileSizeError();
56
55
  remove();
57
56
  }
58
57
  return (