@xaypay/tui 0.0.119 → 0.0.121
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/dist/index.es.js +3983 -4344
- package/dist/index.js +3982 -4345
- package/package.json +1 -1
- package/tui.config.js +1 -1
- package/.eslintrc.js +0 -30
- package/.husky/pre-commit +0 -4
- package/.prettierrc +0 -10
- package/.storybook/main.js +0 -48
- package/.storybook/preview.js +0 -9
- package/rollup.config.js +0 -37
- package/src/assets/attach.svg +0 -4
- package/src/assets/delete.svg +0 -4
- package/src/assets/down-arrow.svg +0 -4
- package/src/assets/figma-image.png +0 -0
- package/src/assets/heart-filled.svg +0 -17
- package/src/assets/heart-outline.svg +0 -14
- package/src/assets/like-filled.svg +0 -21
- package/src/assets/like-outline.svg +0 -21
- package/src/assets/minus.svg +0 -4
- package/src/assets/pdf.svg +0 -3
- package/src/assets/plus.svg +0 -4
- package/src/assets/range-arrow-default.svg +0 -19
- package/src/assets/range-arrow-error.svg +0 -19
- package/src/assets/range-arrow-success.svg +0 -19
- package/src/assets/star-filled.svg +0 -21
- package/src/assets/star-outline.svg +0 -5
- package/src/assets/table-settings-icon.svg +0 -3
- package/src/assets/up-arrow.svg +0 -4
- package/src/assets_old/icons/Read Me.txt +0 -7
- package/src/assets_old/icons/demo-files/demo.css +0 -152
- package/src/assets_old/icons/demo-files/demo.js +0 -28
- package/src/assets_old/icons/demo.html +0 -192
- package/src/assets_old/icons/fonts/icomoon.eot +0 -0
- package/src/assets_old/icons/fonts/icomoon.svg +0 -21
- package/src/assets_old/icons/fonts/icomoon.ttf +0 -0
- package/src/assets_old/icons/fonts/icomoon.woff +0 -0
- package/src/assets_old/icons/selection.json +0 -1
- package/src/assets_old/icons/style.css +0 -58
- package/src/components/autocomplate/autocomplate.module.css +0 -95
- package/src/components/autocomplate/autocomplate.stories.js +0 -35
- package/src/components/autocomplate/index.js +0 -164
- package/src/components/button/button.stories.js +0 -13
- package/src/components/button/index.js +0 -187
- package/src/components/captcha/captcha.module.css +0 -74
- package/src/components/captcha/captcha.stories.js +0 -21
- package/src/components/captcha/index.js +0 -158
- package/src/components/checkbox/checkbox.module.css +0 -0
- package/src/components/checkbox/checkbox.stories.js +0 -76
- package/src/components/checkbox/index.js +0 -120
- package/src/components/file/file.module.css +0 -114
- package/src/components/file/file.stories.js +0 -20
- package/src/components/file/index.js +0 -138
- package/src/components/icon/Active.js +0 -20
- package/src/components/icon/Arrow.js +0 -19
- package/src/components/icon/Cancel.js +0 -19
- package/src/components/icon/CaptchaArrowDown.js +0 -19
- package/src/components/icon/CaptchaArrowUp.js +0 -19
- package/src/components/icon/CheckboxChecked.js +0 -21
- package/src/components/icon/CheckboxUnchecked.js +0 -21
- package/src/components/icon/Close.js +0 -19
- package/src/components/icon/CloseIcon.js +0 -19
- package/src/components/icon/CloseSlide.js +0 -19
- package/src/components/icon/DeActive.js +0 -20
- package/src/components/icon/DeleteComponent.js +0 -20
- package/src/components/icon/Done.js +0 -19
- package/src/components/icon/Dots.js +0 -19
- package/src/components/icon/DownArrow.js +0 -20
- package/src/components/icon/HeartFilled.js +0 -25
- package/src/components/icon/HeartOutline.js +0 -25
- package/src/components/icon/Heic.js +0 -21
- package/src/components/icon/Icon.js +0 -11
- package/src/components/icon/ListItemDelete.js +0 -19
- package/src/components/icon/ListItemJpeg.js +0 -21
- package/src/components/icon/ListItemJpg.js +0 -21
- package/src/components/icon/ListItemPdf.js +0 -21
- package/src/components/icon/ListItemPng.js +0 -21
- package/src/components/icon/Next.js +0 -20
- package/src/components/icon/Nextarrow.js +0 -19
- package/src/components/icon/PDF.js +0 -19
- package/src/components/icon/Prev.js +0 -20
- package/src/components/icon/RangeArrowDefault.js +0 -43
- package/src/components/icon/RangeArrowError.js +0 -43
- package/src/components/icon/RangeArrowSuccess.js +0 -43
- package/src/components/icon/Reject.js +0 -19
- package/src/components/icon/RemoveFile.js +0 -20
- package/src/components/icon/Required.js +0 -19
- package/src/components/icon/ToasterClose.js +0 -19
- package/src/components/icon/ToasterError.js +0 -19
- package/src/components/icon/ToasterInfo.js +0 -19
- package/src/components/icon/ToasterSuccess.js +0 -19
- package/src/components/icon/ToasterWarning.js +0 -19
- package/src/components/icon/Tooltip.js +0 -19
- package/src/components/icon/UpArrow.js +0 -20
- package/src/components/icon/Upload.js +0 -25
- package/src/components/icon/Wrong.js +0 -21
- package/src/components/icon/Zoom.js +0 -21
- package/src/components/icon/index.js +0 -0
- package/src/components/input/index.js +0 -688
- package/src/components/input/input.module.css +0 -51
- package/src/components/input/input.stories.js +0 -26
- package/src/components/modal/index.js +0 -436
- package/src/components/modal/modal.module.css +0 -22
- package/src/components/modal/modal.stories.js +0 -88
- package/src/components/newAutocomplete/NewAutocomplete.stories.js +0 -102
- package/src/components/newAutocomplete/autocomplete.module.css +0 -4
- package/src/components/newAutocomplete/index.js +0 -592
- package/src/components/newFile/fileItem.js +0 -281
- package/src/components/newFile/index.js +0 -731
- package/src/components/newFile/newFile.stories.js +0 -93
- package/src/components/pagination/index.js +0 -234
- package/src/components/pagination/pagination.module.css +0 -93
- package/src/components/pagination/pagination.stories.js +0 -371
- package/src/components/pagination/paginationRange.js +0 -45
- package/src/components/radio/index.js +0 -236
- package/src/components/radio/radio.module.css +0 -59
- package/src/components/radio/radio.stories.js +0 -59
- package/src/components/select/index.js +0 -534
- package/src/components/select/select.module.css +0 -93
- package/src/components/select/select.stories.js +0 -39
- package/src/components/singleCheckbox/Checkbox.js +0 -84
- package/src/components/singleCheckbox/index.js +0 -65
- package/src/components/singleCheckbox/singleCheckbox.stories.js +0 -24
- package/src/components/stepper/index.js +0 -45
- package/src/components/stepper/stepper.module.css +0 -57
- package/src/components/stepper/stepper.stories.js +0 -17
- package/src/components/table/index.js +0 -789
- package/src/components/table/table.module.css +0 -63
- package/src/components/table/table.stories.js +0 -497
- package/src/components/table/td.js +0 -429
- package/src/components/table/th.js +0 -103
- package/src/components/textarea/index.js +0 -285
- package/src/components/textarea/textarea.module.css +0 -25
- package/src/components/textarea/textarea.stories.js +0 -56
- package/src/components/toaster/Toast.js +0 -203
- package/src/components/toaster/index.js +0 -131
- package/src/components/toaster/toaster.module.css +0 -201
- package/src/components/toaster/toaster.stories.js +0 -593
- package/src/components/tooltip/index.js +0 -156
- package/src/components/tooltip/tooltip.module.css +0 -46
- package/src/components/tooltip/tooltip.stories.js +0 -30
- package/src/components/typography/index.js +0 -124
- package/src/components/typography/typography.module.css +0 -57
- package/src/components/typography/typography.stories.js +0 -22
- package/src/index.js +0 -19
- package/src/stories/Introduction.stories.mdx +0 -210
- package/src/stories/assets/code-brackets.svg +0 -1
- package/src/stories/assets/colors.svg +0 -1
- package/src/stories/assets/comments.svg +0 -1
- package/src/stories/assets/direction.svg +0 -1
- package/src/stories/assets/flow.svg +0 -1
- package/src/stories/assets/plugin.svg +0 -1
- package/src/stories/assets/repo.svg +0 -1
- package/src/stories/assets/stackalt.svg +0 -1
- package/src/stories/changelog.stories.mdx +0 -172
- package/src/stories/configuration.stories.mdx +0 -715
- package/src/stories/documentation.stories.mdx +0 -118
- package/src/stories/static/autocomplete-usage.png +0 -0
- package/src/stories/static/button-usage-icon.png +0 -0
- package/src/stories/static/button-usage.png +0 -0
- package/src/stories/static/captcha-usage.png +0 -0
- package/src/stories/static/checkbox-group-usage-2.png +0 -0
- package/src/stories/static/checkbox-group-usage.png +0 -0
- package/src/stories/static/file-single-usage.png +0 -0
- package/src/stories/static/file-usage.png +0 -0
- package/src/stories/static/input-usage.png +0 -0
- package/src/stories/static/modal-usage.png +0 -0
- package/src/stories/static/radio-usage.png +0 -0
- package/src/stories/static/select-usage.png +0 -0
- package/src/stories/static/table-body-data-structure-first-part-usage.png +0 -0
- package/src/stories/static/table-body-data-structure-second-part-usage.png +0 -0
- package/src/stories/static/table-body-data-structure-third-part-usage.png +0 -0
- package/src/stories/static/table-component-usage.png +0 -0
- package/src/stories/static/table-header-data-structure-usage.png +0 -0
- package/src/stories/static/table-new-data-structure-usage.png +0 -0
- package/src/stories/static/textarea-usage.png +0 -0
- package/src/stories/static/toaster-container-usage.png +0 -0
- package/src/stories/static/toaster-usage.png +0 -0
- package/src/stories/static/tooltip-usage.png +0 -0
- package/src/stories/usage.stories.mdx +0 -201
- package/src/utils/index.js +0 -29
|
@@ -1,731 +0,0 @@
|
|
|
1
|
-
import React, { useRef, useState, useEffect, useMemo } from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
3
|
-
import { v4 as uuidv4 } from 'uuid'
|
|
4
|
-
import classnames from 'classnames'
|
|
5
|
-
|
|
6
|
-
import FileItem from './fileItem'
|
|
7
|
-
|
|
8
|
-
import { compereConfigs } from './../../utils'
|
|
9
|
-
import { Button } from './../button'
|
|
10
|
-
|
|
11
|
-
import SvgPdf from './../icon/PDF'
|
|
12
|
-
import SvgHeic from './../icon/Heic'
|
|
13
|
-
import SvgUpload from './../icon/Upload'
|
|
14
|
-
import SvgRequired from './../icon/Required'
|
|
15
|
-
import SvgRemoveFile from './../icon/RemoveFile'
|
|
16
|
-
import SvgDeleteComponent from './../icon/DeleteComponent'
|
|
17
|
-
|
|
18
|
-
export const NewFile = ({
|
|
19
|
-
or,
|
|
20
|
-
size,
|
|
21
|
-
name,
|
|
22
|
-
color,
|
|
23
|
-
label,
|
|
24
|
-
weight,
|
|
25
|
-
height,
|
|
26
|
-
radius,
|
|
27
|
-
change,
|
|
28
|
-
border,
|
|
29
|
-
upload,
|
|
30
|
-
preview,
|
|
31
|
-
maxSize,
|
|
32
|
-
maxWidth,
|
|
33
|
-
disabled,
|
|
34
|
-
multiple,
|
|
35
|
-
required,
|
|
36
|
-
className,
|
|
37
|
-
errorSize,
|
|
38
|
-
labelSize,
|
|
39
|
-
removeFile,
|
|
40
|
-
labelColor,
|
|
41
|
-
errorColor,
|
|
42
|
-
filesArray,
|
|
43
|
-
componentId,
|
|
44
|
-
putFileHere,
|
|
45
|
-
borderColor,
|
|
46
|
-
uploadColor,
|
|
47
|
-
defaultData,
|
|
48
|
-
formatError,
|
|
49
|
-
errorMessage,
|
|
50
|
-
fileSizeText,
|
|
51
|
-
maxSizeError,
|
|
52
|
-
progressColor,
|
|
53
|
-
noChoosenFile,
|
|
54
|
-
|
|
55
|
-
uploadBtnFont,
|
|
56
|
-
uploadBtnSize,
|
|
57
|
-
uploadBtnLabel,
|
|
58
|
-
uploadBtnColor,
|
|
59
|
-
uploadBtnHeight,
|
|
60
|
-
uploadBtnBackgroundColor,
|
|
61
|
-
|
|
62
|
-
fileExtensions,
|
|
63
|
-
listItemHeight,
|
|
64
|
-
backgroundColor,
|
|
65
|
-
deleteComponent,
|
|
66
|
-
removeComponent,
|
|
67
|
-
listItemPadding,
|
|
68
|
-
progressFontSize,
|
|
69
|
-
borderHoverColor,
|
|
70
|
-
maxCHoosenLength,
|
|
71
|
-
listItemErrorSize,
|
|
72
|
-
progressTrackColor,
|
|
73
|
-
fileAreaImageWidth,
|
|
74
|
-
listItemErrorColor,
|
|
75
|
-
timeForRemoveError,
|
|
76
|
-
progressFailedColor,
|
|
77
|
-
fileAreaImageHeight,
|
|
78
|
-
progressSuccessColor,
|
|
79
|
-
progressLoadingColor,
|
|
80
|
-
hiddenBackgroundColor,
|
|
81
|
-
maxCHoosenLengthError,
|
|
82
|
-
extentionsRowMarginTop,
|
|
83
|
-
listItemBackgroundColor,
|
|
84
|
-
listItemBackgroundErrorColor,
|
|
85
|
-
maxCHoosenLengthErrorHideTime,
|
|
86
|
-
}) => {
|
|
87
|
-
const ref = useRef(null)
|
|
88
|
-
const inpRef = useRef(null)
|
|
89
|
-
const configStyles = compereConfigs()
|
|
90
|
-
const memoizedItems = useMemo(() => filesArray, [filesArray])
|
|
91
|
-
const classProps = classnames(className ? className : configStyles.FILE.className)
|
|
92
|
-
|
|
93
|
-
const [error, setError] = useState('')
|
|
94
|
-
const [isHover, setIsHover] = useState(false)
|
|
95
|
-
const [singleFile, setSingleFile] = useState(null)
|
|
96
|
-
const [choosenFileCount, setChoosenFileCount] = useState(0)
|
|
97
|
-
const [image, setImage] = useState(
|
|
98
|
-
!multiple ? (defaultData ? (defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf') : null) : null
|
|
99
|
-
)
|
|
100
|
-
|
|
101
|
-
const handleRemoveComponent = () => {
|
|
102
|
-
if (!multiple) {
|
|
103
|
-
removeFile && removeFile(singleFile)
|
|
104
|
-
} else {
|
|
105
|
-
removeFile && removeFile(filesArray)
|
|
106
|
-
}
|
|
107
|
-
removeComponent(componentId)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const handleRemoveFile = () => {
|
|
111
|
-
setImage(null)
|
|
112
|
-
setSingleFile(null)
|
|
113
|
-
removeFile && removeFile(singleFile)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const handleUploadFiles = (file) => {
|
|
117
|
-
if (maxCHoosenLength && choosenFileCount > 0) {
|
|
118
|
-
if (file.length > choosenFileCount || file.length + memoizedItems.length > choosenFileCount) {
|
|
119
|
-
setError(
|
|
120
|
-
maxCHoosenLengthError
|
|
121
|
-
? maxCHoosenLengthError
|
|
122
|
-
: `Դիմումին կարող եք կցել առավելագույնը ${choosenFileCount} ֆայլ`
|
|
123
|
-
)
|
|
124
|
-
const clearFunc = () => {
|
|
125
|
-
clearTimeout(time)
|
|
126
|
-
}
|
|
127
|
-
const time = setTimeout(
|
|
128
|
-
() => {
|
|
129
|
-
setError('')
|
|
130
|
-
clearFunc()
|
|
131
|
-
},
|
|
132
|
-
maxCHoosenLengthErrorHideTime && typeof maxCHoosenLengthErrorHideTime === 'number'
|
|
133
|
-
? Math.round(maxCHoosenLengthErrorHideTime)
|
|
134
|
-
: 3000
|
|
135
|
-
)
|
|
136
|
-
} else {
|
|
137
|
-
for (let ix = 0; ix < file.length; ix++) {
|
|
138
|
-
if (file[ix]) {
|
|
139
|
-
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
140
|
-
if (
|
|
141
|
-
fileExtensions.includes(file[ix].type.split('/')[1]) ||
|
|
142
|
-
(fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif')
|
|
143
|
-
) {
|
|
144
|
-
change({
|
|
145
|
-
id: '',
|
|
146
|
-
check: '',
|
|
147
|
-
status: '',
|
|
148
|
-
file: file[ix],
|
|
149
|
-
uuid: uuidv4(),
|
|
150
|
-
})
|
|
151
|
-
} else {
|
|
152
|
-
change({
|
|
153
|
-
file: file[ix],
|
|
154
|
-
uuid: uuidv4(),
|
|
155
|
-
check: formatError,
|
|
156
|
-
})
|
|
157
|
-
}
|
|
158
|
-
} else {
|
|
159
|
-
change({
|
|
160
|
-
file: file[ix],
|
|
161
|
-
uuid: uuidv4(),
|
|
162
|
-
check: maxSizeError,
|
|
163
|
-
})
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
} else {
|
|
169
|
-
for (let ix = 0; ix < file.length; ix++) {
|
|
170
|
-
if (file[ix]) {
|
|
171
|
-
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
172
|
-
if (
|
|
173
|
-
fileExtensions.includes(file[ix].type.split('/')[1]) ||
|
|
174
|
-
(fileExtensions.includes('heic') && file[ix].type.split('/')[1] === 'heif')
|
|
175
|
-
) {
|
|
176
|
-
change({
|
|
177
|
-
id: '',
|
|
178
|
-
check: '',
|
|
179
|
-
status: '',
|
|
180
|
-
file: file[ix],
|
|
181
|
-
uuid: uuidv4(),
|
|
182
|
-
})
|
|
183
|
-
} else {
|
|
184
|
-
change({
|
|
185
|
-
file: file[ix],
|
|
186
|
-
uuid: uuidv4(),
|
|
187
|
-
check: formatError,
|
|
188
|
-
})
|
|
189
|
-
}
|
|
190
|
-
} else {
|
|
191
|
-
change({
|
|
192
|
-
file: file[ix],
|
|
193
|
-
uuid: uuidv4(),
|
|
194
|
-
check: maxSizeError,
|
|
195
|
-
})
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const handleChange = (e) => {
|
|
203
|
-
const file = e.target.files
|
|
204
|
-
|
|
205
|
-
if (multiple) {
|
|
206
|
-
setError('')
|
|
207
|
-
setImage(null)
|
|
208
|
-
handleUploadFiles(file)
|
|
209
|
-
|
|
210
|
-
if (file.length === 0 && memoizedItems.length === 0) {
|
|
211
|
-
setError(noChoosenFile)
|
|
212
|
-
}
|
|
213
|
-
} else {
|
|
214
|
-
if (file[0]) {
|
|
215
|
-
if (file[0].size <= maxSize * Math.pow(2, 20)) {
|
|
216
|
-
if (
|
|
217
|
-
fileExtensions.includes(file[0].type.split('/')[1]) ||
|
|
218
|
-
(fileExtensions.includes('heic') &&
|
|
219
|
-
(file[0].type === 'image/heif' || file[0].type === 'image/heic'))
|
|
220
|
-
) {
|
|
221
|
-
setError('')
|
|
222
|
-
change(file)
|
|
223
|
-
setSingleFile(file)
|
|
224
|
-
if (file[0].type === 'application/pdf') {
|
|
225
|
-
setImage('pdf')
|
|
226
|
-
} else if (file[0].type === 'image/heif' || file[0].type === 'image/heic') {
|
|
227
|
-
setImage('heic')
|
|
228
|
-
} else {
|
|
229
|
-
setImage(URL.createObjectURL(file[0]))
|
|
230
|
-
}
|
|
231
|
-
} else {
|
|
232
|
-
setImage(null)
|
|
233
|
-
setError(formatError)
|
|
234
|
-
}
|
|
235
|
-
} else {
|
|
236
|
-
setImage(null)
|
|
237
|
-
setError(maxSizeError)
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
if (file.length === 0) {
|
|
241
|
-
setImage(null)
|
|
242
|
-
setError(noChoosenFile)
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
const handleClick = () => {
|
|
248
|
-
inpRef.current.files = null
|
|
249
|
-
inpRef.current.value = null
|
|
250
|
-
if (!image) {
|
|
251
|
-
inpRef.current.click()
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const handleDrop = (e) => {
|
|
256
|
-
if (!disabled) {
|
|
257
|
-
e.preventDefault()
|
|
258
|
-
handleChange({ target: { files: e.dataTransfer.files } })
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
const handleDragOver = (e) => {
|
|
263
|
-
if (!disabled) {
|
|
264
|
-
e.preventDefault()
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
const handleMouseEnter = () => {
|
|
269
|
-
setIsHover(true)
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
const handleMouseLeave = () => {
|
|
273
|
-
setIsHover(false)
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const handleStopPropagation = (e) => {
|
|
277
|
-
e.stopPropagation()
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
useEffect(() => {
|
|
281
|
-
if (!multiple && defaultData) {
|
|
282
|
-
if (!defaultData.type) {
|
|
283
|
-
alert('Please add type in defaultData prop')
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if (!defaultData.url) {
|
|
287
|
-
alert('Please add url in defaultData prop')
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (multiple && !filesArray) {
|
|
292
|
-
alert('In multiple mode, you should add filesArray prop for drawing files')
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if (multiple) {
|
|
296
|
-
setSingleFile(null)
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
if (multiple && !removeFile) {
|
|
300
|
-
alert('Please add removeFile prop on NewFile component, it is a require in multiple mode')
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
if (maxCHoosenLength) {
|
|
304
|
-
if (typeof maxCHoosenLength !== 'number') {
|
|
305
|
-
alert('maxCHoosenLength prop must be a number, please check it!')
|
|
306
|
-
} else {
|
|
307
|
-
if (maxCHoosenLength <= 0) {
|
|
308
|
-
setChoosenFileCount(1)
|
|
309
|
-
} else {
|
|
310
|
-
setChoosenFileCount(Math.round(maxCHoosenLength))
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}, [multiple, removeFile, filesArray && filesArray.length, defaultData, maxCHoosenLength])
|
|
315
|
-
|
|
316
|
-
useEffect(() => {
|
|
317
|
-
if (deleteComponent && !removeComponent) {
|
|
318
|
-
alert(
|
|
319
|
-
'Please add removeComponent prop on NewFile component it is require when deleteComponent prop is true'
|
|
320
|
-
)
|
|
321
|
-
}
|
|
322
|
-
}, [deleteComponent])
|
|
323
|
-
|
|
324
|
-
useEffect(() => {
|
|
325
|
-
if (errorMessage) {
|
|
326
|
-
setError(errorMessage)
|
|
327
|
-
} else {
|
|
328
|
-
setError('')
|
|
329
|
-
}
|
|
330
|
-
}, [errorMessage])
|
|
331
|
-
|
|
332
|
-
useEffect(() => {
|
|
333
|
-
if (!change) {
|
|
334
|
-
alert('Please add change prop on File component')
|
|
335
|
-
}
|
|
336
|
-
}, [change])
|
|
337
|
-
|
|
338
|
-
return (
|
|
339
|
-
<div
|
|
340
|
-
ref={ref}
|
|
341
|
-
style={{
|
|
342
|
-
width: '100%',
|
|
343
|
-
maxWidth: maxWidth ? maxWidth : configStyles.FILE.maxWidth,
|
|
344
|
-
}}
|
|
345
|
-
className={classProps}
|
|
346
|
-
>
|
|
347
|
-
<div
|
|
348
|
-
style={{
|
|
349
|
-
display: 'flex',
|
|
350
|
-
marginBottom: '6px',
|
|
351
|
-
alignItems: 'center',
|
|
352
|
-
justifyContent: label ? 'space-between' : 'flex-end',
|
|
353
|
-
}}
|
|
354
|
-
>
|
|
355
|
-
{label && (
|
|
356
|
-
<label
|
|
357
|
-
style={{
|
|
358
|
-
color: labelColor ? labelColor : configStyles.FILE.labelColor,
|
|
359
|
-
fontSize: labelSize ? labelSize : configStyles.FILE.labelSize,
|
|
360
|
-
}}
|
|
361
|
-
>
|
|
362
|
-
{label}
|
|
363
|
-
{required && (
|
|
364
|
-
<sup>
|
|
365
|
-
<SvgRequired />
|
|
366
|
-
</sup>
|
|
367
|
-
)}
|
|
368
|
-
</label>
|
|
369
|
-
)}
|
|
370
|
-
{deleteComponent && (
|
|
371
|
-
<span style={{ cursor: 'pointer' }} onClick={handleRemoveComponent}>
|
|
372
|
-
<SvgDeleteComponent />
|
|
373
|
-
</span>
|
|
374
|
-
)}
|
|
375
|
-
</div>
|
|
376
|
-
|
|
377
|
-
<div
|
|
378
|
-
style={{
|
|
379
|
-
width: '100%',
|
|
380
|
-
display: 'flex',
|
|
381
|
-
alignItems: 'center',
|
|
382
|
-
position: 'relative',
|
|
383
|
-
boxSizing: 'border-box',
|
|
384
|
-
justifyContent: 'center',
|
|
385
|
-
cursor: !disabled ? 'pointer' : 'not-allowed',
|
|
386
|
-
height: height ? height : configStyles.FILE.height,
|
|
387
|
-
border: border ? border : configStyles.FILE.border,
|
|
388
|
-
borderRadius: radius ? radius : configStyles.FILE.radius,
|
|
389
|
-
backgroundColor: backgroundColor ? backgroundColor : configStyles.FILE.backgroundColor,
|
|
390
|
-
borderColor: error
|
|
391
|
-
? errorColor
|
|
392
|
-
? errorColor
|
|
393
|
-
: configStyles.FILE.errorColor
|
|
394
|
-
: disabled
|
|
395
|
-
? borderColor
|
|
396
|
-
? borderColor
|
|
397
|
-
: configStyles.FILE.borderColor
|
|
398
|
-
: isHover
|
|
399
|
-
? borderHoverColor
|
|
400
|
-
? borderHoverColor
|
|
401
|
-
: configStyles.FILE.borderHoverColor
|
|
402
|
-
: borderColor
|
|
403
|
-
? borderColor
|
|
404
|
-
: configStyles.FILE.borderColor,
|
|
405
|
-
}}
|
|
406
|
-
onDrop={handleDrop}
|
|
407
|
-
onClick={handleClick}
|
|
408
|
-
onDragOver={handleDragOver}
|
|
409
|
-
onMouseEnter={handleMouseEnter}
|
|
410
|
-
onMouseLeave={handleMouseLeave}
|
|
411
|
-
>
|
|
412
|
-
<input
|
|
413
|
-
hidden
|
|
414
|
-
name={name}
|
|
415
|
-
type="file"
|
|
416
|
-
ref={inpRef}
|
|
417
|
-
disabled={disabled}
|
|
418
|
-
multiple={multiple}
|
|
419
|
-
onChange={handleChange}
|
|
420
|
-
/>
|
|
421
|
-
|
|
422
|
-
<div
|
|
423
|
-
style={{
|
|
424
|
-
width: '100%',
|
|
425
|
-
height: '100%',
|
|
426
|
-
display: 'flex',
|
|
427
|
-
textAlign: 'center',
|
|
428
|
-
alignItems: 'center',
|
|
429
|
-
flexDirection: 'column',
|
|
430
|
-
justifyContent: 'center',
|
|
431
|
-
color: color ? color : configStyles.FILE.color,
|
|
432
|
-
fontSize: size ? size : configStyles.FILE.size,
|
|
433
|
-
fontWeight: weight ? weight : configStyles.FILE.weight,
|
|
434
|
-
}}
|
|
435
|
-
>
|
|
436
|
-
{!multiple && image && preview ? (
|
|
437
|
-
image === 'pdf' ? (
|
|
438
|
-
<SvgPdf />
|
|
439
|
-
) : image === 'heif' || image === 'heic' ? (
|
|
440
|
-
<SvgHeic />
|
|
441
|
-
) : (
|
|
442
|
-
<img
|
|
443
|
-
src={image}
|
|
444
|
-
style={{
|
|
445
|
-
display: 'block',
|
|
446
|
-
maxWidth: '100%',
|
|
447
|
-
maxHeight: '95%',
|
|
448
|
-
objectFit: 'contain',
|
|
449
|
-
width: fileAreaImageWidth
|
|
450
|
-
? fileAreaImageWidth
|
|
451
|
-
: configStyles.FILE.fileAreaImageWidth,
|
|
452
|
-
height: fileAreaImageHeight
|
|
453
|
-
? fileAreaImageHeight
|
|
454
|
-
: configStyles.FILE.fileAreaImageHeight,
|
|
455
|
-
}}
|
|
456
|
-
alt="file preview"
|
|
457
|
-
/>
|
|
458
|
-
)
|
|
459
|
-
) : preview ? (
|
|
460
|
-
<>
|
|
461
|
-
<div>
|
|
462
|
-
<SvgUpload />
|
|
463
|
-
</div>
|
|
464
|
-
|
|
465
|
-
<div>
|
|
466
|
-
<p
|
|
467
|
-
style={{
|
|
468
|
-
margin: '0px',
|
|
469
|
-
}}
|
|
470
|
-
>
|
|
471
|
-
{putFileHere ? putFileHere : configStyles.FILE.putFileHere}
|
|
472
|
-
<br />
|
|
473
|
-
{or ? or : configStyles.FILE.or}{' '}
|
|
474
|
-
<span
|
|
475
|
-
style={{
|
|
476
|
-
color: uploadColor ? uploadColor : configStyles.FILE.uploadColor,
|
|
477
|
-
}}
|
|
478
|
-
>
|
|
479
|
-
{upload ? upload : configStyles.FILE.upload}
|
|
480
|
-
</span>
|
|
481
|
-
</p>
|
|
482
|
-
</div>
|
|
483
|
-
|
|
484
|
-
<div
|
|
485
|
-
style={{
|
|
486
|
-
marginTop: extentionsRowMarginTop
|
|
487
|
-
? extentionsRowMarginTop
|
|
488
|
-
: configStyles.FILE.extentionsRowMarginTop,
|
|
489
|
-
}}
|
|
490
|
-
>
|
|
491
|
-
<p
|
|
492
|
-
style={{
|
|
493
|
-
margin: '0px',
|
|
494
|
-
}}
|
|
495
|
-
>
|
|
496
|
-
{fileSizeText ? fileSizeText : configStyles.FILE.fileSizeText} {maxSize} ՄԲ ({' '}
|
|
497
|
-
{fileExtensions.toString().split(',').join(', ')} )
|
|
498
|
-
</p>
|
|
499
|
-
</div>
|
|
500
|
-
</>
|
|
501
|
-
) : (
|
|
502
|
-
<>
|
|
503
|
-
<div
|
|
504
|
-
style={{
|
|
505
|
-
width: '100%',
|
|
506
|
-
padding: '5px',
|
|
507
|
-
display: 'flex',
|
|
508
|
-
alignItems: 'center',
|
|
509
|
-
boxSizing: 'border-box',
|
|
510
|
-
justifyContent: 'space-between',
|
|
511
|
-
}}
|
|
512
|
-
>
|
|
513
|
-
<Button
|
|
514
|
-
contentWidth
|
|
515
|
-
onClick={(_) => _}
|
|
516
|
-
font={uploadBtnFont ? uploadBtnFont : configStyles.FILE.uploadBtnFont}
|
|
517
|
-
size={uploadBtnSize ? uploadBtnSize : configStyles.FILE.uploadBtnSize}
|
|
518
|
-
label={uploadBtnLabel ? uploadBtnLabel : configStyles.FILE.uploadBtnLabel}
|
|
519
|
-
color={uploadBtnColor ? uploadBtnColor : configStyles.FILE.uploadBtnColor}
|
|
520
|
-
height={uploadBtnHeight ? uploadBtnHeight : configStyles.FILE.uploadBtnHeight}
|
|
521
|
-
hoverColor={uploadBtnColor ? uploadBtnColor : configStyles.FILE.uploadBtnColor}
|
|
522
|
-
backgroundColor={
|
|
523
|
-
uploadBtnBackgroundColor
|
|
524
|
-
? uploadBtnBackgroundColor
|
|
525
|
-
: configStyles.FILE.uploadBtnBackgroundColor
|
|
526
|
-
}
|
|
527
|
-
backgroundHoverColor={
|
|
528
|
-
uploadBtnBackgroundColor
|
|
529
|
-
? uploadBtnBackgroundColor
|
|
530
|
-
: configStyles.FILE.uploadBtnBackgroundColor
|
|
531
|
-
}
|
|
532
|
-
/>
|
|
533
|
-
<p
|
|
534
|
-
style={{
|
|
535
|
-
margin: '0px',
|
|
536
|
-
marginLeft: '5px',
|
|
537
|
-
overflow: 'hidden',
|
|
538
|
-
whiteSpace: 'nowrap',
|
|
539
|
-
textOverflow: 'ellipsis',
|
|
540
|
-
}}
|
|
541
|
-
>
|
|
542
|
-
{singleFile ? (
|
|
543
|
-
singleFile[0].name
|
|
544
|
-
) : (
|
|
545
|
-
<span>
|
|
546
|
-
{fileSizeText ? fileSizeText : configStyles.FILE.fileSizeText} {maxSize} ՄԲ
|
|
547
|
-
( {fileExtensions.toString().split(',').join(', ')} )
|
|
548
|
-
</span>
|
|
549
|
-
)}
|
|
550
|
-
</p>
|
|
551
|
-
</div>
|
|
552
|
-
</>
|
|
553
|
-
)}
|
|
554
|
-
</div>
|
|
555
|
-
|
|
556
|
-
<div
|
|
557
|
-
style={{
|
|
558
|
-
position: 'absolute',
|
|
559
|
-
top: '0px',
|
|
560
|
-
left: '0px',
|
|
561
|
-
zIndex: '1',
|
|
562
|
-
width: '100%',
|
|
563
|
-
height: '100%',
|
|
564
|
-
padding: '10px',
|
|
565
|
-
cursor: 'default',
|
|
566
|
-
boxSizing: 'border-box',
|
|
567
|
-
alignItems: 'flex-start',
|
|
568
|
-
justifyContent: 'flex-end',
|
|
569
|
-
borderRadius: radius ? radius : configStyles.FILE.radius,
|
|
570
|
-
display: !multiple && !disabled && image && !error && isHover ? 'flex' : 'none',
|
|
571
|
-
backgroundColor: hiddenBackgroundColor
|
|
572
|
-
? hiddenBackgroundColor
|
|
573
|
-
: configStyles.FILE.hiddenBackgroundColor,
|
|
574
|
-
}}
|
|
575
|
-
onClick={handleStopPropagation}
|
|
576
|
-
>
|
|
577
|
-
<div
|
|
578
|
-
style={{
|
|
579
|
-
cursor: 'pointer',
|
|
580
|
-
}}
|
|
581
|
-
onClick={handleRemoveFile}
|
|
582
|
-
>
|
|
583
|
-
<SvgRemoveFile />
|
|
584
|
-
</div>
|
|
585
|
-
</div>
|
|
586
|
-
</div>
|
|
587
|
-
|
|
588
|
-
{error ? (
|
|
589
|
-
<span
|
|
590
|
-
style={{
|
|
591
|
-
marginTop: '6px',
|
|
592
|
-
display: 'inline-block',
|
|
593
|
-
color: errorColor ? errorColor : configStyles.FILE.errorColor,
|
|
594
|
-
fontSize: errorSize ? errorSize : configStyles.FILE.errorSize,
|
|
595
|
-
}}
|
|
596
|
-
>
|
|
597
|
-
{error}
|
|
598
|
-
</span>
|
|
599
|
-
) : (
|
|
600
|
-
''
|
|
601
|
-
)}
|
|
602
|
-
|
|
603
|
-
{multiple &&
|
|
604
|
-
memoizedItems &&
|
|
605
|
-
memoizedItems.length > 0 &&
|
|
606
|
-
memoizedItems.map((item) => {
|
|
607
|
-
return (
|
|
608
|
-
<FileItem
|
|
609
|
-
key={item.uuid}
|
|
610
|
-
uuid={item.uuid}
|
|
611
|
-
check={item.check}
|
|
612
|
-
status={item.status}
|
|
613
|
-
size={item.file.size}
|
|
614
|
-
name={item.file.name}
|
|
615
|
-
timeForRemoveError={timeForRemoveError}
|
|
616
|
-
removeFile={removeFile ? removeFile : (_) => _}
|
|
617
|
-
radius={radius ? radius : configStyles.FILE.radius}
|
|
618
|
-
fileFormat={item.file.type.split('/')[1]?.toLowerCase()}
|
|
619
|
-
progressColor={progressColor ? progressColor : configStyles.FILE.progressColor}
|
|
620
|
-
listItemHeight={listItemHeight ? listItemHeight : configStyles.FILE.listItemHeight}
|
|
621
|
-
listItemPadding={listItemPadding ? listItemPadding : configStyles.FILE.listItemPadding}
|
|
622
|
-
progressFontSize={progressFontSize ? progressFontSize : configStyles.FILE.progressFontSize}
|
|
623
|
-
listItemErrorSize={
|
|
624
|
-
listItemErrorSize ? listItemErrorSize : configStyles.FILE.listItemErrorSize
|
|
625
|
-
}
|
|
626
|
-
listItemErrorColor={
|
|
627
|
-
listItemErrorColor ? listItemErrorColor : configStyles.FILE.listItemErrorColor
|
|
628
|
-
}
|
|
629
|
-
progressTrackColor={
|
|
630
|
-
progressTrackColor ? progressTrackColor : configStyles.FILE.progressTrackColor
|
|
631
|
-
}
|
|
632
|
-
progressFailedColor={
|
|
633
|
-
progressFailedColor ? progressFailedColor : configStyles.FILE.progressFailedColor
|
|
634
|
-
}
|
|
635
|
-
progressSuccessColor={
|
|
636
|
-
progressSuccessColor ? progressSuccessColor : configStyles.FILE.progressSuccessColor
|
|
637
|
-
}
|
|
638
|
-
progressLoadingColor={
|
|
639
|
-
progressLoadingColor ? progressLoadingColor : configStyles.FILE.progressLoadingColor
|
|
640
|
-
}
|
|
641
|
-
listItemBackgroundColor={
|
|
642
|
-
listItemBackgroundColor
|
|
643
|
-
? listItemBackgroundColor
|
|
644
|
-
: configStyles.FILE.listItemBackgroundColor
|
|
645
|
-
}
|
|
646
|
-
listItemBackgroundErrorColor={
|
|
647
|
-
listItemBackgroundErrorColor
|
|
648
|
-
? listItemBackgroundErrorColor
|
|
649
|
-
: configStyles.FILE.listItemBackgroundErrorColor
|
|
650
|
-
}
|
|
651
|
-
/>
|
|
652
|
-
)
|
|
653
|
-
})}
|
|
654
|
-
</div>
|
|
655
|
-
)
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
NewFile.propTypes = {
|
|
659
|
-
or: PropTypes.string,
|
|
660
|
-
size: PropTypes.string,
|
|
661
|
-
preview: PropTypes.bool,
|
|
662
|
-
label: PropTypes.string,
|
|
663
|
-
color: PropTypes.string,
|
|
664
|
-
height: PropTypes.string,
|
|
665
|
-
disabled: PropTypes.bool,
|
|
666
|
-
radius: PropTypes.string,
|
|
667
|
-
border: PropTypes.string,
|
|
668
|
-
required: PropTypes.bool,
|
|
669
|
-
upload: PropTypes.string,
|
|
670
|
-
weight: PropTypes.number,
|
|
671
|
-
maxSize: PropTypes.number,
|
|
672
|
-
maxWidth: PropTypes.string,
|
|
673
|
-
removeFile: PropTypes.func,
|
|
674
|
-
className: PropTypes.string,
|
|
675
|
-
errorSize: PropTypes.string,
|
|
676
|
-
labelSize: PropTypes.string,
|
|
677
|
-
labelColor: PropTypes.string,
|
|
678
|
-
errorColor: PropTypes.string,
|
|
679
|
-
formatError: PropTypes.string,
|
|
680
|
-
putFileHere: PropTypes.string,
|
|
681
|
-
borderColor: PropTypes.string,
|
|
682
|
-
uploadColor: PropTypes.string,
|
|
683
|
-
defaultData: PropTypes.object,
|
|
684
|
-
componentId: PropTypes.number,
|
|
685
|
-
maxSizeError: PropTypes.string,
|
|
686
|
-
errorMessage: PropTypes.string,
|
|
687
|
-
fileSizeText: PropTypes.string,
|
|
688
|
-
noChoosenFile: PropTypes.string,
|
|
689
|
-
progressColor: PropTypes.string,
|
|
690
|
-
deleteComponent: PropTypes.bool,
|
|
691
|
-
removeComponent: PropTypes.func,
|
|
692
|
-
|
|
693
|
-
uploadBtnFont: PropTypes.string,
|
|
694
|
-
uploadBtnSize: PropTypes.string,
|
|
695
|
-
uploadBtnLabel: PropTypes.string,
|
|
696
|
-
uploadBtnColor: PropTypes.string,
|
|
697
|
-
uploadBtnHeight: PropTypes.string,
|
|
698
|
-
uploadBtnBackgroundColor: PropTypes.string,
|
|
699
|
-
|
|
700
|
-
listItemHeight: PropTypes.string,
|
|
701
|
-
backgroundColor: PropTypes.string,
|
|
702
|
-
change: PropTypes.func.isRequired,
|
|
703
|
-
listItemPadding: PropTypes.string,
|
|
704
|
-
maxCHoosenLength: PropTypes.number,
|
|
705
|
-
progressFontSize: PropTypes.string,
|
|
706
|
-
borderHoverColor: PropTypes.string,
|
|
707
|
-
listItemErrorSize: PropTypes.string,
|
|
708
|
-
timeForRemoveError: PropTypes.number,
|
|
709
|
-
progressTrackColor: PropTypes.string,
|
|
710
|
-
fileAreaImageWidth: PropTypes.string,
|
|
711
|
-
listItemErrorColor: PropTypes.string,
|
|
712
|
-
fileAreaImageHeight: PropTypes.string,
|
|
713
|
-
progressFailedColor: PropTypes.string,
|
|
714
|
-
progressSuccessColor: PropTypes.string,
|
|
715
|
-
progressLoadingColor: PropTypes.string,
|
|
716
|
-
hiddenBackgroundColor: PropTypes.string,
|
|
717
|
-
maxCHoosenLengthError: PropTypes.string,
|
|
718
|
-
extentionsRowMarginTop: PropTypes.string,
|
|
719
|
-
listItemBackgroundColor: PropTypes.string,
|
|
720
|
-
listItemBackgroundErrorColor: PropTypes.string,
|
|
721
|
-
maxCHoosenLengthErrorHideTime: PropTypes.number,
|
|
722
|
-
filesArray: PropTypes.arrayOf(PropTypes.object),
|
|
723
|
-
fileExtensions: PropTypes.arrayOf(PropTypes.string),
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
NewFile.defaultProps = {
|
|
727
|
-
maxSize: 10,
|
|
728
|
-
preview: true,
|
|
729
|
-
timeForRemoveError: 5000,
|
|
730
|
-
fileExtensions: ['jpg', 'jpeg', 'png', 'pdf', 'heic'],
|
|
731
|
-
}
|