@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
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import SvgListItemPdf from './../icon/ListItemPdf';
|
|
4
|
+
import SvgListItemJpg from './../icon/ListItemJpg';
|
|
5
|
+
import SvgListItemPng from './../icon/ListItemPng';
|
|
6
|
+
import SvgListItemJpeg from './../icon/ListItemJpeg';
|
|
7
|
+
import SvgListItemDelete from './../icon/ListItemDelete';
|
|
8
|
+
|
|
9
|
+
const FileItem = React.memo(({
|
|
10
|
+
size,
|
|
11
|
+
name,
|
|
12
|
+
uuid,
|
|
13
|
+
check,
|
|
14
|
+
radius,
|
|
15
|
+
status,
|
|
16
|
+
removeFile,
|
|
17
|
+
fileFormat,
|
|
18
|
+
progressColor,
|
|
19
|
+
listItemHeight,
|
|
20
|
+
listItemPadding,
|
|
21
|
+
progressFontSize,
|
|
22
|
+
listItemErrorSize,
|
|
23
|
+
listItemErrorColor,
|
|
24
|
+
progressTrackColor,
|
|
25
|
+
progressFailedColor,
|
|
26
|
+
progressSuccessColor,
|
|
27
|
+
progressLoadingColor,
|
|
28
|
+
listItemBackgroundColor,
|
|
29
|
+
listItemBackgroundErrorColor
|
|
30
|
+
}) => {
|
|
31
|
+
const [i, setI] = useState(_ => _);
|
|
32
|
+
const [t, setT] = useState(_ => _);
|
|
33
|
+
const [progress, setProgress] = useState(7);
|
|
34
|
+
|
|
35
|
+
const handleRemoveItem = (id) => {
|
|
36
|
+
removeFile(id);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
let time = Math.floor(Math.random() * (1100 - 900 + 1)) + 900;
|
|
41
|
+
let fileSizeInMB = Math.round(size / (1024 * 1024));
|
|
42
|
+
if (fileSizeInMB > 5) {
|
|
43
|
+
const times = [
|
|
44
|
+
Math.floor(Math.random() * (1700 - 1300 + 1)) + 1300,
|
|
45
|
+
Math.floor(Math.random() * (3200 - 2800 + 1)) + 2800,
|
|
46
|
+
Math.floor(Math.random() * (4700 - 4300 + 1)) + 4300,
|
|
47
|
+
Math.floor(Math.random() * (6200 - 5800 + 1)) + 5800,
|
|
48
|
+
Math.floor(Math.random() * (7700 - 7300 + 1)) + 7300
|
|
49
|
+
];
|
|
50
|
+
const index = Math.min(Math.floor((size - 1) / 15), times.length - 1);
|
|
51
|
+
time = times[index];
|
|
52
|
+
}
|
|
53
|
+
setI(setInterval(() => {
|
|
54
|
+
setProgress(prev => {
|
|
55
|
+
return prev += 7;
|
|
56
|
+
});
|
|
57
|
+
}, time));
|
|
58
|
+
return () => {
|
|
59
|
+
setI(_ => _);
|
|
60
|
+
clearTimeout(t);
|
|
61
|
+
clearInterval(i);
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (progress > 84) {
|
|
67
|
+
clearInterval(i);
|
|
68
|
+
}
|
|
69
|
+
}, [progress]);
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
if (status === 'success') {
|
|
73
|
+
setProgress(100);
|
|
74
|
+
clearInterval(i);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (status === 'failed') {
|
|
78
|
+
setProgress(0);
|
|
79
|
+
clearInterval(i);
|
|
80
|
+
}
|
|
81
|
+
}, [status]);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (check !== '') {
|
|
85
|
+
setT(setTimeout(() => {
|
|
86
|
+
removeFile(uuid);
|
|
87
|
+
}, 3500));
|
|
88
|
+
}
|
|
89
|
+
}, [check]);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<div
|
|
93
|
+
style={{
|
|
94
|
+
width: '100%',
|
|
95
|
+
display: 'flex',
|
|
96
|
+
marginTop: '6px',
|
|
97
|
+
alignItems: 'center',
|
|
98
|
+
borderRadius: radius,
|
|
99
|
+
height: listItemHeight,
|
|
100
|
+
boxSizing: 'border-box',
|
|
101
|
+
padding: listItemPadding,
|
|
102
|
+
flexDirection: check !== '' ? 'column' : 'row',
|
|
103
|
+
justifyContent: check !== '' ? 'space-around' : 'space-between',
|
|
104
|
+
backgroundColor: check !== '' ? listItemBackgroundErrorColor : listItemBackgroundColor
|
|
105
|
+
}}
|
|
106
|
+
>
|
|
107
|
+
{
|
|
108
|
+
check !== ''
|
|
109
|
+
? <>
|
|
110
|
+
<p style={{
|
|
111
|
+
margin: '0px',
|
|
112
|
+
color: listItemErrorColor,
|
|
113
|
+
fontSize: listItemErrorSize
|
|
114
|
+
}}>{ name }</p>
|
|
115
|
+
<p style={{
|
|
116
|
+
margin: '0px',
|
|
117
|
+
color: listItemErrorColor,
|
|
118
|
+
fontSize: listItemErrorSize
|
|
119
|
+
}}>{ check }</p>
|
|
120
|
+
</>
|
|
121
|
+
: <>
|
|
122
|
+
<div
|
|
123
|
+
style={{
|
|
124
|
+
width: '32px'
|
|
125
|
+
}}
|
|
126
|
+
>
|
|
127
|
+
{
|
|
128
|
+
fileFormat === 'pdf' ? <SvgListItemPdf /> :
|
|
129
|
+
fileFormat === 'jpg' ? <SvgListItemJpg /> :
|
|
130
|
+
fileFormat === 'png' ? <SvgListItemPng /> :
|
|
131
|
+
fileFormat === 'jpeg' ? <SvgListItemJpeg /> : ''
|
|
132
|
+
}
|
|
133
|
+
</div>
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
<div
|
|
137
|
+
style={{
|
|
138
|
+
position: 'relative',
|
|
139
|
+
display: 'flex',
|
|
140
|
+
height: '40px',
|
|
141
|
+
margin: '0px 14px',
|
|
142
|
+
alignItems: 'flex-end',
|
|
143
|
+
width: 'calc(100% - 82px)'
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
146
|
+
<div
|
|
147
|
+
style={{
|
|
148
|
+
width: '100%',
|
|
149
|
+
height: '100%',
|
|
150
|
+
display: 'flex',
|
|
151
|
+
paddingTop: '5px',
|
|
152
|
+
color: progressColor,
|
|
153
|
+
boxSizing: 'border-box',
|
|
154
|
+
alignItems: 'flex-start',
|
|
155
|
+
fontSize: progressFontSize,
|
|
156
|
+
justifyContent: 'space-between'
|
|
157
|
+
}}
|
|
158
|
+
>
|
|
159
|
+
<p
|
|
160
|
+
style={{
|
|
161
|
+
margin: '0px',
|
|
162
|
+
overflow: 'hidden',
|
|
163
|
+
whiteSpace: 'nowrap',
|
|
164
|
+
textOverflow: 'ellipsis',
|
|
165
|
+
maxWidth: 'calc(100% - 56px)'
|
|
166
|
+
}}
|
|
167
|
+
>{name}</p>
|
|
168
|
+
|
|
169
|
+
<span>
|
|
170
|
+
{progress} %
|
|
171
|
+
</span>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<div
|
|
175
|
+
style={{
|
|
176
|
+
position: 'absolute',
|
|
177
|
+
left: '0px',
|
|
178
|
+
bottom: '5px',
|
|
179
|
+
width: '100%',
|
|
180
|
+
height: '4px',
|
|
181
|
+
borderRadius: '10px',
|
|
182
|
+
backgroundColor: progressTrackColor
|
|
183
|
+
}}
|
|
184
|
+
>
|
|
185
|
+
<div
|
|
186
|
+
style={{
|
|
187
|
+
height: '100%',
|
|
188
|
+
borderRadius: '10px',
|
|
189
|
+
width: status === 'failed' ? '100%' : progress + '%',
|
|
190
|
+
backgroundColor: status === 'success' ? progressSuccessColor : status === 'failed' ? progressFailedColor : progressLoadingColor
|
|
191
|
+
}}
|
|
192
|
+
></div>
|
|
193
|
+
</div>
|
|
194
|
+
|
|
195
|
+
</div>
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
<div
|
|
199
|
+
style={{
|
|
200
|
+
width: '22px',
|
|
201
|
+
cursor: 'pointer'
|
|
202
|
+
}}
|
|
203
|
+
onClick={() => handleRemoveItem(uuid)}
|
|
204
|
+
>
|
|
205
|
+
<SvgListItemDelete />
|
|
206
|
+
</div>
|
|
207
|
+
</>
|
|
208
|
+
}
|
|
209
|
+
</div>
|
|
210
|
+
)
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
export default FileItem;
|