@patternfly/react-core 4.224.1 → 4.224.4
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/DataListCheck.js +1 -1
- package/dist/esm/components/DataList/DataListCheck.js.map +1 -1
- package/dist/js/components/DataList/DataListCheck.js +1 -1
- package/dist/js/components/DataList/DataListCheck.js.map +1 -1
- package/dist/umd/react-core.js +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +6 -6
- package/src/components/DataList/DataListCheck.tsx +2 -2
- package/src/components/DataList/__tests__/DataListCheck.test.tsx +20 -0
- package/src/components/Modal/examples/Modal.md +22 -804
- package/src/components/Modal/examples/ModalBasic.tsx +37 -0
- package/src/components/Modal/examples/ModalCustomHeaderFooter.tsx +56 -0
- package/src/components/Modal/examples/ModalCustomTitleIcon.tsx +46 -0
- package/src/components/Modal/examples/ModalCustomWidth.tsx +38 -0
- package/src/components/Modal/examples/ModalLarge.tsx +38 -0
- package/src/components/Modal/examples/ModalMedium.tsx +38 -0
- package/src/components/Modal/examples/ModalNoHeaderFooter.tsx +37 -0
- package/src/components/Modal/examples/ModalSmall.tsx +38 -0
- package/src/components/Modal/examples/ModalTitleIcon.tsx +45 -0
- package/src/components/Modal/examples/ModalTopAligned.tsx +38 -0
- package/src/components/Modal/examples/ModalWithDescription.tsx +38 -0
- package/src/components/Modal/examples/ModalWithDropdown.tsx +97 -0
- package/src/components/Modal/examples/ModalWithForm.tsx +4 -12
- package/src/components/Modal/examples/ModalWithHelp.tsx +54 -0
- package/src/components/Modal/examples/ModalWithWizard.tsx +45 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalBasic: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show basic modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
title="Basic modal"
|
|
18
|
+
isOpen={isModalOpen}
|
|
19
|
+
onClose={handleModalToggle}
|
|
20
|
+
actions={[
|
|
21
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
22
|
+
Confirm
|
|
23
|
+
</Button>,
|
|
24
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
25
|
+
Cancel
|
|
26
|
+
</Button>
|
|
27
|
+
]}
|
|
28
|
+
>
|
|
29
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
30
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
31
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
32
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
33
|
+
laborum.
|
|
34
|
+
</Modal>
|
|
35
|
+
</React.Fragment>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, ModalVariant, Button, Title, TitleSizes } from '@patternfly/react-core';
|
|
3
|
+
import WarningTriangleIcon from '@patternfly/react-icons/dist/esm/icons/warning-triangle-icon';
|
|
4
|
+
|
|
5
|
+
export const ModalCustomHeaderFooter: React.FunctionComponent = () => {
|
|
6
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
7
|
+
|
|
8
|
+
const handleModalToggle = () => {
|
|
9
|
+
setIsModalOpen(!isModalOpen);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const header = (
|
|
13
|
+
<React.Fragment>
|
|
14
|
+
<Title id="modal-custom-header-label" headingLevel="h1" size={TitleSizes['2xl']}>
|
|
15
|
+
Custom header/footer modal
|
|
16
|
+
</Title>
|
|
17
|
+
<p className="pf-u-pt-sm">Allows for custom content in the header and/or footer by passing components.</p>
|
|
18
|
+
</React.Fragment>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const footer = (
|
|
22
|
+
<Title headingLevel="h4" size={TitleSizes.md}>
|
|
23
|
+
<WarningTriangleIcon />
|
|
24
|
+
<span className="pf-u-pl-sm">Custom modal footer.</span>
|
|
25
|
+
</Title>
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<React.Fragment>
|
|
30
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
31
|
+
Show custom header/footer modal
|
|
32
|
+
</Button>
|
|
33
|
+
<Modal
|
|
34
|
+
variant={ModalVariant.large}
|
|
35
|
+
isOpen={isModalOpen}
|
|
36
|
+
onClose={handleModalToggle}
|
|
37
|
+
header={header}
|
|
38
|
+
aria-labelledby="modal-custom-header-label"
|
|
39
|
+
aria-describedby="modal-custom-header-description"
|
|
40
|
+
footer={footer}
|
|
41
|
+
>
|
|
42
|
+
<span id="modal-custom-header-description">
|
|
43
|
+
When static text describing the modal is available outside of the modal header, it can be given an ID that is
|
|
44
|
+
then passed in as the modal's aria-describedby value.
|
|
45
|
+
</span>
|
|
46
|
+
<br />
|
|
47
|
+
<br />
|
|
48
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
49
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
50
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
51
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
52
|
+
laborum.
|
|
53
|
+
</Modal>
|
|
54
|
+
</React.Fragment>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button } from '@patternfly/react-core';
|
|
3
|
+
import BullhornIcon from '@patternfly/react-icons/dist/esm/icons/bullhorn-icon';
|
|
4
|
+
|
|
5
|
+
export const ModalCustomTitleIcon: React.FunctionComponent = () => {
|
|
6
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
7
|
+
|
|
8
|
+
const handleModalToggle = () => {
|
|
9
|
+
setIsModalOpen(!isModalOpen);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<React.Fragment>
|
|
14
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
15
|
+
Show custom title icon modal
|
|
16
|
+
</Button>
|
|
17
|
+
<Modal
|
|
18
|
+
title="Custom title icon modal"
|
|
19
|
+
titleIconVariant={BullhornIcon}
|
|
20
|
+
isOpen={isModalOpen}
|
|
21
|
+
onClose={handleModalToggle}
|
|
22
|
+
aria-describedby="modal-custom-icon-description"
|
|
23
|
+
actions={[
|
|
24
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
25
|
+
Confirm
|
|
26
|
+
</Button>,
|
|
27
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
28
|
+
Cancel
|
|
29
|
+
</Button>
|
|
30
|
+
]}
|
|
31
|
+
>
|
|
32
|
+
<span id="modal-custom-icon-description">
|
|
33
|
+
When static text describing the modal is available outside of the modal header, it can be given an ID that is
|
|
34
|
+
then passed in as the modal's aria-describedby value.
|
|
35
|
+
</span>
|
|
36
|
+
<br />
|
|
37
|
+
<br />
|
|
38
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
39
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
40
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
41
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
42
|
+
laborum.
|
|
43
|
+
</Modal>
|
|
44
|
+
</React.Fragment>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalCustomWidth: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show custom width modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
width="50%"
|
|
18
|
+
title="Custom width modal"
|
|
19
|
+
isOpen={isModalOpen}
|
|
20
|
+
onClose={handleModalToggle}
|
|
21
|
+
actions={[
|
|
22
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
23
|
+
Confirm
|
|
24
|
+
</Button>,
|
|
25
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
26
|
+
Cancel
|
|
27
|
+
</Button>
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
31
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
32
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
33
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
34
|
+
laborum.
|
|
35
|
+
</Modal>
|
|
36
|
+
</React.Fragment>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, ModalVariant, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalLarge: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show large modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
variant={ModalVariant.large}
|
|
18
|
+
title="Large modal"
|
|
19
|
+
isOpen={isModalOpen}
|
|
20
|
+
onClose={handleModalToggle}
|
|
21
|
+
actions={[
|
|
22
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
23
|
+
Confirm
|
|
24
|
+
</Button>,
|
|
25
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
26
|
+
Cancel
|
|
27
|
+
</Button>
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
31
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
32
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
33
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
34
|
+
laborum.
|
|
35
|
+
</Modal>
|
|
36
|
+
</React.Fragment>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, ModalVariant, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalMedium: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show medium modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
variant={ModalVariant.medium}
|
|
18
|
+
title="Medium modal"
|
|
19
|
+
isOpen={isModalOpen}
|
|
20
|
+
onClose={handleModalToggle}
|
|
21
|
+
actions={[
|
|
22
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
23
|
+
Confirm
|
|
24
|
+
</Button>,
|
|
25
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
26
|
+
Cancel
|
|
27
|
+
</Button>
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
31
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
32
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
33
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
34
|
+
laborum.
|
|
35
|
+
</Modal>
|
|
36
|
+
</React.Fragment>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, ModalVariant, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalNoHeaderFooter: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show no header/footer modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
variant={ModalVariant.large}
|
|
18
|
+
isOpen={isModalOpen}
|
|
19
|
+
aria-label="No header/footer modal"
|
|
20
|
+
aria-describedby="modal-no-header-description"
|
|
21
|
+
onClose={handleModalToggle}
|
|
22
|
+
>
|
|
23
|
+
<span id="modal-no-header-description">
|
|
24
|
+
When static text describing the modal is available outside of the modal header, it can be given an ID that is
|
|
25
|
+
then passed in as the modal's aria-describedby value.
|
|
26
|
+
</span>
|
|
27
|
+
<br />
|
|
28
|
+
<br />
|
|
29
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
30
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
31
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
32
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
33
|
+
laborum.
|
|
34
|
+
</Modal>
|
|
35
|
+
</React.Fragment>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, ModalVariant, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalSmall: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show small modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
variant={ModalVariant.small}
|
|
18
|
+
title="Small modal"
|
|
19
|
+
isOpen={isModalOpen}
|
|
20
|
+
onClose={handleModalToggle}
|
|
21
|
+
actions={[
|
|
22
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
23
|
+
Confirm
|
|
24
|
+
</Button>,
|
|
25
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
26
|
+
Cancel
|
|
27
|
+
</Button>
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
31
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
32
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
33
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
34
|
+
laborum.
|
|
35
|
+
</Modal>
|
|
36
|
+
</React.Fragment>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalTitleIcon: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show title icon modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
title="Title icon modal"
|
|
18
|
+
titleIconVariant="warning"
|
|
19
|
+
isOpen={isModalOpen}
|
|
20
|
+
aria-describedby="modal-title-icon-description"
|
|
21
|
+
onClose={handleModalToggle}
|
|
22
|
+
actions={[
|
|
23
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
24
|
+
Confirm
|
|
25
|
+
</Button>,
|
|
26
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
27
|
+
Cancel
|
|
28
|
+
</Button>
|
|
29
|
+
]}
|
|
30
|
+
>
|
|
31
|
+
<span id="modal-title-icon-description">
|
|
32
|
+
When static text describing the modal is available outside of the modal header, it can be given an ID that is
|
|
33
|
+
then passed in as the modal's aria-describedby value.
|
|
34
|
+
</span>
|
|
35
|
+
<br />
|
|
36
|
+
<br />
|
|
37
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
38
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
39
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
40
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
41
|
+
laborum.
|
|
42
|
+
</Modal>
|
|
43
|
+
</React.Fragment>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalTopAligned: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show top aligned modal
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
position="top"
|
|
18
|
+
title="Top aligned modal"
|
|
19
|
+
isOpen={isModalOpen}
|
|
20
|
+
onClose={handleModalToggle}
|
|
21
|
+
actions={[
|
|
22
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
23
|
+
Confirm
|
|
24
|
+
</Button>,
|
|
25
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
26
|
+
Cancel
|
|
27
|
+
</Button>
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
31
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
32
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
33
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
34
|
+
laborum.
|
|
35
|
+
</Modal>
|
|
36
|
+
</React.Fragment>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const ModalWithDescription: React.FunctionComponent = () => {
|
|
5
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
6
|
+
|
|
7
|
+
const handleModalToggle = () => {
|
|
8
|
+
setIsModalOpen(!isModalOpen);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<React.Fragment>
|
|
13
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
14
|
+
Show modal with description
|
|
15
|
+
</Button>
|
|
16
|
+
<Modal
|
|
17
|
+
title="Modal with description"
|
|
18
|
+
isOpen={isModalOpen}
|
|
19
|
+
onClose={handleModalToggle}
|
|
20
|
+
description="A description is used when you want to provide more info about the modal than the title is able to describe. The content in the description is static and will not scroll with the rest of the modal body."
|
|
21
|
+
actions={[
|
|
22
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
23
|
+
Confirm
|
|
24
|
+
</Button>,
|
|
25
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
26
|
+
Cancel
|
|
27
|
+
</Button>
|
|
28
|
+
]}
|
|
29
|
+
>
|
|
30
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
31
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
32
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
33
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
34
|
+
laborum.
|
|
35
|
+
</Modal>
|
|
36
|
+
</React.Fragment>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, ModalVariant, Button, Dropdown, DropdownToggle, DropdownItem } from '@patternfly/react-core';
|
|
3
|
+
import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
|
|
4
|
+
|
|
5
|
+
export const ModalWithDropdown: React.FunctionComponent = () => {
|
|
6
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
7
|
+
const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
|
|
8
|
+
|
|
9
|
+
const handleModalToggle = () => {
|
|
10
|
+
setIsModalOpen(!isModalOpen);
|
|
11
|
+
setIsDropdownOpen(false);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const handleDropdownToggle = (isDropdownOpen: boolean) => {
|
|
15
|
+
setIsDropdownOpen(isDropdownOpen);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const onSelect = () => {
|
|
19
|
+
setIsDropdownOpen(!isDropdownOpen);
|
|
20
|
+
onFocus();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const onFocus = () => {
|
|
24
|
+
const element = document.getElementById('modal-dropdown-toggle');
|
|
25
|
+
(element as HTMLElement).focus();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const onEscapePress = () => {
|
|
29
|
+
if (isDropdownOpen) {
|
|
30
|
+
setIsDropdownOpen(!isDropdownOpen);
|
|
31
|
+
onFocus();
|
|
32
|
+
} else {
|
|
33
|
+
handleModalToggle();
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const dropdownItems = [
|
|
38
|
+
<DropdownItem key="link">Link</DropdownItem>,
|
|
39
|
+
<DropdownItem key="action" component="button">
|
|
40
|
+
Action
|
|
41
|
+
</DropdownItem>,
|
|
42
|
+
<DropdownItem key="disabled link" isDisabled>
|
|
43
|
+
Disabled Link
|
|
44
|
+
</DropdownItem>,
|
|
45
|
+
<DropdownItem key="disabled action" isDisabled component="button">
|
|
46
|
+
Disabled Action
|
|
47
|
+
</DropdownItem>
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<React.Fragment>
|
|
52
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
53
|
+
Show dropdown modal
|
|
54
|
+
</Button>
|
|
55
|
+
<Modal
|
|
56
|
+
title="Dropdown modal"
|
|
57
|
+
variant={ModalVariant.small}
|
|
58
|
+
isOpen={isModalOpen}
|
|
59
|
+
onClose={handleModalToggle}
|
|
60
|
+
actions={[
|
|
61
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
62
|
+
Confirm
|
|
63
|
+
</Button>,
|
|
64
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
65
|
+
Cancel
|
|
66
|
+
</Button>
|
|
67
|
+
]}
|
|
68
|
+
onEscapePress={onEscapePress}
|
|
69
|
+
>
|
|
70
|
+
<div>
|
|
71
|
+
Set the dropdown <strong>menuAppendTo</strong> prop to <em>parent</em> in order to allow the dropdown menu
|
|
72
|
+
break out of the modal container. You'll also want to handle closing of the modal yourself, by listening to
|
|
73
|
+
the <strong>onEscapePress</strong> callback on the Modal component, so you can close the Dropdown first if
|
|
74
|
+
it's open without closing the entire modal.
|
|
75
|
+
</div>
|
|
76
|
+
<br />
|
|
77
|
+
<div>
|
|
78
|
+
<Dropdown
|
|
79
|
+
onSelect={onSelect}
|
|
80
|
+
toggle={
|
|
81
|
+
<DropdownToggle
|
|
82
|
+
id="modal-dropdown-toggle"
|
|
83
|
+
onToggle={handleDropdownToggle}
|
|
84
|
+
toggleIndicator={CaretDownIcon}
|
|
85
|
+
>
|
|
86
|
+
Dropdown with a menu that can break out
|
|
87
|
+
</DropdownToggle>
|
|
88
|
+
}
|
|
89
|
+
isOpen={isDropdownOpen}
|
|
90
|
+
dropdownItems={dropdownItems}
|
|
91
|
+
menuAppendTo="parent"
|
|
92
|
+
/>
|
|
93
|
+
</div>
|
|
94
|
+
</Modal>
|
|
95
|
+
</React.Fragment>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
@@ -7,33 +7,26 @@ export const ModalWithForm: React.FunctionComponent = () => {
|
|
|
7
7
|
const [nameValue, setNameValue] = React.useState('');
|
|
8
8
|
const [emailValue, setEmailValue] = React.useState('');
|
|
9
9
|
const [addressValue, setAddressValue] = React.useState('');
|
|
10
|
-
const nameInputRef = React.useRef();
|
|
11
10
|
|
|
12
11
|
const handleModalToggle = () => {
|
|
13
12
|
setModalOpen(!isModalOpen);
|
|
14
13
|
};
|
|
15
14
|
|
|
16
|
-
const handleNameInputChange = value => {
|
|
15
|
+
const handleNameInputChange = (value: string) => {
|
|
17
16
|
setNameValue(value);
|
|
18
17
|
};
|
|
19
18
|
|
|
20
|
-
const handleEmailInputChange = value => {
|
|
19
|
+
const handleEmailInputChange = (value: string) => {
|
|
21
20
|
setEmailValue(value);
|
|
22
21
|
};
|
|
23
|
-
const handleAddressInputChange = value => {
|
|
22
|
+
const handleAddressInputChange = (value: string) => {
|
|
24
23
|
setAddressValue(value);
|
|
25
24
|
};
|
|
26
25
|
|
|
27
|
-
React.useEffect(() => {
|
|
28
|
-
if (isModalOpen && nameInputRef && nameInputRef.current) {
|
|
29
|
-
(nameInputRef.current as HTMLInputElement).focus();
|
|
30
|
-
}
|
|
31
|
-
}, [isModalOpen]);
|
|
32
|
-
|
|
33
26
|
return (
|
|
34
27
|
<React.Fragment>
|
|
35
28
|
<Button variant="primary" onClick={handleModalToggle}>
|
|
36
|
-
Show modal
|
|
29
|
+
Show modal with form
|
|
37
30
|
</Button>
|
|
38
31
|
<Modal
|
|
39
32
|
variant={ModalVariant.small}
|
|
@@ -102,7 +95,6 @@ export const ModalWithForm: React.FunctionComponent = () => {
|
|
|
102
95
|
name="modal-with-form-form-name"
|
|
103
96
|
value={nameValue}
|
|
104
97
|
onChange={handleNameInputChange}
|
|
105
|
-
ref={nameInputRef}
|
|
106
98
|
/>
|
|
107
99
|
</FormGroup>
|
|
108
100
|
<FormGroup
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal, Button, Popover } from '@patternfly/react-core';
|
|
3
|
+
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
4
|
+
|
|
5
|
+
export const ModalWithHelp: React.FunctionComponent = () => {
|
|
6
|
+
const [isModalOpen, setIsModalOpen] = React.useState(false);
|
|
7
|
+
|
|
8
|
+
const handleModalToggle = () => {
|
|
9
|
+
setIsModalOpen(!isModalOpen);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<React.Fragment>
|
|
14
|
+
<Button variant="primary" onClick={handleModalToggle}>
|
|
15
|
+
Show with help modal
|
|
16
|
+
</Button>
|
|
17
|
+
<Modal
|
|
18
|
+
variant="small"
|
|
19
|
+
title="With help modal"
|
|
20
|
+
help={
|
|
21
|
+
<Popover
|
|
22
|
+
headerContent={<div>Help Popover</div>}
|
|
23
|
+
bodyContent={
|
|
24
|
+
<div>
|
|
25
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam id feugiat augue, nec fringilla turpis.
|
|
26
|
+
</div>
|
|
27
|
+
}
|
|
28
|
+
footerContent="Popover Footer"
|
|
29
|
+
>
|
|
30
|
+
<Button variant="plain" aria-label="Help">
|
|
31
|
+
<HelpIcon />
|
|
32
|
+
</Button>
|
|
33
|
+
</Popover>
|
|
34
|
+
}
|
|
35
|
+
isOpen={isModalOpen}
|
|
36
|
+
onClose={handleModalToggle}
|
|
37
|
+
actions={[
|
|
38
|
+
<Button key="confirm" variant="primary" onClick={handleModalToggle}>
|
|
39
|
+
Confirm
|
|
40
|
+
</Button>,
|
|
41
|
+
<Button key="cancel" variant="link" onClick={handleModalToggle}>
|
|
42
|
+
Cancel
|
|
43
|
+
</Button>
|
|
44
|
+
]}
|
|
45
|
+
>
|
|
46
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore
|
|
47
|
+
magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
|
48
|
+
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
49
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
|
|
50
|
+
laborum.
|
|
51
|
+
</Modal>
|
|
52
|
+
</React.Fragment>
|
|
53
|
+
);
|
|
54
|
+
};
|