@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.
Files changed (105) hide show
  1. package/css/index-full-carbon.css +131 -75
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +2 -2
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +1 -0
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +131 -75
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +2 -2
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +121 -75
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +2 -2
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/AddSelect/AddSelectBody.js +1 -1
  18. package/es/components/AddSelect/hooks/usePath.js +8 -1
  19. package/es/components/CreateFullPage/CreateFullPage.js +9 -2
  20. package/es/components/CreateTearsheet/CreateTearsheet.js +9 -2
  21. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -1
  22. package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -4
  23. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +6 -4
  24. package/es/components/Datagrid/Datagrid/Datagrid.js +7 -3
  25. package/es/components/Datagrid/Datagrid/DatagridContent.js +18 -6
  26. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +17 -4
  27. package/es/components/Datagrid/Datagrid/DatagridRow.js +2 -10
  28. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +22 -4
  29. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +29 -8
  30. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +7 -10
  31. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +11 -13
  32. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +28 -27
  33. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +31 -31
  34. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +56 -0
  35. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +1 -1
  36. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +424 -0
  37. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +83 -0
  38. package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +20 -0
  39. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +22 -0
  40. package/es/components/Datagrid/Datagrid/addons/Filtering/index.js +7 -0
  41. package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +38 -0
  42. package/es/components/Datagrid/index.js +2 -1
  43. package/es/components/Datagrid/useCustomizeColumns.js +8 -8
  44. package/es/components/Datagrid/useFiltering.js +90 -0
  45. package/es/components/Datagrid/useParentDimensions.js +3 -1
  46. package/es/components/Datagrid/utils/DatagridActions.js +13 -26
  47. package/es/components/Datagrid/utils/getArgTypes.js +5 -0
  48. package/es/components/Datagrid/utils/getInlineEditColumns.js +6 -1
  49. package/es/components/Datagrid/utils/makeData.js +24 -16
  50. package/es/components/FilterSummary/FilterSummary.js +54 -0
  51. package/es/components/FilterSummary/index.js +7 -0
  52. package/es/components/index.js +1 -1
  53. package/es/global/js/hooks/useCreateComponentFocus.js +38 -10
  54. package/lib/components/AddSelect/AddSelectBody.js +1 -1
  55. package/lib/components/AddSelect/hooks/usePath.js +7 -0
  56. package/lib/components/CreateFullPage/CreateFullPage.js +9 -2
  57. package/lib/components/CreateTearsheet/CreateTearsheet.js +9 -2
  58. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +3 -1
  59. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -4
  60. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +6 -4
  61. package/lib/components/Datagrid/Datagrid/Datagrid.js +8 -3
  62. package/lib/components/Datagrid/Datagrid/DatagridContent.js +17 -6
  63. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +17 -4
  64. package/lib/components/Datagrid/Datagrid/DatagridRow.js +2 -19
  65. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +24 -3
  66. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +31 -8
  67. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +7 -10
  68. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +6 -6
  69. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +30 -28
  70. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{CustomizeColumnsModal.js → CustomizeColumnsTearsheet.js} +27 -25
  71. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/{ModalWrapper.js → TearsheetWrapper.js} +31 -36
  72. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/index.js +3 -3
  73. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +443 -0
  74. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +104 -0
  75. package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +35 -0
  76. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +33 -0
  77. package/lib/components/Datagrid/Datagrid/addons/Filtering/index.js +15 -0
  78. package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +47 -0
  79. package/lib/components/Datagrid/index.js +9 -1
  80. package/lib/components/Datagrid/useCustomizeColumns.js +7 -7
  81. package/lib/components/Datagrid/useFiltering.js +94 -0
  82. package/lib/components/Datagrid/useParentDimensions.js +3 -1
  83. package/lib/components/Datagrid/utils/DatagridActions.js +13 -25
  84. package/lib/components/Datagrid/utils/getArgTypes.js +5 -0
  85. package/lib/components/Datagrid/utils/getInlineEditColumns.js +6 -1
  86. package/lib/components/Datagrid/utils/makeData.js +26 -18
  87. package/lib/components/FilterSummary/FilterSummary.js +72 -0
  88. package/lib/components/FilterSummary/index.js +15 -0
  89. package/lib/components/index.js +6 -0
  90. package/lib/global/js/hooks/useCreateComponentFocus.js +42 -11
  91. package/package.json +2 -2
  92. package/scss/components/Datagrid/_datagrid.scss +0 -1
  93. package/scss/components/Datagrid/_storybook-styles.scss +12 -0
  94. package/scss/components/Datagrid/styles/_datagrid.scss +23 -0
  95. package/scss/components/Datagrid/styles/_draggableElement.scss +9 -8
  96. package/scss/components/Datagrid/styles/_index.scss +8 -8
  97. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +65 -0
  98. package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +87 -0
  99. package/scss/components/FilterSummary/_filter-summary.scss +20 -0
  100. package/scss/components/FilterSummary/_index.scss +10 -0
  101. package/scss/components/FilterSummary/_storybook-styles.scss +14 -0
  102. package/scss/components/Tearsheet/_tearsheet.scss +2 -0
  103. package/scss/components/_index.scss +1 -0
  104. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +0 -63
  105. 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
- CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
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()) : renderTable())), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
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
- CustomizeColumnsModal: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
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/NoDataEmptyState';
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
- illustrationTheme = datagridState.illustrationTheme;
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(NoDataEmptyState, {
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, { useContext } from '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), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-hover-active"), activeCellObject && row.index === activeCellObject.row), _cx))
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
- withOverflowRow = datagridState.withOverflowRow;
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(TableBody, _extends({}, getTableBodyProps(), {
61
- onScroll: onScroll
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(_objectSpread({}, style), {}, {
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
- // @flow
2
-
3
- /*
4
- * Licensed Materials - Property of IBM
5
- * 5724-Q36
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-modal--actions")
18
+ className: "".concat(blockClass, "__customize-columns-tearsheet--actions")
22
19
  }, /*#__PURE__*/React.createElement(Search, {
23
20
  placeholder: findColumnPlaceholderLabel,
24
21
  value: searchText,
25
- size: "sm",
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", "setIsModalOpen", "isModalOpen", "iconTooltipLabel"];
4
- // @flow
3
+ var _excluded = ["onClick", "setIsTearsheetOpen", "isTearsheetOpen", "iconTooltipLabel"];
5
4
 
6
- /*
7
- * Licensed Materials - Property of IBM
8
- * 5724-Q36
9
- * (c) Copyright IBM Corp. 2021
10
- * US Government Users Restricted Rights - Use, duplication or disclosure
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
- setIsModalOpen = _ref.setIsModalOpen,
23
- isModalOpen = _ref.isModalOpen,
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
- setIsModalOpen(!isModalOpen);
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
- isModalOpen: PropTypes.bool.isRequired,
52
+ isTearsheetOpen: PropTypes.bool.isRequired,
55
53
  onClick: PropTypes.func.isRequired,
56
- setIsModalOpen: PropTypes.func.isRequired
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
- * Licensed Materials - Property of IBM
7
- * 5724-Q36
8
- * (c) Copyright IBM Corp. 2021
9
- * US Government Users Restricted Rights - Use, duplication or disclosure
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((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__customize-columns-select-all"), getVisibleColumnsCount() === 0), _defineProperty(_cx, "".concat(blockClass, "__customize-columns-select-all-selected"), getVisibleColumnsCount() > 0), _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
- }, /*#__PURE__*/React.createElement(Checkbox, {
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
- * Licensed Materials - Property of IBM
10
- * 5724-Q36
11
- * (c) Copyright IBM Corp. 2021
12
- * US Government Users Restricted Rights - Use, duplication or disclosure
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 CustomizeColumnsModal = function CustomizeColumnsModal(_ref) {
24
+ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
27
25
  var isOpen = _ref.isOpen,
28
- setIsModalOpen = _ref.setIsModalOpen,
26
+ setIsTearsheetOpen = _ref.setIsTearsheetOpen,
29
27
  onSaveColumnPrefs = _ref.onSaveColumnPrefs,
30
28
  columnDefinitions = _ref.columnDefinitions,
31
29
  originalColumnDefinitions = _ref.originalColumnDefinitions,
32
- _ref$customizeModalHe = _ref.customizeModalHeadingLabel,
33
- customizeModalHeadingLabel = _ref$customizeModalHe === void 0 ? 'Customize Columns' : _ref$customizeModalHe,
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
- setIsModalOpen(false);
92
+ setIsTearsheetOpen(false);
95
93
  };
96
94
 
97
95
  var onRequestSubmit = function onRequestSubmit() {
98
- setIsModalOpen(false);
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(Modal, {
139
- className: "".concat(blockClass, "__customize-columns-modal"),
136
+ return /*#__PURE__*/React.createElement(TearsheetNarrow, {
137
+ className: "".concat(blockClass, "__customize-columns-tearsheet"),
140
138
  open: isOpen,
141
- modalHeading: "".concat(customizeModalHeadingLabel, " (").concat(visibleColumnsCount, "/").concat(totalColumns, ")"),
142
- primaryButtonText: primaryButtonTextLabel,
143
- secondaryButtonText: secondaryButtonTextLabel,
144
- selectorPrimaryFocus: ".".concat(blockClass, "__customize-columns-column-list--focus"),
145
- primaryButtonDisabled: !isDirty,
146
- onRequestClose: onRequestClose,
147
- onRequestSubmit: onRequestSubmit,
148
- size: "sm"
149
- }, /*#__PURE__*/React.createElement("div", {
150
- className: "".concat(blockClass, "__customize-columns-instructions")
151
- }, instructionsLabel), /*#__PURE__*/React.createElement(Actions, {
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
- CustomizeColumnsModal.propTypes = {
177
+ CustomizeColumnsTearsheet.propTypes = {
178
178
  assistiveTextDisabledInstructionsLabel: PropTypes.string,
179
179
  assistiveTextInstructionsLabel: PropTypes.string,
180
180
  columnDefinitions: PropTypes.array.isRequired,
181
- customizeModalHeadingLabel: PropTypes.string,
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
- setIsModalOpen: PropTypes.func.isRequired
191
+ setIsTearsheetOpen: PropTypes.func.isRequired
192
192
  };
193
- export default CustomizeColumnsModal;
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 CustomizeColumnsModalWrapper } from './ModalWrapper';
8
+ export { default as CustomizeColumnsTearsheetWrapper } from './TearsheetWrapper';
9
9
  export { default as ToggleButtonWrapper } from './ButtonWrapper';