@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.
Files changed (93) hide show
  1. package/.eslintrc.js +30 -0
  2. package/.husky/pre-commit +4 -0
  3. package/.prettierrc +10 -0
  4. package/.storybook/main.js +42 -45
  5. package/.storybook/preview.js +7 -7
  6. package/cli-command.js +1 -1
  7. package/dist/index.es.js +105 -94
  8. package/dist/index.js +105 -94
  9. package/package.json +16 -4
  10. package/rollup.config.js +11 -11
  11. package/src/assets_old/icons/demo-files/demo.js +16 -18
  12. package/src/components/autocomplate/autocomplate.stories.js +30 -28
  13. package/src/components/autocomplate/index.js +145 -127
  14. package/src/components/button/button.stories.js +6 -6
  15. package/src/components/button/index.js +176 -126
  16. package/src/components/captcha/captcha.stories.js +12 -8
  17. package/src/components/captcha/index.js +47 -50
  18. package/src/components/checkbox/checkbox.stories.js +7 -7
  19. package/src/components/checkbox/index.js +77 -93
  20. package/src/components/file/file.stories.js +15 -15
  21. package/src/components/file/index.js +114 -116
  22. package/src/components/icon/Arrow.js +18 -18
  23. package/src/components/icon/CaptchaArrowDown.js +18 -18
  24. package/src/components/icon/CaptchaArrowUp.js +18 -18
  25. package/src/components/icon/CheckboxChecked.js +20 -20
  26. package/src/components/icon/CheckboxUnchecked.js +20 -20
  27. package/src/components/icon/Close.js +18 -18
  28. package/src/components/icon/CloseIcon.js +18 -18
  29. package/src/components/icon/CloseSlide.js +18 -18
  30. package/src/components/icon/DeleteComponent.js +19 -19
  31. package/src/components/icon/Dots.js +18 -18
  32. package/src/components/icon/HeartFilled.js +22 -23
  33. package/src/components/icon/HeartOutline.js +22 -22
  34. package/src/components/icon/Icon.js +3 -5
  35. package/src/components/icon/ListItemDelete.js +18 -18
  36. package/src/components/icon/ListItemJpeg.js +20 -20
  37. package/src/components/icon/ListItemJpg.js +20 -20
  38. package/src/components/icon/ListItemPdf.js +20 -20
  39. package/src/components/icon/ListItemPng.js +20 -20
  40. package/src/components/icon/Next.js +19 -19
  41. package/src/components/icon/Nextarrow.js +18 -18
  42. package/src/components/icon/PDF.js +18 -18
  43. package/src/components/icon/Prev.js +19 -19
  44. package/src/components/icon/RangeArrowDefault.js +41 -52
  45. package/src/components/icon/RangeArrowError.js +41 -52
  46. package/src/components/icon/RangeArrowSuccess.js +41 -52
  47. package/src/components/icon/RemoveFile.js +19 -19
  48. package/src/components/icon/ToasterClose.js +18 -18
  49. package/src/components/icon/ToasterError.js +18 -18
  50. package/src/components/icon/ToasterInfo.js +18 -18
  51. package/src/components/icon/ToasterSuccess.js +18 -18
  52. package/src/components/icon/ToasterWarning.js +18 -18
  53. package/src/components/icon/Tooltip.js +18 -18
  54. package/src/components/icon/Upload.js +24 -24
  55. package/src/components/input/index.js +267 -224
  56. package/src/components/input/input.stories.js +20 -21
  57. package/src/components/modal/index.js +172 -159
  58. package/src/components/modal/modal.stories.js +79 -78
  59. package/src/components/newAutocomplete/NewAutocomplete.stories.js +93 -51
  60. package/src/components/newAutocomplete/index.js +342 -216
  61. package/src/components/newFile/fileItem.js +214 -191
  62. package/src/components/newFile/index.js +235 -173
  63. package/src/components/newFile/newFile.stories.js +32 -35
  64. package/src/components/pagination/index.js +97 -122
  65. package/src/components/pagination/pagination.stories.js +362 -362
  66. package/src/components/pagination/paginationRange.js +42 -53
  67. package/src/components/radio/index.js +49 -62
  68. package/src/components/radio/radio.stories.js +7 -7
  69. package/src/components/select/index.js +318 -223
  70. package/src/components/select/select.stories.js +25 -14
  71. package/src/components/singleCheckbox/Checkbox.js +31 -34
  72. package/src/components/singleCheckbox/index.js +36 -45
  73. package/src/components/singleCheckbox/singleCheckbox.stories.js +16 -16
  74. package/src/components/stepper/index.js +35 -30
  75. package/src/components/stepper/stepper.stories.js +11 -11
  76. package/src/components/table/index.js +280 -148
  77. package/src/components/table/table.stories.js +105 -217
  78. package/src/components/table/td.js +80 -72
  79. package/src/components/table/th.js +19 -16
  80. package/src/components/textarea/index.js +86 -62
  81. package/src/components/textarea/textarea.stories.js +10 -13
  82. package/src/components/toaster/Toast.js +180 -158
  83. package/src/components/toaster/index.js +108 -111
  84. package/src/components/toaster/toaster.module.css +13 -0
  85. package/src/components/toaster/toaster.stories.js +582 -367
  86. package/src/components/tooltip/index.js +79 -46
  87. package/src/components/tooltip/tooltip.stories.js +9 -10
  88. package/src/components/typography/index.js +108 -101
  89. package/src/components/typography/typography.stories.js +16 -19
  90. package/src/index.js +20 -20
  91. package/src/stories/configuration.stories.mdx +1 -0
  92. package/src/utils/index.js +11 -11
  93. package/tui.config.js +343 -340
@@ -1,21 +1,21 @@
1
- import React, { useEffect, useState } from "react";
2
- import PropTypes from "prop-types";
3
- import classnames from "classnames";
4
- import { compereConfigs } from "./../../utils";
5
- import styled, { keyframes, css } from 'styled-components';
1
+ import React, { useEffect, useState } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import classnames from 'classnames'
4
+ import { compereConfigs } from './../../utils'
5
+ import styled, { keyframes, css } from 'styled-components'
6
6
 
7
- import styles from "./input.module.css";
7
+ import styles from './input.module.css'
8
8
 
9
9
  export const InputTypes = {
10
10
  TEL: 'tel',
11
- TEXT: "text",
11
+ TEXT: 'text',
12
12
  NUMBER: 'number',
13
- PASSWORD: "password",
14
- };
13
+ PASSWORD: 'password',
14
+ }
15
15
 
16
16
  const P = styled.span`
17
- animation: ${props => props.errorAnimation ? props.animation : 'none'};
18
- `;
17
+ animation: ${(props) => (props.errorAnimation ? props.animation : 'none')};
18
+ `
19
19
 
20
20
  export const Input = ({
21
21
  type,
@@ -58,7 +58,6 @@ export const Input = ({
58
58
  errorMessage,
59
59
  autoComplete,
60
60
  labelDisplay,
61
- errorPosition,
62
61
  boxShadowHover,
63
62
  errorClassName,
64
63
  errorAnimation,
@@ -76,18 +75,18 @@ export const Input = ({
76
75
  errorAnimationDuration,
77
76
  ...props
78
77
  }) => {
79
- const phoneNumberRegex = /^\d+$/;
80
- const [show, setShow] = useState(false);
81
- const [isHover, setIsHover] = useState(false);
82
- const [innerValue, setInnerValue] = useState('');
83
- const [innerErrorMessage, setInnerErrorMessage] = useState('');
84
-
85
- const random = Math.floor((Math.random() * 1000) + 1);
86
- const configStyles = compereConfigs();
78
+ const phoneNumberRegex = /^\d+$/
79
+ const [show, setShow] = useState(false)
80
+ const [isHover, setIsHover] = useState(false)
81
+ const [innerValue, setInnerValue] = useState('')
82
+ const [innerErrorMessage, setInnerErrorMessage] = useState('')
83
+
84
+ const random = Math.floor(Math.random() * 1000 + 1)
85
+ const configStyles = compereConfigs()
87
86
  const classProps = classnames(
88
87
  className ? className : configStyles.INPUT.className,
89
88
  type === 'number' ? styles['inp-num'] : ''
90
- );
89
+ )
91
90
 
92
91
  const errorShow = keyframes`
93
92
  100% {
@@ -98,165 +97,169 @@ export const Input = ({
98
97
  -ms-transform: scale3d(1,1,1);
99
98
  -o-transform: scale3d(1,1,1);
100
99
  }
101
- `;
100
+ `
102
101
 
103
- const animation = _ => css`
104
- ${errorShow} ${errorAnimationDuration ? errorAnimationDuration : configStyles.INPUT.errorAnimationDuration} forwards
105
- `;
102
+ const animation = () => css`
103
+ ${errorShow} ${errorAnimationDuration
104
+ ? errorAnimationDuration
105
+ : configStyles.INPUT.errorAnimationDuration} forwards
106
+ `
106
107
 
107
108
  const handleChange = (event) => {
108
- const currentValue = event.target.value;
109
+ const currentValue = event.target.value
110
+
111
+ let prevValue = innerValue
109
112
 
110
- let prevValue = innerValue;
111
-
112
- setInnerValue(() => currentValue);
113
+ setInnerValue(() => currentValue)
113
114
  if (change) {
114
- change(currentValue);
115
+ change(currentValue)
115
116
  }
116
-
117
+
117
118
  if (type === 'tel') {
118
119
  if (!phoneNumberRegex.test(currentValue)) {
119
120
  if (currentValue === '') {
120
- setInnerErrorMessage('');
121
+ setInnerErrorMessage('')
121
122
  } else {
122
- telErrorMessage ? setInnerErrorMessage(telErrorMessage) : setInnerErrorMessage(configStyles.INPUT.telErrorMessage);
123
- setInnerValue(prevValue);
123
+ telErrorMessage
124
+ ? setInnerErrorMessage(telErrorMessage)
125
+ : setInnerErrorMessage(configStyles.INPUT.telErrorMessage)
126
+ setInnerValue(prevValue)
124
127
  if (change) {
125
- change(prevValue);
128
+ change(prevValue)
126
129
  }
127
130
  }
128
131
  } else {
129
- setInnerErrorMessage('');
132
+ setInnerErrorMessage('')
130
133
  if (currentValue.length > 8) {
131
- setInnerValue(currentValue.substr(0, 8));
134
+ setInnerValue(currentValue.substr(0, 8))
132
135
  if (change) {
133
- change(currentValue.substr(0, 8));
136
+ change(currentValue.substr(0, 8))
134
137
  }
135
138
  }
136
139
  }
137
140
  }
138
141
 
139
142
  if (type === 'number') {
140
- const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
141
-
143
+ const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/
144
+
142
145
  if (minNumSize && currentValue < minNumSize) {
143
- setInnerValue(`${minNumSize}`);
146
+ setInnerValue(`${minNumSize}`)
144
147
  if (change) {
145
- change(`${minNumSize}`);
148
+ change(`${minNumSize}`)
146
149
  }
147
150
  }
148
151
  if (maxNumSize && currentValue > maxNumSize) {
149
- setInnerValue(`${maxNumSize}`);
152
+ setInnerValue(`${maxNumSize}`)
150
153
  if (change) {
151
- change(`${maxNumSize}`);
154
+ change(`${maxNumSize}`)
152
155
  }
153
156
  }
154
157
  if (floatToFix > 0) {
155
- const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue;
156
- const int = floatNumParts[0];
157
- const float = floatNumParts[1];
158
-
158
+ const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue
159
+ const int = floatNumParts[0]
160
+ const float = floatNumParts[1]
161
+
159
162
  if (float) {
160
163
  if (float[0] === '0' || float[0] !== '0') {
161
164
  if (float[1] === undefined) {
162
- setInnerValue(`${int}.${float[0]}`);
165
+ setInnerValue(`${int}.${float[0]}`)
163
166
  if (change) {
164
- change(`${int}.${float[0]}`);
167
+ change(`${int}.${float[0]}`)
165
168
  }
166
169
  } else if (float[1] === '0') {
167
170
  if (float[2] === undefined || float[2] === '0') {
168
- setInnerValue(`${int}.${float[0]}`);
171
+ setInnerValue(`${int}.${float[0]}`)
169
172
  if (change) {
170
- change(`${int}.${float[0]}`);
173
+ change(`${int}.${float[0]}`)
171
174
  }
172
175
  } else if (float[2] !== undefined && float[2] !== '0') {
173
- setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`);
176
+ setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`)
174
177
  if (change) {
175
- change(`${int}.${float[0]}${float[1]}${float[2]}`);
178
+ change(`${int}.${float[0]}${float[1]}${float[2]}`)
176
179
  }
177
180
  }
178
181
  } else if (float[1] !== undefined && float[1] !== '0') {
179
182
  if (float[2] === undefined || float[2] === '0') {
180
- setInnerValue(`${int}.${float[0]}${float[1]}`);
183
+ setInnerValue(`${int}.${float[0]}${float[1]}`)
181
184
  if (change) {
182
- change(`${int}.${float[0]}${float[1]}`);
185
+ change(`${int}.${float[0]}${float[1]}`)
183
186
  }
184
187
  } else if (float[2] !== undefined && float[2] !== '0') {
185
- setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`);
188
+ setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`)
186
189
  if (change) {
187
- change(`${int}.${float[0]}${float[1]}${float[2]}`);
190
+ change(`${int}.${float[0]}${float[1]}${float[2]}`)
188
191
  }
189
192
  }
190
193
  }
191
194
  }
192
195
  }
193
196
  } else {
194
- const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue;
195
- const int = floatNumParts[0];
197
+ const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue
198
+ const int = floatNumParts[0]
196
199
  if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
197
- setInnerValue(`${int}`);
200
+ setInnerValue(`${int}`)
198
201
  if (change) {
199
- change(`${int}`);
202
+ change(`${int}`)
200
203
  }
201
204
  }
202
205
  }
203
206
 
204
207
  if (!regNum.test(currentValue)) {
205
- const newStr = currentValue.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
206
- return b + c.replace(/\./g, '');
207
- });
208
- setInnerValue(newStr);
208
+ const newStr = currentValue.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
209
+ return b + c.replace(/\./g, '')
210
+ })
211
+ setInnerValue(newStr)
209
212
  if (change) {
210
- change(newStr);
213
+ change(newStr)
211
214
  }
212
215
  }
213
216
  if (currentValue === '') {
214
- setInnerValue('');
217
+ setInnerValue('')
215
218
  if (change) {
216
- change('');
219
+ change('')
217
220
  }
218
221
  }
219
222
  }
220
223
 
221
224
  if (maxLength && currentValue.length > maxLength && type !== 'tel') {
222
- setInnerValue(currentValue.substr(0, maxLength));
225
+ setInnerValue(currentValue.substr(0, maxLength))
223
226
  if (change) {
224
- change(currentValue.substr(0, maxLength));
227
+ change(currentValue.substr(0, maxLength))
225
228
  }
226
229
  }
227
230
 
228
231
  if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
229
- !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
232
+ !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('')
230
233
  if (change) {
231
- change(currentValue);
234
+ change(currentValue)
232
235
  }
233
236
  }
234
- };
237
+ }
235
238
 
236
239
  const handleMouseEnter = () => {
237
- setIsHover(true);
238
- };
239
-
240
+ setIsHover(true)
241
+ }
242
+
240
243
  const handleMouseLeave = () => {
241
- setIsHover(false);
242
- };
244
+ setIsHover(false)
245
+ }
243
246
 
244
247
  const handleShowPass = () => {
245
- setShow(!show);
246
- };
248
+ setShow(!show)
249
+ }
247
250
 
248
251
  useEffect(() => {
249
252
  if (errorMessage) {
250
- setInnerErrorMessage(errorMessage);
253
+ setInnerErrorMessage(errorMessage)
251
254
  } else {
252
- setInnerErrorMessage('');
255
+ setInnerErrorMessage('')
253
256
  }
254
257
 
255
258
  if (value !== undefined) {
256
259
  if (value === null) {
257
- setInnerValue('');
260
+ setInnerValue('')
258
261
  } else {
259
- setInnerValue(value);
262
+ setInnerValue(value)
260
263
  if (type === 'tel') {
261
264
  // TODO: discussion
262
265
  // if (!phoneNumberRegex.test(value)) {
@@ -273,95 +276,95 @@ export const Input = ({
273
276
  // }
274
277
  // }
275
278
  if (value.length <= 8) {
276
- setInnerValue(value);
279
+ setInnerValue(value)
277
280
  } else {
278
- setInnerValue(value.substr(0, 8));
281
+ setInnerValue(value.substr(0, 8))
279
282
  }
280
- }
283
+ }
281
284
 
282
285
  if (type === 'number') {
283
- const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
284
-
286
+ const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/
287
+
285
288
  if (minNumSize && value < minNumSize) {
286
- setInnerValue(`${minNumSize}`);
289
+ setInnerValue(`${minNumSize}`)
287
290
  if (change) {
288
- change(`${minNumSize}`);
291
+ change(`${minNumSize}`)
289
292
  }
290
293
  }
291
294
  if (maxNumSize && value > maxNumSize) {
292
- setInnerValue(`${maxNumSize}`);
295
+ setInnerValue(`${maxNumSize}`)
293
296
  if (change) {
294
- change(`${maxNumSize}`);
297
+ change(`${maxNumSize}`)
295
298
  }
296
299
  }
297
300
  if (floatToFix > 0) {
298
- const floatNumParts = typeof value === 'string' ? value.split('.') : value;
299
- const int = floatNumParts[0];
300
- const float = floatNumParts[1];
301
-
301
+ const floatNumParts = typeof value === 'string' ? value.split('.') : value
302
+ const int = floatNumParts[0]
303
+ const float = floatNumParts[1]
304
+
302
305
  if (float) {
303
306
  if (float[0] === '0' || float[0] !== '0') {
304
307
  if (float[1] === undefined) {
305
- setInnerValue(`${int}.${float[0]}`);
308
+ setInnerValue(`${int}.${float[0]}`)
306
309
  if (change) {
307
- change(`${int}.${float[0]}`);
310
+ change(`${int}.${float[0]}`)
308
311
  }
309
312
  } else if (float[1] === '0') {
310
313
  if (float[2] === undefined || float[2] === '0') {
311
- setInnerValue(`${int}.${float[0]}`);
314
+ setInnerValue(`${int}.${float[0]}`)
312
315
  if (change) {
313
- change(`${int}.${float[0]}`);
316
+ change(`${int}.${float[0]}`)
314
317
  }
315
318
  } else if (float[2] !== undefined && float[2] !== '0') {
316
- setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`);
319
+ setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`)
317
320
  if (change) {
318
- change(`${int}.${float[0]}${float[1]}${float[2]}`);
321
+ change(`${int}.${float[0]}${float[1]}${float[2]}`)
319
322
  }
320
323
  }
321
324
  } else if (float[1] !== undefined && float[1] !== '0') {
322
325
  if (float[2] === undefined || float[2] === '0') {
323
- setInnerValue(`${int}.${float[0]}${float[1]}`);
326
+ setInnerValue(`${int}.${float[0]}${float[1]}`)
324
327
  if (change) {
325
- change(`${int}.${float[0]}${float[1]}`);
328
+ change(`${int}.${float[0]}${float[1]}`)
326
329
  }
327
330
  } else if (float[2] !== undefined && float[2] !== '0') {
328
- setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`);
331
+ setInnerValue(`${int}.${float[0]}${float[1]}${float[2]}`)
329
332
  if (change) {
330
- change(`${int}.${float[0]}${float[1]}${float[2]}`);
333
+ change(`${int}.${float[0]}${float[1]}${float[2]}`)
331
334
  }
332
335
  }
333
336
  }
334
337
  }
335
338
  }
336
339
  } else {
337
- const floatNumParts = typeof value === 'string' ? value.split('.') : value;
338
- const int = floatNumParts[0];
340
+ const floatNumParts = typeof value === 'string' ? value.split('.') : value
341
+ const int = floatNumParts[0]
339
342
  if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
340
- setInnerValue(`${int}`);
343
+ setInnerValue(`${int}`)
341
344
  if (change) {
342
- change(`${int}`);
345
+ change(`${int}`)
343
346
  }
344
347
  }
345
348
  }
346
349
  if (!regNum.test(value)) {
347
- const newStr = value.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
348
- return b + c.replace(/\./g, '');
349
- });
350
- setInnerValue(newStr);
350
+ const newStr = value.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
351
+ return b + c.replace(/\./g, '')
352
+ })
353
+ setInnerValue(newStr)
351
354
  if (change) {
352
- change(newStr);
355
+ change(newStr)
353
356
  }
354
357
  }
355
358
  if (value === '') {
356
- setInnerValue('');
359
+ setInnerValue('')
357
360
  if (change) {
358
- change('');
361
+ change('')
359
362
  }
360
363
  }
361
364
  }
362
365
 
363
366
  if (maxLength && value.length > maxLength && type !== 'tel') {
364
- setInnerValue(value.substr(0, maxLength));
367
+ setInnerValue(value.substr(0, maxLength))
365
368
  }
366
369
 
367
370
  if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
@@ -369,97 +372,124 @@ export const Input = ({
369
372
  }
370
373
  }
371
374
  }
372
- }, [type, value, regexp, maxLength, errorMessage, regexpErrorMessage, telErrorMessage]);
375
+ }, [type, value, regexp, maxLength, errorMessage, regexpErrorMessage, telErrorMessage])
373
376
 
374
377
  return (
375
- <div className={`${styles["input-wrap"]}`}>
376
- {
377
- label ? <label
378
- className={`${styles["input-title"]}`}
378
+ <div className={`${styles['input-wrap']}`}>
379
+ {label ? (
380
+ <label
381
+ className={`${styles['input-title']}`}
379
382
  style={{
380
383
  color: labelColor ? labelColor : configStyles.INPUT.labelColor,
381
384
  fontSize: labelSize ? labelSize : configStyles.INPUT.labelSize,
382
385
  display: labelDisplay ? labelDisplay : configStyles.INPUT.labelDisplay,
383
386
  fontWeight: labelWeight ? labelWeight : configStyles.INPUT.labelWeight,
384
387
  lineHeight: labelLineHeight ? labelLineHeight : configStyles.INPUT.labelLineHeight,
385
- marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.INPUT.labelMarginBottom
388
+ marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.INPUT.labelMarginBottom,
386
389
  }}
387
390
  >
388
- {label} {required && <sup style={{ color: errorColor ? errorColor : "#ee0000" }}>*</sup>}
391
+ {label} {required && <sup style={{ color: errorColor ? errorColor : '#ee0000' }}>*</sup>}
389
392
  </label>
390
- : ''
391
- }
393
+ ) : (
394
+ ''
395
+ )}
392
396
  <div
393
- className={`${styles["input-content"]}`}
397
+ className={`${styles['input-content']}`}
394
398
  style={{
395
399
  width: width ? width : configStyles.INPUT.width,
396
400
  borderRadius: radius ? radius : configStyles.INPUT.radius,
397
- boxShadow: innerErrorMessage ? errorColor ? `0 0 0 2px ${errorColor}` : `0 0 0 2px ${configStyles.INPUT.errorColor}` : isHover ? boxShadowHover ? boxShadowHover : configStyles.INPUT.boxShadowHover : boxShadow ? boxShadow : configStyles.INPUT.boxShadow
401
+ boxShadow: innerErrorMessage
402
+ ? errorColor
403
+ ? `0 0 0 2px ${errorColor}`
404
+ : `0 0 0 2px ${configStyles.INPUT.errorColor}`
405
+ : isHover
406
+ ? boxShadowHover
407
+ ? boxShadowHover
408
+ : configStyles.INPUT.boxShadowHover
409
+ : boxShadow
410
+ ? boxShadow
411
+ : configStyles.INPUT.boxShadow,
398
412
  }}
399
413
  onMouseEnter={handleMouseEnter}
400
414
  onMouseLeave={handleMouseLeave}
401
415
  >
402
- {
403
- leftIcon && leftIcon.length > 0 && type != 'tel' ?
404
- <div
405
- onClick={type === 'password' ? handleShowPass : _ => _}
406
- style={{
407
- display: 'flex',
408
- alignItems: 'center',
409
- justifyContent: 'center',
410
- cursor: type === 'password' ? 'pointer' : 'default',
411
- height: height ? height : configStyles.INPUT.height,
412
- padding: padding ? padding : configStyles.INPUT.padding,
413
- width: iconWidth ? iconWidth : configStyles.INPUT.iconWidth,
414
- boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
415
- borderTopLeftRadius: radius ? radius : configStyles.INPUT.radius,
416
- borderBottomLeftRadius: radius ? radius : configStyles.INPUT.radius,
417
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.backgroundColor,
418
- }}
419
- >
420
- {type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]}
421
- </div> : ''
422
- }
423
- {
424
- type === 'tel' ?
425
- <div
426
- style={{
427
- pointerEvents: disabled ? 'none' : 'auto',
428
- fontSize: size ? size : configStyles.INPUT.size,
429
- height: height ? height : configStyles.INPUT.height,
430
- padding: padding ? padding : configStyles.INPUT.padding,
431
- boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
432
- borderTopLeftRadius: radius ? radius : configStyles.INPUT.radius,
433
- borderBottomLeftRadius: radius ? radius : configStyles.INPUT.radius,
434
- display: phoneDisplay ? phoneDisplay : configStyles.INPUT.phoneDisplay,
435
- borderRight: borderRight ? borderRight : configStyles.INPUT.borderRight,
436
- alignItems: phoneAlignItems ? phoneAlignItems : configStyles.INPUT.phoneAlignItems,
437
- borderColor:
438
- innerErrorMessage ? errorColor ? errorColor : configStyles.INPUT.errorColor :
439
- isHover
440
- ?
441
- borderRightColorHover ? borderRightColorHover : configStyles.INPUT.borderRightColorHover
442
- :
443
- borderRightColor ? borderRightColor : configStyles.INPUT.borderRightColor,
444
- color: innerErrorMessage && errorColor ? errorColor : color ? color : configStyles.INPUT.color,
445
- justifyContent: phoneJustifyContent ? phoneJustifyContent : configStyles.INPUT.phoneJustifyContent,
446
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.backgroundColor,
447
- }}
448
- >
449
- +374
450
- </div>
451
- : ''
452
- }
416
+ {leftIcon && leftIcon.length > 0 && type != 'tel' ? (
417
+ <div
418
+ onClick={type === 'password' ? handleShowPass : (_) => _}
419
+ style={{
420
+ display: 'flex',
421
+ alignItems: 'center',
422
+ justifyContent: 'center',
423
+ cursor: type === 'password' ? 'pointer' : 'default',
424
+ height: height ? height : configStyles.INPUT.height,
425
+ padding: padding ? padding : configStyles.INPUT.padding,
426
+ width: iconWidth ? iconWidth : configStyles.INPUT.iconWidth,
427
+ boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
428
+ borderTopLeftRadius: radius ? radius : configStyles.INPUT.radius,
429
+ borderBottomLeftRadius: radius ? radius : configStyles.INPUT.radius,
430
+ backgroundColor: disabled
431
+ ? '#FBFBFB'
432
+ : backgroundColor
433
+ ? backgroundColor
434
+ : configStyles.INPUT.backgroundColor,
435
+ }}
436
+ >
437
+ {type === 'password' ? (show ? leftIcon[1] : leftIcon[0]) : leftIcon[0]}
438
+ </div>
439
+ ) : (
440
+ ''
441
+ )}
442
+ {type === 'tel' ? (
443
+ <div
444
+ style={{
445
+ pointerEvents: disabled ? 'none' : 'auto',
446
+ fontSize: size ? size : configStyles.INPUT.size,
447
+ height: height ? height : configStyles.INPUT.height,
448
+ padding: padding ? padding : configStyles.INPUT.padding,
449
+ boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
450
+ borderTopLeftRadius: radius ? radius : configStyles.INPUT.radius,
451
+ borderBottomLeftRadius: radius ? radius : configStyles.INPUT.radius,
452
+ display: phoneDisplay ? phoneDisplay : configStyles.INPUT.phoneDisplay,
453
+ borderRight: borderRight ? borderRight : configStyles.INPUT.borderRight,
454
+ alignItems: phoneAlignItems ? phoneAlignItems : configStyles.INPUT.phoneAlignItems,
455
+ borderColor: innerErrorMessage
456
+ ? errorColor
457
+ ? errorColor
458
+ : configStyles.INPUT.errorColor
459
+ : isHover
460
+ ? borderRightColorHover
461
+ ? borderRightColorHover
462
+ : configStyles.INPUT.borderRightColorHover
463
+ : borderRightColor
464
+ ? borderRightColor
465
+ : configStyles.INPUT.borderRightColor,
466
+ color:
467
+ innerErrorMessage && errorColor ? errorColor : color ? color : configStyles.INPUT.color,
468
+ justifyContent: phoneJustifyContent
469
+ ? phoneJustifyContent
470
+ : configStyles.INPUT.phoneJustifyContent,
471
+ backgroundColor: disabled
472
+ ? '#FBFBFB'
473
+ : backgroundColor
474
+ ? backgroundColor
475
+ : configStyles.INPUT.backgroundColor,
476
+ }}
477
+ >
478
+ +374
479
+ </div>
480
+ ) : (
481
+ ''
482
+ )}
453
483
  <input
454
484
  {...props}
455
485
  value={innerValue}
456
486
  className={classProps}
457
487
  onInput={handleChange}
458
- disabled={disabled ? disabled : ""}
488
+ disabled={disabled ? disabled : ''}
459
489
  name={name ? name : `tui_${random}_tui`}
460
490
  placeholder={placeholder ? placeholder : ''}
461
491
  type={show || type === 'number' ? 'text' : type}
462
- min={type === 'number' && minNumSize ? minNumSize: ''}
492
+ min={type === 'number' && minNumSize ? minNumSize : ''}
463
493
  max={type === 'number' && maxNumSize ? maxNumSize : ''}
464
494
  autoComplete={autoComplete ? autoComplete : configStyles.INPUT.autoComplete}
465
495
  style={{
@@ -473,13 +503,18 @@ export const Input = ({
473
503
  borderRadius: radius ? radius : configStyles.INPUT.radius,
474
504
  boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
475
505
  color: innerErrorMessage && errorColor ? errorColor : color ? color : configStyles.INPUT.color,
476
- backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : configStyles.INPUT.backgroundDisableColor : backgroundColor ? backgroundColor : configStyles.INPUT.backgroundColor
506
+ backgroundColor: disabled
507
+ ? backgroundDisableColor
508
+ ? backgroundDisableColor
509
+ : configStyles.INPUT.backgroundDisableColor
510
+ : backgroundColor
511
+ ? backgroundColor
512
+ : configStyles.INPUT.backgroundColor,
477
513
  }}
478
514
  />
479
- {
480
- rightIcon && rightIcon.length > 0 ?
515
+ {rightIcon && rightIcon.length > 0 ? (
481
516
  <div
482
- onClick={type === 'password' ? handleShowPass : _ => _}
517
+ onClick={type === 'password' ? handleShowPass : (_) => _}
483
518
  style={{
484
519
  display: 'flex',
485
520
  alignItems: 'center',
@@ -491,42 +526,50 @@ export const Input = ({
491
526
  boxSizing: boxSizing ? boxSizing : configStyles.INPUT.boxSizing,
492
527
  borderTopRightRadius: radius ? radius : configStyles.INPUT.radius,
493
528
  borderBottomRightRadius: radius ? radius : configStyles.INPUT.radius,
494
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : configStyles.INPUT.backgroundColor,
529
+ backgroundColor: disabled
530
+ ? '#FBFBFB'
531
+ : backgroundColor
532
+ ? backgroundColor
533
+ : configStyles.INPUT.backgroundColor,
495
534
  }}
496
535
  >
497
- {type === 'password' ? show ? rightIcon[1] : rightIcon[0] : rightIcon[0]}
498
- </div> : ''
499
- }
536
+ {type === 'password' ? (show ? rightIcon[1] : rightIcon[0]) : rightIcon[0]}
537
+ </div>
538
+ ) : (
539
+ ''
540
+ )}
500
541
  </div>
501
- {
502
- tooltip ? tooltip : ''
503
- }
504
- {
505
- innerErrorMessage ?
506
- <P
507
- errorAnimation={errorAnimation}
508
- animation={animation}
509
- style={{
510
- margin: '0px',
511
- position: 'absolute',
512
- width: width ? width : configStyles.INPUT.width,
513
- left: errorLeft ? errorLeft : configStyles.INPUT.errorLeft,
514
- color: errorColor ? errorColor : configStyles.INPUT.errorColor,
515
- fontSize: errorSize ? errorSize : configStyles.INPUT.errorSize,
516
- zIndex: errorZindex ? errorZindex : configStyles.INPUT.errorZindex,
517
- lineHeight: errorLineHeight ? errorLineHeight : configStyles.INPUT.errorLineHeight,
518
- top: marginTop ? `calc(100% + ${marginTop})` : `calc(100% + ${configStyles.INPUT.marginTop})`,
519
- transform: !errorAnimation ? 'scale3d(1,1,1)' : transform ? transform : configStyles.INPUT.transform,
520
- }}
521
- className={errorClassName ? errorClassName : configStyles.INPUT.errorClassName}
522
- >
523
- {innerErrorMessage}
524
- </P>
525
- : ''
526
- }
542
+ {tooltip ? tooltip : ''}
543
+ {innerErrorMessage ? (
544
+ <P
545
+ errorAnimation={errorAnimation}
546
+ animation={animation}
547
+ style={{
548
+ margin: '0px',
549
+ position: 'absolute',
550
+ width: width ? width : configStyles.INPUT.width,
551
+ left: errorLeft ? errorLeft : configStyles.INPUT.errorLeft,
552
+ color: errorColor ? errorColor : configStyles.INPUT.errorColor,
553
+ fontSize: errorSize ? errorSize : configStyles.INPUT.errorSize,
554
+ zIndex: errorZindex ? errorZindex : configStyles.INPUT.errorZindex,
555
+ lineHeight: errorLineHeight ? errorLineHeight : configStyles.INPUT.errorLineHeight,
556
+ top: marginTop ? `calc(100% + ${marginTop})` : `calc(100% + ${configStyles.INPUT.marginTop})`,
557
+ transform: !errorAnimation
558
+ ? 'scale3d(1,1,1)'
559
+ : transform
560
+ ? transform
561
+ : configStyles.INPUT.transform,
562
+ }}
563
+ className={errorClassName ? errorClassName : configStyles.INPUT.errorClassName}
564
+ >
565
+ {innerErrorMessage}
566
+ </P>
567
+ ) : (
568
+ ''
569
+ )}
527
570
  </div>
528
- );
529
- };
571
+ )
572
+ }
530
573
 
531
574
  Input.propTypes = {
532
575
  name: PropTypes.string,
@@ -584,9 +627,9 @@ Input.propTypes = {
584
627
  leftIcon: PropTypes.arrayOf(PropTypes.element),
585
628
  rightIcon: PropTypes.arrayOf(PropTypes.element),
586
629
  type: PropTypes.oneOf(Object.values(InputTypes)),
587
- value: PropTypes.oneOfType([PropTypes.string, PropTypes.object])
588
- };
630
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
631
+ }
589
632
 
590
633
  Input.defaultProps = {
591
- type: "text",
592
- };
634
+ type: 'text',
635
+ }