@patternfly/react-core 4.217.3 → 4.219.0
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 +30 -0
- package/dist/esm/components/FileUpload/FileUploadField.d.ts +4 -0
- package/dist/esm/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/esm/components/FileUpload/FileUploadField.js +2 -2
- package/dist/esm/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/esm/components/Switch/Switch.d.ts +9 -3
- package/dist/esm/components/Switch/Switch.d.ts.map +1 -1
- package/dist/esm/components/Switch/Switch.js +2 -2
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.d.ts +4 -1
- package/dist/esm/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/esm/components/Tooltip/Tooltip.js +2 -2
- package/dist/esm/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/esm/helpers/Popper/Popper.d.ts +4 -0
- package/dist/esm/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/esm/helpers/Popper/Popper.js +7 -1
- package/dist/esm/helpers/Popper/Popper.js.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.d.ts +4 -0
- package/dist/js/components/FileUpload/FileUploadField.d.ts.map +1 -1
- package/dist/js/components/FileUpload/FileUploadField.js +2 -2
- package/dist/js/components/FileUpload/FileUploadField.js.map +1 -1
- package/dist/js/components/Switch/Switch.d.ts +9 -3
- package/dist/js/components/Switch/Switch.d.ts.map +1 -1
- package/dist/js/components/Switch/Switch.js +2 -2
- package/dist/js/components/Switch/Switch.js.map +1 -1
- package/dist/js/components/Tooltip/Tooltip.d.ts +4 -1
- package/dist/js/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/js/components/Tooltip/Tooltip.js +2 -2
- package/dist/js/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/js/helpers/Popper/Popper.d.ts +4 -0
- package/dist/js/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/js/helpers/Popper/Popper.js +7 -1
- package/dist/js/helpers/Popper/Popper.js.map +1 -1
- package/dist/umd/react-core.js +13 -7
- package/dist/umd/react-core.min.css +10 -10
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +5 -5
- package/src/components/FileUpload/FileUploadField.tsx +8 -0
- package/src/components/FileUpload/__tests__/__snapshots__/FileUpload.test.tsx.snap +1 -0
- package/src/components/FileUpload/__tests__/__snapshots__/FileUploadField.test.tsx.snap +1 -0
- package/src/components/FileUpload/examples/FileUpload.md +6 -3
- package/src/components/Switch/Switch.tsx +12 -4
- package/src/components/Switch/examples/Switch.md +2 -18
- package/src/components/Tooltip/Tooltip.tsx +7 -2
- package/src/helpers/Popper/Popper.tsx +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.219.0",
|
|
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.70.0",
|
|
38
|
+
"@patternfly/react-styles": "^4.69.0",
|
|
39
|
+
"@patternfly/react-tokens": "^4.71.0",
|
|
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": "35dea6aaa7ed4c6f49ae0d3ee6644dda3efb2889"
|
|
64
64
|
}
|
|
@@ -78,6 +78,10 @@ export interface FileUploadFieldProps extends Omit<React.HTMLProps<HTMLDivElemen
|
|
|
78
78
|
containerRef?: React.Ref<HTMLDivElement>;
|
|
79
79
|
/** Text area text changed */
|
|
80
80
|
onTextChange?: (text: string) => void;
|
|
81
|
+
/** Callback for when focus is lost on the text area field */
|
|
82
|
+
onTextAreaBlur?: (event?: any) => void;
|
|
83
|
+
/** Placeholder string to display in the empty text area field */
|
|
84
|
+
textAreaPlaceholder?: string;
|
|
81
85
|
}
|
|
82
86
|
|
|
83
87
|
export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
|
|
@@ -90,6 +94,8 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
|
|
|
90
94
|
onClearButtonClick = () => {},
|
|
91
95
|
onTextAreaClick,
|
|
92
96
|
onTextChange,
|
|
97
|
+
onTextAreaBlur,
|
|
98
|
+
textAreaPlaceholder = '',
|
|
93
99
|
className = '',
|
|
94
100
|
isDisabled = false,
|
|
95
101
|
isReadOnly = false,
|
|
@@ -169,6 +175,8 @@ export const FileUploadField: React.FunctionComponent<FileUploadFieldProps> = ({
|
|
|
169
175
|
value={value as string}
|
|
170
176
|
onChange={onTextAreaChange}
|
|
171
177
|
onClick={onTextAreaClick}
|
|
178
|
+
onBlur={onTextAreaBlur}
|
|
179
|
+
placeholder={textAreaPlaceholder}
|
|
172
180
|
/>
|
|
173
181
|
)}
|
|
174
182
|
{isLoading && (
|
|
@@ -268,7 +268,8 @@ class CustomFileUpload extends React.Component {
|
|
|
268
268
|
isLoading: false,
|
|
269
269
|
isDragActive: false,
|
|
270
270
|
hideDefaultPreview: false,
|
|
271
|
-
children: false
|
|
271
|
+
children: false,
|
|
272
|
+
hasPlaceholderText: false
|
|
272
273
|
};
|
|
273
274
|
this.handleTextAreaChange = value => {
|
|
274
275
|
this.setState({ value });
|
|
@@ -283,11 +284,12 @@ class CustomFileUpload extends React.Component {
|
|
|
283
284
|
isLoading,
|
|
284
285
|
isDragActive,
|
|
285
286
|
hideDefaultPreview,
|
|
286
|
-
children
|
|
287
|
+
children,
|
|
288
|
+
hasPlaceholderText
|
|
287
289
|
} = this.state;
|
|
288
290
|
return (
|
|
289
291
|
<div>
|
|
290
|
-
{['filename', 'isClearButtonDisabled', 'isDragActive', 'isLoading', 'hideDefaultPreview', 'children'].map(
|
|
292
|
+
{['filename', 'isClearButtonDisabled', 'isDragActive', 'isLoading', 'hideDefaultPreview', 'children', 'hasPlaceholderText'].map(
|
|
291
293
|
stateKey => (
|
|
292
294
|
<Checkbox
|
|
293
295
|
key={stateKey}
|
|
@@ -321,6 +323,7 @@ class CustomFileUpload extends React.Component {
|
|
|
321
323
|
isDragActive={isDragActive}
|
|
322
324
|
hideDefaultPreview={hideDefaultPreview}
|
|
323
325
|
browseButtonText="Upload"
|
|
326
|
+
textAreaPlaceholder={hasPlaceholderText ? "File preview" : ''}
|
|
324
327
|
>
|
|
325
328
|
{children && (
|
|
326
329
|
<div className="pf-u-m-md">(A custom preview of the uploaded file can be passed as children)</div>
|
|
@@ -12,12 +12,18 @@ export interface SwitchProps
|
|
|
12
12
|
id?: string;
|
|
13
13
|
/** Additional classes added to the switch */
|
|
14
14
|
className?: string;
|
|
15
|
-
/** Text value for the label when on */
|
|
15
|
+
/** Text value for the visible label when on */
|
|
16
16
|
label?: React.ReactNode;
|
|
17
|
-
/** Text value for the label when off */
|
|
17
|
+
/** Text value for the visible label when off */
|
|
18
18
|
labelOff?: React.ReactNode;
|
|
19
|
-
/** Flag to show if the switch is checked.
|
|
19
|
+
/** Flag to show if the switch is checked when it is controlled by React state.
|
|
20
|
+
* To make the switch uncontrolled instead use the defaultChecked prop, but do not use both.
|
|
21
|
+
*/
|
|
20
22
|
isChecked?: boolean;
|
|
23
|
+
/** Flag to set the default checked value of the switch when it is uncontrolled by React state.
|
|
24
|
+
* To make the switch controlled instead use the isChecked prop, but do not use both.
|
|
25
|
+
*/
|
|
26
|
+
defaultChecked?: boolean;
|
|
21
27
|
/** Flag to show if the switch has a check icon. */
|
|
22
28
|
hasCheckIcon?: boolean;
|
|
23
29
|
/** Flag to show if the switch is disabled. */
|
|
@@ -63,6 +69,7 @@ export class Switch extends React.Component<SwitchProps & OUIAProps, { ouiaState
|
|
|
63
69
|
label,
|
|
64
70
|
labelOff,
|
|
65
71
|
isChecked,
|
|
72
|
+
defaultChecked,
|
|
66
73
|
hasCheckIcon,
|
|
67
74
|
isDisabled,
|
|
68
75
|
onChange,
|
|
@@ -84,7 +91,8 @@ export class Switch extends React.Component<SwitchProps & OUIAProps, { ouiaState
|
|
|
84
91
|
className={css(styles.switchInput)}
|
|
85
92
|
type="checkbox"
|
|
86
93
|
onChange={event => onChange(event.target.checked, event)}
|
|
87
|
-
|
|
94
|
+
{...([true, false].includes(defaultChecked) && { defaultChecked })}
|
|
95
|
+
{...(![true, false].includes(defaultChecked) && { checked: isChecked })}
|
|
88
96
|
disabled={isDisabled}
|
|
89
97
|
aria-labelledby={isAriaLabelledBy ? `${this.id}-on` : null}
|
|
90
98
|
{...props}
|
|
@@ -171,24 +171,8 @@ import React from 'react';
|
|
|
171
171
|
import { Switch } from '@patternfly/react-core';
|
|
172
172
|
|
|
173
173
|
<React.Fragment>
|
|
174
|
-
<Switch
|
|
175
|
-
id="uncontrolled-switch-on"
|
|
176
|
-
aria-label="Message when on"
|
|
177
|
-
label="Message when on"
|
|
178
|
-
labelOff="Message when off"
|
|
179
|
-
isChecked
|
|
180
|
-
/>
|
|
181
|
-
<br />
|
|
182
|
-
<Switch
|
|
183
|
-
id="uncontrolled-switch-off"
|
|
184
|
-
aria-label="Message when on"
|
|
185
|
-
label="Message when on"
|
|
186
|
-
labelOff="Message when off"
|
|
187
|
-
isChecked={false}
|
|
188
|
-
/>
|
|
189
|
-
<br />
|
|
190
|
-
<Switch id="uncontrolled-no-label-switch-on" aria-label="Message when on" isChecked />
|
|
174
|
+
<Switch id="uncontrolled-switch-on" label="Message when on" labelOff="Message when off" defaultChecked={false} />
|
|
191
175
|
<br />
|
|
192
|
-
<Switch id="uncontrolled-no-label-switch-
|
|
176
|
+
<Switch id="uncontrolled-no-label-switch-on" aria-label="Message when on" defaultChecked={true} />
|
|
193
177
|
</React.Fragment>;
|
|
194
178
|
```
|
|
@@ -63,7 +63,10 @@ export interface TooltipProps extends Omit<React.HTMLProps<HTMLDivElement>, 'con
|
|
|
63
63
|
enableFlip?: boolean;
|
|
64
64
|
/** Delay in ms before the tooltip appears */
|
|
65
65
|
entryDelay?: number;
|
|
66
|
-
/** Delay in ms before the tooltip disappears
|
|
66
|
+
/** Delay in ms before the tooltip disappears, Avoid passing in a value of "0", as users should
|
|
67
|
+
* be given ample time to move their mouse from the trigger to the tooltip content without the content
|
|
68
|
+
* being hidden.
|
|
69
|
+
*/
|
|
67
70
|
exitDelay?: number;
|
|
68
71
|
/**
|
|
69
72
|
* The desired position to flip the tooltip to if the initial position is not possible.
|
|
@@ -149,7 +152,7 @@ export const Tooltip: React.FunctionComponent<TooltipProps> = ({
|
|
|
149
152
|
enableFlip = true,
|
|
150
153
|
className = '',
|
|
151
154
|
entryDelay = 300,
|
|
152
|
-
exitDelay =
|
|
155
|
+
exitDelay = 300,
|
|
153
156
|
appendTo = () => document.body,
|
|
154
157
|
zIndex = 9999,
|
|
155
158
|
maxWidth = tooltipMaxWidth.value,
|
|
@@ -318,6 +321,8 @@ export const Tooltip: React.FunctionComponent<TooltipProps> = ({
|
|
|
318
321
|
placement={position}
|
|
319
322
|
onMouseEnter={triggerOnMouseenter && show}
|
|
320
323
|
onMouseLeave={triggerOnMouseenter && hide}
|
|
324
|
+
onPopperMouseEnter={triggerOnMouseenter && show}
|
|
325
|
+
onPopperMouseLeave={triggerOnMouseenter && hide}
|
|
321
326
|
onFocus={triggerOnFocus && show}
|
|
322
327
|
onBlur={triggerOnFocus && hide}
|
|
323
328
|
onDocumentClick={triggerOnClick && onDocumentClick}
|
|
@@ -95,6 +95,10 @@ export interface PopperProps {
|
|
|
95
95
|
onTriggerEnter?: (event?: KeyboardEvent) => void;
|
|
96
96
|
/** Callback function when popper is clicked */
|
|
97
97
|
onPopperClick?: (event?: MouseEvent) => void;
|
|
98
|
+
/** Callback function when mouse enters popper content */
|
|
99
|
+
onPopperMouseEnter?: (event?: MouseEvent) => void;
|
|
100
|
+
/** Callback function when mouse leaves popper content */
|
|
101
|
+
onPopperMouseLeave?: (event?: MouseEvent) => void;
|
|
98
102
|
/** Callback function when document is clicked */
|
|
99
103
|
onDocumentClick?: (event?: MouseEvent, triggerElement?: HTMLElement, popperElement?: HTMLElement) => void;
|
|
100
104
|
/** Callback function when keydown event occurs on document */
|
|
@@ -140,6 +144,8 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
|
|
|
140
144
|
onTriggerClick,
|
|
141
145
|
onTriggerEnter,
|
|
142
146
|
onPopperClick,
|
|
147
|
+
onPopperMouseEnter,
|
|
148
|
+
onPopperMouseLeave,
|
|
143
149
|
onDocumentKeyDown,
|
|
144
150
|
enableFlip = true,
|
|
145
151
|
flipBehavior = 'flip',
|
|
@@ -186,6 +192,8 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
|
|
|
186
192
|
addEventListener(onTriggerClick, refOrTrigger, 'click');
|
|
187
193
|
addEventListener(onTriggerEnter, refOrTrigger, 'keydown');
|
|
188
194
|
addEventListener(onPopperClick, popperElement, 'click');
|
|
195
|
+
addEventListener(onPopperMouseEnter, popperElement, 'mouseenter');
|
|
196
|
+
addEventListener(onPopperMouseLeave, popperElement, 'mouseleave');
|
|
189
197
|
onDocumentClick && addEventListener(onDocumentClickCallback, document, 'click');
|
|
190
198
|
addEventListener(onDocumentKeyDown, document, 'keydown');
|
|
191
199
|
|
|
@@ -203,6 +211,8 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
|
|
|
203
211
|
removeEventListener(onTriggerClick, refOrTrigger, 'click');
|
|
204
212
|
removeEventListener(onTriggerEnter, refOrTrigger, 'keydown');
|
|
205
213
|
removeEventListener(onPopperClick, popperElement, 'click');
|
|
214
|
+
removeEventListener(onPopperMouseEnter, popperElement, 'mouseenter');
|
|
215
|
+
removeEventListener(onPopperMouseLeave, popperElement, 'mouseleave');
|
|
206
216
|
onDocumentClick && removeEventListener(onDocumentClickCallback, document, 'click');
|
|
207
217
|
removeEventListener(onDocumentKeyDown, document, 'keydown');
|
|
208
218
|
observer.disconnect();
|
|
@@ -217,6 +227,8 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
|
|
|
217
227
|
onTriggerClick,
|
|
218
228
|
onTriggerEnter,
|
|
219
229
|
onPopperClick,
|
|
230
|
+
onPopperMouseEnter,
|
|
231
|
+
onPopperMouseLeave,
|
|
220
232
|
onDocumentClick,
|
|
221
233
|
onDocumentKeyDown,
|
|
222
234
|
refElement
|