@carbon/ibm-products 2.15.2 → 2.17.0-alpha.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. package/css/config-dev.css +3 -0
  2. package/css/config-dev.css.map +1 -0
  3. package/css/index-full-carbon.css +195 -1
  4. package/css/index-full-carbon.css.map +1 -1
  5. package/css/index-full-carbon.min.css +1 -1
  6. package/css/index-full-carbon.min.css.map +1 -1
  7. package/css/index-without-carbon-released-only.css +1852 -38
  8. package/css/index-without-carbon-released-only.css.map +1 -1
  9. package/css/index-without-carbon-released-only.min.css +1 -1
  10. package/css/index-without-carbon-released-only.min.css.map +1 -1
  11. package/css/index-without-carbon.css +195 -1
  12. package/css/index-without-carbon.css.map +1 -1
  13. package/css/index-without-carbon.min.css +1 -1
  14. package/css/index-without-carbon.min.css.map +1 -1
  15. package/css/index.css +5 -1
  16. package/css/index.css.map +1 -1
  17. package/css/index.min.css +1 -1
  18. package/css/index.min.css.map +1 -1
  19. package/es/components/Datagrid/Datagrid/DatagridContent.js +12 -9
  20. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -3
  21. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +36 -22
  22. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -11
  23. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +7 -3
  24. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +24 -13
  25. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +2 -2
  26. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +50 -14
  27. package/es/components/Datagrid/Datagrid.docs-page.js +4 -4
  28. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
  29. package/es/components/Datagrid/useActionsColumn.js +1 -4
  30. package/es/components/Datagrid/useDatagrid.js +5 -1
  31. package/es/components/Datagrid/useFlexResize.js +19 -9
  32. package/es/components/Datagrid/useInfiniteScroll.js +1 -5
  33. package/es/components/Datagrid/useOnRowClick.js +6 -7
  34. package/es/components/Datagrid/useSelectRows.js +8 -5
  35. package/es/components/Datagrid/useSortableColumns.js +5 -7
  36. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +2 -1
  37. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +2 -1
  38. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +2 -1
  39. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +2 -1
  40. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +2 -1
  41. package/es/components/EmptyStates/assets/ErrorIllustration.js +5 -3
  42. package/es/components/EmptyStates/assets/NoDataIllustration.js +5 -3
  43. package/es/components/EmptyStates/assets/NoTagsIllustration.js +5 -3
  44. package/es/components/EmptyStates/assets/NotFoundIllustration.js +5 -3
  45. package/es/components/EmptyStates/assets/NotificationsIllustration.js +5 -3
  46. package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +5 -3
  47. package/es/components/InlineTip/InlineTip.docs-page.js +13 -0
  48. package/es/components/InlineTip/InlineTip.js +217 -0
  49. package/es/components/InlineTip/InlineTipButton.js +53 -0
  50. package/es/components/InlineTip/InlineTipLink.js +57 -0
  51. package/es/components/InlineTip/index.js +10 -0
  52. package/es/components/InlineTip/utils.js +36 -0
  53. package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.docs-page.js +11 -0
  54. package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +140 -0
  55. package/es/components/SteppedAnimatedMedia/assets/index.js +4 -0
  56. package/es/components/SteppedAnimatedMedia/index.js +8 -0
  57. package/es/global/js/package-settings.js +3 -4
  58. package/lib/components/Datagrid/Datagrid/DatagridContent.js +12 -9
  59. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -3
  60. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +41 -29
  61. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +11 -11
  62. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +7 -3
  63. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +23 -12
  64. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +2 -2
  65. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +51 -15
  66. package/lib/components/Datagrid/Datagrid.docs-page.js +4 -4
  67. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
  68. package/lib/components/Datagrid/useActionsColumn.js +1 -7
  69. package/lib/components/Datagrid/useDatagrid.js +5 -1
  70. package/lib/components/Datagrid/useFlexResize.js +19 -9
  71. package/lib/components/Datagrid/useInfiniteScroll.js +0 -4
  72. package/lib/components/Datagrid/useOnRowClick.js +6 -7
  73. package/lib/components/Datagrid/useSelectRows.js +8 -5
  74. package/lib/components/Datagrid/useSortableColumns.js +5 -7
  75. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +2 -1
  76. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +2 -1
  77. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +2 -1
  78. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +2 -1
  79. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +2 -1
  80. package/lib/components/EmptyStates/assets/ErrorIllustration.js +5 -3
  81. package/lib/components/EmptyStates/assets/NoDataIllustration.js +5 -3
  82. package/lib/components/EmptyStates/assets/NoTagsIllustration.js +5 -3
  83. package/lib/components/EmptyStates/assets/NotFoundIllustration.js +5 -3
  84. package/lib/components/EmptyStates/assets/NotificationsIllustration.js +5 -3
  85. package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +5 -3
  86. package/lib/components/InlineTip/InlineTip.docs-page.js +23 -0
  87. package/lib/components/InlineTip/InlineTip.js +224 -0
  88. package/lib/components/InlineTip/InlineTipButton.js +57 -0
  89. package/lib/components/InlineTip/InlineTipLink.js +61 -0
  90. package/lib/components/InlineTip/index.js +26 -0
  91. package/lib/components/InlineTip/utils.js +43 -0
  92. package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.docs-page.js +21 -0
  93. package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +148 -0
  94. package/lib/components/SteppedAnimatedMedia/assets/index.js +9 -0
  95. package/lib/components/SteppedAnimatedMedia/index.js +12 -0
  96. package/lib/global/js/package-settings.js +3 -4
  97. package/package.json +6 -7
  98. package/scss/components/Datagrid/styles/_datagrid.scss +5 -0
  99. package/scss/components/{TooltipTrigger/_storybook-styles.scss → InlineTip/_index.scss} +2 -0
  100. package/scss/components/InlineTip/_inline-tip.scss +229 -0
  101. package/scss/components/SidePanel/_side-panel.scss +1 -4
  102. package/scss/components/_index-released-only-with-carbon.scss +1 -0
  103. package/scss/components/_index-released-only.scss +1 -0
  104. package/scss/components/_index.scss +1 -0
  105. package/scss/config-dev.scss +3 -0
  106. package/scss/components/APIKeyModal/_storybook-styles.scss +0 -35
  107. package/scss/components/AboutModal/_storybook-styles.scss +0 -29
  108. package/scss/components/ActionBar/_storybook-styles.scss +0 -8
  109. package/scss/components/ActionSet/_storybook-styles.scss +0 -36
  110. package/scss/components/AddSelect/_storybook-styles.scss +0 -6
  111. package/scss/components/BreadcrumbWithOverflow/_storybook-styles.scss +0 -8
  112. package/scss/components/ButtonMenu/_storybook-styles.scss +0 -6
  113. package/scss/components/ButtonSetWithOverflow/_storybook-styles.scss +0 -8
  114. package/scss/components/Card/_storybook-styles.scss +0 -12
  115. package/scss/components/Cascade/_storybook-styles.scss +0 -34
  116. package/scss/components/Checklist/_storybook-styles.scss +0 -13
  117. package/scss/components/CreateFullPage/_storybook-styles.scss +0 -67
  118. package/scss/components/CreateModal/_storybook-styles.scss +0 -54
  119. package/scss/components/CreateSidePanel/_storybook-styles.scss +0 -32
  120. package/scss/components/CreateTearsheet/_storybook-styles.scss +0 -56
  121. package/scss/components/CreateTearsheetNarrow/_storybook-styles.scss +0 -27
  122. package/scss/components/DataSpreadsheet/_storybook-styles.scss +0 -17
  123. package/scss/components/Datagrid/_storybook-styles.scss +0 -157
  124. package/scss/components/EditFullPage/_storybook-styles.scss +0 -10
  125. package/scss/components/EditInPlace/_storybook-styles.scss +0 -15
  126. package/scss/components/EditSidePanel/_storybook-styles.scss +0 -32
  127. package/scss/components/EditTearsheet/_storybook-styles.scss +0 -59
  128. package/scss/components/EditTearsheetNarrow/_storybook-styles.scss +0 -10
  129. package/scss/components/EditUpdateCards/_storybook-styles.scss +0 -55
  130. package/scss/components/EmptyStates/_storybook-styles.scss +0 -6
  131. package/scss/components/ExampleComponent/_storybook-styles.scss +0 -6
  132. package/scss/components/ExportModal/_storybook-styles.scss +0 -6
  133. package/scss/components/ExpressiveCard/_storybook-styles.scss +0 -26
  134. package/scss/components/FilterSummary/_storybook-styles.scss +0 -16
  135. package/scss/components/ImportModal/_storybook-styles.scss +0 -6
  136. package/scss/components/MultiAddSelect/_storybook-styles.scss +0 -6
  137. package/scss/components/NotificationsPanel/_storybook-styles.scss +0 -23
  138. package/scss/components/OptionsTile/_storybook-styles.scss +0 -29
  139. package/scss/components/PageHeader/_storybook-styles.scss +0 -90
  140. package/scss/components/ProductiveCard/_storybook-styles.scss +0 -23
  141. package/scss/components/RemoveModal/_storybook-styles.scss +0 -6
  142. package/scss/components/Saving/_storybook-styles.scss +0 -12
  143. package/scss/components/SidePanel/_storybook-styles.scss +0 -52
  144. package/scss/components/SingleAddSelect/_storybook-styles.scss +0 -6
  145. package/scss/components/StatusIcon/_storybook-styles.scss +0 -6
  146. package/scss/components/TagSet/_storybook-styles.scss +0 -8
  147. package/scss/components/Tearsheet/_storybook-styles.scss +0 -25
  148. package/scss/components/UserProfileImage/_storybook.scss +0 -6
  149. package/scss/components/WebTerminal/_storybook-styles.scss +0 -46
@@ -3,14 +3,13 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
5
  var _excluded = ["onChange"];
6
- /*
7
- * Licensed Materials - Property of IBM
8
- * 5724-Q36
9
- * (c) Copyright IBM Corp. 2023
10
- * US Government Users Restricted Rights - Use, duplication or disclosure
11
- * restricted by GSA ADP Schedule Contract with IBM Corp.
6
+ /**
7
+ * Copyright IBM Corp. 2020, 2023
8
+ *
9
+ * This source code is licensed under the Apache-2.0 license found in the
10
+ * LICENSE file in the root directory of this source tree.
12
11
  */
13
- // @flow
12
+
14
13
  import React, { useLayoutEffect, useState } from 'react';
15
14
  import { TableSelectAll } from '@carbon/react';
16
15
  import cx from 'classnames';
@@ -23,6 +22,7 @@ var SelectAll = function SelectAll(datagridState) {
23
22
  windowSize = _useState2[0],
24
23
  setWindowSize = _useState2[1];
25
24
  useLayoutEffect(function () {
25
+ /* istanbul ignore next */
26
26
  function updateSize() {
27
27
  setWindowSize(window.innerWidth);
28
28
  }
@@ -43,15 +43,15 @@ var SelectAll = function SelectAll(datagridState) {
43
43
  var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
44
44
  if (hideSelectAll || radio) {
45
45
  return /*#__PURE__*/React.createElement("div", {
46
- className: cx("".concat(blockClass, "__head-hidden-select-all"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft && windowSize > 671))
46
+ className: cx("".concat(blockClass, "__head-hidden-select-all"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), /* istanbul ignore next */
47
+ isFirstColumnStickyLeft && windowSize > 671))
47
48
  });
48
49
  }
49
50
  var getProps = DatagridPagination ? getToggleAllPageRowsSelectedProps : getToggleAllRowsSelectedProps;
50
51
  var _getProps = getProps(),
51
52
  onChange = _getProps.onChange,
52
53
  selectProps = _objectWithoutProperties(_getProps, _excluded);
53
- var _ref = selectProps || {},
54
- indeterminate = _ref.indeterminate;
54
+ var indeterminate = selectProps.indeterminate;
55
55
  var handleSelectAllChange = function handleSelectAllChange(event) {
56
56
  if (indeterminate) {
57
57
  return onChange === null || onChange === void 0 ? void 0 : onChange({
@@ -63,7 +63,8 @@ var SelectAll = function SelectAll(datagridState) {
63
63
  return onChange === null || onChange === void 0 ? void 0 : onChange(event);
64
64
  };
65
65
  return /*#__PURE__*/React.createElement("div", {
66
- className: cx("".concat(blockClass, "__head-select-all"), "".concat(blockClass, "__checkbox-cell"), _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft && windowSize > 671))
66
+ className: cx("".concat(blockClass, "__head-select-all"), "".concat(blockClass, "__checkbox-cell"), _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), /* istanbul ignore next */
67
+ isFirstColumnStickyLeft && windowSize > 671))
67
68
  }, /*#__PURE__*/React.createElement(TableSelectAll, _extends({}, selectProps, {
68
69
  name: "".concat(tableId, "-select-all-checkbox-name"),
69
70
  onSelect: handleSelectAllChange,
@@ -31,7 +31,10 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
31
31
  toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
32
32
  toolbarBatchActions = datagridState.toolbarBatchActions,
33
33
  setGlobalFilter = datagridState.setGlobalFilter,
34
- rows = datagridState.rows;
34
+ rows = datagridState.rows,
35
+ batchActionMenuButtonLabel = datagridState.batchActionMenuButtonLabel,
36
+ translateWithIdBatchActions = datagridState.translateWithIdBatchActions;
37
+ var batchActionMenuButtonLabelText = batchActionMenuButtonLabel !== null && batchActionMenuButtonLabel !== void 0 ? batchActionMenuButtonLabel : 'More';
35
38
  var selectedKeys = Object.keys(selectedRowIds || {});
36
39
  var totalSelected = selectedKeys.length;
37
40
 
@@ -84,7 +87,7 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
84
87
  });
85
88
  };
86
89
  return /*#__PURE__*/React.createElement(MenuButton, {
87
- label: "More",
90
+ label: batchActionMenuButtonLabelText,
88
91
  className: cx([menuClass, _defineProperty({}, "".concat(menuClass, "-icon-only"), width <= minWidthBeforeOverflowIcon)])
89
92
  }, toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
90
93
  var hidden = index < 2 && !displayAllInMenu;
@@ -116,7 +119,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
116
119
  totalSelected: totalSelected,
117
120
  onCancel: onCancelHandler,
118
121
  onSelectAll: onSelectAllHandler,
119
- totalCount: rows && rows.length
122
+ totalCount: rows && rows.length,
123
+ translateWithId: translateWithIdBatchActions
120
124
  }, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
121
125
  if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length <= 3) {
122
126
  return /*#__PURE__*/React.createElement(TableBatchAction, {
@@ -1,4 +1,3 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  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; }
4
3
  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; }
@@ -9,7 +8,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
8
  * LICENSE file in the root directory of this source tree.
10
9
  */
11
10
 
12
- import React, { useEffect } from 'react';
11
+ import React, { useEffect, useRef } from 'react';
13
12
  import { VariableSizeList } from 'react-window';
14
13
  import { TableBody } from '@carbon/react';
15
14
  import { pkg } from '../../../settings';
@@ -40,19 +39,15 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
40
39
  DatagridPagination = datagridState.DatagridPagination,
41
40
  page = datagridState.page,
42
41
  handleResize = datagridState.handleResize,
43
- gridRef = datagridState.gridRef;
42
+ gridRef = datagridState.gridRef,
43
+ tableId = datagridState.tableId;
44
+
45
+ /* istanbul ignore next */
44
46
  var handleVirtualGridResize = function handleVirtualGridResize() {
45
47
  var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
46
48
  gridRefElement.style.width = gridRefElement === null || gridRefElement === void 0 ? void 0 : gridRefElement.clientWidth;
47
49
  };
48
50
  useResizeObserver(gridRef, handleVirtualGridResize);
49
- var syncScroll = function syncScroll(event) {
50
- var virtualBody = event.target;
51
- document.querySelector(".".concat(blockClass, "__head-wrap")).scrollLeft = virtualBody.scrollLeft;
52
- var spacerColumn = document.querySelector(".".concat(blockClass, "__head-wrap thead th:last-child"));
53
- spacerColumn.style.width = px(32 + (virtualBody.offsetWidth - virtualBody.clientWidth)); // scrollbar width to header column to fix header alignment
54
- };
55
-
56
51
  useEffect(function () {
57
52
  handleResize();
58
53
  }, [handleResize]);
@@ -61,15 +56,30 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
61
56
  listRef.current.resetAfterIndex(0);
62
57
  }
63
58
  var visibleRows = DatagridPagination && page || rows;
59
+ var testRef = useRef();
60
+
61
+ // Sync the scrollLeft position of the virtual body to the table header
62
+ useEffect(function () {
63
+ function handleScroll(event) {
64
+ var virtualBody = event.target;
65
+ document.querySelector("#".concat(tableId, " .").concat(blockClass, "__head-wrap")).scrollLeft = virtualBody.scrollLeft;
66
+ var spacerColumn = document.querySelector("#".concat(tableId, " .").concat(blockClass, "__head-wrap thead th:last-child"));
67
+ spacerColumn.style.width = px(32 + (virtualBody.offsetWidth - virtualBody.clientWidth)); // scrollbar width to header column to fix header alignment
68
+ }
69
+
70
+ var testRefValue = testRef.current;
71
+ testRefValue.addEventListener('scroll', handleScroll);
72
+ return function () {
73
+ testRefValue.removeEventListener('scroll', handleScroll);
74
+ };
75
+ });
64
76
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
65
77
  className: "".concat(blockClass, "__head-wrap"),
66
78
  style: {
67
79
  width: (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth,
68
80
  overflow: 'hidden'
69
81
  }
70
- }, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
71
- onScroll: syncScroll
72
- }), /*#__PURE__*/React.createElement(VariableSizeList, {
82
+ }, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, getTableBodyProps(), /*#__PURE__*/React.createElement(VariableSizeList, {
73
83
  height: virtualHeight || tableHeight,
74
84
  itemCount: visibleRows.length,
75
85
  itemSize: function itemSize(index) {
@@ -78,6 +88,7 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
78
88
  estimatedItemSize: rowHeight,
79
89
  onScroll: onScroll,
80
90
  innerRef: innerListRef,
91
+ outerRef: testRef,
81
92
  ref: listRef,
82
93
  className: "".concat(blockClass, "__virtual-scrollbar"),
83
94
  style: {
@@ -66,10 +66,10 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
66
66
  if (destOverCol !== null && destOverCol !== void 0 && destOverCol.length && (_destOverCol$ = destOverCol[0]) !== null && _destOverCol$ !== void 0 && _destOverCol$.disabled) {
67
67
  return;
68
68
  }
69
- var fromVisibleIndex = columns.findIndex(function (col) {
69
+ var fromVisibleIndex = updatedDragCols.findIndex(function (col) {
70
70
  return matchedColsById(col, active);
71
71
  });
72
- var toVisibleIndex = columns.findIndex(function (col) {
72
+ var toVisibleIndex = updatedDragCols.findIndex(function (col) {
73
73
  return matchedColsById(col, over);
74
74
  });
75
75
  var colTitle = getNodeTextContent(updatedDragCols[fromVisibleIndex].Header);
@@ -15,6 +15,7 @@ var COLUMN_RESIZE_START = 'columnStartResizing';
15
15
  var COLUMN_RESIZING = 'columnResizing';
16
16
  var COLUMN_RESIZE_END = 'columnDoneResizing';
17
17
  var INIT = 'init';
18
+ var TOGGLE_ROW_SELECTED = 'toggleRowSelected';
18
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId, isKeyEvent) {
20
21
  dispatch({
@@ -46,8 +47,43 @@ export var handleColumnResizingEvent = function handleColumnResizingEvent(dispat
46
47
  }
47
48
  });
48
49
  };
50
+ export var handleToggleRowSelected = function handleToggleRowSelected(dispatch, rowData, isChecked) {
51
+ return dispatch({
52
+ type: TOGGLE_ROW_SELECTED,
53
+ payload: {
54
+ rowData: rowData,
55
+ isChecked: isChecked
56
+ }
57
+ });
58
+ };
49
59
  export var stateReducer = function stateReducer(newState, action) {
50
60
  switch (action.type) {
61
+ case TOGGLE_ROW_SELECTED:
62
+ {
63
+ var _ref = action.payload || {},
64
+ rowData = _ref.rowData,
65
+ isChecked = _ref.isChecked;
66
+ if (!rowData) {
67
+ return;
68
+ }
69
+ if (isChecked) {
70
+ return _objectSpread(_objectSpread({}, newState), {}, {
71
+ selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, rowData.index, rowData))
72
+ });
73
+ }
74
+ if (rowData && !isChecked) {
75
+ var newData = _objectSpread({}, newState.selectedRowData);
76
+ var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (_ref2) {
77
+ var _ref3 = _slicedToArray(_ref2, 1),
78
+ key = _ref3[0];
79
+ return parseInt(key) !== parseInt(rowData.index);
80
+ }));
81
+ return _objectSpread(_objectSpread({}, newState), {}, {
82
+ selectedRowData: dataWithRemovedRow
83
+ });
84
+ }
85
+ return _objectSpread({}, newState);
86
+ }
51
87
  case INIT:
52
88
  {
53
89
  return _objectSpread(_objectSpread({}, newState), {}, {
@@ -56,27 +92,27 @@ export var stateReducer = function stateReducer(newState, action) {
56
92
  }
57
93
  case COLUMN_RESIZE_START:
58
94
  {
59
- var _ref = action.payload || {},
60
- headerId = _ref.headerId;
95
+ var _ref4 = action.payload || {},
96
+ headerId = _ref4.headerId;
61
97
  return _objectSpread(_objectSpread({}, newState), {}, {
62
98
  isResizing: headerId
63
99
  });
64
100
  }
65
101
  case COLUMN_RESIZING:
66
102
  {
67
- var _ref2 = action.payload || {},
68
- _headerId = _ref2.headerId,
69
- newWidth = _ref2.newWidth,
70
- defaultWidth = _ref2.defaultWidth;
103
+ var _ref5 = action.payload || {},
104
+ _headerId = _ref5.headerId,
105
+ newWidth = _ref5.newWidth,
106
+ defaultWidth = _ref5.defaultWidth;
71
107
  var newColumnWidth = {};
72
108
  if (typeof _headerId === 'undefined') {
73
109
  return _objectSpread({}, newState);
74
110
  }
75
111
  newColumnWidth[_headerId] = newWidth;
76
- var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref3) {
77
- var _ref4 = _slicedToArray(_ref3, 2),
78
- _ = _ref4[0],
79
- value = _ref4[1];
112
+ var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref6) {
113
+ var _ref7 = _slicedToArray(_ref6, 2),
114
+ _ = _ref7[0],
115
+ value = _ref7[1];
80
116
  return !isNaN(value);
81
117
  }));
82
118
  var headerIdArray = newState.columnResizing.headerIdWidths || [];
@@ -91,10 +127,10 @@ export var stateReducer = function stateReducer(newState, action) {
91
127
  }
92
128
  case COLUMN_RESIZE_END:
93
129
  {
94
- var _ref5 = action.payload || {},
95
- onColResizeEnd = _ref5.onColResizeEnd,
96
- _headerId2 = _ref5.headerId,
97
- isKeyEvent = _ref5.isKeyEvent;
130
+ var _ref8 = action.payload || {},
131
+ onColResizeEnd = _ref8.onColResizeEnd,
132
+ _headerId2 = _ref8.headerId,
133
+ isKeyEvent = _ref8.isKeyEvent;
98
134
  var currentColumn = {};
99
135
  currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
100
136
  var allChangedColumns = newState.columnResizing.columnWidths;
@@ -45,13 +45,13 @@ export var DocsPage = function DocsPage() {
45
45
  description: "There is also an optional resize callback when resizing columns, allowing you to save the widths of columns that have been resized. The resize callback returns the column that was just resized and it's width, in addition to all of the columns that have been resized and their widths.",
46
46
  source: {
47
47
  language: 'jsx',
48
- code: "\nuseDatagrid({\n columns,\n data,\n onColResizeEnd: (currentColumn, allColumns) =>\n console.log(currentColumn, allColumns),\n});\n "
48
+ code: "\nuseDatagrid({\n columns,\n data,\n onColResizeEnd: (currentColumn, allColumns) =>\n console.log(currentColumn, allColumns),\n resizerAriaLabel: 'Resize column',\n});\n "
49
49
  }
50
50
  }, {
51
- description: 'Disabling the resizable columns is possible by specifying `disableResizing: true` within the `useDatagrid` hook.',
51
+ description: 'Disabling the resizable columns is possible by specifying `disableResizing: true` within the `useDatagrid` hook. To pass in your own translated label for the column resizer, add the `resizerAriaLabel` property',
52
52
  source: {
53
53
  language: 'jsx',
54
- code: "\nuseDatagrid({\n columns,\n data,\n disableResizing: true,\n});\n "
54
+ code: "\nuseDatagrid({\n columns,\n data,\n disableResizing: true,\n resizerAriaLabel: 'Resize column',\n});\n "
55
55
  }
56
56
  }, {
57
57
  title: 'Rendering the table toolbar',
@@ -106,7 +106,7 @@ export var DocsPage = function DocsPage() {
106
106
  title: 'Selecting rows',
107
107
  description: "When building a Datagrid that requires selectable rows, use the `useSelectRows` hook.\n- Include `useSelectRows` hook\n- Add `onRowSelect` to the `useDatagrid` hook, this is a callback function called when on a row's selection checkbox onChange, and sends back the row object and the event\n ",
108
108
  source: {
109
- code: "\nconst [data] = useState(makeData(10));\nconst columns = React.useMemo(() => getColumns(data), []);\nconst datagridState = useDatagrid(\n {\n columns,\n data,\n onRowSelect: (row, event) => console.log(row, event),\n },\n useSelectRows\n);\n\nreturn <Datagrid datagridState={datagridState} />;\n "
109
+ code: "\nconst [data] = useState(makeData(10));\nconst columns = React.useMemo(() => getColumns(data), []);\nconst datagridState = useDatagrid(\n {\n columns,\n data,\n onRowSelect: (row, event) => console.log(row, event),\n batchActionMenuButtonLabel: 'More',\n },\n useSelectRows\n);\n\nreturn <Datagrid datagridState={datagridState} />;\n "
110
110
  }
111
111
  }, {
112
112
  description: "The select all checkbox can be optionally hidden by settings the `hideSelectAll` property to `true` in the `useDatagrid` hook.",
@@ -45,7 +45,7 @@
45
45
 
46
46
  // ## Sample usage:
47
47
  // 1. include \`useActionsColumn\` hook
48
- // 2. add \`isAction = true\` to the column object in which you which to add the overflow menu actions
48
+ // 2. add \`isAction = true\` to the column object in which you wish to add the overflow menu actions
49
49
  // 3. add \`rowActions = []\` array to the props
50
50
  // - \`rowActions[].id\` for callback to identify the action is called
51
51
  // - \`rowActions[].onClick(actionId: string, row: Row, event: ClickEvent)\` callback on menuitem clicked. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
@@ -12,15 +12,12 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
12
12
  * LICENSE file in the root directory of this source tree.
13
13
  */
14
14
 
15
- import React, { useEffect } from 'react';
15
+ import React from 'react';
16
16
  import cx from 'classnames';
17
17
  import { IconSkeleton, OverflowMenu, OverflowMenuItem } from '@carbon/react';
18
18
  import { pkg } from '../../settings';
19
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
20
20
  var useActionsColumn = function useActionsColumn(hooks) {
21
- useEffect(function () {
22
- pkg.checkReportFeatureEnabled('Datagrid.useActionsColumn');
23
- }, []);
24
21
  var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
25
22
  var rowActions = instance.rowActions,
26
23
  isFetching = instance.isFetching,
@@ -32,6 +32,9 @@ var useDatagrid = function useDatagrid(params) {
32
32
  }
33
33
  var defaultEndPlugins = [usePagination, useRowSelect, useFlexResize, useFloatingScroll];
34
34
  var clientEndPlugins = params.endPlugins || [];
35
+ var defaultColumn = {
36
+ minWidth: 50
37
+ };
35
38
  var tableId = useMemo(function () {
36
39
  return uniqueId('datagrid-table-id');
37
40
  }, []);
@@ -41,7 +44,8 @@ var useDatagrid = function useDatagrid(params) {
41
44
  var tableState = useTable.apply(void 0, [_objectSpread(_objectSpread({
42
45
  tableId: tableId
43
46
  }, params), {}, {
44
- stateReducer: stateReducer
47
+ stateReducer: stateReducer,
48
+ defaultColumn: defaultColumn
45
49
  })].concat(defaultPlugins, plugins, defaultEndPlugins, _toConsumableArray(clientEndPlugins)));
46
50
  return tableState;
47
51
  };
@@ -1,27 +1,37 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
- /*
3
- * Licensed Materials - Property of IBM
4
- * 5724-Q36
5
- * (c) Copyright IBM Corp. 2020
6
- * US Government Users Restricted Rights - Use, duplication or disclosure
7
- * restricted by GSA ADP Schedule Contract with IBM Corp.
2
+ /**
3
+ * Copyright IBM Corp. 2020, 2023
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
8
7
  */
8
+
9
9
  var useFlexResize = function useFlexResize(hooks) {
10
- var spacerColumn = {
10
+ var spacer = {
11
11
  id: 'spacer',
12
12
  width: 0,
13
13
  disableSortBy: true,
14
14
  disableResizing: true
15
15
  };
16
16
  hooks.visibleColumns.push(function (columns) {
17
- return [].concat(_toConsumableArray(columns), [spacerColumn]);
17
+ // always move actions and spacer to the end
18
+ var actionsIdx = columns.findIndex(function (col) {
19
+ return col.isAction;
20
+ });
21
+ if (actionsIdx === -1) {
22
+ return [].concat(_toConsumableArray(columns), [spacer]);
23
+ }
24
+ var cols = _toConsumableArray(columns);
25
+ var actions = cols.splice(actionsIdx, 1)[0];
26
+ cols.splice(columns.length, 0, spacer, actions);
27
+ return cols;
18
28
  });
19
29
  var changeProps = function changeProps(props, data) {
20
30
  var column = data.column;
21
31
  if (!column && data.cell) {
22
32
  column = data.cell.column;
23
33
  }
24
- if (column.id === spacerColumn.id) {
34
+ if (column.id === spacer.id) {
25
35
  return [props, {
26
36
  style: {
27
37
  flex: '1 1 0'
@@ -5,17 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
- import { useCallback, useEffect } from 'react';
8
+ import { useCallback } from 'react';
9
9
  import debounce from 'lodash/debounce';
10
10
  import useParentDimensions from './useParentDimensions';
11
11
  import useResizeTable from './useResizeTable';
12
- import { pkg } from '../../settings';
13
12
  var useInfiniteScroll = function useInfiniteScroll(hooks) {
14
13
  useParentDimensions(hooks);
15
14
  useResizeTable(hooks);
16
- useEffect(function () {
17
- pkg.checkReportFeatureEnabled('Datagrid.useInfiniteScroll');
18
- }, []);
19
15
  var useInstance = function useInstance(instance) {
20
16
  var isFetching = instance.isFetching,
21
17
  tableHeight = instance.tableHeight,
@@ -1,9 +1,8 @@
1
- /*
2
- * Licensed Materials - Property of IBM
3
- * 5724-Q36
4
- * (c) Copyright IBM Corp. 2020, 2023
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 { pkg, carbon } from '../../settings';
@@ -43,7 +42,7 @@ var useOnRowClick = function useOnRowClick(hooks) {
43
42
  var onKeyDown = function onKeyDown(event) {
44
43
  var key = event.key;
45
44
  if (key === 'Enter') {
46
- onClick();
45
+ onClick(event);
47
46
  }
48
47
  };
49
48
  return [props, {
@@ -20,6 +20,7 @@ import { TableSelectRow } from '@carbon/react';
20
20
  import { SelectAll } from './Datagrid/DatagridSelectAll';
21
21
  import { selectionColumnId } from './common-column-ids';
22
22
  import { pkg, carbon } from '../../settings';
23
+ import { handleToggleRowSelected } from './Datagrid/addons/stateReducer';
23
24
  var blockClass = "".concat(pkg.prefix, "--datagrid");
24
25
  var checkboxClass = "".concat(pkg.prefix, "--datagrid__checkbox-cell");
25
26
  var useSelectRows = function useSelectRows(hooks) {
@@ -77,7 +78,8 @@ var SelectRow = function SelectRow(datagridState) {
77
78
  onRadioSelect = datagridState.onRadioSelect,
78
79
  onRowSelect = datagridState.onRowSelect,
79
80
  columns = datagridState.columns,
80
- withStickyColumn = datagridState.withStickyColumn;
81
+ withStickyColumn = datagridState.withStickyColumn,
82
+ dispatch = datagridState.dispatch;
81
83
  var _useState = useState(window.innerWidth),
82
84
  _useState2 = _slicedToArray(_useState, 2),
83
85
  windowSize = _useState2[0],
@@ -91,16 +93,17 @@ var SelectRow = function SelectRow(datagridState) {
91
93
  return window.removeEventListener('resize', updateSize);
92
94
  };
93
95
  }, []);
94
- var onSelectHandler = function onSelectHandler(e) {
95
- e.stopPropagation(); // avoid triggering onRowClick
96
+ var onSelectHandler = function onSelectHandler(event) {
97
+ event.stopPropagation(); // avoid triggering onRowClick
96
98
  if (radio) {
97
99
  toggleAllRowsSelected(false);
98
100
  if (onRadioSelect) {
99
101
  onRadioSelect(row);
100
102
  }
101
103
  }
102
- onChange(e);
103
- onRowSelect === null || onRowSelect === void 0 || onRowSelect(row, e);
104
+ onChange(event);
105
+ onRowSelect === null || onRowSelect === void 0 || onRowSelect(row, event);
106
+ handleToggleRowSelected(dispatch, row, event.target.checked);
104
107
  };
105
108
  var selectDisabled = isFetching || row.getRowProps().disabled;
106
109
  var _row$getToggleRowSele2 = row.getToggleRowSelectedProps(),
@@ -28,9 +28,8 @@ var getAriaSortValue = function getAriaSortValue(col, _ref) {
28
28
  if (!col) {
29
29
  return;
30
30
  }
31
- var _ref2 = col || {},
32
- isSorted = _ref2.isSorted,
33
- isSortedDesc = _ref2.isSortedDesc;
31
+ var isSorted = col.isSorted,
32
+ isSortedDesc = col.isSortedDesc;
34
33
  if (!isSorted) {
35
34
  return defaultSortableLabelText;
36
35
  }
@@ -45,17 +44,16 @@ var getAriaPressedValue = function getAriaPressedValue(col) {
45
44
  if (!col) {
46
45
  return;
47
46
  }
48
- var _ref3 = col || {},
49
- isSorted = _ref3.isSorted;
47
+ var isSorted = col.isSorted;
50
48
  if (isSorted) {
51
49
  return 'true';
52
50
  }
53
51
  return 'false';
54
52
  };
55
53
  var useSortableColumns = function useSortableColumns(hooks) {
56
- var sortableVisibleColumns = function sortableVisibleColumns(visibleColumns, _ref4) {
54
+ var sortableVisibleColumns = function sortableVisibleColumns(visibleColumns, _ref2) {
57
55
  var _instance$customizeCo;
58
- var instance = _ref4.instance;
56
+ var instance = _ref2.instance;
59
57
  var onSort = instance.onSort,
60
58
  ascendingSortableLabelText = instance.ascendingSortableLabelText,
61
59
  descendingSortableLabelText = instance.descendingSortableLabelText,
@@ -48,7 +48,8 @@ export var ErrorEmptyState = /*#__PURE__*/React.forwardRef(function (_ref, ref)
48
48
  ref: ref
49
49
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(ErrorIllustration, {
50
50
  theme: illustrationTheme,
51
- size: size
51
+ size: size,
52
+ title: title
52
53
  }), /*#__PURE__*/React.createElement(EmptyStateContent, {
53
54
  action: action,
54
55
  link: link,
@@ -48,7 +48,8 @@ export var NoTagsEmptyState = /*#__PURE__*/React.forwardRef(function (_ref, ref)
48
48
  ref: ref
49
49
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(NoTagsIllustration, {
50
50
  theme: illustrationTheme,
51
- size: size
51
+ size: size,
52
+ title: title
52
53
  }), /*#__PURE__*/React.createElement(EmptyStateContent, {
53
54
  action: action,
54
55
  link: link,
@@ -48,7 +48,8 @@ export var NotFoundEmptyState = /*#__PURE__*/React.forwardRef(function (_ref, re
48
48
  ref: ref
49
49
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(NotFoundIllustration, {
50
50
  theme: illustrationTheme,
51
- size: size
51
+ size: size,
52
+ title: title
52
53
  }), /*#__PURE__*/React.createElement(EmptyStateContent, {
53
54
  action: action,
54
55
  link: link,
@@ -48,7 +48,8 @@ export var NotificationsEmptyState = /*#__PURE__*/React.forwardRef(function (_re
48
48
  ref: ref
49
49
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(NotificationsIllustration, {
50
50
  size: size,
51
- theme: illustrationTheme
51
+ theme: illustrationTheme,
52
+ title: title
52
53
  }), /*#__PURE__*/React.createElement(EmptyStateContent, {
53
54
  action: action,
54
55
  link: link,
@@ -48,7 +48,8 @@ export var UnauthorizedEmptyState = /*#__PURE__*/React.forwardRef(function (_ref
48
48
  ref: ref
49
49
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement(UnauthorizedIllustration, {
50
50
  size: size,
51
- theme: illustrationTheme
51
+ theme: illustrationTheme,
52
+ title: title
52
53
  }), /*#__PURE__*/React.createElement(EmptyStateContent, {
53
54
  action: action,
54
55
  link: link,
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["theme", "size"];
3
+ var _excluded = ["theme", "title", "size"];
4
4
  /**
5
5
  * Copyright IBM Corp. 2020, 2021
6
6
  *
@@ -21,6 +21,7 @@ import uuidv4 from '../../../global/js/utils/uuidv4';
21
21
  var blockClass = "".concat(pkg.prefix, "--empty-state");
22
22
  export var ErrorIllustration = function ErrorIllustration(_ref) {
23
23
  var theme = _ref.theme,
24
+ title = _ref.title,
24
25
  size = _ref.size,
25
26
  rest = _objectWithoutProperties(_ref, _excluded);
26
27
  var svgId = uuidv4();
@@ -31,7 +32,7 @@ export var ErrorIllustration = function ErrorIllustration(_ref) {
31
32
  viewBox: "0 0 80 80",
32
33
  className: cx(["".concat(blockClass, "__illustration"), "".concat(blockClass, "__illustration-error"), "".concat(blockClass, "__illustration--").concat(size)]),
33
34
  role: "img"
34
- }), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
35
+ }), /*#__PURE__*/React.createElement("title", null, title), theme === 'dark' ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
35
36
  id: "prefix__a_dark_".concat(svgId),
36
37
  x1: 38.9,
37
38
  y1: 77.08,
@@ -209,5 +210,6 @@ export var ErrorIllustration = function ErrorIllustration(_ref) {
209
210
  };
210
211
  ErrorIllustration.propTypes = {
211
212
  size: PropTypes.oneOf(['lg', 'sm']),
212
- theme: PropTypes.oneOf(['light', 'dark'])
213
+ theme: PropTypes.oneOf(['light', 'dark']),
214
+ title: PropTypes.string
213
215
  };