@xaypay/tui 0.0.69 → 0.0.71

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 (69) hide show
  1. package/dist/index.es.js +1323 -294
  2. package/dist/index.js +1323 -292
  3. package/package.json +3 -2
  4. package/src/assets/range-arrow-default.svg +19 -0
  5. package/src/assets/range-arrow-error.svg +19 -0
  6. package/src/assets/range-arrow-success.svg +19 -0
  7. package/src/components/captcha/captcha.module.css +61 -62
  8. package/src/components/captcha/captcha.stories.js +5 -4
  9. package/src/components/captcha/index.js +146 -56
  10. package/src/components/file/file.module.css +1 -1
  11. package/src/components/file/index.js +10 -8
  12. package/src/components/icon/Arrow.js +2 -2
  13. package/src/components/icon/CaptchaArrowDown.js +19 -0
  14. package/src/components/icon/CaptchaArrowUp.js +19 -0
  15. package/src/components/icon/CheckboxChecked.js +2 -2
  16. package/src/components/icon/CheckboxUnchecked.js +2 -2
  17. package/src/components/icon/CloseIcon.js +2 -2
  18. package/src/components/icon/DeleteComponent.js +20 -0
  19. package/src/components/icon/Dots.js +6 -6
  20. package/src/components/icon/ListItemDelete.js +19 -0
  21. package/src/components/icon/ListItemJpg.js +21 -0
  22. package/src/components/icon/ListItemPdf.js +21 -0
  23. package/src/components/icon/Nextarrow.js +19 -0
  24. package/src/components/icon/PDF.js +19 -0
  25. package/src/components/icon/RangeArrowDefault.js +54 -0
  26. package/src/components/icon/RangeArrowError.js +54 -0
  27. package/src/components/icon/RangeArrowSuccess.js +54 -0
  28. package/src/components/icon/RemoveFile.js +20 -0
  29. package/src/components/icon/ToasterClose.js +2 -2
  30. package/src/components/icon/ToasterError.js +2 -2
  31. package/src/components/icon/ToasterInfo.js +2 -2
  32. package/src/components/icon/ToasterSuccess.js +2 -2
  33. package/src/components/icon/ToasterWarning.js +2 -2
  34. package/src/components/icon/Tooltip.js +2 -2
  35. package/src/components/icon/Upload.js +25 -0
  36. package/src/components/icon/index.js +1 -10
  37. package/src/components/input/index.js +36 -31
  38. package/src/components/newAutocomplete/NewAutocomplete.stories.js +50 -0
  39. package/src/components/newAutocomplete/index.js +407 -0
  40. package/src/components/newFile/index.js +463 -0
  41. package/src/components/newFile/newFile.stories.js +41 -0
  42. package/src/components/pagination/index.js +5 -5
  43. package/src/components/textarea/index.js +63 -27
  44. package/src/components/textarea/textarea.stories.js +3 -3
  45. package/src/components/toaster/Toast.js +1 -1
  46. package/src/components/tooltip/index.js +2 -2
  47. package/src/index.js +3 -1
  48. package/src/stories/configuration.stories.mdx +87 -0
  49. package/src/stories/static/captcha-usage.png +0 -0
  50. package/src/stories/static/new-autocomplete-usage.png +0 -0
  51. package/src/stories/usage.stories.mdx +10 -3
  52. package/tui.config.js +120 -21
  53. package/src/assets/icons/arrow.svg +0 -3
  54. package/src/assets/icons/checkbox-checked.svg +0 -3
  55. package/src/assets/icons/checkbox-unchecked.svg +0 -3
  56. package/src/assets/icons/close-icon.svg +0 -3
  57. package/src/assets/icons/dots.svg +0 -3
  58. package/src/assets/icons/nextarrow.svg +0 -3
  59. package/src/assets/icons/toaster-close.svg +0 -3
  60. package/src/assets/icons/toaster-error.svg +0 -3
  61. package/src/assets/icons/toaster-info.svg +0 -3
  62. package/src/assets/icons/toaster-success.svg +0 -3
  63. package/src/assets/icons/toaster-warning.svg +0 -3
  64. package/src/assets/icons/tooltip.svg +0 -3
  65. package/src/assets/upload.svg +0 -4
  66. package/src/components/captcha/blue.png +0 -0
  67. package/src/components/captcha/green.png +0 -0
  68. package/src/components/captcha/red.png +0 -0
  69. package/src/components/icon/NextArrow.js +0 -19
@@ -0,0 +1,463 @@
1
+ import React, { useRef, useState, useEffect } from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import PropTypes from 'prop-types';
4
+ import { v4 as uuidv4 } from 'uuid';
5
+
6
+ import { compereConfigs } from './../../utils';
7
+
8
+ import SvgUpload from './../icon/Upload';
9
+ import SvgRemoveFile from './../icon/RemoveFile';
10
+ import SvgListItemPdf from './../icon/ListItemPdf';
11
+ import SvgListItemJpg from './../icon/ListItemJpg';
12
+ import SvgListItemDelete from './../icon/ListItemDelete';
13
+ import SvgDeleteComponent from './../icon/DeleteComponent';
14
+
15
+ export const NewFile = ({
16
+ size,
17
+ name,
18
+ color,
19
+ label,
20
+ width,
21
+ weight,
22
+ height,
23
+ radius,
24
+ change,
25
+ border,
26
+ maxSize,
27
+ disabled,
28
+ multiple,
29
+ required,
30
+ errorSize,
31
+ labelSize,
32
+ labelColor,
33
+ errorColor,
34
+ filesArray,
35
+ borderColor,
36
+ uploadColor,
37
+ defaultData,
38
+ errorMessage,
39
+ fileExtensions,
40
+ backgroundColor,
41
+ deleteComponent,
42
+ borderHoverColor,
43
+ progressTrackColor,
44
+ labelRequiredColor,
45
+ hiddenBackgroundColor,
46
+ extentionsRowMarginTop,
47
+ listItemBackgroundColor
48
+ }) => {
49
+ const ref = useRef(null);
50
+ const inpRef = useRef(null);
51
+ const [error, setError] = useState('');
52
+ const [image, setImage] = useState('');
53
+ const [progress, setProgress] = useState(5);
54
+ const [isHover, setIsHover] = useState(false);
55
+ const [multipleFiles, setMultipleFiles] = useState([]);
56
+
57
+ const configStyles = compereConfigs();
58
+
59
+ const handleRemoveComponent = () => {
60
+ const node = ReactDOM.findDOMNode(ref.current);
61
+ const parent = node.parentNode;
62
+ parent.removeChild(node);
63
+ };
64
+
65
+ const handleRemoveFile = () => {
66
+ if (!multiple) {
67
+ setImage('');
68
+ onChange(null);
69
+ }
70
+ };
71
+
72
+ const handleChange = (e) => {
73
+ const file = e.target.files;
74
+
75
+ if (file[0]) {
76
+ if (file[0].size <= maxSize * Math.pow(2, 20)) {
77
+ if (fileExtensions.includes(file[0].type.split('/')[1])) {
78
+ setError('');
79
+ if (multiple) {
80
+ change({
81
+ uuid: uuidv4(),
82
+ file: file[0]
83
+ });
84
+ } else {
85
+ change({file});
86
+ if (file[0].type === 'application/pdf') {
87
+ setImage('pdf');
88
+ } else {
89
+ setImage(URL.createObjectURL(file[0]));
90
+ }
91
+ }
92
+ } else {
93
+ setImage('')
94
+ setError('ֆայլի սխալ ֆորմատ');
95
+ }
96
+ } else {
97
+ setImage('')
98
+ setError('առավելագույն ծավալ');
99
+ }
100
+ } else {
101
+ // TODO:
102
+ if (!multiple || multiple && filesArray && filesArray.length === 0) {
103
+ setImage('');
104
+ setError('Ֆայլը ընտրված չէ');
105
+ }
106
+ }
107
+ };
108
+
109
+ const handleClick = () => {
110
+ if (!image) {
111
+ inpRef.current.click();
112
+ }
113
+ };
114
+
115
+ const handleMouseEnter = () => {
116
+ setIsHover(true);
117
+ };
118
+
119
+ const handleMouseLeave = () => {
120
+ setIsHover(false);
121
+ };
122
+
123
+ const handleStopPropagation = (e) => {
124
+ e.stopPropagation();
125
+ };
126
+
127
+ useEffect(() => {
128
+ if (!multiple && defaultData) {
129
+ if (defaultData.type && defaultData.type !== 'application/pdf') {
130
+ setImage(defaultData.url);
131
+ } else {
132
+ setImage('pdf');
133
+ }
134
+ }
135
+
136
+ if (multiple && !filesArray) {
137
+ alert('In multiple mode, you should add filesArray prop for drawing files');
138
+ }
139
+
140
+ if (filesArray) {
141
+ setMultipleFiles(filesArray);
142
+ }
143
+ }, [multiple, filesArray && filesArray.length, defaultData]);
144
+
145
+ useEffect(() => {
146
+ if (errorMessage) {
147
+ setError(errorMessage);
148
+ } else {
149
+ setError('');
150
+ }
151
+ }, [errorMessage]);
152
+
153
+ useEffect(() => {
154
+ if (!change) {
155
+ alert('Please add change prop on File component');
156
+ }
157
+ }, [change]);
158
+
159
+ console.log(multipleFiles, 'multipleFiles');
160
+
161
+ return (
162
+ <div
163
+ ref={ref}
164
+ style={{
165
+ width: width ? width : configStyles.File.width,
166
+ }}
167
+ >
168
+ <div
169
+ style={{
170
+ display: 'flex',
171
+ marginBottom: '6px',
172
+ alignItems: 'center',
173
+ justifyContent: label ? 'space-between' : 'flex-end'
174
+ }}
175
+ >
176
+ {
177
+ label && <label
178
+ style={{
179
+ color: labelColor ? labelColor : configStyles.File.labelColor,
180
+ fontSize: labelSize ? labelSize : configStyles.File.labelSize,
181
+ }}
182
+ >
183
+ {label}
184
+ {required &&
185
+ <sup
186
+ style={{color: labelRequiredColor ? labelRequiredColor : configStyles.File.labelRequiredColor}}
187
+ >*</sup>
188
+ }
189
+ </label>
190
+ }
191
+ {
192
+ deleteComponent && <span style={{cursor: 'pointer'}} onClick={handleRemoveComponent}>
193
+ <SvgDeleteComponent />
194
+ </span>
195
+ }
196
+ </div>
197
+
198
+
199
+ <div
200
+ style={{
201
+ width: '100%',
202
+ display: 'flex',
203
+ alignItems: 'center',
204
+ position: 'relative',
205
+ boxSizing: 'border-box',
206
+ justifyContent: 'center',
207
+ cursor: !disabled ? 'pointer' : 'not-allowed',
208
+ height: height ? height : configStyles.File.height,
209
+ border: border ? border : configStyles.File.border,
210
+ borderRadius: radius ? radius : configStyles.File.radius ,
211
+ backgroundColor: backgroundColor ? backgroundColor : configStyles.File.backgroundColor,
212
+ borderColor:
213
+ error ?
214
+ errorColor ? errorColor : configStyles.File.errorColor :
215
+ disabled ? borderColor ? borderColor : configStyles.File.borderColor :
216
+ isHover ? borderHoverColor ? borderHoverColor : configStyles.File.borderHoverColor :
217
+ borderColor ? borderColor : configStyles.File.borderColor
218
+ }}
219
+ onClick={handleClick}
220
+ onMouseEnter={handleMouseEnter}
221
+ onMouseLeave={handleMouseLeave}
222
+ >
223
+ <input
224
+ hidden
225
+ name={name}
226
+ type='file'
227
+ ref={inpRef}
228
+ disabled={disabled}
229
+ onChange={handleChange}
230
+ />
231
+
232
+ <div
233
+ style={{
234
+ width: '100%',
235
+ height: '100%',
236
+ display: 'flex',
237
+ textAlign: 'center',
238
+ alignItems: 'center',
239
+ flexDirection: 'column',
240
+ justifyContent: 'center',
241
+ color: color ? color : configStyles.File.color,
242
+ fontSize: size ? size : configStyles.File.size,
243
+ fontWeight: weight ? weight : configStyles.File.weight,
244
+ }}
245
+ >
246
+ {
247
+ !multiple && image ?
248
+ image === 'pdf' ?
249
+ <PDF /> :
250
+ <img
251
+ src={image}
252
+ style={{
253
+ maxHeight: '100%',
254
+ }}
255
+ alt='file preview'
256
+ />
257
+ : <>
258
+ <div>
259
+ <SvgUpload />
260
+ </div>
261
+
262
+ <div>
263
+ <p
264
+ style={{
265
+ margin: '0px'
266
+ }}
267
+ >
268
+ Տեղադրել ֆայլը այստեղ
269
+ <br />
270
+ կամ <span
271
+ style={{
272
+ color: uploadColor ? uploadColor : configStyles.File.uploadColor
273
+ }}
274
+ >Բեռնել</span>
275
+ </p>
276
+ </div>
277
+
278
+ <div
279
+ style={{
280
+ marginTop: extentionsRowMarginTop ? extentionsRowMarginTop : configStyles.File.extentionsRowMarginTop
281
+ }}
282
+ >
283
+ <p
284
+ style={{
285
+ margin: '0px'
286
+ }}
287
+ >
288
+ Առավելագույնը {maxSize}ՄԲ ( { fileExtensions.toString().split(',').join(', ') } )
289
+ </p>
290
+ </div>
291
+ </>
292
+ }
293
+ </div>
294
+
295
+
296
+
297
+ <div
298
+ style={{
299
+ position: 'absolute',
300
+ top: '0px',
301
+ left: '0px',
302
+ zIndex: '1',
303
+ width: '100%',
304
+ height: '100%',
305
+ padding: '10px',
306
+ cursor: 'default',
307
+ boxSizing: 'border-box',
308
+ alignItems: 'flex-start',
309
+ justifyContent: 'flex-end',
310
+ borderRadius: radius ? radius : configStyles.File.radius,
311
+ display: !multiple && !disabled && image && !error && isHover ? 'flex' : 'none',
312
+ backgroundColor: hiddenBackgroundColor ? hiddenBackgroundColor : configStyles.File.hiddenBackgroundColor
313
+ }}
314
+ onClick={handleStopPropagation}
315
+ >
316
+ <div
317
+ style={{
318
+ cursor: 'pointer'
319
+ }}
320
+ onClick={handleRemoveFile}
321
+ >
322
+ <SvgRemoveFile />
323
+ </div>
324
+ </div>
325
+ </div>
326
+
327
+ {
328
+ error ? <span
329
+ style={{
330
+ marginTop: '6px',
331
+ display: 'inline-block',
332
+ color: errorColor ? errorColor : configStyles.File.errorColor,
333
+ fontSize: errorSize ? errorSize : configStyles.File.errorSize
334
+ }}
335
+ >{ error }</span> : ''
336
+ }
337
+
338
+
339
+ {
340
+ multiple && multipleFiles && multipleFiles.length > 0 && multipleFiles.map((item, index) => {
341
+ return (
342
+ <div
343
+ key={`${item.file.name}_${index}`}
344
+ style={{
345
+ display: 'flex',
346
+ width: '100%',
347
+ height: '70px',
348
+ marginTop: '6px',
349
+ alignItems: 'center',
350
+ padding: '14px 20px',
351
+ boxSizing: 'border-box',
352
+ justifyContent: 'space-between',
353
+ borderRadius: radius ? radius : configStyles.File.radius,
354
+ backgroundColor: listItemBackgroundColor ? listItemBackgroundColor : configStyles.File.listItemBackgroundColor
355
+ }}
356
+ >
357
+ <div
358
+ style={{
359
+ width: '32px'
360
+ }}
361
+ >
362
+ {
363
+ item.file.type.split('/')[1].toLowerCase() === 'pdf' ? <SvgListItemPdf /> :
364
+ item.file.type.split('/')[1].toLowerCase() === 'jpeg' ? <SvgListItemJpg /> : ''
365
+ }
366
+ </div>
367
+
368
+
369
+ <div
370
+ style={{
371
+ position: 'relative',
372
+ display: 'flex',
373
+ height: '40px',
374
+ margin: '0px 14px',
375
+ alignItems: 'flex-end',
376
+ width: 'calc(100% - 82px)',
377
+ }}
378
+ >
379
+
380
+ <div>
381
+ <p className='new' >{item.file.name}</p>
382
+ </div>
383
+
384
+ <div
385
+ style={{
386
+ position: 'absolute',
387
+ left: '0px',
388
+ bottom: '5px',
389
+ width: '100%',
390
+ height: '4px',
391
+ borderRadius: '10px',
392
+ backgroundColor: progressTrackColor ? progressTrackColor : configStyles.File.progressTrackColor
393
+ }}
394
+ >
395
+ <div
396
+ style={{
397
+ width: progress + '%',
398
+ height: '100%',
399
+ borderRadius: '10px',
400
+ backgroundColor: 'green'
401
+ }}
402
+ >
403
+
404
+ </div>
405
+ </div>
406
+
407
+ </div>
408
+
409
+
410
+ <div
411
+ style={{
412
+ width: '22px',
413
+ cursor: 'pointer'
414
+ }}
415
+ >
416
+ <SvgListItemDelete />
417
+ </div>
418
+ </div>
419
+ )
420
+ })
421
+ }
422
+
423
+ </div>
424
+ );
425
+ };
426
+
427
+ NewFile.propTypes = {
428
+ size: PropTypes.string,
429
+ label: PropTypes.string,
430
+ width: PropTypes.string,
431
+ color: PropTypes.string,
432
+ height: PropTypes.string,
433
+ disabled: PropTypes.bool,
434
+ radius: PropTypes.string,
435
+ border: PropTypes.string,
436
+ required: PropTypes.bool,
437
+ weight: PropTypes.number,
438
+ maxSize: PropTypes.number,
439
+ errorSize: PropTypes.string,
440
+ labelSize: PropTypes.string,
441
+ labelColor: PropTypes.string,
442
+ errorColor: PropTypes.string,
443
+ borderColor: PropTypes.string,
444
+ uploadColor: PropTypes.string,
445
+ defaultData: PropTypes.object,
446
+ errorMessage: PropTypes.string,
447
+ deleteComponent: PropTypes.bool,
448
+ backgroundColor: PropTypes.string,
449
+ change: PropTypes.func.isRequired,
450
+ borderHoverColor: PropTypes.string,
451
+ labelRequiredColor: PropTypes.string,
452
+ progressTrackColor: PropTypes.string,
453
+ hiddenBackgroundColor: PropTypes.string,
454
+ extentionsRowMarginTop: PropTypes.string,
455
+ listItemBackgroundColor: PropTypes.string,
456
+ filesArray: PropTypes.arrayOf(PropTypes.object),
457
+ fileExtensions: PropTypes.arrayOf(PropTypes.string)
458
+ };
459
+
460
+ NewFile.defaultProps = {
461
+ maxSize: 5,
462
+ fileExtensions: ['jpg', 'jpeg', 'png', 'pdf']
463
+ };
@@ -0,0 +1,41 @@
1
+ import React, { useState } from 'react';
2
+ import { NewFile } from './index';
3
+
4
+ export default {
5
+ component: NewFile,
6
+ title: 'Components/NewFile',
7
+ argTypes: {
8
+ change: {
9
+ control: 'function'
10
+ }
11
+ }
12
+ };
13
+
14
+ const Template = (args) => {
15
+ const [files, setFiles] = useState([]);
16
+
17
+ const handleChange = (file) => {
18
+ setFiles(prev => {
19
+ return [
20
+ ...prev,
21
+ file
22
+ ]
23
+ });
24
+ };
25
+
26
+
27
+ return <NewFile change={handleChange} filesArray={files} {...args} />;
28
+ };
29
+
30
+ export const Default = Template.bind({});
31
+ Default.args = {
32
+ label: 'File component',
33
+ deleteComponent: true,
34
+ disabled: false,
35
+ defaultData: {
36
+ url: 'https://images.pexels.com/photos/753626/pexels-photo-753626.jpeg?auto=compress&cs=tinysrgb&w=1600',
37
+ type: "image/png",
38
+ },
39
+ multiple: true,
40
+ name: 'sss'
41
+ };
@@ -6,7 +6,7 @@ import { PaginationRange, Dots } from "./paginationRange";
6
6
  import Icon from "../icon/Icon";
7
7
 
8
8
  import DotsIcon from './../../components/icon/Dots';
9
- import SvgNextArrow from './../../components/icon/NextArrow';
9
+ import SvgNextarrow from './../../components/icon/Nextarrow';
10
10
 
11
11
  export const Pagination = ({
12
12
  onChange,
@@ -78,7 +78,7 @@ export const Pagination = ({
78
78
  onClick={onPrevious}
79
79
  disabled={currentPage === 1 ? true : false}
80
80
  >
81
- <SvgNextArrow />
81
+ <SvgNextarrow />
82
82
  </button>
83
83
 
84
84
  {paginationRange.map((pageNumber, id) => {
@@ -115,7 +115,7 @@ export const Pagination = ({
115
115
  transform: 'rotate(180deg)'
116
116
  }}
117
117
  >
118
- <SvgNextArrow />
118
+ <SvgNextarrow />
119
119
  </span>
120
120
  </>
121
121
  ) : (
@@ -132,7 +132,7 @@ export const Pagination = ({
132
132
  `${styles["pagination-jump-next-arrow"]} pagination-jump-next-arrow-rem`
133
133
  }
134
134
  >
135
- <SvgNextArrow />
135
+ <SvgNextarrow />
136
136
  </span>
137
137
  </>
138
138
  )}
@@ -162,7 +162,7 @@ export const Pagination = ({
162
162
  className={`${styles["pagination-btn"]} pagination-btn-rem`}
163
163
  disabled={currentPageNumber === lastPage ? true : false}
164
164
  >
165
- <SvgNextArrow />
165
+ <SvgNextarrow />
166
166
  </button>
167
167
  </ul>
168
168
  );
@@ -32,10 +32,12 @@ export const Textarea = ({
32
32
  backgroundColor,
33
33
  borderFocusColor,
34
34
  borderHoverColor,
35
+ showCharacterCount,
35
36
  labelRequiredColor
36
37
  }) => {
37
38
  const [isHover, setIsHover] = useState(false);
38
39
  const [isFocus, setIsFocus] = useState(false);
40
+ const [innerValue, setInnerValue] = useState('');
39
41
 
40
42
  const configStyles = compereConfigs();
41
43
 
@@ -55,6 +57,20 @@ export const Textarea = ({
55
57
  setIsFocus(false);
56
58
  };
57
59
 
60
+ const handleChange = (e) => {
61
+ const value = e.target.value;
62
+ onChange(value);
63
+ if (maxLength) {
64
+ if (value.length > maxLength) {
65
+ onChange(value.substr(0, maxLength));
66
+ }
67
+ } else {
68
+ if (value.length > configStyles.TEXTAREA.maxLength) {
69
+ onChange(value.substr(0, configStyles.TEXTAREA.maxLength));
70
+ }
71
+ }
72
+ };
73
+
58
74
  useEffect(() => {
59
75
  if (value === undefined) {
60
76
  alert('Please add value prop on Textarea component');
@@ -63,34 +79,57 @@ export const Textarea = ({
63
79
  if (!onChange) {
64
80
  alert('Please add onChange function on Textarea component');
65
81
  }
82
+
83
+ setInnerValue(value);
66
84
  }, [value, onChange]);
67
85
 
68
86
  return (
69
- <>
70
- {
71
- label
72
- ? <label
73
- style={{
74
- color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
75
- fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
76
- display: labelDisplay ? labelDisplay : configStyles.TEXTAREA.labelDisplay,
77
- fontWeight: labelWeight ? labelWeight : configStyles.TEXTAREA.labelWeight
78
- }}
79
- >
80
- {label}
81
- {
82
- required &&
83
- <sup style={{color: labelRequiredColor ? labelRequiredColor : configStyles.TEXTAREA.labelRequiredColor}}>*</sup>
84
- }
85
- </label>
86
- : ''
87
- }
87
+ <div
88
+ style={{
89
+ width: width ? width : configStyles.TEXTAREA.width,
90
+ }}
91
+ >
92
+ <div
93
+ style={{
94
+ display: 'flex',
95
+ alignItems: 'center',
96
+ justifyContent: label ? 'space-between' : 'flex-end'
97
+ }}
98
+ >
99
+ {
100
+ label
101
+ ? <label
102
+ style={{
103
+ color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
104
+ fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
105
+ display: labelDisplay ? labelDisplay : configStyles.TEXTAREA.labelDisplay,
106
+ fontWeight: labelWeight ? labelWeight : configStyles.TEXTAREA.labelWeight
107
+ }}
108
+ >
109
+ {label}
110
+ {
111
+ required &&
112
+ <sup style={{color: labelRequiredColor ? labelRequiredColor : configStyles.TEXTAREA.labelRequiredColor}}>*</sup>
113
+ }
114
+ </label>
115
+ : ''
116
+ }
117
+
118
+ {
119
+ showCharacterCount && maxLength && <span
120
+ style={{
121
+ color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
122
+ fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
123
+ }}
124
+ >{ maxLength - value.length } նիշ</span>
125
+ }
126
+ </div>
88
127
  <textarea
89
128
  style={{
129
+ width: '100%',
90
130
  outline: 'none',
91
131
  overflow: 'auto',
92
132
  fontSize: size ? size : configStyles.TEXTAREA.size,
93
- width: width ? width : configStyles.TEXTAREA.width,
94
133
  height: height ? height : configStyles.TEXTAREA.height,
95
134
  border: border ? border : configStyles.TEXTAREA.border,
96
135
  padding: padding ? padding : configStyles.TEXTAREA.padding,
@@ -106,19 +145,15 @@ export const Textarea = ({
106
145
  borderColor ? borderColor : configStyles.TEXTAREA.borderColor,
107
146
  resize: resize ? resize : configStyles.TEXTAREA.resize,
108
147
  }}
148
+ value={innerValue}
109
149
  onBlur={handleBlur}
110
- onChange={onChange}
111
150
  onFocus={handleFocus}
151
+ onChange={handleChange}
112
152
  placeholder={placeholder}
113
153
  onMouseEnter={handleMouseEnter}
114
154
  onMouseLeave={handleMouseLeave}
115
- value={
116
- maxLength ? value.length > maxLength ? value.substr(0, maxLength) : value :
117
- configStyles.TEXTAREA.maxLength ? value.length > configStyles.TEXTAREA.maxLength ? value.substr(0, configStyles.TEXTAREA.maxLength) : value :
118
- value
119
- }
120
155
  ></textarea>
121
- </>
156
+ </div>
122
157
  );
123
158
  };
124
159
 
@@ -145,6 +180,7 @@ Textarea.propTypes = {
145
180
  placeholder: PropTypes.string,
146
181
  labelDisplay: PropTypes.string,
147
182
  backgroundColor: PropTypes.string,
183
+ showCharacterCount: PropTypes.bool,
148
184
  value: PropTypes.string.isRequired,
149
185
  borderFocusColor: PropTypes.string,
150
186
  borderHoverColor: PropTypes.string,