@elastic/eui 77.1.0 → 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 (138) 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/index.js +0 -1
  21. package/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  22. package/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
  23. package/es/components/suggest/suggest.a11y.js +70 -0
  24. package/es/components/table/table.a11y.js +75 -0
  25. package/eui.d.ts +55 -173
  26. package/i18ntokens.json +26 -44
  27. package/lib/components/basic_table/basic_table.a11y.js +194 -0
  28. package/lib/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +2 -2
  29. package/lib/components/date_picker/date_picker.js +23 -15
  30. package/lib/components/date_picker/date_picker_range.js +35 -41
  31. package/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  32. package/lib/components/form/field_number/field_number.js +42 -8
  33. package/lib/components/form/field_text/field_text.js +1 -1
  34. package/lib/components/form/form_control_layout/form_control_layout.js +67 -35
  35. package/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  36. package/lib/components/form/form_control_layout/form_control_layout_icons.js +11 -19
  37. package/lib/components/form/range/dual_range.js +2 -4
  38. package/lib/components/form/range/range.js +0 -2
  39. package/lib/components/form/range/range_input.js +52 -11
  40. package/lib/components/form/validatable_control/validatable_control.js +14 -12
  41. package/lib/components/index.js +0 -11
  42. package/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  43. package/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
  44. package/lib/components/suggest/suggest.a11y.js +73 -0
  45. package/lib/components/table/table.a11y.js +78 -0
  46. package/optimize/es/components/basic_table/basic_table.a11y.js +194 -0
  47. package/optimize/es/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +1 -1
  48. package/optimize/es/components/date_picker/date_picker.js +17 -14
  49. package/optimize/es/components/date_picker/date_picker_range.js +20 -14
  50. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  51. package/optimize/es/components/form/field_number/field_number.js +34 -8
  52. package/optimize/es/components/form/field_text/field_text.js +1 -1
  53. package/optimize/es/components/form/form_control_layout/form_control_layout.js +67 -30
  54. package/optimize/es/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  55. package/optimize/es/components/form/form_control_layout/form_control_layout_icons.js +10 -20
  56. package/optimize/es/components/form/range/dual_range.js +2 -4
  57. package/optimize/es/components/form/range/range.js +0 -2
  58. package/optimize/es/components/form/range/range_input.js +49 -12
  59. package/optimize/es/components/form/validatable_control/validatable_control.js +10 -5
  60. package/optimize/es/components/index.js +0 -1
  61. package/optimize/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  62. package/optimize/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
  63. package/optimize/es/components/suggest/suggest.a11y.js +70 -0
  64. package/optimize/es/components/table/table.a11y.js +75 -0
  65. package/optimize/lib/components/basic_table/basic_table.a11y.js +188 -0
  66. package/{test-env/components/basic_table/table.a11y.js → optimize/lib/components/basic_table/in_memory_table.a11y.js} +2 -2
  67. package/optimize/lib/components/date_picker/date_picker.js +17 -14
  68. package/optimize/lib/components/date_picker/date_picker_range.js +19 -13
  69. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  70. package/optimize/lib/components/form/field_number/field_number.js +37 -8
  71. package/optimize/lib/components/form/field_text/field_text.js +1 -1
  72. package/optimize/lib/components/form/form_control_layout/form_control_layout.js +67 -35
  73. package/optimize/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  74. package/optimize/lib/components/form/form_control_layout/form_control_layout_icons.js +9 -19
  75. package/optimize/lib/components/form/range/dual_range.js +2 -4
  76. package/optimize/lib/components/form/range/range.js +0 -2
  77. package/optimize/lib/components/form/range/range_input.js +47 -10
  78. package/optimize/lib/components/form/validatable_control/validatable_control.js +10 -4
  79. package/optimize/lib/components/index.js +0 -11
  80. package/optimize/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  81. package/optimize/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
  82. package/optimize/lib/components/suggest/suggest.a11y.js +73 -0
  83. package/optimize/lib/components/table/table.a11y.js +78 -0
  84. package/package.json +1 -1
  85. package/src/components/date_picker/_date_picker_range.scss +0 -60
  86. package/src/components/date_picker/super_date_picker/_super_date_picker.scss +23 -11
  87. package/src/components/date_picker/super_date_picker/_variables.scss +3 -0
  88. package/src/components/date_picker/super_date_picker/date_popover/_date_popover_button.scss +5 -7
  89. package/src/components/form/form_control_layout/_form_control_layout.scss +2 -2
  90. package/src/components/form/form_control_layout/_form_control_layout_delimited.scss +12 -36
  91. package/src/components/form/form_control_layout/_form_control_layout_icons.scss +27 -6
  92. package/src/themes/amsterdam/overrides/_date_picker.scss +0 -14
  93. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  94. package/test-env/components/basic_table/basic_table.a11y.js +188 -0
  95. package/{optimize/lib/components/basic_table/table.a11y.js → test-env/components/basic_table/in_memory_table.a11y.js} +2 -2
  96. package/test-env/components/date_picker/date_picker.js +23 -15
  97. package/test-env/components/date_picker/date_picker_range.js +35 -41
  98. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  99. package/test-env/components/form/field_number/field_number.js +37 -8
  100. package/test-env/components/form/field_text/field_text.js +1 -1
  101. package/test-env/components/form/form_control_layout/form_control_layout.js +68 -35
  102. package/test-env/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  103. package/test-env/components/form/form_control_layout/form_control_layout_icons.js +11 -19
  104. package/test-env/components/form/range/dual_range.js +2 -4
  105. package/test-env/components/form/range/range.js +0 -2
  106. package/test-env/components/form/range/range_input.js +47 -11
  107. package/test-env/components/form/validatable_control/validatable_control.js +9 -4
  108. package/test-env/components/index.js +0 -11
  109. package/test-env/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  110. package/test-env/components/search_bar/query/ast_to_es_query_string.js +3 -0
  111. package/test-env/components/suggest/suggest.a11y.js +73 -0
  112. package/test-env/components/table/table.a11y.js +78 -0
  113. package/es/components/inline_edit/index.js +0 -10
  114. package/es/components/inline_edit/inline_edit.styles.js +0 -15
  115. package/es/components/inline_edit/inline_edit_form.js +0 -190
  116. package/es/components/inline_edit/inline_edit_text.js +0 -97
  117. package/es/components/inline_edit/inline_edit_title.js +0 -105
  118. package/lib/components/inline_edit/index.js +0 -19
  119. package/lib/components/inline_edit/inline_edit.styles.js +0 -22
  120. package/lib/components/inline_edit/inline_edit_form.js +0 -193
  121. package/lib/components/inline_edit/inline_edit_text.js +0 -97
  122. package/lib/components/inline_edit/inline_edit_title.js +0 -106
  123. package/optimize/es/components/inline_edit/index.js +0 -10
  124. package/optimize/es/components/inline_edit/inline_edit.styles.js +0 -15
  125. package/optimize/es/components/inline_edit/inline_edit_form.js +0 -133
  126. package/optimize/es/components/inline_edit/inline_edit_text.js +0 -52
  127. package/optimize/es/components/inline_edit/inline_edit_title.js +0 -56
  128. package/optimize/lib/components/inline_edit/index.js +0 -19
  129. package/optimize/lib/components/inline_edit/inline_edit.styles.js +0 -22
  130. package/optimize/lib/components/inline_edit/inline_edit_form.js +0 -144
  131. package/optimize/lib/components/inline_edit/inline_edit_text.js +0 -52
  132. package/optimize/lib/components/inline_edit/inline_edit_title.js +0 -57
  133. package/src/themes/amsterdam/overrides/_date_popover_button.scss +0 -14
  134. package/test-env/components/inline_edit/index.js +0 -19
  135. package/test-env/components/inline_edit/inline_edit.styles.js +0 -22
  136. package/test-env/components/inline_edit/inline_edit_form.js +0 -196
  137. package/test-env/components/inline_edit/inline_edit_text.js +0 -96
  138. package/test-env/components/inline_edit/inline_edit_title.js +0 -105
@@ -393,7 +393,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
393
393
  var min = minProps;
394
394
  var max = maxProps;
395
395
  var id = this.state.id;
396
- var digitTolerance = Math.max(String(min).length, String(max).length);
397
396
  var showInputOnly = showInput === 'inputWithPopover';
398
397
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
399
398
  var rangeStyles = (0, _range.euiRangeStyles)(theme);
@@ -404,7 +403,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
404
403
  "aria-label": this.props['aria-label']
405
404
  }, minInputProps, {
406
405
  // Non-overridable props
407
- digitTolerance: digitTolerance,
408
406
  side: "min",
409
407
  min: min,
410
408
  max: Number(this.upperValue),
@@ -433,7 +431,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
433
431
  "aria-label": this.props['aria-label']
434
432
  }, maxInputProps, {
435
433
  // Non-overridable props
436
- digitTolerance: digitTolerance,
437
434
  side: "max",
438
435
  min: Number(this.lowerValue),
439
436
  max: max,
@@ -585,7 +582,8 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
585
582
  readOnly: readOnly,
586
583
  append: append,
587
584
  prepend: prepend,
588
- isLoading: isLoading
585
+ isLoading: isLoading,
586
+ isInvalid: isInvalid
589
587
  }),
590
588
  fullWidth: fullWidth,
591
589
  isOpen: this.state.isPopoverOpen,
@@ -134,14 +134,12 @@ var EuiRangeClass = /*#__PURE__*/function (_Component) {
134
134
  theme = _this$props.theme,
135
135
  rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
136
136
  var id = this.state.id;
137
- var digitTolerance = Math.max(String(min).length, String(max).length);
138
137
  var showInputOnly = showInput === 'inputWithPopover';
139
138
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
140
139
  var theInput = !!showInput ? (0, _react2.jsx)(_range_input.EuiRangeInput, (0, _extends2.default)({
141
140
  id: id,
142
141
  min: min,
143
142
  max: max,
144
- digitTolerance: digitTolerance,
145
143
  step: step,
146
144
  value: value,
147
145
  readOnly: readOnly,
@@ -7,15 +7,17 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.EuiRangeInput = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
11
12
  var _react = _interopRequireWildcard(require("react"));
12
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
14
  var _services = require("../../../services");
14
15
  var _global_styling = require("../../../global_styling");
16
+ var _form = require("../form.styles");
15
17
  var _field_number = require("../field_number");
16
18
  var _range_input = require("./range_input.styles");
17
19
  var _react2 = require("@emotion/react");
18
- var _excluded = ["min", "max", "step", "value", "disabled", "compressed", "onChange", "name", "side", "digitTolerance", "fullWidth", "autoSize"];
20
+ var _excluded = ["min", "max", "step", "value", "inputRef", "isInvalid", "disabled", "compressed", "onChange", "name", "side", "fullWidth", "autoSize"];
19
21
  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); }
20
22
  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; }
21
23
  var EuiRangeInput = function EuiRangeInput(_ref) {
@@ -23,28 +25,61 @@ var EuiRangeInput = function EuiRangeInput(_ref) {
23
25
  max = _ref.max,
24
26
  step = _ref.step,
25
27
  value = _ref.value,
28
+ inputRef = _ref.inputRef,
29
+ isInvalid = _ref.isInvalid,
26
30
  disabled = _ref.disabled,
27
31
  compressed = _ref.compressed,
28
32
  onChange = _ref.onChange,
29
33
  name = _ref.name,
30
34
  _ref$side = _ref.side,
31
35
  side = _ref$side === void 0 ? 'max' : _ref$side,
32
- digitTolerance = _ref.digitTolerance,
33
36
  fullWidth = _ref.fullWidth,
34
37
  _ref$autoSize = _ref.autoSize,
35
38
  autoSize = _ref$autoSize === void 0 ? true : _ref$autoSize,
36
39
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
37
- // Chrome will properly size the input based on the max value, but FF does not.
38
- // Calculate the width of the input based on highest number of characters.
39
- // Add 2 to accommodate for input stepper
40
- var widthStyle = (0, _react.useMemo)(function () {
41
- return autoSize ? (0, _global_styling.logicalStyles)({
42
- width: "".concat(digitTolerance / 1.25 + 2, "em")
43
- }) : {};
44
- }, [autoSize, digitTolerance]);
45
40
  var euiTheme = (0, _services.useEuiTheme)();
46
41
  var styles = (0, _range_input.euiRangeInputStyles)(euiTheme);
47
42
  var cssStyles = [styles.euiRangeInput];
43
+
44
+ // Determine whether an invalid icon is showing, which can come from
45
+ // the underlying EuiFieldNumber's native :invalid state
46
+ var _useState = (0, _react.useState)(isInvalid),
47
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
48
+ hasInvalidIcon = _useState2[0],
49
+ setHasInvalidIcon = _useState2[1];
50
+ var validityRef = (0, _react.useRef)(null);
51
+ var setRefs = (0, _services.useCombinedRefs)([validityRef, inputRef]);
52
+ (0, _react.useEffect)(function () {
53
+ var _validityRef$current;
54
+ var isNativelyInvalid = !((_validityRef$current = validityRef.current) !== null && _validityRef$current !== void 0 && _validityRef$current.validity.valid);
55
+ setHasInvalidIcon(isNativelyInvalid || isInvalid);
56
+ }, [value, isInvalid]);
57
+
58
+ // Calculate the auto size width of the input
59
+ var widthStyle = (0, _react.useMemo)(function () {
60
+ if (!autoSize) return undefined;
61
+
62
+ // Calculate the number of characters to show (dynamic based on user input)
63
+ // Uses the min/max char length as a max, then add an extra UX buffer of 1
64
+ var maxChars = Math.max(String(min).length, String(max).length) + 1;
65
+ var inputCharWidth = Math.min(String(value).length, maxChars);
66
+
67
+ // Calculate the form padding based on `compressed` state
68
+ var _euiFormVariables = (0, _form.euiFormVariables)(euiTheme),
69
+ controlPadding = _euiFormVariables.controlPadding,
70
+ controlCompressedPadding = _euiFormVariables.controlCompressedPadding;
71
+ var inputPadding = compressed ? controlCompressedPadding : controlPadding;
72
+
73
+ // Calculate the invalid icon (if being displayed), also based on `compressed` state
74
+ var invalidIconWidth = hasInvalidIcon ? euiTheme.euiTheme.base * (compressed ? 1.125 : 1.375) // TODO: DRY this out once EuiFormControlLayoutIcons is converted to Emotion
75
+ : 0;
76
+
77
+ // Guesstimate a width for the stepper. Note that it's a little wider in FF than it is in Chrome
78
+ var stepperWidth = 2;
79
+ return (0, _global_styling.logicalStyles)({
80
+ width: "calc(".concat(inputPadding, " + ").concat(inputCharWidth, "ch + ").concat(stepperWidth, "em + ").concat(invalidIconWidth, "px)")
81
+ });
82
+ }, [autoSize, euiTheme, compressed, hasInvalidIcon, min, max, value]);
48
83
  return (0, _react2.jsx)(_field_number.EuiFieldNumber, (0, _extends2.default)({
49
84
  name: name,
50
85
  className: "euiRangeInput euiRangeInput--".concat(side),
@@ -53,6 +88,8 @@ var EuiRangeInput = function EuiRangeInput(_ref) {
53
88
  max: Number(max),
54
89
  step: step,
55
90
  value: value === '' ? '' : Number(value),
91
+ inputRef: setRefs,
92
+ isInvalid: isInvalid,
56
93
  disabled: disabled,
57
94
  compressed: compressed,
58
95
  onChange: onChange,
@@ -63,7 +100,6 @@ var EuiRangeInput = function EuiRangeInput(_ref) {
63
100
  exports.EuiRangeInput = EuiRangeInput;
64
101
  EuiRangeInput.propTypes = {
65
102
  autoSize: _propTypes.default.bool,
66
- digitTolerance: _propTypes.default.number.isRequired,
67
103
  /**
68
104
  * @default 'max'
69
105
  */
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.useEuiValidatableControl = exports.EuiValidatableControl = void 0;
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
9
  var _react = require("react");
9
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
11
  /*
@@ -27,11 +28,15 @@ function isMutableRef(ref) {
27
28
  var EuiValidatableControl = function EuiValidatableControl(_ref) {
28
29
  var isInvalid = _ref.isInvalid,
29
30
  children = _ref.children;
30
- var control = (0, _react.useRef)(null);
31
+ // Note that this must be state and not a ref to cause a rerender/set invalid state on initial mount
32
+ var _useState = (0, _react.useState)(null),
33
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
34
+ control = _useState2[0],
35
+ setControl = _useState2[1];
31
36
  var child = _react.Children.only(children);
32
37
  var childRef = child.ref;
33
38
  var replacedRef = (0, _react.useCallback)(function (element) {
34
- control.current = element;
39
+ setControl(element);
35
40
 
36
41
  // Call the original ref, if any
37
42
  if (typeof childRef === 'function') {
@@ -41,12 +46,12 @@ var EuiValidatableControl = function EuiValidatableControl(_ref) {
41
46
  }
42
47
  }, [childRef]);
43
48
  useSetControlValidity({
44
- controlEl: control.current,
49
+ controlEl: control,
45
50
  isInvalid: isInvalid
46
51
  });
47
52
  return /*#__PURE__*/(0, _react.cloneElement)(child, {
48
53
  ref: replacedRef,
49
- 'aria-invalid': isInvalid
54
+ 'aria-invalid': isInvalid || child.props['aria-invalid']
50
55
  });
51
56
  };
52
57
 
@@ -476,17 +476,6 @@ Object.keys(_inner_text).forEach(function (key) {
476
476
  }
477
477
  });
478
478
  });
479
- var _inline_edit = require("./inline_edit");
480
- Object.keys(_inline_edit).forEach(function (key) {
481
- if (key === "default" || key === "__esModule") return;
482
- if (key in exports && exports[key] === _inline_edit[key]) return;
483
- Object.defineProperty(exports, key, {
484
- enumerable: true,
485
- get: function get() {
486
- return _inline_edit[key];
487
- }
488
- });
489
- });
490
479
  var _i18n = require("./i18n");
491
480
  Object.keys(_i18n).forEach(function (key) {
492
481
  if (key === "default" || key === "__esModule") return;
@@ -59,7 +59,12 @@ var processDateOperation = function processDateOperation(value, operator) {
59
59
  };
60
60
  var _termValuesToQuery = function _termValuesToQuery(values, options) {
61
61
  var body = {
62
- query: values.join(' ')
62
+ query: values.map(function (value) {
63
+ if ((0, _predicate.isString)(value) && value.match(/\s/)) {
64
+ return "\"".concat(value, "\"");
65
+ }
66
+ return value;
67
+ }).join(' ')
63
68
  };
64
69
  if (body.query === '') {
65
70
  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 _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _form = require("../form");
6
+ var _suggest = require("./suggest");
7
+ var _react2 = require("@emotion/react");
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 _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _react = _interopRequireDefault(require("react"));
5
+ var _ = require(".");
6
+ var _react2 = require("@emotion/react");
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
+ });
@@ -1,10 +0,0 @@
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
- export { EuiInlineEditText } from './inline_edit_text';
10
- export { EuiInlineEditTitle } from './inline_edit_title';
@@ -1,15 +0,0 @@
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
- import { css } from '@emotion/react';
10
- export var euiInlineEditStyles = function euiInlineEditStyles(_ref) {
11
- var euiTheme = _ref.euiTheme;
12
- return {
13
- euiInlineEdit: /*#__PURE__*/css("color:", euiTheme.colors.primaryText, ";;label:euiInlineEdit;")
14
- };
15
- };
@@ -1,190 +0,0 @@
1
- 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); }
2
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
- 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."); }
4
- 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); }
5
- 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; }
6
- 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; } }
7
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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
- import React, { useState } from 'react';
17
- import PropTypes from "prop-types";
18
- import classNames from 'classnames';
19
- import { EuiFormRow, EuiFieldText, EuiForm } from '../form';
20
- import { EuiButtonIcon, EuiButtonEmpty } from '../button';
21
- import { EuiFlexGroup, EuiFlexItem } from '../flex';
22
- import { useEuiI18n } from '../i18n';
23
- import { useGeneratedHtmlId } from '../../services/accessibility';
24
-
25
- // Props shared between the internal form component as well as consumer-facing components
26
- import { jsx as ___EmotionJSX } from "@emotion/react";
27
- export var SMALL_SIZE_FORM = {
28
- iconSize: 's',
29
- compressed: true,
30
- buttonSize: 's'
31
- };
32
- export var MEDIUM_SIZE_FORM = {
33
- iconSize: 'm',
34
- compressed: false,
35
- buttonSize: 'm'
36
- };
37
- export var EuiInlineEditForm = function EuiInlineEditForm(_ref) {
38
- var className = _ref.className,
39
- children = _ref.children,
40
- sizes = _ref.sizes,
41
- defaultValue = _ref.defaultValue,
42
- onConfirm = _ref.onConfirm,
43
- inputAriaLabel = _ref.inputAriaLabel,
44
- saveButtonAriaLabel = _ref.saveButtonAriaLabel,
45
- cancelButtonAriaLabel = _ref.cancelButtonAriaLabel,
46
- startWithEditOpen = _ref.startWithEditOpen,
47
- readModeProps = _ref.readModeProps,
48
- editModeProps = _ref.editModeProps;
49
- var classes = classNames('euiInlineEdit', className);
50
-
51
- // Styles to come later! (Styling editMode text to match the size of its readMode counterpart)
52
- /*const theme = useEuiTheme();
53
- const styles = euiInlineEditStyles(theme);
54
- const cssStyles = [styles.euiInlineEdit];*/
55
-
56
- var defaultSaveButtonAriaLabel = useEuiI18n('euiInlineEditForm.saveButtonAriaLabel', 'Save edit');
57
- var defaultCancelButtonAriaLabel = useEuiI18n('euiInlineEditForm.cancelButtonAriaLabel', 'Cancel edit');
58
- var _useState = useState(false || startWithEditOpen),
59
- _useState2 = _slicedToArray(_useState, 2),
60
- isEditing = _useState2[0],
61
- setIsEditing = _useState2[1];
62
- var inlineEditInputId = useGeneratedHtmlId({
63
- prefix: '__inlineEditInput'
64
- });
65
- var _useState3 = useState(defaultValue),
66
- _useState4 = _slicedToArray(_useState3, 2),
67
- editModeValue = _useState4[0],
68
- setEditModeValue = _useState4[1];
69
- var _useState5 = useState(defaultValue),
70
- _useState6 = _slicedToArray(_useState5, 2),
71
- readModeValue = _useState6[0],
72
- setReadModeValue = _useState6[1];
73
- var cancelInlineEdit = function cancelInlineEdit() {
74
- setEditModeValue(readModeValue);
75
- setIsEditing(!isEditing);
76
- };
77
- var saveInlineEditValue = function saveInlineEditValue() {
78
- if (editModeValue && onConfirm && !onConfirm()) {
79
- // If there is text, an onConfirm method is present, and it has returned false, cancel the action
80
- return;
81
- } else if (editModeValue) {
82
- setReadModeValue(editModeValue);
83
- setIsEditing(!isEditing);
84
- } else {
85
- // If there's no text, cancel the action, reset the input text, and return to readMode
86
- cancelInlineEdit();
87
- }
88
- };
89
- var editModeForm = ___EmotionJSX(EuiForm, {
90
- fullWidth: true
91
- }, ___EmotionJSX(EuiFlexGroup, {
92
- gutterSize: "s"
93
- }, ___EmotionJSX(EuiFlexItem, null, ___EmotionJSX(EuiFieldText, _extends({
94
- id: inlineEditInputId,
95
- value: editModeValue,
96
- onChange: function onChange(e) {
97
- setEditModeValue(e.target.value);
98
- },
99
- "aria-label": inputAriaLabel,
100
- autoFocus: true,
101
- compressed: sizes.compressed
102
- }, editModeProps))), ___EmotionJSX(EuiFlexItem, {
103
- grow: false,
104
- className: classes
105
- }, ___EmotionJSX(EuiFormRow, null, ___EmotionJSX(EuiButtonIcon, {
106
- iconType: "check",
107
- "aria-label": saveButtonAriaLabel || defaultSaveButtonAriaLabel,
108
- onClick: saveInlineEditValue,
109
- color: "success",
110
- display: "base",
111
- size: sizes.buttonSize,
112
- iconSize: sizes.iconSize
113
- }))), ___EmotionJSX(EuiFlexItem, {
114
- grow: false
115
- }, ___EmotionJSX(EuiFormRow, null, ___EmotionJSX(EuiButtonIcon, {
116
- iconType: "cross",
117
- "aria-label": cancelButtonAriaLabel || defaultCancelButtonAriaLabel,
118
- onClick: cancelInlineEdit,
119
- color: "danger",
120
- display: "base",
121
- size: sizes.buttonSize,
122
- iconSize: sizes.iconSize
123
- })))));
124
- var readModeElement = ___EmotionJSX(EuiButtonEmpty, _extends({
125
- color: "text",
126
- iconType: "pencil",
127
- iconSide: "right",
128
- autoFocus: true,
129
- flush: "both",
130
- iconSize: sizes.iconSize,
131
- size: sizes.buttonSize,
132
- onClick: function onClick() {
133
- setIsEditing(!isEditing);
134
- }
135
- }, readModeProps), children(readModeValue));
136
- return ___EmotionJSX("div", {
137
- className: classes
138
- }, isEditing ? editModeForm : readModeElement);
139
- };
140
- EuiInlineEditForm.propTypes = {
141
- className: PropTypes.string,
142
- "aria-label": PropTypes.string,
143
- "data-test-subj": PropTypes.string,
144
- css: PropTypes.any,
145
- defaultValue: PropTypes.string.isRequired,
146
- /**
147
- * Allow users to pass in a function that is called when the confirm button is clicked
148
- * The function should return a boolean flag that will determine if the value will be saved.
149
- * When the flag is true, the value will be saved. When the flag is false, the user will be
150
- * returned to editMode.
151
- */
152
- onConfirm: PropTypes.func,
153
- /**
154
- * Form label that appears above the form control
155
- * This is required for accessibility because there is no visual label on the input
156
- */
157
- inputAriaLabel: PropTypes.string.isRequired,
158
- /**
159
- * Aria-label for save button in editMode
160
- */
161
- saveButtonAriaLabel: PropTypes.string,
162
- /**
163
- * Aria-label for cancel button in editMode
164
- */
165
- cancelButtonAriaLabel: PropTypes.string,
166
- /**
167
- * Start in editMode
168
- */
169
- startWithEditOpen: PropTypes.bool,
170
- /**
171
- * Props that will be applied directly to the EuiEmptyButton displayed in readMode
172
- */
173
- readModeProps: PropTypes.any,
174
- /**
175
- * Props that will be applied directly to the EuiFieldText displayed in editMode
176
- */
177
- editModeProps: PropTypes.any,
178
- /**
179
- * Form sizes
180
- */
181
- sizes: PropTypes.shape({
182
- compressed: PropTypes.bool.isRequired,
183
- buttonSize: PropTypes.oneOf(["xs", "s", "m"]).isRequired,
184
- iconSize: PropTypes.oneOf(["s", "m"]).isRequired
185
- }).isRequired,
186
- /**
187
- * Render prop that returns the read mode value as an arg
188
- */
189
- children: PropTypes.func.isRequired
190
- };