@xaypay/tui 0.0.71 → 0.0.73
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 +537 -176
- package/dist/index.js +537 -176
- 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 +161 -130
- package/src/components/newFile/newFile.stories.js +6 -3
- package/src/components/pagination/index.js +74 -3
- package/src/components/pagination/pagination.module.css +13 -1
- package/src/components/pagination/pagination.stories.js +4 -2
- package/src/components/select/index.js +9 -2
- package/src/components/select/select.stories.js +0 -1
- package/src/components/textarea/index.js +30 -1
- package/src/components/typography/index.js +1 -1
- package/src/components/typography/typography.stories.js +2 -1
- package/src/stories/configuration.stories.mdx +45 -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 +31 -19
- 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,56 @@ 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,
|
|
42
|
+
formatError,
|
|
38
43
|
errorMessage,
|
|
44
|
+
fileSizeText,
|
|
45
|
+
maxSizeError,
|
|
46
|
+
progressColor,
|
|
47
|
+
noChoosenFile,
|
|
39
48
|
fileExtensions,
|
|
49
|
+
listItemHeight,
|
|
40
50
|
backgroundColor,
|
|
41
51
|
deleteComponent,
|
|
52
|
+
listItemPadding,
|
|
53
|
+
progressFontSize,
|
|
42
54
|
borderHoverColor,
|
|
55
|
+
listItemErrorSize,
|
|
43
56
|
progressTrackColor,
|
|
57
|
+
fileAreaImageWidth,
|
|
58
|
+
listItemErrorColor,
|
|
44
59
|
labelRequiredColor,
|
|
60
|
+
progressFailedColor,
|
|
61
|
+
fileAreaImageHeight,
|
|
62
|
+
progressSuccessColor,
|
|
63
|
+
progressLoadingColor,
|
|
45
64
|
hiddenBackgroundColor,
|
|
46
65
|
extentionsRowMarginTop,
|
|
47
|
-
listItemBackgroundColor
|
|
66
|
+
listItemBackgroundColor,
|
|
67
|
+
listItemBackgroundErrorColor
|
|
48
68
|
}) => {
|
|
49
69
|
const ref = useRef(null);
|
|
50
70
|
const inpRef = useRef(null);
|
|
71
|
+
const memoizedItems = useMemo(() => filesArray, [filesArray]);
|
|
72
|
+
|
|
51
73
|
const [error, setError] = useState('');
|
|
52
|
-
const [image, setImage] = useState('');
|
|
53
|
-
const [progress, setProgress] = useState(5);
|
|
54
74
|
const [isHover, setIsHover] = useState(false);
|
|
55
|
-
const [
|
|
75
|
+
const [singleFile, setSingleFile] = useState(null);
|
|
76
|
+
const [image, setImage] = useState(!multiple ? defaultData ? defaultData.type !== 'application/pdf' ? defaultData.url : 'pdf' : null : null);
|
|
56
77
|
|
|
57
78
|
const configStyles = compereConfigs();
|
|
58
79
|
|
|
@@ -63,45 +84,70 @@ export const NewFile = ({
|
|
|
63
84
|
};
|
|
64
85
|
|
|
65
86
|
const handleRemoveFile = () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
onChange(null);
|
|
69
|
-
}
|
|
87
|
+
setImage(null);
|
|
88
|
+
removeFile(singleFile);
|
|
70
89
|
};
|
|
71
90
|
|
|
72
91
|
const handleChange = (e) => {
|
|
73
92
|
const file = e.target.files;
|
|
74
93
|
|
|
75
|
-
if (
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
94
|
+
if (multiple) {
|
|
95
|
+
setError('');
|
|
96
|
+
setImage(null);
|
|
97
|
+
for (let ix = 0; ix < file.length; ix++) {
|
|
98
|
+
if (file[ix]) {
|
|
99
|
+
if (file[ix].size <= maxSize * Math.pow(2, 20)) {
|
|
100
|
+
if (fileExtensions.includes(file[ix].type.split('/')[1])) {
|
|
101
|
+
change({
|
|
102
|
+
id: '',
|
|
103
|
+
check: '',
|
|
104
|
+
status: '',
|
|
105
|
+
file: file[ix],
|
|
106
|
+
uuid: uuidv4()
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
change({
|
|
110
|
+
file: file[ix],
|
|
111
|
+
uuid: uuidv4(),
|
|
112
|
+
check: formatError
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
80
116
|
change({
|
|
117
|
+
file: file[ix],
|
|
81
118
|
uuid: uuidv4(),
|
|
82
|
-
|
|
119
|
+
check: maxSizeError
|
|
83
120
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (file.length === 0 && memoizedItems.length === 0) {
|
|
125
|
+
setError(noChoosenFile);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
if (file[0]) {
|
|
129
|
+
if (file[0].size <= maxSize * Math.pow(2, 20)) {
|
|
130
|
+
if (fileExtensions.includes(file[0].type.split('/')[1])) {
|
|
131
|
+
setError('');
|
|
132
|
+
change(file);
|
|
133
|
+
setSingleFile(file);
|
|
86
134
|
if (file[0].type === 'application/pdf') {
|
|
87
135
|
setImage('pdf');
|
|
88
136
|
} else {
|
|
89
137
|
setImage(URL.createObjectURL(file[0]));
|
|
90
138
|
}
|
|
139
|
+
} else {
|
|
140
|
+
setImage(null);
|
|
141
|
+
setError(formatError);
|
|
91
142
|
}
|
|
92
143
|
} else {
|
|
93
|
-
setImage(
|
|
94
|
-
setError(
|
|
144
|
+
setImage(null);
|
|
145
|
+
setError(maxSizeError);
|
|
95
146
|
}
|
|
96
|
-
} else {
|
|
97
|
-
setImage('')
|
|
98
|
-
setError('առավելագույն ծավալ');
|
|
99
147
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
setImage('');
|
|
104
|
-
setError('Ֆայլը ընտրված չէ');
|
|
148
|
+
if (file.length === 0) {
|
|
149
|
+
setImage(null);
|
|
150
|
+
setError(noChoosenFile);
|
|
105
151
|
}
|
|
106
152
|
}
|
|
107
153
|
};
|
|
@@ -112,6 +158,19 @@ export const NewFile = ({
|
|
|
112
158
|
}
|
|
113
159
|
};
|
|
114
160
|
|
|
161
|
+
const handleDrop = (e) => {
|
|
162
|
+
if (!disabled) {
|
|
163
|
+
e.preventDefault();
|
|
164
|
+
handleChange({target: { files: e.dataTransfer.files }});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const handleDragOver = (e) => {
|
|
169
|
+
if (!disabled) {
|
|
170
|
+
e.preventDefault();
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
|
|
115
174
|
const handleMouseEnter = () => {
|
|
116
175
|
setIsHover(true);
|
|
117
176
|
};
|
|
@@ -126,10 +185,12 @@ export const NewFile = ({
|
|
|
126
185
|
|
|
127
186
|
useEffect(() => {
|
|
128
187
|
if (!multiple && defaultData) {
|
|
129
|
-
if (defaultData.type
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
188
|
+
if (!defaultData.type) {
|
|
189
|
+
alert('Please add type in defaultData prop');
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!defaultData.url) {
|
|
193
|
+
alert('Please add url in defaultData prop');
|
|
133
194
|
}
|
|
134
195
|
}
|
|
135
196
|
|
|
@@ -137,8 +198,8 @@ export const NewFile = ({
|
|
|
137
198
|
alert('In multiple mode, you should add filesArray prop for drawing files');
|
|
138
199
|
}
|
|
139
200
|
|
|
140
|
-
if (
|
|
141
|
-
|
|
201
|
+
if (multiple) {
|
|
202
|
+
setSingleFile(null);
|
|
142
203
|
}
|
|
143
204
|
}, [multiple, filesArray && filesArray.length, defaultData]);
|
|
144
205
|
|
|
@@ -154,15 +215,17 @@ export const NewFile = ({
|
|
|
154
215
|
if (!change) {
|
|
155
216
|
alert('Please add change prop on File component');
|
|
156
217
|
}
|
|
157
|
-
}, [change]);
|
|
158
218
|
|
|
159
|
-
|
|
219
|
+
if (!removeFile) {
|
|
220
|
+
alert('Please add removeFile prop on File component');
|
|
221
|
+
}
|
|
222
|
+
}, [change, removeFile]);
|
|
160
223
|
|
|
161
224
|
return (
|
|
162
225
|
<div
|
|
163
226
|
ref={ref}
|
|
164
227
|
style={{
|
|
165
|
-
width: width ? width : configStyles.File.width
|
|
228
|
+
width: width ? width : configStyles.File.width
|
|
166
229
|
}}
|
|
167
230
|
>
|
|
168
231
|
<div
|
|
@@ -195,7 +258,6 @@ export const NewFile = ({
|
|
|
195
258
|
}
|
|
196
259
|
</div>
|
|
197
260
|
|
|
198
|
-
|
|
199
261
|
<div
|
|
200
262
|
style={{
|
|
201
263
|
width: '100%',
|
|
@@ -216,7 +278,9 @@ export const NewFile = ({
|
|
|
216
278
|
isHover ? borderHoverColor ? borderHoverColor : configStyles.File.borderHoverColor :
|
|
217
279
|
borderColor ? borderColor : configStyles.File.borderColor
|
|
218
280
|
}}
|
|
281
|
+
onDrop={handleDrop}
|
|
219
282
|
onClick={handleClick}
|
|
283
|
+
onDragOver={handleDragOver}
|
|
220
284
|
onMouseEnter={handleMouseEnter}
|
|
221
285
|
onMouseLeave={handleMouseLeave}
|
|
222
286
|
>
|
|
@@ -226,6 +290,7 @@ export const NewFile = ({
|
|
|
226
290
|
type='file'
|
|
227
291
|
ref={inpRef}
|
|
228
292
|
disabled={disabled}
|
|
293
|
+
multiple={multiple}
|
|
229
294
|
onChange={handleChange}
|
|
230
295
|
/>
|
|
231
296
|
|
|
@@ -246,11 +311,16 @@ export const NewFile = ({
|
|
|
246
311
|
{
|
|
247
312
|
!multiple && image ?
|
|
248
313
|
image === 'pdf' ?
|
|
249
|
-
<
|
|
314
|
+
<SvgPdf /> :
|
|
250
315
|
<img
|
|
251
316
|
src={image}
|
|
252
317
|
style={{
|
|
253
|
-
|
|
318
|
+
display: 'block',
|
|
319
|
+
maxWidth: '100%',
|
|
320
|
+
maxHeight: '95%',
|
|
321
|
+
objectFit: 'contain',
|
|
322
|
+
width: fileAreaImageWidth ? fileAreaImageWidth : configStyles.File.fileAreaImageWidth,
|
|
323
|
+
height: fileAreaImageHeight ? fileAreaImageHeight : configStyles.File.fileAreaImageHeight,
|
|
254
324
|
}}
|
|
255
325
|
alt='file preview'
|
|
256
326
|
/>
|
|
@@ -265,13 +335,13 @@ export const NewFile = ({
|
|
|
265
335
|
margin: '0px'
|
|
266
336
|
}}
|
|
267
337
|
>
|
|
268
|
-
|
|
338
|
+
{putFileHere ? putFileHere : configStyles.File.putFileHere}
|
|
269
339
|
<br />
|
|
270
|
-
|
|
340
|
+
{or ? or : configStyles.File.or} <span
|
|
271
341
|
style={{
|
|
272
342
|
color: uploadColor ? uploadColor : configStyles.File.uploadColor
|
|
273
343
|
}}
|
|
274
|
-
|
|
344
|
+
>{upload ? upload : configStyles.File.upload}</span>
|
|
275
345
|
</p>
|
|
276
346
|
</div>
|
|
277
347
|
|
|
@@ -285,15 +355,13 @@ export const NewFile = ({
|
|
|
285
355
|
margin: '0px'
|
|
286
356
|
}}
|
|
287
357
|
>
|
|
288
|
-
|
|
358
|
+
{fileSizeText ? fileSizeText : configStyles.File.fileSizeText} {maxSize}ՄԲ ( { fileExtensions.toString().split(',').join(', ') } )
|
|
289
359
|
</p>
|
|
290
360
|
</div>
|
|
291
361
|
</>
|
|
292
362
|
}
|
|
293
363
|
</div>
|
|
294
364
|
|
|
295
|
-
|
|
296
|
-
|
|
297
365
|
<div
|
|
298
366
|
style={{
|
|
299
367
|
position: 'absolute',
|
|
@@ -337,94 +405,38 @@ export const NewFile = ({
|
|
|
337
405
|
|
|
338
406
|
|
|
339
407
|
{
|
|
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
|
-
)
|
|
408
|
+
multiple && memoizedItems && memoizedItems.length > 0 && memoizedItems.map(item => {
|
|
409
|
+
return <FileItem
|
|
410
|
+
key={item.uuid}
|
|
411
|
+
uuid={item.uuid}
|
|
412
|
+
check={item.check}
|
|
413
|
+
status={item.status}
|
|
414
|
+
size={item.file.size}
|
|
415
|
+
name={item.file.name}
|
|
416
|
+
removeFile={removeFile}
|
|
417
|
+
radius={radius ? radius : configStyles.File.radius}
|
|
418
|
+
fileFormat={item.file.type.split('/')[1].toLowerCase()}
|
|
419
|
+
progressColor={progressColor ? progressColor : configStyles.File.progressColor}
|
|
420
|
+
listItemHeight={listItemHeight ? listItemHeight : configStyles.File.listItemHeight}
|
|
421
|
+
listItemPadding={listItemPadding ? listItemPadding : configStyles.File.listItemPadding}
|
|
422
|
+
progressFontSize={progressFontSize ? progressFontSize : configStyles.File.progressFontSize}
|
|
423
|
+
listItemErrorSize={listItemErrorSize ? listItemErrorSize : configStyles.File.listItemErrorSize}
|
|
424
|
+
listItemErrorColor={listItemErrorColor ? listItemErrorColor : configStyles.File.listItemErrorColor}
|
|
425
|
+
progressTrackColor={progressTrackColor ? progressTrackColor : configStyles.File.progressTrackColor}
|
|
426
|
+
progressFailedColor={progressFailedColor ? progressFailedColor : configStyles.File.progressFailedColor}
|
|
427
|
+
progressSuccessColor={progressSuccessColor ? progressSuccessColor : configStyles.File.progressSuccessColor}
|
|
428
|
+
progressLoadingColor={progressLoadingColor ? progressLoadingColor : configStyles.File.progressLoadingColor}
|
|
429
|
+
listItemBackgroundColor={listItemBackgroundColor ? listItemBackgroundColor : configStyles.File.listItemBackgroundColor}
|
|
430
|
+
listItemBackgroundErrorColor={listItemBackgroundErrorColor ? listItemBackgroundErrorColor : configStyles.File.listItemBackgroundErrorColor}
|
|
431
|
+
/>
|
|
420
432
|
})
|
|
421
433
|
}
|
|
422
|
-
|
|
423
434
|
</div>
|
|
424
435
|
);
|
|
425
436
|
};
|
|
426
437
|
|
|
427
438
|
NewFile.propTypes = {
|
|
439
|
+
or: PropTypes.string,
|
|
428
440
|
size: PropTypes.string,
|
|
429
441
|
label: PropTypes.string,
|
|
430
442
|
width: PropTypes.string,
|
|
@@ -434,30 +446,49 @@ NewFile.propTypes = {
|
|
|
434
446
|
radius: PropTypes.string,
|
|
435
447
|
border: PropTypes.string,
|
|
436
448
|
required: PropTypes.bool,
|
|
449
|
+
upload: PropTypes.string,
|
|
437
450
|
weight: PropTypes.number,
|
|
438
451
|
maxSize: PropTypes.number,
|
|
439
452
|
errorSize: PropTypes.string,
|
|
440
453
|
labelSize: PropTypes.string,
|
|
441
454
|
labelColor: PropTypes.string,
|
|
442
455
|
errorColor: PropTypes.string,
|
|
456
|
+
formatError: PropTypes.string,
|
|
457
|
+
putFileHere: PropTypes.string,
|
|
443
458
|
borderColor: PropTypes.string,
|
|
444
459
|
uploadColor: PropTypes.string,
|
|
445
460
|
defaultData: PropTypes.object,
|
|
461
|
+
maxSizeError: PropTypes.string,
|
|
446
462
|
errorMessage: PropTypes.string,
|
|
463
|
+
fileSizeText: PropTypes.string,
|
|
464
|
+
noChoosenFile: PropTypes.string,
|
|
465
|
+
progressColor: PropTypes.string,
|
|
447
466
|
deleteComponent: PropTypes.bool,
|
|
467
|
+
listItemHeight: PropTypes.string,
|
|
448
468
|
backgroundColor: PropTypes.string,
|
|
449
469
|
change: PropTypes.func.isRequired,
|
|
470
|
+
listItemPadding: PropTypes.string,
|
|
471
|
+
progressFontSize: PropTypes.string,
|
|
450
472
|
borderHoverColor: PropTypes.string,
|
|
473
|
+
listItemErrorSize: PropTypes.string,
|
|
451
474
|
labelRequiredColor: PropTypes.string,
|
|
452
475
|
progressTrackColor: PropTypes.string,
|
|
476
|
+
fileAreaImageWidth: PropTypes.string,
|
|
477
|
+
listItemErrorColor: PropTypes.string,
|
|
478
|
+
removeFile: PropTypes.func.isRequired,
|
|
479
|
+
fileAreaImageHeight: PropTypes.string,
|
|
480
|
+
progressFailedColor: PropTypes.string,
|
|
481
|
+
progressSuccessColor: PropTypes.string,
|
|
482
|
+
progressLoadingColor: PropTypes.string,
|
|
453
483
|
hiddenBackgroundColor: PropTypes.string,
|
|
454
484
|
extentionsRowMarginTop: PropTypes.string,
|
|
455
485
|
listItemBackgroundColor: PropTypes.string,
|
|
486
|
+
listItemBackgroundErrorColor: PropTypes.string,
|
|
456
487
|
filesArray: PropTypes.arrayOf(PropTypes.object),
|
|
457
488
|
fileExtensions: PropTypes.arrayOf(PropTypes.string)
|
|
458
489
|
};
|
|
459
490
|
|
|
460
491
|
NewFile.defaultProps = {
|
|
461
|
-
maxSize:
|
|
492
|
+
maxSize: 50,
|
|
462
493
|
fileExtensions: ['jpg', 'jpeg', 'png', 'pdf']
|
|
463
494
|
};
|
|
@@ -23,18 +23,21 @@ 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({});
|
|
31
34
|
Default.args = {
|
|
32
35
|
label: 'File component',
|
|
33
|
-
deleteComponent:
|
|
36
|
+
deleteComponent: false,
|
|
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'
|
|
@@ -3,12 +3,12 @@ import PropTypes from "prop-types";
|
|
|
3
3
|
import classnames from "classnames";
|
|
4
4
|
import styles from "./pagination.module.css";
|
|
5
5
|
import { PaginationRange, Dots } from "./paginationRange";
|
|
6
|
-
import Icon from "../icon/Icon";
|
|
7
6
|
|
|
8
7
|
import DotsIcon from './../../components/icon/Dots';
|
|
9
8
|
import SvgNextarrow from './../../components/icon/Nextarrow';
|
|
10
9
|
|
|
11
10
|
export const Pagination = ({
|
|
11
|
+
goTo,
|
|
12
12
|
onChange,
|
|
13
13
|
totalCount,
|
|
14
14
|
siblingCount,
|
|
@@ -16,6 +16,8 @@ export const Pagination = ({
|
|
|
16
16
|
offset,
|
|
17
17
|
className,
|
|
18
18
|
}) => {
|
|
19
|
+
const [inpVal, setInpVal] = useState('');
|
|
20
|
+
const [error, setError] = useState(false);
|
|
19
21
|
const [siblingCountNumber, setSibilingCountNumber] = useState(siblingCount);
|
|
20
22
|
const [currentPageNumber, setCurrentPage] = useState(currentPage);
|
|
21
23
|
const [currentTotalCount, setcurrentTotalCount] = useState(totalCount);
|
|
@@ -67,6 +69,43 @@ export const Pagination = ({
|
|
|
67
69
|
: onPageChange(currentPageNumber - 4);
|
|
68
70
|
};
|
|
69
71
|
|
|
72
|
+
const handleChangeInput = (e) => {
|
|
73
|
+
setError(false);
|
|
74
|
+
if (e.target.value.trim() !== '') {
|
|
75
|
+
const val = parseInt(e.target.value);
|
|
76
|
+
if (Number.isInteger(val)) {
|
|
77
|
+
setInpVal(val);
|
|
78
|
+
} else {
|
|
79
|
+
setInpVal('');
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
setInpVal('');
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleKeyDown = (e) => {
|
|
87
|
+
const forbiddenKeys = ["e", ".", "+", "-"];
|
|
88
|
+
if (forbiddenKeys.includes(e.key)) {
|
|
89
|
+
e.preventDefault();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (e.keyCode === 13) {
|
|
93
|
+
if (inpVal === '') {
|
|
94
|
+
setError(true);
|
|
95
|
+
} else {
|
|
96
|
+
if (inpVal <= 1) {
|
|
97
|
+
setInpVal(1);
|
|
98
|
+
onPageChange(1);
|
|
99
|
+
} else if (inpVal >= (totalCount / offset)) {
|
|
100
|
+
setInpVal(Math.ceil(totalCount / offset));
|
|
101
|
+
onPageChange(Math.ceil(totalCount / offset));
|
|
102
|
+
} else {
|
|
103
|
+
onPageChange(inpVal);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
70
109
|
let lastPage = paginationRange[paginationRange.length - 1];
|
|
71
110
|
return (
|
|
72
111
|
<ul className={classProps}>
|
|
@@ -74,9 +113,9 @@ export const Pagination = ({
|
|
|
74
113
|
style={{
|
|
75
114
|
transform: 'rotate(180deg)'
|
|
76
115
|
}}
|
|
77
|
-
className={`${styles["pagination-btn"]} pagination-btn-rem`}
|
|
78
116
|
onClick={onPrevious}
|
|
79
117
|
disabled={currentPage === 1 ? true : false}
|
|
118
|
+
className={`${styles["pagination-btn"]} pagination-btn-rem`}
|
|
80
119
|
>
|
|
81
120
|
<SvgNextarrow />
|
|
82
121
|
</button>
|
|
@@ -157,18 +196,50 @@ export const Pagination = ({
|
|
|
157
196
|
</li>
|
|
158
197
|
);
|
|
159
198
|
})}
|
|
199
|
+
|
|
160
200
|
<button
|
|
161
201
|
onClick={onNext}
|
|
162
|
-
className={`${styles["pagination-btn"]} pagination-btn-rem`}
|
|
163
202
|
disabled={currentPageNumber === lastPage ? true : false}
|
|
203
|
+
className={`${styles["pagination-btn"]} pagination-btn-rem`}
|
|
164
204
|
>
|
|
165
205
|
<SvgNextarrow />
|
|
166
206
|
</button>
|
|
207
|
+
|
|
208
|
+
{
|
|
209
|
+
goTo && <div>
|
|
210
|
+
<input
|
|
211
|
+
onKeyDown={handleKeyDown}
|
|
212
|
+
onInput={handleChangeInput}
|
|
213
|
+
type='number'
|
|
214
|
+
style={{
|
|
215
|
+
width: '53px',
|
|
216
|
+
height: '30px',
|
|
217
|
+
outline: 'none',
|
|
218
|
+
color: '#3C393E',
|
|
219
|
+
fontSize: '13px',
|
|
220
|
+
margin: '0px 6px',
|
|
221
|
+
fontWeight: '500',
|
|
222
|
+
textAlign: 'center',
|
|
223
|
+
border: '1px solid',
|
|
224
|
+
borderRadius: '6px',
|
|
225
|
+
borderColor: error ? 'red' : '#00236a'
|
|
226
|
+
}}
|
|
227
|
+
value={inpVal}
|
|
228
|
+
/>
|
|
229
|
+
<span
|
|
230
|
+
style={{
|
|
231
|
+
color: '#3C393E',
|
|
232
|
+
fontSize: '13px'
|
|
233
|
+
}}
|
|
234
|
+
>Էջ</span>
|
|
235
|
+
</div>
|
|
236
|
+
}
|
|
167
237
|
</ul>
|
|
168
238
|
);
|
|
169
239
|
};
|
|
170
240
|
|
|
171
241
|
Pagination.propTypes = {
|
|
242
|
+
goTo: PropTypes.bool,
|
|
172
243
|
offset: PropTypes.number,
|
|
173
244
|
totalCount: PropTypes.number,
|
|
174
245
|
className: PropTypes.string,
|
|
@@ -78,4 +78,16 @@ i {
|
|
|
78
78
|
font-size: 12px;
|
|
79
79
|
line-height: 12px;
|
|
80
80
|
color: #3C393E;
|
|
81
|
-
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Works for Chrome, Safari, Edge, Opera */
|
|
84
|
+
input::-webkit-outer-spin-button,
|
|
85
|
+
input::-webkit-inner-spin-button {
|
|
86
|
+
-webkit-appearance: none;
|
|
87
|
+
margin: 0;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/* Works for Firefox */
|
|
91
|
+
input[type="number"] {
|
|
92
|
+
-moz-appearance: textfield;
|
|
93
|
+
}
|