@patternfly/react-core 4.227.2 → 4.227.5
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 +24 -0
- package/dist/esm/components/DataList/DataList.d.ts +0 -2
- package/dist/esm/components/DataList/DataList.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataList.js.map +1 -1
- package/dist/esm/components/DataList/DataListItem.d.ts.map +1 -1
- package/dist/esm/components/DataList/DataListItem.js +1 -2
- package/dist/esm/components/DataList/DataListItem.js.map +1 -1
- package/dist/js/components/DataList/DataList.d.ts +0 -2
- package/dist/js/components/DataList/DataList.d.ts.map +1 -1
- package/dist/js/components/DataList/DataList.js.map +1 -1
- package/dist/js/components/DataList/DataListItem.d.ts.map +1 -1
- package/dist/js/components/DataList/DataListItem.js +1 -2
- package/dist/js/components/DataList/DataListItem.js.map +1 -1
- package/dist/umd/react-core.js +1 -2
- package/dist/umd/react-core.min.css +3339 -3339
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/DataList/DataList.tsx +0 -2
- package/src/components/DataList/DataListItem.tsx +1 -3
- package/src/components/DataList/__tests__/DataList.test.tsx +14 -32
- package/src/components/DataList/examples/DataListSelectableRows.tsx +1 -1
- package/src/components/Menu/examples/Menu.md +19 -1290
- package/src/components/Menu/examples/MenuBasic.tsx +51 -0
- package/src/components/Menu/examples/MenuFilteringWithTextInput.tsx +52 -0
- package/src/components/Menu/examples/MenuOptionMultiSelect.tsx +30 -0
- package/src/components/Menu/examples/MenuOptionSingleSelect.tsx +27 -0
- package/src/components/Menu/examples/MenuScrollable.tsx +48 -0
- package/src/components/Menu/examples/MenuScrollableCustomMenuHeight.tsx +48 -0
- package/src/components/Menu/examples/MenuWithActions.tsx +75 -0
- package/src/components/Menu/examples/MenuWithCheckbox.tsx +2 -2
- package/src/components/Menu/examples/MenuWithDescription.tsx +35 -0
- package/src/components/Menu/examples/{MenuDrilldown.tsx → MenuWithDrilldown.tsx} +1 -1
- package/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx +331 -0
- package/src/components/Menu/examples/{MenuDrilldownInitialState.tsx → MenuWithDrilldownInitialState.tsx} +0 -0
- package/src/components/Menu/examples/{MenuDrilldownSubmenuFunctions.tsx → MenuWithDrilldownSubmenuFunctions.tsx} +1 -1
- package/src/components/Menu/examples/MenuWithFavorites.tsx +104 -0
- package/src/components/Menu/examples/MenuWithFooter.tsx +40 -0
- package/src/components/Menu/examples/MenuWithIcons.tsx +33 -0
- package/src/components/Menu/examples/MenuWithLinks.tsx +30 -0
- package/src/components/Menu/examples/MenuWithSeparators.tsx +26 -0
- package/src/components/Menu/examples/MenuWithTitledGroups.tsx +46 -0
- package/src/components/Menu/examples/MenuWithViewMore.tsx +118 -0
- package/src/components/Radio/examples/Radio.md +12 -68
- package/src/components/Radio/examples/RadioControlled.tsx +21 -0
- package/src/components/Radio/examples/RadioDisabled.tsx +15 -0
- package/src/components/Radio/examples/RadioLabelWraps.tsx +6 -0
- package/src/components/Radio/examples/RadioReversed.tsx +6 -0
- package/src/components/Radio/examples/RadioStandaloneInput.tsx +6 -0
- package/src/components/Radio/examples/RadioUncontrolled.tsx +6 -0
- package/src/components/Radio/examples/RadioWithBody.tsx +6 -0
- package/src/components/Radio/examples/RadioWithDescription.tsx +11 -0
- package/src/components/Radio/examples/RadioWithDescriptionAndBody.tsx +12 -0
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Menu, MenuList, MenuItem, MenuContent, Spinner } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const MenuWithViewMore: React.FunctionComponent = () => {
|
|
5
|
+
const [activeItem, setActiveItem] = React.useState<number | string>(0);
|
|
6
|
+
const [isLoading, setIsLoading] = React.useState(false);
|
|
7
|
+
const [numOptions, setNumOptions] = React.useState(3);
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
|
+
const [menuOptions, setMenuOptions] = React.useState([
|
|
10
|
+
<MenuItem key={0} itemId={'view-more-0'}>
|
|
11
|
+
Action
|
|
12
|
+
</MenuItem>,
|
|
13
|
+
<MenuItem
|
|
14
|
+
key={1}
|
|
15
|
+
itemId={'view-more-1'}
|
|
16
|
+
to="#default-link2"
|
|
17
|
+
// just for demo so that navigation is not triggered
|
|
18
|
+
onClick={event => event.preventDefault()}
|
|
19
|
+
>
|
|
20
|
+
Link
|
|
21
|
+
</MenuItem>,
|
|
22
|
+
<MenuItem key={2} itemId="view-more-2" isDisabled>
|
|
23
|
+
Disabled action
|
|
24
|
+
</MenuItem>,
|
|
25
|
+
<MenuItem key={3} itemId="view-more-3" isDisabled to="#default-link4">
|
|
26
|
+
Disabled link
|
|
27
|
+
</MenuItem>,
|
|
28
|
+
<MenuItem key={4} itemId="view-more-4">
|
|
29
|
+
Action 2
|
|
30
|
+
</MenuItem>,
|
|
31
|
+
<MenuItem key={5} itemId="view-more-5">
|
|
32
|
+
Action 3
|
|
33
|
+
</MenuItem>,
|
|
34
|
+
<MenuItem key={6} itemId="view-more-6">
|
|
35
|
+
Action 4
|
|
36
|
+
</MenuItem>,
|
|
37
|
+
<MenuItem key={7} itemId="view-more-7">
|
|
38
|
+
Action 5
|
|
39
|
+
</MenuItem>,
|
|
40
|
+
<MenuItem key={8} itemId="view-more-8">
|
|
41
|
+
Final option
|
|
42
|
+
</MenuItem>
|
|
43
|
+
]);
|
|
44
|
+
const [visibleOptions, setVisibleOptions] = React.useState(menuOptions.slice(0, numOptions));
|
|
45
|
+
|
|
46
|
+
const activeItemRef = React.useRef<HTMLElement>(null);
|
|
47
|
+
const viewMoreRef = React.useRef<HTMLElement>(null);
|
|
48
|
+
|
|
49
|
+
React.useEffect(() => {
|
|
50
|
+
activeItemRef.current?.focus();
|
|
51
|
+
}, [visibleOptions]);
|
|
52
|
+
|
|
53
|
+
const onSelect = (_event: React.MouseEvent<Element, MouseEvent> | undefined, itemId: number | string | undefined) => {
|
|
54
|
+
// eslint-disable-next-line no-console
|
|
55
|
+
console.log(`clicked ${itemId}`);
|
|
56
|
+
setActiveItem(itemId as string);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const simulateNetworkCall = (networkCallback: () => void) => {
|
|
60
|
+
setTimeout(networkCallback, 2000);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const getNextValidItem = (startingIndex: number, maxLength: number) => {
|
|
64
|
+
let validItem;
|
|
65
|
+
for (let i = startingIndex; i < maxLength; i++) {
|
|
66
|
+
if (menuOptions[i].props.isDisabled) {
|
|
67
|
+
continue;
|
|
68
|
+
} else {
|
|
69
|
+
validItem = menuOptions[i];
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return validItem;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const loadMoreOptions = () => {
|
|
77
|
+
const newLength = numOptions + 3 <= menuOptions.length ? numOptions + 3 : menuOptions.length;
|
|
78
|
+
const prevPosition = numOptions;
|
|
79
|
+
const nextValidItem = getNextValidItem(prevPosition, newLength);
|
|
80
|
+
|
|
81
|
+
setNumOptions(newLength);
|
|
82
|
+
setIsLoading(false);
|
|
83
|
+
setActiveItem(nextValidItem.props.itemId);
|
|
84
|
+
setVisibleOptions(menuOptions.slice(0, newLength));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const onViewMoreClick = () => {
|
|
88
|
+
setIsLoading(true);
|
|
89
|
+
simulateNetworkCall(() => {
|
|
90
|
+
loadMoreOptions();
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Menu activeItemId={activeItem} onSelect={onSelect}>
|
|
96
|
+
<MenuContent>
|
|
97
|
+
<MenuList>
|
|
98
|
+
{visibleOptions.map(option => {
|
|
99
|
+
const props = option.props;
|
|
100
|
+
|
|
101
|
+
return <MenuItem key={option.key} ref={props.itemId === activeItem ? activeItemRef : null} {...props} />;
|
|
102
|
+
})}
|
|
103
|
+
{numOptions !== menuOptions.length && (
|
|
104
|
+
<MenuItem
|
|
105
|
+
{...(!isLoading && { isLoadButton: true })}
|
|
106
|
+
{...(isLoading && { isLoading: true })}
|
|
107
|
+
onClick={onViewMoreClick}
|
|
108
|
+
itemId="loader"
|
|
109
|
+
ref={viewMoreRef}
|
|
110
|
+
>
|
|
111
|
+
{isLoading ? <Spinner size="lg" /> : 'View more'}
|
|
112
|
+
</MenuItem>
|
|
113
|
+
)}
|
|
114
|
+
</MenuList>
|
|
115
|
+
</MenuContent>
|
|
116
|
+
</Menu>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
@@ -7,104 +7,48 @@ ouia: true
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## Examples
|
|
10
|
+
|
|
10
11
|
### Controlled
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
import { Radio } from '@patternfly/react-core';
|
|
14
|
-
|
|
15
|
-
class ControlledRadio extends React.Component {
|
|
16
|
-
constructor(props) {
|
|
17
|
-
super(props);
|
|
18
|
-
this.state = {
|
|
19
|
-
check1: false,
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
this.handleChange = (_, event) => {
|
|
23
|
-
const { value } = event.currentTarget;
|
|
24
|
-
this.setState({ [value]: true });
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
render() {
|
|
29
|
-
return (
|
|
30
|
-
<React.Fragment>
|
|
31
|
-
<Radio
|
|
32
|
-
isChecked={this.state.check1}
|
|
33
|
-
name="radio-1"
|
|
34
|
-
onChange={this.handleChange}
|
|
35
|
-
label="Controlled radio"
|
|
36
|
-
id="radio-controlled"
|
|
37
|
-
value="check1"
|
|
38
|
-
/>
|
|
39
|
-
</React.Fragment>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
12
|
+
|
|
13
|
+
```ts file="./RadioControlled.tsx"
|
|
43
14
|
```
|
|
44
15
|
|
|
45
16
|
### Uncontrolled
|
|
46
|
-
```js
|
|
47
|
-
import React from 'react';
|
|
48
|
-
import { Radio } from '@patternfly/react-core';
|
|
49
17
|
|
|
50
|
-
|
|
18
|
+
```ts file="./RadioUncontrolled.tsx"
|
|
51
19
|
```
|
|
52
20
|
|
|
53
21
|
### Reversed
|
|
54
|
-
```js
|
|
55
|
-
import React from 'react';
|
|
56
|
-
import { Radio } from '@patternfly/react-core';
|
|
57
22
|
|
|
58
|
-
|
|
23
|
+
```ts file="./RadioReversed.tsx"
|
|
59
24
|
```
|
|
60
25
|
|
|
61
26
|
### Label wraps
|
|
62
|
-
```js
|
|
63
|
-
import React from 'react';
|
|
64
|
-
import { Radio } from '@patternfly/react-core';
|
|
65
27
|
|
|
66
|
-
|
|
28
|
+
```ts file="./RadioLabelWraps.tsx"
|
|
67
29
|
```
|
|
68
30
|
|
|
69
31
|
### Disabled
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
import { Radio } from '@patternfly/react-core';
|
|
73
|
-
|
|
74
|
-
<React.Fragment>
|
|
75
|
-
<Radio id="radio-disabled" label="Disabled radio example" isDisabled name="radio-5" />
|
|
76
|
-
<Radio id="radio-disabled-checked" defaultChecked label="Disabled and checked radio example" isDisabled name="radio-6" />
|
|
77
|
-
</React.Fragment>
|
|
32
|
+
|
|
33
|
+
```ts file="./RadioDisabled.tsx"
|
|
78
34
|
```
|
|
79
35
|
|
|
80
36
|
### With description
|
|
81
|
-
```js
|
|
82
|
-
import React from 'react';
|
|
83
|
-
import { Radio } from '@patternfly/react-core';
|
|
84
37
|
|
|
85
|
-
|
|
38
|
+
```ts file="./RadioWithDescription.tsx"
|
|
86
39
|
```
|
|
87
40
|
|
|
88
41
|
### With body
|
|
89
|
-
```js
|
|
90
|
-
import React from 'react';
|
|
91
|
-
import { Radio } from '@patternfly/react-core';
|
|
92
42
|
|
|
93
|
-
|
|
43
|
+
```ts file="./RadioWithBody.tsx"
|
|
94
44
|
```
|
|
95
45
|
|
|
96
46
|
### With description and body
|
|
97
|
-
```js
|
|
98
|
-
import React from 'react';
|
|
99
|
-
import { Radio } from '@patternfly/react-core';
|
|
100
47
|
|
|
101
|
-
|
|
48
|
+
```ts file="./RadioWithDescriptionAndBody.tsx"
|
|
102
49
|
```
|
|
103
50
|
|
|
104
51
|
### Standalone input
|
|
105
|
-
```js
|
|
106
|
-
import React from 'react';
|
|
107
|
-
import { Radio } from '@patternfly/react-core';
|
|
108
52
|
|
|
109
|
-
|
|
53
|
+
```ts file="./RadioStandaloneInput.tsx"
|
|
110
54
|
```
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Radio } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const RadioControlled: React.FunctionComponent = () => {
|
|
5
|
+
const [check1, setCheck1] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleChange = () => {
|
|
8
|
+
setCheck1(true);
|
|
9
|
+
};
|
|
10
|
+
return (
|
|
11
|
+
<React.Fragment>
|
|
12
|
+
<Radio
|
|
13
|
+
isChecked={check1}
|
|
14
|
+
name="radio-1"
|
|
15
|
+
onChange={handleChange}
|
|
16
|
+
label="Controlled Radio"
|
|
17
|
+
id="radio-controlled"
|
|
18
|
+
></Radio>
|
|
19
|
+
</React.Fragment>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Radio } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const RadioDisabled: React.FunctionComponent = () => (
|
|
5
|
+
<React.Fragment>
|
|
6
|
+
<Radio id="radio-disabled" label="Disabled radio example" isDisabled name="radio-5" />
|
|
7
|
+
<Radio
|
|
8
|
+
id="radio-disabled-checked"
|
|
9
|
+
defaultChecked
|
|
10
|
+
label="Disabled and checked radio example"
|
|
11
|
+
isDisabled
|
|
12
|
+
name="radio-6"
|
|
13
|
+
/>
|
|
14
|
+
</React.Fragment>
|
|
15
|
+
);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Radio } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const RadioWithDescription: React.FunctionComponent = () => (
|
|
5
|
+
<Radio
|
|
6
|
+
id="radio-with-description"
|
|
7
|
+
label="Radio with description example"
|
|
8
|
+
name="radio-7"
|
|
9
|
+
description="Single-tenant cloud service hosted and managed by Red Hat that offers high-availability enterprise-grade clusters in a virtual private cloud on AWS or GCP."
|
|
10
|
+
/>
|
|
11
|
+
);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Radio } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const RadioWithDescriptionAndBody: React.FunctionComponent = () => (
|
|
5
|
+
<Radio
|
|
6
|
+
id="radio-description-body"
|
|
7
|
+
label="Radio with description and body"
|
|
8
|
+
description="Single-tenant cloud service hosted and managed by Red Hat that offers high-availability enterprise-grade clusters in a virtual private cloud on AWS or GCP."
|
|
9
|
+
body="This is where custom content goes."
|
|
10
|
+
name="radio-8"
|
|
11
|
+
/>
|
|
12
|
+
);
|