@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,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 = _ => css`
108
- ${showOption} ${showOptionDuration ? showOptionDuration : configStyles.NEWAUTOCOMPLETE.showOptionDuration} linear forwards
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 ? contentBottomRowHoverColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowHoverColor;
121
- e.target.style.backgroundColor = contentBottomRowHoverBackgroundColor ? contentBottomRowHoverBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowHoverBackgroundColor;
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 ? contentBottomRowColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowColor;
126
- e.target.style.backgroundColor = contentBottomRowBackgroundColor ? contentBottomRowBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowBackgroundColor;
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
- show && innerOptions && !disabled
161
- ?
162
- innerOptions.length > 0
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
- left: contentBottomLeft ? contentBottomLeft : configStyles.NEWAUTOCOMPLETE.contentBottomLeft,
167
- width: contentBottomWidth ? contentBottomWidth : configStyles.NEWAUTOCOMPLETE.contentBottomWidth,
168
- zIndex: contentBottomZindex ? contentBottomZindex : configStyles.NEWAUTOCOMPLETE.contentBottomZindex,
169
- borderRadius: contentBottomRadius ? contentBottomRadius : configStyles.NEWAUTOCOMPLETE.contentBottomRadius,
170
- maxWidth: contentBottomMaxWidth ? contentBottomMaxWidth : configStyles.NEWAUTOCOMPLETE.contentBottomMaxWidth,
171
- overflow: contentBottomOverflow ? contentBottomOverflow : configStyles.NEWAUTOCOMPLETE.contentBottomOverflow,
172
- position: contentBottomPosition ? contentBottomPosition : configStyles.NEWAUTOCOMPLETE.contentBottomPosition,
173
- minHeight: contentBottomMinHeight ? contentBottomMinHeight : configStyles.NEWAUTOCOMPLETE.contentBottomMinHeight,
174
- boxShadow: contentBottomBoxShadow ? contentBottomBoxShadow : configStyles.NEWAUTOCOMPLETE.contentBottomBoxShadow,
175
- backgroundColor: contentBottomBackgroundColor ? contentBottomBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomBackgroundColor,
176
- top: contentTopHeight ?
177
- contentTopHeight.includes('rem') ?
178
- parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 3)) + 0.6 + 'rem' :
179
- parseFloat(contentTopHeight.substr(0, contentTopHeight.length - 2)) + 6 + 'px'
180
- : configStyles.NEWAUTOCOMPLETE.contentTopHeight.includes('rem') ?
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
- <div
187
- style={{
188
- display: contentBottomInnerDisplay ? contentBottomInnerDisplay : configStyles.NEWAUTOCOMPLETE.contentBottomInnerDisplay,
189
- overflowY: contentBottomInnerOverflowY ? contentBottomInnerOverflowY : configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowY,
190
- overflowX: contentBottomInnerOverflowX ? contentBottomInnerOverflowX : configStyles.NEWAUTOCOMPLETE.contentBottomInnerOverflowX,
191
- maxHeight: contentBottomInnerMaxHeight ? contentBottomInnerMaxHeight : configStyles.NEWAUTOCOMPLETE.contentBottomInnerMaxHeight,
192
- flexDirection: contentBottomInnerDirection ? contentBottomInnerDirection : configStyles.NEWAUTOCOMPLETE.contentBottomInnerDirection
193
- }}
194
- >
195
- {
196
- innerOptions.map(item => {
197
- return (
198
- <p
199
- key={item.id}
200
- onMouseEnter={handleRowMouseEnter}
201
- onMouseLeave={handleRowMouseLeave}
202
- onClick={() => handleClick(item)}
203
- style={{
204
- flexShrink: 0,
205
- color: contentBottomRowColor ? contentBottomRowColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowColor,
206
- height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
207
- cursor: contentBottomRowCursor ? contentBottomRowCursor : configStyles.NEWAUTOCOMPLETE.contentBottomRowCursor,
208
- display: contentBottomRowDisplay ? contentBottomRowDisplay : configStyles.NEWAUTOCOMPLETE.contentBottomRowDisplay,
209
- padding: contentBottomRowPadding ? contentBottomRowPadding : configStyles.NEWAUTOCOMPLETE.contentBottomRowPadding,
210
- fontSize: contentBottomRowFontSize ? contentBottomRowFontSize : configStyles.NEWAUTOCOMPLETE.contentBottomRowFontSize,
211
- boxSizing: contentBottomRowBoxSizing ? contentBottomRowBoxSizing : configStyles.NEWAUTOCOMPLETE.contentBottomRowBoxSizing,
212
- fontWeight: contentBottomRowFontWeight ? contentBottomRowFontWeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowFontWeight,
213
- lineHeight: contentBottomRowLineHeight ? contentBottomRowLineHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowLineHeight,
214
- alignItems: contentBottomRowAlignItems ? contentBottomRowAlignItems : configStyles.NEWAUTOCOMPLETE.contentBottomRowAlignItems,
215
- transition: contentBottomRowTransition ? contentBottomRowTransition : configStyles.NEWAUTOCOMPLETE.contentBottomRowTransition,
216
- marginBottom: contentBottomRowMarginBottom ? contentBottomRowMarginBottom : configStyles.NEWAUTOCOMPLETE.contentBottomRowMarginBottom,
217
- backgroundColor: contentBottomRowBackgroundColor ? contentBottomRowBackgroundColor : configStyles.NEWAUTOCOMPLETE.contentBottomRowBackgroundColor
218
- }}
219
- >
220
- {item[keyNames.name]}
221
- </p>
222
- )
223
- })
224
- }
225
- </div>
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
- : innerOptions.length <= 0
228
- ?
229
- innerError ? '' : <span
230
- style={{
231
- position: 'absolute',
232
- zIndex: '9999999999',
233
- color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
234
- fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
235
- top: marginTop ? `calc(100% + ${marginTop})` : `calc(100% + ${configStyles.INPUT.marginTop})`,
236
- padding: innerErrorPadding ? innerErrorPadding : configStyles.NEWAUTOCOMPLETE.innerErrorPadding,
237
- height: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
238
- lineHeight: contentBottomRowHeight ? contentBottomRowHeight : configStyles.NEWAUTOCOMPLETE.contentBottomRowHeight,
239
- backgroundColor: innerErrorBackgroundColor ? innerErrorBackgroundColor : configStyles.NEWAUTOCOMPLETE.innerErrorBackgroundColor,
240
- }}
241
- >
242
- {
243
- innerValue.length >= searchCount
244
- ? 'Նման տվյալ առկա չէ'
245
- : `Լրացնել առնվազն ${searchCount} նիշ`
246
- }
247
- </span>
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 && options.length > 0 && options.map(item => {
260
- if (!item.hasOwnProperty(keyNames.name)) {
261
- alert(`Please add ${keyNames.name} property in items of options array`);
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
- ? <label
297
- style={{
298
- color: labelColor ? labelColor : configStyles.NEWAUTOCOMPLETE.labelColor,
299
- fontSize: labelSize ? labelSize : configStyles.NEWAUTOCOMPLETE.labelSize,
300
- display: labelDisplay ? labelDisplay : configStyles.NEWAUTOCOMPLETE.labelDisplay,
301
- fontWeight: labelWeight ? labelWeight : configStyles.NEWAUTOCOMPLETE.labelWeight,
302
- lineHeight: labelLineHeight ? labelLineHeight : configStyles.NEWAUTOCOMPLETE.labelLineHeight,
303
- maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
304
- marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.NEWAUTOCOMPLETE.labelMarginBottom,
305
- textTransform: labelTextTransform ? labelTextTransform : configStyles.NEWAUTOCOMPLETE.labelTextTransform,
306
- }}
307
- >
308
- {label}
309
- {
310
- required && <sup
311
- style={{
312
- color: labelRequiredColor ? labelRequiredColor : configStyles.NEWAUTOCOMPLETE.labelRequiredColor
313
- }}
314
- >*</sup>
315
- }
316
- </label>
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='text'
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 ? contentTopRadius : configStyles.NEWAUTOCOMPLETE.contentTopRadius,
353
- boxSizing: contentTopBoxSizing ? contentTopBoxSizing : configStyles.NEWAUTOCOMPLETE.contentTopBoxSizing,
354
- lineHeight: contentTopLineHeight ? contentTopLineHeight : configStyles.NEWAUTOCOMPLETE.contentTopLineHeight,
355
- flexDirection: contentTopDirection ? contentTopDirection : configStyles.NEWAUTOCOMPLETE.contentTopDirection,
356
- boxShadow:
357
- errorMessage ? errorColor ? `0 0 0 2px ${errorColor}` : `0 0 0 2px ${configStyles.NEWAUTOCOMPLETE.errorColor}` :
358
- isFocus ? contentTopBorderActive ? contentTopBorderActive : configStyles.NEWAUTOCOMPLETE.contentTopBorderActive :
359
- isHover ? contentTopBorderHover ? contentTopBorderHover : configStyles.NEWAUTOCOMPLETE.contentTopBorderHover :
360
- contentTopBorder ? contentTopBorder : configStyles.NEWAUTOCOMPLETE.contentTopBorder,
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
- innerError
367
- ? <span
368
- style={{
369
- left: '0px',
370
- position: 'absolute',
371
- color: errorColor ? errorColor : configStyles.NEWAUTOCOMPLETE.errorColor,
372
- fontSize: errorSize ? errorSize : configStyles.NEWAUTOCOMPLETE.errorSize,
373
- top: marginTop ? `calc(100% + ${marginTop})` : `calc(100% + ${configStyles.INPUT.marginTop})`,
374
- maxWidth: contentTopMaxWidth ? contentTopMaxWidth : configStyles.NEWAUTOCOMPLETE.contentTopMaxWidth,
375
- }}
376
- >
377
- {innerError}
378
- </span>
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
+ }