@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
|
@@ -20,14 +20,15 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
|
|
|
20
20
|
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; }
|
|
21
21
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
22
22
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
23
|
-
function
|
|
24
|
-
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; }
|
|
23
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
25
24
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
26
25
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
26
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
28
27
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
29
28
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
30
29
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
30
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
31
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
31
32
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
32
33
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
33
34
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -51,7 +52,8 @@ var defaults = {
|
|
|
51
52
|
config: {
|
|
52
53
|
multiSelect: true,
|
|
53
54
|
filterWith: 'prefix',
|
|
54
|
-
searchThreshold: 10
|
|
55
|
+
searchThreshold: 10,
|
|
56
|
+
autoSortOptions: true
|
|
55
57
|
}
|
|
56
58
|
};
|
|
57
59
|
var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*/function (_Component) {
|
|
@@ -59,45 +61,132 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
59
61
|
var _this;
|
|
60
62
|
_classCallCheck(this, FieldValueSelectionFilter);
|
|
61
63
|
_this = _callSuper(this, FieldValueSelectionFilter, [props]);
|
|
62
|
-
_defineProperty(_this, "
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return function () {
|
|
70
|
-
var cachedOptions = _this.state.cachedOptions;
|
|
71
|
-
if (cachedOptions) {
|
|
72
|
-
return Promise.resolve(cachedOptions);
|
|
73
|
-
}
|
|
74
|
-
return options().then(function (opts) {
|
|
75
|
-
// If a cache time is set, populate the cache and also schedule a
|
|
76
|
-
// cache reset.
|
|
77
|
-
if (_this.props.config.cache != null && _this.props.config.cache > 0) {
|
|
64
|
+
_defineProperty(_this, "selectableClassRef", /*#__PURE__*/(0, _react.createRef)());
|
|
65
|
+
_defineProperty(_this, "cacheTimeout", void 0);
|
|
66
|
+
_defineProperty(_this, "loadOptions", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
67
|
+
var loadedOptions, _this$props$config, options, cache, _this$state$cachedOpt, items, _this$props, query, config;
|
|
68
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
69
|
+
while (1) switch (_context.prev = _context.next) {
|
|
70
|
+
case 0:
|
|
78
71
|
_this.setState({
|
|
79
|
-
|
|
72
|
+
options: null,
|
|
73
|
+
error: null
|
|
80
74
|
});
|
|
81
|
-
|
|
75
|
+
_this$props$config = _this.props.config, options = _this$props$config.options, cache = _this$props$config.cache;
|
|
76
|
+
_context.prev = 2;
|
|
77
|
+
if (!(0, _predicate.isArray)(options)) {
|
|
78
|
+
_context.next = 7;
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
// Synchronous options, already loaded
|
|
82
|
+
loadedOptions = options;
|
|
83
|
+
_context.next = 16;
|
|
84
|
+
break;
|
|
85
|
+
case 7:
|
|
86
|
+
if (!((_this$state$cachedOpt = _this.state.cachedOptions) !== null && _this$state$cachedOpt !== void 0)) {
|
|
87
|
+
_context.next = 11;
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
_context.t0 = _this$state$cachedOpt;
|
|
91
|
+
_context.next = 14;
|
|
92
|
+
break;
|
|
93
|
+
case 11:
|
|
94
|
+
_context.next = 13;
|
|
95
|
+
return options();
|
|
96
|
+
case 13:
|
|
97
|
+
_context.t0 = _context.sent;
|
|
98
|
+
case 14:
|
|
99
|
+
loadedOptions = _context.t0;
|
|
100
|
+
// If a cache time is set, populate the cache and schedule a cache reset
|
|
101
|
+
if (cache != null && cache > 0) {
|
|
82
102
|
_this.setState({
|
|
83
|
-
cachedOptions:
|
|
103
|
+
cachedOptions: loadedOptions
|
|
84
104
|
});
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
105
|
+
_this.cacheTimeout = setTimeout(function () {
|
|
106
|
+
_this.setState({
|
|
107
|
+
cachedOptions: null
|
|
108
|
+
});
|
|
109
|
+
}, cache);
|
|
110
|
+
}
|
|
111
|
+
case 16:
|
|
112
|
+
_context.next = 21;
|
|
113
|
+
break;
|
|
114
|
+
case 18:
|
|
115
|
+
_context.prev = 18;
|
|
116
|
+
_context.t1 = _context["catch"](2);
|
|
117
|
+
return _context.abrupt("return", _this.setState({
|
|
118
|
+
options: null,
|
|
119
|
+
error: 'Could not load options'
|
|
120
|
+
}));
|
|
121
|
+
case 21:
|
|
122
|
+
items = {
|
|
123
|
+
on: [],
|
|
124
|
+
off: [],
|
|
125
|
+
rest: []
|
|
126
|
+
};
|
|
127
|
+
_this$props = _this.props, query = _this$props.query, config = _this$props.config;
|
|
128
|
+
if (loadedOptions) {
|
|
129
|
+
loadedOptions.forEach(function (op) {
|
|
130
|
+
var optionField = op.field || config.field;
|
|
131
|
+
if (optionField) {
|
|
132
|
+
var clause = _this.multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
133
|
+
var checked = _this.resolveChecked(clause);
|
|
134
|
+
if (!checked) {
|
|
135
|
+
items.rest.push(op);
|
|
136
|
+
} else if (checked === 'on') {
|
|
137
|
+
items.on.push(op);
|
|
138
|
+
} else {
|
|
139
|
+
items.off.push(op);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
_this.setState({
|
|
146
|
+
error: null,
|
|
147
|
+
activeItemsCount: items.on.length,
|
|
148
|
+
options: {
|
|
149
|
+
unsorted: loadedOptions,
|
|
150
|
+
sorted: [].concat(_toConsumableArray(items.on), _toConsumableArray(items.off), _toConsumableArray(items.rest))
|
|
151
|
+
}
|
|
152
|
+
}, _this.scrollToAutoSortedOption);
|
|
153
|
+
case 25:
|
|
154
|
+
case "end":
|
|
155
|
+
return _context.stop();
|
|
156
|
+
}
|
|
157
|
+
}, _callee, null, [[2, 18]]);
|
|
158
|
+
})));
|
|
159
|
+
_defineProperty(_this, "scrollToAutoSortedOption", function () {
|
|
160
|
+
if (!_this.autoSortOptions) return;
|
|
161
|
+
var _this$state = _this.state,
|
|
162
|
+
lastCheckedValue = _this$state.lastCheckedValue,
|
|
163
|
+
options = _this$state.options;
|
|
164
|
+
if (lastCheckedValue) {
|
|
165
|
+
var sortedIndex = options.sorted.findIndex(function (option) {
|
|
166
|
+
return option.value === lastCheckedValue;
|
|
88
167
|
});
|
|
89
|
-
|
|
168
|
+
if (sortedIndex >= 0) {
|
|
169
|
+
var _this$selectableClass;
|
|
170
|
+
// EuiSelectable should automatically handle scrolling its list to the new index
|
|
171
|
+
(_this$selectableClass = _this.selectableClassRef.current) === null || _this$selectableClass === void 0 || _this$selectableClass.setState({
|
|
172
|
+
activeOptionIndex: sortedIndex
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
_this.setState({
|
|
176
|
+
lastCheckedValue: undefined
|
|
177
|
+
});
|
|
178
|
+
}
|
|
90
179
|
});
|
|
91
180
|
var _options = props.config.options;
|
|
92
181
|
var preloadedOptions = (0, _predicate.isArray)(_options) ? {
|
|
93
|
-
|
|
94
|
-
|
|
182
|
+
unsorted: _options,
|
|
183
|
+
sorted: _options
|
|
95
184
|
} : null;
|
|
96
185
|
_this.state = {
|
|
97
186
|
popoverOpen: false,
|
|
98
187
|
error: null,
|
|
99
188
|
options: preloadedOptions,
|
|
100
|
-
|
|
189
|
+
activeItemsCount: 0
|
|
101
190
|
};
|
|
102
191
|
return _this;
|
|
103
192
|
}
|
|
@@ -127,94 +216,6 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
127
216
|
};
|
|
128
217
|
});
|
|
129
218
|
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "loadOptions",
|
|
132
|
-
value: function loadOptions() {
|
|
133
|
-
var _this3 = this;
|
|
134
|
-
var loader = this.resolveOptionsLoader();
|
|
135
|
-
this.setState({
|
|
136
|
-
options: null,
|
|
137
|
-
error: null
|
|
138
|
-
});
|
|
139
|
-
loader().then(function (options) {
|
|
140
|
-
var items = {
|
|
141
|
-
on: [],
|
|
142
|
-
off: [],
|
|
143
|
-
rest: []
|
|
144
|
-
};
|
|
145
|
-
var _this3$props = _this3.props,
|
|
146
|
-
query = _this3$props.query,
|
|
147
|
-
config = _this3$props.config;
|
|
148
|
-
var multiSelect = _this3.resolveMultiSelect();
|
|
149
|
-
if (options) {
|
|
150
|
-
options.forEach(function (op) {
|
|
151
|
-
var optionField = op.field || config.field;
|
|
152
|
-
if (optionField) {
|
|
153
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, op.value) : query.getSimpleFieldClause(optionField, op.value);
|
|
154
|
-
var checked = _this3.resolveChecked(clause);
|
|
155
|
-
if (!checked) {
|
|
156
|
-
items.rest.push(op);
|
|
157
|
-
} else if (checked === 'on') {
|
|
158
|
-
items.on.push(op);
|
|
159
|
-
} else {
|
|
160
|
-
items.off.push(op);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return;
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
_this3.setState({
|
|
167
|
-
error: null,
|
|
168
|
-
activeItems: items.on,
|
|
169
|
-
options: {
|
|
170
|
-
all: options,
|
|
171
|
-
shown: [].concat(_toConsumableArray(items.on), _toConsumableArray(items.off), _toConsumableArray(items.rest))
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
}).catch(function () {
|
|
175
|
-
_this3.setState({
|
|
176
|
-
options: null,
|
|
177
|
-
error: 'Could not load options'
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}, {
|
|
182
|
-
key: "filterOptions",
|
|
183
|
-
value: function filterOptions() {
|
|
184
|
-
var _this4 = this;
|
|
185
|
-
var q = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
186
|
-
this.setState(function (prevState) {
|
|
187
|
-
if ((0, _predicate.isNil)(prevState.options)) {
|
|
188
|
-
return {};
|
|
189
|
-
}
|
|
190
|
-
var predicate = _this4.getOptionFilter();
|
|
191
|
-
return _objectSpread(_objectSpread({}, prevState), {}, {
|
|
192
|
-
options: _objectSpread(_objectSpread({}, prevState.options), {}, {
|
|
193
|
-
shown: prevState.options.all.filter(function (option, i, options) {
|
|
194
|
-
var name = _this4.resolveOptionName(option).toLowerCase();
|
|
195
|
-
var query = q.toLowerCase();
|
|
196
|
-
return predicate(name, query, options);
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
}, {
|
|
203
|
-
key: "getOptionFilter",
|
|
204
|
-
value: function getOptionFilter() {
|
|
205
|
-
var filterWith = this.props.config.filterWith || defaults.config.filterWith;
|
|
206
|
-
if (typeof filterWith === 'function') {
|
|
207
|
-
return filterWith;
|
|
208
|
-
}
|
|
209
|
-
if (filterWith === 'includes') {
|
|
210
|
-
return function (name, query) {
|
|
211
|
-
return name.includes(query);
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
return function (name, query) {
|
|
215
|
-
return name.startsWith(query);
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
219
|
}, {
|
|
219
220
|
key: "resolveOptionName",
|
|
220
221
|
value: function resolveOptionName(option) {
|
|
@@ -223,23 +224,27 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
223
224
|
}, {
|
|
224
225
|
key: "onOptionClick",
|
|
225
226
|
value: function onOptionClick(field, value, checked) {
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
_this$props$
|
|
230
|
-
|
|
227
|
+
var _this$props$config2 = this.props.config,
|
|
228
|
+
autoClose = _this$props$config2.autoClose,
|
|
229
|
+
_this$props$config2$o = _this$props$config2.operator,
|
|
230
|
+
operator = _this$props$config2$o === void 0 ? _ast.Operator.EQ : _this$props$config2$o;
|
|
231
|
+
if (checked && this.autoSortOptions) {
|
|
232
|
+
this.setState({
|
|
233
|
+
lastCheckedValue: value
|
|
234
|
+
});
|
|
235
|
+
}
|
|
231
236
|
|
|
232
237
|
// If the consumer explicitly sets `autoClose`, always defer to that.
|
|
233
238
|
// Otherwise, default to auto-closing for single selections and leaving the
|
|
234
239
|
// popover open for multi-select (so users can continue selecting options)
|
|
235
|
-
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !multiSelect;
|
|
240
|
+
var shouldClosePopover = autoClose !== null && autoClose !== void 0 ? autoClose : !this.multiSelect;
|
|
236
241
|
if (shouldClosePopover) {
|
|
237
242
|
this.closePopover();
|
|
238
243
|
}
|
|
239
|
-
if (!multiSelect) {
|
|
244
|
+
if (!this.multiSelect) {
|
|
240
245
|
var _query = checked ? this.props.query.removeSimpleFieldClauses(field).addSimpleFieldValue(field, value, true, operator) : this.props.query.removeSimpleFieldClauses(field);
|
|
241
246
|
this.props.onChange(_query);
|
|
242
|
-
} else if (multiSelect === 'or') {
|
|
247
|
+
} else if (this.multiSelect === 'or') {
|
|
243
248
|
var _query2 = checked ? this.props.query.addOrFieldValue(field, value, true, operator) : this.props.query.removeOrFieldValue(field, value);
|
|
244
249
|
this.props.onChange(_query2);
|
|
245
250
|
} else {
|
|
@@ -248,10 +253,16 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
248
253
|
}
|
|
249
254
|
}
|
|
250
255
|
}, {
|
|
251
|
-
key: "
|
|
252
|
-
|
|
253
|
-
var
|
|
254
|
-
return
|
|
256
|
+
key: "autoSortOptions",
|
|
257
|
+
get: function get() {
|
|
258
|
+
var _this$props$config$au;
|
|
259
|
+
return (_this$props$config$au = this.props.config.autoSortOptions) !== null && _this$props$config$au !== void 0 ? _this$props$config$au : defaults.config.autoSortOptions;
|
|
260
|
+
}
|
|
261
|
+
}, {
|
|
262
|
+
key: "multiSelect",
|
|
263
|
+
get: function get() {
|
|
264
|
+
var _this$props$config$mu;
|
|
265
|
+
return (_this$props$config$mu = this.props.config.multiSelect) !== null && _this$props$config$mu !== void 0 ? _this$props$config$mu : defaults.config.multiSelect;
|
|
255
266
|
}
|
|
256
267
|
}, {
|
|
257
268
|
key: "componentDidMount",
|
|
@@ -263,19 +274,26 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
263
274
|
value: function componentDidUpdate(prevProps) {
|
|
264
275
|
if (this.props.query !== prevProps.query) this.loadOptions();
|
|
265
276
|
}
|
|
277
|
+
}, {
|
|
278
|
+
key: "componentWillUnmount",
|
|
279
|
+
value: function componentWillUnmount() {
|
|
280
|
+
clearTimeout(this.cacheTimeout);
|
|
281
|
+
}
|
|
266
282
|
}, {
|
|
267
283
|
key: "render",
|
|
268
284
|
value: function render() {
|
|
269
|
-
var
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
285
|
+
var _this$state$options,
|
|
286
|
+
_this$state$options2,
|
|
287
|
+
_this3 = this;
|
|
288
|
+
var _this$props2 = this.props,
|
|
289
|
+
query = _this$props2.query,
|
|
290
|
+
config = _this$props2.config;
|
|
291
|
+
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;
|
|
274
292
|
var activeTop = this.isActiveField(config.field);
|
|
275
|
-
var activeItem =
|
|
276
|
-
return
|
|
293
|
+
var activeItem = options ? options.some(function (item) {
|
|
294
|
+
return _this3.isActiveField(item.field);
|
|
277
295
|
}) : false;
|
|
278
|
-
var activeItemsCount = this.state.
|
|
296
|
+
var activeItemsCount = this.state.activeItemsCount;
|
|
279
297
|
var active = (activeTop || activeItem) && activeItemsCount > 0;
|
|
280
298
|
var button = (0, _react2.jsx)(_filter_group.EuiFilterButton, {
|
|
281
299
|
iconType: "arrowDown",
|
|
@@ -285,15 +303,15 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
285
303
|
numActiveFilters: active ? activeItemsCount : undefined,
|
|
286
304
|
grow: true
|
|
287
305
|
}, config.name);
|
|
288
|
-
var items =
|
|
306
|
+
var items = options ? options.map(function (option) {
|
|
289
307
|
var _option$view;
|
|
290
308
|
var optionField = option.field || config.field;
|
|
291
309
|
if (optionField == null) {
|
|
292
310
|
throw new Error('option.field or field should be provided in <FieldValueSelectionFilter/>');
|
|
293
311
|
}
|
|
294
|
-
var clause = multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
295
|
-
var label =
|
|
296
|
-
var checked =
|
|
312
|
+
var clause = _this3.multiSelect === 'or' ? query.getOrFieldClause(optionField, option.value) : query.getSimpleFieldClause(optionField, option.value);
|
|
313
|
+
var label = _this3.resolveOptionName(option);
|
|
314
|
+
var checked = _this3.resolveChecked(clause);
|
|
297
315
|
return {
|
|
298
316
|
label: label,
|
|
299
317
|
checked: checked,
|
|
@@ -305,7 +323,7 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
305
323
|
};
|
|
306
324
|
}) : [];
|
|
307
325
|
var threshold = config.searchThreshold || defaults.config.searchThreshold;
|
|
308
|
-
var isOverSearchThreshold =
|
|
326
|
+
var isOverSearchThreshold = options && options.length >= threshold;
|
|
309
327
|
var searchProps = {
|
|
310
328
|
searchable: false
|
|
311
329
|
};
|
|
@@ -321,31 +339,32 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
321
339
|
return (0, _react2.jsx)(_services.RenderWithEuiTheme, null, function (euiThemeContext) {
|
|
322
340
|
return (0, _react2.jsx)(_popover.EuiPopover, {
|
|
323
341
|
button: button,
|
|
324
|
-
isOpen:
|
|
325
|
-
closePopover:
|
|
342
|
+
isOpen: _this3.state.popoverOpen,
|
|
343
|
+
closePopover: _this3.closePopover.bind(_this3),
|
|
326
344
|
panelPaddingSize: "none",
|
|
327
345
|
anchorPosition: "downCenter",
|
|
328
346
|
panelProps: {
|
|
329
347
|
css: (0, _filter_group2.euiFilterGroupStyles)(euiThemeContext).euiFilterGroup__popoverPanel
|
|
330
348
|
}
|
|
331
349
|
}, (0, _react2.jsx)(_selectable.EuiSelectable, _extends({
|
|
332
|
-
|
|
350
|
+
ref: _this3.selectableClassRef,
|
|
351
|
+
singleSelection: !_this3.multiSelect,
|
|
333
352
|
"aria-label": config.name,
|
|
334
353
|
options: items,
|
|
335
354
|
renderOption: function renderOption(option) {
|
|
336
355
|
return option.view;
|
|
337
356
|
},
|
|
338
|
-
isLoading: (0, _predicate.isNil)(
|
|
357
|
+
isLoading: (0, _predicate.isNil)(options),
|
|
339
358
|
loadingMessage: config.loadingMessage,
|
|
340
359
|
emptyMessage: config.noOptionsMessage,
|
|
341
|
-
errorMessage:
|
|
360
|
+
errorMessage: _this3.state.error,
|
|
342
361
|
noMatchesMessage: config.noOptionsMessage,
|
|
343
362
|
listProps: {
|
|
344
363
|
isVirtualized: isOverSearchThreshold || false
|
|
345
364
|
},
|
|
346
365
|
onChange: function onChange(options, event, changedOption) {
|
|
347
366
|
if (changedOption.data) {
|
|
348
|
-
|
|
367
|
+
_this3.onOptionClick(changedOption.data.optionField, changedOption.data.value, changedOption.checked);
|
|
349
368
|
}
|
|
350
369
|
}
|
|
351
370
|
}, searchProps), function (list, search) {
|
|
@@ -369,8 +388,7 @@ var FieldValueSelectionFilter = exports.FieldValueSelectionFilter = /*#__PURE__*
|
|
|
369
388
|
return false;
|
|
370
389
|
}
|
|
371
390
|
var query = this.props.query;
|
|
372
|
-
|
|
373
|
-
if (multiSelect === 'or') {
|
|
391
|
+
if (this.multiSelect === 'or') {
|
|
374
392
|
return query.hasOrFieldClause(field);
|
|
375
393
|
}
|
|
376
394
|
return query.hasSimpleFieldClause(field);
|
|
@@ -413,7 +431,8 @@ FieldValueSelectionFilter.propTypes = {
|
|
|
413
431
|
searchThreshold: _propTypes.default.number,
|
|
414
432
|
available: _propTypes.default.func,
|
|
415
433
|
autoClose: _propTypes.default.bool,
|
|
416
|
-
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"])
|
|
434
|
+
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"]),
|
|
435
|
+
autoSortOptions: _propTypes.default.bool
|
|
417
436
|
}).isRequired,
|
|
418
437
|
query: _propTypes.default.any.isRequired,
|
|
419
438
|
onChange: _propTypes.default.func.isRequired
|
|
@@ -370,7 +370,8 @@ EuiSearchBar.propTypes = {
|
|
|
370
370
|
searchThreshold: _propTypes.default.number,
|
|
371
371
|
available: _propTypes.default.func,
|
|
372
372
|
autoClose: _propTypes.default.bool,
|
|
373
|
-
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"])
|
|
373
|
+
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"]),
|
|
374
|
+
autoSortOptions: _propTypes.default.bool
|
|
374
375
|
}).isRequired, _propTypes.default.shape({
|
|
375
376
|
type: _propTypes.default.oneOf(["field_value_toggle"]).isRequired,
|
|
376
377
|
field: _propTypes.default.string.isRequired,
|
|
@@ -107,7 +107,8 @@ EuiSearchBarFilters.propTypes = {
|
|
|
107
107
|
searchThreshold: _propTypes.default.number,
|
|
108
108
|
available: _propTypes.default.func,
|
|
109
109
|
autoClose: _propTypes.default.bool,
|
|
110
|
-
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"])
|
|
110
|
+
operator: _propTypes.default.oneOf(["eq", "exact", "gt", "gte", "lt", "lte"]),
|
|
111
|
+
autoSortOptions: _propTypes.default.bool
|
|
111
112
|
}).isRequired, _propTypes.default.shape({
|
|
112
113
|
type: _propTypes.default.oneOf(["field_value_toggle"]).isRequired,
|
|
113
114
|
field: _propTypes.default.string.isRequired,
|
|
@@ -10,6 +10,8 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
|
10
10
|
import React, { useEffect, useState, useMemo } from 'react';
|
|
11
11
|
import { tabbable } from 'tabbable';
|
|
12
12
|
import { keys } from '../../../../services';
|
|
13
|
+
import { useGeneratedHtmlId } from '../../../../services/accessibility';
|
|
14
|
+
import { isDOMNode } from '../../../../utils';
|
|
13
15
|
import { EuiFocusTrap } from '../../../focus_trap';
|
|
14
16
|
import { EuiScreenReaderOnly } from '../../../accessibility';
|
|
15
17
|
import { EuiI18n } from '../../../i18n';
|
|
@@ -29,7 +31,8 @@ export var HandleInteractiveChildren = function HandleInteractiveChildren(_ref)
|
|
|
29
31
|
var cellEl = _ref.cellEl,
|
|
30
32
|
children = _ref.children,
|
|
31
33
|
updateCellFocusContext = _ref.updateCellFocusContext,
|
|
32
|
-
renderFocusTrap = _ref.renderFocusTrap
|
|
34
|
+
renderFocusTrap = _ref.renderFocusTrap,
|
|
35
|
+
onInteractiveChildrenFound = _ref.onInteractiveChildrenFound;
|
|
33
36
|
var _useState = useState(false),
|
|
34
37
|
_useState2 = _slicedToArray(_useState, 2),
|
|
35
38
|
hasInteractiveChildren = _useState2[0],
|
|
@@ -38,12 +41,11 @@ export var HandleInteractiveChildren = function HandleInteractiveChildren(_ref)
|
|
|
38
41
|
// On mount, disable all interactive children
|
|
39
42
|
useEffect(function () {
|
|
40
43
|
if (cellEl) {
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
44
|
+
var interactives = disableInteractives(cellEl);
|
|
45
|
+
onInteractiveChildrenFound === null || onInteractiveChildrenFound === void 0 || onInteractiveChildrenFound(interactives);
|
|
46
|
+
setHasInteractiveChildren(interactives.length > 0);
|
|
45
47
|
}
|
|
46
|
-
}, [cellEl,
|
|
48
|
+
}, [cellEl, onInteractiveChildrenFound]);
|
|
47
49
|
|
|
48
50
|
// Ensure that any interactive children that are clicked update the latest cell focus context
|
|
49
51
|
useEffect(function () {
|
|
@@ -81,6 +83,24 @@ export var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
|
81
83
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
82
84
|
isCellEntered = _useState4[0],
|
|
83
85
|
setIsCellEntered = _useState4[1];
|
|
86
|
+
var _useState5 = useState(false),
|
|
87
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
88
|
+
isExited = _useState6[0],
|
|
89
|
+
setExited = _useState6[1];
|
|
90
|
+
var keyboardHintAriaId = useGeneratedHtmlId({
|
|
91
|
+
prefix: 'euiDataGridCellHeader',
|
|
92
|
+
suffix: 'keyboardHint'
|
|
93
|
+
});
|
|
94
|
+
var exitedHintAriaId = useGeneratedHtmlId({
|
|
95
|
+
prefix: 'euiDataGridCellHeader',
|
|
96
|
+
suffix: 'exited'
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
// direct DOM manipulation as workaround to attach required hints
|
|
100
|
+
useEffect(function () {
|
|
101
|
+
var currentAriaDescribedbyId = cellEl.getAttribute('aria-describedby');
|
|
102
|
+
cellEl.setAttribute('aria-describedby', "".concat(currentAriaDescribedbyId, " ").concat(exitedHintAriaId, " ").concat(keyboardHintAriaId, " "));
|
|
103
|
+
}, [cellEl, keyboardHintAriaId, exitedHintAriaId]);
|
|
84
104
|
useEffect(function () {
|
|
85
105
|
if (isCellEntered) {
|
|
86
106
|
enableAndFocusInteractives(cellEl);
|
|
@@ -100,28 +120,52 @@ export var FocusTrappedChildren = function FocusTrappedChildren(_ref2) {
|
|
|
100
120
|
event.preventDefault();
|
|
101
121
|
setIsCellEntered(function (isCellEntered) {
|
|
102
122
|
if (isCellEntered === true) {
|
|
123
|
+
setExited(true);
|
|
103
124
|
requestAnimationFrame(function () {
|
|
104
125
|
return cellEl.focus();
|
|
105
126
|
}); // move focus to cell
|
|
106
127
|
return false;
|
|
128
|
+
} else if (
|
|
129
|
+
// when opened content is closed, we don't want Escape to return to the cell
|
|
130
|
+
// immediately but instead return focus to a trigger as expected
|
|
131
|
+
isCellEntered === false && isDOMNode(event.target) && isDOMNode(event.currentTarget) && event.currentTarget.contains(event.target)) {
|
|
132
|
+
return true;
|
|
107
133
|
}
|
|
108
134
|
return isCellEntered;
|
|
109
135
|
});
|
|
110
136
|
break;
|
|
111
137
|
}
|
|
112
138
|
};
|
|
139
|
+
|
|
140
|
+
// ensures the SR text is reset when navigating to a different cell
|
|
141
|
+
var onBlur = function onBlur() {
|
|
142
|
+
return setExited(false);
|
|
143
|
+
};
|
|
113
144
|
cellEl.addEventListener('keyup', onKeyUp);
|
|
145
|
+
cellEl.addEventListener('blur', onBlur);
|
|
114
146
|
return function () {
|
|
115
147
|
cellEl.removeEventListener('keyup', onKeyUp);
|
|
148
|
+
cellEl.removeEventListener('blur', onBlur);
|
|
116
149
|
};
|
|
117
150
|
}, [cellEl]);
|
|
118
151
|
return ___EmotionJSX(EuiFocusTrap, {
|
|
119
152
|
disabled: !isCellEntered,
|
|
153
|
+
clickOutsideDisables: true,
|
|
120
154
|
onDeactivation: function onDeactivation() {
|
|
121
155
|
return setIsCellEntered(false);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
156
|
+
}
|
|
157
|
+
}, children, ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
|
|
158
|
+
id: exitedHintAriaId,
|
|
159
|
+
"aria-hidden": "true"
|
|
160
|
+
}, isExited && ___EmotionJSX(EuiI18n
|
|
161
|
+
// eslint-disable-next-line local/i18n
|
|
162
|
+
, {
|
|
163
|
+
token: "euiDataGridCell.focusTrapExitPrompt",
|
|
164
|
+
default: "Exited cell content."
|
|
165
|
+
}))), ___EmotionJSX(EuiScreenReaderOnly, null, ___EmotionJSX("p", {
|
|
166
|
+
id: keyboardHintAriaId,
|
|
167
|
+
"aria-hidden": "true"
|
|
168
|
+
}, !isCellEntered && ___EmotionJSX(EuiI18n
|
|
125
169
|
// eslint-disable-next-line local/i18n
|
|
126
170
|
, {
|
|
127
171
|
token: "euiDataGridCell.focusTrapEnterPrompt",
|
|
@@ -145,7 +189,8 @@ var enableAndFocusInteractives = function enableAndFocusInteractives(cell) {
|
|
|
145
189
|
var interactives = cell.querySelectorAll('[data-euigrid-tab-managed]');
|
|
146
190
|
interactives.forEach(function (element, i) {
|
|
147
191
|
element.setAttribute('tabIndex', '0');
|
|
148
|
-
if
|
|
192
|
+
// focus the first element only if we're on the cell and not inside of it
|
|
193
|
+
if (i === 0 && !cell.contains(document.activeElement)) {
|
|
149
194
|
element.focus();
|
|
150
195
|
}
|
|
151
196
|
});
|