siam-ui-utils 2.1.0 → 2.1.2
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/.storybook/main.ts +17 -17
- package/.storybook/preview.ts +16 -16
- package/package.json +87 -87
- package/src/bridges/index.jsx +1 -3
- package/src/dropzone-uploader/DropzoneUploader.stories.tsx +17 -15
- package/src/dropzone-uploader/index.jsx +144 -132
- package/src/index.js +6 -7
- package/vite.config.ts +2 -6
package/.storybook/main.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import type { StorybookConfig } from '@storybook/react-vite';
|
|
2
|
-
|
|
3
|
-
const config: StorybookConfig = {
|
|
4
|
-
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
5
|
-
addons: [
|
|
6
|
-
'@storybook/addon-onboarding',
|
|
7
|
-
'@storybook/addon-links',
|
|
8
|
-
'@storybook/addon-essentials',
|
|
9
|
-
'@chromatic-com/storybook',
|
|
10
|
-
'@storybook/addon-interactions',
|
|
11
|
-
],
|
|
12
|
-
framework: {
|
|
13
|
-
name: '@storybook/react-vite',
|
|
14
|
-
options: {},
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
export default config;
|
|
1
|
+
import type { StorybookConfig } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
const config: StorybookConfig = {
|
|
4
|
+
stories: ['../src/**/*.mdx', '../src/**/*.stories.@(js|jsx|mjs|ts|tsx)'],
|
|
5
|
+
addons: [
|
|
6
|
+
'@storybook/addon-onboarding',
|
|
7
|
+
'@storybook/addon-links',
|
|
8
|
+
'@storybook/addon-essentials',
|
|
9
|
+
'@chromatic-com/storybook',
|
|
10
|
+
'@storybook/addon-interactions',
|
|
11
|
+
],
|
|
12
|
+
framework: {
|
|
13
|
+
name: '@storybook/react-vite',
|
|
14
|
+
options: {},
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
export default config;
|
package/.storybook/preview.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Preview } from '@storybook/react';
|
|
2
|
-
import "./css/bootstrap.min.css";
|
|
3
|
-
import "./css/bootstrap.rtl.only.min.css";
|
|
4
|
-
|
|
5
|
-
const preview: Preview = {
|
|
6
|
-
parameters: {
|
|
7
|
-
controls: {
|
|
8
|
-
matchers: {
|
|
9
|
-
color: /(background|color)$/i,
|
|
10
|
-
date: /Date$/i,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default preview;
|
|
1
|
+
import type { Preview } from '@storybook/react';
|
|
2
|
+
import "./css/bootstrap.min.css";
|
|
3
|
+
import "./css/bootstrap.rtl.only.min.css";
|
|
4
|
+
|
|
5
|
+
const preview: Preview = {
|
|
6
|
+
parameters: {
|
|
7
|
+
controls: {
|
|
8
|
+
matchers: {
|
|
9
|
+
color: /(background|color)$/i,
|
|
10
|
+
date: /Date$/i,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default preview;
|
package/package.json
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "siam-ui-utils",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"keywords": [
|
|
5
|
-
"ampf-react",
|
|
6
|
-
"ampf-utils",
|
|
7
|
-
"siam-ui-utils"
|
|
8
|
-
],
|
|
9
|
-
"type": "module",
|
|
10
|
-
"author": "Ampf Development Team",
|
|
11
|
-
"license": "MIT",
|
|
12
|
-
"description": "Conjunto de librerias de componentes utiles para AMPF",
|
|
13
|
-
"main": "src/index.js",
|
|
14
|
-
"browser": "src/index.js",
|
|
15
|
-
"types": "index",
|
|
16
|
-
"homepage": "https://github.com/ampfgit/siam-ui-utils#readme",
|
|
17
|
-
"repository": {
|
|
18
|
-
"type": "git",
|
|
19
|
-
"url": "https://github.com/ampfgit/siam-ui-utils"
|
|
20
|
-
},
|
|
21
|
-
"moduleResolution": "nodenext",
|
|
22
|
-
"scripts": {
|
|
23
|
-
"start": "vite",
|
|
24
|
-
"publish-npm": "npm publish",
|
|
25
|
-
"storybook": "storybook dev -p 6006",
|
|
26
|
-
"build-storybook": "storybook build"
|
|
27
|
-
},
|
|
28
|
-
"dependencies": {
|
|
29
|
-
"@storybook/cli": "^8.3.2",
|
|
30
|
-
"@types/react-intl": "^3.0.0",
|
|
31
|
-
"eslint-plugin-react-hooks": "^4.6.2",
|
|
32
|
-
"eslint-plugin-react-refresh": "^0.4.12",
|
|
33
|
-
"html5-file-selector": "^2.1.0",
|
|
34
|
-
"init": "^0.1.2",
|
|
35
|
-
"prop-types": "^15.8.1",
|
|
36
|
-
"react": "^18.3.1",
|
|
37
|
-
"react-dropzone-uploader": "^2.11.0",
|
|
38
|
-
"react-intl": "^6.4.2",
|
|
39
|
-
"react-notifications": "^1.7.4",
|
|
40
|
-
"react-router": "^6.26.2",
|
|
41
|
-
"react-router-dom": "^6.26.2",
|
|
42
|
-
"react-select": "^5.8.0",
|
|
43
|
-
"reactstrap": "^9.2.2",
|
|
44
|
-
"siam-utils": "^1.1.4",
|
|
45
|
-
"source-map-loader": "^5.0.0",
|
|
46
|
-
"styled-components": "^6.1.12",
|
|
47
|
-
"typescript": "^5.5.4",
|
|
48
|
-
"vite-plugin-commonjs": "^0.10.3"
|
|
49
|
-
},
|
|
50
|
-
"devDependencies": {
|
|
51
|
-
"@chromatic-com/storybook": "^1.9.0",
|
|
52
|
-
"@storybook/addon-essentials": "^8.3.2",
|
|
53
|
-
"@storybook/addon-interactions": "^8.3.2",
|
|
54
|
-
"@storybook/addon-links": "^8.3.2",
|
|
55
|
-
"@storybook/addon-onboarding": "^8.3.2",
|
|
56
|
-
"@storybook/blocks": "^8.3.2",
|
|
57
|
-
"@storybook/react": "^8.3.2",
|
|
58
|
-
"@storybook/react-vite": "^8.3.2",
|
|
59
|
-
"@storybook/test": "^8.3.2",
|
|
60
|
-
"@testing-library/dom": "^10.4.0",
|
|
61
|
-
"@testing-library/jest-dom": "^6.4.8",
|
|
62
|
-
"@testing-library/react": "^16.0.0",
|
|
63
|
-
"@types/react-router-dom": "^5.3.3",
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
65
|
-
"@typescript-eslint/parser": "^5.0.0",
|
|
66
|
-
"@vitejs/plugin-react": "^4.3.1",
|
|
67
|
-
"copyfiles": "^2.4.1",
|
|
68
|
-
"eslint": "^8.57.1",
|
|
69
|
-
"eslint-config-airbnb": "^19.0.4",
|
|
70
|
-
"eslint-config-prettier": "^8.8.0",
|
|
71
|
-
"eslint-config-react-app": "^7.0.1",
|
|
72
|
-
"eslint-plugin-import": "^2.27.5",
|
|
73
|
-
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
74
|
-
"eslint-plugin-prettier": "^5.0.0-alpha.1",
|
|
75
|
-
"eslint-plugin-react": "^7.33.0",
|
|
76
|
-
"eslint-plugin-storybook": "^0.8.0",
|
|
77
|
-
"storybook": "^8.3.2",
|
|
78
|
-
"vite": "^5.3.4",
|
|
79
|
-
"vite-plugin-eslint": "^1.
|
|
80
|
-
"vitest": "^2.0.5"
|
|
81
|
-
},
|
|
82
|
-
"eslintConfig": {
|
|
83
|
-
"extends": [
|
|
84
|
-
"plugin:storybook/recommended"
|
|
85
|
-
]
|
|
86
|
-
}
|
|
87
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "siam-ui-utils",
|
|
3
|
+
"version": "2.1.2",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"ampf-react",
|
|
6
|
+
"ampf-utils",
|
|
7
|
+
"siam-ui-utils"
|
|
8
|
+
],
|
|
9
|
+
"type": "module",
|
|
10
|
+
"author": "Ampf Development Team",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"description": "Conjunto de librerias de componentes utiles para AMPF",
|
|
13
|
+
"main": "src/index.js",
|
|
14
|
+
"browser": "src/index.js",
|
|
15
|
+
"types": "index",
|
|
16
|
+
"homepage": "https://github.com/ampfgit/siam-ui-utils#readme",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/ampfgit/siam-ui-utils"
|
|
20
|
+
},
|
|
21
|
+
"moduleResolution": "nodenext",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"start": "vite",
|
|
24
|
+
"publish-npm": "npm publish",
|
|
25
|
+
"storybook": "storybook dev -p 6006",
|
|
26
|
+
"build-storybook": "storybook build"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@storybook/cli": "^8.3.2",
|
|
30
|
+
"@types/react-intl": "^3.0.0",
|
|
31
|
+
"eslint-plugin-react-hooks": "^4.6.2",
|
|
32
|
+
"eslint-plugin-react-refresh": "^0.4.12",
|
|
33
|
+
"html5-file-selector": "^2.1.0",
|
|
34
|
+
"init": "^0.1.2",
|
|
35
|
+
"prop-types": "^15.8.1",
|
|
36
|
+
"react": "^18.3.1",
|
|
37
|
+
"react-dropzone-uploader": "^2.11.0",
|
|
38
|
+
"react-intl": "^6.4.2",
|
|
39
|
+
"react-notifications": "^1.7.4",
|
|
40
|
+
"react-router": "^6.26.2",
|
|
41
|
+
"react-router-dom": "^6.26.2",
|
|
42
|
+
"react-select": "^5.8.0",
|
|
43
|
+
"reactstrap": "^9.2.2",
|
|
44
|
+
"siam-utils": "^1.1.4",
|
|
45
|
+
"source-map-loader": "^5.0.0",
|
|
46
|
+
"styled-components": "^6.1.12",
|
|
47
|
+
"typescript": "^5.5.4",
|
|
48
|
+
"vite-plugin-commonjs": "^0.10.3"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@chromatic-com/storybook": "^1.9.0",
|
|
52
|
+
"@storybook/addon-essentials": "^8.3.2",
|
|
53
|
+
"@storybook/addon-interactions": "^8.3.2",
|
|
54
|
+
"@storybook/addon-links": "^8.3.2",
|
|
55
|
+
"@storybook/addon-onboarding": "^8.3.2",
|
|
56
|
+
"@storybook/blocks": "^8.3.2",
|
|
57
|
+
"@storybook/react": "^8.3.2",
|
|
58
|
+
"@storybook/react-vite": "^8.3.2",
|
|
59
|
+
"@storybook/test": "^8.3.2",
|
|
60
|
+
"@testing-library/dom": "^10.4.0",
|
|
61
|
+
"@testing-library/jest-dom": "^6.4.8",
|
|
62
|
+
"@testing-library/react": "^16.0.0",
|
|
63
|
+
"@types/react-router-dom": "^5.3.3",
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
65
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
66
|
+
"@vitejs/plugin-react": "^4.3.1",
|
|
67
|
+
"copyfiles": "^2.4.1",
|
|
68
|
+
"eslint": "^8.57.1",
|
|
69
|
+
"eslint-config-airbnb": "^19.0.4",
|
|
70
|
+
"eslint-config-prettier": "^8.8.0",
|
|
71
|
+
"eslint-config-react-app": "^7.0.1",
|
|
72
|
+
"eslint-plugin-import": "^2.27.5",
|
|
73
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
74
|
+
"eslint-plugin-prettier": "^5.0.0-alpha.1",
|
|
75
|
+
"eslint-plugin-react": "^7.33.0",
|
|
76
|
+
"eslint-plugin-storybook": "^0.8.0",
|
|
77
|
+
"storybook": "^8.3.2",
|
|
78
|
+
"vite": "^5.3.4",
|
|
79
|
+
"vite-plugin-eslint": "^1.1.0",
|
|
80
|
+
"vitest": "^2.0.5"
|
|
81
|
+
},
|
|
82
|
+
"eslintConfig": {
|
|
83
|
+
"extends": [
|
|
84
|
+
"plugin:storybook/recommended"
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
}
|
package/src/bridges/index.jsx
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useNavigate } from 'react-router';
|
|
3
3
|
|
|
4
|
-
const withRouter = (Component) => {
|
|
4
|
+
export const withRouter = (Component) => {
|
|
5
5
|
const Wrapper = (props) => {
|
|
6
6
|
const history = useNavigate();
|
|
7
7
|
return <Component history={history} {...props} />;
|
|
8
8
|
};
|
|
9
9
|
return Wrapper;
|
|
10
10
|
};
|
|
11
|
-
|
|
12
|
-
export default withRouter;
|
|
@@ -2,31 +2,33 @@ import type { Meta, StoryObj } from '@storybook/react';
|
|
|
2
2
|
|
|
3
3
|
import { DropzoneUploader } from '.';
|
|
4
4
|
|
|
5
|
-
const args={
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const args = {
|
|
6
|
+
onChangeFiles: () => {
|
|
7
|
+
console.log('Accion despues de seleccionar un archivo');
|
|
8
|
+
},
|
|
9
|
+
totalFiles: 0,
|
|
10
|
+
maxFiles: 3,
|
|
11
|
+
accept: 'image/*, application/pdf',
|
|
12
|
+
capture: null,
|
|
13
|
+
nameFileLabel: 'Subir archivos',
|
|
14
|
+
maxFileSize: 2,
|
|
15
|
+
};
|
|
14
16
|
|
|
15
17
|
const meta = {
|
|
16
18
|
title: 'Components/DropzoneUploader',
|
|
17
19
|
component: DropzoneUploader,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
args: {
|
|
21
|
+
...args,
|
|
22
|
+
},
|
|
21
23
|
} satisfies Meta<typeof DropzoneUploader>;
|
|
22
24
|
|
|
23
25
|
export default meta;
|
|
26
|
+
|
|
24
27
|
type Story = StoryObj<typeof meta>;
|
|
25
28
|
|
|
26
29
|
export const DropzoneUploaderBasic: Story = {
|
|
27
30
|
args: {
|
|
28
31
|
...args,
|
|
29
|
-
maxFileSize:
|
|
30
|
-
|
|
32
|
+
maxFileSize: 5,
|
|
33
|
+
},
|
|
31
34
|
};
|
|
32
|
-
|
|
@@ -1,138 +1,150 @@
|
|
|
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
|
|
8
|
-
import { pdfImage } from '../constants-svg'
|
|
9
|
-
import
|
|
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 from '../iconos/icon-button-svg';
|
|
8
|
+
import { pdfImage } from '../constants-svg';
|
|
9
|
+
import './dropzone-uploader.css';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
console.log('dropzone1 :>> ');
|
|
12
|
+
|
|
13
|
+
const maxSize = 7; //en MB
|
|
12
14
|
export const DropzoneUploader = ({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
onChangeFiles,
|
|
16
|
+
totalFiles,
|
|
17
|
+
maxFiles = 3,
|
|
18
|
+
accept = 'image/*, application/pdf',
|
|
19
|
+
capture = null,
|
|
20
|
+
nameFileLabel = 'Subir archivos',
|
|
21
|
+
maxFileSize = maxSize,
|
|
20
22
|
}) => {
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
23
|
+
console.log('dropzone2 :>> ');
|
|
24
|
+
|
|
25
|
+
const [files, setFiles] = useState([]);
|
|
26
|
+
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
|
+
|
|
48
|
+
return new Promise((resolve) => {
|
|
49
|
+
getDroppedOrSelectedFiles(e).then((chosenFiles) => {
|
|
50
|
+
resolve(chosenFiles.map((f) => f.fileObject));
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
const CustomPreview = ({ fileWithMeta }) => {
|
|
55
|
+
console.log('dropzone4 :>> ');
|
|
56
|
+
|
|
57
|
+
const { meta, remove } = fileWithMeta;
|
|
58
|
+
if (meta.size / (1024 * 1024) > maxFileSize) {
|
|
59
|
+
NotificationManager.error(
|
|
60
|
+
'El archivo supera el tamaño máximo',
|
|
61
|
+
'Advertencia',
|
|
62
|
+
);
|
|
63
|
+
remove();
|
|
64
|
+
}
|
|
65
|
+
return (
|
|
66
|
+
<div className="dropzone-upload-previewContainer">
|
|
67
|
+
{meta.type === 'application/pdf' ? (
|
|
68
|
+
<>
|
|
69
|
+
<IconButtonSvg
|
|
70
|
+
className="form-control flex"
|
|
71
|
+
svg={pdfImage}
|
|
72
|
+
svgOver={pdfImage}
|
|
73
|
+
height="1.6rem"
|
|
74
|
+
width="1.6rem"
|
|
75
|
+
title={meta.name}
|
|
76
|
+
/>
|
|
77
|
+
<p>
|
|
78
|
+
{meta.name.length > 17
|
|
79
|
+
? meta.name.substring(0, 17) + '...'
|
|
80
|
+
: meta.name}
|
|
81
|
+
</p>
|
|
82
|
+
</>
|
|
83
|
+
) : (
|
|
84
|
+
<>
|
|
85
|
+
<img
|
|
86
|
+
className="dropzone-upload-previewImage"
|
|
87
|
+
src={meta.previewUrl}
|
|
88
|
+
alt={meta.name}
|
|
89
|
+
/>
|
|
90
|
+
<p>
|
|
91
|
+
{meta.name.length > 17
|
|
92
|
+
? meta.name.substring(0, 17) + '...'
|
|
93
|
+
: meta.name}
|
|
94
|
+
</p>
|
|
95
|
+
</>
|
|
96
|
+
)}
|
|
97
|
+
<p>{(meta.size / 1024).toFixed(2)} .Kb</p>
|
|
98
|
+
<button
|
|
99
|
+
onClick={remove}
|
|
100
|
+
className="dropzone-upload-delete-btn simple-icon-trash"
|
|
101
|
+
></button>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
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
|
+
);
|
|
130
|
+
};
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
setTotalFilesDU(totalFiles);
|
|
133
|
+
}, [totalFiles]);
|
|
97
134
|
|
|
98
|
-
|
|
99
|
-
const text =
|
|
100
|
-
totalFilesDU > 0
|
|
101
|
-
? `${maxFiles - totalFilesDU} archivo/s más`
|
|
102
|
-
: nameFileLabel
|
|
103
|
-
return (
|
|
104
|
-
<label className='dropzone-upload-button'>
|
|
105
|
-
{text}
|
|
106
|
-
<input
|
|
107
|
-
style={{ display: 'none' }}
|
|
108
|
-
type='file'
|
|
109
|
-
accept={accept}
|
|
110
|
-
capture={capture}
|
|
111
|
-
multiple
|
|
112
|
-
onChange={(e) => {
|
|
113
|
-
getFilesFromEvent(e).then((chosenFiles) => {
|
|
114
|
-
onFiles(chosenFiles)
|
|
115
|
-
})
|
|
116
|
-
}}
|
|
117
|
-
/>
|
|
118
|
-
</label>
|
|
119
|
-
)
|
|
120
|
-
}
|
|
121
|
-
useEffect(() => {
|
|
122
|
-
setTotalFilesDU(totalFiles)
|
|
123
|
-
}, [totalFiles])
|
|
135
|
+
console.log('dropzone5 :>> ');
|
|
124
136
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
137
|
+
return (
|
|
138
|
+
<Dropzone
|
|
139
|
+
disableUpload={false}
|
|
140
|
+
maxFiles={totalFilesDU < maxFiles ? maxFiles : 0}
|
|
141
|
+
maxSize={maxFileSize} // 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
|
+
);
|
|
150
|
+
};
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from './dropzone-uploader'
|
|
2
|
-
export * from './bridges'
|
|
3
|
-
export * from './CustomBootstrap'
|
|
4
|
-
export * from './CustomSelectInput'
|
|
5
|
-
export * from
|
|
6
|
-
export * from './
|
|
7
|
-
export * 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';
|
package/vite.config.ts
CHANGED
|
@@ -3,12 +3,8 @@ import { defineConfig } from "vitest/config";
|
|
|
3
3
|
import eslint from 'vite-plugin-eslint';
|
|
4
4
|
|
|
5
5
|
export default defineConfig({
|
|
6
|
-
plugins: [react()
|
|
6
|
+
plugins: [react()],
|
|
7
7
|
test: {
|
|
8
8
|
globals: true,
|
|
9
|
-
}
|
|
10
|
-
server: {
|
|
11
|
-
port: 3002,
|
|
12
|
-
open: true,
|
|
13
|
-
},
|
|
9
|
+
}
|
|
14
10
|
});
|