@patternfly/react-core 4.168.9 → 4.169.1
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 +44 -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/Banner/Banner.d.ts +1 -1
- package/dist/esm/components/Banner/Banner.d.ts.map +1 -1
- package/dist/esm/components/Banner/Banner.js +5 -1
- package/dist/esm/components/Banner/Banner.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownGroup.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownGroup.js +10 -6
- package/dist/esm/components/Dropdown/DropdownGroup.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/Banner/Banner.d.ts +1 -1
- package/dist/js/components/Banner/Banner.d.ts.map +1 -1
- package/dist/js/components/Banner/Banner.js +4 -1
- package/dist/js/components/Banner/Banner.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownGroup.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownGroup.js +9 -6
- package/dist/js/components/Dropdown/DropdownGroup.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 +108 -15
- 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/Banner/Banner.tsx +4 -2
- package/src/components/Banner/__tests__/__snapshots__/Banner.test.tsx.snap +6 -0
- package/src/components/Dropdown/DropdownGroup.tsx +3 -2
- package/src/components/TextInput/TextInput.tsx +6 -7
- package/src/helpers/index.ts +1 -0
- package/src/helpers/resizeObserver.tsx +90 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.169.1",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.
|
|
38
|
-
"@patternfly/react-styles": "^4.
|
|
39
|
-
"@patternfly/react-tokens": "^4.
|
|
37
|
+
"@patternfly/react-icons": "^4.20.1",
|
|
38
|
+
"@patternfly/react-styles": "^4.19.1",
|
|
39
|
+
"@patternfly/react-tokens": "^4.21.1",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "ee4fbe6fc666c104911264204b14215dd6aefc08"
|
|
64
64
|
}
|
|
@@ -32,6 +32,8 @@ export interface AboutModalProps {
|
|
|
32
32
|
appendTo?: HTMLElement | (() => HTMLElement);
|
|
33
33
|
/** Set aria label to the close button */
|
|
34
34
|
closeButtonAriaLabel?: string;
|
|
35
|
+
/** Flag to disable focus trap */
|
|
36
|
+
disableFocusTrap?: boolean;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
interface ModalState {
|
|
@@ -36,6 +36,8 @@ export interface AboutModalContainerProps extends React.HTMLProps<HTMLDivElement
|
|
|
36
36
|
aboutModalBoxContentId: string;
|
|
37
37
|
/** Set close button aria label */
|
|
38
38
|
closeButtonAriaLabel?: string;
|
|
39
|
+
/** Flag to disable focus trap */
|
|
40
|
+
disableFocusTrap?: boolean;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
export const AboutModalContainer: React.FunctionComponent<AboutModalContainerProps> = ({
|
|
@@ -51,6 +53,7 @@ export const AboutModalContainer: React.FunctionComponent<AboutModalContainerPro
|
|
|
51
53
|
closeButtonAriaLabel,
|
|
52
54
|
aboutModalBoxHeaderId,
|
|
53
55
|
aboutModalBoxContentId,
|
|
56
|
+
disableFocusTrap = false,
|
|
54
57
|
...props
|
|
55
58
|
}: AboutModalContainerProps) => {
|
|
56
59
|
if (!isOpen) {
|
|
@@ -58,7 +61,11 @@ export const AboutModalContainer: React.FunctionComponent<AboutModalContainerPro
|
|
|
58
61
|
}
|
|
59
62
|
return (
|
|
60
63
|
<Backdrop>
|
|
61
|
-
<FocusTrap
|
|
64
|
+
<FocusTrap
|
|
65
|
+
active={!disableFocusTrap}
|
|
66
|
+
focusTrapOptions={{ clickOutsideDeactivates: true }}
|
|
67
|
+
className={css(styles.bullseye)}
|
|
68
|
+
>
|
|
62
69
|
<AboutModalBox
|
|
63
70
|
className={className}
|
|
64
71
|
aria-labelledby={aboutModalBoxHeaderId}
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/Banner/banner';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
|
|
5
|
-
export interface BannerProps extends React.HTMLProps<
|
|
5
|
+
export interface BannerProps extends React.HTMLProps<HTMLDivElement> {
|
|
6
6
|
/** Content rendered inside the banner */
|
|
7
7
|
children?: React.ReactNode;
|
|
8
8
|
/** Additional classes added to the banner */
|
|
@@ -17,7 +17,8 @@ export const Banner: React.FunctionComponent<BannerProps> = ({
|
|
|
17
17
|
children,
|
|
18
18
|
className,
|
|
19
19
|
variant = 'default',
|
|
20
|
-
isSticky = false
|
|
20
|
+
isSticky = false,
|
|
21
|
+
...props
|
|
21
22
|
}: BannerProps) => (
|
|
22
23
|
<div
|
|
23
24
|
className={css(
|
|
@@ -26,6 +27,7 @@ export const Banner: React.FunctionComponent<BannerProps> = ({
|
|
|
26
27
|
isSticky && styles.modifiers.sticky,
|
|
27
28
|
className
|
|
28
29
|
)}
|
|
30
|
+
{...props}
|
|
29
31
|
>
|
|
30
32
|
{children}
|
|
31
33
|
</div>
|
|
@@ -6,6 +6,7 @@ exports[`danger banner 1`] = `
|
|
|
6
6
|
variant="danger"
|
|
7
7
|
>
|
|
8
8
|
<div
|
|
9
|
+
aria-label="danger"
|
|
9
10
|
className="pf-c-banner pf-m-danger"
|
|
10
11
|
>
|
|
11
12
|
danger
|
|
@@ -20,6 +21,7 @@ exports[`default banner 1`] = `
|
|
|
20
21
|
variant="default"
|
|
21
22
|
>
|
|
22
23
|
<div
|
|
24
|
+
aria-label="default"
|
|
23
25
|
className="pf-c-banner"
|
|
24
26
|
>
|
|
25
27
|
default
|
|
@@ -34,6 +36,7 @@ exports[`info banner 1`] = `
|
|
|
34
36
|
variant="info"
|
|
35
37
|
>
|
|
36
38
|
<div
|
|
39
|
+
aria-label="info"
|
|
37
40
|
className="pf-c-banner pf-m-info"
|
|
38
41
|
>
|
|
39
42
|
info
|
|
@@ -48,6 +51,7 @@ exports[`sticky banner 1`] = `
|
|
|
48
51
|
isSticky={true}
|
|
49
52
|
>
|
|
50
53
|
<div
|
|
54
|
+
aria-label="sticky"
|
|
51
55
|
className="pf-c-banner pf-m-sticky"
|
|
52
56
|
>
|
|
53
57
|
Sticky Banner
|
|
@@ -61,6 +65,7 @@ exports[`success banner 1`] = `
|
|
|
61
65
|
variant="success"
|
|
62
66
|
>
|
|
63
67
|
<div
|
|
68
|
+
aria-label="success"
|
|
64
69
|
className="pf-c-banner pf-m-success"
|
|
65
70
|
>
|
|
66
71
|
success
|
|
@@ -75,6 +80,7 @@ exports[`warning banner 1`] = `
|
|
|
75
80
|
variant="warning"
|
|
76
81
|
>
|
|
77
82
|
<div
|
|
83
|
+
aria-label="warning"
|
|
78
84
|
className="pf-c-banner pf-m-warning"
|
|
79
85
|
>
|
|
80
86
|
warning
|
|
@@ -14,13 +14,14 @@ export interface DropdownGroupProps extends Omit<React.HTMLProps<HTMLDivElement>
|
|
|
14
14
|
export const DropdownGroup: React.FunctionComponent<DropdownGroupProps> = ({
|
|
15
15
|
children = null,
|
|
16
16
|
className = '',
|
|
17
|
-
label = ''
|
|
17
|
+
label = '',
|
|
18
|
+
...props
|
|
18
19
|
}: DropdownGroupProps) => (
|
|
19
20
|
<DropdownContext.Consumer>
|
|
20
21
|
{({ sectionClass, sectionTitleClass, sectionComponent }) => {
|
|
21
22
|
const SectionComponent = sectionComponent as any;
|
|
22
23
|
return (
|
|
23
|
-
<SectionComponent className={css(sectionClass, className)}>
|
|
24
|
+
<SectionComponent className={css(sectionClass, className)} {...props}>
|
|
24
25
|
{label && (
|
|
25
26
|
<h1 className={css(sectionTitleClass)} aria-hidden>
|
|
26
27
|
{label}
|
|
@@ -2,8 +2,9 @@ import * as React from 'react';
|
|
|
2
2
|
import styles from '@patternfly/react-styles/css/components/FormControl/form-control';
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { ValidatedOptions } from '../../helpers/constants';
|
|
5
|
-
import {
|
|
5
|
+
import { trimLeft } from '../../helpers/util';
|
|
6
6
|
import { getDefaultOUIAId, getOUIAProps, OUIAProps } from '../../helpers';
|
|
7
|
+
import { getResizeObserver } from '../../helpers/resizeObserver';
|
|
7
8
|
|
|
8
9
|
export enum TextInputTypes {
|
|
9
10
|
text = 'text',
|
|
@@ -89,6 +90,7 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
|
|
|
89
90
|
ouiaSafe: true
|
|
90
91
|
};
|
|
91
92
|
inputRef = React.createRef<HTMLInputElement>();
|
|
93
|
+
observer: any = () => {};
|
|
92
94
|
|
|
93
95
|
constructor(props: TextInputProps) {
|
|
94
96
|
super(props);
|
|
@@ -109,18 +111,15 @@ export class TextInputBase extends React.Component<TextInputProps, TextInputStat
|
|
|
109
111
|
|
|
110
112
|
componentDidMount() {
|
|
111
113
|
if (this.props.isLeftTruncated) {
|
|
114
|
+
const inputRef = this.props.innerRef || this.inputRef;
|
|
115
|
+
this.observer = getResizeObserver(inputRef.current, this.handleResize);
|
|
112
116
|
this.handleResize();
|
|
113
|
-
if (canUseDOM) {
|
|
114
|
-
window.addEventListener('resize', debounce(this.handleResize, 250));
|
|
115
|
-
}
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
componentWillUnmount() {
|
|
120
121
|
if (this.props.isLeftTruncated) {
|
|
121
|
-
|
|
122
|
-
window.removeEventListener('resize', debounce(this.handleResize, 250));
|
|
123
|
-
}
|
|
122
|
+
this.observer();
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
|
package/src/helpers/index.ts
CHANGED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { canUseDOM } from './util';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This function creates a ResizeObserver used to handle resize events for the given containerRef. If ResizeObserver
|
|
5
|
+
* or the given containerRef are not available, a window resize event listener is used by default.
|
|
6
|
+
*
|
|
7
|
+
* Example 1:
|
|
8
|
+
*
|
|
9
|
+
* private containerRef = React.createRef<HTMLDivElement>();
|
|
10
|
+
* private observer: any = () => {};
|
|
11
|
+
*
|
|
12
|
+
* public componentDidMount() {
|
|
13
|
+
* this.observer = getResizeObserver(this.containerRef.current, this.handleResize);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* public componentWillUnmount() {
|
|
17
|
+
* this.observer();
|
|
18
|
+
* }
|
|
19
|
+
*
|
|
20
|
+
* private handleResize = () => {
|
|
21
|
+
* if (this.containerRef.current && this.containerRef.current.clientWidth) {
|
|
22
|
+
* this.setState({ width: this.containerRef.current.clientWidth });
|
|
23
|
+
* }
|
|
24
|
+
* };
|
|
25
|
+
*
|
|
26
|
+
* public render() {
|
|
27
|
+
* return (
|
|
28
|
+
* <div ref={this.containerRef} >
|
|
29
|
+
* <Chart width={this.state.width} ... />
|
|
30
|
+
* </div>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
*
|
|
34
|
+
* Example 2:
|
|
35
|
+
*
|
|
36
|
+
* private inputRef = React.createRef<HTMLInputElement>();
|
|
37
|
+
* private observer: any = () => {};
|
|
38
|
+
*
|
|
39
|
+
* public componentDidMount() {
|
|
40
|
+
* this.observer = getResizeObserver(this.inputRef.current, this.handleResize);
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* public componentWillUnmount() {
|
|
44
|
+
* this.observer();
|
|
45
|
+
* }
|
|
46
|
+
*
|
|
47
|
+
* private handleResize = () => {
|
|
48
|
+
* if (this.inputRef.current) {
|
|
49
|
+
* trimLeft(inputRef.current, String(this.props.value));
|
|
50
|
+
* }
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* public render() {
|
|
54
|
+
* return (
|
|
55
|
+
* <input ref={this.inputRef} ... />
|
|
56
|
+
* );
|
|
57
|
+
* }
|
|
58
|
+
*
|
|
59
|
+
* @param {Element} containerRefElement The container reference to observe
|
|
60
|
+
* @param {Function} handleResize The function to call for resize events
|
|
61
|
+
* @return {Function} The function used to unobserve resize events
|
|
62
|
+
*/
|
|
63
|
+
export const getResizeObserver = (containerRefElement: Element, handleResize: () => void) => {
|
|
64
|
+
let unobserve: any;
|
|
65
|
+
|
|
66
|
+
if (canUseDOM) {
|
|
67
|
+
const { ResizeObserver } = window as any;
|
|
68
|
+
|
|
69
|
+
if (containerRefElement && ResizeObserver) {
|
|
70
|
+
const resizeObserver = new ResizeObserver((entries: any) => {
|
|
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(containerRefElement);
|
|
79
|
+
unobserve = () => resizeObserver.unobserve(containerRefElement);
|
|
80
|
+
} else {
|
|
81
|
+
window.addEventListener('resize', handleResize);
|
|
82
|
+
unobserve = () => window.removeEventListener('resize', handleResize);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return () => {
|
|
86
|
+
if (unobserve) {
|
|
87
|
+
unobserve();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
};
|