intelicoreact 1.6.25 → 1.6.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/dist/Atomic/FormElements/ActionAlert/ActionAlert.js +1 -98
  2. package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +1 -48
  3. package/dist/Atomic/FormElements/Calendar/Calendar.js +1 -249
  4. package/dist/Atomic/FormElements/Calendar/Calendar.props.js +1 -4
  5. package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +1 -65
  6. package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +1 -52
  7. package/dist/Atomic/FormElements/Datepicker/Datepicker.js +1 -424
  8. package/dist/Atomic/FormElements/Datepicker/Datepicker.props.js +1 -4
  9. package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.js +1 -173
  10. package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.props.js +1 -4
  11. package/dist/Atomic/FormElements/Dropdown/Dropdown.d.ts +5 -0
  12. package/dist/Atomic/FormElements/Dropdown/Dropdown.js +1 -735
  13. package/dist/Atomic/FormElements/Dropdown/Dropdown.js.map +1 -0
  14. package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +1 -20
  15. package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +1 -529
  16. package/dist/Atomic/FormElements/FileLoader/FileLoader.js +1 -94
  17. package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +1 -105
  18. package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +1 -67
  19. package/dist/Atomic/FormElements/FileLoaderDescription/FileLoaderDescription.js +1 -247
  20. package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +1 -160
  21. package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +1 -193
  22. package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +1 -135
  23. package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.js +1 -116
  24. package/dist/Atomic/FormElements/Input/Input.js +1 -467
  25. package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +1 -161
  26. package/dist/Atomic/FormElements/InputColor/InputColor.js +1 -64
  27. package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +1 -200
  28. package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +1 -354
  29. package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +1 -71
  30. package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +1 -693
  31. package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +1 -254
  32. package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +1 -32
  33. package/dist/Atomic/FormElements/InputDateRange/dependencies.js +1 -200
  34. package/dist/Atomic/FormElements/InputLink/InputLink.js +1 -99
  35. package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +1 -37
  36. package/dist/Atomic/FormElements/InputMask/InputMask.js +1 -1214
  37. package/dist/Atomic/FormElements/InputMask/config.js +1 -15
  38. package/dist/Atomic/FormElements/InputMask/functions.js +1 -58
  39. package/dist/Atomic/FormElements/InputMask2/InputMask2.js +1 -674
  40. package/dist/Atomic/FormElements/InputMask2/config.js +1 -15
  41. package/dist/Atomic/FormElements/InputMask2/functions.js +1 -58
  42. package/dist/Atomic/FormElements/InputMask3/InputMask3.js +1 -766
  43. package/dist/Atomic/FormElements/InputMask3/config.js +1 -15
  44. package/dist/Atomic/FormElements/InputMask3/functions.js +1 -58
  45. package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +1 -114
  46. package/dist/Atomic/FormElements/InputsRow/InputsRow.js +1 -140
  47. package/dist/Atomic/FormElements/Label/Label.js +1 -87
  48. package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +1 -506
  49. package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +1 -45
  50. package/dist/Atomic/FormElements/NumericInput/NumericInput.js +1 -331
  51. package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +1 -66
  52. package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +1 -80
  53. package/dist/Atomic/FormElements/RadioInput/RadioInput.js +1 -57
  54. package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +1 -54
  55. package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +1 -183
  56. package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +1 -222
  57. package/dist/Atomic/FormElements/RangeList/RangeList.js +1 -175
  58. package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +1 -43
  59. package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +1 -443
  60. package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +1 -858
  61. package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +1 -39
  62. package/dist/Atomic/FormElements/Switcher/Switcher.js +1 -59
  63. package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +1 -50
  64. package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +1 -44
  65. package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +1 -100
  66. package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +1 -52
  67. package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +1 -64
  68. package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +1 -170
  69. package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +1 -202
  70. package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +1 -67
  71. package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +1 -115
  72. package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +1 -1110
  73. package/dist/Atomic/FormElements/Text/Text.js +1 -125
  74. package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +1 -49
  75. package/dist/Atomic/FormElements/Textarea/Textarea.js +1 -80
  76. package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +1 -176
  77. package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +1 -62
  78. package/dist/Atomic/FormElements/TimeRange/TimeRange.js +1 -119
  79. package/dist/Atomic/FormElements/UserContacts/UserContacts.js +1 -188
  80. package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +1 -83
  81. package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +1 -82
  82. package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +1 -101
  83. package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +1 -29
  84. package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +1 -113
  85. package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +1 -30
  86. package/dist/Atomic/Layout/Header/Header.js +1 -85
  87. package/dist/Atomic/Layout/Spinner/Spinner.js +1 -44
  88. package/dist/Atomic/UI/Accordion/Accordion.js +1 -108
  89. package/dist/Atomic/UI/Accordion/AccordionItem.js +1 -176
  90. package/dist/Atomic/UI/AccordionTable/AccordionTable.js +1 -238
  91. package/dist/Atomic/UI/AccordionText/AccordionText.js +1 -69
  92. package/dist/Atomic/UI/AdvancedTag/AdvTag.js +1 -207
  93. package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +1 -56
  94. package/dist/Atomic/UI/Alert/Alert.js +1 -72
  95. package/dist/Atomic/UI/Arrow/Arrow.js +1 -132
  96. package/dist/Atomic/UI/Box/Box.js +1 -52
  97. package/dist/Atomic/UI/Button/Button.js +1 -47
  98. package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +1 -72
  99. package/dist/Atomic/UI/Chart/Chart.js +1 -172
  100. package/dist/Atomic/UI/Chart/partial/Chart.constants.js +1 -95
  101. package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +1 -80
  102. package/dist/Atomic/UI/Chart/partial/datasetSetters.js +1 -188
  103. package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +1 -335
  104. package/dist/Atomic/UI/Chart/partial/optionsSetters.js +1 -43
  105. package/dist/Atomic/UI/Chart/partial/utils.js +1 -60
  106. package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +1 -109
  107. package/dist/Atomic/UI/DateTime/DateTime.js +1 -57
  108. package/dist/Atomic/UI/DebugContainer/DebugContainer.js +1 -44
  109. package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +1 -15
  110. package/dist/Atomic/UI/DoubleString/DoubleString.js +1 -102
  111. package/dist/Atomic/UI/DoubleString/DoubleString.scss +8 -1
  112. package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +1 -70
  113. package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +1 -221
  114. package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +1 -106
  115. package/dist/Atomic/UI/Hint/Hint.js +1 -256
  116. package/dist/Atomic/UI/Hint/partials/_utils.js +1 -64
  117. package/dist/Atomic/UI/Modal/Modal.js +1 -179
  118. package/dist/Atomic/UI/Modal/ModalHOC.js +1 -97
  119. package/dist/Atomic/UI/Modal/partials/ModalFooter.js +1 -71
  120. package/dist/Atomic/UI/Modal/partials/ModalTitle.js +1 -110
  121. package/dist/Atomic/UI/Modal/partials/useMobileModal.js +1 -192
  122. package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.js +1 -75
  123. package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +1 -80
  124. package/dist/Atomic/UI/NavLine/NavLine.js +1 -317
  125. package/dist/Atomic/UI/PageTitle/PageTitle.js +1 -77
  126. package/dist/Atomic/UI/PieChart/PieChart.js +1 -42
  127. package/dist/Atomic/UI/Price/Price.js +1 -31
  128. package/dist/Atomic/UI/PriceRange/PriceRange.js +1 -44
  129. package/dist/Atomic/UI/ProgressLine/ProgressLine.js +1 -98
  130. package/dist/Atomic/UI/Status/Status.js +1 -67
  131. package/dist/Atomic/UI/Table/Partials/TdCell.js +1 -87
  132. package/dist/Atomic/UI/Table/Partials/TdHeader.js +1 -38
  133. package/dist/Atomic/UI/Table/Partials/TdRow.js +1 -99
  134. package/dist/Atomic/UI/Table/Partials/TdTitle.js +1 -52
  135. package/dist/Atomic/UI/Table/Table.js +1 -63
  136. package/dist/Atomic/UI/Table/TdTypes/TdActions.js +1 -80
  137. package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +1 -28
  138. package/dist/Atomic/UI/Table/TdTypes/TdRange.js +1 -13
  139. package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +1 -53
  140. package/dist/Atomic/UI/Tag/Tag.js +1 -167
  141. package/dist/Atomic/UI/TagList/TagList.js +1 -251
  142. package/dist/Atomic/UI/UserBox/UserBox.js +1 -86
  143. package/dist/Atomic/UI/WizardStepper/constructor.js +1 -84
  144. package/dist/Atomic/UI/WizardStepper/index.js +1 -3
  145. package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +1 -37
  146. package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +1 -3
  147. package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +1 -61
  148. package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +1 -3
  149. package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +1 -39
  150. package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +1 -3
  151. package/dist/Atomic/UI/WizardStepper/ui/icons.js +1 -49
  152. package/dist/Atomic/UI/WizardStepper/ui/index.js +1 -3
  153. package/dist/Classes/AbortableFetch.js +1 -454
  154. package/dist/Classes/AnimatedHandler.js +1 -47
  155. package/dist/Classes/RESTAPI/index.js +1 -228
  156. package/dist/Classes/RESTAPI/partials/AbortableFetch.js +1 -457
  157. package/dist/Classes/RESTAPI/partials/ApiBase.js +1 -48
  158. package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +1 -112
  159. package/dist/Classes/RESTAPI/partials/ApiUtils.js +1 -189
  160. package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +1 -252
  161. package/dist/Classes/RESTAPI/partials/Utils.js +1 -92
  162. package/dist/Classes/RESTAPI/partials/_outerDependencies.js +1 -3
  163. package/dist/Classes/RESTAPI/partials/_utils.js +1 -197
  164. package/dist/Constants/index.constants.js +1 -78
  165. package/dist/Functions/Portal.js +1 -22
  166. package/dist/Functions/customEventListener.js +1 -96
  167. package/dist/Functions/dateTime.js +1 -149
  168. package/dist/Functions/fieldValueFormatters.js +1 -405
  169. package/dist/Functions/guards/assertions.js +1 -294
  170. package/dist/Functions/guards/safeValue.js +1 -75
  171. package/dist/Functions/guards/typeGuards.js +1 -373
  172. package/dist/Functions/hooks/useFormFieldsChangesManager.js +1 -95
  173. package/dist/Functions/locale/createTranslator.js +1 -32
  174. package/dist/Functions/operations.js +1 -130
  175. package/dist/Functions/presets/inputMaskPresets.js +1 -170
  176. package/dist/Functions/presets/inputPresets.js +1 -60
  177. package/dist/Functions/presets/mobileKeyboardTypesPresets.js +1 -45
  178. package/dist/Functions/schemas.js +1 -31
  179. package/dist/Functions/useBodyScrollLock.js +1 -17
  180. package/dist/Functions/useClickOutside.js +1 -15
  181. package/dist/Functions/useDebounce.js +1 -17
  182. package/dist/Functions/useFieldFocus.js +1 -84
  183. package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +1 -39
  184. package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +1 -159
  185. package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +1 -78
  186. package/dist/Functions/useFormTools/functions/General.js +1 -134
  187. package/dist/Functions/useFormTools/functions/RenderFields.js +1 -111
  188. package/dist/Functions/useFormTools/functions/usePrevious.js +1 -12
  189. package/dist/Functions/useFormTools/index.js +1 -778
  190. package/dist/Functions/useInputHighlightError.js +1 -67
  191. package/dist/Functions/useIsMobile/useIsMobile.js +1 -33
  192. package/dist/Functions/useKeyPress/useHandleKeyPress.js +1 -52
  193. package/dist/Functions/useKeyPress/useKeyPress.js +1 -52
  194. package/dist/Functions/useLocalStorage.js +1 -34
  195. package/dist/Functions/useLocationParams.js +1 -27
  196. package/dist/Functions/useMediaQuery.js +1 -17
  197. package/dist/Functions/useMetaInfo.js +1 -43
  198. package/dist/Functions/useMouseUpOutside.js +1 -16
  199. package/dist/Functions/useOnlineStatus.js +1 -29
  200. package/dist/Functions/usePasswordChecker.js +1 -110
  201. package/dist/Functions/usePrevious.js +1 -12
  202. package/dist/Functions/useResize.js +1 -31
  203. package/dist/Functions/useScrollTo.js +1 -17
  204. package/dist/Functions/useToggle.js +1 -17
  205. package/dist/Functions/utils.js +1 -522
  206. package/dist/Langs.js +1 -168
  207. package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +1 -21
  208. package/dist/Molecular/CustomIcons/components/AlertCircle.js +1 -23
  209. package/dist/Molecular/CustomIcons/components/AppStore.js +1 -29
  210. package/dist/Molecular/CustomIcons/components/Arrow.js +1 -32
  211. package/dist/Molecular/CustomIcons/components/ArrowDown.js +1 -17
  212. package/dist/Molecular/CustomIcons/components/ArrowLeft.js +1 -22
  213. package/dist/Molecular/CustomIcons/components/ArrowRight.js +1 -22
  214. package/dist/Molecular/CustomIcons/components/ArrowUp.js +1 -17
  215. package/dist/Molecular/CustomIcons/components/Bell.js +1 -15
  216. package/dist/Molecular/CustomIcons/components/Button.js +1 -12
  217. package/dist/Molecular/CustomIcons/components/Campaigns.js +1 -16
  218. package/dist/Molecular/CustomIcons/components/Check.js +1 -14
  219. package/dist/Molecular/CustomIcons/components/Check2.js +1 -12
  220. package/dist/Molecular/CustomIcons/components/ChevronDown.js +1 -12
  221. package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +1 -11
  222. package/dist/Molecular/CustomIcons/components/ChevronLeft.js +1 -11
  223. package/dist/Molecular/CustomIcons/components/ChevronRight.js +1 -11
  224. package/dist/Molecular/CustomIcons/components/ChevronUp.js +1 -11
  225. package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +1 -27
  226. package/dist/Molecular/CustomIcons/components/Close.js +1 -14
  227. package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +1 -17
  228. package/dist/Molecular/CustomIcons/components/Delete.js +1 -16
  229. package/dist/Molecular/CustomIcons/components/Edit.js +1 -15
  230. package/dist/Molecular/CustomIcons/components/Email.js +1 -31
  231. package/dist/Molecular/CustomIcons/components/FinturfLogo.js +1 -18
  232. package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +1 -35
  233. package/dist/Molecular/CustomIcons/components/Flows.js +1 -15
  234. package/dist/Molecular/CustomIcons/components/Gift.js +1 -25
  235. package/dist/Molecular/CustomIcons/components/GoogleAuth.js +1 -29
  236. package/dist/Molecular/CustomIcons/components/GooglePlay.js +1 -29
  237. package/dist/Molecular/CustomIcons/components/HelpCircle.js +1 -19
  238. package/dist/Molecular/CustomIcons/components/HelpCircle2.js +1 -20
  239. package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +1 -19
  240. package/dist/Molecular/CustomIcons/components/Home.js +1 -16
  241. package/dist/Molecular/CustomIcons/components/Home2.js +1 -22
  242. package/dist/Molecular/CustomIcons/components/Key.js +1 -23
  243. package/dist/Molecular/CustomIcons/components/Landers.js +1 -20
  244. package/dist/Molecular/CustomIcons/components/Lock.js +1 -15
  245. package/dist/Molecular/CustomIcons/components/Mail.js +1 -26
  246. package/dist/Molecular/CustomIcons/components/Mastercard.js +1 -73
  247. package/dist/Molecular/CustomIcons/components/Minus.js +1 -25
  248. package/dist/Molecular/CustomIcons/components/Offers.js +1 -16
  249. package/dist/Molecular/CustomIcons/components/Pause.js +1 -28
  250. package/dist/Molecular/CustomIcons/components/PayPal.js +1 -41
  251. package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +1 -28
  252. package/dist/Molecular/CustomIcons/components/Phone.js +1 -30
  253. package/dist/Molecular/CustomIcons/components/Play.js +1 -25
  254. package/dist/Molecular/CustomIcons/components/Plus.js +1 -25
  255. package/dist/Molecular/CustomIcons/components/Profile.js +1 -16
  256. package/dist/Molecular/CustomIcons/components/QRCode.js +1 -29
  257. package/dist/Molecular/CustomIcons/components/Rectangle.js +1 -12
  258. package/dist/Molecular/CustomIcons/components/Revert.js +1 -13
  259. package/dist/Molecular/CustomIcons/components/Star.js +1 -14
  260. package/dist/Molecular/CustomIcons/components/Star2.js +1 -16
  261. package/dist/Molecular/CustomIcons/components/TrafficSources.js +1 -14
  262. package/dist/Molecular/CustomIcons/components/Trash.js +1 -15
  263. package/dist/Molecular/CustomIcons/components/TrashRed.js +1 -15
  264. package/dist/Molecular/CustomIcons/components/Triggers.js +1 -15
  265. package/dist/Molecular/CustomIcons/components/User.js +1 -25
  266. package/dist/Molecular/CustomIcons/components/Visa.js +1 -31
  267. package/dist/Molecular/CustomIcons/components/X.js +1 -12
  268. package/dist/Molecular/CustomIcons/index.js +1 -61
  269. package/dist/Molecular/FormElement/FormElement.js +1 -54
  270. package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +1 -184
  271. package/dist/Molecular/FormWithDependOn/partials/_utils.js +1 -53
  272. package/dist/Molecular/InputAddress/InputAddress.js +1 -626
  273. package/dist/Molecular/InputPassword/InputPassword.js +1 -48
  274. package/dist/index.js +1 -104
  275. package/package.json +1 -1
@@ -1,192 +1 @@
1
- /* eslint-disable react-web-api/no-leaked-event-listener */ "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "default", {
6
- enumerable: true,
7
- get: function() {
8
- return useMobileModal;
9
- }
10
- });
11
- const _jsxruntime = require("react/jsx-runtime");
12
- const _react = require("react");
13
- const _useIsMobile = /*#__PURE__*/ _interop_require_default(require("../../../../Functions/useIsMobile/useIsMobile"));
14
- function _interop_require_default(obj) {
15
- return obj && obj.__esModule ? obj : {
16
- default: obj
17
- };
18
- }
19
- const SCROLL_DIRECTION = {
20
- UP: 'up',
21
- DOWN: 'down'
22
- };
23
- function useMobileModal({ modalRef, withMobileLogic = false, withFixedFooter = false, isOpen = false }) {
24
- var _modalMobileHeaderRef_current_getBoundingClientRect, _modalMobileHeaderRef_current, _modalMobileFooterRef_current_getBoundingClientRect, _modalMobileFooterRef_current;
25
- const modalMobileContainerRef = (0, _react.useRef)(null);
26
- const modalMobileHeaderRef = (0, _react.useRef)(null);
27
- const modalMobileFooterRef = (0, _react.useRef)(null);
28
- const modalMobileBodyRef = (0, _react.useRef)(null);
29
- const { isMobile } = (0, _useIsMobile.default)();
30
- const [modalHeight, setModalHeight] = (0, _react.useState)(0);
31
- const [modalsLogic, setModalsLogic] = (0, _react.useState)({
32
- IS_HEADER_HIDDEN: false,
33
- IS_HEADER_STICKY: false,
34
- IS_FOOTER_HIDDEN: false,
35
- IS_FOOTER_STICKY: withFixedFooter
36
- });
37
- const [modalsLogicProps, setModalsLogicProps] = (0, _react.useState)({
38
- headerHeight: 0,
39
- footerHeight: 0
40
- });
41
- const [scrollDirection, setScrollDirection] = (0, _react.useState)(SCROLL_DIRECTION.UP);
42
- const [scrollTopPrev, setScrollTopPrev] = (0, _react.useState)(0);
43
- const [scrollTop, setScrollTop] = (0, _react.useState)(0);
44
- const [scrollHeight, setScrollHeight] = (0, _react.useState)(1);
45
- const [, setContainerScrollHeight] = (0, _react.useState)(1);
46
- /* MODALS LOGIC | BEGIN */ // Count ScrollTop
47
- (0, _react.useLayoutEffect)(()=>{
48
- const el = modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current;
49
- if (el) {
50
- el.addEventListener('scroll', ()=>{
51
- setScrollTop((scrollTop)=>{
52
- if (scrollTop !== el.scrollTop) setScrollTopPrev(scrollTop);
53
- return el.scrollTop;
54
- });
55
- });
56
- }
57
- }, [
58
- modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current
59
- ]);
60
- // Count ScrollDirection
61
- (0, _react.useEffect)(()=>{
62
- setScrollDirection((prevScrollDirection)=>scrollTop < scrollTopPrev ? SCROLL_DIRECTION.UP : scrollTop > scrollTopPrev ? SCROLL_DIRECTION.DOWN : prevScrollDirection);
63
- }, [
64
- scrollTop,
65
- scrollTopPrev
66
- ]);
67
- // Dynamic Modal Positioning
68
- (0, _react.useLayoutEffect)(()=>{
69
- if (isOpen) {
70
- const modalStyle = (modalRef === null || modalRef === void 0 ? void 0 : modalRef.current) ? (modalRef === null || modalRef === void 0 ? void 0 : modalRef.current.style) || window.getComputedStyle(modalRef === null || modalRef === void 0 ? void 0 : modalRef.current) : {};
71
- const computedModalHeight = (modalRef === null || modalRef === void 0 ? void 0 : modalRef.current) ? modalHeight + Number.parseFloat((modalStyle === null || modalStyle === void 0 ? void 0 : modalStyle.marginTop) || '0') : 0;
72
- const windowHeight = document.documentElement.clientHeight || window.screen.availHeight || window.screen.height;
73
- if (modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current) {
74
- if (computedModalHeight <= windowHeight) {
75
- modalMobileContainerRef.current.style.display = 'flex';
76
- modalMobileContainerRef.current.style.alignItems = 'flex-end';
77
- } else {
78
- var _modalMobileContainerRef_current_style, _modalMobileContainerRef_current, _modalMobileContainerRef_current_style1, _modalMobileContainerRef_current1;
79
- (_modalMobileContainerRef_current = modalMobileContainerRef.current) === null || _modalMobileContainerRef_current === void 0 ? void 0 : (_modalMobileContainerRef_current_style = _modalMobileContainerRef_current.style) === null || _modalMobileContainerRef_current_style === void 0 ? void 0 : _modalMobileContainerRef_current_style.removeProperty('display');
80
- (_modalMobileContainerRef_current1 = modalMobileContainerRef.current) === null || _modalMobileContainerRef_current1 === void 0 ? void 0 : (_modalMobileContainerRef_current_style1 = _modalMobileContainerRef_current1.style) === null || _modalMobileContainerRef_current_style1 === void 0 ? void 0 : _modalMobileContainerRef_current_style1.removeProperty('align-items');
81
- }
82
- }
83
- }
84
- }, [
85
- modalsLogicProps,
86
- isOpen,
87
- isMobile,
88
- modalHeight
89
- ]);
90
- // Calculating
91
- (0, _react.useLayoutEffect)(()=>{
92
- if (isMobile && isOpen) {
93
- var _modalRef_current_getBoundingClientRect, _modalRef_current;
94
- const newModalHeight = modalRef === null || modalRef === void 0 ? void 0 : (_modalRef_current = modalRef.current) === null || _modalRef_current === void 0 ? void 0 : (_modalRef_current_getBoundingClientRect = _modalRef_current.getBoundingClientRect()) === null || _modalRef_current_getBoundingClientRect === void 0 ? void 0 : _modalRef_current_getBoundingClientRect.height;
95
- if (newModalHeight && modalHeight !== newModalHeight) {
96
- setModalHeight(newModalHeight);
97
- }
98
- }
99
- });
100
- (0, _react.useEffect)(()=>{
101
- if (isMobile && withMobileLogic) {
102
- const { footerHeight, headerHeight } = modalsLogicProps;
103
- setModalsLogic((prevStickyLogic)=>({
104
- IS_HEADER_HIDDEN: scrollDirection === SCROLL_DIRECTION.DOWN || scrollTop === 0,
105
- IS_HEADER_STICKY: scrollDirection === SCROLL_DIRECTION.UP && scrollTop !== 0 && (scrollTop >= headerHeight || prevStickyLogic.IS_HEADER_STICKY),
106
- IS_FOOTER_HIDDEN: !withFixedFooter && (scrollDirection === SCROLL_DIRECTION.UP || scrollHeight === Math.round(scrollTop)),
107
- IS_FOOTER_STICKY: withFixedFooter && scrollHeight > 1 || scrollDirection === SCROLL_DIRECTION.DOWN && (scrollHeight - Math.round(scrollTop) >= footerHeight || prevStickyLogic.IS_FOOTER_STICKY)
108
- }));
109
- }
110
- }, [
111
- scrollTop,
112
- scrollHeight,
113
- isMobile,
114
- withMobileLogic,
115
- scrollDirection,
116
- modalsLogicProps,
117
- modalHeight,
118
- window.innerHeight
119
- ]);
120
- (0, _react.useLayoutEffect)(()=>{
121
- var _modalMobileHeaderRef_current_getBoundingClientRect, _modalMobileHeaderRef_current;
122
- if ((modalMobileHeaderRef === null || modalMobileHeaderRef === void 0 ? void 0 : (_modalMobileHeaderRef_current = modalMobileHeaderRef.current) === null || _modalMobileHeaderRef_current === void 0 ? void 0 : (_modalMobileHeaderRef_current_getBoundingClientRect = _modalMobileHeaderRef_current.getBoundingClientRect()) === null || _modalMobileHeaderRef_current_getBoundingClientRect === void 0 ? void 0 : _modalMobileHeaderRef_current_getBoundingClientRect.height) !== undefined) {
123
- setModalsLogicProps((state)=>{
124
- var _modalMobileHeaderRef_current_getBoundingClientRect, _modalMobileHeaderRef_current;
125
- var _modalMobileHeaderRef_current_getBoundingClientRect_height;
126
- return {
127
- ...state,
128
- headerHeight: (_modalMobileHeaderRef_current_getBoundingClientRect_height = modalMobileHeaderRef === null || modalMobileHeaderRef === void 0 ? void 0 : (_modalMobileHeaderRef_current = modalMobileHeaderRef.current) === null || _modalMobileHeaderRef_current === void 0 ? void 0 : (_modalMobileHeaderRef_current_getBoundingClientRect = _modalMobileHeaderRef_current.getBoundingClientRect()) === null || _modalMobileHeaderRef_current_getBoundingClientRect === void 0 ? void 0 : _modalMobileHeaderRef_current_getBoundingClientRect.height) !== null && _modalMobileHeaderRef_current_getBoundingClientRect_height !== void 0 ? _modalMobileHeaderRef_current_getBoundingClientRect_height : 0
129
- };
130
- });
131
- }
132
- }, [
133
- modalMobileHeaderRef === null || modalMobileHeaderRef === void 0 ? void 0 : (_modalMobileHeaderRef_current = modalMobileHeaderRef.current) === null || _modalMobileHeaderRef_current === void 0 ? void 0 : (_modalMobileHeaderRef_current_getBoundingClientRect = _modalMobileHeaderRef_current.getBoundingClientRect()) === null || _modalMobileHeaderRef_current_getBoundingClientRect === void 0 ? void 0 : _modalMobileHeaderRef_current_getBoundingClientRect.height
134
- ]);
135
- (0, _react.useLayoutEffect)(()=>{
136
- var _modalMobileFooterRef_current_getBoundingClientRect, _modalMobileFooterRef_current;
137
- if ((modalMobileFooterRef === null || modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef_current = modalMobileFooterRef.current) === null || _modalMobileFooterRef_current === void 0 ? void 0 : (_modalMobileFooterRef_current_getBoundingClientRect = _modalMobileFooterRef_current.getBoundingClientRect()) === null || _modalMobileFooterRef_current_getBoundingClientRect === void 0 ? void 0 : _modalMobileFooterRef_current_getBoundingClientRect.height) !== undefined) {
138
- setModalsLogicProps((state)=>{
139
- var _modalMobileFooterRef_current_getBoundingClientRect, _modalMobileFooterRef_current;
140
- var _modalMobileFooterRef_current_getBoundingClientRect_height;
141
- return {
142
- ...state,
143
- footerHeight: (_modalMobileFooterRef_current_getBoundingClientRect_height = modalMobileFooterRef === null || modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef_current = modalMobileFooterRef.current) === null || _modalMobileFooterRef_current === void 0 ? void 0 : (_modalMobileFooterRef_current_getBoundingClientRect = _modalMobileFooterRef_current.getBoundingClientRect()) === null || _modalMobileFooterRef_current_getBoundingClientRect === void 0 ? void 0 : _modalMobileFooterRef_current_getBoundingClientRect.height) !== null && _modalMobileFooterRef_current_getBoundingClientRect_height !== void 0 ? _modalMobileFooterRef_current_getBoundingClientRect_height : 0
144
- };
145
- });
146
- }
147
- }, [
148
- modalMobileFooterRef === null || modalMobileFooterRef === void 0 ? void 0 : (_modalMobileFooterRef_current = modalMobileFooterRef.current) === null || _modalMobileFooterRef_current === void 0 ? void 0 : (_modalMobileFooterRef_current_getBoundingClientRect = _modalMobileFooterRef_current.getBoundingClientRect()) === null || _modalMobileFooterRef_current_getBoundingClientRect === void 0 ? void 0 : _modalMobileFooterRef_current_getBoundingClientRect.height
149
- ]);
150
- (0, _react.useEffect)(()=>{
151
- if (modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current) {
152
- var _modalMobileContainerRef_current, _modalMobileContainerRef_current1;
153
- setContainerScrollHeight(modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : (_modalMobileContainerRef_current = modalMobileContainerRef.current) === null || _modalMobileContainerRef_current === void 0 ? void 0 : _modalMobileContainerRef_current.scrollHeight);
154
- setScrollHeight((modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : (_modalMobileContainerRef_current1 = modalMobileContainerRef.current) === null || _modalMobileContainerRef_current1 === void 0 ? void 0 : _modalMobileContainerRef_current1.scrollHeight) - window.innerHeight);
155
- }
156
- }, [
157
- scrollTop,
158
- modalMobileContainerRef === null || modalMobileContainerRef === void 0 ? void 0 : modalMobileContainerRef.current,
159
- window.innerHeight
160
- ]);
161
- (0, _react.useEffect)(()=>{
162
- window.addEventListener('resize', ()=>{
163
- setContainerScrollHeight((containerScrollHeight)=>{
164
- setScrollHeight(containerScrollHeight - window.innerHeight);
165
- return containerScrollHeight;
166
- });
167
- });
168
- }, []);
169
- /* MODALS LOGIC | END */ const renderModal = (0, _react.useCallback)((modal)=>{
170
- if (!isMobile || !withMobileLogic) return modal;
171
- return /*#__PURE__*/ (0, _jsxruntime.jsx)("div", {
172
- className: "modal-mobile-container",
173
- ref: modalMobileContainerRef,
174
- children: modal
175
- });
176
- }, [
177
- isMobile,
178
- withMobileLogic
179
- ]);
180
- return {
181
- modalMobileContainerRef,
182
- modalMobileHeaderRef,
183
- modalMobileBodyRef,
184
- modalMobileFooterRef,
185
- MODALS_LOGIC: modalsLogic,
186
- SCROLL_DIRECTION,
187
- scrollTop,
188
- scrollHeight,
189
- renderModal,
190
- isMobile
191
- };
192
- }
1
+ function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function n(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function r(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n,r,l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var u=[],o=!0,i=!1;try{for(l=l.call(e);!(o=(n=l.next()).done)&&(u.push(n.value),!t||u.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{o||null==l.return||l.return()}finally{if(i)throw r}}return u}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var r=Object.prototype.toString.call(t).slice(8,-1);if("Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return e(t,n)}}(t,n)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"default",{enumerable:!0,get:function(){return a}});var l,u=require("react/jsx-runtime"),o=require("react"),i=(l=require("../../../../Functions/useIsMobile/useIsMobile"))&&l.__esModule?l:{default:l},c={UP:"up",DOWN:"down"};function a(e){var l,a,f,d,s=e.modalRef,g=e.withMobileLogic,v=void 0!==g&&g,y=e.withFixedFooter,h=void 0!==y&&y,b=e.isOpen,O=void 0!==b&&b,p=(0,o.useRef)(null),m=(0,o.useRef)(null),S=(0,o.useRef)(null),E=(0,o.useRef)(null),w=(0,i.default)().isMobile,I=r((0,o.useState)(0),2),R=I[0],_=I[1],H=r((0,o.useState)({IS_HEADER_HIDDEN:!1,IS_HEADER_STICKY:!1,IS_FOOTER_HIDDEN:!1,IS_FOOTER_STICKY:h}),2),D=H[0],j=H[1],C=r((0,o.useState)({headerHeight:0,footerHeight:0}),2),P=C[0],T=C[1],M=r((0,o.useState)(c.UP),2),A=M[0],L=M[1],N=r((0,o.useState)(0),2),F=N[0],x=N[1],B=r((0,o.useState)(0),2),K=B[0],U=B[1],Y=r((0,o.useState)(1),2),W=Y[0],k=Y[1],q=r((0,o.useState)(1),2)[1];(0,o.useLayoutEffect)(function(){var e=null==p?void 0:p.current;e&&e.addEventListener("scroll",function(){U(function(t){return t!==e.scrollTop&&x(t),e.scrollTop})})},[null==p?void 0:p.current]),(0,o.useEffect)(function(){L(function(e){return K<F?c.UP:K>F?c.DOWN:e})},[K,F]),(0,o.useLayoutEffect)(function(){if(O){var e,t,n,r,l=(null==s?void 0:s.current)?(null==s?void 0:s.current.style)||window.getComputedStyle(null==s?void 0:s.current):{},u=(null==s?void 0:s.current)?R+Number.parseFloat((null==l?void 0:l.marginTop)||"0"):0,o=document.documentElement.clientHeight||window.screen.availHeight||window.screen.height;(null==p?void 0:p.current)&&(u<=o?(p.current.style.display="flex",p.current.style.alignItems="flex-end"):(null==(t=p.current)||null==(e=t.style)||e.removeProperty("display"),null==(r=p.current)||null==(n=r.style)||n.removeProperty("align-items")))}},[P,O,w,R]),(0,o.useLayoutEffect)(function(){if(w&&O){var e,t,n=null==s||null==(t=s.current)||null==(e=t.getBoundingClientRect())?void 0:e.height;n&&R!==n&&_(n)}}),(0,o.useEffect)(function(){if(w&&v){var e=P.footerHeight,t=P.headerHeight;j(function(n){return{IS_HEADER_HIDDEN:A===c.DOWN||0===K,IS_HEADER_STICKY:A===c.UP&&0!==K&&(K>=t||n.IS_HEADER_STICKY),IS_FOOTER_HIDDEN:!h&&(A===c.UP||W===Math.round(K)),IS_FOOTER_STICKY:h&&W>1||A===c.DOWN&&(W-Math.round(K)>=e||n.IS_FOOTER_STICKY)}})}},[K,W,w,v,A,P,R,window.innerHeight]),(0,o.useLayoutEffect)(function(){var e,r;(null==m||null==(r=m.current)||null==(e=r.getBoundingClientRect())?void 0:e.height)!==void 0&&T(function(e){var r,l,u;return n(t({},e),{headerHeight:null!=(u=null==m||null==(l=m.current)||null==(r=l.getBoundingClientRect())?void 0:r.height)?u:0})})},[null==m||null==(a=m.current)||null==(l=a.getBoundingClientRect())?void 0:l.height]),(0,o.useLayoutEffect)(function(){var e,r;(null==S||null==(r=S.current)||null==(e=r.getBoundingClientRect())?void 0:e.height)!==void 0&&T(function(e){var r,l,u;return n(t({},e),{footerHeight:null!=(u=null==S||null==(l=S.current)||null==(r=l.getBoundingClientRect())?void 0:r.height)?u:0})})},[null==S||null==(d=S.current)||null==(f=d.getBoundingClientRect())?void 0:f.height]),(0,o.useEffect)(function(){if(null==p?void 0:p.current){var e,t;q(null==p||null==(e=p.current)?void 0:e.scrollHeight),k((null==p||null==(t=p.current)?void 0:t.scrollHeight)-window.innerHeight)}},[K,null==p?void 0:p.current,window.innerHeight]),(0,o.useEffect)(function(){window.addEventListener("resize",function(){q(function(e){return k(e-window.innerHeight),e})})},[]);var z=(0,o.useCallback)(function(e){return w&&v?(0,u.jsx)("div",{className:"modal-mobile-container",ref:p,children:e}):e},[w,v]);return{modalMobileContainerRef:p,modalMobileHeaderRef:m,modalMobileBodyRef:E,modalMobileFooterRef:S,MODALS_LOGIC:D,SCROLL_DIRECTION:c,scrollTop:K,scrollHeight:W,renderModal:z,isMobile:w}}
@@ -1,75 +1 @@
1
- import { fireEvent, render, screen } from '@testing-library/react';
2
-
3
- import MonoAccordion from './MonoAccordion';
4
-
5
- describe('monoAccordion', () => {
6
- const defaultProps = {
7
- titleJSX: <div>Accordion Title</div>,
8
- icon: <span>▼</span>,
9
- isOpen: false,
10
- onClick: jest.fn(),
11
- testId: 'test-accordion',
12
- };
13
-
14
- it('renders correctly with default props', () => {
15
- render(
16
- <MonoAccordion {...defaultProps}>
17
- <div>Accordion Content</div>
18
- </MonoAccordion>,
19
- );
20
-
21
- expect(screen.getByTestId('test-accordion')).toBeInTheDocument();
22
- expect(screen.getByText('Accordion Title')).toBeInTheDocument();
23
- });
24
-
25
- it('handles click events correctly', () => {
26
- render(
27
- <MonoAccordion {...defaultProps}>
28
- <div>Accordion Content</div>
29
- </MonoAccordion>,
30
- );
31
-
32
- fireEvent.click(screen.getByRole('button'));
33
- expect(defaultProps.onClick).toHaveBeenCalled();
34
- });
35
-
36
- it('applies correct classes when open', () => {
37
- render(
38
- <MonoAccordion {...defaultProps} isOpen={true}>
39
- <div>Accordion Content</div>
40
- </MonoAccordion>,
41
- );
42
-
43
- expect(screen.getByTestId('test-accordion')).toHaveClass('mono-accordion--is-open');
44
- });
45
-
46
- it('applies disabled state correctly', () => {
47
- render(
48
- <MonoAccordion {...defaultProps} disabled={true}>
49
- <div>Accordion Content</div>
50
- </MonoAccordion>,
51
- );
52
-
53
- const button = screen.getByRole('button');
54
- expect(button).toBeDisabled();
55
- expect(screen.getByTestId('test-accordion')).toHaveClass('mono-accordion--disabled');
56
- });
57
-
58
- it('handles aria attributes correctly', () => {
59
- const { rerender } = render(
60
- <MonoAccordion {...defaultProps}>
61
- <div>Accordion Content</div>
62
- </MonoAccordion>,
63
- );
64
-
65
- expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'false');
66
-
67
- rerender(
68
- <MonoAccordion {...defaultProps} isOpen={true}>
69
- <div>Accordion Content</div>
70
- </MonoAccordion>,
71
- );
72
-
73
- expect(screen.getByRole('button')).toHaveAttribute('aria-expanded', 'true');
74
- });
75
- });
1
+ function e(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),o.forEach(function(t){var o;o=n[t],t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o})}return e}function t(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);n.push.apply(n,o)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}import{jsx as n}from"react/jsx-runtime";import{fireEvent as o,render as r,screen as c}from"@testing-library/react";import i from"./MonoAccordion";describe("monoAccordion",function(){var d={titleJSX:n("div",{children:"Accordion Title"}),icon:n("span",{children:"▼"}),isOpen:!1,onClick:jest.fn(),testId:"test-accordion"};it("renders correctly with default props",function(){r(n(i,t(e({},d),{children:n("div",{children:"Accordion Content"})}))),expect(c.getByTestId("test-accordion")).toBeInTheDocument(),expect(c.getByText("Accordion Title")).toBeInTheDocument()}),it("handles click events correctly",function(){r(n(i,t(e({},d),{children:n("div",{children:"Accordion Content"})}))),o.click(c.getByRole("button")),expect(d.onClick).toHaveBeenCalled()}),it("applies correct classes when open",function(){r(n(i,t(e({},d),{isOpen:!0,children:n("div",{children:"Accordion Content"})}))),expect(c.getByTestId("test-accordion")).toHaveClass("mono-accordion--is-open")}),it("applies disabled state correctly",function(){r(n(i,t(e({},d),{disabled:!0,children:n("div",{children:"Accordion Content"})}))),expect(c.getByRole("button")).toBeDisabled(),expect(c.getByTestId("test-accordion")).toHaveClass("mono-accordion--disabled")}),it("handles aria attributes correctly",function(){var o=r(n(i,t(e({},d),{children:n("div",{children:"Accordion Content"})}))).rerender;expect(c.getByRole("button")).toHaveAttribute("aria-expanded","false"),o(n(i,t(e({},d),{isOpen:!0,children:n("div",{children:"Accordion Content"})}))),expect(c.getByRole("button")).toHaveAttribute("aria-expanded","true")})});
@@ -1,80 +1 @@
1
- import React, { useEffect, useRef, useState } from "react";
2
-
3
- import cn from "classnames";
4
-
5
- import "./MonoAccordion.scss";
6
-
7
- const RC = "mono-accordion";
8
-
9
- const MonoAccordion = ({
10
- titleJSX,
11
- icon,
12
- children,
13
- isOpen,
14
- onClick,
15
- className,
16
- disabled,
17
- testId = "mono-accordion",
18
- datasetProp = {},
19
- }) => {
20
- const [maxHeight, setMaxHeight] = useState();
21
- const titleRef = useRef();
22
- const containerRef = useRef();
23
-
24
- const setHeight = (value) => {
25
- if (value !== undefined) setMaxHeight((state) => `${value}px`);
26
- else
27
- setMaxHeight(
28
- (state) =>
29
- `${Array.from(containerRef.current?.childNodes)?.reduce?.((acc, el) => acc + el.offsetHeight, 0)}px`,
30
- );
31
- };
32
-
33
- const handleClick = (e) => {
34
- if (
35
- !Array.from(titleRef.current.childNodes).some((el) =>
36
- el.contains(e.target),
37
- )
38
- ) {
39
- onClick(e);
40
- e?.preventDefault();
41
- e?.stopPropagation();
42
- } else return e;
43
- };
44
-
45
- useEffect(() => {
46
- if (!isOpen) setHeight(0);
47
- else setHeight();
48
- }, [isOpen, children]);
49
-
50
- return (
51
- <div
52
- {...datasetProp}
53
- data-testid={testId}
54
- className={cn(RC, className, {
55
- [`${RC}_is-open`]: isOpen,
56
- [`${RC}_disabled`]: disabled,
57
- })}
58
- >
59
- <div
60
- className={`${RC}__head`}
61
- onClick={handleClick}
62
- >
63
- <div ref={titleRef} className={`${RC}__tile-container`}>
64
- {titleJSX}
65
- </div>
66
- <span className={`${RC}__icon-container`}>{icon}</span>
67
- </div>
68
-
69
- <div
70
- ref={containerRef}
71
- style={{ maxHeight }}
72
- className={cn(`${RC}__container`)}
73
- >
74
- <div className={`${RC}__content-wrapper`}>{children}</div>
75
- </div>
76
- </div>
77
- );
78
- };
79
-
80
- export default MonoAccordion;
1
+ function t(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=Array(r);e<r;e++)n[e]=t[e];return n}function r(t,r,e){return r in t?Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[r]=e,t}import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useEffect as o,useRef as c,useState as i}from"react";import a from"classnames";import"./MonoAccordion.scss";var l="mono-accordion";export default function(u){var s,f,d,p,m=u.titleJSX,y=u.icon,b=u.children,v=u.isOpen,h=u.onClick,O=u.className,g=u.disabled,j=u.testId,P=u.datasetProp,w=(s=i(),function(t){if(Array.isArray(t))return t}(s)||function(t,r){var e,n,o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var c=[],i=!0,a=!1;try{for(o=o.call(t);!(i=(e=o.next()).done)&&(c.push(e.value),c.length!==r);i=!0);}catch(t){a=!0,n=t}finally{try{i||null==o.return||o.return()}finally{if(a)throw n}}return c}}(s,2)||function(r,e){if(r){if("string"==typeof r)return t(r,2);var n=Object.prototype.toString.call(r).slice(8,-1);if("Object"===n&&r.constructor&&(n=r.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return t(r,e)}}(s,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),_=w[0],S=w[1],A=c(),N=c(),x=function(t){void 0!==t?S(function(r){return"".concat(t,"px")}):S(function(t){var r,e,n;return"".concat(null==(e=Array.from(null==(n=N.current)?void 0:n.childNodes))||null==(r=e.reduce)?void 0:r.call(e,function(t,r){return t+r.offsetHeight},0),"px")})};return o(function(){v?x():x(0)},[v,b]),n("div",(f=function(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{},o=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(o=o.concat(Object.getOwnPropertySymbols(n).filter(function(t){return Object.getOwnPropertyDescriptor(n,t).enumerable}))),o.forEach(function(e){r(t,e,n[e])})}return t}({},void 0===P?{}:P),d=d={"data-testid":void 0===j?"mono-accordion":j,className:a(l,O,(r(p={},"".concat(l,"_is-open"),v),r(p,"".concat(l,"_disabled"),g),p)),children:[n("div",{className:"".concat(l,"__head"),onClick:function(t){if(Array.from(A.current.childNodes).some(function(r){return r.contains(t.target)}))return t;h(t),null==t||t.preventDefault(),null==t||t.stopPropagation()},children:[e("div",{ref:A,className:"".concat(l,"__tile-container"),children:m}),e("span",{className:"".concat(l,"__icon-container"),children:y})]}),e("div",{ref:N,style:{maxHeight:_},className:a("".concat(l,"__container")),children:e("div",{className:"".concat(l,"__content-wrapper"),children:b})})]},Object.getOwnPropertyDescriptors?Object.defineProperties(f,Object.getOwnPropertyDescriptors(d)):(function(t,r){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e.push.apply(e,n)}return e})(Object(d)).forEach(function(t){Object.defineProperty(f,t,Object.getOwnPropertyDescriptor(d,t))}),f))}