@carbon/ibm-products 1.47.0 → 1.49.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +1424 -29
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +5 -5
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +37 -15
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +2 -2
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +1424 -29
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +5 -5
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +1424 -29
- package/css/index.css.map +1 -1
- package/css/index.min.css +5 -5
- package/css/index.min.css.map +1 -1
- package/es/components/AddSelect/AddSelectBreadcrumbs.js +6 -4
- package/es/components/AddSelect/AddSelectList.js +15 -26
- package/es/components/CreateFullPage/CreateFullPage.js +3 -2
- package/es/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +14 -5
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +6 -3
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +15 -56
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -8
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +105 -0
- package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +17 -5
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
- package/es/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +8 -8
- package/es/components/Datagrid/index.js +8 -7
- package/es/components/Datagrid/useOnRowClick.js +3 -3
- package/es/components/Datagrid/useSortableColumns.js +26 -9
- package/es/components/Datagrid/utils/getAutoSizedColumnWidth.js +27 -0
- package/es/components/InlineEditV2/InlineEditV2.js +6 -3
- package/es/components/NonLinearReading/NonLinearReading.js +87 -0
- package/es/components/NonLinearReading/index.js +8 -0
- package/es/components/SidePanel/SidePanel.js +3 -4
- package/es/components/index.js +3 -2
- package/es/global/js/package-settings.js +3 -1
- package/es/global/js/utils/story-helper.js +9 -0
- package/lib/components/AddSelect/AddSelectBreadcrumbs.js +6 -4
- package/lib/components/AddSelect/AddSelectList.js +14 -25
- package/lib/components/CreateFullPage/CreateFullPage.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridContent.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +1 -1
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +13 -4
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/ButtonWrapper.js +6 -3
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/Columns.js +15 -56
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js +5 -8
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/DraggableItemsList.js +113 -0
- package/lib/components/Datagrid/Datagrid/addons/CustomizeColumns/TearsheetWrapper.js +1 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +17 -5
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +11 -0
- package/lib/components/Datagrid/Datagrid/addons/RowSize/RowSizeDropdown.js +3 -1
- package/lib/components/Datagrid/index.js +8 -1
- package/lib/components/Datagrid/useOnRowClick.js +3 -3
- package/lib/components/Datagrid/useSortableColumns.js +26 -9
- package/lib/components/Datagrid/utils/getAutoSizedColumnWidth.js +35 -0
- package/lib/components/InlineEditV2/InlineEditV2.js +6 -3
- package/lib/components/NonLinearReading/NonLinearReading.js +90 -0
- package/lib/components/NonLinearReading/index.js +12 -0
- package/lib/components/SidePanel/SidePanel.js +2 -3
- package/lib/components/index.js +14 -1
- package/lib/global/js/package-settings.js +3 -1
- package/lib/global/js/utils/story-helper.js +12 -2
- package/package.json +2 -2
- package/scss/components/AddSelect/_add-select.scss +0 -10
- package/scss/components/Datagrid/styles/_datagrid.scss +5 -1
- package/scss/components/Datagrid/styles/_useSortableColumns.scss +8 -4
- package/scss/components/InlineEditV1/_inline-edit-v1.scss +1 -5
- package/scss/components/InlineEditV2/_inline-edit-v2.scss +41 -3
- package/scss/components/NonLinearReading/_index.scss +8 -0
- package/scss/components/NonLinearReading/_non-linear-reading.scss +157 -0
- package/scss/components/NonLinearReading/_storybook-styles.scss +13 -0
- package/scss/components/SidePanel/_side-panel.scss +7 -15
- package/scss/components/_index.scss +1 -0
@@ -8,7 +8,7 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
8
8
|
//
|
9
9
|
|
10
10
|
import React from 'react';
|
11
|
-
import { Button, Checkbox, Dropdown, RadioButton
|
11
|
+
import { Button, Checkbox, Dropdown, RadioButton } from 'carbon-components-react';
|
12
12
|
import { ChevronRight16, View16 } from '@carbon/icons-react';
|
13
13
|
import PropTypes from 'prop-types';
|
14
14
|
import cx from 'classnames';
|
@@ -99,33 +99,22 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
99
99
|
};
|
100
100
|
return /*#__PURE__*/React.createElement("div", {
|
101
101
|
className: cx("".concat(blockClass, "-wrapper"), _defineProperty({}, "".concat(blockClass, "-wrapper-multi"), multi))
|
102
|
-
}, /*#__PURE__*/React.createElement(
|
103
|
-
selection: true,
|
102
|
+
}, /*#__PURE__*/React.createElement("div", {
|
104
103
|
className: "".concat(blockClass)
|
105
|
-
}, /*#__PURE__*/React.createElement(
|
104
|
+
}, /*#__PURE__*/React.createElement("div", {
|
105
|
+
className: "".concat(blockClass, "-body")
|
106
|
+
}, filteredItems.map(function (item) {
|
106
107
|
var _cx2;
|
107
|
-
return /*#__PURE__*/React.createElement(
|
108
|
+
return /*#__PURE__*/React.createElement("div", {
|
108
109
|
key: item.id,
|
109
|
-
className: cx("".concat(blockClass, "-row"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "-row--selected"), isSelected(item.id)), _defineProperty(_cx2, "".concat(blockClass, "-row-meta--selected"), isInMetaPanel(item.id)), _cx2))
|
110
|
-
onClick: function onClick(evt) {
|
111
|
-
return metaPanelHandler(item, evt);
|
112
|
-
},
|
113
|
-
label: true
|
110
|
+
className: cx("".concat(blockClass, "-row"), (_cx2 = {}, _defineProperty(_cx2, "".concat(blockClass, "-row--selected"), isSelected(item.id)), _defineProperty(_cx2, "".concat(blockClass, "-row-meta--selected"), isInMetaPanel(item.id)), _cx2))
|
114
111
|
}, /*#__PURE__*/React.createElement("div", {
|
115
112
|
className: "".concat(blockClass, "-cell")
|
116
113
|
}, /*#__PURE__*/React.createElement("div", {
|
117
114
|
className: "".concat(blockClass, "-cell-wrapper")
|
118
115
|
}, multi ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
119
116
|
className: "".concat(blockClass, "-checkbox")
|
120
|
-
},
|
121
|
-
/*#__PURE__*/
|
122
|
-
// hacky way to prevent checkbox from triggering the meta onclick handler
|
123
|
-
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-static-element-interactions
|
124
|
-
React.createElement("div", {
|
125
|
-
onClick: function onClick(event) {
|
126
|
-
return event.stopPropagation();
|
127
|
-
}
|
128
|
-
}, /*#__PURE__*/React.createElement(Checkbox, {
|
117
|
+
}, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Checkbox, {
|
129
118
|
onChange: function onChange(value, id) {
|
130
119
|
return handleMultiSelection(value, id);
|
131
120
|
},
|
@@ -147,10 +136,9 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
147
136
|
id: "add-select-modifier-".concat(item.id),
|
148
137
|
type: "inline",
|
149
138
|
items: modifiers.options,
|
150
|
-
light: true,
|
151
139
|
label: modifiers.label,
|
152
140
|
disabled: !isSelected(item.id),
|
153
|
-
className: "".concat(blockClass, "-dropdown
|
141
|
+
className: "".concat(blockClass, "-dropdown"),
|
154
142
|
initialSelectedItem: item[modifiers.id],
|
155
143
|
onChange: function onChange(_ref5) {
|
156
144
|
var selectedItem = _ref5.selectedItem;
|
@@ -178,9 +166,7 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
178
166
|
},
|
179
167
|
kind: "ghost",
|
180
168
|
size: "sm"
|
181
|
-
}), item.meta && /*#__PURE__*/React.createElement(
|
182
|
-
className: "".concat(blockClass, "-hidden-hover")
|
183
|
-
}, /*#__PURE__*/React.createElement(Button, {
|
169
|
+
}), item.meta && /*#__PURE__*/React.createElement(Button, {
|
184
170
|
className: "".concat(blockClass, "-view-meta"),
|
185
171
|
renderIcon: View16,
|
186
172
|
iconDescription: metaIconDescription,
|
@@ -188,8 +174,11 @@ export var AddSelectList = function AddSelectList(_ref) {
|
|
188
174
|
tooltipAlignment: "center",
|
189
175
|
hasIconOnly: true,
|
190
176
|
kind: "ghost",
|
191
|
-
size: "sm"
|
192
|
-
|
177
|
+
size: "sm",
|
178
|
+
onClick: function onClick() {
|
179
|
+
return metaPanelHandler(item);
|
180
|
+
}
|
181
|
+
}))));
|
193
182
|
}))));
|
194
183
|
};
|
195
184
|
AddSelectList.propTypes = {
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
4
|
var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "firstFocusElement", "submitButtonText"];
|
5
5
|
/**
|
6
|
-
* Copyright IBM Corp. 2021,
|
6
|
+
* Copyright IBM Corp. 2021, 2023
|
7
7
|
*
|
8
8
|
* This source code is licensed under the Apache-2.0 license found in the
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
@@ -200,7 +200,8 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
200
200
|
kind: "secondary",
|
201
201
|
onClick: function onClick() {
|
202
202
|
setModalIsOpen(!modalIsOpen);
|
203
|
-
}
|
203
|
+
},
|
204
|
+
"data-modal-primary-focus": true
|
204
205
|
}, modalSecondaryButtonText), /*#__PURE__*/React.createElement(Button, {
|
205
206
|
type: "button",
|
206
207
|
kind: "danger",
|
@@ -90,9 +90,9 @@ export var DatagridContent = function DatagridContent(_ref) {
|
|
90
90
|
return handleGridKeyPress({
|
91
91
|
event: event,
|
92
92
|
dispatch: dispatch,
|
93
|
-
inlineEditState: inlineEditState,
|
94
93
|
instance: datagridState,
|
95
94
|
keysPressedList: keysPressedList,
|
95
|
+
state: inlineEditState,
|
96
96
|
usingMac: usingMac
|
97
97
|
});
|
98
98
|
} : null,
|
@@ -108,7 +108,7 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
|
|
108
108
|
setGlobalFilter(null);
|
109
109
|
}
|
110
110
|
}, !displayAllInMenu && toolbarBatchActions && (toolbarBatchActions === null || toolbarBatchActions === void 0 ? void 0 : toolbarBatchActions.map(function (batchAction, index) {
|
111
|
-
if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length
|
111
|
+
if (index < 2 && toolbarBatchActions.length > 3 || index < 3 && toolbarBatchActions.length <= 3) {
|
112
112
|
return /*#__PURE__*/React.createElement(TableBatchAction, {
|
113
113
|
key: "".concat(batchAction.label, "-").concat(index),
|
114
114
|
renderIcon: batchAction.renderIcon,
|
@@ -5,16 +5,17 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
5
5
|
/*
|
6
6
|
* Licensed Materials - Property of IBM
|
7
7
|
* 5724-Q36
|
8
|
-
* (c) Copyright IBM Corp. 2020 -
|
8
|
+
* (c) Copyright IBM Corp. 2020 - 2023
|
9
9
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
10
10
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
11
11
|
*/
|
12
12
|
import React, { useEffect } from 'react';
|
13
13
|
import { VariableSizeList } from 'react-window';
|
14
14
|
import { DataTable } from 'carbon-components-react';
|
15
|
+
import { px } from '@carbon/layout';
|
16
|
+
import { useResizeDetector } from 'react-resize-detector';
|
15
17
|
import { pkg } from '../../../settings';
|
16
18
|
import DatagridHead from './DatagridHead';
|
17
|
-
import { px } from '@carbon/layout';
|
18
19
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
19
20
|
var TableBody = DataTable.TableBody;
|
20
21
|
var rowSizeMap = {
|
@@ -46,10 +47,18 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
46
47
|
page = datagridState.page,
|
47
48
|
handleResize = datagridState.handleResize,
|
48
49
|
gridRef = datagridState.gridRef;
|
50
|
+
var handleVirtualGridResize = function handleVirtualGridResize() {
|
51
|
+
var gridRefElement = gridRef === null || gridRef === void 0 ? void 0 : gridRef.current;
|
52
|
+
gridRefElement.style.width = gridRefElement === null || gridRefElement === void 0 ? void 0 : gridRefElement.clientWidth;
|
53
|
+
};
|
54
|
+
useResizeDetector({
|
55
|
+
onResize: handleVirtualGridResize,
|
56
|
+
targetRef: gridRef
|
57
|
+
});
|
49
58
|
var syncScroll = function syncScroll(e) {
|
50
59
|
var virtualBody = e.target;
|
51
|
-
document.querySelector(".".concat(blockClass, "__head-
|
52
|
-
var spacerColumn = document.querySelector(".".concat(blockClass, "__head-
|
60
|
+
document.querySelector(".".concat(blockClass, "__head-wrap")).scrollLeft = virtualBody.scrollLeft;
|
61
|
+
var spacerColumn = document.querySelector(".".concat(blockClass, "__head-wrap thead th:last-child"));
|
53
62
|
spacerColumn.style.width = px(32 + (virtualBody.offsetWidth - virtualBody.clientWidth)); // scrollbar width to header column to fix header alignment
|
54
63
|
};
|
55
64
|
|
@@ -62,7 +71,7 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
62
71
|
}
|
63
72
|
var visibleRows = DatagridPagination && page || rows;
|
64
73
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
65
|
-
className: "".concat(blockClass, "__head-
|
74
|
+
className: "".concat(blockClass, "__head-wrap"),
|
66
75
|
style: {
|
67
76
|
width: (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth,
|
68
77
|
overflow: 'hidden'
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
-
var _excluded = ["onClick", "setIsTearsheetOpen", "isTearsheetOpen", "iconTooltipLabel"];
|
3
|
+
var _excluded = ["onClick", "setIsTearsheetOpen", "isTearsheetOpen", "iconTooltipLabel", "tooltipPosition"];
|
4
4
|
/**
|
5
5
|
* Copyright IBM Corp. 2022, 2022
|
6
6
|
*
|
@@ -20,11 +20,13 @@ var ButtonWrapper = function ButtonWrapper(_ref) {
|
|
20
20
|
isTearsheetOpen = _ref.isTearsheetOpen,
|
21
21
|
_ref$iconTooltipLabel = _ref.iconTooltipLabel,
|
22
22
|
iconTooltipLabel = _ref$iconTooltipLabel === void 0 ? 'Customize columns' : _ref$iconTooltipLabel,
|
23
|
+
_ref$tooltipPosition = _ref.tooltipPosition,
|
24
|
+
tooltipPosition = _ref$tooltipPosition === void 0 ? 'bottom' : _ref$tooltipPosition,
|
23
25
|
rest = _objectWithoutProperties(_ref, _excluded);
|
24
26
|
return /*#__PURE__*/React.createElement(Button, _extends({}, rest, {
|
25
27
|
renderIcon: Column16,
|
26
28
|
iconDescription: iconTooltipLabel,
|
27
|
-
tooltipPosition:
|
29
|
+
tooltipPosition: tooltipPosition,
|
28
30
|
kind: "ghost",
|
29
31
|
hasIconOnly: true,
|
30
32
|
"test-id": "".concat(blockClass, "__customize-columns-trigger"),
|
@@ -40,6 +42,7 @@ ButtonWrapper.propTypes = {
|
|
40
42
|
iconTooltipLabel: PropTypes.string,
|
41
43
|
isTearsheetOpen: PropTypes.bool.isRequired,
|
42
44
|
onClick: PropTypes.func.isRequired,
|
43
|
-
setIsTearsheetOpen: PropTypes.func.isRequired
|
45
|
+
setIsTearsheetOpen: PropTypes.func.isRequired,
|
46
|
+
tooltipPosition: Button.propTypes.tooltipPosition
|
44
47
|
};
|
45
48
|
export default ButtonWrapper;
|
@@ -14,9 +14,8 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
|
|
14
14
|
import { Checkbox } from 'carbon-components-react';
|
15
15
|
import update from 'immutability-helper';
|
16
16
|
import { pkg } from '../../../../../settings';
|
17
|
-
import DraggableElement from '../../DraggableElement';
|
18
|
-
import { isColumnVisible } from './common';
|
19
17
|
import classNames from 'classnames';
|
18
|
+
import { DraggableItemsList } from './DraggableItemsList';
|
20
19
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
21
20
|
var getNextIndex = function getNextIndex(array, currentIndex, key) {
|
22
21
|
var newIndex = -1;
|
@@ -36,7 +35,8 @@ var Columns = function Columns(_ref) {
|
|
36
35
|
onSelectColumn = _ref.onSelectColumn,
|
37
36
|
assistiveTextInstructionsLabel = _ref.assistiveTextInstructionsLabel,
|
38
37
|
assistiveTextDisabledInstructionsLabel = _ref.assistiveTextDisabledInstructionsLabel,
|
39
|
-
selectAllLabel = _ref.selectAllLabel
|
38
|
+
selectAllLabel = _ref.selectAllLabel,
|
39
|
+
isTableSortable = _ref.isTableSortable;
|
40
40
|
var _React$useState = React.useState(''),
|
41
41
|
_React$useState2 = _slicedToArray(_React$useState, 2),
|
42
42
|
ariaRegionText = _React$useState2[0],
|
@@ -87,59 +87,17 @@ var Columns = function Columns(_ref) {
|
|
87
87
|
},
|
88
88
|
id: "".concat(blockClass, "__customization-column-select-all"),
|
89
89
|
labelText: selectAllLabel
|
90
|
-
})),
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
disabled: isFrozenColumn,
|
102
|
-
onChange: onSelectColumn.bind(null, colDef),
|
103
|
-
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
104
|
-
labelText: colDef.Header.props.title,
|
105
|
-
title: colDef.Header.props.title,
|
106
|
-
className: "".concat(blockClass, "__customize-columns-checkbox"),
|
107
|
-
hideLabel: true
|
108
|
-
}), /*#__PURE__*/React.createElement("div", {
|
109
|
-
dangerouslySetInnerHTML: {
|
110
|
-
__html: highlightedText
|
111
|
-
}
|
112
|
-
}));
|
113
|
-
return /*#__PURE__*/React.createElement(DraggableElement, {
|
114
|
-
key: colDef.id,
|
115
|
-
index: i,
|
116
|
-
listData: columns,
|
117
|
-
setListData: setColumnsObject,
|
118
|
-
id: "dnd-datagrid-columns-".concat(colDef.id),
|
119
|
-
type: "column-customization",
|
120
|
-
disabled: filterString.length > 0 || isFrozenColumn,
|
121
|
-
ariaLabel: colDef.Header.props.title,
|
122
|
-
onGrab: setAriaRegionText,
|
123
|
-
isFocused: focusIndex === i,
|
124
|
-
moveElement: moveElement,
|
125
|
-
onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
|
126
|
-
if (isGrabbed) {
|
127
|
-
var _columns$nextIndex;
|
128
|
-
var nextIndex = getNextIndex(columns, currentIndex, e.key);
|
129
|
-
e.preventDefault();
|
130
|
-
e.stopPropagation();
|
131
|
-
if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
|
132
|
-
setFocusIndex(nextIndex);
|
133
|
-
moveElement(currentIndex, nextIndex);
|
134
|
-
e.target.scrollIntoView({
|
135
|
-
block: 'center'
|
136
|
-
});
|
137
|
-
}
|
138
|
-
}
|
139
|
-
},
|
140
|
-
isSticky: isFrozenColumn,
|
141
|
-
selected: isColumnVisible(colDef)
|
142
|
-
}, listContents);
|
90
|
+
})), /*#__PURE__*/React.createElement(DraggableItemsList, {
|
91
|
+
columns: columns,
|
92
|
+
filterString: filterString,
|
93
|
+
focusIndex: focusIndex,
|
94
|
+
getNextIndex: getNextIndex,
|
95
|
+
isTableSortable: isTableSortable,
|
96
|
+
moveElement: moveElement,
|
97
|
+
onSelectColumn: onSelectColumn,
|
98
|
+
setAriaRegionText: setAriaRegionText,
|
99
|
+
setColumnsObject: setColumnsObject,
|
100
|
+
setFocusIndex: setFocusIndex
|
143
101
|
}))));
|
144
102
|
};
|
145
103
|
Columns.propTypes = {
|
@@ -150,6 +108,7 @@ Columns.propTypes = {
|
|
150
108
|
filterString: PropTypes.string.isRequired,
|
151
109
|
getVisibleColumnsCount: PropTypes.func.isRequired,
|
152
110
|
instructionsLabel: PropTypes.string,
|
111
|
+
isTableSortable: PropTypes.bool.isRequired,
|
153
112
|
onSelectColumn: PropTypes.func.isRequired,
|
154
113
|
selectAllLabel: PropTypes.string,
|
155
114
|
setColumnStatus: PropTypes.func,
|
package/es/components/Datagrid/Datagrid/addons/CustomizeColumns/CustomizeColumnsTearsheet.js
CHANGED
@@ -41,7 +41,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
41
41
|
_ref$assistiveTextDis = _ref.assistiveTextDisabledInstructionsLabel,
|
42
42
|
assistiveTextDisabledInstructionsLabel = _ref$assistiveTextDis === void 0 ? 'Reordering columns are disabled because they are filtered currently.' : _ref$assistiveTextDis,
|
43
43
|
_ref$selectAllLabel = _ref.selectAllLabel,
|
44
|
-
selectAllLabel = _ref$selectAllLabel === void 0 ? 'Column name' : _ref$selectAllLabel
|
44
|
+
selectAllLabel = _ref$selectAllLabel === void 0 ? 'Column name' : _ref$selectAllLabel,
|
45
|
+
isTableSortable = _ref.isTableSortable;
|
45
46
|
var _useState = useState(''),
|
46
47
|
_useState2 = _slicedToArray(_useState, 2),
|
47
48
|
visibleColumnsCount = _useState2[0],
|
@@ -55,12 +56,6 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
55
56
|
searchText = _useState6[0],
|
56
57
|
setSearchText = _useState6[1];
|
57
58
|
var _useState7 = useState(columnDefinitions
|
58
|
-
// hide the columns without Header, e.g the sticky actions, spacer
|
59
|
-
.filter(function (colDef) {
|
60
|
-
return !!colDef.Header.props && !!colDef.Header.props.title;
|
61
|
-
}).filter(function (colDef) {
|
62
|
-
return !colDef.isAction;
|
63
|
-
})
|
64
59
|
// only sort the hidden column to the end when modal reopen
|
65
60
|
.sort(function (defA, defB) {
|
66
61
|
var isVisibleA = isColumnVisible(defA);
|
@@ -157,7 +152,8 @@ var CustomizeColumnsTearsheet = function CustomizeColumnsTearsheet(_ref) {
|
|
157
152
|
setColumnObjects(cols);
|
158
153
|
setDirty();
|
159
154
|
},
|
160
|
-
selectAllLabel: selectAllLabel
|
155
|
+
selectAllLabel: selectAllLabel,
|
156
|
+
isTableSortable: isTableSortable
|
161
157
|
}));
|
162
158
|
};
|
163
159
|
CustomizeColumnsTearsheet.propTypes = {
|
@@ -168,6 +164,7 @@ CustomizeColumnsTearsheet.propTypes = {
|
|
168
164
|
findColumnPlaceholderLabel: PropTypes.string,
|
169
165
|
instructionsLabel: PropTypes.string,
|
170
166
|
isOpen: PropTypes.bool.isRequired,
|
167
|
+
isTableSortable: PropTypes.bool.isRequired,
|
171
168
|
onSaveColumnPrefs: PropTypes.func.isRequired,
|
172
169
|
originalColumnDefinitions: PropTypes.array.isRequired,
|
173
170
|
primaryButtonTextLabel: PropTypes.string,
|
@@ -0,0 +1,105 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright IBM Corp. 2023, 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.
|
6
|
+
*/
|
7
|
+
|
8
|
+
import React from 'react';
|
9
|
+
import { PropTypes } from 'prop-types';
|
10
|
+
import { Checkbox } from 'carbon-components-react';
|
11
|
+
import { isColumnVisible } from './common';
|
12
|
+
import DraggableElement from '../../DraggableElement';
|
13
|
+
import { pkg } from '../../../../../settings';
|
14
|
+
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
15
|
+
export var DraggableItemsList = function DraggableItemsList(_ref) {
|
16
|
+
var columns = _ref.columns,
|
17
|
+
filterString = _ref.filterString,
|
18
|
+
focusIndex = _ref.focusIndex,
|
19
|
+
getNextIndex = _ref.getNextIndex,
|
20
|
+
isTableSortable = _ref.isTableSortable,
|
21
|
+
moveElement = _ref.moveElement,
|
22
|
+
onSelectColumn = _ref.onSelectColumn,
|
23
|
+
setAriaRegionText = _ref.setAriaRegionText,
|
24
|
+
setColumnsObject = _ref.setColumnsObject,
|
25
|
+
setFocusIndex = _ref.setFocusIndex;
|
26
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, columns
|
27
|
+
// hide the columns without Header, e.g the sticky actions, spacer
|
28
|
+
.filter(function (colDef) {
|
29
|
+
var _colDef$Header$props$, _colDef$Header$props;
|
30
|
+
var sortableTitle = isTableSortable && ((_colDef$Header$props$ = colDef.Header().props.children.props) === null || _colDef$Header$props$ === void 0 ? void 0 : _colDef$Header$props$.title);
|
31
|
+
return !!colDef.Header.props && !!((_colDef$Header$props = colDef.Header.props) !== null && _colDef$Header$props !== void 0 && _colDef$Header$props.title) || isTableSortable && !!sortableTitle;
|
32
|
+
}).filter(function (colDef) {
|
33
|
+
return !colDef.isAction;
|
34
|
+
}).filter(function (colDef) {
|
35
|
+
var _colDef$Header$props$2, _colDef$Header$props2, _colDef$Header$props3;
|
36
|
+
var sortableTitle = isTableSortable && ((_colDef$Header$props$2 = colDef.Header().props.children.props) === null || _colDef$Header$props$2 === void 0 ? void 0 : _colDef$Header$props$2.title);
|
37
|
+
return filterString.length === 0 || (isTableSortable ? sortableTitle === null || sortableTitle === void 0 ? void 0 : sortableTitle.toLowerCase().includes(filterString) : (_colDef$Header$props2 = colDef.Header.props) === null || _colDef$Header$props2 === void 0 ? void 0 : (_colDef$Header$props3 = _colDef$Header$props2.title) === null || _colDef$Header$props3 === void 0 ? void 0 : _colDef$Header$props3.toLowerCase().includes(filterString)) && colDef.id !== 'spacer';
|
38
|
+
}).map(function (colDef, i) {
|
39
|
+
var _colDef$Header$props$3, _colDef$Header$props4, _colDef$Header$props5, _colDef$Header$props6, _colDef$Header$props7;
|
40
|
+
var isSortableColumn = !!colDef.canSort && !!isTableSortable;
|
41
|
+
var sortableTitle = isTableSortable && ((_colDef$Header$props$3 = colDef.Header().props.children.props) === null || _colDef$Header$props$3 === void 0 ? void 0 : _colDef$Header$props$3.title);
|
42
|
+
var searchString = new RegExp('(' + filterString + ')');
|
43
|
+
var res = filterString.length ? isSortableColumn ? sortableTitle.toLowerCase().split(searchString) : colDef.Header.props.title.toLowerCase().split(searchString) : null;
|
44
|
+
var firstWord = res !== null ? res[0] === '' ? res[1].charAt(0).toUpperCase() + res[1].substring(1) : res[0].charAt(0).toUpperCase() + res[0].substring(1) : null;
|
45
|
+
var highlightedText = res !== null ? res[0] === '' ? "<strong>".concat(firstWord, "</strong>") + res[2] : firstWord + "<strong>".concat(res[1], "</strong>") + res[2] : isSortableColumn ? sortableTitle : (_colDef$Header$props4 = colDef.Header.props) === null || _colDef$Header$props4 === void 0 ? void 0 : _colDef$Header$props4.title;
|
46
|
+
var isFrozenColumn = !!colDef.sticky;
|
47
|
+
var listContents = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Checkbox, {
|
48
|
+
wrapperClassName: "".concat(blockClass, "__customize-columns-checkbox-wrapper"),
|
49
|
+
checked: isColumnVisible(colDef),
|
50
|
+
disabled: isFrozenColumn,
|
51
|
+
onChange: onSelectColumn.bind(null, colDef),
|
52
|
+
id: "".concat(blockClass, "__customization-column-").concat(colDef.id),
|
53
|
+
labelText: isSortableColumn ? sortableTitle : (_colDef$Header$props5 = colDef.Header.props) === null || _colDef$Header$props5 === void 0 ? void 0 : _colDef$Header$props5.title,
|
54
|
+
title: isSortableColumn ? sortableTitle : (_colDef$Header$props6 = colDef.Header.props) === null || _colDef$Header$props6 === void 0 ? void 0 : _colDef$Header$props6.title,
|
55
|
+
className: "".concat(blockClass, "__customize-columns-checkbox"),
|
56
|
+
hideLabel: true
|
57
|
+
}), /*#__PURE__*/React.createElement("div", {
|
58
|
+
dangerouslySetInnerHTML: {
|
59
|
+
__html: highlightedText
|
60
|
+
}
|
61
|
+
}));
|
62
|
+
return /*#__PURE__*/React.createElement(DraggableElement, {
|
63
|
+
key: colDef.id,
|
64
|
+
index: i,
|
65
|
+
listData: columns,
|
66
|
+
setListData: setColumnsObject,
|
67
|
+
id: "dnd-datagrid-columns-".concat(colDef.id),
|
68
|
+
type: "column-customization",
|
69
|
+
disabled: filterString.length > 0 || isFrozenColumn,
|
70
|
+
ariaLabel: isSortableColumn ? sortableTitle : (_colDef$Header$props7 = colDef.Header.props) === null || _colDef$Header$props7 === void 0 ? void 0 : _colDef$Header$props7.title,
|
71
|
+
onGrab: setAriaRegionText,
|
72
|
+
isFocused: focusIndex === i,
|
73
|
+
moveElement: moveElement,
|
74
|
+
onArrowKeyDown: function onArrowKeyDown(e, isGrabbed, currentIndex) {
|
75
|
+
if (isGrabbed) {
|
76
|
+
var _columns$nextIndex;
|
77
|
+
var nextIndex = getNextIndex(columns, currentIndex, e.key);
|
78
|
+
e.preventDefault();
|
79
|
+
e.stopPropagation();
|
80
|
+
if (nextIndex >= 0 && !((_columns$nextIndex = columns[nextIndex]) !== null && _columns$nextIndex !== void 0 && _columns$nextIndex.sticky)) {
|
81
|
+
setFocusIndex(nextIndex);
|
82
|
+
moveElement(currentIndex, nextIndex);
|
83
|
+
e.target.scrollIntoView({
|
84
|
+
block: 'center'
|
85
|
+
});
|
86
|
+
}
|
87
|
+
}
|
88
|
+
},
|
89
|
+
isSticky: isFrozenColumn,
|
90
|
+
selected: isColumnVisible(colDef)
|
91
|
+
}, listContents);
|
92
|
+
}));
|
93
|
+
};
|
94
|
+
DraggableItemsList.propTypes = {
|
95
|
+
columns: PropTypes.array.isRequired,
|
96
|
+
filterString: PropTypes.string.isRequired,
|
97
|
+
focusIndex: PropTypes.number.isRequired,
|
98
|
+
getNextIndex: PropTypes.func.isRequired,
|
99
|
+
isTableSortable: PropTypes.bool,
|
100
|
+
moveElement: PropTypes.func.isRequired,
|
101
|
+
onSelectColumn: PropTypes.func.isRequired,
|
102
|
+
setAriaRegionText: PropTypes.func.isRequired,
|
103
|
+
setColumnsObject: PropTypes.func.isRequired,
|
104
|
+
setFocusIndex: PropTypes.func.isRequired
|
105
|
+
};
|
@@ -21,6 +21,7 @@ var TearsheetWrapper = function TearsheetWrapper(_ref) {
|
|
21
21
|
rest = _objectWithoutProperties(_instance$customizeCo, _excluded);
|
22
22
|
return /*#__PURE__*/React.createElement(CustomizeColumnsTearsheet, _extends({}, rest, labels, {
|
23
23
|
isOpen: isTearsheetOpen,
|
24
|
+
isTableSortable: instance === null || instance === void 0 ? void 0 : instance.isTableSortable,
|
24
25
|
setIsTearsheetOpen: setIsTearsheetOpen,
|
25
26
|
columnDefinitions: instance.allColumns,
|
26
27
|
originalColumnDefinitions: instance.columns,
|
@@ -45,7 +45,15 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
45
45
|
_ref$showFilterSearch = _ref.showFilterSearch,
|
46
46
|
showFilterSearch = _ref$showFilterSearch === void 0 ? false : _ref$showFilterSearch,
|
47
47
|
_ref$filterPanelMinHe = _ref.filterPanelMinHeight,
|
48
|
-
filterPanelMinHeight = _ref$filterPanelMinHe === void 0 ? 600 : _ref$filterPanelMinHe
|
48
|
+
filterPanelMinHeight = _ref$filterPanelMinHe === void 0 ? 600 : _ref$filterPanelMinHe,
|
49
|
+
_ref$primaryActionLab = _ref.primaryActionLabel,
|
50
|
+
primaryActionLabel = _ref$primaryActionLab === void 0 ? 'Apply' : _ref$primaryActionLab,
|
51
|
+
_ref$secondaryActionL = _ref.secondaryActionLabel,
|
52
|
+
secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
|
53
|
+
_ref$searchLabelText = _ref.searchLabelText,
|
54
|
+
searchLabelText = _ref$searchLabelText === void 0 ? 'Filter search' : _ref$searchLabelText,
|
55
|
+
_ref$searchPlaceholde = _ref.searchPlaceholder,
|
56
|
+
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde;
|
49
57
|
/** State */
|
50
58
|
var _useState = useState(false),
|
51
59
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -120,13 +128,13 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
120
128
|
actions: [{
|
121
129
|
key: 1,
|
122
130
|
kind: 'primary',
|
123
|
-
label:
|
131
|
+
label: primaryActionLabel,
|
124
132
|
onClick: apply,
|
125
133
|
disabled: shouldDisableButtons
|
126
134
|
}, {
|
127
135
|
key: 2,
|
128
136
|
kind: 'secondary',
|
129
|
-
label:
|
137
|
+
label: secondaryActionLabel,
|
130
138
|
onClick: cancel,
|
131
139
|
disabled: shouldDisableButtons
|
132
140
|
}],
|
@@ -189,8 +197,8 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
189
197
|
ref: filterSearchRef,
|
190
198
|
className: "".concat(componentClass, "__search")
|
191
199
|
}, /*#__PURE__*/React.createElement(Search, {
|
192
|
-
labelText:
|
193
|
-
placeHolderText:
|
200
|
+
labelText: searchLabelText,
|
201
|
+
placeHolderText: searchPlaceholder,
|
194
202
|
light: true,
|
195
203
|
size: "sm"
|
196
204
|
}))), /*#__PURE__*/React.createElement("div", {
|
@@ -231,6 +239,10 @@ FilterPanel.propTypes = {
|
|
231
239
|
onPanelClose: PropTypes.func,
|
232
240
|
onPanelOpen: PropTypes.func,
|
233
241
|
open: PropTypes.bool,
|
242
|
+
primaryActionLabel: PropTypes.string,
|
243
|
+
searchLabelText: PropTypes.string,
|
244
|
+
searchPlaceholder: PropTypes.string,
|
245
|
+
secondaryActionLabel: PropTypes.string,
|
234
246
|
setAllFilters: PropTypes.func.isRequired,
|
235
247
|
showFilterSearch: PropTypes.bool,
|
236
248
|
title: PropTypes.string,
|
@@ -125,6 +125,17 @@ var useFilters = function useFilters(_ref) {
|
|
125
125
|
// Remove it from the filters array
|
126
126
|
filtersObjectArrayCopy.splice(_index2, 1);
|
127
127
|
}
|
128
|
+
} else if (type === NUMBER) {
|
129
|
+
// If the value is empty remove it from the filtersObjectArray
|
130
|
+
if (value === '') {
|
131
|
+
// Find the column that uses number and displays an empty string
|
132
|
+
var _index3 = filtersObjectArrayCopy.findIndex(function (filter) {
|
133
|
+
return filter.id === column;
|
134
|
+
});
|
135
|
+
|
136
|
+
// Remove it from the filters array
|
137
|
+
filtersObjectArrayCopy.splice(_index3, 1);
|
138
|
+
}
|
128
139
|
}
|
129
140
|
setFiltersObjectArray(filtersObjectArrayCopy);
|
130
141
|
|
@@ -3,13 +3,11 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
4
4
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
5
5
|
var _excluded = ["legendText"];
|
6
|
-
|
7
|
-
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* US Government Users Restricted Rights - Use, duplication or disclosure
|
12
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2021, 2023
|
8
|
+
*
|
9
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
13
11
|
*/
|
14
12
|
|
15
13
|
import * as React from 'react';
|
@@ -36,7 +34,9 @@ var RowSizeDropdown = function RowSizeDropdown(_ref) {
|
|
36
34
|
tooltipPosition: "bottom",
|
37
35
|
renderIcon: Settings16,
|
38
36
|
onClick: function onClick() {
|
39
|
-
return setIsOpen(
|
37
|
+
return setIsOpen(function (prevOpen) {
|
38
|
+
return !prevOpen;
|
39
|
+
});
|
40
40
|
},
|
41
41
|
iconDescription: legendText,
|
42
42
|
className: cx("".concat(blockClass, "__row-size-button"), _defineProperty({}, "".concat(blockClass, "__row-size-button--open"), isOpen))
|
@@ -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
|
export { Datagrid } from './Datagrid';
|
9
9
|
export { default as useDatagrid } from './useDatagrid';
|
10
10
|
export { default as useInfiniteScroll } from './useInfiniteScroll';
|
@@ -23,4 +23,5 @@ export { default as useSelectAllWithToggle } from './useSelectAllToggle';
|
|
23
23
|
export { default as useColumnCenterAlign } from './useColumnCenterAlign';
|
24
24
|
export { default as useColumnOrder } from './useColumnOrder';
|
25
25
|
export { default as useInlineEdit } from './useInlineEdit';
|
26
|
-
export { default as useFiltering } from './useFiltering';
|
26
|
+
export { default as useFiltering } from './useFiltering';
|
27
|
+
export { getAutoSizedColumnWidth } from './utils/getAutoSizedColumnWidth';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* Licensed Materials - Property of IBM
|
3
3
|
* 5724-Q36
|
4
|
-
* (c) Copyright IBM Corp. 2020
|
4
|
+
* (c) Copyright IBM Corp. 2020, 2023
|
5
5
|
* US Government Users Restricted Rights - Use, duplication or disclosure
|
6
6
|
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
7
7
|
*/
|
@@ -15,9 +15,9 @@ var useOnRowClick = function useOnRowClick(hooks) {
|
|
15
15
|
instance = datagridState.instance;
|
16
16
|
var id = row.id,
|
17
17
|
toggleRowSelected = row.toggleRowSelected;
|
18
|
-
var onClick = function onClick() {
|
18
|
+
var onClick = function onClick(event) {
|
19
19
|
if (!isFetching && onRowClick) {
|
20
|
-
onRowClick(row);
|
20
|
+
onRowClick(row, event);
|
21
21
|
instance.selectedFlatRows && instance.selectedFlatRows.map(function (toggleRow) {
|
22
22
|
return toggleRow.toggleRowSelected(false);
|
23
23
|
});
|