@chayns-components/core 5.3.10 → 5.3.11-alpha.0

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 (451) hide show
  1. package/AGENTS.md +12 -0
  2. package/lib/cjs/components/accordion/Accordion.js +107 -12
  3. package/lib/cjs/components/accordion/Accordion.js.map +1 -1
  4. package/lib/cjs/components/accordion/Accordion.styles.js +23 -3
  5. package/lib/cjs/components/accordion/Accordion.styles.js.map +1 -1
  6. package/lib/cjs/components/accordion/accordion-body/AccordionBody.styles.js +3 -1
  7. package/lib/cjs/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  8. package/lib/cjs/components/accordion/accordion-group/AccordionGroup.js +36 -19
  9. package/lib/cjs/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  10. package/lib/cjs/components/accordion/accordion-head/AccordionHead.js +6 -3
  11. package/lib/cjs/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  12. package/lib/cjs/components/accordion/accordion-head/AccordionHead.styles.js +14 -0
  13. package/lib/cjs/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  14. package/lib/cjs/components/amount-control/AmountControl.js +31 -17
  15. package/lib/cjs/components/amount-control/AmountControl.js.map +1 -1
  16. package/lib/cjs/components/amount-control/AmountControl.styles.js +18 -2
  17. package/lib/cjs/components/amount-control/AmountControl.styles.js.map +1 -1
  18. package/lib/cjs/components/button/Button.js +5 -1
  19. package/lib/cjs/components/button/Button.js.map +1 -1
  20. package/lib/cjs/components/button/Button.styles.js +17 -0
  21. package/lib/cjs/components/button/Button.styles.js.map +1 -1
  22. package/lib/cjs/components/button/Button.types.js.map +1 -1
  23. package/lib/cjs/components/checkbox/Checkbox.js +5 -1
  24. package/lib/cjs/components/checkbox/Checkbox.js.map +1 -1
  25. package/lib/cjs/components/checkbox/Checkbox.styles.js +29 -2
  26. package/lib/cjs/components/checkbox/Checkbox.styles.js.map +1 -1
  27. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.js +7 -2
  28. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  29. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js +8 -2
  30. package/lib/cjs/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
  31. package/lib/cjs/components/combobox/ComboBox.js +52 -5
  32. package/lib/cjs/components/combobox/ComboBox.js.map +1 -1
  33. package/lib/cjs/components/combobox/ComboBox.styles.js +11 -0
  34. package/lib/cjs/components/combobox/ComboBox.styles.js.map +1 -1
  35. package/lib/cjs/components/combobox/ComboBox.types.js.map +1 -1
  36. package/lib/cjs/components/context-menu/ContextMenu.js +100 -6
  37. package/lib/cjs/components/context-menu/ContextMenu.js.map +1 -1
  38. package/lib/cjs/components/context-menu/ContextMenu.styles.js +38 -0
  39. package/lib/cjs/components/context-menu/ContextMenu.styles.js.map +1 -1
  40. package/lib/cjs/components/context-menu/ContextMenu.types.js.map +1 -1
  41. package/lib/cjs/components/file-input/FileInput.js +4 -2
  42. package/lib/cjs/components/file-input/FileInput.js.map +1 -1
  43. package/lib/cjs/components/file-list/file-item/FileItem.js +23 -2
  44. package/lib/cjs/components/file-list/file-item/FileItem.js.map +1 -1
  45. package/lib/cjs/components/file-list/file-item/FileItem.styles.js +19 -1
  46. package/lib/cjs/components/file-list/file-item/FileItem.styles.js.map +1 -1
  47. package/lib/cjs/components/file-select/FileSelect.js +27 -4
  48. package/lib/cjs/components/file-select/FileSelect.js.map +1 -1
  49. package/lib/cjs/components/file-select/FileSelect.styles.js +10 -0
  50. package/lib/cjs/components/file-select/FileSelect.styles.js.map +1 -1
  51. package/lib/cjs/components/filter/Filter.js +51 -16
  52. package/lib/cjs/components/filter/Filter.js.map +1 -1
  53. package/lib/cjs/components/filter/Filter.styles.js +9 -0
  54. package/lib/cjs/components/filter/Filter.styles.js.map +1 -1
  55. package/lib/cjs/components/filter/filter-content/FilterContent.js +14 -5
  56. package/lib/cjs/components/filter/filter-content/FilterContent.js.map +1 -1
  57. package/lib/cjs/components/filter/filter-content/FilterContent.types.js.map +1 -1
  58. package/lib/cjs/components/filter-buttons/FilterButtons.js +69 -4
  59. package/lib/cjs/components/filter-buttons/FilterButtons.js.map +1 -1
  60. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js +40 -2
  61. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
  62. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.styles.js +11 -0
  63. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -1
  64. package/lib/cjs/components/grid-image/GridImage.js +20 -2
  65. package/lib/cjs/components/grid-image/GridImage.js.map +1 -1
  66. package/lib/cjs/components/grid-image/GridImage.styles.js +11 -2
  67. package/lib/cjs/components/grid-image/GridImage.styles.js.map +1 -1
  68. package/lib/cjs/components/grouped-image/GroupedImage.js +23 -4
  69. package/lib/cjs/components/grouped-image/GroupedImage.js.map +1 -1
  70. package/lib/cjs/components/grouped-image/GroupedImage.styles.js +9 -0
  71. package/lib/cjs/components/grouped-image/GroupedImage.styles.js.map +1 -1
  72. package/lib/cjs/components/highlight-slider/HighlightSlider.js +10 -3
  73. package/lib/cjs/components/highlight-slider/HighlightSlider.js.map +1 -1
  74. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js +21 -4
  75. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js.map +1 -1
  76. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js +11 -2
  77. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js.map +1 -1
  78. package/lib/cjs/components/icon/Icon.js +24 -5
  79. package/lib/cjs/components/icon/Icon.js.map +1 -1
  80. package/lib/cjs/components/icon/Icon.styles.js +23 -0
  81. package/lib/cjs/components/icon/Icon.styles.js.map +1 -1
  82. package/lib/cjs/components/input/Input.js +29 -8
  83. package/lib/cjs/components/input/Input.js.map +1 -1
  84. package/lib/cjs/components/input/Input.styles.js +33 -3
  85. package/lib/cjs/components/input/Input.styles.js.map +1 -1
  86. package/lib/cjs/components/list/List.js +124 -37
  87. package/lib/cjs/components/list/List.js.map +1 -1
  88. package/lib/cjs/components/list/List.utils.js +107 -1
  89. package/lib/cjs/components/list/List.utils.js.map +1 -1
  90. package/lib/cjs/components/list/list-item/ListItem.js +82 -3
  91. package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
  92. package/lib/cjs/components/list/list-item/ListItem.styles.js +9 -0
  93. package/lib/cjs/components/list/list-item/ListItem.styles.js.map +1 -1
  94. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js +40 -5
  95. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  96. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.styles.js +5 -1
  97. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  98. package/lib/cjs/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js +32 -1
  99. package/lib/cjs/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js.map +1 -1
  100. package/lib/cjs/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js +32 -1
  101. package/lib/cjs/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js.map +1 -1
  102. package/lib/cjs/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js +30 -1
  103. package/lib/cjs/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js.map +1 -1
  104. package/lib/cjs/components/list/list-item/useListItemFocus.js +47 -0
  105. package/lib/cjs/components/list/list-item/useListItemFocus.js.map +1 -0
  106. package/lib/cjs/components/mention-finder/MentionFinder.js +31 -2
  107. package/lib/cjs/components/mention-finder/MentionFinder.js.map +1 -1
  108. package/lib/cjs/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -1
  109. package/lib/cjs/components/multi-action-button/MultiActionButton.js +36 -3
  110. package/lib/cjs/components/multi-action-button/MultiActionButton.js.map +1 -1
  111. package/lib/cjs/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  112. package/lib/cjs/components/multi-action-button/action-button/ActionButton.js +7 -1
  113. package/lib/cjs/components/multi-action-button/action-button/ActionButton.js.map +1 -1
  114. package/lib/cjs/components/multi-action-button/action-button/ActionButton.styles.js +12 -0
  115. package/lib/cjs/components/multi-action-button/action-button/ActionButton.styles.js.map +1 -1
  116. package/lib/cjs/components/number-input/NumberInput.js +13 -10
  117. package/lib/cjs/components/number-input/NumberInput.js.map +1 -1
  118. package/lib/cjs/components/page-provider/PageProvider.js +4 -2
  119. package/lib/cjs/components/page-provider/PageProvider.js.map +1 -1
  120. package/lib/cjs/components/popup/Popup.js +8 -1
  121. package/lib/cjs/components/popup/Popup.js.map +1 -1
  122. package/lib/cjs/components/radio-button/RadioButton.js +29 -15
  123. package/lib/cjs/components/radio-button/RadioButton.js.map +1 -1
  124. package/lib/cjs/components/radio-button/RadioButton.styles.js +19 -8
  125. package/lib/cjs/components/radio-button/RadioButton.styles.js.map +1 -1
  126. package/lib/cjs/components/radio-button/radio-button-group/RadioButtonGroup.js +7 -4
  127. package/lib/cjs/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -1
  128. package/lib/cjs/components/search-box/SearchBox.js +5 -2
  129. package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
  130. package/lib/cjs/components/search-input/SearchInput.js +40 -41
  131. package/lib/cjs/components/search-input/SearchInput.js.map +1 -1
  132. package/lib/cjs/components/search-input/SearchInput.styles.js +25 -2
  133. package/lib/cjs/components/search-input/SearchInput.styles.js.map +1 -1
  134. package/lib/cjs/components/select-button/SelectButton.js +4 -2
  135. package/lib/cjs/components/select-button/SelectButton.js.map +1 -1
  136. package/lib/cjs/components/setup-wizard/SetupWizard.js +7 -4
  137. package/lib/cjs/components/setup-wizard/SetupWizard.js.map +1 -1
  138. package/lib/cjs/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +5 -3
  139. package/lib/cjs/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -1
  140. package/lib/cjs/components/sharing-bar/SharingBar.js +31 -6
  141. package/lib/cjs/components/sharing-bar/SharingBar.js.map +1 -1
  142. package/lib/cjs/components/sharing-bar/SharingBar.styles.js +5 -0
  143. package/lib/cjs/components/sharing-bar/SharingBar.styles.js.map +1 -1
  144. package/lib/cjs/components/sharing-button/SharingButton.js +4 -2
  145. package/lib/cjs/components/sharing-button/SharingButton.js.map +1 -1
  146. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js +3 -1
  147. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  148. package/lib/cjs/components/signature/Signature.js +6 -3
  149. package/lib/cjs/components/signature/Signature.js.map +1 -1
  150. package/lib/cjs/components/slider/Slider.js +30 -7
  151. package/lib/cjs/components/slider/Slider.js.map +1 -1
  152. package/lib/cjs/components/slider/Slider.styles.js +9 -2
  153. package/lib/cjs/components/slider/Slider.styles.js.map +1 -1
  154. package/lib/cjs/components/slider-button/SliderButton.js +63 -6
  155. package/lib/cjs/components/slider-button/SliderButton.js.map +1 -1
  156. package/lib/cjs/components/slider-button/SliderButton.styles.js +19 -2
  157. package/lib/cjs/components/slider-button/SliderButton.styles.js.map +1 -1
  158. package/lib/cjs/components/slider-button/SliderButton.types.js +6 -0
  159. package/lib/cjs/components/slider-button/SliderButton.types.js.map +1 -0
  160. package/lib/cjs/components/slider-button/useSliderButtonPopupKeyboard.js +66 -0
  161. package/lib/cjs/components/slider-button/useSliderButtonPopupKeyboard.js.map +1 -0
  162. package/lib/cjs/components/slider-button/useSliderButtonThumbKeyboard.js +47 -0
  163. package/lib/cjs/components/slider-button/useSliderButtonThumbKeyboard.js.map +1 -0
  164. package/lib/cjs/components/tag-input/TagInput.js +91 -36
  165. package/lib/cjs/components/tag-input/TagInput.js.map +1 -1
  166. package/lib/cjs/components/tag-input/TagInput.styles.js +31 -3
  167. package/lib/cjs/components/tag-input/TagInput.styles.js.map +1 -1
  168. package/lib/cjs/components/text-area/TextArea.js +17 -8
  169. package/lib/cjs/components/text-area/TextArea.js.map +1 -1
  170. package/lib/cjs/components/text-area/TextArea.styles.js +15 -1
  171. package/lib/cjs/components/text-area/TextArea.styles.js.map +1 -1
  172. package/lib/cjs/components/truncation/Truncation.js +17 -3
  173. package/lib/cjs/components/truncation/Truncation.js.map +1 -1
  174. package/lib/cjs/components/truncation/Truncation.styles.js +19 -1
  175. package/lib/cjs/components/truncation/Truncation.styles.js.map +1 -1
  176. package/lib/cjs/hooks/useKeyboardFocusHighlighting.js +68 -0
  177. package/lib/cjs/hooks/useKeyboardFocusHighlighting.js.map +1 -0
  178. package/lib/cjs/utils/file.js.map +1 -1
  179. package/lib/cjs/utils/keyboardFocusHighlighting.styles.js +30 -0
  180. package/lib/cjs/utils/keyboardFocusHighlighting.styles.js.map +1 -0
  181. package/lib/esm/components/accordion/Accordion.js +105 -12
  182. package/lib/esm/components/accordion/Accordion.js.map +1 -1
  183. package/lib/esm/components/accordion/Accordion.styles.js +23 -3
  184. package/lib/esm/components/accordion/Accordion.styles.js.map +1 -1
  185. package/lib/esm/components/accordion/accordion-body/AccordionBody.styles.js +3 -1
  186. package/lib/esm/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  187. package/lib/esm/components/accordion/accordion-group/AccordionGroup.js +33 -19
  188. package/lib/esm/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  189. package/lib/esm/components/accordion/accordion-head/AccordionHead.js +6 -3
  190. package/lib/esm/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  191. package/lib/esm/components/accordion/accordion-head/AccordionHead.styles.js +14 -0
  192. package/lib/esm/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  193. package/lib/esm/components/amount-control/AmountControl.js +30 -16
  194. package/lib/esm/components/amount-control/AmountControl.js.map +1 -1
  195. package/lib/esm/components/amount-control/AmountControl.styles.js +18 -2
  196. package/lib/esm/components/amount-control/AmountControl.styles.js.map +1 -1
  197. package/lib/esm/components/button/Button.js +5 -1
  198. package/lib/esm/components/button/Button.js.map +1 -1
  199. package/lib/esm/components/button/Button.styles.js +17 -0
  200. package/lib/esm/components/button/Button.styles.js.map +1 -1
  201. package/lib/esm/components/button/Button.types.js.map +1 -1
  202. package/lib/esm/components/checkbox/Checkbox.js +5 -1
  203. package/lib/esm/components/checkbox/Checkbox.js.map +1 -1
  204. package/lib/esm/components/checkbox/Checkbox.styles.js +29 -2
  205. package/lib/esm/components/checkbox/Checkbox.styles.js.map +1 -1
  206. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js +7 -2
  207. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  208. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js +8 -2
  209. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
  210. package/lib/esm/components/combobox/ComboBox.js +50 -5
  211. package/lib/esm/components/combobox/ComboBox.js.map +1 -1
  212. package/lib/esm/components/combobox/ComboBox.styles.js +11 -0
  213. package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
  214. package/lib/esm/components/combobox/ComboBox.types.js.map +1 -1
  215. package/lib/esm/components/context-menu/ContextMenu.js +99 -5
  216. package/lib/esm/components/context-menu/ContextMenu.js.map +1 -1
  217. package/lib/esm/components/context-menu/ContextMenu.styles.js +38 -0
  218. package/lib/esm/components/context-menu/ContextMenu.styles.js.map +1 -1
  219. package/lib/esm/components/context-menu/ContextMenu.types.js.map +1 -1
  220. package/lib/esm/components/file-input/FileInput.js +4 -2
  221. package/lib/esm/components/file-input/FileInput.js.map +1 -1
  222. package/lib/esm/components/file-list/file-item/FileItem.js +24 -3
  223. package/lib/esm/components/file-list/file-item/FileItem.js.map +1 -1
  224. package/lib/esm/components/file-list/file-item/FileItem.styles.js +18 -0
  225. package/lib/esm/components/file-list/file-item/FileItem.styles.js.map +1 -1
  226. package/lib/esm/components/file-select/FileSelect.js +27 -4
  227. package/lib/esm/components/file-select/FileSelect.js.map +1 -1
  228. package/lib/esm/components/file-select/FileSelect.styles.js +10 -0
  229. package/lib/esm/components/file-select/FileSelect.styles.js.map +1 -1
  230. package/lib/esm/components/filter/Filter.js +52 -16
  231. package/lib/esm/components/filter/Filter.js.map +1 -1
  232. package/lib/esm/components/filter/Filter.styles.js +9 -0
  233. package/lib/esm/components/filter/Filter.styles.js.map +1 -1
  234. package/lib/esm/components/filter/filter-content/FilterContent.js +15 -5
  235. package/lib/esm/components/filter/filter-content/FilterContent.js.map +1 -1
  236. package/lib/esm/components/filter/filter-content/FilterContent.types.js.map +1 -1
  237. package/lib/esm/components/filter-buttons/FilterButtons.js +69 -5
  238. package/lib/esm/components/filter-buttons/FilterButtons.js.map +1 -1
  239. package/lib/esm/components/filter-buttons/filter-button/FilterButton.js +40 -2
  240. package/lib/esm/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
  241. package/lib/esm/components/filter-buttons/filter-button/FilterButton.styles.js +11 -0
  242. package/lib/esm/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -1
  243. package/lib/esm/components/grid-image/GridImage.js +20 -2
  244. package/lib/esm/components/grid-image/GridImage.js.map +1 -1
  245. package/lib/esm/components/grid-image/GridImage.styles.js +10 -1
  246. package/lib/esm/components/grid-image/GridImage.styles.js.map +1 -1
  247. package/lib/esm/components/grouped-image/GroupedImage.js +22 -4
  248. package/lib/esm/components/grouped-image/GroupedImage.js.map +1 -1
  249. package/lib/esm/components/grouped-image/GroupedImage.styles.js +9 -0
  250. package/lib/esm/components/grouped-image/GroupedImage.styles.js.map +1 -1
  251. package/lib/esm/components/highlight-slider/HighlightSlider.js +10 -3
  252. package/lib/esm/components/highlight-slider/HighlightSlider.js.map +1 -1
  253. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js +20 -3
  254. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js.map +1 -1
  255. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js +10 -1
  256. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js.map +1 -1
  257. package/lib/esm/components/icon/Icon.js +26 -7
  258. package/lib/esm/components/icon/Icon.js.map +1 -1
  259. package/lib/esm/components/icon/Icon.styles.js +23 -0
  260. package/lib/esm/components/icon/Icon.styles.js.map +1 -1
  261. package/lib/esm/components/input/Input.js +24 -4
  262. package/lib/esm/components/input/Input.js.map +1 -1
  263. package/lib/esm/components/input/Input.styles.js +33 -3
  264. package/lib/esm/components/input/Input.styles.js.map +1 -1
  265. package/lib/esm/components/list/List.js +123 -37
  266. package/lib/esm/components/list/List.js.map +1 -1
  267. package/lib/esm/components/list/List.utils.js +99 -0
  268. package/lib/esm/components/list/List.utils.js.map +1 -1
  269. package/lib/esm/components/list/list-item/ListItem.js +83 -4
  270. package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
  271. package/lib/esm/components/list/list-item/ListItem.styles.js +9 -0
  272. package/lib/esm/components/list/list-item/ListItem.styles.js.map +1 -1
  273. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js +41 -6
  274. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  275. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.styles.js +4 -0
  276. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  277. package/lib/esm/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js +33 -2
  278. package/lib/esm/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js.map +1 -1
  279. package/lib/esm/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js +33 -2
  280. package/lib/esm/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js.map +1 -1
  281. package/lib/esm/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js +30 -1
  282. package/lib/esm/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js.map +1 -1
  283. package/lib/esm/components/list/list-item/useListItemFocus.js +40 -0
  284. package/lib/esm/components/list/list-item/useListItemFocus.js.map +1 -0
  285. package/lib/esm/components/mention-finder/MentionFinder.js +30 -2
  286. package/lib/esm/components/mention-finder/MentionFinder.js.map +1 -1
  287. package/lib/esm/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -1
  288. package/lib/esm/components/multi-action-button/MultiActionButton.js +36 -3
  289. package/lib/esm/components/multi-action-button/MultiActionButton.js.map +1 -1
  290. package/lib/esm/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  291. package/lib/esm/components/multi-action-button/action-button/ActionButton.js +7 -1
  292. package/lib/esm/components/multi-action-button/action-button/ActionButton.js.map +1 -1
  293. package/lib/esm/components/multi-action-button/action-button/ActionButton.styles.js +12 -0
  294. package/lib/esm/components/multi-action-button/action-button/ActionButton.styles.js.map +1 -1
  295. package/lib/esm/components/number-input/NumberInput.js +13 -10
  296. package/lib/esm/components/number-input/NumberInput.js.map +1 -1
  297. package/lib/esm/components/page-provider/PageProvider.js +4 -2
  298. package/lib/esm/components/page-provider/PageProvider.js.map +1 -1
  299. package/lib/esm/components/popup/Popup.js +8 -1
  300. package/lib/esm/components/popup/Popup.js.map +1 -1
  301. package/lib/esm/components/radio-button/RadioButton.js +29 -15
  302. package/lib/esm/components/radio-button/RadioButton.js.map +1 -1
  303. package/lib/esm/components/radio-button/RadioButton.styles.js +19 -8
  304. package/lib/esm/components/radio-button/RadioButton.styles.js.map +1 -1
  305. package/lib/esm/components/radio-button/radio-button-group/RadioButtonGroup.js +7 -4
  306. package/lib/esm/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -1
  307. package/lib/esm/components/search-box/SearchBox.js +5 -2
  308. package/lib/esm/components/search-box/SearchBox.js.map +1 -1
  309. package/lib/esm/components/search-input/SearchInput.js +41 -42
  310. package/lib/esm/components/search-input/SearchInput.js.map +1 -1
  311. package/lib/esm/components/search-input/SearchInput.styles.js +24 -1
  312. package/lib/esm/components/search-input/SearchInput.styles.js.map +1 -1
  313. package/lib/esm/components/select-button/SelectButton.js +4 -2
  314. package/lib/esm/components/select-button/SelectButton.js.map +1 -1
  315. package/lib/esm/components/setup-wizard/SetupWizard.js +7 -4
  316. package/lib/esm/components/setup-wizard/SetupWizard.js.map +1 -1
  317. package/lib/esm/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +5 -3
  318. package/lib/esm/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -1
  319. package/lib/esm/components/sharing-bar/SharingBar.js +30 -5
  320. package/lib/esm/components/sharing-bar/SharingBar.js.map +1 -1
  321. package/lib/esm/components/sharing-bar/SharingBar.styles.js +5 -0
  322. package/lib/esm/components/sharing-bar/SharingBar.styles.js.map +1 -1
  323. package/lib/esm/components/sharing-button/SharingButton.js +4 -2
  324. package/lib/esm/components/sharing-button/SharingButton.js.map +1 -1
  325. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js +3 -1
  326. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  327. package/lib/esm/components/signature/Signature.js +6 -3
  328. package/lib/esm/components/signature/Signature.js.map +1 -1
  329. package/lib/esm/components/slider/Slider.js +30 -7
  330. package/lib/esm/components/slider/Slider.js.map +1 -1
  331. package/lib/esm/components/slider/Slider.styles.js +8 -1
  332. package/lib/esm/components/slider/Slider.styles.js.map +1 -1
  333. package/lib/esm/components/slider-button/SliderButton.js +62 -6
  334. package/lib/esm/components/slider-button/SliderButton.js.map +1 -1
  335. package/lib/esm/components/slider-button/SliderButton.styles.js +18 -1
  336. package/lib/esm/components/slider-button/SliderButton.styles.js.map +1 -1
  337. package/lib/esm/components/slider-button/SliderButton.types.js +2 -0
  338. package/lib/esm/components/slider-button/SliderButton.types.js.map +1 -0
  339. package/lib/esm/components/slider-button/useSliderButtonPopupKeyboard.js +56 -0
  340. package/lib/esm/components/slider-button/useSliderButtonPopupKeyboard.js.map +1 -0
  341. package/lib/esm/components/slider-button/useSliderButtonThumbKeyboard.js +38 -0
  342. package/lib/esm/components/slider-button/useSliderButtonThumbKeyboard.js.map +1 -0
  343. package/lib/esm/components/tag-input/TagInput.js +85 -35
  344. package/lib/esm/components/tag-input/TagInput.js.map +1 -1
  345. package/lib/esm/components/tag-input/TagInput.styles.js +29 -1
  346. package/lib/esm/components/tag-input/TagInput.styles.js.map +1 -1
  347. package/lib/esm/components/text-area/TextArea.js +18 -9
  348. package/lib/esm/components/text-area/TextArea.js.map +1 -1
  349. package/lib/esm/components/text-area/TextArea.styles.js +14 -0
  350. package/lib/esm/components/text-area/TextArea.styles.js.map +1 -1
  351. package/lib/esm/components/truncation/Truncation.js +18 -4
  352. package/lib/esm/components/truncation/Truncation.js.map +1 -1
  353. package/lib/esm/components/truncation/Truncation.styles.js +18 -0
  354. package/lib/esm/components/truncation/Truncation.styles.js.map +1 -1
  355. package/lib/esm/hooks/useKeyboardFocusHighlighting.js +61 -0
  356. package/lib/esm/hooks/useKeyboardFocusHighlighting.js.map +1 -0
  357. package/lib/esm/utils/file.js.map +1 -1
  358. package/lib/esm/utils/keyboardFocusHighlighting.styles.js +25 -0
  359. package/lib/esm/utils/keyboardFocusHighlighting.styles.js.map +1 -0
  360. package/lib/types/components/accordion/Accordion.d.ts +5 -0
  361. package/lib/types/components/accordion/Accordion.styles.d.ts +8 -4
  362. package/lib/types/components/accordion/accordion-body/AccordionBody.styles.d.ts +2 -2
  363. package/lib/types/components/accordion/accordion-group/AccordionGroup.d.ts +7 -2
  364. package/lib/types/components/accordion/accordion-head/AccordionHead.d.ts +1 -0
  365. package/lib/types/components/accordion/accordion-head/AccordionHead.styles.d.ts +18 -18
  366. package/lib/types/components/amount-control/AmountControl.d.ts +5 -0
  367. package/lib/types/components/amount-control/AmountControl.styles.d.ts +8 -4
  368. package/lib/types/components/button/Button.styles.d.ts +8 -6
  369. package/lib/types/components/button/Button.types.d.ts +8 -0
  370. package/lib/types/components/checkbox/Checkbox.d.ts +4 -0
  371. package/lib/types/components/checkbox/Checkbox.styles.d.ts +5 -1
  372. package/lib/types/components/color-scheme-provider/ColorSchemeProvider.d.ts +5 -0
  373. package/lib/types/components/combobox/ComboBox.styles.d.ts +4 -2
  374. package/lib/types/components/combobox/ComboBox.types.d.ts +5 -0
  375. package/lib/types/components/context-menu/ContextMenu.styles.d.ts +4 -2
  376. package/lib/types/components/context-menu/ContextMenu.types.d.ts +6 -0
  377. package/lib/types/components/context-menu/context-menu-content/ContextMenuContent.styles.d.ts +2 -2
  378. package/lib/types/components/dropdown-body-wrapper/delayed-dropdown-content/DelayedDropdownContent.styles.d.ts +2 -2
  379. package/lib/types/components/expandable-content/ExpandableContent.styles.d.ts +2 -2
  380. package/lib/types/components/file-input/FileInput.d.ts +4 -0
  381. package/lib/types/components/file-input/FileInput.styles.d.ts +2 -2
  382. package/lib/types/components/file-list/file-item/FileItem.styles.d.ts +3 -0
  383. package/lib/types/components/file-select/FileSelect.d.ts +4 -0
  384. package/lib/types/components/file-select/FileSelect.styles.d.ts +6 -4
  385. package/lib/types/components/filter/Filter.d.ts +1 -0
  386. package/lib/types/components/filter/Filter.styles.d.ts +6 -4
  387. package/lib/types/components/filter/filter-content/FilterContent.types.d.ts +4 -0
  388. package/lib/types/components/filter-buttons/FilterButtons.d.ts +4 -0
  389. package/lib/types/components/filter-buttons/filter-button/FilterButton.d.ts +5 -0
  390. package/lib/types/components/filter-buttons/filter-button/FilterButton.styles.d.ts +12 -8
  391. package/lib/types/components/grid-image/GridImage.d.ts +4 -0
  392. package/lib/types/components/grid-image/GridImage.styles.d.ts +4 -2
  393. package/lib/types/components/grouped-image/GroupedImage.d.ts +4 -0
  394. package/lib/types/components/grouped-image/GroupedImage.styles.d.ts +8 -6
  395. package/lib/types/components/highlight-slider/HighlightSlider.d.ts +4 -0
  396. package/lib/types/components/highlight-slider/highlight-slider-item/HighlightSliderItem.d.ts +3 -0
  397. package/lib/types/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.d.ts +9 -5
  398. package/lib/types/components/icon/Icon.d.ts +4 -0
  399. package/lib/types/components/icon/Icon.styles.d.ts +1 -0
  400. package/lib/types/components/input/Input.d.ts +4 -0
  401. package/lib/types/components/input/Input.styles.d.ts +17 -9
  402. package/lib/types/components/list/List.d.ts +11 -0
  403. package/lib/types/components/list/List.utils.d.ts +16 -1
  404. package/lib/types/components/list/list-item/ListItem.styles.d.ts +64 -64
  405. package/lib/types/components/list/list-item/list-item-body/ListItemBody.styles.d.ts +2 -2
  406. package/lib/types/components/list/list-item/list-item-head/ListItemHead.d.ts +1 -0
  407. package/lib/types/components/list/list-item/list-item-head/ListItemHead.styles.d.ts +195 -194
  408. package/lib/types/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.d.ts +1 -0
  409. package/lib/types/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.d.ts +1 -0
  410. package/lib/types/components/list/list-item/list-item-head/list-item-title/ListItemTitle.d.ts +1 -0
  411. package/lib/types/components/list/list-item/useListItemFocus.d.ts +13 -0
  412. package/lib/types/components/masonry/masonry-item/MasonryItem.styles.d.ts +2 -2
  413. package/lib/types/components/mention-finder/MentionFinder.styles.d.ts +4 -4
  414. package/lib/types/components/multi-action-button/MultiActionButton.styles.d.ts +2 -2
  415. package/lib/types/components/multi-action-button/MultiActionButton.types.d.ts +7 -0
  416. package/lib/types/components/multi-action-button/action-button/ActionButton.d.ts +4 -1
  417. package/lib/types/components/multi-action-button/action-button/ActionButton.styles.d.ts +4 -2
  418. package/lib/types/components/number-input/NumberInput.d.ts +4 -0
  419. package/lib/types/components/popup/popup-content-wrapper/PopupContentWrapper.styles.d.ts +2 -2
  420. package/lib/types/components/progress-bar/ProgressBar.styles.d.ts +6 -6
  421. package/lib/types/components/radio-button/RadioButton.d.ts +4 -0
  422. package/lib/types/components/radio-button/RadioButton.styles.d.ts +15 -9
  423. package/lib/types/components/radio-button/radio-button-group/RadioButtonGroup.d.ts +5 -0
  424. package/lib/types/components/search-box/SearchBox.d.ts +4 -0
  425. package/lib/types/components/search-box/SearchBox.styles.d.ts +2 -2
  426. package/lib/types/components/search-input/SearchInput.d.ts +4 -0
  427. package/lib/types/components/search-input/SearchInput.styles.d.ts +17 -9
  428. package/lib/types/components/select-button/SelectButton.d.ts +4 -0
  429. package/lib/types/components/setup-wizard/SetupWizard.d.ts +5 -0
  430. package/lib/types/components/sharing-bar/SharingBar.d.ts +4 -0
  431. package/lib/types/components/sharing-button/SharingButton.d.ts +1 -1
  432. package/lib/types/components/sharing-context-menu/SharingContextMenu.d.ts +10 -2
  433. package/lib/types/components/signature/Signature.d.ts +4 -0
  434. package/lib/types/components/skeleton/base-skeleton/BaseSkeleton.styles.d.ts +4 -4
  435. package/lib/types/components/slider/Slider.d.ts +8 -0
  436. package/lib/types/components/slider/Slider.styles.d.ts +18 -14
  437. package/lib/types/components/slider-button/SliderButton.d.ts +1 -28
  438. package/lib/types/components/slider-button/SliderButton.styles.d.ts +6 -4
  439. package/lib/types/components/slider-button/SliderButton.types.d.ts +32 -0
  440. package/lib/types/components/slider-button/useSliderButtonPopupKeyboard.d.ts +17 -0
  441. package/lib/types/components/slider-button/useSliderButtonThumbKeyboard.d.ts +13 -0
  442. package/lib/types/components/tag-input/TagInput.d.ts +4 -0
  443. package/lib/types/components/tag-input/TagInput.styles.d.ts +12 -2
  444. package/lib/types/components/text-area/TextArea.d.ts +4 -0
  445. package/lib/types/components/text-area/TextArea.styles.d.ts +1 -0
  446. package/lib/types/components/truncation/Truncation.d.ts +4 -0
  447. package/lib/types/components/truncation/Truncation.styles.d.ts +7 -2
  448. package/lib/types/hooks/useKeyboardFocusHighlighting.d.ts +5 -0
  449. package/lib/types/utils/file.d.ts +1 -1
  450. package/lib/types/utils/keyboardFocusHighlighting.styles.d.ts +9 -0
  451. package/package.json +2 -2
@@ -229,6 +229,11 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
229
229
  handleHide();
230
230
  }
231
231
  }, [handleHide]);
232
+ const handleDocumentKeyDown = (0, _react2.useCallback)(event => {
233
+ if (event.key === 'Escape') {
234
+ handleHide();
235
+ }
236
+ }, [handleHide]);
232
237
  (0, _react2.useImperativeHandle)(ref, () => ({
233
238
  hide: handleHide,
234
239
  show: handleShow
@@ -241,11 +246,13 @@ const Popup = /*#__PURE__*/(0, _react2.forwardRef)(({
241
246
  document.addEventListener('click', handleDocumentClick, true);
242
247
  window.addEventListener('blur', handleHide);
243
248
  }
249
+ document.addEventListener('keydown', handleDocumentKeyDown);
244
250
  return () => {
245
251
  document.removeEventListener('click', handleDocumentClick, true);
246
252
  window.removeEventListener('blur', handleHide);
253
+ document.removeEventListener('keydown', handleDocumentKeyDown);
247
254
  };
248
- }, [handleDocumentClick, handleHide, isControlled, isPopupOpen, shouldBeOpen]);
255
+ }, [handleDocumentClick, handleDocumentKeyDown, handleHide, isControlled, isPopupOpen, shouldBeOpen]);
249
256
  (0, _react2.useEffect)(() => {
250
257
  if (previousIsVisibleRef.current === isPopupOpen) {
251
258
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","names":["_react","require","_react2","_interopRequireWildcard","_reactDom","_uuid","_popup","_AreaContextProvider","_interopRequireDefault","_PopupContentWrapper","_Popup","_element","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popup","forwardRef","alignment","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","useState","x","y","internalAlignment","setInternalAlignment","PopupAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxHeight","setContentMaxHeight","undefined","timeout","useRef","previousIsVisibleRef","uuid","useUuid","isControlled","isPopupOpen","height","width","measuredElement","useMeasuredClone","shouldPreventTextWrapping","popupContentRef","popupRef","useEffect","current","el","element","closest","Element","updatePopupPosition","useCallback","HORIZONTAL_PADDING","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","childrenCenterX","scrollLeft","scrollTop","boundaryLeft","boundaryWidth","relativeX","shouldShowBottom","BottomLeft","BottomRight","BottomCenter","shouldForceRight","TopRight","shouldUseCenterAlignment","TopCenter","hasEnoughSpaceForCenter","isRight","newOffset","right","newX","handleShow","handleReposition","window","addEventListener","removeEventListener","viewHeight","clientHeight","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","_popupContentRef$curr","contains","target","useImperativeHandle","hide","show","createPortal","createElement","AnimatePresence","initial","key","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","StyledPopup","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName","_default","exports"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n forwardRef,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup } from './Popup.styles';\nimport { useMeasuredClone } from '../../hooks/element';\nimport type { PopupProps } from './Popup.types';\n\nexport type { PopupProps } from './Popup.types';\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n content,\n onShow,\n container,\n onHide,\n children,\n isOpen,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n shouldBeOpen = false,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isInternallyOpen, setIsInternallyOpen] = useState(shouldBeOpen);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n const previousIsVisibleRef = useRef(false);\n\n const uuid = useUuid();\n const isControlled = typeof isOpen === 'boolean';\n const isPopupOpen = isControlled ? isOpen : isInternallyOpen;\n\n const { height, width, measuredElement } = useMeasuredClone({\n content,\n shouldPreventTextWrapping: !shouldUseChildrenWidth,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const updatePopupPosition = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const HORIZONTAL_PADDING = 23;\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n const childrenCenterX = childrenLeft + childrenWidth / 2;\n const x = (childrenCenterX - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;\n\n // Use one coordinate space for all horizontal bounds checks.\n const boundaryLeft = element.scrollLeft;\n const boundaryWidth = containerWidth / zoomX;\n const relativeX = x - boundaryLeft;\n\n const shouldShowBottom =\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight ||\n alignment === PopupAlignment.BottomCenter;\n\n const shouldForceRight = shouldShowBottom\n ? alignment === PopupAlignment.BottomRight\n : alignment === PopupAlignment.TopRight;\n\n const shouldUseCenterAlignment = shouldShowBottom\n ? alignment === PopupAlignment.BottomCenter\n : alignment === PopupAlignment.TopCenter;\n\n const hasEnoughSpaceForCenter =\n pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING &&\n pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;\n\n if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter,\n );\n setOffset(0);\n setCoordinates({\n x,\n y,\n });\n } else {\n let isRight = false;\n\n if (pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight,\n );\n isRight = true;\n } else {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft,\n );\n }\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING\n ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING)\n : 0;\n } else {\n const right = boundaryWidth - relativeX;\n\n newOffset =\n right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING\n ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING)\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX,\n y,\n });\n }\n }\n }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);\n\n const handleShow = useCallback(() => {\n updatePopupPosition();\n\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(true);\n }, [isControlled, updatePopupPosition]);\n\n useEffect(() => {\n if (isControlled) {\n if (isOpen) {\n updatePopupPosition();\n }\n\n return;\n }\n\n if (shouldBeOpen) {\n handleShow();\n }\n }, [handleShow, isControlled, isOpen, shouldBeOpen, updatePopupPosition]);\n\n const handleReposition = useCallback(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n window.addEventListener('resize', handleReposition);\n window.addEventListener('scroll', handleReposition, true);\n\n return () => {\n window.removeEventListener('resize', handleReposition);\n window.removeEventListener('scroll', handleReposition, true);\n };\n }, [handleReposition, isPopupOpen]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n if (isControlled) {\n return;\n }\n\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(false);\n }, [isControlled]);\n\n const handleMouseEnter = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, isControlled, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, isControlled, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n if (!isControlled && !shouldBeOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n };\n }, [handleDocumentClick, handleHide, isControlled, isPopupOpen, shouldBeOpen]);\n\n useEffect(() => {\n if (previousIsVisibleRef.current === isPopupOpen) {\n return;\n }\n\n previousIsVisibleRef.current = isPopupOpen;\n\n if (isPopupOpen) {\n onShow?.();\n\n return;\n }\n\n onHide?.();\n }, [isPopupOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isPopupOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isPopupOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAAuD,SAAAO,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAS,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK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ACKjF,eAAe,eAChB7E,OAAA,CAAAY,OAAA,CAAA0I,aAAA,CAAC9I,MAAA,CAAAuJ,WAAW;IACRC,SAAS,EAAC,mBAAmB;IAC7BnH,GAAG,EAAEoC,QAAS;IACdgF,OAAO,EAAE1B,mBAAoB;IAC7BoB,YAAY,EAAEhB,gBAAiB;IAC/BiB,YAAY,EAAEnB,gBAAiB;IAC/ByB,uBAAuB,EAAE1H,sBAAuB;IAChD2H,mBAAmB,EAAEzH;EAAmB,GAEvCN,QACQ,CAAC,EACbuB,MACH,CAAC;AAEX,CACJ,CAAC;AAED9B,KAAK,CAACuI,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA1J,OAAA,GAEbiB,KAAK","ignoreList":[]}
1
+ {"version":3,"file":"Popup.js","names":["_react","require","_react2","_interopRequireWildcard","_reactDom","_uuid","_popup","_AreaContextProvider","_interopRequireDefault","_PopupContentWrapper","_Popup","_element","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Popup","forwardRef","alignment","content","onShow","container","onHide","children","isOpen","shouldHideOnChildrenLeave","shouldShowOnHover","shouldUseChildrenWidth","shouldScrollWithContent","shouldUseFullWidth","yOffset","shouldBeOpen","ref","coordinates","setCoordinates","useState","x","y","internalAlignment","setInternalAlignment","PopupAlignment","TopLeft","offset","setOffset","isInternallyOpen","setIsInternallyOpen","portal","setPortal","pseudoSize","setPseudoSize","newContainer","setNewContainer","contentMaxHeight","setContentMaxHeight","undefined","timeout","useRef","previousIsVisibleRef","uuid","useUuid","isControlled","isPopupOpen","height","width","measuredElement","useMeasuredClone","shouldPreventTextWrapping","popupContentRef","popupRef","useEffect","current","el","element","closest","Element","updatePopupPosition","useCallback","HORIZONTAL_PADDING","pseudoHeight","pseudoWidth","childrenHeight","left","childrenLeft","top","childrenTop","childrenWidth","getBoundingClientRect","document","body","containerHeight","containerWidth","zoomX","offsetWidth","zoomY","offsetHeight","childrenCenterX","scrollLeft","scrollTop","boundaryLeft","boundaryWidth","relativeX","shouldShowBottom","BottomLeft","BottomRight","BottomCenter","shouldForceRight","TopRight","shouldUseCenterAlignment","TopCenter","hasEnoughSpaceForCenter","isRight","newOffset","right","newX","handleShow","handleReposition","window","addEventListener","removeEventListener","viewHeight","clientHeight","includes","handleChildrenClick","handleHide","handleMouseEnter","clearTimeout","handleMouseLeave","setTimeout","handleDocumentClick","event","_popupContentRef$curr","contains","target","handleDocumentKeyDown","key","useImperativeHandle","hide","show","createPortal","createElement","AnimatePresence","initial","maxHeight","onMouseLeave","onMouseEnter","shouldChangeColor","Fragment","StyledPopup","className","onClick","$shouldUseChildrenWidth","$shouldUseFullWidth","displayName","_default","exports"],"sources":["../../../../src/components/popup/Popup.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n forwardRef,\n ReactPortal,\n useCallback,\n useEffect,\n useImperativeHandle,\n useRef,\n useState,\n} from 'react';\nimport { createPortal } from 'react-dom';\nimport { useUuid } from '../../hooks/uuid';\nimport { PopupAlignment, PopupCoordinates, PopupRef } from '../../types/popup';\nimport AreaContextProvider from '../area-provider/AreaContextProvider';\nimport PopupContentWrapper from './popup-content-wrapper/PopupContentWrapper';\nimport { StyledPopup } from './Popup.styles';\nimport { useMeasuredClone } from '../../hooks/element';\nimport type { PopupProps } from './Popup.types';\n\nexport type { PopupProps } from './Popup.types';\n\nconst Popup = forwardRef<PopupRef, PopupProps>(\n (\n {\n alignment,\n content,\n onShow,\n container,\n onHide,\n children,\n isOpen,\n shouldHideOnChildrenLeave,\n shouldShowOnHover = false,\n shouldUseChildrenWidth = true,\n shouldScrollWithContent = true,\n shouldUseFullWidth = false,\n yOffset = 0,\n shouldBeOpen = false,\n },\n ref,\n ) => {\n const [coordinates, setCoordinates] = useState<PopupCoordinates>({\n x: 0,\n y: 0,\n });\n\n const [internalAlignment, setInternalAlignment] = useState<PopupAlignment>(\n PopupAlignment.TopLeft,\n );\n const [offset, setOffset] = useState<number>(0);\n const [isInternallyOpen, setIsInternallyOpen] = useState(shouldBeOpen);\n const [portal, setPortal] = useState<ReactPortal>();\n const [pseudoSize, setPseudoSize] = useState<{ height: number; width: number }>();\n const [newContainer, setNewContainer] = useState<Element | null>(container ?? null);\n const [contentMaxHeight, setContentMaxHeight] = useState<number | undefined>(undefined);\n\n const timeout = useRef<number>();\n const previousIsVisibleRef = useRef(false);\n\n const uuid = useUuid();\n const isControlled = typeof isOpen === 'boolean';\n const isPopupOpen = isControlled ? isOpen : isInternallyOpen;\n\n const { height, width, measuredElement } = useMeasuredClone({\n content,\n shouldPreventTextWrapping: !shouldUseChildrenWidth,\n });\n\n const popupContentRef = useRef<HTMLDivElement>(null);\n const popupRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (popupRef.current && !container) {\n const el = popupRef.current as HTMLElement;\n\n const element = el.closest('.dialog-inner, .page-provider, .tapp, body');\n\n setNewContainer(element);\n }\n }, [container]);\n\n useEffect(() => {\n if (container instanceof Element) {\n setNewContainer(container);\n }\n }, [container]);\n\n useEffect(() => {\n setPseudoSize({ height, width });\n }, [height, width]);\n\n const updatePopupPosition = useCallback(() => {\n if (popupRef.current && pseudoSize) {\n if (!newContainer) {\n return;\n }\n\n const HORIZONTAL_PADDING = 23;\n\n const { height: pseudoHeight, width: pseudoWidth } = pseudoSize;\n\n const {\n height: childrenHeight,\n left: childrenLeft,\n top: childrenTop,\n width: childrenWidth,\n } = popupRef.current.getBoundingClientRect();\n\n const element = shouldScrollWithContent ? newContainer : document.body;\n\n const {\n height: containerHeight,\n width: containerWidth,\n top,\n left,\n } = element.getBoundingClientRect();\n\n const zoomX = containerWidth / (element as HTMLElement).offsetWidth;\n const zoomY = containerHeight / (element as HTMLElement).offsetHeight;\n\n const childrenCenterX = childrenLeft + childrenWidth / 2;\n const x = (childrenCenterX - left) / zoomX + element.scrollLeft;\n const y =\n (childrenTop + childrenHeight / 2 - top) / zoomY + element.scrollTop - yOffset;\n\n // Use one coordinate space for all horizontal bounds checks.\n const boundaryLeft = element.scrollLeft;\n const boundaryWidth = containerWidth / zoomX;\n const relativeX = x - boundaryLeft;\n\n const shouldShowBottom =\n pseudoHeight > childrenTop - 25 ||\n alignment === PopupAlignment.BottomLeft ||\n alignment === PopupAlignment.BottomRight ||\n alignment === PopupAlignment.BottomCenter;\n\n const shouldForceRight = shouldShowBottom\n ? alignment === PopupAlignment.BottomRight\n : alignment === PopupAlignment.TopRight;\n\n const shouldUseCenterAlignment = shouldShowBottom\n ? alignment === PopupAlignment.BottomCenter\n : alignment === PopupAlignment.TopCenter;\n\n const hasEnoughSpaceForCenter =\n pseudoWidth / 2 <= relativeX - HORIZONTAL_PADDING &&\n pseudoWidth / 2 <= boundaryWidth - relativeX - HORIZONTAL_PADDING;\n\n if (shouldUseCenterAlignment && hasEnoughSpaceForCenter) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomCenter : PopupAlignment.TopCenter,\n );\n setOffset(0);\n setCoordinates({\n x,\n y,\n });\n } else {\n let isRight = false;\n\n if (pseudoWidth > relativeX - HORIZONTAL_PADDING || shouldForceRight) {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomRight : PopupAlignment.TopRight,\n );\n isRight = true;\n } else {\n setInternalAlignment(\n shouldShowBottom ? PopupAlignment.BottomLeft : PopupAlignment.TopLeft,\n );\n }\n\n let newOffset;\n\n if (isRight) {\n newOffset =\n relativeX + pseudoWidth >= boundaryWidth - HORIZONTAL_PADDING\n ? relativeX + pseudoWidth - (boundaryWidth - HORIZONTAL_PADDING)\n : 0;\n } else {\n const right = boundaryWidth - relativeX;\n\n newOffset =\n right + pseudoWidth >= boundaryWidth + HORIZONTAL_PADDING\n ? right + pseudoWidth - (boundaryWidth + HORIZONTAL_PADDING)\n : 0;\n }\n\n setOffset(newOffset);\n\n const newX = x - newOffset;\n\n setCoordinates({\n x: newX,\n y,\n });\n }\n }\n }, [alignment, newContainer, pseudoSize, shouldScrollWithContent, yOffset]);\n\n const handleShow = useCallback(() => {\n updatePopupPosition();\n\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(true);\n }, [isControlled, updatePopupPosition]);\n\n useEffect(() => {\n if (isControlled) {\n if (isOpen) {\n updatePopupPosition();\n }\n\n return;\n }\n\n if (shouldBeOpen) {\n handleShow();\n }\n }, [handleShow, isControlled, isOpen, shouldBeOpen, updatePopupPosition]);\n\n const handleReposition = useCallback(() => {\n if (isPopupOpen) {\n updatePopupPosition();\n }\n }, [isPopupOpen, updatePopupPosition]);\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n window.addEventListener('resize', handleReposition);\n window.addEventListener('scroll', handleReposition, true);\n\n return () => {\n window.removeEventListener('resize', handleReposition);\n window.removeEventListener('scroll', handleReposition, true);\n };\n }, [handleReposition, isPopupOpen]);\n\n useEffect(() => {\n if (!newContainer || !popupRef.current) return;\n\n const viewHeight = newContainer.clientHeight;\n const childrenHeight = popupRef.current.getBoundingClientRect().height;\n\n if (\n [\n PopupAlignment.TopLeft,\n PopupAlignment.TopRight,\n PopupAlignment.TopCenter,\n ].includes(internalAlignment)\n ) {\n setContentMaxHeight(coordinates.y - 20);\n } else {\n setContentMaxHeight(viewHeight - childrenHeight - coordinates.y - 20);\n }\n }, [coordinates.y, internalAlignment, newContainer]);\n\n const handleChildrenClick = () => {\n if (isControlled) {\n return;\n }\n\n handleShow();\n };\n\n const handleHide = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n setIsInternallyOpen(false);\n }, [isControlled]);\n\n const handleMouseEnter = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (shouldShowOnHover) {\n window.clearTimeout(timeout.current);\n handleShow();\n }\n }, [handleShow, isControlled, shouldShowOnHover]);\n\n const handleMouseLeave = useCallback(() => {\n if (isControlled) {\n return;\n }\n\n if (!shouldShowOnHover) {\n return;\n }\n\n if (shouldHideOnChildrenLeave) {\n handleHide();\n\n return;\n }\n\n timeout.current = window.setTimeout(() => {\n handleHide();\n }, 500);\n }, [handleHide, isControlled, shouldHideOnChildrenLeave, shouldShowOnHover]);\n\n const handleDocumentClick = useCallback<EventListener>(\n (event) => {\n if (!popupContentRef.current?.contains(event.target as Node)) {\n handleHide();\n }\n },\n [handleHide],\n );\n\n const handleDocumentKeyDown = useCallback(\n (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n handleHide();\n }\n },\n [handleHide],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n hide: handleHide,\n show: handleShow,\n }),\n [handleHide, handleShow],\n );\n\n useEffect(() => {\n if (!isPopupOpen) {\n return undefined;\n }\n\n if (!isControlled && !shouldBeOpen) {\n document.addEventListener('click', handleDocumentClick, true);\n window.addEventListener('blur', handleHide);\n }\n\n document.addEventListener('keydown', handleDocumentKeyDown);\n\n return () => {\n document.removeEventListener('click', handleDocumentClick, true);\n window.removeEventListener('blur', handleHide);\n document.removeEventListener('keydown', handleDocumentKeyDown);\n };\n }, [\n handleDocumentClick,\n handleDocumentKeyDown,\n handleHide,\n isControlled,\n isPopupOpen,\n shouldBeOpen,\n ]);\n\n useEffect(() => {\n if (previousIsVisibleRef.current === isPopupOpen) {\n return;\n }\n\n previousIsVisibleRef.current = isPopupOpen;\n\n if (isPopupOpen) {\n onShow?.();\n\n return;\n }\n\n onHide?.();\n }, [isPopupOpen, onHide, onShow]);\n\n useEffect(() => {\n if (!newContainer) {\n return;\n }\n\n setPortal(() =>\n createPortal(\n <AnimatePresence initial={false}>\n {isPopupOpen && (\n <PopupContentWrapper\n width={pseudoSize?.width ?? 0}\n offset={offset}\n shouldScrollWithContent={shouldScrollWithContent}\n coordinates={coordinates}\n key={`tooltip_${uuid}`}\n maxHeight={contentMaxHeight}\n alignment={internalAlignment}\n ref={popupContentRef}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n >\n <AreaContextProvider shouldChangeColor>\n {content}\n </AreaContextProvider>\n </PopupContentWrapper>\n )}\n </AnimatePresence>,\n newContainer,\n ),\n );\n }, [\n contentMaxHeight,\n internalAlignment,\n newContainer,\n content,\n coordinates,\n handleMouseEnter,\n handleMouseLeave,\n isPopupOpen,\n offset,\n pseudoSize?.width,\n uuid,\n shouldScrollWithContent,\n ]);\n\n return (\n <>\n {measuredElement}\n <StyledPopup\n className=\"beta-chayns-popup\"\n ref={popupRef}\n onClick={handleChildrenClick}\n onMouseLeave={handleMouseLeave}\n onMouseEnter={handleMouseEnter}\n $shouldUseChildrenWidth={shouldUseChildrenWidth}\n $shouldUseFullWidth={shouldUseFullWidth}\n >\n {children}\n </StyledPopup>\n {portal}\n </>\n );\n },\n);\n\nPopup.displayName = 'Popup';\n\nexport default Popup;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AASA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,oBAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,oBAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AACA,IAAAU,QAAA,GAAAV,OAAA;AAAuD,SAAAO,uBAAAI,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAS,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA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J,oBAAA,CAAAO,OAAmB;MAACkJ,iBAAiB;IAAA,GACjC9H,OACgB,CACJ,CAEZ,CAAC,EAClB+B,YACJ,CACJ,CAAC;EACL,CAAC,EAAE,CACCE,gBAAgB,EAChBd,iBAAiB,EACjBY,YAAY,EACZ/B,OAAO,EACPc,WAAW,EACX2F,gBAAgB,EAChBE,gBAAgB,EAChBjE,WAAW,EACXnB,MAAM,EACNM,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEe,KAAK,EACjBL,IAAI,EACJ9B,uBAAuB,CAC1B,CAAC;EAEF,oBACIzC,OAAA,CAAAY,OAAA,CAAA4I,aAAA,CAAAxJ,OAAA,CAAAY,OAAA,CAAAmJ,QAAA,QACKlF,eAAe,eAChB7E,OAAA,CAAAY,OAAA,CAAA4I,aAAA,CAAChJ,MAAA,CAAAwJ,WAAW;IACRC,SAAS,EAAC,mBAAmB;IAC7BpH,GAAG,EAAEoC,QAAS;IACdiF,OAAO,EAAE3B,mBAAoB;IAC7BqB,YAAY,EAAEjB,gBAAiB;IAC/BkB,YAAY,EAAEpB,gBAAiB;IAC/B0B,uBAAuB,EAAE3H,sBAAuB;IAChD4H,mBAAmB,EAAE1H;EAAmB,GAEvCN,QACQ,CAAC,EACbuB,MACH,CAAC;AAEX,CACJ,CAAC;AAED9B,KAAK,CAACwI,WAAW,GAAG,OAAO;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA3J,OAAA,GAEbiB,KAAK","ignoreList":[]}
@@ -9,6 +9,7 @@ var _react2 = _interopRequireWildcard(require("react"));
9
9
  var _RadioButtonGroup = require("./radio-button-group/RadioButtonGroup");
10
10
  var _RadioButton = require("./RadioButton.styles");
11
11
  var _calculate = require("../../utils/calculate");
12
+ var _useKeyboardFocusHighlighting = require("../../hooks/useKeyboardFocusHighlighting");
12
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
14
  const RadioButton = ({
14
15
  children,
@@ -17,14 +18,16 @@ const RadioButton = ({
17
18
  id,
18
19
  rightElement,
19
20
  shouldShowCentered = true,
20
- isDisabled = false
21
+ isDisabled = false,
22
+ shouldEnableKeyboardHighlighting
21
23
  }) => {
22
24
  const {
23
25
  selectedRadioButtonId,
24
26
  updateSelectedRadioButtonId,
25
27
  radioButtonRightElements,
26
28
  updateHasRightElement,
27
- radioButtonsCanBeUnchecked
29
+ radioButtonsCanBeUnchecked,
30
+ shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingFromGroup
28
31
  } = (0, _react2.useContext)(_RadioButtonGroup.RadioButtonGroupContext);
29
32
  const [internalIsChecked, setInternalIsChecked] = (0, _react2.useState)(false);
30
33
  const [isHovered, setIsHovered] = (0, _react2.useState)(false);
@@ -34,6 +37,8 @@ const RadioButton = ({
34
37
  const isInGroup = typeof updateSelectedRadioButtonId === 'function';
35
38
  const isMarked = isInGroup ? selectedRadioButtonId === id : internalIsChecked;
36
39
  const uncheckable = radioButtonsCanBeUnchecked;
40
+ const effectiveShouldEnableKeyboardHighlighting = shouldEnableKeyboardHighlightingFromGroup ?? shouldEnableKeyboardHighlighting;
41
+ const shouldShowKeyboardHighlighting = (0, _useKeyboardFocusHighlighting.useKeyboardFocusHighlighting)(effectiveShouldEnableKeyboardHighlighting && !isDisabled);
37
42
  (0, _react2.useEffect)(() => {
38
43
  if (radioButtonRootRef.current && !shouldShowCentered) {
39
44
  var _radioButtonBoxRef$cu;
@@ -68,6 +73,12 @@ const RadioButton = ({
68
73
  const handleMouseLeave = () => {
69
74
  setIsHovered(false);
70
75
  };
76
+ const handleKeyDown = (0, _react2.useCallback)(event => {
77
+ if (event.key === 'Enter') {
78
+ event.preventDefault();
79
+ handleClick();
80
+ }
81
+ }, [handleClick]);
71
82
  const radioButtonRightElementMargin = (0, _react2.useMemo)(() => {
72
83
  if (!radioButtonRightElements) {
73
84
  return 'NONE';
@@ -113,8 +124,20 @@ const RadioButton = ({
113
124
  $isDisabled: isDisabled,
114
125
  $radioButtonRightElementMargin: radioButtonRightElementMargin
115
126
  }, /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledRadioButtonWrapper, {
116
- ref: radioButtonRootRef
117
- }, /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledRadioButtonPseudoCheckBox, {
127
+ ref: radioButtonRootRef,
128
+ $shouldShowKeyboardHighlighting: shouldShowKeyboardHighlighting
129
+ }, /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledRadioButtonCheckBox, {
130
+ onClick: handleClick,
131
+ onMouseEnter: handleMouseEnter,
132
+ onMouseLeave: handleMouseLeave,
133
+ onKeyDown: handleKeyDown,
134
+ disabled: isDisabled,
135
+ $isDisabled: isDisabled,
136
+ $shouldShowKeyboardHighlighting: shouldShowKeyboardHighlighting,
137
+ type: "radio",
138
+ checked: isMarked,
139
+ onChange: () => {}
140
+ }), /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledRadioButtonPseudoCheckBox, {
118
141
  $isDisabled: isDisabled,
119
142
  $isChecked: isMarked,
120
143
  ref: radioButtonBoxRef,
@@ -129,16 +152,7 @@ const RadioButton = ({
129
152
  $isHovered: isHovered,
130
153
  $isSelected: isMarked,
131
154
  $isDisabled: isDisabled
132
- })), /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledRadioButtonCheckBox, {
133
- onClick: handleClick,
134
- onMouseEnter: handleMouseEnter,
135
- onMouseLeave: handleMouseLeave,
136
- disabled: isDisabled,
137
- $isDisabled: isDisabled,
138
- type: "radio",
139
- checked: isMarked,
140
- onChange: () => {}
141
- }), /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledLabelWrapper, null, label && /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledRadioButtonLabel, {
155
+ })), /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledLabelWrapper, null, label && /*#__PURE__*/_react2.default.createElement(_RadioButton.StyledRadioButtonLabel, {
142
156
  $isDisabled: isDisabled,
143
157
  onClick: handleClick,
144
158
  onMouseEnter: handleMouseEnter,
@@ -156,7 +170,7 @@ const RadioButton = ({
156
170
  transition: {
157
171
  duration: 0.2
158
172
  }
159
- }, children))), [children, handleClick, handleMouseEnter, isDisabled, isHovered, isMarked, label, radioButtonRightElementMargin, radioButtonTop, rightElement, shouldShowCentered, shouldShowRightElement]);
173
+ }, children))), [children, handleClick, handleKeyDown, handleMouseEnter, isDisabled, isHovered, isMarked, label, radioButtonRightElementMargin, radioButtonTop, rightElement, shouldShowCentered, shouldShowKeyboardHighlighting, shouldShowRightElement]);
160
174
  };
161
175
  RadioButton.displayName = 'RadioButton';
162
176
  var _default = exports.default = RadioButton;
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.js","names":["_react","require","_react2","_interopRequireWildcard","_RadioButtonGroup","_RadioButton","_calculate","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RadioButton","children","shouldShowRightElementOnlyOnChecked","label","id","rightElement","shouldShowCentered","isDisabled","selectedRadioButtonId","updateSelectedRadioButtonId","radioButtonRightElements","updateHasRightElement","radioButtonsCanBeUnchecked","useContext","RadioButtonGroupContext","internalIsChecked","setInternalIsChecked","useState","isHovered","setIsHovered","radioButtonTop","setRadioButtonTop","undefined","radioButtonBoxRef","useRef","radioButtonRootRef","isInGroup","isMarked","uncheckable","useEffect","current","_radioButtonBoxRef$cu","singleLineHeight","getHeightOfSingleTextLine","container","boxHeight","getBoundingClientRect","height","handleClick","useCallback","prev","handleMouseEnter","handleMouseLeave","radioButtonRightElementMargin","useMemo","index","findIndex","element","prevButton","currentButton","nextButton","hasRightElement","shouldShowRightElement","window","setTimeout","createElement","StyledRadioButton","$isDisabled","$radioButtonRightElementMargin","StyledRadioButtonWrapper","ref","StyledRadioButtonPseudoCheckBox","$isChecked","onClick","style","top","transform","StyledRadioButtonCheckBoxMark","onMouseEnter","onMouseLeave","$isHovered","$isSelected","StyledRadioButtonCheckBox","disabled","type","checked","onChange","StyledLabelWrapper","StyledRadioButtonLabel","AnimatePresence","initial","StyledMotionRadioButtonChildren","animate","opacity","transition","duration","displayName","_default","exports"],"sources":["../../../../src/components/radio-button/RadioButton.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n FC,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n useRef,\n} from 'react';\nimport { RadioButtonRightElementMargin } from '../../types/radioButton';\nimport { RadioButtonGroupContext } from './radio-button-group/RadioButtonGroup';\nimport {\n StyledLabelWrapper,\n StyledMotionRadioButtonChildren,\n StyledRadioButton,\n StyledRadioButtonCheckBox,\n StyledRadioButtonCheckBoxMark,\n StyledRadioButtonLabel,\n StyledRadioButtonPseudoCheckBox,\n StyledRadioButtonWrapper,\n} from './RadioButton.styles';\nimport { getHeightOfSingleTextLine } from '../../utils/calculate';\n\nexport type RadioButtonProps = {\n /**\n * The children that should be displayed after the RadioButton is checked.\n */\n children?: ReactNode;\n /**\n * whether the RadioButton should be shown.\n */\n isDisabled?: boolean;\n /**\n * The id of the radio button.\n */\n id: string;\n /**\n * The label that should be displayed next to the radio button.\n */\n label?: ReactNode;\n /**\n * An element that should be displayed on the right side of the label.\n */\n rightElement?: ReactNode;\n /**\n * Whether the rightElement should only be displayed when the RadioButton is checked\n */\n shouldShowRightElementOnlyOnChecked?: boolean;\n /**\n * Whether the RadioButton should be displayed centered to the label or at the top\n */\n shouldShowCentered?: boolean;\n};\n\nconst RadioButton: FC<RadioButtonProps> = ({\n children,\n shouldShowRightElementOnlyOnChecked = false,\n label,\n id,\n rightElement,\n shouldShowCentered = true,\n isDisabled = false,\n}) => {\n const {\n selectedRadioButtonId,\n updateSelectedRadioButtonId,\n radioButtonRightElements,\n updateHasRightElement,\n radioButtonsCanBeUnchecked,\n } = useContext(RadioButtonGroupContext);\n\n const [internalIsChecked, setInternalIsChecked] = useState(false);\n const [isHovered, setIsHovered] = useState(false);\n const [radioButtonTop, setRadioButtonTop] = useState<number | undefined>(undefined);\n\n const radioButtonBoxRef = useRef<HTMLDivElement>(null);\n const radioButtonRootRef = useRef<HTMLDivElement>(null);\n\n const isInGroup = typeof updateSelectedRadioButtonId === 'function';\n\n const isMarked = isInGroup ? selectedRadioButtonId === id : internalIsChecked;\n\n const uncheckable = radioButtonsCanBeUnchecked;\n\n useEffect(() => {\n if (radioButtonRootRef.current && !shouldShowCentered) {\n const singleLineHeight = getHeightOfSingleTextLine({\n container: radioButtonRootRef.current,\n });\n\n const boxHeight = radioButtonBoxRef.current?.getBoundingClientRect().height ?? 0;\n\n setRadioButtonTop((singleLineHeight - boxHeight) / 2);\n }\n }, [shouldShowCentered]);\n\n const handleClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (uncheckable) {\n if (updateSelectedRadioButtonId) {\n updateSelectedRadioButtonId(id === selectedRadioButtonId ? undefined : id);\n }\n setInternalIsChecked((prev) => !prev);\n return;\n }\n if (typeof updateSelectedRadioButtonId === 'function') {\n updateSelectedRadioButtonId(id);\n }\n setInternalIsChecked(true);\n }, [id, isDisabled, uncheckable, selectedRadioButtonId, updateSelectedRadioButtonId]);\n\n const handleMouseEnter = useCallback(() => {\n if (!isDisabled) {\n setIsHovered(true);\n }\n }, [isDisabled]);\n\n const handleMouseLeave = () => {\n setIsHovered(false);\n };\n\n const radioButtonRightElementMargin: RadioButtonRightElementMargin = useMemo(() => {\n if (!radioButtonRightElements) {\n return 'NONE';\n }\n\n const index = radioButtonRightElements.findIndex((element) => element.id === id);\n\n if (index < 0) {\n return 'NONE';\n }\n\n const prevButton = radioButtonRightElements[index - 1];\n const currentButton = radioButtonRightElements[index];\n const nextButton = radioButtonRightElements[index + 1];\n\n if (!currentButton?.hasRightElement) {\n return 'NONE';\n }\n\n switch (true) {\n case prevButton?.hasRightElement && !nextButton?.hasRightElement:\n return 'TOP';\n case !prevButton?.hasRightElement && nextButton?.hasRightElement:\n return 'BOTTOM';\n case currentButton?.hasRightElement &&\n !nextButton?.hasRightElement &&\n !prevButton?.hasRightElement:\n return 'NONE';\n default:\n return 'BOTH';\n }\n }, [id, radioButtonRightElements]);\n\n const shouldShowRightElement = useMemo(() => {\n if (rightElement) {\n if (shouldShowRightElementOnlyOnChecked) {\n return isMarked;\n }\n\n return true;\n }\n\n return false;\n }, [isMarked, rightElement, shouldShowRightElementOnlyOnChecked]);\n\n useEffect(() => {\n if (typeof updateHasRightElement === 'function') {\n window.setTimeout(() => {\n updateHasRightElement(id, shouldShowRightElement);\n }, 10);\n }\n }, [id, shouldShowRightElement, updateHasRightElement]);\n\n return useMemo(\n () => (\n <StyledRadioButton\n $isDisabled={isDisabled}\n $radioButtonRightElementMargin={radioButtonRightElementMargin}\n >\n <StyledRadioButtonWrapper ref={radioButtonRootRef}>\n <StyledRadioButtonPseudoCheckBox\n $isDisabled={isDisabled}\n $isChecked={isMarked}\n ref={radioButtonBoxRef}\n onClick={handleClick}\n style={{\n top: shouldShowCentered ? '50%' : radioButtonTop,\n transform: shouldShowCentered ? 'translateY(-50%)' : undefined,\n }}\n >\n <StyledRadioButtonCheckBoxMark\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n $isHovered={isHovered}\n $isSelected={isMarked}\n $isDisabled={isDisabled}\n />\n </StyledRadioButtonPseudoCheckBox>\n <StyledRadioButtonCheckBox\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n disabled={isDisabled}\n $isDisabled={isDisabled}\n type=\"radio\"\n checked={isMarked}\n onChange={() => {}}\n />\n <StyledLabelWrapper>\n {label && (\n <StyledRadioButtonLabel\n $isDisabled={isDisabled}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {label}\n </StyledRadioButtonLabel>\n )}\n {shouldShowRightElement && rightElement}\n </StyledLabelWrapper>\n </StyledRadioButtonWrapper>\n {children && (\n <AnimatePresence initial={false}>\n <StyledMotionRadioButtonChildren\n animate={\n isMarked\n ? { opacity: 1, height: 'auto' }\n : { opacity: 0, height: 0 }\n }\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionRadioButtonChildren>\n </AnimatePresence>\n )}\n </StyledRadioButton>\n ),\n [\n children,\n handleClick,\n handleMouseEnter,\n isDisabled,\n isHovered,\n isMarked,\n label,\n radioButtonRightElementMargin,\n radioButtonTop,\n rightElement,\n shouldShowCentered,\n shouldShowRightElement,\n ],\n );\n};\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAWA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAUA,IAAAK,UAAA,GAAAL,OAAA;AAAkE,SAAAE,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAA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,EAAE;IAAE,CACjC;IACD+C,UAAU,EAAE;MAAEC,QAAQ,EAAE;IAAI;EAAE,GAE7BpF,QAC4B,CACpB,CAEN,CACtB,EACD,CACIA,QAAQ,EACRqC,WAAW,EACXG,gBAAgB,EAChBlC,UAAU,EACVW,SAAS,EACTS,QAAQ,EACRxB,KAAK,EACLwC,6BAA6B,EAC7BvB,cAAc,EACdf,YAAY,EACZC,kBAAkB,EAClB8C,sBAAsB,CAE9B,CAAC;AACL,CAAC;AAEDpD,WAAW,CAACsF,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAjG,OAAA,GAEzBS,WAAW","ignoreList":[]}
1
+ {"version":3,"file":"RadioButton.js","names":["_react","require","_react2","_interopRequireWildcard","_RadioButtonGroup","_RadioButton","_calculate","_useKeyboardFocusHighlighting","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RadioButton","children","shouldShowRightElementOnlyOnChecked","label","id","rightElement","shouldShowCentered","isDisabled","shouldEnableKeyboardHighlighting","selectedRadioButtonId","updateSelectedRadioButtonId","radioButtonRightElements","updateHasRightElement","radioButtonsCanBeUnchecked","shouldEnableKeyboardHighlightingFromGroup","useContext","RadioButtonGroupContext","internalIsChecked","setInternalIsChecked","useState","isHovered","setIsHovered","radioButtonTop","setRadioButtonTop","undefined","radioButtonBoxRef","useRef","radioButtonRootRef","isInGroup","isMarked","uncheckable","effectiveShouldEnableKeyboardHighlighting","shouldShowKeyboardHighlighting","useKeyboardFocusHighlighting","useEffect","current","_radioButtonBoxRef$cu","singleLineHeight","getHeightOfSingleTextLine","container","boxHeight","getBoundingClientRect","height","handleClick","useCallback","prev","handleMouseEnter","handleMouseLeave","handleKeyDown","event","key","preventDefault","radioButtonRightElementMargin","useMemo","index","findIndex","element","prevButton","currentButton","nextButton","hasRightElement","shouldShowRightElement","window","setTimeout","createElement","StyledRadioButton","$isDisabled","$radioButtonRightElementMargin","StyledRadioButtonWrapper","ref","$shouldShowKeyboardHighlighting","StyledRadioButtonCheckBox","onClick","onMouseEnter","onMouseLeave","onKeyDown","disabled","type","checked","onChange","StyledRadioButtonPseudoCheckBox","$isChecked","style","top","transform","StyledRadioButtonCheckBoxMark","$isHovered","$isSelected","StyledLabelWrapper","StyledRadioButtonLabel","AnimatePresence","initial","StyledMotionRadioButtonChildren","animate","opacity","transition","duration","displayName","_default","exports"],"sources":["../../../../src/components/radio-button/RadioButton.tsx"],"sourcesContent":["import { AnimatePresence } from 'motion/react';\nimport React, {\n FC,\n useCallback,\n useContext,\n useEffect,\n useMemo,\n useState,\n type ReactNode,\n useRef,\n} from 'react';\nimport { RadioButtonRightElementMargin } from '../../types/radioButton';\nimport { RadioButtonGroupContext } from './radio-button-group/RadioButtonGroup';\nimport {\n StyledLabelWrapper,\n StyledMotionRadioButtonChildren,\n StyledRadioButton,\n StyledRadioButtonCheckBox,\n StyledRadioButtonCheckBoxMark,\n StyledRadioButtonLabel,\n StyledRadioButtonPseudoCheckBox,\n StyledRadioButtonWrapper,\n} from './RadioButton.styles';\nimport { getHeightOfSingleTextLine } from '../../utils/calculate';\nimport { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';\n\nexport type RadioButtonProps = {\n /**\n * The children that should be displayed after the RadioButton is checked.\n */\n children?: ReactNode;\n /**\n * whether the RadioButton should be shown.\n */\n isDisabled?: boolean;\n /**\n * The id of the radio button.\n */\n id: string;\n /**\n * The label that should be displayed next to the radio button.\n */\n label?: ReactNode;\n /**\n * An element that should be displayed on the right side of the label.\n */\n rightElement?: ReactNode;\n /**\n * Whether the rightElement should only be displayed when the RadioButton is checked\n */\n shouldShowRightElementOnlyOnChecked?: boolean;\n /**\n * Whether the RadioButton should be displayed centered to the label or at the top\n */\n shouldShowCentered?: boolean;\n /**\n * Enables keyboard-only focus highlighting.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n};\n\nconst RadioButton: FC<RadioButtonProps> = ({\n children,\n shouldShowRightElementOnlyOnChecked = false,\n label,\n id,\n rightElement,\n shouldShowCentered = true,\n isDisabled = false,\n shouldEnableKeyboardHighlighting,\n}) => {\n const {\n selectedRadioButtonId,\n updateSelectedRadioButtonId,\n radioButtonRightElements,\n updateHasRightElement,\n radioButtonsCanBeUnchecked,\n shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingFromGroup,\n } = useContext(RadioButtonGroupContext);\n\n const [internalIsChecked, setInternalIsChecked] = useState(false);\n const [isHovered, setIsHovered] = useState(false);\n const [radioButtonTop, setRadioButtonTop] = useState<number | undefined>(undefined);\n\n const radioButtonBoxRef = useRef<HTMLDivElement>(null);\n const radioButtonRootRef = useRef<HTMLDivElement>(null);\n\n const isInGroup = typeof updateSelectedRadioButtonId === 'function';\n\n const isMarked = isInGroup ? selectedRadioButtonId === id : internalIsChecked;\n\n const uncheckable = radioButtonsCanBeUnchecked;\n\n const effectiveShouldEnableKeyboardHighlighting =\n shouldEnableKeyboardHighlightingFromGroup ?? shouldEnableKeyboardHighlighting;\n\n const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(\n effectiveShouldEnableKeyboardHighlighting && !isDisabled,\n );\n\n useEffect(() => {\n if (radioButtonRootRef.current && !shouldShowCentered) {\n const singleLineHeight = getHeightOfSingleTextLine({\n container: radioButtonRootRef.current,\n });\n\n const boxHeight = radioButtonBoxRef.current?.getBoundingClientRect().height ?? 0;\n\n setRadioButtonTop((singleLineHeight - boxHeight) / 2);\n }\n }, [shouldShowCentered]);\n\n const handleClick = useCallback(() => {\n if (isDisabled) {\n return;\n }\n\n if (uncheckable) {\n if (updateSelectedRadioButtonId) {\n updateSelectedRadioButtonId(id === selectedRadioButtonId ? undefined : id);\n }\n setInternalIsChecked((prev) => !prev);\n return;\n }\n if (typeof updateSelectedRadioButtonId === 'function') {\n updateSelectedRadioButtonId(id);\n }\n setInternalIsChecked(true);\n }, [id, isDisabled, uncheckable, selectedRadioButtonId, updateSelectedRadioButtonId]);\n\n const handleMouseEnter = useCallback(() => {\n if (!isDisabled) {\n setIsHovered(true);\n }\n }, [isDisabled]);\n\n const handleMouseLeave = () => {\n setIsHovered(false);\n };\n\n const handleKeyDown = useCallback(\n (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Enter') {\n event.preventDefault();\n handleClick();\n }\n },\n [handleClick],\n );\n\n const radioButtonRightElementMargin: RadioButtonRightElementMargin = useMemo(() => {\n if (!radioButtonRightElements) {\n return 'NONE';\n }\n\n const index = radioButtonRightElements.findIndex((element) => element.id === id);\n\n if (index < 0) {\n return 'NONE';\n }\n\n const prevButton = radioButtonRightElements[index - 1];\n const currentButton = radioButtonRightElements[index];\n const nextButton = radioButtonRightElements[index + 1];\n\n if (!currentButton?.hasRightElement) {\n return 'NONE';\n }\n\n switch (true) {\n case prevButton?.hasRightElement && !nextButton?.hasRightElement:\n return 'TOP';\n case !prevButton?.hasRightElement && nextButton?.hasRightElement:\n return 'BOTTOM';\n case currentButton?.hasRightElement &&\n !nextButton?.hasRightElement &&\n !prevButton?.hasRightElement:\n return 'NONE';\n default:\n return 'BOTH';\n }\n }, [id, radioButtonRightElements]);\n\n const shouldShowRightElement = useMemo(() => {\n if (rightElement) {\n if (shouldShowRightElementOnlyOnChecked) {\n return isMarked;\n }\n\n return true;\n }\n\n return false;\n }, [isMarked, rightElement, shouldShowRightElementOnlyOnChecked]);\n\n useEffect(() => {\n if (typeof updateHasRightElement === 'function') {\n window.setTimeout(() => {\n updateHasRightElement(id, shouldShowRightElement);\n }, 10);\n }\n }, [id, shouldShowRightElement, updateHasRightElement]);\n\n return useMemo(\n () => (\n <StyledRadioButton\n $isDisabled={isDisabled}\n $radioButtonRightElementMargin={radioButtonRightElementMargin}\n >\n <StyledRadioButtonWrapper\n ref={radioButtonRootRef}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n >\n <StyledRadioButtonCheckBox\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n onKeyDown={handleKeyDown}\n disabled={isDisabled}\n $isDisabled={isDisabled}\n $shouldShowKeyboardHighlighting={shouldShowKeyboardHighlighting}\n type=\"radio\"\n checked={isMarked}\n onChange={() => {}}\n />\n <StyledRadioButtonPseudoCheckBox\n $isDisabled={isDisabled}\n $isChecked={isMarked}\n ref={radioButtonBoxRef}\n onClick={handleClick}\n style={{\n top: shouldShowCentered ? '50%' : radioButtonTop,\n transform: shouldShowCentered ? 'translateY(-50%)' : undefined,\n }}\n >\n <StyledRadioButtonCheckBoxMark\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n $isHovered={isHovered}\n $isSelected={isMarked}\n $isDisabled={isDisabled}\n />\n </StyledRadioButtonPseudoCheckBox>\n <StyledLabelWrapper>\n {label && (\n <StyledRadioButtonLabel\n $isDisabled={isDisabled}\n onClick={handleClick}\n onMouseEnter={handleMouseEnter}\n onMouseLeave={handleMouseLeave}\n >\n {label}\n </StyledRadioButtonLabel>\n )}\n {shouldShowRightElement && rightElement}\n </StyledLabelWrapper>\n </StyledRadioButtonWrapper>\n {children && (\n <AnimatePresence initial={false}>\n <StyledMotionRadioButtonChildren\n animate={\n isMarked\n ? { opacity: 1, height: 'auto' }\n : { opacity: 0, height: 0 }\n }\n transition={{ duration: 0.2 }}\n >\n {children}\n </StyledMotionRadioButtonChildren>\n </AnimatePresence>\n )}\n </StyledRadioButton>\n ),\n [\n children,\n handleClick,\n handleKeyDown,\n handleMouseEnter,\n isDisabled,\n isHovered,\n isMarked,\n label,\n radioButtonRightElementMargin,\n radioButtonTop,\n rightElement,\n shouldShowCentered,\n shouldShowKeyboardHighlighting,\n shouldShowRightElement,\n ],\n );\n};\n\nRadioButton.displayName = 'RadioButton';\n\nexport default RadioButton;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAWA,IAAAG,iBAAA,GAAAH,OAAA;AACA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Aa,EACbF,gBAAgB,EAChBvC,UAAU,EACVa,SAAS,EACTS,QAAQ,EACR1B,KAAK,EACLiD,6BAA6B,EAC7B9B,cAAc,EACdjB,YAAY,EACZC,kBAAkB,EAClB0B,8BAA8B,EAC9B6B,sBAAsB,CAE9B,CAAC;AACL,CAAC;AAED7D,WAAW,CAACiG,WAAW,GAAG,aAAa;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAA5G,OAAA,GAEzBS,WAAW","ignoreList":[]}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.StyledRadioButtonWrapper = exports.StyledRadioButtonPseudoCheckBox = exports.StyledRadioButtonLabel = exports.StyledRadioButtonCheckBoxMark = exports.StyledRadioButtonCheckBox = exports.StyledRadioButton = exports.StyledMotionRadioButtonChildren = exports.StyledLabelWrapper = void 0;
7
7
  var _react = require("motion/react");
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
+ var _keyboardFocusHighlighting = require("../../utils/keyboardFocusHighlighting.styles");
9
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
11
  const StyledRadioButton = exports.StyledRadioButton = _styledComponents.default.span`
11
12
  display: flex;
@@ -48,14 +49,6 @@ const StyledRadioButtonWrapper = exports.StyledRadioButtonWrapper = _styledCompo
48
49
  gap: 5px;
49
50
  user-select: none;
50
51
  `;
51
- const StyledRadioButtonCheckBox = exports.StyledRadioButtonCheckBox = _styledComponents.default.input`
52
- opacity: 0;
53
- height: 15px;
54
- width: 15px;
55
- cursor: ${({
56
- $isDisabled
57
- }) => $isDisabled ? 'default !important' : 'pointer !important'};
58
- `;
59
52
  const StyledRadioButtonPseudoCheckBox = exports.StyledRadioButtonPseudoCheckBox = _styledComponents.default.div`
60
53
  background-color: ${({
61
54
  theme,
@@ -70,9 +63,27 @@ const StyledRadioButtonPseudoCheckBox = exports.StyledRadioButtonPseudoCheckBox
70
63
  height: 15px;
71
64
  position: absolute;
72
65
  border-radius: 100%;
66
+ z-index: 1;
67
+ cursor: ${({
68
+ $isDisabled
69
+ }) => $isDisabled ? 'default !important' : 'pointer !important'};
70
+ `;
71
+ const StyledRadioButtonCheckBox = exports.StyledRadioButtonCheckBox = _styledComponents.default.input`
72
+ opacity: 0;
73
+ height: 15px;
74
+ width: 15px;
73
75
  cursor: ${({
74
76
  $isDisabled
75
77
  }) => $isDisabled ? 'default !important' : 'pointer !important'};
78
+
79
+ ${({
80
+ $shouldShowKeyboardHighlighting
81
+ }) => $shouldShowKeyboardHighlighting && (0, _styledComponents.css)`
82
+ &:focus-visible + ${StyledRadioButtonPseudoCheckBox} {
83
+ transition: none;
84
+ ${_keyboardFocusHighlighting.keyboardFocusHighlightingCircleRingCss}
85
+ }
86
+ `}
76
87
  `;
77
88
  const StyledRadioButtonCheckBoxMark = exports.StyledRadioButtonCheckBoxMark = _styledComponents.default.span`
78
89
  background-color: transparent;
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButton.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledRadioButton","exports","styled","span","$isDisabled","$radioButtonRightElementMargin","css","StyledRadioButtonWrapper","div","StyledRadioButtonCheckBox","input","StyledRadioButtonPseudoCheckBox","theme","$isChecked","StyledRadioButtonCheckBoxMark","$isHovered","$isSelected","StyledRadioButtonLabel","p","text","StyledLabelWrapper","StyledMotionRadioButtonChildren","motion"],"sources":["../../../../src/components/radio-button/RadioButton.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { RadioButtonRightElementMargin } from '../../types/radioButton';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\ntype StyledRadioButtonProps = WithTheme<{\n $isDisabled: boolean;\n $radioButtonRightElementMargin: RadioButtonRightElementMargin;\n}>;\n\nexport const StyledRadioButton = styled.span<StyledRadioButtonProps>`\n display: flex;\n flex-direction: column;\n\n position: relative;\n\n opacity: ${({ $isDisabled }: StyledRadioButtonProps) => ($isDisabled ? 0.5 : 1)};\n\n ${({ $radioButtonRightElementMargin }: StyledRadioButtonProps) => {\n switch ($radioButtonRightElementMargin) {\n case 'BOTH':\n return css`\n margin: 6px 0;\n `;\n case 'TOP':\n return css`\n margin-top: 6px;\n `;\n case 'BOTTOM':\n return css`\n margin-bottom: 6px;\n `;\n case 'NONE':\n default:\n return css`\n margin: 0;\n `;\n }\n }}\n`;\n\nexport const StyledRadioButtonWrapper = styled.div`\n display: flex;\n align-items: center;\n position: relative;\n gap: 5px;\n user-select: none;\n`;\n\ntype StyledRadioButtonCheckBoxProps = WithTheme<{ $isDisabled: boolean }>;\n\nexport const StyledRadioButtonCheckBox = styled.input<StyledRadioButtonCheckBoxProps>`\n opacity: 0;\n height: 15px;\n width: 15px;\n cursor: ${({ $isDisabled }: StyledRadioButtonCheckBoxProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n`;\n\ntype StyledRadioButtonPseudoCheckBoxProps = WithTheme<{\n $isChecked: boolean;\n $isDisabled: boolean;\n}>;\n\nexport const StyledRadioButtonPseudoCheckBox = styled.div<StyledRadioButtonPseudoCheckBoxProps>`\n background-color: ${({ theme, $isChecked }: StyledRadioButtonPseudoCheckBoxProps) =>\n $isChecked ? theme['secondary-408'] : theme['secondary-403']};\n opacity: 1;\n border: 1px solid\n rgba(${({ theme }: StyledRadioButtonPseudoCheckBoxProps) => theme['409-rgb']}, 0.5);\n width: 15px;\n height: 15px;\n position: absolute;\n border-radius: 100%;\n cursor: ${({ $isDisabled }: StyledRadioButtonPseudoCheckBoxProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n`;\n\ntype StyledRadioButtonCheckBoxMarkProps = WithTheme<{\n $isHovered: boolean;\n $isSelected: boolean;\n $isDisabled: boolean;\n}>;\n\nexport const StyledRadioButtonCheckBoxMark = styled.span<StyledRadioButtonCheckBoxMarkProps>`\n background-color: transparent;\n position: absolute;\n top: 1px;\n left: 3.925px;\n display: inline-block;\n transform: rotate(35deg);\n height: 9px;\n width: 5px;\n border-bottom: 2px solid white;\n border-right: 2px solid white;\n border-top: transparent;\n border-left: transparent;\n z-index: 2;\n cursor: ${({ $isDisabled }: StyledRadioButtonCheckBoxMarkProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n\n ${({ $isHovered, $isSelected }) => {\n if ($isSelected) {\n return css`\n opacity: 1;\n `;\n }\n\n if ($isHovered) {\n return css`\n opacity: 0.5;\n `;\n }\n\n return css`\n opacity: 0;\n `;\n }}\n`;\n\ntype StyledRadioButtonLabelProps = WithTheme<{ $isDisabled: boolean }>;\n\nexport const StyledRadioButtonLabel = styled.p<StyledRadioButtonLabelProps>`\n color: ${({ theme }: StyledRadioButtonLabelProps) => theme.text};\n margin: 0;\n cursor: ${({ $isDisabled }: StyledRadioButtonLabelProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n`;\n\nexport const StyledLabelWrapper = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n gap: 12px;\n`;\n\ntype StyledMotionRadioButtonChildrenProps = WithTheme<unknown>;\n\nexport const StyledMotionRadioButtonChildren = styled(\n motion.div,\n)<StyledMotionRadioButtonChildrenProps>`\n margin-left: 20px;\n cursor: text;\n overflow: hidden;\n color: ${({ theme }: StyledMotionRadioButtonChildrenProps) => theme.text};\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA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ACA,MAAM,CAAC;EAAEW,UAAU;EAAEC;AAAY,CAAC,KAAK;EAC/B,IAAIA,WAAW,EAAE;IACb,OAAO,IAAAV,qBAAG;AACtB;AACA,aAAa;EACL;EAEA,IAAIS,UAAU,EAAE;IACZ,OAAO,IAAAT,qBAAG;AACtB;AACA,aAAa;EACL;EAEA,OAAO,IAAAA,qBAAG;AAClB;AACA,SAAS;AACL,CAAC;AACL,CAAC;AAIM,MAAMW,sBAAsB,GAAAhB,OAAA,CAAAgB,sBAAA,GAAGf,yBAAM,CAACgB,CAA8B;AAC3E,aAAa,CAAC;EAAEN;AAAmC,CAAC,KAAKA,KAAK,CAACO,IAAI;AACnE;AACA,cAAc,CAAC;EAAEf;AAAyC,CAAC,KACnDA,WAAW,GAAG,oBAAoB,GAAG,oBAAoB;AACjE,CAAC;AAEM,MAAMgB,kBAAkB,GAAAnB,OAAA,CAAAmB,kBAAA,GAAGlB,yBAAM,CAACM,GAAG;AAC5C;AACA;AACA;AACA;AACA;AACA,CAAC;AAIM,MAAMa,+BAA+B,GAAApB,OAAA,CAAAoB,+BAAA,GAAG,IAAAnB,yBAAM,EACjDoB,aAAM,CAACd,GACX,CAAuC;AACvC;AACA;AACA;AACA,aAAa,CAAC;EAAEI;AAA4C,CAAC,KAAKA,KAAK,CAACO,IAAI;AAC5E,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"RadioButton.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_keyboardFocusHighlighting","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledRadioButton","exports","styled","span","$isDisabled","$radioButtonRightElementMargin","css","StyledRadioButtonWrapper","div","StyledRadioButtonPseudoCheckBox","theme","$isChecked","StyledRadioButtonCheckBox","input","$shouldShowKeyboardHighlighting","keyboardFocusHighlightingCircleRingCss","StyledRadioButtonCheckBoxMark","$isHovered","$isSelected","StyledRadioButtonLabel","p","text","StyledLabelWrapper","StyledMotionRadioButtonChildren","motion"],"sources":["../../../../src/components/radio-button/RadioButton.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { RadioButtonRightElementMargin } from '../../types/radioButton';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { keyboardFocusHighlightingCircleRingCss } from '../../utils/keyboardFocusHighlighting.styles';\n\ntype StyledRadioButtonProps = WithTheme<{\n $isDisabled: boolean;\n $radioButtonRightElementMargin: RadioButtonRightElementMargin;\n}>;\n\nexport const StyledRadioButton = styled.span<StyledRadioButtonProps>`\n display: flex;\n flex-direction: column;\n\n position: relative;\n\n opacity: ${({ $isDisabled }: StyledRadioButtonProps) => ($isDisabled ? 0.5 : 1)};\n\n ${({ $radioButtonRightElementMargin }: StyledRadioButtonProps) => {\n switch ($radioButtonRightElementMargin) {\n case 'BOTH':\n return css`\n margin: 6px 0;\n `;\n case 'TOP':\n return css`\n margin-top: 6px;\n `;\n case 'BOTTOM':\n return css`\n margin-bottom: 6px;\n `;\n case 'NONE':\n default:\n return css`\n margin: 0;\n `;\n }\n }}\n`;\n\ntype StyledRadioButtonWrapperProps = {\n $shouldShowKeyboardHighlighting: boolean;\n};\n\nexport const StyledRadioButtonWrapper = styled.div<StyledRadioButtonWrapperProps>`\n display: flex;\n align-items: center;\n position: relative;\n gap: 5px;\n user-select: none;\n`;\n\ntype StyledRadioButtonPseudoCheckBoxProps = WithTheme<{\n $isChecked: boolean;\n $isDisabled: boolean;\n}>;\n\nexport const StyledRadioButtonPseudoCheckBox = styled.div<StyledRadioButtonPseudoCheckBoxProps>`\n background-color: ${({ theme, $isChecked }: StyledRadioButtonPseudoCheckBoxProps) =>\n $isChecked ? theme['secondary-408'] : theme['secondary-403']};\n opacity: 1;\n border: 1px solid\n rgba(${({ theme }: StyledRadioButtonPseudoCheckBoxProps) => theme['409-rgb']}, 0.5);\n width: 15px;\n height: 15px;\n position: absolute;\n border-radius: 100%;\n z-index: 1;\n cursor: ${({ $isDisabled }: StyledRadioButtonPseudoCheckBoxProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n`;\n\ntype StyledRadioButtonCheckBoxProps = WithTheme<{\n $isDisabled: boolean;\n $shouldShowKeyboardHighlighting: boolean;\n}>;\n\nexport const StyledRadioButtonCheckBox = styled.input<StyledRadioButtonCheckBoxProps>`\n opacity: 0;\n height: 15px;\n width: 15px;\n cursor: ${({ $isDisabled }: StyledRadioButtonCheckBoxProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n\n ${({ $shouldShowKeyboardHighlighting }) =>\n $shouldShowKeyboardHighlighting &&\n css`\n &:focus-visible + ${StyledRadioButtonPseudoCheckBox} {\n transition: none;\n ${keyboardFocusHighlightingCircleRingCss}\n }\n `}\n`;\n\ntype StyledRadioButtonCheckBoxMarkProps = WithTheme<{\n $isHovered: boolean;\n $isSelected: boolean;\n $isDisabled: boolean;\n}>;\n\nexport const StyledRadioButtonCheckBoxMark = styled.span<StyledRadioButtonCheckBoxMarkProps>`\n background-color: transparent;\n position: absolute;\n top: 1px;\n left: 3.925px;\n display: inline-block;\n transform: rotate(35deg);\n height: 9px;\n width: 5px;\n border-bottom: 2px solid white;\n border-right: 2px solid white;\n border-top: transparent;\n border-left: transparent;\n z-index: 2;\n cursor: ${({ $isDisabled }: StyledRadioButtonCheckBoxMarkProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n\n ${({ $isHovered, $isSelected }) => {\n if ($isSelected) {\n return css`\n opacity: 1;\n `;\n }\n\n if ($isHovered) {\n return css`\n opacity: 0.5;\n `;\n }\n\n return css`\n opacity: 0;\n `;\n }}\n`;\n\ntype StyledRadioButtonLabelProps = WithTheme<{ $isDisabled: boolean }>;\n\nexport const StyledRadioButtonLabel = styled.p<StyledRadioButtonLabelProps>`\n color: ${({ theme }: StyledRadioButtonLabelProps) => theme.text};\n margin: 0;\n cursor: ${({ $isDisabled }: StyledRadioButtonLabelProps) =>\n $isDisabled ? 'default !important' : 'pointer !important'};\n`;\n\nexport const StyledLabelWrapper = styled.div`\n display: flex;\n align-items: center;\n justify-content: space-between;\n width: 100%;\n gap: 12px;\n`;\n\ntype StyledMotionRadioButtonChildrenProps = WithTheme<unknown>;\n\nexport const StyledMotionRadioButtonChildren = styled(\n motion.div,\n)<StyledMotionRadioButtonChildrenProps>`\n margin-left: 20px;\n cursor: text;\n overflow: hidden;\n color: ${({ theme }: StyledMotionRadioButtonChildrenProps) => theme.text};\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAGA,IAAAG,0BAAA,GAAAH,OAAA;AAAsG,SAAAE,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,G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,yBAAM,EACjDsB,aAAM,CAAChB,GACX,CAAuC;AACvC;AACA;AACA;AACA,aAAa,CAAC;EAAEE;AAA4C,CAAC,KAAKA,KAAK,CAACW,IAAI;AAC5E,CAAC","ignoreList":[]}
@@ -12,14 +12,16 @@ const RadioButtonGroupContext = exports.RadioButtonGroupContext = /*#__PURE__*/_
12
12
  updateSelectedRadioButtonId: undefined,
13
13
  radioButtonsCanBeUnchecked: false,
14
14
  radioButtonRightElements: [],
15
- updateHasRightElement: undefined
15
+ updateHasRightElement: undefined,
16
+ shouldEnableKeyboardHighlighting: undefined
16
17
  });
17
18
  RadioButtonGroupContext.displayName = 'RadioButtonGroupContext';
18
19
  const RadioButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
19
20
  children,
20
21
  canUncheckRadioButtons,
21
22
  selectedId,
22
- onSelect
23
+ onSelect,
24
+ shouldEnableKeyboardHighlighting
23
25
  }, ref) => {
24
26
  const [selectedRadioButtonId, setSelectedRadioButtonId] = (0, _react.useState)(undefined);
25
27
  const [radioButtonRightElements, setRadioButtonRightElements] = (0, _react.useState)([]);
@@ -57,8 +59,9 @@ const RadioButtonGroup = /*#__PURE__*/(0, _react.forwardRef)(({
57
59
  updateSelectedRadioButtonId,
58
60
  radioButtonsCanBeUnchecked: canUncheckRadioButtons,
59
61
  updateHasRightElement,
60
- radioButtonRightElements
61
- }), [canUncheckRadioButtons, radioButtonRightElements, selectedRadioButtonId, updateHasRightElement, updateSelectedRadioButtonId]);
62
+ radioButtonRightElements,
63
+ shouldEnableKeyboardHighlighting
64
+ }), [canUncheckRadioButtons, radioButtonRightElements, selectedRadioButtonId, shouldEnableKeyboardHighlighting, updateHasRightElement, updateSelectedRadioButtonId]);
62
65
  return /*#__PURE__*/_react.default.createElement(RadioButtonGroupContext.Provider, {
63
66
  value: providerValue
64
67
  }, children);
@@ -1 +1 @@
1
- {"version":3,"file":"RadioButtonGroup.js","names":["_react","_interopRequireWildcard","require","_radioButton","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RadioButtonGroupContext","exports","React","createContext","selectedRadioButtonId","undefined","updateSelectedRadioButtonId","radioButtonsCanBeUnchecked","radioButtonRightElements","updateHasRightElement","displayName","RadioButtonGroup","forwardRef","children","canUncheckRadioButtons","selectedId","onSelect","ref","setSelectedRadioButtonId","useState","setRadioButtonRightElements","isControlled","useEffect","useCallback","id","hasRightElement","prevState","map","prev","ids","getRadioButtonOrder","rightElements","useImperativeHandle","providerValue","useMemo","createElement","Provider","value","_default"],"sources":["../../../../../src/components/radio-button/radio-button-group/RadioButtonGroup.tsx"],"sourcesContent":["import React, {\n forwardRef,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\nimport { getRadioButtonOrder } from '../../../utils/radioButton';\n\ntype IUpdateSelectedRadioButtonId = (id: string | undefined) => void;\n\ntype IUpdateHasRightElement = (id: string, hasRightElement: boolean) => void;\n\ntype IRadioButtonRightElements = { id: string; hasRightElement: boolean }[];\n\ninterface IRadioButtonGroupContext {\n selectedRadioButtonId: string | undefined;\n updateSelectedRadioButtonId?: IUpdateSelectedRadioButtonId;\n radioButtonRightElements: IRadioButtonRightElements;\n updateHasRightElement?: IUpdateHasRightElement;\n radioButtonsCanBeUnchecked?: boolean;\n}\n\nexport const RadioButtonGroupContext = React.createContext<IRadioButtonGroupContext>({\n selectedRadioButtonId: undefined,\n updateSelectedRadioButtonId: undefined,\n radioButtonsCanBeUnchecked: false,\n radioButtonRightElements: [],\n updateHasRightElement: undefined,\n});\n\nRadioButtonGroupContext.displayName = 'RadioButtonGroupContext';\n\nexport interface RadioButtonGroupRef {\n updateSelectedRadioButtonId: IUpdateSelectedRadioButtonId;\n}\n\nexport type RadioButtonGroupProps = {\n /**\n * Whether the RadioButtons can be unchecked.\n */\n canUncheckRadioButtons?: boolean;\n /**\n * The RadioButtons that should be grouped. Radio buttons with the same group are\n * automatically unchecked when an `RadioButton` of the group is checked.\n */\n children: ReactNode;\n /**\n * Function to be executed when an id is selected.\n */\n onSelect?: (id?: string) => void;\n /**\n * The id of the current selected RadioButton.\n */\n selectedId?: string;\n};\n\nconst RadioButtonGroup = forwardRef<RadioButtonGroupRef, RadioButtonGroupProps>(\n ({ children, canUncheckRadioButtons, selectedId, onSelect }, ref) => {\n const [selectedRadioButtonId, setSelectedRadioButtonId] =\n useState<IRadioButtonGroupContext['selectedRadioButtonId']>(undefined);\n const [radioButtonRightElements, setRadioButtonRightElements] =\n useState<IRadioButtonRightElements>([]);\n\n const isControlled = typeof selectedId === 'string';\n\n useEffect(() => {\n setSelectedRadioButtonId(selectedId);\n }, [selectedId]);\n\n const updateSelectedRadioButtonId = useCallback<IUpdateSelectedRadioButtonId>(\n (id) => {\n if (typeof onSelect === 'function') {\n onSelect(id);\n }\n\n if (!isControlled) {\n setSelectedRadioButtonId(id);\n }\n },\n [isControlled, onSelect],\n );\n\n const updateHasRightElement = useCallback<IUpdateHasRightElement>((id, hasRightElement) => {\n setRadioButtonRightElements((prevState) =>\n prevState.map((prev) => (id === prev.id ? { id, hasRightElement } : prev)),\n );\n }, []);\n\n useEffect(() => {\n const ids = getRadioButtonOrder(children);\n\n const rightElements = ids.map((id) => ({ id, hasRightElement: false }));\n\n setRadioButtonRightElements(rightElements);\n }, [children]);\n\n useImperativeHandle(\n ref,\n () => ({\n updateSelectedRadioButtonId,\n }),\n [updateSelectedRadioButtonId],\n );\n\n const providerValue = useMemo<IRadioButtonGroupContext>(\n () => ({\n selectedRadioButtonId,\n updateSelectedRadioButtonId,\n radioButtonsCanBeUnchecked: canUncheckRadioButtons,\n updateHasRightElement,\n radioButtonRightElements,\n }),\n [\n canUncheckRadioButtons,\n radioButtonRightElements,\n selectedRadioButtonId,\n updateHasRightElement,\n updateSelectedRadioButtonId,\n ],\n );\n\n return (\n <RadioButtonGroupContext.Provider value={providerValue}>\n {children}\n </RadioButtonGroupContext.Provider>\n );\n },\n);\n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MO,GAAG,GAAG,IAAAC,gCAAmB,EAACjB,QAAQ,CAAC;IAEzC,MAAMkB,aAAa,GAAGF,GAAG,CAACF,GAAG,CAAEH,EAAE,KAAM;MAAEA,EAAE;MAAEC,eAAe,EAAE;IAAM,CAAC,CAAC,CAAC;IAEvEL,2BAA2B,CAACW,aAAa,CAAC;EAC9C,CAAC,EAAE,CAAClB,QAAQ,CAAC,CAAC;EAEd,IAAAmB,0BAAmB,EACff,GAAG,EACH,OAAO;IACHX;EACJ,CAAC,CAAC,EACF,CAACA,2BAA2B,CAChC,CAAC;EAED,MAAM2B,aAAa,GAAG,IAAAC,cAAO,EACzB,OAAO;IACH9B,qBAAqB;IACrBE,2BAA2B;IAC3BC,0BAA0B,EAAEO,sBAAsB;IAClDL,qBAAqB;IACrBD;EACJ,CAAC,CAAC,EACF,CACIM,sBAAsB,EACtBN,wBAAwB,EACxBJ,qBAAqB,EACrBK,qBAAqB,EACrBH,2BAA2B,CAEnC,CAAC;EAED,oBACI7B,MAAA,CAAAc,OAAA,CAAA4C,aAAA,CAACnC,uBAAuB,CAACoC,QAAQ;IAACC,KAAK,EAAEJ;EAAc,GAClDpB,QAC6B,CAAC;AAE3C,CACJ,CAAC;AAEDF,gBAAgB,CAACD,WAAW,GAAG,kBAAkB;AAAC,IAAA4B,QAAA,GAAArC,OAAA,CAAAV,OAAA,GAEnCoB,gBAAgB","ignoreList":[]}
1
+ {"version":3,"file":"RadioButtonGroup.js","names":["_react","_interopRequireWildcard","require","_radioButton","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","RadioButtonGroupContext","exports","React","createContext","selectedRadioButtonId","undefined","updateSelectedRadioButtonId","radioButtonsCanBeUnchecked","radioButtonRightElements","updateHasRightElement","shouldEnableKeyboardHighlighting","displayName","RadioButtonGroup","forwardRef","children","canUncheckRadioButtons","selectedId","onSelect","ref","setSelectedRadioButtonId","useState","setRadioButtonRightElements","isControlled","useEffect","useCallback","id","hasRightElement","prevState","map","prev","ids","getRadioButtonOrder","rightElements","useImperativeHandle","providerValue","useMemo","createElement","Provider","value","_default"],"sources":["../../../../../src/components/radio-button/radio-button-group/RadioButtonGroup.tsx"],"sourcesContent":["import React, {\n forwardRef,\n ReactNode,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useState,\n} from 'react';\nimport { getRadioButtonOrder } from '../../../utils/radioButton';\n\ntype IUpdateSelectedRadioButtonId = (id: string | undefined) => void;\n\ntype IUpdateHasRightElement = (id: string, hasRightElement: boolean) => void;\n\ntype IRadioButtonRightElements = { id: string; hasRightElement: boolean }[];\n\ninterface IRadioButtonGroupContext {\n selectedRadioButtonId: string | undefined;\n updateSelectedRadioButtonId?: IUpdateSelectedRadioButtonId;\n radioButtonRightElements: IRadioButtonRightElements;\n updateHasRightElement?: IUpdateHasRightElement;\n radioButtonsCanBeUnchecked?: boolean;\n shouldEnableKeyboardHighlighting?: boolean;\n}\n\nexport const RadioButtonGroupContext = React.createContext<IRadioButtonGroupContext>({\n selectedRadioButtonId: undefined,\n updateSelectedRadioButtonId: undefined,\n radioButtonsCanBeUnchecked: false,\n radioButtonRightElements: [],\n updateHasRightElement: undefined,\n shouldEnableKeyboardHighlighting: undefined,\n});\n\nRadioButtonGroupContext.displayName = 'RadioButtonGroupContext';\n\nexport interface RadioButtonGroupRef {\n updateSelectedRadioButtonId: IUpdateSelectedRadioButtonId;\n}\n\nexport type RadioButtonGroupProps = {\n /**\n * Whether the RadioButtons can be unchecked.\n */\n canUncheckRadioButtons?: boolean;\n /**\n * Enables keyboard-only focus highlighting for all RadioButtons in this group.\n */\n shouldEnableKeyboardHighlighting?: boolean;\n /**\n * The RadioButtons that should be grouped. Radio buttons with the same group are\n * automatically unchecked when an `RadioButton` of the group is checked.\n */\n children: ReactNode;\n /**\n * Function to be executed when an id is selected.\n */\n onSelect?: (id?: string) => void;\n /**\n * The id of the current selected RadioButton.\n */\n selectedId?: string;\n};\n\nconst RadioButtonGroup = forwardRef<RadioButtonGroupRef, RadioButtonGroupProps>(\n (\n {\n children,\n canUncheckRadioButtons,\n selectedId,\n onSelect,\n shouldEnableKeyboardHighlighting,\n },\n ref,\n ) => {\n const [selectedRadioButtonId, setSelectedRadioButtonId] =\n useState<IRadioButtonGroupContext['selectedRadioButtonId']>(undefined);\n const [radioButtonRightElements, setRadioButtonRightElements] =\n useState<IRadioButtonRightElements>([]);\n\n const isControlled = typeof selectedId === 'string';\n\n useEffect(() => {\n setSelectedRadioButtonId(selectedId);\n }, [selectedId]);\n\n const updateSelectedRadioButtonId = useCallback<IUpdateSelectedRadioButtonId>(\n (id) => {\n if (typeof onSelect === 'function') {\n onSelect(id);\n }\n\n if (!isControlled) {\n setSelectedRadioButtonId(id);\n }\n },\n [isControlled, onSelect],\n );\n\n const updateHasRightElement = useCallback<IUpdateHasRightElement>((id, hasRightElement) => {\n setRadioButtonRightElements((prevState) =>\n prevState.map((prev) => (id === prev.id ? { id, hasRightElement } : prev)),\n );\n }, []);\n\n useEffect(() => {\n const ids = getRadioButtonOrder(children);\n\n const rightElements = ids.map((id) => ({ id, hasRightElement: false }));\n\n setRadioButtonRightElements(rightElements);\n }, [children]);\n\n useImperativeHandle(\n ref,\n () => ({\n updateSelectedRadioButtonId,\n }),\n [updateSelectedRadioButtonId],\n );\n\n const providerValue = useMemo<IRadioButtonGroupContext>(\n () => ({\n selectedRadioButtonId,\n updateSelectedRadioButtonId,\n radioButtonsCanBeUnchecked: canUncheckRadioButtons,\n updateHasRightElement,\n radioButtonRightElements,\n shouldEnableKeyboardHighlighting,\n }),\n [\n canUncheckRadioButtons,\n radioButtonRightElements,\n selectedRadioButtonId,\n shouldEnableKeyboardHighlighting,\n updateHasRightElement,\n updateSelectedRadioButtonId,\n ],\n );\n\n return (\n <RadioButtonGroupContext.Provider value={providerValue}>\n {children}\n </RadioButtonGroupContext.Provider>\n );\n },\n);\n\nRadioButtonGroup.displayName = 'RadioButtonGroup';\n\nexport default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,GAAG,IAAAC,gCAAmB,EAACjB,QAAQ,CAAC;IAEzC,MAAMkB,aAAa,GAAGF,GAAG,CAACF,GAAG,CAAEH,EAAE,KAAM;MAAEA,EAAE;MAAEC,eAAe,EAAE;IAAM,CAAC,CAAC,CAAC;IAEvEL,2BAA2B,CAACW,aAAa,CAAC;EAC9C,CAAC,EAAE,CAAClB,QAAQ,CAAC,CAAC;EAEd,IAAAmB,0BAAmB,EACff,GAAG,EACH,OAAO;IACHZ;EACJ,CAAC,CAAC,EACF,CAACA,2BAA2B,CAChC,CAAC;EAED,MAAM4B,aAAa,GAAG,IAAAC,cAAO,EACzB,OAAO;IACH/B,qBAAqB;IACrBE,2BAA2B;IAC3BC,0BAA0B,EAAEQ,sBAAsB;IAClDN,qBAAqB;IACrBD,wBAAwB;IACxBE;EACJ,CAAC,CAAC,EACF,CACIK,sBAAsB,EACtBP,wBAAwB,EACxBJ,qBAAqB,EACrBM,gCAAgC,EAChCD,qBAAqB,EACrBH,2BAA2B,CAEnC,CAAC;EAED,oBACI7B,MAAA,CAAAc,OAAA,CAAA6C,aAAA,CAACpC,uBAAuB,CAACqC,QAAQ;IAACC,KAAK,EAAEJ;EAAc,GAClDpB,QAC6B,CAAC;AAE3C,CACJ,CAAC;AAEDF,gBAAgB,CAACD,WAAW,GAAG,kBAAkB;AAAC,IAAA4B,QAAA,GAAAtC,OAAA,CAAAV,OAAA,GAEnCqB,gBAAgB","ignoreList":[]}
@@ -41,7 +41,8 @@ const SearchBox = /*#__PURE__*/(0, _react.forwardRef)(({
41
41
  shouldShowContentOnEmptyInput = true,
42
42
  shouldShowRoundImage,
43
43
  shouldShowToggleIcon = false,
44
- tagInputSettings
44
+ tagInputSettings,
45
+ shouldEnableKeyboardHighlighting
45
46
  }, ref) => {
46
47
  const [matchingListsItems, setMatchingListsItems] = (0, _react.useState)(lists);
47
48
  const [selectedImage, setSelectedImage] = (0, _react.useState)();
@@ -561,6 +562,7 @@ const SearchBox = /*#__PURE__*/(0, _react.forwardRef)(({
561
562
  placeholder: placeholder,
562
563
  ref: tagInputRef,
563
564
  shouldAllowMultiple: tagInputSettings.shouldAllowMultiple,
565
+ shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlighting,
564
566
  shouldPreventEnter: true,
565
567
  tags: tagInputSettings.tags
566
568
  }) : /*#__PURE__*/_react.default.createElement(_Input.default, {
@@ -573,6 +575,7 @@ const SearchBox = /*#__PURE__*/(0, _react.forwardRef)(({
573
575
  placeholder: placeholder,
574
576
  ref: inputRef,
575
577
  rightElement: rightElement,
578
+ shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlighting,
576
579
  value: value
577
580
  })), boxRef.current && /*#__PURE__*/_react.default.createElement(_DropdownBodyWrapper.default, {
578
581
  anchorElement: boxRef.current,
@@ -590,7 +593,7 @@ const SearchBox = /*#__PURE__*/(0, _react.forwardRef)(({
590
593
  ref: contentRef,
591
594
  selectedGroups: groups,
592
595
  shouldHideFilterButtons: shouldHideFilterButtons
593
- }, content))), [container, content, dropdownDirection, filterButtons, groups, handleBlur, handleChange, handleClose, handleDropdownOutsideClick, handleFocus, height, isInvalid, leftElement, onKeyDown, placeholder, rightElement, shouldHideFilterButtons, shouldShowDropdown, tagInputSettings, uuid, value]);
596
+ }, content))), [container, content, dropdownDirection, filterButtons, groups, handleBlur, handleChange, handleClose, handleDropdownOutsideClick, handleFocus, height, isInvalid, leftElement, onKeyDown, placeholder, rightElement, shouldHideFilterButtons, shouldShowDropdown, shouldEnableKeyboardHighlighting, tagInputSettings, uuid, value]);
594
597
  });
595
598
  SearchBox.displayName = 'SearchBox';
596
599
  var _default = exports.default = SearchBox;