@carbon/ibm-products 1.31.0 → 1.32.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. package/css/index-full-carbon.css +71 -5
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +67 -5
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +1 -1
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +67 -5
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +1 -1
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
  14. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  15. package/es/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
  16. package/es/components/Datagrid/Datagrid/DatagridContent.js +43 -18
  17. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  18. package/es/components/Datagrid/Datagrid/DatagridRow.js +10 -2
  19. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +12 -3
  20. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
  21. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
  22. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +9 -1
  23. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +153 -87
  24. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +66 -0
  25. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
  26. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  27. package/es/components/Datagrid/useActionsColumn.js +28 -12
  28. package/es/components/Datagrid/useExpandedRow.js +0 -1
  29. package/es/components/Datagrid/useNestedRowExpander.js +42 -0
  30. package/es/components/Datagrid/useNestedRows.js +2 -2
  31. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  32. package/es/components/Datagrid/utils/DatagridActions.js +121 -0
  33. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  34. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  35. package/es/components/Datagrid/utils/getArgTypes.js +85 -0
  36. package/es/components/Datagrid/utils/makeData.js +25 -5
  37. package/es/components/InlineEdit/InlineEdit.js +7 -7
  38. package/es/components/OptionsTile/OptionsTile.js +4 -2
  39. package/es/global/js/utils/story-helper.js +5 -1
  40. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +1 -0
  41. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  42. package/lib/components/DataSpreadsheet/hooks/useMultipleKeyTracking.js +2 -2
  43. package/lib/components/Datagrid/Datagrid/DatagridContent.js +44 -18
  44. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  45. package/lib/components/Datagrid/Datagrid/DatagridRow.js +19 -2
  46. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +14 -3
  47. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +1 -4
  48. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +16 -8
  49. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +10 -7
  50. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +155 -87
  51. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +78 -0
  52. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +1 -1
  53. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -1
  54. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  55. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  56. package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
  57. package/lib/components/Datagrid/useNestedRows.js +3 -3
  58. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  59. package/lib/components/Datagrid/utils/DatagridActions.js +139 -0
  60. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  61. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  62. package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
  63. package/lib/components/Datagrid/utils/makeData.js +26 -5
  64. package/lib/components/InlineEdit/InlineEdit.js +7 -7
  65. package/lib/components/OptionsTile/OptionsTile.js +4 -2
  66. package/lib/global/js/utils/story-helper.js +5 -1
  67. package/package.json +12 -12
  68. package/scss/components/Datagrid/styles/_datagrid.scss +0 -4
  69. package/scss/components/Datagrid/styles/_useActionsColumn.scss +12 -0
  70. package/scss/components/Datagrid/styles/_useExpandedRow.scss +30 -0
  71. package/scss/components/Datagrid/styles/_useInlineEdit.scss +6 -0
  72. package/scss/components/Datagrid/styles/_useNestedRows.scss +15 -1
  73. package/scss/components/Datagrid/styles/_useStickyColumn.scss +6 -0
  74. package/scss/components/OptionsTile/_options-tile.scss +4 -0
@@ -1,7 +1,8 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
4
+ var _excluded = ["id", "itemText", "onClick", "icon"],
5
+ _excluded2 = ["id", "onClick", "shouldHideMenuItem", "shouldDisableMenuItem", "disabled"];
5
6
 
6
7
  /*
7
8
  * Licensed Materials - Property of IBM
@@ -19,7 +20,8 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
19
20
  var useActionsColumn = function useActionsColumn(hooks) {
20
21
  var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
21
22
  var rowActions = instance.rowActions,
22
- isFetching = instance.isFetching;
23
+ isFetching = instance.isFetching,
24
+ selectedFlatRows = instance.selectedFlatRows;
23
25
 
24
26
  if (rowActions && Array.isArray(rowActions)) {
25
27
  var addActionsMenu = function addActionsMenu(props, cellData) {
@@ -28,7 +30,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
28
30
  column = cell.column;
29
31
 
30
32
  if (column.isAction) {
31
- var _cx;
33
+ var _cx3;
32
34
 
33
35
  return [props, {
34
36
  children: /*#__PURE__*/React.createElement("div", {
@@ -40,26 +42,37 @@ var useActionsColumn = function useActionsColumn(hooks) {
40
42
  style: {
41
43
  display: 'flex'
42
44
  }
43
- }, rowActions.map(function (action) {
45
+ }, rowActions.map(function (action, index) {
44
46
  var id = action.id,
45
47
  itemText = action.itemText,
46
48
  _onClick = action.onClick,
47
- icon = action.icon;
49
+ icon = action.icon,
50
+ rest = _objectWithoutProperties(action, _excluded);
51
+
52
+ var selectedRowId = selectedFlatRows === null || selectedFlatRows === void 0 ? void 0 : selectedFlatRows.filter(function (item) {
53
+ return item.id === row.id ? item.id : null;
54
+ });
48
55
  return /*#__PURE__*/React.createElement("div", {
49
- className: "".concat(blockClass, "__actions-column-button"),
50
- key: ""
51
- }, /*#__PURE__*/React.createElement(OverflowMenu, {
56
+ className: cx("".concat(blockClass, "__actions-column-button"), _defineProperty({}, "".concat(blockClass, "__disabled-row-action-button"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
57
+ key: "".concat(itemText, "__").concat(index)
58
+ }, /*#__PURE__*/React.createElement(OverflowMenu, _extends({}, rest, {
52
59
  renderIcon: icon,
53
60
  hasIconOnly: true,
54
61
  light: true,
55
62
  iconDescription: itemText,
56
63
  kind: "ghost",
64
+ className: cx(_defineProperty({}, "".concat(blockClass, "__disabled-row-action"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
57
65
  onClick: function onClick(e) {
66
+ if (selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length) {
67
+ // Row actions should be disabled if row is selected and batchActions toolbar is active
68
+ return;
69
+ }
70
+
58
71
  e.stopPropagation();
59
72
 
60
73
  _onClick(id, row, e);
61
74
  }
62
- }));
75
+ })));
63
76
  })), !isFetching && rowActions.length > 2 && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(OverflowMenu, {
64
77
  size: "sm",
65
78
  light: true,
@@ -73,7 +86,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
73
86
  shouldHideMenuItem = action.shouldHideMenuItem,
74
87
  shouldDisableMenuItem = action.shouldDisableMenuItem,
75
88
  disabled = action.disabled,
76
- rest = _objectWithoutProperties(action, _excluded);
89
+ rest = _objectWithoutProperties(action, _excluded2);
77
90
 
78
91
  var hidden = typeof shouldHideMenuItem === 'function' && shouldHideMenuItem(row); // shouldDisableMenuItem will override disabled because it's more specific
79
92
  // if shouldDisableMenuItem doesn't exists, fall back to disabled
@@ -94,7 +107,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
94
107
  key: id
95
108
  }));
96
109
  })))),
97
- className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx, "".concat(blockClass, "__cell"), true), _cx))
110
+ className: cx((_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__cell"), true), _cx3)),
111
+ style: {
112
+ width: 96
113
+ }
98
114
  }];
99
115
  }
100
116
 
@@ -37,7 +37,6 @@ var useExpandedRow = function useExpandedRow(hooks) {
37
37
  return _objectSpread(_objectSpread({}, row), {}, {
38
38
  canExpand: row.original && !row.original.notExpandable,
39
39
  expandedContentHeight: expandedRowsHeight[row.index] || expandedContentHeight,
40
- // RowRenderer: DatagridExpandedRow(row.RowRenderer, expansionRenderer),
41
40
  RowRenderer: DatagridExpandedRow(row.RowRenderer, ExpandedRowContentComponent)
42
41
  });
43
42
  });
@@ -0,0 +1,42 @@
1
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+
4
+ /* eslint-disable react/prop-types */
5
+
6
+ /*
7
+ * Licensed Materials - Property of IBM
8
+ * 5724-Q36
9
+ * (c) Copyright IBM Corp. 2020
10
+ * US Government Users Restricted Rights - Use, duplication or disclosure
11
+ * restricted by GSA ADP Schedule Contract with IBM Corp.
12
+ */
13
+ import React from 'react';
14
+ import { ChevronRight16 } from '@carbon/icons-react';
15
+ import cx from 'classnames';
16
+ import { pkg } from '../../settings';
17
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
18
+
19
+ var useNestedRowExpander = function useNestedRowExpander(hooks) {
20
+ var visibleColumns = function visibleColumns(columns) {
21
+ var expanderColumn = {
22
+ id: 'expander',
23
+ Cell: function Cell(_ref) {
24
+ var _cx;
25
+
26
+ var row = _ref.row;
27
+ return row.canExpand && /*#__PURE__*/React.createElement("span", row.getToggleRowExpandedProps(), /*#__PURE__*/React.createElement(ChevronRight16, {
28
+ className: cx("".concat(blockClass, "__expander-icon"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
29
+ }));
30
+ },
31
+ width: 48,
32
+ disableResizing: true,
33
+ disableSortBy: true,
34
+ Header: ''
35
+ };
36
+ return [expanderColumn].concat(_toConsumableArray(columns));
37
+ };
38
+
39
+ hooks.visibleColumns.push(visibleColumns);
40
+ };
41
+
42
+ export default useNestedRowExpander;
@@ -5,12 +5,12 @@
5
5
  * US Government Users Restricted Rights - Use, duplication or disclosure
6
6
  * restricted by GSA ADP Schedule Contract with IBM Corp.
7
7
  */
8
- import useRowExpander from './useRowExpander';
9
8
  import { pkg } from '../../settings';
9
+ import useNestedRowExpander from './useNestedRowExpander';
10
10
  var blockClass = "".concat(pkg.prefix, "--datagrid");
11
11
 
12
12
  var useNestedRows = function useNestedRows(hooks) {
13
- useRowExpander(hooks);
13
+ useNestedRowExpander(hooks);
14
14
  var marginLeft = 24;
15
15
 
16
16
  var getRowProps = function getRowProps(props, _ref) {
@@ -1,3 +1,5 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+
1
3
  /*
2
4
  * Licensed Materials - Property of IBM
3
5
  * 5724-Q36
@@ -7,6 +9,7 @@
7
9
  */
8
10
  // @flow
9
11
  import React from 'react';
12
+ import cx from 'classnames';
10
13
  import { selectionColumnId } from './common-column-ids';
11
14
  import SelectAllWithToggle from './Datagrid/DatagridSelectAllWithToggle';
12
15
  import { pkg } from '../../settings';
@@ -40,12 +43,18 @@ var useSelectAllWithToggleComponent = function useSelectAllWithToggleComponent(h
40
43
 
41
44
  var useAddClassNameToSelectRow = function useAddClassNameToSelectRow(hooks) {
42
45
  hooks.getCellProps.push(function (props, data) {
46
+ var _columns$;
47
+
43
48
  var column = data.cell.column;
44
- var DatagridPagination = data.instance.DatagridPagination;
49
+ var _data$instance = data.instance,
50
+ DatagridPagination = _data$instance.DatagridPagination,
51
+ columns = _data$instance.columns,
52
+ withStickyColumn = _data$instance.withStickyColumn;
53
+ var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
45
54
 
46
55
  if (column.id === selectionColumnId && DatagridPagination) {
47
56
  return [props, {
48
- className: "".concat(blockClass, "__select-all-toggle-on")
57
+ className: cx("".concat(blockClass, "__select-all-toggle-on"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
49
58
  }];
50
59
  }
51
60
 
@@ -59,14 +68,18 @@ var Header = function Header(gridState) {
59
68
  selectAllToggle = gridState.selectAllToggle,
60
69
  getToggleAllPageRowsSelectedProps = gridState.getToggleAllPageRowsSelectedProps,
61
70
  getToggleAllRowsSelectedProps = gridState.getToggleAllRowsSelectedProps,
62
- isAllRowsSelected = gridState.isAllRowsSelected;
71
+ isAllRowsSelected = gridState.isAllRowsSelected,
72
+ withStickyColumn = gridState.withStickyColumn,
73
+ columns = gridState.columns;
63
74
  var props = {
64
75
  tableId: tableId,
65
76
  isFetching: isFetching,
66
77
  selectAllToggle: selectAllToggle,
67
78
  getToggleAllPageRowsSelectedProps: getToggleAllPageRowsSelectedProps,
68
79
  getToggleAllRowsSelectedProps: getToggleAllRowsSelectedProps,
69
- isAllRowsSelected: isAllRowsSelected
80
+ isAllRowsSelected: isAllRowsSelected,
81
+ withStickyColumn: withStickyColumn,
82
+ columns: columns
70
83
  };
71
84
  return /*#__PURE__*/React.createElement(SelectAllWithToggle, props);
72
85
  };
@@ -0,0 +1,121 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2022
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ import { DataTable, Button } from 'carbon-components-react';
9
+ import { Download16, Filter16, Add16, Restart16 } from '@carbon/icons-react';
10
+ import { action } from '@storybook/addon-actions';
11
+ import { pkg } from '../../../settings';
12
+ import { ButtonMenu, ButtonMenuItem } from '../../ButtonMenu';
13
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
14
+ export var DatagridActions = function DatagridActions(datagridState) {
15
+ var selectedFlatRows = datagridState.selectedFlatRows,
16
+ setGlobalFilter = datagridState.setGlobalFilter,
17
+ CustomizeColumnsButton = datagridState.CustomizeColumnsButton,
18
+ RowSizeDropdown = datagridState.RowSizeDropdown,
19
+ rowSizeDropdownProps = datagridState.rowSizeDropdownProps,
20
+ useDenseHeader = datagridState.useDenseHeader;
21
+
22
+ var downloadCsv = function downloadCsv() {
23
+ alert('Downloading...');
24
+ };
25
+
26
+ var TableToolbarContent = DataTable.TableToolbarContent,
27
+ TableToolbarSearch = DataTable.TableToolbarSearch;
28
+
29
+ var refreshColumns = function refreshColumns() {
30
+ alert('refreshing...');
31
+ };
32
+
33
+ var leftPanelClick = function leftPanelClick() {
34
+ alert('open/close left panel...');
35
+ };
36
+
37
+ var searchForAColumn = 'Search';
38
+ var isNothingSelected = selectedFlatRows.length === 0;
39
+ var style = {
40
+ 'button:nth-child(1) > span:nth-child(1)': {
41
+ bottom: '-37px'
42
+ }
43
+ };
44
+ return isNothingSelected && (useDenseHeader && useDenseHeader ? /*#__PURE__*/React.createElement(TableToolbarContent, {
45
+ size: "sm"
46
+ }, /*#__PURE__*/React.createElement("div", {
47
+ style: style
48
+ }, /*#__PURE__*/React.createElement(Button, {
49
+ kind: "ghost",
50
+ hasIconOnly: true,
51
+ tooltipPosition: "bottom",
52
+ renderIcon: Download16,
53
+ iconDescription: 'Download CSV',
54
+ onClick: downloadCsv
55
+ })), /*#__PURE__*/React.createElement("div", {
56
+ style: style
57
+ }, /*#__PURE__*/React.createElement(Button, {
58
+ kind: "ghost",
59
+ hasIconOnly: true,
60
+ tooltipPosition: "bottom",
61
+ renderIcon: Filter16,
62
+ iconDescription: 'Left panel',
63
+ onClick: leftPanelClick
64
+ })), /*#__PURE__*/React.createElement(RowSizeDropdown, rowSizeDropdownProps), /*#__PURE__*/React.createElement("div", {
65
+ style: style,
66
+ className: "".concat(blockClass, "__toolbar-divider")
67
+ }, /*#__PURE__*/React.createElement(Button, {
68
+ kind: "ghost",
69
+ renderIcon: Add16,
70
+ iconDescription: 'Action'
71
+ }, "Ghost button")), CustomizeColumnsButton && /*#__PURE__*/React.createElement("div", {
72
+ style: style
73
+ }, /*#__PURE__*/React.createElement(CustomizeColumnsButton, null))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Button, {
74
+ kind: "ghost",
75
+ hasIconOnly: true,
76
+ tooltipPosition: "bottom",
77
+ renderIcon: Filter16,
78
+ iconDescription: 'Left panel',
79
+ onClick: leftPanelClick
80
+ }), /*#__PURE__*/React.createElement(TableToolbarContent, null, /*#__PURE__*/React.createElement(TableToolbarSearch, {
81
+ size: "xl",
82
+ id: "columnSearch",
83
+ persistent: true,
84
+ placeHolderText: searchForAColumn,
85
+ onChange: function onChange(e) {
86
+ return setGlobalFilter(e.target.value);
87
+ }
88
+ }), /*#__PURE__*/React.createElement(RowSizeDropdown, rowSizeDropdownProps), /*#__PURE__*/React.createElement("div", {
89
+ style: style
90
+ }, /*#__PURE__*/React.createElement(Button, {
91
+ kind: "ghost",
92
+ hasIconOnly: true,
93
+ tooltipPosition: "bottom",
94
+ renderIcon: Restart16,
95
+ iconDescription: 'Refresh',
96
+ onClick: refreshColumns
97
+ })), /*#__PURE__*/React.createElement("div", {
98
+ style: style
99
+ }, /*#__PURE__*/React.createElement(Button, {
100
+ kind: "ghost",
101
+ hasIconOnly: true,
102
+ tooltipPosition: "bottom",
103
+ renderIcon: Download16,
104
+ iconDescription: 'Download CSV',
105
+ onClick: downloadCsv
106
+ })), CustomizeColumnsButton && /*#__PURE__*/React.createElement("div", {
107
+ style: style
108
+ }, /*#__PURE__*/React.createElement(CustomizeColumnsButton, null)), /*#__PURE__*/React.createElement(ButtonMenu, {
109
+ label: "Primary button",
110
+ renderIcon: Add16
111
+ }, /*#__PURE__*/React.createElement(ButtonMenuItem, {
112
+ itemText: "Option 1",
113
+ onClick: action("Click on ButtonMenu Option 1")
114
+ }), /*#__PURE__*/React.createElement(ButtonMenuItem, {
115
+ itemText: "Option 2",
116
+ onClick: action("Click on ButtonMenu Option 2")
117
+ }), /*#__PURE__*/React.createElement(ButtonMenuItem, {
118
+ itemText: "Option 3",
119
+ onClick: action("Click on ButtonMenu Option 3")
120
+ })))));
121
+ };
@@ -0,0 +1,33 @@
1
+ /* eslint-disable react/prop-types */
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2022, 2022
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import React from 'react';
10
+ import { Pagination } from 'carbon-components-react';
11
+ export var DatagridPagination = function DatagridPagination(_ref) {
12
+ var state = _ref.state,
13
+ setPageSize = _ref.setPageSize,
14
+ gotoPage = _ref.gotoPage,
15
+ rows = _ref.rows;
16
+
17
+ var updatePagination = function updatePagination(_ref2) {
18
+ var page = _ref2.page,
19
+ pageSize = _ref2.pageSize;
20
+ console.log(state);
21
+ setPageSize(pageSize);
22
+ gotoPage(page - 1); // Carbon is non-zero-based
23
+ };
24
+
25
+ return /*#__PURE__*/React.createElement(Pagination, {
26
+ page: state.pageIndex + 1 // react-table is zero-based
27
+ ,
28
+ pageSize: state.pageSize,
29
+ pageSizes: state.pageSizes || [10, 20, 30, 40, 50],
30
+ totalItems: rows.length,
31
+ onChange: updatePagination
32
+ });
33
+ };
@@ -0,0 +1,21 @@
1
+ /* eslint-disable react/prop-types */
2
+
3
+ /**
4
+ * Copyright IBM Corp. 2020, 2022
5
+ *
6
+ * This source code is licensed under the Apache-2.0 license found in the
7
+ * LICENSE file in the root directory of this source tree.
8
+ */
9
+ import React from 'react';
10
+ export var Wrapper = function Wrapper(_ref) {
11
+ var children = _ref.children;
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ style: {
14
+ height: '100vh',
15
+ width: '100%',
16
+ padding: '1rem',
17
+ margin: '0',
18
+ zIndex: '0'
19
+ }
20
+ }, children);
21
+ };
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Copyright IBM Corp. 2022, 2022
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
+ export var ARG_TYPES = {
8
+ gridTitle: {
9
+ name: 'gridTitle',
10
+ control: 'text',
11
+ description: 'This sets the title text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
12
+ type: {
13
+ name: 'string',
14
+ required: false
15
+ }
16
+ },
17
+ gridDescription: {
18
+ name: 'gridDescription',
19
+ control: 'text',
20
+ description: 'This sets the description text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
21
+ type: {
22
+ name: 'string',
23
+ required: false
24
+ }
25
+ },
26
+ emptyStateTitle: {
27
+ name: 'emptyStateTitle',
28
+ control: 'text',
29
+ description: 'This sets the empty state title text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
30
+ type: {
31
+ name: 'string',
32
+ required: false
33
+ }
34
+ },
35
+ emptyStateDescription: {
36
+ name: 'emptyStateDescription',
37
+ control: 'text',
38
+ description: 'This sets the empty state description text for the Datagrid component. _This value is set/passed inside of the `datagridState` object._',
39
+ type: {
40
+ name: 'string',
41
+ required: false
42
+ }
43
+ },
44
+ emptyStateSize: {
45
+ control: 'select',
46
+ options: ['sm', 'lg']
47
+ },
48
+ useDenseHeader: {
49
+ control: {
50
+ type: 'radio'
51
+ },
52
+ options: [true, false],
53
+ description: 'This sets the dense header option for the Datagrid component. _This value is set/passed inside of the `datagridState` object._'
54
+ },
55
+ rowSize: {
56
+ control: 'select',
57
+ options: ['xs', 'sm', 'md', 'lg', 'xl'],
58
+ description: 'This sets the height for each row of the Datagrid component. _This value is set/passed inside of the `datagridState` object._'
59
+ },
60
+ rowSizes: {
61
+ control: 'object',
62
+ description: 'This array of objects specifies the different row size options that will render from the settings icon in the table actions. _This value is set/passed inside of the `datagridState` object._'
63
+ },
64
+ onRowSizeChange: {
65
+ description: 'Callback function that is called on row size changes. _This value is set/passed inside of the `datagridState` object._'
66
+ },
67
+ rowActions: {
68
+ control: 'object',
69
+ description: 'This array of objects renders the action buttons for each row in the Datagrid. _This value is set/passed inside of the `datagridState` object._',
70
+ action: 'Row action onClick'
71
+ },
72
+ batchActions: {
73
+ control: {
74
+ type: 'radio'
75
+ },
76
+ options: [true, false],
77
+ description: 'This will allow the Datagrid component to use batch actions. _This value is set/passed inside of the `datagridState` object._'
78
+ },
79
+ expandedContentHeight: {
80
+ control: {
81
+ type: 'number'
82
+ },
83
+ description: 'This value controls the height of the expanded content area. _This value is set/passed inside of the `datagridState` object._'
84
+ }
85
+ };
@@ -12,12 +12,20 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
12
12
  */
13
13
  import React from 'react';
14
14
  import namor from 'namor';
15
+ import { StatusIcon } from '../../StatusIcon';
15
16
  import { inlineEditSelectItems } from './getInlineEditColumns';
16
17
 
17
- var getRandomInteger = function getRandomInteger(min, max) {
18
- min = Math.ceil(min);
19
- max = Math.floor(max);
20
- return Math.floor(Math.random() * (max - min + 1)) + min;
18
+ var getRandomInteger = function getRandomInteger(min, max, decimalPlaces) {
19
+ var roundedMin = Math.ceil(min);
20
+ var roundedMax = Math.floor(max);
21
+ var randomNumber = Math.random() * (max - min) + min;
22
+
23
+ if (!decimalPlaces) {
24
+ return Math.floor(Math.random() * (roundedMax - roundedMin + 1)) + roundedMin;
25
+ }
26
+
27
+ var power = Math.pow(10, decimalPlaces);
28
+ return Math.floor(randomNumber * power) / power;
21
29
  };
22
30
 
23
31
  export var makeData = function makeData() {
@@ -47,6 +55,16 @@ export var range = function range(len) {
47
55
  return arr;
48
56
  };
49
57
 
58
+ var renderStatusIcon = function renderStatusIcon(statusChance) {
59
+ var iconProps = {
60
+ size: 'sm',
61
+ theme: 'light',
62
+ kind: statusChance > 0.66 ? 'critical' : statusChance > 0.33 ? 'minor-warning' : 'normal',
63
+ iconDescription: statusChance > 0.66 ? 'Critical' : statusChance > 0.33 ? 'Minor warning' : 'Normal'
64
+ };
65
+ return /*#__PURE__*/React.createElement(StatusIcon, iconProps);
66
+ };
67
+
50
68
  var newPerson = function newPerson() {
51
69
  var statusChance = Math.random();
52
70
  var initialChartTypeIndex = getRandomInteger(0, 2);
@@ -149,7 +167,9 @@ var newPerson = function newPerson() {
149
167
  }),
150
168
  status: statusChance > 0.66 ? 'relationship' : statusChance > 0.33 ? 'complicated' : 'single',
151
169
  chartType: initialChartTypeIndex === 0 ? inlineEditSelectItems[0] : initialChartTypeIndex === 1 ? inlineEditSelectItems[1] : inlineEditSelectItems[2],
152
- activeSince: statusChance > 0.66 ? activeSinceDate : statusChance > 0.33 ? yesterdayDate : twoDaysAgoDate
170
+ activeSince: statusChance > 0.66 ? activeSinceDate : statusChance > 0.33 ? yesterdayDate : twoDaysAgoDate,
171
+ bonus: "$\r".concat(getRandomInteger(100, 500, 2)),
172
+ status_icon: renderStatusIcon(statusChance)
153
173
  };
154
174
  };
155
175
 
@@ -40,7 +40,7 @@ var buttons = ['cancel', 'edit', 'save'];
40
40
  */
41
41
 
42
42
  export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
43
- var _cx, _refInput$current, _refInput$current$inn, _cx3;
43
+ var _cx, _refInput$current, _refInput$current$tex, _cx3;
44
44
 
45
45
  var buttonTooltipAlignment = _ref.buttonTooltipAlignment,
46
46
  buttonTooltipPosition = _ref.buttonTooltipPosition,
@@ -66,7 +66,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
66
66
  rest = _objectWithoutProperties(_ref, _excluded);
67
67
 
68
68
  var refInput = useRef({
69
- innerText: value
69
+ textContent: value
70
70
  });
71
71
  var localRef = useRef(null);
72
72
  var ref = refIn || localRef;
@@ -148,15 +148,15 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
148
148
  document.getSelection().removeAllRanges();
149
149
 
150
150
  if (onSave) {
151
- onSave(refInput.current.innerText);
151
+ onSave(refInput.current.textContent);
152
152
  }
153
153
  };
154
154
 
155
155
  var handleInput = function handleInput() {
156
- setInternalValue(refInput.current.innerText);
156
+ setInternalValue(refInput.current.textContent);
157
157
 
158
158
  if (onChange) {
159
- onChange(refInput.current.innerText);
159
+ onChange(refInput.current.textContent);
160
160
  }
161
161
  }; // pasting into contentEditable not supported by userEvent
162
162
 
@@ -191,7 +191,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
191
191
  };
192
192
 
193
193
  var handleCancel = function handleCancel() {
194
- refInput.current.innerText = value;
194
+ refInput.current.textContent = value;
195
195
  handleInput(value);
196
196
  doSetEditing(false);
197
197
  document.getSelection().removeAllRanges();
@@ -259,7 +259,7 @@ export var InlineEdit = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
259
259
  }, /*#__PURE__*/React.createElement("div", _extends({}, rest, getDevtoolsProps(componentName), {
260
260
  id: id,
261
261
  size: size,
262
- className: cx("".concat(blockClass, "__input"), _defineProperty({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$inn = _refInput$current.innerText) === null || _refInput$current$inn === void 0 ? void 0 : _refInput$current$inn.length) === 0)),
262
+ className: cx("".concat(blockClass, "__input"), _defineProperty({}, "".concat(blockClass, "__input--empty"), ((_refInput$current = refInput.current) === null || _refInput$current === void 0 ? void 0 : (_refInput$current$tex = _refInput$current.textContent) === null || _refInput$current$tex === void 0 ? void 0 : _refInput$current$tex.length) === 0)),
263
263
  contentEditable: true,
264
264
  "aria-label": labelText,
265
265
  role: "textbox",
@@ -202,12 +202,14 @@ export var OptionsTile = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
202
202
  className: "".concat(blockClass, "__heading")
203
203
  }, /*#__PURE__*/React.createElement("h6", {
204
204
  id: titleId,
205
- className: "".concat(blockClass, "__title")
205
+ className: "".concat(blockClass, "__title"),
206
+ title: title
206
207
  }, title), text && /*#__PURE__*/React.createElement("span", {
207
208
  className: cx(summaryClasses),
208
209
  "aria-hidden": summaryHidden
209
210
  }, Icon && /*#__PURE__*/React.createElement(Icon, null), /*#__PURE__*/React.createElement("span", {
210
- className: "".concat(blockClass, "__summary-text")
211
+ className: "".concat(blockClass, "__summary-text"),
212
+ title: text
211
213
  }, text)));
212
214
  }
213
215
 
@@ -29,7 +29,11 @@ export var getStoryTitle = function getStoryTitle(componentName) {
29
29
  * @returns The story id.
30
30
  */
31
31
 
32
- export var getStoryId = function getStoryId(componentName, scenario) {
32
+ export var getStoryId = function getStoryId(componentName, scenario, subdirectory) {
33
+ if (subdirectory) {
34
+ return "".concat(sanitize(getStoryTitle(componentName)), "-").concat(sanitize(subdirectory), "--").concat(scenario);
35
+ }
36
+
33
37
  return "".concat(sanitize(getStoryTitle(componentName)), "--").concat(scenario);
34
38
  };
35
39
  /**
@@ -897,6 +897,7 @@ var DataSpreadsheet = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref
897
897
  className: (0, _classnames.default)("".concat(blockClass, "--interactive-cell-element"), "".concat(blockClass, "__active-cell--highlight"), (0, _defineProperty2.default)({}, "".concat(blockClass, "__active-cell--with-selection"), activeCellInsideSelectionArea)),
898
898
  type: "button"
899
899
  }, activeCellContent), /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.TextArea, {
900
+ id: "".concat(blockClass, "__cell-editor-text-area"),
900
901
  value: cellEditorValue,
901
902
  onKeyDown: (0, _handleEditSubmit.handleEditSubmit)({
902
903
  activeCellCoordinates: activeCellCoordinates,
@@ -411,7 +411,8 @@ var DataSpreadsheetBody = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, re
411
411
  }), {
412
412
  className: (0, _classnames.default)("".concat(blockClass, "__tr")),
413
413
  "data-row-index": index,
414
- "aria-rowindex": index + 1
414
+ "aria-rowindex": index + 1,
415
+ "aria-owns": "".concat(blockClass, "__cell-editor-text-area")
415
416
  }), /*#__PURE__*/_react.default.createElement("div", {
416
417
  role: "rowheader",
417
418
  className: "".concat(blockClass, "__td-th--cell-container")
@@ -80,7 +80,7 @@ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
80
80
  };
81
81
  }, []);
82
82
  (0, _react.useEffect)(function () {
83
- if (containerHasFocus && !isEditing) {
83
+ if (ref && containerHasFocus && !isEditing) {
84
84
  ref.current.onkeydown = ref.current.onkeyup = function (event) {
85
85
  // If keydown, we will add the new key to the keysPressedList array
86
86
  if (event.type === 'keydown') {
@@ -132,7 +132,7 @@ var useMultipleKeyTracking = function useMultipleKeyTracking(_ref) {
132
132
  // or is currently in edit mode
133
133
 
134
134
 
135
- if (!containerHasFocus || isEditing) {
135
+ if (ref && !containerHasFocus || isEditing) {
136
136
  ref.current.onkeydown = undefined;
137
137
  ref.current.onkeyup = undefined;
138
138