@carbon/ibm-products 2.10.2 → 2.11.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. package/README.md +7 -0
  2. package/css/index-full-carbon.css +71 -26
  3. package/css/index-full-carbon.css.map +1 -1
  4. package/css/index-full-carbon.min.css +3 -3
  5. package/css/index-full-carbon.min.css.map +1 -1
  6. package/css/index-without-carbon-released-only.css +1 -0
  7. package/css/index-without-carbon-released-only.css.map +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +71 -26
  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 +68 -25
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +2 -2
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/APIKeyModal/APIKeyModal.js +10 -3
  18. package/es/components/AboutModal/AboutModal.js +10 -3
  19. package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
  20. package/es/components/CreateModal/CreateModal.js +10 -3
  21. package/es/components/Datagrid/Datagrid/DatagridContent.js +9 -7
  22. package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +3 -2
  23. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
  24. package/es/components/Datagrid/Datagrid/DatagridRow.js +47 -40
  25. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
  26. package/es/components/Datagrid/Datagrid/DraggableElement.js +36 -132
  27. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +17 -49
  28. package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +125 -40
  29. package/es/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
  30. package/es/components/Datagrid/useExpandedRow.js +1 -1
  31. package/es/components/Datagrid/useNestedRowExpander.js +22 -9
  32. package/es/components/Datagrid/useRowExpander.js +22 -9
  33. package/es/components/Datagrid/utils/DatagridActions.js +1 -1
  34. package/es/components/Datagrid/utils/DatagridPagination.js +1 -1
  35. package/es/components/Datagrid/utils/getArgTypes.js +12 -0
  36. package/es/components/EditTearsheet/EditTearsheet.js +47 -38
  37. package/es/components/EditTearsheet/EditTearsheetForm.js +6 -0
  38. package/es/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
  39. package/es/components/EmptyStates/EmptyState.js +1 -1
  40. package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  41. package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  42. package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  43. package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  44. package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  45. package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  46. package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -11
  47. package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -11
  48. package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
  49. package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
  50. package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
  51. package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
  52. package/es/components/ExportModal/ExportModal.js +10 -3
  53. package/es/components/ImportModal/ImportModal.js +10 -3
  54. package/es/components/RemoveModal/RemoveModal.js +10 -3
  55. package/es/components/TagSet/TagSet.js +5 -21
  56. package/es/components/TagSet/TagSetModal.js +7 -3
  57. package/es/components/Tearsheet/Tearsheet.js +2 -2
  58. package/es/components/Tearsheet/TearsheetNarrow.js +2 -2
  59. package/es/components/Tearsheet/TearsheetShell.js +14 -28
  60. package/es/global/decorators/sidePanelDecorator.js +7 -0
  61. package/es/global/js/hooks/usePortalTarget.js +30 -0
  62. package/es/global/js/hooks/useRetrieveFormTitles.js +20 -0
  63. package/es/global/js/hooks/useWindowScroll.js +5 -0
  64. package/es/global/js/package-settings.js +0 -1
  65. package/es/global/js/utils/getNodeTextContent.js +47 -0
  66. package/flags.js +6 -0
  67. package/lib/components/APIKeyModal/APIKeyModal.js +10 -3
  68. package/lib/components/AboutModal/AboutModal.js +10 -3
  69. package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
  70. package/lib/components/CreateModal/CreateModal.js +10 -3
  71. package/lib/components/Datagrid/Datagrid/DatagridContent.js +9 -7
  72. package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +2 -1
  73. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
  74. package/lib/components/Datagrid/Datagrid/DatagridRow.js +46 -41
  75. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +30 -37
  76. package/lib/components/Datagrid/Datagrid/DraggableElement.js +37 -137
  77. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +20 -49
  78. package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +130 -47
  79. package/lib/components/Datagrid/Extensions/ExpandableRow/ExpandableRow.docs-page.js +1 -1
  80. package/lib/components/Datagrid/useExpandedRow.js +1 -1
  81. package/lib/components/Datagrid/useNestedRowExpander.js +24 -9
  82. package/lib/components/Datagrid/useRowExpander.js +24 -9
  83. package/lib/components/Datagrid/utils/DatagridActions.js +1 -1
  84. package/lib/components/Datagrid/utils/DatagridPagination.js +1 -1
  85. package/lib/components/Datagrid/utils/getArgTypes.js +12 -0
  86. package/lib/components/EditTearsheet/EditTearsheet.js +47 -38
  87. package/lib/components/EditTearsheet/EditTearsheetForm.js +6 -0
  88. package/lib/components/EditTearsheet/preview-components/MultiFormEditTearsheet.js +6 -1
  89. package/lib/components/EmptyStates/EmptyState.js +1 -1
  90. package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
  91. package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
  92. package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
  93. package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
  94. package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
  95. package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
  96. package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -11
  97. package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -11
  98. package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
  99. package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
  100. package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
  101. package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
  102. package/lib/components/ExportModal/ExportModal.js +10 -3
  103. package/lib/components/ImportModal/ImportModal.js +10 -3
  104. package/lib/components/RemoveModal/RemoveModal.js +10 -3
  105. package/lib/components/TagSet/TagSet.js +5 -21
  106. package/lib/components/TagSet/TagSetModal.js +7 -3
  107. package/lib/components/Tearsheet/Tearsheet.js +2 -2
  108. package/lib/components/Tearsheet/TearsheetNarrow.js +2 -2
  109. package/lib/components/Tearsheet/TearsheetShell.js +14 -28
  110. package/lib/global/decorators/sidePanelDecorator.js +7 -0
  111. package/lib/global/js/hooks/usePortalTarget.js +38 -0
  112. package/lib/global/js/hooks/useRetrieveFormTitles.js +28 -0
  113. package/lib/global/js/hooks/useWindowScroll.js +6 -0
  114. package/lib/global/js/package-settings.js +0 -1
  115. package/lib/global/js/utils/getNodeTextContent.js +55 -0
  116. package/package.json +7 -3
  117. package/scss/components/ActionSet/_action-set.scss +2 -1
  118. package/scss/components/Datagrid/_datagrid.scss +9 -0
  119. package/scss/components/Datagrid/styles/_datagrid.scss +7 -6
  120. package/scss/components/Datagrid/styles/_draggableElement.scss +34 -16
  121. package/scss/components/Datagrid/styles/_useExpandedRow.scss +13 -0
  122. package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +1 -1
  123. package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +23 -11
  124. package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +7 -3
  125. package/scss/components/FilterSummary/_filter-summary.scss +3 -1
  126. package/scss/global/decorators/_side-panel-decorator.scss +7 -0
  127. package/scss/global/js/utils/_story-as-full-page.scss +0 -6
@@ -1,6 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
- var _excluded = ["className", "children", "onRequestClose", "onRequestSubmit", "open", "title", "subtitle", "description", "secondaryButtonText", "primaryButtonText", "disableSubmit", "selectorPrimaryFocus"];
3
+ var _excluded = ["className", "children", "onRequestClose", "onRequestSubmit", "open", "title", "subtitle", "description", "secondaryButtonText", "portalTarget", "primaryButtonText", "disableSubmit", "selectorPrimaryFocus"];
4
4
  /**
5
5
  * Copyright IBM Corp. 2021, 2021
6
6
  *
@@ -17,6 +17,7 @@ import PropTypes from 'prop-types';
17
17
  import cx from 'classnames';
18
18
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
19
  import { pkg } from '../../settings';
20
+ import { usePortalTarget } from '../../global/js/hooks/usePortalTarget';
20
21
  var componentName = 'CreateModal';
21
22
  var blockClass = "".concat(pkg.prefix, "--create-modal");
22
23
 
@@ -47,11 +48,13 @@ export var CreateModal = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
47
48
  subtitle = _ref2.subtitle,
48
49
  description = _ref2.description,
49
50
  secondaryButtonText = _ref2.secondaryButtonText,
51
+ portalTargetIn = _ref2.portalTarget,
50
52
  primaryButtonText = _ref2.primaryButtonText,
51
53
  disableSubmit = _ref2.disableSubmit,
52
54
  selectorPrimaryFocus = _ref2.selectorPrimaryFocus,
53
55
  rest = _objectWithoutProperties(_ref2, _excluded);
54
- return /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
56
+ var renderPortalUse = usePortalTarget(portalTargetIn);
57
+ return renderPortalUse( /*#__PURE__*/React.createElement(ComposedModal, _extends({}, rest, {
55
58
  selectorPrimaryFocus: selectorPrimaryFocus,
56
59
  className: cx(blockClass, className),
57
60
  open: open,
@@ -84,7 +87,7 @@ export var CreateModal = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
84
87
  kind: "primary",
85
88
  onClick: onRequestSubmit,
86
89
  disabled: disableSubmit
87
- }, primaryButtonText)));
90
+ }, primaryButtonText))));
88
91
  });
89
92
 
90
93
  // Return a placeholder if not released and not enabled by feature flag
@@ -121,6 +124,10 @@ CreateModal.propTypes = {
121
124
  * Specifies whether the CreateModal is open or not.
122
125
  */
123
126
  open: PropTypes.bool,
127
+ /**
128
+ * The DOM node the tearsheet should be rendered within. Defaults to document.body.
129
+ */
130
+ portalTarget: PropTypes.node,
124
131
  /**
125
132
  * Specifies the primary button's text in the modal.
126
133
  */
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  /**
4
- * Copyright IBM Corp. 2022, 2022
4
+ * Copyright IBM Corp. 2022, 2023
5
5
  *
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -59,8 +59,10 @@ export var DatagridContent = function DatagridContent(_ref) {
59
59
  DatagridActions = datagridState.DatagridActions,
60
60
  totalColumnsWidth = datagridState.totalColumnsWidth,
61
61
  gridRef = datagridState.gridRef,
62
- state = datagridState.state;
63
- var rows = DatagridPagination && datagridState.page || datagridState.rows;
62
+ state = datagridState.state,
63
+ page = datagridState.page,
64
+ rows = datagridState.rows;
65
+ var contentRows = DatagridPagination && page || rows;
64
66
  var gridAreaRef = useRef();
65
67
  var multiKeyTrackingRef = useRef();
66
68
  useClickOutside(gridAreaRef, function (target) {
@@ -82,7 +84,7 @@ export var DatagridContent = function DatagridContent(_ref) {
82
84
  var _getTableProps;
83
85
  return /*#__PURE__*/React.createElement(Table, _extends({}, getTableProps(), {
84
86
  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),
85
- role: withInlineEdit && 'grid',
87
+ role: withInlineEdit ? 'grid' : undefined,
86
88
  tabIndex: withInlineEdit ? 0 : -1,
87
89
  onKeyDown: withInlineEdit ? function (event) {
88
90
  return handleGridKeyPress({
@@ -98,8 +100,8 @@ export var DatagridContent = function DatagridContent(_ref) {
98
100
  return handleGridFocus(inlineEditState, dispatch);
99
101
  } : null,
100
102
  title: title
101
- }), !withVirtualScroll ? /*#__PURE__*/React.createElement(DatagridHead, datagridState) : null, /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
102
- rows: rows
103
+ }), !withVirtualScroll && /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
104
+ rows: contentRows
103
105
  })));
104
106
  };
105
107
  var _useMultipleKeyTracki = useMultipleKeyTracking({
@@ -151,7 +153,7 @@ export var DatagridContent = function DatagridContent(_ref) {
151
153
  }, renderTable()) : withVirtualScroll ? /*#__PURE__*/React.createElement("div", {
152
154
  className: "".concat(blockClass, "__virtualScrollContainer"),
153
155
  ref: gridRef
154
- }, renderTable()) : renderTable()))), (rows === null || rows === void 0 ? void 0 : rows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsTearsheet && /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, {
156
+ }, renderTable()) : renderTable()))), (contentRows === null || contentRows === void 0 ? void 0 : contentRows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsTearsheet && /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, {
155
157
  instance: datagridState
156
158
  }));
157
159
  };
@@ -9,7 +9,7 @@ import _extends from "@babel/runtime/helpers/extends";
9
9
  import React from 'react';
10
10
  import { pkg } from '../../../settings';
11
11
  import { TableBody, TableRow, TableCell } from '@carbon/react';
12
- import { NoDataEmptyState, ErrorEmptyState, NotFoundEmptyState } from '../../EmptyStates';
12
+ import { NoDataEmptyState, ErrorEmptyState, NotFoundEmptyState, EmptyState } from '../../EmptyStates';
13
13
  var blockClass = "".concat(pkg.prefix, "--datagrid");
14
14
  var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
15
15
  var getTableBodyProps = datagridState.getTableBodyProps,
@@ -30,6 +30,7 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
30
30
  action: emptyStateAction,
31
31
  link: emptyStateLink
32
32
  };
33
+ var validEmptyStates = ['error', 'noData', 'notFound'];
33
34
  return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
34
35
  role: false
35
36
  }), {
@@ -37,6 +38,6 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
37
38
  }), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
38
39
  colSpan: headers.length,
39
40
  className: "".concat(blockClass, "__empty-state-cell")
40
- }, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/React.createElement(NotFoundEmptyState, emptyStateProps))));
41
+ }, validEmptyStates.includes(emptyStateType) ? /*#__PURE__*/React.createElement(React.Fragment, null, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/React.createElement(NotFoundEmptyState, emptyStateProps)) : /*#__PURE__*/React.createElement(EmptyState, emptyStateProps))));
41
42
  };
42
43
  export default DatagridEmptyBody;
@@ -1,9 +1,8 @@
1
- /*
2
- * Licensed Materials - Property of IBM
3
- * 5724-Q36
4
- * (c) Copyright IBM Corp. 2020
5
- * US Government Users Restricted Rights - Use, duplication or disclosure
6
- * restricted by GSA ADP Schedule Contract with IBM Corp.
1
+ /**
2
+ * Copyright IBM Corp. 2020, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
7
6
  */
8
7
 
9
8
  import React from 'react';
@@ -11,17 +10,31 @@ import { pkg } from '../../../settings';
11
10
  var blockClass = "".concat(pkg.prefix, "--datagrid");
12
11
 
13
12
  // eslint-disable-next-line react/prop-types
14
- var DatagridExpandedRow = function DatagridExpandedRow(PreviousRowRenderer, ExpandedRowContentComponent) {
13
+ var DatagridExpandedRow = function DatagridExpandedRow(ExpandedRowContentComponent) {
15
14
  return function (datagridState) {
16
15
  var row = datagridState.row;
17
16
  var _ref = row || {},
18
17
  expandedContentHeight = _ref.expandedContentHeight;
19
- if (!row.isExpanded) {
20
- return PreviousRowRenderer(datagridState);
21
- }
22
- return /*#__PURE__*/React.createElement("div", {
23
- className: "".concat(blockClass, "__expanded-row")
24
- }, PreviousRowRenderer(datagridState), /*#__PURE__*/React.createElement("div", {
18
+ var toggleParentHoverClass = function toggleParentHoverClass(event, eventType) {
19
+ var _event$target;
20
+ if (event !== null && event !== void 0 && (_event$target = event.target) !== null && _event$target !== void 0 && (_event$target = _event$target.parentNode) !== null && _event$target !== void 0 && _event$target.previousElementSibling) {
21
+ var parentNode = event.target.parentNode.previousElementSibling;
22
+ if (eventType === 'enter') {
23
+ parentNode.classList.add("".concat(blockClass, "__expandable-row--hover"));
24
+ } else {
25
+ parentNode.classList.remove("".concat(blockClass, "__expandable-row--hover"));
26
+ }
27
+ }
28
+ };
29
+ return /*#__PURE__*/React.createElement("tr", {
30
+ className: "".concat(blockClass, "__expanded-row"),
31
+ onMouseEnter: function onMouseEnter(event) {
32
+ return toggleParentHoverClass(event, 'enter');
33
+ },
34
+ onMouseLeave: function onMouseLeave(event) {
35
+ return toggleParentHoverClass(event);
36
+ }
37
+ }, /*#__PURE__*/React.createElement("div", {
25
38
  className: "".concat(blockClass, "__expanded-row-content"),
26
39
  style: {
27
40
  height: expandedContentHeight ? expandedContentHeight : null
@@ -2,14 +2,15 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var _excluded = ["children"];
5
- /*
6
- * Licensed Materials - Property of IBM
7
- * 5724-Q36
8
- * (c) Copyright IBM Corp. 2020
9
- * US Government Users Restricted Rights - Use, duplication or disclosure
10
- * restricted by GSA ADP Schedule Contract with IBM Corp.
5
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
+ /**
8
+ * Copyright IBM Corp. 2020, 2023
9
+ *
10
+ * This source code is licensed under the Apache-2.0 license found in the
11
+ * LICENSE file in the root directory of this source tree.
11
12
  */
12
- // @flow
13
+
13
14
  import React from 'react';
14
15
  import { TableRow, TableCell, SkeletonText } from '@carbon/react';
15
16
  import { px } from '@carbon/layout';
@@ -30,7 +31,8 @@ var DatagridRow = function DatagridRow(datagridState) {
30
31
  var _cx;
31
32
  var row = datagridState.row,
32
33
  rowSize = datagridState.rowSize,
33
- withNestedRows = datagridState.withNestedRows;
34
+ withNestedRows = datagridState.withNestedRows,
35
+ prepareRow = datagridState.prepareRow;
34
36
  var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
35
37
  var isExpanded = _ref.isExpanded,
36
38
  subRows = _ref.subRows;
@@ -45,6 +47,9 @@ var DatagridRow = function DatagridRow(datagridState) {
45
47
  };
46
48
  var hoverHandler = function hoverHandler(event) {
47
49
  var _hoverRow$style, _hoverRow$style2, _hoverRow$style3;
50
+ if (!withNestedRows) {
51
+ return;
52
+ }
48
53
  var subRowCount = getVisibleNestedRowCount(row);
49
54
  var totalNestedRowIndicatorHeight = px(subRowCount * rowHeights[rowSize]);
50
55
  var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
@@ -61,48 +66,50 @@ var DatagridRow = function DatagridRow(datagridState) {
61
66
  el.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
62
67
  });
63
68
  };
64
- return /*#__PURE__*/React.createElement(TableRow, _extends({
65
- className: cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx))
69
+ var renderExpandedRow = function renderExpandedRow() {
70
+ if (row.isExpanded) {
71
+ var _row$RowExpansionRend;
72
+ prepareRow(row);
73
+ return row === null || row === void 0 || (_row$RowExpansionRend = row.RowExpansionRenderer) === null || _row$RowExpansionRend === void 0 ? void 0 : _row$RowExpansionRend.call(row, _objectSpread(_objectSpread({}, datagridState), {}, {
74
+ row: row
75
+ }));
76
+ }
77
+ return null;
78
+ };
79
+ var handleMouseLeave = function handleMouseLeave(event) {
80
+ var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
81
+ hoverRow === null || hoverRow === void 0 || hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
82
+ };
83
+ var handleOnKeyUp = function handleOnKeyUp(event) {
84
+ if (!withNestedRows) {
85
+ return;
86
+ }
87
+ if (event.key === 'Enter' || event.key === 'Space') {
88
+ focusRemover();
89
+ hoverHandler(event);
90
+ }
91
+ };
92
+ var rowClassNames = cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx));
93
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableRow, _extends({
94
+ className: rowClassNames
66
95
  }, row.getRowProps({
67
96
  role: false
68
97
  }), {
69
98
  key: row.id,
70
- onMouseEnter: function onMouseEnter(event) {
71
- if (!withNestedRows) {
72
- return;
73
- }
74
- hoverHandler(event);
75
- },
76
- onMouseLeave: function onMouseLeave(event) {
77
- var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
78
- hoverRow === null || hoverRow === void 0 || hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
79
- },
80
- onFocus: function onFocus(event) {
81
- if (!withNestedRows) {
82
- return;
83
- }
84
- hoverHandler(event);
85
- },
86
- onBlur: function onBlur() {
87
- focusRemover();
88
- },
89
- onKeyUp: function onKeyUp(event) {
90
- if (!withNestedRows) {
91
- return;
92
- }
93
- if (event.key === 'Enter' || event.key === 'Space') {
94
- focusRemover();
95
- hoverHandler(event);
96
- }
97
- }
99
+ onMouseEnter: hoverHandler,
100
+ onMouseLeave: handleMouseLeave,
101
+ onFocus: hoverHandler,
102
+ onBlur: focusRemover,
103
+ onKeyUp: handleOnKeyUp
98
104
  }), row.cells.map(function (cell, index) {
105
+ var _cell$column;
99
106
  var cellProps = cell.getCellProps({
100
107
  role: false
101
108
  });
102
109
  var children = cellProps.children,
103
110
  restProps = _objectWithoutProperties(cellProps, _excluded);
104
111
  var content = children || /*#__PURE__*/React.createElement(React.Fragment, null, !row.isSkeleton && cell.render('Cell'), row.isSkeleton && /*#__PURE__*/React.createElement(SkeletonText, null));
105
- if (cell && cell.column && cell.column.id === selectionColumnId) {
112
+ if ((cell === null || cell === void 0 || (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : _cell$column.id) === selectionColumnId) {
106
113
  // directly render component without the wrapping TableCell
107
114
  return cell.render('Cell', {
108
115
  key: cell.column.id
@@ -113,6 +120,6 @@ var DatagridRow = function DatagridRow(datagridState) {
113
120
  }, restProps, {
114
121
  key: cell.column.id
115
122
  }), content);
116
- }));
123
+ })), renderExpandedRow());
117
124
  };
118
125
  export default DatagridRow;
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  /**
4
- * Copyright IBM Corp. 2022, 2023
4
+ * Copyright IBM Corp. 2021, 2023
5
5
  *
6
6
  * This source code is licensed under the Apache-2.0 license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -73,39 +73,41 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
73
73
  // Do not render ButtonMenu when there are 3 or less items
74
74
  // and if there is enough available space to render all the items
75
75
  if ((toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.length) <= 3 && !displayAllInMenu) {
76
- return null;
76
+ return;
77
77
  }
78
- return /*#__PURE__*/React.createElement(MenuButton, {
79
- label: "More",
80
- className: cx("".concat(blockClass, "__button-menu"), _defineProperty({}, "".concat(blockClass, "__button-menu--icon-only"), width <= minWidthBeforeOverflowIcon))
81
- }, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
82
- if (index < 2) {
83
- if (displayAllInMenu) {
84
- return /*#__PURE__*/React.createElement(MenuItem, {
85
- key: "".concat(batchAction.label, "-").concat(index),
86
- label: batchAction.label,
87
- onClick: function onClick(event) {
88
- batchAction.onClick(getSelectedRowData(), event);
89
- if (batchAction.type === 'select_all') {
90
- toggleAllRowsSelected(true);
91
- }
92
- }
93
- });
94
- }
95
- return null;
96
- }
78
+ var renderItem = function renderItem(batchAction, index) {
97
79
  return /*#__PURE__*/React.createElement(MenuItem, {
98
80
  key: "".concat(batchAction.label, "-").concat(index),
99
81
  label: batchAction.label,
100
82
  onClick: function onClick(event) {
101
- batchAction.onClick(getSelectedRowData(), event);
102
- if (batchAction.type === 'select_all') {
103
- toggleAllRowsSelected(true);
104
- }
83
+ return onClickHandler(event, batchAction);
105
84
  }
106
85
  });
86
+ };
87
+ return /*#__PURE__*/React.createElement(MenuButton, {
88
+ label: "More",
89
+ className: cx("".concat(blockClass, "__button-menu"), _defineProperty({}, "".concat(blockClass, "__button-menu--icon-only"), width <= minWidthBeforeOverflowIcon))
90
+ }, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
91
+ if (index < 2 && !displayAllInMenu) {
92
+ return;
93
+ }
94
+ return renderItem(batchAction, index);
107
95
  }));
108
96
  };
97
+ var onClickHandler = function onClickHandler(event, batchAction) {
98
+ batchAction.onClick(getSelectedRowData(), event);
99
+ if (batchAction.type === 'select_all') {
100
+ toggleAllRowsSelected(true);
101
+ }
102
+ };
103
+ var onCancelHandler = function onCancelHandler() {
104
+ toggleAllRowsSelected(false);
105
+ setGlobalFilter(null);
106
+ };
107
+ var onSelectAllHandler = function onSelectAllHandler() {
108
+ toggleAllRowsSelected(true);
109
+ onSelectAllRows === null || onSelectAllRows === void 0 || onSelectAllRows(true);
110
+ };
109
111
 
110
112
  // Only display the first two batch actions, the rest are
111
113
  // displayed inside of the ButtonMenu if there are more than
@@ -113,14 +115,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
113
115
  return /*#__PURE__*/React.createElement(TableBatchActions, {
114
116
  shouldShowBatchActions: totalSelected > 0,
115
117
  totalSelected: totalSelected,
116
- onCancel: function onCancel() {
117
- toggleAllRowsSelected(false);
118
- setGlobalFilter(null);
119
- },
120
- onSelectAll: function onSelectAll() {
121
- toggleAllRowsSelected(true);
122
- onSelectAllRows === null || onSelectAllRows === void 0 || onSelectAllRows(true);
123
- },
118
+ onCancel: onCancelHandler,
119
+ onSelectAll: onSelectAllHandler,
124
120
  totalCount: rows && rows.length
125
121
  }, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
126
122
  if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length <= 3) {
@@ -128,10 +124,7 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
128
124
  key: "".concat(batchAction.label, "-").concat(index),
129
125
  renderIcon: batchAction.renderIcon,
130
126
  onClick: function onClick(event) {
131
- batchAction.onClick(getSelectedRowData(), event);
132
- if (batchAction.type === 'select_all') {
133
- toggleAllRowsSelected(true);
134
- }
127
+ return onClickHandler(batchAction, event);
135
128
  },
136
129
  iconDescription: batchAction.label
137
130
  }, batchAction.label);
@@ -1,5 +1,5 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  // @flow
4
4
  /*
5
5
  * Licensed Materials - Property of IBM
@@ -8,163 +8,67 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
8
8
  * US Government Users Restricted Rights - Use, duplication or disclosure
9
9
  * restricted by GSA ADP Schedule Contract with IBM Corp.
10
10
  */
11
- import * as React from 'react';
11
+ import React from 'react';
12
12
  import PropTypes from 'prop-types';
13
- import { Draggable, Locked } from '@carbon/react/icons';
14
- // import { useDrag, useDrop } from 'react-dnd';
13
+ import { Draggable as DraggableIcon, Locked } from '@carbon/react/icons';
15
14
  import cx from 'classnames';
16
15
  import { pkg } from '../../../settings';
17
- var useEffect = React.useEffect,
18
- useRef = React.useRef,
19
- useState = React.useState;
16
+ import { CSS } from '@dnd-kit/utilities';
17
+ import { useSortable } from '@dnd-kit/sortable';
20
18
  var blockClass = "".concat(pkg.prefix, "--datagrid");
21
-
22
- // const DRAG_TYPE = `${blockClass}__shared-ui-draggable-element`;
23
-
24
19
  var DraggableElement = function DraggableElement(_ref) {
25
20
  var _cx;
26
- var index = _ref.index,
27
- listData = _ref.listData,
21
+ var id = _ref.id,
28
22
  children = _ref.children,
23
+ classList = _ref.classList,
29
24
  disabled = _ref.disabled,
30
25
  ariaLabel = _ref.ariaLabel,
31
- onGrab = _ref.onGrab,
32
- onArrowKeyDown = _ref.onArrowKeyDown,
33
- isFocused = _ref.isFocused,
34
26
  isSticky = _ref.isSticky,
35
- selected = _ref.selected,
36
- _ref$positionLabel = _ref.positionLabel,
37
- positionLabel = _ref$positionLabel === void 0 ? 'Current position {index} of {total}' : _ref$positionLabel,
38
- _ref$grabbedLabel = _ref.grabbedLabel,
39
- grabbedLabel = _ref$grabbedLabel === void 0 ? '{itemName} grabbed.' : _ref$grabbedLabel,
40
- _ref$droppedLabel = _ref.droppedLabel,
41
- droppedLabel = _ref$droppedLabel === void 0 ? '{itemName} dropped.' : _ref$droppedLabel;
42
- var ref = useRef();
43
-
44
- // const [{ isOver }, drop] = useDrop({
45
- // accept: DRAG_TYPE + type,
46
- // collect: (monitor) => ({
47
- // isOver: !!monitor.isOver(),
48
- // }),
49
- // drop: (item) => {
50
- // moveElement(item.index, index);
51
- // },
52
- // canDrop: () => !disabled,
53
- // hover(item) {
54
- // const dragIndex = item.index;
55
- // const hoverIndex = index;
56
- // // Don't replace items with themselves
57
- // if (dragIndex === hoverIndex || disabled) {
58
- // return;
59
- // }
60
- // // moveElement(dragIndex, hoverIndex);
61
- // // Time to actually perform the action
62
- // // Note: we're mutating the monitor item here!
63
- // // Generally it's better to avoid mutations,
64
- // // but it's good here for the sake of performance
65
- // // to avoid expensive index searches.
66
- // // eslint-disable-next-line no-param-reassign
67
- // item.index = hoverIndex;
68
- // },
69
- // });
70
-
71
- // const [{ isDragging }, drag, preview] = useDrag({
72
- // type: DRAG_TYPE + type,
73
- // item: { id, index },
74
- // canDrag: () => !disabled,
75
- // collect: (monitor) => ({
76
- // isDragging: monitor.isDragging(),
77
- // }),
78
- // });
79
-
80
- // Temporarily disable drag support because of commonjs support/issues with react-dnd in latest version
81
- var _useState = useState(false),
82
- _useState2 = _slicedToArray(_useState, 1),
83
- isDragging = _useState2[0];
84
- var _useState3 = useState(false),
85
- _useState4 = _slicedToArray(_useState3, 1),
86
- isOver = _useState4[0];
87
- var preview = useRef();
88
- var drag = useRef();
89
- useEffect(function () {
90
- if (isFocused && ref && ref.current) {
91
- ref.current.focus();
92
- }
93
- }, [isFocused]);
94
- var _useState5 = useState(false),
95
- _useState6 = _slicedToArray(_useState5, 2),
96
- isGrabbed = _useState6[0],
97
- setIsGrabbed = _useState6[1];
98
- var _useState7 = useState(isFocused),
99
- _useState8 = _slicedToArray(_useState7, 2),
100
- isFocusedOnItem = _useState8[0],
101
- setIsFocusedOnItem = _useState8[1];
102
- // drop(ref);
27
+ selected = _ref.selected;
28
+ var _useSortable = useSortable({
29
+ id: id
30
+ }),
31
+ attributes = _useSortable.attributes,
32
+ isDragging = _useSortable.isDragging,
33
+ listeners = _useSortable.listeners,
34
+ setNodeRef = _useSortable.setNodeRef,
35
+ transform = _useSortable.transform,
36
+ transition = _useSortable.transition;
103
37
  var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
104
38
  className: cx({
105
39
  disabled: disabled
106
40
  }, "".concat(blockClass, "__draggable-handleStyle"))
107
41
  }, isSticky ? /*#__PURE__*/React.createElement(Locked, {
108
42
  size: 16
109
- }) : /*#__PURE__*/React.createElement(Draggable, {
43
+ }) : /*#__PURE__*/React.createElement(DraggableIcon, {
110
44
  size: 16
111
45
  })), children);
112
- return /*#__PURE__*/React.createElement("li", {
113
- 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--sticky"), isSticky), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder"), !selected), _cx)),
114
- ref: ref,
115
- "aria-selected": isFocused,
116
- role: "option",
117
- tabIndex: isFocused ? 0 : -1,
118
- onKeyPress: function onKeyPress(e) {
119
- if (e.key === ' ' && e.target === e.currentTarget && !disabled) {
120
- var positionText = positionLabel.replace('{index}', index + 1).replace('{total}', listData.length);
121
- var grabAriaText = (isGrabbed ? droppedLabel : grabbedLabel).replace('{itemName}', ariaLabel);
122
- onGrab(grabAriaText + positionText);
123
- setIsGrabbed(!isGrabbed);
124
- e.preventDefault();
125
- }
126
- },
127
- onKeyDown: function onKeyDown(e) {
128
- if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
129
- onArrowKeyDown(e, isGrabbed, index);
130
- }
131
- },
132
- onBlur: function onBlur(e) {
133
- // handle when focus move to inner elements
134
- setIsFocusedOnItem(e.currentTarget === e.target);
135
- },
136
- onFocus: function onFocus(e) {
137
- // handle when focus move to li element
138
- setIsFocusedOnItem(e.currentTarget === e.target);
139
- }
140
- }, /*#__PURE__*/React.createElement("span", {
46
+ var style = {
47
+ transform: CSS.Transform.toString(transform),
48
+ transition: transition
49
+ };
50
+ return /*#__PURE__*/React.createElement("li", _extends({
51
+ className: cx(classList, "".concat(blockClass, "__draggable-handleHolder"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder--selected"), selected), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder--sticky"), isSticky), _defineProperty(_cx, "".concat(blockClass, "__draggable-handleHolder--dragging"), isDragging), _cx)),
52
+ id: id,
53
+ ref: setNodeRef,
54
+ style: style
55
+ }, attributes, listeners, {
56
+ disabled: disabled,
57
+ "aria-selected": selected,
58
+ role: "option"
59
+ }), /*#__PURE__*/React.createElement("span", {
141
60
  className: "".concat(blockClass, "__shared-ui--assistive-text")
142
- }, ariaLabel), isDragging && !isOver ? /*#__PURE__*/React.createElement("div", {
143
- ref: preview,
144
- className: "".concat(blockClass, "__draggable-handleHolder-droppable ").concat(blockClass, "__draggable-handleHolder-droppable--origin")
145
- }, content) : /*#__PURE__*/React.createElement("div", {
146
- ref: drag,
147
- "aria-hidden": isFocused && isFocusedOnItem // if focus on li, hide the children from aria
148
- ,
61
+ }, ariaLabel), /*#__PURE__*/React.createElement("div", {
149
62
  className: cx(_defineProperty({}, "".concat(blockClass, "__draggable-handleStyle"), !disabled), ["".concat(blockClass, "__draggable-handleHolder-droppable")])
150
- }, (!isOver || disabled) && content));
63
+ }, content));
151
64
  };
152
65
  DraggableElement.propTypes = {
153
66
  ariaLabel: PropTypes.string.isRequired,
154
67
  children: PropTypes.element.isRequired,
68
+ classList: PropTypes.string,
155
69
  disabled: PropTypes.bool,
156
- droppedLabel: PropTypes.string,
157
- grabbedLabel: PropTypes.string,
158
70
  id: PropTypes.string.isRequired,
159
- index: PropTypes.number.isRequired,
160
- isFocused: PropTypes.bool.isRequired,
161
71
  isSticky: PropTypes.bool,
162
- listData: PropTypes.array.isRequired,
163
- // moveElement: PropTypes.func.isRequired,
164
- onArrowKeyDown: PropTypes.func.isRequired,
165
- onGrab: PropTypes.func.isRequired,
166
- positionLabel: PropTypes.string,
167
- selected: PropTypes.bool,
168
- type: PropTypes.string.isRequired
72
+ selected: PropTypes.bool
169
73
  };
170
74
  export default DraggableElement;