@elastic/eui 97.0.0 → 97.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  2. package/es/components/datagrid/body/cell/focus_utils.js +14 -4
  3. package/es/components/datagrid/body/data_grid_body.js +2 -1
  4. package/es/components/datagrid/body/data_grid_body_custom.js +5 -2
  5. package/es/components/datagrid/body/data_grid_body_virtualized.js +8 -4
  6. package/es/components/datagrid/body/header/column_actions.js +262 -27
  7. package/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +10 -4
  8. package/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
  9. package/es/components/datagrid/body/header/column_sorting.js +134 -0
  10. package/es/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
  11. package/es/components/datagrid/body/header/data_grid_header_cell.js +86 -305
  12. package/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  13. package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
  14. package/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  15. package/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
  16. package/es/components/datagrid/body/header/draggable_columns.js +301 -0
  17. package/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
  18. package/es/components/datagrid/data_grid.js +2 -1
  19. package/es/components/datagrid/data_grid.stories.utils.js +9 -6
  20. package/es/components/datagrid/utils/col_widths.js +4 -6
  21. package/es/components/datagrid/utils/focus.js +2 -2
  22. package/es/components/datagrid/utils/scrolling.js +13 -10
  23. package/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
  24. package/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
  25. package/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
  26. package/es/components/date_picker/super_date_picker/super_date_picker.js +27 -5
  27. package/es/components/drag_and_drop/draggable.js +13 -5
  28. package/es/components/header/header.styles.js +6 -12
  29. package/es/components/header/header_links/header_links.js +1 -1
  30. package/es/components/header/header_links/header_links.styles.js +1 -0
  31. package/es/components/page_template/inner/page_inner.styles.js +3 -4
  32. package/es/components/tabs/tab.js +1 -1
  33. package/eui.d.ts +417 -307
  34. package/i18ntokens.json +175 -175
  35. package/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  36. package/lib/components/datagrid/body/cell/focus_utils.js +14 -4
  37. package/lib/components/datagrid/body/data_grid_body.js +2 -1
  38. package/lib/components/datagrid/body/data_grid_body_custom.js +5 -2
  39. package/lib/components/datagrid/body/data_grid_body_virtualized.js +8 -4
  40. package/lib/components/datagrid/body/header/column_actions.js +265 -29
  41. package/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
  42. package/{optimize/lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
  43. package/lib/components/datagrid/body/header/column_sorting.js +144 -0
  44. package/lib/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
  45. package/lib/components/datagrid/body/header/data_grid_header_cell.js +86 -305
  46. package/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  47. package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
  48. package/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  49. package/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
  50. package/lib/components/datagrid/body/header/draggable_columns.js +308 -0
  51. package/lib/components/datagrid/body/header/draggable_columns.styles.js +42 -0
  52. package/lib/components/datagrid/data_grid.js +2 -1
  53. package/lib/components/datagrid/data_grid.stories.utils.js +9 -6
  54. package/lib/components/datagrid/utils/col_widths.js +4 -6
  55. package/lib/components/datagrid/utils/focus.js +2 -2
  56. package/lib/components/datagrid/utils/scrolling.js +13 -10
  57. package/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
  58. package/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
  59. package/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
  60. package/lib/components/date_picker/super_date_picker/super_date_picker.js +27 -5
  61. package/lib/components/drag_and_drop/draggable.js +13 -5
  62. package/lib/components/header/header.styles.js +6 -12
  63. package/lib/components/header/header_links/header_links.js +1 -1
  64. package/lib/components/header/header_links/header_links.styles.js +1 -0
  65. package/lib/components/page_template/inner/page_inner.styles.js +3 -4
  66. package/lib/components/tabs/tab.js +1 -1
  67. package/optimize/es/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  68. package/optimize/es/components/datagrid/body/cell/focus_utils.js +13 -4
  69. package/optimize/es/components/datagrid/body/data_grid_body_custom.js +3 -1
  70. package/optimize/es/components/datagrid/body/data_grid_body_virtualized.js +6 -3
  71. package/optimize/es/components/datagrid/body/header/column_actions.js +250 -26
  72. package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +8 -3
  73. package/optimize/es/components/datagrid/body/header/{data_grid_column_resizer.styles.js → column_resizer.styles.js} +6 -1
  74. package/optimize/es/components/datagrid/body/header/column_sorting.js +134 -0
  75. package/optimize/es/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
  76. package/optimize/es/components/datagrid/body/header/data_grid_header_cell.js +82 -302
  77. package/optimize/es/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  78. package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
  79. package/optimize/es/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  80. package/optimize/es/components/datagrid/body/header/data_grid_header_row.js +25 -10
  81. package/optimize/es/components/datagrid/body/header/draggable_columns.js +223 -0
  82. package/optimize/es/components/datagrid/body/header/draggable_columns.styles.js +38 -0
  83. package/optimize/es/components/datagrid/data_grid.js +2 -1
  84. package/optimize/es/components/datagrid/data_grid.stories.utils.js +7 -5
  85. package/optimize/es/components/datagrid/utils/col_widths.js +4 -6
  86. package/optimize/es/components/datagrid/utils/focus.js +2 -2
  87. package/optimize/es/components/datagrid/utils/scrolling.js +13 -10
  88. package/optimize/es/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
  89. package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
  90. package/optimize/es/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
  91. package/optimize/es/components/date_picker/super_date_picker/super_date_picker.js +11 -5
  92. package/optimize/es/components/drag_and_drop/draggable.js +8 -3
  93. package/optimize/es/components/header/header.styles.js +6 -12
  94. package/optimize/es/components/header/header_links/header_links.js +1 -1
  95. package/optimize/es/components/header/header_links/header_links.styles.js +1 -0
  96. package/optimize/es/components/page_template/inner/page_inner.styles.js +3 -4
  97. package/optimize/es/components/tabs/tab.js +1 -1
  98. package/optimize/lib/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  99. package/optimize/lib/components/datagrid/body/cell/focus_utils.js +13 -4
  100. package/optimize/lib/components/datagrid/body/data_grid_body_custom.js +3 -1
  101. package/optimize/lib/components/datagrid/body/data_grid_body_virtualized.js +6 -3
  102. package/optimize/lib/components/datagrid/body/header/column_actions.js +253 -27
  103. package/optimize/lib/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +9 -4
  104. package/{test-env/components/datagrid/body/header/data_grid_column_resizer.styles.js → optimize/lib/components/datagrid/body/header/column_resizer.styles.js} +6 -1
  105. package/optimize/lib/components/datagrid/body/header/column_sorting.js +144 -0
  106. package/optimize/lib/components/datagrid/body/header/data_grid_control_header_cell.js +2 -2
  107. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.js +80 -300
  108. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  109. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.js +15 -14
  110. package/optimize/lib/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  111. package/optimize/lib/components/datagrid/body/header/data_grid_header_row.js +24 -9
  112. package/optimize/lib/components/datagrid/body/header/draggable_columns.js +231 -0
  113. package/optimize/lib/components/datagrid/body/header/draggable_columns.styles.js +43 -0
  114. package/optimize/lib/components/datagrid/data_grid.js +2 -1
  115. package/optimize/lib/components/datagrid/data_grid.stories.utils.js +7 -5
  116. package/optimize/lib/components/datagrid/utils/col_widths.js +4 -6
  117. package/optimize/lib/components/datagrid/utils/focus.js +2 -2
  118. package/optimize/lib/components/datagrid/utils/scrolling.js +13 -10
  119. package/optimize/lib/components/date_picker/super_date_picker/date_popover/absolute_tab.js +5 -1
  120. package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_button.js +6 -2
  121. package/optimize/lib/components/date_picker/super_date_picker/date_popover/date_popover_content.js +6 -2
  122. package/optimize/lib/components/date_picker/super_date_picker/super_date_picker.js +11 -5
  123. package/optimize/lib/components/drag_and_drop/draggable.js +8 -3
  124. package/optimize/lib/components/header/header.styles.js +6 -12
  125. package/optimize/lib/components/header/header_links/header_links.js +1 -1
  126. package/optimize/lib/components/header/header_links/header_links.styles.js +1 -0
  127. package/optimize/lib/components/page_template/inner/page_inner.styles.js +3 -4
  128. package/optimize/lib/components/tabs/tab.js +1 -1
  129. package/package.json +1 -1
  130. package/test-env/components/datagrid/body/cell/data_grid_cell.styles.js +4 -2
  131. package/test-env/components/datagrid/body/cell/focus_utils.js +13 -4
  132. package/test-env/components/datagrid/body/data_grid_body.js +2 -1
  133. package/test-env/components/datagrid/body/data_grid_body_custom.js +5 -2
  134. package/test-env/components/datagrid/body/data_grid_body_virtualized.js +8 -4
  135. package/test-env/components/datagrid/body/header/column_actions.js +261 -27
  136. package/test-env/components/datagrid/body/header/{data_grid_column_resizer.js → column_resizer.js} +11 -5
  137. package/{lib/components/datagrid/body/header/data_grid_column_resizer.styles.js → test-env/components/datagrid/body/header/column_resizer.styles.js} +6 -1
  138. package/test-env/components/datagrid/body/header/column_sorting.js +144 -0
  139. package/test-env/components/datagrid/body/header/data_grid_control_header_cell.js +3 -3
  140. package/test-env/components/datagrid/body/header/data_grid_header_cell.js +82 -301
  141. package/test-env/components/datagrid/body/header/data_grid_header_cell.styles.js +1 -1
  142. package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.js +19 -17
  143. package/test-env/components/datagrid/body/header/data_grid_header_cell_wrapper.styles.js +1 -2
  144. package/test-env/components/datagrid/body/header/data_grid_header_row.js +24 -9
  145. package/test-env/components/datagrid/body/header/draggable_columns.js +305 -0
  146. package/test-env/components/datagrid/body/header/draggable_columns.styles.js +43 -0
  147. package/test-env/components/datagrid/data_grid.js +2 -1
  148. package/test-env/components/datagrid/data_grid.stories.utils.js +9 -6
  149. package/test-env/components/datagrid/utils/col_widths.js +4 -6
  150. package/test-env/components/datagrid/utils/focus.js +2 -2
  151. package/test-env/components/datagrid/utils/scrolling.js +13 -10
  152. package/test-env/components/date_picker/super_date_picker/date_popover/absolute_tab.js +8 -2
  153. package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_button.js +8 -2
  154. package/test-env/components/date_picker/super_date_picker/date_popover/date_popover_content.js +8 -2
  155. package/test-env/components/date_picker/super_date_picker/super_date_picker.js +27 -5
  156. package/test-env/components/drag_and_drop/draggable.js +13 -5
  157. package/test-env/components/header/header.styles.js +6 -12
  158. package/test-env/components/header/header_links/header_links.js +1 -1
  159. package/test-env/components/header/header_links/header_links.styles.js +1 -0
  160. package/test-env/components/page_template/inner/page_inner.styles.js +3 -4
  161. package/test-env/components/tabs/tab.js +1 -1
@@ -1,4 +1,4 @@
1
- var _excluded = ["id", "index", "visibleColCount", "width", "className", "children", "hasActionsPopover", "openActionsPopover", "aria-label"];
1
+ var _excluded = ["id", "index", "isLastColumn", "width", "className", "children", "hasColumnActions", "isDragging", "onKeyDown", "aria-label"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
4
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -33,12 +33,13 @@ import { jsx as ___EmotionJSX } from "@emotion/react";
33
33
  export var EuiDataGridHeaderCellWrapper = function EuiDataGridHeaderCellWrapper(_ref) {
34
34
  var id = _ref.id,
35
35
  index = _ref.index,
36
- visibleColCount = _ref.visibleColCount,
36
+ isLastColumn = _ref.isLastColumn,
37
37
  width = _ref.width,
38
38
  className = _ref.className,
39
39
  children = _ref.children,
40
- hasActionsPopover = _ref.hasActionsPopover,
41
- openActionsPopover = _ref.openActionsPopover,
40
+ hasColumnActions = _ref.hasColumnActions,
41
+ isDragging = _ref.isDragging,
42
+ _onKeyDown = _ref.onKeyDown,
42
43
  ariaLabel = _ref['aria-label'],
43
44
  rest = _objectWithoutProperties(_ref, _excluded);
44
45
  var classes = classnames('euiDataGridHeaderCell', className);
@@ -59,8 +60,8 @@ export var EuiDataGridHeaderCellWrapper = function EuiDataGridHeaderCellWrapper(
59
60
  setInteractiveChildren = _useState6[1];
60
61
  useEffect(function () {
61
62
  // We're checking for interactive children outside of the default actions button
62
- setRenderFocusTrap(interactiveChildren.length > (hasActionsPopover ? 1 : 0));
63
- }, [hasActionsPopover, interactiveChildren]);
63
+ setRenderFocusTrap(interactiveChildren.length > (hasColumnActions ? 1 : 0));
64
+ }, [hasColumnActions, interactiveChildren]);
64
65
  var _useContext = useContext(DataGridFocusContext),
65
66
  setFocusedCell = _useContext.setFocusedCell,
66
67
  onFocusUpdate = _useContext.onFocusUpdate;
@@ -82,14 +83,14 @@ export var EuiDataGridHeaderCellWrapper = function EuiDataGridHeaderCellWrapper(
82
83
  }
83
84
  });
84
85
  }, [index, onFocusUpdate, headerEl]);
85
-
86
- // For cell headers with only actions, auto-open the actions popover on enter keypress
87
86
  var onKeyDown = useCallback(function (e) {
88
- if (e.key === keys.ENTER && hasActionsPopover && !renderFocusTrap && e.target === headerEl) {
89
- openActionsPopover === null || openActionsPopover === void 0 || openActionsPopover();
87
+ // Ignore keys that conflict with the focus trap being entered/exited
88
+ if (renderFocusTrap && (e.key === keys.ENTER || e.key === keys.ESCAPE)) {
89
+ return;
90
90
  }
91
- }, [hasActionsPopover, openActionsPopover, renderFocusTrap, headerEl]);
92
- var isLastColumn = index === visibleColCount - 1;
91
+ // Otherwise, continue with whatever onKeyDown is being passed
92
+ _onKeyDown === null || _onKeyDown === void 0 || _onKeyDown(e);
93
+ }, [_onKeyDown, renderFocusTrap]);
93
94
  return ___EmotionJSX("div", _extends({
94
95
  role: "columnheader",
95
96
  ref: setHeaderEl,
@@ -107,9 +108,9 @@ export var EuiDataGridHeaderCellWrapper = function EuiDataGridHeaderCellWrapper(
107
108
  } : {},
108
109
  "aria-label": renderFocusTrap ? ariaLabel : undefined
109
110
  }, rest), ___EmotionJSX(HandleInteractiveChildren, {
110
- cellEl: headerEl,
111
+ cellEl: isDragging ? null : headerEl,
112
+ renderFocusTrap: isDragging ? false : renderFocusTrap,
111
113
  updateCellFocusContext: updateCellFocusContext,
112
- renderFocusTrap: renderFocusTrap,
113
114
  onInteractiveChildrenFound: setInteractiveChildren
114
115
  }, typeof children === 'function' ? children(renderFocusTrap) : children), isLastColumn ? tabularCopyMarkers.hiddenNewline : tabularCopyMarkers.hiddenTab);
115
116
  };
@@ -117,10 +118,11 @@ EuiDataGridHeaderCellWrapper.propTypes = {
117
118
  children: PropTypes.oneOfType([PropTypes.node.isRequired, PropTypes.func.isRequired]).isRequired,
118
119
  id: PropTypes.string.isRequired,
119
120
  index: PropTypes.number.isRequired,
120
- visibleColCount: PropTypes.number.isRequired,
121
+ isLastColumn: PropTypes.bool.isRequired,
121
122
  width: PropTypes.oneOfType([PropTypes.number.isRequired, PropTypes.oneOf([null])]),
122
123
  className: PropTypes.string,
123
124
  "aria-label": PropTypes.any,
124
- hasActionsPopover: PropTypes.bool,
125
- openActionsPopover: PropTypes.func
125
+ hasColumnActions: PropTypes.bool,
126
+ isDragging: PropTypes.bool,
127
+ onKeyDown: PropTypes.any
126
128
  };
@@ -20,8 +20,7 @@ export var euiDataGridHeaderCellWrapperStyles = function euiDataGridHeaderCellWr
20
20
  hoverStyles = _euiDataGridCellOutli.hoverStyles;
21
21
  var _euiDataGridCellOutli2 = euiDataGridCellOutlineSelectors(),
22
22
  outlineSelectors = _euiDataGridCellOutli2.header;
23
- var _sharedFlexCss = /*#__PURE__*/css("display:flex;align-items:center;gap:", euiTheme.size.xxs, ";");
24
23
  return {
25
- euiDataGridHeaderCell: /*#__PURE__*/css("position:relative;", _sharedFlexCss, " flex:0 0 auto;font-weight:", euiTheme.font.weight.bold, ";", outlineSelectors.focus, "{", focusStyles, ";}", outlineSelectors.focusTrapped, "{", hoverStyles, ";}&>[data-focus-lock-disabled]{", _sharedFlexCss, " ", logicalCSS('width', '100%'), ";};label:euiDataGridHeaderCell;")
24
+ euiDataGridHeaderCell: /*#__PURE__*/css("position:relative;display:flex;align-items:center;flex:0 0 auto;font-weight:", euiTheme.font.weight.bold, ";", outlineSelectors.focus, "{", focusStyles, ";}", outlineSelectors.focusTrapped, "{", hoverStyles, ";}", outlineSelectors.showActions, "{&,&>[data-focus-lock-disabled]{gap:", euiTheme.size.xxs, ";}}&>[data-focus-lock-disabled]{display:flex;align-items:center;", logicalCSS('width', '100%'), ";};label:euiDataGridHeaderCell;")
26
25
  };
27
26
  };
@@ -1,4 +1,4 @@
1
- var _excluded = ["className", "data-test-subj", "leadingControlColumns", "trailingControlColumns", "columns", "columnWidths", "defaultColumnWidth", "setColumnWidth", "visibleColCount", "setVisibleColumns", "switchColumnPos", "sorting", "schema", "schemaDetectors", "gridStyles"];
1
+ var _excluded = ["className", "data-test-subj", "leadingControlColumns", "trailingControlColumns", "columns", "columnWidths", "defaultColumnWidth", "setColumnWidth", "visibleColCount", "setVisibleColumns", "switchColumnPos", "sorting", "schema", "schemaDetectors", "gridStyles", "canDragAndDropColumns"];
2
2
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
3
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
4
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
@@ -11,14 +11,16 @@ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t =
11
11
  */
12
12
 
13
13
  import classnames from 'classnames';
14
- import React, { forwardRef, memo } from 'react';
14
+ import React, { forwardRef, memo, useCallback } from 'react';
15
15
  import { useEuiMemoizedStyles } from '../../../../services';
16
16
  import { emptyControlColumns } from '../../data_grid_types';
17
+ import { ConditionalDroppableColumns } from './draggable_columns';
17
18
  import { EuiDataGridControlHeaderCell } from './data_grid_control_header_cell';
18
19
  import { EuiDataGridHeaderCell } from './data_grid_header_cell';
19
20
  import { euiDataGridHeaderStyles } from './data_grid_header_row.styles';
20
21
  import { jsx as ___EmotionJSX } from "@emotion/react";
21
22
  var EuiDataGridHeaderRow = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (props, ref) {
23
+ var _leadingControlColumn;
22
24
  var className = props.className,
23
25
  _dataTestSubj = props['data-test-subj'],
24
26
  _props$leadingControl = props.leadingControlColumns,
@@ -36,11 +38,15 @@ var EuiDataGridHeaderRow = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (
36
38
  schema = props.schema,
37
39
  schemaDetectors = props.schemaDetectors,
38
40
  gridStyles = props.gridStyles,
41
+ canDragAndDropColumns = props.canDragAndDropColumns,
39
42
  rest = _objectWithoutProperties(props, _excluded);
40
43
  var styles = useEuiMemoizedStyles(euiDataGridHeaderStyles);
41
44
  var cssStyles = [styles.euiDataGridHeader, styles[gridStyles.header]];
42
45
  var classes = classnames('euiDataGridHeader', className);
43
46
  var dataTestSubj = classnames('dataGridHeader', _dataTestSubj);
47
+ var isLastColumn = useCallback(function (index) {
48
+ return index === visibleColCount - 1;
49
+ }, [visibleColCount]);
44
50
  return ___EmotionJSX("div", _extends({
45
51
  role: "row",
46
52
  ref: ref,
@@ -51,30 +57,39 @@ var EuiDataGridHeaderRow = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (
51
57
  return ___EmotionJSX(EuiDataGridControlHeaderCell, {
52
58
  key: controlColumn.id,
53
59
  index: index,
54
- visibleColCount: visibleColCount,
60
+ isLastColumn: isLastColumn(index),
55
61
  controlColumn: controlColumn
56
62
  });
57
- }), columns.map(function (column, index) {
63
+ }), ___EmotionJSX(ConditionalDroppableColumns, {
64
+ canDragAndDropColumns: !!canDragAndDropColumns,
65
+ columns: columns,
66
+ switchColumnPos: switchColumnPos,
67
+ indexOffset: (_leadingControlColumn = leadingControlColumns === null || leadingControlColumns === void 0 ? void 0 : leadingControlColumns.length) !== null && _leadingControlColumn !== void 0 ? _leadingControlColumn : 0
68
+ }, columns.map(function (column, index) {
69
+ var visibleIndex = index + leadingControlColumns.length;
58
70
  return ___EmotionJSX(EuiDataGridHeaderCell, {
59
71
  key: column.id,
60
- index: index + leadingControlColumns.length,
72
+ index: visibleIndex,
73
+ isLastColumn: isLastColumn(visibleIndex),
61
74
  column: column,
62
75
  columns: columns,
63
76
  columnWidths: columnWidths,
64
77
  defaultColumnWidth: defaultColumnWidth,
65
78
  setColumnWidth: setColumnWidth,
66
- visibleColCount: visibleColCount,
67
79
  setVisibleColumns: setVisibleColumns,
68
80
  switchColumnPos: switchColumnPos,
69
81
  sorting: sorting,
70
82
  schema: schema,
71
- schemaDetectors: schemaDetectors
83
+ schemaDetectors: schemaDetectors,
84
+ canDragAndDropColumns: canDragAndDropColumns,
85
+ gridStyles: gridStyles
72
86
  });
73
- }), trailingControlColumns.map(function (controlColumn, index) {
87
+ })), trailingControlColumns.map(function (controlColumn, index) {
88
+ var visibleIndex = index + leadingControlColumns.length + columns.length;
74
89
  return ___EmotionJSX(EuiDataGridControlHeaderCell, {
75
90
  key: controlColumn.id,
76
- index: index + leadingControlColumns.length + columns.length,
77
- visibleColCount: visibleColCount,
91
+ index: visibleIndex,
92
+ isLastColumn: isLastColumn(visibleIndex),
78
93
  controlColumn: controlColumn
79
94
  });
80
95
  }));
@@ -0,0 +1,301 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _excluded = ["role", "tabIndex"],
3
+ _excluded2 = ["canDragAndDropColumns", "children"],
4
+ _excluded3 = ["canDragAndDropColumns", "children"];
5
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
10
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
11
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], t.indexOf(o) >= 0 || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
12
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (e.indexOf(n) >= 0) continue; t[n] = r[n]; } return t; }
13
+ /*
14
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
15
+ * or more contributor license agreements. Licensed under the Elastic License
16
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
17
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
18
+ * Side Public License, v 1.
19
+ */
20
+
21
+ import React, { memo, useCallback, useContext, useRef } from 'react';
22
+ import PropTypes from "prop-types";
23
+ import { useEuiMemoizedStyles, useGeneratedHtmlId } from '../../../../services';
24
+ import { EuiDragDropContext, EuiDroppable, EuiDraggable } from '../../../drag_and_drop';
25
+ import { EuiPortal } from '../../../portal';
26
+ import { DataGridFocusContext } from '../../utils/focus';
27
+ import { euiDataGridStyles } from '../../data_grid.styles';
28
+ import { euiDataGridDraggableHeaderStyles } from './draggable_columns.styles';
29
+
30
+ /**
31
+ * Parent context + EuiDroppable wrapper
32
+ */
33
+ import { jsx as ___EmotionJSX } from "@emotion/react";
34
+ export var DroppableColumns = /*#__PURE__*/memo(function (_ref) {
35
+ var columns = _ref.columns,
36
+ switchColumnPos = _ref.switchColumnPos,
37
+ indexOffset = _ref.indexOffset,
38
+ children = _ref.children;
39
+ var styles = useEuiMemoizedStyles(euiDataGridDraggableHeaderStyles);
40
+ var droppableId = useGeneratedHtmlId({
41
+ prefix: 'euiDataGridHeaderDroppable'
42
+ });
43
+ var _useContext = useContext(DataGridFocusContext),
44
+ setFocusedCell = _useContext.setFocusedCell;
45
+ var handleOnDragEnd = useCallback(function (_ref2) {
46
+ var source = _ref2.source,
47
+ destination = _ref2.destination;
48
+ if (!source) return;
49
+ if (destination && destination.index !== source.index) {
50
+ var sourceColumn = columns[source.index - indexOffset];
51
+ var destinationColumn = columns[destination.index - indexOffset];
52
+ if (sourceColumn && destinationColumn) {
53
+ switchColumnPos(sourceColumn.id, destinationColumn.id);
54
+ }
55
+ }
56
+ // Force focus the cell to prevent the datagrid body from become unfocusable, including on drag cancel
57
+ setTimeout(function () {
58
+ var cellToFocus = destination ? destination.index : source.index;
59
+ setFocusedCell([cellToFocus, -1], true);
60
+ });
61
+ }, [columns, indexOffset, switchColumnPos, setFocusedCell]);
62
+ return ___EmotionJSX(EuiDragDropContext, {
63
+ onDragEnd: handleOnDragEnd
64
+ }, ___EmotionJSX(EuiDroppable, {
65
+ droppableId: droppableId,
66
+ direction: "horizontal",
67
+ ignoreContainerClipping: true,
68
+ css: styles.euiDataGridHeaderDroppable,
69
+ "data-test-subj": "euiDataGridHeaderDroppable"
70
+ }, children));
71
+ });
72
+ DroppableColumns.propTypes = {
73
+ indexOffset: PropTypes.number.isRequired,
74
+ children: PropTypes.oneOfType([PropTypes.element.isRequired, PropTypes.arrayOf(PropTypes.element.isRequired).isRequired, PropTypes.any.isRequired]).isRequired
75
+ };
76
+ DroppableColumns.displayName = 'DroppableColumns';
77
+
78
+ /**
79
+ * Individual EuiDraggable columns
80
+ */
81
+ export var DraggableColumn = /*#__PURE__*/memo(function (_ref3) {
82
+ var id = _ref3.id,
83
+ index = _ref3.index,
84
+ gridStyles = _ref3.gridStyles,
85
+ columnResizer = _ref3.columnResizer,
86
+ actionsPopoverToggle = _ref3.actionsPopoverToggle,
87
+ children = _ref3.children;
88
+ var dataGridStyles = useEuiMemoizedStyles(euiDataGridStyles);
89
+ var styles = useEuiMemoizedStyles(euiDataGridDraggableHeaderStyles);
90
+ // Manually re-apply background and border overrides, since
91
+ // the droppable zone sets its own and confuses :first-of-type CSS
92
+ var reapplyCellStyles = [styles[gridStyles.header], index !== 0 && styles.noLeadingBorder];
93
+
94
+ // Draggable prevents the cell from receiving focus on click.
95
+ // We manually ensure focus is set on cell mouseDown which
96
+ // also includes setting focus before dragging
97
+ var _useContext2 = useContext(DataGridFocusContext),
98
+ setFocusedCell = _useContext2.setFocusedCell;
99
+ var handleOnMouseDown = useCallback(function (e) {
100
+ var openFocusTrap = document.querySelector('[data-focus-lock-disabled="false"]');
101
+ if (!!openFocusTrap &&
102
+ // If a focus trap is open somewhere on the page
103
+ !openFocusTrap.contains(e.target) &&
104
+ // & the focus trap doesn't belong to this header
105
+ e.target !== actionsPopoverToggle // & we're not closing the actions popover toggle
106
+ ) {
107
+ // Trick the focus trap lib into registering an outside click -
108
+ // the drag/drop lib otherwise otherwise prevents the event 💀
109
+ document.dispatchEvent(new MouseEvent('mousedown'));
110
+ }
111
+ setTimeout(function () {
112
+ setFocusedCell([index, -1], true);
113
+ });
114
+ }, [setFocusedCell, index, actionsPopoverToggle]);
115
+
116
+ // Prevent any other keypresses when dragging
117
+ var isDraggingRef = useRef(false);
118
+ var handleOnKeydown = useCallback(function (e) {
119
+ if (isDraggingRef.current) {
120
+ e.preventDefault();
121
+ e.stopPropagation();
122
+ return false;
123
+ }
124
+ }, []);
125
+
126
+ // UX polish: add a slight animation frame delay to the dragging ref end
127
+ // which prevents re-running the hover animation of column header actions
128
+ var updateDraggingRef = useCallback(function (isDragging) {
129
+ // Only update if the state has changed from before
130
+ if (isDragging !== isDraggingRef.current) {
131
+ if (!isDragging) {
132
+ requestAnimationFrame(function () {
133
+ isDraggingRef.current = false;
134
+ });
135
+ } else {
136
+ isDraggingRef.current = true;
137
+ }
138
+ }
139
+ }, []);
140
+ return ___EmotionJSX("div", {
141
+ css: styles.euiDataGridHeaderCellDraggableWrapper,
142
+ onMouseDown: handleOnMouseDown,
143
+ onKeyDownCapture: handleOnKeydown
144
+ }, columnResizer, ___EmotionJSX(EuiDraggable, {
145
+ draggableId: id,
146
+ className: "euiDataGridHeaderCellDraggable",
147
+ css: styles.euiDataGridHeaderCellDraggable,
148
+ index: index,
149
+ customDragHandle: "custom",
150
+ hasInteractiveChildren: true,
151
+ usePortal: true
152
+ }, function (_ref4, _ref5) {
153
+ var dragHandleProps = _ref4.dragHandleProps;
154
+ var isDragging = _ref5.isDragging,
155
+ mode = _ref5.mode;
156
+ updateDraggingRef(isDragging);
157
+ var _ref6 = dragHandleProps !== null && dragHandleProps !== void 0 ? dragHandleProps : {},
158
+ role = _ref6.role,
159
+ tabIndex = _ref6.tabIndex,
160
+ restDragHandleProps = _objectWithoutProperties(_ref6, _excluded);
161
+ var passedProps = _objectSpread(_objectSpread({}, restDragHandleProps), {}, {
162
+ css: reapplyCellStyles,
163
+ 'data-column-moving': isDraggingRef.current || undefined,
164
+ isDragging: isDragging
165
+ });
166
+
167
+ // since the cloned content is in a portal outside the datagrid
168
+ // we need to re-add styles to the cell as the scoped styles
169
+ // from the wrapper don't apply
170
+ var draggingStyles = [styles.euiDataGridHeaderCellDraggable,
171
+ // ensure height is maintained while dragging
172
+ dataGridStyles.cellPadding[gridStyles.cellPadding], dataGridStyles.fontSize[gridStyles.fontSize], dataGridStyles.borders[gridStyles.border], mode === 'SNAP' && styles.isKeyboardDragging];
173
+ return isDragging ? ___EmotionJSX("div", {
174
+ css: draggingStyles
175
+ }, ___EmotionJSX(DragOverlay, {
176
+ isDragging: true,
177
+ cursor: "grabbing"
178
+ }), children(passedProps)) : children(passedProps);
179
+ }));
180
+ });
181
+ DraggableColumn.propTypes = {
182
+ id: PropTypes.string.isRequired,
183
+ index: PropTypes.number.isRequired,
184
+ gridStyles: PropTypes.shape({
185
+ /**
186
+ * Size of fonts used within the row and column cells
187
+ * @default m
188
+ */
189
+ fontSize: PropTypes.oneOf(["s", "m", "l"]),
190
+ /**
191
+ * Defines the padding with the row and column cells
192
+ * @default m
193
+ */
194
+ cellPadding: PropTypes.oneOf(["s", "m", "l"]),
195
+ /**
196
+ * Border used for the row and column cells
197
+ * @default all
198
+ */
199
+ border: PropTypes.oneOf(["all", "horizontal", "none"]),
200
+ /**
201
+ * If set to true, rows will alternate zebra striping for clarity
202
+ * @default false
203
+ */
204
+ stripes: PropTypes.bool,
205
+ /**
206
+ * Visual style for the column headers. Recommendation is to use the `underline` style in times when #EuiDataGrid `toolbarVisibility` is set to `false`.
207
+ * @default shade
208
+ */
209
+ header: PropTypes.oneOf(["shade", "underline"]),
210
+ /**
211
+ * Visual style for the column footers.
212
+ * @default overline
213
+ */
214
+ footer: PropTypes.oneOf(["shade", "overline", "striped"]),
215
+ /**
216
+ * If set to true, the footer row will be sticky
217
+ * @default true
218
+ */
219
+ stickyFooter: PropTypes.bool,
220
+ /**
221
+ * Will define what visual style to show on row hover
222
+ * @default hover
223
+ */
224
+ rowHover: PropTypes.oneOf(["highlight", "none"]),
225
+ /**
226
+ * Optionally pass custom classes to highlight or customize certain rows
227
+ */
228
+ rowClasses: PropTypes.shape({}),
229
+ /**
230
+ * Optional callback returning the current `gridStyle` config when changes occur from user input (e.g. toolbar display controls).
231
+ * Can be used for, e.g. storing user `gridStyle` in a local storage object.
232
+ */
233
+ onChange: PropTypes.func
234
+ }).isRequired,
235
+ columnResizer: PropTypes.node,
236
+ actionsPopoverToggle: PropTypes.oneOfType([PropTypes.any.isRequired, PropTypes.oneOf([null])]),
237
+ children: PropTypes.func.isRequired
238
+ };
239
+ DraggableColumn.displayName = 'DraggableColumn';
240
+
241
+ /**
242
+ * Components for conditionally rendering drag/drop wrappers
243
+ * Allows us to conditionally call hooks while not instantiating a bunch
244
+ * of extra state/etc., since draggable columns isn't yet(?) a default
245
+ */
246
+
247
+ export var ConditionalDroppableColumns = /*#__PURE__*/memo(function (_ref7) {
248
+ var canDragAndDropColumns = _ref7.canDragAndDropColumns,
249
+ children = _ref7.children,
250
+ rest = _objectWithoutProperties(_ref7, _excluded2);
251
+ return canDragAndDropColumns ? ___EmotionJSX(DroppableColumns, rest, children) : ___EmotionJSX(React.Fragment, null, children);
252
+ });
253
+ ConditionalDroppableColumns.propTypes = {
254
+ canDragAndDropColumns: PropTypes.bool.isRequired
255
+ };
256
+ ConditionalDroppableColumns.displayName = 'ConditionalDroppableColumns';
257
+ export var ConditionalDraggableColumn = /*#__PURE__*/memo(function (_ref8) {
258
+ var canDragAndDropColumns = _ref8.canDragAndDropColumns,
259
+ children = _ref8.children,
260
+ rest = _objectWithoutProperties(_ref8, _excluded3);
261
+ return canDragAndDropColumns ? ___EmotionJSX(DraggableColumn, rest, children) : ___EmotionJSX(React.Fragment, null, children());
262
+ });
263
+ ConditionalDraggableColumn.propTypes = {
264
+ canDragAndDropColumns: PropTypes.bool.isRequired
265
+ };
266
+ ConditionalDraggableColumn.displayName = 'ConditionalDraggableColumn';
267
+
268
+ /**
269
+ * Creates an invisible overlay that prevents hover interactions/transitions
270
+ * on other elements that the dragged element is dragged over, and also maintains
271
+ * the intended drag cursor over any location.
272
+ *
273
+ * TODO: If this is useful elsewhere, consider moving it to `src/services`
274
+ */
275
+ var _ref10 = process.env.NODE_ENV === "production" ? {
276
+ name: "q8wbl-DragOverlay",
277
+ styles: "position:fixed;inset:0;label:DragOverlay;"
278
+ } : {
279
+ name: "q8wbl-DragOverlay",
280
+ styles: "position:fixed;inset:0;label:DragOverlay;",
281
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
282
+ };
283
+ export var DragOverlay = /*#__PURE__*/memo(function (_ref9) {
284
+ var isDragging = _ref9.isDragging,
285
+ cursor = _ref9.cursor,
286
+ _ref9$zIndex = _ref9.zIndex,
287
+ zIndex = _ref9$zIndex === void 0 ? 9999 : _ref9$zIndex;
288
+ return isDragging ? ___EmotionJSX(EuiPortal, null, ___EmotionJSX("div", {
289
+ css: _ref10,
290
+ style: {
291
+ cursor: cursor,
292
+ zIndex: zIndex
293
+ }
294
+ })) : null;
295
+ });
296
+ DragOverlay.propTypes = {
297
+ isDragging: PropTypes.bool,
298
+ cursor: PropTypes.any,
299
+ zIndex: PropTypes.any
300
+ };
301
+ DragOverlay.displayName = 'DragOverlay';
@@ -0,0 +1,38 @@
1
+ var _templateObject;
2
+ function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
3
+ function _EMOTION_STRINGIFIED_CSS_ERROR__() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
4
+ /*
5
+ * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
6
+ * or more contributor license agreements. Licensed under the Elastic License
7
+ * 2.0 and the Server Side Public License, v 1; you may not use this file except
8
+ * in compliance with, at your election, the Elastic License 2.0 or the Server
9
+ * Side Public License, v 1.
10
+ */
11
+
12
+ import { css, keyframes } from '@emotion/react';
13
+ import { euiCanAnimate, logicalCSS } from '../../../../global_styling';
14
+ var _ref = process.env.NODE_ENV === "production" ? {
15
+ name: "pfqu74-euiDataGridHeaderDroppable",
16
+ styles: "display:flex;label:euiDataGridHeaderDroppable;"
17
+ } : {
18
+ name: "pfqu74-euiDataGridHeaderDroppable",
19
+ styles: "display:flex;label:euiDataGridHeaderDroppable;",
20
+ toString: _EMOTION_STRINGIFIED_CSS_ERROR__
21
+ };
22
+ export var euiDataGridDraggableHeaderStyles = function euiDataGridDraggableHeaderStyles(_ref2) {
23
+ var euiTheme = _ref2.euiTheme;
24
+ return {
25
+ euiDataGridHeaderDroppable: _ref,
26
+ // The resizer must be positioned outside the draggable component to ensure both work independently
27
+ euiDataGridHeaderCellDraggableWrapper: /*#__PURE__*/css("position:relative;.euiDataGridColumnResizer::after{", logicalCSS('margin-left', "-".concat(euiTheme.border.width.thick)), ";};label:euiDataGridHeaderCellDraggableWrapper;"),
28
+ // override internal styling from @hello-pangea/dnd to ensure positioning
29
+ euiDataGridHeaderCellDraggable: /*#__PURE__*/css("display:flex;", logicalCSS('height', '100%'), ";;label:euiDataGridHeaderCellDraggable;"),
30
+ // Add more visual affordance to keyboard drags (raises cell slightly to show green droppable bg)
31
+ // Using animation as transition doesn't seem to work (a tale as old as EuiDataGrid...)
32
+ isKeyboardDragging: /*#__PURE__*/css("animation-name:", keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from { transform: translateY(0); }\n to { transform: translateY(-", "); }\n "])), euiTheme.size.s), ";animation-iteration-count:1;animation-fill-mode:forwards;", euiCanAnimate, "{animation-duration:", euiTheme.animation.fast, ";};label:isKeyboardDragging;"),
33
+ // Ensure correct cell background colors on drag
34
+ underline: /*#__PURE__*/css("background-color:", euiTheme.colors.emptyShade, ";;label:underline;"),
35
+ shade: /*#__PURE__*/css("background-color:", euiTheme.colors.lightestShade, ";;label:shade;"),
36
+ noLeadingBorder: /*#__PURE__*/css(logicalCSS('border-left', 'none !important'), ";;label:noLeadingBorder;")
37
+ };
38
+ };
@@ -403,7 +403,8 @@ export var EuiDataGrid = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (pr
403
403
  gridRef: gridRef,
404
404
  gridItemsRendered: gridItemsRendered,
405
405
  wrapperRef: contentRef,
406
- renderCustomGridBody: renderCustomGridBody
406
+ renderCustomGridBody: renderCustomGridBody,
407
+ canDragAndDropColumns: columnVisibility.canDragAndDropColumns
407
408
  }))), showPagination && props['aria-labelledby'] && ___EmotionJSX("p", {
408
409
  id: ariaLabelledById,
409
410
  hidden: true
@@ -118,9 +118,6 @@ var columns = [{
118
118
  "aria-label": "Send email to ".concat(value)
119
119
  }, "Send email");
120
120
  }]
121
- }, {
122
- id: 'location',
123
- displayAsText: 'Location'
124
121
  }, {
125
122
  id: 'account',
126
123
  displayAsText: 'Account',
@@ -155,6 +152,9 @@ var columns = [{
155
152
  "aria-label": "Send money to ".concat(value)
156
153
  }, "Send money");
157
154
  }]
155
+ }, {
156
+ id: 'location',
157
+ displayAsText: 'Location'
158
158
  }, {
159
159
  id: 'date',
160
160
  displayAsText: 'Date',
@@ -235,7 +235,8 @@ export var defaultStorybookArgs = {
235
235
  // setup for easier testing/QA
236
236
  columnVisibility: {
237
237
  visibleColumns: ['name', 'email', 'account', 'location', 'date', 'amount', 'phone', 'version'],
238
- setVisibleColumns: function setVisibleColumns() {}
238
+ setVisibleColumns: function setVisibleColumns() {},
239
+ canDragAndDropColumns: false
239
240
  },
240
241
  inMemory: {
241
242
  level: 'sorting'
@@ -346,7 +347,8 @@ export var StatefulDataGrid = function StatefulDataGrid(props) {
346
347
  return ___EmotionJSX(EuiDataGrid, _extends({}, rest, {
347
348
  columnVisibility: {
348
349
  visibleColumns: visibleColumns,
349
- setVisibleColumns: setVisibleColumns
350
+ setVisibleColumns: setVisibleColumns,
351
+ canDragAndDropColumns: columnVisibility.canDragAndDropColumns
350
352
  },
351
353
  sorting: {
352
354
  columns: sortingColumns,
@@ -855,7 +857,8 @@ EuiDataGridToolbarPropsComponent.propTypes = {
855
857
  /**
856
858
  * A callback for when a column's visibility or order is modified by the user.
857
859
  */
858
- setVisibleColumns: PropTypes.func.isRequired
860
+ setVisibleColumns: PropTypes.func.isRequired,
861
+ /** Enables reordering grid columns on drag and drop via the headers cells */canDragAndDropColumns: PropTypes.bool
859
862
  }).isRequired,
860
863
  /**
861
864
  * An array of custom #EuiDataGridSchemaDetector objects. You can inject custom schemas to the grid to define the classnames applied.
@@ -76,12 +76,10 @@ export var useColumnWidths = function useColumnWidths(_ref) {
76
76
  setColumnWidths(function (prevColumnWidths) {
77
77
  return _objectSpread(_objectSpread({}, prevColumnWidths), {}, _defineProperty({}, columnId, width));
78
78
  });
79
- if (onColumnResize) {
80
- onColumnResize({
81
- columnId: columnId,
82
- width: width
83
- });
84
- }
79
+ onColumnResize === null || onColumnResize === void 0 || onColumnResize({
80
+ columnId: columnId,
81
+ width: width
82
+ });
85
83
  }, [onColumnResize]);
86
84
 
87
85
  // Used by react-window to determine actual column widths
@@ -47,11 +47,11 @@ export var useFocus = function useFocus() {
47
47
  _useState4 = _slicedToArray(_useState3, 2),
48
48
  focusedCell = _useState4[0],
49
49
  _setFocusedCell = _useState4[1];
50
- var setFocusedCell = useCallback(function (nextFocusedCell) {
50
+ var setFocusedCell = useCallback(function (nextFocusedCell, forceUpdate) {
51
51
  _setFocusedCell(function (prevFocusedCell) {
52
52
  // If the x/y coordinates remained the same, don't update. This keeps the focusedCell
53
53
  // reference stable, and allows it to be used in places that need reference equality.
54
- if (nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
54
+ if (!forceUpdate && nextFocusedCell[0] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[0]) && nextFocusedCell[1] === (prevFocusedCell === null || prevFocusedCell === void 0 ? void 0 : prevFocusedCell[1])) {
55
55
  return prevFocusedCell;
56
56
  } else {
57
57
  setIsFocusedCellInView(true); // scrolling.ts ensures focused cells are fully in view