@elastic/eui 95.9.0 → 95.10.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_theme_dark.css +35 -6
- package/dist/eui_theme_dark.min.css +1 -1
- package/dist/eui_theme_light.css +35 -6
- package/dist/eui_theme_light.min.css +1 -1
- package/es/components/basic_table/in_memory_table.js +2 -1
- package/es/components/datagrid/body/cell/data_grid_cell.js +2 -0
- package/es/components/datagrid/body/cell/focus_utils.js +57 -11
- package/es/components/datagrid/body/data_grid_body.js +1 -0
- package/es/components/datagrid/body/data_grid_body_custom.js +1 -0
- package/es/components/datagrid/body/data_grid_body_virtualized.js +1 -0
- package/es/components/datagrid/body/header/data_grid_header_cell.js +92 -83
- package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +37 -22
- package/es/components/datagrid/controls/column_sorting.js +1 -0
- package/es/components/datagrid/data_grid.a11y.js +2 -0
- package/es/components/datagrid/utils/in_memory.js +1 -0
- package/es/components/date_picker/date_picker.js +32 -10
- package/es/components/date_picker/date_picker.styles.js +3 -2
- package/es/components/date_picker/date_picker_range.styles.js +1 -1
- package/es/components/form/super_select/super_select.styles.js +1 -1
- package/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +15 -8
- package/es/components/markdown_editor/plugins/markdown_default_plugins/plugins.js +21 -4
- package/es/components/markdown_editor/plugins/markdown_default_plugins/processing_plugins.js +5 -2
- package/es/components/markdown_editor/plugins/markdown_link_validator.js +8 -2
- package/es/components/search_bar/filters/field_value_selection_filter.js +171 -152
- package/es/components/search_bar/search_bar.js +2 -1
- package/es/components/search_bar/search_filters.js +2 -1
- package/eui.d.ts +138 -69
- package/i18ntokens.json +78 -42
- package/lib/components/basic_table/in_memory_table.js +2 -1
- package/lib/components/datagrid/body/cell/data_grid_cell.js +2 -0
- package/lib/components/datagrid/body/cell/focus_utils.js +58 -12
- package/lib/components/datagrid/body/data_grid_body.js +1 -0
- package/lib/components/datagrid/body/data_grid_body_custom.js +1 -0
- package/lib/components/datagrid/body/data_grid_body_virtualized.js +1 -0
- package/lib/components/datagrid/body/header/data_grid_header_cell.js +98 -88
- package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +38 -23
- package/lib/components/datagrid/controls/column_sorting.js +1 -0
- package/lib/components/datagrid/data_grid.a11y.js +2 -0
- package/lib/components/datagrid/utils/in_memory.js +1 -0
- package/lib/components/date_picker/date_picker.js +32 -10
- package/lib/components/date_picker/date_picker.styles.js +3 -2
- package/lib/components/date_picker/date_picker_range.styles.js +1 -1
- package/lib/components/form/super_select/super_select.styles.js +1 -1
- package/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +26 -17
- package/lib/components/markdown_editor/plugins/markdown_default_plugins/plugins.js +21 -6
- package/lib/components/markdown_editor/plugins/markdown_default_plugins/processing_plugins.js +5 -2
- package/lib/components/markdown_editor/plugins/markdown_link_validator.js +9 -2
- package/lib/components/search_bar/filters/field_value_selection_filter.js +170 -151
- package/lib/components/search_bar/search_bar.js +2 -1
- package/lib/components/search_bar/search_filters.js +2 -1
- package/optimize/es/components/datagrid/body/cell/focus_utils.js +55 -10
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +90 -83
- package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +33 -19
- package/optimize/es/components/datagrid/data_grid.a11y.js +2 -0
- package/optimize/es/components/date_picker/date_picker.js +15 -9
- package/optimize/es/components/date_picker/date_picker.styles.js +3 -2
- package/optimize/es/components/date_picker/date_picker_range.styles.js +1 -1
- package/optimize/es/components/form/super_select/super_select.styles.js +1 -1
- package/optimize/es/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +14 -8
- package/optimize/es/components/markdown_editor/plugins/markdown_default_plugins/plugins.js +18 -4
- package/optimize/es/components/markdown_editor/plugins/markdown_default_plugins/processing_plugins.js +5 -2
- package/optimize/es/components/markdown_editor/plugins/markdown_link_validator.js +8 -2
- package/optimize/es/components/search_bar/filters/field_value_selection_filter.js +168 -151
- package/optimize/lib/components/datagrid/body/cell/focus_utils.js +56 -11
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +92 -84
- package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +33 -19
- package/optimize/lib/components/datagrid/data_grid.a11y.js +2 -0
- package/optimize/lib/components/date_picker/date_picker.js +15 -9
- package/optimize/lib/components/date_picker/date_picker.styles.js +3 -2
- package/optimize/lib/components/date_picker/date_picker_range.styles.js +1 -1
- package/optimize/lib/components/form/super_select/super_select.styles.js +1 -1
- package/optimize/lib/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +15 -11
- package/optimize/lib/components/markdown_editor/plugins/markdown_default_plugins/plugins.js +19 -6
- package/optimize/lib/components/markdown_editor/plugins/markdown_default_plugins/processing_plugins.js +5 -2
- package/optimize/lib/components/markdown_editor/plugins/markdown_link_validator.js +9 -2
- package/optimize/lib/components/search_bar/filters/field_value_selection_filter.js +167 -150
- package/package.json +1 -1
- package/src/components/datagrid/_data_grid_data_row.scss +5 -0
- package/src/components/datagrid/body/header/_data_grid_header_row.scss +27 -5
- package/test-env/components/basic_table/in_memory_table.js +2 -1
- package/test-env/components/datagrid/body/cell/data_grid_cell.js +2 -0
- package/test-env/components/datagrid/body/cell/focus_utils.js +58 -12
- package/test-env/components/datagrid/body/data_grid_body.js +1 -0
- package/test-env/components/datagrid/body/data_grid_body_custom.js +1 -0
- package/test-env/components/datagrid/body/data_grid_body_virtualized.js +1 -0
- package/test-env/components/datagrid/body/header/data_grid_header_cell.js +93 -84
- package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +37 -22
- package/test-env/components/datagrid/controls/column_sorting.js +1 -0
- package/test-env/components/datagrid/data_grid.a11y.js +2 -0
- package/test-env/components/datagrid/utils/in_memory.js +1 -0
- package/test-env/components/date_picker/date_picker.js +32 -10
- package/test-env/components/date_picker/date_picker.styles.js +3 -2
- package/test-env/components/date_picker/date_picker_range.styles.js +1 -1
- package/test-env/components/form/super_select/super_select.styles.js +1 -1
- package/test-env/components/markdown_editor/plugins/markdown_default_plugins/parsing_plugins.js +15 -11
- package/test-env/components/markdown_editor/plugins/markdown_default_plugins/plugins.js +19 -6
- package/test-env/components/markdown_editor/plugins/markdown_default_plugins/processing_plugins.js +5 -2
- package/test-env/components/markdown_editor/plugins/markdown_link_validator.js +9 -2
- package/test-env/components/search_bar/filters/field_value_selection_filter.js +169 -151
- package/test-env/components/search_bar/search_bar.js +2 -1
- package/test-env/components/search_bar/search_filters.js +2 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
4
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
5
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
8
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
8
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
|
-
|
|
10
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
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
12
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
13
13
|
/*
|
|
@@ -18,7 +18,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
18
18
|
* Side Public License, v 1.
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import React, { Component } from 'react';
|
|
21
|
+
import React, { Component, createRef } from 'react';
|
|
22
22
|
import { RenderWithEuiTheme } from '../../../services';
|
|
23
23
|
import { isArray, isNil } from '../../../services/predicate';
|
|
24
24
|
import { EuiPopover, EuiPopoverTitle } from '../../popover';
|
|
@@ -32,7 +32,8 @@ var defaults = {
|
|
|
32
32
|
config: {
|
|
33
33
|
multiSelect: true,
|
|
34
34
|
filterWith: 'prefix',
|
|
35
|
-
searchThreshold: 10
|
|
35
|
+
searchThreshold: 10,
|
|
36
|
+
autoSortOptions: true
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
@@ -40,45 +41,132 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
40
41
|
var _this;
|
|
41
42
|
_classCallCheck(this, FieldValueSelectionFilter);
|
|
42
43
|
_this = _callSuper(this, FieldValueSelectionFilter, [props]);
|
|
43
|
-
_defineProperty(_this, "
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return function () {
|
|
51
|
-
var cachedOptions = _this.state.cachedOptions;
|
|
52
|
-
if (cachedOptions) {
|
|
53
|
-
return Promise.resolve(cachedOptions);
|
|
54
|
-
}
|
|
55
|
-
return options().then(function (opts) {
|
|
56
|
-
// If a cache time is set, populate the cache and also schedule a
|
|
57
|
-
// cache reset.
|
|
58
|
-
if (_this.props.config.cache != null && _this.props.config.cache > 0) {
|
|
44
|
+
_defineProperty(_this, "selectableClassRef", /*#__PURE__*/createRef());
|
|
45
|
+
_defineProperty(_this, "cacheTimeout", void 0);
|
|
46
|
+
_defineProperty(_this, "loadOptions", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
47
|
+
var loadedOptions, _this$props$config, options, cache, _this$state$cachedOpt, items, _this$props, query, config;
|
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
49
|
+
while (1) switch (_context.prev = _context.next) {
|
|
50
|
+
case 0:
|
|
59
51
|
_this.setState({
|
|
60
|
-
|
|
52
|
+
options: null,
|
|
53
|
+
error: null
|
|
61
54
|
});
|
|
62
|
-
|
|
55
|
+
_this$props$config = _this.props.config, options = _this$props$config.options, cache = _this$props$config.cache;
|
|
56
|
+
_context.prev = 2;
|
|
57
|
+
if (!isArray(options)) {
|
|
58
|
+
_context.next = 7;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
// Synchronous options, already loaded
|
|
62
|
+
loadedOptions = options;
|
|
63
|
+
_context.next = 16;
|
|
64
|
+
break;
|
|
65
|
+
case 7:
|
|
66
|
+
if (!((_this$state$cachedOpt = _this.state.cachedOptions) !== null && _this$state$cachedOpt !== void 0)) {
|
|
67
|
+
_context.next = 11;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
_context.t0 = _this$state$cachedOpt;
|
|
71
|
+
_context.next = 14;
|
|
72
|
+
break;
|
|
73
|
+
case 11:
|
|
74
|
+
_context.next = 13;
|
|
75
|
+
return options();
|
|
76
|
+
case 13:
|
|
77
|
+
_context.t0 = _context.sent;
|
|
78
|
+
case 14:
|
|
79
|
+
loadedOptions = _context.t0;
|
|
80
|
+
// If a cache time is set, populate the cache and schedule a cache reset
|
|
81
|
+
if (cache != null && cache > 0) {
|
|
63
82
|
_this.setState({
|
|
64
|
-
cachedOptions:
|
|
83
|
+
cachedOptions: loadedOptions
|
|
65
84
|
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
85
|
+
_this.cacheTimeout = setTimeout(function () {
|
|
86
|
+
_this.setState({
|
|
87
|
+
cachedOptions: null
|
|
88
|
+
});
|
|
89
|
+
}, cache);
|
|
90
|
+
}
|
|
91
|
+
case 16:
|
|
92
|
+
_context.next = 21;
|
|
93
|
+
break;
|
|
94
|
+
case 18:
|
|
95
|
+
_context.prev = 18;
|
|
96
|
+
_context.t1 = _context["catch"](2);
|
|
97
|
+
return _context.abrupt("return", _this.setState({
|
|
98
|
+
options: null,
|
|
99
|
+
error: 'Could not load options'
|
|
100
|
+
}));
|
|
101
|
+
case 21:
|
|
102
|
+
items = {
|
|
103
|
+
on: [],
|
|
104
|
+
off: [],
|
|
105
|
+
rest: []
|
|
106
|
+
};
|
|
107
|
+
_this$props = _this.props, query = _this$props.query, config = _this$props.config;
|
|
108
|
+
if (loadedOptions) {
|
|
109
|
+
loadedOptions.forEach(function (op) {
|
|
110
|
+
var optionField = op.field || config.field;
|
|
111
|
+
if (optionField) {
|
|
112
|
+
var clause = _this.multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
113
|
+
var checked = _this.resolveChecked(clause);
|
|
114
|
+
if (!checked) {
|
|
115
|
+
items.rest.push(op);
|
|
116
|
+
} else if (checked === 'on') {
|
|
117
|
+
items.on.push(op);
|
|
118
|
+
} else {
|
|
119
|
+
items.off.push(op);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
_this.setState({
|
|
126
|
+
error: null,
|
|
127
|
+
activeItemsCount: items.on.length,
|
|
128
|
+
options: {
|
|
129
|
+
unsorted: loadedOptions,
|
|
130
|
+
sorted: [].concat(_toConsumableArray(items.on), _toConsumableArray(items.off), _toConsumableArray(items.rest))
|
|
131
|
+
}
|
|
132
|
+
}, _this.scrollToAutoSortedOption);
|
|
133
|
+
case 25:
|
|
134
|
+
case "end":
|
|
135
|
+
return _context.stop();
|
|
136
|
+
}
|
|
137
|
+
}, _callee, null, [[2, 18]]);
|
|
138
|
+
})));
|
|
139
|
+
_defineProperty(_this, "scrollToAutoSortedOption", function () {
|
|
140
|
+
if (!_this.autoSortOptions) return;
|
|
141
|
+
var _this$state = _this.state,
|
|
142
|
+
lastCheckedValue = _this$state.lastCheckedValue,
|
|
143
|
+
options = _this$state.options;
|
|
144
|
+
if (lastCheckedValue) {
|
|
145
|
+
var sortedIndex = options.sorted.findIndex(function (option) {
|
|
146
|
+
return option.value === lastCheckedValue;
|
|
69
147
|
});
|
|
70
|
-
|
|
148
|
+
if (sortedIndex >= 0) {
|
|
149
|
+
var _this$selectableClass;
|
|
150
|
+
// EuiSelectable should automatically handle scrolling its list to the new index
|
|
151
|
+
(_this$selectableClass = _this.selectableClassRef.current) === null || _this$selectableClass === void 0 || _this$selectableClass.setState({
|
|
152
|
+
activeOptionIndex: sortedIndex
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
_this.setState({
|
|
156
|
+
lastCheckedValue: undefined
|
|
157
|
+
});
|
|
158
|
+
}
|
|
71
159
|
});
|
|
72
160
|
var _options = props.config.options;
|
|
73
161
|
var preloadedOptions = isArray(_options) ? {
|
|
74
|
-
|
|
75
|
-
|
|
162
|
+
unsorted: _options,
|
|
163
|
+
sorted: _options
|
|
76
164
|
} : null;
|
|
77
165
|
_this.state = {
|
|
78
166
|
popoverOpen: false,
|
|
79
167
|
error: null,
|
|
80
168
|
options: preloadedOptions,
|
|
81
|
-
|
|
169
|
+
activeItemsCount: 0
|
|
82
170
|
};
|
|
83
171
|
return _this;
|
|
84
172
|
}
|
|
@@ -108,94 +196,6 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
108
196
|
};
|
|
109
197
|
});
|
|
110
198
|
}
|
|
111
|
-
}, {
|
|
112
|
-
key: "loadOptions",
|
|
113
|
-
value: function loadOptions() {
|
|
114
|
-
var _this3 = this;
|
|
115
|
-
var loader = this.resolveOptionsLoader();
|
|
116
|
-
this.setState({
|
|
117
|
-
options: null,
|
|
118
|
-
error: null
|
|
119
|
-
});
|
|
120
|
-
loader().then(function (options) {
|
|
121
|
-
var items = {
|
|
122
|
-
on: [],
|
|
123
|
-
off: [],
|
|
124
|
-
rest: []
|
|
125
|
-
};
|
|
126
|
-
var _this3$props = _this3.props,
|
|
127
|
-
query = _this3$props.query,
|
|
128
|
-
config = _this3$props.config;
|
|
129
|
-
var multiSelect = _this3.resolveMultiSelect();
|
|
130
|
-
if (options) {
|
|
131
|
-
options.forEach(function (op) {
|
|
132
|
-
var optionField = op.field || config.field;
|
|
133
|
-
if (optionField) {
|
|
134
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
135
|
-
var checked = _this3.resolveChecked(clause);
|
|
136
|
-
if (!checked) {
|
|
137
|
-
items.rest.push(op);
|
|
138
|
-
} else if (checked === 'on') {
|
|
139
|
-
items.on.push(op);
|
|
140
|
-
} else {
|
|
141
|
-
items.off.push(op);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return;
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
_this3.setState({
|
|
148
|
-
error: null,
|
|
149
|
-
activeItems: items.on,
|
|
150
|
-
options: {
|
|
151
|
-
all: options,
|
|
152
|
-
shown: [].concat(_toConsumableArray(items.on), _toConsumableArray(items.off), _toConsumableArray(items.rest))
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}).catch(function () {
|
|
156
|
-
_this3.setState({
|
|
157
|
-
options: null,
|
|
158
|
-
error: 'Could not load options'
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
}, {
|
|
163
|
-
key: "filterOptions",
|
|
164
|
-
value: function filterOptions() {
|
|
165
|
-
var _this4 = this;
|
|
166
|
-
var q = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
167
|
-
this.setState(function (prevState) {
|
|
168
|
-
if (isNil(prevState.options)) {
|
|
169
|
-
return {};
|
|
170
|
-
}
|
|
171
|
-
var predicate = _this4.getOptionFilter();
|
|
172
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
173
|
-
options: _objectSpread(_objectSpread({}, prevState.options), {}, {
|
|
174
|
-
shown: prevState.options.all.filter(function (option, i, options) {
|
|
175
|
-
var name = _this4.resolveOptionName(option).toLowerCase();
|
|
176
|
-
var query = q.toLowerCase();
|
|
177
|
-
return predicate(name, query, options);
|
|
178
|
-
})
|
|
179
|
-
})
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}, {
|
|
184
|
-
key: "getOptionFilter",
|
|
185
|
-
value: function getOptionFilter() {
|
|
186
|
-
var filterWith = this.props.config.filterWith || defaults.config.filterWith;
|
|
187
|
-
if (typeof filterWith === 'function') {
|
|
188
|
-
return filterWith;
|
|
189
|
-
}
|
|
190
|
-
if (filterWith === 'includes') {
|
|
191
|
-
return function (name, query) {
|
|
192
|
-
return name.includes(query);
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
return function (name, query) {
|
|
196
|
-
return name.startsWith(query);
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
199
|
}, {
|
|
200
200
|
key: "resolveOptionName",
|
|
201
201
|
value: function resolveOptionName(option) {
|
|
@@ -204,23 +204,27 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
204
204
|
}, {
|
|
205
205
|
key: "onOptionClick",
|
|
206
206
|
value: function onOptionClick(field, value, checked) {
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
_this$props$
|
|
211
|
-
|
|
207
|
+
var _this$props$config2 = this.props.config,
|
|
208
|
+
autoClose = _this$props$config2.autoClose,
|
|
209
|
+
_this$props$config2$o = _this$props$config2.operator,
|
|
210
|
+
operator = _this$props$config2$o === void 0 ? Operator.EQ : _this$props$config2$o;
|
|
211
|
+
if (checked && this.autoSortOptions) {
|
|
212
|
+
this.setState({
|
|
213
|
+
lastCheckedValue: value
|
|
214
|
+
});
|
|
215
|
+
}
|
|
212
216
|
|
|
213
217
|
// If the consumer explicitly sets `autoClose`, always defer to that.
|
|
214
218
|
// Otherwise, default to auto-closing for single selections and leaving the
|
|
215
219
|
// popover open for multi-select (so users can continue selecting options)
|
|
216
|
-
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !multiSelect;
|
|
220
|
+
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !this.multiSelect;
|
|
217
221
|
if (shouldClosePopover) {
|
|
218
222
|
this.closePopover();
|
|
219
223
|
}
|
|
220
|
-
if (!multiSelect) {
|
|
224
|
+
if (!this.multiSelect) {
|
|
221
225
|
var _query = checked ? this.props.query.removeSimpleFieldClauses(field).addSimpleFieldValue(field, value, true, operator) : this.props.query.removeSimpleFieldClauses(field);
|
|
222
226
|
this.props.onChange(_query);
|
|
223
|
-
} else if (multiSelect === 'or') {
|
|
227
|
+
} else if (this.multiSelect === 'or') {
|
|
224
228
|
var _query2 = checked ? this.props.query.addOrFieldValue(field, value, true, operator) : this.props.query.removeOrFieldValue(field, value);
|
|
225
229
|
this.props.onChange(_query2);
|
|
226
230
|
} else {
|
|
@@ -229,10 +233,16 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
229
233
|
}
|
|
230
234
|
}
|
|
231
235
|
}, {
|
|
232
|
-
key: "
|
|
233
|
-
|
|
234
|
-
var
|
|
235
|
-
return
|
|
236
|
+
key: "autoSortOptions",
|
|
237
|
+
get: function get() {
|
|
238
|
+
var _this$props$config$au;
|
|
239
|
+
return (_this$props$config$au = this.props.config.autoSortOptions) !== null && _this$props$config$au !== void 0 ? _this$props$config$au : defaults.config.autoSortOptions;
|
|
240
|
+
}
|
|
241
|
+
}, {
|
|
242
|
+
key: "multiSelect",
|
|
243
|
+
get: function get() {
|
|
244
|
+
var _this$props$config$mu;
|
|
245
|
+
return (_this$props$config$mu = this.props.config.multiSelect) !== null && _this$props$config$mu !== void 0 ? _this$props$config$mu : defaults.config.multiSelect;
|
|
236
246
|
}
|
|
237
247
|
}, {
|
|
238
248
|
key: "componentDidMount",
|
|
@@ -244,19 +254,26 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
244
254
|
value: function componentDidUpdate(prevProps) {
|
|
245
255
|
if (this.props.query !== prevProps.query) this.loadOptions();
|
|
246
256
|
}
|
|
257
|
+
}, {
|
|
258
|
+
key: "componentWillUnmount",
|
|
259
|
+
value: function componentWillUnmount() {
|
|
260
|
+
clearTimeout(this.cacheTimeout);
|
|
261
|
+
}
|
|
247
262
|
}, {
|
|
248
263
|
key: "render",
|
|
249
264
|
value: function render() {
|
|
250
|
-
var
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
265
|
+
var _this$state$options,
|
|
266
|
+
_this$state$options2,
|
|
267
|
+
_this3 = this;
|
|
268
|
+
var _this$props2 = this.props,
|
|
269
|
+
query = _this$props2.query,
|
|
270
|
+
config = _this$props2.config;
|
|
271
|
+
var options = this.autoSortOptions ? (_this$state$options = this.state.options) === null || _this$state$options === void 0 ? void 0 : _this$state$options.sorted : (_this$state$options2 = this.state.options) === null || _this$state$options2 === void 0 ? void 0 : _this$state$options2.unsorted;
|
|
255
272
|
var activeTop = this.isActiveField(config.field);
|
|
256
|
-
var activeItem =
|
|
257
|
-
return
|
|
273
|
+
var activeItem = options ? options.some(function (item) {
|
|
274
|
+
return _this3.isActiveField(item.field);
|
|
258
275
|
}) : false;
|
|
259
|
-
var activeItemsCount = this.state.
|
|
276
|
+
var activeItemsCount = this.state.activeItemsCount;
|
|
260
277
|
var active = (activeTop || activeItem) && activeItemsCount > 0;
|
|
261
278
|
var button = ___EmotionJSX(EuiFilterButton, {
|
|
262
279
|
iconType: "arrowDown",
|
|
@@ -266,15 +283,15 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
266
283
|
numActiveFilters: active ? activeItemsCount : undefined,
|
|
267
284
|
grow: true
|
|
268
285
|
}, config.name);
|
|
269
|
-
var items =
|
|
286
|
+
var items = options ? options.map(function (option) {
|
|
270
287
|
var _option$view;
|
|
271
288
|
var optionField = option.field || config.field;
|
|
272
289
|
if (optionField == null) {
|
|
273
290
|
throw new Error('option.field or field should be provided in <FieldValueSelectionFilter/>');
|
|
274
291
|
}
|
|
275
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
276
|
-
var label =
|
|
277
|
-
var checked =
|
|
292
|
+
var clause = _this3.multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
293
|
+
var label = _this3.resolveOptionName(option);
|
|
294
|
+
var checked = _this3.resolveChecked(clause);
|
|
278
295
|
return {
|
|
279
296
|
label: label,
|
|
280
297
|
checked: checked,
|
|
@@ -286,7 +303,7 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
286
303
|
};
|
|
287
304
|
}) : [];
|
|
288
305
|
var threshold = config.searchThreshold || defaults.config.searchThreshold;
|
|
289
|
-
var isOverSearchThreshold =
|
|
306
|
+
var isOverSearchThreshold = options && options.length >= threshold;
|
|
290
307
|
var searchProps = {
|
|
291
308
|
searchable: false
|
|
292
309
|
};
|
|
@@ -302,31 +319,32 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
302
319
|
return ___EmotionJSX(RenderWithEuiTheme, null, function (euiThemeContext) {
|
|
303
320
|
return ___EmotionJSX(EuiPopover, {
|
|
304
321
|
button: button,
|
|
305
|
-
isOpen:
|
|
306
|
-
closePopover:
|
|
322
|
+
isOpen: _this3.state.popoverOpen,
|
|
323
|
+
closePopover: _this3.closePopover.bind(_this3),
|
|
307
324
|
panelPaddingSize: "none",
|
|
308
325
|
anchorPosition: "downCenter",
|
|
309
326
|
panelProps: {
|
|
310
327
|
css: euiFilterGroupStyles(euiThemeContext).euiFilterGroup__popoverPanel
|
|
311
328
|
}
|
|
312
329
|
}, ___EmotionJSX(EuiSelectable, _extends({
|
|
313
|
-
|
|
330
|
+
ref: _this3.selectableClassRef,
|
|
331
|
+
singleSelection: !_this3.multiSelect,
|
|
314
332
|
"aria-label": config.name,
|
|
315
333
|
options: items,
|
|
316
334
|
renderOption: function renderOption(option) {
|
|
317
335
|
return option.view;
|
|
318
336
|
},
|
|
319
|
-
isLoading: isNil(
|
|
337
|
+
isLoading: isNil(options),
|
|
320
338
|
loadingMessage: config.loadingMessage,
|
|
321
339
|
emptyMessage: config.noOptionsMessage,
|
|
322
|
-
errorMessage:
|
|
340
|
+
errorMessage: _this3.state.error,
|
|
323
341
|
noMatchesMessage: config.noOptionsMessage,
|
|
324
342
|
listProps: {
|
|
325
343
|
isVirtualized: isOverSearchThreshold || false
|
|
326
344
|
},
|
|
327
345
|
onChange: function onChange(options, event, changedOption) {
|
|
328
346
|
if (changedOption.data) {
|
|
329
|
-
|
|
347
|
+
_this3.onOptionClick(changedOption.data.optionField, changedOption.data.value, changedOption.checked);
|
|
330
348
|
}
|
|
331
349
|
}
|
|
332
350
|
}, searchProps), function (list, search) {
|
|
@@ -350,8 +368,7 @@ export var FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
|
350
368
|
return false;
|
|
351
369
|
}
|
|
352
370
|
var query = this.props.query;
|
|
353
|
-
|
|
354
|
-
if (multiSelect === 'or') {
|
|
371
|
+
if (this.multiSelect === 'or') {
|
|
355
372
|
return query.hasOrFieldClause(field);
|
|
356
373
|
}
|
|
357
374
|
return query.hasSimpleFieldClause(field);
|
|
@@ -10,8 +10,10 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _tabbable = require("tabbable");
|
|
12
12
|
var _services = require("../../../../services");
|
|
13
|
+
var _accessibility = require("../../../../services/accessibility");
|
|
14
|
+
var _utils = require("../../../../utils");
|
|
13
15
|
var _focus_trap = require("../../../focus_trap");
|
|
14
|
-
var
|
|
16
|
+
var _accessibility2 = require("../../../accessibility");
|
|
15
17
|
var _i18n = require("../../../i18n");
|
|
16
18
|
var _react2 = require("@emotion/react");
|
|
17
19
|
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); }
|
|
@@ -38,7 +40,8 @@ var HandleInteractiveChildren = exports.HandleInteractiveChildren = function Han
|
|
|
38
40
|
var cellEl = _ref.cellEl,
|
|
39
41
|
children = _ref.children,
|
|
40
42
|
updateCellFocusContext = _ref.updateCellFocusContext,
|
|
41
|
-
renderFocusTrap = _ref.renderFocusTrap
|
|
43
|
+
renderFocusTrap = _ref.renderFocusTrap,
|
|
44
|
+
onInteractiveChildrenFound = _ref.onInteractiveChildrenFound;
|
|
42
45
|
var _useState = (0, _react.useState)(false),
|
|
43
46
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
44
47
|
hasInteractiveChildren = _useState2[0],
|
|
@@ -47,12 +50,11 @@ var HandleInteractiveChildren = exports.HandleInteractiveChildren = function Han
|
|
|
47
50
|
// On mount, disable all interactive children
|
|
48
51
|
(0, _react.useEffect)(function () {
|
|
49
52
|
if (cellEl) {
|
|
50
|
-
var
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
53
|
+
var interactives = disableInteractives(cellEl);
|
|
54
|
+
onInteractiveChildrenFound === null || onInteractiveChildrenFound === void 0 || onInteractiveChildrenFound(interactives);
|
|
55
|
+
setHasInteractiveChildren(interactives.length > 0);
|
|
54
56
|
}
|
|
55
|
-
}, [cellEl,
|
|
57
|
+
}, [cellEl, onInteractiveChildrenFound]);
|
|
56
58
|
|
|
57
59
|
// Ensure that any interactive children that are clicked update the latest cell focus context
|
|
58
60
|
(0, _react.useEffect)(function () {
|
|
@@ -90,6 +92,24 @@ var FocusTrappedChildren = exports.FocusTrappedChildren = function FocusTrappedC
|
|
|
90
92
|
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
|
91
93
|
isCellEntered = _useState4[0],
|
|
92
94
|
setIsCellEntered = _useState4[1];
|
|
95
|
+
var _useState5 = (0, _react.useState)(false),
|
|
96
|
+
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
|
97
|
+
isExited = _useState6[0],
|
|
98
|
+
setExited = _useState6[1];
|
|
99
|
+
var keyboardHintAriaId = (0, _accessibility.useGeneratedHtmlId)({
|
|
100
|
+
prefix: 'euiDataGridCellHeader',
|
|
101
|
+
suffix: 'keyboardHint'
|
|
102
|
+
});
|
|
103
|
+
var exitedHintAriaId = (0, _accessibility.useGeneratedHtmlId)({
|
|
104
|
+
prefix: 'euiDataGridCellHeader',
|
|
105
|
+
suffix: 'exited'
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// direct DOM manipulation as workaround to attach required hints
|
|
109
|
+
(0, _react.useEffect)(function () {
|
|
110
|
+
var currentAriaDescribedbyId = cellEl.getAttribute('aria-describedby');
|
|
111
|
+
cellEl.setAttribute('aria-describedby', "".concat(currentAriaDescribedbyId, " ").concat(exitedHintAriaId, " ").concat(keyboardHintAriaId, " "));
|
|
112
|
+
}, [cellEl, keyboardHintAriaId, exitedHintAriaId]);
|
|
93
113
|
(0, _react.useEffect)(function () {
|
|
94
114
|
if (isCellEntered) {
|
|
95
115
|
enableAndFocusInteractives(cellEl);
|
|
@@ -109,28 +129,52 @@ var FocusTrappedChildren = exports.FocusTrappedChildren = function FocusTrappedC
|
|
|
109
129
|
event.preventDefault();
|
|
110
130
|
setIsCellEntered(function (isCellEntered) {
|
|
111
131
|
if (isCellEntered === true) {
|
|
132
|
+
setExited(true);
|
|
112
133
|
requestAnimationFrame(function () {
|
|
113
134
|
return cellEl.focus();
|
|
114
135
|
}); // move focus to cell
|
|
115
136
|
return false;
|
|
137
|
+
} else if (
|
|
138
|
+
// when opened content is closed, we don't want Escape to return to the cell
|
|
139
|
+
// immediately but instead return focus to a trigger as expected
|
|
140
|
+
isCellEntered === false && (0, _utils.isDOMNode)(event.target) && (0, _utils.isDOMNode)(event.currentTarget) && event.currentTarget.contains(event.target)) {
|
|
141
|
+
return true;
|
|
116
142
|
}
|
|
117
143
|
return isCellEntered;
|
|
118
144
|
});
|
|
119
145
|
break;
|
|
120
146
|
}
|
|
121
147
|
};
|
|
148
|
+
|
|
149
|
+
// ensures the SR text is reset when navigating to a different cell
|
|
150
|
+
var onBlur = function onBlur() {
|
|
151
|
+
return setExited(false);
|
|
152
|
+
};
|
|
122
153
|
cellEl.addEventListener('keyup', onKeyUp);
|
|
154
|
+
cellEl.addEventListener('blur', onBlur);
|
|
123
155
|
return function () {
|
|
124
156
|
cellEl.removeEventListener('keyup', onKeyUp);
|
|
157
|
+
cellEl.removeEventListener('blur', onBlur);
|
|
125
158
|
};
|
|
126
159
|
}, [cellEl]);
|
|
127
160
|
return (0, _react2.jsx)(_focus_trap.EuiFocusTrap, {
|
|
128
161
|
disabled: !isCellEntered,
|
|
162
|
+
clickOutsideDisables: true,
|
|
129
163
|
onDeactivation: function onDeactivation() {
|
|
130
164
|
return setIsCellEntered(false);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
165
|
+
}
|
|
166
|
+
}, children, (0, _react2.jsx)(_accessibility2.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", {
|
|
167
|
+
id: exitedHintAriaId,
|
|
168
|
+
"aria-hidden": "true"
|
|
169
|
+
}, isExited && (0, _react2.jsx)(_i18n.EuiI18n
|
|
170
|
+
// eslint-disable-next-line local/i18n
|
|
171
|
+
, {
|
|
172
|
+
token: "euiDataGridCell.focusTrapExitPrompt",
|
|
173
|
+
default: "Exited cell content."
|
|
174
|
+
}))), (0, _react2.jsx)(_accessibility2.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", {
|
|
175
|
+
id: keyboardHintAriaId,
|
|
176
|
+
"aria-hidden": "true"
|
|
177
|
+
}, !isCellEntered && (0, _react2.jsx)(_i18n.EuiI18n
|
|
134
178
|
// eslint-disable-next-line local/i18n
|
|
135
179
|
, {
|
|
136
180
|
token: "euiDataGridCell.focusTrapEnterPrompt",
|
|
@@ -154,7 +198,8 @@ var enableAndFocusInteractives = function enableAndFocusInteractives(cell) {
|
|
|
154
198
|
var interactives = cell.querySelectorAll('[data-euigrid-tab-managed]');
|
|
155
199
|
interactives.forEach(function (element, i) {
|
|
156
200
|
element.setAttribute('tabIndex', '0');
|
|
157
|
-
if
|
|
201
|
+
// focus the first element only if we're on the cell and not inside of it
|
|
202
|
+
if (i === 0 && !cell.contains(document.activeElement)) {
|
|
158
203
|
element.focus();
|
|
159
204
|
}
|
|
160
205
|
});
|