@elastic/eui 119.0.0 → 119.1.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 (285) hide show
  1. package/dist/eui-icons.json +93 -90
  2. package/dist/svgs/cursor_default.svg +3 -0
  3. package/dist/svgs/log_in.svg +4 -0
  4. package/dist/svgs/route_split.svg +3 -0
  5. package/es/components/avatar/avatar.js +1 -1
  6. package/es/components/badge/badge.js +1 -1
  7. package/es/components/badge/beta_badge/beta_badge.js +1 -1
  8. package/es/components/basic_table/basic_table.js +4 -4
  9. package/es/components/basic_table/in_memory_table.js +4 -4
  10. package/es/components/button/button.js +4 -2
  11. package/es/components/button/button_display/_button_display_content.js +1 -1
  12. package/es/components/button/button_empty/button_empty.js +1 -1
  13. package/es/components/button/button_group/button_group.js +87 -9
  14. package/es/components/button/button_group/button_group.styles.js +48 -9
  15. package/es/components/button/button_icon/button_icon.js +5 -3
  16. package/es/components/button/split_button/split_button.js +39 -16
  17. package/es/components/button/split_button/split_button.styles.js +28 -32
  18. package/es/components/button/split_button/split_button_actions.js +16 -5
  19. package/es/components/button/use_button_common_props.js +6 -2
  20. package/es/components/call_out/call_out.js +2 -2
  21. package/es/components/card/card.js +1 -1
  22. package/es/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
  23. package/es/components/comment_list/comment.js +2 -2
  24. package/es/components/comment_list/comment_event.js +1 -1
  25. package/es/components/comment_list/comment_list.js +2 -2
  26. package/es/components/comment_list/comment_timeline.js +1 -1
  27. package/es/components/context_menu/context_menu_item.js +1 -1
  28. package/es/components/datagrid/body/cell/data_grid_cell.js +24 -24
  29. package/es/components/datagrid/body/data_grid_body.js +13 -13
  30. package/es/components/datagrid/body/data_grid_body_custom.js +13 -13
  31. package/es/components/datagrid/body/data_grid_body_virtualized.js +13 -13
  32. package/es/components/datagrid/body/header/column_actions.js +3 -1
  33. package/es/components/datagrid/body/header/data_grid_header_cell.js +12 -12
  34. package/es/components/datagrid/controls/column_sorting.js +13 -13
  35. package/es/components/datagrid/controls/column_sorting_draggable.js +1 -1
  36. package/es/components/datagrid/controls/data_grid_toolbar_control.js +1 -1
  37. package/es/components/datagrid/utils/in_memory.js +12 -12
  38. package/es/components/date_picker/date_picker.js +2 -2
  39. package/es/components/date_picker/date_picker_range.js +1 -1
  40. package/es/components/empty_prompt/empty_prompt.js +1 -1
  41. package/es/components/flyout/flyout_menu/flyout_menu.js +39 -14
  42. package/es/components/form/field_number/field_number.js +2 -2
  43. package/es/components/form/field_text/field_text.js +2 -2
  44. package/es/components/form/file_picker/file_picker.js +187 -224
  45. package/es/components/form/file_picker/file_picker.styles.js +1 -1
  46. package/es/components/form/form_control_button/form_control_button.js +1 -1
  47. package/es/components/form/form_control_layout/append_prepend/form_append_prepend.js +2 -2
  48. package/es/components/form/form_control_layout/form_control_layout.js +2 -2
  49. package/es/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
  50. package/es/components/form/text_area/text_area.js +2 -2
  51. package/es/components/header/header_links/header_link.js +1 -1
  52. package/es/components/header/header_links/header_links.js +1 -1
  53. package/es/components/header/header_logo/header_logo.js +1 -1
  54. package/es/components/header/header_section/header_section_item_button.js +1 -1
  55. package/es/components/icon/assets/cursor_default.js +35 -0
  56. package/es/components/icon/assets/log_in.js +35 -0
  57. package/es/components/icon/assets/route_split.js +33 -0
  58. package/es/components/icon/icon.js +1 -1
  59. package/es/components/icon/icon_map.js +15 -0
  60. package/es/components/icon/svgs/cursor_default.svg +3 -0
  61. package/es/components/icon/svgs/log_in.svg +4 -0
  62. package/es/components/icon/svgs/route_split.svg +3 -0
  63. package/es/components/key_pad_menu/key_pad_menu_item.js +1 -1
  64. package/es/components/list_group/list_group.js +2 -2
  65. package/es/components/list_group/list_group_item.js +2 -2
  66. package/es/components/list_group/list_group_item_extra_action.js +1 -1
  67. package/es/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
  68. package/es/components/loading/loading_logo.js +1 -1
  69. package/es/components/markdown_editor/markdown_editor.js +1 -1
  70. package/es/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
  71. package/es/components/markdown_editor/markdown_editor_footer.js +1 -1
  72. package/es/components/markdown_editor/markdown_editor_toolbar.js +1 -1
  73. package/es/components/page/page_header/page_header_content.js +1 -1
  74. package/es/components/pagination/pagination_button.js +1 -1
  75. package/es/components/selectable/selectable_list/selectable_list.js +1 -1
  76. package/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
  77. package/es/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
  78. package/es/components/table/table_header_cell.js +1 -1
  79. package/es/components/timeline/timeline_item_icon.js +1 -1
  80. package/es/components/toast/global_toast_list.js +2 -2
  81. package/es/components/toast/toast.js +2 -2
  82. package/es/components/tool_tip/icon_tip.js +1 -1
  83. package/es/global_styling/mixins/_button.js +6 -0
  84. package/es/services/accessibility/html_id_generator.js +26 -1
  85. package/eui.d.ts +241 -329
  86. package/i18ntokens.json +2678 -2660
  87. package/lib/components/avatar/avatar.js +1 -1
  88. package/lib/components/badge/badge.js +1 -1
  89. package/lib/components/badge/beta_badge/beta_badge.js +1 -1
  90. package/lib/components/basic_table/basic_table.js +4 -4
  91. package/lib/components/basic_table/in_memory_table.js +4 -4
  92. package/lib/components/button/button.js +4 -2
  93. package/lib/components/button/button_display/_button_display_content.js +1 -1
  94. package/lib/components/button/button_empty/button_empty.js +1 -1
  95. package/lib/components/button/button_group/button_group.js +86 -10
  96. package/lib/components/button/button_group/button_group.styles.js +47 -8
  97. package/lib/components/button/button_icon/button_icon.js +5 -3
  98. package/lib/components/button/split_button/split_button.js +37 -15
  99. package/lib/components/button/split_button/split_button.styles.js +29 -31
  100. package/lib/components/button/split_button/split_button_actions.js +15 -4
  101. package/lib/components/button/use_button_common_props.js +6 -2
  102. package/lib/components/call_out/call_out.js +2 -2
  103. package/lib/components/card/card.js +1 -1
  104. package/lib/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
  105. package/lib/components/comment_list/comment.js +2 -2
  106. package/lib/components/comment_list/comment_event.js +1 -1
  107. package/lib/components/comment_list/comment_list.js +2 -2
  108. package/lib/components/comment_list/comment_timeline.js +1 -1
  109. package/lib/components/context_menu/context_menu_item.js +1 -1
  110. package/lib/components/datagrid/body/cell/data_grid_cell.js +24 -24
  111. package/lib/components/datagrid/body/data_grid_body.js +13 -13
  112. package/lib/components/datagrid/body/data_grid_body_custom.js +13 -13
  113. package/lib/components/datagrid/body/data_grid_body_virtualized.js +13 -13
  114. package/lib/components/datagrid/body/header/column_actions.js +3 -1
  115. package/lib/components/datagrid/body/header/data_grid_header_cell.js +12 -12
  116. package/lib/components/datagrid/controls/column_sorting.js +13 -13
  117. package/lib/components/datagrid/controls/column_sorting_draggable.js +1 -1
  118. package/lib/components/datagrid/controls/data_grid_toolbar_control.js +1 -1
  119. package/lib/components/datagrid/utils/in_memory.js +12 -12
  120. package/lib/components/date_picker/date_picker.js +2 -2
  121. package/lib/components/date_picker/date_picker_range.js +1 -1
  122. package/lib/components/empty_prompt/empty_prompt.js +1 -1
  123. package/lib/components/flyout/flyout_menu/flyout_menu.js +39 -14
  124. package/lib/components/form/field_number/field_number.js +2 -2
  125. package/lib/components/form/field_text/field_text.js +2 -2
  126. package/lib/components/form/file_picker/file_picker.js +193 -227
  127. package/lib/components/form/file_picker/file_picker.styles.js +1 -1
  128. package/lib/components/form/form_control_button/form_control_button.js +1 -1
  129. package/lib/components/form/form_control_layout/append_prepend/form_append_prepend.js +2 -2
  130. package/lib/components/form/form_control_layout/form_control_layout.js +2 -2
  131. package/lib/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
  132. package/lib/components/form/text_area/text_area.js +2 -2
  133. package/lib/components/header/header_links/header_link.js +1 -1
  134. package/lib/components/header/header_links/header_links.js +1 -1
  135. package/lib/components/header/header_logo/header_logo.js +1 -1
  136. package/lib/components/header/header_section/header_section_item_button.js +1 -1
  137. package/lib/components/icon/assets/cursor_default.js +42 -0
  138. package/lib/components/icon/assets/log_in.js +42 -0
  139. package/lib/components/icon/assets/route_split.js +40 -0
  140. package/lib/components/icon/icon.js +1 -1
  141. package/lib/components/icon/icon_map.js +21 -0
  142. package/lib/components/icon/svgs/cursor_default.svg +3 -0
  143. package/lib/components/icon/svgs/log_in.svg +4 -0
  144. package/lib/components/icon/svgs/route_split.svg +3 -0
  145. package/lib/components/key_pad_menu/key_pad_menu_item.js +1 -1
  146. package/lib/components/list_group/list_group.js +2 -2
  147. package/lib/components/list_group/list_group_item.js +2 -2
  148. package/lib/components/list_group/list_group_item_extra_action.js +1 -1
  149. package/lib/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
  150. package/lib/components/loading/loading_logo.js +1 -1
  151. package/lib/components/markdown_editor/markdown_editor.js +1 -1
  152. package/lib/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
  153. package/lib/components/markdown_editor/markdown_editor_footer.js +1 -1
  154. package/lib/components/markdown_editor/markdown_editor_toolbar.js +1 -1
  155. package/lib/components/page/page_header/page_header_content.js +1 -1
  156. package/lib/components/pagination/pagination_button.js +1 -1
  157. package/lib/components/selectable/selectable_list/selectable_list.js +1 -1
  158. package/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
  159. package/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
  160. package/lib/components/table/table_header_cell.js +1 -1
  161. package/lib/components/timeline/timeline_item_icon.js +1 -1
  162. package/lib/components/toast/global_toast_list.js +2 -2
  163. package/lib/components/toast/toast.js +2 -2
  164. package/lib/components/tool_tip/icon_tip.js +1 -1
  165. package/lib/global_styling/mixins/_button.js +6 -0
  166. package/lib/services/accessibility/html_id_generator.js +26 -1
  167. package/optimize/es/components/button/button.js +4 -2
  168. package/optimize/es/components/button/button_group/button_group.js +55 -8
  169. package/optimize/es/components/button/button_group/button_group.styles.js +48 -9
  170. package/optimize/es/components/button/button_icon/button_icon.js +4 -2
  171. package/optimize/es/components/button/split_button/split_button.js +36 -16
  172. package/optimize/es/components/button/split_button/split_button.styles.js +28 -32
  173. package/optimize/es/components/button/split_button/split_button_actions.js +16 -5
  174. package/optimize/es/components/button/use_button_common_props.js +6 -2
  175. package/optimize/es/components/datagrid/body/header/column_actions.js +3 -1
  176. package/optimize/es/components/flyout/flyout_menu/flyout_menu.js +32 -9
  177. package/optimize/es/components/form/file_picker/file_picker.js +182 -216
  178. package/optimize/es/components/form/file_picker/file_picker.styles.js +1 -1
  179. package/optimize/es/components/icon/assets/cursor_default.js +34 -0
  180. package/optimize/es/components/icon/assets/log_in.js +34 -0
  181. package/optimize/es/components/icon/assets/route_split.js +32 -0
  182. package/optimize/es/components/icon/icon_map.js +15 -0
  183. package/optimize/es/components/icon/svgs/cursor_default.svg +3 -0
  184. package/optimize/es/components/icon/svgs/log_in.svg +4 -0
  185. package/optimize/es/components/icon/svgs/route_split.svg +3 -0
  186. package/optimize/es/global_styling/mixins/_button.js +6 -0
  187. package/optimize/es/services/accessibility/html_id_generator.js +26 -1
  188. package/optimize/lib/components/button/button.js +4 -2
  189. package/optimize/lib/components/button/button_group/button_group.js +55 -9
  190. package/optimize/lib/components/button/button_group/button_group.styles.js +47 -8
  191. package/optimize/lib/components/button/button_icon/button_icon.js +4 -2
  192. package/optimize/lib/components/button/split_button/split_button.js +35 -15
  193. package/optimize/lib/components/button/split_button/split_button.styles.js +29 -31
  194. package/optimize/lib/components/button/split_button/split_button_actions.js +15 -4
  195. package/optimize/lib/components/button/use_button_common_props.js +6 -2
  196. package/optimize/lib/components/datagrid/body/header/column_actions.js +3 -1
  197. package/optimize/lib/components/flyout/flyout_menu/flyout_menu.js +32 -9
  198. package/optimize/lib/components/form/file_picker/file_picker.js +183 -215
  199. package/optimize/lib/components/form/file_picker/file_picker.styles.js +1 -1
  200. package/optimize/lib/components/icon/assets/cursor_default.js +42 -0
  201. package/optimize/lib/components/icon/assets/log_in.js +42 -0
  202. package/optimize/lib/components/icon/assets/route_split.js +40 -0
  203. package/optimize/lib/components/icon/icon_map.js +21 -0
  204. package/optimize/lib/components/icon/svgs/cursor_default.svg +3 -0
  205. package/optimize/lib/components/icon/svgs/log_in.svg +4 -0
  206. package/optimize/lib/components/icon/svgs/route_split.svg +3 -0
  207. package/optimize/lib/global_styling/mixins/_button.js +6 -0
  208. package/optimize/lib/services/accessibility/html_id_generator.js +26 -1
  209. package/package.json +11 -17
  210. package/test-env/components/avatar/avatar.js +1 -1
  211. package/test-env/components/badge/badge.js +1 -1
  212. package/test-env/components/badge/beta_badge/beta_badge.js +1 -1
  213. package/test-env/components/basic_table/basic_table.js +4 -4
  214. package/test-env/components/basic_table/in_memory_table.js +4 -4
  215. package/test-env/components/button/button.js +4 -2
  216. package/test-env/components/button/button_display/_button_display_content.js +1 -1
  217. package/test-env/components/button/button_empty/button_empty.js +1 -1
  218. package/test-env/components/button/button_group/button_group.js +84 -10
  219. package/test-env/components/button/button_group/button_group.styles.js +47 -8
  220. package/test-env/components/button/button_icon/button_icon.js +5 -3
  221. package/test-env/components/button/split_button/split_button.js +35 -15
  222. package/test-env/components/button/split_button/split_button.styles.js +29 -31
  223. package/test-env/components/button/split_button/split_button_actions.js +15 -4
  224. package/test-env/components/button/use_button_common_props.js +6 -2
  225. package/test-env/components/call_out/call_out.js +2 -2
  226. package/test-env/components/card/card.js +1 -1
  227. package/test-env/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
  228. package/test-env/components/comment_list/comment.js +2 -2
  229. package/test-env/components/comment_list/comment_event.js +1 -1
  230. package/test-env/components/comment_list/comment_list.js +2 -2
  231. package/test-env/components/comment_list/comment_timeline.js +1 -1
  232. package/test-env/components/context_menu/context_menu_item.js +1 -1
  233. package/test-env/components/datagrid/body/cell/data_grid_cell.js +24 -24
  234. package/test-env/components/datagrid/body/data_grid_body.js +13 -13
  235. package/test-env/components/datagrid/body/data_grid_body_custom.js +13 -13
  236. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +13 -13
  237. package/test-env/components/datagrid/body/header/column_actions.js +3 -1
  238. package/test-env/components/datagrid/body/header/data_grid_header_cell.js +12 -12
  239. package/test-env/components/datagrid/controls/column_sorting.js +13 -13
  240. package/test-env/components/datagrid/controls/column_sorting_draggable.js +1 -1
  241. package/test-env/components/datagrid/controls/data_grid_toolbar_control.js +1 -1
  242. package/test-env/components/datagrid/utils/in_memory.js +12 -12
  243. package/test-env/components/date_picker/date_picker.js +2 -2
  244. package/test-env/components/date_picker/date_picker_range.js +1 -1
  245. package/test-env/components/empty_prompt/empty_prompt.js +1 -1
  246. package/test-env/components/flyout/flyout_menu/flyout_menu.js +39 -14
  247. package/test-env/components/form/field_number/field_number.js +2 -2
  248. package/test-env/components/form/field_text/field_text.js +2 -2
  249. package/test-env/components/form/file_picker/file_picker.js +184 -216
  250. package/test-env/components/form/file_picker/file_picker.styles.js +1 -1
  251. package/test-env/components/form/form_control_button/form_control_button.js +1 -1
  252. package/test-env/components/form/form_control_layout/append_prepend/form_append_prepend.js +2 -2
  253. package/test-env/components/form/form_control_layout/form_control_layout.js +2 -2
  254. package/test-env/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
  255. package/test-env/components/form/text_area/text_area.js +2 -2
  256. package/test-env/components/header/header_links/header_link.js +1 -1
  257. package/test-env/components/header/header_links/header_links.js +1 -1
  258. package/test-env/components/header/header_logo/header_logo.js +1 -1
  259. package/test-env/components/header/header_section/header_section_item_button.js +1 -1
  260. package/test-env/components/icon/assets/cursor_default.js +42 -0
  261. package/test-env/components/icon/assets/log_in.js +42 -0
  262. package/test-env/components/icon/assets/route_split.js +40 -0
  263. package/test-env/components/icon/icon_map.js +21 -0
  264. package/test-env/components/key_pad_menu/key_pad_menu_item.js +1 -1
  265. package/test-env/components/list_group/list_group.js +2 -2
  266. package/test-env/components/list_group/list_group_item.js +2 -2
  267. package/test-env/components/list_group/list_group_item_extra_action.js +1 -1
  268. package/test-env/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
  269. package/test-env/components/loading/loading_logo.js +1 -1
  270. package/test-env/components/markdown_editor/markdown_editor.js +1 -1
  271. package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
  272. package/test-env/components/markdown_editor/markdown_editor_footer.js +1 -1
  273. package/test-env/components/markdown_editor/markdown_editor_toolbar.js +1 -1
  274. package/test-env/components/page/page_header/page_header_content.js +1 -1
  275. package/test-env/components/pagination/pagination_button.js +1 -1
  276. package/test-env/components/selectable/selectable_list/selectable_list.js +1 -1
  277. package/test-env/components/selectable/selectable_list/selectable_list_item.js +1 -1
  278. package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
  279. package/test-env/components/table/table_header_cell.js +1 -1
  280. package/test-env/components/timeline/timeline_item_icon.js +1 -1
  281. package/test-env/components/toast/global_toast_list.js +2 -2
  282. package/test-env/components/toast/toast.js +2 -2
  283. package/test-env/components/tool_tip/icon_tip.js +1 -1
  284. package/test-env/global_styling/mixins/_button.js +6 -0
  285. package/test-env/services/accessibility/html_id_generator.js +11 -0
@@ -8,6 +8,23 @@
8
8
 
9
9
  import React, { useMemo } from 'react';
10
10
  import { v1 as uuidv1 } from 'uuid';
11
+ import { warnOnce } from '../console';
12
+
13
+ /**
14
+ * IDs containing whitespace are invalid HTML, and silently break attributes
15
+ * that take a space-separated list of ID references (`aria-controls`,
16
+ * `aria-labelledby`, `aria-describedby`, `for`), as each "word" is then parsed
17
+ * as a separate reference to a non-existent element.
18
+ *
19
+ * This most commonly happens when a human-readable or localized string is
20
+ * passed as a prefix/suffix, so warn consumers as early as possible.
21
+ */
22
+ var warnOnWhitespace = function warnOnWhitespace(value) {
23
+ if (process.env.NODE_ENV === 'production') return;
24
+ if (value && /\s/.test(value)) {
25
+ warnOnce("generatedHtmlIdWhitespace:".concat(value), "[EUI] Generated HTML ID: \"".concat(value, "\" contains whitespace, which generates an invalid HTML id ") + 'and breaks attributes referencing it, such as `aria-controls` or `for`. ' + 'Pass a static identifier instead of a human-readable or localized string.');
26
+ }
27
+ };
11
28
 
12
29
  /**
13
30
  * This function returns a function to generate ids.
@@ -19,8 +36,10 @@ import { v1 as uuidv1 } from 'uuid';
19
36
  export function htmlIdGenerator() {
20
37
  var idPrefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
21
38
  var staticUuid = uuidv1();
39
+ warnOnWhitespace(idPrefix);
22
40
  return function () {
23
41
  var idSuffix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
42
+ warnOnWhitespace(idSuffix);
24
43
  var prefix = "".concat(idPrefix).concat(idPrefix !== '' ? '_' : 'i');
25
44
  var suffix = idSuffix ? "_".concat(idSuffix) : '';
26
45
  return "".concat(prefix).concat(suffix ? staticUuid : uuidv1()).concat(suffix);
@@ -53,7 +72,13 @@ var useNewGeneratedHtmlId = function useNewGeneratedHtmlId() {
53
72
  // to prevent React <18 import errors.
54
73
  var id = React.useId();
55
74
  return useMemo(function () {
56
- return conditionalId || "".concat(prefix).concat(id).concat(suffix);
75
+ if (conditionalId) return conditionalId;
76
+
77
+ // Memoized so that the check only runs when the prefix/suffix change,
78
+ // as this hook is called on virtually every EUI render
79
+ warnOnWhitespace(prefix);
80
+ warnOnWhitespace(suffix);
81
+ return "".concat(prefix).concat(id).concat(suffix);
57
82
  }, [id, conditionalId, prefix, suffix]);
58
83
  };
59
84
  export var useGeneratedHtmlId = 'useId' in React ? useNewGeneratedHtmlId : useDeprecatedGeneratedHtmlId;
@@ -38,7 +38,7 @@ var EuiButton = exports.EuiButton = function EuiButton(_ref) {
38
38
  _size = _ref$size === void 0 ? 'm' : _ref$size,
39
39
  _ref$color = _ref.color,
40
40
  _color = _ref$color === void 0 ? 'primary' : _ref$color,
41
- fill = _ref.fill,
41
+ _fill = _ref.fill,
42
42
  _isDisabled = _ref.isDisabled,
43
43
  _hasAriaDisabled = _ref.hasAriaDisabled,
44
44
  _fullWidth = _ref.fullWidth,
@@ -49,6 +49,7 @@ var EuiButton = exports.EuiButton = function EuiButton(_ref) {
49
49
  isDisabled: _isDisabled,
50
50
  hasAriaDisabled: _hasAriaDisabled,
51
51
  fullWidth: _fullWidth,
52
+ fill: _fill,
52
53
  href: rest.href,
53
54
  disabled: rest.disabled,
54
55
  isLoading: rest.isLoading
@@ -57,7 +58,8 @@ var EuiButton = exports.EuiButton = function EuiButton(_ref) {
57
58
  color = _useEuiButtonCommonPr.color,
58
59
  isDisabled = _useEuiButtonCommonPr.isDisabled,
59
60
  hasAriaDisabled = _useEuiButtonCommonPr.hasAriaDisabled,
60
- fullWidth = _useEuiButtonCommonPr.fullWidth;
61
+ fullWidth = _useEuiButtonCommonPr.fullWidth,
62
+ fill = _useEuiButtonCommonPr.fill;
61
63
  var buttonColorStyles = (0, _button.useEuiButtonColorCSS)({
62
64
  display: fill ? 'fill' : 'base'
63
65
  })[isDisabled ? 'disabled' : color];
@@ -5,7 +5,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.EuiButtonGroup = exports.BUTTON_GROUP_GUTTER_SIZES = void 0;
8
+ exports.EuiButtonGroupChildren = exports.EuiButtonGroup = exports.BUTTON_GROUP_GUTTER_SIZES = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
12
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -17,7 +18,7 @@ var _button_context = require("../button_context");
17
18
  var _button_group = require("./button_group.styles");
18
19
  var _react2 = require("@emotion/react");
19
20
  var _excluded = ["className", "buttonSize", "color", "idSelected", "idToSelectedMap", "isDisabled", "hasAriaDisabled", "isFullWidth", "isIconOnly", "legend", "name", "onChange", "options", "type"],
20
- _excluded2 = ["className", "children", "legend", "buttonSize", "variant", "gutterSize", "isDisabled", "hasAriaDisabled", "isFullWidth", "onChange"];
21
+ _excluded2 = ["className", "children", "legend", "buttonSize", "variant", "gutterSize", "isDisabled", "hasAriaDisabled", "isFullWidth", "showDividers", "wrap", "layout", "onChange"];
21
22
  /*
22
23
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
24
  * or more contributor license agreements. Licensed under the Elastic License
@@ -25,8 +26,26 @@ var _excluded = ["className", "buttonSize", "color", "idSelected", "idToSelected
25
26
  * in compliance with, at your election, the Elastic License 2.0 or the Server
26
27
  * Side Public License, v 1.
27
28
  */
29
+ // removes outer fragment wrappers only; no nested traversal of children
30
+ // uses forEach over .toArray() to avoid mutating keys; only unwraps one Fragment level
28
31
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
29
32
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
33
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
34
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
35
+ function flattenButtonGroupChildren(children) {
36
+ var result = [];
37
+ _react.default.Children.forEach(children, function (child) {
38
+ if (! /*#__PURE__*/_react.default.isValidElement(child)) return;
39
+ if (child.type === _react.default.Fragment) {
40
+ _react.default.Children.forEach(child.props.children, function (fragmentChild) {
41
+ if ( /*#__PURE__*/_react.default.isValidElement(fragmentChild)) result.push(fragmentChild);
42
+ });
43
+ } else {
44
+ result.push(child);
45
+ }
46
+ });
47
+ return result;
48
+ }
30
49
  var EuiButtonGroupOptions = function EuiButtonGroupOptions(_ref) {
31
50
  var className = _ref.className,
32
51
  _ref$buttonSize = _ref.buttonSize,
@@ -89,9 +108,9 @@ var EuiButtonGroupOptions = function EuiButtonGroupOptions(_ref) {
89
108
  })));
90
109
  };
91
110
  var BUTTON_GROUP_GUTTER_SIZES = exports.BUTTON_GROUP_GUTTER_SIZES = ['none', 'xs', 's', 'm', 'l', 'xl'];
92
- var EuiButtonGroupChildren = function EuiButtonGroupChildren(_ref2) {
111
+ var EuiButtonGroupChildren = exports.EuiButtonGroupChildren = function EuiButtonGroupChildren(_ref2) {
93
112
  var className = _ref2.className,
94
- children = _ref2.children,
113
+ _children = _ref2.children,
95
114
  legend = _ref2.legend,
96
115
  _ref2$buttonSize = _ref2.buttonSize,
97
116
  buttonSize = _ref2$buttonSize === void 0 ? 's' : _ref2$buttonSize,
@@ -105,36 +124,63 @@ var EuiButtonGroupChildren = function EuiButtonGroupChildren(_ref2) {
105
124
  hasAriaDisabled = _ref2$hasAriaDisabled === void 0 ? false : _ref2$hasAriaDisabled,
106
125
  _ref2$isFullWidth = _ref2.isFullWidth,
107
126
  isFullWidth = _ref2$isFullWidth === void 0 ? false : _ref2$isFullWidth,
127
+ _ref2$showDividers = _ref2.showDividers,
128
+ showDividers = _ref2$showDividers === void 0 ? false : _ref2$showDividers,
129
+ _ref2$wrap = _ref2.wrap,
130
+ wrap = _ref2$wrap === void 0 ? true : _ref2$wrap,
131
+ _ref2$layout = _ref2.layout,
132
+ layout = _ref2$layout === void 0 ? 'horizontal' : _ref2$layout,
108
133
  _onChange = _ref2.onChange,
109
134
  rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
135
+ var isSegmented = variant === 'segmented';
136
+ var hasGutterSize = variant === 'default' && gutterSize !== 'none';
110
137
  var wrapperCssStyles = [_button_group.euiButtonGroupStyles.euiButtonGroup, isFullWidth && _button_group.euiButtonGroupStyles.fullWidth];
111
138
  var styles = (0, _services.useEuiMemoizedStyles)(_button_group.euiButtonGroupButtonsStyles);
112
- var cssStyles = [styles.euiButtonGroup__buttons, isFullWidth && styles.fullWidth, gutterSize && gutterSize !== 'none' && styles.gutterSize[gutterSize]];
139
+ var cssStyles = [styles.euiButtonGroup__buttons, hasGutterSize && styles.gutterSize[gutterSize], isSegmented && !wrap && styles.noWrap];
140
+ var containerCssStyles = [styles.euiButtonGroup__container, isFullWidth && layout !== 'vertical' && styles.fullWidth];
113
141
  var classes = (0, _classnames.default)('euiButtonGroup', {
114
142
  'euiButtonGroup-isDisabled': isDisabled
115
143
  }, className);
116
144
  var contextValue = (0, _react.useMemo)(function () {
117
- return {
145
+ return _objectSpread({
118
146
  size: buttonSize,
119
147
  isDisabled: isDisabled || undefined,
120
148
  hasAriaDisabled: hasAriaDisabled || undefined,
121
149
  fullWidth: isFullWidth
122
- };
123
- }, [buttonSize, isDisabled, hasAriaDisabled, isFullWidth]);
150
+ }, isSegmented && {
151
+ display: 'base',
152
+ color: 'text',
153
+ fill: false
154
+ });
155
+ }, [buttonSize, isDisabled, hasAriaDisabled, isFullWidth, isSegmented]);
156
+
157
+ // wrap children in a wrapper to be able to apply required styles
158
+ var children = isSegmented ? flattenButtonGroupChildren(_children).map(function (child, index) {
159
+ var _child$key;
160
+ return (0, _react2.jsx)("div", {
161
+ key: (_child$key = child.key) !== null && _child$key !== void 0 ? _child$key : "euiButtonGroupItem-".concat(index),
162
+ className: "euiButtonGroup__item"
163
+ }, child);
164
+ }) : _children;
124
165
  return (0, _react2.jsx)("div", (0, _extends2.default)({
125
166
  css: wrapperCssStyles,
126
167
  className: classes,
127
168
  role: "group",
128
169
  "data-variant": variant,
129
170
  "data-size": buttonSize,
171
+ "data-layout": isSegmented ? layout : undefined,
172
+ "data-dividers": isSegmented && showDividers || undefined,
130
173
  "aria-label": legend,
131
174
  "aria-disabled": isDisabled || undefined
132
175
  }, rest), (0, _react2.jsx)("div", {
176
+ css: containerCssStyles,
177
+ className: "euiButtonGroup__container"
178
+ }, (0, _react2.jsx)("div", {
133
179
  css: cssStyles,
134
180
  className: "euiButtonGroup__buttons"
135
181
  }, (0, _react2.jsx)(_button_context.EuiButtonContext.Provider, {
136
182
  value: contextValue
137
- }, children)));
183
+ }, children))));
138
184
  };
139
185
 
140
186
  /* Overloaded call signatures let one `EuiButtonGroup` component support both
@@ -15,8 +15,12 @@ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringif
15
15
  * in compliance with, at your election, the Elastic License 2.0 or the Server
16
16
  * Side Public License, v 1.
17
17
  */
18
+ var hasButtonOnlySelector = ':not(:has(.euiButtonIcon))';
19
+ var hasButtonIconOnlySelector = ':not(:has(.euiButton, .euiButtonEmpty))';
20
+ var buttonItemSelector = '.euiButtonGroup__item, .euiToolTipAnchor, .euiPopover, .euiButton';
21
+ var buttonOnlyItemSelector = "*:is(".concat(buttonItemSelector, "):not(:has(.euiButtonIcon))");
18
22
  var euiButtonGroupStyles = exports.euiButtonGroupStyles = {
19
- euiButtonGroup: /*#__PURE__*/(0, _react.css)("display:inline-block;", (0, _global_styling.logicalCSS)('max-width', '100%'), " position:relative;;label:euiButtonGroup;"),
23
+ euiButtonGroup: /*#__PURE__*/(0, _react.css)("display:inline-block;", (0, _global_styling.logicalCSS)('max-width', '100%'), " position:relative;&:where([data-variant='segmented']){&", hasButtonIconOnlySelector, "{display:flex;}};label:euiButtonGroup;"),
20
24
  fullWidth: process.env.NODE_ENV === "production" ? {
21
25
  name: "jl0hie-fullWidth",
22
26
  styles: "display:block;label:fullWidth;"
@@ -28,23 +32,58 @@ var euiButtonGroupStyles = exports.euiButtonGroupStyles = {
28
32
  };
29
33
  var euiButtonGroupButtonsStyles = exports.euiButtonGroupButtonsStyles = function euiButtonGroupButtonsStyles(euiThemeContext) {
30
34
  var euiTheme = euiThemeContext.euiTheme;
31
- var buttonSizes = {
32
- s: "\n border-radius: ".concat(euiTheme.border.radius.small, ";\n ").concat(_highContrastStyles(euiThemeContext), "\n "),
33
- m: "\n border-radius: ".concat(euiTheme.border.radius.medium, ";\n ").concat(_highContrastStyles(euiThemeContext), "\n ")
35
+ var buttonSizeMap = (0, _global_styling.euiButtonSizeMap)(euiThemeContext);
36
+ var containerPadding = euiTheme.size.xs;
37
+ var splitPadding = (0, _global_styling.mathWithUnits)(containerPadding, function (x) {
38
+ return x / 2;
39
+ });
40
+ var insetSize = function insetSize(height) {
41
+ return (0, _global_styling.mathWithUnits)([height, containerPadding], function (x, y) {
42
+ return x - y * 2;
43
+ });
34
44
  };
45
+ var buttonGroupVariables = {
46
+ gap: {
47
+ regular: euiTheme.size.xs,
48
+ dividers: (0, _global_styling.mathWithUnits)([euiTheme.size.xs, euiTheme.border.width.thin], function (x, y) {
49
+ return x + y;
50
+ })
51
+ },
52
+ // TODO: use from buttonSizeMap once added via EuiSplitButton:
53
+ // https://github.com/elastic/eui/pull/9865
54
+ radius: {
55
+ outer: euiTheme.border.radius.medium,
56
+ inner: '2px' // should eventually be a token, but currently small and medium have the same value
57
+ },
58
+ size: {
59
+ s: insetSize(buttonSizeMap.s.height),
60
+ m: insetSize(buttonSizeMap.m.height)
61
+ }
62
+ };
63
+ var dividerOffset = (0, _global_styling.mathWithUnits)([buttonGroupVariables.gap.dividers, euiTheme.border.width.thin], function (x, y) {
64
+ return (x + y) / 2;
65
+ });
35
66
  var _euiFormVariables = (0, _form.euiFormVariables)(euiThemeContext),
36
67
  controlCompressedHeight = _euiFormVariables.controlCompressedHeight,
37
68
  controlCompressedBorderRadius = _euiFormVariables.controlCompressedBorderRadius,
38
69
  backgroundColor = _euiFormVariables.backgroundColor,
39
70
  borderColor = _euiFormVariables.borderColor;
71
+ var dividerStyles = "\n gap: ".concat(buttonGroupVariables.gap.dividers, ";\n\n .euiButtonGroup__item {\n position: relative;\n\n /* block border */\n &::before {\n content: '';\n position: absolute;\n inset-block-start: -").concat(dividerOffset, ";\n inset-inline-start: -").concat((0, _global_styling.mathWithUnits)(containerPadding, function (x) {
72
+ return x / 2;
73
+ }), ";\n inline-size: calc(\n 100% + ").concat((0, _global_styling.mathWithUnits)(containerPadding, function (x) {
74
+ return x * 2;
75
+ }), "\n );\n block-size: ").concat(euiTheme.border.width.thin, ";\n border-block-start: ").concat(euiTheme.border.width.thin, " solid\n ").concat(euiTheme.colors.borderBasePlain, ";\n pointer-events: none;\n }\n\n /* inline border */\n &::after {\n content: '';\n position: absolute;\n inset-inline-start: -").concat(dividerOffset, ";\n block-size: calc(\n var(--euiButtonGroupButtonInsetSize) - ").concat(euiTheme.size.s, "\n );\n inline-size: ").concat(euiTheme.border.width.thin, ";\n border-inline-start: ").concat(euiTheme.border.width.thin, " solid\n ").concat(euiTheme.colors.borderBasePlain, ";\n pointer-events: none;\n }\n }\n\n &:where([data-layout='horizontal'] &) {\n &:where(:is(").concat(hasButtonIconOnlySelector, ") &) {\n .euiButtonGroup__item::before {\n inset-inline-start: 0;\n inline-size: 100%;\n }\n }\n }\n\n &:where([data-layout='vertical'] &) {\n &:where(:is(").concat(hasButtonIconOnlySelector, ") &) {\n .euiButtonGroup__item::before {\n inset-inline-start: auto;\n inline-size: calc(\n var(--euiButtonGroupButtonInsetSize) - ").concat(euiTheme.size.s, "\n );\n }\n }\n }\n ");
76
+ var segmentedChildrenStyles = "\n /* Buttons are used inset and shouldn't have their own borders */\n .euiButton,\n .euiButtonIcon {\n border: none;\n pointer-events: auto; /* Ensure buttons are still clickable in jsdom */\n\n &::before {\n border-radius: inherit;\n }\n }\n\n /* Adjust children for inset behavior */\n ".concat(buttonItemSelector, ", \n .euiButtonIcon {\n display: inline-flex;\n align-items: center;\n block-size: var(--euiButtonGroupButtonInsetSize);\n border-radius: ").concat(buttonGroupVariables.radius.inner, ";\n }\n\n .euiButtonIcon {\n inline-size: var(--euiButtonGroupButtonInsetSize);\n }\n\n /* Only non-icon buttons auto-grow/shrink */\n .euiButton,\n ").concat(buttonOnlyItemSelector, " {\n flex: 1;\n min-inline-size: auto;\n }\n ");
40
77
  return {
41
78
  // Base
42
- euiButtonGroup__buttons: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('max-width', '100%'), " display:flex;align-items:center;&:where([data-variant='default'] &){flex-wrap:wrap;}&:where([data-size='s'] &){", buttonSizes.s, ";}&:where([data-size='m'] &){", buttonSizes.m, ";};label:euiButtonGroup__buttons;"),
43
- fullWidth: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('width', '100%'), " .euiButtonGroupButton,.euiButtonGroup__tooltipWrapper{flex:1;", (0, _global_styling.logicalCSS)('width', '100%'), ";}.euiButton{flex-grow:1;inline-size:auto;}.euiButtonEmpty{flex-shrink:0;};label:fullWidth;"),
79
+ euiButtonGroup__container: /*#__PURE__*/(0, _react.css)("&:where([data-variant='segmented'] &){position:relative;display:inline-flex;align-items:center;max-inline-size:100%;padding:", splitPadding, ";border-radius:", buttonGroupVariables.radius.outer, ";background-color:", euiTheme.colors.backgroundBasePlain, ";&:where([data-size='s'] &){--euiButtonGroupButtonInsetSize:", buttonGroupVariables.size.s, ";min-block-size:", buttonSizeMap.s.height, ";}&:where([data-size='m'] &){--euiButtonGroupButtonInsetSize:", buttonGroupVariables.size.m, ";min-block-size:", buttonSizeMap.m.height, ";}&::after{content:'';position:absolute;inset:0;border:", euiTheme.border.width.thin, " solid ", euiTheme.colors.borderBasePlain, ";border-radius:inherit;pointer-events:none;}};label:euiButtonGroup__container;"),
80
+ euiButtonGroup__buttons: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('max-width', '100%'), " display:flex;align-items:center;&:where([data-variant='default'] &){flex-wrap:wrap;}&:where([data-variant='segmented'] &){position:relative;display:inline-flex;align-items:center;flex-wrap:wrap;gap:", buttonGroupVariables.gap.regular, ";max-inline-size:100%;padding:", splitPadding, ";overflow:hidden;*:where(.euiButton, .euiButtonIcon):is(", _global_styling.euiDisabledSelector, "){background-color:transparent;}&:where([data-dividers='true'] &){", dividerStyles, ";}", segmentedChildrenStyles, " &:where([data-layout='vertical'] &){flex-direction:column;.euiButtonGroup__item{justify-content:center;}}};label:euiButtonGroup__buttons;"),
81
+ noWrap: /*#__PURE__*/(0, _react.css)("&:where([data-variant='segmented'] &){flex-wrap:nowrap;", buttonOnlyItemSelector, "{flex:0 1 auto;min-inline-size:0;.euiButton .eui-textTruncate{min-inline-size:0;}}&", hasButtonIconOnlySelector, "{overflow-inline:auto;}};label:noWrap;"),
82
+ fullWidth: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('width', '100%'), " .euiButtonGroupButton,.euiButtonGroup__tooltipWrapper{flex:1;", (0, _global_styling.logicalCSS)('width', '100%'), ";}&:where([data-variant='default'] &){.euiButton{flex-grow:1;inline-size:auto;}.euiButtonEmpty{flex-shrink:0;}}&:where([data-variant='segmented'] &){&", hasButtonIconOnlySelector, "{inline-size:auto;}&", hasButtonOnlySelector, "{.euiButtonGroup__buttons{inline-size:100%;}", buttonOnlyItemSelector, "{flex-grow:1;}}};label:fullWidth;"),
44
83
  // Sizes
45
84
  size: {
46
- m: /*#__PURE__*/(0, _react.css)(buttonSizes.m, ";;label:m;"),
47
- s: /*#__PURE__*/(0, _react.css)(buttonSizes.s, ";;label:s;"),
85
+ m: /*#__PURE__*/(0, _react.css)("border-radius:", euiTheme.border.radius.medium, ";", _highContrastStyles(euiThemeContext), ";;label:m;"),
86
+ s: /*#__PURE__*/(0, _react.css)("border-radius:", euiTheme.border.radius.small, ";", _highContrastStyles(euiThemeContext), ";;label:s;"),
48
87
  compressed: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('height', controlCompressedHeight), " background-color:", backgroundColor, ";border:", euiTheme.border.width.thin, " solid ", borderColor, ";border-radius:", controlCompressedBorderRadius, ";", _highContrastStyles(euiThemeContext, true), ";;label:compressed;")
49
88
  },
50
89
  gutterSize: {
@@ -42,7 +42,7 @@ var EuiButtonIcon = exports.EuiButtonIcon = function EuiButtonIcon(_ref) {
42
42
  _ref$type = _ref.type,
43
43
  type = _ref$type === void 0 ? 'button' : _ref$type,
44
44
  _ref$display = _ref.display,
45
- display = _ref$display === void 0 ? 'empty' : _ref$display,
45
+ _display = _ref$display === void 0 ? 'empty' : _ref$display,
46
46
  target = _ref.target,
47
47
  rel = _ref.rel,
48
48
  _ref$size = _ref.size,
@@ -56,6 +56,7 @@ var EuiButtonIcon = exports.EuiButtonIcon = function EuiButtonIcon(_ref) {
56
56
  color: _color,
57
57
  isDisabled: _isDisabled,
58
58
  hasAriaDisabled: _hasAriaDisabled,
59
+ display: _display,
59
60
  href: href,
60
61
  disabled: disabled,
61
62
  isLoading: isLoading
@@ -64,7 +65,8 @@ var EuiButtonIcon = exports.EuiButtonIcon = function EuiButtonIcon(_ref) {
64
65
  color = _useEuiButtonCommonPr.color,
65
66
  isDisabled = _useEuiButtonCommonPr.isDisabled,
66
67
  _useEuiButtonCommonPr2 = _useEuiButtonCommonPr.hasAriaDisabled,
67
- hasAriaDisabled = _useEuiButtonCommonPr2 === void 0 ? false : _useEuiButtonCommonPr2;
68
+ hasAriaDisabled = _useEuiButtonCommonPr2 === void 0 ? false : _useEuiButtonCommonPr2,
69
+ display = _useEuiButtonCommonPr.display;
68
70
  var _useEuiDisabledElemen = (0, _useEuiDisabledElement.useEuiDisabledElement)({
69
71
  isDisabled: isDisabled,
70
72
  hasAriaDisabled: hasAriaDisabled,
@@ -7,10 +7,12 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports._EuiSplitButton = exports.EuiSplitButton = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
11
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
13
  var _classnames = _interopRequireDefault(require("classnames"));
13
14
  var _react = _interopRequireWildcard(require("react"));
15
+ var _euiThemeCommon = require("@elastic/eui-theme-common");
14
16
  var _services = require("../../../services");
15
17
  var _global_styling = require("../../../global_styling");
16
18
  var _split_button_context = require("./split_button_context");
@@ -27,6 +29,8 @@ var _excluded = ["className", "children", "size", "color", "fill", "isDisabled",
27
29
  */
28
30
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
29
31
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
32
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
33
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
30
34
  var _EuiSplitButton = exports._EuiSplitButton = function _EuiSplitButton(_ref) {
31
35
  var className = _ref.className,
32
36
  children = _ref.children,
@@ -41,29 +45,41 @@ var _EuiSplitButton = exports._EuiSplitButton = function _EuiSplitButton(_ref) {
41
45
  isLoading = _ref.isLoading,
42
46
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
43
47
  var euiThemeContext = (0, _services.useEuiTheme)();
44
- var highContrastMode = euiThemeContext.highContrastMode;
48
+ var euiTheme = euiThemeContext.euiTheme,
49
+ highContrastMode = euiThemeContext.highContrastMode;
45
50
  var _children = (0, _slicedToArray2.default)(children, 2),
46
51
  primaryAction = _children[0],
47
52
  secondaryAction = _children[1];
48
53
  var key = (0, _services.useGeneratedHtmlId)({
49
54
  suffix: 'EuiSplitButton'
50
55
  });
51
- var commonProps = {
52
- size: size,
53
- color: color,
54
- fill: fill,
55
- isDisabled: isDisabled,
56
- hasAriaDisabled: hasAriaDisabled,
57
- isLoading: isLoading
58
- };
56
+ var commonProps = (0, _react.useMemo)(function () {
57
+ return {
58
+ size: size,
59
+ color: color,
60
+ fill: fill,
61
+ isDisabled: isDisabled,
62
+ hasAriaDisabled: hasAriaDisabled,
63
+ isLoading: isLoading
64
+ };
65
+ }, [size, color, fill, isDisabled, hasAriaDisabled, isLoading]);
59
66
  var buttonFilledColors = (0, _global_styling.getEuiFilledButtonColorValues)(euiThemeContext, isDisabled ? 'disabled' : color);
60
67
  var buttonColors = (0, _global_styling.getEuiButtonColorValues)(euiThemeContext, isDisabled ? 'disabled' : color);
68
+ var borderToken = color === 'text' ? 'borderBasePlain' : (0, _euiThemeCommon.getTokenName)('borderBase', color);
61
69
  var classes = (0, _classnames.default)('euiSplitButton', className);
62
- var styles = (0, _services.useEuiMemoizedStyles)(_split_button.euiSplitButtonStyles);
63
- var cssStyles = [styles.euiSplitButton, fill && styles.fill];
70
+ var styles = (0, _react.useMemo)(function () {
71
+ return (0, _split_button.euiSplitButtonStyles)(euiThemeContext, fill ? buttonFilledColors.backgroundColor : buttonColors.backgroundColor);
72
+ }, [euiThemeContext, fill, buttonFilledColors.backgroundColor, buttonColors.backgroundColor]);
73
+ var cssStyles = [styles.euiSplitButton, (color === 'text' || highContrastMode) && styles.hasBorder];
74
+ var dividerColor = color === 'warning' && fill ? buttonFilledColors.color : euiTheme.colors[borderToken];
64
75
  var dividerStyles = (0, _react.useMemo)(function () {
65
- return (0, _split_button.euiSplitButtonDividerStyles)(euiThemeContext, !fill ? buttonColors.borderColor : highContrastMode && fill ? buttonFilledColors.backgroundColor : 'transparent');
66
- }, [euiThemeContext, highContrastMode, fill, buttonFilledColors.backgroundColor, buttonColors.borderColor]);
76
+ return (0, _split_button.euiSplitButtonDividerStyles)(euiThemeContext, highContrastMode && fill ? buttonFilledColors.color : dividerColor);
77
+ }, [euiThemeContext, highContrastMode, fill, buttonFilledColors.color, dividerColor]);
78
+ var cssVariables = (0, _react.useMemo)(function () {
79
+ return {
80
+ '--euiSplitButtonBorderColor': dividerColor
81
+ };
82
+ }, [dividerColor]);
67
83
 
68
84
  // NOTE: dev-mode-only runtime check to evaluate if correct child components are passed
69
85
  if (process.env.NODE_ENV !== 'production') {
@@ -81,8 +97,12 @@ var _EuiSplitButton = exports._EuiSplitButton = function _EuiSplitButton(_ref) {
81
97
  return (0, _react2.jsx)("div", (0, _extends2.default)({
82
98
  role: "group",
83
99
  className: classes,
84
- css: cssStyles
85
- }, rest), (0, _react2.jsx)(_split_button_context.EuiSplitButtonContext.Provider, {
100
+ css: cssStyles,
101
+ "data-size": size,
102
+ "data-fill": fill || undefined
103
+ }, rest, {
104
+ style: _objectSpread({}, cssVariables)
105
+ }), (0, _react2.jsx)(_split_button_context.EuiSplitButtonContext.Provider, {
86
106
  value: commonProps
87
107
  }, (0, _react2.jsx)(_react.Fragment, {
88
108
  key: "".concat(key, "-primaryAction")
@@ -6,50 +6,48 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.euiSplitButtonStyles = exports.euiSplitButtonDividerStyles = exports.euiSplitButtonActionStyles = void 0;
7
7
  var _react = require("@emotion/react");
8
8
  var _global_styling = require("../../../global_styling");
9
- function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; } /*
9
+ /*
10
10
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
11
11
  * or more contributor license agreements. Licensed under the Elastic License
12
12
  * 2.0 and the Server Side Public License, v 1; you may not use this file except
13
13
  * in compliance with, at your election, the Elastic License 2.0 or the Server
14
14
  * Side Public License, v 1.
15
15
  */
16
- var euiSplitButtonStyles = exports.euiSplitButtonStyles = function euiSplitButtonStyles(euiThemeContext) {
16
+
17
+ var primaryDisabledSelector = ".euiSplitButtonActionPrimary:is(".concat(_global_styling.euiDisabledSelector, ")");
18
+ var secondaryDisabledSelector = ".euiSplitButtonActionSecondary:is(".concat(_global_styling.euiDisabledSelector, ")");
19
+ var euiSplitButtonStyles = exports.euiSplitButtonStyles = function euiSplitButtonStyles(euiThemeContext, backgroundColor) {
17
20
  var euiTheme = euiThemeContext.euiTheme;
18
- var primaryDisabledSelector = ".euiSplitButtonActionPrimary:is(".concat(_global_styling.euiDisabledSelector, ")");
19
- var secondaryDisabledSelector = ".euiSplitButtonActionSecondary:is(".concat(_global_styling.euiDisabledSelector, ")");
20
- var dividerSelector = ".euiSplitButton__divider";
21
+ var buttonSizeMap = (0, _global_styling.euiButtonSizeMap)(euiThemeContext);
22
+ var borderStyles = function borderStyles(color) {
23
+ return "\n &::after {\n content: '';\n position: absolute;\n inset: 0;\n border: ".concat(euiTheme.border.width.thin, " solid ").concat(color, ";\n border-radius: ").concat(euiTheme.border.radius.small, ";\n pointer-events: none;\n }\n ");
24
+ };
21
25
  return {
22
- euiSplitButton: /*#__PURE__*/(0, _react.css)("display:inline-flex;flex-wrap:nowrap;&:has(", primaryDisabledSelector, "):has(", secondaryDisabledSelector, "){", dividerSelector, "{", (0, _global_styling.highContrastModeStyles)(euiThemeContext, {
23
- // When both buttons are disabled set as visual gap
24
- none: "\n border-color: transparent;\n ",
25
- // When both buttons are disabled set a disabled divider color
26
- preferred: "\n border-color: ".concat(euiTheme.colors.borderBaseDisabled, ";\n ")
27
- }), ";}};label:euiSplitButton;"),
28
- // When both buttons are enabled set as visual gap
29
- fill: /*#__PURE__*/(0, _react.css)("&:not(:has(", primaryDisabledSelector, ")):not(\n :has(", secondaryDisabledSelector, ")\n ){", dividerSelector, "{border-color:transparent;}};label:fill;")
26
+ euiSplitButton: /*#__PURE__*/(0, _react.css)("position:relative;display:inline-flex;align-items:center;flex-wrap:nowrap;max-inline-size:fit-content;padding:", euiTheme.size.xs, ";border-radius:", euiTheme.border.radius.small, ";background-color:", backgroundColor, ";&:where([data-size='s']){block-size:", buttonSizeMap.s.height, ";}&:where([data-size='m']){block-size:", buttonSizeMap.m.height, ";}&:has(", primaryDisabledSelector, ", ", secondaryDisabledSelector, "){background-color:", euiTheme.colors.backgroundBaseDisabled, ";};label:euiSplitButton;"),
27
+ hasBorder: /*#__PURE__*/(0, _react.css)((0, _global_styling.highContrastModeStyles)(euiThemeContext, {
28
+ none: "\n &:where(:not([data-fill])):not(:has(".concat(primaryDisabledSelector, ", ").concat(secondaryDisabledSelector, ")) {\n ").concat(borderStyles("var(--euiSplitButtonBorderColor)"), "\n }\n "),
29
+ preferred: "\n &:where(:not([data-fill])) {\n ".concat(borderStyles("var(--euiSplitButtonBorderColor)"), "\n\n &:has(").concat(primaryDisabledSelector, ", ").concat(secondaryDisabledSelector, ") {\n ").concat(borderStyles(euiTheme.colors.borderBaseDisabled), "\n }\n }\n\n &:where([data-fill]):has(").concat(primaryDisabledSelector, ", ").concat(secondaryDisabledSelector, ") {\n ").concat(borderStyles(euiTheme.colors.borderBaseDisabled), "\n }\n "),
30
+ forced: "\n ".concat(borderStyles("var(--euiSplitButtonBorderColor)"), "\n ")
31
+ }), ";;label:hasBorder;")
30
32
  };
31
33
  };
32
- var euiSplitButtonActionStyles = exports.euiSplitButtonActionStyles = {
33
- euiSplitButtonActionPrimary: process.env.NODE_ENV === "production" ? {
34
- name: "12txneb-euiSplitButtonActionPrimary",
35
- styles: "z-index:0;border-inline-end:none;border-start-end-radius:0;border-end-end-radius:0;label:euiSplitButtonActionPrimary;"
36
- } : {
37
- name: "12txneb-euiSplitButtonActionPrimary",
38
- styles: "z-index:0;border-inline-end:none;border-start-end-radius:0;border-end-end-radius:0;label:euiSplitButtonActionPrimary;",
39
- toString: _EMOTION_STRINGIFIED_CSS_ERROR__
40
- },
41
- euiSplitButtonActionSecondary: process.env.NODE_ENV === "production" ? {
42
- name: "5uh4vx-euiSplitButtonActionSecondary",
43
- styles: "border-inline-start:none;border-start-start-radius:0;border-end-start-radius:0;label:euiSplitButtonActionSecondary;"
44
- } : {
45
- name: "5uh4vx-euiSplitButtonActionSecondary",
46
- styles: "border-inline-start:none;border-start-start-radius:0;border-end-start-radius:0;label:euiSplitButtonActionSecondary;",
47
- toString: _EMOTION_STRINGIFIED_CSS_ERROR__
48
- }
34
+ var euiSplitButtonActionStyles = exports.euiSplitButtonActionStyles = function euiSplitButtonActionStyles(euiThemeContext, size) {
35
+ var euiTheme = euiThemeContext.euiTheme;
36
+ var buttonSizeMap = (0, _global_styling.euiButtonSizeMap)(euiThemeContext);
37
+
38
+ // uses smaller sizes due to the buttons being inset into the parent container
39
+ var buttonSize = size === 's' ? buttonSizeMap.xs.height : buttonSizeMap.s.height;
40
+ var buttonMinWidth = size === 's' ? buttonSizeMap.xs.minWidth : buttonSizeMap.s.minWidth;
41
+ var buttonRadius = size === 's' ? buttonSizeMap.xs.radiusInset : buttonSizeMap.s.radiusInset;
42
+ var commonStyles = "\n block-size: ".concat(buttonSize, ";\n border-radius: ").concat(buttonRadius, ";\n /* prevent issues in jsdom where pointer-events: none is inherited from the pseudo element */\n pointer-events: auto;\n\n /* zero-specificity ancestor :has() check */\n &:where(:not(:has(").concat(primaryDisabledSelector, ", ").concat(secondaryDisabledSelector, ")) &) {\n border: none;\n }\n \n &:where(:has(").concat(primaryDisabledSelector, ", ").concat(secondaryDisabledSelector, ") &) {\n &:is(").concat(_global_styling.euiDisabledSelector, ") {\n border: none;\n }\n }\n \n ");
43
+ return {
44
+ euiSplitButtonActionPrimary: /*#__PURE__*/(0, _react.css)(commonStyles, " z-index:", euiTheme.levels.content, ";&:not(.euiButtonIcon){min-inline-size:", buttonMinWidth, "px;}&.euiButtonIcon{inline-size:", buttonSize, ";};label:euiSplitButtonActionPrimary;"),
45
+ euiSplitButtonActionSecondary: /*#__PURE__*/(0, _react.css)(commonStyles, " inline-size:", buttonSize, ";;label:euiSplitButtonActionSecondary;")
46
+ };
49
47
  };
50
48
  var euiSplitButtonDividerStyles = exports.euiSplitButtonDividerStyles = function euiSplitButtonDividerStyles(euiThemeContext, color) {
51
49
  var euiTheme = euiThemeContext.euiTheme;
52
50
  return {
53
- divider: /*#__PURE__*/(0, _react.css)("border-inline-start:", euiTheme.border.width.thin, " solid ", color, ";;label:divider;")
51
+ divider: /*#__PURE__*/(0, _react.css)("block-size:calc(100% - ", euiTheme.size.s, ");border-inline-start:", euiTheme.border.width.thin, " solid ", color, ";", (0, _global_styling.logicalCSS)('margin-horizontal', euiTheme.size.xs), ";&:where(\n ", primaryDisabledSelector, " + &,\n :has(~ ", secondaryDisabledSelector, ")\n ){border-color:", euiTheme.colors.borderBaseDisabled, ";};label:divider;")
54
52
  };
55
53
  };
@@ -11,6 +11,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
11
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
12
12
  var _react = _interopRequireWildcard(require("react"));
13
13
  var _classnames = _interopRequireDefault(require("classnames"));
14
+ var _services = require("../../../services");
14
15
  var _popover = require("../../popover");
15
16
  var _tool_tip = require("../../tool_tip");
16
17
  var _button = require("../button");
@@ -20,9 +21,9 @@ var _split_button = require("./split_button.styles");
20
21
  var _split_button_context = require("./split_button_context");
21
22
  var _react2 = require("@emotion/react");
22
23
  var _excluded = ["className", "isIconOnly", "tooltipProps"],
23
- _excluded2 = ["fill", "isDisabled", "isLoading"],
24
+ _excluded2 = ["fill", "isDisabled", "isLoading", "size"],
24
25
  _excluded3 = ["className", "popoverProps", "tooltipProps"],
25
- _excluded4 = ["fill", "isDisabled", "isLoading"];
26
+ _excluded4 = ["fill", "isDisabled", "isLoading", "size"];
26
27
  /*
27
28
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
28
29
  * or more contributor license agreements. Licensed under the Elastic License
@@ -39,17 +40,22 @@ var EuiSplitButtonActionPrimary = exports.EuiSplitButtonActionPrimary = function
39
40
  isIconOnly = _ref.isIconOnly,
40
41
  tooltipProps = _ref.tooltipProps,
41
42
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
43
+ var euiThemeContext = (0, _services.useEuiTheme)();
42
44
  var _useContext = (0, _react.useContext)(_split_button_context.EuiSplitButtonContext),
43
45
  fill = _useContext.fill,
44
46
  isDisabled = _useContext.isDisabled,
45
47
  isLoading = _useContext.isLoading,
48
+ size = _useContext.size,
46
49
  sharedRest = (0, _objectWithoutProperties2.default)(_useContext, _excluded2);
47
50
  var _isDisabled = !!isDisabled || (0, _button_display.isButtonDisabled)(rest);
48
51
  var _isLoading = !!isLoading || !!rest.isLoading;
49
52
  var display = fill ? 'fill' : 'base';
50
53
  var classes = (0, _classnames.default)('euiSplitButtonActionPrimary', className);
51
- var styles = _split_button.euiSplitButtonActionStyles;
54
+ var styles = (0, _react.useMemo)(function () {
55
+ return (0, _split_button.euiSplitButtonActionStyles)(euiThemeContext, size);
56
+ }, [euiThemeContext, size]);
52
57
  var actionProps = _objectSpread(_objectSpread(_objectSpread({}, rest), sharedRest), {}, {
58
+ size: size,
53
59
  isDisabled: _isDisabled,
54
60
  isLoading: _isLoading,
55
61
  css: [styles.euiSplitButtonActionPrimary],
@@ -69,17 +75,22 @@ var EuiSplitButtonActionSecondary = exports.EuiSplitButtonActionSecondary = func
69
75
  popoverProps = _ref2.popoverProps,
70
76
  tooltipProps = _ref2.tooltipProps,
71
77
  rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded3);
78
+ var euiThemeContext = (0, _services.useEuiTheme)();
72
79
  var _useContext2 = (0, _react.useContext)(_split_button_context.EuiSplitButtonContext),
73
80
  fill = _useContext2.fill,
74
81
  isDisabled = _useContext2.isDisabled,
75
82
  isLoading = _useContext2.isLoading,
83
+ size = _useContext2.size,
76
84
  sharedRest = (0, _objectWithoutProperties2.default)(_useContext2, _excluded4);
77
85
  var _isDisabled = !!isDisabled || (0, _button_display.isButtonDisabled)(rest);
78
86
  var _isLoading = !!isLoading || !!rest.isLoading;
79
87
  var display = fill ? 'fill' : 'base';
80
88
  var classes = (0, _classnames.default)('euiSplitButtonActionSecondary', className);
81
- var styles = _split_button.euiSplitButtonActionStyles;
89
+ var styles = (0, _react.useMemo)(function () {
90
+ return (0, _split_button.euiSplitButtonActionStyles)(euiThemeContext, size);
91
+ }, [euiThemeContext, size]);
82
92
  var actionProps = _objectSpread(_objectSpread(_objectSpread({}, rest), sharedRest), {}, {
93
+ size: size,
83
94
  display: display,
84
95
  // enforce chevronSingleDown icon when a popover is rendered
85
96
  iconType: popoverProps != null ? 'chevronSingleDown' : rest.iconType,
@@ -20,12 +20,14 @@ var _button_display = require("./button_display/_button_display");
20
20
  * popover boundary isolation and isDisabled computation.
21
21
  */
22
22
  function useEuiButtonCommonProps(_ref) {
23
- var _groupContext$isDisab, _groupContext$size, _groupContext$color, _groupContext$hasAria, _groupContext$fullWid;
23
+ var _groupContext$isDisab, _groupContext$size, _groupContext$color, _groupContext$hasAria, _groupContext$fullWid, _groupContext$display, _groupContext$fill;
24
24
  var size = _ref.size,
25
25
  color = _ref.color,
26
26
  _isDisabled = _ref.isDisabled,
27
27
  hasAriaDisabled = _ref.hasAriaDisabled,
28
28
  fullWidth = _ref.fullWidth,
29
+ fill = _ref.fill,
30
+ display = _ref.display,
29
31
  href = _ref.href,
30
32
  disabled = _ref.disabled,
31
33
  isLoading = _ref.isLoading;
@@ -41,6 +43,8 @@ function useEuiButtonCommonProps(_ref) {
41
43
  color: (_groupContext$color = groupContext.color) !== null && _groupContext$color !== void 0 ? _groupContext$color : color,
42
44
  isDisabled: isDisabled,
43
45
  hasAriaDisabled: (_groupContext$hasAria = groupContext.hasAriaDisabled) !== null && _groupContext$hasAria !== void 0 ? _groupContext$hasAria : hasAriaDisabled,
44
- fullWidth: (_groupContext$fullWid = groupContext.fullWidth) !== null && _groupContext$fullWid !== void 0 ? _groupContext$fullWid : fullWidth
46
+ fullWidth: (_groupContext$fullWid = groupContext.fullWidth) !== null && _groupContext$fullWid !== void 0 ? _groupContext$fullWid : fullWidth,
47
+ display: (_groupContext$display = groupContext.display) !== null && _groupContext$display !== void 0 ? _groupContext$display : display,
48
+ fill: (_groupContext$fill = groupContext.fill) !== null && _groupContext$fill !== void 0 ? _groupContext$fill : fill
45
49
  };
46
50
  }
@@ -84,7 +84,9 @@ var ColumnActions = exports.ColumnActions = /*#__PURE__*/(0, _react.memo)(functi
84
84
  });
85
85
  var actionsEnterKeyInstructions = (0, _i18n.useEuiI18n)('euiDataGridHeaderCell.actionsEnterKeyInstructions', "Press the Enter key to view this column's actions");
86
86
  var openActionsPopoverOnEnter = (0, _react.useCallback)(function (e) {
87
- if (e.key === _services.keys.ENTER) {
87
+ // Only handle Enter when the cell div itself is focused,
88
+ // not when it bubbles up from the nested button
89
+ if (e.key === _services.keys.ENTER && e.target === e.currentTarget) {
88
90
  setIsPopoverOpen(true);
89
91
  }
90
92
  }, []);