@carbon/ibm-products 2.0.0-rc.10 → 2.0.0-rc.11
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +102 -1
- 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.css +102 -1
- 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 +93 -1
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -4
- package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +6 -4
- package/es/components/Datagrid/Datagrid/Datagrid.js +7 -3
- package/es/components/Datagrid/Datagrid/DatagridContent.js +8 -3
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +17 -4
- package/es/components/Datagrid/Datagrid/DatagridRow.js +2 -10
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -4
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +29 -8
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +424 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +83 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +20 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +22 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/index.js +7 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +38 -0
- package/es/components/Datagrid/index.js +2 -1
- package/es/components/Datagrid/useFiltering.js +90 -0
- package/es/components/Datagrid/useParentDimensions.js +3 -1
- package/es/components/Datagrid/utils/DatagridActions.js +13 -26
- package/es/components/Datagrid/utils/getArgTypes.js +5 -0
- package/es/components/Datagrid/utils/getInlineEditColumns.js +6 -1
- package/es/components/Datagrid/utils/makeData.js +24 -16
- package/es/components/FilterSummary/FilterSummary.js +54 -0
- package/es/components/FilterSummary/index.js +7 -0
- package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -4
- package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +6 -4
- package/lib/components/Datagrid/Datagrid/Datagrid.js +8 -3
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +8 -3
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +17 -4
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +2 -19
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +24 -3
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +31 -8
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +443 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +104 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +35 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +33 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/index.js +15 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +47 -0
- package/lib/components/Datagrid/index.js +9 -1
- package/lib/components/Datagrid/useFiltering.js +94 -0
- package/lib/components/Datagrid/useParentDimensions.js +3 -1
- package/lib/components/Datagrid/utils/DatagridActions.js +13 -25
- package/lib/components/Datagrid/utils/getArgTypes.js +5 -0
- package/lib/components/Datagrid/utils/getInlineEditColumns.js +6 -1
- package/lib/components/Datagrid/utils/makeData.js +26 -18
- package/lib/components/FilterSummary/FilterSummary.js +72 -0
- package/lib/components/FilterSummary/index.js +15 -0
- package/package.json +2 -2
- package/scss/components/Datagrid/_datagrid.scss +0 -1
- package/scss/components/Datagrid/_storybook-styles.scss +12 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +18 -0
- package/scss/components/Datagrid/styles/_index.scss +1 -0
- package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +87 -0
- package/scss/components/FilterSummary/_filter-summary.scss +20 -0
- package/scss/components/FilterSummary/_index.scss +10 -0
- package/scss/components/FilterSummary/_storybook-styles.scss +14 -0
- package/scss/components/_index.scss +1 -0
@@ -202,10 +202,7 @@ export var DataSpreadsheet = /*#__PURE__*/React.forwardRef(function (_ref, ref)
|
|
202
202
|
|
203
203
|
var removeActiveCell = useCallback(function () {
|
204
204
|
var activeCellHighlight = spreadsheetRef.current.querySelector(".".concat(blockClass, "__active-cell--highlight"));
|
205
|
-
|
206
|
-
if (activeCellHighlight) {
|
207
|
-
activeCellHighlight.style.display = 'none';
|
208
|
-
}
|
205
|
+
activeCellHighlight.style.display = 'none';
|
209
206
|
}, [spreadsheetRef]);
|
210
207
|
var removeCellEditor = useCallback(function () {
|
211
208
|
setCellEditorValue('');
|
@@ -7,6 +7,8 @@
|
|
7
7
|
import { deepCloneObject } from '../../../global/js/utils/deepCloneObject';
|
8
8
|
import { rangeWithCallback } from '../../../global/js/utils/rangeWithCallback';
|
9
9
|
export var handleCellDeletion = function handleCellDeletion(_ref) {
|
10
|
+
var _selectionAreaToEmpty, _selectionAreaToEmpty2, _selectionAreaToEmpty3, _selectionAreaToEmpty4, _selectionAreaToEmpty5, _selectionAreaToEmpty6, _selectionAreaToEmpty7, _selectionAreaToEmpty8;
|
11
|
+
|
10
12
|
var activeCellCoordinates = _ref.activeCellCoordinates,
|
11
13
|
selectionAreas = _ref.selectionAreas,
|
12
14
|
currentMatcher = _ref.currentMatcher,
|
@@ -26,10 +28,10 @@ export var handleCellDeletion = function handleCellDeletion(_ref) {
|
|
26
28
|
return item.matcher === currentMatcher;
|
27
29
|
});
|
28
30
|
var selectionAreaToEmptyContents = selectionAreaClone[indexOfCurrentSelectionArea];
|
29
|
-
var lowestColumnIndex = Math.min(selectionAreaToEmptyContents.point1.column, selectionAreaToEmptyContents.point2.column);
|
30
|
-
var greatestColumnIndex = Math.max(selectionAreaToEmptyContents.point1.column, selectionAreaToEmptyContents.point2.column);
|
31
|
-
var lowestRowIndex = Math.min(selectionAreaToEmptyContents.point1.row, selectionAreaToEmptyContents.point2.row);
|
32
|
-
var greatestRowIndex = Math.max(selectionAreaToEmptyContents.point1.row, selectionAreaToEmptyContents.point2.row);
|
31
|
+
var lowestColumnIndex = Math.min(selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty = selectionAreaToEmptyContents.point1) === null || _selectionAreaToEmpty === void 0 ? void 0 : _selectionAreaToEmpty.column, selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty2 = selectionAreaToEmptyContents.point2) === null || _selectionAreaToEmpty2 === void 0 ? void 0 : _selectionAreaToEmpty2.column);
|
32
|
+
var greatestColumnIndex = Math.max(selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty3 = selectionAreaToEmptyContents.point1) === null || _selectionAreaToEmpty3 === void 0 ? void 0 : _selectionAreaToEmpty3.column, selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty4 = selectionAreaToEmptyContents.point2) === null || _selectionAreaToEmpty4 === void 0 ? void 0 : _selectionAreaToEmpty4.column);
|
33
|
+
var lowestRowIndex = Math.min(selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty5 = selectionAreaToEmptyContents.point1) === null || _selectionAreaToEmpty5 === void 0 ? void 0 : _selectionAreaToEmpty5.row, selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty6 = selectionAreaToEmptyContents.point2) === null || _selectionAreaToEmpty6 === void 0 ? void 0 : _selectionAreaToEmpty6.row);
|
34
|
+
var greatestRowIndex = Math.max(selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty7 = selectionAreaToEmptyContents.point1) === null || _selectionAreaToEmpty7 === void 0 ? void 0 : _selectionAreaToEmpty7.row, selectionAreaToEmptyContents === null || selectionAreaToEmptyContents === void 0 ? void 0 : (_selectionAreaToEmpty8 = selectionAreaToEmptyContents.point2) === null || _selectionAreaToEmpty8 === void 0 ? void 0 : _selectionAreaToEmpty8.row);
|
33
35
|
rangeWithCallback(lowestColumnIndex, greatestColumnIndex, function (columnIndex) {
|
34
36
|
rangeWithCallback(lowestRowIndex, greatestRowIndex, function (rowIndex) {
|
35
37
|
var cellProps = rows[rowIndex].cells[columnIndex];
|
@@ -16,6 +16,7 @@ import { pkg } from '../../../settings';
|
|
16
16
|
import pconsole from '../../../global/js/utils/pconsole';
|
17
17
|
import { InlineEditProvider } from './addons/InlineEdit/InlineEditContext';
|
18
18
|
import { DatagridContent } from './DatagridContent';
|
19
|
+
import { FilterProvider } from './addons/Filtering/FilterProvider';
|
19
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
21
|
var componentName = 'Datagrid';
|
21
22
|
export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
@@ -32,9 +33,12 @@ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
32
33
|
isFetching = datagridState.isFetching,
|
33
34
|
tableId = datagridState.tableId,
|
34
35
|
leftPanel = datagridState.leftPanel,
|
35
|
-
className = datagridState.className
|
36
|
+
className = datagridState.className,
|
37
|
+
filters = datagridState.state.filters;
|
36
38
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
37
|
-
return /*#__PURE__*/React.createElement(
|
39
|
+
return /*#__PURE__*/React.createElement(FilterProvider, {
|
40
|
+
filters: filters
|
41
|
+
}, /*#__PURE__*/React.createElement(InlineEditProvider, null, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
38
42
|
id: tableId,
|
39
43
|
ref: ref,
|
40
44
|
className: cx(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"), !isFetching && rows.length === 0 ? "".concat(blockClass, "__empty-state") : '')
|
@@ -44,7 +48,7 @@ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
44
48
|
datagridState: datagridState
|
45
49
|
})), leftPanel === undefined && /*#__PURE__*/React.createElement(DatagridContent, {
|
46
50
|
datagridState: datagridState
|
47
|
-
})));
|
51
|
+
}))));
|
48
52
|
}); // Return a placeholder if not released and not enabled by feature flag
|
49
53
|
|
50
54
|
Datagrid = pkg.checkComponentEnabled(Datagrid, componentName); // The display name of the component, used by React. Note that displayName
|
@@ -44,7 +44,8 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
44
44
|
withInlineEdit = datagridState.withInlineEdit,
|
45
45
|
tableId = datagridState.tableId,
|
46
46
|
DatagridActions = datagridState.DatagridActions,
|
47
|
-
totalColumnsWidth = datagridState.totalColumnsWidth
|
47
|
+
totalColumnsWidth = datagridState.totalColumnsWidth,
|
48
|
+
gridRef = datagridState.gridRef;
|
48
49
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
49
50
|
var gridActive = state.gridActive,
|
50
51
|
editId = state.editId;
|
@@ -88,7 +89,7 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
88
89
|
onFocus: withInlineEdit ? function () {
|
89
90
|
return handleGridFocus(state, dispatch);
|
90
91
|
} : null
|
91
|
-
}), /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
92
|
+
}), !withVirtualScroll ? /*#__PURE__*/React.createElement(DatagridHead, datagridState) : null, /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
92
93
|
rows: rows
|
93
94
|
})));
|
94
95
|
};
|
@@ -126,6 +127,9 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
126
127
|
className: "".concat(blockClass, "__datagridLeftPanel")
|
127
128
|
}, leftPanel.panelContent), withInlineEdit ? /*#__PURE__*/React.createElement("div", {
|
128
129
|
ref: multiKeyTrackingRef
|
130
|
+
}, renderTable()) : withVirtualScroll ? /*#__PURE__*/React.createElement("div", {
|
131
|
+
className: "".concat(blockClass, "__virtualScrollContainer"),
|
132
|
+
ref: gridRef
|
129
133
|
}, renderTable()) : renderTable())), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
|
130
134
|
instance: datagridState
|
131
135
|
}));
|
@@ -149,6 +153,7 @@ DatagridContent.propTypes = {
|
|
149
153
|
page: PropTypes.arrayOf(PropTypes.object),
|
150
154
|
rows: PropTypes.arrayOf(PropTypes.object),
|
151
155
|
tableId: PropTypes.string,
|
152
|
-
totalColumnsWidth: PropTypes.number
|
156
|
+
totalColumnsWidth: PropTypes.number,
|
157
|
+
gridRef: PropTypes.object
|
153
158
|
})
|
154
159
|
};
|
@@ -10,7 +10,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
10
10
|
import React from 'react';
|
11
11
|
import { pkg } from '../../../settings';
|
12
12
|
import { DataTable } from '@carbon/react';
|
13
|
-
import { NoDataEmptyState } from '../../EmptyStates
|
13
|
+
import { NoDataEmptyState, ErrorEmptyState } from '../../EmptyStates';
|
14
14
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
15
15
|
var TableBody = DataTable.TableBody,
|
16
16
|
TableRow = DataTable.TableRow,
|
@@ -22,16 +22,29 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
|
|
22
22
|
emptyStateTitle = datagridState.emptyStateTitle,
|
23
23
|
emptyStateDescription = datagridState.emptyStateDescription,
|
24
24
|
emptyStateSize = datagridState.emptyStateSize,
|
25
|
-
|
25
|
+
_datagridState$emptyS = datagridState.emptyStateType,
|
26
|
+
emptyStateType = _datagridState$emptyS === void 0 ? 'noData' : _datagridState$emptyS,
|
27
|
+
illustrationTheme = datagridState.illustrationTheme,
|
28
|
+
emptyStateAction = datagridState.emptyStateAction,
|
29
|
+
emptyStateLink = datagridState.emptyStateLink;
|
26
30
|
return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
|
27
31
|
className: "".concat(blockClass, "__empty-state-body")
|
28
32
|
}), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
|
29
33
|
colSpan: headers.length
|
30
|
-
}, /*#__PURE__*/React.createElement(
|
34
|
+
}, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, {
|
31
35
|
illustrationTheme: illustrationTheme,
|
32
36
|
size: emptyStateSize,
|
33
37
|
title: emptyStateTitle,
|
34
|
-
subtitle: emptyStateDescription
|
38
|
+
subtitle: emptyStateDescription,
|
39
|
+
action: emptyStateAction,
|
40
|
+
link: emptyStateLink
|
41
|
+
}), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, {
|
42
|
+
illustrationTheme: illustrationTheme,
|
43
|
+
size: emptyStateSize,
|
44
|
+
title: emptyStateTitle,
|
45
|
+
subtitle: emptyStateDescription,
|
46
|
+
action: emptyStateAction,
|
47
|
+
link: emptyStateLink
|
35
48
|
}))));
|
36
49
|
};
|
37
50
|
|
@@ -11,14 +11,12 @@ var _excluded = ["children"];
|
|
11
11
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
12
12
|
*/
|
13
13
|
// @flow
|
14
|
-
import React
|
14
|
+
import React from 'react';
|
15
15
|
import { DataTable, SkeletonText } from '@carbon/react';
|
16
16
|
import { px } from '@carbon/layout';
|
17
17
|
import { selectionColumnId } from '../common-column-ids';
|
18
18
|
import cx from 'classnames';
|
19
19
|
import { pkg, carbon } from '../../../settings';
|
20
|
-
import { InlineEditContext } from './addons/InlineEdit/InlineEditContext/InlineEditContext';
|
21
|
-
import { getCellIdAsObject } from './addons/InlineEdit/InlineEditContext/getCellIdAsObject';
|
22
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
23
21
|
var TableRow = DataTable.TableRow,
|
24
22
|
TableCell = DataTable.TableCell;
|
@@ -37,12 +35,6 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
37
35
|
rowSize = datagridState.rowSize,
|
38
36
|
withNestedRows = datagridState.withNestedRows;
|
39
37
|
|
40
|
-
var _useContext = useContext(InlineEditContext),
|
41
|
-
state = _useContext.state;
|
42
|
-
|
43
|
-
var activeCellId = state.activeCellId;
|
44
|
-
var activeCellObject = activeCellId && getCellIdAsObject(activeCellId);
|
45
|
-
|
46
38
|
var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
|
47
39
|
var isExpanded = _ref.isExpanded,
|
48
40
|
subRows = _ref.subRows;
|
@@ -59,7 +51,7 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
59
51
|
};
|
60
52
|
|
61
53
|
return /*#__PURE__*/React.createElement(TableRow, _extends({
|
62
|
-
className: cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected),
|
54
|
+
className: cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx))
|
63
55
|
}, row.getRowProps(), {
|
64
56
|
key: row.id,
|
65
57
|
onMouseEnter: function onMouseEnter(event) {
|
@@ -7,13 +7,16 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
7
|
* This source code is licensed under the Apache-2.0 license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
-
import React, { useEffect, useState } from 'react';
|
10
|
+
import React, { useEffect, useState, useContext } from 'react';
|
11
11
|
import { Add, OverflowMenuVertical } from '@carbon/react/icons';
|
12
12
|
import { DataTable, TableBatchActions, TableBatchAction } from '@carbon/react';
|
13
13
|
import { useResizeDetector } from 'react-resize-detector';
|
14
14
|
import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
|
15
15
|
import { pkg, carbon } from '../../../settings';
|
16
16
|
import cx from 'classnames';
|
17
|
+
import { FilterSummary } from '../../FilterSummary';
|
18
|
+
import { FilterContext } from './addons/Filtering/FilterProvider';
|
19
|
+
import { CLEAR_FILTERS } from './addons/Filtering/constants';
|
17
20
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
21
|
var TableToolbar = DataTable.TableToolbar;
|
19
22
|
|
@@ -141,13 +144,28 @@ var DatagridToolbar = function DatagridToolbar(datagridState) {
|
|
141
144
|
|
142
145
|
var DatagridActions = datagridState.DatagridActions,
|
143
146
|
DatagridBatchActions = datagridState.DatagridBatchActions,
|
144
|
-
batchActions = datagridState.batchActions
|
147
|
+
batchActions = datagridState.batchActions,
|
148
|
+
state = datagridState.state;
|
149
|
+
|
150
|
+
var _useContext = useContext(FilterContext),
|
151
|
+
filterTags = _useContext.filterTags,
|
152
|
+
EventEmitter = _useContext.EventEmitter;
|
153
|
+
|
154
|
+
var renderFilterSummary = function renderFilterSummary() {
|
155
|
+
return state.filters.length > 0 && /*#__PURE__*/React.createElement(FilterSummary, {
|
156
|
+
filters: filterTags,
|
157
|
+
clearFilters: function clearFilters() {
|
158
|
+
return EventEmitter.dispatch(CLEAR_FILTERS);
|
159
|
+
}
|
160
|
+
});
|
161
|
+
};
|
162
|
+
|
145
163
|
return batchActions && DatagridActions ? /*#__PURE__*/React.createElement("div", {
|
146
164
|
ref: ref,
|
147
165
|
className: "".concat(blockClass, "__table-toolbar")
|
148
|
-
}, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActionsToolbar && DatagridBatchActionsToolbar(datagridState, width, ref))) : DatagridActions ? /*#__PURE__*/React.createElement("div", {
|
166
|
+
}, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActionsToolbar && DatagridBatchActionsToolbar(datagridState, width, ref)), renderFilterSummary()) : DatagridActions ? /*#__PURE__*/React.createElement("div", {
|
149
167
|
className: "".concat(blockClass, "__table-toolbar")
|
150
|
-
}, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState))) : null;
|
168
|
+
}, /*#__PURE__*/React.createElement(TableToolbar, null, DatagridActions && DatagridActions(datagridState), DatagridBatchActions && DatagridBatchActions(datagridState)), renderFilterSummary()) : null;
|
151
169
|
};
|
152
170
|
|
153
171
|
export default DatagridToolbar;
|
@@ -16,6 +16,8 @@ import React, { useEffect } from 'react';
|
|
16
16
|
import { VariableSizeList } from 'react-window';
|
17
17
|
import { DataTable } from '@carbon/react';
|
18
18
|
import { pkg } from '../../../settings';
|
19
|
+
import DatagridHead from './DatagridHead';
|
20
|
+
import { px } from '@carbon/layout';
|
19
21
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
22
|
var TableBody = DataTable.TableBody;
|
21
23
|
var rowSizeMap = {
|
@@ -33,6 +35,8 @@ var rowSizeMap = {
|
|
33
35
|
var defaultRowHeight = rowSizeMap.lg;
|
34
36
|
|
35
37
|
var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
38
|
+
var _gridRef$current, _gridRef$current2;
|
39
|
+
|
36
40
|
var getTableBodyProps = datagridState.getTableBodyProps,
|
37
41
|
rows = datagridState.rows,
|
38
42
|
prepareRow = datagridState.prepareRow,
|
@@ -46,7 +50,15 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
46
50
|
DatagridPagination = datagridState.DatagridPagination,
|
47
51
|
page = datagridState.page,
|
48
52
|
handleResize = datagridState.handleResize,
|
49
|
-
|
53
|
+
gridRef = datagridState.gridRef;
|
54
|
+
|
55
|
+
var syncScroll = function syncScroll(e) {
|
56
|
+
var virtualBody = e.target;
|
57
|
+
document.querySelector(".".concat(blockClass, "__head-warp")).scrollLeft = virtualBody.scrollLeft;
|
58
|
+
var spacerColumn = document.querySelector(".".concat(blockClass, "__head-warp thead th:last-child"));
|
59
|
+
spacerColumn.style.width = px(32 + (virtualBody.offsetWidth - virtualBody.clientWidth)); // scrollbar width to header column to fix header alignment
|
60
|
+
};
|
61
|
+
|
50
62
|
useEffect(function () {
|
51
63
|
handleResize();
|
52
64
|
}, [handleResize]);
|
@@ -57,8 +69,16 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
57
69
|
}
|
58
70
|
|
59
71
|
var visibleRows = DatagridPagination && page || rows;
|
60
|
-
return /*#__PURE__*/React.createElement(
|
61
|
-
|
72
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
73
|
+
className: "".concat(blockClass, "__head-warp"),
|
74
|
+
style: {
|
75
|
+
width: (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth,
|
76
|
+
overflow: 'hidden'
|
77
|
+
}
|
78
|
+
}, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
|
79
|
+
onScroll: function onScroll(e) {
|
80
|
+
return syncScroll(e);
|
81
|
+
}
|
62
82
|
}), /*#__PURE__*/React.createElement(VariableSizeList, {
|
63
83
|
height: virtualHeight || tableHeight,
|
64
84
|
itemCount: visibleRows.length,
|
@@ -69,20 +89,21 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
69
89
|
onScroll: onScroll,
|
70
90
|
innerRef: innerListRef,
|
71
91
|
ref: listRef,
|
72
|
-
className: "".concat(blockClass, "__virtual-scrollbar")
|
92
|
+
className: "".concat(blockClass, "__virtual-scrollbar"),
|
93
|
+
style: {
|
94
|
+
width: (_gridRef$current2 = gridRef.current) === null || _gridRef$current2 === void 0 ? void 0 : _gridRef$current2.clientWidth
|
95
|
+
}
|
73
96
|
}, function (_ref) {
|
74
97
|
var index = _ref.index,
|
75
98
|
style = _ref.style;
|
76
99
|
var row = visibleRows[index];
|
77
100
|
prepareRow(row);
|
78
101
|
return /*#__PURE__*/React.createElement("div", {
|
79
|
-
style: _objectSpread(
|
80
|
-
overflow: withOverflowRow ? 'visible' : 'hidden'
|
81
|
-
})
|
102
|
+
style: _objectSpread({}, style)
|
82
103
|
}, row.RowRenderer(_objectSpread(_objectSpread({}, datagridState), {}, {
|
83
104
|
row: row
|
84
105
|
})));
|
85
|
-
}));
|
106
|
+
})));
|
86
107
|
};
|
87
108
|
|
88
109
|
export default DatagridVirtualBody;
|