@carbon/ibm-products 1.62.0 → 1.62.1
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +16 -2
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +15 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +16 -2
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +16 -2
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/Carousel/Carousel.js +194 -119
- package/es/components/Carousel/CarouselItem.js +8 -21
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +6 -7
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
- package/es/components/Datagrid/Datagrid/DatagridRow.js +19 -10
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +19 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +15 -1
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +67 -24
- package/es/components/Datagrid/useExpandedRow.js +3 -6
- package/es/components/Datagrid/useFocusRowExpander.js +40 -0
- package/es/components/Datagrid/useNestedRowExpander.js +9 -0
- package/es/components/Datagrid/useNestedRows.js +0 -4
- package/es/components/Datagrid/useRowExpander.js +9 -0
- package/es/components/Datagrid/useSelectRows.js +23 -11
- package/es/components/Guidebanner/Guidebanner.js +9 -12
- package/es/global/js/package-settings.js +0 -2
- package/lib/components/Carousel/Carousel.js +190 -114
- package/lib/components/Carousel/CarouselItem.js +9 -25
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +6 -7
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +13 -3
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +19 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +15 -1
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +70 -26
- package/lib/components/Datagrid/useExpandedRow.js +2 -5
- package/lib/components/Datagrid/useFocusRowExpander.js +46 -0
- package/lib/components/Datagrid/useNestedRowExpander.js +9 -0
- package/lib/components/Datagrid/useNestedRows.js +0 -4
- package/lib/components/Datagrid/useRowExpander.js +9 -0
- package/lib/components/Datagrid/useSelectRows.js +17 -4
- package/lib/components/Guidebanner/Guidebanner.js +9 -12
- package/lib/global/js/package-settings.js +0 -2
- package/package.json +2 -2
- package/scss/components/Carousel/_carousel.scss +1 -2
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +21 -0
- package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -0
- package/es/components/Carousel/utils.js +0 -98
- package/lib/components/Carousel/utils.js +0 -108
@@ -14,6 +14,7 @@ import { useResizeObserver } from '../../../global/js/hooks/useResizeObserver';
|
|
14
14
|
import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
|
15
15
|
import { pkg, carbon } from '../../../settings';
|
16
16
|
import cx from 'classnames';
|
17
|
+
import { handleSelectAllRowData } from './addons/stateReducer';
|
17
18
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
19
|
var toolbarClass = "".concat(blockClass, "__table-toolbar");
|
19
20
|
var menuClass = "".concat(blockClass, "__button-menu");
|
@@ -35,8 +36,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
35
36
|
toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
|
36
37
|
toolbarBatchActions = datagridState.toolbarBatchActions,
|
37
38
|
setGlobalFilter = datagridState.setGlobalFilter,
|
39
|
+
dispatch = datagridState.dispatch,
|
40
|
+
getRowId = datagridState.getRowId,
|
38
41
|
batchActionMenuButtonLabel = datagridState.batchActionMenuButtonLabel,
|
39
|
-
translateWithIdBatchActions = datagridState.translateWithIdBatchActions
|
42
|
+
translateWithIdBatchActions = datagridState.translateWithIdBatchActions,
|
43
|
+
rows = datagridState.rows;
|
40
44
|
var batchActionMenuButtonLabelText = batchActionMenuButtonLabel !== null && batchActionMenuButtonLabel !== void 0 ? batchActionMenuButtonLabel : 'More';
|
41
45
|
var selectedKeys = Object.keys(selectedRowIds || {});
|
42
46
|
var totalSelected = selectedKeys.length;
|
@@ -84,6 +88,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
84
88
|
batchAction.onClick();
|
85
89
|
if (batchAction.type === 'select_all') {
|
86
90
|
toggleAllRowsSelected(true);
|
91
|
+
handleSelectAllRowData({
|
92
|
+
dispatch: dispatch,
|
93
|
+
rows: rows,
|
94
|
+
getRowId: getRowId
|
95
|
+
});
|
87
96
|
}
|
88
97
|
}
|
89
98
|
});
|
@@ -111,6 +120,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
111
120
|
batchAction.onClick();
|
112
121
|
if (batchAction.type === 'select_all') {
|
113
122
|
toggleAllRowsSelected(true);
|
123
|
+
handleSelectAllRowData({
|
124
|
+
dispatch: dispatch,
|
125
|
+
rows: rows,
|
126
|
+
getRowId: getRowId
|
127
|
+
});
|
114
128
|
}
|
115
129
|
},
|
116
130
|
iconDescription: batchAction.label
|
@@ -16,6 +16,7 @@ var COLUMN_RESIZING = 'columnResizing';
|
|
16
16
|
var COLUMN_RESIZE_END = 'columnDoneResizing';
|
17
17
|
var INIT = 'init';
|
18
18
|
var TOGGLE_ROW_SELECTED = 'toggleRowSelected';
|
19
|
+
var TOGGLE_ALL_ROWS_SELECTED = 'toggleAllRowsSelected';
|
19
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
21
|
export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId, isKeyEvent) {
|
21
22
|
dispatch({
|
@@ -47,35 +48,77 @@ export var handleColumnResizingEvent = function handleColumnResizingEvent(dispat
|
|
47
48
|
}
|
48
49
|
});
|
49
50
|
};
|
50
|
-
export var handleToggleRowSelected = function handleToggleRowSelected(
|
51
|
+
export var handleToggleRowSelected = function handleToggleRowSelected(_ref) {
|
52
|
+
var dispatch = _ref.dispatch,
|
53
|
+
rowData = _ref.rowData,
|
54
|
+
isChecked = _ref.isChecked,
|
55
|
+
getRowId = _ref.getRowId,
|
56
|
+
selectAll = _ref.selectAll;
|
51
57
|
return dispatch({
|
52
58
|
type: TOGGLE_ROW_SELECTED,
|
53
59
|
payload: {
|
54
60
|
rowData: rowData,
|
61
|
+
isChecked: isChecked,
|
62
|
+
getRowId: getRowId,
|
63
|
+
selectAll: selectAll
|
64
|
+
}
|
65
|
+
});
|
66
|
+
};
|
67
|
+
export var handleSelectAllRowData = function handleSelectAllRowData(_ref2) {
|
68
|
+
var dispatch = _ref2.dispatch,
|
69
|
+
rows = _ref2.rows,
|
70
|
+
getRowId = _ref2.getRowId,
|
71
|
+
indeterminate = _ref2.indeterminate,
|
72
|
+
isChecked = _ref2.isChecked;
|
73
|
+
return dispatch({
|
74
|
+
type: TOGGLE_ALL_ROWS_SELECTED,
|
75
|
+
payload: {
|
76
|
+
rows: rows,
|
77
|
+
getRowId: getRowId,
|
78
|
+
indeterminate: indeterminate,
|
55
79
|
isChecked: isChecked
|
56
80
|
}
|
57
81
|
});
|
58
82
|
};
|
59
83
|
export var stateReducer = function stateReducer(newState, action) {
|
60
84
|
switch (action.type) {
|
85
|
+
case TOGGLE_ALL_ROWS_SELECTED:
|
86
|
+
{
|
87
|
+
var _ref3 = action.payload || {},
|
88
|
+
rows = _ref3.rows,
|
89
|
+
getRowId = _ref3.getRowId,
|
90
|
+
indeterminate = _ref3.indeterminate,
|
91
|
+
isChecked = _ref3.isChecked;
|
92
|
+
if (rows) {
|
93
|
+
var newSelectedRowData = {};
|
94
|
+
rows.forEach(function (row) {
|
95
|
+
newSelectedRowData[getRowId(row, row.index)] = row;
|
96
|
+
});
|
97
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
98
|
+
selectedRowData: indeterminate || !isChecked ? {} : newSelectedRowData
|
99
|
+
});
|
100
|
+
}
|
101
|
+
return _objectSpread({}, newState);
|
102
|
+
}
|
61
103
|
case TOGGLE_ROW_SELECTED:
|
62
104
|
{
|
63
|
-
var
|
64
|
-
rowData =
|
65
|
-
|
105
|
+
var _ref4 = action.payload || {},
|
106
|
+
rowData = _ref4.rowData,
|
107
|
+
_isChecked = _ref4.isChecked,
|
108
|
+
_getRowId = _ref4.getRowId;
|
66
109
|
if (!rowData) {
|
67
110
|
return;
|
68
111
|
}
|
69
|
-
if (
|
112
|
+
if (_isChecked) {
|
70
113
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
71
|
-
selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, rowData.index, rowData))
|
114
|
+
selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, _getRowId(rowData, rowData.index), rowData))
|
72
115
|
});
|
73
116
|
}
|
74
|
-
if (rowData && !
|
117
|
+
if (rowData && !_isChecked) {
|
75
118
|
var newData = _objectSpread({}, newState.selectedRowData);
|
76
|
-
var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (
|
77
|
-
var
|
78
|
-
key =
|
119
|
+
var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (_ref5) {
|
120
|
+
var _ref6 = _slicedToArray(_ref5, 1),
|
121
|
+
key = _ref6[0];
|
79
122
|
return parseInt(key) !== parseInt(rowData.index);
|
80
123
|
}));
|
81
124
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
@@ -92,27 +135,27 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
92
135
|
}
|
93
136
|
case COLUMN_RESIZE_START:
|
94
137
|
{
|
95
|
-
var
|
96
|
-
headerId =
|
138
|
+
var _ref7 = action.payload || {},
|
139
|
+
headerId = _ref7.headerId;
|
97
140
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
98
141
|
isResizing: headerId
|
99
142
|
});
|
100
143
|
}
|
101
144
|
case COLUMN_RESIZING:
|
102
145
|
{
|
103
|
-
var
|
104
|
-
_headerId =
|
105
|
-
newWidth =
|
106
|
-
defaultWidth =
|
146
|
+
var _ref8 = action.payload || {},
|
147
|
+
_headerId = _ref8.headerId,
|
148
|
+
newWidth = _ref8.newWidth,
|
149
|
+
defaultWidth = _ref8.defaultWidth;
|
107
150
|
var newColumnWidth = {};
|
108
151
|
if (typeof _headerId === 'undefined') {
|
109
152
|
return _objectSpread({}, newState);
|
110
153
|
}
|
111
154
|
newColumnWidth[_headerId] = newWidth;
|
112
|
-
var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (
|
113
|
-
var
|
114
|
-
_ =
|
115
|
-
value =
|
155
|
+
var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref9) {
|
156
|
+
var _ref10 = _slicedToArray(_ref9, 2),
|
157
|
+
_ = _ref10[0],
|
158
|
+
value = _ref10[1];
|
116
159
|
return !isNaN(value);
|
117
160
|
}));
|
118
161
|
var headerIdArray = newState.columnResizing.headerIdWidths || [];
|
@@ -127,10 +170,10 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
127
170
|
}
|
128
171
|
case COLUMN_RESIZE_END:
|
129
172
|
{
|
130
|
-
var
|
131
|
-
onColResizeEnd =
|
132
|
-
_headerId2 =
|
133
|
-
isKeyEvent =
|
173
|
+
var _ref11 = action.payload || {},
|
174
|
+
onColResizeEnd = _ref11.onColResizeEnd,
|
175
|
+
_headerId2 = _ref11.headerId,
|
176
|
+
isKeyEvent = _ref11.isKeyEvent;
|
134
177
|
var currentColumn = {};
|
135
178
|
currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
|
136
179
|
var allChangedColumns = newState.columnResizing.columnWidths;
|
@@ -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 {
|
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);
|
@@ -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
|
+
};
|
@@ -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) {
|
@@ -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) || {},
|
@@ -6,14 +6,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
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
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
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
|
-
|
15
|
+
|
17
16
|
import React, { useLayoutEffect, useState } from 'react';
|
18
17
|
import cx from 'classnames';
|
19
18
|
import { TableSelectRow } from 'carbon-components-react';
|
@@ -43,7 +42,14 @@ var useSelectRows = function useSelectRows(hooks) {
|
|
43
42
|
});
|
44
43
|
});
|
45
44
|
hooks.visibleColumns.push(function (columns) {
|
46
|
-
|
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 : []), [{
|
47
53
|
id: selectionColumnId,
|
48
54
|
Header: function Header(gridState) {
|
49
55
|
return /*#__PURE__*/React.createElement(SelectAll, gridState);
|
@@ -51,7 +57,7 @@ var useSelectRows = function useSelectRows(hooks) {
|
|
51
57
|
Cell: function Cell(gridState) {
|
52
58
|
return /*#__PURE__*/React.createElement(SelectRow, gridState);
|
53
59
|
}
|
54
|
-
}]
|
60
|
+
}], _toConsumableArray(newColOrder));
|
55
61
|
});
|
56
62
|
};
|
57
63
|
var useHighlightSelection = function useHighlightSelection(hooks) {
|
@@ -79,7 +85,8 @@ var SelectRow = function SelectRow(datagridState) {
|
|
79
85
|
onRowSelect = datagridState.onRowSelect,
|
80
86
|
columns = datagridState.columns,
|
81
87
|
withStickyColumn = datagridState.withStickyColumn,
|
82
|
-
dispatch = datagridState.dispatch
|
88
|
+
dispatch = datagridState.dispatch,
|
89
|
+
getRowId = datagridState.getRowId;
|
83
90
|
var _useState = useState(window.innerWidth),
|
84
91
|
_useState2 = _slicedToArray(_useState, 2),
|
85
92
|
windowSize = _useState2[0],
|
@@ -110,7 +117,12 @@ var SelectRow = function SelectRow(datagridState) {
|
|
110
117
|
}
|
111
118
|
onChange(event);
|
112
119
|
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(row, event);
|
113
|
-
handleToggleRowSelected(
|
120
|
+
handleToggleRowSelected({
|
121
|
+
dispatch: dispatch,
|
122
|
+
rowData: row,
|
123
|
+
isChecked: event.target.checked,
|
124
|
+
getRowId: getRowId
|
125
|
+
});
|
114
126
|
};
|
115
127
|
var rowId = "".concat(tableId, "-").concat(row.index);
|
116
128
|
return /*#__PURE__*/React.createElement(TableSelectRow, _extends({}, cellProps, selectProps, {
|
@@ -74,9 +74,6 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
74
74
|
_useState6 = _slicedToArray(_useState5, 2),
|
75
75
|
isCollapsed = _useState6[0],
|
76
76
|
setIsCollapsed = _useState6[1];
|
77
|
-
var handleScrollableChange = function handleScrollableChange(value) {
|
78
|
-
setShowNavigation(value);
|
79
|
-
};
|
80
77
|
var handleClickToggle = function handleClickToggle() {
|
81
78
|
setScrollPosition(0);
|
82
79
|
scrollRef.current.scrollToView(0);
|
@@ -101,9 +98,13 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
101
98
|
left: blue90,
|
102
99
|
right: purple70
|
103
100
|
},
|
104
|
-
|
105
|
-
|
106
|
-
|
101
|
+
onChangeIsScrollable: function onChangeIsScrollable(value) {
|
102
|
+
setShowNavigation(value);
|
103
|
+
},
|
104
|
+
onScroll: function onScroll(scrollPercent) {
|
105
|
+
setScrollPosition(scrollPercent);
|
106
|
+
},
|
107
|
+
ref: scrollRef
|
107
108
|
}, children), /*#__PURE__*/React.createElement("div", {
|
108
109
|
className: cx([collapsible || showNavigation ? "".concat(blockClass, "__navigation") : null])
|
109
110
|
}, collapsible && /*#__PURE__*/React.createElement(Button, {
|
@@ -122,9 +123,7 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
122
123
|
tooltipPosition: "top",
|
123
124
|
iconDescription: previousIconDescription,
|
124
125
|
onClick: function onClick() {
|
125
|
-
scrollRef.current.scrollPrev()
|
126
|
-
return setScrollPosition(scrollPercentage);
|
127
|
-
});
|
126
|
+
scrollRef.current.scrollPrev();
|
128
127
|
}
|
129
128
|
}), /*#__PURE__*/React.createElement(Button, {
|
130
129
|
kind: "ghost",
|
@@ -137,9 +136,7 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
137
136
|
tooltipAlignment: "end",
|
138
137
|
iconDescription: nextIconDescription,
|
139
138
|
onClick: function onClick() {
|
140
|
-
scrollRef.current.scrollNext()
|
141
|
-
return setScrollPosition(scrollPercentage);
|
142
|
-
});
|
139
|
+
scrollRef.current.scrollNext();
|
143
140
|
}
|
144
141
|
}))), onClose && /*#__PURE__*/React.createElement(Button, {
|
145
142
|
className: "".concat(blockClass, "__close-button"),
|
@@ -95,8 +95,6 @@ var defaults = {
|
|
95
95
|
feature: {
|
96
96
|
'a-new-feature': false,
|
97
97
|
'default-portal-target-body': true,
|
98
|
-
'Datagrid.useExpandedRow': false,
|
99
|
-
'Datagrid.useNestedRows': false,
|
100
98
|
'Datagrid.useInlineEdit': false,
|
101
99
|
'Datagrid.useFiltering': false,
|
102
100
|
'Datagrid.useCustomizeColumns': false,
|