@patternfly/react-core 4.237.5 → 4.237.8
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 +27 -0
- package/dist/esm/components/Checkbox/Checkbox.d.ts +7 -5
- package/dist/esm/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js +7 -3
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js +1 -1
- package/dist/esm/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/js/components/Checkbox/Checkbox.d.ts +7 -5
- package/dist/js/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/js/components/Checkbox/Checkbox.js +7 -3
- package/dist/js/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.d.ts.map +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js +1 -1
- package/dist/js/components/MenuToggle/MenuToggle.js.map +1 -1
- package/dist/umd/react-core.min.css +77 -77
- package/dist/umd/react-core.min.js +4 -4
- package/package.json +6 -6
- package/src/components/Button/examples/Button.md +3 -15
- package/src/components/Button/examples/ButtonAriaDisabled.tsx +15 -2
- package/src/components/Checkbox/Checkbox.tsx +16 -5
- package/src/components/Checkbox/examples/Checkbox.md +5 -0
- package/src/components/Checkbox/examples/CheckboxRequired.tsx +6 -0
- package/src/components/MenuToggle/MenuToggle.tsx +1 -0
- package/src/components/MenuToggle/__tests__/MenuToggle.test.tsx +27 -1
- package/src/components/TreeView/examples/TreeView.md +37 -19
- package/src/demos/Filters/FilterDemos.md +48 -0
- package/src/demos/Filters/examples/FilterCheckboxSelect.tsx +405 -0
- package/src/demos/Filters/examples/FilterSearchInput.tsx +331 -0
- package/src/demos/Filters/examples/FilterSingleSelect.tsx +392 -0
- package/src/components/Button/examples/ButtonAriaDisabledLinkTooltip.tsx +0 -10
- package/src/components/Button/examples/ButtonAriaDisabledTooltip.tsx +0 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.237.
|
|
3
|
+
"version": "4.237.8",
|
|
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",
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
"generate": "node scripts/copyStyles.js"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@patternfly/react-icons": "^4.88.
|
|
48
|
-
"@patternfly/react-styles": "^4.87.
|
|
49
|
-
"@patternfly/react-tokens": "^4.89.
|
|
47
|
+
"@patternfly/react-icons": "^4.88.8",
|
|
48
|
+
"@patternfly/react-styles": "^4.87.8",
|
|
49
|
+
"@patternfly/react-tokens": "^4.89.8",
|
|
50
50
|
"focus-trap": "6.9.2",
|
|
51
51
|
"react-dropzone": "9.0.0",
|
|
52
52
|
"tippy.js": "5.1.2",
|
|
53
53
|
"tslib": "^2.0.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@patternfly/patternfly": "4.
|
|
56
|
+
"@patternfly/patternfly": "4.215.0",
|
|
57
57
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
58
58
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
59
59
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^16.8.0 || ^17.0.0",
|
|
71
71
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "655ddf36fb109c26211e803531627a92841587d1"
|
|
74
74
|
}
|
|
@@ -96,21 +96,9 @@ Router links can be used for in-app linking in React environments to prevent pag
|
|
|
96
96
|
|
|
97
97
|
Buttons that are aria-disabled are similar to normal disabled buttons, except they can receive focus. Every button variant can be aria-disabled using the `isAriaDisabled` property.
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Aria-disabled with tooltip
|
|
103
|
-
|
|
104
|
-
Unlike normal disabled buttons, aria-disabled buttons can support tooltips.
|
|
105
|
-
|
|
106
|
-
```ts file="./ButtonAriaDisabledTooltip.tsx"
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Aria-disabled link as button with tooltip
|
|
110
|
-
|
|
111
|
-
Aria-disabled buttons can operate as links, which also support tooltips.
|
|
99
|
+
Unlike normal disabled buttons, aria-disabled buttons can support tooltips. Furthermore, aria-disabled buttons can operate as links, which also support tooltips.
|
|
112
100
|
|
|
113
|
-
```ts file="./
|
|
101
|
+
```ts file="./ButtonAriaDisabled.tsx"
|
|
114
102
|
```
|
|
115
103
|
|
|
116
104
|
### Button with count
|
|
@@ -118,4 +106,4 @@ Aria-disabled buttons can operate as links, which also support tooltips.
|
|
|
118
106
|
Buttons can display a `count` in the form of a badge to indicate some value or number by passing in the `countOptions` prop as a `BadgeCountObject` object. The `BadgeCountObject` object will handle `count`, `isRead`, and `className` props for the badge count.
|
|
119
107
|
|
|
120
108
|
```ts file="./ButtonWithCount.tsx" isBeta
|
|
121
|
-
```
|
|
109
|
+
```
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Button } from '@patternfly/react-core';
|
|
2
|
+
import { Button, Tooltip } from '@patternfly/react-core';
|
|
3
3
|
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
4
4
|
import PlusCircleIcon from '@patternfly/react-icons/dist/esm/icons/plus-circle-icon';
|
|
5
5
|
|
|
6
6
|
export const ButtonAriaDisabled: React.FunctionComponent = () => (
|
|
7
7
|
<React.Fragment>
|
|
8
|
-
<Button isAriaDisabled>Primary aria disabled</Button>
|
|
8
|
+
<Button isAriaDisabled>Primary aria disabled</Button>
|
|
9
|
+
<Button isAriaDisabled>Secondary aria disabled</Button>{' '}
|
|
9
10
|
<Button variant="secondary" isDanger isAriaDisabled>
|
|
10
11
|
Danger secondary aria disabled
|
|
11
12
|
</Button>{' '}
|
|
@@ -35,5 +36,17 @@ export const ButtonAriaDisabled: React.FunctionComponent = () => (
|
|
|
35
36
|
<Button isAriaDisabled variant="control">
|
|
36
37
|
Control aria disabled
|
|
37
38
|
</Button>
|
|
39
|
+
<br />
|
|
40
|
+
<br />
|
|
41
|
+
<Tooltip content="Aria-disabled buttons are like disabled buttons, but focusable. Allows for tooltip support.">
|
|
42
|
+
<Button isAriaDisabled variant="secondary">
|
|
43
|
+
Secondary button to core docs
|
|
44
|
+
</Button>
|
|
45
|
+
</Tooltip>{' '}
|
|
46
|
+
<Tooltip content="Aria-disabled link as button with tooltip">
|
|
47
|
+
<Button component="a" isAriaDisabled href="https://pf4.patternfly.org/" target="_blank" variant="tertiary">
|
|
48
|
+
Tertiary link as button to core docs
|
|
49
|
+
</Button>
|
|
50
|
+
</Tooltip>
|
|
38
51
|
</React.Fragment>
|
|
39
52
|
);
|
|
@@ -3,20 +3,23 @@ import styles from '@patternfly/react-styles/css/components/Check/check';
|
|
|
3
3
|
import { css } from '@patternfly/react-styles';
|
|
4
4
|
import { PickOptional } from '../../helpers/typeUtils';
|
|
5
5
|
import { getDefaultOUIAId, getOUIAProps, OUIAProps } from '../../helpers';
|
|
6
|
+
import { ASTERISK } from '../../helpers/htmlConstants';
|
|
6
7
|
|
|
7
8
|
export interface CheckboxProps
|
|
8
9
|
extends Omit<React.HTMLProps<HTMLInputElement>, 'type' | 'onChange' | 'disabled' | 'label'>,
|
|
9
10
|
OUIAProps {
|
|
10
|
-
/** Additional classes added to the
|
|
11
|
+
/** Additional classes added to the checkbox. */
|
|
11
12
|
className?: string;
|
|
12
|
-
/** Flag to show if the
|
|
13
|
+
/** Flag to show if the checkbox selection is valid or invalid. */
|
|
13
14
|
isValid?: boolean;
|
|
14
|
-
/** Flag to show if the
|
|
15
|
+
/** Flag to show if the checkbox is disabled. */
|
|
15
16
|
isDisabled?: boolean;
|
|
16
|
-
/** Flag to show if the
|
|
17
|
+
/** Flag to show if the checkbox is required. */
|
|
18
|
+
isRequired?: boolean;
|
|
19
|
+
/** Flag to show if the checkbox is checked. If null, the checkbox will be indeterminate (partially checked). */
|
|
17
20
|
isChecked?: boolean | null;
|
|
18
21
|
checked?: boolean;
|
|
19
|
-
/** A callback for when the
|
|
22
|
+
/** A callback for when the checkbox selection changes. */
|
|
20
23
|
onChange?: (checked: boolean, event: React.FormEvent<HTMLInputElement>) => void;
|
|
21
24
|
/** Label text of the checkbox. */
|
|
22
25
|
label?: React.ReactNode;
|
|
@@ -45,6 +48,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
|
|
|
45
48
|
className: '',
|
|
46
49
|
isValid: true,
|
|
47
50
|
isDisabled: false,
|
|
51
|
+
isRequired: false,
|
|
48
52
|
isChecked: false,
|
|
49
53
|
onChange: defaultOnChange,
|
|
50
54
|
ouiaSafe: true,
|
|
@@ -69,6 +73,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
|
|
|
69
73
|
onChange,
|
|
70
74
|
isValid,
|
|
71
75
|
isDisabled,
|
|
76
|
+
isRequired,
|
|
72
77
|
isChecked,
|
|
73
78
|
label,
|
|
74
79
|
checked,
|
|
@@ -106,6 +111,7 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
|
|
|
106
111
|
aria-invalid={!isValid}
|
|
107
112
|
aria-label={ariaLabel}
|
|
108
113
|
disabled={isDisabled}
|
|
114
|
+
required={isRequired}
|
|
109
115
|
ref={elem => elem && (elem.indeterminate = isChecked === null)}
|
|
110
116
|
{...checkedProps}
|
|
111
117
|
{...getOUIAProps(Checkbox.displayName, ouiaId !== undefined ? ouiaId : this.state.ouiaStateId, ouiaSafe)}
|
|
@@ -113,6 +119,11 @@ export class Checkbox extends React.Component<CheckboxProps, CheckboxState> {
|
|
|
113
119
|
{label && (
|
|
114
120
|
<label className={css(styles.checkLabel, isDisabled && styles.modifiers.disabled)} htmlFor={props.id}>
|
|
115
121
|
{label}
|
|
122
|
+
{isRequired && (
|
|
123
|
+
<span className={css(styles.checkLabelRequired)} aria-hidden="true">
|
|
124
|
+
{ASTERISK}
|
|
125
|
+
</span>
|
|
126
|
+
)}
|
|
116
127
|
</label>
|
|
117
128
|
)}
|
|
118
129
|
{description && <span className={css(styles.checkDescription)}>{description}</span>}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { render } from '@testing-library/react';
|
|
3
2
|
import { MenuToggle } from '../MenuToggle';
|
|
3
|
+
import { MenuToggleCheckbox } from '../MenuToggleCheckbox';
|
|
4
4
|
import { Badge } from '../../Badge';
|
|
5
5
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
6
6
|
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
7
|
+
import userEvent from '@testing-library/user-event';
|
|
8
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
7
9
|
|
|
8
10
|
describe('menu toggle', () => {
|
|
9
11
|
test('renders successfully', () => {
|
|
@@ -54,4 +56,28 @@ describe('menu toggle', () => {
|
|
|
54
56
|
const { asFragment } = render(<MenuToggle badge={<Badge>badge</Badge>}>Toggle</MenuToggle>);
|
|
55
57
|
expect(asFragment()).toMatchSnapshot();
|
|
56
58
|
});
|
|
59
|
+
|
|
60
|
+
test('split toggle passes onClick', async () => {
|
|
61
|
+
const mockClick = jest.fn();
|
|
62
|
+
const user = userEvent.setup();
|
|
63
|
+
|
|
64
|
+
render(<MenuToggle
|
|
65
|
+
onClick={mockClick}
|
|
66
|
+
splitButtonOptions={{
|
|
67
|
+
items: [
|
|
68
|
+
<MenuToggleCheckbox
|
|
69
|
+
id="split-button-checkbox-with-text-disabled-example"
|
|
70
|
+
key="split-checkbox-with-text-disabled"
|
|
71
|
+
aria-label="Select all"
|
|
72
|
+
>
|
|
73
|
+
10 selected
|
|
74
|
+
</MenuToggleCheckbox>
|
|
75
|
+
]
|
|
76
|
+
}}
|
|
77
|
+
aria-label="Menu toggle with checkbox split button and text"
|
|
78
|
+
/>);
|
|
79
|
+
|
|
80
|
+
await user.click(screen.getByRole(`button`) as Element);
|
|
81
|
+
expect(mockClick).toHaveBeenCalled();
|
|
82
|
+
});
|
|
57
83
|
});
|
|
@@ -20,12 +20,15 @@ class DefaultTreeView extends React.Component {
|
|
|
20
20
|
constructor(props) {
|
|
21
21
|
super(props);
|
|
22
22
|
|
|
23
|
-
this.state = { activeItems:
|
|
23
|
+
this.state = { activeItems: [], allExpanded: null };
|
|
24
24
|
|
|
25
25
|
this.onSelect = (evt, treeViewItem) => {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
// Ignore folders for selection
|
|
27
|
+
if (treeViewItem && !treeViewItem.children) {
|
|
28
|
+
this.setState({
|
|
29
|
+
activeItems: [treeViewItem]
|
|
30
|
+
});
|
|
31
|
+
}
|
|
29
32
|
};
|
|
30
33
|
|
|
31
34
|
this.onToggle = evt => {
|
|
@@ -288,9 +291,12 @@ class SearchTreeView extends React.Component {
|
|
|
288
291
|
this.state = { activeItems: {}, filteredItems: this.options, isFiltered: null };
|
|
289
292
|
|
|
290
293
|
this.onSelect = (evt, treeViewItem) => {
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
+
// Ignore folders for selection
|
|
295
|
+
if (treeViewItem && !treeViewItem.children) {
|
|
296
|
+
this.setState({
|
|
297
|
+
activeItems: [treeViewItem]
|
|
298
|
+
});
|
|
299
|
+
}
|
|
294
300
|
};
|
|
295
301
|
|
|
296
302
|
this.onSearch = evt => {
|
|
@@ -575,9 +581,12 @@ class IconTreeView extends React.Component {
|
|
|
575
581
|
this.state = { activeItems: {} };
|
|
576
582
|
|
|
577
583
|
this.onSelect = (evt, treeViewItem) => {
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
584
|
+
// Ignore folders for selection
|
|
585
|
+
if (treeViewItem && !treeViewItem.children) {
|
|
586
|
+
this.setState({
|
|
587
|
+
activeItems: [treeViewItem]
|
|
588
|
+
});
|
|
589
|
+
}
|
|
581
590
|
};
|
|
582
591
|
}
|
|
583
592
|
|
|
@@ -668,9 +677,12 @@ class BadgesTreeView extends React.Component {
|
|
|
668
677
|
this.state = { activeItems: {} };
|
|
669
678
|
|
|
670
679
|
this.onSelect = (evt, treeViewItem) => {
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
680
|
+
// Ignore folders for selection
|
|
681
|
+
if (treeViewItem && !treeViewItem.children) {
|
|
682
|
+
this.setState({
|
|
683
|
+
activeItems: [treeViewItem]
|
|
684
|
+
});
|
|
685
|
+
}
|
|
674
686
|
};
|
|
675
687
|
}
|
|
676
688
|
|
|
@@ -753,9 +765,12 @@ class CustomBadgesTreeView extends React.Component {
|
|
|
753
765
|
this.state = { activeItems: {} };
|
|
754
766
|
|
|
755
767
|
this.onSelect = (evt, treeViewItem) => {
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
768
|
+
// Ignore folders for selection
|
|
769
|
+
if (treeViewItem && !treeViewItem.children) {
|
|
770
|
+
this.setState({
|
|
771
|
+
activeItems: [treeViewItem]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
759
774
|
};
|
|
760
775
|
}
|
|
761
776
|
|
|
@@ -853,9 +868,12 @@ class IconTreeView extends React.Component {
|
|
|
853
868
|
this.state = { activeItems: {}, isOpen: false };
|
|
854
869
|
|
|
855
870
|
this.onSelect = (evt, treeViewItem) => {
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
871
|
+
// Ignore folders for selection
|
|
872
|
+
if (treeViewItem && !treeViewItem.children) {
|
|
873
|
+
this.setState({
|
|
874
|
+
activeItems: [treeViewItem]
|
|
875
|
+
});
|
|
876
|
+
}
|
|
859
877
|
};
|
|
860
878
|
|
|
861
879
|
this.onToggle = isOpen => {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Filters
|
|
3
|
+
section: demos
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Popper,
|
|
8
|
+
SearchInput,
|
|
9
|
+
Toolbar,
|
|
10
|
+
ToolbarContent,
|
|
11
|
+
ToolbarItem,
|
|
12
|
+
Menu,
|
|
13
|
+
MenuContent,
|
|
14
|
+
MenuList,
|
|
15
|
+
MenuItem,
|
|
16
|
+
MenuToggle,
|
|
17
|
+
MenuToggleCheckbox,
|
|
18
|
+
ToolbarGroup,
|
|
19
|
+
ToolbarFilter,
|
|
20
|
+
Badge,
|
|
21
|
+
Pagination,
|
|
22
|
+
EmptyState,
|
|
23
|
+
EmptyStateIcon,
|
|
24
|
+
Title,
|
|
25
|
+
EmptyStateBody,
|
|
26
|
+
EmptyStatePrimary,
|
|
27
|
+
Button
|
|
28
|
+
} from '@patternfly/react-core';
|
|
29
|
+
import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
|
|
30
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
31
|
+
import { TableComposable, Thead, Tr, Th, Tbody, Td } from '@patternfly/react-table';
|
|
32
|
+
|
|
33
|
+
## Demos
|
|
34
|
+
|
|
35
|
+
### Filtering with a search input
|
|
36
|
+
|
|
37
|
+
```ts file="./examples/FilterSearchInput.tsx"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Filtering with a single select
|
|
41
|
+
|
|
42
|
+
```ts file="./examples/FilterSingleSelect.tsx"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Filtering with a checkbox select
|
|
46
|
+
|
|
47
|
+
```ts file="./examples/FilterCheckboxSelect.tsx"
|
|
48
|
+
```
|