@carbon/ibm-products 1.61.1 → 1.62.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. package/css/index-full-carbon.css +172 -70
  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-released-only.css +1768 -0
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +172 -70
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +172 -70
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -3
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Carousel/Carousel.js +194 -119
  18. package/es/components/Carousel/CarouselItem.js +8 -21
  19. package/es/components/Coachmark/Coachmark.js +17 -5
  20. package/es/components/Coachmark/CoachmarkDragbar.js +12 -5
  21. package/es/components/Coachmark/CoachmarkHeader.js +2 -1
  22. package/es/components/Coachmark/CoachmarkOverlay.js +105 -9
  23. package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +5 -2
  24. package/es/components/CoachmarkFixed/CoachmarkFixed.js +26 -6
  25. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +34 -10
  26. package/es/components/CoachmarkStack/CoachmarkStack.js +19 -4
  27. package/es/components/CoachmarkStack/CoachmarkStackHome.js +45 -11
  28. package/es/components/Datagrid/Datagrid/DatagridContent.js +12 -9
  29. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +6 -4
  30. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +42 -25
  31. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +4 -1
  32. package/es/components/Datagrid/Datagrid/DatagridRow.js +23 -11
  33. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +31 -12
  34. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  35. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +43 -23
  36. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +18 -18
  37. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +93 -14
  38. package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
  39. package/es/components/Datagrid/useActionsColumn.js +9 -9
  40. package/es/components/Datagrid/useDatagrid.js +13 -1
  41. package/es/components/Datagrid/useExpandedRow.js +3 -6
  42. package/es/components/Datagrid/useFlexResize.js +19 -9
  43. package/es/components/Datagrid/useFocusRowExpander.js +40 -0
  44. package/es/components/Datagrid/useInfiniteScroll.js +10 -9
  45. package/es/components/Datagrid/useNestedRowExpander.js +9 -0
  46. package/es/components/Datagrid/useNestedRows.js +0 -4
  47. package/es/components/Datagrid/useOnRowClick.js +6 -7
  48. package/es/components/Datagrid/useParentDimensions.js +6 -6
  49. package/es/components/Datagrid/useResizeTable.js +7 -7
  50. package/es/components/Datagrid/useRowExpander.js +9 -0
  51. package/es/components/Datagrid/useSelectAllToggle.js +2 -2
  52. package/es/components/Datagrid/useSelectRows.js +52 -30
  53. package/es/components/Datagrid/useSkeletonRows.js +6 -6
  54. package/es/components/Datagrid/useSortableColumns.js +4 -5
  55. package/es/components/Datagrid/useStickyColumn.js +13 -6
  56. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -0
  57. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -0
  58. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -0
  59. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -0
  60. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -0
  61. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -0
  62. package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -4
  63. package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -4
  64. package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -4
  65. package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -4
  66. package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -4
  67. package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -4
  68. package/es/components/Guidebanner/Guidebanner.js +9 -12
  69. package/es/global/js/hooks/index.js +3 -2
  70. package/es/global/js/hooks/usePrefix.js +11 -0
  71. package/es/global/js/package-settings.js +1 -4
  72. package/lib/components/Carousel/Carousel.js +190 -114
  73. package/lib/components/Carousel/CarouselItem.js +9 -25
  74. package/lib/components/Coachmark/Coachmark.js +16 -4
  75. package/lib/components/Coachmark/CoachmarkDragbar.js +12 -5
  76. package/lib/components/Coachmark/CoachmarkHeader.js +2 -1
  77. package/lib/components/Coachmark/CoachmarkOverlay.js +105 -8
  78. package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +5 -2
  79. package/lib/components/CoachmarkFixed/CoachmarkFixed.js +25 -5
  80. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +34 -10
  81. package/lib/components/CoachmarkStack/CoachmarkStack.js +18 -3
  82. package/lib/components/CoachmarkStack/CoachmarkStackHome.js +44 -10
  83. package/lib/components/Datagrid/Datagrid/DatagridContent.js +12 -9
  84. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +6 -4
  85. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +42 -32
  86. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +4 -1
  87. package/lib/components/Datagrid/Datagrid/DatagridRow.js +17 -4
  88. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +25 -5
  89. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
  90. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +43 -23
  91. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +12 -12
  92. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +96 -15
  93. package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
  94. package/lib/components/Datagrid/useActionsColumn.js +9 -12
  95. package/lib/components/Datagrid/useDatagrid.js +13 -1
  96. package/lib/components/Datagrid/useExpandedRow.js +2 -5
  97. package/lib/components/Datagrid/useFlexResize.js +19 -9
  98. package/lib/components/Datagrid/useFocusRowExpander.js +46 -0
  99. package/lib/components/Datagrid/useInfiniteScroll.js +9 -9
  100. package/lib/components/Datagrid/useNestedRowExpander.js +9 -0
  101. package/lib/components/Datagrid/useNestedRows.js +0 -4
  102. package/lib/components/Datagrid/useOnRowClick.js +6 -7
  103. package/lib/components/Datagrid/useParentDimensions.js +5 -6
  104. package/lib/components/Datagrid/useResizeTable.js +6 -7
  105. package/lib/components/Datagrid/useRowExpander.js +9 -0
  106. package/lib/components/Datagrid/useSelectAllToggle.js +2 -2
  107. package/lib/components/Datagrid/useSelectRows.js +46 -23
  108. package/lib/components/Datagrid/useSkeletonRows.js +6 -6
  109. package/lib/components/Datagrid/useSortableColumns.js +4 -5
  110. package/lib/components/Datagrid/useStickyColumn.js +8 -0
  111. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -0
  112. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -0
  113. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -0
  114. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -0
  115. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -0
  116. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -0
  117. package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -4
  118. package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -4
  119. package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -4
  120. package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -4
  121. package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -4
  122. package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -4
  123. package/lib/components/Guidebanner/Guidebanner.js +9 -12
  124. package/lib/global/js/hooks/index.js +8 -1
  125. package/lib/global/js/hooks/usePrefix.js +19 -0
  126. package/lib/global/js/package-settings.js +1 -4
  127. package/package.json +2 -2
  128. package/scss/components/Carousel/_carousel.scss +1 -2
  129. package/scss/components/Checklist/_checklist.scss +13 -25
  130. package/scss/components/Coachmark/styles/_coachmark-dragbar.scss +1 -45
  131. package/scss/components/Coachmark/styles/_coachmark-header.scss +0 -33
  132. package/scss/components/Coachmark/styles/_coachmark-overlay.scss +113 -5
  133. package/scss/components/Coachmark/styles/_coachmark-tagline.scss +18 -0
  134. package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +19 -1
  135. package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +2 -0
  136. package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +1 -0
  137. package/scss/components/CoachmarkStack/_coachmark-stack.scss +3 -0
  138. package/scss/components/Datagrid/styles/_datagrid.scss +31 -5
  139. package/scss/components/Datagrid/styles/_useExpandedRow.scss +21 -0
  140. package/scss/components/Datagrid/styles/_useNestedRows.scss +1 -1
  141. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -0
  142. package/scss/components/_index-released-only.scss +1 -0
  143. package/es/components/Carousel/utils.js +0 -98
  144. package/lib/components/Carousel/utils.js +0 -108
@@ -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(target) { for (var i = 1; i < arguments.length; i++) { va
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-components-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,
@@ -41,12 +38,13 @@ var useActionsColumn = function useActionsColumn(hooks) {
41
38
  column = cell.column;
42
39
  if (column.isAction) {
43
40
  var _cx3;
41
+ var isColumnSticky = !!column.sticky;
44
42
  return [props, {
45
43
  children: /*#__PURE__*/React.createElement("div", {
46
44
  className: "".concat(blockClass, "__actions-column-contents")
47
45
  }, isFetching && /*#__PURE__*/React.createElement(IconSkeleton, {
48
46
  className: "".concat(blockClass, "__actions-column-loading")
49
- }), !isFetching && rowActions.length <= 2 && /*#__PURE__*/React.createElement("div", {
47
+ }), !isFetching && rowActions.length <= 2 && !isColumnSticky && /*#__PURE__*/React.createElement("div", {
50
48
  className: "".concat(blockClass, "_actions-column"),
51
49
  style: {
52
50
  display: 'flex'
@@ -70,6 +68,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
70
68
  hasIconOnly: true,
71
69
  light: true,
72
70
  iconDescription: itemText,
71
+ ariaLabel: itemText,
73
72
  kind: "ghost",
74
73
  className: cx(_defineProperty({}, "".concat(blockClass, "__disabled-row-action"), getDisabledState(row.index))),
75
74
  onClick: function onClick(e) {
@@ -81,7 +80,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
81
80
  _onClick(id, row, e);
82
81
  }
83
82
  })));
84
- })), !isFetching && rowActions.length > 2 && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(OverflowMenu, {
83
+ })), !isFetching && (rowActions.length > 2 || isColumnSticky) && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(OverflowMenu, {
85
84
  size: "sm",
86
85
  light: true,
87
86
  flipped: true,
@@ -111,9 +110,9 @@ var useActionsColumn = function useActionsColumn(hooks) {
111
110
  key: id
112
111
  }));
113
112
  })))),
114
- className: cx((_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__cell"), true), _cx3)),
113
+ className: cx((_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell-non-sticky"), !isColumnSticky), _cx3)),
115
114
  style: {
116
- width: rowActions.length > 2 ? 48 : 96
115
+ width: rowActions.length > 2 || isColumnSticky ? 48 : 96
117
116
  }
118
117
  }];
119
118
  }
@@ -128,9 +127,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
128
127
  var addHeaderWidth = function addHeaderWidth(props, cellData) {
129
128
  var column = cellData.column;
130
129
  if (column.isAction) {
130
+ var isColumnSticky = !!column.sticky;
131
131
  return [props, {
132
132
  style: _objectSpread(_objectSpread({}, props.style), {}, {
133
- width: rowActions.length > 2 ? 48 : 96 // set header width based on action length
133
+ width: rowActions.length > 2 || isColumnSticky ? 48 : 96 // set header width based on action length
134
134
  })
135
135
  }];
136
136
  }
@@ -22,8 +22,19 @@ import useFloatingScroll from './useFloatingScroll';
22
22
  import { stateReducer } from './Datagrid/addons/stateReducer';
23
23
  var useDatagrid = function useDatagrid(params) {
24
24
  var defaultPlugins = [useFlexLayout, useHeaderRow, useSkeletonRows, useResizeColumns, useRowRenderer, useDefaultStringRenderer, useRowSize, useFilters, useGlobalFilter, useSortBy, useExpanded];
25
+
26
+ // Disable resizing
27
+ if (params.disableResizing) {
28
+ var resizeIndex = defaultPlugins.findIndex(function (p) {
29
+ return p.pluginName === 'useResizeColumns';
30
+ });
31
+ defaultPlugins.splice(resizeIndex, 1);
32
+ }
25
33
  var defaultEndPlugins = [usePagination, useRowSelect, useFlexResize, useFloatingScroll];
26
34
  var clientEndPlugins = params.endPlugins || [];
35
+ var defaultColumn = {
36
+ minWidth: 50
37
+ };
27
38
  var tableId = useMemo(function () {
28
39
  return uniqueId('datagrid-table-id');
29
40
  }, []);
@@ -33,7 +44,8 @@ var useDatagrid = function useDatagrid(params) {
33
44
  var tableState = useTable.apply(void 0, [_objectSpread(_objectSpread({
34
45
  tableId: tableId
35
46
  }, params), {}, {
36
- stateReducer: stateReducer
47
+ stateReducer: stateReducer,
48
+ defaultColumn: defaultColumn
37
49
  })].concat(defaultPlugins, plugins, defaultEndPlugins, _toConsumableArray(clientEndPlugins)));
38
50
  return tableState;
39
51
  };
@@ -9,14 +9,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
9
  * LICENSE file in the root directory of this source tree.
10
10
  */
11
11
 
12
- import { useEffect, useState } from 'react';
13
- import { pkg } from '../../settings';
12
+ import { useState } from 'react';
14
13
  import DatagridExpandedRow from './Datagrid/DatagridExpandedRow';
15
14
  import useRowExpander from './useRowExpander';
16
15
  var useExpandedRow = function useExpandedRow(hooks) {
17
- useEffect(function () {
18
- pkg.checkReportFeatureEnabled('Datagrid.useExpandedRow');
19
- }, []);
20
16
  useRowExpander(hooks);
21
17
  var useInstance = function useInstance(instance) {
22
18
  var rows = instance.rows,
@@ -38,7 +34,8 @@ var useExpandedRow = function useExpandedRow(hooks) {
38
34
  });
39
35
  Object.assign(instance, {
40
36
  rows: rowsWithExpand,
41
- setExpandedRowHeight: setExpandedRowHeight
37
+ setExpandedRowHeight: setExpandedRowHeight,
38
+ withExpandedRows: true
42
39
  });
43
40
  };
44
41
  hooks.useInstance.push(useInstance);
@@ -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'
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 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.
6
+ */
7
+
8
+ import { useEffect } from 'react';
9
+
10
+ // Focuses the row expander after a nested/expandable row state change.
11
+ // We have to add this workaround because react-table is re-rendering the entire row
12
+ // which removes the focus from the expander and interrupts the keyboard navigation
13
+ // flow.
14
+ export var useFocusRowExpander = function useFocusRowExpander(_ref) {
15
+ var instance = _ref.instance,
16
+ _ref$lastExpandedRowI = _ref.lastExpandedRowIndex,
17
+ lastExpandedRowIndex = _ref$lastExpandedRowI === void 0 ? 0 : _ref$lastExpandedRowI,
18
+ blockClass = _ref.blockClass,
19
+ activeElement = _ref.activeElement;
20
+ useEffect(function () {
21
+ // We need to return at this point so that the focus is not stolen from
22
+ // other interactive elements in the Datagrid
23
+ if (!activeElement.classList.contains("".concat(blockClass, "__row-expander"))) {
24
+ return;
25
+ }
26
+ var tableId = instance === null || instance === void 0 ? void 0 : instance.tableId;
27
+ var rowElements = document.querySelectorAll("#".concat(tableId, " tbody tr"));
28
+ var rowElementsArray = Array.from(rowElements);
29
+ var activeRow = rowElementsArray.filter(function (r) {
30
+ if (r.getAttribute('data-nested-row-id') === lastExpandedRowIndex) {
31
+ return r;
32
+ }
33
+ return null;
34
+ });
35
+ if (activeRow.length) {
36
+ var rowExpander = activeRow[0].querySelector(".".concat(blockClass, "__row-expander"));
37
+ rowExpander.focus();
38
+ }
39
+ }, [instance === null || instance === void 0 ? void 0 : instance.tableId, instance === null || instance === void 0 ? void 0 : instance.expandedRows, lastExpandedRowIndex, blockClass, activeElement]);
40
+ };
@@ -1,10 +1,10 @@
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
  */
7
+
8
8
  import { useCallback } from 'react';
9
9
  import debounce from 'lodash/debounce';
10
10
  import useParentDimensions from './useParentDimensions';
@@ -17,10 +17,11 @@ var useInfiniteScroll = function useInfiniteScroll(hooks) {
17
17
  tableHeight = instance.tableHeight,
18
18
  innerListRef = instance.innerListRef,
19
19
  fetchMoreData = instance.fetchMoreData,
20
- tableId = instance.tableId;
20
+ tableId = instance.tableId,
21
+ loadMoreThreshold = instance.loadMoreThreshold;
21
22
  var tableElement = document.querySelector("#".concat(tableId));
22
23
  var totalTableHeight = tableHeight || (tableElement === null || tableElement === void 0 ? void 0 : tableElement.clientHeight);
23
- var loadMoreThreshold = 200;
24
+ var loadMoreThresholdValue = typeof loadMoreThreshold === 'number' ? loadMoreThreshold : 200;
24
25
  var emptyFetchData = function emptyFetchData() {};
25
26
  // eslint-disable-next-line react-hooks/exhaustive-deps
26
27
  var fetchMore = useCallback(debounce(fetchMoreData || emptyFetchData, 3000, {
@@ -31,7 +32,7 @@ var useInfiniteScroll = function useInfiniteScroll(hooks) {
31
32
  var scrollDirection = _ref.scrollDirection,
32
33
  scrollOffset = _ref.scrollOffset;
33
34
  if (innerListRef && innerListRef.current) {
34
- if (!isFetching && scrollDirection === 'forward' && scrollOffset + totalTableHeight >= innerListRef.current.clientHeight - loadMoreThreshold) {
35
+ if (!isFetching && scrollDirection === 'forward' && scrollOffset + totalTableHeight >= innerListRef.current.clientHeight - loadMoreThresholdValue) {
35
36
  if (fetchMoreData) {
36
37
  fetchMore();
37
38
  }
@@ -15,12 +15,20 @@ import React, { useRef } from 'react';
15
15
  import { ChevronRight16 } from '@carbon/icons-react';
16
16
  import cx from 'classnames';
17
17
  import { pkg, carbon } from '../../settings';
18
+ import { useFocusRowExpander } from './useFocusRowExpander';
18
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useNestedRowExpander = function useNestedRowExpander(hooks) {
20
21
  var tempState = useRef();
22
+ var lastExpandedRowIndex = useRef();
21
23
  var useInstance = function useInstance(instance) {
22
24
  tempState.current = instance;
23
25
  };
26
+ useFocusRowExpander({
27
+ instance: tempState === null || tempState === void 0 ? void 0 : tempState.current,
28
+ lastExpandedRowIndex: lastExpandedRowIndex === null || lastExpandedRowIndex === void 0 ? void 0 : lastExpandedRowIndex.current,
29
+ blockClass: blockClass,
30
+ activeElement: document.activeElement
31
+ });
24
32
  var visibleColumns = function visibleColumns(columns) {
25
33
  var expanderColumn = {
26
34
  id: 'expander',
@@ -32,6 +40,7 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
32
40
  // Prevents `onRowClick` from being called if `useOnRowClick` is included
33
41
  event.stopPropagation();
34
42
  row.toggleRowExpanded();
43
+ lastExpandedRowIndex.current = row.id;
35
44
  }
36
45
  });
37
46
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
@@ -6,15 +6,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
 
9
- import { useEffect } from 'react';
10
9
  import { pkg } from '../../settings';
11
10
  import cx from 'classnames';
12
11
  import useNestedRowExpander from './useNestedRowExpander';
13
12
  var blockClass = "".concat(pkg.prefix, "--datagrid");
14
13
  var useNestedRows = function useNestedRows(hooks) {
15
- useEffect(function () {
16
- pkg.checkReportFeatureEnabled('Datagrid.useNestedRows');
17
- }, []);
18
14
  useNestedRowExpander(hooks);
19
15
  var marginLeft = 24;
20
16
  var getRowProps = function getRowProps(props, _ref) {
@@ -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, {
@@ -1,11 +1,11 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
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
  import { useRef, useState } from 'react';
10
10
  var useParentDimensions = function useParentDimensions(hooks) {
11
11
  var rootRef = useRef();
@@ -1,10 +1,10 @@
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
  */
7
+
8
8
  import { useLayoutEffect } from 'react';
9
9
  var useResizeTable = function useResizeTable(hooks) {
10
10
  var useInstanceBeforeDimensions = function useInstanceBeforeDimensions(instance) {
@@ -26,7 +26,7 @@ var useResizeTable = function useResizeTable(hooks) {
26
26
  resizeObserver = null;
27
27
  };
28
28
  }
29
- return console.error(' Could not resize table, no support for ResizeObserver');
29
+ return console.error('Could not resize table, no support for ResizeObserver');
30
30
  }, [handleResize, parent]);
31
31
  };
32
32
  hooks.useInstanceBeforeDimensions.push(useInstanceBeforeDimensions);
@@ -15,12 +15,20 @@ import React, { useRef } from 'react';
15
15
  import { ChevronDown16, ChevronUp16 } from '@carbon/icons-react';
16
16
  import cx from 'classnames';
17
17
  import { pkg, carbon } from '../../settings';
18
+ import { useFocusRowExpander } from './useFocusRowExpander';
18
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useRowExpander = function useRowExpander(hooks) {
20
21
  var tempState = useRef();
22
+ var lastExpandedRowIndex = useRef();
21
23
  var useInstance = function useInstance(instance) {
22
24
  tempState.current = instance;
23
25
  };
26
+ useFocusRowExpander({
27
+ instance: tempState === null || tempState === void 0 ? void 0 : tempState.current,
28
+ lastExpandedRowIndex: lastExpandedRowIndex === null || lastExpandedRowIndex === void 0 ? void 0 : lastExpandedRowIndex.current,
29
+ blockClass: blockClass,
30
+ activeElement: document.activeElement
31
+ });
24
32
  var visibleColumns = function visibleColumns(columns) {
25
33
  var expanderColumn = {
26
34
  id: 'expander',
@@ -31,6 +39,7 @@ var useRowExpander = function useRowExpander(hooks) {
31
39
  // Prevents `onRowClick` from being called if `useOnRowClick` is included
32
40
  event.stopPropagation();
33
41
  row.toggleRowExpanded();
42
+ lastExpandedRowIndex.current = row.id;
34
43
  }
35
44
  });
36
45
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
@@ -13,7 +13,7 @@ import cx from 'classnames';
13
13
  import { selectionColumnId } from './common-column-ids';
14
14
  import SelectAllWithToggle from './Datagrid/DatagridSelectAllWithToggle';
15
15
  import { pkg } from '../../settings';
16
- var blockClass = "".concat(pkg.prefix, "--datagrid");
16
+ var blockClass = "".concat(pkg.prefix, "--datagrid__select-all");
17
17
  var useSelectAllToggle = function useSelectAllToggle(hooks) {
18
18
  useSelectAllWithToggleComponent(hooks);
19
19
  useAddClassNameToSelectRow(hooks);
@@ -60,7 +60,7 @@ var useAddClassNameToSelectRow = function useAddClassNameToSelectRow(hooks) {
60
60
  var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
61
61
  if (column.id === selectionColumnId && DatagridPagination) {
62
62
  return [props, {
63
- className: cx("".concat(blockClass, "__select-all-toggle-on"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft && windowSize > 671))
63
+ className: cx(["".concat(blockClass, "-toggle-on"), _defineProperty({}, "".concat(blockClass, "-sticky-left"), isFirstColumnStickyLeft && windowSize > 671)])
64
64
  }];
65
65
  }
66
66
  return [props];
@@ -3,24 +3,25 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
5
5
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
- var _excluded = ["onChange"];
6
+ var _excluded = ["onChange", "title"];
7
7
  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; }
8
8
  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; }
9
- /*
10
- * Licensed Materials - Property of IBM
11
- * 5724-Q36
12
- * (c) Copyright IBM Corp. 2023
13
- * US Government Users Restricted Rights - Use, duplication or disclosure
14
- * restricted by GSA ADP Schedule Contract with IBM Corp.
9
+ /**
10
+ * Copyright IBM Corp. 2020, 2023
11
+ *
12
+ * This source code is licensed under the Apache-2.0 license found in the
13
+ * LICENSE file in the root directory of this source tree.
15
14
  */
16
- // @flow
15
+
17
16
  import React, { useLayoutEffect, useState } from 'react';
18
17
  import cx from 'classnames';
19
18
  import { TableSelectRow } from 'carbon-components-react';
20
19
  import { SelectAll } from './Datagrid/DatagridSelectAll';
21
20
  import { selectionColumnId } from './common-column-ids';
22
21
  import { pkg, carbon } from '../../settings';
22
+ import { handleToggleRowSelected } from './Datagrid/addons/stateReducer';
23
23
  var blockClass = "".concat(pkg.prefix, "--datagrid");
24
+ var checkboxClass = "".concat(blockClass, "__checkbox-cell");
24
25
  var useSelectRows = function useSelectRows(hooks) {
25
26
  useHighlightSelection(hooks);
26
27
  var useInstance = function useInstance(instance) {
@@ -41,7 +42,14 @@ var useSelectRows = function useSelectRows(hooks) {
41
42
  });
42
43
  });
43
44
  hooks.visibleColumns.push(function (columns) {
44
- return [{
45
+ // Ensures that the first column is the row expander in the
46
+ // case of selected rows and expandable rows being used together
47
+ var newColOrder = _toConsumableArray(columns);
48
+ var expanderColumnIndex = newColOrder.findIndex(function (col) {
49
+ return col.id === 'expander';
50
+ });
51
+ var expanderCol = expanderColumnIndex > -1 ? newColOrder.splice(expanderColumnIndex, 1) : [];
52
+ return [].concat(_toConsumableArray(expanderColumnIndex > -1 && expanderCol && expanderCol.length ? expanderCol : []), [{
45
53
  id: selectionColumnId,
46
54
  Header: function Header(gridState) {
47
55
  return /*#__PURE__*/React.createElement(SelectAll, gridState);
@@ -49,14 +57,17 @@ var useSelectRows = function useSelectRows(hooks) {
49
57
  Cell: function Cell(gridState) {
50
58
  return /*#__PURE__*/React.createElement(SelectRow, gridState);
51
59
  }
52
- }].concat(_toConsumableArray(columns));
60
+ }], _toConsumableArray(newColOrder));
53
61
  });
54
62
  };
55
63
  var useHighlightSelection = function useHighlightSelection(hooks) {
56
64
  var getRowProps = function getRowProps(props, _ref) {
65
+ var _ref2;
57
66
  var row = _ref.row;
67
+ var _row$getToggleRowSele = row.getToggleRowSelectedProps(),
68
+ checked = _row$getToggleRowSele.checked;
58
69
  return [props, {
59
- className: cx("".concat(blockClass, "__carbon-row"), row.getToggleRowSelectedProps().checked ? "".concat(carbon.prefix, "--data-table--selected ").concat(blockClass, "__active-row") : '')
70
+ className: cx(["".concat(blockClass, "__carbon-row"), (_ref2 = {}, _defineProperty(_ref2, "".concat(carbon.prefix, "--data-table--selected"), checked), _defineProperty(_ref2, "".concat(blockClass, "__active-row"), checked), _ref2)])
60
71
  }];
61
72
  };
62
73
  hooks.getRowProps.push(getRowProps);
@@ -73,7 +84,9 @@ var SelectRow = function SelectRow(datagridState) {
73
84
  onRadioSelect = datagridState.onRadioSelect,
74
85
  onRowSelect = datagridState.onRowSelect,
75
86
  columns = datagridState.columns,
76
- withStickyColumn = datagridState.withStickyColumn;
87
+ withStickyColumn = datagridState.withStickyColumn,
88
+ dispatch = datagridState.dispatch,
89
+ getRowId = datagridState.getRowId;
77
90
  var _useState = useState(window.innerWidth),
78
91
  _useState2 = _slicedToArray(_useState, 2),
79
92
  windowSize = _useState2[0],
@@ -88,28 +101,37 @@ var SelectRow = function SelectRow(datagridState) {
88
101
  };
89
102
  }, []);
90
103
  var selectDisabled = isFetching || row.getRowProps().selectDisabled;
91
- var _row$getToggleRowSele = row.getToggleRowSelectedProps(),
92
- onChange = _row$getToggleRowSele.onChange,
93
- selectProps = _objectWithoutProperties(_row$getToggleRowSele, _excluded);
104
+ var _row$getToggleRowSele2 = row.getToggleRowSelectedProps(),
105
+ onChange = _row$getToggleRowSele2.onChange,
106
+ title = _row$getToggleRowSele2.title,
107
+ selectProps = _objectWithoutProperties(_row$getToggleRowSele2, _excluded);
94
108
  var cellProps = cell.getCellProps();
95
109
  var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
110
+ var onSelectHandler = function onSelectHandler(event) {
111
+ event.stopPropagation(); // avoid triggering onRowClick
112
+ if (radio) {
113
+ toggleAllRowsSelected(false);
114
+ if (onRadioSelect) {
115
+ onRadioSelect(row);
116
+ }
117
+ }
118
+ onChange(event);
119
+ onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(row, event);
120
+ handleToggleRowSelected({
121
+ dispatch: dispatch,
122
+ rowData: row,
123
+ isChecked: event.target.checked,
124
+ getRowId: getRowId
125
+ });
126
+ };
127
+ var rowId = "".concat(tableId, "-").concat(row.index);
96
128
  return /*#__PURE__*/React.createElement(TableSelectRow, _extends({}, cellProps, selectProps, {
97
129
  radio: radio,
98
- onSelect: function onSelect(e) {
99
- e.stopPropagation(); // avoid triggering onRowClick
100
- if (radio) {
101
- toggleAllRowsSelected(false);
102
- if (onRadioSelect) {
103
- onRadioSelect(row);
104
- }
105
- }
106
- onChange(e);
107
- onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(row, e);
108
- },
109
- id: "".concat(tableId, "-").concat(row.index),
110
- name: "".concat(tableId, "-").concat(row.index, "-name"),
111
- className: cx("".concat(blockClass, "__checkbox-cell"), cellProps.className, _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft && windowSize > 671)),
112
- ariaLabel: "".concat(tableId, "-row-").concat(row.index) // TODO: aria label should be i18n'ed
130
+ onSelect: onSelectHandler,
131
+ id: rowId,
132
+ name: "".concat(rowId, "-name"),
133
+ className: cx(["".concat(checkboxClass, "__checkbox-cell"), cellProps.className, _defineProperty({}, "".concat(checkboxClass, "-sticky-left"), isFirstColumnStickyLeft && windowSize > 671)]),
134
+ ariaLabel: title // TODO: aria label should be i18n'ed
113
135
  ,
114
136
  disabled: selectDisabled
115
137
  }));
@@ -1,11 +1,11 @@
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 useSkeletons = function useSkeletons(hooks) {
10
10
  var useInstance = function useInstance(instance) {
11
11
  var isFetching = instance.isFetching,
@@ -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
  }
@@ -42,9 +41,9 @@ var getAriaSortValue = function getAriaSortValue(col, _ref) {
42
41
  }
43
42
  };
44
43
  var useSortableColumns = function useSortableColumns(hooks) {
45
- var sortableVisibleColumns = function sortableVisibleColumns(visibleColumns, _ref3) {
44
+ var sortableVisibleColumns = function sortableVisibleColumns(visibleColumns, _ref2) {
46
45
  var _instance$customizeCo;
47
- var instance = _ref3.instance;
46
+ var instance = _ref2.instance;
48
47
  var onSort = instance.onSort,
49
48
  ascendingSortableLabelText = instance.ascendingSortableLabelText,
50
49
  descendingSortableLabelText = instance.descendingSortableLabelText,