intelicoreact 1.3.21 → 1.3.22
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/dist/Atomic/FormElements/ActionAlert/ActionAlert.js +15 -23
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +15 -23
- package/dist/Atomic/FormElements/Calendar/Calendar.js +69 -124
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +27 -36
- package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +23 -39
- package/dist/Atomic/FormElements/Datepicker/Datepicker.js +110 -246
- package/dist/Atomic/FormElements/Datepicker/components/Calendar.js +44 -85
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +246 -414
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +5 -9
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +93 -165
- package/dist/Atomic/FormElements/FileLoader/FileLoader.js +39 -64
- package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +51 -132
- package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +34 -73
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +54 -75
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +67 -110
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +33 -83
- package/dist/Atomic/FormElements/Input/Input.js +161 -253
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +48 -102
- package/dist/Atomic/FormElements/InputColor/InputColor.js +27 -40
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +28 -58
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +108 -176
- package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +32 -57
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +184 -302
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +85 -157
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +11 -16
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +76 -193
- package/dist/Atomic/FormElements/InputLink/InputLink.js +34 -58
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +8 -12
- package/dist/Atomic/FormElements/InputMask/InputMask.js +554 -964
- package/dist/Atomic/FormElements/InputMask/config.js +1 -1
- package/dist/Atomic/FormElements/InputMask/functions.js +17 -43
- package/dist/Atomic/FormElements/InputMask2/InputMask2.js +268 -404
- package/dist/Atomic/FormElements/InputMask2/config.js +1 -1
- package/dist/Atomic/FormElements/InputMask2/functions.js +17 -43
- package/dist/Atomic/FormElements/InputMask3/InputMask3.js +300 -460
- package/dist/Atomic/FormElements/InputMask3/config.js +1 -1
- package/dist/Atomic/FormElements/InputMask3/functions.js +17 -43
- package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +53 -113
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +64 -118
- package/dist/Atomic/FormElements/Label/Label.js +13 -23
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +217 -349
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +25 -47
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +133 -207
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +29 -61
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +20 -42
- package/dist/Atomic/FormElements/RadioInput/RadioInput.js +22 -33
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +20 -43
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +54 -101
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +59 -102
- package/dist/Atomic/FormElements/RangeList/RangeList.js +89 -150
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +23 -29
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +135 -300
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +381 -571
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +14 -24
- package/dist/Atomic/FormElements/Switcher/Switcher.js +24 -29
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +25 -47
- package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +20 -32
- package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +32 -55
- package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +22 -42
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +23 -33
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +51 -120
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +2 -3
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +23 -46
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +260 -413
- package/dist/Atomic/FormElements/Text/Text.js +47 -53
- package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +21 -31
- package/dist/Atomic/FormElements/Textarea/Textarea.js +16 -27
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +68 -128
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +25 -36
- package/dist/Atomic/FormElements/TimeRange/TimeRange.js +33 -70
- package/dist/Atomic/FormElements/UserContacts/UserContacts.js +58 -124
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +48 -80
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +32 -42
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +40 -60
- package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +2 -3
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +50 -69
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +3 -3
- package/dist/Atomic/Layout/Header/Header.js +21 -48
- package/dist/Atomic/Layout/MainMenu/MainMenu.js +36 -79
- package/dist/Atomic/Layout/Spinner/Spinner.js +8 -14
- package/dist/Atomic/UI/Accordion/Accordion.js +18 -48
- package/dist/Atomic/UI/Accordion/AccordionItem.js +35 -60
- package/dist/Atomic/UI/AccordionTable/AccordionTable.js +49 -106
- package/dist/Atomic/UI/AccordionText/AccordionText.js +13 -37
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +48 -94
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +22 -50
- package/dist/Atomic/UI/Alert/Alert.js +20 -44
- package/dist/Atomic/UI/Arrow/Arrow.js +15 -35
- package/dist/Atomic/UI/Box/Box.js +14 -21
- package/dist/Atomic/UI/Button/Button.js +26 -35
- package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +22 -31
- package/dist/Atomic/UI/Chart/Chart.js +45 -86
- package/dist/Atomic/UI/Chart/partial/Chart.constants.js +14 -24
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +13 -22
- package/dist/Atomic/UI/Chart/partial/datasetSetters.js +68 -113
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +158 -140
- package/dist/Atomic/UI/Chart/partial/optionsSetters.js +26 -42
- package/dist/Atomic/UI/Chart/partial/utils.js +20 -48
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +22 -42
- package/dist/Atomic/UI/DateTime/DateTime.js +23 -38
- package/dist/Atomic/UI/DebugContainer/DebugContainer.js +12 -36
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +5 -21
- package/dist/Atomic/UI/DoubleString/DoubleString.js +27 -50
- package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +15 -63
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +62 -157
- package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +47 -110
- package/dist/Atomic/UI/Hint/Hint.js +49 -94
- package/dist/Atomic/UI/Modal/Modal.js +149 -179
- package/dist/Atomic/UI/Modal/ModalHOC.js +12 -21
- package/dist/Atomic/UI/Modal/partials/ModalFooter.js +7 -12
- package/dist/Atomic/UI/Modal/partials/ModalTitle.js +17 -21
- package/dist/Atomic/UI/Modal/partials/useMobileModal.js +98 -160
- package/dist/Atomic/UI/ModalBackup/Modal.js +65 -90
- package/dist/Atomic/UI/ModalBackup/ModalHOC.js +12 -21
- package/dist/Atomic/UI/ModalBackup/partials/ModalFooter.js +6 -11
- package/dist/Atomic/UI/ModalBackup/partials/ModalTitle.js +15 -19
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +32 -62
- package/dist/Atomic/UI/NavLine/NavLine.js +120 -211
- package/dist/Atomic/UI/NavLine/Tabs.js +2 -3
- package/dist/Atomic/UI/PageTitle/PageTitle.js +13 -17
- package/dist/Atomic/UI/PieChart/PieChart.js +11 -21
- package/dist/Atomic/UI/Price/Price.js +10 -13
- package/dist/Atomic/UI/PriceRange/PriceRange.js +7 -11
- package/dist/Atomic/UI/ProgressLine/ProgressLine.js +27 -56
- package/dist/Atomic/UI/Status/Status.js +19 -30
- package/dist/Atomic/UI/Table/Partials/TdCell.js +28 -71
- package/dist/Atomic/UI/Table/Partials/TdHeader.js +7 -16
- package/dist/Atomic/UI/Table/Partials/TdRow.js +29 -65
- package/dist/Atomic/UI/Table/Partials/TdTitle.js +16 -40
- package/dist/Atomic/UI/Table/Table.js +27 -47
- package/dist/Atomic/UI/Table/TdTypes/TdActions.js +18 -48
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +9 -19
- package/dist/Atomic/UI/Table/TdTypes/TdRange.js +5 -8
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +25 -47
- package/dist/Atomic/UI/Tag/Tag.js +20 -48
- package/dist/Atomic/UI/TagList/TagList.js +80 -150
- package/dist/Atomic/UI/UserBox/UserBox.js +14 -26
- package/dist/Classes/AbortableFetch.js +283 -422
- package/dist/Classes/AnimatedHandler.js +44 -56
- package/dist/Classes/RESTAPI/index.js +154 -433
- package/dist/Classes/RESTAPI/partials/AbortableFetch.js +290 -428
- package/dist/Classes/RESTAPI/partials/ApiBase.js +24 -67
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +57 -275
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +146 -377
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +155 -403
- package/dist/Classes/RESTAPI/partials/Utils.js +81 -135
- package/dist/Classes/RESTAPI/partials/_outerDependencies.js +2 -6
- package/dist/Classes/RESTAPI/partials/_utils.js +101 -395
- package/dist/Constants/index.constants.js +8 -15
- package/dist/Functions/Portal.js +14 -33
- package/dist/Functions/customEventListener.js +5 -20
- package/dist/Functions/fieldValueFormatters.js +148 -211
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +75 -137
- package/dist/Functions/locale/createTranslator.js +13 -27
- package/dist/Functions/operations.js +35 -49
- package/dist/Functions/presets/inputMaskPresets.js +25 -27
- package/dist/Functions/presets/inputPresets.js +19 -22
- package/dist/Functions/presets/mobileKeyboardTypesPresets.js +7 -9
- package/dist/Functions/schemas.js +6 -15
- package/dist/Functions/useClickOutside.js +3 -7
- package/dist/Functions/useDebounce.js +11 -25
- package/dist/Functions/useFieldFocus.js +42 -67
- package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +35 -54
- package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +74 -95
- package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +55 -91
- package/dist/Functions/useFormTools/functions/General.js +80 -99
- package/dist/Functions/useFormTools/functions/RenderFields.js +45 -72
- package/dist/Functions/useFormTools/functions/usePrevious.js +3 -7
- package/dist/Functions/useFormTools/index.js +382 -598
- package/dist/Functions/useInputHighlightError.js +27 -52
- package/dist/Functions/useIsMobile.js +13 -36
- package/dist/Functions/useLocalStorage.js +7 -22
- package/dist/Functions/useLocationParams.js +16 -27
- package/dist/Functions/useMetaInfo.js +19 -50
- package/dist/Functions/useMouseUpOutside.js +2 -5
- package/dist/Functions/useOnlineStatus.js +7 -26
- package/dist/Functions/usePasswordChecker.js +42 -77
- package/dist/Functions/usePrevious.js +3 -7
- package/dist/Functions/useResize.js +12 -32
- package/dist/Functions/useScrollTo.js +6 -20
- package/dist/Functions/useToggle.js +10 -30
- package/dist/Functions/utils.js +186 -366
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +21 -32
- package/dist/Molecular/CustomIcons/components/AlertCircle.js +21 -32
- package/dist/Molecular/CustomIcons/components/AppStore.js +25 -36
- package/dist/Molecular/CustomIcons/components/Arrow.js +31 -42
- package/dist/Molecular/CustomIcons/components/ArrowDown.js +13 -24
- package/dist/Molecular/CustomIcons/components/ArrowLeft.js +16 -27
- package/dist/Molecular/CustomIcons/components/ArrowRight.js +16 -27
- package/dist/Molecular/CustomIcons/components/ArrowUp.js +13 -24
- package/dist/Molecular/CustomIcons/components/Bell.js +11 -22
- package/dist/Molecular/CustomIcons/components/Button.js +11 -22
- package/dist/Molecular/CustomIcons/components/Campaigns.js +12 -23
- package/dist/Molecular/CustomIcons/components/Check.js +12 -23
- package/dist/Molecular/CustomIcons/components/Check2.js +11 -22
- package/dist/Molecular/CustomIcons/components/ChevronDown.js +11 -22
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +11 -22
- package/dist/Molecular/CustomIcons/components/ChevronLeft.js +11 -22
- package/dist/Molecular/CustomIcons/components/ChevronRight.js +11 -22
- package/dist/Molecular/CustomIcons/components/ChevronUp.js +11 -22
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +26 -37
- package/dist/Molecular/CustomIcons/components/Close.js +13 -24
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +38 -49
- package/dist/Molecular/CustomIcons/components/Delete.js +12 -23
- package/dist/Molecular/CustomIcons/components/Edit.js +11 -22
- package/dist/Molecular/CustomIcons/components/Email.js +29 -40
- package/dist/Molecular/CustomIcons/components/FinturfLogo.js +19 -30
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +27 -38
- package/dist/Molecular/CustomIcons/components/Flows.js +11 -22
- package/dist/Molecular/CustomIcons/components/Gift.js +16 -27
- package/dist/Molecular/CustomIcons/components/GoogleAuth.js +25 -36
- package/dist/Molecular/CustomIcons/components/GooglePlay.js +25 -36
- package/dist/Molecular/CustomIcons/components/HelpCircle.js +14 -25
- package/dist/Molecular/CustomIcons/components/HelpCircle2.js +15 -26
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +14 -25
- package/dist/Molecular/CustomIcons/components/Home.js +14 -25
- package/dist/Molecular/CustomIcons/components/Home2.js +17 -28
- package/dist/Molecular/CustomIcons/components/Key.js +19 -30
- package/dist/Molecular/CustomIcons/components/Landers.js +15 -26
- package/dist/Molecular/CustomIcons/components/Lock.js +11 -22
- package/dist/Molecular/CustomIcons/components/Mail.js +19 -30
- package/dist/Molecular/CustomIcons/components/Mastercard.js +61 -72
- package/dist/Molecular/CustomIcons/components/Minus.js +24 -35
- package/dist/Molecular/CustomIcons/components/Offers.js +12 -23
- package/dist/Molecular/CustomIcons/components/Pause.js +24 -35
- package/dist/Molecular/CustomIcons/components/PayPal.js +38 -49
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +25 -36
- package/dist/Molecular/CustomIcons/components/Phone.js +26 -37
- package/dist/Molecular/CustomIcons/components/Play.js +24 -35
- package/dist/Molecular/CustomIcons/components/Plus.js +24 -35
- package/dist/Molecular/CustomIcons/components/Profile.js +16 -27
- package/dist/Molecular/CustomIcons/components/QRCode.js +26 -37
- package/dist/Molecular/CustomIcons/components/Rectangle.js +11 -22
- package/dist/Molecular/CustomIcons/components/Revert.js +14 -25
- package/dist/Molecular/CustomIcons/components/Star.js +10 -21
- package/dist/Molecular/CustomIcons/components/Star2.js +12 -23
- package/dist/Molecular/CustomIcons/components/TrafficSources.js +14 -25
- package/dist/Molecular/CustomIcons/components/Trash.js +11 -22
- package/dist/Molecular/CustomIcons/components/TrashRed.js +11 -22
- package/dist/Molecular/CustomIcons/components/Triggers.js +11 -22
- package/dist/Molecular/CustomIcons/components/User.js +16 -27
- package/dist/Molecular/CustomIcons/components/Visa.js +27 -38
- package/dist/Molecular/CustomIcons/components/X.js +11 -22
- package/dist/Molecular/CustomIcons/index.js +61 -183
- package/dist/Molecular/FormElement/FormElement.js +18 -27
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +95 -112
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +35 -34
- package/dist/Molecular/InputAddress/InputAddress.js +176 -312
- package/dist/Molecular/InputPassword/InputPassword.js +15 -39
- package/dist/index.js +1 -3
- package/package.json +1 -1
- package/dist/Atomic/FormElements/UserContacts/partial/defaultIcons.js +0 -91
|
@@ -1,284 +1,180 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof3 = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
4
|
Object.defineProperty(exports, "__esModule", {
|
|
8
5
|
value: true
|
|
9
6
|
});
|
|
10
7
|
exports.default = void 0;
|
|
11
|
-
|
|
12
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
13
|
-
|
|
14
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
-
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
19
|
-
|
|
20
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
21
|
-
|
|
22
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
23
|
-
|
|
24
10
|
var _reactDom = require("react-dom");
|
|
25
|
-
|
|
26
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
27
|
-
|
|
28
12
|
var _reactFeather = require("react-feather");
|
|
29
|
-
|
|
30
13
|
var _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
|
|
31
|
-
|
|
32
14
|
var _utils = require("../../../Functions/utils");
|
|
33
|
-
|
|
34
|
-
var _useIsMobile2 = _interopRequireDefault(require("../../../Functions/useIsMobile"));
|
|
35
|
-
|
|
15
|
+
var _useIsMobile = _interopRequireDefault(require("../../../Functions/useIsMobile"));
|
|
36
16
|
var _Input = _interopRequireDefault(require("../../../Atomic/FormElements/Input/Input"));
|
|
37
|
-
|
|
38
17
|
var _RadioInput = _interopRequireDefault(require("../../../Atomic/FormElements/RadioInput/RadioInput"));
|
|
39
|
-
|
|
40
18
|
var _DropdownLoader = _interopRequireDefault(require("./components/DropdownLoader"));
|
|
41
|
-
|
|
42
19
|
require("./Dropdown.scss");
|
|
43
|
-
|
|
44
|
-
function
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
var _useState = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2)),
|
|
95
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
96
|
-
dropdownId = _useState2[0],
|
|
97
|
-
setDropdownId = _useState2[1];
|
|
98
|
-
|
|
99
|
-
var _useState3 = (0, _react.useState)(false),
|
|
100
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
101
|
-
isOpen = _useState4[0],
|
|
102
|
-
setIsOpen = _useState4[1];
|
|
103
|
-
|
|
104
|
-
var _useState5 = (0, _react.useState)(),
|
|
105
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
106
|
-
searchValue = _useState6[0],
|
|
107
|
-
setSearchValue = _useState6[1];
|
|
108
|
-
|
|
109
|
-
var dropdownRef = (0, _react.useRef)(null);
|
|
110
|
-
var dropdownListRef = (0, _react.useRef)(null);
|
|
111
|
-
var dropdownListWrapperRef = (0, _react.useRef)(null);
|
|
112
|
-
var searchInputRef = (0, _react.useRef)(null);
|
|
113
|
-
var wrapperRef = (0, _react.useRef)(null);
|
|
114
|
-
|
|
115
|
-
var _useState7 = (0, _react.useState)(null),
|
|
116
|
-
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
117
|
-
initListHeight = _useState8[0],
|
|
118
|
-
setInitListHeight = _useState8[1];
|
|
119
|
-
|
|
120
|
-
var _useState9 = (0, _react.useState)(false),
|
|
121
|
-
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
122
|
-
isSearchChanged = _useState10[0],
|
|
123
|
-
setIsSearchChanged = _useState10[1];
|
|
124
|
-
|
|
125
|
-
var _useState11 = (0, _react.useState)(false),
|
|
126
|
-
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
127
|
-
isSearchInputFocused = _useState12[0],
|
|
128
|
-
setIsSearchInputFocused = _useState12[1];
|
|
129
|
-
|
|
130
|
-
var _useState13 = (0, _react.useState)(null),
|
|
131
|
-
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
132
|
-
isScrollableList = _useState14[0],
|
|
133
|
-
setIsScrollableList = _useState14[1];
|
|
134
|
-
|
|
135
|
-
var _useState15 = (0, _react.useState)(false),
|
|
136
|
-
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
137
|
-
isFixedMaxHeight = _useState16[0],
|
|
138
|
-
setIsFixedMaxHeight = _useState16[1];
|
|
139
|
-
|
|
140
|
-
var _useState17 = (0, _react.useState)(0),
|
|
141
|
-
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
142
|
-
scrollTop = _useState18[0],
|
|
143
|
-
setScrollTop = _useState18[1];
|
|
144
|
-
|
|
145
|
-
var _useState19 = (0, _react.useState)(1),
|
|
146
|
-
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
|
147
|
-
scrollHeight = _useState20[0],
|
|
148
|
-
setScrollHeight = _useState20[1];
|
|
149
|
-
|
|
20
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
21
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
22
|
+
const RC = 'dropdown';
|
|
23
|
+
const MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH = 10;
|
|
24
|
+
const Dropdown = _ref => {
|
|
25
|
+
var _options$find, _dropdownListWrapperR3, _dropdownListRef$curr5, _dropdownListRef$curr6, _filteredOptions$find, _tabIndex$toString;
|
|
26
|
+
let {
|
|
27
|
+
label,
|
|
28
|
+
options = [],
|
|
29
|
+
value,
|
|
30
|
+
error,
|
|
31
|
+
disabled,
|
|
32
|
+
onChange,
|
|
33
|
+
placeholder,
|
|
34
|
+
className,
|
|
35
|
+
isSearchable,
|
|
36
|
+
entity,
|
|
37
|
+
scrollReactionObj,
|
|
38
|
+
isListTop,
|
|
39
|
+
isNotValidateASCII = false,
|
|
40
|
+
testId,
|
|
41
|
+
sortAlphabetical = true,
|
|
42
|
+
fieldKey,
|
|
43
|
+
id,
|
|
44
|
+
noOptionsText = 'No options available',
|
|
45
|
+
attributesOfNativeInput = {},
|
|
46
|
+
isDoNotPullOutListOfMainContainer,
|
|
47
|
+
withMobileLogic,
|
|
48
|
+
minItemsForShowMobileSearch = MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH,
|
|
49
|
+
customTrigger,
|
|
50
|
+
tabIndex
|
|
51
|
+
} = _ref;
|
|
52
|
+
const {
|
|
53
|
+
isMobile: isMobileProp
|
|
54
|
+
} = (0, _useIsMobile.default)();
|
|
55
|
+
const isMobile = isMobileProp && withMobileLogic;
|
|
56
|
+
const [dropdownId, setDropdownId] = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2));
|
|
57
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
58
|
+
const [searchValue, setSearchValue] = (0, _react.useState)();
|
|
59
|
+
const dropdownRef = (0, _react.useRef)(null);
|
|
60
|
+
const dropdownListRef = (0, _react.useRef)(null);
|
|
61
|
+
const dropdownListWrapperRef = (0, _react.useRef)(null);
|
|
62
|
+
const searchInputRef = (0, _react.useRef)(null);
|
|
63
|
+
const wrapperRef = (0, _react.useRef)(null);
|
|
64
|
+
const [initListHeight, setInitListHeight] = (0, _react.useState)(null);
|
|
65
|
+
const [isSearchChanged, setIsSearchChanged] = (0, _react.useState)(false);
|
|
66
|
+
const [isSearchInputFocused, setIsSearchInputFocused] = (0, _react.useState)(false);
|
|
67
|
+
const [isScrollableList, setIsScrollableList] = (0, _react.useState)(null);
|
|
68
|
+
const [isFixedMaxHeight, setIsFixedMaxHeight] = (0, _react.useState)(false);
|
|
69
|
+
const [scrollTop, setScrollTop] = (0, _react.useState)(0);
|
|
70
|
+
const [scrollHeight, setScrollHeight] = (0, _react.useState)(1);
|
|
150
71
|
if (!options) return null;
|
|
151
|
-
|
|
152
|
-
return options === null || options === void 0 ? void 0 : options.reduce(
|
|
72
|
+
const getTotalOptions = (0, _react.useCallback)(() => {
|
|
73
|
+
return options === null || options === void 0 ? void 0 : options.reduce((result, item) => {
|
|
153
74
|
if (item !== null && item !== void 0 && item.list || item !== null && item !== void 0 && item.items) {
|
|
154
75
|
var _item$list, _item$items;
|
|
155
|
-
|
|
156
|
-
result += (item === null || item === void 0 ? void 0 : (_item$list = item.list) === null || _item$list === void 0 ? void 0 : _item$list.length) || (item === null || item === void 0 ? void 0 : (_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.length) || 0;
|
|
76
|
+
result += (item === null || item === void 0 || (_item$list = item.list) === null || _item$list === void 0 ? void 0 : _item$list.length) || (item === null || item === void 0 || (_item$items = item.items) === null || _item$items === void 0 ? void 0 : _item$items.length) || 0;
|
|
157
77
|
} else {
|
|
158
78
|
++result;
|
|
159
79
|
}
|
|
160
|
-
|
|
161
80
|
return result;
|
|
162
81
|
}, 0);
|
|
163
82
|
}, [options]);
|
|
164
83
|
if (isMobile) isSearchable = getTotalOptions() > (minItemsForShowMobileSearch || MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH);
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
var otherIndex = options === null || options === void 0 ? void 0 : options.findIndex(function (option) {
|
|
168
|
-
return (option === null || option === void 0 ? void 0 : option.value) === 'other';
|
|
169
|
-
});
|
|
170
|
-
|
|
84
|
+
const moveOtherToEnd = options => {
|
|
85
|
+
const otherIndex = options === null || options === void 0 ? void 0 : options.findIndex(option => (option === null || option === void 0 ? void 0 : option.value) === 'other');
|
|
171
86
|
if (otherIndex > -1) {
|
|
172
|
-
|
|
173
|
-
options.push
|
|
87
|
+
const other = options === null || options === void 0 ? void 0 : options.splice(otherIndex, 1);
|
|
88
|
+
options.push(...other);
|
|
174
89
|
}
|
|
175
|
-
|
|
176
90
|
return options;
|
|
177
91
|
};
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
options.map(function (option) {
|
|
92
|
+
const optionsWithOtherAtTheEnd = moveOtherToEnd(options);
|
|
93
|
+
options.map(option => {
|
|
181
94
|
if (option.items) {
|
|
182
95
|
return option.items = moveOtherToEnd(option.items);
|
|
183
96
|
} else return option;
|
|
184
97
|
});
|
|
185
|
-
|
|
98
|
+
const filteredGroups = optionsWithOtherAtTheEnd.map(item => {
|
|
186
99
|
var _item$items2;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
items: !isSearchable || !isSearchChanged ? item === null || item === void 0 ? void 0 : item.items : (_item$items2 = item.items) === null || _item$items2 === void 0 ? void 0 : _item$items2.slice().filter(
|
|
100
|
+
return {
|
|
101
|
+
...item,
|
|
102
|
+
items: !isSearchable || !isSearchChanged ? item === null || item === void 0 ? void 0 : item.items : (_item$items2 = item.items) === null || _item$items2 === void 0 ? void 0 : _item$items2.slice().filter(el => {
|
|
190
103
|
var _el$label;
|
|
191
|
-
|
|
192
|
-
return (el === null || el === void 0 ? void 0 : (_el$label = el.label) === null || _el$label === void 0 ? void 0 : _el$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(el !== null && el !== void 0 && el.value) || (el === null || el === void 0 ? void 0 : el.value) === '';
|
|
104
|
+
return (el === null || el === void 0 || (_el$label = el.label) === null || _el$label === void 0 ? void 0 : _el$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(el !== null && el !== void 0 && el.value) || (el === null || el === void 0 ? void 0 : el.value) === '';
|
|
193
105
|
})
|
|
194
|
-
}
|
|
195
|
-
}).filter(
|
|
106
|
+
};
|
|
107
|
+
}).filter(item => {
|
|
196
108
|
var _item$items3;
|
|
197
|
-
|
|
198
109
|
return ((_item$items3 = item.items) === null || _item$items3 === void 0 ? void 0 : _item$items3.length) > 0;
|
|
199
110
|
});
|
|
200
|
-
|
|
111
|
+
const filteredItems = optionsWithOtherAtTheEnd.filter(item => {
|
|
201
112
|
var _item$items4;
|
|
202
|
-
|
|
203
113
|
return !((_item$items4 = item.items) !== null && _item$items4 !== void 0 && _item$items4.length);
|
|
204
|
-
}).filter(
|
|
114
|
+
}).filter(item => {
|
|
205
115
|
var _item$label;
|
|
206
|
-
|
|
207
116
|
if (!isSearchable || !isSearchChanged) return true;
|
|
208
|
-
return (item === null || item === void 0
|
|
117
|
+
return (item === null || item === void 0 || (_item$label = item.label) === null || _item$label === void 0 ? void 0 : _item$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(item !== null && item !== void 0 && item.value) || (item === null || item === void 0 ? void 0 : item.value) === '';
|
|
209
118
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
var onChangeHandler = function onChangeHandler(item) {
|
|
119
|
+
const filteredOptions = [...filteredItems, ...filteredGroups];
|
|
120
|
+
const modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
|
|
121
|
+
const onChangeHandler = item => {
|
|
214
122
|
setIsOpen(false);
|
|
215
123
|
onChange(item.value);
|
|
216
124
|
};
|
|
217
|
-
|
|
218
|
-
var onKeyDown = function onKeyDown(e) {
|
|
125
|
+
const onKeyDown = e => {
|
|
219
126
|
if (![9, 13].includes(e.keyCode)) return false;
|
|
220
127
|
setIsOpen(false);
|
|
221
128
|
};
|
|
222
|
-
|
|
223
|
-
var onKeyUp = function onKeyUp(e) {
|
|
129
|
+
const onKeyUp = e => {
|
|
224
130
|
if (![9, 13].includes(e.keyCode)) return false;
|
|
225
131
|
setIsOpen(true);
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
var newOnChange = function newOnChange(e) {
|
|
132
|
+
};
|
|
133
|
+
// decorator
|
|
134
|
+
const getDepends = getDependsTrigger => {
|
|
135
|
+
const newOnChange = e => {
|
|
231
136
|
if (e.value === 'open_modal') {
|
|
232
137
|
onChange('open_modal');
|
|
233
138
|
} else {
|
|
234
139
|
onChangeHandler(e);
|
|
235
140
|
}
|
|
236
|
-
};
|
|
237
|
-
|
|
141
|
+
};
|
|
238
142
|
|
|
239
|
-
|
|
143
|
+
// add pseudo option
|
|
144
|
+
const newOptions = [{
|
|
240
145
|
label: "New ".concat(entity),
|
|
241
146
|
value: 'open_modal',
|
|
242
147
|
className: 'dropdown__list-item--modal'
|
|
243
|
-
}
|
|
148
|
+
}, ...filteredOptions];
|
|
244
149
|
return {
|
|
245
|
-
onChange:
|
|
150
|
+
onChange: changeItem => {
|
|
246
151
|
return getDependsTrigger ? newOnChange(changeItem) : onChangeHandler(changeItem);
|
|
247
152
|
},
|
|
248
153
|
options: getDependsTrigger ? newOptions : options
|
|
249
154
|
};
|
|
250
155
|
};
|
|
251
|
-
|
|
252
|
-
var handleClickOutside = function handleClickOutside(event) {
|
|
156
|
+
const handleClickOutside = event => {
|
|
253
157
|
var _getListContainer;
|
|
254
|
-
|
|
255
158
|
if (!((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(event === null || event === void 0 ? void 0 : event.target))) {
|
|
256
159
|
setIsOpen(false);
|
|
257
160
|
}
|
|
258
161
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
var inputValue = name;
|
|
162
|
+
const onSearchHandler = name => {
|
|
163
|
+
let inputValue = name;
|
|
262
164
|
if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
|
|
263
165
|
setIsSearchChanged(true);
|
|
264
166
|
setSearchValue(inputValue);
|
|
265
167
|
};
|
|
266
|
-
|
|
267
|
-
var onWrapperClick = function onWrapperClick(e) {
|
|
168
|
+
const onWrapperClick = e => {
|
|
268
169
|
if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
|
|
269
170
|
e.stopPropagation();
|
|
270
171
|
e.preventDefault();
|
|
271
172
|
setIsOpen(false);
|
|
272
173
|
}
|
|
273
174
|
};
|
|
274
|
-
|
|
275
|
-
var hightlightedText = function hightlightedText(text, postfix, description) {
|
|
175
|
+
const hightlightedText = (text, postfix, description) => {
|
|
276
176
|
var _text;
|
|
277
|
-
|
|
278
|
-
var prepare = function prepare(text) {
|
|
279
|
-
return text === null || text === void 0 ? void 0 : text.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
|
|
280
|
-
};
|
|
281
|
-
|
|
177
|
+
const prepare = text => text === null || text === void 0 ? void 0 : text.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
|
|
282
178
|
text = text.replace(/["&<>]/g, function (a) {
|
|
283
179
|
return {
|
|
284
180
|
'"': '"',
|
|
@@ -287,28 +183,26 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
287
183
|
'>': '>'
|
|
288
184
|
}[a];
|
|
289
185
|
});
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
var postfixPart = postfix ? "<span class=\"dropdown__list-item-postfix\">".concat(postfix, "</span>") : '';
|
|
294
|
-
var descriptionPart = description ? "<span class=\"dropdown__list-item-description\">".concat(description, "</span>") : '';
|
|
186
|
+
const main = isSearchable && searchValue ? (_text = text) === null || _text === void 0 ? void 0 : _text.replace(new RegExp(prepare(searchValue), 'i'), match => "<span class=\"bg--yellow\">".concat(match, "</span>")) : text;
|
|
187
|
+
const postfixPart = postfix ? "<span class=\"dropdown__list-item-postfix\">".concat(postfix, "</span>") : '';
|
|
188
|
+
const descriptionPart = description ? "<span class=\"dropdown__list-item-description\">".concat(description, "</span>") : '';
|
|
295
189
|
return main + postfixPart + descriptionPart;
|
|
296
190
|
};
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
var getMarkupForElement = function getMarkupForElement(item, index, optTestId) {
|
|
301
|
-
var _item$value, _item$value$toString, _item$value2, _item$value2$toString, _cn, _item$customMobileIco;
|
|
302
|
-
|
|
191
|
+
const depend = getDepends(modalBtnTrigger);
|
|
192
|
+
const getMarkupForElement = (item, index, optTestId) => {
|
|
193
|
+
var _item$value, _item$value2, _item$customMobileIco;
|
|
303
194
|
return /*#__PURE__*/_react.default.createElement("button", {
|
|
304
|
-
"data-testid": "dropdown--button--key-".concat(optTestId || (item === null || item === void 0
|
|
305
|
-
key: (_item$value2 = item.value) === null || _item$value2 === void 0
|
|
306
|
-
onMouseDown:
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
195
|
+
"data-testid": "dropdown--button--key-".concat(optTestId || (item === null || item === void 0 || (_item$value = item.value) === null || _item$value === void 0 || (_item$value = _item$value.toString()) === null || _item$value === void 0 ? void 0 : _item$value.replace(/\s/, '-')) || (item === null || item === void 0 ? void 0 : item.key) || 'item', "--option"),
|
|
196
|
+
key: (_item$value2 = item.value) === null || _item$value2 === void 0 || (_item$value2 = _item$value2.toString()) === null || _item$value2 === void 0 ? void 0 : _item$value2.replace(/ /g, '_'),
|
|
197
|
+
onMouseDown: () => depend.onChange(item),
|
|
198
|
+
className: (0, _classnames.default)("".concat(RC, "__list-item"), {
|
|
199
|
+
["".concat(RC, "__list-item_active")]: item.value === value,
|
|
200
|
+
["".concat(RC, "__list-item_disabled")]: item.disabled
|
|
201
|
+
}, item.className)
|
|
310
202
|
}, !isMobile && /*#__PURE__*/_react.default.createElement("span", {
|
|
311
|
-
className: (0, _classnames.default)("".concat(RC, "__active-icon"),
|
|
203
|
+
className: (0, _classnames.default)("".concat(RC, "__active-icon"), {
|
|
204
|
+
["".concat(RC, "__active-icon_active")]: item.value === value
|
|
205
|
+
})
|
|
312
206
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.Check, null)), /*#__PURE__*/_react.default.createElement("div", {
|
|
313
207
|
className: (0, _classnames.default)("".concat(RC, "__list-item-label"), item.labelClassName || ''),
|
|
314
208
|
dangerouslySetInnerHTML: {
|
|
@@ -319,73 +213,54 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
319
213
|
checked: value
|
|
320
214
|
}) : '');
|
|
321
215
|
};
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
var _filteredOption$items, _filteredOption$label, _filteredOption$label2;
|
|
325
|
-
|
|
216
|
+
const filteredOptionList = filteredOption => {
|
|
217
|
+
var _filteredOption$items, _filteredOption$label;
|
|
326
218
|
return ((_filteredOption$items = filteredOption.items) === null || _filteredOption$items === void 0 ? void 0 : _filteredOption$items.length) > 0 ? /*#__PURE__*/_react.default.createElement("div", {
|
|
327
|
-
key: (_filteredOption$label = filteredOption.label) === null || _filteredOption$label === void 0
|
|
219
|
+
key: (_filteredOption$label = filteredOption.label) === null || _filteredOption$label === void 0 || (_filteredOption$label = _filteredOption$label.toString()) === null || _filteredOption$label === void 0 ? void 0 : _filteredOption$label.replace(/ /g, '_').concat(Date.now()),
|
|
328
220
|
className: (0, _classnames.default)("".concat(RC, "-group"), filteredOption.className)
|
|
329
221
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
330
222
|
className: "".concat(RC, "-group__name")
|
|
331
|
-
}, filteredOption.label), filteredOption.items.map(
|
|
332
|
-
return getMarkupForElement(el, index, el === null || el === void 0 ? void 0 : el.testId);
|
|
333
|
-
})) : null;
|
|
223
|
+
}, filteredOption.label), filteredOption.items.map((el, index) => getMarkupForElement(el, index, el === null || el === void 0 ? void 0 : el.testId))) : null;
|
|
334
224
|
};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
return el.value === value;
|
|
338
|
-
})) === null || _options$find === void 0 ? void 0 : _options$find.label) || options.reduce(function (acc, item) {
|
|
339
|
-
var _item$items5, _item$items5$find;
|
|
340
|
-
|
|
341
|
-
return acc || ((_item$items5 = item.items) === null || _item$items5 === void 0 ? void 0 : (_item$items5$find = _item$items5.find(function (el) {
|
|
342
|
-
return el.value === value;
|
|
343
|
-
})) === null || _item$items5$find === void 0 ? void 0 : _item$items5$find.label);
|
|
225
|
+
const selectedLabel = ((_options$find = options.find(el => el.value === value)) === null || _options$find === void 0 ? void 0 : _options$find.label) || options.reduce((acc, item) => {
|
|
226
|
+
var _item$items5;
|
|
227
|
+
return acc || ((_item$items5 = item.items) === null || _item$items5 === void 0 || (_item$items5 = _item$items5.find(el => el.value === value)) === null || _item$items5 === void 0 ? void 0 : _item$items5.label);
|
|
344
228
|
}, null);
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
229
|
+
const doScrollCallback = (0, _react.useCallback)(e => {
|
|
230
|
+
const {
|
|
231
|
+
callback,
|
|
232
|
+
isWithAnyScrolling,
|
|
233
|
+
scrollingInaccuracy = 0
|
|
234
|
+
} = scrollReactionObj || {};
|
|
352
235
|
if (callback && typeof callback === 'function') {
|
|
353
236
|
if (isWithAnyScrolling) callback(e);else if (Math.round(e.target.clientHeight + e.target.scrollTop + scrollingInaccuracy) >= e.target.scrollHeight) callback(e);
|
|
354
237
|
}
|
|
355
238
|
}, [filteredOptions]);
|
|
356
|
-
|
|
357
|
-
var getParentNode = function getParentNode() {
|
|
239
|
+
const getParentNode = () => {
|
|
358
240
|
var _document$querySelect;
|
|
359
|
-
|
|
360
241
|
if (isDoNotPullOutListOfMainContainer) return dropdownRef.current;
|
|
361
242
|
return (_document$querySelect = document.querySelector('div#root')) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector('div#app');
|
|
362
243
|
};
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
var dropdownList = document.createElement('div');
|
|
244
|
+
const initListContainer = () => {
|
|
245
|
+
const dropdownList = document.createElement('div');
|
|
366
246
|
dropdownList.setAttribute('id', dropdownId);
|
|
367
247
|
dropdownList.classList.add('dropdown__container');
|
|
368
|
-
|
|
369
248
|
if (isMobile) {
|
|
370
|
-
dropdownList.addEventListener('click',
|
|
249
|
+
dropdownList.addEventListener('click', e => {
|
|
371
250
|
if (e.target.id === dropdownId) setIsOpen(false);
|
|
372
251
|
});
|
|
373
252
|
}
|
|
374
|
-
|
|
375
253
|
try {
|
|
376
254
|
var _getListContainer2;
|
|
377
|
-
|
|
378
|
-
(_getListContainer2 = getListContainer()) === null || _getListContainer2 === void 0 ? void 0 : _getListContainer2.remove();
|
|
255
|
+
(_getListContainer2 = getListContainer()) === null || _getListContainer2 === void 0 || _getListContainer2.remove();
|
|
379
256
|
} finally {
|
|
380
257
|
if (isMobile) {
|
|
381
258
|
try {
|
|
382
259
|
var _document$getElementB;
|
|
383
|
-
|
|
384
|
-
(_document$getElementB = document.getElementById("mlw-".concat(dropdownId))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove();
|
|
260
|
+
(_document$getElementB = document.getElementById("mlw-".concat(dropdownId))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
|
385
261
|
} catch (e) {}
|
|
386
|
-
|
|
387
262
|
;
|
|
388
|
-
|
|
263
|
+
const dropdownMobileListWrapper = document.createElement('div');
|
|
389
264
|
dropdownMobileListWrapper.classList.add('dropdown-mobile');
|
|
390
265
|
dropdownMobileListWrapper.setAttribute('id', "mlw-".concat(dropdownId));
|
|
391
266
|
dropdownMobileListWrapper.append(dropdownList);
|
|
@@ -395,151 +270,141 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
395
270
|
}
|
|
396
271
|
}
|
|
397
272
|
};
|
|
398
|
-
|
|
399
|
-
var getListContainer = function getListContainer() {
|
|
273
|
+
const getListContainer = () => {
|
|
400
274
|
return document.getElementById(dropdownId);
|
|
401
275
|
};
|
|
402
|
-
|
|
403
|
-
var getListContainerWrapper = function getListContainerWrapper() {
|
|
276
|
+
const getListContainerWrapper = () => {
|
|
404
277
|
return document.getElementById("mlw-".concat(dropdownId));
|
|
405
278
|
};
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
var lc = getListContainer();
|
|
279
|
+
const setListContainerStyles = () => {
|
|
280
|
+
var _dropdownRef$current$, _dropdownListWrapperR, _getComputedStyle$mar, _getComputedStyle, _getComputedStyle$max, _getComputedStyle2, _sw$getBoundingClient, _dropdownListWrapperR2, _lh$getBoundingClient;
|
|
281
|
+
const lc = getListContainer();
|
|
411
282
|
if (!lc || !isOpen) return false;
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
var maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_getComputedStyle$max = (_getComputedStyle2 = getComputedStyle(sw)) === null || _getComputedStyle2 === void 0 ? void 0 : (_getComputedStyle2$ma = _getComputedStyle2.maxHeight) === null || _getComputedStyle2$ma === void 0 ? void 0 : _getComputedStyle2$ma.replace('px', '')) !== null && _getComputedStyle$max !== void 0 ? _getComputedStyle$max : 0);
|
|
283
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
284
|
+
const {
|
|
285
|
+
width,
|
|
286
|
+
height,
|
|
287
|
+
left,
|
|
288
|
+
top
|
|
289
|
+
} = (_dropdownRef$current$ = dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current.getBoundingClientRect()) !== null && _dropdownRef$current$ !== void 0 ? _dropdownRef$current$ : {};
|
|
290
|
+
const sw = lc.getElementsByClassName('dropdown__list')[0];
|
|
291
|
+
const lh = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 || (_dropdownListWrapperR = dropdownListWrapperRef.current) === null || _dropdownListWrapperR === void 0 ? void 0 : _dropdownListWrapperR.getElementsByClassName('dropdown__list-header')[0];
|
|
292
|
+
const margin = parseInt((_getComputedStyle$mar = (_getComputedStyle = getComputedStyle(sw)) === null || _getComputedStyle === void 0 || (_getComputedStyle = _getComputedStyle.marginTop) === null || _getComputedStyle === void 0 ? void 0 : _getComputedStyle.replace('px', '')) !== null && _getComputedStyle$mar !== void 0 ? _getComputedStyle$mar : 0);
|
|
293
|
+
const maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_getComputedStyle$max = (_getComputedStyle2 = getComputedStyle(sw)) === null || _getComputedStyle2 === void 0 || (_getComputedStyle2 = _getComputedStyle2.maxHeight) === null || _getComputedStyle2 === void 0 ? void 0 : _getComputedStyle2.replace('px', '')) !== null && _getComputedStyle$max !== void 0 ? _getComputedStyle$max : 0);
|
|
424
294
|
if (initListHeight === null) setInitListHeight(maxHeight);
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
295
|
+
const toTop = top - margin;
|
|
296
|
+
const toBottom = windowHeight - top - height - margin * 2;
|
|
297
|
+
const swHeight = sw === null || sw === void 0 || (_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height;
|
|
298
|
+
const maxSwHeight = isMobile ? (dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 || (_dropdownListWrapperR2 = dropdownListWrapperRef.current) === null || _dropdownListWrapperR2 === void 0 || (_dropdownListWrapperR2 = _dropdownListWrapperR2.getBoundingClientRect()) === null || _dropdownListWrapperR2 === void 0 ? void 0 : _dropdownListWrapperR2.height) - (lh === null || lh === void 0 || (_lh$getBoundingClient = lh.getBoundingClientRect()) === null || _lh$getBoundingClient === void 0 ? void 0 : _lh$getBoundingClient.height) : toTop >= maxHeight || toBottom >= maxHeight ? maxHeight - 3 * margin : toTop > toBottom ? toTop - 3 * margin : toBottom - 4 * margin;
|
|
299
|
+
const listPos = toTop < toBottom || toBottom >= swHeight ? 'bottom' : 'top';
|
|
430
300
|
lc.style.minWidth = "".concat(width, "px");
|
|
431
301
|
lc.style.left = "".concat(left, "px");
|
|
432
302
|
lc.style.top = "".concat(listPos === 'bottom' ? top + height : top - swHeight - 3 * margin, "px");
|
|
433
303
|
sw.style.maxHeight = "".concat(maxSwHeight, "px");
|
|
434
304
|
};
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
var lc = getListContainer();
|
|
305
|
+
const renderListContainer = () => {
|
|
306
|
+
const lc = getListContainer();
|
|
438
307
|
if (!lc) return null;
|
|
439
308
|
return /*#__PURE__*/(0, _reactDom.createPortal)(getListMarkUp(), lc);
|
|
440
309
|
};
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
var newData = (0, _toConsumableArray2.default)(data);
|
|
444
|
-
|
|
310
|
+
const getSortedOptions = data => {
|
|
311
|
+
let newData = [...data];
|
|
445
312
|
if (sortAlphabetical) {
|
|
446
|
-
|
|
447
|
-
|
|
313
|
+
const openModalOption = newData.filter(_ref2 => {
|
|
314
|
+
let {
|
|
315
|
+
value
|
|
316
|
+
} = _ref2;
|
|
448
317
|
return value === 'open_modal';
|
|
449
318
|
});
|
|
450
|
-
|
|
451
|
-
|
|
319
|
+
const emptyOption = newData.filter(_ref3 => {
|
|
320
|
+
let {
|
|
321
|
+
value
|
|
322
|
+
} = _ref3;
|
|
452
323
|
return value === '';
|
|
453
324
|
});
|
|
454
|
-
|
|
455
|
-
|
|
325
|
+
const restOfOptions = newData.filter(_ref4 => {
|
|
326
|
+
let {
|
|
327
|
+
value
|
|
328
|
+
} = _ref4;
|
|
456
329
|
return value !== 'open_modal' && value !== '';
|
|
457
330
|
}).sort(_utils.compareAlphabetical);
|
|
458
|
-
newData = [
|
|
331
|
+
newData = [...openModalOption, ...emptyOption, ...restOfOptions].map(item => {
|
|
459
332
|
if (item !== null && item !== void 0 && item.items) {
|
|
460
|
-
item.items =
|
|
333
|
+
item.items = [...item.items].sort(_utils.compareAlphabetical);
|
|
461
334
|
}
|
|
462
|
-
|
|
463
335
|
return item;
|
|
464
336
|
});
|
|
465
337
|
}
|
|
466
|
-
|
|
467
338
|
return newData;
|
|
468
339
|
};
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
var _cn3, _cn4, _getSortedOptions;
|
|
472
|
-
|
|
340
|
+
const getListMarkUp = () => {
|
|
341
|
+
var _getSortedOptions;
|
|
473
342
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
474
343
|
className: (0, _classnames.default)("".concat(RC, "__container-wrapper")),
|
|
475
344
|
ref: wrapperRef,
|
|
476
|
-
onClick: isMobile ? onWrapperClick :
|
|
345
|
+
onClick: isMobile ? onWrapperClick : () => {}
|
|
477
346
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
478
|
-
className: (0, _classnames.default)("".concat(RC, "__list-wrapper"),
|
|
347
|
+
className: (0, _classnames.default)("".concat(RC, "__list-wrapper"), {
|
|
348
|
+
["".concat(RC, "__list-wrapper--fixed-height")]: isFixedMaxHeight,
|
|
349
|
+
["".concat(RC, "__list-wrapper--with-bottom-shadow")]: isScrollableList && isMobile,
|
|
350
|
+
["".concat(RC, "__list-wrapper--with-bottom-shadow-hidden")]: scrollTop === scrollHeight
|
|
351
|
+
}),
|
|
479
352
|
ref: dropdownListWrapperRef
|
|
480
353
|
}, isMobile && /*#__PURE__*/_react.default.createElement("div", {
|
|
481
|
-
className: (0, _classnames.default)("".concat(RC, "__list-header"),
|
|
354
|
+
className: (0, _classnames.default)("".concat(RC, "__list-header"), {
|
|
355
|
+
["".concat(RC, "__list-header-with-shadow")]: isScrollableList && isMobile,
|
|
356
|
+
["".concat(RC, "__list-header-with-shadow-hidden")]: scrollTop === 0
|
|
357
|
+
})
|
|
482
358
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
483
359
|
className: (0, _classnames.default)("".concat(RC, "__list-header-row"))
|
|
484
360
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
485
361
|
className: (0, _classnames.default)("".concat(RC, "__list-label"))
|
|
486
362
|
}, label), /*#__PURE__*/_react.default.createElement("div", {
|
|
487
363
|
className: (0, _classnames.default)("".concat(RC, "__list-close-icon")),
|
|
488
|
-
onClick:
|
|
489
|
-
return setIsOpen(false);
|
|
490
|
-
}
|
|
364
|
+
onClick: () => setIsOpen(false)
|
|
491
365
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.X, {
|
|
492
|
-
onClick:
|
|
493
|
-
return setIsOpen(false);
|
|
494
|
-
}
|
|
366
|
+
onClick: () => setIsOpen(false)
|
|
495
367
|
}))), isSearchable && /*#__PURE__*/_react.default.createElement("div", {
|
|
496
368
|
className: (0, _classnames.default)("".concat(RC, "__list-header-row"))
|
|
497
369
|
}, /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({
|
|
498
370
|
ref: searchInputRef,
|
|
499
371
|
className: "".concat(RC, "__input"),
|
|
500
372
|
value: searchValue !== null && searchValue !== void 0 ? searchValue : selectedLabel,
|
|
501
|
-
onChange:
|
|
502
|
-
return onSearchHandler(v);
|
|
503
|
-
},
|
|
373
|
+
onChange: v => onSearchHandler(v),
|
|
504
374
|
placeholder: placeholder || 'Search',
|
|
505
375
|
withDelete: true,
|
|
506
|
-
onFocus:
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
onBlur: function onBlur() {
|
|
510
|
-
return setIsSearchInputFocused(false);
|
|
511
|
-
},
|
|
512
|
-
onMouseDown: function onMouseDown() {
|
|
376
|
+
onFocus: () => setIsSearchInputFocused(true),
|
|
377
|
+
onBlur: () => setIsSearchInputFocused(false),
|
|
378
|
+
onMouseDown: () => {
|
|
513
379
|
if (!isOpen) {
|
|
514
380
|
setIsSearchInputFocused(true);
|
|
515
381
|
setIsOpen(true);
|
|
516
382
|
}
|
|
517
383
|
}
|
|
518
384
|
}, attributesOfNativeInput)))), /*#__PURE__*/_react.default.createElement("div", {
|
|
519
|
-
className: (0, _classnames.default)("".concat(RC, "__list"),
|
|
385
|
+
className: (0, _classnames.default)("".concat(RC, "__list"), {
|
|
386
|
+
["".concat(RC, "__list-top")]: isListTop
|
|
387
|
+
}),
|
|
520
388
|
ref: dropdownListRef
|
|
521
|
-
}, (_getSortedOptions = getSortedOptions(depend.options)) === null || _getSortedOptions === void 0 ? void 0 : _getSortedOptions.map(
|
|
389
|
+
}, (_getSortedOptions = getSortedOptions(depend.options)) === null || _getSortedOptions === void 0 ? void 0 : _getSortedOptions.map(option => {
|
|
522
390
|
var _option$items;
|
|
523
|
-
|
|
524
391
|
if (option !== null && option !== void 0 && (_option$items = option.items) !== null && _option$items !== void 0 && _option$items.length) {
|
|
525
392
|
if (!isSearchable || !isSearchChanged) {
|
|
526
393
|
return filteredOptionList(option);
|
|
527
394
|
} else {
|
|
528
395
|
var _option$items2;
|
|
529
|
-
|
|
530
|
-
var items = (_option$items2 = option.items) === null || _option$items2 === void 0 ? void 0 : _option$items2.slice().filter(function (el) {
|
|
396
|
+
const items = (_option$items2 = option.items) === null || _option$items2 === void 0 ? void 0 : _option$items2.slice().filter(el => {
|
|
531
397
|
var _el$label2;
|
|
532
|
-
|
|
533
|
-
|
|
398
|
+
return (el === null || el === void 0 || (_el$label2 = el.label) === null || _el$label2 === void 0 ? void 0 : _el$label2.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(el !== null && el !== void 0 && el.value) || (el === null || el === void 0 ? void 0 : el.value) === '';
|
|
399
|
+
});
|
|
400
|
+
if (items !== null && items !== void 0 && items.length) return filteredOptionList({
|
|
401
|
+
...option,
|
|
402
|
+
items
|
|
534
403
|
});
|
|
535
|
-
if (items !== null && items !== void 0 && items.length) return filteredOptionList(_objectSpread(_objectSpread({}, option), {}, {
|
|
536
|
-
items: items
|
|
537
|
-
}));
|
|
538
404
|
return null;
|
|
539
405
|
}
|
|
540
406
|
} else {
|
|
541
407
|
var _option$label;
|
|
542
|
-
|
|
543
408
|
if (!isSearchable || !isSearchChanged || option !== null && option !== void 0 && (_option$label = option.label) !== null && _option$label !== void 0 && _option$label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '') || !(option !== null && option !== void 0 && option.value) || (option === null || option === void 0 ? void 0 : option.value) === '') {
|
|
544
409
|
return getMarkupForElement(option);
|
|
545
410
|
}
|
|
@@ -548,23 +413,18 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
548
413
|
className: "".concat(RC, "__list-item ").concat(RC, "__list-item--no-options")
|
|
549
414
|
}, noOptionsText), disabled && isOpen && /*#__PURE__*/_react.default.createElement(_DropdownLoader.default, null))));
|
|
550
415
|
};
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
setIsOpen(function (isOpen) {
|
|
555
|
-
return !isOpen;
|
|
556
|
-
});
|
|
416
|
+
const toggleList = e => {
|
|
417
|
+
e === null || e === void 0 || e.stopPropagation();
|
|
418
|
+
setIsOpen(isOpen => !isOpen);
|
|
557
419
|
};
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
(0, _react.useEffect)(function () {
|
|
420
|
+
const closeList = isOpen ? handleClickOutside : () => {};
|
|
421
|
+
(0, _react.useEffect)(() => {
|
|
561
422
|
if (!isDoNotPullOutListOfMainContainer || dropdownRef.current) {
|
|
562
423
|
initListContainer();
|
|
563
424
|
}
|
|
564
425
|
}, [isDoNotPullOutListOfMainContainer, dropdownRef.current]);
|
|
565
|
-
(0, _react.useLayoutEffect)(
|
|
426
|
+
(0, _react.useLayoutEffect)(() => {
|
|
566
427
|
var _getListContainer3;
|
|
567
|
-
|
|
568
428
|
if (!isMobile) {
|
|
569
429
|
window.addEventListener('resize', setListContainerStyles);
|
|
570
430
|
window.addEventListener('mousewheel', closeList);
|
|
@@ -576,118 +436,96 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
576
436
|
window.removeEventListener('scroll', closeList);
|
|
577
437
|
window.removeEventListener('touchmove', closeList);
|
|
578
438
|
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
return function () {
|
|
439
|
+
(_getListContainer3 = getListContainer()) === null || _getListContainer3 === void 0 || _getListContainer3.addEventListener('click', closeList);
|
|
440
|
+
return () => {
|
|
582
441
|
var _getListContainer4;
|
|
583
|
-
|
|
584
442
|
window.removeEventListener('resize', setListContainerStyles);
|
|
585
443
|
window.removeEventListener('mousewheel', closeList);
|
|
586
444
|
window.removeEventListener('scroll', closeList);
|
|
587
445
|
window.removeEventListener('touchmove', closeList);
|
|
588
|
-
(_getListContainer4 = getListContainer()) === null || _getListContainer4 === void 0
|
|
446
|
+
(_getListContainer4 = getListContainer()) === null || _getListContainer4 === void 0 || _getListContainer4.removeEventListener('click', closeList);
|
|
589
447
|
};
|
|
590
448
|
}, [getListContainer]);
|
|
591
|
-
(0, _react.useLayoutEffect)(
|
|
449
|
+
(0, _react.useLayoutEffect)(() => {
|
|
592
450
|
setListContainerStyles();
|
|
593
|
-
}, [isOpen, searchValue, isMobile, options, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0
|
|
594
|
-
(0, _react.useEffect)(
|
|
451
|
+
}, [isOpen, searchValue, isMobile, options, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 || (_dropdownListWrapperR3 = dropdownListWrapperRef.current) === null || _dropdownListWrapperR3 === void 0 || (_dropdownListWrapperR3 = _dropdownListWrapperR3.getBoundingClientRect()) === null || _dropdownListWrapperR3 === void 0 ? void 0 : _dropdownListWrapperR3.height]);
|
|
452
|
+
(0, _react.useEffect)(() => {
|
|
595
453
|
document.addEventListener('click', handleClickOutside, true);
|
|
596
|
-
return
|
|
597
|
-
return document.removeEventListener('click', handleClickOutside, true);
|
|
598
|
-
};
|
|
454
|
+
return () => document.removeEventListener('click', handleClickOutside, true);
|
|
599
455
|
}, [value]);
|
|
600
|
-
(0, _react.useEffect)(
|
|
456
|
+
(0, _react.useEffect)(() => {
|
|
601
457
|
if (!isOpen) {
|
|
602
458
|
setIsSearchChanged(false);
|
|
603
459
|
}
|
|
604
|
-
|
|
605
|
-
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
|
|
460
|
+
if (scrollReactionObj && typeof scrollReactionObj === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
|
|
606
461
|
dropdownListRef.current.addEventListener('scroll', doScrollCallback);
|
|
607
462
|
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
if (scrollReactionObj && (0, _typeof2.default)(scrollReactionObj) === 'object') removeEventListener('scroll', doScrollCallback);
|
|
463
|
+
return () => {
|
|
464
|
+
if (scrollReactionObj && typeof scrollReactionObj === 'object') removeEventListener('scroll', doScrollCallback);
|
|
611
465
|
};
|
|
612
466
|
}, [isOpen, dropdownListRef]);
|
|
613
|
-
(0, _react.useEffect)(
|
|
467
|
+
(0, _react.useEffect)(() => {
|
|
614
468
|
if (!searchValue && isSearchInputFocused) {
|
|
615
469
|
setSearchValue(selectedLabel);
|
|
616
|
-
setTimeout(
|
|
617
|
-
return searchInputRef.current.select();
|
|
618
|
-
}, 1);
|
|
470
|
+
setTimeout(() => searchInputRef.current.select(), 1);
|
|
619
471
|
}
|
|
620
|
-
|
|
621
472
|
if (!isSearchInputFocused && !isOpen) {
|
|
622
473
|
setSearchValue(null);
|
|
623
474
|
}
|
|
624
475
|
}, [isSearchInputFocused]);
|
|
625
|
-
(0, _react.useEffect)(
|
|
476
|
+
(0, _react.useEffect)(() => {
|
|
626
477
|
var _searchInputRef$curre;
|
|
627
|
-
|
|
628
|
-
if (isOpen && !isSearchInputFocused && searchInputRef !== null && searchInputRef !== void 0 && searchInputRef.current && !isMobile) searchInputRef === null || searchInputRef === void 0 ? void 0 : (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 ? void 0 : _searchInputRef$curre.focus();
|
|
629
|
-
|
|
478
|
+
if (isOpen && !isSearchInputFocused && searchInputRef !== null && searchInputRef !== void 0 && searchInputRef.current && !isMobile) searchInputRef === null || searchInputRef === void 0 || (_searchInputRef$curre = searchInputRef.current) === null || _searchInputRef$curre === void 0 || _searchInputRef$curre.focus();
|
|
630
479
|
if (isOpen) {
|
|
631
480
|
var _getListContainer5;
|
|
632
|
-
|
|
633
|
-
(_getListContainer5 = getListContainer()) === null || _getListContainer5 === void 0 ? void 0 : _getListContainer5.classList.add('dropdown__container--opened');
|
|
481
|
+
(_getListContainer5 = getListContainer()) === null || _getListContainer5 === void 0 || _getListContainer5.classList.add('dropdown__container--opened');
|
|
634
482
|
} else {
|
|
635
483
|
var _getListContainer6;
|
|
636
|
-
|
|
637
|
-
(_getListContainer6 = getListContainer()) === null || _getListContainer6 === void 0 ? void 0 : _getListContainer6.classList.remove('dropdown__container--opened');
|
|
484
|
+
(_getListContainer6 = getListContainer()) === null || _getListContainer6 === void 0 || _getListContainer6.classList.remove('dropdown__container--opened');
|
|
638
485
|
}
|
|
639
|
-
|
|
640
486
|
if (!isOpen && isMobile) {
|
|
641
487
|
setSearchValue(null);
|
|
642
488
|
}
|
|
643
489
|
}, [isOpen]);
|
|
644
|
-
(0, _react.useEffect)(
|
|
490
|
+
(0, _react.useEffect)(() => {
|
|
645
491
|
if (isOpen && isMobile && dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current && !searchValue) {
|
|
646
492
|
var _dropdownListRef$curr, _dropdownListRef$curr2, _dropdownListRef$curr3, _dropdownListRef$curr4;
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
setIsFixedMaxHeight(isScrollableList || (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr3 = dropdownListRef.current) === null || _dropdownListRef$curr3 === void 0 ? void 0 : _dropdownListRef$curr3.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr4 = dropdownListRef.current) === null || _dropdownListRef$curr4 === void 0 ? void 0 : _dropdownListRef$curr4.clientHeight));
|
|
493
|
+
setIsScrollableList((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr = dropdownListRef.current) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr2 = dropdownListRef.current) === null || _dropdownListRef$curr2 === void 0 ? void 0 : _dropdownListRef$curr2.clientHeight));
|
|
494
|
+
setIsFixedMaxHeight(isScrollableList || (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr3 = dropdownListRef.current) === null || _dropdownListRef$curr3 === void 0 ? void 0 : _dropdownListRef$curr3.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr4 = dropdownListRef.current) === null || _dropdownListRef$curr4 === void 0 ? void 0 : _dropdownListRef$curr4.clientHeight));
|
|
650
495
|
}
|
|
651
|
-
}, [isOpen, isMobile, isScrollableList, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0
|
|
652
|
-
(0, _react.useEffect)(
|
|
653
|
-
|
|
496
|
+
}, [isOpen, isMobile, isScrollableList, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr5 = dropdownListRef.current) === null || _dropdownListRef$curr5 === void 0 ? void 0 : _dropdownListRef$curr5.scrollHeight, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr6 = dropdownListRef.current) === null || _dropdownListRef$curr6 === void 0 ? void 0 : _dropdownListRef$curr6.clientHeight]);
|
|
497
|
+
(0, _react.useEffect)(() => {
|
|
498
|
+
const setScrollTopValue = e => {
|
|
654
499
|
setScrollTop(parseInt(e.target.scrollTop));
|
|
655
500
|
};
|
|
656
|
-
|
|
657
501
|
if (isOpen && isMobile && dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
658
502
|
var _dropdownListRef$curr7;
|
|
659
|
-
|
|
660
|
-
dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr7 = dropdownListRef.current) === null || _dropdownListRef$curr7 === void 0 ? void 0 : _dropdownListRef$curr7.addEventListener('scroll', setScrollTopValue);
|
|
503
|
+
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr7 = dropdownListRef.current) === null || _dropdownListRef$curr7 === void 0 || _dropdownListRef$curr7.addEventListener('scroll', setScrollTopValue);
|
|
661
504
|
}
|
|
662
|
-
|
|
663
|
-
return function () {
|
|
505
|
+
return () => {
|
|
664
506
|
var _dropdownListRef$curr8;
|
|
665
|
-
|
|
666
|
-
dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr8 = dropdownListRef.current) === null || _dropdownListRef$curr8 === void 0 ? void 0 : _dropdownListRef$curr8.removeEventListener('scroll', setScrollTopValue);
|
|
507
|
+
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr8 = dropdownListRef.current) === null || _dropdownListRef$curr8 === void 0 || _dropdownListRef$curr8.removeEventListener('scroll', setScrollTopValue);
|
|
667
508
|
};
|
|
668
509
|
}, [isOpen, isMobile, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current]);
|
|
669
|
-
(0, _react.useEffect)(
|
|
510
|
+
(0, _react.useEffect)(() => {
|
|
670
511
|
if (dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
671
512
|
var _dropdownListRef$curr9, _dropdownListRef$curr10;
|
|
672
|
-
|
|
673
|
-
setScrollHeight(parseInt((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr9 = dropdownListRef.current) === null || _dropdownListRef$curr9 === void 0 ? void 0 : _dropdownListRef$curr9.scrollHeight) - (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr10 = dropdownListRef.current) === null || _dropdownListRef$curr10 === void 0 ? void 0 : _dropdownListRef$curr10.clientHeight)));
|
|
513
|
+
setScrollHeight(parseInt((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr9 = dropdownListRef.current) === null || _dropdownListRef$curr9 === void 0 ? void 0 : _dropdownListRef$curr9.scrollHeight) - (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr10 = dropdownListRef.current) === null || _dropdownListRef$curr10 === void 0 ? void 0 : _dropdownListRef$curr10.clientHeight)));
|
|
674
514
|
}
|
|
675
515
|
}, [scrollTop, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current]);
|
|
676
|
-
(0, _react.useEffect)(
|
|
677
|
-
return
|
|
516
|
+
(0, _react.useEffect)(() => {
|
|
517
|
+
return () => {
|
|
678
518
|
var _getListContainer7, _getListContainerWrap;
|
|
679
|
-
|
|
680
|
-
(
|
|
681
|
-
(_getListContainerWrap = getListContainerWrapper()) === null || _getListContainerWrap === void 0 ? void 0 : _getListContainerWrap.remove();
|
|
519
|
+
(_getListContainer7 = getListContainer()) === null || _getListContainer7 === void 0 || _getListContainer7.remove();
|
|
520
|
+
(_getListContainerWrap = getListContainerWrapper()) === null || _getListContainerWrap === void 0 || _getListContainerWrap.remove();
|
|
682
521
|
};
|
|
683
522
|
}, []);
|
|
684
|
-
|
|
685
|
-
return option.value === value;
|
|
686
|
-
})) === null || _filteredOptions$find === void 0 ? void 0 : _filteredOptions$find.postfix) || null;
|
|
523
|
+
const postfixText = selectedLabel && ((_filteredOptions$find = filteredOptions.find(option => option.value === value)) === null || _filteredOptions$find === void 0 ? void 0 : _filteredOptions$find.postfix) || null;
|
|
687
524
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
688
|
-
className: (0, _classnames.default)(RC, className,
|
|
689
|
-
disabled
|
|
690
|
-
|
|
525
|
+
className: (0, _classnames.default)(RC, className, {
|
|
526
|
+
disabled,
|
|
527
|
+
["".concat(RC, "-mobile")]: isMobile
|
|
528
|
+
}),
|
|
691
529
|
ref: dropdownRef,
|
|
692
530
|
onKeyDown: onKeyDown,
|
|
693
531
|
onKeyUp: onKeyUp
|
|
@@ -697,22 +535,16 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
697
535
|
onClick: toggleList,
|
|
698
536
|
onKeyDown: onKeyDown,
|
|
699
537
|
onKeyUp: onKeyUp,
|
|
700
|
-
tabIndex: tabIndex === null || tabIndex === void 0
|
|
538
|
+
tabIndex: tabIndex === null || tabIndex === void 0 || (_tabIndex$toString = tabIndex.toString) === null || _tabIndex$toString === void 0 ? void 0 : _tabIndex$toString.call(tabIndex)
|
|
701
539
|
}, customTrigger || /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, isSearchable && !isMobile ? /*#__PURE__*/_react.default.createElement("input", (0, _extends2.default)({
|
|
702
540
|
ref: searchInputRef,
|
|
703
541
|
className: "".concat(RC, "__input"),
|
|
704
542
|
value: isOpen ? searchValue !== null && searchValue !== void 0 ? searchValue : '' : selectedLabel || '',
|
|
705
|
-
onChange:
|
|
706
|
-
return onSearchHandler(e.target.value);
|
|
707
|
-
},
|
|
543
|
+
onChange: e => onSearchHandler(e.target.value),
|
|
708
544
|
placeholder: placeholder,
|
|
709
|
-
onFocus:
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
onBlur: function onBlur() {
|
|
713
|
-
return setIsSearchInputFocused(false);
|
|
714
|
-
},
|
|
715
|
-
onMouseDown: function onMouseDown() {
|
|
545
|
+
onFocus: () => setIsSearchInputFocused(true),
|
|
546
|
+
onBlur: () => setIsSearchInputFocused(false),
|
|
547
|
+
onMouseDown: () => {
|
|
716
548
|
if (!isOpen) {
|
|
717
549
|
setIsSearchInputFocused(true);
|
|
718
550
|
setIsOpen(true);
|
|
@@ -725,12 +557,12 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
725
557
|
}, selectedLabel || placeholder), postfixText && /*#__PURE__*/_react.default.createElement("span", {
|
|
726
558
|
className: "dropdown__list-item-postfix"
|
|
727
559
|
}, postfixText)), /*#__PURE__*/_react.default.createElement("span", {
|
|
728
|
-
className: (0, _classnames.default)("".concat(RC, "__arrow"),
|
|
560
|
+
className: (0, _classnames.default)("".concat(RC, "__arrow"), {
|
|
561
|
+
["".concat(RC, "__arrow_active")]: isOpen
|
|
562
|
+
}),
|
|
729
563
|
onClick: toggleList
|
|
730
564
|
}, isMobile ? /*#__PURE__*/_react.default.createElement(_reactFeather.Code, {
|
|
731
565
|
className: "mobile-icon"
|
|
732
566
|
}) : isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, null) : /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronDown, null)))), isOpen && renderListContainer());
|
|
733
567
|
};
|
|
734
|
-
|
|
735
|
-
var _default = Dropdown;
|
|
736
|
-
exports.default = _default;
|
|
568
|
+
var _default = exports.default = Dropdown;
|