intelicoreact 1.4.10 → 1.4.12

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