@elastic/eui 60.2.0 → 60.3.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 (36) hide show
  1. package/es/components/accordion/accordion.js +10 -5
  2. package/es/components/context_menu/context_menu.js +1 -1
  3. package/es/components/datagrid/body/data_grid_body.js +6 -3
  4. package/es/components/datagrid/body/data_grid_cell.js +78 -10
  5. package/es/components/datagrid/data_grid.js +2 -0
  6. package/es/components/datagrid/utils/ref.js +24 -3
  7. package/es/components/selectable/selectable.js +2 -0
  8. package/eui.d.ts +19 -5
  9. package/i18ntokens.json +27 -27
  10. package/lib/components/accordion/accordion.js +10 -5
  11. package/lib/components/context_menu/context_menu.js +1 -1
  12. package/lib/components/datagrid/body/data_grid_body.js +6 -3
  13. package/lib/components/datagrid/body/data_grid_cell.js +77 -9
  14. package/lib/components/datagrid/data_grid.js +2 -0
  15. package/lib/components/datagrid/utils/ref.js +24 -3
  16. package/lib/components/selectable/selectable.js +2 -0
  17. package/optimize/es/components/accordion/accordion.js +10 -5
  18. package/optimize/es/components/datagrid/body/data_grid_body.js +6 -3
  19. package/optimize/es/components/datagrid/body/data_grid_cell.js +18 -9
  20. package/optimize/es/components/datagrid/data_grid.js +2 -0
  21. package/optimize/es/components/datagrid/utils/ref.js +24 -3
  22. package/optimize/es/components/selectable/selectable.js +2 -0
  23. package/optimize/lib/components/accordion/accordion.js +8 -5
  24. package/optimize/lib/components/datagrid/body/data_grid_body.js +6 -3
  25. package/optimize/lib/components/datagrid/body/data_grid_cell.js +17 -8
  26. package/optimize/lib/components/datagrid/data_grid.js +2 -0
  27. package/optimize/lib/components/datagrid/utils/ref.js +24 -3
  28. package/optimize/lib/components/selectable/selectable.js +2 -0
  29. package/package.json +3 -3
  30. package/test-env/components/accordion/accordion.js +8 -5
  31. package/test-env/components/context_menu/context_menu.js +1 -1
  32. package/test-env/components/datagrid/body/data_grid_body.js +6 -3
  33. package/test-env/components/datagrid/body/data_grid_cell.js +77 -9
  34. package/test-env/components/datagrid/data_grid.js +2 -0
  35. package/test-env/components/datagrid/utils/ref.js +24 -3
  36. package/test-env/components/selectable/selectable.js +2 -0
@@ -170,6 +170,8 @@ var EuiSelectable = /*#__PURE__*/function (_Component) {
170
170
  event.stopPropagation();
171
171
 
172
172
  if (_this.state.activeOptionIndex != null && optionsList) {
173
+ event.persist(); // NOTE: This is needed for React v16 backwards compatibility
174
+
173
175
  optionsList.onAddOrRemoveOption(_this.state.visibleOptions[_this.state.activeOptionIndex], event);
174
176
  }
175
177
 
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@elastic/eui",
3
3
  "description": "Elastic UI Component Library",
4
- "version": "60.2.0",
4
+ "version": "60.3.0",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "main": "lib",
7
7
  "module": "es",
8
8
  "types": "eui.d.ts",
9
- "docker_image": "node:16.14.2",
9
+ "docker_image": "node:16.16.0",
10
10
  "sideEffects": [
11
11
  "*.css",
12
12
  "*.scss"
@@ -115,7 +115,7 @@
115
115
  "@cypress/code-coverage": "^3.9.12",
116
116
  "@cypress/react": "^5.10.3",
117
117
  "@cypress/webpack-dev-server": "^1.7.0",
118
- "@elastic/charts": "^46.11.2",
118
+ "@elastic/charts": "^46.12.1",
119
119
  "@elastic/datemath": "^5.0.3",
120
120
  "@elastic/eslint-config-kibana": "^0.15.0",
121
121
  "@emotion/babel-preset-css-prop": "^11.2.0",
@@ -122,6 +122,12 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
122
122
  _this.childContent = node;
123
123
  });
124
124
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "generatedId", (0, _services.htmlIdGenerator)()());
125
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "resizeRef", function () {});
126
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "observerRef", function (ref) {
127
+ _this.setChildContentRef(ref);
128
+
129
+ _this.resizeRef(ref);
130
+ });
125
131
  return _this;
126
132
  }
127
133
 
@@ -271,12 +277,9 @@ var EuiAccordionClass = /*#__PURE__*/function (_Component) {
271
277
  }, (0, _react2.jsx)(_resize_observer.EuiResizeObserver, {
272
278
  onResize: this.setChildContentHeight
273
279
  }, function (resizeRef) {
280
+ _this2.resizeRef = resizeRef;
274
281
  return (0, _react2.jsx)("div", {
275
- ref: function ref(_ref) {
276
- _this2.setChildContentRef(_ref);
277
-
278
- resizeRef(_ref);
279
- }
282
+ ref: _this2.observerRef
280
283
  }, (0, _react2.jsx)("div", {
281
284
  className: childrenClasses,
282
285
  css: cssChildrenStyles
@@ -401,7 +401,7 @@ EuiContextMenu.propTypes = {
401
401
  "data-test-subj": _propTypes.default.string
402
402
  }).isRequired),
403
403
  content: _propTypes.default.node,
404
- width: _propTypes.default.number,
404
+ width: _propTypes.default.any,
405
405
  initialFocusedItemIndex: _propTypes.default.number,
406
406
 
407
407
  /**
@@ -84,7 +84,8 @@ var Cell = function Cell(_ref) {
84
84
  schemaDetectors = data.schemaDetectors,
85
85
  rowHeightsOptions = data.rowHeightsOptions,
86
86
  rowHeightUtils = data.rowHeightUtils,
87
- rowManager = data.rowManager;
87
+ rowManager = data.rowManager,
88
+ pagination = data.pagination;
88
89
  var popoverContext = (0, _react.useContext)(_data_grid_cell_popover.DataGridCellPopoverContext);
89
90
 
90
91
  var _useContext = (0, _react.useContext)(DataGridWrapperRowsContext),
@@ -123,7 +124,8 @@ var Cell = function Cell(_ref) {
123
124
  rowHeightUtils: rowHeightUtils,
124
125
  setRowHeight: isFirstColumn ? setRowHeight : undefined,
125
126
  rowManager: rowManager,
126
- popoverContext: popoverContext
127
+ popoverContext: popoverContext,
128
+ pagination: pagination
127
129
  };
128
130
 
129
131
  if (isLeadingControlColumn) {
@@ -456,7 +458,8 @@ var EuiDataGridBody = function EuiDataGridBody(props) {
456
458
  interactiveCellId: interactiveCellId,
457
459
  rowHeightsOptions: rowHeightsOptions,
458
460
  rowHeightUtils: rowHeightUtils,
459
- rowManager: rowManager
461
+ rowManager: rowManager,
462
+ pagination: pagination
460
463
  },
461
464
  rowCount: _utils.IS_JEST_ENVIRONMENT || headerRowHeight > 0 ? visibleRowCount : 0
462
465
  }), Cell), scrollBorderOverlay) : null;
@@ -57,8 +57,8 @@ var _utils = require("../../../utils");
57
57
 
58
58
  var _react2 = require("@emotion/react");
59
59
 
60
- var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "rowHeightUtils", "isDefinedHeight"],
61
- _excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager"],
60
+ var _excluded = ["renderCellValue", "column", "setCellContentsRef", "rowHeightsOptions", "rowIndex", "colIndex", "ariaRowIndex", "rowHeightUtils", "isDefinedHeight"],
61
+ _excluded2 = ["width", "popoverContext", "interactiveCellId", "columnType", "className", "column", "style", "rowHeightUtils", "rowHeightsOptions", "rowManager", "pagination"],
62
62
  _excluded3 = ["isExpandable", "style", "className", "data-test-subj"];
63
63
 
64
64
  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); }
@@ -80,15 +80,12 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
80
80
  rowHeightsOptions = _ref.rowHeightsOptions,
81
81
  rowIndex = _ref.rowIndex,
82
82
  colIndex = _ref.colIndex,
83
+ ariaRowIndex = _ref.ariaRowIndex,
83
84
  rowHeightUtils = _ref.rowHeightUtils,
84
85
  isDefinedHeight = _ref.isDefinedHeight,
85
86
  rest = (0, _objectWithoutProperties2.default)(_ref, _excluded);
86
87
  // React is more permissible than the TS types indicate
87
88
  var CellElement = renderCellValue;
88
- var positionText = (0, _i18n.useEuiI18n)('euiDataGridCell.position', 'Row: {row}; Column: {col}', {
89
- row: rowIndex + 1,
90
- col: colIndex + 1
91
- });
92
89
  return (0, _react2.jsx)(_react.default.Fragment, null, (0, _react2.jsx)("div", {
93
90
  ref: setCellContentsRef,
94
91
  "data-datagrid-cellcontent": true,
@@ -100,7 +97,15 @@ var EuiDataGridCellContent = /*#__PURE__*/(0, _react.memo)(function (_ref) {
100
97
  rowIndex: rowIndex,
101
98
  colIndex: colIndex,
102
99
  schema: (column === null || column === void 0 ? void 0 : column.schema) || rest.columnType
103
- }, rest))), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", null, positionText)));
100
+ }, rest))), (0, _react2.jsx)(_accessibility.EuiScreenReaderOnly, null, (0, _react2.jsx)("p", null, '- ', (0, _react2.jsx)(_i18n.EuiI18n, {
101
+ token: "euiDataGridCell.position",
102
+ default: "{columnId}, column {col}, row {row}",
103
+ values: {
104
+ columnId: (column === null || column === void 0 ? void 0 : column.displayAsText) || rest.columnId,
105
+ col: colIndex + 1,
106
+ row: ariaRowIndex
107
+ }
108
+ }))));
104
109
  });
105
110
  EuiDataGridCellContent.propTypes = {
106
111
  rowIndex: _propTypes.default.number.isRequired,
@@ -556,10 +561,40 @@ EuiDataGridCellContent.propTypes = {
556
561
  onChange: _propTypes.default.func
557
562
  }),
558
563
  rowHeightUtils: _propTypes.default.any,
564
+ pagination: _propTypes.default.shape({
565
+ /**
566
+ * The index of the current page, starts at 0 for the first page
567
+ */
568
+ pageIndex: _propTypes.default.number.isRequired,
569
+
570
+ /**
571
+ * How many rows should initially be shown per page.
572
+ * Pass `0` to display the selected "Show all" option and hide the pagination.
573
+ */
574
+ pageSize: _propTypes.default.number.isRequired,
575
+
576
+ /**
577
+ * An array of page sizes the user can select from.
578
+ * Pass `0` as one of the options to create a "Show all" option.
579
+ * Leave this prop undefined or use an empty array to hide "Rows per page" select button.
580
+ */
581
+ pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.number.isRequired),
582
+
583
+ /**
584
+ * A callback for when the user changes the page size selection
585
+ */
586
+ onChangeItemsPerPage: _propTypes.default.func.isRequired,
587
+
588
+ /**
589
+ * A callback for when the current page index changes
590
+ */
591
+ onChangePage: _propTypes.default.func.isRequired
592
+ }),
559
593
  setCellProps: _propTypes.default.func.isRequired,
560
594
  setCellContentsRef: _propTypes.default.any.isRequired,
561
595
  isExpanded: _propTypes.default.bool.isRequired,
562
- isDefinedHeight: _propTypes.default.bool.isRequired
596
+ isDefinedHeight: _propTypes.default.bool.isRequired,
597
+ ariaRowIndex: _propTypes.default.number.isRequired
563
598
  };
564
599
 
565
600
  var EuiDataGridCell = /*#__PURE__*/function (_Component) {
@@ -939,6 +974,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
939
974
  rowHeightUtils = _this$props8.rowHeightUtils,
940
975
  rowHeightsOptions = _this$props8.rowHeightsOptions,
941
976
  rowManager = _this$props8.rowManager,
977
+ pagination = _this$props8.pagination,
942
978
  rest = (0, _objectWithoutProperties2.default)(_this$props8, _excluded2);
943
979
  var rowIndex = rest.rowIndex,
944
980
  visibleRowIndex = rest.visibleRowIndex,
@@ -947,6 +983,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
947
983
  var popoverIsOpen = this.isPopoverOpen();
948
984
  var showCellActions = this.state.isFocused || this.state.isEntered || this.state.enableInteractions || popoverIsOpen;
949
985
  var cellClasses = (0, _classnames.default)('euiDataGridRowCell', (_classNames = {}, (0, _defineProperty2.default)(_classNames, "euiDataGridRowCell--".concat(columnType), columnType), (0, _defineProperty2.default)(_classNames, 'euiDataGridRowCell--open', popoverIsOpen), _classNames), className);
986
+ var ariaRowIndex = pagination ? visibleRowIndex + 1 + pagination.pageSize * pagination.pageIndex : visibleRowIndex + 1;
950
987
  var _this$state$cellProps2 = this.state.cellProps,
951
988
  _ = _this$state$cellProps2.isExpandable,
952
989
  cellPropsStyle = _this$state$cellProps2.style,
@@ -1054,7 +1091,8 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
1054
1091
  setCellContentsRef: this.setCellContentsRef,
1055
1092
  rowHeightsOptions: rowHeightsOptions,
1056
1093
  rowHeightUtils: rowHeightUtils,
1057
- isDefinedHeight: isDefinedHeight
1094
+ isDefinedHeight: isDefinedHeight,
1095
+ ariaRowIndex: ariaRowIndex
1058
1096
  });
1059
1097
 
1060
1098
  var anchorClass = 'euiDataGridRowCell__expandFlex';
@@ -1100,6 +1138,7 @@ var EuiDataGridCell = /*#__PURE__*/function (_Component) {
1100
1138
 
1101
1139
  var content = (0, _react2.jsx)("div", (0, _extends2.default)({
1102
1140
  role: "gridcell",
1141
+ "aria-rowindex": ariaRowIndex,
1103
1142
  tabIndex: this.state.isFocused && !this.state.disableCellTabIndex ? 0 : -1,
1104
1143
  ref: this.cellRef
1105
1144
  }, cellProps, {
@@ -1521,5 +1560,34 @@ EuiDataGridCell.propTypes = {
1521
1560
  rowHeightUtils: _propTypes.default.any,
1522
1561
  rowManager: _propTypes.default.shape({
1523
1562
  getRow: _propTypes.default.func.isRequired
1563
+ }),
1564
+ pagination: _propTypes.default.shape({
1565
+ /**
1566
+ * The index of the current page, starts at 0 for the first page
1567
+ */
1568
+ pageIndex: _propTypes.default.number.isRequired,
1569
+
1570
+ /**
1571
+ * How many rows should initially be shown per page.
1572
+ * Pass `0` to display the selected "Show all" option and hide the pagination.
1573
+ */
1574
+ pageSize: _propTypes.default.number.isRequired,
1575
+
1576
+ /**
1577
+ * An array of page sizes the user can select from.
1578
+ * Pass `0` as one of the options to create a "Show all" option.
1579
+ * Leave this prop undefined or use an empty array to hide "Rows per page" select button.
1580
+ */
1581
+ pageSizeOptions: _propTypes.default.arrayOf(_propTypes.default.number.isRequired),
1582
+
1583
+ /**
1584
+ * A callback for when the user changes the page size selection
1585
+ */
1586
+ onChangeItemsPerPage: _propTypes.default.func.isRequired,
1587
+
1588
+ /**
1589
+ * A callback for when the current page index changes
1590
+ */
1591
+ onChangePage: _propTypes.default.func.isRequired
1524
1592
  })
1525
1593
  };
@@ -266,6 +266,7 @@ var EuiDataGrid = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
266
266
 
267
267
  (0, _ref.useImperativeGridRef)({
268
268
  ref: ref,
269
+ gridRef: gridRef,
269
270
  setIsFullScreen: setIsFullScreen,
270
271
  focusContext: focusContext,
271
272
  cellPopoverContext: cellPopoverContext,
@@ -369,6 +370,7 @@ var EuiDataGrid = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
369
370
  "data-test-subj": "euiDataGridBody",
370
371
  className: "euiDataGrid__content",
371
372
  role: "grid",
373
+ "aria-rowcount": rowCount,
372
374
  id: gridId
373
375
  }, wrappingDivFocusProps, gridAriaProps), (0, _react2.jsx)(_body.EuiDataGridBody, {
374
376
  columns: orderedVisibleColumns,
@@ -16,6 +16,7 @@ var _react = require("react");
16
16
  */
17
17
  var useImperativeGridRef = function useImperativeGridRef(_ref) {
18
18
  var ref = _ref.ref,
19
+ gridRef = _ref.gridRef,
19
20
  setIsFullScreen = _ref.setIsFullScreen,
20
21
  focusContext = _ref.focusContext,
21
22
  cellPopoverContext = _ref.cellPopoverContext,
@@ -70,16 +71,36 @@ var useImperativeGridRef = function useImperativeGridRef(_ref) {
70
71
  rowIndex: visibleRowIndex,
71
72
  colIndex: colIndex
72
73
  });
73
- }, [_openCellPopover, checkCellExists, findVisibleRowIndex]); // Set the ref APIs
74
+ }, [_openCellPopover, checkCellExists, findVisibleRowIndex]);
75
+ var scrollTo = (0, _react.useCallback)(function () {
76
+ var _gridRef$current;
77
+
78
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
79
+ args[_key] = arguments[_key];
80
+ }
81
+
82
+ return (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.scrollTo.apply(_gridRef$current, args);
83
+ }, [gridRef]);
84
+ var scrollToItem = (0, _react.useCallback)(function () {
85
+ var _gridRef$current2;
86
+
87
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
88
+ args[_key2] = arguments[_key2];
89
+ }
90
+
91
+ return (_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.scrollToItem.apply(_gridRef$current2, args);
92
+ }, [gridRef]); // Set the ref APIs
74
93
 
75
94
  (0, _react.useImperativeHandle)(ref, function () {
76
95
  return {
77
96
  setIsFullScreen: setIsFullScreen,
78
97
  setFocusedCell: setFocusedCell,
79
98
  openCellPopover: openCellPopover,
80
- closeCellPopover: closeCellPopover
99
+ closeCellPopover: closeCellPopover,
100
+ scrollTo: scrollTo,
101
+ scrollToItem: scrollToItem
81
102
  };
82
- }, [setIsFullScreen, setFocusedCell, openCellPopover, closeCellPopover]);
103
+ }, [setIsFullScreen, setFocusedCell, openCellPopover, closeCellPopover, scrollTo, scrollToItem]);
83
104
  };
84
105
  /**
85
106
  * Throw a digestible error if the consumer attempts to focus into an invalid
@@ -172,6 +172,8 @@ var EuiSelectable = /*#__PURE__*/function (_Component) {
172
172
  event.stopPropagation();
173
173
 
174
174
  if (_this.state.activeOptionIndex != null && optionsList) {
175
+ event.persist(); // NOTE: This is needed for React v16 backwards compatibility
176
+
175
177
  optionsList.onAddOrRemoveOption(_this.state.visibleOptions[_this.state.activeOptionIndex], event);
176
178
  }
177
179