@geneui/components 2.11.2 → 2.12.2

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 (213) hide show
  1. package/{ActionableList.js → ActionableList/index.js} +83 -152
  2. package/{AdvancedSearch.js → AdvancedSearch/index.js} +290 -304
  3. package/Alert/index.js +97 -0
  4. package/Avatar/index.js +30 -0
  5. package/Badge/index.js +75 -0
  6. package/{Breadcrumb.js → Breadcrumb/index.js} +32 -31
  7. package/BusyLoader/index.js +68 -0
  8. package/Button/index.js +129 -0
  9. package/CHANGELOG.md +53 -0
  10. package/{Card.js → Card/index.js} +82 -94
  11. package/{CardList.js → CardList/index.js} +120 -165
  12. package/{CellMeasurerCache-b786dd93.js → CellMeasurerCache-3741d716.js} +2 -2
  13. package/{index-9164a86d.js → Charts/index.js} +17103 -30447
  14. package/{Checkbox.js → Checkbox/index.js} +37 -38
  15. package/{CheckboxGroup.js → CheckboxGroup/index.js} +41 -42
  16. package/{CheckboxGroupWithSearch.js → CheckboxGroupWithSearch/index.js} +64 -65
  17. package/{Collapse.js → Collapse/index.js} +28 -29
  18. package/{ColorPicker.js → ColorPicker/index.js} +16 -16
  19. package/ComboBox/index.js +525 -0
  20. package/Counter/index.js +310 -0
  21. package/{DateFilter.js → DateFilter/index.js} +45 -43
  22. package/{DatePicker.js → DatePicker/index.js} +106 -108
  23. package/{index-0199942c.js → DatePickerInput/index.js} +114 -100
  24. package/{Divider.js → Divider/index.js} +9 -10
  25. package/{Drawer.js → Drawer/index.js} +40 -41
  26. package/Dropdown/index.js +41 -0
  27. package/{Editor.js → Editor/index.js} +165 -164
  28. package/{Empty.js → Empty/index.js} +12 -13
  29. package/{ExtendedInput.js → ExtendedInput/index.js} +81 -71
  30. package/Form/index.js +83 -0
  31. package/{FormContainer.js → FormContainer/index.js} +25 -26
  32. package/FormableCheckbox/index.js +26 -0
  33. package/FormableDatePicker/index.js +41 -0
  34. package/FormableDropdown/index.js +48 -0
  35. package/FormableEditor/index.js +24 -0
  36. package/{FormableHOC-21051057.js → FormableHOC-55263162.js} +3 -3
  37. package/FormableMultiSelectDropdown/index.js +48 -0
  38. package/FormableNumberInput/index.js +32 -0
  39. package/FormableRadio/index.js +22 -0
  40. package/FormableSwitcher/index.js +22 -0
  41. package/FormableTextInput/index.js +32 -0
  42. package/FormableUploader/index.js +42 -0
  43. package/GeneUIProvider/index.js +282 -0
  44. package/{Grid.js → Grid/index.js} +27 -27
  45. package/Holder/index.js +261 -0
  46. package/{Icon.js → Icon/index.js} +9 -10
  47. package/Image/index.js +129 -0
  48. package/ImagePreview/index.js +481 -0
  49. package/{KeyValue.js → KeyValue/index.js} +11 -12
  50. package/LICENSE +21 -0
  51. package/Label/index.js +57 -0
  52. package/LinkButton/index.js +67 -0
  53. package/{Menu.js → Menu/index.js} +27 -28
  54. package/MobileNavigation/index.js +94 -0
  55. package/{MobilePopup.js → MobilePopup/index.js} +42 -41
  56. package/{Modal.js → Modal/index.js} +39 -40
  57. package/ModuleTitle/index.js +143 -0
  58. package/{NavigationMenu.js → NavigationMenu/index.js} +30 -29
  59. package/Notification/index.js +119 -0
  60. package/Option/index.js +184 -0
  61. package/Overlay/index.js +189 -0
  62. package/Overspread/index.js +289 -0
  63. package/{Pagination.js → Pagination/index.js} +35 -34
  64. package/Paper/index.js +96 -0
  65. package/{index-084588e9.js → Popover/index.js} +48 -58
  66. package/PopoverV2/index.js +18 -0
  67. package/{Portal.js → Portal/index.js} +7 -8
  68. package/{Products.js → Products/index.js} +20 -21
  69. package/Profile/index.js +585 -0
  70. package/Progress/index.js +199 -0
  71. package/{QRCode.js → QRCode/index.js} +4 -6
  72. package/{Radio.js → Radio/index.js} +25 -26
  73. package/{RadioGroup.js → RadioGroup/index.js} +17 -18
  74. package/{index-00fe8887.js → Range/index.js} +29 -32
  75. package/RichEditor/index.js +13 -0
  76. package/{RichEditor-98accead.js → RichEditor-8b0f7ccd.js} +18 -18
  77. package/{Scrollbar.js → Scrollbar/index.js} +15 -17
  78. package/{Search.js → Search/index.js} +25 -24
  79. package/SearchWithDropdown/index.js +138 -0
  80. package/Section/index.js +61 -0
  81. package/{SkeletonLoader.js → SkeletonLoader/index.js} +13 -14
  82. package/{Slider.js → Slider/index.js} +46 -43
  83. package/Status/index.js +103 -0
  84. package/Steps/index.js +313 -0
  85. package/{index-897d8240.js → SuggestionList/index.js} +15 -38
  86. package/{Switcher.js → Switcher/index.js} +30 -31
  87. package/Table/index.js +53 -0
  88. package/{TableCompositions.js → TableCompositions/index.js} +131 -168
  89. package/Tabs/index.js +235 -0
  90. package/Tag/index.js +102 -0
  91. package/{TextLink.js → TextLink/index.js} +3 -3
  92. package/{Textarea.js → Textarea/index.js} +66 -65
  93. package/{Time.js → Time/index.js} +13 -14
  94. package/TimePicker/index.js +555 -0
  95. package/Timeline/index.js +113 -0
  96. package/Title/index.js +65 -0
  97. package/{Toaster.js → Toaster/index.js} +19 -20
  98. package/{Tooltip.js → Tooltip/index.js} +27 -28
  99. package/{TransferList.js → TransferList/index.js} +44 -55
  100. package/{index-135b9d17.js → Uploader/index.js} +119 -116
  101. package/{ValidatableCheckbox.js → ValidatableCheckbox/index.js} +23 -24
  102. package/{ValidatableDatePicker.js → ValidatableDatePicker/index.js} +44 -42
  103. package/ValidatableDropdown/index.js +139 -0
  104. package/ValidatableElements/index.js +65 -0
  105. package/ValidatableMultiSelectDropdown/index.js +150 -0
  106. package/{ValidatableNumberInput.js → ValidatableNumberInput/index.js} +41 -33
  107. package/{ValidatableRadio.js → ValidatableRadio/index.js} +19 -20
  108. package/{ValidatableSwitcher.js → ValidatableSwitcher/index.js} +19 -20
  109. package/{ValidatableTextInput.js → ValidatableTextInput/index.js} +32 -31
  110. package/{ValidatableTimeInput.js → ValidatableTimeInput/index.js} +31 -30
  111. package/{ValidatableUploader.js → ValidatableUploader/index.js} +36 -34
  112. package/Widget/index.js +227 -0
  113. package/config-0ca92874.js +31 -0
  114. package/{configs-91c86664.js → configs-fed6ac34.js} +28 -1
  115. package/hooks/useBodyScroll.js +16 -0
  116. package/hooks/useClick.js +18 -0
  117. package/{useClickOutside-5183e396.js → hooks/useClickOutside.js} +1 -1
  118. package/hooks/useDebounceHook.js +16 -0
  119. package/{useDeviceType-dd51db38.js → hooks/useDeviceType.js} +4 -3
  120. package/hooks/useDidMount.js +15 -0
  121. package/{useEllipsisDetection-ef536015.js → hooks/useEllipsisDetection.js} +1 -1
  122. package/hooks/useForceUpdate.js +8 -0
  123. package/hooks/useImgDownload.js +18 -0
  124. package/{useKeyDown-38102ae7.js → hooks/useKeyDown.js} +1 -1
  125. package/hooks/useMount.js +13 -0
  126. package/hooks/useMutationObserver.js +21 -0
  127. package/hooks/usePrevious.js +10 -0
  128. package/hooks/useThrottle.js +16 -0
  129. package/hooks/useToggle.js +11 -0
  130. package/hooks/useUpdatableRef.js +14 -0
  131. package/hooks/useUpdate.js +10 -0
  132. package/{useWidth-9f4647f8.js → hooks/useWidth.js} +2 -2
  133. package/{useWindowSize-80369d76.js → hooks/useWindowSize.js} +1 -1
  134. package/{index-8c98317a.js → index-11eea761.js} +678 -752
  135. package/index-2ad83e03.js +4 -0
  136. package/index-34e47647.js +10054 -0
  137. package/index-45eafea6.js +90 -0
  138. package/{index-5e96cb4d.js → index-462461c0.js} +50 -48
  139. package/{index-ac59cb10.js → index-a0e4e333.js} +6 -6
  140. package/{index-e8776f3d.js → index-b1e429a7.js} +1 -1
  141. package/index.d.ts +115 -0
  142. package/index.js +137 -113
  143. package/index.mobile.d.ts +16 -0
  144. package/lib/atoms/Avatar/Avatar.d.ts +34 -0
  145. package/lib/atoms/Avatar/index.d.ts +1 -0
  146. package/lib/atoms/LinkButton/LinkButton.d.ts +46 -0
  147. package/lib/atoms/LinkButton/index.d.ts +1 -0
  148. package/{objectWithoutPropertiesLoose-299691d8.js → objectWithoutPropertiesLoose-d8a4a68c.js} +12 -12
  149. package/package.json +42 -22
  150. package/{rangeAndSlider-20599da4.js → rangeAndSlider-0301a458.js} +220 -375
  151. package/{react-beautiful-dnd.esm-38c37304.js → react-beautiful-dnd.esm-04c14563.js} +9 -9
  152. package/react-lifecycles-compat.es-6e1f3768.js +158 -0
  153. package/Alert.js +0 -98
  154. package/Avatar.js +0 -77
  155. package/Badge.js +0 -76
  156. package/BusyLoader.js +0 -69
  157. package/Button.js +0 -130
  158. package/Charts.js +0 -99
  159. package/ComboBox.js +0 -99
  160. package/Counter.js +0 -99
  161. package/DatePickerInput.js +0 -30
  162. package/Dropdown.js +0 -99
  163. package/Form.js +0 -116
  164. package/FormableCheckbox.js +0 -27
  165. package/FormableDatePicker.js +0 -39
  166. package/FormableDropdown.js +0 -105
  167. package/FormableEditor.js +0 -24
  168. package/FormableMultiSelectDropdown.js +0 -105
  169. package/FormableNumberInput.js +0 -31
  170. package/FormableRadio.js +0 -23
  171. package/FormableSwitcher.js +0 -23
  172. package/FormableTextInput.js +0 -31
  173. package/FormableUploader.js +0 -40
  174. package/GeneUIProvider.js +0 -256
  175. package/Holder.js +0 -99
  176. package/Image.js +0 -130
  177. package/ImagePreview.js +0 -99
  178. package/Label.js +0 -58
  179. package/LinkButton.js +0 -104
  180. package/MobileNavigation.js +0 -95
  181. package/ModuleTitle.js +0 -99
  182. package/Notification.js +0 -120
  183. package/Option.js +0 -186
  184. package/Overlay.js +0 -99
  185. package/Overspread.js +0 -343
  186. package/Paper.js +0 -97
  187. package/Popover.js +0 -20
  188. package/PopoverV2.js +0 -19
  189. package/Profile.js +0 -99
  190. package/Progress.js +0 -200
  191. package/Range.js +0 -14
  192. package/RichEditor.js +0 -13
  193. package/SearchWithDropdown.js +0 -195
  194. package/Section.js +0 -62
  195. package/Status.js +0 -104
  196. package/Steps.js +0 -312
  197. package/SuggestionList.js +0 -15
  198. package/Table.js +0 -102
  199. package/Tabs.js +0 -236
  200. package/Tag.js +0 -103
  201. package/TimePicker.js +0 -99
  202. package/Timeline.js +0 -114
  203. package/Title.js +0 -66
  204. package/Uploader.js +0 -32
  205. package/ValidatableDropdown.js +0 -99
  206. package/ValidatableElements.js +0 -99
  207. package/ValidatableMultiSelectDropdown.js +0 -99
  208. package/Widget.js +0 -99
  209. package/globalStyling-9c60a159.js +0 -4
  210. package/index-2030e31c.js +0 -4
  211. package/index-b7a33c58.js +0 -11
  212. package/index-e0af0caf.js +0 -1182
  213. package/useMount-6fef51a5.js +0 -9
@@ -0,0 +1,525 @@
1
+ import { _ as _extends } from '../_rollupPluginBabelHelpers-e8fb2e5c.js';
2
+ import React__default, { forwardRef, useState, useRef, useMemo, useCallback, useEffect } from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import { c as classnames } from '../index-6ff23041.js';
5
+ import { i as inputConfig } from '../configs-fed6ac34.js';
6
+ import { s as stopEvent, n as noop } from '../index-a0e4e333.js';
7
+ import useClickOutside from '../hooks/useClickOutside.js';
8
+ import { c as callAfterDelay, k as keyDownKeys, a as actionTypes, S as SPACE_HEIGHT } from '../config-0ca92874.js';
9
+ import Icon from '../Icon/index.js';
10
+ import CustomScrollbar from '../Scrollbar/index.js';
11
+ import Tooltip from '../Tooltip/index.js';
12
+ import useKeyDown from '../hooks/useKeyDown.js';
13
+ import Tag from '../Tag/index.js';
14
+ import { s as styleInject } from '../style-inject.es-746bb8ed.js';
15
+ import '../dateValidation-67caec66.js';
16
+ import '../_commonjsHelpers-24198af3.js';
17
+ import 'react-dom';
18
+ import '../Popover-f4d1cac0.js';
19
+ import '../hooks/useDeviceType.js';
20
+ import '../hooks/useWindowSize.js';
21
+ import '../GeneUIProvider/index.js';
22
+
23
+ var css_248z$1 = "[data-gene-ui-version=\"2.12.2\"] .tag-wrapper{align-items:center;display:flex;max-width:100%}[data-gene-ui-version=\"2.12.2\"] .tag-wrapper.flex-basis{align-self:center;flex-basis:20px}[data-gene-ui-version=\"2.12.2\"] .tag-wrapper .input{background:#0000;border:none;caret-color:var(--background-sc);color:var(--background-sc);flex:1 1;margin:1px 0;outline:none;padding:0;width:100%}[data-gene-ui-version=\"2.12.2\"] .tag-wrapper span{align-self:flex-start;background:#fff;border:none;color:#000;display:flex;flex:1 1;height:0;outline:none;padding:0;visibility:hidden;white-space:pre}";
24
+ styleInject(css_248z$1);
25
+
26
+ /**
27
+ * Tag Wrapper
28
+ */
29
+ const TagWrapper = /*#__PURE__*/forwardRef((props, ref) => {
30
+ const {
31
+ createInputRef,
32
+ activeRowRef
33
+ } = ref;
34
+ const {
35
+ isValid,
36
+ label,
37
+ editMode,
38
+ index,
39
+ onChangeHandler,
40
+ onDeleteHandler,
41
+ placeholder,
42
+ hasTags,
43
+ hasIcon,
44
+ onKeyPress,
45
+ activeTagIndex,
46
+ setEditModeIndex,
47
+ setActiveTagIndex,
48
+ withEdit
49
+ } = props;
50
+ const [hasTooltip, setHasTooltip] = useState(false);
51
+ const [inputValue, setInputValue] = useState('');
52
+ const [isEditMode, setIsEditMode] = useState(editMode);
53
+ const inputRef = useRef(null);
54
+ const tagRef = useRef(null);
55
+ const isActive = useMemo(() => index === activeTagIndex, [activeTagIndex, index]);
56
+ const createMode = useMemo(() => index === undefined, [index]);
57
+ const editModeChangeHandler = useCallback(() => {
58
+ setIsEditMode(editMode);
59
+ editMode && callAfterDelay(() => {
60
+ var _inputRef$current;
61
+ return inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus();
62
+ });
63
+ }, [editMode, inputRef]);
64
+ const stopEventHandler = e => stopEvent(e, true);
65
+ const keyDownHandler = useCallback(e => {
66
+ switch (e.key) {
67
+ case keyDownKeys.tab:
68
+ case keyDownKeys.enter:
69
+ e.key === keyDownKeys.tab && (isEditMode && !createMode || createMode && inputValue && inputValue.trim().length) && stopEventHandler(e);
70
+ setEditModeIndex && setEditModeIndex(null);
71
+ if (inputValue && inputValue.trim().length && isEditMode) {
72
+ setInputValue(createMode ? '' : inputValue);
73
+ onChangeHandler({
74
+ label: inputValue,
75
+ index
76
+ });
77
+ !createMode && setIsEditMode(false);
78
+ } else if (!inputValue && !createMode) {
79
+ onDeleteHandler(index);
80
+ setIsEditMode(false);
81
+ } else if (activeTagIndex !== null && setEditModeIndex) {
82
+ e.key === keyDownKeys.enter && setEditModeIndex(activeTagIndex);
83
+ e.key === keyDownKeys.tab && setActiveTagIndex(null);
84
+ }
85
+ break;
86
+ case keyDownKeys.escape:
87
+ setEditModeIndex && setEditModeIndex(null);
88
+ setActiveTagIndex && setActiveTagIndex(null);
89
+ if (!createMode) {
90
+ setIsEditMode(false);
91
+ setInputValue(label || '');
92
+ }
93
+ break;
94
+ case keyDownKeys.arrowRight:
95
+ case keyDownKeys.backspace:
96
+ case keyDownKeys.arrowLeft:
97
+ case keyDownKeys.delete:
98
+ createMode && !inputValue && withEdit && onKeyPress(e.key);
99
+ break;
100
+ }
101
+ }, [activeTagIndex, createMode, index, inputValue, isEditMode, label, onChangeHandler, onDeleteHandler, onKeyPress, setActiveTagIndex, setEditModeIndex, withEdit]);
102
+ const dblclickHandler = useCallback(() => {
103
+ const handleClick = () => {
104
+ if (createMode || !withEdit || isEditMode) return;
105
+ setIsEditMode(prev => !prev);
106
+ setEditModeIndex(index);
107
+ setActiveTagIndex(null);
108
+ (createInputRef || inputRef).current.focus();
109
+ };
110
+ const element = tagRef === null || tagRef === void 0 ? void 0 : tagRef.current;
111
+ element && element.addEventListener('dblclick', handleClick);
112
+ return () => {
113
+ element && element.removeEventListener('dblclick', handleClick);
114
+ };
115
+ }, [createMode, isEditMode, createInputRef, withEdit, setEditModeIndex, index, setActiveTagIndex]);
116
+ const handleOutsideClick = useClickOutside(event => {
117
+ if (tagRef && !tagRef.current.contains(event.target)) {
118
+ if (!createMode && isEditMode) {
119
+ setIsEditMode(false);
120
+ if (label !== inputValue) {
121
+ if (inputValue && inputValue.trim().length) {
122
+ onChangeHandler({
123
+ label: inputValue,
124
+ index
125
+ });
126
+ } else {
127
+ onDeleteHandler(index);
128
+ }
129
+ }
130
+ } else if (inputValue && createMode) {
131
+ inputValue.trim().length && onChangeHandler({
132
+ label: inputValue,
133
+ index
134
+ });
135
+ setInputValue('');
136
+ }
137
+ }
138
+ });
139
+ const handleChangeLabel = useCallback(() => {
140
+ var _tagRef$current, _tagRef$current2, _tagRef$current2$offs;
141
+ setHasTooltip((tagRef === null || tagRef === void 0 ? void 0 : (_tagRef$current = tagRef.current) === null || _tagRef$current === void 0 ? void 0 : _tagRef$current.offsetWidth) + 130 > (tagRef === null || tagRef === void 0 ? void 0 : (_tagRef$current2 = tagRef.current) === null || _tagRef$current2 === void 0 ? void 0 : (_tagRef$current2$offs = _tagRef$current2.offsetParent) === null || _tagRef$current2$offs === void 0 ? void 0 : _tagRef$current2$offs.offsetWidth));
142
+ }, [setHasTooltip, tagRef]);
143
+ const inputChangeHandler = useCallback(e => {
144
+ setInputValue(e.target.value);
145
+ createMode && setActiveTagIndex(null);
146
+ }, [createMode, setActiveTagIndex]);
147
+ useKeyDown(keyDownHandler, [keyDownHandler], createInputRef || inputRef, [keyDownKeys.enter, keyDownKeys.escape, keyDownKeys.arrowLeft, keyDownKeys.arrowRight, keyDownKeys.backspace, keyDownKeys.tab, keyDownKeys.delete]);
148
+ useEffect(dblclickHandler, [createInputRef, tagRef, inputRef, withEdit, isEditMode]);
149
+ useEffect(() => label && setInputValue(label), [label]);
150
+ useEffect(editModeChangeHandler, [editMode, inputRef]);
151
+ useEffect(handleChangeLabel, [tagRef, label]);
152
+ return /*#__PURE__*/React__default.createElement("div", {
153
+ className: classnames('tag-wrapper', {
154
+ 'flex-basis': hasTags
155
+ }),
156
+ ref: tagRef
157
+ }, /*#__PURE__*/React__default.createElement("div", {
158
+ ref: handleOutsideClick
159
+ }, isEditMode ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("input", {
160
+ ref: createInputRef || inputRef,
161
+ onChange: inputChangeHandler,
162
+ onClick: stopEventHandler,
163
+ placeholder: placeholder,
164
+ className: "input",
165
+ value: inputValue
166
+ }), /*#__PURE__*/React__default.createElement("span", null, inputValue.replaceAll(' ', '-'))) : /*#__PURE__*/React__default.createElement("div", {
167
+ ref: isActive ? activeRowRef : null
168
+ }, /*#__PURE__*/React__default.createElement(Tooltip, {
169
+ position: "auto",
170
+ title: hasTooltip ? label : ''
171
+ }, /*#__PURE__*/React__default.createElement(Tag, _extends({}, hasIcon ? {
172
+ icons: /*#__PURE__*/React__default.createElement(Icon, {
173
+ type: "bc-icon-clear-small",
174
+ onClick: () => onDeleteHandler(index)
175
+ })
176
+ } : {}, {
177
+ appearance: isActive ? 'colored' : 'light'
178
+ }, !isValid && {
179
+ color: 'red'
180
+ }, {
181
+ cornerRadius: "smooth-radius",
182
+ onClick: stopEventHandler,
183
+ name: label
184
+ }))))));
185
+ });
186
+ TagWrapper.propTypes = {
187
+ isValid: PropTypes.bool,
188
+ label: PropTypes.string,
189
+ editMode: PropTypes.bool,
190
+ index: PropTypes.number,
191
+ onChangeHandler: PropTypes.func,
192
+ onDeleteHandler: PropTypes.func,
193
+ placeholder: PropTypes.string,
194
+ hasTags: PropTypes.bool,
195
+ hasIcon: PropTypes.bool,
196
+ onKeyPress: PropTypes.func,
197
+ activeTagIndex: PropTypes.number,
198
+ setEditModeIndex: PropTypes.func,
199
+ setActiveTagIndex: PropTypes.func,
200
+ withEdit: PropTypes.bool
201
+ };
202
+ TagWrapper.defaultProps = {
203
+ isValid: false,
204
+ isActive: false
205
+ };
206
+
207
+ var css_248z = "[data-gene-ui-version=\"2.12.2\"] .combo-box{--element-height:4.6rem;--element-min-width:25rem;--message-padding-side:2rem;--input-message-padding-side:2rem;--element-border-color:rgba(var(--background-sc-rgb),0.2);height:-webkit-fit-content;height:-moz-fit-content;height:fit-content;max-width:100%;min-width:var(--element-min-width);position:relative;transition:opacity .3s;-webkit-user-select:none;user-select:none;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content}[data-gene-ui-version=\"2.12.2\"] .combo-box.read-only{--element-border-color:rgba(var(--background-sc-rgb),0.05)}[data-gene-ui-version=\"2.12.2\"] .combo-box.filled:not(:focus-within){--element-border-color:rgba(var(--background-sc-rgb),0.3)}[data-gene-ui-version=\"2.12.2\"] .combo-box:not(.read-only):focus-within{--element-border-color:var(--hero)}[data-gene-ui-version=\"2.12.2\"] .combo-box:not(.f-content-size){width:100%}[data-gene-ui-version=\"2.12.2\"] .combo-box.disabled{opacity:.5;pointer-events:none}[data-gene-ui-version=\"2.12.2\"] .combo-box.disabled:not(.read-only):focus-within{--element-border-color:rgba(var(--background-sc-rgb),0.2)}[data-gene-ui-version=\"2.12.2\"] .combo-box.read-only{cursor:inherit}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container{border:1px solid var(--element-border-color,#0000);border-radius:10px;overflow:hidden;width:100%}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container .swap-label{display:flex;font:600 1rem/1.8rem var(--font-family);left:0;padding:0 var(--input-message-padding-side);position:absolute;top:-.9rem;width:100%;z-index:5}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container .swap-label .icon{font-size:1.8rem;transition:none}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container .swap{max-width:100%;overflow:hidden}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container .swap-animate{align-items:center;background:var(--background);box-shadow:inset 0 -.8rem 0 var(--input-element-background);color:var(--swap-label-color);display:flex;max-width:100%;padding:0 .4rem;transition:transform .3s,opacity .3s .1s,color .3s}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container .swap-animate>*+*{margin-inline-start:.5rem}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container .swap-animate.hide{opacity:0;transform:translateY(100%)}[data-gene-ui-version=\"2.12.2\"] .combo-box .combo-box-container .boxes{display:flex;flex-wrap:wrap;gap:8px;min-height:4.2rem;padding:8px 16px}[data-gene-ui-version=\"2.12.2\"] .information-message{cursor:default;font:600 1.2rem/1.42 var(--font-family);margin:.6rem 0 0;padding:0 var(--input-message-padding-side);width:100%}[data-gene-ui-version=\"2.12.2\"] .information-message:empty{display:none}[data-gene-ui-version=\"2.12.2\"] .input-description{cursor:default;font:600 1.4rem/2rem var(--font-family);margin:1rem 0 0;max-width:100%;opacity:.7}[data-gene-ui-version=\"2.12.2\"] .input-structure~.input-description{padding:0 1rem}[data-gene-ui-version=\"2.12.2\"] .title{align-items:center;cursor:default;display:flex;font:600 1.4rem/2rem var(--font-family);margin:0 0 .4rem;max-width:100%;opacity:.5;padding:0 var(--message-padding-side)}[data-gene-ui-version=\"2.12.2\"] .title>*+*{margin-inline-start:.5rem}";
208
+ styleInject(css_248z);
209
+
210
+ /**
211
+ * Combo box
212
+ */
213
+ function ComboBox(props) {
214
+ const {
215
+ infoIconTooltipProps,
216
+ labelAppearance,
217
+ withInfoIcon,
218
+ flexibility,
219
+ placeholder,
220
+ withDelete,
221
+ className,
222
+ maxHeight,
223
+ required,
224
+ tabIndex,
225
+ onChange,
226
+ readOnly,
227
+ withEdit,
228
+ disabled,
229
+ label,
230
+ regEx
231
+ } = props;
232
+ const inputLabel = label || placeholder;
233
+ const asterisk = required ? '*' : '';
234
+ const isControlled = 'value' in props && props.value;
235
+ const [activeTagIndex, setActiveTagIndex] = useState(null);
236
+ const [editModeIndex, setEditModeIndex] = useState(null);
237
+ const [values, setValues] = useState([]);
238
+ const scrollbarRef = useRef();
239
+ const activeRowRef = useRef();
240
+ const inputRef = useRef();
241
+ const checkIsValid = useCallback(value => regEx ? new RegExp(regEx).test(value) : true, [regEx]);
242
+ const onValueChangeHandler = useCallback(_ref => {
243
+ let {
244
+ label,
245
+ index
246
+ } = _ref;
247
+ const valuesClone = [...values];
248
+ const isValid = checkIsValid(label);
249
+ const added = index === undefined;
250
+ if (added) {
251
+ valuesClone.push({
252
+ label,
253
+ isValid
254
+ });
255
+ } else {
256
+ valuesClone[index].label = label;
257
+ valuesClone[index].isValid = isValid;
258
+ inputRef.current.focus();
259
+ setEditModeIndex(null);
260
+ }
261
+ !isControlled && setValues(valuesClone);
262
+ onChange({
263
+ value: valuesClone,
264
+ additional: {
265
+ type: added ? actionTypes.add : actionTypes.edit,
266
+ index: added ? valuesClone.length - 1 : index,
267
+ isValid,
268
+ label
269
+ }
270
+ });
271
+ }, [values, checkIsValid, isControlled, onChange, setEditModeIndex]);
272
+ const onDeleteHandler = useCallback(index => {
273
+ const valuesClone = [...values];
274
+ const item = valuesClone[index];
275
+ valuesClone.splice(index, 1);
276
+ !isControlled && setValues(valuesClone);
277
+ !valuesClone.length && setActiveTagIndex(null);
278
+ onChange({
279
+ value: valuesClone,
280
+ additional: {
281
+ type: actionTypes.delete,
282
+ index,
283
+ ...item
284
+ }
285
+ });
286
+ inputRef.current && callAfterDelay(() => inputRef.current.focus());
287
+ }, [values, isControlled, onChange, inputRef]);
288
+ const init = useCallback(() => {
289
+ if (isControlled && Array.isArray(props.value)) {
290
+ setValues(props.value.map(row => ({
291
+ ...row,
292
+ isValid: checkIsValid(row === null || row === void 0 ? void 0 : row.label)
293
+ })));
294
+ } else if (props.defaultValue && Array.isArray(props.defaultValue)) {
295
+ setValues(props.defaultValue.map(row => ({
296
+ ...row,
297
+ isValid: checkIsValid(row === null || row === void 0 ? void 0 : row.label)
298
+ })));
299
+ }
300
+ }, [checkIsValid, isControlled, props.defaultValue, props.value]);
301
+ const handleOutsideClick = useClickOutside(() => {
302
+ scrollbarRef.current.scrollTop(0, 0);
303
+ setActiveTagIndex(null);
304
+ });
305
+ const onClickHandler = useCallback(() => {
306
+ if (disabled || readOnly) return;
307
+ inputRef.current && callAfterDelay(() => inputRef.current.focus());
308
+ }, [disabled, readOnly, inputRef]);
309
+ const onKeyPress = useCallback(type => {
310
+ switch (type) {
311
+ case keyDownKeys.arrowLeft:
312
+ if (values.length && activeTagIndex !== 0) {
313
+ setActiveTagIndex(activeTagIndex === null ? values.length - 1 : activeTagIndex - 1);
314
+ }
315
+ break;
316
+ case keyDownKeys.arrowRight:
317
+ if (values.length && activeTagIndex !== null && activeTagIndex < values.length - 1) {
318
+ setActiveTagIndex(activeTagIndex + 1);
319
+ }
320
+ break;
321
+ case keyDownKeys.delete:
322
+ case keyDownKeys.backspace:
323
+ if (withDelete) {
324
+ if (activeTagIndex !== null) {
325
+ activeTagIndex > 0 && setActiveTagIndex(activeTagIndex - 1);
326
+ onDeleteHandler(activeTagIndex);
327
+ } else if (values.length) {
328
+ onDeleteHandler(values.length - 1);
329
+ }
330
+ }
331
+ break;
332
+ }
333
+ }, [activeTagIndex, onDeleteHandler, values.length, withDelete]);
334
+ const onFocusHandler = useCallback(() => {
335
+ var _inputRef$current;
336
+ return editModeIndex === null && !disabled && !readOnly && (inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.focus());
337
+ }, [editModeIndex, disabled, readOnly, inputRef]);
338
+ useEffect(init, [props.defaultValue, props.value]);
339
+ useEffect(() => {
340
+ if (activeTagIndex && activeRowRef.current) {
341
+ const scrollbarRefBounding = scrollbarRef.current.container.getBoundingClientRect();
342
+ const activeRowRefBounding = activeRowRef.current.getBoundingClientRect();
343
+ if (scrollbarRefBounding.top > activeRowRefBounding.top - SPACE_HEIGHT) {
344
+ scrollbarRef.current.scrollTop(scrollbarRef.current.viewScrollTop - activeRowRefBounding.height - SPACE_HEIGHT);
345
+ } else if (activeRowRefBounding.top + activeRowRefBounding.height + SPACE_HEIGHT > scrollbarRefBounding.top + maxHeight) {
346
+ scrollbarRef.current.scrollTop(scrollbarRef.current.viewScrollTop + activeRowRefBounding.height + SPACE_HEIGHT);
347
+ }
348
+ }
349
+ }, [activeTagIndex, scrollbarRef]);
350
+ return /*#__PURE__*/React__default.createElement("div", {
351
+ onFocus: onFocusHandler,
352
+ ref: handleOutsideClick,
353
+ tabIndex: tabIndex,
354
+ className: classnames('combo-box', "f-".concat(flexibility), className, {
355
+ 'read-only': readOnly,
356
+ disabled
357
+ })
358
+ }, labelAppearance === inputConfig.labelAppearance[1] && /*#__PURE__*/React__default.createElement("div", {
359
+ className: "title ellipsis-text"
360
+ }, /*#__PURE__*/React__default.createElement(Tooltip, _extends({
361
+ position: "auto"
362
+ }, infoIconTooltipProps), /*#__PURE__*/React__default.createElement("span", {
363
+ className: "ellipsis-text"
364
+ }, asterisk, " ", inputLabel)), withInfoIcon && /*#__PURE__*/React__default.createElement(Tooltip, _extends({
365
+ position: "auto"
366
+ }, infoIconTooltipProps), /*#__PURE__*/React__default.createElement(Icon, {
367
+ type: "bc-icon-info"
368
+ }))), /*#__PURE__*/React__default.createElement("div", {
369
+ className: "combo-box-container",
370
+ onClick: onClickHandler
371
+ }, /*#__PURE__*/React__default.createElement("div", {
372
+ className: "element-back"
373
+ }, labelAppearance === inputConfig.labelAppearance[2] && /*#__PURE__*/React__default.createElement("div", {
374
+ className: "swap-label"
375
+ }, /*#__PURE__*/React__default.createElement("div", {
376
+ className: "swap"
377
+ }, /*#__PURE__*/React__default.createElement("div", {
378
+ className: classnames('input-swap-animate ellipsis-text', {
379
+ hide: !values.length
380
+ })
381
+ }, /*#__PURE__*/React__default.createElement(Tooltip, _extends({
382
+ position: "auto"
383
+ }, infoIconTooltipProps), /*#__PURE__*/React__default.createElement("span", {
384
+ className: "ellipsis-text"
385
+ }, asterisk, " ", inputLabel)), withInfoIcon && /*#__PURE__*/React__default.createElement(Tooltip, _extends({
386
+ position: "auto"
387
+ }, infoIconTooltipProps), /*#__PURE__*/React__default.createElement(Icon, {
388
+ type: "bc-icon-info"
389
+ })))))), /*#__PURE__*/React__default.createElement("div", {
390
+ className: classnames({
391
+ 'pointer-events-none': disabled || readOnly
392
+ })
393
+ }, /*#__PURE__*/React__default.createElement(CustomScrollbar, {
394
+ autoHeight: true,
395
+ autoHeightMax: maxHeight,
396
+ ref: scrollbarRef
397
+ }, /*#__PURE__*/React__default.createElement("div", {
398
+ className: "boxes"
399
+ }, values.map((value, index) => /*#__PURE__*/React__default.createElement(TagWrapper, _extends({
400
+ key: "".concat(JSON.stringify(value)).concat(index),
401
+ onChangeHandler: onValueChangeHandler,
402
+ setActiveTagIndex: setActiveTagIndex,
403
+ setEditModeIndex: setEditModeIndex,
404
+ editMode: editModeIndex === index,
405
+ hasIcon: !readOnly && withDelete,
406
+ onDeleteHandler: onDeleteHandler,
407
+ activeTagIndex: activeTagIndex,
408
+ activeRowRef: activeRowRef,
409
+ onKeyPress: onKeyPress,
410
+ ref: {
411
+ activeRowRef
412
+ },
413
+ withEdit: withEdit,
414
+ hasTags: true,
415
+ index: index
416
+ }, value))), withEdit && !disabled && !readOnly && /*#__PURE__*/React__default.createElement(TagWrapper, {
417
+ placeholder: !values.length ? placeholder : '',
418
+ onChangeHandler: onValueChangeHandler,
419
+ setActiveTagIndex: setActiveTagIndex,
420
+ setEditModeIndex: setEditModeIndex,
421
+ activeTagIndex: activeTagIndex,
422
+ hasTags: !!values.length,
423
+ onKeyPress: onKeyPress,
424
+ withEdit: withEdit,
425
+ editMode: true,
426
+ ref: {
427
+ createInputRef: inputRef
428
+ }
429
+ }))))));
430
+ }
431
+ ComboBox.propTypes = {
432
+ /**
433
+ * Additional className
434
+ */
435
+ className: PropTypes.string,
436
+ /**
437
+ * Specify a "label" appearance
438
+ */
439
+ labelAppearance: PropTypes.oneOf(inputConfig.labelAppearance),
440
+ /**
441
+ * How to display inscription in relation to it's parent in ExtendedInput
442
+ */
443
+ flexibility: PropTypes.oneOf(inputConfig.flexibility),
444
+ /**
445
+ * Define is input required or no.
446
+ */
447
+ required: PropTypes.bool,
448
+ /**
449
+ * Define is need input info icon required.
450
+ */
451
+ withInfoIcon: PropTypes.bool,
452
+ /**
453
+ * Tooltip props
454
+ */
455
+ infoIconTooltipProps: PropTypes.shape({
456
+ ...Tooltip.propTypes
457
+ }),
458
+ /**
459
+ * validation regex
460
+ */
461
+ regEx: PropTypes.string,
462
+ /**
463
+ * On change handler
464
+ */
465
+ onChange: PropTypes.func,
466
+ /**
467
+ * Use this prop to get specified value when "onChange" is fired
468
+ */
469
+ value: PropTypes.arrayOf(PropTypes.shape({
470
+ label: PropTypes.string
471
+ })),
472
+ /**
473
+ * Initial Combobox value.
474
+ */
475
+ defaultValue: PropTypes.arrayOf(PropTypes.shape({
476
+ label: PropTypes.string
477
+ })),
478
+ /**
479
+ * Combobox disabled state
480
+ */
481
+ disabled: PropTypes.bool,
482
+ /**
483
+ * Combobox readOnly state
484
+ */
485
+ readOnly: PropTypes.bool,
486
+ /**
487
+ * Is Combobox in edit mode
488
+ */
489
+ withEdit: PropTypes.bool,
490
+ /**
491
+ * Can Delete tags
492
+ */
493
+ withDelete: PropTypes.bool,
494
+ /**
495
+ * Max height of Combobox
496
+ */
497
+ maxHeight: PropTypes.number,
498
+ /**
499
+ * Since the editor has its own modal windows, there may be a problem with
500
+ * the zIndex so you can change it using this prop
501
+ */
502
+ tabIndex: PropTypes.number
503
+ };
504
+
505
+ // toDo Add validation scheme fot form
506
+ ComboBox.defaultProps = {
507
+ labelAppearance: inputConfig.labelAppearance[0],
508
+ flexibility: inputConfig.flexibility[0],
509
+ label: '',
510
+ placeholder: '',
511
+ onChange: noop,
512
+ regEx: '',
513
+ withInfoIcon: false,
514
+ required: false,
515
+ disabled: false,
516
+ readOnly: false,
517
+ withEdit: true,
518
+ withDelete: true,
519
+ maxHeight: 510,
520
+ tabIndex: 0,
521
+ infoIconTooltipProps: {}
522
+ };
523
+ ComboBox.displayName = 'ComboBox';
524
+
525
+ export { ComboBox as default };