@xaypay/tui 0.0.104 → 0.0.106
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +30 -0
- package/.husky/pre-commit +4 -0
- package/.prettierrc +10 -0
- package/.storybook/main.js +42 -45
- package/.storybook/preview.js +7 -7
- package/cli-command.js +1 -1
- package/dist/index.es.js +183 -152
- package/dist/index.js +183 -152
- package/package.json +16 -4
- package/rollup.config.js +11 -11
- package/src/assets_old/icons/demo-files/demo.js +16 -18
- package/src/components/autocomplate/autocomplate.stories.js +30 -28
- package/src/components/autocomplate/index.js +145 -127
- package/src/components/button/button.stories.js +6 -6
- package/src/components/button/index.js +176 -126
- package/src/components/captcha/captcha.stories.js +12 -8
- package/src/components/captcha/index.js +47 -50
- package/src/components/checkbox/checkbox.stories.js +7 -7
- package/src/components/checkbox/index.js +77 -93
- package/src/components/file/file.stories.js +15 -15
- package/src/components/file/index.js +114 -116
- package/src/components/icon/Arrow.js +18 -18
- package/src/components/icon/CaptchaArrowDown.js +18 -18
- package/src/components/icon/CaptchaArrowUp.js +18 -18
- package/src/components/icon/CheckboxChecked.js +20 -20
- package/src/components/icon/CheckboxUnchecked.js +20 -20
- package/src/components/icon/Close.js +18 -18
- package/src/components/icon/CloseIcon.js +18 -18
- package/src/components/icon/CloseSlide.js +18 -18
- package/src/components/icon/DeleteComponent.js +19 -19
- package/src/components/icon/Dots.js +18 -18
- package/src/components/icon/HeartFilled.js +22 -23
- package/src/components/icon/HeartOutline.js +22 -22
- package/src/components/icon/Icon.js +3 -5
- package/src/components/icon/ListItemDelete.js +18 -18
- package/src/components/icon/ListItemJpeg.js +20 -20
- package/src/components/icon/ListItemJpg.js +20 -20
- package/src/components/icon/ListItemPdf.js +20 -20
- package/src/components/icon/ListItemPng.js +20 -20
- package/src/components/icon/Next.js +19 -19
- package/src/components/icon/Nextarrow.js +18 -18
- package/src/components/icon/PDF.js +18 -18
- package/src/components/icon/Prev.js +19 -19
- package/src/components/icon/RangeArrowDefault.js +41 -52
- package/src/components/icon/RangeArrowError.js +41 -52
- package/src/components/icon/RangeArrowSuccess.js +41 -52
- package/src/components/icon/RemoveFile.js +19 -19
- package/src/components/icon/ToasterClose.js +18 -18
- package/src/components/icon/ToasterError.js +18 -18
- package/src/components/icon/ToasterInfo.js +18 -18
- package/src/components/icon/ToasterSuccess.js +18 -18
- package/src/components/icon/ToasterWarning.js +18 -18
- package/src/components/icon/Tooltip.js +18 -18
- package/src/components/icon/Upload.js +24 -24
- package/src/components/input/index.js +267 -224
- package/src/components/input/input.stories.js +20 -21
- package/src/components/modal/index.js +172 -157
- package/src/components/modal/modal.stories.js +79 -78
- package/src/components/newAutocomplete/NewAutocomplete.stories.js +93 -51
- package/src/components/newAutocomplete/index.js +342 -216
- package/src/components/newFile/fileItem.js +213 -191
- package/src/components/newFile/index.js +231 -173
- package/src/components/newFile/newFile.stories.js +32 -35
- package/src/components/pagination/index.js +95 -126
- package/src/components/pagination/pagination.stories.js +363 -365
- package/src/components/pagination/paginationRange.js +42 -67
- package/src/components/radio/index.js +49 -62
- package/src/components/radio/radio.stories.js +7 -7
- package/src/components/select/index.js +316 -221
- package/src/components/select/select.stories.js +25 -14
- package/src/components/singleCheckbox/Checkbox.js +53 -0
- package/src/components/singleCheckbox/index.js +36 -36
- package/src/components/singleCheckbox/singleCheckbox.stories.js +21 -7
- package/src/components/stepper/index.js +35 -30
- package/src/components/stepper/stepper.stories.js +11 -11
- package/src/components/table/index.js +280 -148
- package/src/components/table/table.stories.js +105 -217
- package/src/components/table/td.js +80 -72
- package/src/components/table/th.js +19 -16
- package/src/components/textarea/index.js +86 -62
- package/src/components/textarea/textarea.stories.js +10 -13
- package/src/components/toaster/Toast.js +177 -159
- package/src/components/toaster/index.js +107 -111
- package/src/components/toaster/toaster.stories.js +582 -367
- package/src/components/tooltip/index.js +79 -46
- package/src/components/tooltip/tooltip.stories.js +9 -10
- package/src/components/typography/index.js +108 -101
- package/src/components/typography/typography.stories.js +16 -19
- package/src/index.js +20 -20
- package/src/stories/configuration.stories.mdx +9 -0
- package/src/utils/index.js +11 -11
- package/tui.config.js +345 -338
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
2
|
|
|
3
|
-
import { SingleCheckbox } from './../singleCheckbox'
|
|
3
|
+
import { SingleCheckbox } from './../singleCheckbox'
|
|
4
4
|
|
|
5
|
-
import styles from './table.module.css'
|
|
5
|
+
import styles from './table.module.css'
|
|
6
6
|
|
|
7
7
|
const TD = ({
|
|
8
|
-
id,
|
|
9
8
|
item,
|
|
10
9
|
tBodyColor,
|
|
11
10
|
borderRight,
|
|
@@ -15,13 +14,13 @@ const TD = ({
|
|
|
15
14
|
tBodyFontFamily,
|
|
16
15
|
tBodyFontWeight,
|
|
17
16
|
handleCheckedBody,
|
|
18
|
-
handleBodyActionClick
|
|
17
|
+
handleBodyActionClick,
|
|
19
18
|
}) => {
|
|
20
|
-
const [opend, setOpend] = useState(false)
|
|
19
|
+
const [opend, setOpend] = useState(false)
|
|
21
20
|
|
|
22
21
|
const handleOpenCloseSubTd = () => {
|
|
23
|
-
setOpend(!opend)
|
|
24
|
-
}
|
|
22
|
+
setOpend(!opend)
|
|
23
|
+
}
|
|
25
24
|
|
|
26
25
|
return (
|
|
27
26
|
<td
|
|
@@ -36,17 +35,16 @@ const TD = ({
|
|
|
36
35
|
fontWeight: tBodyFontWeight,
|
|
37
36
|
}}
|
|
38
37
|
>
|
|
39
|
-
{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
? item.map((newItem, newIndex) => {
|
|
38
|
+
{Array.isArray(item) ? (
|
|
39
|
+
item.length > 0 ? (
|
|
40
|
+
item.map((newItem, newIndex) => {
|
|
43
41
|
if (newItem && !Array.isArray(newItem) && typeof newItem === 'object') {
|
|
44
42
|
return (
|
|
45
43
|
<span
|
|
46
44
|
style={{
|
|
47
45
|
width: '32px',
|
|
48
46
|
height: '32px',
|
|
49
|
-
marginRight: '10px'
|
|
47
|
+
marginRight: '10px',
|
|
50
48
|
}}
|
|
51
49
|
id={newItem.id}
|
|
52
50
|
type={newItem.type}
|
|
@@ -54,21 +52,23 @@ const TD = ({
|
|
|
54
52
|
key={`${newItem}_${newIndex}`}
|
|
55
53
|
onClick={handleBodyActionClick}
|
|
56
54
|
>
|
|
57
|
-
{
|
|
55
|
+
{newItem.content}
|
|
58
56
|
</span>
|
|
59
57
|
)
|
|
60
58
|
} else if (newItem && Array.isArray(newItem)) {
|
|
61
59
|
return (
|
|
62
60
|
<span
|
|
61
|
+
key={newItem.id}
|
|
63
62
|
style={{
|
|
64
63
|
display: 'inline-block',
|
|
65
64
|
marginRight: newIndex !== item.length - 1 ? '10px' : '0px',
|
|
66
|
-
borderRight:
|
|
65
|
+
borderRight:
|
|
66
|
+
newIndex !== item.length - 1 ? '1px solid rgb(238, 238, 238)' : 'none',
|
|
67
67
|
}}
|
|
68
68
|
>
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
{item[newIndex].map((iT, iN) => {
|
|
70
|
+
return (
|
|
71
|
+
<span
|
|
72
72
|
style={{
|
|
73
73
|
width: '32px',
|
|
74
74
|
height: '32px',
|
|
@@ -80,60 +80,62 @@ const TD = ({
|
|
|
80
80
|
onClick={handleBodyActionClick}
|
|
81
81
|
key={`${iT.id || iT.content}_${iN}`}
|
|
82
82
|
>
|
|
83
|
-
{
|
|
83
|
+
{iT.content}
|
|
84
84
|
</span>
|
|
85
|
-
|
|
86
|
-
}
|
|
85
|
+
)
|
|
86
|
+
})}
|
|
87
87
|
</span>
|
|
88
|
-
)
|
|
88
|
+
)
|
|
89
89
|
} else {
|
|
90
|
-
return <span
|
|
91
|
-
key={`${newItem}_${newIndex}`}
|
|
92
|
-
>
|
|
93
|
-
{newItem}
|
|
94
|
-
</span>
|
|
90
|
+
return <span key={`${newItem}_${newIndex}`}>{newItem}</span>
|
|
95
91
|
}
|
|
96
92
|
})
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
93
|
+
) : (
|
|
94
|
+
<></>
|
|
95
|
+
)
|
|
96
|
+
) : item !== null && !Array.isArray(item) && typeof item === 'object' ? (
|
|
97
|
+
<div
|
|
98
|
+
style={{
|
|
99
|
+
display: 'flex',
|
|
100
|
+
alignItems: 'flex-start',
|
|
101
|
+
justifyContent: item.contentList || item.checkBox ? 'space-between' : 'center',
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{item.contentList && (
|
|
105
|
+
<div
|
|
107
106
|
id={item.id}
|
|
108
107
|
style={{
|
|
109
108
|
width: '21px',
|
|
110
|
-
height: '21px'
|
|
109
|
+
height: '21px',
|
|
111
110
|
}}
|
|
112
111
|
onClick={handleOpenCloseSubTd}
|
|
113
112
|
className={styles['td-span']}
|
|
114
113
|
>
|
|
115
|
-
{
|
|
114
|
+
{opend === false ? item.closeArrow : item.openArrow}
|
|
116
115
|
</div>
|
|
117
|
-
|
|
116
|
+
)}
|
|
118
117
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
118
|
+
{item.checkBox && (
|
|
119
|
+
<SingleCheckbox
|
|
120
|
+
data={item}
|
|
121
|
+
handleChecked={handleCheckedBody}
|
|
122
|
+
checked={item.checkBox.checked}
|
|
123
|
+
disabled={item.checkBox.disabled}
|
|
124
|
+
checkedColor={item.checkBox.checkedColor}
|
|
125
|
+
unCheckedColor={item.checkBox.unCheckedColor}
|
|
126
|
+
/>
|
|
127
|
+
)}
|
|
129
128
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
{item.
|
|
129
|
+
<div>
|
|
130
|
+
<p
|
|
131
|
+
style={{
|
|
132
|
+
margin: '0px',
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
{item.content}
|
|
136
|
+
</p>
|
|
137
|
+
{item.contentList && (
|
|
138
|
+
<div
|
|
137
139
|
style={{
|
|
138
140
|
overflow: 'hidden',
|
|
139
141
|
marginTop: '10px',
|
|
@@ -141,22 +143,28 @@ const TD = ({
|
|
|
141
143
|
}}
|
|
142
144
|
>
|
|
143
145
|
{item.contentList.map((innerItem, innerIndex) => {
|
|
144
|
-
return
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
146
|
+
return (
|
|
147
|
+
<p
|
|
148
|
+
key={`${innerItem}_${innerIndex}`}
|
|
149
|
+
style={{
|
|
150
|
+
margin: '0px',
|
|
151
|
+
textAlign: 'left',
|
|
152
|
+
paddingLeft: '10px',
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
{innerItem}
|
|
156
|
+
</p>
|
|
157
|
+
)
|
|
152
158
|
})}
|
|
153
|
-
</div>
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
159
|
+
</div>
|
|
160
|
+
)}
|
|
161
|
+
</div>
|
|
162
|
+
</div>
|
|
163
|
+
) : (
|
|
164
|
+
''
|
|
165
|
+
)}
|
|
158
166
|
</td>
|
|
159
167
|
)
|
|
160
|
-
}
|
|
168
|
+
}
|
|
161
169
|
|
|
162
|
-
export default TD
|
|
170
|
+
export default TD
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable no-prototype-builtins */
|
|
2
|
+
import React from 'react'
|
|
2
3
|
|
|
3
|
-
import { SingleCheckbox } from './../singleCheckbox'
|
|
4
|
+
import { SingleCheckbox } from './../singleCheckbox'
|
|
4
5
|
|
|
5
|
-
import styles from './table.module.css'
|
|
6
|
+
import styles from './table.module.css'
|
|
6
7
|
|
|
7
8
|
const TH = ({
|
|
8
9
|
item,
|
|
@@ -12,7 +13,7 @@ const TH = ({
|
|
|
12
13
|
handleCheckedHeader,
|
|
13
14
|
borderTopLeftRadius,
|
|
14
15
|
borderTopRightRadius,
|
|
15
|
-
handleHeaderItemClick
|
|
16
|
+
handleHeaderItemClick,
|
|
16
17
|
}) => {
|
|
17
18
|
return (
|
|
18
19
|
<th
|
|
@@ -23,33 +24,35 @@ const TH = ({
|
|
|
23
24
|
fontWeight: tHeadFontWeight,
|
|
24
25
|
borderTopLeftRadius: borderTopLeftRadius,
|
|
25
26
|
borderTopRightRadius: borderTopRightRadius,
|
|
26
|
-
cursor: handleHeaderItemClick ? 'pointer' : 'normal'
|
|
27
|
+
cursor: handleHeaderItemClick ? 'pointer' : 'normal',
|
|
27
28
|
}}
|
|
28
|
-
onClick={handleHeaderItemClick ? handleHeaderItemClick : _ => _}
|
|
29
|
+
onClick={handleHeaderItemClick ? handleHeaderItemClick : (_) => _}
|
|
29
30
|
className={`${item.sortingArrows && styles['sorting-arrows']}`}
|
|
30
31
|
>
|
|
31
32
|
<div
|
|
32
33
|
style={{
|
|
33
34
|
display: 'flex',
|
|
34
35
|
alignItems: 'flex-start',
|
|
35
|
-
justifyContent: item.hasOwnProperty('checkBox') ? 'space-between' : 'center'
|
|
36
|
+
justifyContent: item.hasOwnProperty('checkBox') ? 'space-between' : 'center',
|
|
36
37
|
}}
|
|
37
38
|
>
|
|
38
|
-
{item.hasOwnProperty('checkBox')
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
{item.hasOwnProperty('checkBox') ? (
|
|
40
|
+
<SingleCheckbox
|
|
41
|
+
data={item}
|
|
42
|
+
float="left"
|
|
41
43
|
checked={item.checkBox.checked}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
disabled={item.checkBox.disabled}
|
|
45
|
+
handleChecked={handleCheckedHeader ? handleCheckedHeader : (_) => _}
|
|
44
46
|
checkedColor={item.checkBox.checkedColor ? item.checkBox.checkedColor : ''}
|
|
45
47
|
unCheckedColor={item.checkBox.unCheckedColor ? item.checkBox.unCheckedColor : ''}
|
|
46
48
|
/>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
) : (
|
|
50
|
+
''
|
|
51
|
+
)}
|
|
49
52
|
{item.type === 'show' ? item.content : ''}
|
|
50
53
|
</div>
|
|
51
54
|
</th>
|
|
52
55
|
)
|
|
53
|
-
}
|
|
56
|
+
}
|
|
54
57
|
|
|
55
|
-
export default TH
|
|
58
|
+
export default TH
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react'
|
|
2
|
-
import PropTypes from 'prop-types'
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
3
|
|
|
4
|
-
import { compereConfigs } from
|
|
4
|
+
import { compereConfigs } from './../../utils'
|
|
5
5
|
|
|
6
|
-
import './textarea.module.css'
|
|
6
|
+
import './textarea.module.css'
|
|
7
7
|
|
|
8
8
|
export const Textarea = ({
|
|
9
9
|
size,
|
|
@@ -37,70 +37,70 @@ export const Textarea = ({
|
|
|
37
37
|
borderHoverColor,
|
|
38
38
|
labelMarginBottom,
|
|
39
39
|
showCharacterCount,
|
|
40
|
-
labelRequiredColor
|
|
40
|
+
labelRequiredColor,
|
|
41
41
|
}) => {
|
|
42
|
-
const [error, setError] = useState('')
|
|
43
|
-
const [isHover, setIsHover] = useState(false)
|
|
44
|
-
const [isFocus, setIsFocus] = useState(false)
|
|
45
|
-
const [innerValue, setInnerValue] = useState('')
|
|
42
|
+
const [error, setError] = useState('')
|
|
43
|
+
const [isHover, setIsHover] = useState(false)
|
|
44
|
+
const [isFocus, setIsFocus] = useState(false)
|
|
45
|
+
const [innerValue, setInnerValue] = useState('')
|
|
46
46
|
|
|
47
|
-
const configStyles = compereConfigs()
|
|
47
|
+
const configStyles = compereConfigs()
|
|
48
48
|
|
|
49
49
|
const handleMouseEnter = () => {
|
|
50
|
-
setIsHover(true)
|
|
51
|
-
}
|
|
52
|
-
|
|
50
|
+
setIsHover(true)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
53
|
const handleMouseLeave = () => {
|
|
54
|
-
setIsHover(false)
|
|
55
|
-
}
|
|
54
|
+
setIsHover(false)
|
|
55
|
+
}
|
|
56
56
|
|
|
57
57
|
const handleFocus = () => {
|
|
58
|
-
setIsFocus(true)
|
|
59
|
-
}
|
|
58
|
+
setIsFocus(true)
|
|
59
|
+
}
|
|
60
60
|
|
|
61
61
|
const handleBlur = () => {
|
|
62
|
-
setIsFocus(false)
|
|
63
|
-
}
|
|
62
|
+
setIsFocus(false)
|
|
63
|
+
}
|
|
64
64
|
|
|
65
65
|
const handleChange = (e) => {
|
|
66
|
-
const value = e.target.value
|
|
67
|
-
onChange(value)
|
|
66
|
+
const value = e.target.value
|
|
67
|
+
onChange(value)
|
|
68
68
|
if (maxLength) {
|
|
69
69
|
if (value.length > maxLength) {
|
|
70
|
-
onChange(value.substr(0, maxLength))
|
|
71
|
-
setError('Նիշերի քանակը գերազանցում է')
|
|
70
|
+
onChange(value.substr(0, maxLength))
|
|
71
|
+
setError('Նիշերի քանակը գերազանցում է')
|
|
72
72
|
} else {
|
|
73
|
-
setError('')
|
|
73
|
+
setError('')
|
|
74
74
|
}
|
|
75
75
|
} else {
|
|
76
76
|
if (value.length > configStyles.TEXTAREA.maxLength) {
|
|
77
|
-
setError('Նիշերի քանակը գերազանցում է')
|
|
78
|
-
onChange(value.substr(0, configStyles.TEXTAREA.maxLength))
|
|
77
|
+
setError('Նիշերի քանակը գերազանցում է')
|
|
78
|
+
onChange(value.substr(0, configStyles.TEXTAREA.maxLength))
|
|
79
79
|
} else {
|
|
80
|
-
setError('')
|
|
80
|
+
setError('')
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
|
-
}
|
|
83
|
+
}
|
|
84
84
|
|
|
85
85
|
useEffect(() => {
|
|
86
86
|
if (value === undefined) {
|
|
87
|
-
alert('Please add value prop on Textarea component')
|
|
87
|
+
alert('Please add value prop on Textarea component')
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
if (!onChange) {
|
|
91
|
-
alert('Please add onChange function on Textarea component')
|
|
91
|
+
alert('Please add onChange function on Textarea component')
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
setInnerValue(value)
|
|
95
|
-
}, [value, onChange])
|
|
94
|
+
setInnerValue(value)
|
|
95
|
+
}, [value, onChange])
|
|
96
96
|
|
|
97
97
|
useEffect(() => {
|
|
98
98
|
if (errorMessage) {
|
|
99
|
-
setError(errorMessage)
|
|
99
|
+
setError(errorMessage)
|
|
100
100
|
} else {
|
|
101
|
-
setError('')
|
|
101
|
+
setError('')
|
|
102
102
|
}
|
|
103
|
-
}, [errorMessage])
|
|
103
|
+
}, [errorMessage])
|
|
104
104
|
|
|
105
105
|
return (
|
|
106
106
|
<div
|
|
@@ -113,36 +113,45 @@ export const Textarea = ({
|
|
|
113
113
|
display: 'flex',
|
|
114
114
|
alignItems: 'center',
|
|
115
115
|
justifyContent: label ? 'space-between' : 'flex-end',
|
|
116
|
-
marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.TEXTAREA.labelMarginBottom
|
|
116
|
+
marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.TEXTAREA.labelMarginBottom,
|
|
117
117
|
}}
|
|
118
118
|
>
|
|
119
|
-
{
|
|
120
|
-
label
|
|
121
|
-
? <label
|
|
119
|
+
{label ? (
|
|
120
|
+
<label
|
|
122
121
|
style={{
|
|
123
122
|
color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
|
|
124
123
|
fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
|
|
125
124
|
display: labelDisplay ? labelDisplay : configStyles.TEXTAREA.labelDisplay,
|
|
126
|
-
fontWeight: labelWeight ? labelWeight : configStyles.TEXTAREA.labelWeight
|
|
125
|
+
fontWeight: labelWeight ? labelWeight : configStyles.TEXTAREA.labelWeight,
|
|
127
126
|
}}
|
|
128
127
|
>
|
|
129
128
|
{label}
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
{required && (
|
|
130
|
+
<sup
|
|
131
|
+
style={{
|
|
132
|
+
color: labelRequiredColor
|
|
133
|
+
? labelRequiredColor
|
|
134
|
+
: configStyles.TEXTAREA.labelRequiredColor,
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
*
|
|
138
|
+
</sup>
|
|
139
|
+
)}
|
|
134
140
|
</label>
|
|
135
|
-
|
|
136
|
-
|
|
141
|
+
) : (
|
|
142
|
+
''
|
|
143
|
+
)}
|
|
137
144
|
|
|
138
|
-
{
|
|
139
|
-
|
|
145
|
+
{showCharacterCount && maxLength && (
|
|
146
|
+
<span
|
|
140
147
|
style={{
|
|
141
148
|
color: labelColor ? labelColor : configStyles.TEXTAREA.labelColor,
|
|
142
149
|
fontSize: labelSize ? labelSize : configStyles.TEXTAREA.labelSize,
|
|
143
150
|
}}
|
|
144
|
-
>
|
|
145
|
-
|
|
151
|
+
>
|
|
152
|
+
{maxLength - value.length} նիշ
|
|
153
|
+
</span>
|
|
154
|
+
)}
|
|
146
155
|
</div>
|
|
147
156
|
<textarea
|
|
148
157
|
style={{
|
|
@@ -160,10 +169,21 @@ export const Textarea = ({
|
|
|
160
169
|
maxHeight: maxHeight ? maxHeight : configStyles.TEXTAREA.maxHeight,
|
|
161
170
|
boxSizing: boxSizing ? boxSizing : configStyles.TEXTAREA.boxSizing,
|
|
162
171
|
backgroundColor: backgroundColor ? backgroundColor : configStyles.TEXTAREA.backgroundColor,
|
|
163
|
-
boxShadow: error
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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,
|
|
167
187
|
resize: resize ? resize : configStyles.TEXTAREA.resize,
|
|
168
188
|
}}
|
|
169
189
|
value={innerValue}
|
|
@@ -174,19 +194,23 @@ export const Textarea = ({
|
|
|
174
194
|
onMouseEnter={handleMouseEnter}
|
|
175
195
|
onMouseLeave={handleMouseLeave}
|
|
176
196
|
></textarea>
|
|
177
|
-
{
|
|
178
|
-
|
|
197
|
+
{error ? (
|
|
198
|
+
<span
|
|
179
199
|
style={{
|
|
180
200
|
display: 'inline-block',
|
|
181
201
|
fontSize: errorSize ? errorSize : configStyles.TEXTAREA.errorSize,
|
|
182
202
|
color: errorColor ? errorColor : configStyles.TEXTAREA.errorColor,
|
|
183
|
-
marginTop: marginTop ? marginTop : configStyles.TEXTAREA.marginTop
|
|
203
|
+
marginTop: marginTop ? marginTop : configStyles.TEXTAREA.marginTop,
|
|
184
204
|
}}
|
|
185
|
-
>
|
|
186
|
-
|
|
205
|
+
>
|
|
206
|
+
{error}
|
|
207
|
+
</span>
|
|
208
|
+
) : (
|
|
209
|
+
''
|
|
210
|
+
)}
|
|
187
211
|
</div>
|
|
188
|
-
)
|
|
189
|
-
}
|
|
212
|
+
)
|
|
213
|
+
}
|
|
190
214
|
|
|
191
215
|
Textarea.propTypes = {
|
|
192
216
|
size: PropTypes.string,
|
|
@@ -220,5 +244,5 @@ Textarea.propTypes = {
|
|
|
220
244
|
borderHoverColor: PropTypes.string,
|
|
221
245
|
labelMarginBottom: PropTypes.string,
|
|
222
246
|
onChange: PropTypes.func.isRequired,
|
|
223
|
-
labelRequiredColor: PropTypes.string
|
|
247
|
+
labelRequiredColor: PropTypes.string,
|
|
224
248
|
}
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { Textarea } from '.'
|
|
3
|
-
import { Input } from '../input';
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Textarea } from '.'
|
|
4
3
|
|
|
5
4
|
export default {
|
|
6
5
|
Comment: Textarea,
|
|
7
|
-
title: 'Components/Textarea'
|
|
6
|
+
title: 'Components/Textarea',
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
const Template = (args) => {
|
|
11
|
-
const [val, setVal] = useState('')
|
|
10
|
+
const [val, setVal] = useState('')
|
|
12
11
|
|
|
13
12
|
const handleChangeValue = (value) => {
|
|
14
|
-
setVal(value)
|
|
13
|
+
setVal(value)
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
);
|
|
20
|
-
};
|
|
16
|
+
return <Textarea value={val} onChange={handleChangeValue} {...args} />
|
|
17
|
+
}
|
|
21
18
|
|
|
22
|
-
export const Default = Template.bind({})
|
|
19
|
+
export const Default = Template.bind({})
|
|
23
20
|
Default.args = {
|
|
24
21
|
label: 'Label for textarea',
|
|
25
22
|
required: true,
|
|
@@ -46,8 +43,8 @@ Default.args = {
|
|
|
46
43
|
borderColor: '#D1D1D1',
|
|
47
44
|
boxSizing: 'border-box',
|
|
48
45
|
backgroundColor: 'white',
|
|
49
|
-
showCharacterCount: true,
|
|
46
|
+
showCharacterCount: true, // for showing textarea character count
|
|
50
47
|
borderHoverColor: '#3C393E',
|
|
51
48
|
borderFocusColor: '#00236A',
|
|
52
49
|
labelRequiredColor: '#ee0000',
|
|
53
|
-
}
|
|
50
|
+
}
|