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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) 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.module.scss.cjs.js +2 -2
  10. package/dist/components/ContextMenu/ContextMenu.module.scss.es.js +6 -6
  11. package/dist/components/ContextMenu/ContextMenuDivider.module.scss.cjs.js +2 -2
  12. package/dist/components/ContextMenu/ContextMenuDivider.module.scss.es.js +2 -2
  13. package/dist/components/ContextMenu/ContextMenuItem.module.scss.cjs.js +2 -2
  14. package/dist/components/ContextMenu/ContextMenuItem.module.scss.es.js +3 -3
  15. package/dist/components/DataGrid/DataGrid.module.scss.cjs.js +2 -2
  16. package/dist/components/DataGrid/DataGrid.module.scss.es.js +8 -8
  17. package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.cjs.js +2 -2
  18. package/dist/components/DataGrid/DataGridActions/DataGridActions.module.scss.es.js +6 -6
  19. package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.cjs.js +2 -2
  20. package/dist/components/DataGrid/DataGridActions/DataGridColumnsToggle.module.scss.es.js +7 -7
  21. package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.cjs.js +2 -2
  22. package/dist/components/DataGrid/DataGridBody/DataGridBody.module.scss.es.js +2 -2
  23. package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.cjs.js +2 -2
  24. package/dist/components/DataGrid/DataGridBody/DataGridCell/DataGridCell.module.scss.es.js +5 -5
  25. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.cjs.js +2 -2
  26. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawer.module.scss.es.js +4 -4
  27. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.cjs.js +2 -2
  28. package/dist/components/DataGrid/DataGridBody/DataGridDrawer/DataGridDrawerItem.module.scss.es.js +5 -5
  29. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.cjs.js +2 -2
  30. package/dist/components/DataGrid/DataGridBody/DataGridRow/DataGridRow.module.scss.es.js +24 -24
  31. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.cjs.js +1 -1
  32. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.cjs.js.map +1 -1
  33. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.es.js +1 -1
  34. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.es.js.map +1 -1
  35. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.cjs.js +2 -2
  36. package/dist/components/DataGrid/DataGridFilters/DataGridFilter.module.scss.es.js +9 -9
  37. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js +1 -1
  38. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.cjs.js.map +1 -1
  39. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.es.js +17 -21
  40. package/dist/components/DataGrid/DataGridFilters/DataGridFilterService.es.js.map +1 -1
  41. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js +1 -1
  42. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.cjs.js.map +1 -1
  43. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js +15 -4
  44. package/dist/components/DataGrid/DataGridFilters/DataGridFilterTag.es.js.map +1 -1
  45. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js +1 -1
  46. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.cjs.js.map +1 -1
  47. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.es.js +54 -6
  48. package/dist/components/DataGrid/DataGridFilters/DataGridFilterValueSelect.es.js.map +1 -1
  49. package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.cjs.js.map +1 -1
  50. package/dist/components/DataGrid/DataGridFilters/DataGridFilters.interfaces.es.js.map +1 -1
  51. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.cjs.js +2 -2
  52. package/dist/components/DataGrid/DataGridFilters/DataGridToolbar.module.scss.es.js +10 -10
  53. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.cjs.js +2 -2
  54. package/dist/components/DataGrid/DataGridFilters/DateTimePicker/DateTimePicker.module.scss.es.js +17 -17
  55. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.cjs.js +2 -2
  56. package/dist/components/DataGrid/DataGridHeader/DataGridHeader.module.scss.es.js +4 -4
  57. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.cjs.js +2 -2
  58. package/dist/components/DataGrid/DataGridHeader/DataGridHeaderCell.module.scss.es.js +11 -11
  59. package/dist/components/DatePicker/DatePicker.module.scss.cjs.js +2 -2
  60. package/dist/components/DatePicker/DatePicker.module.scss.es.js +31 -31
  61. package/dist/components/Form/Checkbox/Checkbox.module.scss.cjs.js +2 -2
  62. package/dist/components/Form/Checkbox/Checkbox.module.scss.es.js +13 -13
  63. package/dist/components/Form/Fieldset/Fieldset.cjs.js +1 -1
  64. package/dist/components/Form/Fieldset/Fieldset.cjs.js.map +1 -1
  65. package/dist/components/Form/Fieldset/Fieldset.es.js +3 -4
  66. package/dist/components/Form/Fieldset/Fieldset.es.js.map +1 -1
  67. package/dist/components/Form/Fieldset/Fieldset.module.scss.cjs.js +2 -2
  68. package/dist/components/Form/Fieldset/Fieldset.module.scss.es.js +6 -6
  69. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.cjs.js +2 -2
  70. package/dist/components/Form/FileUpload/FileItem/FileItem.module.scss.es.js +18 -18
  71. package/dist/components/Form/FileUpload/FileUpload.module.scss.cjs.js +2 -2
  72. package/dist/components/Form/FileUpload/FileUpload.module.scss.es.js +16 -16
  73. package/dist/components/Form/Form.module.scss.cjs.js +2 -2
  74. package/dist/components/Form/Form.module.scss.es.js +2 -2
  75. package/dist/components/Form/FormControl/FormControl.cjs.js +1 -1
  76. package/dist/components/Form/FormControl/FormControl.cjs.js.map +1 -1
  77. package/dist/components/Form/FormControl/FormControl.es.js +4 -5
  78. package/dist/components/Form/FormControl/FormControl.es.js.map +1 -1
  79. package/dist/components/Form/FormControl/FormControl.module.scss.cjs.js +2 -2
  80. package/dist/components/Form/FormControl/FormControl.module.scss.es.js +13 -13
  81. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.cjs.js +2 -2
  82. package/dist/components/Form/FormErrorText/FormErrorText.module.scss.es.js +6 -6
  83. package/dist/components/Form/FormGroup/FormGroup.module.scss.cjs.js +2 -2
  84. package/dist/components/Form/FormGroup/FormGroup.module.scss.es.js +3 -3
  85. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.cjs.js +2 -2
  86. package/dist/components/Form/FormHelperText/FormHelperText.module.scss.es.js +4 -4
  87. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.cjs.js +2 -2
  88. package/dist/components/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss.es.js +6 -6
  89. package/dist/components/Form/Input/Input.module.scss.cjs.js +2 -2
  90. package/dist/components/Form/Input/Input.module.scss.es.js +8 -8
  91. package/dist/components/Form/Label/Label.module.scss.cjs.js +2 -2
  92. package/dist/components/Form/Label/Label.module.scss.es.js +2 -2
  93. package/dist/components/Form/Radio/Radio.module.scss.cjs.js +2 -2
  94. package/dist/components/Form/Radio/Radio.module.scss.es.js +11 -11
  95. package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js +1 -1
  96. package/dist/components/Form/Select/MultiSelect/MultiOption.cjs.js.map +1 -1
  97. package/dist/components/Form/Select/MultiSelect/MultiOption.es.js +8 -6
  98. package/dist/components/Form/Select/MultiSelect/MultiOption.es.js.map +1 -1
  99. package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js +1 -1
  100. package/dist/components/Form/Select/MultiSelect/MultiSelect.cjs.js.map +1 -1
  101. package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js +180 -36
  102. package/dist/components/Form/Select/MultiSelect/MultiSelect.es.js.map +1 -1
  103. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.cjs.js +2 -2
  104. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js +20 -15
  105. package/dist/components/Form/Select/MultiSelect/MultiSelect.module.scss.es.js.map +1 -1
  106. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.cjs.js +2 -2
  107. package/dist/components/Form/Select/MultiSelect/SelectButton.module.scss.es.js +2 -2
  108. package/dist/components/Form/Select/MultiSelect/SelectedOptions.cjs.js.map +1 -1
  109. package/dist/components/Form/Select/MultiSelect/SelectedOptions.es.js.map +1 -1
  110. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.cjs.js +2 -2
  111. package/dist/components/Form/Select/MultiSelect/SelectedOptions.module.scss.es.js +4 -4
  112. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.cjs.js +1 -1
  113. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.cjs.js.map +1 -1
  114. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.es.js +57 -3
  115. package/dist/components/Form/Select/MultiSelect/useArrowNavigation.es.js.map +1 -1
  116. package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js +1 -1
  117. package/dist/components/Form/Select/MultiSelect/useSearch.cjs.js.map +1 -1
  118. package/dist/components/Form/Select/MultiSelect/useSearch.es.js +69 -52
  119. package/dist/components/Form/Select/MultiSelect/useSearch.es.js.map +1 -1
  120. package/dist/components/Form/Select/Select.interfaces.cjs.js.map +1 -1
  121. package/dist/components/Form/Select/Select.interfaces.es.js.map +1 -1
  122. package/dist/components/Form/Select/SingleSelect/Option.cjs.js +1 -1
  123. package/dist/components/Form/Select/SingleSelect/Option.cjs.js.map +1 -1
  124. package/dist/components/Form/Select/SingleSelect/Option.es.js +9 -8
  125. package/dist/components/Form/Select/SingleSelect/Option.es.js.map +1 -1
  126. package/dist/components/Form/Select/SingleSelect/Select.cjs.js +1 -1
  127. package/dist/components/Form/Select/SingleSelect/Select.cjs.js.map +1 -1
  128. package/dist/components/Form/Select/SingleSelect/Select.es.js +160 -33
  129. package/dist/components/Form/Select/SingleSelect/Select.es.js.map +1 -1
  130. package/dist/components/Form/Select/SingleSelect/Select.module.scss.cjs.js +2 -2
  131. package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js +21 -17
  132. package/dist/components/Form/Select/SingleSelect/Select.module.scss.es.js.map +1 -1
  133. package/dist/components/Form/Select/SingleSelect/useArrowNavigation.cjs.js +1 -1
  134. package/dist/components/Form/Select/SingleSelect/useArrowNavigation.cjs.js.map +1 -1
  135. package/dist/components/Form/Select/SingleSelect/useArrowNavigation.es.js +62 -3
  136. package/dist/components/Form/Select/SingleSelect/useArrowNavigation.es.js.map +1 -1
  137. package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js +1 -1
  138. package/dist/components/Form/Select/SingleSelect/useSearch.cjs.js.map +1 -1
  139. package/dist/components/Form/Select/SingleSelect/useSearch.es.js +46 -34
  140. package/dist/components/Form/Select/SingleSelect/useSearch.es.js.map +1 -1
  141. package/dist/components/Form/Select/useAddNewBtn.cjs.js +1 -1
  142. package/dist/components/Form/Select/useAddNewBtn.cjs.js.map +1 -1
  143. package/dist/components/Form/Select/useAddNewBtn.es.js +6 -5
  144. package/dist/components/Form/Select/useAddNewBtn.es.js.map +1 -1
  145. package/dist/components/Form/Select/useAddNewBtn.module.scss.cjs.js +2 -2
  146. package/dist/components/Form/Select/useAddNewBtn.module.scss.es.js +4 -4
  147. package/dist/components/Form/Select/useBaseSearch.cjs.js +2 -0
  148. package/dist/components/Form/Select/useBaseSearch.cjs.js.map +1 -0
  149. package/dist/components/Form/Select/useBaseSearch.es.js +85 -0
  150. package/dist/components/Form/Select/useBaseSearch.es.js.map +1 -0
  151. package/dist/components/Form/Textarea/Textarea.module.scss.cjs.js +2 -2
  152. package/dist/components/Form/Textarea/Textarea.module.scss.es.js +6 -6
  153. package/dist/components/Form/Toggle/Toggle.module.scss.cjs.js +2 -2
  154. package/dist/components/Form/Toggle/Toggle.module.scss.es.js +18 -18
  155. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.cjs.js +2 -2
  156. package/dist/components/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss.es.js +5 -5
  157. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.cjs.js +2 -2
  158. package/dist/components/Form/Wrapper/InputWrapper/InputWrapper.module.scss.es.js +5 -5
  159. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.cjs.js +2 -2
  160. package/dist/components/Form/Wrapper/MultiSelectWrapper/MultiSelectWrapper.module.scss.es.js +3 -3
  161. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js +1 -1
  162. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.cjs.js.map +1 -1
  163. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.es.js +7 -5
  164. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.es.js.map +1 -1
  165. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.cjs.js +2 -2
  166. package/dist/components/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss.es.js +5 -5
  167. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.cjs.js +2 -2
  168. package/dist/components/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss.es.js +3 -3
  169. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.cjs.js +2 -2
  170. package/dist/components/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss.es.js +8 -8
  171. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.cjs.js +2 -2
  172. package/dist/components/Form/Wrapper/Wrapper/Wrapper.module.scss.es.js +6 -6
  173. package/dist/components/Icon/Icon.module.scss.cjs.js +2 -2
  174. package/dist/components/Icon/Icon.module.scss.es.js +108 -108
  175. package/dist/components/Layout/ActionBar/ActionBar.module.scss.cjs.js +2 -2
  176. package/dist/components/Layout/ActionBar/ActionBar.module.scss.es.js +10 -10
  177. package/dist/components/Layout/Card/Card.module.scss.cjs.js +2 -2
  178. package/dist/components/Layout/Card/Card.module.scss.es.js +12 -12
  179. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.cjs.js +2 -2
  180. package/dist/components/Layout/ContentHeader/ContentHeader.module.scss.es.js +19 -19
  181. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.cjs.js +2 -2
  182. package/dist/components/Layout/FormPage/FormWithStepper/FormSection/FormSection.module.scss.es.js +4 -4
  183. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.cjs.js +2 -2
  184. package/dist/components/Layout/FormPage/FormWithStepper/FormStepper/FormStepper.module.scss.es.js +2 -2
  185. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.cjs.js +2 -2
  186. package/dist/components/Layout/FormPage/FormWithStepper/FormWithStepper.module.scss.es.js +3 -3
  187. package/dist/components/Link/Link.module.scss.cjs.js +2 -2
  188. package/dist/components/Link/Link.module.scss.es.js +17 -17
  189. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.cjs.js +2 -2
  190. package/dist/components/Notifications/Alert/AlertContainer/AlertContainer.module.scss.es.js +11 -11
  191. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.cjs.js +2 -2
  192. package/dist/components/Notifications/Alert/AlertItem/AlertItem.module.scss.es.js +22 -22
  193. package/dist/components/Notifications/Banner/Banner.module.scss.cjs.js +2 -2
  194. package/dist/components/Notifications/Banner/Banner.module.scss.es.js +9 -9
  195. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.cjs.js +2 -2
  196. package/dist/components/Notifications/BaseModal/BaseModal.module.scss.es.js +5 -5
  197. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.cjs.js +2 -2
  198. package/dist/components/Notifications/BaseModal/BaseModalActions/BaseModalActions.module.scss.es.js +4 -4
  199. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.cjs.js +2 -2
  200. package/dist/components/Notifications/BaseModal/BaseModalContent/BaseModalContent.module.scss.es.js +2 -2
  201. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.cjs.js +2 -2
  202. package/dist/components/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.module.scss.es.js +6 -6
  203. package/dist/components/Notifications/Dialog/Dialog.module.scss.cjs.js +2 -2
  204. package/dist/components/Notifications/Dialog/Dialog.module.scss.es.js +4 -4
  205. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.cjs.js +2 -2
  206. package/dist/components/Notifications/Dialog/DialogActions/DialogActions.module.scss.es.js +3 -3
  207. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.cjs.js +2 -2
  208. package/dist/components/Notifications/Dialog/DialogTitle/DialogTitle.module.scss.es.js +10 -10
  209. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.cjs.js +2 -2
  210. package/dist/components/Notifications/SideSheet/SideSheet.module.scss.es.js +13 -13
  211. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.cjs.js +2 -2
  212. package/dist/components/Notifications/SideSheet/SideSheetContent/SideSheetContent.module.scss.es.js +2 -2
  213. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.cjs.js +2 -2
  214. package/dist/components/Notifications/SideSheet/SideSheetHeader/SideSheetHeader.module.scss.es.js +2 -2
  215. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.cjs.js +2 -2
  216. package/dist/components/Notifications/SlideInModal/SlideInModal.module.scss.es.js +10 -10
  217. package/dist/components/Pagination/Pagination.module.scss.cjs.js +2 -2
  218. package/dist/components/Pagination/Pagination.module.scss.es.js +15 -15
  219. package/dist/components/Popover/Popover.module.scss.cjs.js +2 -2
  220. package/dist/components/Popover/Popover.module.scss.es.js +3 -3
  221. package/dist/components/ProgressBar/ProgressBar.module.scss.cjs.js +2 -2
  222. package/dist/components/ProgressBar/ProgressBar.module.scss.es.js +9 -9
  223. package/dist/components/Skeleton/Skeleton.module.scss.cjs.js +2 -2
  224. package/dist/components/Skeleton/Skeleton.module.scss.es.js +5 -5
  225. package/dist/components/Spinner/Spinner.module.scss.cjs.js +2 -2
  226. package/dist/components/Spinner/Spinner.module.scss.es.js +3 -3
  227. package/dist/components/Stepper/Step.module.scss.cjs.js +2 -2
  228. package/dist/components/Stepper/Step.module.scss.es.js +22 -22
  229. package/dist/components/Stepper/Stepper.module.scss.cjs.js +2 -2
  230. package/dist/components/Stepper/Stepper.module.scss.es.js +4 -4
  231. package/dist/components/Tabs/Tab.module.scss.cjs.js +2 -2
  232. package/dist/components/Tabs/Tab.module.scss.es.js +3 -3
  233. package/dist/components/Tabs/TabButton.module.scss.cjs.js +2 -2
  234. package/dist/components/Tabs/TabButton.module.scss.es.js +12 -12
  235. package/dist/components/Tabs/Tabs.module.scss.cjs.js +2 -2
  236. package/dist/components/Tabs/Tabs.module.scss.es.js +10 -10
  237. package/dist/components/Tag/RemoveButton.module.scss.cjs.js +2 -2
  238. package/dist/components/Tag/RemoveButton.module.scss.es.js +3 -3
  239. package/dist/components/Tag/Tag.cjs.js +1 -1
  240. package/dist/components/Tag/Tag.cjs.js.map +1 -1
  241. package/dist/components/Tag/Tag.es.js +7 -1
  242. package/dist/components/Tag/Tag.es.js.map +1 -1
  243. package/dist/components/Tag/Tag.module.scss.cjs.js +2 -2
  244. package/dist/components/Tag/Tag.module.scss.es.js +6 -6
  245. package/dist/components/TextEllipsis/TextEllipsis.module.scss.cjs.js +2 -2
  246. package/dist/components/TextEllipsis/TextEllipsis.module.scss.es.js +3 -3
  247. package/dist/components/Tiles/Tile.module.scss.cjs.js +2 -2
  248. package/dist/components/Tiles/Tile.module.scss.es.js +8 -8
  249. package/dist/components/Tiles/Tiles.module.scss.cjs.js +2 -2
  250. package/dist/components/Tiles/Tiles.module.scss.es.js +2 -2
  251. package/dist/components/Tooltip/Tooltip.cjs.js.map +1 -1
  252. package/dist/components/Tooltip/Tooltip.es.js.map +1 -1
  253. package/dist/components/Tooltip/Tooltip.module.scss.cjs.js +2 -2
  254. package/dist/components/Tooltip/Tooltip.module.scss.es.js +28 -28
  255. package/dist/components/Typography/Typography.module.scss.cjs.js +2 -2
  256. package/dist/components/Typography/Typography.module.scss.es.js +13 -13
  257. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.cjs.js +2 -2
  258. package/dist/components/admin/layout/LeftNav/LeftNav.module.scss.es.js +5 -5
  259. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.cjs.js +2 -2
  260. package/dist/components/admin/layout/LeftNav/LeftNavItem/LeftNavItem.module.scss.es.js +14 -14
  261. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.cjs.js +2 -2
  262. package/dist/components/admin/layout/MicrofrontendContainer/MicrofrontendContainer.module.scss.es.js +3 -3
  263. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.cjs.js +2 -2
  264. package/dist/components/admin/layout/ProfileMenu/ProfileMenu.module.scss.es.js +7 -7
  265. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.cjs.js +2 -2
  266. package/dist/components/admin/layout/TopNavBar/TopNavBar.module.scss.es.js +13 -13
  267. package/dist/components/miscellaneous/IdentityProviderButton.cjs.js.map +1 -1
  268. package/dist/components/miscellaneous/IdentityProviderButton.es.js.map +1 -1
  269. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.cjs.js +2 -2
  270. package/dist/components/miscellaneous/IdentityProviderButton.module.scss.es.js +3 -3
  271. package/dist/hooks/useClickOutside.cjs.js +1 -1
  272. package/dist/hooks/useClickOutside.cjs.js.map +1 -1
  273. package/dist/hooks/useClickOutside.es.js +1 -1
  274. package/dist/hooks/useClickOutside.es.js.map +1 -1
  275. package/dist/hooks/useDebouncedCallback.cjs.js +1 -1
  276. package/dist/hooks/useDebouncedCallback.cjs.js.map +1 -1
  277. package/dist/hooks/useDebouncedCallback.es.js +8 -1
  278. package/dist/hooks/useDebouncedCallback.es.js.map +1 -1
  279. package/dist/index.d.ts +64 -9
  280. package/dist/readyclasses.module.scss.cjs.js +2 -2
  281. package/dist/readyclasses.module.scss.es.js +5 -5
  282. package/dist/util/helper.cjs.js +1 -1
  283. package/dist/util/helper.cjs.js.map +1 -1
  284. package/dist/util/helper.es.js +19 -0
  285. package/dist/util/helper.es.js.map +1 -1
  286. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useSearch.es.js","sources":["../../../../../src/components/Form/Select/MultiSelect/useSearch.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, { useEffect, useRef, useState } from \"react\";\nimport { SearchProps } from \"../Select.interfaces\";\nimport { omitProps } from \"../../../../util/helper\";\n\ninterface Props {\n selectId: string;\n search?: SearchProps;\n optionsCount: number;\n searchInputClassName: string;\n expanded: boolean;\n setFocusedSelectItem: (idx: number) => void;\n focusedSelectItem: number;\n describedBy?: string;\n error?: boolean;\n getOptionId: (multiSelectId: string, optionIndex: number) => string;\n getListboxId: (multiSelectId: string) => string;\n}\n\n/** @scope .*/\nexport const useSearch = ({\n selectId,\n search,\n optionsCount,\n searchInputClassName,\n expanded,\n setFocusedSelectItem,\n focusedSelectItem,\n describedBy,\n error = false,\n getOptionId,\n getListboxId\n}: Props) => {\n const [filter, setFilter] = useState(\"\");\n\n const DEFAULT_RENDER_THRESHOLD = 0;\n\n const searchInputRef = useRef<HTMLInputElement>(null);\n\n const threshold = search?.renderThreshold ?? DEFAULT_RENDER_THRESHOLD;\n const hasEnoughChildren = optionsCount >= threshold;\n\n const shouldRenderSearch = () => {\n if (search?.enabled) {\n return hasEnoughChildren;\n }\n\n if (search) {\n return search.enabled as boolean;\n }\n\n return optionsCount > DEFAULT_RENDER_THRESHOLD;\n };\n\n const renderSearch = () => {\n // Filter out non-native HTML input attributes\n const filteredProps = omitProps(\n search?.searchInputProps ?? {},\n /^(reset|prefix|suffix|wrapperProps|labeledBy|readOnlyView|error|success)$/\n );\n\n return (\n <input\n {...filteredProps}\n ref={searchInputRef}\n value={filter}\n onChange={event => setFilter(event.currentTarget.value)}\n className={[searchInputClassName, search?.searchInputProps?.className].join(\" \")}\n style={{\n display: expanded ? \"block\" : \"none\"\n }}\n type=\"text\"\n name=\"search-option\"\n placeholder={search?.searchPlaceholder}\n role=\"combobox\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-controls={getListboxId(selectId)}\n aria-describedby={describedBy}\n aria-invalid={error}\n aria-autocomplete=\"none\"\n aria-expanded={expanded}\n aria-activedescendant={getOptionId(selectId, focusedSelectItem)}\n aria-haspopup={true}\n />\n );\n };\n\n const resetSearchState = () => {\n setFilter(\"\");\n setFocusedSelectItem(0);\n };\n\n const visible = shouldRenderSearch();\n\n useEffect(() => {\n if (search?.searchInputProps?.reset) {\n resetSearchState();\n }\n }, [search?.searchInputProps?.reset]);\n\n return {\n renderSearch,\n resetSearchState,\n searchVisible: visible,\n searchThreshold: threshold,\n searchInputRef,\n filter\n };\n};\n"],"names":["_a"],"mappings":";;AAmCO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AACF,MAAa;;AACX,QAAM,CAAC,QAAQ,SAAS,IAAI,SAAS,EAAE;AAEvC,QAAM,2BAA2B;AAEjC,QAAM,iBAAiB,OAAyB,IAAI;AAEpD,QAAM,aAAY,iCAAQ,oBAAmB;AAC7C,QAAM,oBAAoB,gBAAgB;AAE1C,QAAM,qBAAqB,MAAM;AAC/B,QAAI,iCAAQ,SAAS;AACnB,aAAO;AAAA,IACT;AAEA,QAAI,QAAQ;AACV,aAAO,OAAO;AAAA,IAChB;AAEA,WAAO,eAAe;AAAA,EACxB;AAEA,QAAM,eAAe,MAAM;;AAEzB,UAAM,gBAAgB;AAAA,OACpB,iCAAQ,qBAAoB,CAAA;AAAA,MAC5B;AAAA,IAAA;AAGF,WACE,sBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACE,GAAG;AAAA,QACJ,KAAK;AAAA,QACL,OAAO;AAAA,QACP,UAAU,CAAA,UAAS,UAAU,MAAM,cAAc,KAAK;AAAA,QACtD,WAAW,CAAC,uBAAsBA,MAAA,iCAAQ,qBAAR,gBAAAA,IAA0B,SAAS,EAAE,KAAK,GAAG;AAAA,QAC/E,OAAO;AAAA,UACL,SAAS,WAAW,UAAU;AAAA,QAAA;AAAA,QAEhC,MAAK;AAAA,QACL,MAAK;AAAA,QACL,aAAa,iCAAQ;AAAA,QACrB,MAAK;AAAA,QACL,cAAa;AAAA,QACb,aAAY;AAAA,QACZ,YAAY;AAAA,QACZ,iBAAe,aAAa,QAAQ;AAAA,QACpC,oBAAkB;AAAA,QAClB,gBAAc;AAAA,QACd,qBAAkB;AAAA,QAClB,iBAAe;AAAA,QACf,yBAAuB,YAAY,UAAU,iBAAiB;AAAA,QAC9D,iBAAe;AAAA,MAAA;AAAA,IAAA;AAAA,EAGrB;AAEA,QAAM,mBAAmB,MAAM;AAC7B,cAAU,EAAE;AACZ,yBAAqB,CAAC;AAAA,EACxB;AAEA,QAAM,UAAU,mBAAA;AAEhB,YAAU,MAAM;;AACd,SAAIA,MAAA,iCAAQ,qBAAR,gBAAAA,IAA0B,OAAO;AACnC,uBAAA;AAAA,IACF;AAAA,EACF,GAAG,EAAC,sCAAQ,qBAAR,mBAA0B,KAAK,CAAC;AAEpC,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"useSearch.es.js","sources":["../../../../../src/components/Form/Select/MultiSelect/useSearch.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\";\nimport { SearchProps } from \"../Select.interfaces\";\nimport { omitProps } from \"../../../../util/helper\";\nimport { useBaseSearch } from \"../useBaseSearch\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport classes from \"./MultiSelect.module.scss\";\n\ninterface Props {\n selectId: string;\n search?: SearchProps;\n optionsCount: number;\n searchInputClassName: string;\n expanded: boolean;\n setFocusedSelectItem: (idx: number) => void;\n focusedSelectItem: number;\n describedBy?: string;\n error?: boolean;\n getOptionId: (multiSelectId: string, optionIndex: number) => string;\n getListboxId: (multiSelectId: string) => string;\n placeholder?: string;\n}\n\n/** @scope .*/\nexport const useSearch = ({\n selectId,\n search,\n optionsCount,\n searchInputClassName,\n expanded,\n setFocusedSelectItem,\n focusedSelectItem,\n describedBy,\n error = false,\n getOptionId,\n getListboxId,\n placeholder\n}: Props) => {\n const {\n filter,\n isAsyncPending,\n searchInputRef,\n threshold,\n asyncSearch,\n filterResults,\n visible,\n resetSearchState,\n defaultMinSearchLength\n } = useBaseSearch({\n search,\n optionsCount,\n defaultRenderThreshold: 0,\n resetFocusedIndex: 0,\n setFocusedSelectItem\n });\n\n const clearFilter = () => {\n filterResults({ currentTarget: { value: \"\" } } as React.ChangeEvent<HTMLInputElement>);\n searchInputRef.current?.focus();\n };\n\n const renderSearch = () => {\n // Filter out non-native HTML input attributes\n const filteredProps = omitProps(\n search?.searchInputProps ?? {},\n /^(reset|prefix|suffix|wrapperProps|labeledBy|readOnlyView|error|success)$/\n );\n\n return (\n <span\n className={classes[\"search-input-wrapper\"]}\n style={{ display: expanded ? \"flex\" : \"none\" }}\n >\n <input\n {...filteredProps}\n ref={searchInputRef}\n value={filter}\n onChange={filterResults}\n className={[searchInputClassName, search?.searchInputProps?.className].join(\" \")}\n type=\"text\"\n name=\"search-option\"\n placeholder={search?.searchPlaceholder ?? placeholder ?? \"Search...\"}\n role=\"combobox\"\n autoComplete=\"off\"\n autoCorrect=\"off\"\n spellCheck={false}\n aria-controls={getListboxId(selectId)}\n aria-describedby={describedBy}\n aria-invalid={error}\n aria-autocomplete=\"none\"\n aria-expanded={expanded}\n aria-activedescendant={getOptionId(selectId, focusedSelectItem)}\n aria-haspopup={true}\n />\n {filter && (\n <button\n type=\"button\"\n className={classes[\"search-clear-button\"]}\n onClick={clearFilter}\n aria-label=\"Clear search\"\n >\n <Icon icon={Icons.Times} />\n </button>\n )}\n </span>\n );\n };\n\n return {\n renderSearch,\n resetSearchState,\n searchVisible: visible,\n searchThreshold: threshold,\n searchInputRef,\n filter,\n isAsync: !!asyncSearch,\n isAsyncPending,\n asyncMinSearchLength: asyncSearch?.minSearchLength ?? defaultMinSearchLength\n };\n};\n"],"names":[],"mappings":";;;;;AAuCO,MAAM,YAAY,CAAC;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AACF,MAAa;AACX,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA,IACE,cAAc;AAAA,IAChB;AAAA,IACA;AAAA,IACA,wBAAwB;AAAA,IACxB,mBAAmB;AAAA,IACnB;AAAA,EAAA,CACD;AAED,QAAM,cAAc,MAAM;;AACxB,kBAAc,EAAE,eAAe,EAAE,OAAO,GAAA,GAA6C;AACrF,yBAAe,YAAf,mBAAwB;AAAA,EAC1B;AAEA,QAAM,eAAe,MAAM;;AAEzB,UAAM,gBAAgB;AAAA,OACpB,iCAAQ,qBAAoB,CAAA;AAAA,MAC5B;AAAA,IAAA;AAGF,WACE,sBAAA;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAW,QAAQ,sBAAsB;AAAA,QACzC,OAAO,EAAE,SAAS,WAAW,SAAS,OAAA;AAAA,MAAO;AAAA,MAE7C,sBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACE,GAAG;AAAA,UACJ,KAAK;AAAA,UACL,OAAO;AAAA,UACP,UAAU;AAAA,UACV,WAAW,CAAC,uBAAsB,sCAAQ,qBAAR,mBAA0B,SAAS,EAAE,KAAK,GAAG;AAAA,UAC/E,MAAK;AAAA,UACL,MAAK;AAAA,UACL,cAAa,iCAAQ,sBAAqB,eAAe;AAAA,UACzD,MAAK;AAAA,UACL,cAAa;AAAA,UACb,aAAY;AAAA,UACZ,YAAY;AAAA,UACZ,iBAAe,aAAa,QAAQ;AAAA,UACpC,oBAAkB;AAAA,UAClB,gBAAc;AAAA,UACd,qBAAkB;AAAA,UAClB,iBAAe;AAAA,UACf,yBAAuB,YAAY,UAAU,iBAAiB;AAAA,UAC9D,iBAAe;AAAA,QAAA;AAAA,MAAA;AAAA,MAEhB,UACC,sBAAA;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,MAAK;AAAA,UACL,WAAW,QAAQ,qBAAqB;AAAA,UACxC,SAAS;AAAA,UACT,cAAW;AAAA,QAAA;AAAA,QAEX,sBAAA,cAAC,MAAA,EAAK,MAAM,MAAM,MAAA,CAAO;AAAA,MAAA;AAAA,IAC3B;AAAA,EAIR;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf,iBAAiB;AAAA,IACjB;AAAA,IACA;AAAA,IACA,SAAS,CAAC,CAAC;AAAA,IACX;AAAA,IACA,uBAAsB,2CAAa,oBAAmB;AAAA,EAAA;AAE1D;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Select.interfaces.cjs.js","sources":["../../../../src/components/Form/Select/Select.interfaces.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 { ComponentPropsWithRef, ReactElement } from \"react\";\nimport { Props as InputProps } from \"../Input/Input\";\nimport { Props as SelectOptionProps } from \"./SingleSelect/Option\";\nimport { FormElement } from \"../form.interfaces\";\n\nexport type PartialInputProps = Partial<InputProps>;\n\n/**\n * Props of the elements accepted as Select/MultiSelect children. React 19 types `ReactElement`'s\n * props as `unknown`, so `children` has to name this shape for `child.props` to be readable.\n * `fixed` comes from MultiOption, which extends Option's props.\n */\nexport type OptionElementProps = SelectOptionProps & { fixed?: boolean };\n\nexport interface SearchProps {\n enabled?: boolean;\n renderThreshold?: number;\n searchPlaceholder?: string;\n searchInputProps?: PartialInputProps & { reset?: boolean };\n}\n\nexport interface AddNewProps {\n label: string;\n onAddNew: (value: string) => void;\n btnProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n alwaysEnabled?: boolean;\n}\n\nexport interface SelectProps<V extends string | readonly string[] | undefined>\n extends ComponentPropsWithRef<\"select\">, FormElement {\n children: ReactElement<OptionElementProps> | ReactElement<OptionElementProps>[];\n name?: string;\n labeledBy?: string;\n describedBy?: string;\n placeholder?: string;\n selectButtonProps?: ComponentPropsWithRef<\"button\"> & FormElement;\n search?: SearchProps;\n className?: string;\n value: V;\n clearLabel?: string;\n noResultsLabel?: string;\n onChange?: (event: React.ChangeEvent<HTMLSelectElement>, child?: ReactElement) => void;\n addNew?: AddNewProps;\n isReadOnlyView?: boolean;\n domRoot?: HTMLElement;\n}\n\nexport type SingleSelectProps = SelectProps<string>;\nexport type MultiSelectProps = SelectProps<string[]>;\n\nexport enum Position {\n Above = \"Above\",\n Below = \"Below\"\n}\n\nexport interface UseArrowNavigationParams {\n expanded: boolean;\n setExpanded: React.Dispatch<React.SetStateAction<boolean>>;\n isSearching: boolean;\n setIsSearching: React.Dispatch<React.SetStateAction<boolean>>;\n setFocusedSelectItem: React.Dispatch<React.SetStateAction<number>>;\n childrenCount: number;\n setShouldClick: React.Dispatch<React.SetStateAction<boolean>>;\n onOptionChangeHandler: (optionElement: HTMLElement | null) => void;\n searchInputRef: React.RefObject<HTMLInputElement | null>;\n addBtnRef?: React.RefObject<HTMLButtonElement | null>;\n renderThreshold: number;\n isReadOnlyView?: boolean;\n}\n\nexport interface UseSelectPositionListParams {\n expanded: boolean;\n optionListReference: React.RefObject<HTMLDivElement | null>;\n containerReference: React.RefObject<HTMLDivElement | null>;\n addBtnRef: React.RefObject<HTMLButtonElement | null>;\n}\n"],"names":["Position"],"mappings":"gFAkEO,IAAKA,GAAAA,IACVA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QAFEA,IAAAA,GAAA,CAAA"}
1
+ {"version":3,"file":"Select.interfaces.cjs.js","sources":["../../../../src/components/Form/Select/Select.interfaces.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 { ComponentPropsWithRef, ReactElement, ReactNode } from \"react\";\nimport { Props as InputProps } from \"../Input/Input\";\nimport { Props as SelectOptionProps } from \"./SingleSelect/Option\";\nimport { FormElement } from \"../form.interfaces\";\n\nexport type PartialInputProps = Partial<InputProps>;\n\n//`fixed` comes from MultiOption.\nexport type OptionElementProps = SelectOptionProps & { fixed?: boolean };\nexport interface AsyncSearchProps {\n /** Enables backend search. When set, built-in client-side filtering is disabled. */\n onSearch: (query: string) => void;\n /** Debounce applied to onSearch, in ms. Default 300. */\n debounceTime?: number;\n /** Minimum chars before onSearch fires and options render. Default 0. */\n minSearchLength?: number;\n /** Consumer sets true while a request is in flight. Shows a loading row; never shows \"no results\" while true. */\n loading?: boolean;\n /** When set, shows an error row instead of results. */\n errorLabel?: string;\n /** Optional retry affordance rendered alongside errorLabel. */\n onRetry?: () => void;\n /** Shown while the query is shorter than minSearchLength. Default \"Type to search\". */\n idleLabel?: string;\n /** Called when the user scrolls near the end of the option list. */\n onLoadMore?: () => void;\n /** More pages available. Enables the sentinel + \"loading more\" row. */\n hasMore?: boolean;\n}\n\nexport interface SearchProps {\n enabled?: boolean;\n renderThreshold?: number;\n searchPlaceholder?: string;\n searchInputProps?: PartialInputProps & { reset?: boolean };\n /** Enables backend search: disables client-side filtering and emits the typed query via `onSearch`. */\n async?: AsyncSearchProps;\n}\n\nexport interface AddNewProps {\n label: string;\n onAddNew: (value: string) => void;\n btnProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n alwaysEnabled?: boolean;\n}\n\nexport interface SelectProps<V extends string | readonly string[] | undefined>\n extends ComponentPropsWithRef<\"select\">, FormElement {\n children: ReactElement<OptionElementProps> | ReactElement<OptionElementProps>[];\n name?: string;\n labeledBy?: string;\n describedBy?: string;\n placeholder?: string;\n selectButtonProps?: ComponentPropsWithRef<\"button\"> & FormElement;\n search?: SearchProps;\n className?: string;\n value: V;\n clearLabel?: string;\n noResultsLabel?: string;\n onChange?: (event: React.ChangeEvent<HTMLSelectElement>, child?: ReactElement) => void;\n addNew?: AddNewProps;\n isReadOnlyView?: boolean;\n domRoot?: HTMLElement;\n /** Fallback display for the current value when it is absent from `children` (async mode). */\n selectedOption?: { value: string; label: ReactNode };\n /** Fallback display for picked values absent from `children` (async multi). */\n selectedOptions?: { value: string; label: ReactNode }[];\n}\n\nexport type SingleSelectProps = SelectProps<string>;\nexport type MultiSelectProps = SelectProps<string[]>;\n\nexport enum Position {\n Above = \"Above\",\n Below = \"Below\"\n}\n\nexport interface UseArrowNavigationParams {\n expanded: boolean;\n setExpanded: React.Dispatch<React.SetStateAction<boolean>>;\n isSearching: boolean;\n setIsSearching: React.Dispatch<React.SetStateAction<boolean>>;\n setFocusedSelectItem: React.Dispatch<React.SetStateAction<number>>;\n childrenCount: number;\n setShouldClick: React.Dispatch<React.SetStateAction<boolean>>;\n onOptionChangeHandler: (optionElement: HTMLElement | null) => void;\n searchInputRef: React.RefObject<HTMLInputElement | null>;\n addBtnRef?: React.RefObject<HTMLButtonElement | null>;\n renderThreshold: number;\n isReadOnlyView?: boolean;\n isAsync?: boolean;\n listRef?: React.RefObject<HTMLUListElement | null>;\n}\n\nexport interface UseSelectPositionListParams {\n expanded: boolean;\n optionListReference: React.RefObject<HTMLDivElement | null>;\n containerReference: React.RefObject<HTMLDivElement | null>;\n addBtnRef: React.RefObject<HTMLButtonElement | null>;\n}\n"],"names":["Position"],"mappings":"gFAwFO,IAAKA,GAAAA,IACVA,EAAA,MAAQ,QACRA,EAAA,MAAQ,QAFEA,IAAAA,GAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"Select.interfaces.es.js","sources":["../../../../src/components/Form/Select/Select.interfaces.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 { ComponentPropsWithRef, ReactElement } from \"react\";\nimport { Props as InputProps } from \"../Input/Input\";\nimport { Props as SelectOptionProps } from \"./SingleSelect/Option\";\nimport { FormElement } from \"../form.interfaces\";\n\nexport type PartialInputProps = Partial<InputProps>;\n\n/**\n * Props of the elements accepted as Select/MultiSelect children. React 19 types `ReactElement`'s\n * props as `unknown`, so `children` has to name this shape for `child.props` to be readable.\n * `fixed` comes from MultiOption, which extends Option's props.\n */\nexport type OptionElementProps = SelectOptionProps & { fixed?: boolean };\n\nexport interface SearchProps {\n enabled?: boolean;\n renderThreshold?: number;\n searchPlaceholder?: string;\n searchInputProps?: PartialInputProps & { reset?: boolean };\n}\n\nexport interface AddNewProps {\n label: string;\n onAddNew: (value: string) => void;\n btnProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n alwaysEnabled?: boolean;\n}\n\nexport interface SelectProps<V extends string | readonly string[] | undefined>\n extends ComponentPropsWithRef<\"select\">, FormElement {\n children: ReactElement<OptionElementProps> | ReactElement<OptionElementProps>[];\n name?: string;\n labeledBy?: string;\n describedBy?: string;\n placeholder?: string;\n selectButtonProps?: ComponentPropsWithRef<\"button\"> & FormElement;\n search?: SearchProps;\n className?: string;\n value: V;\n clearLabel?: string;\n noResultsLabel?: string;\n onChange?: (event: React.ChangeEvent<HTMLSelectElement>, child?: ReactElement) => void;\n addNew?: AddNewProps;\n isReadOnlyView?: boolean;\n domRoot?: HTMLElement;\n}\n\nexport type SingleSelectProps = SelectProps<string>;\nexport type MultiSelectProps = SelectProps<string[]>;\n\nexport enum Position {\n Above = \"Above\",\n Below = \"Below\"\n}\n\nexport interface UseArrowNavigationParams {\n expanded: boolean;\n setExpanded: React.Dispatch<React.SetStateAction<boolean>>;\n isSearching: boolean;\n setIsSearching: React.Dispatch<React.SetStateAction<boolean>>;\n setFocusedSelectItem: React.Dispatch<React.SetStateAction<number>>;\n childrenCount: number;\n setShouldClick: React.Dispatch<React.SetStateAction<boolean>>;\n onOptionChangeHandler: (optionElement: HTMLElement | null) => void;\n searchInputRef: React.RefObject<HTMLInputElement | null>;\n addBtnRef?: React.RefObject<HTMLButtonElement | null>;\n renderThreshold: number;\n isReadOnlyView?: boolean;\n}\n\nexport interface UseSelectPositionListParams {\n expanded: boolean;\n optionListReference: React.RefObject<HTMLDivElement | null>;\n containerReference: React.RefObject<HTMLDivElement | null>;\n addBtnRef: React.RefObject<HTMLButtonElement | null>;\n}\n"],"names":["Position"],"mappings":"AAkEO,IAAK,6BAAAA,cAAL;AACLA,YAAA,OAAA,IAAQ;AACRA,YAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"Select.interfaces.es.js","sources":["../../../../src/components/Form/Select/Select.interfaces.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 { ComponentPropsWithRef, ReactElement, ReactNode } from \"react\";\nimport { Props as InputProps } from \"../Input/Input\";\nimport { Props as SelectOptionProps } from \"./SingleSelect/Option\";\nimport { FormElement } from \"../form.interfaces\";\n\nexport type PartialInputProps = Partial<InputProps>;\n\n//`fixed` comes from MultiOption.\nexport type OptionElementProps = SelectOptionProps & { fixed?: boolean };\nexport interface AsyncSearchProps {\n /** Enables backend search. When set, built-in client-side filtering is disabled. */\n onSearch: (query: string) => void;\n /** Debounce applied to onSearch, in ms. Default 300. */\n debounceTime?: number;\n /** Minimum chars before onSearch fires and options render. Default 0. */\n minSearchLength?: number;\n /** Consumer sets true while a request is in flight. Shows a loading row; never shows \"no results\" while true. */\n loading?: boolean;\n /** When set, shows an error row instead of results. */\n errorLabel?: string;\n /** Optional retry affordance rendered alongside errorLabel. */\n onRetry?: () => void;\n /** Shown while the query is shorter than minSearchLength. Default \"Type to search\". */\n idleLabel?: string;\n /** Called when the user scrolls near the end of the option list. */\n onLoadMore?: () => void;\n /** More pages available. Enables the sentinel + \"loading more\" row. */\n hasMore?: boolean;\n}\n\nexport interface SearchProps {\n enabled?: boolean;\n renderThreshold?: number;\n searchPlaceholder?: string;\n searchInputProps?: PartialInputProps & { reset?: boolean };\n /** Enables backend search: disables client-side filtering and emits the typed query via `onSearch`. */\n async?: AsyncSearchProps;\n}\n\nexport interface AddNewProps {\n label: string;\n onAddNew: (value: string) => void;\n btnProps?: React.ButtonHTMLAttributes<HTMLButtonElement>;\n alwaysEnabled?: boolean;\n}\n\nexport interface SelectProps<V extends string | readonly string[] | undefined>\n extends ComponentPropsWithRef<\"select\">, FormElement {\n children: ReactElement<OptionElementProps> | ReactElement<OptionElementProps>[];\n name?: string;\n labeledBy?: string;\n describedBy?: string;\n placeholder?: string;\n selectButtonProps?: ComponentPropsWithRef<\"button\"> & FormElement;\n search?: SearchProps;\n className?: string;\n value: V;\n clearLabel?: string;\n noResultsLabel?: string;\n onChange?: (event: React.ChangeEvent<HTMLSelectElement>, child?: ReactElement) => void;\n addNew?: AddNewProps;\n isReadOnlyView?: boolean;\n domRoot?: HTMLElement;\n /** Fallback display for the current value when it is absent from `children` (async mode). */\n selectedOption?: { value: string; label: ReactNode };\n /** Fallback display for picked values absent from `children` (async multi). */\n selectedOptions?: { value: string; label: ReactNode }[];\n}\n\nexport type SingleSelectProps = SelectProps<string>;\nexport type MultiSelectProps = SelectProps<string[]>;\n\nexport enum Position {\n Above = \"Above\",\n Below = \"Below\"\n}\n\nexport interface UseArrowNavigationParams {\n expanded: boolean;\n setExpanded: React.Dispatch<React.SetStateAction<boolean>>;\n isSearching: boolean;\n setIsSearching: React.Dispatch<React.SetStateAction<boolean>>;\n setFocusedSelectItem: React.Dispatch<React.SetStateAction<number>>;\n childrenCount: number;\n setShouldClick: React.Dispatch<React.SetStateAction<boolean>>;\n onOptionChangeHandler: (optionElement: HTMLElement | null) => void;\n searchInputRef: React.RefObject<HTMLInputElement | null>;\n addBtnRef?: React.RefObject<HTMLButtonElement | null>;\n renderThreshold: number;\n isReadOnlyView?: boolean;\n isAsync?: boolean;\n listRef?: React.RefObject<HTMLUListElement | null>;\n}\n\nexport interface UseSelectPositionListParams {\n expanded: boolean;\n optionListReference: React.RefObject<HTMLDivElement | null>;\n containerReference: React.RefObject<HTMLDivElement | null>;\n addBtnRef: React.RefObject<HTMLButtonElement | null>;\n}\n"],"names":["Position"],"mappings":"AAwFO,IAAK,6BAAAA,cAAL;AACLA,YAAA,OAAA,IAAQ;AACRA,YAAA,OAAA,IAAQ;AAFE,SAAAA;AAAA,GAAA,YAAA,CAAA,CAAA;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./Select.module.scss.cjs.js"),s=require("../../../../util/helper.cjs.js"),r=e.forwardRef(({id:r,children:c,className:l,isSelected:n=!1,disableDefaultSelectedStyle:a,shouldClick:o,hasFocus:u,selectOpened:i,isSearching:d,childIndex:f,onOptionSelect:p,onFocusChange:h,disabled:S,value:b,isAddBtnFocused:g,...j},m)=>{const v=e.useRef(s.generateID(20)),x=r??v.current,y=m||e.createRef(),D=[];l&&D.push(l),n&&!a&&D.push(t.default["selected-option"]),S&&D.push(t.default.disabled),e.useEffect(()=>{n&&y.current&&o&&y.current.click()},[n,o]),e.useEffect(()=>{y.current&&u&&i&&!d&&!g&&(h&&f&&h(f),y.current.focus())},[u,y,i,d]);const E=()=>{S||null==p||p(y)};return e.createElement("li",{...j,id:x,ref:y,"data-value":b,className:D.join(" "),onClick:E,onKeyDown:e=>{"Enter"===e.code&&(e.stopPropagation(),e.preventDefault(),E())},"aria-selected":n,"aria-disabled":S,role:"option",tabIndex:S?-1:0},c)});exports.Option=r;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=require("./Select.module.scss.cjs.js"),s=require("../../../../util/helper.cjs.js"),l=e.forwardRef(({id:l,children:c,className:r,isSelected:a=!1,disableDefaultSelectedStyle:n,shouldClick:o,hasFocus:u,selectOpened:d,isSearching:i,childIndex:f,onOptionSelect:p,onFocusChange:S,disabled:b,value:h,isAddBtnFocused:g,...m},j)=>{const v=e.useRef(s.generateID(20)),x=l??v.current,y=e.useRef(null),D=j||y,E=s.classNames(r,{[t.default["selected-option"]]:a&&!n,[t.default.disabled]:b});e.useEffect(()=>{a&&D.current&&o&&D.current.click()},[a,o]),e.useEffect(()=>{D.current&&u&&d&&!i&&!g&&(S&&f&&S(f),D.current.focus())},[u,D,d,i]);const O=()=>{b||null==p||p(D)};return e.createElement("li",{...m,id:x,ref:D,"data-value":h,className:E,onClick:O,onKeyDown:e=>{"Enter"===e.code&&(e.stopPropagation(),e.preventDefault(),O())},"aria-selected":a,"aria-disabled":b,role:"option",tabIndex:b?-1:0},c)});exports.Option=l;
2
2
  //# sourceMappingURL=Option.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Option.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Option.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, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n createRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement | null>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n const innerOptionRef = (ref as RefObject<HTMLLIElement | null>) || createRef<HTMLLIElement>();\n\n const additionalClasses = [];\n className && additionalClasses.push(className);\n isSelected && !disableDefaultSelectedStyle && additionalClasses.push(classes[\"selected-option\"]);\n disabled && additionalClasses.push(classes[\"disabled\"]);\n\n useEffect(() => {\n if (isSelected && innerOptionRef.current && shouldClick) {\n innerOptionRef.current.click();\n }\n }, [isSelected, shouldClick]);\n\n useEffect(() => {\n if (innerOptionRef.current && hasFocus && selectOpened && !isSearching && !isAddBtnFocused) {\n onFocusChange && childIndex && onFocusChange(childIndex);\n innerOptionRef.current.focus();\n }\n }, [hasFocus, innerOptionRef, selectOpened, isSearching]);\n\n const onSelectHandler = () => {\n if (disabled) {\n return;\n }\n onOptionSelect?.(innerOptionRef);\n };\n\n return (\n <li // NOSONAR S6819 - <option> is only valid inside <select>/<optgroup>; this is an ARIA listbox built from <li> elements, so role=\"option\" is the correct authoring practice.\n {...rest}\n id={optionId}\n ref={innerOptionRef}\n data-value={value}\n className={additionalClasses.join(\" \")}\n onClick={onSelectHandler}\n onKeyDown={event => {\n if (event.code === \"Enter\") {\n event.stopPropagation();\n event.preventDefault();\n\n onSelectHandler();\n }\n }}\n aria-selected={isSelected}\n aria-disabled={disabled}\n role=\"option\" // NOSONAR S6842 - required by the ARIA listbox pattern; the parent <ul role=\"listbox\"> needs option-role children, and aria-selected is only valid on this role.\n tabIndex={disabled ? -1 : 0}\n >\n {children}\n </li>\n );\n};\n\nexport const Option = React.forwardRef(OptionComponent);\n"],"names":["Option","React","forwardRef","id","children","className","isSelected","disableDefaultSelectedStyle","shouldClick","hasFocus","selectOpened","isSearching","childIndex","onOptionSelect","onFocusChange","disabled","value","isAddBtnFocused","rest","ref","defaultOptionId","useRef","generateID","optionId","current","innerOptionRef","createRef","additionalClasses","push","classes","useEffect","click","focus","onSelectHandler","createElement","join","onClick","onKeyDown","event","code","stopPropagation","preventDefault","role","tabIndex"],"mappings":"8LAyHaA,EAASC,EAAMC,WA5E4C,EAEpEC,KACAC,WACAC,YACAC,cAAa,EACbC,8BACAC,cACAC,WACAC,eACAC,cACAC,aACAC,iBACAC,gBACAC,WACAC,QACAC,qBACGC,GAELC,KAEA,MAAMC,EAAkBC,EAAAA,OAAOC,EAAAA,WAAW,KACpCC,EAAWpB,GAAMiB,EAAgBI,QACjCC,EAAkBN,GAA2CO,cAE7DC,EAAoB,GAC1BtB,GAAasB,EAAkBC,KAAKvB,GACpCC,IAAeC,GAA+BoB,EAAkBC,KAAKC,EAAAA,QAAQ,oBAC7Ed,GAAYY,EAAkBC,KAAKC,EAAAA,QAAkB,UAErDC,EAAAA,UAAU,KACJxB,GAAcmB,EAAeD,SAAWhB,GAC1CiB,EAAeD,QAAQO,SAExB,CAACzB,EAAYE,IAEhBsB,EAAAA,UAAU,KACJL,EAAeD,SAAWf,GAAYC,IAAiBC,IAAgBM,IACzEH,GAAiBF,GAAcE,EAAcF,GAC7Ca,EAAeD,QAAQQ,UAExB,CAACvB,EAAUgB,EAAgBf,EAAcC,IAE5C,MAAMsB,EAAkB,KAClBlB,GAGJ,MAAAF,GAAAA,EAAiBY,IAGnB,OACExB,EAAAiC,cAAC,KAAA,IACKhB,EACJf,GAAIoB,EACJJ,IAAKM,EACL,aAAYT,EACZX,UAAWsB,EAAkBQ,KAAK,KAClCC,QAASH,EACTI,UAAWC,IACU,UAAfA,EAAMC,OACRD,EAAME,kBACNF,EAAMG,iBAENR,MAGJ,gBAAe3B,EACf,gBAAeS,EACf2B,KAAK,SACLC,SAAU5B,GAAW,EAAK,GAEzBX"}
1
+ {"version":3,"file":"Option.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Option.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, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { classNames, generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement | null>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n /** Fallback ref when none is forwarded. Must be `useRef`, not `createRef` — a fresh object\n * every render would re-trigger the focus effect below on every render, not just on focus change. */\n const fallbackRef = useRef<HTMLLIElement>(null);\n const innerOptionRef = (ref as RefObject<HTMLLIElement | null>) || fallbackRef;\n\n const additionalClasses = classNames(className, {\n [classes[\"selected-option\"]]: isSelected && !disableDefaultSelectedStyle,\n [classes[\"disabled\"]]: disabled\n });\n\n useEffect(() => {\n if (isSelected && innerOptionRef.current && shouldClick) {\n innerOptionRef.current.click();\n }\n }, [isSelected, shouldClick]);\n\n useEffect(() => {\n if (innerOptionRef.current && hasFocus && selectOpened && !isSearching && !isAddBtnFocused) {\n onFocusChange && childIndex && onFocusChange(childIndex);\n innerOptionRef.current.focus();\n }\n }, [hasFocus, innerOptionRef, selectOpened, isSearching]);\n\n const onSelectHandler = () => {\n if (disabled) {\n return;\n }\n onOptionSelect?.(innerOptionRef);\n };\n\n return (\n <li // NOSONAR S6819 - <option> is only valid inside <select>/<optgroup>; this is an ARIA listbox built from <li> elements, so role=\"option\" is the correct authoring practice.\n {...rest}\n id={optionId}\n ref={innerOptionRef}\n data-value={value}\n className={additionalClasses}\n onClick={onSelectHandler}\n onKeyDown={event => {\n if (event.code === \"Enter\") {\n event.stopPropagation();\n event.preventDefault();\n\n onSelectHandler();\n }\n }}\n aria-selected={isSelected}\n aria-disabled={disabled}\n role=\"option\" // NOSONAR S6842 - required by the ARIA listbox pattern; the parent <ul role=\"listbox\"> needs option-role children, and aria-selected is only valid on this role.\n tabIndex={disabled ? -1 : 0}\n >\n {children}\n </li>\n );\n};\n\nexport const Option = React.forwardRef(OptionComponent);\n"],"names":["Option","React","forwardRef","id","children","className","isSelected","disableDefaultSelectedStyle","shouldClick","hasFocus","selectOpened","isSearching","childIndex","onOptionSelect","onFocusChange","disabled","value","isAddBtnFocused","rest","ref","defaultOptionId","useRef","generateID","optionId","current","fallbackRef","innerOptionRef","additionalClasses","classNames","classes","useEffect","click","focus","onSelectHandler","createElement","onClick","onKeyDown","event","code","stopPropagation","preventDefault","role","tabIndex"],"mappings":"8LA2HaA,EAASC,EAAMC,WA/E4C,EAEpEC,KACAC,WACAC,YACAC,cAAa,EACbC,8BACAC,cACAC,WACAC,eACAC,cACAC,aACAC,iBACAC,gBACAC,WACAC,QACAC,qBACGC,GAELC,KAEA,MAAMC,EAAkBC,EAAAA,OAAOC,EAAAA,WAAW,KACpCC,EAAWpB,GAAMiB,EAAgBI,QAGjCC,EAAcJ,EAAAA,OAAsB,MACpCK,EAAkBP,GAA2CM,EAE7DE,EAAoBC,EAAAA,WAAWvB,EAAW,CAC9C,CAACwB,UAAQ,oBAAqBvB,IAAeC,EAC7C,CAACsB,EAAAA,QAAkB,UAAId,IAGzBe,EAAAA,UAAU,KACJxB,GAAcoB,EAAeF,SAAWhB,GAC1CkB,EAAeF,QAAQO,SAExB,CAACzB,EAAYE,IAEhBsB,EAAAA,UAAU,KACJJ,EAAeF,SAAWf,GAAYC,IAAiBC,IAAgBM,IACzEH,GAAiBF,GAAcE,EAAcF,GAC7Cc,EAAeF,QAAQQ,UAExB,CAACvB,EAAUiB,EAAgBhB,EAAcC,IAE5C,MAAMsB,EAAkB,KAClBlB,GAGJ,MAAAF,GAAAA,EAAiBa,IAGnB,OACEzB,EAAAiC,cAAC,KAAA,IACKhB,EACJf,GAAIoB,EACJJ,IAAKO,EACL,aAAYV,EACZX,UAAWsB,EACXQ,QAASF,EACTG,UAAWC,IACU,UAAfA,EAAMC,OACRD,EAAME,kBACNF,EAAMG,iBAENP,MAGJ,gBAAe3B,EACf,gBAAeS,EACf0B,KAAK,SACLC,SAAU3B,GAAW,EAAK,GAEzBX"}
@@ -1,6 +1,6 @@
1
- import React, { useRef, createRef, useEffect } from "react";
1
+ import React, { useRef, useEffect } from "react";
2
2
  import selectClasses from "./Select.module.scss.es.js";
3
- import { generateID } from "../../../../util/helper.es.js";
3
+ import { generateID, classNames } from "../../../../util/helper.es.js";
4
4
  const OptionComponent = ({
5
5
  id,
6
6
  children,
@@ -21,11 +21,12 @@ const OptionComponent = ({
21
21
  }, ref) => {
22
22
  const defaultOptionId = useRef(generateID(20));
23
23
  const optionId = id ?? defaultOptionId.current;
24
- const innerOptionRef = ref || createRef();
25
- const additionalClasses = [];
26
- className && additionalClasses.push(className);
27
- isSelected && !disableDefaultSelectedStyle && additionalClasses.push(selectClasses["selected-option"]);
28
- disabled && additionalClasses.push(selectClasses["disabled"]);
24
+ const fallbackRef = useRef(null);
25
+ const innerOptionRef = ref || fallbackRef;
26
+ const additionalClasses = classNames(className, {
27
+ [selectClasses["selected-option"]]: isSelected && !disableDefaultSelectedStyle,
28
+ [selectClasses["disabled"]]: disabled
29
+ });
29
30
  useEffect(() => {
30
31
  if (isSelected && innerOptionRef.current && shouldClick) {
31
32
  innerOptionRef.current.click();
@@ -50,7 +51,7 @@ const OptionComponent = ({
50
51
  id: optionId,
51
52
  ref: innerOptionRef,
52
53
  "data-value": value,
53
- className: additionalClasses.join(" "),
54
+ className: additionalClasses,
54
55
  onClick: onSelectHandler,
55
56
  onKeyDown: (event) => {
56
57
  if (event.code === "Enter") {
@@ -1 +1 @@
1
- {"version":3,"file":"Option.es.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Option.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, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n createRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement | null>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n const innerOptionRef = (ref as RefObject<HTMLLIElement | null>) || createRef<HTMLLIElement>();\n\n const additionalClasses = [];\n className && additionalClasses.push(className);\n isSelected && !disableDefaultSelectedStyle && additionalClasses.push(classes[\"selected-option\"]);\n disabled && additionalClasses.push(classes[\"disabled\"]);\n\n useEffect(() => {\n if (isSelected && innerOptionRef.current && shouldClick) {\n innerOptionRef.current.click();\n }\n }, [isSelected, shouldClick]);\n\n useEffect(() => {\n if (innerOptionRef.current && hasFocus && selectOpened && !isSearching && !isAddBtnFocused) {\n onFocusChange && childIndex && onFocusChange(childIndex);\n innerOptionRef.current.focus();\n }\n }, [hasFocus, innerOptionRef, selectOpened, isSearching]);\n\n const onSelectHandler = () => {\n if (disabled) {\n return;\n }\n onOptionSelect?.(innerOptionRef);\n };\n\n return (\n <li // NOSONAR S6819 - <option> is only valid inside <select>/<optgroup>; this is an ARIA listbox built from <li> elements, so role=\"option\" is the correct authoring practice.\n {...rest}\n id={optionId}\n ref={innerOptionRef}\n data-value={value}\n className={additionalClasses.join(\" \")}\n onClick={onSelectHandler}\n onKeyDown={event => {\n if (event.code === \"Enter\") {\n event.stopPropagation();\n event.preventDefault();\n\n onSelectHandler();\n }\n }}\n aria-selected={isSelected}\n aria-disabled={disabled}\n role=\"option\" // NOSONAR S6842 - required by the ARIA listbox pattern; the parent <ul role=\"listbox\"> needs option-role children, and aria-selected is only valid on this role.\n tabIndex={disabled ? -1 : 0}\n >\n {children}\n </li>\n );\n};\n\nexport const Option = React.forwardRef(OptionComponent);\n"],"names":["classes"],"mappings":";;;AA6CA,MAAM,kBAAkE,CACtE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,QACG;AACH,QAAM,kB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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, {\n ForwardRefRenderFunction,\n ComponentPropsWithRef,\n RefObject,\n useEffect,\n ReactNode,\n useRef\n} from \"react\";\nimport classes from \"./Select.module.scss\";\nimport { classNames, generateID } from \"../../../../util/helper\";\n\nexport interface Props extends ComponentPropsWithRef<\"li\"> {\n children: ReactNode;\n value: string;\n disabled?: boolean;\n isSelected?: boolean;\n disableDefaultSelectedStyle?: boolean;\n selectOpened?: boolean;\n hasFocus?: boolean;\n shouldClick?: boolean;\n isSearching?: boolean;\n label?: string;\n childIndex?: number;\n onOptionSelect?: (ref: React.RefObject<HTMLLIElement | null>) => void;\n onFocusChange?: (childIndex: number) => void;\n isAddBtnFocused?: boolean;\n}\n\nconst OptionComponent: ForwardRefRenderFunction<HTMLLIElement, Props> = (\n {\n id,\n children,\n className,\n isSelected = false,\n disableDefaultSelectedStyle,\n shouldClick,\n hasFocus,\n selectOpened,\n isSearching,\n childIndex,\n onOptionSelect,\n onFocusChange,\n disabled,\n value,\n isAddBtnFocused,\n ...rest\n }: Props,\n ref\n) => {\n const defaultOptionId = useRef(generateID(20));\n const optionId = id ?? defaultOptionId.current;\n /** Fallback ref when none is forwarded. Must be `useRef`, not `createRef` — a fresh object\n * every render would re-trigger the focus effect below on every render, not just on focus change. */\n const fallbackRef = useRef<HTMLLIElement>(null);\n const innerOptionRef = (ref as RefObject<HTMLLIElement | null>) || fallbackRef;\n\n const additionalClasses = classNames(className, {\n [classes[\"selected-option\"]]: isSelected && !disableDefaultSelectedStyle,\n [classes[\"disabled\"]]: disabled\n });\n\n useEffect(() => {\n if (isSelected && innerOptionRef.current && shouldClick) {\n innerOptionRef.current.click();\n }\n }, [isSelected, shouldClick]);\n\n useEffect(() => {\n if (innerOptionRef.current && hasFocus && selectOpened && !isSearching && !isAddBtnFocused) {\n onFocusChange && childIndex && onFocusChange(childIndex);\n innerOptionRef.current.focus();\n }\n }, [hasFocus, innerOptionRef, selectOpened, isSearching]);\n\n const onSelectHandler = () => {\n if (disabled) {\n return;\n }\n onOptionSelect?.(innerOptionRef);\n };\n\n return (\n <li // NOSONAR S6819 - <option> is only valid inside <select>/<optgroup>; this is an ARIA listbox built from <li> elements, so role=\"option\" is the correct authoring practice.\n {...rest}\n id={optionId}\n ref={innerOptionRef}\n data-value={value}\n className={additionalClasses}\n onClick={onSelectHandler}\n onKeyDown={event => {\n if (event.code === \"Enter\") {\n event.stopPropagation();\n event.preventDefault();\n\n onSelectHandler();\n }\n }}\n aria-selected={isSelected}\n aria-disabled={disabled}\n role=\"option\" // NOSONAR S6842 - required by the ARIA listbox pattern; the parent <ul role=\"listbox\"> needs option-role children, and aria-selected is only valid on this role.\n tabIndex={disabled ? -1 : 0}\n >\n {children}\n </li>\n );\n};\n\nexport const Option = React.forwardRef(OptionComponent);\n"],"names":["classes"],"mappings":";;;AA4CA,MAAM,kBAAkE,CACtE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GACA,QACG;AACH,QAAM,kBAAkB,OAAO,WAAW,EAAE,CAAC;AAC7C,QAAM,WAAW,MAAM,gBAAgB;AAGvC,QAAM,cAAc,OAAsB,IAAI;AAC9C,QAAM,iBAAkB,OAA2C;AAEnE,QAAM,oBAAoB,WAAW,WAAW;AAAA,IAC9C,CAACA,cAAQ,iBAAiB,CAAC,GAAG,cAAc,CAAC;AAAA,IAC7C,CAACA,cAAQ,UAAU,CAAC,GAAG;AAAA,EAAA,CACxB;AAED,YAAU,MAAM;AACd,QAAI,cAAc,eAAe,WAAW,aAAa;AACvD,qBAAe,QAAQ,MAAA;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,YAAY,WAAW,CAAC;AAE5B,YAAU,MAAM;AACd,QAAI,eAAe,WAAW,YAAY,gBAAgB,CAAC,eAAe,CAAC,iBAAiB;AAC1F,uBAAiB,cAAc,cAAc,UAAU;AACvD,qBAAe,QAAQ,MAAA;AAAA,IACzB;AAAA,EACF,GAAG,CAAC,UAAU,gBAAgB,cAAc,WAAW,CAAC;AAExD,QAAM,kBAAkB,MAAM;AAC5B,QAAI,UAAU;AACZ;AAAA,IACF;AACA,qDAAiB;AAAA,EACnB;AAEA,SACE,sBAAA;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAG;AAAA,MACJ,IAAI;AAAA,MACJ,KAAK;AAAA,MACL,cAAY;AAAA,MACZ,WAAW;AAAA,MACX,SAAS;AAAA,MACT,WAAW,CAAA,UAAS;AAClB,YAAI,MAAM,SAAS,SAAS;AAC1B,gBAAM,gBAAA;AACN,gBAAM,eAAA;AAEN,0BAAA;AAAA,QACF;AAAA,MACF;AAAA,MACA,iBAAe;AAAA,MACf,iBAAe;AAAA,MACf,MAAK;AAAA,MACL,UAAU,WAAW,KAAK;AAAA,IAAA;AAAA,IAEzB;AAAA,EAAA;AAGP;AAEO,MAAM,SAAS,MAAM,WAAW,eAAe;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Select.module.scss.cjs.js"),t=require("react"),s=require("../../../../hooks/useClickOutside.cjs.js"),a=require("../../../../readyclasses.module.scss.cjs.js"),r=require("../../../../util/helper.cjs.js"),n=require("../../../Icon/Icon.cjs.js"),l=require("../Select.interfaces.cjs.js"),i=require("../useSelectPositionList.cjs.js"),c=require("../useAddNewBtn.cjs.js"),o=require("./useSearch.cjs.js"),d=require("./useArrowNavigation.cjs.js"),u=require("../../../withReadOnly.cjs.js"),p=require("../../../RequiredSign/RequiredSign.cjs.js"),h=require("../../FormStatusIndicator/FormStatusIndicator.cjs.js"),m=require("../../../InlineEditing/InlineEditingContext.cjs.js"),f=(e,s)=>t.Children.map(e,(e,a)=>t.cloneElement(e,{onFocusChange:s.onFocusChange,onOptionSelect:s.onOptionSelect,isSelected:e.props.value===s.value,isSearching:s.isSearching,selectOpened:s.selectOpened,childIndex:a,hasFocus:s.focusedSelectItem===a,shouldClick:s.shouldClick,isAddBtnFocused:s.addBtnRef.current===document.activeElement})),S=u.withReadOnly(t.forwardRef(({children:u,name:S,disabled:g=!1,labeledBy:v,placeholder:b,describedBy:j,selectButtonProps:C,className:y,error:E=!1,success:N=!1,value:w,clearLabel:I="Clear selection",noResultsLabel:R="No results found",onChange:q,addNew:x,search:O,isReadOnlyView:A,...B},k)=>{const F=`${t.useRef(r.generateID(20)).current}_listbox`,[P,L]=t.useState(!1),[$,H]=t.useState(""),T=t.useRef(null),V=t.useRef(null),[D,M]=t.useState(-1),[K,U]=t.useState(!1),[_,z]=t.useState(!1),G=t.Children.count(u),{filter:J,isSearching:Q,renderSearch:W,searchInputRef:X,setIsSearching:Y,searchThreshold:Z,searchVisible:ee}=o.useSearch({expanded:P,search:O,searchInputClassName:e.default["select-search"],optionsCount:G,setFocusedSelectItem:M}),{addBtnRef:te,addNewBtnOptionsContainerClassName:se,renderAddNew:ae}=c.useAddNewBtn({addNew:x,filter:J,focusedSelectItem:D,optionsCount:G,searchInputRef:X}),{inlineClassNames:re}=m.useInlineEditing(),ne=re?` ${re}`:"",le=k||t.createRef(),ie=e=>{"true"!==(null==e?void 0:e.getAttribute("aria-disabled"))&&(le.current&&e&&(le.current.value=e.dataset.value,le.current.dispatchEvent(new Event("change",{bubbles:!0}))),L(!1))},ce=e=>{M(e)},oe=e=>{ie(e.current),U(!1)},de=t.useRef(null),{onArrowNavigation:ue}=d.useArrowNavigation({expanded:P,setExpanded:L,isSearching:Q,setIsSearching:Y,setFocusedSelectItem:M,onOptionChangeHandler:ie,childrenCount:G,setShouldClick:U,searchInputRef:X,addBtnRef:te,renderThreshold:Z,isReadOnlyView:A||!!B["data-readonlyview"]}),{listPosition:pe,opacity:he,optionsListMaxHeight:me,setListPosition:fe,setOpacity:Se}=i.useSelectPositionList({expanded:P,optionListReference:V,containerReference:T,addBtnRef:te});t.useEffect(()=>{P&&(M(0),z(!0)),!P&&de.current&&_&&(de.current.focus(),z(!1))},[P,de.current,_]),t.useEffect(()=>{var e;e=w,t.Children.forEach(u,t=>{t.props.value===e&&H(t.props.children)})},[w,u]);const ge=t.useRef(null);s.useClickOutside(ge,()=>{P&&(L(!1),fe(l.Position.Below),Se(0))},[P]);const ve=[];return P&&ve.push(e.default.expanded),E&&ve.push(e.default.error),g&&ve.push(e.default.disabled),y&&ve.push(y),N&&ve.push(e.default.success),t.createElement("div",{ref:ge,className:`${e.default.root}${ne}`},t.createElement("select",{...r.omitProps(B,/^data-/),tabIndex:-1,"aria-hidden":"true",ref:le,name:S,onChange:e=>{null==q||q(e)},className:a.default["sr-only"]},t.createElement("option",{value:""}),t.Children.map(u,e=>t.createElement("option",{value:e.props.value}))),t.createElement("div",{...r.pickProps(B,/^data-/),ref:T,onKeyDown:ue,className:`custom-select ${e.default.select} ${ve.join(" ")}`},ee&&W(),t.createElement("button",{...C,onClick:()=>{L(!A&&!B["data-readonlyview"]&&!P)},ref:de,type:"button",name:S,className:`${e.default["custom-select"]} ${ve.join(" ")} `,style:{display:P&&ee?"none":"block"},disabled:g,role:"combobox","aria-disabled":g,"aria-invalid":E,"aria-expanded":P,"aria-controls":F,"aria-haspopup":"listbox","aria-labelledby":v,"aria-describedby":j},t.createElement("div",{"data-display":!0,className:e.default.selected},!w&&b&&t.createElement("span",{className:e.default.placeholder},b),(null==w?void 0:w.length)>0&&t.createElement("span",{"data-display-inner":!0},$),t.createElement(p.RequiredSign,{className:e.default.required})),t.createElement("div",{className:e.default.status},t.createElement(h.FormStatusIndicator,{isReadOnlyView:A,success:N,error:E},P?t.createElement(n.Icon,{className:e.default["chevron-icon"],icon:n.Icons.ChevronUp}):t.createElement(n.Icon,{className:e.default["chevron-icon"],icon:n.Icons.ChevronDown})))),t.createElement("div",{className:"list-wrapper-container"},t.createElement("div",{ref:V,className:`list-wrapper ${e.default["list-wrapper"]}`,style:{display:P?"block":"none",opacity:he,maxHeight:me.wrapper,pointerEvents:P?"auto":"none",bottom:pe===l.Position.Above?"2.85rem":"initial",marginTop:"4px"}},t.createElement("ul",{id:F,className:se,role:"listbox",style:{maxHeight:me.list}},(()=>{const s={onFocusChange:ce,onOptionSelect:oe,value:w,isSearching:Q,selectOpened:P,focusedSelectItem:D,shouldClick:K,addBtnRef:te};if(Q||""!==J){const a=t.Children.toArray(u).filter(e=>{const t=e.props.children;return(Array.isArray(t)?t.map(String).join(""):String(t)).toLowerCase().includes(J.toLowerCase())});return 0===f(a,s).length?t.createElement("li",{className:e.default["no-results"]},R):f(a,s)}return f(t.Children.toArray(u),s)})()),ae()))))}));exports.Select=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Select.module.scss.cjs.js"),t=require("react"),n=require("../../../../hooks/useClickOutside.cjs.js"),r=require("../../../../readyclasses.module.scss.cjs.js"),s=require("../../../../util/helper.cjs.js"),a=require("../../../Icon/Icon.cjs.js"),l=require("../../../Spinner/Spinner.cjs.js"),i=require("../Select.interfaces.cjs.js"),c=require("../useSelectPositionList.cjs.js"),o=require("../useAddNewBtn.cjs.js"),u=require("./useSearch.cjs.js"),d=require("./useArrowNavigation.cjs.js"),m=require("../../../withReadOnly.cjs.js"),p=require("../../../RequiredSign/RequiredSign.cjs.js"),h=require("../../FormStatusIndicator/FormStatusIndicator.cjs.js"),f=require("../../../InlineEditing/InlineEditingContext.cjs.js"),y=(e,n)=>t.Children.map(e,(e,r)=>t.cloneElement(e,{onFocusChange:n.onFocusChange,onOptionSelect:n.onOptionSelect,isSelected:e.props.value===n.value,isSearching:n.isSearching,selectOpened:n.selectOpened,childIndex:r,hasFocus:n.focusedSelectItem===r,shouldClick:n.shouldClick,isAddBtnFocused:n.addBtnRef.current===document.activeElement})),v=m.withReadOnly(t.forwardRef(({children:m,name:v,disabled:b=!1,labeledBy:S,placeholder:g,describedBy:E,selectButtonProps:C,className:N,error:R=!1,success:j=!1,value:I,clearLabel:w="Clear selection",noResultsLabel:q="No results found",onChange:O,addNew:x,search:L,isReadOnlyView:A,selectedOption:k,...B},P)=>{var F,$,T,M;const _=`${t.useRef(s.generateID(20)).current}_listbox`,[H,V]=t.useState(!1),[D,z]=t.useState(""),K=t.useRef(null),U=t.useRef(null),[G,J]=t.useState(-1),[Q,W]=t.useState(!1),[X,Y]=t.useState(!1),Z=t.Children.count(m),ee=t.useRef(null),te=t.useRef(null),ne=t.useRef(!1),re=t.useRef(!1),{filter:se,isSearching:ae,renderSearch:le,searchInputRef:ie,setIsSearching:ce,searchThreshold:oe,searchVisible:ue,isAsync:de,isAsyncPending:me,asyncMinSearchLength:pe}=u.useSearch({expanded:H,search:L,searchInputClassName:e.default["select-search"],optionsCount:Z,setFocusedSelectItem:J,placeholder:g}),{addBtnRef:he,addNewBtnOptionsContainerClassName:fe,renderAddNew:ye}=o.useAddNewBtn({addNew:x,filter:se,focusedSelectItem:G,optionsCount:Z,searchInputRef:ie}),{inlineClassNames:ve}=f.useInlineEditing(),be=ve?` ${ve}`:"",Se=P||t.createRef(),ge=e=>{"true"!==(null==e?void 0:e.getAttribute("aria-disabled"))&&(Se.current&&e&&(Se.current.value=e.dataset.value,Se.current.dispatchEvent(new Event("change",{bubbles:!0}))),V(!1))},Ee=e=>{J(e)},Ce=e=>{ge(e.current),W(!1)},Ne=t.useRef(null),{onArrowNavigation:Re}=d.useArrowNavigation({expanded:H,setExpanded:V,isSearching:ae,setIsSearching:ce,setFocusedSelectItem:J,onOptionChangeHandler:ge,childrenCount:Z,setShouldClick:W,searchInputRef:ie,addBtnRef:he,renderThreshold:oe,isReadOnlyView:A||!!B["data-readonlyview"],isAsync:de,listRef:ee}),{listPosition:je,opacity:Ie,optionsListMaxHeight:we,setListPosition:qe,setOpacity:Oe}=c.useSelectPositionList({expanded:H,optionListReference:U,containerReference:K,addBtnRef:he}),xe=!!(null==(F=null==L?void 0:L.async)?void 0:F.loading)||me;re.current=xe;const Le=null==($=null==L?void 0:L.async)?void 0:$.onLoadMore,Ae=de&&!!Le,ke=de&&pe>0&&0===se.length,Be=Ae&&!!(null==(T=null==L?void 0:L.async)?void 0:T.hasMore)&&!(null==(M=null==L?void 0:L.async)?void 0:M.errorLabel)&&se.length>=pe&&t.Children.count(m)>0;t.useEffect(()=>{H&&(de&&ae&&ie.current?ie.current.focus():J(0),Y(!0)),!H&&Ne.current&&X&&(Ne.current.focus(),Y(!1))},[H]),t.useEffect(()=>{(e=>{let n=!1;t.Children.forEach(m,t=>{t.props.value===e&&(z(t.props.children),n=!0)}),n||(k&&(null==k?void 0:k.value)===e?z(k.label):z(""))})(I)},[I,m,k]),t.useEffect(()=>{if(!Be||!H)return void(ne.current=!1);const e=te.current;if(!e||"undefined"==typeof IntersectionObserver)return;const t=new IntersectionObserver(([e])=>{e.isIntersecting?ne.current||re.current||(ne.current=!0,null==Le||Le()):ne.current=!1},{root:ee.current,threshold:0});return t.observe(e),()=>t.disconnect()},[Be,H,Le]);const Pe=t.useRef(null);n.useClickOutside(Pe,()=>{H&&(V(!1),qe(i.Position.Below),Oe(0))},[H]);const Fe=s.classNames(N,{[e.default.expanded]:H,[e.default.error]:R,[e.default.disabled]:b,[e.default.success]:j});return t.createElement("div",{ref:Pe,className:`${e.default.root}${be}`},t.createElement("select",{...s.omitProps(B,/^data-/),tabIndex:-1,"aria-hidden":"true",ref:Se,name:v,onChange:e=>{null==O||O(e)},className:r.default["sr-only"]},t.createElement("option",{value:""}),t.Children.map(m,e=>t.createElement("option",{value:e.props.value}))),t.createElement("div",{...s.pickProps(B,/^data-/),ref:K,onKeyDown:Re,className:`custom-select ${e.default.select} ${Fe}`},ue&&le(),t.createElement("button",{...C,onClick:()=>{V(!A&&!B["data-readonlyview"]&&!H)},ref:Ne,type:"button",name:v,className:`${e.default["custom-select"]} ${Fe} `,style:{display:H&&ue?"none":"block"},disabled:b,role:"combobox","aria-disabled":b,"aria-invalid":R,"aria-expanded":H,"aria-controls":_,"aria-haspopup":"listbox","aria-labelledby":S,"aria-describedby":E},t.createElement("div",{"data-display":!0,className:e.default.selected},!I&&g&&t.createElement("span",{className:e.default.placeholder},g),(null==I?void 0:I.length)>0&&t.createElement("span",{"data-display-inner":!0},D),t.createElement(p.RequiredSign,{className:e.default.required})),t.createElement("div",{className:e.default.status},t.createElement(h.FormStatusIndicator,{isReadOnlyView:A,success:j,error:R},H?t.createElement(a.Icon,{className:e.default["chevron-icon"],icon:a.Icons.ChevronUp}):t.createElement(a.Icon,{className:e.default["chevron-icon"],icon:a.Icons.ChevronDown})))),t.createElement("div",{className:"list-wrapper-container"},t.createElement("div",{ref:U,className:`list-wrapper ${e.default["list-wrapper"]}`,style:{display:H&&!ke?"block":"none",opacity:Ie,maxHeight:we.wrapper,pointerEvents:H?"auto":"none",bottom:je===i.Position.Above?"2.85rem":"initial",marginTop:"4px"}},t.createElement("ul",{ref:ee,id:_,className:fe,role:"listbox",style:{maxHeight:we.list},"aria-busy":de?xe:void 0},(()=>{const n={onFocusChange:Ee,onOptionSelect:Ce,value:I,isSearching:ae,selectOpened:H,focusedSelectItem:G,shouldClick:Q,addBtnRef:he};return de?(n=>{const r=null==L?void 0:L.async;return se.length<pe?t.createElement("li",{className:e.default["async-status"]},(null==r?void 0:r.idleLabel)??"Type to search"):(null==r?void 0:r.errorLabel)?t.createElement("li",{className:e.default["async-status"]},r.errorLabel,r.onRetry&&t.createElement("button",{type:"button",className:e.default["retry-button"],onClick:r.onRetry},"Retry")):xe?Ae&&t.Children.count(m)>0?[...y(t.Children.toArray(m),n),t.createElement("li",{key:"__select-load-more-status__","data-testid":"select-load-more-status",className:e.default["async-status"]},t.createElement(l.Spinner,{size:16}))]:t.createElement("li",{className:e.default["async-status"]},t.createElement(l.Spinner,{size:20})):0===t.Children.count(m)?t.createElement("li",{className:e.default["no-results"]},q):y(t.Children.toArray(m),n)})(n):(n=>{if(ae||""!==se){const r=t.Children.toArray(m).filter(e=>{const t=e.props.children;return(Array.isArray(t)?t.map(String).join(""):String(t)).toLowerCase().includes(se.toLowerCase())}),s=y(r,n);return 0===s.length?t.createElement("li",{className:e.default["no-results"]},q):s}return y(t.Children.toArray(m),n)})(n)})(),Be&&t.createElement("li",{ref:te,"aria-hidden":"true","data-testid":"select-load-more-sentinel",className:e.default["load-more-sentinel"]})),de&&t.createElement("output",{"aria-live":"polite",className:r.default["sr-only"]},(()=>{const e=null==L?void 0:L.async;if(!e)return"";if(se.length<pe)return e.idleLabel??"Type to search";if(e.errorLabel)return e.errorLabel;if(xe)return"Loading";const n=t.Children.count(m);return 0===n?q:`${n} results`})()),ye()))))}));exports.Select=v;
2
2
  //# sourceMappingURL=Select.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Select.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Select.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 classes from \"./Select.module.scss\";\n\nimport React, {\n createRef,\n ForwardRefRenderFunction,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState\n} from \"react\";\nimport { useClickOutside } from \"../../../../hooks/useClickOutside\";\nimport readyclasses from \"../../../../readyclasses.module.scss\";\nimport { generateID, omitProps, pickProps } from \"../../../../util/helper\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport { OptionElementProps, Position, SingleSelectProps } from \"../Select.interfaces\";\nimport { useSelectPositionList } from \"../useSelectPositionList\";\nimport { useAddNewBtn } from \"../useAddNewBtn\";\nimport { useSearch } from \"./useSearch\";\nimport { useArrowNavigation } from \"./useArrowNavigation\";\nimport { withReadOnly } from \"../../../withReadOnly\";\nimport { RequiredSign } from \"../../../RequiredSign/RequiredSign\";\nimport { FormStatusIndicator } from \"../../FormStatusIndicator/FormStatusIndicator\";\nimport { useInlineEditing } from \"../../../InlineEditing/InlineEditingContext\";\n\ninterface OptionRenderProps {\n onFocusChange: (childIndex: number) => void;\n onOptionSelect: (optionRef: React.RefObject<HTMLLIElement | null>) => void;\n value: string;\n isSearching: boolean;\n selectOpened: boolean;\n focusedSelectItem: number;\n shouldClick: boolean;\n addBtnRef: React.RefObject<HTMLButtonElement | null>;\n}\n\nconst renderChildOptions = (\n internalChildren: ReactElement<OptionElementProps>[],\n optionProps: OptionRenderProps\n) => {\n return React.Children.map(internalChildren, (child, index) => {\n return React.cloneElement(child, {\n onFocusChange: optionProps.onFocusChange,\n onOptionSelect: optionProps.onOptionSelect,\n isSelected: child.props.value === optionProps.value,\n isSearching: optionProps.isSearching,\n selectOpened: optionProps.selectOpened,\n childIndex: index,\n hasFocus: optionProps.focusedSelectItem === index,\n shouldClick: optionProps.shouldClick,\n isAddBtnFocused: optionProps.addBtnRef.current === document.activeElement\n });\n });\n};\n\nconst SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectProps> = (\n {\n children,\n name,\n disabled = false,\n labeledBy,\n placeholder,\n describedBy,\n selectButtonProps,\n className,\n error = false,\n success = false,\n value,\n clearLabel = \"Clear selection\",\n noResultsLabel = \"No results found\",\n onChange,\n addNew,\n search,\n isReadOnlyView,\n ...rest\n }: SingleSelectProps,\n ref\n) => {\n const selectId = useRef(generateID(20));\n const listboxId = `${selectId.current}_listbox`;\n const [expanded, setExpanded] = useState(false);\n const [display, setDisplay] = useState<ReactNode>(\"\");\n const containerReference = useRef<HTMLDivElement>(null);\n const optionListReference = useRef<HTMLDivElement>(null);\n const [focusedSelectItem, setFocusedSelectItem] = useState(-1);\n const [shouldClick, setShouldClick] = useState(false);\n /** We need this, because whenever we use the arrow keys to select the select item, and we focus the currently selected item it fires the \"click\" listener in Option component. Instead, we only want this to fire if we press \"enter\" or \"spacebar\" so we set this to true whenever that is the case, and back to false when it has been executed. */\n const [shouldFocusButtonAfterClose, setShouldFocusButtonAfterClose] = useState(false);\n const optionsCount = React.Children.count(children);\n const {\n filter,\n isSearching,\n renderSearch,\n searchInputRef,\n setIsSearching,\n searchThreshold,\n searchVisible\n } = useSearch({\n expanded,\n search,\n searchInputClassName: classes[\"select-search\"],\n optionsCount,\n setFocusedSelectItem\n });\n const { addBtnRef, addNewBtnOptionsContainerClassName, renderAddNew } = useAddNewBtn({\n addNew,\n filter,\n focusedSelectItem,\n optionsCount,\n searchInputRef\n });\n\n const { inlineClassNames } = useInlineEditing();\n const rootClassNames = inlineClassNames ? ` ${inlineClassNames}` : \"\";\n\n const nativeSelect = (ref as React.RefObject<HTMLSelectElement | null>) || createRef();\n\n const onOptionChangeHandler = (optionElement: HTMLElement | null) => {\n if (optionElement?.getAttribute(\"aria-disabled\") === \"true\") {\n return;\n }\n\n if (nativeSelect.current && optionElement) {\n nativeSelect.current.value = optionElement.dataset.value!;\n nativeSelect.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n setExpanded(false);\n };\n\n const handleOptionFocusChange = (childIndex: number) => {\n setFocusedSelectItem(childIndex);\n };\n\n const handleOptionSelect = (optionRef: React.RefObject<HTMLLIElement | null>) => {\n onOptionChangeHandler(optionRef.current);\n setShouldClick(false);\n };\n\n const customSelectButtonRef = useRef<HTMLButtonElement>(null);\n const { onArrowNavigation } = useArrowNavigation({\n expanded,\n setExpanded,\n isSearching,\n setIsSearching,\n setFocusedSelectItem,\n onOptionChangeHandler,\n childrenCount: optionsCount,\n setShouldClick,\n searchInputRef,\n addBtnRef,\n renderThreshold: searchThreshold,\n isReadOnlyView: isReadOnlyView || !!rest[\"data-readonlyview\"]\n });\n\n const { listPosition, opacity, optionsListMaxHeight, setListPosition, setOpacity } =\n useSelectPositionList({ expanded, optionListReference, containerReference, addBtnRef });\n\n const syncDisplayValue = (val: string) => {\n React.Children.forEach(children, child => {\n if (child.props.value === val) {\n setDisplay(child.props.children);\n }\n });\n };\n\n /**\n * @description We have to modify the children (Option component) to have an additional props that allows us to keep track of which one is selected and focused at all times and if a filter is active.\n * The `children` prop can be either a single object (1 child) or an array of multiple children.\n */\n const renderOptions = () => {\n const optionProps: OptionRenderProps = {\n onFocusChange: handleOptionFocusChange,\n onOptionSelect: handleOptionSelect,\n value,\n isSearching,\n selectOpened: expanded,\n focusedSelectItem,\n shouldClick,\n addBtnRef\n };\n\n if (isSearching || filter !== \"\") {\n const filteredChildren = React.Children.toArray(children).filter(child => {\n const childElement = child as ReactElement<OptionElementProps>;\n const innerChildren = childElement.props.children;\n\n const childText = Array.isArray(innerChildren)\n ? innerChildren.map(String).join(\"\")\n : String(innerChildren);\n return childText.toLowerCase().includes(filter.toLowerCase());\n });\n\n const internalChildren = renderChildOptions(\n filteredChildren as ReactElement<OptionElementProps>[],\n optionProps\n );\n\n if (internalChildren.length === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return renderChildOptions(\n filteredChildren as ReactElement<OptionElementProps>[],\n optionProps\n );\n }\n\n return renderChildOptions(\n React.Children.toArray(children) as ReactElement<OptionElementProps>[],\n optionProps\n );\n };\n\n const renderChevronIcon = () => {\n return expanded ? (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronUp} />\n ) : (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronDown} />\n );\n };\n\n const nativeOnChangeHandler = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n };\n\n useEffect(() => {\n if (expanded) {\n setFocusedSelectItem(0);\n setShouldFocusButtonAfterClose(true);\n }\n\n if (!expanded && customSelectButtonRef.current && shouldFocusButtonAfterClose) {\n customSelectButtonRef.current.focus();\n setShouldFocusButtonAfterClose(false);\n }\n }, [expanded, customSelectButtonRef.current, shouldFocusButtonAfterClose]);\n\n useEffect(() => {\n syncDisplayValue(value);\n }, [value, children]);\n\n const myElementRef = useRef<HTMLDivElement>(null);\n\n useClickOutside(myElementRef, () => {\n if (!expanded) {\n return;\n }\n setExpanded(false);\n setListPosition(Position.Below);\n setOpacity(0);\n }, [expanded]);\n\n const additionalClasses = [];\n expanded && additionalClasses.push(classes.expanded);\n error && additionalClasses.push(classes.error);\n disabled && additionalClasses.push(classes.disabled);\n className && additionalClasses.push(className);\n success && additionalClasses.push(classes.success);\n\n /** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */\n return (\n <div ref={myElementRef} className={`${classes[\"root\"]}${rootClassNames}`}>\n <select\n {...omitProps(rest, /^data-/)}\n tabIndex={-1}\n aria-hidden=\"true\"\n ref={nativeSelect}\n name={name}\n onChange={nativeOnChangeHandler}\n className={readyclasses[\"sr-only\"]}\n >\n <option value=\"\"></option>\n {React.Children.map(children, child => (\n <option value={child.props.value}></option>\n ))}\n </select>\n <div // NOSONAR(S6848) event-delegation wrapper; keys bubble from focusable button/options, adding role/tabIndex would create a spurious tab stop\n {...pickProps(rest, /^data-/)}\n ref={containerReference}\n onKeyDown={onArrowNavigation}\n className={`custom-select ${classes.select} ${additionalClasses.join(\" \")}`}\n >\n {searchVisible && renderSearch()}\n <button // NOSONAR(S6819) no semantic equivalent: <input list>/<select multiple> can't host the search input, add-new button, status icon or custom option markup, and <input> can't contain the trigger's child elements. role=\"combobox\" follows the ARIA APG select-only combobox pattern and is what allows aria-invalid here.\n {...selectButtonProps}\n onClick={() => {\n setExpanded(isReadOnlyView || rest[\"data-readonlyview\"] ? false : !expanded);\n }}\n ref={customSelectButtonRef}\n type=\"button\"\n name={name}\n className={`${classes[\"custom-select\"]} ${additionalClasses.join(\" \")} `}\n style={{ display: expanded && searchVisible ? \"none\" : \"block\" }}\n disabled={disabled}\n /* ARIA 1.2 combobox pattern: the trigger owns the popup state, the invalid state and controls the listbox. */\n role=\"combobox\"\n aria-disabled={disabled}\n aria-invalid={error}\n aria-expanded={expanded}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n aria-labelledby={labeledBy}\n aria-describedby={describedBy}\n >\n <div data-display className={classes[\"selected\"]}>\n {!value && placeholder && <span className={classes[\"placeholder\"]}>{placeholder}</span>}\n {value?.length > 0 && <span data-display-inner>{display}</span>}\n <RequiredSign className={classes[\"required\"]} />\n </div>\n <div className={classes[\"status\"]}>\n <FormStatusIndicator isReadOnlyView={isReadOnlyView} success={success} error={error}>\n {renderChevronIcon()}\n </FormStatusIndicator>\n </div>\n </button>\n <div className=\"list-wrapper-container\">\n <div\n ref={optionListReference}\n className={`list-wrapper ${classes[\"list-wrapper\"]}`}\n style={{\n display: expanded ? \"block\" : \"none\",\n opacity: opacity,\n maxHeight: optionsListMaxHeight.wrapper,\n pointerEvents: expanded ? \"auto\" : \"none\",\n bottom: listPosition === Position.Above ? \"2.85rem\" : \"initial\",\n marginTop: \"4px\"\n }}\n >\n <ul // NOSONAR(S6819) native <select> can't host search, add-new or custom option markup\n id={listboxId}\n className={addNewBtnOptionsContainerClassName}\n role=\"listbox\" // NOSONAR(S6842) required by the ARIA listbox pattern\n style={{ maxHeight: optionsListMaxHeight.list }}\n >\n {renderOptions()}\n </ul>\n {renderAddNew()}\n </div>\n </div>\n </div>\n </div>\n );\n};\nexport const Select = withReadOnly(React.forwardRef(SelectComponent));\n"],"names":["renderChildOptions","internalChildren","optionProps","React","Children","map","child","index","cloneElement","onFocusChange","onOptionSelect","isSelected","props","value","isSearching","selectOpened","childIndex","hasFocus","focusedSelectItem","shouldClick","isAddBtnFocused","addBtnRef","current","document","activeElement","Select","withReadOnly","forwardRef","children","name","disabled","labeledBy","placeholder","describedBy","selectButtonProps","className","error","success","clearLabel","noResultsLabel","onChange","addNew","search","isReadOnlyView","rest","ref","listboxId","useRef","generateID","expanded","setExpanded","useState","display","setDisplay","containerReference","optionListReference","setFocusedSelectItem","setShouldClick","shouldFocusButtonAfterClose","setShouldFocusButtonAfterClose","optionsCount","count","filter","renderSearch","searchInputRef","setIsSearching","searchThreshold","searchVisible","useSearch","searchInputClassName","classes","addNewBtnOptionsContainerClassName","renderAddNew","useAddNewBtn","inlineClassNames","useInlineEditing","rootClassNames","nativeSelect","createRef","onOptionChangeHandler","optionElement","getAttribute","dataset","dispatchEvent","Event","bubbles","handleOptionFocusChange","handleOptionSelect","optionRef","customSelectButtonRef","onArrowNavigation","useArrowNavigation","childrenCount","renderThreshold","listPosition","opacity","optionsListMaxHeight","setListPosition","setOpacity","useSelectPositionList","useEffect","focus","val","forEach","myElementRef","useClickOutside","Position","Below","additionalClasses","push","createElement","omitProps","tabIndex","event","readyclasses","pickProps","onKeyDown","select","join","onClick","type","style","role","length","RequiredSign","FormStatusIndicator","Icon","icon","Icons","ChevronUp","ChevronDown","maxHeight","wrapper","pointerEvents","bottom","Above","marginTop","id","list","filteredChildren","toArray","innerChildren","Array","isArray","String","toLowerCase","includes","renderOptions"],"mappings":"0vBAoDMA,EAAqB,CACzBC,EACAC,IAEOC,EAAMC,SAASC,IAAIJ,EAAkB,CAACK,EAAOC,IAC3CJ,EAAMK,aAAaF,EAAO,CAC/BG,cAAeP,EAAYO,cAC3BC,eAAgBR,EAAYQ,eAC5BC,WAAYL,EAAMM,MAAMC,QAAUX,EAAYW,MAC9CC,YAAaZ,EAAYY,YACzBC,aAAcb,EAAYa,aAC1BC,WAAYT,EACZU,SAAUf,EAAYgB,oBAAsBX,EAC5CY,YAAajB,EAAYiB,YACzBC,gBAAiBlB,EAAYmB,UAAUC,UAAYC,SAASC,iBAsSrDC,EAASC,EAAAA,aAAavB,EAAMwB,WAjS+C,EA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gB,EAAAA,MAAK3F,UAAWmC,UAAQ,gBAAiByD,KAAMC,EAAAA,MAAME,mBAkGpDpB,cAAC,MAAA,CAAI3E,UAAU,0BACbhC,EAAA2G,cAAC,MAAA,CACCjE,IAAKU,EACLpB,UAAW,gBAAgBmC,UAAQ,kBACnCmD,MAAO,CACLrE,QAASH,EAAW,QAAU,OAC9B8C,WACAoC,UAAWnC,GAAqBoC,QAChCC,cAAepF,EAAW,OAAS,OACnCqF,OAAQxC,KAAiBY,EAAAA,SAAS6B,MAAQ,UAAY,UACtDC,UAAW,QAGbrI,EAAA2G,cAAC,KAAA,CACC2B,GAAI3F,EACJX,UAAWoC,GACXmD,KAAK,UACLD,MAAO,CAAEU,UAAWnC,GAAqB0C,OAnK/B,MACpB,MAAMxI,EAAiC,CACrCO,cAAe6E,GACf5E,eAAgB6E,GAChB1E,QACAC,cACAC,aAAckC,EACd/B,oBACAC,cACAE,cAGF,GAAIP,GAA0B,KAAXgD,EAAe,CAChC,MAAM6E,EAAmBxI,EAAMC,SAASwI,QAAQhH,GAAUkC,OAAOxD,IAC/D,MACMuI,EADevI,EACcM,MAAMgB,SAKzC,OAHkBkH,MAAMC,QAAQF,GAC5BA,EAAcxI,IAAI2I,QAAQ1B,KAAK,IAC/B0B,OAAOH,IACMI,cAAcC,SAASpF,EAAOmF,iBAQjD,OAAgC,IALPjJ,EACvB2I,EACAzI,GAGmByH,uBACX,KAAA,CAAGxF,UAAWmC,UAAQ,eAAgB/B,GAGzCvC,EACL2I,EACAzI,EAEJ,CAEA,OAAOF,EACLG,EAAMC,SAASwI,QAAQhH,GACvB1B,IA6HSiJ,IAEF3E"}
1
+ {"version":3,"file":"Select.cjs.js","sources":["../../../../../src/components/Form/Select/SingleSelect/Select.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 classes from \"./Select.module.scss\";\n\nimport React, {\n createRef,\n ForwardRefRenderFunction,\n ReactElement,\n ReactNode,\n useEffect,\n useRef,\n useState\n} from \"react\";\nimport { useClickOutside } from \"../../../../hooks/useClickOutside\";\nimport readyclasses from \"../../../../readyclasses.module.scss\";\nimport { classNames, generateID, omitProps, pickProps } from \"../../../../util/helper\";\nimport { Icon, Icons } from \"../../../Icon/Icon\";\nimport { Spinner } from \"../../../Spinner/Spinner\";\nimport { OptionElementProps, Position, SingleSelectProps } from \"../Select.interfaces\";\nimport { useSelectPositionList } from \"../useSelectPositionList\";\nimport { useAddNewBtn } from \"../useAddNewBtn\";\nimport { useSearch } from \"./useSearch\";\nimport { useArrowNavigation } from \"./useArrowNavigation\";\nimport { withReadOnly } from \"../../../withReadOnly\";\nimport { RequiredSign } from \"../../../RequiredSign/RequiredSign\";\nimport { FormStatusIndicator } from \"../../FormStatusIndicator/FormStatusIndicator\";\nimport { useInlineEditing } from \"../../../InlineEditing/InlineEditingContext\";\n\ninterface OptionRenderProps {\n onFocusChange: (childIndex: number) => void;\n onOptionSelect: (optionRef: React.RefObject<HTMLLIElement | null>) => void;\n value: string;\n isSearching: boolean;\n selectOpened: boolean;\n focusedSelectItem: number;\n shouldClick: boolean;\n addBtnRef: React.RefObject<HTMLButtonElement | null>;\n}\n\nconst renderChildOptions = (\n internalChildren: ReactElement<OptionElementProps>[],\n optionProps: OptionRenderProps\n) => {\n return React.Children.map(internalChildren, (child, index) => {\n return React.cloneElement(child, {\n onFocusChange: optionProps.onFocusChange,\n onOptionSelect: optionProps.onOptionSelect,\n isSelected: child.props.value === optionProps.value,\n isSearching: optionProps.isSearching,\n selectOpened: optionProps.selectOpened,\n childIndex: index,\n hasFocus: optionProps.focusedSelectItem === index,\n shouldClick: optionProps.shouldClick,\n isAddBtnFocused: optionProps.addBtnRef.current === document.activeElement\n });\n });\n};\n\nconst SelectComponent: ForwardRefRenderFunction<HTMLSelectElement, SingleSelectProps> = (\n {\n children,\n name,\n disabled = false,\n labeledBy,\n placeholder,\n describedBy,\n selectButtonProps,\n className,\n error = false,\n success = false,\n value,\n clearLabel = \"Clear selection\",\n noResultsLabel = \"No results found\",\n onChange,\n addNew,\n search,\n isReadOnlyView,\n selectedOption,\n ...rest\n }: SingleSelectProps,\n ref\n) => {\n const selectId = useRef(generateID(20));\n const listboxId = `${selectId.current}_listbox`;\n const [expanded, setExpanded] = useState(false);\n const [display, setDisplay] = useState<ReactNode>(\"\");\n const containerReference = useRef<HTMLDivElement>(null);\n const optionListReference = useRef<HTMLDivElement>(null);\n const [focusedSelectItem, setFocusedSelectItem] = useState(-1);\n const [shouldClick, setShouldClick] = useState(false);\n /** We need this, because whenever we use the arrow keys to select the select item, and we focus the currently selected item it fires the \"click\" listener in Option component. Instead, we only want this to fire if we press \"enter\" or \"spacebar\" so we set this to true whenever that is the case, and back to false when it has been executed. */\n const [shouldFocusButtonAfterClose, setShouldFocusButtonAfterClose] = useState(false);\n const optionsCount = React.Children.count(children);\n const listRef = useRef<HTMLUListElement>(null);\n const loadMoreSentinelRef = useRef<HTMLLIElement>(null);\n const loadMoreFiredRef = useRef(false);\n const asyncBusyRef = useRef(false);\n const {\n filter,\n isSearching,\n renderSearch,\n searchInputRef,\n setIsSearching,\n searchThreshold,\n searchVisible,\n isAsync,\n isAsyncPending,\n asyncMinSearchLength\n } = useSearch({\n expanded,\n search,\n searchInputClassName: classes[\"select-search\"],\n optionsCount,\n setFocusedSelectItem,\n placeholder\n });\n const { addBtnRef, addNewBtnOptionsContainerClassName, renderAddNew } = useAddNewBtn({\n addNew,\n filter,\n focusedSelectItem,\n optionsCount,\n searchInputRef\n });\n\n const { inlineClassNames } = useInlineEditing();\n const rootClassNames = inlineClassNames ? ` ${inlineClassNames}` : \"\";\n\n const nativeSelect = (ref as React.RefObject<HTMLSelectElement | null>) || createRef();\n\n const onOptionChangeHandler = (optionElement: HTMLElement | null) => {\n if (optionElement?.getAttribute(\"aria-disabled\") === \"true\") {\n return;\n }\n\n if (nativeSelect.current && optionElement) {\n nativeSelect.current.value = optionElement.dataset.value!;\n nativeSelect.current.dispatchEvent(new Event(\"change\", { bubbles: true }));\n }\n\n setExpanded(false);\n };\n\n const handleOptionFocusChange = (childIndex: number) => {\n setFocusedSelectItem(childIndex);\n };\n\n const handleOptionSelect = (optionRef: React.RefObject<HTMLLIElement | null>) => {\n onOptionChangeHandler(optionRef.current);\n setShouldClick(false);\n };\n\n const customSelectButtonRef = useRef<HTMLButtonElement>(null);\n const { onArrowNavigation } = useArrowNavigation({\n expanded,\n setExpanded,\n isSearching,\n setIsSearching,\n setFocusedSelectItem,\n onOptionChangeHandler,\n childrenCount: optionsCount,\n setShouldClick,\n searchInputRef,\n addBtnRef,\n renderThreshold: searchThreshold,\n isReadOnlyView: isReadOnlyView || !!rest[\"data-readonlyview\"],\n isAsync,\n listRef\n });\n\n const { listPosition, opacity, optionsListMaxHeight, setListPosition, setOpacity } =\n useSelectPositionList({ expanded, optionListReference, containerReference, addBtnRef });\n\n const syncDisplayValue = (val: string) => {\n let hasMatchingChild = false;\n React.Children.forEach(children, child => {\n if (child.props.value === val) {\n setDisplay(child.props.children);\n hasMatchingChild = true;\n }\n });\n\n if (hasMatchingChild) {\n return;\n }\n\n if (selectedOption && selectedOption?.value === val) {\n setDisplay(selectedOption.label);\n return;\n }\n\n setDisplay(\"\");\n };\n\n const asyncBusy = !!search?.async?.loading || isAsyncPending;\n asyncBusyRef.current = asyncBusy;\n\n const asyncOnLoadMore = search?.async?.onLoadMore;\n const canPaginate = isAsync && !!asyncOnLoadMore;\n /** Below the minimum search length, the dropdown only makes sense once the user has actually\n * started typing - at 0 characters there is nothing to prompt them about yet, so it stays\n * fully hidden instead of showing an idle message. */\n const asyncIdleHidden = isAsync && asyncMinSearchLength > 0 && filter.length === 0;\n const showLoadMoreSentinel =\n canPaginate &&\n !!search?.async?.hasMore &&\n !search?.async?.errorLabel &&\n filter.length >= asyncMinSearchLength &&\n React.Children.count(children) > 0;\n\n const renderAsyncOptions = (optionProps: OptionRenderProps) => {\n const asyncSearch = search?.async;\n\n if (filter.length < asyncMinSearchLength) {\n return (\n <li className={classes[\"async-status\"]}>{asyncSearch?.idleLabel ?? \"Type to search\"}</li>\n );\n }\n\n if (asyncSearch?.errorLabel) {\n return (\n <li className={classes[\"async-status\"]}>\n {asyncSearch.errorLabel}\n {asyncSearch.onRetry && (\n <button type=\"button\" className={classes[\"retry-button\"]} onClick={asyncSearch.onRetry}>\n Retry\n </button>\n )}\n </li>\n );\n }\n\n if (asyncBusy) {\n if (canPaginate && React.Children.count(children) > 0) {\n return [\n ...renderChildOptions(\n React.Children.toArray(children) as ReactElement<OptionElementProps>[],\n optionProps\n ),\n <li\n key=\"__select-load-more-status__\"\n data-testid=\"select-load-more-status\"\n className={classes[\"async-status\"]}\n >\n <Spinner size={16} />\n </li>\n ];\n }\n\n return (\n <li className={classes[\"async-status\"]}>\n <Spinner size={20} />\n </li>\n );\n }\n\n if (React.Children.count(children) === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return renderChildOptions(\n React.Children.toArray(children) as ReactElement<OptionElementProps>[],\n optionProps\n );\n };\n\n const renderSyncOptions = (optionProps: OptionRenderProps) => {\n if (isSearching || filter !== \"\") {\n const filteredChildren = React.Children.toArray(children).filter(child => {\n const childElement = child as ReactElement<OptionElementProps>;\n const innerChildren = childElement.props.children;\n\n const childText = Array.isArray(innerChildren)\n ? innerChildren.map(String).join(\"\")\n : String(innerChildren);\n return childText.toLowerCase().includes(filter.toLowerCase());\n });\n\n const internalChildren = renderChildOptions(\n filteredChildren as ReactElement<OptionElementProps>[],\n optionProps\n );\n\n if (internalChildren.length === 0) {\n return <li className={classes[\"no-results\"]}>{noResultsLabel}</li>;\n }\n\n return internalChildren;\n }\n\n return renderChildOptions(\n React.Children.toArray(children) as ReactElement<OptionElementProps>[],\n optionProps\n );\n };\n\n /**\n * @description We have to modify the children (Option component) to have an additional props that allows us to keep track of which one is selected and focused at all times and if a filter is active.\n * The `children` prop can be either a single object (1 child) or an array of multiple children.\n */\n const renderOptions = () => {\n const optionProps: OptionRenderProps = {\n onFocusChange: handleOptionFocusChange,\n onOptionSelect: handleOptionSelect,\n value,\n isSearching,\n selectOpened: expanded,\n focusedSelectItem,\n shouldClick,\n addBtnRef\n };\n\n if (isAsync) {\n return renderAsyncOptions(optionProps);\n }\n\n return renderSyncOptions(optionProps);\n };\n\n const getAsyncStatusMessage = () => {\n const asyncSearch = search?.async;\n if (!asyncSearch) {\n return \"\";\n }\n\n if (filter.length < asyncMinSearchLength) {\n return asyncSearch.idleLabel ?? \"Type to search\";\n }\n\n if (asyncSearch.errorLabel) {\n return asyncSearch.errorLabel;\n }\n\n if (asyncBusy) {\n return \"Loading\";\n }\n\n const resultsCount = React.Children.count(children);\n return resultsCount === 0 ? noResultsLabel : `${resultsCount} results`;\n };\n\n const renderChevronIcon = () => {\n return expanded ? (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronUp} />\n ) : (\n <Icon className={classes[\"chevron-icon\"]} icon={Icons.ChevronDown} />\n );\n };\n\n const nativeOnChangeHandler = (event: React.ChangeEvent<HTMLSelectElement>) => {\n onChange?.(event);\n };\n\n useEffect(() => {\n if (expanded) {\n if (isAsync && isSearching && searchInputRef.current) {\n searchInputRef.current.focus();\n } else {\n setFocusedSelectItem(0);\n }\n setShouldFocusButtonAfterClose(true);\n }\n\n if (!expanded && customSelectButtonRef.current && shouldFocusButtonAfterClose) {\n customSelectButtonRef.current.focus();\n setShouldFocusButtonAfterClose(false);\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [expanded]);\n\n useEffect(() => {\n syncDisplayValue(value);\n }, [value, children, selectedOption]);\n\n useEffect(() => {\n if (!showLoadMoreSentinel || !expanded) {\n loadMoreFiredRef.current = false;\n return;\n }\n\n const sentinel = loadMoreSentinelRef.current;\n if (!sentinel || typeof IntersectionObserver === \"undefined\") {\n return;\n }\n\n const observer = new IntersectionObserver(\n ([entry]) => {\n if (!entry.isIntersecting) {\n loadMoreFiredRef.current = false;\n return;\n }\n\n if (loadMoreFiredRef.current || asyncBusyRef.current) {\n return;\n }\n\n loadMoreFiredRef.current = true;\n asyncOnLoadMore?.();\n },\n { root: listRef.current, threshold: 0 }\n );\n\n observer.observe(sentinel);\n\n return () => observer.disconnect();\n }, [showLoadMoreSentinel, expanded, asyncOnLoadMore]);\n\n const myElementRef = useRef<HTMLDivElement>(null);\n\n useClickOutside(myElementRef, () => {\n if (!expanded) {\n return;\n }\n setExpanded(false);\n setListPosition(Position.Below);\n setOpacity(0);\n }, [expanded]);\n\n const additionalClasses = classNames(className, {\n [classes.expanded]: expanded,\n [classes.error]: error,\n [classes.disabled]: disabled,\n [classes.success]: success\n });\n\n /** The native select is purely for external form libraries. We use it to emit an onChange with native select event object so they know exactly what's happening. */\n return (\n <div ref={myElementRef} className={`${classes[\"root\"]}${rootClassNames}`}>\n <select\n {...omitProps(rest, /^data-/)}\n tabIndex={-1}\n aria-hidden=\"true\"\n ref={nativeSelect}\n name={name}\n onChange={nativeOnChangeHandler}\n className={readyclasses[\"sr-only\"]}\n >\n <option value=\"\"></option>\n {React.Children.map(children, child => (\n <option value={child.props.value}></option>\n ))}\n </select>\n <div // NOSONAR(S6848) event-delegation wrapper; keys bubble from focusable button/options, adding role/tabIndex would create a spurious tab stop\n {...pickProps(rest, /^data-/)}\n ref={containerReference}\n onKeyDown={onArrowNavigation}\n className={`custom-select ${classes.select} ${additionalClasses}`}\n >\n {searchVisible && renderSearch()}\n <button // NOSONAR(S6819) no semantic equivalent: <input list>/<select multiple> can't host the search input, add-new button, status icon or custom option markup, and <input> can't contain the trigger's child elements. role=\"combobox\" follows the ARIA APG select-only combobox pattern and is what allows aria-invalid here.\n {...selectButtonProps}\n onClick={() => {\n setExpanded(isReadOnlyView || rest[\"data-readonlyview\"] ? false : !expanded);\n }}\n ref={customSelectButtonRef}\n type=\"button\"\n name={name}\n className={`${classes[\"custom-select\"]} ${additionalClasses} `}\n style={{ display: expanded && searchVisible ? \"none\" : \"block\" }}\n disabled={disabled}\n /* ARIA 1.2 combobox pattern: the trigger owns the popup state, the invalid state and controls the listbox. */\n role=\"combobox\"\n aria-disabled={disabled}\n aria-invalid={error}\n aria-expanded={expanded}\n aria-controls={listboxId}\n aria-haspopup=\"listbox\"\n aria-labelledby={labeledBy}\n aria-describedby={describedBy}\n >\n <div data-display className={classes[\"selected\"]}>\n {!value && placeholder && <span className={classes[\"placeholder\"]}>{placeholder}</span>}\n {value?.length > 0 && <span data-display-inner>{display}</span>}\n <RequiredSign className={classes[\"required\"]} />\n </div>\n <div className={classes[\"status\"]}>\n <FormStatusIndicator isReadOnlyView={isReadOnlyView} success={success} error={error}>\n {renderChevronIcon()}\n </FormStatusIndicator>\n </div>\n </button>\n <div className=\"list-wrapper-container\">\n <div\n ref={optionListReference}\n className={`list-wrapper ${classes[\"list-wrapper\"]}`}\n style={{\n display: expanded && !asyncIdleHidden ? \"block\" : \"none\",\n opacity: opacity,\n maxHeight: optionsListMaxHeight.wrapper,\n pointerEvents: expanded ? \"auto\" : \"none\",\n bottom: listPosition === Position.Above ? \"2.85rem\" : \"initial\",\n marginTop: \"4px\"\n }}\n >\n <ul // NOSONAR(S6819) native <select> can't host search, add-new or custom option markup\n ref={listRef}\n id={listboxId}\n className={addNewBtnOptionsContainerClassName}\n role=\"listbox\" // NOSONAR(S6842) required by the ARIA listbox pattern\n style={{ maxHeight: optionsListMaxHeight.list }}\n aria-busy={isAsync ? asyncBusy : undefined}\n >\n {renderOptions()}\n {showLoadMoreSentinel && (\n <li\n ref={loadMoreSentinelRef}\n aria-hidden=\"true\"\n data-testid=\"select-load-more-sentinel\"\n className={classes[\"load-more-sentinel\"]}\n />\n )}\n </ul>\n {isAsync && (\n <output aria-live=\"polite\" className={readyclasses[\"sr-only\"]}>\n {getAsyncStatusMessage()}\n </output>\n )}\n {renderAddNew()}\n </div>\n </div>\n </div>\n </div>\n );\n};\nexport const Select = withReadOnly(React.forwardRef(SelectComponent));\n"],"names":["renderChildOptions","internalChildren","optionProps","React","Children","map","child","index","cloneElement","onFocusChange","onOptionSelect","isSelected","props","value","isSearching","selectOpened","childIndex","hasFocus","focusedSelectItem","shouldClick","isAddBtnFocused","addBtnRef","current","document","activeElement","Select","withReadOnly","forwardRef","children","name","disabled","labeledBy","placeholder","describedBy","selectButtonProps","className","error","success","clearLabel","noResultsLabel","onChange","addNew","search","isReadOnlyView","selectedOption","rest","ref","listboxId","useRef","generateID","expanded","setExpanded","useState","display","setDisplay","containerReference","optionListReference","setFocusedSelectItem","setShouldClick","shouldFocusButtonAfterClose","setShouldFocusButtonAfterClose","optionsCount","count","listRef","loadMoreSentinelRef","loadMoreFiredRef","asyncBusyRef","filter","renderSearch","searchInputRef","setIsSearching","searchThreshold","searchVisible","isAsync","isAsyncPending","asyncMinSearchLength","useSearch","searchInputClassName","classes","addNewBtnOptionsContainerClassName","renderAddNew","useAddNewBtn","inlineClassNames","useInlineEditing","rootClassNames","nativeSelect","createRef","onOptionChangeHandler","optionElement","getAttribute","dataset","dispatchEvent","Event","bubbles","handleOptionFocusChange","handleOptionSelect","optionRef","customSelectButtonRef","onArrowNavigation","useArrowNavigation","childrenCount","renderThreshold","listPosition","opacity","optionsListMaxHeight","setListPosition","setOpacity","useSelectPositionList","asyncBusy","_a","async","loading","asyncOnLoadMore","_b","onLoadMore","canPaginate","asyncIdleHidden","length","showLoadMoreSentinel","_c","hasMore","_d","errorLabel","useEffect","focus","val","hasMatchingChild","forEach","label","syncDisplayValue","sentinel","IntersectionObserver","observer","entry","isIntersecting","root","threshold","observe","disconnect","myElementRef","useClickOutside","Position","Below","additionalClasses","classNames","createElement","omitProps","tabIndex","event","readyclasses","pickProps","onKeyDown","select","onClick","type","style","role","RequiredSign","FormStatusIndicator","Icon","icon","Icons","ChevronUp","ChevronDown","maxHeight","wrapper","pointerEvents","bottom","Above","marginTop","id","list","asyncSearch","idleLabel","onRetry","toArray","key","Spinner","size","renderAsyncOptions","filteredChildren","innerChildren","Array","isArray","String","join","toLowerCase","includes","renderSyncOptions","renderOptions","resultsCount","getAsyncStatusMessage"],"mappings":"uyBAqDMA,EAAqB,CACzBC,EACAC,IAEOC,EAAMC,SAASC,IAAIJ,EAAkB,CAACK,EAAOC,IAC3CJ,EAAMK,aAAaF,EAAO,CAC/BG,cAAeP,EAAYO,cAC3BC,eAAgBR,EAAYQ,eAC5BC,WAAYL,EAAMM,MAAMC,QAAUX,EAAYW,MAC9CC,YAAaZ,EAAYY,YACzBC,aAAcb,EAAYa,aAC1BC,WAAYT,EACZU,SAAUf,EAAYgB,oBAAsBX,EAC5CY,YAAajB,EAAYiB,YACzBC,gBAAiBlB,EAAYmB,UAAUC,UAAYC,SAASC,iBAsdrDC,EAASC,EAAAA,aAAavB,EAAMwB,WAjd+C,EAEpFC,WACAC,OACAC,YAAW,EACXC,YACAC,cACAC,cACAC,oBACAC,YACAC,SAAQ,EACRC,WAAU,EACVxB,QACAyB,aAAa,kBACbC,iBAAiB,mBACjBC,WACAC,SACAC,SACAC,iBACAC,oBACGC,GAELC,iBAEA,MACMC,EAAY,GADDC,EAAAA,OAAOC,EAAAA,WAAW,KACL3B,mBACvB4B,EAAUC,GAAeC,EAAAA,UAAS,IAClCC,EAASC,GAAcF,EAAAA,SAAoB,IAC5CG,EAAqBP,EAAAA,OAAuB,MAC5CQ,EAAsBR,EAAAA,OAAuB,OAC5C9B,EAAmBuC,GAAwBL,EAAAA,UAAS,IACpDjC,EAAauC,GAAkBN,EAAAA,UAAS,IAExCO,EAA6BC,GAAkCR,EAAAA,UAAS,GACzES,EAAe1D,EAAMC,SAAS0D,MAAMlC,GACpCmC,GAAUf,EAAAA,OAAyB,MACnCgB,GAAsBhB,EAAAA,OAAs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