@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
|
@@ -11,27 +11,47 @@ var _excluded = ["startControl", "endControl", "delimiter", "className"];
|
|
|
11
11
|
|
|
12
12
|
import React, { cloneElement } from 'react';
|
|
13
13
|
import classNames from 'classnames';
|
|
14
|
+
import { useEuiI18n } from '../../i18n';
|
|
15
|
+
import { EuiIcon } from '../../icon';
|
|
14
16
|
import { EuiText } from '../../text';
|
|
15
17
|
import { EuiFormControlLayout } from './form_control_layout';
|
|
16
18
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
17
19
|
export var EuiFormControlLayoutDelimited = function EuiFormControlLayoutDelimited(_ref) {
|
|
18
20
|
var startControl = _ref.startControl,
|
|
19
21
|
endControl = _ref.endControl,
|
|
20
|
-
|
|
21
|
-
delimiter = _ref$delimiter === void 0 ? '→' : _ref$delimiter,
|
|
22
|
+
delimiter = _ref.delimiter,
|
|
22
23
|
className = _ref.className,
|
|
23
24
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
-
var
|
|
25
|
+
var isInvalid = rest.isInvalid,
|
|
26
|
+
isDisabled = rest.isDisabled,
|
|
27
|
+
readOnly = rest.readOnly;
|
|
28
|
+
var showInvalidState = isInvalid && !isDisabled && !readOnly;
|
|
29
|
+
var classes = classNames('euiFormControlLayoutDelimited', className, {
|
|
30
|
+
'euiFormControlLayoutDelimited--isInvalid': showInvalidState
|
|
31
|
+
});
|
|
25
32
|
return ___EmotionJSX(EuiFormControlLayout, _extends({
|
|
26
|
-
className: classes
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
33
|
+
className: classes,
|
|
34
|
+
iconsPosition: "static"
|
|
35
|
+
}, rest), addClassesToControl(startControl), ___EmotionJSX(EuiFormControlDelimiter, {
|
|
36
|
+
delimiter: delimiter,
|
|
37
|
+
isInvalid: showInvalidState
|
|
38
|
+
}), addClassesToControl(endControl));
|
|
32
39
|
};
|
|
33
|
-
function addClassesToControl(control) {
|
|
40
|
+
var addClassesToControl = function addClassesToControl(control) {
|
|
34
41
|
return /*#__PURE__*/cloneElement(control, {
|
|
35
42
|
className: classNames(control.props.className, 'euiFormControlLayoutDelimited__input')
|
|
36
43
|
});
|
|
37
|
-
}
|
|
44
|
+
};
|
|
45
|
+
var EuiFormControlDelimiter = function EuiFormControlDelimiter(_ref2) {
|
|
46
|
+
var delimiter = _ref2.delimiter,
|
|
47
|
+
isInvalid = _ref2.isInvalid;
|
|
48
|
+
var defaultAriaLabel = useEuiI18n('euiFormControlLayoutDelimited.delimiterLabel', 'to');
|
|
49
|
+
return ___EmotionJSX(EuiText, {
|
|
50
|
+
className: "euiFormControlLayoutDelimited__delimiter",
|
|
51
|
+
size: "s",
|
|
52
|
+
color: isInvalid ? 'danger' : 'subdued'
|
|
53
|
+
}, delimiter !== null && delimiter !== void 0 ? delimiter : ___EmotionJSX(EuiIcon, {
|
|
54
|
+
type: "sortRight",
|
|
55
|
+
"aria-label": defaultAriaLabel
|
|
56
|
+
}));
|
|
57
|
+
};
|
|
@@ -16,7 +16,8 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
16
16
|
* Side Public License, v 1.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import React, {
|
|
19
|
+
import React, { Component } from 'react';
|
|
20
|
+
import classNames from 'classnames';
|
|
20
21
|
import { EuiLoadingSpinner } from '../../loading';
|
|
21
22
|
import { EuiFormControlLayoutClearButton } from './form_control_layout_clear_button';
|
|
22
23
|
import { EuiFormControlLayoutCustomIcon } from './form_control_layout_custom_icon';
|
|
@@ -37,30 +38,19 @@ export var EuiFormControlLayoutIcons = /*#__PURE__*/function (_Component) {
|
|
|
37
38
|
key: "render",
|
|
38
39
|
value: function render() {
|
|
39
40
|
var _this$props = this.props,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
_this$props$side = _this$props.side,
|
|
42
|
+
side = _this$props$side === void 0 ? 'left' : _this$props$side,
|
|
43
|
+
_this$props$iconsPosi = _this$props.iconsPosition,
|
|
44
|
+
iconsPosition = _this$props$iconsPosi === void 0 ? 'absolute' : _this$props$iconsPosi;
|
|
44
45
|
var customIcon = this.renderCustomIcon();
|
|
45
46
|
var loadingSpinner = this.renderLoadingSpinner();
|
|
46
47
|
var clearButton = this.renderClearButton();
|
|
47
48
|
var invalidIcon = this.renderInvalidIcon();
|
|
48
49
|
var dropdownIcon = this.renderDropdownIcon();
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}, customIcon);
|
|
54
|
-
}
|
|
55
|
-
var rightIcons;
|
|
56
|
-
|
|
57
|
-
// If the icon is on the right, it should be placed after the clear button in the DOM.
|
|
58
|
-
if (clearButton || loadingSpinner || isInvalid || isDropdown || customIcon && iconSide === 'right') {
|
|
59
|
-
rightIcons = ___EmotionJSX("div", {
|
|
60
|
-
className: "euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
|
|
61
|
-
}, clearButton, loadingSpinner, invalidIcon, iconSide === 'right' ? customIcon : undefined, dropdownIcon);
|
|
62
|
-
}
|
|
63
|
-
return ___EmotionJSX(Fragment, null, leftIcons, rightIcons);
|
|
50
|
+
var classes = classNames('euiFormControlLayoutIcons', "euiFormControlLayoutIcons--".concat(side), "euiFormControlLayoutIcons--".concat(iconsPosition));
|
|
51
|
+
return ___EmotionJSX("div", {
|
|
52
|
+
className: classes
|
|
53
|
+
}, clearButton, loadingSpinner, invalidIcon, customIcon, dropdownIcon);
|
|
64
54
|
}
|
|
65
55
|
}, {
|
|
66
56
|
key: "renderCustomIcon",
|
|
@@ -390,7 +390,6 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
|
|
|
390
390
|
var min = minProps;
|
|
391
391
|
var max = maxProps;
|
|
392
392
|
var id = this.state.id;
|
|
393
|
-
var digitTolerance = Math.max(String(min).length, String(max).length);
|
|
394
393
|
var showInputOnly = showInput === 'inputWithPopover';
|
|
395
394
|
var canShowDropdown = showInputOnly && !readOnly && !disabled;
|
|
396
395
|
var rangeStyles = euiRangeStyles(theme);
|
|
@@ -401,7 +400,6 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
|
|
|
401
400
|
"aria-label": this.props['aria-label']
|
|
402
401
|
}, minInputProps, {
|
|
403
402
|
// Non-overridable props
|
|
404
|
-
digitTolerance: digitTolerance,
|
|
405
403
|
side: "min",
|
|
406
404
|
min: min,
|
|
407
405
|
max: Number(this.upperValue),
|
|
@@ -430,7 +428,6 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
|
|
|
430
428
|
"aria-label": this.props['aria-label']
|
|
431
429
|
}, maxInputProps, {
|
|
432
430
|
// Non-overridable props
|
|
433
|
-
digitTolerance: digitTolerance,
|
|
434
431
|
side: "max",
|
|
435
432
|
min: Number(this.lowerValue),
|
|
436
433
|
max: max,
|
|
@@ -582,7 +579,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
|
|
|
582
579
|
readOnly: readOnly,
|
|
583
580
|
append: append,
|
|
584
581
|
prepend: prepend,
|
|
585
|
-
isLoading: isLoading
|
|
582
|
+
isLoading: isLoading,
|
|
583
|
+
isInvalid: isInvalid
|
|
586
584
|
}),
|
|
587
585
|
fullWidth: fullWidth,
|
|
588
586
|
isOpen: this.state.isPopoverOpen,
|
|
@@ -131,14 +131,12 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
|
|
|
131
131
|
theme = _this$props.theme,
|
|
132
132
|
rest = _objectWithoutProperties(_this$props, _excluded);
|
|
133
133
|
var id = this.state.id;
|
|
134
|
-
var digitTolerance = Math.max(String(min).length, String(max).length);
|
|
135
134
|
var showInputOnly = showInput === 'inputWithPopover';
|
|
136
135
|
var canShowDropdown = showInputOnly && !readOnly && !disabled;
|
|
137
136
|
var theInput = !!showInput ? ___EmotionJSX(EuiRangeInput, _extends({
|
|
138
137
|
id: id,
|
|
139
138
|
min: min,
|
|
140
139
|
max: max,
|
|
141
|
-
digitTolerance: digitTolerance,
|
|
142
140
|
step: step,
|
|
143
141
|
value: value,
|
|
144
142
|
readOnly: readOnly,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
var _excluded = ["min", "max", "step", "value", "disabled", "compressed", "onChange", "name", "side", "
|
|
4
|
+
var _excluded = ["min", "max", "step", "value", "inputRef", "isInvalid", "disabled", "compressed", "onChange", "name", "side", "fullWidth", "autoSize"];
|
|
4
5
|
/*
|
|
5
6
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
6
7
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -9,9 +10,10 @@ var _excluded = ["min", "max", "step", "value", "disabled", "compressed", "onCha
|
|
|
9
10
|
* Side Public License, v 1.
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
|
-
import React, { useMemo } from 'react';
|
|
13
|
-
import { useEuiTheme } from '../../../services';
|
|
13
|
+
import React, { useState, useEffect, useMemo, useRef } from 'react';
|
|
14
|
+
import { useEuiTheme, useCombinedRefs } from '../../../services';
|
|
14
15
|
import { logicalStyles } from '../../../global_styling';
|
|
16
|
+
import { euiFormVariables } from '../form.styles';
|
|
15
17
|
import { EuiFieldNumber } from '../field_number';
|
|
16
18
|
import { euiRangeInputStyles } from './range_input.styles';
|
|
17
19
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
@@ -20,28 +22,61 @@ export var EuiRangeInput = function EuiRangeInput(_ref) {
|
|
|
20
22
|
max = _ref.max,
|
|
21
23
|
step = _ref.step,
|
|
22
24
|
value = _ref.value,
|
|
25
|
+
inputRef = _ref.inputRef,
|
|
26
|
+
isInvalid = _ref.isInvalid,
|
|
23
27
|
disabled = _ref.disabled,
|
|
24
28
|
compressed = _ref.compressed,
|
|
25
29
|
onChange = _ref.onChange,
|
|
26
30
|
name = _ref.name,
|
|
27
31
|
_ref$side = _ref.side,
|
|
28
32
|
side = _ref$side === void 0 ? 'max' : _ref$side,
|
|
29
|
-
digitTolerance = _ref.digitTolerance,
|
|
30
33
|
fullWidth = _ref.fullWidth,
|
|
31
34
|
_ref$autoSize = _ref.autoSize,
|
|
32
35
|
autoSize = _ref$autoSize === void 0 ? true : _ref$autoSize,
|
|
33
36
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
34
|
-
// Chrome will properly size the input based on the max value, but FF does not.
|
|
35
|
-
// Calculate the width of the input based on highest number of characters.
|
|
36
|
-
// Add 2 to accommodate for input stepper
|
|
37
|
-
var widthStyle = useMemo(function () {
|
|
38
|
-
return autoSize ? logicalStyles({
|
|
39
|
-
width: "".concat(digitTolerance / 1.25 + 2, "em")
|
|
40
|
-
}) : {};
|
|
41
|
-
}, [autoSize, digitTolerance]);
|
|
42
37
|
var euiTheme = useEuiTheme();
|
|
43
38
|
var styles = euiRangeInputStyles(euiTheme);
|
|
44
39
|
var cssStyles = [styles.euiRangeInput];
|
|
40
|
+
|
|
41
|
+
// Determine whether an invalid icon is showing, which can come from
|
|
42
|
+
// the underlying EuiFieldNumber's native :invalid state
|
|
43
|
+
var _useState = useState(isInvalid),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
hasInvalidIcon = _useState2[0],
|
|
46
|
+
setHasInvalidIcon = _useState2[1];
|
|
47
|
+
var validityRef = useRef(null);
|
|
48
|
+
var setRefs = useCombinedRefs([validityRef, inputRef]);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
var _validityRef$current;
|
|
51
|
+
var isNativelyInvalid = !((_validityRef$current = validityRef.current) !== null && _validityRef$current !== void 0 && _validityRef$current.validity.valid);
|
|
52
|
+
setHasInvalidIcon(isNativelyInvalid || isInvalid);
|
|
53
|
+
}, [value, isInvalid]);
|
|
54
|
+
|
|
55
|
+
// Calculate the auto size width of the input
|
|
56
|
+
var widthStyle = useMemo(function () {
|
|
57
|
+
if (!autoSize) return undefined;
|
|
58
|
+
|
|
59
|
+
// Calculate the number of characters to show (dynamic based on user input)
|
|
60
|
+
// Uses the min/max char length as a max, then add an extra UX buffer of 1
|
|
61
|
+
var maxChars = Math.max(String(min).length, String(max).length) + 1;
|
|
62
|
+
var inputCharWidth = Math.min(String(value).length, maxChars);
|
|
63
|
+
|
|
64
|
+
// Calculate the form padding based on `compressed` state
|
|
65
|
+
var _euiFormVariables = euiFormVariables(euiTheme),
|
|
66
|
+
controlPadding = _euiFormVariables.controlPadding,
|
|
67
|
+
controlCompressedPadding = _euiFormVariables.controlCompressedPadding;
|
|
68
|
+
var inputPadding = compressed ? controlCompressedPadding : controlPadding;
|
|
69
|
+
|
|
70
|
+
// Calculate the invalid icon (if being displayed), also based on `compressed` state
|
|
71
|
+
var invalidIconWidth = hasInvalidIcon ? euiTheme.euiTheme.base * (compressed ? 1.125 : 1.375) // TODO: DRY this out once EuiFormControlLayoutIcons is converted to Emotion
|
|
72
|
+
: 0;
|
|
73
|
+
|
|
74
|
+
// Guesstimate a width for the stepper. Note that it's a little wider in FF than it is in Chrome
|
|
75
|
+
var stepperWidth = 2;
|
|
76
|
+
return logicalStyles({
|
|
77
|
+
width: "calc(".concat(inputPadding, " + ").concat(inputCharWidth, "ch + ").concat(stepperWidth, "em + ").concat(invalidIconWidth, "px)")
|
|
78
|
+
});
|
|
79
|
+
}, [autoSize, euiTheme, compressed, hasInvalidIcon, min, max, value]);
|
|
45
80
|
return ___EmotionJSX(EuiFieldNumber, _extends({
|
|
46
81
|
name: name,
|
|
47
82
|
className: "euiRangeInput euiRangeInput--".concat(side),
|
|
@@ -50,6 +85,8 @@ export var EuiRangeInput = function EuiRangeInput(_ref) {
|
|
|
50
85
|
max: Number(max),
|
|
51
86
|
step: step,
|
|
52
87
|
value: value === '' ? '' : Number(value),
|
|
88
|
+
inputRef: setRefs,
|
|
89
|
+
isInvalid: isInvalid,
|
|
53
90
|
disabled: disabled,
|
|
54
91
|
compressed: compressed,
|
|
55
92
|
onChange: onChange,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
1
2
|
/*
|
|
2
3
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
3
4
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
* Side Public License, v 1.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
|
-
import { Children, cloneElement,
|
|
10
|
+
import { Children, cloneElement, useState, useEffect, useCallback } from 'react';
|
|
10
11
|
function isMutableRef(ref) {
|
|
11
12
|
return ref != null && ref.hasOwnProperty('current');
|
|
12
13
|
}
|
|
@@ -19,11 +20,15 @@ function isMutableRef(ref) {
|
|
|
19
20
|
export var EuiValidatableControl = function EuiValidatableControl(_ref) {
|
|
20
21
|
var isInvalid = _ref.isInvalid,
|
|
21
22
|
children = _ref.children;
|
|
22
|
-
|
|
23
|
+
// Note that this must be state and not a ref to cause a rerender/set invalid state on initial mount
|
|
24
|
+
var _useState = useState(null),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
control = _useState2[0],
|
|
27
|
+
setControl = _useState2[1];
|
|
23
28
|
var child = Children.only(children);
|
|
24
29
|
var childRef = child.ref;
|
|
25
30
|
var replacedRef = useCallback(function (element) {
|
|
26
|
-
|
|
31
|
+
setControl(element);
|
|
27
32
|
|
|
28
33
|
// Call the original ref, if any
|
|
29
34
|
if (typeof childRef === 'function') {
|
|
@@ -33,12 +38,12 @@ export var EuiValidatableControl = function EuiValidatableControl(_ref) {
|
|
|
33
38
|
}
|
|
34
39
|
}, [childRef]);
|
|
35
40
|
useSetControlValidity({
|
|
36
|
-
controlEl: control
|
|
41
|
+
controlEl: control,
|
|
37
42
|
isInvalid: isInvalid
|
|
38
43
|
});
|
|
39
44
|
return /*#__PURE__*/cloneElement(child, {
|
|
40
45
|
ref: replacedRef,
|
|
41
|
-
'aria-invalid': isInvalid
|
|
46
|
+
'aria-invalid': isInvalid || child.props['aria-invalid']
|
|
42
47
|
});
|
|
43
48
|
};
|
|
44
49
|
|
|
@@ -60,7 +60,12 @@ var processDateOperation = function processDateOperation(value, operator) {
|
|
|
60
60
|
};
|
|
61
61
|
export var _termValuesToQuery = function _termValuesToQuery(values, options) {
|
|
62
62
|
var body = {
|
|
63
|
-
query: values.
|
|
63
|
+
query: values.map(function (value) {
|
|
64
|
+
if (isString(value) && value.match(/\s/)) {
|
|
65
|
+
return "\"".concat(value, "\"");
|
|
66
|
+
}
|
|
67
|
+
return value;
|
|
68
|
+
}).join(' ')
|
|
64
69
|
};
|
|
65
70
|
if (body.query === '') {
|
|
66
71
|
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
|
+
});
|