@patternfly/react-core 4.236.6 → 4.236.7

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 4.236.7 (2022-09-07)
7
+
8
+ **Note:** Version bump only for package @patternfly/react-core
9
+
10
+
11
+
12
+
13
+
6
14
  ## 4.236.6 (2022-09-06)
7
15
 
8
16
 
@@ -54,9 +54,16 @@
54
54
  * );
55
55
  * }
56
56
  *
57
+ * Example 3 - With debounced method passed in:
58
+ *
59
+ * public componentDidMount() {
60
+ * this.observer = getResizeObserver(this.inputRef.current, debounce(this.handleResize, 250), false);
61
+ * }
62
+ *
57
63
  * @param {Element} containerRefElement The container reference to observe
58
64
  * @param {Function} handleResize The function to call for resize events
65
+ * @param {boolean} useRequestAnimationFrame Whether to pass the handleResize function as a callback to requestAnimationFrame. Pass in false when the function passed in is debounced. Defaults to true.
59
66
  * @return {Function} The function used to unobserve resize events
60
67
  */
61
- export declare const getResizeObserver: (containerRefElement: Element, handleResize: () => void) => () => void;
68
+ export declare const getResizeObserver: (containerRefElement: Element, handleResize: () => void, useRequestAnimationFrame?: boolean) => () => void;
62
69
  //# sourceMappingURL=resizeObserver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resizeObserver.d.ts","sourceRoot":"","sources":["../../../src/helpers/resizeObserver.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,eAAO,MAAM,iBAAiB,wBAAyB,OAAO,gBAAgB,MAAM,IAAI,eA2BvF,CAAC"}
1
+ {"version":3,"file":"resizeObserver.d.ts","sourceRoot":"","sources":["../../../src/helpers/resizeObserver.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,eAAO,MAAM,iBAAiB,wBACP,OAAO,gBACd,MAAM,IAAI,6BACE,OAAO,eAmClC,CAAC"}
@@ -55,22 +55,37 @@ import { canUseDOM } from './util';
55
55
  * );
56
56
  * }
57
57
  *
58
+ * Example 3 - With debounced method passed in:
59
+ *
60
+ * public componentDidMount() {
61
+ * this.observer = getResizeObserver(this.inputRef.current, debounce(this.handleResize, 250), false);
62
+ * }
63
+ *
58
64
  * @param {Element} containerRefElement The container reference to observe
59
65
  * @param {Function} handleResize The function to call for resize events
66
+ * @param {boolean} useRequestAnimationFrame Whether to pass the handleResize function as a callback to requestAnimationFrame. Pass in false when the function passed in is debounced. Defaults to true.
60
67
  * @return {Function} The function used to unobserve resize events
61
68
  */
62
- export const getResizeObserver = (containerRefElement, handleResize) => {
69
+ export const getResizeObserver = (containerRefElement, handleResize, useRequestAnimationFrame = true) => {
63
70
  let unobserve;
64
71
  if (canUseDOM) {
65
72
  const { ResizeObserver } = window;
66
73
  if (containerRefElement && ResizeObserver) {
67
74
  const resizeObserver = new ResizeObserver((entries) => {
68
75
  // Wrap resize function in requestAnimationFrame to avoid "ResizeObserver loop limit exceeded" errors
69
- window.requestAnimationFrame(() => {
76
+ if (useRequestAnimationFrame) {
77
+ window.requestAnimationFrame(() => {
78
+ if (Array.isArray(entries) && entries.length > 0) {
79
+ handleResize();
80
+ }
81
+ });
82
+ // Avoid wrapping function in requestAnimationFrame if the function is debounced
83
+ }
84
+ else {
70
85
  if (Array.isArray(entries) && entries.length > 0) {
71
86
  handleResize();
72
87
  }
73
- });
88
+ }
74
89
  });
75
90
  resizeObserver.observe(containerRefElement);
76
91
  unobserve = () => resizeObserver.unobserve(containerRefElement);
@@ -1 +1 @@
1
- {"version":3,"file":"resizeObserver.js","sourceRoot":"","sources":["../../../src/helpers/resizeObserver.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAA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example 3 - With debounced method passed in:
58
+ *
59
+ * public componentDidMount() {
60
+ * this.observer = getResizeObserver(this.inputRef.current, debounce(this.handleResize, 250), false);
61
+ * }
62
+ *
57
63
  * @param {Element} containerRefElement The container reference to observe
58
64
  * @param {Function} handleResize The function to call for resize events
65
+ * @param {boolean} useRequestAnimationFrame Whether to pass the handleResize function as a callback to requestAnimationFrame. Pass in false when the function passed in is debounced. Defaults to true.
59
66
  * @return {Function} The function used to unobserve resize events
60
67
  */
61
- export declare const getResizeObserver: (containerRefElement: Element, handleResize: () => void) => () => void;
68
+ export declare const getResizeObserver: (containerRefElement: Element, handleResize: () => void, useRequestAnimationFrame?: boolean) => () => void;
62
69
  //# sourceMappingURL=resizeObserver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resizeObserver.d.ts","sourceRoot":"","sources":["../../../src/helpers/resizeObserver.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,eAAO,MAAM,iBAAiB,wBAAyB,OAAO,gBAAgB,MAAM,IAAI,eA2BvF,CAAC"}
1
+ {"version":3,"file":"resizeObserver.d.ts","sourceRoot":"","sources":["../../../src/helpers/resizeObserver.tsx"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,eAAO,MAAM,iBAAiB,wBACP,OAAO,gBACd,MAAM,IAAI,6BACE,OAAO,eAmClC,CAAC"}
@@ -58,22 +58,37 @@ const util_1 = require("./util");
58
58
  * );
59
59
  * }
60
60
  *
61
+ * Example 3 - With debounced method passed in:
62
+ *
63
+ * public componentDidMount() {
64
+ * this.observer = getResizeObserver(this.inputRef.current, debounce(this.handleResize, 250), false);
65
+ * }
66
+ *
61
67
  * @param {Element} containerRefElement The container reference to observe
62
68
  * @param {Function} handleResize The function to call for resize events
69
+ * @param {boolean} useRequestAnimationFrame Whether to pass the handleResize function as a callback to requestAnimationFrame. Pass in false when the function passed in is debounced. Defaults to true.
63
70
  * @return {Function} The function used to unobserve resize events
64
71
  */
65
- const getResizeObserver = (containerRefElement, handleResize) => {
72
+ const getResizeObserver = (containerRefElement, handleResize, useRequestAnimationFrame = true) => {
66
73
  let unobserve;
67
74
  if (util_1.canUseDOM) {
68
75
  const { ResizeObserver } = window;
69
76
  if (containerRefElement && ResizeObserver) {
70
77
  const resizeObserver = new ResizeObserver((entries) => {
71
78
  // Wrap resize function in requestAnimationFrame to avoid "ResizeObserver loop limit exceeded" errors
72
- window.requestAnimationFrame(() => {
79
+ if (useRequestAnimationFrame) {
80
+ window.requestAnimationFrame(() => {
81
+ if (Array.isArray(entries) && entries.length > 0) {
82
+ handleResize();
83
+ }
84
+ });
85
+ // Avoid wrapping function in requestAnimationFrame if the function is debounced
86
+ }
87
+ else {
73
88
  if (Array.isArray(entries) && entries.length > 0) {
74
89
  handleResize();
75
90
  }
76
- });
91
+ }
77
92
  });
78
93
  resizeObserver.observe(containerRefElement);
79
94
  unobserve = () => resizeObserver.unobserve(containerRefElement);
@@ -1 +1 @@
1
- {"version":3,"file":"resizeObserver.js","sourceRoot":"","sources":["../../../src/helpers/resizeObserver.tsx"],"names":[],"mappings":";;;AAAA,iCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACI,MAAM,iBAAiB,GAAG,CAAC,mBAA4B,EAAE,YAAwB,EAAE,EAAE;IAC1F,IAAI,SAAc,CAAC;IAEnB,IAAI,gBAAS,EAAE;QACb,MAAM,EAAE,cAAc,EAAE,GAAG,MAAa,CAAC;QAEzC,IAAI,mBAAmB,IAAI,cAAc,EAAE;YACzC,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,CAAC,OAAY,EAAE,EAAE;gBACzD,qGAAqG;gBACrG,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;o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