@carbon/ibm-products 2.0.0-rc.10 → 2.0.0-rc.12
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +131 -75
- 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 +1 -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 +131 -75
- 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 +121 -75
- 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/AddSelect/AddSelectBody.js +1 -1
- package/es/components/AddSelect/hooks/usePath.js +8 -1
- package/es/components/CreateFullPage/CreateFullPage.js +9 -2
- package/es/components/CreateTearsheet/CreateTearsheet.js +9 -2
- package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -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 +18 -6
- 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/CustomizeColumns/Actions.js +7 -10
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +11 -13
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +28 -27
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +31 -31
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +56 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +1 -1
- 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/useCustomizeColumns.js +8 -8
- 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/es/components/index.js +1 -1
- package/es/global/js/hooks/useCreateComponentFocus.js +38 -10
- package/lib/components/AddSelect/AddSelectBody.js +1 -1
- package/lib/components/AddSelect/hooks/usePath.js +7 -0
- package/lib/components/CreateFullPage/CreateFullPage.js +9 -2
- package/lib/components/CreateTearsheet/CreateTearsheet.js +9 -2
- package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -1
- 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 +17 -6
- 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/CustomizeColumns/Actions.js +7 -10
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +6 -6
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +30 -28
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +27 -25
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{ModalWrapper.js → TearsheetWrapper.js} +31 -36
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +3 -3
- 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/useCustomizeColumns.js +7 -7
- 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/lib/components/index.js +6 -0
- package/lib/global/js/hooks/useCreateComponentFocus.js +42 -11
- 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 +23 -0
- package/scss/components/Datagrid/styles/_draggableElement.scss +9 -8
- package/scss/components/Datagrid/styles/_index.scss +8 -8
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +65 -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/Tearsheet/_tearsheet.scss +2 -0
- package/scss/components/_index.scss +1 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +0 -63
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +0 -93
@@ -1,5 +1,12 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Copyright IBM Corp. 2022, 2022
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
3
10
|
import React, { useContext, useEffect, useRef } from 'react';
|
4
11
|
import cx from 'classnames';
|
5
12
|
import PropTypes from 'prop-types';
|
@@ -32,7 +39,7 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
32
39
|
withVirtualScroll = datagridState.withVirtualScroll,
|
33
40
|
DatagridPagination = datagridState.DatagridPagination,
|
34
41
|
isFetching = datagridState.isFetching,
|
35
|
-
|
42
|
+
CustomizeColumnsTearsheet = datagridState.CustomizeColumnsTearsheet,
|
36
43
|
leftPanel = datagridState.leftPanel,
|
37
44
|
fullHeightDatagrid = datagridState.fullHeightDatagrid,
|
38
45
|
_datagridState$vertic = datagridState.verticalAlign,
|
@@ -44,7 +51,8 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
44
51
|
withInlineEdit = datagridState.withInlineEdit,
|
45
52
|
tableId = datagridState.tableId,
|
46
53
|
DatagridActions = datagridState.DatagridActions,
|
47
|
-
totalColumnsWidth = datagridState.totalColumnsWidth
|
54
|
+
totalColumnsWidth = datagridState.totalColumnsWidth,
|
55
|
+
gridRef = datagridState.gridRef;
|
48
56
|
var rows = DatagridPagination && datagridState.page || datagridState.rows;
|
49
57
|
var gridActive = state.gridActive,
|
50
58
|
editId = state.editId;
|
@@ -88,7 +96,7 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
88
96
|
onFocus: withInlineEdit ? function () {
|
89
97
|
return handleGridFocus(state, dispatch);
|
90
98
|
} : null
|
91
|
-
}), /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
99
|
+
}), !withVirtualScroll ? /*#__PURE__*/React.createElement(DatagridHead, datagridState) : null, /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
92
100
|
rows: rows
|
93
101
|
})));
|
94
102
|
};
|
@@ -126,7 +134,10 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
126
134
|
className: "".concat(blockClass, "__datagridLeftPanel")
|
127
135
|
}, leftPanel.panelContent), withInlineEdit ? /*#__PURE__*/React.createElement("div", {
|
128
136
|
ref: multiKeyTrackingRef
|
129
|
-
}, renderTable()) :
|
137
|
+
}, renderTable()) : withVirtualScroll ? /*#__PURE__*/React.createElement("div", {
|
138
|
+
className: "".concat(blockClass, "__virtualScrollContainer"),
|
139
|
+
ref: gridRef
|
140
|
+
}, renderTable()) : renderTable())), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsTearsheet && /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, {
|
130
141
|
instance: datagridState
|
131
142
|
}));
|
132
143
|
};
|
@@ -136,7 +147,7 @@ DatagridContent.propTypes = {
|
|
136
147
|
withVirtualScroll: PropTypes.bool,
|
137
148
|
DatagridActions: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
138
149
|
DatagridPagination: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
139
|
-
|
150
|
+
CustomizeColumnsTearsheet: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
|
140
151
|
isFetching: PropTypes.bool,
|
141
152
|
leftPanel: PropTypes.object,
|
142
153
|
fullHeightDatagrid: PropTypes.bool,
|
@@ -149,6 +160,7 @@ DatagridContent.propTypes = {
|
|
149
160
|
page: PropTypes.arrayOf(PropTypes.object),
|
150
161
|
rows: PropTypes.arrayOf(PropTypes.object),
|
151
162
|
tableId: PropTypes.string,
|
152
|
-
totalColumnsWidth: PropTypes.number
|
163
|
+
totalColumnsWidth: PropTypes.number,
|
164
|
+
gridRef: PropTypes.object
|
153
165
|
})
|
154
166
|
};
|
@@ -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;
|
@@ -1,11 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
*
|
5
|
-
*
|
6
|
-
* (c) Copyright IBM Corp. 2021
|
7
|
-
* US Government Users Restricted Rights - Use, duplication or disclosure
|
8
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2022, 2022
|
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.
|
9
6
|
*/
|
10
7
|
import PropTypes from 'prop-types';
|
11
8
|
import { Search } from '@carbon/react';
|
@@ -18,11 +15,11 @@ var Actions = function Actions(_ref) {
|
|
18
15
|
setSearchText = _ref.setSearchText,
|
19
16
|
findColumnPlaceholderLabel = _ref.findColumnPlaceholderLabel;
|
20
17
|
return /*#__PURE__*/React.createElement("div", {
|
21
|
-
className: "".concat(blockClass, "__customize-columns-
|
18
|
+
className: "".concat(blockClass, "__customize-columns-tearsheet--actions")
|
22
19
|
}, /*#__PURE__*/React.createElement(Search, {
|
23
20
|
placeholder: findColumnPlaceholderLabel,
|
24
21
|
value: searchText,
|
25
|
-
size: "
|
22
|
+
size: "lg",
|
26
23
|
labelText: findColumnPlaceholderLabel,
|
27
24
|
onChange: function onChange(e) {
|
28
25
|
// TODO: is it performant?
|
@@ -1,14 +1,12 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
var _excluded = ["onClick", "
|
4
|
-
// @flow
|
3
|
+
var _excluded = ["onClick", "setIsTearsheetOpen", "isTearsheetOpen", "iconTooltipLabel"];
|
5
4
|
|
6
|
-
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2022, 2022
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
12
10
|
*/
|
13
11
|
import * as React from 'react';
|
14
12
|
import PropTypes from 'prop-types';
|
@@ -19,8 +17,8 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
|
|
19
17
|
|
20
18
|
var ButtonWrapper = function ButtonWrapper(_ref) {
|
21
19
|
var _onClick = _ref.onClick,
|
22
|
-
|
23
|
-
|
20
|
+
setIsTearsheetOpen = _ref.setIsTearsheetOpen,
|
21
|
+
isTearsheetOpen = _ref.isTearsheetOpen,
|
24
22
|
_ref$iconTooltipLabel = _ref.iconTooltipLabel,
|
25
23
|
iconTooltipLabel = _ref$iconTooltipLabel === void 0 ? 'Customize columns' : _ref$iconTooltipLabel,
|
26
24
|
rest = _objectWithoutProperties(_ref, _excluded);
|
@@ -37,7 +35,7 @@ var ButtonWrapper = function ButtonWrapper(_ref) {
|
|
37
35
|
hasIconOnly: true,
|
38
36
|
"test-id": "".concat(blockClass, "__customize-columns-trigger"),
|
39
37
|
onClick: function onClick() {
|
40
|
-
|
38
|
+
setIsTearsheetOpen(!isTearsheetOpen);
|
41
39
|
|
42
40
|
if (typeof _onClick === 'function') {
|
43
41
|
_onClick();
|
@@ -51,8 +49,8 @@ ButtonWrapper.defaultProps = {
|
|
51
49
|
};
|
52
50
|
ButtonWrapper.propTypes = {
|
53
51
|
iconTooltipLabel: PropTypes.string,
|
54
|
-
|
52
|
+
isTearsheetOpen: PropTypes.bool.isRequired,
|
55
53
|
onClick: PropTypes.func.isRequired,
|
56
|
-
|
54
|
+
setIsTearsheetOpen: PropTypes.func.isRequired
|
57
55
|
};
|
58
56
|
export default ButtonWrapper;
|
@@ -1,13 +1,11 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
-
// @flow
|
4
3
|
|
5
|
-
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
4
|
+
/**
|
5
|
+
* Copyright IBM Corp. 2022, 2022
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
11
9
|
*/
|
12
10
|
import React from 'react';
|
13
11
|
import PropTypes from 'prop-types';
|
@@ -36,8 +34,6 @@ var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
|
36
34
|
};
|
37
35
|
|
38
36
|
var Columns = function Columns(_ref) {
|
39
|
-
var _cx;
|
40
|
-
|
41
37
|
var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
|
42
38
|
filterString = _ref.filterString,
|
43
39
|
columns = _ref.columns,
|
@@ -80,12 +76,7 @@ var Columns = function Columns(_ref) {
|
|
80
76
|
e.stopPropagation();
|
81
77
|
}
|
82
78
|
},
|
83
|
-
tabIndex: 0
|
84
|
-
onFocus: function onFocus(e) {
|
85
|
-
if (e.target === e.currentTarget) {
|
86
|
-
setFocusIndex(0);
|
87
|
-
}
|
88
|
-
}
|
79
|
+
tabIndex: 0
|
89
80
|
}, /*#__PURE__*/React.createElement("span", {
|
90
81
|
"aria-live": "assertive",
|
91
82
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
@@ -94,7 +85,7 @@ var Columns = function Columns(_ref) {
|
|
94
85
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
95
86
|
}, filterString.length === 0 ? assistiveTextInstructionsLabel : assistiveTextDisabledInstructionsLabel), /*#__PURE__*/React.createElement("div", {
|
96
87
|
id: "".concat(blockClass, "__customize-columns-select-all"),
|
97
|
-
className: cx(
|
88
|
+
className: cx("".concat(blockClass, "__customize-columns-select-all"), _defineProperty({}, "".concat(blockClass, "__customize-columns-select-all--selected"), getVisibleColumnsCount() > 0)),
|
98
89
|
selected: getVisibleColumnsCount() > 0
|
99
90
|
}, /*#__PURE__*/React.createElement(Checkbox, {
|
100
91
|
className: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
@@ -108,6 +99,26 @@ var Columns = function Columns(_ref) {
|
|
108
99
|
})), columns.filter(function (colDef) {
|
109
100
|
return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
|
110
101
|
}).map(function (colDef, i) {
|
102
|
+
var searchString = new RegExp('(' + filterString + ')');
|
103
|
+
var res = filterString.length ? colDef.Header.props.title.toLowerCase().split(searchString) : null;
|
104
|
+
var firstWord = res !== null ? res[0] === '' ? res[1].charAt(0).toUpperCase() + res[1].substring(1) : res[0].charAt(0).toUpperCase() + res[0].substring(1) : null;
|
105
|
+
var highlightedText = res !== null ? res[0] === '' ? "<strong>".concat(firstWord, "</strong>") + res[2] : firstWord + "<strong>".concat(res[1], "</strong>") + res[2] : colDef.Header.props.title;
|
106
|
+
var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
|
107
|
+
className: cx("".concat(blockClass, "__customize-columns-checkbox-wrapper"), "".concat(blockClass, "__customize-columns-checkbox")),
|
108
|
+
checked: isColumnVisible(colDef),
|
109
|
+
onChange: function onChange(_, _ref2) {
|
110
|
+
var checked = _ref2.checked;
|
111
|
+
return onSelectColumn(colDef, checked);
|
112
|
+
},
|
113
|
+
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
114
|
+
labelText: colDef.Header.props.title,
|
115
|
+
title: colDef.Header.props.title,
|
116
|
+
hideLabel: true
|
117
|
+
}), /*#__PURE__*/React.createElement("div", {
|
118
|
+
dangerouslySetInnerHTML: {
|
119
|
+
__html: highlightedText
|
120
|
+
}
|
121
|
+
}));
|
111
122
|
return /*#__PURE__*/React.createElement(DraggableElement, {
|
112
123
|
key: colDef.id,
|
113
124
|
index: i,
|
@@ -136,17 +147,7 @@ var Columns = function Columns(_ref) {
|
|
136
147
|
}
|
137
148
|
},
|
138
149
|
selected: isColumnVisible(colDef)
|
139
|
-
},
|
140
|
-
className: cx("".concat(blockClass, "__customize-columns-checkbox-wrapper"), "".concat(blockClass, "__customize-columns-checkbox")),
|
141
|
-
checked: isColumnVisible(colDef),
|
142
|
-
onChange: function onChange(_, _ref2) {
|
143
|
-
var checked = _ref2.checked;
|
144
|
-
return onSelectColumn(colDef, checked);
|
145
|
-
},
|
146
|
-
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
147
|
-
labelText: colDef.Header.props.title,
|
148
|
-
title: colDef.Header.props.title
|
149
|
-
}));
|
150
|
+
}, listContents);
|
150
151
|
}))));
|
151
152
|
};
|
152
153
|
|
@@ -5,32 +5,30 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
5
5
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
7
|
|
8
|
-
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
*
|
13
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
8
|
+
/**
|
9
|
+
* Copyright IBM Corp. 2022, 2022
|
10
|
+
*
|
11
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
14
13
|
*/
|
15
|
-
// @flow
|
16
14
|
import React, { useEffect, useState } from 'react';
|
17
15
|
import PropTypes from 'prop-types';
|
18
|
-
import { Modal } from '@carbon/react';
|
19
16
|
import { isColumnVisible } from './common';
|
17
|
+
import { TearsheetNarrow } from '../../../../Tearsheet';
|
20
18
|
import Columns from './Columns';
|
21
19
|
import Actions from './Actions';
|
22
20
|
import { pkg } from '../../../../../settings';
|
23
21
|
import { useCallback } from 'react';
|
24
22
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
25
23
|
|
26
|
-
var
|
24
|
+
var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
27
25
|
var isOpen = _ref.isOpen,
|
28
|
-
|
26
|
+
setIsTearsheetOpen = _ref.setIsTearsheetOpen,
|
29
27
|
onSaveColumnPrefs = _ref.onSaveColumnPrefs,
|
30
28
|
columnDefinitions = _ref.columnDefinitions,
|
31
29
|
originalColumnDefinitions = _ref.originalColumnDefinitions,
|
32
|
-
_ref$
|
33
|
-
|
30
|
+
_ref$customizeTearshe = _ref.customizeTearsheetHeadingLabel,
|
31
|
+
customizeTearsheetHeadingLabel = _ref$customizeTearshe === void 0 ? 'Customize columns' : _ref$customizeTearshe,
|
34
32
|
_ref$primaryButtonTex = _ref.primaryButtonTextLabel,
|
35
33
|
primaryButtonTextLabel = _ref$primaryButtonTex === void 0 ? 'Save' : _ref$primaryButtonTex,
|
36
34
|
_ref$secondaryButtonT = _ref.secondaryButtonTextLabel,
|
@@ -91,11 +89,11 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
91
89
|
setIsDirty = _useState10[1];
|
92
90
|
|
93
91
|
var onRequestClose = function onRequestClose() {
|
94
|
-
|
92
|
+
setIsTearsheetOpen(false);
|
95
93
|
};
|
96
94
|
|
97
95
|
var onRequestSubmit = function onRequestSubmit() {
|
98
|
-
|
96
|
+
setIsTearsheetOpen(false);
|
99
97
|
var updatedColumns = columnObjects.map(function (colDef) {
|
100
98
|
return {
|
101
99
|
id: colDef.id,
|
@@ -135,20 +133,22 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
135
133
|
setVisibleColumnsCount(getVisibleColumnsCount());
|
136
134
|
setTotalColumns(columnObjects.length);
|
137
135
|
}, [getVisibleColumnsCount, columnObjects.length]);
|
138
|
-
return /*#__PURE__*/React.createElement(
|
139
|
-
className: "".concat(blockClass, "__customize-columns-
|
136
|
+
return /*#__PURE__*/React.createElement(TearsheetNarrow, {
|
137
|
+
className: "".concat(blockClass, "__customize-columns-tearsheet"),
|
140
138
|
open: isOpen,
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
139
|
+
title: "".concat(customizeTearsheetHeadingLabel, " (").concat(visibleColumnsCount, "/").concat(totalColumns, ")"),
|
140
|
+
description: instructionsLabel,
|
141
|
+
actions: [{
|
142
|
+
kind: 'secondary',
|
143
|
+
label: secondaryButtonTextLabel,
|
144
|
+
onClick: onRequestClose
|
145
|
+
}, {
|
146
|
+
kind: 'primary',
|
147
|
+
label: primaryButtonTextLabel,
|
148
|
+
onClick: onRequestSubmit,
|
149
|
+
disabled: !isDirty
|
150
|
+
}]
|
151
|
+
}, /*#__PURE__*/React.createElement(Actions, {
|
152
152
|
columns: columnObjects,
|
153
153
|
originalColumnDefinitions: originalColumnDefinitions,
|
154
154
|
searchText: searchText,
|
@@ -174,11 +174,11 @@ var CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
|
|
174
174
|
}));
|
175
175
|
};
|
176
176
|
|
177
|
-
|
177
|
+
CustomizeColumnsTearsheet.propTypes = {
|
178
178
|
assistiveTextDisabledInstructionsLabel: PropTypes.string,
|
179
179
|
assistiveTextInstructionsLabel: PropTypes.string,
|
180
180
|
columnDefinitions: PropTypes.array.isRequired,
|
181
|
-
|
181
|
+
customizeTearsheetHeadingLabel: PropTypes.string,
|
182
182
|
findColumnPlaceholderLabel: PropTypes.string,
|
183
183
|
instructionsLabel: PropTypes.string,
|
184
184
|
isOpen: PropTypes.bool.isRequired,
|
@@ -188,6 +188,6 @@ CustomizeColumnsModal.propTypes = {
|
|
188
188
|
resetToDefaultLabel: PropTypes.string,
|
189
189
|
secondaryButtonTextLabel: PropTypes.string,
|
190
190
|
selectAllLabel: PropTypes.string,
|
191
|
-
|
191
|
+
setIsTearsheetOpen: PropTypes.func.isRequired
|
192
192
|
};
|
193
|
-
export default
|
193
|
+
export default CustomizeColumnsTearsheet;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
var _excluded = ["onSaveColumnPrefs", "isTearsheetOpen", "setIsTearsheetOpen", "labels"];
|
4
|
+
|
5
|
+
/* Copyright IBM Corp. 2022, 2022
|
6
|
+
*
|
7
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
9
|
+
*/
|
10
|
+
import * as React from 'react';
|
11
|
+
import PropTypes from 'prop-types';
|
12
|
+
import CustomizeColumnsTearsheet from './CustomizeColumnsTearsheet';
|
13
|
+
|
14
|
+
var TearsheetWrapper = function TearsheetWrapper(_ref) {
|
15
|
+
var instance = _ref.instance;
|
16
|
+
|
17
|
+
var _instance$customizeCo = instance.customizeColumnsProps,
|
18
|
+
_onSaveColumnPrefs = _instance$customizeCo.onSaveColumnPrefs,
|
19
|
+
isTearsheetOpen = _instance$customizeCo.isTearsheetOpen,
|
20
|
+
setIsTearsheetOpen = _instance$customizeCo.setIsTearsheetOpen,
|
21
|
+
labels = _instance$customizeCo.labels,
|
22
|
+
rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
|
23
|
+
|
24
|
+
return /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
|
25
|
+
isOpen: isTearsheetOpen,
|
26
|
+
setIsTearsheetOpen: setIsTearsheetOpen,
|
27
|
+
columnDefinitions: instance.allColumns,
|
28
|
+
originalColumnDefinitions: instance.columns,
|
29
|
+
onSaveColumnPrefs: function onSaveColumnPrefs(updatedColDefs) {
|
30
|
+
var hiddenIds = updatedColDefs.filter(function (colDef) {
|
31
|
+
return !colDef.isVisible;
|
32
|
+
}).map(function (colDef) {
|
33
|
+
return colDef.id;
|
34
|
+
});
|
35
|
+
instance.setHiddenColumns(hiddenIds);
|
36
|
+
|
37
|
+
if (typeof instance.setColumnOrder === 'function') {
|
38
|
+
instance.setColumnOrder(updatedColDefs.map(function (colDef) {
|
39
|
+
return colDef.id;
|
40
|
+
}));
|
41
|
+
} else {
|
42
|
+
// eslint-disable-next-line no-console
|
43
|
+
console.warn("Column order can not be updated. Did you forget to add 'useColumnOrder' in 'useDatagrid'");
|
44
|
+
}
|
45
|
+
|
46
|
+
if (typeof _onSaveColumnPrefs === 'function') {
|
47
|
+
_onSaveColumnPrefs(updatedColDefs);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
}));
|
51
|
+
};
|
52
|
+
|
53
|
+
TearsheetWrapper.propTypes = {
|
54
|
+
instance: PropTypes.object.isRequired
|
55
|
+
};
|
56
|
+
export default TearsheetWrapper;
|
@@ -5,5 +5,5 @@
|
|
5
5
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
6
6
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
7
7
|
*/
|
8
|
-
export { default as
|
8
|
+
export { default as CustomizeColumnsTearsheetWrapper } from './TearsheetWrapper';
|
9
9
|
export { default as ToggleButtonWrapper } from './ButtonWrapper';
|