@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
|
@@ -7,9 +7,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
exports.EuiSuperSelect = void 0;
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
10
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
14
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
15
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
17
|
var _react = _interopRequireWildcard(require("react"));
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
19
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
14
20
|
var _services = require("../../../services");
|
|
15
21
|
var _i18n = require("../../i18n");
|
|
@@ -19,271 +25,367 @@ var _super_select_control = require("./super_select_control");
|
|
|
19
25
|
var _super_select_item = require("./super_select_item");
|
|
20
26
|
var _super_select = require("./super_select.styles");
|
|
21
27
|
var _react2 = require("@emotion/react");
|
|
22
|
-
var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "
|
|
28
|
+
var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "isOpen", "isInvalid", "itemClassName", "fullWidth", "popoverProps", "compressed"],
|
|
23
29
|
_excluded2 = ["value", "dropdownDisplay", "inputDisplay", "disabled"];
|
|
24
|
-
|
|
30
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
31
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
32
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
33
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /*
|
|
25
34
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
26
35
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
27
36
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
28
37
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
29
38
|
* Side Public License, v 1.
|
|
30
39
|
*/
|
|
31
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
32
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
33
40
|
var ShiftDirection = /*#__PURE__*/function (ShiftDirection) {
|
|
34
41
|
ShiftDirection["BACK"] = "back";
|
|
35
42
|
ShiftDirection["FORWARD"] = "forward";
|
|
36
43
|
return ShiftDirection;
|
|
37
|
-
}(ShiftDirection || {});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
_ref$compressed = _ref.compressed,
|
|
57
|
-
compressed = _ref$compressed === void 0 ? false : _ref$compressed,
|
|
58
|
-
_ref$isLoading = _ref.isLoading,
|
|
59
|
-
isLoading = _ref$isLoading === void 0 ? false : _ref$isLoading,
|
|
60
|
-
rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
61
|
-
var styles = (0, _services.useEuiMemoizedStyles)(_super_select.euiSuperSelectStyles);
|
|
62
|
-
var itemNodes = (0, _react.useRef)([]);
|
|
63
|
-
var isMounted = (0, _react.useRef)(false);
|
|
64
|
-
var controlButtonRef = (0, _react.useRef)(null);
|
|
65
|
-
var _useState = (0, _react.useState)(function () {
|
|
66
|
-
return (0, _services.htmlIdGenerator)('euiSuperSelect_')('_screenreaderDescribeId');
|
|
67
|
-
}),
|
|
68
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
|
69
|
-
describedById = _useState2[0];
|
|
70
|
-
var _useState3 = (0, _react.useState)(isOpen || false),
|
|
71
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
72
|
-
isPopoverOpen = _useState4[0],
|
|
73
|
-
setIsPopoverOpen = _useState4[1];
|
|
74
|
-
var _useState5 = (0, _react.useState)(0),
|
|
75
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
76
|
-
currentIndex = _useState6[0],
|
|
77
|
-
setCurrentIndex = _useState6[1];
|
|
78
|
-
var setItemNode = function setItemNode(node, index) {
|
|
79
|
-
itemNodes.current[index] = node;
|
|
80
|
-
};
|
|
81
|
-
var focusItemAt = (0, _react.useCallback)(function (index) {
|
|
82
|
-
var _itemNodes$current$in;
|
|
83
|
-
(_itemNodes$current$in = itemNodes.current[index]) === null || _itemNodes$current$in === void 0 || _itemNodes$current$in.focus();
|
|
84
|
-
}, []);
|
|
85
|
-
var openPopover = (0, _react.useCallback)(function () {
|
|
86
|
-
var indexOfSelected = options.findIndex(function (option) {
|
|
87
|
-
return (option === null || option === void 0 ? void 0 : option.value) === valueOfSelected;
|
|
44
|
+
}(ShiftDirection || {});
|
|
45
|
+
var EuiSuperSelect = exports.EuiSuperSelect = /*#__PURE__*/function (_Component) {
|
|
46
|
+
function EuiSuperSelect() {
|
|
47
|
+
var _this;
|
|
48
|
+
(0, _classCallCheck2.default)(this, EuiSuperSelect);
|
|
49
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
50
|
+
args[_key] = arguments[_key];
|
|
51
|
+
}
|
|
52
|
+
_this = _callSuper(this, EuiSuperSelect, [].concat(args));
|
|
53
|
+
(0, _defineProperty2.default)(_this, "itemNodes", []);
|
|
54
|
+
(0, _defineProperty2.default)(_this, "_isMounted", false);
|
|
55
|
+
(0, _defineProperty2.default)(_this, "controlButtonRef", /*#__PURE__*/(0, _react.createRef)());
|
|
56
|
+
(0, _defineProperty2.default)(_this, "describedById", (0, _services.htmlIdGenerator)('euiSuperSelect_')('_screenreaderDescribeId'));
|
|
57
|
+
(0, _defineProperty2.default)(_this, "state", {
|
|
58
|
+
isPopoverOpen: _this.props.isOpen || false,
|
|
59
|
+
currentIndex: 0
|
|
60
|
+
});
|
|
61
|
+
(0, _defineProperty2.default)(_this, "setItemNode", function (node, index) {
|
|
62
|
+
_this.itemNodes[index] = node;
|
|
88
63
|
});
|
|
89
|
-
|
|
90
|
-
|
|
64
|
+
(0, _defineProperty2.default)(_this, "openPopover", function () {
|
|
65
|
+
var _this$props = _this.props,
|
|
66
|
+
options = _this$props.options,
|
|
67
|
+
valueOfSelected = _this$props.valueOfSelected;
|
|
68
|
+
var indexOfSelected = options.findIndex(function (option) {
|
|
69
|
+
return (option === null || option === void 0 ? void 0 : option.value) === valueOfSelected;
|
|
70
|
+
});
|
|
71
|
+
var candidateIndex = valueOfSelected != null && indexOfSelected >= 0 ? indexOfSelected : 0;
|
|
72
|
+
var initialIndex = candidateIndex;
|
|
91
73
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
74
|
+
// If the item is disabled, find the first focusable item going forward
|
|
75
|
+
while (initialIndex < options.length && (_options$initialIndex = options[initialIndex]) !== null && _options$initialIndex !== void 0 && _options$initialIndex.disabled) {
|
|
76
|
+
var _options$initialIndex;
|
|
77
|
+
initialIndex++;
|
|
78
|
+
}
|
|
79
|
+
if (initialIndex >= options.length) {
|
|
80
|
+
initialIndex = candidateIndex;
|
|
81
|
+
}
|
|
82
|
+
_this.setState({
|
|
83
|
+
isPopoverOpen: options.length > 0,
|
|
84
|
+
currentIndex: initialIndex
|
|
85
|
+
});
|
|
103
86
|
requestAnimationFrame(function () {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
onFocus
|
|
110
|
-
|
|
87
|
+
requestAnimationFrame(function () {
|
|
88
|
+
if (!_this._isMounted) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
_this.focusItemAt(initialIndex);
|
|
92
|
+
if (_this.props.onFocus) {
|
|
93
|
+
_this.props.onFocus();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
111
96
|
});
|
|
112
97
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
98
|
+
(0, _defineProperty2.default)(_this, "closePopover", function () {
|
|
99
|
+
_this.setState({
|
|
100
|
+
isPopoverOpen: false,
|
|
101
|
+
currentIndex: -1
|
|
102
|
+
});
|
|
117
103
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
104
|
+
// Refocus back to the toggling control button on popover close
|
|
105
|
+
requestAnimationFrame(function () {
|
|
106
|
+
var _this$controlButtonRe;
|
|
107
|
+
(_this$controlButtonRe = _this.controlButtonRef.current) === null || _this$controlButtonRe === void 0 || _this$controlButtonRe.focus();
|
|
108
|
+
});
|
|
109
|
+
if (_this.props.onBlur) {
|
|
110
|
+
_this.props.onBlur();
|
|
111
|
+
}
|
|
122
112
|
});
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
}, [openPopover, closePopover]);
|
|
133
|
-
var itemClicked = function itemClicked(value) {
|
|
134
|
-
closePopover();
|
|
135
|
-
if (onChange) {
|
|
136
|
-
onChange(value);
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
var onSelectKeyDown = function onSelectKeyDown(event) {
|
|
140
|
-
// Mimic the ways native `<select>`s can be opened via keypress
|
|
141
|
-
if (event.key === _services.keys.ARROW_UP || event.key === _services.keys.ARROW_DOWN || event.key === _services.keys.SPACE) {
|
|
142
|
-
event.preventDefault();
|
|
143
|
-
event.stopPropagation();
|
|
144
|
-
openPopover();
|
|
145
|
-
}
|
|
146
|
-
};
|
|
147
|
-
var onItemKeyDown = function onItemKeyDown(event) {
|
|
148
|
-
switch (event.key) {
|
|
149
|
-
case _services.keys.ESCAPE:
|
|
150
|
-
// close the popover and prevent ancestors from handling
|
|
151
|
-
event.preventDefault();
|
|
152
|
-
event.stopPropagation();
|
|
153
|
-
closePopover();
|
|
154
|
-
break;
|
|
155
|
-
case _services.keys.TAB:
|
|
156
|
-
// Mimic native `<select>` behavior, which selects an item on tab press
|
|
157
|
-
event.preventDefault();
|
|
158
|
-
event.stopPropagation();
|
|
159
|
-
event.target.click();
|
|
160
|
-
break;
|
|
161
|
-
case _services.keys.ARROW_UP:
|
|
162
|
-
event.preventDefault();
|
|
163
|
-
event.stopPropagation();
|
|
164
|
-
shiftFocus(ShiftDirection.BACK);
|
|
165
|
-
break;
|
|
166
|
-
case _services.keys.ARROW_DOWN:
|
|
113
|
+
(0, _defineProperty2.default)(_this, "itemClicked", function (value) {
|
|
114
|
+
_this.closePopover();
|
|
115
|
+
if (_this.props.onChange) {
|
|
116
|
+
_this.props.onChange(value);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
(0, _defineProperty2.default)(_this, "onSelectKeyDown", function (event) {
|
|
120
|
+
// Mimic the ways native `<select>`s can be opened via keypress
|
|
121
|
+
if (event.key === _services.keys.ARROW_UP || event.key === _services.keys.ARROW_DOWN || event.key === _services.keys.SPACE) {
|
|
167
122
|
event.preventDefault();
|
|
168
123
|
event.stopPropagation();
|
|
169
|
-
|
|
170
|
-
|
|
124
|
+
_this.openPopover();
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
(0, _defineProperty2.default)(_this, "onItemKeyDown", function (event) {
|
|
128
|
+
switch (event.key) {
|
|
129
|
+
case _services.keys.ESCAPE:
|
|
130
|
+
// close the popover and prevent ancestors from handling
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
event.stopPropagation();
|
|
133
|
+
_this.closePopover();
|
|
134
|
+
break;
|
|
135
|
+
case _services.keys.TAB:
|
|
136
|
+
// Mimic native `<select>` behavior, which selects an item on tab press
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
event.stopPropagation();
|
|
139
|
+
event.target.click();
|
|
140
|
+
break;
|
|
141
|
+
case _services.keys.ARROW_UP:
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
event.stopPropagation();
|
|
144
|
+
_this.shiftFocus(ShiftDirection.BACK);
|
|
145
|
+
break;
|
|
146
|
+
case _services.keys.ARROW_DOWN:
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
event.stopPropagation();
|
|
149
|
+
_this.shiftFocus(ShiftDirection.FORWARD);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return _this;
|
|
154
|
+
}
|
|
155
|
+
(0, _inherits2.default)(EuiSuperSelect, _Component);
|
|
156
|
+
return (0, _createClass2.default)(EuiSuperSelect, [{
|
|
157
|
+
key: "componentDidMount",
|
|
158
|
+
value: function componentDidMount() {
|
|
159
|
+
this._isMounted = true;
|
|
160
|
+
if (this.props.isOpen) {
|
|
161
|
+
this.openPopover();
|
|
162
|
+
}
|
|
171
163
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
focusItemAt(0);
|
|
177
|
-
setCurrentIndex(0);
|
|
178
|
-
return;
|
|
164
|
+
}, {
|
|
165
|
+
key: "componentWillUnmount",
|
|
166
|
+
value: function componentWillUnmount() {
|
|
167
|
+
this._isMounted = false;
|
|
179
168
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
169
|
+
}, {
|
|
170
|
+
key: "focusItemAt",
|
|
171
|
+
value: function focusItemAt(index) {
|
|
172
|
+
var _this$itemNodes$index;
|
|
173
|
+
(_this$itemNodes$index = this.itemNodes[index]) === null || _this$itemNodes$index === void 0 || _this$itemNodes$index.focus();
|
|
174
|
+
}
|
|
175
|
+
}, {
|
|
176
|
+
key: "shiftFocus",
|
|
177
|
+
value: function shiftFocus(direction) {
|
|
178
|
+
var options = this.props.options;
|
|
179
|
+
var currentIndex = this.state.currentIndex;
|
|
180
|
+
if (currentIndex === -1) {
|
|
181
|
+
// somehow the select options has lost focus
|
|
182
|
+
this.focusItemAt(0);
|
|
183
|
+
this.setState({
|
|
184
|
+
currentIndex: 0
|
|
185
|
+
});
|
|
190
186
|
return;
|
|
191
187
|
}
|
|
192
|
-
|
|
188
|
+
|
|
189
|
+
// Note: this component purposely does not cycle arrow key navigation
|
|
190
|
+
// to match native <select> elements
|
|
191
|
+
var step = direction === ShiftDirection.BACK ? -1 : 1;
|
|
192
|
+
var nextIndex = currentIndex + step;
|
|
193
|
+
while (nextIndex >= 0 && nextIndex < options.length) {
|
|
194
|
+
var _options$nextIndex;
|
|
195
|
+
if (!((_options$nextIndex = options[nextIndex]) !== null && _options$nextIndex !== void 0 && _options$nextIndex.disabled)) {
|
|
196
|
+
this.focusItemAt(nextIndex);
|
|
197
|
+
this.setState({
|
|
198
|
+
currentIndex: nextIndex
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
nextIndex += step;
|
|
203
|
+
}
|
|
193
204
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
205
|
+
}, {
|
|
206
|
+
key: "render",
|
|
207
|
+
value: function render() {
|
|
208
|
+
var _this2 = this,
|
|
209
|
+
_options$this$state$c;
|
|
210
|
+
var _this$props2 = this.props,
|
|
211
|
+
className = _this$props2.className,
|
|
212
|
+
options = _this$props2.options,
|
|
213
|
+
valueOfSelected = _this$props2.valueOfSelected,
|
|
214
|
+
placeholder = _this$props2.placeholder,
|
|
215
|
+
onChange = _this$props2.onChange,
|
|
216
|
+
isOpen = _this$props2.isOpen,
|
|
217
|
+
isInvalid = _this$props2.isInvalid,
|
|
218
|
+
itemClassName = _this$props2.itemClassName,
|
|
219
|
+
fullWidth = _this$props2.fullWidth,
|
|
220
|
+
popoverProps = _this$props2.popoverProps,
|
|
221
|
+
compressed = _this$props2.compressed,
|
|
222
|
+
rest = (0, _objectWithoutProperties2.default)(_this$props2, _excluded);
|
|
223
|
+
var popoverClasses = (0, _classnames.default)('euiSuperSelect', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className);
|
|
224
|
+
var button = (0, _react2.jsx)(_super_select_control.EuiSuperSelectControl, (0, _extends2.default)({
|
|
225
|
+
options: options,
|
|
226
|
+
value: valueOfSelected,
|
|
227
|
+
placeholder: placeholder,
|
|
228
|
+
onClick: this.state.isPopoverOpen ? this.closePopover : this.openPopover,
|
|
229
|
+
onKeyDown: this.onSelectKeyDown,
|
|
230
|
+
className: className,
|
|
231
|
+
fullWidth: fullWidth,
|
|
232
|
+
isInvalid: isInvalid,
|
|
233
|
+
compressed: compressed
|
|
234
|
+
}, rest, {
|
|
235
|
+
buttonRef: this.controlButtonRef,
|
|
236
|
+
isDropdownOpen: this.state.isPopoverOpen
|
|
237
|
+
}));
|
|
238
|
+
var items = options.map(function (option, index) {
|
|
239
|
+
var value = option.value,
|
|
240
|
+
dropdownDisplay = option.dropdownDisplay,
|
|
241
|
+
inputDisplay = option.inputDisplay,
|
|
242
|
+
disabled = option.disabled,
|
|
243
|
+
optionRest = (0, _objectWithoutProperties2.default)(option, _excluded2);
|
|
244
|
+
if (value == null) return;
|
|
245
|
+
return (0, _react2.jsx)(_super_select_item.EuiSuperSelectItem, (0, _extends2.default)({
|
|
246
|
+
key: index
|
|
247
|
+
/* NOTE: This should rather use "li" to align select-like behavior. But the current
|
|
248
|
+
implementation relies on the interactive and focusable item for the navigation.
|
|
249
|
+
This will require additional refactoring to adjust but we might want to decide first
|
|
250
|
+
if the effort is worth it, considering the unification plans for selection components
|
|
251
|
+
as part of OneSelect (https://github.com/elastic/eui/issues/8808).
|
|
252
|
+
*/,
|
|
253
|
+
element: "button",
|
|
254
|
+
id: String(value),
|
|
255
|
+
className: itemClassName,
|
|
256
|
+
checked: valueOfSelected === value ? 'on' : undefined,
|
|
257
|
+
isSelected: valueOfSelected === value,
|
|
258
|
+
isFocused: _this2.state.currentIndex === index,
|
|
259
|
+
isSingleSelection: true,
|
|
260
|
+
isDisabled: disabled,
|
|
261
|
+
textWrap: "wrap",
|
|
262
|
+
onClick: function onClick() {
|
|
263
|
+
return _this2.itemClicked(value);
|
|
264
|
+
},
|
|
265
|
+
onKeyDown: _this2.onItemKeyDown,
|
|
266
|
+
ref: function ref(node) {
|
|
267
|
+
return _this2.setItemNode(node, index);
|
|
268
|
+
},
|
|
269
|
+
"aria-selected": valueOfSelected === value
|
|
270
|
+
}, optionRest), dropdownDisplay || inputDisplay);
|
|
271
|
+
});
|
|
272
|
+
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;
|
|
273
|
+
return (0, _react2.jsx)(_services.RenderWithEuiStylesMemoizer, null, function (stylesMemoizer) {
|
|
274
|
+
var styles = stylesMemoizer(_super_select.euiSuperSelectStyles);
|
|
275
|
+
return (0, _react2.jsx)(_popover.EuiInputPopover, (0, _extends2.default)({
|
|
276
|
+
closePopover: _this2.closePopover,
|
|
277
|
+
panelPaddingSize: "none"
|
|
278
|
+
}, popoverProps, {
|
|
279
|
+
className: popoverClasses,
|
|
280
|
+
isOpen: isOpen || _this2.state.isPopoverOpen,
|
|
281
|
+
input: button,
|
|
282
|
+
fullWidth: fullWidth,
|
|
283
|
+
disableFocusTrap: true // This component handles its own focus manually
|
|
284
|
+
}), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", {
|
|
285
|
+
id: _this2.describedById
|
|
286
|
+
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
287
|
+
token: "euiSuperSelect.screenReaderAnnouncement",
|
|
288
|
+
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."
|
|
289
|
+
}))), (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
290
|
+
token: "euiSuperSelect.ariaLabel",
|
|
291
|
+
default: "Select listbox"
|
|
292
|
+
}, function (ariaLabel) {
|
|
293
|
+
return (0, _react2.jsx)("div", {
|
|
294
|
+
"aria-label": ariaLabel,
|
|
295
|
+
"aria-describedby": _this2.describedById,
|
|
296
|
+
css: styles.euiSuperSelect__listbox,
|
|
297
|
+
className: "euiSuperSelect__listbox eui-scrollBar",
|
|
298
|
+
role: "listbox",
|
|
299
|
+
"aria-activedescendant": ariaActiveDescendant,
|
|
300
|
+
tabIndex: 0
|
|
301
|
+
}, items);
|
|
302
|
+
}));
|
|
303
|
+
});
|
|
199
304
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
};
|
|
288
|
-
var EuiSuperSelect = exports.EuiSuperSelect = /*#__PURE__*/(0, _react.forwardRef)(EuiSuperSelectInner);
|
|
289
|
-
EuiSuperSelect.displayName = 'EuiSuperSelect';
|
|
305
|
+
}]);
|
|
306
|
+
}(_react.Component);
|
|
307
|
+
(0, _defineProperty2.default)(EuiSuperSelect, "defaultProps", {
|
|
308
|
+
fullWidth: false,
|
|
309
|
+
compressed: false,
|
|
310
|
+
isInvalid: false,
|
|
311
|
+
isLoading: false
|
|
312
|
+
});
|
|
313
|
+
EuiSuperSelect.propTypes = {
|
|
314
|
+
className: _propTypes.default.string,
|
|
315
|
+
"aria-label": _propTypes.default.string,
|
|
316
|
+
"data-test-subj": _propTypes.default.string,
|
|
317
|
+
css: _propTypes.default.any,
|
|
318
|
+
buttonRef: _propTypes.default.any,
|
|
319
|
+
/**
|
|
320
|
+
* @default false
|
|
321
|
+
*/
|
|
322
|
+
compressed: _propTypes.default.bool,
|
|
323
|
+
/**
|
|
324
|
+
* Expand to fill 100% of the parent.
|
|
325
|
+
* Defaults to `fullWidth` prop of `<EuiForm>`.
|
|
326
|
+
* @default false
|
|
327
|
+
*/
|
|
328
|
+
fullWidth: _propTypes.default.bool,
|
|
329
|
+
/**
|
|
330
|
+
* @default false
|
|
331
|
+
*/
|
|
332
|
+
isInvalid: _propTypes.default.bool,
|
|
333
|
+
/**
|
|
334
|
+
* @default false
|
|
335
|
+
*/
|
|
336
|
+
isLoading: _propTypes.default.bool,
|
|
337
|
+
readOnly: _propTypes.default.bool,
|
|
338
|
+
name: _propTypes.default.string,
|
|
339
|
+
/**
|
|
340
|
+
* Placeholder to display when the current selected value is empty.
|
|
341
|
+
*/
|
|
342
|
+
placeholder: _propTypes.default.oneOfType([_propTypes.default.node, _propTypes.default.node]),
|
|
343
|
+
/**
|
|
344
|
+
* Creates an input group with element(s) coming before input.
|
|
345
|
+
* `string` | `ReactElement` or an array of these
|
|
346
|
+
*/
|
|
347
|
+
prepend: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.element.isRequired]).isRequired, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.element.isRequired]).isRequired).isRequired]),
|
|
348
|
+
/**
|
|
349
|
+
* Creates an input group with element(s) coming after input.
|
|
350
|
+
* `string` | `ReactElement` or an array of these
|
|
351
|
+
*/
|
|
352
|
+
append: _propTypes.default.oneOfType([_propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.element.isRequired]).isRequired, _propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.element.isRequired]).isRequired).isRequired]),
|
|
353
|
+
/**
|
|
354
|
+
* Pass an array of options that must at least include:
|
|
355
|
+
* `value`: storing unique value of item,
|
|
356
|
+
* `inputDisplay`: what shows inside the form input when selected
|
|
357
|
+
* `dropdownDisplay` (optional): what shows for the item in the dropdown
|
|
358
|
+
*/
|
|
359
|
+
options: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
360
|
+
value: _propTypes.default.any.isRequired,
|
|
361
|
+
inputDisplay: _propTypes.default.node,
|
|
362
|
+
dropdownDisplay: _propTypes.default.node,
|
|
363
|
+
disabled: _propTypes.default.bool,
|
|
364
|
+
"data-test-subj": _propTypes.default.string
|
|
365
|
+
}).isRequired).isRequired,
|
|
366
|
+
valueOfSelected: _propTypes.default.any,
|
|
367
|
+
/**
|
|
368
|
+
* Classes for the context menu item
|
|
369
|
+
*/
|
|
370
|
+
itemClassName: _propTypes.default.string,
|
|
371
|
+
/**
|
|
372
|
+
* You must pass an `onChange` function to handle the update of the value
|
|
373
|
+
*/
|
|
374
|
+
onChange: _propTypes.default.func,
|
|
375
|
+
onFocus: _propTypes.default.func,
|
|
376
|
+
onBlur: _propTypes.default.func,
|
|
377
|
+
/**
|
|
378
|
+
* Controls whether the options are shown. Default: false
|
|
379
|
+
*/
|
|
380
|
+
isOpen: _propTypes.default.bool,
|
|
381
|
+
/**
|
|
382
|
+
* Optional props to pass to the underlying [EuiInputPopover](https://eui.elastic.co/docs/components/containers/popover/).
|
|
383
|
+
* Allows fine-grained control of the popover dropdown menu, including
|
|
384
|
+
* `repositionOnScroll` for EuiSuperSelects used within scrollable containers,
|
|
385
|
+
* and customizing popover panel styling.
|
|
386
|
+
*
|
|
387
|
+
* Does not accept a nested `popoverProps.isOpen` property - use the top level
|
|
388
|
+
* `isOpen` API instead.
|
|
389
|
+
*/
|
|
390
|
+
popoverProps: _propTypes.default.any
|
|
391
|
+
};
|