@patternfly/react-core 4.168.10 → 4.168.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 +11 -0
- package/dist/esm/components/AboutModal/AboutModal.d.ts +2 -0
- package/dist/esm/components/AboutModal/AboutModal.d.ts.map +1 -1
- package/dist/esm/components/AboutModal/AboutModal.js.map +1 -1
- package/dist/esm/components/AboutModal/AboutModalContainer.d.ts +2 -0
- package/dist/esm/components/AboutModal/AboutModalContainer.d.ts.map +1 -1
- package/dist/esm/components/AboutModal/AboutModalContainer.js +2 -2
- package/dist/esm/components/AboutModal/AboutModalContainer.js.map +1 -1
- package/dist/esm/components/TextInput/TextInput.d.ts +1 -0
- package/dist/esm/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/esm/components/TextInput/TextInput.js +6 -7
- package/dist/esm/components/TextInput/TextInput.js.map +1 -1
- package/dist/esm/helpers/resizeObserver.d.ts +63 -0
- package/dist/esm/helpers/resizeObserver.d.ts.map +1 -0
- package/dist/esm/helpers/resizeObserver.js +89 -0
- package/dist/esm/helpers/resizeObserver.js.map +1 -0
- package/dist/js/components/AboutModal/AboutModal.d.ts +2 -0
- package/dist/js/components/AboutModal/AboutModal.d.ts.map +1 -1
- package/dist/js/components/AboutModal/AboutModal.js.map +1 -1
- package/dist/js/components/AboutModal/AboutModalContainer.d.ts +2 -0
- package/dist/js/components/AboutModal/AboutModalContainer.d.ts.map +1 -1
- package/dist/js/components/AboutModal/AboutModalContainer.js +2 -2
- package/dist/js/components/AboutModal/AboutModalContainer.js.map +1 -1
- package/dist/js/components/TextInput/TextInput.d.ts +1 -0
- package/dist/js/components/TextInput/TextInput.d.ts.map +1 -1
- package/dist/js/components/TextInput/TextInput.js +5 -6
- package/dist/js/components/TextInput/TextInput.js.map +1 -1
- package/dist/js/helpers/resizeObserver.d.ts +63 -0
- package/dist/js/helpers/resizeObserver.d.ts.map +1 -0
- package/dist/js/helpers/resizeObserver.js +93 -0
- package/dist/js/helpers/resizeObserver.js.map +1 -0
- package/dist/umd/react-core.js +94 -8
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +5 -5
- package/src/components/AboutModal/AboutModal.tsx +2 -0
- package/src/components/AboutModal/AboutModalContainer.tsx +8 -1
- package/src/components/TextInput/TextInput.tsx +6 -7
- package/src/helpers/resizeObserver.tsx +91 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getResizeObserver = void 0;
|
|
4
|
+
const util_1 = require("./util");
|
|
5
|
+
/**
|
|
6
|
+
* This function creates a ResizeObserver used to handle resize events for the given containerRef. If ResizeObserver
|
|
7
|
+
* or the given containerRef are not available, a window resize event listener is used by default.
|
|
8
|
+
*
|
|
9
|
+
* Example 1:
|
|
10
|
+
*
|
|
11
|
+
* private containerRef = React.createRef<HTMLDivElement>();
|
|
12
|
+
* private observer: any = () => {};
|
|
13
|
+
*
|
|
14
|
+
* public componentDidMount() {
|
|
15
|
+
* this.observer = getResizeObserver(this.containerRef.current, this.handleResize);
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* public componentWillUnmount() {
|
|
19
|
+
* this.observer();
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* private handleResize = () => {
|
|
23
|
+
* if (this.containerRef.current && this.containerRef.current.clientWidth) {
|
|
24
|
+
* this.setState({ width: this.containerRef.current.clientWidth });
|
|
25
|
+
* }
|
|
26
|
+
* };
|
|
27
|
+
*
|
|
28
|
+
* public render() {
|
|
29
|
+
* return (
|
|
30
|
+
* <div ref={this.containerRef} >
|
|
31
|
+
* <Chart width={this.state.width} ... />
|
|
32
|
+
* </div>
|
|
33
|
+
* );
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* Example 2:
|
|
37
|
+
*
|
|
38
|
+
* private inputRef = React.createRef<HTMLInputElement>();
|
|
39
|
+
* private observer: any = () => {};
|
|
40
|
+
*
|
|
41
|
+
* public componentDidMount() {
|
|
42
|
+
* this.observer = getResizeObserver(this.inputRef.current, this.handleResize);
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* public componentWillUnmount() {
|
|
46
|
+
* this.observer();
|
|
47
|
+
* }
|
|
48
|
+
*
|
|
49
|
+
* private handleResize = () => {
|
|
50
|
+
* if (this.inputRef.current) {
|
|
51
|
+
* trimLeft(inputRef.current, String(this.props.value));
|
|
52
|
+
* }
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* public render() {
|
|
56
|
+
* return (
|
|
57
|
+
* <input ref={this.inputRef} ... />
|
|
58
|
+
* );
|
|
59
|
+
* }
|
|
60
|
+
*
|
|
61
|
+
* @param {React.RefObject} containerRef The container reference to observe
|
|
62
|
+
* @param {Function} handleResize The function to call for resize events
|
|
63
|
+
* @return {Function} The function used to unobserve resize events
|
|
64
|
+
*/
|
|
65
|
+
const getResizeObserver = (containerRef, handleResize) => {
|
|
66
|
+
let unobserve;
|
|
67
|
+
if (util_1.canUseDOM) {
|
|
68
|
+
const { ResizeObserver } = window;
|
|
69
|
+
if (containerRef && ResizeObserver) {
|
|
70
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
71
|
+
// Wrap resize function in requestAnimationFrame to avoid "ResizeObserver loop limit exceeded" errors
|
|
72
|
+
window.requestAnimationFrame(() => {
|
|
73
|
+
if (Array.isArray(entries) && entries.length > 0) {
|
|
74
|
+
handleResize();
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
resizeObserver.observe(containerRef);
|
|
79
|
+
unobserve = () => resizeObserver.unobserve(containerRef);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
window.addEventListener('resize', handleResize);
|
|
83
|
+
unobserve = () => window.removeEventListener('resize', handleResize);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return () => {
|
|
87
|
+
if (unobserve) {
|
|
88
|
+
unobserve();
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
exports.getResizeObserver = getResizeObserver;
|
|
93
|
+
//# sourceMappingURL=resizeObserver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resizeObserver.js","sourceRoot":"","sources":["../../../src/helpers/resizeObserver.tsx"],"names":[],"mappings":";;;AACA,iCAAmC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACI,MAAM,iBAAiB,GAAG,CAAC,YAAkC,EAAE,YAAwB,EAAE,EAAE;IAChG,IAAI,SAAc,CAAC;IAEnB,IAAI,gBAAS,EAAE;QACb,MAAM,EAAE,cAAc,EAAE,GAAG,MAAa,CAAC;QAEzC,IAAI,YAAY,IAAI,cAAc,EAAE;YAClC,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,CAAC,OAAY,EAAE,EAAE;gBACzD,qGAAqG;gBACrG,MAAM,CAAC,qBAAqB,CAAC,GAAG,EAAE;oBAChC,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;wBAChD,YAAY,EAAE,CAAC;qBAChB;gBACH,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;YACrC,SAAS,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;SAC1D;aAAM;YACL,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;YAChD,SAAS,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;SACtE;KACF;IACD,OAAO,GAAG,EAAE;QACV,IAAI,SAAS,EAAE;YACb,SAAS,EAAE,CAAC;SACb;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AA3BW,QAAA,iBAAiB,qBA2B5B"}
|
package/dist/umd/react-core.js
CHANGED
|
@@ -3637,12 +3637,12 @@
|
|
|
3637
3637
|
Backdrop.displayName = 'Backdrop';
|
|
3638
3638
|
|
|
3639
3639
|
const AboutModalContainer = (_a) => {
|
|
3640
|
-
var { children, className = '', isOpen = false, onClose = () => undefined, productName = '', trademark, brandImageSrc, brandImageAlt, backgroundImageSrc, closeButtonAriaLabel, aboutModalBoxHeaderId, aboutModalBoxContentId } = _a, props = __rest$1(_a, ["children", "className", "isOpen", "onClose", "productName", "trademark", "brandImageSrc", "brandImageAlt", "backgroundImageSrc", "closeButtonAriaLabel", "aboutModalBoxHeaderId", "aboutModalBoxContentId"]);
|
|
3640
|
+
var { children, className = '', isOpen = false, onClose = () => undefined, productName = '', trademark, brandImageSrc, brandImageAlt, backgroundImageSrc, closeButtonAriaLabel, aboutModalBoxHeaderId, aboutModalBoxContentId, disableFocusTrap = false } = _a, props = __rest$1(_a, ["children", "className", "isOpen", "onClose", "productName", "trademark", "brandImageSrc", "brandImageAlt", "backgroundImageSrc", "closeButtonAriaLabel", "aboutModalBoxHeaderId", "aboutModalBoxContentId", "disableFocusTrap"]);
|
|
3641
3641
|
if (!isOpen) {
|
|
3642
3642
|
return null;
|
|
3643
3643
|
}
|
|
3644
3644
|
return (React__namespace.createElement(Backdrop, null,
|
|
3645
|
-
React__namespace.createElement(FocusTrap, { focusTrapOptions: { clickOutsideDeactivates: true }, className: css(_default$1n.bullseye) },
|
|
3645
|
+
React__namespace.createElement(FocusTrap, { active: !disableFocusTrap, focusTrapOptions: { clickOutsideDeactivates: true }, className: css(_default$1n.bullseye) },
|
|
3646
3646
|
React__namespace.createElement(AboutModalBox, { className: className, "aria-labelledby": aboutModalBoxHeaderId, "aria-describedby": aboutModalBoxContentId },
|
|
3647
3647
|
React__namespace.createElement(AboutModalBoxBrand, { src: brandImageSrc, alt: brandImageAlt }),
|
|
3648
3648
|
React__namespace.createElement(AboutModalBoxCloseButton, { "aria-label": closeButtonAriaLabel, onClose: onClose }),
|
|
@@ -5604,6 +5604,94 @@
|
|
|
5604
5604
|
};
|
|
5605
5605
|
BreadcrumbHeading.displayName = 'BreadcrumbHeading';
|
|
5606
5606
|
|
|
5607
|
+
/**
|
|
5608
|
+
* This function creates a ResizeObserver used to handle resize events for the given containerRef. If ResizeObserver
|
|
5609
|
+
* or the given containerRef are not available, a window resize event listener is used by default.
|
|
5610
|
+
*
|
|
5611
|
+
* Example 1:
|
|
5612
|
+
*
|
|
5613
|
+
* private containerRef = React.createRef<HTMLDivElement>();
|
|
5614
|
+
* private observer: any = () => {};
|
|
5615
|
+
*
|
|
5616
|
+
* public componentDidMount() {
|
|
5617
|
+
* this.observer = getResizeObserver(this.containerRef.current, this.handleResize);
|
|
5618
|
+
* }
|
|
5619
|
+
*
|
|
5620
|
+
* public componentWillUnmount() {
|
|
5621
|
+
* this.observer();
|
|
5622
|
+
* }
|
|
5623
|
+
*
|
|
5624
|
+
* private handleResize = () => {
|
|
5625
|
+
* if (this.containerRef.current && this.containerRef.current.clientWidth) {
|
|
5626
|
+
* this.setState({ width: this.containerRef.current.clientWidth });
|
|
5627
|
+
* }
|
|
5628
|
+
* };
|
|
5629
|
+
*
|
|
5630
|
+
* public render() {
|
|
5631
|
+
* return (
|
|
5632
|
+
* <div ref={this.containerRef} >
|
|
5633
|
+
* <Chart width={this.state.width} ... />
|
|
5634
|
+
* </div>
|
|
5635
|
+
* );
|
|
5636
|
+
* }
|
|
5637
|
+
*
|
|
5638
|
+
* Example 2:
|
|
5639
|
+
*
|
|
5640
|
+
* private inputRef = React.createRef<HTMLInputElement>();
|
|
5641
|
+
* private observer: any = () => {};
|
|
5642
|
+
*
|
|
5643
|
+
* public componentDidMount() {
|
|
5644
|
+
* this.observer = getResizeObserver(this.inputRef.current, this.handleResize);
|
|
5645
|
+
* }
|
|
5646
|
+
*
|
|
5647
|
+
* public componentWillUnmount() {
|
|
5648
|
+
* this.observer();
|
|
5649
|
+
* }
|
|
5650
|
+
*
|
|
5651
|
+
* private handleResize = () => {
|
|
5652
|
+
* if (this.inputRef.current) {
|
|
5653
|
+
* trimLeft(inputRef.current, String(this.props.value));
|
|
5654
|
+
* }
|
|
5655
|
+
* };
|
|
5656
|
+
*
|
|
5657
|
+
* public render() {
|
|
5658
|
+
* return (
|
|
5659
|
+
* <input ref={this.inputRef} ... />
|
|
5660
|
+
* );
|
|
5661
|
+
* }
|
|
5662
|
+
*
|
|
5663
|
+
* @param {React.RefObject} containerRef The container reference to observe
|
|
5664
|
+
* @param {Function} handleResize The function to call for resize events
|
|
5665
|
+
* @return {Function} The function used to unobserve resize events
|
|
5666
|
+
*/
|
|
5667
|
+
const getResizeObserver = (containerRef, handleResize) => {
|
|
5668
|
+
let unobserve;
|
|
5669
|
+
if (canUseDOM) {
|
|
5670
|
+
const { ResizeObserver } = window;
|
|
5671
|
+
if (containerRef && ResizeObserver) {
|
|
5672
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
5673
|
+
// Wrap resize function in requestAnimationFrame to avoid "ResizeObserver loop limit exceeded" errors
|
|
5674
|
+
window.requestAnimationFrame(() => {
|
|
5675
|
+
if (Array.isArray(entries) && entries.length > 0) {
|
|
5676
|
+
handleResize();
|
|
5677
|
+
}
|
|
5678
|
+
});
|
|
5679
|
+
});
|
|
5680
|
+
resizeObserver.observe(containerRef);
|
|
5681
|
+
unobserve = () => resizeObserver.unobserve(containerRef);
|
|
5682
|
+
}
|
|
5683
|
+
else {
|
|
5684
|
+
window.addEventListener('resize', handleResize);
|
|
5685
|
+
unobserve = () => window.removeEventListener('resize', handleResize);
|
|
5686
|
+
}
|
|
5687
|
+
}
|
|
5688
|
+
return () => {
|
|
5689
|
+
if (unobserve) {
|
|
5690
|
+
unobserve();
|
|
5691
|
+
}
|
|
5692
|
+
};
|
|
5693
|
+
};
|
|
5694
|
+
|
|
5607
5695
|
exports.TextInputTypes = void 0;
|
|
5608
5696
|
(function (TextInputTypes) {
|
|
5609
5697
|
TextInputTypes["text"] = "text";
|
|
@@ -5622,6 +5710,7 @@
|
|
|
5622
5710
|
constructor(props) {
|
|
5623
5711
|
super(props);
|
|
5624
5712
|
this.inputRef = React__namespace.createRef();
|
|
5713
|
+
this.observer = () => { };
|
|
5625
5714
|
this.handleChange = (event) => {
|
|
5626
5715
|
if (this.props.onChange) {
|
|
5627
5716
|
this.props.onChange(event.currentTarget.value, event);
|
|
@@ -5664,17 +5753,14 @@
|
|
|
5664
5753
|
}
|
|
5665
5754
|
componentDidMount() {
|
|
5666
5755
|
if (this.props.isLeftTruncated) {
|
|
5756
|
+
const inputRef = this.props.innerRef || this.inputRef;
|
|
5757
|
+
this.observer = getResizeObserver(inputRef.current, this.handleResize);
|
|
5667
5758
|
this.handleResize();
|
|
5668
|
-
if (canUseDOM) {
|
|
5669
|
-
window.addEventListener('resize', debounce$1(this.handleResize, 250));
|
|
5670
|
-
}
|
|
5671
5759
|
}
|
|
5672
5760
|
}
|
|
5673
5761
|
componentWillUnmount() {
|
|
5674
5762
|
if (this.props.isLeftTruncated) {
|
|
5675
|
-
|
|
5676
|
-
window.removeEventListener('resize', debounce$1(this.handleResize, 250));
|
|
5677
|
-
}
|
|
5763
|
+
this.observer();
|
|
5678
5764
|
}
|
|
5679
5765
|
}
|
|
5680
5766
|
render() {
|