@patternfly/react-core 4.192.2 → 4.192.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.
- package/CHANGELOG.md +35 -0
- package/dist/esm/components/DatePicker/DatePicker.d.ts +2 -0
- package/dist/esm/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/esm/components/DatePicker/DatePicker.js +7 -3
- package/dist/esm/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/esm/components/Menu/MenuContent.js +1 -1
- package/dist/esm/components/Menu/MenuContent.js.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.d.ts +2 -0
- package/dist/js/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/js/components/DatePicker/DatePicker.js +7 -3
- package/dist/js/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/js/components/Menu/MenuContent.js +1 -1
- package/dist/js/components/Menu/MenuContent.js.map +1 -1
- package/dist/umd/react-core.css +910 -910
- package/dist/umd/react-core.js +8 -4
- package/dist/umd/react-core.min.css +72 -72
- package/dist/umd/react-core.min.js +2 -2
- package/index.d.ts +4 -0
- package/package.json +5 -5
- package/src/components/BackToTop/examples/BackToTop.css +3 -3
- package/src/components/BackToTop/examples/BackToTop.md +1 -6
- package/src/components/BackToTop/examples/BackToTopBasic.tsx +4 -0
- package/src/components/Backdrop/examples/Backdrop.md +3 -12
- package/src/components/Backdrop/examples/BackdropBasic.tsx +4 -0
- package/src/components/Backdrop/examples/BackdropSpinner.tsx +10 -0
- package/src/components/BackgroundImage/examples/BackgroundImage.md +2 -21
- package/src/components/BackgroundImage/examples/BackgroundImageBasic.tsx +15 -0
- package/src/components/Badge/examples/Badge.md +3 -24
- package/src/components/Badge/examples/BadgeRead.tsx +19 -0
- package/src/components/Badge/examples/BadgeUnread.tsx +8 -0
- package/src/components/Banner/examples/Banner.md +1 -14
- package/src/components/Banner/examples/BannerBasic.tsx +16 -0
- package/src/components/Brand/examples/Brand.md +3 -5
- package/src/components/Brand/examples/BrandBasic.tsx +5 -0
- package/src/components/Breadcrumb/examples/Breadcrumb.md +4 -105
- package/src/components/Breadcrumb/examples/BreadcrumbBasic.tsx +13 -0
- package/src/components/Breadcrumb/examples/BreadcrumbDropdown.tsx +53 -0
- package/src/components/Breadcrumb/examples/BreadcrumbWithHeading.tsx +12 -0
- package/src/components/Breadcrumb/examples/BreadcrumbWithoutHomeLink.tsx +15 -0
- package/src/components/Button/examples/ButtonAriaDisabled.tsx +33 -37
- package/src/components/Button/examples/ButtonCallToAction.tsx +8 -6
- package/src/components/Button/examples/ButtonDisabled.tsx +33 -37
- package/src/components/Button/examples/ButtonInlineSpanLink.tsx +2 -2
- package/src/components/Button/examples/ButtonLinks.tsx +6 -6
- package/src/components/Button/examples/ButtonProgress.tsx +8 -5
- package/src/components/Button/examples/ButtonSmall.tsx +9 -7
- package/src/components/Button/examples/ButtonTypes.tsx +4 -6
- package/src/components/Button/examples/ButtonVariations.tsx +31 -36
- package/src/components/DatePicker/DatePicker.tsx +10 -2
- package/src/components/DatePicker/examples/DatePicker.md +4 -1
- package/src/components/JumpLinks/examples/JumpLinks.md +0 -1
- package/src/components/Menu/MenuContent.tsx +2 -2
- package/src/components/Menu/examples/Menu.md +7 -7
- package/src/demos/ComposableMenu/ComposableMenu.md +88 -0
- package/src/demos/ComposableMenu/examples/ComposableActionsMenu.tsx +122 -0
- package/src/demos/ComposableMenu/examples/ComposableApplicationLauncher.tsx +282 -0
- package/src/demos/ComposableMenu/examples/ComposableContextSelector.tsx +202 -0
- package/src/demos/ComposableMenu/examples/ComposableDrilldownMenu.tsx +246 -0
- package/src/demos/ComposableMenu/examples/ComposableDropdwnVariants.tsx +235 -0
- package/src/demos/ComposableMenu/examples/ComposableFlyout.tsx +103 -0
- package/src/demos/ComposableMenu/examples/ComposableOptionsMenuVariants.tsx +94 -0
- package/src/demos/ComposableMenu/examples/ComposableSimpleDropdown.tsx +70 -0
- package/src/demos/ComposableMenu/examples/ComposableSimpleSelect.tsx +74 -0
- package/src/demos/ComposableMenu/examples/ComposableTreeViewMenu.tsx +240 -0
- package/src/demos/ComposableMenu/examples/avatarImg.svg +18 -0
- package/src/demos/ComposableMenu/examples/pf-logo-small.svg +23 -0
- package/src/demos/JumpLinks.md +0 -1
- package/src/demos/ComposableMenu.md +0 -1443
- package/src/demos/composable-menu.css +0 -3
|
@@ -1,43 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } 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 ButtonDisabled: React.FunctionComponent = () => (
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Control disabled
|
|
40
|
-
</Button>
|
|
41
|
-
</Flex>
|
|
42
|
-
</Flex>
|
|
7
|
+
<React.Fragment>
|
|
8
|
+
<Button isDisabled>Primary disabled</Button> <Button isDisabled>Secondary disabled</Button>{' '}
|
|
9
|
+
<Button variant="secondary" isDanger isDisabled>
|
|
10
|
+
Danger secondary disabled
|
|
11
|
+
</Button>{' '}
|
|
12
|
+
<Button isDisabled variant="tertiary">
|
|
13
|
+
Tertiary disabled
|
|
14
|
+
</Button>{' '}
|
|
15
|
+
<Button isDisabled variant="danger">
|
|
16
|
+
Danger disabled
|
|
17
|
+
</Button>{' '}
|
|
18
|
+
<Button isDisabled variant="warning">
|
|
19
|
+
Warning disabled
|
|
20
|
+
</Button>
|
|
21
|
+
<br />
|
|
22
|
+
<br />
|
|
23
|
+
<Button isDisabled variant="link" icon={<PlusCircleIcon />}>
|
|
24
|
+
Link disabled
|
|
25
|
+
</Button>{' '}
|
|
26
|
+
<Button isDisabled variant="link" isInline>
|
|
27
|
+
Inline link disabled
|
|
28
|
+
</Button>{' '}
|
|
29
|
+
<Button variant="link" isDanger isDisabled>
|
|
30
|
+
Danger link disabled
|
|
31
|
+
</Button>{' '}
|
|
32
|
+
<Button isDisabled variant="plain" aria-label="Action">
|
|
33
|
+
<TimesIcon />
|
|
34
|
+
</Button>{' '}
|
|
35
|
+
<Button isDisabled variant="control">
|
|
36
|
+
Control disabled
|
|
37
|
+
</Button>
|
|
38
|
+
</React.Fragment>
|
|
43
39
|
);
|
|
@@ -13,7 +13,7 @@ const handleKeydown = (event: React.KeyboardEvent<HTMLButtonElement>) => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
export const ButtonInlineSpanLink: React.FunctionComponent = () => (
|
|
16
|
-
|
|
16
|
+
<React.Fragment>
|
|
17
17
|
<p>
|
|
18
18
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
19
19
|
<Button variant="link" isInline component="span">
|
|
@@ -32,5 +32,5 @@ export const ButtonInlineSpanLink: React.FunctionComponent = () => (
|
|
|
32
32
|
</Button>
|
|
33
33
|
Pressing the Enter or Space keys on the inline link as span above demonstrates this by triggering an alert.
|
|
34
34
|
</p>
|
|
35
|
-
|
|
35
|
+
</React.Fragment>
|
|
36
36
|
);
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
4
|
export const ButtonLinks: React.FunctionComponent = () => (
|
|
5
|
-
<
|
|
5
|
+
<React.Fragment>
|
|
6
6
|
<Button component="a" href="https://pf4.patternfly.org/" target="_blank" variant="primary">
|
|
7
7
|
Link to core docs
|
|
8
|
-
</Button>
|
|
8
|
+
</Button>{' '}
|
|
9
9
|
<Button component="a" href="https://pf4.patternfly.org/" target="_blank" variant="secondary">
|
|
10
10
|
Secondary link to core docs
|
|
11
|
-
</Button>
|
|
11
|
+
</Button>{' '}
|
|
12
12
|
<Button isDisabled component="a" href="https://pf4.patternfly.org/" target="_blank" variant="tertiary">
|
|
13
13
|
Tertiary link to core docs
|
|
14
|
-
</Button>
|
|
14
|
+
</Button>{' '}
|
|
15
15
|
<Button component="a" href="https://pf4.patternfly.org/contribution/#modifiers" variant="link">
|
|
16
16
|
Jump to modifiers in contribution guidelines
|
|
17
17
|
</Button>
|
|
18
|
-
</
|
|
18
|
+
</React.Fragment>
|
|
19
19
|
);
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
4
|
export const ButtonProgress: React.FunctionComponent = () => {
|
|
5
5
|
const [isPrimaryLoading, setIsPrimaryLoading] = React.useState<boolean>(true);
|
|
6
6
|
const [isSecondaryLoading, setIsSecondaryLoading] = React.useState<boolean>(true);
|
|
7
7
|
|
|
8
8
|
return (
|
|
9
|
-
<
|
|
9
|
+
<React.Fragment>
|
|
10
10
|
<Button
|
|
11
|
+
spinnerAriaValueText={isPrimaryLoading ? 'Loading' : undefined}
|
|
11
12
|
isLoading={isPrimaryLoading}
|
|
12
13
|
variant="primary"
|
|
13
14
|
onClick={() => setIsPrimaryLoading(!isPrimaryLoading)}
|
|
14
15
|
{...(isPrimaryLoading && { spinnerAriaValueText: 'Loading' })}
|
|
15
16
|
>
|
|
16
17
|
{isPrimaryLoading ? 'Click to stop loading' : 'Click to start loading'}
|
|
17
|
-
</Button>
|
|
18
|
-
|
|
18
|
+
</Button>{' '}
|
|
19
19
|
<Button
|
|
20
|
+
spinnerAriaValueText={isSecondaryLoading ? 'Loading' : undefined}
|
|
20
21
|
isLoading={isSecondaryLoading}
|
|
21
22
|
variant="secondary"
|
|
22
23
|
onClick={() => setIsSecondaryLoading(!isSecondaryLoading)}
|
|
@@ -24,6 +25,8 @@ export const ButtonProgress: React.FunctionComponent = () => {
|
|
|
24
25
|
>
|
|
25
26
|
{isSecondaryLoading ? 'Click to stop loading' : 'Click to start loading'}
|
|
26
27
|
</Button>
|
|
27
|
-
|
|
28
|
+
<br />
|
|
29
|
+
<br />
|
|
30
|
+
</React.Fragment>
|
|
28
31
|
);
|
|
29
32
|
};
|
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
4
|
export const ButtonSmall: React.FunctionComponent = () => (
|
|
5
|
-
<
|
|
5
|
+
<React.Fragment>
|
|
6
6
|
<Button variant="primary" isSmall>
|
|
7
7
|
Primary
|
|
8
|
-
</Button>
|
|
8
|
+
</Button>{' '}
|
|
9
9
|
<Button variant="secondary" isSmall>
|
|
10
10
|
Secondary
|
|
11
|
-
</Button>
|
|
11
|
+
</Button>{' '}
|
|
12
12
|
<Button variant="tertiary" isSmall>
|
|
13
13
|
Tertiary
|
|
14
|
-
</Button>
|
|
14
|
+
</Button>{' '}
|
|
15
15
|
<Button variant="danger" isSmall>
|
|
16
16
|
Danger
|
|
17
|
-
</Button>
|
|
17
|
+
</Button>{' '}
|
|
18
18
|
<Button variant="warning" isSmall>
|
|
19
19
|
Warning
|
|
20
20
|
</Button>
|
|
21
|
-
|
|
21
|
+
<br />
|
|
22
|
+
<br />
|
|
23
|
+
</React.Fragment>
|
|
22
24
|
);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
4
|
export const ButtonTypes: React.FunctionComponent = () => (
|
|
5
|
-
<
|
|
6
|
-
<Button type="submit">Submit</Button>
|
|
7
|
-
|
|
8
|
-
<Button>Default</Button>
|
|
9
|
-
</Flex>
|
|
5
|
+
<React.Fragment>
|
|
6
|
+
<Button type="submit">Submit</Button> <Button type="reset">Reset</Button> <Button>Default</Button>
|
|
7
|
+
</React.Fragment>
|
|
10
8
|
);
|
|
@@ -1,47 +1,42 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { Button
|
|
2
|
+
import { Button } 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
|
import ExternalLinkSquareAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-square-alt-icon';
|
|
6
6
|
import CopyIcon from '@patternfly/react-icons/dist/esm/icons/copy-icon';
|
|
7
7
|
|
|
8
8
|
export const ButtonVariations: React.FunctionComponent = () => (
|
|
9
|
-
<
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
Danger link
|
|
33
|
-
</Button>
|
|
34
|
-
</Flex>
|
|
35
|
-
|
|
9
|
+
<React.Fragment>
|
|
10
|
+
<Button variant="primary">Primary</Button> <Button variant="secondary">Secondary</Button>{' '}
|
|
11
|
+
<Button variant="secondary" isDanger>
|
|
12
|
+
Danger Secondary
|
|
13
|
+
</Button>{' '}
|
|
14
|
+
<Button variant="tertiary">Tertiary</Button> <Button variant="danger">Danger</Button>{' '}
|
|
15
|
+
<Button variant="warning">Warning</Button>
|
|
16
|
+
<br />
|
|
17
|
+
<br />
|
|
18
|
+
<Button variant="link" icon={<PlusCircleIcon />}>
|
|
19
|
+
Link
|
|
20
|
+
</Button>{' '}
|
|
21
|
+
<Button variant="link" icon={<ExternalLinkSquareAltIcon />} iconPosition="right">
|
|
22
|
+
Link
|
|
23
|
+
</Button>{' '}
|
|
24
|
+
<Button variant="link" isInline>
|
|
25
|
+
Inline link
|
|
26
|
+
</Button>{' '}
|
|
27
|
+
<Button variant="link" isDanger>
|
|
28
|
+
Danger link
|
|
29
|
+
</Button>
|
|
30
|
+
<br />
|
|
31
|
+
<br />
|
|
36
32
|
<Button variant="plain" aria-label="Action">
|
|
37
33
|
<TimesIcon />
|
|
38
34
|
</Button>
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</Flex>
|
|
35
|
+
<br />
|
|
36
|
+
<br />
|
|
37
|
+
<Button variant="control">Control</Button>{' '}
|
|
38
|
+
<Button variant="control" aria-label="Copy">
|
|
39
|
+
<CopyIcon />
|
|
40
|
+
</Button>
|
|
41
|
+
</React.Fragment>
|
|
47
42
|
);
|
|
@@ -30,6 +30,8 @@ export interface DatePickerProps
|
|
|
30
30
|
invalidFormatText?: string;
|
|
31
31
|
/** Callback called every time the input value changes */
|
|
32
32
|
onChange?: (value: string, date?: Date) => void;
|
|
33
|
+
/** Callback called every time the input loses focus */
|
|
34
|
+
onBlur?: (value: string, date?: Date) => void;
|
|
33
35
|
/** Text for label */
|
|
34
36
|
helperText?: React.ReactNode;
|
|
35
37
|
/** Aria label for the button to open the date picker */
|
|
@@ -69,6 +71,7 @@ const DatePickerBase = (
|
|
|
69
71
|
'aria-label': ariaLabel = 'Date picker',
|
|
70
72
|
buttonAriaLabel = 'Toggle date picker',
|
|
71
73
|
onChange = (): any => undefined,
|
|
74
|
+
onBlur = (): any => undefined,
|
|
72
75
|
invalidFormatText = 'Invalid date',
|
|
73
76
|
helperText,
|
|
74
77
|
appendTo,
|
|
@@ -101,10 +104,13 @@ const DatePickerBase = (
|
|
|
101
104
|
setValueDate(dateParse(valueProp));
|
|
102
105
|
}, [valueProp]);
|
|
103
106
|
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
setPristine(!value);
|
|
109
|
+
}, [value]);
|
|
110
|
+
|
|
104
111
|
const setError = (date: Date) => setErrorText(validators.map(validator => validator(date)).join('\n') || '');
|
|
105
112
|
|
|
106
113
|
const onTextInput = (value: string) => {
|
|
107
|
-
setPristine(false);
|
|
108
114
|
setValue(value);
|
|
109
115
|
setErrorText('');
|
|
110
116
|
const newValueDate = dateParse(value);
|
|
@@ -122,8 +128,10 @@ const DatePickerBase = (
|
|
|
122
128
|
}
|
|
123
129
|
const newValueDate = dateParse(value);
|
|
124
130
|
if (isValidDate(newValueDate)) {
|
|
131
|
+
onBlur(value, new Date(newValueDate));
|
|
125
132
|
setError(newValueDate);
|
|
126
133
|
} else {
|
|
134
|
+
onBlur(value);
|
|
127
135
|
setErrorText(invalidFormatText);
|
|
128
136
|
}
|
|
129
137
|
};
|
|
@@ -230,4 +238,4 @@ const DatePickerBase = (
|
|
|
230
238
|
};
|
|
231
239
|
|
|
232
240
|
export const DatePicker = React.forwardRef<DatePickerRef, DatePickerProps>(DatePickerBase);
|
|
233
|
-
DatePicker.displayName = '
|
|
241
|
+
DatePicker.displayName = 'DatePicker';
|
|
@@ -12,7 +12,10 @@ beta: true
|
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import { DatePicker } from '@patternfly/react-core';
|
|
14
14
|
|
|
15
|
-
<DatePicker
|
|
15
|
+
<DatePicker
|
|
16
|
+
onBlur={(str, date) => console.log('onBlur', str, date)}
|
|
17
|
+
onChange={(str, date) => console.log('onChange', str, date)}
|
|
18
|
+
/>
|
|
16
19
|
```
|
|
17
20
|
|
|
18
21
|
### American format
|
|
@@ -19,10 +19,10 @@ export interface MenuContentProps extends React.HTMLProps<HTMLElement> {
|
|
|
19
19
|
export const MenuContent = React.forwardRef((props: MenuContentProps, ref: React.Ref<HTMLDivElement>) => {
|
|
20
20
|
const { getHeight, children, menuHeight, maxMenuHeight, ...rest } = props;
|
|
21
21
|
const menuContentRef = React.createRef<HTMLDivElement>();
|
|
22
|
-
const refCallback = (el:
|
|
22
|
+
const refCallback = (el: HTMLElement, menuId: string, onGetMenuHeight: (menuId: string, height: number) => void) => {
|
|
23
23
|
if (el) {
|
|
24
24
|
onGetMenuHeight && onGetMenuHeight(menuId, el.clientHeight);
|
|
25
|
-
getHeight && getHeight(el.clientHeight);
|
|
25
|
+
getHeight && getHeight(el.clientHeight.toString());
|
|
26
26
|
}
|
|
27
27
|
return ref || menuContentRef;
|
|
28
28
|
};
|
|
@@ -749,7 +749,7 @@ class MenuWithDrilldown extends React.Component {
|
|
|
749
749
|
direction="down"
|
|
750
750
|
drilldownMenu={
|
|
751
751
|
<DrilldownMenu id="drilldownMenuStart">
|
|
752
|
-
<MenuItem itemId="group:
|
|
752
|
+
<MenuItem itemId="group:start_rollout_breadcrumb" direction="up">
|
|
753
753
|
Start rollout
|
|
754
754
|
</MenuItem>
|
|
755
755
|
<Divider component="li" />
|
|
@@ -759,7 +759,7 @@ class MenuWithDrilldown extends React.Component {
|
|
|
759
759
|
direction="down"
|
|
760
760
|
drilldownMenu={
|
|
761
761
|
<DrilldownMenu id="drilldownMenuStartGrouping">
|
|
762
|
-
<MenuItem itemId="group:
|
|
762
|
+
<MenuItem itemId="group:app_grouping_breadcrumb" direction="up">
|
|
763
763
|
Application grouping
|
|
764
764
|
</MenuItem>
|
|
765
765
|
<Divider component="li" />
|
|
@@ -777,7 +777,7 @@ class MenuWithDrilldown extends React.Component {
|
|
|
777
777
|
direction="down"
|
|
778
778
|
drilldownMenu={
|
|
779
779
|
<DrilldownMenu id="drilldownMenuStartLabels">
|
|
780
|
-
<MenuItem itemId="group:
|
|
780
|
+
<MenuItem itemId="group:labels_breadcrumb" direction="up">
|
|
781
781
|
Labels
|
|
782
782
|
</MenuItem>
|
|
783
783
|
<Divider component="li" />
|
|
@@ -800,7 +800,7 @@ class MenuWithDrilldown extends React.Component {
|
|
|
800
800
|
direction="down"
|
|
801
801
|
drilldownMenu={
|
|
802
802
|
<DrilldownMenu id="drilldownMenuPause">
|
|
803
|
-
<MenuItem itemId="group:
|
|
803
|
+
<MenuItem itemId="group:pause_rollout_breadcrumb" direction="up">
|
|
804
804
|
Pause rollouts
|
|
805
805
|
</MenuItem>
|
|
806
806
|
<Divider component="li" />
|
|
@@ -810,7 +810,7 @@ class MenuWithDrilldown extends React.Component {
|
|
|
810
810
|
direction="down"
|
|
811
811
|
drilldownMenu={
|
|
812
812
|
<DrilldownMenu id="drilldownMenuGrouping">
|
|
813
|
-
<MenuItem itemId="group:
|
|
813
|
+
<MenuItem itemId="group:app_grouping_breadcrumb" direction="up">
|
|
814
814
|
Application grouping
|
|
815
815
|
</MenuItem>
|
|
816
816
|
<Divider component="li" />
|
|
@@ -828,7 +828,7 @@ class MenuWithDrilldown extends React.Component {
|
|
|
828
828
|
direction="down"
|
|
829
829
|
drilldownMenu={
|
|
830
830
|
<DrilldownMenu id="drilldownMenuLabels">
|
|
831
|
-
<MenuItem itemId="group:
|
|
831
|
+
<MenuItem itemId="group:labels_breadcrumb" direction="up">
|
|
832
832
|
Labels
|
|
833
833
|
</MenuItem>
|
|
834
834
|
<Divider component="li" />
|
|
@@ -852,7 +852,7 @@ class MenuWithDrilldown extends React.Component {
|
|
|
852
852
|
direction="down"
|
|
853
853
|
drilldownMenu={
|
|
854
854
|
<DrilldownMenu id="drilldownMenuStorage">
|
|
855
|
-
<MenuItem itemId="group:
|
|
855
|
+
<MenuItem itemId="group:storage_breadcrumb" icon={<StorageDomainIcon aria-hidden />} direction="up">
|
|
856
856
|
Add storage
|
|
857
857
|
</MenuItem>
|
|
858
858
|
<Divider component="li" />
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Composable menu
|
|
3
|
+
section: demos
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
import { Link } from '@reach/router';
|
|
7
|
+
|
|
8
|
+
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
9
|
+
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
10
|
+
import TableIcon from '@patternfly/react-icons/dist/esm/icons/table-icon';
|
|
11
|
+
import StorageDomainIcon from '@patternfly/react-icons/dist/esm/icons/storage-domain-icon';
|
|
12
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
13
|
+
import LayerGroupIcon from '@patternfly/react-icons/dist/esm/icons/layer-group-icon';
|
|
14
|
+
import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
|
|
15
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
16
|
+
import ClipboardIcon from '@patternfly/react-icons/dist/esm/icons/clipboard-icon';
|
|
17
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
18
|
+
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
|
|
19
|
+
import pfIcon from './examples/pf-logo-small.svg';
|
|
20
|
+
import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
|
|
21
|
+
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
22
|
+
import avatarImg from './examples/avatarImg.svg';
|
|
23
|
+
|
|
24
|
+
## Demos
|
|
25
|
+
|
|
26
|
+
Composable menus currently require consumer keyboard handling and use of our undocumented [popper.js](https://popper.js.org/) wrapper component called Popper. We understand this is inconvientent boilerplate and these examples will be updated to use [Dropdown](/components/dropdown) in a future release.
|
|
27
|
+
|
|
28
|
+
### Composable simple dropdown
|
|
29
|
+
|
|
30
|
+
```ts file="./examples/ComposableSimpleDropdown.tsx"
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Composable actions menu
|
|
35
|
+
|
|
36
|
+
```ts file="./examples/ComposableActionsMenu.tsx"
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Composable simple select
|
|
41
|
+
|
|
42
|
+
```ts file="./examples/ComposableSimpleSelect.tsx"
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Composable drilldown menu
|
|
47
|
+
|
|
48
|
+
```ts isBeta file="./examples/ComposableDrilldownMenu.tsx"
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Composable tree view menu
|
|
53
|
+
|
|
54
|
+
```ts file="./examples/ComposableTreeViewMenu.tsx"
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Composable flyout
|
|
59
|
+
|
|
60
|
+
The flyout will automatically position to the left or top if it would otherwise go outside the window. The menu must be placed in a container outside the main content like Popper, [Popover](/components/popover) or [Tooltip](/components/tooltip) since it may go over the side nav.
|
|
61
|
+
|
|
62
|
+
```ts isBeta file="./examples/ComposableFlyout.tsx"
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Composable application launcher
|
|
67
|
+
|
|
68
|
+
```ts file="./examples/ComposableApplicationLauncher.tsx"
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Composable context selector
|
|
73
|
+
|
|
74
|
+
```ts file="./examples/ComposableContextSelector.tsx"
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Composable options menu variants
|
|
79
|
+
|
|
80
|
+
```ts file="./examples/ComposableOptionsMenuVariants.tsx"
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Composable dropdown variants
|
|
85
|
+
|
|
86
|
+
```ts file="./examples/ComposableDropdwnVariants.tsx"
|
|
87
|
+
|
|
88
|
+
```
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuToggle, Menu, MenuList, MenuItem, MenuGroup, MenuItemAction, Popper } from '@patternfly/react-core';
|
|
3
|
+
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
4
|
+
import ClipboardIcon from '@patternfly/react-icons/dist/esm/icons/clipboard-icon';
|
|
5
|
+
import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
|
|
6
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
7
|
+
|
|
8
|
+
export const ComposableActionsMenu: React.FunctionComponent = () => {
|
|
9
|
+
const [isOpen, setIsOpen] = React.useState<boolean>(false);
|
|
10
|
+
const [selectedItems, setSelectedItems] = React.useState<number[]>([]);
|
|
11
|
+
const toggleRef = React.useRef<HTMLButtonElement>();
|
|
12
|
+
const menuRef = React.useRef<HTMLDivElement>();
|
|
13
|
+
|
|
14
|
+
const handleMenuKeys = (event: KeyboardEvent) => {
|
|
15
|
+
if (isOpen && menuRef.current.contains(event.target as Node)) {
|
|
16
|
+
if (event.key === 'Escape' || event.key === 'Tab') {
|
|
17
|
+
setIsOpen(!isOpen);
|
|
18
|
+
toggleRef.current.focus();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const handleClickOutside = (event: MouseEvent) => {
|
|
24
|
+
if (isOpen && !menuRef.current.contains(event.target as Node)) {
|
|
25
|
+
setIsOpen(false);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
React.useEffect(() => {
|
|
30
|
+
window.addEventListener('keydown', handleMenuKeys);
|
|
31
|
+
window.addEventListener('click', handleClickOutside);
|
|
32
|
+
return () => {
|
|
33
|
+
window.removeEventListener('keydown', handleMenuKeys);
|
|
34
|
+
window.removeEventListener('click', handleClickOutside);
|
|
35
|
+
};
|
|
36
|
+
}, [isOpen, menuRef]);
|
|
37
|
+
|
|
38
|
+
const onSelect = (ev: React.MouseEvent<Element, MouseEvent>, itemId: number) => {
|
|
39
|
+
if (selectedItems.includes(itemId)) {
|
|
40
|
+
setSelectedItems(selectedItems.filter(id => id !== itemId));
|
|
41
|
+
} else {
|
|
42
|
+
setSelectedItems([...selectedItems, itemId]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const onToggleClick = (ev: React.MouseEvent) => {
|
|
47
|
+
ev.stopPropagation(); // Stop handleClickOutside from handling
|
|
48
|
+
setTimeout(() => {
|
|
49
|
+
if (menuRef.current) {
|
|
50
|
+
const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
|
|
51
|
+
firstElement && (firstElement as HTMLElement).focus();
|
|
52
|
+
}
|
|
53
|
+
}, 0);
|
|
54
|
+
setIsOpen(!isOpen);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const toggle = (
|
|
58
|
+
<MenuToggle ref={toggleRef} onClick={onToggleClick} isExpanded={isOpen}>
|
|
59
|
+
{isOpen ? 'Expanded' : 'Collapsed'}
|
|
60
|
+
</MenuToggle>
|
|
61
|
+
);
|
|
62
|
+
const menu = (
|
|
63
|
+
<Menu
|
|
64
|
+
ref={menuRef}
|
|
65
|
+
// eslint-disable-next-line no-console
|
|
66
|
+
onActionClick={(event, itemId, actionId) => console.log(`clicked on ${itemId} - ${actionId}`)}
|
|
67
|
+
onSelect={onSelect}
|
|
68
|
+
style={
|
|
69
|
+
{
|
|
70
|
+
'--pf-c-menu--Width': '300px'
|
|
71
|
+
} as React.CSSProperties
|
|
72
|
+
}
|
|
73
|
+
>
|
|
74
|
+
<MenuGroup label="Actions">
|
|
75
|
+
<MenuList>
|
|
76
|
+
<MenuItem
|
|
77
|
+
isSelected={selectedItems.includes(0)}
|
|
78
|
+
actions={
|
|
79
|
+
<MenuItemAction
|
|
80
|
+
icon={<CodeBranchIcon aria-hidden />}
|
|
81
|
+
actionId="code"
|
|
82
|
+
// eslint-disable-next-line no-console
|
|
83
|
+
onClick={() => console.log('clicked on code icon')}
|
|
84
|
+
aria-label="Code"
|
|
85
|
+
/>
|
|
86
|
+
}
|
|
87
|
+
description="This is a description"
|
|
88
|
+
itemId={0}
|
|
89
|
+
>
|
|
90
|
+
Item 1
|
|
91
|
+
</MenuItem>
|
|
92
|
+
<MenuItem
|
|
93
|
+
isDisabled
|
|
94
|
+
isSelected={selectedItems.includes(1)}
|
|
95
|
+
actions={<MenuItemAction icon={<BellIcon aria-hidden />} actionId="alert" aria-label="Alert" />}
|
|
96
|
+
description="This is a description"
|
|
97
|
+
itemId={1}
|
|
98
|
+
>
|
|
99
|
+
Item 2
|
|
100
|
+
</MenuItem>
|
|
101
|
+
<MenuItem
|
|
102
|
+
isSelected={selectedItems.includes(2)}
|
|
103
|
+
actions={<MenuItemAction icon={<ClipboardIcon aria-hidden />} actionId="copy" aria-label="Copy" />}
|
|
104
|
+
itemId={2}
|
|
105
|
+
>
|
|
106
|
+
Item 3
|
|
107
|
+
</MenuItem>
|
|
108
|
+
<MenuItem
|
|
109
|
+
isSelected={selectedItems.includes(3)}
|
|
110
|
+
actions={<MenuItemAction icon={<BarsIcon aria-hidden />} actionId="expand" aria-label="Expand" />}
|
|
111
|
+
description="This is a description"
|
|
112
|
+
itemId={3}
|
|
113
|
+
>
|
|
114
|
+
Item 4
|
|
115
|
+
</MenuItem>
|
|
116
|
+
</MenuList>
|
|
117
|
+
</MenuGroup>
|
|
118
|
+
</Menu>
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
return <Popper trigger={toggle} popper={menu} isVisible={isOpen} popperMatchesTriggerWidth={false} />;
|
|
122
|
+
};
|