@chayns-components/core 5.4.6 → 5.4.8-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 (470) 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 +10 -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 +68 -11
  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 +146 -42
  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/context-menu/ContextMenu.utils.js +27 -1
  42. package/lib/cjs/components/context-menu/ContextMenu.utils.js.map +1 -1
  43. package/lib/cjs/components/context-menu/context-menu-content/ContextMenuContent.js +3 -8
  44. package/lib/cjs/components/context-menu/context-menu-content/ContextMenuContent.js.map +1 -1
  45. package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.js +2 -5
  46. package/lib/cjs/components/dropdown-body-wrapper/DropdownBodyWrapper.js.map +1 -1
  47. package/lib/cjs/components/file-input/FileInput.js +4 -2
  48. package/lib/cjs/components/file-input/FileInput.js.map +1 -1
  49. package/lib/cjs/components/file-list/file-item/FileItem.js +48 -25
  50. package/lib/cjs/components/file-list/file-item/FileItem.js.map +1 -1
  51. package/lib/cjs/components/file-list/file-item/FileItem.styles.js +25 -1
  52. package/lib/cjs/components/file-list/file-item/FileItem.styles.js.map +1 -1
  53. package/lib/cjs/components/file-select/FileSelect.js +27 -4
  54. package/lib/cjs/components/file-select/FileSelect.js.map +1 -1
  55. package/lib/cjs/components/file-select/FileSelect.styles.js +10 -0
  56. package/lib/cjs/components/file-select/FileSelect.styles.js.map +1 -1
  57. package/lib/cjs/components/filter/Filter.js +51 -16
  58. package/lib/cjs/components/filter/Filter.js.map +1 -1
  59. package/lib/cjs/components/filter/Filter.styles.js +9 -0
  60. package/lib/cjs/components/filter/Filter.styles.js.map +1 -1
  61. package/lib/cjs/components/filter/filter-content/FilterContent.js +14 -5
  62. package/lib/cjs/components/filter/filter-content/FilterContent.js.map +1 -1
  63. package/lib/cjs/components/filter/filter-content/FilterContent.types.js.map +1 -1
  64. package/lib/cjs/components/filter-buttons/FilterButtons.js +69 -4
  65. package/lib/cjs/components/filter-buttons/FilterButtons.js.map +1 -1
  66. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js +40 -2
  67. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
  68. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.styles.js +11 -0
  69. package/lib/cjs/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -1
  70. package/lib/cjs/components/grid-image/GridImage.js +20 -2
  71. package/lib/cjs/components/grid-image/GridImage.js.map +1 -1
  72. package/lib/cjs/components/grid-image/GridImage.styles.js +11 -2
  73. package/lib/cjs/components/grid-image/GridImage.styles.js.map +1 -1
  74. package/lib/cjs/components/grouped-image/GroupedImage.js +23 -4
  75. package/lib/cjs/components/grouped-image/GroupedImage.js.map +1 -1
  76. package/lib/cjs/components/grouped-image/GroupedImage.styles.js +9 -0
  77. package/lib/cjs/components/grouped-image/GroupedImage.styles.js.map +1 -1
  78. package/lib/cjs/components/highlight-slider/HighlightSlider.js +13 -3
  79. package/lib/cjs/components/highlight-slider/HighlightSlider.js.map +1 -1
  80. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js +21 -4
  81. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js.map +1 -1
  82. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js +11 -2
  83. package/lib/cjs/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js.map +1 -1
  84. package/lib/cjs/components/icon/Icon.js +24 -5
  85. package/lib/cjs/components/icon/Icon.js.map +1 -1
  86. package/lib/cjs/components/icon/Icon.styles.js +23 -0
  87. package/lib/cjs/components/icon/Icon.styles.js.map +1 -1
  88. package/lib/cjs/components/input/Input.js +29 -8
  89. package/lib/cjs/components/input/Input.js.map +1 -1
  90. package/lib/cjs/components/input/Input.styles.js +38 -3
  91. package/lib/cjs/components/input/Input.styles.js.map +1 -1
  92. package/lib/cjs/components/list/List.js +124 -37
  93. package/lib/cjs/components/list/List.js.map +1 -1
  94. package/lib/cjs/components/list/List.utils.js +213 -1
  95. package/lib/cjs/components/list/List.utils.js.map +1 -1
  96. package/lib/cjs/components/list/list-item/ListItem.js +84 -3
  97. package/lib/cjs/components/list/list-item/ListItem.js.map +1 -1
  98. package/lib/cjs/components/list/list-item/ListItem.styles.js +7 -0
  99. package/lib/cjs/components/list/list-item/ListItem.styles.js.map +1 -1
  100. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js +5 -1
  101. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  102. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.styles.js +5 -1
  103. package/lib/cjs/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  104. package/lib/cjs/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js +1 -0
  105. package/lib/cjs/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js.map +1 -1
  106. package/lib/cjs/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js +3 -0
  107. package/lib/cjs/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js.map +1 -1
  108. package/lib/cjs/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js +1 -0
  109. package/lib/cjs/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js.map +1 -1
  110. package/lib/cjs/components/list/list-item/useListItemFocus.js +47 -0
  111. package/lib/cjs/components/list/list-item/useListItemFocus.js.map +1 -0
  112. package/lib/cjs/components/mention-finder/MentionFinder.js +43 -5
  113. package/lib/cjs/components/mention-finder/MentionFinder.js.map +1 -1
  114. package/lib/cjs/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -1
  115. package/lib/cjs/components/multi-action-button/MultiActionButton.js +36 -3
  116. package/lib/cjs/components/multi-action-button/MultiActionButton.js.map +1 -1
  117. package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js +6 -0
  118. package/lib/cjs/components/multi-action-button/MultiActionButton.styles.js.map +1 -1
  119. package/lib/cjs/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  120. package/lib/cjs/components/multi-action-button/action-button/ActionButton.js +7 -1
  121. package/lib/cjs/components/multi-action-button/action-button/ActionButton.js.map +1 -1
  122. package/lib/cjs/components/multi-action-button/action-button/ActionButton.styles.js +12 -0
  123. package/lib/cjs/components/multi-action-button/action-button/ActionButton.styles.js.map +1 -1
  124. package/lib/cjs/components/number-input/NumberInput.js +13 -10
  125. package/lib/cjs/components/number-input/NumberInput.js.map +1 -1
  126. package/lib/cjs/components/page-provider/PageProvider.js +4 -2
  127. package/lib/cjs/components/page-provider/PageProvider.js.map +1 -1
  128. package/lib/cjs/components/popup/Popup.js +8 -1
  129. package/lib/cjs/components/popup/Popup.js.map +1 -1
  130. package/lib/cjs/components/radio-button/RadioButton.js +29 -15
  131. package/lib/cjs/components/radio-button/RadioButton.js.map +1 -1
  132. package/lib/cjs/components/radio-button/RadioButton.styles.js +19 -8
  133. package/lib/cjs/components/radio-button/RadioButton.styles.js.map +1 -1
  134. package/lib/cjs/components/radio-button/radio-button-group/RadioButtonGroup.js +7 -4
  135. package/lib/cjs/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -1
  136. package/lib/cjs/components/search-box/SearchBox.js +21 -6
  137. package/lib/cjs/components/search-box/SearchBox.js.map +1 -1
  138. package/lib/cjs/components/search-input/SearchInput.js +56 -43
  139. package/lib/cjs/components/search-input/SearchInput.js.map +1 -1
  140. package/lib/cjs/components/search-input/SearchInput.styles.js +26 -2
  141. package/lib/cjs/components/search-input/SearchInput.styles.js.map +1 -1
  142. package/lib/cjs/components/select-button/SelectButton.js +4 -2
  143. package/lib/cjs/components/select-button/SelectButton.js.map +1 -1
  144. package/lib/cjs/components/setup-wizard/SetupWizard.js +10 -4
  145. package/lib/cjs/components/setup-wizard/SetupWizard.js.map +1 -1
  146. package/lib/cjs/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +5 -3
  147. package/lib/cjs/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -1
  148. package/lib/cjs/components/sharing-bar/SharingBar.js +31 -6
  149. package/lib/cjs/components/sharing-bar/SharingBar.js.map +1 -1
  150. package/lib/cjs/components/sharing-bar/SharingBar.styles.js +5 -0
  151. package/lib/cjs/components/sharing-bar/SharingBar.styles.js.map +1 -1
  152. package/lib/cjs/components/sharing-button/SharingButton.js +4 -2
  153. package/lib/cjs/components/sharing-button/SharingButton.js.map +1 -1
  154. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js +3 -1
  155. package/lib/cjs/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  156. package/lib/cjs/components/signature/Signature.js +6 -3
  157. package/lib/cjs/components/signature/Signature.js.map +1 -1
  158. package/lib/cjs/components/slider/Slider.js +30 -7
  159. package/lib/cjs/components/slider/Slider.js.map +1 -1
  160. package/lib/cjs/components/slider/Slider.styles.js +9 -2
  161. package/lib/cjs/components/slider/Slider.styles.js.map +1 -1
  162. package/lib/cjs/components/slider-button/SliderButton.js +63 -6
  163. package/lib/cjs/components/slider-button/SliderButton.js.map +1 -1
  164. package/lib/cjs/components/slider-button/SliderButton.styles.js +15 -2
  165. package/lib/cjs/components/slider-button/SliderButton.styles.js.map +1 -1
  166. package/lib/cjs/components/slider-button/SliderButton.types.js +6 -0
  167. package/lib/cjs/components/slider-button/SliderButton.types.js.map +1 -0
  168. package/lib/cjs/components/slider-button/useSliderButtonPopupKeyboard.js +66 -0
  169. package/lib/cjs/components/slider-button/useSliderButtonPopupKeyboard.js.map +1 -0
  170. package/lib/cjs/components/slider-button/useSliderButtonThumbKeyboard.js +47 -0
  171. package/lib/cjs/components/slider-button/useSliderButtonThumbKeyboard.js.map +1 -0
  172. package/lib/cjs/components/tag-input/TagInput.js +92 -36
  173. package/lib/cjs/components/tag-input/TagInput.js.map +1 -1
  174. package/lib/cjs/components/tag-input/TagInput.styles.js +29 -3
  175. package/lib/cjs/components/tag-input/TagInput.styles.js.map +1 -1
  176. package/lib/cjs/components/text-area/TextArea.js +17 -8
  177. package/lib/cjs/components/text-area/TextArea.js.map +1 -1
  178. package/lib/cjs/components/text-area/TextArea.styles.js +15 -1
  179. package/lib/cjs/components/text-area/TextArea.styles.js.map +1 -1
  180. package/lib/cjs/components/truncation/Truncation.js +17 -3
  181. package/lib/cjs/components/truncation/Truncation.js.map +1 -1
  182. package/lib/cjs/components/truncation/Truncation.styles.js +18 -1
  183. package/lib/cjs/components/truncation/Truncation.styles.js.map +1 -1
  184. package/lib/cjs/hooks/dropdown.js +40 -11
  185. package/lib/cjs/hooks/dropdown.js.map +1 -1
  186. package/lib/cjs/hooks/useKeyboardFocusHighlighting.js +68 -0
  187. package/lib/cjs/hooks/useKeyboardFocusHighlighting.js.map +1 -0
  188. package/lib/cjs/utils/file.js.map +1 -1
  189. package/lib/cjs/utils/keyboardFocusHighlighting.styles.js +29 -0
  190. package/lib/cjs/utils/keyboardFocusHighlighting.styles.js.map +1 -0
  191. package/lib/esm/components/accordion/Accordion.js +105 -12
  192. package/lib/esm/components/accordion/Accordion.js.map +1 -1
  193. package/lib/esm/components/accordion/Accordion.styles.js +23 -3
  194. package/lib/esm/components/accordion/Accordion.styles.js.map +1 -1
  195. package/lib/esm/components/accordion/accordion-body/AccordionBody.styles.js +3 -1
  196. package/lib/esm/components/accordion/accordion-body/AccordionBody.styles.js.map +1 -1
  197. package/lib/esm/components/accordion/accordion-group/AccordionGroup.js +33 -19
  198. package/lib/esm/components/accordion/accordion-group/AccordionGroup.js.map +1 -1
  199. package/lib/esm/components/accordion/accordion-head/AccordionHead.js +6 -3
  200. package/lib/esm/components/accordion/accordion-head/AccordionHead.js.map +1 -1
  201. package/lib/esm/components/accordion/accordion-head/AccordionHead.styles.js +14 -0
  202. package/lib/esm/components/accordion/accordion-head/AccordionHead.styles.js.map +1 -1
  203. package/lib/esm/components/amount-control/AmountControl.js +30 -16
  204. package/lib/esm/components/amount-control/AmountControl.js.map +1 -1
  205. package/lib/esm/components/amount-control/AmountControl.styles.js +18 -2
  206. package/lib/esm/components/amount-control/AmountControl.styles.js.map +1 -1
  207. package/lib/esm/components/button/Button.js +5 -1
  208. package/lib/esm/components/button/Button.js.map +1 -1
  209. package/lib/esm/components/button/Button.styles.js +10 -0
  210. package/lib/esm/components/button/Button.styles.js.map +1 -1
  211. package/lib/esm/components/button/Button.types.js.map +1 -1
  212. package/lib/esm/components/checkbox/Checkbox.js +5 -1
  213. package/lib/esm/components/checkbox/Checkbox.js.map +1 -1
  214. package/lib/esm/components/checkbox/Checkbox.styles.js +29 -2
  215. package/lib/esm/components/checkbox/Checkbox.styles.js.map +1 -1
  216. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js +7 -2
  217. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.js.map +1 -1
  218. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js +8 -2
  219. package/lib/esm/components/color-scheme-provider/ColorSchemeProvider.styles.js.map +1 -1
  220. package/lib/esm/components/combobox/ComboBox.js +61 -7
  221. package/lib/esm/components/combobox/ComboBox.js.map +1 -1
  222. package/lib/esm/components/combobox/ComboBox.styles.js +11 -0
  223. package/lib/esm/components/combobox/ComboBox.styles.js.map +1 -1
  224. package/lib/esm/components/combobox/ComboBox.types.js.map +1 -1
  225. package/lib/esm/components/context-menu/ContextMenu.js +145 -42
  226. package/lib/esm/components/context-menu/ContextMenu.js.map +1 -1
  227. package/lib/esm/components/context-menu/ContextMenu.styles.js +38 -0
  228. package/lib/esm/components/context-menu/ContextMenu.styles.js.map +1 -1
  229. package/lib/esm/components/context-menu/ContextMenu.types.js.map +1 -1
  230. package/lib/esm/components/context-menu/ContextMenu.utils.js +24 -0
  231. package/lib/esm/components/context-menu/ContextMenu.utils.js.map +1 -1
  232. package/lib/esm/components/context-menu/context-menu-content/ContextMenuContent.js +3 -8
  233. package/lib/esm/components/context-menu/context-menu-content/ContextMenuContent.js.map +1 -1
  234. package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.js +2 -5
  235. package/lib/esm/components/dropdown-body-wrapper/DropdownBodyWrapper.js.map +1 -1
  236. package/lib/esm/components/file-input/FileInput.js +4 -2
  237. package/lib/esm/components/file-input/FileInput.js.map +1 -1
  238. package/lib/esm/components/file-list/file-item/FileItem.js +49 -26
  239. package/lib/esm/components/file-list/file-item/FileItem.js.map +1 -1
  240. package/lib/esm/components/file-list/file-item/FileItem.styles.js +24 -0
  241. package/lib/esm/components/file-list/file-item/FileItem.styles.js.map +1 -1
  242. package/lib/esm/components/file-select/FileSelect.js +27 -4
  243. package/lib/esm/components/file-select/FileSelect.js.map +1 -1
  244. package/lib/esm/components/file-select/FileSelect.styles.js +10 -0
  245. package/lib/esm/components/file-select/FileSelect.styles.js.map +1 -1
  246. package/lib/esm/components/filter/Filter.js +52 -16
  247. package/lib/esm/components/filter/Filter.js.map +1 -1
  248. package/lib/esm/components/filter/Filter.styles.js +9 -0
  249. package/lib/esm/components/filter/Filter.styles.js.map +1 -1
  250. package/lib/esm/components/filter/filter-content/FilterContent.js +15 -5
  251. package/lib/esm/components/filter/filter-content/FilterContent.js.map +1 -1
  252. package/lib/esm/components/filter/filter-content/FilterContent.types.js.map +1 -1
  253. package/lib/esm/components/filter-buttons/FilterButtons.js +69 -5
  254. package/lib/esm/components/filter-buttons/FilterButtons.js.map +1 -1
  255. package/lib/esm/components/filter-buttons/filter-button/FilterButton.js +40 -2
  256. package/lib/esm/components/filter-buttons/filter-button/FilterButton.js.map +1 -1
  257. package/lib/esm/components/filter-buttons/filter-button/FilterButton.styles.js +11 -0
  258. package/lib/esm/components/filter-buttons/filter-button/FilterButton.styles.js.map +1 -1
  259. package/lib/esm/components/grid-image/GridImage.js +20 -2
  260. package/lib/esm/components/grid-image/GridImage.js.map +1 -1
  261. package/lib/esm/components/grid-image/GridImage.styles.js +10 -1
  262. package/lib/esm/components/grid-image/GridImage.styles.js.map +1 -1
  263. package/lib/esm/components/grouped-image/GroupedImage.js +22 -4
  264. package/lib/esm/components/grouped-image/GroupedImage.js.map +1 -1
  265. package/lib/esm/components/grouped-image/GroupedImage.styles.js +9 -0
  266. package/lib/esm/components/grouped-image/GroupedImage.styles.js.map +1 -1
  267. package/lib/esm/components/highlight-slider/HighlightSlider.js +13 -3
  268. package/lib/esm/components/highlight-slider/HighlightSlider.js.map +1 -1
  269. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js +20 -3
  270. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.js.map +1 -1
  271. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js +10 -1
  272. package/lib/esm/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.js.map +1 -1
  273. package/lib/esm/components/icon/Icon.js +26 -7
  274. package/lib/esm/components/icon/Icon.js.map +1 -1
  275. package/lib/esm/components/icon/Icon.styles.js +23 -0
  276. package/lib/esm/components/icon/Icon.styles.js.map +1 -1
  277. package/lib/esm/components/input/Input.js +24 -4
  278. package/lib/esm/components/input/Input.js.map +1 -1
  279. package/lib/esm/components/input/Input.styles.js +38 -3
  280. package/lib/esm/components/input/Input.styles.js.map +1 -1
  281. package/lib/esm/components/list/List.js +123 -37
  282. package/lib/esm/components/list/List.js.map +1 -1
  283. package/lib/esm/components/list/List.utils.js +202 -0
  284. package/lib/esm/components/list/List.utils.js.map +1 -1
  285. package/lib/esm/components/list/list-item/ListItem.js +85 -4
  286. package/lib/esm/components/list/list-item/ListItem.js.map +1 -1
  287. package/lib/esm/components/list/list-item/ListItem.styles.js +7 -0
  288. package/lib/esm/components/list/list-item/ListItem.styles.js.map +1 -1
  289. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js +6 -2
  290. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.js.map +1 -1
  291. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.styles.js +4 -0
  292. package/lib/esm/components/list/list-item/list-item-head/ListItemHead.styles.js.map +1 -1
  293. package/lib/esm/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js +1 -0
  294. package/lib/esm/components/list/list-item/list-item-head/list-item-right-element/ListItemRightElement.js.map +1 -1
  295. package/lib/esm/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js +4 -1
  296. package/lib/esm/components/list/list-item/list-item-head/list-item-subtitle/ListItemSubtitle.js.map +1 -1
  297. package/lib/esm/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js +1 -0
  298. package/lib/esm/components/list/list-item/list-item-head/list-item-title/ListItemTitle.js.map +1 -1
  299. package/lib/esm/components/list/list-item/useListItemFocus.js +40 -0
  300. package/lib/esm/components/list/list-item/useListItemFocus.js.map +1 -0
  301. package/lib/esm/components/mention-finder/MentionFinder.js +39 -3
  302. package/lib/esm/components/mention-finder/MentionFinder.js.map +1 -1
  303. package/lib/esm/components/mention-finder/mention-finder-item/MentionFinderItem.styles.js.map +1 -1
  304. package/lib/esm/components/multi-action-button/MultiActionButton.js +36 -3
  305. package/lib/esm/components/multi-action-button/MultiActionButton.js.map +1 -1
  306. package/lib/esm/components/multi-action-button/MultiActionButton.styles.js +6 -0
  307. package/lib/esm/components/multi-action-button/MultiActionButton.styles.js.map +1 -1
  308. package/lib/esm/components/multi-action-button/MultiActionButton.types.js.map +1 -1
  309. package/lib/esm/components/multi-action-button/action-button/ActionButton.js +7 -1
  310. package/lib/esm/components/multi-action-button/action-button/ActionButton.js.map +1 -1
  311. package/lib/esm/components/multi-action-button/action-button/ActionButton.styles.js +12 -0
  312. package/lib/esm/components/multi-action-button/action-button/ActionButton.styles.js.map +1 -1
  313. package/lib/esm/components/number-input/NumberInput.js +13 -10
  314. package/lib/esm/components/number-input/NumberInput.js.map +1 -1
  315. package/lib/esm/components/page-provider/PageProvider.js +4 -2
  316. package/lib/esm/components/page-provider/PageProvider.js.map +1 -1
  317. package/lib/esm/components/popup/Popup.js +8 -1
  318. package/lib/esm/components/popup/Popup.js.map +1 -1
  319. package/lib/esm/components/radio-button/RadioButton.js +29 -15
  320. package/lib/esm/components/radio-button/RadioButton.js.map +1 -1
  321. package/lib/esm/components/radio-button/RadioButton.styles.js +19 -8
  322. package/lib/esm/components/radio-button/RadioButton.styles.js.map +1 -1
  323. package/lib/esm/components/radio-button/radio-button-group/RadioButtonGroup.js +7 -4
  324. package/lib/esm/components/radio-button/radio-button-group/RadioButtonGroup.js.map +1 -1
  325. package/lib/esm/components/search-box/SearchBox.js +18 -4
  326. package/lib/esm/components/search-box/SearchBox.js.map +1 -1
  327. package/lib/esm/components/search-input/SearchInput.js +56 -44
  328. package/lib/esm/components/search-input/SearchInput.js.map +1 -1
  329. package/lib/esm/components/search-input/SearchInput.styles.js +25 -1
  330. package/lib/esm/components/search-input/SearchInput.styles.js.map +1 -1
  331. package/lib/esm/components/select-button/SelectButton.js +4 -2
  332. package/lib/esm/components/select-button/SelectButton.js.map +1 -1
  333. package/lib/esm/components/setup-wizard/SetupWizard.js +10 -4
  334. package/lib/esm/components/setup-wizard/SetupWizard.js.map +1 -1
  335. package/lib/esm/components/setup-wizard/setup-wizard-item/SetupWizardItem.js +5 -3
  336. package/lib/esm/components/setup-wizard/setup-wizard-item/SetupWizardItem.js.map +1 -1
  337. package/lib/esm/components/sharing-bar/SharingBar.js +30 -5
  338. package/lib/esm/components/sharing-bar/SharingBar.js.map +1 -1
  339. package/lib/esm/components/sharing-bar/SharingBar.styles.js +5 -0
  340. package/lib/esm/components/sharing-bar/SharingBar.styles.js.map +1 -1
  341. package/lib/esm/components/sharing-button/SharingButton.js +4 -2
  342. package/lib/esm/components/sharing-button/SharingButton.js.map +1 -1
  343. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js +3 -1
  344. package/lib/esm/components/sharing-context-menu/SharingContextMenu.js.map +1 -1
  345. package/lib/esm/components/signature/Signature.js +6 -3
  346. package/lib/esm/components/signature/Signature.js.map +1 -1
  347. package/lib/esm/components/slider/Slider.js +30 -7
  348. package/lib/esm/components/slider/Slider.js.map +1 -1
  349. package/lib/esm/components/slider/Slider.styles.js +8 -1
  350. package/lib/esm/components/slider/Slider.styles.js.map +1 -1
  351. package/lib/esm/components/slider-button/SliderButton.js +62 -6
  352. package/lib/esm/components/slider-button/SliderButton.js.map +1 -1
  353. package/lib/esm/components/slider-button/SliderButton.styles.js +14 -1
  354. package/lib/esm/components/slider-button/SliderButton.styles.js.map +1 -1
  355. package/lib/esm/components/slider-button/SliderButton.types.js +2 -0
  356. package/lib/esm/components/slider-button/SliderButton.types.js.map +1 -0
  357. package/lib/esm/components/slider-button/useSliderButtonPopupKeyboard.js +56 -0
  358. package/lib/esm/components/slider-button/useSliderButtonPopupKeyboard.js.map +1 -0
  359. package/lib/esm/components/slider-button/useSliderButtonThumbKeyboard.js +38 -0
  360. package/lib/esm/components/slider-button/useSliderButtonThumbKeyboard.js.map +1 -0
  361. package/lib/esm/components/tag-input/TagInput.js +86 -35
  362. package/lib/esm/components/tag-input/TagInput.js.map +1 -1
  363. package/lib/esm/components/tag-input/TagInput.styles.js +27 -1
  364. package/lib/esm/components/tag-input/TagInput.styles.js.map +1 -1
  365. package/lib/esm/components/text-area/TextArea.js +18 -9
  366. package/lib/esm/components/text-area/TextArea.js.map +1 -1
  367. package/lib/esm/components/text-area/TextArea.styles.js +14 -0
  368. package/lib/esm/components/text-area/TextArea.styles.js.map +1 -1
  369. package/lib/esm/components/truncation/Truncation.js +18 -4
  370. package/lib/esm/components/truncation/Truncation.js.map +1 -1
  371. package/lib/esm/components/truncation/Truncation.styles.js +17 -0
  372. package/lib/esm/components/truncation/Truncation.styles.js.map +1 -1
  373. package/lib/esm/hooks/dropdown.js +41 -12
  374. package/lib/esm/hooks/dropdown.js.map +1 -1
  375. package/lib/esm/hooks/useKeyboardFocusHighlighting.js +61 -0
  376. package/lib/esm/hooks/useKeyboardFocusHighlighting.js.map +1 -0
  377. package/lib/esm/utils/file.js.map +1 -1
  378. package/lib/esm/utils/keyboardFocusHighlighting.styles.js +24 -0
  379. package/lib/esm/utils/keyboardFocusHighlighting.styles.js.map +1 -0
  380. package/lib/types/components/accordion/Accordion.d.ts +5 -0
  381. package/lib/types/components/accordion/Accordion.styles.d.ts +8 -4
  382. package/lib/types/components/accordion/accordion-body/AccordionBody.styles.d.ts +2 -2
  383. package/lib/types/components/accordion/accordion-group/AccordionGroup.d.ts +7 -2
  384. package/lib/types/components/accordion/accordion-head/AccordionHead.d.ts +1 -0
  385. package/lib/types/components/accordion/accordion-head/AccordionHead.styles.d.ts +18 -18
  386. package/lib/types/components/amount-control/AmountControl.d.ts +5 -0
  387. package/lib/types/components/amount-control/AmountControl.styles.d.ts +8 -4
  388. package/lib/types/components/button/Button.styles.d.ts +8 -6
  389. package/lib/types/components/button/Button.types.d.ts +8 -0
  390. package/lib/types/components/checkbox/Checkbox.d.ts +4 -0
  391. package/lib/types/components/checkbox/Checkbox.styles.d.ts +5 -1
  392. package/lib/types/components/color-scheme-provider/ColorSchemeProvider.d.ts +5 -0
  393. package/lib/types/components/combobox/ComboBox.styles.d.ts +4 -2
  394. package/lib/types/components/combobox/ComboBox.types.d.ts +5 -0
  395. package/lib/types/components/context-menu/ContextMenu.styles.d.ts +4 -2
  396. package/lib/types/components/context-menu/ContextMenu.types.d.ts +6 -0
  397. package/lib/types/components/context-menu/ContextMenu.utils.d.ts +10 -0
  398. package/lib/types/components/context-menu/context-menu-content/ContextMenuContent.d.ts +1 -1
  399. package/lib/types/components/context-menu/context-menu-content/ContextMenuContent.styles.d.ts +2 -2
  400. package/lib/types/components/dropdown-body-wrapper/delayed-dropdown-content/DelayedDropdownContent.styles.d.ts +2 -2
  401. package/lib/types/components/expandable-content/ExpandableContent.styles.d.ts +2 -2
  402. package/lib/types/components/file-input/FileInput.d.ts +4 -0
  403. package/lib/types/components/file-input/FileInput.styles.d.ts +2 -2
  404. package/lib/types/components/file-list/file-item/FileItem.styles.d.ts +3 -0
  405. package/lib/types/components/file-select/FileSelect.d.ts +4 -0
  406. package/lib/types/components/file-select/FileSelect.styles.d.ts +6 -4
  407. package/lib/types/components/filter/Filter.d.ts +1 -0
  408. package/lib/types/components/filter/Filter.styles.d.ts +6 -4
  409. package/lib/types/components/filter/filter-content/FilterContent.types.d.ts +4 -0
  410. package/lib/types/components/filter-buttons/FilterButtons.d.ts +4 -0
  411. package/lib/types/components/filter-buttons/filter-button/FilterButton.d.ts +5 -0
  412. package/lib/types/components/filter-buttons/filter-button/FilterButton.styles.d.ts +12 -8
  413. package/lib/types/components/grid-image/GridImage.d.ts +4 -0
  414. package/lib/types/components/grid-image/GridImage.styles.d.ts +4 -2
  415. package/lib/types/components/grouped-image/GroupedImage.d.ts +4 -0
  416. package/lib/types/components/grouped-image/GroupedImage.styles.d.ts +8 -6
  417. package/lib/types/components/highlight-slider/HighlightSlider.d.ts +4 -0
  418. package/lib/types/components/highlight-slider/highlight-slider-item/HighlightSliderItem.d.ts +3 -0
  419. package/lib/types/components/highlight-slider/highlight-slider-item/HighlightSliderItem.styles.d.ts +9 -5
  420. package/lib/types/components/icon/Icon.d.ts +4 -0
  421. package/lib/types/components/icon/Icon.styles.d.ts +1 -0
  422. package/lib/types/components/input/Input.d.ts +4 -0
  423. package/lib/types/components/input/Input.styles.d.ts +17 -9
  424. package/lib/types/components/list/List.d.ts +11 -0
  425. package/lib/types/components/list/List.utils.d.ts +32 -1
  426. package/lib/types/components/list/list-item/ListItem.d.ts +4 -0
  427. package/lib/types/components/list/list-item/ListItem.styles.d.ts +64 -64
  428. package/lib/types/components/list/list-item/list-item-body/ListItemBody.styles.d.ts +2 -2
  429. package/lib/types/components/list/list-item/list-item-head/ListItemHead.styles.d.ts +195 -194
  430. package/lib/types/components/list/list-item/useListItemFocus.d.ts +13 -0
  431. package/lib/types/components/masonry/masonry-item/MasonryItem.styles.d.ts +2 -2
  432. package/lib/types/components/mention-finder/MentionFinder.styles.d.ts +4 -4
  433. package/lib/types/components/multi-action-button/MultiActionButton.styles.d.ts +2 -2
  434. package/lib/types/components/multi-action-button/MultiActionButton.types.d.ts +7 -0
  435. package/lib/types/components/multi-action-button/action-button/ActionButton.d.ts +4 -1
  436. package/lib/types/components/multi-action-button/action-button/ActionButton.styles.d.ts +4 -2
  437. package/lib/types/components/number-input/NumberInput.d.ts +4 -0
  438. package/lib/types/components/popup/popup-content-wrapper/PopupContentWrapper.styles.d.ts +2 -2
  439. package/lib/types/components/progress-bar/ProgressBar.styles.d.ts +6 -6
  440. package/lib/types/components/radio-button/RadioButton.d.ts +4 -0
  441. package/lib/types/components/radio-button/RadioButton.styles.d.ts +15 -9
  442. package/lib/types/components/radio-button/radio-button-group/RadioButtonGroup.d.ts +5 -0
  443. package/lib/types/components/search-box/SearchBox.d.ts +4 -0
  444. package/lib/types/components/search-box/SearchBox.styles.d.ts +2 -2
  445. package/lib/types/components/search-input/SearchInput.d.ts +4 -0
  446. package/lib/types/components/search-input/SearchInput.styles.d.ts +17 -9
  447. package/lib/types/components/select-button/SelectButton.d.ts +4 -0
  448. package/lib/types/components/setup-wizard/SetupWizard.d.ts +5 -0
  449. package/lib/types/components/sharing-bar/SharingBar.d.ts +4 -0
  450. package/lib/types/components/sharing-button/SharingButton.d.ts +1 -1
  451. package/lib/types/components/sharing-context-menu/SharingContextMenu.d.ts +10 -2
  452. package/lib/types/components/signature/Signature.d.ts +4 -0
  453. package/lib/types/components/skeleton/base-skeleton/BaseSkeleton.styles.d.ts +4 -4
  454. package/lib/types/components/slider/Slider.d.ts +8 -0
  455. package/lib/types/components/slider/Slider.styles.d.ts +18 -14
  456. package/lib/types/components/slider-button/SliderButton.d.ts +1 -28
  457. package/lib/types/components/slider-button/SliderButton.styles.d.ts +6 -4
  458. package/lib/types/components/slider-button/SliderButton.types.d.ts +32 -0
  459. package/lib/types/components/slider-button/useSliderButtonPopupKeyboard.d.ts +17 -0
  460. package/lib/types/components/slider-button/useSliderButtonThumbKeyboard.d.ts +13 -0
  461. package/lib/types/components/tag-input/TagInput.d.ts +4 -0
  462. package/lib/types/components/tag-input/TagInput.styles.d.ts +12 -2
  463. package/lib/types/components/text-area/TextArea.d.ts +4 -0
  464. package/lib/types/components/text-area/TextArea.styles.d.ts +1 -0
  465. package/lib/types/components/truncation/Truncation.d.ts +4 -0
  466. package/lib/types/components/truncation/Truncation.styles.d.ts +7 -2
  467. package/lib/types/hooks/useKeyboardFocusHighlighting.d.ts +5 -0
  468. package/lib/types/utils/file.d.ts +1 -1
  469. package/lib/types/utils/keyboardFocusHighlighting.styles.d.ts +9 -0
  470. package/package.json +3 -3
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyledTruncationPseudoContent = exports.StyledTruncationClampWrapper = exports.StyledTruncationClamp = exports.StyledTruncation = exports.StyledMotionTruncationContent = void 0;
6
+ exports.StyledTruncationPseudoContent = exports.StyledTruncationClampWrapper = exports.StyledTruncationClampFocusWrapper = exports.StyledTruncationClamp = exports.StyledTruncation = exports.StyledMotionTruncationContent = void 0;
7
7
  var _react = require("motion/react");
8
8
  var _styledComponents = _interopRequireWildcard(require("styled-components"));
9
9
  var _truncation = require("../../types/truncation");
10
+ var _keyboardFocusHighlighting = require("../../utils/keyboardFocusHighlighting.styles");
10
11
  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); }
11
12
  const StyledTruncation = exports.StyledTruncation = _styledComponents.default.div`
12
13
  position: relative;
@@ -45,8 +46,24 @@ const StyledTruncationClampWrapper = exports.StyledTruncationClampWrapper = _sty
45
46
  }
46
47
  }}
47
48
  `;
49
+ const StyledTruncationClampFocusWrapper = exports.StyledTruncationClampFocusWrapper = _styledComponents.default.div`
50
+ display: inline-block;
51
+ border-radius: 3px;
52
+
53
+ ${({
54
+ $shouldShowKeyboardHighlighting
55
+ }) => $shouldShowKeyboardHighlighting && (0, _styledComponents.css)`
56
+ &:focus-within {
57
+ transition: none;
58
+ ${_keyboardFocusHighlighting.keyboardFocusHighlightingRingCss};
59
+ color: inherit;
60
+ }
61
+ `}
62
+ `;
48
63
  const StyledTruncationClamp = exports.StyledTruncationClamp = _styledComponents.default.a`
49
64
  cursor: pointer;
50
65
  z-index: 2;
66
+ display: inline-block;
67
+ line-height: 1.2;
51
68
  `;
52
69
  //# sourceMappingURL=Truncation.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Truncation.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_truncation","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledTruncation","exports","styled","div","StyledMotionTruncationContent","motion","StyledTruncationPseudoContent","StyledTruncationClampWrapper","$position","ClampPosition","Left","css","Middle","StyledTruncationClamp","a"],"sources":["../../../../src/components/truncation/Truncation.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { ClampPosition } from '../../types/truncation';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\n\nexport const StyledTruncation = styled.div`\n position: relative;\n overflow: hidden;\n`;\n\n// Fix framer-motion bug\nexport const StyledMotionTruncationContent = styled(motion.div)`\n overflow: hidden;\n position: relative;\n`;\n\nexport const StyledTruncationPseudoContent = styled.div`\n visibility: hidden;\n position: absolute;\n width: 100%;\n`;\n\ntype StyledTruncationClampWrapperProps = WithTheme<{ $position: ClampPosition }>;\n\nexport const StyledTruncationClampWrapper = styled.div<StyledTruncationClampWrapperProps>`\n display: flex;\n\n ${({ $position }) => {\n switch ($position) {\n case ClampPosition.Left:\n return css`\n justify-content: left;\n `;\n case ClampPosition.Middle:\n return css`\n justify-content: center;\n `;\n default:\n return css`\n justify-content: right;\n `;\n }\n }}\n`;\n\nexport const StyledTruncationClamp = styled.a`\n cursor: pointer;\n z-index: 2;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAC,uBAAA,CAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAAuD,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,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAGhD,MAAMkB,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAGE,yBAAM,CAACC,GAAG;AAC1C;AACA;AACA,CAAC;;AAED;AACO,MAAMC,6BAA6B,GAAAH,OAAA,CAAAG,6BAAA,GAAG,IAAAF,yBAAM,EAACG,aAAM,CAACF,GAAG,CAAC;AAC/D;AACA;AACA,CAAC;AAEM,MAAMG,6BAA6B,GAAAL,OAAA,CAAAK,6BAAA,GAAGJ,yBAAM,CAACC,GAAG;AACvD;AACA;AACA;AACA,CAAC;AAIM,MAAMI,4BAA4B,GAAAN,OAAA,CAAAM,4BAAA,GAAGL,yBAAM,CAACC,GAAsC;AACzF;AACA;AACA,MAAM,CAAC;EAAEK;AAAU,CAAC,KAAK;EACjB,QAAQA,SAAS;IACb,KAAKC,yBAAa,CAACC,IAAI;MACnB,OAAO,IAAAC,qBAAG;AAC1B;AACA,iBAAiB;IACL,KAAKF,yBAAa,CAACG,MAAM;MACrB,OAAO,IAAAD,qBAAG;AAC1B;AACA,iBAAiB;IACL;MACI,OAAO,IAAAA,qBAAG;AAC1B;AACA,iBAAiB;EACT;AACJ,CAAC;AACL,CAAC;AAEM,MAAME,qBAAqB,GAAAZ,OAAA,CAAAY,qBAAA,GAAGX,yBAAM,CAACY,CAAC;AAC7C;AACA;AACA,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"Truncation.styles.js","names":["_react","require","_styledComponents","_interopRequireWildcard","_truncation","_keyboardFocusHighlighting","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","StyledTruncation","exports","styled","div","StyledMotionTruncationContent","motion","StyledTruncationPseudoContent","StyledTruncationClampWrapper","$position","ClampPosition","Left","css","Middle","StyledTruncationClampFocusWrapper","$shouldShowKeyboardHighlighting","keyboardFocusHighlightingRingCss","StyledTruncationClamp","a"],"sources":["../../../../src/components/truncation/Truncation.styles.ts"],"sourcesContent":["import { motion } from 'motion/react';\nimport styled, { css } from 'styled-components';\nimport { ClampPosition } from '../../types/truncation';\nimport type { WithTheme } from '../color-scheme-provider/ColorSchemeProvider';\nimport { keyboardFocusHighlightingRingCss } from '../../utils/keyboardFocusHighlighting.styles';\n\nexport const StyledTruncation = styled.div`\n position: relative;\n overflow: hidden;\n`;\n\n// Fix framer-motion bug\nexport const StyledMotionTruncationContent = styled(motion.div)`\n overflow: hidden;\n position: relative;\n`;\n\nexport const StyledTruncationPseudoContent = styled.div`\n visibility: hidden;\n position: absolute;\n width: 100%;\n`;\n\ntype StyledTruncationClampWrapperProps = WithTheme<{ $position: ClampPosition }>;\n\nexport const StyledTruncationClampWrapper = styled.div<StyledTruncationClampWrapperProps>`\n display: flex;\n\n ${({ $position }) => {\n switch ($position) {\n case ClampPosition.Left:\n return css`\n justify-content: left;\n `;\n case ClampPosition.Middle:\n return css`\n justify-content: center;\n `;\n default:\n return css`\n justify-content: right;\n `;\n }\n }}\n`;\n\ntype StyledTruncationClampProps = {\n $shouldShowKeyboardHighlighting: boolean;\n};\n\nexport const StyledTruncationClampFocusWrapper = styled.div<StyledTruncationClampProps>`\n display: inline-block;\n border-radius: 3px;\n\n ${({ $shouldShowKeyboardHighlighting }) =>\n $shouldShowKeyboardHighlighting &&\n css`\n &:focus-within {\n transition: none;\n ${keyboardFocusHighlightingRingCss};\n color: inherit;\n }\n `}\n`;\n\nexport const StyledTruncationClamp = styled.a`\n cursor: point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G;AAC1C;AACA;AACA,CAAC;;AAED;AACO,MAAMC,6BAA6B,GAAAH,OAAA,CAAAG,6BAAA,GAAG,IAAAF,yBAAM,EAACG,aAAM,CAACF,GAAG,CAAC;AAC/D;AACA;AACA,CAAC;AAEM,MAAMG,6BAA6B,GAAAL,OAAA,CAAAK,6BAAA,GAAGJ,yBAAM,CAACC,GAAG;AACvD;AACA;AACA;AACA,CAAC;AAIM,MAAMI,4BAA4B,GAAAN,OAAA,CAAAM,4BAAA,GAAGL,yBAAM,CAACC,GAAsC;AACzF;AACA;AACA,MAAM,CAAC;EAAEK;AAAU,CAAC,KAAK;EACjB,QAAQA,SAAS;IACb,KAAKC,yBAAa,CAACC,IAAI;MACnB,OAAO,IAAAC,qBAAG;AAC1B;AACA,iBAAiB;IACL,KAAKF,yBAAa,CAACG,MAAM;MACrB,OAAO,IAAAD,qBAAG;AAC1B;AACA,iBAAiB;IACL;MACI,OAAO,IAAAA,qBAAG;AAC1B;AACA,iBAAiB;EACT;AACJ,CAAC;AACL,CAAC;AAMM,MAAME,iCAAiC,GAAAZ,OAAA,CAAAY,iCAAA,GAAGX,yBAAM,CAACC,GAA+B;AACvF;AACA;AACA;AACA,MAAM,CAAC;EAAEW;AAAgC,CAAC,KAClCA,+BAA+B,IAC/B,IAAAH,qBAAG;AACX;AACA;AACA,kBAAkBI,2DAAgC;AAClD;AACA;AACA,SAAS;AACT,CAAC;AAEM,MAAMC,qBAAqB,GAAAf,OAAA,CAAAe,qBAAA,GAAGd,yBAAM,CAACe,CAAC;AAC7C;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -76,7 +76,22 @@ const useDropdownPosition = ({
76
76
  });
77
77
  const [shouldUseTopAlignment, setShouldUseTopAlignment] = (0, _react.useState)(false);
78
78
  const [availableMaxHeight, setAvailableMaxHeight] = (0, _react.useState)(0);
79
+
80
+ // Stores the alignment decision (top/bottom) that was made when the dropdown opened. The
81
+ // decision depends on the content height, but the content height in turn is limited by the
82
+ // available height (which depends on the alignment). Recalculating the alignment on every
83
+ // change would create a feedback loop that makes the alignment flip and the height oscillate.
84
+ // We therefore lock the alignment while the dropdown stays open and reset it on close.
85
+ const lockedTopAlignmentRef = (0, _react.useRef)(null);
79
86
  const calculateCoordinates = (0, _react.useCallback)(() => {
87
+ // While the dropdown is closing (or closed) we must not recalculate the position and the
88
+ // available height. Otherwise layout changes underneath the dropdown (e.g. content that
89
+ // appears after a selection) would move or resize the dropdown body while it is still fading
90
+ // out, causing it to visibly jump. Freezing the last calculated values keeps the closing
91
+ // animation stable.
92
+ if (!shouldShowDropdown) {
93
+ return;
94
+ }
80
95
  if (container) {
81
96
  const {
82
97
  left: anchorLeft,
@@ -92,33 +107,47 @@ const useDropdownPosition = ({
92
107
  const y = anchorTop - top + container.scrollTop;
93
108
  let useTopAlignment = [_dropdown.DropdownDirection.TOP, _dropdown.DropdownDirection.TOP_LEFT, _dropdown.DropdownDirection.TOP_RIGHT].includes(direction);
94
109
  const hasBottomAlignment = [_dropdown.DropdownDirection.BOTTOM, _dropdown.DropdownDirection.BOTTOM_LEFT, _dropdown.DropdownDirection.BOTTOM_RIGHT].includes(direction);
95
- if (!hasBottomAlignment && y + anchorHeight + contentHeight > height) {
96
- useTopAlignment = true;
97
- setShouldUseTopAlignment(true);
98
- } else {
99
- setShouldUseTopAlignment(false);
110
+
111
+ // The available space above and below the anchor within the container.
112
+ const spaceToTop = y;
113
+ const spaceToBottom = height - (y + anchorHeight);
114
+ if (lockedTopAlignmentRef.current !== null) {
115
+ // Keep the alignment that was decided when the dropdown opened.
116
+ useTopAlignment = lockedTopAlignmentRef.current;
117
+ } else if (!hasBottomAlignment && y + anchorHeight + contentHeight > height) {
118
+ // The content does not fit below the anchor. Only flip to the top when there is
119
+ // actually more space above than below. Otherwise the content would be cut off less
120
+ // when opened downwards (the content is limited to the available height anyway), so
121
+ // we keep the downward alignment. This avoids opening upwards for a content that,
122
+ // once limited to the available space, would fit below just fine.
123
+ useTopAlignment = spaceToTop > spaceToBottom;
100
124
  }
125
+ lockedTopAlignmentRef.current = useTopAlignment;
126
+ setShouldUseTopAlignment(useTopAlignment);
101
127
 
102
128
  // Calculate the space that is available for the dropdown content. When the dropdown is
103
129
  // opened to the top, the available space reaches from the anchor to the top edge of the
104
130
  // container. When it is opened to the bottom, it reaches from the bottom of the anchor
105
131
  // to the bottom edge of the container. A small spacing is subtracted so the content does
106
132
  // not touch the container edge (e.g. to leave room for shadows).
107
- const spaceToTop = y;
108
- const spaceToBottom = height - (y + anchorHeight);
133
+
109
134
  const nextAvailableMaxHeight = Math.max(Math.round((useTopAlignment ? spaceToTop : spaceToBottom) - AVAILABLE_HEIGHT_SPACING), 0);
110
135
 
111
- // Only update the available max height when it changes by more than one pixel. This
112
- // prevents subpixel fluctuations of getBoundingClientRect from repeatedly triggering
113
- // re-renders of the consumer, which could otherwise cause a layout shift loop.
136
+ // Ignore sub-pixel fluctuations so tiny changes from getBoundingClientRect do not
137
+ // repeatedly trigger re-renders that could keep the height oscillating.
114
138
  setAvailableMaxHeight(currentAvailableMaxHeight => Math.abs(currentAvailableMaxHeight - nextAvailableMaxHeight) <= 1 ? currentAvailableMaxHeight : nextAvailableMaxHeight);
115
139
  setCoordinates({
116
140
  x,
117
141
  y: useTopAlignment ? y : y + anchorHeight
118
142
  });
119
143
  }
120
- }, [anchorElement, container, contentHeight, direction]);
144
+ }, [anchorElement, container, contentHeight, direction, shouldShowDropdown]);
121
145
  useIsomorphicLayoutEffect(() => {
146
+ // Reset the locked alignment whenever the dropdown is closed, so the next time it opens the
147
+ // alignment (top/bottom) is decided freshly based on the then-available space.
148
+ if (!shouldShowDropdown) {
149
+ lockedTopAlignmentRef.current = null;
150
+ }
122
151
  const handleResize = () => {
123
152
  calculateCoordinates();
124
153
  setTimeout(calculateCoordinates, 300);
@@ -1 +1 @@
1
- {"version":3,"file":"dropdown.js","names":["_react","require","_dropdown","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","useDropdownListener","onClick","onClose","onTouchEnd","onTouchStart","shouldCaptureEvents","document","addEventListener","removeEventListener","exports","useDropdownAlignment","anchorElement","contentWidth","direction","shouldUseTopAlignment","translateX","setTranslateX","useState","translateY","setTranslateY","DropdownDirection","BOTTOM_LEFT","TOP_LEFT","LEFT","includes","difference","clientWidth","useTopAlignment","TOP","TOP_RIGHT","useMemo","x","y","AVAILABLE_HEIGHT_SPACING","useDropdownPosition","container","contentHeight","shouldShowDropdown","coordinates","setCoordinates","setShouldUseTopAlignment","availableMaxHeight","setAvailableMaxHeight","calculateCoordinates","useCallback","left","anchorLeft","top","anchorTop","height","anchorHeight","getBoundingClientRect","scrollLeft","scrollTop","hasBottomAlignment","BOTTOM","BOTTOM_RIGHT","spaceToTop","spaceToBottom","nextAvailableMaxHeight","Math","max","round","currentAvailableMaxHeight","abs","handleResize","setTimeout","useDropdown","transform","width"],"sources":["../../../src/hooks/dropdown.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useMemo, useState } from 'react';\nimport { DropdownCoordinates, DropdownDirection } from '../types/dropdown';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\ninterface UseDropdownListenerOptions {\n onClick: (event: MouseEvent) => void;\n onClose: () => void;\n onTouchEnd: (event: TouchEvent) => void;\n onTouchStart: (event: TouchEvent) => void;\n shouldCaptureEvents?: boolean;\n}\n\nexport const useDropdownListener = ({\n onClick,\n onClose,\n onTouchEnd,\n onTouchStart,\n shouldCaptureEvents,\n}: UseDropdownListenerOptions) => {\n useEffect(() => {\n document.addEventListener('click', onClick, shouldCaptureEvents);\n document.addEventListener('touchend', onTouchEnd, shouldCaptureEvents);\n document.addEventListener('touchstart', onTouchStart, shouldCaptureEvents);\n\n window.addEventListener('blur', onClose);\n\n return () => {\n document.removeEventListener('click', onClick, shouldCaptureEvents);\n document.removeEventListener('touchend', onTouchEnd, shouldCaptureEvents);\n document.removeEventListener('touchstart', onTouchStart, shouldCaptureEvents);\n\n window.removeEventListener('blur', onClose);\n };\n }, [onClick, onClose, onTouchEnd, onTouchStart]);\n};\n\ninterface UseDropdownAlignmentOptions {\n direction: DropdownDirection;\n shouldUseTopAlignment: boolean;\n contentWidth: number;\n anchorElement: Element;\n}\n\nexport const useDropdownAlignment = ({\n anchorElement,\n contentWidth,\n direction,\n shouldUseTopAlignment,\n}: UseDropdownAlignmentOptions) => {\n const [translateX, setTranslateX] = useState<string>('0px');\n const [translateY, setTranslateY] = useState<string>('0px');\n\n useEffect(() => {\n if (\n [\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.TOP_LEFT,\n DropdownDirection.LEFT,\n ].includes(direction)\n ) {\n const difference = anchorElement.clientWidth - contentWidth;\n\n setTranslateX(`${difference}px`);\n } else {\n setTranslateX('0px');\n }\n }, [anchorElement.clientWidth, contentWidth, direction]);\n\n useEffect(() => {\n const useTopAlignment =\n shouldUseTopAlignment ||\n [\n DropdownDirection.TOP,\n DropdownDirection.TOP_LEFT,\n DropdownDirection.TOP_RIGHT,\n ].includes(direction);\n\n if (useTopAlignment) {\n setTranslateY('-100%');\n } else {\n setTranslateY('0px');\n }\n }, [direction, shouldUseTopAlignment]);\n\n return useMemo(() => ({ x: translateX, y: translateY }), [translateX, translateY]);\n};\n\ninterface UseDropdownPositionOptions {\n anchorElement: Element;\n container?: Element;\n contentHeight?: number;\n direction: DropdownDirection;\n shouldShowDropdown: boolean;\n}\n\n/**\n * The space (in pixels) that should be kept between the dropdown content and the edge of the\n * container when calculating the available maximum height.\n */\nconst AVAILABLE_HEIGHT_SPACING = 16;\n\nexport const useDropdownPosition = ({\n anchorElement,\n container,\n contentHeight = 0,\n direction,\n shouldShowDropdown,\n}: UseDropdownPositionOptions) => {\n const [coordinates, setCoordinates] = useState<DropdownCoordinates>({ x: 0, y: 0 });\n const [shouldUseTopAlignment, setShouldUseTopAlignment] = useState(false);\n const [availableMaxHeight, setAvailableMaxHeight] = useState<number>(0);\n\n const calculateCoordinates = useCallback(() => {\n if (container) {\n const {\n left: anchorLeft,\n top: anchorTop,\n height: anchorHeight,\n } = anchorElement.getBoundingClientRect();\n\n const { left, top, height } = container.getBoundingClientRect();\n\n const x = anchorLeft - left + container.scrollLeft;\n const y = anchorTop - top + container.scrollTop;\n\n let useTopAlignment = [\n DropdownDirection.TOP,\n DropdownDirection.TOP_LEFT,\n DropdownDirection.TOP_RIGHT,\n ].includes(direction);\n\n const hasBottomAlignment = [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes(direction);\n\n if (!hasBottomAlignment && y + anchorHeight + contentHeight > height) {\n useTopAlignment = true;\n\n setShouldUseTopAlignment(true);\n } else {\n setShouldUseTopAlignment(false);\n }\n\n // Calculate the space that is available for the dropdown content. When the dropdown is\n // opened to the top, the available space reaches from the anchor to the top edge of the\n // container. When it is opened to the bottom, it reaches from the bottom of the anchor\n // to the bottom edge of the container. A small spacing is subtracted so the content does\n // not touch the container edge (e.g. to leave room for shadows).\n const spaceToTop = y;\n const spaceToBottom = height - (y + anchorHeight);\n\n const nextAvailableMaxHeight = Math.max(\n Math.round(\n (useTopAlignment ? spaceToTop : spaceToBottom) - AVAILABLE_HEIGHT_SPACING,\n ),\n 0,\n );\n\n // Only update the available max height when it changes by more than one pixel. This\n // prevents subpixel fluctuations of getBoundingClientRect from repeatedly triggering\n // re-renders of the consumer, which could otherwise cause a layout shift loop.\n setAvailableMaxHeight((currentAvailableMaxHeight) =>\n Math.abs(currentAvailableMaxHeight - nextAvailableMaxHeight) <= 1\n ? currentAvailableMaxHeight\n : nextAvailableMaxHeight,\n );\n\n setCoordinates({ x, y: useTopAlignment ? y : y + anchorHeight });\n }\n }, [anchorElement, container, contentHeight, direction]);\n\n useIsomorphicLayoutEffect(() => {\n const handleResize = () => {\n calculateCoordinates();\n\n setTimeout(calculateCoordinates, 300);\n };\n\n handleResize();\n\n if (shouldShowDropdown) {\n window.addEventListener('resize', handleResize);\n }\n\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n }, [calculateCoordinates, shouldShowDropdown]);\n\n return useMemo(\n () => ({ shouldUseTopAlignment, coordinates, availableMaxHeight }),\n [availableMaxHeight, coordinates, shouldUseTopAlignment],\n );\n};\n\ninterface UseDropdownOptions {\n anchorElement: Element;\n container?: Element;\n contentHeight?: number;\n contentWidth: number;\n direction: DropdownDirection;\n shouldShowDropdown: boolean;\n}\n\nexport const useDropdown = ({\n anchorElement,\n container,\n contentHeight,\n contentWidth,\n direction,\n shouldShowDropdown,\n}: UseDropdownOptions) => {\n const { shouldUseTopAlignment, coordinates, availableMaxHeight } = useDropdownPosition({\n anchorElement,\n container,\n contentHeight,\n direction,\n shouldShowDropdown,\n });\n\n const transform = useDropdownAlignment({\n anchorElement,\n contentWidth,\n direction,\n shouldUseTopAlignment,\n });\n\n const width = anchorElement.clientWidth;\n\n return useMemo(\n () => ({ coordinates, transform, width, availableMaxHeight }),\n [availableMaxHeight, coordinates, transform, width],\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,MAAME,yBAAyB,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGC,sBAAe,GAAGC,gBAAS;AAUtF,MAAMC,mBAAmB,GAAGA,CAAC;EAChCC,OAAO;EACPC,OAAO;EACPC,UAAU;EACVC,YAAY;EACZC;AACwB,CAAC,KAAK;EAC9B,IAAAN,gBAAS,EAAC,MAAM;IACZO,QAAQ,CAACC,gBAAgB,CAAC,OAAO,EAAEN,OAAO,EAAEI,mBAAmB,CAAC;IAChEC,QAAQ,CAACC,gBAAgB,CAAC,UAAU,EAAEJ,UAAU,EAAEE,mBAAmB,CAAC;IACtEC,QAAQ,CAACC,gBAAgB,CAAC,YAAY,EAAEH,YAAY,EAAEC,mBAAmB,CAAC;IAE1ER,MAAM,CAACU,gBAAgB,CAAC,MAAM,EAAEL,OAAO,CAAC;IAExC,OAAO,MAAM;MACTI,QAAQ,CAACE,mB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AAE8B,SAAS;IAAEC,KAAK;IAAE5B;EAAmB,CAAC,CAAC,EAC7D,CAACA,kBAAkB,EAAEH,WAAW,EAAE8B,SAAS,EAAEC,KAAK,CACtD,CAAC;AACL,CAAC;AAAC5D,OAAA,CAAA0D,WAAA,GAAAA,WAAA","ignoreList":[]}
1
+ {"version":3,"file":"dropdown.js","names":["_react","require","_dropdown","useIsomorphicLayoutEffect","window","useLayoutEffect","useEffect","useDropdownListener","onClick","onClose","onTouchEnd","onTouchStart","shouldCaptureEvents","document","addEventListener","removeEventListener","exports","useDropdownAlignment","anchorElement","contentWidth","direction","shouldUseTopAlignment","translateX","setTranslateX","useState","translateY","setTranslateY","DropdownDirection","BOTTOM_LEFT","TOP_LEFT","LEFT","includes","difference","clientWidth","useTopAlignment","TOP","TOP_RIGHT","useMemo","x","y","AVAILABLE_HEIGHT_SPACING","useDropdownPosition","container","contentHeight","shouldShowDropdown","coordinates","setCoordinates","setShouldUseTopAlignment","availableMaxHeight","setAvailableMaxHeight","lockedTopAlignmentRef","useRef","calculateCoordinates","useCallback","left","anchorLeft","top","anchorTop","height","anchorHeight","getBoundingClientRect","scrollLeft","scrollTop","hasBottomAlignment","BOTTOM","BOTTOM_RIGHT","spaceToTop","spaceToBottom","current","nextAvailableMaxHeight","Math","max","round","currentAvailableMaxHeight","abs","handleResize","setTimeout","useDropdown","transform","width"],"sources":["../../../src/hooks/dropdown.ts"],"sourcesContent":["import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react';\nimport { DropdownCoordinates, DropdownDirection } from '../types/dropdown';\n\nconst useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;\n\ninterface UseDropdownListenerOptions {\n onClick: (event: MouseEvent) => void;\n onClose: () => void;\n onTouchEnd: (event: TouchEvent) => void;\n onTouchStart: (event: TouchEvent) => void;\n shouldCaptureEvents?: boolean;\n}\n\nexport const useDropdownListener = ({\n onClick,\n onClose,\n onTouchEnd,\n onTouchStart,\n shouldCaptureEvents,\n}: UseDropdownListenerOptions) => {\n useEffect(() => {\n document.addEventListener('click', onClick, shouldCaptureEvents);\n document.addEventListener('touchend', onTouchEnd, shouldCaptureEvents);\n document.addEventListener('touchstart', onTouchStart, shouldCaptureEvents);\n\n window.addEventListener('blur', onClose);\n\n return () => {\n document.removeEventListener('click', onClick, shouldCaptureEvents);\n document.removeEventListener('touchend', onTouchEnd, shouldCaptureEvents);\n document.removeEventListener('touchstart', onTouchStart, shouldCaptureEvents);\n\n window.removeEventListener('blur', onClose);\n };\n }, [onClick, onClose, onTouchEnd, onTouchStart]);\n};\n\ninterface UseDropdownAlignmentOptions {\n direction: DropdownDirection;\n shouldUseTopAlignment: boolean;\n contentWidth: number;\n anchorElement: Element;\n}\n\nexport const useDropdownAlignment = ({\n anchorElement,\n contentWidth,\n direction,\n shouldUseTopAlignment,\n}: UseDropdownAlignmentOptions) => {\n const [translateX, setTranslateX] = useState<string>('0px');\n const [translateY, setTranslateY] = useState<string>('0px');\n\n useEffect(() => {\n if (\n [\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.TOP_LEFT,\n DropdownDirection.LEFT,\n ].includes(direction)\n ) {\n const difference = anchorElement.clientWidth - contentWidth;\n\n setTranslateX(`${difference}px`);\n } else {\n setTranslateX('0px');\n }\n }, [anchorElement.clientWidth, contentWidth, direction]);\n\n useEffect(() => {\n const useTopAlignment =\n shouldUseTopAlignment ||\n [\n DropdownDirection.TOP,\n DropdownDirection.TOP_LEFT,\n DropdownDirection.TOP_RIGHT,\n ].includes(direction);\n\n if (useTopAlignment) {\n setTranslateY('-100%');\n } else {\n setTranslateY('0px');\n }\n }, [direction, shouldUseTopAlignment]);\n\n return useMemo(() => ({ x: translateX, y: translateY }), [translateX, translateY]);\n};\n\ninterface UseDropdownPositionOptions {\n anchorElement: Element;\n container?: Element;\n contentHeight?: number;\n direction: DropdownDirection;\n shouldShowDropdown: boolean;\n}\n\n/**\n * The space (in pixels) that should be kept between the dropdown content and the edge of the\n * container when calculating the available maximum height.\n */\nconst AVAILABLE_HEIGHT_SPACING = 16;\n\nexport const useDropdownPosition = ({\n anchorElement,\n container,\n contentHeight = 0,\n direction,\n shouldShowDropdown,\n}: UseDropdownPositionOptions) => {\n const [coordinates, setCoordinates] = useState<DropdownCoordinates>({ x: 0, y: 0 });\n const [shouldUseTopAlignment, setShouldUseTopAlignment] = useState(false);\n const [availableMaxHeight, setAvailableMaxHeight] = useState<number>(0);\n\n // Stores the alignment decision (top/bottom) that was made when the dropdown opened. The\n // decision depends on the content height, but the content height in turn is limited by the\n // available height (which depends on the alignment). Recalculating the alignment on every\n // change would create a feedback loop that makes the alignment flip and the height oscillate.\n // We therefore lock the alignment while the dropdown stays open and reset it on close.\n const lockedTopAlignmentRef = useRef<boolean | null>(null);\n\n const calculateCoordinates = useCallback(() => {\n // While the dropdown is closing (or closed) we must not recalculate the position and the\n // available height. Otherwise layout changes underneath the dropdown (e.g. content that\n // appears after a selection) would move or resize the dropdown body while it is still fading\n // out, causing it to visibly jump. Freezing the last calculated values keeps the closing\n // animation stable.\n if (!shouldShowDropdown) {\n return;\n }\n\n if (container) {\n const {\n left: anchorLeft,\n top: anchorTop,\n height: anchorHeight,\n } = anchorElement.getBoundingClientRect();\n\n const { left, top, height } = container.getBoundingClientRect();\n\n const x = anchorLeft - left + container.scrollLeft;\n const y = anchorTop - top + container.scrollTop;\n\n let useTopAlignment = [\n DropdownDirection.TOP,\n DropdownDirection.TOP_LEFT,\n DropdownDirection.TOP_RIGHT,\n ].includes(direction);\n\n const hasBottomAlignment = [\n DropdownDirection.BOTTOM,\n DropdownDirection.BOTTOM_LEFT,\n DropdownDirection.BOTTOM_RIGHT,\n ].includes(direction);\n\n // The available space above and below the anchor within the container.\n const spaceToTop = y;\n const spaceToBottom = height - (y + anchorHeight);\n\n if (lockedTopAlignmentRef.current !== null) {\n // Keep the alignment that was decided when the dropdown opened.\n useTopAlignment = lockedTopAlignmentRef.current;\n } else if (!hasBottomAlignment && y + anchorHeight + contentHeight > height) {\n // The content does not fit below the anchor. Only flip to the top when there is\n // actually more space above than below. Otherwise the content would be cut off less\n // when opened downwards (the content is limited to the available height anyway), so\n // we keep the downward alignment. This avoids opening upwards for a content that,\n // once limited to the available space, would fit below just fine.\n useTopAlignment = spaceToTop > spaceToBottom;\n }\n\n lockedTopAlignmentRef.current = useTopAlignment;\n\n setShouldUseTopAlignment(useTopAlignment);\n\n // Calculate the space that is available for the dropdown content. When the dropdown is\n // opened to the top, the available space reaches from the anchor to the top edge of the\n // container. When it is opened to the bottom, it reaches from the bottom of the anchor\n // to the bottom edge of the container. A small spacing is subtracted so the content does\n // not touch the container edge (e.g. to leave room for shadows).\n\n const nextAvailableMaxHeight = Math.max(\n Math.round(\n (useTopAlignment ? spaceToTop : spaceToBottom) - AVAILABLE_HEIGHT_SPACING,\n ),\n 0,\n );\n\n // Ignore sub-pixel fluctuations so tiny changes from getBoundingClientRect do not\n // repeatedly trigger re-renders that could keep the height oscillating.\n setAvailableMaxHeight((currentAvailableMaxHeight) =>\n Math.abs(currentAvailableMaxHeight - nextAvailableMaxHeight) <= 1\n ? currentAvailableMaxHeight\n : nextAvailableMaxHeight,\n );\n\n setCoordinates({ x, y: useTopAlignment ? y : y + anchorHeight });\n }\n }, [anchorElement, container, contentHeight, direction, shouldShowDropdown]);\n\n useIsomorphicLayoutEffect(() => {\n // Reset the locked alignment whenever the dropdown is closed, so the next time it opens the\n // alignment (top/bottom) is decided freshly based on the then-available space.\n if (!shouldShowDropdown) {\n lockedTopAlignmentRef.current = null;\n }\n\n const handleResize = () => {\n calculateCoordinates();\n\n setTimeout(calculateCoordinates, 300);\n };\n\n handleResize();\n\n if (shouldShowDropdown) {\n window.addEventListener('resize', handleResize);\n }\n\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n }, [calculateCoordinates, shouldShowDropdown]);\n\n return useMemo(\n () => ({ shouldUseTopAlignment, coordinates, availableMaxHeight }),\n [availableMaxHeight, coordinates, shouldUseTopAlignment],\n );\n};\n\ninterface UseDropdownOptions {\n anchorElement: Element;\n container?: Element;\n contentHeight?: number;\n contentWidth: number;\n direction: DropdownDirection;\n shouldShowDropdown: boolean;\n}\n\nexport const useDropdown = ({\n anchorElement,\n container,\n contentHeight,\n contentWidth,\n direction,\n shouldShowDropdown,\n}: UseDropdownOptions) => {\n const { shouldUseTopAlignment, coordinates, availableMaxHeight } = useDropdownPosition({\n anchorElement,\n container,\n contentHeight,\n direction,\n shouldShowDropdown,\n });\n\n const transform = useDropdownAlignment({\n anchorElement,\n contentWidth,\n direction,\n shouldUseTopAlignment,\n });\n\n const width = anchorElement.clientWidth;\n\n return useMemo(\n () => ({ coordinates, transform, width, availableMaxHeight }),\n [availableMaxHeight, coordinates, transform, width],\n );\n};\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,MAAME,yBAAyB,GAAG,OAAOC,MAAM,KAAK,WAAW,GAAGC,sBAAe,GAAGC,gBAAS;AAUtF,MAAMC,mBAAmB,GAAGA,CAAC;EAChCC,OAAO;EACPC,OAAO;EACPC,UAAU;EACVC,YAAY;EACZC;AACwB,CAAC,KAAK;EAC9B,IAAAN,gBAAS,EAAC,MAAM;IACZO,QAAQ,CAACC,gBAAgB,CAAC,OAAO,EAAEN,OAAO,EAAEI,mBAAmB,CAAC;IAChEC,QAAQ,CAACC,gBAAgB,CAAC,UAAU,EAAEJ,UAAU,EAAEE,mBAAmB,CAAC;IACtEC,QAAQ,CAACC,gBAAgB,CAAC,YAAY,EAAEH,YAAY,EAAEC,mBAAmB,CAAC;IAE1ER,MAAM,CAACU,gBAAgB,CAAC,MAAM,EAAEL,OAAO,CAAC;IAExC,OAAO,MAAM;MACTI,QAAQ,CAACE,mBAAmB,CAAC,OAAO,EAAEP,OAAO,EAAEI,mBAAmB,CAAC;MACnEC,QAAQ,CAACE,mBAAmB,CAAC,UAAU,EAAEL,UAAU,EAAEE,mBAAmB,CAAC;MACzEC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C;IACnFvB,aAAa;IACbwB,SAAS;IACTC,aAAa;IACbvB,SAAS;IACTwB;EACJ,CAAC,CAAC;EAEF,MAAMkC,SAAS,GAAG7D,oBAAoB,CAAC;IACnCC,aAAa;IACbC,YAAY;IACZC,SAAS;IACTC;EACJ,CAAC,CAAC;EAEF,MAAM0D,KAAK,GAAG7D,aAAa,CAACe,WAAW;EAEvC,OAAO,IAAAI,cAAO,EACV,OAAO;IAAEQ,WAAW;IAAEiC,SAAS;IAAEC,KAAK;IAAE/B;EAAmB,CAAC,CAAC,EAC7D,CAACA,kBAAkB,EAAEH,WAAW,EAAEiC,SAAS,EAAEC,KAAK,CACtD,CAAC;AACL,CAAC;AAAC/D,OAAA,CAAA6D,WAAA,GAAAA,WAAA","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useKeyboardFocusHighlighting = void 0;
7
+ var _react = require("react");
8
+ var _ColorSchemeProvider = require("../components/color-scheme-provider/ColorSchemeProvider");
9
+ /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */
10
+
11
+ /**
12
+ * Tracks whether focus highlighting should be visible for keyboard navigation.
13
+ * Keyboard mode is enabled via Tab and reset by mouse interaction.
14
+ */
15
+ const useKeyboardFocusHighlighting = isEnabledProp => {
16
+ const colorScheme = (0, _react.useContext)(_ColorSchemeProvider.ColorSchemeContext);
17
+ const contextIsEnabled = (colorScheme === null || colorScheme === void 0 ? void 0 : colorScheme.shouldEnableKeyboardHighlighting) === true;
18
+ const isEnabled = isEnabledProp ?? contextIsEnabled;
19
+ const [isKeyboardNavigation, setIsKeyboardNavigation] = (0, _react.useState)(false);
20
+ (0, _react.useEffect)(() => {
21
+ const canListen = isEnabled && typeof window !== 'undefined';
22
+ const enableKeyboardNavigation = () => {
23
+ setIsKeyboardNavigation(true);
24
+ };
25
+ const handleKeyDown = event => {
26
+ // Ignore pure modifier presses, but treat any real keyboard interaction as keyboard navigation.
27
+ if (event.ctrlKey || event.altKey || event.metaKey) {
28
+ return;
29
+ }
30
+ if (['Shift', 'Control', 'Alt', 'Meta'].includes(event.key)) {
31
+ return;
32
+ }
33
+ enableKeyboardNavigation();
34
+ };
35
+ const handleFocusIn = event => {
36
+ const {
37
+ target
38
+ } = event;
39
+
40
+ // Fallback for first tab-focus when the keydown was not observed.
41
+ if (target instanceof HTMLElement && typeof target.matches === 'function' && target.matches(':focus-visible')) {
42
+ enableKeyboardNavigation();
43
+ }
44
+ };
45
+ const disableKeyboardNavigation = () => {
46
+ setIsKeyboardNavigation(current => current ? false : current);
47
+ };
48
+ if (canListen) {
49
+ window.addEventListener('keydown', handleKeyDown);
50
+ window.addEventListener('focusin', handleFocusIn);
51
+ window.addEventListener('mousedown', disableKeyboardNavigation);
52
+ window.addEventListener('mousemove', disableKeyboardNavigation);
53
+ } else {
54
+ setIsKeyboardNavigation(false);
55
+ }
56
+ return () => {
57
+ if (canListen) {
58
+ window.removeEventListener('keydown', handleKeyDown);
59
+ window.removeEventListener('focusin', handleFocusIn);
60
+ window.removeEventListener('mousedown', disableKeyboardNavigation);
61
+ window.removeEventListener('mousemove', disableKeyboardNavigation);
62
+ }
63
+ };
64
+ }, [isEnabled]);
65
+ return Boolean(isEnabled && isKeyboardNavigation);
66
+ };
67
+ exports.useKeyboardFocusHighlighting = useKeyboardFocusHighlighting;
68
+ //# sourceMappingURL=useKeyboardFocusHighlighting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeyboardFocusHighlighting.js","names":["_react","require","_ColorSchemeProvider","useKeyboardFocusHighlighting","isEnabledProp","colorScheme","useContext","ColorSchemeContext","contextIsEnabled","shouldEnableKeyboardHighlighting","isEnabled","isKeyboardNavigation","setIsKeyboardNavigation","useState","useEffect","canListen","window","enableKeyboardNavigation","handleKeyDown","event","ctrlKey","altKey","metaKey","includes","key","handleFocusIn","target","HTMLElement","matches","disableKeyboardNavigation","current","addEventListener","removeEventListener","Boolean","exports"],"sources":["../../../src/hooks/useKeyboardFocusHighlighting.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */\nimport { useContext, useEffect, useState } from 'react';\nimport {\n ColorSchemeContext,\n type ColorSchemeContextProps,\n} from '../components/color-scheme-provider/ColorSchemeProvider';\n\n/**\n * Tracks whether focus highlighting should be visible for keyboard navigation.\n * Keyboard mode is enabled via Tab and reset by mouse interaction.\n */\nexport const useKeyboardFocusHighlighting = (isEnabledProp?: boolean): boolean => {\n const colorScheme = useContext<ColorSchemeContextProps | undefined>(ColorSchemeContext);\n const contextIsEnabled: boolean = colorScheme?.shouldEnableKeyboardHighlighting === true;\n const isEnabled: boolean = isEnabledProp ?? contextIsEnabled;\n\n const [isKeyboardNavigation, setIsKeyboardNavigation] = useState(false);\n\n useEffect(() => {\n const canListen = isEnabled && typeof window !== 'undefined';\n\n const enableKeyboardNavigation = () => {\n setIsKeyboardNavigation(true);\n };\n\n const handleKeyDown = (event: KeyboardEvent) => {\n // Ignore pure modifier presses, but treat any real keyboard interaction as keyboard navigation.\n if (event.ctrlKey || event.altKey || event.metaKey) {\n return;\n }\n\n if (['Shift', 'Control', 'Alt', 'Meta'].includes(event.key)) {\n return;\n }\n\n enableKeyboardNavigation();\n };\n\n const handleFocusIn = (event: FocusEvent) => {\n const { target } = event;\n\n // Fallback for first tab-focus when the keydown was not observed.\n if (\n target instanceof HTMLElement &&\n typeof target.matches === 'function' &&\n target.matches(':focus-visible')\n ) {\n enableKeyboardNavigation();\n }\n };\n\n const disableKeyboardNavigation = () => {\n setIsKeyboardNavigation((current) => (current ? false : current));\n };\n\n if (canListen) {\n window.addEventListener('keydown', handleKeyDown);\n window.addEventListener('focusin', handleFocusIn);\n window.addEventListener('mousedown', disableKeyboardNavigation);\n window.addEventListener('mousemove', disableKeyboardNavigation);\n } else {\n setIsKeyboardNavigation(false);\n }\n\n return () => {\n if (canListen) {\n window.removeEventListener('keydown', handleKeyDown);\n window.removeEventListener('focusin', handleFocusIn);\n window.removeEventListener('mousedown', disableKeyboardNavigation);\n window.removeEventListener('mousemove', disableKeyboardNavigation);\n }\n };\n }, [isEnabled]);\n\n return Boolean(isEnabled && isKeyboardNavigation);\n};\n"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAFA;;AAOA;AACA;AACA;AACA;AACO,MAAME,4BAA4B,GAAIC,aAAuB,IAAc;EAC9E,MAAMC,WAAW,GAAG,IAAAC,iBAAU,EAAsCC,uCAAkB,CAAC;EACvF,MAAMC,gBAAyB,GAAG,CAAAH,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAEI,gCAAgC,MAAK,IAAI;EACxF,MAAMC,SAAkB,GAAGN,aAAa,IAAII,gBAAgB;EAE5D,MAAM,CAACG,oBAAoB,EAAEC,uBAAuB,CAAC,GAAG,IAAAC,eAAQ,EAAC,KAAK,CAAC;EAEvE,IAAAC,gBAAS,EAAC,MAAM;IACZ,MAAMC,SAAS,GAAGL,SAAS,IAAI,OAAOM,MAAM,KAAK,WAAW;IAE5D,MAAMC,wBAAwB,GAAGA,CAAA,KAAM;MACnCL,uBAAuB,CAAC,IAAI,CAAC;IACjC,CAAC;IAED,MAAMM,aAAa,GAAIC,KAAoB,IAAK;MAC5C;MACA,IAAIA,KAAK,CAACC,OAAO,IAAID,KAAK,CAACE,MAAM,IAAIF,KAAK,CAACG,OAAO,EAAE;QAChD;MACJ;MAEA,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAACC,QAAQ,CAACJ,KAAK,CAACK,GAAG,CAAC,EAAE;QACzD;MACJ;MAEAP,wBAAwB,CAAC,CAAC;IAC9B,CAAC;IAED,MAAMQ,aAAa,GAAIN,KAAiB,IAAK;MACzC,MAAM;QAAEO;MAAO,CAAC,GAAGP,KAAK;;MAExB;MACA,IACIO,MAAM,YAAYC,WAAW,IAC7B,OAAOD,MAAM,CAACE,OAAO,KAAK,UAAU,IACpCF,MAAM,CAACE,OAAO,CAAC,gBAAgB,CAAC,EAClC;QACEX,wBAAwB,CAAC,CAAC;MAC9B;IACJ,CAAC;IAED,MAAMY,yBAAyB,GAAGA,CAAA,KAAM;MACpCjB,uBAAuB,CAAEkB,OAAO,IAAMA,OAAO,GAAG,KAAK,GAAGA,OAAQ,CAAC;IACrE,CAAC;IAED,IAAIf,SAAS,EAAE;MACXC,MAAM,CAACe,gBAAgB,CAAC,SAAS,EAAEb,aAAa,CAAC;MACjDF,MAAM,CAACe,gBAAgB,CAAC,SAAS,EAAEN,aAAa,CAAC;MACjDT,MAAM,CAACe,gBAAgB,CAAC,WAAW,EAAEF,yBAAyB,CAAC;MAC/Db,MAAM,CAACe,gBAAgB,CAAC,WAAW,EAAEF,yBAAyB,CAAC;IACnE,CAAC,MAAM;MACHjB,uBAAuB,CAAC,KAAK,CAAC;IAClC;IAEA,OAAO,MAAM;MACT,IAAIG,SAAS,EAAE;QACXC,MAAM,CAACgB,mBAAmB,CAAC,SAAS,EAAEd,aAAa,CAAC;QACpDF,MAAM,CAACgB,mBAAmB,CAAC,SAAS,EAAEP,aAAa,CAAC;QACpDT,MAAM,CAACgB,mBAAmB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;QAClEb,MAAM,CAACgB,mBAAmB,CAAC,WAAW,EAAEH,yBAAyB,CAAC;MACtE;IACJ,CAAC;EACL,CAAC,EAAE,CAACnB,SAAS,CAAC,CAAC;EAEf,OAAOuB,OAAO,CAACvB,SAAS,IAAIC,oBAAoB,CAAC;AACrD,CAAC;AAACuB,OAAA,CAAA/B,4BAAA,GAAAA,4BAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","names":["hasDuplicate","items","newItem","comparator","some","item","exports","filterDuplicateFile","files","newFile","a","b","name","size","filterDuplicateFileUrls","getHumanSize","bytes","FILE_SIZE_UNITS","unitIndex","Math","round","toString","replace","isValidFileType","types","file","allowedTypesArray","split","map","type","trim","fileType","endsWith","baseType","slice","startsWith","MIME_TYPE_MAPPING","getIconByMimeType","mimeType","matchedType","Object","keys","find"],"sources":["../../../src/utils/file.ts"],"sourcesContent":["import { UploadedFile } from '../components/file-select/FileSelect';\n\nexport const hasDuplicate = <T>(\n items: T[],\n newItem: T,\n comparator: (a: T, b: T) => boolean,\n): boolean => items.some((item) => comparator(item, newItem));\n\ninterface FilerDuplicateFileOptions {\n files: File[];\n newFile: File;\n}\n\nexport const filterDuplicateFile = ({ files, newFile }: FilerDuplicateFileOptions) =>\n hasDuplicate(files, newFile, (a, b) => a.name === b.name && a.size === b.size);\n\ninterface FilterDuplicateFileUrlsOptions {\n files: UploadedFile[];\n newFile: UploadedFile;\n}\n\nexport const filterDuplicateFileUrls = ({ files, newFile }: FilterDuplicateFileUrlsOptions) =>\n hasDuplicate(files, newFile, (a, b) => a === b);\n\nexport const getHumanSize = (bytes: number): string => {\n const FILE_SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];\n let size = bytes || 0;\n let unitIndex = 0;\n\n while (size >= 1024) {\n size /= 1024;\n unitIndex += 1;\n }\n\n size = Math.round(size * 10) / 10;\n\n return `${size.toString().replace('.', ',')} ${FILE_SIZE_UNITS[unitIndex] ?? ''}`;\n};\n\ninterface IsValidFileTypeOptions {\n file: File;\n types: string;\n}\n\nexport const isValidFileType = ({ types, file }: IsValidFileTypeOptions) => {\n const allowedTypesArray = types.split(',').map((type) => type.trim());\n const fileType = file.type;\n\n return allowedTypesArray.some((type) => {\n if (type.endsWith('/*')) {\n const baseType = type.slice(0, -2); // remove '/*'\n return fileType.startsWith(baseType);\n }\n return fileType === type;\n });\n};\n\nexport const MIME_TYPE_MAPPING: Record<string, string> = {\n // Haupttypen\n 'application/pdf': 'fa fa-file-pdf',\n 'application/zip': 'fa fa-file-archive',\n 'application/msword': 'fa fa-file-word',\n 'application/vnd.ms-excel': 'fa fa-file-excel',\n // Typen mit Wildcards\n 'application/vnd.openxmlformats-officedocument.': 'fa fa-file-word',\n 'application/x-': 'fa fa-file-archive',\n // Addiere nur spezifische Fälle\n 'text/pdf': 'fa fa-file-pdf',\n};\n\nexport const getIconByMimeType = (mimeType?: string): string => {\n const matchedType = Object.keys(MIME_TYPE_MAPPING).find((type) => mimeType?.startsWith(type));\n return MIME_TYPE_MAPPING[matchedType!] || 'fa fa-file';\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GAAGA,CACxBC,KAAU,EACVC,OAAU,EACVC,UAAmC,KACzBF,KAAK,CAACG,IAAI,CAAEC,IAAI,IAAKF,UAAU,CAACE,IAAI,EAAEH,OAAO,CAAC,CAAC;AAACI,OAAA,CAAAN,YAAA,GAAAA,YAAA;AAOvD,MAAMO,mBAAmB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAmC,CAAC,KAC7ET,YAAY,CAACQ,KAAK,EAAEC,OAAO,EAAE,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,IAAI,KAAKD,CAAC,CAACC,IAAI,IAAIF,CAAC,CAACG,IAAI,KAAKF,CAAC,CAACE,IAAI,CAAC;AAACP,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AAO5E,MAAMO,uBAAuB,GAAGA,CAAC;EAAEN,KAAK;EAAEC;AAAwC,CAAC,KACtFT,YAAY,CAACQ,KAAK,EAAEC,OAAO,EAAE,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,KAAKC,CAAC,CAAC;AAACL,OAAA,CAAAQ,uBAAA,GAAAA,uBAAA;AAE7C,MAAMC,YAAY,GAAIC,KAAa,IAAa;EACnD,MAAMC,eAAe,GAAG,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC;EAC3D,IAAIJ,IAAI,GAAGG,KAAK,IAAI,CAAC;EACrB,IAAIE,SAAS,GAAG,CAAC;EAEjB,OAAOL,IAAI,IAAI,IAAI,EAAE;IAC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M,MAAMC,iBAAiB,GAAIC,QAAiB,IAAa;EAC5D,MAAMC,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACL,iBAAiB,CAAC,CAACM,IAAI,CAAEb,IAAI,IAAKS,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEH,UAAU,CAACN,IAAI,CAAC,CAAC;EAC7F,OAAOO,iBAAiB,CAACG,WAAW,CAAE,IAAI,YAAY;AAC1D,CAAC;AAACjC,OAAA,CAAA+B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"file.js","names":["hasDuplicate","items","newItem","comparator","some","item","exports","filterDuplicateFile","files","newFile","a","b","name","size","filterDuplicateFileUrls","getHumanSize","bytes","FILE_SIZE_UNITS","unitIndex","Math","round","toString","replace","isValidFileType","types","file","allowedTypesArray","split","map","type","trim","fileType","endsWith","baseType","slice","startsWith","MIME_TYPE_MAPPING","getIconByMimeType","mimeType","matchedType","Object","keys","find"],"sources":["../../../src/utils/file.ts"],"sourcesContent":["import type { UploadedFile } from '../components/file-select/FileSelect';\n\nexport const hasDuplicate = <T>(\n items: T[],\n newItem: T,\n comparator: (a: T, b: T) => boolean,\n): boolean => items.some((item) => comparator(item, newItem));\n\ninterface FilerDuplicateFileOptions {\n files: File[];\n newFile: File;\n}\n\nexport const filterDuplicateFile = ({ files, newFile }: FilerDuplicateFileOptions) =>\n hasDuplicate(files, newFile, (a, b) => a.name === b.name && a.size === b.size);\n\ninterface FilterDuplicateFileUrlsOptions {\n files: UploadedFile[];\n newFile: UploadedFile;\n}\n\nexport const filterDuplicateFileUrls = ({ files, newFile }: FilterDuplicateFileUrlsOptions) =>\n hasDuplicate(files, newFile, (a, b) => a === b);\n\nexport const getHumanSize = (bytes: number): string => {\n const FILE_SIZE_UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB'];\n let size = bytes || 0;\n let unitIndex = 0;\n\n while (size >= 1024) {\n size /= 1024;\n unitIndex += 1;\n }\n\n size = Math.round(size * 10) / 10;\n\n return `${size.toString().replace('.', ',')} ${FILE_SIZE_UNITS[unitIndex] ?? ''}`;\n};\n\ninterface IsValidFileTypeOptions {\n file: File;\n types: string;\n}\n\nexport const isValidFileType = ({ types, file }: IsValidFileTypeOptions) => {\n const allowedTypesArray = types.split(',').map((type) => type.trim());\n const fileType = file.type;\n\n return allowedTypesArray.some((type) => {\n if (type.endsWith('/*')) {\n const baseType = type.slice(0, -2); // remove '/*'\n return fileType.startsWith(baseType);\n }\n return fileType === type;\n });\n};\n\nexport const MIME_TYPE_MAPPING: Record<string, string> = {\n // Haupttypen\n 'application/pdf': 'fa fa-file-pdf',\n 'application/zip': 'fa fa-file-archive',\n 'application/msword': 'fa fa-file-word',\n 'application/vnd.ms-excel': 'fa fa-file-excel',\n // Typen mit Wildcards\n 'application/vnd.openxmlformats-officedocument.': 'fa fa-file-word',\n 'application/x-': 'fa fa-file-archive',\n // Addiere nur spezifische Fälle\n 'text/pdf': 'fa fa-file-pdf',\n};\n\nexport const getIconByMimeType = (mimeType?: string): string => {\n const matchedType = Object.keys(MIME_TYPE_MAPPING).find((type) => mimeType?.startsWith(type));\n return MIME_TYPE_MAPPING[matchedType!] || 'fa fa-file';\n};\n"],"mappings":";;;;;;AAEO,MAAMA,YAAY,GAAGA,CACxBC,KAAU,EACVC,OAAU,EACVC,UAAmC,KACzBF,KAAK,CAACG,IAAI,CAAEC,IAAI,IAAKF,UAAU,CAACE,IAAI,EAAEH,OAAO,CAAC,CAAC;AAACI,OAAA,CAAAN,YAAA,GAAAA,YAAA;AAOvD,MAAMO,mBAAmB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAmC,CAAC,KAC7ET,YAAY,CAACQ,KAAK,EAAEC,OAAO,EAAE,CAACC,CAAC,EAAEC,CAAC,KAAKD,CAAC,CAACE,IAAI,KAAKD,CAAC,CAACC,IAAI,IAAIF,CAAC,CAACG,IAAI,KAAKF,CAAC,CAACE,IAAI,CAAC;AAACP,OAAA,CAAAC,mBAAA,GAAAA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C,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;MACpC,OAAOH,QAAQ,CAACI,UAAU,CAACF,QAAQ,CAAC;IACxC;IACA,OAAOF,QAAQ,KAAKF,IAAI;EAC5B,CAAC,CAAC;AACN,CAAC;AAACvB,OAAA,CAAAiB,eAAA,GAAAA,eAAA;AAEK,MAAMa,iBAAyC,GAAA9B,OAAA,CAAA8B,iBAAA,GAAG;EACrD;EACA,iBAAiB,EAAE,gBAAgB;EACnC,iBAAiB,EAAE,oBAAoB;EACvC,oBAAoB,EAAE,iBAAiB;EACvC,0BAA0B,EAAE,kBAAkB;EAC9C;EACA,gDAAgD,EAAE,iBAAiB;EACnE,gBAAgB,EAAE,oBAAoB;EACtC;EACA,UAAU,EAAE;AAChB,CAAC;AAEM,MAAMC,iBAAiB,GAAIC,QAAiB,IAAa;EAC5D,MAAMC,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACL,iBAAiB,CAAC,CAACM,IAAI,CAAEb,IAAI,IAAKS,QAAQ,aAARA,QAAQ,uBAARA,QAAQ,CAAEH,UAAU,CAACN,IAAI,CAAC,CAAC;EAC7F,OAAOO,iBAAiB,CAACG,WAAW,CAAE,IAAI,YAAY;AAC1D,CAAC;AAACjC,OAAA,CAAA+B,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.keyboardFocusHighlightingRingCss = exports.keyboardFocusHighlightingCircleRingCss = void 0;
7
+ var _styledComponents = require("styled-components");
8
+ /**
9
+ * Shared focus ring for components with keyboard-only highlighting.
10
+ * Apply this only when keyboard highlighting is enabled/active.
11
+ */
12
+ const keyboardFocusHighlightingRingCss = exports.keyboardFocusHighlightingRingCss = (0, _styledComponents.css)`
13
+ outline: solid 2px color-mix(in srgb, white 70%, transparent);
14
+ box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
15
+ border-radius: 3px;
16
+ outline-offset: 1px;
17
+ `;
18
+
19
+ /**
20
+ * Circular focus ring variant for round controls (e.g. RadioButton).
21
+ */
22
+ const keyboardFocusHighlightingCircleRingCss = exports.keyboardFocusHighlightingCircleRingCss = (0, _styledComponents.css)`
23
+ outline: solid 2px color-mix(in srgb, white 70%, transparent);
24
+ box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);
25
+ border-radius: 50%;
26
+ outline-offset: 1px;
27
+ color: white;
28
+ `;
29
+ //# sourceMappingURL=keyboardFocusHighlighting.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardFocusHighlighting.styles.js","names":["_styledComponents","require","keyboardFocusHighlightingRingCss","exports","css","keyboardFocusHighlightingCircleRingCss"],"sources":["../../../src/utils/keyboardFocusHighlighting.styles.ts"],"sourcesContent":["import { css } from 'styled-components';\n\n/**\n * Shared focus ring for components with keyboard-only highlighting.\n * Apply this only when keyboard highlighting is enabled/active.\n */\nexport const keyboardFocusHighlightingRingCss = css`\n outline: solid 2px color-mix(in srgb, white 70%, transparent);\n box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);\n border-radius: 3px;\n outline-offset: 1px;\n`;\n\n/**\n * Circular focus ring variant for round controls (e.g. RadioButton).\n */\nexport const keyboardFocusHighlightingCircleRingCss = css`\n outline: solid 2px color-mix(in srgb, white 70%, transparent);\n box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.3);\n border-radius: 50%;\n outline-offset: 1px;\n color: white;\n`;\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACO,MAAMC,gCAAgC,GAAAC,OAAA,CAAAD,gCAAA,GAAG,IAAAE,qBAAG;AACnD;AACA;AACA;AACA;AACA,CAAC;;AAED;AACA;AACA;AACO,MAAMC,sCAAsC,GAAAF,OAAA,CAAAE,sCAAA,GAAG,IAAAD,qBAAG;AACzD;AACA;AACA;AACA;AACA;AACA,CAAC","ignoreList":[]}
@@ -1,7 +1,9 @@
1
1
  import { AnimatePresence, MotionConfig } from 'motion/react';
2
2
  import React, { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { useUuid } from '../../hooks/uuid';
4
+ import { useKeyboardFocusHighlighting } from '../../hooks/useKeyboardFocusHighlighting';
4
5
  import { AreaContext } from '../area-provider/AreaContextProvider';
6
+ import { useColorScheme } from '../color-scheme-provider/ColorSchemeProvider';
5
7
  import AccordionBody from './accordion-body/AccordionBody';
6
8
  import { AccordionGroupContext } from './accordion-group/AccordionGroup';
7
9
  import AccordionHead from './accordion-head/AccordionHead';
@@ -41,14 +43,19 @@ const Accordion = ({
41
43
  shouldSkipAnimation: shouldSkipAnimationProp = false,
42
44
  colors,
43
45
  shouldIndex = false,
44
- onBodyAnimationComplete
46
+ onBodyAnimationComplete,
47
+ shouldEnableKeyboardHighlighting
45
48
  }) => {
46
49
  const {
47
50
  isWrapped: groupIsWrapped,
48
51
  openAccordionUuid,
49
52
  accordionGroupUuid,
50
53
  accordionUuids,
51
- updateOpenAccordionUuid
54
+ updateOpenAccordionUuid,
55
+ activeAccordionUuid,
56
+ updateActiveAccordionUuid,
57
+ registerAccordionUuid,
58
+ unregisterAccordionUuid
52
59
  } = useContext(AccordionGroupContext);
53
60
  const {
54
61
  isWrapped: isParentWrapped
@@ -56,8 +63,11 @@ const Accordion = ({
56
63
  const {
57
64
  isWrapped: contextIsWrapped
58
65
  } = useContext(AccordionWrappedContext);
66
+ const colorScheme = useColorScheme();
67
+ const shouldEnableKeyboardHighlightingEffective = shouldEnableKeyboardHighlighting ?? colorScheme?.shouldEnableKeyboardHighlighting ?? false;
59
68
  const isWrapped = useMemo(() => groupIsWrapped ?? contextIsWrapped, [contextIsWrapped, groupIsWrapped]);
60
69
  const [isAccordionOpen, setIsAccordionOpen] = useState(isDefaultOpen ?? isOpened);
70
+ const [isGroupFocusWithin, setIsGroupFocusWithin] = useState(false);
61
71
  const uuid = useUuid();
62
72
  const isInitialRenderRef = useRef(true);
63
73
  const initialRenderSkipRef = useInitialRenderRef(true);
@@ -67,6 +77,18 @@ const Accordion = ({
67
77
  const isOpenRef = useRef(isOpen);
68
78
  const onCloseRef = useRef(onClose);
69
79
  const onOpenRef = useRef(onOpen);
80
+ const shouldShowKeyboardHighlighting = useKeyboardFocusHighlighting(shouldEnableKeyboardHighlightingEffective);
81
+ const isKeyboardFocusable = !isDisabled && (shouldIndex || shouldEnableKeyboardHighlightingEffective);
82
+ const isInKeyboardNavigationGroup = isKeyboardFocusable && typeof updateActiveAccordionUuid === 'function' && typeof accordionGroupUuid === 'string';
83
+ useEffect(() => {
84
+ if (typeof accordionGroupUuid === 'string' && typeof registerAccordionUuid === 'function' && typeof unregisterAccordionUuid === 'function') {
85
+ registerAccordionUuid(uuid);
86
+ return () => {
87
+ unregisterAccordionUuid(uuid);
88
+ };
89
+ }
90
+ return undefined;
91
+ }, [accordionGroupUuid, registerAccordionUuid, unregisterAccordionUuid, uuid]);
70
92
  const isLastAccordion = useMemo(() => accordionUuids ? accordionUuids[accordionUuids.length - 1] === uuid : false, [accordionUuids, uuid]);
71
93
  useEffect(() => {
72
94
  isOpenRef.current = isOpen;
@@ -77,11 +99,14 @@ const Accordion = ({
77
99
  if (isDisabled) {
78
100
  return;
79
101
  }
102
+ if (isKeyboardFocusable && typeof updateActiveAccordionUuid === 'function') {
103
+ updateActiveAccordionUuid(uuid);
104
+ }
80
105
  if (typeof updateOpenAccordionUuid === 'function') {
81
106
  updateOpenAccordionUuid(uuid);
82
107
  }
83
108
  setIsAccordionOpen(currentIsAccordionOpen => !currentIsAccordionOpen);
84
- }, [isDisabled, updateOpenAccordionUuid, uuid]);
109
+ }, [isDisabled, isKeyboardFocusable, updateActiveAccordionUuid, updateOpenAccordionUuid, uuid]);
85
110
  useEffect(() => {
86
111
  if (isDisabled && isOpen) {
87
112
  if (typeof updateOpenAccordionUuid === 'function') {
@@ -145,6 +170,75 @@ const Accordion = ({
145
170
  opacity: 0
146
171
  };
147
172
  }, [isOpen, shouldSkipAnimation]);
173
+ const tabIndex = useMemo(() => isKeyboardFocusable ? 0 : -1, [isKeyboardFocusable]);
174
+ const handleKeyDown = useCallback(e => {
175
+ const isCurrentAccordionTarget = e.currentTarget === e.target;
176
+ if (isCurrentAccordionTarget && isInKeyboardNavigationGroup && accordionUuids?.length && (e.key === 'ArrowDown' || e.key === 'ArrowUp')) {
177
+ const currentIndex = accordionUuids.indexOf(uuid);
178
+ if (currentIndex !== -1) {
179
+ const nextIndex = e.key === 'ArrowDown' ? (currentIndex + 1) % accordionUuids.length : (currentIndex - 1 + accordionUuids.length) % accordionUuids.length;
180
+ const nextAccordionUuid = accordionUuids[nextIndex];
181
+ if (nextAccordionUuid && nextAccordionUuid !== uuid) {
182
+ const nextAccordionElement = document.querySelector(`[data-uuid="${accordionGroupUuid}---${nextAccordionUuid}"]`);
183
+ if (nextAccordionElement) {
184
+ updateActiveAccordionUuid(nextAccordionUuid);
185
+ nextAccordionElement.focus();
186
+ return;
187
+ }
188
+ }
189
+ }
190
+ }
191
+ if (isCurrentAccordionTarget && (e.key === 'Enter' || e.key === ' ') && isKeyboardFocusable) {
192
+ handleHeadClick();
193
+ }
194
+ if (isCurrentAccordionTarget && e.key === 'ArrowRight' && isKeyboardFocusable && !isOpen) {
195
+ e.preventDefault();
196
+ handleHeadClick();
197
+ }
198
+ if (isCurrentAccordionTarget && (e.key === 'Escape' || e.key === 'ArrowLeft')) {
199
+ if (isOpen && isKeyboardFocusable) {
200
+ e.preventDefault();
201
+ handleHeadClick();
202
+ return;
203
+ }
204
+ if (isInKeyboardNavigationGroup && typeof updateActiveAccordionUuid === 'function') {
205
+ e.preventDefault();
206
+ updateActiveAccordionUuid(undefined);
207
+ let parentAccordion = e.currentTarget.parentElement?.closest('.beta-chayns-accordion');
208
+ while (parentAccordion) {
209
+ const parentGroupId = parentAccordion.getAttribute('data-uuid')?.split('---')[0];
210
+ if (parentGroupId !== accordionGroupUuid) {
211
+ parentAccordion.focus();
212
+ break;
213
+ }
214
+ parentAccordion = parentAccordion.parentElement?.closest('.beta-chayns-accordion');
215
+ }
216
+ }
217
+ }
218
+ }, [accordionGroupUuid, accordionUuids, handleHeadClick, isInKeyboardNavigationGroup, isKeyboardFocusable, isOpen, updateActiveAccordionUuid, uuid]);
219
+ const handleFocus = useCallback(e => {
220
+ if (e.currentTarget === e.target && isInKeyboardNavigationGroup && typeof updateActiveAccordionUuid === 'function') {
221
+ setIsGroupFocusWithin(true);
222
+ updateActiveAccordionUuid(uuid);
223
+ }
224
+ }, [isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid]);
225
+ const handleBlur = useCallback(e => {
226
+ if (isInKeyboardNavigationGroup && typeof updateActiveAccordionUuid === 'function' && typeof accordionGroupUuid === 'string') {
227
+ const nextFocusedElement = e.relatedTarget;
228
+ const currentGroupElement = e.currentTarget;
229
+ if (!nextFocusedElement || !currentGroupElement.contains(nextFocusedElement)) {
230
+ setIsGroupFocusWithin(false);
231
+ updateActiveAccordionUuid(undefined);
232
+ }
233
+ }
234
+ }, [accordionGroupUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid]);
235
+ useEffect(() => {
236
+ if (!isInKeyboardNavigationGroup) {
237
+ setIsGroupFocusWithin(false);
238
+ } else if (activeAccordionUuid == null && typeof updateActiveAccordionUuid === 'function' && accordionUuids?.[0] === uuid) {
239
+ updateActiveAccordionUuid(uuid);
240
+ }
241
+ }, [accordionUuids, activeAccordionUuid, isInKeyboardNavigationGroup, updateActiveAccordionUuid, uuid]);
148
242
  return /*#__PURE__*/React.createElement(StyledMotionAccordion, {
149
243
  animate: {
150
244
  height: 'auto',
@@ -158,7 +252,7 @@ const Accordion = ({
158
252
  },
159
253
  initial: initialAnimation,
160
254
  $isOpen: isOpen,
161
- tabIndex: shouldIndex ? 0 : -1,
255
+ tabIndex: tabIndex,
162
256
  $shouldShowLines: !isLastAccordion || !isWrapped,
163
257
  $isParentWrapped: isParentWrapped,
164
258
  $isWrapped: isWrapped,
@@ -166,13 +260,11 @@ const Accordion = ({
166
260
  $shouldHideBackground: shouldHideBackground,
167
261
  $shouldHideBottomLine: shouldHideBottomLine,
168
262
  $bottomBorderColor: colors?.borderBottomColor,
169
- onKeyDown: e => {
170
- if ((e.key === 'Enter' || e.key === ' ') && e.target.className.includes('beta-chayns-accordion') && shouldIndex) {
171
- e.preventDefault();
172
- e.stopPropagation();
173
- handleHeadClick();
174
- }
175
- },
263
+ $shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingEffective,
264
+ $shouldShowKeyboardHighlighting: shouldShowKeyboardHighlighting,
265
+ onKeyDown: handleKeyDown,
266
+ onFocus: handleFocus,
267
+ onBlur: handleBlur,
176
268
  onMouseEnter: onHoverStart,
177
269
  onMouseLeave: onHoverEnd,
178
270
  transition: {
@@ -202,7 +294,8 @@ const Accordion = ({
202
294
  titleElement: titleElement,
203
295
  onTitleInputChange: onTitleInputChange,
204
296
  titleInputProps: titleInputProps,
205
- titleColor: colors?.titleColor
297
+ titleColor: colors?.titleColor,
298
+ shouldEnableKeyboardHighlighting: shouldEnableKeyboardHighlightingEffective
206
299
  }), /*#__PURE__*/React.createElement(AnimatePresence, {
207
300
  initial: false
208
301
  }, (isOpen || shouldRenderClosed) && /*#__PURE__*/React.createElement(AccordionBody, {