@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
@@ -13,7 +13,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
14
14
|
var _devtools = require("../../global/js/utils/devtools");
|
15
15
|
var _settings = require("../../settings");
|
16
|
-
var
|
16
|
+
var _usePortalTarget = require("../../global/js/hooks/usePortalTarget");
|
17
|
+
var _excluded = ["className", "children", "onRequestClose", "onRequestSubmit", "open", "title", "subtitle", "description", "secondaryButtonText", "portalTarget", "primaryButtonText", "disableSubmit", "selectorPrimaryFocus"];
|
17
18
|
/**
|
18
19
|
* Copyright IBM Corp. 2021, 2021
|
19
20
|
*
|
@@ -52,11 +53,13 @@ var CreateModal = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
|
|
52
53
|
subtitle = _ref2.subtitle,
|
53
54
|
description = _ref2.description,
|
54
55
|
secondaryButtonText = _ref2.secondaryButtonText,
|
56
|
+
portalTargetIn = _ref2.portalTarget,
|
55
57
|
primaryButtonText = _ref2.primaryButtonText,
|
56
58
|
disableSubmit = _ref2.disableSubmit,
|
57
59
|
selectorPrimaryFocus = _ref2.selectorPrimaryFocus,
|
58
60
|
rest = (0, _objectWithoutProperties2.default)(_ref2, _excluded);
|
59
|
-
|
61
|
+
var renderPortalUse = (0, _usePortalTarget.usePortalTarget)(portalTargetIn);
|
62
|
+
return renderPortalUse( /*#__PURE__*/_react.default.createElement(_react2.ComposedModal, (0, _extends2.default)({}, rest, {
|
60
63
|
selectorPrimaryFocus: selectorPrimaryFocus,
|
61
64
|
className: (0, _classnames.default)(blockClass, className),
|
62
65
|
open: open,
|
@@ -89,7 +92,7 @@ var CreateModal = /*#__PURE__*/_react.default.forwardRef(function (_ref2, ref) {
|
|
89
92
|
kind: "primary",
|
90
93
|
onClick: onRequestSubmit,
|
91
94
|
disabled: disableSubmit
|
92
|
-
}, primaryButtonText)));
|
95
|
+
}, primaryButtonText))));
|
93
96
|
});
|
94
97
|
|
95
98
|
// Return a placeholder if not released and not enabled by feature flag
|
@@ -127,6 +130,10 @@ CreateModal.propTypes = {
|
|
127
130
|
* Specifies whether the CreateModal is open or not.
|
128
131
|
*/
|
129
132
|
open: _propTypes.default.bool,
|
133
|
+
/**
|
134
|
+
* The DOM node the tearsheet should be rendered within. Defaults to document.body.
|
135
|
+
*/
|
136
|
+
portalTarget: _propTypes.default.node,
|
130
137
|
/**
|
131
138
|
* Specifies the primary button's text in the modal.
|
132
139
|
*/
|
@@ -28,7 +28,7 @@ var _hooks2 = require("../../DataSpreadsheet/hooks");
|
|
28
28
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
29
29
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
30
30
|
/**
|
31
|
-
* Copyright IBM Corp. 2022,
|
31
|
+
* Copyright IBM Corp. 2022, 2023
|
32
32
|
*
|
33
33
|
* This source code is licensed under the Apache-2.0 license found in the
|
34
34
|
* LICENSE file in the root directory of this source tree.
|
@@ -69,8 +69,10 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
69
69
|
DatagridActions = datagridState.DatagridActions,
|
70
70
|
totalColumnsWidth = datagridState.totalColumnsWidth,
|
71
71
|
gridRef = datagridState.gridRef,
|
72
|
-
state = datagridState.state
|
73
|
-
|
72
|
+
state = datagridState.state,
|
73
|
+
page = datagridState.page,
|
74
|
+
rows = datagridState.rows;
|
75
|
+
var contentRows = DatagridPagination && page || rows;
|
74
76
|
var gridAreaRef = (0, _react.useRef)();
|
75
77
|
var multiKeyTrackingRef = (0, _react.useRef)();
|
76
78
|
(0, _hooks.useClickOutside)(gridAreaRef, function (target) {
|
@@ -92,7 +94,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
92
94
|
var _getTableProps;
|
93
95
|
return /*#__PURE__*/_react.default.createElement(_react2.Table, (0, _extends2.default)({}, getTableProps(), {
|
94
96
|
className: (0, _classnames.default)(withVirtualScroll ? '' : "".concat(blockClass, "__table-simple"), "".concat(blockClass, "__vertical-align-").concat(verticalAlign), (0, _defineProperty2.default)({}, "".concat(blockClass, "__variable-row-height"), variableRowHeight), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-with-inline-edit"), withInlineEdit), (0, _defineProperty2.default)({}, "".concat(blockClass, "__table-grid-active"), gridActive), (_getTableProps = getTableProps()) === null || _getTableProps === void 0 ? void 0 : _getTableProps.className),
|
95
|
-
role: withInlineEdit
|
97
|
+
role: withInlineEdit ? 'grid' : undefined,
|
96
98
|
tabIndex: withInlineEdit ? 0 : -1,
|
97
99
|
onKeyDown: withInlineEdit ? function (event) {
|
98
100
|
return (0, _handleGridKeyPress.handleGridKeyPress)({
|
@@ -108,8 +110,8 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
108
110
|
return (0, _handleGridFocus.handleGridFocus)(inlineEditState, dispatch);
|
109
111
|
} : null,
|
110
112
|
title: title
|
111
|
-
}), !withVirtualScroll
|
112
|
-
rows:
|
113
|
+
}), !withVirtualScroll && /*#__PURE__*/_react.default.createElement(_DatagridHead.default, datagridState), /*#__PURE__*/_react.default.createElement(_DatagridBody.default, (0, _extends2.default)({}, datagridState, {
|
114
|
+
rows: contentRows
|
113
115
|
})));
|
114
116
|
};
|
115
117
|
var _useMultipleKeyTracki = (0, _hooks2.useMultipleKeyTracking)({
|
@@ -161,7 +163,7 @@ var DatagridContent = function DatagridContent(_ref) {
|
|
161
163
|
}, renderTable()) : withVirtualScroll ? /*#__PURE__*/_react.default.createElement("div", {
|
162
164
|
className: "".concat(blockClass, "__virtualScrollContainer"),
|
163
165
|
ref: gridRef
|
164
|
-
}, renderTable()) : renderTable()))), (
|
166
|
+
}, renderTable()) : renderTable()))), (contentRows === null || contentRows === void 0 ? void 0 : contentRows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/_react.default.createElement(DatagridPagination, datagridState), CustomizeColumnsTearsheet && /*#__PURE__*/_react.default.createElement(CustomizeColumnsTearsheet, {
|
165
167
|
instance: datagridState
|
166
168
|
}));
|
167
169
|
};
|
@@ -37,6 +37,7 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
|
|
37
37
|
action: emptyStateAction,
|
38
38
|
link: emptyStateLink
|
39
39
|
};
|
40
|
+
var validEmptyStates = ['error', 'noData', 'notFound'];
|
40
41
|
return /*#__PURE__*/_react.default.createElement(_react2.TableBody, (0, _extends2.default)({}, getTableBodyProps({
|
41
42
|
role: false
|
42
43
|
}), {
|
@@ -44,7 +45,7 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
|
|
44
45
|
}), /*#__PURE__*/_react.default.createElement(_react2.TableRow, null, /*#__PURE__*/_react.default.createElement(_react2.TableCell, {
|
45
46
|
colSpan: headers.length,
|
46
47
|
className: "".concat(blockClass, "__empty-state-cell")
|
47
|
-
}, emptyStateType === 'error' && /*#__PURE__*/_react.default.createElement(_EmptyStates.ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/_react.default.createElement(_EmptyStates.NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/_react.default.createElement(_EmptyStates.NotFoundEmptyState, emptyStateProps))));
|
48
|
+
}, validEmptyStates.includes(emptyStateType) ? /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, emptyStateType === 'error' && /*#__PURE__*/_react.default.createElement(_EmptyStates.ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/_react.default.createElement(_EmptyStates.NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/_react.default.createElement(_EmptyStates.NotFoundEmptyState, emptyStateProps)) : /*#__PURE__*/_react.default.createElement(_EmptyStates.EmptyState, emptyStateProps))));
|
48
49
|
};
|
49
50
|
var _default = DatagridEmptyBody;
|
50
51
|
exports.default = _default;
|
@@ -7,28 +7,41 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
exports.default = void 0;
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
9
9
|
var _settings = require("../../../settings");
|
10
|
-
|
11
|
-
*
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*
|
15
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
10
|
+
/**
|
11
|
+
* Copyright IBM Corp. 2020, 2023
|
12
|
+
*
|
13
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
14
|
+
* LICENSE file in the root directory of this source tree.
|
16
15
|
*/
|
17
16
|
|
18
17
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
19
18
|
|
20
19
|
// eslint-disable-next-line react/prop-types
|
21
|
-
var DatagridExpandedRow = function DatagridExpandedRow(
|
20
|
+
var DatagridExpandedRow = function DatagridExpandedRow(ExpandedRowContentComponent) {
|
22
21
|
return function (datagridState) {
|
23
22
|
var row = datagridState.row;
|
24
23
|
var _ref = row || {},
|
25
24
|
expandedContentHeight = _ref.expandedContentHeight;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
var toggleParentHoverClass = function toggleParentHoverClass(event, eventType) {
|
26
|
+
var _event$target;
|
27
|
+
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) {
|
28
|
+
var parentNode = event.target.parentNode.previousElementSibling;
|
29
|
+
if (eventType === 'enter') {
|
30
|
+
parentNode.classList.add("".concat(blockClass, "__expandable-row--hover"));
|
31
|
+
} else {
|
32
|
+
parentNode.classList.remove("".concat(blockClass, "__expandable-row--hover"));
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
36
|
+
return /*#__PURE__*/_react.default.createElement("tr", {
|
37
|
+
className: "".concat(blockClass, "__expanded-row"),
|
38
|
+
onMouseEnter: function onMouseEnter(event) {
|
39
|
+
return toggleParentHoverClass(event, 'enter');
|
40
|
+
},
|
41
|
+
onMouseLeave: function onMouseLeave(event) {
|
42
|
+
return toggleParentHoverClass(event);
|
43
|
+
}
|
44
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
32
45
|
className: "".concat(blockClass, "__expanded-row-content"),
|
33
46
|
style: {
|
34
47
|
height: expandedContentHeight ? expandedContentHeight : null
|
@@ -15,14 +15,13 @@ var _commonColumnIds = require("../common-column-ids");
|
|
15
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
16
16
|
var _settings = require("../../../settings");
|
17
17
|
var _excluded = ["children"];
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
// @flow
|
18
|
+
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; }
|
19
|
+
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) { (0, _defineProperty2.default)(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; } /**
|
20
|
+
* Copyright IBM Corp. 2020, 2023
|
21
|
+
*
|
22
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
23
|
+
* LICENSE file in the root directory of this source tree.
|
24
|
+
*/
|
26
25
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
27
26
|
var rowHeights = {
|
28
27
|
xs: 24,
|
@@ -37,7 +36,8 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
37
36
|
var _cx;
|
38
37
|
var row = datagridState.row,
|
39
38
|
rowSize = datagridState.rowSize,
|
40
|
-
withNestedRows = datagridState.withNestedRows
|
39
|
+
withNestedRows = datagridState.withNestedRows,
|
40
|
+
prepareRow = datagridState.prepareRow;
|
41
41
|
var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
|
42
42
|
var isExpanded = _ref.isExpanded,
|
43
43
|
subRows = _ref.subRows;
|
@@ -52,6 +52,9 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
52
52
|
};
|
53
53
|
var hoverHandler = function hoverHandler(event) {
|
54
54
|
var _hoverRow$style, _hoverRow$style2, _hoverRow$style3;
|
55
|
+
if (!withNestedRows) {
|
56
|
+
return;
|
57
|
+
}
|
55
58
|
var subRowCount = getVisibleNestedRowCount(row);
|
56
59
|
var totalNestedRowIndicatorHeight = (0, _layout.px)(subRowCount * rowHeights[rowSize]);
|
57
60
|
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
@@ -68,48 +71,50 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
68
71
|
el.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
69
72
|
});
|
70
73
|
};
|
71
|
-
|
72
|
-
|
74
|
+
var renderExpandedRow = function renderExpandedRow() {
|
75
|
+
if (row.isExpanded) {
|
76
|
+
var _row$RowExpansionRend;
|
77
|
+
prepareRow(row);
|
78
|
+
return row === null || row === void 0 || (_row$RowExpansionRend = row.RowExpansionRenderer) === null || _row$RowExpansionRend === void 0 ? void 0 : _row$RowExpansionRend.call(row, _objectSpread(_objectSpread({}, datagridState), {}, {
|
79
|
+
row: row
|
80
|
+
}));
|
81
|
+
}
|
82
|
+
return null;
|
83
|
+
};
|
84
|
+
var handleMouseLeave = function handleMouseLeave(event) {
|
85
|
+
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
86
|
+
hoverRow === null || hoverRow === void 0 || hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
87
|
+
};
|
88
|
+
var handleOnKeyUp = function handleOnKeyUp(event) {
|
89
|
+
if (!withNestedRows) {
|
90
|
+
return;
|
91
|
+
}
|
92
|
+
if (event.key === 'Enter' || event.key === 'Space') {
|
93
|
+
focusRemover();
|
94
|
+
hoverHandler(event);
|
95
|
+
}
|
96
|
+
};
|
97
|
+
var rowClassNames = (0, _classnames.default)("".concat(blockClass, "__carbon-row"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), (0, _defineProperty2.default)(_cx, "".concat(_settings.carbon.prefix, "--data-table--selected"), row.isSelected), _cx));
|
98
|
+
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_react2.TableRow, (0, _extends2.default)({
|
99
|
+
className: rowClassNames
|
73
100
|
}, row.getRowProps({
|
74
101
|
role: false
|
75
102
|
}), {
|
76
103
|
key: row.id,
|
77
|
-
onMouseEnter:
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
},
|
83
|
-
onMouseLeave: function onMouseLeave(event) {
|
84
|
-
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
85
|
-
hoverRow === null || hoverRow === void 0 || hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
86
|
-
},
|
87
|
-
onFocus: function onFocus(event) {
|
88
|
-
if (!withNestedRows) {
|
89
|
-
return;
|
90
|
-
}
|
91
|
-
hoverHandler(event);
|
92
|
-
},
|
93
|
-
onBlur: function onBlur() {
|
94
|
-
focusRemover();
|
95
|
-
},
|
96
|
-
onKeyUp: function onKeyUp(event) {
|
97
|
-
if (!withNestedRows) {
|
98
|
-
return;
|
99
|
-
}
|
100
|
-
if (event.key === 'Enter' || event.key === 'Space') {
|
101
|
-
focusRemover();
|
102
|
-
hoverHandler(event);
|
103
|
-
}
|
104
|
-
}
|
104
|
+
onMouseEnter: hoverHandler,
|
105
|
+
onMouseLeave: handleMouseLeave,
|
106
|
+
onFocus: hoverHandler,
|
107
|
+
onBlur: focusRemover,
|
108
|
+
onKeyUp: handleOnKeyUp
|
105
109
|
}), row.cells.map(function (cell, index) {
|
110
|
+
var _cell$column;
|
106
111
|
var cellProps = cell.getCellProps({
|
107
112
|
role: false
|
108
113
|
});
|
109
114
|
var children = cellProps.children,
|
110
115
|
restProps = (0, _objectWithoutProperties2.default)(cellProps, _excluded);
|
111
116
|
var content = children || /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, !row.isSkeleton && cell.render('Cell'), row.isSkeleton && /*#__PURE__*/_react.default.createElement(_react2.SkeletonText, null));
|
112
|
-
if (cell
|
117
|
+
if ((cell === null || cell === void 0 || (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : _cell$column.id) === _commonColumnIds.selectionColumnId) {
|
113
118
|
// directly render component without the wrapping TableCell
|
114
119
|
return cell.render('Cell', {
|
115
120
|
key: cell.column.id
|
@@ -120,7 +125,7 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
120
125
|
}, restProps, {
|
121
126
|
key: cell.column.id
|
122
127
|
}), content);
|
123
|
-
}));
|
128
|
+
})), renderExpandedRow());
|
124
129
|
};
|
125
130
|
var _default = DatagridRow;
|
126
131
|
exports.default = _default;
|
@@ -1,20 +1,19 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
6
5
|
value: true
|
7
6
|
});
|
8
7
|
exports.default = void 0;
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
10
|
-
var
|
11
|
-
var React = _interopRequireWildcard(require("react"));
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
12
11
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
13
12
|
var _icons = require("@carbon/react/icons");
|
14
13
|
var _classnames = _interopRequireDefault(require("classnames"));
|
15
14
|
var _settings = require("../../../settings");
|
16
|
-
|
17
|
-
|
15
|
+
var _utilities = require("@dnd-kit/utilities");
|
16
|
+
var _sortable = require("@dnd-kit/sortable");
|
18
17
|
// @flow
|
19
18
|
/*
|
20
19
|
* Licensed Materials - Property of IBM
|
@@ -24,160 +23,61 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
24
23
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
25
24
|
*/
|
26
25
|
|
27
|
-
// import { useDrag, useDrop } from 'react-dnd';
|
28
|
-
|
29
|
-
var useEffect = React.useEffect,
|
30
|
-
useRef = React.useRef,
|
31
|
-
useState = React.useState;
|
32
26
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
33
|
-
|
34
|
-
// const DRAG_TYPE = `${blockClass}__shared-ui-draggable-element`;
|
35
|
-
|
36
27
|
var DraggableElement = function DraggableElement(_ref) {
|
37
28
|
var _cx;
|
38
|
-
var
|
39
|
-
listData = _ref.listData,
|
29
|
+
var id = _ref.id,
|
40
30
|
children = _ref.children,
|
31
|
+
classList = _ref.classList,
|
41
32
|
disabled = _ref.disabled,
|
42
33
|
ariaLabel = _ref.ariaLabel,
|
43
|
-
onGrab = _ref.onGrab,
|
44
|
-
onArrowKeyDown = _ref.onArrowKeyDown,
|
45
|
-
isFocused = _ref.isFocused,
|
46
34
|
isSticky = _ref.isSticky,
|
47
|
-
selected = _ref.selected
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
// collect: (monitor) => ({
|
59
|
-
// isOver: !!monitor.isOver(),
|
60
|
-
// }),
|
61
|
-
// drop: (item) => {
|
62
|
-
// moveElement(item.index, index);
|
63
|
-
// },
|
64
|
-
// canDrop: () => !disabled,
|
65
|
-
// hover(item) {
|
66
|
-
// const dragIndex = item.index;
|
67
|
-
// const hoverIndex = index;
|
68
|
-
// // Don't replace items with themselves
|
69
|
-
// if (dragIndex === hoverIndex || disabled) {
|
70
|
-
// return;
|
71
|
-
// }
|
72
|
-
// // moveElement(dragIndex, hoverIndex);
|
73
|
-
// // Time to actually perform the action
|
74
|
-
// // Note: we're mutating the monitor item here!
|
75
|
-
// // Generally it's better to avoid mutations,
|
76
|
-
// // but it's good here for the sake of performance
|
77
|
-
// // to avoid expensive index searches.
|
78
|
-
// // eslint-disable-next-line no-param-reassign
|
79
|
-
// item.index = hoverIndex;
|
80
|
-
// },
|
81
|
-
// });
|
82
|
-
|
83
|
-
// const [{ isDragging }, drag, preview] = useDrag({
|
84
|
-
// type: DRAG_TYPE + type,
|
85
|
-
// item: { id, index },
|
86
|
-
// canDrag: () => !disabled,
|
87
|
-
// collect: (monitor) => ({
|
88
|
-
// isDragging: monitor.isDragging(),
|
89
|
-
// }),
|
90
|
-
// });
|
91
|
-
|
92
|
-
// Temporarily disable drag support because of commonjs support/issues with react-dnd in latest version
|
93
|
-
var _useState = useState(false),
|
94
|
-
_useState2 = (0, _slicedToArray2.default)(_useState, 1),
|
95
|
-
isDragging = _useState2[0];
|
96
|
-
var _useState3 = useState(false),
|
97
|
-
_useState4 = (0, _slicedToArray2.default)(_useState3, 1),
|
98
|
-
isOver = _useState4[0];
|
99
|
-
var preview = useRef();
|
100
|
-
var drag = useRef();
|
101
|
-
useEffect(function () {
|
102
|
-
if (isFocused && ref && ref.current) {
|
103
|
-
ref.current.focus();
|
104
|
-
}
|
105
|
-
}, [isFocused]);
|
106
|
-
var _useState5 = useState(false),
|
107
|
-
_useState6 = (0, _slicedToArray2.default)(_useState5, 2),
|
108
|
-
isGrabbed = _useState6[0],
|
109
|
-
setIsGrabbed = _useState6[1];
|
110
|
-
var _useState7 = useState(isFocused),
|
111
|
-
_useState8 = (0, _slicedToArray2.default)(_useState7, 2),
|
112
|
-
isFocusedOnItem = _useState8[0],
|
113
|
-
setIsFocusedOnItem = _useState8[1];
|
114
|
-
// drop(ref);
|
115
|
-
var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
35
|
+
selected = _ref.selected;
|
36
|
+
var _useSortable = (0, _sortable.useSortable)({
|
37
|
+
id: id
|
38
|
+
}),
|
39
|
+
attributes = _useSortable.attributes,
|
40
|
+
isDragging = _useSortable.isDragging,
|
41
|
+
listeners = _useSortable.listeners,
|
42
|
+
setNodeRef = _useSortable.setNodeRef,
|
43
|
+
transform = _useSortable.transform,
|
44
|
+
transition = _useSortable.transition;
|
45
|
+
var content = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
|
116
46
|
className: (0, _classnames.default)({
|
117
47
|
disabled: disabled
|
118
48
|
}, "".concat(blockClass, "__draggable-handleStyle"))
|
119
|
-
}, isSticky ? /*#__PURE__*/
|
49
|
+
}, isSticky ? /*#__PURE__*/_react.default.createElement(_icons.Locked, {
|
120
50
|
size: 16
|
121
|
-
}) : /*#__PURE__*/
|
51
|
+
}) : /*#__PURE__*/_react.default.createElement(_icons.Draggable, {
|
122
52
|
size: 16
|
123
53
|
})), children);
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
},
|
139
|
-
onKeyDown: function onKeyDown(e) {
|
140
|
-
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
141
|
-
onArrowKeyDown(e, isGrabbed, index);
|
142
|
-
}
|
143
|
-
},
|
144
|
-
onBlur: function onBlur(e) {
|
145
|
-
// handle when focus move to inner elements
|
146
|
-
setIsFocusedOnItem(e.currentTarget === e.target);
|
147
|
-
},
|
148
|
-
onFocus: function onFocus(e) {
|
149
|
-
// handle when focus move to li element
|
150
|
-
setIsFocusedOnItem(e.currentTarget === e.target);
|
151
|
-
}
|
152
|
-
}, /*#__PURE__*/React.createElement("span", {
|
54
|
+
var style = {
|
55
|
+
transform: _utilities.CSS.Transform.toString(transform),
|
56
|
+
transition: transition
|
57
|
+
};
|
58
|
+
return /*#__PURE__*/_react.default.createElement("li", (0, _extends2.default)({
|
59
|
+
className: (0, _classnames.default)(classList, "".concat(blockClass, "__draggable-handleHolder"), (_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__draggable-handleHolder--selected"), selected), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__draggable-handleHolder--sticky"), isSticky), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__draggable-handleHolder--dragging"), isDragging), _cx)),
|
60
|
+
id: id,
|
61
|
+
ref: setNodeRef,
|
62
|
+
style: style
|
63
|
+
}, attributes, listeners, {
|
64
|
+
disabled: disabled,
|
65
|
+
"aria-selected": selected,
|
66
|
+
role: "option"
|
67
|
+
}), /*#__PURE__*/_react.default.createElement("span", {
|
153
68
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
154
|
-
}, ariaLabel),
|
155
|
-
ref: preview,
|
156
|
-
className: "".concat(blockClass, "__draggable-handleHolder-droppable ").concat(blockClass, "__draggable-handleHolder-droppable--origin")
|
157
|
-
}, content) : /*#__PURE__*/React.createElement("div", {
|
158
|
-
ref: drag,
|
159
|
-
"aria-hidden": isFocused && isFocusedOnItem // if focus on li, hide the children from aria
|
160
|
-
,
|
69
|
+
}, ariaLabel), /*#__PURE__*/_react.default.createElement("div", {
|
161
70
|
className: (0, _classnames.default)((0, _defineProperty2.default)({}, "".concat(blockClass, "__draggable-handleStyle"), !disabled), ["".concat(blockClass, "__draggable-handleHolder-droppable")])
|
162
|
-
},
|
71
|
+
}, content));
|
163
72
|
};
|
164
73
|
DraggableElement.propTypes = {
|
165
74
|
ariaLabel: _propTypes.default.string.isRequired,
|
166
75
|
children: _propTypes.default.element.isRequired,
|
76
|
+
classList: _propTypes.default.string,
|
167
77
|
disabled: _propTypes.default.bool,
|
168
|
-
droppedLabel: _propTypes.default.string,
|
169
|
-
grabbedLabel: _propTypes.default.string,
|
170
78
|
id: _propTypes.default.string.isRequired,
|
171
|
-
index: _propTypes.default.number.isRequired,
|
172
|
-
isFocused: _propTypes.default.bool.isRequired,
|
173
79
|
isSticky: _propTypes.default.bool,
|
174
|
-
|
175
|
-
// moveElement: PropTypes.func.isRequired,
|
176
|
-
onArrowKeyDown: _propTypes.default.func.isRequired,
|
177
|
-
onGrab: _propTypes.default.func.isRequired,
|
178
|
-
positionLabel: _propTypes.default.string,
|
179
|
-
selected: _propTypes.default.bool,
|
180
|
-
type: _propTypes.default.string.isRequired
|
80
|
+
selected: _propTypes.default.bool
|
181
81
|
};
|
182
82
|
var _default = DraggableElement;
|
183
83
|
exports.default = _default;
|