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,735 +1 @@
1
- /* 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 _useIsMobile = /*#__PURE__*/ _interop_require_default(require("../../../Functions/useIsMobile/useIsMobile"));
18
- const _utils = require("../../../Functions/utils");
19
- const _Input = /*#__PURE__*/ _interop_require_default(require("../Input/Input"));
20
- const _RadioInput = /*#__PURE__*/ _interop_require_default(require("../RadioInput/RadioInput"));
21
- const _DropdownLoader = /*#__PURE__*/ _interop_require_default(require("./components/DropdownLoader"));
22
- require("./Dropdown.scss");
23
- function _interop_require_default(obj) {
24
- return obj && obj.__esModule ? obj : {
25
- default: obj
26
- };
27
- }
28
- function _getRequireWildcardCache(nodeInterop) {
29
- if (typeof WeakMap !== "function") return null;
30
- var cacheBabelInterop = new WeakMap();
31
- var cacheNodeInterop = new WeakMap();
32
- return (_getRequireWildcardCache = function(nodeInterop) {
33
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
34
- })(nodeInterop);
35
- }
36
- function _interop_require_wildcard(obj, nodeInterop) {
37
- if (!nodeInterop && obj && obj.__esModule) {
38
- return obj;
39
- }
40
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
41
- return {
42
- default: obj
43
- };
44
- }
45
- var cache = _getRequireWildcardCache(nodeInterop);
46
- if (cache && cache.has(obj)) {
47
- return cache.get(obj);
48
- }
49
- var newObj = {
50
- __proto__: null
51
- };
52
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
53
- for(var key in obj){
54
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
55
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
56
- if (desc && (desc.get || desc.set)) {
57
- Object.defineProperty(newObj, key, desc);
58
- } else {
59
- newObj[key] = obj[key];
60
- }
61
- }
62
- }
63
- newObj.default = obj;
64
- if (cache) {
65
- cache.set(obj, newObj);
66
- }
67
- return newObj;
68
- }
69
- const RC = 'dropdown';
70
- const MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH = 10;
71
- const Dropdown = ({ label, options, value, error, disabled, onChange, placeholder, className, isSearchable, entity, scrollReactionObj, isListTop, isNotValidateASCII = false, testId = 'dropdown', sortAlphabetical = true, fieldKey, id, noOptionsText = 'No options available', attributesOfNativeInput, isDoNotPullOutListOfMainContainer, withMobileLogic, withActions, minItemsForShowMobileSearch = MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH, customTrigger, tabIndex, onActionConfirmClick, onActionCancelClick, isDefaultOpened })=>{
72
- var _options_find, _dropdownListWrapperRef_current_getBoundingClientRect, _dropdownListWrapperRef_current, _dropdownListRef_current, _dropdownListRef_current1, _filteredOptions_find, _this;
73
- const { isMobile: isMobileProp } = (0, _useIsMobile.default)();
74
- const isMobile = isMobileProp && withMobileLogic && window.screen.width <= 768;
75
- const [dropdownId] = (0, _react.useState)((id || fieldKey || Math.random().toString(16).slice(2)).toString());
76
- const [isOpen, setIsOpen] = (0, _react.useState)(false);
77
- const [searchValue, setSearchValue] = (0, _react.useState)();
78
- const dropdownRef = (0, _react.useRef)(null);
79
- const dropdownListRef = (0, _react.useRef)(null);
80
- const dropdownListWrapperRef = (0, _react.useRef)(null);
81
- const searchInputRef = (0, _react.useRef)(null);
82
- const wrapperRef = (0, _react.useRef)(null);
83
- const [initListHeight, setInitListHeight] = (0, _react.useState)(null);
84
- const [isSearchChanged, setIsSearchChanged] = (0, _react.useState)(false);
85
- const [isSearchInputFocused, setIsSearchInputFocused] = (0, _react.useState)(false);
86
- const [isScrollableList, setIsScrollableList] = (0, _react.useState)(false);
87
- const [isFixedMaxHeight, setIsFixedMaxHeight] = (0, _react.useState)(false);
88
- const [scrollTop, setScrollTop] = (0, _react.useState)(0);
89
- const [scrollHeight, setScrollHeight] = (0, _react.useState)(1);
90
- const getTotalOptions = (0, _react.useCallback)(()=>{
91
- var _options_reduce;
92
- return (_options_reduce = options === null || options === void 0 ? void 0 : options.reduce((result, item)=>{
93
- if ((item === null || item === void 0 ? void 0 : item.list) || (item === null || item === void 0 ? void 0 : item.items)) {
94
- var _item_list, _item_items;
95
- result += (item === null || item === void 0 ? void 0 : (_item_list = item.list) === null || _item_list === void 0 ? void 0 : _item_list.length) || (item === null || item === void 0 ? void 0 : (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items.length) || 0;
96
- } else {
97
- ++result;
98
- }
99
- return result;
100
- }, 0)) !== null && _options_reduce !== void 0 ? _options_reduce : 0;
101
- }, [
102
- options
103
- ]);
104
- if (isMobile) {
105
- isSearchable = getTotalOptions() > (minItemsForShowMobileSearch || MIN_ITEMS_FOR_SHOW_MOBILE_SEARCH);
106
- }
107
- const moveOtherToEnd = (options)=>{
108
- const otherIndex = options === null || options === void 0 ? void 0 : options.findIndex((option)=>(option === null || option === void 0 ? void 0 : option.value) === 'other');
109
- if (otherIndex > -1) {
110
- const other = options === null || options === void 0 ? void 0 : options.splice(otherIndex, 1);
111
- options.push(...other);
112
- }
113
- return options;
114
- };
115
- const optionsWithOtherAtTheEnd = moveOtherToEnd(options !== null && options !== void 0 ? options : []);
116
- options === null || options === void 0 ? void 0 : options.map((option)=>{
117
- if (option.items) {
118
- return option.items = moveOtherToEnd(option.items);
119
- } else {
120
- return option;
121
- }
122
- });
123
- const filteredGroups = optionsWithOtherAtTheEnd.map((item)=>{
124
- var _item_items;
125
- return {
126
- ...item,
127
- items: !isSearchable || !isSearchChanged ? item === null || item === void 0 ? void 0 : item.items : (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items.slice().filter((el)=>{
128
- var _el_label;
129
- return (el === null || el === void 0 ? void 0 : (_el_label = el.label) === null || _el_label === void 0 ? void 0 : _el_label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(el === null || el === void 0 ? void 0 : el.value) || (el === null || el === void 0 ? void 0 : el.value) === '';
130
- })
131
- };
132
- }).filter((item)=>{
133
- var _item_items;
134
- var _item_items_length;
135
- return ((_item_items_length = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items.length) !== null && _item_items_length !== void 0 ? _item_items_length : 0) > 0;
136
- });
137
- const filteredItems = optionsWithOtherAtTheEnd.filter((item)=>{
138
- var _item_items;
139
- return !((_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items.length);
140
- }).filter((item)=>{
141
- var _item_label;
142
- if (!isSearchable || !isSearchChanged) return true;
143
- return (item === null || item === void 0 ? void 0 : (_item_label = item.label) === null || _item_label === void 0 ? void 0 : _item_label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(item === null || item === void 0 ? void 0 : item.value) || (item === null || item === void 0 ? void 0 : item.value) === '';
144
- });
145
- const filteredOptions = [
146
- ...filteredItems,
147
- ...filteredGroups
148
- ];
149
- const modalBtnTrigger = entity && entity !== '' && typeof entity === 'string';
150
- const onChangeHandler = (item)=>{
151
- setIsOpen(false);
152
- onChange === null || onChange === void 0 ? void 0 : onChange(item.value);
153
- };
154
- const onKeyDown = (e)=>{
155
- if (![
156
- 9,
157
- 13
158
- ].includes(e.keyCode)) return false;
159
- setIsOpen(false);
160
- return true;
161
- };
162
- const onKeyUp = (e)=>{
163
- if (![
164
- 9,
165
- 13
166
- ].includes(e.keyCode)) return false;
167
- setIsOpen(true);
168
- return true;
169
- };
170
- const getDepends = (getDependsTrigger)=>{
171
- const newOnChange = (e)=>{
172
- if (e.value === 'open_modal') {
173
- onChange === null || onChange === void 0 ? void 0 : onChange('open_modal');
174
- } else {
175
- onChangeHandler(e);
176
- }
177
- };
178
- // add pseudo option
179
- const newOptions = [
180
- {
181
- label: `New ${entity}`,
182
- value: 'open_modal',
183
- className: 'dropdown__list-item--modal'
184
- },
185
- ...filteredOptions !== null && filteredOptions !== void 0 ? filteredOptions : []
186
- ];
187
- return {
188
- onChange: (changeItem)=>{
189
- return getDependsTrigger ? newOnChange(changeItem) : onChangeHandler(changeItem);
190
- },
191
- options: getDependsTrigger ? newOptions : options
192
- };
193
- };
194
- const getListContainer = ()=>{
195
- return document.getElementById(dropdownId);
196
- };
197
- const handleClickOutside = (event)=>{
198
- var _getListContainer;
199
- if (!((_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.contains(event === null || event === void 0 ? void 0 : event.target)) && (dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current) !== null && !(dropdownRef === null || dropdownRef === void 0 ? void 0 : dropdownRef.current.contains(event === null || event === void 0 ? void 0 : event.target))) {
200
- setIsOpen(false);
201
- }
202
- };
203
- const onSearchHandler = (name)=>{
204
- let inputValue = name;
205
- if (!isNotValidateASCII) inputValue = (0, _fieldValueFormatters.formatToOnlyASCIICodeText)(inputValue);
206
- setIsSearchChanged(true);
207
- setSearchValue(inputValue);
208
- };
209
- const onWrapperClick = (e)=>{
210
- if (e.target === (wrapperRef === null || wrapperRef === void 0 ? void 0 : wrapperRef.current)) {
211
- e.stopPropagation();
212
- e.preventDefault();
213
- setIsOpen(false);
214
- }
215
- };
216
- const hightlightedText = (text, postfix, description)=>{
217
- const prepare = (text)=>text === null || text === void 0 ? void 0 : text.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
218
- text = text.replace(/["&<>]/g, (a)=>{
219
- var _a;
220
- return (_a = ({
221
- '"': '&quot;',
222
- '&': '&amp;',
223
- '<': '&lt;',
224
- '>': '&gt;'
225
- })[a]) !== null && _a !== void 0 ? _a : '';
226
- });
227
- const main = isSearchable && searchValue ? text === null || text === void 0 ? void 0 : text.replace(// eslint-disable-next-line security/detect-non-literal-regexp
228
- new RegExp(prepare(searchValue), 'i'), (match)=>`<span class="bg--yellow">${match}</span>`) : text;
229
- const postfixPart = postfix ? `<span class="dropdown__list-item-postfix">${postfix}</span>` : '';
230
- const descriptionPart = description ? `<span class="dropdown__list-item-description">${description}</span>` : '';
231
- return main + postfixPart + descriptionPart;
232
- };
233
- const depend = getDepends(modalBtnTrigger);
234
- const getMarkupForElement = (item, _index, optTestId)=>{
235
- var _item_value_toString, _item_value;
236
- var _item_customMobileIcon;
237
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("button", {
238
- type: "button",
239
- "data-testid": `${testId}-${optTestId}-option`,
240
- onMouseDown: ()=>depend.onChange(item),
241
- className: (0, _classnames.default)(`${RC}__list-item`, {
242
- [`${RC}__list-item_active`]: item.value === value,
243
- [`${RC}__list-item_disabled`]: item.disabled
244
- }, item.className),
245
- children: [
246
- !isMobile && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
247
- className: (0, _classnames.default)(`${RC}__active-icon`, {
248
- [`${RC}__active-icon_active`]: item.value === value
249
- }),
250
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Check, {})
251
- }),
252
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
253
- className: (0, _classnames.default)(`${RC}__list-item-label`, item.labelClassName || ''),
254
- // eslint-disable-next-line react-dom/no-dangerously-set-innerhtml
255
- dangerouslySetInnerHTML: {
256
- __html: hightlightedText(item.label, item.postfix, item.description)
257
- }
258
- }),
259
- (item === null || item === void 0 ? void 0 : item.icon) || '',
260
- isMobile ? (_item_customMobileIcon = item === null || item === void 0 ? void 0 : item.customMobileIcon) !== null && _item_customMobileIcon !== void 0 ? _item_customMobileIcon : /*#__PURE__*/ (0, _jsxruntime.jsx)(_RadioInput.default, {
261
- value: item.value,
262
- checked: value === null || value === void 0 ? void 0 : value.toString()
263
- }) : ''
264
- ]
265
- }, (_item_value = item.value) === null || _item_value === void 0 ? void 0 : (_item_value_toString = _item_value.toString()) === null || _item_value_toString === void 0 ? void 0 : _item_value_toString.replace(/ /g, '_'));
266
- };
267
- const filteredOptionList = (filteredOption)=>{
268
- var _filteredOption_items, _filteredOption_items1, _Date_now, _filteredOption_label_toString, _filteredOption_label;
269
- var _filteredOption_items_length;
270
- return ((_filteredOption_items_length = (_filteredOption_items = filteredOption.items) === null || _filteredOption_items === void 0 ? void 0 : _filteredOption_items.length) !== null && _filteredOption_items_length !== void 0 ? _filteredOption_items_length : 0) > 0 ? /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
271
- className: (0, _classnames.default)(`${RC}-group`, filteredOption.className),
272
- children: [
273
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
274
- className: `${RC}-group__name`,
275
- children: filteredOption.label
276
- }),
277
- (_filteredOption_items1 = filteredOption.items) === null || _filteredOption_items1 === void 0 ? void 0 : _filteredOption_items1.map((el, index)=>{
278
- var _this;
279
- return getMarkupForElement(el, index, (_this = (el === null || el === void 0 ? void 0 : el.testId) || index) === null || _this === void 0 ? void 0 : _this.toString());
280
- })
281
- ]
282
- }, (_filteredOption_label = filteredOption.label) === null || _filteredOption_label === void 0 ? void 0 : (_filteredOption_label_toString = _filteredOption_label.toString()) === null || _filteredOption_label_toString === void 0 ? void 0 : _filteredOption_label_toString.replace(/ /g, '_').concat((_Date_now = Date.now()) === null || _Date_now === void 0 ? void 0 : _Date_now.toString())) : null;
283
- };
284
- var _options_find_label;
285
- const selectedLabel = (_options_find_label = options === null || options === void 0 ? void 0 : (_options_find = options.find((el)=>el.value === value)) === null || _options_find === void 0 ? void 0 : _options_find.label) !== null && _options_find_label !== void 0 ? _options_find_label : options === null || options === void 0 ? void 0 : options.reduce((acc, item)=>{
286
- var _item_items_find, _item_items;
287
- var _item_items_find_label;
288
- if (!(acc === null || acc === void 0 ? void 0 : acc.length)) return (_item_items_find_label = (_item_items = item.items) === null || _item_items === void 0 ? void 0 : (_item_items_find = _item_items.find((el)=>el.value === value)) === null || _item_items_find === void 0 ? void 0 : _item_items_find.label) !== null && _item_items_find_label !== void 0 ? _item_items_find_label : '';
289
- return acc;
290
- }, '');
291
- const doScrollCallback = (0, _react.useCallback)((e)=>{
292
- const { callback, isWithAnyScrolling, scrollingInaccuracy = 0 } = scrollReactionObj || {};
293
- const target = e === null || e === void 0 ? void 0 : e.target;
294
- if (callback && typeof callback === 'function') {
295
- if (isWithAnyScrolling) {
296
- callback(e);
297
- } else if (Math.round(target.clientHeight + target.scrollTop + scrollingInaccuracy) >= target.scrollHeight) {
298
- callback(e);
299
- }
300
- }
301
- }, [
302
- filteredOptions
303
- ]);
304
- const getParentNode = ()=>{
305
- if (isDoNotPullOutListOfMainContainer) return dropdownRef.current;
306
- var _document_querySelector, _ref;
307
- 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');
308
- };
309
- const initListContainer = ()=>{
310
- const dropdownList = document.createElement('div');
311
- dropdownList.setAttribute('id', dropdownId);
312
- dropdownList.classList.add('dropdown__container');
313
- if (isMobile) {
314
- dropdownList.addEventListener('click', (e)=>{
315
- const { id } = e === null || e === void 0 ? void 0 : e.target;
316
- if (id === dropdownId) setIsOpen(false);
317
- });
318
- }
319
- try {
320
- var _getListContainer;
321
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.remove();
322
- } finally{
323
- if (isMobile) {
324
- var _getParentNode;
325
- try {
326
- var _document_getElementById;
327
- (_document_getElementById = document.getElementById(`mlw-${dropdownId}`)) === null || _document_getElementById === void 0 ? void 0 : _document_getElementById.remove();
328
- } catch (e) {}
329
- const dropdownMobileListWrapper = document.createElement('div');
330
- dropdownMobileListWrapper.classList.add('dropdown-mobile');
331
- dropdownMobileListWrapper.setAttribute('id', `mlw-${dropdownId}`);
332
- dropdownMobileListWrapper === null || dropdownMobileListWrapper === void 0 ? void 0 : dropdownMobileListWrapper.append(dropdownList);
333
- (_getParentNode = getParentNode()) === null || _getParentNode === void 0 ? void 0 : _getParentNode.append(dropdownMobileListWrapper);
334
- } else {
335
- var _getParentNode1;
336
- (_getParentNode1 = getParentNode()) === null || _getParentNode1 === void 0 ? void 0 : _getParentNode1.append(dropdownList);
337
- }
338
- }
339
- };
340
- const getListContainerWrapper = ()=>{
341
- return document.getElementById(`mlw-${dropdownId}`);
342
- };
343
- const setListContainerStyles = ()=>{
344
- var _dropdownRef_current, _dropdownListWrapperRef_current, _getComputedStyle_marginTop, _getComputedStyle, _getComputedStyle_maxHeight, _getComputedStyle1, _sw_getBoundingClientRect, _dropdownListWrapperRef_current_getBoundingClientRect, _dropdownListWrapperRef_current1, _lh_getBoundingClientRect, _getComputedStyle_height, _getComputedStyle2;
345
- const lc = getListContainer();
346
- if (!lc || !isOpen) return false;
347
- const windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
348
- var _dropdownRef_current_getBoundingClientRect;
349
- 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 : {};
350
- const sw = lc.getElementsByClassName('dropdown__list')[0];
351
- const lh = dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperRef_current = dropdownListWrapperRef.current) === null || _dropdownListWrapperRef_current === void 0 ? void 0 : _dropdownListWrapperRef_current.getElementsByClassName('dropdown__list-header')[0];
352
- var _getComputedStyle_marginTop_replace;
353
- const margin = Number.parseInt((_getComputedStyle_marginTop_replace = (_getComputedStyle = getComputedStyle(dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : dropdownListWrapperRef.current)) === 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);
354
- var _getComputedStyle_maxHeight_replace;
355
- const maxHeight = initListHeight !== null && initListHeight !== void 0 ? initListHeight : Number.parseInt((_getComputedStyle_maxHeight_replace = (_getComputedStyle1 = getComputedStyle(sw)) === null || _getComputedStyle1 === void 0 ? void 0 : (_getComputedStyle_maxHeight = _getComputedStyle1.maxHeight) === null || _getComputedStyle_maxHeight === void 0 ? void 0 : _getComputedStyle_maxHeight.replace('px', '')) !== null && _getComputedStyle_maxHeight_replace !== void 0 ? _getComputedStyle_maxHeight_replace : 0, 10);
356
- if (initListHeight === null) setInitListHeight(maxHeight);
357
- const toTop = top - margin;
358
- const toBottom = windowHeight - top - height - margin * 2;
359
- const swHeight = sw === null || sw === void 0 ? void 0 : (_sw_getBoundingClientRect = sw.getBoundingClientRect()) === null || _sw_getBoundingClientRect === void 0 ? void 0 : _sw_getBoundingClientRect.height;
360
- const maxSwHeight = isMobile ? (dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : (_dropdownListWrapperRef_current1 = dropdownListWrapperRef.current) === null || _dropdownListWrapperRef_current1 === void 0 ? void 0 : (_dropdownListWrapperRef_current_getBoundingClientRect = _dropdownListWrapperRef_current1.getBoundingClientRect()) === null || _dropdownListWrapperRef_current_getBoundingClientRect === void 0 ? void 0 : _dropdownListWrapperRef_current_getBoundingClientRect.height) - (lh === null || lh === void 0 ? void 0 : (_lh_getBoundingClientRect = lh.getBoundingClientRect()) === null || _lh_getBoundingClientRect === void 0 ? void 0 : _lh_getBoundingClientRect.height) : toTop >= maxHeight || toBottom >= maxHeight ? maxHeight - 3 * margin : toTop > toBottom ? toTop - 3 * margin : toBottom - 4 * margin;
361
- const listPos = toTop < toBottom || toBottom >= swHeight ? 'bottom' : 'top';
362
- lc.style.minWidth = `${width}px`;
363
- lc.style.left = `${left}px`;
364
- var _getComputedStyle_height_replace;
365
- lc.style.top = `${listPos === 'bottom' ? top + height : top - margin * 3 - Number.parseInt((_getComputedStyle_height_replace = (_getComputedStyle2 = getComputedStyle(dropdownListWrapperRef === null || dropdownListWrapperRef === void 0 ? void 0 : dropdownListWrapperRef.current)) === null || _getComputedStyle2 === void 0 ? void 0 : (_getComputedStyle_height = _getComputedStyle2.height) === null || _getComputedStyle_height === void 0 ? void 0 : _getComputedStyle_height.replace('px', '')) !== null && _getComputedStyle_height_replace !== void 0 ? _getComputedStyle_height_replace : 0, 10)}px`;
366
- sw.style.maxHeight = `${maxSwHeight}px`;
367
- return true;
368
- };
369
- const renderListContainer = ()=>{
370
- const lc = getListContainer();
371
- if (!lc) return null;
372
- // eslint-disable-next-line ts/no-use-before-define
373
- return /*#__PURE__*/ (0, _reactdom.createPortal)(getListMarkUp(), lc);
374
- };
375
- const getSortedOptions = (data)=>{
376
- let newData = [
377
- ...data
378
- ];
379
- if (sortAlphabetical) {
380
- const openModalOption = newData.filter(({ value })=>value === 'open_modal');
381
- const emptyOption = newData.filter(({ value })=>value === '');
382
- const restOfOptions = newData.filter(({ value })=>value !== 'open_modal' && value !== '').sort(_utils.compareAlphabetical);
383
- newData = [
384
- ...openModalOption,
385
- ...emptyOption,
386
- ...restOfOptions
387
- ].map((item)=>{
388
- if (item === null || item === void 0 ? void 0 : item.items) {
389
- item.items = [
390
- ...item.items
391
- ].sort(_utils.compareAlphabetical);
392
- }
393
- return item;
394
- });
395
- }
396
- return newData;
397
- };
398
- const getListMarkUp = ()=>{
399
- var _getSortedOptions;
400
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
401
- "data-testid": `${testId}-container-wrapper`,
402
- className: (0, _classnames.default)(`${RC}__container-wrapper`),
403
- ref: wrapperRef,
404
- onClick: isMobile ? onWrapperClick : ()=>{},
405
- children: /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
406
- className: (0, _classnames.default)(`${RC}__list-wrapper`, {
407
- [`${RC}__list-wrapper--fixed-height`]: isFixedMaxHeight,
408
- [`${RC}__list-wrapper--with-bottom-shadow`]: isScrollableList && isMobile,
409
- [`${RC}__list-wrapper--with-bottom-shadow-hidden`]: scrollTop === scrollHeight
410
- }),
411
- ref: dropdownListWrapperRef,
412
- children: [
413
- isMobile && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
414
- className: (0, _classnames.default)(`${RC}__list-header`, {
415
- [`${RC}__list-header-with-shadow`]: isScrollableList && isMobile,
416
- [`${RC}__list-header-with-shadow-hidden`]: scrollTop === 0
417
- }),
418
- children: [
419
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
420
- className: (0, _classnames.default)(`${RC}__list-header-row`),
421
- children: [
422
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
423
- className: (0, _classnames.default)(`${RC}__list-label`),
424
- children: label
425
- }),
426
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
427
- className: (0, _classnames.default)(`${RC}__list-close-icon`),
428
- onClick: ()=>setIsOpen(false),
429
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.X, {
430
- onClick: ()=>setIsOpen(false)
431
- })
432
- })
433
- ]
434
- }),
435
- isSearchable && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
436
- className: (0, _classnames.default)(`${RC}__list-header-row`),
437
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_Input.default, {
438
- ref: searchInputRef,
439
- // TODO: Remove after make "Input" component typisation
440
- // @ts-ignore
441
- className: `${RC}__input`,
442
- value: searchValue !== null && searchValue !== void 0 ? searchValue : selectedLabel,
443
- onChange: onSearchHandler,
444
- placeholder: placeholder || 'Search',
445
- // TODO: Remove after make "Input" component typisation
446
- // @ts-ignore
447
- withDelete: true,
448
- onFocus: ()=>setIsSearchInputFocused(true),
449
- onBlur: ()=>setIsSearchInputFocused(false),
450
- onMouseDown: ()=>{
451
- if (!isOpen) {
452
- setIsSearchInputFocused(true);
453
- }
454
- },
455
- ...attributesOfNativeInput
456
- })
457
- })
458
- ]
459
- }),
460
- /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
461
- className: (0, _classnames.default)(`${RC}__list`, {
462
- [`${RC}__list-top`]: isListTop
463
- }),
464
- ref: dropdownListRef,
465
- children: [
466
- depend.options && ((_getSortedOptions = getSortedOptions(depend.options)) === null || _getSortedOptions === void 0 ? void 0 : _getSortedOptions.map((option, index)=>{
467
- var _option_items, _option_label;
468
- if (option === null || option === void 0 ? void 0 : (_option_items = option.items) === null || _option_items === void 0 ? void 0 : _option_items.length) {
469
- if (!isSearchable || !isSearchChanged) {
470
- return filteredOptionList(option);
471
- } else {
472
- var _option_items1;
473
- const items = (_option_items1 = option.items) === null || _option_items1 === void 0 ? void 0 : _option_items1.slice().filter((el)=>{
474
- var _el_label;
475
- return (el === null || el === void 0 ? void 0 : (_el_label = el.label) === null || _el_label === void 0 ? void 0 : _el_label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(el === null || el === void 0 ? void 0 : el.value) || (el === null || el === void 0 ? void 0 : el.value) === '';
476
- });
477
- if (items === null || items === void 0 ? void 0 : items.length) return filteredOptionList({
478
- ...option,
479
- items
480
- });
481
- return null;
482
- }
483
- } else if (!isSearchable || !isSearchChanged || (option === null || option === void 0 ? void 0 : (_option_label = option.label) === null || _option_label === void 0 ? void 0 : _option_label.toLowerCase().includes((searchValue === null || searchValue === void 0 ? void 0 : searchValue.toLowerCase()) || '')) || !(option === null || option === void 0 ? void 0 : option.value) || (option === null || option === void 0 ? void 0 : option.value) === '') {
484
- var _this;
485
- return getMarkupForElement(option, index, (_this = (option === null || option === void 0 ? void 0 : option.testId) || index) === null || _this === void 0 ? void 0 : _this.toString());
486
- }
487
- return null;
488
- })),
489
- !filteredItems.length && !filteredGroups.length && /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
490
- className: `${RC}__list-item ${RC}__list-item--no-options`,
491
- children: noOptionsText
492
- }),
493
- disabled && isOpen && /*#__PURE__*/ (0, _jsxruntime.jsx)(_DropdownLoader.default, {})
494
- ]
495
- })
496
- ]
497
- })
498
- });
499
- };
500
- const toggleList = (e)=>{
501
- e === null || e === void 0 ? void 0 : e.stopPropagation();
502
- setIsOpen((isOpen)=>{
503
- return !isOpen;
504
- });
505
- };
506
- const closeList = isOpen ? handleClickOutside : ()=>{};
507
- (0, _react.useEffect)(()=>{
508
- if (!isDoNotPullOutListOfMainContainer || dropdownRef.current) {
509
- initListContainer();
510
- if (isDefaultOpened && !isMobileProp) setIsOpen(true);
511
- }
512
- }, [
513
- isDoNotPullOutListOfMainContainer,
514
- dropdownRef.current
515
- ]);
516
- (0, _react.useLayoutEffect)(()=>{
517
- var _getListContainer;
518
- if (!isMobile) {
519
- window.addEventListener('resize', setListContainerStyles);
520
- window.addEventListener('mousewheel', closeList);
521
- window.addEventListener('scroll', closeList);
522
- window.addEventListener('touchmove', closeList);
523
- } else {
524
- window.removeEventListener('resize', setListContainerStyles);
525
- window.removeEventListener('mousewheel', closeList);
526
- window.removeEventListener('scroll', closeList);
527
- window.removeEventListener('touchmove', closeList);
528
- }
529
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.addEventListener('click', closeList);
530
- return ()=>{
531
- var _getListContainer;
532
- window.removeEventListener('resize', setListContainerStyles);
533
- window.removeEventListener('mousewheel', closeList);
534
- window.removeEventListener('scroll', closeList);
535
- window.removeEventListener('touchmove', closeList);
536
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.removeEventListener('click', closeList);
537
- };
538
- }, [
539
- getListContainer
540
- ]);
541
- (0, _react.useLayoutEffect)(()=>{
542
- setListContainerStyles();
543
- }, [
544
- isOpen,
545
- searchValue,
546
- isMobile,
547
- options,
548
- 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
549
- ]);
550
- (0, _react.useEffect)(()=>{
551
- document.addEventListener('click', handleClickOutside, true);
552
- return ()=>document.removeEventListener('click', handleClickOutside, true);
553
- }, []);
554
- (0, _react.useEffect)(()=>{
555
- if (!isOpen) {
556
- setIsSearchChanged(false);
557
- }
558
- if (scrollReactionObj && typeof scrollReactionObj === 'object' && isOpen && dropdownListRef && dropdownListRef.current) {
559
- dropdownListRef.current.addEventListener('scroll', doScrollCallback);
560
- }
561
- return ()=>{
562
- if (scrollReactionObj && typeof scrollReactionObj === 'object') removeEventListener('scroll', doScrollCallback);
563
- };
564
- }, [
565
- isOpen,
566
- dropdownListRef
567
- ]);
568
- (0, _react.useEffect)(()=>{
569
- let timeout;
570
- if (!searchValue && isSearchInputFocused) {
571
- setSearchValue(selectedLabel);
572
- timeout = setTimeout(()=>searchInputRef.current.select(), 1);
573
- }
574
- if (!isSearchInputFocused && !isOpen) {
575
- setSearchValue(null);
576
- }
577
- return ()=>{
578
- clearTimeout(timeout);
579
- };
580
- }, [
581
- isSearchInputFocused
582
- ]);
583
- (0, _react.useEffect)(()=>{
584
- var _searchInputRef_current;
585
- if (isOpen && !isSearchInputFocused && (searchInputRef === null || searchInputRef === void 0 ? void 0 : searchInputRef.current) && !isMobile) (_searchInputRef_current = searchInputRef.current) === null || _searchInputRef_current === void 0 ? void 0 : _searchInputRef_current.focus();
586
- if (isOpen) {
587
- var _getListContainer;
588
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.classList.add('dropdown__container--opened');
589
- } else {
590
- var _searchInputRef_current1, _getListContainer1;
591
- (_searchInputRef_current1 = searchInputRef.current) === null || _searchInputRef_current1 === void 0 ? void 0 : _searchInputRef_current1.blur();
592
- (_getListContainer1 = getListContainer()) === null || _getListContainer1 === void 0 ? void 0 : _getListContainer1.classList.remove('dropdown__container--opened');
593
- }
594
- if (!isOpen && isMobile) {
595
- setSearchValue(null);
596
- }
597
- }, [
598
- isOpen
599
- ]);
600
- (0, _react.useEffect)(()=>{
601
- if (isOpen && isMobile && (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current) && !searchValue) {
602
- var _dropdownListRef_current, _dropdownListRef_current1, _dropdownListRef_current2, _dropdownListRef_current3;
603
- setIsScrollableList((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));
604
- setIsFixedMaxHeight(isScrollableList || (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current2 = dropdownListRef.current) === null || _dropdownListRef_current2 === void 0 ? void 0 : _dropdownListRef_current2.scrollHeight) > (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current3 = dropdownListRef.current) === null || _dropdownListRef_current3 === void 0 ? void 0 : _dropdownListRef_current3.clientHeight));
605
- }
606
- }, [
607
- isOpen,
608
- isMobile,
609
- isScrollableList,
610
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current,
611
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current = dropdownListRef.current) === null || _dropdownListRef_current === void 0 ? void 0 : _dropdownListRef_current.scrollHeight,
612
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current1 = dropdownListRef.current) === null || _dropdownListRef_current1 === void 0 ? void 0 : _dropdownListRef_current1.clientHeight
613
- ]);
614
- (0, _react.useEffect)(()=>{
615
- const setScrollTopValue = (e)=>{
616
- var _e_target_scrollTop, _e_target;
617
- setScrollTop(Number.parseInt(e === null || e === void 0 ? void 0 : (_e_target = e.target) === null || _e_target === void 0 ? void 0 : (_e_target_scrollTop = _e_target.scrollTop) === null || _e_target_scrollTop === void 0 ? void 0 : _e_target_scrollTop.toString(), 10));
618
- };
619
- if (isOpen && isMobile && (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current)) {
620
- var _dropdownListRef_current;
621
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current = dropdownListRef.current) === null || _dropdownListRef_current === void 0 ? void 0 : _dropdownListRef_current.addEventListener('scroll', setScrollTopValue);
622
- }
623
- return ()=>{
624
- if ((dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current) !== null) {
625
- var _dropdownListRef_current;
626
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : (_dropdownListRef_current = dropdownListRef.current) === null || _dropdownListRef_current === void 0 ? void 0 : _dropdownListRef_current.removeEventListener('scroll', setScrollTopValue);
627
- }
628
- };
629
- }, [
630
- isOpen,
631
- isMobile,
632
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current
633
- ]);
634
- (0, _react.useEffect)(()=>{
635
- if (dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current) {
636
- var _dropdownListRef_current, _dropdownListRef_current1;
637
- setScrollHeight(Number.parseInt(((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)).toString(), 10));
638
- }
639
- }, [
640
- scrollTop,
641
- dropdownListRef === null || dropdownListRef === void 0 ? void 0 : dropdownListRef.current
642
- ]);
643
- (0, _react.useEffect)(()=>{
644
- return ()=>{
645
- var _getListContainer, _getListContainerWrapper;
646
- (_getListContainer = getListContainer()) === null || _getListContainer === void 0 ? void 0 : _getListContainer.remove();
647
- (_getListContainerWrapper = getListContainerWrapper()) === null || _getListContainerWrapper === void 0 ? void 0 : _getListContainerWrapper.remove();
648
- };
649
- }, []);
650
- const postfixText = selectedLabel && ((_filteredOptions_find = filteredOptions.find((option)=>option.value === value)) === null || _filteredOptions_find === void 0 ? void 0 : _filteredOptions_find.postfix) || null;
651
- if (!options) return null;
652
- return /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
653
- className: (0, _classnames.default)(RC, className, {
654
- disabled,
655
- [`${RC}-mobile`]: isMobile,
656
- [`${RC}--focused`]: isOpen && !isMobile,
657
- [`${RC}--with-custom-trigger`]: Boolean(customTrigger)
658
- }),
659
- ref: dropdownRef,
660
- onKeyDown: onKeyDown,
661
- onKeyUp: onKeyUp,
662
- children: [
663
- /*#__PURE__*/ (0, _jsxruntime.jsx)("button", {
664
- type: "button",
665
- "data-testid": testId,
666
- className: (0, _classnames.default)(`${RC}__trigger`, 'input__wrap', {
667
- [`${RC}__trigger--with-actions`]: withActions,
668
- placeholder: !value,
669
- error
670
- }),
671
- onClick: ()=>setIsOpen(true),
672
- onKeyDown: onKeyDown,
673
- onKeyUp: onKeyUp,
674
- tabIndex: tabIndex,
675
- children: customTrigger || /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
676
- children: [
677
- isSearchable && !isMobile ? /*#__PURE__*/ (0, _jsxruntime.jsx)("input", {
678
- ref: searchInputRef,
679
- className: `${RC}__input`,
680
- value: (_this = isOpen ? searchValue !== null && searchValue !== void 0 ? searchValue : '' : selectedLabel !== null && selectedLabel !== void 0 ? selectedLabel : '') === null || _this === void 0 ? void 0 : _this.toString(),
681
- onChange: (e)=>onSearchHandler(e.target.value),
682
- placeholder: placeholder,
683
- onFocus: ()=>setIsSearchInputFocused(true),
684
- onBlur: ()=>setIsSearchInputFocused(false),
685
- onMouseDown: ()=>{
686
- if (!isOpen) {
687
- setIsSearchInputFocused(true);
688
- }
689
- },
690
- ...attributesOfNativeInput,
691
- tabIndex: -1
692
- }) : /*#__PURE__*/ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
693
- children: [
694
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
695
- className: "text",
696
- children: selectedLabel || placeholder || ''
697
- }),
698
- postfixText && /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
699
- className: "dropdown__list-item-postfix",
700
- children: postfixText
701
- })
702
- ]
703
- }),
704
- /*#__PURE__*/ (0, _jsxruntime.jsx)("span", {
705
- className: (0, _classnames.default)(`${RC}__arrow`, {
706
- [`${RC}__arrow_active`]: isOpen
707
- }),
708
- onClick: toggleList,
709
- children: isMobile ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Code, {
710
- className: "mobile-icon"
711
- }) : isOpen ? /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.ChevronUp, {}) : /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.ChevronDown, {})
712
- })
713
- ]
714
- })
715
- }),
716
- withActions && /*#__PURE__*/ (0, _jsxruntime.jsxs)("div", {
717
- className: (0, _classnames.default)(`${RC}__actions`),
718
- children: [
719
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
720
- className: (0, _classnames.default)(`${RC}__actions-item`),
721
- onClick: onActionConfirmClick,
722
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.Check, {})
723
- }),
724
- /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
725
- className: (0, _classnames.default)(`${RC}__actions-item`),
726
- onClick: onActionCancelClick,
727
- children: /*#__PURE__*/ (0, _jsxruntime.jsx)(_reactfeather.X, {})
728
- })
729
- ]
730
- }),
731
- isOpen && renderListContainer()
732
- ]
733
- });
734
- };
735
- const _default = Dropdown;
1
+ function e(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,l=Array(n);t<n;t++)l[t]=e[t];return l}function n(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function t(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{},r=Object.keys(l);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(l).filter(function(e){return Object.getOwnPropertyDescriptor(l,e).enumerable}))),r.forEach(function(t){n(e,t,l[t])})}return e}function l(e,n){return n=null!=n?n:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):(function(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);t.push.apply(t,l)}return t})(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}),e}function r(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t,l,r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),!n||o.length!==n);i=!0);}catch(e){u=!0,l=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw l}}return o}}(e,n)||u(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 o(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)||u(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(e){return e&&"undefined"!=typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}function u(n,t){if(n){if("string"==typeof n)return e(n,t);var l=Object.prototype.toString.call(n).slice(8,-1);if("Object"===l&&n.constructor&&(l=n.constructor.name),"Map"===l||"Set"===l)return Array.from(l);if("Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l))return e(n,t)}}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return j}});var c=require("react/jsx-runtime"),a=w(require("classnames")),s=function(e,n){if(e&&e.__esModule)return e;if(null===e||(void 0===e?"undefined":i(e))!=="object"&&"function"!=typeof e)return{default:e};var t=_(n);if(t&&t.has(e))return t.get(e);var l={__proto__:null},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if("default"!==o&&Object.prototype.hasOwnProperty.call(e,o)){var u=r?Object.getOwnPropertyDescriptor(e,o):null;u&&(u.get||u.set)?Object.defineProperty(l,o,u):l[o]=e[o]}return l.default=e,t&&t.set(e,l),l}(require("react")),d=require("react-dom"),v=require("react-feather"),f=require("../../../Functions/fieldValueFormatters"),p=w(require("../../../Functions/useIsMobile/useIsMobile")),m=require("../../../Functions/utils"),h=w(require("../Input/Input")),g=w(require("../RadioInput/RadioInput")),b=w(require("./components/DropdownLoader"));function w(e){return e&&e.__esModule?e:{default:e}}function _(e){if("function"!=typeof WeakMap)return null;var n=new WeakMap,t=new WeakMap;return(_=function(e){return e?t:n})(e)}require("./Dropdown.scss");var y="dropdown",j=function(e){var u,w,_,j,x,C,S,E,N,O,L,I,k,P,A,M,D,q=e.label,H=e.options,R=e.value,T=e.error,B=e.disabled,F=e.onChange,K=e.placeholder,W=e.className,U=e.isSearchable,z=e.entity,$=e.scrollReactionObj,V=e.isListTop,X=e.isNotValidateASCII,G=void 0!==X&&X,J=e.testId,Q=void 0===J?"dropdown":J,Y=e.sortAlphabetical,Z=void 0===Y||Y,ee=e.fieldKey,en=e.id,et=e.noOptionsText,el=void 0===et?"No options available":et,er=e.attributesOfNativeInput,eo=e.isDoNotPullOutListOfMainContainer,ei=e.withMobileLogic,eu=e.withActions,ec=e.minItemsForShowMobileSearch,ea=e.customTrigger,es=e.tabIndex,ed=e.onActionConfirmClick,ev=e.onActionCancelClick,ef=e.isDefaultOpened,ep=(0,p.default)().isMobile,em=ep&&ei&&window.screen.width<=768,eh=r((0,s.useState)((en||ee||Math.random().toString(16).slice(2)).toString()),1)[0],eg=r((0,s.useState)(!1),2),eb=eg[0],ew=eg[1],e_=r((0,s.useState)(),2),ey=e_[0],ej=e_[1],ex=(0,s.useRef)(null),eC=(0,s.useRef)(null),eS=(0,s.useRef)(null),eE=(0,s.useRef)(null),eN=(0,s.useRef)(null),eO=r((0,s.useState)(null),2),eL=eO[0],eI=eO[1],ek=r((0,s.useState)(!1),2),eP=ek[0],eA=ek[1],eM=r((0,s.useState)(!1),2),eD=eM[0],eq=eM[1],eH=r((0,s.useState)(!1),2),eR=eH[0],eT=eH[1],eB=r((0,s.useState)(!1),2),eF=eB[0],eK=eB[1],eW=r((0,s.useState)(0),2),eU=eW[0],ez=eW[1],e$=r((0,s.useState)(1),2),eV=e$[0],eX=e$[1],eG=(0,s.useCallback)(function(){var e;return null!=(e=null==H?void 0:H.reduce(function(e,n){if((null==n?void 0:n.list)||(null==n?void 0:n.items)){var t,l;e+=(null==n||null==(t=n.list)?void 0:t.length)||(null==n||null==(l=n.items)?void 0:l.length)||0}else++e;return e},0))?e:0},[H]);em&&(U=eG()>((void 0===ec?10:ec)||10));var eJ=function(e){var n=null==e?void 0:e.findIndex(function(e){return(null==e?void 0:e.value)==="other"});if(n>-1){var t=null==e?void 0:e.splice(n,1);e.push.apply(e,o(t))}return e},eQ=eJ(null!=H?H:[]);null==H||H.map(function(e){return e.items?e.items=eJ(e.items):e});var eY=eQ.map(function(e){var n;return l(t({},e),{items:U&&eP?null==(n=e.items)?void 0:n.slice().filter(function(e){var n;return(null==e||null==(n=e.label)?void 0:n.toLowerCase().includes((null==ey?void 0:ey.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)===""}):null==e?void 0:e.items})}).filter(function(e){var n,t;return(null!=(t=null==(n=e.items)?void 0:n.length)?t:0)>0}),eZ=eQ.filter(function(e){var n;return!(null==(n=e.items)?void 0:n.length)}).filter(function(e){var n;return!U||!eP||(null==e||null==(n=e.label)?void 0:n.toLowerCase().includes((null==ey?void 0:ey.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)===""}),e0=o(eZ).concat(o(eY)),e1=function(e){ew(!1),null==F||F(e.value)},e2=function(e){return!![9,13].includes(e.keyCode)&&(ew(!1),!0)},e3=function(e){return!![9,13].includes(e.keyCode)&&(ew(!0),!0)},e6=function(){return document.getElementById(eh)},e8=function(e){var n;(null==(n=e6())?void 0:n.contains(null==e?void 0:e.target))||(null==ex?void 0:ex.current)===null||(null==ex?void 0:ex.current.contains(null==e?void 0:e.target))||ew(!1)},e9=function(e){var n=e;G||(n=(0,f.formatToOnlyASCIICodeText)(n)),eA(!0),ej(n)},e4=function(e){e.target===(null==eN?void 0:eN.current)&&(e.stopPropagation(),e.preventDefault(),ew(!1))},e7=function(e,n,t){return e=null==e?void 0:e.replace(/["&<>]/g,function(e){var n;return null!=(n=({'"':"&quot;","&":"&amp;","<":"&lt;",">":"&gt;"})[e])?n:""}),(U&&ey?null==e?void 0:e.replace(RegExp(null==ey?void 0:ey.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&"),"i"),function(e){return'<span class="bg--yellow">'.concat(e,"</span>")}):e)+(n?'<span class="dropdown__list-item-postfix">'.concat(n,"</span>"):"")+(t?'<span class="dropdown__list-item-description">'.concat(t,"</span>"):"")},e5=(j=z&&""!==z&&"string"==typeof z,x=function(e){"open_modal"===e.value?null==F||F("open_modal"):e1(e)},C=[{label:"New ".concat(z),value:"open_modal",className:"dropdown__list-item--modal"}].concat(o(null!=e0?e0:[])),{onChange:function(e){return j?x(e):e1(e)},options:j?C:H}),ne=function(e,t,l){var r,o,i,u;return(0,c.jsxs)("button",{type:"button","data-testid":"".concat(Q,"-").concat(l,"-option"),onMouseDown:function(){return e5.onChange(e)},className:(0,a.default)("".concat(y,"__list-item"),(n(u={},"".concat(y,"__list-item_active"),e.value===R),n(u,"".concat(y,"__list-item_disabled"),e.disabled),u),e.className),children:[!em&&(0,c.jsx)("span",{className:(0,a.default)("".concat(y,"__active-icon"),n({},"".concat(y,"__active-icon_active"),e.value===R)),children:(0,c.jsx)(v.Check,{})}),(0,c.jsx)("div",{className:(0,a.default)("".concat(y,"__list-item-label"),e.labelClassName||""),dangerouslySetInnerHTML:{__html:e7(e.label,e.postfix,e.description)}}),(null==e?void 0:e.icon)||"",em?null!=(i=null==e?void 0:e.customMobileIcon)?i:(0,c.jsx)(g.default,{value:e.value,checked:null==R?void 0:R.toString()}):""]},null==(o=e.value)||null==(r=o.toString())?void 0:r.replace(/ /g,"_"))},nn=function(e){var n,t,l,r,o,i;return(null!=(i=null==(n=e.items)?void 0:n.length)?i:0)>0?(0,c.jsxs)("div",{className:(0,a.default)("".concat(y,"-group"),e.className),children:[(0,c.jsx)("div",{className:"".concat(y,"-group__name"),children:e.label}),null==(t=e.items)?void 0:t.map(function(e,n){var t;return ne(e,n,null==(t=(null==e?void 0:e.testId)||n)?void 0:t.toString())})]},null==(o=e.label)||null==(r=o.toString())?void 0:r.replace(/ /g,"_").concat(null==(l=Date.now())?void 0:l.toString())):null},nt=null!=(A=null==H||null==(E=H.find(function(e){return e.value===R}))?void 0:E.label)?A:null==H?void 0:H.reduce(function(e,n){var t,l,r;return(null==e?void 0:e.length)?e:null!=(r=null==(l=n.items)||null==(t=l.find(function(e){return e.value===R}))?void 0:t.label)?r:""},""),nl=(0,s.useCallback)(function(e){var n=$||{},t=n.callback,l=n.isWithAnyScrolling,r=n.scrollingInaccuracy,o=null==e?void 0:e.target;t&&"function"==typeof t&&(l?t(e):Math.round(o.clientHeight+o.scrollTop+(void 0===r?0:r))>=o.scrollHeight&&t(e))},[e0]),nr=function(){var e,n;return eo?ex.current:null!=(n=null!=(e=document.querySelector("div#root"))?e:document.querySelector("div#app"))?n:document.querySelector("div#storybook-root")},no=function(){var e=document.createElement("div");e.setAttribute("id",eh),e.classList.add("dropdown__container"),em&&e.addEventListener("click",function(e){(null==e?void 0:e.target).id===eh&&ew(!1)});try{null==(n=e6())||n.remove()}finally{if(em){try{null==(r=document.getElementById("mlw-".concat(eh)))||r.remove()}catch(e){}var n,t,l,r,o=document.createElement("div");o.classList.add("dropdown-mobile"),o.setAttribute("id","mlw-".concat(eh)),null==o||o.append(e),null==(l=nr())||l.append(o)}else null==(t=nr())||t.append(e)}},ni=function(){var e,n,t,l,r,o,i,u,c,a,s,d,v,f,p,m,h=e6();if(!h||!eb)return!1;var g=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,b=null!=(v=null==ex||null==(e=ex.current)?void 0:e.getBoundingClientRect())?v:{},w=b.width,_=b.height,y=void 0===_?0:_,j=b.left,x=b.top,C=void 0===x?0:x,S=h.getElementsByClassName("dropdown__list")[0],E=null==eS||null==(n=eS.current)?void 0:n.getElementsByClassName("dropdown__list-header")[0],N=Number.parseInt(null!=(f=null==(l=getComputedStyle(null==eS?void 0:eS.current))||null==(t=l.marginTop)?void 0:t.replace("px",""))?f:0,10),O=null!=eL?eL:Number.parseInt(null!=(p=null==(o=getComputedStyle(S))||null==(r=o.maxHeight)?void 0:r.replace("px",""))?p:0,10);null===eL&&eI(O);var L=C-N,I=g-C-y-2*N,k=null==S||null==(i=S.getBoundingClientRect())?void 0:i.height,P=em?(null==eS||null==(c=eS.current)||null==(u=c.getBoundingClientRect())?void 0:u.height)-(null==E||null==(a=E.getBoundingClientRect())?void 0:a.height):L>=O||I>=O?O-3*N:L>I?L-3*N:I-4*N;return h.style.minWidth="".concat(w,"px"),h.style.left="".concat(j,"px"),h.style.top="".concat("bottom"==(L<I||I>=k?"bottom":"top")?C+y:C-3*N-Number.parseInt(null!=(m=null==(d=getComputedStyle(null==eS?void 0:eS.current))||null==(s=d.height)?void 0:s.replace("px",""))?m:0,10),"px"),S.style.maxHeight="".concat(P,"px"),!0},nu=function(e){var n=o(e);if(Z){var t=n.filter(function(e){return"open_modal"===e.value}),l=n.filter(function(e){return""===e.value}),r=n.filter(function(e){var n=e.value;return"open_modal"!==n&&""!==n}).sort(m.compareAlphabetical);n=o(t).concat(o(l),o(r)).map(function(e){return(null==e?void 0:e.items)&&(e.items=o(e.items).sort(m.compareAlphabetical)),e})}return n},nc=eb?e8:function(){};(0,s.useEffect)(function(){(!eo||ex.current)&&(no(),ef&&!ep&&ew(!0))},[eo,ex.current]),(0,s.useLayoutEffect)(function(){var e;return em?(window.removeEventListener("resize",ni),window.removeEventListener("mousewheel",nc),window.removeEventListener("scroll",nc),window.removeEventListener("touchmove",nc)):(window.addEventListener("resize",ni),window.addEventListener("mousewheel",nc),window.addEventListener("scroll",nc),window.addEventListener("touchmove",nc)),null==(e=e6())||e.addEventListener("click",nc),function(){var e;window.removeEventListener("resize",ni),window.removeEventListener("mousewheel",nc),window.removeEventListener("scroll",nc),window.removeEventListener("touchmove",nc),null==(e=e6())||e.removeEventListener("click",nc)}},[e6]),(0,s.useLayoutEffect)(function(){ni()},[eb,ey,em,H,null==eS||null==(O=eS.current)||null==(N=O.getBoundingClientRect())?void 0:N.height]),(0,s.useEffect)(function(){return document.addEventListener("click",e8,!0),function(){return document.removeEventListener("click",e8,!0)}},[]),(0,s.useEffect)(function(){return eb||eA(!1),$&&(void 0===$?"undefined":i($))==="object"&&eb&&eC&&eC.current&&eC.current.addEventListener("scroll",nl),function(){$&&(void 0===$?"undefined":i($))==="object"&&removeEventListener("scroll",nl)}},[eb,eC]),(0,s.useEffect)(function(){var e;return!ey&&eD&&(ej(nt),e=setTimeout(function(){return eE.current.select()},1)),eD||eb||ej(null),function(){clearTimeout(e)}},[eD]),(0,s.useEffect)(function(){var e,n,t,l;eb&&!eD&&(null==eE?void 0:eE.current)&&!em&&(null==(e=eE.current)||e.focus()),eb?null==(n=e6())||n.classList.add("dropdown__container--opened"):(null==(t=eE.current)||t.blur(),null==(l=e6())||l.classList.remove("dropdown__container--opened")),!eb&&em&&ej(null)},[eb]),(0,s.useEffect)(function(){if(eb&&em&&(null==eC?void 0:eC.current)&&!ey){var e,n,t,l;eT((null==eC||null==(e=eC.current)?void 0:e.scrollHeight)>(null==eC||null==(n=eC.current)?void 0:n.clientHeight)),eK(eR||(null==eC||null==(t=eC.current)?void 0:t.scrollHeight)>(null==eC||null==(l=eC.current)?void 0:l.clientHeight))}},[eb,em,eR,null==eC?void 0:eC.current,null==eC||null==(L=eC.current)?void 0:L.scrollHeight,null==eC||null==(I=eC.current)?void 0:I.clientHeight]),(0,s.useEffect)(function(){var e,n=function(e){var n,t;ez(Number.parseInt(null==e||null==(t=e.target)||null==(n=t.scrollTop)?void 0:n.toString(),10))};return eb&&em&&(null==eC?void 0:eC.current)&&(null==eC||null==(e=eC.current)||e.addEventListener("scroll",n)),function(){if((null==eC?void 0:eC.current)!==null){var e;null==eC||null==(e=eC.current)||e.removeEventListener("scroll",n)}}},[eb,em,null==eC?void 0:eC.current]),(0,s.useEffect)(function(){if(null==eC?void 0:eC.current){var e,n;eX(Number.parseInt(((null==eC||null==(e=eC.current)?void 0:e.scrollHeight)-(null==eC||null==(n=eC.current)?void 0:n.clientHeight)).toString(),10))}},[eU,null==eC?void 0:eC.current]),(0,s.useEffect)(function(){return function(){var e,n;null==(e=e6())||e.remove(),null==(n=document.getElementById("mlw-".concat(eh)))||n.remove()}},[]);var na=nt&&(null==(k=e0.find(function(e){return e.value===R}))?void 0:k.postfix)||null;if(!H)return null;return(0,c.jsxs)("div",{className:(0,a.default)(y,W,(n(M={disabled:B},"".concat(y,"-mobile"),em),n(M,"".concat(y,"--focused"),eb&&!em),n(M,"".concat(y,"--with-custom-trigger"),!!ea),M)),ref:ex,onKeyDown:e2,onKeyUp:e3,children:[(0,c.jsx)("button",{type:"button","data-testid":Q,className:(0,a.default)("".concat(y,"__trigger"),"input__wrap",(n(D={},"".concat(y,"__trigger--with-actions"),eu),n(D,"placeholder",!R),n(D,"error",T),D)),onClick:function(){return ew(!0)},onKeyDown:e2,onKeyUp:e3,tabIndex:es,children:ea||(0,c.jsxs)(c.Fragment,{children:[U&&!em?(0,c.jsx)("input",l(t({ref:eE,className:"".concat(y,"__input"),value:null==(P=eb?null!=ey?ey:"":null!=nt?nt:"")?void 0:P.toString(),onChange:function(e){return e9(e.target.value)},placeholder:K,onFocus:function(){return eq(!0)},onBlur:function(){return eq(!1)},onMouseDown:function(){eb||eq(!0)}},er),{tabIndex:-1})):(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("span",{className:"text",children:nt||K||""}),na&&(0,c.jsx)("span",{className:"dropdown__list-item-postfix",children:na})]}),(0,c.jsx)("span",{className:(0,a.default)("".concat(y,"__arrow"),n({},"".concat(y,"__arrow_active"),eb)),onClick:function(e){null==e||e.stopPropagation(),ew(function(e){return!e})},children:em?(0,c.jsx)(v.Code,{className:"mobile-icon"}):eb?(0,c.jsx)(v.ChevronUp,{}):(0,c.jsx)(v.ChevronDown,{})})]})}),eu&&(0,c.jsxs)("div",{className:(0,a.default)("".concat(y,"__actions")),children:[(0,c.jsx)("div",{className:(0,a.default)("".concat(y,"__actions-item")),onClick:ed,children:(0,c.jsx)(v.Check,{})}),(0,c.jsx)("div",{className:(0,a.default)("".concat(y,"__actions-item")),onClick:ev,children:(0,c.jsx)(v.X,{})})]}),eb&&((S=e6())?(0,d.createPortal)((0,c.jsx)("div",{"data-testid":"".concat(Q,"-container-wrapper"),className:(0,a.default)("".concat(y,"__container-wrapper")),ref:eN,onClick:em?e4:function(){},children:(0,c.jsxs)("div",{className:(0,a.default)("".concat(y,"__list-wrapper"),(n(w={},"".concat(y,"__list-wrapper--fixed-height"),eF),n(w,"".concat(y,"__list-wrapper--with-bottom-shadow"),eR&&em),n(w,"".concat(y,"__list-wrapper--with-bottom-shadow-hidden"),eU===eV),w)),ref:eS,children:[em&&(0,c.jsxs)("div",{className:(0,a.default)("".concat(y,"__list-header"),(n(_={},"".concat(y,"__list-header-with-shadow"),eR&&em),n(_,"".concat(y,"__list-header-with-shadow-hidden"),0===eU),_)),children:[(0,c.jsxs)("div",{className:(0,a.default)("".concat(y,"__list-header-row")),children:[(0,c.jsx)("div",{className:(0,a.default)("".concat(y,"__list-label")),children:q}),(0,c.jsx)("div",{className:(0,a.default)("".concat(y,"__list-close-icon")),onClick:function(){return ew(!1)},children:(0,c.jsx)(v.X,{onClick:function(){return ew(!1)}})})]}),U&&(0,c.jsx)("div",{className:(0,a.default)("".concat(y,"__list-header-row")),children:(0,c.jsx)(h.default,t({ref:eE,className:"".concat(y,"__input"),value:null!=ey?ey:nt,onChange:e9,placeholder:K||"Search",withDelete:!0,onFocus:function(){return eq(!0)},onBlur:function(){return eq(!1)},onMouseDown:function(){eb||eq(!0)}},er))})]}),(0,c.jsxs)("div",{className:(0,a.default)("".concat(y,"__list"),n({},"".concat(y,"__list-top"),V)),ref:eC,children:[e5.options&&(null==(u=nu(e5.options))?void 0:u.map(function(e,n){if(null==e||null==(o=e.items)?void 0:o.length)if(!U||!eP)return nn(e);else{var r,o,i,u,c=null==(u=e.items)?void 0:u.slice().filter(function(e){var n;return(null==e||null==(n=e.label)?void 0:n.toLowerCase().includes((null==ey?void 0:ey.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)===""});if(null==c?void 0:c.length)return nn(l(t({},e),{items:c}))}else if(!U||!eP||(null==e||null==(i=e.label)?void 0:i.toLowerCase().includes((null==ey?void 0:ey.toLowerCase())||""))||!(null==e?void 0:e.value)||(null==e?void 0:e.value)==="")return ne(e,n,null==(r=(null==e?void 0:e.testId)||n)?void 0:r.toString());return null})),!eZ.length&&!eY.length&&(0,c.jsx)("div",{className:"".concat(y,"__list-item ").concat(y,"__list-item--no-options"),children:el}),B&&eb&&(0,c.jsx)(b.default,{})]})]})}),S):null)]})};