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