@elastic/eui 77.1.1 → 77.2.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.
Files changed (108) hide show
  1. package/README.md +30 -29
  2. package/dist/eui_theme_dark.css +70 -158
  3. package/dist/eui_theme_dark.min.css +1 -1
  4. package/dist/eui_theme_light.css +70 -158
  5. package/dist/eui_theme_light.min.css +1 -1
  6. package/es/components/basic_table/basic_table.a11y.js +202 -0
  7. package/es/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +1 -1
  8. package/es/components/date_picker/date_picker.js +23 -15
  9. package/es/components/date_picker/date_picker_range.js +36 -42
  10. package/es/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  11. package/es/components/form/field_number/field_number.js +39 -8
  12. package/es/components/form/field_text/field_text.js +1 -1
  13. package/es/components/form/form_control_layout/form_control_layout.js +67 -30
  14. package/es/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  15. package/es/components/form/form_control_layout/form_control_layout_icons.js +12 -20
  16. package/es/components/form/range/dual_range.js +2 -4
  17. package/es/components/form/range/range.js +0 -2
  18. package/es/components/form/range/range_input.js +54 -13
  19. package/es/components/form/validatable_control/validatable_control.js +15 -5
  20. package/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  21. package/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
  22. package/es/components/suggest/suggest.a11y.js +70 -0
  23. package/es/components/table/table.a11y.js +75 -0
  24. package/eui.d.ts +54 -54
  25. package/i18ntokens.json +26 -8
  26. package/lib/components/basic_table/basic_table.a11y.js +194 -0
  27. package/lib/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +2 -2
  28. package/lib/components/date_picker/date_picker.js +23 -15
  29. package/lib/components/date_picker/date_picker_range.js +35 -41
  30. package/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  31. package/lib/components/form/field_number/field_number.js +42 -8
  32. package/lib/components/form/field_text/field_text.js +1 -1
  33. package/lib/components/form/form_control_layout/form_control_layout.js +67 -35
  34. package/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  35. package/lib/components/form/form_control_layout/form_control_layout_icons.js +11 -19
  36. package/lib/components/form/range/dual_range.js +2 -4
  37. package/lib/components/form/range/range.js +0 -2
  38. package/lib/components/form/range/range_input.js +52 -11
  39. package/lib/components/form/validatable_control/validatable_control.js +14 -12
  40. package/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  41. package/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
  42. package/lib/components/suggest/suggest.a11y.js +73 -0
  43. package/lib/components/table/table.a11y.js +78 -0
  44. package/optimize/es/components/basic_table/basic_table.a11y.js +194 -0
  45. package/optimize/es/components/basic_table/{table.a11y.js → in_memory_table.a11y.js} +1 -1
  46. package/optimize/es/components/date_picker/date_picker.js +17 -14
  47. package/optimize/es/components/date_picker/date_picker_range.js +20 -14
  48. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  49. package/optimize/es/components/form/field_number/field_number.js +34 -8
  50. package/optimize/es/components/form/field_text/field_text.js +1 -1
  51. package/optimize/es/components/form/form_control_layout/form_control_layout.js +67 -30
  52. package/optimize/es/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  53. package/optimize/es/components/form/form_control_layout/form_control_layout_icons.js +10 -20
  54. package/optimize/es/components/form/range/dual_range.js +2 -4
  55. package/optimize/es/components/form/range/range.js +0 -2
  56. package/optimize/es/components/form/range/range_input.js +49 -12
  57. package/optimize/es/components/form/validatable_control/validatable_control.js +10 -5
  58. package/optimize/es/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  59. package/optimize/es/components/search_bar/query/ast_to_es_query_string.js +3 -0
  60. package/optimize/es/components/suggest/suggest.a11y.js +70 -0
  61. package/optimize/es/components/table/table.a11y.js +75 -0
  62. package/optimize/lib/components/basic_table/basic_table.a11y.js +188 -0
  63. package/{test-env/components/basic_table/table.a11y.js → optimize/lib/components/basic_table/in_memory_table.a11y.js} +2 -2
  64. package/optimize/lib/components/date_picker/date_picker.js +17 -14
  65. package/optimize/lib/components/date_picker/date_picker_range.js +19 -13
  66. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  67. package/optimize/lib/components/form/field_number/field_number.js +37 -8
  68. package/optimize/lib/components/form/field_text/field_text.js +1 -1
  69. package/optimize/lib/components/form/form_control_layout/form_control_layout.js +67 -35
  70. package/optimize/lib/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  71. package/optimize/lib/components/form/form_control_layout/form_control_layout_icons.js +9 -19
  72. package/optimize/lib/components/form/range/dual_range.js +2 -4
  73. package/optimize/lib/components/form/range/range.js +0 -2
  74. package/optimize/lib/components/form/range/range_input.js +47 -10
  75. package/optimize/lib/components/form/validatable_control/validatable_control.js +10 -4
  76. package/optimize/lib/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  77. package/optimize/lib/components/search_bar/query/ast_to_es_query_string.js +3 -0
  78. package/optimize/lib/components/suggest/suggest.a11y.js +73 -0
  79. package/optimize/lib/components/table/table.a11y.js +78 -0
  80. package/package.json +1 -1
  81. package/src/components/date_picker/_date_picker_range.scss +0 -60
  82. package/src/components/date_picker/super_date_picker/_super_date_picker.scss +23 -11
  83. package/src/components/date_picker/super_date_picker/_variables.scss +3 -0
  84. package/src/components/date_picker/super_date_picker/date_popover/_date_popover_button.scss +5 -7
  85. package/src/components/form/form_control_layout/_form_control_layout.scss +2 -2
  86. package/src/components/form/form_control_layout/_form_control_layout_delimited.scss +12 -36
  87. package/src/components/form/form_control_layout/_form_control_layout_icons.scss +27 -6
  88. package/src/themes/amsterdam/overrides/_date_picker.scss +0 -14
  89. package/src/themes/amsterdam/overrides/_index.scss +0 -1
  90. package/test-env/components/basic_table/basic_table.a11y.js +188 -0
  91. package/{optimize/lib/components/basic_table/table.a11y.js → test-env/components/basic_table/in_memory_table.a11y.js} +2 -2
  92. package/test-env/components/date_picker/date_picker.js +23 -15
  93. package/test-env/components/date_picker/date_picker_range.js +35 -41
  94. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +99 -84
  95. package/test-env/components/form/field_number/field_number.js +37 -8
  96. package/test-env/components/form/field_text/field_text.js +1 -1
  97. package/test-env/components/form/form_control_layout/form_control_layout.js +68 -35
  98. package/test-env/components/form/form_control_layout/form_control_layout_delimited.js +31 -11
  99. package/test-env/components/form/form_control_layout/form_control_layout_icons.js +11 -19
  100. package/test-env/components/form/range/dual_range.js +2 -4
  101. package/test-env/components/form/range/range.js +0 -2
  102. package/test-env/components/form/range/range_input.js +47 -11
  103. package/test-env/components/form/validatable_control/validatable_control.js +9 -4
  104. package/test-env/components/search_bar/query/ast_to_es_query_dsl.js +6 -1
  105. package/test-env/components/search_bar/query/ast_to_es_query_string.js +3 -0
  106. package/test-env/components/suggest/suggest.a11y.js +73 -0
  107. package/test-env/components/table/table.a11y.js +78 -0
  108. package/src/themes/amsterdam/overrides/_date_popover_button.scss +0 -14
@@ -205,6 +205,36 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
205
205
  _this.asyncInterval = new _async_interval.AsyncInterval(handler, refreshInterval);
206
206
  }
207
207
  });
208
+ _defineProperty(_assertThisInitialized(_this), "renderQuickSelect", function () {
209
+ var _this$props2 = _this.props,
210
+ start = _this$props2.start,
211
+ end = _this$props2.end,
212
+ customQuickSelectPanels = _this$props2.customQuickSelectPanels,
213
+ customQuickSelectRender = _this$props2.customQuickSelectRender,
214
+ commonlyUsedRanges = _this$props2.commonlyUsedRanges,
215
+ timeOptions = _this$props2.timeOptions,
216
+ dateFormat = _this$props2.dateFormat,
217
+ onRefreshChange = _this$props2.onRefreshChange,
218
+ recentlyUsedRanges = _this$props2.recentlyUsedRanges,
219
+ refreshInterval = _this$props2.refreshInterval,
220
+ isPaused = _this$props2.isPaused,
221
+ isDisabled = _this$props2.isDisabled;
222
+ return (0, _react2.jsx)(_quick_select_popover.EuiQuickSelectPopover, {
223
+ applyRefreshInterval: onRefreshChange ? _this.onRefreshChange : undefined,
224
+ applyTime: _this.applyQuickTime,
225
+ commonlyUsedRanges: commonlyUsedRanges,
226
+ customQuickSelectPanels: customQuickSelectPanels,
227
+ customQuickSelectRender: customQuickSelectRender,
228
+ dateFormat: dateFormat,
229
+ end: end,
230
+ isDisabled: isDisabled,
231
+ isPaused: isPaused,
232
+ recentlyUsedRanges: recentlyUsedRanges,
233
+ refreshInterval: refreshInterval,
234
+ start: start,
235
+ timeOptions: timeOptions
236
+ });
237
+ });
208
238
  _defineProperty(_assertThisInitialized(_this), "renderDatePickerRange", function () {
209
239
  var _this$state = _this.state,
210
240
  end = _this$state.end,
@@ -214,24 +244,47 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
214
244
  isStartDatePopoverOpen = _this$state.isStartDatePopoverOpen,
215
245
  showPrettyDuration = _this$state.showPrettyDuration,
216
246
  start = _this$state.start;
217
- var _this$props2 = _this.props,
218
- commonlyUsedRanges = _this$props2.commonlyUsedRanges,
219
- timeOptions = _this$props2.timeOptions,
220
- dateFormat = _this$props2.dateFormat,
221
- isDisabled = _this$props2.isDisabled,
222
- locale = _this$props2.locale,
223
- timeFormat = _this$props2.timeFormat,
224
- utcOffset = _this$props2.utcOffset,
225
- compressed = _this$props2.compressed,
226
- onFocus = _this$props2.onFocus;
247
+ var _this$props3 = _this.props,
248
+ isQuickSelectOnly = _this$props3.isQuickSelectOnly,
249
+ showUpdateButton = _this$props3.showUpdateButton,
250
+ commonlyUsedRanges = _this$props3.commonlyUsedRanges,
251
+ timeOptions = _this$props3.timeOptions,
252
+ dateFormat = _this$props3.dateFormat,
253
+ refreshInterval = _this$props3.refreshInterval,
254
+ isPaused = _this$props3.isPaused,
255
+ isDisabled = _this$props3.isDisabled,
256
+ isLoading = _this$props3.isLoading,
257
+ locale = _this$props3.locale,
258
+ timeFormat = _this$props3.timeFormat,
259
+ utcOffset = _this$props3.utcOffset,
260
+ compressed = _this$props3.compressed,
261
+ onFocus = _this$props3.onFocus,
262
+ className = _this$props3.className,
263
+ dataTestSubj = _this$props3['data-test-subj'];
264
+ var autoRefreshAppend = !isPaused ? (0, _react2.jsx)(_auto_refresh.EuiAutoRefreshButton, {
265
+ refreshInterval: refreshInterval,
266
+ isDisabled: isDisabled,
267
+ isPaused: isPaused,
268
+ onRefreshChange: _this.onRefreshChange,
269
+ shortHand: true
270
+ }) : undefined;
271
+ var formControlLayoutProps = {
272
+ className: (0, _classnames.default)('euiSuperDatePicker', className),
273
+ compressed: compressed,
274
+ isInvalid: isInvalid,
275
+ isLoading: isLoading && !showUpdateButton,
276
+ disabled: isDisabled,
277
+ prepend: _this.renderQuickSelect(),
278
+ append: autoRefreshAppend,
279
+ 'data-test-subj': dataTestSubj
280
+ };
281
+ if (isQuickSelectOnly) {
282
+ return (0, _react2.jsx)(_form.EuiFormControlLayout, _extends({
283
+ iconsPosition: "static"
284
+ }, formControlLayoutProps));
285
+ }
227
286
  if (showPrettyDuration && !isStartDatePopoverOpen && !isEndDatePopoverOpen) {
228
- return (0, _react2.jsx)(_date_picker_range.EuiDatePickerRange, {
229
- className: "euiDatePickerRange--inGroup",
230
- iconType: false,
231
- isCustom: true,
232
- startDateControl: (0, _react2.jsx)("div", null),
233
- endDateControl: (0, _react2.jsx)("div", null)
234
- }, (0, _react2.jsx)("button", {
287
+ return (0, _react2.jsx)(_form.EuiFormControlLayout, formControlLayoutProps, (0, _react2.jsx)("button", {
235
288
  className: (0, _classnames.default)('euiSuperDatePicker__prettyFormat', {
236
289
  'euiSuperDatePicker__prettyFormat--disabled': isDisabled
237
290
  }),
@@ -248,12 +301,12 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
248
301
  }
249
302
  return (0, _react2.jsx)(_context.EuiI18nConsumer, null, function (_ref4) {
250
303
  var contextLocale = _ref4.locale;
251
- return (0, _react2.jsx)(_date_picker_range.EuiDatePickerRange, {
252
- className: "euiDatePickerRange--inGroup",
253
- iconType: false,
254
- isInvalid: isInvalid,
255
- disabled: isDisabled,
304
+ return (0, _react2.jsx)(_date_picker_range.EuiDatePickerRange, _extends({}, formControlLayoutProps, {
305
+ className: (0, _classnames.default)(formControlLayoutProps.className, {
306
+ 'euiSuperDatePicker--needsUpdating': hasChanged && !isDisabled && !isInvalid
307
+ }),
256
308
  isCustom: true,
309
+ iconType: false,
257
310
  startDateControl: (0, _react2.jsx)(_date_popover_button.EuiDatePopoverButton, {
258
311
  className: "euiSuperDatePicker__startPopoverButton",
259
312
  compressed: compressed,
@@ -296,15 +349,15 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
296
349
  onFocus: onFocus
297
350
  }
298
351
  })
299
- });
352
+ }));
300
353
  });
301
354
  });
302
355
  _defineProperty(_assertThisInitialized(_this), "handleClickUpdateButton", function () {
303
356
  if (!_this.state.hasChanged && _this.props.onRefresh) {
304
- var _this$props3 = _this.props,
305
- start = _this$props3.start,
306
- end = _this$props3.end,
307
- refreshInterval = _this$props3.refreshInterval;
357
+ var _this$props4 = _this.props,
358
+ start = _this$props4.start,
359
+ end = _this$props4.end,
360
+ refreshInterval = _this$props4.refreshInterval;
308
361
  _this.props.onRefresh({
309
362
  start: start,
310
363
  end: end,
@@ -315,12 +368,12 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
315
368
  }
316
369
  });
317
370
  _defineProperty(_assertThisInitialized(_this), "renderUpdateButton", function () {
318
- var _this$props4 = _this.props,
319
- isLoading = _this$props4.isLoading,
320
- isDisabled = _this$props4.isDisabled,
321
- updateButtonProps = _this$props4.updateButtonProps,
322
- showUpdateButton = _this$props4.showUpdateButton,
323
- compressed = _this$props4.compressed;
371
+ var _this$props5 = _this.props,
372
+ isLoading = _this$props5.isLoading,
373
+ isDisabled = _this$props5.isDisabled,
374
+ updateButtonProps = _this$props5.updateButtonProps,
375
+ showUpdateButton = _this$props5.showUpdateButton,
376
+ compressed = _this$props5.compressed;
324
377
  if (!showUpdateButton) return null;
325
378
  return (0, _react2.jsx)(_flex.EuiFlexItem, {
326
379
  grow: false
@@ -340,52 +393,21 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
340
393
  _createClass(EuiSuperDatePickerInternal, [{
341
394
  key: "render",
342
395
  value: function render() {
343
- var _this$props5 = this.props,
344
- commonlyUsedRanges = _this$props5.commonlyUsedRanges,
345
- timeOptions = _this$props5.timeOptions,
346
- customQuickSelectPanels = _this$props5.customQuickSelectPanels,
347
- customQuickSelectRender = _this$props5.customQuickSelectRender,
348
- dateFormat = _this$props5.dateFormat,
349
- end = _this$props5.end,
350
- isAutoRefreshOnly = _this$props5.isAutoRefreshOnly,
351
- isDisabled = _this$props5.isDisabled,
352
- isPaused = _this$props5.isPaused,
353
- onRefreshChange = _this$props5.onRefreshChange,
354
- recentlyUsedRanges = _this$props5.recentlyUsedRanges,
355
- refreshInterval = _this$props5.refreshInterval,
356
- showUpdateButton = _this$props5.showUpdateButton,
357
- start = _this$props5.start,
358
- dataTestSubj = _this$props5['data-test-subj'],
359
- _width = _this$props5.width,
360
- isQuickSelectOnly = _this$props5.isQuickSelectOnly,
361
- compressed = _this$props5.compressed,
362
- className = _this$props5.className;
396
+ var _this$props6 = this.props,
397
+ isAutoRefreshOnly = _this$props6.isAutoRefreshOnly,
398
+ isDisabled = _this$props6.isDisabled,
399
+ isPaused = _this$props6.isPaused,
400
+ onRefreshChange = _this$props6.onRefreshChange,
401
+ refreshInterval = _this$props6.refreshInterval,
402
+ showUpdateButton = _this$props6.showUpdateButton,
403
+ dataTestSubj = _this$props6['data-test-subj'],
404
+ _width = _this$props6.width,
405
+ isQuickSelectOnly = _this$props6.isQuickSelectOnly,
406
+ compressed = _this$props6.compressed,
407
+ className = _this$props6.className;
363
408
 
364
409
  // Force reduction in width if showing quick select only
365
410
  var width = isQuickSelectOnly ? 'auto' : _width;
366
- var autoRefreshAppend = !isPaused ? (0, _react2.jsx)(_auto_refresh.EuiAutoRefreshButton, {
367
- className: "euiFormControlLayout__append",
368
- refreshInterval: refreshInterval,
369
- isDisabled: isDisabled,
370
- isPaused: isPaused,
371
- onRefreshChange: this.onRefreshChange,
372
- shortHand: true
373
- }) : undefined;
374
- var quickSelect = (0, _react2.jsx)(_quick_select_popover.EuiQuickSelectPopover, {
375
- applyRefreshInterval: onRefreshChange ? this.onRefreshChange : undefined,
376
- applyTime: this.applyQuickTime,
377
- commonlyUsedRanges: commonlyUsedRanges,
378
- customQuickSelectPanels: customQuickSelectPanels,
379
- customQuickSelectRender: customQuickSelectRender,
380
- dateFormat: dateFormat,
381
- end: end,
382
- isDisabled: isDisabled,
383
- isPaused: isPaused,
384
- recentlyUsedRanges: recentlyUsedRanges,
385
- refreshInterval: refreshInterval,
386
- start: start,
387
- timeOptions: timeOptions
388
- });
389
411
  var flexWrapperClasses = (0, _classnames.default)('euiSuperDatePicker__flexWrapper', {
390
412
  'euiSuperDatePicker__flexWrapper--noUpdateButton': !showUpdateButton,
391
413
  'euiSuperDatePicker__flexWrapper--isAutoRefreshOnly': isAutoRefreshOnly,
@@ -406,14 +428,7 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
406
428
  isDisabled: isDisabled,
407
429
  "data-test-subj": dataTestSubj,
408
430
  className: className
409
- })) : (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_flex.EuiFlexItem, null, (0, _react2.jsx)(_form.EuiFormControlLayout, {
410
- className: (0, _classnames.default)('euiSuperDatePicker', className),
411
- compressed: compressed,
412
- isDisabled: isDisabled,
413
- prepend: quickSelect,
414
- append: autoRefreshAppend,
415
- "data-test-subj": dataTestSubj
416
- }, !isQuickSelectOnly && this.renderDatePickerRange())), this.renderUpdateButton()));
431
+ })) : (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_flex.EuiFlexItem, null, this.renderDatePickerRange()), this.renderUpdateButton()));
417
432
  }
418
433
  }], [{
419
434
  key: "getDerivedStateFromProps",
@@ -1,20 +1,30 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.EuiFieldNumber = void 0;
7
- var _react = _interopRequireDefault(require("react"));
8
+ var _react = _interopRequireWildcard(require("react"));
8
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
9
10
  var _classnames = _interopRequireDefault(require("classnames"));
10
- var _form_control_layout = require("../form_control_layout");
11
+ var _services = require("../../../services");
11
12
  var _validatable_control = require("../validatable_control");
12
- var _eui_form_context = require("../eui_form_context");
13
+ var _form_control_layout = require("../form_control_layout");
13
14
  var _num_icons = require("../form_control_layout/_num_icons");
15
+ var _eui_form_context = require("../eui_form_context");
14
16
  var _react2 = require("@emotion/react");
15
- var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly"];
17
+ var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "onKeyDown"];
16
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
21
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
22
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
23
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
25
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
26
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
27
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
28
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
19
29
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
20
30
  var EuiFieldNumber = function EuiFieldNumber(props) {
@@ -40,9 +50,31 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
40
50
  inputRef = props.inputRef,
41
51
  readOnly = props.readOnly,
42
52
  controlOnly = props.controlOnly,
53
+ _onKeyDown = props.onKeyDown,
43
54
  rest = _objectWithoutProperties(props, _excluded);
44
- var numIconsClass = (0, _num_icons.getFormControlClassNameForIconCount)({
45
- isInvalid: isInvalid,
55
+
56
+ // Attempt to determine additional invalid state. The native number input
57
+ // will set :invalid state automatically, but we need to also set
58
+ // `aria-invalid` as well as display an icon. We also want to *not* set this on
59
+ // EuiValidatableControl, in order to not override custom validity messages
60
+ var _useState = (0, _react.useState)(false),
61
+ _useState2 = _slicedToArray(_useState, 2),
62
+ isNativelyInvalid = _useState2[0],
63
+ setIsNativelyInvalid = _useState2[1];
64
+ var validityRef = (0, _react.useRef)(null);
65
+ var setRefs = (0, _services.useCombinedRefs)([validityRef, inputRef]);
66
+
67
+ // Note that we can't use hook into `onChange` because browsers don't emit change events
68
+ // for invalid values - see https://github.com/facebook/react/issues/16554
69
+ var onKeyDown = (0, _react.useCallback)(function (e) {
70
+ _onKeyDown === null || _onKeyDown === void 0 ? void 0 : _onKeyDown(e);
71
+ // Wait a beat before checking validity - we can't use `e.target` as it's stale
72
+ requestAnimationFrame(function () {
73
+ setIsNativelyInvalid(!validityRef.current.validity.valid);
74
+ });
75
+ }, [_onKeyDown]);
76
+ var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
77
+ isInvalid: isInvalid || isNativelyInvalid,
46
78
  isLoading: isLoading
47
79
  });
48
80
  var classes = (0, _classnames.default)('euiFieldNumber', className, numIconsClass, {
@@ -64,7 +96,9 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
64
96
  placeholder: placeholder,
65
97
  readOnly: readOnly,
66
98
  className: classes,
67
- ref: inputRef
99
+ ref: setRefs,
100
+ onKeyDown: onKeyDown,
101
+ "aria-invalid": isInvalid || isNativelyInvalid
68
102
  }, rest)));
69
103
  if (controlOnly) {
70
104
  return control;
@@ -73,7 +107,7 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
73
107
  icon: icon,
74
108
  fullWidth: fullWidth,
75
109
  isLoading: isLoading,
76
- isInvalid: isInvalid,
110
+ isInvalid: isInvalid || isNativelyInvalid,
77
111
  compressed: compressed,
78
112
  readOnly: readOnly,
79
113
  prepend: prepend,
@@ -37,7 +37,7 @@ var EuiFieldText = function EuiFieldText(props) {
37
37
  readOnly = props.readOnly,
38
38
  controlOnly = props.controlOnly,
39
39
  rest = _objectWithoutProperties(props, _excluded);
40
- var numIconsClass = (0, _num_icons.getFormControlClassNameForIconCount)({
40
+ var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
41
41
  isInvalid: isInvalid,
42
42
  isLoading: isLoading
43
43
  });
@@ -4,12 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.EuiFormControlLayout = void 0;
7
- Object.defineProperty(exports, "ICON_SIDES", {
8
- enumerable: true,
9
- get: function get() {
10
- return _form_control_layout_icons.ICON_SIDES;
11
- }
12
- });
13
7
  var _react = _interopRequireWildcard(require("react"));
14
8
  var _propTypes = _interopRequireDefault(require("prop-types"));
15
9
  var _classnames = _interopRequireDefault(require("classnames"));
@@ -17,7 +11,7 @@ var _form_control_layout_icons = require("./form_control_layout_icons");
17
11
  var _form_label = require("../form_label");
18
12
  var _eui_form_context = require("../eui_form_context");
19
13
  var _react2 = require("@emotion/react");
20
- var _excluded = ["children", "icon", "clear", "fullWidth", "isLoading", "isDisabled", "compressed", "className", "prepend", "append", "readOnly", "isInvalid", "isDropdown", "inputId"];
14
+ var _excluded = ["children", "icon", "iconsPosition", "clear", "fullWidth", "isLoading", "isDisabled", "compressed", "className", "prepend", "append", "readOnly", "isInvalid", "isDropdown", "inputId"];
21
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
16
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
17
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -42,31 +36,75 @@ var EuiFormControlLayout = /*#__PURE__*/function (_Component) {
42
36
  _inherits(EuiFormControlLayout, _Component);
43
37
  var _super = _createSuper(EuiFormControlLayout);
44
38
  function EuiFormControlLayout() {
39
+ var _this;
45
40
  _classCallCheck(this, EuiFormControlLayout);
46
- return _super.apply(this, arguments);
41
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
42
+ args[_key] = arguments[_key];
43
+ }
44
+ _this = _super.call.apply(_super, [this].concat(args));
45
+ _defineProperty(_assertThisInitialized(_this), "renderLeftIcons", function () {
46
+ var _this$props = _this.props,
47
+ icon = _this$props.icon,
48
+ iconsPosition = _this$props.iconsPosition,
49
+ compressed = _this$props.compressed;
50
+ var leftCustomIcon = icon && (icon === null || icon === void 0 ? void 0 : icon.side) !== 'right' ? icon : undefined;
51
+ return leftCustomIcon ? (0, _react2.jsx)(_form_control_layout_icons.EuiFormControlLayoutIcons, {
52
+ side: "left",
53
+ icon: leftCustomIcon,
54
+ iconsPosition: iconsPosition,
55
+ compressed: compressed
56
+ }) : null;
57
+ });
58
+ _defineProperty(_assertThisInitialized(_this), "renderRightIcons", function () {
59
+ var _this$props2 = _this.props,
60
+ icon = _this$props2.icon,
61
+ iconsPosition = _this$props2.iconsPosition,
62
+ clear = _this$props2.clear,
63
+ compressed = _this$props2.compressed,
64
+ isLoading = _this$props2.isLoading,
65
+ isInvalid = _this$props2.isInvalid,
66
+ isDisabled = _this$props2.isDisabled,
67
+ readOnly = _this$props2.readOnly,
68
+ isDropdown = _this$props2.isDropdown;
69
+ var hasDropdownIcon = !readOnly && !isDisabled && isDropdown;
70
+ var rightCustomIcon = icon && (icon === null || icon === void 0 ? void 0 : icon.side) === 'right' ? icon : undefined;
71
+ var hasRightIcons = rightCustomIcon || clear || isLoading || isInvalid || hasDropdownIcon;
72
+ return hasRightIcons ? (0, _react2.jsx)(_form_control_layout_icons.EuiFormControlLayoutIcons, {
73
+ side: "right",
74
+ icon: rightCustomIcon,
75
+ iconsPosition: iconsPosition,
76
+ compressed: compressed,
77
+ clear: clear,
78
+ isLoading: isLoading,
79
+ isInvalid: isInvalid,
80
+ isDropdown: hasDropdownIcon
81
+ }) : null;
82
+ });
83
+ return _this;
47
84
  }
48
85
  _createClass(EuiFormControlLayout, [{
49
86
  key: "render",
50
87
  value: function render() {
51
88
  var _ref = this.context,
52
89
  defaultFullWidth = _ref.defaultFullWidth;
53
- var _this$props = this.props,
54
- children = _this$props.children,
55
- icon = _this$props.icon,
56
- clear = _this$props.clear,
57
- _this$props$fullWidth = _this$props.fullWidth,
58
- fullWidth = _this$props$fullWidth === void 0 ? defaultFullWidth : _this$props$fullWidth,
59
- isLoading = _this$props.isLoading,
60
- isDisabled = _this$props.isDisabled,
61
- compressed = _this$props.compressed,
62
- className = _this$props.className,
63
- prepend = _this$props.prepend,
64
- append = _this$props.append,
65
- readOnly = _this$props.readOnly,
66
- invalid = _this$props.isInvalid,
67
- isDropdown = _this$props.isDropdown,
68
- inputId = _this$props.inputId,
69
- rest = _objectWithoutProperties(_this$props, _excluded);
90
+ var _this$props3 = this.props,
91
+ children = _this$props3.children,
92
+ icon = _this$props3.icon,
93
+ iconsPosition = _this$props3.iconsPosition,
94
+ clear = _this$props3.clear,
95
+ _this$props3$fullWidt = _this$props3.fullWidth,
96
+ fullWidth = _this$props3$fullWidt === void 0 ? defaultFullWidth : _this$props3$fullWidt,
97
+ isLoading = _this$props3.isLoading,
98
+ isDisabled = _this$props3.isDisabled,
99
+ compressed = _this$props3.compressed,
100
+ className = _this$props3.className,
101
+ prepend = _this$props3.prepend,
102
+ append = _this$props3.append,
103
+ readOnly = _this$props3.readOnly,
104
+ isInvalid = _this$props3.isInvalid,
105
+ isDropdown = _this$props3.isDropdown,
106
+ inputId = _this$props3.inputId,
107
+ rest = _objectWithoutProperties(_this$props3, _excluded);
70
108
  var classes = (0, _classnames.default)('euiFormControlLayout', {
71
109
  'euiFormControlLayout--fullWidth': fullWidth,
72
110
  'euiFormControlLayout--compressed': compressed,
@@ -80,19 +118,12 @@ var EuiFormControlLayout = /*#__PURE__*/function (_Component) {
80
118
  className: classes
81
119
  }, rest), prependNodes, (0, _react2.jsx)("div", {
82
120
  className: "euiFormControlLayout__childrenWrapper"
83
- }, children, (0, _react2.jsx)(_form_control_layout_icons.EuiFormControlLayoutIcons, {
84
- icon: icon,
85
- clear: clear,
86
- compressed: compressed,
87
- isLoading: isLoading,
88
- isInvalid: invalid,
89
- isDropdown: !readOnly && !isDisabled && isDropdown
90
- })), appendNodes);
121
+ }, this.renderLeftIcons(), children, this.renderRightIcons()), appendNodes);
91
122
  }
92
123
  }, {
93
124
  key: "renderSideNode",
94
125
  value: function renderSideNode(side, nodes, inputId) {
95
- var _this = this;
126
+ var _this2 = this;
96
127
  if (!nodes) {
97
128
  return;
98
129
  }
@@ -100,7 +131,7 @@ var EuiFormControlLayout = /*#__PURE__*/function (_Component) {
100
131
  return this.createFormLabel(side, nodes, inputId);
101
132
  }
102
133
  var appendNodes = _react.default.Children.map(nodes, function (item, index) {
103
- return typeof item === 'string' ? _this.createFormLabel(side, item, inputId) : _this.createSideNode(side, item, index);
134
+ return typeof item === 'string' ? _this2.createFormLabel(side, item, inputId) : _this2.createSideNode(side, item, index);
104
135
  });
105
136
  return appendNodes;
106
137
  }
@@ -147,6 +178,7 @@ EuiFormControlLayout.propTypes = {
147
178
  color: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.any.isRequired]),
148
179
  ref: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.func.isRequired])
149
180
  }).isRequired]),
181
+ iconsPosition: _propTypes.default.oneOf(["absolute", "static"]),
150
182
  clear: _propTypes.default.shape({
151
183
  className: _propTypes.default.string,
152
184
  "aria-label": _propTypes.default.string,
@@ -8,6 +8,8 @@ exports.EuiFormControlLayoutDelimited = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
10
  var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _i18n = require("../../i18n");
12
+ var _icon = require("../../icon");
11
13
  var _text = require("../../text");
12
14
  var _form_control_layout = require("./form_control_layout");
13
15
  var _react2 = require("@emotion/react");
@@ -21,18 +23,23 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
21
23
  var EuiFormControlLayoutDelimited = function EuiFormControlLayoutDelimited(_ref) {
22
24
  var startControl = _ref.startControl,
23
25
  endControl = _ref.endControl,
24
- _ref$delimiter = _ref.delimiter,
25
- delimiter = _ref$delimiter === void 0 ? '→' : _ref$delimiter,
26
+ delimiter = _ref.delimiter,
26
27
  className = _ref.className,
27
28
  rest = _objectWithoutProperties(_ref, _excluded);
28
- var classes = (0, _classnames.default)('euiFormControlLayoutDelimited', className);
29
+ var isInvalid = rest.isInvalid,
30
+ isDisabled = rest.isDisabled,
31
+ readOnly = rest.readOnly;
32
+ var showInvalidState = isInvalid && !isDisabled && !readOnly;
33
+ var classes = (0, _classnames.default)('euiFormControlLayoutDelimited', className, {
34
+ 'euiFormControlLayoutDelimited--isInvalid': showInvalidState
35
+ });
29
36
  return (0, _react2.jsx)(_form_control_layout.EuiFormControlLayout, _extends({
30
- className: classes
31
- }, rest), addClassesToControl(startControl), (0, _react2.jsx)(_text.EuiText, {
32
- className: "euiFormControlLayoutDelimited__delimeter",
33
- size: "s",
34
- color: "subdued"
35
- }, delimiter), addClassesToControl(endControl));
37
+ className: classes,
38
+ iconsPosition: "static"
39
+ }, rest), addClassesToControl(startControl), (0, _react2.jsx)(EuiFormControlDelimiter, {
40
+ delimiter: delimiter,
41
+ isInvalid: showInvalidState
42
+ }), addClassesToControl(endControl));
36
43
  };
37
44
  exports.EuiFormControlLayoutDelimited = EuiFormControlLayoutDelimited;
38
45
  EuiFormControlLayoutDelimited.propTypes = {
@@ -51,8 +58,21 @@ EuiFormControlLayoutDelimited.propTypes = {
51
58
  delimiter: _propTypes.default.node,
52
59
  className: _propTypes.default.string
53
60
  };
54
- function addClassesToControl(control) {
61
+ var addClassesToControl = function addClassesToControl(control) {
55
62
  return /*#__PURE__*/(0, _react.cloneElement)(control, {
56
63
  className: (0, _classnames.default)(control.props.className, 'euiFormControlLayoutDelimited__input')
57
64
  });
58
- }
65
+ };
66
+ var EuiFormControlDelimiter = function EuiFormControlDelimiter(_ref2) {
67
+ var delimiter = _ref2.delimiter,
68
+ isInvalid = _ref2.isInvalid;
69
+ var defaultAriaLabel = (0, _i18n.useEuiI18n)('euiFormControlLayoutDelimited.delimiterLabel', 'to');
70
+ return (0, _react2.jsx)(_text.EuiText, {
71
+ className: "euiFormControlLayoutDelimited__delimiter",
72
+ size: "s",
73
+ color: isInvalid ? 'danger' : 'subdued'
74
+ }, delimiter !== null && delimiter !== void 0 ? delimiter : (0, _react2.jsx)(_icon.EuiIcon, {
75
+ type: "sortRight",
76
+ "aria-label": defaultAriaLabel
77
+ }));
78
+ };
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.ICON_SIDES = exports.EuiFormControlLayoutIcons = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _propTypes = _interopRequireDefault(require("prop-types"));
10
+ var _classnames = _interopRequireDefault(require("classnames"));
10
11
  var _loading = require("../../loading");
11
12
  var _form_control_layout_clear_button = require("./form_control_layout_clear_button");
12
13
  var _form_control_layout_custom_icon = require("./form_control_layout_custom_icon");
@@ -47,30 +48,19 @@ var EuiFormControlLayoutIcons = /*#__PURE__*/function (_Component) {
47
48
  key: "render",
48
49
  value: function render() {
49
50
  var _this$props = this.props,
50
- icon = _this$props.icon,
51
- isInvalid = _this$props.isInvalid,
52
- isDropdown = _this$props.isDropdown;
53
- var iconSide = isIconShape(icon) && icon.side ? icon.side : 'left';
51
+ _this$props$side = _this$props.side,
52
+ side = _this$props$side === void 0 ? 'left' : _this$props$side,
53
+ _this$props$iconsPosi = _this$props.iconsPosition,
54
+ iconsPosition = _this$props$iconsPosi === void 0 ? 'absolute' : _this$props$iconsPosi;
54
55
  var customIcon = this.renderCustomIcon();
55
56
  var loadingSpinner = this.renderLoadingSpinner();
56
57
  var clearButton = this.renderClearButton();
57
58
  var invalidIcon = this.renderInvalidIcon();
58
59
  var dropdownIcon = this.renderDropdownIcon();
59
- var leftIcons;
60
- if (customIcon && iconSide === 'left') {
61
- leftIcons = (0, _react2.jsx)("div", {
62
- className: "euiFormControlLayoutIcons"
63
- }, customIcon);
64
- }
65
- var rightIcons;
66
-
67
- // If the icon is on the right, it should be placed after the clear button in the DOM.
68
- if (clearButton || loadingSpinner || isInvalid || isDropdown || customIcon && iconSide === 'right') {
69
- rightIcons = (0, _react2.jsx)("div", {
70
- className: "euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
71
- }, clearButton, loadingSpinner, invalidIcon, iconSide === 'right' ? customIcon : undefined, dropdownIcon);
72
- }
73
- return (0, _react2.jsx)(_react.Fragment, null, leftIcons, rightIcons);
60
+ var classes = (0, _classnames.default)('euiFormControlLayoutIcons', "euiFormControlLayoutIcons--".concat(side), "euiFormControlLayoutIcons--".concat(iconsPosition));
61
+ return (0, _react2.jsx)("div", {
62
+ className: classes
63
+ }, clearButton, loadingSpinner, invalidIcon, customIcon, dropdownIcon);
74
64
  }
75
65
  }, {
76
66
  key: "renderCustomIcon",
@@ -160,6 +150,8 @@ EuiFormControlLayoutIcons.propTypes = {
160
150
  color: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.any.isRequired]),
161
151
  ref: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.func.isRequired])
162
152
  }).isRequired]),
153
+ side: _propTypes.default.any,
154
+ iconsPosition: _propTypes.default.oneOf(["absolute", "static"]),
163
155
  clear: _propTypes.default.shape({
164
156
  className: _propTypes.default.string,
165
157
  "aria-label": _propTypes.default.string,