intelicoreact 1.4.23 → 1.4.25
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 +9 -1
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +10 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.js +24 -4
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +10 -1
- package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +14 -2
- package/dist/Atomic/FormElements/Datepicker/Datepicker.js +54 -5
- package/dist/Atomic/FormElements/Datepicker/components/Calendar.js +21 -3
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +144 -51
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +7 -1
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +91 -25
- package/dist/Atomic/FormElements/FileLoader/FileLoader.js +15 -3
- package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +29 -15
- package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +15 -5
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +26 -6
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +35 -19
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +38 -9
- package/dist/Atomic/FormElements/Input/Input.js +60 -25
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +31 -4
- package/dist/Atomic/FormElements/InputColor/InputColor.js +14 -4
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +29 -6
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +43 -8
- package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +21 -3
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +81 -58
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +41 -6
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +8 -1
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +46 -16
- package/dist/Atomic/FormElements/InputLink/InputLink.js +23 -6
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +4 -0
- package/dist/Atomic/FormElements/InputMask/InputMask.js +208 -77
- package/dist/Atomic/FormElements/InputMask/functions.js +28 -2
- package/dist/Atomic/FormElements/InputMask2/InputMask2.js +119 -43
- package/dist/Atomic/FormElements/InputMask2/functions.js +28 -2
- package/dist/Atomic/FormElements/InputMask3/InputMask3.js +137 -44
- package/dist/Atomic/FormElements/InputMask3/functions.js +28 -2
- package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +17 -3
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +24 -5
- package/dist/Atomic/FormElements/Label/Label.js +9 -1
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +73 -35
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +15 -3
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +44 -23
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +17 -7
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +14 -3
- package/dist/Atomic/FormElements/RadioInput/RadioInput.js +10 -1
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +14 -3
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +23 -3
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +34 -17
- package/dist/Atomic/FormElements/RangeList/RangeList.js +25 -6
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +11 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +85 -14
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +132 -43
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +10 -1
- package/dist/Atomic/FormElements/Switcher/Switcher.js +10 -1
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +13 -1
- package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +10 -1
- package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +17 -2
- package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +17 -3
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +11 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +29 -6
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +3 -2
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +12 -1
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +47 -45
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +400 -271
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.scss +26 -4
- package/dist/Atomic/FormElements/Text/Text.js +16 -10
- package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +9 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.js +16 -3
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +35 -6
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +13 -4
- package/dist/Atomic/FormElements/TimeRange/TimeRange.js +21 -7
- package/dist/Atomic/FormElements/UserContacts/UserContacts.js +35 -8
- package/dist/Atomic/FormElements/UserContacts/partial/defaultIcons.js +91 -0
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +18 -5
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +10 -3
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +11 -3
- package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +2 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +12 -5
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +3 -3
- package/dist/Atomic/Layout/Header/Header.js +15 -3
- package/dist/Atomic/Layout/MainMenu/MainMenu.js +20 -3
- package/dist/Atomic/Layout/Spinner/Spinner.js +8 -1
- package/dist/Atomic/UI/Accordion/Accordion.js +19 -3
- package/dist/Atomic/UI/Accordion/AccordionItem.js +23 -9
- package/dist/Atomic/UI/AccordionTable/AccordionTable.js +32 -7
- package/dist/Atomic/UI/AccordionText/AccordionText.js +15 -3
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +21 -4
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +15 -3
- package/dist/Atomic/UI/Alert/Alert.js +19 -3
- package/dist/Atomic/UI/Arrow/Arrow.js +16 -3
- package/dist/Atomic/UI/Box/Box.js +9 -3
- package/dist/Atomic/UI/Button/Button.js +11 -2
- package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +10 -1
- package/dist/Atomic/UI/Chart/Chart.js +29 -4
- package/dist/Atomic/UI/Chart/partial/Chart.constants.js +19 -11
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +12 -1
- package/dist/Atomic/UI/Chart/partial/datasetSetters.js +34 -11
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +56 -82
- package/dist/Atomic/UI/Chart/partial/optionsSetters.js +19 -15
- package/dist/Atomic/UI/Chart/partial/utils.js +20 -6
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +13 -3
- package/dist/Atomic/UI/DateTime/DateTime.js +14 -3
- package/dist/Atomic/UI/DebugContainer/DebugContainer.js +16 -4
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +11 -3
- package/dist/Atomic/UI/DoubleString/DoubleString.js +17 -5
- package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +10 -3
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +52 -17
- package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +29 -1
- package/dist/Atomic/UI/Hint/Hint.js +31 -5
- package/dist/Atomic/UI/Modal/Modal.js +28 -6
- package/dist/Atomic/UI/Modal/ModalHOC.js +9 -1
- package/dist/Atomic/UI/Modal/partials/ModalFooter.js +7 -1
- package/dist/Atomic/UI/Modal/partials/ModalTitle.js +8 -1
- package/dist/Atomic/UI/Modal/partials/useMobileModal.js +49 -32
- package/dist/Atomic/UI/ModalBackup/Modal.js +174 -0
- package/dist/Atomic/UI/ModalBackup/Modal.scss +333 -0
- package/dist/Atomic/UI/ModalBackup/ModalHOC.js +51 -0
- package/dist/Atomic/UI/ModalBackup/partials/ModalFooter.js +24 -0
- package/dist/Atomic/UI/ModalBackup/partials/ModalTitle.js +41 -0
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +21 -6
- package/dist/Atomic/UI/NavLine/NavLine.js +55 -26
- package/dist/Atomic/UI/NavLine/Tabs.js +3 -2
- package/dist/Atomic/UI/PageTitle/PageTitle.js +10 -2
- package/dist/Atomic/UI/PieChart/PieChart.js +10 -1
- package/dist/Atomic/UI/Price/Price.js +8 -3
- package/dist/Atomic/UI/PriceRange/PriceRange.js +7 -1
- package/dist/Atomic/UI/ProgressLine/ProgressLine.js +16 -1
- package/dist/Atomic/UI/Status/Status.js +8 -1
- package/dist/Atomic/UI/Table/Partials/TdCell.js +29 -5
- package/dist/Atomic/UI/Table/Partials/TdHeader.js +11 -1
- package/dist/Atomic/UI/Table/Partials/TdRow.js +17 -5
- package/dist/Atomic/UI/Table/Partials/TdTitle.js +14 -3
- package/dist/Atomic/UI/Table/Table.js +12 -1
- package/dist/Atomic/UI/Table/TdTypes/TdActions.js +18 -2
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +9 -1
- package/dist/Atomic/UI/Table/TdTypes/TdRange.js +4 -1
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +13 -1
- package/dist/Atomic/UI/Tag/Tag.js +54 -11
- package/dist/Atomic/UI/Tag/Tag.scss +2 -3
- package/dist/Atomic/UI/TagList/TagList.js +75 -39
- package/dist/Atomic/UI/TagList/TagList.scss +7 -0
- package/dist/Atomic/UI/UserBox/UserBox.js +13 -1
- package/dist/Classes/AbortableFetch.js +93 -36
- package/dist/Classes/AnimatedHandler.js +7 -3
- package/dist/Classes/RESTAPI/index.js +42 -39
- package/dist/Classes/RESTAPI/partials/AbortableFetch.js +93 -35
- package/dist/Classes/RESTAPI/partials/ApiBase.js +9 -1
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +32 -24
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +41 -34
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +44 -21
- package/dist/Classes/RESTAPI/partials/Utils.js +19 -6
- package/dist/Classes/RESTAPI/partials/_outerDependencies.js +6 -2
- package/dist/Classes/RESTAPI/partials/_utils.js +36 -13
- package/dist/Constants/index.constants.js +15 -8
- package/dist/Functions/Portal.js +16 -5
- package/dist/Functions/customEventListener.js +17 -4
- package/dist/Functions/fieldValueFormatters.js +83 -43
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +26 -23
- package/dist/Functions/locale/createTranslator.js +9 -4
- package/dist/Functions/operations.js +22 -12
- package/dist/Functions/presets/inputMaskPresets.js +11 -9
- package/dist/Functions/presets/inputPresets.js +11 -8
- package/dist/Functions/presets/mobileKeyboardTypesPresets.js +9 -7
- package/dist/Functions/schemas.js +13 -6
- package/dist/Functions/useBodyScrollLock.js +6 -1
- package/dist/Functions/useClickOutside.js +4 -0
- package/dist/Functions/useDebounce.js +7 -2
- package/dist/Functions/useFieldFocus.js +18 -6
- package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +9 -0
- package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +23 -12
- package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +15 -6
- package/dist/Functions/useFormTools/functions/General.js +28 -18
- package/dist/Functions/useFormTools/functions/RenderFields.js +11 -2
- package/dist/Functions/useFormTools/functions/usePrevious.js +5 -1
- package/dist/Functions/useFormTools/index.js +144 -85
- package/dist/Functions/useInputHighlightError.js +12 -3
- package/dist/Functions/useIsMobile.js +13 -7
- package/dist/Functions/useKeyPress/useHandleKeyPress.js +7 -1
- package/dist/Functions/useKeyPress/useKeyPress.js +9 -1
- package/dist/Functions/useLocalStorage.js +9 -1
- package/dist/Functions/useLocationParams.js +5 -4
- package/dist/Functions/useMediaQuery.js +9 -3
- package/dist/Functions/useMetaInfo.js +10 -3
- package/dist/Functions/useMouseUpOutside.js +3 -0
- package/dist/Functions/useOnlineStatus.js +9 -1
- package/dist/Functions/usePasswordChecker.js +20 -4
- package/dist/Functions/usePrevious.js +5 -1
- package/dist/Functions/useResize.js +10 -2
- package/dist/Functions/useScrollTo.js +7 -2
- package/dist/Functions/useToggle.js +5 -1
- package/dist/Functions/utils.js +131 -56
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +9 -2
- package/dist/Molecular/CustomIcons/components/AlertCircle.js +9 -2
- package/dist/Molecular/CustomIcons/components/AppStore.js +9 -2
- package/dist/Molecular/CustomIcons/components/Arrow.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowDown.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowLeft.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowRight.js +9 -2
- package/dist/Molecular/CustomIcons/components/ArrowUp.js +9 -2
- package/dist/Molecular/CustomIcons/components/Bell.js +9 -2
- package/dist/Molecular/CustomIcons/components/Button.js +9 -2
- package/dist/Molecular/CustomIcons/components/Campaigns.js +9 -2
- package/dist/Molecular/CustomIcons/components/Check.js +9 -2
- package/dist/Molecular/CustomIcons/components/Check2.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronDown.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronLeft.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronRight.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronUp.js +9 -2
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +9 -2
- package/dist/Molecular/CustomIcons/components/Close.js +9 -2
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +9 -2
- package/dist/Molecular/CustomIcons/components/Delete.js +9 -2
- package/dist/Molecular/CustomIcons/components/Edit.js +9 -2
- package/dist/Molecular/CustomIcons/components/Email.js +9 -2
- package/dist/Molecular/CustomIcons/components/FinturfLogo.js +9 -2
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +9 -2
- package/dist/Molecular/CustomIcons/components/Flows.js +9 -2
- package/dist/Molecular/CustomIcons/components/Gift.js +9 -2
- package/dist/Molecular/CustomIcons/components/GoogleAuth.js +9 -2
- package/dist/Molecular/CustomIcons/components/GooglePlay.js +9 -2
- package/dist/Molecular/CustomIcons/components/HelpCircle.js +9 -2
- package/dist/Molecular/CustomIcons/components/HelpCircle2.js +9 -2
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +9 -2
- package/dist/Molecular/CustomIcons/components/Home.js +9 -2
- package/dist/Molecular/CustomIcons/components/Home2.js +9 -2
- package/dist/Molecular/CustomIcons/components/Key.js +9 -2
- package/dist/Molecular/CustomIcons/components/Landers.js +9 -2
- package/dist/Molecular/CustomIcons/components/Lock.js +9 -2
- package/dist/Molecular/CustomIcons/components/Mail.js +9 -2
- package/dist/Molecular/CustomIcons/components/Mastercard.js +9 -2
- package/dist/Molecular/CustomIcons/components/Minus.js +9 -2
- package/dist/Molecular/CustomIcons/components/Offers.js +9 -2
- package/dist/Molecular/CustomIcons/components/Pause.js +9 -2
- package/dist/Molecular/CustomIcons/components/PayPal.js +9 -2
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +9 -2
- package/dist/Molecular/CustomIcons/components/Phone.js +9 -2
- package/dist/Molecular/CustomIcons/components/Play.js +9 -2
- package/dist/Molecular/CustomIcons/components/Plus.js +9 -2
- package/dist/Molecular/CustomIcons/components/Profile.js +9 -2
- package/dist/Molecular/CustomIcons/components/QRCode.js +9 -2
- package/dist/Molecular/CustomIcons/components/Rectangle.js +9 -2
- package/dist/Molecular/CustomIcons/components/Revert.js +9 -2
- package/dist/Molecular/CustomIcons/components/Star.js +9 -2
- package/dist/Molecular/CustomIcons/components/Star2.js +9 -2
- package/dist/Molecular/CustomIcons/components/TrafficSources.js +9 -2
- package/dist/Molecular/CustomIcons/components/Trash.js +9 -2
- package/dist/Molecular/CustomIcons/components/TrashRed.js +9 -2
- package/dist/Molecular/CustomIcons/components/Triggers.js +9 -2
- package/dist/Molecular/CustomIcons/components/User.js +9 -2
- package/dist/Molecular/CustomIcons/components/Visa.js +9 -2
- package/dist/Molecular/CustomIcons/components/X.js +9 -2
- package/dist/Molecular/CustomIcons/index.js +122 -0
- package/dist/Molecular/FormElement/FormElement.js +12 -1
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +31 -30
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +12 -9
- package/dist/Molecular/InputAddress/InputAddress.js +114 -65
- package/dist/Molecular/InputPassword/InputPassword.js +19 -5
- package/dist/index.js +2 -0
- package/package.json +1 -1
|
@@ -1,31 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
|
5
6
|
value: true
|
|
6
7
|
});
|
|
7
8
|
exports.default = void 0;
|
|
9
|
+
|
|
8
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
9
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
+
|
|
10
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
15
|
+
|
|
11
16
|
var _reactDom = require("react-dom");
|
|
17
|
+
|
|
12
18
|
var _reactFeather = require("react-feather");
|
|
19
|
+
|
|
13
20
|
var _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
|
|
21
|
+
|
|
14
22
|
var _useDebounce = require("../../../Functions/useDebounce");
|
|
23
|
+
|
|
15
24
|
var _useIsMobile = _interopRequireDefault(require("../../../Functions/useIsMobile"));
|
|
25
|
+
|
|
16
26
|
var _CheckboxInput = _interopRequireDefault(require("../../FormElements/CheckboxInput/CheckboxInput"));
|
|
27
|
+
|
|
17
28
|
var _Input = _interopRequireDefault(require("../../FormElements/Input/Input"));
|
|
29
|
+
|
|
18
30
|
var _Button = _interopRequireDefault(require("../../UI/Button/Button"));
|
|
31
|
+
|
|
19
32
|
var _Tag = _interopRequireDefault(require("../../UI/Tag/Tag"));
|
|
33
|
+
|
|
20
34
|
var _TagList = _interopRequireDefault(require("../../UI/TagList/TagList"));
|
|
35
|
+
|
|
21
36
|
require("./TagsDropdown.scss");
|
|
22
|
-
|
|
23
|
-
function
|
|
37
|
+
|
|
38
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
39
|
+
|
|
40
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
41
|
+
|
|
24
42
|
const RC = "tags-dropdown";
|
|
25
43
|
const MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH = 10;
|
|
26
44
|
const COLORS = ["#F1F0F0", "#E3E2E0", "#EEDFDA", "#F9DEC9", "#FDECC8", "#DBECDB", "#D3E4EF", "#E8DEEE", "#F4E0E9", "#FFE2DD", "#D3EFED", "#ECEEDE"];
|
|
45
|
+
|
|
27
46
|
const TagsDropdown = _ref => {
|
|
28
|
-
var _Object$keys, _dropdownListWrapperR2, _dropdownListRef$curr7, _dropdownListRef$curr8;
|
|
47
|
+
var _Object$keys, _dropdownListWrapperR2, _dropdownListWrapperR3, _dropdownListRef$curr7, _dropdownListRef$curr8;
|
|
48
|
+
|
|
29
49
|
let {
|
|
30
50
|
options: optionsProp,
|
|
31
51
|
chosenOptions = [],
|
|
@@ -101,235 +121,138 @@ const TagsDropdown = _ref => {
|
|
|
101
121
|
delay: 600
|
|
102
122
|
});
|
|
103
123
|
const [isValueDeleted, setIsValueDeleted] = (0, _react.useState)(false);
|
|
124
|
+
|
|
104
125
|
const setSearchValueInterceptor = value => {
|
|
105
126
|
setSearchValue(value);
|
|
106
127
|
setIsValueDeleted(searchValue !== value && value === "");
|
|
107
128
|
searchValueRef.current = value;
|
|
108
129
|
};
|
|
130
|
+
|
|
109
131
|
const [options, setOptions] = (0, _react.useState)([]);
|
|
110
|
-
const [editingOption,
|
|
132
|
+
const [editingOption, setEditingOptionState] = (0, _react.useState)(null);
|
|
133
|
+
|
|
134
|
+
const setEditingOption = data => {
|
|
135
|
+
setEditingOptionState(editingOption => !data ? data : { ...(editingOption !== null && editingOption !== void 0 ? editingOption : {}),
|
|
136
|
+
...(typeof data === "function" ? data === null || data === void 0 ? void 0 : data(editingOption) : data),
|
|
137
|
+
isChanged: Boolean(editingOption)
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const isEditingOptionError = (0, _react.useMemo)(() => {
|
|
142
|
+
if (!editingOption) return false;
|
|
143
|
+
return options.filter(_ref2 => {
|
|
144
|
+
let {
|
|
145
|
+
value
|
|
146
|
+
} = _ref2;
|
|
147
|
+
return value !== editingOption.value;
|
|
148
|
+
}).some(_ref3 => {
|
|
149
|
+
let {
|
|
150
|
+
label
|
|
151
|
+
} = _ref3;
|
|
152
|
+
return label === editingOption.label;
|
|
153
|
+
}) ? true : null;
|
|
154
|
+
}, [options, editingOption]);
|
|
111
155
|
const [localOptionsStore, setLocalOptionsStore] = (0, _react.useState)({});
|
|
112
156
|
const randomColorForNewOption = (0, _react.useMemo)(() => {
|
|
113
157
|
const getRandomIndex = (min, max) => {
|
|
114
158
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
115
159
|
};
|
|
160
|
+
|
|
116
161
|
const randomIndex = getRandomIndex(0, COLORS.length - 1);
|
|
117
|
-
return COLORS[randomIndex];
|
|
118
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
162
|
+
return COLORS[randomIndex]; // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
163
|
}, [options.length]);
|
|
120
164
|
const singleLevelOptions = options === null || options === void 0 ? void 0 : options.reduce((acc, item) => {
|
|
121
165
|
const checkUniqAndPush = (acc, item) => {
|
|
122
|
-
const isExist = acc === null || acc === void 0 ? void 0 : acc.findIndex(
|
|
166
|
+
const isExist = acc === null || acc === void 0 ? void 0 : acc.findIndex(_ref4 => {
|
|
123
167
|
let {
|
|
124
168
|
value
|
|
125
|
-
} =
|
|
169
|
+
} = _ref4;
|
|
126
170
|
return value === (item === null || item === void 0 ? void 0 : item.value);
|
|
127
171
|
});
|
|
172
|
+
|
|
128
173
|
if (isExist !== -1) {
|
|
129
174
|
acc[isExist] = item;
|
|
130
175
|
} else {
|
|
131
176
|
acc.push(item);
|
|
132
177
|
}
|
|
133
178
|
};
|
|
179
|
+
|
|
134
180
|
if (item.groupName) {
|
|
135
181
|
var _item$list;
|
|
136
|
-
|
|
182
|
+
|
|
183
|
+
(_item$list = item.list) === null || _item$list === void 0 ? void 0 : _item$list.map(item => checkUniqAndPush(acc, item));
|
|
137
184
|
} else {
|
|
138
185
|
checkUniqAndPush(acc, item);
|
|
139
186
|
}
|
|
187
|
+
|
|
140
188
|
return acc;
|
|
141
189
|
}, isUseLocalOptionsStore ? (_Object$keys = Object.keys(localOptionsStore)) === null || _Object$keys === void 0 ? void 0 : _Object$keys.map(value => ({
|
|
142
190
|
value,
|
|
143
191
|
label: localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[value]
|
|
144
192
|
})) : []);
|
|
145
193
|
|
|
146
|
-
// --- GENERAL FUNCTIONS BEGIN --- //
|
|
147
|
-
const handleClickOutside = e => {
|
|
148
|
-
var _editOptionModalRef$c, _getListContainer, _customTriggerRef$cur, _customTriggerRef$cur2;
|
|
149
|
-
const {
|
|
150
|
-
target
|
|
151
|
-
} = e;
|
|
152
|
-
if (editOptionModalRef.current && !((_editOptionModalRef$c = editOptionModalRef.current) !== null && _editOptionModalRef$c !== void 0 && _editOptionModalRef$c.contains(target)) && !document.getElementById(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value).contains(target)) {
|
|
153
|
-
saveEditingOption();
|
|
154
|
-
} else if (!((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(target)) && isOpen && (!(customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) || !(customTriggerRef !== null && customTriggerRef !== void 0 && (_customTriggerRef$cur = customTriggerRef.current) !== null && _customTriggerRef$cur !== void 0 && _customTriggerRef$cur.contains(target))) || customTriggerRef !== null && customTriggerRef !== void 0 && (_customTriggerRef$cur2 = customTriggerRef.current) !== null && _customTriggerRef$cur2 !== void 0 && _customTriggerRef$cur2.isEqualNode(target)) {
|
|
155
|
-
setIsOpen(false);
|
|
156
|
-
onDropdownListClose === null || onDropdownListClose === void 0 || onDropdownListClose(e);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
const closeList = e => {
|
|
160
|
-
var _inputRef$current;
|
|
161
|
-
handleClickOutside(e);
|
|
162
|
-
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();
|
|
163
|
-
};
|
|
164
|
-
const isTargetInParent = target => {
|
|
165
|
-
var _target$className, _target$className$ind, _target$className2, _target$className2$in;
|
|
166
|
-
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;
|
|
167
|
-
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;
|
|
168
|
-
return false;
|
|
169
|
-
};
|
|
170
|
-
const isItemMatchesSearch = item => {
|
|
171
|
-
const title = item.title || item.label;
|
|
172
|
-
return searchValue.length ? title === null || title === void 0 ? void 0 : title.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || "") : true;
|
|
173
|
-
};
|
|
174
|
-
// --- GENERAL FUNCTIONS END --- //
|
|
175
|
-
|
|
176
|
-
const prepareOptions = options => {
|
|
177
|
-
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();
|
|
178
|
-
};
|
|
179
|
-
const getFilteredOptions = options => options === null || options === void 0 ? void 0 : options.reduce((result, option) => {
|
|
180
|
-
if (option.groupName) {
|
|
181
|
-
var _option$list;
|
|
182
|
-
const filteredGroupItems = option === null || option === void 0 || (_option$list = option.list) === null || _option$list === void 0 ? void 0 : _option$list.filter(item => isItemMatchesSearch(item));
|
|
183
|
-
if (filteredGroupItems !== null && filteredGroupItems !== void 0 && filteredGroupItems.length) {
|
|
184
|
-
result.push({
|
|
185
|
-
...option,
|
|
186
|
-
list: filteredGroupItems
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
} else if (isItemMatchesSearch(option)) {
|
|
190
|
-
result.push(option);
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}, []);
|
|
194
|
-
const getTotalOptions = (0, _react.useCallback)(() => {
|
|
195
|
-
return options === null || options === void 0 ? void 0 : options.reduce((result, item) => {
|
|
196
|
-
if (item !== null && item !== void 0 && item.list) {
|
|
197
|
-
var _item$list2;
|
|
198
|
-
result += (item === null || item === void 0 || (_item$list2 = item.list) === null || _item$list2 === void 0 ? void 0 : _item$list2.length) || 0;
|
|
199
|
-
} else {
|
|
200
|
-
++result;
|
|
201
|
-
}
|
|
202
|
-
return result;
|
|
203
|
-
}, 0);
|
|
204
|
-
}, [options]);
|
|
205
194
|
const deleteChosen = value => {
|
|
206
195
|
if (isMobile ? closeOnRemoveMobile : closeOnRemove) setIsOpen(false);
|
|
196
|
+
|
|
207
197
|
if (isUseLocalOptionsStore) {
|
|
208
|
-
setLocalOptionsStore(options => ({
|
|
209
|
-
...options,
|
|
198
|
+
setLocalOptionsStore(options => ({ ...options,
|
|
210
199
|
[value]: undefined
|
|
211
200
|
}));
|
|
212
201
|
}
|
|
202
|
+
|
|
213
203
|
onChange(chosenOptions.filter(item => item !== value), "chosenOptions");
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
if (item !== null && item !== void 0 && item.isFreezed) return false;
|
|
217
|
-
if ((item === null || item === void 0 ? void 0 : item.closeOnOptionSelect) !== undefined) {
|
|
218
|
-
if (item.closeOnOptionSelect) setIsOpen(false);
|
|
219
|
-
} else if (isMobile ? closeOnSelectMobile : closeOnSelect) setIsOpen(false);
|
|
220
|
-
setSearchValueInterceptor("");
|
|
221
|
-
if (chosenOptions.some(el => el === item.value)) {
|
|
222
|
-
deleteChosen(item.value);
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
if (isUseLocalOptionsStore) {
|
|
226
|
-
setLocalOptionsStore(options => ({
|
|
227
|
-
...options,
|
|
228
|
-
[item === null || item === void 0 ? void 0 : item.value]: item === null || item === void 0 ? void 0 : item.label
|
|
229
|
-
}));
|
|
230
|
-
}
|
|
231
|
-
onChange([...chosenOptions, item.value], "chosenOptions");
|
|
232
|
-
return null;
|
|
233
|
-
};
|
|
234
|
-
const onSearchHandler = name => {
|
|
235
|
-
let inputValue = name;
|
|
236
|
-
if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
|
|
237
|
-
setSearchValueInterceptor(inputValue);
|
|
238
|
-
};
|
|
239
|
-
const onWrapperClick = e => {
|
|
240
|
-
if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
|
|
241
|
-
e.stopPropagation();
|
|
242
|
-
e.preventDefault();
|
|
243
|
-
setIsOpen(false);
|
|
244
|
-
}
|
|
245
|
-
};
|
|
246
|
-
const selectAllItems = () => {
|
|
247
|
-
var _prepareOptions;
|
|
248
|
-
const preparedOptions = (_prepareOptions = prepareOptions(options)) === null || _prepareOptions === void 0 ? void 0 : _prepareOptions.filter(_ref3 => {
|
|
249
|
-
let {
|
|
250
|
-
isFreezed,
|
|
251
|
-
value
|
|
252
|
-
} = _ref3;
|
|
253
|
-
return !isFreezed && !(chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.includes(value)) && value !== "open_modal";
|
|
254
|
-
});
|
|
255
|
-
if (isUseLocalOptionsStore) {
|
|
256
|
-
setLocalOptionsStore(options => preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.reduce((result, _ref4) => {
|
|
257
|
-
let {
|
|
258
|
-
value,
|
|
259
|
-
label
|
|
260
|
-
} = _ref4;
|
|
261
|
-
result[value] = label;
|
|
262
|
-
return result;
|
|
263
|
-
}, options));
|
|
264
|
-
}
|
|
265
|
-
onChange([...chosenOptions, ...((preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(_ref5 => {
|
|
266
|
-
let {
|
|
267
|
-
value
|
|
268
|
-
} = _ref5;
|
|
269
|
-
return value;
|
|
270
|
-
})) || [])], "chosenOptions");
|
|
271
|
-
if (isMobile ? closeOnSelectAllMobile : closeOnSelectAll) setIsOpen(false);
|
|
272
|
-
};
|
|
273
|
-
const unselectAllItems = () => {
|
|
274
|
-
if (isUseLocalOptionsStore) setLocalOptionsStore({});
|
|
275
|
-
onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(item => {
|
|
276
|
-
var _prepareOptions2;
|
|
277
|
-
return (_prepareOptions2 = prepareOptions(options)) === null || _prepareOptions2 === void 0 || (_prepareOptions2 = _prepareOptions2.find(_ref6 => {
|
|
278
|
-
let {
|
|
279
|
-
value
|
|
280
|
-
} = _ref6;
|
|
281
|
-
return value === item;
|
|
282
|
-
})) === null || _prepareOptions2 === void 0 ? void 0 : _prepareOptions2.isFreezed;
|
|
283
|
-
}), "chosenOptions");
|
|
284
|
-
if (isMobile ? closeOnRemoveAllMobile : closeOnRemoveAll) setIsOpen(false);
|
|
285
|
-
};
|
|
286
|
-
const doScrollCallback = (0, _react.useCallback)(e => {
|
|
287
|
-
if (doLiveSearchRequest && typeof doLiveSearchRequest === "function") {
|
|
288
|
-
if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
|
|
289
|
-
doLiveSearchRequest(searchValueRef.current, true);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
}, [options]);
|
|
204
|
+
}; // --- LIST CONTAINER FUNCTIONS BEGIN --- //
|
|
205
|
+
|
|
293
206
|
|
|
294
|
-
// --- LIST CONTAINER FUNCTIONS BEGIN --- //
|
|
295
207
|
const getParentNode = () => {
|
|
296
|
-
var
|
|
297
|
-
|
|
208
|
+
var _ref5, _document$querySelect;
|
|
209
|
+
|
|
210
|
+
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");
|
|
298
211
|
};
|
|
212
|
+
|
|
299
213
|
const initListContainer = () => {
|
|
300
214
|
const dropdownList = document.createElement("div");
|
|
301
215
|
dropdownList.setAttribute("id", dropdownId);
|
|
302
216
|
dropdownList.classList.add("tags-dropdown__container");
|
|
217
|
+
|
|
303
218
|
if (isMobile) {
|
|
304
219
|
dropdownList.addEventListener("click", e => {
|
|
305
220
|
if (e.target.id === dropdownId) setIsOpen(false);
|
|
306
221
|
});
|
|
307
222
|
}
|
|
223
|
+
|
|
308
224
|
if (isMobile) {
|
|
309
225
|
var _getParentNode;
|
|
226
|
+
|
|
310
227
|
try {
|
|
311
228
|
var _document$getElementB;
|
|
312
|
-
|
|
313
|
-
// eslint-disable-next-line no-empty
|
|
229
|
+
|
|
230
|
+
(_document$getElementB = document.getElementById("mlw-".concat(dropdownId))) === null || _document$getElementB === void 0 ? void 0 : _document$getElementB.remove(); // eslint-disable-next-line no-empty
|
|
314
231
|
} catch (e) {}
|
|
232
|
+
|
|
315
233
|
const dropdownMobileListWrapper = document.createElement("div");
|
|
316
234
|
dropdownMobileListWrapper.classList.add("tags-dropdown-mobile");
|
|
317
235
|
dropdownMobileListWrapper.setAttribute("id", "mlw-".concat(dropdownId));
|
|
318
|
-
dropdownMobileListWrapper === null || dropdownMobileListWrapper === void 0
|
|
319
|
-
(_getParentNode = getParentNode()) === null || _getParentNode === void 0
|
|
236
|
+
dropdownMobileListWrapper === null || dropdownMobileListWrapper === void 0 ? void 0 : dropdownMobileListWrapper.append(dropdownList);
|
|
237
|
+
(_getParentNode = getParentNode()) === null || _getParentNode === void 0 ? void 0 : _getParentNode.append(dropdownMobileListWrapper);
|
|
320
238
|
} else {
|
|
321
239
|
var _getParentNode2;
|
|
322
|
-
|
|
240
|
+
|
|
241
|
+
(_getParentNode2 = getParentNode()) === null || _getParentNode2 === void 0 ? void 0 : _getParentNode2.append(dropdownList);
|
|
323
242
|
}
|
|
324
243
|
};
|
|
244
|
+
|
|
325
245
|
const getListContainer = () => {
|
|
326
246
|
return document.getElementById(dropdownId);
|
|
327
247
|
};
|
|
248
|
+
|
|
328
249
|
const getListContainerWrapper = () => {
|
|
329
250
|
return document.getElementById("mlw-".concat(dropdownId));
|
|
330
251
|
};
|
|
252
|
+
|
|
331
253
|
const setListContainerStyles = () => {
|
|
332
|
-
var _dropdownRef$current$, _dropdownRef$current, _getComputedStyle$mar, _getComputedStyle, _getComputedStyle$max, _getComputedStyle2,
|
|
254
|
+
var _dropdownRef$current$, _dropdownRef$current, _getComputedStyle$mar, _getComputedStyle, _getComputedStyle$mar2, _getComputedStyle$max, _getComputedStyle2, _getComputedStyle2$ma, _sw$getBoundingClient, _sw$getBoundingClient2, _lh$getBoundingClient, _lf$getBoundingClient;
|
|
255
|
+
|
|
333
256
|
const lc = getListContainer();
|
|
334
257
|
if (!lc || !isOpen) return false;
|
|
335
258
|
const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
|
|
@@ -338,42 +261,42 @@ const TagsDropdown = _ref => {
|
|
|
338
261
|
height,
|
|
339
262
|
left,
|
|
340
263
|
top
|
|
341
|
-
} = (_dropdownRef$current$ = dropdownRef === null || dropdownRef === void 0
|
|
264
|
+
} = (_dropdownRef$current$ = dropdownRef === null || dropdownRef === void 0 ? void 0 : (_dropdownRef$current = dropdownRef.current) === null || _dropdownRef$current === void 0 ? void 0 : _dropdownRef$current.getBoundingClientRect()) !== null && _dropdownRef$current$ !== void 0 ? _dropdownRef$current$ : {};
|
|
342
265
|
const sw = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : dropdownListWrapperRef.current;
|
|
343
266
|
const dl = lc.getElementsByClassName("tags-dropdown__list")[0];
|
|
344
267
|
const lh = sw === null || sw === void 0 ? void 0 : sw.getElementsByClassName("tags-dropdown__header")[0];
|
|
345
268
|
const lf = sw === null || sw === void 0 ? void 0 : sw.getElementsByClassName("tags-dropdown__footer")[0];
|
|
346
|
-
const margin = parseInt((_getComputedStyle$mar = (_getComputedStyle = getComputedStyle(sw)) === null || _getComputedStyle === void 0
|
|
347
|
-
const maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_getComputedStyle$max = (_getComputedStyle2 = getComputedStyle(dl)) === null || _getComputedStyle2 === void 0
|
|
269
|
+
const margin = parseInt((_getComputedStyle$mar = (_getComputedStyle = getComputedStyle(sw)) === null || _getComputedStyle === void 0 ? void 0 : (_getComputedStyle$mar2 = _getComputedStyle.marginTop) === null || _getComputedStyle$mar2 === void 0 ? void 0 : _getComputedStyle$mar2.replace("px", "")) !== null && _getComputedStyle$mar !== void 0 ? _getComputedStyle$mar : 0, 10);
|
|
270
|
+
const maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : parseInt((_getComputedStyle$max = (_getComputedStyle2 = getComputedStyle(dl)) === null || _getComputedStyle2 === void 0 ? void 0 : (_getComputedStyle2$ma = _getComputedStyle2.maxHeight) === null || _getComputedStyle2$ma === void 0 ? void 0 : _getComputedStyle2$ma.replace("px", "")) !== null && _getComputedStyle$max !== void 0 ? _getComputedStyle$max : 0, 10);
|
|
348
271
|
if (initListHeight === null) setInitListHeight(maxHeight);
|
|
349
272
|
const toTop = top - margin;
|
|
350
273
|
const toBottom = windowHeight - top - height - margin * 2;
|
|
351
|
-
|
|
352
|
-
let swHeight = sw === null || sw === void 0 || (_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height;
|
|
353
|
-
const controlsHeight = swHeight - dlHeight;
|
|
274
|
+
let swHeight = sw === null || sw === void 0 ? void 0 : (_sw$getBoundingClient = sw.getBoundingClientRect()) === null || _sw$getBoundingClient === void 0 ? void 0 : _sw$getBoundingClient.height;
|
|
354
275
|
if (swHeight > maxHeight) swHeight = maxHeight - 2 * margin;
|
|
355
|
-
const maxSwHeight = (sw === null || sw === void 0
|
|
276
|
+
const maxSwHeight = (sw === null || sw === void 0 ? void 0 : (_sw$getBoundingClient2 = sw.getBoundingClientRect()) === null || _sw$getBoundingClient2 === void 0 ? void 0 : _sw$getBoundingClient2.height) - (lh === null || lh === void 0 ? void 0 : (_lh$getBoundingClient = lh.getBoundingClientRect()) === null || _lh$getBoundingClient === void 0 ? void 0 : _lh$getBoundingClient.height) - (lf === null || lf === void 0 ? void 0 : (_lf$getBoundingClient = lf.getBoundingClientRect()) === null || _lf$getBoundingClient === void 0 ? void 0 : _lf$getBoundingClient.height);
|
|
356
277
|
const listPos = toTop < toBottom || toBottom >= swHeight ? "bottom" : "top";
|
|
357
278
|
if (swHeight > (listPos === "top" ? toTop : toBottom)) swHeight = (listPos === "top" ? toTop : toBottom) - 3 * margin;
|
|
358
279
|
lc.style.minWidth = "".concat(width, "px");
|
|
359
280
|
lc.style.left = "".concat(left, "px");
|
|
360
281
|
lc.style.top = "".concat(listPos === "bottom" ? top + height : top - swHeight - 2 * margin, "px");
|
|
282
|
+
|
|
361
283
|
if (isMobile) {
|
|
362
284
|
dl.style.maxHeight = "".concat(maxSwHeight, "px");
|
|
363
285
|
}
|
|
364
286
|
};
|
|
287
|
+
|
|
365
288
|
const renderListContainer = () => {
|
|
366
289
|
const lc = getListContainer();
|
|
367
|
-
if (!lc) return null;
|
|
290
|
+
if (!lc) return null; // eslint-disable-next-line no-use-before-define
|
|
368
291
|
|
|
369
|
-
// eslint-disable-next-line no-use-before-define
|
|
370
292
|
return /*#__PURE__*/(0, _reactDom.createPortal)(getListMarkUp(), lc);
|
|
371
|
-
};
|
|
372
|
-
// --- LIST CONTAINER FUNCTIONS END --- //
|
|
373
|
-
|
|
293
|
+
}; // --- LIST CONTAINER FUNCTIONS END --- //
|
|
374
294
|
// --- CREATABLE LOGIC BEGIN --- //
|
|
295
|
+
|
|
296
|
+
|
|
375
297
|
const onOptionCreateClick = () => {
|
|
376
298
|
var _onOptionCreate;
|
|
299
|
+
|
|
377
300
|
const newOption = {
|
|
378
301
|
label: searchValue,
|
|
379
302
|
style: {
|
|
@@ -381,107 +304,106 @@ const TagsDropdown = _ref => {
|
|
|
381
304
|
},
|
|
382
305
|
isEditable: true,
|
|
383
306
|
ref: /*#__PURE__*/(0, _react.createRef)()
|
|
384
|
-
};
|
|
307
|
+
}; // eslint-disable-next-line no-promise-executor-return
|
|
308
|
+
|
|
385
309
|
((_onOptionCreate = onOptionCreate === null || onOptionCreate === void 0 ? void 0 : onOptionCreate(newOption)) !== null && _onOptionCreate !== void 0 ? _onOptionCreate : new Promise(r => r())).then(result => {
|
|
386
310
|
var _result$id;
|
|
311
|
+
|
|
387
312
|
const tempId = Math.random().toString(16).slice(2);
|
|
388
313
|
newOption.value = (_result$id = result === null || result === void 0 ? void 0 : result.id) !== null && _result$id !== void 0 ? _result$id : tempId;
|
|
389
314
|
setOptions(state => [...state, newOption]);
|
|
390
315
|
setSearchValue("");
|
|
391
|
-
onChangeHandler(
|
|
392
|
-
value: tempId,
|
|
393
|
-
label: searchValue
|
|
394
|
-
});
|
|
316
|
+
onChangeHandler(newOption);
|
|
395
317
|
});
|
|
396
318
|
};
|
|
319
|
+
|
|
397
320
|
const onOptionEditClick = (e, item) => {
|
|
398
|
-
e === null || e === void 0
|
|
399
|
-
e === null || e === void 0
|
|
321
|
+
e === null || e === void 0 ? void 0 : e.preventDefault();
|
|
322
|
+
e === null || e === void 0 ? void 0 : e.stopPropagation();
|
|
400
323
|
setEditingOption((editingOption === null || editingOption === void 0 ? void 0 : editingOption.value) === (item === null || item === void 0 ? void 0 : item.value) ? null : item);
|
|
401
324
|
};
|
|
325
|
+
|
|
402
326
|
const onOptionDeleteClick = () => {
|
|
403
327
|
var _onOptionDelete;
|
|
328
|
+
|
|
329
|
+
// eslint-disable-next-line no-promise-executor-return
|
|
404
330
|
((_onOptionDelete = onOptionDelete === null || onOptionDelete === void 0 ? void 0 : onOptionDelete(editingOption)) !== null && _onOptionDelete !== void 0 ? _onOptionDelete : new Promise(r => r())).then(() => {
|
|
405
331
|
deleteChosen(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value);
|
|
406
|
-
setOptions(options => options.filter(
|
|
332
|
+
setOptions(options => options.filter(_ref6 => {
|
|
407
333
|
let {
|
|
408
334
|
value
|
|
409
|
-
} =
|
|
335
|
+
} = _ref6;
|
|
410
336
|
return value !== (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value);
|
|
411
337
|
}));
|
|
412
338
|
setEditingOption(null);
|
|
413
339
|
});
|
|
414
340
|
};
|
|
341
|
+
|
|
415
342
|
const saveEditingOption = () => {
|
|
416
|
-
|
|
343
|
+
if (!(editingOption !== null && editingOption !== void 0 && editingOption.isChanged) || isEditingOptionError) {
|
|
344
|
+
setEditingOption(null);
|
|
345
|
+
return false;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
onOptionEdit === null || onOptionEdit === void 0 ? void 0 : onOptionEdit(editingOption);
|
|
417
349
|
setOptions(options => options.map(option => {
|
|
418
350
|
if (editingOption && option.value === (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value)) {
|
|
419
|
-
const tmp = {
|
|
420
|
-
...editingOption
|
|
351
|
+
const tmp = { ...editingOption
|
|
421
352
|
};
|
|
422
353
|
setEditingOption(null);
|
|
423
354
|
return tmp;
|
|
424
355
|
}
|
|
356
|
+
|
|
425
357
|
return option;
|
|
426
358
|
}));
|
|
427
359
|
};
|
|
360
|
+
|
|
428
361
|
const setEditOptionModalStyles = () => {
|
|
429
|
-
var _editingOption$ref, _el$getBoundingClient, _dropdownListWrapperR;
|
|
362
|
+
var _editingOption$ref, _el$getBoundingClient, _dropdownListWrapperR, _positionClasses;
|
|
363
|
+
|
|
430
364
|
if (!editingOption || !(editOptionModalRef !== null && editOptionModalRef !== void 0 && editOptionModalRef.current)) return null;
|
|
431
|
-
const
|
|
365
|
+
const {
|
|
366
|
+
scrollX,
|
|
367
|
+
scrollY
|
|
368
|
+
} = window;
|
|
369
|
+
const positionClasses = {
|
|
370
|
+
left: "modal-left",
|
|
371
|
+
right: "modal-right"
|
|
372
|
+
};
|
|
432
373
|
const windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
|
|
433
|
-
|
|
434
|
-
windowHeight,
|
|
435
|
-
windowWidth
|
|
436
|
-
});
|
|
437
|
-
const el = editingOption === null || editingOption === void 0 || (_editingOption$ref = editingOption.ref) === null || _editingOption$ref === void 0 ? void 0 : _editingOption$ref.current;
|
|
374
|
+
const el = editingOption === null || editingOption === void 0 ? void 0 : (_editingOption$ref = editingOption.ref) === null || _editingOption$ref === void 0 ? void 0 : _editingOption$ref.current;
|
|
438
375
|
const {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
left,
|
|
442
|
-
right,
|
|
376
|
+
x,
|
|
377
|
+
y,
|
|
443
378
|
width,
|
|
444
379
|
height
|
|
445
380
|
} = (_el$getBoundingClient = el === null || el === void 0 ? void 0 : el.getBoundingClientRect()) !== null && _el$getBoundingClient !== void 0 ? _el$getBoundingClient : {};
|
|
446
|
-
const containerPosition = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
// console.log(containerPosition.top, {
|
|
454
|
-
// top,
|
|
455
|
-
// bottom,
|
|
456
|
-
// left,
|
|
457
|
-
// right,
|
|
458
|
-
// width,
|
|
459
|
-
// height,
|
|
460
|
-
// });
|
|
461
|
-
|
|
462
|
-
editOptionModalRef.current.style.top = "".concat(top - height, "px");
|
|
463
|
-
|
|
464
|
-
// if (containerPosition?.top + top <= 173) {
|
|
465
|
-
// editOptionModalRef.current.style.top = `${top - height}px`;
|
|
466
|
-
// } else {
|
|
467
|
-
// editOptionModalRef.current.style.bottom = `${bottom - height}px`;
|
|
468
|
-
// }
|
|
381
|
+
const containerPosition = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperR = dropdownListWrapperRef.current) === null || _dropdownListWrapperR === void 0 ? void 0 : _dropdownListWrapperR.getBoundingClientRect();
|
|
382
|
+
const widthToRight = windowWidth - (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.x) - (containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.width);
|
|
383
|
+
Object.values(positionClasses).map(className => editOptionModalRef.current.classList.remove(className));
|
|
384
|
+
editOptionModalRef.current.classList.add((_positionClasses = positionClasses === null || positionClasses === void 0 ? void 0 : positionClasses[widthToRight < 182 ? "left" : "right"]) !== null && _positionClasses !== void 0 ? _positionClasses : "");
|
|
385
|
+
editOptionModalRef.current.style.left = "".concat(x + scrollX + width, "px");
|
|
386
|
+
editOptionModalRef.current.style.top = "".concat(y + scrollY + height + 10, "px");
|
|
387
|
+
editOptionModalRef.current.style.transform = widthToRight < 182 ? "translateX(calc(-100% + 7px))" : "translateX(-35px)";
|
|
469
388
|
};
|
|
389
|
+
|
|
470
390
|
const renderEditOptionModal = () => {
|
|
471
391
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
392
|
+
key: "editOptionModal".concat(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value),
|
|
472
393
|
ref: editOptionModalRef,
|
|
473
394
|
className: (0, _classnames.default)("".concat(RC, "__edit-option-modal"))
|
|
474
395
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
475
396
|
className: (0, _classnames.default)("".concat(RC, "__edit-option-modal-section"))
|
|
476
397
|
}, /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
477
398
|
value: editingOption.label,
|
|
478
|
-
onChange: v => setEditingOption(state => ({
|
|
479
|
-
...state,
|
|
399
|
+
onChange: v => setEditingOption(state => ({ ...state,
|
|
480
400
|
label: v
|
|
481
401
|
})),
|
|
402
|
+
error: isEditingOptionError,
|
|
482
403
|
onKeyDown: keyCode => {
|
|
483
404
|
if (keyCode === 13) saveEditingOption();
|
|
484
|
-
}
|
|
405
|
+
},
|
|
406
|
+
symbolsLimit: "50"
|
|
485
407
|
}), /*#__PURE__*/_react.default.createElement(_Button.default, {
|
|
486
408
|
variant: "link",
|
|
487
409
|
icon: /*#__PURE__*/_react.default.createElement(_reactFeather.Trash2, null),
|
|
@@ -495,33 +417,206 @@ const TagsDropdown = _ref => {
|
|
|
495
417
|
className: (0, _classnames.default)("".concat(RC, "__edit-option-modal-section-colors"))
|
|
496
418
|
}, COLORS.map(color => {
|
|
497
419
|
var _editingOption$style;
|
|
420
|
+
|
|
498
421
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
422
|
+
key: color,
|
|
499
423
|
className: "color-block",
|
|
500
424
|
style: {
|
|
501
425
|
backgroundColor: color
|
|
502
426
|
},
|
|
503
|
-
onClick: () => setEditingOption(state => ({
|
|
504
|
-
...state,
|
|
505
|
-
style: {
|
|
506
|
-
...state.style,
|
|
427
|
+
onClick: () => setEditingOption(state => ({ ...state,
|
|
428
|
+
style: { ...state.style,
|
|
507
429
|
backgroundColor: color
|
|
508
430
|
}
|
|
509
431
|
}))
|
|
510
|
-
}, (editingOption === null || editingOption === void 0
|
|
432
|
+
}, (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);
|
|
511
433
|
}))));
|
|
434
|
+
}; // --- CREATABLE LOGIC END --- //
|
|
435
|
+
// --- GENERAL FUNCTIONS BEGIN --- //
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
const handleClickOutside = e => {
|
|
439
|
+
var _getListContainer, _editOptionModalRef$c;
|
|
440
|
+
|
|
441
|
+
const {
|
|
442
|
+
target
|
|
443
|
+
} = e;
|
|
444
|
+
|
|
445
|
+
if (isOpen && !((_getListContainer = getListContainer()) !== null && _getListContainer !== void 0 && _getListContainer.contains(target)) && !editOptionModalRef.current // &&
|
|
446
|
+
// (
|
|
447
|
+
// customTriggerRef?.current ? customTriggerRef?.current?.contains(target) : true
|
|
448
|
+
// )
|
|
449
|
+
) {
|
|
450
|
+
setIsOpen(false);
|
|
451
|
+
onDropdownListClose === null || onDropdownListClose === void 0 ? void 0 : onDropdownListClose(e);
|
|
452
|
+
} else if (editOptionModalRef.current && !((_editOptionModalRef$c = editOptionModalRef.current) !== null && _editOptionModalRef$c !== void 0 && _editOptionModalRef$c.contains(target))) {
|
|
453
|
+
var _document, _document$getElementB2, _document$getElementB3, _document$getElementB4;
|
|
454
|
+
|
|
455
|
+
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();
|
|
456
|
+
}
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
const closeList = e => {
|
|
460
|
+
var _inputRef$current;
|
|
461
|
+
|
|
462
|
+
handleClickOutside(e);
|
|
463
|
+
if (!e.target.isEqualNode(inputRef === null || inputRef === void 0 ? void 0 : inputRef.current)) inputRef === null || inputRef === void 0 ? void 0 : (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.blur();
|
|
464
|
+
};
|
|
465
|
+
|
|
466
|
+
const isTargetInParent = target => {
|
|
467
|
+
var _target$className, _target$className$ind, _target$className2, _target$className2$in;
|
|
468
|
+
|
|
469
|
+
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;
|
|
470
|
+
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$className = target.className) === null || _target$className === void 0 ? 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 ? void 0 : (_target$className2 = target.className) === null || _target$className2 === void 0 ? 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;
|
|
471
|
+
return false;
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
const isItemMatchesSearch = item => {
|
|
475
|
+
const title = item.title || item.label;
|
|
476
|
+
return searchValue.length ? title === null || title === void 0 ? void 0 : title.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || "") : true;
|
|
477
|
+
}; // --- GENERAL FUNCTIONS END --- //
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
const prepareOptions = options => {
|
|
481
|
+
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();
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
const getFilteredOptions = options => options === null || options === void 0 ? void 0 : options.reduce((result, option) => {
|
|
485
|
+
if (option.groupName) {
|
|
486
|
+
var _option$list;
|
|
487
|
+
|
|
488
|
+
const filteredGroupItems = option === null || option === void 0 ? void 0 : (_option$list = option.list) === null || _option$list === void 0 ? void 0 : _option$list.filter(item => isItemMatchesSearch(item));
|
|
489
|
+
|
|
490
|
+
if (filteredGroupItems !== null && filteredGroupItems !== void 0 && filteredGroupItems.length) {
|
|
491
|
+
result.push({ ...option,
|
|
492
|
+
list: filteredGroupItems
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
} else if (isItemMatchesSearch(option)) {
|
|
496
|
+
result.push(option);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
return result;
|
|
500
|
+
}, []);
|
|
501
|
+
|
|
502
|
+
const getTotalOptions = (0, _react.useCallback)(() => {
|
|
503
|
+
return options === null || options === void 0 ? void 0 : options.reduce((result, item) => {
|
|
504
|
+
if (item !== null && item !== void 0 && item.list) {
|
|
505
|
+
var _item$list2;
|
|
506
|
+
|
|
507
|
+
result += (item === null || item === void 0 ? void 0 : (_item$list2 = item.list) === null || _item$list2 === void 0 ? void 0 : _item$list2.length) || 0;
|
|
508
|
+
} else {
|
|
509
|
+
++result;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
return result;
|
|
513
|
+
}, 0);
|
|
514
|
+
}, [options]);
|
|
515
|
+
|
|
516
|
+
const onChangeHandler = item => {
|
|
517
|
+
if (item !== null && item !== void 0 && item.isFreezed) return false;
|
|
518
|
+
|
|
519
|
+
if ((item === null || item === void 0 ? void 0 : item.closeOnOptionSelect) !== undefined) {
|
|
520
|
+
if (item.closeOnOptionSelect) setIsOpen(false);
|
|
521
|
+
} else if (isMobile ? closeOnSelectMobile : closeOnSelect) setIsOpen(false);
|
|
522
|
+
|
|
523
|
+
setSearchValueInterceptor("");
|
|
524
|
+
|
|
525
|
+
if (chosenOptions.some(el => el === item.value)) {
|
|
526
|
+
deleteChosen(item.value);
|
|
527
|
+
return null;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
if (isUseLocalOptionsStore) {
|
|
531
|
+
setLocalOptionsStore(options => ({ ...options,
|
|
532
|
+
[item === null || item === void 0 ? void 0 : item.value]: item === null || item === void 0 ? void 0 : item.label
|
|
533
|
+
}));
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
onChange([...chosenOptions, item.value], "chosenOptions");
|
|
537
|
+
return null;
|
|
512
538
|
};
|
|
513
|
-
// --- CREATABLE LOGIC END --- //
|
|
514
539
|
|
|
515
|
-
|
|
540
|
+
const onSearchHandler = name => {
|
|
541
|
+
let inputValue = name;
|
|
542
|
+
if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
|
|
543
|
+
setSearchValueInterceptor(inputValue);
|
|
544
|
+
};
|
|
545
|
+
|
|
546
|
+
const onWrapperClick = e => {
|
|
547
|
+
if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
|
|
548
|
+
e.stopPropagation();
|
|
549
|
+
e.preventDefault();
|
|
550
|
+
setIsOpen(false);
|
|
551
|
+
}
|
|
552
|
+
};
|
|
553
|
+
|
|
554
|
+
const selectAllItems = () => {
|
|
555
|
+
var _prepareOptions;
|
|
556
|
+
|
|
557
|
+
const preparedOptions = (_prepareOptions = prepareOptions(options)) === null || _prepareOptions === void 0 ? void 0 : _prepareOptions.filter(_ref7 => {
|
|
558
|
+
let {
|
|
559
|
+
isFreezed,
|
|
560
|
+
value
|
|
561
|
+
} = _ref7;
|
|
562
|
+
return !isFreezed && !(chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.includes(value)) && value !== "open_modal";
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
if (isUseLocalOptionsStore) {
|
|
566
|
+
setLocalOptionsStore(options => preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.reduce((result, _ref8) => {
|
|
567
|
+
let {
|
|
568
|
+
value,
|
|
569
|
+
label
|
|
570
|
+
} = _ref8;
|
|
571
|
+
result[value] = label;
|
|
572
|
+
return result;
|
|
573
|
+
}, options));
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
onChange([...chosenOptions, ...((preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(_ref9 => {
|
|
577
|
+
let {
|
|
578
|
+
value
|
|
579
|
+
} = _ref9;
|
|
580
|
+
return value;
|
|
581
|
+
})) || [])], "chosenOptions");
|
|
582
|
+
if (isMobile ? closeOnSelectAllMobile : closeOnSelectAll) setIsOpen(false);
|
|
583
|
+
};
|
|
584
|
+
|
|
585
|
+
const unselectAllItems = () => {
|
|
586
|
+
if (isUseLocalOptionsStore) setLocalOptionsStore({});
|
|
587
|
+
onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter(item => {
|
|
588
|
+
var _prepareOptions2, _prepareOptions2$find;
|
|
589
|
+
|
|
590
|
+
return (_prepareOptions2 = prepareOptions(options)) === null || _prepareOptions2 === void 0 ? void 0 : (_prepareOptions2$find = _prepareOptions2.find(_ref10 => {
|
|
591
|
+
let {
|
|
592
|
+
value
|
|
593
|
+
} = _ref10;
|
|
594
|
+
return value === item;
|
|
595
|
+
})) === null || _prepareOptions2$find === void 0 ? void 0 : _prepareOptions2$find.isFreezed;
|
|
596
|
+
}), "chosenOptions");
|
|
597
|
+
if (isMobile ? closeOnRemoveAllMobile : closeOnRemoveAll) setIsOpen(false);
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
const doScrollCallback = (0, _react.useCallback)(e => {
|
|
601
|
+
if (doLiveSearchRequest && typeof doLiveSearchRequest === "function") {
|
|
602
|
+
if (Math.round(e.target.clientHeight + e.target.scrollTop) == e.target.scrollHeight) {
|
|
603
|
+
doLiveSearchRequest(searchValueRef.current, true);
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}, [options]); // --- RENDER FUNCTIONS BEGIN --- //
|
|
607
|
+
|
|
516
608
|
const getMarkupForElement = item => {
|
|
517
609
|
var _title$toString, _item$customMobileIco;
|
|
610
|
+
|
|
518
611
|
const {
|
|
519
612
|
description
|
|
520
613
|
} = item;
|
|
521
614
|
const title = item.title || item.label;
|
|
615
|
+
|
|
522
616
|
const hightlightSearchValue = title => {
|
|
523
617
|
var _title$toLowerCase;
|
|
524
|
-
|
|
618
|
+
|
|
619
|
+
const 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());
|
|
525
620
|
if (index === -1) return title;
|
|
526
621
|
return /*#__PURE__*/_react.default.createElement("pre", {
|
|
527
622
|
className: "inherit-styles"
|
|
@@ -529,9 +624,10 @@ const TagsDropdown = _ref => {
|
|
|
529
624
|
className: "search-match bg--yellow"
|
|
530
625
|
}, 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))));
|
|
531
626
|
};
|
|
627
|
+
|
|
532
628
|
return /*#__PURE__*/_react.default.createElement("button", {
|
|
533
629
|
ref: item === null || item === void 0 ? void 0 : item.ref,
|
|
534
|
-
key: title === null || title === void 0
|
|
630
|
+
key: title === null || title === void 0 ? void 0 : (_title$toString = title.toString()) === null || _title$toString === void 0 ? void 0 : _title$toString.replace(/ /g, "_"),
|
|
535
631
|
onClick: e => {
|
|
536
632
|
e.preventDefault();
|
|
537
633
|
e.stopPropagation();
|
|
@@ -569,7 +665,7 @@ const TagsDropdown = _ref => {
|
|
|
569
665
|
}, hightlightSearchValue(title)), description && /*#__PURE__*/_react.default.createElement("span", {
|
|
570
666
|
className: (0, _classnames.default)("".concat(RC, "__list-item-description"))
|
|
571
667
|
}, description)), !isMobile && (item === null || item === void 0 ? void 0 : item.isEditable) && /*#__PURE__*/_react.default.createElement("div", {
|
|
572
|
-
id: item === null || item === void 0 ? void 0 : item.value,
|
|
668
|
+
id: "editTrigger".concat(item === null || item === void 0 ? void 0 : item.value),
|
|
573
669
|
className: (0, _classnames.default)("".concat(RC, "__list-item-edit-trigger")),
|
|
574
670
|
onClick: e => onOptionEditClick(e, item)
|
|
575
671
|
}, /*#__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, {
|
|
@@ -579,8 +675,10 @@ const TagsDropdown = _ref => {
|
|
|
579
675
|
}
|
|
580
676
|
}) : "");
|
|
581
677
|
};
|
|
678
|
+
|
|
582
679
|
const getListMarkUp = () => {
|
|
583
|
-
var _filteredOptions$filt, _filteredOptions$filt2;
|
|
680
|
+
var _filteredOptions$filt, _filteredOptions$filt2, _document$getElementB5;
|
|
681
|
+
|
|
584
682
|
const filteredOptions = getFilteredOptions(options);
|
|
585
683
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
586
684
|
className: (0, _classnames.default)("".concat(RC, "__container-wrapper")),
|
|
@@ -628,10 +726,10 @@ const TagsDropdown = _ref => {
|
|
|
628
726
|
className: (0, _classnames.default)("".concat(RC, "__header-row"))
|
|
629
727
|
}, headerContent)) : null, withSearchInputInList && /*#__PURE__*/_react.default.createElement("div", {
|
|
630
728
|
className: (0, _classnames.default)("".concat(RC, "__input-list-wrapper"))
|
|
631
|
-
}, renderSearchInput()), withCreateLogic && searchValue && filteredOptions.length && singleLevelOptions.every(
|
|
729
|
+
}, renderSearchInput()), withCreateLogic && searchValue && filteredOptions.length && singleLevelOptions.every(_ref11 => {
|
|
632
730
|
let {
|
|
633
731
|
label
|
|
634
|
-
} =
|
|
732
|
+
} = _ref11;
|
|
635
733
|
return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
636
734
|
}) ? /*#__PURE__*/_react.default.createElement("div", {
|
|
637
735
|
className: (0, _classnames.default)("".concat(RC, "__creatable-helper"))
|
|
@@ -639,24 +737,25 @@ const TagsDropdown = _ref => {
|
|
|
639
737
|
ref: dropdownListRef,
|
|
640
738
|
className: "".concat(RC, "__list ").concat(headerContent || isMobile ? "".concat(RC, "__list--with-header") : "", " ").concat(footerContent ? "".concat(RC, "__list--with-footer") : "")
|
|
641
739
|
}, filteredOptions === null || filteredOptions === void 0 ? void 0 : filteredOptions.map(option => {
|
|
642
|
-
var _option$groupName, _option$list2;
|
|
740
|
+
var _option$groupName, _option$groupName$toS, _option$list2;
|
|
741
|
+
|
|
643
742
|
return option.groupName ? /*#__PURE__*/_react.default.createElement("div", {
|
|
644
|
-
key: (_option$groupName = option.groupName) === null || _option$groupName === void 0
|
|
743
|
+
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()),
|
|
645
744
|
className: (0, _classnames.default)("".concat(RC, "-group"), option.className)
|
|
646
745
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
|
647
746
|
className: "".concat(RC, "-group__name")
|
|
648
747
|
}, option.groupName), (_option$list2 = option.list) === null || _option$list2 === void 0 ? void 0 : _option$list2.map(item => getMarkupForElement(item))) : getMarkupForElement(option);
|
|
649
|
-
}), ((_filteredOptions$filt = filteredOptions.filter(
|
|
748
|
+
}), ((_filteredOptions$filt = filteredOptions.filter(_ref12 => {
|
|
650
749
|
let {
|
|
651
750
|
value
|
|
652
|
-
} =
|
|
751
|
+
} = _ref12;
|
|
653
752
|
return value !== "open_modal";
|
|
654
753
|
})) === null || _filteredOptions$filt === void 0 ? void 0 : _filteredOptions$filt.length) === 0 && (!withCreateLogic || !searchValue) ? /*#__PURE__*/_react.default.createElement("div", {
|
|
655
754
|
className: "".concat(RC, "__no-options")
|
|
656
|
-
}, noOptionsText) : null), (footerContent || isMobile) && ((_filteredOptions$filt2 = filteredOptions.filter(
|
|
755
|
+
}, noOptionsText) : null), (footerContent || isMobile) && ((_filteredOptions$filt2 = filteredOptions.filter(_ref13 => {
|
|
657
756
|
let {
|
|
658
757
|
value
|
|
659
|
-
} =
|
|
758
|
+
} = _ref13;
|
|
660
759
|
return value !== "open_modal";
|
|
661
760
|
})) === null || _filteredOptions$filt2 === void 0 ? void 0 : _filteredOptions$filt2.length) > 0 ? /*#__PURE__*/_react.default.createElement("div", {
|
|
662
761
|
className: (0, _classnames.default)("".concat(RC, "__footer"), {
|
|
@@ -665,10 +764,10 @@ const TagsDropdown = _ref => {
|
|
|
665
764
|
})
|
|
666
765
|
}, footerContent, isMobile && /*#__PURE__*/_react.default.createElement("button", {
|
|
667
766
|
onClick: () => setIsOpen(false)
|
|
668
|
-
}, "Apply", chosenOptions !== null && chosenOptions !== void 0 && chosenOptions.length ? "(".concat(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.length, ")") : "")) : null, editingOption && renderEditOptionModal(), withCreateLogic && searchValue && singleLevelOptions.every(
|
|
767
|
+
}, "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$getElementB5 = document.getElementById("app")) !== null && _document$getElementB5 !== void 0 ? _document$getElementB5 : document.body), withCreateLogic && searchValue && singleLevelOptions.every(_ref14 => {
|
|
669
768
|
let {
|
|
670
769
|
label
|
|
671
|
-
} =
|
|
770
|
+
} = _ref14;
|
|
672
771
|
return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
673
772
|
}) && /*#__PURE__*/_react.default.createElement("div", {
|
|
674
773
|
className: (0, _classnames.default)("".concat(RC, "__create-option")),
|
|
@@ -681,6 +780,7 @@ const TagsDropdown = _ref => {
|
|
|
681
780
|
isNoDismiss: true
|
|
682
781
|
}))));
|
|
683
782
|
};
|
|
783
|
+
|
|
684
784
|
const renderSearchInput = () => {
|
|
685
785
|
return /*#__PURE__*/_react.default.createElement(_Input.default, {
|
|
686
786
|
ref: inputRef,
|
|
@@ -690,38 +790,42 @@ const TagsDropdown = _ref => {
|
|
|
690
790
|
value: searchValue,
|
|
691
791
|
onChange: onSearchHandler,
|
|
692
792
|
placeholder: placeholder || "Select from list",
|
|
693
|
-
attributesOfNativeInput: {
|
|
694
|
-
...attributesOfNativeInput,
|
|
793
|
+
attributesOfNativeInput: { ...attributesOfNativeInput,
|
|
695
794
|
onKeyDown: e => {
|
|
696
|
-
if (e.keyCode === 13 && withCreateLogic && singleLevelOptions.every(
|
|
795
|
+
if (e.keyCode === 13 && withCreateLogic && singleLevelOptions.every(_ref15 => {
|
|
697
796
|
let {
|
|
698
797
|
label
|
|
699
|
-
} =
|
|
798
|
+
} = _ref15;
|
|
700
799
|
return (label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase());
|
|
701
800
|
})) {
|
|
702
801
|
onOptionCreateClick();
|
|
703
802
|
}
|
|
803
|
+
|
|
704
804
|
onKeyPress(e, searchValue);
|
|
705
805
|
},
|
|
706
806
|
onFocus: e => {
|
|
707
807
|
var _e$target;
|
|
708
|
-
|
|
808
|
+
|
|
809
|
+
if (isMobile) e === null || e === void 0 ? void 0 : (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.blur();
|
|
709
810
|
}
|
|
710
811
|
}
|
|
711
812
|
});
|
|
712
813
|
};
|
|
814
|
+
|
|
713
815
|
const renderDropdownTrigger = (0, _react.useCallback)(() => {
|
|
714
816
|
var _renderCustomTrigger;
|
|
817
|
+
|
|
715
818
|
const renderDefaultDropdownTrigger = () => {
|
|
716
819
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
717
820
|
className: (0, _classnames.default)("".concat(RC, "__trigger"), {
|
|
718
821
|
"tags-dropdown__error": error,
|
|
719
822
|
["".concat(RC, "__trigger--with-actions")]: withActions
|
|
720
823
|
}),
|
|
721
|
-
onClick:
|
|
824
|
+
onClick: _ref16 => {
|
|
722
825
|
let {
|
|
723
826
|
target
|
|
724
|
-
} =
|
|
827
|
+
} = _ref16;
|
|
828
|
+
|
|
725
829
|
if ((target === null || target === void 0 ? void 0 : target.tagName) === "INPUT") {
|
|
726
830
|
setIsOpen(true);
|
|
727
831
|
} else if (isTargetInParent(target)) {
|
|
@@ -766,6 +870,7 @@ const TagsDropdown = _ref => {
|
|
|
766
870
|
className: "color--text"
|
|
767
871
|
})));
|
|
768
872
|
};
|
|
873
|
+
|
|
769
874
|
return (_renderCustomTrigger = renderCustomTrigger === null || renderCustomTrigger === void 0 ? void 0 : renderCustomTrigger({
|
|
770
875
|
chosenOptions,
|
|
771
876
|
singleLevelOptions,
|
|
@@ -775,23 +880,25 @@ const TagsDropdown = _ref => {
|
|
|
775
880
|
isOpen,
|
|
776
881
|
setIsOpen
|
|
777
882
|
})) !== null && _renderCustomTrigger !== void 0 ? _renderCustomTrigger : renderDefaultDropdownTrigger();
|
|
778
|
-
}, [chosenOptions, singleLevelOptions, inputRef, isOpen]);
|
|
779
|
-
// --- RENDER FUNCTIONS END --- //
|
|
883
|
+
}, [chosenOptions, singleLevelOptions, inputRef, isOpen]); // --- RENDER FUNCTIONS END --- //
|
|
780
884
|
|
|
781
885
|
(0, _react.useLayoutEffect)(() => {
|
|
782
886
|
initListContainer();
|
|
783
887
|
return () => {
|
|
784
888
|
var _getListContainer2, _getListContainerWrap;
|
|
785
|
-
|
|
786
|
-
(
|
|
889
|
+
|
|
890
|
+
(_getListContainer2 = getListContainer()) === null || _getListContainer2 === void 0 ? void 0 : _getListContainer2.remove();
|
|
891
|
+
(_getListContainerWrap = getListContainerWrapper()) === null || _getListContainerWrap === void 0 ? void 0 : _getListContainerWrap.remove();
|
|
787
892
|
};
|
|
788
893
|
}, []);
|
|
789
894
|
(0, _react.useLayoutEffect)(() => {
|
|
790
895
|
var _getListContainer3;
|
|
896
|
+
|
|
791
897
|
const onResize = () => {
|
|
792
898
|
setListContainerStyles();
|
|
793
899
|
setEditOptionModalStyles();
|
|
794
900
|
};
|
|
901
|
+
|
|
795
902
|
if (!isMobile) {
|
|
796
903
|
window.addEventListener("resize", onResize);
|
|
797
904
|
window.addEventListener("mousewheel", closeList);
|
|
@@ -805,27 +912,28 @@ const TagsDropdown = _ref => {
|
|
|
805
912
|
window.removeEventListener("touchmove", closeList);
|
|
806
913
|
window.removeEventListener("mouseup", handleClickOutside);
|
|
807
914
|
}
|
|
808
|
-
|
|
915
|
+
|
|
916
|
+
(_getListContainer3 = getListContainer()) === null || _getListContainer3 === void 0 ? void 0 : _getListContainer3.addEventListener("click", closeList);
|
|
809
917
|
return () => {
|
|
810
918
|
var _getListContainer4;
|
|
919
|
+
|
|
811
920
|
window.removeEventListener("resize", onResize);
|
|
812
921
|
window.removeEventListener("mousewheel", closeList);
|
|
813
922
|
window.removeEventListener("mouseup", handleClickOutside);
|
|
814
923
|
window.removeEventListener("scroll", closeList);
|
|
815
924
|
window.removeEventListener("touchmove", closeList);
|
|
816
|
-
(_getListContainer4 = getListContainer()) === null || _getListContainer4 === void 0
|
|
925
|
+
(_getListContainer4 = getListContainer()) === null || _getListContainer4 === void 0 ? void 0 : _getListContainer4.removeEventListener("click", closeList);
|
|
817
926
|
};
|
|
818
927
|
}, [getListContainer, isMobile]);
|
|
819
928
|
(0, _react.useLayoutEffect)(() => {
|
|
820
929
|
setListContainerStyles();
|
|
821
930
|
setEditOptionModalStyles();
|
|
822
|
-
}, [isOpen, chosenOptions, isMobile, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0
|
|
931
|
+
}, [isOpen, chosenOptions, isMobile, dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperR2 = dropdownListWrapperRef.current) === null || _dropdownListWrapperR2 === void 0 ? void 0 : (_dropdownListWrapperR3 = _dropdownListWrapperR2.getBoundingClientRect()) === null || _dropdownListWrapperR3 === void 0 ? void 0 : _dropdownListWrapperR3.height, recalculateListContainerStylesTrigger]);
|
|
823
932
|
(0, _react.useEffect)(() => {
|
|
824
933
|
if (isUseLocalOptionsStore && chosenOptions.length !== Object.keys(localOptionsStore).length) {
|
|
825
934
|
options.map(option => {
|
|
826
935
|
if (!(localOptionsStore !== null && localOptionsStore !== void 0 && localOptionsStore[option === null || option === void 0 ? void 0 : option.value])) {
|
|
827
|
-
setLocalOptionsStore(options => ({
|
|
828
|
-
...options,
|
|
936
|
+
setLocalOptionsStore(options => ({ ...options,
|
|
829
937
|
[option === null || option === void 0 ? void 0 : option.value]: option === null || option === void 0 ? void 0 : option.label
|
|
830
938
|
}));
|
|
831
939
|
}
|
|
@@ -834,16 +942,28 @@ const TagsDropdown = _ref => {
|
|
|
834
942
|
}, [chosenOptions, isUseLocalOptionsStore]);
|
|
835
943
|
(0, _react.useEffect)(() => {
|
|
836
944
|
var _selectAllButtonRef$c, _unselectAllButtonRef;
|
|
945
|
+
|
|
837
946
|
const fn = isOpen ? "addEventListener" : "removeEventListener";
|
|
838
|
-
selectAllButtonRef === null || selectAllButtonRef === void 0
|
|
839
|
-
unselectAllButtonRef === null || unselectAllButtonRef === void 0
|
|
947
|
+
selectAllButtonRef === null || selectAllButtonRef === void 0 ? void 0 : (_selectAllButtonRef$c = selectAllButtonRef.current) === null || _selectAllButtonRef$c === void 0 ? void 0 : _selectAllButtonRef$c[fn]("click", selectAllItems, true);
|
|
948
|
+
unselectAllButtonRef === null || unselectAllButtonRef === void 0 ? void 0 : (_unselectAllButtonRef = unselectAllButtonRef.current) === null || _unselectAllButtonRef === void 0 ? void 0 : _unselectAllButtonRef[fn]("click", unselectAllItems, true);
|
|
949
|
+
|
|
840
950
|
if (isOpen) {
|
|
841
951
|
var _getListContainer5, _inputRef$current2, _inputRef$current2$fo;
|
|
842
|
-
|
|
843
|
-
|
|
952
|
+
|
|
953
|
+
if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
|
|
954
|
+
customTriggerRef.current.style.pointerEvents = "none";
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
(_getListContainer5 = getListContainer()) === null || _getListContainer5 === void 0 ? void 0 : _getListContainer5.classList.add("tags-dropdown__container--opened");
|
|
958
|
+
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);
|
|
844
959
|
} else {
|
|
845
960
|
var _getListContainer6;
|
|
846
|
-
|
|
961
|
+
|
|
962
|
+
if (customTriggerRef !== null && customTriggerRef !== void 0 && customTriggerRef.current) {
|
|
963
|
+
customTriggerRef.current.style.pointerEvents = "auto";
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
(_getListContainer6 = getListContainer()) === null || _getListContainer6 === void 0 ? void 0 : _getListContainer6.classList.remove("tags-dropdown__container--opened");
|
|
847
967
|
if (withSearchInputInList) setSearchValueInterceptor("");
|
|
848
968
|
}
|
|
849
969
|
}, [isOpen]);
|
|
@@ -851,38 +971,45 @@ const TagsDropdown = _ref => {
|
|
|
851
971
|
const setScrollTopValue = e => {
|
|
852
972
|
setScrollTop(parseInt(e.target.scrollTop, 10));
|
|
853
973
|
};
|
|
974
|
+
|
|
854
975
|
if (isOpen && isMobile && dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
855
976
|
var _dropdownListRef$curr, _dropdownListRef$curr2, _dropdownListRef$curr3;
|
|
856
|
-
|
|
857
|
-
|
|
977
|
+
|
|
978
|
+
dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr = dropdownListRef.current) === null || _dropdownListRef$curr === void 0 ? void 0 : _dropdownListRef$curr.addEventListener("scroll", setScrollTopValue);
|
|
979
|
+
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));
|
|
980
|
+
|
|
858
981
|
if (isScrollableList === null) {
|
|
859
982
|
var _dropdownListRef$curr4, _dropdownListRef$curr5;
|
|
860
|
-
|
|
983
|
+
|
|
984
|
+
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));
|
|
861
985
|
}
|
|
862
986
|
}
|
|
987
|
+
|
|
863
988
|
if (isOpen && dropdownListRef && dropdownListRef.current) {
|
|
864
989
|
dropdownListRef.current.addEventListener("scroll", doScrollCallback);
|
|
865
990
|
}
|
|
991
|
+
|
|
866
992
|
return () => {
|
|
867
993
|
var _dropdownListRef$curr6;
|
|
994
|
+
|
|
868
995
|
removeEventListener("scroll", doScrollCallback);
|
|
869
|
-
dropdownListRef === null || dropdownListRef === void 0
|
|
996
|
+
dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr6 = dropdownListRef.current) === null || _dropdownListRef$curr6 === void 0 ? void 0 : _dropdownListRef$curr6.removeEventListener("scroll", setScrollTopValue);
|
|
870
997
|
};
|
|
871
|
-
}, [isOpen, isMobile, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0
|
|
998
|
+
}, [isOpen, isMobile, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr7 = dropdownListRef.current) === null || _dropdownListRef$curr7 === void 0 ? void 0 : _dropdownListRef$curr7.scrollHeight, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr8 = dropdownListRef.current) === null || _dropdownListRef$curr8 === void 0 ? void 0 : _dropdownListRef$curr8.clientHeight]);
|
|
872
999
|
(0, _react.useEffect)(() => {
|
|
873
1000
|
if (dropdownListRef !== null && dropdownListRef !== void 0 && dropdownListRef.current) {
|
|
874
1001
|
var _dropdownListRef$curr9, _dropdownListRef$curr10;
|
|
875
|
-
|
|
1002
|
+
|
|
1003
|
+
setScrollHeight(parseInt((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr9 = dropdownListRef.current) === null || _dropdownListRef$curr9 === void 0 ? void 0 : _dropdownListRef$curr9.scrollHeight) - (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef$curr10 = dropdownListRef.current) === null || _dropdownListRef$curr10 === void 0 ? void 0 : _dropdownListRef$curr10.clientHeight), 10));
|
|
876
1004
|
}
|
|
877
1005
|
}, [scrollTop, dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current]);
|
|
878
1006
|
(0, _react.useEffect)(() => {
|
|
879
1007
|
if (isSearchable && useLiveSearch && (debouncedSearchTerm || isValueDeleted || isOpen)) {
|
|
880
|
-
doLiveSearchRequest === null || doLiveSearchRequest === void 0
|
|
1008
|
+
doLiveSearchRequest === null || doLiveSearchRequest === void 0 ? void 0 : doLiveSearchRequest(debouncedSearchTerm);
|
|
881
1009
|
}
|
|
882
1010
|
}, [isOpen, debouncedSearchTerm, isValueDeleted]);
|
|
883
1011
|
(0, _react.useEffect)(() => {
|
|
884
|
-
setOptions(optionsProp.map(option => ({
|
|
885
|
-
...option,
|
|
1012
|
+
setOptions(optionsProp.map(option => ({ ...option,
|
|
886
1013
|
ref: /*#__PURE__*/(0, _react.createRef)()
|
|
887
1014
|
})));
|
|
888
1015
|
}, [optionsProp]);
|
|
@@ -906,4 +1033,6 @@ const TagsDropdown = _ref => {
|
|
|
906
1033
|
onClick: onActionCancelClick
|
|
907
1034
|
}, /*#__PURE__*/_react.default.createElement(_reactFeather.X, null))), isOpen && renderListContainer());
|
|
908
1035
|
};
|
|
909
|
-
|
|
1036
|
+
|
|
1037
|
+
var _default = TagsDropdown;
|
|
1038
|
+
exports.default = _default;
|