@carbon/ibm-products 1.62.0 → 1.62.1
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 +16 -2
- package/css/index-full-carbon.css.map +1 -1
- package/css/index-full-carbon.min.css +2 -2
- package/css/index-full-carbon.min.css.map +1 -1
- package/css/index-without-carbon-released-only.css +15 -0
- 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 +16 -2
- package/css/index-without-carbon.css.map +1 -1
- package/css/index-without-carbon.min.css +2 -2
- package/css/index-without-carbon.min.css.map +1 -1
- package/css/index.css +16 -2
- package/css/index.css.map +1 -1
- package/css/index.min.css +2 -2
- package/css/index.min.css.map +1 -1
- package/es/components/Carousel/Carousel.js +194 -119
- package/es/components/Carousel/CarouselItem.js +8 -21
- package/es/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +6 -7
- package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
- package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
- package/es/components/Datagrid/Datagrid/DatagridRow.js +19 -10
- package/es/components/Datagrid/Datagrid/DatagridSelectAll.js +19 -1
- package/es/components/Datagrid/Datagrid/DatagridToolbar.js +15 -1
- package/es/components/Datagrid/Datagrid/addons/stateReducer.js +67 -24
- package/es/components/Datagrid/useExpandedRow.js +3 -6
- package/es/components/Datagrid/useFocusRowExpander.js +40 -0
- package/es/components/Datagrid/useNestedRowExpander.js +9 -0
- package/es/components/Datagrid/useNestedRows.js +0 -4
- package/es/components/Datagrid/useRowExpander.js +9 -0
- package/es/components/Datagrid/useSelectRows.js +23 -11
- package/es/components/Guidebanner/Guidebanner.js +9 -12
- package/es/global/js/package-settings.js +0 -2
- package/lib/components/Carousel/Carousel.js +190 -114
- package/lib/components/Carousel/CarouselItem.js +9 -25
- package/lib/components/CoachmarkOverlayElements/CoachmarkOverlayElements.js +6 -7
- package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
- package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -0
- package/lib/components/Datagrid/Datagrid/DatagridRow.js +13 -3
- package/lib/components/Datagrid/Datagrid/DatagridSelectAll.js +19 -1
- package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +15 -1
- package/lib/components/Datagrid/Datagrid/addons/stateReducer.js +70 -26
- package/lib/components/Datagrid/useExpandedRow.js +2 -5
- package/lib/components/Datagrid/useFocusRowExpander.js +46 -0
- package/lib/components/Datagrid/useNestedRowExpander.js +9 -0
- package/lib/components/Datagrid/useNestedRows.js +0 -4
- package/lib/components/Datagrid/useRowExpander.js +9 -0
- package/lib/components/Datagrid/useSelectRows.js +17 -4
- package/lib/components/Guidebanner/Guidebanner.js +9 -12
- package/lib/global/js/package-settings.js +0 -2
- package/package.json +2 -2
- package/scss/components/Carousel/_carousel.scss +1 -2
- package/scss/components/Datagrid/styles/_useExpandedRow.scss +21 -0
- package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -0
- package/es/components/Carousel/utils.js +0 -98
- package/lib/components/Carousel/utils.js +0 -108
@@ -1,7 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
|
-
var _excluded = ["children", "className", "disableArrowScroll", "fadedEdgeColor", "
|
3
|
+
var _excluded = ["children", "className", "disableArrowScroll", "fadedEdgeColor", "onChangeIsScrollable", "onScroll"];
|
5
4
|
/**
|
6
5
|
* Copyright IBM Corp. 2023, 2023
|
7
6
|
*
|
@@ -9,20 +8,13 @@ var _excluded = ["children", "className", "disableArrowScroll", "fadedEdgeColor"
|
|
9
8
|
* LICENSE file in the root directory of this source tree.
|
10
9
|
*/
|
11
10
|
|
12
|
-
import React, { useCallback, useEffect, useImperativeHandle, useRef
|
13
|
-
|
14
|
-
// Other standard imports.
|
15
|
-
import { clamp, debounce } from 'lodash';
|
11
|
+
import React, { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
|
16
12
|
import PropTypes from 'prop-types';
|
17
13
|
import { CarouselItem } from './CarouselItem';
|
18
|
-
import { useIsOverflow, useWindowEvent } from './utils';
|
19
14
|
import cx from 'classnames';
|
20
15
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
21
16
|
import { pkg } from '../../settings';
|
22
17
|
|
23
|
-
// Carbon and package components we use.
|
24
|
-
/* TODO: @import(s) of carbon components and other package components. */
|
25
|
-
|
26
18
|
// The block part of our conventional BEM class names (blockClass__E--M).
|
27
19
|
var blockClass = "".concat(pkg.prefix, "--carousel");
|
28
20
|
var componentName = 'Carousel';
|
@@ -30,107 +22,178 @@ var componentName = 'Carousel';
|
|
30
22
|
// Default values for props
|
31
23
|
var defaults = {
|
32
24
|
disableArrowScroll: false,
|
33
|
-
|
25
|
+
onScroll: function onScroll() {},
|
26
|
+
onChangeIsScrollable: function onChangeIsScrollable() {}
|
34
27
|
};
|
35
28
|
|
36
29
|
/**
|
37
30
|
* The Carousel acts as a scaffold for other Novice to Pro content.
|
38
31
|
*
|
39
32
|
* This component is not intended for general use.
|
33
|
+
*
|
34
|
+
* Expected scrolling behavior.
|
35
|
+
* 1. Scroll the maximum number of visible items at a time.
|
36
|
+
* 2. The left-most item should always be left-aligned in the viewport.
|
37
|
+
*
|
38
|
+
* Exception.
|
39
|
+
* 1. After scrolling to the last (right-most) item,
|
40
|
+
* if some of its content remains hidden,
|
41
|
+
* then nudge it to the right until it is right-aligned.
|
42
|
+
* 2. From the right-aligned position, when scrolling left,
|
43
|
+
* the left-most item should again be left-aligned.
|
40
44
|
*/
|
41
|
-
|
45
|
+
var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
42
46
|
var children = _ref.children,
|
43
47
|
className = _ref.className,
|
44
48
|
_ref$disableArrowScro = _ref.disableArrowScroll,
|
45
49
|
disableArrowScroll = _ref$disableArrowScro === void 0 ? defaults.disableArrowScroll : _ref$disableArrowScro,
|
46
50
|
fadedEdgeColor = _ref.fadedEdgeColor,
|
47
|
-
|
48
|
-
_ref$
|
49
|
-
|
51
|
+
_ref$onChangeIsScroll = _ref.onChangeIsScrollable,
|
52
|
+
onChangeIsScrollable = _ref$onChangeIsScroll === void 0 ? defaults.onChangeIsScrollable : _ref$onChangeIsScroll,
|
53
|
+
_ref$onScroll = _ref.onScroll,
|
54
|
+
onScroll = _ref$onScroll === void 0 ? defaults.onScroll : _ref$onScroll,
|
50
55
|
rest = _objectWithoutProperties(_ref, _excluded);
|
51
|
-
var
|
52
|
-
var
|
56
|
+
var carouselRef = useRef();
|
57
|
+
var scrollRef = useRef();
|
58
|
+
// Array of refs used to reference this component's children DOM elements
|
59
|
+
var childElementsRef = useRef(Array(React.Children.count(children)).fill(useRef(null)));
|
53
60
|
var leftFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.left) || fadedEdgeColor;
|
54
61
|
var rightFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.right) || fadedEdgeColor;
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
return scrollToView(currentViewID + 1);
|
72
|
-
}, [currentViewID, scrollToView]);
|
73
|
-
var scrollPrev = useCallback(function () {
|
74
|
-
return scrollToView(currentViewID - 1);
|
75
|
-
}, [currentViewID, scrollToView]);
|
76
|
-
var scrollToView = useCallback(function (viewID) {
|
77
|
-
if (!isScrolling && scrollRef.current && mountedRef.current) {
|
78
|
-
var _scrollRef$current;
|
79
|
-
var targetViewID = clamp(viewID, 0, totalViews - 1);
|
80
|
-
setCurrentViewID(targetViewID);
|
81
|
-
setIsScrolling(true);
|
82
|
-
scrollRef.current.scrollLeft = ((_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.offsetWidth) * targetViewID + scrollTune;
|
83
|
-
return scrollPromise();
|
62
|
+
|
63
|
+
// Trigger callbacks to report state of the carousel
|
64
|
+
var handleOnScroll = useCallback(function () {
|
65
|
+
// viewport's width
|
66
|
+
var clientWidth = scrollRef.current.clientWidth;
|
67
|
+
// scroll position
|
68
|
+
var scrollLeft = parseInt(scrollRef.current.scrollLeft, 10);
|
69
|
+
// scrollable width
|
70
|
+
var scrollWidth = scrollRef.current.scrollWidth;
|
71
|
+
|
72
|
+
// The maximum scrollLeft achievable is the scrollable width - the viewport width.
|
73
|
+
var scrollLeftMax = scrollWidth - clientWidth;
|
74
|
+
// if isNaN(scrollLeft / scrollLeftMax), then set to zero
|
75
|
+
var scrollPercent = parseFloat((scrollLeft / scrollLeftMax).toFixed(2)) || 0;
|
76
|
+
if (!scrollRef.current) {
|
77
|
+
return;
|
84
78
|
}
|
85
|
-
|
86
|
-
|
79
|
+
|
80
|
+
// Callback 1: Does the carousel have enough content to enable scrolling?
|
81
|
+
onChangeIsScrollable(scrollWidth > clientWidth);
|
82
|
+
|
83
|
+
// Callback 2: Return the percentage of current scroll, between 0 and 1.
|
84
|
+
onScroll(scrollPercent);
|
85
|
+
}, [onChangeIsScrollable, onScroll]);
|
86
|
+
|
87
|
+
// Check if an individual child element is visible in the container
|
88
|
+
var getElementInView = useCallback(function (containerRect, elementRect) {
|
89
|
+
// Is the element's left greater than or equal to the containers left
|
90
|
+
var elementLeftIsRightOfContainerLeft = elementRect.left >= containerRect.left;
|
91
|
+
// Is the element's right less than or equal to the containers right
|
92
|
+
var elementRightIsLeftOfContainerRight = elementRect.right <= containerRect.right;
|
93
|
+
return elementLeftIsRightOfContainerLeft && elementRightIsLeftOfContainerRight;
|
94
|
+
}, []);
|
95
|
+
|
96
|
+
// Get all elements that are visible in the container.
|
97
|
+
var getElementsInView = useCallback(function () {
|
98
|
+
var containerRect = scrollRef.current.getBoundingClientRect();
|
99
|
+
var inViewElements = childElementsRef.current.filter(function (el) {
|
100
|
+
return getElementInView(containerRect, el.getBoundingClientRect());
|
87
101
|
});
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
102
|
+
return inViewElements;
|
103
|
+
}, [getElementInView]);
|
104
|
+
|
105
|
+
// Return container's and children's rect data
|
106
|
+
var getContainerAndChildRectData = useCallback(function () {
|
107
|
+
// Get the rect of the container
|
108
|
+
var containerRect = scrollRef.current.getBoundingClientRect();
|
109
|
+
// Get all child elements that are in view of the container, and return their bounding rects.
|
110
|
+
var elementRectsInView = getElementsInView().map(function (el) {
|
111
|
+
return el.getBoundingClientRect();
|
94
112
|
});
|
95
|
-
|
96
|
-
|
97
|
-
if
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
113
|
+
|
114
|
+
// What is the overall width of the visible elements in the container
|
115
|
+
// Note: may end up being 0 if the container's width is less than the child's width
|
116
|
+
var visibleWidth = elementRectsInView.reduce(function (accumulator, currentValue) {
|
117
|
+
return accumulator + currentValue.width;
|
118
|
+
}, 0);
|
119
|
+
return {
|
120
|
+
containerRect: containerRect,
|
121
|
+
elementRectsInView: elementRectsInView,
|
122
|
+
visibleWidth: visibleWidth
|
123
|
+
};
|
124
|
+
}, [getElementsInView]);
|
125
|
+
var handleScrollNext = useCallback(function () {
|
126
|
+
var _getContainerAndChild = getContainerAndChildRectData(),
|
127
|
+
containerRect = _getContainerAndChild.containerRect,
|
128
|
+
visibleWidth = _getContainerAndChild.visibleWidth;
|
129
|
+
// Set the scrollValue to the visibleWidth, but if the visibleWidth value is 0, set it to the container's width
|
130
|
+
var scrollValue = visibleWidth > 0 ? visibleWidth : containerRect.width;
|
131
|
+
// Increment the scrollLeft of the container
|
132
|
+
scrollRef.current.scrollLeft += scrollValue;
|
133
|
+
}, [getContainerAndChildRectData]);
|
134
|
+
var handleScrollPrev = useCallback(function () {
|
135
|
+
var _getContainerAndChild2 = getContainerAndChildRectData(),
|
136
|
+
containerRect = _getContainerAndChild2.containerRect,
|
137
|
+
elementRectsInView = _getContainerAndChild2.elementRectsInView,
|
138
|
+
visibleWidth = _getContainerAndChild2.visibleWidth;
|
139
|
+
// Set the scrollValue to the visibleWidth minus the first child's left value,
|
140
|
+
// but if the visibleWidth value is 0, set it to the container's width plus the container's left value
|
141
|
+
var scrollValue = visibleWidth > 0 ? visibleWidth - elementRectsInView[0].left : containerRect.width + containerRect.left;
|
142
|
+
|
143
|
+
// Decrement the scrollLeft of the container
|
144
|
+
scrollRef.current.scrollLeft -= scrollValue;
|
145
|
+
}, [getContainerAndChildRectData]);
|
146
|
+
var handleScrollReset = useCallback(function () {
|
147
|
+
// This doesn't trigger "scrollend"...
|
148
|
+
scrollRef.current.scrollLeft = 0;
|
149
|
+
// ...so trigger a callback manually.
|
150
|
+
handleOnScroll();
|
151
|
+
}, [handleOnScroll]);
|
152
|
+
var handleScrollToView = useCallback(function (itemNumber) {
|
153
|
+
childElementsRef.current[itemNumber].scrollIntoView();
|
102
154
|
}, []);
|
103
|
-
var scrollPosition = function scrollPosition() {
|
104
|
-
var _scrollRef$current2;
|
105
|
-
return (_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 ? void 0 : _scrollRef$current2.scrollLeft;
|
106
|
-
};
|
107
|
-
var maxScroll = function maxScroll() {
|
108
|
-
var _scrollRef$current3, _scrollRef$current4;
|
109
|
-
return ((_scrollRef$current3 = scrollRef.current) === null || _scrollRef$current3 === void 0 ? void 0 : _scrollRef$current3.scrollWidth) - ((_scrollRef$current4 = scrollRef.current) === null || _scrollRef$current4 === void 0 ? void 0 : _scrollRef$current4.clientWidth);
|
110
|
-
};
|
111
|
-
var handleResize = debounce(function () {
|
112
|
-
scrollToView(currentViewIDRef.current);
|
113
|
-
}, 200);
|
114
|
-
var setCurrentViewID = function setCurrentViewID(val) {
|
115
|
-
currentViewIDRef.current = val;
|
116
|
-
_setCurrentViewID(val);
|
117
|
-
};
|
118
|
-
var _useState3 = useState(false),
|
119
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
120
|
-
isScrolling = _useState4[0],
|
121
|
-
setIsScrolling = _useState4[1];
|
122
|
-
|
123
|
-
// EFFECTS
|
124
|
-
useWindowEvent('resize', handleResize);
|
125
|
-
// SAVE POINT
|
126
155
|
|
156
|
+
// Trigger a callback after first render (and applied CSS).
|
127
157
|
useEffect(function () {
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
158
|
+
// Normally, we can trigger a callback "immediately after first
|
159
|
+
// render", because we will be doing more "logical" work (update
|
160
|
+
// a state, show / hide a feature, etc.), and the final, applied
|
161
|
+
// CSS can "catch up" asynchronously without breaking anything.
|
162
|
+
setTimeout(function () {
|
163
|
+
// But, because we are making calculations based on the final,
|
164
|
+
// applied CSS, we must wait for one more "tick".
|
165
|
+
handleOnScroll();
|
166
|
+
}, 0);
|
167
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
168
|
+
}, []);
|
169
|
+
|
170
|
+
// On window.resize, reset carousel to zero.
|
132
171
|
useEffect(function () {
|
133
|
-
function
|
172
|
+
var handleWindowResize = function handleWindowResize() {
|
173
|
+
scrollRef.current.scrollLeft = 0;
|
174
|
+
handleOnScroll();
|
175
|
+
};
|
176
|
+
window.addEventListener('resize', handleWindowResize);
|
177
|
+
return function () {
|
178
|
+
return window.removeEventListener('resize', handleWindowResize);
|
179
|
+
};
|
180
|
+
}, [handleOnScroll]);
|
181
|
+
|
182
|
+
// On scrollRef.scrollend, trigger a callback.
|
183
|
+
useEffect(function () {
|
184
|
+
var handleScrollend = function handleScrollend() {
|
185
|
+
handleOnScroll();
|
186
|
+
};
|
187
|
+
var scrollDiv = scrollRef.current;
|
188
|
+
scrollDiv.addEventListener('scrollend', handleScrollend);
|
189
|
+
return function () {
|
190
|
+
return scrollDiv.removeEventListener('scrollend', handleScrollend);
|
191
|
+
};
|
192
|
+
}, [handleOnScroll]);
|
193
|
+
|
194
|
+
// Disable wheel scrolling
|
195
|
+
useEffect(function () {
|
196
|
+
function handleWheel(event) {
|
134
197
|
// update the scroll position
|
135
198
|
event.stopPropagation();
|
136
199
|
event.preventDefault();
|
@@ -138,18 +201,20 @@ export var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
138
201
|
}
|
139
202
|
var scrollDiv = scrollRef.current;
|
140
203
|
if (scrollDiv) {
|
141
|
-
scrollDiv.addEventListener('wheel',
|
204
|
+
scrollDiv.addEventListener('wheel', handleWheel, {
|
142
205
|
passive: false
|
143
206
|
});
|
144
207
|
return function () {
|
145
|
-
scrollDiv.removeEventListener('wheel',
|
208
|
+
scrollDiv.removeEventListener('wheel', handleWheel, {
|
146
209
|
passive: false
|
147
210
|
});
|
148
211
|
};
|
149
212
|
}
|
150
213
|
}, []);
|
214
|
+
|
215
|
+
// Enable arrow scrolling from within the carousel
|
151
216
|
useEffect(function () {
|
152
|
-
function
|
217
|
+
function handleKeydown(event) {
|
153
218
|
var key = event.key;
|
154
219
|
if ((key === 'ArrowLeft' || key === 'ArrowRight') && disableArrowScroll) {
|
155
220
|
event.stopPropagation();
|
@@ -157,27 +222,32 @@ export var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
157
222
|
event.cancelBubble = false;
|
158
223
|
}
|
159
224
|
}
|
160
|
-
var
|
161
|
-
if (
|
162
|
-
|
225
|
+
var carouselDiv = carouselRef.current;
|
226
|
+
if (carouselDiv) {
|
227
|
+
carouselDiv.addEventListener('keydown', handleKeydown);
|
163
228
|
return function () {
|
164
|
-
return
|
229
|
+
return carouselDiv.removeEventListener('keydown', handleKeydown);
|
165
230
|
};
|
166
231
|
}
|
167
232
|
}, [disableArrowScroll]);
|
168
|
-
|
169
|
-
|
170
|
-
mountedRef.current = false;
|
171
|
-
};
|
172
|
-
}, []);
|
233
|
+
|
234
|
+
// Enable external function calls
|
173
235
|
useImperativeHandle(ref, function () {
|
174
236
|
return {
|
175
|
-
scrollNext: scrollNext
|
176
|
-
|
177
|
-
|
178
|
-
|
237
|
+
scrollNext: function scrollNext() {
|
238
|
+
handleScrollNext();
|
239
|
+
},
|
240
|
+
scrollPrev: function scrollPrev() {
|
241
|
+
handleScrollPrev();
|
242
|
+
},
|
243
|
+
scrollReset: function scrollReset() {
|
244
|
+
handleScrollReset();
|
245
|
+
},
|
246
|
+
scrollToView: function scrollToView(itemNumber) {
|
247
|
+
handleScrollToView(itemNumber);
|
248
|
+
}
|
179
249
|
};
|
180
|
-
}, [
|
250
|
+
}, [handleScrollNext, handleScrollPrev, handleScrollReset, handleScrollToView]);
|
181
251
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
182
252
|
tabIndex: -1,
|
183
253
|
className: cx(blockClass, className),
|
@@ -188,8 +258,13 @@ export var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
188
258
|
}, /*#__PURE__*/React.createElement("div", {
|
189
259
|
className: "".concat(blockClass, "__elements"),
|
190
260
|
ref: scrollRef
|
191
|
-
}, React.Children.map(children, function (child) {
|
192
|
-
return /*#__PURE__*/React.createElement(CarouselItem,
|
261
|
+
}, React.Children.map(children, function (child, index) {
|
262
|
+
return /*#__PURE__*/React.createElement(CarouselItem, {
|
263
|
+
key: index,
|
264
|
+
ref: function ref(element) {
|
265
|
+
return childElementsRef.current[index] = element;
|
266
|
+
}
|
267
|
+
}, child);
|
193
268
|
})), leftFadedEdgeColor && /*#__PURE__*/React.createElement("div", {
|
194
269
|
className: "".concat(blockClass, "__elements-container--scrolled"),
|
195
270
|
style: {
|
@@ -202,9 +277,6 @@ export var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
202
277
|
}
|
203
278
|
})));
|
204
279
|
});
|
205
|
-
|
206
|
-
// The display name of the component, used by React. Note that displayName
|
207
|
-
// is used in preference to relying on function.name.
|
208
280
|
Carousel.displayName = componentName;
|
209
281
|
|
210
282
|
// The types and DocGen commentary for the component props,
|
@@ -227,21 +299,24 @@ Carousel.propTypes = {
|
|
227
299
|
/**
|
228
300
|
* Enables the edges of the component to have faded styling.
|
229
301
|
*
|
230
|
-
* Pass a single string to specify the same color for left and right.
|
302
|
+
* Pass a single string (`$color`) to specify the same color for left and right.
|
231
303
|
*
|
232
|
-
*
|
304
|
+
* Or pass an object (`{ left: $color1, right: $color2 }`) to specify different colors.
|
233
305
|
*/
|
234
306
|
fadedEdgeColor: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
235
307
|
left: PropTypes.string,
|
236
308
|
right: PropTypes.string
|
237
309
|
})]),
|
238
310
|
/**
|
239
|
-
*
|
311
|
+
* An optional callback function that returns `true`
|
312
|
+
* when the carousel has enough content to be scrollable,
|
313
|
+
* and `false` when there is not enough content.
|
240
314
|
*/
|
241
|
-
|
315
|
+
onChangeIsScrollable: PropTypes.func,
|
242
316
|
/**
|
243
|
-
* An optional callback function that returns
|
244
|
-
*
|
317
|
+
* An optional callback function that returns the scroll position as
|
318
|
+
* a value between 0 and 1.
|
245
319
|
*/
|
246
|
-
|
247
|
-
};
|
320
|
+
onScroll: PropTypes.func
|
321
|
+
};
|
322
|
+
export { Carousel };
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
3
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
4
3
|
var _excluded = ["children", "className"];
|
5
4
|
/**
|
@@ -9,12 +8,11 @@ var _excluded = ["children", "className"];
|
|
9
8
|
* LICENSE file in the root directory of this source tree.
|
10
9
|
*/
|
11
10
|
|
12
|
-
import React
|
11
|
+
import React from 'react';
|
13
12
|
|
14
13
|
// Other standard imports.
|
15
14
|
import PropTypes from 'prop-types';
|
16
15
|
import cx from 'classnames';
|
17
|
-
import { useIntersection } from './utils';
|
18
16
|
import { getDevtoolsProps } from '../../global/js/utils/devtools';
|
19
17
|
import { pkg } from '../../settings';
|
20
18
|
|
@@ -28,28 +26,17 @@ var componentName = 'CarouselItem';
|
|
28
26
|
/**
|
29
27
|
* TODO: A description of the component.
|
30
28
|
*/
|
31
|
-
var CarouselItem = function
|
29
|
+
var CarouselItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
32
30
|
var children = _ref.children,
|
33
31
|
className = _ref.className,
|
34
32
|
rest = _objectWithoutProperties(_ref, _excluded);
|
35
|
-
var itemRef = useRef();
|
36
|
-
var isInView = useIntersection(itemRef, 0.85);
|
37
|
-
useEffect(function () {
|
38
|
-
var _itemRef$current;
|
39
|
-
var matches = (_itemRef$current = itemRef.current) === null || _itemRef$current === void 0 ? void 0 : _itemRef$current.querySelectorAll('a, button, [role="button"], [tabindex]');
|
40
|
-
if (matches) {
|
41
|
-
var ti = isInView ? 0 : -1;
|
42
|
-
_toConsumableArray(matches).forEach(function (match) {
|
43
|
-
match.tabIndex = ti;
|
44
|
-
});
|
45
|
-
}
|
46
|
-
}, [isInView]);
|
47
33
|
return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
|
48
|
-
className: cx(blockClass, className)
|
49
|
-
|
50
|
-
|
51
|
-
};
|
52
|
-
|
34
|
+
className: cx(blockClass, className)
|
35
|
+
}, getDevtoolsProps(componentName), {
|
36
|
+
ref: ref
|
37
|
+
}), children);
|
38
|
+
});
|
39
|
+
CarouselItem.displayName = componentName;
|
53
40
|
// The types and DocGen commentary for the component props,
|
54
41
|
// in alphabetical order (for consistency).
|
55
42
|
// See https://www.npmjs.com/package/prop-types#usage.
|
@@ -113,7 +113,10 @@ export var CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_r
|
|
113
113
|
ref: buttonFocusRef
|
114
114
|
}), closeButtonLabel))) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Carousel, {
|
115
115
|
disableArrowScroll: true,
|
116
|
-
ref: scrollRef
|
116
|
+
ref: scrollRef,
|
117
|
+
onScroll: function onScroll(scrollPercent) {
|
118
|
+
setScrollPosition(scrollPercent);
|
119
|
+
}
|
117
120
|
}, children), /*#__PURE__*/React.createElement("div", {
|
118
121
|
className: cx("".concat(blockClass, "__footer"))
|
119
122
|
}, /*#__PURE__*/React.createElement("div", {
|
@@ -125,9 +128,7 @@ export var CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_r
|
|
125
128
|
disabled: scrollPosition === 0,
|
126
129
|
onClick: function onClick() {
|
127
130
|
var targetStep = clamp(currentProgStep - 1, progStepFloor, progStepCeil);
|
128
|
-
scrollRef.current.scrollToView(targetStep)
|
129
|
-
setScrollPosition(scrollPercentage);
|
130
|
-
});
|
131
|
+
scrollRef.current.scrollToView(targetStep);
|
131
132
|
setCurrentProgStep(targetStep);
|
132
133
|
}
|
133
134
|
}, previousButtonLabel), currentProgStep < progStepCeil ? /*#__PURE__*/React.createElement(Button, {
|
@@ -137,9 +138,7 @@ export var CoachmarkOverlayElements = /*#__PURE__*/React.forwardRef(function (_r
|
|
137
138
|
disabled: scrollPosition === 1,
|
138
139
|
onClick: function onClick() {
|
139
140
|
var targetStep = clamp(currentProgStep + 1, progStepFloor, progStepCeil);
|
140
|
-
scrollRef.current.scrollToView(targetStep)
|
141
|
-
setScrollPosition(scrollPercentage);
|
142
|
-
});
|
141
|
+
scrollRef.current.scrollToView(targetStep);
|
143
142
|
setCurrentProgStep(targetStep);
|
144
143
|
}
|
145
144
|
}, nextButtonText) : closeButtonLabel && /*#__PURE__*/React.createElement(Button, _extends({
|
@@ -34,12 +34,14 @@ var DatagridExpandedRow = function DatagridExpandedRow(ExpandedRowContentCompone
|
|
34
34
|
onMouseLeave: function onMouseLeave(event) {
|
35
35
|
return toggleParentHoverClass(event);
|
36
36
|
}
|
37
|
+
}, /*#__PURE__*/React.createElement("td", {
|
38
|
+
className: "".concat(blockClass, "__expanded-row-cell-wrapper")
|
37
39
|
}, /*#__PURE__*/React.createElement("div", {
|
38
40
|
className: "".concat(blockClass, "__expanded-row-content"),
|
39
41
|
style: {
|
40
42
|
height: expandedContentHeight && expandedContentHeight
|
41
43
|
}
|
42
|
-
}, /*#__PURE__*/React.createElement(ExpandedRowContentComponent, datagridState)));
|
44
|
+
}, /*#__PURE__*/React.createElement(ExpandedRowContentComponent, datagridState))));
|
43
45
|
};
|
44
46
|
};
|
45
47
|
export default DatagridExpandedRow;
|
@@ -61,6 +61,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
|
|
61
61
|
var handleOnMouseDownResize = function handleOnMouseDownResize(event, resizeProps) {
|
62
62
|
var _resizeProps = _objectSpread({}, resizeProps()),
|
63
63
|
onMouseDown = _resizeProps.onMouseDown;
|
64
|
+
event.target.focus();
|
64
65
|
// When event.button is 2, that is a right click
|
65
66
|
// and we do not want to resize
|
66
67
|
if (event.button === 2 || event.ctrlKey) {
|
@@ -4,14 +4,13 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
var _excluded = ["children"];
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
7
|
-
|
8
|
-
*
|
9
|
-
*
|
10
|
-
*
|
11
|
-
*
|
12
|
-
* restricted by GSA ADP Schedule Contract with IBM Corp.
|
7
|
+
/**
|
8
|
+
* Copyright IBM Corp. 2020, 2023
|
9
|
+
*
|
10
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
11
|
+
* LICENSE file in the root directory of this source tree.
|
13
12
|
*/
|
14
|
-
|
13
|
+
|
15
14
|
import React from 'react';
|
16
15
|
import { DataTable, SkeletonText } from 'carbon-components-react';
|
17
16
|
import { px } from '@carbon/layout';
|
@@ -36,7 +35,9 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
36
35
|
rowSize = datagridState.rowSize,
|
37
36
|
withNestedRows = datagridState.withNestedRows,
|
38
37
|
prepareRow = datagridState.prepareRow,
|
39
|
-
key = datagridState.key
|
38
|
+
key = datagridState.key,
|
39
|
+
tableId = datagridState.tableId,
|
40
|
+
withExpandedRows = datagridState.withExpandedRows;
|
40
41
|
var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
|
41
42
|
var isExpanded = _ref.isExpanded,
|
42
43
|
subRows = _ref.subRows;
|
@@ -65,7 +66,7 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
65
66
|
hoverRow === null || hoverRow === void 0 ? void 0 : (_hoverRow$style3 = hoverRow.style) === null || _hoverRow$style3 === void 0 ? void 0 : _hoverRow$style3.setProperty("--".concat(blockClass, "--indicator-offset-amount"), px((rowExpanderButton === null || rowExpanderButton === void 0 ? void 0 : rowExpanderButton.offsetLeft) || 0));
|
66
67
|
};
|
67
68
|
var focusRemover = function focusRemover() {
|
68
|
-
var elements = document.querySelectorAll(".".concat(blockClass, "__carbon-row-expanded"));
|
69
|
+
var elements = document.querySelectorAll("#".concat(tableId, " .").concat(blockClass, "__carbon-row-expanded"));
|
69
70
|
elements.forEach(function (el) {
|
70
71
|
el.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
|
71
72
|
});
|
@@ -94,6 +95,14 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
94
95
|
}
|
95
96
|
};
|
96
97
|
var rowClassNames = cx("".concat(blockClass, "__carbon-row"), (_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expanded"), row.isExpanded), _defineProperty(_cx, "".concat(blockClass, "__carbon-row-expandable"), row.canExpand), _defineProperty(_cx, "".concat(carbon.prefix, "--data-table--selected"), row.isSelected), _cx));
|
98
|
+
var setAdditionalRowProps = function setAdditionalRowProps() {
|
99
|
+
if (withNestedRows || withExpandedRows) {
|
100
|
+
return {
|
101
|
+
'data-nested-row-id': row.id
|
102
|
+
};
|
103
|
+
}
|
104
|
+
return {};
|
105
|
+
};
|
97
106
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
98
107
|
key: key
|
99
108
|
}, /*#__PURE__*/React.createElement(TableRow, _extends({
|
@@ -107,7 +116,7 @@ var DatagridRow = function DatagridRow(datagridState) {
|
|
107
116
|
onFocus: hoverHandler,
|
108
117
|
onBlur: focusRemover,
|
109
118
|
onKeyUp: handleOnKeyUp
|
110
|
-
}), row.cells.map(function (cell, index) {
|
119
|
+
}, setAdditionalRowProps()), row.cells.map(function (cell, index) {
|
111
120
|
var _cell$column;
|
112
121
|
var cellProps = cell.getCellProps({
|
113
122
|
role: false
|
@@ -14,6 +14,7 @@ import React, { useLayoutEffect, useState } from 'react';
|
|
14
14
|
import { DataTable } from 'carbon-components-react';
|
15
15
|
import cx from 'classnames';
|
16
16
|
import { pkg } from '../../../settings';
|
17
|
+
import { handleSelectAllRowData } from './addons/stateReducer';
|
17
18
|
var blockClass = "".concat(pkg.prefix, "--datagrid");
|
18
19
|
var SelectAll = function SelectAll(datagridState) {
|
19
20
|
var _columns$;
|
@@ -39,7 +40,11 @@ var SelectAll = function SelectAll(datagridState) {
|
|
39
40
|
DatagridPagination = datagridState.DatagridPagination,
|
40
41
|
radio = datagridState.radio,
|
41
42
|
columns = datagridState.columns,
|
42
|
-
withStickyColumn = datagridState.withStickyColumn
|
43
|
+
withStickyColumn = datagridState.withStickyColumn,
|
44
|
+
dispatch = datagridState.dispatch,
|
45
|
+
rows = datagridState.rows,
|
46
|
+
getRowId = datagridState.getRowId,
|
47
|
+
toggleAllRowsSelected = datagridState.toggleAllRowsSelected;
|
43
48
|
var isFirstColumnStickyLeft = ((_columns$ = columns[0]) === null || _columns$ === void 0 ? void 0 : _columns$.sticky) === 'left' && withStickyColumn;
|
44
49
|
if (hideSelectAll || radio) {
|
45
50
|
return /*#__PURE__*/React.createElement("div", {
|
@@ -54,12 +59,25 @@ var SelectAll = function SelectAll(datagridState) {
|
|
54
59
|
var indeterminate = selectProps.indeterminate;
|
55
60
|
var handleSelectAllChange = function handleSelectAllChange(event) {
|
56
61
|
if (indeterminate) {
|
62
|
+
handleSelectAllRowData({
|
63
|
+
dispatch: dispatch,
|
64
|
+
rows: rows,
|
65
|
+
getRowId: getRowId,
|
66
|
+
indeterminate: true
|
67
|
+
});
|
68
|
+
toggleAllRowsSelected(false);
|
57
69
|
return onChange === null || onChange === void 0 ? void 0 : onChange({
|
58
70
|
target: {
|
59
71
|
checked: false
|
60
72
|
}
|
61
73
|
});
|
62
74
|
}
|
75
|
+
handleSelectAllRowData({
|
76
|
+
dispatch: dispatch,
|
77
|
+
rows: rows,
|
78
|
+
getRowId: getRowId,
|
79
|
+
isChecked: event.target.checked
|
80
|
+
});
|
63
81
|
return onChange === null || onChange === void 0 ? void 0 : onChange(event);
|
64
82
|
};
|
65
83
|
return /*#__PURE__*/React.createElement("div", {
|