@carbon/ibm-products 1.59.0 → 1.60.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. package/css/index-full-carbon.css +97 -65
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +53 -21
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +2 -2
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +97 -65
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +3 -3
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/Checklist/ChecklistChart.js +2 -2
  14. package/es/components/Datagrid/Datagrid/Datagrid.js +2 -1
  15. package/es/components/Datagrid/Datagrid/DatagridContent.js +15 -7
  16. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +3 -2
  17. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
  18. package/es/components/Datagrid/Datagrid/DatagridRow.js +41 -33
  19. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +13 -1
  20. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +3 -15
  21. package/es/components/Datagrid/Datagrid/DraggableElement.js +32 -135
  22. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +14 -38
  23. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -0
  24. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +128 -40
  25. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +7 -6
  26. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +104 -18
  27. package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +1 -0
  28. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +37 -4
  29. package/es/components/Datagrid/useExpandedRow.js +1 -1
  30. package/es/components/Datagrid/useFiltering.js +4 -1
  31. package/es/components/Datagrid/useNestedRowExpander.js +22 -9
  32. package/es/components/Datagrid/useRowExpander.js +22 -9
  33. package/es/components/Datagrid/utils/DatagridPagination.js +1 -1
  34. package/es/components/Datagrid/utils/getArgTypes.js +12 -0
  35. package/es/components/EmptyStates/EmptyState.js +1 -1
  36. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  37. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  38. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  39. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  40. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  41. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  42. package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -11
  43. package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -11
  44. package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
  45. package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
  46. package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
  47. package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
  48. package/es/components/FilterSummary/FilterSummary.js +9 -3
  49. package/es/components/TagSet/TagSet.js +3 -7
  50. package/es/global/js/hooks/useWindowScroll.js +5 -0
  51. package/lib/components/Checklist/ChecklistChart.js +2 -2
  52. package/lib/components/Datagrid/Datagrid/Datagrid.js +2 -1
  53. package/lib/components/Datagrid/Datagrid/DatagridContent.js +14 -6
  54. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +2 -1
  55. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
  56. package/lib/components/Datagrid/Datagrid/DatagridRow.js +41 -33
  57. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +13 -1
  58. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +3 -15
  59. package/lib/components/Datagrid/Datagrid/DraggableElement.js +34 -140
  60. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +17 -38
  61. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -0
  62. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +128 -47
  63. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +7 -6
  64. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +104 -24
  65. package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -2
  66. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +36 -3
  67. package/lib/components/Datagrid/useExpandedRow.js +1 -1
  68. package/lib/components/Datagrid/useFiltering.js +4 -1
  69. package/lib/components/Datagrid/useNestedRowExpander.js +24 -9
  70. package/lib/components/Datagrid/useRowExpander.js +24 -9
  71. package/lib/components/Datagrid/utils/DatagridPagination.js +1 -1
  72. package/lib/components/Datagrid/utils/getArgTypes.js +12 -0
  73. package/lib/components/EmptyStates/EmptyState.js +1 -1
  74. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  75. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  76. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  77. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  78. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  79. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  80. package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -11
  81. package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -11
  82. package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
  83. package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
  84. package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
  85. package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
  86. package/lib/components/FilterSummary/FilterSummary.js +9 -10
  87. package/lib/components/TagSet/TagSet.js +2 -6
  88. package/lib/global/js/hooks/useWindowScroll.js +6 -0
  89. package/package.json +8 -7
  90. package/scss/components/Datagrid/_datagrid.scss +1 -1
  91. package/scss/components/Datagrid/styles/_datagrid.scss +5 -0
  92. package/scss/components/Datagrid/styles/_draggableElement.scss +44 -20
  93. package/scss/components/Datagrid/styles/_useExpandedRow.scss +10 -0
  94. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +0 -1
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  /**
4
- * Copyright IBM Corp. 2022, 2022
4
+ * Copyright IBM Corp. 2022, 2023
5
5
  *
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -24,7 +24,9 @@ import { useMultipleKeyTracking } from '../../DataSpreadsheet/hooks';
24
24
  import FilterPanel from './addons/Filtering/FilterPanel';
25
25
  import { FilterSummary } from '../../FilterSummary';
26
26
  import { FilterContext } from './addons/Filtering';
27
- import { CLEAR_FILTERS } from './addons/Filtering/constants';
27
+ import { CLEAR_FILTERS, CLEAR_SINGLE_FILTER } from './addons/Filtering/constants';
28
+ import { useSubscribeToEventEmitter } from './addons/Filtering/hooks';
29
+ import { clearSingleFilter } from './addons/Filtering/FilterProvider';
28
30
  var TableContainer = DataTable.TableContainer,
29
31
  Table = DataTable.Table;
30
32
  var blockClass = "".concat(pkg.prefix, "--datagrid");
@@ -62,8 +64,11 @@ export var DatagridContent = function DatagridContent(_ref) {
62
64
  DatagridActions = datagridState.DatagridActions,
63
65
  totalColumnsWidth = datagridState.totalColumnsWidth,
64
66
  gridRef = datagridState.gridRef,
65
- state = datagridState.state;
66
- var rows = DatagridPagination && datagridState.page || datagridState.rows;
67
+ setAllFilters = datagridState.setAllFilters,
68
+ state = datagridState.state,
69
+ page = datagridState.page,
70
+ rows = datagridState.rows;
71
+ var contentRows = DatagridPagination && page || rows;
67
72
  var gridAreaRef = useRef();
68
73
  var multiKeyTrackingRef = useRef();
69
74
  useClickOutside(gridAreaRef, function (target) {
@@ -101,8 +106,8 @@ export var DatagridContent = function DatagridContent(_ref) {
101
106
  return handleGridFocus(inlineEditState, dispatch);
102
107
  } : null,
103
108
  title: title
104
- }), !withVirtualScroll ? /*#__PURE__*/React.createElement(DatagridHead, datagridState) : null, /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
105
- rows: rows
109
+ }), !withVirtualScroll && /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
110
+ rows: contentRows
106
111
  })));
107
112
  };
108
113
  var _useMultipleKeyTracki = useMultipleKeyTracking({
@@ -125,6 +130,9 @@ export var DatagridContent = function DatagridContent(_ref) {
125
130
  gridElement.style.setProperty("--".concat(blockClass, "--grid-header-height"), px((tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.clientHeight) || 0));
126
131
  }
127
132
  }, [withInlineEdit, tableId, totalColumnsWidth, datagridState, gridActive]);
133
+ useSubscribeToEventEmitter(CLEAR_SINGLE_FILTER, function (id) {
134
+ return clearSingleFilter(id, setAllFilters, state);
135
+ });
128
136
  var renderFilterSummary = function renderFilterSummary() {
129
137
  return state.filters.length > 0 && /*#__PURE__*/React.createElement(FilterSummary, {
130
138
  className: "".concat(blockClass, "__filter-summary"),
@@ -153,7 +161,7 @@ export var DatagridContent = function DatagridContent(_ref) {
153
161
  }, renderTable()) : withVirtualScroll ? /*#__PURE__*/React.createElement("div", {
154
162
  className: "".concat(blockClass, "__virtualScrollContainer"),
155
163
  ref: gridRef
156
- }, renderTable()) : renderTable()))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsTearsheet && /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, {
164
+ }, renderTable()) : renderTable()))), (contentRows === null || contentRows === void 0 ? void 0 : contentRows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsTearsheet && /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, {
157
165
  instance: datagridState
158
166
  }));
159
167
  };
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime/helpers/extends";
9
9
  import React from 'react';
10
10
  import { pkg } from '../../../settings';
11
11
  import { DataTable } from 'carbon-components-react';
12
- import { NoDataEmptyState, ErrorEmptyState, NotFoundEmptyState } from '../../EmptyStates';
12
+ import { NoDataEmptyState, ErrorEmptyState, NotFoundEmptyState, EmptyState } from '../../EmptyStates';
13
13
  var blockClass = "".concat(pkg.prefix, "--datagrid");
14
14
  var TableBody = DataTable.TableBody,
15
15
  TableRow = DataTable.TableRow,
@@ -33,12 +33,13 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
33
33
  action: emptyStateAction,
34
34
  link: emptyStateLink
35
35
  };
36
+ var validEmptyStates = ['error', 'noData', 'notFound'];
36
37
  return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
37
38
  role: false
38
39
  }), {
39
40
  className: "".concat(blockClass, "__empty-state-body")
40
41
  }), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
41
42
  colSpan: headers.length
42
- }, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/React.createElement(NotFoundEmptyState, emptyStateProps))));
43
+ }, validEmptyStates.includes(emptyStateType) ? /*#__PURE__*/React.createElement(React.Fragment, null, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/React.createElement(NotFoundEmptyState, emptyStateProps)) : /*#__PURE__*/React.createElement(EmptyState, emptyStateProps))));
43
44
  };
44
45
  export default DatagridEmptyBody;
@@ -1,9 +1,8 @@
1
- /*
2
- * Licensed Materials - Property of IBM
3
- * 5724-Q36
4
- * (c) Copyright IBM Corp. 2020
5
- * US Government Users Restricted Rights - Use, duplication or disclosure
6
- * restricted by GSA ADP Schedule Contract with IBM Corp.
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
7
6
  */
8
7
 
9
8
  import React from 'react';
@@ -11,17 +10,31 @@ import { pkg } from '../../../settings';
11
10
  var blockClass = "".concat(pkg.prefix, "--datagrid");
12
11
 
13
12
  // eslint-disable-next-line react/prop-types
14
- var DatagridExpandedRow = function DatagridExpandedRow(PreviousRowRenderer, ExpandedRowContentComponent) {
13
+ var DatagridExpandedRow = function DatagridExpandedRow(ExpandedRowContentComponent) {
15
14
  return function (datagridState) {
16
15
  var row = datagridState.row;
17
16
  var _ref = row || {},
18
17
  expandedContentHeight = _ref.expandedContentHeight;
19
- if (!row.isExpanded) {
20
- return PreviousRowRenderer(datagridState);
21
- }
22
- return /*#__PURE__*/React.createElement("div", {
23
- className: "".concat(blockClass, "__expanded-row")
24
- }, PreviousRowRenderer(datagridState), /*#__PURE__*/React.createElement("div", {
18
+ var toggleParentHoverClass = function toggleParentHoverClass(event, eventType) {
19
+ var _event$target, _event$target$parentN;
20
+ if (event !== null && event !== void 0 && (_event$target = event.target) !== null && _event$target !== void 0 && (_event$target$parentN = _event$target.parentNode) !== null && _event$target$parentN !== void 0 && _event$target$parentN.previousElementSibling) {
21
+ var parentNode = event.target.parentNode.previousElementSibling;
22
+ if (eventType === 'enter') {
23
+ parentNode.classList.add("".concat(blockClass, "__expandable-row--hover"));
24
+ } else {
25
+ parentNode.classList.remove("".concat(blockClass, "__expandable-row--hover"));
26
+ }
27
+ }
28
+ };
29
+ return /*#__PURE__*/React.createElement("tr", {
30
+ className: "".concat(blockClass, "__expanded-row"),
31
+ onMouseEnter: function onMouseEnter(event) {
32
+ return toggleParentHoverClass(event, 'enter');
33
+ },
34
+ onMouseLeave: function onMouseLeave(event) {
35
+ return toggleParentHoverClass(event);
36
+ }
37
+ }, /*#__PURE__*/React.createElement("div", {
25
38
  className: "".concat(blockClass, "__expanded-row-content"),
26
39
  style: {
27
40
  height: expandedContentHeight ? expandedContentHeight : null
@@ -2,6 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var _excluded = ["children"];
5
+ 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; }
6
+ 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) { _defineProperty(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; }
5
7
  /*
6
8
  * Licensed Materials - Property of IBM
7
9
  * 5724-Q36
@@ -32,7 +34,8 @@ var DatagridRow = function DatagridRow(datagridState) {
32
34
  var _cx;
33
35
  var row = datagridState.row,
34
36
  rowSize = datagridState.rowSize,
35
- withNestedRows = datagridState.withNestedRows;
37
+ withNestedRows = datagridState.withNestedRows,
38
+ prepareRow = datagridState.prepareRow;
36
39
  var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
37
40
  var isExpanded = _ref.isExpanded,
38
41
  subRows = _ref.subRows;
@@ -47,6 +50,9 @@ var DatagridRow = function DatagridRow(datagridState) {
47
50
  };
48
51
  var hoverHandler = function hoverHandler(event) {
49
52
  var _hoverRow$style, _hoverRow$style2, _hoverRow$style3;
53
+ if (!withNestedRows) {
54
+ return;
55
+ }
50
56
  var subRowCount = getVisibleNestedRowCount(row);
51
57
  var totalNestedRowIndicatorHeight = px(subRowCount * rowHeights[rowSize]);
52
58
  var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
@@ -63,48 +69,50 @@ var DatagridRow = function DatagridRow(datagridState) {
63
69
  el.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
64
70
  });
65
71
  };
66
- return /*#__PURE__*/React.createElement(TableRow, _extends({
67
- className: cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx))
72
+ var renderExpandedRow = function renderExpandedRow() {
73
+ if (row.isExpanded) {
74
+ var _row$RowExpansionRend;
75
+ prepareRow(row);
76
+ return row === null || row === void 0 ? void 0 : (_row$RowExpansionRend = row.RowExpansionRenderer) === null || _row$RowExpansionRend === void 0 ? void 0 : _row$RowExpansionRend.call(row, _objectSpread(_objectSpread({}, datagridState), {}, {
77
+ row: row
78
+ }));
79
+ }
80
+ return null;
81
+ };
82
+ var handleMouseLeave = function handleMouseLeave(event) {
83
+ var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
84
+ hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
85
+ };
86
+ var handleOnKeyUp = function handleOnKeyUp(event) {
87
+ if (!withNestedRows) {
88
+ return;
89
+ }
90
+ if (event.key === 'Enter' || event.key === 'Space') {
91
+ focusRemover();
92
+ hoverHandler(event);
93
+ }
94
+ };
95
+ var rowClassNames = cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx));
96
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableRow, _extends({
97
+ className: rowClassNames
68
98
  }, row.getRowProps({
69
99
  role: false
70
100
  }), {
71
101
  key: row.id,
72
- onMouseEnter: function onMouseEnter(event) {
73
- if (!withNestedRows) {
74
- return;
75
- }
76
- hoverHandler(event);
77
- },
78
- onMouseLeave: function onMouseLeave(event) {
79
- var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
80
- hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
81
- },
82
- onFocus: function onFocus(event) {
83
- if (!withNestedRows) {
84
- return;
85
- }
86
- hoverHandler(event);
87
- },
88
- onBlur: function onBlur() {
89
- focusRemover();
90
- },
91
- onKeyUp: function onKeyUp(event) {
92
- if (!withNestedRows) {
93
- return;
94
- }
95
- if (event.key === 'Enter' || event.key === 'Space') {
96
- focusRemover();
97
- hoverHandler(event);
98
- }
99
- }
102
+ onMouseEnter: hoverHandler,
103
+ onMouseLeave: handleMouseLeave,
104
+ onFocus: hoverHandler,
105
+ onBlur: focusRemover,
106
+ onKeyUp: handleOnKeyUp
100
107
  }), row.cells.map(function (cell, index) {
108
+ var _cell$column;
101
109
  var cellProps = cell.getCellProps({
102
110
  role: false
103
111
  });
104
112
  var children = cellProps.children,
105
113
  restProps = _objectWithoutProperties(cellProps, _excluded);
106
114
  var content = children || /*#__PURE__*/React.createElement(React.Fragment, null, !row.isSkeleton && cell.render('Cell'), row.isSkeleton && /*#__PURE__*/React.createElement(SkeletonText, null));
107
- if (cell && cell.column && cell.column.id === selectionColumnId) {
115
+ if ((cell === null || cell === void 0 ? void 0 : (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : _cell$column.id) === selectionColumnId) {
108
116
  // directly render component without the wrapping TableCell
109
117
  return cell.render('Cell', {
110
118
  key: cell.column.id
@@ -115,6 +123,6 @@ var DatagridRow = function DatagridRow(datagridState) {
115
123
  }, restProps, {
116
124
  key: cell.column.id
117
125
  }), content);
118
- }));
126
+ })), renderExpandedRow());
119
127
  };
120
128
  export default DatagridRow;
@@ -50,11 +50,23 @@ var SelectAll = function SelectAll(datagridState) {
50
50
  var _getProps = getProps(),
51
51
  onChange = _getProps.onChange,
52
52
  selectProps = _objectWithoutProperties(_getProps, _excluded);
53
+ var _ref = selectProps || {},
54
+ indeterminate = _ref.indeterminate;
55
+ var handleSelectAllChange = function handleSelectAllChange(event) {
56
+ if (indeterminate) {
57
+ return onChange === null || onChange === void 0 ? void 0 : onChange({
58
+ target: {
59
+ checked: false
60
+ }
61
+ });
62
+ }
63
+ return onChange === null || onChange === void 0 ? void 0 : onChange(event);
64
+ };
53
65
  return /*#__PURE__*/React.createElement("div", {
54
66
  className: cx("".concat(blockClass, "__head-select-all"), "".concat(blockClass, "__checkbox-cell"), _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft && windowSize > 671))
55
67
  }, /*#__PURE__*/React.createElement(TableSelectAll, _extends({}, selectProps, {
56
68
  name: "".concat(tableId, "-select-all-checkbox-name"),
57
- onSelect: onChange,
69
+ onSelect: handleSelectAllChange,
58
70
  disabled: isFetching || selectProps.disabled,
59
71
  id: "".concat(tableId, "-select-all-checkbox-id")
60
72
  })));
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  /**
4
- * Copyright IBM Corp. 2022, 2022
4
+ * Copyright IBM Corp. 2022, 2023
5
5
  *
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -70,20 +70,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
70
70
  menuOptionsClass: "".concat(blockClass, "__button-menu-options"),
71
71
  flipped: true
72
72
  }, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
73
- if (index < 2) {
74
- if (displayAllInMenu) {
75
- return /*#__PURE__*/React.createElement(ButtonMenuItem, {
76
- key: "".concat(batchAction.label, "-").concat(index),
77
- itemText: batchAction.label,
78
- onClick: function onClick() {
79
- batchAction.onClick();
80
- if (batchAction.type === 'select_all') {
81
- toggleAllRowsSelected(true);
82
- }
83
- }
84
- });
85
- }
86
- return null;
73
+ if (index < 2 && !displayAllInMenu) {
74
+ return;
87
75
  }
88
76
  return /*#__PURE__*/React.createElement(ButtonMenuItem, {
89
77
  key: "".concat(batchAction.label, "-").concat(index),
@@ -1,5 +1,5 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  // @flow
4
4
  /*
5
5
  * Licensed Materials - Property of IBM
@@ -8,166 +8,63 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
8
8
  * US Government Users Restricted Rights - Use, duplication or disclosure
9
9
  * restricted by GSA ADP Schedule Contract with IBM Corp.
10
10
  */
11
- import * as React from 'react';
11
+ import React from 'react';
12
12
  import PropTypes from 'prop-types';
13
13
  import { Draggable16, Locked16 } from '@carbon/icons-react';
14
- import { useDrag, useDrop } from 'react-dnd';
15
14
  import cx from 'classnames';
16
15
  import { pkg } from '../../../settings';
17
- var useEffect = React.useEffect,
18
- useRef = React.useRef,
19
- useState = React.useState;
16
+ import { CSS } from '@dnd-kit/utilities';
17
+ import { useSortable } from '@dnd-kit/sortable';
20
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
- var DRAG_TYPE = "".concat(blockClass, "__shared-ui-draggable-element");
22
19
  var DraggableElement = function DraggableElement(_ref) {
23
20
  var _cx;
24
21
  var id = _ref.id,
25
- index = _ref.index,
26
- listData = _ref.listData,
27
22
  children = _ref.children,
28
- type = _ref.type,
23
+ classList = _ref.classList,
29
24
  disabled = _ref.disabled,
30
25
  ariaLabel = _ref.ariaLabel,
31
- onGrab = _ref.onGrab,
32
- onArrowKeyDown = _ref.onArrowKeyDown,
33
- isFocused = _ref.isFocused,
34
26
  isSticky = _ref.isSticky,
35
- moveElement = _ref.moveElement,
36
- selected = _ref.selected,
37
- _ref$positionLabel = _ref.positionLabel,
38
- positionLabel = _ref$positionLabel === void 0 ? 'Current position {index} of {total}' : _ref$positionLabel,
39
- _ref$grabbedLabel = _ref.grabbedLabel,
40
- grabbedLabel = _ref$grabbedLabel === void 0 ? '{itemName} grabbed.' : _ref$grabbedLabel,
41
- _ref$droppedLabel = _ref.droppedLabel,
42
- droppedLabel = _ref$droppedLabel === void 0 ? '{itemName} dropped.' : _ref$droppedLabel;
43
- var ref = useRef();
44
- var _useDrop = useDrop({
45
- accept: DRAG_TYPE + type,
46
- collect: function collect(monitor) {
47
- return {
48
- isOver: !!monitor.isOver()
49
- };
50
- },
51
- drop: function drop(item) {
52
- moveElement(item.index, index);
53
- },
54
- canDrop: function canDrop() {
55
- return !disabled;
56
- },
57
- hover: function hover(item) {
58
- var dragIndex = item.index;
59
- var hoverIndex = index;
60
- // Don't replace items with themselves
61
- if (dragIndex === hoverIndex || disabled) {
62
- return;
63
- }
64
- moveElement(dragIndex, hoverIndex);
65
- // Time to actually perform the action
66
- // Note: we're mutating the monitor item here!
67
- // Generally it's better to avoid mutations,
68
- // but it's good here for the sake of performance
69
- // to avoid expensive index searches.
70
- // eslint-disable-next-line no-param-reassign
71
- item.index = hoverIndex;
72
- }
27
+ selected = _ref.selected;
28
+ var _useSortable = useSortable({
29
+ id: id
73
30
  }),
74
- _useDrop2 = _slicedToArray(_useDrop, 2),
75
- isOver = _useDrop2[0].isOver,
76
- drop = _useDrop2[1];
77
- var _useDrag = useDrag({
78
- type: DRAG_TYPE + type,
79
- item: {
80
- id: id,
81
- index: index
82
- },
83
- canDrag: function canDrag() {
84
- return !disabled;
85
- },
86
- collect: function collect(monitor) {
87
- return {
88
- isDragging: monitor.isDragging()
89
- };
90
- }
91
- }),
92
- _useDrag2 = _slicedToArray(_useDrag, 3),
93
- isDragging = _useDrag2[0].isDragging,
94
- drag = _useDrag2[1],
95
- preview = _useDrag2[2];
96
- useEffect(function () {
97
- if (isFocused && ref && ref.current) {
98
- ref.current.focus();
99
- }
100
- }, [isFocused]);
101
- var _useState = useState(false),
102
- _useState2 = _slicedToArray(_useState, 2),
103
- isGrabbed = _useState2[0],
104
- setIsGrabbed = _useState2[1];
105
- var _useState3 = useState(isFocused),
106
- _useState4 = _slicedToArray(_useState3, 2),
107
- isFocusedOnItem = _useState4[0],
108
- setIsFocusedOnItem = _useState4[1];
109
- drop(ref);
31
+ attributes = _useSortable.attributes,
32
+ isDragging = _useSortable.isDragging,
33
+ listeners = _useSortable.listeners,
34
+ setNodeRef = _useSortable.setNodeRef,
35
+ transform = _useSortable.transform,
36
+ transition = _useSortable.transition;
110
37
  var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
111
38
  className: cx({
112
39
  disabled: disabled
113
40
  }, "".concat(blockClass, "__draggable-handleStyle"))
114
41
  }, isSticky ? /*#__PURE__*/React.createElement(Locked16, null) : /*#__PURE__*/React.createElement(Draggable16, null)), children);
115
- return /*#__PURE__*/React.createElement("li", {
116
- className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-isOver"), isOver && !disabled), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-grabbed"), isGrabbed), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-selected"), selected), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder--sticky"), isSticky), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder"), !selected), _cx)),
117
- ref: ref,
118
- "aria-selected": isFocused,
119
- role: "option",
120
- tabIndex: isFocused ? 0 : -1,
121
- onKeyPress: function onKeyPress(e) {
122
- if (e.key === ' ' && e.target === e.currentTarget && !disabled) {
123
- var positionText = positionLabel.replace('{index}', index + 1).replace('{total}', listData.length);
124
- var grabAriaText = (isGrabbed ? droppedLabel : grabbedLabel).replace('{itemName}', ariaLabel);
125
- onGrab(grabAriaText + positionText);
126
- setIsGrabbed(!isGrabbed);
127
- e.preventDefault();
128
- }
129
- },
130
- onKeyDown: function onKeyDown(e) {
131
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
132
- onArrowKeyDown(e, isGrabbed, index);
133
- }
134
- },
135
- onBlur: function onBlur(e) {
136
- // handle when focus move to inner elements
137
- setIsFocusedOnItem(e.currentTarget === e.target);
138
- },
139
- onFocus: function onFocus(e) {
140
- // handle when focus move to li element
141
- setIsFocusedOnItem(e.currentTarget === e.target);
142
- }
143
- }, /*#__PURE__*/React.createElement("span", {
42
+ var style = {
43
+ transform: CSS.Transform.toString(transform),
44
+ transition: transition
45
+ };
46
+ return /*#__PURE__*/React.createElement("li", _extends({
47
+ className: cx(classList, "".concat(blockClass, "__draggable-handleHolder"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder--selected"), selected), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder--sticky"), isSticky), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder--dragging"), isDragging), _cx)),
48
+ id: id,
49
+ ref: setNodeRef,
50
+ style: style
51
+ }, attributes, listeners, {
52
+ disabled: disabled,
53
+ "aria-selected": selected,
54
+ role: "option"
55
+ }), /*#__PURE__*/React.createElement("span", {
144
56
  className: "".concat(blockClass, "__shared-ui--assistive-text")
145
- }, ariaLabel), isDragging && !isOver ? /*#__PURE__*/React.createElement("div", {
146
- ref: preview,
147
- className: "".concat(blockClass, "__draggable-handleHolder-droppable ").concat(blockClass, "__draggable-handleHolder-droppable--origin")
148
- }, content) : /*#__PURE__*/React.createElement("div", {
149
- ref: drag,
150
- "aria-hidden": isFocused && isFocusedOnItem // if focus on li, hide the children from aria
151
- ,
57
+ }, ariaLabel), /*#__PURE__*/React.createElement("div", {
152
58
  className: cx(_defineProperty({}, "".concat(blockClass, "__draggable-handleStyle"), !disabled), ["".concat(blockClass, "__draggable-handleHolder-droppable")])
153
- }, (!isOver || disabled) && content));
59
+ }, content));
154
60
  };
155
61
  DraggableElement.propTypes = {
156
62
  ariaLabel: PropTypes.string.isRequired,
157
63
  children: PropTypes.element.isRequired,
64
+ classList: PropTypes.string,
158
65
  disabled: PropTypes.bool,
159
- droppedLabel: PropTypes.string,
160
- grabbedLabel: PropTypes.string,
161
66
  id: PropTypes.string.isRequired,
162
- index: PropTypes.number.isRequired,
163
- isFocused: PropTypes.bool.isRequired,
164
67
  isSticky: PropTypes.bool,
165
- listData: PropTypes.array.isRequired,
166
- moveElement: PropTypes.func.isRequired,
167
- onArrowKeyDown: PropTypes.func.isRequired,
168
- onGrab: PropTypes.func.isRequired,
169
- positionLabel: PropTypes.string,
170
- selected: PropTypes.bool,
171
- type: PropTypes.string.isRequired
68
+ selected: PropTypes.bool
172
69
  };
173
70
  export default DraggableElement;
@@ -1,32 +1,21 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  /**
4
- * Copyright IBM Corp. 2022, 2022
4
+ * Copyright IBM Corp. 2022, 2023
5
5
  *
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
9
 
10
- import React from 'react';
10
+ import React, { useRef } from 'react';
11
11
  import PropTypes from 'prop-types';
12
- import { DndProvider } from 'react-dnd';
13
- import { HTML5Backend } from 'react-dnd-html5-backend';
14
12
  import { Checkbox } from 'carbon-components-react';
15
13
  import update from 'immutability-helper';
16
14
  import { pkg } from '../../../../../settings';
17
15
  import classNames from 'classnames';
18
16
  import { DraggableItemsList } from './DraggableItemsList';
17
+ import uuidv4 from '../../../../../global/js/utils/uuidv4';
19
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
20
- var getNextIndex = function getNextIndex(array, currentIndex, key) {
21
- var newIndex = -1;
22
- if (key === 'ArrowUp') {
23
- newIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : array.length - 1;
24
- }
25
- if (key === 'ArrowDown') {
26
- newIndex = currentIndex + 1 < array.length ? currentIndex + 1 : 0;
27
- }
28
- return newIndex;
29
- };
30
19
  var Columns = function Columns(_ref) {
31
20
  var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
32
21
  filterString = _ref.filterString,
@@ -36,36 +25,26 @@ var Columns = function Columns(_ref) {
36
25
  assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
37
26
  assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
38
27
  selectAllLabel = _ref.selectAllLabel;
28
+ var listId = useRef(uuidv4()); // keep id between renders
29
+ var listRef = useRef(null);
39
30
  var _React$useState = React.useState(''),
40
31
  _React$useState2 = _slicedToArray(_React$useState, 2),
41
32
  ariaRegionText = _React$useState2[0],
42
33
  setAriaRegionText = _React$useState2[1];
43
- var _React$useState3 = React.useState(-1),
44
- _React$useState4 = _slicedToArray(_React$useState3, 2),
45
- focusIndex = _React$useState4[0],
46
- setFocusIndex = _React$useState4[1];
47
- var moveElement = React.useCallback(function (dragIndex, hoverIndex) {
48
- var dragCard = columns[dragIndex];
34
+ // after a drag/drop action set the columns
35
+ var moveElement = React.useCallback(function (from, to) {
36
+ var fromCol = columns[from];
49
37
  setColumnsObject(update(columns, {
50
- $splice: [[dragIndex, 1], [hoverIndex, 0, dragCard]]
38
+ $splice: [[from, 1], [to, 0, fromCol]]
51
39
  }));
52
40
  }, [columns, setColumnsObject]);
53
41
  return /*#__PURE__*/React.createElement("div", {
54
- className: "".concat(blockClass, "__customize-columns-column-list")
55
- }, /*#__PURE__*/React.createElement(DndProvider, {
56
- backend: HTML5Backend
42
+ className: "".concat(blockClass, "__customize-columns-column-list"),
43
+ ref: listRef
57
44
  }, /*#__PURE__*/React.createElement("ol", {
58
45
  className: "".concat(blockClass, "__customize-columns-column-list--focus"),
59
46
  role: "listbox",
60
47
  "aria-describedby": "".concat(blockClass, "__customize-columns--instructions"),
61
- onKeyDown: function onKeyDown(e) {
62
- var nextIndex = getNextIndex(columns, focusIndex, e.key);
63
- if (nextIndex >= 0) {
64
- setFocusIndex(nextIndex);
65
- e.preventDefault();
66
- e.stopPropagation();
67
- }
68
- },
69
48
  tabIndex: 0
70
49
  }, /*#__PURE__*/React.createElement("span", {
71
50
  "aria-live": "assertive",
@@ -87,16 +66,13 @@ var Columns = function Columns(_ref) {
87
66
  id: "".concat(blockClass, "__customization-column-select-all"),
88
67
  labelText: selectAllLabel
89
68
  })), /*#__PURE__*/React.createElement(DraggableItemsList, {
69
+ id: listId.current,
90
70
  columns: columns,
91
71
  filterString: filterString,
92
- focusIndex: focusIndex,
93
- getNextIndex: getNextIndex,
94
72
  moveElement: moveElement,
95
- onSelectColumn: onSelectColumn,
96
73
  setAriaRegionText: setAriaRegionText,
97
- setColumnsObject: setColumnsObject,
98
- setFocusIndex: setFocusIndex
99
- }))));
74
+ onSelectColumn: onSelectColumn
75
+ })));
100
76
  };
101
77
  Columns.propTypes = {
102
78
  assistiveTextDisabledInstructionsLabel: PropTypes.string,
@@ -75,6 +75,7 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
75
75
  isDirty = _useState10[0],
76
76
  setIsDirty = _useState10[1];
77
77
  var onRequestClose = function onRequestClose() {
78
+ setColumnObjects(columnDefinitions);
78
79
  setIsTearsheetOpen(false);
79
80
  };
80
81
  var onRequestSubmit = function onRequestSubmit() {