@elastic/eui 121.0.0-snapshot.1788869799640 → 121.0.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/dist/eui-icons.json +10 -10
- package/es/components/datagrid/body/cell/data_grid_cell.js +5 -8
- package/es/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
- package/es/components/datagrid/body/cell/data_grid_cell_wrapper.js +2 -4
- package/es/components/datagrid/body/footer/data_grid_footer_row.js +0 -4
- package/es/components/datagrid/body/header/column_resizer.js +87 -74
- package/es/components/datagrid/body/header/data_grid_control_header_cell.js +1 -2
- package/es/components/datagrid/body/header/data_grid_header_cell.js +0 -1
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +3 -9
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
- package/es/components/datagrid/controls/keyboard_shortcuts.js +1 -17
- package/es/components/datagrid/data_grid.js +0 -2
- package/es/components/form/super_select/super_select.js +351 -247
- package/eui.d.ts +55 -30
- package/i18ntokens.json +205 -277
- package/lib/components/datagrid/body/cell/data_grid_cell.js +5 -8
- package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
- package/lib/components/datagrid/body/cell/data_grid_cell_wrapper.js +2 -4
- package/lib/components/datagrid/body/footer/data_grid_footer_row.js +0 -4
- package/lib/components/datagrid/body/header/column_resizer.js +85 -73
- package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +1 -2
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +0 -1
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +3 -9
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
- package/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -17
- package/lib/components/datagrid/data_grid.js +0 -2
- package/lib/components/form/super_select/super_select.js +355 -253
- package/optimize/es/components/datagrid/body/cell/data_grid_cell.js +4 -5
- package/optimize/es/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
- package/optimize/es/components/datagrid/body/cell/data_grid_cell_wrapper.js +2 -4
- package/optimize/es/components/datagrid/body/footer/data_grid_footer_row.js +0 -4
- package/optimize/es/components/datagrid/body/header/column_resizer.js +81 -69
- package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +1 -2
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +0 -1
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +3 -7
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
- package/optimize/es/components/datagrid/controls/keyboard_shortcuts.js +1 -17
- package/optimize/es/components/datagrid/data_grid.js +0 -2
- package/optimize/es/components/form/super_select/super_select.js +265 -242
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell.js +4 -5
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell_wrapper.js +2 -4
- package/optimize/lib/components/datagrid/body/footer/data_grid_footer_row.js +0 -4
- package/optimize/lib/components/datagrid/body/header/column_resizer.js +79 -69
- package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +1 -2
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +0 -1
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +3 -7
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
- package/optimize/lib/components/datagrid/controls/keyboard_shortcuts.js +1 -17
- package/optimize/lib/components/datagrid/data_grid.js +0 -2
- package/optimize/lib/components/form/super_select/super_select.js +265 -243
- package/package.json +7 -8
- package/test-env/components/datagrid/body/cell/data_grid_cell.js +5 -8
- package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
- package/test-env/components/datagrid/body/cell/data_grid_cell_wrapper.js +2 -4
- package/test-env/components/datagrid/body/footer/data_grid_footer_row.js +0 -4
- package/test-env/components/datagrid/body/header/column_resizer.js +79 -69
- package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +1 -2
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +0 -1
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +3 -9
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
- package/test-env/components/datagrid/controls/keyboard_shortcuts.js +1 -17
- package/test-env/components/datagrid/data_grid.js +0 -2
- package/test-env/components/form/super_select/super_select.js +345 -243
- package/es/components/datagrid/utils/copy_focused_cell.js +0 -34
- package/lib/components/datagrid/utils/copy_focused_cell.js +0 -39
- package/optimize/es/components/datagrid/utils/copy_focused_cell.js +0 -34
- package/optimize/lib/components/datagrid/utils/copy_focused_cell.js +0 -39
- package/test-env/components/datagrid/utils/copy_focused_cell.js +0 -16
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
|
|
3
|
+
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
|
+
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
|
+
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
+
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
+
var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "isOpen", "isInvalid", "itemClassName", "fullWidth", "popoverProps", "compressed"],
|
|
5
10
|
_excluded2 = ["value", "dropdownDisplay", "inputDisplay", "disabled"];
|
|
11
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
12
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
6
13
|
/*
|
|
7
14
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
8
15
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
@@ -11,9 +18,9 @@ var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onCh
|
|
|
11
18
|
* Side Public License, v 1.
|
|
12
19
|
*/
|
|
13
20
|
|
|
14
|
-
import React, {
|
|
21
|
+
import React, { Component, createRef } from 'react';
|
|
15
22
|
import classNames from 'classnames';
|
|
16
|
-
import { htmlIdGenerator, keys,
|
|
23
|
+
import { htmlIdGenerator, keys, RenderWithEuiStylesMemoizer } from '../../../services';
|
|
17
24
|
import { EuiI18n } from '../../i18n';
|
|
18
25
|
import { EuiScreenReaderOnly } from '../../accessibility';
|
|
19
26
|
import { EuiInputPopover } from '../../popover';
|
|
@@ -25,256 +32,272 @@ var ShiftDirection = /*#__PURE__*/function (ShiftDirection) {
|
|
|
25
32
|
ShiftDirection["BACK"] = "back";
|
|
26
33
|
ShiftDirection["FORWARD"] = "forward";
|
|
27
34
|
return ShiftDirection;
|
|
28
|
-
}(ShiftDirection || {});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
_ref$compressed = _ref.compressed,
|
|
48
|
-
compressed = _ref$compressed === void 0 ? false : _ref$compressed,
|
|
49
|
-
_ref$isLoading = _ref.isLoading,
|
|
50
|
-
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
51
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
52
|
-
var styles = useEuiMemoizedStyles(euiSuperSelectStyles);
|
|
53
|
-
var itemNodes = useRef([]);
|
|
54
|
-
var isMounted = useRef(false);
|
|
55
|
-
var controlButtonRef = useRef(null);
|
|
56
|
-
var _useState = useState(function () {
|
|
57
|
-
return htmlIdGenerator('euiSuperSelect_')('_screenreaderDescribeId');
|
|
58
|
-
}),
|
|
59
|
-
_useState2 = _slicedToArray(_useState, 1),
|
|
60
|
-
describedById = _useState2[0];
|
|
61
|
-
var _useState3 = useState(isOpen || false),
|
|
62
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
63
|
-
isPopoverOpen = _useState4[0],
|
|
64
|
-
setIsPopoverOpen = _useState4[1];
|
|
65
|
-
var _useState5 = useState(0),
|
|
66
|
-
_useState6 = _slicedToArray(_useState5, 2),
|
|
67
|
-
currentIndex = _useState6[0],
|
|
68
|
-
setCurrentIndex = _useState6[1];
|
|
69
|
-
var setItemNode = function setItemNode(node, index) {
|
|
70
|
-
itemNodes.current[index] = node;
|
|
71
|
-
};
|
|
72
|
-
var focusItemAt = useCallback(function (index) {
|
|
73
|
-
var _itemNodes$current$in;
|
|
74
|
-
(_itemNodes$current$in = itemNodes.current[index]) === null || _itemNodes$current$in === void 0 || _itemNodes$current$in.focus();
|
|
75
|
-
}, []);
|
|
76
|
-
var openPopover = useCallback(function () {
|
|
77
|
-
var indexOfSelected = options.findIndex(function (option) {
|
|
78
|
-
return (option === null || option === void 0 ? void 0 : option.value) === valueOfSelected;
|
|
35
|
+
}(ShiftDirection || {});
|
|
36
|
+
export var EuiSuperSelect = /*#__PURE__*/function (_Component) {
|
|
37
|
+
function EuiSuperSelect() {
|
|
38
|
+
var _this;
|
|
39
|
+
_classCallCheck(this, EuiSuperSelect);
|
|
40
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
41
|
+
args[_key] = arguments[_key];
|
|
42
|
+
}
|
|
43
|
+
_this = _callSuper(this, EuiSuperSelect, [].concat(args));
|
|
44
|
+
_defineProperty(_this, "itemNodes", []);
|
|
45
|
+
_defineProperty(_this, "_isMounted", false);
|
|
46
|
+
_defineProperty(_this, "controlButtonRef", /*#__PURE__*/createRef());
|
|
47
|
+
_defineProperty(_this, "describedById", htmlIdGenerator('euiSuperSelect_')('_screenreaderDescribeId'));
|
|
48
|
+
_defineProperty(_this, "state", {
|
|
49
|
+
isPopoverOpen: _this.props.isOpen || false,
|
|
50
|
+
currentIndex: 0
|
|
51
|
+
});
|
|
52
|
+
_defineProperty(_this, "setItemNode", function (node, index) {
|
|
53
|
+
_this.itemNodes[index] = node;
|
|
79
54
|
});
|
|
80
|
-
|
|
81
|
-
|
|
55
|
+
_defineProperty(_this, "openPopover", function () {
|
|
56
|
+
var _this$props = _this.props,
|
|
57
|
+
options = _this$props.options,
|
|
58
|
+
valueOfSelected = _this$props.valueOfSelected;
|
|
59
|
+
var indexOfSelected = options.findIndex(function (option) {
|
|
60
|
+
return (option === null || option === void 0 ? void 0 : option.value) === valueOfSelected;
|
|
61
|
+
});
|
|
62
|
+
var candidateIndex = valueOfSelected != null && indexOfSelected >= 0 ? indexOfSelected : 0;
|
|
63
|
+
var initialIndex = candidateIndex;
|
|
82
64
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
65
|
+
// If the item is disabled, find the first focusable item going forward
|
|
66
|
+
while (initialIndex < options.length && (_options$initialIndex = options[initialIndex]) !== null && _options$initialIndex !== void 0 && _options$initialIndex.disabled) {
|
|
67
|
+
var _options$initialIndex;
|
|
68
|
+
initialIndex++;
|
|
69
|
+
}
|
|
70
|
+
if (initialIndex >= options.length) {
|
|
71
|
+
initialIndex = candidateIndex;
|
|
72
|
+
}
|
|
73
|
+
_this.setState({
|
|
74
|
+
isPopoverOpen: options.length > 0,
|
|
75
|
+
currentIndex: initialIndex
|
|
76
|
+
});
|
|
94
77
|
requestAnimationFrame(function () {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
onFocus
|
|
101
|
-
|
|
78
|
+
requestAnimationFrame(function () {
|
|
79
|
+
if (!_this._isMounted) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
_this.focusItemAt(initialIndex);
|
|
83
|
+
if (_this.props.onFocus) {
|
|
84
|
+
_this.props.onFocus();
|
|
85
|
+
}
|
|
86
|
+
});
|
|
102
87
|
});
|
|
103
88
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
89
|
+
_defineProperty(_this, "closePopover", function () {
|
|
90
|
+
_this.setState({
|
|
91
|
+
isPopoverOpen: false,
|
|
92
|
+
currentIndex: -1
|
|
93
|
+
});
|
|
108
94
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
95
|
+
// Refocus back to the toggling control button on popover close
|
|
96
|
+
requestAnimationFrame(function () {
|
|
97
|
+
var _this$controlButtonRe;
|
|
98
|
+
(_this$controlButtonRe = _this.controlButtonRef.current) === null || _this$controlButtonRe === void 0 || _this$controlButtonRe.focus();
|
|
99
|
+
});
|
|
100
|
+
if (_this.props.onBlur) {
|
|
101
|
+
_this.props.onBlur();
|
|
102
|
+
}
|
|
113
103
|
});
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}, [openPopover, closePopover]);
|
|
124
|
-
var itemClicked = function itemClicked(value) {
|
|
125
|
-
closePopover();
|
|
126
|
-
if (onChange) {
|
|
127
|
-
onChange(value);
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
var onSelectKeyDown = function onSelectKeyDown(event) {
|
|
131
|
-
// Mimic the ways native `<select>`s can be opened via keypress
|
|
132
|
-
if (event.key === keys.ARROW_UP || event.key === keys.ARROW_DOWN || event.key === keys.SPACE) {
|
|
133
|
-
event.preventDefault();
|
|
134
|
-
event.stopPropagation();
|
|
135
|
-
openPopover();
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
var onItemKeyDown = function onItemKeyDown(event) {
|
|
139
|
-
switch (event.key) {
|
|
140
|
-
case keys.ESCAPE:
|
|
141
|
-
// close the popover and prevent ancestors from handling
|
|
142
|
-
event.preventDefault();
|
|
143
|
-
event.stopPropagation();
|
|
144
|
-
closePopover();
|
|
145
|
-
break;
|
|
146
|
-
case keys.TAB:
|
|
147
|
-
// Mimic native `<select>` behavior, which selects an item on tab press
|
|
148
|
-
event.preventDefault();
|
|
149
|
-
event.stopPropagation();
|
|
150
|
-
event.target.click();
|
|
151
|
-
break;
|
|
152
|
-
case keys.ARROW_UP:
|
|
153
|
-
event.preventDefault();
|
|
154
|
-
event.stopPropagation();
|
|
155
|
-
shiftFocus(ShiftDirection.BACK);
|
|
156
|
-
break;
|
|
157
|
-
case keys.ARROW_DOWN:
|
|
104
|
+
_defineProperty(_this, "itemClicked", function (value) {
|
|
105
|
+
_this.closePopover();
|
|
106
|
+
if (_this.props.onChange) {
|
|
107
|
+
_this.props.onChange(value);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
_defineProperty(_this, "onSelectKeyDown", function (event) {
|
|
111
|
+
// Mimic the ways native `<select>`s can be opened via keypress
|
|
112
|
+
if (event.key === keys.ARROW_UP || event.key === keys.ARROW_DOWN || event.key === keys.SPACE) {
|
|
158
113
|
event.preventDefault();
|
|
159
114
|
event.stopPropagation();
|
|
160
|
-
|
|
161
|
-
|
|
115
|
+
_this.openPopover();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
_defineProperty(_this, "onItemKeyDown", function (event) {
|
|
119
|
+
switch (event.key) {
|
|
120
|
+
case keys.ESCAPE:
|
|
121
|
+
// close the popover and prevent ancestors from handling
|
|
122
|
+
event.preventDefault();
|
|
123
|
+
event.stopPropagation();
|
|
124
|
+
_this.closePopover();
|
|
125
|
+
break;
|
|
126
|
+
case keys.TAB:
|
|
127
|
+
// Mimic native `<select>` behavior, which selects an item on tab press
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
event.stopPropagation();
|
|
130
|
+
event.target.click();
|
|
131
|
+
break;
|
|
132
|
+
case keys.ARROW_UP:
|
|
133
|
+
event.preventDefault();
|
|
134
|
+
event.stopPropagation();
|
|
135
|
+
_this.shiftFocus(ShiftDirection.BACK);
|
|
136
|
+
break;
|
|
137
|
+
case keys.ARROW_DOWN:
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
_this.shiftFocus(ShiftDirection.FORWARD);
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return _this;
|
|
145
|
+
}
|
|
146
|
+
_inherits(EuiSuperSelect, _Component);
|
|
147
|
+
return _createClass(EuiSuperSelect, [{
|
|
148
|
+
key: "componentDidMount",
|
|
149
|
+
value: function componentDidMount() {
|
|
150
|
+
this._isMounted = true;
|
|
151
|
+
if (this.props.isOpen) {
|
|
152
|
+
this.openPopover();
|
|
153
|
+
}
|
|
162
154
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
focusItemAt(0);
|
|
168
|
-
setCurrentIndex(0);
|
|
169
|
-
return;
|
|
155
|
+
}, {
|
|
156
|
+
key: "componentWillUnmount",
|
|
157
|
+
value: function componentWillUnmount() {
|
|
158
|
+
this._isMounted = false;
|
|
170
159
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
160
|
+
}, {
|
|
161
|
+
key: "focusItemAt",
|
|
162
|
+
value: function focusItemAt(index) {
|
|
163
|
+
var _this$itemNodes$index;
|
|
164
|
+
(_this$itemNodes$index = this.itemNodes[index]) === null || _this$itemNodes$index === void 0 || _this$itemNodes$index.focus();
|
|
165
|
+
}
|
|
166
|
+
}, {
|
|
167
|
+
key: "shiftFocus",
|
|
168
|
+
value: function shiftFocus(direction) {
|
|
169
|
+
var options = this.props.options;
|
|
170
|
+
var currentIndex = this.state.currentIndex;
|
|
171
|
+
if (currentIndex === -1) {
|
|
172
|
+
// somehow the select options has lost focus
|
|
173
|
+
this.focusItemAt(0);
|
|
174
|
+
this.setState({
|
|
175
|
+
currentIndex: 0
|
|
176
|
+
});
|
|
181
177
|
return;
|
|
182
178
|
}
|
|
183
|
-
|
|
179
|
+
|
|
180
|
+
// Note: this component purposely does not cycle arrow key navigation
|
|
181
|
+
// to match native <select> elements
|
|
182
|
+
var step = direction === ShiftDirection.BACK ? -1 : 1;
|
|
183
|
+
var nextIndex = currentIndex + step;
|
|
184
|
+
while (nextIndex >= 0 && nextIndex < options.length) {
|
|
185
|
+
var _options$nextIndex;
|
|
186
|
+
if (!((_options$nextIndex = options[nextIndex]) !== null && _options$nextIndex !== void 0 && _options$nextIndex.disabled)) {
|
|
187
|
+
this.focusItemAt(nextIndex);
|
|
188
|
+
this.setState({
|
|
189
|
+
currentIndex: nextIndex
|
|
190
|
+
});
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
nextIndex += step;
|
|
194
|
+
}
|
|
184
195
|
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
196
|
+
}, {
|
|
197
|
+
key: "render",
|
|
198
|
+
value: function render() {
|
|
199
|
+
var _this2 = this,
|
|
200
|
+
_options$this$state$c;
|
|
201
|
+
var _this$props2 = this.props,
|
|
202
|
+
className = _this$props2.className,
|
|
203
|
+
options = _this$props2.options,
|
|
204
|
+
valueOfSelected = _this$props2.valueOfSelected,
|
|
205
|
+
placeholder = _this$props2.placeholder,
|
|
206
|
+
onChange = _this$props2.onChange,
|
|
207
|
+
isOpen = _this$props2.isOpen,
|
|
208
|
+
isInvalid = _this$props2.isInvalid,
|
|
209
|
+
itemClassName = _this$props2.itemClassName,
|
|
210
|
+
fullWidth = _this$props2.fullWidth,
|
|
211
|
+
popoverProps = _this$props2.popoverProps,
|
|
212
|
+
compressed = _this$props2.compressed,
|
|
213
|
+
rest = _objectWithoutProperties(_this$props2, _excluded);
|
|
214
|
+
var popoverClasses = classNames('euiSuperSelect', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className);
|
|
215
|
+
var button = ___EmotionJSX(EuiSuperSelectControl, _extends({
|
|
216
|
+
options: options,
|
|
217
|
+
value: valueOfSelected,
|
|
218
|
+
placeholder: placeholder,
|
|
219
|
+
onClick: this.state.isPopoverOpen ? this.closePopover : this.openPopover,
|
|
220
|
+
onKeyDown: this.onSelectKeyDown,
|
|
221
|
+
className: className,
|
|
222
|
+
fullWidth: fullWidth,
|
|
223
|
+
isInvalid: isInvalid,
|
|
224
|
+
compressed: compressed
|
|
225
|
+
}, rest, {
|
|
226
|
+
buttonRef: this.controlButtonRef,
|
|
227
|
+
isDropdownOpen: this.state.isPopoverOpen
|
|
228
|
+
}));
|
|
229
|
+
var items = options.map(function (option, index) {
|
|
230
|
+
var value = option.value,
|
|
231
|
+
dropdownDisplay = option.dropdownDisplay,
|
|
232
|
+
inputDisplay = option.inputDisplay,
|
|
233
|
+
disabled = option.disabled,
|
|
234
|
+
optionRest = _objectWithoutProperties(option, _excluded2);
|
|
235
|
+
if (value == null) return;
|
|
236
|
+
return ___EmotionJSX(EuiSuperSelectItem, _extends({
|
|
237
|
+
key: index
|
|
238
|
+
/* NOTE: This should rather use "li" to align select-like behavior. But the current
|
|
239
|
+
implementation relies on the interactive and focusable item for the navigation.
|
|
240
|
+
This will require additional refactoring to adjust but we might want to decide first
|
|
241
|
+
if the effort is worth it, considering the unification plans for selection components
|
|
242
|
+
as part of OneSelect (https://github.com/elastic/eui/issues/8808).
|
|
243
|
+
*/,
|
|
244
|
+
element: "button",
|
|
245
|
+
id: String(value),
|
|
246
|
+
className: itemClassName,
|
|
247
|
+
checked: valueOfSelected === value ? 'on' : undefined,
|
|
248
|
+
isSelected: valueOfSelected === value,
|
|
249
|
+
isFocused: _this2.state.currentIndex === index,
|
|
250
|
+
isSingleSelection: true,
|
|
251
|
+
isDisabled: disabled,
|
|
252
|
+
textWrap: "wrap",
|
|
253
|
+
onClick: function onClick() {
|
|
254
|
+
return _this2.itemClicked(value);
|
|
255
|
+
},
|
|
256
|
+
onKeyDown: _this2.onItemKeyDown,
|
|
257
|
+
ref: function ref(node) {
|
|
258
|
+
return _this2.setItemNode(node, index);
|
|
259
|
+
},
|
|
260
|
+
"aria-selected": valueOfSelected === value
|
|
261
|
+
}, optionRest), dropdownDisplay || inputDisplay);
|
|
262
|
+
});
|
|
263
|
+
var ariaActiveDescendant = ((_options$this$state$c = options[this.state.currentIndex]) === null || _options$this$state$c === void 0 ? void 0 : _options$this$state$c.value) != null ? String(options[this.state.currentIndex].value) : undefined;
|
|
264
|
+
return ___EmotionJSX(RenderWithEuiStylesMemoizer, null, function (stylesMemoizer) {
|
|
265
|
+
var styles = stylesMemoizer(euiSuperSelectStyles);
|
|
266
|
+
return ___EmotionJSX(EuiInputPopover, _extends({
|
|
267
|
+
closePopover: _this2.closePopover,
|
|
268
|
+
panelPaddingSize: "none"
|
|
269
|
+
}, popoverProps, {
|
|
270
|
+
className: popoverClasses,
|
|
271
|
+
isOpen: isOpen || _this2.state.isPopoverOpen,
|
|
272
|
+
input: button,
|
|
273
|
+
fullWidth: fullWidth,
|
|
274
|
+
disableFocusTrap: true // This component handles its own focus manually
|
|
275
|
+
}), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
|
|
276
|
+
id: _this2.describedById
|
|
277
|
+
}, ___EmotionJSX(EuiI18n, {
|
|
278
|
+
token: "euiSuperSelect.screenReaderAnnouncement",
|
|
279
|
+
default: "You are in a form selector and must select a single option. Use the Up and Down arrow keys to navigate or Escape to close."
|
|
280
|
+
}))), ___EmotionJSX(EuiI18n, {
|
|
281
|
+
token: "euiSuperSelect.ariaLabel",
|
|
282
|
+
default: "Select listbox"
|
|
283
|
+
}, function (ariaLabel) {
|
|
284
|
+
return ___EmotionJSX("div", {
|
|
285
|
+
"aria-label": ariaLabel,
|
|
286
|
+
"aria-describedby": _this2.describedById,
|
|
287
|
+
css: styles.euiSuperSelect__listbox,
|
|
288
|
+
className: "euiSuperSelect__listbox eui-scrollBar",
|
|
289
|
+
role: "listbox",
|
|
290
|
+
"aria-activedescendant": ariaActiveDescendant,
|
|
291
|
+
tabIndex: 0
|
|
292
|
+
}, items);
|
|
293
|
+
}));
|
|
294
|
+
});
|
|
190
295
|
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
options: options,
|
|
200
|
-
value: valueOfSelected,
|
|
201
|
-
placeholder: placeholder,
|
|
202
|
-
onClick: isPopoverOpen ? closePopover : openPopover,
|
|
203
|
-
onKeyDown: onSelectKeyDown,
|
|
204
|
-
onFocus: onFocus,
|
|
205
|
-
onBlur: onBlur,
|
|
206
|
-
className: className,
|
|
207
|
-
fullWidth: fullWidth,
|
|
208
|
-
isInvalid: isInvalid,
|
|
209
|
-
compressed: compressed,
|
|
210
|
-
isLoading: isLoading
|
|
211
|
-
}, rest, {
|
|
212
|
-
buttonRef: controlButtonRef,
|
|
213
|
-
isDropdownOpen: isPopoverOpen
|
|
214
|
-
}));
|
|
215
|
-
var items = options.map(function (option, index) {
|
|
216
|
-
var value = option.value,
|
|
217
|
-
dropdownDisplay = option.dropdownDisplay,
|
|
218
|
-
inputDisplay = option.inputDisplay,
|
|
219
|
-
disabled = option.disabled,
|
|
220
|
-
optionRest = _objectWithoutProperties(option, _excluded2);
|
|
221
|
-
if (value == null) return;
|
|
222
|
-
return ___EmotionJSX(EuiSuperSelectItem, _extends({
|
|
223
|
-
key: index
|
|
224
|
-
/* NOTE: This should rather use "li" to align select-like behavior. But the current
|
|
225
|
-
implementation relies on the interactive and focusable item for the navigation.
|
|
226
|
-
This will require additional refactoring to adjust but we might want to decide first
|
|
227
|
-
if the effort is worth it, considering the unification plans for selection components
|
|
228
|
-
as part of OneSelect (https://github.com/elastic/eui/issues/8808).
|
|
229
|
-
*/,
|
|
230
|
-
element: "button",
|
|
231
|
-
id: String(value),
|
|
232
|
-
className: itemClassName,
|
|
233
|
-
checked: valueOfSelected === value ? 'on' : undefined,
|
|
234
|
-
isSelected: valueOfSelected === value,
|
|
235
|
-
isFocused: currentIndex === index,
|
|
236
|
-
isSingleSelection: true,
|
|
237
|
-
isDisabled: disabled,
|
|
238
|
-
textWrap: "wrap",
|
|
239
|
-
onClick: function onClick() {
|
|
240
|
-
return itemClicked(value);
|
|
241
|
-
},
|
|
242
|
-
onKeyDown: onItemKeyDown,
|
|
243
|
-
ref: function ref(node) {
|
|
244
|
-
return setItemNode(node, index);
|
|
245
|
-
},
|
|
246
|
-
"aria-selected": valueOfSelected === value
|
|
247
|
-
}, optionRest), dropdownDisplay || inputDisplay);
|
|
248
|
-
});
|
|
249
|
-
var ariaActiveDescendant = ((_options$currentIndex = options[currentIndex]) === null || _options$currentIndex === void 0 ? void 0 : _options$currentIndex.value) != null ? String(options[currentIndex].value) : undefined;
|
|
250
|
-
return ___EmotionJSX(EuiInputPopover, _extends({
|
|
251
|
-
closePopover: closePopover,
|
|
252
|
-
panelPaddingSize: "none"
|
|
253
|
-
}, popoverProps, {
|
|
254
|
-
className: popoverClasses,
|
|
255
|
-
isOpen: isOpen || isPopoverOpen,
|
|
256
|
-
input: button,
|
|
257
|
-
fullWidth: fullWidth,
|
|
258
|
-
disableFocusTrap: true // This component handles its own focus manually
|
|
259
|
-
}), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
|
|
260
|
-
id: describedById
|
|
261
|
-
}, ___EmotionJSX(EuiI18n, {
|
|
262
|
-
token: "euiSuperSelect.screenReaderAnnouncement",
|
|
263
|
-
default: "You are in a form selector and must select a single option. Use the Up and Down arrow keys to navigate or Escape to close."
|
|
264
|
-
}))), ___EmotionJSX(EuiI18n, {
|
|
265
|
-
token: "euiSuperSelect.ariaLabel",
|
|
266
|
-
default: "Select listbox"
|
|
267
|
-
}, function (ariaLabel) {
|
|
268
|
-
return ___EmotionJSX("div", {
|
|
269
|
-
"aria-label": ariaLabel,
|
|
270
|
-
"aria-describedby": describedById,
|
|
271
|
-
css: styles.euiSuperSelect__listbox,
|
|
272
|
-
className: "euiSuperSelect__listbox eui-scrollBar",
|
|
273
|
-
role: "listbox",
|
|
274
|
-
"aria-activedescendant": ariaActiveDescendant,
|
|
275
|
-
tabIndex: 0
|
|
276
|
-
}, items);
|
|
277
|
-
}));
|
|
278
|
-
};
|
|
279
|
-
export var EuiSuperSelect = /*#__PURE__*/forwardRef(EuiSuperSelectInner);
|
|
280
|
-
EuiSuperSelect.displayName = 'EuiSuperSelect';
|
|
296
|
+
}]);
|
|
297
|
+
}(Component);
|
|
298
|
+
_defineProperty(EuiSuperSelect, "defaultProps", {
|
|
299
|
+
fullWidth: false,
|
|
300
|
+
compressed: false,
|
|
301
|
+
isInvalid: false,
|
|
302
|
+
isLoading: false
|
|
303
|
+
});
|
|
@@ -31,7 +31,7 @@ var _focus_utils = require("./focus_utils");
|
|
|
31
31
|
var _data_grid_cell = require("./data_grid_cell.styles");
|
|
32
32
|
var _react2 = require("@emotion/react");
|
|
33
33
|
var _excluded = ["renderCellValue", "cellContext", "column", "setCellContentsRef", "rowIndex", "colIndex", "rowHeightsOptions", "rowHeightUtils", "isControlColumn"],
|
|
34
|
-
_excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"
|
|
34
|
+
_excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
|
|
35
35
|
_excluded3 = ["isExpandable", "style", "className", "data-test-subj"],
|
|
36
36
|
_excluded4 = ["columnId", "columnIndex", "rowIndex", "visibleRowIndex"];
|
|
37
37
|
/*
|
|
@@ -425,8 +425,6 @@ var EuiDataGridCell = exports.EuiDataGridCell = /*#__PURE__*/function (_Componen
|
|
|
425
425
|
rowHeightsOptions = _this$props9.rowHeightsOptions,
|
|
426
426
|
rowManager = _this$props9.rowManager,
|
|
427
427
|
pagination = _this$props9.pagination,
|
|
428
|
-
_this$props9$isLastCo = _this$props9.isLastCopyColumn,
|
|
429
|
-
isLastCopyColumn = _this$props9$isLastCo === void 0 ? false : _this$props9$isLastCo,
|
|
430
428
|
rest = (0, _objectWithoutProperties2.default)(_this$props9, _excluded2);
|
|
431
429
|
var rowIndex = rest.rowIndex,
|
|
432
430
|
visibleRowIndex = rest.visibleRowIndex,
|
|
@@ -438,6 +436,7 @@ var EuiDataGridCell = exports.EuiDataGridCell = /*#__PURE__*/function (_Componen
|
|
|
438
436
|
|
|
439
437
|
// classNames set by EuiDataGridCellWrapper
|
|
440
438
|
var isControlColumn = cellClasses.includes('euiDataGridRowCell--controlColumn');
|
|
439
|
+
var isLastColumn = cellClasses.includes('euiDataGridRowCell--lastColumn');
|
|
441
440
|
var ariaRowIndex = pagination ? visibleRowIndex + 1 + pagination.pageSize * pagination.pageIndex : visibleRowIndex + 1;
|
|
442
441
|
var _this$state$cellProps2 = this.state.cellProps,
|
|
443
442
|
_ = _this$state$cellProps2.isExpandable,
|
|
@@ -477,7 +476,7 @@ var EuiDataGridCell = exports.EuiDataGridCell = /*#__PURE__*/function (_Componen
|
|
|
477
476
|
onKeyDown: this.handleCellKeyDown,
|
|
478
477
|
onMouseEnter: this.onMouseEnter,
|
|
479
478
|
onMouseLeave: this.onMouseLeave
|
|
480
|
-
}),
|
|
479
|
+
}), (0, _react2.jsx)(_focus_utils.HandleInteractiveChildren, {
|
|
481
480
|
cellEl: this.cellRef.current,
|
|
482
481
|
updateCellFocusContext: this.updateCellFocusContext,
|
|
483
482
|
renderFocusTrap: !isExpandable
|
|
@@ -493,7 +492,7 @@ var EuiDataGridCell = exports.EuiDataGridCell = /*#__PURE__*/function (_Componen
|
|
|
493
492
|
isControlColumn: isControlColumn,
|
|
494
493
|
rowIndex: rowIndex,
|
|
495
494
|
colIndex: colIndex
|
|
496
|
-
}))),
|
|
495
|
+
}))), isLastColumn ? _services.tabularCopyMarkers.hiddenNewline : _services.tabularCopyMarkers.hiddenTab, this.state.isFocused && (0, _react2.jsx)(CellScreenReaderDescription, {
|
|
497
496
|
columnName: (column === null || column === void 0 ? void 0 : column.displayAsText) || this.props.columnId,
|
|
498
497
|
columnIndex: colIndex + 1,
|
|
499
498
|
rowIndex: ariaRowIndex,
|
|
@@ -108,7 +108,7 @@ var euiDataGridRowCellStyles = exports.euiDataGridRowCellStyles = function euiDa
|
|
|
108
108
|
var _euiDataGridCellOutli = euiDataGridCellOutlineSelectors(),
|
|
109
109
|
outlineSelectors = _euiDataGridCellOutli.outline;
|
|
110
110
|
return {
|
|
111
|
-
euiDataGridRowCell: /*#__PURE__*/(0, _react.css)("position:relative;", outlineSelectors.show, "{", cellOutline.focusStyles, ";}", outlineSelectors.hover, "{", cellOutline.hoverStyles, ";}", outlineSelectors.focusTrapped, "{", cellOutline.hoverStyles, ";}&>[data-focus-lock-disabled]{", (0, _global_styling.logicalCSS)('height', '100%'), ";}&:where(.euiDataGridRowCell--numeric, .euiDataGridRowCell--currency){", (0, _global_styling.logicalTextAlignCSS)('right'), ";}&:where(.euiDataGridRowCell--uppercase){text-transform:uppercase;}&:where(.euiDataGridRowCell--lowercase){text-transform:lowercase;}&:where(.euiDataGridRowCell--capitalize){text-transform:capitalize;}
|
|
111
|
+
euiDataGridRowCell: /*#__PURE__*/(0, _react.css)("position:relative;", outlineSelectors.show, "{", cellOutline.focusStyles, ";}", outlineSelectors.hover, "{", cellOutline.hoverStyles, ";}", outlineSelectors.focusTrapped, "{", cellOutline.hoverStyles, ";}&>[data-focus-lock-disabled]{", (0, _global_styling.logicalCSS)('height', '100%'), ";}&:where(.euiDataGridRowCell--numeric, .euiDataGridRowCell--currency){", (0, _global_styling.logicalTextAlignCSS)('right'), ";}&:where(.euiDataGridRowCell--uppercase){text-transform:uppercase;}&:where(.euiDataGridRowCell--lowercase){text-transform:lowercase;}&:where(.euiDataGridRowCell--capitalize){text-transform:capitalize;};label:euiDataGridRowCell;"),
|
|
112
112
|
content: {
|
|
113
113
|
euiDataGridRowCell__content: _ref,
|
|
114
114
|
autoHeight: /*#__PURE__*/(0, _react.css)((0, _global_styling.logicalCSS)('height', 'auto'), ";;label:autoHeight;"),
|
|
@@ -57,7 +57,6 @@ var CellWrapper = exports.CellWrapper = /*#__PURE__*/(0, _react.memo)(function (
|
|
|
57
57
|
getCorrectRowIndex = _useContext.getCorrectRowIndex;
|
|
58
58
|
var isFirstColumn = colIndex === 0;
|
|
59
59
|
var isLastColumn = colIndex === visibleColCount - 1;
|
|
60
|
-
var isLastCopyColumn = columns.length > 0 && colIndex === leadingControlColumns.length + columns.length - 1;
|
|
61
60
|
var isLeadingControlColumn = colIndex < leadingControlColumns.length;
|
|
62
61
|
var isTrailingControlColumn = colIndex >= leadingControlColumns.length + columns.length;
|
|
63
62
|
var datacolIndex = colIndex - leadingControlColumns.length;
|
|
@@ -88,10 +87,9 @@ var CellWrapper = exports.CellWrapper = /*#__PURE__*/(0, _react.memo)(function (
|
|
|
88
87
|
rowManager: rowManager,
|
|
89
88
|
popoverContext: popoverContext,
|
|
90
89
|
pagination: pagination,
|
|
91
|
-
cellContext: cellContext
|
|
92
|
-
isLastCopyColumn: isLastCopyColumn
|
|
90
|
+
cellContext: cellContext
|
|
93
91
|
};
|
|
94
|
-
}, [colIndex, setRowHeight, visibleRowIndex, getCorrectRowIndex, interactiveCellId, style, rowHeightsOptions, rowHeightUtils, rowManager, popoverContext, pagination, cellContext, isFirstColumn, isLastColumn,
|
|
92
|
+
}, [colIndex, setRowHeight, visibleRowIndex, getCorrectRowIndex, interactiveCellId, style, rowHeightsOptions, rowHeightUtils, rowManager, popoverContext, pagination, cellContext, isFirstColumn, isLastColumn, isLeadingControlColumn, isTrailingControlColumn, textTransform]);
|
|
95
93
|
if (isLeadingControlColumn) {
|
|
96
94
|
var leadingColumn = leadingControlColumns[colIndex];
|
|
97
95
|
var id = leadingColumn.id,
|
|
@@ -49,7 +49,6 @@ var EuiDataGridFooterRow = exports.EuiDataGridFooterRow = /*#__PURE__*/(0, _reac
|
|
|
49
49
|
var cssStyles = [styles.euiDataGridFooter, gridStyles.stickyFooter && styles.sticky, gridStyles.footer === 'striped' ? visibleRowIndex % 2 !== 0 && styles.striped : styles[gridStyles.footer]];
|
|
50
50
|
var classes = (0, _classnames.default)('euiDataGridFooter', className);
|
|
51
51
|
var dataTestSubj = (0, _classnames.default)('dataGridRow', 'dataGridFooterRow', _dataTestSubj);
|
|
52
|
-
var lastCopyColumnIndex = columns.length > 0 ? leadingControlColumns.length + columns.length - 1 : -1;
|
|
53
52
|
var getCellClasses = (0, _react.useCallback)(function (columnIndex, classes) {
|
|
54
53
|
return (0, _classnames.default)('euiDataGridFooterCell', {
|
|
55
54
|
'euiDataGridRowCell--firstColumn': columnIndex === 0,
|
|
@@ -83,7 +82,6 @@ var EuiDataGridFooterRow = exports.EuiDataGridFooterRow = /*#__PURE__*/(0, _reac
|
|
|
83
82
|
width: width,
|
|
84
83
|
renderCellValue: footerCellRender !== null && footerCellRender !== void 0 ? footerCellRender : renderEmpty,
|
|
85
84
|
isExpandable: false,
|
|
86
|
-
isLastCopyColumn: i === lastCopyColumnIndex,
|
|
87
85
|
className: getCellClasses(i, (0, _classnames.default)('euiDataGridRowCell--controlColumn', footerCellProps === null || footerCellProps === void 0 ? void 0 : footerCellProps.className))
|
|
88
86
|
}));
|
|
89
87
|
}), columns.map(function (_ref3, i) {
|
|
@@ -101,7 +99,6 @@ var EuiDataGridFooterRow = exports.EuiDataGridFooterRow = /*#__PURE__*/(0, _reac
|
|
|
101
99
|
renderCellValue: renderCellValue,
|
|
102
100
|
renderCellPopover: renderCellPopover,
|
|
103
101
|
isExpandable: true,
|
|
104
|
-
isLastCopyColumn: columnPosition === lastCopyColumnIndex,
|
|
105
102
|
className: getCellClasses(columnPosition)
|
|
106
103
|
}));
|
|
107
104
|
}), trailingControlColumns.map(function (_ref4, i) {
|
|
@@ -117,7 +114,6 @@ var EuiDataGridFooterRow = exports.EuiDataGridFooterRow = /*#__PURE__*/(0, _reac
|
|
|
117
114
|
width: width,
|
|
118
115
|
renderCellValue: footerCellRender !== null && footerCellRender !== void 0 ? footerCellRender : renderEmpty,
|
|
119
116
|
isExpandable: false,
|
|
120
|
-
isLastCopyColumn: colIndex === lastCopyColumnIndex,
|
|
121
117
|
className: getCellClasses(colIndex, (0, _classnames.default)('euiDataGridRowCell--controlColumn', footerCellProps === null || footerCellProps === void 0 ? void 0 : footerCellProps.className))
|
|
122
118
|
}));
|
|
123
119
|
}));
|