@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
@@ -390,7 +390,6 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
390
390
  var min = minProps;
391
391
  var max = maxProps;
392
392
  var id = this.state.id;
393
- var digitTolerance = Math.max(String(min).length, String(max).length);
394
393
  var showInputOnly = showInput === 'inputWithPopover';
395
394
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
396
395
  var rangeStyles = euiRangeStyles(theme);
@@ -401,7 +400,6 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
401
400
  "aria-label": this.props['aria-label']
402
401
  }, minInputProps, {
403
402
  // Non-overridable props
404
- digitTolerance: digitTolerance,
405
403
  side: "min",
406
404
  min: min,
407
405
  max: Number(this.upperValue),
@@ -430,7 +428,6 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
430
428
  "aria-label": this.props['aria-label']
431
429
  }, maxInputProps, {
432
430
  // Non-overridable props
433
- digitTolerance: digitTolerance,
434
431
  side: "max",
435
432
  min: Number(this.lowerValue),
436
433
  max: max,
@@ -582,7 +579,8 @@ export var EuiDualRangeClass = /*#__PURE__*/function (_Component) {
582
579
  readOnly: readOnly,
583
580
  append: append,
584
581
  prepend: prepend,
585
- isLoading: isLoading
582
+ isLoading: isLoading,
583
+ isInvalid: isInvalid
586
584
  }),
587
585
  fullWidth: fullWidth,
588
586
  isOpen: this.state.isPopoverOpen,
@@ -131,14 +131,12 @@ export var EuiRangeClass = /*#__PURE__*/function (_Component) {
131
131
  theme = _this$props.theme,
132
132
  rest = _objectWithoutProperties(_this$props, _excluded);
133
133
  var id = this.state.id;
134
- var digitTolerance = Math.max(String(min).length, String(max).length);
135
134
  var showInputOnly = showInput === 'inputWithPopover';
136
135
  var canShowDropdown = showInputOnly && !readOnly && !disabled;
137
136
  var theInput = !!showInput ? ___EmotionJSX(EuiRangeInput, _extends({
138
137
  id: id,
139
138
  min: min,
140
139
  max: max,
141
- digitTolerance: digitTolerance,
142
140
  step: step,
143
141
  value: value,
144
142
  readOnly: readOnly,
@@ -1,6 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["min", "max", "step", "value", "disabled", "compressed", "onChange", "name", "side", "digitTolerance", "fullWidth", "autoSize"];
4
+ var _excluded = ["min", "max", "step", "value", "inputRef", "isInvalid", "disabled", "compressed", "onChange", "name", "side", "fullWidth", "autoSize"];
4
5
  /*
5
6
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
6
7
  * or more contributor license agreements. Licensed under the Elastic License
@@ -9,9 +10,10 @@ var _excluded = ["min", "max", "step", "value", "disabled", "compressed", "onCha
9
10
  * Side Public License, v 1.
10
11
  */
11
12
 
12
- import React, { useMemo } from 'react';
13
- import { useEuiTheme } from '../../../services';
13
+ import React, { useState, useEffect, useMemo, useRef } from 'react';
14
+ import { useEuiTheme, useCombinedRefs } from '../../../services';
14
15
  import { logicalStyles } from '../../../global_styling';
16
+ import { euiFormVariables } from '../form.styles';
15
17
  import { EuiFieldNumber } from '../field_number';
16
18
  import { euiRangeInputStyles } from './range_input.styles';
17
19
  import { jsx as ___EmotionJSX } from "@emotion/react";
@@ -20,28 +22,61 @@ export var EuiRangeInput = function EuiRangeInput(_ref) {
20
22
  max = _ref.max,
21
23
  step = _ref.step,
22
24
  value = _ref.value,
25
+ inputRef = _ref.inputRef,
26
+ isInvalid = _ref.isInvalid,
23
27
  disabled = _ref.disabled,
24
28
  compressed = _ref.compressed,
25
29
  onChange = _ref.onChange,
26
30
  name = _ref.name,
27
31
  _ref$side = _ref.side,
28
32
  side = _ref$side === void 0 ? 'max' : _ref$side,
29
- digitTolerance = _ref.digitTolerance,
30
33
  fullWidth = _ref.fullWidth,
31
34
  _ref$autoSize = _ref.autoSize,
32
35
  autoSize = _ref$autoSize === void 0 ? true : _ref$autoSize,
33
36
  rest = _objectWithoutProperties(_ref, _excluded);
34
- // Chrome will properly size the input based on the max value, but FF does not.
35
- // Calculate the width of the input based on highest number of characters.
36
- // Add 2 to accommodate for input stepper
37
- var widthStyle = useMemo(function () {
38
- return autoSize ? logicalStyles({
39
- width: "".concat(digitTolerance / 1.25 + 2, "em")
40
- }) : {};
41
- }, [autoSize, digitTolerance]);
42
37
  var euiTheme = useEuiTheme();
43
38
  var styles = euiRangeInputStyles(euiTheme);
44
39
  var cssStyles = [styles.euiRangeInput];
40
+
41
+ // Determine whether an invalid icon is showing, which can come from
42
+ // the underlying EuiFieldNumber's native :invalid state
43
+ var _useState = useState(isInvalid),
44
+ _useState2 = _slicedToArray(_useState, 2),
45
+ hasInvalidIcon = _useState2[0],
46
+ setHasInvalidIcon = _useState2[1];
47
+ var validityRef = useRef(null);
48
+ var setRefs = useCombinedRefs([validityRef, inputRef]);
49
+ useEffect(function () {
50
+ var _validityRef$current;
51
+ var isNativelyInvalid = !((_validityRef$current = validityRef.current) !== null && _validityRef$current !== void 0 && _validityRef$current.validity.valid);
52
+ setHasInvalidIcon(isNativelyInvalid || isInvalid);
53
+ }, [value, isInvalid]);
54
+
55
+ // Calculate the auto size width of the input
56
+ var widthStyle = useMemo(function () {
57
+ if (!autoSize) return undefined;
58
+
59
+ // Calculate the number of characters to show (dynamic based on user input)
60
+ // Uses the min/max char length as a max, then add an extra UX buffer of 1
61
+ var maxChars = Math.max(String(min).length, String(max).length) + 1;
62
+ var inputCharWidth = Math.min(String(value).length, maxChars);
63
+
64
+ // Calculate the form padding based on `compressed` state
65
+ var _euiFormVariables = euiFormVariables(euiTheme),
66
+ controlPadding = _euiFormVariables.controlPadding,
67
+ controlCompressedPadding = _euiFormVariables.controlCompressedPadding;
68
+ var inputPadding = compressed ? controlCompressedPadding : controlPadding;
69
+
70
+ // Calculate the invalid icon (if being displayed), also based on `compressed` state
71
+ var invalidIconWidth = hasInvalidIcon ? euiTheme.euiTheme.base * (compressed ? 1.125 : 1.375) // TODO: DRY this out once EuiFormControlLayoutIcons is converted to Emotion
72
+ : 0;
73
+
74
+ // Guesstimate a width for the stepper. Note that it's a little wider in FF than it is in Chrome
75
+ var stepperWidth = 2;
76
+ return logicalStyles({
77
+ width: "calc(".concat(inputPadding, " + ").concat(inputCharWidth, "ch + ").concat(stepperWidth, "em + ").concat(invalidIconWidth, "px)")
78
+ });
79
+ }, [autoSize, euiTheme, compressed, hasInvalidIcon, min, max, value]);
45
80
  return ___EmotionJSX(EuiFieldNumber, _extends({
46
81
  name: name,
47
82
  className: "euiRangeInput euiRangeInput--".concat(side),
@@ -50,6 +85,8 @@ export var EuiRangeInput = function EuiRangeInput(_ref) {
50
85
  max: Number(max),
51
86
  step: step,
52
87
  value: value === '' ? '' : Number(value),
88
+ inputRef: setRefs,
89
+ isInvalid: isInvalid,
53
90
  disabled: disabled,
54
91
  compressed: compressed,
55
92
  onChange: onChange,
@@ -1,3 +1,4 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
2
  /*
2
3
  * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
4
  * or more contributor license agreements. Licensed under the Elastic License
@@ -6,7 +7,7 @@
6
7
  * Side Public License, v 1.
7
8
  */
8
9
 
9
- import { Children, cloneElement, useRef, useEffect, useCallback } from 'react';
10
+ import { Children, cloneElement, useState, useEffect, useCallback } from 'react';
10
11
  function isMutableRef(ref) {
11
12
  return ref != null && ref.hasOwnProperty('current');
12
13
  }
@@ -19,11 +20,15 @@ function isMutableRef(ref) {
19
20
  export var EuiValidatableControl = function EuiValidatableControl(_ref) {
20
21
  var isInvalid = _ref.isInvalid,
21
22
  children = _ref.children;
22
- var control = useRef(null);
23
+ // Note that this must be state and not a ref to cause a rerender/set invalid state on initial mount
24
+ var _useState = useState(null),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ control = _useState2[0],
27
+ setControl = _useState2[1];
23
28
  var child = Children.only(children);
24
29
  var childRef = child.ref;
25
30
  var replacedRef = useCallback(function (element) {
26
- control.current = element;
31
+ setControl(element);
27
32
 
28
33
  // Call the original ref, if any
29
34
  if (typeof childRef === 'function') {
@@ -33,12 +38,12 @@ export var EuiValidatableControl = function EuiValidatableControl(_ref) {
33
38
  }
34
39
  }, [childRef]);
35
40
  useSetControlValidity({
36
- controlEl: control.current,
41
+ controlEl: control,
37
42
  isInvalid: isInvalid
38
43
  });
39
44
  return /*#__PURE__*/cloneElement(child, {
40
45
  ref: replacedRef,
41
- 'aria-invalid': isInvalid
46
+ 'aria-invalid': isInvalid || child.props['aria-invalid']
42
47
  });
43
48
  };
44
49
 
@@ -60,7 +60,12 @@ var processDateOperation = function processDateOperation(value, operator) {
60
60
  };
61
61
  export var _termValuesToQuery = function _termValuesToQuery(values, options) {
62
62
  var body = {
63
- query: values.join(' ')
63
+ query: values.map(function (value) {
64
+ if (isString(value) && value.match(/\s/)) {
65
+ return "\"".concat(value, "\"");
66
+ }
67
+ return value;
68
+ }).join(' ')
64
69
  };
65
70
  if (body.query === '') {
66
71
  return;
@@ -134,6 +134,9 @@ var emitTermClause = function emitTermClause(clause, isGroupMember) {
134
134
  match = undefined;
135
135
  }
136
136
  var matchOp = emitMatch(match);
137
+ if (isString(value) && value.match(/\s/)) {
138
+ return "".concat(matchOp, "\"").concat(escapeValue(value), "\"");
139
+ }
137
140
  return "".concat(matchOp).concat(escapeValue(value));
138
141
  };
139
142
  var emitIsClause = function emitIsClause(clause, isGroupMember) {
@@ -0,0 +1,70 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ /// <reference types="cypress" />
10
+ /// <reference types="cypress-real-events" />
11
+ /// <reference types="../../../cypress/support" />
12
+
13
+ import React from 'react';
14
+ import { EuiFormRow } from '../form';
15
+ import { EuiSuggest } from './suggest';
16
+ import { jsx as ___EmotionJSX } from "@emotion/react";
17
+ var Suggest = function Suggest() {
18
+ var suggestedItems = [{
19
+ type: {
20
+ iconType: 'accessibility',
21
+ color: 'tint1'
22
+ },
23
+ label: 'Accessibility',
24
+ description: 'A short description'
25
+ }, {
26
+ type: {
27
+ iconType: 'image',
28
+ color: 'tint2'
29
+ },
30
+ label: 'Images',
31
+ description: 'Another short description'
32
+ }, {
33
+ type: {
34
+ iconType: 'lock',
35
+ color: 'tint3'
36
+ },
37
+ label: 'Locks',
38
+ description: 'A third short description'
39
+ }];
40
+ return ___EmotionJSX(EuiFormRow, {
41
+ label: "Suggest a topic",
42
+ id: "cy-label-suggest-1"
43
+ }, ___EmotionJSX(EuiSuggest, {
44
+ "aria-labelledby": "cy-label-suggest-1-label",
45
+ suggestions: suggestedItems
46
+ }));
47
+ };
48
+ describe('EuiSuggest', function () {
49
+ beforeEach(function () {
50
+ cy.realMount(___EmotionJSX(Suggest, null));
51
+ });
52
+ describe('Automated accessibility check', function () {
53
+ it('has zero violations when rendered', function () {
54
+ cy.checkAxe();
55
+ });
56
+ });
57
+ describe('Keyboard accessibility', function () {
58
+ it('has zero violations after traversing list items', function () {
59
+ cy.realPress('Tab');
60
+ cy.get('#cy-label-suggest-1').should('have.focus');
61
+ cy.get('ul[role="listbox"]').should('exist');
62
+ cy.realPress('ArrowDown');
63
+ cy.realPress('ArrowUp');
64
+ cy.realPress('ArrowRight');
65
+ cy.realPress('ArrowLeft');
66
+ cy.get('li[role="option"]').first().should('have.attr', 'aria-selected', 'true');
67
+ cy.checkAxe();
68
+ });
69
+ });
70
+ });
@@ -0,0 +1,75 @@
1
+ /*
2
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3
+ * or more contributor license agreements. Licensed under the Elastic License
4
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
5
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
6
+ * Side Public License, v 1.
7
+ */
8
+
9
+ /// <reference types="cypress" />
10
+ /// <reference types="cypress-real-events" />
11
+ /// <reference types="../../../cypress/support" />
12
+
13
+ import React from 'react';
14
+ import { EuiTable, EuiTableHeader, EuiTableHeaderCell, EuiTableBody, EuiTableRow, EuiTableRowCell } from '.';
15
+ import { jsx as ___EmotionJSX } from "@emotion/react";
16
+ var users = [{
17
+ id: '47936',
18
+ firstName: 'Robert',
19
+ lastName: 'Stein',
20
+ github: 'steiner_rob',
21
+ location: {
22
+ city: 'Los Angeles',
23
+ state: 'CA'
24
+ }
25
+ }, {
26
+ id: '54736',
27
+ firstName: 'Martina',
28
+ lastName: 'Conlon',
29
+ github: 'martina_zen',
30
+ location: {
31
+ city: 'Boston',
32
+ state: 'MA'
33
+ }
34
+ }, {
35
+ id: '40193',
36
+ firstName: 'Alyce',
37
+ lastName: 'Benning',
38
+ github: 'alyce_benning',
39
+ location: {
40
+ city: 'Atlanta',
41
+ state: 'GA'
42
+ }
43
+ }];
44
+ var userRows = users.map(function (user) {
45
+ var id = user.id,
46
+ firstName = user.firstName,
47
+ lastName = user.lastName,
48
+ github = user.github,
49
+ _user$location = user.location,
50
+ city = _user$location.city,
51
+ state = _user$location.state;
52
+ return ___EmotionJSX(EuiTableRow, {
53
+ key: id
54
+ }, ___EmotionJSX(EuiTableRowCell, null, "".concat(firstName, " ").concat(lastName)), ___EmotionJSX(EuiTableRowCell, null, github), ___EmotionJSX(EuiTableRowCell, null, "".concat(city, ", ").concat(state)));
55
+ });
56
+ var customColumns = ['Name', 'Github', 'Location'];
57
+ var columnHeaders = customColumns.map(function (column, i) {
58
+ return ___EmotionJSX(EuiTableHeaderCell, {
59
+ key: i
60
+ }, column);
61
+ });
62
+ var CustomTable = function CustomTable() {
63
+ return ___EmotionJSX(EuiTable, null, ___EmotionJSX(EuiTableHeader, null, columnHeaders), ___EmotionJSX(EuiTableBody, null, userRows));
64
+ };
65
+ describe('EuiTable', function () {
66
+ beforeEach(function () {
67
+ cy.viewport(1024, 768); // medium breakpoint
68
+ cy.realMount(___EmotionJSX(CustomTable, null));
69
+ });
70
+ describe('Automated accessibility check', function () {
71
+ it('has zero violations on render', function () {
72
+ cy.checkAxe();
73
+ });
74
+ });
75
+ });
@@ -0,0 +1,188 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
6
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _basic_table = require("./basic_table");
9
+ var _button = require("../button");
10
+ var _health = require("../health");
11
+ var _link = require("../link");
12
+ var _accessibility = require("../accessibility");
13
+ var _services = require("../../services");
14
+ var _faker = require("@faker-js/faker");
15
+ var _react2 = require("@emotion/react");
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); }
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; }
18
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
20
+ var users = [];
21
+ for (var i = 0; i < 20; i++) {
22
+ users.push({
23
+ id: i + 1,
24
+ firstName: _faker.faker.name.firstName(),
25
+ lastName: _faker.faker.name.lastName(),
26
+ github: _faker.faker.internet.userName(),
27
+ dateOfBirth: _faker.faker.date.past(),
28
+ online: _faker.faker.datatype.boolean(),
29
+ location: {
30
+ city: _faker.faker.address.city(),
31
+ country: _faker.faker.address.country()
32
+ }
33
+ });
34
+ }
35
+ var columns = [{
36
+ field: 'firstName',
37
+ name: 'First Name',
38
+ sortable: true,
39
+ truncateText: true,
40
+ mobileOptions: {
41
+ render: function render(user) {
42
+ return (0, _react2.jsx)("span", null, user.firstName, " ", user.lastName);
43
+ },
44
+ header: false,
45
+ truncateText: false,
46
+ enlarge: true,
47
+ width: '100%'
48
+ }
49
+ }, {
50
+ field: 'lastName',
51
+ name: 'Last Name',
52
+ truncateText: true,
53
+ mobileOptions: {
54
+ show: false
55
+ }
56
+ }, {
57
+ field: 'github',
58
+ name: 'Github',
59
+ render: function render(username) {
60
+ return (0, _react2.jsx)(_link.EuiLink, {
61
+ href: "#",
62
+ target: "_blank"
63
+ }, username);
64
+ }
65
+ }, {
66
+ field: 'dateOfBirth',
67
+ name: 'Date of Birth',
68
+ dataType: 'date',
69
+ render: function render(dateOfBirth) {
70
+ return (0, _services.formatDate)(dateOfBirth, 'dobLong');
71
+ },
72
+ sortable: true
73
+ }, {
74
+ field: 'location',
75
+ name: 'Location',
76
+ truncateText: true,
77
+ textOnly: true,
78
+ render: function render(location) {
79
+ return "".concat(location.city, ", ").concat(location.country);
80
+ }
81
+ }, {
82
+ field: 'online',
83
+ name: 'Online',
84
+ dataType: 'boolean',
85
+ render: function render(online) {
86
+ var color = online ? 'success' : 'danger';
87
+ var label = online ? 'Online' : 'Offline';
88
+ return (0, _react2.jsx)(_health.EuiHealth, {
89
+ color: color
90
+ }, label);
91
+ },
92
+ sortable: true,
93
+ mobileOptions: {
94
+ show: false
95
+ }
96
+ }];
97
+ describe('EuiTable', function () {
98
+ var BasicTable = function BasicTable() {
99
+ return (0, _react2.jsx)(_basic_table.EuiBasicTable, {
100
+ tableCaption: "Demo of EuiBasicTable",
101
+ columns: columns,
102
+ items: users,
103
+ "data-test-subj": "cy-basic-table"
104
+ });
105
+ };
106
+ describe('Basic table', function () {
107
+ describe('Automated accessibility check', function () {
108
+ it('has zero violations on render', function () {
109
+ cy.viewport(1024, 768); // medium breakpoint
110
+ cy.realMount((0, _react2.jsx)(BasicTable, null));
111
+ cy.get('[data-test-subj="cy-basic-table"]').should('exist');
112
+ cy.checkAxe();
113
+ });
114
+ });
115
+ });
116
+ describe('Mobile basic table', function () {
117
+ describe('Automated accessibility check', function () {
118
+ it('has zero violations on render', function () {
119
+ cy.viewport(375, 667); // small breakpoint
120
+ cy.realMount((0, _react2.jsx)(BasicTable, null));
121
+ cy.get('[data-test-subj="cy-basic-table"]').should('exist');
122
+ cy.checkAxe();
123
+ });
124
+ });
125
+ });
126
+ describe('Expandable rows', function () {
127
+ var ExpandableRowTable = function ExpandableRowTable() {
128
+ var _useState = (0, _react.useState)({}),
129
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
130
+ itemIdToExpandedRowMap = _useState2[0],
131
+ setItemIdToExpandedRowMap = _useState2[1];
132
+ var toggleDetails = function toggleDetails(user) {
133
+ var itemIdToExpandedRowMapValues = _objectSpread({}, itemIdToExpandedRowMap);
134
+ if (itemIdToExpandedRowMapValues[user.id]) {
135
+ delete itemIdToExpandedRowMapValues[user.id];
136
+ } else {
137
+ itemIdToExpandedRowMapValues[user.id] = (0, _react2.jsx)("div", null, (0, _react2.jsx)("p", null, "Location: ".concat(user.location.city)), (0, _react2.jsx)("p", null, "This person is online."));
138
+ }
139
+ setItemIdToExpandedRowMap(itemIdToExpandedRowMapValues);
140
+ };
141
+ var columnsWithExpandingRowToggle = [].concat(columns, [{
142
+ align: 'right',
143
+ width: '40px',
144
+ isExpander: true,
145
+ name: (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("span", null, "Expand rows")),
146
+ render: function render(user) {
147
+ var itemIdToExpandedRowMapValues = _objectSpread({}, itemIdToExpandedRowMap);
148
+ return (0, _react2.jsx)(_button.EuiButtonIcon, {
149
+ id: user.id.toString(),
150
+ onClick: function onClick() {
151
+ return toggleDetails(user);
152
+ },
153
+ "aria-label": itemIdToExpandedRowMapValues[user.id] ? 'Collapse' : 'Expand',
154
+ iconType: itemIdToExpandedRowMapValues[user.id] ? 'arrowDown' : 'arrowRight'
155
+ });
156
+ }
157
+ }]);
158
+ return (0, _react2.jsx)(_basic_table.EuiBasicTable, {
159
+ tableCaption: "Demo of EuiBasicTable with expanding rows",
160
+ itemIdToExpandedRowMap: itemIdToExpandedRowMap,
161
+ isExpandable: true,
162
+ columns: columnsWithExpandingRowToggle,
163
+ items: users,
164
+ itemId: "id",
165
+ "data-test-subj": "cy-expandable-row-table"
166
+ });
167
+ };
168
+ beforeEach(function () {
169
+ cy.viewport(1024, 768); // medium breakpoint
170
+ cy.realMount((0, _react2.jsx)(ExpandableRowTable, null));
171
+ cy.get('[data-test-subj="cy-expandable-row-table"]').should('exist');
172
+ });
173
+ describe('Automated accessibility check', function () {
174
+ it('has zero violations on render', function () {
175
+ cy.checkAxe();
176
+ });
177
+ });
178
+ describe('Keyboard accessibility', function () {
179
+ it('has zero violations after expanding a row', function () {
180
+ cy.repeatRealPress('Tab');
181
+ cy.get('button#1').should('have.focus');
182
+ cy.realPress('Enter');
183
+ cy.get('tr.euiTableRow-isExpandedRow div.euiTableCellContent').should('exist');
184
+ cy.checkAxe();
185
+ });
186
+ });
187
+ });
188
+ });
@@ -3,7 +3,7 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
  var _react = _interopRequireDefault(require("react"));
5
5
  var _faker = require("@faker-js/faker");
6
- var _index = require("./index");
6
+ var _ = require(".");
7
7
  var _health = require("../health");
8
8
  var _link = require("../link");
9
9
  var _services = require("../../services");
@@ -99,7 +99,7 @@ var columns = [{
99
99
  }];
100
100
  describe('EuiInMemoryTable', function () {
101
101
  var mountTable = function mountTable() {
102
- cy.realMount((0, _react2.jsx)(_index.EuiInMemoryTable, {
102
+ cy.realMount((0, _react2.jsx)(_.EuiInMemoryTable, {
103
103
  "data-test-subj": "cy-in-memory-table",
104
104
  tableCaption: "Demo of EuiInMemoryTable",
105
105
  items: users,
@@ -17,7 +17,7 @@ var _services = require("../../services");
17
17
  var _context = require("../context");
18
18
  var _reactDatepicker = require("./react-datepicker");
19
19
  var _react2 = require("@emotion/react");
20
- var _excluded = ["adjustDateOnChange", "calendarClassName", "className", "customInput", "dateFormat", "dayClassName", "disabled", "excludeDates", "filterDate", "fullWidth", "iconType", "injectTimes", "inline", "inputRef", "isInvalid", "isLoading", "locale", "maxDate", "maxTime", "minDate", "minTime", "onChange", "onClear", "openToDate", "placeholder", "popperClassName", "popoverPlacement", "selected", "shadow", "shouldCloseOnSelect", "showIcon", "showTimeSelect", "showTimeSelectOnly", "timeFormat", "utcOffset"];
20
+ var _excluded = ["adjustDateOnChange", "calendarClassName", "className", "controlOnly", "customInput", "dateFormat", "dayClassName", "disabled", "excludeDates", "filterDate", "fullWidth", "iconType", "injectTimes", "inline", "inputRef", "isInvalid", "isLoading", "locale", "maxDate", "maxTime", "minDate", "minTime", "onChange", "onClear", "openToDate", "placeholder", "popperClassName", "popoverPlacement", "selected", "shadow", "shouldCloseOnSelect", "showIcon", "showTimeSelect", "showTimeSelectOnly", "timeFormat", "utcOffset"];
21
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
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; }
23
23
  var euiDatePickerDefaultDateFormat = 'MM/DD/YYYY';
@@ -56,6 +56,7 @@ var EuiDatePicker = function EuiDatePicker(_ref) {
56
56
  adjustDateOnChange = _ref$adjustDateOnChan === void 0 ? true : _ref$adjustDateOnChan,
57
57
  calendarClassName = _ref.calendarClassName,
58
58
  className = _ref.className,
59
+ controlOnly = _ref.controlOnly,
59
60
  customInput = _ref.customInput,
60
61
  _ref$dateFormat = _ref.dateFormat,
61
62
  dateFormat = _ref$dateFormat === void 0 ? euiDatePickerDefaultDateFormat : _ref$dateFormat,
@@ -101,7 +102,7 @@ var EuiDatePicker = function EuiDatePicker(_ref) {
101
102
  'euiDatePicker--shadow': shadow,
102
103
  'euiDatePicker--inline': inline
103
104
  });
104
- var numIconsClass = (0, _num_icons.getFormControlClassNameForIconCount)({
105
+ var numIconsClass = controlOnly ? false : (0, _num_icons.getFormControlClassNameForIconCount)({
105
106
  isInvalid: isInvalid,
106
107
  isLoading: isLoading
107
108
  });
@@ -142,17 +143,7 @@ var EuiDatePicker = function EuiDatePicker(_ref) {
142
143
  controlEl: inputValidityRef
143
144
  });
144
145
  var inputRefs = (0, _services.useCombinedRefs)([inputRef, setInputValidityRef]);
145
- return (0, _react2.jsx)("span", {
146
- className: classes
147
- }, (0, _react2.jsx)(_form.EuiFormControlLayout, {
148
- icon: optionalIcon,
149
- fullWidth: fullWidth,
150
- clear: selected && onClear ? {
151
- onClick: onClear
152
- } : undefined,
153
- isLoading: isLoading,
154
- isInvalid: isInvalid
155
- }, (0, _react2.jsx)(_context.EuiI18nConsumer, null, function (_ref2) {
146
+ var control = (0, _react2.jsx)(_context.EuiI18nConsumer, null, function (_ref2) {
156
147
  var contextLocale = _ref2.locale;
157
148
  return (0, _react2.jsx)(_reactDatepicker.ReactDatePicker, (0, _extends2.default)({
158
149
  adjustDateOnChange: adjustDateOnChange,
@@ -188,6 +179,18 @@ var EuiDatePicker = function EuiDatePicker(_ref) {
188
179
  accessibleMode: true,
189
180
  popperPlacement: popoverPlacement
190
181
  }, rest));
191
- })));
182
+ });
183
+ if (controlOnly) return control;
184
+ return (0, _react2.jsx)("span", {
185
+ className: classes
186
+ }, (0, _react2.jsx)(_form.EuiFormControlLayout, {
187
+ icon: optionalIcon,
188
+ fullWidth: fullWidth,
189
+ clear: selected && onClear ? {
190
+ onClick: onClear
191
+ } : undefined,
192
+ isLoading: isLoading,
193
+ isInvalid: isInvalid
194
+ }, control));
192
195
  };
193
196
  exports.EuiDatePicker = EuiDatePicker;