@carbon/ibm-products 2.0.0-rc.24 → 2.0.0-rc.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. package/README.md +10 -4
  2. package/css/index-full-carbon.css +87 -123
  3. package/css/index-full-carbon.css.map +1 -1
  4. package/css/index-full-carbon.min.css +4 -4
  5. package/css/index-full-carbon.min.css.map +1 -1
  6. package/css/index-without-carbon-released-only.css +18 -109
  7. package/css/index-without-carbon-released-only.css.map +1 -1
  8. package/css/index-without-carbon-released-only.min.css +3 -3
  9. package/css/index-without-carbon-released-only.min.css.map +1 -1
  10. package/css/index-without-carbon.css +87 -123
  11. package/css/index-without-carbon.css.map +1 -1
  12. package/css/index-without-carbon.min.css +4 -4
  13. package/css/index-without-carbon.min.css.map +1 -1
  14. package/css/index.css +87 -123
  15. package/css/index.css.map +1 -1
  16. package/css/index.min.css +4 -4
  17. package/css/index.min.css.map +1 -1
  18. package/es/components/AddSelect/AddSelectBody.js +1 -0
  19. package/es/components/AddSelect/AddSelectFormControl.js +92 -0
  20. package/es/components/AddSelect/AddSelectList.js +26 -195
  21. package/es/components/AddSelect/AddSelectRow.js +220 -0
  22. package/es/components/AddSelect/hooks/useFocus.js +35 -0
  23. package/es/components/CreateFullPage/CreateFullPageStep.js +16 -9
  24. package/es/components/CreateTearsheet/CreateTearsheetStep.js +8 -8
  25. package/es/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +11 -17
  26. package/es/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +9 -13
  27. package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
  28. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
  29. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +15 -4
  30. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +15 -60
  31. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +6 -8
  32. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +112 -0
  33. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
  34. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +29 -23
  35. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -0
  36. package/es/components/Datagrid/index.js +7 -7
  37. package/es/components/Datagrid/useInfiniteScroll.js +5 -1
  38. package/es/components/Datagrid/useOnRowClick.js +3 -3
  39. package/es/components/Datagrid/useSortableColumns.js +19 -9
  40. package/es/components/Datagrid/utils/getAutoSizedColumnWidth.js +29 -0
  41. package/es/components/ExampleComponent/ExampleComponent.js +39 -5
  42. package/es/components/ExampleComponent/useExample.js +51 -0
  43. package/es/components/InlineEditV1/InlineEditV1.js +15 -20
  44. package/es/components/InlineEditV2/InlineEditV2.js +21 -31
  45. package/es/components/SidePanel/SidePanel.js +3 -5
  46. package/es/components/index.js +1 -1
  47. package/es/global/js/package-settings.js +24 -3
  48. package/es/global/js/utils/story-helper.js +9 -0
  49. package/es/global/js/utils/test-helper.js +38 -6
  50. package/lib/components/AddSelect/AddSelectBody.js +1 -0
  51. package/lib/components/AddSelect/AddSelectFormControl.js +110 -0
  52. package/lib/components/AddSelect/AddSelectList.js +29 -203
  53. package/lib/components/AddSelect/AddSelectRow.js +247 -0
  54. package/lib/components/AddSelect/hooks/useFocus.js +46 -0
  55. package/lib/components/CreateFullPage/CreateFullPageStep.js +14 -7
  56. package/lib/components/CreateTearsheet/CreateTearsheetStep.js +7 -7
  57. package/lib/components/CreateTearsheet/preview-components/MultiStepTearsheet.js +10 -16
  58. package/lib/components/CreateTearsheet/preview-components/MultiStepWithIntro.js +9 -13
  59. package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
  60. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
  61. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +15 -3
  62. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +16 -64
  63. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +6 -8
  64. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +132 -0
  65. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
  66. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +23 -16
  67. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -0
  68. package/lib/components/Datagrid/index.js +9 -1
  69. package/lib/components/Datagrid/useInfiniteScroll.js +5 -0
  70. package/lib/components/Datagrid/useOnRowClick.js +3 -3
  71. package/lib/components/Datagrid/useSortableColumns.js +19 -9
  72. package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.js +40 -0
  73. package/lib/components/ExampleComponent/ExampleComponent.js +47 -4
  74. package/lib/components/ExampleComponent/useExample.js +63 -0
  75. package/lib/components/InlineEditV1/InlineEditV1.js +14 -19
  76. package/lib/components/InlineEditV2/InlineEditV2.js +20 -30
  77. package/lib/components/SidePanel/SidePanel.js +2 -4
  78. package/lib/components/index.js +6 -0
  79. package/lib/global/js/package-settings.js +24 -3
  80. package/lib/global/js/utils/story-helper.js +13 -2
  81. package/lib/global/js/utils/test-helper.js +42 -8
  82. package/package.json +2 -2
  83. package/scss/components/AddSelect/_add-select.scss +4 -16
  84. package/scss/components/CreateFullPage/_create-full-page.scss +5 -10
  85. package/scss/components/CreateTearsheet/_create-tearsheet.scss +8 -3
  86. package/scss/components/Datagrid/styles/_datagrid.scss +4 -0
  87. package/scss/components/Datagrid/styles/_useSortableColumns.scss +6 -3
  88. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +15 -2
  89. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +18 -6
  90. package/scss/components/EmptyStates/_empty-state.scss +2 -2
  91. package/scss/components/InlineEditV1/_inline-edit-v1.scss +5 -89
  92. package/scss/components/InlineEditV2/_inline-edit-v2.scss +42 -3
  93. package/scss/components/SidePanel/_side-panel.scss +7 -15
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  /* eslint-disable react/prop-types */
4
4
 
5
5
  /**
6
- * Copyright IBM Corp. 2021, 2022
6
+ * Copyright IBM Corp. 2021, 2023
7
7
  *
8
8
  * This source code is licensed under the Apache-2.0 license found in the
9
9
  * LICENSE file in the root directory of this source tree.
@@ -184,13 +184,11 @@ export var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
184
184
  disableSubmit: !stepOneTextInputValue,
185
185
  subtitle: "This is the unique name used to recognize your topic",
186
186
  description: "It will also be used by your producers and consumers as part of the connection information, so make it something easy to recognize."
187
- }, /*#__PURE__*/React.createElement(Grid, {
188
- narrow: true
189
- }, /*#__PURE__*/React.createElement(Column, {
187
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Column, {
190
188
  xlg: 8,
191
189
  lg: 8,
192
190
  md: 8,
193
- sm: 8
191
+ sm: 4
194
192
  }, /*#__PURE__*/React.createElement(TextInput, {
195
193
  labelText: "Topic name",
196
194
  id: "tearsheet-multi-step-story-text-input-multi-step-1",
@@ -243,11 +241,11 @@ export var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
243
241
  subtitle: "One or more partitions make up a topic. A partition is an ordered list of messages.",
244
242
  description: "Partitions are distributed across the brokers in order to increase the scalability of your topic. You can also use them to distribute messages across the members of a consumer group.",
245
243
  fieldsetLegendText: "Partition information"
246
- }, /*#__PURE__*/React.createElement(Grid, {
247
- narrow: true
248
- }, /*#__PURE__*/React.createElement(Column, {
244
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Column, {
249
245
  xlg: 3,
250
- lg: 3
246
+ lg: 3,
247
+ md: 8,
248
+ sm: 4
251
249
  }, /*#__PURE__*/React.createElement(NumberInput, {
252
250
  iconDescription: "Choose a number",
253
251
  id: "carbon-number",
@@ -269,13 +267,11 @@ export var MultiStepWithIntro = function MultiStepWithIntro(_ref) {
269
267
  subtitle: "This is how long messages are retained before they are deleted.",
270
268
  description: "If your messages are not read by a consumer within this time, they will be missed.",
271
269
  fieldsetLegendText: "Message retention scheduling"
272
- }, /*#__PURE__*/React.createElement(Grid, {
273
- narrow: true
274
- }, /*#__PURE__*/React.createElement(Column, {
270
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Column, {
275
271
  xlg: 8,
276
272
  lg: 8,
277
273
  md: 8,
278
- sm: 8
274
+ sm: 4
279
275
  }, /*#__PURE__*/React.createElement(RadioButtonGroup, {
280
276
  legendText: "Message retention",
281
277
  name: "radio-button-group",
@@ -95,9 +95,9 @@ export var DatagridContent = function DatagridContent(_ref) {
95
95
  return handleGridKeyPress({
96
96
  event: event,
97
97
  dispatch: dispatch,
98
- inlineEditState: inlineEditState,
99
98
  instance: datagridState,
100
99
  keysPressedList: keysPressedList,
100
+ state: inlineEditState,
101
101
  usingMac: usingMac
102
102
  });
103
103
  } : null,
@@ -116,7 +116,7 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
116
116
  setGlobalFilter(null);
117
117
  }
118
118
  }, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
119
- if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length === 3) {
119
+ if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length <= 3) {
120
120
  return /*#__PURE__*/React.createElement(TableBatchAction, {
121
121
  key: "".concat(batchAction.label, "-").concat(index),
122
122
  renderIcon: batchAction.renderIcon,
@@ -8,7 +8,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
8
8
  /*
9
9
  * Licensed Materials - Property of IBM
10
10
  * 5724-Q36
11
- * (c) Copyright IBM Corp. 2020 - 2021
11
+ * (c) Copyright IBM Corp. 2020 - 2023
12
12
  * US Government Users Restricted Rights - Use, duplication or disclosure
13
13
  * restricted by GSA ADP Schedule Contract with IBM Corp.
14
14
  */
@@ -18,6 +18,7 @@ import { TableBody } from '@carbon/react';
18
18
  import { pkg } from '../../../settings';
19
19
  import DatagridHead from './DatagridHead';
20
20
  import { px } from '@carbon/layout';
21
+ import { useResizeDetector } from 'react-resize-detector';
21
22
  var blockClass = "".concat(pkg.prefix, "--datagrid");
22
23
  var rowSizeMap = {
23
24
  xs: 24,
@@ -51,10 +52,20 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
51
52
  handleResize = datagridState.handleResize,
52
53
  gridRef = datagridState.gridRef;
53
54
 
55
+ var handleVirtualGridResize = function handleVirtualGridResize() {
56
+ var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
57
+ gridRefElement.style.width = gridRefElement === null || gridRefElement === void 0 ? void 0 : gridRefElement.clientWidth;
58
+ };
59
+
60
+ useResizeDetector({
61
+ onResize: handleVirtualGridResize,
62
+ targetRef: gridRef
63
+ });
64
+
54
65
  var syncScroll = function syncScroll(e) {
55
66
  var virtualBody = e.target;
56
- document.querySelector(".".concat(blockClass, "__head-warp")).scrollLeft = virtualBody.scrollLeft;
57
- var spacerColumn = document.querySelector(".".concat(blockClass, "__head-warp thead th:last-child"));
67
+ document.querySelector(".".concat(blockClass, "__head-wrap")).scrollLeft = virtualBody.scrollLeft;
68
+ var spacerColumn = document.querySelector(".".concat(blockClass, "__head-wrap thead th:last-child"));
58
69
  spacerColumn.style.width = px(32 + (virtualBody.offsetWidth - virtualBody.clientWidth)); // scrollbar width to header column to fix header alignment
59
70
  };
60
71
 
@@ -69,7 +80,7 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
69
80
 
70
81
  var visibleRows = DatagridPagination && page || rows;
71
82
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
72
- className: "".concat(blockClass, "__head-warp"),
83
+ className: "".concat(blockClass, "__head-wrap"),
73
84
  style: {
74
85
  width: (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth,
75
86
  overflow: 'hidden'
@@ -14,9 +14,8 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
14
14
  import { Checkbox } from '@carbon/react';
15
15
  import update from 'immutability-helper';
16
16
  import { pkg } from '../../../../../settings';
17
- import DraggableElement from '../../DraggableElement';
18
- import { isColumnVisible } from './common';
19
17
  import cx from 'classnames';
18
+ import { DraggableItemsList } from './DraggableItemsList';
20
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
20
 
22
21
  var getNextIndex = function getNextIndex(array, currentIndex, key) {
@@ -41,7 +40,8 @@ var Columns = function Columns(_ref) {
41
40
  onSelectColumn = _ref.onSelectColumn,
42
41
  assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
43
42
  assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
44
- selectAllLabel = _ref.selectAllLabel;
43
+ selectAllLabel = _ref.selectAllLabel,
44
+ isTableSortable = _ref.isTableSortable;
45
45
 
46
46
  var _React$useState = React.useState(''),
47
47
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -96,63 +96,17 @@ var Columns = function Columns(_ref) {
96
96
  },
97
97
  id: "".concat(blockClass, "__customization-column-select-all"),
98
98
  labelText: selectAllLabel
99
- })), columns.filter(function (colDef) {
100
- return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
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 isFrozenColumn = !!colDef.sticky;
107
- var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
108
- className: cx("".concat(blockClass, "__customize-columns-checkbox-wrapper"), "".concat(blockClass, "__customize-columns-checkbox")),
109
- checked: isColumnVisible(colDef),
110
- disabled: isFrozenColumn,
111
- onChange: function onChange(_, _ref2) {
112
- var checked = _ref2.checked;
113
- return onSelectColumn(colDef, checked);
114
- },
115
- id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
116
- labelText: colDef.Header.props.title,
117
- title: colDef.Header.props.title,
118
- hideLabel: true
119
- }), /*#__PURE__*/React.createElement("div", {
120
- dangerouslySetInnerHTML: {
121
- __html: highlightedText
122
- }
123
- }));
124
- return /*#__PURE__*/React.createElement(DraggableElement, {
125
- key: colDef.id,
126
- index: i,
127
- listData: columns,
128
- setListData: setColumnsObject,
129
- id: "dnd-datagrid-columns-".concat(colDef.id),
130
- type: "column-customization",
131
- disabled: filterString.length > 0 || isFrozenColumn,
132
- ariaLabel: colDef.Header.props.title,
133
- onGrab: setAriaRegionText,
134
- isFocused: focusIndex === i,
135
- isSticky: isFrozenColumn,
136
- moveElement: moveElement,
137
- onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
138
- if (isGrabbed) {
139
- var _columns$nextIndex;
140
-
141
- var nextIndex = getNextIndex(columns, currentIndex, e.key);
142
- e.preventDefault();
143
- e.stopPropagation();
144
-
145
- if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
146
- setFocusIndex(nextIndex);
147
- moveElement(currentIndex, nextIndex);
148
- e.target.scrollIntoView({
149
- block: 'center'
150
- });
151
- }
152
- }
153
- },
154
- selected: isColumnVisible(colDef)
155
- }, listContents);
99
+ })), /*#__PURE__*/React.createElement(DraggableItemsList, {
100
+ columns: columns,
101
+ filterString: filterString,
102
+ focusIndex: focusIndex,
103
+ getNextIndex: getNextIndex,
104
+ isTableSortable: isTableSortable,
105
+ moveElement: moveElement,
106
+ onSelectColumn: onSelectColumn,
107
+ setAriaRegionText: setAriaRegionText,
108
+ setColumnsObject: setColumnsObject,
109
+ setFocusIndex: setFocusIndex
156
110
  }))));
157
111
  };
158
112
 
@@ -164,6 +118,7 @@ Columns.propTypes = {
164
118
  filterString: PropTypes.string.isRequired,
165
119
  getVisibleColumnsCount: PropTypes.func.isRequired,
166
120
  instructionsLabel: PropTypes.string,
121
+ isTableSortable: PropTypes.bool.isRequired,
167
122
  onSelectColumn: PropTypes.func.isRequired,
168
123
  selectAllLabel: PropTypes.string,
169
124
  setColumnStatus: PropTypes.func,
@@ -44,7 +44,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
44
44
  _ref$assistiveTextDis = _ref.assistiveTextDisabledInstructionsLabel,
45
45
  assistiveTextDisabledInstructionsLabel = _ref$assistiveTextDis === void 0 ? 'Reordering columns are disabled because they are filtered currently.' : _ref$assistiveTextDis,
46
46
  _ref$selectAllLabel = _ref.selectAllLabel,
47
- selectAllLabel = _ref$selectAllLabel === void 0 ? 'Column name' : _ref$selectAllLabel;
47
+ selectAllLabel = _ref$selectAllLabel === void 0 ? 'Column name' : _ref$selectAllLabel,
48
+ isTableSortable = _ref.isTableSortable;
48
49
 
49
50
  var _useState = useState(''),
50
51
  _useState2 = _slicedToArray(_useState, 2),
@@ -61,12 +62,7 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
61
62
  searchText = _useState6[0],
62
63
  setSearchText = _useState6[1];
63
64
 
64
- var _useState7 = useState(columnDefinitions // hide the columns without Header, e.g the sticky actions, spacer
65
- .filter(function (colDef) {
66
- return !!colDef.Header.props && !!colDef.Header.props.title;
67
- }).filter(function (colDef) {
68
- return !colDef.isAction;
69
- }) // only sort the hidden column to the end when modal reopen
65
+ var _useState7 = useState(columnDefinitions // only sort the hidden column to the end when modal reopen
70
66
  .sort(function (defA, defB) {
71
67
  var isVisibleA = isColumnVisible(defA);
72
68
  var isVisibleB = isColumnVisible(defB);
@@ -172,7 +168,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
172
168
  setColumnObjects(cols);
173
169
  setDirty();
174
170
  },
175
- selectAllLabel: selectAllLabel
171
+ selectAllLabel: selectAllLabel,
172
+ isTableSortable: isTableSortable
176
173
  }));
177
174
  };
178
175
 
@@ -184,6 +181,7 @@ CustomizeColumnsTearsheet.propTypes = {
184
181
  findColumnPlaceholderLabel: PropTypes.string,
185
182
  instructionsLabel: PropTypes.string,
186
183
  isOpen: PropTypes.bool.isRequired,
184
+ isTableSortable: PropTypes.bool.isRequired,
187
185
  onSaveColumnPrefs: PropTypes.func.isRequired,
188
186
  originalColumnDefinitions: PropTypes.array.isRequired,
189
187
  primaryButtonTextLabel: PropTypes.string,
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { PropTypes } from 'prop-types';
9
+ import { Checkbox } from '@carbon/react';
10
+ import { isColumnVisible } from './common';
11
+ import DraggableElement from '../../DraggableElement';
12
+ import { pkg } from '../../../../../settings';
13
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
14
+ export var DraggableItemsList = function DraggableItemsList(_ref) {
15
+ var columns = _ref.columns,
16
+ filterString = _ref.filterString,
17
+ focusIndex = _ref.focusIndex,
18
+ getNextIndex = _ref.getNextIndex,
19
+ isTableSortable = _ref.isTableSortable,
20
+ moveElement = _ref.moveElement,
21
+ onSelectColumn = _ref.onSelectColumn,
22
+ setAriaRegionText = _ref.setAriaRegionText,
23
+ setColumnsObject = _ref.setColumnsObject,
24
+ setFocusIndex = _ref.setFocusIndex;
25
+ return /*#__PURE__*/React.createElement(React.Fragment, null, columns // hide the columns without Header, e.g the sticky actions, spacer
26
+ .filter(function (colDef) {
27
+ var _colDef$Header$props$, _colDef$Header$props;
28
+
29
+ var sortableTitle = isTableSortable && ((_colDef$Header$props$ = colDef.Header().props.children.props) === null || _colDef$Header$props$ === void 0 ? void 0 : _colDef$Header$props$.title);
30
+ return !!colDef.Header.props && !!((_colDef$Header$props = colDef.Header.props) !== null && _colDef$Header$props !== void 0 && _colDef$Header$props.title) || isTableSortable && !!sortableTitle;
31
+ }).filter(function (colDef) {
32
+ return !colDef.isAction;
33
+ }).filter(function (colDef) {
34
+ var _colDef$Header$props$2, _colDef$Header$props2, _colDef$Header$props3;
35
+
36
+ var sortableTitle = isTableSortable && ((_colDef$Header$props$2 = colDef.Header().props.children.props) === null || _colDef$Header$props$2 === void 0 ? void 0 : _colDef$Header$props$2.title);
37
+ return filterString.length === 0 || (isTableSortable ? sortableTitle === null || sortableTitle === void 0 ? void 0 : sortableTitle.toLowerCase().includes(filterString) : (_colDef$Header$props2 = colDef.Header.props) === null || _colDef$Header$props2 === void 0 ? void 0 : (_colDef$Header$props3 = _colDef$Header$props2.title) === null || _colDef$Header$props3 === void 0 ? void 0 : _colDef$Header$props3.toLowerCase().includes(filterString)) && colDef.id !== 'spacer';
38
+ }).map(function (colDef, i) {
39
+ var _colDef$Header$props$3, _colDef$Header$props4, _colDef$Header$props5, _colDef$Header$props6, _colDef$Header$props7;
40
+
41
+ var isSortableColumn = !!colDef.canSort && !!isTableSortable;
42
+ var sortableTitle = isTableSortable && ((_colDef$Header$props$3 = colDef.Header().props.children.props) === null || _colDef$Header$props$3 === void 0 ? void 0 : _colDef$Header$props$3.title);
43
+ var searchString = new RegExp('(' + filterString + ')');
44
+ var res = filterString.length ? isSortableColumn ? sortableTitle.toLowerCase().split(searchString) : colDef.Header.props.title.toLowerCase().split(searchString) : null;
45
+ 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;
46
+ var highlightedText = res !== null ? res[0] === '' ? "<strong>".concat(firstWord, "</strong>") + res[2] : firstWord + "<strong>".concat(res[1], "</strong>") + res[2] : isSortableColumn ? sortableTitle : (_colDef$Header$props4 = colDef.Header.props) === null || _colDef$Header$props4 === void 0 ? void 0 : _colDef$Header$props4.title;
47
+ var isFrozenColumn = !!colDef.sticky;
48
+ var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
49
+ wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
50
+ checked: isColumnVisible(colDef),
51
+ disabled: isFrozenColumn,
52
+ onChange: function onChange(_, _ref2) {
53
+ var checked = _ref2.checked;
54
+ return onSelectColumn(colDef, checked);
55
+ },
56
+ id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
57
+ labelText: isSortableColumn ? sortableTitle : (_colDef$Header$props5 = colDef.Header.props) === null || _colDef$Header$props5 === void 0 ? void 0 : _colDef$Header$props5.title,
58
+ title: isSortableColumn ? sortableTitle : (_colDef$Header$props6 = colDef.Header.props) === null || _colDef$Header$props6 === void 0 ? void 0 : _colDef$Header$props6.title,
59
+ className: "".concat(blockClass, "__customize-columns-checkbox"),
60
+ hideLabel: true
61
+ }), /*#__PURE__*/React.createElement("div", {
62
+ dangerouslySetInnerHTML: {
63
+ __html: highlightedText
64
+ },
65
+ className: "".concat(blockClass, "__customize-columns-checkbox-visible-label")
66
+ }));
67
+ return /*#__PURE__*/React.createElement(DraggableElement, {
68
+ key: colDef.id,
69
+ index: i,
70
+ listData: columns,
71
+ setListData: setColumnsObject,
72
+ id: "dnd-datagrid-columns-".concat(colDef.id),
73
+ type: "column-customization",
74
+ disabled: filterString.length > 0 || isFrozenColumn,
75
+ ariaLabel: isSortableColumn ? sortableTitle : (_colDef$Header$props7 = colDef.Header.props) === null || _colDef$Header$props7 === void 0 ? void 0 : _colDef$Header$props7.title,
76
+ onGrab: setAriaRegionText,
77
+ isFocused: focusIndex === i,
78
+ moveElement: moveElement,
79
+ onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
80
+ if (isGrabbed) {
81
+ var _columns$nextIndex;
82
+
83
+ var nextIndex = getNextIndex(columns, currentIndex, e.key);
84
+ e.preventDefault();
85
+ e.stopPropagation();
86
+
87
+ if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
88
+ setFocusIndex(nextIndex);
89
+ moveElement(currentIndex, nextIndex);
90
+ e.target.scrollIntoView({
91
+ block: 'center'
92
+ });
93
+ }
94
+ }
95
+ },
96
+ isSticky: isFrozenColumn,
97
+ selected: isColumnVisible(colDef)
98
+ }, listContents);
99
+ }));
100
+ };
101
+ DraggableItemsList.propTypes = {
102
+ columns: PropTypes.array.isRequired,
103
+ filterString: PropTypes.string.isRequired,
104
+ focusIndex: PropTypes.number.isRequired,
105
+ getNextIndex: PropTypes.func.isRequired,
106
+ isTableSortable: PropTypes.bool,
107
+ moveElement: PropTypes.func.isRequired,
108
+ onSelectColumn: PropTypes.func.isRequired,
109
+ setAriaRegionText: PropTypes.func.isRequired,
110
+ setColumnsObject: PropTypes.func.isRequired,
111
+ setFocusIndex: PropTypes.func.isRequired
112
+ };
@@ -23,6 +23,7 @@ var TearsheetWrapper = function TearsheetWrapper(_ref) {
23
23
 
24
24
  return /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
25
25
  isOpen: isTearsheetOpen,
26
+ isTableSortable: instance === null || instance === void 0 ? void 0 : instance.isTableSortable,
26
27
  setIsTearsheetOpen: setIsTearsheetOpen,
27
28
  columnDefinitions: instance.allColumns,
28
29
  originalColumnDefinitions: instance.columns,
@@ -1,28 +1,27 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
- var _excluded = ["legendText"];
6
- // @flow
4
+ var _excluded = ["align", "legendText"];
7
5
 
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.
6
+ /**
7
+ * Copyright IBM Corp. 2021, 2023
8
+ *
9
+ * This source code is licensed under the Apache-2.0 license found in the
10
+ * LICENSE file in the root directory of this source tree.
14
11
  */
15
12
  import * as React from 'react';
16
13
  import PropTypes from 'prop-types';
17
14
  import { Settings } from '@carbon/react/icons';
18
- import { IconButton, Popover, PopoverContent } from '@carbon/react';
15
+ import { IconButton, Toggletip, ToggletipContent, ToggletipButton } from '@carbon/react';
19
16
  import cx from 'classnames';
20
17
  import RowSizeRadioGroup from './RowSizeRadioGroup';
21
18
  import { pkg } from '../../../../../settings';
22
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
23
20
 
24
21
  var RowSizeDropdown = function RowSizeDropdown(_ref) {
25
- var _ref$legendText = _ref.legendText,
22
+ var _ref$align = _ref.align,
23
+ align = _ref$align === void 0 ? 'bottom' : _ref$align,
24
+ _ref$legendText = _ref.legendText,
26
25
  legendText = _ref$legendText === void 0 ? 'Row height' : _ref$legendText,
27
26
  props = _objectWithoutProperties(_ref, _excluded);
28
27
 
@@ -31,31 +30,38 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
31
30
  isOpen = _React$useState2[0],
32
31
  setIsOpen = _React$useState2[1];
33
32
 
34
- return /*#__PURE__*/React.createElement(Popover, {
35
- align: "bottom-right",
36
- caret: false,
37
- dropShadow: false,
38
- open: isOpen,
39
- className: "".concat(blockClass, "__row-height-settings-popover")
40
- }, /*#__PURE__*/React.createElement(IconButton, {
33
+ return /*#__PURE__*/React.createElement(React.Fragment, null, !isOpen && /*#__PURE__*/React.createElement(IconButton, {
41
34
  kind: "ghost",
42
- align: "left",
35
+ align: align,
43
36
  onClick: function onClick() {
44
- return setIsOpen(!isOpen);
37
+ return setIsOpen(function (prevOpen) {
38
+ return !prevOpen;
39
+ });
45
40
  },
46
41
  label: legendText,
47
- className: cx("".concat(blockClass, "__row-size-button"), _defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
42
+ className: cx("".concat(blockClass, "__row-size-button"))
48
43
  }, /*#__PURE__*/React.createElement(Settings, {
49
44
  size: 16
50
- })), /*#__PURE__*/React.createElement(PopoverContent, null, /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({}, props, {
45
+ })), isOpen && /*#__PURE__*/React.createElement(Toggletip, {
46
+ defaultOpen: true,
47
+ className: "".concat(blockClass, "__row-size-toggle-tip")
48
+ }, /*#__PURE__*/React.createElement(ToggletipButton, {
49
+ className: cx("".concat(blockClass, "__row-size-toggle-tip-button"), "".concat(blockClass, "__row-size-button--open")),
50
+ label: legendText
51
+ }, /*#__PURE__*/React.createElement(Settings, {
52
+ size: 16
53
+ })), /*#__PURE__*/React.createElement(ToggletipContent, {
54
+ className: "".concat(blockClass, "__row-size-toggle-tip-content")
55
+ }, /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({}, props, {
51
56
  legendText: legendText,
52
57
  hideRadioGroup: function hideRadioGroup() {
53
58
  setIsOpen(false);
54
59
  }
55
- }))));
60
+ })))));
56
61
  };
57
62
 
58
63
  RowSizeDropdown.propTypes = {
64
+ align: IconButton.propTypes.align,
59
65
  datagridName: PropTypes.string,
60
66
  legendText: PropTypes.string,
61
67
  light: PropTypes.bool,
@@ -62,6 +62,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
62
62
  }
63
63
 
64
64
  return /*#__PURE__*/React.createElement(RadioButton, {
65
+ className: "".concat(blockClass, "__row-size-radio-button"),
65
66
  key: option.value,
66
67
  labelText: labelText,
67
68
  value: option.value,
@@ -1,9 +1,8 @@
1
- /*
2
- * Licensed Materials - Property of IBM
3
- * 5724-Q36
4
- * (c) Copyright IBM Corp. 2020
5
- * US Government Users Restricted Rights - Use, duplication or disclosure
6
- * restricted by GSA ADP Schedule Contract with IBM Corp.
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
7
6
  */
8
7
  export { Datagrid } from './Datagrid';
9
8
  export { default as useDatagrid } from './useDatagrid';
@@ -23,4 +22,5 @@ export { default as useSelectAllWithToggle } from './useSelectAllToggle';
23
22
  export { default as useColumnCenterAlign } from './useColumnCenterAlign';
24
23
  export { default as useColumnOrder } from './useColumnOrder';
25
24
  export { default as useInlineEdit } from './useInlineEdit';
26
- export { default as useFiltering } from './useFiltering';
25
+ export { default as useFiltering } from './useFiltering';
26
+ export { getAutoSizedColumnWidth } from './utils/getAutoSizedColumnWidth';
@@ -5,14 +5,18 @@
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
- import { useCallback } from 'react';
8
+ import { useCallback, useEffect } from 'react';
9
9
  import debounce from 'lodash/debounce';
10
10
  import useParentDimensions from './useParentDimensions';
11
11
  import useResizeTable from './useResizeTable';
12
+ import { pkg } from '../../settings';
12
13
 
13
14
  var useInfiniteScroll = function useInfiniteScroll(hooks) {
14
15
  useParentDimensions(hooks);
15
16
  useResizeTable(hooks);
17
+ useEffect(function () {
18
+ pkg.checkReportFeatureEnabled('Datagrid.useInfiniteScroll');
19
+ }, []);
16
20
 
17
21
  var useInstance = function useInstance(instance) {
18
22
  var isFetching = instance.isFetching,
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * Licensed Materials - Property of IBM
3
3
  * 5724-Q36
4
- * (c) Copyright IBM Corp. 2020
4
+ * (c) Copyright IBM Corp. 2020, 2023
5
5
  * US Government Users Restricted Rights - Use, duplication or disclosure
6
6
  * restricted by GSA ADP Schedule Contract with IBM Corp.
7
7
  */
@@ -16,9 +16,9 @@ var useOnRowClick = function useOnRowClick(hooks) {
16
16
  var id = row.id,
17
17
  toggleRowSelected = row.toggleRowSelected;
18
18
 
19
- var onClick = function onClick() {
19
+ var onClick = function onClick(event) {
20
20
  if (!isFetching && onRowClick) {
21
- onRowClick(row);
21
+ onRowClick(row, event);
22
22
  instance.selectedFlatRows && instance.selectedFlatRows.map(function (toggleRow) {
23
23
  return toggleRow.toggleRowSelected(false);
24
24
  });
@@ -26,6 +26,8 @@ var ordering = {
26
26
 
27
27
  var useSortableColumns = function useSortableColumns(hooks) {
28
28
  var sortableVisibleColumns = function sortableVisibleColumns(visibleColumns, _ref) {
29
+ var _instance$customizeCo;
30
+
29
31
  var instance = _ref.instance;
30
32
  var onSort = instance.onSort;
31
33
 
@@ -46,28 +48,36 @@ var useSortableColumns = function useSortableColumns(hooks) {
46
48
 
47
49
  var sortableColumns = visibleColumns.map(function (column) {
48
50
  var icon = function icon(col, props) {
49
- if (col.isSorted) {
51
+ if (col !== null && col !== void 0 && col.isSorted) {
50
52
  switch (col.isSortedDesc) {
51
53
  case false:
52
54
  return /*#__PURE__*/React.createElement(ArrowUp, _extends({
53
55
  size: 16
54
- }, props));
56
+ }, props, {
57
+ className: "".concat(blockClass, "__sortable-icon ").concat(carbon.prefix, "--btn__icon")
58
+ }));
55
59
 
56
60
  case true:
57
61
  return /*#__PURE__*/React.createElement(ArrowDown, _extends({
58
62
  size: 16
59
- }, props));
63
+ }, props, {
64
+ className: "".concat(blockClass, "__sortable-icon ").concat(carbon.prefix, "--btn__icon")
65
+ }));
60
66
 
61
67
  default:
62
68
  return /*#__PURE__*/React.createElement(ArrowsVertical, _extends({
63
69
  size: 16
64
- }, props));
70
+ }, props, {
71
+ className: "".concat(blockClass, "__sortable-icon ").concat(carbon.prefix, "--btn__icon")
72
+ }));
65
73
  }
66
74
  }
67
75
 
68
76
  return /*#__PURE__*/React.createElement(ArrowsVertical, _extends({
69
77
  size: 16
70
- }, props));
78
+ }, props, {
79
+ className: "".concat(blockClass, "__sortable-icon ").concat(carbon.prefix, "--btn__icon")
80
+ }));
71
81
  };
72
82
 
73
83
  var Header = function Header(headerProp) {
@@ -75,13 +85,13 @@ var useSortableColumns = function useSortableColumns(hooks) {
75
85
 
76
86
  return column.disableSortBy === true ? column.Header : /*#__PURE__*/React.createElement(Button, {
77
87
  onClick: function onClick() {
78
- return onSortClick(headerProp.column);
88
+ return onSortClick(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column);
79
89
  },
80
90
  kind: "ghost",
81
91
  renderIcon: function renderIcon(props) {
82
- return icon(headerProp.column, props);
92
+ return icon(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column, props);
83
93
  },
84
- className: cx("".concat(carbon.prefix, "--table-sort ").concat(blockClass, "--table-sort"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--table-sort--desc"), headerProp.column.isSortedDesc), _defineProperty(_cx, "".concat(blockClass, "--table-sort--asc"), headerProp.column.isSortedDesc === false), _cx))
94
+ className: cx("".concat(carbon.prefix, "--table-sort ").concat(blockClass, "--table-sort"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "--table-sort--desc"), headerProp === null || headerProp === void 0 ? void 0 : headerProp.column.isSortedDesc), _defineProperty(_cx, "".concat(blockClass, "--table-sort--asc"), (headerProp === null || headerProp === void 0 ? void 0 : headerProp.column.isSortedDesc) === false), _cx))
85
95
  }, column.Header);
86
96
  };
87
97
 
@@ -90,7 +100,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
90
100
  minWidth: column.disableSortBy === true ? 0 : 90
91
101
  });
92
102
  });
93
- return _toConsumableArray(sortableColumns);
103
+ return (_instance$customizeCo = instance.customizeColumnsProps) !== null && _instance$customizeCo !== void 0 && _instance$customizeCo.isTearsheetOpen ? visibleColumns : _toConsumableArray(sortableColumns);
94
104
  };
95
105
 
96
106
  var sortInstanceProps = function sortInstanceProps(instance) {