@carbon/ibm-products 1.48.0 → 1.50.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. package/css/index-full-carbon.css +41 -5
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +4 -4
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +40 -4
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +2 -2
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +41 -5
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +4 -4
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +41 -5
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +4 -4
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Card/Card.js +3 -3
  18. package/es/components/Card/CardHeader.js +3 -3
  19. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +16 -20
  20. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
  21. package/es/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  22. package/es/components/Datagrid/Datagrid/DatagridRow.js +6 -2
  23. package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
  24. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
  25. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
  26. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +6 -3
  27. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +15 -62
  28. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -2
  29. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +105 -0
  30. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
  31. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +17 -5
  32. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
  33. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +8 -8
  34. package/es/components/Datagrid/index.js +8 -7
  35. package/es/components/Datagrid/useOnRowClick.js +3 -3
  36. package/es/components/Datagrid/useSortableColumns.js +6 -5
  37. package/es/components/Datagrid/utils/getAutoSizedColumnWidth.js +27 -0
  38. package/es/components/ExpressiveCard/ExpressiveCard.js +3 -3
  39. package/es/components/InlineEditV2/InlineEditV2.js +6 -3
  40. package/es/components/ProductiveCard/ProductiveCard.js +3 -3
  41. package/es/components/SidePanel/SidePanel.js +1 -1
  42. package/es/components/index.js +1 -1
  43. package/es/global/js/utils/story-helper.js +9 -0
  44. package/lib/components/Card/Card.js +3 -3
  45. package/lib/components/Card/CardHeader.js +3 -3
  46. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +14 -19
  47. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
  48. package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
  49. package/lib/components/Datagrid/Datagrid/DatagridRow.js +6 -2
  50. package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
  51. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
  52. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
  53. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +6 -3
  54. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +15 -62
  55. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -2
  56. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +113 -0
  57. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
  58. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +17 -5
  59. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
  60. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +3 -1
  61. package/lib/components/Datagrid/index.js +8 -1
  62. package/lib/components/Datagrid/useOnRowClick.js +3 -3
  63. package/lib/components/Datagrid/useSortableColumns.js +6 -5
  64. package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.js +35 -0
  65. package/lib/components/ExpressiveCard/ExpressiveCard.js +3 -3
  66. package/lib/components/InlineEditV2/InlineEditV2.js +6 -3
  67. package/lib/components/ProductiveCard/ProductiveCard.js +3 -3
  68. package/lib/components/SidePanel/SidePanel.js +1 -1
  69. package/lib/components/index.js +6 -0
  70. package/lib/global/js/utils/story-helper.js +12 -2
  71. package/package.json +2 -2
  72. package/scss/components/Datagrid/styles/_datagrid.scss +1 -1
  73. package/scss/components/InlineEditV1/_inline-edit-v1.scss +1 -5
  74. package/scss/components/InlineEditV2/_inline-edit-v2.scss +41 -3
  75. package/scss/components/SidePanel/_side-panel.scss +2 -1
  76. package/scss/components/TagSet/_tag-set.scss +6 -0
@@ -1,15 +1,15 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- /*
3
- * Licensed Materials - Property of IBM
4
- * 5724-Q36
5
- * (c) Copyright IBM Corp. 2020
6
- * US Government Users Restricted Rights - Use, duplication or disclosure
7
- * restricted by GSA ADP Schedule Contract with IBM Corp.
2
+ /**
3
+ * Copyright IBM Corp. 2020, 2023
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
8
7
  */
8
+
9
9
  import React from 'react';
10
10
  import { pkg } from '../../../settings';
11
11
  import { DataTable } from 'carbon-components-react';
12
- import { NoDataEmptyState, ErrorEmptyState } from '../../EmptyStates';
12
+ import { NoDataEmptyState, ErrorEmptyState, NotFoundEmptyState } from '../../EmptyStates';
13
13
  var blockClass = "".concat(pkg.prefix, "--datagrid");
14
14
  var TableBody = DataTable.TableBody,
15
15
  TableRow = DataTable.TableRow,
@@ -25,24 +25,20 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
25
25
  illustrationTheme = datagridState.illustrationTheme,
26
26
  emptyStateAction = datagridState.emptyStateAction,
27
27
  emptyStateLink = datagridState.emptyStateLink;
28
- return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
29
- className: "".concat(blockClass, "__empty-state-body")
30
- }), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
31
- colSpan: headers.length
32
- }, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, {
33
- illustrationTheme: illustrationTheme,
34
- size: emptyStateSize,
35
- title: emptyStateTitle,
36
- subtitle: emptyStateDescription,
37
- action: emptyStateAction,
38
- link: emptyStateLink
39
- }), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, {
28
+ var emptyStateProps = {
40
29
  illustrationTheme: illustrationTheme,
41
30
  size: emptyStateSize,
42
31
  title: emptyStateTitle,
43
32
  subtitle: emptyStateDescription,
44
33
  action: emptyStateAction,
45
34
  link: emptyStateLink
46
- }))));
35
+ };
36
+ return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
37
+ role: false
38
+ }), {
39
+ className: "".concat(blockClass, "__empty-state-body")
40
+ }), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
41
+ colSpan: headers.length
42
+ }, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/React.createElement(NotFoundEmptyState, emptyStateProps))));
47
43
  };
48
44
  export default DatagridEmptyBody;
@@ -15,7 +15,9 @@ import { selectionColumnId } from '../common-column-ids';
15
15
  import { pkg } from '../../../settings';
16
16
  var blockClass = "".concat(pkg.prefix, "--datagrid");
17
17
  var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
18
- return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps(), {
18
+ return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps({
19
+ role: false
20
+ }), {
19
21
  className: cx("".concat(blockClass, "__head"), headerGroup.getHeaderGroupProps().className),
20
22
  ref: headRef
21
23
  }), datagridState.headers.filter(function (_ref) {
@@ -29,7 +31,9 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
29
31
  key: header.id
30
32
  });
31
33
  }
32
- return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps(), {
34
+ return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps({
35
+ role: false
36
+ }), {
33
37
  className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), header.canSort), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
34
38
  key: header.id
35
39
  }), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement("div", _extends({}, header.getResizerProps(), {
@@ -22,7 +22,9 @@ var DatagridRefBody = function DatagridRefBody(datagridState) {
22
22
  var getTableBodyProps = datagridState.getTableBodyProps,
23
23
  rows = datagridState.rows,
24
24
  prepareRow = datagridState.prepareRow;
25
- return /*#__PURE__*/React.createElement("tbody", _extends({}, getTableBodyProps(), {
25
+ return /*#__PURE__*/React.createElement("tbody", _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);
@@ -65,7 +65,9 @@ var DatagridRow = function DatagridRow(datagridState) {
65
65
  };
66
66
  return /*#__PURE__*/React.createElement(TableRow, _extends({
67
67
  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))
68
- }, row.getRowProps(), {
68
+ }, row.getRowProps({
69
+ role: false
70
+ }), {
69
71
  key: row.id,
70
72
  onMouseEnter: function onMouseEnter(event) {
71
73
  if (!withNestedRows) {
@@ -96,7 +98,9 @@ var DatagridRow = function DatagridRow(datagridState) {
96
98
  }
97
99
  }
98
100
  }), row.cells.map(function (cell, index) {
99
- var cellProps = cell.getCellProps();
101
+ var cellProps = cell.getCellProps({
102
+ role: false
103
+ });
100
104
  var children = cellProps.children,
101
105
  restProps = _objectWithoutProperties(cellProps, _excluded);
102
106
  var content = children || /*#__PURE__*/React.createElement(React.Fragment, null, !row.isSkeleton && cell.render('Cell'), row.isSkeleton && /*#__PURE__*/React.createElement(SkeletonText, null));
@@ -19,7 +19,9 @@ var DatagridSimpleBody = function DatagridSimpleBody(datagridState) {
19
19
  var getTableBodyProps = datagridState.getTableBodyProps,
20
20
  rows = datagridState.rows,
21
21
  prepareRow = datagridState.prepareRow;
22
- return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
22
+ return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
23
+ role: false
24
+ }), {
23
25
  className: cx("".concat(blockClass, "__simple-body"), getTableBodyProps().className)
24
26
  }), rows.map(function (row) {
25
27
  prepareRow(row);
@@ -108,7 +108,7 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
108
108
  setGlobalFilter(null);
109
109
  }
110
110
  }, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
111
- if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length === 3) {
111
+ if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length <= 3) {
112
112
  return /*#__PURE__*/React.createElement(TableBatchAction, {
113
113
  key: "".concat(batchAction.label, "-").concat(index),
114
114
  renderIcon: batchAction.renderIcon,
@@ -76,7 +76,9 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
76
76
  width: (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth,
77
77
  overflow: 'hidden'
78
78
  }
79
- }, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(), {
79
+ }, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
80
+ role: false
81
+ }), {
80
82
  onScroll: function onScroll(e) {
81
83
  return syncScroll(e);
82
84
  }
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["onClick", "setIsTearsheetOpen", "isTearsheetOpen", "iconTooltipLabel"];
3
+ var _excluded = ["onClick", "setIsTearsheetOpen", "isTearsheetOpen", "iconTooltipLabel", "tooltipPosition"];
4
4
  /**
5
5
  * Copyright IBM Corp. 2022, 2022
6
6
  *
@@ -20,11 +20,13 @@ var ButtonWrapper = function ButtonWrapper(_ref) {
20
20
  isTearsheetOpen = _ref.isTearsheetOpen,
21
21
  _ref$iconTooltipLabel = _ref.iconTooltipLabel,
22
22
  iconTooltipLabel = _ref$iconTooltipLabel === void 0 ? 'Customize columns' : _ref$iconTooltipLabel,
23
+ _ref$tooltipPosition = _ref.tooltipPosition,
24
+ tooltipPosition = _ref$tooltipPosition === void 0 ? 'bottom' : _ref$tooltipPosition,
23
25
  rest = _objectWithoutProperties(_ref, _excluded);
24
26
  return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
25
27
  renderIcon: Column16,
26
28
  iconDescription: iconTooltipLabel,
27
- tooltipPosition: "left",
29
+ tooltipPosition: tooltipPosition,
28
30
  kind: "ghost",
29
31
  hasIconOnly: true,
30
32
  "test-id": "".concat(blockClass, "__customize-columns-trigger"),
@@ -40,6 +42,7 @@ ButtonWrapper.propTypes = {
40
42
  iconTooltipLabel: PropTypes.string,
41
43
  isTearsheetOpen: PropTypes.bool.isRequired,
42
44
  onClick: PropTypes.func.isRequired,
43
- setIsTearsheetOpen: PropTypes.func.isRequired
45
+ setIsTearsheetOpen: PropTypes.func.isRequired,
46
+ tooltipPosition: Button.propTypes.tooltipPosition
44
47
  };
45
48
  export default ButtonWrapper;
@@ -14,9 +14,8 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
14
14
  import { Checkbox } from 'carbon-components-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 classNames from 'classnames';
18
+ import { DraggableItemsList } from './DraggableItemsList';
20
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
20
  var getNextIndex = function getNextIndex(array, currentIndex, key) {
22
21
  var newIndex = -1;
@@ -36,7 +35,8 @@ var Columns = function Columns(_ref) {
36
35
  onSelectColumn = _ref.onSelectColumn,
37
36
  assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
38
37
  assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
39
- selectAllLabel = _ref.selectAllLabel;
38
+ selectAllLabel = _ref.selectAllLabel,
39
+ isTableSortable = _ref.isTableSortable;
40
40
  var _React$useState = React.useState(''),
41
41
  _React$useState2 = _slicedToArray(_React$useState, 2),
42
42
  ariaRegionText = _React$useState2[0],
@@ -87,65 +87,17 @@ var Columns = function Columns(_ref) {
87
87
  },
88
88
  id: "".concat(blockClass, "__customization-column-select-all"),
89
89
  labelText: selectAllLabel
90
- })), columns
91
- // hide the columns without Header, e.g the sticky actions, spacer
92
- .filter(function (colDef) {
93
- return !!colDef.Header.props && !!colDef.Header.props.title;
94
- }).filter(function (colDef) {
95
- return !colDef.isAction;
96
- }).filter(function (colDef) {
97
- return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
98
- }).map(function (colDef, i) {
99
- var searchString = new RegExp('(' + filterString + ')');
100
- var res = filterString.length ? colDef.Header.props.title.toLowerCase().split(searchString) : null;
101
- 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;
102
- var highlightedText = res !== null ? res[0] === '' ? "<strong>".concat(firstWord, "</strong>") + res[2] : firstWord + "<strong>".concat(res[1], "</strong>") + res[2] : colDef.Header.props.title;
103
- var isFrozenColumn = !!colDef.sticky;
104
- var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
105
- wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
106
- checked: isColumnVisible(colDef),
107
- disabled: isFrozenColumn,
108
- onChange: onSelectColumn.bind(null, colDef),
109
- id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
110
- labelText: colDef.Header.props.title,
111
- title: colDef.Header.props.title,
112
- className: "".concat(blockClass, "__customize-columns-checkbox"),
113
- hideLabel: true
114
- }), /*#__PURE__*/React.createElement("div", {
115
- dangerouslySetInnerHTML: {
116
- __html: highlightedText
117
- }
118
- }));
119
- return /*#__PURE__*/React.createElement(DraggableElement, {
120
- key: colDef.id,
121
- index: i,
122
- listData: columns,
123
- setListData: setColumnsObject,
124
- id: "dnd-datagrid-columns-".concat(colDef.id),
125
- type: "column-customization",
126
- disabled: filterString.length > 0 || isFrozenColumn,
127
- ariaLabel: colDef.Header.props.title,
128
- onGrab: setAriaRegionText,
129
- isFocused: focusIndex === i,
130
- moveElement: moveElement,
131
- onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
132
- if (isGrabbed) {
133
- var _columns$nextIndex;
134
- var nextIndex = getNextIndex(columns, currentIndex, e.key);
135
- e.preventDefault();
136
- e.stopPropagation();
137
- if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
138
- setFocusIndex(nextIndex);
139
- moveElement(currentIndex, nextIndex);
140
- e.target.scrollIntoView({
141
- block: 'center'
142
- });
143
- }
144
- }
145
- },
146
- isSticky: isFrozenColumn,
147
- selected: isColumnVisible(colDef)
148
- }, listContents);
90
+ })), /*#__PURE__*/React.createElement(DraggableItemsList, {
91
+ columns: columns,
92
+ filterString: filterString,
93
+ focusIndex: focusIndex,
94
+ getNextIndex: getNextIndex,
95
+ isTableSortable: isTableSortable,
96
+ moveElement: moveElement,
97
+ onSelectColumn: onSelectColumn,
98
+ setAriaRegionText: setAriaRegionText,
99
+ setColumnsObject: setColumnsObject,
100
+ setFocusIndex: setFocusIndex
149
101
  }))));
150
102
  };
151
103
  Columns.propTypes = {
@@ -156,6 +108,7 @@ Columns.propTypes = {
156
108
  filterString: PropTypes.string.isRequired,
157
109
  getVisibleColumnsCount: PropTypes.func.isRequired,
158
110
  instructionsLabel: PropTypes.string,
111
+ isTableSortable: PropTypes.bool.isRequired,
159
112
  onSelectColumn: PropTypes.func.isRequired,
160
113
  selectAllLabel: PropTypes.string,
161
114
  setColumnStatus: PropTypes.func,
@@ -41,7 +41,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
41
41
  _ref$assistiveTextDis = _ref.assistiveTextDisabledInstructionsLabel,
42
42
  assistiveTextDisabledInstructionsLabel = _ref$assistiveTextDis === void 0 ? 'Reordering columns are disabled because they are filtered currently.' : _ref$assistiveTextDis,
43
43
  _ref$selectAllLabel = _ref.selectAllLabel,
44
- selectAllLabel = _ref$selectAllLabel === void 0 ? 'Column name' : _ref$selectAllLabel;
44
+ selectAllLabel = _ref$selectAllLabel === void 0 ? 'Column name' : _ref$selectAllLabel,
45
+ isTableSortable = _ref.isTableSortable;
45
46
  var _useState = useState(''),
46
47
  _useState2 = _slicedToArray(_useState, 2),
47
48
  visibleColumnsCount = _useState2[0],
@@ -151,7 +152,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
151
152
  setColumnObjects(cols);
152
153
  setDirty();
153
154
  },
154
- selectAllLabel: selectAllLabel
155
+ selectAllLabel: selectAllLabel,
156
+ isTableSortable: isTableSortable
155
157
  }));
156
158
  };
157
159
  CustomizeColumnsTearsheet.propTypes = {
@@ -162,6 +164,7 @@ CustomizeColumnsTearsheet.propTypes = {
162
164
  findColumnPlaceholderLabel: PropTypes.string,
163
165
  instructionsLabel: PropTypes.string,
164
166
  isOpen: PropTypes.bool.isRequired,
167
+ isTableSortable: PropTypes.bool.isRequired,
165
168
  onSaveColumnPrefs: PropTypes.func.isRequired,
166
169
  originalColumnDefinitions: PropTypes.array.isRequired,
167
170
  primaryButtonTextLabel: PropTypes.string,
@@ -0,0 +1,105 @@
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
+
8
+ import React from 'react';
9
+ import { PropTypes } from 'prop-types';
10
+ import { Checkbox } from 'carbon-components-react';
11
+ import { isColumnVisible } from './common';
12
+ import DraggableElement from '../../DraggableElement';
13
+ import { pkg } from '../../../../../settings';
14
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
15
+ export var DraggableItemsList = function DraggableItemsList(_ref) {
16
+ var columns = _ref.columns,
17
+ filterString = _ref.filterString,
18
+ focusIndex = _ref.focusIndex,
19
+ getNextIndex = _ref.getNextIndex,
20
+ isTableSortable = _ref.isTableSortable,
21
+ moveElement = _ref.moveElement,
22
+ onSelectColumn = _ref.onSelectColumn,
23
+ setAriaRegionText = _ref.setAriaRegionText,
24
+ setColumnsObject = _ref.setColumnsObject,
25
+ setFocusIndex = _ref.setFocusIndex;
26
+ return /*#__PURE__*/React.createElement(React.Fragment, null, columns
27
+ // hide the columns without Header, e.g the sticky actions, spacer
28
+ .filter(function (colDef) {
29
+ var _colDef$Header$props$, _colDef$Header$props;
30
+ var sortableTitle = isTableSortable && ((_colDef$Header$props$ = colDef.Header().props.children.props) === null || _colDef$Header$props$ === void 0 ? void 0 : _colDef$Header$props$.title);
31
+ return !!colDef.Header.props && !!((_colDef$Header$props = colDef.Header.props) !== null && _colDef$Header$props !== void 0 && _colDef$Header$props.title) || isTableSortable && !!sortableTitle;
32
+ }).filter(function (colDef) {
33
+ return !colDef.isAction;
34
+ }).filter(function (colDef) {
35
+ var _colDef$Header$props$2, _colDef$Header$props2, _colDef$Header$props3;
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
+ var isSortableColumn = !!colDef.canSort && !!isTableSortable;
41
+ 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);
42
+ var searchString = new RegExp('(' + filterString + ')');
43
+ var res = filterString.length ? isSortableColumn ? sortableTitle.toLowerCase().split(searchString) : colDef.Header.props.title.toLowerCase().split(searchString) : null;
44
+ 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;
45
+ 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;
46
+ var isFrozenColumn = !!colDef.sticky;
47
+ var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
48
+ wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
49
+ checked: isColumnVisible(colDef),
50
+ disabled: isFrozenColumn,
51
+ onChange: onSelectColumn.bind(null, colDef),
52
+ id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
53
+ labelText: isSortableColumn ? sortableTitle : (_colDef$Header$props5 = colDef.Header.props) === null || _colDef$Header$props5 === void 0 ? void 0 : _colDef$Header$props5.title,
54
+ title: isSortableColumn ? sortableTitle : (_colDef$Header$props6 = colDef.Header.props) === null || _colDef$Header$props6 === void 0 ? void 0 : _colDef$Header$props6.title,
55
+ className: "".concat(blockClass, "__customize-columns-checkbox"),
56
+ hideLabel: true
57
+ }), /*#__PURE__*/React.createElement("div", {
58
+ dangerouslySetInnerHTML: {
59
+ __html: highlightedText
60
+ }
61
+ }));
62
+ return /*#__PURE__*/React.createElement(DraggableElement, {
63
+ key: colDef.id,
64
+ index: i,
65
+ listData: columns,
66
+ setListData: setColumnsObject,
67
+ id: "dnd-datagrid-columns-".concat(colDef.id),
68
+ type: "column-customization",
69
+ disabled: filterString.length > 0 || isFrozenColumn,
70
+ ariaLabel: isSortableColumn ? sortableTitle : (_colDef$Header$props7 = colDef.Header.props) === null || _colDef$Header$props7 === void 0 ? void 0 : _colDef$Header$props7.title,
71
+ onGrab: setAriaRegionText,
72
+ isFocused: focusIndex === i,
73
+ moveElement: moveElement,
74
+ onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
75
+ if (isGrabbed) {
76
+ var _columns$nextIndex;
77
+ var nextIndex = getNextIndex(columns, currentIndex, e.key);
78
+ e.preventDefault();
79
+ e.stopPropagation();
80
+ if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
81
+ setFocusIndex(nextIndex);
82
+ moveElement(currentIndex, nextIndex);
83
+ e.target.scrollIntoView({
84
+ block: 'center'
85
+ });
86
+ }
87
+ }
88
+ },
89
+ isSticky: isFrozenColumn,
90
+ selected: isColumnVisible(colDef)
91
+ }, listContents);
92
+ }));
93
+ };
94
+ DraggableItemsList.propTypes = {
95
+ columns: PropTypes.array.isRequired,
96
+ filterString: PropTypes.string.isRequired,
97
+ focusIndex: PropTypes.number.isRequired,
98
+ getNextIndex: PropTypes.func.isRequired,
99
+ isTableSortable: PropTypes.bool,
100
+ moveElement: PropTypes.func.isRequired,
101
+ onSelectColumn: PropTypes.func.isRequired,
102
+ setAriaRegionText: PropTypes.func.isRequired,
103
+ setColumnsObject: PropTypes.func.isRequired,
104
+ setFocusIndex: PropTypes.func.isRequired
105
+ };
@@ -21,6 +21,7 @@ var TearsheetWrapper = function TearsheetWrapper(_ref) {
21
21
  rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
22
22
  return /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
23
23
  isOpen: isTearsheetOpen,
24
+ isTableSortable: instance === null || instance === void 0 ? void 0 : instance.isTableSortable,
24
25
  setIsTearsheetOpen: setIsTearsheetOpen,
25
26
  columnDefinitions: instance.allColumns,
26
27
  originalColumnDefinitions: instance.columns,
@@ -45,7 +45,15 @@ var FilterPanel = function FilterPanel(_ref) {
45
45
  _ref$showFilterSearch = _ref.showFilterSearch,
46
46
  showFilterSearch = _ref$showFilterSearch === void 0 ? false : _ref$showFilterSearch,
47
47
  _ref$filterPanelMinHe = _ref.filterPanelMinHeight,
48
- filterPanelMinHeight = _ref$filterPanelMinHe === void 0 ? 600 : _ref$filterPanelMinHe;
48
+ filterPanelMinHeight = _ref$filterPanelMinHe === void 0 ? 600 : _ref$filterPanelMinHe,
49
+ _ref$primaryActionLab = _ref.primaryActionLabel,
50
+ primaryActionLabel = _ref$primaryActionLab === void 0 ? 'Apply' : _ref$primaryActionLab,
51
+ _ref$secondaryActionL = _ref.secondaryActionLabel,
52
+ secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
53
+ _ref$searchLabelText = _ref.searchLabelText,
54
+ searchLabelText = _ref$searchLabelText === void 0 ? 'Filter search' : _ref$searchLabelText,
55
+ _ref$searchPlaceholde = _ref.searchPlaceholder,
56
+ searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde;
49
57
  /** State */
50
58
  var _useState = useState(false),
51
59
  _useState2 = _slicedToArray(_useState, 2),
@@ -120,13 +128,13 @@ var FilterPanel = function FilterPanel(_ref) {
120
128
  actions: [{
121
129
  key: 1,
122
130
  kind: 'primary',
123
- label: 'Apply',
131
+ label: primaryActionLabel,
124
132
  onClick: apply,
125
133
  disabled: shouldDisableButtons
126
134
  }, {
127
135
  key: 2,
128
136
  kind: 'secondary',
129
- label: 'Cancel',
137
+ label: secondaryActionLabel,
130
138
  onClick: cancel,
131
139
  disabled: shouldDisableButtons
132
140
  }],
@@ -189,8 +197,8 @@ var FilterPanel = function FilterPanel(_ref) {
189
197
  ref: filterSearchRef,
190
198
  className: "".concat(componentClass, "__search")
191
199
  }, /*#__PURE__*/React.createElement(Search, {
192
- labelText: "Filter search",
193
- placeHolderText: "Find filters",
200
+ labelText: searchLabelText,
201
+ placeHolderText: searchPlaceholder,
194
202
  light: true,
195
203
  size: "sm"
196
204
  }))), /*#__PURE__*/React.createElement("div", {
@@ -231,6 +239,10 @@ FilterPanel.propTypes = {
231
239
  onPanelClose: PropTypes.func,
232
240
  onPanelOpen: PropTypes.func,
233
241
  open: PropTypes.bool,
242
+ primaryActionLabel: PropTypes.string,
243
+ searchLabelText: PropTypes.string,
244
+ searchPlaceholder: PropTypes.string,
245
+ secondaryActionLabel: PropTypes.string,
234
246
  setAllFilters: PropTypes.func.isRequired,
235
247
  showFilterSearch: PropTypes.bool,
236
248
  title: PropTypes.string,
@@ -125,6 +125,17 @@ var useFilters = function useFilters(_ref) {
125
125
  // Remove it from the filters array
126
126
  filtersObjectArrayCopy.splice(_index2, 1);
127
127
  }
128
+ } else if (type === NUMBER) {
129
+ // If the value is empty remove it from the filtersObjectArray
130
+ if (value === '') {
131
+ // Find the column that uses number and displays an empty string
132
+ var _index3 = filtersObjectArrayCopy.findIndex(function (filter) {
133
+ return filter.id === column;
134
+ });
135
+
136
+ // Remove it from the filters array
137
+ filtersObjectArrayCopy.splice(_index3, 1);
138
+ }
128
139
  }
129
140
  setFiltersObjectArray(filtersObjectArrayCopy);
130
141
 
@@ -3,13 +3,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
5
5
  var _excluded = ["legendText"];
6
- // @flow
7
- /*
8
- * Licensed Materials - Property of IBM
9
- * 5724-Q36
10
- * (c) Copyright IBM Corp. 2021
11
- * US Government Users Restricted Rights - Use, duplication or disclosure
12
- * 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.
13
11
  */
14
12
 
15
13
  import * as React from 'react';
@@ -36,7 +34,9 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
36
34
  tooltipPosition: "bottom",
37
35
  renderIcon: Settings16,
38
36
  onClick: function onClick() {
39
- return setIsOpen(!isOpen);
37
+ return setIsOpen(function (prevOpen) {
38
+ return !prevOpen;
39
+ });
40
40
  },
41
41
  iconDescription: legendText,
42
42
  className: cx("".concat(blockClass, "__row-size-button"), _defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
@@ -1,10 +1,10 @@
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
  */
7
+
8
8
  export { Datagrid } from './Datagrid';
9
9
  export { default as useDatagrid } from './useDatagrid';
10
10
  export { default as useInfiniteScroll } from './useInfiniteScroll';
@@ -23,4 +23,5 @@ export { default as useSelectAllWithToggle } from './useSelectAllToggle';
23
23
  export { default as useColumnCenterAlign } from './useColumnCenterAlign';
24
24
  export { default as useColumnOrder } from './useColumnOrder';
25
25
  export { default as useInlineEdit } from './useInlineEdit';
26
- export { default as useFiltering } from './useFiltering';
26
+ export { default as useFiltering } from './useFiltering';
27
+ export { getAutoSizedColumnWidth } from './utils/getAutoSizedColumnWidth';
@@ -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
  */
@@ -15,9 +15,9 @@ var useOnRowClick = function useOnRowClick(hooks) {
15
15
  instance = datagridState.instance;
16
16
  var id = row.id,
17
17
  toggleRowSelected = row.toggleRowSelected;
18
- var onClick = function onClick() {
18
+ var onClick = function onClick(event) {
19
19
  if (!isFetching && onRowClick) {
20
- onRowClick(row);
20
+ onRowClick(row, event);
21
21
  instance.selectedFlatRows && instance.selectedFlatRows.map(function (toggleRow) {
22
22
  return toggleRow.toggleRowSelected(false);
23
23
  });
@@ -22,6 +22,7 @@ var ordering = {
22
22
  };
23
23
  var useSortableColumns = function useSortableColumns(hooks) {
24
24
  var sortableVisibleColumns = function sortableVisibleColumns(visibleColumns, _ref) {
25
+ var _instance$customizeCo;
25
26
  var instance = _ref.instance;
26
27
  var onSort = instance.onSort;
27
28
  var onSortClick = function onSortClick(column) {
@@ -37,7 +38,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
37
38
  };
38
39
  var sortableColumns = visibleColumns.map(function (column) {
39
40
  var icon = function icon(col) {
40
- if (col.isSorted) {
41
+ if (col !== null && col !== void 0 && col.isSorted) {
41
42
  switch (col.isSortedDesc) {
42
43
  case false:
43
44
  return function () {
@@ -69,11 +70,11 @@ var useSortableColumns = function useSortableColumns(hooks) {
69
70
  var _cx;
70
71
  return column.disableSortBy === true ? column.Header : /*#__PURE__*/React.createElement(Button, {
71
72
  onClick: function onClick() {
72
- return onSortClick(headerProp.column);
73
+ return onSortClick(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column);
73
74
  },
74
75
  kind: "ghost",
75
- renderIcon: icon(headerProp.column),
76
- 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))
76
+ renderIcon: icon(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column),
77
+ 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))
77
78
  }, column.Header);
78
79
  };
79
80
  return _objectSpread(_objectSpread({}, column), {}, {
@@ -81,7 +82,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
81
82
  minWidth: column.disableSortBy === true ? 0 : 90
82
83
  });
83
84
  });
84
- return _toConsumableArray(sortableColumns);
85
+ return (_instance$customizeCo = instance.customizeColumnsProps) !== null && _instance$customizeCo !== void 0 && _instance$customizeCo.isTearsheetOpen ? visibleColumns : _toConsumableArray(sortableColumns);
85
86
  };
86
87
  var sortInstanceProps = function sortInstanceProps(instance) {
87
88
  var onSort = instance.onSort;