@xaypay/tui 0.0.118 → 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 +4144 -4294
  2. package/dist/index.js +4144 -4295
  3. package/package.json +1 -1
  4. package/storybook-static/favicon.ico +0 -0
  5. package/tui.config.js +8 -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 -657
  110. package/src/components/newFile/newFile.stories.js +0 -57
  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 -428
  131. package/src/components/table/th.js +0 -103
  132. package/src/components/textarea/index.js +0 -251
  133. package/src/components/textarea/textarea.module.css +0 -25
  134. package/src/components/textarea/textarea.stories.js +0 -50
  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 -131
  156. package/src/stories/configuration.stories.mdx +0 -708
  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,251 +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 Textarea = ({
11
- size,
12
- label,
13
- width,
14
- value,
15
- height,
16
- resize,
17
- radius,
18
- padding,
19
- disabled,
20
- required,
21
- onChange,
22
- minWidth,
23
- maxWidth,
24
- boxShadow,
25
- minHeight,
26
- maxHeight,
27
- boxSizing,
28
- maxLength,
29
- labelSize,
30
- errorSize,
31
- marginTop,
32
- className,
33
- labelColor,
34
- errorColor,
35
- labelWeight,
36
- placeholder,
37
- labelDisplay,
38
- errorMessage,
39
- labelFontFamily,
40
- backgroundColor,
41
- borderFocusColor,
42
- borderHoverColor,
43
- labelMarginBottom,
44
- showCharacterCount,
45
- }) => {
46
- const [error, setError] = useState('')
47
- const [isHover, setIsHover] = useState(false)
48
- const [isFocus, setIsFocus] = useState(false)
49
- const [innerValue, setInnerValue] = useState('')
50
-
51
- const configStyles = compereConfigs()
52
- const classProps = classnames(className ? className : configStyles.TEXTAREA.className)
53
-
54
- const handleMouseEnter = () => {
55
- setIsHover(true)
56
- }
57
-
58
- const handleMouseLeave = () => {
59
- setIsHover(false)
60
- }
61
-
62
- const handleFocus = () => {
63
- setIsFocus(true)
64
- }
65
-
66
- const handleBlur = () => {
67
- setIsFocus(false)
68
- }
69
-
70
- const handleChange = (e) => {
71
- const value = e.target.value
72
- onChange(value)
73
- if (maxLength) {
74
- if (value.length > maxLength) {
75
- onChange(value.substr(0, maxLength))
76
- }
77
- } else {
78
- if (value.length > configStyles.TEXTAREA.maxLength) {
79
- onChange(value.substr(0, configStyles.TEXTAREA.maxLength))
80
- }
81
- }
82
- }
83
-
84
- useEffect(() => {
85
- if (value === undefined) {
86
- alert('Please add value prop on Textarea component')
87
- }
88
-
89
- if (!onChange) {
90
- alert('Please add onChange function on Textarea component')
91
- }
92
-
93
- if (value === '') {
94
- setError('')
95
- }
96
-
97
- setInnerValue(value)
98
- }, [value, onChange])
99
-
100
- useEffect(() => {
101
- if (errorMessage) {
102
- setError(errorMessage)
103
- } else {
104
- setError('')
105
- }
106
- }, [errorMessage])
107
-
108
- return (
109
- <div
110
- style={{
111
- width: width ? width : configStyles.TEXTAREA.width,
112
- }}
113
- className={classProps}
114
- >
115
- <div
116
- style={{
117
- display: 'flex',
118
- alignItems: 'center',
119
- justifyContent: label ? 'space-between' : 'flex-end',
120
- fontFamily: labelFontFamily ? labelFontFamily : configStyles.TEXTAREA.labelFontFamily,
121
- marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.TEXTAREA.labelMarginBottom,
122
- }}
123
- >
124
- {label ? (
125
- <label
126
- style={{
127
- color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
128
- fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
129
- display: labelDisplay ? labelDisplay : configStyles.TEXTAREA.labelDisplay,
130
- fontWeight: labelWeight ? labelWeight : configStyles.TEXTAREA.labelWeight,
131
- }}
132
- >
133
- {label}
134
- {required && (
135
- <sup>
136
- <SvgRequired />
137
- </sup>
138
- )}
139
- </label>
140
- ) : (
141
- ''
142
- )}
143
-
144
- {showCharacterCount && maxLength && (
145
- <span
146
- style={{
147
- color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
148
- fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
149
- }}
150
- >
151
- {maxLength - value.length} նիշ
152
- </span>
153
- )}
154
- </div>
155
- <textarea
156
- style={{
157
- width: '100%',
158
- border: 'none',
159
- outline: 'none',
160
- overflow: 'auto',
161
- cursor: disabled ? 'not-allowed' : 'auto',
162
- fontSize: size ? size : configStyles.TEXTAREA.size,
163
- height: height ? height : configStyles.TEXTAREA.height,
164
- padding: padding ? padding : configStyles.TEXTAREA.padding,
165
- borderRadius: radius ? radius : configStyles.TEXTAREA.radius,
166
- minWidth: minWidth ? minWidth : configStyles.TEXTAREA.minWidth,
167
- maxWidth: maxWidth ? maxWidth : configStyles.TEXTAREA.maxWidth,
168
- minHeight: minHeight ? minHeight : configStyles.TEXTAREA.minHeight,
169
- maxHeight: maxHeight ? maxHeight : configStyles.TEXTAREA.maxHeight,
170
- boxSizing: boxSizing ? boxSizing : configStyles.TEXTAREA.boxSizing,
171
- backgroundColor: backgroundColor ? backgroundColor : configStyles.TEXTAREA.backgroundColor,
172
- boxShadow: error
173
- ? errorColor
174
- ? `0 0 0 2px ${errorColor}`
175
- : `0 0 0 2px ${configStyles.TEXTAREA.errorColor}`
176
- : isFocus
177
- ? borderFocusColor
178
- ? `0 0 0 2px ${borderFocusColor}`
179
- : `0 0 0 2px ${configStyles.TEXTAREA.borderFocusColor}`
180
- : isHover
181
- ? borderHoverColor
182
- ? `0 0 0 2px ${borderHoverColor}`
183
- : `0 0 0 2px ${configStyles.TEXTAREA.borderHoverColor}`
184
- : boxShadow
185
- ? boxShadow
186
- : configStyles.INPUT.boxShadow,
187
- resize: resize ? resize : configStyles.TEXTAREA.resize,
188
- }}
189
- value={innerValue}
190
- disabled={disabled}
191
- onBlur={handleBlur}
192
- onFocus={handleFocus}
193
- onChange={handleChange}
194
- placeholder={placeholder}
195
- onMouseEnter={handleMouseEnter}
196
- onMouseLeave={handleMouseLeave}
197
- ></textarea>
198
- {error ? (
199
- <span
200
- style={{
201
- display: 'inline-block',
202
- fontSize: errorSize ? errorSize : configStyles.TEXTAREA.errorSize,
203
- color: errorColor ? errorColor : configStyles.TEXTAREA.errorColor,
204
- marginTop: marginTop ? marginTop : configStyles.TEXTAREA.marginTop,
205
- }}
206
- >
207
- {error}
208
- </span>
209
- ) : (
210
- ''
211
- )}
212
- </div>
213
- )
214
- }
215
-
216
- Textarea.propTypes = {
217
- size: PropTypes.string,
218
- label: PropTypes.string,
219
- width: PropTypes.string,
220
- height: PropTypes.string,
221
- resize: PropTypes.string,
222
- radius: PropTypes.string,
223
- required: PropTypes.bool,
224
- disabled: PropTypes.bool,
225
- padding: PropTypes.string,
226
- minWidth: PropTypes.string,
227
- maxWidth: PropTypes.string,
228
- boxShadow: PropTypes.string,
229
- marginTop: PropTypes.string,
230
- boxSizing: PropTypes.string,
231
- minHeight: PropTypes.string,
232
- maxHeight: PropTypes.string,
233
- maxLength: PropTypes.number,
234
- labelSize: PropTypes.string,
235
- errorSize: PropTypes.string,
236
- className: PropTypes.string,
237
- labelColor: PropTypes.string,
238
- errorColor: PropTypes.string,
239
- labelWeight: PropTypes.string,
240
- placeholder: PropTypes.string,
241
- errorMessage: PropTypes.string,
242
- labelDisplay: PropTypes.string,
243
- labelFontFamily: PropTypes.string,
244
- backgroundColor: PropTypes.string,
245
- showCharacterCount: PropTypes.bool,
246
- value: PropTypes.string.isRequired,
247
- borderFocusColor: PropTypes.string,
248
- borderHoverColor: PropTypes.string,
249
- labelMarginBottom: PropTypes.string,
250
- onChange: PropTypes.func.isRequired,
251
- }
@@ -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,50 +0,0 @@
1
- import React, { useState } from 'react'
2
- import { Textarea } from '.'
3
-
4
- export default {
5
- Comment: Textarea,
6
- title: 'Components/Textarea',
7
- }
8
-
9
- const Template = (args) => {
10
- const [val, setVal] = useState('')
11
-
12
- const handleChangeValue = (value) => {
13
- setVal(value)
14
- }
15
-
16
- return <Textarea value={val} onChange={handleChangeValue} {...args} />
17
- }
18
-
19
- export const Default = Template.bind({})
20
- Default.args = {
21
- label: 'Label for textarea',
22
- required: true,
23
- disabled: false,
24
- size: '16px',
25
- radius: '6px',
26
- errorSize: '',
27
- width: '400px',
28
- errorColor: '',
29
- height: '134px',
30
- maxLength: 1500,
31
- errorMessage: '',
32
- color: '#3C393E',
33
- minWidth: '200px',
34
- maxWidth: '500px',
35
- labelSize: '16px',
36
- resize: 'vertical',
37
- minHeight: '100px',
38
- maxHeight: '300px',
39
- border: '2px solid',
40
- padding: '12px 15px',
41
- labelColor: '#3C393E',
42
- labelWeight: 'normal',
43
- labelDisplay: 'block',
44
- borderColor: '#D1D1D1',
45
- boxSizing: 'border-box',
46
- backgroundColor: 'white',
47
- showCharacterCount: true, // for showing textarea character count
48
- borderHoverColor: '#3C393E',
49
- borderFocusColor: '#00236A',
50
- }
@@ -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
- }