@patternfly/react-table 4.37.10 → 4.37.11

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,17 @@
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.37.11 (2021-11-01)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **AboutModal:** allow to disable FocusTrap ([#6509](https://github.com/patternfly/patternfly-react/issues/6509)) ([72536e1](https://github.com/patternfly/patternfly-react/commit/72536e1f73641ff3f19f865f08dbb41ad0ee7b9f))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 4.37.10 (2021-10-29)
7
18
 
8
19
 
@@ -4441,6 +4441,94 @@
4441
4441
  }));
4442
4442
  };
4443
4443
 
4444
+ /**
4445
+ * This function creates a ResizeObserver used to handle resize events for the given containerRef. If ResizeObserver
4446
+ * or the given containerRef are not available, a window resize event listener is used by default.
4447
+ *
4448
+ * Example 1:
4449
+ *
4450
+ * private containerRef = React.createRef<HTMLDivElement>();
4451
+ * private observer: any = () => {};
4452
+ *
4453
+ * public componentDidMount() {
4454
+ * this.observer = getResizeObserver(this.containerRef.current, this.handleResize);
4455
+ * }
4456
+ *
4457
+ * public componentWillUnmount() {
4458
+ * this.observer();
4459
+ * }
4460
+ *
4461
+ * private handleResize = () => {
4462
+ * if (this.containerRef.current && this.containerRef.current.clientWidth) {
4463
+ * this.setState({ width: this.containerRef.current.clientWidth });
4464
+ * }
4465
+ * };
4466
+ *
4467
+ * public render() {
4468
+ * return (
4469
+ * <div ref={this.containerRef} >
4470
+ * <Chart width={this.state.width} ... />
4471
+ * </div>
4472
+ * );
4473
+ * }
4474
+ *
4475
+ * Example 2:
4476
+ *
4477
+ * private inputRef = React.createRef<HTMLInputElement>();
4478
+ * private observer: any = () => {};
4479
+ *
4480
+ * public componentDidMount() {
4481
+ * this.observer = getResizeObserver(this.inputRef.current, this.handleResize);
4482
+ * }
4483
+ *
4484
+ * public componentWillUnmount() {
4485
+ * this.observer();
4486
+ * }
4487
+ *
4488
+ * private handleResize = () => {
4489
+ * if (this.inputRef.current) {
4490
+ * trimLeft(inputRef.current, String(this.props.value));
4491
+ * }
4492
+ * };
4493
+ *
4494
+ * public render() {
4495
+ * return (
4496
+ * <input ref={this.inputRef} ... />
4497
+ * );
4498
+ * }
4499
+ *
4500
+ * @param {React.RefObject} containerRef The container reference to observe
4501
+ * @param {Function} handleResize The function to call for resize events
4502
+ * @return {Function} The function used to unobserve resize events
4503
+ */
4504
+ const getResizeObserver = (containerRef, handleResize) => {
4505
+ let unobserve;
4506
+ if (canUseDOM) {
4507
+ const { ResizeObserver } = window;
4508
+ if (containerRef && ResizeObserver) {
4509
+ const resizeObserver = new ResizeObserver((entries) => {
4510
+ // Wrap resize function in requestAnimationFrame to avoid "ResizeObserver loop limit exceeded" errors
4511
+ window.requestAnimationFrame(() => {
4512
+ if (Array.isArray(entries) && entries.length > 0) {
4513
+ handleResize();
4514
+ }
4515
+ });
4516
+ });
4517
+ resizeObserver.observe(containerRef);
4518
+ unobserve = () => resizeObserver.unobserve(containerRef);
4519
+ }
4520
+ else {
4521
+ window.addEventListener('resize', handleResize);
4522
+ unobserve = () => window.removeEventListener('resize', handleResize);
4523
+ }
4524
+ }
4525
+ return () => {
4526
+ if (unobserve) {
4527
+ unobserve();
4528
+ }
4529
+ };
4530
+ };
4531
+
4444
4532
  var TextInputTypes;
4445
4533
  (function (TextInputTypes) {
4446
4534
  TextInputTypes["text"] = "text";
@@ -4459,6 +4547,7 @@
4459
4547
  constructor(props) {
4460
4548
  super(props);
4461
4549
  this.inputRef = React__namespace.createRef();
4550
+ this.observer = () => { };
4462
4551
  this.handleChange = (event) => {
4463
4552
  if (this.props.onChange) {
4464
4553
  this.props.onChange(event.currentTarget.value, event);
@@ -4501,17 +4590,14 @@
4501
4590
  }
4502
4591
  componentDidMount() {
4503
4592
  if (this.props.isLeftTruncated) {
4593
+ const inputRef = this.props.innerRef || this.inputRef;
4594
+ this.observer = getResizeObserver(inputRef.current, this.handleResize);
4504
4595
  this.handleResize();
4505
- if (canUseDOM) {
4506
- window.addEventListener('resize', debounce$1(this.handleResize, 250));
4507
- }
4508
4596
  }
4509
4597
  }
4510
4598
  componentWillUnmount() {
4511
4599
  if (this.props.isLeftTruncated) {
4512
- if (canUseDOM) {
4513
- window.removeEventListener('resize', debounce$1(this.handleResize, 250));
4514
- }
4600
+ this.observer();
4515
4601
  }
4516
4602
  }
4517
4603
  render() {