@carbon/ibm-products 2.10.2 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +7 -0
- package/css/index-full-carbon.css +67 -26
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +3 -3
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +1 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +67 -26
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +3 -3
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +64 -25
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/APIKeyModal/APIKeyModal.js +10 -3
- package/es/components/AboutModal/AboutModal.js +10 -3
- package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
- package/es/components/CreateModal/CreateModal.js +10 -3
- package/es/components/Datagrid/Datagrid/DatagridContent.js +9 -7
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +3 -2
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
- package/es/components/Datagrid/Datagrid/DatagridRow.js +47 -40
- package/es/components/Datagrid/Datagrid/DraggableElement.js +36 -132
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +17 -49
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +125 -40
- package/es/components/Datagrid/useExpandedRow.js +1 -1
- package/es/components/Datagrid/utils/DatagridPagination.js +1 -1
- package/es/components/EmptyStates/EmptyState.js +1 -1
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -11
- package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -11
- package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
- package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
- package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
- package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
- package/es/components/ExportModal/ExportModal.js +10 -3
- package/es/components/ImportModal/ImportModal.js +10 -3
- package/es/components/RemoveModal/RemoveModal.js +10 -3
- package/es/components/TagSet/TagSet.js +5 -21
- package/es/components/TagSet/TagSetModal.js +7 -3
- package/es/components/Tearsheet/TearsheetShell.js +12 -26
- package/es/global/decorators/sidePanelDecorator.js +7 -0
- package/es/global/js/hooks/usePortalTarget.js +30 -0
- package/es/global/js/hooks/useWindowScroll.js +5 -0
- package/es/global/js/package-settings.js +0 -1
- package/es/global/js/utils/getNodeTextContent.js +47 -0
- package/flags.js +6 -0
- package/lib/components/APIKeyModal/APIKeyModal.js +10 -3
- package/lib/components/AboutModal/AboutModal.js +10 -3
- package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +17 -5
- package/lib/components/CreateModal/CreateModal.js +10 -3
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +9 -7
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +26 -13
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +46 -41
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +37 -137
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +20 -49
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +130 -47
- package/lib/components/Datagrid/useExpandedRow.js +1 -1
- package/lib/components/Datagrid/utils/DatagridPagination.js +1 -1
- package/lib/components/EmptyStates/EmptyState.js +1 -1
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -1
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -1
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -1
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -1
- package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -11
- package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -11
- package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -12
- package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -12
- package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -12
- package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -12
- package/lib/components/ExportModal/ExportModal.js +10 -3
- package/lib/components/ImportModal/ImportModal.js +10 -3
- package/lib/components/RemoveModal/RemoveModal.js +10 -3
- package/lib/components/TagSet/TagSet.js +5 -21
- package/lib/components/TagSet/TagSetModal.js +7 -3
- package/lib/components/Tearsheet/TearsheetShell.js +12 -26
- package/lib/global/decorators/sidePanelDecorator.js +7 -0
- package/lib/global/js/hooks/usePortalTarget.js +38 -0
- package/lib/global/js/hooks/useWindowScroll.js +6 -0
- package/lib/global/js/package-settings.js +0 -1
- package/lib/global/js/utils/getNodeTextContent.js +55 -0
- package/package.json +7 -3
- package/scss/components/ActionSet/_action-set.scss +2 -1
- package/scss/components/Datagrid/styles/_datagrid.scss +6 -6
- package/scss/components/Datagrid/styles/_draggableElement.scss +34 -16
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +13 -0
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +1 -1
- package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +22 -11
- package/scss/components/Datagrid/styles/addons/_FilterPanel.scss +6 -3
- package/scss/components/FilterSummary/_filter-summary.scss +2 -1
- package/scss/global/decorators/_side-panel-decorator.scss +7 -0
- 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
|
-
|
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,
|
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
|
-
|
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
|
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
|
102
|
-
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()))), (
|
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
|
-
*
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
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(
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
7
|
-
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
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
|
-
|
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
|
-
|
65
|
-
|
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:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
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
|
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,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
|
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
|
-
|
18
|
-
|
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
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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(
|
43
|
+
}) : /*#__PURE__*/React.createElement(DraggableIcon, {
|
110
44
|
size: 16
|
111
45
|
})), children);
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
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),
|
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
|
-
},
|
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
|
-
|
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;
|
@@ -7,26 +7,15 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
8
8
|
*/
|
9
9
|
|
10
|
-
import React from 'react';
|
10
|
+
import React, { useRef } from 'react';
|
11
11
|
import PropTypes from 'prop-types';
|
12
|
-
// import { DndProvider } from 'react-dnd';
|
13
|
-
// import { HTML5Backend } from 'react-dnd-html5-backend';
|
14
12
|
import { Checkbox } from '@carbon/react';
|
15
|
-
|
13
|
+
import update from 'immutability-helper';
|
16
14
|
import { pkg } from '../../../../../settings';
|
17
15
|
import cx from 'classnames';
|
18
16
|
import { DraggableItemsList } from './DraggableItemsList';
|
17
|
+
import uuidv4 from '../../../../../global/js/utils/uuidv4';
|
19
18
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
|
-
var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
21
|
-
var newIndex = -1;
|
22
|
-
if (key === 'ArrowUp') {
|
23
|
-
newIndex = currentIndex - 1 >= 0 ? currentIndex - 1 : array.length - 1;
|
24
|
-
}
|
25
|
-
if (key === 'ArrowDown') {
|
26
|
-
newIndex = currentIndex + 1 < array.length ? currentIndex + 1 : 0;
|
27
|
-
}
|
28
|
-
return newIndex;
|
29
|
-
};
|
30
19
|
var Columns = function Columns(_ref) {
|
31
20
|
var getVisibleColumnsCount = _ref.getVisibleColumnsCount,
|
32
21
|
filterString = _ref.filterString,
|
@@ -36,43 +25,26 @@ var Columns = function Columns(_ref) {
|
|
36
25
|
assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
|
37
26
|
assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
|
38
27
|
selectAllLabel = _ref.selectAllLabel;
|
28
|
+
var listId = useRef(uuidv4()); // keep id between renders
|
29
|
+
var listRef = useRef(null);
|
39
30
|
var _React$useState = React.useState(''),
|
40
31
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
41
32
|
ariaRegionText = _React$useState2[0],
|
42
33
|
setAriaRegionText = _React$useState2[1];
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
// setColumnsObject(
|
51
|
-
// update(columns, {
|
52
|
-
// $splice: [
|
53
|
-
// [dragIndex, 1],
|
54
|
-
// [hoverIndex, 0, dragCard],
|
55
|
-
// ],
|
56
|
-
// })
|
57
|
-
// );
|
58
|
-
// },
|
59
|
-
// [columns, setColumnsObject]
|
60
|
-
// );
|
61
|
-
|
34
|
+
// after a drag/drop action set the columns
|
35
|
+
var moveElement = React.useCallback(function (from, to) {
|
36
|
+
var fromCol = columns[from];
|
37
|
+
setColumnsObject(update(columns, {
|
38
|
+
$splice: [[from, 1], [to, 0, fromCol]]
|
39
|
+
}));
|
40
|
+
}, [columns, setColumnsObject]);
|
62
41
|
return /*#__PURE__*/React.createElement("div", {
|
63
|
-
className: "".concat(blockClass, "__customize-columns-column-list")
|
42
|
+
className: "".concat(blockClass, "__customize-columns-column-list"),
|
43
|
+
ref: listRef
|
64
44
|
}, /*#__PURE__*/React.createElement("ol", {
|
65
45
|
className: "".concat(blockClass, "__customize-columns-column-list--focus"),
|
66
46
|
role: "listbox",
|
67
47
|
"aria-describedby": "".concat(blockClass, "__customize-columns--instructions"),
|
68
|
-
onKeyDown: function onKeyDown(e) {
|
69
|
-
var nextIndex = getNextIndex(columns, focusIndex, e.key);
|
70
|
-
if (nextIndex >= 0) {
|
71
|
-
setFocusIndex(nextIndex);
|
72
|
-
e.preventDefault();
|
73
|
-
e.stopPropagation();
|
74
|
-
}
|
75
|
-
},
|
76
48
|
tabIndex: 0
|
77
49
|
}, /*#__PURE__*/React.createElement("span", {
|
78
50
|
"aria-live": "assertive",
|
@@ -94,16 +66,12 @@ var Columns = function Columns(_ref) {
|
|
94
66
|
id: "".concat(blockClass, "__customization-column-select-all"),
|
95
67
|
labelText: selectAllLabel
|
96
68
|
})), /*#__PURE__*/React.createElement(DraggableItemsList, {
|
69
|
+
id: listId.current,
|
97
70
|
columns: columns,
|
98
71
|
filterString: filterString,
|
99
|
-
|
100
|
-
getNextIndex: getNextIndex
|
101
|
-
// moveElement={moveElement}
|
102
|
-
,
|
103
|
-
onSelectColumn: onSelectColumn,
|
72
|
+
moveElement: moveElement,
|
104
73
|
setAriaRegionText: setAriaRegionText,
|
105
|
-
|
106
|
-
setFocusIndex: setFocusIndex
|
74
|
+
onSelectColumn: onSelectColumn
|
107
75
|
})));
|
108
76
|
};
|
109
77
|
Columns.propTypes = {
|