@patternfly/react-core 4.168.10 → 4.169.2
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 +41 -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/Popover/Popover.d.ts +2 -0
- package/dist/esm/components/Popover/Popover.d.ts.map +1 -1
- package/dist/esm/components/Popover/Popover.js +5 -3
- package/dist/esm/components/Popover/Popover.js.map +1 -1
- package/dist/esm/components/Popover/PopoverContext.d.ts +7 -0
- package/dist/esm/components/Popover/PopoverContext.d.ts.map +1 -0
- package/dist/esm/components/Popover/PopoverContext.js +3 -0
- package/dist/esm/components/Popover/PopoverContext.js.map +1 -0
- package/dist/esm/components/Popover/PopoverHeader.d.ts.map +1 -1
- package/dist/esm/components/Popover/PopoverHeader.js +2 -1
- package/dist/esm/components/Popover/PopoverHeader.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/index.d.ts +1 -0
- package/dist/esm/helpers/index.d.ts.map +1 -1
- package/dist/esm/helpers/index.js +1 -0
- package/dist/esm/helpers/index.js.map +1 -1
- package/dist/esm/helpers/resizeObserver.d.ts +62 -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/Popover/Popover.d.ts +2 -0
- package/dist/js/components/Popover/Popover.d.ts.map +1 -1
- package/dist/js/components/Popover/Popover.js +5 -3
- package/dist/js/components/Popover/Popover.js.map +1 -1
- package/dist/js/components/Popover/PopoverContext.d.ts +7 -0
- package/dist/js/components/Popover/PopoverContext.d.ts.map +1 -0
- package/dist/js/components/Popover/PopoverContext.js +7 -0
- package/dist/js/components/Popover/PopoverContext.js.map +1 -0
- package/dist/js/components/Popover/PopoverHeader.d.ts.map +1 -1
- package/dist/js/components/Popover/PopoverHeader.js +2 -1
- package/dist/js/components/Popover/PopoverHeader.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/index.d.ts +1 -0
- package/dist/js/helpers/index.d.ts.map +1 -1
- package/dist/js/helpers/index.js +1 -0
- package/dist/js/helpers/index.js.map +1 -1
- package/dist/js/helpers/resizeObserver.d.ts +62 -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 +102 -12
- 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/Popover/Popover.tsx +24 -18
- package/src/components/Popover/PopoverContext.tsx +7 -0
- package/src/components/Popover/PopoverHeader.tsx +8 -3
- package/src/components/Popover/__tests__/Generated/__snapshots__/Popover.test.tsx.snap +91 -83
- package/src/components/Popover/__tests__/Generated/__snapshots__/PopoverHeader.test.tsx.snap +3 -9
- package/src/components/Popover/__tests__/__snapshots__/Popover.test.tsx.snap +406 -374
- package/src/components/TextInput/TextInput.tsx +6 -7
- package/src/helpers/index.ts +1 -0
- package/src/helpers/resizeObserver.tsx +90 -0
package/dist/umd/react-core.js
CHANGED
|
@@ -3308,6 +3308,94 @@
|
|
|
3308
3308
|
noSpaceHandling: false
|
|
3309
3309
|
};
|
|
3310
3310
|
|
|
3311
|
+
/**
|
|
3312
|
+
* This function creates a ResizeObserver used to handle resize events for the given containerRef. If ResizeObserver
|
|
3313
|
+
* or the given containerRef are not available, a window resize event listener is used by default.
|
|
3314
|
+
*
|
|
3315
|
+
* Example 1:
|
|
3316
|
+
*
|
|
3317
|
+
* private containerRef = React.createRef<HTMLDivElement>();
|
|
3318
|
+
* private observer: any = () => {};
|
|
3319
|
+
*
|
|
3320
|
+
* public componentDidMount() {
|
|
3321
|
+
* this.observer = getResizeObserver(this.containerRef.current, this.handleResize);
|
|
3322
|
+
* }
|
|
3323
|
+
*
|
|
3324
|
+
* public componentWillUnmount() {
|
|
3325
|
+
* this.observer();
|
|
3326
|
+
* }
|
|
3327
|
+
*
|
|
3328
|
+
* private handleResize = () => {
|
|
3329
|
+
* if (this.containerRef.current && this.containerRef.current.clientWidth) {
|
|
3330
|
+
* this.setState({ width: this.containerRef.current.clientWidth });
|
|
3331
|
+
* }
|
|
3332
|
+
* };
|
|
3333
|
+
*
|
|
3334
|
+
* public render() {
|
|
3335
|
+
* return (
|
|
3336
|
+
* <div ref={this.containerRef} >
|
|
3337
|
+
* <Chart width={this.state.width} ... />
|
|
3338
|
+
* </div>
|
|
3339
|
+
* );
|
|
3340
|
+
* }
|
|
3341
|
+
*
|
|
3342
|
+
* Example 2:
|
|
3343
|
+
*
|
|
3344
|
+
* private inputRef = React.createRef<HTMLInputElement>();
|
|
3345
|
+
* private observer: any = () => {};
|
|
3346
|
+
*
|
|
3347
|
+
* public componentDidMount() {
|
|
3348
|
+
* this.observer = getResizeObserver(this.inputRef.current, this.handleResize);
|
|
3349
|
+
* }
|
|
3350
|
+
*
|
|
3351
|
+
* public componentWillUnmount() {
|
|
3352
|
+
* this.observer();
|
|
3353
|
+
* }
|
|
3354
|
+
*
|
|
3355
|
+
* private handleResize = () => {
|
|
3356
|
+
* if (this.inputRef.current) {
|
|
3357
|
+
* trimLeft(inputRef.current, String(this.props.value));
|
|
3358
|
+
* }
|
|
3359
|
+
* };
|
|
3360
|
+
*
|
|
3361
|
+
* public render() {
|
|
3362
|
+
* return (
|
|
3363
|
+
* <input ref={this.inputRef} ... />
|
|
3364
|
+
* );
|
|
3365
|
+
* }
|
|
3366
|
+
*
|
|
3367
|
+
* @param {Element} containerRefElement The container reference to observe
|
|
3368
|
+
* @param {Function} handleResize The function to call for resize events
|
|
3369
|
+
* @return {Function} The function used to unobserve resize events
|
|
3370
|
+
*/
|
|
3371
|
+
const getResizeObserver = (containerRefElement, handleResize) => {
|
|
3372
|
+
let unobserve;
|
|
3373
|
+
if (canUseDOM) {
|
|
3374
|
+
const { ResizeObserver } = window;
|
|
3375
|
+
if (containerRefElement && ResizeObserver) {
|
|
3376
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
3377
|
+
// Wrap resize function in requestAnimationFrame to avoid "ResizeObserver loop limit exceeded" errors
|
|
3378
|
+
window.requestAnimationFrame(() => {
|
|
3379
|
+
if (Array.isArray(entries) && entries.length > 0) {
|
|
3380
|
+
handleResize();
|
|
3381
|
+
}
|
|
3382
|
+
});
|
|
3383
|
+
});
|
|
3384
|
+
resizeObserver.observe(containerRefElement);
|
|
3385
|
+
unobserve = () => resizeObserver.unobserve(containerRefElement);
|
|
3386
|
+
}
|
|
3387
|
+
else {
|
|
3388
|
+
window.addEventListener('resize', handleResize);
|
|
3389
|
+
unobserve = () => window.removeEventListener('resize', handleResize);
|
|
3390
|
+
}
|
|
3391
|
+
}
|
|
3392
|
+
return () => {
|
|
3393
|
+
if (unobserve) {
|
|
3394
|
+
unobserve();
|
|
3395
|
+
}
|
|
3396
|
+
};
|
|
3397
|
+
};
|
|
3398
|
+
|
|
3311
3399
|
var _default$1n = {
|
|
3312
3400
|
"bullseye": "pf-l-bullseye"
|
|
3313
3401
|
};
|
|
@@ -3637,12 +3725,12 @@
|
|
|
3637
3725
|
Backdrop.displayName = 'Backdrop';
|
|
3638
3726
|
|
|
3639
3727
|
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"]);
|
|
3728
|
+
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
3729
|
if (!isOpen) {
|
|
3642
3730
|
return null;
|
|
3643
3731
|
}
|
|
3644
3732
|
return (React__namespace.createElement(Backdrop, null,
|
|
3645
|
-
React__namespace.createElement(FocusTrap, { focusTrapOptions: { clickOutsideDeactivates: true }, className: css(_default$1n.bullseye) },
|
|
3733
|
+
React__namespace.createElement(FocusTrap, { active: !disableFocusTrap, focusTrapOptions: { clickOutsideDeactivates: true }, className: css(_default$1n.bullseye) },
|
|
3646
3734
|
React__namespace.createElement(AboutModalBox, { className: className, "aria-labelledby": aboutModalBoxHeaderId, "aria-describedby": aboutModalBoxContentId },
|
|
3647
3735
|
React__namespace.createElement(AboutModalBoxBrand, { src: brandImageSrc, alt: brandImageAlt }),
|
|
3648
3736
|
React__namespace.createElement(AboutModalBoxCloseButton, { "aria-label": closeButtonAriaLabel, onClose: onClose }),
|
|
@@ -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() {
|
|
@@ -8777,6 +8863,8 @@
|
|
|
8777
8863
|
"title": "pf-c-title"
|
|
8778
8864
|
};
|
|
8779
8865
|
|
|
8866
|
+
const PopoverContext = React__namespace.createContext({});
|
|
8867
|
+
|
|
8780
8868
|
const PopoverContent = (_a) => {
|
|
8781
8869
|
var { className = null, children } = _a, props = __rest$1(_a, ["className", "children"]);
|
|
8782
8870
|
return (React__namespace.createElement("div", Object.assign({ className: css(_default$P.popoverContent, className) }, props), children));
|
|
@@ -8791,7 +8879,7 @@
|
|
|
8791
8879
|
|
|
8792
8880
|
const PopoverHeader = (_a) => {
|
|
8793
8881
|
var { children, id } = _a, props = __rest$1(_a, ["children", "id"]);
|
|
8794
|
-
return (React__namespace.createElement(Title, Object.assign({ headingLevel:
|
|
8882
|
+
return (React__namespace.createElement(PopoverContext.Consumer, null, ({ headerComponent }) => (React__namespace.createElement(Title, Object.assign({ headingLevel: headerComponent, size: exports.TitleSizes.md, id: id }, props), children))));
|
|
8795
8883
|
};
|
|
8796
8884
|
PopoverHeader.displayName = 'PopoverHeader';
|
|
8797
8885
|
|
|
@@ -8853,9 +8941,9 @@
|
|
|
8853
8941
|
PopoverPosition["rightEnd"] = "right-end";
|
|
8854
8942
|
})(exports.PopoverPosition || (exports.PopoverPosition = {}));
|
|
8855
8943
|
const Popover = (_a) => {
|
|
8856
|
-
var { children, position = 'top', enableFlip = true, className = '', isVisible = null, shouldClose = () => null, shouldOpen = () => null, 'aria-label': ariaLabel = '', bodyContent, headerContent = null, footerContent = null, appendTo = () => document.body, hideOnOutsideClick = true, onHide = () => null, onHidden = () => null, onShow = () => null, onShown = () => null, onMount = () => null, zIndex = 9999, minWidth = popoverMinWidth && popoverMinWidth.value, maxWidth = popoverMaxWidth && popoverMaxWidth.value, closeBtnAriaLabel = 'Close', showClose = true, distance = 25,
|
|
8944
|
+
var { children, position = 'top', enableFlip = true, className = '', isVisible = null, shouldClose = () => null, shouldOpen = () => null, 'aria-label': ariaLabel = '', bodyContent, headerContent = null, headerComponent = 'h6', footerContent = null, appendTo = () => document.body, hideOnOutsideClick = true, onHide = () => null, onHidden = () => null, onShow = () => null, onShown = () => null, onMount = () => null, zIndex = 9999, minWidth = popoverMinWidth && popoverMinWidth.value, maxWidth = popoverMaxWidth && popoverMaxWidth.value, closeBtnAriaLabel = 'Close', showClose = true, distance = 25,
|
|
8857
8945
|
// For every initial starting position, there are 3 escape positions
|
|
8858
|
-
flipBehavior = ['top', 'right', 'bottom', 'left', 'top', 'right', 'bottom'], animationDuration = 300, id, withFocusTrap: propWithFocusTrap, boundary, tippyProps, reference, hasNoPadding = false, hasAutoWidth = false } = _a, rest = __rest$1(_a, ["children", "position", "enableFlip", "className", "isVisible", "shouldClose", "shouldOpen", 'aria-label', "bodyContent", "headerContent", "footerContent", "appendTo", "hideOnOutsideClick", "onHide", "onHidden", "onShow", "onShown", "onMount", "zIndex", "minWidth", "maxWidth", "closeBtnAriaLabel", "showClose", "distance", "flipBehavior", "animationDuration", "id", "withFocusTrap", "boundary", "tippyProps", "reference", "hasNoPadding", "hasAutoWidth"]);
|
|
8946
|
+
flipBehavior = ['top', 'right', 'bottom', 'left', 'top', 'right', 'bottom'], animationDuration = 300, id, withFocusTrap: propWithFocusTrap, boundary, tippyProps, reference, hasNoPadding = false, hasAutoWidth = false } = _a, rest = __rest$1(_a, ["children", "position", "enableFlip", "className", "isVisible", "shouldClose", "shouldOpen", 'aria-label', "bodyContent", "headerContent", "headerComponent", "footerContent", "appendTo", "hideOnOutsideClick", "onHide", "onHidden", "onShow", "onShown", "onMount", "zIndex", "minWidth", "maxWidth", "closeBtnAriaLabel", "showClose", "distance", "flipBehavior", "animationDuration", "id", "withFocusTrap", "boundary", "tippyProps", "reference", "hasNoPadding", "hasAutoWidth"]);
|
|
8859
8947
|
{
|
|
8860
8948
|
boundary !== undefined &&
|
|
8861
8949
|
console.warn('The Popover boundary prop has been deprecated. If you want to constrain the popper to a specific element use the appendTo prop instead.');
|
|
@@ -9033,7 +9121,8 @@
|
|
|
9033
9121
|
headerContent && (React__namespace.createElement(PopoverHeader, { id: `popover-${uniqueId}-header` }, typeof headerContent === 'function' ? headerContent(hide) : headerContent)),
|
|
9034
9122
|
React__namespace.createElement(PopoverBody, { id: `popover-${uniqueId}-body` }, typeof bodyContent === 'function' ? bodyContent(hide) : bodyContent),
|
|
9035
9123
|
footerContent && (React__namespace.createElement(PopoverFooter, { id: `popover-${uniqueId}-footer` }, typeof footerContent === 'function' ? footerContent(hide) : footerContent)))));
|
|
9036
|
-
return (React__namespace.createElement(
|
|
9124
|
+
return (React__namespace.createElement(PopoverContext.Provider, { value: { headerComponent } },
|
|
9125
|
+
React__namespace.createElement(Popper, { trigger: children, reference: reference, popper: content, popperMatchesTriggerWidth: false, appendTo: appendTo, isVisible: visible, positionModifiers: positionModifiers, distance: distance, placement: position, onTriggerClick: onTriggerClick, onTriggerEnter: onTriggerEnter, onDocumentClick: onDocumentClick, onDocumentKeyDown: onDocumentKeyDown, enableFlip: enableFlip, zIndex: zIndex, flipBehavior: flipBehavior })));
|
|
9037
9126
|
};
|
|
9038
9127
|
Popover.displayName = 'Popover';
|
|
9039
9128
|
|
|
@@ -20664,6 +20753,7 @@
|
|
|
20664
20753
|
exports.getNextIndex = getNextIndex;
|
|
20665
20754
|
exports.getOUIAProps = getOUIAProps;
|
|
20666
20755
|
exports.getOpacityTransition = getOpacityTransition;
|
|
20756
|
+
exports.getResizeObserver = getResizeObserver;
|
|
20667
20757
|
exports.getTextWidth = getTextWidth;
|
|
20668
20758
|
exports.getUniqueId = getUniqueId;
|
|
20669
20759
|
exports.globalBreakpoints = globalBreakpoints;
|