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