@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,181 +1,203 @@
|
|
|
1
|
-
import React, { useEffect, useState, useRef } from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
1
|
+
import React, { useEffect, useState, useRef } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import ToasterInfo from '../icon/ToasterInfo'
|
|
5
|
-
import ToasterError from '../icon/ToasterError'
|
|
6
|
-
import ToasterClose from '../icon/ToasterClose'
|
|
7
|
-
import ToasterWarn from '../icon/ToasterWarning'
|
|
8
|
-
import ToasterSuccess from '../icon/ToasterSuccess'
|
|
4
|
+
import ToasterInfo from '../icon/ToasterInfo'
|
|
5
|
+
import ToasterError from '../icon/ToasterError'
|
|
6
|
+
import ToasterClose from '../icon/ToasterClose'
|
|
7
|
+
import ToasterWarn from '../icon/ToasterWarning'
|
|
8
|
+
import ToasterSuccess from '../icon/ToasterSuccess'
|
|
9
9
|
|
|
10
|
+
import styles from './toaster.module.css'
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
let wWidth = window.innerWidth
|
|
12
13
|
|
|
13
14
|
const ToasterType = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
15
|
+
info: 'info',
|
|
16
|
+
warn: 'warn',
|
|
17
|
+
error: 'error',
|
|
18
|
+
success: 'success',
|
|
19
|
+
}
|
|
19
20
|
|
|
20
21
|
const ToasterPosition = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
22
|
+
topLeft: 'top-left',
|
|
23
|
+
topRight: 'top-right',
|
|
24
|
+
topCenter: 'top-center',
|
|
25
|
+
bottomLeft: 'bottom-left',
|
|
26
|
+
bottomRight: 'bottom-right',
|
|
27
|
+
bottomCenter: 'bottom-center',
|
|
28
|
+
}
|
|
28
29
|
|
|
29
|
-
export const Toast = ({
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
timer,
|
|
33
|
-
position,
|
|
34
|
-
removeToast,
|
|
35
|
-
description,
|
|
36
|
-
}) => {
|
|
37
|
-
let timeoutCall;
|
|
38
|
-
let timeoutClick;
|
|
30
|
+
export const Toast = ({ type, title, timer, position, removeToast, description }) => {
|
|
31
|
+
let timeoutCall
|
|
32
|
+
let timeoutClick
|
|
39
33
|
|
|
40
|
-
|
|
41
|
-
|
|
34
|
+
const ref = useRef(null)
|
|
35
|
+
const [showToaster, setShowToaster] = useState(true)
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const handleCloseToaster = (ref) => {
|
|
48
|
-
setShowToaster(false);
|
|
49
|
-
timeoutClick = setTimeout(() => {
|
|
50
|
-
removeToast(ref, position);
|
|
51
|
-
}, 300);
|
|
52
|
-
clearTimeout(timeoutCall);
|
|
53
|
-
};
|
|
37
|
+
const handleToasterClick = (e) => {
|
|
38
|
+
e.stopPropagation()
|
|
39
|
+
}
|
|
54
40
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
clearTimeout(timeoutCall);
|
|
62
|
-
clearTimeout(timeoutClick);
|
|
41
|
+
const handleCloseToaster = (ref) => {
|
|
42
|
+
setShowToaster(false)
|
|
43
|
+
timeoutClick = setTimeout(() => {
|
|
44
|
+
removeToast(ref, position)
|
|
45
|
+
}, 300)
|
|
46
|
+
clearTimeout(timeoutCall)
|
|
63
47
|
}
|
|
64
|
-
}, []);
|
|
65
48
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
timeoutCall = setTimeout(() => {
|
|
51
|
+
handleCloseToaster(ref)
|
|
52
|
+
}, timer)
|
|
53
|
+
return () => {
|
|
54
|
+
setShowToaster(true)
|
|
55
|
+
clearTimeout(timeoutCall)
|
|
56
|
+
clearTimeout(timeoutClick)
|
|
57
|
+
}
|
|
58
|
+
}, [])
|
|
59
|
+
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
ref={ref}
|
|
63
|
+
onClick={handleToasterClick}
|
|
64
|
+
style={{
|
|
65
|
+
position: 'absolute',
|
|
66
|
+
display: 'flex',
|
|
67
|
+
width: wWidth > 480 ? '440px' : '300px',
|
|
68
|
+
height: '83px',
|
|
69
|
+
borderRadius: '40px',
|
|
70
|
+
alignItems: 'center',
|
|
71
|
+
boxSizing: 'border-box',
|
|
72
|
+
backgroundColor: '#FFFFFF',
|
|
73
|
+
border: '2px solid #EEEEEE',
|
|
74
|
+
padding: '14px 29px 14px 12px',
|
|
75
|
+
justifyContent: 'space-between',
|
|
76
|
+
}}
|
|
77
|
+
className={`
|
|
84
78
|
${styles['notify-block']}
|
|
85
79
|
${
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
: position === '
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
position === 'top-left'
|
|
81
|
+
? showToaster
|
|
82
|
+
? styles['bounce-in-left']
|
|
83
|
+
: styles['bounce-out-left']
|
|
84
|
+
: position === 'top-right'
|
|
85
|
+
? showToaster
|
|
86
|
+
? styles['bounce-in-right']
|
|
87
|
+
: styles['bounce-out-right']
|
|
88
|
+
: position === 'top-center'
|
|
89
|
+
? showToaster
|
|
90
|
+
? styles['bounce-in-left']
|
|
91
|
+
: styles['bounce-out-left']
|
|
92
|
+
: position === 'bottom-left'
|
|
93
|
+
? showToaster
|
|
94
|
+
? styles['bounce-in-left']
|
|
95
|
+
: styles['bounce-out-left']
|
|
96
|
+
: position === 'bottom-right'
|
|
97
|
+
? showToaster
|
|
98
|
+
? styles['bounce-in-right']
|
|
99
|
+
: styles['bounce-out-right']
|
|
100
|
+
: position === 'bottom-center'
|
|
101
|
+
? showToaster
|
|
102
|
+
? styles['bounce-in-left']
|
|
103
|
+
: styles['bounce-out-left']
|
|
104
|
+
: ''
|
|
93
105
|
}
|
|
94
106
|
`}
|
|
95
|
-
>
|
|
96
|
-
<div
|
|
97
|
-
style={{
|
|
98
|
-
display: 'flex',
|
|
99
|
-
width: '60px',
|
|
100
|
-
height: '60px',
|
|
101
|
-
borderRadius: '30px',
|
|
102
|
-
alignItems: 'center',
|
|
103
|
-
justifyContent: 'center',
|
|
104
|
-
backgroundColor:
|
|
105
|
-
type === 'info' ? 'rgba(0, 35, 106, 0.05)'
|
|
106
|
-
: type === 'warn' ? 'rgba(255, 138, 0, 0.05)'
|
|
107
|
-
: type === 'error' ? 'rgba(238, 0, 0, 0.05)'
|
|
108
|
-
: type === 'success' ? 'rgba(13, 165, 116, 0.05)'
|
|
109
|
-
: ''
|
|
110
|
-
}}
|
|
111
|
-
>
|
|
112
|
-
{
|
|
113
|
-
type === 'info' ? <ToasterInfo />
|
|
114
|
-
: type === 'warn' ? <ToasterWarn />
|
|
115
|
-
: type === 'error' ? <ToasterError />
|
|
116
|
-
: type === 'success' ? <ToasterSuccess />
|
|
117
|
-
: ''
|
|
118
|
-
}
|
|
119
|
-
</div>
|
|
120
|
-
|
|
121
|
-
<div
|
|
122
|
-
style={{
|
|
123
|
-
height: '100%',
|
|
124
|
-
width: 'calc(100% - 90px)'
|
|
125
|
-
}}
|
|
126
|
-
>
|
|
127
|
-
<p
|
|
128
|
-
style={{
|
|
129
|
-
margin: '0px',
|
|
130
|
-
fontWeight: 600,
|
|
131
|
-
color: '#3C393E',
|
|
132
|
-
fontSize: '16px',
|
|
133
|
-
lineHeight: '22px',
|
|
134
|
-
fontStyle: 'normal',
|
|
135
|
-
}}
|
|
136
|
-
>
|
|
137
|
-
{title ? title.length > 25 ? title.substr(0, 25) + '...' : title : ''}
|
|
138
|
-
</p>
|
|
139
|
-
<span
|
|
140
|
-
style={{
|
|
141
|
-
fontWeight: 500,
|
|
142
|
-
color: '#3C393E',
|
|
143
|
-
fontSize: '12px',
|
|
144
|
-
lineHeight: '16px',
|
|
145
|
-
fontStyle: 'normal',
|
|
146
|
-
fontFamily: '',
|
|
147
|
-
opacity: 0.8
|
|
148
|
-
}}
|
|
149
107
|
>
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
108
|
+
<div
|
|
109
|
+
style={{
|
|
110
|
+
display: 'flex',
|
|
111
|
+
width: '60px',
|
|
112
|
+
height: '60px',
|
|
113
|
+
borderRadius: '30px',
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
justifyContent: 'center',
|
|
116
|
+
backgroundColor:
|
|
117
|
+
type === 'info'
|
|
118
|
+
? 'rgba(0, 35, 106, 0.05)'
|
|
119
|
+
: type === 'warn'
|
|
120
|
+
? 'rgba(255, 138, 0, 0.05)'
|
|
121
|
+
: type === 'error'
|
|
122
|
+
? 'rgba(238, 0, 0, 0.05)'
|
|
123
|
+
: type === 'success'
|
|
124
|
+
? 'rgba(13, 165, 116, 0.05)'
|
|
125
|
+
: '',
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
{type === 'info' ? (
|
|
129
|
+
<ToasterInfo />
|
|
130
|
+
) : type === 'warn' ? (
|
|
131
|
+
<ToasterWarn />
|
|
132
|
+
) : type === 'error' ? (
|
|
133
|
+
<ToasterError />
|
|
134
|
+
) : type === 'success' ? (
|
|
135
|
+
<ToasterSuccess />
|
|
136
|
+
) : (
|
|
137
|
+
''
|
|
138
|
+
)}
|
|
139
|
+
</div>
|
|
140
|
+
|
|
141
|
+
<div
|
|
142
|
+
style={{
|
|
143
|
+
height: '100%',
|
|
144
|
+
width: 'calc(100% - 90px)',
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
<p
|
|
148
|
+
style={{
|
|
149
|
+
margin: '0px',
|
|
150
|
+
fontWeight: 600,
|
|
151
|
+
color: '#3C393E',
|
|
152
|
+
fontSize: '16px',
|
|
153
|
+
lineHeight: '22px',
|
|
154
|
+
fontStyle: 'normal',
|
|
155
|
+
}}
|
|
156
|
+
className={styles['notify-title']}
|
|
157
|
+
>
|
|
158
|
+
{title ? title : ''}
|
|
159
|
+
</p>
|
|
160
|
+
<span
|
|
161
|
+
style={{
|
|
162
|
+
fontWeight: 500,
|
|
163
|
+
color: '#3C393E',
|
|
164
|
+
fontSize: '12px',
|
|
165
|
+
lineHeight: '16px',
|
|
166
|
+
fontStyle: 'normal',
|
|
167
|
+
fontFamily: '',
|
|
168
|
+
opacity: 0.8,
|
|
169
|
+
}}
|
|
170
|
+
className={styles['notify-desc']}
|
|
171
|
+
>
|
|
172
|
+
{description ? description : ''}
|
|
173
|
+
</span>
|
|
174
|
+
</div>
|
|
153
175
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
176
|
+
<div
|
|
177
|
+
onClick={() => handleCloseToaster(ref)}
|
|
178
|
+
style={{
|
|
179
|
+
width: '18px',
|
|
180
|
+
height: '18px',
|
|
181
|
+
cursor: 'pointer',
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
184
|
+
<ToasterClose />
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
)
|
|
188
|
+
}
|
|
167
189
|
|
|
168
190
|
Toast.propTypes = {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
191
|
+
timer: PropTypes.number,
|
|
192
|
+
title: PropTypes.string,
|
|
193
|
+
description: PropTypes.string,
|
|
194
|
+
removeToast: PropTypes.func.isRequired,
|
|
195
|
+
position: PropTypes.oneOf(Object.values(ToasterPosition)),
|
|
196
|
+
type: PropTypes.oneOf(Object.values(ToasterType)).isRequired,
|
|
197
|
+
}
|
|
176
198
|
|
|
177
199
|
Toast.defaultProps = {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
200
|
+
timer: 5000,
|
|
201
|
+
position: 'top-right',
|
|
202
|
+
title: 'toaster title',
|
|
203
|
+
}
|
|
@@ -1,129 +1,126 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import ReactDOM from 'react-dom'
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import ReactDOM from 'react-dom'
|
|
3
3
|
|
|
4
|
-
import { Toast } from './Toast'
|
|
4
|
+
import { Toast } from './Toast'
|
|
5
5
|
|
|
6
|
-
import styles from './toaster.module.css'
|
|
6
|
+
import styles from './toaster.module.css'
|
|
7
7
|
|
|
8
|
-
let toastify
|
|
9
|
-
let path = window.location.href
|
|
8
|
+
let toastify
|
|
9
|
+
let path = window.location.href
|
|
10
|
+
let wWidth = window.innerWidth
|
|
10
11
|
|
|
11
12
|
const removeToast = (ref) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// eslint-disable-next-line react/no-find-dom-node
|
|
14
|
+
const node = ReactDOM.findDOMNode(ref.current)
|
|
15
|
+
const removeElem = node.parentNode
|
|
16
|
+
const parent = removeElem.parentNode
|
|
15
17
|
|
|
16
|
-
|
|
18
|
+
parent.removeChild(removeElem)
|
|
17
19
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
20
|
+
if (!parent.hasChildNodes()) {
|
|
21
|
+
toastify.removeChild(parent)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
22
24
|
|
|
23
|
-
const createToast = ({
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
description,
|
|
29
|
-
}) => {
|
|
30
|
-
let toastParentBlock;
|
|
31
|
-
if (!toastify) {
|
|
32
|
-
toastify = document.getElementById('toastify');
|
|
33
|
-
}
|
|
25
|
+
const createToast = ({ type, timer, title, position, description }) => {
|
|
26
|
+
let toastParentBlock
|
|
27
|
+
if (!toastify) {
|
|
28
|
+
toastify = document.getElementById('toastify')
|
|
29
|
+
}
|
|
34
30
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
const toastBlock = document.createElement('div')
|
|
32
|
+
toastBlock.style.position = 'relative'
|
|
33
|
+
toastBlock.style.flexShrink = 0
|
|
34
|
+
toastBlock.style.width = wWidth > 480 ? '440px' : '300px'
|
|
35
|
+
toastBlock.style.height = '83px'
|
|
36
|
+
toastBlock.style.marginBottom = '20px'
|
|
37
|
+
const newElem = React.createElement(Toast, {
|
|
38
|
+
type,
|
|
39
|
+
timer,
|
|
40
|
+
title,
|
|
41
|
+
position,
|
|
42
|
+
removeToast,
|
|
43
|
+
description,
|
|
44
|
+
})
|
|
45
|
+
ReactDOM.render(newElem, toastBlock)
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
47
|
+
if (!document.getElementById(styles[position]) || document.getElementById(styles[position]) == null) {
|
|
48
|
+
toastParentBlock = document.createElement('div')
|
|
49
|
+
toastParentBlock.style.position = 'fixed'
|
|
50
|
+
toastParentBlock.style.display = 'flex'
|
|
51
|
+
toastParentBlock.style.zIndex = 999999999999
|
|
52
|
+
toastParentBlock.style.flexDirection =
|
|
53
|
+
position === 'top-left' || position === 'top-right' || position === 'top-center'
|
|
54
|
+
? 'column-reverse'
|
|
55
|
+
: 'column'
|
|
56
|
+
toastParentBlock.setAttribute('id', styles[position])
|
|
57
|
+
toastParentBlock.appendChild(toastBlock)
|
|
58
|
+
toastify.appendChild(toastParentBlock)
|
|
59
|
+
} else {
|
|
60
|
+
document.getElementById(styles[position]).appendChild(toastBlock)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
64
63
|
|
|
65
64
|
export const toast = {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
65
|
+
success: (title, props) => {
|
|
66
|
+
const { timer, position, description } = props || {}
|
|
67
|
+
createToast({
|
|
68
|
+
title,
|
|
69
|
+
type: 'success',
|
|
70
|
+
timer: timer ? timer : 5000,
|
|
71
|
+
position: position ? position : 'top-right',
|
|
72
|
+
description: description ? description : '',
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
info: (title, props) => {
|
|
76
|
+
const { timer, position, description } = props || {}
|
|
77
|
+
createToast({
|
|
78
|
+
title,
|
|
79
|
+
type: 'info',
|
|
80
|
+
timer: timer ? timer : 5000,
|
|
81
|
+
position: position ? position : 'top-right',
|
|
82
|
+
description: description ? description : '',
|
|
83
|
+
})
|
|
84
|
+
},
|
|
85
|
+
warn: (title, props) => {
|
|
86
|
+
const { timer, position, description } = props || {}
|
|
87
|
+
createToast({
|
|
88
|
+
title,
|
|
89
|
+
type: 'warn',
|
|
90
|
+
timer: timer ? timer : 5000,
|
|
91
|
+
position: position ? position : 'top-right',
|
|
92
|
+
description: description ? description : '',
|
|
93
|
+
})
|
|
94
|
+
},
|
|
95
|
+
error: (title, props) => {
|
|
96
|
+
const { timer, position, description } = props || {}
|
|
97
|
+
createToast({
|
|
98
|
+
title,
|
|
99
|
+
type: 'error',
|
|
100
|
+
timer: timer ? timer : 5000,
|
|
101
|
+
position: position ? position : 'top-right',
|
|
102
|
+
description: description ? description : '',
|
|
103
|
+
})
|
|
104
|
+
},
|
|
105
|
+
}
|
|
107
106
|
|
|
108
107
|
export const Toaster = () => {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
window.addEventListener('popstate', () => {
|
|
109
|
+
if (path !== window.location.href) {
|
|
110
|
+
if (!toastify) {
|
|
111
|
+
toastify = document.getElementById('toastify')
|
|
112
|
+
}
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
114
|
+
if (toastify.hasChildNodes()) {
|
|
115
|
+
toastify.innerHTML = ''
|
|
116
|
+
}
|
|
118
117
|
|
|
119
|
-
|
|
118
|
+
path = window.location.href
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
const handleToasterClick = (e) => {
|
|
122
|
+
e.stopPropagation()
|
|
120
123
|
}
|
|
121
|
-
});
|
|
122
|
-
const handleToasterClick = (e) => {
|
|
123
|
-
e.stopPropagation();
|
|
124
|
-
};
|
|
125
124
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
);
|
|
129
|
-
};
|
|
125
|
+
return <div onClick={handleToasterClick} id="toastify"></div>
|
|
126
|
+
}
|
|
@@ -95,6 +95,19 @@
|
|
|
95
95
|
animation-name: bounceOutRight;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
.notify-title {
|
|
99
|
+
overflow: hidden;
|
|
100
|
+
text-overflow: ellipsis;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.notify-desc {
|
|
104
|
+
display: -webkit-box;
|
|
105
|
+
-webkit-box-orient: vertical;
|
|
106
|
+
-webkit-line-clamp: 2;
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
text-overflow: ellipsis;
|
|
109
|
+
}
|
|
110
|
+
|
|
98
111
|
@keyframes bounceInRight {
|
|
99
112
|
from {
|
|
100
113
|
opacity: 0;
|