@carbon/ibm-products 2.0.0-rc.25 → 2.0.0-rc.27

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/README.md +10 -4
  2. package/css/index-full-carbon.css +129 -127
  3. package/css/index-full-carbon.css.map +1 -1
  4. package/css/index-full-carbon.min.css +3 -3
  5. package/css/index-full-carbon.min.css.map +1 -1
  6. package/css/index-without-carbon-released-only.css +69 -118
  7. package/css/index-without-carbon-released-only.css.map +1 -1
  8. package/css/index-without-carbon-released-only.min.css +2 -2
  9. package/css/index-without-carbon-released-only.min.css.map +1 -1
  10. package/css/index-without-carbon.css +129 -127
  11. package/css/index-without-carbon.css.map +1 -1
  12. package/css/index-without-carbon.min.css +3 -3
  13. package/css/index-without-carbon.min.css.map +1 -1
  14. package/css/index.css +129 -127
  15. package/css/index.css.map +1 -1
  16. package/css/index.min.css +3 -3
  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/Card/Card.js +8 -6
  24. package/es/components/Card/CardHeader.js +2 -2
  25. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +15 -20
  26. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
  27. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  28. package/es/components/Datagrid/Datagrid/DatagridRow.js +6 -2
  29. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
  30. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
  31. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
  32. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +15 -65
  33. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -2
  34. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +112 -0
  35. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
  36. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
  37. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +29 -23
  38. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -0
  39. package/es/components/Datagrid/index.js +7 -7
  40. package/es/components/Datagrid/useInfiniteScroll.js +5 -1
  41. package/es/components/Datagrid/useOnRowClick.js +3 -3
  42. package/es/components/Datagrid/useSortableColumns.js +7 -5
  43. package/es/components/Datagrid/utils/getAutoSizedColumnWidth.js +29 -0
  44. package/es/components/ExampleComponent/ExampleComponent.js +39 -5
  45. package/es/components/ExampleComponent/useExample.js +51 -0
  46. package/es/components/ExpressiveCard/ExpressiveCard.js +3 -3
  47. package/es/components/InlineEditV1/InlineEditV1.js +15 -20
  48. package/es/components/InlineEditV2/InlineEditV2.js +21 -31
  49. package/es/components/PageHeader/PageHeader.js +4 -3
  50. package/es/components/ProductiveCard/ProductiveCard.js +3 -3
  51. package/es/components/index.js +1 -1
  52. package/es/global/js/package-settings.js +24 -3
  53. package/es/global/js/utils/story-helper.js +9 -0
  54. package/es/global/js/utils/test-helper.js +38 -6
  55. package/lib/components/AddSelect/AddSelectBody.js +1 -0
  56. package/lib/components/AddSelect/AddSelectFormControl.js +110 -0
  57. package/lib/components/AddSelect/AddSelectList.js +29 -203
  58. package/lib/components/AddSelect/AddSelectRow.js +247 -0
  59. package/lib/components/AddSelect/hooks/useFocus.js +46 -0
  60. package/lib/components/Card/Card.js +7 -5
  61. package/lib/components/Card/CardHeader.js +2 -2
  62. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +14 -19
  63. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
  64. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  65. package/lib/components/Datagrid/Datagrid/DatagridRow.js +6 -2
  66. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
  67. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
  68. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
  69. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +16 -69
  70. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -2
  71. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +132 -0
  72. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
  73. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
  74. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +23 -16
  75. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -0
  76. package/lib/components/Datagrid/index.js +9 -1
  77. package/lib/components/Datagrid/useInfiniteScroll.js +5 -0
  78. package/lib/components/Datagrid/useOnRowClick.js +3 -3
  79. package/lib/components/Datagrid/useSortableColumns.js +7 -5
  80. package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.js +40 -0
  81. package/lib/components/ExampleComponent/ExampleComponent.js +47 -4
  82. package/lib/components/ExampleComponent/useExample.js +63 -0
  83. package/lib/components/ExpressiveCard/ExpressiveCard.js +3 -3
  84. package/lib/components/InlineEditV1/InlineEditV1.js +14 -19
  85. package/lib/components/InlineEditV2/InlineEditV2.js +20 -30
  86. package/lib/components/PageHeader/PageHeader.js +4 -3
  87. package/lib/components/ProductiveCard/ProductiveCard.js +3 -3
  88. package/lib/components/index.js +6 -0
  89. package/lib/global/js/package-settings.js +24 -3
  90. package/lib/global/js/utils/story-helper.js +13 -2
  91. package/lib/global/js/utils/test-helper.js +42 -8
  92. package/package.json +2 -2
  93. package/scss/components/ActionBar/_action-bar.scss +0 -4
  94. package/scss/components/AddSelect/_add-select.scss +4 -16
  95. package/scss/components/Card/_card.scss +13 -6
  96. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +15 -2
  97. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +18 -6
  98. package/scss/components/ExportModal/_export-modal.scss +0 -4
  99. package/scss/components/ExpressiveCard/_expressive-card.scss +1 -1
  100. package/scss/components/InlineEditV1/_inline-edit-v1.scss +5 -89
  101. package/scss/components/InlineEditV2/_inline-edit-v2.scss +42 -3
  102. package/scss/components/PageHeader/_page-header.scss +2 -3
  103. package/scss/components/ProductiveCard/_productive-card.scss +31 -2
  104. package/scss/components/SidePanel/_side-panel.scss +2 -1
  105. package/scss/components/TagSet/_tag-set.scss +1 -0
  106. package/scss/components/UserProfileImage/_user-profile-image.scss +5 -0
@@ -71,7 +71,9 @@ var DatagridRow = function DatagridRow(datagridState) {
71
71
 
72
72
  return /*#__PURE__*/React.createElement(TableRow, _extends({
73
73
  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))
74
- }, row.getRowProps(), {
74
+ }, row.getRowProps({
75
+ role: false
76
+ }), {
75
77
  key: row.id,
76
78
  onMouseEnter: function onMouseEnter(event) {
77
79
  if (!withNestedRows) {
@@ -105,7 +107,9 @@ var DatagridRow = function DatagridRow(datagridState) {
105
107
  }
106
108
  }
107
109
  }), row.cells.map(function (cell, index) {
108
- var cellProps = cell.getCellProps();
110
+ var cellProps = cell.getCellProps({
111
+ role: false
112
+ });
109
113
 
110
114
  var children = cellProps.children,
111
115
  restProps = _objectWithoutProperties(cellProps, _excluded);
@@ -22,7 +22,9 @@ var DatagridSimpleBody = function DatagridSimpleBody(datagridState) {
22
22
  var getTableBodyProps = datagridState.getTableBodyProps,
23
23
  rows = datagridState.rows,
24
24
  prepareRow = datagridState.prepareRow;
25
- return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
25
+ return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
26
+ role: false
27
+ }), {
26
28
  className: cx("".concat(blockClass, "__simple-body"), getTableBodyProps().className)
27
29
  }), rows.map(function (row) {
28
30
  prepareRow(row);
@@ -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,
@@ -85,7 +85,9 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
85
85
  width: (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth,
86
86
  overflow: 'hidden'
87
87
  }
88
- }, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
88
+ }, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
89
+ role: false
90
+ }), {
89
91
  onScroll: function onScroll(e) {
90
92
  return syncScroll(e);
91
93
  }
@@ -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,68 +96,17 @@ var Columns = function Columns(_ref) {
96
96
  },
97
97
  id: "".concat(blockClass, "__customization-column-select-all"),
98
98
  labelText: selectAllLabel
99
- })), columns // hide the columns without Header, e.g the sticky actions, spacer
100
- .filter(function (colDef) {
101
- return !!colDef.Header.props && !!colDef.Header.props.title;
102
- }).filter(function (colDef) {
103
- return !colDef.isAction;
104
- }).filter(function (colDef) {
105
- return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
106
- }).map(function (colDef, i) {
107
- var searchString = new RegExp('(' + filterString + ')');
108
- var res = filterString.length ? colDef.Header.props.title.toLowerCase().split(searchString) : null;
109
- 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;
110
- var highlightedText = res !== null ? res[0] === '' ? "<strong>".concat(firstWord, "</strong>") + res[2] : firstWord + "<strong>".concat(res[1], "</strong>") + res[2] : colDef.Header.props.title;
111
- var isFrozenColumn = !!colDef.sticky;
112
- var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
113
- className: cx("".concat(blockClass, "__customize-columns-checkbox-wrapper"), "".concat(blockClass, "__customize-columns-checkbox")),
114
- checked: isColumnVisible(colDef),
115
- disabled: isFrozenColumn,
116
- onChange: function onChange(_, _ref2) {
117
- var checked = _ref2.checked;
118
- return onSelectColumn(colDef, checked);
119
- },
120
- id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
121
- labelText: colDef.Header.props.title,
122
- title: colDef.Header.props.title,
123
- hideLabel: true
124
- }), /*#__PURE__*/React.createElement("div", {
125
- dangerouslySetInnerHTML: {
126
- __html: highlightedText
127
- }
128
- }));
129
- return /*#__PURE__*/React.createElement(DraggableElement, {
130
- key: colDef.id,
131
- index: i,
132
- listData: columns,
133
- setListData: setColumnsObject,
134
- id: "dnd-datagrid-columns-".concat(colDef.id),
135
- type: "column-customization",
136
- disabled: filterString.length > 0 || isFrozenColumn,
137
- ariaLabel: colDef.Header.props.title,
138
- onGrab: setAriaRegionText,
139
- isFocused: focusIndex === i,
140
- isSticky: isFrozenColumn,
141
- moveElement: moveElement,
142
- onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
143
- if (isGrabbed) {
144
- var _columns$nextIndex;
145
-
146
- var nextIndex = getNextIndex(columns, currentIndex, e.key);
147
- e.preventDefault();
148
- e.stopPropagation();
149
-
150
- if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
151
- setFocusIndex(nextIndex);
152
- moveElement(currentIndex, nextIndex);
153
- e.target.scrollIntoView({
154
- block: 'center'
155
- });
156
- }
157
- }
158
- },
159
- selected: isColumnVisible(colDef)
160
- }, 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
161
110
  }))));
162
111
  };
163
112
 
@@ -169,6 +118,7 @@ Columns.propTypes = {
169
118
  filterString: PropTypes.string.isRequired,
170
119
  getVisibleColumnsCount: PropTypes.func.isRequired,
171
120
  instructionsLabel: PropTypes.string,
121
+ isTableSortable: PropTypes.bool.isRequired,
172
122
  onSelectColumn: PropTypes.func.isRequired,
173
123
  selectAllLabel: PropTypes.string,
174
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),
@@ -167,7 +168,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
167
168
  setColumnObjects(cols);
168
169
  setDirty();
169
170
  },
170
- selectAllLabel: selectAllLabel
171
+ selectAllLabel: selectAllLabel,
172
+ isTableSortable: isTableSortable
171
173
  }));
172
174
  };
173
175
 
@@ -179,6 +181,7 @@ CustomizeColumnsTearsheet.propTypes = {
179
181
  findColumnPlaceholderLabel: PropTypes.string,
180
182
  instructionsLabel: PropTypes.string,
181
183
  isOpen: PropTypes.bool.isRequired,
184
+ isTableSortable: PropTypes.bool.isRequired,
182
185
  onSaveColumnPrefs: PropTypes.func.isRequired,
183
186
  originalColumnDefinitions: PropTypes.array.isRequired,
184
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,
@@ -133,6 +133,17 @@ var useFilters = function useFilters(_ref) {
133
133
 
134
134
  filtersObjectArrayCopy.splice(_index2, 1);
135
135
  }
136
+ } else if (type === NUMBER) {
137
+ // If the value is empty remove it from the filtersObjectArray
138
+ if (value === '') {
139
+ // Find the column that uses number and displays an empty string
140
+ var _index3 = filtersObjectArrayCopy.findIndex(function (filter) {
141
+ return filter.id === column;
142
+ }); // Remove it from the filters array
143
+
144
+
145
+ filtersObjectArrayCopy.splice(_index3, 1);
146
+ }
136
147
  }
137
148
 
138
149
  setFiltersObjectArray(filtersObjectArrayCopy); // // Automatically apply the filters if the updateMethod is instant
@@ -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,7 +48,7 @@ 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({
@@ -83,13 +85,13 @@ var useSortableColumns = function useSortableColumns(hooks) {
83
85
 
84
86
  return column.disableSortBy === true ? column.Header : /*#__PURE__*/React.createElement(Button, {
85
87
  onClick: function onClick() {
86
- return onSortClick(headerProp.column);
88
+ return onSortClick(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column);
87
89
  },
88
90
  kind: "ghost",
89
91
  renderIcon: function renderIcon(props) {
90
- return icon(headerProp.column, props);
92
+ return icon(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column, props);
91
93
  },
92
- 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))
93
95
  }, column.Header);
94
96
  };
95
97
 
@@ -98,7 +100,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
98
100
  minWidth: column.disableSortBy === true ? 0 : 90
99
101
  });
100
102
  });
101
- return _toConsumableArray(sortableColumns);
103
+ return (_instance$customizeCo = instance.customizeColumnsProps) !== null && _instance$customizeCo !== void 0 && _instance$customizeCo.isTearsheetOpen ? visibleColumns : _toConsumableArray(sortableColumns);
102
104
  };
103
105
 
104
106
  var sortInstanceProps = function sortInstanceProps(instance) {
@@ -0,0 +1,29 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2023, 2023
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+
10
+ /**
11
+ * Calculates the auto sized width of a column
12
+ * @param {Array<object>} rows - The datagrid rows
13
+ * @param {string} accessor - The accessor for the column
14
+ * @param {string} headerText - The header text for the column
15
+ */
16
+ export var getAutoSizedColumnWidth = function getAutoSizedColumnWidth(rows, accessor, headerText) {
17
+ var maxWidth = 400;
18
+ var minWidth = 58;
19
+ var letterSpacing = 10;
20
+ var cellLength = Math.max.apply(Math, _toConsumableArray(rows.map(function (row) {
21
+ return ("".concat(row[accessor]) || '').length;
22
+ })).concat([headerText.length]));
23
+
24
+ if (cellLength <= 3) {
25
+ return minWidth;
26
+ }
27
+
28
+ return Math.min(maxWidth, cellLength * letterSpacing + 16);
29
+ };