@carbon/ibm-products 1.54.1 → 1.55.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. package/css/index-full-carbon.css +1309 -110
  2. package/css/index-full-carbon.css.map +1 -1
  3. package/css/index-full-carbon.min.css +3 -3
  4. package/css/index-full-carbon.min.css.map +1 -1
  5. package/css/index-without-carbon.css +1304 -110
  6. package/css/index-without-carbon.css.map +1 -1
  7. package/css/index-without-carbon.min.css +2 -2
  8. package/css/index-without-carbon.min.css.map +1 -1
  9. package/css/index.css +1312 -113
  10. package/css/index.css.map +1 -1
  11. package/css/index.min.css +3 -3
  12. package/css/index.min.css.map +1 -1
  13. package/es/components/APIKeyModal/APIKeyModal.js +25 -21
  14. package/es/components/ActionBar/ActionBar.js +5 -5
  15. package/es/components/Carousel/Carousel.js +237 -0
  16. package/es/components/Carousel/CarouselItem.js +66 -0
  17. package/es/components/Carousel/index.js +9 -0
  18. package/es/components/Carousel/utils.js +98 -0
  19. package/es/components/CreateFullPage/CreateFullPage.js +4 -2
  20. package/es/components/CreateModal/CreateModal.js +2 -1
  21. package/es/components/CreateSidePanel/CreateSidePanel.js +6 -2
  22. package/es/components/CreateTearsheet/CreateTearsheet.js +3 -1
  23. package/es/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +6 -2
  24. package/es/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -1
  25. package/es/components/Datagrid/Datagrid/DatagridToolbar.js +3 -2
  26. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +2 -1
  27. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +13 -0
  28. package/es/components/Datagrid/index.js +2 -1
  29. package/es/components/Datagrid/useActionsColumn.js +13 -7
  30. package/es/components/Datagrid/useOnRowClick.js +20 -4
  31. package/es/components/Datagrid/useSortableColumns.js +27 -3
  32. package/es/components/Datagrid/useStickyColumn.js +10 -3
  33. package/es/components/Datagrid/utils/DatagridActions.js +6 -6
  34. package/es/components/Datagrid/utils/getArgTypes.js +4 -0
  35. package/es/components/EditSidePanel/EditSidePanel.js +7 -3
  36. package/es/components/FilterSummary/FilterSummary.js +7 -3
  37. package/es/components/Guidebanner/Guidebanner.js +229 -0
  38. package/es/components/Guidebanner/GuidebannerElement.js +71 -0
  39. package/es/components/Guidebanner/GuidebannerElementButton.js +76 -0
  40. package/es/components/Guidebanner/GuidebannerElementLink.js +56 -0
  41. package/es/components/Guidebanner/index.js +11 -0
  42. package/es/components/InlineTip/InlineTip.js +228 -0
  43. package/es/components/InlineTip/InlineTipButton.js +89 -0
  44. package/es/components/InlineTip/InlineTipLink.js +89 -0
  45. package/es/components/InlineTip/index.js +10 -0
  46. package/es/components/InlineTip/utils.js +36 -0
  47. package/es/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +164 -0
  48. package/es/components/SteppedAnimatedMedia/assets/index.js +4 -0
  49. package/es/components/SteppedAnimatedMedia/index.js +8 -0
  50. package/es/components/Tearsheet/TearsheetShell.js +2 -1
  51. package/es/components/index.js +4 -2
  52. package/es/global/js/hooks/useResizeObserver.js +1 -1
  53. package/es/global/js/package-settings.js +2 -0
  54. package/lib/components/APIKeyModal/APIKeyModal.js +25 -21
  55. package/lib/components/ActionBar/ActionBar.js +5 -5
  56. package/lib/components/Carousel/Carousel.js +238 -0
  57. package/lib/components/Carousel/CarouselItem.js +66 -0
  58. package/lib/components/Carousel/index.js +19 -0
  59. package/lib/components/Carousel/utils.js +108 -0
  60. package/lib/components/CreateFullPage/CreateFullPage.js +4 -2
  61. package/lib/components/CreateModal/CreateModal.js +2 -1
  62. package/lib/components/CreateSidePanel/CreateSidePanel.js +6 -2
  63. package/lib/components/CreateTearsheet/CreateTearsheet.js +3 -1
  64. package/lib/components/CreateTearsheetNarrow/CreateTearsheetNarrow.js +6 -2
  65. package/lib/components/Datagrid/Datagrid/DatagridHeaderRow.js +1 -1
  66. package/lib/components/Datagrid/Datagrid/DatagridToolbar.js +3 -2
  67. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +8 -1
  68. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilterContext.js +20 -0
  69. package/lib/components/Datagrid/index.js +8 -1
  70. package/lib/components/Datagrid/useActionsColumn.js +13 -7
  71. package/lib/components/Datagrid/useOnRowClick.js +20 -4
  72. package/lib/components/Datagrid/useSortableColumns.js +27 -3
  73. package/lib/components/Datagrid/useStickyColumn.js +10 -3
  74. package/lib/components/Datagrid/utils/DatagridActions.js +6 -6
  75. package/lib/components/Datagrid/utils/getArgTypes.js +4 -0
  76. package/lib/components/EditSidePanel/EditSidePanel.js +7 -3
  77. package/lib/components/FilterSummary/FilterSummary.js +7 -3
  78. package/lib/components/Guidebanner/Guidebanner.js +229 -0
  79. package/lib/components/Guidebanner/GuidebannerElement.js +67 -0
  80. package/lib/components/Guidebanner/GuidebannerElementButton.js +71 -0
  81. package/lib/components/Guidebanner/GuidebannerElementLink.js +52 -0
  82. package/lib/components/Guidebanner/index.js +33 -0
  83. package/lib/components/InlineTip/InlineTip.js +228 -0
  84. package/lib/components/InlineTip/InlineTipButton.js +86 -0
  85. package/lib/components/InlineTip/InlineTipLink.js +86 -0
  86. package/lib/components/InlineTip/index.js +26 -0
  87. package/lib/components/InlineTip/utils.js +44 -0
  88. package/lib/components/SteppedAnimatedMedia/SteppedAnimatedMedia.js +165 -0
  89. package/lib/components/SteppedAnimatedMedia/assets/index.js +12 -0
  90. package/lib/components/SteppedAnimatedMedia/index.js +12 -0
  91. package/lib/components/Tearsheet/TearsheetShell.js +2 -1
  92. package/lib/components/index.js +21 -1
  93. package/lib/global/js/hooks/useResizeObserver.js +1 -1
  94. package/lib/global/js/package-settings.js +2 -0
  95. package/package.json +5 -5
  96. package/scss/components/Carousel/_carousel.scss +80 -0
  97. package/scss/components/Carousel/_index.scss +8 -0
  98. package/scss/components/Carousel/_storybook-styles.scss +10 -0
  99. package/scss/components/Datagrid/_storybook-styles.scss +13 -0
  100. package/scss/components/Datagrid/styles/_datagrid.scss +1 -6
  101. package/scss/components/Guidebanner/_guidebanner.scss +257 -0
  102. package/scss/components/Guidebanner/_index.scss +8 -0
  103. package/scss/components/Guidebanner/_storybook-styles.scss +20 -0
  104. package/scss/components/InlineTip/_index.scss +8 -0
  105. package/scss/components/InlineTip/_inline-tip.scss +231 -0
  106. package/scss/components/InlineTip/_storybook-styles.scss +21 -0
  107. package/scss/components/SteppedAnimatedMedia/_index.scss +8 -0
  108. package/scss/components/SteppedAnimatedMedia/_stepped-animated-media.scss +34 -0
  109. package/scss/components/SteppedAnimatedMedia/_storybook-styles.scss +12 -0
  110. package/scss/components/_index.scss +4 -0
@@ -74,13 +74,12 @@ export var ActionBar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
74
74
  className: "".concat(blockClass, "__hidden-sizing-items"),
75
75
  "aria-hidden": true,
76
76
  ref: sizingRef
77
- }, /*#__PURE__*/React.createElement("span", {
78
- "aria-hidden": false
79
- }, /*#__PURE__*/React.createElement(ActionBarOverflowItems, {
77
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(ActionBarOverflowItems, {
80
78
  className: "".concat(blockClass, "__hidden-sizing-item"),
81
79
  overflowAriaLabel: "hidden sizing overflow items",
82
80
  overflowItems: [],
83
- key: "hidden-overflow-menu"
81
+ key: "hidden-overflow-menu",
82
+ tabIndex: -1
84
83
  }), actions.map(function (_ref2) {
85
84
  var key = _ref2.key,
86
85
  id = _ref2.id,
@@ -89,7 +88,8 @@ export var ActionBar = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
89
88
  // ensure id is not duplicated
90
89
  "data-original-id": id,
91
90
  key: "hidden-item-".concat(key),
92
- className: "".concat(blockClass, "__hidden-sizing-item")
91
+ className: "".concat(blockClass, "__hidden-sizing-item"),
92
+ tabIndex: -1
93
93
  }));
94
94
  }))));
95
95
  }, [actions]);
@@ -0,0 +1,237 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["children", "className", "disableArrowScroll", "fadedEdgeColor", "scrollableChange", "scrollTune"];
5
+ /**
6
+ * Copyright IBM Corp. 2023, 2023
7
+ *
8
+ * This source code is licensed under the Apache-2.0 license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+
12
+ import React, { useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react';
13
+
14
+ // Other standard imports.
15
+ import { clamp, debounce } from 'lodash';
16
+ import PropTypes from 'prop-types';
17
+ import { CarouselItem } from './CarouselItem';
18
+ import { useIsOverflow, useWindowEvent } from './utils';
19
+ import cx from 'classnames';
20
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
21
+ import { pkg } from '../../settings';
22
+
23
+ // Carbon and package components we use.
24
+ /* TODO: @import(s) of carbon components and other package components. */
25
+
26
+ // The block part of our conventional BEM class names (blockClass__E--M).
27
+ var blockClass = "".concat(pkg.prefix, "--carousel");
28
+ var componentName = 'Carousel';
29
+
30
+ // Default values for props
31
+ var defaults = {
32
+ disableArrowScroll: false,
33
+ scrollTune: 0
34
+ };
35
+
36
+ /**
37
+ * The Carousel acts as a scaffold for other Novice to Pro content.
38
+ *
39
+ * This component is not intended for general use.
40
+ */
41
+ export var Carousel = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
42
+ var children = _ref.children,
43
+ className = _ref.className,
44
+ _ref$disableArrowScro = _ref.disableArrowScroll,
45
+ disableArrowScroll = _ref$disableArrowScro === void 0 ? defaults.disableArrowScroll : _ref$disableArrowScro,
46
+ fadedEdgeColor = _ref.fadedEdgeColor,
47
+ scrollableChange = _ref.scrollableChange,
48
+ _ref$scrollTune = _ref.scrollTune,
49
+ scrollTune = _ref$scrollTune === void 0 ? defaults.scrollTune : _ref$scrollTune,
50
+ rest = _objectWithoutProperties(_ref, _excluded);
51
+ var carouselScrollPromiseDelay = 700;
52
+ var totalViews = React.Children.count(children) || 1;
53
+ var leftFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.left) || fadedEdgeColor;
54
+ var rightFadedEdgeColor = (fadedEdgeColor === null || fadedEdgeColor === void 0 ? void 0 : fadedEdgeColor.right) || fadedEdgeColor;
55
+ var _useState = useState(0),
56
+ _useState2 = _slicedToArray(_useState, 2),
57
+ currentViewID = _useState2[0],
58
+ _setCurrentViewID = _useState2[1];
59
+ var currentViewIDRef = useRef(currentViewID);
60
+ var scrollRef = useRef();
61
+ var carouselRef = useRef();
62
+ var isScrollable = useIsOverflow(scrollRef);
63
+ // Scrolling has no complete callback, nor does it return a promise.
64
+ // Since there is no way to tell when a scroll is finished we can set a timeout.
65
+ // Chrome appears to be the slowest implementation.
66
+ // Here is the spec: https://drafts.csswg.org/cssom-view/#concept-smooth-scroll
67
+ // found issue: https://github.com/w3c/csswg-drafts/issues/3744
68
+
69
+ var scrollNext = useCallback(function () {
70
+ return scrollToView(currentViewID + 1);
71
+ }, [currentViewID, scrollToView]);
72
+ var scrollPrev = useCallback(function () {
73
+ return scrollToView(currentViewID - 1);
74
+ }, [currentViewID, scrollToView]);
75
+ var scrollToView = useCallback(function (viewID) {
76
+ if (!isScrolling) {
77
+ var _scrollRef$current;
78
+ var targetViewID = clamp(viewID, 0, totalViews - 1);
79
+ setCurrentViewID(targetViewID);
80
+ setIsScrolling(true);
81
+ scrollRef.current.scrollLeft = ((_scrollRef$current = scrollRef.current) === null || _scrollRef$current === void 0 ? void 0 : _scrollRef$current.offsetWidth) * targetViewID + scrollTune;
82
+ return scrollPromise();
83
+ }
84
+ return new Promise(function (resolve) {
85
+ return resolveScroll(resolve);
86
+ });
87
+ }, [isScrolling, resolveScroll, scrollPromise, scrollTune, totalViews]);
88
+ var scrollPromise = useCallback(function () {
89
+ return new Promise(function (resolve) {
90
+ setTimeout(function () {
91
+ return resolveScroll(resolve);
92
+ }, carouselScrollPromiseDelay);
93
+ });
94
+ }, [resolveScroll]);
95
+ var resolveScroll = useCallback(function (resolve) {
96
+ setIsScrolling(false);
97
+ var percentage = scrollPosition() / maxScroll();
98
+ return resolve(parseFloat(percentage.toFixed(2)));
99
+ }, []);
100
+ var scrollPosition = function scrollPosition() {
101
+ var _scrollRef$current2;
102
+ return (_scrollRef$current2 = scrollRef.current) === null || _scrollRef$current2 === void 0 ? void 0 : _scrollRef$current2.scrollLeft;
103
+ };
104
+ var maxScroll = function maxScroll() {
105
+ var _scrollRef$current3, _scrollRef$current4;
106
+ 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);
107
+ };
108
+ var handleResize = debounce(function () {
109
+ scrollToView(currentViewIDRef.current);
110
+ }, 200);
111
+ var setCurrentViewID = function setCurrentViewID(val) {
112
+ currentViewIDRef.current = val;
113
+ _setCurrentViewID(val);
114
+ };
115
+ var _useState3 = useState(false),
116
+ _useState4 = _slicedToArray(_useState3, 2),
117
+ isScrolling = _useState4[0],
118
+ setIsScrolling = _useState4[1];
119
+
120
+ // EFFECTS
121
+ useWindowEvent('resize', handleResize);
122
+ useEffect(function () {
123
+ if (scrollableChange) {
124
+ scrollableChange(isScrollable);
125
+ }
126
+ }, [isScrollable, scrollableChange]);
127
+ useEffect(function () {
128
+ function updateScrollPosition(event) {
129
+ // update the scroll position
130
+ event.stopPropagation();
131
+ event.preventDefault();
132
+ event.cancelBubble = false;
133
+ }
134
+ var scrollDiv = scrollRef.current;
135
+ if (scrollDiv) {
136
+ scrollDiv.addEventListener('wheel', updateScrollPosition, {
137
+ passive: false
138
+ });
139
+ return function () {
140
+ scrollDiv.removeEventListener('wheel', updateScrollPosition, {
141
+ passive: false
142
+ });
143
+ };
144
+ }
145
+ }, []);
146
+ useEffect(function () {
147
+ function keypress(event) {
148
+ var key = event.key;
149
+ if ((key === 'ArrowLeft' || key === 'ArrowRight') && disableArrowScroll) {
150
+ event.stopPropagation();
151
+ event.preventDefault();
152
+ event.cancelBubble = false;
153
+ }
154
+ }
155
+ var outerDiv = carouselRef.current;
156
+ if (outerDiv) {
157
+ outerDiv.addEventListener('keydown', keypress);
158
+ return function () {
159
+ return outerDiv.removeEventListener('keydown', keypress);
160
+ };
161
+ }
162
+ }, [disableArrowScroll]);
163
+ useImperativeHandle(ref, function () {
164
+ return {
165
+ scrollNext: scrollNext,
166
+ scrollPrev: scrollPrev,
167
+ scrollToView: scrollToView,
168
+ maxScroll: maxScroll
169
+ };
170
+ }, [scrollNext, scrollPrev, scrollToView]);
171
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
172
+ tabIndex: -1,
173
+ className: cx(blockClass, className),
174
+ ref: carouselRef,
175
+ role: "main"
176
+ }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("div", {
177
+ className: cx("".concat(blockClass, "__elements-container"))
178
+ }, /*#__PURE__*/React.createElement("div", {
179
+ className: "".concat(blockClass, "__elements"),
180
+ ref: scrollRef
181
+ }, React.Children.map(children, function (child) {
182
+ return /*#__PURE__*/React.createElement(CarouselItem, null, child);
183
+ })), leftFadedEdgeColor && /*#__PURE__*/React.createElement("div", {
184
+ className: "".concat(blockClass, "__elements-container--scrolled"),
185
+ style: {
186
+ background: "linear-gradient(90deg, ".concat(leftFadedEdgeColor, ", transparent)")
187
+ }
188
+ }), rightFadedEdgeColor && /*#__PURE__*/React.createElement("div", {
189
+ className: "".concat(blockClass, "__elements-container--scroll-max"),
190
+ style: {
191
+ background: "linear-gradient(270deg, ".concat(rightFadedEdgeColor, ", transparent)")
192
+ }
193
+ })));
194
+ });
195
+
196
+ // The display name of the component, used by React. Note that displayName
197
+ // is used in preference to relying on function.name.
198
+ Carousel.displayName = componentName;
199
+
200
+ // The types and DocGen commentary for the component props,
201
+ // in alphabetical order (for consistency).
202
+ // See https://www.npmjs.com/package/prop-types#usage.
203
+ Carousel.propTypes = {
204
+ /**
205
+ * Provide the contents of the Carousel.
206
+ */
207
+ children: PropTypes.node.isRequired,
208
+ /**
209
+ * Provide an optional class to be applied to the containing node.
210
+ */
211
+ className: PropTypes.string,
212
+ /**
213
+ * Disables the ability of the Carousel to scroll
214
+ * use a keyboard's left and right arrow keys.
215
+ */
216
+ disableArrowScroll: PropTypes.bool,
217
+ /**
218
+ * Enables the edges of the component to have faded styling.
219
+ *
220
+ * Pass a single string to specify the same color for left and right.
221
+ *
222
+ * Pass `{ left: $color1, right: $color2 }` to specify different colors.
223
+ */
224
+ fadedEdgeColor: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
225
+ left: PropTypes.string,
226
+ right: PropTypes.string
227
+ })]),
228
+ /**
229
+ * Determines how much of the Carousel moves into view on rotation.
230
+ */
231
+ scrollTune: PropTypes.number,
232
+ /**
233
+ * An optional callback function that returns `true`
234
+ * when the carousel has completed scrolling a single item.
235
+ */
236
+ scrollableChange: PropTypes.func
237
+ };
@@ -0,0 +1,66 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
+ var _excluded = ["children", "className"];
5
+ /**
6
+ * Copyright IBM Corp. 2023, 2023
7
+ *
8
+ * This source code is licensed under the Apache-2.0 license found in the
9
+ * LICENSE file in the root directory of this source tree.
10
+ */
11
+
12
+ import React, { useEffect, useRef } from 'react';
13
+
14
+ // Other standard imports.
15
+ import PropTypes from 'prop-types';
16
+ import cx from 'classnames';
17
+ import { useIntersection } from './utils';
18
+ import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
+ import { pkg } from '../../settings';
20
+
21
+ // Carbon and package components we use.
22
+ /* TODO: @import(s) of carbon components and other package components. */
23
+
24
+ // The block part of our conventional BEM class names (blockClass__E--M).
25
+ var blockClass = "".concat(pkg.prefix, "--carousel__item");
26
+ var componentName = 'CarouselItem';
27
+
28
+ /**
29
+ * TODO: A description of the component.
30
+ */
31
+ var CarouselItem = function CarouselItem(_ref) {
32
+ var children = _ref.children,
33
+ className = _ref.className,
34
+ 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
+ return /*#__PURE__*/React.createElement("div", _extends({}, rest, {
48
+ className: cx(blockClass, className),
49
+ ref: itemRef
50
+ }, getDevtoolsProps(componentName)), children);
51
+ };
52
+
53
+ // The types and DocGen commentary for the component props,
54
+ // in alphabetical order (for consistency).
55
+ // See https://www.npmjs.com/package/prop-types#usage.
56
+ CarouselItem.propTypes = {
57
+ /**
58
+ * Provide the contents of the CarouselItem.
59
+ */
60
+ children: PropTypes.node.isRequired,
61
+ /**
62
+ * Provide an optional class to be applied to the containing node.
63
+ */
64
+ className: PropTypes.string
65
+ };
66
+ 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 _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
- var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "firstFocusElement", "submitButtonText"];
4
+ var _excluded = ["backButtonText", "cancelButtonText", "children", "className", "modalDangerButtonText", "modalDescription", "modalSecondaryButtonText", "modalTitle", "nextButtonText", "onClose", "onRequestSubmit", "firstFocusElement", "submitButtonText", "title"];
5
5
  /**
6
6
  * Copyright IBM Corp. 2021, 2023
7
7
  *
@@ -49,6 +49,7 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
49
49
  onRequestSubmit = _ref.onRequestSubmit,
50
50
  firstFocusElement = _ref.firstFocusElement,
51
51
  submitButtonText = _ref.submitButtonText,
52
+ title = _ref.title,
52
53
  rest = _objectWithoutProperties(_ref, _excluded);
53
54
  var _useState = useState([]),
54
55
  _useState2 = _slicedToArray(_useState, 2),
@@ -159,7 +160,8 @@ export var CreateFullPage = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
159
160
  }, /*#__PURE__*/React.createElement("div", {
160
161
  className: "".concat(blockClass, "__content")
161
162
  }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Form, {
162
- className: "".concat(blockClass, "__form")
163
+ className: "".concat(blockClass, "__form"),
164
+ "aria-label": title
163
165
  }, /*#__PURE__*/React.createElement(StepsContext.Provider, {
164
166
  value: {
165
167
  currentStep: currentStep,
@@ -66,7 +66,8 @@ export var CreateModal = /*#__PURE__*/React.forwardRef(function (_ref2, ref) {
66
66
  }, description && /*#__PURE__*/React.createElement("p", {
67
67
  className: "".concat(blockClass, "__description")
68
68
  }, description), /*#__PURE__*/React.createElement(Form, {
69
- className: "".concat(blockClass, "__form")
69
+ className: "".concat(blockClass, "__form"),
70
+ "aria-label": title
70
71
  }, children)), /*#__PURE__*/React.createElement(ModalFooter, null, /*#__PURE__*/React.createElement(Button, {
71
72
  type: "button",
72
73
  kind: "secondary",
@@ -23,6 +23,7 @@ import { getDevtoolsProps } from '../../global/js/utils/devtools';
23
23
  // Carbon and package components we use.
24
24
  import { Form } from 'carbon-components-react';
25
25
  import { SidePanel } from '../SidePanel';
26
+ import uuidv4 from '../../global/js/utils/uuidv4';
26
27
 
27
28
  // The block part of our conventional BEM class names (blockClass__E--M).
28
29
  var blockClass = "".concat(pkg.prefix, "--create-side-panel");
@@ -63,6 +64,7 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
63
64
  onClick: onRequestClose,
64
65
  kind: 'secondary'
65
66
  }];
67
+ var formTitleId = uuidv4();
66
68
  return selectorPageContent && /*#__PURE__*/React.createElement(SidePanel, _extends({}, rest, _objectSpread({
67
69
  open: open,
68
70
  ref: ref,
@@ -79,11 +81,13 @@ export var CreateSidePanel = /*#__PURE__*/React.forwardRef(function (_ref, ref)
79
81
  size: "md",
80
82
  actions: actions
81
83
  }), /*#__PURE__*/React.createElement("h3", {
82
- className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text")
84
+ className: "".concat(blockClass, "__form-title-text ").concat(blockClass, "__content-text"),
85
+ id: formTitleId
83
86
  }, formTitle), /*#__PURE__*/React.createElement("p", {
84
87
  className: "".concat(blockClass, "__form-description-text ").concat(blockClass, "__content-text")
85
88
  }, formDescription), /*#__PURE__*/React.createElement(Form, {
86
- className: "".concat(blockClass, "__form")
89
+ className: "".concat(blockClass, "__form"),
90
+ "aria-labelledby": formTitleId
87
91
  }, children));
88
92
  });
89
93
  CreateSidePanel = pkg.checkComponentEnabled(CreateSidePanel, componentName);
@@ -196,7 +196,9 @@ export var CreateTearsheet = /*#__PURE__*/forwardRef(function (_ref, ref) {
196
196
  className: "".concat(blockClass, "__content"),
197
197
  onBlur: handleBlur,
198
198
  ref: contentRef
199
- }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Form, null, /*#__PURE__*/React.createElement(StepsContext.Provider, {
199
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(Form, {
200
+ "aria-label": title
201
+ }, /*#__PURE__*/React.createElement(StepsContext.Provider, {
200
202
  value: {
201
203
  currentStep: currentStep,
202
204
  setIsDisabled: setIsDisabled,
@@ -18,6 +18,7 @@ import { Form } from 'carbon-components-react';
18
18
  import { getDevtoolsProps } from '../../global/js/utils/devtools';
19
19
  import { pkg } from '../../settings';
20
20
  import { TearsheetNarrow } from '../Tearsheet/TearsheetNarrow';
21
+ import uuidv4 from '../../global/js/utils/uuidv4';
21
22
 
22
23
  // The block part of our conventional BEM class names (blockClass__E--M).
23
24
  var blockClass = "".concat(pkg.prefix, "--create-tearsheet-narrow");
@@ -57,6 +58,7 @@ export var CreateTearsheetNarrow = /*#__PURE__*/React.forwardRef(function (_ref,
57
58
  kind: 'secondary'
58
59
  }];
59
60
  var formTextClass = "".concat(blockClass, "__content-text");
61
+ var formTitleId = uuidv4();
60
62
  return /*#__PURE__*/React.createElement(TearsheetNarrow, _extends({}, rest, {
61
63
  title: title,
62
64
  description: description,
@@ -73,11 +75,13 @@ export var CreateTearsheetNarrow = /*#__PURE__*/React.forwardRef(function (_ref,
73
75
  verticalPosition: verticalPosition,
74
76
  role: "presentation"
75
77
  }, getDevtoolsProps(componentName)), /*#__PURE__*/React.createElement("h3", {
76
- className: cx("".concat(blockClass, "__form-title-text"), formTextClass)
78
+ className: cx("".concat(blockClass, "__form-title-text"), formTextClass),
79
+ id: formTitleId
77
80
  }, formTitle), /*#__PURE__*/React.createElement("p", {
78
81
  className: cx("".concat(blockClass, "__form-description-text"), formTextClass)
79
82
  }, formDescription), /*#__PURE__*/React.createElement(Form, {
80
- className: "".concat(blockClass, "__form")
83
+ className: "".concat(blockClass, "__form"),
84
+ "aria-labelledby": formTitleId
81
85
  }, children));
82
86
  });
83
87
 
@@ -34,7 +34,7 @@ var HeaderRow = function HeaderRow(datagridState, headRef, headerGroup) {
34
34
  return /*#__PURE__*/React.createElement(TableHeader, _extends({}, header.getHeaderProps({
35
35
  role: false
36
36
  }), {
37
- className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), header.canSort), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
37
+ className: cx((_cx = {}, _defineProperty(_cx, "".concat(blockClass, "__resizableColumn"), header.getResizerProps), _defineProperty(_cx, "".concat(blockClass, "__isResizing"), header.isResizing), _defineProperty(_cx, "".concat(blockClass, "__sortableColumn"), datagridState.isTableSortable), _defineProperty(_cx, "".concat(blockClass, "__isSorted"), header.isSorted), _cx), header.getHeaderProps().className),
38
38
  key: header.id
39
39
  }), header.render('Header'), header.getResizerProps && /*#__PURE__*/React.createElement("div", _extends({}, header.getResizerProps(), {
40
40
  className: "".concat(blockClass, "__resizer")
@@ -17,6 +17,7 @@ import cx from 'classnames';
17
17
  var blockClass = "".concat(pkg.prefix, "--datagrid");
18
18
  var TableToolbar = DataTable.TableToolbar;
19
19
  var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridState, width, ref) {
20
+ var _Object$keys;
20
21
  var _useState = useState(false),
21
22
  _useState2 = _slicedToArray(_useState, 2),
22
23
  displayAllInMenu = _useState2[0],
@@ -29,11 +30,11 @@ var DatagridBatchActionsToolbar = function DatagridBatchActionsToolbar(datagridS
29
30
  _useState6 = _slicedToArray(_useState5, 2),
30
31
  receivedInitialWidth = _useState6[0],
31
32
  setReceivedInitialWidth = _useState6[1];
32
- var selectedFlatRows = datagridState.selectedFlatRows,
33
+ var selectedRowIds = datagridState.state.selectedRowIds,
33
34
  toggleAllRowsSelected = datagridState.toggleAllRowsSelected,
34
35
  toolbarBatchActions = datagridState.toolbarBatchActions,
35
36
  setGlobalFilter = datagridState.setGlobalFilter;
36
- var totalSelected = selectedFlatRows && selectedFlatRows.length;
37
+ var totalSelected = (_Object$keys = Object.keys(selectedRowIds || {})) === null || _Object$keys === void 0 ? void 0 : _Object$keys.length;
37
38
 
38
39
  // Get initial width of batch actions container,
39
40
  // used to measure when all items are put inside
@@ -7,4 +7,5 @@
7
7
 
8
8
  export { default as useSubscribeToEventEmitter } from './useSubscribeToEventEmitter';
9
9
  export { default as useShouldDisableButtons } from './useShouldDisableButtons';
10
- export { default as useFilters } from './useFilters';
10
+ export { default as useFilters } from './useFilters';
11
+ export { default as useFilterContext } from './useFilterContext';
@@ -0,0 +1,13 @@
1
+ import { FilterContext } from '../FilterProvider';
2
+ import { useContext } from 'react';
3
+ var useFilterContext = function useFilterContext() {
4
+ // get the context
5
+ var context = useContext(FilterContext);
6
+
7
+ // if `undefined`, throw an error
8
+ if (context === undefined) {
9
+ throw new Error('useFilterContext was used outside of its Provider');
10
+ }
11
+ return context;
12
+ };
13
+ export default useFilterContext;
@@ -25,4 +25,5 @@ export { default as useColumnOrder } from './useColumnOrder';
25
25
  export { default as useInlineEdit } from './useInlineEdit';
26
26
  export { default as useEditableCell } from './useEditableCell';
27
27
  export { default as useFiltering } from './useFiltering';
28
- export { getAutoSizedColumnWidth } from './utils/getAutoSizedColumnWidth';
28
+ export { getAutoSizedColumnWidth } from './utils/getAutoSizedColumnWidth';
29
+ export { useFilterContext } from './Datagrid/addons/Filtering/hooks';
@@ -24,7 +24,16 @@ var useActionsColumn = function useActionsColumn(hooks) {
24
24
  var useAttachActionsOnInstance = function useAttachActionsOnInstance(instance) {
25
25
  var rowActions = instance.rowActions,
26
26
  isFetching = instance.isFetching,
27
- selectedFlatRows = instance.selectedFlatRows;
27
+ selectedRowIds = instance.state.selectedRowIds;
28
+ var getDisabledState = function getDisabledState(rowIndex) {
29
+ var selectedRowIndexes = Object.keys(selectedRowIds).map(function (n) {
30
+ return Number(n);
31
+ });
32
+ if (selectedRowIndexes.includes(rowIndex)) {
33
+ return true;
34
+ }
35
+ return false;
36
+ };
28
37
  if (rowActions && Array.isArray(rowActions)) {
29
38
  var addActionsMenu = function addActionsMenu(props, cellData) {
30
39
  var cell = cellData.cell;
@@ -53,11 +62,8 @@ var useActionsColumn = function useActionsColumn(hooks) {
53
62
  if (hidden) {
54
63
  return null;
55
64
  }
56
- var selectedRowId = selectedFlatRows === null || selectedFlatRows === void 0 ? void 0 : selectedFlatRows.filter(function (item) {
57
- return item.id === row.id ? item.id : null;
58
- });
59
65
  return /*#__PURE__*/React.createElement("div", {
60
- className: cx("".concat(blockClass, "__actions-column-button"), _defineProperty({}, "".concat(blockClass, "__disabled-row-action-button"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
66
+ className: cx("".concat(blockClass, "__actions-column-button"), _defineProperty({}, "".concat(blockClass, "__disabled-row-action-button"), getDisabledState(row.index))),
61
67
  key: "".concat(itemText, "__").concat(index)
62
68
  }, /*#__PURE__*/React.createElement(OverflowMenu, _extends({}, rest, {
63
69
  renderIcon: icon,
@@ -65,9 +71,9 @@ var useActionsColumn = function useActionsColumn(hooks) {
65
71
  light: true,
66
72
  iconDescription: itemText,
67
73
  kind: "ghost",
68
- className: cx(_defineProperty({}, "".concat(blockClass, "__disabled-row-action"), selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length)),
74
+ className: cx(_defineProperty({}, "".concat(blockClass, "__disabled-row-action"), getDisabledState(row.index))),
69
75
  onClick: function onClick(e) {
70
- if (selectedFlatRows && selectedFlatRows.length && selectedRowId && selectedRowId.length) {
76
+ if (getDisabledState(row.index)) {
71
77
  // Row actions should be disabled if row is selected and batchActions toolbar is active
72
78
  return;
73
79
  }