@elastic/eui 77.1.1 → 77.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 (108) hide show
  1. package/README.md +30 -29
  2. package/dist/eui_theme_dark.css +70 -158
  3. package/dist/eui_theme_dark.min.css +1 -1
  4. package/dist/eui_theme_light.css +70 -158
  5. package/dist/eui_theme_light.min.css +1 -1
  6. package/es/components/basic_table/basic_table.a11y.js +202 -0
  7. package/es/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +1 -1
  8. package/es/components/date_picker/date_picker.js +23 -15
  9. package/es/components/date_picker/date_picker_range.js +36 -42
  10. package/es/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  11. package/es/components/form/field_number/field_number.js +39 -8
  12. package/es/components/form/field_text/field_text.js +1 -1
  13. package/es/components/form/form_control_layout/form_control_layout.js +67 -30
  14. package/es/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  15. package/es/components/form/form_control_layout/form_control_layout_icons.js +12 -20
  16. package/es/components/form/range/dual_range.js +2 -4
  17. package/es/components/form/range/range.js +0 -2
  18. package/es/components/form/range/range_input.js +54 -13
  19. package/es/components/form/validatable_control/validatable_control.js +15 -5
  20. package/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  21. package/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
  22. package/es/components/suggest/suggest.a11y.js +70 -0
  23. package/es/components/table/table.a11y.js +75 -0
  24. package/eui.d.ts +54 -54
  25. package/i18ntokens.json +26 -8
  26. package/lib/components/basic_table/basic_table.a11y.js +194 -0
  27. package/lib/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +2 -2
  28. package/lib/components/date_picker/date_picker.js +23 -15
  29. package/lib/components/date_picker/date_picker_range.js +35 -41
  30. package/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  31. package/lib/components/form/field_number/field_number.js +42 -8
  32. package/lib/components/form/field_text/field_text.js +1 -1
  33. package/lib/components/form/form_control_layout/form_control_layout.js +67 -35
  34. package/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  35. package/lib/components/form/form_control_layout/form_control_layout_icons.js +11 -19
  36. package/lib/components/form/range/dual_range.js +2 -4
  37. package/lib/components/form/range/range.js +0 -2
  38. package/lib/components/form/range/range_input.js +52 -11
  39. package/lib/components/form/validatable_control/validatable_control.js +14 -12
  40. package/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  41. package/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
  42. package/lib/components/suggest/suggest.a11y.js +73 -0
  43. package/lib/components/table/table.a11y.js +78 -0
  44. package/optimize/es/components/basic_table/basic_table.a11y.js +194 -0
  45. package/optimize/es/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +1 -1
  46. package/optimize/es/components/date_picker/date_picker.js +17 -14
  47. package/optimize/es/components/date_picker/date_picker_range.js +20 -14
  48. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  49. package/optimize/es/components/form/field_number/field_number.js +34 -8
  50. package/optimize/es/components/form/field_text/field_text.js +1 -1
  51. package/optimize/es/components/form/form_control_layout/form_control_layout.js +67 -30
  52. package/optimize/es/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  53. package/optimize/es/components/form/form_control_layout/form_control_layout_icons.js +10 -20
  54. package/optimize/es/components/form/range/dual_range.js +2 -4
  55. package/optimize/es/components/form/range/range.js +0 -2
  56. package/optimize/es/components/form/range/range_input.js +49 -12
  57. package/optimize/es/components/form/validatable_control/validatable_control.js +10 -5
  58. package/optimize/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  59. package/optimize/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
  60. package/optimize/es/components/suggest/suggest.a11y.js +70 -0
  61. package/optimize/es/components/table/table.a11y.js +75 -0
  62. package/optimize/lib/components/basic_table/basic_table.a11y.js +188 -0
  63. package/{test-env/components/basic_table/table.a11y.js → optimize/lib/components/basic_table/in_memory_table.a11y.js} +2 -2
  64. package/optimize/lib/components/date_picker/date_picker.js +17 -14
  65. package/optimize/lib/components/date_picker/date_picker_range.js +19 -13
  66. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  67. package/optimize/lib/components/form/field_number/field_number.js +37 -8
  68. package/optimize/lib/components/form/field_text/field_text.js +1 -1
  69. package/optimize/lib/components/form/form_control_layout/form_control_layout.js +67 -35
  70. package/optimize/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  71. package/optimize/lib/components/form/form_control_layout/form_control_layout_icons.js +9 -19
  72. package/optimize/lib/components/form/range/dual_range.js +2 -4
  73. package/optimize/lib/components/form/range/range.js +0 -2
  74. package/optimize/lib/components/form/range/range_input.js +47 -10
  75. package/optimize/lib/components/form/validatable_control/validatable_control.js +10 -4
  76. package/optimize/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  77. package/optimize/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
  78. package/optimize/lib/components/suggest/suggest.a11y.js +73 -0
  79. package/optimize/lib/components/table/table.a11y.js +78 -0
  80. package/package.json +1 -1
  81. package/src/components/date_picker/_date_picker_range.scss +0 -60
  82. package/src/components/date_picker/super_date_picker/_super_date_picker.scss +23 -11
  83. package/src/components/date_picker/super_date_picker/_variables.scss +3 -0
  84. package/src/components/date_picker/super_date_picker/date_popover/_date_popover_button.scss +5 -7
  85. package/src/components/form/form_control_layout/_form_control_layout.scss +2 -2
  86. package/src/components/form/form_control_layout/_form_control_layout_delimited.scss +12 -36
  87. package/src/components/form/form_control_layout/_form_control_layout_icons.scss +27 -6
  88. package/src/themes/amsterdam/overrides/_date_picker.scss +0 -14
  89. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  90. package/test-env/components/basic_table/basic_table.a11y.js +188 -0
  91. package/{optimize/lib/components/basic_table/table.a11y.js → test-env/components/basic_table/in_memory_table.a11y.js} +2 -2
  92. package/test-env/components/date_picker/date_picker.js +23 -15
  93. package/test-env/components/date_picker/date_picker_range.js +35 -41
  94. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  95. package/test-env/components/form/field_number/field_number.js +37 -8
  96. package/test-env/components/form/field_text/field_text.js +1 -1
  97. package/test-env/components/form/form_control_layout/form_control_layout.js +68 -35
  98. package/test-env/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  99. package/test-env/components/form/form_control_layout/form_control_layout_icons.js +11 -19
  100. package/test-env/components/form/range/dual_range.js +2 -4
  101. package/test-env/components/form/range/range.js +0 -2
  102. package/test-env/components/form/range/range_input.js +47 -11
  103. package/test-env/components/form/validatable_control/validatable_control.js +9 -4
  104. package/test-env/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  105. package/test-env/components/search_bar/query/ast_to_es_query_string.js +3 -0
  106. package/test-env/components/suggest/suggest.a11y.js +73 -0
  107. package/test-env/components/table/table.a11y.js +78 -0
  108. package/src/themes/amsterdam/overrides/_date_popover_button.scss +0 -14
@@ -138,14 +138,12 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
138
138
  theme = _this$props.theme,
139
139
  rest = _objectWithoutProperties(_this$props, _excluded);
140
140
  var id = this.state.id;
141
- var digitTolerance = Math.max(String(min).length, String(max).length);
142
141
  var showInputOnly = showInput === 'inputWithPopover';
143
142
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
144
143
  var theInput = !!showInput ? ___EmotionJSX(EuiRangeInput, _extends({
145
144
  id: id,
146
145
  min: min,
147
146
  max: max,
148
- digitTolerance: digitTolerance,
149
147
  step: step,
150
148
  value: value,
151
149
  readOnly: readOnly,
@@ -1,5 +1,11 @@
1
- var _excluded = ["min", "max", "step", "value", "disabled", "compressed", "onChange", "name", "side", "digitTolerance", "fullWidth", "autoSize"];
1
+ var _excluded = ["min", "max", "step", "value", "inputRef", "isInvalid", "disabled", "compressed", "onChange", "name", "side", "fullWidth", "autoSize"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ 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."); }
5
+ 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); }
6
+ 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; }
7
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
8
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
3
9
  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; }
4
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; }
5
11
  /*
@@ -10,10 +16,11 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
10
16
  * Side Public License, v 1.
11
17
  */
12
18
 
13
- import React, { useMemo } from 'react';
19
+ import React, { useState, useEffect, useMemo, useRef } from 'react';
14
20
  import PropTypes from "prop-types";
15
- import { useEuiTheme } from '../../../services';
21
+ import { useEuiTheme, useCombinedRefs } from '../../../services';
16
22
  import { logicalStyles } from '../../../global_styling';
23
+ import { euiFormVariables } from '../form.styles';
17
24
  import { EuiFieldNumber } from '../field_number';
18
25
  import { euiRangeInputStyles } from './range_input.styles';
19
26
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -22,28 +29,61 @@ export var EuiRangeInput = function EuiRangeInput(_ref) {
22
29
  max = _ref.max,
23
30
  step = _ref.step,
24
31
  value = _ref.value,
32
+ inputRef = _ref.inputRef,
33
+ isInvalid = _ref.isInvalid,
25
34
  disabled = _ref.disabled,
26
35
  compressed = _ref.compressed,
27
36
  onChange = _ref.onChange,
28
37
  name = _ref.name,
29
38
  _ref$side = _ref.side,
30
39
  side = _ref$side === void 0 ? 'max' : _ref$side,
31
- digitTolerance = _ref.digitTolerance,
32
40
  fullWidth = _ref.fullWidth,
33
41
  _ref$autoSize = _ref.autoSize,
34
42
  autoSize = _ref$autoSize === void 0 ? true : _ref$autoSize,
35
43
  rest = _objectWithoutProperties(_ref, _excluded);
36
- // Chrome will properly size the input based on the max value, but FF does not.
37
- // Calculate the width of the input based on highest number of characters.
38
- // Add 2 to accommodate for input stepper
39
- var widthStyle = useMemo(function () {
40
- return autoSize ? logicalStyles({
41
- width: "".concat(digitTolerance / 1.25 + 2, "em")
42
- }) : {};
43
- }, [autoSize, digitTolerance]);
44
44
  var euiTheme = useEuiTheme();
45
45
  var styles = euiRangeInputStyles(euiTheme);
46
46
  var cssStyles = [styles.euiRangeInput];
47
+
48
+ // Determine whether an invalid icon is showing, which can come from
49
+ // the underlying EuiFieldNumber's native :invalid state
50
+ var _useState = useState(isInvalid),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ hasInvalidIcon = _useState2[0],
53
+ setHasInvalidIcon = _useState2[1];
54
+ var validityRef = useRef(null);
55
+ var setRefs = useCombinedRefs([validityRef, inputRef]);
56
+ useEffect(function () {
57
+ var _validityRef$current;
58
+ var isNativelyInvalid = !((_validityRef$current = validityRef.current) !== null && _validityRef$current !== void 0 && _validityRef$current.validity.valid);
59
+ setHasInvalidIcon(isNativelyInvalid || isInvalid);
60
+ }, [value, isInvalid]);
61
+
62
+ // Calculate the auto size width of the input
63
+ var widthStyle = useMemo(function () {
64
+ if (!autoSize) return undefined;
65
+
66
+ // Calculate the number of characters to show (dynamic based on user input)
67
+ // Uses the min/max char length as a max, then add an extra UX buffer of 1
68
+ var maxChars = Math.max(String(min).length, String(max).length) + 1;
69
+ var inputCharWidth = Math.min(String(value).length, maxChars);
70
+
71
+ // Calculate the form padding based on `compressed` state
72
+ var _euiFormVariables = euiFormVariables(euiTheme),
73
+ controlPadding = _euiFormVariables.controlPadding,
74
+ controlCompressedPadding = _euiFormVariables.controlCompressedPadding;
75
+ var inputPadding = compressed ? controlCompressedPadding : controlPadding;
76
+
77
+ // Calculate the invalid icon (if being displayed), also based on `compressed` state
78
+ var invalidIconWidth = hasInvalidIcon ? euiTheme.euiTheme.base * (compressed ? 1.125 : 1.375) // TODO: DRY this out once EuiFormControlLayoutIcons is converted to Emotion
79
+ : 0;
80
+
81
+ // Guesstimate a width for the stepper. Note that it's a little wider in FF than it is in Chrome
82
+ var stepperWidth = 2;
83
+ return logicalStyles({
84
+ width: "calc(".concat(inputPadding, " + ").concat(inputCharWidth, "ch + ").concat(stepperWidth, "em + ").concat(invalidIconWidth, "px)")
85
+ });
86
+ }, [autoSize, euiTheme, compressed, hasInvalidIcon, min, max, value]);
47
87
  return ___EmotionJSX(EuiFieldNumber, _extends({
48
88
  name: name,
49
89
  className: "euiRangeInput euiRangeInput--".concat(side),
@@ -52,6 +92,8 @@ export var EuiRangeInput = function EuiRangeInput(_ref) {
52
92
  max: Number(max),
53
93
  step: step,
54
94
  value: value === '' ? '' : Number(value),
95
+ inputRef: setRefs,
96
+ isInvalid: isInvalid,
55
97
  disabled: disabled,
56
98
  compressed: compressed,
57
99
  onChange: onChange,
@@ -61,7 +103,6 @@ export var EuiRangeInput = function EuiRangeInput(_ref) {
61
103
  };
62
104
  EuiRangeInput.propTypes = {
63
105
  autoSize: PropTypes.bool,
64
- digitTolerance: PropTypes.number.isRequired,
65
106
  /**
66
107
  * @default 'max'
67
108
  */
@@ -1,3 +1,9 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1
7
  /*
2
8
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
9
  * or more contributor license agreements. Licensed under the Elastic License
@@ -6,7 +12,7 @@
6
12
  * Side Public License, v 1.
7
13
  */
8
14
 
9
- import { Children, cloneElement, useRef, useEffect, useCallback } from 'react';
15
+ import { Children, cloneElement, useState, useEffect, useCallback } from 'react';
10
16
  import PropTypes from "prop-types";
11
17
  function isMutableRef(ref) {
12
18
  return ref != null && ref.hasOwnProperty('current');
@@ -20,11 +26,15 @@ function isMutableRef(ref) {
20
26
  export var EuiValidatableControl = function EuiValidatableControl(_ref) {
21
27
  var isInvalid = _ref.isInvalid,
22
28
  children = _ref.children;
23
- var control = useRef(null);
29
+ // Note that this must be state and not a ref to cause a rerender/set invalid state on initial mount
30
+ var _useState = useState(null),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ control = _useState2[0],
33
+ setControl = _useState2[1];
24
34
  var child = Children.only(children);
25
35
  var childRef = child.ref;
26
36
  var replacedRef = useCallback(function (element) {
27
- control.current = element;
37
+ setControl(element);
28
38
 
29
39
  // Call the original ref, if any
30
40
  if (typeof childRef === 'function') {
@@ -34,12 +44,12 @@ export var EuiValidatableControl = function EuiValidatableControl(_ref) {
34
44
  }
35
45
  }, [childRef]);
36
46
  useSetControlValidity({
37
- controlEl: control.current,
47
+ controlEl: control,
38
48
  isInvalid: isInvalid
39
49
  });
40
50
  return /*#__PURE__*/cloneElement(child, {
41
51
  ref: replacedRef,
42
- 'aria-invalid': isInvalid
52
+ 'aria-invalid': isInvalid || child.props['aria-invalid']
43
53
  });
44
54
  };
45
55
 
@@ -66,7 +66,12 @@ var processDateOperation = function processDateOperation(value, operator) {
66
66
  };
67
67
  export var _termValuesToQuery = function _termValuesToQuery(values, options) {
68
68
  var body = {
69
- query: values.join(' ')
69
+ query: values.map(function (value) {
70
+ if (isString(value) && value.match(/\s/)) {
71
+ return "\"".concat(value, "\"");
72
+ }
73
+ return value;
74
+ }).join(' ')
70
75
  };
71
76
  if (body.query === '') {
72
77
  return;
@@ -134,6 +134,9 @@ var emitTermClause = function emitTermClause(clause, isGroupMember) {
134
134
  match = undefined;
135
135
  }
136
136
  var matchOp = emitMatch(match);
137
+ if (isString(value) && value.match(/\s/)) {
138
+ return "".concat(matchOp, "\"").concat(escapeValue(value), "\"");
139
+ }
137
140
  return "".concat(matchOp).concat(escapeValue(value));
138
141
  };
139
142
  var emitIsClause = function emitIsClause(clause, isGroupMember) {
@@ -0,0 +1,70 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ /// <reference types="cypress" />
10
+ /// <reference types="cypress-real-events" />
11
+ /// <reference types="../../../cypress/support" />
12
+
13
+ import React from 'react';
14
+ import { EuiFormRow } from '../form';
15
+ import { EuiSuggest } from './suggest';
16
+ import { jsx as ___EmotionJSX } from "@emotion/react";
17
+ var Suggest = function Suggest() {
18
+ var suggestedItems = [{
19
+ type: {
20
+ iconType: 'accessibility',
21
+ color: 'tint1'
22
+ },
23
+ label: 'Accessibility',
24
+ description: 'A short description'
25
+ }, {
26
+ type: {
27
+ iconType: 'image',
28
+ color: 'tint2'
29
+ },
30
+ label: 'Images',
31
+ description: 'Another short description'
32
+ }, {
33
+ type: {
34
+ iconType: 'lock',
35
+ color: 'tint3'
36
+ },
37
+ label: 'Locks',
38
+ description: 'A third short description'
39
+ }];
40
+ return ___EmotionJSX(EuiFormRow, {
41
+ label: "Suggest a topic",
42
+ id: "cy-label-suggest-1"
43
+ }, ___EmotionJSX(EuiSuggest, {
44
+ "aria-labelledby": "cy-label-suggest-1-label",
45
+ suggestions: suggestedItems
46
+ }));
47
+ };
48
+ describe('EuiSuggest', function () {
49
+ beforeEach(function () {
50
+ cy.realMount(___EmotionJSX(Suggest, null));
51
+ });
52
+ describe('Automated accessibility check', function () {
53
+ it('has zero violations when rendered', function () {
54
+ cy.checkAxe();
55
+ });
56
+ });
57
+ describe('Keyboard accessibility', function () {
58
+ it('has zero violations after traversing list items', function () {
59
+ cy.realPress('Tab');
60
+ cy.get('#cy-label-suggest-1').should('have.focus');
61
+ cy.get('ul[role="listbox"]').should('exist');
62
+ cy.realPress('ArrowDown');
63
+ cy.realPress('ArrowUp');
64
+ cy.realPress('ArrowRight');
65
+ cy.realPress('ArrowLeft');
66
+ cy.get('li[role="option"]').first().should('have.attr', 'aria-selected', 'true');
67
+ cy.checkAxe();
68
+ });
69
+ });
70
+ });
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ /// <reference types="cypress" />
10
+ /// <reference types="cypress-real-events" />
11
+ /// <reference types="../../../cypress/support" />
12
+
13
+ import React from 'react';
14
+ import { EuiTable, EuiTableHeader, EuiTableHeaderCell, EuiTableBody, EuiTableRow, EuiTableRowCell } from '.';
15
+ import { jsx as ___EmotionJSX } from "@emotion/react";
16
+ var users = [{
17
+ id: '47936',
18
+ firstName: 'Robert',
19
+ lastName: 'Stein',
20
+ github: 'steiner_rob',
21
+ location: {
22
+ city: 'Los Angeles',
23
+ state: 'CA'
24
+ }
25
+ }, {
26
+ id: '54736',
27
+ firstName: 'Martina',
28
+ lastName: 'Conlon',
29
+ github: 'martina_zen',
30
+ location: {
31
+ city: 'Boston',
32
+ state: 'MA'
33
+ }
34
+ }, {
35
+ id: '40193',
36
+ firstName: 'Alyce',
37
+ lastName: 'Benning',
38
+ github: 'alyce_benning',
39
+ location: {
40
+ city: 'Atlanta',
41
+ state: 'GA'
42
+ }
43
+ }];
44
+ var userRows = users.map(function (user) {
45
+ var id = user.id,
46
+ firstName = user.firstName,
47
+ lastName = user.lastName,
48
+ github = user.github,
49
+ _user$location = user.location,
50
+ city = _user$location.city,
51
+ state = _user$location.state;
52
+ return ___EmotionJSX(EuiTableRow, {
53
+ key: id
54
+ }, ___EmotionJSX(EuiTableRowCell, null, "".concat(firstName, " ").concat(lastName)), ___EmotionJSX(EuiTableRowCell, null, github), ___EmotionJSX(EuiTableRowCell, null, "".concat(city, ", ").concat(state)));
55
+ });
56
+ var customColumns = ['Name', 'Github', 'Location'];
57
+ var columnHeaders = customColumns.map(function (column, i) {
58
+ return ___EmotionJSX(EuiTableHeaderCell, {
59
+ key: i
60
+ }, column);
61
+ });
62
+ var CustomTable = function CustomTable() {
63
+ return ___EmotionJSX(EuiTable, null, ___EmotionJSX(EuiTableHeader, null, columnHeaders), ___EmotionJSX(EuiTableBody, null, userRows));
64
+ };
65
+ describe('EuiTable', function () {
66
+ beforeEach(function () {
67
+ cy.viewport(1024, 768); // medium breakpoint
68
+ cy.realMount(___EmotionJSX(CustomTable, null));
69
+ });
70
+ describe('Automated accessibility check', function () {
71
+ it('has zero violations on render', function () {
72
+ cy.checkAxe();
73
+ });
74
+ });
75
+ });
package/eui.d.ts CHANGED
@@ -3219,6 +3219,41 @@ declare module '@elastic/eui/src/components/form/described_form_group' {
3219
3219
  export type { EuiDescribedFormGroupProps } from '@elastic/eui/src/components/form/described_form_group/described_form_group';
3220
3220
  export { EuiDescribedFormGroup } from '@elastic/eui/src/components/form/described_form_group/described_form_group';
3221
3221
 
3222
+ }
3223
+ declare module '@elastic/eui/src/components/form/validatable_control/validatable_control' {
3224
+ import { ReactElement, Ref, FunctionComponent } from 'react';
3225
+ import { CommonProps } from '@elastic/eui/src/components/common';
3226
+ export interface HTMLConstraintValidityElement extends Element {
3227
+ setCustomValidity: (error: string) => void;
3228
+ }
3229
+ export interface ReactElementWithRef extends ReactElement {
3230
+ ref?: Ref<HTMLConstraintValidityElement>;
3231
+ }
3232
+ /**
3233
+ * The `EuiValidatableControl` component should be used in scenarios where
3234
+ * we can render the validated `<input>` as its direct child.
3235
+ */
3236
+ export interface EuiValidatableControlProps {
3237
+ isInvalid?: boolean;
3238
+ children: ReactElementWithRef;
3239
+ }
3240
+ export const EuiValidatableControl: FunctionComponent<CommonProps & EuiValidatableControlProps>;
3241
+ /**
3242
+ * The `UseEuiValidatableControl` hook should be used in scenarios where
3243
+ * we *cannot* control where the validated `<input>` is rendered (e.g., ReactDatePicker)
3244
+ * and instead need to access the input via a ref and pass the element in directly
3245
+ */
3246
+ export interface UseEuiValidatableControlProps {
3247
+ isInvalid?: boolean;
3248
+ controlEl: HTMLInputElement | HTMLConstraintValidityElement | null;
3249
+ }
3250
+ export const useEuiValidatableControl: ({ isInvalid, controlEl, }: UseEuiValidatableControlProps) => void;
3251
+
3252
+ }
3253
+ declare module '@elastic/eui/src/components/form/validatable_control' {
3254
+ export type { EuiValidatableControlProps, UseEuiValidatableControlProps, } from '@elastic/eui/src/components/form/validatable_control/validatable_control';
3255
+ export { EuiValidatableControl, useEuiValidatableControl, } from '@elastic/eui/src/components/form/validatable_control/validatable_control';
3256
+
3222
3257
  }
3223
3258
  declare module '@elastic/eui/src/components/form/form_control_layout/form_control_layout_clear_button' {
3224
3259
  import { FunctionComponent, ButtonHTMLAttributes } from 'react';
@@ -3248,7 +3283,8 @@ declare module '@elastic/eui/src/components/form/form_control_layout/form_contro
3248
3283
  import { EuiFormControlLayoutCustomIconProps } from '@elastic/eui/src/components/form/form_control_layout/form_control_layout_custom_icon';
3249
3284
  import { IconColor, IconType } from '@elastic/eui/src/components/icon';
3250
3285
  import { DistributiveOmit } from '@elastic/eui/src/components/common';
3251
- export const ICON_SIDES: ['left', 'right']; type IconShape = DistributiveOmit<EuiFormControlLayoutCustomIconProps, 'type' | 'iconRef'> & {
3286
+ export const ICON_SIDES: readonly ["left", "right"];
3287
+ export type IconShape = DistributiveOmit<EuiFormControlLayoutCustomIconProps, 'type' | 'iconRef'> & {
3252
3288
  type: IconType;
3253
3289
  side?: typeof ICON_SIDES[number];
3254
3290
  color?: IconColor;
@@ -3256,6 +3292,8 @@ declare module '@elastic/eui/src/components/form/form_control_layout/form_contro
3256
3292
  };
3257
3293
  export interface EuiFormControlLayoutIconsProps {
3258
3294
  icon?: IconType | IconShape;
3295
+ side?: typeof ICON_SIDES[number];
3296
+ iconsPosition?: 'absolute' | 'static';
3259
3297
  clear?: EuiFormControlLayoutClearButtonProps;
3260
3298
  isLoading?: boolean;
3261
3299
  isInvalid?: boolean;
@@ -3270,7 +3308,6 @@ declare module '@elastic/eui/src/components/form/form_control_layout/form_contro
3270
3308
  renderClearButton(): JSX.Element | null;
3271
3309
  renderInvalidIcon(): JSX.Element | null;
3272
3310
  }
3273
- export {};
3274
3311
 
3275
3312
  }
3276
3313
  declare module '@elastic/eui/src/components/form/form_label/form_label' {
@@ -3309,8 +3346,7 @@ declare module '@elastic/eui/src/components/form/form_control_layout/form_contro
3309
3346
  import React, { Component, HTMLAttributes, ReactElement, ReactNode } from 'react';
3310
3347
  import { EuiFormControlLayoutIconsProps } from '@elastic/eui/src/components/form/form_control_layout/form_control_layout_icons';
3311
3348
  import { CommonProps } from '@elastic/eui/src/components/common';
3312
- import { FormContextValue } from '@elastic/eui/src/components/form/eui_form_context';
3313
- export { ICON_SIDES } from '@elastic/eui/src/components/form/form_control_layout/form_control_layout_icons'; type StringOrReactElement = string | ReactElement; type PrependAppendType = StringOrReactElement | StringOrReactElement[];
3349
+ import { FormContextValue } from '@elastic/eui/src/components/form/eui_form_context'; type StringOrReactElement = string | ReactElement; type PrependAppendType = StringOrReactElement | StringOrReactElement[];
3314
3350
  export type EuiFormControlLayoutProps = CommonProps & HTMLAttributes<HTMLDivElement> & {
3315
3351
  /**
3316
3352
  * Creates an input group with element(s) coming before children.
@@ -3324,6 +3360,7 @@ declare module '@elastic/eui/src/components/form/form_control_layout/form_contro
3324
3360
  append?: PrependAppendType;
3325
3361
  children?: ReactNode;
3326
3362
  icon?: EuiFormControlLayoutIconsProps['icon'];
3363
+ iconsPosition?: EuiFormControlLayoutIconsProps['iconsPosition'];
3327
3364
  clear?: EuiFormControlLayoutIconsProps['clear'];
3328
3365
  /**
3329
3366
  * Expand to fill 100% of the parent.
@@ -3349,10 +3386,13 @@ declare module '@elastic/eui/src/components/form/form_control_layout/form_contro
3349
3386
  export class EuiFormControlLayout extends Component<EuiFormControlLayoutProps> {
3350
3387
  static contextType: React.Context<FormContextValue>;
3351
3388
  render(): JSX.Element;
3389
+ renderLeftIcons: () => JSX.Element | null;
3390
+ renderRightIcons: () => JSX.Element | null;
3352
3391
  renderSideNode(side: 'append' | 'prepend', nodes?: PrependAppendType, inputId?: string): JSX.Element | JSX.Element[] | undefined;
3353
3392
  createFormLabel(side: 'append' | 'prepend', string: string, inputId?: string): JSX.Element;
3354
3393
  createSideNode(side: 'append' | 'prepend', node: ReactElement, key: React.Key): React.ReactElement<any, string | React.JSXElementConstructor<any>>;
3355
3394
  }
3395
+ export {};
3356
3396
 
3357
3397
  }
3358
3398
  declare module '@elastic/eui/src/components/form/form_control_layout/form_control_layout_delimited' {
@@ -3383,41 +3423,6 @@ declare module '@elastic/eui/src/components/form/form_control_layout' {
3383
3423
  export type { EuiFormControlLayoutDelimitedProps } from '@elastic/eui/src/components/form/form_control_layout/form_control_layout_delimited';
3384
3424
  export { EuiFormControlLayoutDelimited } from '@elastic/eui/src/components/form/form_control_layout/form_control_layout_delimited';
3385
3425
 
3386
- }
3387
- declare module '@elastic/eui/src/components/form/validatable_control/validatable_control' {
3388
- import { ReactElement, Ref, FunctionComponent } from 'react';
3389
- import { CommonProps } from '@elastic/eui/src/components/common';
3390
- export interface HTMLConstraintValidityElement extends Element {
3391
- setCustomValidity: (error: string) => void;
3392
- }
3393
- export interface ReactElementWithRef extends ReactElement {
3394
- ref?: Ref<HTMLConstraintValidityElement>;
3395
- }
3396
- /**
3397
- * The `EuiValidatableControl` component should be used in scenarios where
3398
- * we can render the validated `<input>` as its direct child.
3399
- */
3400
- export interface EuiValidatableControlProps {
3401
- isInvalid?: boolean;
3402
- children: ReactElementWithRef;
3403
- }
3404
- export const EuiValidatableControl: FunctionComponent<CommonProps & EuiValidatableControlProps>;
3405
- /**
3406
- * The `UseEuiValidatableControl` hook should be used in scenarios where
3407
- * we *cannot* control where the validated `<input>` is rendered (e.g., ReactDatePicker)
3408
- * and instead need to access the input via a ref and pass the element in directly
3409
- */
3410
- export interface UseEuiValidatableControlProps {
3411
- isInvalid?: boolean;
3412
- controlEl: HTMLInputElement | HTMLConstraintValidityElement | null;
3413
- }
3414
- export const useEuiValidatableControl: ({ isInvalid, controlEl, }: UseEuiValidatableControlProps) => void;
3415
-
3416
- }
3417
- declare module '@elastic/eui/src/components/form/validatable_control' {
3418
- export type { EuiValidatableControlProps, UseEuiValidatableControlProps, } from '@elastic/eui/src/components/form/validatable_control/validatable_control';
3419
- export { EuiValidatableControl, useEuiValidatableControl, } from '@elastic/eui/src/components/form/validatable_control/validatable_control';
3420
-
3421
3426
  }
3422
3427
  declare module '@elastic/eui/src/components/form/form_control_layout/_num_icons' {
3423
3428
  /**
@@ -3444,8 +3449,8 @@ declare module '@elastic/eui/src/components/form/form_control_layout/_num_icons'
3444
3449
  declare module '@elastic/eui/src/components/form/field_number/field_number' {
3445
3450
  import { InputHTMLAttributes, Ref, FunctionComponent } from 'react';
3446
3451
  import { CommonProps } from '@elastic/eui/src/components/common';
3447
- import { EuiFormControlLayoutProps } from '@elastic/eui/src/components/form/form_control_layout';
3448
3452
  import { IconType } from '@elastic/eui/src/components/icon';
3453
+ import { EuiFormControlLayoutProps } from '@elastic/eui/src/components/form/form_control_layout';
3449
3454
  export type EuiFieldNumberProps = Omit<InputHTMLAttributes<HTMLInputElement>, 'min' | 'max' | 'readOnly' | 'step'> & CommonProps & {
3450
3455
  icon?: IconType;
3451
3456
  isInvalid?: boolean;
@@ -5424,7 +5429,6 @@ declare module '@elastic/eui/src/components/form/range/range_input' {
5424
5429
  import type { _SingleRangeValue, _SharedRangeInputSide } from '@elastic/eui/src/components/form/range/types';
5425
5430
  export interface EuiRangeInputProps extends Omit<EuiFieldNumberProps, 'max' | 'min' | 'value' | 'step'>, Omit<_SingleRangeValue, 'onChange'>, _SharedRangeInputSide {
5426
5431
  autoSize?: boolean;
5427
- digitTolerance: number;
5428
5432
  }
5429
5433
  export const EuiRangeInput: FunctionComponent<EuiRangeInputProps>;
5430
5434
 
@@ -13807,6 +13811,11 @@ declare module '@elastic/eui/src/components/date_picker/date_picker' {
13807
13811
  * **Use [EuiPopover](/#/layout/popover) values**: 'upCenter', 'upLeft', 'upRight', downCenter', 'downLeft', 'downRight', 'leftCenter', 'leftUp', 'leftDown', 'rightCenter', 'rightUp', 'rightDown'.
13808
13812
  */
13809
13813
  popoverPlacement?: PopoverAnchorPosition;
13814
+ /**
13815
+ * Completely removes form control layout wrapper and ignores
13816
+ * iconType. Best used inside EuiFormControlLayoutDelimited.
13817
+ */
13818
+ controlOnly?: boolean;
13810
13819
  }
13811
13820
  export type EuiDatePickerProps = CommonProps & EuiExtendedDatePickerProps;
13812
13821
  export const EuiDatePicker: FunctionComponent<EuiDatePickerProps>;
@@ -14423,9 +14432,10 @@ declare module '@elastic/eui/src/components/date_picker/super_date_picker/async_
14423
14432
  }
14424
14433
  declare module '@elastic/eui/src/components/date_picker/date_picker_range' {
14425
14434
  import { FocusEventHandler, FunctionComponent, ReactNode, ReactElement } from 'react';
14435
+ import { EuiFormControlLayoutDelimitedProps } from '@elastic/eui/src/components/form';
14426
14436
  import { IconType } from '@elastic/eui/src/components/icon';
14427
14437
  import { CommonProps } from '@elastic/eui/src/components/common';
14428
- export type EuiDatePickerRangeProps = CommonProps & {
14438
+ export type EuiDatePickerRangeProps = CommonProps & Pick<EuiFormControlLayoutDelimitedProps, 'isInvalid' | 'readOnly' | 'fullWidth' | 'prepend' | 'append'> & {
14429
14439
  /**
14430
14440
  * Including any children will replace all innards with the provided children
14431
14441
  */
@@ -14446,22 +14456,10 @@ declare module '@elastic/eui/src/components/date_picker/date_picker_range' {
14446
14456
  * Won't apply any additional props to start and end date components
14447
14457
  */
14448
14458
  isCustom?: boolean;
14449
- /**
14450
- * Will color the range delimiter the `danger` color and pass through to each control
14451
- */
14452
- isInvalid?: boolean;
14453
14459
  /**
14454
14460
  * Passes through to each control
14455
14461
  */
14456
14462
  disabled?: boolean;
14457
- /**
14458
- * Passes through to each control
14459
- */
14460
- readOnly?: boolean;
14461
- /**
14462
- * Passes through to each control
14463
- */
14464
- fullWidth?: boolean;
14465
14463
  /**
14466
14464
  * Triggered whenever the start or end controls are blurred
14467
14465
  */
@@ -14761,6 +14759,7 @@ declare module '@elastic/eui/src/components/date_picker/super_date_picker/super_
14761
14759
  onRefreshChange: ApplyRefreshInterval;
14762
14760
  stopInterval: () => void;
14763
14761
  startInterval: (refreshInterval: number) => void;
14762
+ renderQuickSelect: () => JSX.Element;
14764
14763
  renderDatePickerRange: () => JSX.Element;
14765
14764
  handleClickUpdateButton: () => void;
14766
14765
  renderUpdateButton: () => JSX.Element | null;
@@ -26457,6 +26456,7 @@ declare module '@elastic/eui' {
26457
26456
  "euiFilePicker.clearSelectedFiles": any;
26458
26457
  "euiFilePicker.removeSelected": any;
26459
26458
  "euiFormControlLayoutClearButton.label": any;
26459
+ "euiFormControlLayoutDelimited.delimiterLabel": any;
26460
26460
  "euiForm.addressFormErrors": any;
26461
26461
  "euiDualRange.sliderScreenReaderInstructions": any;
26462
26462
  "euiRange.sliderScreenReaderInstructions": any;
package/i18ntokens.json CHANGED
@@ -4805,6 +4805,24 @@
4805
4805
  },
4806
4806
  "filepath": "src/components/form/form_control_layout/form_control_layout_clear_button.tsx"
4807
4807
  },
4808
+ {
4809
+ "token": "euiFormControlLayoutDelimited.delimiterLabel",
4810
+ "defString": "to",
4811
+ "highlighting": "string",
4812
+ "loc": {
4813
+ "start": {
4814
+ "line": 87,
4815
+ "column": 27,
4816
+ "index": 2215
4817
+ },
4818
+ "end": {
4819
+ "line": 90,
4820
+ "column": 3,
4821
+ "index": 2291
4822
+ }
4823
+ },
4824
+ "filepath": "src/components/form/form_control_layout/form_control_layout_delimited.tsx"
4825
+ },
4808
4826
  {
4809
4827
  "token": "euiForm.addressFormErrors",
4810
4828
  "defString": "Please address the highlighted errors.",
@@ -4829,14 +4847,14 @@
4829
4847
  "highlighting": "string",
4830
4848
  "loc": {
4831
4849
  "start": {
4832
- "line": 571,
4850
+ "line": 568,
4833
4851
  "column": 6,
4834
- "index": 17705
4852
+ "index": 17548
4835
4853
  },
4836
4854
  "end": {
4837
- "line": 574,
4855
+ "line": 571,
4838
4856
  "column": 8,
4839
- "index": 17940
4857
+ "index": 17783
4840
4858
  }
4841
4859
  },
4842
4860
  "filepath": "src/components/form/range/dual_range.tsx"
@@ -4847,14 +4865,14 @@
4847
4865
  "highlighting": "string",
4848
4866
  "loc": {
4849
4867
  "start": {
4850
- "line": 184,
4868
+ "line": 182,
4851
4869
  "column": 6,
4852
- "index": 4950
4870
+ "index": 4833
4853
4871
  },
4854
4872
  "end": {
4855
- "line": 187,
4873
+ "line": 185,
4856
4874
  "column": 8,
4857
- "index": 5127
4875
+ "index": 5010
4858
4876
  }
4859
4877
  },
4860
4878
  "filepath": "src/components/form/range/range.tsx"