@patternfly/react-core 4.223.1 → 4.224.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/esm/components/Form/FormGroup.d.ts +4 -2
  3. package/dist/esm/components/Form/FormGroup.d.ts.map +1 -1
  4. package/dist/esm/components/Form/FormGroup.js +4 -3
  5. package/dist/esm/components/Form/FormGroup.js.map +1 -1
  6. package/dist/esm/components/ProgressStepper/ProgressStep.js +2 -2
  7. package/dist/esm/components/ProgressStepper/ProgressStep.js.map +1 -1
  8. package/dist/esm/components/Wizard/Wizard.d.ts +9 -0
  9. package/dist/esm/components/Wizard/Wizard.d.ts.map +1 -1
  10. package/dist/esm/components/Wizard/Wizard.js +6 -3
  11. package/dist/esm/components/Wizard/Wizard.js.map +1 -1
  12. package/dist/esm/components/Wizard/WizardBody.d.ts +6 -0
  13. package/dist/esm/components/Wizard/WizardBody.d.ts.map +1 -1
  14. package/dist/esm/components/Wizard/WizardBody.js +6 -2
  15. package/dist/esm/components/Wizard/WizardBody.js.map +1 -1
  16. package/dist/esm/components/Wizard/WizardDrawerWrapper.d.ts +11 -0
  17. package/dist/esm/components/Wizard/WizardDrawerWrapper.d.ts.map +1 -0
  18. package/dist/esm/components/Wizard/WizardDrawerWrapper.js +3 -0
  19. package/dist/esm/components/Wizard/WizardDrawerWrapper.js.map +1 -0
  20. package/dist/esm/components/Wizard/WizardToggle.d.ts +5 -1
  21. package/dist/esm/components/Wizard/WizardToggle.d.ts.map +1 -1
  22. package/dist/esm/components/Wizard/WizardToggle.js +4 -2
  23. package/dist/esm/components/Wizard/WizardToggle.js.map +1 -1
  24. package/dist/js/components/Form/FormGroup.d.ts +4 -2
  25. package/dist/js/components/Form/FormGroup.d.ts.map +1 -1
  26. package/dist/js/components/Form/FormGroup.js +4 -3
  27. package/dist/js/components/Form/FormGroup.js.map +1 -1
  28. package/dist/js/components/ProgressStepper/ProgressStep.js +2 -2
  29. package/dist/js/components/ProgressStepper/ProgressStep.js.map +1 -1
  30. package/dist/js/components/Wizard/Wizard.d.ts +9 -0
  31. package/dist/js/components/Wizard/Wizard.d.ts.map +1 -1
  32. package/dist/js/components/Wizard/Wizard.js +6 -3
  33. package/dist/js/components/Wizard/Wizard.js.map +1 -1
  34. package/dist/js/components/Wizard/WizardBody.d.ts +6 -0
  35. package/dist/js/components/Wizard/WizardBody.d.ts.map +1 -1
  36. package/dist/js/components/Wizard/WizardBody.js +6 -2
  37. package/dist/js/components/Wizard/WizardBody.js.map +1 -1
  38. package/dist/js/components/Wizard/WizardDrawerWrapper.d.ts +11 -0
  39. package/dist/js/components/Wizard/WizardDrawerWrapper.d.ts.map +1 -0
  40. package/dist/js/components/Wizard/WizardDrawerWrapper.js +7 -0
  41. package/dist/js/components/Wizard/WizardDrawerWrapper.js.map +1 -0
  42. package/dist/js/components/Wizard/WizardToggle.d.ts +5 -1
  43. package/dist/js/components/Wizard/WizardToggle.d.ts.map +1 -1
  44. package/dist/js/components/Wizard/WizardToggle.js +4 -2
  45. package/dist/js/components/Wizard/WizardToggle.js.map +1 -1
  46. package/dist/umd/react-core.js +22 -12
  47. package/dist/umd/react-core.min.js +4 -4
  48. package/package.json +6 -6
  49. package/src/components/Form/FormGroup.tsx +40 -29
  50. package/src/components/Form/examples/Form.md +12 -1271
  51. package/src/components/Form/examples/FormBasic.tsx +122 -0
  52. package/src/components/Form/examples/FormFieldGroups.tsx +324 -0
  53. package/src/components/Form/examples/FormGrid.tsx +66 -0
  54. package/src/components/Form/examples/FormGroupLabelInfo.tsx +72 -0
  55. package/src/components/Form/examples/FormHorizontal.tsx +118 -0
  56. package/src/components/Form/examples/FormHorizontalHelper.tsx +23 -0
  57. package/src/components/Form/examples/FormHorizontalStacked.tsx +11 -0
  58. package/src/components/Form/examples/FormInvalid.tsx +47 -0
  59. package/src/components/Form/examples/FormInvalidWithFormAlert.tsx +52 -0
  60. package/src/components/Form/examples/FormLimitWidth.tsx +122 -0
  61. package/src/components/Form/examples/FormSections.tsx +44 -0
  62. package/src/components/Form/examples/FormValidated.tsx +60 -0
  63. package/src/components/ProgressStepper/ProgressStep.tsx +2 -2
  64. package/src/components/ProgressStepper/__tests__/__snapshots__/ProgressStepper.test.tsx.snap +2 -4
  65. package/src/components/Wizard/Wizard.tsx +21 -1
  66. package/src/components/Wizard/WizardBody.tsx +23 -2
  67. package/src/components/Wizard/WizardDrawerWrapper.tsx +18 -0
  68. package/src/components/Wizard/WizardToggle.tsx +12 -2
  69. package/src/components/Wizard/__tests__/Wizard.test.tsx +24 -7
  70. package/src/components/Wizard/examples/Wizard.md +157 -2
  71. package/src/demos/Wizard/WizardDemo.md +1033 -2
@@ -14,7 +14,7 @@ export interface WizardToggleProps {
14
14
  /** The currently active WizardStep */
15
15
  activeStep: WizardStep;
16
16
  /** The WizardFooter */
17
- children: React.ReactNode;
17
+ children?: React.ReactNode;
18
18
  /** Set to true to remove body padding */
19
19
  hasNoBodyPadding: boolean;
20
20
  /** If the nav is open */
@@ -29,6 +29,10 @@ export interface WizardToggleProps {
29
29
  mainAriaLabel?: string;
30
30
  /** If the wizard is in-page */
31
31
  isInPage?: boolean;
32
+ /** @beta Flag indicating the wizard has a drawer for at least one of the wizard steps */
33
+ hasDrawer?: boolean;
34
+ /** @beta Flag indicating the wizard drawer is expanded */
35
+ isDrawerExpanded?: boolean;
32
36
  }
33
37
 
34
38
  export const WizardToggle: React.FunctionComponent<WizardToggleProps> = ({
@@ -42,7 +46,9 @@ export const WizardToggle: React.FunctionComponent<WizardToggleProps> = ({
42
46
  'aria-label': ariaLabel = 'Wizard Toggle',
43
47
  mainAriaLabelledBy = null,
44
48
  mainAriaLabel = null,
45
- isInPage = true
49
+ isInPage = true,
50
+ hasDrawer,
51
+ isDrawerExpanded
46
52
  }: WizardToggleProps) => {
47
53
  let activeStepIndex;
48
54
  let activeStepName;
@@ -91,7 +97,11 @@ export const WizardToggle: React.FunctionComponent<WizardToggleProps> = ({
91
97
  aria-label={mainAriaLabel}
92
98
  aria-labelledby={mainAriaLabelledBy}
93
99
  hasNoBodyPadding={hasNoBodyPadding}
100
+ activeStep={activeStep}
101
+ isDrawerExpanded={isDrawerExpanded}
102
+ hasDrawer={hasDrawer}
94
103
  >
104
+ {hasDrawer && !isDrawerExpanded && activeStep.drawerToggleButton}
95
105
  {activeStep.component}
96
106
  </WizardBody>
97
107
  </div>
@@ -1,31 +1,32 @@
1
1
  import React from 'react';
2
2
  import { render, screen } from '@testing-library/react';
3
3
  import { Wizard, WizardStepFunctionType, WizardStep } from '../Wizard';
4
+ import { DrawerPanelContent, DrawerColorVariant, DrawerHead } from '../../Drawer';
4
5
 
5
6
  describe('Wizard', () => {
6
7
  test('Wizard should match snapshot', () => {
7
8
  const steps: WizardStep[] = [
8
- { name: 'A', id: "step-A", component: <p>Step 1</p> },
9
+ { name: 'A', id: 'step-A', component: <p>Step 1</p> },
9
10
  {
10
11
  name: 'B',
11
- id: "step-B",
12
+ id: 'step-B',
12
13
  steps: [
13
14
  {
14
15
  name: 'B-1',
15
- id: "step-B-1",
16
+ id: 'step-B-1',
16
17
  component: <p>Step 2</p>,
17
18
  enableNext: true
18
19
  },
19
20
  {
20
21
  name: 'B-2',
21
- id: "step-B-2",
22
+ id: 'step-B-2',
22
23
  component: <p>Step 3</p>,
23
24
  enableNext: false
24
25
  }
25
26
  ]
26
27
  },
27
- { name: 'C', id: "step-C", component: <p>Step 4</p> },
28
- { name: 'D', id: "step-D", component: <p>Step 5</p> }
28
+ { name: 'C', id: 'step-C', component: <p>Step 4</p> },
29
+ { name: 'D', id: 'step-D', component: <p>Step 5</p> }
29
30
  ];
30
31
  const onBack: WizardStepFunctionType = step => {
31
32
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -100,6 +101,22 @@ describe('Wizard', () => {
100
101
  expect(screen.getByRole('heading', { name: 'Wizard' })).toBeInTheDocument();
101
102
  });
102
103
 
104
+ test('wiz with drawer', () => {
105
+ const wizDrawerPanelContent = (
106
+ <DrawerPanelContent colorVariant={DrawerColorVariant.light200}>
107
+ <DrawerHead>
108
+ <span>This wizard has a drawer with drawer panel content</span>
109
+ </DrawerHead>
110
+ </DrawerPanelContent>
111
+ );
112
+
113
+ const steps: WizardStep[] = [{ name: 'A', component: <p>Step 1</p>, drawerPanelContent: wizDrawerPanelContent }];
114
+
115
+ render(<Wizard title="Wizard with drawer" hasDrawer isDrawerExpanded steps={steps} />);
116
+ expect(screen.getByRole('heading', { name: 'Wizard with drawer' })).toBeInTheDocument();
117
+ expect(screen.getByText('This wizard has a drawer with drawer panel content')).toBeInTheDocument();
118
+ });
119
+
103
120
  test('wiz with title and navAriaLabel combination', () => {
104
121
  const steps: WizardStep[] = [{ name: 'A', component: <p>Step 1</p> }];
105
122
 
@@ -109,7 +126,7 @@ describe('Wizard', () => {
109
126
 
110
127
  expect(screen.getByRole('heading', { name: 'Wizard' })).toBeInTheDocument();
111
128
  expect(nav).toBeInTheDocument();
112
- expect(nav).toHaveAttribute('aria-labelledby', 'pf-wizard-title-4');
129
+ expect(nav).toHaveAttribute('aria-labelledby', 'pf-wizard-title-5');
113
130
  });
114
131
 
115
132
  test('wiz with title, navAriaLabel, and mainAriaLabel combination', () => {
@@ -2,10 +2,12 @@
2
2
  id: Wizard
3
3
  section: components
4
4
  cssPrefix: pf-c-wizard
5
- propComponents: ['Wizard', 'WizardNav', 'WizardNavItem', 'WizardHeader', 'WizardBody', 'WizardFooter', 'WizardToggle', 'WizardStep']
5
+ propComponents:
6
+ ['Wizard', 'WizardNav', 'WizardNavItem', 'WizardHeader', 'WizardBody', 'WizardFooter', 'WizardToggle', 'WizardStep']
6
7
  ---
7
8
 
8
- import { Button, Wizard, WizardFooter, WizardContextConsumer, ModalVariant, Alert, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStateSecondaryActions, Title, Progress } from '@patternfly/react-core';
9
+ import { Button, Drawer, DrawerActions, DrawerCloseButton, DrawerColorVariant,
10
+ DrawerContent, DrawerContentBody, DrawerHead, DrawerPanelContent, DrawerSection, Wizard, WizardFooter, WizardContextConsumer, ModalVariant, Alert, EmptyState, EmptyStateIcon, EmptyStateBody, EmptyStateSecondaryActions, Title, Progress } from '@patternfly/react-core';
9
11
  import ExternalLinkAltIcon from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
10
12
  import SlackHashIcon from '@patternfly/react-icons/dist/esm/icons/slack-hash-icon';
11
13
  import FinishedStep from './FinishedStep';
@@ -859,3 +861,156 @@ class WizardInModal extends React.Component {
859
861
  }
860
862
  }
861
863
  ```
864
+
865
+ ### Wizard with drawer
866
+
867
+ ```js isBeta
868
+ import React from 'react';
869
+ import {
870
+ Button,
871
+ DrawerActions,
872
+ DrawerCloseButton,
873
+ DrawerHead,
874
+ DrawerPanelContent,
875
+ Text,
876
+ TextContent,
877
+ Wizard
878
+ } from '@patternfly/react-core';
879
+
880
+ class WizardWithDrawer extends React.Component {
881
+ constructor(props) {
882
+ super(props);
883
+ this.state = {
884
+ isOpen: false,
885
+ isDrawerExpanded: false,
886
+ sectionGray: false,
887
+ panelGray: true,
888
+ contentGray: false
889
+ };
890
+
891
+ this.drawerRef = React.createRef();
892
+
893
+ this.onExpand = () => {
894
+ this.drawerRef.current && this.drawerRef.current.focus();
895
+ };
896
+
897
+ this.onOpenClick = () => {
898
+ this.setState({
899
+ isDrawerExpanded: true
900
+ });
901
+ };
902
+
903
+ this.onCloseClick = () => {
904
+ this.setState({
905
+ isDrawerExpanded: false
906
+ });
907
+ };
908
+ }
909
+
910
+ render() {
911
+ const { isDrawerExpanded } = this.state;
912
+
913
+ const panel1Content = (
914
+ <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.light200}>
915
+ <DrawerHead>
916
+ <span tabIndex={isDrawerExpanded ? 0 : -1} ref={this.drawerRef}>
917
+ drawer-panel-1 content
918
+ </span>
919
+ <DrawerActions>
920
+ <DrawerCloseButton onClick={this.onCloseClick} />
921
+ </DrawerActions>
922
+ </DrawerHead>
923
+ </DrawerPanelContent>
924
+ );
925
+
926
+ const panel2Content = (
927
+ <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.light200}>
928
+ <DrawerHead>
929
+ <span tabIndex={0} ref={this.drawerRef}>
930
+ drawer-panel-2 content
931
+ </span>
932
+ <DrawerActions>
933
+ <DrawerCloseButton onClick={this.onCloseClick} />
934
+ </DrawerActions>
935
+ </DrawerHead>
936
+ </DrawerPanelContent>
937
+ );
938
+
939
+ const panel3Content = (
940
+ <DrawerPanelContent widths={{ default: 'width_33' }} colorVariant={DrawerColorVariant.light200}>
941
+ <DrawerHead>
942
+ <span tabIndex={0} ref={this.drawerRef}>
943
+ drawer-panel-3 content
944
+ </span>
945
+ <DrawerActions>
946
+ <DrawerCloseButton onClick={this.onCloseClick} />
947
+ </DrawerActions>
948
+ </DrawerHead>
949
+ </DrawerPanelContent>
950
+ );
951
+
952
+ const drawerToggleButton = (
953
+ <Button isInline variant="link" onClick={this.onOpenClick}>
954
+ Open Drawer
955
+ </Button>
956
+ );
957
+
958
+ const steps = [
959
+ {
960
+ name: 'Information',
961
+ component: <p>Information step content</p>,
962
+ drawerPanelContent: panel1Content,
963
+ drawerToggleButton: drawerToggleButton
964
+ },
965
+ {
966
+ name: 'Configuration',
967
+ steps: [
968
+ {
969
+ name: 'Substep A',
970
+ component: <p>Substep A content</p>,
971
+ drawerPanelContent: panel2Content,
972
+ drawerToggleButton: drawerToggleButton
973
+ },
974
+ {
975
+ name: 'Substep B',
976
+ component: <p>Substep B content</p>,
977
+ drawerPanelContent: panel2Content,
978
+ drawerToggleButton: drawerToggleButton
979
+ },
980
+ {
981
+ name: 'Substep C',
982
+ component: <p>Substep C content</p>,
983
+ drawerPanelContent: panel2Content,
984
+ drawerToggleButton: drawerToggleButton
985
+ }
986
+ ]
987
+ },
988
+ {
989
+ name: 'Additional',
990
+ component: <p>Additional step content</p>,
991
+ drawerPanelContent: panel3Content,
992
+ drawerToggleButton: drawerToggleButton
993
+ },
994
+ {
995
+ name: 'Review',
996
+ component: <p>Review step content</p>,
997
+ nextButtonText: 'Finish'
998
+ }
999
+ ];
1000
+
1001
+ const title = 'Wizard with drawer';
1002
+
1003
+ return (
1004
+ <React.Fragment>
1005
+ <Wizard
1006
+ height={400}
1007
+ isDrawerExpanded={isDrawerExpanded}
1008
+ hasDrawer
1009
+ navAriaLabel={`${title} steps`}
1010
+ steps={steps}
1011
+ />
1012
+ </React.Fragment>
1013
+ );
1014
+ }
1015
+ }
1016
+ ```