@xaypay/tui 0.0.105 → 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.
Files changed (91) 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 +84 -83
  8. package/dist/index.js +84 -83
  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 +213 -191
  62. package/src/components/newFile/index.js +231 -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 +316 -221
  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 +177 -159
  83. package/src/components/toaster/index.js +107 -111
  84. package/src/components/toaster/toaster.stories.js +582 -367
  85. package/src/components/tooltip/index.js +79 -46
  86. package/src/components/tooltip/tooltip.stories.js +9 -10
  87. package/src/components/typography/index.js +108 -101
  88. package/src/components/typography/typography.stories.js +16 -19
  89. package/src/index.js +20 -20
  90. package/src/utils/index.js +11 -11
  91. package/tui.config.js +343 -341
@@ -1,13 +1,13 @@
1
- import React, {useEffect, useState, useRef} from 'react';
2
- import PropTypes from 'prop-types';
3
- import classnames from 'classnames';
4
- import { compereConfigs } from "./../../utils";
5
- import { SingleCheckbox } from '../singleCheckbox';
1
+ import React, { useEffect, useState, useRef } from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import classnames from 'classnames'
4
+ import { compereConfigs } from './../../utils'
5
+ import { SingleCheckbox } from '../singleCheckbox'
6
6
 
7
- import ReactArrowIcon from '../icon/Arrow';
8
- import ReactCloseIcon from '../icon/CloseIcon';
7
+ import ReactArrowIcon from '../icon/Arrow'
8
+ import ReactCloseIcon from '../icon/CloseIcon'
9
9
 
10
- import styles from './select.module.css';
10
+ import styles from './select.module.css'
11
11
 
12
12
  export const Select = ({
13
13
  dots,
@@ -71,158 +71,159 @@ export const Select = ({
71
71
  optionItemBackgroudColorHover,
72
72
 
73
73
  boxShadow,
74
- boxShadowHover
74
+ boxShadowHover,
75
75
  }) => {
76
- const ref = useRef();
77
-
78
- const [opened, setOpened] = useState(false);
79
- const [isHover, setIsHover] = useState(false);
80
- const [newSelected, setNewSelected] = useState([]);
81
- const [existOptions, setExistOptions] = useState([]);
82
-
83
- const configStyles = compereConfigs();
84
- const classProps = classnames(
85
- className
86
- );
76
+ const ref = useRef()
77
+
78
+ const [opened, setOpened] = useState(false)
79
+ const [isHover, setIsHover] = useState(false)
80
+ const [newSelected, setNewSelected] = useState([])
81
+ const [existOptions, setExistOptions] = useState([])
82
+
83
+ const configStyles = compereConfigs()
84
+ const classProps = classnames(className)
87
85
 
88
86
  const handleOpenClose = () => {
89
- setOpened(!opened);
90
- };
87
+ setOpened(!opened)
88
+ }
91
89
 
92
90
  const handleClearSelect = (e) => {
93
- onChange({});
94
- setNewSelected([]);
95
- const clearedOptions = existOptions && existOptions.length > 0 && existOptions.map(item => {
96
- item.checked = false;
97
- return item;
98
- });
99
- setExistOptions(clearedOptions);
100
- e.stopPropagation();
101
- };
91
+ onChange({})
92
+ setNewSelected([])
93
+ const clearedOptions =
94
+ existOptions &&
95
+ existOptions.length > 0 &&
96
+ existOptions.map((item) => {
97
+ item.checked = false
98
+ return item
99
+ })
100
+ setExistOptions(clearedOptions)
101
+ e.stopPropagation()
102
+ }
102
103
 
103
104
  const handleSelectItem = (option) => {
104
- const checkedOption = {...option};
105
- delete checkedOption.checked;
106
-
105
+ const checkedOption = { ...option }
106
+ delete checkedOption.checked
107
+
107
108
  if (!multiple) {
108
- setOpened(!opened);
109
- setNewSelected([option]);
110
- onChange(checkedOption);
109
+ setOpened(!opened)
110
+ setNewSelected([option])
111
+ onChange(checkedOption)
111
112
  } else {
112
- const indexOfObject = newSelected.findIndex(obj => {
113
- return obj[keyNames.name] === option[keyNames.name];
114
- });
113
+ const indexOfObject = newSelected.findIndex((obj) => {
114
+ return obj[keyNames.name] === option[keyNames.name]
115
+ })
115
116
  if (indexOfObject === -1) {
116
- option.checked = true;
117
- setNewSelected(prev => {
118
- return [
119
- ...prev,
120
- option
121
- ]
122
- });
117
+ option.checked = true
118
+ setNewSelected((prev) => {
119
+ return [...prev, option]
120
+ })
123
121
  onChange([...newSelected, option])
124
122
  } else {
125
- option.checked = false;
126
- setNewSelected([
127
- ...newSelected.slice(0, indexOfObject),
128
- ...newSelected.slice(indexOfObject + 1),
129
- ]);
130
- onChange([
131
- ...newSelected.slice(0, indexOfObject),
132
- ...newSelected.slice(indexOfObject + 1),
133
- ])
123
+ option.checked = false
124
+ setNewSelected([...newSelected.slice(0, indexOfObject), ...newSelected.slice(indexOfObject + 1)])
125
+ onChange([...newSelected.slice(0, indexOfObject), ...newSelected.slice(indexOfObject + 1)])
134
126
  }
135
127
  }
136
- };
128
+ }
137
129
 
138
130
  const handleMouseEnter = () => {
139
- setIsHover(true);
140
- };
141
-
131
+ setIsHover(true)
132
+ }
133
+
142
134
  const handleMouseLeave = () => {
143
- setIsHover(false);
144
- };
135
+ setIsHover(false)
136
+ }
145
137
 
146
138
  const handleMouseEnterOption = (e) => {
147
- e.target.style.color = optionItemColorHover ? optionItemColorHover : configStyles.SELECT.optionItemColorHover;
148
- e.target.style.backgroundColor = optionItemBackgroudColorHover ? optionItemBackgroudColorHover : configStyles.SELECT.optionItemBackgroudColorHover;
149
- };
150
-
139
+ e.target.style.color = optionItemColorHover ? optionItemColorHover : configStyles.SELECT.optionItemColorHover
140
+ e.target.style.backgroundColor = optionItemBackgroudColorHover
141
+ ? optionItemBackgroudColorHover
142
+ : configStyles.SELECT.optionItemBackgroudColorHover
143
+ }
144
+
151
145
  const handleMouseLeaveOption = (e) => {
152
146
  e.target.style.color = optionItemColor ? optionItemColor : configStyles.SELECT.optionItemColor
153
- e.target.style.backgroundColor = optionItemBackgroudColor ? optionItemBackgroudColor : configStyles.SELECT.optionItemBackgroudColor;
154
- };
147
+ e.target.style.backgroundColor = optionItemBackgroudColor
148
+ ? optionItemBackgroudColor
149
+ : configStyles.SELECT.optionItemBackgroudColor
150
+ }
155
151
 
156
152
  const isObjectEmpty = (obj) => {
157
153
  for (var key in obj) {
158
- if (obj.hasOwnProperty(key)) {
159
- return false;
160
- }
154
+ // eslint-disable-next-line no-prototype-builtins
155
+ if (obj.hasOwnProperty(key)) {
156
+ return false
157
+ }
161
158
  }
162
- return true;
163
- };
159
+ return true
160
+ }
164
161
 
165
162
  useEffect(() => {
166
- if(opened){
167
- const checkIfClickedOutside = e => {
163
+ if (opened) {
164
+ const checkIfClickedOutside = (e) => {
168
165
  if (opened && ref.current && !ref.current.contains(e.target)) {
169
166
  setOpened(false)
170
167
  }
171
- };
172
- document.addEventListener("mousedown", checkIfClickedOutside)
168
+ }
169
+ document.addEventListener('mousedown', checkIfClickedOutside)
173
170
  return () => {
174
- document.removeEventListener("mousedown", checkIfClickedOutside)
171
+ document.removeEventListener('mousedown', checkIfClickedOutside)
175
172
  }
176
173
  }
177
- }, [opened]);
174
+ }, [opened])
178
175
 
179
176
  useEffect(() => {
180
177
  if (selected) {
181
178
  if (selected.length > 0) {
182
- setNewSelected(isObjectEmpty(selected[0]) ? []: selected );
179
+ setNewSelected(isObjectEmpty(selected[0]) ? [] : selected)
183
180
  } else {
184
- setNewSelected([]);
181
+ setNewSelected([])
185
182
  }
186
183
  }
187
184
 
188
185
  if (!multiple) {
189
- options && options.length > 0 && setExistOptions(options);
186
+ options && options.length > 0 && setExistOptions(options)
190
187
  } else {
191
- const modifiedOptions = options && options.length > 0 && options.map((item, index) => {
192
- item.checked = false;
193
- if (selected && selected.length > 0) {
194
- selected.map(innerItem => {
195
- if (innerItem[keyNames.name] === item[keyNames.name]) {
196
- item.checked = true;
197
- }
198
- });
199
- }
200
- return item;
201
- });
202
- setExistOptions(modifiedOptions);
188
+ const modifiedOptions =
189
+ options &&
190
+ options.length > 0 &&
191
+ options.map((item) => {
192
+ item.checked = false
193
+ if (selected && selected.length > 0) {
194
+ selected.map((innerItem) => {
195
+ if (innerItem[keyNames.name] === item[keyNames.name]) {
196
+ item.checked = true
197
+ }
198
+ })
199
+ }
200
+ return item
201
+ })
202
+ setExistOptions(modifiedOptions)
203
203
  }
204
- }, [options, multiple, selected, selected?.length]);
205
-
204
+ }, [options, multiple, selected, selected?.length])
205
+
206
206
  return (
207
207
  <div className={classProps} style={{ position: 'relative' }}>
208
- {
209
- label ?
210
- <label
211
- style={{
212
- color: labelColor ? labelColor : configStyles.SELECT.labelColor,
213
- fontWeight: labelWeight ? labelWeight : configStyles.SELECT.labelWeight,
214
- display: labelDisplay ? labelDisplay : configStyles.SELECT.labelDisplay,
215
- fontSize: labelFontSize ? labelFontSize : configStyles.SELECT.labelFontSize,
216
- lineHeight: labelLineHeight ? labelLineHeight : configStyles.SELECT.labelLineHeight,
217
- marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.SELECT.labelMarginBottom,
218
- textTransform: labelTextTransform ? labelTextTransform : configStyles.SELECT.labelTextTransform
219
- }}
220
- >
221
- {label}
222
- {required && <sup style={{color: "#ee0000"}}>*</sup>}
223
- </label> : ""
224
- }
225
-
208
+ {label ? (
209
+ <label
210
+ style={{
211
+ color: labelColor ? labelColor : configStyles.SELECT.labelColor,
212
+ fontWeight: labelWeight ? labelWeight : configStyles.SELECT.labelWeight,
213
+ display: labelDisplay ? labelDisplay : configStyles.SELECT.labelDisplay,
214
+ fontSize: labelFontSize ? labelFontSize : configStyles.SELECT.labelFontSize,
215
+ lineHeight: labelLineHeight ? labelLineHeight : configStyles.SELECT.labelLineHeight,
216
+ marginBottom: labelMarginBottom ? labelMarginBottom : configStyles.SELECT.labelMarginBottom,
217
+ textTransform: labelTextTransform ? labelTextTransform : configStyles.SELECT.labelTextTransform,
218
+ }}
219
+ >
220
+ {label}
221
+ {required && <sup style={{ color: '#ee0000' }}>*</sup>}
222
+ </label>
223
+ ) : (
224
+ ''
225
+ )}
226
+
226
227
  <div ref={ref}>
227
228
  <div className={styles['select-content']}>
228
229
  <div
@@ -233,15 +234,37 @@ export const Select = ({
233
234
  borderRadius: selectedRadius ? selectedRadius : configStyles.SELECT.selectedRadius,
234
235
  fontSize: selectedFontSize ? selectedFontSize : configStyles.SELECT.selectedFontSize,
235
236
  boxSizing: selectedBoxSizing ? selectedBoxSizing : configStyles.SELECT.selectedBoxSizing,
236
- fontWeight: selectedFontWeight ? selectedFontWeight : configStyles.SELECT.selectedFontWeight,
237
- lineHeight: selectedLineHeight ? selectedLineHeight : configStyles.SELECT.selectedLineHeight,
238
- transition: selectedTransition ? selectedTransition : configStyles.SELECT.selectedTransition,
239
- backgroundColor: disabled ? selectedDisableBackgroundColor ? selectedDisableBackgroundColor : configStyles.SELECT.selectedDisableBackgroundColor : selectedBackgroundColor ? selectedBackgroundColor : configStyles.SELECT.selectedBackgroundColor,
240
- boxShadow: errorMessage ? errorColor ? `0 0 0 2px ${errorColor}` : `0 0 0 2px ${configStyles.SELECT.errorColor}` : isHover ? boxShadowHover ? boxShadowHover : configStyles.SELECT.boxShadowHover : boxShadow ? boxShadow : configStyles.SELECT.boxShadow
237
+ fontWeight: selectedFontWeight
238
+ ? selectedFontWeight
239
+ : configStyles.SELECT.selectedFontWeight,
240
+ lineHeight: selectedLineHeight
241
+ ? selectedLineHeight
242
+ : configStyles.SELECT.selectedLineHeight,
243
+ transition: selectedTransition
244
+ ? selectedTransition
245
+ : configStyles.SELECT.selectedTransition,
246
+ backgroundColor: disabled
247
+ ? selectedDisableBackgroundColor
248
+ ? selectedDisableBackgroundColor
249
+ : configStyles.SELECT.selectedDisableBackgroundColor
250
+ : selectedBackgroundColor
251
+ ? selectedBackgroundColor
252
+ : configStyles.SELECT.selectedBackgroundColor,
253
+ boxShadow: errorMessage
254
+ ? errorColor
255
+ ? `0 0 0 2px ${errorColor}`
256
+ : `0 0 0 2px ${configStyles.SELECT.errorColor}`
257
+ : isHover
258
+ ? boxShadowHover
259
+ ? boxShadowHover
260
+ : configStyles.SELECT.boxShadowHover
261
+ : boxShadow
262
+ ? boxShadow
263
+ : configStyles.SELECT.boxShadow,
241
264
  }}
242
- onClick={disabled ? _ => _ : _ => handleOpenClose()}
243
- onMouseEnter={disabled ? _ => _ : _ => handleMouseEnter()}
244
- onMouseLeave={disabled ? _ => _ : _ => handleMouseLeave()}
265
+ onClick={disabled ? (_) => _ : () => handleOpenClose()}
266
+ onMouseEnter={disabled ? (_) => _ : () => handleMouseEnter()}
267
+ onMouseLeave={disabled ? (_) => _ : () => handleMouseLeave()}
245
268
  className={`${styles['select-content-top']}`}
246
269
  >
247
270
  <div
@@ -250,119 +273,191 @@ export const Select = ({
250
273
  whiteSpace: 'nowrap',
251
274
  overflow: 'hidden',
252
275
  textOverflow: 'ellipsis',
253
- color: errorMessage ? errorColor ? errorColor : configStyles.SELECT.errorColor : isHover ? selectedHoverColor ? selectedHoverColor : configStyles.SELECT.selectedHoverColor : selectedColor ? selectedColor : configStyles.SELECT.selectedColor,
276
+ color: errorMessage
277
+ ? errorColor
278
+ ? errorColor
279
+ : configStyles.SELECT.errorColor
280
+ : isHover
281
+ ? selectedHoverColor
282
+ ? selectedHoverColor
283
+ : configStyles.SELECT.selectedHoverColor
284
+ : selectedColor
285
+ ? selectedColor
286
+ : configStyles.SELECT.selectedColor,
254
287
  }}
255
288
  >
256
- {
257
- !multiple && newSelected && newSelected[0] && newSelected[0][keyNames.name] ? newSelected[0][keyNames.name] :
258
- newSelected && newSelected.length > 0 ? newSelected.map((_, index) => {
259
- if (newSelected[index][keyNames.name]) {
260
- if (index > 0) {
261
- return ', ' + newSelected[index][keyNames.name];
262
- } else {
263
- return newSelected[index][keyNames.name];
264
- }
265
- }
266
- }) : defaultOption ? defaultOption : ''
267
- }
289
+ {!multiple && newSelected && newSelected[0] && newSelected[0][keyNames.name]
290
+ ? newSelected[0][keyNames.name]
291
+ : newSelected && newSelected.length > 0
292
+ ? newSelected.map((_, index) => {
293
+ if (newSelected[index][keyNames.name]) {
294
+ if (index > 0) {
295
+ return ', ' + newSelected[index][keyNames.name]
296
+ } else {
297
+ return newSelected[index][keyNames.name]
298
+ }
299
+ }
300
+ })
301
+ : defaultOption
302
+ ? defaultOption
303
+ : ''}
268
304
  </div>
269
305
  <div className={`${styles['select-content-top-icon']}`}>
270
- {
271
- !disabled && multiple && newSelected.length > 1 && <span>{newSelected.length}</span>
272
- }
306
+ {!disabled && multiple && newSelected.length > 1 && <span>{newSelected.length}</span>}
273
307
 
274
- {(showCloseIcon === true || showCloseIcon === false ? showCloseIcon : configStyles.SELECT.showCloseIcon) && !disabled && newSelected && newSelected.length > 0 &&
275
- <div
276
- className={`${styles['close-icon']}`}
277
- onClick={disabled ? _ => _ : handleClearSelect}
278
- style={{marginLeft: multiple && newSelected.length > 1 ? '17px' : '0px'}}
279
- >
280
- { closeIcon ? closeIcon : <ReactCloseIcon /> }
281
- </div>
282
- }
308
+ {(showCloseIcon === true || showCloseIcon === false
309
+ ? showCloseIcon
310
+ : configStyles.SELECT.showCloseIcon) &&
311
+ !disabled &&
312
+ newSelected &&
313
+ newSelected.length > 0 && (
314
+ <div
315
+ className={`${styles['close-icon']}`}
316
+ onClick={disabled ? (_) => _ : handleClearSelect}
317
+ style={{ marginLeft: multiple && newSelected.length > 1 ? '17px' : '0px' }}
318
+ >
319
+ {closeIcon ? closeIcon : <ReactCloseIcon />}
320
+ </div>
321
+ )}
283
322
 
284
- {!disabled ? <div
323
+ {!disabled ? (
324
+ <div
285
325
  style={{
286
326
  transform: opened ? 'rotate(180deg)' : 'rotate(0deg)',
287
327
  }}
288
- className={`${styles['arrow-icon']}`}>
328
+ className={`${styles['arrow-icon']}`}
329
+ >
289
330
  {arrowIcon ? arrowIcon : <ReactArrowIcon />}
290
- </div> : ''
291
- }
331
+ </div>
332
+ ) : (
333
+ ''
334
+ )}
292
335
  </div>
293
336
  </div>
294
- {
295
- opened && !disabled ?
296
- <div
297
- style={{
298
- boxShadow: optionsBoxShadow ? optionsBoxShadow : configStyles.SELECT.optionsBoxShadow,
299
- borderRadius: optionsBorderRadius ? optionsBorderRadius : configStyles.SELECT.optionsBorderRadius,
300
- backgroundColor: optionsBackgroundColor ? optionsBackgroundColor : configStyles.SELECT.optionsBackgroundColor,
301
- top:
302
- selectedMinHeight ?
303
- selectedMinHeight.includes('rem') ?
304
- parseFloat(selectedMinHeight.substr(0, selectedMinHeight.length - 3)) + 0.6 + 'rem' :
305
- parseFloat(selectedMinHeight.substr(0, selectedMinHeight.length - 2)) + 6 + 'px'
306
- : configStyles.SELECT.selectedMinHeight.includes('rem') ?
307
- parseFloat(configStyles.SELECT.selectedMinHeight.substr(0, configStyles.SELECT.selectedMinHeight.length - 3)) + 0.6 + 'rem' :
308
- parseFloat(configStyles.SELECT.selectedMinHeight.substr(0, configStyles.SELECT.selectedMinHeight.length - 2)) + 6 + 'px'
309
- }}
310
- className={`${styles['select-content-bottom']}`}
311
- >
312
- <div className={`${styles['select-content-bottom-inner']}`}>
313
- {
314
- existOptions && existOptions.length > 0 && existOptions.map((option, i) => {
315
- return <div
316
- key={i}
317
- disabled={true}
318
- defaultValue={option[keyNames.id]}
319
- onClick={disabled ? _ => _ : _ => handleSelectItem(option)}
320
- onMouseEnter={disabled ? _ => _ : e => handleMouseEnterOption(e)}
321
- onMouseLeave={disabled ? _ => _ : e => handleMouseLeaveOption(e)}
322
- className={`${styles['select-content-bottom-row']} ${dots || configStyles.SELECT.dots ? styles['ellipsis'] : ''}`}
323
- style={{
324
- overflowWrap: !dots && !configStyles.SELECT.dots ? 'anywhere' : 'break-word',
325
- color: optionItemColor ? optionItemColor : configStyles.SELECT.optionItemColor,
326
- cursor: optionItemCursor ? optionItemCursor : configStyles.SELECT.optionItemCursor,
327
- padding: optionItemPadding ? optionItemPadding : configStyles.SELECT.optionItemPadding,
328
- fontSize: optionItemFontSize ? optionItemFontSize : configStyles.SELECT.optionItemFontSize,
329
- boxSizing: optionItemBoxSizing ? optionItemBoxSizing : configStyles.SELECT.optionItemBoxSizing,
330
- minHeight: optionItemMinHeight ? optionItemMinHeight : configStyles.SELECT.optionItemMinHeight,
331
- fontWeight: optionItemFontWeight ? optionItemFontWeight : configStyles.SELECT.optionItemFontWeight,
332
- lineHeight: dots || configStyles.SELECT.dots ? '46px' : optionItemLineHeight ? optionItemLineHeight : configStyles.SELECT.optionItemLineHeight,
333
- marginBottom: optionItemMarginBottom ? optionItemMarginBottom : configStyles.SELECT.optionItemMarginBottom,
334
- backgroundColor: optionItemBackgroudColor ? optionItemBackgroudColor : configStyles.SELECT.optionItemBackgroudColor,
335
- }}
336
- >
337
- {multiple && multipleCheckbox ? <SingleCheckbox checked={option.checked} /> : ''}
338
- {option[keyNames.name]}
339
- </div>
340
- })
341
- }
342
- </div>
343
- </div> : null
344
- }
337
+ {opened && !disabled ? (
338
+ <div
339
+ style={{
340
+ boxShadow: optionsBoxShadow ? optionsBoxShadow : configStyles.SELECT.optionsBoxShadow,
341
+ borderRadius: optionsBorderRadius
342
+ ? optionsBorderRadius
343
+ : configStyles.SELECT.optionsBorderRadius,
344
+ backgroundColor: optionsBackgroundColor
345
+ ? optionsBackgroundColor
346
+ : configStyles.SELECT.optionsBackgroundColor,
347
+ top: selectedMinHeight
348
+ ? selectedMinHeight.includes('rem')
349
+ ? parseFloat(selectedMinHeight.substr(0, selectedMinHeight.length - 3)) +
350
+ 0.6 +
351
+ 'rem'
352
+ : parseFloat(selectedMinHeight.substr(0, selectedMinHeight.length - 2)) +
353
+ 6 +
354
+ 'px'
355
+ : configStyles.SELECT.selectedMinHeight.includes('rem')
356
+ ? parseFloat(
357
+ configStyles.SELECT.selectedMinHeight.substr(
358
+ 0,
359
+ configStyles.SELECT.selectedMinHeight.length - 3
360
+ )
361
+ ) +
362
+ 0.6 +
363
+ 'rem'
364
+ : parseFloat(
365
+ configStyles.SELECT.selectedMinHeight.substr(
366
+ 0,
367
+ configStyles.SELECT.selectedMinHeight.length - 2
368
+ )
369
+ ) +
370
+ 6 +
371
+ 'px',
372
+ }}
373
+ className={`${styles['select-content-bottom']}`}
374
+ >
375
+ <div className={`${styles['select-content-bottom-inner']}`}>
376
+ {existOptions &&
377
+ existOptions.length > 0 &&
378
+ existOptions.map((option, i) => {
379
+ return (
380
+ <div
381
+ key={i}
382
+ disabled={true}
383
+ defaultValue={option[keyNames.id]}
384
+ onClick={disabled ? (_) => _ : () => handleSelectItem(option)}
385
+ onMouseEnter={disabled ? (_) => _ : (e) => handleMouseEnterOption(e)}
386
+ onMouseLeave={disabled ? (_) => _ : (e) => handleMouseLeaveOption(e)}
387
+ className={`${styles['select-content-bottom-row']} ${
388
+ dots || configStyles.SELECT.dots ? styles['ellipsis'] : ''
389
+ }`}
390
+ style={{
391
+ overflowWrap:
392
+ !dots && !configStyles.SELECT.dots ? 'anywhere' : 'break-word',
393
+ color: optionItemColor
394
+ ? optionItemColor
395
+ : configStyles.SELECT.optionItemColor,
396
+ cursor: optionItemCursor
397
+ ? optionItemCursor
398
+ : configStyles.SELECT.optionItemCursor,
399
+ padding: optionItemPadding
400
+ ? optionItemPadding
401
+ : configStyles.SELECT.optionItemPadding,
402
+ fontSize: optionItemFontSize
403
+ ? optionItemFontSize
404
+ : configStyles.SELECT.optionItemFontSize,
405
+ boxSizing: optionItemBoxSizing
406
+ ? optionItemBoxSizing
407
+ : configStyles.SELECT.optionItemBoxSizing,
408
+ minHeight: optionItemMinHeight
409
+ ? optionItemMinHeight
410
+ : configStyles.SELECT.optionItemMinHeight,
411
+ fontWeight: optionItemFontWeight
412
+ ? optionItemFontWeight
413
+ : configStyles.SELECT.optionItemFontWeight,
414
+ lineHeight:
415
+ dots || configStyles.SELECT.dots
416
+ ? '46px'
417
+ : optionItemLineHeight
418
+ ? optionItemLineHeight
419
+ : configStyles.SELECT.optionItemLineHeight,
420
+ marginBottom: optionItemMarginBottom
421
+ ? optionItemMarginBottom
422
+ : configStyles.SELECT.optionItemMarginBottom,
423
+ backgroundColor: optionItemBackgroudColor
424
+ ? optionItemBackgroudColor
425
+ : configStyles.SELECT.optionItemBackgroudColor,
426
+ }}
427
+ >
428
+ {multiple && multipleCheckbox ? (
429
+ <SingleCheckbox checked={option.checked} />
430
+ ) : (
431
+ ''
432
+ )}
433
+ {option[keyNames.name]}
434
+ </div>
435
+ )
436
+ })}
437
+ </div>
438
+ </div>
439
+ ) : null}
345
440
  </div>
346
441
  </div>
347
-
348
- {
349
- errorMessage ?
350
- <span
351
- style={{
352
- position: 'absolute',
353
- color: errorColor ? errorColor : configStyles.SELECT.errorColor,
354
- fontSize: errorSize ? errorSize : configStyles.SELECT.errorSize,
355
- zIndex: errorZindex ? errorZindex : configStyles.SELECT.errorZindex,
356
- top: marginTop ? `calc(100% + ${marginTop})` : `calc(100% + ${configStyles.INPUT.marginTop})`
357
- }}
358
- >
359
- {errorMessage}
360
- </span>
361
- : ''
362
- }
442
+
443
+ {errorMessage ? (
444
+ <span
445
+ style={{
446
+ position: 'absolute',
447
+ color: errorColor ? errorColor : configStyles.SELECT.errorColor,
448
+ fontSize: errorSize ? errorSize : configStyles.SELECT.errorSize,
449
+ zIndex: errorZindex ? errorZindex : configStyles.SELECT.errorZindex,
450
+ top: marginTop ? `calc(100% + ${marginTop})` : `calc(100% + ${configStyles.INPUT.marginTop})`,
451
+ }}
452
+ >
453
+ {errorMessage}
454
+ </span>
455
+ ) : (
456
+ ''
457
+ )}
363
458
  </div>
364
- );
365
- };
459
+ )
460
+ }
366
461
 
367
462
  Select.propTypes = {
368
463
  dots: PropTypes.bool,
@@ -427,4 +522,4 @@ Select.propTypes = {
427
522
 
428
523
  boxShadow: PropTypes.string,
429
524
  boxShadowHover: PropTypes.string,
430
- };
525
+ }