siam-ui-utils 2.1.8 → 2.1.10

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/index.d.ts CHANGED
@@ -10,7 +10,7 @@ declare module "siam-ui-utils" {
10
10
  export function CustomSelectInput(props);
11
11
 
12
12
  //DROPZONEUploader
13
- // export function DropzoneUploader(props);
13
+ export function DropzoneUploader(props);
14
14
 
15
15
  //INTLMESSAGES
16
16
  export function IntlMessages(props);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "siam-ui-utils",
3
- "version": "2.1.8",
3
+ "version": "2.1.10",
4
4
  "keywords": [
5
5
  "ampf-react",
6
6
  "ampf-utils",
@@ -1,4 +1,3 @@
1
- /* eslint-disable react/prop-types */
2
1
  import React, { useEffect, useState } from 'react';
3
2
  import { getDroppedOrSelectedFiles } from 'html5-file-selector';
4
3
  import Dropzone from 'react-dropzone-uploader';
@@ -8,9 +7,16 @@ import IconButtonSvg from '../iconos/icon-button-svg';
8
7
  import { pdfImage } from '../constants-svg';
9
8
  import './dropzone-uploader.css';
10
9
 
11
- console.log('dropzone1 :>> ');
12
-
13
10
  const maxSize = 7; //en MB
11
+
12
+ const getFilesFromEvent = (e) => {
13
+ return new Promise((resolve) => {
14
+ getDroppedOrSelectedFiles(e).then((chosenFiles) => {
15
+ resolve(chosenFiles.map((f) => f.fileObject));
16
+ });
17
+ });
18
+ };
19
+
14
20
  export const DropzoneUploader = ({
15
21
  onChangeFiles,
16
22
  totalFiles,
@@ -20,40 +26,34 @@ export const DropzoneUploader = ({
20
26
  nameFileLabel = 'Subir archivos',
21
27
  maxFileSize = maxSize,
22
28
  }) => {
23
- console.log('dropzone2 :>> ');
24
-
25
29
  const [files, setFiles] = useState([]);
26
30
  const [totalFilesDU, setTotalFilesDU] = useState(totalFiles);
27
- const handleChangeStatus = ({ file }, status) => {
28
- if (status == 'done') {
29
- const filesTemp = files;
30
- filesTemp.push(file);
31
- setFiles(filesTemp);
32
- onChangeFiles(files);
33
- setTotalFilesDU(files.length);
34
- } else if (status == 'removed') {
35
- const filesTemp = files;
36
- const index = files.indexOf(file);
37
- if (index > -1) {
38
- filesTemp.splice(index, 1);
39
- }
40
- setFiles(filesTemp);
41
- onChangeFiles(files);
42
- setTotalFilesDU(files.length);
43
- }
44
- };
45
- const getFilesFromEvent = (e) => {
46
- console.log('dropzone3 :>> ');
47
31
 
48
- return new Promise((resolve) => {
49
- getDroppedOrSelectedFiles(e).then((chosenFiles) => {
50
- resolve(chosenFiles.map((f) => f.fileObject));
51
- });
52
- });
32
+ const Input = ({ accept, onFiles, getFilesFromEvent }) => {
33
+ const text =
34
+ totalFilesDU > 0
35
+ ? `${maxFiles - totalFilesDU} archivo/s más`
36
+ : nameFileLabel;
37
+ return (
38
+ <label className="dropzone-upload-button">
39
+ {text}
40
+ <input
41
+ style={{ display: 'none' }}
42
+ type="file"
43
+ accept={accept}
44
+ capture={capture}
45
+ multiple
46
+ onChange={(e) => {
47
+ getFilesFromEvent(e).then((chosenFiles) => {
48
+ onFiles(chosenFiles);
49
+ });
50
+ }}
51
+ />
52
+ </label>
53
+ );
53
54
  };
54
- const CustomPreview = ({ fileWithMeta }) => {
55
- console.log('dropzone4 :>> ');
56
55
 
56
+ const CustomPreview = ({ fileWithMeta }) => {
57
57
  const { meta, remove } = fileWithMeta;
58
58
  if (meta.size / (1024 * 1024) > maxFileSize) {
59
59
  NotificationManager.error(
@@ -103,37 +103,29 @@ export const DropzoneUploader = ({
103
103
  );
104
104
  };
105
105
 
106
- const Input = ({ accept, onFiles, getFilesFromEvent }) => {
107
- console.log('dropzone4 :>> ');
108
-
109
- const text =
110
- totalFilesDU > 0
111
- ? `${maxFiles - totalFilesDU} archivo/s más`
112
- : nameFileLabel;
113
- return (
114
- <label className="dropzone-upload-button">
115
- {text}
116
- <input
117
- style={{ display: 'none' }}
118
- type="file"
119
- accept={accept}
120
- capture={capture}
121
- multiple
122
- onChange={(e) => {
123
- getFilesFromEvent(e).then((chosenFiles) => {
124
- onFiles(chosenFiles);
125
- });
126
- }}
127
- />
128
- </label>
129
- );
106
+ const handleChangeStatus = ({ file }, status) => {
107
+ if (status == 'done') {
108
+ const filesTemp = files;
109
+ filesTemp.push(file);
110
+ setFiles(filesTemp);
111
+ onChangeFiles(files);
112
+ setTotalFilesDU(files.length);
113
+ } else if (status == 'removed') {
114
+ const filesTemp = files;
115
+ const index = files.indexOf(file);
116
+ if (index > -1) {
117
+ filesTemp.splice(index, 1);
118
+ }
119
+ setFiles(filesTemp);
120
+ onChangeFiles(files);
121
+ setTotalFilesDU(files.length);
122
+ }
130
123
  };
124
+
131
125
  useEffect(() => {
132
126
  setTotalFilesDU(totalFiles);
133
127
  }, [totalFiles]);
134
128
 
135
- console.log('dropzone5 :>> ');
136
-
137
129
  return (
138
130
  <>
139
131
  <Dropzone
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
- // export { DropzoneUploader } from './dropzone-uploader';
2
- export { withRouter } from './bridges';
3
- export { Colxx, Separator } from './CustomBootstrap';
4
- export { CustomSelectInput } from './CustomSelectInput';
5
- export { IntlMessages } from './IntlMessages';
6
- export { TomarFoto } from './tomar-foto';
1
+ export * from './dropzone-uploader';
2
+ export * from './bridges';
3
+ export * from './CustomBootstrap';
4
+ export * from './CustomSelectInput';
5
+ export * from './IntlMessages';
6
+ export * from './tomar-foto';
@@ -1,6 +1,6 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
- import { DropzoneUploader } from '.';
3
+ import { DropzoneUploader } from '../dropzone-uploader';
4
4
 
5
5
  const args = {
6
6
  onChangeFiles: () => {
@@ -1,14 +1,14 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react';
2
2
 
3
- import { TomarFoto } from '.';
3
+ import { TomarFoto } from '../tomar-foto';
4
4
 
5
5
  const meta = {
6
6
  title: 'Components/TomarFoto',
7
7
  component: TomarFoto,
8
- args: {
9
- onFilesSelectedSelfie:() => { },
10
- isMobile:false
11
- },
8
+ args: {
9
+ onFilesSelectedSelfie: () => {},
10
+ isMobile: false,
11
+ },
12
12
  } satisfies Meta<typeof TomarFoto>;
13
13
 
14
14
  export default meta;
@@ -16,14 +16,14 @@ type Story = StoryObj<typeof meta>;
16
16
 
17
17
  export const TomarFotoWebApplication: Story = {
18
18
  args: {
19
- isMobile: false
20
- },
19
+ isMobile: false,
20
+ },
21
21
  };
22
22
  export const TomarFotoMobileApplication: Story = {
23
23
  args: {
24
24
  isMobile: true,
25
- onFilesSelectedSelfie: () => {
26
- console.log('Dispatch an action')
27
- }
25
+ onFilesSelectedSelfie: () => {
26
+ console.log('Dispatch an action');
27
+ },
28
28
  },
29
29
  };
@@ -1,67 +1,66 @@
1
1
  /* eslint-disable react/prop-types */
2
- import React, { useState } from 'react';
3
- import { Row } from 'reactstrap';
4
- import { DropzoneUploader } from '../dropzone-uploader';
5
- import { Colxx } from '../CustomBootstrap';
6
- import { TAKE_PHOTO } from '../constants';
7
- import imgHacerFoto from '../assets/img/take-photo.png';
2
+ import React, { useState } from 'react'
3
+ import { Row } from 'reactstrap'
4
+ import { DropzoneUploader, Colxx } from '../'
5
+ import { TAKE_PHOTO } from '../constants'
6
+ import imgHacerFoto from '../assets/img/take-photo.png'
8
7
 
9
8
  export const TomarFoto = ({ onFilesSelectedSelfie, isMobile = false }) => {
10
- const [filesTotalSelectedSelfie, setTotalFilesSelectedSelfie] = useState(0);
11
- const {
12
- LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE,
13
- MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE,
14
- TAKE_PHOTO_MESSAGE,
15
- } = TAKE_PHOTO;
9
+ const [filesTotalSelectedSelfie, setTotalFilesSelectedSelfie] = useState(0)
10
+ const {
11
+ LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE,
12
+ MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE,
13
+ TAKE_PHOTO_MESSAGE,
14
+ } = TAKE_PHOTO
16
15
 
17
- const handleFilesSelectedSelfie = (files) => {
18
- setTotalFilesSelectedSelfie(files.length);
19
- onFilesSelectedSelfie(files);
20
- };
16
+ const handleFilesSelectedSelfie = (files) => {
17
+ setTotalFilesSelectedSelfie(files.length)
18
+ onFilesSelectedSelfie(files)
19
+ }
21
20
 
22
- return (
23
- <>
24
- <Row className="pt-2 ml-4">
25
- <Colxx xxs="11" md="5">
26
- {LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE}
27
- </Colxx>
28
- </Row>
29
- <Row className="pt-2 ml-2">
30
- <Colxx xxs="12" md="9">
31
- {isMobile ? (
32
- <>
33
- <Colxx xxs="12" className="text-center">
34
- {filesTotalSelectedSelfie === 0 && (
35
- <img
36
- style={{ width: '97%' }}
37
- alt="hacerFotoDNI"
38
- src={imgHacerFoto}
39
- />
40
- )}
41
- <DropzoneUploader
42
- className="pt-2 ml-2"
43
- maxFiles={1}
44
- onChangeFiles={handleFilesSelectedSelfie}
45
- totalFiles={filesTotalSelectedSelfie}
46
- accept="image/jpg,image/jpeg"
47
- capture="environment"
48
- nameFileLabel={TAKE_PHOTO_MESSAGE}
49
- />
50
- </Colxx>
51
- </>
52
- ) : (
53
- <h2
54
- className={'view-icon iconsminds-smartphone-4 ml-2 mr-2'}
55
- style={{
56
- color: 'red',
57
- margin: '10px 10px 0px 10px',
58
- }}
59
- >
60
- {MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE}
61
- </h2>
62
- )}
63
- </Colxx>
64
- </Row>
65
- </>
66
- );
67
- };
21
+ return (
22
+ <>
23
+ <Row className='pt-2 ml-4'>
24
+ <Colxx xxs='11' md='5'>
25
+ {LOAD_SELFIE_WITH_IDENTITY_CARD_MESSAGE}
26
+ </Colxx>
27
+ </Row>
28
+ <Row className='pt-2 ml-2'>
29
+ <Colxx xxs='12' md='9'>
30
+ {isMobile ? (
31
+ <>
32
+ <Colxx xxs='12' className='text-center'>
33
+ {filesTotalSelectedSelfie === 0 && (
34
+ <img
35
+ style={{ width: '97%' }}
36
+ alt='hacerFotoDNI'
37
+ src={imgHacerFoto}
38
+ />
39
+ )}
40
+ <DropzoneUploader
41
+ className='pt-2 ml-2'
42
+ maxFiles={1}
43
+ onChangeFiles={handleFilesSelectedSelfie}
44
+ totalFiles={filesTotalSelectedSelfie}
45
+ accept='image/jpg,image/jpeg'
46
+ capture='environment'
47
+ nameFileLabel={TAKE_PHOTO_MESSAGE}
48
+ />
49
+ </Colxx>
50
+ </>
51
+ ) : (
52
+ <h2
53
+ className={'view-icon iconsminds-smartphone-4 ml-2 mr-2'}
54
+ style={{
55
+ color: 'red',
56
+ margin: '10px 10px 0px 10px',
57
+ }}
58
+ >
59
+ {MESSAGE_SELFIE_ONLY_CAN_TAKE_FROM_CELLPHONE}
60
+ </h2>
61
+ )}
62
+ </Colxx>
63
+ </Row>
64
+ </>
65
+ )
66
+ }