@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
|
@@ -6,8 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.FieldValueSelectionFilter = void 0;
|
|
9
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
11
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
13
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
14
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
15
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
@@ -27,8 +29,6 @@ var _ast = require("../query/ast");
|
|
|
27
29
|
var _react2 = require("@emotion/react");
|
|
28
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); }
|
|
29
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; }
|
|
30
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
31
|
-
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) { (0, _defineProperty2.default)(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; }
|
|
32
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
33
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /*
|
|
34
34
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -41,7 +41,8 @@ var defaults = {
|
|
|
41
41
|
config: {
|
|
42
42
|
multiSelect: true,
|
|
43
43
|
filterWith: 'prefix',
|
|
44
|
-
searchThreshold: 10
|
|
44
|
+
searchThreshold: 10,
|
|
45
|
+
autoSortOptions: true
|
|
45
46
|
}
|
|
46
47
|
};
|
|
47
48
|
var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
@@ -49,45 +50,132 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
49
50
|
var _this;
|
|
50
51
|
(0, _classCallCheck2.default)(this, FieldValueSelectionFilter);
|
|
51
52
|
_this = _callSuper(this, FieldValueSelectionFilter, [props]);
|
|
52
|
-
(0, _defineProperty2.default)(_this, "
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return function () {
|
|
60
|
-
var cachedOptions = _this.state.cachedOptions;
|
|
61
|
-
if (cachedOptions) {
|
|
62
|
-
return Promise.resolve(cachedOptions);
|
|
63
|
-
}
|
|
64
|
-
return options().then(function (opts) {
|
|
65
|
-
// If a cache time is set, populate the cache and also schedule a
|
|
66
|
-
// cache reset.
|
|
67
|
-
if (_this.props.config.cache != null && _this.props.config.cache > 0) {
|
|
53
|
+
(0, _defineProperty2.default)(_this, "selectableClassRef", /*#__PURE__*/(0, _react.createRef)());
|
|
54
|
+
(0, _defineProperty2.default)(_this, "cacheTimeout", void 0);
|
|
55
|
+
(0, _defineProperty2.default)(_this, "loadOptions", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
56
|
+
var loadedOptions, _this$props$config, options, cache, _this$state$cachedOpt, items, _this$props, query, config;
|
|
57
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
58
|
+
while (1) switch (_context.prev = _context.next) {
|
|
59
|
+
case 0:
|
|
68
60
|
_this.setState({
|
|
69
|
-
|
|
61
|
+
options: null,
|
|
62
|
+
error: null
|
|
70
63
|
});
|
|
71
|
-
|
|
64
|
+
_this$props$config = _this.props.config, options = _this$props$config.options, cache = _this$props$config.cache;
|
|
65
|
+
_context.prev = 2;
|
|
66
|
+
if (!(0, _predicate.isArray)(options)) {
|
|
67
|
+
_context.next = 7;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
// Synchronous options, already loaded
|
|
71
|
+
loadedOptions = options;
|
|
72
|
+
_context.next = 16;
|
|
73
|
+
break;
|
|
74
|
+
case 7:
|
|
75
|
+
if (!((_this$state$cachedOpt = _this.state.cachedOptions) !== null && _this$state$cachedOpt !== void 0)) {
|
|
76
|
+
_context.next = 11;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
_context.t0 = _this$state$cachedOpt;
|
|
80
|
+
_context.next = 14;
|
|
81
|
+
break;
|
|
82
|
+
case 11:
|
|
83
|
+
_context.next = 13;
|
|
84
|
+
return options();
|
|
85
|
+
case 13:
|
|
86
|
+
_context.t0 = _context.sent;
|
|
87
|
+
case 14:
|
|
88
|
+
loadedOptions = _context.t0;
|
|
89
|
+
// If a cache time is set, populate the cache and schedule a cache reset
|
|
90
|
+
if (cache != null && cache > 0) {
|
|
72
91
|
_this.setState({
|
|
73
|
-
cachedOptions:
|
|
92
|
+
cachedOptions: loadedOptions
|
|
74
93
|
});
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
94
|
+
_this.cacheTimeout = setTimeout(function () {
|
|
95
|
+
_this.setState({
|
|
96
|
+
cachedOptions: null
|
|
97
|
+
});
|
|
98
|
+
}, cache);
|
|
99
|
+
}
|
|
100
|
+
case 16:
|
|
101
|
+
_context.next = 21;
|
|
102
|
+
break;
|
|
103
|
+
case 18:
|
|
104
|
+
_context.prev = 18;
|
|
105
|
+
_context.t1 = _context["catch"](2);
|
|
106
|
+
return _context.abrupt("return", _this.setState({
|
|
107
|
+
options: null,
|
|
108
|
+
error: 'Could not load options'
|
|
109
|
+
}));
|
|
110
|
+
case 21:
|
|
111
|
+
items = {
|
|
112
|
+
on: [],
|
|
113
|
+
off: [],
|
|
114
|
+
rest: []
|
|
115
|
+
};
|
|
116
|
+
_this$props = _this.props, query = _this$props.query, config = _this$props.config;
|
|
117
|
+
if (loadedOptions) {
|
|
118
|
+
loadedOptions.forEach(function (op) {
|
|
119
|
+
var optionField = op.field || config.field;
|
|
120
|
+
if (optionField) {
|
|
121
|
+
var clause = _this.multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
122
|
+
var checked = _this.resolveChecked(clause);
|
|
123
|
+
if (!checked) {
|
|
124
|
+
items.rest.push(op);
|
|
125
|
+
} else if (checked === 'on') {
|
|
126
|
+
items.on.push(op);
|
|
127
|
+
} else {
|
|
128
|
+
items.off.push(op);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
_this.setState({
|
|
135
|
+
error: null,
|
|
136
|
+
activeItemsCount: items.on.length,
|
|
137
|
+
options: {
|
|
138
|
+
unsorted: loadedOptions,
|
|
139
|
+
sorted: [].concat((0, _toConsumableArray2.default)(items.on), (0, _toConsumableArray2.default)(items.off), (0, _toConsumableArray2.default)(items.rest))
|
|
140
|
+
}
|
|
141
|
+
}, _this.scrollToAutoSortedOption);
|
|
142
|
+
case 25:
|
|
143
|
+
case "end":
|
|
144
|
+
return _context.stop();
|
|
145
|
+
}
|
|
146
|
+
}, _callee, null, [[2, 18]]);
|
|
147
|
+
})));
|
|
148
|
+
(0, _defineProperty2.default)(_this, "scrollToAutoSortedOption", function () {
|
|
149
|
+
if (!_this.autoSortOptions) return;
|
|
150
|
+
var _this$state = _this.state,
|
|
151
|
+
lastCheckedValue = _this$state.lastCheckedValue,
|
|
152
|
+
options = _this$state.options;
|
|
153
|
+
if (lastCheckedValue) {
|
|
154
|
+
var sortedIndex = options.sorted.findIndex(function (option) {
|
|
155
|
+
return option.value === lastCheckedValue;
|
|
78
156
|
});
|
|
79
|
-
|
|
157
|
+
if (sortedIndex >= 0) {
|
|
158
|
+
var _this$selectableClass;
|
|
159
|
+
// EuiSelectable should automatically handle scrolling its list to the new index
|
|
160
|
+
(_this$selectableClass = _this.selectableClassRef.current) === null || _this$selectableClass === void 0 || _this$selectableClass.setState({
|
|
161
|
+
activeOptionIndex: sortedIndex
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
_this.setState({
|
|
165
|
+
lastCheckedValue: undefined
|
|
166
|
+
});
|
|
167
|
+
}
|
|
80
168
|
});
|
|
81
169
|
var _options = props.config.options;
|
|
82
170
|
var preloadedOptions = (0, _predicate.isArray)(_options) ? {
|
|
83
|
-
|
|
84
|
-
|
|
171
|
+
unsorted: _options,
|
|
172
|
+
sorted: _options
|
|
85
173
|
} : null;
|
|
86
174
|
_this.state = {
|
|
87
175
|
popoverOpen: false,
|
|
88
176
|
error: null,
|
|
89
177
|
options: preloadedOptions,
|
|
90
|
-
|
|
178
|
+
activeItemsCount: 0
|
|
91
179
|
};
|
|
92
180
|
return _this;
|
|
93
181
|
}
|
|
@@ -117,94 +205,6 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
117
205
|
};
|
|
118
206
|
});
|
|
119
207
|
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "loadOptions",
|
|
122
|
-
value: function loadOptions() {
|
|
123
|
-
var _this3 = this;
|
|
124
|
-
var loader = this.resolveOptionsLoader();
|
|
125
|
-
this.setState({
|
|
126
|
-
options: null,
|
|
127
|
-
error: null
|
|
128
|
-
});
|
|
129
|
-
loader().then(function (options) {
|
|
130
|
-
var items = {
|
|
131
|
-
on: [],
|
|
132
|
-
off: [],
|
|
133
|
-
rest: []
|
|
134
|
-
};
|
|
135
|
-
var _this3$props = _this3.props,
|
|
136
|
-
query = _this3$props.query,
|
|
137
|
-
config = _this3$props.config;
|
|
138
|
-
var multiSelect = _this3.resolveMultiSelect();
|
|
139
|
-
if (options) {
|
|
140
|
-
options.forEach(function (op) {
|
|
141
|
-
var optionField = op.field || config.field;
|
|
142
|
-
if (optionField) {
|
|
143
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
144
|
-
var checked = _this3.resolveChecked(clause);
|
|
145
|
-
if (!checked) {
|
|
146
|
-
items.rest.push(op);
|
|
147
|
-
} else if (checked === 'on') {
|
|
148
|
-
items.on.push(op);
|
|
149
|
-
} else {
|
|
150
|
-
items.off.push(op);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
return;
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
_this3.setState({
|
|
157
|
-
error: null,
|
|
158
|
-
activeItems: items.on,
|
|
159
|
-
options: {
|
|
160
|
-
all: options,
|
|
161
|
-
shown: [].concat((0, _toConsumableArray2.default)(items.on), (0, _toConsumableArray2.default)(items.off), (0, _toConsumableArray2.default)(items.rest))
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}).catch(function () {
|
|
165
|
-
_this3.setState({
|
|
166
|
-
options: null,
|
|
167
|
-
error: 'Could not load options'
|
|
168
|
-
});
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
}, {
|
|
172
|
-
key: "filterOptions",
|
|
173
|
-
value: function filterOptions() {
|
|
174
|
-
var _this4 = this;
|
|
175
|
-
var q = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
176
|
-
this.setState(function (prevState) {
|
|
177
|
-
if ((0, _predicate.isNil)(prevState.options)) {
|
|
178
|
-
return {};
|
|
179
|
-
}
|
|
180
|
-
var predicate = _this4.getOptionFilter();
|
|
181
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
182
|
-
options: _objectSpread(_objectSpread({}, prevState.options), {}, {
|
|
183
|
-
shown: prevState.options.all.filter(function (option, i, options) {
|
|
184
|
-
var name = _this4.resolveOptionName(option).toLowerCase();
|
|
185
|
-
var query = q.toLowerCase();
|
|
186
|
-
return predicate(name, query, options);
|
|
187
|
-
})
|
|
188
|
-
})
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}, {
|
|
193
|
-
key: "getOptionFilter",
|
|
194
|
-
value: function getOptionFilter() {
|
|
195
|
-
var filterWith = this.props.config.filterWith || defaults.config.filterWith;
|
|
196
|
-
if (typeof filterWith === 'function') {
|
|
197
|
-
return filterWith;
|
|
198
|
-
}
|
|
199
|
-
if (filterWith === 'includes') {
|
|
200
|
-
return function (name, query) {
|
|
201
|
-
return name.includes(query);
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
return function (name, query) {
|
|
205
|
-
return name.startsWith(query);
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
208
|
}, {
|
|
209
209
|
key: "resolveOptionName",
|
|
210
210
|
value: function resolveOptionName(option) {
|
|
@@ -213,23 +213,27 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
213
213
|
}, {
|
|
214
214
|
key: "onOptionClick",
|
|
215
215
|
value: function onOptionClick(field, value, checked) {
|
|
216
|
-
var
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
_this$props$
|
|
220
|
-
|
|
216
|
+
var _this$props$config2 = this.props.config,
|
|
217
|
+
autoClose = _this$props$config2.autoClose,
|
|
218
|
+
_this$props$config2$o = _this$props$config2.operator,
|
|
219
|
+
operator = _this$props$config2$o === void 0 ? _ast.Operator.EQ : _this$props$config2$o;
|
|
220
|
+
if (checked && this.autoSortOptions) {
|
|
221
|
+
this.setState({
|
|
222
|
+
lastCheckedValue: value
|
|
223
|
+
});
|
|
224
|
+
}
|
|
221
225
|
|
|
222
226
|
// If the consumer explicitly sets `autoClose`, always defer to that.
|
|
223
227
|
// Otherwise, default to auto-closing for single selections and leaving the
|
|
224
228
|
// popover open for multi-select (so users can continue selecting options)
|
|
225
|
-
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !multiSelect;
|
|
229
|
+
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !this.multiSelect;
|
|
226
230
|
if (shouldClosePopover) {
|
|
227
231
|
this.closePopover();
|
|
228
232
|
}
|
|
229
|
-
if (!multiSelect) {
|
|
233
|
+
if (!this.multiSelect) {
|
|
230
234
|
var _query = checked ? this.props.query.removeSimpleFieldClauses(field).addSimpleFieldValue(field, value, true, operator) : this.props.query.removeSimpleFieldClauses(field);
|
|
231
235
|
this.props.onChange(_query);
|
|
232
|
-
} else if (multiSelect === 'or') {
|
|
236
|
+
} else if (this.multiSelect === 'or') {
|
|
233
237
|
var _query2 = checked ? this.props.query.addOrFieldValue(field, value, true, operator) : this.props.query.removeOrFieldValue(field, value);
|
|
234
238
|
this.props.onChange(_query2);
|
|
235
239
|
} else {
|
|
@@ -238,10 +242,16 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
238
242
|
}
|
|
239
243
|
}
|
|
240
244
|
}, {
|
|
241
|
-
key: "
|
|
242
|
-
|
|
243
|
-
var
|
|
244
|
-
return
|
|
245
|
+
key: "autoSortOptions",
|
|
246
|
+
get: function get() {
|
|
247
|
+
var _this$props$config$au;
|
|
248
|
+
return (_this$props$config$au = this.props.config.autoSortOptions) !== null && _this$props$config$au !== void 0 ? _this$props$config$au : defaults.config.autoSortOptions;
|
|
249
|
+
}
|
|
250
|
+
}, {
|
|
251
|
+
key: "multiSelect",
|
|
252
|
+
get: function get() {
|
|
253
|
+
var _this$props$config$mu;
|
|
254
|
+
return (_this$props$config$mu = this.props.config.multiSelect) !== null && _this$props$config$mu !== void 0 ? _this$props$config$mu : defaults.config.multiSelect;
|
|
245
255
|
}
|
|
246
256
|
}, {
|
|
247
257
|
key: "componentDidMount",
|
|
@@ -253,19 +263,26 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
253
263
|
value: function componentDidUpdate(prevProps) {
|
|
254
264
|
if (this.props.query !== prevProps.query) this.loadOptions();
|
|
255
265
|
}
|
|
266
|
+
}, {
|
|
267
|
+
key: "componentWillUnmount",
|
|
268
|
+
value: function componentWillUnmount() {
|
|
269
|
+
clearTimeout(this.cacheTimeout);
|
|
270
|
+
}
|
|
256
271
|
}, {
|
|
257
272
|
key: "render",
|
|
258
273
|
value: function render() {
|
|
259
|
-
var
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
274
|
+
var _this$state$options,
|
|
275
|
+
_this$state$options2,
|
|
276
|
+
_this3 = this;
|
|
277
|
+
var _this$props2 = this.props,
|
|
278
|
+
query = _this$props2.query,
|
|
279
|
+
config = _this$props2.config;
|
|
280
|
+
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;
|
|
264
281
|
var activeTop = this.isActiveField(config.field);
|
|
265
|
-
var activeItem =
|
|
266
|
-
return
|
|
282
|
+
var activeItem = options ? options.some(function (item) {
|
|
283
|
+
return _this3.isActiveField(item.field);
|
|
267
284
|
}) : false;
|
|
268
|
-
var activeItemsCount = this.state.
|
|
285
|
+
var activeItemsCount = this.state.activeItemsCount;
|
|
269
286
|
var active = (activeTop || activeItem) && activeItemsCount > 0;
|
|
270
287
|
var button = (0, _react2.jsx)(_filter_group.EuiFilterButton, {
|
|
271
288
|
iconType: "arrowDown",
|
|
@@ -275,15 +292,15 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
275
292
|
numActiveFilters: active ? activeItemsCount : undefined,
|
|
276
293
|
grow: true
|
|
277
294
|
}, config.name);
|
|
278
|
-
var items =
|
|
295
|
+
var items = options ? options.map(function (option) {
|
|
279
296
|
var _option$view;
|
|
280
297
|
var optionField = option.field || config.field;
|
|
281
298
|
if (optionField == null) {
|
|
282
299
|
throw new Error('option.field or field should be provided in <FieldValueSelectionFilter/>');
|
|
283
300
|
}
|
|
284
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
285
|
-
var label =
|
|
286
|
-
var checked =
|
|
301
|
+
var clause = _this3.multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
302
|
+
var label = _this3.resolveOptionName(option);
|
|
303
|
+
var checked = _this3.resolveChecked(clause);
|
|
287
304
|
return {
|
|
288
305
|
label: label,
|
|
289
306
|
checked: checked,
|
|
@@ -295,7 +312,7 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
295
312
|
};
|
|
296
313
|
}) : [];
|
|
297
314
|
var threshold = config.searchThreshold || defaults.config.searchThreshold;
|
|
298
|
-
var isOverSearchThreshold =
|
|
315
|
+
var isOverSearchThreshold = options && options.length >= threshold;
|
|
299
316
|
var searchProps = {
|
|
300
317
|
searchable: false
|
|
301
318
|
};
|
|
@@ -311,31 +328,32 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
311
328
|
return (0, _react2.jsx)(_services.RenderWithEuiTheme, null, function (euiThemeContext) {
|
|
312
329
|
return (0, _react2.jsx)(_popover.EuiPopover, {
|
|
313
330
|
button: button,
|
|
314
|
-
isOpen:
|
|
315
|
-
closePopover:
|
|
331
|
+
isOpen: _this3.state.popoverOpen,
|
|
332
|
+
closePopover: _this3.closePopover.bind(_this3),
|
|
316
333
|
panelPaddingSize: "none",
|
|
317
334
|
anchorPosition: "downCenter",
|
|
318
335
|
panelProps: {
|
|
319
336
|
css: (0, _filter_group2.euiFilterGroupStyles)(euiThemeContext).euiFilterGroup__popoverPanel
|
|
320
337
|
}
|
|
321
338
|
}, (0, _react2.jsx)(_selectable.EuiSelectable, (0, _extends2.default)({
|
|
322
|
-
|
|
339
|
+
ref: _this3.selectableClassRef,
|
|
340
|
+
singleSelection: !_this3.multiSelect,
|
|
323
341
|
"aria-label": config.name,
|
|
324
342
|
options: items,
|
|
325
343
|
renderOption: function renderOption(option) {
|
|
326
344
|
return option.view;
|
|
327
345
|
},
|
|
328
|
-
isLoading: (0, _predicate.isNil)(
|
|
346
|
+
isLoading: (0, _predicate.isNil)(options),
|
|
329
347
|
loadingMessage: config.loadingMessage,
|
|
330
348
|
emptyMessage: config.noOptionsMessage,
|
|
331
|
-
errorMessage:
|
|
349
|
+
errorMessage: _this3.state.error,
|
|
332
350
|
noMatchesMessage: config.noOptionsMessage,
|
|
333
351
|
listProps: {
|
|
334
352
|
isVirtualized: isOverSearchThreshold || false
|
|
335
353
|
},
|
|
336
354
|
onChange: function onChange(options, event, changedOption) {
|
|
337
355
|
if (changedOption.data) {
|
|
338
|
-
|
|
356
|
+
_this3.onOptionClick(changedOption.data.optionField, changedOption.data.value, changedOption.checked);
|
|
339
357
|
}
|
|
340
358
|
}
|
|
341
359
|
}, searchProps), function (list, search) {
|
|
@@ -359,8 +377,7 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
359
377
|
return false;
|
|
360
378
|
}
|
|
361
379
|
var query = this.props.query;
|
|
362
|
-
|
|
363
|
-
if (multiSelect === 'or') {
|
|
380
|
+
if (this.multiSelect === 'or') {
|
|
364
381
|
return query.hasOrFieldClause(field);
|
|
365
382
|
}
|
|
366
383
|
return query.hasSimpleFieldClause(field);
|
|
@@ -403,7 +420,8 @@ FieldValueSelectionFilter.propTypes = {
|
|
|
403
420
|
searchThreshold: _propTypes.default.number,
|
|
404
421
|
available: _propTypes.default.func,
|
|
405
422
|
autoClose: _propTypes.default.bool,
|
|
406
|
-
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"])
|
|
423
|
+
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"]),
|
|
424
|
+
autoSortOptions: _propTypes.default.bool
|
|
407
425
|
}).isRequired,
|
|
408
426
|
query: _propTypes.default.any.isRequired,
|
|
409
427
|
onChange: _propTypes.default.func.isRequired
|
|
@@ -365,7 +365,8 @@ EuiSearchBar.propTypes = {
|
|
|
365
365
|
searchThreshold: _propTypes.default.number,
|
|
366
366
|
available: _propTypes.default.func,
|
|
367
367
|
autoClose: _propTypes.default.bool,
|
|
368
|
-
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"])
|
|
368
|
+
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"]),
|
|
369
|
+
autoSortOptions: _propTypes.default.bool
|
|
369
370
|
}).isRequired, _propTypes.default.shape({
|
|
370
371
|
type: _propTypes.default.oneOf(["field_value_toggle"]).isRequired,
|
|
371
372
|
field: _propTypes.default.string.isRequired,
|
|
@@ -102,7 +102,8 @@ EuiSearchBarFilters.propTypes = {
|
|
|
102
102
|
searchThreshold: _propTypes.default.number,
|
|
103
103
|
available: _propTypes.default.func,
|
|
104
104
|
autoClose: _propTypes.default.bool,
|
|
105
|
-
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"])
|
|
105
|
+
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"]),
|
|
106
|
+
autoSortOptions: _propTypes.default.bool
|
|
106
107
|
}).isRequired, _propTypes.default.shape({
|
|
107
108
|
type: _propTypes.default.oneOf(["field_value_toggle"]).isRequired,
|
|
108
109
|
field: _propTypes.default.string.isRequired,
|