@elastic/eui 77.1.1 → 77.2.1

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 +37 -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 +40 -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 +32 -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 +35 -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 +35 -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
@@ -201,6 +201,36 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
201
201
  _this.asyncInterval = new _async_interval.AsyncInterval(handler, refreshInterval);
202
202
  }
203
203
  });
204
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderQuickSelect", function () {
205
+ var _this$props2 = _this.props,
206
+ start = _this$props2.start,
207
+ end = _this$props2.end,
208
+ customQuickSelectPanels = _this$props2.customQuickSelectPanels,
209
+ customQuickSelectRender = _this$props2.customQuickSelectRender,
210
+ commonlyUsedRanges = _this$props2.commonlyUsedRanges,
211
+ timeOptions = _this$props2.timeOptions,
212
+ dateFormat = _this$props2.dateFormat,
213
+ onRefreshChange = _this$props2.onRefreshChange,
214
+ recentlyUsedRanges = _this$props2.recentlyUsedRanges,
215
+ refreshInterval = _this$props2.refreshInterval,
216
+ isPaused = _this$props2.isPaused,
217
+ isDisabled = _this$props2.isDisabled;
218
+ return (0, _react2.jsx)(_quick_select_popover.EuiQuickSelectPopover, {
219
+ applyRefreshInterval: onRefreshChange ? _this.onRefreshChange : undefined,
220
+ applyTime: _this.applyQuickTime,
221
+ commonlyUsedRanges: commonlyUsedRanges,
222
+ customQuickSelectPanels: customQuickSelectPanels,
223
+ customQuickSelectRender: customQuickSelectRender,
224
+ dateFormat: dateFormat,
225
+ end: end,
226
+ isDisabled: isDisabled,
227
+ isPaused: isPaused,
228
+ recentlyUsedRanges: recentlyUsedRanges,
229
+ refreshInterval: refreshInterval,
230
+ start: start,
231
+ timeOptions: timeOptions
232
+ });
233
+ });
204
234
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderDatePickerRange", function () {
205
235
  var _this$state = _this.state,
206
236
  end = _this$state.end,
@@ -210,24 +240,47 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
210
240
  isStartDatePopoverOpen = _this$state.isStartDatePopoverOpen,
211
241
  showPrettyDuration = _this$state.showPrettyDuration,
212
242
  start = _this$state.start;
213
- var _this$props2 = _this.props,
214
- commonlyUsedRanges = _this$props2.commonlyUsedRanges,
215
- timeOptions = _this$props2.timeOptions,
216
- dateFormat = _this$props2.dateFormat,
217
- isDisabled = _this$props2.isDisabled,
218
- locale = _this$props2.locale,
219
- timeFormat = _this$props2.timeFormat,
220
- utcOffset = _this$props2.utcOffset,
221
- compressed = _this$props2.compressed,
222
- onFocus = _this$props2.onFocus;
243
+ var _this$props3 = _this.props,
244
+ isQuickSelectOnly = _this$props3.isQuickSelectOnly,
245
+ showUpdateButton = _this$props3.showUpdateButton,
246
+ commonlyUsedRanges = _this$props3.commonlyUsedRanges,
247
+ timeOptions = _this$props3.timeOptions,
248
+ dateFormat = _this$props3.dateFormat,
249
+ refreshInterval = _this$props3.refreshInterval,
250
+ isPaused = _this$props3.isPaused,
251
+ isDisabled = _this$props3.isDisabled,
252
+ isLoading = _this$props3.isLoading,
253
+ locale = _this$props3.locale,
254
+ timeFormat = _this$props3.timeFormat,
255
+ utcOffset = _this$props3.utcOffset,
256
+ compressed = _this$props3.compressed,
257
+ onFocus = _this$props3.onFocus,
258
+ className = _this$props3.className,
259
+ dataTestSubj = _this$props3['data-test-subj'];
260
+ var autoRefreshAppend = !isPaused ? (0, _react2.jsx)(_auto_refresh.EuiAutoRefreshButton, {
261
+ refreshInterval: refreshInterval,
262
+ isDisabled: isDisabled,
263
+ isPaused: isPaused,
264
+ onRefreshChange: _this.onRefreshChange,
265
+ shortHand: true
266
+ }) : undefined;
267
+ var formControlLayoutProps = {
268
+ className: (0, _classnames.default)('euiSuperDatePicker', className),
269
+ compressed: compressed,
270
+ isInvalid: isInvalid,
271
+ isLoading: isLoading && !showUpdateButton,
272
+ disabled: isDisabled,
273
+ prepend: _this.renderQuickSelect(),
274
+ append: autoRefreshAppend,
275
+ 'data-test-subj': dataTestSubj
276
+ };
277
+ if (isQuickSelectOnly) {
278
+ return (0, _react2.jsx)(_form.EuiFormControlLayout, (0, _extends2.default)({
279
+ iconsPosition: "static"
280
+ }, formControlLayoutProps));
281
+ }
223
282
  if (showPrettyDuration && !isStartDatePopoverOpen && !isEndDatePopoverOpen) {
224
- return (0, _react2.jsx)(_date_picker_range.EuiDatePickerRange, {
225
- className: "euiDatePickerRange--inGroup",
226
- iconType: false,
227
- isCustom: true,
228
- startDateControl: (0, _react2.jsx)("div", null),
229
- endDateControl: (0, _react2.jsx)("div", null)
230
- }, (0, _react2.jsx)("button", {
283
+ return (0, _react2.jsx)(_form.EuiFormControlLayout, formControlLayoutProps, (0, _react2.jsx)("button", {
231
284
  className: (0, _classnames.default)('euiSuperDatePicker__prettyFormat', {
232
285
  'euiSuperDatePicker__prettyFormat--disabled': isDisabled
233
286
  }),
@@ -244,12 +297,12 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
244
297
  }
245
298
  return (0, _react2.jsx)(_context.EuiI18nConsumer, null, function (_ref4) {
246
299
  var contextLocale = _ref4.locale;
247
- return (0, _react2.jsx)(_date_picker_range.EuiDatePickerRange, {
248
- className: "euiDatePickerRange--inGroup",
249
- iconType: false,
250
- isInvalid: isInvalid,
251
- disabled: isDisabled,
300
+ return (0, _react2.jsx)(_date_picker_range.EuiDatePickerRange, (0, _extends2.default)({}, formControlLayoutProps, {
301
+ className: (0, _classnames.default)(formControlLayoutProps.className, {
302
+ 'euiSuperDatePicker--needsUpdating': hasChanged && !isDisabled && !isInvalid
303
+ }),
252
304
  isCustom: true,
305
+ iconType: false,
253
306
  startDateControl: (0, _react2.jsx)(_date_popover_button.EuiDatePopoverButton, {
254
307
  className: "euiSuperDatePicker__startPopoverButton",
255
308
  compressed: compressed,
@@ -292,15 +345,15 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
292
345
  onFocus: onFocus
293
346
  }
294
347
  })
295
- });
348
+ }));
296
349
  });
297
350
  });
298
351
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClickUpdateButton", function () {
299
352
  if (!_this.state.hasChanged && _this.props.onRefresh) {
300
- var _this$props3 = _this.props,
301
- start = _this$props3.start,
302
- end = _this$props3.end,
303
- refreshInterval = _this$props3.refreshInterval;
353
+ var _this$props4 = _this.props,
354
+ start = _this$props4.start,
355
+ end = _this$props4.end,
356
+ refreshInterval = _this$props4.refreshInterval;
304
357
  _this.props.onRefresh({
305
358
  start: start,
306
359
  end: end,
@@ -311,12 +364,12 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
311
364
  }
312
365
  });
313
366
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderUpdateButton", function () {
314
- var _this$props4 = _this.props,
315
- isLoading = _this$props4.isLoading,
316
- isDisabled = _this$props4.isDisabled,
317
- updateButtonProps = _this$props4.updateButtonProps,
318
- showUpdateButton = _this$props4.showUpdateButton,
319
- compressed = _this$props4.compressed;
367
+ var _this$props5 = _this.props,
368
+ isLoading = _this$props5.isLoading,
369
+ isDisabled = _this$props5.isDisabled,
370
+ updateButtonProps = _this$props5.updateButtonProps,
371
+ showUpdateButton = _this$props5.showUpdateButton,
372
+ compressed = _this$props5.compressed;
320
373
  if (!showUpdateButton) return null;
321
374
  return (0, _react2.jsx)(_flex.EuiFlexItem, {
322
375
  grow: false
@@ -336,52 +389,21 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
336
389
  (0, _createClass2.default)(EuiSuperDatePickerInternal, [{
337
390
  key: "render",
338
391
  value: function render() {
339
- var _this$props5 = this.props,
340
- commonlyUsedRanges = _this$props5.commonlyUsedRanges,
341
- timeOptions = _this$props5.timeOptions,
342
- customQuickSelectPanels = _this$props5.customQuickSelectPanels,
343
- customQuickSelectRender = _this$props5.customQuickSelectRender,
344
- dateFormat = _this$props5.dateFormat,
345
- end = _this$props5.end,
346
- isAutoRefreshOnly = _this$props5.isAutoRefreshOnly,
347
- isDisabled = _this$props5.isDisabled,
348
- isPaused = _this$props5.isPaused,
349
- onRefreshChange = _this$props5.onRefreshChange,
350
- recentlyUsedRanges = _this$props5.recentlyUsedRanges,
351
- refreshInterval = _this$props5.refreshInterval,
352
- showUpdateButton = _this$props5.showUpdateButton,
353
- start = _this$props5.start,
354
- dataTestSubj = _this$props5['data-test-subj'],
355
- _width = _this$props5.width,
356
- isQuickSelectOnly = _this$props5.isQuickSelectOnly,
357
- compressed = _this$props5.compressed,
358
- className = _this$props5.className;
392
+ var _this$props6 = this.props,
393
+ isAutoRefreshOnly = _this$props6.isAutoRefreshOnly,
394
+ isDisabled = _this$props6.isDisabled,
395
+ isPaused = _this$props6.isPaused,
396
+ onRefreshChange = _this$props6.onRefreshChange,
397
+ refreshInterval = _this$props6.refreshInterval,
398
+ showUpdateButton = _this$props6.showUpdateButton,
399
+ dataTestSubj = _this$props6['data-test-subj'],
400
+ _width = _this$props6.width,
401
+ isQuickSelectOnly = _this$props6.isQuickSelectOnly,
402
+ compressed = _this$props6.compressed,
403
+ className = _this$props6.className;
359
404
 
360
405
  // Force reduction in width if showing quick select only
361
406
  var width = isQuickSelectOnly ? 'auto' : _width;
362
- var autoRefreshAppend = !isPaused ? (0, _react2.jsx)(_auto_refresh.EuiAutoRefreshButton, {
363
- className: "euiFormControlLayout__append",
364
- refreshInterval: refreshInterval,
365
- isDisabled: isDisabled,
366
- isPaused: isPaused,
367
- onRefreshChange: this.onRefreshChange,
368
- shortHand: true
369
- }) : undefined;
370
- var quickSelect = (0, _react2.jsx)(_quick_select_popover.EuiQuickSelectPopover, {
371
- applyRefreshInterval: onRefreshChange ? this.onRefreshChange : undefined,
372
- applyTime: this.applyQuickTime,
373
- commonlyUsedRanges: commonlyUsedRanges,
374
- customQuickSelectPanels: customQuickSelectPanels,
375
- customQuickSelectRender: customQuickSelectRender,
376
- dateFormat: dateFormat,
377
- end: end,
378
- isDisabled: isDisabled,
379
- isPaused: isPaused,
380
- recentlyUsedRanges: recentlyUsedRanges,
381
- refreshInterval: refreshInterval,
382
- start: start,
383
- timeOptions: timeOptions
384
- });
385
407
  var flexWrapperClasses = (0, _classnames.default)('euiSuperDatePicker__flexWrapper', {
386
408
  'euiSuperDatePicker__flexWrapper--noUpdateButton': !showUpdateButton,
387
409
  'euiSuperDatePicker__flexWrapper--isAutoRefreshOnly': isAutoRefreshOnly,
@@ -402,14 +424,7 @@ var EuiSuperDatePickerInternal = /*#__PURE__*/function (_Component) {
402
424
  isDisabled: isDisabled,
403
425
  "data-test-subj": dataTestSubj,
404
426
  className: className
405
- })) : (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_flex.EuiFlexItem, null, (0, _react2.jsx)(_form.EuiFormControlLayout, {
406
- className: (0, _classnames.default)('euiSuperDatePicker', className),
407
- compressed: compressed,
408
- isDisabled: isDisabled,
409
- prepend: quickSelect,
410
- append: autoRefreshAppend,
411
- "data-test-subj": dataTestSubj
412
- }, !isQuickSelectOnly && this.renderDatePickerRange())), this.renderUpdateButton()));
427
+ })) : (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)(_flex.EuiFlexItem, null, this.renderDatePickerRange()), this.renderUpdateButton()));
413
428
  }
414
429
  }], [{
415
430
  key: "getDerivedStateFromProps",
@@ -1,21 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.EuiFieldNumber = void 0;
8
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
11
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
- var _react = _interopRequireDefault(require("react"));
12
+ var _react = _interopRequireWildcard(require("react"));
11
13
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
14
  var _classnames = _interopRequireDefault(require("classnames"));
13
- var _form_control_layout = require("../form_control_layout");
14
15
  var _validatable_control = require("../validatable_control");
15
- var _eui_form_context = require("../eui_form_context");
16
+ var _form_control_layout = require("../form_control_layout");
16
17
  var _num_icons = require("../form_control_layout/_num_icons");
18
+ var _eui_form_context = require("../eui_form_context");
17
19
  var _react2 = require("@emotion/react");
18
- var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly"];
20
+ var _excluded = ["className", "icon", "id", "placeholder", "name", "min", "max", "value", "isInvalid", "fullWidth", "isLoading", "compressed", "prepend", "append", "inputRef", "readOnly", "controlOnly", "onKeyUp"];
21
+ 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); }
22
+ 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; }
19
23
  var EuiFieldNumber = function EuiFieldNumber(props) {
20
24
  var _useFormContext = (0, _eui_form_context.useFormContext)(),
21
25
  defaultFullWidth = _useFormContext.defaultFullWidth;
@@ -39,9 +43,30 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
39
43
  inputRef = props.inputRef,
40
44
  readOnly = props.readOnly,
41
45
  controlOnly = props.controlOnly,
46
+ _onKeyUp = props.onKeyUp,
42
47
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
43
- var numIconsClass = (0, _num_icons.getFormControlClassNameForIconCount)({
44
- isInvalid: isInvalid,
48
+
49
+ // Attempt to determine additional invalid state. The native number input
50
+ // will set :invalid state automatically, but we need to also set
51
+ // `aria-invalid` as well as display an icon. We also want to *not* set this on
52
+ // EuiValidatableControl, in order to not override custom validity messages
53
+ var _useState = (0, _react.useState)(),
54
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
55
+ isNativelyInvalid = _useState2[0],
56
+ setIsNativelyInvalid = _useState2[1];
57
+
58
+ // Note that we can't use hook into `onChange` because browsers don't emit change events
59
+ // for invalid values - see https://github.com/facebook/react/issues/16554
60
+ var onKeyUp = (0, _react.useCallback)(function (e) {
61
+ _onKeyUp === null || _onKeyUp === void 0 ? void 0 : _onKeyUp(e);
62
+ var _ref = e.target,
63
+ validity = _ref.validity;
64
+ // Prefer `undefined` over `false` so that the `aria-invalid` prop unsets completely
65
+ var isInvalid = !validity.valid || undefined;
66
+ setIsNativelyInvalid(isInvalid);
67
+ }, [_onKeyUp]);
68
+ var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
69
+ isInvalid: isInvalid || isNativelyInvalid,
45
70
  isLoading: isLoading
46
71
  });
47
72
  var classes = (0, _classnames.default)('euiFieldNumber', className, numIconsClass, {
@@ -63,7 +88,9 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
63
88
  placeholder: placeholder,
64
89
  readOnly: readOnly,
65
90
  className: classes,
66
- ref: inputRef
91
+ ref: inputRef,
92
+ onKeyUp: onKeyUp,
93
+ "aria-invalid": isInvalid == null ? isNativelyInvalid : isInvalid
67
94
  }, rest)));
68
95
  if (controlOnly) {
69
96
  return control;
@@ -72,7 +99,7 @@ var EuiFieldNumber = function EuiFieldNumber(props) {
72
99
  icon: icon,
73
100
  fullWidth: fullWidth,
74
101
  isLoading: isLoading,
75
- isInvalid: isInvalid,
102
+ isInvalid: isInvalid || isNativelyInvalid,
76
103
  compressed: compressed,
77
104
  readOnly: readOnly,
78
105
  prepend: prepend,
@@ -36,7 +36,7 @@ var EuiFieldText = function EuiFieldText(props) {
36
36
  readOnly = props.readOnly,
37
37
  controlOnly = props.controlOnly,
38
38
  rest = (0, _objectWithoutProperties2.default)(props, _excluded);
39
- var numIconsClass = (0, _num_icons.getFormControlClassNameForIconCount)({
39
+ var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
40
40
  isInvalid: isInvalid,
41
41
  isLoading: isLoading
42
42
  });
@@ -6,16 +6,11 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.EuiFormControlLayout = void 0;
9
- Object.defineProperty(exports, "ICON_SIDES", {
10
- enumerable: true,
11
- get: function get() {
12
- return _form_control_layout_icons.ICON_SIDES;
13
- }
14
- });
15
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
16
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
17
11
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
18
12
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
19
14
  var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
20
15
  var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
21
16
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
@@ -27,7 +22,7 @@ var _form_control_layout_icons = require("./form_control_layout_icons");
27
22
  var _form_label = require("../form_label");
28
23
  var _eui_form_context = require("../eui_form_context");
29
24
  var _react2 = require("@emotion/react");
30
- var _excluded = ["children", "icon", "clear", "fullWidth", "isLoading", "isDisabled", "compressed", "className", "prepend", "append", "readOnly", "isInvalid", "isDropdown", "inputId"];
25
+ var _excluded = ["children", "icon", "iconsPosition", "clear", "fullWidth", "isLoading", "isDisabled", "compressed", "className", "prepend", "append", "readOnly", "isInvalid", "isDropdown", "inputId"];
31
26
  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); }
32
27
  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; }
33
28
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -36,31 +31,75 @@ var EuiFormControlLayout = /*#__PURE__*/function (_Component) {
36
31
  (0, _inherits2.default)(EuiFormControlLayout, _Component);
37
32
  var _super = _createSuper(EuiFormControlLayout);
38
33
  function EuiFormControlLayout() {
34
+ var _this;
39
35
  (0, _classCallCheck2.default)(this, EuiFormControlLayout);
40
- return _super.apply(this, arguments);
36
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
37
+ args[_key] = arguments[_key];
38
+ }
39
+ _this = _super.call.apply(_super, [this].concat(args));
40
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderLeftIcons", function () {
41
+ var _this$props = _this.props,
42
+ icon = _this$props.icon,
43
+ iconsPosition = _this$props.iconsPosition,
44
+ compressed = _this$props.compressed;
45
+ var leftCustomIcon = icon && (icon === null || icon === void 0 ? void 0 : icon.side) !== 'right' ? icon : undefined;
46
+ return leftCustomIcon ? (0, _react2.jsx)(_form_control_layout_icons.EuiFormControlLayoutIcons, {
47
+ side: "left",
48
+ icon: leftCustomIcon,
49
+ iconsPosition: iconsPosition,
50
+ compressed: compressed
51
+ }) : null;
52
+ });
53
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderRightIcons", function () {
54
+ var _this$props2 = _this.props,
55
+ icon = _this$props2.icon,
56
+ iconsPosition = _this$props2.iconsPosition,
57
+ clear = _this$props2.clear,
58
+ compressed = _this$props2.compressed,
59
+ isLoading = _this$props2.isLoading,
60
+ isInvalid = _this$props2.isInvalid,
61
+ isDisabled = _this$props2.isDisabled,
62
+ readOnly = _this$props2.readOnly,
63
+ isDropdown = _this$props2.isDropdown;
64
+ var hasDropdownIcon = !readOnly && !isDisabled && isDropdown;
65
+ var rightCustomIcon = icon && (icon === null || icon === void 0 ? void 0 : icon.side) === 'right' ? icon : undefined;
66
+ var hasRightIcons = rightCustomIcon || clear || isLoading || isInvalid || hasDropdownIcon;
67
+ return hasRightIcons ? (0, _react2.jsx)(_form_control_layout_icons.EuiFormControlLayoutIcons, {
68
+ side: "right",
69
+ icon: rightCustomIcon,
70
+ iconsPosition: iconsPosition,
71
+ compressed: compressed,
72
+ clear: clear,
73
+ isLoading: isLoading,
74
+ isInvalid: isInvalid,
75
+ isDropdown: hasDropdownIcon
76
+ }) : null;
77
+ });
78
+ return _this;
41
79
  }
42
80
  (0, _createClass2.default)(EuiFormControlLayout, [{
43
81
  key: "render",
44
82
  value: function render() {
45
83
  var _ref = this.context,
46
84
  defaultFullWidth = _ref.defaultFullWidth;
47
- var _this$props = this.props,
48
- children = _this$props.children,
49
- icon = _this$props.icon,
50
- clear = _this$props.clear,
51
- _this$props$fullWidth = _this$props.fullWidth,
52
- fullWidth = _this$props$fullWidth === void 0 ? defaultFullWidth : _this$props$fullWidth,
53
- isLoading = _this$props.isLoading,
54
- isDisabled = _this$props.isDisabled,
55
- compressed = _this$props.compressed,
56
- className = _this$props.className,
57
- prepend = _this$props.prepend,
58
- append = _this$props.append,
59
- readOnly = _this$props.readOnly,
60
- invalid = _this$props.isInvalid,
61
- isDropdown = _this$props.isDropdown,
62
- inputId = _this$props.inputId,
63
- rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
85
+ var _this$props3 = this.props,
86
+ children = _this$props3.children,
87
+ icon = _this$props3.icon,
88
+ iconsPosition = _this$props3.iconsPosition,
89
+ clear = _this$props3.clear,
90
+ _this$props3$fullWidt = _this$props3.fullWidth,
91
+ fullWidth = _this$props3$fullWidt === void 0 ? defaultFullWidth : _this$props3$fullWidt,
92
+ isLoading = _this$props3.isLoading,
93
+ isDisabled = _this$props3.isDisabled,
94
+ compressed = _this$props3.compressed,
95
+ className = _this$props3.className,
96
+ prepend = _this$props3.prepend,
97
+ append = _this$props3.append,
98
+ readOnly = _this$props3.readOnly,
99
+ isInvalid = _this$props3.isInvalid,
100
+ isDropdown = _this$props3.isDropdown,
101
+ inputId = _this$props3.inputId,
102
+ rest = (0, _objectWithoutProperties2.default)(_this$props3, _excluded);
64
103
  var classes = (0, _classnames.default)('euiFormControlLayout', {
65
104
  'euiFormControlLayout--fullWidth': fullWidth,
66
105
  'euiFormControlLayout--compressed': compressed,
@@ -74,19 +113,12 @@ var EuiFormControlLayout = /*#__PURE__*/function (_Component) {
74
113
  className: classes
75
114
  }, rest), prependNodes, (0, _react2.jsx)("div", {
76
115
  className: "euiFormControlLayout__childrenWrapper"
77
- }, children, (0, _react2.jsx)(_form_control_layout_icons.EuiFormControlLayoutIcons, {
78
- icon: icon,
79
- clear: clear,
80
- compressed: compressed,
81
- isLoading: isLoading,
82
- isInvalid: invalid,
83
- isDropdown: !readOnly && !isDisabled && isDropdown
84
- })), appendNodes);
116
+ }, this.renderLeftIcons(), children, this.renderRightIcons()), appendNodes);
85
117
  }
86
118
  }, {
87
119
  key: "renderSideNode",
88
120
  value: function renderSideNode(side, nodes, inputId) {
89
- var _this = this;
121
+ var _this2 = this;
90
122
  if (!nodes) {
91
123
  return;
92
124
  }
@@ -94,7 +126,7 @@ var EuiFormControlLayout = /*#__PURE__*/function (_Component) {
94
126
  return this.createFormLabel(side, nodes, inputId);
95
127
  }
96
128
  var appendNodes = _react.default.Children.map(nodes, function (item, index) {
97
- return typeof item === 'string' ? _this.createFormLabel(side, item, inputId) : _this.createSideNode(side, item, index);
129
+ return typeof item === 'string' ? _this2.createFormLabel(side, item, inputId) : _this2.createSideNode(side, item, index);
98
130
  });
99
131
  return appendNodes;
100
132
  }
@@ -141,6 +173,7 @@ EuiFormControlLayout.propTypes = {
141
173
  color: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.any.isRequired]),
142
174
  ref: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.func.isRequired])
143
175
  }).isRequired]),
176
+ iconsPosition: _propTypes.default.oneOf(["absolute", "static"]),
144
177
  clear: _propTypes.default.shape({
145
178
  className: _propTypes.default.string,
146
179
  "aria-label": _propTypes.default.string,
@@ -11,6 +11,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
11
11
  var _react = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _classnames = _interopRequireDefault(require("classnames"));
14
+ var _i18n = require("../../i18n");
15
+ var _icon = require("../../icon");
14
16
  var _text = require("../../text");
15
17
  var _form_control_layout = require("./form_control_layout");
16
18
  var _react2 = require("@emotion/react");
@@ -20,18 +22,23 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
20
22
  var EuiFormControlLayoutDelimited = function EuiFormControlLayoutDelimited(_ref) {
21
23
  var startControl = _ref.startControl,
22
24
  endControl = _ref.endControl,
23
- _ref$delimiter = _ref.delimiter,
24
- delimiter = _ref$delimiter === void 0 ? '→' : _ref$delimiter,
25
+ delimiter = _ref.delimiter,
25
26
  className = _ref.className,
26
27
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
27
- var classes = (0, _classnames.default)('euiFormControlLayoutDelimited', className);
28
+ var isInvalid = rest.isInvalid,
29
+ isDisabled = rest.isDisabled,
30
+ readOnly = rest.readOnly;
31
+ var showInvalidState = isInvalid && !isDisabled && !readOnly;
32
+ var classes = (0, _classnames.default)('euiFormControlLayoutDelimited', className, {
33
+ 'euiFormControlLayoutDelimited--isInvalid': showInvalidState
34
+ });
28
35
  return (0, _react2.jsx)(_form_control_layout.EuiFormControlLayout, (0, _extends2.default)({
29
- className: classes
30
- }, rest), addClassesToControl(startControl), (0, _react2.jsx)(_text.EuiText, {
31
- className: "euiFormControlLayoutDelimited__delimeter",
32
- size: "s",
33
- color: "subdued"
34
- }, delimiter), addClassesToControl(endControl));
36
+ className: classes,
37
+ iconsPosition: "static"
38
+ }, rest), addClassesToControl(startControl), (0, _react2.jsx)(EuiFormControlDelimiter, {
39
+ delimiter: delimiter,
40
+ isInvalid: showInvalidState
41
+ }), addClassesToControl(endControl));
35
42
  };
36
43
  exports.EuiFormControlLayoutDelimited = EuiFormControlLayoutDelimited;
37
44
  EuiFormControlLayoutDelimited.propTypes = {
@@ -50,8 +57,21 @@ EuiFormControlLayoutDelimited.propTypes = {
50
57
  delimiter: _propTypes.default.node,
51
58
  className: _propTypes.default.string
52
59
  };
53
- function addClassesToControl(control) {
60
+ var addClassesToControl = function addClassesToControl(control) {
54
61
  return /*#__PURE__*/(0, _react.cloneElement)(control, {
55
62
  className: (0, _classnames.default)(control.props.className, 'euiFormControlLayoutDelimited__input')
56
63
  });
57
- }
64
+ };
65
+ var EuiFormControlDelimiter = function EuiFormControlDelimiter(_ref2) {
66
+ var delimiter = _ref2.delimiter,
67
+ isInvalid = _ref2.isInvalid;
68
+ var defaultAriaLabel = (0, _i18n.useEuiI18n)('euiFormControlLayoutDelimited.delimiterLabel', 'to');
69
+ return (0, _react2.jsx)(_text.EuiText, {
70
+ className: "euiFormControlLayoutDelimited__delimiter",
71
+ size: "s",
72
+ color: isInvalid ? 'danger' : 'subdued'
73
+ }, delimiter !== null && delimiter !== void 0 ? delimiter : (0, _react2.jsx)(_icon.EuiIcon, {
74
+ type: "sortRight",
75
+ "aria-label": defaultAriaLabel
76
+ }));
77
+ };
@@ -15,6 +15,7 @@ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime
15
15
  var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
16
16
  var _react = _interopRequireWildcard(require("react"));
17
17
  var _propTypes = _interopRequireDefault(require("prop-types"));
18
+ var _classnames = _interopRequireDefault(require("classnames"));
18
19
  var _loading = require("../../loading");
19
20
  var _form_control_layout_clear_button = require("./form_control_layout_clear_button");
20
21
  var _form_control_layout_custom_icon = require("./form_control_layout_custom_icon");
@@ -41,30 +42,19 @@ var EuiFormControlLayoutIcons = /*#__PURE__*/function (_Component) {
41
42
  key: "render",
42
43
  value: function render() {
43
44
  var _this$props = this.props,
44
- icon = _this$props.icon,
45
- isInvalid = _this$props.isInvalid,
46
- isDropdown = _this$props.isDropdown;
47
- var iconSide = isIconShape(icon) && icon.side ? icon.side : 'left';
45
+ _this$props$side = _this$props.side,
46
+ side = _this$props$side === void 0 ? 'left' : _this$props$side,
47
+ _this$props$iconsPosi = _this$props.iconsPosition,
48
+ iconsPosition = _this$props$iconsPosi === void 0 ? 'absolute' : _this$props$iconsPosi;
48
49
  var customIcon = this.renderCustomIcon();
49
50
  var loadingSpinner = this.renderLoadingSpinner();
50
51
  var clearButton = this.renderClearButton();
51
52
  var invalidIcon = this.renderInvalidIcon();
52
53
  var dropdownIcon = this.renderDropdownIcon();
53
- var leftIcons;
54
- if (customIcon && iconSide === 'left') {
55
- leftIcons = (0, _react2.jsx)("div", {
56
- className: "euiFormControlLayoutIcons"
57
- }, customIcon);
58
- }
59
- var rightIcons;
60
-
61
- // If the icon is on the right, it should be placed after the clear button in the DOM.
62
- if (clearButton || loadingSpinner || isInvalid || isDropdown || customIcon && iconSide === 'right') {
63
- rightIcons = (0, _react2.jsx)("div", {
64
- className: "euiFormControlLayoutIcons euiFormControlLayoutIcons--right"
65
- }, clearButton, loadingSpinner, invalidIcon, iconSide === 'right' ? customIcon : undefined, dropdownIcon);
66
- }
67
- return (0, _react2.jsx)(_react.Fragment, null, leftIcons, rightIcons);
54
+ var classes = (0, _classnames.default)('euiFormControlLayoutIcons', "euiFormControlLayoutIcons--".concat(side), "euiFormControlLayoutIcons--".concat(iconsPosition));
55
+ return (0, _react2.jsx)("div", {
56
+ className: classes
57
+ }, clearButton, loadingSpinner, invalidIcon, customIcon, dropdownIcon);
68
58
  }
69
59
  }, {
70
60
  key: "renderCustomIcon",
@@ -154,6 +144,8 @@ EuiFormControlLayoutIcons.propTypes = {
154
144
  color: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.any.isRequired]),
155
145
  ref: _propTypes.default.oneOfType([_propTypes.default.string.isRequired, _propTypes.default.func.isRequired])
156
146
  }).isRequired]),
147
+ side: _propTypes.default.any,
148
+ iconsPosition: _propTypes.default.oneOf(["absolute", "static"]),
157
149
  clear: _propTypes.default.shape({
158
150
  className: _propTypes.default.string,
159
151
  "aria-label": _propTypes.default.string,
@@ -393,7 +393,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
393
393
  var min = minProps;
394
394
  var max = maxProps;
395
395
  var id = this.state.id;
396
- var digitTolerance = Math.max(String(min).length, String(max).length);
397
396
  var showInputOnly = showInput === 'inputWithPopover';
398
397
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
399
398
  var rangeStyles = (0, _range.euiRangeStyles)(theme);
@@ -404,7 +403,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
404
403
  "aria-label": this.props['aria-label']
405
404
  }, minInputProps, {
406
405
  // Non-overridable props
407
- digitTolerance: digitTolerance,
408
406
  side: "min",
409
407
  min: min,
410
408
  max: Number(this.upperValue),
@@ -433,7 +431,6 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
433
431
  "aria-label": this.props['aria-label']
434
432
  }, maxInputProps, {
435
433
  // Non-overridable props
436
- digitTolerance: digitTolerance,
437
434
  side: "max",
438
435
  min: Number(this.lowerValue),
439
436
  max: max,
@@ -585,7 +582,8 @@ var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
585
582
  readOnly: readOnly,
586
583
  append: append,
587
584
  prepend: prepend,
588
- isLoading: isLoading
585
+ isLoading: isLoading,
586
+ isInvalid: isInvalid
589
587
  }),
590
588
  fullWidth: fullWidth,
591
589
  isOpen: this.state.isPopoverOpen,