intelicoreact 1.6.25 → 1.6.27

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.
Files changed (275) hide show
  1. package/dist/Atomic/FormElements/ActionAlert/ActionAlert.js +1 -98
  2. package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +1 -48
  3. package/dist/Atomic/FormElements/Calendar/Calendar.js +1 -249
  4. package/dist/Atomic/FormElements/Calendar/Calendar.props.js +1 -4
  5. package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +1 -65
  6. package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +1 -52
  7. package/dist/Atomic/FormElements/Datepicker/Datepicker.js +1 -424
  8. package/dist/Atomic/FormElements/Datepicker/Datepicker.props.js +1 -4
  9. package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.js +1 -173
  10. package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.props.js +1 -4
  11. package/dist/Atomic/FormElements/Dropdown/Dropdown.d.ts +5 -0
  12. package/dist/Atomic/FormElements/Dropdown/Dropdown.js +1 -735
  13. package/dist/Atomic/FormElements/Dropdown/Dropdown.js.map +1 -0
  14. package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +1 -20
  15. package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +1 -529
  16. package/dist/Atomic/FormElements/FileLoader/FileLoader.js +1 -94
  17. package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +1 -105
  18. package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +1 -67
  19. package/dist/Atomic/FormElements/FileLoaderDescription/FileLoaderDescription.js +1 -247
  20. package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +1 -160
  21. package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +1 -193
  22. package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +1 -135
  23. package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.js +1 -116
  24. package/dist/Atomic/FormElements/Input/Input.js +1 -467
  25. package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +1 -161
  26. package/dist/Atomic/FormElements/InputColor/InputColor.js +1 -64
  27. package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +1 -200
  28. package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +1 -354
  29. package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +1 -71
  30. package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +1 -693
  31. package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +1 -254
  32. package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +1 -32
  33. package/dist/Atomic/FormElements/InputDateRange/dependencies.js +1 -200
  34. package/dist/Atomic/FormElements/InputLink/InputLink.js +1 -99
  35. package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +1 -37
  36. package/dist/Atomic/FormElements/InputMask/InputMask.js +1 -1214
  37. package/dist/Atomic/FormElements/InputMask/config.js +1 -15
  38. package/dist/Atomic/FormElements/InputMask/functions.js +1 -58
  39. package/dist/Atomic/FormElements/InputMask2/InputMask2.js +1 -674
  40. package/dist/Atomic/FormElements/InputMask2/config.js +1 -15
  41. package/dist/Atomic/FormElements/InputMask2/functions.js +1 -58
  42. package/dist/Atomic/FormElements/InputMask3/InputMask3.js +1 -766
  43. package/dist/Atomic/FormElements/InputMask3/config.js +1 -15
  44. package/dist/Atomic/FormElements/InputMask3/functions.js +1 -58
  45. package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +1 -114
  46. package/dist/Atomic/FormElements/InputsRow/InputsRow.js +1 -140
  47. package/dist/Atomic/FormElements/Label/Label.js +1 -87
  48. package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +1 -506
  49. package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +1 -45
  50. package/dist/Atomic/FormElements/NumericInput/NumericInput.js +1 -331
  51. package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +1 -66
  52. package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +1 -80
  53. package/dist/Atomic/FormElements/RadioInput/RadioInput.js +1 -57
  54. package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +1 -54
  55. package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +1 -183
  56. package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +1 -222
  57. package/dist/Atomic/FormElements/RangeList/RangeList.js +1 -175
  58. package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +1 -43
  59. package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +1 -443
  60. package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +1 -858
  61. package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +1 -39
  62. package/dist/Atomic/FormElements/Switcher/Switcher.js +1 -59
  63. package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +1 -50
  64. package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +1 -44
  65. package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +1 -100
  66. package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +1 -52
  67. package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +1 -64
  68. package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +1 -170
  69. package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +1 -202
  70. package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +1 -67
  71. package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +1 -115
  72. package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +1 -1110
  73. package/dist/Atomic/FormElements/Text/Text.js +1 -125
  74. package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +1 -49
  75. package/dist/Atomic/FormElements/Textarea/Textarea.js +1 -80
  76. package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +1 -176
  77. package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +1 -62
  78. package/dist/Atomic/FormElements/TimeRange/TimeRange.js +1 -119
  79. package/dist/Atomic/FormElements/UserContacts/UserContacts.js +1 -188
  80. package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +1 -83
  81. package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +1 -82
  82. package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +1 -101
  83. package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +1 -29
  84. package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +1 -113
  85. package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +1 -30
  86. package/dist/Atomic/Layout/Header/Header.js +1 -85
  87. package/dist/Atomic/Layout/Spinner/Spinner.js +1 -44
  88. package/dist/Atomic/UI/Accordion/Accordion.js +1 -108
  89. package/dist/Atomic/UI/Accordion/AccordionItem.js +1 -176
  90. package/dist/Atomic/UI/AccordionTable/AccordionTable.js +1 -238
  91. package/dist/Atomic/UI/AccordionText/AccordionText.js +1 -69
  92. package/dist/Atomic/UI/AdvancedTag/AdvTag.js +1 -207
  93. package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +1 -56
  94. package/dist/Atomic/UI/Alert/Alert.js +1 -72
  95. package/dist/Atomic/UI/Arrow/Arrow.js +1 -132
  96. package/dist/Atomic/UI/Box/Box.js +1 -52
  97. package/dist/Atomic/UI/Button/Button.js +1 -47
  98. package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +1 -72
  99. package/dist/Atomic/UI/Chart/Chart.js +1 -172
  100. package/dist/Atomic/UI/Chart/partial/Chart.constants.js +1 -95
  101. package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +1 -80
  102. package/dist/Atomic/UI/Chart/partial/datasetSetters.js +1 -188
  103. package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +1 -335
  104. package/dist/Atomic/UI/Chart/partial/optionsSetters.js +1 -43
  105. package/dist/Atomic/UI/Chart/partial/utils.js +1 -60
  106. package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +1 -109
  107. package/dist/Atomic/UI/DateTime/DateTime.js +1 -57
  108. package/dist/Atomic/UI/DebugContainer/DebugContainer.js +1 -44
  109. package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +1 -15
  110. package/dist/Atomic/UI/DoubleString/DoubleString.js +1 -102
  111. package/dist/Atomic/UI/DoubleString/DoubleString.scss +8 -1
  112. package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +1 -70
  113. package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +1 -221
  114. package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +1 -106
  115. package/dist/Atomic/UI/Hint/Hint.js +1 -256
  116. package/dist/Atomic/UI/Hint/partials/_utils.js +1 -64
  117. package/dist/Atomic/UI/Modal/Modal.js +1 -179
  118. package/dist/Atomic/UI/Modal/ModalHOC.js +1 -97
  119. package/dist/Atomic/UI/Modal/partials/ModalFooter.js +1 -71
  120. package/dist/Atomic/UI/Modal/partials/ModalTitle.js +1 -110
  121. package/dist/Atomic/UI/Modal/partials/useMobileModal.js +1 -192
  122. package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.js +1 -75
  123. package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +1 -80
  124. package/dist/Atomic/UI/NavLine/NavLine.js +1 -317
  125. package/dist/Atomic/UI/PageTitle/PageTitle.js +1 -77
  126. package/dist/Atomic/UI/PieChart/PieChart.js +1 -42
  127. package/dist/Atomic/UI/Price/Price.js +1 -31
  128. package/dist/Atomic/UI/PriceRange/PriceRange.js +1 -44
  129. package/dist/Atomic/UI/ProgressLine/ProgressLine.js +1 -98
  130. package/dist/Atomic/UI/Status/Status.js +1 -67
  131. package/dist/Atomic/UI/Table/Partials/TdCell.js +1 -87
  132. package/dist/Atomic/UI/Table/Partials/TdHeader.js +1 -38
  133. package/dist/Atomic/UI/Table/Partials/TdRow.js +1 -99
  134. package/dist/Atomic/UI/Table/Partials/TdTitle.js +1 -52
  135. package/dist/Atomic/UI/Table/Table.js +1 -63
  136. package/dist/Atomic/UI/Table/TdTypes/TdActions.js +1 -80
  137. package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +1 -28
  138. package/dist/Atomic/UI/Table/TdTypes/TdRange.js +1 -13
  139. package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +1 -53
  140. package/dist/Atomic/UI/Tag/Tag.js +1 -167
  141. package/dist/Atomic/UI/TagList/TagList.js +1 -251
  142. package/dist/Atomic/UI/UserBox/UserBox.js +1 -86
  143. package/dist/Atomic/UI/WizardStepper/constructor.js +1 -84
  144. package/dist/Atomic/UI/WizardStepper/index.js +1 -3
  145. package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +1 -37
  146. package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +1 -3
  147. package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +1 -61
  148. package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +1 -3
  149. package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +1 -39
  150. package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +1 -3
  151. package/dist/Atomic/UI/WizardStepper/ui/icons.js +1 -49
  152. package/dist/Atomic/UI/WizardStepper/ui/index.js +1 -3
  153. package/dist/Classes/AbortableFetch.js +1 -454
  154. package/dist/Classes/AnimatedHandler.js +1 -47
  155. package/dist/Classes/RESTAPI/index.js +1 -228
  156. package/dist/Classes/RESTAPI/partials/AbortableFetch.js +1 -457
  157. package/dist/Classes/RESTAPI/partials/ApiBase.js +1 -48
  158. package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +1 -112
  159. package/dist/Classes/RESTAPI/partials/ApiUtils.js +1 -189
  160. package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +1 -252
  161. package/dist/Classes/RESTAPI/partials/Utils.js +1 -92
  162. package/dist/Classes/RESTAPI/partials/_outerDependencies.js +1 -3
  163. package/dist/Classes/RESTAPI/partials/_utils.js +1 -197
  164. package/dist/Constants/index.constants.js +1 -78
  165. package/dist/Functions/Portal.js +1 -22
  166. package/dist/Functions/customEventListener.js +1 -96
  167. package/dist/Functions/dateTime.js +1 -149
  168. package/dist/Functions/fieldValueFormatters.js +1 -405
  169. package/dist/Functions/guards/assertions.js +1 -294
  170. package/dist/Functions/guards/safeValue.js +1 -75
  171. package/dist/Functions/guards/typeGuards.js +1 -373
  172. package/dist/Functions/hooks/useFormFieldsChangesManager.js +1 -95
  173. package/dist/Functions/locale/createTranslator.js +1 -32
  174. package/dist/Functions/operations.js +1 -130
  175. package/dist/Functions/presets/inputMaskPresets.js +1 -170
  176. package/dist/Functions/presets/inputPresets.js +1 -60
  177. package/dist/Functions/presets/mobileKeyboardTypesPresets.js +1 -45
  178. package/dist/Functions/schemas.js +1 -31
  179. package/dist/Functions/useBodyScrollLock.js +1 -17
  180. package/dist/Functions/useClickOutside.js +1 -15
  181. package/dist/Functions/useDebounce.js +1 -17
  182. package/dist/Functions/useFieldFocus.js +1 -84
  183. package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +1 -39
  184. package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +1 -159
  185. package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +1 -78
  186. package/dist/Functions/useFormTools/functions/General.js +1 -134
  187. package/dist/Functions/useFormTools/functions/RenderFields.js +1 -111
  188. package/dist/Functions/useFormTools/functions/usePrevious.js +1 -12
  189. package/dist/Functions/useFormTools/index.js +1 -778
  190. package/dist/Functions/useInputHighlightError.js +1 -67
  191. package/dist/Functions/useIsMobile/useIsMobile.js +1 -33
  192. package/dist/Functions/useKeyPress/useHandleKeyPress.js +1 -52
  193. package/dist/Functions/useKeyPress/useKeyPress.js +1 -52
  194. package/dist/Functions/useLocalStorage.js +1 -34
  195. package/dist/Functions/useLocationParams.js +1 -27
  196. package/dist/Functions/useMediaQuery.js +1 -17
  197. package/dist/Functions/useMetaInfo.js +1 -43
  198. package/dist/Functions/useMouseUpOutside.js +1 -16
  199. package/dist/Functions/useOnlineStatus.js +1 -29
  200. package/dist/Functions/usePasswordChecker.js +1 -110
  201. package/dist/Functions/usePrevious.js +1 -12
  202. package/dist/Functions/useResize.js +1 -31
  203. package/dist/Functions/useScrollTo.js +1 -17
  204. package/dist/Functions/useToggle.js +1 -17
  205. package/dist/Functions/utils.js +1 -522
  206. package/dist/Langs.js +1 -168
  207. package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +1 -21
  208. package/dist/Molecular/CustomIcons/components/AlertCircle.js +1 -23
  209. package/dist/Molecular/CustomIcons/components/AppStore.js +1 -29
  210. package/dist/Molecular/CustomIcons/components/Arrow.js +1 -32
  211. package/dist/Molecular/CustomIcons/components/ArrowDown.js +1 -17
  212. package/dist/Molecular/CustomIcons/components/ArrowLeft.js +1 -22
  213. package/dist/Molecular/CustomIcons/components/ArrowRight.js +1 -22
  214. package/dist/Molecular/CustomIcons/components/ArrowUp.js +1 -17
  215. package/dist/Molecular/CustomIcons/components/Bell.js +1 -15
  216. package/dist/Molecular/CustomIcons/components/Button.js +1 -12
  217. package/dist/Molecular/CustomIcons/components/Campaigns.js +1 -16
  218. package/dist/Molecular/CustomIcons/components/Check.js +1 -14
  219. package/dist/Molecular/CustomIcons/components/Check2.js +1 -12
  220. package/dist/Molecular/CustomIcons/components/ChevronDown.js +1 -12
  221. package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +1 -11
  222. package/dist/Molecular/CustomIcons/components/ChevronLeft.js +1 -11
  223. package/dist/Molecular/CustomIcons/components/ChevronRight.js +1 -11
  224. package/dist/Molecular/CustomIcons/components/ChevronUp.js +1 -11
  225. package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +1 -27
  226. package/dist/Molecular/CustomIcons/components/Close.js +1 -14
  227. package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +1 -17
  228. package/dist/Molecular/CustomIcons/components/Delete.js +1 -16
  229. package/dist/Molecular/CustomIcons/components/Edit.js +1 -15
  230. package/dist/Molecular/CustomIcons/components/Email.js +1 -31
  231. package/dist/Molecular/CustomIcons/components/FinturfLogo.js +1 -18
  232. package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +1 -35
  233. package/dist/Molecular/CustomIcons/components/Flows.js +1 -15
  234. package/dist/Molecular/CustomIcons/components/Gift.js +1 -25
  235. package/dist/Molecular/CustomIcons/components/GoogleAuth.js +1 -29
  236. package/dist/Molecular/CustomIcons/components/GooglePlay.js +1 -29
  237. package/dist/Molecular/CustomIcons/components/HelpCircle.js +1 -19
  238. package/dist/Molecular/CustomIcons/components/HelpCircle2.js +1 -20
  239. package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +1 -19
  240. package/dist/Molecular/CustomIcons/components/Home.js +1 -16
  241. package/dist/Molecular/CustomIcons/components/Home2.js +1 -22
  242. package/dist/Molecular/CustomIcons/components/Key.js +1 -23
  243. package/dist/Molecular/CustomIcons/components/Landers.js +1 -20
  244. package/dist/Molecular/CustomIcons/components/Lock.js +1 -15
  245. package/dist/Molecular/CustomIcons/components/Mail.js +1 -26
  246. package/dist/Molecular/CustomIcons/components/Mastercard.js +1 -73
  247. package/dist/Molecular/CustomIcons/components/Minus.js +1 -25
  248. package/dist/Molecular/CustomIcons/components/Offers.js +1 -16
  249. package/dist/Molecular/CustomIcons/components/Pause.js +1 -28
  250. package/dist/Molecular/CustomIcons/components/PayPal.js +1 -41
  251. package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +1 -28
  252. package/dist/Molecular/CustomIcons/components/Phone.js +1 -30
  253. package/dist/Molecular/CustomIcons/components/Play.js +1 -25
  254. package/dist/Molecular/CustomIcons/components/Plus.js +1 -25
  255. package/dist/Molecular/CustomIcons/components/Profile.js +1 -16
  256. package/dist/Molecular/CustomIcons/components/QRCode.js +1 -29
  257. package/dist/Molecular/CustomIcons/components/Rectangle.js +1 -12
  258. package/dist/Molecular/CustomIcons/components/Revert.js +1 -13
  259. package/dist/Molecular/CustomIcons/components/Star.js +1 -14
  260. package/dist/Molecular/CustomIcons/components/Star2.js +1 -16
  261. package/dist/Molecular/CustomIcons/components/TrafficSources.js +1 -14
  262. package/dist/Molecular/CustomIcons/components/Trash.js +1 -15
  263. package/dist/Molecular/CustomIcons/components/TrashRed.js +1 -15
  264. package/dist/Molecular/CustomIcons/components/Triggers.js +1 -15
  265. package/dist/Molecular/CustomIcons/components/User.js +1 -25
  266. package/dist/Molecular/CustomIcons/components/Visa.js +1 -31
  267. package/dist/Molecular/CustomIcons/components/X.js +1 -12
  268. package/dist/Molecular/CustomIcons/index.js +1 -61
  269. package/dist/Molecular/FormElement/FormElement.js +1 -54
  270. package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +1 -184
  271. package/dist/Molecular/FormWithDependOn/partials/_utils.js +1 -53
  272. package/dist/Molecular/InputAddress/InputAddress.js +1 -626
  273. package/dist/Molecular/InputPassword/InputPassword.js +1 -48
  274. package/dist/index.js +1 -104
  275. package/package.json +1 -1
@@ -1,1110 +1 @@
1
- /* eslint-disable ts/no-use-before-define */ /* eslint-disable react-web-api/no-leaked-event-listener */ "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return _default;
9
- }
10
- });
11
- const _jsxruntime = require("react/jsx-runtime");
12
- const _classnames = /*#__PURE__*/ _interop_require_default(require("classnames"));
13
- const _react = /*#__PURE__*/ _interop_require_wildcard(require("react"));
14
- const _reactdom = require("react-dom");
15
- const _reactfeather = require("react-feather");
16
- const _fieldValueFormatters = require("../../../Functions/fieldValueFormatters");
17
- const _useDebounce = require("../../../Functions/useDebounce");
18
- const _useIsMobile = /*#__PURE__*/ _interop_require_default(require("../../../Functions/useIsMobile/useIsMobile"));
19
- const _Button = /*#__PURE__*/ _interop_require_default(require("../../UI/Button/Button"));
20
- const _Tag = /*#__PURE__*/ _interop_require_default(require("../../UI/Tag/Tag"));
21
- const _TagList = /*#__PURE__*/ _interop_require_default(require("../../UI/TagList/TagList"));
22
- const _CheckboxInput = /*#__PURE__*/ _interop_require_default(require("../CheckboxInput/CheckboxInput"));
23
- const _Input = /*#__PURE__*/ _interop_require_default(require("../Input/Input"));
24
- require("./TagsDropdown.scss");
25
- function _interop_require_default(obj) {
26
- return obj && obj.__esModule ? obj : {
27
- default: obj
28
- };
29
- }
30
- function _getRequireWildcardCache(nodeInterop) {
31
- if (typeof WeakMap !== "function") return null;
32
- var cacheBabelInterop = new WeakMap();
33
- var cacheNodeInterop = new WeakMap();
34
- return (_getRequireWildcardCache = function(nodeInterop) {
35
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
36
- })(nodeInterop);
37
- }
38
- function _interop_require_wildcard(obj, nodeInterop) {
39
- if (!nodeInterop && obj && obj.__esModule) {
40
- return obj;
41
- }
42
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
43
- return {
44
- default: obj
45
- };
46
- }
47
- var cache = _getRequireWildcardCache(nodeInterop);
48
- if (cache && cache.has(obj)) {
49
- return cache.get(obj);
50
- }
51
- var newObj = {
52
- __proto__: null
53
- };
54
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
55
- for(var key in obj){
56
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
57
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
58
- if (desc && (desc.get || desc.set)) {
59
- Object.defineProperty(newObj, key, desc);
60
- } else {
61
- newObj[key] = obj[key];
62
- }
63
- }
64
- }
65
- newObj.default = obj;
66
- if (cache) {
67
- cache.set(obj, newObj);
68
- }
69
- return newObj;
70
- }
71
- const RC = 'tags-dropdown';
72
- const MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH = 10;
73
- const COLORS = [
74
- '#F1F0F0',
75
- '#E3E2E0',
76
- '#EEDFDA',
77
- '#F9DEC9',
78
- '#FDECC8',
79
- '#DBECDB',
80
- '#D3E4EF',
81
- '#E8DEEE',
82
- '#F4E0E9',
83
- '#FFE2DD',
84
- '#D3EFED',
85
- '#ECEEDE'
86
- ];
87
- const TagsDropdown = ({ options: optionsProp, chosenOptions, onChange, className, tagClassname, listClassName, onKeyPress, placeholder, label, disabled, isValuesInTags, error, isNotValidateASCII = false, noTagsWrap = false, headerContent = null, footerContent = null, selectAllButtonRef = null, unselectAllButtonRef = null, closeOnSelect = false, closeOnRemove = false, closeOnRemoveAll = false, closeOnSelectAll = false, closeOnSelectMobile = false, closeOnRemoveMobile = false, closeOnRemoveAllMobile = false, closeOnSelectAllMobile = false, fieldKey, id, noOptionsText = 'No options available', mobileSearchPlaceholder, isSearchable = true, useLiveSearch, doRequest: doLiveSearchRequest, attributesOfNativeInput, isUseLocalOptionsStore = true, isDefaultOpened = false, withMobileLogic, withCreateLogic, withActions, withSearchInputInList, renderOptionsAsTags, minItemsForShowMobileSearch = MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH, onOptionCreate, onOptionEdit, onOptionDelete, onActionConfirmClick, onActionCancelClick, onDropdownListClose, customTriggerRef, renderCustomTrigger, recalculateListContainerStylesTrigger })=>{
88
- var _Object_keys, _dropdownListWrapperRef_current_getBoundingClientRect, _dropdownListWrapperRef_current, _dropdownListRef_current, _dropdownListRef_current1;
89
- const inputRef = (0, _react.useRef)(null);
90
- const wrapperRef = (0, _react.useRef)(null);
91
- const dropdownRef = (0, _react.useRef)(null);
92
- const dropdownListRef = (0, _react.useRef)(null);
93
- const editOptionModalRef = (0, _react.useRef)(null);
94
- const dropdownListWrapperRef = (0, _react.useRef)(null);
95
- const { isMobile: isMobileProp } = (0, _useIsMobile.default)();
96
- const isMobile = isMobileProp && withMobileLogic && window.screen.width <= 768;
97
- const [dropdownId] = (0, _react.useState)(id || fieldKey || Math.random().toString(16).slice(2));
98
- const [isOpen, setIsOpen] = (0, _react.useState)(false);
99
- const [windowScrollTop, setWindowScrollTop] = (0, _react.useState)(0);
100
- const [listPos, setListPos] = (0, _react.useState)(null);
101
- const [initListHeight, setInitListHeight] = (0, _react.useState)(null);
102
- const [isScrollableList, setIsScrollableList] = (0, _react.useState)(null);
103
- const [isFixedMaxHeight, setIsFixedMaxHeight] = (0, _react.useState)(false);
104
- const [scrollTop, setScrollTop] = (0, _react.useState)(0);
105
- const [scrollHeight, setScrollHeight] = (0, _react.useState)(1);
106
- const searchValueRef = (0, _react.useRef)(null);
107
- const [searchValue, setSearchValue] = (0, _react.useState)('');
108
- const debouncedSearchTerm = (0, _useDebounce.useDebounce)({
109
- searchValue,
110
- delay: 600
111
- });
112
- const [isValueDeleted, setIsValueDeleted] = (0, _react.useState)(false);
113
- const setSearchValueInterceptor = (value)=>{
114
- setSearchValue(value);
115
- setIsValueDeleted(searchValue !== value && value === '');
116
- searchValueRef.current = value;
117
- };
118
- const editingOptionInputRef = (0, _react.useRef)(null);
119
- const [options, setOptions] = (0, _react.useState)([]);
120
- const [editingOption, setEditingOptionState] = (0, _react.useState)(null);
121
- const setEditingOption = (data)=>{
122
- setEditingOptionState((editingOption)=>!data ? data : {
123
- ...editingOption !== null && editingOption !== void 0 ? editingOption : {},
124
- ...typeof data === 'function' ? data === null || data === void 0 ? void 0 : data(editingOption) : data,
125
- isChanged: Boolean(editingOption)
126
- });
127
- };
128
- const isEditingOptionError = (0, _react.useMemo)(()=>{
129
- if (!editingOption) return false;
130
- return options.filter(({ value })=>value !== editingOption.value).some(({ label })=>label === editingOption.label) ? true : null;
131
- }, [
132
- options,
133
- editingOption
134
- ]);
135
- const [localOptionsStore, setLocalOptionsStore] = (0, _react.useState)({});
136
- const randomColorForNewOption = (0, _react.useMemo)(()=>{
137
- const getRandomIndex = (min, max)=>{
138
- return Math.floor(Math.random() * (max - min + 1)) + min;
139
- };
140
- const randomIndex = getRandomIndex(0, COLORS.length - 1);
141
- return COLORS[randomIndex];
142
- }, [
143
- options.length
144
- ]);
145
- const singleLevelOptions = options === null || options === void 0 ? void 0 : options.reduce((acc, item)=>{
146
- const checkUniqAndPush = (acc, item)=>{
147
- const isExist = acc === null || acc === void 0 ? void 0 : acc.findIndex(({ value })=>value === (item === null || item === void 0 ? void 0 : item.value));
148
- if (isExist !== -1) {
149
- acc[isExist] = item;
150
- } else {
151
- acc.push(item);
152
- }
153
- };
154
- if (item.groupName) {
155
- var _item_list;
156
- (_item_list = item.list) === null || _item_list === void 0 ? void 0 : _item_list.map((item)=>checkUniqAndPush(acc, item));
157
- } else {
158
- checkUniqAndPush(acc, item);
159
- }
160
- return acc;
161
- }, isUseLocalOptionsStore ? (_Object_keys = Object.keys(localOptionsStore)) === null || _Object_keys === void 0 ? void 0 : _Object_keys.map((value)=>{
162
- var _localOptionsStore_value;
163
- return {
164
- value,
165
- label: (_localOptionsStore_value = localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[value]) !== null && _localOptionsStore_value !== void 0 ? _localOptionsStore_value : ''
166
- };
167
- }) : []);
168
- const deleteChosen = (value)=>{
169
- if (isMobile ? closeOnRemoveMobile : closeOnRemove) setIsOpen(false);
170
- if (isUseLocalOptionsStore) {
171
- setLocalOptionsStore((options)=>{
172
- const newOptions = {
173
- ...options,
174
- [value]: undefined
175
- };
176
- return newOptions;
177
- });
178
- }
179
- onChange === null || onChange === void 0 ? void 0 : onChange(chosenOptions.filter((item)=>item !== value), 'chosenOptions');
180
- };
181
- // --- LIST CONTAINER FUNCTIONS BEGIN --- //
182
- const getParentNode = ()=>{
183
- var _document_querySelector, _ref;
184
- return (_ref = (_document_querySelector = document.querySelector('div#root')) !== null && _document_querySelector !== void 0 ? _document_querySelector : document.querySelector('div#app')) !== null && _ref !== void 0 ? _ref : document.querySelector('div#storybook-root');
185
- };
186
- const initListContainer = ()=>{
187
- const dropdownList = document.createElement('div');
188
- dropdownList.setAttribute('id', dropdownId);
189
- dropdownList.classList.add('tags-dropdown__container');
190
- listClassName && dropdownList.classList.add(listClassName);
191
- if (isMobile) {
192
- dropdownList.addEventListener('click', (e)=>{
193
- if (e.target && e.target.id === dropdownId) setIsOpen(false);
194
- });
195
- }
196
- if (isMobile) {
197
- var _getParentNode;
198
- try {
199
- var _document_getElementById;
200
- (_document_getElementById = document.getElementById(`mlw-${dropdownId}`)) === null || _document_getElementById === void 0 ? void 0 : _document_getElementById.remove();
201
- } catch (e) {}
202
- const dropdownMobileListWrapper = document.createElement('div');
203
- dropdownMobileListWrapper.classList.add('tags-dropdown-mobile');
204
- dropdownMobileListWrapper.setAttribute('id', `mlw-${dropdownId}`);
205
- dropdownMobileListWrapper === null || dropdownMobileListWrapper === void 0 ? void 0 : dropdownMobileListWrapper.append(dropdownList);
206
- (_getParentNode = getParentNode()) === null || _getParentNode === void 0 ? void 0 : _getParentNode.append(dropdownMobileListWrapper);
207
- } else {
208
- var _getParentNode1;
209
- (_getParentNode1 = getParentNode()) === null || _getParentNode1 === void 0 ? void 0 : _getParentNode1.append(dropdownList);
210
- }
211
- };
212
- const getListContainer = ()=>{
213
- return document.getElementById(dropdownId);
214
- };
215
- const getListContainerWrapper = ()=>{
216
- return document.getElementById(`mlw-${dropdownId}`);
217
- };
218
- const setListContainerStyles = ()=>{
219
- var _dropdownRef_current, _getComputedStyle_marginTop, _getComputedStyle, _selectorWrapper_getBoundingClientRect, _listHeader_getBoundingClientRect, _listFooter_getBoundingClientRect;
220
- const listContainer = getListContainer();
221
- if (!listContainer || !isOpen) return false;
222
- const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
223
- var _dropdownRef_current_getBoundingClientRect;
224
- const { width, height = 0, left, top = 0 } = (_dropdownRef_current_getBoundingClientRect = dropdownRef === null || dropdownRef === void 0 ? void 0 : (_dropdownRef_current = dropdownRef.current) === null || _dropdownRef_current === void 0 ? void 0 : _dropdownRef_current.getBoundingClientRect()) !== null && _dropdownRef_current_getBoundingClientRect !== void 0 ? _dropdownRef_current_getBoundingClientRect : {};
225
- const selectorWrapper = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : dropdownListWrapperRef.current;
226
- const dropdownList = listContainer.getElementsByClassName('tags-dropdown__list')[0];
227
- const listHeader = selectorWrapper === null || selectorWrapper === void 0 ? void 0 : selectorWrapper.getElementsByClassName('tags-dropdown__header')[0];
228
- const listFooter = selectorWrapper === null || selectorWrapper === void 0 ? void 0 : selectorWrapper.getElementsByClassName('tags-dropdown__footer')[0];
229
- var _getComputedStyle_marginTop_replace;
230
- const margin = Number.parseInt((_getComputedStyle_marginTop_replace = (_getComputedStyle = getComputedStyle(selectorWrapper)) === null || _getComputedStyle === void 0 ? void 0 : (_getComputedStyle_marginTop = _getComputedStyle.marginTop) === null || _getComputedStyle_marginTop === void 0 ? void 0 : _getComputedStyle_marginTop.replace('px', '')) !== null && _getComputedStyle_marginTop_replace !== void 0 ? _getComputedStyle_marginTop_replace : 0, 10);
231
- var _selectorWrapper_getBoundingClientRect_height;
232
- let selectorWrapperHeight = (_selectorWrapper_getBoundingClientRect_height = selectorWrapper === null || selectorWrapper === void 0 ? void 0 : (_selectorWrapper_getBoundingClientRect = selectorWrapper.getBoundingClientRect()) === null || _selectorWrapper_getBoundingClientRect === void 0 ? void 0 : _selectorWrapper_getBoundingClientRect.height) !== null && _selectorWrapper_getBoundingClientRect_height !== void 0 ? _selectorWrapper_getBoundingClientRect_height : 0;
233
- var _listHeader_getBoundingClientRect_height, _listFooter_getBoundingClientRect_height;
234
- const maxSelectorWrapperHeight = 500 - ((_listHeader_getBoundingClientRect_height = listHeader === null || listHeader === void 0 ? void 0 : (_listHeader_getBoundingClientRect = listHeader.getBoundingClientRect()) === null || _listHeader_getBoundingClientRect === void 0 ? void 0 : _listHeader_getBoundingClientRect.height) !== null && _listHeader_getBoundingClientRect_height !== void 0 ? _listHeader_getBoundingClientRect_height : 0) - ((_listFooter_getBoundingClientRect_height = listFooter === null || listFooter === void 0 ? void 0 : (_listFooter_getBoundingClientRect = listFooter.getBoundingClientRect()) === null || _listFooter_getBoundingClientRect === void 0 ? void 0 : _listFooter_getBoundingClientRect.height) !== null && _listFooter_getBoundingClientRect_height !== void 0 ? _listFooter_getBoundingClientRect_height : 0);
235
- if (!isMobile || !withMobileLogic) {
236
- var _getComputedStyle1, _customTriggerRef_current_getBoundingClientRect, _customTriggerRef_current;
237
- const dropdownListMaxHeightInPx = (_getComputedStyle1 = getComputedStyle(dropdownList)) === null || _getComputedStyle1 === void 0 ? void 0 : _getComputedStyle1.maxHeight;
238
- var _dropdownListMaxHeightInPx_replace;
239
- const maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : Number.parseInt((_dropdownListMaxHeightInPx_replace = dropdownListMaxHeightInPx === null || dropdownListMaxHeightInPx === void 0 ? void 0 : dropdownListMaxHeightInPx.replace('px', '')) !== null && _dropdownListMaxHeightInPx_replace !== void 0 ? _dropdownListMaxHeightInPx_replace : 0, 10);
240
- if (initListHeight === null && !Number.isNaN(maxHeight)) setInitListHeight(maxHeight);
241
- if (selectorWrapperHeight !== undefined && selectorWrapperHeight > maxHeight && !Number.isNaN(maxHeight)) selectorWrapperHeight = maxHeight - 2 * margin;
242
- var _customTriggerRef_current_getBoundingClientRect_height;
243
- const toTop = renderCustomTrigger ? top - margin - ((_customTriggerRef_current_getBoundingClientRect_height = customTriggerRef === null || customTriggerRef === void 0 ? void 0 : (_customTriggerRef_current = customTriggerRef.current) === null || _customTriggerRef_current === void 0 ? void 0 : (_customTriggerRef_current_getBoundingClientRect = _customTriggerRef_current.getBoundingClientRect()) === null || _customTriggerRef_current_getBoundingClientRect === void 0 ? void 0 : _customTriggerRef_current_getBoundingClientRect.height) !== null && _customTriggerRef_current_getBoundingClientRect_height !== void 0 ? _customTriggerRef_current_getBoundingClientRect_height : 0) : top - margin;
244
- const toBottom = windowHeight - top - height - margin * 2;
245
- let listPosition = listPos;
246
- if (!listPos && options.length) {
247
- listPosition = toTop < toBottom || toBottom >= selectorWrapperHeight ? 'bottom' : 'top';
248
- setListPos(listPosition);
249
- }
250
- if (selectorWrapperHeight > (listPosition === 'top' ? toTop : toBottom)) {
251
- selectorWrapperHeight = (listPosition === 'top' ? toTop : toBottom) - 3 * margin;
252
- if (selectorWrapperHeight < 200) {
253
- selectorWrapperHeight = 200;
254
- }
255
- if (selectorWrapper) selectorWrapper.style.maxHeight = `${selectorWrapperHeight}px`;
256
- }
257
- listContainer.style.minWidth = `${width}px`;
258
- listContainer.style.left = `${left}px`;
259
- listContainer.style.top = `${listPosition === 'bottom' ? top + height : top - selectorWrapperHeight - 2 * margin}px`;
260
- } else {
261
- dropdownList.style.maxHeight = `${maxSelectorWrapperHeight}px`;
262
- }
263
- };
264
- const renderListContainer = ()=>{
265
- const lc = getListContainer();
266
- if (!lc) return null;
267
- return /*#__PURE__*/ (0, _reactdom.createPortal)(getListMarkUp(), lc);
268
- };
269
- // --- LIST CONTAINER FUNCTIONS END --- //
270
- // --- CREATABLE LOGIC BEGIN --- //
271
- const onOptionCreateClick = ()=>{
272
- const newOption = {
273
- label: searchValue,
274
- style: {
275
- backgroundColor: randomColorForNewOption
276
- },
277
- isEditable: true,
278
- ref: /*#__PURE__*/ (0, _react.createRef)()
279
- };
280
- var _onOptionCreate;
281
- ((_onOptionCreate = onOptionCreate === null || onOptionCreate === void 0 ? void 0 : onOptionCreate(newOption)) !== null && _onOptionCreate !== void 0 ? _onOptionCreate : new Promise((r)=>r(1))).then((result)=>{
282
- const tempId = Math.random().toString(16).slice(2);
283
- var _result_id;
284
- newOption.value = (_result_id = result === null || result === void 0 ? void 0 : result.id) !== null && _result_id !== void 0 ? _result_id : tempId;
285
- setOptions((state)=>[
286
- ...state,
287
- newOption
288
- ]);
289
- setSearchValue('');
290
- onChangeHandler(newOption);
291
- });
292
- };
293
- const onOptionEditClick = (e, item)=>{
294
- e === null || e === void 0 ? void 0 : e.preventDefault();
295
- e === null || e === void 0 ? void 0 : e.stopPropagation();
296
- setEditingOption((editingOption === null || editingOption === void 0 ? void 0 : editingOption.value) === (item === null || item === void 0 ? void 0 : item.value) ? null : item);
297
- };
298
- const onOptionDeleteClick = ()=>{
299
- var _onOptionDelete;
300
- ((_onOptionDelete = onOptionDelete === null || onOptionDelete === void 0 ? void 0 : onOptionDelete(editingOption)) !== null && _onOptionDelete !== void 0 ? _onOptionDelete : new Promise((r)=>r(1))).then(()=>{
301
- if (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value) deleteChosen(editingOption === null || editingOption === void 0 ? void 0 : editingOption.value);
302
- setOptions((options)=>options.filter(({ value })=>value !== (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value)));
303
- setEditingOption(null);
304
- });
305
- };
306
- const saveEditingOption = ()=>{
307
- if (!(editingOption === null || editingOption === void 0 ? void 0 : editingOption.isChanged) || isEditingOptionError) {
308
- setEditingOption(null);
309
- return false;
310
- }
311
- onOptionEdit === null || onOptionEdit === void 0 ? void 0 : onOptionEdit(editingOption);
312
- setOptions((options)=>options.map((option)=>{
313
- if (editingOption && option.value === (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value)) {
314
- const tmp = {
315
- ...editingOption
316
- };
317
- setEditingOption(null);
318
- return tmp;
319
- }
320
- return option;
321
- }));
322
- };
323
- const setEditOptionModalStyles = ()=>{
324
- var _editingOption_ref, _dropdownListWrapperRef_current;
325
- if (!editingOption || !(editOptionModalRef === null || editOptionModalRef === void 0 ? void 0 : editOptionModalRef.current)) return null;
326
- const modalSize = 200;
327
- const { scrollX, scrollY } = window;
328
- const positionClasses = {
329
- left: 'modal-left',
330
- right: 'modal-right',
331
- top: 'modal-top',
332
- bottom: 'modal-bottom'
333
- };
334
- const windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
335
- const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
336
- const el = editingOption === null || editingOption === void 0 ? void 0 : (_editingOption_ref = editingOption.ref) === null || _editingOption_ref === void 0 ? void 0 : _editingOption_ref.current;
337
- var _el_getBoundingClientRect;
338
- const { x = 0, y = 0, width = 0, height = 0 } = (_el_getBoundingClientRect = el === null || el === void 0 ? void 0 : el.getBoundingClientRect()) !== null && _el_getBoundingClientRect !== void 0 ? _el_getBoundingClientRect : {};
339
- const containerPosition = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperRef_current = dropdownListWrapperRef.current) === null || _dropdownListWrapperRef_current === void 0 ? void 0 : _dropdownListWrapperRef_current.getBoundingClientRect();
340
- var _containerPosition_x, _containerPosition_width;
341
- const distanceToRight = windowWidth - ((_containerPosition_x = containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.x) !== null && _containerPosition_x !== void 0 ? _containerPosition_x : 0) - ((_containerPosition_width = containerPosition === null || containerPosition === void 0 ? void 0 : containerPosition.width) !== null && _containerPosition_width !== void 0 ? _containerPosition_width : 0);
342
- const distanceToBottom = windowHeight - y - scrollY - height;
343
- Object.values(positionClasses).map((className)=>{
344
- if (editOptionModalRef.current) editOptionModalRef.current.classList.remove(className);
345
- return className;
346
- });
347
- var _positionClasses_;
348
- editOptionModalRef.current.classList.add((_positionClasses_ = positionClasses === null || positionClasses === void 0 ? void 0 : positionClasses[distanceToRight < modalSize ? 'left' : 'right']) !== null && _positionClasses_ !== void 0 ? _positionClasses_ : '');
349
- var _positionClasses_1;
350
- editOptionModalRef.current.classList.add((_positionClasses_1 = positionClasses === null || positionClasses === void 0 ? void 0 : positionClasses[distanceToBottom < modalSize ? 'top' : 'bottom']) !== null && _positionClasses_1 !== void 0 ? _positionClasses_1 : '');
351
- const xTranslate = distanceToRight < modalSize ? 'calc(-100% + 7px)' : '-35px';
352
- const yTranslate = distanceToBottom < modalSize ? `calc(-100% - ${height + 10}px)` : '10px';
353
- editOptionModalRef.current.style.left = `${x + scrollX + width}px`;
354
- editOptionModalRef.current.style.top = `${y + scrollY + height}px`;
355
- editOptionModalRef.current.style.transform = `translate(${xTranslate}, ${yTranslate})`;
356
- };
357
- const renderEditOptionModal = ()=>{
358
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
359
- ref: editOptionModalRef,
360
- className: (0, _classnames.default)(`${RC}__edit-option-modal`),
361
- children: [
362
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
363
- className: (0, _classnames.default)(`${RC}__edit-option-modal-section`),
364
- children: [
365
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Input.default, {
366
- // TODO: REMOVE AFTER MIGRATE INPUT TO TYPESCRIPT
367
- // @ts-ignore
368
- value: editingOption.label,
369
- onChange: (v)=>setEditingOption((state)=>({
370
- ...state,
371
- label: v
372
- })),
373
- error: isEditingOptionError,
374
- onKeyDown: (keyCode)=>{
375
- if (keyCode === 13) saveEditingOption();
376
- },
377
- symbolsLimit: "50",
378
- ref: editingOptionInputRef
379
- }),
380
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Button.default, {
381
- variant: "link",
382
- icon: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Trash2, {}),
383
- label: "Delete",
384
- onClick: onOptionDeleteClick
385
- })
386
- ]
387
- }),
388
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
389
- className: (0, _classnames.default)(`${RC}__edit-option-modal-section-divider`)
390
- }),
391
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
392
- className: (0, _classnames.default)(`${RC}__edit-option-modal-section`),
393
- children: [
394
- /*#__PURE__*/ (0, _jsxruntime.jsx)("h3", {
395
- children: "Colors"
396
- }),
397
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
398
- className: (0, _classnames.default)(`${RC}__edit-option-modal-section-colors`),
399
- children: COLORS.map((color)=>{
400
- var _editingOption_style;
401
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
402
- className: "color-block",
403
- style: {
404
- backgroundColor: color
405
- },
406
- onClick: ()=>setEditingOption((state)=>({
407
- ...state,
408
- style: {
409
- ...state ? state.style : {},
410
- backgroundColor: color
411
- }
412
- })),
413
- children: (editingOption === null || editingOption === void 0 ? void 0 : (_editingOption_style = editingOption.style) === null || _editingOption_style === void 0 ? void 0 : _editingOption_style.backgroundColor) === color ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Check, {}) : null
414
- }, color);
415
- })
416
- })
417
- ]
418
- })
419
- ]
420
- }, `editOptionModal${editingOption === null || editingOption === void 0 ? void 0 : editingOption.value}`);
421
- };
422
- // --- CREATABLE LOGIC END --- //
423
- // --- GENERAL FUNCTIONS BEGIN --- //
424
- const handleClickOutside = (e)=>{
425
- var _getListContainer, _editOptionModalRef_current;
426
- const { target } = e;
427
- if (isOpen && !((_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.contains(target)) && !editOptionModalRef.current) {
428
- setIsOpen(false);
429
- onDropdownListClose === null || onDropdownListClose === void 0 ? void 0 : onDropdownListClose(e);
430
- } else if (editOptionModalRef.current && !((_editOptionModalRef_current = editOptionModalRef.current) === null || _editOptionModalRef_current === void 0 ? void 0 : _editOptionModalRef_current.contains(target))) {
431
- var _document_getElementById_contains, _document_getElementById, _document_getElementById1, _document;
432
- if (!((_document = document) === null || _document === void 0 ? void 0 : (_document_getElementById1 = _document.getElementById) === null || _document_getElementById1 === void 0 ? void 0 : (_document_getElementById = _document_getElementById1.call(_document, `editTrigger${editingOption === null || editingOption === void 0 ? void 0 : editingOption.value}`)) === null || _document_getElementById === void 0 ? void 0 : (_document_getElementById_contains = _document_getElementById.contains) === null || _document_getElementById_contains === void 0 ? void 0 : _document_getElementById_contains.call(_document_getElementById, target))) {
433
- saveEditingOption();
434
- }
435
- }
436
- };
437
- const closeList = (e)=>{
438
- var _inputRef_current;
439
- handleClickOutside(e);
440
- 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();
441
- };
442
- const isTargetInParent = (target)=>{
443
- var _target_parentNode, _target_parentNode1, _target_className_indexOf, _target_className, _target_className_indexOf1, _target_className1;
444
- if ((target === null || target === void 0 ? void 0 : target.tagName) === 'svg' && (target === null || target === void 0 ? void 0 : (_target_parentNode = target.parentNode) === null || _target_parentNode === void 0 ? void 0 : _target_parentNode.className) === 'tag__button' || (target === null || target === void 0 ? void 0 : target.tagName) === 'line') {
445
- return false;
446
- }
447
- if ((target === null || target === void 0 ? void 0 : target.tagName) === 'svg' && (target === null || target === void 0 ? void 0 : (_target_parentNode1 = target.parentNode) === null || _target_parentNode1 === void 0 ? void 0 : _target_parentNode1.className) !== 'tag__button' || (target === null || target === void 0 ? void 0 : (_target_className = target.className) === null || _target_className === void 0 ? void 0 : (_target_className_indexOf = _target_className.indexOf) === null || _target_className_indexOf === void 0 ? void 0 : _target_className_indexOf.call(_target_className, 'tag__label')) !== -1 || (target === null || target === void 0 ? void 0 : (_target_className1 = target.className) === null || _target_className1 === void 0 ? void 0 : (_target_className_indexOf1 = _target_className1.indexOf) === null || _target_className_indexOf1 === void 0 ? void 0 : _target_className_indexOf1.call(_target_className1, 'tag-list_wrapper')) !== -1 || (target === null || target === void 0 ? void 0 : target.className.indexOf(`${RC}__trigger`)) !== -1 || (target === null || target === void 0 ? void 0 : target.className) === 'tags-dropdown__arrow') {
448
- return true;
449
- }
450
- return false;
451
- };
452
- const isItemMatchesSearch = (item)=>{
453
- if (item.isHiddenInList) return false;
454
- const title = item.title || item.label;
455
- return searchValue.length ? !!(title === null || title === void 0 ? void 0 : title.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) : true;
456
- };
457
- // --- GENERAL FUNCTIONS END --- //
458
- const prepareOptions = (options)=>{
459
- return options === null || options === void 0 ? void 0 : options.map((option)=>{
460
- var _option_list;
461
- return (option === null || option === void 0 ? void 0 : option.groupName) ? (_option_list = option === null || option === void 0 ? void 0 : option.list) !== null && _option_list !== void 0 ? _option_list : [] : option;
462
- }).flat();
463
- };
464
- const getFilteredOptions = (options)=>options === null || options === void 0 ? void 0 : options.reduce((result, option)=>{
465
- if (option.groupName) {
466
- var _option_list;
467
- 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));
468
- if (filteredGroupItems === null || filteredGroupItems === void 0 ? void 0 : filteredGroupItems.length) {
469
- result.push({
470
- ...option,
471
- list: filteredGroupItems
472
- });
473
- }
474
- } else if (isItemMatchesSearch(option)) {
475
- result.push(option);
476
- }
477
- return result;
478
- }, []);
479
- const getTotalOptions = (0, _react.useCallback)(()=>{
480
- return options === null || options === void 0 ? void 0 : options.reduce((result, item)=>{
481
- if (item === null || item === void 0 ? void 0 : item.list) {
482
- var _item_list;
483
- result += (item === null || item === void 0 ? void 0 : (_item_list = item.list) === null || _item_list === void 0 ? void 0 : _item_list.length) || 0;
484
- } else {
485
- ++result;
486
- }
487
- return result;
488
- }, 0);
489
- }, [
490
- options
491
- ]);
492
- const onChangeHandler = (item)=>{
493
- if (item === null || item === void 0 ? void 0 : item.isFreezed) return false;
494
- if ((item === null || item === void 0 ? void 0 : item.closeOnOptionSelect) !== undefined) {
495
- if (item.closeOnOptionSelect) setIsOpen(false);
496
- } else if (isMobile ? closeOnSelectMobile : closeOnSelect) {
497
- setIsOpen(false);
498
- }
499
- setSearchValueInterceptor('');
500
- if (item.value && chosenOptions.includes(item.value)) {
501
- deleteChosen(item.value);
502
- return null;
503
- }
504
- if (item.value && isUseLocalOptionsStore) {
505
- setLocalOptionsStore((options)=>{
506
- if (item.value) {
507
- return {
508
- ...options,
509
- [item.value]: item === null || item === void 0 ? void 0 : item.label
510
- };
511
- } else {
512
- return options;
513
- }
514
- });
515
- }
516
- if (item.value) onChange === null || onChange === void 0 ? void 0 : onChange([
517
- ...chosenOptions,
518
- item.value
519
- ], 'chosenOptions');
520
- return null;
521
- };
522
- const onSearchHandler = (name)=>{
523
- let inputValue = name;
524
- if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
525
- setSearchValueInterceptor(inputValue);
526
- };
527
- const onWrapperClick = (e)=>{
528
- if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
529
- e.stopPropagation();
530
- e.preventDefault();
531
- setIsOpen(false);
532
- }
533
- };
534
- const selectAllItems = ()=>{
535
- var _prepareOptions;
536
- const preparedOptions = (_prepareOptions = prepareOptions(options)) === null || _prepareOptions === void 0 ? void 0 : _prepareOptions.filter(({ isFreezed, value })=>value && !isFreezed && !(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.includes(value === null || value === void 0 ? void 0 : value.toString())) && value !== 'open_modal');
537
- if (isUseLocalOptionsStore) {
538
- setLocalOptionsStore((options)=>preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.reduce((result, { value, label })=>{
539
- if (value) result[value] = label;
540
- return result;
541
- }, options));
542
- }
543
- onChange === null || onChange === void 0 ? void 0 : onChange([
544
- ...chosenOptions,
545
- ...(preparedOptions === null || preparedOptions === void 0 ? void 0 : preparedOptions.map(({ value })=>value !== null && value !== void 0 ? value : '')) || []
546
- ], 'chosenOptions');
547
- if (isMobile ? closeOnSelectAllMobile : closeOnSelectAll) setIsOpen(false);
548
- };
549
- const unselectAllItems = ()=>{
550
- if (isUseLocalOptionsStore) setLocalOptionsStore({});
551
- onChange === null || onChange === void 0 ? void 0 : onChange(chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.filter((item)=>{
552
- var _prepareOptions_find, _prepareOptions;
553
- return (_prepareOptions = prepareOptions(options)) === null || _prepareOptions === void 0 ? void 0 : (_prepareOptions_find = _prepareOptions.find(({ value })=>value === item)) === null || _prepareOptions_find === void 0 ? void 0 : _prepareOptions_find.isFreezed;
554
- }), 'chosenOptions');
555
- if (isMobile ? closeOnRemoveAllMobile : closeOnRemoveAll) setIsOpen(false);
556
- };
557
- const doScrollCallback = (0, _react.useCallback)((e)=>{
558
- if (doLiveSearchRequest && typeof doLiveSearchRequest === 'function') {
559
- if (+Math.round(e.target.clientHeight + e.target.scrollTop) === +e.target.scrollHeight) {
560
- doLiveSearchRequest(searchValueRef.current, true);
561
- }
562
- }
563
- }, [
564
- options
565
- ]);
566
- // --- RENDER FUNCTIONS BEGIN --- //
567
- const getMarkupForElement = (item)=>{
568
- const { description } = item;
569
- const title = item.title || item.label;
570
- const hightlightSearchValue = (title)=>{
571
- var _title_toLowerCase;
572
- 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());
573
- if (index === -1) return title;
574
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("pre", {
575
- className: "inherit-styles",
576
- children: [
577
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
578
- children: title.substring(0, index)
579
- }),
580
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
581
- className: "search-match bg--yellow",
582
- children: title.substring(index, index + (searchValue === null || searchValue === void 0 ? void 0 : searchValue.length))
583
- }),
584
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
585
- children: title.substring(index + (searchValue === null || searchValue === void 0 ? void 0 : searchValue.length))
586
- })
587
- ]
588
- });
589
- };
590
- var _item_customMobileIcon;
591
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("button", {
592
- type: "button",
593
- ref: item === null || item === void 0 ? void 0 : item.ref,
594
- onClick: (e)=>{
595
- e.preventDefault();
596
- e.stopPropagation();
597
- onChangeHandler(item);
598
- },
599
- className: (0, _classnames.default)(`${RC}__list-item`, {
600
- [`${RC}__list-item_active`]: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.some((value)=>value === item.value)
601
- }, {
602
- [`${RC}__list-item_disabled`]: item.disabled
603
- }, {
604
- [`${RC}__list-item_freezed`]: item === null || item === void 0 ? void 0 : item.isFreezed
605
- }, {
606
- [`${RC}__list-item--editing`]: (item === null || item === void 0 ? void 0 : item.value) === (editingOption === null || editingOption === void 0 ? void 0 : editingOption.value)
607
- }, item.className),
608
- children: [
609
- !isMobile && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
610
- className: (0, _classnames.default)(`${RC}__active-icon`, {
611
- [`${RC}__active-icon_active`]: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.some((value)=>value === item.value)
612
- }),
613
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Check, {
614
- width: 16,
615
- height: 16,
616
- className: "color--text"
617
- })
618
- }),
619
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
620
- className: (0, _classnames.default)(`${RC}__list-item-body`),
621
- children: [
622
- renderOptionsAsTags ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_Tag.default, {
623
- className: (0, _classnames.default)(`${RC}__list-item-title`, item === null || item === void 0 ? void 0 : item.labelClassName, {
624
- 'tag_with-btn': !(item === null || item === void 0 ? void 0 : item.isFreezed)
625
- }),
626
- label: title ? hightlightSearchValue(title) : '',
627
- style: item === null || item === void 0 ? void 0 : item.style,
628
- isNoDismiss: true
629
- }, item === null || item === void 0 ? void 0 : item.value) : /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
630
- className: (0, _classnames.default)(`${RC}__list-item-title`, item.labelClassName),
631
- children: title ? hightlightSearchValue(title) : ''
632
- }),
633
- description && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
634
- className: (0, _classnames.default)(`${RC}__list-item-description`),
635
- children: description
636
- })
637
- ]
638
- }),
639
- !isMobile && (item === null || item === void 0 ? void 0 : item.isEditable) && onOptionEdit && onOptionDelete && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
640
- id: `editTrigger${item === null || item === void 0 ? void 0 : item.value}`,
641
- className: (0, _classnames.default)(`${RC}__list-item-edit-trigger`),
642
- onClick: (e)=>onOptionEditClick(e, item),
643
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.MoreHorizontal, {})
644
- }),
645
- isMobile ? (_item_customMobileIcon = item === null || item === void 0 ? void 0 : item.customMobileIcon) !== null && _item_customMobileIcon !== void 0 ? _item_customMobileIcon : /*#__PURE__*/ (0, _jsxruntime.jsx)(_CheckboxInput.default, {
646
- value: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.some((value)=>value === item.value),
647
- onChange: ()=>{
648
- onChangeHandler(item);
649
- },
650
- label: "",
651
- id: ""
652
- }) : ''
653
- ]
654
- }, `${RC}__list-item-${item.id || item.value}`);
655
- };
656
- const getListMarkUp = ()=>{
657
- var _filteredOptions_filter, _filteredOptions_filter1;
658
- const filteredOptions = getFilteredOptions(options);
659
- const arrToPrint = [];
660
- for (const option of filteredOptions){
661
- if (option.groupName) {
662
- var _option_list, _Date_now, _option_groupName_toString, _option_groupName;
663
- arrToPrint.push(/*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
664
- className: (0, _classnames.default)(`${RC}-group`, option.className),
665
- children: [
666
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
667
- className: `${RC}-group__name`,
668
- children: option.groupName
669
- }),
670
- (_option_list = option.list) === null || _option_list === void 0 ? void 0 : _option_list.map((item)=>getMarkupForElement(item))
671
- ]
672
- }, (_option_groupName = option.groupName) === null || _option_groupName === void 0 ? void 0 : (_option_groupName_toString = _option_groupName.toString()) === null || _option_groupName_toString === void 0 ? void 0 : _option_groupName_toString.replace(/ /g, '_').concat((_Date_now = Date.now()) === null || _Date_now === void 0 ? void 0 : _Date_now.toString())));
673
- } else {
674
- arrToPrint.push(getMarkupForElement(option));
675
- }
676
- }
677
- var _document_getElementById;
678
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
679
- className: (0, _classnames.default)(`${RC}__container-wrapper`),
680
- ref: wrapperRef,
681
- onClick: isMobile ? onWrapperClick : ()=>{},
682
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
683
- ref: dropdownListWrapperRef,
684
- className: (0, _classnames.default)(`${RC}__selector-wrapper`, {
685
- [`${RC}__selector-wrapper--fixed-height`]: isFixedMaxHeight && isMobile
686
- }),
687
- children: [
688
- headerContent || isMobile ? /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
689
- className: (0, _classnames.default)(`${RC}__header`, {
690
- [`${RC}__header-with-shadow`]: isScrollableList && isMobile,
691
- [`${RC}__header-with-shadow-hidden`]: scrollTop === 0
692
- }),
693
- children: [
694
- isMobile && /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
695
- children: [
696
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
697
- className: (0, _classnames.default)(`${RC}__header-row`),
698
- children: [
699
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
700
- className: (0, _classnames.default)(`${RC}__label`),
701
- children: label
702
- }),
703
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
704
- className: (0, _classnames.default)(`${RC}__close-icon`),
705
- onClick: (e)=>{
706
- e.stopPropagation();
707
- setIsOpen(false);
708
- },
709
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.X, {
710
- onClick: (e)=>{
711
- e.stopPropagation();
712
- setIsOpen(false);
713
- }
714
- })
715
- })
716
- ]
717
- }),
718
- getTotalOptions() > (minItemsForShowMobileSearch || MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH) && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
719
- className: (0, _classnames.default)(`${RC}__header-row`),
720
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Input.default, {
721
- className: `${RC}__input`,
722
- value: searchValue,
723
- onChange: (v)=>setSearchValueInterceptor(v),
724
- placeholder: mobileSearchPlaceholder || 'Search',
725
- // TODO: REMOVE AFTER MIGRATE INPUT TO TYPESCRIPT
726
- // @ts-ignore
727
- withDelete: true,
728
- onMouseDown: ()=>{
729
- if (!isOpen) {
730
- setIsOpen(true);
731
- }
732
- },
733
- ...attributesOfNativeInput
734
- })
735
- })
736
- ]
737
- }),
738
- headerContent && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
739
- className: (0, _classnames.default)(`${RC}__header-row`),
740
- children: headerContent
741
- })
742
- ]
743
- }) : null,
744
- withSearchInputInList && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
745
- className: (0, _classnames.default)(`${RC}__input-list-wrapper`),
746
- children: renderSearchInput()
747
- }),
748
- withCreateLogic && onOptionCreate && searchValue && filteredOptions.length && singleLevelOptions.every(({ label })=>(label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase())) ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
749
- className: (0, _classnames.default)(`${RC}__creatable-helper`),
750
- children: "Select an option or create one"
751
- }) : null,
752
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
753
- ref: dropdownListRef,
754
- className: `${RC}__list ${headerContent || isMobile ? `${RC}__list--with-header` : ''} ${footerContent ? `${RC}__list--with-footer` : ''}`,
755
- children: [
756
- arrToPrint,
757
- ((_filteredOptions_filter = filteredOptions.filter(({ value })=>value !== 'open_modal')) === null || _filteredOptions_filter === void 0 ? void 0 : _filteredOptions_filter.length) === 0 && (!withCreateLogic || !searchValue) ? /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
758
- className: `${RC}__no-options`,
759
- children: noOptionsText
760
- }) : null
761
- ]
762
- }),
763
- (footerContent || isMobile) && ((_filteredOptions_filter1 = filteredOptions.filter(({ value })=>value !== 'open_modal')) === null || _filteredOptions_filter1 === void 0 ? void 0 : _filteredOptions_filter1.length) > 0 ? /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
764
- className: (0, _classnames.default)(`${RC}__footer`, {
765
- [`${RC}__footer-with-shadow`]: isMobile && isScrollableList,
766
- [`${RC}__footer-with-shadow-hidden`]: scrollTop === scrollHeight
767
- }),
768
- children: [
769
- footerContent,
770
- isMobile && /*#__PURE__*/ (0, _jsxruntime.jsxs)("button", {
771
- type: "button",
772
- onClick: ()=>setIsOpen(false),
773
- children: [
774
- "Apply",
775
- (chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.length) ? `(${chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.length})` : ''
776
- ]
777
- })
778
- ]
779
- }) : null,
780
- editingOption && /*#__PURE__*/ (0, _reactdom.createPortal)(renderEditOptionModal(), (_document_getElementById = document.getElementById('app')) !== null && _document_getElementById !== void 0 ? _document_getElementById : document.body),
781
- withCreateLogic && onOptionCreate && searchValue && singleLevelOptions.every(({ label })=>(label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase())) && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
782
- className: (0, _classnames.default)(`${RC}__create-option`),
783
- onClick: onOptionCreateClick,
784
- children: [
785
- "Create",
786
- /*#__PURE__*/ (0, _jsxruntime.jsx)(_Tag.default, {
787
- label: searchValue,
788
- style: {
789
- backgroundColor: randomColorForNewOption
790
- },
791
- isNoDismiss: true
792
- })
793
- ]
794
- })
795
- ]
796
- })
797
- });
798
- };
799
- const renderSearchInput = ()=>{
800
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Input.default, {
801
- ref: inputRef,
802
- // TODO: REMOVE AFTER MIGRATE INPUT TO TYPESCRIPT
803
- // @ts-ignore
804
- className: (0, _classnames.default)(`${RC}__input`, {
805
- [`${RC}__input--in-list`]: withSearchInputInList
806
- }),
807
- value: searchValue,
808
- onChange: onSearchHandler,
809
- placeholder: placeholder || 'Select from list',
810
- attributesOfNativeInput: {
811
- ...attributesOfNativeInput,
812
- onKeyDown: (e)=>{
813
- if (e.keyCode === 13 && withCreateLogic && onOptionCreate && singleLevelOptions.every(({ label })=>(label === null || label === void 0 ? void 0 : label.toLowerCase()) !== (searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()))) {
814
- onOptionCreateClick();
815
- }
816
- onKeyPress === null || onKeyPress === void 0 ? void 0 : onKeyPress(e, searchValue);
817
- }
818
- },
819
- ...withCreateLogic ? {
820
- symbolsLimit: 50
821
- } : {}
822
- });
823
- };
824
- const renderDropdownTrigger = (0, _react.useCallback)(()=>{
825
- const renderDefaultDropdownTrigger = ()=>{
826
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
827
- className: (0, _classnames.default)(`${RC}__trigger`, {
828
- 'tags-dropdown__error': error,
829
- [`${RC}__trigger--with-actions`]: withActions
830
- }),
831
- onClick: ({ target })=>{
832
- if ((target === null || target === void 0 ? void 0 : target.tagName) === 'INPUT') {
833
- setIsOpen(true);
834
- } else if (isTargetInParent(target)) {
835
- setIsOpen((isOpen)=>!isOpen);
836
- }
837
- },
838
- children: [
839
- noTagsWrap ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_TagList.default, {
840
- // TODO: REMOVE AFTER MIGRATE TAGLIST TO TYPESCRIPT
841
- // @ts-ignore
842
- items: chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.map((value, i)=>{
843
- const tag = singleLevelOptions === null || singleLevelOptions === void 0 ? void 0 : singleLevelOptions.find((el)=>el.value === value);
844
- 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);
845
- return {
846
- value,
847
- label,
848
- id: i,
849
- className: tag === null || tag === void 0 ? void 0 : tag.labelClassName,
850
- style: tag === null || tag === void 0 ? void 0 : tag.style
851
- };
852
- }),
853
- disableShowMore: true
854
- }) : chosenOptions === null || chosenOptions === void 0 ? void 0 : chosenOptions.map((value)=>{
855
- const tag = singleLevelOptions === null || singleLevelOptions === void 0 ? void 0 : singleLevelOptions.find((el)=>el.value === value);
856
- 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);
857
- return /*#__PURE__*/ (0, _jsxruntime.jsx)(_Tag.default, {
858
- className: (0, _classnames.default)(tagClassname, tag === null || tag === void 0 ? void 0 : tag.labelClassName, {
859
- 'tag_with-btn': !(tag === null || tag === void 0 ? void 0 : tag.isFreezed)
860
- }),
861
- label: label,
862
- style: tag === null || tag === void 0 ? void 0 : tag.style,
863
- removeItem: (tag === null || tag === void 0 ? void 0 : tag.isFreezed) ? undefined : ()=>deleteChosen(value),
864
- isNoDismiss: false
865
- }, value);
866
- }),
867
- chosenOptions.length === 0 || !noTagsWrap ? renderSearchInput() : '',
868
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
869
- className: (0, _classnames.default)(`${RC}__arrow`, {
870
- [`${RC}__arrow_active`]: isOpen
871
- }),
872
- children: isMobile ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Code, {
873
- className: "mobile-icon"
874
- }) : isOpen ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.ChevronUp, {
875
- className: "color--text"
876
- }) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.ChevronDown, {
877
- className: "color--text"
878
- })
879
- })
880
- ]
881
- });
882
- };
883
- var _renderCustomTrigger;
884
- return (_renderCustomTrigger = renderCustomTrigger === null || renderCustomTrigger === void 0 ? void 0 : renderCustomTrigger({
885
- chosenOptions,
886
- singleLevelOptions,
887
- deleteChosen,
888
- inputRef,
889
- onSearchHandler,
890
- isOpen,
891
- setIsOpen
892
- })) !== null && _renderCustomTrigger !== void 0 ? _renderCustomTrigger : renderDefaultDropdownTrigger();
893
- }, [
894
- chosenOptions,
895
- singleLevelOptions,
896
- inputRef,
897
- isOpen
898
- ]);
899
- // --- RENDER FUNCTIONS END --- //
900
- (0, _react.useLayoutEffect)(()=>{
901
- initListContainer();
902
- if (isDefaultOpened && !isMobileProp) setIsOpen(true);
903
- return ()=>{
904
- var _getListContainer, _getListContainerWrapper;
905
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.remove();
906
- (_getListContainerWrapper = getListContainerWrapper()) === null || _getListContainerWrapper === void 0 ? void 0 : _getListContainerWrapper.remove();
907
- };
908
- }, []);
909
- (0, _react.useLayoutEffect)(()=>{
910
- var _getListContainer;
911
- if (!isMobile) {
912
- window.addEventListener('mousewheel', closeList);
913
- window.addEventListener('wheel', closeList);
914
- window.addEventListener('touchmove', closeList);
915
- window.addEventListener('mouseup', handleClickOutside);
916
- } else {
917
- window.removeEventListener('mousewheel', closeList);
918
- window.removeEventListener('wheel', closeList);
919
- window.removeEventListener('touchmove', closeList);
920
- window.removeEventListener('mouseup', handleClickOutside);
921
- }
922
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.addEventListener('click', closeList);
923
- return ()=>{
924
- var _getListContainer;
925
- window.removeEventListener('mousewheel', closeList);
926
- window.removeEventListener('mouseup', handleClickOutside);
927
- window.removeEventListener('wheel', closeList);
928
- window.removeEventListener('touchmove', closeList);
929
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.removeEventListener('click', closeList);
930
- };
931
- }, [
932
- getListContainer,
933
- isMobile
934
- ]);
935
- (0, _react.useLayoutEffect)(()=>{
936
- if (isOpen) {
937
- setListContainerStyles();
938
- setEditOptionModalStyles();
939
- }
940
- }, [
941
- isOpen,
942
- optionsProp,
943
- chosenOptions,
944
- searchValue,
945
- isMobile,
946
- dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperRef_current = dropdownListWrapperRef.current) === null || _dropdownListWrapperRef_current === void 0 ? void 0 : (_dropdownListWrapperRef_current_getBoundingClientRect = _dropdownListWrapperRef_current.getBoundingClientRect()) === null || _dropdownListWrapperRef_current_getBoundingClientRect === void 0 ? void 0 : _dropdownListWrapperRef_current_getBoundingClientRect.height,
947
- recalculateListContainerStylesTrigger
948
- ]);
949
- (0, _react.useEffect)(()=>{
950
- if (isUseLocalOptionsStore && chosenOptions.length !== Object.keys(localOptionsStore).length) {
951
- options.map((option)=>{
952
- var _option_value;
953
- if ((option === null || option === void 0 ? void 0 : option.value) && !(localOptionsStore === null || localOptionsStore === void 0 ? void 0 : localOptionsStore[option === null || option === void 0 ? void 0 : (_option_value = option.value) === null || _option_value === void 0 ? void 0 : _option_value.toString()])) {
954
- setLocalOptionsStore((options)=>{
955
- if (option.value) {
956
- var _option_value;
957
- return {
958
- ...options,
959
- [option === null || option === void 0 ? void 0 : (_option_value = option.value) === null || _option_value === void 0 ? void 0 : _option_value.toString()]: option === null || option === void 0 ? void 0 : option.label
960
- };
961
- } else {
962
- return options;
963
- }
964
- });
965
- }
966
- return option;
967
- });
968
- }
969
- }, [
970
- chosenOptions,
971
- isUseLocalOptionsStore
972
- ]);
973
- (0, _react.useEffect)(()=>{
974
- var _selectAllButtonRef_current, _unselectAllButtonRef_current;
975
- const windowScrollEventHandler = ()=>{
976
- setWindowScrollTop(window.scrollY);
977
- };
978
- const fn = isOpen ? 'addEventListener' : 'removeEventListener';
979
- selectAllButtonRef === null || selectAllButtonRef === void 0 ? void 0 : (_selectAllButtonRef_current = selectAllButtonRef.current) === null || _selectAllButtonRef_current === void 0 ? void 0 : _selectAllButtonRef_current[fn]('click', selectAllItems, true);
980
- unselectAllButtonRef === null || unselectAllButtonRef === void 0 ? void 0 : (_unselectAllButtonRef_current = unselectAllButtonRef.current) === null || _unselectAllButtonRef_current === void 0 ? void 0 : _unselectAllButtonRef_current[fn]('click', unselectAllItems, true);
981
- if (isOpen) {
982
- var _getListContainer;
983
- if (!isMobile || !withMobileLogic) window.removeEventListener('scroll', windowScrollEventHandler);
984
- if (customTriggerRef === null || customTriggerRef === void 0 ? void 0 : customTriggerRef.current) {
985
- customTriggerRef.current.style.pointerEvents = 'none';
986
- }
987
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.classList.add('tags-dropdown__container--opened');
988
- if (!isMobile) {
989
- var _inputRef_current_focus, _inputRef_current;
990
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef_current = inputRef.current) === null || _inputRef_current === void 0 ? void 0 : (_inputRef_current_focus = _inputRef_current.focus) === null || _inputRef_current_focus === void 0 ? void 0 : _inputRef_current_focus.call(_inputRef_current);
991
- } else {
992
- var _inputRef_current_blur, _inputRef_current1;
993
- inputRef === null || inputRef === void 0 ? void 0 : (_inputRef_current1 = inputRef.current) === null || _inputRef_current1 === void 0 ? void 0 : (_inputRef_current_blur = _inputRef_current1.blur) === null || _inputRef_current_blur === void 0 ? void 0 : _inputRef_current_blur.call(_inputRef_current1);
994
- }
995
- } else {
996
- var _getListContainer1;
997
- if (!isMobile || !withMobileLogic) window.addEventListener('scroll', windowScrollEventHandler);
998
- if (customTriggerRef === null || customTriggerRef === void 0 ? void 0 : customTriggerRef.current) {
999
- customTriggerRef.current.style.pointerEvents = 'auto';
1000
- }
1001
- (_getListContainer1 = getListContainer()) === null || _getListContainer1 === void 0 ? void 0 : _getListContainer1.classList.remove('tags-dropdown__container--opened');
1002
- if (withSearchInputInList) setSearchValueInterceptor('');
1003
- setListPos(null);
1004
- setSearchValue('');
1005
- }
1006
- }, [
1007
- isOpen
1008
- ]);
1009
- (0, _react.useEffect)(()=>{
1010
- const setScrollTopValue = (e)=>{
1011
- var _e_target_scrollTop;
1012
- setScrollTop(Number.parseInt((_e_target_scrollTop = e.target.scrollTop) === null || _e_target_scrollTop === void 0 ? void 0 : _e_target_scrollTop.toString(), 10));
1013
- };
1014
- const preventWindowScrolling = (e)=>{
1015
- e.preventDefault();
1016
- window.scrollTo({
1017
- top: windowScrollTop
1018
- });
1019
- };
1020
- if (isOpen && isMobile && (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current)) {
1021
- var _dropdownListRef_current, _dropdownListRef_current1, _dropdownListRef_current2;
1022
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current = dropdownListRef.current) === null || _dropdownListRef_current === void 0 ? void 0 : _dropdownListRef_current.addEventListener('scroll', setScrollTopValue);
1023
- setIsScrollableList((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current1 = dropdownListRef.current) === null || _dropdownListRef_current1 === void 0 ? void 0 : _dropdownListRef_current1.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current2 = dropdownListRef.current) === null || _dropdownListRef_current2 === void 0 ? void 0 : _dropdownListRef_current2.clientHeight));
1024
- if (isScrollableList === null) {
1025
- var _dropdownListRef_current3, _dropdownListRef_current4;
1026
- setIsFixedMaxHeight((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current3 = dropdownListRef.current) === null || _dropdownListRef_current3 === void 0 ? void 0 : _dropdownListRef_current3.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current4 = dropdownListRef.current) === null || _dropdownListRef_current4 === void 0 ? void 0 : _dropdownListRef_current4.clientHeight));
1027
- }
1028
- }
1029
- if (isOpen && dropdownListRef && dropdownListRef.current) {
1030
- dropdownListRef.current.addEventListener('scroll', doScrollCallback);
1031
- if (!isMobile || !withMobileLogic) window.addEventListener('scroll', preventWindowScrolling);
1032
- }
1033
- return ()=>{
1034
- var _dropdownListRef_current, _dropdownListRef_current1;
1035
- if (!isMobile || !withMobileLogic) window.removeEventListener('scroll', preventWindowScrolling);
1036
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current = dropdownListRef.current) === null || _dropdownListRef_current === void 0 ? void 0 : _dropdownListRef_current.removeEventListener('scroll', doScrollCallback);
1037
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current1 = dropdownListRef.current) === null || _dropdownListRef_current1 === void 0 ? void 0 : _dropdownListRef_current1.removeEventListener('scroll', setScrollTopValue);
1038
- };
1039
- }, [
1040
- isOpen,
1041
- isMobile,
1042
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current,
1043
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current = dropdownListRef.current) === null || _dropdownListRef_current === void 0 ? void 0 : _dropdownListRef_current.scrollHeight,
1044
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current1 = dropdownListRef.current) === null || _dropdownListRef_current1 === void 0 ? void 0 : _dropdownListRef_current1.clientHeight
1045
- ]);
1046
- (0, _react.useEffect)(()=>{
1047
- if (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current) {
1048
- var _this, _dropdownListRef_current, _dropdownListRef_current1;
1049
- setScrollHeight(Number.parseInt((_this = (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current = dropdownListRef.current) === null || _dropdownListRef_current === void 0 ? void 0 : _dropdownListRef_current.scrollHeight) - (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current1 = dropdownListRef.current) === null || _dropdownListRef_current1 === void 0 ? void 0 : _dropdownListRef_current1.clientHeight)) === null || _this === void 0 ? void 0 : _this.toString(), 10));
1050
- }
1051
- }, [
1052
- scrollTop,
1053
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current
1054
- ]);
1055
- (0, _react.useEffect)(()=>{
1056
- if (isSearchable && useLiveSearch && (debouncedSearchTerm || isValueDeleted || isOpen)) {
1057
- doLiveSearchRequest === null || doLiveSearchRequest === void 0 ? void 0 : doLiveSearchRequest(debouncedSearchTerm);
1058
- }
1059
- }, [
1060
- isOpen,
1061
- debouncedSearchTerm,
1062
- isValueDeleted
1063
- ]);
1064
- (0, _react.useEffect)(()=>{
1065
- setOptions(optionsProp.map((option)=>({
1066
- ...option,
1067
- ref: /*#__PURE__*/ (0, _react.createRef)()
1068
- })));
1069
- }, [
1070
- optionsProp
1071
- ]);
1072
- (0, _react.useEffect)(()=>{
1073
- if (editingOption) {
1074
- var _editingOptionInputRef_current_focus, _editingOptionInputRef_current;
1075
- setEditOptionModalStyles();
1076
- editingOptionInputRef === null || editingOptionInputRef === void 0 ? void 0 : (_editingOptionInputRef_current = editingOptionInputRef.current) === null || _editingOptionInputRef_current === void 0 ? void 0 : (_editingOptionInputRef_current_focus = _editingOptionInputRef_current.focus) === null || _editingOptionInputRef_current_focus === void 0 ? void 0 : _editingOptionInputRef_current_focus.call(_editingOptionInputRef_current);
1077
- }
1078
- }, [
1079
- editingOption === null || editingOption === void 0 ? void 0 : editingOption.value
1080
- ]);
1081
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
1082
- className: (0, _classnames.default)(RC, className, {
1083
- [`${RC}_disabled`]: disabled,
1084
- [`${RC}-mobile`]: isMobile,
1085
- [`${RC}--focused`]: isOpen && !(customTriggerRef === null || customTriggerRef === void 0 ? void 0 : customTriggerRef.current) && !isMobile,
1086
- [`${RC}--custom-trigger`]: Boolean(customTriggerRef === null || customTriggerRef === void 0 ? void 0 : customTriggerRef.current)
1087
- }),
1088
- ref: dropdownRef,
1089
- children: [
1090
- renderDropdownTrigger(),
1091
- withActions && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
1092
- className: (0, _classnames.default)(`${RC}__actions`),
1093
- children: [
1094
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
1095
- className: (0, _classnames.default)(`${RC}__actions-item`),
1096
- onClick: onActionConfirmClick,
1097
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Check, {})
1098
- }),
1099
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
1100
- className: (0, _classnames.default)(`${RC}__actions-item`),
1101
- onClick: onActionCancelClick,
1102
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.X, {})
1103
- })
1104
- ]
1105
- }),
1106
- isOpen && renderListContainer()
1107
- ]
1108
- });
1109
- };
1110
- const _default = TagsDropdown;
1
+ function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var l=0,t=Array(n);l<n;l++)t[l]=e[l];return t}function n(e,n,l){return n in e?Object.defineProperty(e,n,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[n]=l,e}function l(e){for(var l=1;l<arguments.length;l++){var t=null!=arguments[l]?arguments[l]:{},o=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),o.forEach(function(l){n(e,l,t[l])})}return e}function t(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e,n){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);l.push.apply(l,t)}return l})(Object(n)).forEach(function(l){Object.defineProperty(e,l,Object.getOwnPropertyDescriptor(n,l))}),e}function o(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var l,t,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var r=[],i=!0,u=!1;try{for(o=o.call(e);!(i=(l=o.next()).done)&&(r.push(l.value),!n||r.length!==n);i=!0);}catch(e){u=!0,t=e}finally{try{i||null==o.return||o.return()}finally{if(u)throw t}}return r}}(e,n)||i(e,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(n){return function(n){if(Array.isArray(n))return e(n)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||i(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(n,l){if(n){if("string"==typeof n)return e(n,l);var t=Object.prototype.toString.call(n).slice(8,-1);if("Object"===t&&n.constructor&&(t=n.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return e(n,l)}}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return j}});var u=require("react/jsx-runtime"),a=w(require("classnames")),c=function(e,n){if(e&&e.__esModule)return e;if(null===e||(void 0===e?"undefined":e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)!="object"&&"function"!=typeof e)return{default:e};var l=y(n);if(l&&l.has(e))return l.get(e);var t={__proto__:null},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var r in e)if("default"!==r&&Object.prototype.hasOwnProperty.call(e,r)){var i=o?Object.getOwnPropertyDescriptor(e,r):null;i&&(i.get||i.set)?Object.defineProperty(t,r,i):t[r]=e[r]}return t.default=e,l&&l.set(e,t),t}(require("react")),s=require("react-dom"),d=require("react-feather"),v=require("../../../Functions/fieldValueFormatters"),f=require("../../../Functions/useDebounce"),m=w(require("../../../Functions/useIsMobile/useIsMobile")),p=w(require("../../UI/Button/Button")),h=w(require("../../UI/Tag/Tag")),g=w(require("../../UI/TagList/TagList")),b=w(require("../CheckboxInput/CheckboxInput")),_=w(require("../Input/Input"));function w(e){return e&&e.__esModule?e:{default:e}}function y(e){if("function"!=typeof WeakMap)return null;var n=new WeakMap,l=new WeakMap;return(y=function(e){return e?l:n})(e)}require("./TagsDropdown.scss");var x="tags-dropdown",N=["#F1F0F0","#E3E2E0","#EEDFDA","#F9DEC9","#FDECC8","#DBECDB","#D3E4EF","#E8DEEE","#F4E0E9","#FFE2DD","#D3EFED","#ECEEDE"],j=function(e){var i,w,y,j,C,E,O,S=e.options,L=e.chosenOptions,k=e.onChange,D=e.className,I=e.tagClassname,P=e.listClassName,M=e.onKeyPress,R=e.placeholder,A=e.label,F=e.disabled,T=e.isValuesInTags,B=e.error,H=e.isNotValidateASCII,q=void 0!==H&&H,z=e.noTagsWrap,W=void 0!==z&&z,U=e.headerContent,K=void 0===U?null:U,V=e.footerContent,X=void 0===V?null:V,Y=e.selectAllButtonRef,$=void 0===Y?null:Y,G=e.unselectAllButtonRef,J=void 0===G?null:G,Q=e.closeOnSelect,Z=void 0!==Q&&Q,ee=e.closeOnRemove,en=void 0!==ee&&ee,el=e.closeOnRemoveAll,et=void 0!==el&&el,eo=e.closeOnSelectAll,er=void 0!==eo&&eo,ei=e.closeOnSelectMobile,eu=void 0!==ei&&ei,ea=e.closeOnRemoveMobile,ec=void 0!==ea&&ea,es=e.closeOnRemoveAllMobile,ed=void 0!==es&&es,ev=e.closeOnSelectAllMobile,ef=void 0!==ev&&ev,em=e.fieldKey,ep=e.id,eh=e.noOptionsText,eg=void 0===eh?"No options available":eh,eb=e.mobileSearchPlaceholder,e_=e.isSearchable,ew=void 0===e_||e_,ey=e.useLiveSearch,ex=e.doRequest,eN=e.attributesOfNativeInput,ej=e.isUseLocalOptionsStore,eC=void 0===ej||ej,eE=e.isDefaultOpened,eO=void 0!==eE&&eE,eS=e.withMobileLogic,eL=e.withCreateLogic,ek=e.withActions,eD=e.withSearchInputInList,eI=e.renderOptionsAsTags,eP=e.minItemsForShowMobileSearch,eM=void 0===eP?10:eP,eR=e.onOptionCreate,eA=e.onOptionEdit,eF=e.onOptionDelete,eT=e.onActionConfirmClick,eB=e.onActionCancelClick,eH=e.onDropdownListClose,eq=e.customTriggerRef,ez=e.renderCustomTrigger,eW=e.recalculateListContainerStylesTrigger,eU=(0,c.useRef)(null),eK=(0,c.useRef)(null),eV=(0,c.useRef)(null),eX=(0,c.useRef)(null),eY=(0,c.useRef)(null),e$=(0,c.useRef)(null),eG=(0,m.default)().isMobile,eJ=eG&&eS&&window.screen.width<=768,eQ=o((0,c.useState)(ep||em||Math.random().toString(16).slice(2)),1)[0],eZ=o((0,c.useState)(!1),2),e0=eZ[0],e1=eZ[1],e2=o((0,c.useState)(0),2),e3=e2[0],e6=e2[1],e8=o((0,c.useState)(null),2),e5=e8[0],e9=e8[1],e4=o((0,c.useState)(null),2),e7=e4[0],ne=e4[1],nn=o((0,c.useState)(null),2),nl=nn[0],nt=nn[1],no=o((0,c.useState)(!1),2),nr=no[0],ni=no[1],nu=o((0,c.useState)(0),2),na=nu[0],nc=nu[1],ns=o((0,c.useState)(1),2),nd=ns[0],nv=ns[1],nf=(0,c.useRef)(null),nm=o((0,c.useState)(""),2),np=nm[0],nh=nm[1],ng=(0,f.useDebounce)({searchValue:np,delay:600}),nb=o((0,c.useState)(!1),2),n_=nb[0],nw=nb[1],ny=function(e){nh(e),nw(np!==e&&""===e),nf.current=e},nx=(0,c.useRef)(null),nN=o((0,c.useState)([]),2),nj=nN[0],nC=nN[1],nE=o((0,c.useState)(null),2),nO=nE[0],nS=nE[1],nL=function(e){nS(function(n){return e?t(l({},null!=n?n:{},"function"==typeof e?null==e?void 0:e(n):e),{isChanged:!!n}):e})},nk=(0,c.useMemo)(function(){return!!nO&&(!!nj.filter(function(e){return e.value!==nO.value}).some(function(e){return e.label===nO.label})||null)},[nj,nO]),nD=o((0,c.useState)({}),2),nI=nD[0],nP=nD[1],nM=(0,c.useMemo)(function(){var e=Math.floor(Math.random()*(N.length-1-0+1))+0;return N[e]},[nj.length]),nR=null==nj?void 0:nj.reduce(function(e,n){var l,t=function(e,n){var l=null==e?void 0:e.findIndex(function(e){return e.value===(null==n?void 0:n.value)});-1!==l?e[l]=n:e.push(n)};return n.groupName?null==(l=n.list)||l.map(function(n){return t(e,n)}):t(e,n),e},eC?null==(w=Object.keys(nI))?void 0:w.map(function(e){var n;return{value:e,label:null!=(n=null==nI?void 0:nI[e])?n:""}}):[]),nA=function(e){(eJ?ec:en)&&e1(!1),eC&&nP(function(o){return t(l({},o),n({},e,void 0))}),null==k||k(L.filter(function(n){return n!==e}),"chosenOptions")},nF=function(){var e,n;return null!=(n=null!=(e=document.querySelector("div#root"))?e:document.querySelector("div#app"))?n:document.querySelector("div#storybook-root")},nT=function(){var e,n=document.createElement("div");if(n.setAttribute("id",eQ),n.classList.add("tags-dropdown__container"),P&&n.classList.add(P),eJ&&n.addEventListener("click",function(e){e.target&&e.target.id===eQ&&e1(!1)}),eJ){try{null==(t=document.getElementById("mlw-".concat(eQ)))||t.remove()}catch(e){}var l,t,o=document.createElement("div");o.classList.add("tags-dropdown-mobile"),o.setAttribute("id","mlw-".concat(eQ)),null==o||o.append(n),null==(l=nF())||l.append(o)}else null==(e=nF())||e.append(n)},nB=function(){return document.getElementById(eQ)},nH=function(){var e=nB();if(!e||!e0)return!1;var n=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,l=null!=(x=null==eV||null==(h=eV.current)?void 0:h.getBoundingClientRect())?x:{},t=l.width,o=l.height,r=void 0===o?0:o,i=l.left,u=l.top,a=void 0===u?0:u,c=null==e$?void 0:e$.current,s=e.getElementsByClassName("tags-dropdown__list")[0],d=null==c?void 0:c.getElementsByClassName("tags-dropdown__header")[0],v=null==c?void 0:c.getElementsByClassName("tags-dropdown__footer")[0],f=Number.parseInt(null!=(N=null==(b=getComputedStyle(c))||null==(g=b.marginTop)?void 0:g.replace("px",""))?N:0,10),m=null!=(j=null==c||null==(_=c.getBoundingClientRect())?void 0:_.height)?j:0,p=500-(null!=(C=null==d||null==(w=d.getBoundingClientRect())?void 0:w.height)?C:0)-(null!=(E=null==v||null==(y=v.getBoundingClientRect())?void 0:y.height)?E:0);if(eJ&&eS)s.style.maxHeight="".concat(p,"px");else{var h,g,b,_,w,y,x,N,j,C,E,O,S,L,k,D,I=null==(O=getComputedStyle(s))?void 0:O.maxHeight,P=null!=e7?e7:Number.parseInt(null!=(k=null==I?void 0:I.replace("px",""))?k:0,10);null!==e7||Number.isNaN(P)||ne(P),void 0!==m&&m>P&&!Number.isNaN(P)&&(m=P-2*f);var M=ez?a-f-(null!=(D=null==eq||null==(L=eq.current)||null==(S=L.getBoundingClientRect())?void 0:S.height)?D:0):a-f,R=n-a-r-2*f,A=e5;!e5&&nj.length&&e9(A=M<R||R>=m?"bottom":"top"),m>("top"===A?M:R)&&((m=("top"===A?M:R)-3*f)<200&&(m=200),c&&(c.style.maxHeight="".concat(m,"px"))),e.style.minWidth="".concat(t,"px"),e.style.left="".concat(i,"px"),e.style.top="".concat("bottom"===A?a+r:a-m-2*f,"px")}},nq=function(){var e,n={label:np,style:{backgroundColor:nM},isEditable:!0,ref:(0,c.createRef)()};(null!=(e=null==eR?void 0:eR(n))?e:new Promise(function(e){return e(1)})).then(function(e){var l,t=Math.random().toString(16).slice(2);n.value=null!=(l=null==e?void 0:e.id)?l:t,nC(function(e){return r(e).concat([n])}),nh(""),nQ(n)})},nz=function(e,n){null==e||e.preventDefault(),null==e||e.stopPropagation(),nL((null==nO?void 0:nO.value)===(null==n?void 0:n.value)?null:n)},nW=function(){var e;(null!=(e=null==eF?void 0:eF(nO))?e:new Promise(function(e){return e(1)})).then(function(){(null==nO?void 0:nO.value)&&nA(null==nO?void 0:nO.value),nC(function(e){return e.filter(function(e){return e.value!==(null==nO?void 0:nO.value)})}),nL(null)})},nU=function(){if(!(null==nO?void 0:nO.isChanged)||nk)return nL(null),!1;null==eA||eA(nO),nC(function(e){return e.map(function(e){if(nO&&e.value===(null==nO?void 0:nO.value)){var n=l({},nO);return nL(null),n}return e})})},nK=function(){if(!nO||!(null==eY?void 0:eY.current))return null;var e,n,l,t,o,r,i,u=window.scrollX,a=window.scrollY,c={left:"modal-left",right:"modal-right",top:"modal-top",bottom:"modal-bottom"},s=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,d=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,v=null==nO||null==(e=nO.ref)?void 0:e.current,f=null!=(l=null==v?void 0:v.getBoundingClientRect())?l:{},m=f.x,p=f.y,h=void 0===p?0:p,g=f.width,b=f.height,_=void 0===b?0:b,w=null==e$||null==(n=e$.current)?void 0:n.getBoundingClientRect(),y=s-(null!=(t=null==w?void 0:w.x)?t:0)-(null!=(o=null==w?void 0:w.width)?o:0),x=d-h-a-_;Object.values(c).map(function(e){return eY.current&&eY.current.classList.remove(e),e}),eY.current.classList.add(null!=(r=null==c?void 0:c[y<200?"left":"right"])?r:""),eY.current.classList.add(null!=(i=null==c?void 0:c[x<200?"top":"bottom"])?i:""),eY.current.style.left="".concat((void 0===m?0:m)+u+(void 0===g?0:g),"px"),eY.current.style.top="".concat(h+a+_,"px"),eY.current.style.transform="translate(".concat(y<200?"calc(-100% + 7px)":"-35px",", ").concat(x<200?"calc(-100% - ".concat(_+10,"px)"):"10px",")")},nV=function(e){var n,l,t,o,r,i,u=e.target;!e0||(null==(n=nB())?void 0:n.contains(u))||eY.current?eY.current&&!(null==(l=eY.current)?void 0:l.contains(u))&&((null==(i=document)||null==(r=i.getElementById)||null==(o=r.call(i,"editTrigger".concat(null==nO?void 0:nO.value)))||null==(t=o.contains)?void 0:t.call(o,u))||nU()):(e1(!1),null==eH||eH(e))},nX=function(e){var n;nV(e),e.target.isEqualNode(null==eU?void 0:eU.current)||null==eU||null==(n=eU.current)||n.blur()},nY=function(e){var n,l,t,o,r,i;return((null==e?void 0:e.tagName)!=="svg"||(null==e||null==(n=e.parentNode)?void 0:n.className)!=="tag__button")&&(null==e?void 0:e.tagName)!=="line"&&((null==e?void 0:e.tagName)==="svg"&&(null==e||null==(l=e.parentNode)?void 0:l.className)!=="tag__button"||(null==e||null==(o=e.className)||null==(t=o.indexOf)?void 0:t.call(o,"tag__label"))!==-1||(null==e||null==(i=e.className)||null==(r=i.indexOf)?void 0:r.call(i,"tag-list_wrapper"))!==-1||(null==e?void 0:e.className.indexOf("".concat(x,"__trigger")))!==-1||(null==e?void 0:e.className)==="tags-dropdown__arrow")},n$=function(e){if(e.isHiddenInList)return!1;var n=e.title||e.label;return!np.length||!!(null==n?void 0:n.toLowerCase().includes((null==np?void 0:np.toLowerCase())||""))},nG=function(e){return null==e?void 0:e.map(function(e){var n;return(null==e?void 0:e.groupName)?null!=(n=null==e?void 0:e.list)?n:[]:e}).flat()},nJ=(0,c.useCallback)(function(){return null==nj?void 0:nj.reduce(function(e,n){if(null==n?void 0:n.list){var l;e+=(null==n||null==(l=n.list)?void 0:l.length)||0}else++e;return e},0)},[nj]),nQ=function(e){return(null==e||!e.isFreezed)&&(((null==e?void 0:e.closeOnOptionSelect)!==void 0?e.closeOnOptionSelect&&e1(!1):(eJ?eu:Z)&&e1(!1),ny(""),e.value&&L.includes(e.value))?nA(e.value):(e.value&&eC&&nP(function(o){return e.value?t(l({},o),n({},e.value,null==e?void 0:e.label)):o}),e.value&&(null==k||k(r(L).concat([e.value]),"chosenOptions"))),null)},nZ=function(e){var n=e;q||(n=(0,v.formatToOnlyASCIICodeText)(n)),ny(n)},n0=function(e){e.target===(null==eK?void 0:eK.current)&&(e.stopPropagation(),e.preventDefault(),e1(!1))},n1=function(){var e,n=null==(e=nG(nj))?void 0:e.filter(function(e){var n=e.isFreezed,l=e.value;return l&&!n&&!(null==L?void 0:L.includes(null==l?void 0:l.toString()))&&"open_modal"!==l});eC&&nP(function(e){return null==n?void 0:n.reduce(function(e,n){var l=n.value,t=n.label;return l&&(e[l]=t),e},e)}),null==k||k(r(L).concat(r((null==n?void 0:n.map(function(e){var n=e.value;return null!=n?n:""}))||[])),"chosenOptions"),(eJ?ef:er)&&e1(!1)},n2=function(){eC&&nP({}),null==k||k(null==L?void 0:L.filter(function(e){var n,l;return null==(l=nG(nj))||null==(n=l.find(function(n){return n.value===e}))?void 0:n.isFreezed}),"chosenOptions"),(eJ?ed:et)&&e1(!1)},n3=(0,c.useCallback)(function(e){ex&&"function"==typeof ex&&+Math.round(e.target.clientHeight+e.target.scrollTop)==+e.target.scrollHeight&&ex(nf.current,!0)},[nj]),n6=function(e){var l,t=e.description,o=e.title||e.label,r=function(e){var n,l=null==e||null==(n=e.toLowerCase())?void 0:n.indexOf(null==np?void 0:np.toLowerCase());return -1===l?e:(0,u.jsxs)("pre",{className:"inherit-styles",children:[(0,u.jsx)("span",{children:e.substring(0,l)}),(0,u.jsx)("span",{className:"search-match bg--yellow",children:e.substring(l,l+(null==np?void 0:np.length))}),(0,u.jsx)("span",{children:e.substring(l+(null==np?void 0:np.length))})]})};return(0,u.jsxs)("button",{type:"button",ref:null==e?void 0:e.ref,onClick:function(n){n.preventDefault(),n.stopPropagation(),nQ(e)},className:(0,a.default)("".concat(x,"__list-item"),n({},"".concat(x,"__list-item_active"),null==L?void 0:L.some(function(n){return n===e.value})),n({},"".concat(x,"__list-item_disabled"),e.disabled),n({},"".concat(x,"__list-item_freezed"),null==e?void 0:e.isFreezed),n({},"".concat(x,"__list-item--editing"),(null==e?void 0:e.value)===(null==nO?void 0:nO.value)),e.className),children:[!eJ&&(0,u.jsx)("span",{className:(0,a.default)("".concat(x,"__active-icon"),n({},"".concat(x,"__active-icon_active"),null==L?void 0:L.some(function(n){return n===e.value}))),children:(0,u.jsx)(d.Check,{width:16,height:16,className:"color--text"})}),(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__list-item-body")),children:[eI?(0,u.jsx)(h.default,{className:(0,a.default)("".concat(x,"__list-item-title"),null==e?void 0:e.labelClassName,{"tag_with-btn":!(null==e?void 0:e.isFreezed)}),label:o?r(o):"",style:null==e?void 0:e.style,isNoDismiss:!0},null==e?void 0:e.value):(0,u.jsx)("span",{className:(0,a.default)("".concat(x,"__list-item-title"),e.labelClassName),children:o?r(o):""}),t&&(0,u.jsx)("span",{className:(0,a.default)("".concat(x,"__list-item-description")),children:t})]}),!eJ&&(null==e?void 0:e.isEditable)&&eA&&eF&&(0,u.jsx)("div",{id:"editTrigger".concat(null==e?void 0:e.value),className:(0,a.default)("".concat(x,"__list-item-edit-trigger")),onClick:function(n){return nz(n,e)},children:(0,u.jsx)(d.MoreHorizontal,{})}),eJ?null!=(l=null==e?void 0:e.customMobileIcon)?l:(0,u.jsx)(b.default,{value:null==L?void 0:L.some(function(n){return n===e.value}),onChange:function(){nQ(e)},label:"",id:""}):""]},"".concat(x,"__list-item-").concat(e.id||e.value))},n8=function(){return(0,u.jsx)(_.default,l({ref:eU,className:(0,a.default)("".concat(x,"__input"),n({},"".concat(x,"__input--in-list"),eD)),value:np,onChange:nZ,placeholder:R||"Select from list",attributesOfNativeInput:t(l({},eN),{onKeyDown:function(e){13===e.keyCode&&eL&&eR&&nR.every(function(e){var n=e.label;return(null==n?void 0:n.toLowerCase())!==(null==np?void 0:np.toLowerCase())})&&nq(),null==M||M(e,np)}})},eL?{symbolsLimit:50}:{}))},n5=(0,c.useCallback)(function(){var e;return null!=(e=null==ez?void 0:ez({chosenOptions:L,singleLevelOptions:nR,deleteChosen:nA,inputRef:eU,onSearchHandler:nZ,isOpen:e0,setIsOpen:e1}))?e:(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__trigger"),n({"tags-dropdown__error":B},"".concat(x,"__trigger--with-actions"),ek)),onClick:function(e){var n=e.target;(null==n?void 0:n.tagName)==="INPUT"?e1(!0):nY(n)&&e1(function(e){return!e})},children:[W?(0,u.jsx)(g.default,{items:null==L?void 0:L.map(function(e,n){var l=null==nR?void 0:nR.find(function(n){return n.value===e});return{value:e,label:T?null==l?void 0:l.value:(null==l?void 0:l.label)||(null==l?void 0:l.name)||(null==l?void 0:l.title),id:n,className:null==l?void 0:l.labelClassName,style:null==l?void 0:l.style}}),disableShowMore:!0}):null==L?void 0:L.map(function(e){var n=null==nR?void 0:nR.find(function(n){return n.value===e}),l=T?null==n?void 0:n.value:(null==n?void 0:n.label)||(null==n?void 0:n.name)||(null==n?void 0:n.title);return(0,u.jsx)(h.default,{className:(0,a.default)(I,null==n?void 0:n.labelClassName,{"tag_with-btn":!(null==n?void 0:n.isFreezed)}),label:l,style:null==n?void 0:n.style,removeItem:(null==n?void 0:n.isFreezed)?void 0:function(){return nA(e)},isNoDismiss:!1},e)}),0!==L.length&&W?"":n8(),(0,u.jsx)("span",{className:(0,a.default)("".concat(x,"__arrow"),n({},"".concat(x,"__arrow_active"),e0)),children:eJ?(0,u.jsx)(d.Code,{className:"mobile-icon"}):e0?(0,u.jsx)(d.ChevronUp,{className:"color--text"}):(0,u.jsx)(d.ChevronDown,{className:"color--text"})})]})},[L,nR,eU,e0]);return(0,c.useLayoutEffect)(function(){return nT(),eO&&!eG&&e1(!0),function(){var e,n;null==(e=nB())||e.remove(),null==(n=document.getElementById("mlw-".concat(eQ)))||n.remove()}},[]),(0,c.useLayoutEffect)(function(){var e;return eJ?(window.removeEventListener("mousewheel",nX),window.removeEventListener("wheel",nX),window.removeEventListener("touchmove",nX),window.removeEventListener("mouseup",nV)):(window.addEventListener("mousewheel",nX),window.addEventListener("wheel",nX),window.addEventListener("touchmove",nX),window.addEventListener("mouseup",nV)),null==(e=nB())||e.addEventListener("click",nX),function(){var e;window.removeEventListener("mousewheel",nX),window.removeEventListener("mouseup",nV),window.removeEventListener("wheel",nX),window.removeEventListener("touchmove",nX),null==(e=nB())||e.removeEventListener("click",nX)}},[nB,eJ]),(0,c.useLayoutEffect)(function(){e0&&(nH(),nK())},[e0,S,L,np,eJ,null==e$||null==(j=e$.current)||null==(y=j.getBoundingClientRect())?void 0:y.height,eW]),(0,c.useEffect)(function(){eC&&L.length!==Object.keys(nI).length&&nj.map(function(e){var o;return(null==e?void 0:e.value)&&!(null==nI?void 0:nI[null==e||null==(o=e.value)?void 0:o.toString()])&&nP(function(o){var r;return e.value?t(l({},o),n({},null==e||null==(r=e.value)?void 0:r.toString(),null==e?void 0:e.label)):o}),e})},[L,eC]),(0,c.useEffect)(function(){var e,n,l,t,o,r,i,u,a=function(){e6(window.scrollY)},c=e0?"addEventListener":"removeEventListener";null==$||null==(e=$.current)||e[c]("click",n1,!0),null==J||null==(n=J.current)||n[c]("click",n2,!0),e0?(eJ&&eS||window.removeEventListener("scroll",a),(null==eq?void 0:eq.current)&&(eq.current.style.pointerEvents="none"),null==(l=nB())||l.classList.add("tags-dropdown__container--opened"),eJ?null==eU||null==(i=eU.current)||null==(r=i.blur)||r.call(i):null==eU||null==(o=eU.current)||null==(t=o.focus)||t.call(o)):(eJ&&eS||window.addEventListener("scroll",a),(null==eq?void 0:eq.current)&&(eq.current.style.pointerEvents="auto"),null==(u=nB())||u.classList.remove("tags-dropdown__container--opened"),eD&&ny(""),e9(null),nh(""))},[e0]),(0,c.useEffect)(function(){var e,n,l,t,o,r=function(e){var n;nc(Number.parseInt(null==(n=e.target.scrollTop)?void 0:n.toString(),10))},i=function(e){e.preventDefault(),window.scrollTo({top:e3})};return e0&&eJ&&(null==eX?void 0:eX.current)&&(null==eX||null==(e=eX.current)||e.addEventListener("scroll",r),nt((null==eX||null==(n=eX.current)?void 0:n.scrollHeight)>(null==eX||null==(l=eX.current)?void 0:l.clientHeight)),null===nl&&ni((null==eX||null==(t=eX.current)?void 0:t.scrollHeight)>(null==eX||null==(o=eX.current)?void 0:o.clientHeight))),e0&&eX&&eX.current&&(eX.current.addEventListener("scroll",n3),eJ&&eS||window.addEventListener("scroll",i)),function(){var e,n;eJ&&eS||window.removeEventListener("scroll",i),null==eX||null==(e=eX.current)||e.removeEventListener("scroll",n3),null==eX||null==(n=eX.current)||n.removeEventListener("scroll",r)}},[e0,eJ,null==eX?void 0:eX.current,null==eX||null==(C=eX.current)?void 0:C.scrollHeight,null==eX||null==(E=eX.current)?void 0:E.clientHeight]),(0,c.useEffect)(function(){if(null==eX?void 0:eX.current){var e,n,l;nv(Number.parseInt((e=(null==eX||null==(n=eX.current)?void 0:n.scrollHeight)-(null==eX||null==(l=eX.current)?void 0:l.clientHeight),e.toString()),10))}},[na,null==eX?void 0:eX.current]),(0,c.useEffect)(function(){ew&&ey&&(ng||n_||e0)&&(null==ex||ex(ng))},[e0,ng,n_]),(0,c.useEffect)(function(){nC(S.map(function(e){return t(l({},e),{ref:(0,c.createRef)()})}))},[S]),(0,c.useEffect)(function(){if(nO){var e,n;nK(),null==nx||null==(n=nx.current)||null==(e=n.focus)||e.call(n)}},[null==nO?void 0:nO.value]),(0,u.jsxs)("div",{className:(0,a.default)(x,D,(n(O={},"".concat(x,"_disabled"),F),n(O,"".concat(x,"-mobile"),eJ),n(O,"".concat(x,"--focused"),e0&&!(null==eq?void 0:eq.current)&&!eJ),n(O,"".concat(x,"--custom-trigger"),!!(null==eq?void 0:eq.current)),O)),ref:eV,children:[n5(),ek&&(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__actions")),children:[(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__actions-item")),onClick:eT,children:(0,u.jsx)(d.Check,{})}),(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__actions-item")),onClick:eB,children:(0,u.jsx)(d.X,{})})]}),e0&&((i=nB())?(0,s.createPortal)(function(){var e,o,r,i=null==nj?void 0:nj.reduce(function(e,n){if(n.groupName){var o,r=null==n||null==(o=n.list)?void 0:o.filter(function(e){return n$(e)});(null==r?void 0:r.length)&&e.push(t(l({},n),{list:r}))}else n$(n)&&e.push(n);return e},[]),c=[],v=!0,f=!1,m=void 0;try{for(var g,b,w,y=i[Symbol.iterator]();!(v=(w=y.next()).done);v=!0){var j,C,E,O,S=w.value;S.groupName?c.push((0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"-group"),S.className),children:[(0,u.jsx)("span",{className:"".concat(x,"-group__name"),children:S.groupName}),null==(j=S.list)?void 0:j.map(function(e){return n6(e)})]},null==(O=S.groupName)||null==(E=O.toString())?void 0:E.replace(/ /g,"_").concat(null==(C=Date.now())?void 0:C.toString()))):c.push(n6(S))}}catch(e){f=!0,m=e}finally{try{v||null==y.return||y.return()}finally{if(f)throw m}}return(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__container-wrapper")),ref:eK,onClick:eJ?n0:function(){},children:(0,u.jsxs)("div",{ref:e$,className:(0,a.default)("".concat(x,"__selector-wrapper"),n({},"".concat(x,"__selector-wrapper--fixed-height"),nr&&eJ)),children:[K||eJ?(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__header"),(n(o={},"".concat(x,"__header-with-shadow"),nl&&eJ),n(o,"".concat(x,"__header-with-shadow-hidden"),0===na),o)),children:[eJ&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__header-row")),children:[(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__label")),children:A}),(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__close-icon")),onClick:function(e){e.stopPropagation(),e1(!1)},children:(0,u.jsx)(d.X,{onClick:function(e){e.stopPropagation(),e1(!1)}})})]}),nJ()>(eM||10)&&(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__header-row")),children:(0,u.jsx)(_.default,l({className:"".concat(x,"__input"),value:np,onChange:function(e){return ny(e)},placeholder:eb||"Search",withDelete:!0,onMouseDown:function(){e0||e1(!0)}},eN))})]}),K&&(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__header-row")),children:K})]}):null,eD&&(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__input-list-wrapper")),children:n8()}),eL&&eR&&np&&i.length&&nR.every(function(e){var n=e.label;return(null==n?void 0:n.toLowerCase())!==(null==np?void 0:np.toLowerCase())})?(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__creatable-helper")),children:"Select an option or create one"}):null,(0,u.jsxs)("div",{ref:eX,className:"".concat(x,"__list ").concat(K||eJ?"".concat(x,"__list--with-header"):""," ").concat(X?"".concat(x,"__list--with-footer"):""),children:[c,(null==(g=i.filter(function(e){return"open_modal"!==e.value}))?void 0:g.length)!==0||eL&&np?null:(0,u.jsx)("div",{className:"".concat(x,"__no-options"),children:eg})]}),(X||eJ)&&(null==(b=i.filter(function(e){return"open_modal"!==e.value}))?void 0:b.length)>0?(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__footer"),(n(r={},"".concat(x,"__footer-with-shadow"),eJ&&nl),n(r,"".concat(x,"__footer-with-shadow-hidden"),na===nd),r)),children:[X,eJ&&(0,u.jsxs)("button",{type:"button",onClick:function(){return e1(!1)},children:["Apply",(null==L?void 0:L.length)?"(".concat(null==L?void 0:L.length,")"):""]})]}):null,nO&&(0,s.createPortal)((0,u.jsxs)("div",{ref:eY,className:(0,a.default)("".concat(x,"__edit-option-modal")),children:[(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__edit-option-modal-section")),children:[(0,u.jsx)(_.default,{value:nO.label,onChange:function(e){return nL(function(n){return t(l({},n),{label:e})})},error:nk,onKeyDown:function(e){13===e&&nU()},symbolsLimit:"50",ref:nx}),(0,u.jsx)(p.default,{variant:"link",icon:(0,u.jsx)(d.Trash2,{}),label:"Delete",onClick:nW})]}),(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__edit-option-modal-section-divider"))}),(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__edit-option-modal-section")),children:[(0,u.jsx)("h3",{children:"Colors"}),(0,u.jsx)("div",{className:(0,a.default)("".concat(x,"__edit-option-modal-section-colors")),children:N.map(function(e){var n;return(0,u.jsx)("div",{className:"color-block",style:{backgroundColor:e},onClick:function(){return nL(function(n){return t(l({},n),{style:t(l({},n?n.style:{}),{backgroundColor:e})})})},children:(null==nO||null==(n=nO.style)?void 0:n.backgroundColor)===e?(0,u.jsx)(d.Check,{}):null},e)})})]})]},"editOptionModal".concat(null==nO?void 0:nO.value)),null!=(e=document.getElementById("app"))?e:document.body),eL&&eR&&np&&nR.every(function(e){var n=e.label;return(null==n?void 0:n.toLowerCase())!==(null==np?void 0:np.toLowerCase())})&&(0,u.jsxs)("div",{className:(0,a.default)("".concat(x,"__create-option")),onClick:nq,children:["Create",(0,u.jsx)(h.default,{label:np,style:{backgroundColor:nM},isNoDismiss:!0})]})]})})}(),i):null)]})};