@zohodesk/components 1.2.4 → 1.2.6

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 (202) hide show
  1. package/README.md +8 -0
  2. package/coverage/Button/Button.js.html +1 -1
  3. package/coverage/Button/css/Button.module.css.html +1 -1
  4. package/coverage/Button/css/cssJSLogic.js.html +1 -1
  5. package/coverage/Button/css/index.html +1 -1
  6. package/coverage/Button/index.html +1 -1
  7. package/coverage/Button/props/defaultProps.js.html +1 -1
  8. package/coverage/Button/props/index.html +1 -1
  9. package/coverage/Button/props/propTypes.js.html +1 -1
  10. package/coverage/Buttongroup/Buttongroup.js.html +1 -1
  11. package/coverage/Buttongroup/Buttongroup.module.css.html +1 -1
  12. package/coverage/Buttongroup/index.html +1 -1
  13. package/coverage/Buttongroup/props/defaultProps.js.html +1 -1
  14. package/coverage/Buttongroup/props/index.html +1 -1
  15. package/coverage/Buttongroup/props/propTypes.js.html +1 -1
  16. package/coverage/index.html +1 -1
  17. package/coverage/utils/dummyFunction.js.html +1 -1
  18. package/coverage/utils/index.html +1 -1
  19. package/es/AppContainer/AppContainer.js +3 -0
  20. package/es/v1/Accordion/Accordion.js +65 -0
  21. package/es/v1/Accordion/AccordionItem.js +57 -0
  22. package/es/v1/Accordion/index.js +2 -0
  23. package/es/v1/Animation/Animation.js +127 -0
  24. package/es/v1/AppContainer/AppContainer.js +137 -0
  25. package/es/v1/Avatar/Avatar.js +189 -0
  26. package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
  27. package/es/v1/Button/Button.js +68 -0
  28. package/es/v1/Buttongroup/Buttongroup.js +31 -0
  29. package/es/v1/Card/Card.js +271 -0
  30. package/es/v1/CheckBox/CheckBox.js +155 -0
  31. package/es/v1/DateTime/CalendarView.js +218 -0
  32. package/es/v1/DateTime/DateTime.js +783 -0
  33. package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
  34. package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
  35. package/es/v1/DateTime/DateWidget.js +1098 -0
  36. package/es/v1/DateTime/DaysRow.js +31 -0
  37. package/es/v1/DateTime/Time.js +166 -0
  38. package/es/v1/DateTime/YearView.js +264 -0
  39. package/es/v1/DateTime/index.js +1 -0
  40. package/es/v1/DropBox/DropBox.js +91 -0
  41. package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
  42. package/es/v1/DropDown/DropDown.js +73 -0
  43. package/es/v1/DropDown/DropDownHeading.js +44 -0
  44. package/es/v1/DropDown/DropDownItem.js +76 -0
  45. package/es/v1/DropDown/DropDownSearch.js +63 -0
  46. package/es/v1/DropDown/DropDownSeparator.js +15 -0
  47. package/es/v1/Heading/Heading.js +32 -0
  48. package/es/v1/Label/Label.js +40 -0
  49. package/es/v1/Layout/Box.js +115 -0
  50. package/es/v1/Layout/Container.js +132 -0
  51. package/es/v1/Layout/index.js +2 -0
  52. package/es/v1/ListItem/ListContainer.js +102 -0
  53. package/es/v1/ListItem/ListItem.js +124 -0
  54. package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
  55. package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
  56. package/es/v1/ListItem/ListItemWithIcon.js +127 -0
  57. package/es/v1/ListItem/ListItemWithRadio.js +105 -0
  58. package/es/v1/ListItem/index.js +6 -0
  59. package/es/v1/Modal/Modal.js +154 -0
  60. package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
  61. package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
  62. package/es/v1/MultiSelect/EmptyState.js +64 -0
  63. package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
  64. package/es/v1/MultiSelect/MultiSelect.js +1120 -0
  65. package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
  66. package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
  67. package/es/v1/MultiSelect/SelectedOptions.js +82 -0
  68. package/es/v1/MultiSelect/Suggestions.js +142 -0
  69. package/es/v1/MultiSelect/index.js +4 -0
  70. package/es/v1/PopOver/PopOver.js +211 -0
  71. package/es/v1/Popup/Popup.js +645 -0
  72. package/es/v1/Radio/Radio.js +115 -0
  73. package/es/v1/Responsive/CustomResponsive.js +195 -0
  74. package/es/v1/Responsive/RefWrapper.js +39 -0
  75. package/es/v1/Responsive/ResizeComponent.js +197 -0
  76. package/es/v1/Responsive/ResizeObserver.js +140 -0
  77. package/es/v1/Responsive/Responsive.js +194 -0
  78. package/es/v1/Responsive/index.js +9 -0
  79. package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
  80. package/es/v1/Ribbon/Ribbon.js +33 -0
  81. package/es/v1/RippleEffect/RippleEffect.js +24 -0
  82. package/es/v1/Select/GroupSelect.js +803 -0
  83. package/es/v1/Select/Select.js +969 -0
  84. package/es/v1/Select/SelectWithAvatar.js +344 -0
  85. package/es/v1/Select/SelectWithIcon.js +535 -0
  86. package/es/v1/Select/index.js +4 -0
  87. package/es/v1/Stencils/Stencils.js +26 -0
  88. package/es/v1/Switch/Switch.js +94 -0
  89. package/es/v1/Tab/Tab.js +108 -0
  90. package/es/v1/Tab/TabContent.js +30 -0
  91. package/es/v1/Tab/TabContentWrapper.js +29 -0
  92. package/es/v1/Tab/TabWrapper.js +57 -0
  93. package/es/v1/Tab/Tabs.js +612 -0
  94. package/es/v1/Tab/index.js +5 -0
  95. package/es/v1/Tag/Tag.js +134 -0
  96. package/es/v1/TextBox/TextBox.js +154 -0
  97. package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
  98. package/es/v1/Textarea/Textarea.js +102 -0
  99. package/es/v1/Tooltip/Tooltip.js +518 -0
  100. package/es/v1/Typography/Typography.js +38 -0
  101. package/es/v1/Typography/css/Typography.module.css +376 -0
  102. package/es/v1/Typography/css/cssJSLogic.js +46 -0
  103. package/es/v1/Typography/css/letterSpacingMap.js +12 -0
  104. package/es/v1/Typography/props/defaultProps.js +8 -0
  105. package/es/v1/Typography/props/propTypes.js +24 -0
  106. package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
  107. package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
  108. package/es/v1/semantic/Button/Button.js +53 -0
  109. package/es/v1/semantic/index.js +1 -0
  110. package/lib/AppContainer/AppContainer.js +5 -0
  111. package/lib/v1/Accordion/Accordion.js +96 -0
  112. package/lib/v1/Accordion/AccordionItem.js +68 -0
  113. package/lib/v1/Accordion/index.js +23 -0
  114. package/lib/v1/Animation/Animation.js +143 -0
  115. package/lib/v1/AppContainer/AppContainer.js +209 -0
  116. package/lib/v1/Avatar/Avatar.js +246 -0
  117. package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
  118. package/lib/v1/Button/Button.js +82 -0
  119. package/lib/v1/Buttongroup/Buttongroup.js +44 -0
  120. package/lib/v1/Card/Card.js +365 -0
  121. package/lib/v1/CheckBox/CheckBox.js +166 -0
  122. package/lib/v1/DateTime/CalendarView.js +285 -0
  123. package/lib/v1/DateTime/DateTime.js +872 -0
  124. package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
  125. package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
  126. package/lib/v1/DateTime/DateWidget.js +1125 -0
  127. package/lib/v1/DateTime/DaysRow.js +80 -0
  128. package/lib/v1/DateTime/Time.js +254 -0
  129. package/lib/v1/DateTime/YearView.js +325 -0
  130. package/lib/v1/DateTime/index.js +15 -0
  131. package/lib/v1/DropBox/DropBox.js +119 -0
  132. package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
  133. package/lib/v1/DropDown/DropDown.js +170 -0
  134. package/lib/v1/DropDown/DropDownHeading.js +93 -0
  135. package/lib/v1/DropDown/DropDownItem.js +127 -0
  136. package/lib/v1/DropDown/DropDownSearch.js +113 -0
  137. package/lib/v1/DropDown/DropDownSeparator.js +64 -0
  138. package/lib/v1/Heading/Heading.js +49 -0
  139. package/lib/v1/Label/Label.js +51 -0
  140. package/lib/v1/Layout/Box.js +128 -0
  141. package/lib/v1/Layout/Container.js +145 -0
  142. package/lib/v1/Layout/index.js +23 -0
  143. package/lib/v1/ListItem/ListContainer.js +120 -0
  144. package/lib/v1/ListItem/ListItem.js +138 -0
  145. package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
  146. package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
  147. package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
  148. package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
  149. package/lib/v1/ListItem/index.js +55 -0
  150. package/lib/v1/Modal/Modal.js +212 -0
  151. package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
  152. package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
  153. package/lib/v1/MultiSelect/EmptyState.js +112 -0
  154. package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
  155. package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
  156. package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
  157. package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
  158. package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
  159. package/lib/v1/MultiSelect/Suggestions.js +195 -0
  160. package/lib/v1/MultiSelect/index.js +39 -0
  161. package/lib/v1/PopOver/PopOver.js +293 -0
  162. package/lib/v1/Popup/Popup.js +715 -0
  163. package/lib/v1/Radio/Radio.js +126 -0
  164. package/lib/v1/Responsive/CustomResponsive.js +242 -0
  165. package/lib/v1/Responsive/RefWrapper.js +57 -0
  166. package/lib/v1/Responsive/ResizeComponent.js +268 -0
  167. package/lib/v1/Responsive/ResizeObserver.js +168 -0
  168. package/lib/v1/Responsive/Responsive.js +274 -0
  169. package/lib/v1/Responsive/index.js +55 -0
  170. package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
  171. package/lib/v1/Ribbon/Ribbon.js +44 -0
  172. package/lib/v1/RippleEffect/RippleEffect.js +39 -0
  173. package/lib/v1/Select/GroupSelect.js +877 -0
  174. package/lib/v1/Select/Select.js +1013 -0
  175. package/lib/v1/Select/SelectWithAvatar.js +394 -0
  176. package/lib/v1/Select/SelectWithIcon.js +597 -0
  177. package/lib/v1/Select/index.js +39 -0
  178. package/lib/v1/Stencils/Stencils.js +43 -0
  179. package/lib/v1/Switch/Switch.js +108 -0
  180. package/lib/v1/Tab/Tab.js +132 -0
  181. package/lib/v1/Tab/TabContent.js +42 -0
  182. package/lib/v1/Tab/TabContentWrapper.js +42 -0
  183. package/lib/v1/Tab/TabWrapper.js +89 -0
  184. package/lib/v1/Tab/Tabs.js +680 -0
  185. package/lib/v1/Tab/index.js +47 -0
  186. package/lib/v1/Tag/Tag.js +154 -0
  187. package/lib/v1/TextBox/TextBox.js +168 -0
  188. package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
  189. package/lib/v1/Textarea/Textarea.js +118 -0
  190. package/lib/v1/Tooltip/Tooltip.js +586 -0
  191. package/lib/v1/Typography/Typography.js +56 -0
  192. package/lib/v1/Typography/css/Typography.module.css +376 -0
  193. package/lib/v1/Typography/css/cssJSLogic.js +41 -0
  194. package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
  195. package/lib/v1/Typography/props/defaultProps.js +15 -0
  196. package/lib/v1/Typography/props/propTypes.js +35 -0
  197. package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
  198. package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
  199. package/lib/v1/semantic/Button/Button.js +63 -0
  200. package/lib/v1/semantic/index.js +15 -0
  201. package/package.json +1 -1
  202. package/result.json +1 -1
@@ -0,0 +1,1079 @@
1
+ import React from 'react';
2
+ import { AdvancedGroupMultiSelect_propTypes } from '../../MultiSelect/props/propTypes';
3
+ import { AdvancedGroupMultiSelect_defaultProps } from '../../MultiSelect/props/defaultProps';
4
+ /**** Components ****/
5
+
6
+ import Loader from '@zohodesk/svg/lib/Loader/Loader';
7
+ import Popup from '../Popup/Popup';
8
+ import TextBoxIcon from '../TextBoxIcon/TextBoxIcon';
9
+ import { Container, Box } from '../Layout';
10
+ import DropDownHeading from '../DropDown/DropDownHeading';
11
+ import MultiSelectHeader from './MultiSelectHeader';
12
+ import SelectedOptions from './SelectedOptions';
13
+ import Suggestions from './Suggestions';
14
+ import EmptyState from './EmptyState';
15
+ import Card, { CardContent, CardHeader, CardFooter } from '../Card/Card';
16
+ import { getUniqueId } from '../../Provider/IdProvider';
17
+ import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
18
+ import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
19
+ /**** Icons ****/
20
+
21
+ import { Icon } from '@zohodesk/icons';
22
+ /**** CSS ****/
23
+
24
+ import style from '../../MultiSelect/MultiSelect.module.css';
25
+ /**** Methods ****/
26
+
27
+ import { debounce, scrollTo, getIsEmptyValue, getSearchString } from '../../utils/Common.js';
28
+ import { makeGetMultiSelectSelectedOptions, makeGetGroupSelectOptions, optionIdGrouping, makeGetGroupSelectFilterSuggestions, makeGetOptionIdChange, extractOptionId, makeFormatOptions, makeObjectConcat } from '../../utils/dropDownUtils';
29
+ /* eslint-disable react/forbid-component-props */
30
+
31
+ /* eslint-disable react/no-unused-prop-types */
32
+
33
+ class AdvancedGroupMultiSelect extends React.Component {
34
+ constructor(props) {
35
+ super(props);
36
+ this.getNextAriaId = getUniqueId(this);
37
+ this.objectConcat = makeObjectConcat();
38
+ this.getGroupSelectOptions = makeGetGroupSelectOptions();
39
+ this.getFilterSuggestions = makeGetGroupSelectFilterSuggestions();
40
+ this.getSelectedOptions = makeGetMultiSelectSelectedOptions();
41
+ this.getOptionIdChange = makeGetOptionIdChange();
42
+ this.formatSelectedOptions = makeFormatOptions();
43
+ let {
44
+ searchDebounceTime = 500,
45
+ selectedGroupOptions
46
+ } = props;
47
+ let {
48
+ revampedGroups,
49
+ normalizedAllOptions,
50
+ normalizedFormatOptions,
51
+ allOptionIds,
52
+ groupIds,
53
+ normalizedGroupedOptions: groupDetails
54
+ } = this.handleGetGroupSelectOptions(props);
55
+ let changedSelectedOptionDetails = this.handleSelectedOptionDetailsIdChange(props, {
56
+ groupIds,
57
+ groupDetails
58
+ });
59
+ let {
60
+ normalizedSelectedOptions
61
+ } = this.handleGetSelectedOptions(changedSelectedOptionDetails);
62
+ let {
63
+ formatSelectedOptions,
64
+ selectedOptionIds
65
+ } = this.handleSelectedOptionIdChange(selectedGroupOptions, normalizedFormatOptions, normalizedSelectedOptions);
66
+ this.handleGetGroupSelectOptions = this.handleGetGroupSelectOptions.bind(this);
67
+ this.selectedOptionContainerRef = this.selectedOptionContainerRef.bind(this);
68
+ this.suggestionContainerRef = this.suggestionContainerRef.bind(this);
69
+ this.suggestionItemRef = this.suggestionItemRef.bind(this);
70
+ this.searchInputRef = this.searchInputRef.bind(this);
71
+ this.handleScroll = this.handleScroll.bind(this);
72
+ this.handleScrollFuncCall = debounce(this.handleScrollFuncCall.bind(this), 500);
73
+ this.handleInputCick = this.handleInputCick.bind(this);
74
+ this.togglePopup = this.togglePopup.bind(this);
75
+ this.handleSelectedOptionIdChange = this.handleSelectedOptionIdChange.bind(this);
76
+ this.handleMouseEnter = this.handleMouseEnter.bind(this);
77
+ this.handleSelectOption = this.handleSelectOption.bind(this);
78
+ this.selectedOptionRef = this.selectedOptionRef.bind(this);
79
+ this.handleClickSelectedOption = this.handleClickSelectedOption.bind(this);
80
+ this.handleRemoveOption = this.handleRemoveOption.bind(this);
81
+ this.handleKeyDown = this.handleKeyDown.bind(this);
82
+ this.handleChange = this.handleChange.bind(this);
83
+ this.handleFetchOptions = this.handleFetchOptions.bind(this);
84
+ this.handleSearch = this.handleSearch.bind(this);
85
+ this.handleSearchOptions = debounce(this.handleSearchOptions.bind(this), searchDebounceTime);
86
+ this.handleSelectAll = this.handleSelectAll.bind(this);
87
+ this.handleDeselectAll = this.handleDeselectAll.bind(this);
88
+ this.handleActive = this.handleActive.bind(this);
89
+ this.handleInactive = this.handleInactive.bind(this);
90
+ this.handleInputFocus = this.handleInputFocus.bind(this);
91
+ this.state = {
92
+ isActive: false,
93
+ searchStr: '',
94
+ revampedGroups,
95
+ normalizedAllOptions,
96
+ normalizedFormatOptions,
97
+ allOptionIds,
98
+ selectedOptionIds,
99
+ formatSelectedOptions,
100
+ hoverIndex: 0,
101
+ highLightedSelectOptions: [],
102
+ lastHighLightedSelectOption: '',
103
+ shiftKeyPressHighLighted: 0,
104
+ isActive: false,
105
+ isFetchingOptions: false,
106
+ groupIds,
107
+ groupDetails
108
+ };
109
+ this._isMounted = false;
110
+ }
111
+
112
+ handleGetSelectedOptions(selectedOptionDetails) {
113
+ let {
114
+ normalizedFormatOptions: normalizedSelectedOptions
115
+ } = this.handleFormatSelectedOptions(selectedOptionDetails, this.props);
116
+ return {
117
+ normalizedSelectedOptions
118
+ };
119
+ }
120
+
121
+ handleFormatSelectedOptions(selectedOptionDetails, props) {
122
+ let {
123
+ valueField,
124
+ textField
125
+ } = props;
126
+ return this.formatSelectedOptions({
127
+ options: selectedOptionDetails,
128
+ valueField,
129
+ textField
130
+ });
131
+ }
132
+
133
+ handleSelectedOptionDetailsIdChange(props, state) {
134
+ let {
135
+ groupIds,
136
+ groupDetails
137
+ } = state;
138
+ let {
139
+ selectedOptionDetails = {}
140
+ } = props;
141
+ let newSelectedOptionDetails = [];
142
+ groupIds.forEach(groupId => {
143
+ let {
144
+ valueField,
145
+ textField,
146
+ optionType
147
+ } = groupDetails[groupId];
148
+ let changedDetails = this.getOptionIdChange({
149
+ options: selectedOptionDetails[groupId],
150
+ valueField,
151
+ prefixText: groupId,
152
+ textField,
153
+ optionType
154
+ });
155
+ newSelectedOptionDetails = [...newSelectedOptionDetails, ...changedDetails];
156
+ });
157
+ return newSelectedOptionDetails;
158
+ }
159
+
160
+ selectedOptionRef(el, id) {
161
+ this[`selectedOption_${id}`] = el;
162
+ }
163
+
164
+ suggestionContainerRef(el) {
165
+ this.suggestionContainer = el;
166
+ }
167
+
168
+ selectedOptionContainerRef(el) {
169
+ let {
170
+ getTargetRef
171
+ } = this.props;
172
+ this.selectedOptionContainer = el;
173
+ getTargetRef(el);
174
+ }
175
+
176
+ suggestionItemRef(el, index, id) {
177
+ this[`suggestion_${id}`] = el;
178
+ }
179
+
180
+ searchInputRef(ref) {
181
+ this.searchInput = ref;
182
+ }
183
+
184
+ handleSelectedOptionIdChange(selectedGroupOptions, normalizedFormatOptions, normalizedSelectedOptions) {
185
+ let newSelectedOptions = selectedGroupOptions.map(option => optionIdGrouping(option.id, option.groupId));
186
+ let selectedOptionsLength = newSelectedOptions.length;
187
+ let formatOptions = this.objectConcat({
188
+ obj1: normalizedFormatOptions,
189
+ obj2: normalizedSelectedOptions
190
+ });
191
+ return this.getSelectedOptions({
192
+ selectedOptions: newSelectedOptions,
193
+ normalizedFormatOptions: formatOptions,
194
+ selectedOptionsLength
195
+ });
196
+ }
197
+
198
+ togglePopup(e) {
199
+ let {
200
+ togglePopup,
201
+ defaultDropBoxPosition,
202
+ isReadOnly
203
+ } = this.props;
204
+ !isReadOnly && togglePopup(e, defaultDropBoxPosition ? `${defaultDropBoxPosition}Center` : null);
205
+ }
206
+
207
+ handleFilterSuggestions() {
208
+ let {
209
+ revampedGroups,
210
+ searchStr = '',
211
+ allOptionIds
212
+ } = this.state;
213
+ let {
214
+ needLocalSearch
215
+ } = this.props;
216
+
217
+ if (searchStr && searchStr.trim().length) {
218
+ searchStr = getSearchString(searchStr);
219
+ let {
220
+ suggestionGroups,
221
+ suggestionOptionIds
222
+ } = this.getFilterSuggestions({
223
+ revampedGroups,
224
+ searchStr,
225
+ needSearch: needLocalSearch
226
+ });
227
+ return {
228
+ suggestionGroups,
229
+ suggestionOptionIds
230
+ };
231
+ }
232
+
233
+ return {
234
+ suggestionGroups: revampedGroups,
235
+ suggestionOptionIds: allOptionIds
236
+ };
237
+ }
238
+
239
+ handleGetGroupSelectOptions(props) {
240
+ let {
241
+ groupedOptions = []
242
+ } = props;
243
+ return this.getGroupSelectOptions({
244
+ groupedOptions
245
+ });
246
+ }
247
+
248
+ handleInputCick(e) {
249
+ let {
250
+ highLightedSelectOptions
251
+ } = this.state;
252
+ highLightedSelectOptions.length ? this.setState({
253
+ highLightedSelectOptions: [],
254
+ shiftKeyPressHighLighted: 0,
255
+ lastHighLightedSelectOption: ''
256
+ }) : this.togglePopup(e);
257
+ }
258
+
259
+ handleClickSelectedOption() {
260
+ let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
261
+ let e = arguments.length > 1 ? arguments[1] : undefined;
262
+ let {
263
+ selectedOptionIds
264
+ } = this.state;
265
+ let {
266
+ highLightedSelectOptions,
267
+ lastHighLightedSelectOption
268
+ } = this.state;
269
+ let {
270
+ metaKey,
271
+ ctrlKey,
272
+ shiftKey
273
+ } = e;
274
+
275
+ if (e && shiftKey) {
276
+ //shift+click
277
+ let from = selectedOptionIds.indexOf(lastHighLightedSelectOption) >= 0 ? selectedOptionIds.indexOf(lastHighLightedSelectOption) : 0;
278
+ let to = id && selectedOptionIds.indexOf(id) >= 0 ? selectedOptionIds.indexOf(id) : null;
279
+
280
+ if (to >= 0 && to < from) {
281
+ [to] = [from, from = to];
282
+ }
283
+
284
+ to += 1;
285
+ let newSelectedHighlights = to ? selectedOptionIds.slice(from, to) : [];
286
+ to && this.setState({
287
+ highLightedSelectOptions: newSelectedHighlights,
288
+ lastHighLightedSelectOption: id
289
+ });
290
+ } else if (e && (ctrlKey || metaKey)) {
291
+ //ctrl+click
292
+ let isRemove = highLightedSelectOptions.indexOf(id) >= 0;
293
+ let newSelectedHighlights = [];
294
+
295
+ if (isRemove) {
296
+ lastHighLightedSelectOption = id === lastHighLightedSelectOption ? '' : lastHighLightedSelectOption;
297
+ newSelectedHighlights = highLightedSelectOptions.filter(option => option !== id);
298
+ } else {
299
+ lastHighLightedSelectOption = id;
300
+ newSelectedHighlights = [...highLightedSelectOptions, id];
301
+ }
302
+
303
+ this.setState({
304
+ highLightedSelectOptions: newSelectedHighlights,
305
+ lastHighLightedSelectOption
306
+ });
307
+ } else {
308
+ this.setState({
309
+ highLightedSelectOptions: [id],
310
+ lastHighLightedSelectOption: id
311
+ });
312
+ }
313
+
314
+ this.setState({
315
+ shiftKeyPressHighLighted: 0
316
+ });
317
+ this.searchInput && this.searchInput.focus({
318
+ preventScroll: true
319
+ });
320
+ }
321
+
322
+ handleRemoveOption(options) {
323
+ let newOptions = !getIsEmptyValue(options) && !Array.isArray(options) ? [options] : options;
324
+ let {
325
+ isReadOnly
326
+ } = this.props;
327
+ let {
328
+ selectedOptionIds
329
+ } = this.state;
330
+ let {
331
+ highLightedSelectOptions,
332
+ lastHighLightedSelectOption,
333
+ shiftKeyPressHighLighted
334
+ } = this.state;
335
+
336
+ if (newOptions.length && !isReadOnly) {
337
+ let newSelectedOptions = selectedOptionIds.filter(option => newOptions.indexOf(option) === -1);
338
+ let newHighLightedSelectOptions = highLightedSelectOptions.filter(option => newSelectedOptions.indexOf(option) >= 0);
339
+ let isHighlightedRemoved = false;
340
+ let newOptionsLen = newOptions.length;
341
+
342
+ for (let i = 0; i < newOptionsLen; i++) {
343
+ let removedOption = newOptions[i];
344
+
345
+ if (highLightedSelectOptions.indexOf(removedOption) >= 0) {
346
+ isHighlightedRemoved = true;
347
+ break;
348
+ }
349
+ }
350
+
351
+ this.setState({
352
+ lastHighLightedSelectOption: newSelectedOptions.indexOf(lastHighLightedSelectOption) >= 0 && !isHighlightedRemoved ? lastHighLightedSelectOption : '',
353
+ highLightedSelectOptions: isHighlightedRemoved ? [] : newHighLightedSelectOptions,
354
+ shiftKeyPressHighLighted: isHighlightedRemoved ? 0 : shiftKeyPressHighLighted
355
+ });
356
+ this.handleChange(newSelectedOptions);
357
+ }
358
+
359
+ this.searchInput && this.searchInput.focus({
360
+ preventScroll: true
361
+ });
362
+ }
363
+
364
+ handleKeyDown(e) {
365
+ let {
366
+ keyCode,
367
+ ctrlKey,
368
+ metaKey,
369
+ shiftKey
370
+ } = e;
371
+ let suggestions = [];
372
+ let {
373
+ hoverIndex,
374
+ searchStr,
375
+ highLightedSelectOptions,
376
+ lastHighLightedSelectOption,
377
+ shiftKeyPressHighLighted,
378
+ selectedOptionIds: selectedOptions
379
+ } = this.state;
380
+ let {
381
+ isNextOptions,
382
+ getNextOptions,
383
+ isPopupOpen,
384
+ isPopupOpenOnEnter,
385
+ onKeyDown
386
+ } = this.props;
387
+ let highLightedSelectOptionsLen = highLightedSelectOptions.length;
388
+
389
+ if (isPopupOpen && (keyCode === 38 || keyCode === 40 || keyCode === 13 || keyCode === 27)) {
390
+ let {
391
+ suggestionOptionIds
392
+ } = this.handleFilterSuggestions();
393
+ suggestions = suggestionOptionIds;
394
+ }
395
+
396
+ if (!isPopupOpen && !isPopupOpenOnEnter) {
397
+ onKeyDown && onKeyDown(e);
398
+ }
399
+
400
+ if (!isPopupOpen && keyCode === 40) {
401
+ //down arrow press popup open
402
+ e.preventDefault(); //prevent body scroll
403
+
404
+ this.togglePopup(e);
405
+ }
406
+
407
+ let suggestionsLen = suggestions.length;
408
+
409
+ if (suggestionsLen && isPopupOpen && keyCode === 38) {
410
+ //up arrow
411
+
412
+ /*if (hoverOption === 0) { //disable first to last option higlight
413
+ !isNextOptions && this.setState({ hoverOption: suggestionsLen - 1 });
414
+ }*/
415
+ if (hoverIndex) {
416
+ this.setState({
417
+ hoverIndex: hoverIndex - 1
418
+ });
419
+ }
420
+ } else if (suggestionsLen && isPopupOpen && keyCode === 40) {
421
+ //down arrow
422
+
423
+ /*else if (hoverOption === suggestionsLen - 1 || hoverOption === null) {
424
+ //disable last to first option higlight
425
+ !isNextOptions && this.setState({ hoverOption: 0 });
426
+ }*/
427
+ if (isNextOptions && suggestionsLen >= 5 && hoverIndex === suggestionsLen - 3) {
428
+ getNextOptions && this.handleFetchOptions(getNextOptions, searchStr);
429
+ this.setState({
430
+ hoverIndex: hoverIndex + 1
431
+ });
432
+ } else if (suggestionsLen - 1 > hoverIndex) {
433
+ this.setState({
434
+ hoverIndex: hoverIndex + 1
435
+ });
436
+ }
437
+ } else if (keyCode === 13) {
438
+ //enter key
439
+ let id = suggestions[hoverIndex] || {};
440
+ isPopupOpen && !getIsEmptyValue(id) && this.handleSelectOption(id, null, null, e);
441
+ !isPopupOpen && isPopupOpenOnEnter && this.togglePopup(e);
442
+ } else if (selectedOptions.length && keyCode === 8 && !searchStr.length) {
443
+ //backspace key
444
+ if (highLightedSelectOptionsLen) {
445
+ this.handleRemoveOption(highLightedSelectOptions);
446
+ } else {
447
+ this.handleRemoveOption(selectedOptions.slice(-1)); // this.setState({
448
+ // highLightedSelectOptions: selectedOptions.slice(-1)
449
+ // });
450
+ }
451
+ } else if (selectedOptions && keyCode === 65 && (ctrlKey || metaKey) && !searchStr.length) {
452
+ //ctrl+a key
453
+ this.setState({
454
+ highLightedSelectOptions: selectedOptions,
455
+ shiftKeyPressHighLighted: 0
456
+ });
457
+ } else if (keyCode === 39 && shiftKey && selectedOptions.length && !searchStr.length) {
458
+ //shift+right arrow=39
459
+ let lastHighLightedSelectOptionIndex = lastHighLightedSelectOption && selectedOptions.indexOf(lastHighLightedSelectOption) >= 0 ? selectedOptions.indexOf(lastHighLightedSelectOption) : 0;
460
+ let newShiftKeyPressHighLighted = shiftKeyPressHighLighted ? shiftKeyPressHighLighted : shiftKeyPressHighLighted + 1;
461
+ let newHighLightedSelectOption = lastHighLightedSelectOptionIndex !== null ? selectedOptions[lastHighLightedSelectOptionIndex + newShiftKeyPressHighLighted] : selectedOptions[0];
462
+
463
+ if (!getIsEmptyValue(newHighLightedSelectOption)) {
464
+ let newLastHighLightedSelectOption = lastHighLightedSelectOption ? lastHighLightedSelectOption : selectedOptions[0];
465
+ highLightedSelectOptions = !shiftKeyPressHighLighted ? [newLastHighLightedSelectOption] : highLightedSelectOptions;
466
+ let isRemove = highLightedSelectOptions.indexOf(newHighLightedSelectOption) >= 0 && newHighLightedSelectOption !== lastHighLightedSelectOption ? true : false;
467
+ let newHighLightedSelectOptions = isRemove ? highLightedSelectOptions.filter(option => option !== newHighLightedSelectOption) : [...highLightedSelectOptions, newHighLightedSelectOption];
468
+ this.setState({
469
+ highLightedSelectOptions: newHighLightedSelectOptions,
470
+ shiftKeyPressHighLighted: newShiftKeyPressHighLighted + 1,
471
+ lastHighLightedSelectOption: newLastHighLightedSelectOption
472
+ });
473
+ }
474
+ } else if (keyCode === 37 && shiftKey && selectedOptions.length && !searchStr.length) {
475
+ // shift+left arrow=37
476
+ let lastHighLightedSelectOptionIndex = lastHighLightedSelectOption ? selectedOptions.indexOf(lastHighLightedSelectOption) : selectedOptions.length - 1;
477
+ let newShiftKeyPressHighLighted = shiftKeyPressHighLighted !== 1 ? shiftKeyPressHighLighted : shiftKeyPressHighLighted - 1;
478
+ let newHighLightedSelectOption = selectedOptions[lastHighLightedSelectOptionIndex + newShiftKeyPressHighLighted - 1];
479
+
480
+ if (!getIsEmptyValue(newHighLightedSelectOption)) {
481
+ let newLastHighLightedSelectOption = lastHighLightedSelectOption ? lastHighLightedSelectOption : selectedOptions.slice(-1)[0];
482
+ highLightedSelectOptions = !shiftKeyPressHighLighted ? [newLastHighLightedSelectOption] : highLightedSelectOptions;
483
+ let isRemove = highLightedSelectOptions.indexOf(newHighLightedSelectOption) >= 0 && newHighLightedSelectOption !== lastHighLightedSelectOption ? true : false;
484
+ let newHighLightedSelectOptions = isRemove ? highLightedSelectOptions.filter(option => option !== newHighLightedSelectOption) : [...highLightedSelectOptions, newHighLightedSelectOption];
485
+ this.setState({
486
+ highLightedSelectOptions: newHighLightedSelectOptions,
487
+ shiftKeyPressHighLighted: newShiftKeyPressHighLighted - 1,
488
+ lastHighLightedSelectOption: newLastHighLightedSelectOption
489
+ });
490
+ }
491
+ } else if ((keyCode === 39 || keyCode === 37) && selectedOptions.length && !searchStr.length) {
492
+ let isRightArrow = keyCode === 39 ? true : false; // let isLefttArrow = keyCode === 37 ? true : false;
493
+
494
+ if (highLightedSelectOptions.length) {
495
+ let [lastHighLightedSelectOption] = highLightedSelectOptions.slice(-1);
496
+ let lastHighLightedSelectOptionIndex = selectedOptions.indexOf(lastHighLightedSelectOption);
497
+ let newLastHighLightedSelectOptionIndex = isRightArrow ? lastHighLightedSelectOptionIndex === selectedOptions.length - 1 ? lastHighLightedSelectOptionIndex : lastHighLightedSelectOptionIndex + 1 : lastHighLightedSelectOptionIndex - 1;
498
+ let newLastHighLightedSelectOption = selectedOptions[newLastHighLightedSelectOptionIndex];
499
+ let isEmptyHighlighted = isRightArrow && highLightedSelectOptions.length === 1 && selectedOptions.slice(-1)[0] === lastHighLightedSelectOption ? true : false;
500
+
501
+ if (!getIsEmptyValue(newLastHighLightedSelectOption)) {
502
+ this.setState({
503
+ lastHighLightedSelectOption: isEmptyHighlighted ? '' : newLastHighLightedSelectOption,
504
+ highLightedSelectOptions: isEmptyHighlighted ? [] : [newLastHighLightedSelectOption],
505
+ shiftKeyPressHighLighted: 0
506
+ });
507
+ }
508
+ } else {
509
+ let [newLastHighLightedSelectOption] = isRightArrow ? selectedOptions : selectedOptions.slice(-1);
510
+ this.setState({
511
+ lastHighLightedSelectOption: newLastHighLightedSelectOption,
512
+ highLightedSelectOptions: [newLastHighLightedSelectOption],
513
+ shiftKeyPressHighLighted: 0
514
+ });
515
+ }
516
+ } // eslint-disable-next-line
517
+ else if (keyCode === 27) {// this.handlePopupClose(e);
518
+ }
519
+ }
520
+
521
+ handleMouseEnter(id, val, hoverOptionIndex, e) {
522
+ e && e.preventDefault();
523
+ let {
524
+ hoverIndex,
525
+ allOptionIds
526
+ } = this.state;
527
+ let newHoverIndex = allOptionIds.indexOf(id);
528
+ hoverIndex !== newHoverIndex && this.setState({
529
+ hoverIndex: newHoverIndex
530
+ });
531
+ }
532
+
533
+ handleFetchOptions() {
534
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
535
+ args[_key] = arguments[_key];
536
+ }
537
+
538
+ let [APICall, searchStr] = args;
539
+ let {
540
+ isFetchingOptions
541
+ } = this.state;
542
+ let {
543
+ _isMounted
544
+ } = this;
545
+
546
+ if (!isFetchingOptions && APICall) {
547
+ this.setState({
548
+ isFetchingOptions: true
549
+ });
550
+
551
+ try {
552
+ return APICall(searchStr).then(() => {
553
+ _isMounted && this.setState({
554
+ isFetchingOptions: false
555
+ });
556
+ }, () => {
557
+ _isMounted && this.setState({
558
+ isFetchingOptions: false
559
+ });
560
+ });
561
+ } catch (e) {
562
+ _isMounted && this.setState({
563
+ isFetchingOptions: false
564
+ });
565
+ }
566
+ }
567
+ }
568
+
569
+ handleSearchOptions() {
570
+ let {
571
+ onSearch
572
+ } = this.props;
573
+ let {
574
+ searchStr
575
+ } = this.state;
576
+ searchStr && this.handleFetchOptions(onSearch, searchStr);
577
+ }
578
+
579
+ handleSearch(value, e) {
580
+ let {
581
+ onSearch,
582
+ isPopupOpen
583
+ } = this.props;
584
+ !isPopupOpen && e && this.togglePopup(e);
585
+ let {
586
+ searchStr = ''
587
+ } = this.state;
588
+ let searchStrRegex = getSearchString(searchStr);
589
+ let valueStrRegex = getSearchString(value);
590
+ let isSearch = searchStrRegex !== valueStrRegex ? true : false;
591
+ this.setState({
592
+ searchStr: value
593
+ }, () => {
594
+ if (!value) {
595
+ onSearch && onSearch('');
596
+ } else if (isSearch && onSearch) {
597
+ this.handleSearchOptions();
598
+ }
599
+ });
600
+ }
601
+
602
+ handleScroll(e) {
603
+ let {
604
+ isNextOptions
605
+ } = this.props;
606
+
607
+ if (e.target.scrollTop + e.target.offsetHeight > e.target.scrollHeight - 1 && isNextOptions) {
608
+ this.handleScrollFuncCall();
609
+ }
610
+ }
611
+
612
+ handleScrollFuncCall() {
613
+ let {
614
+ getNextOptions
615
+ } = this.props;
616
+ let {
617
+ searchStr
618
+ } = this.state;
619
+ getNextOptions && getNextOptions(searchStr);
620
+ }
621
+
622
+ handleSelectAll(e) {
623
+ e && e.preventDefault();
624
+ let {
625
+ suggestionOptionIds
626
+ } = this.handleFilterSuggestions();
627
+ let {
628
+ selectedOptionIds
629
+ } = this.state;
630
+ let newSelectedOptions = suggestionOptionIds.filter(id => selectedOptionIds.indexOf(id) === -1);
631
+ this.handleChange([...selectedOptionIds, ...newSelectedOptions]);
632
+ }
633
+
634
+ handleDeselectAll(e) {
635
+ e && e.preventDefault();
636
+ let {
637
+ highLightedSelectOptions
638
+ } = this.state;
639
+
640
+ if (highLightedSelectOptions.length) {
641
+ this.setState({
642
+ highLightedSelectOptions: [],
643
+ lastHighLightedSelectOption: ''
644
+ });
645
+ }
646
+
647
+ this.handleChange([]);
648
+ }
649
+
650
+ handleChange() {
651
+ let selectedOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
652
+ let e = arguments.length > 1 ? arguments[1] : undefined;
653
+ let {
654
+ onChange,
655
+ needToCloseOnSelect,
656
+ togglePopup,
657
+ isSearchClearOnSelect
658
+ } = this.props;
659
+ let {
660
+ searchStr
661
+ } = this.state;
662
+ let newSelectedOptions = selectedOptions.map(option => extractOptionId(option));
663
+ onChange([...newSelectedOptions]);
664
+
665
+ if (searchStr.trim() != '' && isSearchClearOnSelect) {
666
+ this.handleSearch('');
667
+ }
668
+
669
+ this.searchInput && this.searchInput.focus({
670
+ preventScroll: true
671
+ });
672
+
673
+ if (needToCloseOnSelect) {
674
+ e && togglePopup(e);
675
+ }
676
+ }
677
+
678
+ handleSelectOption(id, val, index, e) {
679
+ e && e.preventDefault();
680
+ let {
681
+ selectedOptionIds
682
+ } = this.state;
683
+
684
+ if (selectedOptionIds.indexOf(id) === -1) {
685
+ this.handleChange([...selectedOptionIds, id], e);
686
+ } else {
687
+ this.handleRemoveOption(id);
688
+ }
689
+ }
690
+
691
+ handleActive(e) {
692
+ let {
693
+ searchStr,
694
+ isActive
695
+ } = this.state;
696
+
697
+ if (!isActive) {
698
+ this.setState({
699
+ isActive: true
700
+ });
701
+ }
702
+
703
+ let {
704
+ target
705
+ } = e || {};
706
+ target && target.setSelectionRange(target, 0);
707
+ let {
708
+ onFocus
709
+ } = this.props;
710
+ onFocus && onFocus(searchStr);
711
+ }
712
+
713
+ handleInactive() {
714
+ let {
715
+ isActive
716
+ } = this.state;
717
+
718
+ if (isActive) {
719
+ this.setState({
720
+ isActive: false
721
+ });
722
+ }
723
+ }
724
+
725
+ handleInputFocus() {
726
+ let {
727
+ isDisabled,
728
+ isReadOnly
729
+ } = this.props;
730
+ this.searchInput && !isDisabled && !isReadOnly && this.searchInput.focus({
731
+ preventScroll: true
732
+ });
733
+ }
734
+
735
+ componentDidMount() {
736
+ this._isMounted = true;
737
+ }
738
+
739
+ componentWillUnmount() {
740
+ this._isMounted = false;
741
+ }
742
+
743
+ componentDidUpdate(prevProps) {
744
+ let {
745
+ groupedOptions,
746
+ selectedGroupOptions,
747
+ isPopupOpen,
748
+ selectedOptionDetails,
749
+ searchStr,
750
+ notifyPopupToggle
751
+ } = this.props;
752
+ let {
753
+ normalizedFormatOptions,
754
+ hoverIndex
755
+ } = this.state;
756
+ let newOptionIds = this.state.allOptionIds;
757
+
758
+ if (prevProps.groupedOptions != groupedOptions) {
759
+ let {
760
+ revampedGroups,
761
+ normalizedAllOptions,
762
+ normalizedFormatOptions: formatNoramlizer,
763
+ allOptionIds,
764
+ groupIds,
765
+ normalizedGroupedOptions
766
+ } = this.handleGetGroupSelectOptions(this.props);
767
+ normalizedFormatOptions = formatNoramlizer;
768
+ newOptionIds = allOptionIds;
769
+ this.setState({
770
+ revampedGroups,
771
+ normalizedAllOptions,
772
+ normalizedFormatOptions: formatNoramlizer,
773
+ allOptionIds,
774
+ groupIds,
775
+ groupDetails: normalizedGroupedOptions
776
+ });
777
+ }
778
+
779
+ if (prevProps.selectedOptionDetails != selectedOptionDetails || prevProps.selectedGroupOptions != selectedGroupOptions) {
780
+ let {
781
+ groupDetails,
782
+ groupIds
783
+ } = this.state;
784
+ let changedSelectedOptionDetails = this.handleSelectedOptionDetailsIdChange(this.props, {
785
+ groupIds,
786
+ groupDetails
787
+ });
788
+ let {
789
+ normalizedSelectedOptions
790
+ } = this.handleGetSelectedOptions(changedSelectedOptionDetails);
791
+ let {
792
+ formatSelectedOptions,
793
+ selectedOptionIds
794
+ } = this.handleSelectedOptionIdChange(selectedGroupOptions, normalizedFormatOptions, normalizedSelectedOptions);
795
+ this.setState({
796
+ formatSelectedOptions,
797
+ selectedOptionIds
798
+ });
799
+ }
800
+
801
+ let hoverId = getIsEmptyValue(newOptionIds[hoverIndex]) ? '' : newOptionIds[hoverIndex];
802
+ let selSuggestion = this[`suggestion_${hoverId}`];
803
+ isPopupOpen && scrollTo(this.suggestionContainer, selSuggestion); //When suggestions length less than 5, getNextOptions function call
804
+
805
+ let {
806
+ isNextOptions,
807
+ getNextOptions,
808
+ needLocalSearch
809
+ } = this.props;
810
+ let {
811
+ suggestionOptionIds: suggestions
812
+ } = this.handleFilterSuggestions();
813
+ let suggestionsLen = suggestions.length;
814
+
815
+ if (isPopupOpen && suggestionsLen <= 5 && isNextOptions && getNextOptions && !needLocalSearch) {
816
+ this.handleFetchOptions(getNextOptions, searchStr);
817
+ }
818
+
819
+ if (prevProps.isPopupOpen != isPopupOpen) {
820
+ notifyPopupToggle && notifyPopupToggle(isPopupOpen);
821
+ }
822
+ }
823
+
824
+ responsiveFunc(_ref) {
825
+ let {
826
+ mediaQueryOR
827
+ } = _ref;
828
+ return {
829
+ tabletMode: mediaQueryOR([{
830
+ maxWidth: 700
831
+ }])
832
+ };
833
+ }
834
+
835
+ render() {
836
+ let {
837
+ size,
838
+ textBoxSize,
839
+ selectedGroupOptions,
840
+ placeHolder,
841
+ dataId,
842
+ dataSelectorId,
843
+ isReadOnly,
844
+ isDisabled,
845
+ isPopupOpen,
846
+ isPopupReady,
847
+ defaultDropBoxPosition,
848
+ removeClose,
849
+ needResponsive,
850
+ animationStyle,
851
+ needSelectAll,
852
+ selectAllText,
853
+ dropBoxSize,
854
+ position,
855
+ getContainerRef,
856
+ emptyMessage,
857
+ searchEmptyMessage,
858
+ title,
859
+ variant,
860
+ children,
861
+ listItemSize,
862
+ isDataLoaded,
863
+ needBorder,
864
+ isNextOptions,
865
+ getFooter,
866
+ customClass,
867
+ borderColor,
868
+ isPadding,
869
+ htmlId,
870
+ i18nKeys,
871
+ a11y,
872
+ palette,
873
+ needEffect,
874
+ autoComplete
875
+ } = this.props;
876
+ let {
877
+ clearText = 'Clear all'
878
+ } = i18nKeys;
879
+ let {
880
+ clearLabel = 'Clear all'
881
+ } = a11y;
882
+ i18nKeys = Object.assign({}, i18nKeys, {
883
+ emptyText: i18nKeys.emptyText || emptyMessage,
884
+ searchEmptyText: i18nKeys.searchEmptyText || searchEmptyMessage
885
+ });
886
+ let {
887
+ isActive,
888
+ searchStr,
889
+ revampedGroups = [],
890
+ selectedOptionIds,
891
+ formatSelectedOptions,
892
+ hoverIndex,
893
+ highLightedSelectOptions,
894
+ isFetchingOptions
895
+ } = this.state;
896
+ let {
897
+ suggestionGroups,
898
+ suggestionOptionIds
899
+ } = this.handleFilterSuggestions();
900
+ let setAriaId = this.getNextAriaId();
901
+ let ariaErrorId = this.getNextAriaId();
902
+ const isShowClearIcon = !isReadOnly && !isDisabled && selectedGroupOptions.length > 1;
903
+ return /*#__PURE__*/React.createElement("div", {
904
+ className: `${style.wrapper} ${isDisabled ? style.disabled : ''} ${needEffect && !(isDisabled || isReadOnly) ? style.effect : ''}`,
905
+ "data-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
906
+ "data-test-id": `${isDisabled ? `${dataId}_disabled` : isReadOnly ? `${dataId}_readOnly` : dataId}`,
907
+ "data-title": isDisabled ? title : null,
908
+ onClick: this.handleInputFocus,
909
+ "data-selector-id": dataSelectorId
910
+ }, children ? /*#__PURE__*/React.createElement(Container, {
911
+ align: "vertical",
912
+ alignBox: "row",
913
+ onClick: this.togglePopup,
914
+ className: customClass
915
+ }, children) : /*#__PURE__*/React.createElement(Container, {
916
+ align: "vertical",
917
+ alignBox: "row",
918
+ className: `${style.container} ${style[size]} ${isActive && needBorder ? style.active : ''} ${needBorder ? style.hasBorder : ''} ${style[`borderColor_${borderColor}`]} ${customClass}`,
919
+ eleRef: this.selectedOptionContainerRef,
920
+ wrap: "wrap"
921
+ }, /*#__PURE__*/React.createElement(SelectedOptions, {
922
+ selectedOptions: formatSelectedOptions,
923
+ highLightedSelectOptions: highLightedSelectOptions,
924
+ isReadOnly: isReadOnly,
925
+ getRef: this.selectedOptionRef,
926
+ onRemove: this.handleRemoveOption,
927
+ onSelect: this.handleClickSelectedOption,
928
+ isGroupSelect: true
929
+ }), /*#__PURE__*/React.createElement(Box, {
930
+ flexible: true,
931
+ className: style.wrapper,
932
+ adjust: true,
933
+ shrink: true
934
+ }, /*#__PURE__*/React.createElement("span", {
935
+ className: ` ${style.custmSpan} ${textBoxSize === 'xmedium' ? style.custmSpanXmedium : style.custmSpanMedium} ${isShowClearIcon ? style.clearIconSpace : ''}
936
+ `
937
+ }, searchStr), /*#__PURE__*/React.createElement(TextBoxIcon, {
938
+ isDisabled: isDisabled,
939
+ inputRef: this.searchInputRef,
940
+ needBorder: false,
941
+ onBlur: this.handleInactive,
942
+ onChange: this.handleSearch,
943
+ onClick: this.handleInputCick,
944
+ onFocus: this.handleActive,
945
+ onKeyDown: this.handleKeyDown,
946
+ placeHolder: selectedGroupOptions.length >= 1 ? '' : placeHolder,
947
+ size: textBoxSize,
948
+ value: searchStr,
949
+ variant: variant,
950
+ dataId: `${dataId}_textBox`,
951
+ isReadOnly: isReadOnly,
952
+ customClass: {
953
+ customTBoxWrap: style.custmInputWrapper
954
+ },
955
+ tabindex: isDisabled && '-1',
956
+ htmlId: htmlId,
957
+ a11y: {
958
+ ariaExpanded: !isReadOnly && !isDisabled && isPopupOpen ? true : false,
959
+ ariaHaspopup: true,
960
+ role: 'combobox',
961
+ ariaControls: setAriaId,
962
+ ariaOwns: setAriaId,
963
+ ariaDescribedby: ariaErrorId
964
+ },
965
+ autoComplete: autoComplete
966
+ }, isShowClearIcon ? /*#__PURE__*/React.createElement(Container, {
967
+ alignBox: "row",
968
+ align: "vertical"
969
+ }, /*#__PURE__*/React.createElement(Box, {
970
+ className: `${style.delete} ${style[`${palette}Delete`]}`,
971
+ dataId: `${dataId}_clearIcon`,
972
+ "data-title": clearText,
973
+ onClick: this.handleDeselectAll,
974
+ tagName: "button",
975
+ "aria-label": clearLabel
976
+ }, /*#__PURE__*/React.createElement(Icon, {
977
+ name: "ZD-delete",
978
+ size: "15"
979
+ }))) : null))), !isReadOnly && !isDisabled && isPopupOpen ? /*#__PURE__*/React.createElement(ResponsiveReceiver, {
980
+ query: this.responsiveFunc,
981
+ responsiveId: "Helmet"
982
+ }, _ref2 => {
983
+ let {
984
+ tabletMode
985
+ } = _ref2;
986
+ return /*#__PURE__*/React.createElement(ResponsiveDropBox, {
987
+ animationStyle: animationStyle,
988
+ boxPosition: position || `${defaultDropBoxPosition}Center`,
989
+ getRef: getContainerRef,
990
+ isActive: isPopupReady,
991
+ isAnimate: true,
992
+ isArrow: false,
993
+ onClick: removeClose,
994
+ needResponsive: needResponsive,
995
+ isPadding: isPadding,
996
+ isBoxPaddingNeed: !needSelectAll,
997
+ htmlId: setAriaId,
998
+ a11y: {
999
+ role: 'listbox',
1000
+ ariaMultiselectable: true
1001
+ },
1002
+ alignBox: "row"
1003
+ }, /*#__PURE__*/React.createElement(Box, {
1004
+ flexible: true
1005
+ }, /*#__PURE__*/React.createElement(Card, {
1006
+ customClass: `${style.box} ${style[`${palette}Box`]}`,
1007
+ onScroll: this.handleScroll
1008
+ }, needSelectAll ? /*#__PURE__*/React.createElement(CardHeader, null, /*#__PURE__*/React.createElement(MultiSelectHeader, {
1009
+ onSelect: this.handleSelectAll,
1010
+ selectAllText: selectAllText,
1011
+ suggestions: suggestionOptionIds,
1012
+ dataId: dataId
1013
+ })) : null, isDataLoaded ? /*#__PURE__*/React.createElement(CardContent, {
1014
+ shrink: true,
1015
+ customClass: !tabletMode && dropBoxSize ? style[dropBoxSize] : '',
1016
+ eleRef: this.suggestionContainerRef
1017
+ }, /*#__PURE__*/React.createElement(React.Fragment, {
1018
+ key: 'SuggestonsParent'
1019
+ }, suggestionGroups.length ? suggestionGroups.map(group => {
1020
+ let {
1021
+ options: suggestions = []
1022
+ } = group;
1023
+ let groupId = group.id;
1024
+ let groupName = group.name;
1025
+ let hoverId = suggestionOptionIds[hoverIndex];
1026
+ return /*#__PURE__*/React.createElement(React.Fragment, {
1027
+ key: groupId
1028
+ }, groupName && /*#__PURE__*/React.createElement("div", {
1029
+ className: style.groupTitle
1030
+ }, /*#__PURE__*/React.createElement(DropDownHeading, {
1031
+ text: groupName,
1032
+ a11y: {
1033
+ role: 'heading'
1034
+ }
1035
+ })), /*#__PURE__*/React.createElement(Suggestions, {
1036
+ suggestions: suggestions,
1037
+ selectedOptions: selectedOptionIds,
1038
+ getRef: this.suggestionItemRef,
1039
+ hoverId: hoverId,
1040
+ onClick: this.handleSelectOption,
1041
+ onMouseEnter: this.handleMouseEnter,
1042
+ needTick: true,
1043
+ listItemSize: listItemSize,
1044
+ a11y: {
1045
+ role: 'option'
1046
+ }
1047
+ }));
1048
+ }) : /*#__PURE__*/React.createElement(EmptyState, {
1049
+ options: revampedGroups,
1050
+ searchString: searchStr,
1051
+ suggestions: suggestionGroups,
1052
+ dataId: dataId,
1053
+ isLoading: isFetchingOptions,
1054
+ i18nKeys: i18nKeys,
1055
+ htmlId: ariaErrorId
1056
+ }), isNextOptions && /*#__PURE__*/React.createElement("div", {
1057
+ className: style.loader
1058
+ }, /*#__PURE__*/React.createElement(Loader, null)))) : /*#__PURE__*/React.createElement("div", {
1059
+ className: style.loader
1060
+ }, /*#__PURE__*/React.createElement(Loader, null)), getFooter ? isDataLoaded ? /*#__PURE__*/React.createElement(CardFooter, null, getFooter()) : /*#__PURE__*/React.createElement("div", {
1061
+ className: style.loader
1062
+ }, /*#__PURE__*/React.createElement(Loader, null)) : null)));
1063
+ }) : null);
1064
+ }
1065
+
1066
+ }
1067
+
1068
+ AdvancedGroupMultiSelect.defaultProps = AdvancedGroupMultiSelect_defaultProps;
1069
+ AdvancedGroupMultiSelect.propTypes = AdvancedGroupMultiSelect_propTypes;
1070
+ const AdvancedGroupMultiSelectComponent = Popup(AdvancedGroupMultiSelect);
1071
+ AdvancedGroupMultiSelectComponent.defaultProps = AdvancedGroupMultiSelect.defaultProps;
1072
+ AdvancedGroupMultiSelectComponent.propTypes = AdvancedGroupMultiSelect.propTypes; // if (__DOCS__) {
1073
+ // AdvancedGroupMultiSelect.docs = {
1074
+ // componentGroup: 'Form Elements',
1075
+ // folderName: 'Style Guide'
1076
+ // };
1077
+ // }
1078
+
1079
+ export default AdvancedGroupMultiSelectComponent;