@apify/ui-library 1.138.0 → 1.138.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/README.md +3 -3
  2. package/dist/src/components/action_link.d.ts.map +1 -1
  3. package/dist/src/components/action_link.js +3 -3
  4. package/dist/src/components/action_link.js.map +1 -1
  5. package/dist/src/components/actor_template_card.d.ts.map +1 -1
  6. package/dist/src/components/actor_template_card.js +3 -3
  7. package/dist/src/components/actor_template_card.js.map +1 -1
  8. package/dist/src/components/avatar/actor_avatar.d.ts.map +1 -1
  9. package/dist/src/components/avatar/actor_avatar.js +3 -3
  10. package/dist/src/components/avatar/actor_avatar.js.map +1 -1
  11. package/dist/src/components/avatar/boring_avatar.d.ts.map +1 -1
  12. package/dist/src/components/avatar/boring_avatar.js +8 -7
  13. package/dist/src/components/avatar/boring_avatar.js.map +1 -1
  14. package/dist/src/components/avatar/user_avatar.d.ts.map +1 -1
  15. package/dist/src/components/avatar/user_avatar.js +1 -1
  16. package/dist/src/components/avatar/user_avatar.js.map +1 -1
  17. package/dist/src/components/badge.d.ts.map +1 -1
  18. package/dist/src/components/badge.js +10 -3
  19. package/dist/src/components/badge.js.map +1 -1
  20. package/dist/src/components/banner.d.ts.map +1 -1
  21. package/dist/src/components/banner.js +4 -3
  22. package/dist/src/components/banner.js.map +1 -1
  23. package/dist/src/components/blog_article.d.ts.map +1 -1
  24. package/dist/src/components/blog_article.js +2 -3
  25. package/dist/src/components/blog_article.js.map +1 -1
  26. package/dist/src/components/box.d.ts.map +1 -1
  27. package/dist/src/components/box.js +32 -24
  28. package/dist/src/components/box.js.map +1 -1
  29. package/dist/src/components/breadcrumb/breadcrumb.d.ts.map +1 -1
  30. package/dist/src/components/breadcrumb/breadcrumb.js +1 -1
  31. package/dist/src/components/breadcrumb/breadcrumb.js.map +1 -1
  32. package/dist/src/components/button.d.ts.map +1 -1
  33. package/dist/src/components/button.js +12 -9
  34. package/dist/src/components/button.js.map +1 -1
  35. package/dist/src/components/card_container.d.ts.map +1 -1
  36. package/dist/src/components/card_container.js +5 -3
  37. package/dist/src/components/card_container.js.map +1 -1
  38. package/dist/src/components/checkbox/checkbox.d.ts.map +1 -1
  39. package/dist/src/components/checkbox/checkbox.js +1 -1
  40. package/dist/src/components/checkbox/checkbox.js.map +1 -1
  41. package/dist/src/components/checkbox/checkbox.style.d.ts.map +1 -1
  42. package/dist/src/components/checkbox/checkbox.style.js +7 -4
  43. package/dist/src/components/checkbox/checkbox.style.js.map +1 -1
  44. package/dist/src/components/chip.d.ts.map +1 -1
  45. package/dist/src/components/chip.js +1 -1
  46. package/dist/src/components/chip.js.map +1 -1
  47. package/dist/src/components/code/action_button.d.ts.map +1 -1
  48. package/dist/src/components/code/action_button.js +5 -5
  49. package/dist/src/components/code/action_button.js.map +1 -1
  50. package/dist/src/components/code/code_block/code_block.d.ts.map +1 -1
  51. package/dist/src/components/code/code_block/code_block.js +19 -8
  52. package/dist/src/components/code/code_block/code_block.js.map +1 -1
  53. package/dist/src/components/code/code_block/code_block.styled.d.ts.map +1 -1
  54. package/dist/src/components/code/code_block/code_block.styled.js +18 -15
  55. package/dist/src/components/code/code_block/code_block.styled.js.map +1 -1
  56. package/dist/src/components/code/code_block/code_block_with_tabs.d.ts.map +1 -1
  57. package/dist/src/components/code/code_block/code_block_with_tabs.js +10 -8
  58. package/dist/src/components/code/code_block/code_block_with_tabs.js.map +1 -1
  59. package/dist/src/components/code/code_block/utils.d.ts.map +1 -1
  60. package/dist/src/components/code/code_block/utils.js.map +1 -1
  61. package/dist/src/components/code/inline_code/inline_code.d.ts.map +1 -1
  62. package/dist/src/components/code/inline_code/inline_code.js +2 -2
  63. package/dist/src/components/code/inline_code/inline_code.js.map +1 -1
  64. package/dist/src/components/code/one_light_theme.d.ts.map +1 -1
  65. package/dist/src/components/code/one_light_theme.js +2 -17
  66. package/dist/src/components/code/one_light_theme.js.map +1 -1
  67. package/dist/src/components/code/one_line_code/one_line_code.d.ts.map +1 -1
  68. package/dist/src/components/code/one_line_code/one_line_code.js +11 -14
  69. package/dist/src/components/code/one_line_code/one_line_code.js.map +1 -1
  70. package/dist/src/components/code/prism_highlighter.d.ts.map +1 -1
  71. package/dist/src/components/code/prism_highlighter.js +35 -27
  72. package/dist/src/components/code/prism_highlighter.js.map +1 -1
  73. package/dist/src/components/code/prism_python.js.map +1 -1
  74. package/dist/src/components/collapsible_card/collapsible_card.d.ts.map +1 -1
  75. package/dist/src/components/collapsible_card/collapsible_card.js +7 -6
  76. package/dist/src/components/collapsible_card/collapsible_card.js.map +1 -1
  77. package/dist/src/components/color_wheel_gradient.d.ts.map +1 -1
  78. package/dist/src/components/color_wheel_gradient.js +4 -2
  79. package/dist/src/components/color_wheel_gradient.js.map +1 -1
  80. package/dist/src/components/floating/floating_component_base.d.ts +1 -1
  81. package/dist/src/components/floating/floating_component_base.d.ts.map +1 -1
  82. package/dist/src/components/floating/floating_component_base.js +3 -5
  83. package/dist/src/components/floating/floating_component_base.js.map +1 -1
  84. package/dist/src/components/floating/menu.d.ts.map +1 -1
  85. package/dist/src/components/floating/menu.js +11 -5
  86. package/dist/src/components/floating/menu.js.map +1 -1
  87. package/dist/src/components/floating/menu_common.d.ts +4 -4
  88. package/dist/src/components/floating/menu_common.d.ts.map +1 -1
  89. package/dist/src/components/floating/menu_common.js +1 -1
  90. package/dist/src/components/floating/menu_common.js.map +1 -1
  91. package/dist/src/components/floating/menu_components.d.ts.map +1 -1
  92. package/dist/src/components/floating/menu_components.js +9 -7
  93. package/dist/src/components/floating/menu_components.js.map +1 -1
  94. package/dist/src/components/floating/tooltip.d.ts +2 -2
  95. package/dist/src/components/floating/tooltip.d.ts.map +1 -1
  96. package/dist/src/components/floating/tooltip.js +10 -9
  97. package/dist/src/components/floating/tooltip.js.map +1 -1
  98. package/dist/src/components/floating/tooltip_content.d.ts.map +1 -1
  99. package/dist/src/components/floating/tooltip_content.js +3 -3
  100. package/dist/src/components/floating/tooltip_content.js.map +1 -1
  101. package/dist/src/components/icon_button.d.ts.map +1 -1
  102. package/dist/src/components/icon_button.js +10 -8
  103. package/dist/src/components/icon_button.js.map +1 -1
  104. package/dist/src/components/image.d.ts.map +1 -1
  105. package/dist/src/components/image.js +1 -1
  106. package/dist/src/components/image.js.map +1 -1
  107. package/dist/src/components/link.d.ts.map +1 -1
  108. package/dist/src/components/link.js +5 -5
  109. package/dist/src/components/link.js.map +1 -1
  110. package/dist/src/components/message.d.ts.map +1 -1
  111. package/dist/src/components/message.js +21 -21
  112. package/dist/src/components/message.js.map +1 -1
  113. package/dist/src/components/rating.d.ts.map +1 -1
  114. package/dist/src/components/rating.js +5 -6
  115. package/dist/src/components/rating.js.map +1 -1
  116. package/dist/src/components/readme_renderer/pythonize_value.d.ts.map +1 -1
  117. package/dist/src/components/readme_renderer/pythonize_value.js +10 -6
  118. package/dist/src/components/readme_renderer/pythonize_value.js.map +1 -1
  119. package/dist/src/components/readme_renderer/table_of_contents.d.ts.map +1 -1
  120. package/dist/src/components/readme_renderer/table_of_contents.js +16 -15
  121. package/dist/src/components/readme_renderer/table_of_contents.js.map +1 -1
  122. package/dist/src/components/readme_renderer/utils.d.ts.map +1 -1
  123. package/dist/src/components/readme_renderer/utils.js +6 -6
  124. package/dist/src/components/readme_renderer/utils.js.map +1 -1
  125. package/dist/src/components/select/select.d.ts.map +1 -1
  126. package/dist/src/components/select/select.js +14 -13
  127. package/dist/src/components/select/select.js.map +1 -1
  128. package/dist/src/components/shortcut.d.ts +1 -1
  129. package/dist/src/components/shortcut.d.ts.map +1 -1
  130. package/dist/src/components/shortcut.js +2 -2
  131. package/dist/src/components/shortcut.js.map +1 -1
  132. package/dist/src/components/simple_markdown/simple_markdown.d.ts.map +1 -1
  133. package/dist/src/components/simple_markdown/simple_markdown.js +32 -35
  134. package/dist/src/components/simple_markdown/simple_markdown.js.map +1 -1
  135. package/dist/src/components/simple_markdown/simple_markdown_components.d.ts.map +1 -1
  136. package/dist/src/components/simple_markdown/simple_markdown_components.js +26 -12
  137. package/dist/src/components/simple_markdown/simple_markdown_components.js.map +1 -1
  138. package/dist/src/components/spinner.d.ts.map +1 -1
  139. package/dist/src/components/spinner.js +3 -1
  140. package/dist/src/components/spinner.js.map +1 -1
  141. package/dist/src/components/store/store_actor_header.d.ts.map +1 -1
  142. package/dist/src/components/store/store_actor_header.js +1 -1
  143. package/dist/src/components/store/store_actor_header.js.map +1 -1
  144. package/dist/src/components/switch/switch.d.ts.map +1 -1
  145. package/dist/src/components/switch/switch.js +1 -1
  146. package/dist/src/components/switch/switch.js.map +1 -1
  147. package/dist/src/components/switch/switch.style.d.ts.map +1 -1
  148. package/dist/src/components/switch/switch.style.js +5 -3
  149. package/dist/src/components/switch/switch.style.js.map +1 -1
  150. package/dist/src/components/table/table.styled.js +3 -3
  151. package/dist/src/components/table/table.styled.js.map +1 -1
  152. package/dist/src/components/table/table_error_row.d.ts.map +1 -1
  153. package/dist/src/components/table/table_error_row.js +1 -1
  154. package/dist/src/components/table/table_error_row.js.map +1 -1
  155. package/dist/src/components/table/table_row.d.ts.map +1 -1
  156. package/dist/src/components/table/table_row.js +1 -1
  157. package/dist/src/components/table/table_row.js.map +1 -1
  158. package/dist/src/components/table/table_wrapper.d.ts.map +1 -1
  159. package/dist/src/components/table/table_wrapper.js +3 -3
  160. package/dist/src/components/table/table_wrapper.js.map +1 -1
  161. package/dist/src/components/tabs/tab.d.ts.map +1 -1
  162. package/dist/src/components/tabs/tab.js +7 -5
  163. package/dist/src/components/tabs/tab.js.map +1 -1
  164. package/dist/src/components/tabs/tabs.d.ts.map +1 -1
  165. package/dist/src/components/tabs/tabs.js +3 -3
  166. package/dist/src/components/tabs/tabs.js.map +1 -1
  167. package/dist/src/components/tag.d.ts +1 -1
  168. package/dist/src/components/tag.d.ts.map +1 -1
  169. package/dist/src/components/tag.js +1 -1
  170. package/dist/src/components/tag.js.map +1 -1
  171. package/dist/src/components/text/heading_content.d.ts.map +1 -1
  172. package/dist/src/components/text/heading_content.js +1 -1
  173. package/dist/src/components/text/heading_content.js.map +1 -1
  174. package/dist/src/components/text/heading_marketing.d.ts.map +1 -1
  175. package/dist/src/components/text/heading_marketing.js +1 -1
  176. package/dist/src/components/text/heading_marketing.js.map +1 -1
  177. package/dist/src/components/text/heading_shared.d.ts.map +1 -1
  178. package/dist/src/components/text/heading_shared.js +1 -1
  179. package/dist/src/components/text/heading_shared.js.map +1 -1
  180. package/dist/src/components/text/index.d.ts +1 -1
  181. package/dist/src/components/text/index.d.ts.map +1 -1
  182. package/dist/src/components/text/text_base.d.ts.map +1 -1
  183. package/dist/src/components/text/text_base.js +16 -12
  184. package/dist/src/components/text/text_base.js.map +1 -1
  185. package/dist/src/components/text/text_content.d.ts.map +1 -1
  186. package/dist/src/components/text/text_content.js +1 -1
  187. package/dist/src/components/text/text_content.js.map +1 -1
  188. package/dist/src/components/text/text_marketing.d.ts.map +1 -1
  189. package/dist/src/components/text/text_marketing.js +1 -1
  190. package/dist/src/components/text/text_marketing.js.map +1 -1
  191. package/dist/src/components/text/text_shared.d.ts +1 -1
  192. package/dist/src/components/text/text_shared.d.ts.map +1 -1
  193. package/dist/src/components/text/text_shared.js +1 -1
  194. package/dist/src/components/text/text_shared.js.map +1 -1
  195. package/dist/src/components/tile/horizontal_tile.d.ts.map +1 -1
  196. package/dist/src/components/tile/horizontal_tile.js +3 -2
  197. package/dist/src/components/tile/horizontal_tile.js.map +1 -1
  198. package/dist/src/components/tile/shared.d.ts +1 -1
  199. package/dist/src/components/tile/shared.d.ts.map +1 -1
  200. package/dist/src/components/tile/vertical_tile.d.ts.map +1 -1
  201. package/dist/src/components/tile/vertical_tile.js +3 -2
  202. package/dist/src/components/tile/vertical_tile.js.map +1 -1
  203. package/dist/src/components/to_consolidate/card.d.ts.map +1 -1
  204. package/dist/src/components/to_consolidate/card.js +20 -15
  205. package/dist/src/components/to_consolidate/card.js.map +1 -1
  206. package/dist/src/components/to_consolidate/markdown.d.ts.map +1 -1
  207. package/dist/src/components/to_consolidate/markdown.js +36 -20
  208. package/dist/src/components/to_consolidate/markdown.js.map +1 -1
  209. package/dist/src/components/to_consolidate/pagination.d.ts.map +1 -1
  210. package/dist/src/components/to_consolidate/pagination.js +6 -6
  211. package/dist/src/components/to_consolidate/pagination.js.map +1 -1
  212. package/dist/src/components/to_consolidate/tab_number_chip.d.ts.map +1 -1
  213. package/dist/src/components/to_consolidate/tab_number_chip.js +1 -1
  214. package/dist/src/components/to_consolidate/tab_number_chip.js.map +1 -1
  215. package/dist/src/design_system/theme.d.ts.map +1 -1
  216. package/dist/src/design_system/theme.js +1 -1
  217. package/dist/src/design_system/theme.js.map +1 -1
  218. package/dist/src/design_system/typography_theme.d.ts.map +1 -1
  219. package/dist/src/design_system/typography_theme.js.map +1 -1
  220. package/dist/src/ui_dependency_provider.d.ts.map +1 -1
  221. package/dist/src/ui_dependency_provider.js +2 -2
  222. package/dist/src/ui_dependency_provider.js.map +1 -1
  223. package/dist/tsconfig.build.tsbuildinfo +1 -1
  224. package/package.json +8 -6
  225. package/src/codemods/generate_typograpy_tokens_files.mjs +23 -28
  226. package/src/components/action_link.tsx +13 -23
  227. package/src/components/actor_template_card.stories.tsx +20 -14
  228. package/src/components/actor_template_card.tsx +4 -21
  229. package/src/components/avatar/actor_avatar.tsx +3 -4
  230. package/src/components/avatar/boring_avatar.tsx +134 -167
  231. package/src/components/avatar/user_avatar.stories.tsx +1 -5
  232. package/src/components/avatar/user_avatar.tsx +6 -20
  233. package/src/components/badge.stories.jsx +26 -40
  234. package/src/components/badge.tsx +37 -26
  235. package/src/components/banner.stories.tsx +10 -28
  236. package/src/components/banner.tsx +11 -14
  237. package/src/components/blog_article.tsx +6 -4
  238. package/src/components/box.tsx +90 -89
  239. package/src/components/breadcrumb/breadcrumb.stories.tsx +2 -8
  240. package/src/components/breadcrumb/breadcrumb.tsx +7 -5
  241. package/src/components/button.stories.tsx +70 -66
  242. package/src/components/button.tsx +33 -39
  243. package/src/components/card_container.stories.tsx +28 -29
  244. package/src/components/card_container.tsx +15 -10
  245. package/src/components/checkbox/checkbox.stories.tsx +52 -17
  246. package/src/components/checkbox/checkbox.style.ts +7 -4
  247. package/src/components/checkbox/checkbox.tsx +6 -9
  248. package/src/components/chip.stories.tsx +15 -5
  249. package/src/components/chip.tsx +26 -16
  250. package/src/components/code/action_button.tsx +10 -12
  251. package/src/components/code/code_block/code_block.stories.jsx +7 -25
  252. package/src/components/code/code_block/code_block.styled.tsx +26 -19
  253. package/src/components/code/code_block/code_block.tsx +26 -24
  254. package/src/components/code/code_block/code_block_with_tabs.stories.tsx +12 -18
  255. package/src/components/code/code_block/code_block_with_tabs.tsx +30 -16
  256. package/src/components/code/code_block/utils.tsx +23 -15
  257. package/src/components/code/inline_code/inline_code.stories.tsx +18 -10
  258. package/src/components/code/inline_code/inline_code.tsx +16 -21
  259. package/src/components/code/one_light_theme.ts +2 -17
  260. package/src/components/code/one_line_code/one_line_code.stories.tsx +31 -19
  261. package/src/components/code/one_line_code/one_line_code.tsx +19 -30
  262. package/src/components/code/prism_highlighter.tsx +117 -109
  263. package/src/components/code/prism_python.ts +4 -2
  264. package/src/components/collapsible_card/collapsible_card.stories.tsx +2 -1
  265. package/src/components/collapsible_card/collapsible_card.tsx +30 -15
  266. package/src/components/color_wheel_gradient.tsx +9 -7
  267. package/src/components/floating/floating_component_base.tsx +16 -9
  268. package/src/components/floating/menu.tsx +37 -46
  269. package/src/components/floating/menu_common.tsx +24 -30
  270. package/src/components/floating/menu_components.tsx +24 -24
  271. package/src/components/floating/tooltip.stories.jsx +85 -68
  272. package/src/components/floating/tooltip.tsx +32 -39
  273. package/src/components/floating/tooltip_content.tsx +8 -16
  274. package/src/components/icon_button.stories.tsx +176 -188
  275. package/src/components/icon_button.tsx +72 -58
  276. package/src/components/image.tsx +5 -11
  277. package/src/components/link.stories.tsx +4 -2
  278. package/src/components/link.tsx +70 -70
  279. package/src/components/message.stories.jsx +35 -33
  280. package/src/components/message.tsx +45 -45
  281. package/src/components/rating.tsx +37 -44
  282. package/src/components/readme_renderer/pythonize_value.ts +19 -7
  283. package/src/components/readme_renderer/table_of_contents.stories.tsx +40 -15
  284. package/src/components/readme_renderer/table_of_contents.tsx +87 -85
  285. package/src/components/readme_renderer/utils.tsx +17 -13
  286. package/src/components/select/select.stories.tsx +19 -46
  287. package/src/components/select/select.tsx +103 -101
  288. package/src/components/shortcut.stories.jsx +23 -14
  289. package/src/components/shortcut.tsx +2 -13
  290. package/src/components/simple_markdown/simple_markdown.stories.tsx +5 -10
  291. package/src/components/simple_markdown/simple_markdown.tsx +152 -55
  292. package/src/components/simple_markdown/simple_markdown_components.tsx +49 -59
  293. package/src/components/spinner.stories.tsx +14 -8
  294. package/src/components/spinner.tsx +5 -3
  295. package/src/components/store/store_actor_header.stories.tsx +2 -11
  296. package/src/components/store/store_actor_header.tsx +20 -16
  297. package/src/components/switch/switch.stories.jsx +4 -12
  298. package/src/components/switch/switch.style.ts +5 -3
  299. package/src/components/switch/switch.tsx +3 -13
  300. package/src/components/table/table.stories.tsx +5 -2
  301. package/src/components/table/table.styled.ts +3 -3
  302. package/src/components/table/table_error_row.tsx +5 -1
  303. package/src/components/table/table_row.tsx +1 -5
  304. package/src/components/table/table_wrapper.tsx +12 -12
  305. package/src/components/tabs/tab.stories.tsx +1 -5
  306. package/src/components/tabs/tab.tsx +33 -13
  307. package/src/components/tabs/tabs.tsx +14 -18
  308. package/src/components/tag.stories.jsx +35 -45
  309. package/src/components/tag.tsx +18 -22
  310. package/src/components/text/heading_content.stories.tsx +13 -24
  311. package/src/components/text/heading_content.tsx +3 -7
  312. package/src/components/text/heading_marketing.stories.tsx +4 -3
  313. package/src/components/text/heading_marketing.tsx +12 -8
  314. package/src/components/text/heading_shared.stories.tsx +3 -2
  315. package/src/components/text/heading_shared.tsx +3 -7
  316. package/src/components/text/index.ts +1 -3
  317. package/src/components/text/text_base.tsx +29 -35
  318. package/src/components/text/text_content.stories.tsx +17 -13
  319. package/src/components/text/text_content.tsx +20 -23
  320. package/src/components/text/text_marketing.stories.tsx +4 -3
  321. package/src/components/text/text_marketing.tsx +20 -23
  322. package/src/components/text/text_shared.stories.tsx +4 -3
  323. package/src/components/text/text_shared.tsx +23 -27
  324. package/src/components/tile/horizontal_tile.stories.tsx +6 -2
  325. package/src/components/tile/horizontal_tile.tsx +5 -15
  326. package/src/components/tile/shared.ts +5 -5
  327. package/src/components/tile/vertical_tile.stories.tsx +10 -18
  328. package/src/components/tile/vertical_tile.tsx +4 -9
  329. package/src/components/to_consolidate/card.stories.tsx +3 -1
  330. package/src/components/to_consolidate/card.tsx +67 -58
  331. package/src/components/to_consolidate/markdown.tsx +76 -62
  332. package/src/components/to_consolidate/pagination.tsx +11 -15
  333. package/src/components/to_consolidate/tab_number_chip.tsx +5 -6
  334. package/src/design_system/colors/build_color_tokens.js +7 -15
  335. package/src/design_system/theme.ts +1 -8
  336. package/src/design_system/tokens/radiuses.stories.tsx +9 -1
  337. package/src/design_system/tokens/shadows.stories.tsx +3 -1
  338. package/src/design_system/typography_theme.ts +78 -39
  339. package/src/ui_dependency_provider.tsx +16 -23
@@ -11,24 +11,12 @@ import {
11
11
  } from '@floating-ui/react';
12
12
  import clsx from 'clsx';
13
13
  import type React from 'react';
14
- import {
15
- useCallback,
16
- useMemo,
17
- useRef,
18
- useState,
19
- } from 'react';
14
+ import { useCallback, useMemo, useRef, useState } from 'react';
20
15
 
21
- import {
22
- Box,
23
- type BoxProps,
24
- } from '../box.js';
16
+ import { Box, type BoxProps } from '../box.js';
25
17
  import { Text } from '../text/index.js';
26
18
  import { useFloatingMenu } from './menu_common.js';
27
- import {
28
- DropdownMenuBaseComponent,
29
- ListMenuComponent,
30
- ListMenuItemComponent,
31
- } from './menu_components.js';
19
+ import { DropdownMenuBaseComponent, ListMenuComponent, ListMenuItemComponent } from './menu_components.js';
32
20
 
33
21
  export const menuClassNames = {
34
22
  WRAPPER: 'menu-wrapper',
@@ -42,28 +30,28 @@ type SelectActionType = 'click' | 'enter' | 'space' | 'type';
42
30
  // It might be tempting to define label as ReactNode, but we need to have the string value for keyboard navigation
43
31
  // More difficult cases can be handled using renderOption prop
44
32
  export interface MenuOption {
45
- label: string,
46
- value: string,
33
+ label: string;
34
+ value: string;
47
35
  }
48
36
 
49
37
  export interface MenuProps<T = MenuOption> {
50
- ariaLabel?: string,
51
- options: T[],
52
- value?: string,
53
- onSelect: (newValue: string, selectedBy: SelectActionType) => void,
54
- onMenuOpen?: (isOpen: boolean) => void,
55
- defaultLabel?: React.ReactNode,
56
- closeOnSelect?: boolean,
57
- renderOption?: (option: T) => React.ReactNode,
58
- placement?: Placement,
38
+ ariaLabel?: string;
39
+ options: T[];
40
+ value?: string;
41
+ onSelect: (newValue: string, selectedBy: SelectActionType) => void;
42
+ onMenuOpen?: (isOpen: boolean) => void;
43
+ defaultLabel?: React.ReactNode;
44
+ closeOnSelect?: boolean;
45
+ renderOption?: (option: T) => React.ReactNode;
46
+ placement?: Placement;
59
47
  components?: {
60
- MenuBase?: React.ElementType,
61
- Menu?: React.ElementType,
62
- MenuItem?: React.ElementType,
63
- },
48
+ MenuBase?: React.ElementType;
49
+ Menu?: React.ElementType;
50
+ MenuItem?: React.ElementType;
51
+ };
64
52
  }
65
53
 
66
- const defaultRenderOption = ({ label }: MenuOption) => (<Text as='span'>{label}</Text>);
54
+ const defaultRenderOption = ({ label }: MenuOption) => <Text as="span">{label}</Text>;
67
55
 
68
56
  /**
69
57
  * This example is a Select taken from https://floating-ui.com/docs/react-examples
@@ -84,12 +72,15 @@ export const Menu = <T extends MenuOption>({
84
72
  ...rest
85
73
  }: MenuProps<T> & BoxProps) => {
86
74
  const [isOpen, setIsOpenState] = useState(false);
87
- const setIsOpen = useCallback((newIsOpen: boolean) => {
88
- setIsOpenState(newIsOpen);
89
- if (onMenuOpen) {
90
- onMenuOpen(newIsOpen);
91
- }
92
- }, [onMenuOpen]);
75
+ const setIsOpen = useCallback(
76
+ (newIsOpen: boolean) => {
77
+ setIsOpenState(newIsOpen);
78
+ if (onMenuOpen) {
79
+ onMenuOpen(newIsOpen);
80
+ }
81
+ },
82
+ [onMenuOpen],
83
+ );
93
84
  const { refs, floatingStyles, context } = useFloatingMenu({
94
85
  isOpen,
95
86
  setIsOpen,
@@ -131,7 +122,13 @@ export const Menu = <T extends MenuOption>({
131
122
  loop: true,
132
123
  });
133
124
 
134
- const { getFloatingProps, getItemProps, getReferenceProps } = useInteractions([click, dismiss, role, listNav, typeahead]);
125
+ const { getFloatingProps, getItemProps, getReferenceProps } = useInteractions([
126
+ click,
127
+ dismiss,
128
+ role,
129
+ listNav,
130
+ typeahead,
131
+ ]);
135
132
 
136
133
  const MenuBaseComponent = components?.MenuBase || DropdownMenuBaseComponent;
137
134
  const MenuComponent = components?.Menu || ListMenuComponent;
@@ -140,10 +137,7 @@ export const Menu = <T extends MenuOption>({
140
137
  const effectiveRenderOption = renderOption || defaultRenderOption;
141
138
 
142
139
  return (
143
- <Box
144
- className={clsx(className, menuClassNames.WRAPPER)}
145
- {...rest}
146
- >
140
+ <Box className={clsx(className, menuClassNames.WRAPPER)} {...rest}>
147
141
  <MenuBaseComponent
148
142
  aria-label={ariaLabel}
149
143
  aria-labelledby={ariaLabel ? undefined : 'select-label'}
@@ -157,10 +151,7 @@ export const Menu = <T extends MenuOption>({
157
151
  </MenuBaseComponent>
158
152
  {isOpen && (
159
153
  <FloatingPortal>
160
- <FloatingFocusManager
161
- context={context}
162
- modal={false}
163
- >
154
+ <FloatingFocusManager context={context} modal={false}>
164
155
  <MenuComponent
165
156
  ref={refs.setFloating}
166
157
  style={floatingStyles}
@@ -1,36 +1,30 @@
1
- import type {
2
- Placement,
3
- } from '@floating-ui/react';
4
- import {
5
- autoUpdate,
6
- offset,
7
- size,
8
- useFloating,
9
- } from '@floating-ui/react';
1
+ import type { Placement } from '@floating-ui/react';
2
+ import { autoUpdate, offset, size, useFloating } from '@floating-ui/react';
10
3
 
11
4
  export const useFloatingMenu = ({
12
5
  isOpen,
13
6
  setIsOpen,
14
7
  placement = 'bottom-start',
15
8
  }: {
16
- isOpen: boolean,
17
- setIsOpen: (newIsOpen: boolean) => void,
18
- placement?: Placement,
19
- }) => useFloating<Element>({
20
- placement,
21
- open: isOpen,
22
- onOpenChange: setIsOpen,
23
- whileElementsMounted: autoUpdate,
24
- middleware: [
25
- offset(5),
26
- size({
27
- apply({ elements, availableHeight }) {
28
- Object.assign(elements.floating.style, {
29
- maxHeight: `${availableHeight}px`,
30
- minHeight: '50px',
31
- });
32
- },
33
- padding: 10,
34
- }),
35
- ],
36
- });
9
+ isOpen: boolean;
10
+ setIsOpen: (newIsOpen: boolean) => void;
11
+ placement?: Placement;
12
+ }) =>
13
+ useFloating<Element>({
14
+ placement,
15
+ open: isOpen,
16
+ onOpenChange: setIsOpen,
17
+ whileElementsMounted: autoUpdate,
18
+ middleware: [
19
+ offset(5),
20
+ size({
21
+ apply({ elements, availableHeight }) {
22
+ Object.assign(elements.floating.style, {
23
+ maxHeight: `${availableHeight}px`,
24
+ minHeight: '50px',
25
+ });
26
+ },
27
+ padding: 10,
28
+ }),
29
+ ],
30
+ });
@@ -1,7 +1,4 @@
1
- import {
2
- type ReferenceType,
3
- type UseFloatingReturn,
4
- } from '@floating-ui/react';
1
+ import { type ReferenceType, type UseFloatingReturn } from '@floating-ui/react';
5
2
  import { forwardRef } from 'react';
6
3
  import styled, { css } from 'styled-components';
7
4
 
@@ -34,8 +31,8 @@ export const ListMenuComponent = styled(Box).attrs({
34
31
  `;
35
32
 
36
33
  interface SelectableListMenuItemProps {
37
- $isActive?: boolean,
38
- $isSelected?: boolean,
34
+ $isActive?: boolean;
35
+ $isSelected?: boolean;
39
36
  }
40
37
 
41
38
  /**
@@ -49,14 +46,18 @@ export const ListMenuItemComponent = styled(Box).attrs({
49
46
  cursor: pointer;
50
47
  white-space: nowrap;
51
48
 
52
- ${({ $isActive }) => $isActive && css`
53
- background-color: ${theme.color.neutral.hover};
54
- `}
49
+ ${({ $isActive }) =>
50
+ $isActive &&
51
+ css`
52
+ background-color: ${theme.color.neutral.hover};
53
+ `}
55
54
 
56
- ${({ $isSelected }) => $isSelected && css`
57
- background-color: ${theme.color.neutral.backgroundSubtle};
58
- color: ${theme.color.primary.text};
59
- `}
55
+ ${({ $isSelected }) =>
56
+ $isSelected &&
57
+ css`
58
+ background-color: ${theme.color.neutral.backgroundSubtle};
59
+ color: ${theme.color.primary.text};
60
+ `}
60
61
  `;
61
62
 
62
63
  /**
@@ -86,14 +87,13 @@ type DropdownMenuBaseComponentProps = {
86
87
  /**
87
88
  * Menu base component WITH dropdown icon
88
89
  */
89
- export const DropdownMenuBaseComponent = forwardRef<HTMLElement, DropdownMenuBaseComponentProps>(({
90
- children,
91
- ...props
92
- }, ref) => {
93
- return (
94
- <PlainMenuBaseComponent {...props} ref={ref}>
95
- {children}
96
- <ChevronDownIcon size="16" color={theme.color.neutral.icon} />
97
- </PlainMenuBaseComponent>
98
- );
99
- });
90
+ export const DropdownMenuBaseComponent = forwardRef<HTMLElement, DropdownMenuBaseComponentProps>(
91
+ ({ children, ...props }, ref) => {
92
+ return (
93
+ <PlainMenuBaseComponent {...props} ref={ref}>
94
+ {children}
95
+ <ChevronDownIcon size="16" color={theme.color.neutral.icon} />
96
+ </PlainMenuBaseComponent>
97
+ );
98
+ },
99
+ );
@@ -6,11 +6,14 @@ import { Tooltip } from './tooltip.tsx';
6
6
 
7
7
  const Child = () => <div style={{ padding: '8px', border: '1px solid black', borderRadius: '4px' }}>Hover me</div>;
8
8
 
9
- const longText = 'This is a tooltip with a longer text. This is a tooltip with a longer text. This is a tooltip with a longer text.';
10
- const longTextWithLinks = <div style={{ display: 'inline' }}>
11
- This is a tooltip with a longer text. This is a tooltip with a longer text. This is a tooltip with a longer text and finally we have a{' '}
12
- <a href="https://www.example.com">link</a>.
13
- </div>;
9
+ const longText =
10
+ 'This is a tooltip with a longer text. This is a tooltip with a longer text. This is a tooltip with a longer text.';
11
+ const longTextWithLinks = (
12
+ <div style={{ display: 'inline' }}>
13
+ This is a tooltip with a longer text. This is a tooltip with a longer text. This is a tooltip with a longer text
14
+ and finally we have a <a href="https://www.example.com">link</a>.
15
+ </div>
16
+ );
14
17
 
15
18
  export default {
16
19
  title: 'UI-Library/Tooltip',
@@ -43,77 +46,91 @@ const DefaultStoryWrapper = styled.div`
43
46
  `;
44
47
 
45
48
  export const Default = (args) => {
46
- return (<DefaultStoryWrapper>
47
- <div>
48
- <Tooltip {...args}/>
49
- Default
50
- </div>
51
- <div>
52
- <Tooltip shortcuts={['Ctrl / ⌘', 'F']} {...args}/>
53
- With shortcuts
54
- </div>
55
- <div>
56
- <Tooltip subtleText="This is some subtle text" {...args} />
57
- With subtleText
58
- </div>
59
- <div>
60
- <Tooltip imageUrl='https://picsum.photos/id/1/1024' {...args} />
61
- With image
62
- </div>
63
- <div>
64
- <Tooltip
65
- persistent={{ isOpenOverride: true }}
66
- shortcuts={['Ctrl / ⌘', 'F']}
67
- content={longText}
68
- textAlign='center'
69
- ><Child /></Tooltip>
70
- With shortcuts and long centered text
71
- </div>
72
- <div>
73
- <Tooltip
74
- persistent={{ isOpenOverride: true }}
75
- shortcuts={['Ctrl / ⌘', 'F']}
76
- imageUrl='https://picsum.photos/id/1/1024'
77
- subtleText="This is some subtle text"
78
- placement={FLOATING_PLACEMENT.BOTTOM}
79
- content={longTextWithLinks}
80
- ><Child /></Tooltip>
81
- With everything
82
- </div>
83
- </DefaultStoryWrapper>
49
+ return (
50
+ <DefaultStoryWrapper>
51
+ <div>
52
+ <Tooltip {...args} />
53
+ Default
54
+ </div>
55
+ <div>
56
+ <Tooltip shortcuts={['Ctrl / ⌘', 'F']} {...args} />
57
+ With shortcuts
58
+ </div>
59
+ <div>
60
+ <Tooltip subtleText="This is some subtle text" {...args} />
61
+ With subtleText
62
+ </div>
63
+ <div>
64
+ <Tooltip imageUrl="https://picsum.photos/id/1/1024" {...args} />
65
+ With image
66
+ </div>
67
+ <div>
68
+ <Tooltip
69
+ persistent={{ isOpenOverride: true }}
70
+ shortcuts={['Ctrl / ⌘', 'F']}
71
+ content={longText}
72
+ textAlign="center"
73
+ >
74
+ <Child />
75
+ </Tooltip>
76
+ With shortcuts and long centered text
77
+ </div>
78
+ <div>
79
+ <Tooltip
80
+ persistent={{ isOpenOverride: true }}
81
+ shortcuts={['Ctrl / ⌘', 'F']}
82
+ imageUrl="https://picsum.photos/id/1/1024"
83
+ subtleText="This is some subtle text"
84
+ placement={FLOATING_PLACEMENT.BOTTOM}
85
+ content={longTextWithLinks}
86
+ >
87
+ <Child />
88
+ </Tooltip>
89
+ With everything
90
+ </div>
91
+ </DefaultStoryWrapper>
84
92
  );
85
93
  };
86
94
 
87
95
  export const Sizes = () => {
88
- return (<DefaultStoryWrapper>
89
- <div>
90
- Xsmall:
91
- <Tooltip size="xsmall" content={longText}><Child /></Tooltip>
92
- </div>
93
- <div>
94
- Small (default):
95
- <Tooltip size="small" content={longText}><Child /></Tooltip>
96
- </div>
97
- <div>
98
- Medium:
99
- <Tooltip size="medium" content={longText}><Child /></Tooltip>
100
- </div>
101
- <div>
102
- Large:
103
- <Tooltip size="large" content={longText}><Child /></Tooltip>
104
- </div>
105
- <div>
106
- Xlarge:
107
- <Tooltip size="xlarge" content={longText}><Child /></Tooltip>
108
- </div>
109
- </DefaultStoryWrapper>
96
+ return (
97
+ <DefaultStoryWrapper>
98
+ <div>
99
+ Xsmall:
100
+ <Tooltip size="xsmall" content={longText}>
101
+ <Child />
102
+ </Tooltip>
103
+ </div>
104
+ <div>
105
+ Small (default):
106
+ <Tooltip size="small" content={longText}>
107
+ <Child />
108
+ </Tooltip>
109
+ </div>
110
+ <div>
111
+ Medium:
112
+ <Tooltip size="medium" content={longText}>
113
+ <Child />
114
+ </Tooltip>
115
+ </div>
116
+ <div>
117
+ Large:
118
+ <Tooltip size="large" content={longText}>
119
+ <Child />
120
+ </Tooltip>
121
+ </div>
122
+ <div>
123
+ Xlarge:
124
+ <Tooltip size="xlarge" content={longText}>
125
+ <Child />
126
+ </Tooltip>
127
+ </div>
128
+ </DefaultStoryWrapper>
110
129
  );
111
130
  };
112
131
 
113
132
  export const Playground = (args) => {
114
- return (
115
- <Tooltip {...args}/>
116
- );
133
+ return <Tooltip {...args} />;
117
134
  };
118
135
  Playground.argTypes = {
119
136
  content: { control: 'text' },
@@ -1,8 +1,4 @@
1
- import {
2
- useFloating,
3
- useHover,
4
- useInteractions,
5
- } from '@floating-ui/react';
1
+ import { useFloating, useHover, useInteractions } from '@floating-ui/react';
6
2
  import { type ComponentType, type ElementType, forwardRef, type ReactNode, useState } from 'react';
7
3
  import styled, { css } from 'styled-components';
8
4
 
@@ -16,17 +12,17 @@ export const TOOLTIP_TEXT_ALIGNS = {
16
12
  CENTER: 'center',
17
13
  } as const;
18
14
 
19
- export type TooltipTextAlign = typeof TOOLTIP_TEXT_ALIGNS[keyof typeof TOOLTIP_TEXT_ALIGNS];
15
+ export type TooltipTextAlign = (typeof TOOLTIP_TEXT_ALIGNS)[keyof typeof TOOLTIP_TEXT_ALIGNS];
20
16
 
21
17
  export const TOOLTIP_SIZES = {
22
18
  XSMALL: 'xsmall',
23
19
  SMALL: 'small',
24
20
  MEDIUM: 'medium',
25
- LARGE: 'large', /* Previously WIDE */
26
- XLARGE: 'xlarge', /* Previously WIDER */
21
+ LARGE: 'large' /* Previously WIDE */,
22
+ XLARGE: 'xlarge' /* Previously WIDER */,
27
23
  } as const;
28
24
 
29
- export type TooltipSize = typeof TOOLTIP_SIZES[keyof typeof TOOLTIP_SIZES];
25
+ export type TooltipSize = (typeof TOOLTIP_SIZES)[keyof typeof TOOLTIP_SIZES];
30
26
 
31
27
  export interface TooltipProps extends Omit<FloatingComponentBaseProps, 'isOpen' | 'size'> {
32
28
  as?: ElementType;
@@ -60,10 +56,12 @@ const StyledFloatingComponentBase = styled(FloatingComponentBase)<{ $isDarkTheme
60
56
  }
61
57
  }
62
58
 
63
- ${({ $isDarkTheme }) => $isDarkTheme && css`
64
- box-shadow: ${theme.shadow.shadow2};
65
- border: 1px solid ${theme.color.neutral.smallTooltipBorder};
66
- `}
59
+ ${({ $isDarkTheme }) =>
60
+ $isDarkTheme &&
61
+ css`
62
+ box-shadow: ${theme.shadow.shadow2};
63
+ border: 1px solid ${theme.color.neutral.smallTooltipBorder};
64
+ `}
67
65
  `;
68
66
 
69
67
  /**
@@ -103,42 +101,37 @@ export const Tooltip = ({
103
101
  const tooltipProps = {
104
102
  isOpen: open,
105
103
  ...rest,
106
- content: <TooltipContent
107
- content={tooltipSafeHtml(rest.content)}
108
- shortcuts={shortcuts}
109
- imageUrl={imageUrl}
110
- subtleText={subtleText}
111
- size={size}
112
- textAlign={textAlign}
113
- />,
104
+ content: (
105
+ <TooltipContent
106
+ content={tooltipSafeHtml(rest.content)}
107
+ shortcuts={shortcuts}
108
+ imageUrl={imageUrl}
109
+ subtleText={subtleText}
110
+ size={size}
111
+ textAlign={textAlign}
112
+ />
113
+ ),
114
114
  };
115
115
 
116
116
  return (
117
- <TooltipFocusArea
118
- as={as}
119
- className={className}
120
- ref={refs.setReference}
121
- {...getReferenceProps()}
122
- >
123
- <div
124
- ref={refs.setFloating}
125
- {...getFloatingProps()}
126
- >
127
- <StyledFloatingComponentBase
128
- {...tooltipProps}
129
- $isDarkTheme={uiTheme === 'DARK'}
130
- />
117
+ <TooltipFocusArea as={as} className={className} ref={refs.setReference} {...getReferenceProps()}>
118
+ <div ref={refs.setFloating} {...getFloatingProps()}>
119
+ <StyledFloatingComponentBase {...tooltipProps} $isDarkTheme={uiTheme === 'DARK'} />
131
120
  </div>
132
121
  </TooltipFocusArea>
133
122
  );
134
123
  };
135
124
 
136
- export function withTooltip<TProps extends Record<string, unknown> = Record<string, unknown>>(Component: ComponentType<TProps>) {
125
+ export function withTooltip<TProps extends Record<string, unknown> = Record<string, unknown>>(
126
+ Component: ComponentType<TProps>,
127
+ ) {
137
128
  const Enhanced = forwardRef<HTMLElement, TProps & WithTooltipProps>(({ tooltipProps, ...rest }, ref) => {
138
129
  if (!tooltipProps) return <Component {...(rest as unknown as TProps)} ref={ref} />;
139
- return <Tooltip {...tooltipProps}>
140
- <Component {...(rest as unknown as TProps)} ref={ref} />
141
- </Tooltip>;
130
+ return (
131
+ <Tooltip {...tooltipProps}>
132
+ <Component {...(rest as unknown as TProps)} ref={ref} />
133
+ </Tooltip>
134
+ );
142
135
  });
143
136
 
144
137
  Enhanced.displayName = `WithTooltip:${Component.displayName || Component.name}`;
@@ -22,7 +22,7 @@ const TOOLTIP_CLASSNAMES = {
22
22
  SHORTCUT_CONTAINER: 'Tooltip-shortcutContainer',
23
23
  } as const;
24
24
 
25
- const StyledContent = styled.div<{ $size: TooltipSize, $textAlign: TooltipTextAlign }>`
25
+ const StyledContent = styled.div<{ $size: TooltipSize; $textAlign: TooltipTextAlign }>`
26
26
  display: flex;
27
27
  flex-direction: column;
28
28
  gap: ${theme.space.space8};
@@ -45,13 +45,13 @@ const StyledContent = styled.div<{ $size: TooltipSize, $textAlign: TooltipTextAl
45
45
  align-items: ${({ $textAlign }) => ($textAlign === 'center' ? 'center' : 'flex-start')};
46
46
 
47
47
  /* When there is no child with subtleText class */
48
- &:not(:has(.${TOOLTIP_CLASSNAMES.SUBTLE_TEXT})){
48
+ &:not(:has(.${TOOLTIP_CLASSNAMES.SUBTLE_TEXT})) {
49
49
  flex-direction: row;
50
50
  flex-wrap: wrap;
51
51
  }
52
52
 
53
53
  /* When there is a child with subtleText class */
54
- &:has(.${TOOLTIP_CLASSNAMES.SUBTLE_TEXT}){
54
+ &:has(.${TOOLTIP_CLASSNAMES.SUBTLE_TEXT}) {
55
55
  text-align: left;
56
56
  }
57
57
 
@@ -81,24 +81,16 @@ export const TooltipContent = ({
81
81
  }: ContentProps) => {
82
82
  return (
83
83
  <StyledContent $size={size} $textAlign={textAlign}>
84
- {imageUrl && (
85
- <img
86
- src={imageUrl}
87
- alt=""
88
- className={TOOLTIP_CLASSNAMES.IMAGE}
89
- />
90
- )}
84
+ {imageUrl && <img src={imageUrl} alt="" className={TOOLTIP_CLASSNAMES.IMAGE} />}
91
85
  <div className={TOOLTIP_CLASSNAMES.TEXT_CONTENT}>
92
86
  {content}
93
- {subtleText && (
94
- <div className={TOOLTIP_CLASSNAMES.SUBTLE_TEXT}>
95
- {subtleText}
96
- </div>
97
- )}
87
+ {subtleText && <div className={TOOLTIP_CLASSNAMES.SUBTLE_TEXT}>{subtleText}</div>}
98
88
  {shortcuts.length > 0 && (
99
89
  <div className={TOOLTIP_CLASSNAMES.SHORTCUT_CONTAINER}>
100
90
  {shortcuts.map((shortcut, index) => (
101
- <Shortcut key={`${shortcut}-${index}`} dark>{shortcut}</Shortcut>
91
+ <Shortcut key={`${shortcut}-${index}`} dark>
92
+ {shortcut}
93
+ </Shortcut>
102
94
  ))}
103
95
  </div>
104
96
  )}