@carbon/ibm-products 1.60.0 → 1.61.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/css/index-full-carbon.css +57 -37
  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 +9 -3
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +47 -22
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +3 -3
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +47 -37
  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/Datagrid/Datagrid/DatagridContent.js +3 -1
  18. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +10 -54
  19. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +9 -8
  20. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +6 -12
  21. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +0 -5
  22. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +17 -5
  23. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +4 -3
  24. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +37 -24
  25. package/es/components/Datagrid/useColumnCenterAlign.js +6 -6
  26. package/es/components/Datagrid/useColumnRightAlign.js +6 -6
  27. package/es/components/Datagrid/useInlineEdit.js +1 -6
  28. package/es/components/Datagrid/useNestedRowExpander.js +10 -1
  29. package/es/components/Datagrid/useRowExpander.js +11 -1
  30. package/es/components/Datagrid/useSortableColumns.js +6 -5
  31. package/es/components/FilterSummary/FilterSummary.js +6 -2
  32. package/es/components/Guidebanner/Guidebanner.js +3 -3
  33. package/es/components/Guidebanner/GuidebannerElement.js +9 -3
  34. package/es/components/Guidebanner/GuidebannerElementButton.js +9 -4
  35. package/es/components/Guidebanner/GuidebannerElementLink.js +9 -3
  36. package/es/components/InlineTip/InlineTipButton.js +7 -0
  37. package/es/components/InlineTip/InlineTipLink.js +7 -0
  38. package/es/components/TagSet/TagSet.js +11 -3
  39. package/es/components/TagSet/TagSetOverflow.js +16 -5
  40. package/es/components/index.js +2 -2
  41. package/es/global/js/package-settings.js +5 -0
  42. package/es/global/js/utils/getNodeTextContent.js +51 -0
  43. package/lib/components/Datagrid/Datagrid/DatagridContent.js +3 -1
  44. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +9 -54
  45. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +9 -8
  46. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +6 -12
  47. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +0 -5
  48. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +15 -3
  49. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +7 -3
  50. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +38 -33
  51. package/lib/components/Datagrid/useInlineEdit.js +1 -6
  52. package/lib/components/Datagrid/useNestedRowExpander.js +10 -9
  53. package/lib/components/Datagrid/useRowExpander.js +11 -9
  54. package/lib/components/Datagrid/useSortableColumns.js +6 -5
  55. package/lib/components/FilterSummary/FilterSummary.js +6 -2
  56. package/lib/components/Guidebanner/Guidebanner.js +3 -3
  57. package/lib/components/Guidebanner/GuidebannerElement.js +8 -1
  58. package/lib/components/Guidebanner/GuidebannerElementButton.js +8 -1
  59. package/lib/components/Guidebanner/GuidebannerElementLink.js +8 -1
  60. package/lib/components/InlineTip/InlineTipButton.js +8 -1
  61. package/lib/components/InlineTip/InlineTipLink.js +8 -1
  62. package/lib/components/TagSet/TagSet.js +11 -3
  63. package/lib/components/TagSet/TagSetOverflow.js +16 -5
  64. package/lib/components/index.js +30 -0
  65. package/lib/global/js/package-settings.js +5 -0
  66. package/lib/global/js/utils/getNodeTextContent.js +59 -0
  67. package/package.json +4 -4
  68. package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +0 -15
  69. package/scss/components/Datagrid/_datagrid.scss +1 -0
  70. package/scss/components/Datagrid/_storybook-styles.scss +15 -0
  71. package/scss/components/Datagrid/styles/_useInlineEdit.scss +7 -11
  72. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +42 -1
  73. package/scss/components/TagSet/_tag-set.scss +13 -3
  74. package/es/components/Datagrid/utils/getColTitle.js +0 -25
  75. package/lib/components/Datagrid/utils/getColTitle.js +0 -32
@@ -8,19 +8,18 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
 
11
- // @flow
12
11
  import React, { useState, useEffect } from 'react';
13
12
  import cx from 'classnames';
14
13
  import { DataTable } from 'carbon-components-react';
15
14
  import { px } from '@carbon/layout';
16
15
  import { selectionColumnId } from '../common-column-ids';
17
16
  import { pkg } from '../../../settings';
18
- import { handleColumnResizeEndEvent, handleColumnResizeStartEvent, handleColumnResizingEvent } from './addons/stateReducer';
19
- import getColTitle from '../utils/getColTitle';
17
+ import { handleColumnResizeEndEvent, handleColumnResizingEvent } from './addons/stateReducer';
18
+ import { getNodeTextContent } from '../../../global/js/utils/getNodeTextContent';
20
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
20
  var getAccessibilityProps = function getAccessibilityProps(header) {
22
21
  var props = {};
23
- var title = getColTitle(header);
22
+ var title = getNodeTextContent(header.Header);
24
23
  if (title) {
25
24
  props.title = title;
26
25
  } else {
@@ -58,38 +57,6 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
58
57
  var _useState = useState(2),
59
58
  _useState2 = _slicedToArray(_useState, 1),
60
59
  incrementAmount = _useState2[0];
61
- var getClientXPosition = function getClientXPosition(event) {
62
- var isTouchEvent = false;
63
- if (event.type === 'touchstart') {
64
- // Do not respond to multiple touches (e.g. 2 or 3 fingers)
65
- if (event.touches && event.touches.length > 1) {
66
- return;
67
- }
68
- isTouchEvent = true;
69
- }
70
- var clientX = isTouchEvent ? Math.round(event.touches[0].clientX) : event.clientX;
71
- var closestHeader = event.target.closest('th');
72
- var closestHeaderCoords = closestHeader.getBoundingClientRect();
73
- var headerOffset = closestHeaderCoords.left;
74
- var offsetValue = clientX - headerOffset;
75
- return offsetValue;
76
- };
77
- useEffect(function () {
78
- var isResizing = datagridState.state.isResizing;
79
- if (isResizing) {
80
- var onColResizeEnd = datagridState.onColResizeEnd;
81
- document.addEventListener('mouseup', function () {
82
- handleColumnResizeEndEvent(datagridState.dispatch, onColResizeEnd, isResizing);
83
- document.activeElement.blur();
84
- });
85
- }
86
- return function () {
87
- document.removeEventListener('mouseup', function () {
88
- return handleColumnResizeEndEvent(datagridState.dispatch);
89
- });
90
- };
91
- // eslint-disable-next-line react-hooks/exhaustive-deps
92
- }, [datagridState.state.isResizing]);
93
60
  return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps({
94
61
  role: false
95
62
  }), {
@@ -112,32 +79,21 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
112
79
  state = datagridState.state,
113
80
  dispatch = datagridState.dispatch,
114
81
  onColResizeEnd = datagridState.onColResizeEnd;
115
- var columnResizing = state.columnResizing,
116
- isResizing = state.isResizing;
82
+ var columnResizing = state.columnResizing;
117
83
  var columnWidths = columnResizing.columnWidths;
118
84
  var originalCol = visibleColumns[index];
119
85
  return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps({
120
86
  role: false
121
87
  }), {
122
- className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
123
- key: header.id
88
+ className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable && header.id !== 'spacer'), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
89
+ key: header.id,
90
+ "aria-hidden": header.id === 'spacer' && 'true'
124
91
  }, getAccessibilityProps(header)), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("input", _extends({}, header.getResizerProps(), {
125
- onMouseMove: function onMouseMove(event) {
126
- if (isResizing) {
127
- var newWidth = getClientXPosition(event);
128
- // Sets a min width for resizing so at least one character from the column header is visible
129
- if (newWidth >= 50) {
130
- handleColumnResizingEvent(dispatch, header, newWidth);
131
- }
132
- }
133
- },
134
- onMouseDown: function onMouseDown() {
135
- return handleColumnResizeStartEvent(dispatch, header.id);
136
- },
137
92
  onKeyDown: function onKeyDown(event) {
138
93
  var key = event.key;
139
94
  if (key === 'ArrowLeft' || key === 'ArrowRight') {
140
- var currentColumnWidth = columnWidths[header.id] || (datagridState.isTableSortable && originalCol.width < 90 ? 90 : originalCol.width);
95
+ var originalColMinWidth = originalCol.minWidth || 90;
96
+ var currentColumnWidth = columnWidths[header.id] || (datagridState.isTableSortable && originalCol.width < originalColMinWidth ? originalColMinWidth : originalCol.width);
141
97
  if (key === 'ArrowLeft') {
142
98
  if (currentColumnWidth - incrementAmount > Math.max(minWidth, 50)) {
143
99
  var newWidth = currentColumnWidth - incrementAmount;
@@ -151,7 +107,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
151
107
  }
152
108
  },
153
109
  onKeyUp: function onKeyUp() {
154
- return handleColumnResizeEndEvent(dispatch, onColResizeEnd, header.id);
110
+ return handleColumnResizeEndEvent(dispatch, onColResizeEnd, header.id, true);
155
111
  },
156
112
  className: cx("".concat(blockClass, "__col-resizer-range")),
157
113
  type: "range",
@@ -14,7 +14,7 @@ import { Checkbox } from 'carbon-components-react';
14
14
  import { isColumnVisible } from './common';
15
15
  import DraggableElement from '../../DraggableElement';
16
16
  import { pkg } from '../../../../../settings';
17
- import getColTitle from '../../../utils/getColTitle';
17
+ import { getNodeTextContent } from '../../../../../global/js/utils/getNodeTextContent';
18
18
  import { DndContext, KeyboardSensor, PointerSensor, closestCenter, useSensor, useSensors } from '@dnd-kit/core';
19
19
  import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
20
20
  var blockClass = "".concat(pkg.prefix, "--datagrid");
@@ -32,12 +32,13 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
32
32
  var visibleCols = columns
33
33
  // hide the columns without Header, e.g the sticky actions, spacer
34
34
  .filter(function (colDef) {
35
- return !!getColTitle(colDef);
35
+ return getNodeTextContent(colDef.Header).trim().length !== 0;
36
36
  }).filter(Boolean).filter(function (colDef) {
37
37
  return !colDef.isAction;
38
38
  }).filter(function (colDef) {
39
- var _getColTitle;
40
- return filterString.length === 0 || ((_getColTitle = getColTitle(colDef)) === null || _getColTitle === void 0 ? void 0 : _getColTitle.toLowerCase().includes(filterString)) && colDef.id !== 'spacer';
39
+ return colDef.id !== 'spacer';
40
+ }).filter(function (colDef) {
41
+ return filterString.length === 0 || getNodeTextContent(colDef.Header).toLowerCase().includes(filterString);
41
42
  });
42
43
 
43
44
  // let localRefCopy;
@@ -50,7 +51,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
50
51
  var toVisibleIndex = columns.findIndex(function (col) {
51
52
  return matchedColsById(col, over);
52
53
  });
53
- var colTitle = getColTitle(visibleCols[fromVisibleIndex]);
54
+ var colTitle = getNodeTextContent(visibleCols[fromVisibleIndex].Header);
54
55
  setAriaRegionText("".concat(colTitle, " dropped. New position ").concat(toVisibleIndex + 1, " of ").concat(visibleCols.length, "."));
55
56
  var fromIndex = columns.findIndex(function (col) {
56
57
  return matchedColsById(col, active);
@@ -65,7 +66,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
65
66
  var fromIndex = visibleCols.findIndex(function (col) {
66
67
  return matchedColsById(col, active);
67
68
  });
68
- var colTitle = getColTitle(visibleCols[fromIndex]);
69
+ var colTitle = getNodeTextContent(visibleCols[fromIndex].Header);
69
70
  setAriaRegionText("".concat(colTitle, " grabbed. Current position ").concat(fromIndex + 1, " of ").concat(visibleCols.length, "."));
70
71
  };
71
72
  var handleDragUpdate = function handleDragUpdate(event) {
@@ -77,7 +78,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
77
78
  var toIndex = visibleCols.findIndex(function (col) {
78
79
  return matchedColsById(col, over);
79
80
  });
80
- var colTitle = getColTitle(visibleCols[fromIndex]);
81
+ var colTitle = getNodeTextContent(visibleCols[fromIndex].Header);
81
82
  setAriaRegionText("".concat(colTitle, " grabbed. Original position ").concat(fromIndex + 1, ", new position ").concat(toIndex + 1, " of ").concat(visibleCols.length, "."));
82
83
  };
83
84
  var pointerSensor = useSensor(PointerSensor, {
@@ -140,7 +141,7 @@ export var DraggableItemsList = function DraggableItemsList(_ref) {
140
141
  items: visibleCols,
141
142
  strategy: verticalListSortingStrategy
142
143
  }, visibleCols.map(function (colDef) {
143
- var colHeaderTitle = getColTitle(colDef);
144
+ var colHeaderTitle = getNodeTextContent(colDef.Header);
144
145
  var searchString = new RegExp('(' + filterString + ')');
145
146
  var res = filterString.length ? colHeaderTitle.toLowerCase().split(searchString) : null;
146
147
  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;
@@ -1,10 +1,9 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- /*
3
- * Licensed Materials - Property of IBM
4
- * 5724-Q36
5
- * (c) Copyright IBM Corp. 2022
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. 2022, 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
  */
9
8
 
10
9
  import React from 'react';
@@ -22,12 +21,9 @@ export var InlineEditButton = function InlineEditButton(_ref) {
22
21
  nonEditCell = _ref.nonEditCell,
23
22
  isActiveCell = _ref.isActiveCell,
24
23
  columnConfig = _ref.columnConfig,
25
- totalInlineEditColumns = _ref.totalInlineEditColumns,
26
- totalColumns = _ref.totalColumns,
27
24
  type = _ref.type;
28
- var inlineEditColsLessThanHalfOfTotal = totalInlineEditColumns < totalColumns / 2;
29
25
  return /*#__PURE__*/React.createElement("div", {
30
- className: cx("".concat(blockClass, "__inline-edit-button"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--edit-less-than-half-of-total-cols"), inlineEditColsLessThanHalfOfTotal), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
26
+ className: cx("".concat(blockClass, "__inline-edit-button"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--disabled"), disabled || nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--with-label-icon"), LabelIcon), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--non-edit"), nonEditCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--active"), isActiveCell), _defineProperty(_cx, "".concat(blockClass, "__inline-edit-button--").concat(type), type === 'date' || type === 'selection'), _cx)),
31
27
  tabIndex: isActiveCell ? 0 : -1,
32
28
  "data-disabled": disabled || nonEditCell,
33
29
  "aria-disabled": disabled || nonEditCell,
@@ -52,8 +48,6 @@ InlineEditButton.propTypes = {
52
48
  nonEditCell: PropTypes.bool,
53
49
  placeholder: PropTypes.string,
54
50
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]),
55
- totalColumns: PropTypes.number,
56
- totalInlineEditColumns: PropTypes.number,
57
51
  type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
58
52
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.node])
59
53
  };
@@ -32,14 +32,12 @@ export var InlineEditCell = function InlineEditCell(_ref) {
32
32
  tabIndex = _ref.tabIndex,
33
33
  value = _ref.value,
34
34
  nonEditCell = _ref.nonEditCell,
35
- totalInlineEditColumns = _ref.totalInlineEditColumns,
36
35
  type = _ref.type;
37
36
  var columnId = cell.column.id;
38
37
  var columnIndex = instance.columns.findIndex(function (col) {
39
38
  return col.id === columnId;
40
39
  });
41
40
  var cellId = "column-".concat(columnIndex, "-row-").concat(cell.row.index);
42
- var totalColumns = instance.columns.length;
43
41
  var _useContext = useContext(InlineEditContext),
44
42
  state = _useContext.state,
45
43
  dispatch = _useContext.dispatch;
@@ -442,8 +440,6 @@ export var InlineEditCell = function InlineEditCell(_ref) {
442
440
  tabIndex: tabIndex,
443
441
  nonEditCell: nonEditCell,
444
442
  columnConfig: cell.column,
445
- totalInlineEditColumns: totalInlineEditColumns,
446
- totalColumns: totalColumns,
447
443
  type: type
448
444
  }), !nonEditCell && inEditMode && cellId === activeCellId && /*#__PURE__*/React.createElement(React.Fragment, null, type === 'text' && renderTextInput(), type === 'number' && renderNumberInput(), type === 'selection' && renderSelectCell(), type === 'date' && renderDateCell()))
449
445
  );
@@ -461,7 +457,6 @@ InlineEditCell.propTypes = {
461
457
  nonEditCell: PropTypes.bool,
462
458
  placeholder: PropTypes.string,
463
459
  tabIndex: PropTypes.number,
464
- totalInlineEditColumns: PropTypes.number,
465
460
  type: PropTypes.oneOf(['text', 'number', 'selection', 'date']),
466
461
  value: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.object])
467
462
  };
@@ -10,23 +10,31 @@ var _excluded = ["legendText"];
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
12
 
13
- import React, { useRef, useState } from 'react';
13
+ import React, { useRef, useState, useEffect } from 'react';
14
14
  import PropTypes from 'prop-types';
15
15
  import { Settings16 } from '@carbon/icons-react';
16
16
  import { Button } from 'carbon-components-react';
17
17
  import cx from 'classnames';
18
18
  import RowSizeRadioGroup from './RowSizeRadioGroup';
19
- import { pkg } from '../../../../../settings';
19
+ import { pkg, carbon } from '../../../../../settings';
20
20
  var blockClass = "".concat(pkg.prefix, "--datagrid__row-size");
21
21
  var RowSizeDropdown = function RowSizeDropdown(_ref) {
22
22
  var _ref$legendText = _ref.legendText,
23
- legendText = _ref$legendText === void 0 ? 'Row height' : _ref$legendText,
23
+ legendText = _ref$legendText === void 0 ? 'Row settings' : _ref$legendText,
24
24
  props = _objectWithoutProperties(_ref, _excluded);
25
25
  var buttonRef = useRef(null);
26
+ var radioGroupRef = useRef();
26
27
  var _useState = useState(false),
27
28
  _useState2 = _slicedToArray(_useState, 2),
28
29
  isOpen = _useState2[0],
29
30
  setIsOpen = _useState2[1];
31
+ useEffect(function () {
32
+ if (isOpen) {
33
+ var radioGroupParentElement = radioGroupRef === null || radioGroupRef === void 0 ? void 0 : radioGroupRef.current;
34
+ var checkedRadioChild = radioGroupParentElement === null || radioGroupParentElement === void 0 ? void 0 : radioGroupParentElement.querySelector(".".concat(carbon.prefix, "--radio-button:checked"));
35
+ checkedRadioChild === null || checkedRadioChild === void 0 ? void 0 : checkedRadioChild.focus();
36
+ }
37
+ }, [isOpen]);
30
38
  var onCloseHandler = function onCloseHandler() {
31
39
  setIsOpen(false);
32
40
  };
@@ -36,7 +44,9 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
36
44
  }
37
45
  };
38
46
  var onClickHandler = function onClickHandler() {
39
- setIsOpen(!isOpen);
47
+ setIsOpen(function (prev) {
48
+ return !prev;
49
+ });
40
50
  };
41
51
  var onKeyHandler = function onKeyHandler(e) {
42
52
  if (e.key === 'Escape') {
@@ -59,7 +69,9 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
59
69
  iconDescription: legendText,
60
70
  className: cx("".concat(blockClass, "-button"), _defineProperty({}, "".concat(blockClass, "-button--open"), isOpen)),
61
71
  onClick: onClickHandler
62
- }), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({}, props, {
72
+ }), isOpen && /*#__PURE__*/React.createElement(RowSizeRadioGroup, _extends({
73
+ ref: radioGroupRef
74
+ }, props, {
63
75
  legendText: legendText,
64
76
  buttonRef: buttonRef
65
77
  })));
@@ -8,13 +8,13 @@
8
8
  * restricted by GSA ADP Schedule Contract with IBM Corp.
9
9
  */
10
10
 
11
- import React from 'react';
11
+ import React, { forwardRef } from 'react';
12
12
  import PropTypes from 'prop-types';
13
13
  import { RadioButtonGroup, RadioButton } from 'carbon-components-react';
14
14
  import isArray from 'lodash/isArray';
15
15
  import { pkg } from '../../../../../settings';
16
16
  var blockClass = "".concat(pkg.prefix, "--datagrid");
17
- var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
17
+ var RowSizeRadioGroup = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
18
  var rowSizes = _ref.rowSizes,
19
19
  selectedOption = _ref.selectedOption,
20
20
  datagridName = _ref.datagridName,
@@ -29,6 +29,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
29
29
  xs: 'Extra small'
30
30
  } : _ref$rowSizeLabels;
31
31
  return /*#__PURE__*/React.createElement("div", {
32
+ ref: ref,
32
33
  className: "".concat(blockClass, "__row-size-dropdown"),
33
34
  role: "presentation"
34
35
  }, /*#__PURE__*/React.createElement(RadioButtonGroup, {
@@ -51,7 +52,7 @@ var RowSizeRadioGroup = function RowSizeRadioGroup(_ref) {
51
52
  id: "".concat(datagridName || 'datagrid', "--row-density--").concat(option.value)
52
53
  });
53
54
  })));
54
- };
55
+ });
55
56
  var getBackwardCompatibleRowSize = function getBackwardCompatibleRowSize(rowSize) {
56
57
  // TODO: deprecate this function in next major release (v8) on carbon-components-react
57
58
  var rowSizeMap = {
@@ -1,3 +1,4 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -9,24 +10,19 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
10
  * LICENSE file in the root directory of this source tree.
10
11
  */
11
12
 
13
+ import { pkg } from '../../../../settings';
12
14
  var COLUMN_RESIZE_START = 'columnStartResizing';
13
15
  var COLUMN_RESIZING = 'columnResizing';
14
16
  var COLUMN_RESIZE_END = 'columnDoneResizing';
15
17
  var INIT = 'init';
16
- export var handleColumnResizeStartEvent = function handleColumnResizeStartEvent(dispatch, headerId) {
17
- dispatch({
18
- type: COLUMN_RESIZE_START,
19
- payload: {
20
- headerId: headerId
21
- }
22
- });
23
- };
24
- export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId) {
18
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
19
+ export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId, isKeyEvent) {
25
20
  dispatch({
26
21
  type: COLUMN_RESIZE_END,
27
22
  payload: {
28
23
  onColResizeEnd: onColResizeEnd,
29
- headerId: headerId
24
+ headerId: headerId,
25
+ isKeyEvent: isKeyEvent
30
26
  }
31
27
  });
32
28
  };
@@ -60,42 +56,45 @@ export var stateReducer = function stateReducer(newState, action) {
60
56
  }
61
57
  case COLUMN_RESIZE_START:
62
58
  {
63
- var headerId = action.payload.headerId;
59
+ var _ref = action.payload || {},
60
+ headerId = _ref.headerId;
64
61
  return _objectSpread(_objectSpread({}, newState), {}, {
65
62
  isResizing: headerId
66
63
  });
67
64
  }
68
65
  case COLUMN_RESIZING:
69
66
  {
70
- var _ref = action.payload || {},
71
- _headerId = _ref.headerId,
72
- newWidth = _ref.newWidth,
73
- defaultWidth = _ref.defaultWidth;
67
+ var _ref2 = action.payload || {},
68
+ _headerId = _ref2.headerId,
69
+ newWidth = _ref2.newWidth,
70
+ defaultWidth = _ref2.defaultWidth;
74
71
  var newColumnWidth = {};
75
72
  if (typeof _headerId === 'undefined') {
76
73
  return _objectSpread({}, newState);
77
74
  }
78
75
  newColumnWidth[_headerId] = newWidth;
79
- var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref2) {
80
- var _ref3 = _slicedToArray(_ref2, 2),
81
- _ = _ref3[0],
82
- value = _ref3[1];
76
+ var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref3) {
77
+ var _ref4 = _slicedToArray(_ref3, 2),
78
+ _ = _ref4[0],
79
+ value = _ref4[1];
83
80
  return !isNaN(value);
84
81
  }));
82
+ var headerIdArray = newState.columnResizing.headerIdWidths || [];
85
83
  return _objectSpread(_objectSpread({}, newState), {}, {
86
84
  isResizing: _headerId,
87
85
  columnResizing: _objectSpread(_objectSpread({}, newState.columnResizing), {}, {
88
86
  columnWidth: defaultWidth,
89
87
  columnWidths: _objectSpread(_objectSpread({}, cleanedWidths), newColumnWidth),
90
- headerIdWidths: [_headerId, newWidth]
88
+ headerIdWidths: [].concat(_toConsumableArray(headerIdArray), [[_headerId, newWidth]])
91
89
  })
92
90
  });
93
91
  }
94
92
  case COLUMN_RESIZE_END:
95
93
  {
96
- var _action$payload = action.payload,
97
- onColResizeEnd = _action$payload.onColResizeEnd,
98
- _headerId2 = _action$payload.headerId;
94
+ var _ref5 = action.payload || {},
95
+ onColResizeEnd = _ref5.onColResizeEnd,
96
+ _headerId2 = _ref5.headerId,
97
+ isKeyEvent = _ref5.isKeyEvent;
99
98
  var currentColumn = {};
100
99
  currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
101
100
  var allChangedColumns = newState.columnResizing.columnWidths;
@@ -103,8 +102,22 @@ export var stateReducer = function stateReducer(newState, action) {
103
102
  if (isResizing) {
104
103
  onColResizeEnd === null || onColResizeEnd === void 0 ? void 0 : onColResizeEnd(currentColumn, allChangedColumns);
105
104
  }
105
+ if (!isKeyEvent) {
106
+ if (typeof isKeyEvent === 'undefined') {
107
+ // Blur resizer input if it has focus and is not from a key event resize
108
+ if (document.activeElement.classList.contains("".concat(blockClass, "__col-resizer-range"))) {
109
+ var _document, _document$activeEleme;
110
+ (_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.blur();
111
+ }
112
+ return;
113
+ }
114
+ }
106
115
  return _objectSpread(_objectSpread({}, newState), {}, {
107
- isResizing: false
116
+ isResizing: false,
117
+ columnResizing: _objectSpread(_objectSpread({}, newState.columnResizing), {}, {
118
+ isResizingColumn: false,
119
+ startX: null
120
+ })
108
121
  });
109
122
  }
110
123
  }
@@ -2,13 +2,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- /*
6
- * Licensed Materials - Property of IBM
7
- * 5724-Q36
8
- * (c) Copyright IBM Corp. 2020
9
- * US Government Users Restricted Rights - Use, duplication or disclosure
10
- * restricted by GSA ADP Schedule Contract with IBM Corp.
5
+ /**
6
+ * Copyright IBM Corp. 2020, 2023
7
+ *
8
+ * This source code is licensed under the Apache-2.0 license found in the
9
+ * LICENSE file in the root directory of this source tree.
11
10
  */
11
+
12
12
  import React from 'react';
13
13
  import cx from 'classnames';
14
14
  import { pkg } from '../../settings';
@@ -2,13 +2,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
5
- /*
6
- * Licensed Materials - Property of IBM
7
- * 5724-Q36
8
- * (c) Copyright IBM Corp. 2020
9
- * US Government Users Restricted Rights - Use, duplication or disclosure
10
- * restricted by GSA ADP Schedule Contract with IBM Corp.
5
+ /**
6
+ * Copyright IBM Corp. 2020, 2023
7
+ *
8
+ * This source code is licensed under the Apache-2.0 license found in the
9
+ * LICENSE file in the root directory of this source tree.
11
10
  */
11
+
12
12
  import React from 'react';
13
13
  import cx from 'classnames';
14
14
  import { pkg } from '../../settings';
@@ -22,14 +22,11 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
22
22
  }
23
23
  }, [usingEditableCell]);
24
24
  var addInlineEdit = function addInlineEdit(props, _ref) {
25
- var _cell$column, _cell$column$inlineEd, _instance$columns$fil;
25
+ var _cell$column, _cell$column$inlineEd;
26
26
  var cell = _ref.cell,
27
27
  instance = _ref.instance;
28
28
  var columnInlineEditConfig = cell.column.inlineEdit;
29
29
  var inlineEditType = (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : (_cell$column$inlineEd = _cell$column.inlineEdit) === null || _cell$column$inlineEd === void 0 ? void 0 : _cell$column$inlineEd.type;
30
- var totalInlineEditColumns = (_instance$columns$fil = instance.columns.filter(function (item) {
31
- return item.inlineEdit;
32
- })) === null || _instance$columns$fil === void 0 ? void 0 : _instance$columns$fil.length;
33
30
  var renderInlineEditComponent = function renderInlineEditComponent(type) {
34
31
  return /*#__PURE__*/React.createElement(InlineEditCell, {
35
32
  config: columnInlineEditConfig,
@@ -37,7 +34,6 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
37
34
  value: cell.value,
38
35
  cell: cell,
39
36
  instance: instance,
40
- totalInlineEditColumns: totalInlineEditColumns,
41
37
  type: type
42
38
  });
43
39
  };
@@ -57,7 +53,6 @@ var useInlineEdit = function useInlineEdit(hooks, usingEditableCell) {
57
53
  instance: instance,
58
54
  disabled: true,
59
55
  nonEditCell: true,
60
- totalInlineEditColumns: totalInlineEditColumns,
61
56
  type: "text"
62
57
  }))
63
58
  }];
@@ -1,6 +1,8 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
6
  /* eslint-disable react/prop-types */
5
7
  /**
6
8
  * Copyright IBM Corp. 2020, 2023
@@ -25,6 +27,13 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
25
27
  Cell: function Cell(_ref) {
26
28
  var _cx;
27
29
  var row = _ref.row;
30
+ var expanderButtonProps = _objectSpread(_objectSpread({}, row.getToggleRowExpandedProps()), {}, {
31
+ onClick: function onClick(event) {
32
+ // Prevents `onRowClick` from being called if `useOnRowClick` is included
33
+ event.stopPropagation();
34
+ row.toggleRowExpanded();
35
+ }
36
+ });
28
37
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
29
38
  _ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
30
39
  expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
@@ -35,7 +44,7 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
35
44
  type: "button",
36
45
  "aria-label": expanderTitle,
37
46
  className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
38
- }, row.getToggleRowExpandedProps(), {
47
+ }, expanderButtonProps, {
39
48
  title: expanderTitle
40
49
  }), /*#__PURE__*/React.createElement(ChevronRight16, {
41
50
  className: cx("".concat(blockClass, "__expander-icon"), "".concat(blockClass, "__row-expander--icon"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
@@ -1,5 +1,8 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
6
  /* eslint-disable react/prop-types */
4
7
  /**
5
8
  * Copyright IBM Corp. 2020, 2023
@@ -23,6 +26,13 @@ var useRowExpander = function useRowExpander(hooks) {
23
26
  id: 'expander',
24
27
  Cell: function Cell(_ref) {
25
28
  var row = _ref.row;
29
+ var expanderButtonProps = _objectSpread(_objectSpread({}, row.getToggleRowExpandedProps()), {}, {
30
+ onClick: function onClick(event) {
31
+ // Prevents `onRowClick` from being called if `useOnRowClick` is included
32
+ event.stopPropagation();
33
+ row.toggleRowExpanded();
34
+ }
35
+ });
26
36
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
27
37
  _ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
28
38
  expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
@@ -33,7 +43,7 @@ var useRowExpander = function useRowExpander(hooks) {
33
43
  type: "button",
34
44
  "aria-label": expanderTitle,
35
45
  className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
36
- }, row.getToggleRowExpandedProps(), {
46
+ }, expanderButtonProps, {
37
47
  title: expanderTitle
38
48
  }), row.isExpanded ? /*#__PURE__*/React.createElement(ChevronUp16, {
39
49
  className: "".concat(blockClass, "__row-expander--icon")
@@ -14,6 +14,7 @@ import cx from 'classnames';
14
14
  import { pkg, carbon } from '../../settings';
15
15
  import { Button } from 'carbon-components-react';
16
16
  import { ArrowUp16, Arrows16 } from '@carbon/icons-react';
17
+ import { SelectAll } from './Datagrid/DatagridSelectAll';
17
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
18
19
  var ordering = {
19
20
  ASC: 'ASC',
@@ -31,13 +32,13 @@ var getAriaSortValue = function getAriaSortValue(col, _ref) {
31
32
  isSorted = _ref2.isSorted,
32
33
  isSortedDesc = _ref2.isSortedDesc;
33
34
  if (!isSorted) {
34
- return defaultSortableLabelText || 'none';
35
+ return defaultSortableLabelText;
35
36
  }
36
37
  if (isSorted && !isSortedDesc) {
37
- return ascendingSortableLabelText || 'ascending';
38
+ return ascendingSortableLabelText;
38
39
  }
39
40
  if (isSorted && isSortedDesc) {
40
- return descendingSortableLabelText || 'descending';
41
+ return descendingSortableLabelText;
41
42
  }
42
43
  };
43
44
  var useSortableColumns = function useSortableColumns(hooks) {
@@ -91,7 +92,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
91
92
  };
92
93
  var Header = function Header(headerProp) {
93
94
  var _cx;
94
- return column.disableSortBy === true ? column.Header : /*#__PURE__*/React.createElement(Button, {
95
+ return column.disableSortBy === true || column.id === 'datagridSelection' ? column.disableSortBy ? column.Header : /*#__PURE__*/React.createElement(SelectAll, instance) : /*#__PURE__*/React.createElement(Button, {
95
96
  "aria-sort": getAriaSortValue(headerProp === null || headerProp === void 0 ? void 0 : headerProp.column, {
96
97
  ascendingSortableLabelText: ascendingSortableLabelText,
97
98
  descendingSortableLabelText: descendingSortableLabelText,
@@ -107,7 +108,7 @@ var useSortableColumns = function useSortableColumns(hooks) {
107
108
  };
108
109
  return _objectSpread(_objectSpread({}, column), {}, {
109
110
  Header: Header,
110
- minWidth: column.disableSortBy === true ? 0 : 90
111
+ minWidth: column.disableSortBy === true ? 0 : column.minWidth ? column.minWidth : 90
111
112
  });
112
113
  });
113
114
  return (_instance$customizeCo = instance.customizeColumnsProps) !== null && _instance$customizeCo !== void 0 && _instance$customizeCo.isTearsheetOpen ? visibleColumns : _toConsumableArray(sortableColumns);