@zohodesk/components 1.0.0-alpha-271 → 1.0.0-alpha-272
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/es/Accordion/Accordion.js +7 -3
- package/es/Accordion/AccordionItem.js +4 -2
- package/es/Animation/Animation.js +3 -3
- package/es/AppContainer/AppContainer.js +13 -5
- package/es/Avatar/Avatar.js +23 -11
- package/es/AvatarTeam/AvatarTeam.js +3 -3
- package/es/Button/Button.js +4 -3
- package/es/Buttongroup/Buttongroup.js +3 -3
- package/es/Card/Card.js +21 -10
- package/es/CheckBox/CheckBox.js +5 -3
- package/es/DateTime/CalendarView.js +32 -20
- package/es/DateTime/DateTime.js +75 -10
- package/es/DateTime/DateTimePopupFooter.js +4 -2
- package/es/DateTime/DateTimePopupHeader.js +8 -2
- package/es/DateTime/DateWidget.js +98 -35
- package/es/DateTime/DaysRow.js +4 -2
- package/es/DateTime/Time.js +10 -2
- package/es/DateTime/YearView.js +28 -4
- package/es/DateTime/__tests__/CalendarView.spec.js +1 -0
- package/es/DateTime/__tests__/DateTime.spec.js +1 -0
- package/es/DateTime/__tests__/DateWidget.spec.js +2 -3
- package/es/DateTime/common.js +3 -0
- package/es/DateTime/constants.js +1 -0
- package/es/DateTime/dateFormatUtils/dateFormat.js +63 -30
- package/es/DateTime/dateFormatUtils/dateFormats.js +0 -1
- package/es/DateTime/dateFormatUtils/dayChange.js +13 -4
- package/es/DateTime/dateFormatUtils/index.js +32 -2
- package/es/DateTime/dateFormatUtils/monthChange.js +8 -0
- package/es/DateTime/dateFormatUtils/timeChange.js +22 -6
- package/es/DateTime/dateFormatUtils/yearChange.js +11 -2
- package/es/DateTime/objectUtils.js +14 -20
- package/es/DateTime/props/defaultProps.js +2 -1
- package/es/DateTime/typeChecker.js +3 -0
- package/es/DateTime/validator.js +58 -6
- package/es/DropBox/DropBox.js +6 -2
- package/es/DropBox/DropBoxElement/DropBoxElement.js +7 -0
- package/es/DropBox/DropBoxElement/css/cssJSLogic.js +5 -3
- package/es/DropBox/DropBoxElement/useDropboxPosCalc.js +3 -0
- package/es/DropBox/props/defaultProps.js +1 -2
- package/es/DropBox/props/propTypes.js +1 -2
- package/es/DropDown/DropDown.js +8 -4
- package/es/DropDown/DropDownHeading.js +4 -5
- package/es/DropDown/DropDownItem.js +6 -0
- package/es/DropDown/DropDownSearch.js +4 -0
- package/es/DropDown/DropDownSeparator.js +1 -0
- package/es/DropDown/__tests__/DropDown.spec.js +1 -2
- package/es/Heading/Heading.js +2 -3
- package/es/Label/Label.js +2 -3
- package/es/Layout/Box.js +13 -0
- package/es/Layout/Container.js +12 -1
- package/es/Layout/index.js +1 -2
- package/es/ListItem/ListContainer.js +8 -3
- package/es/ListItem/ListItem.js +9 -3
- package/es/ListItem/ListItemWithAvatar.js +9 -3
- package/es/ListItem/ListItemWithCheckBox.js +7 -2
- package/es/ListItem/ListItemWithIcon.js +8 -3
- package/es/ListItem/ListItemWithRadio.js +7 -3
- package/es/Modal/Modal.js +28 -11
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +89 -13
- package/es/MultiSelect/AdvancedMultiSelect.js +32 -9
- package/es/MultiSelect/EmptyState.js +2 -0
- package/es/MultiSelect/MultiSelect.js +99 -32
- package/es/MultiSelect/MultiSelectHeader.js +3 -0
- package/es/MultiSelect/MultiSelectWithAvatar.js +12 -6
- package/es/MultiSelect/SelectedOptions.js +6 -3
- package/es/MultiSelect/Suggestions.js +7 -3
- package/es/MultiSelect/__tests__/MultiSelect.spec.js +4 -6
- package/es/MultiSelect/props/propTypes.js +2 -0
- package/es/PopOver/PopOver.js +18 -2
- package/es/PopOver/__tests__/PopOver.spec.js +2 -1
- package/es/Popup/Popup.js +77 -24
- package/es/Popup/__tests__/Popup.spec.js +17 -5
- package/es/Popup/viewPort.js +16 -4
- package/es/Provider/IdProvider.js +10 -5
- package/es/Provider/LibraryContext.js +6 -4
- package/es/Provider/NumberGenerator/NumberGenerator.js +21 -7
- package/es/Provider/ZindexProvider.js +9 -2
- package/es/Radio/Radio.js +4 -2
- package/es/Responsive/CustomResponsive.js +30 -18
- package/es/Responsive/RefWrapper.js +6 -7
- package/es/Responsive/ResizeComponent.js +35 -25
- package/es/Responsive/ResizeObserver.js +26 -6
- package/es/Responsive/Responsive.js +34 -20
- package/es/Responsive/index.js +1 -3
- package/es/Responsive/sizeObservers.js +28 -7
- package/es/Responsive/utils/index.js +7 -5
- package/es/Responsive/utils/shallowCompare.js +7 -2
- package/es/Responsive/windowResizeObserver.js +7 -0
- package/es/ResponsiveDropBox/ResponsiveDropBox.js +4 -0
- package/es/Ribbon/Ribbon.js +3 -2
- package/es/RippleEffect/RippleEffect.js +1 -3
- package/es/Select/GroupSelect.js +58 -14
- package/es/Select/Select.js +79 -33
- package/es/Select/SelectWithAvatar.js +17 -4
- package/es/Select/SelectWithIcon.js +46 -5
- package/es/Select/__tests__/Select.spec.js +6 -8
- package/es/Select/props/propTypes.js +1 -0
- package/es/Stencils/Stencils.js +3 -3
- package/es/Switch/Switch.js +5 -3
- package/es/Tab/Tab.js +4 -4
- package/es/Tab/TabContent.js +1 -0
- package/es/Tab/TabContentWrapper.js +2 -0
- package/es/Tab/TabWrapper.js +5 -2
- package/es/Tab/Tabs.js +54 -7
- package/es/Tab/__tests__/Tab.spec.js +1 -3
- package/es/Tab/__tests__/TabWrapper.spec.js +1 -0
- package/es/Tag/Tag.js +6 -3
- package/es/TextBox/TextBox.js +15 -3
- package/es/TextBox/__tests__/TextBox.spec.js +1 -4
- package/es/TextBoxIcon/TextBoxIcon.js +9 -2
- package/es/TextBoxIcon/__tests__/TextBoxIcon.spec.js +2 -7
- package/es/Textarea/Textarea.js +12 -3
- package/es/Textarea/__tests__/Textarea.spec.js +2 -2
- package/es/Tooltip/Tooltip.js +58 -14
- package/es/Tooltip/__tests__/Tooltip.spec.js +5 -0
- package/es/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +3 -2
- package/es/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +7 -5
- package/es/deprecated/PortalLayer/PortalLayer.js +25 -20
- package/es/semantic/Button/Button.js +3 -2
- package/es/utils/Common.js +54 -9
- package/es/utils/ContextOptimizer.js +4 -5
- package/es/utils/__tests__/debounce.spec.js +2 -2
- package/es/utils/constructFullName.js +2 -0
- package/es/utils/css/compileClassNames.js +5 -0
- package/es/utils/css/mergeStyle.js +7 -6
- package/es/utils/css/utils.js +1 -0
- package/es/utils/datetime/GMTZones.js +48 -0
- package/es/utils/datetime/common.js +31 -7
- package/es/utils/debounce.js +5 -1
- package/es/utils/dropDownUtils.js +68 -11
- package/es/utils/getInitial.js +4 -0
- package/es/utils/shallowEqual.js +6 -0
- package/lib/Accordion/Accordion.js +42 -18
- package/lib/Accordion/AccordionItem.js +40 -18
- package/lib/Accordion/__tests__/Accordion.spec.js +3 -0
- package/lib/Accordion/index.js +3 -0
- package/lib/Accordion/props/propTypes.js +3 -0
- package/lib/Animation/Animation.js +38 -18
- package/lib/Animation/__tests__/Animation.spec.js +11 -7
- package/lib/Animation/props/propTypes.js +3 -0
- package/lib/AppContainer/AppContainer.js +56 -21
- package/lib/AppContainer/props/propTypes.js +3 -0
- package/lib/Avatar/Avatar.js +78 -38
- package/lib/Avatar/__tests__/Avatar.spec.js +44 -0
- package/lib/Avatar/props/propTypes.js +3 -0
- package/lib/AvatarTeam/AvatarTeam.js +52 -30
- package/lib/AvatarTeam/__tests__/AvatarTeam.spec.js +13 -0
- package/lib/AvatarTeam/props/propTypes.js +3 -0
- package/lib/Button/Button.js +31 -20
- package/lib/Button/css/cssJSLogic.js +18 -17
- package/lib/Button/index.js +3 -0
- package/lib/Button/props/defaultProps.js +2 -0
- package/lib/Button/props/propTypes.js +3 -0
- package/lib/Buttongroup/Buttongroup.js +32 -12
- package/lib/Buttongroup/__test__/Buttongroup.spec.js +10 -0
- package/lib/Buttongroup/props/propTypes.js +3 -0
- package/lib/Card/Card.js +102 -46
- package/lib/Card/__tests__/Card.spec.js +10 -1
- package/lib/Card/index.js +4 -0
- package/lib/Card/props/propTypes.js +3 -0
- package/lib/CheckBox/CheckBox.js +71 -47
- package/lib/CheckBox/__tests__/CheckBox.spec.js +3 -0
- package/lib/CheckBox/props/propTypes.js +3 -0
- package/lib/DateTime/CalendarView.js +82 -42
- package/lib/DateTime/DateTime.js +246 -158
- package/lib/DateTime/DateTimePopupFooter.js +31 -8
- package/lib/DateTime/DateTimePopupHeader.js +48 -17
- package/lib/DateTime/DateWidget.js +352 -250
- package/lib/DateTime/DaysRow.js +27 -5
- package/lib/DateTime/Time.js +73 -32
- package/lib/DateTime/YearView.js +77 -28
- package/lib/DateTime/__tests__/CalendarView.spec.js +13 -5
- package/lib/DateTime/__tests__/DateTime.spec.js +51 -37
- package/lib/DateTime/__tests__/DateWidget.spec.js +10 -8
- package/lib/DateTime/common.js +6 -0
- package/lib/DateTime/constants.js +1 -0
- package/lib/DateTime/dateFormatUtils/dateFormat.js +184 -122
- package/lib/DateTime/dateFormatUtils/dateFormats.js +0 -1
- package/lib/DateTime/dateFormatUtils/dayChange.js +14 -7
- package/lib/DateTime/dateFormatUtils/index.js +74 -16
- package/lib/DateTime/dateFormatUtils/monthChange.js +19 -9
- package/lib/DateTime/dateFormatUtils/timeChange.js +54 -22
- package/lib/DateTime/dateFormatUtils/yearChange.js +22 -11
- package/lib/DateTime/index.js +2 -0
- package/lib/DateTime/objectUtils.js +24 -20
- package/lib/DateTime/props/defaultProps.js +2 -1
- package/lib/DateTime/props/propTypes.js +11 -1
- package/lib/DateTime/typeChecker.js +4 -0
- package/lib/DateTime/validator.js +73 -10
- package/lib/DropBox/DropBox.js +34 -10
- package/lib/DropBox/DropBoxElement/DropBoxElement.js +59 -38
- package/lib/DropBox/DropBoxElement/css/cssJSLogic.js +42 -34
- package/lib/DropBox/DropBoxElement/props/propTypes.js +3 -0
- package/lib/DropBox/DropBoxElement/useDropboxPosCalc.js +14 -9
- package/lib/DropBox/__tests__/DropBox.spec.js +6 -2
- package/lib/DropBox/css/cssJSLogic.js +3 -1
- package/lib/DropBox/props/defaultProps.js +8 -4
- package/lib/DropBox/props/propTypes.js +10 -4
- package/lib/DropDown/DropDown.js +52 -8
- package/lib/DropDown/DropDownHeading.js +39 -20
- package/lib/DropDown/DropDownItem.js +42 -20
- package/lib/DropDown/DropDownSearch.js +40 -17
- package/lib/DropDown/DropDownSeparator.js +24 -4
- package/lib/DropDown/__tests__/DropDown.spec.js +15 -9
- package/lib/DropDown/__tests__/DropDownItem.spec.js +9 -4
- package/lib/DropDown/__tests__/DropDownSearch.spec.js +3 -0
- package/lib/DropDown/index.js +9 -0
- package/lib/DropDown/props/propTypes.js +6 -4
- package/lib/Heading/Heading.js +37 -15
- package/lib/Heading/props/propTypes.js +3 -0
- package/lib/Label/Label.js +39 -19
- package/lib/Label/__tests__/Label.spec.js +14 -1
- package/lib/Label/props/propTypes.js +3 -0
- package/lib/Layout/Box.js +31 -11
- package/lib/Layout/Container.js +29 -10
- package/lib/Layout/__tests__/Box.spec.js +65 -49
- package/lib/Layout/__tests__/Container.spec.js +67 -50
- package/lib/Layout/index.js +3 -0
- package/lib/Layout/props/propTypes.js +3 -0
- package/lib/Layout/utils.js +10 -0
- package/lib/ListItem/ListContainer.js +48 -27
- package/lib/ListItem/ListItem.js +69 -45
- package/lib/ListItem/ListItemWithAvatar.js +75 -48
- package/lib/ListItem/ListItemWithCheckBox.js +64 -39
- package/lib/ListItem/ListItemWithIcon.js +68 -44
- package/lib/ListItem/ListItemWithRadio.js +65 -41
- package/lib/ListItem/index.js +7 -0
- package/lib/ListItem/props/propTypes.js +6 -4
- package/lib/Modal/Modal.js +45 -10
- package/lib/Modal/props/propTypes.js +3 -0
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +294 -166
- package/lib/MultiSelect/AdvancedMultiSelect.js +202 -125
- package/lib/MultiSelect/EmptyState.js +45 -24
- package/lib/MultiSelect/MultiSelect.js +323 -206
- package/lib/MultiSelect/MultiSelectHeader.js +30 -8
- package/lib/MultiSelect/MultiSelectWithAvatar.js +105 -63
- package/lib/MultiSelect/SelectedOptions.js +43 -17
- package/lib/MultiSelect/Suggestions.js +64 -32
- package/lib/MultiSelect/__tests__/MultiSelect.spec.js +86 -75
- package/lib/MultiSelect/index.js +5 -0
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +5 -0
- package/lib/PopOver/PopOver.js +95 -49
- package/lib/PopOver/__tests__/PopOver.spec.js +4 -1
- package/lib/PopOver/index.js +4 -0
- package/lib/PopOver/props/propTypes.js +3 -0
- package/lib/Popup/Popup.js +158 -81
- package/lib/Popup/__tests__/Popup.spec.js +43 -8
- package/lib/Popup/viewPort.js +28 -14
- package/lib/Provider/AvatarSize.js +4 -0
- package/lib/Provider/Config.js +2 -0
- package/lib/Provider/CssProvider.js +4 -0
- package/lib/Provider/IdProvider.js +17 -6
- package/lib/Provider/LibraryContext.js +35 -15
- package/lib/Provider/LibraryContextInit.js +4 -0
- package/lib/Provider/NumberGenerator/NumberGenerator.js +44 -15
- package/lib/Provider/ZindexProvider.js +15 -3
- package/lib/Provider/index.js +5 -0
- package/lib/Radio/Radio.js +61 -38
- package/lib/Radio/__tests__/Radiospec.js +9 -5
- package/lib/Radio/props/propTypes.js +3 -0
- package/lib/Responsive/CustomResponsive.js +73 -29
- package/lib/Responsive/RefWrapper.js +17 -11
- package/lib/Responsive/ResizeComponent.js +62 -36
- package/lib/Responsive/ResizeObserver.js +24 -10
- package/lib/Responsive/Responsive.js +80 -30
- package/lib/Responsive/index.js +4 -0
- package/lib/Responsive/props/propTypes.js +3 -0
- package/lib/Responsive/sizeObservers.js +53 -17
- package/lib/Responsive/utils/index.js +11 -3
- package/lib/Responsive/utils/shallowCompare.js +11 -2
- package/lib/Responsive/windowResizeObserver.js +8 -0
- package/lib/ResponsiveDropBox/ResponsiveDropBox.js +45 -17
- package/lib/ResponsiveDropBox/props/propTypes.js +3 -0
- package/lib/Ribbon/Ribbon.js +33 -13
- package/lib/Ribbon/__tests__/Ribbon.spec.js +22 -0
- package/lib/Ribbon/props/propTypes.js +3 -0
- package/lib/RippleEffect/RippleEffect.js +18 -10
- package/lib/RippleEffect/props/propTypes.js +3 -0
- package/lib/Select/GroupSelect.js +229 -130
- package/lib/Select/Select.js +290 -209
- package/lib/Select/SelectWithAvatar.js +102 -56
- package/lib/Select/SelectWithIcon.js +132 -76
- package/lib/Select/__tests__/Select.spec.js +133 -91
- package/lib/Select/index.js +5 -0
- package/lib/Select/props/defaultProps.js +5 -4
- package/lib/Select/props/propTypes.js +4 -0
- package/lib/Stencils/Stencils.js +29 -10
- package/lib/Stencils/__tests__/Stencils.spec.js +12 -0
- package/lib/Stencils/props/propTypes.js +3 -0
- package/lib/Switch/Switch.js +57 -34
- package/lib/Switch/props/propTypes.js +3 -0
- package/lib/Tab/Tab.js +40 -27
- package/lib/Tab/TabContent.js +12 -5
- package/lib/Tab/TabContentWrapper.js +13 -6
- package/lib/Tab/TabWrapper.js +37 -19
- package/lib/Tab/Tabs.js +171 -91
- package/lib/Tab/__tests__/Tab.spec.js +67 -58
- package/lib/Tab/__tests__/TabContent.spec.js +10 -6
- package/lib/Tab/__tests__/TabContentWrapper.spec.js +28 -20
- package/lib/Tab/__tests__/TabWrapper.spec.js +12 -0
- package/lib/Tab/__tests__/Tabs.spec.js +53 -39
- package/lib/Tab/index.js +6 -0
- package/lib/Tab/props/propTypes.js +3 -0
- package/lib/Tag/Tag.js +72 -43
- package/lib/Tag/__tests__/Tag.spec.js +14 -8
- package/lib/Tag/props/propTypes.js +3 -0
- package/lib/TextBox/TextBox.js +85 -59
- package/lib/TextBox/__tests__/TextBox.spec.js +14 -4
- package/lib/TextBox/props/propTypes.js +6 -4
- package/lib/TextBoxIcon/TextBoxIcon.js +79 -52
- package/lib/TextBoxIcon/__tests__/TextBoxIcon.spec.js +14 -5
- package/lib/TextBoxIcon/props/propTypes.js +3 -0
- package/lib/Textarea/Textarea.js +54 -29
- package/lib/Textarea/__tests__/Textarea.spec.js +14 -2
- package/lib/Textarea/props/propTypes.js +3 -0
- package/lib/Tooltip/Tooltip.js +94 -31
- package/lib/Tooltip/__tests__/Tooltip.spec.js +24 -3
- package/lib/Tooltip/props/propTypes.js +3 -0
- package/lib/VelocityAnimation/VelocityAnimation/VelocityAnimation.js +40 -16
- package/lib/VelocityAnimation/VelocityAnimation/props/propTypes.js +3 -0
- package/lib/VelocityAnimation/VelocityAnimationGroup/VelocityAnimationGroup.js +53 -25
- package/lib/VelocityAnimation/VelocityAnimationGroup/props/propTypes.js +3 -0
- package/lib/VelocityAnimation/index.js +3 -0
- package/lib/css.js +40 -0
- package/lib/deprecated/PortalLayer/PortalLayer.js +46 -23
- package/lib/deprecated/PortalLayer/props/propTypes.js +3 -0
- package/lib/index.js +57 -0
- package/lib/semantic/Button/Button.js +42 -22
- package/lib/semantic/Button/props/propTypes.js +3 -0
- package/lib/semantic/index.js +2 -0
- package/lib/utils/Common.js +110 -18
- package/lib/utils/ContextOptimizer.js +16 -10
- package/lib/utils/__tests__/constructFullName.spec.js +1 -0
- package/lib/utils/__tests__/debounce.spec.js +3 -2
- package/lib/utils/__tests__/getInitial.spec.js +1 -0
- package/lib/utils/constructFullName.js +13 -4
- package/lib/utils/css/compileClassNames.js +6 -0
- package/lib/utils/css/mergeStyle.js +10 -7
- package/lib/utils/css/utils.js +8 -0
- package/lib/utils/datetime/GMTZones.js +55 -0
- package/lib/utils/datetime/common.js +52 -7
- package/lib/utils/debounce.js +6 -1
- package/lib/utils/dropDownUtils.js +175 -59
- package/lib/utils/dummyFunction.js +2 -0
- package/lib/utils/getHTMLFontSize.js +1 -0
- package/lib/utils/getInitial.js +6 -0
- package/lib/utils/index.js +4 -0
- package/lib/utils/scrollTo.js +2 -0
- package/lib/utils/shallowEqual.js +8 -0
- package/package.json +1 -1
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { MultiSelect_propTypes } from './props/propTypes';
|
|
4
4
|
import { MultiSelect_defaultProps } from './props/defaultProps';
|
|
5
|
-
|
|
6
5
|
/**** Components ****/
|
|
6
|
+
|
|
7
7
|
import Popup from '../Popup/Popup';
|
|
8
8
|
import TextBoxIcon from '../TextBoxIcon/TextBoxIcon';
|
|
9
9
|
import { Container, Box } from '../Layout';
|
|
@@ -18,16 +18,18 @@ import ResponsiveDropBox from '../ResponsiveDropBox/ResponsiveDropBox';
|
|
|
18
18
|
import { ResponsiveReceiver } from '../Responsive/CustomResponsive';
|
|
19
19
|
import Loader from '@zohodesk/svg/lib/Loader/Loader';
|
|
20
20
|
/**** Icons ****/
|
|
21
|
+
|
|
21
22
|
import { Icon } from '@zohodesk/icons';
|
|
22
23
|
/**** CSS ****/
|
|
23
|
-
import style from './MultiSelect.module.css';
|
|
24
24
|
|
|
25
|
+
import style from './MultiSelect.module.css';
|
|
25
26
|
/**** Methods ****/
|
|
27
|
+
|
|
26
28
|
import { debounce, scrollTo, bind, getIsEmptyValue, getSearchString, findScrollEnd } from '../utils/Common.js';
|
|
27
29
|
import { makeFormatOptions, makeGetMultiSelectFilterSuggestions as makeGetFilterSuggestions, makeGetMultiSelectSelectedOptions as makeGetSelectedOptions, makeObjectConcat, filterSelectedOptions, makeGetIsShowClearIcon } from '../utils/dropDownUtils';
|
|
28
30
|
import { getLibraryConfig } from '../Provider/Config';
|
|
29
|
-
|
|
30
31
|
/* eslint-disable react/forbid-component-props */
|
|
32
|
+
|
|
31
33
|
/* eslint-disable react/no-unused-prop-types */
|
|
32
34
|
|
|
33
35
|
const dummyArray = [];
|
|
@@ -38,9 +40,8 @@ export class MultiSelectComponent extends React.Component {
|
|
|
38
40
|
this.getFilterSuggestions = makeGetFilterSuggestions();
|
|
39
41
|
this.formatOptions = makeFormatOptions();
|
|
40
42
|
this.getSelectedOptions = makeGetSelectedOptions();
|
|
41
|
-
this.getIsShowClearIcon = makeGetIsShowClearIcon();
|
|
43
|
+
this.getIsShowClearIcon = makeGetIsShowClearIcon(); //Use in AdvancedMultiSelect component
|
|
42
44
|
|
|
43
|
-
//Use in AdvancedMultiSelect component
|
|
44
45
|
this.objectConcat = makeObjectConcat();
|
|
45
46
|
this.formatSelectedOptions = makeFormatOptions();
|
|
46
47
|
const {
|
|
@@ -78,11 +79,11 @@ export class MultiSelectComponent extends React.Component {
|
|
|
78
79
|
this.handleScroll = this.handleScroll.bind(this);
|
|
79
80
|
this.handleScrollFuncCall = debounce(this.handleScrollFuncCall.bind(this), 500);
|
|
80
81
|
}
|
|
82
|
+
|
|
81
83
|
componentDidMount() {
|
|
82
84
|
// let { suggestionContainer } = this;
|
|
83
85
|
this._isMounted = true;
|
|
84
|
-
this.handleExposedPublicMethods();
|
|
85
|
-
// suggestionContainer &&
|
|
86
|
+
this.handleExposedPublicMethods(); // suggestionContainer &&
|
|
86
87
|
// suggestionContainer.addEventListener('scroll', this.handleScroll);
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -95,6 +96,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
95
96
|
prefixText
|
|
96
97
|
} = nextProps;
|
|
97
98
|
const oldProps = this.props;
|
|
99
|
+
|
|
98
100
|
if (selectedOptions !== oldProps.selectedOptions || options !== oldProps.options || valueField !== oldProps.valueField || textField !== oldProps.textField || prefixText !== oldProps.prefixText //For GroupMultiSelect component
|
|
99
101
|
) {
|
|
100
102
|
const {
|
|
@@ -133,6 +135,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
133
135
|
});
|
|
134
136
|
}
|
|
135
137
|
}
|
|
138
|
+
|
|
136
139
|
componentDidUpdate(prevProps, prevState) {
|
|
137
140
|
const {
|
|
138
141
|
suggestionContainer,
|
|
@@ -151,11 +154,11 @@ export class MultiSelectComponent extends React.Component {
|
|
|
151
154
|
onDropBoxClose,
|
|
152
155
|
onDropBoxOpen,
|
|
153
156
|
isSearchClearOnClose
|
|
154
|
-
} = this.props;
|
|
157
|
+
} = this.props; //handle dropbox open & close
|
|
155
158
|
|
|
156
|
-
//handle dropbox open & close
|
|
157
159
|
if (prevProps.isPopupOpen !== isPopupOpen) {
|
|
158
160
|
isPopupOpen && onDropBoxOpen && this.handleFetchOptions(onDropBoxOpen, searchStr);
|
|
161
|
+
|
|
159
162
|
if (!isPopupOpen) {
|
|
160
163
|
this.setState({
|
|
161
164
|
hoverOption: 0
|
|
@@ -163,41 +166,42 @@ export class MultiSelectComponent extends React.Component {
|
|
|
163
166
|
isSearchClearOnClose && searchStr && this.handleSearch('');
|
|
164
167
|
onDropBoxClose && onDropBoxClose();
|
|
165
168
|
}
|
|
166
|
-
}
|
|
169
|
+
} //scrollTo handling
|
|
170
|
+
|
|
167
171
|
|
|
168
|
-
//scrollTo handling
|
|
169
172
|
const hoverId = suggestionsOrder[hoverOption] || '';
|
|
170
173
|
const selectedSuggestion = this[`suggestion_${hoverId}`];
|
|
171
174
|
const lastHighLightedSelectOption = highLightedSelectOptions.slice(-1).length ? highLightedSelectOptions.slice(-1)[0] : null;
|
|
172
175
|
const selectedOption = this[`selectedOption_${lastHighLightedSelectOption}`];
|
|
173
176
|
isPopupOpen && scrollTo(suggestionContainer, selectedSuggestion);
|
|
174
|
-
selectedOptions.length && selectedOption && scrollTo(selectedOptionContainer, selectedOption);
|
|
177
|
+
selectedOptions.length && selectedOption && scrollTo(selectedOptionContainer, selectedOption); //When suggestions length less than 5, getNextOptions function call
|
|
175
178
|
|
|
176
|
-
//When suggestions length less than 5, getNextOptions function call
|
|
177
179
|
const {
|
|
178
180
|
isNextOptions,
|
|
179
181
|
getNextOptions
|
|
180
|
-
} = this.props;
|
|
181
|
-
|
|
182
|
+
} = this.props; // let { searchStr } = this.state;
|
|
183
|
+
|
|
182
184
|
const suggestions = this.handleFilterSuggestions();
|
|
183
185
|
const suggestionsLen = suggestions.length;
|
|
186
|
+
|
|
184
187
|
if (isPopupOpen && suggestionsLen <= 5 && isNextOptions && getNextOptions && !needLocalSearch) {
|
|
185
188
|
this.handleFetchOptions(getNextOptions, searchStr);
|
|
186
|
-
}
|
|
189
|
+
} //Need To MultiselectNew Component
|
|
190
|
+
|
|
187
191
|
|
|
188
|
-
//Need To MultiselectNew Component
|
|
189
192
|
this.handleComponentDidUpdate(prevProps, prevState);
|
|
190
193
|
}
|
|
194
|
+
|
|
191
195
|
componentWillUnmount() {
|
|
192
196
|
// let { suggestionContainer } = this;
|
|
193
|
-
this._isMounted = false;
|
|
194
|
-
// suggestionContainer &&
|
|
197
|
+
this._isMounted = false; // suggestionContainer &&
|
|
195
198
|
// suggestionContainer.removeEventListener('scroll', this.handleScroll);
|
|
196
199
|
}
|
|
197
200
|
|
|
198
201
|
handleComponentDidUpdate() {
|
|
199
202
|
return;
|
|
200
203
|
}
|
|
204
|
+
|
|
201
205
|
handleFormatOptions(props) {
|
|
202
206
|
const {
|
|
203
207
|
options,
|
|
@@ -215,12 +219,14 @@ export class MultiSelectComponent extends React.Component {
|
|
|
215
219
|
disabledOptions
|
|
216
220
|
});
|
|
217
221
|
}
|
|
222
|
+
|
|
218
223
|
handleGetSelectedOptions(selectedOptions, normalizedFormatOptions) {
|
|
219
224
|
return this.getSelectedOptions({
|
|
220
225
|
selectedOptions,
|
|
221
226
|
normalizedFormatOptions
|
|
222
227
|
});
|
|
223
228
|
}
|
|
229
|
+
|
|
224
230
|
handleInputCick(e) {
|
|
225
231
|
const {
|
|
226
232
|
removeClose
|
|
@@ -229,6 +235,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
229
235
|
highLightedSelectOptions,
|
|
230
236
|
searchStr = ''
|
|
231
237
|
} = this.state;
|
|
238
|
+
|
|
232
239
|
if (highLightedSelectOptions.length) {
|
|
233
240
|
this.setState({
|
|
234
241
|
highLightedSelectOptions: [],
|
|
@@ -242,6 +249,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
242
249
|
this.togglePopup(e);
|
|
243
250
|
}
|
|
244
251
|
}
|
|
252
|
+
|
|
245
253
|
handleFilterSuggestions() {
|
|
246
254
|
const {
|
|
247
255
|
options = dummyArray,
|
|
@@ -265,6 +273,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
265
273
|
this.suggestionsOrder = suggestionIds;
|
|
266
274
|
return suggestions;
|
|
267
275
|
}
|
|
276
|
+
|
|
268
277
|
handleKeyDown(e) {
|
|
269
278
|
const {
|
|
270
279
|
keyCode,
|
|
@@ -289,20 +298,27 @@ export class MultiSelectComponent extends React.Component {
|
|
|
289
298
|
onKeyDown
|
|
290
299
|
} = this.props;
|
|
291
300
|
const highLightedSelectOptionsLen = highLightedSelectOptions.length;
|
|
301
|
+
|
|
292
302
|
if (isPopupOpen && (keyCode === 38 || keyCode === 40 || keyCode === 13 || keyCode === 27 || keyCode === 9)) {
|
|
293
303
|
suggestions = this.handleFilterSuggestions();
|
|
294
304
|
}
|
|
305
|
+
|
|
295
306
|
if (!isPopupOpen && !isPopupOpenOnEnter) {
|
|
296
307
|
onKeyDown && onKeyDown(e);
|
|
297
308
|
}
|
|
309
|
+
|
|
298
310
|
if (!isPopupOpen && keyCode === 40) {
|
|
299
311
|
//down arrow press popup open
|
|
300
312
|
e.preventDefault(); //prevent body scroll
|
|
313
|
+
|
|
301
314
|
this.togglePopup(e);
|
|
302
315
|
}
|
|
316
|
+
|
|
303
317
|
const suggestionsLen = suggestions.length;
|
|
318
|
+
|
|
304
319
|
if (suggestionsLen && isPopupOpen && keyCode === 38) {
|
|
305
320
|
//up arrow
|
|
321
|
+
|
|
306
322
|
/*if (hoverOption === 0) { //disable first to last option higlight
|
|
307
323
|
!isNextOptions && this.setState({ hoverOption: suggestionsLen - 1 });
|
|
308
324
|
}*/
|
|
@@ -313,6 +329,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
313
329
|
}
|
|
314
330
|
} else if (suggestionsLen && isPopupOpen && keyCode === 40) {
|
|
315
331
|
//down arrow
|
|
332
|
+
|
|
316
333
|
/*else if (hoverOption === suggestionsLen - 1 || hoverOption === null) {
|
|
317
334
|
//disable last to first option higlight
|
|
318
335
|
!isNextOptions && this.setState({ hoverOption: 0 });
|
|
@@ -340,8 +357,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
340
357
|
if (highLightedSelectOptionsLen) {
|
|
341
358
|
this.handleRemoveOption(highLightedSelectOptions);
|
|
342
359
|
} else {
|
|
343
|
-
this.handleRemoveOption(selectedOptions.slice(-1));
|
|
344
|
-
// this.setState({
|
|
360
|
+
this.handleRemoveOption(selectedOptions.slice(-1)); // this.setState({
|
|
345
361
|
// highLightedSelectOptions: selectedOptions.slice(-1)
|
|
346
362
|
// });
|
|
347
363
|
}
|
|
@@ -356,6 +372,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
356
372
|
const lastHighLightedSelectOptionIndex = lastHighLightedSelectOption && selectedOptions.indexOf(lastHighLightedSelectOption) >= 0 ? selectedOptions.indexOf(lastHighLightedSelectOption) : 0;
|
|
357
373
|
const newShiftKeyPressHighLighted = shiftKeyPressHighLighted ? shiftKeyPressHighLighted : shiftKeyPressHighLighted + 1;
|
|
358
374
|
const newHighLightedSelectOption = lastHighLightedSelectOptionIndex !== null ? selectedOptions[lastHighLightedSelectOptionIndex + newShiftKeyPressHighLighted] : selectedOptions[0];
|
|
375
|
+
|
|
359
376
|
if (!getIsEmptyValue(newHighLightedSelectOption)) {
|
|
360
377
|
const newLastHighLightedSelectOption = lastHighLightedSelectOption ? lastHighLightedSelectOption : selectedOptions[0];
|
|
361
378
|
highLightedSelectOptions = !shiftKeyPressHighLighted ? [newLastHighLightedSelectOption] : highLightedSelectOptions;
|
|
@@ -372,6 +389,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
372
389
|
const lastHighLightedSelectOptionIndex = lastHighLightedSelectOption ? selectedOptions.indexOf(lastHighLightedSelectOption) : selectedOptions.length - 1;
|
|
373
390
|
const newShiftKeyPressHighLighted = shiftKeyPressHighLighted !== 1 ? shiftKeyPressHighLighted : shiftKeyPressHighLighted - 1;
|
|
374
391
|
const newHighLightedSelectOption = selectedOptions[lastHighLightedSelectOptionIndex + newShiftKeyPressHighLighted - 1];
|
|
392
|
+
|
|
375
393
|
if (!getIsEmptyValue(newHighLightedSelectOption)) {
|
|
376
394
|
const newLastHighLightedSelectOption = lastHighLightedSelectOption ? lastHighLightedSelectOption : selectedOptions.slice(-1)[0];
|
|
377
395
|
highLightedSelectOptions = !shiftKeyPressHighLighted ? [newLastHighLightedSelectOption] : highLightedSelectOptions;
|
|
@@ -384,14 +402,15 @@ export class MultiSelectComponent extends React.Component {
|
|
|
384
402
|
});
|
|
385
403
|
}
|
|
386
404
|
} else if ((keyCode === 39 || keyCode === 37) && selectedOptions.length && !searchStr.length) {
|
|
387
|
-
const isRightArrow = keyCode === 39 ? true : false;
|
|
388
|
-
|
|
405
|
+
const isRightArrow = keyCode === 39 ? true : false; // let isLefttArrow = keyCode === 37 ? true : false;
|
|
406
|
+
|
|
389
407
|
if (highLightedSelectOptions.length) {
|
|
390
408
|
const [lastHighLightedSelectOption] = highLightedSelectOptions.slice(-1);
|
|
391
409
|
const lastHighLightedSelectOptionIndex = selectedOptions.indexOf(lastHighLightedSelectOption);
|
|
392
410
|
const newLastHighLightedSelectOptionIndex = isRightArrow ? lastHighLightedSelectOptionIndex === selectedOptions.length - 1 ? lastHighLightedSelectOptionIndex : lastHighLightedSelectOptionIndex + 1 : lastHighLightedSelectOptionIndex - 1;
|
|
393
411
|
const newLastHighLightedSelectOption = selectedOptions[newLastHighLightedSelectOptionIndex];
|
|
394
412
|
const isEmptyHighlighted = isRightArrow && highLightedSelectOptions.length === 1 && selectedOptions.slice(-1)[0] === lastHighLightedSelectOption ? true : false;
|
|
413
|
+
|
|
395
414
|
if (!getIsEmptyValue(newLastHighLightedSelectOption)) {
|
|
396
415
|
this.setState({
|
|
397
416
|
lastHighLightedSelectOption: isEmptyHighlighted ? '' : newLastHighLightedSelectOption,
|
|
@@ -407,12 +426,12 @@ export class MultiSelectComponent extends React.Component {
|
|
|
407
426
|
shiftKeyPressHighLighted: 0
|
|
408
427
|
});
|
|
409
428
|
}
|
|
410
|
-
} else if (keyCode === 27) {
|
|
411
|
-
// this.handlePopupClose(e);
|
|
429
|
+
} else if (keyCode === 27) {// this.handlePopupClose(e);
|
|
412
430
|
} else if (keyCode === 9) {
|
|
413
431
|
this.handlePopupClose(e);
|
|
414
432
|
}
|
|
415
433
|
}
|
|
434
|
+
|
|
416
435
|
handleSelectAll(e) {
|
|
417
436
|
e && e.preventDefault();
|
|
418
437
|
const suggestions = this.handleFilterSuggestions();
|
|
@@ -424,12 +443,12 @@ export class MultiSelectComponent extends React.Component {
|
|
|
424
443
|
const {
|
|
425
444
|
id
|
|
426
445
|
} = option;
|
|
446
|
+
|
|
427
447
|
if (selectedOptions.indexOf(id) === -1) {
|
|
428
448
|
newSelectedOptions.push(id);
|
|
429
449
|
}
|
|
430
450
|
});
|
|
431
|
-
this.handleChange([...selectedOptions, ...newSelectedOptions]);
|
|
432
|
-
// this.handlePopupClose(e);
|
|
451
|
+
this.handleChange([...selectedOptions, ...newSelectedOptions]); // this.handlePopupClose(e);
|
|
433
452
|
}
|
|
434
453
|
|
|
435
454
|
handleDeselectAll(e) {
|
|
@@ -440,15 +459,18 @@ export class MultiSelectComponent extends React.Component {
|
|
|
440
459
|
const {
|
|
441
460
|
highLightedSelectOptions
|
|
442
461
|
} = this.state;
|
|
462
|
+
|
|
443
463
|
if (highLightedSelectOptions.length) {
|
|
444
464
|
this.setState({
|
|
445
465
|
highLightedSelectOptions: [],
|
|
446
466
|
lastHighLightedSelectOption: ''
|
|
447
467
|
});
|
|
448
468
|
}
|
|
469
|
+
|
|
449
470
|
removeClose(e);
|
|
450
471
|
this.handleChange([]);
|
|
451
472
|
}
|
|
473
|
+
|
|
452
474
|
handleSelectOption(option, value, index, e) {
|
|
453
475
|
const {
|
|
454
476
|
selectedOptions,
|
|
@@ -458,9 +480,11 @@ export class MultiSelectComponent extends React.Component {
|
|
|
458
480
|
const {
|
|
459
481
|
searchStr
|
|
460
482
|
} = this.state;
|
|
483
|
+
|
|
461
484
|
if (searchStr.trim() != '' && isSearchClearOnSelect) {
|
|
462
485
|
this.handleSearch('');
|
|
463
486
|
}
|
|
487
|
+
|
|
464
488
|
if (keepSelectedOptions && selectedOptions.indexOf(option) != -1) {
|
|
465
489
|
let newSelectedOptions = selectedOptions.filter(id => {
|
|
466
490
|
return id != option;
|
|
@@ -470,6 +494,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
470
494
|
this.handleChange([...selectedOptions, option], e);
|
|
471
495
|
}
|
|
472
496
|
}
|
|
497
|
+
|
|
473
498
|
handleRemoveOption(options) {
|
|
474
499
|
const newOptions = !getIsEmptyValue(options) && !Array.isArray(options) ? [options] : options;
|
|
475
500
|
const {
|
|
@@ -481,18 +506,22 @@ export class MultiSelectComponent extends React.Component {
|
|
|
481
506
|
lastHighLightedSelectOption,
|
|
482
507
|
shiftKeyPressHighLighted
|
|
483
508
|
} = this.state;
|
|
509
|
+
|
|
484
510
|
if (newOptions.length && !isReadOnly) {
|
|
485
511
|
const newSelectedOptions = selectedOptions.filter(option => newOptions.indexOf(option) === -1);
|
|
486
512
|
const newHighLightedSelectOptions = highLightedSelectOptions.filter(option => newSelectedOptions.indexOf(option) >= 0);
|
|
487
513
|
let isHighlightedRemoved = false;
|
|
488
514
|
const newOptionsLen = newOptions.length;
|
|
515
|
+
|
|
489
516
|
for (let i = 0; i < newOptionsLen; i++) {
|
|
490
517
|
const removedOption = newOptions[i];
|
|
518
|
+
|
|
491
519
|
if (highLightedSelectOptions.indexOf(removedOption) >= 0) {
|
|
492
520
|
isHighlightedRemoved = true;
|
|
493
521
|
break;
|
|
494
522
|
}
|
|
495
523
|
}
|
|
524
|
+
|
|
496
525
|
this.setState({
|
|
497
526
|
lastHighLightedSelectOption: newSelectedOptions.indexOf(lastHighLightedSelectOption) >= 0 && !isHighlightedRemoved ? lastHighLightedSelectOption : '',
|
|
498
527
|
highLightedSelectOptions: isHighlightedRemoved ? [] : newHighLightedSelectOptions,
|
|
@@ -500,10 +529,12 @@ export class MultiSelectComponent extends React.Component {
|
|
|
500
529
|
});
|
|
501
530
|
this.handleChange(newSelectedOptions);
|
|
502
531
|
}
|
|
532
|
+
|
|
503
533
|
this.searchInput && this.searchInput.focus({
|
|
504
534
|
preventScroll: true
|
|
505
535
|
});
|
|
506
536
|
}
|
|
537
|
+
|
|
507
538
|
handleMouseEnter(id, val, hoverOptionIndex, e) {
|
|
508
539
|
e && e.preventDefault();
|
|
509
540
|
const {
|
|
@@ -513,16 +544,19 @@ export class MultiSelectComponent extends React.Component {
|
|
|
513
544
|
suggestionsOrder
|
|
514
545
|
} = this;
|
|
515
546
|
const newHoverIndex = suggestionsOrder.indexOf(id);
|
|
547
|
+
|
|
516
548
|
if (newHoverIndex !== hoverOption) {
|
|
517
549
|
this.setState({
|
|
518
550
|
hoverOption: newHoverIndex
|
|
519
551
|
});
|
|
520
552
|
}
|
|
521
553
|
}
|
|
554
|
+
|
|
522
555
|
handleFetchOptions() {
|
|
523
556
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
524
557
|
args[_key] = arguments[_key];
|
|
525
558
|
}
|
|
559
|
+
|
|
526
560
|
const [APICall, searchStr] = args;
|
|
527
561
|
const {
|
|
528
562
|
isFetchingOptions
|
|
@@ -531,10 +565,12 @@ export class MultiSelectComponent extends React.Component {
|
|
|
531
565
|
_isMounted
|
|
532
566
|
} = this;
|
|
533
567
|
const isForce = isFetchingOptions && searchStr ? true : false;
|
|
568
|
+
|
|
534
569
|
if (!isFetchingOptions && APICall || isForce) {
|
|
535
570
|
this.setState({
|
|
536
571
|
isFetchingOptions: true
|
|
537
572
|
});
|
|
573
|
+
|
|
538
574
|
try {
|
|
539
575
|
return APICall(searchStr).then(() => {
|
|
540
576
|
_isMounted && this.setState({
|
|
@@ -552,6 +588,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
552
588
|
}
|
|
553
589
|
}
|
|
554
590
|
}
|
|
591
|
+
|
|
555
592
|
handleSearchOptions() {
|
|
556
593
|
const {
|
|
557
594
|
onSearch
|
|
@@ -561,6 +598,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
561
598
|
} = this.state;
|
|
562
599
|
searchStr && this.handleFetchOptions(onSearch, searchStr);
|
|
563
600
|
}
|
|
601
|
+
|
|
564
602
|
handleSearch(value, e) {
|
|
565
603
|
const {
|
|
566
604
|
onSearch,
|
|
@@ -583,6 +621,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
583
621
|
}
|
|
584
622
|
});
|
|
585
623
|
}
|
|
624
|
+
|
|
586
625
|
handleClickSelectedOption() {
|
|
587
626
|
let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
588
627
|
let e = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -598,13 +637,16 @@ export class MultiSelectComponent extends React.Component {
|
|
|
598
637
|
ctrlKey,
|
|
599
638
|
shiftKey
|
|
600
639
|
} = e;
|
|
640
|
+
|
|
601
641
|
if (e && shiftKey) {
|
|
602
642
|
//shift+click
|
|
603
643
|
let from = selectedOptions.indexOf(lastHighLightedSelectOption) >= 0 ? selectedOptions.indexOf(lastHighLightedSelectOption) : 0;
|
|
604
644
|
let to = id && selectedOptions.indexOf(id) >= 0 ? selectedOptions.indexOf(id) : null;
|
|
645
|
+
|
|
605
646
|
if (to >= 0 && to < from) {
|
|
606
647
|
[to] = [from, from = to];
|
|
607
648
|
}
|
|
649
|
+
|
|
608
650
|
to += 1;
|
|
609
651
|
const newSelectedHighlights = to ? selectedOptions.slice(from, to) : [];
|
|
610
652
|
to && this.setState({
|
|
@@ -615,6 +657,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
615
657
|
//ctrl+click
|
|
616
658
|
const isRemove = highLightedSelectOptions.indexOf(id) >= 0;
|
|
617
659
|
let newSelectedHighlights = [];
|
|
660
|
+
|
|
618
661
|
if (isRemove) {
|
|
619
662
|
lastHighLightedSelectOption = id === lastHighLightedSelectOption ? '' : lastHighLightedSelectOption;
|
|
620
663
|
newSelectedHighlights = highLightedSelectOptions.filter(option => option !== id);
|
|
@@ -622,6 +665,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
622
665
|
lastHighLightedSelectOption = id;
|
|
623
666
|
newSelectedHighlights = [...highLightedSelectOptions, id];
|
|
624
667
|
}
|
|
668
|
+
|
|
625
669
|
this.setState({
|
|
626
670
|
highLightedSelectOptions: newSelectedHighlights,
|
|
627
671
|
lastHighLightedSelectOption
|
|
@@ -632,6 +676,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
632
676
|
lastHighLightedSelectOption: id
|
|
633
677
|
});
|
|
634
678
|
}
|
|
679
|
+
|
|
635
680
|
this.setState({
|
|
636
681
|
shiftKeyPressHighLighted: 0
|
|
637
682
|
});
|
|
@@ -639,11 +684,13 @@ export class MultiSelectComponent extends React.Component {
|
|
|
639
684
|
preventScroll: true
|
|
640
685
|
});
|
|
641
686
|
}
|
|
687
|
+
|
|
642
688
|
handleScroll(e) {
|
|
643
689
|
let ele = e.target;
|
|
644
690
|
let isScrollReachedBottom = findScrollEnd(ele);
|
|
645
691
|
isScrollReachedBottom && this.handleScrollFuncCall();
|
|
646
692
|
}
|
|
693
|
+
|
|
647
694
|
handleScrollFuncCall() {
|
|
648
695
|
const {
|
|
649
696
|
getNextOptions,
|
|
@@ -654,6 +701,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
654
701
|
} = this.state;
|
|
655
702
|
isNextOptions && getNextOptions && this.handleFetchOptions(getNextOptions, searchStr);
|
|
656
703
|
}
|
|
704
|
+
|
|
657
705
|
handleChange() {
|
|
658
706
|
let selectedOptions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
659
707
|
let e = arguments.length > 1 ? arguments[1] : undefined;
|
|
@@ -676,19 +724,23 @@ export class MultiSelectComponent extends React.Component {
|
|
|
676
724
|
});
|
|
677
725
|
const selectedOptionsLen = newSelectedOptions.length;
|
|
678
726
|
const allSelectedOptionsDetails = [];
|
|
727
|
+
|
|
679
728
|
for (let i = 0; i < selectedOptionsLen; i++) {
|
|
680
729
|
const id = newSelectedOptions[i];
|
|
681
730
|
allSelectedOptionsDetails.push(optionsNormalize[id]);
|
|
682
731
|
}
|
|
683
|
-
|
|
684
|
-
// this.setState({ searchStr: '' });
|
|
732
|
+
|
|
733
|
+
onChange && onChange(newSelectedOptions, allSelectedOptionsDetails); // this.setState({ searchStr: '' });
|
|
734
|
+
|
|
685
735
|
this.searchInput && this.searchInput.focus({
|
|
686
736
|
preventScroll: true
|
|
687
737
|
});
|
|
738
|
+
|
|
688
739
|
if (needToCloseOnSelect) {
|
|
689
740
|
togglePopup(e);
|
|
690
741
|
}
|
|
691
742
|
}
|
|
743
|
+
|
|
692
744
|
togglePopup(e) {
|
|
693
745
|
const {
|
|
694
746
|
togglePopup,
|
|
@@ -697,12 +749,14 @@ export class MultiSelectComponent extends React.Component {
|
|
|
697
749
|
} = this.props;
|
|
698
750
|
!isReadOnly && togglePopup(e, defaultDropBoxPosition ? `${defaultDropBoxPosition}` : null);
|
|
699
751
|
}
|
|
752
|
+
|
|
700
753
|
handlePopupClose(e) {
|
|
701
754
|
const {
|
|
702
755
|
closePopupOnly
|
|
703
756
|
} = this.props;
|
|
704
757
|
closePopupOnly(e);
|
|
705
758
|
}
|
|
759
|
+
|
|
706
760
|
searchInputRef(el) {
|
|
707
761
|
const {
|
|
708
762
|
getRef
|
|
@@ -710,6 +764,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
710
764
|
this.searchInput = el;
|
|
711
765
|
getRef && getRef(el);
|
|
712
766
|
}
|
|
767
|
+
|
|
713
768
|
selectedOptionContainerRef(el) {
|
|
714
769
|
const {
|
|
715
770
|
getTargetRef
|
|
@@ -717,25 +772,31 @@ export class MultiSelectComponent extends React.Component {
|
|
|
717
772
|
this.selectedOptionContainer = el;
|
|
718
773
|
getTargetRef(el);
|
|
719
774
|
}
|
|
775
|
+
|
|
720
776
|
selectedOptionRef(el, id) {
|
|
721
777
|
this[`selectedOption_${id}`] = el;
|
|
722
778
|
}
|
|
779
|
+
|
|
723
780
|
suggestionContainerRef(el) {
|
|
724
781
|
this.suggestionContainer = el;
|
|
725
782
|
}
|
|
783
|
+
|
|
726
784
|
suggestionItemRef(el, index, id) {
|
|
727
785
|
this[`suggestion_${id}`] = el;
|
|
728
786
|
}
|
|
787
|
+
|
|
729
788
|
handleActive(e) {
|
|
730
789
|
const {
|
|
731
790
|
searchStr,
|
|
732
791
|
isActive
|
|
733
792
|
} = this.state;
|
|
793
|
+
|
|
734
794
|
if (!isActive) {
|
|
735
795
|
this.setState({
|
|
736
796
|
isActive: true
|
|
737
797
|
});
|
|
738
798
|
}
|
|
799
|
+
|
|
739
800
|
const {
|
|
740
801
|
target
|
|
741
802
|
} = e || {};
|
|
@@ -745,16 +806,19 @@ export class MultiSelectComponent extends React.Component {
|
|
|
745
806
|
} = this.props;
|
|
746
807
|
onFocus && onFocus(searchStr);
|
|
747
808
|
}
|
|
809
|
+
|
|
748
810
|
handleInactive() {
|
|
749
811
|
const {
|
|
750
812
|
isActive
|
|
751
813
|
} = this.state;
|
|
814
|
+
|
|
752
815
|
if (isActive) {
|
|
753
816
|
this.setState({
|
|
754
817
|
isActive: false
|
|
755
818
|
});
|
|
756
819
|
}
|
|
757
820
|
}
|
|
821
|
+
|
|
758
822
|
handleInputFocus() {
|
|
759
823
|
const {
|
|
760
824
|
isDisabled,
|
|
@@ -764,6 +828,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
764
828
|
preventScroll: true
|
|
765
829
|
});
|
|
766
830
|
}
|
|
831
|
+
|
|
767
832
|
handleExposedPublicMethods() {
|
|
768
833
|
const {
|
|
769
834
|
getPublicMethods,
|
|
@@ -773,6 +838,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
773
838
|
openPopupOnly
|
|
774
839
|
});
|
|
775
840
|
}
|
|
841
|
+
|
|
776
842
|
responsiveFunc(_ref) {
|
|
777
843
|
let {
|
|
778
844
|
mediaQueryOR
|
|
@@ -783,6 +849,7 @@ export class MultiSelectComponent extends React.Component {
|
|
|
783
849
|
}])
|
|
784
850
|
};
|
|
785
851
|
}
|
|
852
|
+
|
|
786
853
|
render() {
|
|
787
854
|
let {
|
|
788
855
|
isReadOnly,
|
|
@@ -1013,16 +1080,16 @@ export class MultiSelectComponent extends React.Component {
|
|
|
1013
1080
|
}, /*#__PURE__*/React.createElement(Loader, null))), getFooter ? /*#__PURE__*/React.createElement(CardFooter, null, getFooter()) : null)));
|
|
1014
1081
|
}) : null);
|
|
1015
1082
|
}
|
|
1083
|
+
|
|
1016
1084
|
}
|
|
1017
1085
|
MultiSelectComponent.propTypes = MultiSelect_propTypes;
|
|
1018
|
-
MultiSelectComponent.defaultProps = MultiSelect_defaultProps;
|
|
1019
|
-
|
|
1020
|
-
// if (__DOCS__) {
|
|
1086
|
+
MultiSelectComponent.defaultProps = MultiSelect_defaultProps; // if (__DOCS__) {
|
|
1021
1087
|
// MultiSelectComponent.docs = {
|
|
1022
1088
|
// componentGroup: 'Form Elements',
|
|
1023
1089
|
// folderName: 'Style Guide'
|
|
1024
1090
|
// };
|
|
1025
1091
|
// }
|
|
1092
|
+
|
|
1026
1093
|
MultiSelectComponent.displayName = 'MultiSelect';
|
|
1027
1094
|
const MultiSelect = Popup(MultiSelectComponent);
|
|
1028
1095
|
MultiSelect.propTypes = MultiSelectComponent.propTypes;
|
|
@@ -3,8 +3,10 @@ import React from 'react';
|
|
|
3
3
|
import { MultiSelectHeader_propTypes } from './props/propTypes';
|
|
4
4
|
import { MultiSelectHeader_defaultProps } from './props/defaultProps';
|
|
5
5
|
/**** Icons ****/
|
|
6
|
+
|
|
6
7
|
import ListItemWithIcon from '../ListItem/ListItemWithIcon';
|
|
7
8
|
/**** CSS ****/
|
|
9
|
+
|
|
8
10
|
import style from './MultiSelect.module.css';
|
|
9
11
|
export default class MultiSelectHeader extends React.PureComponent {
|
|
10
12
|
render() {
|
|
@@ -25,6 +27,7 @@ export default class MultiSelectHeader extends React.PureComponent {
|
|
|
25
27
|
customClass: style.selectAll
|
|
26
28
|
}) : null);
|
|
27
29
|
}
|
|
30
|
+
|
|
28
31
|
}
|
|
29
32
|
MultiSelectHeader.propTypes = MultiSelectHeader_propTypes;
|
|
30
33
|
MultiSelectHeader.defaultProps = MultiSelectHeader_defaultProps;
|