@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
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
+
exports.DEFAULT_OPTIONS = void 0;
|
|
7
8
|
exports.euiMarkdownLinkValidator = euiMarkdownLinkValidator;
|
|
8
9
|
exports.mutateLinkToText = mutateLinkToText;
|
|
9
10
|
exports.validateUrl = validateUrl;
|
|
@@ -16,6 +17,10 @@ var _unistUtilVisit = _interopRequireDefault(require("unist-util-visit"));
|
|
|
16
17
|
* Side Public License, v 1.
|
|
17
18
|
*/
|
|
18
19
|
|
|
20
|
+
var DEFAULT_OPTIONS = exports.DEFAULT_OPTIONS = {
|
|
21
|
+
allowRelative: true,
|
|
22
|
+
allowProtocols: ['https:', 'http:', 'mailto:']
|
|
23
|
+
};
|
|
19
24
|
function euiMarkdownLinkValidator(options) {
|
|
20
25
|
return function (ast) {
|
|
21
26
|
(0, _unistUtilVisit.default)(ast, 'link', function (_node) {
|
|
@@ -46,8 +51,10 @@ function mutateLinkToText(node) {
|
|
|
46
51
|
return node;
|
|
47
52
|
}
|
|
48
53
|
function validateUrl(url, _ref) {
|
|
49
|
-
var allowRelative = _ref.allowRelative,
|
|
50
|
-
|
|
54
|
+
var _ref$allowRelative = _ref.allowRelative,
|
|
55
|
+
allowRelative = _ref$allowRelative === void 0 ? DEFAULT_OPTIONS.allowRelative : _ref$allowRelative,
|
|
56
|
+
_ref$allowProtocols = _ref.allowProtocols,
|
|
57
|
+
allowProtocols = _ref$allowProtocols === void 0 ? DEFAULT_OPTIONS.allowProtocols : _ref$allowProtocols;
|
|
51
58
|
// relative captures both relative paths `/` and protocols `//`
|
|
52
59
|
var isRelative = url.startsWith('/');
|
|
53
60
|
if (isRelative) {
|
|
@@ -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"));
|
|
@@ -26,8 +28,6 @@ var _ast = require("../query/ast");
|
|
|
26
28
|
var _react2 = require("@emotion/react");
|
|
27
29
|
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); }
|
|
28
30
|
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; }
|
|
29
|
-
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; }
|
|
30
|
-
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; }
|
|
31
31
|
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)); }
|
|
32
32
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); } /*
|
|
33
33
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
@@ -40,7 +40,8 @@ var defaults = {
|
|
|
40
40
|
config: {
|
|
41
41
|
multiSelect: true,
|
|
42
42
|
filterWith: 'prefix',
|
|
43
|
-
searchThreshold: 10
|
|
43
|
+
searchThreshold: 10,
|
|
44
|
+
autoSortOptions: true
|
|
44
45
|
}
|
|
45
46
|
};
|
|
46
47
|
var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
@@ -48,45 +49,132 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
48
49
|
var _this;
|
|
49
50
|
(0, _classCallCheck2.default)(this, FieldValueSelectionFilter);
|
|
50
51
|
_this = _callSuper(this, FieldValueSelectionFilter, [props]);
|
|
51
|
-
(0, _defineProperty2.default)(_this, "
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return function () {
|
|
59
|
-
var cachedOptions = _this.state.cachedOptions;
|
|
60
|
-
if (cachedOptions) {
|
|
61
|
-
return Promise.resolve(cachedOptions);
|
|
62
|
-
}
|
|
63
|
-
return options().then(function (opts) {
|
|
64
|
-
// If a cache time is set, populate the cache and also schedule a
|
|
65
|
-
// cache reset.
|
|
66
|
-
if (_this.props.config.cache != null && _this.props.config.cache > 0) {
|
|
52
|
+
(0, _defineProperty2.default)(_this, "selectableClassRef", /*#__PURE__*/(0, _react.createRef)());
|
|
53
|
+
(0, _defineProperty2.default)(_this, "cacheTimeout", void 0);
|
|
54
|
+
(0, _defineProperty2.default)(_this, "loadOptions", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
55
|
+
var loadedOptions, _this$props$config, options, cache, _this$state$cachedOpt, items, _this$props, query, config;
|
|
56
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
57
|
+
while (1) switch (_context.prev = _context.next) {
|
|
58
|
+
case 0:
|
|
67
59
|
_this.setState({
|
|
68
|
-
|
|
60
|
+
options: null,
|
|
61
|
+
error: null
|
|
69
62
|
});
|
|
70
|
-
|
|
63
|
+
_this$props$config = _this.props.config, options = _this$props$config.options, cache = _this$props$config.cache;
|
|
64
|
+
_context.prev = 2;
|
|
65
|
+
if (!(0, _predicate.isArray)(options)) {
|
|
66
|
+
_context.next = 7;
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
// Synchronous options, already loaded
|
|
70
|
+
loadedOptions = options;
|
|
71
|
+
_context.next = 16;
|
|
72
|
+
break;
|
|
73
|
+
case 7:
|
|
74
|
+
if (!((_this$state$cachedOpt = _this.state.cachedOptions) !== null && _this$state$cachedOpt !== void 0)) {
|
|
75
|
+
_context.next = 11;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
_context.t0 = _this$state$cachedOpt;
|
|
79
|
+
_context.next = 14;
|
|
80
|
+
break;
|
|
81
|
+
case 11:
|
|
82
|
+
_context.next = 13;
|
|
83
|
+
return options();
|
|
84
|
+
case 13:
|
|
85
|
+
_context.t0 = _context.sent;
|
|
86
|
+
case 14:
|
|
87
|
+
loadedOptions = _context.t0;
|
|
88
|
+
// If a cache time is set, populate the cache and schedule a cache reset
|
|
89
|
+
if (cache != null && cache > 0) {
|
|
71
90
|
_this.setState({
|
|
72
|
-
cachedOptions:
|
|
91
|
+
cachedOptions: loadedOptions
|
|
73
92
|
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
_this.cacheTimeout = setTimeout(function () {
|
|
94
|
+
_this.setState({
|
|
95
|
+
cachedOptions: null
|
|
96
|
+
});
|
|
97
|
+
}, cache);
|
|
98
|
+
}
|
|
99
|
+
case 16:
|
|
100
|
+
_context.next = 21;
|
|
101
|
+
break;
|
|
102
|
+
case 18:
|
|
103
|
+
_context.prev = 18;
|
|
104
|
+
_context.t1 = _context["catch"](2);
|
|
105
|
+
return _context.abrupt("return", _this.setState({
|
|
106
|
+
options: null,
|
|
107
|
+
error: 'Could not load options'
|
|
108
|
+
}));
|
|
109
|
+
case 21:
|
|
110
|
+
items = {
|
|
111
|
+
on: [],
|
|
112
|
+
off: [],
|
|
113
|
+
rest: []
|
|
114
|
+
};
|
|
115
|
+
_this$props = _this.props, query = _this$props.query, config = _this$props.config;
|
|
116
|
+
if (loadedOptions) {
|
|
117
|
+
loadedOptions.forEach(function (op) {
|
|
118
|
+
var optionField = op.field || config.field;
|
|
119
|
+
if (optionField) {
|
|
120
|
+
var clause = _this.multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
121
|
+
var checked = _this.resolveChecked(clause);
|
|
122
|
+
if (!checked) {
|
|
123
|
+
items.rest.push(op);
|
|
124
|
+
} else if (checked === 'on') {
|
|
125
|
+
items.on.push(op);
|
|
126
|
+
} else {
|
|
127
|
+
items.off.push(op);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
_this.setState({
|
|
134
|
+
error: null,
|
|
135
|
+
activeItemsCount: items.on.length,
|
|
136
|
+
options: {
|
|
137
|
+
unsorted: loadedOptions,
|
|
138
|
+
sorted: [].concat((0, _toConsumableArray2.default)(items.on), (0, _toConsumableArray2.default)(items.off), (0, _toConsumableArray2.default)(items.rest))
|
|
139
|
+
}
|
|
140
|
+
}, _this.scrollToAutoSortedOption);
|
|
141
|
+
case 25:
|
|
142
|
+
case "end":
|
|
143
|
+
return _context.stop();
|
|
144
|
+
}
|
|
145
|
+
}, _callee, null, [[2, 18]]);
|
|
146
|
+
})));
|
|
147
|
+
(0, _defineProperty2.default)(_this, "scrollToAutoSortedOption", function () {
|
|
148
|
+
if (!_this.autoSortOptions) return;
|
|
149
|
+
var _this$state = _this.state,
|
|
150
|
+
lastCheckedValue = _this$state.lastCheckedValue,
|
|
151
|
+
options = _this$state.options;
|
|
152
|
+
if (lastCheckedValue) {
|
|
153
|
+
var sortedIndex = options.sorted.findIndex(function (option) {
|
|
154
|
+
return option.value === lastCheckedValue;
|
|
77
155
|
});
|
|
78
|
-
|
|
156
|
+
if (sortedIndex >= 0) {
|
|
157
|
+
var _this$selectableClass;
|
|
158
|
+
// EuiSelectable should automatically handle scrolling its list to the new index
|
|
159
|
+
(_this$selectableClass = _this.selectableClassRef.current) === null || _this$selectableClass === void 0 || _this$selectableClass.setState({
|
|
160
|
+
activeOptionIndex: sortedIndex
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
_this.setState({
|
|
164
|
+
lastCheckedValue: undefined
|
|
165
|
+
});
|
|
166
|
+
}
|
|
79
167
|
});
|
|
80
168
|
var _options = props.config.options;
|
|
81
169
|
var preloadedOptions = (0, _predicate.isArray)(_options) ? {
|
|
82
|
-
|
|
83
|
-
|
|
170
|
+
unsorted: _options,
|
|
171
|
+
sorted: _options
|
|
84
172
|
} : null;
|
|
85
173
|
_this.state = {
|
|
86
174
|
popoverOpen: false,
|
|
87
175
|
error: null,
|
|
88
176
|
options: preloadedOptions,
|
|
89
|
-
|
|
177
|
+
activeItemsCount: 0
|
|
90
178
|
};
|
|
91
179
|
return _this;
|
|
92
180
|
}
|
|
@@ -116,94 +204,6 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
116
204
|
};
|
|
117
205
|
});
|
|
118
206
|
}
|
|
119
|
-
}, {
|
|
120
|
-
key: "loadOptions",
|
|
121
|
-
value: function loadOptions() {
|
|
122
|
-
var _this3 = this;
|
|
123
|
-
var loader = this.resolveOptionsLoader();
|
|
124
|
-
this.setState({
|
|
125
|
-
options: null,
|
|
126
|
-
error: null
|
|
127
|
-
});
|
|
128
|
-
loader().then(function (options) {
|
|
129
|
-
var items = {
|
|
130
|
-
on: [],
|
|
131
|
-
off: [],
|
|
132
|
-
rest: []
|
|
133
|
-
};
|
|
134
|
-
var _this3$props = _this3.props,
|
|
135
|
-
query = _this3$props.query,
|
|
136
|
-
config = _this3$props.config;
|
|
137
|
-
var multiSelect = _this3.resolveMultiSelect();
|
|
138
|
-
if (options) {
|
|
139
|
-
options.forEach(function (op) {
|
|
140
|
-
var optionField = op.field || config.field;
|
|
141
|
-
if (optionField) {
|
|
142
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
143
|
-
var checked = _this3.resolveChecked(clause);
|
|
144
|
-
if (!checked) {
|
|
145
|
-
items.rest.push(op);
|
|
146
|
-
} else if (checked === 'on') {
|
|
147
|
-
items.on.push(op);
|
|
148
|
-
} else {
|
|
149
|
-
items.off.push(op);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
return;
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
_this3.setState({
|
|
156
|
-
error: null,
|
|
157
|
-
activeItems: items.on,
|
|
158
|
-
options: {
|
|
159
|
-
all: options,
|
|
160
|
-
shown: [].concat((0, _toConsumableArray2.default)(items.on), (0, _toConsumableArray2.default)(items.off), (0, _toConsumableArray2.default)(items.rest))
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
}).catch(function () {
|
|
164
|
-
_this3.setState({
|
|
165
|
-
options: null,
|
|
166
|
-
error: 'Could not load options'
|
|
167
|
-
});
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
}, {
|
|
171
|
-
key: "filterOptions",
|
|
172
|
-
value: function filterOptions() {
|
|
173
|
-
var _this4 = this;
|
|
174
|
-
var q = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
175
|
-
this.setState(function (prevState) {
|
|
176
|
-
if ((0, _predicate.isNil)(prevState.options)) {
|
|
177
|
-
return {};
|
|
178
|
-
}
|
|
179
|
-
var predicate = _this4.getOptionFilter();
|
|
180
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
181
|
-
options: _objectSpread(_objectSpread({}, prevState.options), {}, {
|
|
182
|
-
shown: prevState.options.all.filter(function (option, i, options) {
|
|
183
|
-
var name = _this4.resolveOptionName(option).toLowerCase();
|
|
184
|
-
var query = q.toLowerCase();
|
|
185
|
-
return predicate(name, query, options);
|
|
186
|
-
})
|
|
187
|
-
})
|
|
188
|
-
});
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}, {
|
|
192
|
-
key: "getOptionFilter",
|
|
193
|
-
value: function getOptionFilter() {
|
|
194
|
-
var filterWith = this.props.config.filterWith || defaults.config.filterWith;
|
|
195
|
-
if (typeof filterWith === 'function') {
|
|
196
|
-
return filterWith;
|
|
197
|
-
}
|
|
198
|
-
if (filterWith === 'includes') {
|
|
199
|
-
return function (name, query) {
|
|
200
|
-
return name.includes(query);
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return function (name, query) {
|
|
204
|
-
return name.startsWith(query);
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
207
|
}, {
|
|
208
208
|
key: "resolveOptionName",
|
|
209
209
|
value: function resolveOptionName(option) {
|
|
@@ -212,23 +212,27 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
212
212
|
}, {
|
|
213
213
|
key: "onOptionClick",
|
|
214
214
|
value: function onOptionClick(field, value, checked) {
|
|
215
|
-
var
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
_this$props$
|
|
219
|
-
|
|
215
|
+
var _this$props$config2 = this.props.config,
|
|
216
|
+
autoClose = _this$props$config2.autoClose,
|
|
217
|
+
_this$props$config2$o = _this$props$config2.operator,
|
|
218
|
+
operator = _this$props$config2$o === void 0 ? _ast.Operator.EQ : _this$props$config2$o;
|
|
219
|
+
if (checked && this.autoSortOptions) {
|
|
220
|
+
this.setState({
|
|
221
|
+
lastCheckedValue: value
|
|
222
|
+
});
|
|
223
|
+
}
|
|
220
224
|
|
|
221
225
|
// If the consumer explicitly sets `autoClose`, always defer to that.
|
|
222
226
|
// Otherwise, default to auto-closing for single selections and leaving the
|
|
223
227
|
// popover open for multi-select (so users can continue selecting options)
|
|
224
|
-
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !multiSelect;
|
|
228
|
+
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !this.multiSelect;
|
|
225
229
|
if (shouldClosePopover) {
|
|
226
230
|
this.closePopover();
|
|
227
231
|
}
|
|
228
|
-
if (!multiSelect) {
|
|
232
|
+
if (!this.multiSelect) {
|
|
229
233
|
var _query = checked ? this.props.query.removeSimpleFieldClauses(field).addSimpleFieldValue(field, value, true, operator) : this.props.query.removeSimpleFieldClauses(field);
|
|
230
234
|
this.props.onChange(_query);
|
|
231
|
-
} else if (multiSelect === 'or') {
|
|
235
|
+
} else if (this.multiSelect === 'or') {
|
|
232
236
|
var _query2 = checked ? this.props.query.addOrFieldValue(field, value, true, operator) : this.props.query.removeOrFieldValue(field, value);
|
|
233
237
|
this.props.onChange(_query2);
|
|
234
238
|
} else {
|
|
@@ -237,10 +241,16 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
237
241
|
}
|
|
238
242
|
}
|
|
239
243
|
}, {
|
|
240
|
-
key: "
|
|
241
|
-
|
|
242
|
-
var
|
|
243
|
-
return
|
|
244
|
+
key: "autoSortOptions",
|
|
245
|
+
get: function get() {
|
|
246
|
+
var _this$props$config$au;
|
|
247
|
+
return (_this$props$config$au = this.props.config.autoSortOptions) !== null && _this$props$config$au !== void 0 ? _this$props$config$au : defaults.config.autoSortOptions;
|
|
248
|
+
}
|
|
249
|
+
}, {
|
|
250
|
+
key: "multiSelect",
|
|
251
|
+
get: function get() {
|
|
252
|
+
var _this$props$config$mu;
|
|
253
|
+
return (_this$props$config$mu = this.props.config.multiSelect) !== null && _this$props$config$mu !== void 0 ? _this$props$config$mu : defaults.config.multiSelect;
|
|
244
254
|
}
|
|
245
255
|
}, {
|
|
246
256
|
key: "componentDidMount",
|
|
@@ -252,19 +262,26 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
252
262
|
value: function componentDidUpdate(prevProps) {
|
|
253
263
|
if (this.props.query !== prevProps.query) this.loadOptions();
|
|
254
264
|
}
|
|
265
|
+
}, {
|
|
266
|
+
key: "componentWillUnmount",
|
|
267
|
+
value: function componentWillUnmount() {
|
|
268
|
+
clearTimeout(this.cacheTimeout);
|
|
269
|
+
}
|
|
255
270
|
}, {
|
|
256
271
|
key: "render",
|
|
257
272
|
value: function render() {
|
|
258
|
-
var
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
273
|
+
var _this$state$options,
|
|
274
|
+
_this$state$options2,
|
|
275
|
+
_this3 = this;
|
|
276
|
+
var _this$props2 = this.props,
|
|
277
|
+
query = _this$props2.query,
|
|
278
|
+
config = _this$props2.config;
|
|
279
|
+
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;
|
|
263
280
|
var activeTop = this.isActiveField(config.field);
|
|
264
|
-
var activeItem =
|
|
265
|
-
return
|
|
281
|
+
var activeItem = options ? options.some(function (item) {
|
|
282
|
+
return _this3.isActiveField(item.field);
|
|
266
283
|
}) : false;
|
|
267
|
-
var activeItemsCount = this.state.
|
|
284
|
+
var activeItemsCount = this.state.activeItemsCount;
|
|
268
285
|
var active = (activeTop || activeItem) && activeItemsCount > 0;
|
|
269
286
|
var button = (0, _react2.jsx)(_filter_group.EuiFilterButton, {
|
|
270
287
|
iconType: "arrowDown",
|
|
@@ -274,15 +291,15 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
274
291
|
numActiveFilters: active ? activeItemsCount : undefined,
|
|
275
292
|
grow: true
|
|
276
293
|
}, config.name);
|
|
277
|
-
var items =
|
|
294
|
+
var items = options ? options.map(function (option) {
|
|
278
295
|
var _option$view;
|
|
279
296
|
var optionField = option.field || config.field;
|
|
280
297
|
if (optionField == null) {
|
|
281
298
|
throw new Error('option.field or field should be provided in <FieldValueSelectionFilter/>');
|
|
282
299
|
}
|
|
283
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
284
|
-
var label =
|
|
285
|
-
var checked =
|
|
300
|
+
var clause = _this3.multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
301
|
+
var label = _this3.resolveOptionName(option);
|
|
302
|
+
var checked = _this3.resolveChecked(clause);
|
|
286
303
|
return {
|
|
287
304
|
label: label,
|
|
288
305
|
checked: checked,
|
|
@@ -294,7 +311,7 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
294
311
|
};
|
|
295
312
|
}) : [];
|
|
296
313
|
var threshold = config.searchThreshold || defaults.config.searchThreshold;
|
|
297
|
-
var isOverSearchThreshold =
|
|
314
|
+
var isOverSearchThreshold = options && options.length >= threshold;
|
|
298
315
|
var searchProps = {
|
|
299
316
|
searchable: false
|
|
300
317
|
};
|
|
@@ -310,31 +327,32 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
310
327
|
return (0, _react2.jsx)(_services.RenderWithEuiTheme, null, function (euiThemeContext) {
|
|
311
328
|
return (0, _react2.jsx)(_popover.EuiPopover, {
|
|
312
329
|
button: button,
|
|
313
|
-
isOpen:
|
|
314
|
-
closePopover:
|
|
330
|
+
isOpen: _this3.state.popoverOpen,
|
|
331
|
+
closePopover: _this3.closePopover.bind(_this3),
|
|
315
332
|
panelPaddingSize: "none",
|
|
316
333
|
anchorPosition: "downCenter",
|
|
317
334
|
panelProps: {
|
|
318
335
|
css: (0, _filter_group2.euiFilterGroupStyles)(euiThemeContext).euiFilterGroup__popoverPanel
|
|
319
336
|
}
|
|
320
337
|
}, (0, _react2.jsx)(_selectable.EuiSelectable, (0, _extends2.default)({
|
|
321
|
-
|
|
338
|
+
ref: _this3.selectableClassRef,
|
|
339
|
+
singleSelection: !_this3.multiSelect,
|
|
322
340
|
"aria-label": config.name,
|
|
323
341
|
options: items,
|
|
324
342
|
renderOption: function renderOption(option) {
|
|
325
343
|
return option.view;
|
|
326
344
|
},
|
|
327
|
-
isLoading: (0, _predicate.isNil)(
|
|
345
|
+
isLoading: (0, _predicate.isNil)(options),
|
|
328
346
|
loadingMessage: config.loadingMessage,
|
|
329
347
|
emptyMessage: config.noOptionsMessage,
|
|
330
|
-
errorMessage:
|
|
348
|
+
errorMessage: _this3.state.error,
|
|
331
349
|
noMatchesMessage: config.noOptionsMessage,
|
|
332
350
|
listProps: {
|
|
333
351
|
isVirtualized: isOverSearchThreshold || false
|
|
334
352
|
},
|
|
335
353
|
onChange: function onChange(options, event, changedOption) {
|
|
336
354
|
if (changedOption.data) {
|
|
337
|
-
|
|
355
|
+
_this3.onOptionClick(changedOption.data.optionField, changedOption.data.value, changedOption.checked);
|
|
338
356
|
}
|
|
339
357
|
}
|
|
340
358
|
}, searchProps), function (list, search) {
|
|
@@ -358,8 +376,7 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
358
376
|
return false;
|
|
359
377
|
}
|
|
360
378
|
var query = this.props.query;
|
|
361
|
-
|
|
362
|
-
if (multiSelect === 'or') {
|
|
379
|
+
if (this.multiSelect === 'or') {
|
|
363
380
|
return query.hasOrFieldClause(field);
|
|
364
381
|
}
|
|
365
382
|
return query.hasSimpleFieldClause(field);
|
package/package.json
CHANGED
|
@@ -45,6 +45,11 @@
|
|
|
45
45
|
@include euiDataGridCellFocus;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
// needed to override global style
|
|
49
|
+
&:focus:focus-visible {
|
|
50
|
+
outline: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
48
53
|
// On hover
|
|
49
54
|
&:hover:not(:focus, :focus-within, .euiDataGridRowCell--open) {
|
|
50
55
|
// Color the actions and focus ring grayscale on hover
|
|
@@ -10,15 +10,18 @@
|
|
|
10
10
|
@include euiDataGridHeaderCell {
|
|
11
11
|
@include euiFontSizeS;
|
|
12
12
|
|
|
13
|
-
font-weight: $euiFontWeightBold;
|
|
14
|
-
padding: $euiDataGridCellPaddingM;
|
|
15
|
-
flex: 0 0 auto;
|
|
16
13
|
position: relative;
|
|
17
|
-
align-items: center;
|
|
18
14
|
display: flex;
|
|
15
|
+
flex: 0 0 auto;
|
|
16
|
+
align-items: center;
|
|
17
|
+
padding: $euiDataGridCellPaddingM;
|
|
18
|
+
font-weight: $euiFontWeightBold;
|
|
19
19
|
|
|
20
20
|
// Workaround for focus trap
|
|
21
21
|
& > [data-focus-lock-disabled] {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: $euiSizeXS;
|
|
22
25
|
width: 100%;
|
|
23
26
|
}
|
|
24
27
|
|
|
@@ -28,6 +31,11 @@
|
|
|
28
31
|
@include euiDataGridCellFocus;
|
|
29
32
|
}
|
|
30
33
|
|
|
34
|
+
// needed to override global style
|
|
35
|
+
&:focus:focus-visible {
|
|
36
|
+
outline: none;
|
|
37
|
+
}
|
|
38
|
+
|
|
31
39
|
.euiDataGridHeaderCell__content {
|
|
32
40
|
flex-grow: 1; // ensures content stretches and allows for manual layout styles to apply
|
|
33
41
|
}
|
|
@@ -40,8 +48,18 @@
|
|
|
40
48
|
align-items: center;
|
|
41
49
|
gap: $euiSizeXS;
|
|
42
50
|
width: 100%;
|
|
51
|
+
border-radius: $euiBorderRadiusSmall;
|
|
43
52
|
font-weight: $euiFontWeightBold;
|
|
44
53
|
outline: none;
|
|
54
|
+
|
|
55
|
+
&:focus-visible {
|
|
56
|
+
outline: none;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
[data-focus-lock-disabled='false'] .euiDataGridHeaderCell__button {
|
|
61
|
+
@include euiFocusRing;
|
|
62
|
+
color: $euiFocusRingColor;
|
|
45
63
|
}
|
|
46
64
|
|
|
47
65
|
.euiDataGridHeaderCell__content {
|
|
@@ -61,9 +79,9 @@
|
|
|
61
79
|
display: flex;
|
|
62
80
|
align-items: center;
|
|
63
81
|
justify-content: center;
|
|
82
|
+
width: 0;
|
|
64
83
|
height: $euiSize;
|
|
65
84
|
overflow: hidden;
|
|
66
|
-
width: 0;
|
|
67
85
|
opacity: 0;
|
|
68
86
|
transition: width $euiAnimSpeedFast ease-in, opacity $euiAnimSpeedSlow ease-in;
|
|
69
87
|
}
|
|
@@ -71,6 +89,10 @@
|
|
|
71
89
|
&:focus-within,
|
|
72
90
|
&:hover,
|
|
73
91
|
.euiPopover-isOpen {
|
|
92
|
+
.euiDataGridHeaderCell__button {
|
|
93
|
+
padding: $euiSizeXS;
|
|
94
|
+
}
|
|
95
|
+
|
|
74
96
|
.euiDataGridHeaderCell__icon {
|
|
75
97
|
width: $euiSize;
|
|
76
98
|
opacity: 1;
|
|
@@ -947,7 +947,8 @@ EuiInMemoryTable.propTypes = {
|
|
|
947
947
|
searchThreshold: _propTypes.default.number,
|
|
948
948
|
available: _propTypes.default.func,
|
|
949
949
|
autoClose: _propTypes.default.bool,
|
|
950
|
-
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"])
|
|
950
|
+
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"]),
|
|
951
|
+
autoSortOptions: _propTypes.default.bool
|
|
951
952
|
}).isRequired, _propTypes.default.shape({
|
|
952
953
|
type: _propTypes.default.oneOf(["field_value_toggle"]).isRequired,
|
|
953
954
|
field: _propTypes.default.string.isRequired,
|
|
@@ -124,6 +124,7 @@ EuiDataGridCellContent.propTypes = {
|
|
|
124
124
|
* This can be used to display a readable column name in column hiding/sorting, where `display` won't be used.
|
|
125
125
|
* This will also be used as a `title` attribute that will display on mouseover (useful if the display text is being truncated by the column width).
|
|
126
126
|
* If not passed, `id` will be shown as the column name.
|
|
127
|
+
* Passing this together with `display` is useful to ensure an accessible label is added to the column.
|
|
127
128
|
*/
|
|
128
129
|
displayAsText: _propTypes.default.string,
|
|
129
130
|
/**
|
|
@@ -1014,6 +1015,7 @@ EuiDataGridCell.propTypes = {
|
|
|
1014
1015
|
* This can be used to display a readable column name in column hiding/sorting, where `display` won't be used.
|
|
1015
1016
|
* This will also be used as a `title` attribute that will display on mouseover (useful if the display text is being truncated by the column width).
|
|
1016
1017
|
* If not passed, `id` will be shown as the column name.
|
|
1018
|
+
* Passing this together with `display` is useful to ensure an accessible label is added to the column.
|
|
1017
1019
|
*/
|
|
1018
1020
|
displayAsText: _propTypes.default.string,
|
|
1019
1021
|
/**
|