@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.
- 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 +105 -94
- package/dist/index.js +105 -94
- 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 -159
- 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 +214 -191
- package/src/components/newFile/index.js +235 -173
- package/src/components/newFile/newFile.stories.js +32 -35
- package/src/components/pagination/index.js +97 -122
- package/src/components/pagination/pagination.stories.js +362 -362
- package/src/components/pagination/paginationRange.js +42 -53
- package/src/components/radio/index.js +49 -62
- package/src/components/radio/radio.stories.js +7 -7
- package/src/components/select/index.js +318 -223
- package/src/components/select/select.stories.js +25 -14
- package/src/components/singleCheckbox/Checkbox.js +31 -34
- package/src/components/singleCheckbox/index.js +36 -45
- package/src/components/singleCheckbox/singleCheckbox.stories.js +16 -16
- 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 +180 -158
- package/src/components/toaster/index.js +108 -111
- package/src/components/toaster/toaster.module.css +13 -0
- 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 +1 -0
- package/src/utils/index.js +11 -11
- package/tui.config.js +343 -340
|
@@ -1,13 +1,13 @@
|
|
|
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 classnames from 'classnames'
|
|
5
|
-
import { keyframes, css } from 'styled-components'
|
|
4
|
+
import classnames from 'classnames'
|
|
5
|
+
import { keyframes, css } from 'styled-components'
|
|
6
6
|
|
|
7
|
-
import { compereConfigs } from './../../utils'
|
|
7
|
+
import { compereConfigs } from './../../utils'
|
|
8
|
+
|
|
9
|
+
import styles from './autocomplete.module.css'
|
|
8
10
|
|
|
9
|
-
import styles from './autocomplete.module.css';
|
|
10
|
-
|
|
11
11
|
export const NewAutocomplete = ({
|
|
12
12
|
label,
|
|
13
13
|
change,
|
|
@@ -83,250 +83,353 @@ export const NewAutocomplete = ({
|
|
|
83
83
|
contentBottomRowMarginBottom,
|
|
84
84
|
contentBottomRowBackgroundColor,
|
|
85
85
|
contentBottomRowHoverBackgroundColor,
|
|
86
|
+
backgroundDisableColor,
|
|
86
87
|
...props
|
|
87
88
|
}) => {
|
|
88
|
-
const [id, setId] = useState('')
|
|
89
|
-
const [show, setShow] = useState(false)
|
|
90
|
-
const [isHover, setIsHover] = useState(false)
|
|
91
|
-
const [isFocus, setIsFocus] = useState(false)
|
|
92
|
-
const [innerError, setInnerError] = useState('')
|
|
93
|
-
const [innerValue, setInnerValue] = useState('')
|
|
94
|
-
const [innerOptions, setInnerOptions] = useState([])
|
|
95
|
-
const configStyles = compereConfigs()
|
|
89
|
+
const [id, setId] = useState('')
|
|
90
|
+
const [show, setShow] = useState(false)
|
|
91
|
+
const [isHover, setIsHover] = useState(false)
|
|
92
|
+
const [isFocus, setIsFocus] = useState(false)
|
|
93
|
+
const [innerError, setInnerError] = useState('')
|
|
94
|
+
const [innerValue, setInnerValue] = useState('')
|
|
95
|
+
const [innerOptions, setInnerOptions] = useState([])
|
|
96
|
+
const configStyles = compereConfigs()
|
|
96
97
|
const classProps = classnames(
|
|
97
98
|
className ? className : configStyles.NEWAUTOCOMPLETE.className,
|
|
98
99
|
styles['auto-complete']
|
|
99
|
-
)
|
|
100
|
+
)
|
|
100
101
|
|
|
101
102
|
const showOption = keyframes`
|
|
102
103
|
100% {
|
|
103
104
|
max-height: 400px;
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
`
|
|
106
107
|
|
|
107
|
-
const animation =
|
|
108
|
-
${showOption} ${showOptionDuration
|
|
109
|
-
|
|
108
|
+
const animation = () => css`
|
|
109
|
+
${showOption} ${showOptionDuration
|
|
110
|
+
? showOptionDuration
|
|
111
|
+
: configStyles.NEWAUTOCOMPLETE.showOptionDuration} linear forwards
|
|
112
|
+
`
|
|
110
113
|
|
|
111
114
|
const handleMouseEnter = () => {
|
|
112
|
-
setIsHover(true)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
+
setIsHover(true)
|
|
116
|
+
}
|
|
117
|
+
|
|
115
118
|
const handleMouseLeave = () => {
|
|
116
|
-
setIsHover(false)
|
|
117
|
-
}
|
|
119
|
+
setIsHover(false)
|
|
120
|
+
}
|
|
118
121
|
|
|
119
122
|
const handleRowMouseEnter = (e) => {
|
|
120
|
-
e.target.style.color = contentBottomRowHoverColor
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
123
|
+
e.target.style.color = contentBottomRowHoverColor
|
|
124
|
+
? contentBottomRowHoverColor
|
|
125
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowHoverColor
|
|
126
|
+
e.target.style.backgroundColor = contentBottomRowHoverBackgroundColor
|
|
127
|
+
? contentBottomRowHoverBackgroundColor
|
|
128
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowHoverBackgroundColor
|
|
129
|
+
}
|
|
130
|
+
|
|
124
131
|
const handleRowMouseLeave = (e) => {
|
|
125
|
-
e.target.style.color = contentBottomRowColor
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
e.target.style.color = contentBottomRowColor
|
|
133
|
+
? contentBottomRowColor
|
|
134
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowColor
|
|
135
|
+
e.target.style.backgroundColor = contentBottomRowBackgroundColor
|
|
136
|
+
? contentBottomRowBackgroundColor
|
|
137
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowBackgroundColor
|
|
138
|
+
}
|
|
128
139
|
|
|
129
140
|
const handleFocus = () => {
|
|
130
|
-
setIsFocus(true)
|
|
131
|
-
}
|
|
141
|
+
setIsFocus(true)
|
|
142
|
+
}
|
|
132
143
|
|
|
133
144
|
const handleBlur = () => {
|
|
134
|
-
setIsFocus(false)
|
|
135
|
-
}
|
|
145
|
+
setIsFocus(false)
|
|
146
|
+
}
|
|
136
147
|
|
|
137
148
|
const handleChange = (e) => {
|
|
138
|
-
const value = e.target.value
|
|
139
|
-
const currentId = e.target.id
|
|
140
|
-
value.length > 0 ? setShow(true) : setShow(false)
|
|
141
|
-
setInnerError('')
|
|
142
|
-
setInnerValue(value)
|
|
149
|
+
const value = e.target.value
|
|
150
|
+
const currentId = e.target.id
|
|
151
|
+
value.length > 0 ? setShow(true) : setShow(false)
|
|
152
|
+
setInnerError('')
|
|
153
|
+
setInnerValue(value)
|
|
143
154
|
if (value.length >= searchCount) {
|
|
144
|
-
change({ name: value, id: currentId })
|
|
155
|
+
change({ name: value, id: currentId })
|
|
145
156
|
} else {
|
|
146
|
-
change({ name: '', id: '' })
|
|
157
|
+
change({ name: '', id: '' })
|
|
147
158
|
}
|
|
148
|
-
}
|
|
159
|
+
}
|
|
149
160
|
|
|
150
161
|
const handleClick = (selectedValue) => {
|
|
151
|
-
setShow(false)
|
|
152
|
-
setId(selectedValue[keyNames.id])
|
|
153
|
-
setInnerValue(selectedValue[keyNames.name])
|
|
154
|
-
getItem(selectedValue)
|
|
155
|
-
}
|
|
162
|
+
setShow(false)
|
|
163
|
+
setId(selectedValue[keyNames.id])
|
|
164
|
+
setInnerValue(selectedValue[keyNames.name])
|
|
165
|
+
getItem(selectedValue)
|
|
166
|
+
}
|
|
156
167
|
|
|
157
168
|
const optionList = (
|
|
158
169
|
<>
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
170
|
+
{show && innerOptions && !disabled ? (
|
|
171
|
+
innerOptions.length > 0 ? (
|
|
172
|
+
<div
|
|
173
|
+
style={{
|
|
174
|
+
left: contentBottomLeft
|
|
175
|
+
? contentBottomLeft
|
|
176
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomLeft,
|
|
177
|
+
width: contentBottomWidth
|
|
178
|
+
? contentBottomWidth
|
|
179
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomWidth,
|
|
180
|
+
zIndex: contentBottomZindex
|
|
181
|
+
? contentBottomZindex
|
|
182
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomZindex,
|
|
183
|
+
borderRadius: contentBottomRadius
|
|
184
|
+
? contentBottomRadius
|
|
185
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRadius,
|
|
186
|
+
maxWidth: contentBottomMaxWidth
|
|
187
|
+
? contentBottomMaxWidth
|
|
188
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomMaxWidth,
|
|
189
|
+
overflow: contentBottomOverflow
|
|
190
|
+
? contentBottomOverflow
|
|
191
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomOverflow,
|
|
192
|
+
position: contentBottomPosition
|
|
193
|
+
? contentBottomPosition
|
|
194
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomPosition,
|
|
195
|
+
minHeight: contentBottomMinHeight
|
|
196
|
+
? contentBottomMinHeight
|
|
197
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomMinHeight,
|
|
198
|
+
boxShadow: contentBottomBoxShadow
|
|
199
|
+
? contentBottomBoxShadow
|
|
200
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomBoxShadow,
|
|
201
|
+
backgroundColor: contentBottomBackgroundColor
|
|
202
|
+
? contentBottomBackgroundColor
|
|
203
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomBackgroundColor,
|
|
204
|
+
top: contentTopHeight
|
|
205
|
+
? contentTopHeight.includes('rem')
|
|
206
|
+
? parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 3)) + 0.6 + 'rem'
|
|
207
|
+
: parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 2)) + 6 + 'px'
|
|
208
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopHeight.includes('rem')
|
|
209
|
+
? parseFloat(
|
|
210
|
+
configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(
|
|
211
|
+
0,
|
|
212
|
+
configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 3
|
|
213
|
+
)
|
|
214
|
+
) +
|
|
215
|
+
0.6 +
|
|
216
|
+
'rem'
|
|
217
|
+
: parseFloat(
|
|
218
|
+
configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(
|
|
219
|
+
0,
|
|
220
|
+
configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 2
|
|
221
|
+
)
|
|
222
|
+
) +
|
|
223
|
+
6 +
|
|
224
|
+
'px',
|
|
225
|
+
animation,
|
|
226
|
+
}}
|
|
227
|
+
>
|
|
164
228
|
<div
|
|
165
229
|
style={{
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
parseFloat(configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(0, configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 3)) + 0.6 + 'rem' :
|
|
182
|
-
parseFloat(configStyles.NEWAUTOCOMPLETE.contentTopHeight.substr(0, configStyles.NEWAUTOCOMPLETE.contentTopHeight.length - 2)) + 6 + 'px',
|
|
183
|
-
animation
|
|
230
|
+
display: contentBottomInnerDisplay
|
|
231
|
+
? contentBottomInnerDisplay
|
|
232
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomInnerDisplay,
|
|
233
|
+
overflowY: contentBottomInnerOverflowY
|
|
234
|
+
? contentBottomInnerOverflowY
|
|
235
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowY,
|
|
236
|
+
overflowX: contentBottomInnerOverflowX
|
|
237
|
+
? contentBottomInnerOverflowX
|
|
238
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowX,
|
|
239
|
+
maxHeight: contentBottomInnerMaxHeight
|
|
240
|
+
? contentBottomInnerMaxHeight
|
|
241
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomInnerMaxHeight,
|
|
242
|
+
flexDirection: contentBottomInnerDirection
|
|
243
|
+
? contentBottomInnerDirection
|
|
244
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomInnerDirection,
|
|
184
245
|
}}
|
|
185
246
|
>
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
247
|
+
{innerOptions.map((item) => {
|
|
248
|
+
return (
|
|
249
|
+
<p
|
|
250
|
+
key={item.id}
|
|
251
|
+
onMouseEnter={handleRowMouseEnter}
|
|
252
|
+
onMouseLeave={handleRowMouseLeave}
|
|
253
|
+
onClick={() => handleClick(item)}
|
|
254
|
+
style={{
|
|
255
|
+
flexShrink: 0,
|
|
256
|
+
color: contentBottomRowColor
|
|
257
|
+
? contentBottomRowColor
|
|
258
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowColor,
|
|
259
|
+
height: contentBottomRowHeight
|
|
260
|
+
? contentBottomRowHeight
|
|
261
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
|
|
262
|
+
cursor: contentBottomRowCursor
|
|
263
|
+
? contentBottomRowCursor
|
|
264
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowCursor,
|
|
265
|
+
display: contentBottomRowDisplay
|
|
266
|
+
? contentBottomRowDisplay
|
|
267
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowDisplay,
|
|
268
|
+
padding: contentBottomRowPadding
|
|
269
|
+
? contentBottomRowPadding
|
|
270
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
|
|
271
|
+
fontSize: contentBottomRowFontSize
|
|
272
|
+
? contentBottomRowFontSize
|
|
273
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowFontSize,
|
|
274
|
+
boxSizing: contentBottomRowBoxSizing
|
|
275
|
+
? contentBottomRowBoxSizing
|
|
276
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowBoxSizing,
|
|
277
|
+
fontWeight: contentBottomRowFontWeight
|
|
278
|
+
? contentBottomRowFontWeight
|
|
279
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowFontWeight,
|
|
280
|
+
lineHeight: contentBottomRowLineHeight
|
|
281
|
+
? contentBottomRowLineHeight
|
|
282
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowLineHeight,
|
|
283
|
+
alignItems: contentBottomRowAlignItems
|
|
284
|
+
? contentBottomRowAlignItems
|
|
285
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowAlignItems,
|
|
286
|
+
transition: contentBottomRowTransition
|
|
287
|
+
? contentBottomRowTransition
|
|
288
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowTransition,
|
|
289
|
+
marginBottom: contentBottomRowMarginBottom
|
|
290
|
+
? contentBottomRowMarginBottom
|
|
291
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowMarginBottom,
|
|
292
|
+
backgroundColor: contentBottomRowBackgroundColor
|
|
293
|
+
? contentBottomRowBackgroundColor
|
|
294
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowBackgroundColor,
|
|
295
|
+
}}
|
|
296
|
+
>
|
|
297
|
+
{item[keyNames.name]}
|
|
298
|
+
</p>
|
|
299
|
+
)
|
|
300
|
+
})}
|
|
226
301
|
</div>
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
302
|
+
</div>
|
|
303
|
+
) : innerOptions.length <= 0 ? (
|
|
304
|
+
innerError ? (
|
|
305
|
+
''
|
|
306
|
+
) : (
|
|
307
|
+
<span
|
|
308
|
+
style={{
|
|
309
|
+
position: 'absolute',
|
|
310
|
+
zIndex: '1',
|
|
311
|
+
color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
|
|
312
|
+
fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
|
|
313
|
+
top: marginTop
|
|
314
|
+
? `calc(100% + ${marginTop})`
|
|
315
|
+
: `calc(100% + ${configStyles.INPUT.marginTop})`,
|
|
316
|
+
padding: innerErrorPadding
|
|
317
|
+
? innerErrorPadding
|
|
318
|
+
: configStyles.NEWAUTOCOMPLETE.innerErrorPadding,
|
|
319
|
+
height: contentBottomRowHeight
|
|
320
|
+
? contentBottomRowHeight
|
|
321
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
|
|
322
|
+
lineHeight: contentBottomRowHeight
|
|
323
|
+
? contentBottomRowHeight
|
|
324
|
+
: configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
|
|
325
|
+
backgroundColor: innerErrorBackgroundColor
|
|
326
|
+
? innerErrorBackgroundColor
|
|
327
|
+
: configStyles.NEWAUTOCOMPLETE.innerErrorBackgroundColor,
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
{innerValue.length >= searchCount
|
|
331
|
+
? 'Նման տվյալ առկա չէ'
|
|
332
|
+
: `Լրացնել առնվազն ${searchCount} նիշ`}
|
|
333
|
+
</span>
|
|
334
|
+
)
|
|
335
|
+
) : (
|
|
336
|
+
''
|
|
337
|
+
)
|
|
338
|
+
) : (
|
|
339
|
+
''
|
|
340
|
+
)}
|
|
251
341
|
</>
|
|
252
|
-
)
|
|
342
|
+
)
|
|
253
343
|
|
|
254
344
|
useEffect(() => {
|
|
255
345
|
if (options === undefined) {
|
|
256
|
-
alert('Please add options prop')
|
|
346
|
+
alert('Please add options prop')
|
|
257
347
|
}
|
|
258
348
|
|
|
259
|
-
options &&
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
349
|
+
options &&
|
|
350
|
+
options.length > 0 &&
|
|
351
|
+
options.map((item) => {
|
|
352
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
353
|
+
if (!item.hasOwnProperty(keyNames.name)) {
|
|
354
|
+
alert(`Please add ${keyNames.name} property in items of options array`)
|
|
355
|
+
}
|
|
356
|
+
})
|
|
264
357
|
|
|
265
358
|
if (!getItem) {
|
|
266
|
-
alert('Please add getItem function for get choosen item from autocomplete')
|
|
359
|
+
alert('Please add getItem function for get choosen item from autocomplete')
|
|
267
360
|
}
|
|
268
361
|
|
|
269
|
-
options && setInnerOptions(options)
|
|
270
|
-
}, [options, options?.length, getItem])
|
|
362
|
+
options && setInnerOptions(options)
|
|
363
|
+
}, [options, options?.length, getItem])
|
|
271
364
|
|
|
272
365
|
useEffect(() => {
|
|
273
366
|
if (!change) {
|
|
274
|
-
alert('Please add change prop on New Autocomplete component')
|
|
367
|
+
alert('Please add change prop on New Autocomplete component')
|
|
275
368
|
}
|
|
276
|
-
}, [change])
|
|
369
|
+
}, [change])
|
|
277
370
|
|
|
278
371
|
useEffect(() => {
|
|
279
372
|
if (selected) {
|
|
280
|
-
setId(selected[keyNames.id])
|
|
281
|
-
setInnerValue(selected[keyNames.name])
|
|
373
|
+
setId(selected[keyNames.id])
|
|
374
|
+
setInnerValue(selected[keyNames.name])
|
|
282
375
|
} else {
|
|
283
|
-
setId('')
|
|
284
|
-
setInnerValue('')
|
|
376
|
+
setId('')
|
|
377
|
+
setInnerValue('')
|
|
285
378
|
}
|
|
286
|
-
}, [selected])
|
|
379
|
+
}, [selected])
|
|
287
380
|
|
|
288
381
|
useEffect(() => {
|
|
289
|
-
setInnerError(errorMessage)
|
|
290
|
-
}, [errorMessage])
|
|
291
|
-
|
|
382
|
+
setInnerError(errorMessage)
|
|
383
|
+
}, [errorMessage])
|
|
384
|
+
|
|
292
385
|
return (
|
|
293
386
|
<>
|
|
294
|
-
{
|
|
295
|
-
label
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
387
|
+
{label ? (
|
|
388
|
+
<label
|
|
389
|
+
style={{
|
|
390
|
+
color: labelColor ? labelColor : configStyles.NEWAUTOCOMPLETE.labelColor,
|
|
391
|
+
fontSize: labelSize ? labelSize : configStyles.NEWAUTOCOMPLETE.labelSize,
|
|
392
|
+
display: labelDisplay ? labelDisplay : configStyles.NEWAUTOCOMPLETE.labelDisplay,
|
|
393
|
+
fontWeight: labelWeight ? labelWeight : configStyles.NEWAUTOCOMPLETE.labelWeight,
|
|
394
|
+
lineHeight: labelLineHeight ? labelLineHeight : configStyles.NEWAUTOCOMPLETE.labelLineHeight,
|
|
395
|
+
maxWidth: contentTopMaxWidth
|
|
396
|
+
? contentTopMaxWidth
|
|
397
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
|
|
398
|
+
marginBottom: labelMarginBottom
|
|
399
|
+
? labelMarginBottom
|
|
400
|
+
: configStyles.NEWAUTOCOMPLETE.labelMarginBottom,
|
|
401
|
+
textTransform: labelTextTransform
|
|
402
|
+
? labelTextTransform
|
|
403
|
+
: configStyles.NEWAUTOCOMPLETE.labelTextTransform,
|
|
404
|
+
}}
|
|
405
|
+
>
|
|
406
|
+
{label}
|
|
407
|
+
{required && (
|
|
408
|
+
<sup
|
|
409
|
+
style={{
|
|
410
|
+
color: labelRequiredColor
|
|
411
|
+
? labelRequiredColor
|
|
412
|
+
: configStyles.NEWAUTOCOMPLETE.labelRequiredColor,
|
|
413
|
+
}}
|
|
414
|
+
>
|
|
415
|
+
*
|
|
416
|
+
</sup>
|
|
417
|
+
)}
|
|
418
|
+
</label>
|
|
419
|
+
) : (
|
|
420
|
+
''
|
|
421
|
+
)}
|
|
319
422
|
<div
|
|
320
423
|
style={{
|
|
321
424
|
display: contentDisplay ? contentDisplay : configStyles.NEWAUTOCOMPLETE.contentDisplay,
|
|
322
425
|
position: contentPosition ? contentPosition : configStyles.NEWAUTOCOMPLETE.contentPosition,
|
|
323
426
|
flexDirection: contentDirection ? contentDirection : configStyles.NEWAUTOCOMPLETE.contentDirection,
|
|
324
|
-
maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth
|
|
427
|
+
maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
|
|
325
428
|
}}
|
|
326
429
|
>
|
|
327
430
|
<input
|
|
328
431
|
id={id}
|
|
329
|
-
type=
|
|
432
|
+
type="text"
|
|
330
433
|
value={innerValue}
|
|
331
434
|
disabled={disabled}
|
|
332
435
|
onBlur={handleBlur}
|
|
@@ -345,47 +448,69 @@ export const NewAutocomplete = ({
|
|
|
345
448
|
cursor: disabled ? 'not-allowed' : 'auto',
|
|
346
449
|
color: contentTopColor ? contentTopColor : configStyles.NEWAUTOCOMPLETE.contentTopColor,
|
|
347
450
|
fontSize: contentTopSize ? contentTopSize : configStyles.NEWAUTOCOMPLETE.contentTopSize,
|
|
451
|
+
backgroundColor:
|
|
452
|
+
disabled && (backgroundDisableColor ?? configStyles.NEWAUTOCOMPLETE.backgroundDisableColor),
|
|
348
453
|
height: contentTopHeight ? contentTopHeight : configStyles.NEWAUTOCOMPLETE.contentTopHeight,
|
|
349
454
|
padding: contentTopPadding ? contentTopPadding : configStyles.NEWAUTOCOMPLETE.contentTopPadding,
|
|
350
455
|
display: contentTopDisplay ? contentTopDisplay : configStyles.NEWAUTOCOMPLETE.contentTopDisplay,
|
|
351
456
|
fontWeight: contentTopWeight ? contentTopWeight : configStyles.NEWAUTOCOMPLETE.contentTopWeight,
|
|
352
|
-
borderRadius: contentTopRadius
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
457
|
+
borderRadius: contentTopRadius
|
|
458
|
+
? contentTopRadius
|
|
459
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopRadius,
|
|
460
|
+
boxSizing: contentTopBoxSizing
|
|
461
|
+
? contentTopBoxSizing
|
|
462
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopBoxSizing,
|
|
463
|
+
lineHeight: contentTopLineHeight
|
|
464
|
+
? contentTopLineHeight
|
|
465
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopLineHeight,
|
|
466
|
+
flexDirection: contentTopDirection
|
|
467
|
+
? contentTopDirection
|
|
468
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopDirection,
|
|
469
|
+
boxShadow: errorMessage
|
|
470
|
+
? errorColor
|
|
471
|
+
? `0 0 0 2px ${errorColor}`
|
|
472
|
+
: `0 0 0 2px ${configStyles.NEWAUTOCOMPLETE.errorColor}`
|
|
473
|
+
: isFocus
|
|
474
|
+
? contentTopBorderActive
|
|
475
|
+
? contentTopBorderActive
|
|
476
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopBorderActive
|
|
477
|
+
: isHover
|
|
478
|
+
? contentTopBorderHover
|
|
479
|
+
? contentTopBorderHover
|
|
480
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopBorderHover
|
|
481
|
+
: contentTopBorder
|
|
482
|
+
? contentTopBorder
|
|
483
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopBorder,
|
|
361
484
|
}}
|
|
362
485
|
{...props}
|
|
363
486
|
/>
|
|
364
487
|
|
|
365
|
-
{
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
488
|
+
{innerError ? (
|
|
489
|
+
<span
|
|
490
|
+
style={{
|
|
491
|
+
left: '0px',
|
|
492
|
+
position: 'absolute',
|
|
493
|
+
color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
|
|
494
|
+
fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
|
|
495
|
+
top: marginTop
|
|
496
|
+
? `calc(100% + ${marginTop})`
|
|
497
|
+
: `calc(100% + ${configStyles.INPUT.marginTop})`,
|
|
498
|
+
maxWidth: contentTopMaxWidth
|
|
499
|
+
? contentTopMaxWidth
|
|
500
|
+
: configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
|
|
501
|
+
}}
|
|
502
|
+
>
|
|
503
|
+
{innerError}
|
|
504
|
+
</span>
|
|
505
|
+
) : (
|
|
506
|
+
''
|
|
507
|
+
)}
|
|
381
508
|
|
|
382
|
-
{
|
|
383
|
-
optionList
|
|
384
|
-
}
|
|
509
|
+
{optionList}
|
|
385
510
|
</div>
|
|
386
511
|
</>
|
|
387
|
-
)
|
|
388
|
-
}
|
|
512
|
+
)
|
|
513
|
+
}
|
|
389
514
|
|
|
390
515
|
NewAutocomplete.propTypes = {
|
|
391
516
|
label: PropTypes.string,
|
|
@@ -462,9 +587,10 @@ NewAutocomplete.propTypes = {
|
|
|
462
587
|
contentBottomBackgroundColor: PropTypes.string,
|
|
463
588
|
contentBottomRowBackgroundColor: PropTypes.string,
|
|
464
589
|
contentBottomRowHoverBackgroundColor: PropTypes.string,
|
|
465
|
-
|
|
590
|
+
backgroundDisableColor: PropTypes.string,
|
|
591
|
+
}
|
|
466
592
|
|
|
467
593
|
NewAutocomplete.defaultProps = {
|
|
468
594
|
searchCount: 3,
|
|
469
|
-
disabled: false
|
|
470
|
-
}
|
|
595
|
+
disabled: false,
|
|
596
|
+
}
|