@carbon/ibm-products 1.59.0 → 1.60.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +97 -65
- 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.css +53 -21
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +97 -65
- package/css/index.css.map +1 -1
- package/css/index.min.css +3 -3
- package/css/index.min.css.map +1 -1
- package/es/components/Checklist/ChecklistChart.js +2 -2
- package/es/components/Datagrid/Datagrid/Datagrid.js +2 -1
- package/es/components/Datagrid/Datagrid/DatagridContent.js +15 -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 +41 -33
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +13 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +3 -15
- package/es/components/Datagrid/Datagrid/DraggableElement.js +32 -135
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +14 -38
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +128 -40
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +7 -6
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +104 -18
- package/es/components/Datagrid/Datagrid/addons/Filtering/constants.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +37 -4
- package/es/components/Datagrid/useExpandedRow.js +1 -1
- package/es/components/Datagrid/useFiltering.js +4 -1
- package/es/components/Datagrid/useNestedRowExpander.js +22 -9
- package/es/components/Datagrid/useRowExpander.js +22 -9
- package/es/components/Datagrid/utils/DatagridPagination.js +1 -1
- package/es/components/Datagrid/utils/getArgTypes.js +12 -0
- 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/FilterSummary/FilterSummary.js +9 -3
- package/es/components/TagSet/TagSet.js +3 -7
- package/es/global/js/hooks/useWindowScroll.js +5 -0
- package/lib/components/Checklist/ChecklistChart.js +2 -2
- package/lib/components/Datagrid/Datagrid/Datagrid.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +14 -6
- 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 +41 -33
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +13 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +3 -15
- package/lib/components/Datagrid/Datagrid/DraggableElement.js +34 -140
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +17 -38
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +1 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +128 -47
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +7 -6
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterProvider.js +104 -24
- package/lib/components/Datagrid/Datagrid/addons/Filtering/constants.js +4 -2
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +36 -3
- package/lib/components/Datagrid/useExpandedRow.js +1 -1
- package/lib/components/Datagrid/useFiltering.js +4 -1
- package/lib/components/Datagrid/useNestedRowExpander.js +24 -9
- package/lib/components/Datagrid/useRowExpander.js +24 -9
- package/lib/components/Datagrid/utils/DatagridPagination.js +1 -1
- package/lib/components/Datagrid/utils/getArgTypes.js +12 -0
- 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/FilterSummary/FilterSummary.js +9 -10
- package/lib/components/TagSet/TagSet.js +2 -6
- package/lib/global/js/hooks/useWindowScroll.js +6 -0
- package/package.json +8 -7
- package/scss/components/Datagrid/_datagrid.scss +1 -1
- package/scss/components/Datagrid/styles/_datagrid.scss +5 -0
- package/scss/components/Datagrid/styles/_draggableElement.scss +44 -20
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +10 -0
- package/scss/components/Datagrid/styles/addons/_CustomizeColumnsTearsheet.scss +0 -1
@@ -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.
|
@@ -24,7 +24,9 @@ import { useMultipleKeyTracking } from '../../DataSpreadsheet/hooks';
|
|
24
24
|
import FilterPanel from './addons/Filtering/FilterPanel';
|
25
25
|
import { FilterSummary } from '../../FilterSummary';
|
26
26
|
import { FilterContext } from './addons/Filtering';
|
27
|
-
import { CLEAR_FILTERS } from './addons/Filtering/constants';
|
27
|
+
import { CLEAR_FILTERS, CLEAR_SINGLE_FILTER } from './addons/Filtering/constants';
|
28
|
+
import { useSubscribeToEventEmitter } from './addons/Filtering/hooks';
|
29
|
+
import { clearSingleFilter } from './addons/Filtering/FilterProvider';
|
28
30
|
var TableContainer = DataTable.TableContainer,
|
29
31
|
Table = DataTable.Table;
|
30
32
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
@@ -62,8 +64,11 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
62
64
|
DatagridActions = datagridState.DatagridActions,
|
63
65
|
totalColumnsWidth = datagridState.totalColumnsWidth,
|
64
66
|
gridRef = datagridState.gridRef,
|
65
|
-
|
66
|
-
|
67
|
+
setAllFilters = datagridState.setAllFilters,
|
68
|
+
state = datagridState.state,
|
69
|
+
page = datagridState.page,
|
70
|
+
rows = datagridState.rows;
|
71
|
+
var contentRows = DatagridPagination && page || rows;
|
67
72
|
var gridAreaRef = useRef();
|
68
73
|
var multiKeyTrackingRef = useRef();
|
69
74
|
useClickOutside(gridAreaRef, function (target) {
|
@@ -101,8 +106,8 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
101
106
|
return handleGridFocus(inlineEditState, dispatch);
|
102
107
|
} : null,
|
103
108
|
title: title
|
104
|
-
}), !withVirtualScroll
|
105
|
-
rows:
|
109
|
+
}), !withVirtualScroll && /*#__PURE__*/React.createElement(DatagridHead, datagridState), /*#__PURE__*/React.createElement(DatagridBody, _extends({}, datagridState, {
|
110
|
+
rows: contentRows
|
106
111
|
})));
|
107
112
|
};
|
108
113
|
var _useMultipleKeyTracki = useMultipleKeyTracking({
|
@@ -125,6 +130,9 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
125
130
|
gridElement.style.setProperty("--".concat(blockClass, "--grid-header-height"), px((tableHeader === null || tableHeader === void 0 ? void 0 : tableHeader.clientHeight) || 0));
|
126
131
|
}
|
127
132
|
}, [withInlineEdit, tableId, totalColumnsWidth, datagridState, gridActive]);
|
133
|
+
useSubscribeToEventEmitter(CLEAR_SINGLE_FILTER, function (id) {
|
134
|
+
return clearSingleFilter(id, setAllFilters, state);
|
135
|
+
});
|
128
136
|
var renderFilterSummary = function renderFilterSummary() {
|
129
137
|
return state.filters.length > 0 && /*#__PURE__*/React.createElement(FilterSummary, {
|
130
138
|
className: "".concat(blockClass, "__filter-summary"),
|
@@ -153,7 +161,7 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
153
161
|
}, renderTable()) : withVirtualScroll ? /*#__PURE__*/React.createElement("div", {
|
154
162
|
className: "".concat(blockClass, "__virtualScrollContainer"),
|
155
163
|
ref: gridRef
|
156
|
-
}, renderTable()) : renderTable()))), (
|
164
|
+
}, renderTable()) : renderTable()))), (contentRows === null || contentRows === void 0 ? void 0 : contentRows.length) > 0 && !isFetching && DatagridPagination && /*#__PURE__*/React.createElement(DatagridPagination, datagridState), CustomizeColumnsTearsheet && /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, {
|
157
165
|
instance: datagridState
|
158
166
|
}));
|
159
167
|
};
|
@@ -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 { DataTable } from 'carbon-components-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 TableBody = DataTable.TableBody,
|
15
15
|
TableRow = DataTable.TableRow,
|
@@ -33,12 +33,13 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
|
|
33
33
|
action: emptyStateAction,
|
34
34
|
link: emptyStateLink
|
35
35
|
};
|
36
|
+
var validEmptyStates = ['error', 'noData', 'notFound'];
|
36
37
|
return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
|
37
38
|
role: false
|
38
39
|
}), {
|
39
40
|
className: "".concat(blockClass, "__empty-state-body")
|
40
41
|
}), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
|
41
42
|
colSpan: headers.length
|
42
|
-
}, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, emptyStateProps), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, emptyStateProps), emptyStateType === 'notFound' && /*#__PURE__*/React.createElement(NotFoundEmptyState, emptyStateProps))));
|
43
|
+
}, 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))));
|
43
44
|
};
|
44
45
|
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, _event$target$parentN;
|
20
|
+
if (event !== null && event !== void 0 && (_event$target = event.target) !== null && _event$target !== void 0 && (_event$target$parentN = _event$target.parentNode) !== null && _event$target$parentN !== void 0 && _event$target$parentN.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,6 +2,8 @@ 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
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
5
7
|
/*
|
6
8
|
* Licensed Materials - Property of IBM
|
7
9
|
* 5724-Q36
|
@@ -32,7 +34,8 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
32
34
|
var _cx;
|
33
35
|
var row = datagridState.row,
|
34
36
|
rowSize = datagridState.rowSize,
|
35
|
-
withNestedRows = datagridState.withNestedRows
|
37
|
+
withNestedRows = datagridState.withNestedRows,
|
38
|
+
prepareRow = datagridState.prepareRow;
|
36
39
|
var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
|
37
40
|
var isExpanded = _ref.isExpanded,
|
38
41
|
subRows = _ref.subRows;
|
@@ -47,6 +50,9 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
47
50
|
};
|
48
51
|
var hoverHandler = function hoverHandler(event) {
|
49
52
|
var _hoverRow$style, _hoverRow$style2, _hoverRow$style3;
|
53
|
+
if (!withNestedRows) {
|
54
|
+
return;
|
55
|
+
}
|
50
56
|
var subRowCount = getVisibleNestedRowCount(row);
|
51
57
|
var totalNestedRowIndicatorHeight = px(subRowCount * rowHeights[rowSize]);
|
52
58
|
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
@@ -63,48 +69,50 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
63
69
|
el.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
64
70
|
});
|
65
71
|
};
|
66
|
-
|
67
|
-
|
72
|
+
var renderExpandedRow = function renderExpandedRow() {
|
73
|
+
if (row.isExpanded) {
|
74
|
+
var _row$RowExpansionRend;
|
75
|
+
prepareRow(row);
|
76
|
+
return row === null || row === void 0 ? void 0 : (_row$RowExpansionRend = row.RowExpansionRenderer) === null || _row$RowExpansionRend === void 0 ? void 0 : _row$RowExpansionRend.call(row, _objectSpread(_objectSpread({}, datagridState), {}, {
|
77
|
+
row: row
|
78
|
+
}));
|
79
|
+
}
|
80
|
+
return null;
|
81
|
+
};
|
82
|
+
var handleMouseLeave = function handleMouseLeave(event) {
|
83
|
+
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
84
|
+
hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
85
|
+
};
|
86
|
+
var handleOnKeyUp = function handleOnKeyUp(event) {
|
87
|
+
if (!withNestedRows) {
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
if (event.key === 'Enter' || event.key === 'Space') {
|
91
|
+
focusRemover();
|
92
|
+
hoverHandler(event);
|
93
|
+
}
|
94
|
+
};
|
95
|
+
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));
|
96
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TableRow, _extends({
|
97
|
+
className: rowClassNames
|
68
98
|
}, row.getRowProps({
|
69
99
|
role: false
|
70
100
|
}), {
|
71
101
|
key: row.id,
|
72
|
-
onMouseEnter:
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
},
|
78
|
-
onMouseLeave: function onMouseLeave(event) {
|
79
|
-
var hoverRow = event.target.closest(".".concat(blockClass, "__carbon-row-expanded"));
|
80
|
-
hoverRow === null || hoverRow === void 0 ? void 0 : hoverRow.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
81
|
-
},
|
82
|
-
onFocus: function onFocus(event) {
|
83
|
-
if (!withNestedRows) {
|
84
|
-
return;
|
85
|
-
}
|
86
|
-
hoverHandler(event);
|
87
|
-
},
|
88
|
-
onBlur: function onBlur() {
|
89
|
-
focusRemover();
|
90
|
-
},
|
91
|
-
onKeyUp: function onKeyUp(event) {
|
92
|
-
if (!withNestedRows) {
|
93
|
-
return;
|
94
|
-
}
|
95
|
-
if (event.key === 'Enter' || event.key === 'Space') {
|
96
|
-
focusRemover();
|
97
|
-
hoverHandler(event);
|
98
|
-
}
|
99
|
-
}
|
102
|
+
onMouseEnter: hoverHandler,
|
103
|
+
onMouseLeave: handleMouseLeave,
|
104
|
+
onFocus: hoverHandler,
|
105
|
+
onBlur: focusRemover,
|
106
|
+
onKeyUp: handleOnKeyUp
|
100
107
|
}), row.cells.map(function (cell, index) {
|
108
|
+
var _cell$column;
|
101
109
|
var cellProps = cell.getCellProps({
|
102
110
|
role: false
|
103
111
|
});
|
104
112
|
var children = cellProps.children,
|
105
113
|
restProps = _objectWithoutProperties(cellProps, _excluded);
|
106
114
|
var content = children || /*#__PURE__*/React.createElement(React.Fragment, null, !row.isSkeleton && cell.render('Cell'), row.isSkeleton && /*#__PURE__*/React.createElement(SkeletonText, null));
|
107
|
-
if (cell
|
115
|
+
if ((cell === null || cell === void 0 ? void 0 : (_cell$column = cell.column) === null || _cell$column === void 0 ? void 0 : _cell$column.id) === selectionColumnId) {
|
108
116
|
// directly render component without the wrapping TableCell
|
109
117
|
return cell.render('Cell', {
|
110
118
|
key: cell.column.id
|
@@ -115,6 +123,6 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
115
123
|
}, restProps, {
|
116
124
|
key: cell.column.id
|
117
125
|
}), content);
|
118
|
-
}));
|
126
|
+
})), renderExpandedRow());
|
119
127
|
};
|
120
128
|
export default DatagridRow;
|
@@ -50,11 +50,23 @@ var SelectAll = function SelectAll(datagridState) {
|
|
50
50
|
var _getProps = getProps(),
|
51
51
|
onChange = _getProps.onChange,
|
52
52
|
selectProps = _objectWithoutProperties(_getProps, _excluded);
|
53
|
+
var _ref = selectProps || {},
|
54
|
+
indeterminate = _ref.indeterminate;
|
55
|
+
var handleSelectAllChange = function handleSelectAllChange(event) {
|
56
|
+
if (indeterminate) {
|
57
|
+
return onChange === null || onChange === void 0 ? void 0 : onChange({
|
58
|
+
target: {
|
59
|
+
checked: false
|
60
|
+
}
|
61
|
+
});
|
62
|
+
}
|
63
|
+
return onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
64
|
+
};
|
53
65
|
return /*#__PURE__*/React.createElement("div", {
|
54
66
|
className: cx("".concat(blockClass, "__head-select-all"), "".concat(blockClass, "__checkbox-cell"), _defineProperty({}, "".concat(blockClass, "__checkbox-cell-sticky-left"), isFirstColumnStickyLeft && windowSize > 671))
|
55
67
|
}, /*#__PURE__*/React.createElement(TableSelectAll, _extends({}, selectProps, {
|
56
68
|
name: "".concat(tableId, "-select-all-checkbox-name"),
|
57
|
-
onSelect:
|
69
|
+
onSelect: handleSelectAllChange,
|
58
70
|
disabled: isFetching || selectProps.disabled,
|
59
71
|
id: "".concat(tableId, "-select-all-checkbox-id")
|
60
72
|
})));
|
@@ -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,
|
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.
|
@@ -70,20 +70,8 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
70
70
|
menuOptionsClass: "".concat(blockClass, "__button-menu-options"),
|
71
71
|
flipped: true
|
72
72
|
}, toolbarBatchActions && toolbarBatchActions.map(function (batchAction, index) {
|
73
|
-
if (index < 2) {
|
74
|
-
|
75
|
-
return /*#__PURE__*/React.createElement(ButtonMenuItem, {
|
76
|
-
key: "".concat(batchAction.label, "-").concat(index),
|
77
|
-
itemText: batchAction.label,
|
78
|
-
onClick: function onClick() {
|
79
|
-
batchAction.onClick();
|
80
|
-
if (batchAction.type === 'select_all') {
|
81
|
-
toggleAllRowsSelected(true);
|
82
|
-
}
|
83
|
-
}
|
84
|
-
});
|
85
|
-
}
|
86
|
-
return null;
|
73
|
+
if (index < 2 && !displayAllInMenu) {
|
74
|
+
return;
|
87
75
|
}
|
88
76
|
return /*#__PURE__*/React.createElement(ButtonMenuItem, {
|
89
77
|
key: "".concat(batchAction.label, "-").concat(index),
|
@@ -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,166 +8,63 @@ 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
13
|
import { Draggable16, Locked16 } from '@carbon/icons-react';
|
14
|
-
import { useDrag, useDrop } from 'react-dnd';
|
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
|
-
var DRAG_TYPE = "".concat(blockClass, "__shared-ui-draggable-element");
|
22
19
|
var DraggableElement = function DraggableElement(_ref) {
|
23
20
|
var _cx;
|
24
21
|
var id = _ref.id,
|
25
|
-
index = _ref.index,
|
26
|
-
listData = _ref.listData,
|
27
22
|
children = _ref.children,
|
28
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
positionLabel = _ref$positionLabel === void 0 ? 'Current position {index} of {total}' : _ref$positionLabel,
|
39
|
-
_ref$grabbedLabel = _ref.grabbedLabel,
|
40
|
-
grabbedLabel = _ref$grabbedLabel === void 0 ? '{itemName} grabbed.' : _ref$grabbedLabel,
|
41
|
-
_ref$droppedLabel = _ref.droppedLabel,
|
42
|
-
droppedLabel = _ref$droppedLabel === void 0 ? '{itemName} dropped.' : _ref$droppedLabel;
|
43
|
-
var ref = useRef();
|
44
|
-
var _useDrop = useDrop({
|
45
|
-
accept: DRAG_TYPE + type,
|
46
|
-
collect: function collect(monitor) {
|
47
|
-
return {
|
48
|
-
isOver: !!monitor.isOver()
|
49
|
-
};
|
50
|
-
},
|
51
|
-
drop: function drop(item) {
|
52
|
-
moveElement(item.index, index);
|
53
|
-
},
|
54
|
-
canDrop: function canDrop() {
|
55
|
-
return !disabled;
|
56
|
-
},
|
57
|
-
hover: function hover(item) {
|
58
|
-
var dragIndex = item.index;
|
59
|
-
var hoverIndex = index;
|
60
|
-
// Don't replace items with themselves
|
61
|
-
if (dragIndex === hoverIndex || disabled) {
|
62
|
-
return;
|
63
|
-
}
|
64
|
-
moveElement(dragIndex, hoverIndex);
|
65
|
-
// Time to actually perform the action
|
66
|
-
// Note: we're mutating the monitor item here!
|
67
|
-
// Generally it's better to avoid mutations,
|
68
|
-
// but it's good here for the sake of performance
|
69
|
-
// to avoid expensive index searches.
|
70
|
-
// eslint-disable-next-line no-param-reassign
|
71
|
-
item.index = hoverIndex;
|
72
|
-
}
|
27
|
+
selected = _ref.selected;
|
28
|
+
var _useSortable = useSortable({
|
29
|
+
id: id
|
73
30
|
}),
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
id: id,
|
81
|
-
index: index
|
82
|
-
},
|
83
|
-
canDrag: function canDrag() {
|
84
|
-
return !disabled;
|
85
|
-
},
|
86
|
-
collect: function collect(monitor) {
|
87
|
-
return {
|
88
|
-
isDragging: monitor.isDragging()
|
89
|
-
};
|
90
|
-
}
|
91
|
-
}),
|
92
|
-
_useDrag2 = _slicedToArray(_useDrag, 3),
|
93
|
-
isDragging = _useDrag2[0].isDragging,
|
94
|
-
drag = _useDrag2[1],
|
95
|
-
preview = _useDrag2[2];
|
96
|
-
useEffect(function () {
|
97
|
-
if (isFocused && ref && ref.current) {
|
98
|
-
ref.current.focus();
|
99
|
-
}
|
100
|
-
}, [isFocused]);
|
101
|
-
var _useState = useState(false),
|
102
|
-
_useState2 = _slicedToArray(_useState, 2),
|
103
|
-
isGrabbed = _useState2[0],
|
104
|
-
setIsGrabbed = _useState2[1];
|
105
|
-
var _useState3 = useState(isFocused),
|
106
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
107
|
-
isFocusedOnItem = _useState4[0],
|
108
|
-
setIsFocusedOnItem = _useState4[1];
|
109
|
-
drop(ref);
|
31
|
+
attributes = _useSortable.attributes,
|
32
|
+
isDragging = _useSortable.isDragging,
|
33
|
+
listeners = _useSortable.listeners,
|
34
|
+
setNodeRef = _useSortable.setNodeRef,
|
35
|
+
transform = _useSortable.transform,
|
36
|
+
transition = _useSortable.transition;
|
110
37
|
var content = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
111
38
|
className: cx({
|
112
39
|
disabled: disabled
|
113
40
|
}, "".concat(blockClass, "__draggable-handleStyle"))
|
114
41
|
}, isSticky ? /*#__PURE__*/React.createElement(Locked16, null) : /*#__PURE__*/React.createElement(Draggable16, null)), children);
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
},
|
130
|
-
onKeyDown: function onKeyDown(e) {
|
131
|
-
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
|
132
|
-
onArrowKeyDown(e, isGrabbed, index);
|
133
|
-
}
|
134
|
-
},
|
135
|
-
onBlur: function onBlur(e) {
|
136
|
-
// handle when focus move to inner elements
|
137
|
-
setIsFocusedOnItem(e.currentTarget === e.target);
|
138
|
-
},
|
139
|
-
onFocus: function onFocus(e) {
|
140
|
-
// handle when focus move to li element
|
141
|
-
setIsFocusedOnItem(e.currentTarget === e.target);
|
142
|
-
}
|
143
|
-
}, /*#__PURE__*/React.createElement("span", {
|
42
|
+
var style = {
|
43
|
+
transform: CSS.Transform.toString(transform),
|
44
|
+
transition: transition
|
45
|
+
};
|
46
|
+
return /*#__PURE__*/React.createElement("li", _extends({
|
47
|
+
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)),
|
48
|
+
id: id,
|
49
|
+
ref: setNodeRef,
|
50
|
+
style: style
|
51
|
+
}, attributes, listeners, {
|
52
|
+
disabled: disabled,
|
53
|
+
"aria-selected": selected,
|
54
|
+
role: "option"
|
55
|
+
}), /*#__PURE__*/React.createElement("span", {
|
144
56
|
className: "".concat(blockClass, "__shared-ui--assistive-text")
|
145
|
-
}, ariaLabel),
|
146
|
-
ref: preview,
|
147
|
-
className: "".concat(blockClass, "__draggable-handleHolder-droppable ").concat(blockClass, "__draggable-handleHolder-droppable--origin")
|
148
|
-
}, content) : /*#__PURE__*/React.createElement("div", {
|
149
|
-
ref: drag,
|
150
|
-
"aria-hidden": isFocused && isFocusedOnItem // if focus on li, hide the children from aria
|
151
|
-
,
|
57
|
+
}, ariaLabel), /*#__PURE__*/React.createElement("div", {
|
152
58
|
className: cx(_defineProperty({}, "".concat(blockClass, "__draggable-handleStyle"), !disabled), ["".concat(blockClass, "__draggable-handleHolder-droppable")])
|
153
|
-
},
|
59
|
+
}, content));
|
154
60
|
};
|
155
61
|
DraggableElement.propTypes = {
|
156
62
|
ariaLabel: PropTypes.string.isRequired,
|
157
63
|
children: PropTypes.element.isRequired,
|
64
|
+
classList: PropTypes.string,
|
158
65
|
disabled: PropTypes.bool,
|
159
|
-
droppedLabel: PropTypes.string,
|
160
|
-
grabbedLabel: PropTypes.string,
|
161
66
|
id: PropTypes.string.isRequired,
|
162
|
-
index: PropTypes.number.isRequired,
|
163
|
-
isFocused: PropTypes.bool.isRequired,
|
164
67
|
isSticky: PropTypes.bool,
|
165
|
-
|
166
|
-
moveElement: PropTypes.func.isRequired,
|
167
|
-
onArrowKeyDown: PropTypes.func.isRequired,
|
168
|
-
onGrab: PropTypes.func.isRequired,
|
169
|
-
positionLabel: PropTypes.string,
|
170
|
-
selected: PropTypes.bool,
|
171
|
-
type: PropTypes.string.isRequired
|
68
|
+
selected: PropTypes.bool
|
172
69
|
};
|
173
70
|
export default DraggableElement;
|
@@ -1,32 +1,21 @@
|
|
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,
|
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.
|
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-components-react';
|
15
13
|
import update from 'immutability-helper';
|
16
14
|
import { pkg } from '../../../../../settings';
|
17
15
|
import classNames 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,36 +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
|
-
setFocusIndex = _React$useState4[1];
|
47
|
-
var moveElement = React.useCallback(function (dragIndex, hoverIndex) {
|
48
|
-
var dragCard = columns[dragIndex];
|
34
|
+
// after a drag/drop action set the columns
|
35
|
+
var moveElement = React.useCallback(function (from, to) {
|
36
|
+
var fromCol = columns[from];
|
49
37
|
setColumnsObject(update(columns, {
|
50
|
-
$splice: [[
|
38
|
+
$splice: [[from, 1], [to, 0, fromCol]]
|
51
39
|
}));
|
52
40
|
}, [columns, setColumnsObject]);
|
53
41
|
return /*#__PURE__*/React.createElement("div", {
|
54
|
-
className: "".concat(blockClass, "__customize-columns-column-list")
|
55
|
-
|
56
|
-
backend: HTML5Backend
|
42
|
+
className: "".concat(blockClass, "__customize-columns-column-list"),
|
43
|
+
ref: listRef
|
57
44
|
}, /*#__PURE__*/React.createElement("ol", {
|
58
45
|
className: "".concat(blockClass, "__customize-columns-column-list--focus"),
|
59
46
|
role: "listbox",
|
60
47
|
"aria-describedby": "".concat(blockClass, "__customize-columns--instructions"),
|
61
|
-
onKeyDown: function onKeyDown(e) {
|
62
|
-
var nextIndex = getNextIndex(columns, focusIndex, e.key);
|
63
|
-
if (nextIndex >= 0) {
|
64
|
-
setFocusIndex(nextIndex);
|
65
|
-
e.preventDefault();
|
66
|
-
e.stopPropagation();
|
67
|
-
}
|
68
|
-
},
|
69
48
|
tabIndex: 0
|
70
49
|
}, /*#__PURE__*/React.createElement("span", {
|
71
50
|
"aria-live": "assertive",
|
@@ -87,16 +66,13 @@ var Columns = function Columns(_ref) {
|
|
87
66
|
id: "".concat(blockClass, "__customization-column-select-all"),
|
88
67
|
labelText: selectAllLabel
|
89
68
|
})), /*#__PURE__*/React.createElement(DraggableItemsList, {
|
69
|
+
id: listId.current,
|
90
70
|
columns: columns,
|
91
71
|
filterString: filterString,
|
92
|
-
focusIndex: focusIndex,
|
93
|
-
getNextIndex: getNextIndex,
|
94
72
|
moveElement: moveElement,
|
95
|
-
onSelectColumn: onSelectColumn,
|
96
73
|
setAriaRegionText: setAriaRegionText,
|
97
|
-
|
98
|
-
|
99
|
-
}))));
|
74
|
+
onSelectColumn: onSelectColumn
|
75
|
+
})));
|
100
76
|
};
|
101
77
|
Columns.propTypes = {
|
102
78
|
assistiveTextDisabledInstructionsLabel: PropTypes.string,
|
package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js
CHANGED
@@ -75,6 +75,7 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
75
75
|
isDirty = _useState10[0],
|
76
76
|
setIsDirty = _useState10[1];
|
77
77
|
var onRequestClose = function onRequestClose() {
|
78
|
+
setColumnObjects(columnDefinitions);
|
78
79
|
setIsTearsheetOpen(false);
|
79
80
|
};
|
80
81
|
var onRequestSubmit = function onRequestSubmit() {
|