siam-ui-utils 2.2.26 → 2.2.28

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.
Files changed (138) hide show
  1. package/dist/CustomBootstrap.js +9 -0
  2. package/dist/CustomBootstrap.js.map +1 -0
  3. package/dist/CustomSelectInput.js +12 -0
  4. package/dist/CustomSelectInput.js.map +1 -0
  5. package/dist/IntlMessages.js +10 -0
  6. package/dist/IntlMessages.js.map +1 -0
  7. package/dist/assets/img/copiar.png.js +5 -0
  8. package/dist/assets/img/copiar.png.js.map +1 -0
  9. package/dist/assets/img/take-photo.png.js +5 -0
  10. package/dist/assets/img/take-photo.png.js.map +1 -0
  11. package/dist/bridges/with-router-bridge.js +14 -0
  12. package/dist/bridges/with-router-bridge.js.map +1 -0
  13. package/dist/constants.js +9 -0
  14. package/dist/constants.js.map +1 -0
  15. package/dist/copy-link/index.js +60 -0
  16. package/dist/copy-link/index.js.map +1 -0
  17. package/dist/custom-input/CustomInputCheckbox.js +36 -0
  18. package/dist/custom-input/CustomInputCheckbox.js.map +1 -0
  19. package/dist/custom-input/CustomInputRadio.js +43 -0
  20. package/dist/custom-input/CustomInputRadio.js.map +1 -0
  21. package/dist/dropzone/Dropzone.js +513 -0
  22. package/dist/dropzone/Dropzone.js.map +1 -0
  23. package/{src/dropzone/Input.tsx → dist/dropzone/Input.js} +77 -76
  24. package/dist/dropzone/Input.js.map +1 -0
  25. package/{src/dropzone/Layout.tsx → dist/dropzone/Layout.js} +50 -57
  26. package/dist/dropzone/Layout.js.map +1 -0
  27. package/dist/dropzone/Preview.js +117 -0
  28. package/dist/dropzone/Preview.js.map +1 -0
  29. package/dist/dropzone/SubmitButton.js +34 -0
  30. package/dist/dropzone/SubmitButton.js.map +1 -0
  31. package/dist/dropzone/assets/cancel.svg.js +5 -0
  32. package/dist/dropzone/assets/cancel.svg.js.map +1 -0
  33. package/dist/dropzone/assets/remove.svg.js +5 -0
  34. package/dist/dropzone/assets/remove.svg.js.map +1 -0
  35. package/dist/dropzone/assets/restart.svg.js +5 -0
  36. package/dist/dropzone/assets/restart.svg.js.map +1 -0
  37. package/dist/dropzone/utils.js +85 -0
  38. package/dist/dropzone/utils.js.map +1 -0
  39. package/dist/dropzone-uploader/dropzone-uploader-dni-digital/index.js +150 -0
  40. package/dist/dropzone-uploader/dropzone-uploader-dni-digital/index.js.map +1 -0
  41. package/dist/dropzone-uploader/index.js +136 -0
  42. package/dist/dropzone-uploader/index.js.map +1 -0
  43. package/dist/iconos/constants-svg.js +41 -0
  44. package/dist/iconos/constants-svg.js.map +1 -0
  45. package/dist/iconos/icon-button-svg.js +50 -0
  46. package/dist/iconos/icon-button-svg.js.map +1 -0
  47. package/dist/iconos/styled-icon.js +26 -0
  48. package/dist/iconos/styled-icon.js.map +1 -0
  49. package/dist/index.js +33 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/select/constants.js +8 -0
  52. package/dist/select/constants.js.map +1 -0
  53. package/dist/select/index.js +90 -0
  54. package/dist/select/index.js.map +1 -0
  55. package/dist/timer/index.js +60 -0
  56. package/dist/timer/index.js.map +1 -0
  57. package/dist/tomar-foto/index.js +77 -0
  58. package/dist/tomar-foto/index.js.map +1 -0
  59. package/dist/view-layout/button-editor.js +14 -0
  60. package/dist/view-layout/button-editor.js.map +1 -0
  61. package/dist/view-layout/constants.js +11 -0
  62. package/dist/view-layout/constants.js.map +1 -0
  63. package/dist/view-layout/editor-layer.js +28 -0
  64. package/dist/view-layout/editor-layer.js.map +1 -0
  65. package/dist/view-layout/index.js +53 -0
  66. package/dist/view-layout/index.js.map +1 -0
  67. package/dist/view-layout/slot-wrapper.js +39 -0
  68. package/dist/view-layout/slot-wrapper.js.map +1 -0
  69. package/dist/where-by-room/index.js +20 -0
  70. package/dist/where-by-room/index.js.map +1 -0
  71. package/dist/where-by-room/room.js +78 -0
  72. package/dist/where-by-room/room.js.map +1 -0
  73. package/package.json +65 -17
  74. package/dist/index.cjs.js +0 -262
  75. package/dist/index.es.js +0 -43503
  76. package/dist/siam-ui-utils.css +0 -1
  77. package/eslint.config.mjs +0 -45
  78. package/index.html +0 -17
  79. package/src/App.css +0 -47
  80. package/src/App.jsx +0 -66
  81. package/src/CustomBootstrap.jsx +0 -10
  82. package/src/CustomSelectInput.jsx +0 -8
  83. package/src/IntlMessages.jsx +0 -7
  84. package/src/assets/css/sass/_gogo.style.scss +0 -8967
  85. package/src/assets/css/sass/_mixins.scss +0 -125
  86. package/src/assets/css/sass/_plugins.scss +0 -1
  87. package/src/assets/css/sass/ampf_style.scss +0 -185
  88. package/src/assets/css/sass/main.scss +0 -11
  89. package/src/assets/css/sass/plugins/react-table.scss +0 -314
  90. package/src/assets/css/sass/themes/gogo.light.redruby.scss +0 -41
  91. package/src/assets/css/sass/themes/variables.scss +0 -86
  92. package/src/assets/css/vendor/bootstrap.min.css +0 -6
  93. package/src/assets/css/vendor/bootstrap.rtl.only.min.css +0 -1428
  94. package/src/assets/img/copiar.png +0 -0
  95. package/src/assets/img/take-photo.png +0 -0
  96. package/src/constants.js +0 -7
  97. package/src/copy-link/index.jsx +0 -58
  98. package/src/copy-link/styles.scss +0 -39
  99. package/src/custom-input/CustomInputCheckbox.jsx +0 -33
  100. package/src/custom-input/CustomInputRadio.jsx +0 -37
  101. package/src/custom-input/index.css +0 -168
  102. package/src/custom-input/index.js +0 -2
  103. package/src/dropzone/Dropzone.tsx +0 -816
  104. package/src/dropzone/Preview.tsx +0 -139
  105. package/src/dropzone/SubmitButton.tsx +0 -47
  106. package/src/dropzone/assets/cancel.svg +0 -1
  107. package/src/dropzone/assets/remove.svg +0 -1
  108. package/src/dropzone/assets/restart.svg +0 -1
  109. package/src/dropzone/styles.css +0 -140
  110. package/src/dropzone/utils.ts +0 -113
  111. package/src/dropzone-uploader/dropzone-uploader-dni-digital/index.jsx +0 -151
  112. package/src/dropzone-uploader/dropzone-uploader.css +0 -66
  113. package/src/dropzone-uploader/index.jsx +0 -138
  114. package/src/iconos/constants-svg.js +0 -659
  115. package/src/iconos/icon-button-svg.jsx +0 -50
  116. package/src/iconos/index.js +0 -2
  117. package/src/iconos/styled-icon.jsx +0 -25
  118. package/src/index.css +0 -74
  119. package/src/index.js +0 -12
  120. package/src/main.jsx +0 -7
  121. package/src/select/constants.js +0 -4
  122. package/src/select/index.tsx +0 -147
  123. package/src/test-resources.jsx +0 -145
  124. package/src/timer/index.jsx +0 -62
  125. package/src/timer/styles.scss +0 -54
  126. package/src/tomar-foto/index.jsx +0 -69
  127. package/src/view-layout/button-editor.jsx +0 -18
  128. package/src/view-layout/constants.js +0 -7
  129. package/src/view-layout/editor-layer.jsx +0 -27
  130. package/src/view-layout/index.tsx +0 -62
  131. package/src/view-layout/item-slot.tsx +0 -20
  132. package/src/view-layout/slot-wrapper.tsx +0 -44
  133. package/src/view-layout/styles.scss +0 -143
  134. package/src/where-by-room/constants.js +0 -2
  135. package/src/where-by-room/index.jsx +0 -17
  136. package/src/where-by-room/room.jsx +0 -79
  137. package/tsconfig.json +0 -19
  138. package/vite.config.ts +0 -32
@@ -1,139 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
-
4
- import { formatBytes, formatDuration } from './utils'
5
- import { IPreviewProps } from './Dropzone'
6
- //@ts-ignore
7
- import cancelImg from './assets/cancel.svg'
8
- //@ts-ignore
9
- import removeImg from './assets/remove.svg'
10
- //@ts-ignore
11
- import restartImg from './assets/restart.svg'
12
-
13
- const iconByFn = {
14
- cancel: { backgroundImage: `url(${cancelImg})` },
15
- remove: { backgroundImage: `url(${removeImg})` },
16
- restart: { backgroundImage: `url(${restartImg})` },
17
- }
18
-
19
- class Preview extends React.PureComponent<IPreviewProps> {
20
- render() {
21
- const {
22
- className,
23
- imageClassName,
24
- style,
25
- imageStyle,
26
- fileWithMeta: { cancel, remove, restart },
27
- meta: { name = '', percent = 0, size = 0, previewUrl, status, duration, validationError },
28
- isUpload,
29
- canCancel,
30
- canRemove,
31
- canRestart,
32
- extra: { minSizeBytes },
33
- } = this.props
34
-
35
- let title = `${name || '?'}, ${formatBytes(size)}`
36
- if (duration) title = `${title}, ${formatDuration(duration)}`
37
-
38
- if (status === 'error_file_size' || status === 'error_validation') {
39
- return (
40
- <div className={className} style={style}>
41
- <span className="dzu-previewFileNameError">{title}</span>
42
- {status === 'error_file_size' && <span>{size < minSizeBytes ? 'File too small' : 'File too big'}</span>}
43
- {status === 'error_validation' && <span>{String(validationError)}</span>}
44
- {canRemove && <span className="dzu-previewButton" style={iconByFn.remove} onClick={remove} />}
45
- </div>
46
- )
47
- }
48
-
49
- if (status === 'error_upload_params' || status === 'exception_upload' || status === 'error_upload') {
50
- title = `${title} (upload failed)`
51
- }
52
- if (status === 'aborted') title = `${title} (cancelled)`
53
-
54
- return (
55
- <div className={className} style={style}>
56
- {previewUrl && <img className={imageClassName} style={imageStyle} src={previewUrl} alt={title} title={title} />}
57
- {!previewUrl && <span className="dzu-previewFileName">{title}</span>}
58
-
59
- <div className="dzu-previewStatusContainer">
60
- {isUpload && (
61
- <progress max={100} value={status === 'done' || status === 'headers_received' ? 100 : percent} />
62
- )}
63
-
64
- {status === 'uploading' && canCancel && (
65
- <span className="dzu-previewButton" style={iconByFn.cancel} onClick={cancel} />
66
- )}
67
- {status !== 'preparing' && status !== 'getting_upload_params' && status !== 'uploading' && canRemove && (
68
- <span className="dzu-previewButton" style={iconByFn.remove} onClick={remove} />
69
- )}
70
- {['error_upload_params', 'exception_upload', 'error_upload', 'aborted', 'ready'].includes(status) &&
71
- canRestart && <span className="dzu-previewButton" style={iconByFn.restart} onClick={restart} />}
72
- </div>
73
- </div>
74
- )
75
- }
76
- }
77
-
78
- // @ts-ignore
79
- Preview.propTypes = {
80
- className: PropTypes.string,
81
- imageClassName: PropTypes.string,
82
- style: PropTypes.object,
83
- imageStyle: PropTypes.object,
84
- fileWithMeta: PropTypes.shape({
85
- file: PropTypes.any.isRequired,
86
- meta: PropTypes.object.isRequired,
87
- cancel: PropTypes.func.isRequired,
88
- restart: PropTypes.func.isRequired,
89
- remove: PropTypes.func.isRequired,
90
- xhr: PropTypes.any,
91
- }).isRequired,
92
- // copy of fileWithMeta.meta, won't be mutated
93
- meta: PropTypes.shape({
94
- status: PropTypes.oneOf([
95
- 'preparing',
96
- 'error_file_size',
97
- 'error_validation',
98
- 'ready',
99
- 'getting_upload_params',
100
- 'error_upload_params',
101
- 'uploading',
102
- 'exception_upload',
103
- 'aborted',
104
- 'error_upload',
105
- 'headers_received',
106
- 'done',
107
- ]).isRequired,
108
- type: PropTypes.string.isRequired,
109
- name: PropTypes.string,
110
- uploadedDate: PropTypes.string.isRequired,
111
- percent: PropTypes.number,
112
- size: PropTypes.number,
113
- lastModifiedDate: PropTypes.string,
114
- previewUrl: PropTypes.string,
115
- duration: PropTypes.number,
116
- width: PropTypes.number,
117
- height: PropTypes.number,
118
- videoWidth: PropTypes.number,
119
- videoHeight: PropTypes.number,
120
- validationError: PropTypes.any,
121
- }).isRequired,
122
- isUpload: PropTypes.bool.isRequired,
123
- canCancel: PropTypes.bool.isRequired,
124
- canRemove: PropTypes.bool.isRequired,
125
- canRestart: PropTypes.bool.isRequired,
126
- files: PropTypes.arrayOf(PropTypes.any).isRequired, // eslint-disable-line react/no-unused-prop-types
127
- extra: PropTypes.shape({
128
- active: PropTypes.bool.isRequired,
129
- reject: PropTypes.bool.isRequired,
130
- dragged: PropTypes.arrayOf(PropTypes.any).isRequired,
131
- accept: PropTypes.string.isRequired,
132
- multiple: PropTypes.bool.isRequired,
133
- minSizeBytes: PropTypes.number.isRequired,
134
- maxSizeBytes: PropTypes.number.isRequired,
135
- maxFiles: PropTypes.number.isRequired,
136
- }).isRequired,
137
- }
138
-
139
- export default Preview
@@ -1,47 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
-
4
- import { ISubmitButtonProps } from './Dropzone'
5
-
6
- const SubmitButton = (props: ISubmitButtonProps) => {
7
- const { className, buttonClassName, style, buttonStyle, disabled, content, onSubmit, files } = props
8
-
9
- const _disabled =
10
- files.some(f => ['preparing', 'getting_upload_params', 'uploading'].includes(f.meta.status)) ||
11
- !files.some(f => ['headers_received', 'done'].includes(f.meta.status))
12
-
13
- const handleSubmit = () => {
14
- onSubmit(files.filter(f => ['headers_received', 'done'].includes(f.meta.status)))
15
- }
16
-
17
- return (
18
- <div className={className} style={style}>
19
- <button className={buttonClassName} style={buttonStyle} onClick={handleSubmit} disabled={disabled || _disabled}>
20
- {content}
21
- </button>
22
- </div>
23
- )
24
- }
25
-
26
- SubmitButton.propTypes = {
27
- className: PropTypes.string,
28
- buttonClassName: PropTypes.string,
29
- style: PropTypes.object,
30
- buttonStyle: PropTypes.object,
31
- disabled: PropTypes.bool.isRequired,
32
- content: PropTypes.node,
33
- onSubmit: PropTypes.func.isRequired,
34
- files: PropTypes.arrayOf(PropTypes.object).isRequired,
35
- extra: PropTypes.shape({
36
- active: PropTypes.bool.isRequired,
37
- reject: PropTypes.bool.isRequired,
38
- dragged: PropTypes.arrayOf(PropTypes.any).isRequired,
39
- accept: PropTypes.string.isRequired,
40
- multiple: PropTypes.bool.isRequired,
41
- minSizeBytes: PropTypes.number.isRequired,
42
- maxSizeBytes: PropTypes.number.isRequired,
43
- maxFiles: PropTypes.number.isRequired,
44
- }).isRequired,
45
- }
46
-
47
- export default SubmitButton
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 8 14" xmlns="http://www.w3.org/2000/svg"><g fill="#333333"><path d="M1,14 C0.4,14 0,13.6 0,13 L0,1 C0,0.4 0.4,0 1,0 C1.6,0 2,0.4 2,1 L2,13 C2,13.6 1.6,14 1,14 Z" id="Path"></path><path d="M7,14 C6.4,14 6,13.6 6,13 L6,1 C6,0.4 6.4,0 7,0 C7.6,0 8,0.4 8,1 L8,13 C8,13.6 7.6,14 7,14 Z" id="Path"></path></g></svg>
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"><g transform="translate(-5.0, 0.0)" fill="#333333"><g transform="translate(4.0, 0.0)"><polygon points="7.719 4.964 12.692 0.017 14.389 1.715 9.412 6.666 14.354 11.634 12.657 13.331 6.017 6.657 7.715 4.960"></polygon><polygon points="7.612 4.964 7.616 4.960 9.313 6.657 2.674 13.331 0.977 11.634 5.919 6.666 0.942 1.715 2.639 0.017"></polygon></g></g></svg>
@@ -1 +0,0 @@
1
- <svg viewBox="0 0 11 15" xmlns="http://www.w3.org/2000/svg"><g><path d="M0.5,14.9 C0.2,14.7 0,14.4 0,14 L0,2 C0,1.6 0.2,1.3 0.5,1.1 C0.8,0.9 1.2,0.9 1.5,1.1 L10.5,7.1 C10.8,7.3 10.9,7.6 10.9,7.9 C10.9,8.2 10.7,8.5 10.5,8.7 L1.5,14.7 C1.4,14.9 0.8,15.1 0.5,14.9 Z M2,3.9 L2,12.2 L8.2,8.1 L2,3.9 Z"></path></g></svg>
@@ -1,140 +0,0 @@
1
- .dzu-dropzone {
2
- display: flex;
3
- flex-direction: column;
4
- align-items: center;
5
- width: 100%;
6
- min-height: 120px;
7
- overflow: scroll;
8
- margin: 0 auto;
9
- position: relative;
10
- box-sizing: border-box;
11
- transition: all .15s linear;
12
- border: 2px solid #d9d9d9;
13
- border-radius: 4px;
14
- }
15
-
16
- .dzu-dropzoneActive {
17
- background-color: #DEEBFF;
18
- border-color: #2484FF;
19
- }
20
-
21
- .dzu-dropzoneDisabled {
22
- opacity: 0.5;
23
- }
24
-
25
- .dzu-dropzoneDisabled *:hover {
26
- cursor: unset;
27
- }
28
-
29
- .dzu-input {
30
- display: none;
31
- }
32
-
33
- .dzu-inputLabel {
34
- display: flex;
35
- justify-content: center;
36
- align-items: center;
37
- position: absolute;
38
- top: 0;
39
- bottom: 0;
40
- left: 0;
41
- right: 0;
42
- font-family: 'Helvetica', sans-serif;
43
- font-size: 20px;
44
- font-weight: 600;
45
- color: #2484FF;
46
- -moz-osx-font-smoothing: grayscale;
47
- -webkit-font-smoothing: antialiased;
48
- cursor: pointer;
49
- }
50
-
51
- .dzu-inputLabelWithFiles {
52
- display: flex;
53
- justify-content: center;
54
- align-items: center;
55
- align-self: flex-start;
56
- padding: 0 14px;
57
- min-height: 32px;
58
- background-color: #E6E6E6;
59
- color: #2484FF;
60
- border: none;
61
- font-family: 'Helvetica', sans-serif;
62
- border-radius: 4px;
63
- font-size: 14px;
64
- font-weight: 600;
65
- margin-top: 20px;
66
- margin-left: 3%;
67
- -moz-osx-font-smoothing: grayscale;
68
- -webkit-font-smoothing: antialiased;
69
- cursor: pointer;
70
- }
71
-
72
- .dzu-previewContainer {
73
- padding: 40px 3%;
74
- display: flex;
75
- flex-direction: row;
76
- align-items: center;
77
- justify-content: space-between;
78
- position: relative;
79
- width: 100%;
80
- min-height: 60px;
81
- z-index: 1;
82
- border-bottom: 1px solid #ECECEC;
83
- box-sizing: border-box;
84
- }
85
-
86
- .dzu-previewStatusContainer {
87
- display: flex;
88
- align-items: center;
89
- }
90
-
91
- .dzu-previewFileName {
92
- font-family: 'Helvetica', sans-serif;
93
- font-size: 14px;
94
- font-weight: 400;
95
- color: #333333;
96
- }
97
-
98
- .dzu-previewImage {
99
- width: auto;
100
- max-height: 40px;
101
- max-width: 140px;
102
- border-radius: 4px;
103
- }
104
-
105
- .dzu-previewButton {
106
- background-size: 14px 14px;
107
- background-position: center;
108
- background-repeat: no-repeat;
109
- width: 14px;
110
- height: 14px;
111
- cursor: pointer;
112
- opacity: 0.9;
113
- margin: 0 0 2px 10px;
114
- }
115
-
116
- .dzu-submitButtonContainer {
117
- margin: 24px 0;
118
- z-index: 1;
119
- }
120
-
121
- .dzu-submitButton {
122
- padding: 0 14px;
123
- min-height: 32px;
124
- background-color: #2484FF;
125
- border: none;
126
- border-radius: 4px;
127
- font-family: 'Helvetica', sans-serif;
128
- font-size: 14px;
129
- font-weight: 600;
130
- color: #FFF;
131
- -moz-osx-font-smoothing: grayscale;
132
- -webkit-font-smoothing: antialiased;
133
- cursor: pointer;
134
- }
135
-
136
- .dzu-submitButton:disabled {
137
- background-color: #E6E6E6;
138
- color: #333333;
139
- cursor: unset;
140
- }
@@ -1,113 +0,0 @@
1
- import React from 'react'
2
- import { IStyleCustomization } from './Dropzone'
3
-
4
- export const formatBytes = (b: number) => {
5
- const units = ['bytes', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
6
- let l = 0
7
- let n = b
8
-
9
- while (n >= 1024) {
10
- n /= 1024
11
- l += 1
12
- }
13
-
14
- return `${n.toFixed(n >= 10 || l < 1 ? 0 : 1)}${units[l]}`
15
- }
16
-
17
- export const formatDuration = (seconds: number) => {
18
- const date = new Date(0)
19
- date.setSeconds(seconds)
20
- const dateString = date.toISOString().slice(11, 19)
21
- if (seconds < 3600) return dateString.slice(3)
22
- return dateString
23
- }
24
-
25
- // adapted from: https://github.com/okonet/attr-accept/blob/master/src/index.js
26
- // returns true if file.name is empty and accept string is something like ".csv",
27
- // because file comes from dataTransferItem for drag events, and
28
- // dataTransferItem.name is always empty
29
- export const accepts = (file: File, accept: string) => {
30
- if (!accept || accept === '*') return true
31
-
32
- const mimeType = file.type || ''
33
- const baseMimeType = mimeType.replace(/\/.*$/, '')
34
-
35
- return accept
36
- .split(',')
37
- .map(t => t.trim())
38
- .some(type => {
39
- if (type.charAt(0) === '.') {
40
- return file.name === undefined || file.name.toLowerCase().endsWith(type.toLowerCase())
41
- } else if (type.endsWith('/*')) {
42
- // this is something like an image/* mime type
43
- return baseMimeType === type.replace(/\/.*$/, '')
44
- }
45
- return mimeType === type
46
- })
47
- }
48
-
49
- type ResolveFn<T> = (...args: any[]) => T
50
-
51
- export const resolveValue = <T = any>(value: ResolveFn<T> | T, ...args: any[]) => {
52
- if (typeof value === 'function') return (value as ResolveFn<T>)(...args)
53
- return value
54
- }
55
-
56
- export const defaultClassNames = {
57
- dropzone: 'dzu-dropzone',
58
- dropzoneActive: 'dzu-dropzoneActive',
59
- dropzoneReject: 'dzu-dropzoneActive',
60
- dropzoneDisabled: 'dzu-dropzoneDisabled',
61
- input: 'dzu-input',
62
- inputLabel: 'dzu-inputLabel',
63
- inputLabelWithFiles: 'dzu-inputLabelWithFiles',
64
- preview: 'dzu-previewContainer',
65
- previewImage: 'dzu-previewImage',
66
- submitButtonContainer: 'dzu-submitButtonContainer',
67
- submitButton: 'dzu-submitButton',
68
- }
69
-
70
- export const mergeStyles = (
71
- classNames: IStyleCustomization<string>,
72
- styles: IStyleCustomization<React.CSSProperties>,
73
- addClassNames: IStyleCustomization<string>,
74
- ...args: any[]
75
- ) => {
76
- const resolvedClassNames: { [property: string]: string } = { ...defaultClassNames }
77
- const resolvedStyles = { ...styles } as { [property: string]: string }
78
-
79
- for (const [key, value] of Object.entries(classNames)) {
80
- resolvedClassNames[key] = resolveValue(value, ...args)
81
- }
82
-
83
- for (const [key, value] of Object.entries(addClassNames)) {
84
- resolvedClassNames[key] = `${resolvedClassNames[key]} ${resolveValue(value, ...args)}`
85
- }
86
-
87
- for (const [key, value] of Object.entries(styles)) {
88
- resolvedStyles[key] = resolveValue(value, ...args)
89
- }
90
-
91
- return { classNames: resolvedClassNames, styles: resolvedStyles as IStyleCustomization<React.CSSProperties> }
92
- }
93
-
94
- export const getFilesFromEvent = (
95
- event: React.DragEvent<HTMLElement> | React.ChangeEvent<HTMLInputElement>,
96
- ): Array<File | DataTransferItem> => {
97
- let items = null
98
-
99
- if ('dataTransfer' in event) {
100
- const dt = event.dataTransfer
101
-
102
- // NOTE: Only the 'drop' event has access to DataTransfer.files, otherwise it will always be empty
103
- if ('files' in dt && dt.files.length) {
104
- items = dt.files
105
- } else if (dt.items && dt.items.length) {
106
- items = dt.items
107
- }
108
- } else if (event.target && event.target.files) {
109
- items = event.target.files
110
- }
111
-
112
- return Array.prototype.slice.call(items)
113
- }
@@ -1,151 +0,0 @@
1
- import { getDroppedOrSelectedFiles } from 'html5-file-selector';
2
- import { useState } from 'react';
3
- import { Button } from 'reactstrap';
4
- import Dropzone from '../../dropzone/Dropzone';
5
- import '../../dropzone/styles.css';
6
- import { IconButtonSvg, pdfImage } from '../../iconos';
7
- import '../dropzone-uploader.css';
8
-
9
- export const DropzoneUploaderDniDigital = ({
10
- accept = 'image/*, application/pdf',
11
- classNames = '',
12
- onChangeFiles,
13
- totalFiles,
14
- label = 'Cargar Dni',
15
- maxFiles = 2,
16
- maxSize = 2,
17
- onMaxFileSizeError = () => {
18
- alert('El archivo supera el tamaño máximo');
19
- },
20
- }) => {
21
- const [files, setFiles] = useState([]);
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
- };
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
- };
47
-
48
- const CustomPreview = ({ fileWithMeta }) => {
49
- const { meta, remove } = fileWithMeta;
50
- if (meta.size / (1024 * 1024) > maxSize) {
51
- onMaxFileSizeError();
52
- remove();
53
- }
54
- return (
55
- <div
56
- className="dropzone-upload-previewContainer"
57
- style={{ width: '100%', display: 'flex', alignItems: 'center' }}
58
- >
59
- {meta.type === 'application/pdf' ? (
60
- <>
61
- <IconButtonSvg
62
- className="form-control flex"
63
- svg={pdfImage}
64
- svgOver={pdfImage}
65
- height="1.6rem"
66
- width="1.6rem"
67
- title={meta.name}
68
- />
69
- <p style={{ paddingRight: '1rem' }}>
70
- {meta.name.length > 17
71
- ? meta.name.substring(0, 17) + '...'
72
- : meta.name}
73
- </p>
74
- </>
75
- ) : (
76
- <>
77
- <img
78
- className="dropzone-upload-previewImage mt-1"
79
- src={meta.previewUrl}
80
- alt={meta.name}
81
- style={{
82
- width: '110px',
83
- height: '110px',
84
- objectFit: 'cover',
85
- marginRight: '0.5rem',
86
- }}
87
- />
88
- <div className="dropzone-upload-file-name-container">
89
- <p className="dropzone-upload-file-name" title={meta.name}>
90
- {meta.name}
91
- </p>
92
- </div>
93
- </>
94
- )}
95
- <button
96
- style={{ marginTop: '0rem' }}
97
- onClick={remove}
98
- className="dropzone-upload-delete-btn simple-icon-trash"
99
- ></button>
100
- </div>
101
- );
102
- };
103
-
104
- const Input = ({ accept, onFiles, getFilesFromEvent }) => {
105
- const text =
106
- totalFiles > 0 ? `${maxFiles - 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
- };
133
-
134
- return (
135
- <div className={classNames}>
136
- <Dropzone
137
- disableUpload={false}
138
- maxFiles={totalFiles < maxFiles ? maxFiles : 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
- };
150
-
151
- export default DropzoneUploaderDniDigital;
@@ -1,66 +0,0 @@
1
- .dropzone-upload-button{
2
- padding: 25;
3
- border-radius: 5px !important;
4
- cursor: pointer;
5
- color: #fff;
6
- width: 10rem !important;
7
- height: 2rem !important;
8
- line-height: 1.5 !important;
9
- font-size: 13px;
10
- text-align: center;
11
- vertical-align: middle !important;
12
- border: none;
13
- padding-top: 0.5rem;
14
- margin-top: 0.5rem;
15
- background-color: #af251b;
16
- &:hover {
17
- background-color: rgb(108, 31, 1);
18
- }
19
- }
20
- .dropzone-upload-frame{
21
- border: 0px !important;
22
- overflow: 'none' !important;
23
- }
24
- .dropzone-upload-previewContainer {
25
- display: flex;
26
- flex-direction: row;
27
- align-items: center;
28
- justify-content: space-between;
29
- position: relative;
30
- width: 100px;
31
- min-height: 60px;
32
- z-index: 1;
33
- border-bottom: 1px solid #ECECEC;
34
- box-sizing: border-box;
35
- }
36
-
37
- .dropzone-upload-previewImage {
38
- width: 60rem;
39
- max-height: 60px;
40
- max-width: 10rem;
41
- border-radius: 4px;
42
- padding-right: 1rem;
43
- }
44
-
45
- .dropzone-upload-delete-btn {
46
- width: 2rem;
47
- line-height: 1.5;
48
- border : 0;
49
- color: #ff0000;
50
- background-color: #f8f8f8;
51
- padding-right:1rem;
52
- }
53
-
54
- .dropzone-upload-file-name-container {
55
- position: relative;
56
- display: inline-block;
57
- max-width: 150px; /* Ajusta este valor para aumentar el ancho */
58
- }
59
-
60
- .dropzone-upload-file-name {
61
- padding-right: 1rem;
62
- white-space: nowrap;
63
- overflow: hidden;
64
- text-overflow: ellipsis;
65
- max-width: 150px; /* Ajusta este valor para aumentar el ancho */
66
- }