@patternfly/react-core 4.267.14 → 4.268.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 +22 -0
- package/components/Dropdown/DropdownToggleCheckbox.d.ts +6 -0
- package/components/Dropdown/DropdownToggleCheckbox.d.ts.map +1 -1
- package/components/Dropdown/DropdownToggleCheckbox.js +6 -3
- package/components/Dropdown/DropdownToggleCheckbox.js.map +1 -1
- package/components/SimpleList/SimpleList.d.ts +2 -0
- package/components/SimpleList/SimpleList.d.ts.map +1 -1
- package/components/SimpleList/SimpleList.js +2 -2
- package/components/SimpleList/SimpleList.js.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggleCheckbox.d.ts +6 -0
- package/dist/esm/components/Dropdown/DropdownToggleCheckbox.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/DropdownToggleCheckbox.js +6 -3
- package/dist/esm/components/Dropdown/DropdownToggleCheckbox.js.map +1 -1
- package/dist/esm/components/SimpleList/SimpleList.d.ts +2 -0
- package/dist/esm/components/SimpleList/SimpleList.d.ts.map +1 -1
- package/dist/esm/components/SimpleList/SimpleList.js +2 -2
- package/dist/esm/components/SimpleList/SimpleList.js.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggleCheckbox.d.ts +6 -0
- package/dist/js/components/Dropdown/DropdownToggleCheckbox.d.ts.map +1 -1
- package/dist/js/components/Dropdown/DropdownToggleCheckbox.js +6 -3
- package/dist/js/components/Dropdown/DropdownToggleCheckbox.js.map +1 -1
- package/dist/js/components/SimpleList/SimpleList.d.ts +2 -0
- package/dist/js/components/SimpleList/SimpleList.d.ts.map +1 -1
- package/dist/js/components/SimpleList/SimpleList.js +2 -2
- package/dist/js/components/SimpleList/SimpleList.js.map +1 -1
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +2 -2
- package/src/components/Dropdown/DropdownToggleCheckbox.tsx +26 -1
- package/src/components/Dropdown/examples/Dropdown.md +9 -2
- package/src/components/Dropdown/examples/DropdownSplitButton.tsx +1 -1
- package/src/components/Dropdown/examples/DropdownSplitButtonProgressCheckbox.tsx +140 -0
- package/src/components/SimpleList/SimpleList.tsx +4 -2
- package/src/components/SimpleList/__tests__/SimpleList.test.tsx +5 -0
- package/src/components/SimpleList/__tests__/__snapshots__/SimpleList.test.tsx.snap +43 -0
- package/dist/umd/react-core.min.css +0 -28293
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.268.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",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"react": "^16.8 || ^17 || ^18",
|
|
72
72
|
"react-dom": "^16.8 || ^17 || ^18"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "a4fca9d0be55199414a01de809cc041561207489"
|
|
75
75
|
}
|
|
@@ -3,6 +3,7 @@ import styles from '@patternfly/react-styles/css/components/Dropdown/dropdown';
|
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { PickOptional } from '../../helpers/typeUtils';
|
|
5
5
|
import { getOUIAProps, OUIAProps, getDefaultOUIAId } from '../../helpers';
|
|
6
|
+
import { Spinner } from '../Spinner';
|
|
6
7
|
|
|
7
8
|
export interface DropdownToggleCheckboxProps
|
|
8
9
|
extends Omit<React.HTMLProps<HTMLInputElement>, 'type' | 'onChange' | 'disabled' | 'checked'>,
|
|
@@ -15,6 +16,8 @@ export interface DropdownToggleCheckboxProps
|
|
|
15
16
|
isDisabled?: boolean;
|
|
16
17
|
/** Flag to show if the checkbox is checked */
|
|
17
18
|
isChecked?: boolean | null;
|
|
19
|
+
/** @beta Flag to show if the checkbox is in progress */
|
|
20
|
+
isInProgress?: boolean | null;
|
|
18
21
|
/** Alternate Flag to show if the checkbox is checked */
|
|
19
22
|
checked?: boolean | null;
|
|
20
23
|
/** A callback for when the checkbox selection changes */
|
|
@@ -25,6 +28,10 @@ export interface DropdownToggleCheckboxProps
|
|
|
25
28
|
id: string;
|
|
26
29
|
/** Aria-label of the checkbox */
|
|
27
30
|
'aria-label': string;
|
|
31
|
+
/** @beta Text describing current loading status or progress */
|
|
32
|
+
defaultProgressAriaValueText?: string;
|
|
33
|
+
/** @beta Aria-label for the default progress icon to describe what is loading */
|
|
34
|
+
defaultProgressAriaLabel?: string;
|
|
28
35
|
/** Value to overwrite the randomly generated data-ouia-component-id.*/
|
|
29
36
|
ouiaId?: number | string;
|
|
30
37
|
/** Set the value of data-ouia-safe. Only set to true when the component is in a static state, i.e. no animations are occurring. At all other times, this value must be false. */
|
|
@@ -68,6 +75,9 @@ export class DropdownToggleCheckbox extends React.Component<DropdownToggleCheckb
|
|
|
68
75
|
isValid,
|
|
69
76
|
isDisabled,
|
|
70
77
|
isChecked,
|
|
78
|
+
isInProgress = false,
|
|
79
|
+
defaultProgressAriaLabel,
|
|
80
|
+
defaultProgressAriaValueText = 'Loading...',
|
|
71
81
|
children,
|
|
72
82
|
ouiaId,
|
|
73
83
|
ouiaSafe,
|
|
@@ -77,13 +87,27 @@ export class DropdownToggleCheckbox extends React.Component<DropdownToggleCheckb
|
|
|
77
87
|
/* eslint-enable @typescript-eslint/no-unused-vars */
|
|
78
88
|
...props
|
|
79
89
|
} = this.props;
|
|
90
|
+
|
|
91
|
+
const spinner = (
|
|
92
|
+
<Spinner
|
|
93
|
+
diameter="1em"
|
|
94
|
+
isSVG
|
|
95
|
+
aria-valuetext={defaultProgressAriaValueText}
|
|
96
|
+
aria-live="polite"
|
|
97
|
+
aria-label={defaultProgressAriaLabel}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
|
|
80
101
|
const text = children && (
|
|
81
102
|
<span className={css(styles.dropdownToggleText, className)} aria-hidden="true" id={`${props.id}-text`}>
|
|
82
103
|
{children}
|
|
83
104
|
</span>
|
|
84
105
|
);
|
|
85
106
|
return (
|
|
86
|
-
<label
|
|
107
|
+
<label
|
|
108
|
+
className={css(styles.dropdownToggleCheck, isInProgress && styles.modifiers.inProgress, className)}
|
|
109
|
+
htmlFor={props.id}
|
|
110
|
+
>
|
|
87
111
|
<input
|
|
88
112
|
{...props}
|
|
89
113
|
{...(this.calculateChecked() !== undefined && { onChange: this.handleChange })}
|
|
@@ -98,6 +122,7 @@ export class DropdownToggleCheckbox extends React.Component<DropdownToggleCheckb
|
|
|
98
122
|
ouiaSafe
|
|
99
123
|
)}
|
|
100
124
|
/>
|
|
125
|
+
{isInProgress && <span className={css(styles.dropdownToggleProgress, className)}>{spinner}</span>}
|
|
101
126
|
{text}
|
|
102
127
|
</label>
|
|
103
128
|
);
|
|
@@ -116,7 +116,7 @@ You may use a `<BadgeToggle>` to display the number of dropdown menu items.
|
|
|
116
116
|
```ts file="./DropdownBadge.tsx"
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
### Split button
|
|
119
|
+
### Split button (checkbox)
|
|
120
120
|
|
|
121
121
|
To combine an action button or other control with a dropdown menu, use a split button. A `<DropdownToggle>` can be rendered as a split button by using the `splitButtonItems` property. Elements to be displayed before the toggle button must be included in `splitButtonItems`.
|
|
122
122
|
|
|
@@ -125,13 +125,20 @@ The following example shows a split button with a `<DropdownToggleCheckbox>`, wh
|
|
|
125
125
|
```ts file="./DropdownSplitButton.tsx"
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
### Split button text
|
|
128
|
+
### Split button (checkbox with toggle text)
|
|
129
129
|
|
|
130
130
|
Text labels may optionally be used alongside actions within split buttons.
|
|
131
131
|
|
|
132
132
|
```ts file="./DropdownSplitButtonText.tsx"
|
|
133
133
|
```
|
|
134
134
|
|
|
135
|
+
### Split button (progress checkbox)
|
|
136
|
+
|
|
137
|
+
The `isInProgress` property can be used to indicate a progress state by rendering a spinner in place of a checkbox.
|
|
138
|
+
|
|
139
|
+
```ts isBeta file="./DropdownSplitButtonProgressCheckbox.tsx"
|
|
140
|
+
```
|
|
141
|
+
|
|
135
142
|
### Split button toggle variants
|
|
136
143
|
|
|
137
144
|
Use the `toggleVariant` and `splitButtonVariant` properties to adjust the styling of split button toggles.
|
|
@@ -54,7 +54,7 @@ export const DropdownSplitButton: React.FunctionComponent = () => {
|
|
|
54
54
|
toggle={
|
|
55
55
|
<DropdownToggle
|
|
56
56
|
splitButtonItems={[
|
|
57
|
-
<DropdownToggleCheckbox id="split-button-checkbox" key="split-checkbox" aria-label="Select all" />
|
|
57
|
+
<DropdownToggleCheckbox id="split-button-toggle-checkbox" key="split-checkbox" aria-label="Select all" />
|
|
58
58
|
]}
|
|
59
59
|
onToggle={onToggle}
|
|
60
60
|
id="toggle-split-button"
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Dropdown,
|
|
4
|
+
DropdownToggle,
|
|
5
|
+
DropdownToggleCheckbox,
|
|
6
|
+
DropdownItem,
|
|
7
|
+
DropdownSeparator
|
|
8
|
+
} from '@patternfly/react-core';
|
|
9
|
+
|
|
10
|
+
export const DropdownSplitButtonProgressCheckbox: React.FunctionComponent = () => {
|
|
11
|
+
const [isOpen1, setIsOpen1] = React.useState(false);
|
|
12
|
+
const [isOpen2, setIsOpen2] = React.useState(false);
|
|
13
|
+
|
|
14
|
+
const [isChecked1, setIsChecked1] = React.useState(false);
|
|
15
|
+
const [isChecked2, setIsChecked2] = React.useState(false);
|
|
16
|
+
|
|
17
|
+
const [isTimedOut1, setIsTimedOut1] = React.useState(true);
|
|
18
|
+
const [isTimedOut2, setIsTimedOut2] = React.useState(true);
|
|
19
|
+
|
|
20
|
+
const onToggle1 = (isOpen: boolean) => {
|
|
21
|
+
setIsOpen1(isOpen);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const onToggle2 = (isOpen: boolean) => {
|
|
25
|
+
setIsOpen2(isOpen);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const showProgressIcon1 = () => {
|
|
29
|
+
setIsTimedOut1(false);
|
|
30
|
+
setTimeout(() => setIsTimedOut1(true), 3000);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const showProgressIcon2 = () => {
|
|
34
|
+
setIsTimedOut2(false);
|
|
35
|
+
setTimeout(() => setIsTimedOut2(true), 3000);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const onFocus1 = () => {
|
|
39
|
+
const element = document.getElementById('toggle-split-button-progress');
|
|
40
|
+
element.focus();
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const onFocus2 = () => {
|
|
44
|
+
const element = document.getElementById('toggle-split-button-progress-text');
|
|
45
|
+
element.focus();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const onChange1 = (checked: boolean) => {
|
|
49
|
+
setIsChecked1(checked);
|
|
50
|
+
showProgressIcon1();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const onChange2 = (checked: boolean) => {
|
|
54
|
+
setIsChecked2(checked);
|
|
55
|
+
showProgressIcon2();
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const onSelect1 = () => {
|
|
59
|
+
setIsOpen1(false);
|
|
60
|
+
onFocus1();
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const onSelect2 = () => {
|
|
64
|
+
setIsOpen2(false);
|
|
65
|
+
onFocus2();
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const dropdownItems = [
|
|
69
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
70
|
+
<DropdownItem key="action" component="button">
|
|
71
|
+
Action
|
|
72
|
+
</DropdownItem>,
|
|
73
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
74
|
+
Disabled link
|
|
75
|
+
</DropdownItem>,
|
|
76
|
+
<DropdownItem
|
|
77
|
+
key="disabled action"
|
|
78
|
+
isAriaDisabled
|
|
79
|
+
component="button"
|
|
80
|
+
tooltip="Tooltip for disabled item"
|
|
81
|
+
tooltipProps={{ position: 'top' }}
|
|
82
|
+
>
|
|
83
|
+
Disabled action
|
|
84
|
+
</DropdownItem>,
|
|
85
|
+
<DropdownSeparator key="separator" />,
|
|
86
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
87
|
+
<DropdownItem key="separated action" component="button">
|
|
88
|
+
Separated action
|
|
89
|
+
</DropdownItem>
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
<Dropdown
|
|
95
|
+
onSelect={onSelect1}
|
|
96
|
+
toggle={
|
|
97
|
+
<DropdownToggle
|
|
98
|
+
splitButtonItems={[
|
|
99
|
+
<DropdownToggleCheckbox
|
|
100
|
+
onChange={onChange1}
|
|
101
|
+
isChecked={isChecked1}
|
|
102
|
+
isInProgress={!isTimedOut1}
|
|
103
|
+
id="split-button-progress-toggle-checkbox"
|
|
104
|
+
key="split-progress-checkbox"
|
|
105
|
+
aria-label="Select all"
|
|
106
|
+
/>
|
|
107
|
+
]}
|
|
108
|
+
onToggle={onToggle1}
|
|
109
|
+
id="toggle-split-button-progress"
|
|
110
|
+
/>
|
|
111
|
+
}
|
|
112
|
+
isOpen={isOpen1}
|
|
113
|
+
dropdownItems={dropdownItems}
|
|
114
|
+
/>{' '}
|
|
115
|
+
<Dropdown
|
|
116
|
+
onSelect={onSelect2}
|
|
117
|
+
toggle={
|
|
118
|
+
<DropdownToggle
|
|
119
|
+
splitButtonItems={[
|
|
120
|
+
<DropdownToggleCheckbox
|
|
121
|
+
onChange={onChange2}
|
|
122
|
+
isChecked={isChecked2}
|
|
123
|
+
isInProgress={!isTimedOut2}
|
|
124
|
+
id="split-button-progress-text-checkbox"
|
|
125
|
+
key="split-progress-checkbox"
|
|
126
|
+
aria-label="Select all"
|
|
127
|
+
>
|
|
128
|
+
10 selected
|
|
129
|
+
</DropdownToggleCheckbox>
|
|
130
|
+
]}
|
|
131
|
+
onToggle={onToggle2}
|
|
132
|
+
id="toggle-split-button-progress-text"
|
|
133
|
+
/>
|
|
134
|
+
}
|
|
135
|
+
isOpen={isOpen2}
|
|
136
|
+
dropdownItems={dropdownItems}
|
|
137
|
+
/>
|
|
138
|
+
</>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
@@ -16,6 +16,8 @@ export interface SimpleListProps extends Omit<React.HTMLProps<HTMLDivElement>, '
|
|
|
16
16
|
) => void;
|
|
17
17
|
/** Indicates whether component is controlled by its internal state */
|
|
18
18
|
isControlled?: boolean;
|
|
19
|
+
/** aria-label for the <ul> element that wraps the SimpleList items. */
|
|
20
|
+
'aria-label'?: string;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface SimpleListState {
|
|
@@ -57,7 +59,7 @@ export class SimpleList extends React.Component<SimpleListProps, SimpleListState
|
|
|
57
59
|
|
|
58
60
|
render() {
|
|
59
61
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
60
|
-
const { children, className, onSelect, isControlled, ...props } = this.props;
|
|
62
|
+
const { children, className, onSelect, isControlled, 'aria-label': ariaLabel, ...props } = this.props;
|
|
61
63
|
|
|
62
64
|
let isGrouped = false;
|
|
63
65
|
if (children) {
|
|
@@ -74,7 +76,7 @@ export class SimpleList extends React.Component<SimpleListProps, SimpleListState
|
|
|
74
76
|
>
|
|
75
77
|
<div className={css(styles.simpleList, className)} {...props}>
|
|
76
78
|
{isGrouped && children}
|
|
77
|
-
{!isGrouped && <ul>{children}</ul>}
|
|
79
|
+
{!isGrouped && <ul aria-label={ariaLabel}>{children}</ul>}
|
|
78
80
|
</div>
|
|
79
81
|
</SimpleListContext.Provider>
|
|
80
82
|
);
|
|
@@ -31,6 +31,11 @@ describe('SimpleList', () => {
|
|
|
31
31
|
expect(asFragment()).toMatchSnapshot();
|
|
32
32
|
});
|
|
33
33
|
|
|
34
|
+
test('renders aria-labelled content', () => {
|
|
35
|
+
const { asFragment } = render(<SimpleList aria-label="This is a simple list">{items}</SimpleList>);
|
|
36
|
+
expect(asFragment()).toMatchSnapshot();
|
|
37
|
+
});
|
|
38
|
+
|
|
34
39
|
test('renders grouped content', () => {
|
|
35
40
|
const { asFragment } = render(
|
|
36
41
|
<SimpleList>
|
|
@@ -1,5 +1,48 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
+
exports[`SimpleList renders aria-labelled content 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="pf-c-simple-list"
|
|
7
|
+
>
|
|
8
|
+
<ul
|
|
9
|
+
aria-label="This is a simple list"
|
|
10
|
+
>
|
|
11
|
+
<li
|
|
12
|
+
class=""
|
|
13
|
+
>
|
|
14
|
+
<button
|
|
15
|
+
class="pf-c-simple-list__item-link"
|
|
16
|
+
type="button"
|
|
17
|
+
>
|
|
18
|
+
Item 1
|
|
19
|
+
</button>
|
|
20
|
+
</li>
|
|
21
|
+
<li
|
|
22
|
+
class=""
|
|
23
|
+
>
|
|
24
|
+
<button
|
|
25
|
+
class="pf-c-simple-list__item-link"
|
|
26
|
+
type="button"
|
|
27
|
+
>
|
|
28
|
+
Item 2
|
|
29
|
+
</button>
|
|
30
|
+
</li>
|
|
31
|
+
<li
|
|
32
|
+
class=""
|
|
33
|
+
>
|
|
34
|
+
<button
|
|
35
|
+
class="pf-c-simple-list__item-link"
|
|
36
|
+
type="button"
|
|
37
|
+
>
|
|
38
|
+
Item 3
|
|
39
|
+
</button>
|
|
40
|
+
</li>
|
|
41
|
+
</ul>
|
|
42
|
+
</div>
|
|
43
|
+
</DocumentFragment>
|
|
44
|
+
`;
|
|
45
|
+
|
|
3
46
|
exports[`SimpleList renders content 1`] = `
|
|
4
47
|
<DocumentFragment>
|
|
5
48
|
<div
|