@carbon/ibm-products 1.53.1 → 1.54.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. package/README.md +15 -15
  2. package/es/components/AboutModal/AboutModal.js +1 -3
  3. package/es/components/ActionBar/ActionBar.js +4 -6
  4. package/es/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -6
  5. package/es/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +3 -9
  6. package/es/components/Datagrid/Datagrid/DatagridVirtualBody.js +1 -3
  7. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +35 -36
  8. package/es/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +22 -26
  9. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +0 -1
  10. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +50 -17
  11. package/es/components/Datagrid/useFiltering.js +1 -1
  12. package/es/components/Datagrid/utils/makeData.js +1 -1
  13. package/es/components/PageHeader/PageHeader.js +2 -6
  14. package/es/components/SidePanel/SidePanel.js +1 -3
  15. package/es/components/TagSet/TagSet.js +2 -6
  16. package/es/global/js/hooks/useResizeObserver.js +14 -28
  17. package/es/global/js/utils/story-helper.js +1 -1
  18. package/lib/components/AboutModal/AboutModal.js +1 -3
  19. package/lib/components/ActionBar/ActionBar.js +4 -6
  20. package/lib/components/BreadcrumbWithOverflow/BreadcrumbWithOverflow.js +2 -6
  21. package/lib/components/ButtonSetWithOverflow/ButtonSetWithOverflow.js +3 -9
  22. package/lib/components/Datagrid/Datagrid/DatagridVirtualBody.js +1 -3
  23. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterFlyout.js +33 -35
  24. package/lib/components/Datagrid/Datagrid/addons/Filtering/FilterPanel.js +22 -26
  25. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/index.js +0 -7
  26. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useFilters.js +48 -15
  27. package/lib/components/Datagrid/useFiltering.js +1 -1
  28. package/lib/components/Datagrid/utils/makeData.js +1 -1
  29. package/lib/components/PageHeader/PageHeader.js +2 -6
  30. package/lib/components/SidePanel/SidePanel.js +1 -3
  31. package/lib/components/TagSet/TagSet.js +2 -6
  32. package/lib/global/js/hooks/useResizeObserver.js +13 -27
  33. package/lib/global/js/utils/story-helper.js +1 -1
  34. package/package.json +7 -7
  35. package/es/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +0 -21
  36. package/lib/components/Datagrid/Datagrid/addons/Filtering/hooks/useInitialStateFromFilters.js +0 -30
@@ -14,13 +14,7 @@ var _react = require("react");
14
14
  * LICENSE file in the root directory of this source tree.
15
15
  */
16
16
 
17
- var useResizeObserver = function useResizeObserver(ref) {
18
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
19
- callback: null,
20
- throttleInterval: 0
21
- };
22
- var callback = options.callback,
23
- throttleInterval = options.throttleInterval;
17
+ var useResizeObserver = function useResizeObserver(ref, callback) {
24
18
  var _useState = (0, _react.useState)(0),
25
19
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
26
20
  width = _useState2[0],
@@ -29,8 +23,14 @@ var useResizeObserver = function useResizeObserver(ref) {
29
23
  _useState4 = (0, _slicedToArray2.default)(_useState3, 2),
30
24
  height = _useState4[0],
31
25
  setHeight = _useState4[1];
32
- var throttleTimeout = (0, _react.useRef)(null);
33
26
  var entriesToHandle = (0, _react.useRef)(null);
27
+ var cb = (0, _react.useRef)(callback);
28
+ (0, _react.useEffect)(function () {
29
+ // ref for callback removes it as dependency fro useLayoutEffect
30
+ // This significantly reduces repeated calls if a function is redefined on every
31
+ // render
32
+ cb.current = callback;
33
+ }, [callback]);
34
34
  (0, _react.useLayoutEffect)(function () {
35
35
  if (!(ref !== null && ref !== void 0 && ref.current)) {
36
36
  return;
@@ -42,29 +42,15 @@ var useResizeObserver = function useResizeObserver(ref) {
42
42
  var entry = entriesToHandle.current[0];
43
43
  setWidth(entry.contentRect.width);
44
44
  setHeight(entry.contentRect.height);
45
- throttleTimeout.current = null;
46
- callback && callback(entry.contentRect);
45
+ cb.current && cb.current(entry.contentRect);
47
46
  };
48
47
  var observer = new ResizeObserver(function (entries) {
49
48
  // always update entriesToHandle
50
49
  entriesToHandle.current = entries;
51
- if (throttleInterval) {
52
- // if a throttleInterval check for running timeout
53
- if (throttleTimeout.current === null) {
54
- // no live timeout set entries to handle and move on
55
-
56
- // set up throttle
57
- throttleTimeout.current = setTimeout(function () {
58
- // do callbacks
59
- doCallbacks();
60
- // reset throttle
61
- throttleTimeout.current = null;
62
- }, throttleInterval);
63
- }
64
- } else {
65
- // no throttle do callbacks every time
50
+ window.requestAnimationFrame(function () {
51
+ // do callbacks
66
52
  doCallbacks();
67
- }
53
+ });
68
54
  });
69
55
 
70
56
  // observe all refs passed
@@ -74,7 +60,7 @@ var useResizeObserver = function useResizeObserver(ref) {
74
60
  observer = null;
75
61
  };
76
62
  // eslint-disable-next-line react-hooks/exhaustive-deps
77
- }, [ref, options]);
63
+ }, [ref]);
78
64
  return {
79
65
  width: width,
80
66
  height: height
@@ -75,7 +75,7 @@ exports.prepareStory = prepareStory;
75
75
  var CodesandboxLink = function CodesandboxLink(_ref) {
76
76
  var exampleDirectory = _ref.exampleDirectory;
77
77
  return /*#__PURE__*/_react.default.createElement("a", {
78
- href: "https://codesandbox.io/s/github/carbon-design-system/ibm-cloud-cognitive/tree/main_v1/examples/carbon-for-ibm-products/".concat(exampleDirectory)
78
+ href: "https://codesandbox.io/s/github/carbon-design-system/ibm-products/tree/main_v1/examples/carbon-for-ibm-products/".concat(exampleDirectory)
79
79
  }, /*#__PURE__*/_react.default.createElement("img", {
80
80
  alt: "Edit on CodeSandbox",
81
81
  src: "https://codesandbox.io/static/img/play-codesandbox.svg"
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@carbon/ibm-products",
3
3
  "description": "Carbon for IBM Products",
4
- "version": "1.53.1",
4
+ "version": "1.54.1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "https://github.com/carbon-design-system/ibm-cloud-cognitive.git",
11
- "directory": "packages/cloud-cognitive"
10
+ "url": "https://github.com/carbon-design-system/ibm-products.git",
11
+ "directory": "packages/ibm-products"
12
12
  },
13
- "bugs": "https://github.com/carbon-design-system/ibm-cloud-cognitive/issues",
13
+ "bugs": "https://github.com/carbon-design-system/ibm-products/issues",
14
14
  "sideEffects": [
15
15
  "**/global/js/utils/props-helper.js",
16
16
  "**/*.css",
@@ -53,7 +53,7 @@
53
53
  "devDependencies": {
54
54
  "@babel/cli": "^7.20.7",
55
55
  "@babel/core": "^7.20.12",
56
- "babel-preset-ibm-cloud-cognitive": "^0.14.27",
56
+ "babel-preset-ibm-cloud-cognitive": "^0.14.28",
57
57
  "chalk": "^4.1.2",
58
58
  "change-case": "^4.1.2",
59
59
  "copyfiles": "^2.4.1",
@@ -61,7 +61,7 @@
61
61
  "fs-extra": "^11.1.0",
62
62
  "glob": "^8.1.0",
63
63
  "jest": "^29.4.2",
64
- "jest-config-ibm-cloud-cognitive": "^0.24.14",
64
+ "jest-config-ibm-cloud-cognitive": "^0.24.15",
65
65
  "jest-environment-jsdom": "^29.4.2",
66
66
  "namor": "^1.1.2",
67
67
  "npm-check-updates": "^16.7.4",
@@ -95,5 +95,5 @@
95
95
  "react": "^16.8.6 || ^17.0.1",
96
96
  "react-dom": "^16.8.6 || ^17.0.1"
97
97
  },
98
- "gitHead": "1eaa6392a5ddc2c60ee54bc73f427ee447749d16"
98
+ "gitHead": "d492e0ac9ef45929459680ea97274be0fcee61e5"
99
99
  }
@@ -1,21 +0,0 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
- /*
3
- * Licensed Materials - Property of IBM
4
- * 5724-Q36
5
- * (c) Copyright IBM Corp. 2022
6
- * US Government Users Restricted Rights - Use, duplication or disclosure
7
- * restricted by GSA ADP Schedule Contract with IBM Corp.
8
- */
9
- import { useState } from 'react';
10
- import { FLYOUT } from '../constants';
11
- import { getInitialStateFromFilters } from '../utils';
12
- var useInitialStateFromFilters = function useInitialStateFromFilters(filters) {
13
- var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : FLYOUT;
14
- var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
15
- var _useState = useState(getInitialStateFromFilters(filters, variation, initialFilters)),
16
- _useState2 = _slicedToArray(_useState, 2),
17
- state = _useState2[0],
18
- setState = _useState2[1];
19
- return [state, setState];
20
- };
21
- export default useInitialStateFromFilters;
@@ -1,30 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
- var _react = require("react");
10
- var _constants = require("../constants");
11
- var _utils = require("../utils");
12
- /*
13
- * Licensed Materials - Property of IBM
14
- * 5724-Q36
15
- * (c) Copyright IBM Corp. 2022
16
- * US Government Users Restricted Rights - Use, duplication or disclosure
17
- * restricted by GSA ADP Schedule Contract with IBM Corp.
18
- */
19
-
20
- var useInitialStateFromFilters = function useInitialStateFromFilters(filters) {
21
- var variation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.FLYOUT;
22
- var initialFilters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
23
- var _useState = (0, _react.useState)((0, _utils.getInitialStateFromFilters)(filters, variation, initialFilters)),
24
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
25
- state = _useState2[0],
26
- setState = _useState2[1];
27
- return [state, setState];
28
- };
29
- var _default = useInitialStateFromFilters;
30
- exports.default = _default;