@xaypay/tui 0.0.119 → 0.0.120

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.
Files changed (181) hide show
  1. package/dist/index.es.js +4112 -4330
  2. package/dist/index.js +4111 -4331
  3. package/package.json +1 -1
  4. package/storybook-static/favicon.ico +0 -0
  5. package/tui.config.js +1 -1
  6. package/.eslintrc.js +0 -30
  7. package/.husky/pre-commit +0 -4
  8. package/.prettierrc +0 -10
  9. package/.storybook/main.js +0 -48
  10. package/.storybook/preview.js +0 -9
  11. package/rollup.config.js +0 -37
  12. package/src/assets/attach.svg +0 -4
  13. package/src/assets/delete.svg +0 -4
  14. package/src/assets/down-arrow.svg +0 -4
  15. package/src/assets/figma-image.png +0 -0
  16. package/src/assets/heart-filled.svg +0 -17
  17. package/src/assets/heart-outline.svg +0 -14
  18. package/src/assets/like-filled.svg +0 -21
  19. package/src/assets/like-outline.svg +0 -21
  20. package/src/assets/minus.svg +0 -4
  21. package/src/assets/pdf.svg +0 -3
  22. package/src/assets/plus.svg +0 -4
  23. package/src/assets/range-arrow-default.svg +0 -19
  24. package/src/assets/range-arrow-error.svg +0 -19
  25. package/src/assets/range-arrow-success.svg +0 -19
  26. package/src/assets/star-filled.svg +0 -21
  27. package/src/assets/star-outline.svg +0 -5
  28. package/src/assets/table-settings-icon.svg +0 -3
  29. package/src/assets/up-arrow.svg +0 -4
  30. package/src/assets_old/icons/Read Me.txt +0 -7
  31. package/src/assets_old/icons/demo-files/demo.css +0 -152
  32. package/src/assets_old/icons/demo-files/demo.js +0 -28
  33. package/src/assets_old/icons/demo.html +0 -192
  34. package/src/assets_old/icons/fonts/icomoon.eot +0 -0
  35. package/src/assets_old/icons/fonts/icomoon.svg +0 -21
  36. package/src/assets_old/icons/fonts/icomoon.ttf +0 -0
  37. package/src/assets_old/icons/fonts/icomoon.woff +0 -0
  38. package/src/assets_old/icons/selection.json +0 -1
  39. package/src/assets_old/icons/style.css +0 -58
  40. package/src/components/autocomplate/autocomplate.module.css +0 -95
  41. package/src/components/autocomplate/autocomplate.stories.js +0 -35
  42. package/src/components/autocomplate/index.js +0 -164
  43. package/src/components/button/button.stories.js +0 -13
  44. package/src/components/button/index.js +0 -187
  45. package/src/components/captcha/captcha.module.css +0 -74
  46. package/src/components/captcha/captcha.stories.js +0 -21
  47. package/src/components/captcha/index.js +0 -158
  48. package/src/components/checkbox/checkbox.module.css +0 -0
  49. package/src/components/checkbox/checkbox.stories.js +0 -76
  50. package/src/components/checkbox/index.js +0 -120
  51. package/src/components/file/file.module.css +0 -114
  52. package/src/components/file/file.stories.js +0 -20
  53. package/src/components/file/index.js +0 -138
  54. package/src/components/icon/Active.js +0 -20
  55. package/src/components/icon/Arrow.js +0 -19
  56. package/src/components/icon/Cancel.js +0 -19
  57. package/src/components/icon/CaptchaArrowDown.js +0 -19
  58. package/src/components/icon/CaptchaArrowUp.js +0 -19
  59. package/src/components/icon/CheckboxChecked.js +0 -21
  60. package/src/components/icon/CheckboxUnchecked.js +0 -21
  61. package/src/components/icon/Close.js +0 -19
  62. package/src/components/icon/CloseIcon.js +0 -19
  63. package/src/components/icon/CloseSlide.js +0 -19
  64. package/src/components/icon/DeActive.js +0 -20
  65. package/src/components/icon/DeleteComponent.js +0 -20
  66. package/src/components/icon/Done.js +0 -19
  67. package/src/components/icon/Dots.js +0 -19
  68. package/src/components/icon/DownArrow.js +0 -20
  69. package/src/components/icon/HeartFilled.js +0 -25
  70. package/src/components/icon/HeartOutline.js +0 -25
  71. package/src/components/icon/Heic.js +0 -21
  72. package/src/components/icon/Icon.js +0 -11
  73. package/src/components/icon/ListItemDelete.js +0 -19
  74. package/src/components/icon/ListItemJpeg.js +0 -21
  75. package/src/components/icon/ListItemJpg.js +0 -21
  76. package/src/components/icon/ListItemPdf.js +0 -21
  77. package/src/components/icon/ListItemPng.js +0 -21
  78. package/src/components/icon/Next.js +0 -20
  79. package/src/components/icon/Nextarrow.js +0 -19
  80. package/src/components/icon/PDF.js +0 -19
  81. package/src/components/icon/Prev.js +0 -20
  82. package/src/components/icon/RangeArrowDefault.js +0 -43
  83. package/src/components/icon/RangeArrowError.js +0 -43
  84. package/src/components/icon/RangeArrowSuccess.js +0 -43
  85. package/src/components/icon/Reject.js +0 -19
  86. package/src/components/icon/RemoveFile.js +0 -20
  87. package/src/components/icon/Required.js +0 -19
  88. package/src/components/icon/ToasterClose.js +0 -19
  89. package/src/components/icon/ToasterError.js +0 -19
  90. package/src/components/icon/ToasterInfo.js +0 -19
  91. package/src/components/icon/ToasterSuccess.js +0 -19
  92. package/src/components/icon/ToasterWarning.js +0 -19
  93. package/src/components/icon/Tooltip.js +0 -19
  94. package/src/components/icon/UpArrow.js +0 -20
  95. package/src/components/icon/Upload.js +0 -25
  96. package/src/components/icon/Wrong.js +0 -21
  97. package/src/components/icon/Zoom.js +0 -21
  98. package/src/components/icon/index.js +0 -0
  99. package/src/components/input/index.js +0 -688
  100. package/src/components/input/input.module.css +0 -51
  101. package/src/components/input/input.stories.js +0 -26
  102. package/src/components/modal/index.js +0 -436
  103. package/src/components/modal/modal.module.css +0 -22
  104. package/src/components/modal/modal.stories.js +0 -88
  105. package/src/components/newAutocomplete/NewAutocomplete.stories.js +0 -102
  106. package/src/components/newAutocomplete/autocomplete.module.css +0 -4
  107. package/src/components/newAutocomplete/index.js +0 -592
  108. package/src/components/newFile/fileItem.js +0 -281
  109. package/src/components/newFile/index.js +0 -731
  110. package/src/components/newFile/newFile.stories.js +0 -93
  111. package/src/components/pagination/index.js +0 -234
  112. package/src/components/pagination/pagination.module.css +0 -93
  113. package/src/components/pagination/pagination.stories.js +0 -371
  114. package/src/components/pagination/paginationRange.js +0 -45
  115. package/src/components/radio/index.js +0 -236
  116. package/src/components/radio/radio.module.css +0 -59
  117. package/src/components/radio/radio.stories.js +0 -59
  118. package/src/components/select/index.js +0 -534
  119. package/src/components/select/select.module.css +0 -93
  120. package/src/components/select/select.stories.js +0 -39
  121. package/src/components/singleCheckbox/Checkbox.js +0 -84
  122. package/src/components/singleCheckbox/index.js +0 -65
  123. package/src/components/singleCheckbox/singleCheckbox.stories.js +0 -24
  124. package/src/components/stepper/index.js +0 -45
  125. package/src/components/stepper/stepper.module.css +0 -57
  126. package/src/components/stepper/stepper.stories.js +0 -17
  127. package/src/components/table/index.js +0 -789
  128. package/src/components/table/table.module.css +0 -63
  129. package/src/components/table/table.stories.js +0 -497
  130. package/src/components/table/td.js +0 -429
  131. package/src/components/table/th.js +0 -103
  132. package/src/components/textarea/index.js +0 -285
  133. package/src/components/textarea/textarea.module.css +0 -25
  134. package/src/components/textarea/textarea.stories.js +0 -56
  135. package/src/components/toaster/Toast.js +0 -203
  136. package/src/components/toaster/index.js +0 -131
  137. package/src/components/toaster/toaster.module.css +0 -201
  138. package/src/components/toaster/toaster.stories.js +0 -593
  139. package/src/components/tooltip/index.js +0 -156
  140. package/src/components/tooltip/tooltip.module.css +0 -46
  141. package/src/components/tooltip/tooltip.stories.js +0 -30
  142. package/src/components/typography/index.js +0 -124
  143. package/src/components/typography/typography.module.css +0 -57
  144. package/src/components/typography/typography.stories.js +0 -22
  145. package/src/index.js +0 -19
  146. package/src/stories/Introduction.stories.mdx +0 -210
  147. package/src/stories/assets/code-brackets.svg +0 -1
  148. package/src/stories/assets/colors.svg +0 -1
  149. package/src/stories/assets/comments.svg +0 -1
  150. package/src/stories/assets/direction.svg +0 -1
  151. package/src/stories/assets/flow.svg +0 -1
  152. package/src/stories/assets/plugin.svg +0 -1
  153. package/src/stories/assets/repo.svg +0 -1
  154. package/src/stories/assets/stackalt.svg +0 -1
  155. package/src/stories/changelog.stories.mdx +0 -172
  156. package/src/stories/configuration.stories.mdx +0 -715
  157. package/src/stories/documentation.stories.mdx +0 -118
  158. package/src/stories/static/autocomplete-usage.png +0 -0
  159. package/src/stories/static/button-usage-icon.png +0 -0
  160. package/src/stories/static/button-usage.png +0 -0
  161. package/src/stories/static/captcha-usage.png +0 -0
  162. package/src/stories/static/checkbox-group-usage-2.png +0 -0
  163. package/src/stories/static/checkbox-group-usage.png +0 -0
  164. package/src/stories/static/file-single-usage.png +0 -0
  165. package/src/stories/static/file-usage.png +0 -0
  166. package/src/stories/static/input-usage.png +0 -0
  167. package/src/stories/static/modal-usage.png +0 -0
  168. package/src/stories/static/radio-usage.png +0 -0
  169. package/src/stories/static/select-usage.png +0 -0
  170. package/src/stories/static/table-body-data-structure-first-part-usage.png +0 -0
  171. package/src/stories/static/table-body-data-structure-second-part-usage.png +0 -0
  172. package/src/stories/static/table-body-data-structure-third-part-usage.png +0 -0
  173. package/src/stories/static/table-component-usage.png +0 -0
  174. package/src/stories/static/table-header-data-structure-usage.png +0 -0
  175. package/src/stories/static/table-new-data-structure-usage.png +0 -0
  176. package/src/stories/static/textarea-usage.png +0 -0
  177. package/src/stories/static/toaster-container-usage.png +0 -0
  178. package/src/stories/static/toaster-usage.png +0 -0
  179. package/src/stories/static/tooltip-usage.png +0 -0
  180. package/src/stories/usage.stories.mdx +0 -201
  181. package/src/utils/index.js +0 -29
@@ -1,285 +0,0 @@
1
- import React, { useEffect, useState } from 'react'
2
- import PropTypes from 'prop-types'
3
- import classnames from 'classnames'
4
- import { compereConfigs } from './../../utils'
5
-
6
- import SvgRequired from './../icon/Required'
7
-
8
- import './textarea.module.css'
9
-
10
- export const PositionSide = {
11
- TOP: 'top',
12
- BOTTOM: 'bottom',
13
- }
14
-
15
- export const Textarea = ({
16
- size,
17
- label,
18
- width,
19
- value,
20
- height,
21
- resize,
22
- radius,
23
- padding,
24
- disabled,
25
- required,
26
- onChange,
27
- minWidth,
28
- maxWidth,
29
- boxShadow,
30
- minHeight,
31
- maxHeight,
32
- boxSizing,
33
- maxLength,
34
- labelSize,
35
- errorSize,
36
- marginTop,
37
- className,
38
- labelColor,
39
- errorColor,
40
- labelWeight,
41
- placeholder,
42
- labelDisplay,
43
- errorMessage,
44
- labelFontFamily,
45
- backgroundColor,
46
- borderFocusColor,
47
- borderHoverColor,
48
- labelMarginBottom,
49
- showCharacterCount,
50
- characterCountPosition,
51
- }) => {
52
- const [error, setError] = useState('')
53
- const [isHover, setIsHover] = useState(false)
54
- const [isFocus, setIsFocus] = useState(false)
55
- const [innerValue, setInnerValue] = useState('')
56
-
57
- const configStyles = compereConfigs()
58
- const classProps = classnames(className ? className : configStyles.TEXTAREA.className)
59
-
60
- const handleMouseEnter = () => {
61
- setIsHover(true)
62
- }
63
-
64
- const handleMouseLeave = () => {
65
- setIsHover(false)
66
- }
67
-
68
- const handleFocus = () => {
69
- setIsFocus(true)
70
- }
71
-
72
- const handleBlur = () => {
73
- setIsFocus(false)
74
- }
75
-
76
- const handleChange = (e) => {
77
- const value = e.target.value
78
- onChange(value)
79
- if (maxLength) {
80
- if (value.length > maxLength) {
81
- onChange(value.substr(0, maxLength))
82
- }
83
- } else {
84
- if (value.length > configStyles.TEXTAREA.maxLength) {
85
- onChange(value.substr(0, configStyles.TEXTAREA.maxLength))
86
- }
87
- }
88
- }
89
-
90
- useEffect(() => {
91
- if (value === undefined) {
92
- alert('Please add value prop on Textarea component')
93
- }
94
-
95
- if (!onChange) {
96
- alert('Please add onChange function on Textarea component')
97
- }
98
-
99
- if (errorMessage) {
100
- setError(errorMessage)
101
- } else {
102
- setError('')
103
- }
104
-
105
- if (value === '') {
106
- setError('')
107
- }
108
-
109
- setInnerValue(value)
110
- }, [value, onChange, errorMessage])
111
-
112
- return (
113
- <div
114
- style={{
115
- width: width ? width : configStyles.TEXTAREA.width,
116
- }}
117
- className={classProps}
118
- >
119
- <div
120
- style={{
121
- display: 'flex',
122
- alignItems: 'center',
123
- justifyContent: label ? 'space-between' : 'flex-end',
124
- fontFamily: labelFontFamily ? labelFontFamily : configStyles.TEXTAREA.labelFontFamily,
125
- marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.TEXTAREA.labelMarginBottom,
126
- }}
127
- >
128
- {label ? (
129
- <label
130
- style={{
131
- color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
132
- fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
133
- display: labelDisplay ? labelDisplay : configStyles.TEXTAREA.labelDisplay,
134
- fontWeight: labelWeight ? labelWeight : configStyles.TEXTAREA.labelWeight,
135
- }}
136
- >
137
- {label}
138
- {required && (
139
- <sup>
140
- <SvgRequired />
141
- </sup>
142
- )}
143
- </label>
144
- ) : (
145
- ''
146
- )}
147
-
148
- {showCharacterCount && maxLength && characterCountPosition === 'top' && (
149
- <span
150
- style={{
151
- color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
152
- fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
153
- }}
154
- >
155
- {maxLength - value.length} նիշ
156
- </span>
157
- )}
158
- </div>
159
- <textarea
160
- style={{
161
- width: '100%',
162
- border: 'none',
163
- outline: 'none',
164
- overflow: 'auto',
165
- cursor: disabled ? 'not-allowed' : 'auto',
166
- fontSize: size ? size : configStyles.TEXTAREA.size,
167
- height: height ? height : configStyles.TEXTAREA.height,
168
- padding: padding ? padding : configStyles.TEXTAREA.padding,
169
- borderRadius: radius ? radius : configStyles.TEXTAREA.radius,
170
- minWidth: minWidth ? minWidth : configStyles.TEXTAREA.minWidth,
171
- maxWidth: maxWidth ? maxWidth : configStyles.TEXTAREA.maxWidth,
172
- minHeight: minHeight ? minHeight : configStyles.TEXTAREA.minHeight,
173
- maxHeight: maxHeight ? maxHeight : configStyles.TEXTAREA.maxHeight,
174
- boxSizing: boxSizing ? boxSizing : configStyles.TEXTAREA.boxSizing,
175
- backgroundColor: backgroundColor ? backgroundColor : configStyles.TEXTAREA.backgroundColor,
176
- boxShadow: error
177
- ? errorColor
178
- ? `0 0 0 2px ${errorColor}`
179
- : `0 0 0 2px ${configStyles.TEXTAREA.errorColor}`
180
- : isFocus
181
- ? borderFocusColor
182
- ? `0 0 0 2px ${borderFocusColor}`
183
- : `0 0 0 2px ${configStyles.TEXTAREA.borderFocusColor}`
184
- : isHover
185
- ? borderHoverColor
186
- ? `0 0 0 2px ${borderHoverColor}`
187
- : `0 0 0 2px ${configStyles.TEXTAREA.borderHoverColor}`
188
- : boxShadow
189
- ? boxShadow
190
- : configStyles.INPUT.boxShadow,
191
- resize: resize ? resize : configStyles.TEXTAREA.resize,
192
- }}
193
- value={innerValue}
194
- disabled={disabled}
195
- onBlur={handleBlur}
196
- onFocus={handleFocus}
197
- onChange={handleChange}
198
- placeholder={placeholder}
199
- onMouseEnter={handleMouseEnter}
200
- onMouseLeave={handleMouseLeave}
201
- ></textarea>
202
- {showCharacterCount && maxLength && characterCountPosition === 'bottom' && (
203
- <div
204
- style={{
205
- float: 'right',
206
- }}
207
- >
208
- <span
209
- style={{
210
- color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
211
- fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
212
- }}
213
- >
214
- {maxLength - value.length} նիշ
215
- </span>
216
- </div>
217
- )}
218
-
219
- {error ? (
220
- <div
221
- style={{
222
- clear: 'both',
223
- wordBreak: 'break-all',
224
- maxWidth: width ? width : configStyles.TEXTAREA.width,
225
- }}
226
- >
227
- <span
228
- style={{
229
- display: 'inline-block',
230
- fontSize: errorSize ? errorSize : configStyles.TEXTAREA.errorSize,
231
- color: errorColor ? errorColor : configStyles.TEXTAREA.errorColor,
232
- marginTop: marginTop ? marginTop : configStyles.TEXTAREA.marginTop,
233
- }}
234
- >
235
- {error}
236
- </span>
237
- </div>
238
- ) : (
239
- ''
240
- )}
241
- </div>
242
- )
243
- }
244
-
245
- Textarea.propTypes = {
246
- size: PropTypes.string,
247
- label: PropTypes.string,
248
- width: PropTypes.string,
249
- height: PropTypes.string,
250
- resize: PropTypes.string,
251
- radius: PropTypes.string,
252
- required: PropTypes.bool,
253
- disabled: PropTypes.bool,
254
- padding: PropTypes.string,
255
- minWidth: PropTypes.string,
256
- maxWidth: PropTypes.string,
257
- boxShadow: PropTypes.string,
258
- marginTop: PropTypes.string,
259
- boxSizing: PropTypes.string,
260
- minHeight: PropTypes.string,
261
- maxHeight: PropTypes.string,
262
- maxLength: PropTypes.number,
263
- labelSize: PropTypes.string,
264
- errorSize: PropTypes.string,
265
- className: PropTypes.string,
266
- labelColor: PropTypes.string,
267
- errorColor: PropTypes.string,
268
- labelWeight: PropTypes.string,
269
- placeholder: PropTypes.string,
270
- errorMessage: PropTypes.string,
271
- labelDisplay: PropTypes.string,
272
- labelFontFamily: PropTypes.string,
273
- backgroundColor: PropTypes.string,
274
- showCharacterCount: PropTypes.bool,
275
- value: PropTypes.string.isRequired,
276
- borderFocusColor: PropTypes.string,
277
- borderHoverColor: PropTypes.string,
278
- labelMarginBottom: PropTypes.string,
279
- onChange: PropTypes.func.isRequired,
280
- characterCountPosition: PropTypes.oneOf(Object.values(PositionSide)),
281
- }
282
-
283
- Textarea.defaultProps = {
284
- characterCountPosition: 'top',
285
- }
@@ -1,25 +0,0 @@
1
- textarea {
2
- -webkit-appearance: none;
3
- }
4
-
5
- textarea::-webkit-scrollbar {
6
- width: 6px;
7
- }
8
-
9
- textarea::-webkit-scrollbar-track {
10
- background: #EEEEEE;
11
- border-radius: 3px;
12
- -webkit-border-radius: 3px;
13
- -moz-border-radius: 3px;
14
- -ms-border-radius: 3px;
15
- -o-border-radius: 3px;
16
- }
17
-
18
- textarea::-webkit-scrollbar-thumb {
19
- background: #D1D1D1;
20
- border-radius: 3px;
21
- -webkit-border-radius: 3px;
22
- -moz-border-radius: 3px;
23
- -ms-border-radius: 3px;
24
- -o-border-radius: 3px;
25
- }
@@ -1,56 +0,0 @@
1
- import React, { useState } from 'react'
2
- import { Textarea, PositionSide } from '.'
3
-
4
- export default {
5
- Comment: Textarea,
6
- title: 'Components/Textarea',
7
- argsType: {
8
- characterCountPosition: {
9
- options: Object.values(PositionSide),
10
- },
11
- },
12
- }
13
-
14
- const Template = (args) => {
15
- const [val, setVal] = useState('')
16
-
17
- const handleChangeValue = (value) => {
18
- setVal(value)
19
- }
20
-
21
- return <Textarea value={val} onChange={handleChangeValue} {...args} />
22
- }
23
-
24
- export const Default = Template.bind({})
25
- Default.args = {
26
- label: 'Label for textarea',
27
- required: true,
28
- disabled: false,
29
- size: '16px',
30
- radius: '6px',
31
- errorSize: '',
32
- width: '400px',
33
- errorColor: '',
34
- height: '134px',
35
- maxLength: 1500,
36
- errorMessage: '',
37
- color: '#3C393E',
38
- minWidth: '200px',
39
- maxWidth: '500px',
40
- labelSize: '16px',
41
- resize: 'vertical',
42
- minHeight: '100px',
43
- maxHeight: '300px',
44
- border: '2px solid',
45
- padding: '12px 15px',
46
- labelColor: '#3C393E',
47
- labelWeight: 'normal',
48
- labelDisplay: 'block',
49
- borderColor: '#D1D1D1',
50
- boxSizing: 'border-box',
51
- backgroundColor: 'white',
52
- showCharacterCount: true, // for showing textarea character count
53
- borderHoverColor: '#3C393E',
54
- borderFocusColor: '#00236A',
55
- characterCountPosition: 'top',
56
- }
@@ -1,203 +0,0 @@
1
- import React, { useEffect, useState, useRef } from 'react'
2
- import PropTypes from 'prop-types'
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'
9
-
10
- import styles from './toaster.module.css'
11
-
12
- let wWidth = window.innerWidth
13
-
14
- const ToasterType = {
15
- info: 'info',
16
- warn: 'warn',
17
- error: 'error',
18
- success: 'success',
19
- }
20
-
21
- const ToasterPosition = {
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
- }
29
-
30
- export const Toast = ({ type, title, timer, position, removeToast, description }) => {
31
- let timeoutCall
32
- let timeoutClick
33
-
34
- const ref = useRef(null)
35
- const [showToaster, setShowToaster] = useState(true)
36
-
37
- const handleToasterClick = (e) => {
38
- e.stopPropagation()
39
- }
40
-
41
- const handleCloseToaster = (ref) => {
42
- setShowToaster(false)
43
- timeoutClick = setTimeout(() => {
44
- removeToast(ref, position)
45
- }, 300)
46
- clearTimeout(timeoutCall)
47
- }
48
-
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={`
78
- ${styles['notify-block']}
79
- ${
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
- : ''
105
- }
106
- `}
107
- >
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>
175
-
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
- }
189
-
190
- Toast.propTypes = {
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
- }
198
-
199
- Toast.defaultProps = {
200
- timer: 5000,
201
- position: 'top-right',
202
- title: 'toaster title',
203
- }
@@ -1,131 +0,0 @@
1
- import React from 'react'
2
- import ReactDOM from 'react-dom'
3
- import classnames from 'classnames'
4
- import { compereConfigs } from './../../utils'
5
-
6
- import { Toast } from './Toast'
7
-
8
- import styles from './toaster.module.css'
9
-
10
- let toastify
11
- let path = window.location.href
12
- let wWidth = window.innerWidth
13
-
14
- const removeToast = (ref) => {
15
- // eslint-disable-next-line react/no-find-dom-node
16
- const node = ReactDOM.findDOMNode(ref.current)
17
- const removeElem = node.parentNode
18
- const parent = removeElem.parentNode
19
-
20
- parent.removeChild(removeElem)
21
-
22
- if (!parent.hasChildNodes()) {
23
- toastify.removeChild(parent)
24
- }
25
- }
26
-
27
- const createToast = ({ type, timer, title, position, description }) => {
28
- let toastParentBlock
29
- if (!toastify) {
30
- toastify = document.getElementById('toastify')
31
- }
32
-
33
- const toastBlock = document.createElement('div')
34
- toastBlock.style.position = 'relative'
35
- toastBlock.style.flexShrink = 0
36
- toastBlock.style.width = wWidth > 480 ? '440px' : '300px'
37
- toastBlock.style.height = '83px'
38
- toastBlock.style.marginBottom = '20px'
39
- const newElem = React.createElement(Toast, {
40
- type,
41
- timer,
42
- title,
43
- position,
44
- removeToast,
45
- description,
46
- })
47
- ReactDOM.render(newElem, toastBlock)
48
-
49
- if (!document.getElementById(styles[position]) || document.getElementById(styles[position]) == null) {
50
- toastParentBlock = document.createElement('div')
51
- toastParentBlock.style.position = 'fixed'
52
- toastParentBlock.style.display = 'flex'
53
- toastParentBlock.style.zIndex = 999999999999
54
- toastParentBlock.style.flexDirection =
55
- position === 'top-left' || position === 'top-right' || position === 'top-center'
56
- ? 'column-reverse'
57
- : 'column'
58
- toastParentBlock.setAttribute('id', styles[position])
59
- toastParentBlock.appendChild(toastBlock)
60
- toastify.appendChild(toastParentBlock)
61
- } else {
62
- document.getElementById(styles[position]).appendChild(toastBlock)
63
- }
64
- }
65
-
66
- export const toast = {
67
- success: (title, props) => {
68
- const { timer, position, description } = props || {}
69
- createToast({
70
- title,
71
- type: 'success',
72
- timer: timer ? timer : 5000,
73
- position: position ? position : 'top-right',
74
- description: description ? description : '',
75
- })
76
- },
77
- info: (title, props) => {
78
- const { timer, position, description } = props || {}
79
- createToast({
80
- title,
81
- type: 'info',
82
- timer: timer ? timer : 5000,
83
- position: position ? position : 'top-right',
84
- description: description ? description : '',
85
- })
86
- },
87
- warn: (title, props) => {
88
- const { timer, position, description } = props || {}
89
- createToast({
90
- title,
91
- type: 'warn',
92
- timer: timer ? timer : 5000,
93
- position: position ? position : 'top-right',
94
- description: description ? description : '',
95
- })
96
- },
97
- error: (title, props) => {
98
- const { timer, position, description } = props || {}
99
- createToast({
100
- title,
101
- type: 'error',
102
- timer: timer ? timer : 5000,
103
- position: position ? position : 'top-right',
104
- description: description ? description : '',
105
- })
106
- },
107
- }
108
-
109
- export const Toaster = ({ className }) => {
110
- const configStyles = compereConfigs()
111
- const classProps = classnames(className ? className : configStyles.TOASTER.className)
112
-
113
- window.addEventListener('popstate', () => {
114
- if (path !== window.location.href) {
115
- if (!toastify) {
116
- toastify = document.getElementById('toastify')
117
- }
118
-
119
- if (toastify.hasChildNodes()) {
120
- toastify.innerHTML = ''
121
- }
122
-
123
- path = window.location.href
124
- }
125
- })
126
- const handleToasterClick = (e) => {
127
- e.stopPropagation()
128
- }
129
-
130
- return <div onClick={handleToasterClick} className={classProps} id="toastify"></div>
131
- }