@elastic/eui 123.2.0 → 123.3.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.
- package/dist/eui-icons.json +92 -91
- package/dist/svgs/add_to_chat.svg +3 -5
- package/dist/svgs/product_alert_zero.svg +5 -0
- package/es/components/avatar/avatar.js +1 -1
- package/es/components/badge/badge.js +1 -1
- package/es/components/badge/beta_badge/beta_badge.js +1 -1
- package/es/components/banner/banner.js +40 -3
- package/es/components/basic_table/basic_table.js +4 -4
- package/es/components/basic_table/in_memory_table.js +4 -4
- package/es/components/button/button_display/_button_display_content.js +1 -1
- package/es/components/button/button_empty/button_empty.js +1 -1
- package/es/components/button/button_icon/button_icon.js +1 -1
- package/es/components/call_out/call_out.js +40 -7
- package/es/components/card/card.js +1 -1
- package/es/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
- package/es/components/comment_list/comment.js +2 -2
- package/es/components/comment_list/comment_event.js +1 -1
- package/es/components/comment_list/comment_list.js +2 -2
- package/es/components/comment_list/comment_timeline.js +1 -1
- package/es/components/context_menu/context_menu_item.js +1 -1
- package/es/components/datagrid/body/cell/data_grid_cell.js +24 -24
- package/es/components/datagrid/body/data_grid_body.js +13 -13
- package/es/components/datagrid/body/data_grid_body_custom.js +13 -13
- package/es/components/datagrid/body/data_grid_body_virtualized.js +13 -13
- package/es/components/datagrid/body/header/data_grid_header_cell.js +12 -12
- package/es/components/datagrid/controls/column_sorting.js +13 -13
- package/es/components/datagrid/controls/column_sorting_draggable.js +1 -1
- package/es/components/datagrid/controls/data_grid_toolbar_control.js +1 -1
- package/es/components/datagrid/utils/in_memory.js +12 -12
- package/es/components/date_picker/date_picker.js +2 -2
- package/es/components/date_picker/date_picker_range.js +1 -1
- package/es/components/empty_prompt/empty_prompt.js +1 -1
- package/es/components/flyout/flyout_menu/flyout_menu.js +2 -2
- package/es/components/form/field_number/field_number.js +2 -2
- package/es/components/form/field_text/field_text.js +2 -2
- package/es/components/form/form_control_button/form_control_button.js +1 -1
- package/es/components/form/form_control_layout/append_prepend/form_append_prepend.js +2 -2
- package/es/components/form/form_control_layout/form_control_layout.js +2 -2
- package/es/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
- package/es/components/form/text_area/text_area.js +2 -2
- package/es/components/header/header_links/header_link.js +1 -1
- package/es/components/header/header_links/header_links.js +1 -1
- package/es/components/header/header_section/header_section_item_button.js +1 -1
- package/es/components/icon/assets/add_to_chat.js +2 -10
- package/es/components/icon/assets/product_alert_zero.js +33 -0
- package/es/components/icon/icon.js +1 -1
- package/es/components/icon/icon_map.js +5 -0
- package/es/components/icon/svgs/add_to_chat.svg +3 -5
- package/es/components/icon/svgs/product_alert_zero.svg +5 -0
- package/es/components/key_pad_menu/key_pad_menu_item.js +1 -1
- package/es/components/list_group/list_group.js +2 -2
- package/es/components/list_group/list_group_item.js +2 -2
- package/es/components/list_group/list_group_item_extra_action.js +1 -1
- package/es/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
- package/es/components/loading/loading_logo.js +1 -1
- package/es/components/markdown_editor/markdown_editor.js +1 -1
- package/es/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
- package/es/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/es/components/markdown_editor/markdown_editor_toolbar.js +1 -1
- package/es/components/page/page_header/page_header_content.js +1 -1
- package/es/components/pagination/pagination_button.js +1 -1
- package/es/components/selectable/selectable_list/selectable_list.js +1 -1
- package/es/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/es/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
- package/es/components/selectable/selectable_templates/selectable_template_sitewide.styles.js +5 -1
- package/es/components/table/table_header_cell.js +1 -1
- package/es/components/timeline/timeline_item_icon.js +1 -1
- package/es/components/toast/global_toast_list.js +2 -2
- package/es/components/toast/toast.js +2 -2
- package/es/components/token/token.styles.js +10 -4
- package/es/components/tool_tip/icon_tip.js +1 -1
- package/es/services/theme/provider.js +86 -101
- package/eui.d.ts +23 -11
- package/lib/components/avatar/avatar.js +1 -1
- package/lib/components/badge/badge.js +1 -1
- package/lib/components/badge/beta_badge/beta_badge.js +1 -1
- package/lib/components/banner/banner.js +39 -2
- package/lib/components/basic_table/basic_table.js +4 -4
- package/lib/components/basic_table/in_memory_table.js +4 -4
- package/lib/components/button/button_display/_button_display_content.js +1 -1
- package/lib/components/button/button_empty/button_empty.js +1 -1
- package/lib/components/button/button_icon/button_icon.js +1 -1
- package/lib/components/call_out/call_out.js +39 -6
- package/lib/components/card/card.js +1 -1
- package/lib/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
- package/lib/components/comment_list/comment.js +2 -2
- package/lib/components/comment_list/comment_event.js +1 -1
- package/lib/components/comment_list/comment_list.js +2 -2
- package/lib/components/comment_list/comment_timeline.js +1 -1
- package/lib/components/context_menu/context_menu_item.js +1 -1
- package/lib/components/datagrid/body/cell/data_grid_cell.js +24 -24
- package/lib/components/datagrid/body/data_grid_body.js +13 -13
- package/lib/components/datagrid/body/data_grid_body_custom.js +13 -13
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +13 -13
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +12 -12
- package/lib/components/datagrid/controls/column_sorting.js +13 -13
- package/lib/components/datagrid/controls/column_sorting_draggable.js +1 -1
- package/lib/components/datagrid/controls/data_grid_toolbar_control.js +1 -1
- package/lib/components/datagrid/utils/in_memory.js +12 -12
- package/lib/components/date_picker/date_picker.js +2 -2
- package/lib/components/date_picker/date_picker_range.js +1 -1
- package/lib/components/empty_prompt/empty_prompt.js +1 -1
- package/lib/components/flyout/flyout_menu/flyout_menu.js +2 -2
- package/lib/components/form/field_number/field_number.js +2 -2
- package/lib/components/form/field_text/field_text.js +2 -2
- package/lib/components/form/form_control_button/form_control_button.js +1 -1
- package/lib/components/form/form_control_layout/append_prepend/form_append_prepend.js +2 -2
- package/lib/components/form/form_control_layout/form_control_layout.js +2 -2
- package/lib/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
- package/lib/components/form/text_area/text_area.js +2 -2
- package/lib/components/header/header_links/header_link.js +1 -1
- package/lib/components/header/header_links/header_links.js +1 -1
- package/lib/components/header/header_section/header_section_item_button.js +1 -1
- package/lib/components/icon/assets/add_to_chat.js +2 -10
- package/lib/components/icon/assets/product_alert_zero.js +40 -0
- package/lib/components/icon/icon.js +1 -1
- package/lib/components/icon/icon_map.js +7 -0
- package/lib/components/icon/svgs/add_to_chat.svg +3 -5
- package/lib/components/icon/svgs/product_alert_zero.svg +5 -0
- package/lib/components/key_pad_menu/key_pad_menu_item.js +1 -1
- package/lib/components/list_group/list_group.js +2 -2
- package/lib/components/list_group/list_group_item.js +2 -2
- package/lib/components/list_group/list_group_item_extra_action.js +1 -1
- package/lib/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
- package/lib/components/loading/loading_logo.js +1 -1
- package/lib/components/markdown_editor/markdown_editor.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/lib/components/markdown_editor/markdown_editor_toolbar.js +1 -1
- package/lib/components/page/page_header/page_header_content.js +1 -1
- package/lib/components/pagination/pagination_button.js +1 -1
- package/lib/components/selectable/selectable_list/selectable_list.js +1 -1
- package/lib/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/lib/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
- package/lib/components/selectable/selectable_templates/selectable_template_sitewide.styles.js +5 -1
- package/lib/components/table/table_header_cell.js +1 -1
- package/lib/components/timeline/timeline_item_icon.js +1 -1
- package/lib/components/toast/global_toast_list.js +2 -2
- package/lib/components/toast/toast.js +2 -2
- package/lib/components/token/token.styles.js +10 -4
- package/lib/components/tool_tip/icon_tip.js +1 -1
- package/lib/services/theme/provider.js +85 -102
- package/optimize/es/components/banner/banner.js +35 -3
- package/optimize/es/components/call_out/call_out.js +33 -5
- package/optimize/es/components/icon/assets/add_to_chat.js +2 -10
- package/optimize/es/components/icon/assets/product_alert_zero.js +32 -0
- package/optimize/es/components/icon/icon_map.js +5 -0
- package/optimize/es/components/icon/svgs/add_to_chat.svg +3 -5
- package/optimize/es/components/icon/svgs/product_alert_zero.svg +5 -0
- package/optimize/es/components/selectable/selectable_templates/selectable_template_sitewide.styles.js +5 -1
- package/optimize/es/components/token/token.styles.js +10 -4
- package/optimize/es/services/theme/provider.js +82 -97
- package/optimize/lib/components/banner/banner.js +34 -2
- package/optimize/lib/components/call_out/call_out.js +32 -4
- package/optimize/lib/components/icon/assets/add_to_chat.js +2 -10
- package/optimize/lib/components/icon/assets/product_alert_zero.js +40 -0
- package/optimize/lib/components/icon/icon_map.js +7 -0
- package/optimize/lib/components/icon/svgs/add_to_chat.svg +3 -5
- package/optimize/lib/components/icon/svgs/product_alert_zero.svg +5 -0
- package/optimize/lib/components/selectable/selectable_templates/selectable_template_sitewide.styles.js +5 -1
- package/optimize/lib/components/token/token.styles.js +10 -4
- package/optimize/lib/services/theme/provider.js +80 -97
- package/package.json +6 -6
- package/test-env/components/avatar/avatar.js +1 -1
- package/test-env/components/badge/badge.js +1 -1
- package/test-env/components/badge/beta_badge/beta_badge.js +1 -1
- package/test-env/components/banner/banner.js +34 -2
- package/test-env/components/basic_table/basic_table.js +4 -4
- package/test-env/components/basic_table/in_memory_table.js +4 -4
- package/test-env/components/button/button_display/_button_display_content.js +1 -1
- package/test-env/components/button/button_empty/button_empty.js +1 -1
- package/test-env/components/button/button_icon/button_icon.js +1 -1
- package/test-env/components/call_out/call_out.js +34 -6
- package/test-env/components/card/card.js +1 -1
- package/test-env/components/collapsible_nav/collapsible_nav_group/collapsible_nav_group.js +1 -1
- package/test-env/components/comment_list/comment.js +2 -2
- package/test-env/components/comment_list/comment_event.js +1 -1
- package/test-env/components/comment_list/comment_list.js +2 -2
- package/test-env/components/comment_list/comment_timeline.js +1 -1
- package/test-env/components/context_menu/context_menu_item.js +1 -1
- package/test-env/components/datagrid/body/cell/data_grid_cell.js +24 -24
- package/test-env/components/datagrid/body/data_grid_body.js +13 -13
- package/test-env/components/datagrid/body/data_grid_body_custom.js +13 -13
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +13 -13
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +12 -12
- package/test-env/components/datagrid/controls/column_sorting.js +13 -13
- package/test-env/components/datagrid/controls/column_sorting_draggable.js +1 -1
- package/test-env/components/datagrid/controls/data_grid_toolbar_control.js +1 -1
- package/test-env/components/datagrid/utils/in_memory.js +12 -12
- package/test-env/components/date_picker/date_picker.js +2 -2
- package/test-env/components/date_picker/date_picker_range.js +1 -1
- package/test-env/components/empty_prompt/empty_prompt.js +1 -1
- package/test-env/components/flyout/flyout_menu/flyout_menu.js +2 -2
- package/test-env/components/form/field_number/field_number.js +2 -2
- package/test-env/components/form/field_text/field_text.js +2 -2
- package/test-env/components/form/form_control_button/form_control_button.js +1 -1
- package/test-env/components/form/form_control_layout/append_prepend/form_append_prepend.js +2 -2
- package/test-env/components/form/form_control_layout/form_control_layout.js +2 -2
- package/test-env/components/form/form_control_layout/form_control_layout_custom_icon.js +1 -1
- package/test-env/components/form/text_area/text_area.js +2 -2
- package/test-env/components/header/header_links/header_link.js +1 -1
- package/test-env/components/header/header_links/header_links.js +1 -1
- package/test-env/components/header/header_section/header_section_item_button.js +1 -1
- package/test-env/components/icon/assets/add_to_chat.js +2 -10
- package/test-env/components/icon/assets/product_alert_zero.js +40 -0
- package/test-env/components/icon/icon_map.js +7 -0
- package/test-env/components/key_pad_menu/key_pad_menu_item.js +1 -1
- package/test-env/components/list_group/list_group.js +2 -2
- package/test-env/components/list_group/list_group_item.js +2 -2
- package/test-env/components/list_group/list_group_item_extra_action.js +1 -1
- package/test-env/components/list_group/pinnable_list_group/pinnable_list_group.js +4 -4
- package/test-env/components/loading/loading_logo.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_drop_zone.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_footer.js +1 -1
- package/test-env/components/markdown_editor/markdown_editor_toolbar.js +1 -1
- package/test-env/components/page/page_header/page_header_content.js +1 -1
- package/test-env/components/pagination/pagination_button.js +1 -1
- package/test-env/components/selectable/selectable_list/selectable_list.js +1 -1
- package/test-env/components/selectable/selectable_list/selectable_list_item.js +1 -1
- package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.js +1 -1
- package/test-env/components/selectable/selectable_templates/selectable_template_sitewide.styles.js +5 -1
- package/test-env/components/table/table_header_cell.js +1 -1
- package/test-env/components/timeline/timeline_item_icon.js +1 -1
- package/test-env/components/toast/global_toast_list.js +2 -2
- package/test-env/components/toast/toast.js +2 -2
- package/test-env/components/token/token.styles.js +10 -4
- package/test-env/components/tool_tip/icon_tip.js +1 -1
- package/test-env/services/theme/provider.js +80 -97
|
@@ -6,17 +6,17 @@ function _extends() { return _extends = Object.assign ? Object.assign.bind() : f
|
|
|
6
6
|
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
7
7
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
|
|
8
8
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
9
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
9
|
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
15
10
|
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."); }
|
|
16
11
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
17
12
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
18
13
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
19
14
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
15
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
18
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
19
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
20
|
/*
|
|
21
21
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
22
22
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -37,7 +37,25 @@ import { EuiThemeMemoizedStylesProvider } from './style_memoization';
|
|
|
37
37
|
import { useHighContrastModifications } from './high_contrast_overrides';
|
|
38
38
|
import { buildTheme, getColorMode, getComputed, mergeDeep } from './utils';
|
|
39
39
|
import { EUI_VIS_COLOR_STORE } from '../color';
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Caches `value` during render, only swapping in a new one once `isSame`
|
|
43
|
+
* reports that it actually differs from the cached one.
|
|
44
|
+
*
|
|
45
|
+
* This keeps derived objects referentially stable (so that the - comparatively
|
|
46
|
+
* expensive - theme computation isn't rerun on every render) without deferring
|
|
47
|
+
* them to a `useEffect`/`setState` pair. Effect-synchronised state costs an
|
|
48
|
+
* extra commit, in which consumers would see e.g. an updated `colorMode`
|
|
49
|
+
* alongside a theme that is still computed from the previous one.
|
|
50
|
+
*/
|
|
40
51
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
52
|
+
var useStableValue = function useStableValue(value, isSame) {
|
|
53
|
+
var ref = useRef(value);
|
|
54
|
+
if (ref.current !== value && !isSame(ref.current, value)) {
|
|
55
|
+
ref.current = value;
|
|
56
|
+
}
|
|
57
|
+
return ref.current;
|
|
58
|
+
};
|
|
41
59
|
export var EuiThemeProvider = function EuiThemeProvider(_ref) {
|
|
42
60
|
var _system = _ref.theme,
|
|
43
61
|
_colorMode = _ref.colorMode,
|
|
@@ -66,118 +84,85 @@ export var EuiThemeProvider = function EuiThemeProvider(_ref) {
|
|
|
66
84
|
var EuiConditionalBreakpointProvider = useMemo(function () {
|
|
67
85
|
return isGlobalTheme || _modifications !== null && _modifications !== void 0 && _modifications.breakpoint ? CurrentEuiBreakpointProvider : Fragment;
|
|
68
86
|
}, [isGlobalTheme, _modifications]);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
var
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
var prevColorMode = useRef(colorMode);
|
|
87
|
+
|
|
88
|
+
// Every value below is derived from props/parent context during render, so
|
|
89
|
+
// that all context values this provider exposes - most notably `colorMode`
|
|
90
|
+
// and the computed `theme` - always change within the same commit
|
|
91
|
+
var system = useStableValue(_system || parentSystem, function (previous, next) {
|
|
92
|
+
return previous.key === next.key;
|
|
93
|
+
});
|
|
94
|
+
var mergedModifications = useMemo(function () {
|
|
95
|
+
return mergeDeep(parentModifications, _modifications);
|
|
96
|
+
}, [parentModifications, _modifications]);
|
|
97
|
+
var modifications = useStableValue(mergedModifications, isEqual);
|
|
98
|
+
var colorMode = useMemo(function () {
|
|
99
|
+
return getColorMode(_colorMode, parentColorMode, isForced);
|
|
100
|
+
}, [_colorMode, parentColorMode, isForced]);
|
|
84
101
|
var highContrastMode = useMemo(function () {
|
|
85
102
|
if (isForced) return 'forced'; // System forced high contrast mode will always supercede application settings
|
|
86
103
|
if (_highContrastMode === true) return 'preferred'; // Convert the boolean prop to our internal enum
|
|
87
104
|
if (_highContrastMode === false) return false; // Allow `false` prop to override user/system preference
|
|
88
105
|
return parentHighContrastMode; // Fall back to the parent/system setting
|
|
89
106
|
}, [_highContrastMode, parentHighContrastMode, isForced]);
|
|
90
|
-
var prevHighContrastMode = useRef(highContrastMode);
|
|
91
107
|
var modificationsWithHighContrast = useHighContrastModifications({
|
|
92
108
|
highContrastMode: highContrastMode,
|
|
93
109
|
colorMode: colorMode,
|
|
94
110
|
system: system,
|
|
95
111
|
modifications: modifications
|
|
96
112
|
});
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
|
|
114
|
+
// If this provider resolves to the exact same theme as its parent, the
|
|
115
|
+
// already computed parent theme can be reused instead of recomputing it
|
|
116
|
+
var isParentTheme = useMemo(function () {
|
|
117
|
+
return isGlobalTheme ? system.key === DEFAULTS.system.key && colorMode === DEFAULTS.colorMode && highContrastMode === DEFAULTS.highContrastMode && !_modifications : system.key === parentSystem.key && colorMode === parentColorMode && highContrastMode === parentHighContrastMode && isEqual(parentModifications, modifications);
|
|
118
|
+
}, [isGlobalTheme, system, colorMode, highContrastMode, _modifications, parentSystem, parentColorMode, parentHighContrastMode, parentModifications, modifications]);
|
|
119
|
+
|
|
120
|
+
// Depending on `parentTheme` itself would recompute this provider's theme every
|
|
121
|
+
// time the parent's did, even where the parent's theme is not an input to it -
|
|
122
|
+
// `parentModifications` already reaches `getComputed` through `modifications`
|
|
123
|
+
var reusableParentTheme = isParentTheme && Object.keys(parentTheme).length ? parentTheme : null;
|
|
124
|
+
var theme = useMemo(function () {
|
|
125
|
+
if (reusableParentTheme) {
|
|
126
|
+
return _objectSpread({}, reusableParentTheme); // Intentionally create a new object to break referential equality
|
|
101
127
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
128
|
+
|
|
129
|
+
/* Enables recomputation of component colors when flags are overridden on the provider
|
|
130
|
+
by adding the respective key to modifications to trigger a recomputation. */
|
|
131
|
+
// NOTE: Keeping this as placeholder for potential future usage during Borealis changes
|
|
132
|
+
// TODO: remove once visual refresh is completed and flags are obsolete
|
|
133
|
+
var flagsToRecompute = [];
|
|
134
|
+
var keys = {};
|
|
135
|
+
var forceRecomputeComponents = flagsToRecompute.some(function (item) {
|
|
136
|
+
var _modifications$flags, _modifications$compon;
|
|
137
|
+
if (!item) return false;
|
|
138
|
+
if (Object.keys((_modifications$flags = modifications.flags) !== null && _modifications$flags !== void 0 ? _modifications$flags : {}).includes(item.flag) && !Object.keys((_modifications$compon = modifications.components) !== null && _modifications$compon !== void 0 ? _modifications$compon : {}).includes(item.componentKey)) {
|
|
139
|
+
keys[item.componentKey] = {
|
|
140
|
+
LIGHT: {},
|
|
141
|
+
DARK: {}
|
|
142
|
+
};
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
return false;
|
|
107
146
|
});
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
: getInitialTheme()),
|
|
112
|
-
_useState8 = _slicedToArray(_useState7, 2),
|
|
113
|
-
theme = _useState8[0],
|
|
114
|
-
setTheme = _useState8[1];
|
|
115
|
-
useEffect(function () {
|
|
116
|
-
var newSystem = _system || parentSystem;
|
|
117
|
-
if (prevSystemKey.current !== newSystem.key) {
|
|
118
|
-
setSystem(newSystem);
|
|
119
|
-
prevSystemKey.current = newSystem.key;
|
|
120
|
-
isParentTheme.current = false;
|
|
121
|
-
}
|
|
122
|
-
}, [_system, parentSystem, theme, updateVisColorStore]);
|
|
123
|
-
useEffect(function () {
|
|
124
|
-
updateVisColorStore(theme, isGlobalTheme);
|
|
125
|
-
}, [theme, colorMode, isGlobalTheme, updateVisColorStore]);
|
|
126
|
-
useEffect(function () {
|
|
127
|
-
var newModifications = mergeDeep(parentModifications, _modifications);
|
|
128
|
-
if (!isEqual(prevModifications.current, newModifications)) {
|
|
129
|
-
setModifications(newModifications);
|
|
130
|
-
prevModifications.current = newModifications;
|
|
131
|
-
isParentTheme.current = false;
|
|
132
|
-
}
|
|
133
|
-
}, [_modifications, parentModifications]);
|
|
134
|
-
useEffect(function () {
|
|
135
|
-
var newColorMode = getColorMode(_colorMode, parentColorMode, isForced);
|
|
136
|
-
if (!isEqual(newColorMode, prevColorMode.current)) {
|
|
137
|
-
setColorMode(newColorMode);
|
|
138
|
-
prevColorMode.current = newColorMode;
|
|
139
|
-
isParentTheme.current = false;
|
|
140
|
-
}
|
|
141
|
-
}, [_colorMode, parentColorMode, isForced]);
|
|
142
|
-
useEffect(function () {
|
|
143
|
-
if (prevHighContrastMode.current !== highContrastMode) {
|
|
144
|
-
isParentTheme.current = false;
|
|
145
|
-
}
|
|
146
|
-
}, [highContrastMode]);
|
|
147
|
-
useEffect(function () {
|
|
148
|
-
if (!isParentTheme.current) {
|
|
149
|
-
/* Enables recomputation of component colors when flags are overridden on the provider
|
|
150
|
-
by adding the respective key to modifications to trigger a recomputation. */
|
|
151
|
-
// NOTE: Keeping this as placeholder for potential future usage during Borealis changes
|
|
152
|
-
// TODO: remove once visual refresh is completed and flags are obsolete
|
|
153
|
-
var flagsToRecompute = [];
|
|
154
|
-
var keys = {};
|
|
155
|
-
var forceRecomputeComponents = flagsToRecompute.some(function (item) {
|
|
156
|
-
var _modifications$flags, _modifications$compon;
|
|
157
|
-
if (!item) return false;
|
|
158
|
-
if (Object.keys((_modifications$flags = modifications.flags) !== null && _modifications$flags !== void 0 ? _modifications$flags : {}).includes(item.flag) && !Object.keys((_modifications$compon = modifications.components) !== null && _modifications$compon !== void 0 ? _modifications$compon : {}).includes(item.componentKey)) {
|
|
159
|
-
keys[item.componentKey] = {
|
|
160
|
-
LIGHT: {},
|
|
161
|
-
DARK: {}
|
|
162
|
-
};
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
return false;
|
|
166
|
-
});
|
|
167
|
-
var componentModifications = forceRecomputeComponents ? {
|
|
168
|
-
components: keys
|
|
169
|
-
} : {};
|
|
147
|
+
var componentModifications = forceRecomputeComponents ? {
|
|
148
|
+
components: keys
|
|
149
|
+
} : {};
|
|
170
150
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
151
|
+
// force recomputing of color & component tokens based on flag changes
|
|
152
|
+
var enhancedModifications = _objectSpread(_objectSpread({}, modificationsWithHighContrast), componentModifications);
|
|
153
|
+
return getComputed(system, buildTheme(enhancedModifications, "_".concat(system.key)), colorMode, highContrastMode);
|
|
154
|
+
}, [reusableParentTheme, system, colorMode, highContrastMode, modifications, modificationsWithHighContrast]);
|
|
155
|
+
|
|
156
|
+
// Genuine side effect - the vis color store is consumed outside of React
|
|
157
|
+
useEffect(function () {
|
|
158
|
+
if (isGlobalTheme) {
|
|
159
|
+
EUI_VIS_COLOR_STORE.setVisColors(theme.colors.vis);
|
|
175
160
|
}
|
|
176
|
-
}, [
|
|
177
|
-
var
|
|
178
|
-
|
|
179
|
-
themeCSSVariables =
|
|
180
|
-
_setThemeCSSVariables =
|
|
161
|
+
}, [theme, isGlobalTheme]);
|
|
162
|
+
var _useState = useState(),
|
|
163
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
164
|
+
themeCSSVariables = _useState2[0],
|
|
165
|
+
_setThemeCSSVariables = _useState2[1];
|
|
181
166
|
var setThemeCSSVariables = useCallback(function (variables) {
|
|
182
167
|
return _setThemeCSSVariables(function (previous) {
|
|
183
168
|
var merged = _objectSpread(_objectSpread({}, previous), variables);
|