@carbon/ibm-products 1.61.0 → 1.62.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +154 -79
- 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 +1753 -0
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +3 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +154 -79
- 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 +154 -79
- 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/Coachmark/Coachmark.js +17 -5
- package/es/components/Coachmark/CoachmarkDragbar.js +12 -5
- package/es/components/Coachmark/CoachmarkHeader.js +2 -1
- package/es/components/Coachmark/CoachmarkOverlay.js +105 -9
- package/es/components/CoachmarkBeacon/CoachmarkBeacon.js +5 -2
- package/es/components/CoachmarkFixed/CoachmarkFixed.js +26 -6
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +28 -3
- package/es/components/CoachmarkStack/CoachmarkStack.js +19 -4
- package/es/components/CoachmarkStack/CoachmarkStackHome.js +45 -11
- package/es/components/Datagrid/Datagrid/DatagridContent.js +12 -9
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +4 -4
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +45 -73
- package/es/components/Datagrid/Datagrid/DatagridRefBody.js +4 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +5 -2
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +12 -11
- package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +29 -23
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +18 -18
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +73 -24
- package/es/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
- package/es/components/Datagrid/useActionsColumn.js +9 -9
- package/es/components/Datagrid/useColumnCenterAlign.js +6 -6
- package/es/components/Datagrid/useColumnRightAlign.js +6 -6
- package/es/components/Datagrid/useDatagrid.js +13 -1
- package/es/components/Datagrid/useFlexResize.js +19 -9
- package/es/components/Datagrid/useInfiniteScroll.js +10 -9
- package/es/components/Datagrid/useNestedRowExpander.js +10 -1
- package/es/components/Datagrid/useOnRowClick.js +6 -7
- package/es/components/Datagrid/useParentDimensions.js +6 -6
- package/es/components/Datagrid/useResizeTable.js +7 -7
- package/es/components/Datagrid/useRowExpander.js +11 -1
- package/es/components/Datagrid/useSelectAllToggle.js +2 -2
- package/es/components/Datagrid/useSelectRows.js +31 -21
- package/es/components/Datagrid/useSkeletonRows.js +6 -6
- package/es/components/Datagrid/useSortableColumns.js +5 -6
- package/es/components/Datagrid/useStickyColumn.js +13 -6
- package/es/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -0
- package/es/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -0
- package/es/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -0
- package/es/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -0
- package/es/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -0
- package/es/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -0
- package/es/components/EmptyStates/assets/ErrorIllustration.js +6 -4
- package/es/components/EmptyStates/assets/NoDataIllustration.js +6 -4
- package/es/components/EmptyStates/assets/NoTagsIllustration.js +6 -4
- package/es/components/EmptyStates/assets/NotFoundIllustration.js +6 -4
- package/es/components/EmptyStates/assets/NotificationsIllustration.js +6 -4
- package/es/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -4
- package/es/components/Guidebanner/Guidebanner.js +3 -3
- package/es/components/Guidebanner/GuidebannerElement.js +9 -3
- package/es/components/Guidebanner/GuidebannerElementButton.js +9 -4
- package/es/components/Guidebanner/GuidebannerElementLink.js +9 -3
- package/es/components/InlineTip/InlineTipButton.js +7 -0
- package/es/components/InlineTip/InlineTipLink.js +7 -0
- package/es/components/index.js +2 -2
- package/es/global/js/hooks/index.js +3 -2
- package/es/global/js/hooks/usePrefix.js +11 -0
- package/es/global/js/package-settings.js +6 -2
- package/lib/components/Coachmark/Coachmark.js +16 -4
- package/lib/components/Coachmark/CoachmarkDragbar.js +12 -5
- package/lib/components/Coachmark/CoachmarkHeader.js +2 -1
- package/lib/components/Coachmark/CoachmarkOverlay.js +105 -8
- package/lib/components/CoachmarkBeacon/CoachmarkBeacon.js +5 -2
- package/lib/components/CoachmarkFixed/CoachmarkFixed.js +25 -5
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +28 -3
- package/lib/components/CoachmarkStack/CoachmarkStack.js +18 -3
- package/lib/components/CoachmarkStack/CoachmarkStackHome.js +44 -10
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +12 -9
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +4 -4
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +44 -80
- package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +4 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +5 -2
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +6 -4
- package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +4 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +29 -23
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +12 -12
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +75 -33
- package/lib/components/Datagrid/Datagrid.stories/StickyActionsColumnStory.js +1 -1
- package/lib/components/Datagrid/useActionsColumn.js +9 -12
- package/lib/components/Datagrid/useDatagrid.js +13 -1
- package/lib/components/Datagrid/useFlexResize.js +19 -9
- package/lib/components/Datagrid/useInfiniteScroll.js +9 -9
- package/lib/components/Datagrid/useNestedRowExpander.js +10 -9
- package/lib/components/Datagrid/useOnRowClick.js +6 -7
- package/lib/components/Datagrid/useParentDimensions.js +5 -6
- package/lib/components/Datagrid/useResizeTable.js +6 -7
- package/lib/components/Datagrid/useRowExpander.js +11 -9
- package/lib/components/Datagrid/useSelectAllToggle.js +2 -2
- package/lib/components/Datagrid/useSelectRows.js +31 -21
- package/lib/components/Datagrid/useSkeletonRows.js +6 -6
- package/lib/components/Datagrid/useSortableColumns.js +5 -6
- package/lib/components/Datagrid/useStickyColumn.js +8 -0
- package/lib/components/EmptyStates/ErrorEmptyState/ErrorEmptyState.js +1 -0
- package/lib/components/EmptyStates/NoDataEmptyState/NoDataEmptyState.js +1 -0
- package/lib/components/EmptyStates/NoTagsEmptyState/NoTagsEmptyState.js +1 -0
- package/lib/components/EmptyStates/NotFoundEmptyState/NotFoundEmptyState.js +1 -0
- package/lib/components/EmptyStates/NotificationsEmptyState/NotificationsEmptyState.js +1 -0
- package/lib/components/EmptyStates/UnauthorizedEmptyState/UnauthorizedEmptyState.js +1 -0
- package/lib/components/EmptyStates/assets/ErrorIllustration.js +6 -4
- package/lib/components/EmptyStates/assets/NoDataIllustration.js +6 -4
- package/lib/components/EmptyStates/assets/NoTagsIllustration.js +6 -4
- package/lib/components/EmptyStates/assets/NotFoundIllustration.js +6 -4
- package/lib/components/EmptyStates/assets/NotificationsIllustration.js +6 -4
- package/lib/components/EmptyStates/assets/UnauthorizedIllustration.js +6 -4
- package/lib/components/Guidebanner/Guidebanner.js +3 -3
- package/lib/components/Guidebanner/GuidebannerElement.js +8 -1
- package/lib/components/Guidebanner/GuidebannerElementButton.js +8 -1
- package/lib/components/Guidebanner/GuidebannerElementLink.js +8 -1
- package/lib/components/InlineTip/InlineTipButton.js +8 -1
- package/lib/components/InlineTip/InlineTipLink.js +8 -1
- package/lib/components/index.js +30 -0
- package/lib/global/js/hooks/index.js +8 -1
- package/lib/global/js/hooks/usePrefix.js +19 -0
- package/lib/global/js/package-settings.js +6 -2
- package/package.json +2 -2
- package/scss/components/Checklist/_checklist.scss +13 -25
- package/scss/components/Coachmark/styles/_coachmark-dragbar.scss +1 -45
- package/scss/components/Coachmark/styles/_coachmark-header.scss +0 -33
- package/scss/components/Coachmark/styles/_coachmark-overlay.scss +113 -5
- package/scss/components/Coachmark/styles/_coachmark-tagline.scss +18 -0
- package/scss/components/CoachmarkBeacon/_coachmark-beacon.scss +16 -13
- package/scss/components/CoachmarkOverlayElement/_coachmark-overlay-element.scss +2 -0
- package/scss/components/CoachmarkOverlayElements/_coachmark-overlay-elements.scss +1 -0
- package/scss/components/CoachmarkStack/_coachmark-stack.scss +3 -0
- package/scss/components/Datagrid/_storybook-styles.scss +15 -0
- package/scss/components/Datagrid/styles/_datagrid.scss +31 -5
- package/scss/components/Datagrid/styles/_useNestedRows.scss +1 -1
- package/scss/components/_index-released-only.scss +1 -0
@@ -1,3 +1,4 @@
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
4
|
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; }
|
@@ -9,24 +10,20 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
9
10
|
* LICENSE file in the root directory of this source tree.
|
10
11
|
*/
|
11
12
|
|
13
|
+
import { pkg } from '../../../../settings';
|
12
14
|
var COLUMN_RESIZE_START = 'columnStartResizing';
|
13
15
|
var COLUMN_RESIZING = 'columnResizing';
|
14
16
|
var COLUMN_RESIZE_END = 'columnDoneResizing';
|
15
17
|
var INIT = 'init';
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
payload: {
|
20
|
-
headerId: headerId
|
21
|
-
}
|
22
|
-
});
|
23
|
-
};
|
24
|
-
export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId) {
|
18
|
+
var TOGGLE_ROW_SELECTED = 'toggleRowSelected';
|
19
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
|
+
export var handleColumnResizeEndEvent = function handleColumnResizeEndEvent(dispatch, onColResizeEnd, headerId, isKeyEvent) {
|
25
21
|
dispatch({
|
26
22
|
type: COLUMN_RESIZE_END,
|
27
23
|
payload: {
|
28
24
|
onColResizeEnd: onColResizeEnd,
|
29
|
-
headerId: headerId
|
25
|
+
headerId: headerId,
|
26
|
+
isKeyEvent: isKeyEvent
|
30
27
|
}
|
31
28
|
});
|
32
29
|
};
|
@@ -50,8 +47,43 @@ export var handleColumnResizingEvent = function handleColumnResizingEvent(dispat
|
|
50
47
|
}
|
51
48
|
});
|
52
49
|
};
|
50
|
+
export var handleToggleRowSelected = function handleToggleRowSelected(dispatch, rowData, isChecked) {
|
51
|
+
return dispatch({
|
52
|
+
type: TOGGLE_ROW_SELECTED,
|
53
|
+
payload: {
|
54
|
+
rowData: rowData,
|
55
|
+
isChecked: isChecked
|
56
|
+
}
|
57
|
+
});
|
58
|
+
};
|
53
59
|
export var stateReducer = function stateReducer(newState, action) {
|
54
60
|
switch (action.type) {
|
61
|
+
case TOGGLE_ROW_SELECTED:
|
62
|
+
{
|
63
|
+
var _ref = action.payload || {},
|
64
|
+
rowData = _ref.rowData,
|
65
|
+
isChecked = _ref.isChecked;
|
66
|
+
if (!rowData) {
|
67
|
+
return;
|
68
|
+
}
|
69
|
+
if (isChecked) {
|
70
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
71
|
+
selectedRowData: _objectSpread(_objectSpread({}, newState.selectedRowData), {}, _defineProperty({}, rowData.index, rowData))
|
72
|
+
});
|
73
|
+
}
|
74
|
+
if (rowData && !isChecked) {
|
75
|
+
var newData = _objectSpread({}, newState.selectedRowData);
|
76
|
+
var dataWithRemovedRow = Object.fromEntries(Object.entries(newData).filter(function (_ref2) {
|
77
|
+
var _ref3 = _slicedToArray(_ref2, 1),
|
78
|
+
key = _ref3[0];
|
79
|
+
return parseInt(key) !== parseInt(rowData.index);
|
80
|
+
}));
|
81
|
+
return _objectSpread(_objectSpread({}, newState), {}, {
|
82
|
+
selectedRowData: dataWithRemovedRow
|
83
|
+
});
|
84
|
+
}
|
85
|
+
return _objectSpread({}, newState);
|
86
|
+
}
|
55
87
|
case INIT:
|
56
88
|
{
|
57
89
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
@@ -60,42 +92,45 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
60
92
|
}
|
61
93
|
case COLUMN_RESIZE_START:
|
62
94
|
{
|
63
|
-
var
|
95
|
+
var _ref4 = action.payload || {},
|
96
|
+
headerId = _ref4.headerId;
|
64
97
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
65
98
|
isResizing: headerId
|
66
99
|
});
|
67
100
|
}
|
68
101
|
case COLUMN_RESIZING:
|
69
102
|
{
|
70
|
-
var
|
71
|
-
_headerId =
|
72
|
-
newWidth =
|
73
|
-
defaultWidth =
|
103
|
+
var _ref5 = action.payload || {},
|
104
|
+
_headerId = _ref5.headerId,
|
105
|
+
newWidth = _ref5.newWidth,
|
106
|
+
defaultWidth = _ref5.defaultWidth;
|
74
107
|
var newColumnWidth = {};
|
75
108
|
if (typeof _headerId === 'undefined') {
|
76
109
|
return _objectSpread({}, newState);
|
77
110
|
}
|
78
111
|
newColumnWidth[_headerId] = newWidth;
|
79
|
-
var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (
|
80
|
-
var
|
81
|
-
_ =
|
82
|
-
value =
|
112
|
+
var cleanedWidths = Object.fromEntries(Object.entries(newState.columnResizing.columnWidths).filter(function (_ref6) {
|
113
|
+
var _ref7 = _slicedToArray(_ref6, 2),
|
114
|
+
_ = _ref7[0],
|
115
|
+
value = _ref7[1];
|
83
116
|
return !isNaN(value);
|
84
117
|
}));
|
118
|
+
var headerIdArray = newState.columnResizing.headerIdWidths || [];
|
85
119
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
86
120
|
isResizing: _headerId,
|
87
121
|
columnResizing: _objectSpread(_objectSpread({}, newState.columnResizing), {}, {
|
88
122
|
columnWidth: defaultWidth,
|
89
123
|
columnWidths: _objectSpread(_objectSpread({}, cleanedWidths), newColumnWidth),
|
90
|
-
headerIdWidths: [_headerId, newWidth]
|
124
|
+
headerIdWidths: [].concat(_toConsumableArray(headerIdArray), [[_headerId, newWidth]])
|
91
125
|
})
|
92
126
|
});
|
93
127
|
}
|
94
128
|
case COLUMN_RESIZE_END:
|
95
129
|
{
|
96
|
-
var
|
97
|
-
onColResizeEnd =
|
98
|
-
_headerId2 =
|
130
|
+
var _ref8 = action.payload || {},
|
131
|
+
onColResizeEnd = _ref8.onColResizeEnd,
|
132
|
+
_headerId2 = _ref8.headerId,
|
133
|
+
isKeyEvent = _ref8.isKeyEvent;
|
99
134
|
var currentColumn = {};
|
100
135
|
currentColumn[_headerId2] = newState.columnResizing.columnWidths[_headerId2];
|
101
136
|
var allChangedColumns = newState.columnResizing.columnWidths;
|
@@ -103,8 +138,22 @@ export var stateReducer = function stateReducer(newState, action) {
|
|
103
138
|
if (isResizing) {
|
104
139
|
onColResizeEnd === null || onColResizeEnd === void 0 ? void 0 : onColResizeEnd(currentColumn, allChangedColumns);
|
105
140
|
}
|
141
|
+
if (!isKeyEvent) {
|
142
|
+
if (typeof isKeyEvent === 'undefined') {
|
143
|
+
// Blur resizer input if it has focus and is not from a key event resize
|
144
|
+
if (document.activeElement.classList.contains("".concat(blockClass, "__col-resizer-range"))) {
|
145
|
+
var _document, _document$activeEleme;
|
146
|
+
(_document = document) === null || _document === void 0 ? void 0 : (_document$activeEleme = _document.activeElement) === null || _document$activeEleme === void 0 ? void 0 : _document$activeEleme.blur();
|
147
|
+
}
|
148
|
+
return;
|
149
|
+
}
|
150
|
+
}
|
106
151
|
return _objectSpread(_objectSpread({}, newState), {}, {
|
107
|
-
isResizing: false
|
152
|
+
isResizing: false,
|
153
|
+
columnResizing: _objectSpread(_objectSpread({}, newState.columnResizing), {}, {
|
154
|
+
isResizingColumn: false,
|
155
|
+
startX: null
|
156
|
+
})
|
108
157
|
});
|
109
158
|
}
|
110
159
|
}
|
@@ -45,7 +45,7 @@
|
|
45
45
|
|
46
46
|
// ## Sample usage:
|
47
47
|
// 1. include \`useActionsColumn\` hook
|
48
|
-
// 2. add \`isAction = true\` to the column object in which you
|
48
|
+
// 2. add \`isAction = true\` to the column object in which you wish to add the overflow menu actions
|
49
49
|
// 3. add \`rowActions = []\` array to the props
|
50
50
|
// - \`rowActions[].id\` for callback to identify the action is called
|
51
51
|
// - \`rowActions[].onClick(actionId: string, row: Row, event: ClickEvent)\` callback on menuitem clicked. [Row properties](https://react-table.tanstack.com/docs/api/useTable#row-properties)
|
@@ -12,15 +12,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
12
12
|
* LICENSE file in the root directory of this source tree.
|
13
13
|
*/
|
14
14
|
|
15
|
-
import React
|
15
|
+
import React from 'react';
|
16
16
|
import cx from 'classnames';
|
17
17
|
import { IconSkeleton, OverflowMenu, OverflowMenuItem } from 'carbon-components-react';
|
18
18
|
import { pkg } from '../../settings';
|
19
19
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
20
20
|
var useActionsColumn = function useActionsColumn(hooks) {
|
21
|
-
useEffect(function () {
|
22
|
-
pkg.checkReportFeatureEnabled('Datagrid.useActionsColumn');
|
23
|
-
}, []);
|
24
21
|
var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
|
25
22
|
var rowActions = instance.rowActions,
|
26
23
|
isFetching = instance.isFetching,
|
@@ -41,12 +38,13 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
41
38
|
column = cell.column;
|
42
39
|
if (column.isAction) {
|
43
40
|
var _cx3;
|
41
|
+
var isColumnSticky = !!column.sticky;
|
44
42
|
return [props, {
|
45
43
|
children: /*#__PURE__*/React.createElement("div", {
|
46
44
|
className: "".concat(blockClass, "__actions-column-contents")
|
47
45
|
}, isFetching && /*#__PURE__*/React.createElement(IconSkeleton, {
|
48
46
|
className: "".concat(blockClass, "__actions-column-loading")
|
49
|
-
}), !isFetching && rowActions.length <= 2 && /*#__PURE__*/React.createElement("div", {
|
47
|
+
}), !isFetching && rowActions.length <= 2 && !isColumnSticky && /*#__PURE__*/React.createElement("div", {
|
50
48
|
className: "".concat(blockClass, "_actions-column"),
|
51
49
|
style: {
|
52
50
|
display: 'flex'
|
@@ -70,6 +68,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
70
68
|
hasIconOnly: true,
|
71
69
|
light: true,
|
72
70
|
iconDescription: itemText,
|
71
|
+
ariaLabel: itemText,
|
73
72
|
kind: "ghost",
|
74
73
|
className: cx(_defineProperty({}, "".concat(blockClass, "__disabled-row-action"), getDisabledState(row.index))),
|
75
74
|
onClick: function onClick(e) {
|
@@ -81,7 +80,7 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
81
80
|
_onClick(id, row, e);
|
82
81
|
}
|
83
82
|
})));
|
84
|
-
})), !isFetching && rowActions.length > 2 && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(OverflowMenu, {
|
83
|
+
})), !isFetching && (rowActions.length > 2 || isColumnSticky) && /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(OverflowMenu, {
|
85
84
|
size: "sm",
|
86
85
|
light: true,
|
87
86
|
flipped: true,
|
@@ -111,9 +110,9 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
111
110
|
key: id
|
112
111
|
}));
|
113
112
|
})))),
|
114
|
-
className: cx((_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__cell"), true), _cx3)),
|
113
|
+
className: cx((_cx3 = {}, _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__cell"), true), _defineProperty(_cx3, "".concat(blockClass, "__actions-column-cell-non-sticky"), !isColumnSticky), _cx3)),
|
115
114
|
style: {
|
116
|
-
width: rowActions.length > 2 ? 48 : 96
|
115
|
+
width: rowActions.length > 2 || isColumnSticky ? 48 : 96
|
117
116
|
}
|
118
117
|
}];
|
119
118
|
}
|
@@ -128,9 +127,10 @@ var useActionsColumn = function useActionsColumn(hooks) {
|
|
128
127
|
var addHeaderWidth = function addHeaderWidth(props, cellData) {
|
129
128
|
var column = cellData.column;
|
130
129
|
if (column.isAction) {
|
130
|
+
var isColumnSticky = !!column.sticky;
|
131
131
|
return [props, {
|
132
132
|
style: _objectSpread(_objectSpread({}, props.style), {}, {
|
133
|
-
width: rowActions.length > 2 ? 48 : 96 // set header width based on action length
|
133
|
+
width: rowActions.length > 2 || isColumnSticky ? 48 : 96 // set header width based on action length
|
134
134
|
})
|
135
135
|
}];
|
136
136
|
}
|
@@ -2,13 +2,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
4
|
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
|
-
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2020, 2023
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
11
10
|
*/
|
11
|
+
|
12
12
|
import React from 'react';
|
13
13
|
import cx from 'classnames';
|
14
14
|
import { pkg } from '../../settings';
|
@@ -2,13 +2,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
4
4
|
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
|
-
|
6
|
-
*
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
5
|
+
/**
|
6
|
+
* Copyright IBM Corp. 2020, 2023
|
7
|
+
*
|
8
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
11
10
|
*/
|
11
|
+
|
12
12
|
import React from 'react';
|
13
13
|
import cx from 'classnames';
|
14
14
|
import { pkg } from '../../settings';
|
@@ -22,8 +22,19 @@ import useFloatingScroll from './useFloatingScroll';
|
|
22
22
|
import { stateReducer } from './Datagrid/addons/stateReducer';
|
23
23
|
var useDatagrid = function useDatagrid(params) {
|
24
24
|
var defaultPlugins = [useFlexLayout, useHeaderRow, useSkeletonRows, useResizeColumns, useRowRenderer, useDefaultStringRenderer, useRowSize, useFilters, useGlobalFilter, useSortBy, useExpanded];
|
25
|
+
|
26
|
+
// Disable resizing
|
27
|
+
if (params.disableResizing) {
|
28
|
+
var resizeIndex = defaultPlugins.findIndex(function (p) {
|
29
|
+
return p.pluginName === 'useResizeColumns';
|
30
|
+
});
|
31
|
+
defaultPlugins.splice(resizeIndex, 1);
|
32
|
+
}
|
25
33
|
var defaultEndPlugins = [usePagination, useRowSelect, useFlexResize, useFloatingScroll];
|
26
34
|
var clientEndPlugins = params.endPlugins || [];
|
35
|
+
var defaultColumn = {
|
36
|
+
minWidth: 50
|
37
|
+
};
|
27
38
|
var tableId = useMemo(function () {
|
28
39
|
return uniqueId('datagrid-table-id');
|
29
40
|
}, []);
|
@@ -33,7 +44,8 @@ var useDatagrid = function useDatagrid(params) {
|
|
33
44
|
var tableState = useTable.apply(void 0, [_objectSpread(_objectSpread({
|
34
45
|
tableId: tableId
|
35
46
|
}, params), {}, {
|
36
|
-
stateReducer: stateReducer
|
47
|
+
stateReducer: stateReducer,
|
48
|
+
defaultColumn: defaultColumn
|
37
49
|
})].concat(defaultPlugins, plugins, defaultEndPlugins, _toConsumableArray(clientEndPlugins)));
|
38
50
|
return tableState;
|
39
51
|
};
|
@@ -1,27 +1,37 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2020, 2023
|
4
|
+
*
|
5
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
8
7
|
*/
|
8
|
+
|
9
9
|
var useFlexResize = function useFlexResize(hooks) {
|
10
|
-
var
|
10
|
+
var spacer = {
|
11
11
|
id: 'spacer',
|
12
12
|
width: 0,
|
13
13
|
disableSortBy: true,
|
14
14
|
disableResizing: true
|
15
15
|
};
|
16
16
|
hooks.visibleColumns.push(function (columns) {
|
17
|
-
|
17
|
+
// always move actions and spacer to the end
|
18
|
+
var actionsIdx = columns.findIndex(function (col) {
|
19
|
+
return col.isAction;
|
20
|
+
});
|
21
|
+
if (actionsIdx === -1) {
|
22
|
+
return [].concat(_toConsumableArray(columns), [spacer]);
|
23
|
+
}
|
24
|
+
var cols = _toConsumableArray(columns);
|
25
|
+
var actions = cols.splice(actionsIdx, 1)[0];
|
26
|
+
cols.splice(columns.length, 0, spacer, actions);
|
27
|
+
return cols;
|
18
28
|
});
|
19
29
|
var changeProps = function changeProps(props, data) {
|
20
30
|
var column = data.column;
|
21
31
|
if (!column && data.cell) {
|
22
32
|
column = data.cell.column;
|
23
33
|
}
|
24
|
-
if (column.id ===
|
34
|
+
if (column.id === spacer.id) {
|
25
35
|
return [props, {
|
26
36
|
style: {
|
27
37
|
flex: '1 1 0'
|
@@ -1,10 +1,10 @@
|
|
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
|
*/
|
7
|
+
|
8
8
|
import { useCallback } from 'react';
|
9
9
|
import debounce from 'lodash/debounce';
|
10
10
|
import useParentDimensions from './useParentDimensions';
|
@@ -17,10 +17,11 @@ var useInfiniteScroll = function useInfiniteScroll(hooks) {
|
|
17
17
|
tableHeight = instance.tableHeight,
|
18
18
|
innerListRef = instance.innerListRef,
|
19
19
|
fetchMoreData = instance.fetchMoreData,
|
20
|
-
tableId = instance.tableId
|
20
|
+
tableId = instance.tableId,
|
21
|
+
loadMoreThreshold = instance.loadMoreThreshold;
|
21
22
|
var tableElement = document.querySelector("#".concat(tableId));
|
22
23
|
var totalTableHeight = tableHeight || (tableElement === null || tableElement === void 0 ? void 0 : tableElement.clientHeight);
|
23
|
-
var
|
24
|
+
var loadMoreThresholdValue = typeof loadMoreThreshold === 'number' ? loadMoreThreshold : 200;
|
24
25
|
var emptyFetchData = function emptyFetchData() {};
|
25
26
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
26
27
|
var fetchMore = useCallback(debounce(fetchMoreData || emptyFetchData, 3000, {
|
@@ -31,7 +32,7 @@ var useInfiniteScroll = function useInfiniteScroll(hooks) {
|
|
31
32
|
var scrollDirection = _ref.scrollDirection,
|
32
33
|
scrollOffset = _ref.scrollOffset;
|
33
34
|
if (innerListRef && innerListRef.current) {
|
34
|
-
if (!isFetching && scrollDirection === 'forward' && scrollOffset + totalTableHeight >= innerListRef.current.clientHeight -
|
35
|
+
if (!isFetching && scrollDirection === 'forward' && scrollOffset + totalTableHeight >= innerListRef.current.clientHeight - loadMoreThresholdValue) {
|
35
36
|
if (fetchMoreData) {
|
36
37
|
fetchMore();
|
37
38
|
}
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
4
|
+
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; }
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
4
6
|
/* eslint-disable react/prop-types */
|
5
7
|
/**
|
6
8
|
* Copyright IBM Corp. 2020, 2023
|
@@ -25,6 +27,13 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
|
|
25
27
|
Cell: function Cell(_ref) {
|
26
28
|
var _cx;
|
27
29
|
var row = _ref.row;
|
30
|
+
var expanderButtonProps = _objectSpread(_objectSpread({}, row.getToggleRowExpandedProps()), {}, {
|
31
|
+
onClick: function onClick(event) {
|
32
|
+
// Prevents `onRowClick` from being called if `useOnRowClick` is included
|
33
|
+
event.stopPropagation();
|
34
|
+
row.toggleRowExpanded();
|
35
|
+
}
|
36
|
+
});
|
28
37
|
var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
|
29
38
|
_ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
|
30
39
|
expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
|
@@ -35,7 +44,7 @@ var useNestedRowExpander = function useNestedRowExpander(hooks) {
|
|
35
44
|
type: "button",
|
36
45
|
"aria-label": expanderTitle,
|
37
46
|
className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
|
38
|
-
},
|
47
|
+
}, expanderButtonProps, {
|
39
48
|
title: expanderTitle
|
40
49
|
}), /*#__PURE__*/React.createElement(ChevronRight16, {
|
41
50
|
className: cx("".concat(blockClass, "__expander-icon"), "".concat(blockClass, "__row-expander--icon"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__expander-icon--not-open"), !row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__expander-icon--open"), row.isExpanded), _cx))
|
@@ -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 { pkg, carbon } from '../../settings';
|
@@ -43,7 +42,7 @@ var useOnRowClick = function useOnRowClick(hooks) {
|
|
43
42
|
var onKeyDown = function onKeyDown(event) {
|
44
43
|
var key = event.key;
|
45
44
|
if (key === 'Enter') {
|
46
|
-
onClick();
|
45
|
+
onClick(event);
|
47
46
|
}
|
48
47
|
};
|
49
48
|
return [props, {
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
2
|
-
|
3
|
-
*
|
4
|
-
*
|
5
|
-
*
|
6
|
-
*
|
7
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
2
|
+
/**
|
3
|
+
* Copyright IBM Corp. 2020, 2023
|
4
|
+
*
|
5
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
8
7
|
*/
|
8
|
+
|
9
9
|
import { useRef, useState } from 'react';
|
10
10
|
var useParentDimensions = function useParentDimensions(hooks) {
|
11
11
|
var rootRef = useRef();
|
@@ -1,10 +1,10 @@
|
|
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
|
*/
|
7
|
+
|
8
8
|
import { useLayoutEffect } from 'react';
|
9
9
|
var useResizeTable = function useResizeTable(hooks) {
|
10
10
|
var useInstanceBeforeDimensions = function useInstanceBeforeDimensions(instance) {
|
@@ -26,7 +26,7 @@ var useResizeTable = function useResizeTable(hooks) {
|
|
26
26
|
resizeObserver = null;
|
27
27
|
};
|
28
28
|
}
|
29
|
-
return console.error('
|
29
|
+
return console.error('Could not resize table, no support for ResizeObserver');
|
30
30
|
}, [handleResize, parent]);
|
31
31
|
};
|
32
32
|
hooks.useInstanceBeforeDimensions.push(useInstanceBeforeDimensions);
|
@@ -1,5 +1,8 @@
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
3
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
4
|
+
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; }
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
3
6
|
/* eslint-disable react/prop-types */
|
4
7
|
/**
|
5
8
|
* Copyright IBM Corp. 2020, 2023
|
@@ -23,6 +26,13 @@ var useRowExpander = function useRowExpander(hooks) {
|
|
23
26
|
id: 'expander',
|
24
27
|
Cell: function Cell(_ref) {
|
25
28
|
var row = _ref.row;
|
29
|
+
var expanderButtonProps = _objectSpread(_objectSpread({}, row.getToggleRowExpandedProps()), {}, {
|
30
|
+
onClick: function onClick(event) {
|
31
|
+
// Prevents `onRowClick` from being called if `useOnRowClick` is included
|
32
|
+
event.stopPropagation();
|
33
|
+
row.toggleRowExpanded();
|
34
|
+
}
|
35
|
+
});
|
26
36
|
var _ref2 = (tempState === null || tempState === void 0 ? void 0 : tempState.current) || {},
|
27
37
|
_ref2$expanderButtonT = _ref2.expanderButtonTitleExpanded,
|
28
38
|
expanderButtonTitleExpanded = _ref2$expanderButtonT === void 0 ? 'Collapse row' : _ref2$expanderButtonT,
|
@@ -33,7 +43,7 @@ var useRowExpander = function useRowExpander(hooks) {
|
|
33
43
|
type: "button",
|
34
44
|
"aria-label": expanderTitle,
|
35
45
|
className: cx("".concat(blockClass, "__row-expander"), "".concat(carbon.prefix, "--btn"), "".concat(carbon.prefix, "--btn--ghost"))
|
36
|
-
},
|
46
|
+
}, expanderButtonProps, {
|
37
47
|
title: expanderTitle
|
38
48
|
}), row.isExpanded ? /*#__PURE__*/React.createElement(ChevronUp16, {
|
39
49
|
className: "".concat(blockClass, "__row-expander--icon")
|
@@ -13,7 +13,7 @@ import cx from 'classnames';
|
|
13
13
|
import { selectionColumnId } from './common-column-ids';
|
14
14
|
import SelectAllWithToggle from './Datagrid/DatagridSelectAllWithToggle';
|
15
15
|
import { pkg } from '../../settings';
|
16
|
-
var blockClass = "".concat(pkg.prefix, "--
|
16
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid__select-all");
|
17
17
|
var useSelectAllToggle = function useSelectAllToggle(hooks) {
|
18
18
|
useSelectAllWithToggleComponent(hooks);
|
19
19
|
useAddClassNameToSelectRow(hooks);
|
@@ -60,7 +60,7 @@ var useAddClassNameToSelectRow = function useAddClassNameToSelectRow(hooks) {
|
|
60
60
|
var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
|
61
61
|
if (column.id === selectionColumnId && DatagridPagination) {
|
62
62
|
return [props, {
|
63
|
-
className: cx("".concat(blockClass, "
|
63
|
+
className: cx(["".concat(blockClass, "-toggle-on"), _defineProperty({}, "".concat(blockClass, "-sticky-left"), isFirstColumnStickyLeft && windowSize > 671)])
|
64
64
|
}];
|
65
65
|
}
|
66
66
|
return [props];
|