intelicoreact 1.4.83 → 1.4.85
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 +14 -22
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +14 -22
- package/dist/Atomic/FormElements/Calendar/Calendar.js +67 -122
- 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 +266 -430
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +5 -9
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +161 -283
- 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/FileLoaderDescription/FileLoaderDescription.js +85 -141
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +62 -79
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.scss +4 -0
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +75 -126
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +33 -83
- package/dist/Atomic/FormElements/Input/Input.js +160 -256
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +48 -102
- package/dist/Atomic/FormElements/InputColor/InputColor.js +26 -41
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +38 -76
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +109 -177
- 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 +77 -194
- package/dist/Atomic/FormElements/InputLink/InputLink.js +32 -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 +299 -459
- 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 +51 -113
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +64 -118
- package/dist/Atomic/FormElements/Label/Label.js +14 -24
- 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 +148 -326
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +389 -588
- 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 +23 -41
- 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/TagListToDropdown/TagListToDropdown.js +47 -98
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +485 -713
- 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 +31 -47
- 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 -123
- 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 +35 -77
- 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 +48 -104
- package/dist/Atomic/UI/AccordionText/AccordionText.js +21 -54
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +47 -92
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +22 -50
- package/dist/Atomic/UI/Alert/Alert.js +22 -51
- 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 +13 -37
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +5 -21
- package/dist/Atomic/UI/DoubleString/DoubleString.js +34 -63
- 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 +67 -122
- package/dist/Atomic/UI/Hint/partial/_utils.js +52 -0
- package/dist/Atomic/UI/Hint/partials/_utils.js +14 -29
- package/dist/Atomic/UI/Modal/Modal.js +147 -184
- package/dist/Atomic/UI/Modal/ModalHOC.js +15 -26
- 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 +99 -161
- 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 +28 -58
- 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 -6
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +22 -39
- package/dist/Atomic/UI/Tag/Tag.js +59 -94
- package/dist/Atomic/UI/TagList/TagList.js +81 -144
- package/dist/Atomic/UI/UserBox/UserBox.js +14 -26
- package/dist/Atomic/UI/WizardStepper/constructor.js +7 -15
- package/dist/Atomic/UI/WizardStepper/index.js +1 -5
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +20 -26
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +1 -4
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +26 -39
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +1 -5
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +23 -42
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +1 -5
- package/dist/Atomic/UI/WizardStepper/ui/icons.js +40 -49
- package/dist/Atomic/UI/WizardStepper/ui/index.js +1 -5
- package/dist/Classes/AbortableFetch.js +283 -422
- package/dist/Classes/AnimatedHandler.js +44 -56
- package/dist/Classes/RESTAPI/index.js +158 -441
- 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 +83 -353
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +161 -403
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +159 -400
- 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 +103 -398
- package/dist/Constants/index.constants.js +8 -15
- package/dist/Functions/Portal.js +14 -33
- package/dist/Functions/customEventListener.js +9 -24
- package/dist/Functions/fieldValueFormatters.js +147 -209
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +75 -137
- package/dist/Functions/locale/createTranslator.js +13 -28
- 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/useBodyScrollLock.js +4 -9
- 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 +380 -592
- package/dist/Functions/useInputHighlightError.js +27 -52
- package/dist/Functions/useIsMobile.js +15 -39
- package/dist/Functions/useKeyPress/useHandleKeyPress.js +10 -15
- package/dist/Functions/useKeyPress/useKeyPress.js +18 -35
- package/dist/Functions/useLocalStorage.js +7 -22
- package/dist/Functions/useLocationParams.js +16 -27
- package/dist/Functions/useMediaQuery.js +10 -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 +188 -386
- 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 +19 -28
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +91 -112
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +35 -37
- 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 -119
- package/dist/Atomic/UI/ModalBackup/Modal.js +0 -174
- package/dist/Atomic/UI/ModalBackup/Modal.scss +0 -333
- package/dist/Atomic/UI/ModalBackup/ModalHOC.js +0 -51
- package/dist/Atomic/UI/ModalBackup/partials/ModalFooter.js +0 -24
- package/dist/Atomic/UI/ModalBackup/partials/ModalTitle.js +0 -41
- package/dist/Functions/presets/inputMaskPreset.js +0 -176
|
@@ -1,406 +1,260 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = 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
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
|
-
|
|
16
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
-
|
|
18
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
19
|
-
|
|
20
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
21
|
-
|
|
22
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
23
|
-
|
|
24
11
|
var _reactDom = require("react-dom");
|
|
25
|
-
|
|
26
12
|
var _reactFeather = require("react-feather");
|
|
27
|
-
|
|
28
13
|
var _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
|
|
29
|
-
|
|
30
14
|
var _useDebounce = require("../../../Functions/useDebounce");
|
|
31
|
-
|
|
32
|
-
var _useIsMobile2 = _interopRequireDefault(require("../../../Functions/useIsMobile"));
|
|
33
|
-
|
|
15
|
+
var _useIsMobile = _interopRequireDefault(require("../../../Functions/useIsMobile"));
|
|
34
16
|
var _CheckboxInput = _interopRequireDefault(require("../../FormElements/CheckboxInput/CheckboxInput"));
|
|
35
|
-
|
|
36
17
|
var _Input = _interopRequireDefault(require("../../FormElements/Input/Input"));
|
|
37
|
-
|
|
38
18
|
var _Button = _interopRequireDefault(require("../../UI/Button/Button"));
|
|
39
|
-
|
|
40
19
|
var _Tag = _interopRequireDefault(require("../../UI/Tag/Tag"));
|
|
41
|
-
|
|
42
20
|
var _TagList = _interopRequireDefault(require("../../UI/TagList/TagList"));
|
|
43
|
-
|
|
44
21
|
require("./TagsDropdown.scss");
|
|
45
|
-
|
|
46
|
-
function
|
|
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
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
renderOptionsAsTags = _ref.renderOptionsAsTags,
|
|
129
|
-
_ref$minItemsForShowM = _ref.minItemsForShowMobileSearch,
|
|
130
|
-
minItemsForShowMobileSearch = _ref$minItemsForShowM === void 0 ? MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH : _ref$minItemsForShowM,
|
|
131
|
-
onOptionCreate = _ref.onOptionCreate,
|
|
132
|
-
onOptionEdit = _ref.onOptionEdit,
|
|
133
|
-
onOptionDelete = _ref.onOptionDelete,
|
|
134
|
-
onActionConfirmClick = _ref.onActionConfirmClick,
|
|
135
|
-
onActionCancelClick = _ref.onActionCancelClick,
|
|
136
|
-
onDropdownListClose = _ref.onDropdownListClose,
|
|
137
|
-
customTriggerRef = _ref.customTriggerRef,
|
|
138
|
-
renderCustomTrigger = _ref.renderCustomTrigger,
|
|
139
|
-
recalculateListContainerStylesTrigger = _ref.recalculateListContainerStylesTrigger;
|
|
140
|
-
var inputRef = (0, _react.useRef)(null);
|
|
141
|
-
var wrapperRef = (0, _react.useRef)(null);
|
|
142
|
-
var dropdownRef = (0, _react.useRef)(null);
|
|
143
|
-
var dropdownListRef = (0, _react.useRef)(null);
|
|
144
|
-
var editOptionModalRef = (0, _react.useRef)(null);
|
|
145
|
-
var dropdownListWrapperRef = (0, _react.useRef)(null);
|
|
146
|
-
|
|
147
|
-
var _useIsMobile = (0, _useIsMobile2.default)(),
|
|
148
|
-
isMobileProp = _useIsMobile.isMobile;
|
|
149
|
-
|
|
150
|
-
var isMobile = isMobileProp && withMobileLogic && window.screen.width <= 768;
|
|
151
|
-
|
|
152
|
-
var _useState = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2)),
|
|
153
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
|
154
|
-
dropdownId = _useState2[0];
|
|
155
|
-
|
|
156
|
-
var _useState3 = (0, _react.useState)(false),
|
|
157
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
158
|
-
isOpen = _useState4[0],
|
|
159
|
-
setIsOpen = _useState4[1];
|
|
160
|
-
|
|
161
|
-
var _useState5 = (0, _react.useState)(0),
|
|
162
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
163
|
-
windowScrollTop = _useState6[0],
|
|
164
|
-
setWindowScrollTop = _useState6[1];
|
|
165
|
-
|
|
166
|
-
var _useState7 = (0, _react.useState)(null),
|
|
167
|
-
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
|
168
|
-
listPos = _useState8[0],
|
|
169
|
-
setListPos = _useState8[1];
|
|
170
|
-
|
|
171
|
-
var _useState9 = (0, _react.useState)(null),
|
|
172
|
-
_useState10 = (0, _slicedToArray2.default)(_useState9, 2),
|
|
173
|
-
initListHeight = _useState10[0],
|
|
174
|
-
setInitListHeight = _useState10[1];
|
|
175
|
-
|
|
176
|
-
var _useState11 = (0, _react.useState)(null),
|
|
177
|
-
_useState12 = (0, _slicedToArray2.default)(_useState11, 2),
|
|
178
|
-
isScrollableList = _useState12[0],
|
|
179
|
-
setIsScrollableList = _useState12[1];
|
|
180
|
-
|
|
181
|
-
var _useState13 = (0, _react.useState)(false),
|
|
182
|
-
_useState14 = (0, _slicedToArray2.default)(_useState13, 2),
|
|
183
|
-
isFixedMaxHeight = _useState14[0],
|
|
184
|
-
setIsFixedMaxHeight = _useState14[1];
|
|
185
|
-
|
|
186
|
-
var _useState15 = (0, _react.useState)(0),
|
|
187
|
-
_useState16 = (0, _slicedToArray2.default)(_useState15, 2),
|
|
188
|
-
scrollTop = _useState16[0],
|
|
189
|
-
setScrollTop = _useState16[1];
|
|
190
|
-
|
|
191
|
-
var _useState17 = (0, _react.useState)(1),
|
|
192
|
-
_useState18 = (0, _slicedToArray2.default)(_useState17, 2),
|
|
193
|
-
scrollHeight = _useState18[0],
|
|
194
|
-
setScrollHeight = _useState18[1];
|
|
195
|
-
|
|
196
|
-
var searchValueRef = (0, _react.useRef)(null);
|
|
197
|
-
|
|
198
|
-
var _useState19 = (0, _react.useState)(""),
|
|
199
|
-
_useState20 = (0, _slicedToArray2.default)(_useState19, 2),
|
|
200
|
-
searchValue = _useState20[0],
|
|
201
|
-
setSearchValue = _useState20[1];
|
|
202
|
-
|
|
203
|
-
var debouncedSearchTerm = (0, _useDebounce.useDebounce)({
|
|
204
|
-
searchValue: searchValue,
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
24
|
+
const RC = "tags-dropdown";
|
|
25
|
+
const MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH = 10;
|
|
26
|
+
const COLORS = ["#F1F0F0", "#E3E2E0", "#EEDFDA", "#F9DEC9", "#FDECC8", "#DBECDB", "#D3E4EF", "#E8DEEE", "#F4E0E9", "#FFE2DD", "#D3EFED", "#ECEEDE"];
|
|
27
|
+
const TagsDropdown = _ref => {
|
|
28
|
+
var _Object$keys, _dropdownListWrapperR2, _dropdownListRef$curr8, _dropdownListRef$curr9;
|
|
29
|
+
let {
|
|
30
|
+
options: optionsProp,
|
|
31
|
+
chosenOptions = [],
|
|
32
|
+
onChange,
|
|
33
|
+
className,
|
|
34
|
+
tagClassname,
|
|
35
|
+
listClassName,
|
|
36
|
+
onKeyPress = () => {},
|
|
37
|
+
placeholder,
|
|
38
|
+
label,
|
|
39
|
+
disabled,
|
|
40
|
+
isValuesInTags,
|
|
41
|
+
error,
|
|
42
|
+
isNotValidateASCII = false,
|
|
43
|
+
noTagsWrap = false,
|
|
44
|
+
headerContent = null,
|
|
45
|
+
footerContent = null,
|
|
46
|
+
selectAllButtonRef = null,
|
|
47
|
+
unselectAllButtonRef = null,
|
|
48
|
+
closeOnSelect = false,
|
|
49
|
+
closeOnRemove = false,
|
|
50
|
+
closeOnRemoveAll = false,
|
|
51
|
+
closeOnSelectAll = false,
|
|
52
|
+
closeOnSelectMobile = false,
|
|
53
|
+
closeOnRemoveMobile = false,
|
|
54
|
+
closeOnRemoveAllMobile = false,
|
|
55
|
+
closeOnSelectAllMobile = false,
|
|
56
|
+
fieldKey,
|
|
57
|
+
id,
|
|
58
|
+
noOptionsText = "No options available",
|
|
59
|
+
mobileSearchPlaceholder,
|
|
60
|
+
isSearchable = true,
|
|
61
|
+
useLiveSearch,
|
|
62
|
+
doRequest: doLiveSearchRequest,
|
|
63
|
+
attributesOfNativeInput = {},
|
|
64
|
+
isUseLocalOptionsStore = true,
|
|
65
|
+
isDefaultOpened = false,
|
|
66
|
+
withMobileLogic,
|
|
67
|
+
withCreateLogic,
|
|
68
|
+
withActions,
|
|
69
|
+
withSearchInputInList,
|
|
70
|
+
renderOptionsAsTags,
|
|
71
|
+
minItemsForShowMobileSearch = MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH,
|
|
72
|
+
onOptionCreate,
|
|
73
|
+
onOptionEdit,
|
|
74
|
+
onOptionDelete,
|
|
75
|
+
onActionConfirmClick,
|
|
76
|
+
onActionCancelClick,
|
|
77
|
+
onDropdownListClose,
|
|
78
|
+
customTriggerRef,
|
|
79
|
+
renderCustomTrigger,
|
|
80
|
+
recalculateListContainerStylesTrigger
|
|
81
|
+
} = _ref;
|
|
82
|
+
const inputRef = (0, _react.useRef)(null);
|
|
83
|
+
const wrapperRef = (0, _react.useRef)(null);
|
|
84
|
+
const dropdownRef = (0, _react.useRef)(null);
|
|
85
|
+
const dropdownListRef = (0, _react.useRef)(null);
|
|
86
|
+
const editOptionModalRef = (0, _react.useRef)(null);
|
|
87
|
+
const dropdownListWrapperRef = (0, _react.useRef)(null);
|
|
88
|
+
const {
|
|
89
|
+
isMobile: isMobileProp
|
|
90
|
+
} = (0, _useIsMobile.default)();
|
|
91
|
+
const isMobile = isMobileProp && withMobileLogic && window.screen.width <= 768;
|
|
92
|
+
const [dropdownId] = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2));
|
|
93
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
94
|
+
const [windowScrollTop, setWindowScrollTop] = (0, _react.useState)(0);
|
|
95
|
+
const [listPos, setListPos] = (0, _react.useState)(null);
|
|
96
|
+
const [initListHeight, setInitListHeight] = (0, _react.useState)(null);
|
|
97
|
+
const [isScrollableList, setIsScrollableList] = (0, _react.useState)(null);
|
|
98
|
+
const [isFixedMaxHeight, setIsFixedMaxHeight] = (0, _react.useState)(false);
|
|
99
|
+
const [scrollTop, setScrollTop] = (0, _react.useState)(0);
|
|
100
|
+
const [scrollHeight, setScrollHeight] = (0, _react.useState)(1);
|
|
101
|
+
const searchValueRef = (0, _react.useRef)(null);
|
|
102
|
+
const [searchValue, setSearchValue] = (0, _react.useState)("");
|
|
103
|
+
const debouncedSearchTerm = (0, _useDebounce.useDebounce)({
|
|
104
|
+
searchValue,
|
|
205
105
|
delay: 600
|
|
206
106
|
});
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
_useState22 = (0, _slicedToArray2.default)(_useState21, 2),
|
|
210
|
-
isValueDeleted = _useState22[0],
|
|
211
|
-
setIsValueDeleted = _useState22[1];
|
|
212
|
-
|
|
213
|
-
var setSearchValueInterceptor = function setSearchValueInterceptor(value) {
|
|
107
|
+
const [isValueDeleted, setIsValueDeleted] = (0, _react.useState)(false);
|
|
108
|
+
const setSearchValueInterceptor = value => {
|
|
214
109
|
setSearchValue(value);
|
|
215
110
|
setIsValueDeleted(searchValue !== value && value === "");
|
|
216
111
|
searchValueRef.current = value;
|
|
217
112
|
};
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
var _useState25 = (0, _react.useState)(null),
|
|
227
|
-
_useState26 = (0, _slicedToArray2.default)(_useState25, 2),
|
|
228
|
-
editingOption = _useState26[0],
|
|
229
|
-
setEditingOptionState = _useState26[1];
|
|
230
|
-
|
|
231
|
-
var setEditingOption = function setEditingOption(data) {
|
|
232
|
-
setEditingOptionState(function (editingOption) {
|
|
233
|
-
return !data ? data : _objectSpread(_objectSpread(_objectSpread({}, editingOption !== null && editingOption !== void 0 ? editingOption : {}), typeof data === "function" ? data === null || data === void 0 ? void 0 : data(editingOption) : data), {}, {
|
|
234
|
-
isChanged: Boolean(editingOption)
|
|
235
|
-
});
|
|
113
|
+
const editingOptionInputRef = (0, _react.useRef)(null);
|
|
114
|
+
const [options, setOptions] = (0, _react.useState)([]);
|
|
115
|
+
const [editingOption, setEditingOptionState] = (0, _react.useState)(null);
|
|
116
|
+
const setEditingOption = data => {
|
|
117
|
+
setEditingOptionState(editingOption => !data ? data : {
|
|
118
|
+
...(editingOption !== null && editingOption !== void 0 ? editingOption : {}),
|
|
119
|
+
...(typeof data === "function" ? data === null || data === void 0 ? void 0 : data(editingOption) : data),
|
|
120
|
+
isChanged: Boolean(editingOption)
|
|
236
121
|
});
|
|
237
122
|
};
|
|
238
|
-
|
|
239
|
-
var isEditingOptionError = (0, _react.useMemo)(function () {
|
|
123
|
+
const isEditingOptionError = (0, _react.useMemo)(() => {
|
|
240
124
|
if (!editingOption) return false;
|
|
241
|
-
return options.filter(
|
|
242
|
-
|
|
125
|
+
return options.filter(_ref2 => {
|
|
126
|
+
let {
|
|
127
|
+
value
|
|
128
|
+
} = _ref2;
|
|
243
129
|
return value !== editingOption.value;
|
|
244
|
-
}).some(
|
|
245
|
-
|
|
130
|
+
}).some(_ref3 => {
|
|
131
|
+
let {
|
|
132
|
+
label
|
|
133
|
+
} = _ref3;
|
|
246
134
|
return label === editingOption.label;
|
|
247
135
|
}) ? true : null;
|
|
248
136
|
}, [options, editingOption]);
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
localOptionsStore = _useState28[0],
|
|
253
|
-
setLocalOptionsStore = _useState28[1];
|
|
254
|
-
|
|
255
|
-
var randomColorForNewOption = (0, _react.useMemo)(function () {
|
|
256
|
-
var getRandomIndex = function getRandomIndex(min, max) {
|
|
137
|
+
const [localOptionsStore, setLocalOptionsStore] = (0, _react.useState)({});
|
|
138
|
+
const randomColorForNewOption = (0, _react.useMemo)(() => {
|
|
139
|
+
const getRandomIndex = (min, max) => {
|
|
257
140
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
258
141
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
142
|
+
const randomIndex = getRandomIndex(0, COLORS.length - 1);
|
|
143
|
+
return COLORS[randomIndex];
|
|
144
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
262
145
|
}, [options.length]);
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
146
|
+
const singleLevelOptions = options === null || options === void 0 ? void 0 : options.reduce((acc, item) => {
|
|
147
|
+
const checkUniqAndPush = (acc, item) => {
|
|
148
|
+
const isExist = acc === null || acc === void 0 ? void 0 : acc.findIndex(_ref4 => {
|
|
149
|
+
let {
|
|
150
|
+
value
|
|
151
|
+
} = _ref4;
|
|
267
152
|
return value === (item === null || item === void 0 ? void 0 : item.value);
|
|
268
153
|
});
|
|
269
|
-
|
|
270
154
|
if (isExist !== -1) {
|
|
271
155
|
acc[isExist] = item;
|
|
272
156
|
} else {
|
|
273
157
|
acc.push(item);
|
|
274
158
|
}
|
|
275
159
|
};
|
|
276
|
-
|
|
277
160
|
if (item.groupName) {
|
|
278
161
|
var _item$list;
|
|
279
|
-
|
|
280
|
-
(_item$list = item.list) === null || _item$list === void 0 ? void 0 : _item$list.map(function (item) {
|
|
281
|
-
return checkUniqAndPush(acc, item);
|
|
282
|
-
});
|
|
162
|
+
(_item$list = item.list) === null || _item$list === void 0 || _item$list.map(item => checkUniqAndPush(acc, item));
|
|
283
163
|
} else {
|
|
284
164
|
checkUniqAndPush(acc, item);
|
|
285
165
|
}
|
|
286
|
-
|
|
287
166
|
return acc;
|
|
288
|
-
}, isUseLocalOptionsStore ? (_Object$keys = Object.keys(localOptionsStore)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}) : []);
|
|
294
|
-
|
|
295
|
-
var deleteChosen = function deleteChosen(value) {
|
|
167
|
+
}, isUseLocalOptionsStore ? (_Object$keys = Object.keys(localOptionsStore)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(value => ({
|
|
168
|
+
value,
|
|
169
|
+
label: localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[value]
|
|
170
|
+
})) : []);
|
|
171
|
+
const deleteChosen = value => {
|
|
296
172
|
if (isMobile ? closeOnRemoveMobile : closeOnRemove) setIsOpen(false);
|
|
297
|
-
|
|
298
173
|
if (isUseLocalOptionsStore) {
|
|
299
|
-
setLocalOptionsStore(
|
|
300
|
-
|
|
301
|
-
|
|
174
|
+
setLocalOptionsStore(options => ({
|
|
175
|
+
...options,
|
|
176
|
+
[value]: undefined
|
|
177
|
+
}));
|
|
302
178
|
}
|
|
179
|
+
onChange(chosenOptions.filter(item => item !== value), "chosenOptions");
|
|
180
|
+
};
|
|
303
181
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
}), "chosenOptions");
|
|
307
|
-
}; // --- LIST CONTAINER FUNCTIONS BEGIN --- //
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
var getParentNode = function getParentNode() {
|
|
182
|
+
// --- LIST CONTAINER FUNCTIONS BEGIN --- //
|
|
183
|
+
const getParentNode = () => {
|
|
311
184
|
var _ref5, _document$querySelect;
|
|
312
|
-
|
|
313
185
|
return (_ref5 = (_document$querySelect = document.querySelector("div#root")) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.querySelector("div#app")) !== null && _ref5 !== void 0 ? _ref5 : document.querySelector("div#storybook-root");
|
|
314
186
|
};
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
var dropdownList = document.createElement("div");
|
|
187
|
+
const initListContainer = () => {
|
|
188
|
+
const dropdownList = document.createElement("div");
|
|
318
189
|
dropdownList.setAttribute("id", dropdownId);
|
|
319
190
|
dropdownList.classList.add("tags-dropdown__container");
|
|
320
191
|
listClassName && dropdownList.classList.add(listClassName);
|
|
321
|
-
|
|
322
192
|
if (isMobile) {
|
|
323
|
-
dropdownList.addEventListener("click",
|
|
193
|
+
dropdownList.addEventListener("click", e => {
|
|
324
194
|
if (e.target.id === dropdownId) setIsOpen(false);
|
|
325
195
|
});
|
|
326
196
|
}
|
|
327
|
-
|
|
328
197
|
if (isMobile) {
|
|
329
198
|
var _getParentNode;
|
|
330
|
-
|
|
331
199
|
try {
|
|
332
200
|
var _document$getElementB;
|
|
333
|
-
|
|
334
|
-
|
|
201
|
+
(_document$getElementB = document.getElementById("mlw-".concat(dropdownId))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
|
|
202
|
+
// eslint-disable-next-line no-empty
|
|
335
203
|
} catch (e) {}
|
|
336
|
-
|
|
337
|
-
var dropdownMobileListWrapper = document.createElement("div");
|
|
204
|
+
const dropdownMobileListWrapper = document.createElement("div");
|
|
338
205
|
dropdownMobileListWrapper.classList.add("tags-dropdown-mobile");
|
|
339
206
|
dropdownMobileListWrapper.setAttribute("id", "mlw-".concat(dropdownId));
|
|
340
|
-
dropdownMobileListWrapper === null || dropdownMobileListWrapper === void 0
|
|
341
|
-
(_getParentNode = getParentNode()) === null || _getParentNode === void 0
|
|
207
|
+
dropdownMobileListWrapper === null || dropdownMobileListWrapper === void 0 || dropdownMobileListWrapper.append(dropdownList);
|
|
208
|
+
(_getParentNode = getParentNode()) === null || _getParentNode === void 0 || _getParentNode.append(dropdownMobileListWrapper);
|
|
342
209
|
} else {
|
|
343
210
|
var _getParentNode2;
|
|
344
|
-
|
|
345
|
-
(_getParentNode2 = getParentNode()) === null || _getParentNode2 === void 0 ? void 0 : _getParentNode2.append(dropdownList);
|
|
211
|
+
(_getParentNode2 = getParentNode()) === null || _getParentNode2 === void 0 || _getParentNode2.append(dropdownList);
|
|
346
212
|
}
|
|
347
213
|
};
|
|
348
|
-
|
|
349
|
-
var getListContainer = function getListContainer() {
|
|
214
|
+
const getListContainer = () => {
|
|
350
215
|
return document.getElementById(dropdownId);
|
|
351
216
|
};
|
|
352
|
-
|
|
353
|
-
var getListContainerWrapper = function getListContainerWrapper() {
|
|
217
|
+
const getListContainerWrapper = () => {
|
|
354
218
|
return document.getElementById("mlw-".concat(dropdownId));
|
|
355
219
|
};
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
var listContainer = getListContainer();
|
|
220
|
+
const setListContainerStyles = () => {
|
|
221
|
+
var _dropdownRef$current$, _dropdownRef$current, _getComputedStyle$mar, _getComputedStyle, _selectorWrapper$getB, _listHeader$getBoundi, _listHeader$getBoundi2, _listFooter$getBoundi, _listFooter$getBoundi2;
|
|
222
|
+
const listContainer = getListContainer();
|
|
361
223
|
if (!listContainer || !isOpen) return false;
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
var maxSelectorWrapperHeight = 500 - ((_listHeader$getBoundi = listHeader === null || listHeader === void 0 ? void 0 : (_listHeader$getBoundi2 = listHeader.getBoundingClientRect()) === null || _listHeader$getBoundi2 === void 0 ? void 0 : _listHeader$getBoundi2.height) !== null && _listHeader$getBoundi !== void 0 ? _listHeader$getBoundi : 0) - ((_listFooter$getBoundi = listFooter === null || listFooter === void 0 ? void 0 : (_listFooter$getBoundi2 = listFooter.getBoundingClientRect()) === null || _listFooter$getBoundi2 === void 0 ? void 0 : _listFooter$getBoundi2.height) !== null && _listFooter$getBoundi !== void 0 ? _listFooter$getBoundi : 0);
|
|
377
|
-
|
|
224
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
225
|
+
const {
|
|
226
|
+
width,
|
|
227
|
+
height,
|
|
228
|
+
left,
|
|
229
|
+
top
|
|
230
|
+
} = (_dropdownRef$current$ = dropdownRef === null || dropdownRef === void 0 || (_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.getBoundingClientRect()) !== null && _dropdownRef$current$ !== void 0 ? _dropdownRef$current$ : {};
|
|
231
|
+
const selectorWrapper = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : dropdownListWrapperRef.current;
|
|
232
|
+
const dropdownList = listContainer.getElementsByClassName("tags-dropdown__list")[0];
|
|
233
|
+
const listHeader = selectorWrapper === null || selectorWrapper === void 0 ? void 0 : selectorWrapper.getElementsByClassName("tags-dropdown__header")[0];
|
|
234
|
+
const listFooter = selectorWrapper === null || selectorWrapper === void 0 ? void 0 : selectorWrapper.getElementsByClassName("tags-dropdown__footer")[0];
|
|
235
|
+
const margin = parseInt((_getComputedStyle$mar = (_getComputedStyle = getComputedStyle(selectorWrapper)) === null || _getComputedStyle === void 0 || (_getComputedStyle = _getComputedStyle.marginTop) === null || _getComputedStyle === void 0 ? void 0 : _getComputedStyle.replace("px", "")) !== null && _getComputedStyle$mar !== void 0 ? _getComputedStyle$mar : 0, 10);
|
|
236
|
+
let selectorWrapperHeight = selectorWrapper === null || selectorWrapper === void 0 || (_selectorWrapper$getB = selectorWrapper.getBoundingClientRect()) === null || _selectorWrapper$getB === void 0 ? void 0 : _selectorWrapper$getB.height;
|
|
237
|
+
const maxSelectorWrapperHeight = 500 - ((_listHeader$getBoundi = listHeader === null || listHeader === void 0 || (_listHeader$getBoundi2 = listHeader.getBoundingClientRect()) === null || _listHeader$getBoundi2 === void 0 ? void 0 : _listHeader$getBoundi2.height) !== null && _listHeader$getBoundi !== void 0 ? _listHeader$getBoundi : 0) - ((_listFooter$getBoundi = listFooter === null || listFooter === void 0 || (_listFooter$getBoundi2 = listFooter.getBoundingClientRect()) === null || _listFooter$getBoundi2 === void 0 ? void 0 : _listFooter$getBoundi2.height) !== null && _listFooter$getBoundi !== void 0 ? _listFooter$getBoundi : 0);
|
|
378
238
|
if (!isMobile || !withMobileLogic) {
|
|
379
|
-
var _getComputedStyle2, _dropdownListMaxHeigh, _customTriggerRef$cur, _customTriggerRef$cur2
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
var maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_dropdownListMaxHeigh = dropdownListMaxHeightInPx === null || dropdownListMaxHeightInPx === void 0 ? void 0 : dropdownListMaxHeightInPx.replace("px", "")) !== null && _dropdownListMaxHeigh !== void 0 ? _dropdownListMaxHeigh : 0, 10);
|
|
239
|
+
var _getComputedStyle2, _dropdownListMaxHeigh, _customTriggerRef$cur, _customTriggerRef$cur2;
|
|
240
|
+
const dropdownListMaxHeightInPx = (_getComputedStyle2 = getComputedStyle(dropdownList)) === null || _getComputedStyle2 === void 0 ? void 0 : _getComputedStyle2.maxHeight;
|
|
241
|
+
const maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_dropdownListMaxHeigh = dropdownListMaxHeightInPx === null || dropdownListMaxHeightInPx === void 0 ? void 0 : dropdownListMaxHeightInPx.replace("px", "")) !== null && _dropdownListMaxHeigh !== void 0 ? _dropdownListMaxHeigh : 0, 10);
|
|
383
242
|
if (initListHeight === null && !isNaN(maxHeight)) setInitListHeight(maxHeight);
|
|
384
243
|
if (selectorWrapperHeight > maxHeight && !isNaN(maxHeight)) selectorWrapperHeight = maxHeight - 2 * margin;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
244
|
+
const toTop = renderCustomTrigger ? top - margin - ((_customTriggerRef$cur = customTriggerRef === null || customTriggerRef === void 0 || (_customTriggerRef$cur2 = customTriggerRef.current) === null || _customTriggerRef$cur2 === void 0 || (_customTriggerRef$cur2 = _customTriggerRef$cur2.getBoundingClientRect()) === null || _customTriggerRef$cur2 === void 0 ? void 0 : _customTriggerRef$cur2.height) !== null && _customTriggerRef$cur !== void 0 ? _customTriggerRef$cur : 0) : top - margin;
|
|
245
|
+
const toBottom = windowHeight - top - height - margin * 2;
|
|
246
|
+
let listPosition = listPos;
|
|
389
247
|
if (!listPos && options.length) {
|
|
390
248
|
listPosition = toTop < toBottom || toBottom >= selectorWrapperHeight ? "bottom" : "top";
|
|
391
249
|
setListPos(listPosition);
|
|
392
250
|
}
|
|
393
|
-
|
|
394
251
|
if (selectorWrapperHeight > (listPosition === "top" ? toTop : toBottom)) {
|
|
395
252
|
selectorWrapperHeight = (listPosition === "top" ? toTop : toBottom) - 3 * margin;
|
|
396
|
-
|
|
397
253
|
if (selectorWrapperHeight < 200) {
|
|
398
254
|
selectorWrapperHeight = 200;
|
|
399
255
|
}
|
|
400
|
-
|
|
401
256
|
selectorWrapper.style.maxHeight = "".concat(selectorWrapperHeight, "px");
|
|
402
257
|
}
|
|
403
|
-
|
|
404
258
|
listContainer.style.minWidth = "".concat(width, "px");
|
|
405
259
|
listContainer.style.left = "".concat(left, "px");
|
|
406
260
|
listContainer.style.top = "".concat(listPosition === "bottom" ? top + height : top - selectorWrapperHeight - 2 * margin, "px");
|
|
@@ -408,128 +262,109 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
408
262
|
dropdownList.style.maxHeight = "".concat(maxSelectorWrapperHeight, "px");
|
|
409
263
|
}
|
|
410
264
|
};
|
|
265
|
+
const renderListContainer = () => {
|
|
266
|
+
const lc = getListContainer();
|
|
267
|
+
if (!lc) return null;
|
|
411
268
|
|
|
412
|
-
|
|
413
|
-
var lc = getListContainer();
|
|
414
|
-
if (!lc) return null; // eslint-disable-next-line no-use-before-define
|
|
415
|
-
|
|
269
|
+
// eslint-disable-next-line no-use-before-define
|
|
416
270
|
return /*#__PURE__*/(0, _reactDom.createPortal)(getListMarkUp(), lc);
|
|
417
|
-
};
|
|
418
|
-
// ---
|
|
419
|
-
|
|
271
|
+
};
|
|
272
|
+
// --- LIST CONTAINER FUNCTIONS END --- //
|
|
420
273
|
|
|
421
|
-
|
|
274
|
+
// --- CREATABLE LOGIC BEGIN --- //
|
|
275
|
+
const onOptionCreateClick = () => {
|
|
422
276
|
var _onOptionCreate;
|
|
423
|
-
|
|
424
|
-
var newOption = {
|
|
277
|
+
const newOption = {
|
|
425
278
|
label: searchValue,
|
|
426
279
|
style: {
|
|
427
280
|
backgroundColor: randomColorForNewOption
|
|
428
281
|
},
|
|
429
282
|
isEditable: true,
|
|
430
283
|
ref: /*#__PURE__*/(0, _react.createRef)()
|
|
431
|
-
};
|
|
284
|
+
};
|
|
432
285
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
})).then(function (result) {
|
|
286
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
287
|
+
((_onOptionCreate = onOptionCreate === null || onOptionCreate === void 0 ? void 0 : onOptionCreate(newOption)) !== null && _onOptionCreate !== void 0 ? _onOptionCreate : new Promise(r => r())).then(result => {
|
|
436
288
|
var _result$id;
|
|
437
|
-
|
|
438
|
-
var tempId = Math.random().toString(16).slice(2);
|
|
289
|
+
const tempId = Math.random().toString(16).slice(2);
|
|
439
290
|
newOption.value = (_result$id = result === null || result === void 0 ? void 0 : result.id) !== null && _result$id !== void 0 ? _result$id : tempId;
|
|
440
|
-
setOptions(
|
|
441
|
-
return [].concat((0, _toConsumableArray2.default)(state), [newOption]);
|
|
442
|
-
});
|
|
291
|
+
setOptions(state => [...state, newOption]);
|
|
443
292
|
setSearchValue("");
|
|
444
293
|
onChangeHandler(newOption);
|
|
445
294
|
});
|
|
446
295
|
};
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
e === null || e === void 0
|
|
450
|
-
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
296
|
+
const onOptionEditClick = (e, item) => {
|
|
297
|
+
e === null || e === void 0 || e.preventDefault();
|
|
298
|
+
e === null || e === void 0 || e.stopPropagation();
|
|
451
299
|
setEditingOption((editingOption === null || editingOption === void 0 ? void 0 : editingOption.value) === (item === null || item === void 0 ? void 0 : item.value) ? null : item);
|
|
452
300
|
};
|
|
453
|
-
|
|
454
|
-
var onOptionDeleteClick = function onOptionDeleteClick() {
|
|
301
|
+
const onOptionDeleteClick = () => {
|
|
455
302
|
var _onOptionDelete;
|
|
456
|
-
|
|
457
303
|
// eslint-disable-next-line no-promise-executor-return
|
|
458
|
-
((_onOptionDelete = onOptionDelete === null || onOptionDelete === void 0 ? void 0 : onOptionDelete(editingOption)) !== null && _onOptionDelete !== void 0 ? _onOptionDelete : new Promise(
|
|
459
|
-
return r();
|
|
460
|
-
})).then(function () {
|
|
304
|
+
((_onOptionDelete = onOptionDelete === null || onOptionDelete === void 0 ? void 0 : onOptionDelete(editingOption)) !== null && _onOptionDelete !== void 0 ? _onOptionDelete : new Promise(r => r())).then(() => {
|
|
461
305
|
deleteChosen(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value);
|
|
462
|
-
setOptions(
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
});
|
|
306
|
+
setOptions(options => options.filter(_ref6 => {
|
|
307
|
+
let {
|
|
308
|
+
value
|
|
309
|
+
} = _ref6;
|
|
310
|
+
return value !== (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value);
|
|
311
|
+
}));
|
|
468
312
|
setEditingOption(null);
|
|
469
313
|
});
|
|
470
314
|
};
|
|
471
|
-
|
|
472
|
-
var saveEditingOption = function saveEditingOption() {
|
|
315
|
+
const saveEditingOption = () => {
|
|
473
316
|
if (!(editingOption !== null && editingOption !== void 0 && editingOption.isChanged) || isEditingOptionError) {
|
|
474
317
|
setEditingOption(null);
|
|
475
318
|
return false;
|
|
476
319
|
}
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
return option;
|
|
489
|
-
});
|
|
490
|
-
});
|
|
320
|
+
onOptionEdit === null || onOptionEdit === void 0 || onOptionEdit(editingOption);
|
|
321
|
+
setOptions(options => options.map(option => {
|
|
322
|
+
if (editingOption && option.value === (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value)) {
|
|
323
|
+
const tmp = {
|
|
324
|
+
...editingOption
|
|
325
|
+
};
|
|
326
|
+
setEditingOption(null);
|
|
327
|
+
return tmp;
|
|
328
|
+
}
|
|
329
|
+
return option;
|
|
330
|
+
}));
|
|
491
331
|
};
|
|
492
|
-
|
|
493
|
-
var setEditOptionModalStyles = function setEditOptionModalStyles() {
|
|
332
|
+
const setEditOptionModalStyles = () => {
|
|
494
333
|
var _editingOption$ref, _el$getBoundingClient, _dropdownListWrapperR, _positionClasses, _positionClasses2;
|
|
495
|
-
|
|
496
334
|
if (!editingOption || !(editOptionModalRef !== null && editOptionModalRef !== void 0 && editOptionModalRef.current)) return null;
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
335
|
+
const modalSize = 200;
|
|
336
|
+
const {
|
|
337
|
+
scrollX,
|
|
338
|
+
scrollY
|
|
339
|
+
} = window;
|
|
340
|
+
const positionClasses = {
|
|
502
341
|
left: "modal-left",
|
|
503
342
|
right: "modal-right",
|
|
504
343
|
top: "modal-top",
|
|
505
344
|
bottom: "modal-bottom"
|
|
506
345
|
};
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
Object.values(positionClasses).map(function (className) {
|
|
521
|
-
return editOptionModalRef.current.classList.remove(className);
|
|
522
|
-
});
|
|
346
|
+
const windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
347
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
348
|
+
const el = editingOption === null || editingOption === void 0 || (_editingOption$ref = editingOption.ref) === null || _editingOption$ref === void 0 ? void 0 : _editingOption$ref.current;
|
|
349
|
+
const {
|
|
350
|
+
x,
|
|
351
|
+
y,
|
|
352
|
+
width,
|
|
353
|
+
height
|
|
354
|
+
} = (_el$getBoundingClient = el === null || el === void 0 ? void 0 : el.getBoundingClientRect()) !== null && _el$getBoundingClient !== void 0 ? _el$getBoundingClient : {};
|
|
355
|
+
const containerPosition = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 || (_dropdownListWrapperR = dropdownListWrapperRef.current) === null || _dropdownListWrapperR === void 0 ? void 0 : _dropdownListWrapperR.getBoundingClientRect();
|
|
356
|
+
const distanceToRight = windowWidth - (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.x) - (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.width);
|
|
357
|
+
const distanceToBottom = windowHeight - y - scrollY - height;
|
|
358
|
+
Object.values(positionClasses).map(className => editOptionModalRef.current.classList.remove(className));
|
|
523
359
|
editOptionModalRef.current.classList.add((_positionClasses = positionClasses === null || positionClasses === void 0 ? void 0 : positionClasses[distanceToRight < modalSize ? "left" : "right"]) !== null && _positionClasses !== void 0 ? _positionClasses : "");
|
|
524
360
|
editOptionModalRef.current.classList.add((_positionClasses2 = positionClasses === null || positionClasses === void 0 ? void 0 : positionClasses[distanceToBottom < modalSize ? "top" : "bottom"]) !== null && _positionClasses2 !== void 0 ? _positionClasses2 : "");
|
|
525
|
-
|
|
526
|
-
|
|
361
|
+
const xTranslate = distanceToRight < modalSize ? "calc(-100% + 7px)" : "-35px";
|
|
362
|
+
const yTranslate = distanceToBottom < modalSize ? "calc(-100% - ".concat(height + 10, "px)") : "10px";
|
|
527
363
|
editOptionModalRef.current.style.left = "".concat(x + scrollX + width, "px");
|
|
528
364
|
editOptionModalRef.current.style.top = "".concat(y + scrollY + height, "px");
|
|
529
365
|
editOptionModalRef.current.style.transform = "translate(".concat(xTranslate, ", ").concat(yTranslate, ")");
|
|
530
366
|
};
|
|
531
|
-
|
|
532
|
-
var renderEditOptionModal = function renderEditOptionModal() {
|
|
367
|
+
const renderEditOptionModal = () => {
|
|
533
368
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
534
369
|
key: "editOptionModal".concat(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value),
|
|
535
370
|
ref: editOptionModalRef,
|
|
@@ -538,15 +373,12 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
538
373
|
className: (0, _classnames.default)("".concat(RC, "__edit-option-modal-section"))
|
|
539
374
|
}, /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
540
375
|
value: editingOption.label,
|
|
541
|
-
onChange:
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
},
|
|
376
|
+
onChange: v => setEditingOption(state => ({
|
|
377
|
+
...state,
|
|
378
|
+
label: v
|
|
379
|
+
})),
|
|
548
380
|
error: isEditingOptionError,
|
|
549
|
-
onKeyDown:
|
|
381
|
+
onKeyDown: keyCode => {
|
|
550
382
|
if (keyCode === 13) saveEditingOption();
|
|
551
383
|
},
|
|
552
384
|
symbolsLimit: "50",
|
|
@@ -562,211 +394,182 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
562
394
|
className: (0, _classnames.default)("".concat(RC, "__edit-option-modal-section"))
|
|
563
395
|
}, /*#__PURE__*/_react.default.createElement("h3", null, "Colors"), /*#__PURE__*/_react.default.createElement("div", {
|
|
564
396
|
className: (0, _classnames.default)("".concat(RC, "__edit-option-modal-section-colors"))
|
|
565
|
-
}, COLORS.map(
|
|
397
|
+
}, COLORS.map(color => {
|
|
566
398
|
var _editingOption$style;
|
|
567
|
-
|
|
568
399
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
569
400
|
key: color,
|
|
570
401
|
className: "color-block",
|
|
571
402
|
style: {
|
|
572
403
|
backgroundColor: color
|
|
573
404
|
},
|
|
574
|
-
onClick:
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
}, (editingOption === null || editingOption === void 0 ? void 0 : (_editingOption$style = editingOption.style) === null || _editingOption$style === void 0 ? void 0 : _editingOption$style.backgroundColor) === color ? /*#__PURE__*/_react.default.createElement(_reactFeather.Check, null) : null);
|
|
405
|
+
onClick: () => setEditingOption(state => ({
|
|
406
|
+
...state,
|
|
407
|
+
style: {
|
|
408
|
+
...state.style,
|
|
409
|
+
backgroundColor: color
|
|
410
|
+
}
|
|
411
|
+
}))
|
|
412
|
+
}, (editingOption === null || editingOption === void 0 || (_editingOption$style = editingOption.style) === null || _editingOption$style === void 0 ? void 0 : _editingOption$style.backgroundColor) === color ? /*#__PURE__*/_react.default.createElement(_reactFeather.Check, null) : null);
|
|
584
413
|
}))));
|
|
585
|
-
};
|
|
586
|
-
// ---
|
|
587
|
-
|
|
414
|
+
};
|
|
415
|
+
// --- CREATABLE LOGIC END --- //
|
|
588
416
|
|
|
589
|
-
|
|
417
|
+
// --- GENERAL FUNCTIONS BEGIN --- //
|
|
418
|
+
const handleClickOutside = e => {
|
|
590
419
|
var _getListContainer, _editOptionModalRef$c;
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
if (isOpen && !((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(target)) && !editOptionModalRef.current
|
|
420
|
+
const {
|
|
421
|
+
target
|
|
422
|
+
} = e;
|
|
423
|
+
if (isOpen && !((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(target)) && !editOptionModalRef.current
|
|
424
|
+
// &&
|
|
595
425
|
// (
|
|
596
426
|
// customTriggerRef?.current ? customTriggerRef?.current?.contains(target) : true
|
|
597
427
|
// )
|
|
598
428
|
) {
|
|
599
429
|
setIsOpen(false);
|
|
600
|
-
onDropdownListClose === null || onDropdownListClose === void 0
|
|
430
|
+
onDropdownListClose === null || onDropdownListClose === void 0 || onDropdownListClose(e);
|
|
601
431
|
} else if (editOptionModalRef.current && !((_editOptionModalRef$c = editOptionModalRef.current) !== null && _editOptionModalRef$c !== void 0 && _editOptionModalRef$c.contains(target))) {
|
|
602
|
-
var _document, _document$getElementB2, _document$getElementB3
|
|
603
|
-
|
|
604
|
-
if (!((_document = document) !== null && _document !== void 0 && (_document$getElementB2 = _document.getElementById) !== null && _document$getElementB2 !== void 0 && (_document$getElementB3 = _document$getElementB2.call(_document, "editTrigger".concat(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value))) !== null && _document$getElementB3 !== void 0 && (_document$getElementB4 = _document$getElementB3.contains) !== null && _document$getElementB4 !== void 0 && _document$getElementB4.call(_document$getElementB3, target))) saveEditingOption();
|
|
432
|
+
var _document, _document$getElementB2, _document$getElementB3;
|
|
433
|
+
if (!((_document = document) !== null && _document !== void 0 && (_document$getElementB2 = _document.getElementById) !== null && _document$getElementB2 !== void 0 && (_document$getElementB2 = _document$getElementB2.call(_document, "editTrigger".concat(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value))) !== null && _document$getElementB2 !== void 0 && (_document$getElementB3 = _document$getElementB2.contains) !== null && _document$getElementB3 !== void 0 && _document$getElementB3.call(_document$getElementB2, target))) saveEditingOption();
|
|
605
434
|
}
|
|
606
435
|
};
|
|
607
|
-
|
|
608
|
-
var closeList = function closeList(e) {
|
|
436
|
+
const closeList = e => {
|
|
609
437
|
var _inputRef$current;
|
|
610
|
-
|
|
611
438
|
handleClickOutside(e);
|
|
612
|
-
if (!e.target.isEqualNode(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)) inputRef === null || inputRef === void 0
|
|
439
|
+
if (!e.target.isEqualNode(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)) inputRef === null || inputRef === void 0 || (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 || _inputRef$current.blur();
|
|
613
440
|
};
|
|
614
|
-
|
|
615
|
-
var isTargetInParent = function isTargetInParent(target) {
|
|
441
|
+
const isTargetInParent = target => {
|
|
616
442
|
var _target$className, _target$className$ind, _target$className2, _target$className2$in;
|
|
617
|
-
|
|
618
443
|
if ((target === null || target === void 0 ? void 0 : target.tagName) === "svg" && (target === null || target === void 0 ? void 0 : target.parentNodclassName) === "tag__button" || (target === null || target === void 0 ? void 0 : target.tagName) === "line") return false;
|
|
619
|
-
if ((target === null || target === void 0 ? void 0 : target.tagName) === "svg" && (target === null || target === void 0 ? void 0 : target.parentNodclassName) !== "tag__button" || (target === null || target === void 0
|
|
444
|
+
if ((target === null || target === void 0 ? void 0 : target.tagName) === "svg" && (target === null || target === void 0 ? void 0 : target.parentNodclassName) !== "tag__button" || (target === null || target === void 0 || (_target$className = target.className) === null || _target$className === void 0 || (_target$className$ind = _target$className.indexOf) === null || _target$className$ind === void 0 ? void 0 : _target$className$ind.call(_target$className, "tag__label")) !== -1 || (target === null || target === void 0 || (_target$className2 = target.className) === null || _target$className2 === void 0 || (_target$className2$in = _target$className2.indexOf) === null || _target$className2$in === void 0 ? void 0 : _target$className2$in.call(_target$className2, "tag-list_wrapper")) !== -1 || (target === null || target === void 0 ? void 0 : target.className.indexOf("".concat(RC, "__trigger"))) !== -1 || (target === null || target === void 0 ? void 0 : target.className) === "tags-dropdown__arrow") return true;
|
|
620
445
|
return false;
|
|
621
446
|
};
|
|
622
|
-
|
|
623
|
-
var isItemMatchesSearch = function isItemMatchesSearch(item) {
|
|
447
|
+
const isItemMatchesSearch = item => {
|
|
624
448
|
if (item.isHiddenInList) return false;
|
|
625
|
-
|
|
449
|
+
const title = item.title || item.label;
|
|
626
450
|
return searchValue.length ? title === null || title === void 0 ? void 0 : title.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || "") : true;
|
|
627
|
-
}; // --- GENERAL FUNCTIONS END --- //
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
var prepareOptions = function prepareOptions(options) {
|
|
631
|
-
return options === null || options === void 0 ? void 0 : options.map(function (option) {
|
|
632
|
-
return option !== null && option !== void 0 && option.groupName ? option === null || option === void 0 ? void 0 : option.list : option;
|
|
633
|
-
}).flat();
|
|
634
451
|
};
|
|
452
|
+
// --- GENERAL FUNCTIONS END --- //
|
|
635
453
|
|
|
636
|
-
|
|
637
|
-
return options === null || options === void 0 ? void 0 : options.
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
454
|
+
const prepareOptions = options => {
|
|
455
|
+
return options === null || options === void 0 ? void 0 : options.map(option => option !== null && option !== void 0 && option.groupName ? option === null || option === void 0 ? void 0 : option.list : option).flat();
|
|
456
|
+
};
|
|
457
|
+
const getFilteredOptions = options => options === null || options === void 0 ? void 0 : options.reduce((result, option) => {
|
|
458
|
+
if (option.groupName) {
|
|
459
|
+
var _option$list;
|
|
460
|
+
const filteredGroupItems = option === null || option === void 0 || (_option$list = option.list) === null || _option$list === void 0 ? void 0 : _option$list.filter(item => isItemMatchesSearch(item));
|
|
461
|
+
if (filteredGroupItems !== null && filteredGroupItems !== void 0 && filteredGroupItems.length) {
|
|
462
|
+
result.push({
|
|
463
|
+
...option,
|
|
464
|
+
list: filteredGroupItems
|
|
643
465
|
});
|
|
644
|
-
|
|
645
|
-
if (filteredGroupItems !== null && filteredGroupItems !== void 0 && filteredGroupItems.length) {
|
|
646
|
-
result.push(_objectSpread(_objectSpread({}, option), {}, {
|
|
647
|
-
list: filteredGroupItems
|
|
648
|
-
}));
|
|
649
|
-
}
|
|
650
|
-
} else if (isItemMatchesSearch(option)) {
|
|
651
|
-
result.push(option);
|
|
652
466
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
return options === null || options === void 0 ? void 0 : options.reduce(
|
|
467
|
+
} else if (isItemMatchesSearch(option)) {
|
|
468
|
+
result.push(option);
|
|
469
|
+
}
|
|
470
|
+
return result;
|
|
471
|
+
}, []);
|
|
472
|
+
const getTotalOptions = (0, _react.useCallback)(() => {
|
|
473
|
+
return options === null || options === void 0 ? void 0 : options.reduce((result, item) => {
|
|
660
474
|
if (item !== null && item !== void 0 && item.list) {
|
|
661
475
|
var _item$list2;
|
|
662
|
-
|
|
663
|
-
result += (item === null || item === void 0 ? void 0 : (_item$list2 = item.list) === null || _item$list2 === void 0 ? void 0 : _item$list2.length) || 0;
|
|
476
|
+
result += (item === null || item === void 0 || (_item$list2 = item.list) === null || _item$list2 === void 0 ? void 0 : _item$list2.length) || 0;
|
|
664
477
|
} else {
|
|
665
478
|
++result;
|
|
666
479
|
}
|
|
667
|
-
|
|
668
480
|
return result;
|
|
669
481
|
}, 0);
|
|
670
482
|
}, [options]);
|
|
671
|
-
|
|
672
|
-
var onChangeHandler = function onChangeHandler(item) {
|
|
483
|
+
const onChangeHandler = item => {
|
|
673
484
|
if (item !== null && item !== void 0 && item.isFreezed) return false;
|
|
674
|
-
|
|
675
485
|
if ((item === null || item === void 0 ? void 0 : item.closeOnOptionSelect) !== undefined) {
|
|
676
486
|
if (item.closeOnOptionSelect) setIsOpen(false);
|
|
677
487
|
} else if (isMobile ? closeOnSelectMobile : closeOnSelect) setIsOpen(false);
|
|
678
|
-
|
|
679
488
|
setSearchValueInterceptor("");
|
|
680
|
-
|
|
681
|
-
if (chosenOptions.some(function (el) {
|
|
682
|
-
return el === item.value;
|
|
683
|
-
})) {
|
|
489
|
+
if (chosenOptions.some(el => el === item.value)) {
|
|
684
490
|
deleteChosen(item.value);
|
|
685
491
|
return null;
|
|
686
492
|
}
|
|
687
|
-
|
|
688
493
|
if (isUseLocalOptionsStore) {
|
|
689
|
-
setLocalOptionsStore(
|
|
690
|
-
|
|
691
|
-
|
|
494
|
+
setLocalOptionsStore(options => ({
|
|
495
|
+
...options,
|
|
496
|
+
[item === null || item === void 0 ? void 0 : item.value]: item === null || item === void 0 ? void 0 : item.label
|
|
497
|
+
}));
|
|
692
498
|
}
|
|
693
|
-
|
|
694
|
-
onChange([].concat((0, _toConsumableArray2.default)(chosenOptions), [item.value]), "chosenOptions");
|
|
499
|
+
onChange([...chosenOptions, item.value], "chosenOptions");
|
|
695
500
|
return null;
|
|
696
501
|
};
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
var inputValue = name;
|
|
502
|
+
const onSearchHandler = name => {
|
|
503
|
+
let inputValue = name;
|
|
700
504
|
if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
|
|
701
505
|
setSearchValueInterceptor(inputValue);
|
|
702
506
|
};
|
|
703
|
-
|
|
704
|
-
var onWrapperClick = function onWrapperClick(e) {
|
|
507
|
+
const onWrapperClick = e => {
|
|
705
508
|
if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
|
|
706
509
|
e.stopPropagation();
|
|
707
510
|
e.preventDefault();
|
|
708
511
|
setIsOpen(false);
|
|
709
512
|
}
|
|
710
513
|
};
|
|
711
|
-
|
|
712
|
-
var selectAllItems = function selectAllItems() {
|
|
514
|
+
const selectAllItems = () => {
|
|
713
515
|
var _prepareOptions;
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
516
|
+
const preparedOptions = (_prepareOptions = prepareOptions(options)) === null || _prepareOptions === void 0 ? void 0 : _prepareOptions.filter(_ref7 => {
|
|
517
|
+
let {
|
|
518
|
+
isFreezed,
|
|
519
|
+
value
|
|
520
|
+
} = _ref7;
|
|
718
521
|
return !isFreezed && !(chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.includes(value)) && value !== "open_modal";
|
|
719
522
|
});
|
|
720
|
-
|
|
721
523
|
if (isUseLocalOptionsStore) {
|
|
722
|
-
setLocalOptionsStore(
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
});
|
|
524
|
+
setLocalOptionsStore(options => preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.reduce((result, _ref8) => {
|
|
525
|
+
let {
|
|
526
|
+
value,
|
|
527
|
+
label
|
|
528
|
+
} = _ref8;
|
|
529
|
+
result[value] = label;
|
|
530
|
+
return result;
|
|
531
|
+
}, options));
|
|
730
532
|
}
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
533
|
+
onChange([...chosenOptions, ...((preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(_ref9 => {
|
|
534
|
+
let {
|
|
535
|
+
value
|
|
536
|
+
} = _ref9;
|
|
734
537
|
return value;
|
|
735
|
-
})) || [])
|
|
538
|
+
})) || [])], "chosenOptions");
|
|
736
539
|
if (isMobile ? closeOnSelectAllMobile : closeOnSelectAll) setIsOpen(false);
|
|
737
540
|
};
|
|
738
|
-
|
|
739
|
-
var unselectAllItems = function unselectAllItems() {
|
|
541
|
+
const unselectAllItems = () => {
|
|
740
542
|
if (isUseLocalOptionsStore) setLocalOptionsStore({});
|
|
741
|
-
onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(
|
|
742
|
-
var _prepareOptions2
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
543
|
+
onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(item => {
|
|
544
|
+
var _prepareOptions2;
|
|
545
|
+
return (_prepareOptions2 = prepareOptions(options)) === null || _prepareOptions2 === void 0 || (_prepareOptions2 = _prepareOptions2.find(_ref10 => {
|
|
546
|
+
let {
|
|
547
|
+
value
|
|
548
|
+
} = _ref10;
|
|
746
549
|
return value === item;
|
|
747
|
-
})) === null || _prepareOptions2
|
|
550
|
+
})) === null || _prepareOptions2 === void 0 ? void 0 : _prepareOptions2.isFreezed;
|
|
748
551
|
}), "chosenOptions");
|
|
749
552
|
if (isMobile ? closeOnRemoveAllMobile : closeOnRemoveAll) setIsOpen(false);
|
|
750
553
|
};
|
|
751
|
-
|
|
752
|
-
var doScrollCallback = (0, _react.useCallback)(function (e) {
|
|
554
|
+
const doScrollCallback = (0, _react.useCallback)(e => {
|
|
753
555
|
if (doLiveSearchRequest && typeof doLiveSearchRequest === "function") {
|
|
754
556
|
if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
|
|
755
557
|
doLiveSearchRequest(searchValueRef.current, true);
|
|
756
558
|
}
|
|
757
559
|
}
|
|
758
|
-
}, [options]);
|
|
759
|
-
|
|
760
|
-
var getMarkupForElement = function getMarkupForElement(item) {
|
|
761
|
-
var _item$customMobileIco;
|
|
560
|
+
}, [options]);
|
|
762
561
|
|
|
763
|
-
|
|
764
|
-
var title = item.title || item.label;
|
|
562
|
+
// --- RENDER FUNCTIONS BEGIN --- //
|
|
765
563
|
|
|
766
|
-
|
|
564
|
+
const getMarkupForElement = item => {
|
|
565
|
+
var _item$customMobileIco;
|
|
566
|
+
const {
|
|
567
|
+
description
|
|
568
|
+
} = item;
|
|
569
|
+
const title = item.title || item.label;
|
|
570
|
+
const hightlightSearchValue = title => {
|
|
767
571
|
var _title$toLowerCase;
|
|
768
|
-
|
|
769
|
-
var index = title === null || title === void 0 ? void 0 : (_title$toLowerCase = title.toLowerCase()) === null || _title$toLowerCase === void 0 ? void 0 : _title$toLowerCase.indexOf(searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
572
|
+
const index = title === null || title === void 0 || (_title$toLowerCase = title.toLowerCase()) === null || _title$toLowerCase === void 0 ? void 0 : _title$toLowerCase.indexOf(searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
770
573
|
if (index === -1) return title;
|
|
771
574
|
return /*#__PURE__*/_react.default.createElement("pre", {
|
|
772
575
|
className: "inherit-styles"
|
|
@@ -774,22 +577,27 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
774
577
|
className: "search-match bg--yellow"
|
|
775
578
|
}, title.substring(index, index + (searchValue === null || searchValue === void 0 ? void 0 : searchValue.length))), /*#__PURE__*/_react.default.createElement("span", null, title.substring(index + (searchValue === null || searchValue === void 0 ? void 0 : searchValue.length))));
|
|
776
579
|
};
|
|
777
|
-
|
|
778
580
|
return /*#__PURE__*/_react.default.createElement("button", {
|
|
779
581
|
ref: item === null || item === void 0 ? void 0 : item.ref,
|
|
780
582
|
key: "".concat(RC, "__list-item-").concat(item.id || item.value),
|
|
781
|
-
onClick:
|
|
583
|
+
onClick: e => {
|
|
782
584
|
e.preventDefault();
|
|
783
585
|
e.stopPropagation();
|
|
784
586
|
onChangeHandler(item);
|
|
785
587
|
},
|
|
786
|
-
className: (0, _classnames.default)("".concat(RC, "__list-item"),
|
|
787
|
-
|
|
788
|
-
}
|
|
588
|
+
className: (0, _classnames.default)("".concat(RC, "__list-item"), {
|
|
589
|
+
["".concat(RC, "__list-item_active")]: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.some(value => value === item.value)
|
|
590
|
+
}, {
|
|
591
|
+
["".concat(RC, "__list-item_disabled")]: item.disabled
|
|
592
|
+
}, {
|
|
593
|
+
["".concat(RC, "__list-item_freezed")]: item === null || item === void 0 ? void 0 : item.isFreezed
|
|
594
|
+
}, {
|
|
595
|
+
["".concat(RC, "__list-item--editing")]: (item === null || item === void 0 ? void 0 : item.value) === (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value)
|
|
596
|
+
}, item.className)
|
|
789
597
|
}, !isMobile && /*#__PURE__*/_react.default.createElement("span", {
|
|
790
|
-
className: (0, _classnames.default)("".concat(RC, "__active-icon"),
|
|
791
|
-
|
|
792
|
-
})
|
|
598
|
+
className: (0, _classnames.default)("".concat(RC, "__active-icon"), {
|
|
599
|
+
["".concat(RC, "__active-icon_active")]: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.some(value => value === item.value)
|
|
600
|
+
})
|
|
793
601
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.Check, {
|
|
794
602
|
width: 16,
|
|
795
603
|
height: 16,
|
|
@@ -811,72 +619,55 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
811
619
|
}, description)), !isMobile && (item === null || item === void 0 ? void 0 : item.isEditable) && onOptionEdit && onOptionDelete && /*#__PURE__*/_react.default.createElement("div", {
|
|
812
620
|
id: "editTrigger".concat(item === null || item === void 0 ? void 0 : item.value),
|
|
813
621
|
className: (0, _classnames.default)("".concat(RC, "__list-item-edit-trigger")),
|
|
814
|
-
onClick:
|
|
815
|
-
return onOptionEditClick(e, item);
|
|
816
|
-
}
|
|
622
|
+
onClick: e => onOptionEditClick(e, item)
|
|
817
623
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.MoreHorizontal, null)), isMobile ? (_item$customMobileIco = item === null || item === void 0 ? void 0 : item.customMobileIcon) !== null && _item$customMobileIco !== void 0 ? _item$customMobileIco : /*#__PURE__*/_react.default.createElement(_CheckboxInput.default, {
|
|
818
|
-
value: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.some(
|
|
819
|
-
|
|
820
|
-
}),
|
|
821
|
-
onChange: function onChange() {
|
|
624
|
+
value: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.some(value => value === item.value),
|
|
625
|
+
onChange: () => {
|
|
822
626
|
onChangeHandler(item);
|
|
823
627
|
}
|
|
824
628
|
}) : "");
|
|
825
629
|
};
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
if (option.groupName) {
|
|
841
|
-
var _option$groupName, _option$groupName$toS, _option$list2;
|
|
842
|
-
|
|
843
|
-
arrToPrint.push( /*#__PURE__*/_react.default.createElement("div", {
|
|
844
|
-
key: (_option$groupName = option.groupName) === null || _option$groupName === void 0 ? void 0 : (_option$groupName$toS = _option$groupName.toString()) === null || _option$groupName$toS === void 0 ? void 0 : _option$groupName$toS.replace(/ /g, "_").concat(Date.now()),
|
|
845
|
-
className: (0, _classnames.default)("".concat(RC, "-group"), option.className)
|
|
846
|
-
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
847
|
-
className: "".concat(RC, "-group__name")
|
|
848
|
-
}, option.groupName), (_option$list2 = option.list) === null || _option$list2 === void 0 ? void 0 : _option$list2.map(function (item) {
|
|
849
|
-
return getMarkupForElement(item);
|
|
850
|
-
})));
|
|
851
|
-
} else arrToPrint.push(getMarkupForElement(option));
|
|
852
|
-
}
|
|
853
|
-
} catch (err) {
|
|
854
|
-
_iterator.e(err);
|
|
855
|
-
} finally {
|
|
856
|
-
_iterator.f();
|
|
630
|
+
const getListMarkUp = () => {
|
|
631
|
+
var _filteredOptions$filt, _filteredOptions$filt2, _document$getElementB4;
|
|
632
|
+
const filteredOptions = getFilteredOptions(options);
|
|
633
|
+
const arrToPrint = [];
|
|
634
|
+
for (const option of filteredOptions) {
|
|
635
|
+
if (option.groupName) {
|
|
636
|
+
var _option$groupName, _option$list2;
|
|
637
|
+
arrToPrint.push( /*#__PURE__*/_react.default.createElement("div", {
|
|
638
|
+
key: (_option$groupName = option.groupName) === null || _option$groupName === void 0 || (_option$groupName = _option$groupName.toString()) === null || _option$groupName === void 0 ? void 0 : _option$groupName.replace(/ /g, "_").concat(Date.now()),
|
|
639
|
+
className: (0, _classnames.default)("".concat(RC, "-group"), option.className)
|
|
640
|
+
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
641
|
+
className: "".concat(RC, "-group__name")
|
|
642
|
+
}, option.groupName), (_option$list2 = option.list) === null || _option$list2 === void 0 ? void 0 : _option$list2.map(item => getMarkupForElement(item))));
|
|
643
|
+
} else arrToPrint.push(getMarkupForElement(option));
|
|
857
644
|
}
|
|
858
|
-
|
|
859
645
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
860
646
|
className: (0, _classnames.default)("".concat(RC, "__container-wrapper")),
|
|
861
647
|
ref: wrapperRef,
|
|
862
|
-
onClick: isMobile ? onWrapperClick :
|
|
648
|
+
onClick: isMobile ? onWrapperClick : () => {}
|
|
863
649
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
864
650
|
ref: dropdownListWrapperRef,
|
|
865
|
-
className: (0, _classnames.default)("".concat(RC, "__selector-wrapper"),
|
|
651
|
+
className: (0, _classnames.default)("".concat(RC, "__selector-wrapper"), {
|
|
652
|
+
["".concat(RC, "__selector-wrapper--fixed-height")]: isFixedMaxHeight && isMobile
|
|
653
|
+
})
|
|
866
654
|
}, headerContent || isMobile ? /*#__PURE__*/_react.default.createElement("div", {
|
|
867
|
-
className: (0, _classnames.default)("".concat(RC, "__header"),
|
|
655
|
+
className: (0, _classnames.default)("".concat(RC, "__header"), {
|
|
656
|
+
["".concat(RC, "__header-with-shadow")]: isScrollableList && isMobile,
|
|
657
|
+
["".concat(RC, "__header-with-shadow-hidden")]: scrollTop === 0
|
|
658
|
+
})
|
|
868
659
|
}, isMobile && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
|
869
660
|
className: (0, _classnames.default)("".concat(RC, "__header-row"))
|
|
870
661
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
871
662
|
className: (0, _classnames.default)("".concat(RC, "__label"))
|
|
872
663
|
}, label), /*#__PURE__*/_react.default.createElement("div", {
|
|
873
664
|
className: (0, _classnames.default)("".concat(RC, "__close-icon")),
|
|
874
|
-
onClick:
|
|
665
|
+
onClick: e => {
|
|
875
666
|
e.stopPropagation();
|
|
876
667
|
setIsOpen(false);
|
|
877
668
|
}
|
|
878
669
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.X, {
|
|
879
|
-
onClick:
|
|
670
|
+
onClick: e => {
|
|
880
671
|
e.stopPropagation();
|
|
881
672
|
setIsOpen(false);
|
|
882
673
|
}
|
|
@@ -885,12 +676,10 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
885
676
|
}, /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({
|
|
886
677
|
className: "".concat(RC, "__input"),
|
|
887
678
|
value: searchValue,
|
|
888
|
-
onChange:
|
|
889
|
-
return setSearchValueInterceptor(v);
|
|
890
|
-
},
|
|
679
|
+
onChange: v => setSearchValueInterceptor(v),
|
|
891
680
|
placeholder: mobileSearchPlaceholder || "Search",
|
|
892
681
|
withDelete: true,
|
|
893
|
-
onMouseDown:
|
|
682
|
+
onMouseDown: () => {
|
|
894
683
|
if (!isOpen) {
|
|
895
684
|
setIsOpen(true);
|
|
896
685
|
}
|
|
@@ -899,30 +688,39 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
899
688
|
className: (0, _classnames.default)("".concat(RC, "__header-row"))
|
|
900
689
|
}, headerContent)) : null, withSearchInputInList && /*#__PURE__*/_react.default.createElement("div", {
|
|
901
690
|
className: (0, _classnames.default)("".concat(RC, "__input-list-wrapper"))
|
|
902
|
-
}, renderSearchInput()), withCreateLogic && onOptionCreate && searchValue && filteredOptions.length && singleLevelOptions.every(
|
|
903
|
-
|
|
691
|
+
}, renderSearchInput()), withCreateLogic && onOptionCreate && searchValue && filteredOptions.length && singleLevelOptions.every(_ref11 => {
|
|
692
|
+
let {
|
|
693
|
+
label
|
|
694
|
+
} = _ref11;
|
|
904
695
|
return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
905
696
|
}) ? /*#__PURE__*/_react.default.createElement("div", {
|
|
906
697
|
className: (0, _classnames.default)("".concat(RC, "__creatable-helper"))
|
|
907
698
|
}, "Select an option or create one") : null, /*#__PURE__*/_react.default.createElement("div", {
|
|
908
699
|
ref: dropdownListRef,
|
|
909
700
|
className: "".concat(RC, "__list ").concat(headerContent || isMobile ? "".concat(RC, "__list--with-header") : "", " ").concat(footerContent ? "".concat(RC, "__list--with-footer") : "")
|
|
910
|
-
}, arrToPrint, ((_filteredOptions$filt = filteredOptions.filter(
|
|
911
|
-
|
|
701
|
+
}, arrToPrint, ((_filteredOptions$filt = filteredOptions.filter(_ref12 => {
|
|
702
|
+
let {
|
|
703
|
+
value
|
|
704
|
+
} = _ref12;
|
|
912
705
|
return value !== "open_modal";
|
|
913
706
|
})) === null || _filteredOptions$filt === void 0 ? void 0 : _filteredOptions$filt.length) === 0 && (!withCreateLogic || !searchValue) ? /*#__PURE__*/_react.default.createElement("div", {
|
|
914
707
|
className: "".concat(RC, "__no-options")
|
|
915
|
-
}, noOptionsText) : null), (footerContent || isMobile) && ((_filteredOptions$filt2 = filteredOptions.filter(
|
|
916
|
-
|
|
708
|
+
}, noOptionsText) : null), (footerContent || isMobile) && ((_filteredOptions$filt2 = filteredOptions.filter(_ref13 => {
|
|
709
|
+
let {
|
|
710
|
+
value
|
|
711
|
+
} = _ref13;
|
|
917
712
|
return value !== "open_modal";
|
|
918
713
|
})) === null || _filteredOptions$filt2 === void 0 ? void 0 : _filteredOptions$filt2.length) > 0 ? /*#__PURE__*/_react.default.createElement("div", {
|
|
919
|
-
className: (0, _classnames.default)("".concat(RC, "__footer"),
|
|
714
|
+
className: (0, _classnames.default)("".concat(RC, "__footer"), {
|
|
715
|
+
["".concat(RC, "__footer-with-shadow")]: isMobile && isScrollableList,
|
|
716
|
+
["".concat(RC, "__footer-with-shadow-hidden")]: scrollTop === scrollHeight
|
|
717
|
+
})
|
|
920
718
|
}, footerContent, isMobile && /*#__PURE__*/_react.default.createElement("button", {
|
|
921
|
-
onClick:
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
719
|
+
onClick: () => setIsOpen(false)
|
|
720
|
+
}, "Apply", chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.length ? "(".concat(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.length, ")") : "")) : null, editingOption && /*#__PURE__*/(0, _reactDom.createPortal)(renderEditOptionModal(), (_document$getElementB4 = document.getElementById("app")) !== null && _document$getElementB4 !== void 0 ? _document$getElementB4 : document.body), withCreateLogic && onOptionCreate && searchValue && singleLevelOptions.every(_ref14 => {
|
|
721
|
+
let {
|
|
722
|
+
label
|
|
723
|
+
} = _ref14;
|
|
926
724
|
return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
927
725
|
}) && /*#__PURE__*/_react.default.createElement("div", {
|
|
928
726
|
className: (0, _classnames.default)("".concat(RC, "__create-option")),
|
|
@@ -935,73 +733,70 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
935
733
|
isNoDismiss: true
|
|
936
734
|
}))));
|
|
937
735
|
};
|
|
938
|
-
|
|
939
|
-
var renderSearchInput = function renderSearchInput() {
|
|
736
|
+
const renderSearchInput = () => {
|
|
940
737
|
return /*#__PURE__*/_react.default.createElement(_Input.default, (0, _extends2.default)({
|
|
941
738
|
ref: inputRef,
|
|
942
|
-
className: (0, _classnames.default)("".concat(RC, "__input"),
|
|
739
|
+
className: (0, _classnames.default)("".concat(RC, "__input"), {
|
|
740
|
+
["".concat(RC, "__input--in-list")]: withSearchInputInList
|
|
741
|
+
}),
|
|
943
742
|
value: searchValue,
|
|
944
743
|
onChange: onSearchHandler,
|
|
945
744
|
placeholder: placeholder || "Select from list",
|
|
946
|
-
attributesOfNativeInput:
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
745
|
+
attributesOfNativeInput: {
|
|
746
|
+
...attributesOfNativeInput,
|
|
747
|
+
onKeyDown: e => {
|
|
748
|
+
if (e.keyCode === 13 && withCreateLogic && onOptionCreate && singleLevelOptions.every(_ref15 => {
|
|
749
|
+
let {
|
|
750
|
+
label
|
|
751
|
+
} = _ref15;
|
|
950
752
|
return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
951
753
|
})) {
|
|
952
754
|
onOptionCreateClick();
|
|
953
755
|
}
|
|
954
|
-
|
|
955
756
|
onKeyPress(e, searchValue);
|
|
956
|
-
}
|
|
757
|
+
}
|
|
758
|
+
// onFocus: (e) => {
|
|
957
759
|
// if (isMobile) e?.target?.blur();
|
|
958
760
|
// },
|
|
959
|
-
|
|
960
|
-
})
|
|
761
|
+
}
|
|
961
762
|
}, withCreateLogic ? {
|
|
962
763
|
symbolsLimit: 50
|
|
963
764
|
} : {}));
|
|
964
765
|
};
|
|
965
|
-
|
|
966
|
-
var renderDropdownTrigger = (0, _react.useCallback)(function () {
|
|
766
|
+
const renderDropdownTrigger = (0, _react.useCallback)(() => {
|
|
967
767
|
var _renderCustomTrigger;
|
|
968
|
-
|
|
969
|
-
var renderDefaultDropdownTrigger = function renderDefaultDropdownTrigger() {
|
|
768
|
+
const renderDefaultDropdownTrigger = () => {
|
|
970
769
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
971
|
-
className: (0, _classnames.default)("".concat(RC, "__trigger"),
|
|
972
|
-
"tags-dropdown__error": error
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
770
|
+
className: (0, _classnames.default)("".concat(RC, "__trigger"), {
|
|
771
|
+
"tags-dropdown__error": error,
|
|
772
|
+
["".concat(RC, "__trigger--with-actions")]: withActions
|
|
773
|
+
}),
|
|
774
|
+
onClick: _ref16 => {
|
|
775
|
+
let {
|
|
776
|
+
target
|
|
777
|
+
} = _ref16;
|
|
977
778
|
if ((target === null || target === void 0 ? void 0 : target.tagName) === "INPUT") {
|
|
978
779
|
setIsOpen(true);
|
|
979
780
|
} else if (isTargetInParent(target)) {
|
|
980
|
-
setIsOpen(
|
|
981
|
-
return !isOpen;
|
|
982
|
-
});
|
|
781
|
+
setIsOpen(isOpen => !isOpen);
|
|
983
782
|
}
|
|
984
783
|
}
|
|
985
784
|
}, noTagsWrap ? /*#__PURE__*/_react.default.createElement(_TagList.default, {
|
|
986
|
-
items: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.map(
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
});
|
|
990
|
-
var label = isValuesInTags ? tag === null || tag === void 0 ? void 0 : tag.value : (tag === null || tag === void 0 ? void 0 : tag.label) || (tag === null || tag === void 0 ? void 0 : tag.name) || (tag === null || tag === void 0 ? void 0 : tag.title);
|
|
785
|
+
items: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.map((value, i) => {
|
|
786
|
+
const tag = singleLevelOptions === null || singleLevelOptions === void 0 ? void 0 : singleLevelOptions.find(el => el.value == value);
|
|
787
|
+
const label = isValuesInTags ? tag === null || tag === void 0 ? void 0 : tag.value : (tag === null || tag === void 0 ? void 0 : tag.label) || (tag === null || tag === void 0 ? void 0 : tag.name) || (tag === null || tag === void 0 ? void 0 : tag.title);
|
|
991
788
|
return {
|
|
992
|
-
value
|
|
993
|
-
label
|
|
789
|
+
value,
|
|
790
|
+
label,
|
|
994
791
|
id: i,
|
|
995
792
|
className: tag === null || tag === void 0 ? void 0 : tag.labelClassName,
|
|
996
793
|
style: tag === null || tag === void 0 ? void 0 : tag.style
|
|
997
794
|
};
|
|
998
795
|
}),
|
|
999
796
|
disableShowMore: true
|
|
1000
|
-
}) : chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.map(
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
});
|
|
1004
|
-
var label = isValuesInTags ? tag === null || tag === void 0 ? void 0 : tag.value : (tag === null || tag === void 0 ? void 0 : tag.label) || (tag === null || tag === void 0 ? void 0 : tag.name) || (tag === null || tag === void 0 ? void 0 : tag.title);
|
|
797
|
+
}) : chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.map(value => {
|
|
798
|
+
const tag = singleLevelOptions === null || singleLevelOptions === void 0 ? void 0 : singleLevelOptions.find(el => el.value == value);
|
|
799
|
+
const label = isValuesInTags ? tag === null || tag === void 0 ? void 0 : tag.value : (tag === null || tag === void 0 ? void 0 : tag.label) || (tag === null || tag === void 0 ? void 0 : tag.name) || (tag === null || tag === void 0 ? void 0 : tag.title);
|
|
1005
800
|
return /*#__PURE__*/_react.default.createElement(_Tag.default, {
|
|
1006
801
|
key: value,
|
|
1007
802
|
className: (0, _classnames.default)(tagClassname, tag === null || tag === void 0 ? void 0 : tag.labelClassName, {
|
|
@@ -1009,13 +804,13 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
1009
804
|
}),
|
|
1010
805
|
label: label,
|
|
1011
806
|
style: tag === null || tag === void 0 ? void 0 : tag.style,
|
|
1012
|
-
removeItem: tag !== null && tag !== void 0 && tag.isFreezed ? null :
|
|
1013
|
-
return deleteChosen(value);
|
|
1014
|
-
},
|
|
807
|
+
removeItem: tag !== null && tag !== void 0 && tag.isFreezed ? null : () => deleteChosen(value),
|
|
1015
808
|
isNoDismiss: false
|
|
1016
809
|
});
|
|
1017
810
|
}), chosenOptions.length === 0 || !noTagsWrap ? renderSearchInput() : "", /*#__PURE__*/_react.default.createElement("span", {
|
|
1018
|
-
className: (0, _classnames.default)("".concat(RC, "__arrow"),
|
|
811
|
+
className: (0, _classnames.default)("".concat(RC, "__arrow"), {
|
|
812
|
+
["".concat(RC, "__arrow_active")]: isOpen
|
|
813
|
+
})
|
|
1019
814
|
}, isMobile ? /*#__PURE__*/_react.default.createElement(_reactFeather.Code, {
|
|
1020
815
|
className: "mobile-icon"
|
|
1021
816
|
}) : isOpen ? /*#__PURE__*/_react.default.createElement(_reactFeather.ChevronUp, {
|
|
@@ -1024,31 +819,29 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
1024
819
|
className: "color--text"
|
|
1025
820
|
})));
|
|
1026
821
|
};
|
|
1027
|
-
|
|
1028
822
|
return (_renderCustomTrigger = renderCustomTrigger === null || renderCustomTrigger === void 0 ? void 0 : renderCustomTrigger({
|
|
1029
|
-
chosenOptions
|
|
1030
|
-
singleLevelOptions
|
|
1031
|
-
deleteChosen
|
|
1032
|
-
inputRef
|
|
1033
|
-
onSearchHandler
|
|
1034
|
-
isOpen
|
|
1035
|
-
setIsOpen
|
|
823
|
+
chosenOptions,
|
|
824
|
+
singleLevelOptions,
|
|
825
|
+
deleteChosen,
|
|
826
|
+
inputRef,
|
|
827
|
+
onSearchHandler,
|
|
828
|
+
isOpen,
|
|
829
|
+
setIsOpen
|
|
1036
830
|
})) !== null && _renderCustomTrigger !== void 0 ? _renderCustomTrigger : renderDefaultDropdownTrigger();
|
|
1037
|
-
}, [chosenOptions, singleLevelOptions, inputRef, isOpen]);
|
|
831
|
+
}, [chosenOptions, singleLevelOptions, inputRef, isOpen]);
|
|
832
|
+
// --- RENDER FUNCTIONS END --- //
|
|
1038
833
|
|
|
1039
|
-
(0, _react.useLayoutEffect)(
|
|
834
|
+
(0, _react.useLayoutEffect)(() => {
|
|
1040
835
|
initListContainer();
|
|
1041
836
|
if (isDefaultOpened && !isMobileProp) setIsOpen(true);
|
|
1042
|
-
return
|
|
837
|
+
return () => {
|
|
1043
838
|
var _getListContainer2, _getListContainerWrap;
|
|
1044
|
-
|
|
1045
|
-
(
|
|
1046
|
-
(_getListContainerWrap = getListContainerWrapper()) === null || _getListContainerWrap === void 0 ? void 0 : _getListContainerWrap.remove();
|
|
839
|
+
(_getListContainer2 = getListContainer()) === null || _getListContainer2 === void 0 || _getListContainer2.remove();
|
|
840
|
+
(_getListContainerWrap = getListContainerWrapper()) === null || _getListContainerWrap === void 0 || _getListContainerWrap.remove();
|
|
1047
841
|
};
|
|
1048
842
|
}, []);
|
|
1049
|
-
(0, _react.useLayoutEffect)(
|
|
843
|
+
(0, _react.useLayoutEffect)(() => {
|
|
1050
844
|
var _getListContainer3;
|
|
1051
|
-
|
|
1052
845
|
if (!isMobile) {
|
|
1053
846
|
window.addEventListener("mousewheel", closeList);
|
|
1054
847
|
window.addEventListener("wheel", closeList);
|
|
@@ -1060,148 +853,129 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
1060
853
|
window.removeEventListener("touchmove", closeList);
|
|
1061
854
|
window.removeEventListener("mouseup", handleClickOutside);
|
|
1062
855
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
return function () {
|
|
856
|
+
(_getListContainer3 = getListContainer()) === null || _getListContainer3 === void 0 || _getListContainer3.addEventListener("click", closeList);
|
|
857
|
+
return () => {
|
|
1066
858
|
var _getListContainer4;
|
|
1067
|
-
|
|
1068
859
|
window.removeEventListener("mousewheel", closeList);
|
|
1069
860
|
window.removeEventListener("mouseup", handleClickOutside);
|
|
1070
861
|
window.removeEventListener("wheel", closeList);
|
|
1071
862
|
window.removeEventListener("touchmove", closeList);
|
|
1072
|
-
(_getListContainer4 = getListContainer()) === null || _getListContainer4 === void 0
|
|
863
|
+
(_getListContainer4 = getListContainer()) === null || _getListContainer4 === void 0 || _getListContainer4.removeEventListener("click", closeList);
|
|
1073
864
|
};
|
|
1074
865
|
}, [getListContainer, isMobile]);
|
|
1075
|
-
(0, _react.useLayoutEffect)(
|
|
866
|
+
(0, _react.useLayoutEffect)(() => {
|
|
1076
867
|
if (isOpen) {
|
|
1077
868
|
setListContainerStyles();
|
|
1078
869
|
setEditOptionModalStyles();
|
|
1079
870
|
}
|
|
1080
|
-
}, [isOpen, optionsProp, chosenOptions, searchValue, isMobile, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0
|
|
1081
|
-
(0, _react.useEffect)(
|
|
871
|
+
}, [isOpen, optionsProp, chosenOptions, searchValue, isMobile, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 || (_dropdownListWrapperR2 = dropdownListWrapperRef.current) === null || _dropdownListWrapperR2 === void 0 || (_dropdownListWrapperR2 = _dropdownListWrapperR2.getBoundingClientRect()) === null || _dropdownListWrapperR2 === void 0 ? void 0 : _dropdownListWrapperR2.height, recalculateListContainerStylesTrigger]);
|
|
872
|
+
(0, _react.useEffect)(() => {
|
|
1082
873
|
if (isUseLocalOptionsStore && chosenOptions.length !== Object.keys(localOptionsStore).length) {
|
|
1083
|
-
options.map(
|
|
874
|
+
options.map(option => {
|
|
1084
875
|
if (!(localOptionsStore !== null && localOptionsStore !== void 0 && localOptionsStore[option === null || option === void 0 ? void 0 : option.value])) {
|
|
1085
|
-
setLocalOptionsStore(
|
|
1086
|
-
|
|
1087
|
-
|
|
876
|
+
setLocalOptionsStore(options => ({
|
|
877
|
+
...options,
|
|
878
|
+
[option === null || option === void 0 ? void 0 : option.value]: option === null || option === void 0 ? void 0 : option.label
|
|
879
|
+
}));
|
|
1088
880
|
}
|
|
1089
881
|
});
|
|
1090
882
|
}
|
|
1091
883
|
}, [chosenOptions, isUseLocalOptionsStore]);
|
|
1092
|
-
(0, _react.useEffect)(
|
|
884
|
+
(0, _react.useEffect)(() => {
|
|
1093
885
|
var _selectAllButtonRef$c, _unselectAllButtonRef;
|
|
1094
|
-
|
|
1095
|
-
var windowScrollEventHandler = function windowScrollEventHandler(e) {
|
|
886
|
+
const windowScrollEventHandler = e => {
|
|
1096
887
|
setWindowScrollTop(window.scrollY);
|
|
1097
888
|
};
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
unselectAllButtonRef === null || unselectAllButtonRef === void 0 ? void 0 : (_unselectAllButtonRef = unselectAllButtonRef.current) === null || _unselectAllButtonRef === void 0 ? void 0 : _unselectAllButtonRef[fn]("click", unselectAllItems, true);
|
|
1102
|
-
|
|
889
|
+
const fn = isOpen ? "addEventListener" : "removeEventListener";
|
|
890
|
+
selectAllButtonRef === null || selectAllButtonRef === void 0 || (_selectAllButtonRef$c = selectAllButtonRef.current) === null || _selectAllButtonRef$c === void 0 || _selectAllButtonRef$c[fn]("click", selectAllItems, true);
|
|
891
|
+
unselectAllButtonRef === null || unselectAllButtonRef === void 0 || (_unselectAllButtonRef = unselectAllButtonRef.current) === null || _unselectAllButtonRef === void 0 || _unselectAllButtonRef[fn]("click", unselectAllItems, true);
|
|
1103
892
|
if (isOpen) {
|
|
1104
893
|
var _getListContainer5;
|
|
1105
|
-
|
|
1106
894
|
if (!isMobile || !withMobileLogic) window.removeEventListener("scroll", windowScrollEventHandler);
|
|
1107
|
-
|
|
1108
895
|
if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
|
|
1109
896
|
customTriggerRef.current.style.pointerEvents = "none";
|
|
1110
897
|
}
|
|
1111
|
-
|
|
1112
|
-
(_getListContainer5 = getListContainer()) === null || _getListContainer5 === void 0 ? void 0 : _getListContainer5.classList.add("tags-dropdown__container--opened");
|
|
1113
|
-
|
|
898
|
+
(_getListContainer5 = getListContainer()) === null || _getListContainer5 === void 0 || _getListContainer5.classList.add("tags-dropdown__container--opened");
|
|
1114
899
|
if (!isMobile) {
|
|
1115
900
|
var _inputRef$current2, _inputRef$current2$fo;
|
|
1116
|
-
|
|
1117
|
-
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 ? void 0 : (_inputRef$current2$fo = _inputRef$current2.focus) === null || _inputRef$current2$fo === void 0 ? void 0 : _inputRef$current2$fo.call(_inputRef$current2);
|
|
901
|
+
inputRef === null || inputRef === void 0 || (_inputRef$current2 = inputRef.current) === null || _inputRef$current2 === void 0 || (_inputRef$current2$fo = _inputRef$current2.focus) === null || _inputRef$current2$fo === void 0 || _inputRef$current2$fo.call(_inputRef$current2);
|
|
1118
902
|
} else {
|
|
1119
903
|
var _inputRef$current3, _inputRef$current3$bl;
|
|
1120
|
-
|
|
1121
|
-
inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 ? void 0 : (_inputRef$current3$bl = _inputRef$current3.blur) === null || _inputRef$current3$bl === void 0 ? void 0 : _inputRef$current3$bl.call(_inputRef$current3);
|
|
904
|
+
inputRef === null || inputRef === void 0 || (_inputRef$current3 = inputRef.current) === null || _inputRef$current3 === void 0 || (_inputRef$current3$bl = _inputRef$current3.blur) === null || _inputRef$current3$bl === void 0 || _inputRef$current3$bl.call(_inputRef$current3);
|
|
1122
905
|
}
|
|
1123
906
|
} else {
|
|
1124
907
|
var _getListContainer6;
|
|
1125
|
-
|
|
1126
908
|
if (!isMobile || !withMobileLogic) window.addEventListener("scroll", windowScrollEventHandler);
|
|
1127
|
-
|
|
1128
909
|
if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
|
|
1129
910
|
customTriggerRef.current.style.pointerEvents = "auto";
|
|
1130
911
|
}
|
|
1131
|
-
|
|
1132
|
-
(_getListContainer6 = getListContainer()) === null || _getListContainer6 === void 0 ? void 0 : _getListContainer6.classList.remove("tags-dropdown__container--opened");
|
|
912
|
+
(_getListContainer6 = getListContainer()) === null || _getListContainer6 === void 0 || _getListContainer6.classList.remove("tags-dropdown__container--opened");
|
|
1133
913
|
if (withSearchInputInList) setSearchValueInterceptor("");
|
|
1134
914
|
setListPos(null);
|
|
1135
915
|
setSearchValue("");
|
|
1136
916
|
}
|
|
1137
917
|
}, [isOpen]);
|
|
1138
|
-
(0, _react.useEffect)(
|
|
1139
|
-
|
|
918
|
+
(0, _react.useEffect)(() => {
|
|
919
|
+
const setScrollTopValue = e => {
|
|
1140
920
|
setScrollTop(parseInt(e.target.scrollTop, 10));
|
|
1141
921
|
};
|
|
1142
|
-
|
|
1143
|
-
var preventWindowScrolling = function preventWindowScrolling(e) {
|
|
922
|
+
const preventWindowScrolling = e => {
|
|
1144
923
|
e.preventDefault();
|
|
1145
924
|
window.scrollTo({
|
|
1146
925
|
top: windowScrollTop
|
|
1147
926
|
});
|
|
1148
927
|
};
|
|
1149
|
-
|
|
1150
928
|
if (isOpen && isMobile && dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
1151
929
|
var _dropdownListRef$curr, _dropdownListRef$curr2, _dropdownListRef$curr3;
|
|
1152
|
-
|
|
1153
|
-
dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$
|
|
1154
|
-
setIsScrollableList((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr2 = dropdownListRef.current) === null || _dropdownListRef$curr2 === void 0 ? void 0 : _dropdownListRef$curr2.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr3 = dropdownListRef.current) === null || _dropdownListRef$curr3 === void 0 ? void 0 : _dropdownListRef$curr3.clientHeight));
|
|
1155
|
-
|
|
930
|
+
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr = dropdownListRef.current) === null || _dropdownListRef$curr === void 0 || _dropdownListRef$curr.addEventListener("scroll", setScrollTopValue);
|
|
931
|
+
setIsScrollableList((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr2 = dropdownListRef.current) === null || _dropdownListRef$curr2 === void 0 ? void 0 : _dropdownListRef$curr2.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr3 = dropdownListRef.current) === null || _dropdownListRef$curr3 === void 0 ? void 0 : _dropdownListRef$curr3.clientHeight));
|
|
1156
932
|
if (isScrollableList === null) {
|
|
1157
933
|
var _dropdownListRef$curr4, _dropdownListRef$curr5;
|
|
1158
|
-
|
|
1159
|
-
setIsFixedMaxHeight((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr4 = dropdownListRef.current) === null || _dropdownListRef$curr4 === void 0 ? void 0 : _dropdownListRef$curr4.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr5 = dropdownListRef.current) === null || _dropdownListRef$curr5 === void 0 ? void 0 : _dropdownListRef$curr5.clientHeight));
|
|
934
|
+
setIsFixedMaxHeight((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr4 = dropdownListRef.current) === null || _dropdownListRef$curr4 === void 0 ? void 0 : _dropdownListRef$curr4.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr5 = dropdownListRef.current) === null || _dropdownListRef$curr5 === void 0 ? void 0 : _dropdownListRef$curr5.clientHeight));
|
|
1160
935
|
}
|
|
1161
936
|
}
|
|
1162
|
-
|
|
1163
937
|
if (isOpen && dropdownListRef && dropdownListRef.current) {
|
|
1164
938
|
dropdownListRef.current.addEventListener("scroll", doScrollCallback);
|
|
1165
939
|
if (!isMobile || !withMobileLogic) window.addEventListener("scroll", preventWindowScrolling);
|
|
1166
940
|
}
|
|
1167
|
-
|
|
1168
|
-
return function () {
|
|
941
|
+
return () => {
|
|
1169
942
|
var _dropdownListRef$curr6, _dropdownListRef$curr7;
|
|
1170
|
-
|
|
1171
943
|
if (!isMobile || !withMobileLogic) window.removeEventListener("scroll", preventWindowScrolling);
|
|
1172
|
-
dropdownListRef === null || dropdownListRef === void 0
|
|
1173
|
-
dropdownListRef === null || dropdownListRef === void 0
|
|
944
|
+
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr6 = dropdownListRef.current) === null || _dropdownListRef$curr6 === void 0 || _dropdownListRef$curr6.removeEventListener("scroll", doScrollCallback);
|
|
945
|
+
dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr7 = dropdownListRef.current) === null || _dropdownListRef$curr7 === void 0 || _dropdownListRef$curr7.removeEventListener("scroll", setScrollTopValue);
|
|
1174
946
|
};
|
|
1175
|
-
}, [isOpen, isMobile, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0
|
|
1176
|
-
(0, _react.useEffect)(
|
|
947
|
+
}, [isOpen, isMobile, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr8 = dropdownListRef.current) === null || _dropdownListRef$curr8 === void 0 ? void 0 : _dropdownListRef$curr8.scrollHeight, dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr9 = dropdownListRef.current) === null || _dropdownListRef$curr9 === void 0 ? void 0 : _dropdownListRef$curr9.clientHeight]);
|
|
948
|
+
(0, _react.useEffect)(() => {
|
|
1177
949
|
if (dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
1178
950
|
var _dropdownListRef$curr10, _dropdownListRef$curr11;
|
|
1179
|
-
|
|
1180
|
-
setScrollHeight(parseInt((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr10 = dropdownListRef.current) === null || _dropdownListRef$curr10 === void 0 ? void 0 : _dropdownListRef$curr10.scrollHeight) - (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr11 = dropdownListRef.current) === null || _dropdownListRef$curr11 === void 0 ? void 0 : _dropdownListRef$curr11.clientHeight), 10));
|
|
951
|
+
setScrollHeight(parseInt((dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr10 = dropdownListRef.current) === null || _dropdownListRef$curr10 === void 0 ? void 0 : _dropdownListRef$curr10.scrollHeight) - (dropdownListRef === null || dropdownListRef === void 0 || (_dropdownListRef$curr11 = dropdownListRef.current) === null || _dropdownListRef$curr11 === void 0 ? void 0 : _dropdownListRef$curr11.clientHeight), 10));
|
|
1181
952
|
}
|
|
1182
953
|
}, [scrollTop, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current]);
|
|
1183
|
-
(0, _react.useEffect)(
|
|
954
|
+
(0, _react.useEffect)(() => {
|
|
1184
955
|
if (isSearchable && useLiveSearch && (debouncedSearchTerm || isValueDeleted || isOpen)) {
|
|
1185
|
-
doLiveSearchRequest === null || doLiveSearchRequest === void 0
|
|
956
|
+
doLiveSearchRequest === null || doLiveSearchRequest === void 0 || doLiveSearchRequest(debouncedSearchTerm);
|
|
1186
957
|
}
|
|
1187
958
|
}, [isOpen, debouncedSearchTerm, isValueDeleted]);
|
|
1188
|
-
(0, _react.useEffect)(
|
|
1189
|
-
setOptions(optionsProp.map(
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
}));
|
|
959
|
+
(0, _react.useEffect)(() => {
|
|
960
|
+
setOptions(optionsProp.map(option => ({
|
|
961
|
+
...option,
|
|
962
|
+
ref: /*#__PURE__*/(0, _react.createRef)()
|
|
963
|
+
})));
|
|
1194
964
|
}, [optionsProp]);
|
|
1195
|
-
(0, _react.useEffect)(
|
|
965
|
+
(0, _react.useEffect)(() => {
|
|
1196
966
|
if (editingOption) {
|
|
1197
967
|
var _editingOptionInputRe, _editingOptionInputRe2;
|
|
1198
|
-
|
|
1199
968
|
setEditOptionModalStyles();
|
|
1200
|
-
editingOptionInputRef === null || editingOptionInputRef === void 0
|
|
969
|
+
editingOptionInputRef === null || editingOptionInputRef === void 0 || (_editingOptionInputRe = editingOptionInputRef.current) === null || _editingOptionInputRe === void 0 || (_editingOptionInputRe2 = _editingOptionInputRe.focus) === null || _editingOptionInputRe2 === void 0 || _editingOptionInputRe2.call(_editingOptionInputRe);
|
|
1201
970
|
}
|
|
1202
971
|
}, [editingOption === null || editingOption === void 0 ? void 0 : editingOption.value]);
|
|
1203
972
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
1204
|
-
className: (0, _classnames.default)(RC, className,
|
|
973
|
+
className: (0, _classnames.default)(RC, className, {
|
|
974
|
+
["".concat(RC, "_disabled")]: disabled,
|
|
975
|
+
["".concat(RC, "-mobile")]: isMobile,
|
|
976
|
+
["".concat(RC, "--focused")]: isOpen && !(customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) && !isMobile,
|
|
977
|
+
["".concat(RC, "--custom-trigger")]: Boolean(customTriggerRef === null || customTriggerRef === void 0 ? void 0 : customTriggerRef.current)
|
|
978
|
+
}),
|
|
1205
979
|
ref: dropdownRef
|
|
1206
980
|
}, renderDropdownTrigger(), withActions && /*#__PURE__*/_react.default.createElement("div", {
|
|
1207
981
|
className: (0, _classnames.default)("".concat(RC, "__actions"))
|
|
@@ -1213,6 +987,4 @@ var TagsDropdown = function TagsDropdown(_ref) {
|
|
|
1213
987
|
onClick: onActionCancelClick
|
|
1214
988
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.X, null))), isOpen && renderListContainer());
|
|
1215
989
|
};
|
|
1216
|
-
|
|
1217
|
-
var _default = TagsDropdown;
|
|
1218
|
-
exports.default = _default;
|
|
990
|
+
var _default = exports.default = TagsDropdown;
|