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

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 (340) 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.cjs.js +1 -1
  46. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.cjs.js.map +1 -1
  47. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.es.js +1 -1
  48. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.es.js.map +1 -1
  49. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +2 -2
  50. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.es.js +9 -9
  51. package/dist/components/DataGrid/DataGridFilters/DataGridFilterPopover.cjs.js.map +1 -1
  52. package/dist/components/DataGrid/DataGridFilters/DataGridFilterPopover.es.js.map +1 -1
  53. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js +1 -1
  54. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js.map +1 -1
  55. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.es.js +25 -44
  56. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.es.js.map +1 -1
  57. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
  58. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
  59. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js +4 -15
  60. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js.map +1 -1
  61. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js +1 -1
  62. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js.map +1 -1
  63. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.es.js +6 -56
  64. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.es.js.map +1 -1
  65. package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
  66. package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.es.js.map +1 -1
  67. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +2 -2
  68. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.es.js +10 -10
  69. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.cjs.js.map +1 -1
  70. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.es.js.map +1 -1
  71. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -2
  72. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.es.js +17 -17
  73. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +2 -2
  74. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.es.js +4 -4
  75. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +2 -2
  76. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.es.js +11 -11
  77. package/dist/components/DatePicker/DatePicker.module.scss.cjs.js +2 -2
  78. package/dist/components/DatePicker/DatePicker.module.scss.es.js +31 -31
  79. package/dist/components/Form/Checkbox/Checkbox.cjs.js.map +1 -1
  80. package/dist/components/Form/Checkbox/Checkbox.es.js.map +1 -1
  81. package/dist/components/Form/Checkbox/Checkbox.module.scss.cjs.js +2 -2
  82. package/dist/components/Form/Checkbox/Checkbox.module.scss.es.js +13 -13
  83. package/dist/components/Form/Fieldset/Fieldset.cjs.js +1 -1
  84. package/dist/components/Form/Fieldset/Fieldset.cjs.js.map +1 -1
  85. package/dist/components/Form/Fieldset/Fieldset.es.js +3 -2
  86. package/dist/components/Form/Fieldset/Fieldset.es.js.map +1 -1
  87. package/dist/components/Form/Fieldset/Fieldset.module.scss.cjs.js +2 -2
  88. package/dist/components/Form/Fieldset/Fieldset.module.scss.es.js +6 -6
  89. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +2 -2
  90. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.es.js +18 -18
  91. package/dist/components/Form/FileUpload/FileUpload.module.scss.cjs.js +2 -2
  92. package/dist/components/Form/FileUpload/FileUpload.module.scss.es.js +16 -16
  93. package/dist/components/Form/Form.module.scss.cjs.js +2 -2
  94. package/dist/components/Form/Form.module.scss.es.js +2 -2
  95. package/dist/components/Form/FormControl/FormControl.cjs.js +1 -1
  96. package/dist/components/Form/FormControl/FormControl.cjs.js.map +1 -1
  97. package/dist/components/Form/FormControl/FormControl.es.js +3 -2
  98. package/dist/components/Form/FormControl/FormControl.es.js.map +1 -1
  99. package/dist/components/Form/FormControl/FormControl.module.scss.cjs.js +2 -2
  100. package/dist/components/Form/FormControl/FormControl.module.scss.es.js +13 -13
  101. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.cjs.js +2 -2
  102. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.es.js +6 -6
  103. package/dist/components/Form/FormGroup/FormGroup.cjs.js.map +1 -1
  104. package/dist/components/Form/FormGroup/FormGroup.es.js.map +1 -1
  105. package/dist/components/Form/FormGroup/FormGroup.module.scss.cjs.js +2 -2
  106. package/dist/components/Form/FormGroup/FormGroup.module.scss.es.js +3 -3
  107. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.cjs.js +2 -2
  108. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.es.js +4 -4
  109. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.cjs.js +2 -2
  110. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.es.js +6 -6
  111. package/dist/components/Form/Input/Input.cjs.js +1 -1
  112. package/dist/components/Form/Input/Input.cjs.js.map +1 -1
  113. package/dist/components/Form/Input/Input.es.js +46 -4
  114. package/dist/components/Form/Input/Input.es.js.map +1 -1
  115. package/dist/components/Form/Input/Input.module.scss.cjs.js +2 -2
  116. package/dist/components/Form/Input/Input.module.scss.es.js +8 -8
  117. package/dist/components/Form/Label/Label.module.scss.cjs.js +2 -2
  118. package/dist/components/Form/Label/Label.module.scss.es.js +2 -2
  119. package/dist/components/Form/Radio/Radio.module.scss.cjs.js +2 -2
  120. package/dist/components/Form/Radio/Radio.module.scss.es.js +11 -11
  121. package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js +1 -1
  122. package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js.map +1 -1
  123. package/dist/components/Form/Select/MultiSelect/MultiOption.es.js +2 -3
  124. package/dist/components/Form/Select/MultiSelect/MultiOption.es.js.map +1 -1
  125. package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
  126. package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
  127. package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js +13 -136
  128. package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js.map +1 -1
  129. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.cjs.js +2 -2
  130. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js +15 -18
  131. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js.map +1 -1
  132. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.cjs.js +2 -2
  133. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.es.js +2 -2
  134. package/dist/components/Form/Select/MultiSelect/SelectedOptions.cjs.js.map +1 -1
  135. package/dist/components/Form/Select/MultiSelect/SelectedOptions.es.js.map +1 -1
  136. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.cjs.js +2 -2
  137. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.es.js +4 -4
  138. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.cjs.js.map +1 -1
  139. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.es.js.map +1 -1
  140. package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js +1 -1
  141. package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js.map +1 -1
  142. package/dist/components/Form/Select/MultiSelect/useSearch.es.js +2 -35
  143. package/dist/components/Form/Select/MultiSelect/useSearch.es.js.map +1 -1
  144. package/dist/components/Form/Select/Select.interfaces.cjs.js.map +1 -1
  145. package/dist/components/Form/Select/Select.interfaces.es.js.map +1 -1
  146. package/dist/components/Form/Select/SingleSelect/Option.cjs.js +1 -1
  147. package/dist/components/Form/Select/SingleSelect/Option.cjs.js.map +1 -1
  148. package/dist/components/Form/Select/SingleSelect/Option.es.js +2 -3
  149. package/dist/components/Form/Select/SingleSelect/Option.es.js.map +1 -1
  150. package/dist/components/Form/Select/SingleSelect/Select.cjs.js +1 -1
  151. package/dist/components/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
  152. package/dist/components/Form/Select/SingleSelect/Select.es.js +16 -125
  153. package/dist/components/Form/Select/SingleSelect/Select.es.js.map +1 -1
  154. package/dist/components/Form/Select/SingleSelect/Select.module.scss.cjs.js +2 -2
  155. package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js +17 -20
  156. package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js.map +1 -1
  157. package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js +1 -1
  158. package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js.map +1 -1
  159. package/dist/components/Form/Select/SingleSelect/useSearch.es.js +2 -32
  160. package/dist/components/Form/Select/SingleSelect/useSearch.es.js.map +1 -1
  161. package/dist/components/Form/Select/useAddNewBtn.cjs.js +1 -1
  162. package/dist/components/Form/Select/useAddNewBtn.cjs.js.map +1 -1
  163. package/dist/components/Form/Select/useAddNewBtn.es.js +2 -1
  164. package/dist/components/Form/Select/useAddNewBtn.es.js.map +1 -1
  165. package/dist/components/Form/Select/useAddNewBtn.module.scss.cjs.js +2 -2
  166. package/dist/components/Form/Select/useAddNewBtn.module.scss.es.js +4 -4
  167. package/dist/components/Form/Textarea/Textarea.module.scss.cjs.js +2 -2
  168. package/dist/components/Form/Textarea/Textarea.module.scss.es.js +6 -6
  169. package/dist/components/Form/Toggle/Toggle.module.scss.cjs.js +2 -2
  170. package/dist/components/Form/Toggle/Toggle.module.scss.es.js +18 -18
  171. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.cjs.js.map +1 -1
  172. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.es.js.map +1 -1
  173. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.cjs.js +2 -2
  174. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.es.js +5 -5
  175. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.cjs.js +2 -2
  176. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.es.js +5 -5
  177. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.cjs.js.map +1 -1
  178. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.es.js.map +1 -1
  179. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.cjs.js +2 -2
  180. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.es.js +3 -3
  181. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js +1 -1
  182. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js.map +1 -1
  183. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.es.js +5 -4
  184. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.es.js.map +1 -1
  185. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.cjs.js +2 -2
  186. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.es.js +5 -5
  187. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.cjs.js.map +1 -1
  188. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.es.js.map +1 -1
  189. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.cjs.js +2 -2
  190. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.es.js +3 -3
  191. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.cjs.js +2 -2
  192. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.es.js +8 -8
  193. package/dist/components/Form/Wrapper/Wrapper/Wrapper.cjs.js.map +1 -1
  194. package/dist/components/Form/Wrapper/Wrapper/Wrapper.es.js.map +1 -1
  195. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.cjs.js +2 -2
  196. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.es.js +6 -6
  197. package/dist/components/Icon/Icon.module.scss.cjs.js +2 -2
  198. package/dist/components/Icon/Icon.module.scss.es.js +108 -108
  199. package/dist/components/Layout/ActionBar/ActionBar.module.scss.cjs.js +2 -2
  200. package/dist/components/Layout/ActionBar/ActionBar.module.scss.es.js +10 -10
  201. package/dist/components/Layout/Card/Card.module.scss.cjs.js +2 -2
  202. package/dist/components/Layout/Card/Card.module.scss.es.js +12 -12
  203. package/dist/components/Layout/ContentHeader/ContentHeader.cjs.js.map +1 -1
  204. package/dist/components/Layout/ContentHeader/ContentHeader.es.js.map +1 -1
  205. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.cjs.js +2 -2
  206. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.es.js +19 -19
  207. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.cjs.js +2 -2
  208. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.es.js +4 -4
  209. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.cjs.js +2 -2
  210. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.es.js +2 -2
  211. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.cjs.js +2 -2
  212. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.es.js +3 -3
  213. package/dist/components/Link/Link.module.scss.cjs.js +2 -2
  214. package/dist/components/Link/Link.module.scss.es.js +17 -17
  215. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.cjs.js +2 -2
  216. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.es.js +11 -11
  217. package/dist/components/Notifications/Alert/AlertItem/AlertItem.cjs.js +1 -1
  218. package/dist/components/Notifications/Alert/AlertItem/AlertItem.cjs.js.map +1 -1
  219. package/dist/components/Notifications/Alert/AlertItem/AlertItem.es.js +1 -1
  220. package/dist/components/Notifications/Alert/AlertItem/AlertItem.es.js.map +1 -1
  221. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.cjs.js +2 -2
  222. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.es.js +22 -22
  223. package/dist/components/Notifications/Banner/Banner.module.scss.cjs.js +2 -2
  224. package/dist/components/Notifications/Banner/Banner.module.scss.es.js +9 -9
  225. package/dist/components/Notifications/BaseModal/BaseModal.cjs.js.map +1 -1
  226. package/dist/components/Notifications/BaseModal/BaseModal.es.js.map +1 -1
  227. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.cjs.js +2 -2
  228. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.es.js +5 -5
  229. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.cjs.js.map +1 -1
  230. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.es.js.map +1 -1
  231. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.cjs.js +2 -2
  232. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.es.js +4 -4
  233. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.cjs.js.map +1 -1
  234. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.es.js.map +1 -1
  235. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.cjs.js +2 -2
  236. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.es.js +2 -2
  237. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.cjs.js +2 -2
  238. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.es.js +6 -6
  239. package/dist/components/Notifications/Dialog/Dialog.module.scss.cjs.js +2 -2
  240. package/dist/components/Notifications/Dialog/Dialog.module.scss.es.js +4 -4
  241. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.cjs.js +2 -2
  242. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.es.js +3 -3
  243. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.cjs.js +2 -2
  244. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.es.js +10 -10
  245. package/dist/components/Notifications/DiscardChangesModal/DiscardChangesModal.cjs.js.map +1 -1
  246. package/dist/components/Notifications/DiscardChangesModal/DiscardChangesModal.es.js.map +1 -1
  247. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -2
  248. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.es.js +13 -13
  249. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -2
  250. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.es.js +2 -2
  251. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -2
  252. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.es.js +2 -2
  253. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.cjs.js +2 -2
  254. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.es.js +10 -10
  255. package/dist/components/Pagination/Pagination.module.scss.cjs.js +2 -2
  256. package/dist/components/Pagination/Pagination.module.scss.es.js +15 -15
  257. package/dist/components/Popover/Popover.cjs.js.map +1 -1
  258. package/dist/components/Popover/Popover.es.js.map +1 -1
  259. package/dist/components/Popover/Popover.module.scss.cjs.js +2 -2
  260. package/dist/components/Popover/Popover.module.scss.es.js +3 -3
  261. package/dist/components/ProgressBar/ProgressBar.module.scss.cjs.js +2 -2
  262. package/dist/components/ProgressBar/ProgressBar.module.scss.es.js +9 -9
  263. package/dist/components/Skeleton/Skeleton.module.scss.cjs.js +2 -2
  264. package/dist/components/Skeleton/Skeleton.module.scss.es.js +5 -5
  265. package/dist/components/Spinner/Spinner.module.scss.cjs.js +2 -2
  266. package/dist/components/Spinner/Spinner.module.scss.es.js +3 -3
  267. package/dist/components/Stepper/Step.module.scss.cjs.js +2 -2
  268. package/dist/components/Stepper/Step.module.scss.es.js +22 -22
  269. package/dist/components/Stepper/Stepper.module.scss.cjs.js +2 -2
  270. package/dist/components/Stepper/Stepper.module.scss.es.js +4 -4
  271. package/dist/components/Tabs/Tab.module.scss.cjs.js +2 -2
  272. package/dist/components/Tabs/Tab.module.scss.es.js +3 -3
  273. package/dist/components/Tabs/TabButton.cjs.js.map +1 -1
  274. package/dist/components/Tabs/TabButton.es.js.map +1 -1
  275. package/dist/components/Tabs/TabButton.module.scss.cjs.js +2 -2
  276. package/dist/components/Tabs/TabButton.module.scss.es.js +12 -12
  277. package/dist/components/Tabs/Tabs.cjs.js.map +1 -1
  278. package/dist/components/Tabs/Tabs.es.js.map +1 -1
  279. package/dist/components/Tabs/Tabs.module.scss.cjs.js +2 -2
  280. package/dist/components/Tabs/Tabs.module.scss.es.js +10 -10
  281. package/dist/components/Tag/RemoveButton.module.scss.cjs.js +2 -2
  282. package/dist/components/Tag/RemoveButton.module.scss.es.js +3 -3
  283. package/dist/components/Tag/Tag.cjs.js +1 -1
  284. package/dist/components/Tag/Tag.cjs.js.map +1 -1
  285. package/dist/components/Tag/Tag.es.js +1 -1
  286. package/dist/components/Tag/Tag.es.js.map +1 -1
  287. package/dist/components/Tag/Tag.module.scss.cjs.js +2 -2
  288. package/dist/components/Tag/Tag.module.scss.es.js +6 -6
  289. package/dist/components/TextEllipsis/TextEllipsis.module.scss.cjs.js +2 -2
  290. package/dist/components/TextEllipsis/TextEllipsis.module.scss.es.js +3 -3
  291. package/dist/components/Tiles/Tile.module.scss.cjs.js +2 -2
  292. package/dist/components/Tiles/Tile.module.scss.es.js +8 -8
  293. package/dist/components/Tiles/Tiles.module.scss.cjs.js +2 -2
  294. package/dist/components/Tiles/Tiles.module.scss.es.js +2 -2
  295. package/dist/components/Tooltip/Tooltip.cjs.js.map +1 -1
  296. package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
  297. package/dist/components/Tooltip/Tooltip.module.scss.cjs.js +2 -2
  298. package/dist/components/Tooltip/Tooltip.module.scss.es.js +28 -28
  299. package/dist/components/Typography/Typography.module.scss.cjs.js +2 -2
  300. package/dist/components/Typography/Typography.module.scss.es.js +13 -13
  301. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.cjs.js +2 -2
  302. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.es.js +5 -5
  303. package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.cjs.js.map +1 -1
  304. package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.es.js +3 -1
  305. package/dist/components/admin/layout/LeftNav/LeftNavItem/ButtonLeftNavItem.es.js.map +1 -1
  306. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.cjs.js +2 -2
  307. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.es.js +14 -14
  308. package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.cjs.js.map +1 -1
  309. package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.es.js +6 -2
  310. package/dist/components/admin/layout/LeftNav/LeftNavItem/LinkLeftNavItem.es.js.map +1 -1
  311. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.cjs.js +2 -2
  312. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.es.js +3 -3
  313. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.cjs.js +2 -2
  314. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.es.js +7 -7
  315. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.cjs.js +2 -2
  316. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.es.js +13 -13
  317. package/dist/components/miscellaneous/IdentityProviderButton.cjs.js.map +1 -1
  318. package/dist/components/miscellaneous/IdentityProviderButton.es.js.map +1 -1
  319. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.cjs.js +2 -2
  320. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.es.js +3 -3
  321. package/dist/hooks/useClickOutside.cjs.js.map +1 -1
  322. package/dist/hooks/useClickOutside.es.js.map +1 -1
  323. package/dist/hooks/useDebouncedCallback.cjs.js +1 -1
  324. package/dist/hooks/useDebouncedCallback.cjs.js.map +1 -1
  325. package/dist/hooks/useDebouncedCallback.es.js +1 -1
  326. package/dist/hooks/useDebouncedCallback.es.js.map +1 -1
  327. package/dist/hooks/useGetDomRoot.cjs.js.map +1 -1
  328. package/dist/hooks/useGetDomRoot.es.js.map +1 -1
  329. package/dist/hooks/usePosition.cjs.js.map +1 -1
  330. package/dist/hooks/usePosition.es.js.map +1 -1
  331. package/dist/hooks/useRepeatFocus.cjs.js.map +1 -1
  332. package/dist/hooks/useRepeatFocus.es.js.map +1 -1
  333. package/dist/index.d.ts +28 -81
  334. package/dist/node_modules/tabbable/dist/index.esm.cjs.js +1 -1
  335. package/dist/node_modules/tabbable/dist/index.esm.cjs.js.map +1 -1
  336. package/dist/node_modules/tabbable/dist/index.esm.es.js +4 -3
  337. package/dist/node_modules/tabbable/dist/index.esm.es.js.map +1 -1
  338. package/dist/readyclasses.module.scss.cjs.js +2 -2
  339. package/dist/readyclasses.module.scss.es.js +5 -5
  340. package/package.json +9 -9
@@ -1,10 +1,10 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.ProfileMenu_sr-only_PX3IM{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.ProfileMenu_hidden_PX3IM{display:none}.ProfileMenu_slide-in_PX3IM{animation:ProfileMenu_slide-in_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.ProfileMenu_slide-in_PX3IM{animation-duration:.1ms}}.ProfileMenu_slide-out_PX3IM{animation:ProfileMenu_slide-out_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.ProfileMenu_slide-out_PX3IM{animation-duration:.1ms}}@keyframes ProfileMenu_slide-in_PX3IM{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes ProfileMenu_slide-out_PX3IM{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 */.ProfileMenu_trigger_PX3IM{display:flex;align-items:center;background:none;border:none;cursor:pointer;padding:0 .75rem}.ProfileMenu_trigger_PX3IM:focus-visible{outline:calc(.125 * var(--font-size)) solid var(--color-focus);outline-offset:calc(.125 * var(--font-size));border-radius:var(--focus-border-radius)}.ProfileMenu_circle_PX3IM{width:2.5rem;height:2.5rem;border-radius:50%;background-color:var(--color-primary);color:var(--light);display:flex;align-items:center;justify-content:center;overflow:hidden}.ProfileMenu_circle_PX3IM:hover{background-color:var(--color-primary600)}.ProfileMenu_circle_PX3IM.ProfileMenu_active_PX3IM{background-color:var(--color-primary700)}.ProfileMenu_initials_PX3IM{font-weight:700;font-size:1rem;pointer-events:none}.ProfileMenu_img_PX3IM{width:100%;height:100%;object-fit:cover;border-radius:50%}.ProfileMenu_popover_PX3IM{z-index:11;--font-size: .875rem}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}}();
2
- const trigger = "ProfileMenu_trigger_PX3IM";
3
- const circle = "ProfileMenu_circle_PX3IM";
4
- const active = "ProfileMenu_active_PX3IM";
5
- const initials = "ProfileMenu_initials_PX3IM";
6
- const img = "ProfileMenu_img_PX3IM";
7
- const popover = "ProfileMenu_popover_PX3IM";
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.ProfileMenu_sr-only_vObpl{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.ProfileMenu_hidden_vObpl{display:none}.ProfileMenu_slide-in_vObpl{animation:ProfileMenu_slide-in_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.ProfileMenu_slide-in_vObpl{animation-duration:.1ms}}.ProfileMenu_slide-out_vObpl{animation:ProfileMenu_slide-out_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.ProfileMenu_slide-out_vObpl{animation-duration:.1ms}}@keyframes ProfileMenu_slide-in_vObpl{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes ProfileMenu_slide-out_vObpl{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 */.ProfileMenu_trigger_vObpl{display:flex;align-items:center;background:none;border:none;cursor:pointer;padding:0 .75rem}.ProfileMenu_trigger_vObpl:focus-visible{outline:calc(.125 * var(--font-size)) solid var(--color-focus);outline-offset:calc(.125 * var(--font-size));border-radius:var(--focus-border-radius)}.ProfileMenu_circle_vObpl{width:2.5rem;height:2.5rem;border-radius:50%;background-color:var(--color-primary);color:var(--light);display:flex;align-items:center;justify-content:center;overflow:hidden}.ProfileMenu_circle_vObpl:hover{background-color:var(--color-primary600)}.ProfileMenu_circle_vObpl.ProfileMenu_active_vObpl{background-color:var(--color-primary700)}.ProfileMenu_initials_vObpl{font-weight:700;font-size:1rem;pointer-events:none}.ProfileMenu_img_vObpl{width:100%;height:100%;object-fit:cover;border-radius:50%}.ProfileMenu_popover_vObpl{z-index:11;--font-size: .875rem}')),document.head.appendChild(e)}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}}();
2
+ const trigger = "ProfileMenu_trigger_vObpl";
3
+ const circle = "ProfileMenu_circle_vObpl";
4
+ const active = "ProfileMenu_active_vObpl";
5
+ const initials = "ProfileMenu_initials_vObpl";
6
+ const img = "ProfileMenu_img_vObpl";
7
+ const popover = "ProfileMenu_popover_vObpl";
8
8
  const classes = {
9
9
  trigger,
10
10
  circle,
@@ -1,3 +1,3 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var a=document.createElement("style");a.appendChild(document.createTextNode('.TopNavBar_sr-only_PX3IM{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.TopNavBar_hidden_PX3IM{display:none}.TopNavBar_slide-in_PX3IM{animation:TopNavBar_slide-in_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-in_PX3IM{animation-duration:.1ms}}.TopNavBar_slide-out_PX3IM{animation:TopNavBar_slide-out_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-out_PX3IM{animation-duration:.1ms}}@keyframes TopNavBar_slide-in_PX3IM{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes TopNavBar_slide-out_PX3IM{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 */.TopNavBar_topnavbar_PX3IM{position:sticky;top:0;left:0;z-index:3;width:100%;display:flex;align-items:center;height:4rem;padding:0 .75rem 0 0;background-color:var(--sidenavbar-background);box-shadow:0 2px 4px #0105320a,0 4px 5px #0105320a,0 1px 10px #01053214;--font-size: .875rem;flex-wrap:nowrap}.TopNavBar_topnavbar_PX3IM .TopNavBar_left-section_PX3IM{flex-shrink:0;display:flex;align-items:center}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-link_PX3IM{display:flex;align-items:center;text-decoration:none}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM{display:flex;align-items:center}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo-small_PX3IM{height:2.5rem;display:flex;align-items:center;margin:0 1rem}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo_PX3IM{display:none}@media screen and (min-width:30em){.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo-small_PX3IM{display:none;height:0}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo_PX3IM{display:block;margin-left:1rem}}@media screen and (min-width:30em)and (min-width:50em){.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo_PX3IM{margin-left:.75rem;margin-right:0}}.TopNavBar_topnavbar_PX3IM .TopNavBar_sr-only_PX3IM{position:absolute;margin:-1px;height:1px;width:1px;overflow:hidden}.TopNavBar_topnavbar_PX3IM .TopNavBar_separator_PX3IM{border:none;width:1px;height:2.5rem;background-color:#dedee6;flex-shrink:0;align-self:center;margin:0 3rem}.TopNavBar_topnavbar_PX3IM .TopNavBar_middle-section_PX3IM{flex:1;display:flex;align-items:center;min-width:0;margin-left:6.0625rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_PX3IM .TopNavBar_middle-section_PX3IM{margin-left:0}}.TopNavBar_topnavbar_PX3IM .TopNavBar_separator_PX3IM+.TopNavBar_middle-section_PX3IM{margin-left:0}.TopNavBar_topnavbar_PX3IM .TopNavBar_right-section_PX3IM{display:flex;align-items:center;margin-left:auto;justify-content:flex-end;gap:1rem;padding-left:1rem}.TopNavBar_topnavbar_PX3IM .TopNavBar_menu-button_PX3IM{flex-shrink:0;margin-left:.75rem;display:none;--font-size: 1rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_PX3IM .TopNavBar_menu-button_PX3IM{display:initial}}.TopNavBar_topnavbar_PX3IM .TopNavBar_menu-button_PX3IM.TopNavBar_menu--collapsed_PX3IM{display:initial}')),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();
2
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o="TopNavBar_topnavbar_PX3IM",a="TopNavBar_logo_PX3IM",e="TopNavBar_separator_PX3IM",r={"sr-only":"TopNavBar_sr-only_PX3IM",topnavbar:o,"left-section":"TopNavBar_left-section_PX3IM","logo-link":"TopNavBar_logo-link_PX3IM","logo-container":"TopNavBar_logo-container_PX3IM","logo-small":"TopNavBar_logo-small_PX3IM",logo:a,separator:e,"middle-section":"TopNavBar_middle-section_PX3IM","right-section":"TopNavBar_right-section_PX3IM","menu-button":"TopNavBar_menu-button_PX3IM","menu--collapsed":"TopNavBar_menu--collapsed_PX3IM"};exports.default=r,exports.logo=a,exports.separator=e,exports.topnavbar=o;
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var a=document.createElement("style");a.appendChild(document.createTextNode('.TopNavBar_sr-only_vObpl{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.TopNavBar_hidden_vObpl{display:none}.TopNavBar_slide-in_vObpl{animation:TopNavBar_slide-in_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-in_vObpl{animation-duration:.1ms}}.TopNavBar_slide-out_vObpl{animation:TopNavBar_slide-out_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-out_vObpl{animation-duration:.1ms}}@keyframes TopNavBar_slide-in_vObpl{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes TopNavBar_slide-out_vObpl{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 */.TopNavBar_topnavbar_vObpl{position:sticky;top:0;left:0;z-index:3;width:100%;display:flex;align-items:center;height:4rem;padding:0 .75rem 0 0;background-color:var(--sidenavbar-background);box-shadow:0 2px 4px #0105320a,0 4px 5px #0105320a,0 1px 10px #01053214;--font-size: .875rem;flex-wrap:nowrap}.TopNavBar_topnavbar_vObpl .TopNavBar_left-section_vObpl{flex-shrink:0;display:flex;align-items:center}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-link_vObpl{display:flex;align-items:center;text-decoration:none}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl{display:flex;align-items:center}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo-small_vObpl{height:2.5rem;display:flex;align-items:center;margin:0 1rem}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo_vObpl{display:none}@media screen and (min-width:30em){.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo-small_vObpl{display:none;height:0}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo_vObpl{display:block;margin-left:1rem}}@media screen and (min-width:30em)and (min-width:50em){.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo_vObpl{margin-left:.75rem;margin-right:0}}.TopNavBar_topnavbar_vObpl .TopNavBar_sr-only_vObpl{position:absolute;margin:-1px;height:1px;width:1px;overflow:hidden}.TopNavBar_topnavbar_vObpl .TopNavBar_separator_vObpl{border:none;width:1px;height:2.5rem;background-color:#dedee6;flex-shrink:0;align-self:center;margin:0 3rem}.TopNavBar_topnavbar_vObpl .TopNavBar_middle-section_vObpl{flex:1;display:flex;align-items:center;min-width:0;margin-left:6.0625rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_vObpl .TopNavBar_middle-section_vObpl{margin-left:0}}.TopNavBar_topnavbar_vObpl .TopNavBar_separator_vObpl+.TopNavBar_middle-section_vObpl{margin-left:0}.TopNavBar_topnavbar_vObpl .TopNavBar_right-section_vObpl{display:flex;align-items:center;margin-left:auto;justify-content:flex-end;gap:1rem;padding-left:1rem}.TopNavBar_topnavbar_vObpl .TopNavBar_menu-button_vObpl{flex-shrink:0;margin-left:.75rem;display:none;--font-size: 1rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_vObpl .TopNavBar_menu-button_vObpl{display:initial}}.TopNavBar_topnavbar_vObpl .TopNavBar_menu-button_vObpl.TopNavBar_menu--collapsed_vObpl{display:initial}')),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();
2
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const o="TopNavBar_topnavbar_vObpl",a="TopNavBar_logo_vObpl",l="TopNavBar_separator_vObpl",e={"sr-only":"TopNavBar_sr-only_vObpl",topnavbar:o,"left-section":"TopNavBar_left-section_vObpl","logo-link":"TopNavBar_logo-link_vObpl","logo-container":"TopNavBar_logo-container_vObpl","logo-small":"TopNavBar_logo-small_vObpl",logo:a,separator:l,"middle-section":"TopNavBar_middle-section_vObpl","right-section":"TopNavBar_right-section_vObpl","menu-button":"TopNavBar_menu-button_vObpl","menu--collapsed":"TopNavBar_menu--collapsed_vObpl"};exports.default=e,exports.logo=a,exports.separator=l,exports.topnavbar=o;
3
3
  //# sourceMappingURL=TopNavBar.module.scss.cjs.js.map
@@ -1,20 +1,20 @@
1
- !function(){"use strict";try{if("undefined"!=typeof document){var a=document.createElement("style");a.appendChild(document.createTextNode('.TopNavBar_sr-only_PX3IM{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.TopNavBar_hidden_PX3IM{display:none}.TopNavBar_slide-in_PX3IM{animation:TopNavBar_slide-in_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-in_PX3IM{animation-duration:.1ms}}.TopNavBar_slide-out_PX3IM{animation:TopNavBar_slide-out_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-out_PX3IM{animation-duration:.1ms}}@keyframes TopNavBar_slide-in_PX3IM{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes TopNavBar_slide-out_PX3IM{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 */.TopNavBar_topnavbar_PX3IM{position:sticky;top:0;left:0;z-index:3;width:100%;display:flex;align-items:center;height:4rem;padding:0 .75rem 0 0;background-color:var(--sidenavbar-background);box-shadow:0 2px 4px #0105320a,0 4px 5px #0105320a,0 1px 10px #01053214;--font-size: .875rem;flex-wrap:nowrap}.TopNavBar_topnavbar_PX3IM .TopNavBar_left-section_PX3IM{flex-shrink:0;display:flex;align-items:center}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-link_PX3IM{display:flex;align-items:center;text-decoration:none}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM{display:flex;align-items:center}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo-small_PX3IM{height:2.5rem;display:flex;align-items:center;margin:0 1rem}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo_PX3IM{display:none}@media screen and (min-width:30em){.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo-small_PX3IM{display:none;height:0}.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo_PX3IM{display:block;margin-left:1rem}}@media screen and (min-width:30em)and (min-width:50em){.TopNavBar_topnavbar_PX3IM .TopNavBar_logo-container_PX3IM .TopNavBar_logo_PX3IM{margin-left:.75rem;margin-right:0}}.TopNavBar_topnavbar_PX3IM .TopNavBar_sr-only_PX3IM{position:absolute;margin:-1px;height:1px;width:1px;overflow:hidden}.TopNavBar_topnavbar_PX3IM .TopNavBar_separator_PX3IM{border:none;width:1px;height:2.5rem;background-color:#dedee6;flex-shrink:0;align-self:center;margin:0 3rem}.TopNavBar_topnavbar_PX3IM .TopNavBar_middle-section_PX3IM{flex:1;display:flex;align-items:center;min-width:0;margin-left:6.0625rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_PX3IM .TopNavBar_middle-section_PX3IM{margin-left:0}}.TopNavBar_topnavbar_PX3IM .TopNavBar_separator_PX3IM+.TopNavBar_middle-section_PX3IM{margin-left:0}.TopNavBar_topnavbar_PX3IM .TopNavBar_right-section_PX3IM{display:flex;align-items:center;margin-left:auto;justify-content:flex-end;gap:1rem;padding-left:1rem}.TopNavBar_topnavbar_PX3IM .TopNavBar_menu-button_PX3IM{flex-shrink:0;margin-left:.75rem;display:none;--font-size: 1rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_PX3IM .TopNavBar_menu-button_PX3IM{display:initial}}.TopNavBar_topnavbar_PX3IM .TopNavBar_menu-button_PX3IM.TopNavBar_menu--collapsed_PX3IM{display:initial}')),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();
2
- const topnavbar = "TopNavBar_topnavbar_PX3IM";
3
- const logo = "TopNavBar_logo_PX3IM";
4
- const separator = "TopNavBar_separator_PX3IM";
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var a=document.createElement("style");a.appendChild(document.createTextNode('.TopNavBar_sr-only_vObpl{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.TopNavBar_hidden_vObpl{display:none}.TopNavBar_slide-in_vObpl{animation:TopNavBar_slide-in_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-in_vObpl{animation-duration:.1ms}}.TopNavBar_slide-out_vObpl{animation:TopNavBar_slide-out_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.TopNavBar_slide-out_vObpl{animation-duration:.1ms}}@keyframes TopNavBar_slide-in_vObpl{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes TopNavBar_slide-out_vObpl{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 */.TopNavBar_topnavbar_vObpl{position:sticky;top:0;left:0;z-index:3;width:100%;display:flex;align-items:center;height:4rem;padding:0 .75rem 0 0;background-color:var(--sidenavbar-background);box-shadow:0 2px 4px #0105320a,0 4px 5px #0105320a,0 1px 10px #01053214;--font-size: .875rem;flex-wrap:nowrap}.TopNavBar_topnavbar_vObpl .TopNavBar_left-section_vObpl{flex-shrink:0;display:flex;align-items:center}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-link_vObpl{display:flex;align-items:center;text-decoration:none}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl{display:flex;align-items:center}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo-small_vObpl{height:2.5rem;display:flex;align-items:center;margin:0 1rem}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo_vObpl{display:none}@media screen and (min-width:30em){.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo-small_vObpl{display:none;height:0}.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo_vObpl{display:block;margin-left:1rem}}@media screen and (min-width:30em)and (min-width:50em){.TopNavBar_topnavbar_vObpl .TopNavBar_logo-container_vObpl .TopNavBar_logo_vObpl{margin-left:.75rem;margin-right:0}}.TopNavBar_topnavbar_vObpl .TopNavBar_sr-only_vObpl{position:absolute;margin:-1px;height:1px;width:1px;overflow:hidden}.TopNavBar_topnavbar_vObpl .TopNavBar_separator_vObpl{border:none;width:1px;height:2.5rem;background-color:#dedee6;flex-shrink:0;align-self:center;margin:0 3rem}.TopNavBar_topnavbar_vObpl .TopNavBar_middle-section_vObpl{flex:1;display:flex;align-items:center;min-width:0;margin-left:6.0625rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_vObpl .TopNavBar_middle-section_vObpl{margin-left:0}}.TopNavBar_topnavbar_vObpl .TopNavBar_separator_vObpl+.TopNavBar_middle-section_vObpl{margin-left:0}.TopNavBar_topnavbar_vObpl .TopNavBar_right-section_vObpl{display:flex;align-items:center;margin-left:auto;justify-content:flex-end;gap:1rem;padding-left:1rem}.TopNavBar_topnavbar_vObpl .TopNavBar_menu-button_vObpl{flex-shrink:0;margin-left:.75rem;display:none;--font-size: 1rem}@media screen and (max-width:50em){.TopNavBar_topnavbar_vObpl .TopNavBar_menu-button_vObpl{display:initial}}.TopNavBar_topnavbar_vObpl .TopNavBar_menu-button_vObpl.TopNavBar_menu--collapsed_vObpl{display:initial}')),document.head.appendChild(a)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}}();
2
+ const topnavbar = "TopNavBar_topnavbar_vObpl";
3
+ const logo = "TopNavBar_logo_vObpl";
4
+ const separator = "TopNavBar_separator_vObpl";
5
5
  const classes = {
6
- "sr-only": "TopNavBar_sr-only_PX3IM",
6
+ "sr-only": "TopNavBar_sr-only_vObpl",
7
7
  topnavbar,
8
- "left-section": "TopNavBar_left-section_PX3IM",
9
- "logo-link": "TopNavBar_logo-link_PX3IM",
10
- "logo-container": "TopNavBar_logo-container_PX3IM",
11
- "logo-small": "TopNavBar_logo-small_PX3IM",
8
+ "left-section": "TopNavBar_left-section_vObpl",
9
+ "logo-link": "TopNavBar_logo-link_vObpl",
10
+ "logo-container": "TopNavBar_logo-container_vObpl",
11
+ "logo-small": "TopNavBar_logo-small_vObpl",
12
12
  logo,
13
13
  separator,
14
- "middle-section": "TopNavBar_middle-section_PX3IM",
15
- "right-section": "TopNavBar_right-section_PX3IM",
16
- "menu-button": "TopNavBar_menu-button_PX3IM",
17
- "menu--collapsed": "TopNavBar_menu--collapsed_PX3IM"
14
+ "middle-section": "TopNavBar_middle-section_vObpl",
15
+ "right-section": "TopNavBar_right-section_vObpl",
16
+ "menu-button": "TopNavBar_menu-button_vObpl",
17
+ "menu--collapsed": "TopNavBar_menu--collapsed_vObpl"
18
18
  };
19
19
  export {
20
20
  classes as default,
@@ -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\n// Declared as a plain component, not `ForwardRefRenderFunction`: it was never wrapped in\n// `forwardRef` and takes only props at runtime. React 19 rejects two-argument functions as JSX\n// element types, which surfaced the mismatch. `ref` still reaches <Button> via `...rest`.\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":"sOAyCgE,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\n// Declared as a plain component, not `ForwardRefRenderFunction`: it was never wrapped in\n// `forwardRef` and takes only props at runtime. React 19 rejects two-argument functions as JSX\n// element types, which surfaced the mismatch. `ref` still reaches <Button> via `...rest`.\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":";;;AAyCO,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_PX3IM{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_PX3IM{display:none}.IdentityProviderButton_slide-in_PX3IM{animation:IdentityProviderButton_slide-in_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_PX3IM{animation-duration:.1ms}}.IdentityProviderButton_slide-out_PX3IM{animation:IdentityProviderButton_slide-out_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_PX3IM{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_PX3IM{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_PX3IM{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_PX3IM{width:100%}.IdentityProviderButton_idp-button--with-icon_PX3IM{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_PX3IM","idp-button--with-icon":"IdentityProviderButton_idp-button--with-icon_PX3IM"};
1
+ !function(){"use strict";try{if("undefined"!=typeof document){var e=document.createElement("style");e.appendChild(document.createTextNode('.IdentityProviderButton_sr-only_vObpl{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_vObpl{display:none}.IdentityProviderButton_slide-in_vObpl{animation:IdentityProviderButton_slide-in_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_vObpl{animation-duration:.1ms}}.IdentityProviderButton_slide-out_vObpl{animation:IdentityProviderButton_slide-out_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_vObpl{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_vObpl{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_vObpl{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_vObpl{width:100%}.IdentityProviderButton_idp-button--with-icon_vObpl{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_vObpl","idp-button--with-icon":"IdentityProviderButton_idp-button--with-icon_vObpl"};
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_PX3IM{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_PX3IM{display:none}.IdentityProviderButton_slide-in_PX3IM{animation:IdentityProviderButton_slide-in_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_PX3IM{animation-duration:.1ms}}.IdentityProviderButton_slide-out_PX3IM{animation:IdentityProviderButton_slide-out_PX3IM .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_PX3IM{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_PX3IM{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_PX3IM{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_PX3IM{width:100%}.IdentityProviderButton_idp-button--with-icon_PX3IM{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_vObpl{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.IdentityProviderButton_hidden_vObpl{display:none}.IdentityProviderButton_slide-in_vObpl{animation:IdentityProviderButton_slide-in_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-in_vObpl{animation-duration:.1ms}}.IdentityProviderButton_slide-out_vObpl{animation:IdentityProviderButton_slide-out_vObpl .5s forwards}@media(prefers-reduced-motion:reduce){.IdentityProviderButton_slide-out_vObpl{animation-duration:.1ms}}@keyframes IdentityProviderButton_slide-in_vObpl{0%{transform:translateY(100vh)}to{transform:translateY(0)}}@keyframes IdentityProviderButton_slide-out_vObpl{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_vObpl{width:100%}.IdentityProviderButton_idp-button--with-icon_vObpl{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_PX3IM",
4
- "idp-button--with-icon": "IdentityProviderButton_idp-button--with-icon_PX3IM"
3
+ "idp-button": "IdentityProviderButton_idp-button_vObpl",
4
+ "idp-button--with-icon": "IdentityProviderButton_idp-button--with-icon_vObpl"
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 = myElement.contains(event.target as Node);\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","contains","target","useEffect","setTimeout","window","addEventListener","removeEventListener"],"mappings":"iIAkB+B,CAC7BA,EACAC,EACAC,KAEA,SAASC,EAAcC,GACrB,MAAMC,EAAY,MAAAL,OAAA,EAAAA,EAAcM,QAC3BD,IAG0BA,EAAUE,SAASH,EAAMI,SAGtDP,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 = myElement.contains(event.target as Node);\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","contains","target","useEffect","setTimeout","window","addEventListener","removeEventListener"],"mappings":"iIAkB+B,CAC7BA,EACAC,EACAC,KAEA,SAASC,EAAcC,GACrB,MAAMC,EAAY,MAAAL,OAAA,EAAAA,EAAcM,QAC3BD,IAG0BA,EAAUE,SAASH,EAAMI,SAGtDP,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 = myElement.contains(event.target as Node);\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,UAAU,SAAS,MAAM,MAAc;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 = myElement.contains(event.target as Node);\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,UAAU,SAAS,MAAM,MAAc;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(),o=u?[r,t,...u]:[r,t];return e.useCallback((...e)=>{null!=c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{r(...e)},t)},o)};
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),o=u?[r,t,...u]:[r,t];return e.useCallback((...e)=>{null!=c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{r(...e)},t)},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 return 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"],"names":["callback","delay","dependencies","timeout","React","useRef","comboDeps","useCallback","args","current","clearTimeout","setTimeout"],"mappings":"sIAkBoC,CAClCA,EACAC,EACAC,KAEA,MAAMC,EAAUC,EAAMC,SAChBC,EAAYJ,EAAe,CAACF,EAAUC,KAAUC,GAAgB,CAACF,EAAUC,GAEjF,OAAOG,EAAMG,YAAY,IAAIC,KACJ,MAAnBL,EAAQM,SACVC,aAAaP,EAAQM,SAGvBN,EAAQM,QAAUE,WAAW,KAC3BX,KAAYQ,IACXP,IACFK"}
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 return 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"],"names":["callback","delay","dependencies","timeout","React","useRef","comboDeps","useCallback","args","current","clearTimeout","setTimeout"],"mappings":"sIAkBoC,CAClCA,EACAC,EACAC,KAEA,MAAMC,EAAUC,EAAMC,YAAkD,GAClEC,EAAYJ,EAAe,CAACF,EAAUC,KAAUC,GAAgB,CAACF,EAAUC,GAEjF,OAAOG,EAAMG,YAAY,IAAIC,KACJ,MAAnBL,EAAQM,SACVC,aAAaP,EAAQM,SAGvBN,EAAQM,QAAUE,WAAW,KAC3BX,KAAYQ,IACXP,IACFK"}
@@ -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
  return 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 return 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"],"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,SAAO,MAAM,YAAY,IAAI,SAAY;AACvC,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;AACd;"}
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 return 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"],"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,SAAO,MAAM,YAAY,IAAI,SAAY;AACvC,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;AACd;"}
@@ -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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,CAAwBvE,IACpD,IAAA,MAAWwE,KAAYb,EACrBa,EAASf,iBAAiB,SAAUH,EAExC,CAEA,IAAImB,EACAC,EAAoB,EACpBC,EAAqB,EACzB,GAA8B,oBAAnBC,iBAAkC,OAAA9D,EAAArB,EAAaV,gCAAuBqD,SAAS,CACxF,MAAMyC,EAAKpF,EAAaV,sBAAsBqD,QAC9CsC,EAAoBG,EAAGpC,YACvBkC,EAAqBE,EAAGrC,aACxBiC,EAAiB,IAAIG,eAAeE,IAClC,MAAMC,EAAQD,EAAQ,GACtB,IAAKC,EACH,OAEF,MAAMpD,MAAEA,EAAAE,OAAOA,GAAWkD,EAAMC,aAC5BC,KAAKC,IAAIvD,EAAQ+C,GAAqB,GAAKO,KAAKC,IAAIrD,EAAS8C,GAAsB,KACrFD,EAAoB/C,EACpBgD,EAAqB9C,EACP,OAAVwB,GACFE,qBAAqBF,GAEvBA,EAAQG,sBAAsB,KAC5BH,EAAQ,KACRL,EAAsBZ,eAI5BqC,EAAeU,QAAQN,EACzB,CAEA,MAAO,KACS,OAAVxB,GACFE,qBAAqBF,GAGvB5C,OAAO2E,oBAAoB,SAAU9B,GACrC7C,OAAO2E,oBAAoB,SAAU9B,GAAc,GAE/C7C,OAAOiD,iBACTjD,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,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,IAA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BC,EAAqB,EACzB,GAA8B,oBAAnBC,iBAAkC,OAAA9D,EAAArB,EAAaV,gCAAuBqD,SAAS,CACxF,MAAMyC,EAAKpF,EAAaV,sBAAsBqD,QAC9CsC,EAAoBG,EAAGpC,YACvBkC,EAAqBE,EAAGrC,aACxBiC,EAAiB,IAAIG,eAAeE,IAClC,MAAMC,EAAQD,EAAQ,GACtB,IAAKC,EACH,OAEF,MAAMpD,MAAEA,EAAAE,OAAOA,GAAWkD,EAAMC,aAC5BC,KAAKC,IAAIvD,EAAQ+C,GAAqB,GAAKO,KAAKC,IAAIrD,EAAS8C,GAAsB,KACrFD,EAAoB/C,EACpBgD,EAAqB9C,EACP,OAAVwB,GACFE,qBAAqBF,GAEvBA,EAAQG,sBAAsB,KAC5BH,EAAQ,KACRL,EAAsBZ,eAI5BqC,EAAeU,QAAQN,EACzB,CAEA,MAAO,KACS,OAAVxB,GACFE,qBAAqBF,GAGvB5C,OAAO2E,oBAAoB,SAAU9B,GACrC7C,OAAO2E,oBAAoB,SAAU9B,GAAc,GAE/C7C,OAAOiD,iBACTjD,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 +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;AACT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,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,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,MAA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MAAM;AAClB,iCAAqB,KAAK;AAAA,UAC5B;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 +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;"}