@zohodesk/components 1.2.4 → 1.2.5

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 (200) hide show
  1. package/README.md +4 -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/v1/Accordion/Accordion.js +65 -0
  20. package/es/v1/Accordion/AccordionItem.js +57 -0
  21. package/es/v1/Accordion/index.js +2 -0
  22. package/es/v1/Animation/Animation.js +127 -0
  23. package/es/v1/AppContainer/AppContainer.js +134 -0
  24. package/es/v1/Avatar/Avatar.js +189 -0
  25. package/es/v1/AvatarTeam/AvatarTeam.js +70 -0
  26. package/es/v1/Button/Button.js +68 -0
  27. package/es/v1/Buttongroup/Buttongroup.js +31 -0
  28. package/es/v1/Card/Card.js +271 -0
  29. package/es/v1/CheckBox/CheckBox.js +155 -0
  30. package/es/v1/DateTime/CalendarView.js +218 -0
  31. package/es/v1/DateTime/DateTime.js +783 -0
  32. package/es/v1/DateTime/DateTimePopupFooter.js +47 -0
  33. package/es/v1/DateTime/DateTimePopupHeader.js +105 -0
  34. package/es/v1/DateTime/DateWidget.js +1098 -0
  35. package/es/v1/DateTime/DaysRow.js +31 -0
  36. package/es/v1/DateTime/Time.js +166 -0
  37. package/es/v1/DateTime/YearView.js +264 -0
  38. package/es/v1/DateTime/index.js +1 -0
  39. package/es/v1/DropBox/DropBox.js +91 -0
  40. package/es/v1/DropBox/DropBoxElement/DropBoxElement.js +132 -0
  41. package/es/v1/DropDown/DropDown.js +73 -0
  42. package/es/v1/DropDown/DropDownHeading.js +44 -0
  43. package/es/v1/DropDown/DropDownItem.js +76 -0
  44. package/es/v1/DropDown/DropDownSearch.js +63 -0
  45. package/es/v1/DropDown/DropDownSeparator.js +15 -0
  46. package/es/v1/Heading/Heading.js +32 -0
  47. package/es/v1/Label/Label.js +40 -0
  48. package/es/v1/Layout/Box.js +115 -0
  49. package/es/v1/Layout/Container.js +132 -0
  50. package/es/v1/Layout/index.js +2 -0
  51. package/es/v1/ListItem/ListContainer.js +102 -0
  52. package/es/v1/ListItem/ListItem.js +124 -0
  53. package/es/v1/ListItem/ListItemWithAvatar.js +145 -0
  54. package/es/v1/ListItem/ListItemWithCheckBox.js +104 -0
  55. package/es/v1/ListItem/ListItemWithIcon.js +127 -0
  56. package/es/v1/ListItem/ListItemWithRadio.js +105 -0
  57. package/es/v1/ListItem/index.js +6 -0
  58. package/es/v1/Modal/Modal.js +154 -0
  59. package/es/v1/MultiSelect/AdvancedGroupMultiSelect.js +1079 -0
  60. package/es/v1/MultiSelect/AdvancedMultiSelect.js +568 -0
  61. package/es/v1/MultiSelect/EmptyState.js +64 -0
  62. package/es/v1/MultiSelect/MobileHeader/MobileHeader.js +50 -0
  63. package/es/v1/MultiSelect/MultiSelect.js +1120 -0
  64. package/es/v1/MultiSelect/MultiSelectHeader.js +32 -0
  65. package/es/v1/MultiSelect/MultiSelectWithAvatar.js +216 -0
  66. package/es/v1/MultiSelect/SelectedOptions.js +82 -0
  67. package/es/v1/MultiSelect/Suggestions.js +142 -0
  68. package/es/v1/MultiSelect/index.js +4 -0
  69. package/es/v1/PopOver/PopOver.js +211 -0
  70. package/es/v1/Popup/Popup.js +645 -0
  71. package/es/v1/Radio/Radio.js +115 -0
  72. package/es/v1/Responsive/CustomResponsive.js +195 -0
  73. package/es/v1/Responsive/RefWrapper.js +39 -0
  74. package/es/v1/Responsive/ResizeComponent.js +197 -0
  75. package/es/v1/Responsive/ResizeObserver.js +140 -0
  76. package/es/v1/Responsive/Responsive.js +194 -0
  77. package/es/v1/Responsive/index.js +9 -0
  78. package/es/v1/ResponsiveDropBox/ResponsiveDropBox.js +58 -0
  79. package/es/v1/Ribbon/Ribbon.js +33 -0
  80. package/es/v1/RippleEffect/RippleEffect.js +24 -0
  81. package/es/v1/Select/GroupSelect.js +803 -0
  82. package/es/v1/Select/Select.js +969 -0
  83. package/es/v1/Select/SelectWithAvatar.js +344 -0
  84. package/es/v1/Select/SelectWithIcon.js +535 -0
  85. package/es/v1/Select/index.js +4 -0
  86. package/es/v1/Stencils/Stencils.js +26 -0
  87. package/es/v1/Switch/Switch.js +94 -0
  88. package/es/v1/Tab/Tab.js +108 -0
  89. package/es/v1/Tab/TabContent.js +30 -0
  90. package/es/v1/Tab/TabContentWrapper.js +29 -0
  91. package/es/v1/Tab/TabWrapper.js +57 -0
  92. package/es/v1/Tab/Tabs.js +612 -0
  93. package/es/v1/Tab/index.js +5 -0
  94. package/es/v1/Tag/Tag.js +134 -0
  95. package/es/v1/TextBox/TextBox.js +154 -0
  96. package/es/v1/TextBoxIcon/TextBoxIcon.js +158 -0
  97. package/es/v1/Textarea/Textarea.js +102 -0
  98. package/es/v1/Tooltip/Tooltip.js +518 -0
  99. package/es/v1/Typography/Typography.js +38 -0
  100. package/es/v1/Typography/css/Typography.module.css +376 -0
  101. package/es/v1/Typography/css/cssJSLogic.js +46 -0
  102. package/es/v1/Typography/css/letterSpacingMap.js +12 -0
  103. package/es/v1/Typography/props/defaultProps.js +8 -0
  104. package/es/v1/Typography/props/propTypes.js +24 -0
  105. package/es/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +69 -0
  106. package/es/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +100 -0
  107. package/es/v1/semantic/Button/Button.js +53 -0
  108. package/es/v1/semantic/index.js +1 -0
  109. package/lib/v1/Accordion/Accordion.js +96 -0
  110. package/lib/v1/Accordion/AccordionItem.js +68 -0
  111. package/lib/v1/Accordion/index.js +23 -0
  112. package/lib/v1/Animation/Animation.js +143 -0
  113. package/lib/v1/AppContainer/AppContainer.js +204 -0
  114. package/lib/v1/Avatar/Avatar.js +246 -0
  115. package/lib/v1/AvatarTeam/AvatarTeam.js +81 -0
  116. package/lib/v1/Button/Button.js +82 -0
  117. package/lib/v1/Buttongroup/Buttongroup.js +44 -0
  118. package/lib/v1/Card/Card.js +365 -0
  119. package/lib/v1/CheckBox/CheckBox.js +166 -0
  120. package/lib/v1/DateTime/CalendarView.js +285 -0
  121. package/lib/v1/DateTime/DateTime.js +872 -0
  122. package/lib/v1/DateTime/DateTimePopupFooter.js +96 -0
  123. package/lib/v1/DateTime/DateTimePopupHeader.js +166 -0
  124. package/lib/v1/DateTime/DateWidget.js +1125 -0
  125. package/lib/v1/DateTime/DaysRow.js +80 -0
  126. package/lib/v1/DateTime/Time.js +254 -0
  127. package/lib/v1/DateTime/YearView.js +325 -0
  128. package/lib/v1/DateTime/index.js +15 -0
  129. package/lib/v1/DropBox/DropBox.js +119 -0
  130. package/lib/v1/DropBox/DropBoxElement/DropBoxElement.js +145 -0
  131. package/lib/v1/DropDown/DropDown.js +170 -0
  132. package/lib/v1/DropDown/DropDownHeading.js +93 -0
  133. package/lib/v1/DropDown/DropDownItem.js +127 -0
  134. package/lib/v1/DropDown/DropDownSearch.js +113 -0
  135. package/lib/v1/DropDown/DropDownSeparator.js +64 -0
  136. package/lib/v1/Heading/Heading.js +49 -0
  137. package/lib/v1/Label/Label.js +51 -0
  138. package/lib/v1/Layout/Box.js +128 -0
  139. package/lib/v1/Layout/Container.js +145 -0
  140. package/lib/v1/Layout/index.js +23 -0
  141. package/lib/v1/ListItem/ListContainer.js +120 -0
  142. package/lib/v1/ListItem/ListItem.js +138 -0
  143. package/lib/v1/ListItem/ListItemWithAvatar.js +162 -0
  144. package/lib/v1/ListItem/ListItemWithCheckBox.js +125 -0
  145. package/lib/v1/ListItem/ListItemWithIcon.js +143 -0
  146. package/lib/v1/ListItem/ListItemWithRadio.js +126 -0
  147. package/lib/v1/ListItem/index.js +55 -0
  148. package/lib/v1/Modal/Modal.js +212 -0
  149. package/lib/v1/MultiSelect/AdvancedGroupMultiSelect.js +1167 -0
  150. package/lib/v1/MultiSelect/AdvancedMultiSelect.js +634 -0
  151. package/lib/v1/MultiSelect/EmptyState.js +112 -0
  152. package/lib/v1/MultiSelect/MobileHeader/MobileHeader.js +62 -0
  153. package/lib/v1/MultiSelect/MultiSelect.js +1201 -0
  154. package/lib/v1/MultiSelect/MultiSelectHeader.js +78 -0
  155. package/lib/v1/MultiSelect/MultiSelectWithAvatar.js +270 -0
  156. package/lib/v1/MultiSelect/SelectedOptions.js +126 -0
  157. package/lib/v1/MultiSelect/Suggestions.js +195 -0
  158. package/lib/v1/MultiSelect/index.js +39 -0
  159. package/lib/v1/PopOver/PopOver.js +293 -0
  160. package/lib/v1/Popup/Popup.js +715 -0
  161. package/lib/v1/Radio/Radio.js +126 -0
  162. package/lib/v1/Responsive/CustomResponsive.js +242 -0
  163. package/lib/v1/Responsive/RefWrapper.js +57 -0
  164. package/lib/v1/Responsive/ResizeComponent.js +268 -0
  165. package/lib/v1/Responsive/ResizeObserver.js +168 -0
  166. package/lib/v1/Responsive/Responsive.js +274 -0
  167. package/lib/v1/Responsive/index.js +55 -0
  168. package/lib/v1/ResponsiveDropBox/ResponsiveDropBox.js +79 -0
  169. package/lib/v1/Ribbon/Ribbon.js +44 -0
  170. package/lib/v1/RippleEffect/RippleEffect.js +39 -0
  171. package/lib/v1/Select/GroupSelect.js +877 -0
  172. package/lib/v1/Select/Select.js +1013 -0
  173. package/lib/v1/Select/SelectWithAvatar.js +394 -0
  174. package/lib/v1/Select/SelectWithIcon.js +597 -0
  175. package/lib/v1/Select/index.js +39 -0
  176. package/lib/v1/Stencils/Stencils.js +43 -0
  177. package/lib/v1/Switch/Switch.js +108 -0
  178. package/lib/v1/Tab/Tab.js +132 -0
  179. package/lib/v1/Tab/TabContent.js +42 -0
  180. package/lib/v1/Tab/TabContentWrapper.js +42 -0
  181. package/lib/v1/Tab/TabWrapper.js +89 -0
  182. package/lib/v1/Tab/Tabs.js +680 -0
  183. package/lib/v1/Tab/index.js +47 -0
  184. package/lib/v1/Tag/Tag.js +154 -0
  185. package/lib/v1/TextBox/TextBox.js +168 -0
  186. package/lib/v1/TextBoxIcon/TextBoxIcon.js +196 -0
  187. package/lib/v1/Textarea/Textarea.js +118 -0
  188. package/lib/v1/Tooltip/Tooltip.js +586 -0
  189. package/lib/v1/Typography/Typography.js +56 -0
  190. package/lib/v1/Typography/css/Typography.module.css +376 -0
  191. package/lib/v1/Typography/css/cssJSLogic.js +41 -0
  192. package/lib/v1/Typography/css/letterSpacingMap.js +20 -0
  193. package/lib/v1/Typography/props/defaultProps.js +15 -0
  194. package/lib/v1/Typography/props/propTypes.js +35 -0
  195. package/lib/v1/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +90 -0
  196. package/lib/v1/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +126 -0
  197. package/lib/v1/semantic/Button/Button.js +63 -0
  198. package/lib/v1/semantic/index.js +15 -0
  199. package/package.json +1 -1
  200. package/result.json +1 -1
@@ -0,0 +1,1013 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = exports.SelectComponent = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _defaultProps = require("../../Select/props/defaultProps");
13
+
14
+ var _propTypes = require("../../Select/props/propTypes");
15
+
16
+ var _Popup = _interopRequireDefault(require("../Popup/Popup"));
17
+
18
+ var _TextBoxIcon = _interopRequireDefault(require("../TextBoxIcon/TextBoxIcon"));
19
+
20
+ var _Layout = require("../Layout");
21
+
22
+ var _TextBox = _interopRequireDefault(require("../TextBox/TextBox"));
23
+
24
+ var _Card = _interopRequireWildcard(require("../Card/Card"));
25
+
26
+ var _Suggestions = _interopRequireDefault(require("../MultiSelect/Suggestions"));
27
+
28
+ var _EmptyState = _interopRequireDefault(require("../MultiSelect/EmptyState"));
29
+
30
+ var _IdProvider = require("../../Provider/IdProvider");
31
+
32
+ var _icons = require("@zohodesk/icons");
33
+
34
+ var _ResponsiveDropBox = _interopRequireDefault(require("../ResponsiveDropBox/ResponsiveDropBox"));
35
+
36
+ var _CustomResponsive = require("../Responsive/CustomResponsive");
37
+
38
+ var _Loader = _interopRequireDefault(require("@zohodesk/svg/lib/Loader/Loader"));
39
+
40
+ var _dropDownUtils = require("../../utils/dropDownUtils");
41
+
42
+ var _Common = require("../../utils/Common.js");
43
+
44
+ var _SelectModule = _interopRequireDefault(require("../../Select/Select.module.css"));
45
+
46
+ var _Config = require("../../Provider/Config");
47
+
48
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
49
+
50
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
51
+
52
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
53
+
54
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
55
+
56
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
57
+
58
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
59
+
60
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
61
+
62
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
63
+
64
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
65
+
66
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
67
+
68
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
69
+
70
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
71
+
72
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
73
+
74
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
75
+
76
+ /* eslint-disable react/no-deprecated */
77
+
78
+ /* eslint-disable react/no-unused-prop-types */
79
+ var dummyArray = [];
80
+
81
+ var SelectComponent = /*#__PURE__*/function (_Component) {
82
+ _inherits(SelectComponent, _Component);
83
+
84
+ var _super = _createSuper(SelectComponent);
85
+
86
+ function SelectComponent(props) {
87
+ var _this;
88
+
89
+ _classCallCheck(this, SelectComponent);
90
+
91
+ _this = _super.call(this, props);
92
+ _this.getNextAriaId = (0, _IdProvider.getUniqueId)(_assertThisInitialized(_this));
93
+ _this.getFilterSuggestions = (0, _dropDownUtils.makeGetMultiSelectFilterSuggestions)();
94
+ _this.formatOptions = (0, _dropDownUtils.makeFormatOptions)();
95
+ _this.getSelectedValue = (0, _dropDownUtils.makeGetSelectedValueText)();
96
+ _this.selectedFormatOptions = {};
97
+ var selectedValue = props.selectedValue,
98
+ _props$searchDebounce = props.searchDebounceTime,
99
+ searchDebounceTime = _props$searchDebounce === void 0 ? 500 : _props$searchDebounce,
100
+ isDefaultSelectValue = props.isDefaultSelectValue,
101
+ _props$autoSelectDebo = props.autoSelectDebouneTime,
102
+ autoSelectDebouneTime = _props$autoSelectDebo === void 0 ? 350 : _props$autoSelectDebo,
103
+ valueField = props.valueField,
104
+ textField = props.textField;
105
+
106
+ var _this$handleFormatOpt = _this.handleFormatOptions(_this.props),
107
+ allOptions = _this$handleFormatOpt.allOptions,
108
+ normalizedAllOptions = _this$handleFormatOpt.normalizedAllOptions,
109
+ optionsOrder = _this$handleFormatOpt.optionsOrder,
110
+ normalizedFormatOptions = _this$handleFormatOpt.normalizedFormatOptions;
111
+
112
+ var _this$getSelectedValu = _this.getSelectedValue({
113
+ optionsOrder: optionsOrder,
114
+ selectedValue: selectedValue,
115
+ normalizedFormatOptions: normalizedFormatOptions,
116
+ selectedFormatOptions: _this.selectedFormatOptions,
117
+ isDefaultSelectValue: isDefaultSelectValue,
118
+ valueField: valueField,
119
+ textField: textField
120
+ }),
121
+ selected = _this$getSelectedValu.selected,
122
+ hoverIndex = _this$getSelectedValu.hoverIndex,
123
+ selectedValueDetails = _this$getSelectedValu.selectedValueDetails,
124
+ selectedId = _this$getSelectedValu.selectedId,
125
+ isSelfValueChanged = _this$getSelectedValu.isSelfValueChanged; // eslint-disable-next-line
126
+
127
+
128
+ if (isSelfValueChanged) {// onChange && onChange(selectedId, normalizedAllOptions[selectedId]);
129
+ }
130
+
131
+ _this.state = {
132
+ selected: selected,
133
+ options: allOptions,
134
+ optionsNormalize: normalizedAllOptions,
135
+ hoverIndex: hoverIndex,
136
+ searchStr: '',
137
+ isFetchingOptions: false,
138
+ selectedId: selectedId,
139
+ selectedValueIndex: hoverIndex
140
+ };
141
+ _this.optionsOrder = optionsOrder;
142
+ _this._isMounted = false;
143
+ _this.normalizedFormatOptions = normalizedFormatOptions;
144
+ _this.allSelectedOptions = selectedValueDetails;
145
+ _this.handleChange = _this.handleChange.bind(_assertThisInitialized(_this));
146
+ _this.handleKeyDown = _this.handleKeyDown.bind(_assertThisInitialized(_this));
147
+ _this.handleSearch = _this.handleSearch.bind(_assertThisInitialized(_this));
148
+ _this.handleFilterSuggestions = _this.handleFilterSuggestions.bind(_assertThisInitialized(_this));
149
+ _this.handleMouseEnter = _this.handleMouseEnter.bind(_assertThisInitialized(_this));
150
+ _this.handleFetchOptions = _this.handleFetchOptions.bind(_assertThisInitialized(_this));
151
+ _this.handleGetNextOptions = _this.handleGetNextOptions.bind(_assertThisInitialized(_this));
152
+ _this.handleScroll = _this.handleScroll.bind(_assertThisInitialized(_this));
153
+ _this.handleSearchOptions = (0, _Common.debounce)(_this.handleSearchOptions.bind(_assertThisInitialized(_this)), searchDebounceTime);
154
+ _this.suggestionContainerRef = _this.suggestionContainerRef.bind(_assertThisInitialized(_this));
155
+ _this.suggestionItemRef = _this.suggestionItemRef.bind(_assertThisInitialized(_this));
156
+ _this.searchInputRef = _this.searchInputRef.bind(_assertThisInitialized(_this));
157
+ _this.valueInputRef = _this.valueInputRef.bind(_assertThisInitialized(_this));
158
+ _this.togglePopup = _this.togglePopup.bind(_assertThisInitialized(_this));
159
+ _this.handleSelectFocus = _this.handleSelectFocus.bind(_assertThisInitialized(_this));
160
+ _this.handleFormatOptions = _this.handleFormatOptions.bind(_assertThisInitialized(_this));
161
+ _this.handlePopupClose = _this.handlePopupClose.bind(_assertThisInitialized(_this));
162
+ _this.handleClearSearch = _this.handleClearSearch.bind(_assertThisInitialized(_this));
163
+ _this.handleValueInputChange = _this.handleValueInputChange.bind(_assertThisInitialized(_this));
164
+ _this.handleChangeOnType = (0, _Common.debounce)(_this.handleChangeOnType.bind(_assertThisInitialized(_this)), autoSelectDebouneTime);
165
+ _this.handleAddNewOption = _this.handleAddNewOption.bind(_assertThisInitialized(_this));
166
+ _this.handleExposePopupHandlers = _this.handleExposePopupHandlers.bind(_assertThisInitialized(_this));
167
+ _this.handleGetAddNewOptionText = _this.handleGetAddNewOptionText.bind(_assertThisInitialized(_this));
168
+ _this.valueInputTypeString = '';
169
+ _this.valueInputSearchString = '';
170
+ _this.autoSelectSuggestions = [];
171
+ _this.autoSelectIndex = 0;
172
+ return _this;
173
+ }
174
+
175
+ _createClass(SelectComponent, [{
176
+ key: "componentDidMount",
177
+ value: function componentDidMount() {
178
+ this._isMounted = true;
179
+ this.handleExposePopupHandlers(); // let { suggestionContainer } = this;
180
+ // suggestionContainer &&
181
+ // suggestionContainer.addEventListener('scroll', this.handleScroll);
182
+ }
183
+ }, {
184
+ key: "componentWillReceiveProps",
185
+ value: function componentWillReceiveProps(nextProps) {
186
+ var selectedValue = nextProps.selectedValue,
187
+ isDefaultSelectValue = nextProps.isDefaultSelectValue,
188
+ valueField = nextProps.valueField,
189
+ textField = nextProps.textField;
190
+ var oldHoverIndex = this.state.hoverIndex;
191
+
192
+ var _this$handleFormatOpt2 = this.handleFormatOptions(nextProps),
193
+ allOptions = _this$handleFormatOpt2.allOptions,
194
+ normalizedAllOptions = _this$handleFormatOpt2.normalizedAllOptions,
195
+ optionsOrder = _this$handleFormatOpt2.optionsOrder,
196
+ normalizedFormatOptions = _this$handleFormatOpt2.normalizedFormatOptions;
197
+
198
+ var oldSelectedFormatOptions = this.selectedFormatOptions;
199
+
200
+ var _this$getSelectedValu2 = this.getSelectedValue({
201
+ optionsOrder: optionsOrder,
202
+ selectedValue: selectedValue,
203
+ normalizedFormatOptions: normalizedFormatOptions,
204
+ selectedFormatOptions: oldSelectedFormatOptions,
205
+ isDefaultSelectValue: isDefaultSelectValue,
206
+ valueField: valueField,
207
+ textField: textField
208
+ }),
209
+ selected = _this$getSelectedValu2.selected,
210
+ hoverIndex = _this$getSelectedValu2.hoverIndex,
211
+ selectedValueDetails = _this$getSelectedValu2.selectedValueDetails,
212
+ selectedId = _this$getSelectedValu2.selectedId,
213
+ isSelfValueChanged = _this$getSelectedValu2.isSelfValueChanged;
214
+
215
+ var oldSelectedValue = this.props.selectedValue; // eslint-disable-next-line
216
+
217
+ if (isSelfValueChanged && oldSelectedValue !== selectedValue) {// onChange && onChange(selectedId, normalizedAllOptions[selectedId]);
218
+ }
219
+
220
+ this.selectedFormatOptions = Object.assign(oldSelectedFormatOptions, selectedValueDetails);
221
+ this.normalizedFormatOptions = normalizedFormatOptions;
222
+ this.optionsOrder = optionsOrder;
223
+ this.setState({
224
+ options: allOptions,
225
+ optionsNormalize: normalizedAllOptions,
226
+ selected: selected,
227
+ hoverIndex: oldHoverIndex ? oldHoverIndex : hoverIndex,
228
+ selectedId: selectedId,
229
+ selectedValueIndex: hoverIndex
230
+ });
231
+ }
232
+ }, {
233
+ key: "componentDidUpdate",
234
+ value: function componentDidUpdate(prevProps) {
235
+ var _this2 = this;
236
+
237
+ var suggestionContainer = this.suggestionContainer,
238
+ optionsOrder = this.optionsOrder;
239
+ var _this$state = this.state,
240
+ hoverIndex = _this$state.hoverIndex,
241
+ searchStr = _this$state.searchStr,
242
+ selectedValueIndex = _this$state.selectedValueIndex;
243
+ var _this$props = this.props,
244
+ needLocalSearch = _this$props.needLocalSearch,
245
+ onDropBoxClose = _this$props.onDropBoxClose,
246
+ onDropBoxOpen = _this$props.onDropBoxOpen,
247
+ needSearch = _this$props.needSearch,
248
+ onSearch = _this$props.onSearch,
249
+ isPopupOpen = _this$props.isPopupOpen,
250
+ isSearchClearOnClose = _this$props.isSearchClearOnClose;
251
+ var hoverId = (0, _Common.getIsEmptyValue)(optionsOrder[hoverIndex]) ? '' : optionsOrder[hoverIndex];
252
+ var selSuggestion = this["suggestion_".concat(hoverId)];
253
+ isPopupOpen && (0, _Common.scrollTo)(suggestionContainer, selSuggestion);
254
+
255
+ if (prevProps.isPopupOpen !== isPopupOpen) {
256
+ if (isPopupOpen) {
257
+ onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
258
+ setTimeout(function () {
259
+ _this2.searchInput && _this2.searchInput.focus({
260
+ preventScroll: true
261
+ });
262
+ }, 10);
263
+ } else {
264
+ // needSearch && this.valueInput && this.valueInput.focus({preventScroll:true});
265
+ onDropBoxClose && onDropBoxClose();
266
+ isSearchClearOnClose && searchStr && onSearch && onSearch('');
267
+ this.setState({
268
+ searchStr: isSearchClearOnClose ? '' : searchStr,
269
+ hoverIndex: selectedValueIndex
270
+ });
271
+ }
272
+ } //When suggestions length less than 5, getNextOptions function call
273
+
274
+
275
+ var _this$props2 = this.props,
276
+ isNextOptions = _this$props2.isNextOptions,
277
+ getNextOptions = _this$props2.getNextOptions; // let { searchStr } = this.state;
278
+
279
+ var suggestions = isPopupOpen ? this.handleFilterSuggestions() : [];
280
+ var suggestionsLen = suggestions.length;
281
+
282
+ if (isPopupOpen && suggestionsLen <= 5 && isNextOptions && getNextOptions && !needLocalSearch) {
283
+ this.handleFetchOptions(getNextOptions, searchStr);
284
+ }
285
+ }
286
+ }, {
287
+ key: "componentWillUnmount",
288
+ value: function componentWillUnmount() {
289
+ this._isMounted = false;
290
+ var getPopupHandlers = this.props.getPopupHandlers;
291
+ var methods = {
292
+ removeClose: null,
293
+ openPopup: null,
294
+ closePopup: null,
295
+ togglePopup: null
296
+ };
297
+ getPopupHandlers && getPopupHandlers(methods); // let { suggestionContainer } = this;
298
+ // suggestionContainer &&
299
+ // suggestionContainer.removeEventListener('scroll', this.handleScroll);
300
+ }
301
+ }, {
302
+ key: "handleFormatOptions",
303
+ value: function handleFormatOptions(props) {
304
+ var options = props.options,
305
+ valueField = props.valueField,
306
+ textField = props.textField,
307
+ _props$customProps = props.customProps,
308
+ customProps = _props$customProps === void 0 ? {} : _props$customProps;
309
+ var _customProps$listItem = customProps.listItemProps,
310
+ listItemProps = _customProps$listItem === void 0 ? {} : _customProps$listItem;
311
+ return this.formatOptions({
312
+ options: options,
313
+ valueField: valueField,
314
+ textField: textField,
315
+ listItemProps: listItemProps
316
+ });
317
+ }
318
+ }, {
319
+ key: "handleChange",
320
+ value: function handleChange(id, value, index, e) {
321
+ e && e.preventDefault && e.preventDefault();
322
+ var _this$props3 = this.props,
323
+ onChange = _this$props3.onChange,
324
+ isReadOnly = _this$props3.isReadOnly,
325
+ needCloseOnSelect = _this$props3.needCloseOnSelect;
326
+ var optionsNormalize = this.state.optionsNormalize;
327
+ !isReadOnly && onChange && onChange(id, optionsNormalize[id]); // this.valueInput && this.valueInput.focus({preventScroll:true});
328
+
329
+ needCloseOnSelect && this.handlePopupClose(e);
330
+ }
331
+ }, {
332
+ key: "responsiveFunc",
333
+ value: function responsiveFunc(_ref) {
334
+ var mediaQueryOR = _ref.mediaQueryOR;
335
+ return {
336
+ tabletMode: mediaQueryOR([{
337
+ maxWidth: 700
338
+ }])
339
+ };
340
+ }
341
+ }, {
342
+ key: "handleKeyDown",
343
+ value: function handleKeyDown(e) {
344
+ var _this$props4 = this.props,
345
+ onChange = _this$props4.onChange,
346
+ isPopupOpen = _this$props4.isPopupOpen,
347
+ onKeyDown = _this$props4.onKeyDown,
348
+ isPopupOpenOnEnter = _this$props4.isPopupOpenOnEnter,
349
+ needCloseOnSelect = _this$props4.needCloseOnSelect;
350
+ var _this$state2 = this.state,
351
+ hoverIndex = _this$state2.hoverIndex,
352
+ optionsNormalize = _this$state2.optionsNormalize;
353
+ var options = this.handleFilterSuggestions();
354
+ var keyCode = e.keyCode;
355
+
356
+ if (!isPopupOpen && !isPopupOpenOnEnter) {
357
+ onKeyDown && onKeyDown(e);
358
+ }
359
+
360
+ if (isPopupOpen && (keyCode === 38 || keyCode === 40 || keyCode === 13) && e.preventDefault) {
361
+ e.preventDefault(); //prevent body scroll and enter key prevent
362
+ } else if (!isPopupOpen && keyCode === 40) {
363
+ e.preventDefault(); //prevent body scroll
364
+
365
+ this.togglePopup(e);
366
+ }
367
+
368
+ if (keyCode === 38 && isPopupOpen && options.length) {
369
+ // eslint-disable-next-line
370
+ if (hoverIndex === 0) {// hoverIndex = options.length - 1;
371
+ } else {
372
+ hoverIndex -= 1;
373
+ }
374
+
375
+ this.setState({
376
+ hoverIndex: hoverIndex
377
+ });
378
+ } else if (keyCode === 40 && isPopupOpen && options.length) {
379
+ // eslint-disable-next-line
380
+ if (hoverIndex === options.length - 1) {// hoverIndex = 0;
381
+ } else {
382
+ if (hoverIndex === options.length - 3) {
383
+ this.handleGetNextOptions();
384
+ }
385
+
386
+ hoverIndex += 1;
387
+ }
388
+
389
+ this.setState({
390
+ hoverIndex: hoverIndex
391
+ });
392
+ } else if (keyCode === 13) {
393
+ var option = options[hoverIndex];
394
+
395
+ var _ref2 = option || {},
396
+ id = _ref2.id;
397
+
398
+ if (isPopupOpen && !(0, _Common.getIsEmptyValue)(id) && onChange) {
399
+ onChange(id, optionsNormalize[id]);
400
+ needCloseOnSelect && this.handlePopupClose(e);
401
+ }
402
+
403
+ if (!isPopupOpen && isPopupOpenOnEnter) {
404
+ this.togglePopup(e);
405
+ }
406
+ } else if (keyCode === 27) {
407
+ this.valueInput && this.valueInput.focus({
408
+ preventScroll: true
409
+ }); //this.handlePopupClose(e);
410
+ } else if (keyCode === 9) {
411
+ var _option = options[hoverIndex];
412
+
413
+ var _ref3 = _option || {},
414
+ _id = _ref3.id;
415
+
416
+ if (isPopupOpen && !(0, _Common.getIsEmptyValue)(_id)) {
417
+ onChange && onChange(_id, optionsNormalize[_id]);
418
+ needCloseOnSelect && this.handlePopupClose(e);
419
+ }
420
+
421
+ if (!isPopupOpen && isPopupOpenOnEnter) {
422
+ this.togglePopup(e);
423
+ }
424
+ }
425
+ }
426
+ }, {
427
+ key: "handleSearchOptions",
428
+ value: function handleSearchOptions() {
429
+ var onSearch = this.props.onSearch;
430
+ var searchStr = this.state.searchStr;
431
+ searchStr && this.handleFetchOptions(onSearch, searchStr);
432
+ }
433
+ }, {
434
+ key: "handleSearch",
435
+ value: function handleSearch(value) {
436
+ var _this3 = this;
437
+
438
+ // let { value = '' } = e.target;
439
+ var _this$state$searchStr = this.state.searchStr,
440
+ searchStr = _this$state$searchStr === void 0 ? '' : _this$state$searchStr;
441
+ var onSearch = this.props.onSearch;
442
+ var searchStrRegex = (0, _Common.getSearchString)(searchStr);
443
+ var valueStrRegex = (0, _Common.getSearchString)(value);
444
+ var isSearch = searchStrRegex !== valueStrRegex ? true : false;
445
+ this.setState({
446
+ searchStr: value,
447
+ hoverIndex: 0
448
+ }, function () {
449
+ if (!value) {
450
+ onSearch && _this3.handleFetchOptions(onSearch, '');
451
+ } else if (isSearch && onSearch) {
452
+ _this3.handleSearchOptions();
453
+ }
454
+ });
455
+ }
456
+ }, {
457
+ key: "handleMouseEnter",
458
+ value: function handleMouseEnter(id
459
+ /*val, index*/
460
+ ) {
461
+ var hoverIndex = this.state.hoverIndex;
462
+ var optionsOrder = this.optionsOrder;
463
+ var newHoverIndex = optionsOrder.indexOf(id);
464
+ hoverIndex !== newHoverIndex && this.setState({
465
+ hoverIndex: newHoverIndex
466
+ });
467
+ }
468
+ }, {
469
+ key: "handleFilterSuggestions",
470
+ value: function handleFilterSuggestions() {
471
+ var _this$props5 = this.props,
472
+ needLocalSearch = _this$props5.needLocalSearch,
473
+ _this$props5$excludeO = _this$props5.excludeOptions,
474
+ excludeOptions = _this$props5$excludeO === void 0 ? dummyArray : _this$props5$excludeO;
475
+ var _this$state3 = this.state,
476
+ _this$state3$options = _this$state3.options,
477
+ options = _this$state3$options === void 0 ? dummyArray : _this$state3$options,
478
+ _this$state3$searchSt = _this$state3.searchStr,
479
+ searchStr = _this$state3$searchSt === void 0 ? '' : _this$state3$searchSt; // if (
480
+ // (needSearch && searchStr && searchStr.trim().length) ||
481
+ // (excludeOptions && excludeOptions.length)
482
+ // ) {
483
+
484
+ searchStr = (0, _Common.getSearchString)(searchStr);
485
+
486
+ var _this$getFilterSugges = this.getFilterSuggestions({
487
+ options: options,
488
+ selectedOptions: excludeOptions,
489
+ searchStr: searchStr,
490
+ needSearch: needLocalSearch
491
+ }),
492
+ suggestions = _this$getFilterSugges.suggestions,
493
+ suggestionIds = _this$getFilterSugges.suggestionIds;
494
+
495
+ this.optionsOrder = suggestionIds;
496
+ return suggestions; // }
497
+ // return options;
498
+ }
499
+ }, {
500
+ key: "handleScroll",
501
+ value: function handleScroll(e) {
502
+ var ele = e.target;
503
+ var isScrollReachedBottom = (0, _Common.findScrollEnd)(ele);
504
+ isScrollReachedBottom && this.handleGetNextOptions();
505
+ }
506
+ }, {
507
+ key: "handleFetchOptions",
508
+ value: function handleFetchOptions(APICall) {
509
+ var _this4 = this;
510
+
511
+ var searchStr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
512
+ // let funcArgs = args.slice(1, args.length);
513
+ var _this$state$isFetchin = this.state.isFetchingOptions,
514
+ isFetchingOptions = _this$state$isFetchin === void 0 ? false : _this$state$isFetchin;
515
+ var _isMounted = this._isMounted;
516
+
517
+ if (!isFetchingOptions && APICall) {
518
+ this.setState({
519
+ isFetchingOptions: true
520
+ });
521
+
522
+ try {
523
+ return APICall(searchStr).then(function () {
524
+ _isMounted && _this4.setState({
525
+ isFetchingOptions: false
526
+ });
527
+ }, function () {
528
+ _isMounted && _this4.setState({
529
+ isFetchingOptions: false
530
+ });
531
+ });
532
+ } catch (e) {
533
+ _isMounted && this.setState({
534
+ isFetchingOptions: false
535
+ });
536
+ }
537
+ }
538
+ }
539
+ }, {
540
+ key: "handleGetNextOptions",
541
+ value: function handleGetNextOptions() {
542
+ var _this$props6 = this.props,
543
+ isNextOptions = _this$props6.isNextOptions,
544
+ getNextOptions = _this$props6.getNextOptions;
545
+ var searchStr = this.state.searchStr;
546
+ isNextOptions && getNextOptions && this.handleFetchOptions(getNextOptions, searchStr);
547
+ }
548
+ }, {
549
+ key: "togglePopup",
550
+ value: function togglePopup(e) {
551
+ var _this$props7 = this.props,
552
+ togglePopup = _this$props7.togglePopup,
553
+ isReadOnly = _this$props7.isReadOnly,
554
+ defaultDropBoxPosition = _this$props7.defaultDropBoxPosition,
555
+ onFocus = _this$props7.onFocus,
556
+ isPopupOpen = _this$props7.isPopupOpen;
557
+ !isReadOnly && togglePopup(e, defaultDropBoxPosition ? "".concat(defaultDropBoxPosition) : null);
558
+ !isPopupOpen && typeof onFocus === 'function' && onFocus(e);
559
+ }
560
+ }, {
561
+ key: "handlePopupClose",
562
+ value: function handlePopupClose(e) {
563
+ var closePopupOnly = this.props.closePopupOnly;
564
+ this.valueInput && this.valueInput.focus({
565
+ preventScroll: true
566
+ });
567
+ closePopupOnly(e);
568
+ }
569
+ }, {
570
+ key: "suggestionContainerRef",
571
+ value: function suggestionContainerRef(el) {
572
+ this.suggestionContainer = el;
573
+ }
574
+ }, {
575
+ key: "suggestionItemRef",
576
+ value: function suggestionItemRef(el, index, id) {
577
+ this["suggestion_".concat(id)] = el;
578
+ }
579
+ }, {
580
+ key: "searchInputRef",
581
+ value: function searchInputRef(el) {
582
+ this.searchInput = el;
583
+ }
584
+ }, {
585
+ key: "valueInputRef",
586
+ value: function valueInputRef(el) {
587
+ var getRef = this.props.getRef;
588
+ this.valueInput = el;
589
+ getRef && getRef(el);
590
+ }
591
+ }, {
592
+ key: "handleSelectFocus",
593
+ value: function handleSelectFocus() {
594
+ var valueInput = this.valueInput;
595
+ valueInput && valueInput.setSelectionRange(valueInput, 0);
596
+ }
597
+ }, {
598
+ key: "handleClearSearch",
599
+ value: function handleClearSearch() {
600
+ var _this5 = this;
601
+
602
+ this.handleSearch('');
603
+ setTimeout(function () {
604
+ _this5.searchInput && _this5.searchInput.focus({
605
+ preventScroll: true
606
+ });
607
+ }, 1);
608
+ }
609
+ }, {
610
+ key: "handleValueInputChange",
611
+ value: function handleValueInputChange(e) {
612
+ var which = e.which;
613
+ var typeString = String.fromCharCode(which);
614
+ var _this$props8 = this.props,
615
+ isPopupOpen = _this$props8.isPopupOpen,
616
+ autoSelectOnType = _this$props8.autoSelectOnType;
617
+
618
+ if (!isPopupOpen && autoSelectOnType) {
619
+ this.valueInputTypeString += (typeString || '').trim();
620
+ this.handleChangeOnType();
621
+ }
622
+ }
623
+ }, {
624
+ key: "handleChangeOnType",
625
+ value: function handleChangeOnType() {
626
+ var _this6 = this;
627
+
628
+ var _this$props$excludeOp = this.props.excludeOptions,
629
+ excludeOptions = _this$props$excludeOp === void 0 ? dummyArray : _this$props$excludeOp;
630
+ var _this$state$options = this.state.options,
631
+ options = _this$state$options === void 0 ? dummyArray : _this$state$options;
632
+ var optionsOrder = this.optionsOrder;
633
+ var typeString = this.valueInputTypeString;
634
+ this.valueInputTypeString = '';
635
+
636
+ var changeValue = function changeValue() {
637
+ var optionDetails = _this6.autoSelectSuggestions[_this6.autoSelectIndex];
638
+
639
+ var _ref4 = optionDetails || {},
640
+ id = _ref4.id;
641
+
642
+ if (!(0, _Common.getIsEmptyValue)(id)) {
643
+ _this6.handleChange(id);
644
+
645
+ var hoverIndex = optionsOrder.indexOf(id);
646
+
647
+ _this6.setState({
648
+ hoverIndex: hoverIndex
649
+ });
650
+ }
651
+ };
652
+
653
+ if (typeString && typeString === this.valueInputSearchString) {
654
+ if (this.autoSelectIndex < this.autoSelectSuggestions.length - 1) {
655
+ this.autoSelectIndex += 1;
656
+ } else {
657
+ this.autoSelectIndex = 0;
658
+ }
659
+
660
+ changeValue();
661
+ } else if (typeString) {
662
+ this.valueInputSearchString = typeString;
663
+
664
+ var _this$getFilterSugges2 = this.getFilterSuggestions({
665
+ options: options,
666
+ selectedOptions: excludeOptions,
667
+ searchStr: typeString,
668
+ needSearch: true,
669
+ isStartsWithSearch: true
670
+ }),
671
+ _this$getFilterSugges3 = _this$getFilterSugges2.suggestions,
672
+ suggestions = _this$getFilterSugges3 === void 0 ? [] : _this$getFilterSugges3;
673
+
674
+ this.autoSelectIndex = 0;
675
+ this.autoSelectSuggestions = suggestions;
676
+ changeValue();
677
+ }
678
+ }
679
+ }, {
680
+ key: "handleAddNewOption",
681
+ value: function handleAddNewOption() {
682
+ var searchStr = this.state.searchStr;
683
+ var _this$props9 = this.props,
684
+ onAddNewOption = _this$props9.onAddNewOption,
685
+ getCustomEmptyState = _this$props9.getCustomEmptyState;
686
+
687
+ if (getCustomEmptyState) {
688
+ this.setState({
689
+ searchStr: ''
690
+ });
691
+ this.handleFetchOptions(onAddNewOption, searchStr);
692
+ }
693
+ }
694
+ }, {
695
+ key: "handleExposePopupHandlers",
696
+ value: function handleExposePopupHandlers() {
697
+ var _this$props10 = this.props,
698
+ removeClose = _this$props10.removeClose,
699
+ openPopupOnly = _this$props10.openPopupOnly,
700
+ closePopupOnly = _this$props10.closePopupOnly,
701
+ togglePopup = _this$props10.togglePopup,
702
+ getPopupHandlers = _this$props10.getPopupHandlers;
703
+ var methods = {
704
+ removeClose: removeClose,
705
+ openPopup: openPopupOnly,
706
+ closePopup: closePopupOnly,
707
+ togglePopup: togglePopup
708
+ };
709
+ getPopupHandlers && getPopupHandlers(methods);
710
+ }
711
+ }, {
712
+ key: "handleGetAddNewOptionText",
713
+ value: function handleGetAddNewOptionText() {
714
+ var searchStr = this.state.searchStr;
715
+ var getCustomEmptyState = this.props.getCustomEmptyState;
716
+ return getCustomEmptyState({
717
+ searchString: searchStr,
718
+ onAddNewOption: this.handleAddNewOption
719
+ });
720
+ }
721
+ }, {
722
+ key: "render",
723
+ value: function render() {
724
+ var _this7 = this;
725
+
726
+ var _this$props11 = this.props,
727
+ needSearch = _this$props11.needSearch,
728
+ dropBoxSize = _this$props11.dropBoxSize,
729
+ emptyMessage = _this$props11.emptyMessage,
730
+ searchEmptyMessage = _this$props11.searchEmptyMessage,
731
+ needBorder = _this$props11.needBorder,
732
+ needSelectDownIcon = _this$props11.needSelectDownIcon,
733
+ position = _this$props11.position,
734
+ defaultDropBoxPosition = _this$props11.defaultDropBoxPosition,
735
+ getTargetRef = _this$props11.getTargetRef,
736
+ getContainerRef = _this$props11.getContainerRef,
737
+ removeClose = _this$props11.removeClose,
738
+ isPopupOpen = _this$props11.isPopupOpen,
739
+ isPopupReady = _this$props11.isPopupReady,
740
+ animationStyle = _this$props11.animationStyle,
741
+ textBoxSize = _this$props11.textBoxSize,
742
+ textBoxVariant = _this$props11.textBoxVariant,
743
+ searchBoxSize = _this$props11.searchBoxSize,
744
+ searchBoxPlaceHolder = _this$props11.searchBoxPlaceHolder,
745
+ maxLength = _this$props11.maxLength,
746
+ isDisabled = _this$props11.isDisabled,
747
+ title = _this$props11.title,
748
+ size = _this$props11.size,
749
+ placeHolder = _this$props11.placeHolder,
750
+ className = _this$props11.className,
751
+ isReadOnly = _this$props11.isReadOnly,
752
+ dataId = _this$props11.dataId,
753
+ needResponsive = _this$props11.needResponsive,
754
+ borderColor = _this$props11.borderColor,
755
+ needTick = _this$props11.needTick,
756
+ listItemSize = _this$props11.listItemSize,
757
+ boxSize = _this$props11.boxSize,
758
+ needListBorder = _this$props11.needListBorder,
759
+ getFooter = _this$props11.getFooter,
760
+ getChildren = _this$props11.getChildren,
761
+ getCustomEmptyState = _this$props11.getCustomEmptyState,
762
+ isParentBased = _this$props11.isParentBased,
763
+ i18nKeys = _this$props11.i18nKeys,
764
+ htmlId = _this$props11.htmlId,
765
+ children = _this$props11.children,
766
+ iconOnHover = _this$props11.iconOnHover,
767
+ customProps = _this$props11.customProps,
768
+ autoComplete = _this$props11.autoComplete,
769
+ ariaLabelledby = _this$props11.ariaLabelledby,
770
+ isLoading = _this$props11.isLoading,
771
+ dataSelectorId = _this$props11.dataSelectorId,
772
+ isAbsolutePositioningNeeded = _this$props11.isAbsolutePositioningNeeded,
773
+ positionsOffset = _this$props11.positionsOffset,
774
+ targetOffset = _this$props11.targetOffset,
775
+ isRestrictScroll = _this$props11.isRestrictScroll,
776
+ dropBoxPortalId = _this$props11.dropBoxPortalId;
777
+ var _i18nKeys = i18nKeys,
778
+ TextBoxIcon_i18n = _i18nKeys.TextBoxIcon_i18n,
779
+ _i18nKeys$TextBox_all = _i18nKeys.TextBox_ally_label,
780
+ TextBox_ally_label = _i18nKeys$TextBox_all === void 0 ? 'click to select options' : _i18nKeys$TextBox_all;
781
+ i18nKeys = Object.assign({}, i18nKeys, {
782
+ emptyText: i18nKeys.emptyText || emptyMessage,
783
+ searchEmptyText: i18nKeys.searchEmptyText || searchEmptyMessage
784
+ });
785
+ var _this$state4 = this.state,
786
+ hoverIndex = _this$state4.hoverIndex,
787
+ selected = _this$state4.selected,
788
+ searchStr = _this$state4.searchStr,
789
+ isFetchingOptions = _this$state4.isFetchingOptions,
790
+ selectedId = _this$state4.selectedId,
791
+ options = _this$state4.options;
792
+ var suggestions = this.handleFilterSuggestions();
793
+ var setAriaId = this.getNextAriaId();
794
+ var ariaErrorId = this.getNextAriaId();
795
+ var _customProps$TextBoxP = customProps.TextBoxProps,
796
+ TextBoxProps = _customProps$TextBoxP === void 0 ? {} : _customProps$TextBoxP,
797
+ _customProps$Dropdown = customProps.DropdownSearchTextBoxProps,
798
+ DropdownSearchTextBoxProps = _customProps$Dropdown === void 0 ? {} : _customProps$Dropdown,
799
+ _customProps$Suggesti = customProps.SuggestionsProps,
800
+ SuggestionsProps = _customProps$Suggesti === void 0 ? {} : _customProps$Suggesti;
801
+ return /*#__PURE__*/_react["default"].createElement("div", {
802
+ className: "".concat(isParentBased || isReadOnly || isDisabled ? _SelectModule["default"].container : '', " ").concat(_SelectModule["default"]["box_".concat(size)], " ").concat(isReadOnly ? _SelectModule["default"].readonly : '', " ").concat(borderColor === 'transparent' ? _SelectModule["default"].transparentContainer : '', " ").concat(iconOnHover && (isReadOnly || isDisabled) ? _SelectModule["default"].iconOnHoverReadonly : iconOnHover && !(isReadOnly || isDisabled) ? _SelectModule["default"].iconOnHoverStyle : ''),
803
+ "data-title": isDisabled ? title : null,
804
+ "data-selector-id": dataSelectorId
805
+ }, /*#__PURE__*/_react["default"].createElement("div", {
806
+ className: "".concat(className ? className : ''),
807
+ onClick: isDisabled || isReadOnly ? null : this.togglePopup,
808
+ ref: getTargetRef,
809
+ "data-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId),
810
+ "data-test-id": "".concat(isDisabled ? "".concat(dataId, "_disabled") : isReadOnly ? "".concat(dataId, "_readOnly") : dataId)
811
+ }, needSelectDownIcon ? /*#__PURE__*/_react["default"].createElement(_TextBoxIcon["default"], {
812
+ a11y: {
813
+ role: 'Menuitem',
814
+ ariaLabel: TextBox_ally_label,
815
+ ariaControls: setAriaId,
816
+ ariaExpanded: !isReadOnly && !isDisabled && isPopupOpen ? true : false,
817
+ ariaHaspopup: true,
818
+ ariaReadonly: true,
819
+ ariaActivedescendant: selectedId,
820
+ ariaOwns: setAriaId,
821
+ ariaLabelledby: ariaLabelledby
822
+ },
823
+ isDisabled: isDisabled,
824
+ iconRotated: isPopupOpen,
825
+ inputRef: this.valueInputRef,
826
+ maxLength: maxLength,
827
+ needBorder: needBorder,
828
+ onFocus: this.handleSelectFocus,
829
+ onKeyDown: this.handleKeyDown,
830
+ placeHolder: placeHolder,
831
+ isReadOnly: true,
832
+ size: textBoxSize,
833
+ value: selected,
834
+ variant: textBoxVariant,
835
+ needReadOnlyStyle: isReadOnly ? true : false,
836
+ dataId: "".concat(dataId, "_textBox"),
837
+ isClickable: isReadOnly || isDisabled ? false : true,
838
+ customClass: {
839
+ customTBoxWrap: isReadOnly || isDisabled ? '' : _SelectModule["default"].input
840
+ },
841
+ needEffect: isReadOnly || isDisabled ? false : true,
842
+ onKeyPress: this.handleValueInputChange,
843
+ borderColor: borderColor,
844
+ htmlId: htmlId,
845
+ isFocus: isPopupReady,
846
+ autoComplete: autoComplete,
847
+ customProps: {
848
+ TextBoxProps: TextBoxProps
849
+ }
850
+ }, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
851
+ alignBox: "row",
852
+ align: "both"
853
+ }, children ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
854
+ className: isPopupOpen ? _SelectModule["default"].rotate : '',
855
+ dataId: "".concat(dataId, "_children")
856
+ }, children) : null, /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
857
+ align: "both",
858
+ dataId: "".concat(dataId, "_downIcon"),
859
+ "aria-hidden": true,
860
+ className: _SelectModule["default"].arrowIcon
861
+ }, /*#__PURE__*/_react["default"].createElement(_icons.Icon, {
862
+ name: "ZD-down",
863
+ size: "7"
864
+ })))) : /*#__PURE__*/_react["default"].createElement(_TextBox["default"], {
865
+ a11y: {
866
+ role: 'Menuitem',
867
+ ariaLabel: TextBox_ally_label,
868
+ ariaControls: setAriaId,
869
+ ariaExpanded: !isReadOnly && !isDisabled && isPopupOpen ? true : false,
870
+ ariaHaspopup: true,
871
+ ariaReadonly: true,
872
+ ariaActivedescendant: selectedId,
873
+ ariaOwns: setAriaId,
874
+ ariaLabelledby: ariaLabelledby
875
+ },
876
+ isDisabled: isDisabled,
877
+ inputRef: this.valueInputRef,
878
+ maxLength: maxLength,
879
+ needBorder: needBorder,
880
+ onFocus: this.handleSelectFocus,
881
+ onKeyDown: getChildren && this.handleKeyDown,
882
+ placeHolder: placeHolder,
883
+ isReadOnly: true,
884
+ needEffect: isReadOnly || isDisabled ? false : true,
885
+ size: textBoxSize,
886
+ value: selected,
887
+ variant: textBoxVariant,
888
+ needReadOnlyStyle: isReadOnly ? true : false,
889
+ dataId: "".concat(dataId, "_textBox"),
890
+ isClickable: isReadOnly || isDisabled ? false : true,
891
+ onKeyPress: this.handleValueInputChange,
892
+ borderColor: borderColor,
893
+ htmlId: htmlId,
894
+ autoComplete: autoComplete,
895
+ isFocus: isPopupReady,
896
+ customProps: TextBoxProps
897
+ })), !isReadOnly && !isDisabled && isPopupOpen ? /*#__PURE__*/_react["default"].createElement(_CustomResponsive.ResponsiveReceiver, {
898
+ query: this.responsiveFunc,
899
+ responsiveId: "Helmet"
900
+ }, function (_ref5) {
901
+ var tabletMode = _ref5.tabletMode;
902
+ return /*#__PURE__*/_react["default"].createElement(_ResponsiveDropBox["default"], {
903
+ animationStyle: animationStyle,
904
+ boxPosition: position || "".concat(defaultDropBoxPosition),
905
+ getRef: getContainerRef,
906
+ isActive: isPopupReady,
907
+ isAnimate: true,
908
+ isArrow: false,
909
+ onClick: removeClose,
910
+ needResponsive: needResponsive,
911
+ dataId: "".concat(dataId, "_suggestions"),
912
+ size: boxSize,
913
+ isPadding: false,
914
+ isResponsivePadding: getFooter ? false : true,
915
+ alignBox: "row",
916
+ isAbsolutePositioningNeeded: isAbsolutePositioningNeeded,
917
+ positionsOffset: positionsOffset,
918
+ targetOffset: targetOffset,
919
+ isRestrictScroll: isRestrictScroll,
920
+ portalId: dropBoxPortalId
921
+ }, isLoading ? /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
922
+ align: "both",
923
+ className: _SelectModule["default"].loader
924
+ }, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null)) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, !getChildren ? /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
925
+ flexible: true
926
+ }, /*#__PURE__*/_react["default"].createElement(_Card["default"], {
927
+ onScroll: _this7.handleScroll
928
+ }, needSearch ? /*#__PURE__*/_react["default"].createElement(_Card.CardHeader, null, /*#__PURE__*/_react["default"].createElement("div", {
929
+ className: "".concat(_SelectModule["default"].search, " ").concat(_SelectModule["default"][size])
930
+ }, /*#__PURE__*/_react["default"].createElement(_TextBoxIcon["default"], {
931
+ a11y: {
932
+ ariaControls: setAriaId,
933
+ ariaAutocomplete: 'list',
934
+ ariaDescribedby: ariaErrorId
935
+ },
936
+ inputRef: _this7.searchInputRef,
937
+ maxLength: maxLength,
938
+ onChange: _this7.handleSearch,
939
+ onKeyDown: _this7.handleKeyDown,
940
+ placeHolder: searchBoxPlaceHolder,
941
+ size: searchBoxSize,
942
+ value: searchStr,
943
+ onClear: _this7.handleClearSearch,
944
+ dataId: "".concat(dataId, "_search"),
945
+ i18nKeys: TextBoxIcon_i18n,
946
+ autoComplete: autoComplete,
947
+ customProps: {
948
+ TextBoxProps: DropdownSearchTextBoxProps
949
+ }
950
+ }))) : null, /*#__PURE__*/_react["default"].createElement(_Card.CardContent, {
951
+ shrink: true,
952
+ customClass: !tabletMode && dropBoxSize ? _SelectModule["default"][dropBoxSize] : '',
953
+ eleRef: _this7.suggestionContainerRef
954
+ }, suggestions.length ? /*#__PURE__*/_react["default"].createElement(_Suggestions["default"], _extends({
955
+ activeId: selectedId,
956
+ suggestions: suggestions,
957
+ getRef: _this7.suggestionItemRef,
958
+ hoverOption: hoverIndex,
959
+ onClick: _this7.handleChange,
960
+ onMouseEnter: _this7.handleMouseEnter,
961
+ dataId: "".concat(dataId, "_Options"),
962
+ needTick: needTick,
963
+ needBorder: needListBorder,
964
+ selectedOptions: [selectedId],
965
+ className: "".concat(tabletMode ? _SelectModule["default"].responsivelistItemContainer : _SelectModule["default"].listItemContainer),
966
+ listItemSize: listItemSize,
967
+ htmlId: setAriaId,
968
+ a11y: {
969
+ ariaParentRole: 'listbox',
970
+ role: 'option'
971
+ }
972
+ }, SuggestionsProps)) : /*#__PURE__*/_react["default"].createElement(_EmptyState["default"], {
973
+ isLoading: isFetchingOptions,
974
+ options: options,
975
+ searchString: searchStr,
976
+ suggestions: suggestions,
977
+ dataId: dataId,
978
+ getCustomEmptyState: getCustomEmptyState ? _this7.handleGetAddNewOptionText : null,
979
+ i18nKeys: i18nKeys,
980
+ htmlId: ariaErrorId
981
+ }), isFetchingOptions && /*#__PURE__*/_react["default"].createElement(_Layout.Container, {
982
+ isCover: false,
983
+ align: "both"
984
+ }, /*#__PURE__*/_react["default"].createElement(_Loader["default"], null))), getFooter ? /*#__PURE__*/_react["default"].createElement(_Card.CardFooter, null, getFooter()) : null)) : /*#__PURE__*/_react["default"].createElement(_Layout.Box, {
985
+ flexible: true
986
+ }, getChildren())));
987
+ }) : null);
988
+ }
989
+ }]);
990
+
991
+ return SelectComponent;
992
+ }(_react.Component);
993
+
994
+ exports.SelectComponent = SelectComponent;
995
+ SelectComponent.propTypes = _propTypes.Select_propTypes;
996
+ SelectComponent.defaultProps = _defaultProps.Select_defaultProps;
997
+ SelectComponent.displayName = 'Select';
998
+ var Select = (0, _Popup["default"])(SelectComponent);
999
+ Select.defaultProps = SelectComponent.defaultProps;
1000
+ Select.propTypes = _propTypes.Select_propTypes;
1001
+ Select.displayName = 'Select';
1002
+ var _default = Select; // if (__DOCS__) {
1003
+ // Select.docs = {
1004
+ // componentGroup: 'Form Elements',
1005
+ // folderName: 'Style Guide',
1006
+ // external: true,
1007
+ // description: ' '
1008
+ // };
1009
+ // // eslint-disable-next-line react/forbid-foreign-prop-types
1010
+ // Select.propTypes = SelectComponent.propTypes;
1011
+ // }
1012
+
1013
+ exports["default"] = _default;