@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.
- package/README.md +30 -29
- package/dist/eui_theme_dark.css +70 -158
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +70 -158
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/basic_table/basic_table.a11y.js +202 -0
- package/es/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +1 -1
- package/es/components/date_picker/date_picker.js +23 -15
- package/es/components/date_picker/date_picker_range.js +36 -42
- package/es/components/date_picker/super_date_picker/super_date_picker.js +99 -84
- package/es/components/form/field_number/field_number.js +39 -8
- package/es/components/form/field_text/field_text.js +1 -1
- package/es/components/form/form_control_layout/form_control_layout.js +67 -30
- package/es/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
- package/es/components/form/form_control_layout/form_control_layout_icons.js +12 -20
- package/es/components/form/range/dual_range.js +2 -4
- package/es/components/form/range/range.js +0 -2
- package/es/components/form/range/range_input.js +54 -13
- package/es/components/form/validatable_control/validatable_control.js +15 -5
- package/es/components/index.js +0 -1
- package/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
- package/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
- package/es/components/suggest/suggest.a11y.js +70 -0
- package/es/components/table/table.a11y.js +75 -0
- package/eui.d.ts +55 -173
- package/i18ntokens.json +26 -44
- package/lib/components/basic_table/basic_table.a11y.js +194 -0
- package/lib/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +2 -2
- package/lib/components/date_picker/date_picker.js +23 -15
- package/lib/components/date_picker/date_picker_range.js +35 -41
- package/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
- package/lib/components/form/field_number/field_number.js +42 -8
- package/lib/components/form/field_text/field_text.js +1 -1
- package/lib/components/form/form_control_layout/form_control_layout.js +67 -35
- package/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
- package/lib/components/form/form_control_layout/form_control_layout_icons.js +11 -19
- package/lib/components/form/range/dual_range.js +2 -4
- package/lib/components/form/range/range.js +0 -2
- package/lib/components/form/range/range_input.js +52 -11
- package/lib/components/form/validatable_control/validatable_control.js +14 -12
- package/lib/components/index.js +0 -11
- package/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
- package/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
- package/lib/components/suggest/suggest.a11y.js +73 -0
- package/lib/components/table/table.a11y.js +78 -0
- package/optimize/es/components/basic_table/basic_table.a11y.js +194 -0
- package/optimize/es/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +1 -1
- package/optimize/es/components/date_picker/date_picker.js +17 -14
- package/optimize/es/components/date_picker/date_picker_range.js +20 -14
- package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +99 -84
- package/optimize/es/components/form/field_number/field_number.js +34 -8
- package/optimize/es/components/form/field_text/field_text.js +1 -1
- package/optimize/es/components/form/form_control_layout/form_control_layout.js +67 -30
- package/optimize/es/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
- package/optimize/es/components/form/form_control_layout/form_control_layout_icons.js +10 -20
- package/optimize/es/components/form/range/dual_range.js +2 -4
- package/optimize/es/components/form/range/range.js +0 -2
- package/optimize/es/components/form/range/range_input.js +49 -12
- package/optimize/es/components/form/validatable_control/validatable_control.js +10 -5
- package/optimize/es/components/index.js +0 -1
- package/optimize/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
- package/optimize/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
- package/optimize/es/components/suggest/suggest.a11y.js +70 -0
- package/optimize/es/components/table/table.a11y.js +75 -0
- package/optimize/lib/components/basic_table/basic_table.a11y.js +188 -0
- package/{test-env/components/basic_table/table.a11y.js → optimize/lib/components/basic_table/in_memory_table.a11y.js} +2 -2
- package/optimize/lib/components/date_picker/date_picker.js +17 -14
- package/optimize/lib/components/date_picker/date_picker_range.js +19 -13
- package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
- package/optimize/lib/components/form/field_number/field_number.js +37 -8
- package/optimize/lib/components/form/field_text/field_text.js +1 -1
- package/optimize/lib/components/form/form_control_layout/form_control_layout.js +67 -35
- package/optimize/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
- package/optimize/lib/components/form/form_control_layout/form_control_layout_icons.js +9 -19
- package/optimize/lib/components/form/range/dual_range.js +2 -4
- package/optimize/lib/components/form/range/range.js +0 -2
- package/optimize/lib/components/form/range/range_input.js +47 -10
- package/optimize/lib/components/form/validatable_control/validatable_control.js +10 -4
- package/optimize/lib/components/index.js +0 -11
- package/optimize/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
- package/optimize/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
- package/optimize/lib/components/suggest/suggest.a11y.js +73 -0
- package/optimize/lib/components/table/table.a11y.js +78 -0
- package/package.json +1 -1
- package/src/components/date_picker/_date_picker_range.scss +0 -60
- package/src/components/date_picker/super_date_picker/_super_date_picker.scss +23 -11
- package/src/components/date_picker/super_date_picker/_variables.scss +3 -0
- package/src/components/date_picker/super_date_picker/date_popover/_date_popover_button.scss +5 -7
- package/src/components/form/form_control_layout/_form_control_layout.scss +2 -2
- package/src/components/form/form_control_layout/_form_control_layout_delimited.scss +12 -36
- package/src/components/form/form_control_layout/_form_control_layout_icons.scss +27 -6
- package/src/themes/amsterdam/overrides/_date_picker.scss +0 -14
- package/src/themes/amsterdam/overrides/_index.scss +0 -1
- package/test-env/components/basic_table/basic_table.a11y.js +188 -0
- package/{optimize/lib/components/basic_table/table.a11y.js → test-env/components/basic_table/in_memory_table.a11y.js} +2 -2
- package/test-env/components/date_picker/date_picker.js +23 -15
- package/test-env/components/date_picker/date_picker_range.js +35 -41
- package/test-env/components/date_picker/super_date_picker/super_date_picker.js +99 -84
- package/test-env/components/form/field_number/field_number.js +37 -8
- package/test-env/components/form/field_text/field_text.js +1 -1
- package/test-env/components/form/form_control_layout/form_control_layout.js +68 -35
- package/test-env/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
- package/test-env/components/form/form_control_layout/form_control_layout_icons.js +11 -19
- package/test-env/components/form/range/dual_range.js +2 -4
- package/test-env/components/form/range/range.js +0 -2
- package/test-env/components/form/range/range_input.js +47 -11
- package/test-env/components/form/validatable_control/validatable_control.js +9 -4
- package/test-env/components/index.js +0 -11
- package/test-env/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
- package/test-env/components/search_bar/query/ast_to_es_query_string.js +3 -0
- package/test-env/components/suggest/suggest.a11y.js +73 -0
- package/test-env/components/table/table.a11y.js +78 -0
- package/es/components/inline_edit/index.js +0 -10
- package/es/components/inline_edit/inline_edit.styles.js +0 -15
- package/es/components/inline_edit/inline_edit_form.js +0 -190
- package/es/components/inline_edit/inline_edit_text.js +0 -97
- package/es/components/inline_edit/inline_edit_title.js +0 -105
- package/lib/components/inline_edit/index.js +0 -19
- package/lib/components/inline_edit/inline_edit.styles.js +0 -22
- package/lib/components/inline_edit/inline_edit_form.js +0 -193
- package/lib/components/inline_edit/inline_edit_text.js +0 -97
- package/lib/components/inline_edit/inline_edit_title.js +0 -106
- package/optimize/es/components/inline_edit/index.js +0 -10
- package/optimize/es/components/inline_edit/inline_edit.styles.js +0 -15
- package/optimize/es/components/inline_edit/inline_edit_form.js +0 -133
- package/optimize/es/components/inline_edit/inline_edit_text.js +0 -52
- package/optimize/es/components/inline_edit/inline_edit_title.js +0 -56
- package/optimize/lib/components/inline_edit/index.js +0 -19
- package/optimize/lib/components/inline_edit/inline_edit.styles.js +0 -22
- package/optimize/lib/components/inline_edit/inline_edit_form.js +0 -144
- package/optimize/lib/components/inline_edit/inline_edit_text.js +0 -52
- package/optimize/lib/components/inline_edit/inline_edit_title.js +0 -57
- package/src/themes/amsterdam/overrides/_date_popover_button.scss +0 -14
- package/test-env/components/inline_edit/index.js +0 -19
- package/test-env/components/inline_edit/inline_edit.styles.js +0 -22
- package/test-env/components/inline_edit/inline_edit_form.js +0 -196
- package/test-env/components/inline_edit/inline_edit_text.js +0 -96
- package/test-env/components/inline_edit/inline_edit_title.js +0 -105
|
@@ -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", "
|
|
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,
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
package/es/components/index.js
CHANGED
|
@@ -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.
|
|
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
|
+
});
|