@carbon/ibm-products 1.66.0 → 1.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/css/index-full-carbon.css +7 -10
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +1 -1
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +7 -10
- 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 +7 -10
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +1 -1
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +7 -10
- package/css/index.css.map +1 -1
- package/css/index.min.css +1 -1
- package/css/index.min.css.map +1 -1
- package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +50 -8
- package/es/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +10 -7
- package/es/components/Datagrid/useNestedRows.js +50 -33
- package/es/components/Datagrid/useOnRowClick.js +1 -1
- package/es/components/index.js +1 -0
- package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +49 -7
- package/lib/components/Datagrid/Datagrid/addons/Filtering/motion/variants.js +10 -7
- package/lib/components/Datagrid/useNestedRows.js +50 -33
- package/lib/components/Datagrid/useOnRowClick.js +1 -1
- package/lib/components/index.js +7 -0
- package/package.json +2 -2
- package/scss/components/Datagrid/styles/_datagrid.scss +3 -2
- package/scss/components/Datagrid/styles/addons/_FilterFlyout.scss +11 -8
@@ -1,19 +1,19 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
|
-
// @flow
|
4
3
|
/**
|
5
|
-
* Copyright IBM Corp. 2022,
|
4
|
+
* Copyright IBM Corp. 2022, 2024
|
6
5
|
*
|
7
6
|
* This source code is licensed under the Apache-2.0 license found in the
|
8
7
|
* LICENSE file in the root directory of this source tree.
|
9
8
|
*/
|
10
9
|
|
11
|
-
import {
|
10
|
+
import React, { useRef, useState, useEffect } from 'react';
|
12
11
|
import { Button } from 'carbon-components-react';
|
12
|
+
import { Filter16 } from '@carbon/icons-react';
|
13
|
+
import { px, breakpoints } from '@carbon/layout';
|
13
14
|
import cx from 'classnames';
|
14
15
|
import PropTypes from 'prop-types';
|
15
|
-
import
|
16
|
-
import { useClickOutside } from '../../../../../global/js/hooks';
|
16
|
+
import { useClickOutside, useWindowResize } from '../../../../../global/js/hooks';
|
17
17
|
import { pkg } from '../../../../../settings';
|
18
18
|
import { ActionSet } from '../../../../ActionSet';
|
19
19
|
import { BATCH, CLEAR_FILTERS, FLYOUT, INSTANT } from './constants';
|
@@ -53,6 +53,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
53
53
|
_useState2 = _slicedToArray(_useState, 2),
|
54
54
|
open = _useState2[0],
|
55
55
|
setOpen = _useState2[1];
|
56
|
+
var _useState3 = useState(false),
|
57
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
58
|
+
stackedLayout = _useState4[0],
|
59
|
+
setStackedLayout = _useState4[1];
|
56
60
|
var _useFilters = useFilters({
|
57
61
|
updateMethod: updateMethod,
|
58
62
|
filters: filters,
|
@@ -69,9 +73,13 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
69
73
|
renderFilter = _useFilters.renderFilter,
|
70
74
|
filtersObjectArray = _useFilters.filtersObjectArray,
|
71
75
|
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
76
|
+
var width = breakpoints.md.width;
|
77
|
+
var mdPxWidth = parseInt(width) * 16;
|
72
78
|
|
73
79
|
/** Refs */
|
74
80
|
var filterFlyoutRef = useRef(null);
|
81
|
+
var flyoutInnerRef = useRef(null);
|
82
|
+
var flyoutFiltersContainerRef = useRef(null);
|
75
83
|
var _useShouldDisableButt = useShouldDisableButtons({
|
76
84
|
initialValue: true,
|
77
85
|
filtersState: filtersState,
|
@@ -80,6 +88,33 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
80
88
|
_useShouldDisableButt2 = _slicedToArray(_useShouldDisableButt, 2),
|
81
89
|
shouldDisableButtons = _useShouldDisableButt2[0],
|
82
90
|
setShouldDisableButtons = _useShouldDisableButt2[1];
|
91
|
+
var handleResize = function handleResize(current) {
|
92
|
+
var filterFlyoutRefPosition = flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current.getBoundingClientRect();
|
93
|
+
var originalFlyoutWidth = parseInt(window.getComputedStyle(flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current).getPropertyValue('width'));
|
94
|
+
// Check to see if left value from flyout getBoundingClientRect is a negative number
|
95
|
+
// If it is, that is the amount we need to subtract from the flyout width
|
96
|
+
if (Math.sign(filterFlyoutRefPosition.left) === -1) {
|
97
|
+
var newFlyoutWidth = originalFlyoutWidth - Math.abs(filterFlyoutRefPosition.left);
|
98
|
+
flyoutInnerRef.current.style.width = px(newFlyoutWidth);
|
99
|
+
}
|
100
|
+
// Check to see if left value from flyout getBoundingClientRect is a positive number or 0
|
101
|
+
// If it is, that is the amount we need to add to the flyout width until we reach the
|
102
|
+
// max-width of the flyout (642)
|
103
|
+
if (originalFlyoutWidth < 642 && Math.sign(filterFlyoutRefPosition.left) === 1 || Math.sign(filterFlyoutRefPosition.left).toString() === '0') {
|
104
|
+
var _newFlyoutWidth = originalFlyoutWidth + Math.abs(filterFlyoutRefPosition.left);
|
105
|
+
flyoutInnerRef.current.style.width = px(_newFlyoutWidth);
|
106
|
+
}
|
107
|
+
// Begin stacking filters at this specific point
|
108
|
+
if ((current === null || current === void 0 ? void 0 : current.innerWidth) <= mdPxWidth + 254) {
|
109
|
+
setStackedLayout(true);
|
110
|
+
} else {
|
111
|
+
setStackedLayout(false);
|
112
|
+
}
|
113
|
+
};
|
114
|
+
useWindowResize(function (_ref2) {
|
115
|
+
var current = _ref2.current;
|
116
|
+
handleResize(current);
|
117
|
+
});
|
83
118
|
|
84
119
|
/** Memos */
|
85
120
|
var showActionSet = updateMethod === BATCH;
|
@@ -92,7 +127,12 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
92
127
|
var closeFlyout = function closeFlyout() {
|
93
128
|
setOpen(false);
|
94
129
|
onFlyoutClose();
|
130
|
+
flyoutInnerRef.current.style.width = px(642);
|
95
131
|
};
|
132
|
+
useEffect(function () {
|
133
|
+
// Initialize flyout width
|
134
|
+
flyoutInnerRef.current.style.width = px(642);
|
135
|
+
}, []);
|
96
136
|
var apply = function apply() {
|
97
137
|
setAllFilters(filtersObjectArray);
|
98
138
|
closeFlyout();
|
@@ -151,7 +191,8 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
151
191
|
lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
|
152
192
|
}, [reactTableFiltersState, lastAppliedFilters]);
|
153
193
|
return /*#__PURE__*/React.createElement("div", {
|
154
|
-
className: "".concat(componentClass, "__container")
|
194
|
+
className: "".concat(componentClass, "__container"),
|
195
|
+
ref: filterFlyoutRef
|
155
196
|
}, /*#__PURE__*/React.createElement(Button, {
|
156
197
|
kind: "ghost",
|
157
198
|
hasIconOnly: true,
|
@@ -162,14 +203,15 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
162
203
|
className: cx("".concat(componentClass, "__trigger"), _defineProperty({}, "".concat(componentClass, "__trigger--open"), open)),
|
163
204
|
disabled: data.length === 0
|
164
205
|
}), /*#__PURE__*/React.createElement("div", {
|
165
|
-
ref:
|
206
|
+
ref: flyoutInnerRef,
|
166
207
|
className: cx(componentClass, (_cx2 = {}, _defineProperty(_cx2, "".concat(componentClass, "--open"), open), _defineProperty(_cx2, "".concat(componentClass, "--batch"), showActionSet), _defineProperty(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
|
167
208
|
}, /*#__PURE__*/React.createElement("div", {
|
168
209
|
className: "".concat(componentClass, "__inner-container")
|
169
210
|
}, /*#__PURE__*/React.createElement("span", {
|
170
211
|
className: "".concat(componentClass, "__title")
|
171
212
|
}, title), /*#__PURE__*/React.createElement("div", {
|
172
|
-
className: "".concat(componentClass, "__filters")
|
213
|
+
className: cx("".concat(componentClass, "__filters"), _defineProperty({}, "".concat(componentClass, "__stacked"), stackedLayout)),
|
214
|
+
ref: flyoutFiltersContainerRef
|
173
215
|
}, renderFilters())), renderActionSet()));
|
174
216
|
};
|
175
217
|
FilterFlyout.propTypes = {
|
@@ -36,7 +36,7 @@ export var innerContainerVariants = {
|
|
36
36
|
return {
|
37
37
|
opacity: 0,
|
38
38
|
transition: {
|
39
|
-
duration: shouldReduceMotion ?
|
39
|
+
duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast01,
|
40
40
|
ease: shouldReduceMotion ? 0 : EASINGS.productive.exit
|
41
41
|
}
|
42
42
|
};
|
@@ -45,9 +45,9 @@ export var innerContainerVariants = {
|
|
45
45
|
return {
|
46
46
|
opacity: 1,
|
47
47
|
transition: {
|
48
|
-
duration: shouldReduceMotion ?
|
48
|
+
duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast02,
|
49
49
|
ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance,
|
50
|
-
when: 'beforeChildren'
|
50
|
+
when: shouldReduceMotion ? null : 'beforeChildren'
|
51
51
|
}
|
52
52
|
};
|
53
53
|
}
|
@@ -55,9 +55,10 @@ export var innerContainerVariants = {
|
|
55
55
|
export var actionSetVariants = {
|
56
56
|
hidden: function hidden(shouldReduceMotion) {
|
57
57
|
return {
|
58
|
-
y: ACTION_SET_HEIGHT,
|
58
|
+
y: shouldReduceMotion ? 0 : ACTION_SET_HEIGHT,
|
59
|
+
opacity: shouldReduceMotion ? 0 : 1,
|
59
60
|
transition: {
|
60
|
-
duration: shouldReduceMotion ?
|
61
|
+
duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast01,
|
61
62
|
ease: shouldReduceMotion ? 0 : EASINGS.productive.exit
|
62
63
|
}
|
63
64
|
};
|
@@ -65,9 +66,11 @@ export var actionSetVariants = {
|
|
65
66
|
visible: function visible(shouldReduceMotion) {
|
66
67
|
return {
|
67
68
|
y: 0,
|
69
|
+
opacity: 1,
|
68
70
|
transition: {
|
69
|
-
duration: shouldReduceMotion ?
|
70
|
-
ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance
|
71
|
+
duration: shouldReduceMotion ? DURATIONS.moderate01 : DURATIONS.fast02,
|
72
|
+
ease: shouldReduceMotion ? 0 : EASINGS.productive.entrance,
|
73
|
+
delay: shouldReduceMotion ? 0.075 : 0
|
71
74
|
}
|
72
75
|
};
|
73
76
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
2
2
|
/**
|
3
|
-
* Copyright IBM Corp. 2020,
|
3
|
+
* Copyright IBM Corp. 2020, 2024
|
4
4
|
*
|
5
5
|
* This source code is licensed under the Apache-2.0 license found in the
|
6
6
|
* LICENSE file in the root directory of this source tree.
|
@@ -9,46 +9,63 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
9
9
|
import { pkg } from '../../settings';
|
10
10
|
import cx from 'classnames';
|
11
11
|
import useNestedRowExpander from './useNestedRowExpander';
|
12
|
+
import { useEffect } from 'react';
|
12
13
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
13
14
|
var useNestedRows = function useNestedRows(hooks) {
|
14
15
|
useNestedRowExpander(hooks);
|
15
|
-
var marginLeft = 24;
|
16
|
-
var getRowProps = function getRowProps(props, _ref) {
|
17
|
-
var _cx;
|
18
|
-
var row = _ref.row;
|
19
|
-
return [props, {
|
20
|
-
className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-nested-row"), row.depth > 0), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _cx))
|
21
|
-
}];
|
22
|
-
};
|
23
|
-
var getRowStyles = function getRowStyles(props, _ref2) {
|
24
|
-
var row = _ref2.row;
|
25
|
-
return [props, {
|
26
|
-
style: {
|
27
|
-
paddingLeft: "".concat(row.depth > 1 ? marginLeft * 2 + (row.depth - 1) * (marginLeft + marginLeft / 3) : row.depth === 1 ? marginLeft * 2 : 0, "px")
|
28
|
-
}
|
29
|
-
}];
|
30
|
-
};
|
31
|
-
var getCellProps = function getCellProps(props, _ref3) {
|
32
|
-
var cell = _ref3.cell,
|
33
|
-
instance = _ref3.instance;
|
34
|
-
// reduce the "first cell"s width to compensate added (left) margin
|
35
|
-
var isFirstCell = instance.columns.findIndex(function (c) {
|
36
|
-
return c.id === cell.column.id;
|
37
|
-
}) === 0;
|
38
|
-
return [props, {
|
39
|
-
style: {
|
40
|
-
marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "".concat(-32 * cell.row.depth - 18, "px") : '')
|
41
|
-
}
|
42
|
-
}];
|
43
|
-
};
|
44
16
|
var useInstance = function useInstance(instance) {
|
17
|
+
// This useEffect will expand rows if they exist in the initialState obj
|
18
|
+
useEffect(function () {
|
19
|
+
var rows = instance.rows,
|
20
|
+
initialState = instance.initialState;
|
21
|
+
var expandedRowIds = initialState.expandedRowIds;
|
22
|
+
if (expandedRowIds) {
|
23
|
+
Object.keys(expandedRowIds).forEach(function (key) {
|
24
|
+
var row = rows.filter(function (r) {
|
25
|
+
return r.id.toString() === key.toString();
|
26
|
+
});
|
27
|
+
if (row.length && key.toString() === row[0].id.toString()) {
|
28
|
+
row[0].toggleRowExpanded();
|
29
|
+
}
|
30
|
+
});
|
31
|
+
}
|
32
|
+
}, [instance]);
|
33
|
+
var marginLeft = 24;
|
34
|
+
var getRowProps = function getRowProps(props, _ref) {
|
35
|
+
var _cx;
|
36
|
+
var row = _ref.row;
|
37
|
+
return [props, {
|
38
|
+
className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-nested-row"), row.depth > 0), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _cx))
|
39
|
+
}];
|
40
|
+
};
|
41
|
+
var getRowStyles = function getRowStyles(props, _ref2) {
|
42
|
+
var row = _ref2.row;
|
43
|
+
return [props, {
|
44
|
+
style: {
|
45
|
+
paddingLeft: "".concat(row.depth > 1 ? marginLeft * 2 + (row.depth - 1) * (marginLeft + marginLeft / 3) : row.depth === 1 ? marginLeft * 2 : 0, "px")
|
46
|
+
}
|
47
|
+
}];
|
48
|
+
};
|
49
|
+
var getCellProps = function getCellProps(props, _ref3) {
|
50
|
+
var cell = _ref3.cell,
|
51
|
+
instance = _ref3.instance;
|
52
|
+
// reduce the "first cell"s width to compensate added (left) margin
|
53
|
+
var isFirstCell = instance.columns.findIndex(function (c) {
|
54
|
+
return c.id === cell.column.id;
|
55
|
+
}) === 0;
|
56
|
+
return [props, {
|
57
|
+
style: {
|
58
|
+
marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "".concat(-32 * cell.row.depth - 18, "px") : '')
|
59
|
+
}
|
60
|
+
}];
|
61
|
+
};
|
45
62
|
Object.assign(instance, {
|
46
63
|
withNestedRows: true
|
47
64
|
});
|
65
|
+
hooks.getRowProps.push(getRowProps);
|
66
|
+
hooks.getRowProps.push(getRowStyles);
|
67
|
+
hooks.getCellProps.push(getCellProps);
|
48
68
|
};
|
49
|
-
hooks.getRowProps.push(getRowProps);
|
50
|
-
hooks.getRowProps.push(getRowStyles);
|
51
|
-
hooks.getCellProps.push(getCellProps);
|
52
69
|
hooks.useInstance.push(useInstance);
|
53
70
|
};
|
54
71
|
export default useNestedRows;
|
@@ -29,7 +29,7 @@ var useOnRowClick = function useOnRowClick(hooks) {
|
|
29
29
|
row.classList.remove("".concat(carbon.prefix, "--data-table--selected"));
|
30
30
|
});
|
31
31
|
}
|
32
|
-
var closestRow = event.target.closest(
|
32
|
+
var closestRow = event.target.closest('tr');
|
33
33
|
closestRow.classList.add("".concat(carbon.prefix, "--data-table--selected"));
|
34
34
|
if (!withSelectRows) {
|
35
35
|
instance.selectedFlatRows && instance.selectedFlatRows.map(function (toggleRow) {
|
package/es/components/index.js
CHANGED
@@ -7,6 +7,7 @@
|
|
7
7
|
|
8
8
|
export { AboutModal } from './AboutModal';
|
9
9
|
export { APIKeyModal } from './APIKeyModal';
|
10
|
+
export { ButtonMenu } from './ButtonMenu';
|
10
11
|
export { Cascade } from './Cascade';
|
11
12
|
export { ComboButton, ComboButtonItem } from './ComboButton';
|
12
13
|
export { CreateFullPage, CreateFullPageStep } from './CreateFullPage';
|
@@ -8,11 +8,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
exports.default = void 0;
|
9
9
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
10
10
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
11
|
-
var
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
12
12
|
var _carbonComponentsReact = require("carbon-components-react");
|
13
|
+
var _iconsReact = require("@carbon/icons-react");
|
14
|
+
var _layout = require("@carbon/layout");
|
13
15
|
var _classnames = _interopRequireDefault(require("classnames"));
|
14
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
15
|
-
var _react = _interopRequireWildcard(require("react"));
|
16
17
|
var _hooks = require("../../../../../global/js/hooks");
|
17
18
|
var _settings = require("../../../../../settings");
|
18
19
|
var _ActionSet = require("../../../../ActionSet");
|
@@ -20,9 +21,8 @@ var _constants = require("./constants");
|
|
20
21
|
var _hooks2 = require("./hooks");
|
21
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
22
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
23
|
-
// @flow
|
24
24
|
/**
|
25
|
-
* Copyright IBM Corp. 2022,
|
25
|
+
* Copyright IBM Corp. 2022, 2024
|
26
26
|
*
|
27
27
|
* This source code is licensed under the Apache-2.0 license found in the
|
28
28
|
* LICENSE file in the root directory of this source tree.
|
@@ -62,6 +62,10 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
62
62
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
63
63
|
open = _useState2[0],
|
64
64
|
setOpen = _useState2[1];
|
65
|
+
var _useState3 = (0, _react.useState)(false),
|
66
|
+
_useState4 = (0, _slicedToArray2.default)(_useState3, 2),
|
67
|
+
stackedLayout = _useState4[0],
|
68
|
+
setStackedLayout = _useState4[1];
|
65
69
|
var _useFilters = (0, _hooks2.useFilters)({
|
66
70
|
updateMethod: updateMethod,
|
67
71
|
filters: filters,
|
@@ -78,9 +82,13 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
78
82
|
renderFilter = _useFilters.renderFilter,
|
79
83
|
filtersObjectArray = _useFilters.filtersObjectArray,
|
80
84
|
lastAppliedFilters = _useFilters.lastAppliedFilters;
|
85
|
+
var width = _layout.breakpoints.md.width;
|
86
|
+
var mdPxWidth = parseInt(width) * 16;
|
81
87
|
|
82
88
|
/** Refs */
|
83
89
|
var filterFlyoutRef = (0, _react.useRef)(null);
|
90
|
+
var flyoutInnerRef = (0, _react.useRef)(null);
|
91
|
+
var flyoutFiltersContainerRef = (0, _react.useRef)(null);
|
84
92
|
var _useShouldDisableButt = (0, _hooks2.useShouldDisableButtons)({
|
85
93
|
initialValue: true,
|
86
94
|
filtersState: filtersState,
|
@@ -89,6 +97,33 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
89
97
|
_useShouldDisableButt2 = (0, _slicedToArray2.default)(_useShouldDisableButt, 2),
|
90
98
|
shouldDisableButtons = _useShouldDisableButt2[0],
|
91
99
|
setShouldDisableButtons = _useShouldDisableButt2[1];
|
100
|
+
var handleResize = function handleResize(current) {
|
101
|
+
var filterFlyoutRefPosition = flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current.getBoundingClientRect();
|
102
|
+
var originalFlyoutWidth = parseInt(window.getComputedStyle(flyoutInnerRef === null || flyoutInnerRef === void 0 ? void 0 : flyoutInnerRef.current).getPropertyValue('width'));
|
103
|
+
// Check to see if left value from flyout getBoundingClientRect is a negative number
|
104
|
+
// If it is, that is the amount we need to subtract from the flyout width
|
105
|
+
if (Math.sign(filterFlyoutRefPosition.left) === -1) {
|
106
|
+
var newFlyoutWidth = originalFlyoutWidth - Math.abs(filterFlyoutRefPosition.left);
|
107
|
+
flyoutInnerRef.current.style.width = (0, _layout.px)(newFlyoutWidth);
|
108
|
+
}
|
109
|
+
// Check to see if left value from flyout getBoundingClientRect is a positive number or 0
|
110
|
+
// If it is, that is the amount we need to add to the flyout width until we reach the
|
111
|
+
// max-width of the flyout (642)
|
112
|
+
if (originalFlyoutWidth < 642 && Math.sign(filterFlyoutRefPosition.left) === 1 || Math.sign(filterFlyoutRefPosition.left).toString() === '0') {
|
113
|
+
var _newFlyoutWidth = originalFlyoutWidth + Math.abs(filterFlyoutRefPosition.left);
|
114
|
+
flyoutInnerRef.current.style.width = (0, _layout.px)(_newFlyoutWidth);
|
115
|
+
}
|
116
|
+
// Begin stacking filters at this specific point
|
117
|
+
if ((current === null || current === void 0 ? void 0 : current.innerWidth) <= mdPxWidth + 254) {
|
118
|
+
setStackedLayout(true);
|
119
|
+
} else {
|
120
|
+
setStackedLayout(false);
|
121
|
+
}
|
122
|
+
};
|
123
|
+
(0, _hooks.useWindowResize)(function (_ref2) {
|
124
|
+
var current = _ref2.current;
|
125
|
+
handleResize(current);
|
126
|
+
});
|
92
127
|
|
93
128
|
/** Memos */
|
94
129
|
var showActionSet = updateMethod === _constants.BATCH;
|
@@ -101,7 +136,12 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
101
136
|
var closeFlyout = function closeFlyout() {
|
102
137
|
setOpen(false);
|
103
138
|
onFlyoutClose();
|
139
|
+
flyoutInnerRef.current.style.width = (0, _layout.px)(642);
|
104
140
|
};
|
141
|
+
(0, _react.useEffect)(function () {
|
142
|
+
// Initialize flyout width
|
143
|
+
flyoutInnerRef.current.style.width = (0, _layout.px)(642);
|
144
|
+
}, []);
|
105
145
|
var apply = function apply() {
|
106
146
|
setAllFilters(filtersObjectArray);
|
107
147
|
closeFlyout();
|
@@ -160,7 +200,8 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
160
200
|
lastAppliedFilters.current = JSON.stringify(reactTableFiltersState);
|
161
201
|
}, [reactTableFiltersState, lastAppliedFilters]);
|
162
202
|
return /*#__PURE__*/_react.default.createElement("div", {
|
163
|
-
className: "".concat(componentClass, "__container")
|
203
|
+
className: "".concat(componentClass, "__container"),
|
204
|
+
ref: filterFlyoutRef
|
164
205
|
}, /*#__PURE__*/_react.default.createElement(_carbonComponentsReact.Button, {
|
165
206
|
kind: "ghost",
|
166
207
|
hasIconOnly: true,
|
@@ -171,14 +212,15 @@ var FilterFlyout = function FilterFlyout(_ref) {
|
|
171
212
|
className: (0, _classnames.default)("".concat(componentClass, "__trigger"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__trigger--open"), open)),
|
172
213
|
disabled: data.length === 0
|
173
214
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
174
|
-
ref:
|
215
|
+
ref: flyoutInnerRef,
|
175
216
|
className: (0, _classnames.default)(componentClass, (_cx2 = {}, (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--open"), open), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--batch"), showActionSet), (0, _defineProperty2.default)(_cx2, "".concat(componentClass, "--instant"), !showActionSet), _cx2))
|
176
217
|
}, /*#__PURE__*/_react.default.createElement("div", {
|
177
218
|
className: "".concat(componentClass, "__inner-container")
|
178
219
|
}, /*#__PURE__*/_react.default.createElement("span", {
|
179
220
|
className: "".concat(componentClass, "__title")
|
180
221
|
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
181
|
-
className: "".concat(componentClass, "__filters")
|
222
|
+
className: (0, _classnames.default)("".concat(componentClass, "__filters"), (0, _defineProperty2.default)({}, "".concat(componentClass, "__stacked"), stackedLayout)),
|
223
|
+
ref: flyoutFiltersContainerRef
|
182
224
|
}, renderFilters())), renderActionSet()));
|
183
225
|
};
|
184
226
|
FilterFlyout.propTypes = {
|
@@ -43,7 +43,7 @@ var innerContainerVariants = {
|
|
43
43
|
return {
|
44
44
|
opacity: 0,
|
45
45
|
transition: {
|
46
|
-
duration: shouldReduceMotion ?
|
46
|
+
duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast01,
|
47
47
|
ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.exit
|
48
48
|
}
|
49
49
|
};
|
@@ -52,9 +52,9 @@ var innerContainerVariants = {
|
|
52
52
|
return {
|
53
53
|
opacity: 1,
|
54
54
|
transition: {
|
55
|
-
duration: shouldReduceMotion ?
|
55
|
+
duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast02,
|
56
56
|
ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.entrance,
|
57
|
-
when: 'beforeChildren'
|
57
|
+
when: shouldReduceMotion ? null : 'beforeChildren'
|
58
58
|
}
|
59
59
|
};
|
60
60
|
}
|
@@ -63,9 +63,10 @@ exports.innerContainerVariants = innerContainerVariants;
|
|
63
63
|
var actionSetVariants = {
|
64
64
|
hidden: function hidden(shouldReduceMotion) {
|
65
65
|
return {
|
66
|
-
y: _constants.ACTION_SET_HEIGHT,
|
66
|
+
y: shouldReduceMotion ? 0 : _constants.ACTION_SET_HEIGHT,
|
67
|
+
opacity: shouldReduceMotion ? 0 : 1,
|
67
68
|
transition: {
|
68
|
-
duration: shouldReduceMotion ?
|
69
|
+
duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast01,
|
69
70
|
ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.exit
|
70
71
|
}
|
71
72
|
};
|
@@ -73,9 +74,11 @@ var actionSetVariants = {
|
|
73
74
|
visible: function visible(shouldReduceMotion) {
|
74
75
|
return {
|
75
76
|
y: 0,
|
77
|
+
opacity: 1,
|
76
78
|
transition: {
|
77
|
-
duration: shouldReduceMotion ?
|
78
|
-
ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.entrance
|
79
|
+
duration: shouldReduceMotion ? _motionConstants.DURATIONS.moderate01 : _motionConstants.DURATIONS.fast02,
|
80
|
+
ease: shouldReduceMotion ? 0 : _motionConstants.EASINGS.productive.entrance,
|
81
|
+
delay: shouldReduceMotion ? 0.075 : 0
|
79
82
|
}
|
80
83
|
};
|
81
84
|
}
|
@@ -9,8 +9,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
9
9
|
var _settings = require("../../settings");
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
11
11
|
var _useNestedRowExpander = _interopRequireDefault(require("./useNestedRowExpander"));
|
12
|
+
var _react = require("react");
|
12
13
|
/**
|
13
|
-
* Copyright IBM Corp. 2020,
|
14
|
+
* Copyright IBM Corp. 2020, 2024
|
14
15
|
*
|
15
16
|
* This source code is licensed under the Apache-2.0 license found in the
|
16
17
|
* LICENSE file in the root directory of this source tree.
|
@@ -19,43 +20,59 @@ var _useNestedRowExpander = _interopRequireDefault(require("./useNestedRowExpand
|
|
19
20
|
var blockClass = "".concat(_settings.pkg.prefix, "--datagrid");
|
20
21
|
var useNestedRows = function useNestedRows(hooks) {
|
21
22
|
(0, _useNestedRowExpander.default)(hooks);
|
22
|
-
var marginLeft = 24;
|
23
|
-
var getRowProps = function getRowProps(props, _ref) {
|
24
|
-
var _cx;
|
25
|
-
var row = _ref.row;
|
26
|
-
return [props, {
|
27
|
-
className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-nested-row"), row.depth > 0), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _cx))
|
28
|
-
}];
|
29
|
-
};
|
30
|
-
var getRowStyles = function getRowStyles(props, _ref2) {
|
31
|
-
var row = _ref2.row;
|
32
|
-
return [props, {
|
33
|
-
style: {
|
34
|
-
paddingLeft: "".concat(row.depth > 1 ? marginLeft * 2 + (row.depth - 1) * (marginLeft + marginLeft / 3) : row.depth === 1 ? marginLeft * 2 : 0, "px")
|
35
|
-
}
|
36
|
-
}];
|
37
|
-
};
|
38
|
-
var getCellProps = function getCellProps(props, _ref3) {
|
39
|
-
var cell = _ref3.cell,
|
40
|
-
instance = _ref3.instance;
|
41
|
-
// reduce the "first cell"s width to compensate added (left) margin
|
42
|
-
var isFirstCell = instance.columns.findIndex(function (c) {
|
43
|
-
return c.id === cell.column.id;
|
44
|
-
}) === 0;
|
45
|
-
return [props, {
|
46
|
-
style: {
|
47
|
-
marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "".concat(-32 * cell.row.depth - 18, "px") : '')
|
48
|
-
}
|
49
|
-
}];
|
50
|
-
};
|
51
23
|
var useInstance = function useInstance(instance) {
|
24
|
+
// This useEffect will expand rows if they exist in the initialState obj
|
25
|
+
(0, _react.useEffect)(function () {
|
26
|
+
var rows = instance.rows,
|
27
|
+
initialState = instance.initialState;
|
28
|
+
var expandedRowIds = initialState.expandedRowIds;
|
29
|
+
if (expandedRowIds) {
|
30
|
+
Object.keys(expandedRowIds).forEach(function (key) {
|
31
|
+
var row = rows.filter(function (r) {
|
32
|
+
return r.id.toString() === key.toString();
|
33
|
+
});
|
34
|
+
if (row.length && key.toString() === row[0].id.toString()) {
|
35
|
+
row[0].toggleRowExpanded();
|
36
|
+
}
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}, [instance]);
|
40
|
+
var marginLeft = 24;
|
41
|
+
var getRowProps = function getRowProps(props, _ref) {
|
42
|
+
var _cx;
|
43
|
+
var row = _ref.row;
|
44
|
+
return [props, {
|
45
|
+
className: (0, _classnames.default)((_cx = {}, (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-nested-row"), row.depth > 0), (0, _defineProperty2.default)(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _cx))
|
46
|
+
}];
|
47
|
+
};
|
48
|
+
var getRowStyles = function getRowStyles(props, _ref2) {
|
49
|
+
var row = _ref2.row;
|
50
|
+
return [props, {
|
51
|
+
style: {
|
52
|
+
paddingLeft: "".concat(row.depth > 1 ? marginLeft * 2 + (row.depth - 1) * (marginLeft + marginLeft / 3) : row.depth === 1 ? marginLeft * 2 : 0, "px")
|
53
|
+
}
|
54
|
+
}];
|
55
|
+
};
|
56
|
+
var getCellProps = function getCellProps(props, _ref3) {
|
57
|
+
var cell = _ref3.cell,
|
58
|
+
instance = _ref3.instance;
|
59
|
+
// reduce the "first cell"s width to compensate added (left) margin
|
60
|
+
var isFirstCell = instance.columns.findIndex(function (c) {
|
61
|
+
return c.id === cell.column.id;
|
62
|
+
}) === 0;
|
63
|
+
return [props, {
|
64
|
+
style: {
|
65
|
+
marginRight: "".concat(isFirstCell && cell.row.depth > 0 ? "".concat(-32 * cell.row.depth - 18, "px") : '')
|
66
|
+
}
|
67
|
+
}];
|
68
|
+
};
|
52
69
|
Object.assign(instance, {
|
53
70
|
withNestedRows: true
|
54
71
|
});
|
72
|
+
hooks.getRowProps.push(getRowProps);
|
73
|
+
hooks.getRowProps.push(getRowStyles);
|
74
|
+
hooks.getCellProps.push(getCellProps);
|
55
75
|
};
|
56
|
-
hooks.getRowProps.push(getRowProps);
|
57
|
-
hooks.getRowProps.push(getRowStyles);
|
58
|
-
hooks.getCellProps.push(getCellProps);
|
59
76
|
hooks.useInstance.push(useInstance);
|
60
77
|
};
|
61
78
|
var _default = useNestedRows;
|
@@ -35,7 +35,7 @@ var useOnRowClick = function useOnRowClick(hooks) {
|
|
35
35
|
row.classList.remove("".concat(_settings.carbon.prefix, "--data-table--selected"));
|
36
36
|
});
|
37
37
|
}
|
38
|
-
var closestRow = event.target.closest(
|
38
|
+
var closestRow = event.target.closest('tr');
|
39
39
|
closestRow.classList.add("".concat(_settings.carbon.prefix, "--data-table--selected"));
|
40
40
|
if (!withSelectRows) {
|
41
41
|
instance.selectedFlatRows && instance.selectedFlatRows.map(function (toggleRow) {
|
package/lib/components/index.js
CHANGED
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "AboutModal", {
|
|
15
15
|
return _AboutModal.AboutModal;
|
16
16
|
}
|
17
17
|
});
|
18
|
+
Object.defineProperty(exports, "ButtonMenu", {
|
19
|
+
enumerable: true,
|
20
|
+
get: function get() {
|
21
|
+
return _ButtonMenu.ButtonMenu;
|
22
|
+
}
|
23
|
+
});
|
18
24
|
Object.defineProperty(exports, "Cascade", {
|
19
25
|
enumerable: true,
|
20
26
|
get: function get() {
|
@@ -587,6 +593,7 @@ Object.defineProperty(exports, "useWebTerminal", {
|
|
587
593
|
});
|
588
594
|
var _AboutModal = require("./AboutModal");
|
589
595
|
var _APIKeyModal = require("./APIKeyModal");
|
596
|
+
var _ButtonMenu = require("./ButtonMenu");
|
590
597
|
var _Cascade = require("./Cascade");
|
591
598
|
var _ComboButton = require("./ComboButton");
|
592
599
|
var _CreateFullPage = require("./CreateFullPage");
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@carbon/ibm-products",
|
3
3
|
"description": "Carbon for IBM Products",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.68.0",
|
5
5
|
"license": "Apache-2.0",
|
6
6
|
"main": "lib/index.js",
|
7
7
|
"module": "es/index.js",
|
@@ -97,5 +97,5 @@
|
|
97
97
|
"react": "^16.8.6 || ^17.0.1",
|
98
98
|
"react-dom": "^16.8.6 || ^17.0.1"
|
99
99
|
},
|
100
|
-
"gitHead": "
|
100
|
+
"gitHead": "d1c99ff4199bf3da40a4088dae72668f302d4268"
|
101
101
|
}
|
@@ -542,13 +542,14 @@
|
|
542
542
|
}
|
543
543
|
|
544
544
|
.#{$block-class}
|
545
|
-
.#{$carbon-prefix}--data-table--selected:not(.#{$block-class}__active-row)
|
545
|
+
.#{$carbon-prefix}--data-table--selected:not(.#{$block-class}__active-row)
|
546
|
+
td:first-child {
|
546
547
|
position: relative;
|
547
548
|
}
|
548
549
|
|
549
550
|
.#{$block-class}
|
550
551
|
.#{$carbon-prefix}--data-table--selected:not(.#{$block-class}__active-row)
|
551
|
-
:first-child:not(.#{$carbon-prefix}--checkbox--inline)::before {
|
552
|
+
td:first-child:not(.#{$carbon-prefix}--checkbox--inline)::before {
|
552
553
|
position: absolute;
|
553
554
|
top: 0;
|
554
555
|
left: 0;
|