@xaypay/tui 0.0.118 → 0.0.120

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