@onewelcome/react-lib-components 13.4.0 → 14.0.0-alpha.2

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 (301) hide show
  1. package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.cjs.js +2 -2
  2. package/dist/components/Breadcrumbs/Breadcrumbs.module.scss.es.js +5 -5
  3. package/dist/components/Button/BaseButton.module.scss.cjs.js +2 -2
  4. package/dist/components/Button/BaseButton.module.scss.es.js +4 -4
  5. package/dist/components/Button/Button.module.scss.cjs.js +2 -2
  6. package/dist/components/Button/Button.module.scss.es.js +17 -17
  7. package/dist/components/Button/IconButton.module.scss.cjs.js +2 -2
  8. package/dist/components/Button/IconButton.module.scss.es.js +18 -18
  9. package/dist/components/ContextMenu/ContextMenu.cjs.js.map +1 -1
  10. package/dist/components/ContextMenu/ContextMenu.es.js.map +1 -1
  11. package/dist/components/ContextMenu/ContextMenu.module.scss.cjs.js +2 -2
  12. package/dist/components/ContextMenu/ContextMenu.module.scss.es.js +6 -6
  13. package/dist/components/ContextMenu/ContextMenuDivider.module.scss.cjs.js +2 -2
  14. package/dist/components/ContextMenu/ContextMenuDivider.module.scss.es.js +2 -2
  15. package/dist/components/ContextMenu/ContextMenuItem.cjs.js.map +1 -1
  16. package/dist/components/ContextMenu/ContextMenuItem.es.js.map +1 -1
  17. package/dist/components/ContextMenu/ContextMenuItem.module.scss.cjs.js +2 -2
  18. package/dist/components/ContextMenu/ContextMenuItem.module.scss.es.js +3 -3
  19. package/dist/components/ContextMenu/ContextMenuService.cjs.js.map +1 -1
  20. package/dist/components/ContextMenu/ContextMenuService.es.js.map +1 -1
  21. package/dist/components/DataGrid/DataGrid.cjs.js.map +1 -1
  22. package/dist/components/DataGrid/DataGrid.es.js.map +1 -1
  23. package/dist/components/DataGrid/DataGrid.module.scss.cjs.js +2 -2
  24. package/dist/components/DataGrid/DataGrid.module.scss.es.js +8 -8
  25. package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.cjs.js +2 -2
  26. package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.es.js +6 -6
  27. package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.cjs.js +2 -2
  28. package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.es.js +7 -7
  29. package/dist/components/DataGrid/DataGridBody/DataGridBody.cjs.js.map +1 -1
  30. package/dist/components/DataGrid/DataGridBody/DataGridBody.es.js.map +1 -1
  31. package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.cjs.js +2 -2
  32. package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.es.js +2 -2
  33. package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.cjs.js +2 -2
  34. package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.es.js +5 -5
  35. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.cjs.js +2 -2
  36. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.es.js +4 -4
  37. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.cjs.js +2 -2
  38. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.es.js +5 -5
  39. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.cjs.js.map +1 -1
  40. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.es.js.map +1 -1
  41. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.cjs.js +2 -2
  42. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.es.js +24 -24
  43. package/dist/components/DataGrid/DataGridBody/DataGridRow/useNestedRow.cjs.js.map +1 -1
  44. package/dist/components/DataGrid/DataGridBody/DataGridRow/useNestedRow.es.js.map +1 -1
  45. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +2 -2
  46. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.es.js +9 -9
  47. package/dist/components/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js.map +1 -1
  48. package/dist/components/DataGrid/DataGridFilters/DataGridFilterPopover.es.js.map +1 -1
  49. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
  50. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js.map +1 -1
  51. package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
  52. package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.es.js.map +1 -1
  53. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +2 -2
  54. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.es.js +10 -10
  55. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js.map +1 -1
  56. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.es.js.map +1 -1
  57. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -2
  58. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.es.js +17 -17
  59. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +2 -2
  60. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.es.js +4 -4
  61. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +2 -2
  62. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.es.js +11 -11
  63. package/dist/components/DatePicker/DatePicker.module.scss.cjs.js +2 -2
  64. package/dist/components/DatePicker/DatePicker.module.scss.es.js +31 -31
  65. package/dist/components/Form/Checkbox/Checkbox.cjs.js.map +1 -1
  66. package/dist/components/Form/Checkbox/Checkbox.es.js.map +1 -1
  67. package/dist/components/Form/Checkbox/Checkbox.module.scss.cjs.js +2 -2
  68. package/dist/components/Form/Checkbox/Checkbox.module.scss.es.js +13 -13
  69. package/dist/components/Form/Fieldset/Fieldset.cjs.js +1 -1
  70. package/dist/components/Form/Fieldset/Fieldset.cjs.js.map +1 -1
  71. package/dist/components/Form/Fieldset/Fieldset.es.js +1 -1
  72. package/dist/components/Form/Fieldset/Fieldset.es.js.map +1 -1
  73. package/dist/components/Form/Fieldset/Fieldset.module.scss.cjs.js +2 -2
  74. package/dist/components/Form/Fieldset/Fieldset.module.scss.es.js +6 -6
  75. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +2 -2
  76. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.es.js +18 -18
  77. package/dist/components/Form/FileUpload/FileUpload.module.scss.cjs.js +2 -2
  78. package/dist/components/Form/FileUpload/FileUpload.module.scss.es.js +16 -16
  79. package/dist/components/Form/Form.module.scss.cjs.js +2 -2
  80. package/dist/components/Form/Form.module.scss.es.js +2 -2
  81. package/dist/components/Form/FormControl/FormControl.cjs.js +1 -1
  82. package/dist/components/Form/FormControl/FormControl.cjs.js.map +1 -1
  83. package/dist/components/Form/FormControl/FormControl.es.js +3 -3
  84. package/dist/components/Form/FormControl/FormControl.es.js.map +1 -1
  85. package/dist/components/Form/FormControl/FormControl.module.scss.cjs.js +2 -2
  86. package/dist/components/Form/FormControl/FormControl.module.scss.es.js +13 -13
  87. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.cjs.js +2 -2
  88. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.es.js +6 -6
  89. package/dist/components/Form/FormGroup/FormGroup.cjs.js.map +1 -1
  90. package/dist/components/Form/FormGroup/FormGroup.es.js.map +1 -1
  91. package/dist/components/Form/FormGroup/FormGroup.module.scss.cjs.js +2 -2
  92. package/dist/components/Form/FormGroup/FormGroup.module.scss.es.js +3 -3
  93. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.cjs.js +2 -2
  94. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.es.js +4 -4
  95. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.cjs.js +2 -2
  96. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.es.js +6 -6
  97. package/dist/components/Form/Input/Input.module.scss.cjs.js +2 -2
  98. package/dist/components/Form/Input/Input.module.scss.es.js +8 -8
  99. package/dist/components/Form/Label/Label.module.scss.cjs.js +2 -2
  100. package/dist/components/Form/Label/Label.module.scss.es.js +2 -2
  101. package/dist/components/Form/Radio/Radio.module.scss.cjs.js +2 -2
  102. package/dist/components/Form/Radio/Radio.module.scss.es.js +11 -11
  103. package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js.map +1 -1
  104. package/dist/components/Form/Select/MultiSelect/MultiOption.es.js.map +1 -1
  105. package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
  106. package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js +3 -1
  107. package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js.map +1 -1
  108. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.cjs.js +2 -2
  109. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js +20 -20
  110. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.cjs.js +2 -2
  111. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.es.js +2 -2
  112. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.cjs.js +2 -2
  113. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.es.js +4 -4
  114. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.cjs.js.map +1 -1
  115. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.es.js.map +1 -1
  116. package/dist/components/Form/Select/Select.interfaces.cjs.js.map +1 -1
  117. package/dist/components/Form/Select/Select.interfaces.es.js.map +1 -1
  118. package/dist/components/Form/Select/SingleSelect/Option.cjs.js.map +1 -1
  119. package/dist/components/Form/Select/SingleSelect/Option.es.js.map +1 -1
  120. package/dist/components/Form/Select/SingleSelect/Select.cjs.js +1 -1
  121. package/dist/components/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
  122. package/dist/components/Form/Select/SingleSelect/Select.es.js +16 -4
  123. package/dist/components/Form/Select/SingleSelect/Select.es.js.map +1 -1
  124. package/dist/components/Form/Select/SingleSelect/Select.module.scss.cjs.js +2 -2
  125. package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js +21 -21
  126. package/dist/components/Form/Select/useAddNewBtn.cjs.js +1 -1
  127. package/dist/components/Form/Select/useAddNewBtn.cjs.js.map +1 -1
  128. package/dist/components/Form/Select/useAddNewBtn.es.js +2 -1
  129. package/dist/components/Form/Select/useAddNewBtn.es.js.map +1 -1
  130. package/dist/components/Form/Select/useAddNewBtn.module.scss.cjs.js +2 -2
  131. package/dist/components/Form/Select/useAddNewBtn.module.scss.es.js +4 -4
  132. package/dist/components/Form/Textarea/Textarea.module.scss.cjs.js +2 -2
  133. package/dist/components/Form/Textarea/Textarea.module.scss.es.js +6 -6
  134. package/dist/components/Form/Toggle/Toggle.module.scss.cjs.js +2 -2
  135. package/dist/components/Form/Toggle/Toggle.module.scss.es.js +18 -18
  136. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.cjs.js.map +1 -1
  137. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.es.js.map +1 -1
  138. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.cjs.js +2 -2
  139. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.es.js +5 -5
  140. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.cjs.js +2 -2
  141. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.es.js +5 -5
  142. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.cjs.js.map +1 -1
  143. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.es.js.map +1 -1
  144. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.cjs.js +2 -2
  145. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.es.js +3 -3
  146. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js +1 -1
  147. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js.map +1 -1
  148. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.es.js +4 -1
  149. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.es.js.map +1 -1
  150. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.cjs.js +2 -2
  151. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.es.js +5 -5
  152. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.cjs.js.map +1 -1
  153. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.es.js.map +1 -1
  154. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.cjs.js +2 -2
  155. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.es.js +3 -3
  156. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.cjs.js +2 -2
  157. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.es.js +8 -8
  158. package/dist/components/Form/Wrapper/Wrapper/Wrapper.cjs.js.map +1 -1
  159. package/dist/components/Form/Wrapper/Wrapper/Wrapper.es.js.map +1 -1
  160. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.cjs.js +2 -2
  161. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.es.js +6 -6
  162. package/dist/components/Icon/Icon.module.scss.cjs.js +2 -2
  163. package/dist/components/Icon/Icon.module.scss.es.js +108 -108
  164. package/dist/components/Layout/ActionBar/ActionBar.module.scss.cjs.js +2 -2
  165. package/dist/components/Layout/ActionBar/ActionBar.module.scss.es.js +10 -10
  166. package/dist/components/Layout/Card/Card.module.scss.cjs.js +2 -2
  167. package/dist/components/Layout/Card/Card.module.scss.es.js +12 -12
  168. package/dist/components/Layout/ContentHeader/ContentHeader.cjs.js.map +1 -1
  169. package/dist/components/Layout/ContentHeader/ContentHeader.es.js.map +1 -1
  170. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.cjs.js +2 -2
  171. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.es.js +19 -19
  172. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.cjs.js +2 -2
  173. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.es.js +4 -4
  174. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.cjs.js +2 -2
  175. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.es.js +2 -2
  176. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.cjs.js +2 -2
  177. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.es.js +3 -3
  178. package/dist/components/Link/Link.module.scss.cjs.js +2 -2
  179. package/dist/components/Link/Link.module.scss.es.js +17 -17
  180. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.cjs.js +2 -2
  181. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.es.js +11 -11
  182. package/dist/components/Notifications/Alert/AlertItem/AlertItem.cjs.js +1 -1
  183. package/dist/components/Notifications/Alert/AlertItem/AlertItem.cjs.js.map +1 -1
  184. package/dist/components/Notifications/Alert/AlertItem/AlertItem.es.js +1 -1
  185. package/dist/components/Notifications/Alert/AlertItem/AlertItem.es.js.map +1 -1
  186. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.cjs.js +2 -2
  187. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.es.js +22 -22
  188. package/dist/components/Notifications/Banner/Banner.module.scss.cjs.js +2 -2
  189. package/dist/components/Notifications/Banner/Banner.module.scss.es.js +9 -9
  190. package/dist/components/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
  191. package/dist/components/Notifications/BaseModal/BaseModal.es.js.map +1 -1
  192. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.cjs.js +2 -2
  193. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.es.js +5 -5
  194. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.cjs.js.map +1 -1
  195. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.es.js.map +1 -1
  196. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.cjs.js +2 -2
  197. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.es.js +4 -4
  198. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.cjs.js.map +1 -1
  199. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.es.js.map +1 -1
  200. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.cjs.js +2 -2
  201. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.es.js +2 -2
  202. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.cjs.js +2 -2
  203. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.es.js +6 -6
  204. package/dist/components/Notifications/Dialog/Dialog.module.scss.cjs.js +2 -2
  205. package/dist/components/Notifications/Dialog/Dialog.module.scss.es.js +4 -4
  206. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.cjs.js +2 -2
  207. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.es.js +3 -3
  208. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.cjs.js +2 -2
  209. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.es.js +10 -10
  210. package/dist/components/Notifications/DiscardChangesModal/DiscardChangesModal.cjs.js.map +1 -1
  211. package/dist/components/Notifications/DiscardChangesModal/DiscardChangesModal.es.js.map +1 -1
  212. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -2
  213. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.es.js +13 -13
  214. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -2
  215. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.es.js +2 -2
  216. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -2
  217. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.es.js +2 -2
  218. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.cjs.js +2 -2
  219. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.es.js +10 -10
  220. package/dist/components/Pagination/Pagination.module.scss.cjs.js +2 -2
  221. package/dist/components/Pagination/Pagination.module.scss.es.js +15 -15
  222. package/dist/components/Popover/Popover.cjs.js.map +1 -1
  223. package/dist/components/Popover/Popover.es.js.map +1 -1
  224. package/dist/components/Popover/Popover.module.scss.cjs.js +2 -2
  225. package/dist/components/Popover/Popover.module.scss.es.js +3 -3
  226. package/dist/components/ProgressBar/ProgressBar.module.scss.cjs.js +2 -2
  227. package/dist/components/ProgressBar/ProgressBar.module.scss.es.js +9 -9
  228. package/dist/components/Skeleton/Skeleton.module.scss.cjs.js +2 -2
  229. package/dist/components/Skeleton/Skeleton.module.scss.es.js +5 -5
  230. package/dist/components/Spinner/Spinner.module.scss.cjs.js +2 -2
  231. package/dist/components/Spinner/Spinner.module.scss.es.js +3 -3
  232. package/dist/components/Stepper/Step.module.scss.cjs.js +2 -2
  233. package/dist/components/Stepper/Step.module.scss.es.js +22 -22
  234. package/dist/components/Stepper/Stepper.module.scss.cjs.js +2 -2
  235. package/dist/components/Stepper/Stepper.module.scss.es.js +4 -4
  236. package/dist/components/Tabs/Tab.module.scss.cjs.js +2 -2
  237. package/dist/components/Tabs/Tab.module.scss.es.js +3 -3
  238. package/dist/components/Tabs/TabButton.cjs.js.map +1 -1
  239. package/dist/components/Tabs/TabButton.es.js.map +1 -1
  240. package/dist/components/Tabs/TabButton.module.scss.cjs.js +2 -2
  241. package/dist/components/Tabs/TabButton.module.scss.es.js +12 -12
  242. package/dist/components/Tabs/Tabs.cjs.js.map +1 -1
  243. package/dist/components/Tabs/Tabs.es.js.map +1 -1
  244. package/dist/components/Tabs/Tabs.module.scss.cjs.js +2 -2
  245. package/dist/components/Tabs/Tabs.module.scss.es.js +10 -10
  246. package/dist/components/Tag/RemoveButton.module.scss.cjs.js +2 -2
  247. package/dist/components/Tag/RemoveButton.module.scss.es.js +3 -3
  248. package/dist/components/Tag/Tag.module.scss.cjs.js +2 -2
  249. package/dist/components/Tag/Tag.module.scss.es.js +6 -6
  250. package/dist/components/TextEllipsis/TextEllipsis.module.scss.cjs.js +2 -2
  251. package/dist/components/TextEllipsis/TextEllipsis.module.scss.es.js +3 -3
  252. package/dist/components/Tiles/Tile.module.scss.cjs.js +2 -2
  253. package/dist/components/Tiles/Tile.module.scss.es.js +8 -8
  254. package/dist/components/Tiles/Tiles.module.scss.cjs.js +2 -2
  255. package/dist/components/Tiles/Tiles.module.scss.es.js +2 -2
  256. package/dist/components/Tooltip/Tooltip.cjs.js.map +1 -1
  257. package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
  258. package/dist/components/Tooltip/Tooltip.module.scss.cjs.js +2 -2
  259. package/dist/components/Tooltip/Tooltip.module.scss.es.js +28 -28
  260. package/dist/components/Typography/Typography.module.scss.cjs.js +2 -2
  261. package/dist/components/Typography/Typography.module.scss.es.js +13 -13
  262. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.cjs.js +2 -2
  263. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.es.js +5 -5
  264. package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.cjs.js.map +1 -1
  265. package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.es.js +3 -1
  266. package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.es.js.map +1 -1
  267. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.cjs.js +2 -2
  268. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.es.js +14 -14
  269. package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.cjs.js.map +1 -1
  270. package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.es.js +6 -2
  271. package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.es.js.map +1 -1
  272. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.cjs.js +2 -2
  273. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.es.js +3 -3
  274. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.cjs.js +2 -2
  275. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.es.js +7 -7
  276. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.cjs.js +2 -2
  277. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.es.js +13 -13
  278. package/dist/components/miscellaneous/IdentityProviderButton.cjs.js.map +1 -1
  279. package/dist/components/miscellaneous/IdentityProviderButton.es.js.map +1 -1
  280. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.cjs.js +2 -2
  281. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.es.js +3 -3
  282. package/dist/hooks/useClickOutside.cjs.js.map +1 -1
  283. package/dist/hooks/useClickOutside.es.js.map +1 -1
  284. package/dist/hooks/useDebouncedCallback.cjs.js +1 -1
  285. package/dist/hooks/useDebouncedCallback.cjs.js.map +1 -1
  286. package/dist/hooks/useDebouncedCallback.es.js +1 -1
  287. package/dist/hooks/useDebouncedCallback.es.js.map +1 -1
  288. package/dist/hooks/useGetDomRoot.cjs.js.map +1 -1
  289. package/dist/hooks/useGetDomRoot.es.js.map +1 -1
  290. package/dist/hooks/usePosition.cjs.js.map +1 -1
  291. package/dist/hooks/usePosition.es.js.map +1 -1
  292. package/dist/hooks/useRepeatFocus.cjs.js.map +1 -1
  293. package/dist/hooks/useRepeatFocus.es.js.map +1 -1
  294. package/dist/index.d.ts +21 -19
  295. package/dist/node_modules/tabbable/dist/index.esm.cjs.js +1 -1
  296. package/dist/node_modules/tabbable/dist/index.esm.cjs.js.map +1 -1
  297. package/dist/node_modules/tabbable/dist/index.esm.es.js +4 -3
  298. package/dist/node_modules/tabbable/dist/index.esm.es.js.map +1 -1
  299. package/dist/readyclasses.module.scss.cjs.js +2 -2
  300. package/dist/readyclasses.module.scss.es.js +5 -5
  301. package/package.json +9 -9
@@ -1 +1 @@
1
- {"version":3,"file":"IdentityProviderButton.cjs.js","sources":["../../../src/components/miscellaneous/IdentityProviderButton.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentPropsWithRef, CSSProperties, ForwardRefRenderFunction } from \"react\";\nimport classes from \"./IdentityProviderButton.module.scss\";\nimport { Button } from \"../Button/Button\";\n\nexport interface SupportedCustomizationKeys {\n backgroundColor: string;\n focusBorderColor: string;\n focusBackgroundColor: string;\n hoverBackgroundColor: string;\n pressedBackgroundColor: string;\n textColor: string;\n borderColor: string;\n}\n\nexport interface Props extends Omit<ComponentPropsWithRef<\"button\">, \"color\"> {\n iconUrl?: string;\n imgAltText?: string;\n idpType: string;\n customization?: SupportedCustomizationKeys;\n loading?: boolean;\n}\n\nexport const IdentityProviderButton: ForwardRefRenderFunction<HTMLButtonElement, Props> = ({\n children,\n iconUrl,\n imgAltText,\n idpType,\n customization,\n loading,\n ...rest\n}) => {\n const DEFAULT_BACKGROUND_COLOR = \"#FFFFFF\";\n const DEFAULT_BORDER_COLOR = \"#000000\";\n const DEFAULT_TEXT_COLOR = \"#000000\";\n const DEFAULT_FOCUS_OUTLINE_COLOR = \"var(--color-black50)\";\n const DEFAULT_HOVER_COLOR = \"var(--color-black10)\";\n const DEFAULT_PRESSED_COLOR = \"var(--color-black20)\";\n\n const generateCSSProperties = () => {\n return {\n \"--button-fill-primary-default-color\":\n customization?.backgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n borderColor: customization?.borderColor ?? DEFAULT_BORDER_COLOR,\n \"--button-fill-text-color\": customization?.textColor ?? DEFAULT_TEXT_COLOR,\n \"--color-focus\": customization?.focusBorderColor ?? DEFAULT_FOCUS_OUTLINE_COLOR,\n \"--button-fill-primary-focused-color\":\n customization?.focusBackgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n \"--button-fill-primary-hover-color\":\n customization?.hoverBackgroundColor ?? DEFAULT_HOVER_COLOR,\n \"--button-fill-primary-pressed-color\":\n customization?.pressedBackgroundColor ?? DEFAULT_PRESSED_COLOR\n } as CSSProperties;\n };\n\n return (\n <Button\n style={generateCSSProperties()}\n color=\"primary\"\n variant=\"fill\"\n className={classes[\"idp-button\"]}\n loading={loading}\n {...rest}\n >\n <span className={classes[\"idp-button--with-icon\"]}>\n <img\n height={24}\n width={24}\n aria-hidden={!imgAltText}\n src={iconUrl || `/ui-resources-static/common/idb/icons/${idpType}.svg`}\n alt={imgAltText || \"Identity Provider icon\"}\n />\n {children}\n </span>\n </Button>\n );\n};\n"],"names":["children","iconUrl","imgAltText","idpType","customization","loading","rest","DEFAULT_BACKGROUND_COLOR","React","createElement","Button","style","backgroundColor","borderColor","textColor","focusBorderColor","focusBackgroundColor","hoverBackgroundColor","pressedBackgroundColor","color","variant","className","classes","height","width","src","alt"],"mappings":"sOAsC0F,EACxFA,WACAC,UACAC,aACAC,UACAC,gBACAC,aACGC,MAEH,MAAMC,EAA2B,UAuBjC,OACEC,EAAAC,cAACC,EAAAA,OAAA,CACCC,MAjBK,CACL,6CACEP,WAAeQ,kBAAmBL,EACpCM,mBAAaT,WAAeS,cAVH,UAWzB,kCAA4BT,WAAeU,YAVpB,UAWvB,uBAAiBV,WAAeW,mBAVA,uBAWhC,6CACEX,WAAeY,uBAAwBT,EACzC,2CACEH,WAAea,uBAbO,uBAcxB,6CACEb,WAAec,yBAdS,wBAqB1BC,MAAM,UACNC,QAAQ,OACRC,UAAWC,EAAAA,QAAQ,cACnBjB,aACIC,GAEJE,EAAAC,cAAC,OAAA,CAAKY,UAAWC,EAAAA,QAAQ,0BACvBd,EAAAC,cAAC,MAAA,CACCc,OAAQ,GACRC,MAAO,GACP,eAActB,EACduB,IAAKxB,GAAW,yCAAyCE,QACzDuB,IAAKxB,GAAc,2BAEpBF"}
1
+ {"version":3,"file":"IdentityProviderButton.cjs.js","sources":["../../../src/components/miscellaneous/IdentityProviderButton.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentPropsWithRef, CSSProperties, FunctionComponent } from \"react\";\nimport classes from \"./IdentityProviderButton.module.scss\";\nimport { Button } from \"../Button/Button\";\n\nexport interface SupportedCustomizationKeys {\n backgroundColor: string;\n focusBorderColor: string;\n focusBackgroundColor: string;\n hoverBackgroundColor: string;\n pressedBackgroundColor: string;\n textColor: string;\n borderColor: string;\n}\n\nexport interface Props extends Omit<ComponentPropsWithRef<\"button\">, \"color\"> {\n iconUrl?: string;\n imgAltText?: string;\n idpType: string;\n customization?: SupportedCustomizationKeys;\n loading?: boolean;\n}\n\nexport const IdentityProviderButton: FunctionComponent<Props> = ({\n children,\n iconUrl,\n imgAltText,\n idpType,\n customization,\n loading,\n ...rest\n}) => {\n const DEFAULT_BACKGROUND_COLOR = \"#FFFFFF\";\n const DEFAULT_BORDER_COLOR = \"#000000\";\n const DEFAULT_TEXT_COLOR = \"#000000\";\n const DEFAULT_FOCUS_OUTLINE_COLOR = \"var(--color-black50)\";\n const DEFAULT_HOVER_COLOR = \"var(--color-black10)\";\n const DEFAULT_PRESSED_COLOR = \"var(--color-black20)\";\n\n const generateCSSProperties = () => {\n return {\n \"--button-fill-primary-default-color\":\n customization?.backgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n borderColor: customization?.borderColor ?? DEFAULT_BORDER_COLOR,\n \"--button-fill-text-color\": customization?.textColor ?? DEFAULT_TEXT_COLOR,\n \"--color-focus\": customization?.focusBorderColor ?? DEFAULT_FOCUS_OUTLINE_COLOR,\n \"--button-fill-primary-focused-color\":\n customization?.focusBackgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n \"--button-fill-primary-hover-color\":\n customization?.hoverBackgroundColor ?? DEFAULT_HOVER_COLOR,\n \"--button-fill-primary-pressed-color\":\n customization?.pressedBackgroundColor ?? DEFAULT_PRESSED_COLOR\n } as CSSProperties;\n };\n\n return (\n <Button\n style={generateCSSProperties()}\n color=\"primary\"\n variant=\"fill\"\n className={classes[\"idp-button\"]}\n loading={loading}\n {...rest}\n >\n <span className={classes[\"idp-button--with-icon\"]}>\n <img\n height={24}\n width={24}\n aria-hidden={!imgAltText}\n src={iconUrl || `/ui-resources-static/common/idb/icons/${idpType}.svg`}\n alt={imgAltText || \"Identity Provider icon\"}\n />\n {children}\n </span>\n </Button>\n );\n};\n"],"names":["children","iconUrl","imgAltText","idpType","customization","loading","rest","DEFAULT_BACKGROUND_COLOR","React","createElement","Button","style","backgroundColor","borderColor","textColor","focusBorderColor","focusBackgroundColor","hoverBackgroundColor","pressedBackgroundColor","color","variant","className","classes","height","width","src","alt"],"mappings":"sOAsCgE,EAC9DA,WACAC,UACAC,aACAC,UACAC,gBACAC,aACGC,MAEH,MAAMC,EAA2B,UAuBjC,OACEC,EAAAC,cAACC,EAAAA,OAAA,CACCC,MAjBK,CACL,6CACEP,WAAeQ,kBAAmBL,EACpCM,mBAAaT,WAAeS,cAVH,UAWzB,kCAA4BT,WAAeU,YAVpB,UAWvB,uBAAiBV,WAAeW,mBAVA,uBAWhC,6CACEX,WAAeY,uBAAwBT,EACzC,2CACEH,WAAea,uBAbO,uBAcxB,6CACEb,WAAec,yBAdS,wBAqB1BC,MAAM,UACNC,QAAQ,OACRC,UAAWC,EAAAA,QAAQ,cACnBjB,aACIC,GAEJE,EAAAC,cAAC,OAAA,CAAKY,UAAWC,EAAAA,QAAQ,0BACvBd,EAAAC,cAAC,MAAA,CACCc,OAAQ,GACRC,MAAO,GACP,eAActB,EACduB,IAAKxB,GAAW,yCAAyCE,QACzDuB,IAAKxB,GAAc,2BAEpBF"}
@@ -1 +1 @@
1
- {"version":3,"file":"IdentityProviderButton.es.js","sources":["../../../src/components/miscellaneous/IdentityProviderButton.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentPropsWithRef, CSSProperties, ForwardRefRenderFunction } from \"react\";\nimport classes from \"./IdentityProviderButton.module.scss\";\nimport { Button } from \"../Button/Button\";\n\nexport interface SupportedCustomizationKeys {\n backgroundColor: string;\n focusBorderColor: string;\n focusBackgroundColor: string;\n hoverBackgroundColor: string;\n pressedBackgroundColor: string;\n textColor: string;\n borderColor: string;\n}\n\nexport interface Props extends Omit<ComponentPropsWithRef<\"button\">, \"color\"> {\n iconUrl?: string;\n imgAltText?: string;\n idpType: string;\n customization?: SupportedCustomizationKeys;\n loading?: boolean;\n}\n\nexport const IdentityProviderButton: ForwardRefRenderFunction<HTMLButtonElement, Props> = ({\n children,\n iconUrl,\n imgAltText,\n idpType,\n customization,\n loading,\n ...rest\n}) => {\n const DEFAULT_BACKGROUND_COLOR = \"#FFFFFF\";\n const DEFAULT_BORDER_COLOR = \"#000000\";\n const DEFAULT_TEXT_COLOR = \"#000000\";\n const DEFAULT_FOCUS_OUTLINE_COLOR = \"var(--color-black50)\";\n const DEFAULT_HOVER_COLOR = \"var(--color-black10)\";\n const DEFAULT_PRESSED_COLOR = \"var(--color-black20)\";\n\n const generateCSSProperties = () => {\n return {\n \"--button-fill-primary-default-color\":\n customization?.backgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n borderColor: customization?.borderColor ?? DEFAULT_BORDER_COLOR,\n \"--button-fill-text-color\": customization?.textColor ?? DEFAULT_TEXT_COLOR,\n \"--color-focus\": customization?.focusBorderColor ?? DEFAULT_FOCUS_OUTLINE_COLOR,\n \"--button-fill-primary-focused-color\":\n customization?.focusBackgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n \"--button-fill-primary-hover-color\":\n customization?.hoverBackgroundColor ?? DEFAULT_HOVER_COLOR,\n \"--button-fill-primary-pressed-color\":\n customization?.pressedBackgroundColor ?? DEFAULT_PRESSED_COLOR\n } as CSSProperties;\n };\n\n return (\n <Button\n style={generateCSSProperties()}\n color=\"primary\"\n variant=\"fill\"\n className={classes[\"idp-button\"]}\n loading={loading}\n {...rest}\n >\n <span className={classes[\"idp-button--with-icon\"]}>\n <img\n height={24}\n width={24}\n aria-hidden={!imgAltText}\n src={iconUrl || `/ui-resources-static/common/idb/icons/${idpType}.svg`}\n alt={imgAltText || \"Identity Provider icon\"}\n />\n {children}\n </span>\n </Button>\n );\n};\n"],"names":[],"mappings":";;;AAsCO,MAAM,yBAA6E,CAAC;AAAA,EACzF;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,2BAA2B;AACjC,QAAM,uBAAuB;AAC7B,QAAM,qBAAqB;AAC3B,QAAM,8BAA8B;AACpC,QAAM,sBAAsB;AAC5B,QAAM,wBAAwB;AAE9B,QAAM,wBAAwB,MAAM;AAClC,WAAO;AAAA,MACL,wCACE,+CAAe,oBAAmB;AAAA,MACpC,cAAa,+CAAe,gBAAe;AAAA,MAC3C,6BAA4B,+CAAe,cAAa;AAAA,MACxD,kBAAiB,+CAAe,qBAAoB;AAAA,MACpD,wCACE,+CAAe,yBAAwB;AAAA,MACzC,sCACE,+CAAe,yBAAwB;AAAA,MACzC,wCACE,+CAAe,2BAA0B;AAAA,IAAA;AAAA,EAE/C;AAEA,SACE,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,sBAAA;AAAA,MACP,OAAM;AAAA,MACN,SAAQ;AAAA,MACR,WAAW,QAAQ,YAAY;AAAA,MAC/B;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,IAEJ,sBAAA,cAAC,QAAA,EAAK,WAAW,QAAQ,uBAAuB,KAC9C,sBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,eAAa,CAAC;AAAA,QACd,KAAK,WAAW,yCAAyC,OAAO;AAAA,QAChE,KAAK,cAAc;AAAA,MAAA;AAAA,IAAA,GAEpB,QACH;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"IdentityProviderButton.es.js","sources":["../../../src/components/miscellaneous/IdentityProviderButton.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { ComponentPropsWithRef, CSSProperties, FunctionComponent } from \"react\";\nimport classes from \"./IdentityProviderButton.module.scss\";\nimport { Button } from \"../Button/Button\";\n\nexport interface SupportedCustomizationKeys {\n backgroundColor: string;\n focusBorderColor: string;\n focusBackgroundColor: string;\n hoverBackgroundColor: string;\n pressedBackgroundColor: string;\n textColor: string;\n borderColor: string;\n}\n\nexport interface Props extends Omit<ComponentPropsWithRef<\"button\">, \"color\"> {\n iconUrl?: string;\n imgAltText?: string;\n idpType: string;\n customization?: SupportedCustomizationKeys;\n loading?: boolean;\n}\n\nexport const IdentityProviderButton: FunctionComponent<Props> = ({\n children,\n iconUrl,\n imgAltText,\n idpType,\n customization,\n loading,\n ...rest\n}) => {\n const DEFAULT_BACKGROUND_COLOR = \"#FFFFFF\";\n const DEFAULT_BORDER_COLOR = \"#000000\";\n const DEFAULT_TEXT_COLOR = \"#000000\";\n const DEFAULT_FOCUS_OUTLINE_COLOR = \"var(--color-black50)\";\n const DEFAULT_HOVER_COLOR = \"var(--color-black10)\";\n const DEFAULT_PRESSED_COLOR = \"var(--color-black20)\";\n\n const generateCSSProperties = () => {\n return {\n \"--button-fill-primary-default-color\":\n customization?.backgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n borderColor: customization?.borderColor ?? DEFAULT_BORDER_COLOR,\n \"--button-fill-text-color\": customization?.textColor ?? DEFAULT_TEXT_COLOR,\n \"--color-focus\": customization?.focusBorderColor ?? DEFAULT_FOCUS_OUTLINE_COLOR,\n \"--button-fill-primary-focused-color\":\n customization?.focusBackgroundColor ?? DEFAULT_BACKGROUND_COLOR,\n \"--button-fill-primary-hover-color\":\n customization?.hoverBackgroundColor ?? DEFAULT_HOVER_COLOR,\n \"--button-fill-primary-pressed-color\":\n customization?.pressedBackgroundColor ?? DEFAULT_PRESSED_COLOR\n } as CSSProperties;\n };\n\n return (\n <Button\n style={generateCSSProperties()}\n color=\"primary\"\n variant=\"fill\"\n className={classes[\"idp-button\"]}\n loading={loading}\n {...rest}\n >\n <span className={classes[\"idp-button--with-icon\"]}>\n <img\n height={24}\n width={24}\n aria-hidden={!imgAltText}\n src={iconUrl || `/ui-resources-static/common/idb/icons/${idpType}.svg`}\n alt={imgAltText || \"Identity Provider icon\"}\n />\n {children}\n </span>\n </Button>\n );\n};\n"],"names":[],"mappings":";;;AAsCO,MAAM,yBAAmD,CAAC;AAAA,EAC/D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,QAAM,2BAA2B;AACjC,QAAM,uBAAuB;AAC7B,QAAM,qBAAqB;AAC3B,QAAM,8BAA8B;AACpC,QAAM,sBAAsB;AAC5B,QAAM,wBAAwB;AAE9B,QAAM,wBAAwB,MAAM;AAClC,WAAO;AAAA,MACL,wCACE,+CAAe,oBAAmB;AAAA,MACpC,cAAa,+CAAe,gBAAe;AAAA,MAC3C,6BAA4B,+CAAe,cAAa;AAAA,MACxD,kBAAiB,+CAAe,qBAAoB;AAAA,MACpD,wCACE,+CAAe,yBAAwB;AAAA,MACzC,sCACE,+CAAe,yBAAwB;AAAA,MACzC,wCACE,+CAAe,2BAA0B;AAAA,IAAA;AAAA,EAE/C;AAEA,SACE,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,OAAO,sBAAA;AAAA,MACP,OAAM;AAAA,MACN,SAAQ;AAAA,MACR,WAAW,QAAQ,YAAY;AAAA,MAC/B;AAAA,MACC,GAAG;AAAA,IAAA;AAAA,IAEJ,sBAAA,cAAC,QAAA,EAAK,WAAW,QAAQ,uBAAuB,KAC9C,sBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,QAAQ;AAAA,QACR,OAAO;AAAA,QACP,eAAa,CAAC;AAAA,QACd,KAAK,WAAW,yCAAyC,OAAO;AAAA,QAChE,KAAK,cAAc;AAAA,MAAA;AAAA,IAAA,GAEpB,QACH;AAAA,EAAA;AAGN;"}
@@ -1,3 +1,3 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.IdentityProviderButton_sr-only_ZXWS5{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_ZXWS5{display:none}.IdentityProviderButton_slide-in_ZXWS5{animation:IdentityProviderButton_slide-in_ZXWS5 .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_ZXWS5{animation-duration:.1ms}}.IdentityProviderButton_slide-out_ZXWS5{animation:IdentityProviderButton_slide-out_ZXWS5 .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_ZXWS5{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_ZXWS5{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_ZXWS5{0%{transform:translateY(0)}to{transform:translateY(100vh)}}/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.IdentityProviderButton_idp-button_ZXWS5{width:100%}.IdentityProviderButton_idp-button--with-icon_ZXWS5{display:flex;align-items:center;justify-content:center;gap:.5rem;margin-top:-.125rem;margin-bottom:-.125rem}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
2
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default={"idp-button":"IdentityProviderButton_idp-button_ZXWS5","idp-button--with-icon":"IdentityProviderButton_idp-button--with-icon_ZXWS5"};
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.IdentityProviderButton_sr-only_lUyNk{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_lUyNk{display:none}.IdentityProviderButton_slide-in_lUyNk{animation:IdentityProviderButton_slide-in_lUyNk .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_lUyNk{animation-duration:.1ms}}.IdentityProviderButton_slide-out_lUyNk{animation:IdentityProviderButton_slide-out_lUyNk .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_lUyNk{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_lUyNk{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_lUyNk{0%{transform:translateY(0)}to{transform:translateY(100vh)}}/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.IdentityProviderButton_idp-button_lUyNk{width:100%}.IdentityProviderButton_idp-button--with-icon_lUyNk{display:flex;align-items:center;justify-content:center;gap:.5rem;margin-top:-.125rem;margin-bottom:-.125rem}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
2
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),exports.default={"idp-button":"IdentityProviderButton_idp-button_lUyNk","idp-button--with-icon":"IdentityProviderButton_idp-button--with-icon_lUyNk"};
3
3
  //# sourceMappingURL=IdentityProviderButton.module.scss.cjs.js.map
@@ -1,7 +1,7 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.IdentityProviderButton_sr-only_ZXWS5{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_ZXWS5{display:none}.IdentityProviderButton_slide-in_ZXWS5{animation:IdentityProviderButton_slide-in_ZXWS5 .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_ZXWS5{animation-duration:.1ms}}.IdentityProviderButton_slide-out_ZXWS5{animation:IdentityProviderButton_slide-out_ZXWS5 .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_ZXWS5{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_ZXWS5{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_ZXWS5{0%{transform:translateY(0)}to{transform:translateY(100vh)}}/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.IdentityProviderButton_idp-button_ZXWS5{width:100%}.IdentityProviderButton_idp-button--with-icon_ZXWS5{display:flex;align-items:center;justify-content:center;gap:.5rem;margin-top:-.125rem;margin-bottom:-.125rem}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.IdentityProviderButton_sr-only_lUyNk{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_lUyNk{display:none}.IdentityProviderButton_slide-in_lUyNk{animation:IdentityProviderButton_slide-in_lUyNk .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_lUyNk{animation-duration:.1ms}}.IdentityProviderButton_slide-out_lUyNk{animation:IdentityProviderButton_slide-out_lUyNk .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_lUyNk{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_lUyNk{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_lUyNk{0%{transform:translateY(0)}to{transform:translateY(100vh)}}/*!\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the "License");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an "AS IS" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */.IdentityProviderButton_idp-button_lUyNk{width:100%}.IdentityProviderButton_idp-button--with-icon_lUyNk{display:flex;align-items:center;justify-content:center;gap:.5rem;margin-top:-.125rem;margin-bottom:-.125rem}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}}();
2
2
  const classes = {
3
- "idp-button": "IdentityProviderButton_idp-button_ZXWS5",
4
- "idp-button--with-icon": "IdentityProviderButton_idp-button--with-icon_ZXWS5"
3
+ "idp-button": "IdentityProviderButton_idp-button_lUyNk",
4
+ "idp-button--with-icon": "IdentityProviderButton_idp-button--with-icon_lUyNk"
5
5
  };
6
6
  export {
7
7
  classes as default
@@ -1 +1 @@
1
- {"version":3,"file":"useClickOutside.cjs.js","sources":["../../src/hooks/useClickOutside.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DependencyList, useEffect } from \"react\";\n\nexport const useClickOutside = (\n myElementRef: React.RefObject<HTMLElement>,\n onClickOutside: (event: MouseEvent) => void,\n dependencies?: DependencyList\n) => {\n function eventListener(event: MouseEvent) {\n const myElement = myElementRef?.current;\n if (!myElement) {\n return;\n }\n const clickedInsideMyElement = event.composedPath().includes(myElement);\n\n if (!clickedInsideMyElement) {\n onClickOutside(event);\n }\n }\n useEffect(() => {\n setTimeout(() => window.addEventListener(\"click\", eventListener));\n\n return () => {\n setTimeout(() => window.removeEventListener(\"click\", eventListener));\n };\n }, dependencies);\n};\n"],"names":["myElementRef","onClickOutside","dependencies","eventListener","event","myElement","current","composedPath","includes","useEffect","setTimeout","window","addEventListener","removeEventListener"],"mappings":"iIAkB+B,CAC7BA,EACAC,EACAC,KAEA,SAASC,EAAcC,GACrB,MAAMC,EAAY,MAAAL,OAAA,EAAAA,EAAcM,QAC3BD,IAG0BD,EAAMG,eAAeC,SAASH,IAG3DJ,EAAeG,GAEnB,CACAK,EAAAA,UAAU,KACRC,WAAW,IAAMC,OAAOC,iBAAiB,QAAST,IAE3C,KACLO,WAAW,IAAMC,OAAOE,oBAAoB,QAASV,MAEtDD"}
1
+ {"version":3,"file":"useClickOutside.cjs.js","sources":["../../src/hooks/useClickOutside.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DependencyList, useEffect } from \"react\";\n\nexport const useClickOutside = (\n myElementRef: React.RefObject<HTMLElement | null>,\n onClickOutside: (event: MouseEvent) => void,\n dependencies?: DependencyList\n) => {\n function eventListener(event: MouseEvent) {\n const myElement = myElementRef?.current;\n if (!myElement) {\n return;\n }\n const clickedInsideMyElement = event.composedPath().includes(myElement);\n\n if (!clickedInsideMyElement) {\n onClickOutside(event);\n }\n }\n useEffect(() => {\n setTimeout(() => window.addEventListener(\"click\", eventListener));\n\n return () => {\n setTimeout(() => window.removeEventListener(\"click\", eventListener));\n };\n }, dependencies);\n};\n"],"names":["myElementRef","onClickOutside","dependencies","eventListener","event","myElement","current","composedPath","includes","useEffect","setTimeout","window","addEventListener","removeEventListener"],"mappings":"iIAkB+B,CAC7BA,EACAC,EACAC,KAEA,SAASC,EAAcC,GACrB,MAAMC,EAAY,MAAAL,OAAA,EAAAA,EAAcM,QAC3BD,IAG0BD,EAAMG,eAAeC,SAASH,IAG3DJ,EAAeG,GAEnB,CACAK,EAAAA,UAAU,KACRC,WAAW,IAAMC,OAAOC,iBAAiB,QAAST,IAE3C,KACLO,WAAW,IAAMC,OAAOE,oBAAoB,QAASV,MAEtDD"}
@@ -1 +1 @@
1
- {"version":3,"file":"useClickOutside.es.js","sources":["../../src/hooks/useClickOutside.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DependencyList, useEffect } from \"react\";\n\nexport const useClickOutside = (\n myElementRef: React.RefObject<HTMLElement>,\n onClickOutside: (event: MouseEvent) => void,\n dependencies?: DependencyList\n) => {\n function eventListener(event: MouseEvent) {\n const myElement = myElementRef?.current;\n if (!myElement) {\n return;\n }\n const clickedInsideMyElement = event.composedPath().includes(myElement);\n\n if (!clickedInsideMyElement) {\n onClickOutside(event);\n }\n }\n useEffect(() => {\n setTimeout(() => window.addEventListener(\"click\", eventListener));\n\n return () => {\n setTimeout(() => window.removeEventListener(\"click\", eventListener));\n };\n }, dependencies);\n};\n"],"names":[],"mappings":";AAkBO,MAAM,kBAAkB,CAC7B,cACA,gBACA,iBACG;AACH,WAAS,cAAc,OAAmB;AACxC,UAAM,YAAY,6CAAc;AAChC,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AACA,UAAM,yBAAyB,MAAM,aAAA,EAAe,SAAS,SAAS;AAEtE,QAAI,CAAC,wBAAwB;AAC3B,qBAAe,KAAK;AAAA,IACtB;AAAA,EACF;AACA,YAAU,MAAM;AACd,eAAW,MAAM,OAAO,iBAAiB,SAAS,aAAa,CAAC;AAEhE,WAAO,MAAM;AACX,iBAAW,MAAM,OAAO,oBAAoB,SAAS,aAAa,CAAC;AAAA,IACrE;AAAA,EACF,GAAG,YAAY;AACjB;"}
1
+ {"version":3,"file":"useClickOutside.es.js","sources":["../../src/hooks/useClickOutside.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DependencyList, useEffect } from \"react\";\n\nexport const useClickOutside = (\n myElementRef: React.RefObject<HTMLElement | null>,\n onClickOutside: (event: MouseEvent) => void,\n dependencies?: DependencyList\n) => {\n function eventListener(event: MouseEvent) {\n const myElement = myElementRef?.current;\n if (!myElement) {\n return;\n }\n const clickedInsideMyElement = event.composedPath().includes(myElement);\n\n if (!clickedInsideMyElement) {\n onClickOutside(event);\n }\n }\n useEffect(() => {\n setTimeout(() => window.addEventListener(\"click\", eventListener));\n\n return () => {\n setTimeout(() => window.removeEventListener(\"click\", eventListener));\n };\n }, dependencies);\n};\n"],"names":[],"mappings":";AAkBO,MAAM,kBAAkB,CAC7B,cACA,gBACA,iBACG;AACH,WAAS,cAAc,OAAmB;AACxC,UAAM,YAAY,6CAAc;AAChC,QAAI,CAAC,WAAW;AACd;AAAA,IACF;AACA,UAAM,yBAAyB,MAAM,aAAA,EAAe,SAAS,SAAS;AAEtE,QAAI,CAAC,wBAAwB;AAC3B,qBAAe,KAAK;AAAA,IACtB;AAAA,EACF;AACA,YAAU,MAAM;AACd,eAAW,MAAM,OAAO,iBAAiB,SAAS,aAAa,CAAC;AAEhE,WAAO,MAAM;AACX,iBAAW,MAAM,OAAO,oBAAoB,SAAS,aAAa,CAAC;AAAA,IACrE;AAAA,EACF,GAAG,YAAY;AACjB;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useDebouncedCallback=(r,t,u)=>{const c=e.useRef(),l=u?[r,t,...u]:[r,t],n=e.useCallback((...e)=>{null!=c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{r(...e)},t)},l),a=e.useCallback(()=>{null!=c.current&&(clearTimeout(c.current),c.current=void 0)},[]);return Object.assign(n,{cancel:a})};
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react");exports.useDebouncedCallback=(r,t,u)=>{const c=e.useRef(void 0),l=u?[r,t,...u]:[r,t],n=e.useCallback((...e)=>{null!=c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{r(...e)},t)},l),o=e.useCallback(()=>{null!=c.current&&(clearTimeout(c.current),c.current=void 0)},[]);return Object.assign(n,{cancel:o})};
2
2
  //# sourceMappingURL=useDebouncedCallback.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDebouncedCallback.cjs.js","sources":["../../src/hooks/useDebouncedCallback.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\n\nexport const useDebouncedCallback = <T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n dependencies?: React.DependencyList\n) => {\n const timeout = React.useRef<ReturnType<typeof setTimeout>>();\n const comboDeps = dependencies ? [callback, delay, ...dependencies] : [callback, delay];\n\n const debounced = React.useCallback((...args: T) => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n }\n\n timeout.current = setTimeout(() => {\n callback(...args);\n }, delay);\n }, comboDeps);\n\n const cancel = React.useCallback(() => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n timeout.current = undefined;\n }\n }, []);\n\n return Object.assign(debounced, { cancel });\n};\n"],"names":["callback","delay","dependencies","timeout","React","useRef","comboDeps","debounced","useCallback","args","current","clearTimeout","setTimeout","cancel","Object","assign"],"mappings":"sIAkBoC,CAClCA,EACAC,EACAC,KAEA,MAAMC,EAAUC,EAAMC,SAChBC,EAAYJ,EAAe,CAACF,EAAUC,KAAUC,GAAgB,CAACF,EAAUC,GAE3EM,EAAYH,EAAMI,YAAY,IAAIC,KACf,MAAnBN,EAAQO,SACVC,aAAaR,EAAQO,SAGvBP,EAAQO,QAAUE,WAAW,KAC3BZ,KAAYS,IACXR,IACFK,GAEGO,EAAST,EAAMI,YAAY,KACR,MAAnBL,EAAQO,UACVC,aAAaR,EAAQO,SACrBP,EAAQO,aAAU,IAEnB,IAEH,OAAOI,OAAOC,OAAOR,EAAW,CAAEM"}
1
+ {"version":3,"file":"useDebouncedCallback.cjs.js","sources":["../../src/hooks/useDebouncedCallback.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\n\nexport const useDebouncedCallback = <T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n dependencies?: React.DependencyList\n) => {\n const timeout = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const comboDeps = dependencies ? [callback, delay, ...dependencies] : [callback, delay];\n\n const debounced = React.useCallback((...args: T) => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n }\n\n timeout.current = setTimeout(() => {\n callback(...args);\n }, delay);\n }, comboDeps);\n\n const cancel = React.useCallback(() => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n timeout.current = undefined;\n }\n }, []);\n\n return Object.assign(debounced, { cancel });\n};\n"],"names":["callback","delay","dependencies","timeout","React","useRef","comboDeps","debounced","useCallback","args","current","clearTimeout","setTimeout","cancel","Object","assign"],"mappings":"sIAkBoC,CAClCA,EACAC,EACAC,KAEA,MAAMC,EAAUC,EAAMC,YAAkD,GAClEC,EAAYJ,EAAe,CAACF,EAAUC,KAAUC,GAAgB,CAACF,EAAUC,GAE3EM,EAAYH,EAAMI,YAAY,IAAIC,KACf,MAAnBN,EAAQO,SACVC,aAAaR,EAAQO,SAGvBP,EAAQO,QAAUE,WAAW,KAC3BZ,KAAYS,IACXR,IACFK,GAEGO,EAAST,EAAMI,YAAY,KACR,MAAnBL,EAAQO,UACVC,aAAaR,EAAQO,SACrBP,EAAQO,aAAU,IAEnB,IAEH,OAAOI,OAAOC,OAAOR,EAAW,CAAEM"}
@@ -1,6 +1,6 @@
1
1
  import React from "react";
2
2
  const useDebouncedCallback = (callback, delay, dependencies) => {
3
- const timeout = React.useRef();
3
+ const timeout = React.useRef(void 0);
4
4
  const comboDeps = dependencies ? [callback, delay, ...dependencies] : [callback, delay];
5
5
  const debounced = React.useCallback((...args) => {
6
6
  if (timeout.current != null) {
@@ -1 +1 @@
1
- {"version":3,"file":"useDebouncedCallback.es.js","sources":["../../src/hooks/useDebouncedCallback.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\n\nexport const useDebouncedCallback = <T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n dependencies?: React.DependencyList\n) => {\n const timeout = React.useRef<ReturnType<typeof setTimeout>>();\n const comboDeps = dependencies ? [callback, delay, ...dependencies] : [callback, delay];\n\n const debounced = React.useCallback((...args: T) => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n }\n\n timeout.current = setTimeout(() => {\n callback(...args);\n }, delay);\n }, comboDeps);\n\n const cancel = React.useCallback(() => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n timeout.current = undefined;\n }\n }, []);\n\n return Object.assign(debounced, { cancel });\n};\n"],"names":[],"mappings":";AAkBO,MAAM,uBAAuB,CAClC,UACA,OACA,iBACG;AACH,QAAM,UAAU,MAAM,OAAA;AACtB,QAAM,YAAY,eAAe,CAAC,UAAU,OAAO,GAAG,YAAY,IAAI,CAAC,UAAU,KAAK;AAEtF,QAAM,YAAY,MAAM,YAAY,IAAI,SAAY;AAClD,QAAI,QAAQ,WAAW,MAAM;AAC3B,mBAAa,QAAQ,OAAO;AAAA,IAC9B;AAEA,YAAQ,UAAU,WAAW,MAAM;AACjC,eAAS,GAAG,IAAI;AAAA,IAClB,GAAG,KAAK;AAAA,EACV,GAAG,SAAS;AAEZ,QAAM,SAAS,MAAM,YAAY,MAAM;AACrC,QAAI,QAAQ,WAAW,MAAM;AAC3B,mBAAa,QAAQ,OAAO;AAC5B,cAAQ,UAAU;AAAA,IACpB;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,SAAO,OAAO,OAAO,WAAW,EAAE,QAAQ;AAC5C;"}
1
+ {"version":3,"file":"useDebouncedCallback.es.js","sources":["../../src/hooks/useDebouncedCallback.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from \"react\";\n\nexport const useDebouncedCallback = <T extends unknown[]>(\n callback: (...args: T) => void,\n delay: number,\n dependencies?: React.DependencyList\n) => {\n const timeout = React.useRef<ReturnType<typeof setTimeout> | undefined>(undefined);\n const comboDeps = dependencies ? [callback, delay, ...dependencies] : [callback, delay];\n\n const debounced = React.useCallback((...args: T) => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n }\n\n timeout.current = setTimeout(() => {\n callback(...args);\n }, delay);\n }, comboDeps);\n\n const cancel = React.useCallback(() => {\n if (timeout.current != null) {\n clearTimeout(timeout.current);\n timeout.current = undefined;\n }\n }, []);\n\n return Object.assign(debounced, { cancel });\n};\n"],"names":[],"mappings":";AAkBO,MAAM,uBAAuB,CAClC,UACA,OACA,iBACG;AACH,QAAM,UAAU,MAAM,OAAkD,MAAS;AACjF,QAAM,YAAY,eAAe,CAAC,UAAU,OAAO,GAAG,YAAY,IAAI,CAAC,UAAU,KAAK;AAEtF,QAAM,YAAY,MAAM,YAAY,IAAI,SAAY;AAClD,QAAI,QAAQ,WAAW,MAAM;AAC3B,mBAAa,QAAQ,OAAO;AAAA,IAC9B;AAEA,YAAQ,UAAU,WAAW,MAAM;AACjC,eAAS,GAAG,IAAI;AAAA,IAClB,GAAG,KAAK;AAAA,EACV,GAAG,SAAS;AAEZ,QAAM,SAAS,MAAM,YAAY,MAAM;AACrC,QAAI,QAAQ,WAAW,MAAM;AAC3B,mBAAa,QAAQ,OAAO;AAC5B,cAAQ,UAAU;AAAA,IACpB;AAAA,EACF,GAAG,CAAA,CAAE;AAEL,SAAO,OAAO,OAAO,WAAW,EAAE,QAAQ;AAC5C;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGetDomRoot.cjs.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":["passedDomRoot","relativeElement","root","setRoot","useState","document","body","useEffect","current","closestBaseStylingWrapper","closest"],"mappings":"+HAkB6B,CAC3BA,EACAC,KAEA,MAAOC,EAAMC,GAAWC,EAAAA,SAAsBC,SAASC,MAgBvD,OAdAC,EAAAA,UAAU,KACR,IAAI,MAAAN,OAAA,EAAAA,EAAiBO,WAAYR,EAAe,CAC9C,MAAMS,EAA4BR,EAAgBO,QAAQE,QAAQ,wBAElE,GAAID,EAEF,YADAN,EAAQM,EAGZ,SAAWT,EAET,YADAG,EAAQH,IAGT,CAACC,IAEG,CAAEC"}
1
+ {"version":3,"file":"useGetDomRoot.cjs.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement | null> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":["passedDomRoot","relativeElement","root","setRoot","useState","document","body","useEffect","current","closestBaseStylingWrapper","closest"],"mappings":"+HAkB6B,CAC3BA,EACAC,KAEA,MAAOC,EAAMC,GAAWC,EAAAA,SAAsBC,SAASC,MAgBvD,OAdAC,EAAAA,UAAU,KACR,IAAI,MAAAN,OAAA,EAAAA,EAAiBO,WAAYR,EAAe,CAC9C,MAAMS,EAA4BR,EAAgBO,QAAQE,QAAQ,wBAElE,GAAID,EAEF,YADAN,EAAQM,EAGZ,SAAWT,EAET,YADAG,EAAQH,IAGT,CAACC,IAEG,CAAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useGetDomRoot.es.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":[],"mappings":";AAkBO,MAAM,gBAAgB,CAC3B,eACA,oBACG;AACH,QAAM,CAAC,MAAM,OAAO,IAAI,SAAsB,SAAS,IAAI;AAE3D,YAAU,MAAM;AACd,SAAI,mDAAiB,YAAW,CAAC,eAAe;AAC9C,YAAM,4BAA4B,gBAAgB,QAAQ,QAAQ,sBAAsB;AAExF,UAAI,2BAA2B;AAC7B,gBAAQ,yBAAwC;AAChD;AAAA,MACF;AAAA,IACF,WAAW,eAAe;AACxB,cAAQ,aAAa;AACrB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAEpB,SAAO,EAAE,KAAA;AACX;"}
1
+ {"version":3,"file":"useGetDomRoot.es.js","sources":["../../src/hooks/useGetDomRoot.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useState } from \"react\";\n\nexport const useGetDomRoot = (\n passedDomRoot: HTMLElement | undefined,\n relativeElement: React.RefObject<HTMLDivElement | null> | null\n) => {\n const [root, setRoot] = useState<HTMLElement>(document.body);\n\n useEffect(() => {\n if (relativeElement?.current && !passedDomRoot) {\n const closestBaseStylingWrapper = relativeElement.current.closest(\".basestyling-wrapper\");\n\n if (closestBaseStylingWrapper) {\n setRoot(closestBaseStylingWrapper as HTMLElement);\n return;\n }\n } else if (passedDomRoot) {\n setRoot(passedDomRoot);\n return;\n }\n }, [relativeElement]);\n\n return { root };\n};\n"],"names":[],"mappings":";AAkBO,MAAM,gBAAgB,CAC3B,eACA,oBACG;AACH,QAAM,CAAC,MAAM,OAAO,IAAI,SAAsB,SAAS,IAAI;AAE3D,YAAU,MAAM;AACd,SAAI,mDAAiB,YAAW,CAAC,eAAe;AAC9C,YAAM,4BAA4B,gBAAgB,QAAQ,QAAQ,sBAAsB;AAExF,UAAI,2BAA2B;AAC7B,gBAAQ,yBAAwC;AAChD;AAAA,MACF;AAAA,IACF,WAAW,eAAe;AACxB,cAAQ,aAAa;AACrB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,eAAe,CAAC;AAEpB,SAAO,EAAE,KAAA;AACX;"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePosition.cjs.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState, useEffect, useRef } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const resetCalculationState = () => {\n setInitialCalculationDone(false);\n };\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (returnValue < 0) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const _performCalculation = () => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n };\n\n const performCalculationRef = useRef(_performCalculation);\n performCalculationRef.current = _performCalculation;\n\n const calculatePosition = useDebouncedCallback(() => {\n performCalculationRef.current();\n }, configObject.debounceAmount ?? 20);\n\n const calculatePositionImmediate = () => {\n performCalculationRef.current();\n };\n\n const _getScrollableAncestors = (element: HTMLElement): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n let parent = element.parentElement;\n while (parent && parent !== document.documentElement) {\n const style = window.getComputedStyle(parent);\n const overflowX = style.overflowX;\n const overflowY = style.overflowY;\n if (\n overflowX === \"auto\" ||\n overflowX === \"scroll\" ||\n overflowY === \"auto\" ||\n overflowY === \"scroll\"\n ) {\n ancestors.push(parent);\n }\n parent = parent.parentElement;\n }\n return ancestors;\n };\n\n useEffect(() => {\n if (!initialCalculationDone) {\n return;\n }\n\n let rafId: number | null = null;\n\n const handleResize = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n window.addEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", handleResize);\n window.visualViewport.addEventListener(\"scroll\", handleResize);\n }\n\n const scrollableAncestors: HTMLElement[] = [];\n if (configObject.relativeElement?.current) {\n const relEl = configObject.relativeElement.current as HTMLElement;\n scrollableAncestors.push(..._getScrollableAncestors(relEl));\n for (const ancestor of scrollableAncestors) {\n ancestor.addEventListener(\"scroll\", handleResize);\n }\n }\n\n let resizeObserver: ResizeObserver | undefined;\n let lastObservedWidth = 0;\n let lastObservedHeight = 0;\n if (typeof ResizeObserver !== \"undefined\" && configObject.elementToBePositioned?.current) {\n const el = configObject.elementToBePositioned.current as HTMLElement;\n lastObservedWidth = el.offsetWidth;\n lastObservedHeight = el.offsetHeight;\n resizeObserver = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const { width, height } = entry.contentRect;\n if (Math.abs(width - lastObservedWidth) > 1 || Math.abs(height - lastObservedHeight) > 1) {\n lastObservedWidth = width;\n lastObservedHeight = height;\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n }\n });\n resizeObserver.observe(el);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n\n window.removeEventListener(\"resize\", handleResize);\n window.removeEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", handleResize);\n window.visualViewport.removeEventListener(\"scroll\", handleResize);\n }\n\n for (const ancestor of scrollableAncestors) {\n ancestor.removeEventListener(\"scroll\", handleResize);\n }\n\n if (resizeObserver) {\n resizeObserver.disconnect();\n }\n };\n }, [initialCalculationDone]);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n calculatePositionImmediate,\n initialCalculationDone,\n resetCalculationState\n };\n};\n"],"names":["horizontal","vertical","defaultConfigObject","relativeElement","elementToBePositioned","transformOrigin","placement","offset","top","right","bottom","left","debounceAmount","providedConfigObject","configObject","initialCalculationDone","setInitialCalculationDone","useState","position","setPosition","_calculatePlacement","relEl","elDimensions","axis","placementValue","requestedReturnValue","placementOriginDefinition","Error","_determineCenteredPlacementOrigin","value","window","_calculateInitialPlacementValue","valueWithOffset","returnValue","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_applyOffsetToPlacementValue","innerWidth","width","innerHeight","height","_fixPossibleViewportOverflow","_calculatePlacementValue","direction","oppositeDirection","prevState","_performCalculation","current","relativeElRect","getBoundingClientRect","elementToBePositionedDimensions","offsetHeight","offsetWidth","clonedRelEl","center","centerv","centerh","x","y","performCalculationRef","useRef","calculatePosition","useDebouncedCallback","useEffect","rafId","handleResize","cancelAnimationFrame","requestAnimationFrame","addEventListener","visualViewport","scrollableAncestors","push","element","ancestors","parent","parentElement","document","documentElement","style","getComputedStyle","overflowX","overflowY","_getScrollableAncestors","ancestor","resizeObserver","lastObservedWidth","lastObservedHeight","ResizeObserver","el","entries","entry","contentRect","Math","abs","observe","removeEventListener","disconnect","calculatePositionImmediate","resetCalculationState"],"mappings":"oJA4BO,IAAKA,GAAAA,IACVA,EAAA,KAAO,OACPA,EAAA,OAAS,SACTA,EAAA,SAAW,UACXA,EAAA,MAAQ,QAJEA,IAAAA,GAAA,CAAA,GAOAC,GAAAA,IACVA,EAAA,IAAM,MACNA,EAAA,OAAS,SACTA,EAAA,SAAW,UACXA,EAAA,OAAS,SAJCA,IAAAA,GAAA,CAAA,GAqDZ,MAAMC,EAAoC,CACxCC,qBAAiB,EACjBC,2BAAuB,EACvBC,gBAAiB,CACfL,WAAY,OACZC,SAAU,OAEZK,UAAW,CACTN,WAAY,OACZC,SAAU,OAEZM,OAAQ,CACNC,IAAK,EACLC,MAAO,EACPC,OAAQ,EACRC,KAAM,GAERC,eAAgB,6CAGS,CAACC,EAAqCX,KAC/D,MAAMY,EAAe,IAAKZ,KAAwBW,IAC3CE,EAAwBC,GAA6BC,EAAAA,UAAS,QAEhC,IAAjCH,EAAaT,kBACfS,EAAaT,gBAAkBH,EAAoBG,sBAGtB,IAA3BS,EAAaR,YACfQ,EAAaR,UAAYJ,EAAoBI,gBAGnB,IAAxBQ,EAAaP,SACfO,EAAaP,OAASL,EAAoBK,QAG5C,MAAOW,EAAUC,GAAeF,WAAmB,CACjDN,KAAM,EACNH,IAAK,EACLC,MAAO,UACPC,OAAQ,YAmLJU,EAAsB,CAACC,EAAsBC,EAA0BC,aAC3E,MAAMC,EAjCyB,EAC/BnB,EACAC,EACAmB,EACAJ,EACAC,KAEA,MAAMI,EACU,WAAdpB,EAnBsC,CAACmB,IACzC,GAA6B,eAAzBA,EACF,MAAO,UACT,GAAoC,aAAzBA,EACT,MAAO,UAET,MAAM,IAAIE,MACR,+DAA+DF,iBAYtCG,CAAkCH,GAAwBnB,EAE/EuB,EAxDgC,EACtCxB,EACAoB,EACAJ,EACAK,EACAJ,KAEA,IAAIO,EAAQ,EAoBZ,MAjB4C,SAA1CxB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BACTjD,OAAOiD,eAAe0B,oBAAoB,SAAU9B,GACpD7C,OAAOiD,eAAe0B,oBAAoB,SAAU9B,IAGtD,IAAA,MAAWkB,KAAYb,EACrBa,EAASY,oBAAoB,SAAU9B,GAGrCmB,GACFA,EAAeY,eAGlB,CAAC3F,IAEG,CACLP,IAAKU,EAASV,IACdE,OAAQQ,EAASR,OACjBC,KAAMO,EAASP,KACfF,MAAOS,EAAST,MAChB8D,oBACAoC,2BAnHiC,KACjCtC,EAAsBZ,WAmHtB1C,yBACA6F,sBAjX4B,KAC5B5F,GAA0B"}
1
+ {"version":3,"file":"usePosition.cjs.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState, useEffect, useRef } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement | null> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const resetCalculationState = () => {\n setInitialCalculationDone(false);\n };\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (returnValue < 0) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const _performCalculation = () => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n };\n\n const performCalculationRef = useRef(_performCalculation);\n performCalculationRef.current = _performCalculation;\n\n const calculatePosition = useDebouncedCallback(() => {\n performCalculationRef.current();\n }, configObject.debounceAmount ?? 20);\n\n const calculatePositionImmediate = () => {\n performCalculationRef.current();\n };\n\n const _getScrollableAncestors = (element: HTMLElement): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n let parent = element.parentElement;\n while (parent && parent !== document.documentElement) {\n const style = window.getComputedStyle(parent);\n const overflowX = style.overflowX;\n const overflowY = style.overflowY;\n if (\n overflowX === \"auto\" ||\n overflowX === \"scroll\" ||\n overflowY === \"auto\" ||\n overflowY === \"scroll\"\n ) {\n ancestors.push(parent);\n }\n parent = parent.parentElement;\n }\n return ancestors;\n };\n\n useEffect(() => {\n if (!initialCalculationDone) {\n return;\n }\n\n let rafId: number | null = null;\n\n const handleResize = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n window.addEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", handleResize);\n window.visualViewport.addEventListener(\"scroll\", handleResize);\n }\n\n const scrollableAncestors: HTMLElement[] = [];\n if (configObject.relativeElement?.current) {\n const relEl = configObject.relativeElement.current as HTMLElement;\n scrollableAncestors.push(..._getScrollableAncestors(relEl));\n for (const ancestor of scrollableAncestors) {\n ancestor.addEventListener(\"scroll\", handleResize);\n }\n }\n\n let resizeObserver: ResizeObserver | undefined;\n let lastObservedWidth = 0;\n let lastObservedHeight = 0;\n if (typeof ResizeObserver !== \"undefined\" && configObject.elementToBePositioned?.current) {\n const el = configObject.elementToBePositioned.current as HTMLElement;\n lastObservedWidth = el.offsetWidth;\n lastObservedHeight = el.offsetHeight;\n resizeObserver = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const { width, height } = entry.contentRect;\n if (Math.abs(width - lastObservedWidth) > 1 || Math.abs(height - lastObservedHeight) > 1) {\n lastObservedWidth = width;\n lastObservedHeight = height;\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n }\n });\n resizeObserver.observe(el);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n\n window.removeEventListener(\"resize\", handleResize);\n window.removeEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", handleResize);\n window.visualViewport.removeEventListener(\"scroll\", handleResize);\n }\n\n for (const ancestor of scrollableAncestors) {\n ancestor.removeEventListener(\"scroll\", handleResize);\n }\n\n if (resizeObserver) {\n resizeObserver.disconnect();\n }\n };\n }, [initialCalculationDone]);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n calculatePositionImmediate,\n initialCalculationDone,\n resetCalculationState\n };\n};\n"],"names":["horizontal","vertical","defaultConfigObject","relativeElement","elementToBePositioned","transformOrigin","placement","offset","top","right","bottom","left","debounceAmount","providedConfigObject","configObject","initialCalculationDone","setInitialCalculationDone","useState","position","setPosition","_calculatePlacement","relEl","elDimensions","axis","placementValue","requestedReturnValue","placementOriginDefinition","Error","_determineCenteredPlacementOrigin","value","window","_calculateInitialPlacementValue","valueWithOffset","returnValue","_a","_b","_c","_d","_e","_f","_g","_h","_i","_j","_k","_l","_applyOffsetToPlacementValue","innerWidth","width","innerHeight","height","_fixPossibleViewportOverflow","_calculatePlacementValue","direction","oppositeDirection","prevState","_performCalculation","current","relativeElRect","getBoundingClientRect","elementToBePositionedDimensions","offsetHeight","offsetWidth","clonedRelEl","center","centerv","centerh","x","y","performCalculationRef","useRef","calculatePosition","useDebouncedCallback","useEffect","rafId","handleResize","cancelAnimationFrame","requestAnimationFrame","addEventListener","visualViewport","scrollableAncestors","push","element","ancestors","parent","parentElement","document","documentElement","style","getComputedStyle","overflowX","overflowY","_getScrollableAncestors","ancestor","resizeObserver","lastObservedWidth","lastObservedHeight","ResizeObserver","el","entries","entry","contentRect","Math","abs","observe","removeEventListener","disconnect","calculatePositionImmediate","resetCalculationState"],"mappings":"oJA4BO,IAAKA,GAAAA,IACV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,KAAYb,EACrBa,EAASY,oBAAoB,SAAU9B,GAGrCmB,GACFA,EAAeY,eAGlB,CAAC3F,IAEG,CACLP,IAAKU,EAASV,IACdE,OAAQQ,EAASR,OACjBC,KAAMO,EAASP,KACfF,MAAOS,EAAST,MAChB8D,oBACAoC,2BAnHiC,KACjCtC,EAAsBZ,WAmHtB1C,yBACA6F,sBAjX4B,KAC5B5F,GAA0B"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePosition.es.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState, useEffect, useRef } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const resetCalculationState = () => {\n setInitialCalculationDone(false);\n };\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (returnValue < 0) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const _performCalculation = () => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n };\n\n const performCalculationRef = useRef(_performCalculation);\n performCalculationRef.current = _performCalculation;\n\n const calculatePosition = useDebouncedCallback(() => {\n performCalculationRef.current();\n }, configObject.debounceAmount ?? 20);\n\n const calculatePositionImmediate = () => {\n performCalculationRef.current();\n };\n\n const _getScrollableAncestors = (element: HTMLElement): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n let parent = element.parentElement;\n while (parent && parent !== document.documentElement) {\n const style = window.getComputedStyle(parent);\n const overflowX = style.overflowX;\n const overflowY = style.overflowY;\n if (\n overflowX === \"auto\" ||\n overflowX === \"scroll\" ||\n overflowY === \"auto\" ||\n overflowY === \"scroll\"\n ) {\n ancestors.push(parent);\n }\n parent = parent.parentElement;\n }\n return ancestors;\n };\n\n useEffect(() => {\n if (!initialCalculationDone) {\n return;\n }\n\n let rafId: number | null = null;\n\n const handleResize = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n window.addEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", handleResize);\n window.visualViewport.addEventListener(\"scroll\", handleResize);\n }\n\n const scrollableAncestors: HTMLElement[] = [];\n if (configObject.relativeElement?.current) {\n const relEl = configObject.relativeElement.current as HTMLElement;\n scrollableAncestors.push(..._getScrollableAncestors(relEl));\n for (const ancestor of scrollableAncestors) {\n ancestor.addEventListener(\"scroll\", handleResize);\n }\n }\n\n let resizeObserver: ResizeObserver | undefined;\n let lastObservedWidth = 0;\n let lastObservedHeight = 0;\n if (typeof ResizeObserver !== \"undefined\" && configObject.elementToBePositioned?.current) {\n const el = configObject.elementToBePositioned.current as HTMLElement;\n lastObservedWidth = el.offsetWidth;\n lastObservedHeight = el.offsetHeight;\n resizeObserver = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const { width, height } = entry.contentRect;\n if (Math.abs(width - lastObservedWidth) > 1 || Math.abs(height - lastObservedHeight) > 1) {\n lastObservedWidth = width;\n lastObservedHeight = height;\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n }\n });\n resizeObserver.observe(el);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n\n window.removeEventListener(\"resize\", handleResize);\n window.removeEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", handleResize);\n window.visualViewport.removeEventListener(\"scroll\", handleResize);\n }\n\n for (const ancestor of scrollableAncestors) {\n ancestor.removeEventListener(\"scroll\", handleResize);\n }\n\n if (resizeObserver) {\n resizeObserver.disconnect();\n }\n };\n }, [initialCalculationDone]);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n calculatePositionImmediate,\n initialCalculationDone,\n resetCalculationState\n };\n};\n"],"names":["horizontal","vertical"],"mappings":";;AA4BO,IAAK,+BAAAA,gBAAL;AACLA,cAAA,MAAA,IAAO;AACPA,cAAA,QAAA,IAAS;AACTA,cAAA,UAAA,IAAW;AACXA,cAAA,OAAA,IAAQ;AAJE,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;AAOL,IAAK,6BAAAC,cAAL;AACLA,YAAA,KAAA,IAAM;AACNA,YAAA,QAAA,IAAS;AACTA,YAAA,UAAA,IAAW;AACXA,YAAA,QAAA,IAAS;AAJC,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAqDZ,MAAM,sBAAoC;AAAA,EACxC,iBAAiB;AAAA,EACjB,uBAAuB;AAAA,EACvB,iBAAiB;AAAA,IACf,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA;AAAA,EAEZ,WAAW;AAAA,IACT,YAAY;AAAA,IACZ,UAAU;AAAA,EAAA;AAAA,EAEZ,QAAQ;AAAA,IACN,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,EAAA;AAAA,EAER,gBAAgB;AAClB;AAEO,MAAM,cAAc,CAAC,uBAAqC,wBAAwB;AACvF,QAAM,eAAe,EAAE,GAAG,qBAAqB,GAAG,qBAAA;AAClD,QAAM,CAAC,wBAAwB,yBAAyB,IAAI,SAAS,KAAK;AAE1E,MAAI,aAAa,oBAAoB,QAAW;AAC9C,iBA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AC5B;AACA,kBAAQ,sBAAsB,MAAM;AAClC,oBAAQ;AACR,kCAAsB,QAAA;AAAA,UACxB,CAAC;AAAA,QACH;AAAA,MACF,CAAC;AACD,qBAAe,QAAQ,EAAE;AAAA,IAC3B;AAEA,WAAO,MAAM;AACX,UAAI,UAAU,MAAM;AAClB,6BAAqB,KAAK;AAAA,MAC5B;AAEA,aAAO,oBAAoB,UAAU,YAAY;AACjD,aAAO,oBAAoB,UAAU,cAAc,IAAI;AAEvD,UAAI,OAAO,gBAAgB;AACzB,eAAO,eAAe,oBAAoB,UAAU,YAAY;AAChE,eAAO,eAAe,oBAAoB,UAAU,YAAY;AAAA,MAClE;AAEA,iBAAW,YAAY,qBAAqB;AAC1C,iBAAS,oBAAoB,UAAU,YAAY;AAAA,MACrD;AAEA,UAAI,gBAAgB;AAClB,uBAAe,WAAA;AAAA,MACjB;AAAA,IACF;AAAA,EACF,GAAG,CAAC,sBAAsB,CAAC;AAE3B,SAAO;AAAA,IACL,KAAK,SAAS;AAAA,IACd,QAAQ,SAAS;AAAA,IACjB,MAAM,SAAS;AAAA,IACf,OAAO,SAAS;AAAA,IAChB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"usePosition.es.js","sources":["../../src/hooks/usePosition.ts"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useState, useEffect, useRef } from \"react\";\nimport { useDebouncedCallback } from \"./useDebouncedCallback\";\n\nexport interface ConfigObject {\n relativeElement: RefElement;\n elementToBePositioned: RefElement;\n transformOrigin?: Placement;\n placement?: Placement;\n offset?: Offset;\n debounceAmount?: number;\n}\n\nexport enum horizontal {\n LEFT = \"left\",\n CENTER = \"center\",\n CENTER_H = \"centerh\",\n RIGHT = \"right\"\n}\n\nexport enum vertical {\n TOP = \"top\",\n CENTER = \"center\",\n CENTER_V = \"centerv\",\n BOTTOM = \"bottom\"\n}\n\nexport type HorizontalPlacement = `${horizontal}`;\nexport type VerticalPlacement = `${vertical}`;\n\ntype Axis = \"vertical\" | \"horizontal\";\ntype RefElement = React.RefObject<HTMLOrSVGElement | null> | undefined;\n\ninterface DomRectObject {\n top: number;\n right: number;\n bottom: number;\n left: number;\n center: number;\n centerh: number;\n centerv: number;\n width: number;\n height: number;\n x: number;\n y: number;\n}\n\nexport interface Placement {\n horizontal: HorizontalPlacement;\n vertical: VerticalPlacement;\n}\n\nexport interface Offset {\n top: number;\n right: number;\n bottom: number;\n left: number;\n}\n\nexport interface Position {\n top: PositionType;\n right: PositionType;\n bottom: PositionType;\n left: PositionType;\n}\n\ninterface Dimensions {\n height: number;\n width: number;\n}\n\nexport type PositionType = number | \"initial\";\n\nconst defaultConfigObject: ConfigObject = {\n relativeElement: undefined,\n elementToBePositioned: undefined,\n transformOrigin: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n placement: {\n horizontal: \"left\",\n vertical: \"top\"\n },\n offset: {\n top: 0,\n right: 0,\n bottom: 0,\n left: 0\n },\n debounceAmount: 20\n};\n\nexport const usePosition = (providedConfigObject: ConfigObject = defaultConfigObject) => {\n const configObject = { ...defaultConfigObject, ...providedConfigObject };\n const [initialCalculationDone, setInitialCalculationDone] = useState(false);\n\n if (configObject.transformOrigin === undefined) {\n configObject.transformOrigin = defaultConfigObject.transformOrigin;\n }\n\n if (configObject.placement === undefined) {\n configObject.placement = defaultConfigObject.placement;\n }\n\n if (configObject.offset === undefined) {\n configObject.offset = defaultConfigObject.offset;\n }\n\n const [position, setPosition] = useState<Position>({\n left: 0,\n top: 0,\n right: \"initial\",\n bottom: \"initial\"\n });\n\n const resetCalculationState = () => {\n setInitialCalculationDone(false);\n };\n\n const _fixPossibleViewportOverflow = (\n value: number,\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n elDimensions: Dimensions\n ) => {\n let returnValue = value;\n\n if (returnValue < 0) {\n returnValue = 0;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"left\" &&\n returnValue > window.innerWidth - elDimensions.width) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"horizontal\" &&\n returnValue > window.innerWidth - elDimensions.width)\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n (transformOrigin[requestedReturnValue] === \"top\" &&\n returnValue > window.innerHeight - elDimensions.height) ||\n (transformOrigin[requestedReturnValue] === \"center\" &&\n requestedReturnValue === \"vertical\" &&\n returnValue > window.innerHeight - elDimensions.height)\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"right\" &&\n returnValue > window.innerWidth - elDimensions.width\n ) {\n returnValue = window.innerWidth - elDimensions.width;\n }\n\n if (\n transformOrigin[requestedReturnValue] === \"bottom\" &&\n returnValue > window.innerHeight - elDimensions.height\n ) {\n returnValue = window.innerHeight - elDimensions.height;\n }\n\n return returnValue;\n };\n\n const _applyOffsetToPlacementValue = (\n value: number,\n requestedReturnValue: Axis,\n transformOrigin: Placement\n ) => {\n let returnValue = value;\n if (\n (requestedReturnValue === \"horizontal\" && configObject.offset?.left !== 0) ||\n (requestedReturnValue === \"horizontal\" && configObject.offset?.right !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.left!;\n returnValue -= configObject.offset?.right!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"right\") {\n returnValue -= configObject.offset?.left!;\n returnValue += configObject.offset?.right!;\n }\n }\n\n if (\n (requestedReturnValue === \"vertical\" && configObject.offset?.top !== 0) ||\n (requestedReturnValue === \"vertical\" && configObject.offset?.bottom !== 0)\n ) {\n if (\n transformOrigin[requestedReturnValue] === \"top\" ||\n transformOrigin[requestedReturnValue] === \"center\"\n ) {\n returnValue += configObject.offset?.top!;\n returnValue -= configObject.offset?.bottom!;\n }\n\n if (transformOrigin[requestedReturnValue] === \"bottom\") {\n returnValue -= configObject.offset?.top!;\n returnValue += configObject.offset?.bottom!;\n }\n }\n\n return returnValue;\n };\n\n const _calculateInitialPlacementValue = (\n transformOrigin: Placement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n placementOriginDefinition: HorizontalPlacement | VerticalPlacement,\n elDimensions: Dimensions\n ) => {\n let value = 0;\n\n if (\n transformOrigin[requestedReturnValue] === \"left\" ||\n transformOrigin[requestedReturnValue] === \"top\"\n ) {\n value = relEl[placementOriginDefinition];\n } else if (transformOrigin[requestedReturnValue] === \"center\") {\n value =\n relEl[placementOriginDefinition] -\n elDimensions[requestedReturnValue === \"horizontal\" ? \"width\" : \"height\"] / 2;\n } else if (\n transformOrigin[requestedReturnValue] === \"right\" ||\n transformOrigin[requestedReturnValue] === \"bottom\"\n ) {\n value =\n window[requestedReturnValue === \"horizontal\" ? \"innerWidth\" : \"innerHeight\"] -\n relEl[placementOriginDefinition];\n }\n\n return value;\n };\n\n /**\n *\n * @param requestedReturnValue whether the requested return value is for the horizontal or vertical axis\n * @returns either the horizontally centered placement definition (centerh) or the vertically centered one (centerv)\n */\n const _determineCenteredPlacementOrigin = (requestedReturnValue: Axis) => {\n if (requestedReturnValue === \"horizontal\") {\n return \"centerh\";\n } else if (requestedReturnValue === \"vertical\") {\n return \"centerv\";\n }\n throw new Error(\n `the requested return value isn't \"vertical\" or \"horizontal\" ${requestedReturnValue} was given.`\n );\n };\n\n const _calculatePlacementValue = (\n transformOrigin: Placement,\n placement: HorizontalPlacement | VerticalPlacement,\n requestedReturnValue: Axis,\n relEl: DomRectObject,\n elDimensions: Dimensions\n ): number => {\n const placementOriginDefinition =\n placement === \"center\" ? _determineCenteredPlacementOrigin(requestedReturnValue) : placement;\n\n const value = _calculateInitialPlacementValue(\n transformOrigin,\n requestedReturnValue,\n relEl,\n placementOriginDefinition,\n elDimensions\n );\n\n const valueWithOffset = _applyOffsetToPlacementValue(\n value,\n requestedReturnValue,\n transformOrigin\n );\n\n return _fixPossibleViewportOverflow(\n valueWithOffset,\n transformOrigin,\n requestedReturnValue,\n elDimensions\n );\n };\n\n const _calculatePlacement = (relEl: DomRectObject, elDimensions: Dimensions, axis: Axis) => {\n const placementValue = _calculatePlacementValue(\n configObject.transformOrigin!,\n configObject.placement![axis]!,\n axis,\n relEl,\n elDimensions\n );\n\n let direction = \"left\";\n let oppositeDirection = \"right\";\n\n if (axis === \"horizontal\" && configObject.transformOrigin?.horizontal === \"right\") {\n direction = \"right\";\n oppositeDirection = \"left\";\n } else if (axis === \"horizontal\") {\n direction = \"left\";\n oppositeDirection = \"right\";\n }\n\n if (axis === \"vertical\" && configObject.transformOrigin?.vertical === \"bottom\") {\n direction = \"bottom\";\n oppositeDirection = \"top\";\n } else if (axis === \"vertical\") {\n direction = \"top\";\n oppositeDirection = \"bottom\";\n }\n\n setPosition(prevState => ({\n ...prevState,\n [direction]: placementValue,\n [oppositeDirection]: \"initial\"\n }));\n };\n\n const _performCalculation = () => {\n if (!configObject.relativeElement?.current || !configObject.elementToBePositioned?.current) {\n return;\n }\n const relativeElRect = (configObject.relativeElement!\n .current as HTMLElement)!.getBoundingClientRect();\n const elementToBePositionedDimensions: Dimensions = {\n height: (configObject.elementToBePositioned!.current as HTMLElement).offsetHeight,\n width: (configObject.elementToBePositioned!.current as HTMLElement).offsetWidth\n };\n\n /** We want to add a center (horizontal and vertical) property to the DOMRect object. Since it's a special object we can't modify so we clone it and add it. */\n const clonedRelEl = {\n top: relativeElRect.top,\n right: relativeElRect.right,\n bottom: relativeElRect.bottom,\n center: 0,\n centerv: relativeElRect.top + relativeElRect.height / 2,\n centerh: relativeElRect.left + relativeElRect.width / 2,\n left: relativeElRect.left,\n width: relativeElRect.width,\n height: relativeElRect.height,\n x: relativeElRect.x,\n y: relativeElRect.y\n };\n\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"horizontal\");\n _calculatePlacement(clonedRelEl, elementToBePositionedDimensions, \"vertical\");\n\n if (!initialCalculationDone) {\n setInitialCalculationDone(true);\n }\n };\n\n const performCalculationRef = useRef(_performCalculation);\n performCalculationRef.current = _performCalculation;\n\n const calculatePosition = useDebouncedCallback(() => {\n performCalculationRef.current();\n }, configObject.debounceAmount ?? 20);\n\n const calculatePositionImmediate = () => {\n performCalculationRef.current();\n };\n\n const _getScrollableAncestors = (element: HTMLElement): HTMLElement[] => {\n const ancestors: HTMLElement[] = [];\n let parent = element.parentElement;\n while (parent && parent !== document.documentElement) {\n const style = window.getComputedStyle(parent);\n const overflowX = style.overflowX;\n const overflowY = style.overflowY;\n if (\n overflowX === \"auto\" ||\n overflowX === \"scroll\" ||\n overflowY === \"auto\" ||\n overflowY === \"scroll\"\n ) {\n ancestors.push(parent);\n }\n parent = parent.parentElement;\n }\n return ancestors;\n };\n\n useEffect(() => {\n if (!initialCalculationDone) {\n return;\n }\n\n let rafId: number | null = null;\n\n const handleResize = () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n };\n\n window.addEventListener(\"resize\", handleResize);\n window.addEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.addEventListener(\"resize\", handleResize);\n window.visualViewport.addEventListener(\"scroll\", handleResize);\n }\n\n const scrollableAncestors: HTMLElement[] = [];\n if (configObject.relativeElement?.current) {\n const relEl = configObject.relativeElement.current as HTMLElement;\n scrollableAncestors.push(..._getScrollableAncestors(relEl));\n for (const ancestor of scrollableAncestors) {\n ancestor.addEventListener(\"scroll\", handleResize);\n }\n }\n\n let resizeObserver: ResizeObserver | undefined;\n let lastObservedWidth = 0;\n let lastObservedHeight = 0;\n if (typeof ResizeObserver !== \"undefined\" && configObject.elementToBePositioned?.current) {\n const el = configObject.elementToBePositioned.current as HTMLElement;\n lastObservedWidth = el.offsetWidth;\n lastObservedHeight = el.offsetHeight;\n resizeObserver = new ResizeObserver(entries => {\n const entry = entries[0];\n if (!entry) {\n return;\n }\n const { width, height } = entry.contentRect;\n if (Math.abs(width - lastObservedWidth) > 1 || Math.abs(height - lastObservedHeight) > 1) {\n lastObservedWidth = width;\n lastObservedHeight = height;\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n rafId = requestAnimationFrame(() => {\n rafId = null;\n performCalculationRef.current();\n });\n }\n });\n resizeObserver.observe(el);\n }\n\n return () => {\n if (rafId !== null) {\n cancelAnimationFrame(rafId);\n }\n\n window.removeEventListener(\"resize\", handleResize);\n window.removeEventListener(\"scroll\", handleResize, true);\n\n if (window.visualViewport) {\n window.visualViewport.removeEventListener(\"resize\", handleResize);\n window.visualViewport.removeEventListener(\"scroll\", handleResize);\n }\n\n for (const ancestor of scrollableAncestors) {\n ancestor.removeEventListener(\"scroll\", handleResize);\n }\n\n if (resizeObserver) {\n resizeObserver.disconnect();\n }\n };\n }, [initialCalculationDone]);\n\n return {\n top: position.top,\n bottom: position.bottom,\n left: position.left,\n right: position.right,\n calculatePosition,\n calculatePositionImmediate,\n initialCalculationDone,\n resetCalculationState\n };\n};\n"],"names":["horizontal","vertical"],"mappings":";;AA4BO,IAAK,+BAAAA,gBAAL;AACLA,cAAA,MAAA,IAAO;AACPA,cAAA,QAAA,IAAS;AACTA,cAAA,UAAA,IAAW;AACXA,cAAA,OAAA,IAAQ;AAJE,SAAAA;AAAA,GAAA,cAAA,CAAA,CAAA;AAOL,IAAK,6BAAAC,cAAL;AACLA,YAAA,KAAA,IAAM;AACNA,YAAA,QAAA,IAAS;AACTA,YAAA,UAAA,IAAW;AACXA,YAAA,QAAA,IAAS;AAJC,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;AAqDZ,MAAM,sB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IACA;AAAA,EAAA;AAEJ;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRepeatFocus.cjs.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\nimport { getTabbableElements } from \"../utils/focusManagement\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement>, open?: boolean) => {\n useEffect(() => {\n if (!ref.current || !open) {\n return;\n }\n\n const tabbableElements = getTabbableElements(ref.current);\n const firstFocusableElement = tabbableElements[0];\n const lastFocusableElement = tabbableElements[tabbableElements.length - 1];\n\n if (!lastFocusableElement || !firstFocusableElement) {\n return;\n }\n\n const handleTabKeyPress = (event: Event) => {\n if (!(event instanceof KeyboardEvent) || event.key !== \"Tab\") {\n return;\n }\n\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement?.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement?.focus();\n }\n };\n\n lastFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n\n return () => {\n lastFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }, [ref, open]);\n};\n"],"names":["ref","open","useEffect","current","tabbableElements","getTabbableElements","firstFocusableElement","lastFocusableElement","length","handleTabKeyPress","event","KeyboardEvent","key","shiftKey","document","activeElement","preventDefault","focus","addEventListener","removeEventListener"],"mappings":"6KAyB8B,CAACA,EAAgCC,KAC7DC,EAAAA,UAAU,KACR,IAAKF,EAAIG,UAAYF,EACnB,OAGF,MAAMG,EAAmBC,EAAAA,oBAAoBL,EAAIG,SAC3CG,EAAwBF,EAAiB,GACzCG,EAAuBH,EAAiBA,EAAiBI,OAAS,GAExE,IAAKD,IAAyBD,EAC5B,OAGF,MAAMG,EAAqBC,IACnBA,aAAiBC,eAAgC,QAAdD,EAAME,MAI3CF,EAAMG,SACJC,SAASC,gBAAkBT,IAC7BI,EAAMM,iBACN,MAAAT,GAAAA,EAAsBU,SAEfH,SAASC,gBAAkBR,IACpCG,EAAMM,iBACN,MAAAV,GAAAA,EAAuBW,WAO3B,OAHAV,EAAqBW,iBAAiB,UAAWT,GACjDH,EAAsBY,iBAAiB,UAAWT,GAE3C,KACLF,EAAqBY,oBAAoB,UAAWV,GACpDH,EAAsBa,oBAAoB,UAAWV,KAEtD,CAACT,EAAKC"}
1
+ {"version":3,"file":"useRepeatFocus.cjs.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\nimport { getTabbableElements } from \"../utils/focusManagement\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement | null>, open?: boolean) => {\n useEffect(() => {\n if (!ref.current || !open) {\n return;\n }\n\n const tabbableElements = getTabbableElements(ref.current);\n const firstFocusableElement = tabbableElements[0];\n const lastFocusableElement = tabbableElements[tabbableElements.length - 1];\n\n if (!lastFocusableElement || !firstFocusableElement) {\n return;\n }\n\n const handleTabKeyPress = (event: Event) => {\n if (!(event instanceof KeyboardEvent) || event.key !== \"Tab\") {\n return;\n }\n\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement?.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement?.focus();\n }\n };\n\n lastFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n\n return () => {\n lastFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }, [ref, open]);\n};\n"],"names":["ref","open","useEffect","current","tabbableElements","getTabbableElements","firstFocusableElement","lastFocusableElement","length","handleTabKeyPress","event","KeyboardEvent","key","shiftKey","document","activeElement","preventDefault","focus","addEventListener","removeEventListener"],"mappings":"6KAyB8B,CAACA,EAAuCC,KACpEC,EAAAA,UAAU,KACR,IAAKF,EAAIG,UAAYF,EACnB,OAGF,MAAMG,EAAmBC,EAAAA,oBAAoBL,EAAIG,SAC3CG,EAAwBF,EAAiB,GACzCG,EAAuBH,EAAiBA,EAAiBI,OAAS,GAExE,IAAKD,IAAyBD,EAC5B,OAGF,MAAMG,EAAqBC,IACnBA,aAAiBC,eAAgC,QAAdD,EAAME,MAI3CF,EAAMG,SACJC,SAASC,gBAAkBT,IAC7BI,EAAMM,iBACN,MAAAT,GAAAA,EAAsBU,SAEfH,SAASC,gBAAkBR,IACpCG,EAAMM,iBACN,MAAAV,GAAAA,EAAuBW,WAO3B,OAHAV,EAAqBW,iBAAiB,UAAWT,GACjDH,EAAsBY,iBAAiB,UAAWT,GAE3C,KACLF,EAAqBY,oBAAoB,UAAWV,GACpDH,EAAsBa,oBAAoB,UAAWV,KAEtD,CAACT,EAAKC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRepeatFocus.es.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\nimport { getTabbableElements } from \"../utils/focusManagement\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement>, open?: boolean) => {\n useEffect(() => {\n if (!ref.current || !open) {\n return;\n }\n\n const tabbableElements = getTabbableElements(ref.current);\n const firstFocusableElement = tabbableElements[0];\n const lastFocusableElement = tabbableElements[tabbableElements.length - 1];\n\n if (!lastFocusableElement || !firstFocusableElement) {\n return;\n }\n\n const handleTabKeyPress = (event: Event) => {\n if (!(event instanceof KeyboardEvent) || event.key !== \"Tab\") {\n return;\n }\n\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement?.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement?.focus();\n }\n };\n\n lastFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n\n return () => {\n lastFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }, [ref, open]);\n};\n"],"names":[],"mappings":";;AAyBO,MAAM,iBAAiB,CAAC,KAAgC,SAAmB;AAChF,YAAU,MAAM;AACd,QAAI,CAAC,IAAI,WAAW,CAAC,MAAM;AACzB;AAAA,IACF;AAEA,UAAM,mBAAmB,oBAAoB,IAAI,OAAO;AACxD,UAAM,wBAAwB,iBAAiB,CAAC;AAChD,UAAM,uBAAuB,iBAAiB,iBAAiB,SAAS,CAAC;AAEzE,QAAI,CAAC,wBAAwB,CAAC,uBAAuB;AACnD;AAAA,IACF;AAEA,UAAM,oBAAoB,CAAC,UAAiB;AAC1C,UAAI,EAAE,iBAAiB,kBAAkB,MAAM,QAAQ,OAAO;AAC5D;AAAA,MACF;AAEA,UAAI,MAAM,UAAU;AAClB,YAAI,SAAS,kBAAkB,uBAAuB;AACpD,gBAAM,eAAA;AACN,uEAAsB;AAAA,QACxB;AAAA,MACF,WAAW,SAAS,kBAAkB,sBAAsB;AAC1D,cAAM,eAAA;AACN,uEAAuB;AAAA,MACzB;AAAA,IACF;AAEA,yBAAqB,iBAAiB,WAAW,iBAAiB;AAClE,0BAAsB,iBAAiB,WAAW,iBAAiB;AAEnE,WAAO,MAAM;AACX,2BAAqB,oBAAoB,WAAW,iBAAiB;AACrE,4BAAsB,oBAAoB,WAAW,iBAAiB;AAAA,IACxE;AAAA,EACF,GAAG,CAAC,KAAK,IAAI,CAAC;AAChB;"}
1
+ {"version":3,"file":"useRepeatFocus.es.js","sources":["../../src/hooks/useRepeatFocus.tsx"],"sourcesContent":["/*\n * Copyright 2022 OneWelcome B.V.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { RefObject, useEffect } from \"react\";\nimport { getTabbableElements } from \"../utils/focusManagement\";\n\n/**\n * @description This is a hook that will make sure that when a modal is open and the user tabs through the it,\n * the focus will be repeated and the user will not lose their entire focusable element to an element in the background\n * that is being blocked by the modal.\n */\n\nexport const useRepeatFocus = (ref: RefObject<HTMLDivElement | null>, open?: boolean) => {\n useEffect(() => {\n if (!ref.current || !open) {\n return;\n }\n\n const tabbableElements = getTabbableElements(ref.current);\n const firstFocusableElement = tabbableElements[0];\n const lastFocusableElement = tabbableElements[tabbableElements.length - 1];\n\n if (!lastFocusableElement || !firstFocusableElement) {\n return;\n }\n\n const handleTabKeyPress = (event: Event) => {\n if (!(event instanceof KeyboardEvent) || event.key !== \"Tab\") {\n return;\n }\n\n if (event.shiftKey) {\n if (document.activeElement === firstFocusableElement) {\n event.preventDefault();\n lastFocusableElement?.focus();\n }\n } else if (document.activeElement === lastFocusableElement) {\n event.preventDefault();\n firstFocusableElement?.focus();\n }\n };\n\n lastFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.addEventListener(\"keydown\", handleTabKeyPress);\n\n return () => {\n lastFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n firstFocusableElement.removeEventListener(\"keydown\", handleTabKeyPress);\n };\n }, [ref, open]);\n};\n"],"names":[],"mappings":";;AAyBO,MAAM,iBAAiB,CAAC,KAAuC,SAAmB;AACvF,YAAU,MAAM;AACd,QAAI,CAAC,IAAI,WAAW,CAAC,MAAM;AACzB;AAAA,IACF;AAEA,UAAM,mBAAmB,oBAAoB,IAAI,OAAO;AACxD,UAAM,wBAAwB,iBAAiB,CAAC;AAChD,UAAM,uBAAuB,iBAAiB,iBAAiB,SAAS,CAAC;AAEzE,QAAI,CAAC,wBAAwB,CAAC,uBAAuB;AACnD;AAAA,IACF;AAEA,UAAM,oBAAoB,CAAC,UAAiB;AAC1C,UAAI,EAAE,iBAAiB,kBAAkB,MAAM,QAAQ,OAAO;AAC5D;AAAA,MACF;AAEA,UAAI,MAAM,UAAU;AAClB,YAAI,SAAS,kBAAkB,uBAAuB;AACpD,gBAAM,eAAA;AACN,uEAAsB;AAAA,QACxB;AAAA,MACF,WAAW,SAAS,kBAAkB,sBAAsB;AAC1D,cAAM,eAAA;AACN,uEAAuB;AAAA,MACzB;AAAA,IACF;AAEA,yBAAqB,iBAAiB,WAAW,iBAAiB;AAClE,0BAAsB,iBAAiB,WAAW,iBAAiB;AAEnE,WAAO,MAAM;AACX,2BAAqB,oBAAoB,WAAW,iBAAiB;AACrE,4BAAsB,oBAAoB,WAAW,iBAAiB;AAAA,IACxE;AAAA,EACF,GAAG,CAAC,KAAK,IAAI,CAAC;AAChB;"}
package/dist/index.d.ts CHANGED
@@ -11,10 +11,10 @@ import { Dispatch } from 'react';
11
11
  import { DragEventHandler } from 'react';
12
12
  import { FocusableElement } from 'tabbable';
13
13
  import { ForwardRefExoticComponent } from 'react';
14
- import { ForwardRefRenderFunction } from 'react';
14
+ import { FunctionComponent } from 'react';
15
15
  import { HTMLAttributes } from 'react';
16
16
  import { HTMLProps } from 'react';
17
- import { JSX as JSX_2 } from 'react';
17
+ import { JSX } from 'react';
18
18
  import * as locales from 'date-fns/locale';
19
19
  import { NavigateFunction } from 'react-router-dom';
20
20
  import { ReactElement } from 'react';
@@ -701,8 +701,8 @@ export declare interface DiscardChangesModalProps extends Omit<Props, "onClose">
701
701
  onClose: (event?: default_2.MouseEvent<HTMLElement>) => unknown;
702
702
  headerProps: Omit<Props_4, "onClose" | "id">;
703
703
  discardChangedDialogProps: Omit<Props_10, "open" | "onKeepEditing" | "onDiscardChanges">;
704
- modalRef?: default_2.RefObject<HTMLDivElement>;
705
- dialogRef?: default_2.RefObject<HTMLDivElement>;
704
+ modalRef?: default_2.RefObject<HTMLDivElement | null>;
705
+ dialogRef?: default_2.RefObject<HTMLDivElement | null>;
706
706
  }
707
707
 
708
708
  /** Short msg is when only title is provided. Long one when content or/and actions are provided (or type is error). */
@@ -796,10 +796,6 @@ export declare interface FilterOperator {
796
796
  allowEmptyValues: boolean;
797
797
  }
798
798
 
799
- declare type FiltersState = {
800
- filters: Filter[];
801
- };
802
-
803
799
  declare interface FiltersTranslations {
804
800
  toolbar?: ToolbarTranslations;
805
801
  tag?: TagTranslations;
@@ -839,7 +835,7 @@ export declare interface FormGroupProps extends ComponentPropsWithRef<"div"> {
839
835
  errorMessageIconPosition?: "before" | "after";
840
836
  errorMessage?: string;
841
837
  errorId?: string;
842
- errorMessageProps?: ComponentPropsWithRef<"span">;
838
+ errorMessageProps?: ComponentPropsWithRef<"span"> & KeyValuePair;
843
839
  helperText?: string;
844
840
  helperId?: string;
845
841
  helperProps?: FormHelperTextProps;
@@ -868,7 +864,7 @@ export declare interface FormSectionProps extends ComponentPropsWithRef<"div"> {
868
864
  declare interface FormSelector extends FormElement {
869
865
  helperText?: string;
870
866
  errorMessage?: string;
871
- errorMessageProps?: ComponentPropsWithRef<"span">;
867
+ errorMessageProps?: ComponentPropsWithRef<"span"> & KeyValuePair;
872
868
  parentHelperId?: string;
873
869
  parentErrorId?: string;
874
870
  }
@@ -1040,7 +1036,7 @@ export declare enum Icons {
1040
1036
  Lightbulb = "bulb"
1041
1037
  }
1042
1038
 
1043
- export declare const IdentityProviderButton: ForwardRefRenderFunction<HTMLButtonElement, IdentityProviderButtonProps>;
1039
+ export declare const IdentityProviderButton: FunctionComponent<IdentityProviderButtonProps>;
1044
1040
 
1045
1041
  export declare interface IdentityProviderButtonProps extends Omit<ComponentPropsWithRef<"button">, "color"> {
1046
1042
  iconUrl?: string;
@@ -1211,6 +1207,10 @@ declare type OnSortFunction = (sort: Sort) => void;
1211
1207
  declare const Option_2: default_2.ForwardRefExoticComponent<Omit<OptionProps, "ref"> & default_2.RefAttributes<HTMLLIElement>>;
1212
1208
  export { Option_2 as Option }
1213
1209
 
1210
+ export declare type OptionElementProps = OptionProps & {
1211
+ fixed?: boolean;
1212
+ };
1213
+
1214
1214
  export declare interface OptionProps extends ComponentPropsWithRef<"li"> {
1215
1215
  children: ReactNode;
1216
1216
  value: string;
@@ -1223,7 +1223,7 @@ export declare interface OptionProps extends ComponentPropsWithRef<"li"> {
1223
1223
  isSearching?: boolean;
1224
1224
  label?: string;
1225
1225
  childIndex?: number;
1226
- onOptionSelect?: (ref: default_2.RefObject<HTMLLIElement>) => void;
1226
+ onOptionSelect?: (ref: default_2.RefObject<HTMLLIElement | null>) => void;
1227
1227
  onFocusChange?: (childIndex: number) => void;
1228
1228
  isAddBtnFocused?: boolean;
1229
1229
  }
@@ -1393,7 +1393,7 @@ declare interface Props_5 extends ComponentPropsWithRef<"button"> {
1393
1393
  declare interface Props_6 extends ComponentPropsWithRef<"div"> {
1394
1394
  children?: ReactNode;
1395
1395
  show?: boolean;
1396
- anchorEl?: RefObject<HTMLOrSVGElement>;
1396
+ anchorEl?: RefObject<HTMLOrSVGElement | null>;
1397
1397
  placement?: Placement;
1398
1398
  offset?: Offset;
1399
1399
  debounceAmount?: number;
@@ -1440,7 +1440,7 @@ export declare interface RadioWrapperProps extends ComponentPropsWithRef<"div">,
1440
1440
  onChange?: (event: default_2.ChangeEvent<HTMLInputElement>) => void;
1441
1441
  }
1442
1442
 
1443
- declare type RefElement = default_2.RefObject<HTMLOrSVGElement> | undefined;
1443
+ declare type RefElement = default_2.RefObject<HTMLOrSVGElement | null> | undefined;
1444
1444
 
1445
1445
  export declare enum ScreenSize {
1446
1446
  SMALL = 0,
@@ -1462,7 +1462,7 @@ declare interface SearchProps {
1462
1462
  export declare const Select: default_2.ForwardRefExoticComponent<Omit<default_2.PropsWithChildren<Omit<SingleSelectProps, "ref"> & default_2.RefAttributes<HTMLSelectElement> & WithReadOnlyProps>, "ref"> & default_2.RefAttributes<unknown>>;
1463
1463
 
1464
1464
  declare interface SelectProps_2<V extends string | readonly string[] | undefined> extends ComponentPropsWithRef<"select">, FormElement {
1465
- children: ReactElement[];
1465
+ children: ReactElement<OptionElementProps> | ReactElement<OptionElementProps>[];
1466
1466
  name?: string;
1467
1467
  labeledBy?: string;
1468
1468
  describedBy?: string;
@@ -1789,14 +1789,16 @@ export declare const useAlert: () => {
1789
1789
  enqueueErrorAlert: (entry: AlertQueue) => void;
1790
1790
  };
1791
1791
 
1792
- export declare const useClickOutside: (myElementRef: React.RefObject<HTMLElement>, onClickOutside: (event: MouseEvent) => void, dependencies?: DependencyList) => void;
1792
+ export declare const useClickOutside: (myElementRef: React.RefObject<HTMLElement | null>, onClickOutside: (event: MouseEvent) => void, dependencies?: DependencyList) => void;
1793
1793
 
1794
1794
  export declare const useDebouncedCallback: <T extends unknown[]>(callback: (...args: T) => void, delay: number, dependencies?: default_2.DependencyList) => ((...args: T) => void) & {
1795
1795
  cancel: () => void;
1796
1796
  };
1797
1797
 
1798
1798
  export declare const useFiltersReducer: (filterValues: Filter[] | undefined) => {
1799
- state: FiltersState;
1799
+ state: {
1800
+ filters: Filter[];
1801
+ };
1800
1802
  addFilter: (filter: Filter) => void;
1801
1803
  deleteFilter: (id: string) => void;
1802
1804
  editFilter: (filter: Filter) => void;
@@ -1842,7 +1844,7 @@ export declare const usePosition: (providedConfigObject?: ConfigObject) => {
1842
1844
  };
1843
1845
 
1844
1846
  export declare const useRepeater: <T>({ componentToRepeat }: Arguments) => {
1845
- repeatedComponents: JSX_2.Element[];
1847
+ repeatedComponents: JSX.Element[];
1846
1848
  repeat: () => void;
1847
1849
  remove: (componentToRemove: default_2.ReactElement<T>) => void;
1848
1850
  };
@@ -1902,7 +1904,7 @@ declare interface WrapperProps extends Omit<FormElement, "success"> {
1902
1904
  errorMessage?: string;
1903
1905
  helperText?: string;
1904
1906
  helperProps?: FormHelperTextProps;
1905
- errorMessageProps?: ComponentPropsWithRef<"span">;
1907
+ errorMessageProps?: ComponentPropsWithRef<"span"> & KeyValuePair;
1906
1908
  label?: string;
1907
1909
  name: string;
1908
1910
  required?: boolean;