@xaypay/tui 0.0.105 → 0.0.107
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/.eslintrc.js +30 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc +10 -0
- package/.storybook/main.js +42 -45
- package/.storybook/preview.js +7 -7
- package/cli-command.js +1 -1
- package/dist/index.es.js +105 -94
- package/dist/index.js +105 -94
- package/package.json +16 -4
- package/rollup.config.js +11 -11
- package/src/assets_old/icons/demo-files/demo.js +16 -18
- package/src/components/autocomplate/autocomplate.stories.js +30 -28
- package/src/components/autocomplate/index.js +145 -127
- package/src/components/button/button.stories.js +6 -6
- package/src/components/button/index.js +176 -126
- package/src/components/captcha/captcha.stories.js +12 -8
- package/src/components/captcha/index.js +47 -50
- package/src/components/checkbox/checkbox.stories.js +7 -7
- package/src/components/checkbox/index.js +77 -93
- package/src/components/file/file.stories.js +15 -15
- package/src/components/file/index.js +114 -116
- package/src/components/icon/Arrow.js +18 -18
- package/src/components/icon/CaptchaArrowDown.js +18 -18
- package/src/components/icon/CaptchaArrowUp.js +18 -18
- package/src/components/icon/CheckboxChecked.js +20 -20
- package/src/components/icon/CheckboxUnchecked.js +20 -20
- package/src/components/icon/Close.js +18 -18
- package/src/components/icon/CloseIcon.js +18 -18
- package/src/components/icon/CloseSlide.js +18 -18
- package/src/components/icon/DeleteComponent.js +19 -19
- package/src/components/icon/Dots.js +18 -18
- package/src/components/icon/HeartFilled.js +22 -23
- package/src/components/icon/HeartOutline.js +22 -22
- package/src/components/icon/Icon.js +3 -5
- package/src/components/icon/ListItemDelete.js +18 -18
- package/src/components/icon/ListItemJpeg.js +20 -20
- package/src/components/icon/ListItemJpg.js +20 -20
- package/src/components/icon/ListItemPdf.js +20 -20
- package/src/components/icon/ListItemPng.js +20 -20
- package/src/components/icon/Next.js +19 -19
- package/src/components/icon/Nextarrow.js +18 -18
- package/src/components/icon/PDF.js +18 -18
- package/src/components/icon/Prev.js +19 -19
- package/src/components/icon/RangeArrowDefault.js +41 -52
- package/src/components/icon/RangeArrowError.js +41 -52
- package/src/components/icon/RangeArrowSuccess.js +41 -52
- package/src/components/icon/RemoveFile.js +19 -19
- package/src/components/icon/ToasterClose.js +18 -18
- package/src/components/icon/ToasterError.js +18 -18
- package/src/components/icon/ToasterInfo.js +18 -18
- package/src/components/icon/ToasterSuccess.js +18 -18
- package/src/components/icon/ToasterWarning.js +18 -18
- package/src/components/icon/Tooltip.js +18 -18
- package/src/components/icon/Upload.js +24 -24
- package/src/components/input/index.js +267 -224
- package/src/components/input/input.stories.js +20 -21
- package/src/components/modal/index.js +172 -159
- package/src/components/modal/modal.stories.js +79 -78
- package/src/components/newAutocomplete/NewAutocomplete.stories.js +93 -51
- package/src/components/newAutocomplete/index.js +342 -216
- package/src/components/newFile/fileItem.js +214 -191
- package/src/components/newFile/index.js +235 -173
- package/src/components/newFile/newFile.stories.js +32 -35
- package/src/components/pagination/index.js +97 -122
- package/src/components/pagination/pagination.stories.js +362 -362
- package/src/components/pagination/paginationRange.js +42 -53
- package/src/components/radio/index.js +49 -62
- package/src/components/radio/radio.stories.js +7 -7
- package/src/components/select/index.js +318 -223
- package/src/components/select/select.stories.js +25 -14
- package/src/components/singleCheckbox/Checkbox.js +31 -34
- package/src/components/singleCheckbox/index.js +36 -45
- package/src/components/singleCheckbox/singleCheckbox.stories.js +16 -16
- package/src/components/stepper/index.js +35 -30
- package/src/components/stepper/stepper.stories.js +11 -11
- package/src/components/table/index.js +280 -148
- package/src/components/table/table.stories.js +105 -217
- package/src/components/table/td.js +80 -72
- package/src/components/table/th.js +19 -16
- package/src/components/textarea/index.js +86 -62
- package/src/components/textarea/textarea.stories.js +10 -13
- package/src/components/toaster/Toast.js +180 -158
- package/src/components/toaster/index.js +108 -111
- package/src/components/toaster/toaster.module.css +13 -0
- package/src/components/toaster/toaster.stories.js +582 -367
- package/src/components/tooltip/index.js +79 -46
- package/src/components/tooltip/tooltip.stories.js +9 -10
- package/src/components/typography/index.js +108 -101
- package/src/components/typography/typography.stories.js +16 -19
- package/src/index.js +20 -20
- package/src/stories/configuration.stories.mdx +1 -0
- package/src/utils/index.js +11 -11
- package/tui.config.js +343 -340
|
@@ -1,213 +1,236 @@
|
|
|
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
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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);
|
|
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
|
+
// eslint-disable-next-line react/display-name
|
|
10
|
+
const FileItem = React.memo(
|
|
11
|
+
({
|
|
12
|
+
size,
|
|
13
|
+
name,
|
|
14
|
+
uuid,
|
|
15
|
+
check,
|
|
16
|
+
radius,
|
|
17
|
+
status,
|
|
18
|
+
removeFile,
|
|
19
|
+
fileFormat,
|
|
20
|
+
progressColor,
|
|
21
|
+
listItemHeight,
|
|
22
|
+
listItemPadding,
|
|
23
|
+
progressFontSize,
|
|
24
|
+
listItemErrorSize,
|
|
25
|
+
timeForRemoveError,
|
|
26
|
+
listItemErrorColor,
|
|
27
|
+
progressTrackColor,
|
|
28
|
+
progressFailedColor,
|
|
29
|
+
progressSuccessColor,
|
|
30
|
+
progressLoadingColor,
|
|
31
|
+
listItemBackgroundColor,
|
|
32
|
+
listItemBackgroundErrorColor,
|
|
33
|
+
}) => {
|
|
34
|
+
const [i, setI] = useState((_) => _)
|
|
35
|
+
const [t, setT] = useState((_) => _)
|
|
36
|
+
const [progress, setProgress] = useState(7)
|
|
37
|
+
|
|
38
|
+
const handleRemoveItem = (id) => {
|
|
39
|
+
removeFile(id)
|
|
75
40
|
}
|
|
76
41
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
let time = Math.floor(Math.random() * (1100 - 900 + 1)) + 900
|
|
44
|
+
let fileSizeInMB = Math.round(size / (1024 * 1024))
|
|
45
|
+
if (fileSizeInMB > 5) {
|
|
46
|
+
const times = [
|
|
47
|
+
Math.floor(Math.random() * (1700 - 1300 + 1)) + 1300,
|
|
48
|
+
Math.floor(Math.random() * (3200 - 2800 + 1)) + 2800,
|
|
49
|
+
Math.floor(Math.random() * (4700 - 4300 + 1)) + 4300,
|
|
50
|
+
Math.floor(Math.random() * (6200 - 5800 + 1)) + 5800,
|
|
51
|
+
Math.floor(Math.random() * (7700 - 7300 + 1)) + 7300,
|
|
52
|
+
]
|
|
53
|
+
const index = Math.min(Math.floor((size - 1) / 15), times.length - 1)
|
|
54
|
+
time = times[index]
|
|
55
|
+
}
|
|
56
|
+
setI(
|
|
57
|
+
setInterval(() => {
|
|
58
|
+
setProgress((prev) => {
|
|
59
|
+
return (prev += 7)
|
|
60
|
+
})
|
|
61
|
+
}, time)
|
|
62
|
+
)
|
|
63
|
+
return () => {
|
|
64
|
+
setI((_) => _)
|
|
65
|
+
clearTimeout(t)
|
|
66
|
+
clearInterval(i)
|
|
67
|
+
}
|
|
68
|
+
}, [])
|
|
82
69
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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>
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (progress > 84) {
|
|
72
|
+
clearInterval(i)
|
|
73
|
+
}
|
|
74
|
+
}, [progress])
|
|
134
75
|
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (status === 'success') {
|
|
78
|
+
setProgress(100)
|
|
79
|
+
clearInterval(i)
|
|
80
|
+
}
|
|
135
81
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
82
|
+
if (status === 'failed') {
|
|
83
|
+
setProgress(0)
|
|
84
|
+
clearInterval(i)
|
|
85
|
+
}
|
|
86
|
+
}, [status])
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (check !== '') {
|
|
90
|
+
setT(
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
removeFile(uuid)
|
|
93
|
+
}, timeForRemoveError)
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
}, [check])
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<div
|
|
100
|
+
style={{
|
|
101
|
+
width: '100%',
|
|
102
|
+
display: 'flex',
|
|
103
|
+
marginTop: '6px',
|
|
104
|
+
alignItems: 'center',
|
|
105
|
+
borderRadius: radius,
|
|
106
|
+
height: listItemHeight,
|
|
107
|
+
boxSizing: 'border-box',
|
|
108
|
+
padding: listItemPadding,
|
|
109
|
+
flexDirection: check !== '' ? 'column' : 'row',
|
|
110
|
+
justifyContent: check !== '' ? 'space-around' : 'space-between',
|
|
111
|
+
backgroundColor: check !== '' ? listItemBackgroundErrorColor : listItemBackgroundColor,
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{check !== '' ? (
|
|
115
|
+
<>
|
|
116
|
+
<p
|
|
117
|
+
style={{
|
|
118
|
+
margin: '0px',
|
|
119
|
+
color: listItemErrorColor,
|
|
120
|
+
fontSize: listItemErrorSize,
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
{name}
|
|
124
|
+
</p>
|
|
125
|
+
<p
|
|
126
|
+
style={{
|
|
127
|
+
margin: '0px',
|
|
128
|
+
color: listItemErrorColor,
|
|
129
|
+
fontSize: listItemErrorSize,
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{check}
|
|
133
|
+
</p>
|
|
134
|
+
</>
|
|
135
|
+
) : (
|
|
136
|
+
<>
|
|
146
137
|
<div
|
|
147
138
|
style={{
|
|
148
|
-
width: '
|
|
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'
|
|
139
|
+
width: '32px',
|
|
157
140
|
}}
|
|
158
141
|
>
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
{progress} %
|
|
171
|
-
</span>
|
|
142
|
+
{fileFormat === 'pdf' ? (
|
|
143
|
+
<SvgListItemPdf />
|
|
144
|
+
) : fileFormat === 'jpg' ? (
|
|
145
|
+
<SvgListItemJpg />
|
|
146
|
+
) : fileFormat === 'png' ? (
|
|
147
|
+
<SvgListItemPng />
|
|
148
|
+
) : fileFormat === 'jpeg' ? (
|
|
149
|
+
<SvgListItemJpeg />
|
|
150
|
+
) : (
|
|
151
|
+
''
|
|
152
|
+
)}
|
|
172
153
|
</div>
|
|
173
154
|
|
|
174
155
|
<div
|
|
175
156
|
style={{
|
|
176
|
-
position: '
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
backgroundColor: progressTrackColor
|
|
157
|
+
position: 'relative',
|
|
158
|
+
display: 'flex',
|
|
159
|
+
height: '40px',
|
|
160
|
+
margin: '0px 14px',
|
|
161
|
+
alignItems: 'flex-end',
|
|
162
|
+
width: 'calc(100% - 82px)',
|
|
183
163
|
}}
|
|
184
164
|
>
|
|
185
165
|
<div
|
|
186
166
|
style={{
|
|
167
|
+
width: '100%',
|
|
187
168
|
height: '100%',
|
|
169
|
+
display: 'flex',
|
|
170
|
+
paddingTop: '5px',
|
|
171
|
+
color: progressColor,
|
|
172
|
+
boxSizing: 'border-box',
|
|
173
|
+
alignItems: 'flex-start',
|
|
174
|
+
fontSize: progressFontSize,
|
|
175
|
+
justifyContent: 'space-between',
|
|
176
|
+
}}
|
|
177
|
+
>
|
|
178
|
+
<p
|
|
179
|
+
style={{
|
|
180
|
+
margin: '0px',
|
|
181
|
+
overflow: 'hidden',
|
|
182
|
+
whiteSpace: 'nowrap',
|
|
183
|
+
textOverflow: 'ellipsis',
|
|
184
|
+
maxWidth: 'calc(100% - 56px)',
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
{name}
|
|
188
|
+
</p>
|
|
189
|
+
|
|
190
|
+
<span>{progress} %</span>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<div
|
|
194
|
+
style={{
|
|
195
|
+
position: 'absolute',
|
|
196
|
+
left: '0px',
|
|
197
|
+
bottom: '5px',
|
|
198
|
+
width: '100%',
|
|
199
|
+
height: '4px',
|
|
188
200
|
borderRadius: '10px',
|
|
189
|
-
|
|
190
|
-
backgroundColor: status === 'success' ? progressSuccessColor : status === 'failed' ? progressFailedColor : progressLoadingColor
|
|
201
|
+
backgroundColor: progressTrackColor,
|
|
191
202
|
}}
|
|
192
|
-
|
|
203
|
+
>
|
|
204
|
+
<div
|
|
205
|
+
style={{
|
|
206
|
+
height: '100%',
|
|
207
|
+
borderRadius: '10px',
|
|
208
|
+
width: status === 'failed' ? '100%' : progress + '%',
|
|
209
|
+
backgroundColor:
|
|
210
|
+
status === 'success'
|
|
211
|
+
? progressSuccessColor
|
|
212
|
+
: status === 'failed'
|
|
213
|
+
? progressFailedColor
|
|
214
|
+
: progressLoadingColor,
|
|
215
|
+
}}
|
|
216
|
+
></div>
|
|
217
|
+
</div>
|
|
193
218
|
</div>
|
|
194
219
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
export default FileItem;
|
|
220
|
+
<div
|
|
221
|
+
style={{
|
|
222
|
+
width: '22px',
|
|
223
|
+
cursor: 'pointer',
|
|
224
|
+
}}
|
|
225
|
+
onClick={() => handleRemoveItem(uuid)}
|
|
226
|
+
>
|
|
227
|
+
<SvgListItemDelete />
|
|
228
|
+
</div>
|
|
229
|
+
</>
|
|
230
|
+
)}
|
|
231
|
+
</div>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
export default FileItem
|