@carbon/ibm-products 1.27.0 → 1.32.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (167) hide show
  1. package/css/index-full-carbon.css +570 -80
  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 +942 -23
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +3 -3
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +569 -79
  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 +570 -80
  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/AddSelect/AddSelect.js +0 -3
  18. package/es/components/AddSelect/AddSelectBody.js +20 -3
  19. package/es/components/AddSelect/AddSelectBreadcrumbs.js +11 -3
  20. package/es/components/AddSelect/AddSelectColumn.js +4 -3
  21. package/es/components/AddSelect/AddSelectFilter.js +4 -3
  22. package/es/components/AddSelect/AddSelectList.js +40 -14
  23. package/es/components/Card/Card.js +16 -6
  24. package/es/components/Card/CardFooter.js +3 -1
  25. package/es/components/Card/CardHeader.js +20 -1
  26. package/es/components/DataSpreadsheet/DataSpreadsheet.js +63 -11
  27. package/es/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  28. package/es/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  29. package/es/components/DataSpreadsheet/utils/handleCellDeletion.js +31 -0
  30. package/es/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  31. package/es/components/Datagrid/Datagrid/Datagrid.js +10 -38
  32. package/es/components/Datagrid/Datagrid/DatagridContent.js +127 -0
  33. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  34. package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +10 -3
  35. package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +12 -3
  36. package/es/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  37. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +5 -40
  38. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +35 -10
  39. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +61 -24
  40. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  41. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +60 -0
  42. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +1 -0
  43. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +467 -0
  44. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +1 -0
  45. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +112 -0
  46. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +27 -0
  47. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +1 -0
  48. package/es/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +39 -0
  49. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +19 -0
  50. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +263 -0
  51. package/es/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +66 -0
  52. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  53. package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  54. package/es/components/Datagrid/index.js +3 -1
  55. package/es/components/Datagrid/useActionsColumn.js +28 -12
  56. package/es/components/Datagrid/useColumnOrder.js +8 -0
  57. package/es/components/Datagrid/useCustomizeColumns.js +5 -0
  58. package/es/components/Datagrid/useDisableSelectRows.js +6 -2
  59. package/es/components/Datagrid/useExpandedRow.js +0 -1
  60. package/es/components/Datagrid/useInlineEdit.js +71 -0
  61. package/es/components/Datagrid/useNestedRowExpander.js +42 -0
  62. package/es/components/Datagrid/useNestedRows.js +2 -2
  63. package/es/components/Datagrid/useRowSize.js +17 -6
  64. package/es/components/Datagrid/useSelectAllToggle.js +17 -4
  65. package/es/components/Datagrid/useSelectRows.js +12 -2
  66. package/es/components/Datagrid/useStickyColumn.js +11 -0
  67. package/es/components/Datagrid/utils/DatagridActions.js +121 -0
  68. package/es/components/Datagrid/utils/DatagridPagination.js +33 -0
  69. package/es/components/Datagrid/utils/Wrapper.js +21 -0
  70. package/es/components/Datagrid/utils/getArgTypes.js +85 -0
  71. package/es/components/Datagrid/utils/getInlineEditColumns.js +121 -0
  72. package/es/components/Datagrid/utils/makeData.js +17 -1
  73. package/es/components/ImportModal/ImportModal.js +2 -2
  74. package/es/components/InlineEdit/InlineEdit.js +4 -2
  75. package/es/components/ProductiveCard/ProductiveCard.js +5 -0
  76. package/es/components/index.js +1 -1
  77. package/es/global/js/hooks/useClickOutside.js +1 -1
  78. package/es/global/js/package-settings.js +3 -3
  79. package/es/global/js/utils/rangeWithCallback.js +13 -0
  80. package/es/global/js/utils/story-helper.js +5 -1
  81. package/es/global/js/utils/uuidv4.spec.js +4 -0
  82. package/lib/components/AddSelect/AddSelect.js +0 -4
  83. package/lib/components/AddSelect/AddSelectBody.js +20 -3
  84. package/lib/components/AddSelect/AddSelectBreadcrumbs.js +14 -3
  85. package/lib/components/AddSelect/AddSelectColumn.js +3 -2
  86. package/lib/components/AddSelect/AddSelectFilter.js +3 -2
  87. package/lib/components/AddSelect/AddSelectList.js +39 -13
  88. package/lib/components/Card/Card.js +16 -6
  89. package/lib/components/Card/CardFooter.js +3 -1
  90. package/lib/components/Card/CardHeader.js +21 -1
  91. package/lib/components/DataSpreadsheet/DataSpreadsheet.js +63 -10
  92. package/lib/components/DataSpreadsheet/DataSpreadsheetBody.js +2 -1
  93. package/lib/components/DataSpreadsheet/DataSpreadsheetHeader.js +7 -0
  94. package/lib/components/DataSpreadsheet/utils/handleCellDeletion.js +42 -0
  95. package/lib/components/DataSpreadsheet/utils/handleMultipleKeys.js +1 -1
  96. package/lib/components/Datagrid/Datagrid/Datagrid.js +12 -45
  97. package/lib/components/Datagrid/Datagrid/DatagridContent.js +160 -0
  98. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +9 -1
  99. package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -3
  100. package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +14 -3
  101. package/lib/components/Datagrid/Datagrid/DraggableElement.js +5 -1
  102. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Actions.js +12 -41
  103. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +47 -25
  104. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsModal.js +59 -23
  105. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ModalWrapper.js +3 -2
  106. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/InlineEditButton.js +76 -0
  107. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditButton/index.js +13 -0
  108. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/InlineEditCell.js +491 -0
  109. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditCell/index.js +13 -0
  110. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/InlineEditContext.js +129 -0
  111. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/getCellIdAsObject.js +36 -0
  112. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/index.js +19 -0
  113. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/InlineEditContext/returnUpdatedActiveCell.js +45 -0
  114. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridFocus.js +28 -0
  115. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleGridKeyPress.js +272 -0
  116. package/lib/components/Datagrid/Datagrid/addons/InlineEdit/handleMultipleKeys.js +78 -0
  117. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +6 -5
  118. package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeRadioGroup.js +1 -2
  119. package/lib/components/Datagrid/index.js +17 -1
  120. package/lib/components/Datagrid/useActionsColumn.js +28 -13
  121. package/lib/components/Datagrid/useColumnOrder.js +17 -0
  122. package/lib/components/Datagrid/useCustomizeColumns.js +5 -0
  123. package/lib/components/Datagrid/useDisableSelectRows.js +6 -2
  124. package/lib/components/Datagrid/useExpandedRow.js +0 -1
  125. package/lib/components/Datagrid/useInlineEdit.js +85 -0
  126. package/lib/components/Datagrid/useNestedRowExpander.js +57 -0
  127. package/lib/components/Datagrid/useNestedRows.js +3 -3
  128. package/lib/components/Datagrid/useRowSize.js +18 -13
  129. package/lib/components/Datagrid/useSelectAllToggle.js +18 -4
  130. package/lib/components/Datagrid/useSelectRows.js +12 -2
  131. package/lib/components/Datagrid/useStickyColumn.js +11 -0
  132. package/lib/components/Datagrid/utils/DatagridActions.js +139 -0
  133. package/lib/components/Datagrid/utils/DatagridPagination.js +46 -0
  134. package/lib/components/Datagrid/utils/Wrapper.js +33 -0
  135. package/lib/components/Datagrid/utils/getArgTypes.js +93 -0
  136. package/lib/components/Datagrid/utils/getInlineEditColumns.js +133 -0
  137. package/lib/components/Datagrid/utils/makeData.js +17 -1
  138. package/lib/components/ImportModal/ImportModal.js +2 -2
  139. package/lib/components/InlineEdit/InlineEdit.js +4 -2
  140. package/lib/components/ProductiveCard/ProductiveCard.js +5 -0
  141. package/lib/components/index.js +12 -0
  142. package/lib/global/js/hooks/useClickOutside.js +1 -1
  143. package/lib/global/js/package-settings.js +3 -3
  144. package/lib/global/js/utils/rangeWithCallback.js +22 -0
  145. package/lib/global/js/utils/story-helper.js +5 -1
  146. package/lib/global/js/utils/uuidv4.spec.js +4 -0
  147. package/package.json +13 -13
  148. package/scss/components/AddSelect/_add-select.scss +126 -28
  149. package/scss/components/Card/_card.scss +1 -0
  150. package/scss/components/Cascade/_cascade.scss +1 -1
  151. package/scss/components/CreateTearsheet/_create-tearsheet.scss +1 -0
  152. package/scss/components/DataSpreadsheet/_data-spreadsheet.scss +18 -1
  153. package/scss/components/Datagrid/_storybook-styles.scss +1 -1
  154. package/scss/components/Datagrid/styles/_datagrid.scss +27 -4
  155. package/scss/components/Datagrid/styles/_draggableElement.scss +26 -9
  156. package/scss/components/Datagrid/styles/_index.scss +1 -0
  157. package/scss/components/Datagrid/styles/_useActionsColumn.scss +12 -0
  158. package/scss/components/Datagrid/styles/_useExpandedRow.scss +30 -0
  159. package/scss/components/Datagrid/styles/_useInlineEdit.scss +211 -0
  160. package/scss/components/Datagrid/styles/_useNestedRows.scss +15 -1
  161. package/scss/components/Datagrid/styles/_useStickyColumn.scss +30 -2
  162. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsModal.scss +44 -6
  163. package/scss/components/NotificationsPanel/_notifications-panel.scss +5 -6
  164. package/scss/components/ProductiveCard/_productive-card.scss +39 -0
  165. package/scss/components/RemoveModal/_remove-modal.scss +0 -4
  166. package/scss/components/SidePanel/_side-panel.scss +4 -6
  167. package/scss/components/_index-released-only.scss +1 -0
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
3
  var _excluded = ["datagridState"];
5
4
 
@@ -11,21 +10,15 @@ var _excluded = ["datagridState"];
11
10
  */
12
11
  import React from 'react';
13
12
  import PropTypes from 'prop-types';
14
- import { DataTable } from 'carbon-components-react';
15
13
  import cx from 'classnames';
16
- import DatagridHead from './DatagridHead';
17
- import DatagridBody from './DatagridBody';
18
- import DatagridToolbar from './DatagridToolbar';
19
14
  import { getDevtoolsProps } from '../../../global/js/utils/devtools';
20
15
  import { pkg } from '../../../settings';
21
16
  import pconsole from '../../../global/js/utils/pconsole';
17
+ import { InlineEditProvider } from './addons/InlineEdit/InlineEditContext';
18
+ import { DatagridContent } from './DatagridContent';
22
19
  var blockClass = "".concat(pkg.prefix, "--datagrid");
23
20
  var componentName = 'Datagrid';
24
- var TableContainer = DataTable.TableContainer,
25
- Table = DataTable.Table;
26
21
  export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
27
- var _getTableProps;
28
-
29
22
  var datagridState = _ref.datagridState,
30
23
  rest = _objectWithoutProperties(_ref, _excluded);
31
24
 
@@ -34,45 +27,24 @@ export var Datagrid = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
34
27
  return null;
35
28
  }
36
29
 
37
- var _datagridState$getTab = datagridState.getTableProps,
38
- getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
39
- withVirtualScroll = datagridState.withVirtualScroll,
30
+ var withVirtualScroll = datagridState.withVirtualScroll,
40
31
  DatagridPagination = datagridState.DatagridPagination,
41
32
  isFetching = datagridState.isFetching,
42
33
  tableId = datagridState.tableId,
43
- CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
44
34
  leftPanel = datagridState.leftPanel,
45
- fullHeightDatagrid = datagridState.fullHeightDatagrid,
46
- _datagridState$vertic = datagridState.verticalAlign,
47
- verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
48
- variableRowHeight = datagridState.variableRowHeight,
49
- className = datagridState.className,
50
- gridTitle = datagridState.gridTitle,
51
- gridDescription = datagridState.gridDescription,
52
- useDenseHeader = datagridState.useDenseHeader;
35
+ className = datagridState.className;
53
36
  var rows = DatagridPagination && datagridState.page || datagridState.rows;
54
- var dataGrid = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
55
- className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : ''),
56
- title: gridTitle,
57
- description: gridDescription
58
- }, /*#__PURE__*/React.createElement(DatagridToolbar, datagridState), /*#__PURE__*/React.createElement("div", {
59
- className: "".concat(blockClass, "__table-container")
60
- }, leftPanel && leftPanel.isOpen && /*#__PURE__*/React.createElement("div", {
61
- className: "".concat(blockClass, "__datagridLeftPanel")
62
- }, leftPanel.panelContent), /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), {
63
- className: cx(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className)
64
- }), /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
65
- rows: rows
66
- }))))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
67
- instance: datagridState
68
- }));
69
- return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
37
+ return /*#__PURE__*/React.createElement(InlineEditProvider, null, /*#__PURE__*/React.createElement("div", _extends({}, rest, {
70
38
  id: tableId,
71
39
  ref: ref,
72
40
  className: cx(className, blockClass, withVirtualScroll ? "".concat(blockClass, "__datagridWrap") : "".concat(blockClass, "__datagridWrap-simple"), !isFetching && rows.length === 0 ? "".concat(blockClass, "__empty-state") : '')
73
41
  }, getDevtoolsProps(componentName)), leftPanel && /*#__PURE__*/React.createElement("div", {
74
42
  className: "".concat(blockClass, "__datagridWithPanel ").concat(blockClass, "__displayFlex ").concat(blockClass, "__leftPanel-position")
75
- }, dataGrid), leftPanel === undefined && dataGrid);
43
+ }, /*#__PURE__*/React.createElement(DatagridContent, {
44
+ datagridState: datagridState
45
+ })), leftPanel === undefined && /*#__PURE__*/React.createElement(DatagridContent, {
46
+ datagridState: datagridState
47
+ })));
76
48
  }); // Return a placeholder if not released and not enabled by feature flag
77
49
 
78
50
  Datagrid = pkg.checkComponentEnabled(Datagrid, componentName); // The display name of the component, used by React. Note that displayName
@@ -0,0 +1,127 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
+ import React, { useContext, useRef } from 'react';
4
+ import cx from 'classnames';
5
+ import PropTypes from 'prop-types';
6
+ import { DataTable } from 'carbon-components-react';
7
+ import DatagridHead from './DatagridHead';
8
+ import DatagridBody from './DatagridBody';
9
+ import DatagridToolbar from './DatagridToolbar';
10
+ import { handleGridKeyPress } from './addons/InlineEdit/handleGridKeyPress';
11
+ import { pkg } from '../../../settings';
12
+ import { InlineEditContext } from './addons/InlineEdit/InlineEditContext';
13
+ import { handleGridFocus } from './addons/InlineEdit/handleGridFocus';
14
+ import { useClickOutside } from '../../../global/js/hooks';
15
+ import { useMultipleKeyTracking } from '../../DataSpreadsheet/hooks';
16
+ var TableContainer = DataTable.TableContainer,
17
+ Table = DataTable.Table;
18
+ var blockClass = "".concat(pkg.prefix, "--datagrid");
19
+ export var DatagridContent = function DatagridContent(_ref) {
20
+ var _getTableProps;
21
+
22
+ var datagridState = _ref.datagridState;
23
+
24
+ var _useContext = useContext(InlineEditContext),
25
+ state = _useContext.state,
26
+ dispatch = _useContext.dispatch;
27
+
28
+ var activeCellId = state.activeCellId;
29
+ var _datagridState$getTab = datagridState.getTableProps,
30
+ getTableProps = _datagridState$getTab === void 0 ? function () {} : _datagridState$getTab,
31
+ withVirtualScroll = datagridState.withVirtualScroll,
32
+ DatagridPagination = datagridState.DatagridPagination,
33
+ isFetching = datagridState.isFetching,
34
+ CustomizeColumnsModal = datagridState.CustomizeColumnsModal,
35
+ leftPanel = datagridState.leftPanel,
36
+ fullHeightDatagrid = datagridState.fullHeightDatagrid,
37
+ _datagridState$vertic = datagridState.verticalAlign,
38
+ verticalAlign = _datagridState$vertic === void 0 ? 'center' : _datagridState$vertic,
39
+ variableRowHeight = datagridState.variableRowHeight,
40
+ gridTitle = datagridState.gridTitle,
41
+ gridDescription = datagridState.gridDescription,
42
+ useDenseHeader = datagridState.useDenseHeader,
43
+ withInlineEdit = datagridState.withInlineEdit;
44
+ var rows = DatagridPagination && datagridState.page || datagridState.rows;
45
+ var gridActive = state.gridActive,
46
+ editId = state.editId;
47
+ var gridAreaRef = useRef();
48
+ var multiKeyTrackingRef = useRef();
49
+ useClickOutside(gridAreaRef, function (target) {
50
+ if (!withInlineEdit) {
51
+ return;
52
+ } // We return from here if we find a parent element with the selector below
53
+ // because that element was initially part of the grid area but was removed
54
+ // and swapped out with an input, i.e. text, number, selection, or date picker
55
+
56
+
57
+ if (target.closest(".".concat(blockClass, "__inline-edit-button")) || target.closest(".".concat(blockClass, "__inline-edit--select"))) {
58
+ return;
59
+ }
60
+
61
+ dispatch({
62
+ type: 'REMOVE_GRID_ACTIVE_FOCUS',
63
+ payload: activeCellId
64
+ });
65
+ });
66
+
67
+ var _useMultipleKeyTracki = useMultipleKeyTracking({
68
+ ref: multiKeyTrackingRef,
69
+ containerHasFocus: gridActive,
70
+ isEditing: !!editId
71
+ }),
72
+ keysPressedList = _useMultipleKeyTracki.keysPressedList,
73
+ usingMac = _useMultipleKeyTracki.usingMac;
74
+
75
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableContainer, {
76
+ className: cx("".concat(blockClass, "__grid-container"), withVirtualScroll || fullHeightDatagrid ? "".concat(blockClass, "__full-height") : '', DatagridPagination ? "".concat(blockClass, "__with-pagination") : '', useDenseHeader ? "".concat(blockClass, "__dense-header") : ''),
77
+ title: gridTitle,
78
+ description: gridDescription
79
+ }, /*#__PURE__*/React.createElement(DatagridToolbar, datagridState), /*#__PURE__*/React.createElement("div", {
80
+ className: "".concat(blockClass, "__table-container"),
81
+ ref: gridAreaRef
82
+ }, leftPanel && leftPanel.isOpen && /*#__PURE__*/React.createElement("div", {
83
+ className: "".concat(blockClass, "__datagridLeftPanel")
84
+ }, leftPanel.panelContent), /*#__PURE__*/React.createElement("div", {
85
+ ref: multiKeyTrackingRef
86
+ }, /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), {
87
+ className: cx(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), _defineProperty({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), _defineProperty({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), _defineProperty({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
88
+ role: withInlineEdit && 'grid',
89
+ tabIndex: withInlineEdit && 0,
90
+ onKeyDown: withInlineEdit ? function (event) {
91
+ return handleGridKeyPress({
92
+ event: event,
93
+ dispatch: dispatch,
94
+ state: state,
95
+ instance: datagridState,
96
+ keysPressedList: keysPressedList,
97
+ usingMac: usingMac
98
+ });
99
+ } : null,
100
+ onFocus: withInlineEdit ? function () {
101
+ return handleGridFocus(state, dispatch);
102
+ } : null
103
+ }), /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
104
+ rows: rows
105
+ })))))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && DatagridPagination(datagridState), CustomizeColumnsModal && /*#__PURE__*/React.createElement(CustomizeColumnsModal, {
106
+ instance: datagridState
107
+ }));
108
+ };
109
+ DatagridContent.propTypes = {
110
+ datagridState: PropTypes.shape({
111
+ getTableProps: PropTypes.func,
112
+ withVirtualScroll: PropTypes.bool,
113
+ DatagridPagination: PropTypes.oneOfType([PropTypes.element, PropTypes.func]),
114
+ CustomizeColumnsModal: PropTypes.element,
115
+ isFetching: PropTypes.bool,
116
+ leftPanel: PropTypes.object,
117
+ fullHeightDatagrid: PropTypes.bool,
118
+ variableRowHeight: PropTypes.bool,
119
+ useDenseHeader: PropTypes.bool,
120
+ withInlineEdit: PropTypes.bool,
121
+ verticalAlign: PropTypes.string,
122
+ gridTitle: PropTypes.node,
123
+ gridDescription: PropTypes.node,
124
+ page: PropTypes.arrayOf(PropTypes.object),
125
+ rows: PropTypes.arrayOf(PropTypes.object)
126
+ })
127
+ };
@@ -13,13 +13,21 @@ var DatagridExpandedRow = function DatagridExpandedRow(PreviousRowRenderer, Expa
13
13
  return function (datagridState) {
14
14
  var row = datagridState.row;
15
15
 
16
+ var _ref = row || {},
17
+ expandedContentHeight = _ref.expandedContentHeight;
18
+
16
19
  if (!row.isExpanded) {
17
20
  return PreviousRowRenderer(datagridState);
18
21
  }
19
22
 
20
23
  return /*#__PURE__*/React.createElement("div", {
21
24
  className: "".concat(blockClass, "__expanded-row")
22
- }, PreviousRowRenderer(datagridState), ExpandedRowContentComponent(datagridState));
25
+ }, PreviousRowRenderer(datagridState), /*#__PURE__*/React.createElement("div", {
26
+ className: "".concat(blockClass, "__expanded-row-content"),
27
+ style: {
28
+ height: expandedContentHeight ? expandedContentHeight : null
29
+ }
30
+ }, ExpandedRowContentComponent(datagridState)));
23
31
  };
24
32
  };
25
33
 
@@ -1,5 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  var _excluded = ["onChange"];
4
5
 
5
6
  /*
@@ -12,21 +13,27 @@ var _excluded = ["onChange"];
12
13
  // @flow
13
14
  import React from 'react';
14
15
  import { DataTable } from 'carbon-components-react';
16
+ import cx from 'classnames';
15
17
  import { pkg } from '../../../settings';
16
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
17
19
 
18
20
  var SelectAll = function SelectAll(datagridState) {
21
+ var _columns$;
22
+
19
23
  var isFetching = datagridState.isFetching,
20
24
  getToggleAllRowsSelectedProps = datagridState.getToggleAllRowsSelectedProps,
21
25
  getToggleAllPageRowsSelectedProps = datagridState.getToggleAllPageRowsSelectedProps,
22
26
  tableId = datagridState.tableId,
23
27
  hideSelectAll = datagridState.hideSelectAll,
24
28
  DatagridPagination = datagridState.DatagridPagination,
25
- radio = datagridState.radio;
29
+ radio = datagridState.radio,
30
+ columns = datagridState.columns,
31
+ withStickyColumn = datagridState.withStickyColumn;
32
+ var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
26
33
 
27
34
  if (hideSelectAll || radio) {
28
35
  return /*#__PURE__*/React.createElement("div", {
29
- className: "".concat(blockClass, "__head-hidden-select-all")
36
+ className: cx("".concat(blockClass, "__head-hidden-select-all"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
30
37
  });
31
38
  }
32
39
 
@@ -37,7 +44,7 @@ var SelectAll = function SelectAll(datagridState) {
37
44
  selectProps = _objectWithoutProperties(_getProps, _excluded);
38
45
 
39
46
  return /*#__PURE__*/React.createElement("div", {
40
- className: "".concat(blockClass, "__head-select-all ").concat(blockClass, "__checkbox-cell")
47
+ className: cx("".concat(blockClass, "__head-select-all"), "".concat(blockClass, "__checkbox-cell"), _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft))
41
48
  }, /*#__PURE__*/React.createElement(TableSelectAll, _extends({}, selectProps, {
42
49
  name: "".concat(tableId, "-select-all-checkbox-name"),
43
50
  onSelect: onChange,
@@ -1,4 +1,5 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
5
  var _excluded = ["onChange"];
@@ -13,6 +14,7 @@ var _excluded = ["onChange"];
13
14
  // @flow
14
15
  import React, { useEffect, useState } from 'react';
15
16
  import PropTypes from 'prop-types';
17
+ import cx from 'classnames';
16
18
  import { OverflowMenu, OverflowMenuItem, Checkbox } from 'carbon-components-react';
17
19
  import { CaretDown16 } from '@carbon/icons-react';
18
20
  import { pkg } from '../../../settings'; // cspell:words columnheader
@@ -22,6 +24,8 @@ var SELECT_ALL_PAGE_ROWS = 'pageRows';
22
24
  var SELECT_ALL_ROWS = 'allRows';
23
25
 
24
26
  var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
27
+ var _columns$;
28
+
25
29
  var tableId = _ref.tableId,
26
30
  isFetching = _ref.isFetching,
27
31
  isAllRowsSelected = _ref.isAllRowsSelected,
@@ -31,7 +35,9 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
31
35
  _ref$allPageRowsLabel = _ref.allPageRowsLabel,
32
36
  allPageRowsLabel = _ref$allPageRowsLabel === void 0 ? 'Select all on page' : _ref$allPageRowsLabel,
33
37
  _ref$allRowsLabel = _ref.allRowsLabel,
34
- allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel;
38
+ allRowsLabel = _ref$allRowsLabel === void 0 ? 'Select all' : _ref$allRowsLabel,
39
+ columns = _ref.columns,
40
+ withStickyColumn = _ref.withStickyColumn;
35
41
 
36
42
  var _useState = useState(SELECT_ALL_PAGE_ROWS),
37
43
  _useState2 = _slicedToArray(_useState, 2),
@@ -60,10 +66,11 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
60
66
  selectProps = _objectWithoutProperties(_getProps, _excluded);
61
67
 
62
68
  var disabled = isFetching || selectProps.disabled;
69
+ var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
63
70
  return /*#__PURE__*/React.createElement("th", {
64
71
  role: "columnheader",
65
72
  scope: "col",
66
- className: "".concat(blockClass, "__select-all-toggle-on")
73
+ className: cx("".concat(blockClass, "__select-all-toggle-on"), _defineProperty({}, "".concat(blockClass, "__select-all-sticky-left"), isFirstColumnStickyLeft))
67
74
  }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Checkbox, _extends({}, selectProps, {
68
75
  name: "".concat(tableId, "-select-all-checkbox-name"),
69
76
  onClick: function onClick(e) {
@@ -111,11 +118,13 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
111
118
  SelectAllWithToggle.propTypes = {
112
119
  allPageRowsLabel: PropTypes.string,
113
120
  allRowsLabel: PropTypes.string,
121
+ columns: PropTypes.arrayOf(PropTypes.object),
114
122
  getToggleAllPageRowsSelectedProps: PropTypes.func.isRequired,
115
123
  getToggleAllRowsSelectedProps: PropTypes.func.isRequired,
116
124
  isAllRowsSelected: PropTypes.bool.isRequired,
117
125
  isFetching: PropTypes.bool,
118
126
  selectAllToggle: PropTypes.object,
119
- tableId: PropTypes.string.isRequired
127
+ tableId: PropTypes.string.isRequired,
128
+ withStickyColumn: PropTypes.bool
120
129
  };
121
130
  export default SelectAllWithToggle;
@@ -22,6 +22,8 @@ var blockClass = "".concat(pkg.prefix, "--datagrid");
22
22
  var DRAG_TYPE = "".concat(blockClass, "__shared-ui-draggable-element");
23
23
 
24
24
  var DraggableElement = function DraggableElement(_ref) {
25
+ var _cx;
26
+
25
27
  var id = _ref.id,
26
28
  index = _ref.index,
27
29
  listData = _ref.listData,
@@ -33,6 +35,7 @@ var DraggableElement = function DraggableElement(_ref) {
33
35
  onArrowKeyDown = _ref.onArrowKeyDown,
34
36
  isFocused = _ref.isFocused,
35
37
  moveElement = _ref.moveElement,
38
+ selected = _ref.selected,
36
39
  _ref$positionLabel = _ref.positionLabel,
37
40
  positionLabel = _ref$positionLabel === void 0 ? 'Current position {index} of {total}' : _ref$positionLabel,
38
41
  _ref$grabbedLabel = _ref.grabbedLabel,
@@ -119,7 +122,7 @@ var DraggableElement = function DraggableElement(_ref) {
119
122
  }, "".concat(blockClass, "__draggable-handleStyle"))
120
123
  }, /*#__PURE__*/React.createElement(Draggable16, null)), children);
121
124
  return /*#__PURE__*/React.createElement("li", {
122
- className: cx(_defineProperty({}, "".concat(blockClass, "__draggable-handleHolder-isOver"), isOver && !disabled), _defineProperty({}, "".concat(blockClass, "__wkc-draggable-handleHolder--grabbed"), isGrabbed), "".concat(blockClass, "__draggable-handleHolder")),
125
+ className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-isOver"), isOver && !disabled), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-grabbed"), isGrabbed), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder-selected"), selected), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder"), !selected), _cx)),
123
126
  ref: ref,
124
127
  "aria-selected": isFocused,
125
128
  role: "option",
@@ -173,6 +176,7 @@ DraggableElement.propTypes = {
173
176
  onArrowKeyDown: PropTypes.func.isRequired,
174
177
  onGrab: PropTypes.func.isRequired,
175
178
  positionLabel: PropTypes.string,
179
+ selected: PropTypes.bool,
176
180
  type: PropTypes.string.isRequired
177
181
  };
178
182
  export default DraggableElement;
@@ -1,9 +1,3 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
-
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
-
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
-
7
1
  // @flow
8
2
 
9
3
  /*
@@ -13,28 +7,18 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
13
7
  * US Government Users Restricted Rights - Use, duplication or disclosure
14
8
  * restricted by GSA ADP Schedule Contract with IBM Corp.
15
9
  */
16
- import { Reset16 } from '@carbon/icons-react';
17
10
  import PropTypes from 'prop-types';
18
- import { Button, Search } from 'carbon-components-react';
11
+ import { Search } from 'carbon-components-react';
19
12
  import * as React from 'react';
20
- import keyBy from 'lodash/keyBy';
21
13
  import { pkg } from '../../../../../settings';
22
- import { isColumnVisible } from './common';
23
14
  var blockClass = "".concat(pkg.prefix, "--datagrid");
24
15
 
25
16
  var Actions = function Actions(_ref) {
26
17
  var searchText = _ref.searchText,
27
- columns = _ref.columns,
28
- originalColumnDefinitions = _ref.originalColumnDefinitions,
29
- setColumnsObject = _ref.setColumnsObject,
30
18
  setSearchText = _ref.setSearchText,
31
- _ref$findColumnPlaceh = _ref.findColumnPlaceholderLabel,
32
- findColumnPlaceholderLabel = _ref$findColumnPlaceh === void 0 ? 'Find column' : _ref$findColumnPlaceh,
33
- _ref$resetToDefaultLa = _ref.resetToDefaultLabel,
34
- resetToDefaultLabel = _ref$resetToDefaultLa === void 0 ? 'Reset to default' : _ref$resetToDefaultLa;
19
+ findColumnPlaceholderLabel = _ref.findColumnPlaceholderLabel;
35
20
  return /*#__PURE__*/React.createElement("div", {
36
- className: "".concat(blockClass, "__customize-columns-modal--actions"),
37
- "test-id": "".concat(blockClass, "__customize-columns-modal--actions")
21
+ className: "".concat(blockClass, "__customize-columns-modal--actions")
38
22
  }, /*#__PURE__*/React.createElement(Search, {
39
23
  placeholder: findColumnPlaceholderLabel,
40
24
  value: searchText,
@@ -43,27 +27,8 @@ var Actions = function Actions(_ref) {
43
27
  onChange: function onChange(e) {
44
28
  // TODO: is it performant?
45
29
  setSearchText(e.target.value);
46
- },
47
- "test-id": "".concat(blockClass, "__customize-columns-modal--search")
48
- }), /*#__PURE__*/React.createElement(Button, {
49
- onClick: function onClick() {
50
- var reset = resetToOriginal(columns, originalColumnDefinitions);
51
- setColumnsObject(reset);
52
- },
53
- size: "sm",
54
- kind: "ghost",
55
- renderIcon: Reset16,
56
- "test-id": "".concat(blockClass, "__customize-columns-modal--reset")
57
- }, resetToDefaultLabel));
58
- };
59
-
60
- var resetToOriginal = function resetToOriginal(columnDefinitions, originalColumnDefinitions) {
61
- var keyedDefs = keyBy(columnDefinitions, 'id');
62
- return originalColumnDefinitions.map(function (colDef) {
63
- return _objectSpread(_objectSpread({}, keyedDefs[colDef.id]), {}, {
64
- isVisible: isColumnVisible(colDef)
65
- });
66
- });
30
+ }
31
+ }));
67
32
  };
68
33
 
69
34
  Actions.propTypes = {
@@ -1,3 +1,4 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  // @flow
3
4
 
@@ -8,7 +9,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
8
9
  * US Government Users Restricted Rights - Use, duplication or disclosure
9
10
  * restricted by GSA ADP Schedule Contract with IBM Corp.
10
11
  */
11
- import * as React from 'react';
12
+ import React from 'react';
12
13
  import PropTypes from 'prop-types';
13
14
  import { DndProvider } from 'react-dnd';
14
15
  import { HTML5Backend } from 'react-dnd-html5-backend';
@@ -17,6 +18,7 @@ import update from 'immutability-helper';
17
18
  import { pkg } from '../../../../../settings';
18
19
  import DraggableElement from '../../DraggableElement';
19
20
  import { isColumnVisible } from './common';
21
+ import classNames from 'classnames';
20
22
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
23
 
22
24
  var getNextIndex = function getNextIndex(array, currentIndex, key) {
@@ -34,14 +36,16 @@ var getNextIndex = function getNextIndex(array, currentIndex, key) {
34
36
  };
35
37
 
36
38
  var Columns = function Columns(_ref) {
37
- var filterString = _ref.filterString,
39
+ var _classNames;
40
+
41
+ var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
42
+ filterString = _ref.filterString,
38
43
  columns = _ref.columns,
39
44
  setColumnsObject = _ref.setColumnsObject,
40
45
  onSelectColumn = _ref.onSelectColumn,
41
- _ref$instructionsLabe = _ref.instructionsLabel,
42
- instructionsLabel = _ref$instructionsLabe === void 0 ? 'Press space bar to toggle drag drop mode, use arrow keys to move selected elements.' : _ref$instructionsLabe,
43
- _ref$disabledInstruct = _ref.disabledInstructionsLabel,
44
- disabledInstructionsLabel = _ref$disabledInstruct === void 0 ? 'Reordering columns are disabled because they are filtered currently.' : _ref$disabledInstruct;
46
+ assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
47
+ assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
48
+ selectAllLabel = _ref.selectAllLabel;
45
49
 
46
50
  var _React$useState = React.useState(''),
47
51
  _React$useState2 = _slicedToArray(_React$useState, 2),
@@ -88,7 +92,21 @@ var Columns = function Columns(_ref) {
88
92
  }, ariaRegionText), /*#__PURE__*/React.createElement("span", {
89
93
  id: "".concat(blockClass, "__customize-columns--instructions"),
90
94
  className: "".concat(blockClass, "__shared-ui--assistive-text")
91
- }, filterString.length === 0 ? instructionsLabel : disabledInstructionsLabel), columns.filter(function (colDef) {
95
+ }, filterString.length === 0 ? assistiveTextInstructionsLabel : assistiveTextDisabledInstructionsLabel), /*#__PURE__*/React.createElement("div", {
96
+ id: "".concat(blockClass, "__customize-columns-select-all"),
97
+ className: classNames((_classNames = {}, _defineProperty(_classNames, "".concat(blockClass, "__customize-columns-select-all"), getVisibleColumnsCount() === 0), _defineProperty(_classNames, "".concat(blockClass, "__customize-columns-select-all-selected"), getVisibleColumnsCount() > 0), _classNames)),
98
+ selected: getVisibleColumnsCount() > 0
99
+ }, /*#__PURE__*/React.createElement(Checkbox, {
100
+ wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
101
+ checked: getVisibleColumnsCount() === columns.length,
102
+ empty: !!getVisibleColumnsCount() === 0,
103
+ indeterminate: getVisibleColumnsCount() < columns.length && getVisibleColumnsCount() > 0,
104
+ onChange: function onChange() {
105
+ onSelectColumn(columns, getVisibleColumnsCount() !== columns.length);
106
+ },
107
+ id: "".concat(blockClass, "__customization-column-select-all"),
108
+ labelText: selectAllLabel
109
+ })), columns.filter(function (colDef) {
92
110
  return filterString.length === 0 || colDef.Header.props.title.toLowerCase().includes(filterString);
93
111
  }).map(function (colDef, i) {
94
112
  return /*#__PURE__*/React.createElement(DraggableElement, {
@@ -117,24 +135,31 @@ var Columns = function Columns(_ref) {
117
135
  });
118
136
  }
119
137
  }
120
- }
138
+ },
139
+ selected: isColumnVisible(colDef)
121
140
  }, /*#__PURE__*/React.createElement(Checkbox, {
122
- wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox"),
141
+ wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
123
142
  checked: isColumnVisible(colDef),
124
143
  onChange: onSelectColumn.bind(null, colDef),
125
144
  id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
126
145
  labelText: colDef.Header.props.title,
127
- title: colDef.Header.props.title
146
+ title: colDef.Header.props.title,
147
+ className: "".concat(blockClass, "__customize-columns-checkbox")
128
148
  }));
129
149
  }))));
130
150
  };
131
151
 
132
152
  Columns.propTypes = {
153
+ assistiveTextDisabledInstructionsLabel: PropTypes.string,
154
+ assistiveTextInstructionsLabel: PropTypes.string,
133
155
  columns: PropTypes.array.isRequired,
134
156
  disabledInstructionsLabel: PropTypes.string,
135
157
  filterString: PropTypes.string.isRequired,
158
+ getVisibleColumnsCount: PropTypes.func.isRequired,
136
159
  instructionsLabel: PropTypes.string,
137
160
  onSelectColumn: PropTypes.func.isRequired,
161
+ selectAllLabel: PropTypes.string,
162
+ setColumnStatus: PropTypes.func,
138
163
  setColumnsObject: PropTypes.func.isRequired
139
164
  };
140
165
  export default Columns;