@carbon/ibm-products 1.62.0 → 1.63.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/css/index-full-carbon.css +24 -2
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +19 -0
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +24 -2
  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 +24 -2
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +3 -3
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Carousel/Carousel.js +194 -119
  18. package/es/components/Carousel/CarouselItem.js +8 -21
  19. package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +6 -7
  20. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
  21. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
  22. package/es/components/Datagrid/Datagrid/DatagridRow.js +19 -10
  23. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +19 -1
  24. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +15 -1
  25. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +4 -3
  26. package/es/components/Datagrid/Datagrid/addons/stateReducer.js +67 -24
  27. package/es/components/Datagrid/useExpandedRow.js +3 -6
  28. package/es/components/Datagrid/useFocusRowExpander.js +40 -0
  29. package/es/components/Datagrid/useNestedRowExpander.js +9 -0
  30. package/es/components/Datagrid/useNestedRows.js +0 -4
  31. package/es/components/Datagrid/useRowExpander.js +9 -0
  32. package/es/components/Datagrid/useSelectRows.js +23 -11
  33. package/es/components/Datagrid/utils/handleFilterTagLabelText.js +26 -0
  34. package/es/components/FilterSummary/FilterSummary.js +21 -7
  35. package/es/components/Guidebanner/Guidebanner.js +9 -12
  36. package/es/components/TagSet/TagSet.js +22 -5
  37. package/es/global/js/package-settings.js +0 -2
  38. package/lib/components/Carousel/Carousel.js +190 -114
  39. package/lib/components/Carousel/CarouselItem.js +9 -25
  40. package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +6 -7
  41. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
  42. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
  43. package/lib/components/Datagrid/Datagrid/DatagridRow.js +13 -3
  44. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +19 -1
  45. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +15 -1
  46. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +4 -3
  47. package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +70 -26
  48. package/lib/components/Datagrid/useExpandedRow.js +2 -5
  49. package/lib/components/Datagrid/useFocusRowExpander.js +46 -0
  50. package/lib/components/Datagrid/useNestedRowExpander.js +9 -0
  51. package/lib/components/Datagrid/useNestedRows.js +0 -4
  52. package/lib/components/Datagrid/useRowExpander.js +9 -0
  53. package/lib/components/Datagrid/useSelectRows.js +17 -4
  54. package/lib/components/Datagrid/utils/handleFilterTagLabelText.js +33 -0
  55. package/lib/components/FilterSummary/FilterSummary.js +23 -6
  56. package/lib/components/Guidebanner/Guidebanner.js +9 -12
  57. package/lib/components/TagSet/TagSet.js +21 -4
  58. package/lib/global/js/package-settings.js +0 -2
  59. package/package.json +3 -3
  60. package/scss/components/Carousel/_carousel.scss +1 -2
  61. package/scss/components/Datagrid/styles/_useExpandedRow.scss +21 -0
  62. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -0
  63. package/scss/components/FilterSummary/_filter-summary.scss +6 -1
  64. package/es/components/Carousel/utils.js +0 -98
  65. package/lib/components/Carousel/utils.js +0 -108
@@ -14,6 +14,7 @@ import { useResizeObserver } from '../../../global/js/hooks/useResizeObserver';
14
14
  import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
15
15
  import { pkg, carbon } from '../../../settings';
16
16
  import cx from 'classnames';
17
+ import { handleSelectAllRowData } from './addons/stateReducer';
17
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
18
19
  var toolbarClass = "".concat(blockClass, "__table-toolbar");
19
20
  var menuClass = "".concat(blockClass, "__button-menu");
@@ -35,8 +36,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
35
36
  toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
36
37
  toolbarBatchActions = datagridState.toolbarBatchActions,
37
38
  setGlobalFilter = datagridState.setGlobalFilter,
39
+ dispatch = datagridState.dispatch,
40
+ getRowId = datagridState.getRowId,
38
41
  batchActionMenuButtonLabel = datagridState.batchActionMenuButtonLabel,
39
- translateWithIdBatchActions = datagridState.translateWithIdBatchActions;
42
+ translateWithIdBatchActions = datagridState.translateWithIdBatchActions,
43
+ rows = datagridState.rows;
40
44
  var batchActionMenuButtonLabelText = batchActionMenuButtonLabel !== null && batchActionMenuButtonLabel !== void 0 ? batchActionMenuButtonLabel : 'More';
41
45
  var selectedKeys = Object.keys(selectedRowIds || {});
42
46
  var totalSelected = selectedKeys.length;
@@ -84,6 +88,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
84
88
  batchAction.onClick();
85
89
  if (batchAction.type === 'select_all') {
86
90
  toggleAllRowsSelected(true);
91
+ handleSelectAllRowData({
92
+ dispatch: dispatch,
93
+ rows: rows,
94
+ getRowId: getRowId
95
+ });
87
96
  }
88
97
  }
89
98
  });
@@ -111,6 +120,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
111
120
  batchAction.onClick();
112
121
  if (batchAction.type === 'select_all') {
113
122
  toggleAllRowsSelected(true);
123
+ handleSelectAllRowData({
124
+ dispatch: dispatch,
125
+ rows: rows,
126
+ getRowId: getRowId
127
+ });
114
128
  }
115
129
  },
116
130
  iconDescription: batchAction.label
@@ -50,7 +50,7 @@ var useFilters = function useFilters(_ref) {
50
50
  /** Methods */
51
51
  // If the user decides to cancel or click outside the flyout, it reverts back to the filters that were
52
52
  // there when they opened the flyout
53
- var revertToPreviousFilters = function revertToPreviousFilters() {
53
+ var revertToPreviousFilters = useCallback(function () {
54
54
  setFiltersState(JSON.parse(prevFiltersRef.current));
55
55
  setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
56
56
  setAllFilters(JSON.parse(lastAppliedFilters.current));
@@ -60,7 +60,7 @@ var useFilters = function useFilters(_ref) {
60
60
  holdingPrevFiltersRef.current = JSON.parse(prevFiltersRef.current);
61
61
  holdingLastAppliedFiltersRef.current = JSON.parse(prevFiltersObjectArrayRef.current);
62
62
  holdingPrevFiltersObjectArrayRef.current = JSON.parse(lastAppliedFilters.current);
63
- };
63
+ }, [setAllFilters]);
64
64
  var reset = useCallback(function () {
65
65
  // When we reset we want the "initialFilters" to be an empty array
66
66
  var resetFiltersArray = [];
@@ -314,6 +314,7 @@ var useFilters = function useFilters(_ref) {
314
314
  */
315
315
  useEffect(function () {
316
316
  if (!panelOpen && previousState !== null && previousState !== void 0 && previousState.panelOpen) {
317
+ revertToPreviousFilters();
317
318
  setAllFilters(holdingLastAppliedFiltersRef.current);
318
319
  }
319
320
  if (panelOpen && !(previousState !== null && previousState !== void 0 && previousState.panelOpen)) {
@@ -323,7 +324,7 @@ var useFilters = function useFilters(_ref) {
323
324
  setAllFilters(JSON.parse(prevFiltersObjectArrayRef.current));
324
325
  }
325
326
  }
326
- }, [panelOpen, previousState, previousState === null || previousState === void 0 ? void 0 : previousState.panelOpen, reset, setAllFilters]);
327
+ }, [panelOpen, previousState, previousState === null || previousState === void 0 ? void 0 : previousState.panelOpen, reset, setAllFilters, revertToPreviousFilters]);
327
328
  var cancel = function cancel() {
328
329
  // Reverting to previous filters only applies when using batch actions
329
330
  if (updateMethod === BATCH) {
@@ -16,6 +16,7 @@ var COLUMN_RESIZING = 'columnResizing';
16
16
  var COLUMN_RESIZE_END = 'columnDoneResizing';
17
17
  var INIT = 'init';
18
18
  var TOGGLE_ROW_SELECTED = 'toggleRowSelected';
19
+ var TOGGLE_ALL_ROWS_SELECTED = 'toggleAllRowsSelected';
19
20
  var blockClass = "".concat(pkg.prefix, "--datagrid");
20
21
  export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId, isKeyEvent) {
21
22
  dispatch({
@@ -47,35 +48,77 @@ export var handleColumnResizingEvent = function handleColumnResizingEvent(dispat
47
48
  }
48
49
  });
49
50
  };
50
- export var handleToggleRowSelected = function handleToggleRowSelected(dispatch, rowData, isChecked) {
51
+ export var handleToggleRowSelected = function handleToggleRowSelected(_ref) {
52
+ var dispatch = _ref.dispatch,
53
+ rowData = _ref.rowData,
54
+ isChecked = _ref.isChecked,
55
+ getRowId = _ref.getRowId,
56
+ selectAll = _ref.selectAll;
51
57
  return dispatch({
52
58
  type: TOGGLE_ROW_SELECTED,
53
59
  payload: {
54
60
  rowData: rowData,
61
+ isChecked: isChecked,
62
+ getRowId: getRowId,
63
+ selectAll: selectAll
64
+ }
65
+ });
66
+ };
67
+ export var handleSelectAllRowData = function handleSelectAllRowData(_ref2) {
68
+ var dispatch = _ref2.dispatch,
69
+ rows = _ref2.rows,
70
+ getRowId = _ref2.getRowId,
71
+ indeterminate = _ref2.indeterminate,
72
+ isChecked = _ref2.isChecked;
73
+ return dispatch({
74
+ type: TOGGLE_ALL_ROWS_SELECTED,
75
+ payload: {
76
+ rows: rows,
77
+ getRowId: getRowId,
78
+ indeterminate: indeterminate,
55
79
  isChecked: isChecked
56
80
  }
57
81
  });
58
82
  };
59
83
  export var stateReducer = function stateReducer(newState, action) {
60
84
  switch (action.type) {
85
+ case TOGGLE_ALL_ROWS_SELECTED:
86
+ {
87
+ var _ref3 = action.payload || {},
88
+ rows = _ref3.rows,
89
+ getRowId = _ref3.getRowId,
90
+ indeterminate = _ref3.indeterminate,
91
+ isChecked = _ref3.isChecked;
92
+ if (rows) {
93
+ var newSelectedRowData = {};
94
+ rows.forEach(function (row) {
95
+ newSelectedRowData[getRowId(row, row.index)] = row;
96
+ });
97
+ return _objectSpread(_objectSpread({}, newState), {}, {
98
+ selectedRowData: indeterminate || !isChecked ? {} : newSelectedRowData
99
+ });
100
+ }
101
+ return _objectSpread({}, newState);
102
+ }
61
103
  case TOGGLE_ROW_SELECTED:
62
104
  {
63
- var _ref = action.payload || {},
64
- rowData = _ref.rowData,
65
- isChecked = _ref.isChecked;
105
+ var _ref4 = action.payload || {},
106
+ rowData = _ref4.rowData,
107
+ _isChecked = _ref4.isChecked,
108
+ _getRowId = _ref4.getRowId;
66
109
  if (!rowData) {
67
110
  return;
68
111
  }
69
- if (isChecked) {
112
+ if (_isChecked) {
70
113
  return _objectSpread(_objectSpread({}, newState), {}, {
71
- selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, rowData.index, rowData))
114
+ selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, _getRowId(rowData, rowData.index), rowData))
72
115
  });
73
116
  }
74
- if (rowData && !isChecked) {
117
+ if (rowData && !_isChecked) {
75
118
  var newData = _objectSpread({}, newState.selectedRowData);
76
- var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (_ref2) {
77
- var _ref3 = _slicedToArray(_ref2, 1),
78
- key = _ref3[0];
119
+ var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (_ref5) {
120
+ var _ref6 = _slicedToArray(_ref5, 1),
121
+ key = _ref6[0];
79
122
  return parseInt(key) !== parseInt(rowData.index);
80
123
  }));
81
124
  return _objectSpread(_objectSpread({}, newState), {}, {
@@ -92,27 +135,27 @@ export var stateReducer = function stateReducer(newState, action) {
92
135
  }
93
136
  case COLUMN_RESIZE_START:
94
137
  {
95
- var _ref4 = action.payload || {},
96
- headerId = _ref4.headerId;
138
+ var _ref7 = action.payload || {},
139
+ headerId = _ref7.headerId;
97
140
  return _objectSpread(_objectSpread({}, newState), {}, {
98
141
  isResizing: headerId
99
142
  });
100
143
  }
101
144
  case COLUMN_RESIZING:
102
145
  {
103
- var _ref5 = action.payload || {},
104
- _headerId = _ref5.headerId,
105
- newWidth = _ref5.newWidth,
106
- defaultWidth = _ref5.defaultWidth;
146
+ var _ref8 = action.payload || {},
147
+ _headerId = _ref8.headerId,
148
+ newWidth = _ref8.newWidth,
149
+ defaultWidth = _ref8.defaultWidth;
107
150
  var newColumnWidth = {};
108
151
  if (typeof _headerId === 'undefined') {
109
152
  return _objectSpread({}, newState);
110
153
  }
111
154
  newColumnWidth[_headerId] = newWidth;
112
- var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref6) {
113
- var _ref7 = _slicedToArray(_ref6, 2),
114
- _ = _ref7[0],
115
- value = _ref7[1];
155
+ var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref9) {
156
+ var _ref10 = _slicedToArray(_ref9, 2),
157
+ _ = _ref10[0],
158
+ value = _ref10[1];
116
159
  return !isNaN(value);
117
160
  }));
118
161
  var headerIdArray = newState.columnResizing.headerIdWidths || [];
@@ -127,10 +170,10 @@ export var stateReducer = function stateReducer(newState, action) {
127
170
  }
128
171
  case COLUMN_RESIZE_END:
129
172
  {
130
- var _ref8 = action.payload || {},
131
- onColResizeEnd = _ref8.onColResizeEnd,
132
- _headerId2 = _ref8.headerId,
133
- isKeyEvent = _ref8.isKeyEvent;
173
+ var _ref11 = action.payload || {},
174
+ onColResizeEnd = _ref11.onColResizeEnd,
175
+ _headerId2 = _ref11.headerId,
176
+ isKeyEvent = _ref11.isKeyEvent;
134
177
  var currentColumn = {};
135
178
  currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
136
179
  var allChangedColumns = newState.columnResizing.columnWidths;
@@ -9,14 +9,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
9
9
  * LICENSE file in the root directory of this source tree.
10
10
  */
11
11
 
12
- import { useEffect, useState } from 'react';
13
- import { pkg } from '../../settings';
12
+ import { useState } from 'react';
14
13
  import DatagridExpandedRow from './Datagrid/DatagridExpandedRow';
15
14
  import useRowExpander from './useRowExpander';
16
15
  var useExpandedRow = function useExpandedRow(hooks) {
17
- useEffect(function () {
18
- pkg.checkReportFeatureEnabled('Datagrid.useExpandedRow');
19
- }, []);
20
16
  useRowExpander(hooks);
21
17
  var useInstance = function useInstance(instance) {
22
18
  var rows = instance.rows,
@@ -38,7 +34,8 @@ var useExpandedRow = function useExpandedRow(hooks) {
38
34
  });
39
35
  Object.assign(instance, {
40
36
  rows: rowsWithExpand,
41
- setExpandedRowHeight: setExpandedRowHeight
37
+ setExpandedRowHeight: setExpandedRowHeight,
38
+ withExpandedRows: true
42
39
  });
43
40
  };
44
41
  hooks.useInstance.push(useInstance);
@@ -0,0 +1,40 @@
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 { useEffect } from 'react';
9
+
10
+ // Focuses the row expander after a nested/expandable row state change.
11
+ // We have to add this workaround because react-table is re-rendering the entire row
12
+ // which removes the focus from the expander and interrupts the keyboard navigation
13
+ // flow.
14
+ export var useFocusRowExpander = function useFocusRowExpander(_ref) {
15
+ var instance = _ref.instance,
16
+ _ref$lastExpandedRowI = _ref.lastExpandedRowIndex,
17
+ lastExpandedRowIndex = _ref$lastExpandedRowI === void 0 ? 0 : _ref$lastExpandedRowI,
18
+ blockClass = _ref.blockClass,
19
+ activeElement = _ref.activeElement;
20
+ useEffect(function () {
21
+ // We need to return at this point so that the focus is not stolen from
22
+ // other interactive elements in the Datagrid
23
+ if (!activeElement.classList.contains("".concat(blockClass, "__row-expander"))) {
24
+ return;
25
+ }
26
+ var tableId = instance === null || instance === void 0 ? void 0 : instance.tableId;
27
+ var rowElements = document.querySelectorAll("#".concat(tableId, " tbody tr"));
28
+ var rowElementsArray = Array.from(rowElements);
29
+ var activeRow = rowElementsArray.filter(function (r) {
30
+ if (r.getAttribute('data-nested-row-id') === lastExpandedRowIndex) {
31
+ return r;
32
+ }
33
+ return null;
34
+ });
35
+ if (activeRow.length) {
36
+ var rowExpander = activeRow[0].querySelector(".".concat(blockClass, "__row-expander"));
37
+ rowExpander.focus();
38
+ }
39
+ }, [instance === null || instance === void 0 ? void 0 : instance.tableId, instance === null || instance === void 0 ? void 0 : instance.expandedRows, lastExpandedRowIndex, blockClass, activeElement]);
40
+ };
@@ -15,12 +15,20 @@ import React, { useRef } from 'react';
15
15
  import { ChevronRight16 } from '@carbon/icons-react';
16
16
  import cx from 'classnames';
17
17
  import { pkg, carbon } from '../../settings';
18
+ import { useFocusRowExpander } from './useFocusRowExpander';
18
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useNestedRowExpander = function useNestedRowExpander(hooks) {
20
21
  var tempState = useRef();
22
+ var lastExpandedRowIndex = useRef();
21
23
  var useInstance = function useInstance(instance) {
22
24
  tempState.current = instance;
23
25
  };
26
+ useFocusRowExpander({
27
+ instance: tempState === null || tempState === void 0 ? void 0 : tempState.current,
28
+ lastExpandedRowIndex: lastExpandedRowIndex === null || lastExpandedRowIndex === void 0 ? void 0 : lastExpandedRowIndex.current,
29
+ blockClass: blockClass,
30
+ activeElement: document.activeElement
31
+ });
24
32
  var visibleColumns = function visibleColumns(columns) {
25
33
  var expanderColumn = {
26
34
  id: 'expander',
@@ -32,6 +40,7 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
32
40
  // Prevents `onRowClick` from being called if `useOnRowClick` is included
33
41
  event.stopPropagation();
34
42
  row.toggleRowExpanded();
43
+ lastExpandedRowIndex.current = row.id;
35
44
  }
36
45
  });
37
46
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
@@ -6,15 +6,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  * LICENSE file in the root directory of this source tree.
7
7
  */
8
8
 
9
- import { useEffect } from 'react';
10
9
  import { pkg } from '../../settings';
11
10
  import cx from 'classnames';
12
11
  import useNestedRowExpander from './useNestedRowExpander';
13
12
  var blockClass = "".concat(pkg.prefix, "--datagrid");
14
13
  var useNestedRows = function useNestedRows(hooks) {
15
- useEffect(function () {
16
- pkg.checkReportFeatureEnabled('Datagrid.useNestedRows');
17
- }, []);
18
14
  useNestedRowExpander(hooks);
19
15
  var marginLeft = 24;
20
16
  var getRowProps = function getRowProps(props, _ref) {
@@ -15,12 +15,20 @@ import React, { useRef } from 'react';
15
15
  import { ChevronDown16, ChevronUp16 } from '@carbon/icons-react';
16
16
  import cx from 'classnames';
17
17
  import { pkg, carbon } from '../../settings';
18
+ import { useFocusRowExpander } from './useFocusRowExpander';
18
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useRowExpander = function useRowExpander(hooks) {
20
21
  var tempState = useRef();
22
+ var lastExpandedRowIndex = useRef();
21
23
  var useInstance = function useInstance(instance) {
22
24
  tempState.current = instance;
23
25
  };
26
+ useFocusRowExpander({
27
+ instance: tempState === null || tempState === void 0 ? void 0 : tempState.current,
28
+ lastExpandedRowIndex: lastExpandedRowIndex === null || lastExpandedRowIndex === void 0 ? void 0 : lastExpandedRowIndex.current,
29
+ blockClass: blockClass,
30
+ activeElement: document.activeElement
31
+ });
24
32
  var visibleColumns = function visibleColumns(columns) {
25
33
  var expanderColumn = {
26
34
  id: 'expander',
@@ -31,6 +39,7 @@ var useRowExpander = function useRowExpander(hooks) {
31
39
  // Prevents `onRowClick` from being called if `useOnRowClick` is included
32
40
  event.stopPropagation();
33
41
  row.toggleRowExpanded();
42
+ lastExpandedRowIndex.current = row.id;
34
43
  }
35
44
  });
36
45
  var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
@@ -6,14 +6,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
6
6
  var _excluded = ["onChange", "title"];
7
7
  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; }
8
8
  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; }
9
- /*
10
- * Licensed Materials - Property of IBM
11
- * 5724-Q36
12
- * (c) Copyright IBM Corp. 2023
13
- * US Government Users Restricted Rights - Use, duplication or disclosure
14
- * restricted by GSA ADP Schedule Contract with IBM Corp.
9
+ /**
10
+ * Copyright IBM Corp. 2020, 2023
11
+ *
12
+ * This source code is licensed under the Apache-2.0 license found in the
13
+ * LICENSE file in the root directory of this source tree.
15
14
  */
16
- // @flow
15
+
17
16
  import React, { useLayoutEffect, useState } from 'react';
18
17
  import cx from 'classnames';
19
18
  import { TableSelectRow } from 'carbon-components-react';
@@ -43,7 +42,14 @@ var useSelectRows = function useSelectRows(hooks) {
43
42
  });
44
43
  });
45
44
  hooks.visibleColumns.push(function (columns) {
46
- return [{
45
+ // Ensures that the first column is the row expander in the
46
+ // case of selected rows and expandable rows being used together
47
+ var newColOrder = _toConsumableArray(columns);
48
+ var expanderColumnIndex = newColOrder.findIndex(function (col) {
49
+ return col.id === 'expander';
50
+ });
51
+ var expanderCol = expanderColumnIndex > -1 ? newColOrder.splice(expanderColumnIndex, 1) : [];
52
+ return [].concat(_toConsumableArray(expanderColumnIndex > -1 && expanderCol && expanderCol.length ? expanderCol : []), [{
47
53
  id: selectionColumnId,
48
54
  Header: function Header(gridState) {
49
55
  return /*#__PURE__*/React.createElement(SelectAll, gridState);
@@ -51,7 +57,7 @@ var useSelectRows = function useSelectRows(hooks) {
51
57
  Cell: function Cell(gridState) {
52
58
  return /*#__PURE__*/React.createElement(SelectRow, gridState);
53
59
  }
54
- }].concat(_toConsumableArray(columns));
60
+ }], _toConsumableArray(newColOrder));
55
61
  });
56
62
  };
57
63
  var useHighlightSelection = function useHighlightSelection(hooks) {
@@ -79,7 +85,8 @@ var SelectRow = function SelectRow(datagridState) {
79
85
  onRowSelect = datagridState.onRowSelect,
80
86
  columns = datagridState.columns,
81
87
  withStickyColumn = datagridState.withStickyColumn,
82
- dispatch = datagridState.dispatch;
88
+ dispatch = datagridState.dispatch,
89
+ getRowId = datagridState.getRowId;
83
90
  var _useState = useState(window.innerWidth),
84
91
  _useState2 = _slicedToArray(_useState, 2),
85
92
  windowSize = _useState2[0],
@@ -110,7 +117,12 @@ var SelectRow = function SelectRow(datagridState) {
110
117
  }
111
118
  onChange(event);
112
119
  onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(row, event);
113
- handleToggleRowSelected(dispatch, row, event.target.checked);
120
+ handleToggleRowSelected({
121
+ dispatch: dispatch,
122
+ rowData: row,
123
+ isChecked: event.target.checked,
124
+ getRowId: getRowId
125
+ });
114
126
  };
115
127
  var rowId = "".concat(tableId, "-").concat(row.index);
116
128
  return /*#__PURE__*/React.createElement(TableSelectRow, _extends({}, cellProps, selectProps, {
@@ -0,0 +1,26 @@
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
+ // Example usage for custom filter tag labels, in practice this
9
+ // is where a translation service would be utilized. This
10
+ // utility is for storybook demonstration purposes only.
11
+ export var handleFilterTagLabelText = function handleFilterTagLabelText(key, value) {
12
+ switch (key) {
13
+ case 'role':
14
+ return "Role: ".concat(value);
15
+ case 'joined':
16
+ return "Joined: ".concat(value);
17
+ case 'visits':
18
+ return "Visits: ".concat(value);
19
+ case 'passwordStrength':
20
+ return "Password strength: ".concat(value);
21
+ case 'status':
22
+ return "Status: ".concat(value);
23
+ default:
24
+ return "".concat(key, ": ").concat(value);
25
+ }
26
+ };
@@ -4,19 +4,21 @@ var _excluded = ["key", "value"];
4
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
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; }
6
6
  /**
7
- * Copyright IBM Corp. 2022, 2022
7
+ * Copyright IBM Corp. 2022, 2023
8
8
  *
9
9
  * This source code is licensed under the Apache-2.0 license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
11
  */
12
12
  import { Button } from 'carbon-components-react';
13
- import React from 'react';
13
+ import React, { useRef } from 'react';
14
14
  import PropTypes from 'prop-types';
15
15
  import cx from 'classnames';
16
16
  import { TagSet } from '../TagSet';
17
17
  import { pkg } from '../../settings';
18
+ import uuidv4 from '../../global/js/utils/uuidv4';
18
19
  var blockClass = "".concat(pkg.prefix, "--filter-summary");
19
20
  var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
21
+ var _filterSummaryClearBu;
20
22
  var _ref$className = _ref.className,
21
23
  className = _ref$className === void 0 ? '' : _ref$className,
22
24
  _ref$clearFiltersText = _ref.clearFiltersText,
@@ -28,7 +30,10 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
28
30
  _ref$renderLabel = _ref.renderLabel,
29
31
  renderLabel = _ref$renderLabel === void 0 ? null : _ref$renderLabel,
30
32
  _ref$overflowType = _ref.overflowType,
31
- overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType;
33
+ overflowType = _ref$overflowType === void 0 ? 'default' : _ref$overflowType,
34
+ _ref$clearButtonInlin = _ref.clearButtonInline,
35
+ clearButtonInline = _ref$clearButtonInlin === void 0 ? true : _ref$clearButtonInlin;
36
+ var filterSummaryId = "".concat(blockClass, "__").concat(uuidv4());
32
37
  var tagFilters = filters.map(function (_ref2) {
33
38
  var _renderLabel;
34
39
  var key = _ref2.key,
@@ -39,26 +44,35 @@ var FilterSummary = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
39
44
  label: (_renderLabel = renderLabel === null || renderLabel === void 0 ? void 0 : renderLabel(key, value)) !== null && _renderLabel !== void 0 ? _renderLabel : "".concat(key, ": ").concat(value)
40
45
  });
41
46
  });
47
+ var filterSummaryClearButton = useRef();
48
+ var filterSummaryRef = useRef();
49
+ var localRef = filterSummaryRef || ref;
42
50
  return /*#__PURE__*/React.createElement("div", {
43
- ref: ref,
44
- className: cx([blockClass, className])
51
+ ref: localRef,
52
+ className: cx([blockClass, className]),
53
+ id: filterSummaryId
45
54
  }, /*#__PURE__*/React.createElement(TagSet, {
46
55
  allTagsModalSearchLabel: "Search all tags",
47
56
  allTagsModalSearchPlaceholderText: "Search all tags",
48
57
  allTagsModalTitle: "All tags",
49
58
  showAllTagsLabel: "View all tags",
50
59
  tags: tagFilters,
51
- overflowType: overflowType
60
+ overflowType: overflowType,
61
+ className: cx(_defineProperty({}, "".concat(blockClass, "__clear-button-inline"), clearButtonInline)),
62
+ containingElementRef: localRef,
63
+ measurementOffset: filterSummaryClearButton === null || filterSummaryClearButton === void 0 ? void 0 : (_filterSummaryClearBu = filterSummaryClearButton.current) === null || _filterSummaryClearBu === void 0 ? void 0 : _filterSummaryClearBu.offsetWidth
52
64
  }), /*#__PURE__*/React.createElement(Button, {
53
65
  kind: "ghost",
54
66
  size: "sm",
55
- onClick: clearFilters
67
+ onClick: clearFilters,
68
+ ref: filterSummaryClearButton
56
69
  }, clearFiltersText));
57
70
  });
58
71
  var componentName = 'FilterSummary';
59
72
  FilterSummary.displayName = componentName;
60
73
  FilterSummary.propTypes = {
61
74
  className: PropTypes.string,
75
+ clearButtonInline: PropTypes.boolean,
62
76
  clearFilters: PropTypes.func.isRequired,
63
77
  clearFiltersText: PropTypes.string,
64
78
  filters: PropTypes.arrayOf(PropTypes.object).isRequired,
@@ -74,9 +74,6 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
74
74
  _useState6 = _slicedToArray(_useState5, 2),
75
75
  isCollapsed = _useState6[0],
76
76
  setIsCollapsed = _useState6[1];
77
- var handleScrollableChange = function handleScrollableChange(value) {
78
- setShowNavigation(value);
79
- };
80
77
  var handleClickToggle = function handleClickToggle() {
81
78
  setScrollPosition(0);
82
79
  scrollRef.current.scrollToView(0);
@@ -101,9 +98,13 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
101
98
  left: blue90,
102
99
  right: purple70
103
100
  },
104
- ref: scrollRef,
105
- scrollableChange: handleScrollableChange,
106
- scrollTune: -450
101
+ onChangeIsScrollable: function onChangeIsScrollable(value) {
102
+ setShowNavigation(value);
103
+ },
104
+ onScroll: function onScroll(scrollPercent) {
105
+ setScrollPosition(scrollPercent);
106
+ },
107
+ ref: scrollRef
107
108
  }, children), /*#__PURE__*/React.createElement("div", {
108
109
  className: cx([collapsible || showNavigation ? "".concat(blockClass, "__navigation") : null])
109
110
  }, collapsible && /*#__PURE__*/React.createElement(Button, {
@@ -122,9 +123,7 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
122
123
  tooltipPosition: "top",
123
124
  iconDescription: previousIconDescription,
124
125
  onClick: function onClick() {
125
- scrollRef.current.scrollPrev().then(function (scrollPercentage) {
126
- return setScrollPosition(scrollPercentage);
127
- });
126
+ scrollRef.current.scrollPrev();
128
127
  }
129
128
  }), /*#__PURE__*/React.createElement(Button, {
130
129
  kind: "ghost",
@@ -137,9 +136,7 @@ export var Guidebanner = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
137
136
  tooltipAlignment: "end",
138
137
  iconDescription: nextIconDescription,
139
138
  onClick: function onClick() {
140
- scrollRef.current.scrollNext().then(function (scrollPercentage) {
141
- return setScrollPosition(scrollPercentage);
142
- });
139
+ scrollRef.current.scrollNext();
143
140
  }
144
141
  }))), onClose && /*#__PURE__*/React.createElement(Button, {
145
142
  className: "".concat(blockClass, "__close-button"),