@patternfly/react-core 4.214.3 → 4.215.0
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 +33 -0
- package/dist/esm/components/Checkbox/Checkbox.d.ts +2 -0
- package/dist/esm/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/esm/components/Checkbox/Checkbox.js +4 -3
- package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/esm/components/Menu/MenuItem.d.ts +3 -1
- package/dist/esm/components/Menu/MenuItem.d.ts.map +1 -1
- package/dist/esm/components/Menu/MenuItem.js +15 -6
- package/dist/esm/components/Menu/MenuItem.js.map +1 -1
- package/dist/esm/components/Slider/Slider.d.ts +4 -0
- package/dist/esm/components/Slider/Slider.d.ts.map +1 -1
- package/dist/esm/components/Slider/Slider.js +2 -2
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/esm/components/TextArea/TextArea.d.ts +1 -1
- package/dist/esm/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/esm/components/TextArea/TextArea.js.map +1 -1
- package/dist/js/components/Checkbox/Checkbox.d.ts +2 -0
- package/dist/js/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/js/components/Checkbox/Checkbox.js +4 -3
- package/dist/js/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/js/components/Menu/MenuItem.d.ts +3 -1
- package/dist/js/components/Menu/MenuItem.d.ts.map +1 -1
- package/dist/js/components/Menu/MenuItem.js +15 -6
- package/dist/js/components/Menu/MenuItem.js.map +1 -1
- package/dist/js/components/Slider/Slider.d.ts +4 -0
- package/dist/js/components/Slider/Slider.d.ts.map +1 -1
- package/dist/js/components/Slider/Slider.js +2 -2
- package/dist/js/components/Slider/Slider.js.map +1 -1
- package/dist/js/components/TextArea/TextArea.d.ts +1 -1
- package/dist/js/components/TextArea/TextArea.d.ts.map +1 -1
- package/dist/js/components/TextArea/TextArea.js.map +1 -1
- package/dist/umd/react-core.js +19 -11
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +5 -5
- package/src/components/Checkbox/Checkbox.tsx +7 -3
- package/src/components/Checkbox/__tests__/Checkbox.test.tsx +9 -0
- package/src/components/Dropdown/examples/Dropdown.md +25 -1530
- package/src/components/Dropdown/examples/DropdownAlignmentOnBreakpoints.tsx +64 -0
- package/src/components/Dropdown/examples/DropdownAppendBodyVsParent.tsx +83 -0
- package/src/components/Dropdown/examples/DropdownBadge.tsx +46 -0
- package/src/components/Dropdown/examples/DropdownBasic.tsx +57 -0
- package/src/components/Dropdown/examples/DropdownBasicPanel.tsx +34 -0
- package/src/components/Dropdown/examples/DropdownDescriptions.tsx +55 -0
- package/src/components/Dropdown/examples/DropdownDirectionUp.tsx +58 -0
- package/src/components/Dropdown/examples/DropdownDisabled.tsx +57 -0
- package/src/components/Dropdown/examples/DropdownGroups.tsx +55 -0
- package/src/components/Dropdown/examples/DropdownIconOnly.tsx +59 -0
- package/src/components/Dropdown/examples/DropdownImageAndText.tsx +64 -0
- package/src/components/Dropdown/examples/DropdownInitialSelection.tsx +57 -0
- package/src/components/Dropdown/examples/DropdownKebab.tsx +54 -0
- package/src/components/Dropdown/examples/DropdownPlainTextToggle.tsx +59 -0
- package/src/components/Dropdown/examples/DropdownPositionRight.tsx +58 -0
- package/src/components/Dropdown/examples/DropdownPrimaryToggle.tsx +57 -0
- package/src/components/Dropdown/examples/DropdownRouterLink.tsx +36 -0
- package/src/components/Dropdown/examples/DropdownSecondaryToggle.tsx +57 -0
- package/src/components/Dropdown/examples/DropdownSplitButton.tsx +67 -0
- package/src/components/Dropdown/examples/DropdownSplitButtonAction.tsx +105 -0
- package/src/components/Dropdown/examples/DropdownSplitButtonActionPrimary.tsx +107 -0
- package/src/components/Dropdown/examples/DropdownSplitButtonDisabled.tsx +73 -0
- package/src/components/Dropdown/examples/DropdownSplitButtonIndeterminate.tsx +78 -0
- package/src/components/Dropdown/examples/DropdownSplitButtonText.tsx +69 -0
- package/src/components/Menu/MenuItem.tsx +69 -43
- package/src/components/Menu/__tests__/Menu.test.tsx +23 -0
- package/src/components/Menu/examples/Menu.md +5 -0
- package/src/components/Menu/examples/MenuWithCheckbox.tsx +34 -0
- package/src/components/Slider/Slider.tsx +8 -0
- package/src/components/Slider/_tests_/Slider.test.tsx +27 -1
- package/src/components/TextArea/TextArea.tsx +1 -1
- package/src/demos/ComposableMenu/ComposableMenu.md +5 -0
- package/src/demos/ComposableMenu/examples/ComposableSimpleCheckboxSelect.tsx +98 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownAlignmentOnBreakpoints: React.FunctionComponent = () => {
|
|
5
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isOpen: boolean) => {
|
|
8
|
+
setIsOpen(isOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFocus = () => {
|
|
12
|
+
const element = document.getElementById('toggle-breakpoints');
|
|
13
|
+
element.focus();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const onSelect = () => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
onFocus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const dropdownItems = [
|
|
22
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
23
|
+
<DropdownItem key="action" component="button">
|
|
24
|
+
Action
|
|
25
|
+
</DropdownItem>,
|
|
26
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
27
|
+
Disabled link
|
|
28
|
+
</DropdownItem>,
|
|
29
|
+
<DropdownItem
|
|
30
|
+
key="disabled action"
|
|
31
|
+
isAriaDisabled
|
|
32
|
+
component="button"
|
|
33
|
+
tooltip="Tooltip for disabled item"
|
|
34
|
+
tooltipProps={{ position: 'top' }}
|
|
35
|
+
>
|
|
36
|
+
Disabled action
|
|
37
|
+
</DropdownItem>,
|
|
38
|
+
<DropdownSeparator key="separator" />,
|
|
39
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
40
|
+
<DropdownItem key="separated action" component="button">
|
|
41
|
+
Separated action
|
|
42
|
+
</DropdownItem>
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Dropdown
|
|
47
|
+
onSelect={onSelect}
|
|
48
|
+
alignments={{
|
|
49
|
+
sm: 'left',
|
|
50
|
+
md: 'right',
|
|
51
|
+
lg: 'left',
|
|
52
|
+
xl: 'right',
|
|
53
|
+
'2xl': 'left'
|
|
54
|
+
}}
|
|
55
|
+
toggle={
|
|
56
|
+
<DropdownToggle id="toggle-breakpoints" onToggle={onToggle}>
|
|
57
|
+
Dropdown
|
|
58
|
+
</DropdownToggle>
|
|
59
|
+
}
|
|
60
|
+
isOpen={isOpen}
|
|
61
|
+
dropdownItems={dropdownItems}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator, Flex } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownAppendBodyVsParent: React.FunctionComponent = () => {
|
|
5
|
+
const [isBodyOpen, setIsBodyOpen] = React.useState(false);
|
|
6
|
+
const [isParentOpen, setIsParentOpen] = React.useState(false);
|
|
7
|
+
|
|
8
|
+
const onBodyToggle = (isBodyOpen: boolean) => {
|
|
9
|
+
setIsBodyOpen(isBodyOpen);
|
|
10
|
+
};
|
|
11
|
+
const onParentToggle = (isParentOpen: boolean) => {
|
|
12
|
+
setIsParentOpen(isParentOpen);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const onBodyFocus = () => {
|
|
16
|
+
const element = document.getElementById('toggle-append-body');
|
|
17
|
+
element.focus();
|
|
18
|
+
};
|
|
19
|
+
const onParentFocus = () => {
|
|
20
|
+
const element = document.getElementById('toggle-append-parent');
|
|
21
|
+
element.focus();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const onBodySelect = () => {
|
|
25
|
+
setIsBodyOpen(false);
|
|
26
|
+
onBodyFocus();
|
|
27
|
+
};
|
|
28
|
+
const onParentSelect = () => {
|
|
29
|
+
setIsParentOpen(false);
|
|
30
|
+
onParentFocus();
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const dropdownItems = [
|
|
34
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
35
|
+
<DropdownItem key="action" component="button">
|
|
36
|
+
Action
|
|
37
|
+
</DropdownItem>,
|
|
38
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
39
|
+
Disabled link
|
|
40
|
+
</DropdownItem>,
|
|
41
|
+
<DropdownItem
|
|
42
|
+
key="disabled action"
|
|
43
|
+
isAriaDisabled
|
|
44
|
+
component="button"
|
|
45
|
+
tooltip="Tooltip for disabled item"
|
|
46
|
+
tooltipProps={{ position: 'top' }}
|
|
47
|
+
>
|
|
48
|
+
Disabled action
|
|
49
|
+
</DropdownItem>,
|
|
50
|
+
<DropdownSeparator key="separator" />,
|
|
51
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
52
|
+
<DropdownItem key="separated action" component="button">
|
|
53
|
+
Separated action
|
|
54
|
+
</DropdownItem>
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Flex>
|
|
59
|
+
<Dropdown
|
|
60
|
+
onSelect={onBodySelect}
|
|
61
|
+
toggle={
|
|
62
|
+
<DropdownToggle id="toggle-append-body" onToggle={onBodyToggle}>
|
|
63
|
+
Dropdown appended to body
|
|
64
|
+
</DropdownToggle>
|
|
65
|
+
}
|
|
66
|
+
isOpen={isBodyOpen}
|
|
67
|
+
dropdownItems={dropdownItems}
|
|
68
|
+
menuAppendTo={() => document.body}
|
|
69
|
+
/>
|
|
70
|
+
<Dropdown
|
|
71
|
+
onSelect={onParentSelect}
|
|
72
|
+
toggle={
|
|
73
|
+
<DropdownToggle id="toggle-append-parent" onToggle={onParentToggle}>
|
|
74
|
+
Dropdown appended to parent
|
|
75
|
+
</DropdownToggle>
|
|
76
|
+
}
|
|
77
|
+
isOpen={isParentOpen}
|
|
78
|
+
dropdownItems={dropdownItems}
|
|
79
|
+
menuAppendTo="parent"
|
|
80
|
+
/>
|
|
81
|
+
</Flex>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownItem, BadgeToggle } from '@patternfly/react-core';
|
|
3
|
+
import AngleLeftIcon from '@patternfly/react-icons/dist/esm/icons/angle-left-icon';
|
|
4
|
+
|
|
5
|
+
export const DropdownBadge: React.FunctionComponent = () => {
|
|
6
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
7
|
+
|
|
8
|
+
const onToggle = (isOpen: boolean) => {
|
|
9
|
+
setIsOpen(isOpen);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const onFocus = () => {
|
|
13
|
+
const element = document.getElementById('toggle-badge');
|
|
14
|
+
element.focus();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const onSelect = () => {
|
|
18
|
+
setIsOpen(false);
|
|
19
|
+
onFocus();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const dropdownItems = [
|
|
23
|
+
<DropdownItem key="edit" component="button" icon={<AngleLeftIcon />}>
|
|
24
|
+
Edit
|
|
25
|
+
</DropdownItem>,
|
|
26
|
+
<DropdownItem key="action" component="button" icon={<AngleLeftIcon />}>
|
|
27
|
+
Deployment
|
|
28
|
+
</DropdownItem>,
|
|
29
|
+
<DropdownItem key="apps" component="button" icon={<AngleLeftIcon />}>
|
|
30
|
+
Applications
|
|
31
|
+
</DropdownItem>
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Dropdown
|
|
36
|
+
onSelect={onSelect}
|
|
37
|
+
toggle={
|
|
38
|
+
<BadgeToggle id="toggle-badge" onToggle={onToggle}>
|
|
39
|
+
{dropdownItems.length}
|
|
40
|
+
</BadgeToggle>
|
|
41
|
+
}
|
|
42
|
+
isOpen={isOpen}
|
|
43
|
+
dropdownItems={dropdownItems}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownBasic: React.FunctionComponent = () => {
|
|
5
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isOpen: boolean) => {
|
|
8
|
+
setIsOpen(isOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFocus = () => {
|
|
12
|
+
const element = document.getElementById('toggle-basic');
|
|
13
|
+
element.focus();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const onSelect = () => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
onFocus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const dropdownItems = [
|
|
22
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
23
|
+
<DropdownItem key="action" component="button">
|
|
24
|
+
Action
|
|
25
|
+
</DropdownItem>,
|
|
26
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
27
|
+
Disabled link
|
|
28
|
+
</DropdownItem>,
|
|
29
|
+
<DropdownItem
|
|
30
|
+
key="disabled action"
|
|
31
|
+
isAriaDisabled
|
|
32
|
+
component="button"
|
|
33
|
+
tooltip="Tooltip for disabled item"
|
|
34
|
+
tooltipProps={{ position: 'top' }}
|
|
35
|
+
>
|
|
36
|
+
Disabled action
|
|
37
|
+
</DropdownItem>,
|
|
38
|
+
<DropdownSeparator key="separator" />,
|
|
39
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
40
|
+
<DropdownItem key="separated action" component="button">
|
|
41
|
+
Separated action
|
|
42
|
+
</DropdownItem>
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Dropdown
|
|
47
|
+
onSelect={onSelect}
|
|
48
|
+
toggle={
|
|
49
|
+
<DropdownToggle id="toggle-basic" onToggle={onToggle}>
|
|
50
|
+
Dropdown
|
|
51
|
+
</DropdownToggle>
|
|
52
|
+
}
|
|
53
|
+
isOpen={isOpen}
|
|
54
|
+
dropdownItems={dropdownItems}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownBasicPanel: React.FunctionComponent = () => {
|
|
5
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isOpen: boolean) => {
|
|
8
|
+
setIsOpen(isOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFocus = () => {
|
|
12
|
+
const element = document.getElementById('toggle-panel');
|
|
13
|
+
element.focus();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const onSelect = () => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
onFocus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<Dropdown
|
|
23
|
+
onSelect={onSelect}
|
|
24
|
+
toggle={
|
|
25
|
+
<DropdownToggle id="toggle-panel" onToggle={onToggle}>
|
|
26
|
+
Expanded dropdown
|
|
27
|
+
</DropdownToggle>
|
|
28
|
+
}
|
|
29
|
+
isOpen={isOpen}
|
|
30
|
+
>
|
|
31
|
+
[Panel contents here]
|
|
32
|
+
</Dropdown>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core';
|
|
3
|
+
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
4
|
+
import CubesIcon from '@patternfly/react-icons/dist/esm/icons/cubes-icon';
|
|
5
|
+
|
|
6
|
+
export const DropdownDescriptions: React.FunctionComponent = () => {
|
|
7
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
8
|
+
|
|
9
|
+
const onToggle = (isOpen: boolean) => {
|
|
10
|
+
setIsOpen(isOpen);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const onFocus = () => {
|
|
14
|
+
const element = document.getElementById('toggle-descriptions');
|
|
15
|
+
element.focus();
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const onSelect = () => {
|
|
19
|
+
setIsOpen(false);
|
|
20
|
+
onFocus();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const dropdownItems = [
|
|
24
|
+
<DropdownItem key="link" description="This is a description" icon={<CubesIcon />}>
|
|
25
|
+
Link
|
|
26
|
+
</DropdownItem>,
|
|
27
|
+
<DropdownItem
|
|
28
|
+
key="action"
|
|
29
|
+
component="button"
|
|
30
|
+
icon={<BellIcon />}
|
|
31
|
+
description="This is a very long description that describes the menu item"
|
|
32
|
+
>
|
|
33
|
+
Action
|
|
34
|
+
</DropdownItem>,
|
|
35
|
+
<DropdownItem key="disabled link" isDisabled description="Disabled link description">
|
|
36
|
+
Disabled link
|
|
37
|
+
</DropdownItem>,
|
|
38
|
+
<DropdownItem key="disabled action" isDisabled component="button" description="This is a description">
|
|
39
|
+
Disabled action
|
|
40
|
+
</DropdownItem>
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Dropdown
|
|
45
|
+
onSelect={onSelect}
|
|
46
|
+
toggle={
|
|
47
|
+
<DropdownToggle id="toggle-descriptions" onToggle={onToggle}>
|
|
48
|
+
Dropdown
|
|
49
|
+
</DropdownToggle>
|
|
50
|
+
}
|
|
51
|
+
isOpen={isOpen}
|
|
52
|
+
dropdownItems={dropdownItems}
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator, DropdownDirection } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownDirectionUp: React.FunctionComponent = () => {
|
|
5
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isOpen: boolean) => {
|
|
8
|
+
setIsOpen(isOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFocus = () => {
|
|
12
|
+
const element = document.getElementById('toggle-direction-up');
|
|
13
|
+
element.focus();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const onSelect = () => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
onFocus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const dropdownItems = [
|
|
22
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
23
|
+
<DropdownItem key="action" component="button">
|
|
24
|
+
Action
|
|
25
|
+
</DropdownItem>,
|
|
26
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
27
|
+
Disabled link
|
|
28
|
+
</DropdownItem>,
|
|
29
|
+
<DropdownItem
|
|
30
|
+
key="disabled action"
|
|
31
|
+
isAriaDisabled
|
|
32
|
+
component="button"
|
|
33
|
+
tooltip="Tooltip for disabled item"
|
|
34
|
+
tooltipProps={{ position: 'top' }}
|
|
35
|
+
>
|
|
36
|
+
Disabled action
|
|
37
|
+
</DropdownItem>,
|
|
38
|
+
<DropdownSeparator key="separator" />,
|
|
39
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
40
|
+
<DropdownItem key="separated action" component="button">
|
|
41
|
+
Separated action
|
|
42
|
+
</DropdownItem>
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Dropdown
|
|
47
|
+
onSelect={onSelect}
|
|
48
|
+
direction={DropdownDirection.up}
|
|
49
|
+
toggle={
|
|
50
|
+
<DropdownToggle id="toggle-direction-up" onToggle={onToggle}>
|
|
51
|
+
Dropdown
|
|
52
|
+
</DropdownToggle>
|
|
53
|
+
}
|
|
54
|
+
isOpen={isOpen}
|
|
55
|
+
dropdownItems={dropdownItems}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownDisabled: React.FunctionComponent = () => {
|
|
5
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isOpen: boolean) => {
|
|
8
|
+
setIsOpen(isOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFocus = () => {
|
|
12
|
+
const element = document.getElementById('toggle-disabled');
|
|
13
|
+
element.focus();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const onSelect = () => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
onFocus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const dropdownItems = [
|
|
22
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
23
|
+
<DropdownItem key="action" component="button">
|
|
24
|
+
Action
|
|
25
|
+
</DropdownItem>,
|
|
26
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
27
|
+
Disabled link
|
|
28
|
+
</DropdownItem>,
|
|
29
|
+
<DropdownItem
|
|
30
|
+
key="disabled action"
|
|
31
|
+
isAriaDisabled
|
|
32
|
+
component="button"
|
|
33
|
+
tooltip="Tooltip for disabled item"
|
|
34
|
+
tooltipProps={{ position: 'top' }}
|
|
35
|
+
>
|
|
36
|
+
Disabled action
|
|
37
|
+
</DropdownItem>,
|
|
38
|
+
<DropdownSeparator key="separator" />,
|
|
39
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
40
|
+
<DropdownItem key="separated action" component="button">
|
|
41
|
+
Separated action
|
|
42
|
+
</DropdownItem>
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Dropdown
|
|
47
|
+
onSelect={onSelect}
|
|
48
|
+
toggle={
|
|
49
|
+
<DropdownToggle id="toggle-disabled" isDisabled onToggle={onToggle}>
|
|
50
|
+
Dropdown
|
|
51
|
+
</DropdownToggle>
|
|
52
|
+
}
|
|
53
|
+
isOpen={isOpen}
|
|
54
|
+
dropdownItems={dropdownItems}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownGroup, DropdownItem } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownGroups: React.FunctionComponent = () => {
|
|
5
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isOpen: boolean) => {
|
|
8
|
+
setIsOpen(isOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFocus = () => {
|
|
12
|
+
const element = document.getElementById('toggle-groups');
|
|
13
|
+
element.focus();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const onSelect = () => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
onFocus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const dropdownItems = [
|
|
22
|
+
<DropdownGroup key="group 1">
|
|
23
|
+
<DropdownItem key="group 1 link">Link</DropdownItem>
|
|
24
|
+
<DropdownItem key="group 1 action" component="button">
|
|
25
|
+
Action
|
|
26
|
+
</DropdownItem>
|
|
27
|
+
</DropdownGroup>,
|
|
28
|
+
<DropdownGroup label="Group 2" key="group 2">
|
|
29
|
+
<DropdownItem key="group 2 link">Group 2 link</DropdownItem>
|
|
30
|
+
<DropdownItem key="group 2 action" component="button">
|
|
31
|
+
Group 2 action
|
|
32
|
+
</DropdownItem>
|
|
33
|
+
</DropdownGroup>,
|
|
34
|
+
<DropdownGroup label="Group 3" key="group 3">
|
|
35
|
+
<DropdownItem key="group 3 link">Group 3 link</DropdownItem>
|
|
36
|
+
<DropdownItem key="group 3 action" component="button">
|
|
37
|
+
Group 3 action
|
|
38
|
+
</DropdownItem>
|
|
39
|
+
</DropdownGroup>
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<Dropdown
|
|
44
|
+
onSelect={onSelect}
|
|
45
|
+
toggle={
|
|
46
|
+
<DropdownToggle id="toggle-groups" onToggle={onToggle}>
|
|
47
|
+
Dropdown
|
|
48
|
+
</DropdownToggle>
|
|
49
|
+
}
|
|
50
|
+
isOpen={isOpen}
|
|
51
|
+
dropdownItems={dropdownItems}
|
|
52
|
+
isGrouped
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
3
|
+
import ThIcon from '@patternfly/react-icons/dist/esm/icons/th-icon';
|
|
4
|
+
|
|
5
|
+
export const DropdownIconOnly: React.FunctionComponent = () => {
|
|
6
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
7
|
+
|
|
8
|
+
const onToggle = (isOpen: boolean) => {
|
|
9
|
+
setIsOpen(isOpen);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const onFocus = () => {
|
|
13
|
+
const element = document.getElementById('toggle-icon-only');
|
|
14
|
+
element.focus();
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const onSelect = () => {
|
|
18
|
+
setIsOpen(false);
|
|
19
|
+
onFocus();
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const dropdownItems = [
|
|
23
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
24
|
+
<DropdownItem key="action" component="button">
|
|
25
|
+
Action
|
|
26
|
+
</DropdownItem>,
|
|
27
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
28
|
+
Disabled link
|
|
29
|
+
</DropdownItem>,
|
|
30
|
+
<DropdownItem
|
|
31
|
+
key="disabled action"
|
|
32
|
+
isAriaDisabled
|
|
33
|
+
component="button"
|
|
34
|
+
tooltip="Tooltip for disabled item"
|
|
35
|
+
tooltipProps={{ position: 'top' }}
|
|
36
|
+
>
|
|
37
|
+
Disabled action
|
|
38
|
+
</DropdownItem>,
|
|
39
|
+
<DropdownSeparator key="separator" />,
|
|
40
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
41
|
+
<DropdownItem key="separated action" component="button">
|
|
42
|
+
Separated action
|
|
43
|
+
</DropdownItem>
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<Dropdown
|
|
48
|
+
onSelect={onSelect}
|
|
49
|
+
toggle={
|
|
50
|
+
<DropdownToggle toggleIndicator={null} onToggle={onToggle} aria-label="Applications" id="toggle-icon-only">
|
|
51
|
+
<ThIcon />
|
|
52
|
+
</DropdownToggle>
|
|
53
|
+
}
|
|
54
|
+
isOpen={isOpen}
|
|
55
|
+
isPlain
|
|
56
|
+
dropdownItems={dropdownItems}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Avatar,
|
|
4
|
+
Dropdown,
|
|
5
|
+
DropdownGroup,
|
|
6
|
+
DropdownToggle,
|
|
7
|
+
DropdownItem,
|
|
8
|
+
DropdownSeparator
|
|
9
|
+
} from '@patternfly/react-core';
|
|
10
|
+
import avatarImg from '../../Avatar/examples/avatarImg.svg';
|
|
11
|
+
|
|
12
|
+
export const DropdownImageAndText: React.FunctionComponent = () => {
|
|
13
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
14
|
+
|
|
15
|
+
const onToggle = (isOpen: boolean) => {
|
|
16
|
+
setIsOpen(isOpen);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const onFocus = () => {
|
|
20
|
+
const element = document.getElementById('toggle-image-and-text');
|
|
21
|
+
element.focus();
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const onSelect = () => {
|
|
25
|
+
setIsOpen(false);
|
|
26
|
+
onFocus();
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const dropdownItems = [
|
|
30
|
+
<DropdownGroup key="group 1">
|
|
31
|
+
<DropdownItem key="group 1 plaintext" component="div" isPlainText>
|
|
32
|
+
Text
|
|
33
|
+
</DropdownItem>
|
|
34
|
+
<DropdownItem key="group 1 plaintext2" component="div" isPlainText>
|
|
35
|
+
More text
|
|
36
|
+
</DropdownItem>
|
|
37
|
+
</DropdownGroup>,
|
|
38
|
+
<DropdownSeparator key="dropdown separator" />,
|
|
39
|
+
<DropdownGroup key="group 2">
|
|
40
|
+
<DropdownItem key="group 2 profile">My profile</DropdownItem>
|
|
41
|
+
<DropdownItem key="group 2 user" component="button">
|
|
42
|
+
User management
|
|
43
|
+
</DropdownItem>
|
|
44
|
+
<DropdownItem key="group 2 logout">Logout</DropdownItem>
|
|
45
|
+
</DropdownGroup>
|
|
46
|
+
];
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Dropdown
|
|
50
|
+
onSelect={onSelect}
|
|
51
|
+
toggle={
|
|
52
|
+
<DropdownToggle
|
|
53
|
+
id="toggle-image-and-text"
|
|
54
|
+
onToggle={onToggle}
|
|
55
|
+
icon={<Avatar src={avatarImg} alt="avatar"></Avatar>}
|
|
56
|
+
>
|
|
57
|
+
Ned Username
|
|
58
|
+
</DropdownToggle>
|
|
59
|
+
}
|
|
60
|
+
isOpen={isOpen}
|
|
61
|
+
dropdownItems={dropdownItems}
|
|
62
|
+
/>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Dropdown, DropdownToggle, DropdownItem, DropdownSeparator } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const DropdownInitialSelection: React.FunctionComponent = () => {
|
|
5
|
+
const [isOpen, setIsOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const onToggle = (isOpen: boolean) => {
|
|
8
|
+
setIsOpen(isOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const onFocus = () => {
|
|
12
|
+
const element = document.getElementById('toggle-initial-selection');
|
|
13
|
+
element.focus();
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const onSelect = () => {
|
|
17
|
+
setIsOpen(false);
|
|
18
|
+
onFocus();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const dropdownItems = [
|
|
22
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
23
|
+
<DropdownItem key="action" component="button" autoFocus>
|
|
24
|
+
Action
|
|
25
|
+
</DropdownItem>,
|
|
26
|
+
<DropdownItem key="disabled link" isDisabled href="www.google.com">
|
|
27
|
+
Disabled link
|
|
28
|
+
</DropdownItem>,
|
|
29
|
+
<DropdownItem
|
|
30
|
+
key="disabled action"
|
|
31
|
+
isAriaDisabled
|
|
32
|
+
component="button"
|
|
33
|
+
tooltip="Tooltip for disabled item"
|
|
34
|
+
tooltipProps={{ position: 'top' }}
|
|
35
|
+
>
|
|
36
|
+
Disabled action
|
|
37
|
+
</DropdownItem>,
|
|
38
|
+
<DropdownSeparator key="separator" />,
|
|
39
|
+
<DropdownItem key="separated link">Separated link</DropdownItem>,
|
|
40
|
+
<DropdownItem key="separated action" component="button">
|
|
41
|
+
Separated action
|
|
42
|
+
</DropdownItem>
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<Dropdown
|
|
47
|
+
onSelect={onSelect}
|
|
48
|
+
toggle={
|
|
49
|
+
<DropdownToggle id="toggle-initial-selection" onToggle={onToggle}>
|
|
50
|
+
Dropdown
|
|
51
|
+
</DropdownToggle>
|
|
52
|
+
}
|
|
53
|
+
isOpen={isOpen}
|
|
54
|
+
dropdownItems={dropdownItems}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
};
|