@patternfly/react-core 4.227.3 → 4.227.6

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/umd/react-core.min.css +69 -69
  3. package/package.json +5 -5
  4. package/src/components/Menu/examples/Menu.md +19 -1290
  5. package/src/components/Menu/examples/MenuBasic.tsx +51 -0
  6. package/src/components/Menu/examples/MenuFilteringWithTextInput.tsx +52 -0
  7. package/src/components/Menu/examples/MenuOptionMultiSelect.tsx +30 -0
  8. package/src/components/Menu/examples/MenuOptionSingleSelect.tsx +27 -0
  9. package/src/components/Menu/examples/MenuScrollable.tsx +48 -0
  10. package/src/components/Menu/examples/MenuScrollableCustomMenuHeight.tsx +48 -0
  11. package/src/components/Menu/examples/MenuWithActions.tsx +75 -0
  12. package/src/components/Menu/examples/MenuWithCheckbox.tsx +2 -2
  13. package/src/components/Menu/examples/MenuWithDescription.tsx +35 -0
  14. package/src/components/Menu/examples/{MenuDrilldown.tsx → MenuWithDrilldown.tsx} +1 -1
  15. package/src/components/Menu/examples/MenuWithDrilldownBreadcrumbs.tsx +331 -0
  16. package/src/components/Menu/examples/{MenuDrilldownInitialState.tsx → MenuWithDrilldownInitialState.tsx} +0 -0
  17. package/src/components/Menu/examples/{MenuDrilldownSubmenuFunctions.tsx → MenuWithDrilldownSubmenuFunctions.tsx} +1 -1
  18. package/src/components/Menu/examples/MenuWithFavorites.tsx +104 -0
  19. package/src/components/Menu/examples/MenuWithFooter.tsx +40 -0
  20. package/src/components/Menu/examples/MenuWithIcons.tsx +33 -0
  21. package/src/components/Menu/examples/MenuWithLinks.tsx +30 -0
  22. package/src/components/Menu/examples/MenuWithSeparators.tsx +26 -0
  23. package/src/components/Menu/examples/MenuWithTitledGroups.tsx +46 -0
  24. package/src/components/Menu/examples/MenuWithViewMore.tsx +118 -0
  25. package/src/components/Radio/examples/Radio.md +12 -68
  26. package/src/components/Radio/examples/RadioControlled.tsx +21 -0
  27. package/src/components/Radio/examples/RadioDisabled.tsx +15 -0
  28. package/src/components/Radio/examples/RadioLabelWraps.tsx +6 -0
  29. package/src/components/Radio/examples/RadioReversed.tsx +6 -0
  30. package/src/components/Radio/examples/RadioStandaloneInput.tsx +6 -0
  31. package/src/components/Radio/examples/RadioUncontrolled.tsx +6 -0
  32. package/src/components/Radio/examples/RadioWithBody.tsx +6 -0
  33. package/src/components/Radio/examples/RadioWithDescription.tsx +11 -0
  34. package/src/components/Radio/examples/RadioWithDescriptionAndBody.tsx +12 -0
  35. package/src/components/Spinner/examples/Spinner.md +3 -21
  36. package/src/components/Spinner/examples/SpinnerBasic.tsx +4 -0
  37. package/src/components/Spinner/examples/SpinnerCustomSize.tsx +6 -0
  38. package/src/components/Spinner/examples/SpinnerSizeVariations.tsx +11 -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
- ```js
12
- import React from 'react';
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
- <Radio label="Uncontrolled radio example" id="radio-uncontrolled" name="radio-2" />
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
- <Radio isLabelBeforeButton label="Reversed radio example" id="radio-reversed" name="radio-3" />
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
- <Radio isLabelWrapped label="Label wraps input example" id="radio-label-wraps-input" name="radio-4" />
28
+ ```ts file="./RadioLabelWraps.tsx"
67
29
  ```
68
30
 
69
31
  ### Disabled
70
- ```js
71
- import React from 'react';
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
- <Radio id="radio-with-description" label="Radio with description example" 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." />
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
- <Radio id="radio-with-body" label="Radio with body" body="This is where custom content goes." />
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
- <Radio id="radio-description-body" label="Radio with description and body" 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." body="This is where custom content goes." />
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
- <Radio id="radio-standalone" aria-label="Standalone input" name="exampleRadioStandalone"/>
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,6 @@
1
+ import React from 'react';
2
+ import { Radio } from '@patternfly/react-core';
3
+
4
+ export const RadioLabelWraps: React.FunctionComponent = () => (
5
+ <Radio isLabelWrapped label="Label wraps input example" id="radio-label-wraps-input" name="radio-4" />
6
+ );
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Radio } from '@patternfly/react-core';
3
+
4
+ export const RadioReversed: React.FunctionComponent = () => (
5
+ <Radio isLabelBeforeButton label="Reversed radio example" id="radio-reversed" name="radio-3" />
6
+ );
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Radio } from '@patternfly/react-core';
3
+
4
+ export const RadioStandaloneInput: React.FunctionComponent = () => (
5
+ <Radio id="radio-standalone" aria-label="Standalone input" name="exampleRadioStandalone" />
6
+ );
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Radio } from '@patternfly/react-core';
3
+
4
+ export const RadioUncontrolled: React.FunctionComponent = () => (
5
+ <Radio label="Uncontrolled radio example" id="radio-uncontrolled" name="radio-2" />
6
+ );
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Radio } from '@patternfly/react-core';
3
+
4
+ export const RadioWithBody: React.FunctionComponent = () => (
5
+ <Radio id="radio-with-body" label="Radio with body" name="radio-8" body="This is where custom content goes." />
6
+ );
@@ -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
+ );
@@ -7,31 +7,13 @@ propComponents: ['Spinner']
7
7
 
8
8
  ## Examples
9
9
  ### Basic
10
- ```js
11
- import React from 'react';
12
- import { Spinner } from '@patternfly/react-core';
13
-
14
- <Spinner isSVG aria-label="Contents of the basic example"/>
10
+ ```ts file="./SpinnerBasic.tsx"
15
11
  ```
16
12
 
17
13
  ### Size variations
18
- ```js
19
- import React from 'react';
20
- import { Spinner } from '@patternfly/react-core';
21
-
22
- <React.Fragment>
23
- <Spinner isSVG size="sm" aria-label="Contents of the small example"/>
24
- <Spinner isSVG size="md" aria-label="Contents of the medium example"/>
25
- <Spinner isSVG size="lg" aria-label="Contents of the large example"/>
26
- <Spinner isSVG size="xl" aria-label="Contents of the extra large example"/>
27
- </React.Fragment>
14
+ ```ts file="./SpinnerSizeVariations.tsx"
28
15
  ```
29
16
 
30
17
  ### Custom size
31
- ```js
32
- import React from 'react';
33
- import { Spinner } from '@patternfly/react-core';
34
-
35
- <Spinner isSVG diameter="80px" aria-label="Contents of the custom size example"/>
18
+ ```ts file="./SpinnerCustomSize.tsx"
36
19
  ```
37
-
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { Spinner } from '@patternfly/react-core';
3
+
4
+ export const SpinnerBasic: React.FunctionComponent = () => <Spinner isSVG aria-label="Contents of the basic example" />;
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { Spinner } from '@patternfly/react-core';
3
+
4
+ export const SpinnerCustomSize: React.FunctionComponent = () => (
5
+ <Spinner isSVG diameter="80px" aria-label="Contents of the custom size example" />
6
+ );
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { Spinner } from '@patternfly/react-core';
3
+
4
+ export const SpinnerSizeVariations: React.FunctionComponent = () => (
5
+ <React.Fragment>
6
+ <Spinner isSVG size="sm" aria-label="Contents of the small example" />
7
+ <Spinner isSVG size="md" aria-label="Contents of the medium example" />
8
+ <Spinner isSVG size="lg" aria-label="Contents of the large example" />
9
+ <Spinner isSVG size="xl" aria-label="Contents of the extra large example" />
10
+ </React.Fragment>
11
+ );