@elastic/eui 106.4.0 → 106.6.0-backport.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 (68) hide show
  1. package/es/components/avatar/avatar.js +2 -0
  2. package/es/components/badge/badge.js +5 -7
  3. package/es/components/badge/badge.styles.js +10 -4
  4. package/es/components/basic_table/basic_table.js +6 -0
  5. package/es/components/basic_table/in_memory_table.js +6 -0
  6. package/es/components/color_picker/color_picker_swatch.js +4 -0
  7. package/es/components/datagrid/controls/column_selector.js +32 -3
  8. package/es/components/datagrid/data_grid.styles.js +1 -1
  9. package/es/components/date_picker/super_date_picker/quick_select_popover/quick_select.js +4 -4
  10. package/es/components/date_picker/super_date_picker/super_date_picker.styles.js +1 -1
  11. package/es/components/modal/modal.js +16 -5
  12. package/es/components/table/table_header_cell.js +4 -0
  13. package/es/components/tool_tip/icon_tip.js +4 -0
  14. package/es/components/tool_tip/tool_tip.js +8 -2
  15. package/es/services/color/contrast.js +11 -0
  16. package/eui.d.ts +129 -121
  17. package/i18ntokens.json +2305 -2287
  18. package/lib/components/avatar/avatar.js +2 -0
  19. package/lib/components/badge/badge.js +3 -5
  20. package/lib/components/badge/badge.styles.js +10 -4
  21. package/lib/components/basic_table/basic_table.js +6 -0
  22. package/lib/components/basic_table/in_memory_table.js +6 -0
  23. package/lib/components/color_picker/color_picker_swatch.js +4 -0
  24. package/lib/components/datagrid/controls/column_selector.js +32 -3
  25. package/lib/components/datagrid/data_grid.styles.js +1 -1
  26. package/lib/components/date_picker/super_date_picker/quick_select_popover/quick_select.js +4 -4
  27. package/lib/components/date_picker/super_date_picker/super_date_picker.styles.js +1 -1
  28. package/lib/components/modal/modal.js +15 -4
  29. package/lib/components/table/table_header_cell.js +4 -0
  30. package/lib/components/tool_tip/icon_tip.js +4 -0
  31. package/lib/components/tool_tip/tool_tip.js +9 -3
  32. package/lib/services/color/contrast.js +12 -1
  33. package/optimize/es/components/avatar/avatar.js +2 -0
  34. package/optimize/es/components/badge/badge.js +5 -7
  35. package/optimize/es/components/badge/badge.styles.js +10 -4
  36. package/optimize/es/components/datagrid/controls/column_selector.js +34 -3
  37. package/optimize/es/components/datagrid/data_grid.styles.js +1 -1
  38. package/optimize/es/components/date_picker/super_date_picker/quick_select_popover/quick_select.js +4 -4
  39. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.styles.js +1 -1
  40. package/optimize/es/components/modal/modal.js +16 -5
  41. package/optimize/es/components/tool_tip/tool_tip.js +4 -2
  42. package/optimize/es/services/color/contrast.js +11 -0
  43. package/optimize/lib/components/avatar/avatar.js +2 -0
  44. package/optimize/lib/components/badge/badge.js +3 -5
  45. package/optimize/lib/components/badge/badge.styles.js +10 -4
  46. package/optimize/lib/components/datagrid/controls/column_selector.js +34 -5
  47. package/optimize/lib/components/datagrid/data_grid.styles.js +1 -1
  48. package/optimize/lib/components/date_picker/super_date_picker/quick_select_popover/quick_select.js +4 -4
  49. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.styles.js +1 -1
  50. package/optimize/lib/components/modal/modal.js +15 -4
  51. package/optimize/lib/components/tool_tip/tool_tip.js +5 -3
  52. package/optimize/lib/services/color/contrast.js +12 -1
  53. package/package.json +3 -3
  54. package/test-env/components/avatar/avatar.js +2 -0
  55. package/test-env/components/badge/badge.js +3 -5
  56. package/test-env/components/badge/badge.styles.js +10 -4
  57. package/test-env/components/basic_table/basic_table.js +6 -0
  58. package/test-env/components/basic_table/in_memory_table.js +6 -0
  59. package/test-env/components/color_picker/color_picker_swatch.js +4 -0
  60. package/test-env/components/datagrid/controls/column_selector.js +34 -5
  61. package/test-env/components/datagrid/data_grid.styles.js +1 -1
  62. package/test-env/components/date_picker/super_date_picker/quick_select_popover/quick_select.js +4 -4
  63. package/test-env/components/date_picker/super_date_picker/super_date_picker.styles.js +1 -1
  64. package/test-env/components/modal/modal.js +15 -4
  65. package/test-env/components/table/table_header_cell.js +4 -0
  66. package/test-env/components/tool_tip/icon_tip.js +4 -0
  67. package/test-env/components/tool_tip/tool_tip.js +9 -3
  68. package/test-env/services/color/contrast.js +12 -1
@@ -26,28 +26,57 @@ var _column_selector = require("./column_selector.styles");
26
26
  var _react2 = require("@emotion/react");
27
27
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
28
28
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
29
- /*
29
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
30
+ 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; } }
31
+ 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; } /*
30
32
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
31
33
  * or more contributor license agreements. Licensed under the Elastic License
32
34
  * 2.0 and the Server Side Public License, v 1; you may not use this file except
33
35
  * in compliance with, at your election, the Elastic License 2.0 or the Server
34
36
  * Side Public License, v 1.
35
37
  */
36
-
37
38
  var useDataGridColumnSelector = exports.useDataGridColumnSelector = function useDataGridColumnSelector(availableColumns, columnVisibility, showColumnSelector, displayValues) {
38
39
  var allowColumnHiding = (0, _data_grid_toolbar.getNestedObjectOptions)(showColumnSelector, 'allowHide');
39
40
  var allowColumnReorder = (0, _data_grid_toolbar.getNestedObjectOptions)(showColumnSelector, 'allowReorder');
41
+ var visibleColumns = columnVisibility.visibleColumns,
42
+ setVisibleColumns = columnVisibility.setVisibleColumns;
40
43
  var _useDependentState = (0, _services.useDependentState)(function () {
41
- return availableColumns.map(function (_ref) {
44
+ var availableColumnIds = availableColumns.map(function (_ref) {
42
45
  var id = _ref.id;
43
46
  return id;
44
47
  });
48
+ var availableSet = new Set(availableColumnIds);
49
+ // Filter visibleColumns to only include existing columns
50
+ var validVisibleColumns = visibleColumns.filter(function (id) {
51
+ return availableSet.has(id);
52
+ });
53
+ var visibleSet = new Set(validVisibleColumns);
54
+ var result = [];
55
+ var visibleIndex = 0;
56
+ var _iterator = _createForOfIteratorHelper(availableColumnIds),
57
+ _step;
58
+ try {
59
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
60
+ var columnId = _step.value;
61
+ if (visibleSet.has(columnId)) {
62
+ // Replace with next visible column in order
63
+ result.push(validVisibleColumns[visibleIndex++]);
64
+ } else {
65
+ // Keep hidden column in original position
66
+ result.push(columnId);
67
+ }
68
+ }
69
+ } catch (err) {
70
+ _iterator.e(err);
71
+ } finally {
72
+ _iterator.f();
73
+ }
74
+ return result;
75
+ // doesn't depend on visibleColumns on purpose to keep it an initial state
45
76
  }, [availableColumns]),
46
77
  _useDependentState2 = (0, _slicedToArray2.default)(_useDependentState, 2),
47
78
  sortedColumns = _useDependentState2[0],
48
79
  setSortedColumns = _useDependentState2[1];
49
- var visibleColumns = columnVisibility.visibleColumns,
50
- setVisibleColumns = columnVisibility.setVisibleColumns;
51
80
  var visibleColumnIds = (0, _react.useMemo)(function () {
52
81
  return new Set(visibleColumns);
53
82
  }, [visibleColumns]);
@@ -58,7 +58,7 @@ var euiDataGridStyles = exports.euiDataGridStyles = function euiDataGridStyles(e
58
58
  };
59
59
  var border = "".concat(euiTheme.border.width.thin, " solid ").concat(borderColors.default);
60
60
  return {
61
- euiDataGrid: /*#__PURE__*/(0, _react.css)("display:flex;flex-direction:column;align-items:stretch;", (0, _global_styling.logicalCSS)('height', '100%'), " overflow:hidden;*:where(& .euiDataGridRow){background-color:", euiTheme.components.dataGridRowBackground, ";}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover){background-color:", euiTheme.components.dataGridRowBackgroundHover, ";}*:where(&:not(.euiDataGrid--stripes) .euiDataGridRow--selected){background-color:", euiTheme.components.dataGridRowBackgroundSelect, ";}*:where(& .euiDataGridRow--marked){background-color:", euiTheme.components.dataGridRowBackgroundMarked, ";.euiDataGridRowCell.euiDataGridRowCell{", outlineSelectors.marked, "{", (0, _data_grid_cell.euiDataGridCellOutlineStyles)(euiThemeContext).markedStyles, ";}}}*:where(&:not(.euiDataGrid--stripes) .euiDataGridRow--marked){&:hover{background-color:", euiTheme.components.dataGridRowBackgroundMarkedHover, ";}}*:where(\n &.euiDataGrid--rowHoverHighlight .euiDataGridRow--selected:hover\n ){background-color:", euiTheme.components.dataGridRowBackgroundSelectHover, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow){background-color:", euiTheme.components.dataGridRowStripesBackground, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--striped){background-color:", euiTheme.components.dataGridRowStripesBackgroundStriped, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundHover, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow--striped:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundStripedHover, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--selected){background-color:", euiTheme.components.dataGridRowStripesBackgroundSelect, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--marked){background-color:", euiTheme.components.dataGridRowBackgroundMarked, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow--selected:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundSelectHover, ";}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow)::before{content:'';position:absolute;z-index:-1;pointer-events:none;inset:0;background-color:", euiTheme.components.dataGridRowBackground, ";};label:euiDataGrid;"),
61
+ euiDataGrid: /*#__PURE__*/(0, _react.css)("display:flex;flex-direction:column;align-items:stretch;", (0, _global_styling.logicalCSS)('height', '100%'), " overflow:hidden;*:where(& .euiDataGridRow){background-color:", euiTheme.components.dataGridRowBackground, ";}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow:hover){background-color:", euiTheme.components.dataGridRowBackgroundHover, ";}*:where(& .euiDataGridRow--selected){background-color:", euiTheme.components.dataGridRowBackgroundSelect, ";}*:where(& .euiDataGridRow--marked){background-color:", euiTheme.components.dataGridRowBackgroundMarked, ";.euiDataGridRowCell.euiDataGridRowCell{", outlineSelectors.marked, "{", (0, _data_grid_cell.euiDataGridCellOutlineStyles)(euiThemeContext).markedStyles, ";}}}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow--marked){&:hover{background-color:", euiTheme.components.dataGridRowBackgroundMarkedHover, ";}}*:where(\n &.euiDataGrid--rowHoverHighlight .euiDataGridRow--selected:hover\n ){background-color:", euiTheme.components.dataGridRowBackgroundSelectHover, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow){background-color:", euiTheme.components.dataGridRowStripesBackground, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--striped){background-color:", euiTheme.components.dataGridRowStripesBackgroundStriped, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundHover, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow--striped:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundStripedHover, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--selected){background-color:", euiTheme.components.dataGridRowStripesBackgroundSelect, ";}*:where(&.euiDataGrid--stripes .euiDataGridRow--marked){background-color:", euiTheme.components.dataGridRowBackgroundMarked, ";}*:where(\n &.euiDataGrid--stripes.euiDataGrid--rowHoverHighlight\n .euiDataGridRow--selected:hover\n ){background-color:", euiTheme.components.dataGridRowStripesBackgroundSelectHover, ";}*:where(&.euiDataGrid--rowHoverHighlight .euiDataGridRow)::before{content:'';position:absolute;z-index:-1;pointer-events:none;inset:0;background-color:", euiTheme.components.dataGridRowBackground, ";};label:euiDataGrid;"),
62
62
  cellPadding: {
63
63
  cellPadding: function cellPadding(size) {
64
64
  return /*#__PURE__*/(0, _react.css)(".euiDataGridHeaderCell,.euiDataGridRowCell__content{padding:", _cellPadding[size], ";}.euiDataGridRowCell__content--lineCountHeight,.euiDataGridRowCell__content--autoBelowLineCountHeight{", (0, _high_contrast.highContrastModeStyles)(euiThemeContext, {
@@ -121,8 +121,8 @@ var EuiQuickSelect = exports.EuiQuickSelect = /*#__PURE__*/function (_Component)
121
121
  max = _this$getBounds.max;
122
122
  var diff = max.diff(min);
123
123
  _this.props.applyTime({
124
- start: (0, _moment.default)(max).add(1, 'ms').toISOString(),
125
- end: (0, _moment.default)(max).add(diff + 1, 'ms').toISOString(),
124
+ start: (0, _moment.default)(max).toISOString(),
125
+ end: (0, _moment.default)(max).add(diff, 'ms').toISOString(),
126
126
  keepPopoverOpen: true
127
127
  });
128
128
  });
@@ -132,8 +132,8 @@ var EuiQuickSelect = exports.EuiQuickSelect = /*#__PURE__*/function (_Component)
132
132
  max = _this$getBounds2.max;
133
133
  var diff = max.diff(min);
134
134
  _this.props.applyTime({
135
- start: (0, _moment.default)(min).subtract(diff + 1, 'ms').toISOString(),
136
- end: (0, _moment.default)(min).subtract(1, 'ms').toISOString(),
135
+ start: (0, _moment.default)(min).subtract(diff, 'ms').toISOString(),
136
+ end: (0, _moment.default)(min).toISOString(),
137
137
  keepPopoverOpen: true
138
138
  });
139
139
  });
@@ -79,7 +79,7 @@ var euiSuperDatePickerStyles = exports.euiSuperDatePickerStyles = function euiSu
79
79
  full: "\n label: isAutoRefreshOnly;\n display: block;\n "
80
80
  },
81
81
  // isQuickSelectOnly forces `width` to be `auto`
82
- isQuickSelectOnly: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('min-width', 0), ".euiFormControlLayout__prepend{", (0, _global_styling.logicalCSS)('max-width', 'none'), ";};label:isQuickSelectOnly;"),
82
+ isQuickSelectOnly: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('min-width', 0), ".euiFormControlLayout__prepend{", (0, _global_styling.logicalCSS)('max-width', 'none'), ";}.euiFormControlLayoutDelimited__delimiter:first-child{", (0, _global_styling.logicalCSS)('padding-horizontal', 0), ";};label:isQuickSelectOnly;"),
83
83
  euiSuperDatePicker__range: _ref,
84
84
  euiSuperDatePicker__rangeInput: /*#__PURE__*/(0, _react.css)("flex-grow:1;", (0, _global_styling.logicalCSS)('width', 'auto'), " overflow:hidden;;label:euiSuperDatePicker__rangeInput;"),
85
85
  euiSuperDatePicker__prettyFormat: /*#__PURE__*/(0, _react.css)(_buttonStyles(euiThemeContext), " text-align:start;", isRefreshVariant && prettyFormatStyles, ";;label:euiSuperDatePicker__prettyFormat;"),
@@ -18,8 +18,9 @@ var _focus_trap = require("../focus_trap");
18
18
  var _overlay_mask = require("../overlay_mask");
19
19
  var _i18n = require("../i18n");
20
20
  var _modal = require("./modal.styles");
21
+ var _accessibility = require("../accessibility");
21
22
  var _react2 = require("@emotion/react");
22
- var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style", "focusTrapProps"];
23
+ var _excluded = ["className", "children", "initialFocus", "onClose", "maxWidth", "role", "style", "focusTrapProps", "aria-describedby"];
23
24
  /*
24
25
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
25
26
  * or more contributor license agreements. Licensed under the Elastic License
@@ -40,6 +41,7 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
40
41
  role = _ref$role === void 0 ? 'dialog' : _ref$role,
41
42
  style = _ref.style,
42
43
  focusTrapProps = _ref.focusTrapProps,
44
+ _ariaDescribedBy = _ref['aria-describedby'],
43
45
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
44
46
  var onKeyDown = function onKeyDown(event) {
45
47
  if (event.key === _services.keys.ESCAPE) {
@@ -61,6 +63,14 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
61
63
  var styles = (0, _modal.euiModalStyles)(euiTheme);
62
64
  var cssStyles = [styles.euiModal, maxWidth === true && styles.defaultMaxWidth];
63
65
  var cssCloseIconStyles = [styles.euiModal__closeIcon];
66
+ var descriptionId = (0, _services.useGeneratedHtmlId)();
67
+ var ariaDescribedBy = (0, _classnames.default)(descriptionId, _ariaDescribedBy);
68
+ var screenReaderDescription = (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", {
69
+ id: descriptionId
70
+ }, (0, _react2.jsx)(_i18n.EuiI18n, {
71
+ token: "euiModal.screenReaderModalDialog",
72
+ default: "You are in a modal dialog. Press Escape or tap/click outside the dialog on the shadowed overlay to close."
73
+ })));
64
74
  return (0, _react2.jsx)(_overlay_mask.EuiOverlayMask, null, (0, _react2.jsx)(_focus_trap.EuiFocusTrap, (0, _extends2.default)({}, focusTrapProps, {
65
75
  initialFocus: initialFocus,
66
76
  scrollLock: true,
@@ -72,8 +82,9 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
72
82
  tabIndex: 0,
73
83
  style: newStyle,
74
84
  role: role,
75
- "aria-modal": true
76
- }, rest), (0, _react2.jsx)(_i18n.EuiI18n, {
85
+ "aria-modal": true,
86
+ "aria-describedby": ariaDescribedBy
87
+ }, rest), children, screenReaderDescription, (0, _react2.jsx)(_i18n.EuiI18n, {
77
88
  token: "euiModal.closeModal",
78
89
  default: "Closes this modal window"
79
90
  }, function (closeModal) {
@@ -85,7 +96,7 @@ var EuiModal = exports.EuiModal = function EuiModal(_ref) {
85
96
  color: "text",
86
97
  "aria-label": closeModal
87
98
  });
88
- }), children)));
99
+ }))));
89
100
  };
90
101
  EuiModal.propTypes = {
91
102
  className: _propTypes.default.string,
@@ -226,6 +226,10 @@ EuiTableHeaderCell.propTypes = {
226
226
  * hidden.
227
227
  */
228
228
  onMouseOut: _propTypes.default.func,
229
+ /**
230
+ * Offset in pixels from the anchor. Defaults to 16.
231
+ */
232
+ offset: _propTypes.default.number,
229
233
  "aria-label": _propTypes.default.string,
230
234
  "data-test-subj": _propTypes.default.string,
231
235
  css: _propTypes.default.any,
@@ -100,6 +100,10 @@ EuiIconTip.propTypes = {
100
100
  * hidden.
101
101
  */
102
102
  onMouseOut: _propTypes.default.func,
103
+ /**
104
+ * Offset in pixels from the anchor. Defaults to 16.
105
+ */
106
+ offset: _propTypes.default.number,
103
107
  /**
104
108
  * Explain what this icon means for screen readers.
105
109
  */
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.POSITIONS = exports.EuiToolTip = void 0;
8
+ exports.POSITIONS = exports.EuiToolTip = exports.DEFAULT_TOOLTIP_OFFSET = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -39,6 +39,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
39
39
  */
40
40
  var POSITIONS = exports.POSITIONS = ['top', 'right', 'bottom', 'left'];
41
41
  var DISPLAYS = ['inlineBlock', 'block'];
42
+ var DEFAULT_TOOLTIP_OFFSET = exports.DEFAULT_TOOLTIP_OFFSET = 16;
42
43
  var delayToMsMap = {
43
44
  regular: 250,
44
45
  long: 250 * 5
@@ -113,7 +114,9 @@ var EuiToolTip = exports.EuiToolTip = /*#__PURE__*/function (_Component) {
113
114
  }
114
115
  });
115
116
  (0, _defineProperty2.default)(_this, "positionToolTip", function () {
117
+ var _this$props$offset;
116
118
  var requestedPosition = _this.props.position;
119
+ var offset = (_this$props$offset = _this.props.offset) !== null && _this$props$offset !== void 0 ? _this$props$offset : DEFAULT_TOOLTIP_OFFSET;
117
120
  if (!_this.anchor || !_this.popover) {
118
121
  return;
119
122
  }
@@ -121,8 +124,7 @@ var EuiToolTip = exports.EuiToolTip = /*#__PURE__*/function (_Component) {
121
124
  anchor: _this.anchor,
122
125
  popover: _this.popover,
123
126
  position: requestedPosition,
124
- offset: 16,
125
- // offset popover 16px from the anchor
127
+ offset: offset,
126
128
  arrowConfig: {
127
129
  arrowWidth: 12,
128
130
  arrowBuffer: 4
@@ -369,6 +371,10 @@ EuiToolTip.propTypes = {
369
371
  * hidden.
370
372
  */
371
373
  onMouseOut: _propTypes.default.func,
374
+ /**
375
+ * Offset in pixels from the anchor. Defaults to 16.
376
+ */
377
+ offset: _propTypes.default.number,
372
378
  "aria-label": _propTypes.default.string,
373
379
  "data-test-subj": _propTypes.default.string,
374
380
  css: _propTypes.default.any
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.wcagContrastMin = exports.makeHighContrastColor = exports.makeDisabledContrastColor = void 0;
7
+ exports.wcagContrastMin = exports.warnIfContrastBelowMin = exports.makeHighContrastColor = exports.makeDisabledContrastColor = exports.getColorContrast = void 0;
8
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _chromaJs = _interopRequireDefault(require("chroma-js"));
10
10
  var _manipulation = require("./manipulation");
@@ -17,6 +17,9 @@ var _utils = require("../theme/utils");
17
17
  * Side Public License, v 1.
18
18
  */
19
19
 
20
+ var getColorContrast = exports.getColorContrast = function getColorContrast(textColor, backgroundColor) {
21
+ return _chromaJs.default.contrast(textColor, backgroundColor);
22
+ };
20
23
  var wcagContrastMin = exports.wcagContrastMin = 4.5; // WCAG AA minimum contrast ratio for normal (non-large) text
21
24
 
22
25
  /**
@@ -75,4 +78,12 @@ var makeDisabledContrastColor = exports.makeDisabledContrastColor = function mak
75
78
  return function (themeOrBackground) {
76
79
  return makeHighContrastColor(color, ratio)(themeOrBackground);
77
80
  };
81
+ };
82
+ var warnIfContrastBelowMin = exports.warnIfContrastBelowMin = function warnIfContrastBelowMin(textColor, backgroundColor) {
83
+ var min = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : wcagContrastMin;
84
+ var ratio = getColorContrast(textColor, backgroundColor);
85
+ if (ratio < min) {
86
+ // eslint-disable-next-line no-console
87
+ console.warn("Warning: ".concat(backgroundColor, " background with ").concat(textColor, " text has a low contrast of ").concat(ratio.toFixed(2), ". Should be above ").concat(min, "."));
88
+ }
78
89
  };