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