@elastic/eui 121.0.0 → 122.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 +37 -37
- package/es/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
- package/es/components/datagrid/body/cell/data_grid_cell.js +8 -5
- package/es/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
- package/es/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
- package/es/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
- package/es/components/datagrid/body/header/column_resizer.js +74 -87
- package/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
- package/es/components/datagrid/body/header/data_grid_header_cell.js +1 -0
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +9 -3
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
- package/es/components/datagrid/controls/keyboard_shortcuts.js +17 -1
- package/es/components/datagrid/data_grid.js +2 -0
- package/es/components/datagrid/utils/copy_focused_cell.js +34 -0
- package/es/components/filter_group/filter_group.a11y.js +1 -1
- package/es/components/form/super_select/super_select.js +247 -351
- package/es/components/list_item_layout/_list_item_layout.js +12 -0
- package/es/components/selectable/selectable_list/selectable_list_item.js +9 -7
- package/eui.d.ts +69 -95
- package/i18ntokens.json +608 -554
- package/lib/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
- package/lib/components/datagrid/body/cell/data_grid_cell.js +8 -5
- package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +1 -1
- package/lib/components/datagrid/body/cell/data_grid_cell_wrapper.js +4 -2
- package/lib/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
- package/lib/components/datagrid/body/header/column_resizer.js +73 -85
- package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +1 -0
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +9 -3
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -1
- package/lib/components/datagrid/controls/keyboard_shortcuts.js +17 -1
- package/lib/components/datagrid/data_grid.js +2 -0
- package/lib/components/datagrid/utils/copy_focused_cell.js +39 -0
- package/lib/components/filter_group/filter_group.a11y.js +1 -1
- package/lib/components/form/super_select/super_select.js +253 -355
- package/lib/components/list_item_layout/_list_item_layout.js +12 -0
- package/lib/components/selectable/selectable_list/selectable_list_item.js +9 -7
- package/optimize/es/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
- package/optimize/es/components/datagrid/body/cell/data_grid_cell.js +5 -4
- 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 +4 -2
- package/optimize/es/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
- package/optimize/es/components/datagrid/body/header/column_resizer.js +69 -81
- package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +1 -0
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +7 -3
- 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 +17 -1
- package/optimize/es/components/datagrid/data_grid.js +2 -0
- package/optimize/es/components/datagrid/utils/copy_focused_cell.js +34 -0
- package/optimize/es/components/filter_group/filter_group.a11y.js +1 -1
- package/optimize/es/components/form/super_select/super_select.js +242 -265
- package/optimize/es/components/selectable/selectable_list/selectable_list_item.js +9 -7
- package/optimize/lib/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
- package/optimize/lib/components/datagrid/body/cell/data_grid_cell.js +5 -4
- 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 +4 -2
- package/optimize/lib/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
- package/optimize/lib/components/datagrid/body/header/column_resizer.js +69 -79
- package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +1 -0
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +7 -3
- 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 +17 -1
- package/optimize/lib/components/datagrid/data_grid.js +2 -0
- package/optimize/lib/components/datagrid/utils/copy_focused_cell.js +39 -0
- package/optimize/lib/components/filter_group/filter_group.a11y.js +1 -1
- package/optimize/lib/components/form/super_select/super_select.js +243 -265
- package/optimize/lib/components/selectable/selectable_list/selectable_list_item.js +9 -7
- package/package.json +2 -2
- package/test-env/components/combo_box/combo_box_options_list/combo_box_options_list.js +8 -2
- package/test-env/components/datagrid/body/cell/data_grid_cell.js +8 -5
- 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 +4 -2
- package/test-env/components/datagrid/body/footer/data_grid_footer_row.js +4 -0
- package/test-env/components/datagrid/body/header/column_resizer.js +69 -79
- package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +2 -1
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +1 -0
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +9 -3
- 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 +17 -1
- package/test-env/components/datagrid/data_grid.js +2 -0
- package/test-env/components/datagrid/utils/copy_focused_cell.js +16 -0
- package/test-env/components/filter_group/filter_group.a11y.js +1 -1
- package/test-env/components/form/super_select/super_select.js +243 -345
- package/test-env/components/list_item_layout/_list_item_layout.js +12 -0
- package/test-env/components/selectable/selectable_list/selectable_list_item.js +9 -7
|
@@ -7,15 +7,9 @@ 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"));
|
|
10
11
|
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"));
|
|
17
12
|
var _react = _interopRequireWildcard(require("react"));
|
|
18
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
20
14
|
var _services = require("../../../services");
|
|
21
15
|
var _i18n = require("../../i18n");
|
|
@@ -25,367 +19,271 @@ var _super_select_control = require("./super_select_control");
|
|
|
25
19
|
var _super_select_item = require("./super_select_item");
|
|
26
20
|
var _super_select = require("./super_select.styles");
|
|
27
21
|
var _react2 = require("@emotion/react");
|
|
28
|
-
var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "isOpen", "isInvalid", "itemClassName", "fullWidth", "popoverProps", "compressed"],
|
|
22
|
+
var _excluded = ["className", "options", "valueOfSelected", "placeholder", "onChange", "onFocus", "onBlur", "isOpen", "isInvalid", "itemClassName", "fullWidth", "popoverProps", "compressed", "isLoading"],
|
|
29
23
|
_excluded2 = ["value", "dropdownDisplay", "inputDisplay", "disabled"];
|
|
30
|
-
|
|
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; })(); } /*
|
|
24
|
+
/*
|
|
34
25
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
35
26
|
* or more contributor license agreements. Licensed under the Elastic License
|
|
36
27
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
37
28
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
38
29
|
* Side Public License, v 1.
|
|
39
30
|
*/
|
|
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; }
|
|
40
33
|
var ShiftDirection = /*#__PURE__*/function (ShiftDirection) {
|
|
41
34
|
ShiftDirection["BACK"] = "back";
|
|
42
35
|
ShiftDirection["FORWARD"] = "forward";
|
|
43
36
|
return ShiftDirection;
|
|
44
|
-
}(ShiftDirection || {});
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
37
|
+
}(ShiftDirection || {}); // Runs synchronously on the client before paint, so the mount flag is always
|
|
38
|
+
// set before an interaction can schedule the deferred focus in `openPopover`.
|
|
39
|
+
var useMountEffect = typeof document === 'undefined' ? _react.useEffect : _react.useLayoutEffect;
|
|
40
|
+
var EuiSuperSelectInner = function EuiSuperSelectInner(_ref, ref) {
|
|
41
|
+
var _options$currentIndex;
|
|
42
|
+
var className = _ref.className,
|
|
43
|
+
options = _ref.options,
|
|
44
|
+
valueOfSelected = _ref.valueOfSelected,
|
|
45
|
+
placeholder = _ref.placeholder,
|
|
46
|
+
onChange = _ref.onChange,
|
|
47
|
+
onFocus = _ref.onFocus,
|
|
48
|
+
onBlur = _ref.onBlur,
|
|
49
|
+
isOpen = _ref.isOpen,
|
|
50
|
+
_ref$isInvalid = _ref.isInvalid,
|
|
51
|
+
isInvalid = _ref$isInvalid === void 0 ? false : _ref$isInvalid,
|
|
52
|
+
itemClassName = _ref.itemClassName,
|
|
53
|
+
_ref$fullWidth = _ref.fullWidth,
|
|
54
|
+
fullWidth = _ref$fullWidth === void 0 ? false : _ref$fullWidth,
|
|
55
|
+
popoverProps = _ref.popoverProps,
|
|
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;
|
|
63
88
|
});
|
|
64
|
-
|
|
65
|
-
|
|
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;
|
|
89
|
+
var candidateIndex = valueOfSelected != null && indexOfSelected >= 0 ? indexOfSelected : 0;
|
|
90
|
+
var initialIndex = candidateIndex;
|
|
73
91
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
92
|
+
// If the item is disabled, find the first focusable item going forward
|
|
93
|
+
while (initialIndex < options.length && (_options$initialIndex = options[initialIndex]) !== null && _options$initialIndex !== void 0 && _options$initialIndex.disabled) {
|
|
94
|
+
var _options$initialIndex;
|
|
95
|
+
initialIndex++;
|
|
96
|
+
}
|
|
97
|
+
if (initialIndex >= options.length) {
|
|
98
|
+
initialIndex = candidateIndex;
|
|
99
|
+
}
|
|
100
|
+
setIsPopoverOpen(options.length > 0);
|
|
101
|
+
setCurrentIndex(initialIndex);
|
|
102
|
+
requestAnimationFrame(function () {
|
|
86
103
|
requestAnimationFrame(function () {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
});
|
|
104
|
+
if (!isMounted.current) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
focusItemAt(initialIndex);
|
|
108
|
+
if (onFocus) {
|
|
109
|
+
onFocus();
|
|
110
|
+
}
|
|
96
111
|
});
|
|
97
112
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
});
|
|
113
|
+
}, [options, valueOfSelected, onFocus, focusItemAt]);
|
|
114
|
+
var closePopover = (0, _react.useCallback)(function () {
|
|
115
|
+
setIsPopoverOpen(false);
|
|
116
|
+
setCurrentIndex(-1);
|
|
103
117
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
});
|
|
109
|
-
if (_this.props.onBlur) {
|
|
110
|
-
_this.props.onBlur();
|
|
111
|
-
}
|
|
118
|
+
// Refocus back to the toggling control button on popover close
|
|
119
|
+
requestAnimationFrame(function () {
|
|
120
|
+
var _controlButtonRef$cur;
|
|
121
|
+
(_controlButtonRef$cur = controlButtonRef.current) === null || _controlButtonRef$cur === void 0 || _controlButtonRef$cur.focus();
|
|
112
122
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
if (onBlur) {
|
|
124
|
+
onBlur();
|
|
125
|
+
}
|
|
126
|
+
}, [onBlur]);
|
|
127
|
+
(0, _react.useImperativeHandle)(ref, function () {
|
|
128
|
+
return {
|
|
129
|
+
openPopover: openPopover,
|
|
130
|
+
closePopover: closePopover
|
|
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
|
|
122
151
|
event.preventDefault();
|
|
123
152
|
event.stopPropagation();
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}, {
|
|
165
|
-
key: "componentWillUnmount",
|
|
166
|
-
value: function componentWillUnmount() {
|
|
167
|
-
this._isMounted = false;
|
|
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:
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
event.stopPropagation();
|
|
169
|
+
shiftFocus(ShiftDirection.FORWARD);
|
|
170
|
+
break;
|
|
168
171
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
(
|
|
172
|
+
};
|
|
173
|
+
var shiftFocus = function shiftFocus(direction) {
|
|
174
|
+
if (currentIndex === -1) {
|
|
175
|
+
// somehow the select options has lost focus
|
|
176
|
+
focusItemAt(0);
|
|
177
|
+
setCurrentIndex(0);
|
|
178
|
+
return;
|
|
174
179
|
}
|
|
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
|
-
});
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
180
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
});
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
nextIndex += step;
|
|
181
|
+
// Note: this component purposely does not cycle arrow key navigation
|
|
182
|
+
// to match native <select> elements
|
|
183
|
+
var step = direction === ShiftDirection.BACK ? -1 : 1;
|
|
184
|
+
var nextIndex = currentIndex + step;
|
|
185
|
+
while (nextIndex >= 0 && nextIndex < options.length) {
|
|
186
|
+
var _options$nextIndex;
|
|
187
|
+
if (!((_options$nextIndex = options[nextIndex]) !== null && _options$nextIndex !== void 0 && _options$nextIndex.disabled)) {
|
|
188
|
+
focusItemAt(nextIndex);
|
|
189
|
+
setCurrentIndex(nextIndex);
|
|
190
|
+
return;
|
|
203
191
|
}
|
|
192
|
+
nextIndex += step;
|
|
204
193
|
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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
|
-
});
|
|
194
|
+
};
|
|
195
|
+
useMountEffect(function () {
|
|
196
|
+
isMounted.current = true;
|
|
197
|
+
if (isOpen) {
|
|
198
|
+
openPopover();
|
|
304
199
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
};
|
|
200
|
+
return function () {
|
|
201
|
+
isMounted.current = false;
|
|
202
|
+
};
|
|
203
|
+
// The class lifecycle this replaces only ran when the component mounted.
|
|
204
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
205
|
+
}, []);
|
|
206
|
+
var popoverClasses = (0, _classnames.default)('euiSuperSelect', popoverProps === null || popoverProps === void 0 ? void 0 : popoverProps.className);
|
|
207
|
+
var button = (0, _react2.jsx)(_super_select_control.EuiSuperSelectControl, (0, _extends2.default)({
|
|
208
|
+
options: options,
|
|
209
|
+
value: valueOfSelected,
|
|
210
|
+
placeholder: placeholder,
|
|
211
|
+
onClick: isPopoverOpen ? closePopover : openPopover,
|
|
212
|
+
onKeyDown: onSelectKeyDown,
|
|
213
|
+
onFocus: onFocus,
|
|
214
|
+
onBlur: onBlur,
|
|
215
|
+
className: className,
|
|
216
|
+
fullWidth: fullWidth,
|
|
217
|
+
isInvalid: isInvalid,
|
|
218
|
+
compressed: compressed,
|
|
219
|
+
isLoading: isLoading
|
|
220
|
+
}, rest, {
|
|
221
|
+
buttonRef: controlButtonRef,
|
|
222
|
+
isDropdownOpen: isPopoverOpen
|
|
223
|
+
}));
|
|
224
|
+
var items = options.map(function (option, index) {
|
|
225
|
+
var value = option.value,
|
|
226
|
+
dropdownDisplay = option.dropdownDisplay,
|
|
227
|
+
inputDisplay = option.inputDisplay,
|
|
228
|
+
disabled = option.disabled,
|
|
229
|
+
optionRest = (0, _objectWithoutProperties2.default)(option, _excluded2);
|
|
230
|
+
if (value == null) return;
|
|
231
|
+
return (0, _react2.jsx)(_super_select_item.EuiSuperSelectItem, (0, _extends2.default)({
|
|
232
|
+
key: index
|
|
233
|
+
/* NOTE: This should rather use "li" to align select-like behavior. But the current
|
|
234
|
+
implementation relies on the interactive and focusable item for the navigation.
|
|
235
|
+
This will require additional refactoring to adjust but we might want to decide first
|
|
236
|
+
if the effort is worth it, considering the unification plans for selection components
|
|
237
|
+
as part of OneSelect (https://github.com/elastic/eui/issues/8808).
|
|
238
|
+
*/,
|
|
239
|
+
element: "button",
|
|
240
|
+
id: String(value),
|
|
241
|
+
className: itemClassName,
|
|
242
|
+
checked: valueOfSelected === value ? 'on' : undefined,
|
|
243
|
+
isSelected: valueOfSelected === value,
|
|
244
|
+
isFocused: currentIndex === index,
|
|
245
|
+
isSingleSelection: true,
|
|
246
|
+
isDisabled: disabled,
|
|
247
|
+
textWrap: "wrap",
|
|
248
|
+
onClick: function onClick() {
|
|
249
|
+
return itemClicked(value);
|
|
250
|
+
},
|
|
251
|
+
onKeyDown: onItemKeyDown,
|
|
252
|
+
ref: function ref(node) {
|
|
253
|
+
return setItemNode(node, index);
|
|
254
|
+
},
|
|
255
|
+
"aria-selected": valueOfSelected === value
|
|
256
|
+
}, optionRest), dropdownDisplay || inputDisplay);
|
|
257
|
+
});
|
|
258
|
+
var ariaActiveDescendant = ((_options$currentIndex = options[currentIndex]) === null || _options$currentIndex === void 0 ? void 0 : _options$currentIndex.value) != null ? String(options[currentIndex].value) : undefined;
|
|
259
|
+
return (0, _react2.jsx)(_popover.EuiInputPopover, (0, _extends2.default)({
|
|
260
|
+
closePopover: closePopover,
|
|
261
|
+
panelPaddingSize: "none"
|
|
262
|
+
}, popoverProps, {
|
|
263
|
+
className: popoverClasses,
|
|
264
|
+
isOpen: isOpen || isPopoverOpen,
|
|
265
|
+
input: button,
|
|
266
|
+
fullWidth: fullWidth,
|
|
267
|
+
disableFocusTrap: true // This component handles its own focus manually
|
|
268
|
+
}), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", {
|
|
269
|
+
id: describedById
|
|
270
|
+
}, (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
271
|
+
token: "euiSuperSelect.screenReaderAnnouncement",
|
|
272
|
+
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."
|
|
273
|
+
}))), (0, _react2.jsx)(_i18n.EuiI18n, {
|
|
274
|
+
token: "euiSuperSelect.ariaLabel",
|
|
275
|
+
default: "Select listbox"
|
|
276
|
+
}, function (ariaLabel) {
|
|
277
|
+
return (0, _react2.jsx)("div", {
|
|
278
|
+
"aria-label": ariaLabel,
|
|
279
|
+
"aria-describedby": describedById,
|
|
280
|
+
css: styles.euiSuperSelect__listbox,
|
|
281
|
+
className: "euiSuperSelect__listbox eui-scrollBar",
|
|
282
|
+
role: "listbox",
|
|
283
|
+
"aria-activedescendant": ariaActiveDescendant,
|
|
284
|
+
tabIndex: 0
|
|
285
|
+
}, items);
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
var EuiSuperSelect = exports.EuiSuperSelect = /*#__PURE__*/(0, _react.forwardRef)(EuiSuperSelectInner);
|
|
289
|
+
EuiSuperSelect.displayName = 'EuiSuperSelect';
|
|
@@ -427,6 +427,18 @@ EuiListItemLayout.propTypes = {
|
|
|
427
427
|
"data-test-subj": _propTypes.default.string,
|
|
428
428
|
css: _propTypes.default.any
|
|
429
429
|
}),
|
|
430
|
+
/**
|
|
431
|
+
* Props applied to the label text element.
|
|
432
|
+
*/
|
|
433
|
+
/**
|
|
434
|
+
* Props applied to the label text element.
|
|
435
|
+
*/
|
|
436
|
+
/**
|
|
437
|
+
* Props applied to the label text element.
|
|
438
|
+
*/
|
|
439
|
+
/**
|
|
440
|
+
* Props applied to the label text element.
|
|
441
|
+
*/
|
|
430
442
|
textProps: _propTypes.default.shape({
|
|
431
443
|
className: _propTypes.default.string,
|
|
432
444
|
"aria-label": _propTypes.default.string,
|