@carbon/ibm-products 1.49.0 → 1.51.0
Sign up to get free protection for your applications and to get access to all the features.
- package/css/index-full-carbon.css +46 -18
- 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 +42 -11
- package/css/index-without-carbon-released-only.css.map +1 -1
- package/css/index-without-carbon-released-only.min.css +1 -1
- package/css/index-without-carbon-released-only.min.css.map +1 -1
- package/css/index-without-carbon.css +46 -18
- 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 +46 -18
- 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/Card/Card.js +3 -3
- package/es/components/Card/CardHeader.js +3 -3
- package/es/components/Datagrid/Datagrid/DatagridEmptyBody.js +16 -20
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
- package/es/components/Datagrid/Datagrid/DatagridRow.js +6 -2
- package/es/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +8 -8
- package/es/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
- package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +17 -2
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +8 -4
- package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/utils.js +14 -0
- package/es/components/Datagrid/useFiltering.js +4 -2
- package/es/components/Datagrid/useOnRowClick.js +9 -1
- package/es/components/Datagrid/useSelectRows.js +2 -0
- package/es/components/EditInPlace/EditInPlace.js +43 -0
- package/es/components/EditInPlace/index.js +8 -0
- package/es/components/ExpressiveCard/ExpressiveCard.js +3 -3
- package/es/components/InlineEdit/InlineEdit.js +5 -1
- package/es/components/InlineEditV1/InlineEditV1.js +5 -2
- package/es/components/InlineEditV2/InlineEditV2.js +51 -15
- package/es/components/ProductiveCard/ProductiveCard.js +3 -3
- package/es/components/index.js +1 -0
- package/es/global/js/package-settings.js +1 -0
- package/es/settings.js +15 -0
- package/lib/components/Card/Card.js +3 -3
- package/lib/components/Card/CardHeader.js +3 -3
- package/lib/components/Datagrid/Datagrid/DatagridEmptyBody.js +14 -19
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridRefBody.js +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +6 -2
- package/lib/components/Datagrid/Datagrid/DatagridSelectAllWithToggle.js +2 -1
- package/lib/components/Datagrid/Datagrid/DatagridSimpleBody.js +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +3 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +17 -3
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +17 -2
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +8 -4
- package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +2 -1
- package/lib/components/Datagrid/Datagrid/addons/Filtering/utils.js +15 -0
- package/lib/components/Datagrid/useFiltering.js +4 -2
- package/lib/components/Datagrid/useOnRowClick.js +9 -1
- package/lib/components/Datagrid/useSelectRows.js +2 -0
- package/lib/components/EditInPlace/EditInPlace.js +46 -0
- package/lib/components/EditInPlace/index.js +12 -0
- package/lib/components/ExpressiveCard/ExpressiveCard.js +3 -3
- package/lib/components/InlineEdit/InlineEdit.js +5 -1
- package/lib/components/InlineEditV1/InlineEditV1.js +5 -2
- package/lib/components/InlineEditV2/InlineEditV2.js +53 -16
- package/lib/components/ProductiveCard/ProductiveCard.js +3 -3
- package/lib/components/index.js +7 -0
- package/lib/global/js/package-settings.js +1 -0
- package/lib/settings.js +16 -1
- package/package.json +2 -2
- package/scss/components/Datagrid/styles/_useSelectAllToggle.scss +10 -7
- package/scss/components/InlineEditV2/_inline-edit-v2.scss +52 -11
- package/scss/components/InlineEditV2/_storybook-styles.scss +9 -2
- package/scss/components/TagSet/_tag-set.scss +6 -0
@@ -1,15 +1,15 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
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 React from 'react';
|
10
10
|
import { pkg } from '../../../settings';
|
11
11
|
import { DataTable } from 'carbon-components-react';
|
12
|
-
import { NoDataEmptyState, ErrorEmptyState } from '../../EmptyStates';
|
12
|
+
import { NoDataEmptyState, ErrorEmptyState, NotFoundEmptyState } from '../../EmptyStates';
|
13
13
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
14
14
|
var TableBody = DataTable.TableBody,
|
15
15
|
TableRow = DataTable.TableRow,
|
@@ -25,24 +25,20 @@ var DatagridEmptyBody = function DatagridEmptyBody(datagridState) {
|
|
25
25
|
illustrationTheme = datagridState.illustrationTheme,
|
26
26
|
emptyStateAction = datagridState.emptyStateAction,
|
27
27
|
emptyStateLink = datagridState.emptyStateLink;
|
28
|
-
|
29
|
-
className: "".concat(blockClass, "__empty-state-body")
|
30
|
-
}), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
|
31
|
-
colSpan: headers.length
|
32
|
-
}, emptyStateType === 'error' && /*#__PURE__*/React.createElement(ErrorEmptyState, {
|
33
|
-
illustrationTheme: illustrationTheme,
|
34
|
-
size: emptyStateSize,
|
35
|
-
title: emptyStateTitle,
|
36
|
-
subtitle: emptyStateDescription,
|
37
|
-
action: emptyStateAction,
|
38
|
-
link: emptyStateLink
|
39
|
-
}), emptyStateType === 'noData' && /*#__PURE__*/React.createElement(NoDataEmptyState, {
|
28
|
+
var emptyStateProps = {
|
40
29
|
illustrationTheme: illustrationTheme,
|
41
30
|
size: emptyStateSize,
|
42
31
|
title: emptyStateTitle,
|
43
32
|
subtitle: emptyStateDescription,
|
44
33
|
action: emptyStateAction,
|
45
34
|
link: emptyStateLink
|
46
|
-
}
|
35
|
+
};
|
36
|
+
return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
|
37
|
+
role: false
|
38
|
+
}), {
|
39
|
+
className: "".concat(blockClass, "__empty-state-body")
|
40
|
+
}), /*#__PURE__*/React.createElement(TableRow, null, /*#__PURE__*/React.createElement(TableCell, {
|
41
|
+
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))));
|
47
43
|
};
|
48
44
|
export default DatagridEmptyBody;
|
@@ -15,7 +15,9 @@ import { selectionColumnId } from '../common-column-ids';
|
|
15
15
|
import { pkg } from '../../../settings';
|
16
16
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
17
17
|
var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
18
|
-
return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps(
|
18
|
+
return /*#__PURE__*/React.createElement(TableRow, _extends({}, headerGroup.getHeaderGroupProps({
|
19
|
+
role: false
|
20
|
+
}), {
|
19
21
|
className: cx("".concat(blockClass, "__head"), headerGroup.getHeaderGroupProps().className),
|
20
22
|
ref: headRef
|
21
23
|
}), datagridState.headers.filter(function (_ref) {
|
@@ -29,7 +31,9 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
29
31
|
key: header.id
|
30
32
|
});
|
31
33
|
}
|
32
|
-
return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps(
|
34
|
+
return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps({
|
35
|
+
role: false
|
36
|
+
}), {
|
33
37
|
className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), header.canSort), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
|
34
38
|
key: header.id
|
35
39
|
}), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement("div", _extends({}, header.getResizerProps(), {
|
@@ -22,7 +22,9 @@ var DatagridRefBody = function DatagridRefBody(datagridState) {
|
|
22
22
|
var getTableBodyProps = datagridState.getTableBodyProps,
|
23
23
|
rows = datagridState.rows,
|
24
24
|
prepareRow = datagridState.prepareRow;
|
25
|
-
return /*#__PURE__*/React.createElement("tbody", _extends({}, getTableBodyProps(
|
25
|
+
return /*#__PURE__*/React.createElement("tbody", _extends({}, getTableBodyProps({
|
26
|
+
role: false
|
27
|
+
}), {
|
26
28
|
className: cx("".concat(blockClass, "__simple-body"), getTableBodyProps().className)
|
27
29
|
}), rows.map(function (row) {
|
28
30
|
prepareRow(row);
|
@@ -65,7 +65,9 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
65
65
|
};
|
66
66
|
return /*#__PURE__*/React.createElement(TableRow, _extends({
|
67
67
|
className: 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))
|
68
|
-
}, row.getRowProps(
|
68
|
+
}, row.getRowProps({
|
69
|
+
role: false
|
70
|
+
}), {
|
69
71
|
key: row.id,
|
70
72
|
onMouseEnter: function onMouseEnter(event) {
|
71
73
|
if (!withNestedRows) {
|
@@ -96,7 +98,9 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
96
98
|
}
|
97
99
|
}
|
98
100
|
}), row.cells.map(function (cell, index) {
|
99
|
-
var cellProps = cell.getCellProps(
|
101
|
+
var cellProps = cell.getCellProps({
|
102
|
+
role: false
|
103
|
+
});
|
100
104
|
var children = cellProps.children,
|
101
105
|
restProps = _objectWithoutProperties(cellProps, _excluded);
|
102
106
|
var content = children || /*#__PURE__*/React.createElement(React.Fragment, null, !row.isSkeleton && cell.render('Cell'), row.isSkeleton && /*#__PURE__*/React.createElement(SkeletonText, null));
|
@@ -3,14 +3,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
5
5
|
var _excluded = ["onChange"];
|
6
|
-
|
7
|
-
*
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2020, 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.
|
12
11
|
*/
|
13
|
-
|
12
|
+
|
14
13
|
import React, { useEffect, useState, useLayoutEffect } from 'react';
|
15
14
|
import PropTypes from 'prop-types';
|
16
15
|
import cx from 'classnames';
|
@@ -84,7 +83,8 @@ var SelectAllWithToggle = function SelectAllWithToggle(_ref) {
|
|
84
83
|
id: "".concat(tableId, "-select-all-checkbox-id")
|
85
84
|
}))), /*#__PURE__*/React.createElement(OverflowMenu, {
|
86
85
|
renderIcon: CaretDown16,
|
87
|
-
size: "sm"
|
86
|
+
size: "sm",
|
87
|
+
menuOptionsClass: "".concat(blockClass, "__select-all-toggle-overflow")
|
88
88
|
}, /*#__PURE__*/React.createElement(OverflowMenuItem, {
|
89
89
|
itemText: allPageRowsLabel,
|
90
90
|
requireTitle: true,
|
@@ -19,7 +19,9 @@ var DatagridSimpleBody = function DatagridSimpleBody(datagridState) {
|
|
19
19
|
var getTableBodyProps = datagridState.getTableBodyProps,
|
20
20
|
rows = datagridState.rows,
|
21
21
|
prepareRow = datagridState.prepareRow;
|
22
|
-
return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(
|
22
|
+
return /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
|
23
|
+
role: false
|
24
|
+
}), {
|
23
25
|
className: cx("".concat(blockClass, "__simple-body"), getTableBodyProps().className)
|
24
26
|
}), rows.map(function (row) {
|
25
27
|
prepareRow(row);
|
@@ -76,7 +76,9 @@ var DatagridVirtualBody = function DatagridVirtualBody(datagridState) {
|
|
76
76
|
width: (_gridRef$current = gridRef.current) === null || _gridRef$current === void 0 ? void 0 : _gridRef$current.clientWidth,
|
77
77
|
overflow: 'hidden'
|
78
78
|
}
|
79
|
-
}, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps(
|
79
|
+
}, /*#__PURE__*/React.createElement(DatagridHead, datagridState)), /*#__PURE__*/React.createElement(TableBody, _extends({}, getTableBodyProps({
|
80
|
+
role: false
|
81
|
+
}), {
|
80
82
|
onScroll: function onScroll(e) {
|
81
83
|
return syncScroll(e);
|
82
84
|
}
|
@@ -44,7 +44,12 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
44
44
|
secondaryActionLabel = _ref$secondaryActionL === void 0 ? 'Cancel' : _ref$secondaryActionL,
|
45
45
|
setAllFilters = _ref.setAllFilters,
|
46
46
|
_ref$data = _ref.data,
|
47
|
-
data = _ref$data === void 0 ? [] : _ref$data
|
47
|
+
data = _ref$data === void 0 ? [] : _ref$data,
|
48
|
+
_ref$initialFilters = _ref.initialFilters,
|
49
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
50
|
+
// Save the initial filters we only need the filters once when it loads
|
51
|
+
var initialFiltersRef = useRef(initialFilters);
|
52
|
+
|
48
53
|
/** State */
|
49
54
|
var _useState = useState(false),
|
50
55
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -54,7 +59,8 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
54
59
|
updateMethod: updateMethod,
|
55
60
|
filters: filters,
|
56
61
|
setAllFilters: setAllFilters,
|
57
|
-
variation: FLYOUT
|
62
|
+
variation: FLYOUT,
|
63
|
+
initialFilters: initialFiltersRef.current
|
58
64
|
}),
|
59
65
|
filtersState = _useFilters.filtersState,
|
60
66
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
@@ -179,11 +185,19 @@ FilterFlyout.propTypes = {
|
|
179
185
|
type: PropTypes.string.isRequired,
|
180
186
|
column: PropTypes.string.isRequired,
|
181
187
|
props: PropTypes.object.isRequired
|
182
|
-
}))
|
188
|
+
})),
|
183
189
|
/**
|
184
190
|
* Icon description for the filter flyout button
|
185
191
|
*/
|
186
192
|
flyoutIconDescription: PropTypes.string,
|
193
|
+
/**
|
194
|
+
* Filters that should be applied on load
|
195
|
+
*/
|
196
|
+
initialFilters: PropTypes.arrayOf(PropTypes.shape({
|
197
|
+
id: PropTypes.string.isRequired,
|
198
|
+
type: PropTypes.string.isRequired,
|
199
|
+
value: PropTypes.any.isRequired
|
200
|
+
})),
|
187
201
|
/**
|
188
202
|
* Callback when the apply button is clicked
|
189
203
|
*/
|
@@ -53,7 +53,12 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
53
53
|
_ref$searchLabelText = _ref.searchLabelText,
|
54
54
|
searchLabelText = _ref$searchLabelText === void 0 ? 'Filter search' : _ref$searchLabelText,
|
55
55
|
_ref$searchPlaceholde = _ref.searchPlaceholder,
|
56
|
-
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde
|
56
|
+
searchPlaceholder = _ref$searchPlaceholde === void 0 ? 'Find filters' : _ref$searchPlaceholde,
|
57
|
+
_ref$initialFilters = _ref.initialFilters,
|
58
|
+
initialFilters = _ref$initialFilters === void 0 ? [] : _ref$initialFilters;
|
59
|
+
// Save the initial filters we only need the filters once
|
60
|
+
var initialFiltersRef = useRef(initialFilters);
|
61
|
+
|
57
62
|
/** State */
|
58
63
|
var _useState = useState(false),
|
59
64
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -63,7 +68,8 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
63
68
|
updateMethod: updateMethod,
|
64
69
|
filters: filterSections,
|
65
70
|
setAllFilters: setAllFilters,
|
66
|
-
variation: PANEL
|
71
|
+
variation: PANEL,
|
72
|
+
initialFilters: initialFiltersRef.current
|
67
73
|
}),
|
68
74
|
filtersState = _useFilters.filtersState,
|
69
75
|
prevFiltersObjectArrayRef = _useFilters.prevFiltersObjectArrayRef,
|
@@ -214,6 +220,7 @@ var FilterPanel = function FilterPanel(_ref) {
|
|
214
220
|
filters = _ref2$filters === void 0 ? [] : _ref2$filters,
|
215
221
|
hasAccordion = _ref2.hasAccordion;
|
216
222
|
return /*#__PURE__*/React.createElement("div", {
|
223
|
+
key: categoryTitle,
|
217
224
|
className: "".concat(componentClass, "__category")
|
218
225
|
}, categoryTitle && /*#__PURE__*/React.createElement("div", {
|
219
226
|
className: "".concat(componentClass, "__category-title")
|
@@ -234,6 +241,14 @@ FilterPanel.propTypes = {
|
|
234
241
|
closeIconDescription: PropTypes.string,
|
235
242
|
filterPanelMinHeight: PropTypes.number,
|
236
243
|
filterSections: PropTypes.array,
|
244
|
+
/**
|
245
|
+
* Filters that should be applied on load
|
246
|
+
*/
|
247
|
+
initialFilters: PropTypes.arrayOf(PropTypes.shape({
|
248
|
+
id: PropTypes.string.isRequired,
|
249
|
+
type: PropTypes.string.isRequired,
|
250
|
+
value: PropTypes.any.isRequired
|
251
|
+
})),
|
237
252
|
onApply: PropTypes.func,
|
238
253
|
onCancel: PropTypes.func,
|
239
254
|
onPanelClose: PropTypes.func,
|
@@ -21,13 +21,14 @@ var useFilters = function useFilters(_ref) {
|
|
21
21
|
_ref$filters = _ref.filters,
|
22
22
|
filters = _ref$filters === void 0 ? [] : _ref$filters,
|
23
23
|
setAllFilters = _ref.setAllFilters,
|
24
|
-
variation = _ref.variation
|
24
|
+
variation = _ref.variation,
|
25
|
+
initialFilters = _ref.initialFilters;
|
25
26
|
/** State */
|
26
|
-
var _useInitialStateFromF = useInitialStateFromFilters(filters, variation),
|
27
|
+
var _useInitialStateFromF = useInitialStateFromFilters(filters, variation, initialFilters),
|
27
28
|
_useInitialStateFromF2 = _slicedToArray(_useInitialStateFromF, 2),
|
28
29
|
filtersState = _useInitialStateFromF2[0],
|
29
30
|
setFiltersState = _useInitialStateFromF2[1];
|
30
|
-
var _useState = useState(
|
31
|
+
var _useState = useState(initialFilters),
|
31
32
|
_useState2 = _slicedToArray(_useState, 2),
|
32
33
|
filtersObjectArray = _useState2[0],
|
33
34
|
setFiltersObjectArray = _useState2[1];
|
@@ -44,8 +45,11 @@ var useFilters = function useFilters(_ref) {
|
|
44
45
|
setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
|
45
46
|
};
|
46
47
|
var reset = function reset() {
|
48
|
+
// When we reset we want the "initialFilters" to be an empty array
|
49
|
+
var resetFiltersArray = [];
|
50
|
+
|
47
51
|
// Get the initial values for the filters
|
48
|
-
var initialFiltersState = getInitialStateFromFilters(filters, variation);
|
52
|
+
var initialFiltersState = getInitialStateFromFilters(filters, variation, resetFiltersArray);
|
49
53
|
var initialFiltersObjectArray = [];
|
50
54
|
|
51
55
|
// Set the state to the initial values
|
package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js
CHANGED
@@ -11,7 +11,8 @@ import { FLYOUT } from '../constants';
|
|
11
11
|
import { getInitialStateFromFilters } from '../utils';
|
12
12
|
var useInitialStateFromFilters = function useInitialStateFromFilters(filters) {
|
13
13
|
var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FLYOUT;
|
14
|
-
var
|
14
|
+
var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
15
|
+
var _useState = useState(getInitialStateFromFilters(filters, variation, initialFilters)),
|
15
16
|
_useState2 = _slicedToArray(_useState, 2),
|
16
17
|
state = _useState2[0],
|
17
18
|
setState = _useState2[1];
|
@@ -6,10 +6,21 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import { CHECKBOX, DATE, DROPDOWN, FLYOUT, NUMBER, PANEL, RADIO } from './constants';
|
9
|
+
var applyInitialFilters = function applyInitialFilters(filterState, initialFilters) {
|
10
|
+
Object.keys(filterState).forEach(function (key) {
|
11
|
+
var hasInitialFilter = initialFilters.find(function (filter) {
|
12
|
+
return filter.id === key;
|
13
|
+
});
|
14
|
+
if (hasInitialFilter) {
|
15
|
+
filterState[key].value = hasInitialFilter.value;
|
16
|
+
}
|
17
|
+
});
|
18
|
+
};
|
9
19
|
|
10
20
|
// This functions takes the filters passed in and makes an object to track it's state
|
11
21
|
export var getInitialStateFromFilters = function getInitialStateFromFilters(filters) {
|
12
22
|
var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FLYOUT;
|
23
|
+
var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
|
13
24
|
var initialFilterState = {};
|
14
25
|
var setInitialState = function setInitialState(_ref) {
|
15
26
|
var type = _ref.type,
|
@@ -66,5 +77,8 @@ export var getInitialStateFromFilters = function getInitialStateFromFilters(filt
|
|
66
77
|
} else {
|
67
78
|
console.error('No variation passed into useInitialStateFromFilters');
|
68
79
|
}
|
80
|
+
if (initialFilters.length > 0) {
|
81
|
+
applyInitialFilters(initialFilterState, initialFilters);
|
82
|
+
}
|
69
83
|
return initialFilterState;
|
70
84
|
};
|
@@ -65,11 +65,13 @@ var useFiltering = function useFiltering(hooks) {
|
|
65
65
|
setAllFilters = instance.setAllFilters,
|
66
66
|
setFilter = instance.setFilter,
|
67
67
|
headers = instance.headers,
|
68
|
-
data = instance.data
|
68
|
+
data = instance.data,
|
69
|
+
state = instance.state;
|
69
70
|
var defaultProps = {
|
70
71
|
variation: 'flyout',
|
71
72
|
updateMethod: BATCH,
|
72
|
-
panelIconDescription: 'Open filter panel'
|
73
|
+
panelIconDescription: 'Open filter panel',
|
74
|
+
initialFilters: state.filters
|
73
75
|
};
|
74
76
|
var getFilterFlyoutProps = function getFilterFlyoutProps() {
|
75
77
|
return _objectSpread(_objectSpread(_objectSpread({}, defaultProps), filterProps), {}, {
|
@@ -24,9 +24,17 @@ var useOnRowClick = function useOnRowClick(hooks) {
|
|
24
24
|
toggleRowSelected(id, true);
|
25
25
|
}
|
26
26
|
};
|
27
|
+
var onKeyDown = function onKeyDown(event) {
|
28
|
+
var key = event.key;
|
29
|
+
if (key === 'Enter') {
|
30
|
+
onClick();
|
31
|
+
}
|
32
|
+
};
|
27
33
|
return [props, {
|
28
|
-
onClick: onClick
|
34
|
+
onClick: onClick,
|
35
|
+
onKeyDown: onKeyDown
|
29
36
|
}, {
|
37
|
+
tabIndex: 0,
|
30
38
|
style: {
|
31
39
|
cursor: 'pointer'
|
32
40
|
}
|
@@ -71,6 +71,7 @@ var SelectRow = function SelectRow(datagridState) {
|
|
71
71
|
radio = datagridState.radio,
|
72
72
|
toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
|
73
73
|
onRadioSelect = datagridState.onRadioSelect,
|
74
|
+
onRowSelect = datagridState.onRowSelect,
|
74
75
|
columns = datagridState.columns,
|
75
76
|
withStickyColumn = datagridState.withStickyColumn;
|
76
77
|
var _useState = useState(window.innerWidth),
|
@@ -103,6 +104,7 @@ var SelectRow = function SelectRow(datagridState) {
|
|
103
104
|
}
|
104
105
|
}
|
105
106
|
onChange(e);
|
107
|
+
onRowSelect === null || onRowSelect === void 0 ? void 0 : onRowSelect(row, e);
|
106
108
|
},
|
107
109
|
id: "".concat(tableId, "-").concat(row.index),
|
108
110
|
name: "".concat(tableId, "-").concat(row.index, "-name"),
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
3
|
+
var _excluded = ["v2"];
|
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; }
|
6
|
+
/**
|
7
|
+
* Copyright IBM Corp. 2022, 2022
|
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.
|
11
|
+
*/
|
12
|
+
|
13
|
+
import React, { forwardRef } from 'react';
|
14
|
+
import PropTypes from 'prop-types';
|
15
|
+
import { pkg } from '../../settings';
|
16
|
+
import { InlineEditV1 } from '../InlineEditV1';
|
17
|
+
import { InlineEditV2 } from '../InlineEditV2';
|
18
|
+
|
19
|
+
/**
|
20
|
+
* this is a wrapper component that will allow us to support the rename of InlineEdit to EditInPlace
|
21
|
+
*
|
22
|
+
* if the user passes in the v2 feature flag the v2 version of the component will be rendered
|
23
|
+
* since this is a temporary solution the named export should just remain InlineEdit unlike how
|
24
|
+
* Card works as a base layer for Productive and Expressive cards.
|
25
|
+
*/
|
26
|
+
|
27
|
+
var componentName = 'EditInPlace';
|
28
|
+
export var EditInPlace = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
29
|
+
var v2 = _ref.v2,
|
30
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
31
|
+
var props = _objectSpread(_objectSpread({}, rest), {}, {
|
32
|
+
ref: ref
|
33
|
+
});
|
34
|
+
if (v2 === true) {
|
35
|
+
return /*#__PURE__*/React.createElement(InlineEditV2, props);
|
36
|
+
}
|
37
|
+
return /*#__PURE__*/React.createElement(InlineEditV1, props);
|
38
|
+
});
|
39
|
+
EditInPlace = pkg.checkComponentEnabled(EditInPlace, componentName);
|
40
|
+
EditInPlace.displayName = componentName;
|
41
|
+
EditInPlace.propTypes = {
|
42
|
+
v2: PropTypes.bool
|
43
|
+
};
|
@@ -45,11 +45,11 @@ ExpressiveCard.propTypes = {
|
|
45
45
|
/**
|
46
46
|
* Optional header description
|
47
47
|
*/
|
48
|
-
description: PropTypes.string,
|
48
|
+
description: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
49
49
|
/**
|
50
50
|
* Optional label for the top of the card
|
51
51
|
*/
|
52
|
-
label: PropTypes.string,
|
52
|
+
label: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node]),
|
53
53
|
/**
|
54
54
|
* Optional media content like an image to be placed in the card
|
55
55
|
*/
|
@@ -109,6 +109,6 @@ ExpressiveCard.propTypes = {
|
|
109
109
|
/**
|
110
110
|
* Title that's displayed at the top of the card
|
111
111
|
*/
|
112
|
-
title: PropTypes.string
|
112
|
+
title: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.node])
|
113
113
|
};
|
114
114
|
ExpressiveCard.displayName = componentName;
|
@@ -35,8 +35,12 @@ export var InlineEdit = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
35
35
|
}
|
36
36
|
return /*#__PURE__*/React.createElement(InlineEditV1, props);
|
37
37
|
});
|
38
|
-
InlineEdit =
|
38
|
+
InlineEdit.deprecated = {
|
39
|
+
details: "The InlineEdit component is being renamed to EditInPlace in the next major version of @carbon/ibm-products. You can prepare by updating your usage of InlineEdit to EditInPlace.",
|
40
|
+
level: 'warn'
|
41
|
+
};
|
39
42
|
InlineEdit.displayName = componentName;
|
43
|
+
InlineEdit = pkg.checkComponentEnabled(InlineEdit, componentName);
|
40
44
|
InlineEdit.propTypes = {
|
41
45
|
v2: PropTypes.bool
|
42
46
|
};
|
@@ -18,7 +18,6 @@ import React, { useRef, useState } from 'react';
|
|
18
18
|
import PropTypes from 'prop-types';
|
19
19
|
import cx from 'classnames';
|
20
20
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
21
|
-
import pconsole from '../../global/js/utils/pconsole';
|
22
21
|
import { pkg, carbon } from '../../settings';
|
23
22
|
|
24
23
|
// Carbon and package components we use.
|
@@ -83,7 +82,6 @@ export var InlineEditV1 = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
83
82
|
var showValidation = invalid; // || warn;
|
84
83
|
var validationText = invalidText; // || warnText;
|
85
84
|
var validationIcon = showValidation ? /*#__PURE__*/React.createElement(WarningFilled16, null) : null;
|
86
|
-
pconsole.warn("".concat(componentName, ": the v1 version of this component is being deprecated. please switch to the v2 component as soon as possible."));
|
87
85
|
|
88
86
|
// sanitize the tooltip values
|
89
87
|
var alignIsObject = _typeof(buttonTooltipAlignment) === 'object';
|
@@ -304,6 +302,11 @@ export var InlineEditV1 = /*#__PURE__*/React.forwardRef(function (_ref, refIn) {
|
|
304
302
|
// The display name of the component, used by React. Note that displayName
|
305
303
|
// is used in preference to relying on function.name.
|
306
304
|
InlineEditV1.displayName = componentName;
|
305
|
+
InlineEditV1.deprecated = {
|
306
|
+
level: 'warn',
|
307
|
+
details: "The v1 version of this component is being deprecated. please switch to the v2 component as soon as possible."
|
308
|
+
};
|
309
|
+
pkg.logDeprecated(InlineEditV1, componentName);
|
307
310
|
|
308
311
|
// The types and DocGen commentary for the component props,
|
309
312
|
// in alphabetical order (for consistency).
|