@xaypay/tui 0.0.71 → 0.0.72
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 +454 -166
- package/dist/index.js +454 -166
- package/package.json +1 -1
- package/src/components/autocomplate/autocomplate.stories.js +1 -1
- package/src/components/icon/ListItemJpeg.js +21 -0
- package/src/components/icon/ListItemPng.js +21 -0
- package/src/components/icon/index.js +2 -1
- package/src/components/input/index.js +22 -15
- package/src/components/input/input.stories.js +11 -5
- package/src/components/newAutocomplete/NewAutocomplete.stories.js +26 -26
- package/src/components/newAutocomplete/index.js +113 -92
- package/src/components/newFile/fileItem.js +213 -0
- package/src/components/newFile/index.js +154 -129
- package/src/components/newFile/newFile.stories.js +5 -2
- package/src/components/textarea/index.js +30 -1
- package/src/stories/configuration.stories.mdx +42 -0
- package/src/stories/static/autocomplete-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/tooltip-usage.png +0 -0
- package/src/stories/usage.stories.mdx +17 -8
- package/tui.config.js +20 -2
- package/src/stories/static/input-tooltip-usage.png +0 -0
- package/src/stories/static/new-autocomplete-usage.png +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import React, { useRef, useState, useEffect } from 'react';
|
|
1
|
+
import React, { useRef, useState, useEffect, useMemo } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { v4 as uuidv4 } from 'uuid';
|
|
5
5
|
|
|
6
|
+
import FileItem from './fileItem';
|
|
7
|
+
|
|
6
8
|
import { compereConfigs } from './../../utils';
|
|
7
9
|
|
|
10
|
+
import SvgPdf from './../icon/PDF';
|
|
8
11
|
import SvgUpload from './../icon/Upload';
|
|
9
12
|
import SvgRemoveFile from './../icon/RemoveFile';
|
|
10
|
-
import SvgListItemPdf from './../icon/ListItemPdf';
|
|
11
|
-
import SvgListItemJpg from './../icon/ListItemJpg';
|
|
12
|
-
import SvgListItemDelete from './../icon/ListItemDelete';
|
|
13
13
|
import SvgDeleteComponent from './../icon/DeleteComponent';
|
|
14
14
|
|
|
15
15
|
export const NewFile = ({
|
|
16
|
+
or,
|
|
16
17
|
size,
|
|
17
18
|
name,
|
|
18
19
|
color,
|
|
@@ -23,36 +24,53 @@ export const NewFile = ({
|
|
|
23
24
|
radius,
|
|
24
25
|
change,
|
|
25
26
|
border,
|
|
27
|
+
upload,
|
|
26
28
|
maxSize,
|
|
27
29
|
disabled,
|
|
28
30
|
multiple,
|
|
29
31
|
required,
|
|
30
32
|
errorSize,
|
|
31
33
|
labelSize,
|
|
34
|
+
removeFile,
|
|
32
35
|
labelColor,
|
|
33
36
|
errorColor,
|
|
34
37
|
filesArray,
|
|
38
|
+
putFileHere,
|
|
35
39
|
borderColor,
|
|
36
40
|
uploadColor,
|
|
37
41
|
defaultData,
|
|
38
42
|
errorMessage,
|
|
43
|
+
fileSizeText,
|
|
44
|
+
progressColor,
|
|
39
45
|
fileExtensions,
|
|
46
|
+
listItemHeight,
|
|
40
47
|
backgroundColor,
|
|
41
48
|
deleteComponent,
|
|
49
|
+
listItemPadding,
|
|
50
|
+
progressFontSize,
|
|
42
51
|
borderHoverColor,
|
|
52
|
+
listItemErrorSize,
|
|
43
53
|
progressTrackColor,
|
|
54
|
+
fileAreaImageWidth,
|
|
55
|
+
listItemErrorColor,
|
|
44
56
|
labelRequiredColor,
|
|
57
|
+
progressFailedColor,
|
|
58
|
+
fileAreaImageHeight,
|
|
59
|
+
progressSuccessColor,
|
|
60
|
+
progressLoadingColor,
|
|
45
61
|
hiddenBackgroundColor,
|
|
46
62
|
extentionsRowMarginTop,
|
|
47
|
-
listItemBackgroundColor
|
|
63
|
+
listItemBackgroundColor,
|
|
64
|
+
listItemBackgroundErrorColor
|
|
48
65
|
}) => {
|
|
49
66
|
const ref = useRef(null);
|
|
50
67
|
const inpRef = useRef(null);
|
|
68
|
+
const memoizedItems = useMemo(() => filesArray, [filesArray]);
|
|
69
|
+
|
|
51
70
|
const [error, setError] = useState('');
|
|
52
|
-
const [image, setImage] = useState('');
|
|
53
|
-
const [progress, setProgress] = useState(5);
|
|
54
71
|
const [isHover, setIsHover] = useState(false);
|
|
55
|
-
const [
|
|
72
|
+
const [singleFile, setSingleFile] = useState(null);
|
|
73
|
+
const [image, setImage] = useState(!multiple ? defaultData ? defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf' : null : null);
|
|
56
74
|
|
|
57
75
|
const configStyles = compereConfigs();
|
|
58
76
|
|
|
@@ -63,44 +81,69 @@ export const NewFile = ({
|
|
|
63
81
|
};
|
|
64
82
|
|
|
65
83
|
const handleRemoveFile = () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
onChange(null);
|
|
69
|
-
}
|
|
84
|
+
setImage(null);
|
|
85
|
+
removeFile(singleFile);
|
|
70
86
|
};
|
|
71
87
|
|
|
72
88
|
const handleChange = (e) => {
|
|
73
89
|
const file = e.target.files;
|
|
74
90
|
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
91
|
+
if (multiple) {
|
|
92
|
+
setError('');
|
|
93
|
+
setImage(null);
|
|
94
|
+
for (let ix = 0; ix < file.length; ix++) {
|
|
95
|
+
if (file[ix]) {
|
|
96
|
+
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
97
|
+
if (fileExtensions.includes(file[ix].type.split('/')[1])) {
|
|
98
|
+
change({
|
|
99
|
+
id: '',
|
|
100
|
+
check: '',
|
|
101
|
+
status: '',
|
|
102
|
+
file: file[ix],
|
|
103
|
+
uuid: uuidv4()
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
change({
|
|
107
|
+
file: file[ix],
|
|
108
|
+
uuid: uuidv4(),
|
|
109
|
+
check: 'ֆայլի սխալ ֆորմատ'
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
80
113
|
change({
|
|
114
|
+
file: file[ix],
|
|
81
115
|
uuid: uuidv4(),
|
|
82
|
-
|
|
116
|
+
check: 'առավելագույն ծավալ'
|
|
83
117
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (file.length === 0 && memoizedItems.length === 0) {
|
|
122
|
+
setError('Ֆայլը ընտրված չէ');
|
|
123
|
+
}
|
|
124
|
+
} else {
|
|
125
|
+
if (file[0]) {
|
|
126
|
+
if (file[0].size <= maxSize * Math.pow(2, 20)) {
|
|
127
|
+
if (fileExtensions.includes(file[0].type.split('/')[1])) {
|
|
128
|
+
setError('');
|
|
129
|
+
change(file);
|
|
130
|
+
setSingleFile(file);
|
|
86
131
|
if (file[0].type === 'application/pdf') {
|
|
87
132
|
setImage('pdf');
|
|
88
133
|
} else {
|
|
89
134
|
setImage(URL.createObjectURL(file[0]));
|
|
90
135
|
}
|
|
136
|
+
} else {
|
|
137
|
+
setImage(null);
|
|
138
|
+
setError('ֆայլի սխալ ֆորմատ');
|
|
91
139
|
}
|
|
92
140
|
} else {
|
|
93
|
-
setImage(
|
|
94
|
-
setError('
|
|
141
|
+
setImage(null);
|
|
142
|
+
setError('առավելագույն ծավալ');
|
|
95
143
|
}
|
|
96
|
-
} else {
|
|
97
|
-
setImage('')
|
|
98
|
-
setError('առավելագույն ծավալ');
|
|
99
144
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!multiple || multiple && filesArray && filesArray.length === 0) {
|
|
103
|
-
setImage('');
|
|
145
|
+
if (file.length === 0) {
|
|
146
|
+
setImage(null);
|
|
104
147
|
setError('Ֆայլը ընտրված չէ');
|
|
105
148
|
}
|
|
106
149
|
}
|
|
@@ -112,6 +155,19 @@ export const NewFile = ({
|
|
|
112
155
|
}
|
|
113
156
|
};
|
|
114
157
|
|
|
158
|
+
const handleDrop = (e) => {
|
|
159
|
+
if (!disabled) {
|
|
160
|
+
e.preventDefault();
|
|
161
|
+
handleChange({target: { files: e.dataTransfer.files }});
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const handleDragOver = (e) => {
|
|
166
|
+
if (!disabled) {
|
|
167
|
+
e.preventDefault();
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
115
171
|
const handleMouseEnter = () => {
|
|
116
172
|
setIsHover(true);
|
|
117
173
|
};
|
|
@@ -126,10 +182,12 @@ export const NewFile = ({
|
|
|
126
182
|
|
|
127
183
|
useEffect(() => {
|
|
128
184
|
if (!multiple && defaultData) {
|
|
129
|
-
if (defaultData.type
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
185
|
+
if (!defaultData.type) {
|
|
186
|
+
alert('Please add type in defaultData prop');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (!defaultData.url) {
|
|
190
|
+
alert('Please add url in defaultData prop');
|
|
133
191
|
}
|
|
134
192
|
}
|
|
135
193
|
|
|
@@ -137,8 +195,8 @@ export const NewFile = ({
|
|
|
137
195
|
alert('In multiple mode, you should add filesArray prop for drawing files');
|
|
138
196
|
}
|
|
139
197
|
|
|
140
|
-
if (
|
|
141
|
-
|
|
198
|
+
if (multiple) {
|
|
199
|
+
setSingleFile(null);
|
|
142
200
|
}
|
|
143
201
|
}, [multiple, filesArray && filesArray.length, defaultData]);
|
|
144
202
|
|
|
@@ -154,15 +212,17 @@ export const NewFile = ({
|
|
|
154
212
|
if (!change) {
|
|
155
213
|
alert('Please add change prop on File component');
|
|
156
214
|
}
|
|
157
|
-
}, [change]);
|
|
158
215
|
|
|
159
|
-
|
|
216
|
+
if (!removeFile) {
|
|
217
|
+
alert('Please add removeFile prop on File component');
|
|
218
|
+
}
|
|
219
|
+
}, [change, removeFile]);
|
|
160
220
|
|
|
161
221
|
return (
|
|
162
222
|
<div
|
|
163
223
|
ref={ref}
|
|
164
224
|
style={{
|
|
165
|
-
width: width ? width : configStyles.File.width
|
|
225
|
+
width: width ? width : configStyles.File.width
|
|
166
226
|
}}
|
|
167
227
|
>
|
|
168
228
|
<div
|
|
@@ -195,7 +255,6 @@ export const NewFile = ({
|
|
|
195
255
|
}
|
|
196
256
|
</div>
|
|
197
257
|
|
|
198
|
-
|
|
199
258
|
<div
|
|
200
259
|
style={{
|
|
201
260
|
width: '100%',
|
|
@@ -216,7 +275,9 @@ export const NewFile = ({
|
|
|
216
275
|
isHover ? borderHoverColor ? borderHoverColor : configStyles.File.borderHoverColor :
|
|
217
276
|
borderColor ? borderColor : configStyles.File.borderColor
|
|
218
277
|
}}
|
|
278
|
+
onDrop={handleDrop}
|
|
219
279
|
onClick={handleClick}
|
|
280
|
+
onDragOver={handleDragOver}
|
|
220
281
|
onMouseEnter={handleMouseEnter}
|
|
221
282
|
onMouseLeave={handleMouseLeave}
|
|
222
283
|
>
|
|
@@ -226,6 +287,7 @@ export const NewFile = ({
|
|
|
226
287
|
type='file'
|
|
227
288
|
ref={inpRef}
|
|
228
289
|
disabled={disabled}
|
|
290
|
+
multiple={multiple}
|
|
229
291
|
onChange={handleChange}
|
|
230
292
|
/>
|
|
231
293
|
|
|
@@ -246,11 +308,16 @@ export const NewFile = ({
|
|
|
246
308
|
{
|
|
247
309
|
!multiple && image ?
|
|
248
310
|
image === 'pdf' ?
|
|
249
|
-
<
|
|
311
|
+
<SvgPdf /> :
|
|
250
312
|
<img
|
|
251
313
|
src={image}
|
|
252
314
|
style={{
|
|
253
|
-
|
|
315
|
+
display: 'block',
|
|
316
|
+
maxWidth: '100%',
|
|
317
|
+
maxHeight: '95%',
|
|
318
|
+
objectFit: 'contain',
|
|
319
|
+
width: fileAreaImageWidth ? fileAreaImageWidth : configStyles.File.fileAreaImageWidth,
|
|
320
|
+
height: fileAreaImageHeight ? fileAreaImageHeight : configStyles.File.fileAreaImageHeight,
|
|
254
321
|
}}
|
|
255
322
|
alt='file preview'
|
|
256
323
|
/>
|
|
@@ -265,13 +332,13 @@ export const NewFile = ({
|
|
|
265
332
|
margin: '0px'
|
|
266
333
|
}}
|
|
267
334
|
>
|
|
268
|
-
|
|
335
|
+
{putFileHere ? putFileHere : configStyles.File.putFileHere}
|
|
269
336
|
<br />
|
|
270
|
-
|
|
337
|
+
{or ? or : configStyles.File.or} <span
|
|
271
338
|
style={{
|
|
272
339
|
color: uploadColor ? uploadColor : configStyles.File.uploadColor
|
|
273
340
|
}}
|
|
274
|
-
|
|
341
|
+
>{upload ? upload : configStyles.File.upload}</span>
|
|
275
342
|
</p>
|
|
276
343
|
</div>
|
|
277
344
|
|
|
@@ -285,15 +352,13 @@ export const NewFile = ({
|
|
|
285
352
|
margin: '0px'
|
|
286
353
|
}}
|
|
287
354
|
>
|
|
288
|
-
|
|
355
|
+
{fileSizeText ? fileSizeText : configStyles.File.fileSizeText} {maxSize}ՄԲ ( { fileExtensions.toString().split(',').join(', ') } )
|
|
289
356
|
</p>
|
|
290
357
|
</div>
|
|
291
358
|
</>
|
|
292
359
|
}
|
|
293
360
|
</div>
|
|
294
361
|
|
|
295
|
-
|
|
296
|
-
|
|
297
362
|
<div
|
|
298
363
|
style={{
|
|
299
364
|
position: 'absolute',
|
|
@@ -337,94 +402,38 @@ export const NewFile = ({
|
|
|
337
402
|
|
|
338
403
|
|
|
339
404
|
{
|
|
340
|
-
multiple &&
|
|
341
|
-
return
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
item.file.type.split('/')[1].toLowerCase() === 'jpeg' ? <SvgListItemJpg /> : ''
|
|
365
|
-
}
|
|
366
|
-
</div>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
<div
|
|
370
|
-
style={{
|
|
371
|
-
position: 'relative',
|
|
372
|
-
display: 'flex',
|
|
373
|
-
height: '40px',
|
|
374
|
-
margin: '0px 14px',
|
|
375
|
-
alignItems: 'flex-end',
|
|
376
|
-
width: 'calc(100% - 82px)',
|
|
377
|
-
}}
|
|
378
|
-
>
|
|
379
|
-
|
|
380
|
-
<div>
|
|
381
|
-
<p className='new' >{item.file.name}</p>
|
|
382
|
-
</div>
|
|
383
|
-
|
|
384
|
-
<div
|
|
385
|
-
style={{
|
|
386
|
-
position: 'absolute',
|
|
387
|
-
left: '0px',
|
|
388
|
-
bottom: '5px',
|
|
389
|
-
width: '100%',
|
|
390
|
-
height: '4px',
|
|
391
|
-
borderRadius: '10px',
|
|
392
|
-
backgroundColor: progressTrackColor ? progressTrackColor : configStyles.File.progressTrackColor
|
|
393
|
-
}}
|
|
394
|
-
>
|
|
395
|
-
<div
|
|
396
|
-
style={{
|
|
397
|
-
width: progress + '%',
|
|
398
|
-
height: '100%',
|
|
399
|
-
borderRadius: '10px',
|
|
400
|
-
backgroundColor: 'green'
|
|
401
|
-
}}
|
|
402
|
-
>
|
|
403
|
-
|
|
404
|
-
</div>
|
|
405
|
-
</div>
|
|
406
|
-
|
|
407
|
-
</div>
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
<div
|
|
411
|
-
style={{
|
|
412
|
-
width: '22px',
|
|
413
|
-
cursor: 'pointer'
|
|
414
|
-
}}
|
|
415
|
-
>
|
|
416
|
-
<SvgListItemDelete />
|
|
417
|
-
</div>
|
|
418
|
-
</div>
|
|
419
|
-
)
|
|
405
|
+
multiple && memoizedItems && memoizedItems.length > 0 && memoizedItems.map(item => {
|
|
406
|
+
return <FileItem
|
|
407
|
+
key={item.uuid}
|
|
408
|
+
uuid={item.uuid}
|
|
409
|
+
check={item.check}
|
|
410
|
+
status={item.status}
|
|
411
|
+
size={item.file.size}
|
|
412
|
+
name={item.file.name}
|
|
413
|
+
removeFile={removeFile}
|
|
414
|
+
radius={radius ? radius : configStyles.File.radius}
|
|
415
|
+
fileFormat={item.file.type.split('/')[1].toLowerCase()}
|
|
416
|
+
progressColor={progressColor ? progressColor : configStyles.File.progressColor}
|
|
417
|
+
listItemHeight={listItemHeight ? listItemHeight : configStyles.File.listItemHeight}
|
|
418
|
+
listItemPadding={listItemPadding ? listItemPadding : configStyles.File.listItemPadding}
|
|
419
|
+
progressFontSize={progressFontSize ? progressFontSize : configStyles.File.progressFontSize}
|
|
420
|
+
listItemErrorSize={listItemErrorSize ? listItemErrorSize : configStyles.File.listItemErrorSize}
|
|
421
|
+
listItemErrorColor={listItemErrorColor ? listItemErrorColor : configStyles.File.listItemErrorColor}
|
|
422
|
+
progressTrackColor={progressTrackColor ? progressTrackColor : configStyles.File.progressTrackColor}
|
|
423
|
+
progressFailedColor={progressFailedColor ? progressFailedColor : configStyles.File.progressFailedColor}
|
|
424
|
+
progressSuccessColor={progressSuccessColor ? progressSuccessColor : configStyles.File.progressSuccessColor}
|
|
425
|
+
progressLoadingColor={progressLoadingColor ? progressLoadingColor : configStyles.File.progressLoadingColor}
|
|
426
|
+
listItemBackgroundColor={listItemBackgroundColor ? listItemBackgroundColor : configStyles.File.listItemBackgroundColor}
|
|
427
|
+
listItemBackgroundErrorColor={listItemBackgroundErrorColor ? listItemBackgroundErrorColor : configStyles.File.listItemBackgroundErrorColor}
|
|
428
|
+
/>
|
|
420
429
|
})
|
|
421
430
|
}
|
|
422
|
-
|
|
423
431
|
</div>
|
|
424
432
|
);
|
|
425
433
|
};
|
|
426
434
|
|
|
427
435
|
NewFile.propTypes = {
|
|
436
|
+
or: PropTypes.string,
|
|
428
437
|
size: PropTypes.string,
|
|
429
438
|
label: PropTypes.string,
|
|
430
439
|
width: PropTypes.string,
|
|
@@ -434,30 +443,46 @@ NewFile.propTypes = {
|
|
|
434
443
|
radius: PropTypes.string,
|
|
435
444
|
border: PropTypes.string,
|
|
436
445
|
required: PropTypes.bool,
|
|
446
|
+
upload: PropTypes.string,
|
|
437
447
|
weight: PropTypes.number,
|
|
438
448
|
maxSize: PropTypes.number,
|
|
439
449
|
errorSize: PropTypes.string,
|
|
440
450
|
labelSize: PropTypes.string,
|
|
441
451
|
labelColor: PropTypes.string,
|
|
442
452
|
errorColor: PropTypes.string,
|
|
453
|
+
putFileHere: PropTypes.string,
|
|
443
454
|
borderColor: PropTypes.string,
|
|
444
455
|
uploadColor: PropTypes.string,
|
|
445
456
|
defaultData: PropTypes.object,
|
|
446
457
|
errorMessage: PropTypes.string,
|
|
458
|
+
fileSizeText: PropTypes.string,
|
|
459
|
+
progressColor: PropTypes.string,
|
|
447
460
|
deleteComponent: PropTypes.bool,
|
|
461
|
+
listItemHeight: PropTypes.string,
|
|
448
462
|
backgroundColor: PropTypes.string,
|
|
449
463
|
change: PropTypes.func.isRequired,
|
|
464
|
+
listItemPadding: PropTypes.string,
|
|
465
|
+
progressFontSize: PropTypes.string,
|
|
450
466
|
borderHoverColor: PropTypes.string,
|
|
467
|
+
listItemErrorSize: PropTypes.string,
|
|
451
468
|
labelRequiredColor: PropTypes.string,
|
|
452
469
|
progressTrackColor: PropTypes.string,
|
|
470
|
+
fileAreaImageWidth: PropTypes.string,
|
|
471
|
+
listItemErrorColor: PropTypes.string,
|
|
472
|
+
removeFile: PropTypes.func.isRequired,
|
|
473
|
+
fileAreaImageHeight: PropTypes.string,
|
|
474
|
+
progressFailedColor: PropTypes.string,
|
|
475
|
+
progressSuccessColor: PropTypes.string,
|
|
476
|
+
progressLoadingColor: PropTypes.string,
|
|
453
477
|
hiddenBackgroundColor: PropTypes.string,
|
|
454
478
|
extentionsRowMarginTop: PropTypes.string,
|
|
455
479
|
listItemBackgroundColor: PropTypes.string,
|
|
480
|
+
listItemBackgroundErrorColor: PropTypes.string,
|
|
456
481
|
filesArray: PropTypes.arrayOf(PropTypes.object),
|
|
457
482
|
fileExtensions: PropTypes.arrayOf(PropTypes.string)
|
|
458
483
|
};
|
|
459
484
|
|
|
460
485
|
NewFile.defaultProps = {
|
|
461
|
-
maxSize:
|
|
486
|
+
maxSize: 50,
|
|
462
487
|
fileExtensions: ['jpg', 'jpeg', 'png', 'pdf']
|
|
463
488
|
};
|
|
@@ -23,8 +23,11 @@ const Template = (args) => {
|
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
|
|
26
|
+
const handleRemove = (id) => {
|
|
27
|
+
setFiles(prevItems => prevItems.filter(item => item.uuid !== id));
|
|
28
|
+
};
|
|
26
29
|
|
|
27
|
-
return <NewFile change={handleChange} filesArray={files} {...args} />;
|
|
30
|
+
return <NewFile change={handleChange} filesArray={files} removeFile={handleRemove} {...args} />;
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
export const Default = Template.bind({});
|
|
@@ -34,7 +37,7 @@ Default.args = {
|
|
|
34
37
|
disabled: false,
|
|
35
38
|
defaultData: {
|
|
36
39
|
url: 'https://images.pexels.com/photos/753626/pexels-photo-753626.jpeg?auto=compress&cs=tinysrgb&w=1600',
|
|
37
|
-
type:
|
|
40
|
+
type: 'image/png',
|
|
38
41
|
},
|
|
39
42
|
multiple: true,
|
|
40
43
|
name: 'sss'
|
|
@@ -24,17 +24,21 @@ export const Textarea = ({
|
|
|
24
24
|
boxSizing,
|
|
25
25
|
maxLength,
|
|
26
26
|
labelSize,
|
|
27
|
+
errorSize,
|
|
27
28
|
labelColor,
|
|
29
|
+
errorColor,
|
|
28
30
|
borderColor,
|
|
29
31
|
labelWeight,
|
|
30
32
|
placeholder,
|
|
31
33
|
labelDisplay,
|
|
34
|
+
errorMesaage,
|
|
32
35
|
backgroundColor,
|
|
33
36
|
borderFocusColor,
|
|
34
37
|
borderHoverColor,
|
|
35
38
|
showCharacterCount,
|
|
36
39
|
labelRequiredColor
|
|
37
40
|
}) => {
|
|
41
|
+
const [error, setError] = useState('');
|
|
38
42
|
const [isHover, setIsHover] = useState(false);
|
|
39
43
|
const [isFocus, setIsFocus] = useState(false);
|
|
40
44
|
const [innerValue, setInnerValue] = useState('');
|
|
@@ -63,10 +67,16 @@ export const Textarea = ({
|
|
|
63
67
|
if (maxLength) {
|
|
64
68
|
if (value.length > maxLength) {
|
|
65
69
|
onChange(value.substr(0, maxLength));
|
|
70
|
+
setError('Նիշերի քանակը գերազանցում է');
|
|
71
|
+
} else {
|
|
72
|
+
setError('');
|
|
66
73
|
}
|
|
67
74
|
} else {
|
|
68
75
|
if (value.length > configStyles.TEXTAREA.maxLength) {
|
|
76
|
+
setError('Նիշերի քանակը գերազանցում է');
|
|
69
77
|
onChange(value.substr(0, configStyles.TEXTAREA.maxLength));
|
|
78
|
+
} else {
|
|
79
|
+
setError('');
|
|
70
80
|
}
|
|
71
81
|
}
|
|
72
82
|
};
|
|
@@ -83,6 +93,14 @@ export const Textarea = ({
|
|
|
83
93
|
setInnerValue(value);
|
|
84
94
|
}, [value, onChange]);
|
|
85
95
|
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
if (errorMesaage) {
|
|
98
|
+
setError(errorMesaage);
|
|
99
|
+
} else {
|
|
100
|
+
setError('');
|
|
101
|
+
}
|
|
102
|
+
}, [errorMesaage]);
|
|
103
|
+
|
|
86
104
|
return (
|
|
87
105
|
<div
|
|
88
106
|
style={{
|
|
@@ -140,7 +158,8 @@ export const Textarea = ({
|
|
|
140
158
|
maxHeight: maxHeight ? maxHeight : configStyles.TEXTAREA.maxHeight,
|
|
141
159
|
boxSizing: boxSizing ? boxSizing : configStyles.TEXTAREA.boxSizing,
|
|
142
160
|
backgroundColor: backgroundColor ? backgroundColor : configStyles.TEXTAREA.backgroundColor,
|
|
143
|
-
borderColor:
|
|
161
|
+
borderColor: error ? errorColor ? errorColor : configStyles.TEXTAREA.errorColor :
|
|
162
|
+
isFocus ? borderFocusColor ? borderFocusColor : configStyles.TEXTAREA.borderFocusColor :
|
|
144
163
|
isHover ? borderHoverColor ? borderHoverColor : configStyles.TEXTAREA.borderHoverColor :
|
|
145
164
|
borderColor ? borderColor : configStyles.TEXTAREA.borderColor,
|
|
146
165
|
resize: resize ? resize : configStyles.TEXTAREA.resize,
|
|
@@ -153,6 +172,16 @@ export const Textarea = ({
|
|
|
153
172
|
onMouseEnter={handleMouseEnter}
|
|
154
173
|
onMouseLeave={handleMouseLeave}
|
|
155
174
|
></textarea>
|
|
175
|
+
{
|
|
176
|
+
error ? <span
|
|
177
|
+
style={{
|
|
178
|
+
marginTop: '6px',
|
|
179
|
+
display: 'inline-block',
|
|
180
|
+
fontSize: errorSize ? errorSize : configStyles.TEXTAREA.errorSize,
|
|
181
|
+
color: errorColor ? errorColor : configStyles.TEXTAREA.errorColor,
|
|
182
|
+
}}
|
|
183
|
+
>{ error }</span> : ''
|
|
184
|
+
}
|
|
156
185
|
</div>
|
|
157
186
|
);
|
|
158
187
|
};
|
|
@@ -519,4 +519,46 @@ import StackAlt from './assets/stackalt.svg';
|
|
|
519
519
|
range: 'for example. 72', // for captcha range (add itself on each component)
|
|
520
520
|
getRange: 'is must be function', // for captcha get current range (add itself on each component)
|
|
521
521
|
}
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### NewFile
|
|
525
|
+
```
|
|
526
|
+
{
|
|
527
|
+
or: 'կամ', // for file place text
|
|
528
|
+
weight: 400, // for file place font weight
|
|
529
|
+
size: '12px', // for file font size
|
|
530
|
+
radius: '6px', // for file place border radius
|
|
531
|
+
width: '440px', // for file width
|
|
532
|
+
height: '200px', // for file choose place height
|
|
533
|
+
color: '#3C393E', // for file place color
|
|
534
|
+
upload: 'Բեռնել', // for file place text
|
|
535
|
+
labelSize: '16px', // for file font size
|
|
536
|
+
border: '2px dashed', // for file choose place border
|
|
537
|
+
errorColor: '#ee0000', // for file error message color
|
|
538
|
+
labelColor: '#4A4A4D', // for file color
|
|
539
|
+
errorColor: '#ee0000', // for file place error color
|
|
540
|
+
borderColor: '#D1D1D1', // for file choose place border color
|
|
541
|
+
listItemHeight: '70px', // for file list item height
|
|
542
|
+
uploadColor: '#0DA574', // for file place upload text color
|
|
543
|
+
progressColor: '#4A4A4D', // for file progress bar color
|
|
544
|
+
progressFontSize: '16px', // for file progress bar font size
|
|
545
|
+
listItemErrorSize: '16px', // for file multiple mode error font size
|
|
546
|
+
backgroundColor: '#F8F8F8', // for file choose place background color
|
|
547
|
+
listItemErrorColor: 'black', // for file multiple mode error color
|
|
548
|
+
borderHoverColor: '#00236A', // for file border color, when hover is happening
|
|
549
|
+
fileAreaImageHeight: 'auto', // for file place choosen image preview height
|
|
550
|
+
listItemPadding: '14px 20px', // for file list item padding
|
|
551
|
+
fileSizeText: 'Առավելագույնը', // for file place file size text
|
|
552
|
+
fileAreaImageWidth: '27.8rem', // for file place choosen image preview width
|
|
553
|
+
labelRequiredColor: '#ee0000', // for file label required color
|
|
554
|
+
progressTrackColor: '#E5E8E8', // for file item progress track background color
|
|
555
|
+
extentionsRowMarginTop: '40px', // for file extentions row margin top
|
|
556
|
+
progressFailedColor: '#E40E00', // for file list item progress backfround color when file upload is failed
|
|
557
|
+
progressSuccessColor: '#069768', // for file list item progress background color when file upload is success
|
|
558
|
+
progressLoadingColor: '#051942', // for file list item progress background color when file upload is loading
|
|
559
|
+
listItemBackgroundColor: '#F6F8F8', // for file list item background color
|
|
560
|
+
putFileHere: 'Տեղադրել ֆայլը այստեղ', // for file place text
|
|
561
|
+
hiddenBackgroundColor: 'rgba(60, 57, 62, 0.4)', // for file place background color when hover on file place and there is a choosen file
|
|
562
|
+
listItemBackgroundErrorColor: 'rgba(255, 0, 0, 0.7)', // for file multiple mode error background color
|
|
563
|
+
}
|
|
522
564
|
```
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|