@carbon/ibm-products 2.17.1 → 2.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. package/css/index-full-carbon.css +17078 -15669
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +1 -1
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon-released-only.css +71 -9
  6. package/css/index-without-carbon-released-only.css.map +1 -1
  7. package/css/index-without-carbon-released-only.min.css +1 -1
  8. package/css/index-without-carbon-released-only.min.css.map +1 -1
  9. package/css/index-without-carbon.css +5763 -6355
  10. package/css/index-without-carbon.css.map +1 -1
  11. package/css/index-without-carbon.min.css +1 -1
  12. package/css/index-without-carbon.min.css.map +1 -1
  13. package/css/index.css +124 -9
  14. package/css/index.css.map +1 -1
  15. package/css/index.min.css +1 -1
  16. package/css/index.min.css.map +1 -1
  17. package/es/components/Carousel/Carousel.docs-page.js +11 -0
  18. package/es/components/Carousel/Carousel.js +322 -0
  19. package/es/components/Carousel/CarouselItem.js +53 -0
  20. package/es/components/Carousel/index.js +9 -0
  21. package/es/components/Carousel/utils.js +98 -0
  22. package/es/components/CreateSidePanel/CreateSidePanel.js +7 -1
  23. package/es/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
  24. package/es/components/Datagrid/Datagrid/DatagridRow.js +13 -3
  25. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +4 -3
  26. package/es/components/Datagrid/Extensions/Filtering/Filtering.docs-page.js +7 -1
  27. package/es/components/Datagrid/useExpandedRow.js +3 -6
  28. package/es/components/Datagrid/useFocusRowExpander.js +40 -0
  29. package/es/components/Datagrid/useNestedRowExpander.js +9 -0
  30. package/es/components/Datagrid/useNestedRows.js +1 -5
  31. package/es/components/Datagrid/useRowExpander.js +9 -0
  32. package/es/components/Datagrid/useSelectRows.js +9 -2
  33. package/es/components/Datagrid/utils/handleFilterTagLabelText.js +26 -0
  34. package/es/components/EditSidePanel/EditSidePanel.js +8 -2
  35. package/es/components/FilterSummary/FilterSummary.js +21 -7
  36. package/es/components/Guidebanner/Guidebanner.docs-page.js +15 -0
  37. package/es/components/Guidebanner/Guidebanner.js +221 -0
  38. package/es/components/Guidebanner/GuidebannerElement.js +72 -0
  39. package/es/components/Guidebanner/GuidebannerElementButton.js +80 -0
  40. package/es/components/Guidebanner/GuidebannerElementLink.js +57 -0
  41. package/es/components/Guidebanner/index.js +11 -0
  42. package/es/components/NonLinearReading/NonLinearReading.docs-page.js +15 -0
  43. package/es/components/NonLinearReading/NonLinearReading.js +89 -0
  44. package/es/components/NonLinearReading/index.js +8 -0
  45. package/es/components/SidePanel/SidePanel.js +48 -27
  46. package/es/components/TagSet/TagSet.js +22 -5
  47. package/es/components/WebTerminal/WebTerminal.js +5 -3
  48. package/es/global/js/hooks/useCreateComponentStepChange.js +1 -1
  49. package/es/global/js/package-settings.js +6 -3
  50. package/lib/components/Carousel/Carousel.docs-page.js +21 -0
  51. package/lib/components/Carousel/Carousel.js +329 -0
  52. package/lib/components/Carousel/CarouselItem.js +54 -0
  53. package/lib/components/Carousel/index.js +19 -0
  54. package/lib/components/Carousel/utils.js +105 -0
  55. package/lib/components/CreateSidePanel/CreateSidePanel.js +7 -1
  56. package/lib/components/Datagrid/Datagrid/DatagridExpandedRow.js +3 -1
  57. package/lib/components/Datagrid/Datagrid/DatagridRow.js +13 -3
  58. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +4 -3
  59. package/lib/components/Datagrid/Extensions/Filtering/Filtering.docs-page.js +7 -1
  60. package/lib/components/Datagrid/useExpandedRow.js +2 -5
  61. package/lib/components/Datagrid/useFocusRowExpander.js +45 -0
  62. package/lib/components/Datagrid/useNestedRowExpander.js +9 -0
  63. package/lib/components/Datagrid/useNestedRows.js +1 -5
  64. package/lib/components/Datagrid/useRowExpander.js +9 -0
  65. package/lib/components/Datagrid/useSelectRows.js +9 -2
  66. package/lib/components/Datagrid/utils/handleFilterTagLabelText.js +32 -0
  67. package/lib/components/EditSidePanel/EditSidePanel.js +8 -2
  68. package/lib/components/FilterSummary/FilterSummary.js +24 -7
  69. package/lib/components/Guidebanner/Guidebanner.docs-page.js +25 -0
  70. package/lib/components/Guidebanner/Guidebanner.js +229 -0
  71. package/lib/components/Guidebanner/GuidebannerElement.js +77 -0
  72. package/lib/components/Guidebanner/GuidebannerElementButton.js +85 -0
  73. package/lib/components/Guidebanner/GuidebannerElementLink.js +62 -0
  74. package/lib/components/Guidebanner/index.js +33 -0
  75. package/lib/components/NonLinearReading/NonLinearReading.docs-page.js +25 -0
  76. package/lib/components/NonLinearReading/NonLinearReading.js +97 -0
  77. package/lib/components/NonLinearReading/index.js +12 -0
  78. package/lib/components/SidePanel/SidePanel.js +47 -26
  79. package/lib/components/TagSet/TagSet.js +22 -5
  80. package/lib/components/WebTerminal/WebTerminal.js +4 -2
  81. package/lib/global/js/hooks/useCreateComponentStepChange.js +1 -1
  82. package/lib/global/js/package-settings.js +6 -3
  83. package/package.json +5 -5
  84. package/scss/components/Carousel/_carbon-imports.scss +6 -0
  85. package/scss/components/Carousel/_carousel.scss +72 -0
  86. package/scss/components/Carousel/_index-with-carbon.scss +9 -0
  87. package/scss/components/Carousel/_index.scss +8 -0
  88. package/scss/components/Datagrid/styles/_useExpandedRow.scss +21 -0
  89. package/scss/components/Datagrid/styles/addons/_RowSizeDropdown.scss +9 -0
  90. package/scss/components/FilterSummary/_filter-summary.scss +6 -1
  91. package/scss/components/Guidebanner/_carbon-imports.scss +6 -0
  92. package/scss/components/Guidebanner/_guidebanner.scss +248 -0
  93. package/scss/components/Guidebanner/_index-with-carbon.scss +9 -0
  94. package/scss/components/Guidebanner/_index.scss +8 -0
  95. package/scss/components/NonLinearReading/_carbon-imports.scss +6 -0
  96. package/scss/components/NonLinearReading/_index-with-carbon.scss +9 -0
  97. package/scss/components/NonLinearReading/_index.scss +8 -0
  98. package/scss/components/NonLinearReading/_non-linear-reading.scss +122 -0
  99. package/scss/components/SidePanel/_side-panel.scss +22 -6
  100. package/scss/components/WebTerminal/_web-terminal.scss +1 -2
  101. package/scss/components/_Canary/_canary.scss +1 -2
  102. package/scss/components/_Canary/_carbon-imports.scss +7 -0
  103. package/scss/components/_Canary/_index-with-carbon.scss +8 -0
  104. package/scss/components/_Canary/_index.scss +7 -0
  105. package/scss/components/_index-with-carbon.scss +1 -1
  106. package/scss/components/_index.scss +5 -2
  107. /package/es/components/Datagrid/{Extensions → Datagrid.stories}/ColumnAlignment/ColumnAlignment.docs-page.js +0 -0
  108. /package/lib/components/Datagrid/{Extensions → Datagrid.stories}/ColumnAlignment/ColumnAlignment.docs-page.js +0 -0
@@ -0,0 +1,322 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["children", "className", "disableArrowScroll", "fadedEdgeColor", "onChangeIsScrollable", "onScroll"];
4
+ /**
5
+ * Copyright IBM Corp. 2023, 2023
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ import React, { useCallback, useEffect, useImperativeHandle, useRef } from 'react';
12
+ import PropTypes from 'prop-types';
13
+ import { CarouselItem } from './CarouselItem';
14
+ import cx from 'classnames';
15
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
16
+ import { pkg } from '../../settings';
17
+
18
+ // The block part of our conventional BEM class names (blockClass__E--M).
19
+ var blockClass = "".concat(pkg.prefix, "--carousel");
20
+ var componentName = 'Carousel';
21
+
22
+ // Default values for props
23
+ var defaults = {
24
+ disableArrowScroll: false,
25
+ onScroll: function onScroll() {},
26
+ onChangeIsScrollable: function onChangeIsScrollable() {}
27
+ };
28
+
29
+ /**
30
+ * The Carousel acts as a scaffold for other Novice to Pro content.
31
+ *
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.
44
+ */
45
+ var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
46
+ var children = _ref.children,
47
+ className = _ref.className,
48
+ _ref$disableArrowScro = _ref.disableArrowScroll,
49
+ disableArrowScroll = _ref$disableArrowScro === void 0 ? defaults.disableArrowScroll : _ref$disableArrowScro,
50
+ fadedEdgeColor = _ref.fadedEdgeColor,
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,
55
+ rest = _objectWithoutProperties(_ref, _excluded);
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)));
60
+ var leftFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.left) || fadedEdgeColor;
61
+ var rightFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.right) || fadedEdgeColor;
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;
78
+ }
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());
101
+ });
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();
112
+ });
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();
154
+ }, []);
155
+
156
+ // Trigger a callback after first render (and applied CSS).
157
+ useEffect(function () {
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.
171
+ useEffect(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) {
197
+ // update the scroll position
198
+ event.stopPropagation();
199
+ event.preventDefault();
200
+ event.cancelBubble = false;
201
+ }
202
+ var scrollDiv = scrollRef.current;
203
+ if (scrollDiv) {
204
+ scrollDiv.addEventListener('wheel', handleWheel, {
205
+ passive: false
206
+ });
207
+ return function () {
208
+ scrollDiv.removeEventListener('wheel', handleWheel, {
209
+ passive: false
210
+ });
211
+ };
212
+ }
213
+ }, []);
214
+
215
+ // Enable arrow scrolling from within the carousel
216
+ useEffect(function () {
217
+ function handleKeydown(event) {
218
+ var key = event.key;
219
+ if ((key === 'ArrowLeft' || key === 'ArrowRight') && disableArrowScroll) {
220
+ event.stopPropagation();
221
+ event.preventDefault();
222
+ event.cancelBubble = false;
223
+ }
224
+ }
225
+ var carouselDiv = carouselRef.current;
226
+ if (carouselDiv) {
227
+ carouselDiv.addEventListener('keydown', handleKeydown);
228
+ return function () {
229
+ return carouselDiv.removeEventListener('keydown', handleKeydown);
230
+ };
231
+ }
232
+ }, [disableArrowScroll]);
233
+
234
+ // Enable external function calls
235
+ useImperativeHandle(ref, function () {
236
+ return {
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
+ }
249
+ };
250
+ }, [handleScrollNext, handleScrollPrev, handleScrollReset, handleScrollToView]);
251
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
252
+ tabIndex: -1,
253
+ className: cx(blockClass, className),
254
+ ref: carouselRef,
255
+ role: "main"
256
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
257
+ className: cx("".concat(blockClass, "__elements-container"))
258
+ }, /*#__PURE__*/React.createElement("div", {
259
+ className: "".concat(blockClass, "__elements"),
260
+ ref: scrollRef
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);
268
+ })), leftFadedEdgeColor && /*#__PURE__*/React.createElement("div", {
269
+ className: "".concat(blockClass, "__elements-container--scrolled"),
270
+ style: {
271
+ background: "linear-gradient(90deg, ".concat(leftFadedEdgeColor, ", transparent)")
272
+ }
273
+ }), rightFadedEdgeColor && /*#__PURE__*/React.createElement("div", {
274
+ className: "".concat(blockClass, "__elements-container--scroll-max"),
275
+ style: {
276
+ background: "linear-gradient(270deg, ".concat(rightFadedEdgeColor, ", transparent)")
277
+ }
278
+ })));
279
+ });
280
+ Carousel.displayName = componentName;
281
+
282
+ // The types and DocGen commentary for the component props,
283
+ // in alphabetical order (for consistency).
284
+ // See https://www.npmjs.com/package/prop-types#usage.
285
+ Carousel.propTypes = {
286
+ /**
287
+ * Provide the contents of the Carousel.
288
+ */
289
+ children: PropTypes.node.isRequired,
290
+ /**
291
+ * Provide an optional class to be applied to the containing node.
292
+ */
293
+ className: PropTypes.string,
294
+ /**
295
+ * Disables the ability of the Carousel to scroll
296
+ * use a keyboard's left and right arrow keys.
297
+ */
298
+ disableArrowScroll: PropTypes.bool,
299
+ /**
300
+ * Enables the edges of the component to have faded styling.
301
+ *
302
+ * Pass a single string (`$color`) to specify the same color for left and right.
303
+ *
304
+ * Or pass an object (`{ left: $color1, right: $color2 }`) to specify different colors.
305
+ */
306
+ fadedEdgeColor: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
307
+ left: PropTypes.string,
308
+ right: PropTypes.string
309
+ })]),
310
+ /**
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.
314
+ */
315
+ onChangeIsScrollable: PropTypes.func,
316
+ /**
317
+ * An optional callback function that returns the scroll position as
318
+ * a value between 0 and 1.
319
+ */
320
+ onScroll: PropTypes.func
321
+ };
322
+ export { Carousel };
@@ -0,0 +1,53 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ var _excluded = ["children", "className"];
4
+ /**
5
+ * Copyright IBM Corp. 2023, 2023
6
+ *
7
+ * This source code is licensed under the Apache-2.0 license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */
10
+
11
+ import React from 'react';
12
+
13
+ // Other standard imports.
14
+ import PropTypes from 'prop-types';
15
+ import cx from 'classnames';
16
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
17
+ import { pkg } from '../../settings';
18
+
19
+ // Carbon and package components we use.
20
+ /* TODO: @import(s) of carbon components and other package components. */
21
+
22
+ // The block part of our conventional BEM class names (blockClass__E--M).
23
+ var blockClass = "".concat(pkg.prefix, "--carousel__item");
24
+ var componentName = 'CarouselItem';
25
+
26
+ /**
27
+ * TODO: A description of the component.
28
+ */
29
+ var CarouselItem = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
30
+ var children = _ref.children,
31
+ className = _ref.className,
32
+ rest = _objectWithoutProperties(_ref, _excluded);
33
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
34
+ className: cx(blockClass, className)
35
+ }, getDevtoolsProps(componentName), {
36
+ ref: ref
37
+ }), children);
38
+ });
39
+ CarouselItem.displayName = componentName;
40
+ // The types and DocGen commentary for the component props,
41
+ // in alphabetical order (for consistency).
42
+ // See https://www.npmjs.com/package/prop-types#usage.
43
+ CarouselItem.propTypes = {
44
+ /**
45
+ * Provide the contents of the CarouselItem.
46
+ */
47
+ children: PropTypes.node.isRequired,
48
+ /**
49
+ * Provide an optional class to be applied to the containing node.
50
+ */
51
+ className: PropTypes.string
52
+ };
53
+ export { CarouselItem };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2023, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ export { Carousel } from './Carousel';
9
+ export { CarouselItem } from './CarouselItem';
@@ -0,0 +1,98 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ /**
3
+ * Copyright IBM Corp. 2023, 2023
4
+ *
5
+ * This source code is licensed under the Apache-2.0 license found in the
6
+ * LICENSE file in the root directory of this source tree.
7
+ */
8
+
9
+ import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
10
+ export var useIntersection = function useIntersection(element, threshold) {
11
+ var _useState = useState(false),
12
+ _useState2 = _slicedToArray(_useState, 2),
13
+ isVisible = _useState2[0],
14
+ setState = _useState2[1];
15
+ useEffect(function () {
16
+ var el = element.current;
17
+ var observer = new IntersectionObserver(function (_ref) {
18
+ var _ref2 = _slicedToArray(_ref, 1),
19
+ entry = _ref2[0];
20
+ setState(entry.isIntersecting);
21
+ }, {
22
+ threshold: threshold
23
+ });
24
+ el && observer.observe(el);
25
+ return function () {
26
+ return observer.unobserve(el);
27
+ };
28
+ }, [element, threshold]);
29
+ return isVisible;
30
+ };
31
+ export var useIsOverflow = function useIsOverflow(ref) {
32
+ var _useState3 = useState(),
33
+ _useState4 = _slicedToArray(_useState3, 2),
34
+ isScrollable = _useState4[0],
35
+ setIsScrollable = _useState4[1];
36
+ var _useState5 = useState(),
37
+ _useState6 = _slicedToArray(_useState5, 2),
38
+ mutationObserver = _useState6[0],
39
+ setMutationObserver = _useState6[1];
40
+ var _useState7 = useState(),
41
+ _useState8 = _slicedToArray(_useState7, 2),
42
+ resizeObserver = _useState8[0],
43
+ setResizeObserver = _useState8[1];
44
+ var checkOverflow = useCallback(function () {
45
+ if (!ref.current) {
46
+ return;
47
+ }
48
+ var hasOverflow = ref.current.scrollWidth > ref.current.clientWidth;
49
+ setIsScrollable(hasOverflow);
50
+ }, [ref]);
51
+ useEffect(function () {
52
+ if (!mutationObserver) {
53
+ return;
54
+ }
55
+ return function () {
56
+ if (mutationObserver) {
57
+ mutationObserver.disconnect();
58
+ }
59
+ if (resizeObserver) {
60
+ resizeObserver.disconnect();
61
+ }
62
+ };
63
+ });
64
+ useLayoutEffect(function () {
65
+ var current = ref.current;
66
+ if (current) {
67
+ if ('ResizeObserver' in window && !resizeObserver) {
68
+ setResizeObserver(new ResizeObserver(checkOverflow).observe(current));
69
+ }
70
+ if ('MutationObserver' in window && !mutationObserver) {
71
+ setMutationObserver(new MutationObserver(checkOverflow).observe(current, {
72
+ attributes: false,
73
+ childList: true,
74
+ subtree: false
75
+ }));
76
+ }
77
+ checkOverflow();
78
+ }
79
+ }, [ref, checkOverflow, mutationObserver, resizeObserver]);
80
+ return isScrollable;
81
+ };
82
+ export var useWindowEvent = function useWindowEvent(eventName, callback) {
83
+ var savedCallback = useRef(null);
84
+ useEffect(function () {
85
+ savedCallback.current = callback;
86
+ });
87
+ useEffect(function () {
88
+ function handler(event) {
89
+ if (savedCallback.current) {
90
+ savedCallback.current(event);
91
+ }
92
+ }
93
+ window.addEventListener(eventName, handler);
94
+ return function () {
95
+ window.removeEventListener(eventName, handler);
96
+ };
97
+ }, [eventName]);
98
+ };
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["className", "children", "disableSubmit", "formTitle", "formDescription", "onRequestClose", "onRequestSubmit", "open", "primaryButtonText", "secondaryButtonText", "selectorPageContent", "selectorPrimaryFocus", "subtitle", "title"];
4
+ var _excluded = ["className", "children", "disableSubmit", "formTitle", "formDescription", "id", "onRequestClose", "onRequestSubmit", "open", "primaryButtonText", "secondaryButtonText", "selectorPageContent", "selectorPrimaryFocus", "subtitle", "title"];
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  /**
@@ -40,6 +40,7 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
40
40
  disableSubmit = _ref.disableSubmit,
41
41
  formTitle = _ref.formTitle,
42
42
  formDescription = _ref.formDescription,
43
+ id = _ref.id,
43
44
  onRequestClose = _ref.onRequestClose,
44
45
  onRequestSubmit = _ref.onRequestSubmit,
45
46
  open = _ref.open,
@@ -66,6 +67,7 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
66
67
  }];
67
68
  var formTitleId = uuidv4();
68
69
  return selectorPageContent && /*#__PURE__*/React.createElement(SidePanel, _extends({}, rest, _objectSpread({
70
+ id: id,
69
71
  open: open,
70
72
  ref: ref,
71
73
  selectorPageContent: selectorPageContent,
@@ -118,6 +120,10 @@ CreateSidePanel.propTypes = {
118
120
  * Specifies a required field that provides a title for a form
119
121
  */
120
122
  formTitle: PropTypes.node.isRequired,
123
+ /**
124
+ * Unique identifier
125
+ */
126
+ id: PropTypes.string,
121
127
  /**
122
128
  * Specifies an optional handler which is called when the CreateSidePanel
123
129
  * is closed.
@@ -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;
@@ -33,7 +33,9 @@ var DatagridRow = function DatagridRow(datagridState) {
33
33
  rowSize = datagridState.rowSize,
34
34
  withNestedRows = datagridState.withNestedRows,
35
35
  prepareRow = datagridState.prepareRow,
36
- key = datagridState.key;
36
+ key = datagridState.key,
37
+ tableId = datagridState.tableId,
38
+ withExpandedRows = datagridState.withExpandedRows;
37
39
  var getVisibleNestedRowCount = function getVisibleNestedRowCount(_ref) {
38
40
  var isExpanded = _ref.isExpanded,
39
41
  subRows = _ref.subRows;
@@ -62,7 +64,7 @@ var DatagridRow = function DatagridRow(datagridState) {
62
64
  hoverRow === null || hoverRow === void 0 || (_hoverRow$style3 = hoverRow.style) === null || _hoverRow$style3 === void 0 || _hoverRow$style3.setProperty("--".concat(blockClass, "--indicator-offset-amount"), px((rowExpanderButton === null || rowExpanderButton === void 0 ? void 0 : rowExpanderButton.offsetLeft) || 0));
63
65
  };
64
66
  var focusRemover = function focusRemover() {
65
- var elements = document.querySelectorAll(".".concat(blockClass, "__carbon-row-expanded"));
67
+ var elements = document.querySelectorAll("#".concat(tableId, " .").concat(blockClass, "__carbon-row-expanded"));
66
68
  elements.forEach(function (el) {
67
69
  el.classList.remove("".concat(blockClass, "__carbon-row-expanded-hover-active"));
68
70
  });
@@ -91,6 +93,14 @@ var DatagridRow = function DatagridRow(datagridState) {
91
93
  }
92
94
  };
93
95
  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));
96
+ var setAdditionalRowProps = function setAdditionalRowProps() {
97
+ if (withNestedRows || withExpandedRows) {
98
+ return {
99
+ 'data-nested-row-id': row.id
100
+ };
101
+ }
102
+ return {};
103
+ };
94
104
  return /*#__PURE__*/React.createElement(React.Fragment, {
95
105
  key: key
96
106
  }, /*#__PURE__*/React.createElement(TableRow, _extends({
@@ -102,7 +112,7 @@ var DatagridRow = function DatagridRow(datagridState) {
102
112
  onFocus: hoverHandler,
103
113
  onBlur: focusRemover,
104
114
  onKeyUp: handleOnKeyUp
105
- }), row.cells.map(function (cell, index) {
115
+ }, setAdditionalRowProps()), row.cells.map(function (cell, index) {
106
116
  var _cell$column;
107
117
  var cellProps = cell.getCellProps();
108
118
  var children = cellProps.children,
@@ -78,7 +78,7 @@ var useFilters = function useFilters(_ref2) {
78
78
  /** Methods */
79
79
  // If the user decides to cancel or click outside the flyout, it reverts back to the filters that were
80
80
  // there when they opened the flyout
81
- var revertToPreviousFilters = function revertToPreviousFilters() {
81
+ var revertToPreviousFilters = useCallback(function () {
82
82
  setFiltersState(JSON.parse(prevFiltersRef.current));
83
83
  setFiltersObjectArray(JSON.parse(prevFiltersObjectArrayRef.current));
84
84
  setAllFilters(JSON.parse(lastAppliedFilters.current));
@@ -88,7 +88,7 @@ var useFilters = function useFilters(_ref2) {
88
88
  holdingPrevFiltersRef.current = JSON.parse(prevFiltersRef.current);
89
89
  holdingLastAppliedFiltersRef.current = JSON.parse(prevFiltersObjectArrayRef.current);
90
90
  holdingPrevFiltersObjectArrayRef.current = JSON.parse(lastAppliedFilters.current);
91
- };
91
+ }, [setAllFilters]);
92
92
  var reset = useCallback(function () {
93
93
  // When we reset we want the "initialFilters" to be an empty array
94
94
  var resetFiltersArray = [];
@@ -352,6 +352,7 @@ var useFilters = function useFilters(_ref2) {
352
352
  */
353
353
  useEffect(function () {
354
354
  if (!panelOpen && previousState !== null && previousState !== void 0 && previousState.panelOpen) {
355
+ revertToPreviousFilters();
355
356
  setAllFilters(holdingLastAppliedFiltersRef.current);
356
357
  }
357
358
  if (panelOpen && !(previousState !== null && previousState !== void 0 && previousState.panelOpen)) {
@@ -361,7 +362,7 @@ var useFilters = function useFilters(_ref2) {
361
362
  setAllFilters(JSON.parse(prevFiltersObjectArrayRef.current));
362
363
  }
363
364
  }
364
- }, [panelOpen, previousState, previousState === null || previousState === void 0 ? void 0 : previousState.panelOpen, reset, setAllFilters]);
365
+ }, [panelOpen, previousState, previousState === null || previousState === void 0 ? void 0 : previousState.panelOpen, reset, setAllFilters, revertToPreviousFilters]);
365
366
  var cancel = function cancel() {
366
367
  // Reverting to previous filters only applies when using batch actions
367
368
  if (updateMethod === BATCH) {
@@ -41,6 +41,12 @@ export var DocsPage = function DocsPage() {
41
41
  }, {
42
42
  subTitle: 'Create your filters for panel variant',
43
43
  description: 'Filter panel coming soon.'
44
+ }, {
45
+ subTitle: 'Customizing the filter tag labels',
46
+ description: 'You can customize the rendering of the filter tag labels by supplying the `renderLabel` property to your `filterProps` as seen below. Otherwise it will default to `key: value`.',
47
+ source: {
48
+ code: "\nfilterProps: {\n ...otherFilterProps,\n renderLabel: (key, value) => myCustomTagLabelFormatter(key, value),\n},\n "
49
+ }
44
50
  }, {
45
51
  subTitle: 'Putting it all together',
46
52
  source: {
@@ -50,7 +56,7 @@ export var DocsPage = function DocsPage() {
50
56
  subTitle: "`filterProps` types",
51
57
  source: {
52
58
  language: 'json',
53
- code: "\nfilterProps: {\n /** The variation of filtering */\n variation: 'flyout'|'panel',\n /** The update method in which to filter, instant automatically\n applies the filters, batch the user has to click apply */\n updateMethod: 'batch'|'instant',\n /** Text for primary action button, default is 'Apply' */\n primaryActionLabel: string,\n /** Text for secondary action button, default is 'Cancel' */\n secondaryActionLabel: string,\n /** Text for flyout icon description */\n flyoutIconDescription: string,\n /** Array of objects to render filters in flyout */\n filters: object[]\n}\n "
59
+ code: "\nfilterProps: {\n /** The variation of filtering */\n variation: 'flyout'|'panel',\n /** The update method in which to filter, instant automatically\n applies the filters, batch the user has to click apply */\n updateMethod: 'batch'|'instant',\n /** Text for primary action button, default is 'Apply' */\n primaryActionLabel: string,\n /** Text for secondary action button, default is 'Cancel' */\n secondaryActionLabel: string,\n /** Text for flyout icon description */\n flyoutIconDescription: string,\n /** Array of objects to render filters in flyout */\n filters: object[]\n /** Applies custom formatting to filter tags */\n renderLabel: Function\n}\n "
54
60
  }
55
61
  }]
56
62
  });
@@ -9,14 +9,10 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
9
9
  * LICENSE file in the root directory of this source tree.
10
10
  */
11
11
 
12
- import { useEffect, useState } from 'react';
13
- import { pkg } from '../../settings';
12
+ import { useState } from 'react';
14
13
  import DatagridExpandedRow from './Datagrid/DatagridExpandedRow';
15
14
  import useRowExpander from './useRowExpander';
16
15
  var useExpandedRow = function useExpandedRow(hooks) {
17
- useEffect(function () {
18
- pkg.checkReportFeatureEnabled('Datagrid.useExpandedRow');
19
- }, []);
20
16
  useRowExpander(hooks);
21
17
  var useInstance = function useInstance(instance) {
22
18
  var rows = instance.rows,
@@ -38,7 +34,8 @@ var useExpandedRow = function useExpandedRow(hooks) {
38
34
  });
39
35
  Object.assign(instance, {
40
36
  rows: rowsWithExpand,
41
- setExpandedRowHeight: setExpandedRowHeight
37
+ setExpandedRowHeight: setExpandedRowHeight,
38
+ withExpandedRows: true
42
39
  });
43
40
  };
44
41
  hooks.useInstance.push(useInstance);