@patternfly/react-core 4.217.2 → 4.218.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/ContextSelector/ContextSelector.d.ts +5 -0
- package/dist/esm/components/ContextSelector/ContextSelector.d.ts.map +1 -1
- package/dist/esm/components/ContextSelector/ContextSelector.js +4 -3
- package/dist/esm/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.d.ts +5 -0
- package/dist/esm/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js +2 -2
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownWithContext.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownWithContext.js +7 -3
- package/dist/esm/components/Dropdown/DropdownWithContext.js.map +1 -1
- 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/Select/Select.d.ts +5 -0
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.js +7 -3
- package/dist/esm/components/Select/Select.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/js/components/ContextSelector/ContextSelector.d.ts +5 -0
- package/dist/js/components/ContextSelector/ContextSelector.d.ts.map +1 -1
- package/dist/js/components/ContextSelector/ContextSelector.js +4 -3
- package/dist/js/components/ContextSelector/ContextSelector.js.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.d.ts +5 -0
- package/dist/js/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.js +2 -2
- package/dist/js/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownWithContext.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownWithContext.js +7 -3
- package/dist/js/components/Dropdown/DropdownWithContext.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/Select/Select.d.ts +5 -0
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Select/Select.js +7 -3
- package/dist/js/components/Select/Select.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/umd/react-core.js +24 -15
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/ContextSelector/ContextSelector.tsx +14 -2
- package/src/components/Dropdown/Dropdown.tsx +7 -1
- package/src/components/Dropdown/DropdownWithContext.tsx +6 -1
- 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/Select/Select.tsx +11 -1
- package/src/components/Switch/Switch.tsx +12 -4
- package/src/components/Switch/examples/Switch.md +2 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.218.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.69.0",
|
|
38
|
+
"@patternfly/react-styles": "^4.68.0",
|
|
39
|
+
"@patternfly/react-tokens": "^4.70.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": "5a409a664a4c75aea67d0c8d3d25de641e320f9e"
|
|
64
64
|
}
|
|
@@ -61,6 +61,11 @@ export interface ContextSelectorProps extends Omit<ToggleMenuBaseProps, 'menuApp
|
|
|
61
61
|
isText?: boolean;
|
|
62
62
|
/** Flag to disable focus trap */
|
|
63
63
|
disableFocusTrap?: boolean;
|
|
64
|
+
/** Flag for indicating that the context selector menu should automatically flip vertically when
|
|
65
|
+
* it reaches the boundary. This prop can only be used when the context selector component is not
|
|
66
|
+
* appended inline, e.g. `menuAppendTo="parent"`
|
|
67
|
+
*/
|
|
68
|
+
isFlipEnabled?: boolean;
|
|
64
69
|
}
|
|
65
70
|
|
|
66
71
|
export class ContextSelector extends React.Component<ContextSelectorProps, { ouiaStateId: string }> {
|
|
@@ -83,7 +88,8 @@ export class ContextSelector extends React.Component<ContextSelectorProps, { oui
|
|
|
83
88
|
disableFocusTrap: false,
|
|
84
89
|
footer: null as React.ReactNode,
|
|
85
90
|
isPlain: false,
|
|
86
|
-
isText: false
|
|
91
|
+
isText: false,
|
|
92
|
+
isFlipEnabled: false
|
|
87
93
|
};
|
|
88
94
|
constructor(props: ContextSelectorProps) {
|
|
89
95
|
super(props);
|
|
@@ -126,10 +132,16 @@ export class ContextSelector extends React.Component<ContextSelectorProps, { oui
|
|
|
126
132
|
isText,
|
|
127
133
|
footer,
|
|
128
134
|
disableFocusTrap,
|
|
135
|
+
isFlipEnabled,
|
|
129
136
|
...props
|
|
130
137
|
} = this.props;
|
|
131
138
|
const menuContainer = (
|
|
132
|
-
<div
|
|
139
|
+
<div
|
|
140
|
+
className={css(styles.contextSelectorMenu)}
|
|
141
|
+
// This removes the `position: absolute`styling from the `.pf-c-context-selector__menu`
|
|
142
|
+
// allowing the menu to flip correctly
|
|
143
|
+
{...(isFlipEnabled && { style: { position: 'revert' } })}
|
|
144
|
+
>
|
|
133
145
|
{isOpen && (
|
|
134
146
|
<FocusTrap active={!disableFocusTrap} focusTrapOptions={{ clickOutsideDeactivates: true }}>
|
|
135
147
|
<div className={css(styles.contextSelectorMenuSearch)}>
|
|
@@ -55,6 +55,11 @@ export interface DropdownProps
|
|
|
55
55
|
autoFocus?: boolean;
|
|
56
56
|
/** Props for extreme customization of dropdown */
|
|
57
57
|
contextProps?: typeof DropdownContext;
|
|
58
|
+
/** Flag for indicating that the dropdown menu should automatically flip vertically when
|
|
59
|
+
* it reaches the boundary. This prop can only be used when the dropdown component is not
|
|
60
|
+
* appended inline, e.g. `menuAppendTo="parent"`
|
|
61
|
+
*/
|
|
62
|
+
isFlipEnabled?: boolean;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
export const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
@@ -66,6 +71,7 @@ export const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
66
71
|
alignments,
|
|
67
72
|
contextProps,
|
|
68
73
|
menuAppendTo = 'inline',
|
|
74
|
+
isFlipEnabled = false,
|
|
69
75
|
...props
|
|
70
76
|
}: DropdownProps) => (
|
|
71
77
|
<DropdownContext.Provider
|
|
@@ -91,7 +97,7 @@ export const Dropdown: React.FunctionComponent<DropdownProps> = ({
|
|
|
91
97
|
...contextProps
|
|
92
98
|
}}
|
|
93
99
|
>
|
|
94
|
-
<DropdownWithContext menuAppendTo={menuAppendTo} {...props} />
|
|
100
|
+
<DropdownWithContext menuAppendTo={menuAppendTo} isFlipEnabled={isFlipEnabled} {...props} />
|
|
95
101
|
</DropdownContext.Provider>
|
|
96
102
|
);
|
|
97
103
|
Dropdown.displayName = 'Dropdown';
|
|
@@ -29,7 +29,8 @@ export class DropdownWithContext extends React.Component<DropdownProps & OUIAPro
|
|
|
29
29
|
direction: DropdownDirection.down,
|
|
30
30
|
onSelect: (): void => undefined,
|
|
31
31
|
autoFocus: true,
|
|
32
|
-
menuAppendTo: 'inline'
|
|
32
|
+
menuAppendTo: 'inline',
|
|
33
|
+
isFlipEnabled: false
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
constructor(props: DropdownProps & OUIAProps) {
|
|
@@ -75,6 +76,7 @@ export class DropdownWithContext extends React.Component<DropdownProps & OUIAPro
|
|
|
75
76
|
toggle,
|
|
76
77
|
autoFocus,
|
|
77
78
|
menuAppendTo,
|
|
79
|
+
isFlipEnabled,
|
|
78
80
|
...props
|
|
79
81
|
} = this.props;
|
|
80
82
|
const id = toggle.props.id || `pf-dropdown-toggle-id-${DropdownWithContext.currentId++}`;
|
|
@@ -96,6 +98,9 @@ export class DropdownWithContext extends React.Component<DropdownProps & OUIAPro
|
|
|
96
98
|
const BaseComponent = baseComponent as any;
|
|
97
99
|
const menuContainer = (
|
|
98
100
|
<DropdownMenu
|
|
101
|
+
// This removes the `position: absolute` styling from the `.pf-c-dropdown__menu`
|
|
102
|
+
// allowing the menu to flip correctly
|
|
103
|
+
{...(isFlipEnabled && { style: { position: 'revert', minWidth: 'min-content' } })}
|
|
99
104
|
setMenuComponentRef={this.setMenuComponentRef}
|
|
100
105
|
component={component}
|
|
101
106
|
isOpen={isOpen}
|
|
@@ -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>
|
|
@@ -173,6 +173,11 @@ export interface SelectProps
|
|
|
173
173
|
* menuAppendTo={document.getElementById('target')}
|
|
174
174
|
*/
|
|
175
175
|
menuAppendTo?: HTMLElement | (() => HTMLElement) | 'inline' | 'parent';
|
|
176
|
+
/** Flag for indicating that the select menu should automatically flip vertically when
|
|
177
|
+
* it reaches the boundary. This prop can only be used when the select component is not
|
|
178
|
+
* appended inline, e.g. `menuAppendTo="parent"`
|
|
179
|
+
*/
|
|
180
|
+
isFlipEnabled?: boolean;
|
|
176
181
|
}
|
|
177
182
|
|
|
178
183
|
export interface SelectState {
|
|
@@ -245,7 +250,8 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
|
|
|
245
250
|
isInputValuePersisted: false,
|
|
246
251
|
isInputFilterPersisted: false,
|
|
247
252
|
isCreateSelectOptionObject: false,
|
|
248
|
-
shouldResetOnSelect: true
|
|
253
|
+
shouldResetOnSelect: true,
|
|
254
|
+
isFlipEnabled: false
|
|
249
255
|
};
|
|
250
256
|
|
|
251
257
|
state: SelectState = {
|
|
@@ -978,6 +984,7 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
|
|
|
978
984
|
loadingVariant,
|
|
979
985
|
isCreateSelectOptionObject,
|
|
980
986
|
shouldResetOnSelect,
|
|
987
|
+
isFlipEnabled,
|
|
981
988
|
...props
|
|
982
989
|
} = this.props;
|
|
983
990
|
const {
|
|
@@ -1204,6 +1211,9 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
|
|
|
1204
1211
|
|
|
1205
1212
|
const innerMenu = (
|
|
1206
1213
|
<SelectMenu
|
|
1214
|
+
// This removes the `position: absolute` styling from the `.pf-c-select__menu`
|
|
1215
|
+
// allowing the menu to flip correctly
|
|
1216
|
+
{...(isFlipEnabled && { style: { position: 'revert' } })}
|
|
1207
1217
|
{...props}
|
|
1208
1218
|
isGrouped={isGrouped}
|
|
1209
1219
|
selected={selections}
|
|
@@ -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
|
```
|