@elastic/eui 62.0.3 → 62.2.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 (306) hide show
  1. package/dist/eui_theme_dark.css +1 -783
  2. package/dist/eui_theme_dark.json +0 -57
  3. package/dist/eui_theme_dark.json.d.ts +0 -57
  4. package/dist/eui_theme_dark.min.css +1 -1
  5. package/dist/eui_theme_light.css +1 -783
  6. package/dist/eui_theme_light.json +0 -57
  7. package/dist/eui_theme_light.json.d.ts +0 -57
  8. package/dist/eui_theme_light.min.css +1 -1
  9. package/es/components/breadcrumbs/breadcrumb.js +199 -0
  10. package/es/components/breadcrumbs/breadcrumb.styles.js +61 -0
  11. package/es/components/breadcrumbs/breadcrumbs.js +115 -187
  12. package/es/components/breadcrumbs/breadcrumbs.styles.js +30 -0
  13. package/es/components/code/code_block.js +119 -107
  14. package/es/components/collapsible_nav/collapsible_nav.js +2 -2
  15. package/es/components/control_bar/control_bar.js +13 -0
  16. package/es/components/datagrid/body/data_grid_body.js +12 -2
  17. package/es/components/datagrid/body/data_grid_cell.js +31 -3
  18. package/es/components/datagrid/body/header/data_grid_header_row.js +1 -1
  19. package/es/components/datagrid/controls/column_sorting_draggable.js +1 -1
  20. package/es/components/datagrid/data_grid.js +10 -2
  21. package/es/components/datagrid/utils/row_heights.js +33 -4
  22. package/es/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  23. package/es/components/date_picker/super_date_picker/super_update_button.js +1 -1
  24. package/es/components/description_list/description_list.js +22 -26
  25. package/es/components/description_list/description_list.styles.js +25 -0
  26. package/es/components/description_list/description_list_context.js +14 -0
  27. package/es/components/description_list/description_list_description.js +43 -2
  28. package/es/components/description_list/description_list_description.styles.js +47 -0
  29. package/es/components/description_list/description_list_title.js +43 -2
  30. package/es/components/description_list/description_list_title.styles.js +37 -0
  31. package/es/components/description_list/description_list_types.js +10 -0
  32. package/es/components/header/header.js +1 -27
  33. package/es/components/header/header_breadcrumbs/header_breadcrumbs.js +22 -2
  34. package/es/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +15 -0
  35. package/es/components/header/header_links/header_links.js +9 -9
  36. package/es/components/icon/assets/tokenStruct.js +1 -1
  37. package/es/components/page/page_header/page_header.js +1 -0
  38. package/es/components/page/page_header/page_header_content.js +2 -1
  39. package/es/components/page/page_template.js +1 -0
  40. package/es/components/pagination/pagination.js +1 -1
  41. package/es/components/panel/split_panel/split_panel.js +2 -2
  42. package/es/components/provider/provider.js +2 -2
  43. package/es/components/responsive/hide_for.js +6 -38
  44. package/es/components/responsive/show_for.js +6 -38
  45. package/es/components/selectable/selectable_templates/selectable_template_sitewide.js +17 -36
  46. package/es/components/side_nav/side_nav.js +1 -1
  47. package/es/components/table/table_row_cell.js +1 -2
  48. package/es/components/toast/global_toast_list.js +208 -241
  49. package/es/components/toast/global_toast_list.styles.js +38 -0
  50. package/es/components/toast/global_toast_list_item.js +12 -7
  51. package/es/components/toast/toast.js +25 -25
  52. package/es/components/toast/toast.styles.js +55 -0
  53. package/es/components/token/index.js +2 -1
  54. package/es/components/token/token.js +48 -112
  55. package/es/components/token/token.styles.js +93 -0
  56. package/es/components/token/token_map.js +6 -9
  57. package/es/components/token/token_types.js +11 -0
  58. package/es/global_styling/reset/global_styles.js +1 -1
  59. package/es/services/{breakpoint.js → breakpoint/breakpoint.js} +4 -9
  60. package/es/services/{hooks/useIsWithinBreakpoints.js → breakpoint/current_breakpoint.js} +26 -28
  61. package/es/services/breakpoint/current_breakpoint_hook.js +20 -0
  62. package/es/services/breakpoint/index.js +11 -0
  63. package/es/services/breakpoint/useIsWithinBreakpoints.js +24 -0
  64. package/es/services/hooks/index.js +0 -1
  65. package/es/services/index.js +1 -1
  66. package/es/test/rtl/component_helpers.js +60 -1
  67. package/eui.d.ts +1704 -1475
  68. package/i18ntokens.json +36 -36
  69. package/lib/components/breadcrumbs/breadcrumb.js +225 -0
  70. package/lib/components/breadcrumbs/breadcrumb.styles.js +68 -0
  71. package/lib/components/breadcrumbs/breadcrumbs.js +125 -188
  72. package/lib/components/breadcrumbs/breadcrumbs.styles.js +33 -0
  73. package/lib/components/code/code_block.js +118 -106
  74. package/lib/components/collapsible_nav/collapsible_nav.js +2 -2
  75. package/lib/components/control_bar/control_bar.js +13 -0
  76. package/lib/components/datagrid/body/data_grid_body.js +12 -2
  77. package/lib/components/datagrid/body/data_grid_cell.js +31 -3
  78. package/lib/components/datagrid/body/header/data_grid_header_row.js +1 -1
  79. package/lib/components/datagrid/controls/column_sorting_draggable.js +1 -1
  80. package/lib/components/datagrid/data_grid.js +10 -2
  81. package/lib/components/datagrid/utils/row_heights.js +33 -4
  82. package/lib/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  83. package/lib/components/date_picker/super_date_picker/super_update_button.js +1 -1
  84. package/lib/components/description_list/description_list.js +25 -31
  85. package/lib/components/description_list/description_list.styles.js +36 -0
  86. package/lib/components/description_list/description_list_context.js +24 -0
  87. package/lib/components/description_list/description_list_description.js +52 -2
  88. package/lib/components/description_list/description_list_description.styles.js +51 -0
  89. package/lib/components/description_list/description_list_title.js +52 -2
  90. package/lib/components/description_list/description_list_title.styles.js +50 -0
  91. package/lib/components/description_list/description_list_types.js +20 -0
  92. package/lib/components/header/header.js +1 -27
  93. package/lib/components/header/header_breadcrumbs/header_breadcrumbs.js +24 -2
  94. package/lib/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +26 -0
  95. package/lib/components/header/header_links/header_links.js +8 -8
  96. package/lib/components/icon/assets/tokenStruct.js +1 -1
  97. package/lib/components/icon/svgs/tokens/tokenStruct.svg +1 -1
  98. package/lib/components/page/page_header/page_header.js +1 -0
  99. package/lib/components/page/page_header/page_header_content.js +3 -2
  100. package/lib/components/page/page_template.js +1 -0
  101. package/lib/components/pagination/pagination.js +1 -1
  102. package/lib/components/panel/split_panel/split_panel.js +3 -3
  103. package/lib/components/provider/provider.js +1 -1
  104. package/lib/components/responsive/hide_for.js +12 -44
  105. package/lib/components/responsive/show_for.js +12 -44
  106. package/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +15 -35
  107. package/lib/components/side_nav/side_nav.js +1 -1
  108. package/lib/components/table/table_row_cell.js +1 -3
  109. package/lib/components/toast/global_toast_list.js +209 -238
  110. package/lib/components/toast/global_toast_list.styles.js +45 -0
  111. package/lib/components/toast/global_toast_list_item.js +14 -7
  112. package/lib/components/toast/toast.js +27 -25
  113. package/lib/components/toast/toast.styles.js +66 -0
  114. package/lib/components/token/index.js +5 -3
  115. package/lib/components/token/token.js +50 -120
  116. package/lib/components/token/token.styles.js +101 -0
  117. package/lib/components/token/token_map.js +6 -9
  118. package/lib/components/token/token_types.js +22 -0
  119. package/lib/global_styling/reset/global_styles.js +1 -1
  120. package/{test-env/services → lib/services/breakpoint}/breakpoint.js +5 -9
  121. package/lib/services/breakpoint/current_breakpoint.js +69 -0
  122. package/lib/services/breakpoint/current_breakpoint_hook.js +31 -0
  123. package/lib/services/breakpoint/index.js +57 -0
  124. package/lib/services/breakpoint/useIsWithinBreakpoints.js +34 -0
  125. package/lib/services/hooks/index.js +0 -13
  126. package/lib/services/index.js +28 -0
  127. package/lib/test/rtl/component_helpers.js +69 -3
  128. package/optimize/es/components/breadcrumbs/breadcrumb.js +136 -0
  129. package/optimize/es/components/breadcrumbs/breadcrumb.styles.js +61 -0
  130. package/optimize/es/components/breadcrumbs/breadcrumbs.js +92 -165
  131. package/optimize/es/components/breadcrumbs/breadcrumbs.styles.js +30 -0
  132. package/optimize/es/components/code/code_block.js +106 -107
  133. package/optimize/es/components/datagrid/body/data_grid_body.js +2 -0
  134. package/optimize/es/components/datagrid/body/data_grid_cell.js +13 -1
  135. package/optimize/es/components/datagrid/utils/row_heights.js +33 -4
  136. package/optimize/es/components/description_list/description_list.js +20 -24
  137. package/optimize/es/components/description_list/description_list.styles.js +25 -0
  138. package/optimize/es/components/description_list/description_list_context.js +14 -0
  139. package/optimize/es/components/description_list/description_list_description.js +32 -2
  140. package/optimize/es/components/description_list/description_list_description.styles.js +47 -0
  141. package/optimize/es/components/description_list/description_list_title.js +32 -2
  142. package/optimize/es/components/description_list/description_list_title.styles.js +37 -0
  143. package/optimize/es/components/description_list/description_list_types.js +10 -0
  144. package/optimize/es/components/header/header_breadcrumbs/header_breadcrumbs.js +8 -1
  145. package/optimize/es/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +15 -0
  146. package/optimize/es/components/header/header_links/header_links.js +8 -8
  147. package/optimize/es/components/icon/assets/tokenStruct.js +1 -1
  148. package/optimize/es/components/page/page_header/page_header_content.js +1 -1
  149. package/optimize/es/components/panel/split_panel/split_panel.js +1 -1
  150. package/optimize/es/components/provider/provider.js +2 -2
  151. package/optimize/es/components/responsive/hide_for.js +5 -27
  152. package/optimize/es/components/responsive/show_for.js +5 -27
  153. package/optimize/es/components/selectable/selectable_templates/selectable_template_sitewide.js +16 -35
  154. package/optimize/es/components/table/table_row_cell.js +1 -2
  155. package/optimize/es/components/toast/global_toast_list.js +199 -230
  156. package/optimize/es/components/toast/global_toast_list.styles.js +38 -0
  157. package/optimize/es/components/toast/global_toast_list_item.js +11 -6
  158. package/optimize/es/components/toast/toast.js +24 -24
  159. package/optimize/es/components/toast/toast.styles.js +55 -0
  160. package/optimize/es/components/token/index.js +2 -1
  161. package/optimize/es/components/token/token.js +46 -69
  162. package/optimize/es/components/token/token.styles.js +83 -0
  163. package/optimize/es/components/token/token_map.js +6 -9
  164. package/optimize/es/components/token/token_types.js +11 -0
  165. package/optimize/es/global_styling/reset/global_styles.js +1 -1
  166. package/optimize/es/services/{breakpoint.js → breakpoint/breakpoint.js} +4 -9
  167. package/optimize/es/services/breakpoint/current_breakpoint.js +44 -0
  168. package/optimize/es/services/breakpoint/current_breakpoint_hook.js +20 -0
  169. package/optimize/es/services/breakpoint/index.js +11 -0
  170. package/optimize/es/services/breakpoint/useIsWithinBreakpoints.js +24 -0
  171. package/optimize/es/services/hooks/index.js +0 -1
  172. package/optimize/es/services/index.js +1 -1
  173. package/optimize/es/test/rtl/component_helpers.js +60 -1
  174. package/optimize/lib/components/breadcrumbs/breadcrumb.js +162 -0
  175. package/optimize/lib/components/breadcrumbs/breadcrumb.styles.js +68 -0
  176. package/optimize/lib/components/breadcrumbs/breadcrumbs.js +99 -164
  177. package/optimize/lib/components/breadcrumbs/breadcrumbs.styles.js +33 -0
  178. package/optimize/lib/components/code/code_block.js +105 -106
  179. package/optimize/lib/components/datagrid/body/data_grid_body.js +2 -0
  180. package/optimize/lib/components/datagrid/body/data_grid_cell.js +13 -1
  181. package/optimize/lib/components/datagrid/utils/row_heights.js +33 -4
  182. package/optimize/lib/components/description_list/description_list.js +23 -28
  183. package/optimize/lib/components/description_list/description_list.styles.js +36 -0
  184. package/optimize/lib/components/description_list/description_list_context.js +24 -0
  185. package/optimize/lib/components/description_list/description_list_description.js +43 -2
  186. package/optimize/lib/components/description_list/description_list_description.styles.js +51 -0
  187. package/optimize/lib/components/description_list/description_list_title.js +43 -2
  188. package/optimize/lib/components/description_list/description_list_title.styles.js +50 -0
  189. package/optimize/lib/components/description_list/description_list_types.js +20 -0
  190. package/optimize/lib/components/header/header_breadcrumbs/header_breadcrumbs.js +10 -1
  191. package/optimize/lib/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +26 -0
  192. package/optimize/lib/components/header/header_links/header_links.js +7 -7
  193. package/optimize/lib/components/icon/assets/tokenStruct.js +1 -1
  194. package/optimize/lib/components/icon/svgs/tokens/tokenStruct.svg +1 -1
  195. package/optimize/lib/components/page/page_header/page_header_content.js +2 -2
  196. package/optimize/lib/components/panel/split_panel/split_panel.js +2 -2
  197. package/optimize/lib/components/provider/provider.js +1 -1
  198. package/optimize/lib/components/responsive/hide_for.js +4 -33
  199. package/optimize/lib/components/responsive/show_for.js +4 -33
  200. package/optimize/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +14 -34
  201. package/optimize/lib/components/table/table_row_cell.js +1 -3
  202. package/optimize/lib/components/toast/global_toast_list.js +206 -220
  203. package/optimize/lib/components/toast/global_toast_list.styles.js +47 -0
  204. package/optimize/lib/components/toast/global_toast_list_item.js +14 -7
  205. package/optimize/lib/components/toast/toast.js +26 -24
  206. package/optimize/lib/components/toast/toast.styles.js +66 -0
  207. package/optimize/lib/components/token/index.js +5 -3
  208. package/optimize/lib/components/token/token.js +50 -76
  209. package/optimize/lib/components/token/token.styles.js +91 -0
  210. package/optimize/lib/components/token/token_map.js +6 -9
  211. package/optimize/lib/components/token/token_types.js +22 -0
  212. package/optimize/lib/global_styling/reset/global_styles.js +1 -1
  213. package/optimize/lib/services/{breakpoint.js → breakpoint/breakpoint.js} +5 -9
  214. package/optimize/lib/services/breakpoint/current_breakpoint.js +68 -0
  215. package/optimize/lib/services/breakpoint/current_breakpoint_hook.js +31 -0
  216. package/optimize/lib/services/breakpoint/index.js +57 -0
  217. package/optimize/lib/services/breakpoint/useIsWithinBreakpoints.js +34 -0
  218. package/optimize/lib/services/hooks/index.js +0 -13
  219. package/optimize/lib/services/index.js +28 -0
  220. package/optimize/lib/test/rtl/component_helpers.js +69 -3
  221. package/package.json +2 -2
  222. package/src/components/control_bar/_control_bar.scss +1 -1
  223. package/src/components/header/_index.scss +0 -1
  224. package/src/components/index.scss +0 -5
  225. package/src/themes/amsterdam/overrides/_breadcrumbs.scss +0 -12
  226. package/src/themes/amsterdam/overrides/_index.scss +0 -4
  227. package/test-env/components/breadcrumbs/breadcrumb.js +211 -0
  228. package/test-env/components/breadcrumbs/breadcrumb.styles.js +68 -0
  229. package/test-env/components/breadcrumbs/breadcrumbs.js +122 -174
  230. package/test-env/components/breadcrumbs/breadcrumbs.styles.js +33 -0
  231. package/test-env/components/collapsible_nav/collapsible_nav.js +2 -2
  232. package/test-env/components/control_bar/control_bar.js +13 -0
  233. package/test-env/components/datagrid/body/data_grid_body.js +12 -2
  234. package/test-env/components/datagrid/body/data_grid_cell.js +31 -3
  235. package/test-env/components/datagrid/body/header/data_grid_header_row.js +1 -1
  236. package/test-env/components/datagrid/controls/column_sorting_draggable.js +1 -1
  237. package/test-env/components/datagrid/data_grid.js +10 -2
  238. package/test-env/components/datagrid/utils/row_heights.js +33 -4
  239. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  240. package/test-env/components/date_picker/super_date_picker/super_update_button.js +1 -1
  241. package/test-env/components/description_list/description_list.js +25 -30
  242. package/test-env/components/description_list/description_list.styles.js +36 -0
  243. package/test-env/components/description_list/description_list_context.js +24 -0
  244. package/test-env/components/description_list/description_list_description.js +43 -2
  245. package/test-env/components/description_list/description_list_description.styles.js +51 -0
  246. package/test-env/components/description_list/description_list_title.js +43 -2
  247. package/test-env/components/description_list/description_list_title.styles.js +50 -0
  248. package/test-env/components/description_list/description_list_types.js +20 -0
  249. package/test-env/components/header/header.js +1 -27
  250. package/test-env/components/header/header_breadcrumbs/header_breadcrumbs.js +24 -2
  251. package/test-env/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +26 -0
  252. package/test-env/components/header/header_links/header_links.js +8 -8
  253. package/test-env/components/icon/assets/tokenStruct.js +1 -1
  254. package/test-env/components/observer/resize_observer/resize_observer.js +43 -126
  255. package/test-env/components/page/page_header/page_header.js +1 -0
  256. package/test-env/components/page/page_header/page_header_content.js +3 -2
  257. package/test-env/components/page/page_template.js +1 -0
  258. package/test-env/components/pagination/pagination.js +1 -1
  259. package/test-env/components/panel/split_panel/split_panel.js +3 -3
  260. package/test-env/components/provider/provider.js +1 -1
  261. package/test-env/components/responsive/hide_for.js +5 -34
  262. package/test-env/components/responsive/show_for.js +5 -34
  263. package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.js +15 -35
  264. package/test-env/components/side_nav/side_nav.js +1 -1
  265. package/test-env/components/table/table_row_cell.js +1 -3
  266. package/test-env/components/toast/global_toast_list.js +206 -220
  267. package/test-env/components/toast/global_toast_list.styles.js +47 -0
  268. package/test-env/components/toast/global_toast_list_item.js +14 -7
  269. package/test-env/components/toast/toast.js +27 -25
  270. package/test-env/components/toast/toast.styles.js +66 -0
  271. package/test-env/components/token/index.js +5 -3
  272. package/test-env/components/token/token.js +51 -120
  273. package/test-env/components/token/token.styles.js +91 -0
  274. package/test-env/components/token/token_map.js +6 -9
  275. package/test-env/components/token/token_types.js +22 -0
  276. package/test-env/global_styling/reset/global_styles.js +1 -1
  277. package/{lib/services → test-env/services/breakpoint}/breakpoint.js +5 -9
  278. package/test-env/services/breakpoint/current_breakpoint.js +68 -0
  279. package/test-env/services/breakpoint/current_breakpoint_hook.js +33 -0
  280. package/test-env/services/breakpoint/index.js +57 -0
  281. package/test-env/services/breakpoint/useIsWithinBreakpoints.js +34 -0
  282. package/test-env/services/hooks/index.js +0 -13
  283. package/test-env/services/index.js +28 -0
  284. package/test-env/test/rtl/component_helpers.js +69 -3
  285. package/lib/services/hooks/useIsWithinBreakpoints.js +0 -57
  286. package/optimize/es/services/hooks/useIsWithinBreakpoints.js +0 -46
  287. package/optimize/lib/services/hooks/useIsWithinBreakpoints.js +0 -57
  288. package/src/components/breadcrumbs/_breadcrumbs.scss +0 -79
  289. package/src/components/breadcrumbs/_index.scss +0 -2
  290. package/src/components/breadcrumbs/_variables.scss +0 -2
  291. package/src/components/description_list/_description_list.scss +0 -211
  292. package/src/components/description_list/_index.scss +0 -1
  293. package/src/components/header/header_breadcrumbs/_header_breadcrumbs.scss +0 -8
  294. package/src/components/header/header_breadcrumbs/_index.scss +0 -1
  295. package/src/components/portal/_index.scss +0 -1
  296. package/src/components/portal/_portal.scss +0 -6
  297. package/src/components/toast/_global_toast_list.scss +0 -90
  298. package/src/components/toast/_index.scss +0 -4
  299. package/src/components/toast/_toast.scss +0 -103
  300. package/src/components/token/_index.scss +0 -2
  301. package/src/components/token/_token.scss +0 -85
  302. package/src/components/token/_variables.scss +0 -13
  303. package/src/themes/amsterdam/overrides/_header_breadcrumbs.scss +0 -71
  304. package/src/themes/amsterdam/overrides/_toast.scss +0 -21
  305. package/src/themes/amsterdam/overrides/_token.scss +0 -4
  306. package/test-env/services/hooks/useIsWithinBreakpoints.js +0 -57
@@ -16,9 +16,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
16
  * in compliance with, at your election, the Elastic License 2.0 or the Server
17
17
  * Side Public License, v 1.
18
18
  */
19
- import React, { useState, useEffect } from 'react';
19
+ import React, { useState, useMemo } from 'react';
20
20
  import classNames from 'classnames';
21
- import { useCombinedRefs, throttle } from '../../../services';
21
+ import { useCombinedRefs, useCurrentEuiBreakpoint } from '../../../services';
22
22
  import { EuiSelectable } from '../selectable';
23
23
  import { EuiPopoverTitle, EuiPopoverFooter } from '../../popover';
24
24
  import { EuiPopover } from '../../popover/popover';
@@ -26,7 +26,6 @@ import { useEuiI18n, EuiI18n } from '../../i18n';
26
26
  import { EuiSelectableMessage } from '../selectable_message';
27
27
  import { EuiLoadingSpinner } from '../../loading';
28
28
  import { euiSelectableTemplateSitewideFormatOptions, euiSelectableTemplateSitewideRenderOptions } from './selectable_template_sitewide_option';
29
- import { isWithinBreakpoints } from '../../../services/breakpoint';
30
29
  import { EuiSpacer } from '../../spacer';
31
30
  import { ENTER } from '../../../services/keys';
32
31
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -44,33 +43,9 @@ export var EuiSelectableTemplateSitewide = function EuiSelectableTemplateSitewid
44
43
  popoverButtonBreakpoints = _ref.popoverButtonBreakpoints,
45
44
  rest = _objectWithoutProperties(_ref, _excluded);
46
45
 
47
- /**
48
- * Breakpoint management
49
- */
50
- var _useState = useState(typeof window !== 'undefined' && popoverButtonBreakpoints ? isWithinBreakpoints(window.innerWidth, popoverButtonBreakpoints) : true),
51
- _useState2 = _slicedToArray(_useState, 2),
52
- canShowPopoverButton = _useState2[0],
53
- setCanShowPopoverButton = _useState2[1];
54
-
55
- var functionToCallOnWindowResize = throttle(function () {
56
- var newWidthIsWithinBreakpoint = popoverButtonBreakpoints ? isWithinBreakpoints(window.innerWidth, popoverButtonBreakpoints) : true;
57
-
58
- if (newWidthIsWithinBreakpoint !== canShowPopoverButton) {
59
- setCanShowPopoverButton(newWidthIsWithinBreakpoint);
60
- } // reacts every 50ms to resize changes and always gets the final update
61
-
62
- }, 50); // Add window resize handlers
63
-
64
- useEffect(function () {
65
- window.addEventListener('resize', functionToCallOnWindowResize);
66
- return function () {
67
- window.removeEventListener('resize', functionToCallOnWindowResize);
68
- };
69
- }, [functionToCallOnWindowResize]);
70
46
  /**
71
47
  * i18n text
72
48
  */
73
-
74
49
  var _useEuiI18n = useEuiI18n(['euiSelectableTemplateSitewide.searchPlaceholder'], ['Search for anything...']),
75
50
  _useEuiI18n2 = _slicedToArray(_useEuiI18n, 1),
76
51
  searchPlaceholder = _useEuiI18n2[0];
@@ -79,15 +54,15 @@ export var EuiSelectableTemplateSitewide = function EuiSelectableTemplateSitewid
79
54
  */
80
55
 
81
56
 
82
- var _useState3 = useState(null),
83
- _useState4 = _slicedToArray(_useState3, 2),
84
- popoverRef = _useState4[0],
85
- setPopoverRef = _useState4[1];
57
+ var _useState = useState(null),
58
+ _useState2 = _slicedToArray(_useState, 2),
59
+ popoverRef = _useState2[0],
60
+ setPopoverRef = _useState2[1];
86
61
 
87
- var _useState5 = useState(false),
88
- _useState6 = _slicedToArray(_useState5, 2),
89
- popoverIsOpen = _useState6[0],
90
- setPopoverIsOpen = _useState6[1];
62
+ var _useState3 = useState(false),
63
+ _useState4 = _slicedToArray(_useState3, 2),
64
+ popoverIsOpen = _useState4[0],
65
+ setPopoverIsOpen = _useState4[1];
91
66
 
92
67
  var _popoverProps = _objectSpread({}, popoverProps),
93
68
  _closePopover = _popoverProps.closePopover,
@@ -184,6 +159,12 @@ export var EuiSelectableTemplateSitewide = function EuiSelectableTemplateSitewid
184
159
  */
185
160
 
186
161
 
162
+ var currentBreakpoint = useCurrentEuiBreakpoint();
163
+ var canShowPopoverButton = useMemo(function () {
164
+ if (!popoverButtonBreakpoints) return true;
165
+ if (!currentBreakpoint) return false;
166
+ return popoverButtonBreakpoints.includes(currentBreakpoint);
167
+ }, [currentBreakpoint, popoverButtonBreakpoints]);
187
168
  var popoverTrigger;
188
169
 
189
170
  if (popoverButton && canShowPopoverButton) {
@@ -16,9 +16,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
16
16
  */
17
17
  import React, { Fragment } from 'react';
18
18
  import classNames from 'classnames';
19
- import { LEFT_ALIGNMENT, RIGHT_ALIGNMENT, CENTER_ALIGNMENT } from '../../services';
19
+ import { LEFT_ALIGNMENT, RIGHT_ALIGNMENT, CENTER_ALIGNMENT, useIsWithinBreakpoints } from '../../services';
20
20
  import { resolveWidthAsStyle } from './utils';
21
- import { useIsWithinBreakpoints } from '../../services/hooks/useIsWithinBreakpoints';
22
21
  import { jsx as ___EmotionJSX } from "@emotion/react";
23
22
  export var EuiTableRowCell = function EuiTableRowCell(_ref) {
24
23
  var _mobileOptions$showOn, _mobileOptions$trunca;
@@ -1,12 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
- import _createClass from "@babel/runtime/helpers/createClass";
5
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
- import _inherits from "@babel/runtime/helpers/inherits";
7
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
10
5
  var _excluded = ["className", "toasts", "dismissToast", "toastLifeTimeMs", "side"],
11
6
  _excluded2 = ["text", "toastLifeTimeMs"];
12
7
 
@@ -14,10 +9,6 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
14
9
 
15
10
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
16
11
 
17
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
18
-
19
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
20
-
21
12
  /*
22
13
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
23
14
  * or more contributor license agreements. Licensed under the Elastic License
@@ -25,12 +16,14 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
25
16
  * in compliance with, at your election, the Elastic License 2.0 or the Server
26
17
  * Side Public License, v 1.
27
18
  */
28
- import React, { Component } from 'react';
19
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
29
20
  import classNames from 'classnames';
30
21
  import { keysOf } from '../common';
22
+ import { useEuiTheme } from '../../services';
31
23
  import { Timer } from '../../services/time';
32
24
  import { EuiGlobalToastListItem } from './global_toast_list_item';
33
25
  import { EuiToast } from './toast';
26
+ import { euiGlobalToastListStyles } from './global_toast_list.styles';
34
27
  import { jsx as ___EmotionJSX } from "@emotion/react";
35
28
  var sideToClassNameMap = {
36
29
  left: 'euiGlobalToastList--left',
@@ -38,252 +31,228 @@ var sideToClassNameMap = {
38
31
  };
39
32
  export var SIDES = keysOf(sideToClassNameMap);
40
33
  export var TOAST_FADE_OUT_MS = 250;
41
- export var EuiGlobalToastList = /*#__PURE__*/function (_Component) {
42
- _inherits(EuiGlobalToastList, _Component);
43
-
44
- var _super = _createSuper(EuiGlobalToastList);
45
-
46
- function EuiGlobalToastList() {
47
- var _this;
48
-
49
- _classCallCheck(this, EuiGlobalToastList);
50
-
51
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
52
- args[_key] = arguments[_key];
53
- }
54
-
55
- _this = _super.call.apply(_super, [this].concat(args));
56
-
57
- _defineProperty(_assertThisInitialized(_this), "state", {
58
- toastIdToDismissedMap: {}
59
- });
60
-
61
- _defineProperty(_assertThisInitialized(_this), "dismissTimeoutIds", []);
62
-
63
- _defineProperty(_assertThisInitialized(_this), "toastIdToTimerMap", {});
64
-
65
- _defineProperty(_assertThisInitialized(_this), "isScrollingToBottom", false);
34
+ export var EuiGlobalToastList = function EuiGlobalToastList(_ref) {
35
+ var className = _ref.className,
36
+ _ref$toasts = _ref.toasts,
37
+ toasts = _ref$toasts === void 0 ? [] : _ref$toasts,
38
+ dismissToastProp = _ref.dismissToast,
39
+ toastLifeTimeMs = _ref.toastLifeTimeMs,
40
+ _ref$side = _ref.side,
41
+ side = _ref$side === void 0 ? 'right' : _ref$side,
42
+ rest = _objectWithoutProperties(_ref, _excluded);
43
+
44
+ var _useState = useState({}),
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ toastIdToDismissedMap = _useState2[0],
47
+ setToastIdToDismissedMap = _useState2[1];
48
+
49
+ var _useState3 = useState(),
50
+ _useState4 = _slicedToArray(_useState3, 2),
51
+ toastToDismiss = _useState4[0],
52
+ setToastToDismiss = _useState4[1];
53
+
54
+ var prevToasts = useRef([]);
55
+ var dismissTimeoutIds = useRef([]);
56
+ var toastIdToTimerMap = useRef({});
57
+ var isScrollingToBottom = useRef(false);
58
+ var isScrolledToBottom = useRef(true);
59
+ var isUserInteracting = useRef(false); // See [Return Value](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame#Return_value)
60
+ // for information on initial value of 0
61
+
62
+ var isScrollingAnimationFrame = useRef(0);
63
+ var startScrollingAnimationFrame = useRef(0);
64
+ var listElement = useRef(null);
65
+ var euiTheme = useEuiTheme();
66
+ var styles = euiGlobalToastListStyles(euiTheme);
67
+ var cssStyles = [styles.euiGlobalToastList, styles[side]];
68
+
69
+ var startScrollingToBottom = function startScrollingToBottom() {
70
+ isScrollingToBottom.current = true;
71
+
72
+ var scrollToBottom = function scrollToBottom() {
73
+ // Although we cancel the requestAnimationFrame in componentWillUnmount,
74
+ // it's possible for this.listElement to become null in the meantime
75
+ if (!listElement.current) {
76
+ return;
77
+ }
66
78
 
67
- _defineProperty(_assertThisInitialized(_this), "isScrolledToBottom", true);
79
+ var position = listElement.current.scrollTop;
80
+ var destination = listElement.current.scrollHeight - listElement.current.clientHeight;
81
+ var distanceToDestination = destination - position;
68
82
 
69
- _defineProperty(_assertThisInitialized(_this), "isUserInteracting", false);
83
+ if (distanceToDestination < 5) {
84
+ listElement.current.scrollTop = destination;
85
+ isScrollingToBottom.current = false;
86
+ isScrolledToBottom.current = true;
87
+ return;
88
+ }
70
89
 
71
- _defineProperty(_assertThisInitialized(_this), "isScrollingAnimationFrame", 0);
90
+ listElement.current.scrollTop = position + distanceToDestination * 0.25;
72
91
 
73
- _defineProperty(_assertThisInitialized(_this), "startScrollingAnimationFrame", 0);
92
+ if (isScrollingToBottom) {
93
+ isScrollingAnimationFrame.current = window.requestAnimationFrame(scrollToBottom);
94
+ }
95
+ };
74
96
 
75
- _defineProperty(_assertThisInitialized(_this), "listElement", null);
97
+ startScrollingAnimationFrame.current = window.requestAnimationFrame(scrollToBottom);
98
+ };
76
99
 
77
- _defineProperty(_assertThisInitialized(_this), "onMouseEnter", function () {
78
- // Stop scrolling to bottom if we're in mid-scroll, because the user wants to interact with
79
- // the list.
80
- _this.isScrollingToBottom = false;
81
- _this.isUserInteracting = true; // Don't let toasts dismiss themselves while the user is interacting with them.
100
+ var onMouseEnter = function onMouseEnter() {
101
+ // Stop scrolling to bottom if we're in mid-scroll, because the user wants to interact with
102
+ // the list.
103
+ isScrollingToBottom.current = false;
104
+ isUserInteracting.current = true; // Don't let toasts dismiss themselves while the user is interacting with them.
82
105
 
83
- for (var _toastId in _this.toastIdToTimerMap) {
84
- if (_this.toastIdToTimerMap.hasOwnProperty(_toastId)) {
85
- var timer = _this.toastIdToTimerMap[_toastId];
86
- timer.pause();
87
- }
106
+ for (var _toastId in toastIdToTimerMap.current) {
107
+ if (toastIdToTimerMap.current.hasOwnProperty(_toastId)) {
108
+ var timer = toastIdToTimerMap.current[_toastId];
109
+ timer.pause();
88
110
  }
89
- });
90
-
91
- _defineProperty(_assertThisInitialized(_this), "onMouseLeave", function () {
92
- _this.isUserInteracting = false;
111
+ }
112
+ };
93
113
 
94
- for (var _toastId2 in _this.toastIdToTimerMap) {
95
- if (_this.toastIdToTimerMap.hasOwnProperty(_toastId2)) {
96
- var timer = _this.toastIdToTimerMap[_toastId2];
97
- timer.resume();
98
- }
99
- }
100
- });
114
+ var onMouseLeave = function onMouseLeave() {
115
+ isUserInteracting.current = false;
101
116
 
102
- _defineProperty(_assertThisInitialized(_this), "onScroll", function () {
103
- if (_this.listElement) {
104
- _this.isScrolledToBottom = _this.listElement.scrollHeight - _this.listElement.scrollTop === _this.listElement.clientHeight;
117
+ for (var _toastId2 in toastIdToTimerMap.current) {
118
+ if (toastIdToTimerMap.current.hasOwnProperty(_toastId2)) {
119
+ var timer = toastIdToTimerMap.current[_toastId2];
120
+ timer.resume();
105
121
  }
106
- });
107
-
108
- _defineProperty(_assertThisInitialized(_this), "scheduleAllToastsForDismissal", function () {
109
- _this.props.toasts.forEach(function (toast) {
110
- if (!_this.toastIdToTimerMap[toast.id]) {
111
- _this.scheduleToastForDismissal(toast);
112
- }
113
- });
114
- });
122
+ }
123
+ };
115
124
 
116
- _defineProperty(_assertThisInitialized(_this), "scheduleToastForDismissal", function (toast) {
117
- // Start fading the toast out once its lifetime elapses.
118
- _this.toastIdToTimerMap[toast.id] = new Timer(_this.dismissToast.bind(_assertThisInitialized(_this), toast), toast.toastLifeTimeMs != null ? toast.toastLifeTimeMs : _this.props.toastLifeTimeMs);
125
+ var onScroll = function onScroll() {
126
+ if (listElement.current) {
127
+ isScrolledToBottom.current = listElement.current.scrollHeight - listElement.current.scrollTop === listElement.current.clientHeight;
128
+ }
129
+ };
130
+
131
+ var dismissToast = useCallback(function (toast) {
132
+ // Remove the toast after it's done fading out.
133
+ dismissTimeoutIds.current.push(window.setTimeout(function () {
134
+ setToastToDismiss(toast);
135
+ }, TOAST_FADE_OUT_MS));
136
+ setToastIdToDismissedMap(function (prev) {
137
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, toast.id, true));
119
138
  });
120
-
121
- _defineProperty(_assertThisInitialized(_this), "dismissToast", function (toast) {
122
- // Remove the toast after it's done fading out.
123
- _this.dismissTimeoutIds.push(window.setTimeout(function () {
124
- // Because this is wrapped in a setTimeout, and because React does not guarantee when
125
- // state updates happen, it is possible to double-dismiss a toast
126
- // including by double-clicking the "x" button on the toast
127
- // so, first check to make sure we haven't already dismissed this toast
128
- if (_this.toastIdToTimerMap.hasOwnProperty(toast.id)) {
129
- _this.props.dismissToast.apply(_assertThisInitialized(_this), [toast]);
130
-
131
- _this.toastIdToTimerMap[toast.id].clear();
132
-
133
- delete _this.toastIdToTimerMap[toast.id];
134
-
135
- _this.setState(function (prevState) {
136
- var toastIdToDismissedMap = _objectSpread({}, prevState.toastIdToDismissedMap);
137
-
138
- delete toastIdToDismissedMap[toast.id];
139
- return {
140
- toastIdToDismissedMap: toastIdToDismissedMap
141
- };
142
- });
143
- }
144
- }, TOAST_FADE_OUT_MS));
145
-
146
- _this.setState(function (prevState) {
147
- var toastIdToDismissedMap = _objectSpread(_objectSpread({}, prevState.toastIdToDismissedMap), {}, _defineProperty({}, toast.id, true));
148
-
149
- return {
150
- toastIdToDismissedMap: toastIdToDismissedMap
151
- };
152
- });
139
+ }, []);
140
+ var scheduleToastForDismissal = useCallback(function (toast) {
141
+ // Start fading the toast out once its lifetime elapses.
142
+ toastIdToTimerMap.current[toast.id] = new Timer(function () {
143
+ return dismissToast(toast);
144
+ }, toast.toastLifeTimeMs != null ? toast.toastLifeTimeMs : toastLifeTimeMs);
145
+ }, [dismissToast, toastLifeTimeMs]);
146
+ var scheduleAllToastsForDismissal = useCallback(function () {
147
+ toasts.forEach(function (toast) {
148
+ if (!toastIdToTimerMap.current[toast.id]) {
149
+ scheduleToastForDismissal(toast);
150
+ }
153
151
  });
152
+ }, [scheduleToastForDismissal, toasts]);
154
153
 
155
- return _this;
156
- }
157
-
158
- _createClass(EuiGlobalToastList, [{
159
- key: "startScrollingToBottom",
160
- value: function startScrollingToBottom() {
161
- var _this2 = this;
162
-
163
- this.isScrollingToBottom = true;
164
-
165
- var scrollToBottom = function scrollToBottom() {
166
- // Although we cancel the requestAnimationFrame in componentWillUnmount,
167
- // it's possible for this.listElement to become null in the meantime
168
- if (!_this2.listElement) {
169
- return;
170
- }
171
-
172
- var position = _this2.listElement.scrollTop;
173
- var destination = _this2.listElement.scrollHeight - _this2.listElement.clientHeight;
174
- var distanceToDestination = destination - position;
175
-
176
- if (distanceToDestination < 5) {
177
- _this2.listElement.scrollTop = destination;
178
- _this2.isScrollingToBottom = false;
179
- _this2.isScrolledToBottom = true;
180
- return;
181
- }
154
+ var addListeners = function addListeners() {
155
+ if (listElement.current) {
156
+ listElement.current.addEventListener('scroll', onScroll);
157
+ listElement.current.addEventListener('mouseenter', onMouseEnter);
158
+ listElement.current.addEventListener('mouseleave', onMouseLeave);
159
+ }
160
+ };
182
161
 
183
- _this2.listElement.scrollTop = position + distanceToDestination * 0.25;
162
+ var removeListeners = function removeListeners() {
163
+ if (listElement.current) {
164
+ listElement.current.removeEventListener('scroll', onScroll);
165
+ listElement.current.removeEventListener('mouseenter', onMouseEnter);
166
+ listElement.current.removeEventListener('mouseleave', onMouseLeave);
167
+ }
168
+ }; // componentDidMount
184
169
 
185
- if (_this2.isScrollingToBottom) {
186
- _this2.isScrollingAnimationFrame = window.requestAnimationFrame(scrollToBottom);
187
- }
188
- };
189
170
 
190
- this.startScrollingAnimationFrame = window.requestAnimationFrame(scrollToBottom);
191
- }
192
- }, {
193
- key: "componentDidMount",
194
- value: function componentDidMount() {
195
- if (this.listElement) {
196
- this.listElement.addEventListener('scroll', this.onScroll);
197
- this.listElement.addEventListener('mouseenter', this.onMouseEnter);
198
- this.listElement.addEventListener('mouseleave', this.onMouseLeave);
199
- }
171
+ useEffect(function () {
172
+ addListeners(); // componentWillUnmount
200
173
 
201
- this.scheduleAllToastsForDismissal();
202
- }
203
- }, {
204
- key: "componentDidUpdate",
205
- value: function componentDidUpdate(prevProps) {
206
- this.scheduleAllToastsForDismissal();
207
-
208
- if (!this.isUserInteracting) {
209
- // If the user has scrolled up the toast list then we don't want to annoy them by scrolling
210
- // all the way back to the bottom.
211
- if (this.isScrolledToBottom) {
212
- if (prevProps.toasts.length < this.props.toasts.length) {
213
- this.startScrollingToBottom();
214
- }
215
- }
216
- }
217
- }
218
- }, {
219
- key: "componentWillUnmount",
220
- value: function componentWillUnmount() {
221
- if (this.isScrollingAnimationFrame !== 0) {
222
- window.cancelAnimationFrame(this.isScrollingAnimationFrame);
174
+ return function () {
175
+ if (isScrollingAnimationFrame.current !== 0) {
176
+ window.cancelAnimationFrame(isScrollingAnimationFrame.current);
223
177
  }
224
178
 
225
- if (this.startScrollingAnimationFrame !== 0) {
226
- window.cancelAnimationFrame(this.startScrollingAnimationFrame);
179
+ if (startScrollingAnimationFrame.current !== 0) {
180
+ window.cancelAnimationFrame(startScrollingAnimationFrame.current);
227
181
  }
228
182
 
229
- if (this.listElement) {
230
- this.listElement.removeEventListener('scroll', this.onScroll);
231
- this.listElement.removeEventListener('mouseenter', this.onMouseEnter);
232
- this.listElement.removeEventListener('mouseleave', this.onMouseLeave);
233
- }
183
+ removeListeners();
184
+ dismissTimeoutIds.current.forEach(clearTimeout); // eslint-disable-line react-hooks/exhaustive-deps
234
185
 
235
- this.dismissTimeoutIds.forEach(clearTimeout);
186
+ for (var _toastId3 in toastIdToTimerMap.current) {
187
+ if (toastIdToTimerMap.current.hasOwnProperty(_toastId3)) {
188
+ var timer = toastIdToTimerMap.current[_toastId3]; // eslint-disable-line react-hooks/exhaustive-deps
236
189
 
237
- for (var _toastId3 in this.toastIdToTimerMap) {
238
- if (this.toastIdToTimerMap.hasOwnProperty(_toastId3)) {
239
- var timer = this.toastIdToTimerMap[_toastId3];
240
190
  timer.clear();
241
191
  }
242
192
  }
193
+ };
194
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
195
+ // componentDidUpdate
196
+
197
+ useEffect(function () {
198
+ scheduleAllToastsForDismissal();
199
+
200
+ if (!isUserInteracting.current) {
201
+ // If the user has scrolled up the toast list then we don't want to annoy them by scrolling
202
+ // all the way back to the bottom.
203
+ if (isScrolledToBottom.current) {
204
+ if (prevToasts.current.length < toasts.length) {
205
+ startScrollingToBottom();
206
+ }
207
+ }
243
208
  }
244
- }, {
245
- key: "render",
246
- value: function render() {
247
- var _this3 = this;
248
-
249
- var _this$props = this.props,
250
- className = _this$props.className,
251
- toasts = _this$props.toasts,
252
- dismissToast = _this$props.dismissToast,
253
- toastLifeTimeMs = _this$props.toastLifeTimeMs,
254
- side = _this$props.side,
255
- rest = _objectWithoutProperties(_this$props, _excluded);
256
-
257
- var renderedToasts = toasts.map(function (toast) {
258
- var text = toast.text,
259
- toastLifeTimeMs = toast.toastLifeTimeMs,
260
- rest = _objectWithoutProperties(toast, _excluded2);
261
-
262
- return ___EmotionJSX(EuiGlobalToastListItem, {
263
- key: toast.id,
264
- isDismissed: _this3.state.toastIdToDismissedMap[toast.id]
265
- }, ___EmotionJSX(EuiToast, _extends({
266
- onClose: _this3.dismissToast.bind(_this3, toast),
267
- onFocus: _this3.onMouseEnter,
268
- onBlur: _this3.onMouseLeave
269
- }, rest), text));
209
+
210
+ prevToasts.current = toasts;
211
+ }, [toasts, scheduleAllToastsForDismissal]); // Toast dismissal side effect
212
+ // Ensure the callback has correct state by not enclosing it in `setTimeout`
213
+
214
+ useEffect(function () {
215
+ var toast = toastToDismiss; // Because this is triggered by a setTimeout, and because React does not guarantee when
216
+ // state updates happen, it is possible to double-dismiss a toast
217
+ // including by double-clicking the "x" button on the toast
218
+ // so, first check to make sure we haven't already dismissed this toast
219
+
220
+ if (toast && toastIdToTimerMap.current.hasOwnProperty(toast.id)) {
221
+ dismissToastProp(toast);
222
+ toastIdToTimerMap.current[toast.id].clear();
223
+ delete toastIdToTimerMap.current[toast.id];
224
+ setToastIdToDismissedMap(function (prev) {
225
+ var toastIdToDismissedMap = _objectSpread({}, prev);
226
+
227
+ delete toastIdToDismissedMap[toast.id];
228
+ return toastIdToDismissedMap;
270
229
  });
271
- var classes = classNames('euiGlobalToastList', side ? sideToClassNameMap[side] : null, className);
272
- return ___EmotionJSX("div", _extends({
273
- "aria-live": "polite",
274
- role: "region",
275
- ref: function ref(element) {
276
- _this3.listElement = element;
277
- },
278
- className: classes
279
- }, rest), renderedToasts);
280
230
  }
281
- }]);
282
-
283
- return EuiGlobalToastList;
284
- }(Component);
285
-
286
- _defineProperty(EuiGlobalToastList, "defaultProps", {
287
- toasts: [],
288
- side: 'right'
289
- });
231
+ }, [toastToDismiss, dismissToastProp]);
232
+ var renderedToasts = toasts.map(function (toast) {
233
+ var text = toast.text,
234
+ toastLifeTimeMs = toast.toastLifeTimeMs,
235
+ rest = _objectWithoutProperties(toast, _excluded2);
236
+
237
+ var onClose = function onClose() {
238
+ return dismissToast(toast);
239
+ };
240
+
241
+ return ___EmotionJSX(EuiGlobalToastListItem, {
242
+ key: toast.id,
243
+ isDismissed: toastIdToDismissedMap[toast.id]
244
+ }, ___EmotionJSX(EuiToast, _extends({
245
+ onClose: onClose,
246
+ onFocus: onMouseEnter,
247
+ onBlur: onMouseLeave
248
+ }, rest), text));
249
+ });
250
+ var classes = classNames('euiGlobalToastList', className);
251
+ return ___EmotionJSX("div", _extends({
252
+ "aria-live": "polite",
253
+ role: "region",
254
+ ref: listElement,
255
+ css: cssStyles,
256
+ className: classes
257
+ }, rest), renderedToasts);
258
+ };
@@ -0,0 +1,38 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject;
4
+
5
+ /*
6
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
+ * or more contributor license agreements. Licensed under the Elastic License
8
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
9
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
10
+ * Side Public License, v 1.
11
+ */
12
+ import { css, keyframes } from '@emotion/react';
13
+ import { euiBreakpoint, euiScrollBarStyles, logicalCSS, logicalSizeCSS } from '../../global_styling';
14
+ export var euiGlobalToastListStyles = function euiGlobalToastListStyles(euiThemeContext) {
15
+ var euiTheme = euiThemeContext.euiTheme;
16
+ var euiToastWidth = euiTheme.base * 20;
17
+ return {
18
+ /**
19
+ * 1. Allow list to expand as items are added, but cap it at the screen height.
20
+ * 2. Allow some padding for shadow
21
+ */
22
+ // Base
23
+ euiGlobalToastList: /*#__PURE__*/css(euiScrollBarStyles(euiThemeContext), " display:flex;flex-direction:column;align-items:stretch;position:fixed;z-index:", euiTheme.levels.toast, ";", logicalCSS('bottom', 0), ";", logicalCSS('width', "".concat(euiToastWidth + euiTheme.base * 5, "px")), ";", logicalCSS('max-height', '100vh'), ";overflow-y:auto;", logicalCSS('overflow-y', 'auto'), ";scrollbar-width:none;&::-webkit-scrollbar{", logicalSizeCSS(0, 0), ";}&:not(:empty){", logicalCSS('padding-left', euiTheme.size.base), ";", logicalCSS('padding-right', euiTheme.size.base), ";", logicalCSS('padding-vertical', euiTheme.size.base), ";}", euiBreakpoint(euiThemeContext, ['xs', 's']), "{&:not(:empty){", logicalCSS('left', 0), ";", logicalCSS('width', '100%'), ";}};label:euiGlobalToastList;"),
24
+ // Variants
25
+ right: /*#__PURE__*/css("&:not(:empty){", logicalCSS('right', 0), ";", logicalCSS('padding-left', "".concat(euiTheme.base * 4, "px")), ";}", euiBreakpoint(euiThemeContext, ['xs', 's']), "{&:not(:empty){", logicalCSS('padding-left', euiTheme.size.base), ";}};label:right;"),
26
+ left: /*#__PURE__*/css("&:not(:empty){", logicalCSS('left', 0), ";", logicalCSS('padding-right', "".concat(euiTheme.base * 4, "px")), ";}", euiBreakpoint(euiThemeContext, ['xs', 's']), "{&:not(:empty){", logicalCSS('padding-right', euiTheme.size.base), ";}};label:left;")
27
+ };
28
+ };
29
+ export var euiGlobalToastListItemStyles = function euiGlobalToastListItemStyles(_ref) {
30
+ var euiTheme = _ref.euiTheme;
31
+ var euiShowToast = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from {\n transform: translateY(", ") scale(.9);\n opacity: 0;\n }\n\n to {\n transform: translateY(0) scale(1);\n opacity: 1;\n }\n"])), euiTheme.size.l);
32
+ return {
33
+ // Base
34
+ euiGlobalToastListItem: /*#__PURE__*/css(logicalCSS('margin-bottom', euiTheme.size.base), ";animation:", euiTheme.animation.normal, " ", euiShowToast, " ", euiTheme.animation.resistance, ";opacity:1;&:first-child{", logicalCSS('margin-top', 'auto'), ";}&:last-child{", logicalCSS('margin-bottom', 0), ";};label:euiGlobalToastListItem;"),
35
+ // States
36
+ dismissed: /*#__PURE__*/css("transition:opacity ", euiTheme.animation.normal, ";opacity:0;;label:dismissed;")
37
+ };
38
+ };