@elastic/eui 77.1.1 → 77.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +37 -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 +40 -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 +32 -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 +35 -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 +35 -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
@@ -398,7 +398,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
398
398
  var min = minProps;
399
399
  var max = maxProps;
400
400
  var id = this.state.id;
401
- var digitTolerance = Math.max(String(min).length, String(max).length);
402
401
  var showInputOnly = showInput === 'inputWithPopover';
403
402
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
404
403
  var rangeStyles = (0, _range.euiRangeStyles)(theme);
@@ -409,7 +408,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
409
408
  "aria-label": this.props['aria-label']
410
409
  }, minInputProps, {
411
410
  // Non-overridable props
412
- digitTolerance: digitTolerance,
413
411
  side: "min",
414
412
  min: min,
415
413
  max: Number(this.upperValue),
@@ -438,7 +436,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
438
436
  "aria-label": this.props['aria-label']
439
437
  }, maxInputProps, {
440
438
  // Non-overridable props
441
- digitTolerance: digitTolerance,
442
439
  side: "max",
443
440
  min: Number(this.lowerValue),
444
441
  max: max,
@@ -590,7 +587,8 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
590
587
  readOnly: readOnly,
591
588
  append: append,
592
589
  prepend: prepend,
593
- isLoading: isLoading
590
+ isLoading: isLoading,
591
+ isInvalid: isInvalid
594
592
  }),
595
593
  fullWidth: fullWidth,
596
594
  isOpen: this.state.isPopoverOpen,
@@ -139,14 +139,12 @@ var EuiRangeClass = /*#__PURE__*/function (_Component) {
139
139
  theme = _this$props.theme,
140
140
  rest = _objectWithoutProperties(_this$props, _excluded);
141
141
  var id = this.state.id;
142
- var digitTolerance = Math.max(String(min).length, String(max).length);
143
142
  var showInputOnly = showInput === 'inputWithPopover';
144
143
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
145
144
  var theInput = !!showInput ? (0, _react2.jsx)(_range_input.EuiRangeInput, _extends({
146
145
  id: id,
147
146
  min: min,
148
147
  max: max,
149
- digitTolerance: digitTolerance,
150
148
  step: step,
151
149
  value: value,
152
150
  readOnly: readOnly,
@@ -9,14 +9,21 @@ var _react = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
10
  var _services = require("../../../services");
11
11
  var _global_styling = require("../../../global_styling");
12
+ var _form = require("../form.styles");
12
13
  var _field_number = require("../field_number");
13
14
  var _range_input = require("./range_input.styles");
14
15
  var _react2 = require("@emotion/react");
15
- var _excluded = ["min", "max", "step", "value", "disabled", "compressed", "onChange", "name", "side", "digitTolerance", "fullWidth", "autoSize"];
16
+ var _excluded = ["min", "max", "step", "value", "inputRef", "isInvalid", "disabled", "compressed", "onChange", "name", "side", "fullWidth", "autoSize"];
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
19
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
20
  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); }
21
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
22
+ 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."); }
23
+ 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); }
24
+ 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; }
25
+ 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; } }
26
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
27
  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; }
21
28
  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; }
22
29
  var EuiRangeInput = function EuiRangeInput(_ref) {
@@ -24,28 +31,61 @@ var EuiRangeInput = function EuiRangeInput(_ref) {
24
31
  max = _ref.max,
25
32
  step = _ref.step,
26
33
  value = _ref.value,
34
+ inputRef = _ref.inputRef,
35
+ isInvalid = _ref.isInvalid,
27
36
  disabled = _ref.disabled,
28
37
  compressed = _ref.compressed,
29
38
  onChange = _ref.onChange,
30
39
  name = _ref.name,
31
40
  _ref$side = _ref.side,
32
41
  side = _ref$side === void 0 ? 'max' : _ref$side,
33
- digitTolerance = _ref.digitTolerance,
34
42
  fullWidth = _ref.fullWidth,
35
43
  _ref$autoSize = _ref.autoSize,
36
44
  autoSize = _ref$autoSize === void 0 ? true : _ref$autoSize,
37
45
  rest = _objectWithoutProperties(_ref, _excluded);
38
- // Chrome will properly size the input based on the max value, but FF does not.
39
- // Calculate the width of the input based on highest number of characters.
40
- // Add 2 to accommodate for input stepper
41
- var widthStyle = (0, _react.useMemo)(function () {
42
- return autoSize ? (0, _global_styling.logicalStyles)({
43
- width: "".concat(digitTolerance / 1.25 + 2, "em")
44
- }) : {};
45
- }, [autoSize, digitTolerance]);
46
46
  var euiTheme = (0, _services.useEuiTheme)();
47
47
  var styles = (0, _range_input.euiRangeInputStyles)(euiTheme);
48
48
  var cssStyles = [styles.euiRangeInput];
49
+
50
+ // Determine whether an invalid icon is showing, which can come from
51
+ // the underlying EuiFieldNumber's native :invalid state
52
+ var _useState = (0, _react.useState)(isInvalid),
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ hasInvalidIcon = _useState2[0],
55
+ setHasInvalidIcon = _useState2[1];
56
+ var validityRef = (0, _react.useRef)(null);
57
+ var setRefs = (0, _services.useCombinedRefs)([validityRef, inputRef]);
58
+ (0, _react.useEffect)(function () {
59
+ var _validityRef$current;
60
+ var isNativelyInvalid = !((_validityRef$current = validityRef.current) !== null && _validityRef$current !== void 0 && _validityRef$current.validity.valid);
61
+ setHasInvalidIcon(isNativelyInvalid || isInvalid);
62
+ }, [value, isInvalid]);
63
+
64
+ // Calculate the auto size width of the input
65
+ var widthStyle = (0, _react.useMemo)(function () {
66
+ if (!autoSize) return undefined;
67
+
68
+ // Calculate the number of characters to show (dynamic based on user input)
69
+ // Uses the min/max char length as a max, then add an extra UX buffer of 1
70
+ var maxChars = Math.max(String(min).length, String(max).length) + 1;
71
+ var inputCharWidth = Math.min(String(value).length, maxChars);
72
+
73
+ // Calculate the form padding based on `compressed` state
74
+ var _euiFormVariables = (0, _form.euiFormVariables)(euiTheme),
75
+ controlPadding = _euiFormVariables.controlPadding,
76
+ controlCompressedPadding = _euiFormVariables.controlCompressedPadding;
77
+ var inputPadding = compressed ? controlCompressedPadding : controlPadding;
78
+
79
+ // Calculate the invalid icon (if being displayed), also based on `compressed` state
80
+ var invalidIconWidth = hasInvalidIcon ? euiTheme.euiTheme.base * (compressed ? 1.125 : 1.375) // TODO: DRY this out once EuiFormControlLayoutIcons is converted to Emotion
81
+ : 0;
82
+
83
+ // Guesstimate a width for the stepper. Note that it's a little wider in FF than it is in Chrome
84
+ var stepperWidth = 2;
85
+ return (0, _global_styling.logicalStyles)({
86
+ width: "calc(".concat(inputPadding, " + ").concat(inputCharWidth, "ch + ").concat(stepperWidth, "em + ").concat(invalidIconWidth, "px)")
87
+ });
88
+ }, [autoSize, euiTheme, compressed, hasInvalidIcon, min, max, value]);
49
89
  return (0, _react2.jsx)(_field_number.EuiFieldNumber, _extends({
50
90
  name: name,
51
91
  className: "euiRangeInput euiRangeInput--".concat(side),
@@ -54,6 +94,8 @@ var EuiRangeInput = function EuiRangeInput(_ref) {
54
94
  max: Number(max),
55
95
  step: step,
56
96
  value: value === '' ? '' : Number(value),
97
+ inputRef: setRefs,
98
+ isInvalid: isInvalid,
57
99
  disabled: disabled,
58
100
  compressed: compressed,
59
101
  onChange: onChange,
@@ -64,7 +106,6 @@ var EuiRangeInput = function EuiRangeInput(_ref) {
64
106
  exports.EuiRangeInput = EuiRangeInput;
65
107
  EuiRangeInput.propTypes = {
66
108
  autoSize: _propTypes.default.bool,
67
- digitTolerance: _propTypes.default.number.isRequired,
68
109
  /**
69
110
  * @default 'max'
70
111
  */
@@ -7,14 +7,12 @@ exports.useEuiValidatableControl = exports.EuiValidatableControl = void 0;
7
7
  var _react = require("react");
8
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- /*
11
- * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
12
- * or more contributor license agreements. Licensed under the Elastic License
13
- * 2.0 and the Server Side Public License, v 1; you may not use this file except
14
- * in compliance with, at your election, the Elastic License 2.0 or the Server
15
- * Side Public License, v 1.
16
- */
17
-
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ 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."); }
12
+ 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); }
13
+ 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; }
14
+ 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; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
16
  function isMutableRef(ref) {
19
17
  return ref != null && ref.hasOwnProperty('current');
20
18
  }
@@ -27,11 +25,15 @@ function isMutableRef(ref) {
27
25
  var EuiValidatableControl = function EuiValidatableControl(_ref) {
28
26
  var isInvalid = _ref.isInvalid,
29
27
  children = _ref.children;
30
- var control = (0, _react.useRef)(null);
28
+ // Note that this must be state and not a ref to cause a rerender/set invalid state on initial mount
29
+ var _useState = (0, _react.useState)(null),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ control = _useState2[0],
32
+ setControl = _useState2[1];
31
33
  var child = _react.Children.only(children);
32
34
  var childRef = child.ref;
33
35
  var replacedRef = (0, _react.useCallback)(function (element) {
34
- control.current = element;
36
+ setControl(element);
35
37
 
36
38
  // Call the original ref, if any
37
39
  if (typeof childRef === 'function') {
@@ -41,12 +43,12 @@ var EuiValidatableControl = function EuiValidatableControl(_ref) {
41
43
  }
42
44
  }, [childRef]);
43
45
  useSetControlValidity({
44
- controlEl: control.current,
46
+ controlEl: control,
45
47
  isInvalid: isInvalid
46
48
  });
47
49
  return /*#__PURE__*/(0, _react.cloneElement)(child, {
48
50
  ref: replacedRef,
49
- 'aria-invalid': isInvalid
51
+ 'aria-invalid': isInvalid || child.props['aria-invalid']
50
52
  });
51
53
  };
52
54
 
@@ -64,7 +64,12 @@ var processDateOperation = function processDateOperation(value, operator) {
64
64
  };
65
65
  var _termValuesToQuery = function _termValuesToQuery(values, options) {
66
66
  var body = {
67
- query: values.join(' ')
67
+ query: values.map(function (value) {
68
+ if ((0, _predicate.isString)(value) && value.match(/\s/)) {
69
+ return "\"".concat(value, "\"");
70
+ }
71
+ return value;
72
+ }).join(' ')
68
73
  };
69
74
  if (body.query === '') {
70
75
  return;
@@ -140,6 +140,9 @@ var emitTermClause = function emitTermClause(clause, isGroupMember) {
140
140
  match = undefined;
141
141
  }
142
142
  var matchOp = emitMatch(match);
143
+ if ((0, _predicate.isString)(value) && value.match(/\s/)) {
144
+ return "".concat(matchOp, "\"").concat(escapeValue(value), "\"");
145
+ }
143
146
  return "".concat(matchOp).concat(escapeValue(value));
144
147
  };
145
148
  var emitIsClause = function emitIsClause(clause, isGroupMember) {
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+ var _form = require("../form");
5
+ var _suggest = require("./suggest");
6
+ var _react2 = require("@emotion/react");
7
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ /*
9
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
10
+ * or more contributor license agreements. Licensed under the Elastic License
11
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
12
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
13
+ * Side Public License, v 1.
14
+ */
15
+
16
+ /// <reference types="cypress" />
17
+ /// <reference types="cypress-real-events" />
18
+ /// <reference types="../../../cypress/support" />
19
+
20
+ var Suggest = function Suggest() {
21
+ var suggestedItems = [{
22
+ type: {
23
+ iconType: 'accessibility',
24
+ color: 'tint1'
25
+ },
26
+ label: 'Accessibility',
27
+ description: 'A short description'
28
+ }, {
29
+ type: {
30
+ iconType: 'image',
31
+ color: 'tint2'
32
+ },
33
+ label: 'Images',
34
+ description: 'Another short description'
35
+ }, {
36
+ type: {
37
+ iconType: 'lock',
38
+ color: 'tint3'
39
+ },
40
+ label: 'Locks',
41
+ description: 'A third short description'
42
+ }];
43
+ return (0, _react2.jsx)(_form.EuiFormRow, {
44
+ label: "Suggest a topic",
45
+ id: "cy-label-suggest-1"
46
+ }, (0, _react2.jsx)(_suggest.EuiSuggest, {
47
+ "aria-labelledby": "cy-label-suggest-1-label",
48
+ suggestions: suggestedItems
49
+ }));
50
+ };
51
+ describe('EuiSuggest', function () {
52
+ beforeEach(function () {
53
+ cy.realMount((0, _react2.jsx)(Suggest, null));
54
+ });
55
+ describe('Automated accessibility check', function () {
56
+ it('has zero violations when rendered', function () {
57
+ cy.checkAxe();
58
+ });
59
+ });
60
+ describe('Keyboard accessibility', function () {
61
+ it('has zero violations after traversing list items', function () {
62
+ cy.realPress('Tab');
63
+ cy.get('#cy-label-suggest-1').should('have.focus');
64
+ cy.get('ul[role="listbox"]').should('exist');
65
+ cy.realPress('ArrowDown');
66
+ cy.realPress('ArrowUp');
67
+ cy.realPress('ArrowRight');
68
+ cy.realPress('ArrowLeft');
69
+ cy.get('li[role="option"]').first().should('have.attr', 'aria-selected', 'true');
70
+ cy.checkAxe();
71
+ });
72
+ });
73
+ });
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+ var _ = require(".");
5
+ var _react2 = require("@emotion/react");
6
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
+ /*
8
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
9
+ * or more contributor license agreements. Licensed under the Elastic License
10
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
11
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
12
+ * Side Public License, v 1.
13
+ */
14
+
15
+ /// <reference types="cypress" />
16
+ /// <reference types="cypress-real-events" />
17
+ /// <reference types="../../../cypress/support" />
18
+
19
+ var users = [{
20
+ id: '47936',
21
+ firstName: 'Robert',
22
+ lastName: 'Stein',
23
+ github: 'steiner_rob',
24
+ location: {
25
+ city: 'Los Angeles',
26
+ state: 'CA'
27
+ }
28
+ }, {
29
+ id: '54736',
30
+ firstName: 'Martina',
31
+ lastName: 'Conlon',
32
+ github: 'martina_zen',
33
+ location: {
34
+ city: 'Boston',
35
+ state: 'MA'
36
+ }
37
+ }, {
38
+ id: '40193',
39
+ firstName: 'Alyce',
40
+ lastName: 'Benning',
41
+ github: 'alyce_benning',
42
+ location: {
43
+ city: 'Atlanta',
44
+ state: 'GA'
45
+ }
46
+ }];
47
+ var userRows = users.map(function (user) {
48
+ var id = user.id,
49
+ firstName = user.firstName,
50
+ lastName = user.lastName,
51
+ github = user.github,
52
+ _user$location = user.location,
53
+ city = _user$location.city,
54
+ state = _user$location.state;
55
+ return (0, _react2.jsx)(_.EuiTableRow, {
56
+ key: id
57
+ }, (0, _react2.jsx)(_.EuiTableRowCell, null, "".concat(firstName, " ").concat(lastName)), (0, _react2.jsx)(_.EuiTableRowCell, null, github), (0, _react2.jsx)(_.EuiTableRowCell, null, "".concat(city, ", ").concat(state)));
58
+ });
59
+ var customColumns = ['Name', 'Github', 'Location'];
60
+ var columnHeaders = customColumns.map(function (column, i) {
61
+ return (0, _react2.jsx)(_.EuiTableHeaderCell, {
62
+ key: i
63
+ }, column);
64
+ });
65
+ var CustomTable = function CustomTable() {
66
+ return (0, _react2.jsx)(_.EuiTable, null, (0, _react2.jsx)(_.EuiTableHeader, null, columnHeaders), (0, _react2.jsx)(_.EuiTableBody, null, userRows));
67
+ };
68
+ describe('EuiTable', function () {
69
+ beforeEach(function () {
70
+ cy.viewport(1024, 768); // medium breakpoint
71
+ cy.realMount((0, _react2.jsx)(CustomTable, null));
72
+ });
73
+ describe('Automated accessibility check', function () {
74
+ it('has zero violations on render', function () {
75
+ cy.checkAxe();
76
+ });
77
+ });
78
+ });
@@ -0,0 +1,194 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
+ /*
6
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
+ * or more contributor license agreements. Licensed under the Elastic License
8
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
9
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
10
+ * Side Public License, v 1.
11
+ */
12
+
13
+ /// <reference types="cypress" />
14
+ /// <reference types="cypress-real-events" />
15
+ /// <reference types="../../../cypress/support" />
16
+
17
+ import React, { useState } from 'react';
18
+ import { EuiBasicTable } from './basic_table';
19
+ import { EuiButtonIcon } from '../button';
20
+ import { EuiHealth } from '../health';
21
+ import { EuiLink } from '../link';
22
+ import { EuiScreenReaderOnly } from '../accessibility';
23
+ import { formatDate } from '../../services';
24
+ import { faker } from '@faker-js/faker';
25
+ import { jsx as ___EmotionJSX } from "@emotion/react";
26
+ var users = [];
27
+ for (var i = 0; i < 20; i++) {
28
+ users.push({
29
+ id: i + 1,
30
+ firstName: faker.name.firstName(),
31
+ lastName: faker.name.lastName(),
32
+ github: faker.internet.userName(),
33
+ dateOfBirth: faker.date.past(),
34
+ online: faker.datatype.boolean(),
35
+ location: {
36
+ city: faker.address.city(),
37
+ country: faker.address.country()
38
+ }
39
+ });
40
+ }
41
+ var columns = [{
42
+ field: 'firstName',
43
+ name: 'First Name',
44
+ sortable: true,
45
+ truncateText: true,
46
+ mobileOptions: {
47
+ render: function render(user) {
48
+ return ___EmotionJSX("span", null, user.firstName, " ", user.lastName);
49
+ },
50
+ header: false,
51
+ truncateText: false,
52
+ enlarge: true,
53
+ width: '100%'
54
+ }
55
+ }, {
56
+ field: 'lastName',
57
+ name: 'Last Name',
58
+ truncateText: true,
59
+ mobileOptions: {
60
+ show: false
61
+ }
62
+ }, {
63
+ field: 'github',
64
+ name: 'Github',
65
+ render: function render(username) {
66
+ return ___EmotionJSX(EuiLink, {
67
+ href: "#",
68
+ target: "_blank"
69
+ }, username);
70
+ }
71
+ }, {
72
+ field: 'dateOfBirth',
73
+ name: 'Date of Birth',
74
+ dataType: 'date',
75
+ render: function render(dateOfBirth) {
76
+ return formatDate(dateOfBirth, 'dobLong');
77
+ },
78
+ sortable: true
79
+ }, {
80
+ field: 'location',
81
+ name: 'Location',
82
+ truncateText: true,
83
+ textOnly: true,
84
+ render: function render(location) {
85
+ return "".concat(location.city, ", ").concat(location.country);
86
+ }
87
+ }, {
88
+ field: 'online',
89
+ name: 'Online',
90
+ dataType: 'boolean',
91
+ render: function render(online) {
92
+ var color = online ? 'success' : 'danger';
93
+ var label = online ? 'Online' : 'Offline';
94
+ return ___EmotionJSX(EuiHealth, {
95
+ color: color
96
+ }, label);
97
+ },
98
+ sortable: true,
99
+ mobileOptions: {
100
+ show: false
101
+ }
102
+ }];
103
+ describe('EuiTable', function () {
104
+ var BasicTable = function BasicTable() {
105
+ return ___EmotionJSX(EuiBasicTable, {
106
+ tableCaption: "Demo of EuiBasicTable",
107
+ columns: columns,
108
+ items: users,
109
+ "data-test-subj": "cy-basic-table"
110
+ });
111
+ };
112
+ describe('Basic table', function () {
113
+ describe('Automated accessibility check', function () {
114
+ it('has zero violations on render', function () {
115
+ cy.viewport(1024, 768); // medium breakpoint
116
+ cy.realMount(___EmotionJSX(BasicTable, null));
117
+ cy.get('[data-test-subj="cy-basic-table"]').should('exist');
118
+ cy.checkAxe();
119
+ });
120
+ });
121
+ });
122
+ describe('Mobile basic table', function () {
123
+ describe('Automated accessibility check', function () {
124
+ it('has zero violations on render', function () {
125
+ cy.viewport(375, 667); // small breakpoint
126
+ cy.realMount(___EmotionJSX(BasicTable, null));
127
+ cy.get('[data-test-subj="cy-basic-table"]').should('exist');
128
+ cy.checkAxe();
129
+ });
130
+ });
131
+ });
132
+ describe('Expandable rows', function () {
133
+ var ExpandableRowTable = function ExpandableRowTable() {
134
+ var _useState = useState({}),
135
+ _useState2 = _slicedToArray(_useState, 2),
136
+ itemIdToExpandedRowMap = _useState2[0],
137
+ setItemIdToExpandedRowMap = _useState2[1];
138
+ var toggleDetails = function toggleDetails(user) {
139
+ var itemIdToExpandedRowMapValues = _objectSpread({}, itemIdToExpandedRowMap);
140
+ if (itemIdToExpandedRowMapValues[user.id]) {
141
+ delete itemIdToExpandedRowMapValues[user.id];
142
+ } else {
143
+ itemIdToExpandedRowMapValues[user.id] = ___EmotionJSX("div", null, ___EmotionJSX("p", null, "Location: ".concat(user.location.city)), ___EmotionJSX("p", null, "This person is online."));
144
+ }
145
+ setItemIdToExpandedRowMap(itemIdToExpandedRowMapValues);
146
+ };
147
+ var columnsWithExpandingRowToggle = [].concat(columns, [{
148
+ align: 'right',
149
+ width: '40px',
150
+ isExpander: true,
151
+ name: ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("span", null, "Expand rows")),
152
+ render: function render(user) {
153
+ var itemIdToExpandedRowMapValues = _objectSpread({}, itemIdToExpandedRowMap);
154
+ return ___EmotionJSX(EuiButtonIcon, {
155
+ id: user.id.toString(),
156
+ onClick: function onClick() {
157
+ return toggleDetails(user);
158
+ },
159
+ "aria-label": itemIdToExpandedRowMapValues[user.id] ? 'Collapse' : 'Expand',
160
+ iconType: itemIdToExpandedRowMapValues[user.id] ? 'arrowDown' : 'arrowRight'
161
+ });
162
+ }
163
+ }]);
164
+ return ___EmotionJSX(EuiBasicTable, {
165
+ tableCaption: "Demo of EuiBasicTable with expanding rows",
166
+ itemIdToExpandedRowMap: itemIdToExpandedRowMap,
167
+ isExpandable: true,
168
+ columns: columnsWithExpandingRowToggle,
169
+ items: users,
170
+ itemId: "id",
171
+ "data-test-subj": "cy-expandable-row-table"
172
+ });
173
+ };
174
+ beforeEach(function () {
175
+ cy.viewport(1024, 768); // medium breakpoint
176
+ cy.realMount(___EmotionJSX(ExpandableRowTable, null));
177
+ cy.get('[data-test-subj="cy-expandable-row-table"]').should('exist');
178
+ });
179
+ describe('Automated accessibility check', function () {
180
+ it('has zero violations on render', function () {
181
+ cy.checkAxe();
182
+ });
183
+ });
184
+ describe('Keyboard accessibility', function () {
185
+ it('has zero violations after expanding a row', function () {
186
+ cy.repeatRealPress('Tab');
187
+ cy.get('button#1').should('have.focus');
188
+ cy.realPress('Enter');
189
+ cy.get('tr.euiTableRow-isExpandedRow div.euiTableCellContent').should('exist');
190
+ cy.checkAxe();
191
+ });
192
+ });
193
+ });
194
+ });
@@ -12,7 +12,7 @@
12
12
 
13
13
  import React from 'react';
14
14
  import { faker } from '@faker-js/faker';
15
- import { EuiInMemoryTable } from './index';
15
+ import { EuiInMemoryTable } from '.';
16
16
  import { EuiHealth } from '../health';
17
17
  import { EuiLink } from '../link';
18
18
  import { formatDate } from '../../services';
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["adjustDateOnChange", "calendarClassName", "className", "customInput", "dateFormat", "dayClassName", "disabled", "excludeDates", "filterDate", "fullWidth", "iconType", "injectTimes", "inline", "inputRef", "isInvalid", "isLoading", "locale", "maxDate", "maxTime", "minDate", "minTime", "onChange", "onClear", "openToDate", "placeholder", "popperClassName", "popoverPlacement", "selected", "shadow", "shouldCloseOnSelect", "showIcon", "showTimeSelect", "showTimeSelectOnly", "timeFormat", "utcOffset"];
4
+ var _excluded = ["adjustDateOnChange", "calendarClassName", "className", "controlOnly", "customInput", "dateFormat", "dayClassName", "disabled", "excludeDates", "filterDate", "fullWidth", "iconType", "injectTimes", "inline", "inputRef", "isInvalid", "isLoading", "locale", "maxDate", "maxTime", "minDate", "minTime", "onChange", "onClear", "openToDate", "placeholder", "popperClassName", "popoverPlacement", "selected", "shadow", "shouldCloseOnSelect", "showIcon", "showTimeSelect", "showTimeSelectOnly", "timeFormat", "utcOffset"];
5
5
  /*
6
6
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
7
7
  * or more contributor license agreements. Licensed under the Elastic License
@@ -54,6 +54,7 @@ export var EuiDatePicker = function EuiDatePicker(_ref) {
54
54
  adjustDateOnChange = _ref$adjustDateOnChan === void 0 ? true : _ref$adjustDateOnChan,
55
55
  calendarClassName = _ref.calendarClassName,
56
56
  className = _ref.className,
57
+ controlOnly = _ref.controlOnly,
57
58
  customInput = _ref.customInput,
58
59
  _ref$dateFormat = _ref.dateFormat,
59
60
  dateFormat = _ref$dateFormat === void 0 ? euiDatePickerDefaultDateFormat : _ref$dateFormat,
@@ -99,7 +100,7 @@ export var EuiDatePicker = function EuiDatePicker(_ref) {
99
100
  'euiDatePicker--shadow': shadow,
100
101
  'euiDatePicker--inline': inline
101
102
  });
102
- var numIconsClass = getFormControlClassNameForIconCount({
103
+ var numIconsClass = controlOnly ? false : getFormControlClassNameForIconCount({
103
104
  isInvalid: isInvalid,
104
105
  isLoading: isLoading
105
106
  });
@@ -140,17 +141,7 @@ export var EuiDatePicker = function EuiDatePicker(_ref) {
140
141
  controlEl: inputValidityRef
141
142
  });
142
143
  var inputRefs = useCombinedRefs([inputRef, setInputValidityRef]);
143
- return ___EmotionJSX("span", {
144
- className: classes
145
- }, ___EmotionJSX(EuiFormControlLayout, {
146
- icon: optionalIcon,
147
- fullWidth: fullWidth,
148
- clear: selected && onClear ? {
149
- onClick: onClear
150
- } : undefined,
151
- isLoading: isLoading,
152
- isInvalid: isInvalid
153
- }, ___EmotionJSX(EuiI18nConsumer, null, function (_ref2) {
144
+ var control = ___EmotionJSX(EuiI18nConsumer, null, function (_ref2) {
154
145
  var contextLocale = _ref2.locale;
155
146
  return ___EmotionJSX(ReactDatePicker, _extends({
156
147
  adjustDateOnChange: adjustDateOnChange,
@@ -186,5 +177,17 @@ export var EuiDatePicker = function EuiDatePicker(_ref) {
186
177
  accessibleMode: true,
187
178
  popperPlacement: popoverPlacement
188
179
  }, rest));
189
- })));
180
+ });
181
+ if (controlOnly) return control;
182
+ return ___EmotionJSX("span", {
183
+ className: classes
184
+ }, ___EmotionJSX(EuiFormControlLayout, {
185
+ icon: optionalIcon,
186
+ fullWidth: fullWidth,
187
+ clear: selected && onClear ? {
188
+ onClick: onClear
189
+ } : undefined,
190
+ isLoading: isLoading,
191
+ isInvalid: isInvalid
192
+ }, control));
190
193
  };