@elastic/eui 62.0.2 → 62.2.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 (313) hide show
  1. package/dist/eui_charts_theme.js +330 -330
  2. package/dist/eui_charts_theme.js.map +1 -1
  3. package/dist/eui_theme_dark.css +1 -783
  4. package/dist/eui_theme_dark.json +0 -57
  5. package/dist/eui_theme_dark.json.d.ts +0 -57
  6. package/dist/eui_theme_dark.min.css +1 -1
  7. package/dist/eui_theme_light.css +1 -783
  8. package/dist/eui_theme_light.json +0 -57
  9. package/dist/eui_theme_light.json.d.ts +0 -57
  10. package/dist/eui_theme_light.min.css +1 -1
  11. package/es/components/breadcrumbs/breadcrumb.js +199 -0
  12. package/es/components/breadcrumbs/breadcrumb.styles.js +61 -0
  13. package/es/components/breadcrumbs/breadcrumbs.js +115 -187
  14. package/es/components/breadcrumbs/breadcrumbs.styles.js +30 -0
  15. package/es/components/code/code_block.js +119 -107
  16. package/es/components/collapsible_nav/collapsible_nav.js +2 -2
  17. package/es/components/control_bar/control_bar.js +13 -0
  18. package/es/components/datagrid/body/data_grid_body.js +12 -2
  19. package/es/components/datagrid/body/data_grid_cell.js +31 -3
  20. package/es/components/datagrid/body/header/data_grid_header_row.js +1 -1
  21. package/es/components/datagrid/controls/column_sorting_draggable.js +1 -1
  22. package/es/components/datagrid/data_grid.js +10 -2
  23. package/es/components/datagrid/utils/row_heights.js +33 -4
  24. package/es/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  25. package/es/components/date_picker/super_date_picker/super_update_button.js +1 -1
  26. package/es/components/description_list/description_list.js +22 -26
  27. package/es/components/description_list/description_list.styles.js +25 -0
  28. package/es/components/description_list/description_list_context.js +14 -0
  29. package/es/components/description_list/description_list_description.js +43 -2
  30. package/es/components/description_list/description_list_description.styles.js +47 -0
  31. package/es/components/description_list/description_list_title.js +43 -2
  32. package/es/components/description_list/description_list_title.styles.js +37 -0
  33. package/es/components/description_list/description_list_types.js +10 -0
  34. package/es/components/header/header.js +1 -27
  35. package/es/components/header/header_breadcrumbs/header_breadcrumbs.js +22 -2
  36. package/es/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +15 -0
  37. package/es/components/header/header_links/header_links.js +9 -9
  38. package/es/components/icon/assets/tokenStruct.js +1 -1
  39. package/es/components/page/page_header/page_header.js +1 -0
  40. package/es/components/page/page_header/page_header_content.js +2 -1
  41. package/es/components/page/page_template.js +1 -0
  42. package/es/components/pagination/pagination.js +1 -1
  43. package/es/components/panel/split_panel/split_panel.js +2 -2
  44. package/es/components/popover/wrapping_popover.js +88 -45
  45. package/es/components/portal/portal.js +84 -38
  46. package/es/components/provider/provider.js +2 -2
  47. package/es/components/responsive/hide_for.js +6 -38
  48. package/es/components/responsive/show_for.js +6 -38
  49. package/es/components/selectable/selectable_templates/selectable_template_sitewide.js +17 -36
  50. package/es/components/side_nav/side_nav.js +1 -1
  51. package/es/components/table/table_row_cell.js +1 -2
  52. package/es/components/toast/global_toast_list.js +208 -241
  53. package/es/components/toast/global_toast_list.styles.js +38 -0
  54. package/es/components/toast/global_toast_list_item.js +12 -7
  55. package/es/components/toast/toast.js +25 -25
  56. package/es/components/toast/toast.styles.js +55 -0
  57. package/es/components/token/index.js +2 -1
  58. package/es/components/token/token.js +48 -112
  59. package/es/components/token/token.styles.js +93 -0
  60. package/es/components/token/token_map.js +6 -9
  61. package/es/components/token/token_types.js +11 -0
  62. package/es/global_styling/reset/global_styles.js +1 -1
  63. package/es/services/{breakpoint.js → breakpoint/breakpoint.js} +4 -9
  64. package/es/services/{hooks/useIsWithinBreakpoints.js → breakpoint/currentEuiBreakpoint.js} +36 -28
  65. package/es/services/breakpoint/index.js +10 -0
  66. package/es/services/breakpoint/useIsWithinBreakpoints.js +24 -0
  67. package/es/services/hooks/index.js +0 -1
  68. package/es/services/index.js +1 -1
  69. package/es/test/rtl/component_helpers.js +60 -1
  70. package/eui.d.ts +1787 -1550
  71. package/i18ntokens.json +36 -36
  72. package/lib/components/breadcrumbs/breadcrumb.js +225 -0
  73. package/lib/components/breadcrumbs/breadcrumb.styles.js +68 -0
  74. package/lib/components/breadcrumbs/breadcrumbs.js +125 -188
  75. package/lib/components/breadcrumbs/breadcrumbs.styles.js +33 -0
  76. package/lib/components/code/code_block.js +118 -106
  77. package/lib/components/collapsible_nav/collapsible_nav.js +2 -2
  78. package/lib/components/control_bar/control_bar.js +13 -0
  79. package/lib/components/datagrid/body/data_grid_body.js +12 -2
  80. package/lib/components/datagrid/body/data_grid_cell.js +31 -3
  81. package/lib/components/datagrid/body/header/data_grid_header_row.js +1 -1
  82. package/lib/components/datagrid/controls/column_sorting_draggable.js +1 -1
  83. package/lib/components/datagrid/data_grid.js +10 -2
  84. package/lib/components/datagrid/utils/row_heights.js +33 -4
  85. package/lib/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  86. package/lib/components/date_picker/super_date_picker/super_update_button.js +1 -1
  87. package/lib/components/description_list/description_list.js +25 -31
  88. package/lib/components/description_list/description_list.styles.js +36 -0
  89. package/lib/components/description_list/description_list_context.js +24 -0
  90. package/lib/components/description_list/description_list_description.js +52 -2
  91. package/lib/components/description_list/description_list_description.styles.js +51 -0
  92. package/lib/components/description_list/description_list_title.js +52 -2
  93. package/lib/components/description_list/description_list_title.styles.js +50 -0
  94. package/lib/components/description_list/description_list_types.js +20 -0
  95. package/lib/components/header/header.js +1 -27
  96. package/lib/components/header/header_breadcrumbs/header_breadcrumbs.js +24 -2
  97. package/lib/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +26 -0
  98. package/lib/components/header/header_links/header_links.js +8 -8
  99. package/lib/components/icon/assets/tokenStruct.js +1 -1
  100. package/lib/components/icon/svgs/tokens/tokenStruct.svg +1 -1
  101. package/lib/components/page/page_header/page_header.js +1 -0
  102. package/lib/components/page/page_header/page_header_content.js +3 -2
  103. package/lib/components/page/page_template.js +1 -0
  104. package/lib/components/pagination/pagination.js +1 -1
  105. package/lib/components/panel/split_panel/split_panel.js +3 -3
  106. package/lib/components/popover/wrapping_popover.js +85 -44
  107. package/lib/components/portal/portal.js +87 -39
  108. package/lib/components/provider/provider.js +1 -1
  109. package/lib/components/responsive/hide_for.js +12 -44
  110. package/lib/components/responsive/show_for.js +12 -44
  111. package/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +15 -35
  112. package/lib/components/side_nav/side_nav.js +1 -1
  113. package/lib/components/table/table_row_cell.js +1 -3
  114. package/lib/components/toast/global_toast_list.js +209 -238
  115. package/lib/components/toast/global_toast_list.styles.js +45 -0
  116. package/lib/components/toast/global_toast_list_item.js +14 -7
  117. package/lib/components/toast/toast.js +27 -25
  118. package/lib/components/toast/toast.styles.js +66 -0
  119. package/lib/components/token/index.js +5 -3
  120. package/lib/components/token/token.js +50 -120
  121. package/lib/components/token/token.styles.js +101 -0
  122. package/lib/components/token/token_map.js +6 -9
  123. package/lib/components/token/token_types.js +22 -0
  124. package/lib/global_styling/reset/global_styles.js +1 -1
  125. package/{test-env/services → lib/services/breakpoint}/breakpoint.js +5 -9
  126. package/lib/services/breakpoint/currentEuiBreakpoint.js +80 -0
  127. package/lib/services/breakpoint/index.js +44 -0
  128. package/lib/services/breakpoint/useIsWithinBreakpoints.js +34 -0
  129. package/lib/services/hooks/index.js +0 -13
  130. package/lib/services/index.js +28 -0
  131. package/lib/test/rtl/component_helpers.js +69 -3
  132. package/optimize/es/components/breadcrumbs/breadcrumb.js +136 -0
  133. package/optimize/es/components/breadcrumbs/breadcrumb.styles.js +61 -0
  134. package/optimize/es/components/breadcrumbs/breadcrumbs.js +92 -165
  135. package/optimize/es/components/breadcrumbs/breadcrumbs.styles.js +30 -0
  136. package/optimize/es/components/code/code_block.js +106 -107
  137. package/optimize/es/components/datagrid/body/data_grid_body.js +2 -0
  138. package/optimize/es/components/datagrid/body/data_grid_cell.js +13 -1
  139. package/optimize/es/components/datagrid/utils/row_heights.js +33 -4
  140. package/optimize/es/components/description_list/description_list.js +20 -24
  141. package/optimize/es/components/description_list/description_list.styles.js +25 -0
  142. package/optimize/es/components/description_list/description_list_context.js +14 -0
  143. package/optimize/es/components/description_list/description_list_description.js +32 -2
  144. package/optimize/es/components/description_list/description_list_description.styles.js +47 -0
  145. package/optimize/es/components/description_list/description_list_title.js +32 -2
  146. package/optimize/es/components/description_list/description_list_title.styles.js +37 -0
  147. package/optimize/es/components/description_list/description_list_types.js +10 -0
  148. package/optimize/es/components/header/header_breadcrumbs/header_breadcrumbs.js +8 -1
  149. package/optimize/es/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +15 -0
  150. package/optimize/es/components/header/header_links/header_links.js +8 -8
  151. package/optimize/es/components/icon/assets/tokenStruct.js +1 -1
  152. package/optimize/es/components/page/page_header/page_header_content.js +1 -1
  153. package/optimize/es/components/panel/split_panel/split_panel.js +1 -1
  154. package/optimize/es/components/popover/wrapping_popover.js +79 -38
  155. package/optimize/es/components/portal/portal.js +66 -34
  156. package/optimize/es/components/provider/provider.js +2 -2
  157. package/optimize/es/components/responsive/hide_for.js +5 -27
  158. package/optimize/es/components/responsive/show_for.js +5 -27
  159. package/optimize/es/components/selectable/selectable_templates/selectable_template_sitewide.js +16 -35
  160. package/optimize/es/components/table/table_row_cell.js +1 -2
  161. package/optimize/es/components/toast/global_toast_list.js +199 -230
  162. package/optimize/es/components/toast/global_toast_list.styles.js +38 -0
  163. package/optimize/es/components/toast/global_toast_list_item.js +11 -6
  164. package/optimize/es/components/toast/toast.js +24 -24
  165. package/optimize/es/components/toast/toast.styles.js +55 -0
  166. package/optimize/es/components/token/index.js +2 -1
  167. package/optimize/es/components/token/token.js +46 -69
  168. package/optimize/es/components/token/token.styles.js +83 -0
  169. package/optimize/es/components/token/token_map.js +6 -9
  170. package/optimize/es/components/token/token_types.js +11 -0
  171. package/optimize/es/global_styling/reset/global_styles.js +1 -1
  172. package/optimize/es/services/{breakpoint.js → breakpoint/breakpoint.js} +4 -9
  173. package/optimize/es/services/breakpoint/currentEuiBreakpoint.js +53 -0
  174. package/optimize/es/services/breakpoint/index.js +10 -0
  175. package/optimize/es/services/breakpoint/useIsWithinBreakpoints.js +24 -0
  176. package/optimize/es/services/hooks/index.js +0 -1
  177. package/optimize/es/services/index.js +1 -1
  178. package/optimize/es/test/rtl/component_helpers.js +60 -1
  179. package/optimize/lib/components/breadcrumbs/breadcrumb.js +162 -0
  180. package/optimize/lib/components/breadcrumbs/breadcrumb.styles.js +68 -0
  181. package/optimize/lib/components/breadcrumbs/breadcrumbs.js +99 -164
  182. package/optimize/lib/components/breadcrumbs/breadcrumbs.styles.js +33 -0
  183. package/optimize/lib/components/code/code_block.js +105 -106
  184. package/optimize/lib/components/datagrid/body/data_grid_body.js +2 -0
  185. package/optimize/lib/components/datagrid/body/data_grid_cell.js +13 -1
  186. package/optimize/lib/components/datagrid/utils/row_heights.js +33 -4
  187. package/optimize/lib/components/description_list/description_list.js +23 -28
  188. package/optimize/lib/components/description_list/description_list.styles.js +36 -0
  189. package/optimize/lib/components/description_list/description_list_context.js +24 -0
  190. package/optimize/lib/components/description_list/description_list_description.js +43 -2
  191. package/optimize/lib/components/description_list/description_list_description.styles.js +51 -0
  192. package/optimize/lib/components/description_list/description_list_title.js +43 -2
  193. package/optimize/lib/components/description_list/description_list_title.styles.js +50 -0
  194. package/optimize/lib/components/description_list/description_list_types.js +20 -0
  195. package/optimize/lib/components/header/header_breadcrumbs/header_breadcrumbs.js +10 -1
  196. package/optimize/lib/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +26 -0
  197. package/optimize/lib/components/header/header_links/header_links.js +7 -7
  198. package/optimize/lib/components/icon/assets/tokenStruct.js +1 -1
  199. package/optimize/lib/components/icon/svgs/tokens/tokenStruct.svg +1 -1
  200. package/optimize/lib/components/page/page_header/page_header_content.js +2 -2
  201. package/optimize/lib/components/panel/split_panel/split_panel.js +2 -2
  202. package/optimize/lib/components/popover/wrapping_popover.js +78 -38
  203. package/optimize/lib/components/portal/portal.js +65 -44
  204. package/optimize/lib/components/provider/provider.js +1 -1
  205. package/optimize/lib/components/responsive/hide_for.js +4 -33
  206. package/optimize/lib/components/responsive/show_for.js +4 -33
  207. package/optimize/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +14 -34
  208. package/optimize/lib/components/table/table_row_cell.js +1 -3
  209. package/optimize/lib/components/toast/global_toast_list.js +206 -220
  210. package/optimize/lib/components/toast/global_toast_list.styles.js +47 -0
  211. package/optimize/lib/components/toast/global_toast_list_item.js +14 -7
  212. package/optimize/lib/components/toast/toast.js +26 -24
  213. package/optimize/lib/components/toast/toast.styles.js +66 -0
  214. package/optimize/lib/components/token/index.js +5 -3
  215. package/optimize/lib/components/token/token.js +50 -76
  216. package/optimize/lib/components/token/token.styles.js +91 -0
  217. package/optimize/lib/components/token/token_map.js +6 -9
  218. package/optimize/lib/components/token/token_types.js +22 -0
  219. package/optimize/lib/global_styling/reset/global_styles.js +1 -1
  220. package/optimize/lib/services/{breakpoint.js → breakpoint/breakpoint.js} +5 -9
  221. package/optimize/lib/services/breakpoint/currentEuiBreakpoint.js +81 -0
  222. package/optimize/lib/services/breakpoint/index.js +44 -0
  223. package/optimize/lib/services/breakpoint/useIsWithinBreakpoints.js +34 -0
  224. package/optimize/lib/services/hooks/index.js +0 -13
  225. package/optimize/lib/services/index.js +28 -0
  226. package/optimize/lib/test/rtl/component_helpers.js +69 -3
  227. package/package.json +2 -2
  228. package/src/components/control_bar/_control_bar.scss +1 -1
  229. package/src/components/header/_index.scss +0 -1
  230. package/src/components/index.scss +0 -5
  231. package/src/themes/amsterdam/overrides/_breadcrumbs.scss +0 -12
  232. package/src/themes/amsterdam/overrides/_index.scss +0 -4
  233. package/test-env/components/breadcrumbs/breadcrumb.js +211 -0
  234. package/test-env/components/breadcrumbs/breadcrumb.styles.js +68 -0
  235. package/test-env/components/breadcrumbs/breadcrumbs.js +122 -174
  236. package/test-env/components/breadcrumbs/breadcrumbs.styles.js +33 -0
  237. package/test-env/components/collapsible_nav/collapsible_nav.js +2 -2
  238. package/test-env/components/control_bar/control_bar.js +13 -0
  239. package/test-env/components/datagrid/body/data_grid_body.js +12 -2
  240. package/test-env/components/datagrid/body/data_grid_cell.js +31 -3
  241. package/test-env/components/datagrid/body/header/data_grid_header_row.js +1 -1
  242. package/test-env/components/datagrid/controls/column_sorting_draggable.js +1 -1
  243. package/test-env/components/datagrid/data_grid.js +10 -2
  244. package/test-env/components/datagrid/utils/row_heights.js +33 -4
  245. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +2 -2
  246. package/test-env/components/date_picker/super_date_picker/super_update_button.js +1 -1
  247. package/test-env/components/description_list/description_list.js +25 -30
  248. package/test-env/components/description_list/description_list.styles.js +36 -0
  249. package/test-env/components/description_list/description_list_context.js +24 -0
  250. package/test-env/components/description_list/description_list_description.js +43 -2
  251. package/test-env/components/description_list/description_list_description.styles.js +51 -0
  252. package/test-env/components/description_list/description_list_title.js +43 -2
  253. package/test-env/components/description_list/description_list_title.styles.js +50 -0
  254. package/test-env/components/description_list/description_list_types.js +20 -0
  255. package/test-env/components/header/header.js +1 -27
  256. package/test-env/components/header/header_breadcrumbs/header_breadcrumbs.js +24 -2
  257. package/test-env/components/header/header_breadcrumbs/header_breadcrumbs.styles.js +26 -0
  258. package/test-env/components/header/header_links/header_links.js +8 -8
  259. package/test-env/components/icon/assets/tokenStruct.js +1 -1
  260. package/test-env/components/observer/resize_observer/resize_observer.js +43 -126
  261. package/test-env/components/page/page_header/page_header.js +1 -0
  262. package/test-env/components/page/page_header/page_header_content.js +3 -2
  263. package/test-env/components/page/page_template.js +1 -0
  264. package/test-env/components/pagination/pagination.js +1 -1
  265. package/test-env/components/panel/split_panel/split_panel.js +3 -3
  266. package/test-env/components/popover/wrapping_popover.js +78 -38
  267. package/test-env/components/portal/portal.js +79 -45
  268. package/test-env/components/provider/provider.js +1 -1
  269. package/test-env/components/responsive/hide_for.js +5 -34
  270. package/test-env/components/responsive/show_for.js +5 -34
  271. package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.js +15 -35
  272. package/test-env/components/side_nav/side_nav.js +1 -1
  273. package/test-env/components/table/table_row_cell.js +1 -3
  274. package/test-env/components/toast/global_toast_list.js +206 -220
  275. package/test-env/components/toast/global_toast_list.styles.js +47 -0
  276. package/test-env/components/toast/global_toast_list_item.js +14 -7
  277. package/test-env/components/toast/toast.js +27 -25
  278. package/test-env/components/toast/toast.styles.js +66 -0
  279. package/test-env/components/token/index.js +5 -3
  280. package/test-env/components/token/token.js +51 -120
  281. package/test-env/components/token/token.styles.js +91 -0
  282. package/test-env/components/token/token_map.js +6 -9
  283. package/test-env/components/token/token_types.js +22 -0
  284. package/test-env/global_styling/reset/global_styles.js +1 -1
  285. package/{lib/services → test-env/services/breakpoint}/breakpoint.js +5 -9
  286. package/test-env/services/breakpoint/currentEuiBreakpoint.js +37 -0
  287. package/test-env/services/breakpoint/index.js +44 -0
  288. package/test-env/services/breakpoint/useIsWithinBreakpoints.js +34 -0
  289. package/test-env/services/hooks/index.js +0 -13
  290. package/test-env/services/index.js +28 -0
  291. package/test-env/test/rtl/component_helpers.js +69 -3
  292. package/lib/services/hooks/useIsWithinBreakpoints.js +0 -57
  293. package/optimize/es/services/hooks/useIsWithinBreakpoints.js +0 -46
  294. package/optimize/lib/services/hooks/useIsWithinBreakpoints.js +0 -57
  295. package/src/components/breadcrumbs/_breadcrumbs.scss +0 -79
  296. package/src/components/breadcrumbs/_index.scss +0 -2
  297. package/src/components/breadcrumbs/_variables.scss +0 -2
  298. package/src/components/description_list/_description_list.scss +0 -211
  299. package/src/components/description_list/_index.scss +0 -1
  300. package/src/components/header/header_breadcrumbs/_header_breadcrumbs.scss +0 -8
  301. package/src/components/header/header_breadcrumbs/_index.scss +0 -1
  302. package/src/components/portal/_index.scss +0 -1
  303. package/src/components/portal/_portal.scss +0 -6
  304. package/src/components/toast/_global_toast_list.scss +0 -90
  305. package/src/components/toast/_index.scss +0 -4
  306. package/src/components/toast/_toast.scss +0 -103
  307. package/src/components/token/_index.scss +0 -2
  308. package/src/components/token/_token.scss +0 -85
  309. package/src/components/token/_variables.scss +0 -13
  310. package/src/themes/amsterdam/overrides/_header_breadcrumbs.scss +0 -71
  311. package/src/themes/amsterdam/overrides/_toast.scss +0 -21
  312. package/src/themes/amsterdam/overrides/_token.scss +0 -4
  313. package/test-env/services/hooks/useIsWithinBreakpoints.js +0 -57
@@ -1,39 +1,29 @@
1
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
2
-
3
1
  var _excluded = ["className", "toasts", "dismissToast", "toastLifeTimeMs", "side"],
4
2
  _excluded2 = ["text", "toastLifeTimeMs"];
5
3
 
6
4
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
7
5
 
8
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
-
10
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
11
-
12
6
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
13
7
 
14
8
  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; }
15
9
 
16
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17
-
18
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
19
-
20
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
10
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
11
 
22
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
12
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
13
 
24
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
14
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
25
15
 
26
- 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); }; }
16
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
27
17
 
28
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
18
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
29
19
 
30
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
20
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
31
21
 
32
- 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; } }
22
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
33
23
 
34
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
24
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
35
25
 
36
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
26
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
27
 
38
28
  /*
39
29
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
@@ -42,13 +32,15 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
42
32
  * in compliance with, at your election, the Elastic License 2.0 or the Server
43
33
  * Side Public License, v 1.
44
34
  */
45
- import React, { Component } from 'react';
35
+ import React, { useCallback, useEffect, useRef, useState } from 'react';
46
36
  import PropTypes from "prop-types";
47
37
  import classNames from 'classnames';
48
38
  import { keysOf } from '../common';
39
+ import { useEuiTheme } from '../../services';
49
40
  import { Timer } from '../../services/time';
50
41
  import { EuiGlobalToastListItem } from './global_toast_list_item';
51
42
  import { EuiToast } from './toast';
43
+ import { euiGlobalToastListStyles } from './global_toast_list.styles';
52
44
  import { jsx as ___EmotionJSX } from "@emotion/react";
53
45
  var sideToClassNameMap = {
54
46
  left: 'euiGlobalToastList--left',
@@ -56,269 +48,244 @@ var sideToClassNameMap = {
56
48
  };
57
49
  export var SIDES = keysOf(sideToClassNameMap);
58
50
  export var TOAST_FADE_OUT_MS = 250;
59
- export var EuiGlobalToastList = /*#__PURE__*/function (_Component) {
60
- _inherits(EuiGlobalToastList, _Component);
61
-
62
- var _super = _createSuper(EuiGlobalToastList);
63
-
64
- function EuiGlobalToastList() {
65
- var _this;
66
-
67
- _classCallCheck(this, EuiGlobalToastList);
68
-
69
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
70
- args[_key] = arguments[_key];
71
- }
72
-
73
- _this = _super.call.apply(_super, [this].concat(args));
74
-
75
- _defineProperty(_assertThisInitialized(_this), "state", {
76
- toastIdToDismissedMap: {}
77
- });
78
-
79
- _defineProperty(_assertThisInitialized(_this), "dismissTimeoutIds", []);
80
-
81
- _defineProperty(_assertThisInitialized(_this), "toastIdToTimerMap", {});
82
-
83
- _defineProperty(_assertThisInitialized(_this), "isScrollingToBottom", false);
51
+ export var EuiGlobalToastList = function EuiGlobalToastList(_ref) {
52
+ var className = _ref.className,
53
+ _ref$toasts = _ref.toasts,
54
+ toasts = _ref$toasts === void 0 ? [] : _ref$toasts,
55
+ dismissToastProp = _ref.dismissToast,
56
+ toastLifeTimeMs = _ref.toastLifeTimeMs,
57
+ _ref$side = _ref.side,
58
+ side = _ref$side === void 0 ? 'right' : _ref$side,
59
+ rest = _objectWithoutProperties(_ref, _excluded);
60
+
61
+ var _useState = useState({}),
62
+ _useState2 = _slicedToArray(_useState, 2),
63
+ toastIdToDismissedMap = _useState2[0],
64
+ setToastIdToDismissedMap = _useState2[1];
65
+
66
+ var _useState3 = useState(),
67
+ _useState4 = _slicedToArray(_useState3, 2),
68
+ toastToDismiss = _useState4[0],
69
+ setToastToDismiss = _useState4[1];
70
+
71
+ var prevToasts = useRef([]);
72
+ var dismissTimeoutIds = useRef([]);
73
+ var toastIdToTimerMap = useRef({});
74
+ var isScrollingToBottom = useRef(false);
75
+ var isScrolledToBottom = useRef(true);
76
+ var isUserInteracting = useRef(false); // See [Return Value](https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame#Return_value)
77
+ // for information on initial value of 0
78
+
79
+ var isScrollingAnimationFrame = useRef(0);
80
+ var startScrollingAnimationFrame = useRef(0);
81
+ var listElement = useRef(null);
82
+ var euiTheme = useEuiTheme();
83
+ var styles = euiGlobalToastListStyles(euiTheme);
84
+ var cssStyles = [styles.euiGlobalToastList, styles[side]];
85
+
86
+ var startScrollingToBottom = function startScrollingToBottom() {
87
+ isScrollingToBottom.current = true;
88
+
89
+ var scrollToBottom = function scrollToBottom() {
90
+ // Although we cancel the requestAnimationFrame in componentWillUnmount,
91
+ // it's possible for this.listElement to become null in the meantime
92
+ if (!listElement.current) {
93
+ return;
94
+ }
84
95
 
85
- _defineProperty(_assertThisInitialized(_this), "isScrolledToBottom", true);
96
+ var position = listElement.current.scrollTop;
97
+ var destination = listElement.current.scrollHeight - listElement.current.clientHeight;
98
+ var distanceToDestination = destination - position;
86
99
 
87
- _defineProperty(_assertThisInitialized(_this), "isUserInteracting", false);
100
+ if (distanceToDestination < 5) {
101
+ listElement.current.scrollTop = destination;
102
+ isScrollingToBottom.current = false;
103
+ isScrolledToBottom.current = true;
104
+ return;
105
+ }
88
106
 
89
- _defineProperty(_assertThisInitialized(_this), "isScrollingAnimationFrame", 0);
107
+ listElement.current.scrollTop = position + distanceToDestination * 0.25;
90
108
 
91
- _defineProperty(_assertThisInitialized(_this), "startScrollingAnimationFrame", 0);
109
+ if (isScrollingToBottom) {
110
+ isScrollingAnimationFrame.current = window.requestAnimationFrame(scrollToBottom);
111
+ }
112
+ };
92
113
 
93
- _defineProperty(_assertThisInitialized(_this), "listElement", null);
114
+ startScrollingAnimationFrame.current = window.requestAnimationFrame(scrollToBottom);
115
+ };
94
116
 
95
- _defineProperty(_assertThisInitialized(_this), "onMouseEnter", function () {
96
- // Stop scrolling to bottom if we're in mid-scroll, because the user wants to interact with
97
- // the list.
98
- _this.isScrollingToBottom = false;
99
- _this.isUserInteracting = true; // Don't let toasts dismiss themselves while the user is interacting with them.
117
+ var onMouseEnter = function onMouseEnter() {
118
+ // Stop scrolling to bottom if we're in mid-scroll, because the user wants to interact with
119
+ // the list.
120
+ isScrollingToBottom.current = false;
121
+ isUserInteracting.current = true; // Don't let toasts dismiss themselves while the user is interacting with them.
100
122
 
101
- for (var _toastId in _this.toastIdToTimerMap) {
102
- if (_this.toastIdToTimerMap.hasOwnProperty(_toastId)) {
103
- var timer = _this.toastIdToTimerMap[_toastId];
104
- timer.pause();
105
- }
123
+ for (var _toastId in toastIdToTimerMap.current) {
124
+ if (toastIdToTimerMap.current.hasOwnProperty(_toastId)) {
125
+ var timer = toastIdToTimerMap.current[_toastId];
126
+ timer.pause();
106
127
  }
107
- });
108
-
109
- _defineProperty(_assertThisInitialized(_this), "onMouseLeave", function () {
110
- _this.isUserInteracting = false;
128
+ }
129
+ };
111
130
 
112
- for (var _toastId2 in _this.toastIdToTimerMap) {
113
- if (_this.toastIdToTimerMap.hasOwnProperty(_toastId2)) {
114
- var timer = _this.toastIdToTimerMap[_toastId2];
115
- timer.resume();
116
- }
117
- }
118
- });
131
+ var onMouseLeave = function onMouseLeave() {
132
+ isUserInteracting.current = false;
119
133
 
120
- _defineProperty(_assertThisInitialized(_this), "onScroll", function () {
121
- if (_this.listElement) {
122
- _this.isScrolledToBottom = _this.listElement.scrollHeight - _this.listElement.scrollTop === _this.listElement.clientHeight;
134
+ for (var _toastId2 in toastIdToTimerMap.current) {
135
+ if (toastIdToTimerMap.current.hasOwnProperty(_toastId2)) {
136
+ var timer = toastIdToTimerMap.current[_toastId2];
137
+ timer.resume();
123
138
  }
124
- });
125
-
126
- _defineProperty(_assertThisInitialized(_this), "scheduleAllToastsForDismissal", function () {
127
- _this.props.toasts.forEach(function (toast) {
128
- if (!_this.toastIdToTimerMap[toast.id]) {
129
- _this.scheduleToastForDismissal(toast);
130
- }
131
- });
132
- });
139
+ }
140
+ };
133
141
 
134
- _defineProperty(_assertThisInitialized(_this), "scheduleToastForDismissal", function (toast) {
135
- // Start fading the toast out once its lifetime elapses.
136
- _this.toastIdToTimerMap[toast.id] = new Timer(_this.dismissToast.bind(_assertThisInitialized(_this), toast), toast.toastLifeTimeMs != null ? toast.toastLifeTimeMs : _this.props.toastLifeTimeMs);
142
+ var onScroll = function onScroll() {
143
+ if (listElement.current) {
144
+ isScrolledToBottom.current = listElement.current.scrollHeight - listElement.current.scrollTop === listElement.current.clientHeight;
145
+ }
146
+ };
147
+
148
+ var dismissToast = useCallback(function (toast) {
149
+ // Remove the toast after it's done fading out.
150
+ dismissTimeoutIds.current.push(window.setTimeout(function () {
151
+ setToastToDismiss(toast);
152
+ }, TOAST_FADE_OUT_MS));
153
+ setToastIdToDismissedMap(function (prev) {
154
+ return _objectSpread(_objectSpread({}, prev), {}, _defineProperty({}, toast.id, true));
137
155
  });
138
-
139
- _defineProperty(_assertThisInitialized(_this), "dismissToast", function (toast) {
140
- // Remove the toast after it's done fading out.
141
- _this.dismissTimeoutIds.push(window.setTimeout(function () {
142
- // Because this is wrapped in a setTimeout, and because React does not guarantee when
143
- // state updates happen, it is possible to double-dismiss a toast
144
- // including by double-clicking the "x" button on the toast
145
- // so, first check to make sure we haven't already dismissed this toast
146
- if (_this.toastIdToTimerMap.hasOwnProperty(toast.id)) {
147
- _this.props.dismissToast.apply(_assertThisInitialized(_this), [toast]);
148
-
149
- _this.toastIdToTimerMap[toast.id].clear();
150
-
151
- delete _this.toastIdToTimerMap[toast.id];
152
-
153
- _this.setState(function (prevState) {
154
- var toastIdToDismissedMap = _objectSpread({}, prevState.toastIdToDismissedMap);
155
-
156
- delete toastIdToDismissedMap[toast.id];
157
- return {
158
- toastIdToDismissedMap: toastIdToDismissedMap
159
- };
160
- });
161
- }
162
- }, TOAST_FADE_OUT_MS));
163
-
164
- _this.setState(function (prevState) {
165
- var toastIdToDismissedMap = _objectSpread(_objectSpread({}, prevState.toastIdToDismissedMap), {}, _defineProperty({}, toast.id, true));
166
-
167
- return {
168
- toastIdToDismissedMap: toastIdToDismissedMap
169
- };
170
- });
156
+ }, []);
157
+ var scheduleToastForDismissal = useCallback(function (toast) {
158
+ // Start fading the toast out once its lifetime elapses.
159
+ toastIdToTimerMap.current[toast.id] = new Timer(function () {
160
+ return dismissToast(toast);
161
+ }, toast.toastLifeTimeMs != null ? toast.toastLifeTimeMs : toastLifeTimeMs);
162
+ }, [dismissToast, toastLifeTimeMs]);
163
+ var scheduleAllToastsForDismissal = useCallback(function () {
164
+ toasts.forEach(function (toast) {
165
+ if (!toastIdToTimerMap.current[toast.id]) {
166
+ scheduleToastForDismissal(toast);
167
+ }
171
168
  });
169
+ }, [scheduleToastForDismissal, toasts]);
172
170
 
173
- return _this;
174
- }
175
-
176
- _createClass(EuiGlobalToastList, [{
177
- key: "startScrollingToBottom",
178
- value: function startScrollingToBottom() {
179
- var _this2 = this;
180
-
181
- this.isScrollingToBottom = true;
182
-
183
- var scrollToBottom = function scrollToBottom() {
184
- // Although we cancel the requestAnimationFrame in componentWillUnmount,
185
- // it's possible for this.listElement to become null in the meantime
186
- if (!_this2.listElement) {
187
- return;
188
- }
189
-
190
- var position = _this2.listElement.scrollTop;
191
- var destination = _this2.listElement.scrollHeight - _this2.listElement.clientHeight;
192
- var distanceToDestination = destination - position;
193
-
194
- if (distanceToDestination < 5) {
195
- _this2.listElement.scrollTop = destination;
196
- _this2.isScrollingToBottom = false;
197
- _this2.isScrolledToBottom = true;
198
- return;
199
- }
171
+ var addListeners = function addListeners() {
172
+ if (listElement.current) {
173
+ listElement.current.addEventListener('scroll', onScroll);
174
+ listElement.current.addEventListener('mouseenter', onMouseEnter);
175
+ listElement.current.addEventListener('mouseleave', onMouseLeave);
176
+ }
177
+ };
200
178
 
201
- _this2.listElement.scrollTop = position + distanceToDestination * 0.25;
179
+ var removeListeners = function removeListeners() {
180
+ if (listElement.current) {
181
+ listElement.current.removeEventListener('scroll', onScroll);
182
+ listElement.current.removeEventListener('mouseenter', onMouseEnter);
183
+ listElement.current.removeEventListener('mouseleave', onMouseLeave);
184
+ }
185
+ }; // componentDidMount
202
186
 
203
- if (_this2.isScrollingToBottom) {
204
- _this2.isScrollingAnimationFrame = window.requestAnimationFrame(scrollToBottom);
205
- }
206
- };
207
187
 
208
- this.startScrollingAnimationFrame = window.requestAnimationFrame(scrollToBottom);
209
- }
210
- }, {
211
- key: "componentDidMount",
212
- value: function componentDidMount() {
213
- if (this.listElement) {
214
- this.listElement.addEventListener('scroll', this.onScroll);
215
- this.listElement.addEventListener('mouseenter', this.onMouseEnter);
216
- this.listElement.addEventListener('mouseleave', this.onMouseLeave);
217
- }
188
+ useEffect(function () {
189
+ addListeners(); // componentWillUnmount
218
190
 
219
- this.scheduleAllToastsForDismissal();
220
- }
221
- }, {
222
- key: "componentDidUpdate",
223
- value: function componentDidUpdate(prevProps) {
224
- this.scheduleAllToastsForDismissal();
225
-
226
- if (!this.isUserInteracting) {
227
- // If the user has scrolled up the toast list then we don't want to annoy them by scrolling
228
- // all the way back to the bottom.
229
- if (this.isScrolledToBottom) {
230
- if (prevProps.toasts.length < this.props.toasts.length) {
231
- this.startScrollingToBottom();
232
- }
233
- }
234
- }
235
- }
236
- }, {
237
- key: "componentWillUnmount",
238
- value: function componentWillUnmount() {
239
- if (this.isScrollingAnimationFrame !== 0) {
240
- window.cancelAnimationFrame(this.isScrollingAnimationFrame);
191
+ return function () {
192
+ if (isScrollingAnimationFrame.current !== 0) {
193
+ window.cancelAnimationFrame(isScrollingAnimationFrame.current);
241
194
  }
242
195
 
243
- if (this.startScrollingAnimationFrame !== 0) {
244
- window.cancelAnimationFrame(this.startScrollingAnimationFrame);
196
+ if (startScrollingAnimationFrame.current !== 0) {
197
+ window.cancelAnimationFrame(startScrollingAnimationFrame.current);
245
198
  }
246
199
 
247
- if (this.listElement) {
248
- this.listElement.removeEventListener('scroll', this.onScroll);
249
- this.listElement.removeEventListener('mouseenter', this.onMouseEnter);
250
- this.listElement.removeEventListener('mouseleave', this.onMouseLeave);
251
- }
200
+ removeListeners();
201
+ dismissTimeoutIds.current.forEach(clearTimeout); // eslint-disable-line react-hooks/exhaustive-deps
252
202
 
253
- this.dismissTimeoutIds.forEach(clearTimeout);
203
+ for (var _toastId3 in toastIdToTimerMap.current) {
204
+ if (toastIdToTimerMap.current.hasOwnProperty(_toastId3)) {
205
+ var timer = toastIdToTimerMap.current[_toastId3]; // eslint-disable-line react-hooks/exhaustive-deps
254
206
 
255
- for (var _toastId3 in this.toastIdToTimerMap) {
256
- if (this.toastIdToTimerMap.hasOwnProperty(_toastId3)) {
257
- var timer = this.toastIdToTimerMap[_toastId3];
258
207
  timer.clear();
259
208
  }
260
209
  }
210
+ };
211
+ }, []); // eslint-disable-line react-hooks/exhaustive-deps
212
+ // componentDidUpdate
213
+
214
+ useEffect(function () {
215
+ scheduleAllToastsForDismissal();
216
+
217
+ if (!isUserInteracting.current) {
218
+ // If the user has scrolled up the toast list then we don't want to annoy them by scrolling
219
+ // all the way back to the bottom.
220
+ if (isScrolledToBottom.current) {
221
+ if (prevToasts.current.length < toasts.length) {
222
+ startScrollingToBottom();
223
+ }
224
+ }
261
225
  }
262
- }, {
263
- key: "render",
264
- value: function render() {
265
- var _this3 = this;
266
-
267
- var _this$props = this.props,
268
- className = _this$props.className,
269
- toasts = _this$props.toasts,
270
- dismissToast = _this$props.dismissToast,
271
- toastLifeTimeMs = _this$props.toastLifeTimeMs,
272
- side = _this$props.side,
273
- rest = _objectWithoutProperties(_this$props, _excluded);
274
-
275
- var renderedToasts = toasts.map(function (toast) {
276
- var text = toast.text,
277
- toastLifeTimeMs = toast.toastLifeTimeMs,
278
- rest = _objectWithoutProperties(toast, _excluded2);
279
-
280
- return ___EmotionJSX(EuiGlobalToastListItem, {
281
- key: toast.id,
282
- isDismissed: _this3.state.toastIdToDismissedMap[toast.id]
283
- }, ___EmotionJSX(EuiToast, _extends({
284
- onClose: _this3.dismissToast.bind(_this3, toast),
285
- onFocus: _this3.onMouseEnter,
286
- onBlur: _this3.onMouseLeave
287
- }, rest), text));
226
+
227
+ prevToasts.current = toasts;
228
+ }, [toasts, scheduleAllToastsForDismissal]); // Toast dismissal side effect
229
+ // Ensure the callback has correct state by not enclosing it in `setTimeout`
230
+
231
+ useEffect(function () {
232
+ var toast = toastToDismiss; // Because this is triggered by a setTimeout, and because React does not guarantee when
233
+ // state updates happen, it is possible to double-dismiss a toast
234
+ // including by double-clicking the "x" button on the toast
235
+ // so, first check to make sure we haven't already dismissed this toast
236
+
237
+ if (toast && toastIdToTimerMap.current.hasOwnProperty(toast.id)) {
238
+ dismissToastProp(toast);
239
+ toastIdToTimerMap.current[toast.id].clear();
240
+ delete toastIdToTimerMap.current[toast.id];
241
+ setToastIdToDismissedMap(function (prev) {
242
+ var toastIdToDismissedMap = _objectSpread({}, prev);
243
+
244
+ delete toastIdToDismissedMap[toast.id];
245
+ return toastIdToDismissedMap;
288
246
  });
289
- var classes = classNames('euiGlobalToastList', side ? sideToClassNameMap[side] : null, className);
290
- return ___EmotionJSX("div", _extends({
291
- "aria-live": "polite",
292
- role: "region",
293
- ref: function ref(element) {
294
- _this3.listElement = element;
295
- },
296
- className: classes
297
- }, rest), renderedToasts);
298
247
  }
299
- }]);
300
-
301
- return EuiGlobalToastList;
302
- }(Component);
303
-
304
- _defineProperty(EuiGlobalToastList, "defaultProps", {
305
- toasts: [],
306
- side: 'right'
307
- });
308
-
248
+ }, [toastToDismiss, dismissToastProp]);
249
+ var renderedToasts = toasts.map(function (toast) {
250
+ var text = toast.text,
251
+ toastLifeTimeMs = toast.toastLifeTimeMs,
252
+ rest = _objectWithoutProperties(toast, _excluded2);
253
+
254
+ var onClose = function onClose() {
255
+ return dismissToast(toast);
256
+ };
257
+
258
+ return ___EmotionJSX(EuiGlobalToastListItem, {
259
+ key: toast.id,
260
+ isDismissed: toastIdToDismissedMap[toast.id]
261
+ }, ___EmotionJSX(EuiToast, _extends({
262
+ onClose: onClose,
263
+ onFocus: onMouseEnter,
264
+ onBlur: onMouseLeave
265
+ }, rest), text));
266
+ });
267
+ var classes = classNames('euiGlobalToastList', className);
268
+ return ___EmotionJSX("div", _extends({
269
+ "aria-live": "polite",
270
+ role: "region",
271
+ ref: listElement,
272
+ css: cssStyles,
273
+ className: classes
274
+ }, rest), renderedToasts);
275
+ };
309
276
  EuiGlobalToastList.propTypes = {
310
277
  toasts: PropTypes.arrayOf(PropTypes.shape({
311
278
  id: PropTypes.string.isRequired,
312
279
  text: PropTypes.node,
313
280
  toastLifeTimeMs: PropTypes.number,
314
281
  title: PropTypes.node,
315
- color: PropTypes.oneOf(["primary", "success", "warning", "danger"]),
282
+ color: PropTypes.any,
316
283
  iconType: PropTypes.oneOfType([PropTypes.oneOf(["accessibility", "addDataApp", "advancedSettingsApp", "agentApp", "aggregate", "alert", "analyzeEvent", "annotation", "apmApp", "apmTrace", "appSearchApp", "apps", "arrowDown", "arrowLeft", "arrowRight", "arrowUp", "arrowStart", "arrowEnd", "asterisk", "auditbeatApp", "beaker", "bell", "bellSlash", "bolt", "boxesHorizontal", "boxesVertical", "branch", "branchUser", "broom", "brush", "bug", "bullseye", "calendar", "canvasApp", "casesApp", "check", "checkInCircleFilled", "cheer", "classificationJob", "clock", "cloudDrizzle", "cloudStormy", "cloudSunny", "cluster", "codeApp", "color", "compute", "console", "consoleApp", "container", "continuityAbove", "continuityAboveBelow", "continuityBelow", "continuityWithin", "controlsHorizontal", "controlsVertical", "copy", "copyClipboard", "createAdvancedJob", "createMultiMetricJob", "createPopulationJob", "createSingleMetricJob", "cross", "crossClusterReplicationApp", "crossInACircleFilled", "crosshairs", "currency", "cut", "dashboardApp", "dataVisualizer", "database", "desktop", "devToolsApp", "discoverApp", "document", "documentEdit", "documentation", "documents", "dot", "doubleArrowLeft", "doubleArrowRight", "download", "editorAlignCenter", "editorAlignLeft", "editorAlignRight", "editorBold", "editorChecklist", "editorCodeBlock", "editorComment", "editorDistributeHorizontal", "editorDistributeVertical", "editorHeading", "editorItalic", "editorItemAlignBottom", "editorItemAlignCenter", "editorItemAlignLeft", "editorItemAlignMiddle", "editorItemAlignRight", "editorItemAlignTop", "editorLink", "editorOrderedList", "editorPositionBottomLeft", "editorPositionBottomRight", "editorPositionTopLeft", "editorPositionTopRight", "editorRedo", "editorStrike", "editorTable", "editorUnderline", "editorUndo", "editorUnorderedList", "email", "empty", "emsApp", "eql", "eraser", "exit", "expand", "expandMini", "exportAction", "eye", "eyeClosed", "faceHappy", "faceNeutral", "faceSad", "filebeatApp", "filter", "flag", "fleetApp", "fold", "folderCheck", "folderClosed", "folderExclamation", "folderOpen", "frameNext", "framePrevious", "fullScreen", "fullScreenExit", "function", "gear", "gisApp", "glasses", "globe", "grab", "grabHorizontal", "graphApp", "grid", "grokApp", "heart", "heartbeatApp", "heatmap", "help", "home", "iInCircle", "image", "importAction", "indexClose", "indexEdit", "indexFlush", "indexManagementApp", "indexMapping", "indexOpen", "indexPatternApp", "indexRollupApp", "indexRuntime", "indexSettings", "inputOutput", "inspect", "invert", "ip", "keyboard", "kqlField", "kqlFunction", "kqlOperand", "kqlSelector", "kqlValue", "kubernetesNode", "kubernetesPod", "layers", "lensApp", "lettering", "lineDashed", "lineDotted", "lineSolid", "link", "list", "listAdd", "lock", "lockOpen", "logoAWS", "logoAWSMono", "logoAerospike", "logoApache", "logoAppSearch", "logoAzure", "logoAzureMono", "logoBeats", "logoBusinessAnalytics", "logoCeph", "logoCloud", "logoCloudEnterprise", "logoCode", "logoCodesandbox", "logoCouchbase", "logoDocker", "logoDropwizard", "logoElastic", "logoElasticStack", "logoElasticsearch", "logoEnterpriseSearch", "logoEtcd", "logoGCP", "logoGCPMono", "logoGithub", "logoGmail", "logoGolang", "logoGoogleG", "logoHAproxy", "logoIBM", "logoIBMMono", "logoKafka", "logoKibana", "logoKubernetes", "logoLogging", "logoLogstash", "logoMaps", "logoMemcached", "logoMetrics", "logoMongodb", "logoMySQL", "logoNginx", "logoObservability", "logoOsquery", "logoPhp", "logoPostgres", "logoPrometheus", "logoRabbitmq", "logoRedis", "logoSecurity", "logoSiteSearch", "logoSketch", "logoSlack", "logoUptime", "logoWebhook", "logoWindows", "logoWorkplaceSearch", "logsApp", "logstashFilter", "logstashIf", "logstashInput", "logstashOutput", "logstashQueue", "machineLearningApp", "magnet", "magnifyWithExclamation", "magnifyWithMinus", "magnifyWithPlus", "managementApp", "mapMarker", "memory", "menu", "menuDown", "menuLeft", "menuRight", "menuUp", "merge", "metricbeatApp", "metricsApp", "minimize", "minus", "minusInCircle", "minusInCircleFilled", "mobile", "monitoringApp", "moon", "namespace", "nested", "node", "notebookApp", "number", "offline", "online", "outlierDetectionJob", "package", "packetbeatApp", "pageSelect", "pagesSelect", "paperClip", "partial", "pause", "payment", "pencil", "percent", "pin", "pinFilled", "pipelineApp", "play", "playFilled", "plus", "plusInCircle", "plusInCircleFilled", "popout", "push", "questionInCircle", "quote", "recentlyViewedApp", "refresh", "regressionJob", "reporter", "reportingApp", "returnKey", "save", "savedObjectsApp", "scale", "search", "searchProfilerApp", "securityAnalyticsApp", "securityApp", "securitySignal", "securitySignalDetected", "securitySignalResolved", "sessionViewer", "shard", "share", "snowflake", "sortDown", "sortLeft", "sortRight", "sortUp", "sortable", "spacesApp", "sqlApp", "starEmpty", "starEmptySpace", "starFilled", "starFilledSpace", "starMinusEmpty", "starMinusFilled", "starPlusEmpty", "starPlusFilled", "stats", "stop", "stopFilled", "stopSlash", "storage", "string", "submodule", "sun", "swatchInput", "symlink", "tableDensityCompact", "tableDensityExpanded", "tableDensityNormal", "tableOfContents", "tag", "tear", "temperature", "timeline", "timelionApp", "timeRefresh", "timeslider", "training", "trash", "unfold", "unlink", "upgradeAssistantApp", "uptimeApp", "user", "userAvatar", "users", "usersRolesApp", "vector", "videoPlayer", "visArea", "visAreaStacked", "visBarHorizontal", "visBarHorizontalStacked", "visBarVertical", "visBarVerticalStacked", "visGauge", "visGoal", "visLine", "visMapCoordinate", "visMapRegion", "visMetric", "visPie", "visTable", "visTagCloud", "visText", "visTimelion", "visVega", "visVisualBuilder", "visualizeApp", "watchesApp", "wordWrap", "wordWrapDisabled", "workplaceSearchApp", "wrench", "tokenAlias", "tokenAnnotation", "tokenArray", "tokenBinary", "tokenBoolean", "tokenClass", "tokenCompletionSuggester", "tokenConstant", "tokenDate", "tokenDenseVector", "tokenElement", "tokenEnum", "tokenEnumMember", "tokenEvent", "tokenException", "tokenField", "tokenFile", "tokenFlattened", "tokenFunction", "tokenGeo", "tokenHistogram", "tokenInterface", "tokenIP", "tokenJoin", "tokenKey", "tokenKeyword", "tokenMethod", "tokenMetricCounter", "tokenMetricGauge", "tokenModule", "tokenNamespace", "tokenNested", "tokenNull", "tokenNumber", "tokenObject", "tokenOperator", "tokenPackage", "tokenParameter", "tokenPercolator", "tokenProperty", "tokenRange", "tokenRankFeature", "tokenRankFeatures", "tokenRepo", "tokenSearchType", "tokenShape", "tokenString", "tokenStruct", "tokenSymbol", "tokenTag", "tokenText", "tokenTokenCount", "tokenVariable"]).isRequired, PropTypes.string.isRequired, PropTypes.elementType.isRequired]),
317
284
  onClose: PropTypes.func,
318
285
  className: PropTypes.string,
319
286
  "aria-label": PropTypes.string,
320
287
  "data-test-subj": PropTypes.string
321
- }).isRequired).isRequired,
288
+ }).isRequired),
322
289
  dismissToast: PropTypes.func.isRequired,
323
290
  toastLifeTimeMs: PropTypes.number.isRequired,
324
291
 
@@ -0,0 +1,38 @@
1
+ var _templateObject;
2
+
3
+ function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
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
+ };