@patternfly/react-core 4.240.0 → 4.241.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 (90) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/esm/next/components/Wizard/Wizard.d.ts +4 -2
  3. package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -1
  4. package/dist/esm/next/components/Wizard/Wizard.js +9 -18
  5. package/dist/esm/next/components/Wizard/Wizard.js.map +1 -1
  6. package/dist/esm/next/components/Wizard/WizardBody.d.ts +1 -1
  7. package/dist/esm/next/components/Wizard/WizardBody.d.ts.map +1 -1
  8. package/dist/esm/next/components/Wizard/WizardContext.d.ts +3 -3
  9. package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -1
  10. package/dist/esm/next/components/Wizard/WizardContext.js +12 -2
  11. package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -1
  12. package/dist/esm/next/components/Wizard/WizardNav.d.ts +1 -1
  13. package/dist/esm/next/components/Wizard/WizardNav.d.ts.map +1 -1
  14. package/dist/esm/next/components/Wizard/WizardNav.js +2 -2
  15. package/dist/esm/next/components/Wizard/WizardNav.js.map +1 -1
  16. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  17. package/dist/esm/next/components/Wizard/WizardNavItem.js +4 -1
  18. package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -1
  19. package/dist/esm/next/components/Wizard/WizardStep.d.ts +3 -3
  20. package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -1
  21. package/dist/esm/next/components/Wizard/WizardStep.js +1 -1
  22. package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -1
  23. package/dist/esm/next/components/Wizard/WizardToggle.d.ts +17 -8
  24. package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  25. package/dist/esm/next/components/Wizard/WizardToggle.js +29 -24
  26. package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -1
  27. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts +2 -1
  28. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -1
  29. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.js.map +1 -1
  30. package/dist/esm/next/components/Wizard/types.d.ts +7 -1
  31. package/dist/esm/next/components/Wizard/types.d.ts.map +1 -1
  32. package/dist/esm/next/components/Wizard/types.js.map +1 -1
  33. package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -1
  34. package/dist/esm/next/components/Wizard/utils.js +16 -18
  35. package/dist/esm/next/components/Wizard/utils.js.map +1 -1
  36. package/dist/js/next/components/Wizard/Wizard.d.ts +4 -2
  37. package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -1
  38. package/dist/js/next/components/Wizard/Wizard.js +6 -15
  39. package/dist/js/next/components/Wizard/Wizard.js.map +1 -1
  40. package/dist/js/next/components/Wizard/WizardBody.d.ts +1 -1
  41. package/dist/js/next/components/Wizard/WizardBody.d.ts.map +1 -1
  42. package/dist/js/next/components/Wizard/WizardContext.d.ts +3 -3
  43. package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -1
  44. package/dist/js/next/components/Wizard/WizardContext.js +12 -2
  45. package/dist/js/next/components/Wizard/WizardContext.js.map +1 -1
  46. package/dist/js/next/components/Wizard/WizardNav.d.ts +1 -1
  47. package/dist/js/next/components/Wizard/WizardNav.d.ts.map +1 -1
  48. package/dist/js/next/components/Wizard/WizardNav.js +2 -2
  49. package/dist/js/next/components/Wizard/WizardNav.js.map +1 -1
  50. package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -1
  51. package/dist/js/next/components/Wizard/WizardNavItem.js +4 -1
  52. package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -1
  53. package/dist/js/next/components/Wizard/WizardStep.d.ts +3 -3
  54. package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -1
  55. package/dist/js/next/components/Wizard/WizardStep.js +1 -1
  56. package/dist/js/next/components/Wizard/WizardStep.js.map +1 -1
  57. package/dist/js/next/components/Wizard/WizardToggle.d.ts +17 -8
  58. package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -1
  59. package/dist/js/next/components/Wizard/WizardToggle.js +32 -26
  60. package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -1
  61. package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts +2 -1
  62. package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -1
  63. package/dist/js/next/components/Wizard/hooks/useWizardFooter.js.map +1 -1
  64. package/dist/js/next/components/Wizard/types.d.ts +7 -1
  65. package/dist/js/next/components/Wizard/types.d.ts.map +1 -1
  66. package/dist/js/next/components/Wizard/types.js.map +1 -1
  67. package/dist/js/next/components/Wizard/utils.d.ts.map +1 -1
  68. package/dist/js/next/components/Wizard/utils.js +16 -18
  69. package/dist/js/next/components/Wizard/utils.js.map +1 -1
  70. package/package.json +5 -5
  71. package/src/next/components/Wizard/Wizard.tsx +34 -47
  72. package/src/next/components/Wizard/WizardBody.tsx +1 -1
  73. package/src/next/components/Wizard/WizardContext.tsx +29 -5
  74. package/src/next/components/Wizard/WizardNav.tsx +3 -3
  75. package/src/next/components/Wizard/WizardNavItem.tsx +4 -1
  76. package/src/next/components/Wizard/WizardStep.tsx +4 -4
  77. package/src/next/components/Wizard/WizardToggle.tsx +74 -49
  78. package/src/next/components/Wizard/__tests__/Wizard.test.tsx +316 -298
  79. package/src/next/components/Wizard/__tests__/WizardBody.test.tsx +41 -0
  80. package/src/next/components/Wizard/__tests__/WizardFooter.test.tsx +93 -0
  81. package/src/next/components/Wizard/__tests__/WizardStep.test.tsx +33 -0
  82. package/src/next/components/Wizard/__tests__/WizardToggle.test.tsx +113 -0
  83. package/src/next/components/Wizard/__tests__/utils.test.tsx +66 -0
  84. package/src/next/components/Wizard/examples/Wizard.md +3 -5
  85. package/src/next/components/Wizard/examples/WizardCustomNav.tsx +2 -2
  86. package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +3 -11
  87. package/src/next/components/Wizard/hooks/__tests__/useWizardFooter.test.tsx +51 -0
  88. package/src/next/components/Wizard/hooks/useWizardFooter.tsx +3 -1
  89. package/src/next/components/Wizard/types.tsx +7 -1
  90. package/src/next/components/Wizard/utils.ts +23 -21
@@ -1 +1 @@
1
- {"version":3,"file":"useWizardFooter.d.ts","sourceRoot":"","sources":["../../../../../../src/next/components/Wizard/hooks/useWizardFooter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY,MAAM,YAAY,WAAW,MAAM,GAAG,MAAM,SAanF,CAAC"}
1
+ {"version":3,"file":"useWizardFooter.d.ts","sourceRoot":"","sources":["../../../../../../src/next/components/Wizard/hooks/useWizardFooter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAGpD;;;;GAIG;AACH,eAAO,MAAM,eAAe,WAAY,wBAAwB,GAAG,MAAM,YAAY,WAAW,MAAM,GAAG,MAAM,SAa9G,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useWizardFooter.js","sourceRoot":"","sources":["../../../../../../src/next/components/Wizard/hooks/useWizardFooter.tsx"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAC1B,oDAAoD;AAEpD;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,MAA0B,EAAE,MAAwB,EAAE,EAAE;IACtF,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,gCAAgB,EAAE,CAAC;IAErD,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,EAAE,KAAK,MAAM,EAAE;YACvC,SAAS,CAAC,MAAM,CAAC,CAAC;YAElB,+BAA+B;YAC/B,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AAbW,QAAA,eAAe,mBAa1B"}
1
+ {"version":3,"file":"useWizardFooter.js","sourceRoot":"","sources":["../../../../../../src/next/components/Wizard/hooks/useWizardFooter.tsx"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAG1B,oDAAoD;AAEpD;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAAC,MAAqD,EAAE,MAAwB,EAAE,EAAE;IACjH,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,GAAG,gCAAgB,EAAE,CAAC;IAErD,eAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,MAAM,IAAI,UAAU,CAAC,EAAE,KAAK,MAAM,EAAE;YACvC,SAAS,CAAC,MAAM,CAAC,CAAC;YAElB,+BAA+B;YAC/B,OAAO,GAAG,EAAE;gBACV,SAAS,CAAC,IAAI,CAAC,CAAC;YAClB,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9C,CAAC,CAAC;AAbW,QAAA,eAAe,mBAa1B"}
@@ -52,6 +52,12 @@ export interface DefaultWizardFooterProps {
52
52
  backButtonText?: React.ReactNode;
53
53
  /** The Cancel button text */
54
54
  cancelButtonText?: React.ReactNode;
55
+ /** Next button callback */
56
+ onNext?: () => WizardNavStepFunction | void;
57
+ /** Back button callback */
58
+ onBack?: () => WizardNavStepFunction | void;
59
+ /** Cancel link callback */
60
+ onClose?: () => void;
55
61
  }
56
62
  /** Encompasses all step type variants that are internally controlled by the Wizard. */
57
63
  export declare type WizardControlStep = WizardBasicStep | WizardParentStep | WizardSubStep;
@@ -60,7 +66,7 @@ export declare type WizardNavStepFunction = (currentStep: WizardNavStepData, pre
60
66
  /** Data returned for either parameter of WizardNavStepFunction. */
61
67
  export declare type WizardNavStepData = Pick<WizardControlStep, 'id' | 'name'>;
62
68
  /** Callback for the Wizard's 'nav' property. Returns element which replaces the Wizard's default navigation. */
63
- export declare type CustomWizardNavFunction = (isOpen: boolean, steps: WizardControlStep[], activeStep: WizardControlStep, goToStepByIndex: (index: number) => void) => React.ReactElement<WizardNavProps>;
69
+ export declare type CustomWizardNavFunction = (isExpanded: boolean, steps: WizardControlStep[], activeStep: WizardControlStep, goToStepByIndex: (index: number) => void) => React.ReactElement<WizardNavProps>;
64
70
  export declare function isCustomWizardNav(nav: DefaultWizardNavProps | CustomWizardNavFunction): nav is CustomWizardNavFunction;
65
71
  export declare function isCustomWizardFooter(footer: DefaultWizardFooterProps | React.ReactElement): footer is React.ReactElement;
66
72
  export declare function isWizardBasicStep(step: WizardControlStep): step is WizardBasicStep;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/Wizard/types.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/D,mHAAmH;AACnH,MAAM,WAAW,eAAe;IAC9B,kCAAkC;IAClC,IAAI,EAAE,KAAK,CAAC,SAAS,CAAC;IACtB,wBAAwB;IACxB,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yEAAyE;IACzE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,8HAA8H;IAC9H,SAAS,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC;IAC/B,yDAAyD;IACzD,OAAO,CAAC,EAAE,KAAK,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;IACjD,2JAA2J;IAC3J,cAAc,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACjC,uFAAuF;IACvF,WAAW,CAAC,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AAyB,0CAAE,UAAU,MAAK,SAAS,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACxF,CAAC;AAFD,8CAEC;AAED,SAAgB,eAAe,CAAC,IAAuB;;IACrD,OAAO,CAAA,MAAC,IAAsB,0CAAE,QAAQ,MAAK,SAAS,CAAC;AACzD,CAAC;AAFD,0CAEC;AAED,SAAgB,kBAAkB,CAAC,IAAuB;;IACxD,OAAO,CAAA,MAAC,IAAyB,0CAAE,UAAU,MAAK,SAAS,CAAC;AAC9D,CAAC;AAFD,gDAEC"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/next/components/Wizard/types.tsx"],"names":[],"mappings":";;;;AAAA,0DAA0B;AAoF1B,SAAgB,iBAAiB,CAC/B,GAAoD;IAEpD,OAAO,OAAO,GAAG,KAAK,UAAU,CAAC;AACnC,CAAC;AAJD,8CAIC;AAED,SAAgB,oBAAoB,CAClC,MAAqD;IAErD,OAAO,eAAK,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAJD,oDAIC;AAED,SAAgB,iBAAiB,CAAC,IAAuB;;IACvD,OAAO,CAAA,MAAC,IAAyB,0CAAE,UAAU,MAAK,SAAS,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AACxF,CAAC;AAFD,8CAEC;AAED,SAAgB,eAAe,CAAC,IAAuB;;IACrD,OAAO,CAAA,MAAC,IAAsB,0CAAE,QAAQ,MAAK,SAAS,CAAC;AACzD,CAAC;AAFD,0CAEC;AAED,SAAgB,kBAAkB,CAAC,IAAuB;;IACxD,OAAO,CAAA,MAAC,IAAyB,0CAAE,UAAU,MAAK,SAAS,CAAC;AAC9D,CAAC;AAFD,gDAEC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/Wizard/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAM3D;;;;GAIG;AACH,eAAO,MAAM,UAAU,aAAc,MAAM,YAAY,CAAC,eAAe,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,CAAC,EAAE,wBA4BxG,CAAC;AAET,eAAO,MAAM,gBAAgB,iBAAkB,iBAAiB;;;CAAmB,CAAC;AACpF,eAAO,MAAM,aAAa,UAAW,iBAAiB,EAAE,oBAAoB,MAAM,sBACxB,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../../src/next/components/Wizard/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAc,eAAe,EAAE,MAAM,cAAc,CAAC;AAM3D;;;;GAIG;AACH,eAAO,MAAM,UAAU,aAAc,MAAM,YAAY,CAAC,eAAe,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,CAAC,EAAE,wBA8BxG,CAAC;AAET,eAAO,MAAM,gBAAgB,iBAAkB,iBAAiB;;;CAAmB,CAAC;AACpF,eAAO,MAAM,aAAa,UAAW,iBAAiB,EAAE,oBAAoB,MAAM,sBACxB,CAAC"}
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importDefault(require("react"));
6
6
  const WizardStep_1 = require("./WizardStep");
7
7
  function hasWizardStepProps(props) {
8
- return props.name !== undefined && props.id !== undefined && props.children !== undefined;
8
+ return props.name !== undefined && props.id !== undefined;
9
9
  }
10
10
  /**
11
11
  * Accumulate list of step & sub-step props pulled from child components
@@ -13,23 +13,21 @@ function hasWizardStepProps(props) {
13
13
  * @returns WizardControlStep[]
14
14
  */
15
15
  const buildSteps = (children) => react_1.default.Children.toArray(children).reduce((acc, child) => {
16
- if (react_1.default.isValidElement(child)) {
17
- if (child.type === WizardStep_1.WizardStep || hasWizardStepProps(child.props)) {
18
- // Omit "children" and use the whole "child" (WizardStep) for the component prop. Sub-steps will do the same.
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- const _a = child.props, { steps: subSteps, id, children } = _a, stepProps = tslib_1.__rest(_a, ["steps", "id", "children"]);
21
- acc.push(Object.assign(Object.assign({ id, component: child }, stepProps), (subSteps && {
22
- subStepIds: subSteps === null || subSteps === void 0 ? void 0 : subSteps.map(subStep => {
23
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- const _a = subStep.props, { children } = _a, subStepProps = tslib_1.__rest(_a, ["children"]);
25
- acc.push(Object.assign(Object.assign({}, subStepProps), { component: subStep, parentId: id }));
26
- return subStep.props.id;
27
- })
28
- })));
29
- }
30
- else {
31
- throw new Error('Wizard only accepts children of type WizardStep');
32
- }
16
+ if (react_1.default.isValidElement(child) && (child.type === WizardStep_1.WizardStep || hasWizardStepProps(child.props))) {
17
+ // Omit "children" and use the whole "child" (WizardStep) for the component prop. Sub-steps will do the same.
18
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
+ const _a = child.props, { steps: subSteps, id, children } = _a, stepProps = tslib_1.__rest(_a, ["steps", "id", "children"]);
20
+ acc.push(Object.assign(Object.assign({ id, component: child }, stepProps), (subSteps && {
21
+ subStepIds: subSteps === null || subSteps === void 0 ? void 0 : subSteps.map(subStep => {
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ const _a = subStep.props, { children } = _a, subStepProps = tslib_1.__rest(_a, ["children"]);
24
+ acc.push(Object.assign(Object.assign({}, subStepProps), { component: subStep, parentId: id }));
25
+ return subStep.props.id;
26
+ })
27
+ })));
28
+ }
29
+ else {
30
+ throw new Error('Wizard only accepts children of type WizardStep');
33
31
  }
34
32
  return acc;
35
33
  }, []);
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/next/components/Wizard/utils.ts"],"names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sBAA7C,2BAA+C,CAAiC,CAAC;QAEvF,GAAG,CAAC,IAAI,+BACN,EAAE,EACF,SAAS,EAAE,KAAK,IACb,SAAS,GACT,CAAC,QAAQ,IAAI;YACd,UAAU,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,GAAG,CAAC,OAAO,CAAC,EAAE;gBAClC,6DAA6D;gBAC7D,MAAM,KAAgC,OAAO,CAAC,KAAK,EAA7C,EAAE,QAAQ,OAAmC,EAA9B,YAAY,sBAA3B,YAA6B,CAAgB,CAAC;gBACpD,GAAG,CAAC,IAAI,iCACH,YAAY,KACf,SAAS,EAAE,OAAO,EAClB,QAAQ,EAAE,EAAE,IACZ,CAAC;gBAEH,OAAO,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,CAAC,CAAC;SACH,CAAC,EACF,CAAC;KACJ;SAAM;QACL,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;KACpE;IAED,OAAO,GAAG,CAAC;AACb,CAAC,EAAE,EAAE,CAAC,CAAC;AA9BI,QAAA,UAAU,cA8Bd;AAEF,MAAM,gBAAgB,GAAG,CAAC,EAAE,EAAE,EAAE,IAAI,EAAqB,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;AAAvE,QAAA,gBAAgB,oBAAuD;AAC7E,MAAM,aAAa,GAAG,CAAC,KAA0B,EAAE,gBAAwB,EAAE,EAAE,CACpF,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,KAAK,gBAAgB,CAAC,CAAC;AAD9C,QAAA,aAAa,iBACiC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.240.0",
3
+ "version": "4.241.0",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -44,9 +44,9 @@
44
44
  "generate": "node scripts/copyStyles.js"
45
45
  },
46
46
  "dependencies": {
47
- "@patternfly/react-icons": "^4.91.0",
48
- "@patternfly/react-styles": "^4.90.0",
49
- "@patternfly/react-tokens": "^4.92.0",
47
+ "@patternfly/react-icons": "^4.92.0",
48
+ "@patternfly/react-styles": "^4.91.0",
49
+ "@patternfly/react-tokens": "^4.93.0",
50
50
  "focus-trap": "6.9.2",
51
51
  "react-dropzone": "9.0.0",
52
52
  "tippy.js": "5.1.2",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8.0 || ^17.0.0",
71
71
  "react-dom": "^16.8.0 || ^17.0.0"
72
72
  },
73
- "gitHead": "2703bc1465144000deac49dab1b9d779093205c3"
73
+ "gitHead": "a2a8a79f20c5930b41ac016b84f9455764f3949a"
74
74
  }
@@ -6,16 +6,14 @@ import styles from '@patternfly/react-styles/css/components/Wizard/wizard';
6
6
  import {
7
7
  DefaultWizardFooterProps,
8
8
  DefaultWizardNavProps,
9
- isCustomWizardFooter,
10
9
  isWizardParentStep,
11
10
  WizardNavStepFunction,
12
11
  CustomWizardNavFunction
13
12
  } from './types';
14
13
  import { buildSteps, normalizeNavStep } from './utils';
15
- import { useWizardContext, WizardContextProvider } from './WizardContext';
14
+ import { WizardContextProvider } from './WizardContext';
16
15
  import { WizardStepProps } from './WizardStep';
17
- import { WizardFooter } from './WizardFooter';
18
- import { WizardToggle } from './WizardToggle';
16
+ import { WizardToggleInternal } from './WizardToggle';
19
17
 
20
18
  /**
21
19
  * Wrapper for all steps and hosts state, including navigation helpers, within context.
@@ -29,7 +27,7 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
29
27
  header?: React.ReactNode;
30
28
  /** Wizard footer */
31
29
  footer?: DefaultWizardFooterProps | React.ReactElement;
32
- /** Default wizard nav props or a custom WizardNav (with callback) */
30
+ /** Wizard nav */
33
31
  nav?: DefaultWizardNavProps | CustomWizardNavFunction;
34
32
  /** The initial index the wizard is to start on (1 or higher). Defaults to 1. */
35
33
  startIndex?: number;
@@ -39,6 +37,8 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
39
37
  width?: number | string;
40
38
  /** Custom height of the wizard */
41
39
  height?: number | string;
40
+ /** Flag to unmount inactive steps instead of hiding. Defaults to true */
41
+ unmountInactiveSteps?: boolean;
42
42
  /** Callback function when a step in the nav is clicked */
43
43
  onNavByIndex?: WizardNavStepFunction;
44
44
  /** Callback function after next button is clicked */
@@ -51,8 +51,23 @@ export interface WizardProps extends React.HTMLProps<HTMLDivElement> {
51
51
  onClose?: () => void;
52
52
  }
53
53
 
54
- export const Wizard = (props: WizardProps) => {
55
- const { startIndex = 1, children, footer, onNavByIndex, onNext, onBack, onSave, onClose, ...internalProps } = props;
54
+ export const Wizard = ({
55
+ startIndex = 1,
56
+ children,
57
+ footer,
58
+ height,
59
+ width,
60
+ className,
61
+ header,
62
+ nav,
63
+ unmountInactiveSteps,
64
+ onNavByIndex,
65
+ onNext,
66
+ onBack,
67
+ onSave,
68
+ onClose,
69
+ ...wrapperProps
70
+ }: WizardProps) => {
56
71
  const [currentStepIndex, setCurrentStepIndex] = React.useState(startIndex);
57
72
  const steps = buildSteps(children);
58
73
 
@@ -130,7 +145,7 @@ export const Wizard = (props: WizardProps) => {
130
145
  <WizardContextProvider
131
146
  steps={steps}
132
147
  currentStepIndex={currentStepIndex}
133
- footer={isCustomWizardFooter(footer) && footer}
148
+ footer={footer}
134
149
  onNext={goToNextStep}
135
150
  onBack={goToPrevStep}
136
151
  onClose={onClose}
@@ -138,47 +153,19 @@ export const Wizard = (props: WizardProps) => {
138
153
  goToStepByName={goToStepByName}
139
154
  goToStepByIndex={goToStepByIndex}
140
155
  >
141
- <WizardInternal {...internalProps} footer={footer}>
142
- {children}
143
- </WizardInternal>
156
+ <div
157
+ className={css(styles.wizard, className)}
158
+ style={{
159
+ ...(height ? { height } : {}),
160
+ ...(width ? { width } : {})
161
+ }}
162
+ {...wrapperProps}
163
+ >
164
+ {header}
165
+ <WizardToggleInternal nav={nav} unmountInactiveSteps={unmountInactiveSteps} />
166
+ </div>
144
167
  </WizardContextProvider>
145
168
  );
146
169
  };
147
170
 
148
- // eslint-disable-next-line patternfly-react/no-anonymous-functions
149
- const WizardInternal = ({ height, width, className, header, footer, nav, ...divProps }: WizardProps) => {
150
- const { activeStep, steps, footer: customFooter, onNext, onBack, onClose, goToStepByIndex } = useWizardContext();
151
-
152
- const wizardFooter = customFooter || (
153
- <WizardFooter
154
- activeStep={activeStep}
155
- onNext={onNext}
156
- onBack={onBack}
157
- onClose={onClose}
158
- disableBackButton={activeStep?.id === steps[0]?.id}
159
- {...footer}
160
- />
161
- );
162
-
163
- return (
164
- <div
165
- className={css(styles.wizard, className)}
166
- style={{
167
- ...(height ? { height } : {}),
168
- ...(width ? { width } : {})
169
- }}
170
- {...divProps}
171
- >
172
- {header}
173
- <WizardToggle
174
- steps={steps}
175
- activeStep={activeStep}
176
- footer={wizardFooter}
177
- nav={nav}
178
- goToStepByIndex={goToStepByIndex}
179
- />
180
- </div>
181
- );
182
- };
183
-
184
171
  Wizard.displayName = 'Wizard';
@@ -8,7 +8,7 @@ import { css } from '@patternfly/react-styles';
8
8
  */
9
9
 
10
10
  export interface WizardBodyProps {
11
- children?: React.ReactNode | React.ReactNode[];
11
+ children: React.ReactNode | React.ReactNode[];
12
12
  /** Set to true to remove the default body padding */
13
13
  hasNoBodyPadding?: boolean;
14
14
  /** An aria-label to use for the wrapper element */
@@ -1,6 +1,11 @@
1
1
  import React from 'react';
2
- import { WizardControlStep } from './types';
2
+
3
+ import { css } from '@patternfly/react-styles';
4
+ import styles from '@patternfly/react-styles/css/components/Wizard/wizard';
5
+
6
+ import { DefaultWizardFooterProps, isCustomWizardFooter, WizardControlStep } from './types';
3
7
  import { getActiveStep } from './utils';
8
+ import { WizardFooter } from './WizardFooter';
4
9
 
5
10
  export interface WizardContextProps {
6
11
  /** List of steps */
@@ -22,7 +27,7 @@ export interface WizardContextProps {
22
27
  /** Navigate to step by index */
23
28
  goToStepByIndex: (index: number) => void;
24
29
  /** Update the footer with any react element */
25
- setFooter: (footer: React.ReactElement) => void;
30
+ setFooter: (footer: DefaultWizardFooterProps | React.ReactElement) => void;
26
31
  }
27
32
 
28
33
  export const WizardContext = React.createContext({} as WizardContextProps);
@@ -39,7 +44,7 @@ interface WizardContextRenderProps {
39
44
  export interface WizardContextProviderProps {
40
45
  steps: WizardControlStep[];
41
46
  currentStepIndex: number;
42
- footer: React.ReactElement;
47
+ footer: DefaultWizardFooterProps | React.ReactElement;
43
48
  children: React.ReactElement | ((props: WizardContextRenderProps) => React.ReactElement);
44
49
  onNext(): void;
45
50
  onBack(): void;
@@ -66,6 +71,23 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
66
71
  const [footer, setFooter] = React.useState(initialFooter);
67
72
  const activeStep = getActiveStep(steps, currentStepIndex);
68
73
 
74
+ const wizardFooter = React.useMemo(
75
+ () =>
76
+ isCustomWizardFooter(footer) ? (
77
+ <div className={css(styles.wizardFooter)}>{footer}</div>
78
+ ) : (
79
+ <WizardFooter
80
+ activeStep={activeStep}
81
+ onNext={onNext}
82
+ onBack={onBack}
83
+ onClose={onClose}
84
+ disableBackButton={activeStep?.id === steps[0]?.id}
85
+ {...footer}
86
+ />
87
+ ),
88
+ [activeStep, footer, onBack, onClose, onNext, steps]
89
+ );
90
+
69
91
  // When the active step changes and the newly active step isn't visited, set the visited flag to true.
70
92
  React.useEffect(() => {
71
93
  if (activeStep && !activeStep?.visited) {
@@ -86,7 +108,7 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
86
108
  value={{
87
109
  steps,
88
110
  activeStep,
89
- footer,
111
+ footer: wizardFooter,
90
112
  onNext,
91
113
  onBack,
92
114
  onClose,
@@ -96,7 +118,9 @@ export const WizardContextProvider: React.FunctionComponent<WizardContextProvide
96
118
  setFooter
97
119
  }}
98
120
  >
99
- {typeof children === 'function' ? children({ activeStep, steps, footer, onNext, onBack, onClose }) : children}
121
+ {typeof children === 'function'
122
+ ? children({ activeStep, steps, footer: wizardFooter, onNext, onBack, onClose })
123
+ : children}
100
124
  </WizardContext.Provider>
101
125
  );
102
126
  };
@@ -10,7 +10,7 @@ export interface WizardNavProps {
10
10
  /** Sets the aria-labelledby attribute on the nav element */
11
11
  'aria-labelledby'?: string;
12
12
  /** Whether the nav is expanded */
13
- isOpen?: boolean;
13
+ isExpanded?: boolean;
14
14
  /** True to return the inner list without the wrapping nav element */
15
15
  returnList?: boolean;
16
16
  }
@@ -19,7 +19,7 @@ export const WizardNav: React.FunctionComponent<WizardNavProps> = ({
19
19
  children,
20
20
  'aria-label': ariaLabel,
21
21
  'aria-labelledby': ariaLabelledBy,
22
- isOpen = false,
22
+ isExpanded = false,
23
23
  returnList = false
24
24
  }: WizardNavProps) => {
25
25
  const innerList = <ol className={css(styles.wizardNavList)}>{children}</ol>;
@@ -30,7 +30,7 @@ export const WizardNav: React.FunctionComponent<WizardNavProps> = ({
30
30
 
31
31
  return (
32
32
  <nav
33
- className={css(styles.wizardNav, isOpen && styles.modifiers.expanded)}
33
+ className={css(styles.wizardNav, isExpanded && styles.modifiers.expanded)}
34
34
  aria-label={ariaLabel}
35
35
  aria-labelledby={ariaLabelledBy}
36
36
  >
@@ -73,7 +73,10 @@ export const WizardNavItem: React.FunctionComponent<WizardNavItemProps> = ({
73
73
  {...rest}
74
74
  {...(navItemComponent === 'a' ? { ...linkProps } : { ...btnProps })}
75
75
  {...(id && { id: id.toString() })}
76
- onClick={() => (isExpandable ? setIsExpanded(!isExpanded || isCurrent) : onNavItemClick(step))}
76
+ onClick={e => {
77
+ e.preventDefault();
78
+ isExpandable ? setIsExpanded(!isExpanded || isCurrent) : onNavItemClick(step);
79
+ }}
77
80
  className={css(
78
81
  styles.wizardNavLink,
79
82
  isCurrent && styles.modifiers.current,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { WizardControlStep } from './types';
3
+ import { WizardBasicStep } from './types';
4
4
  import { WizardBody, WizardBodyProps } from './WizardBody';
5
5
 
6
6
  /**
@@ -8,16 +8,16 @@ import { WizardBody, WizardBodyProps } from './WizardBody';
8
8
  * Also acts as a wrapper for content, with an optional inclusion of WizardBody.
9
9
  */
10
10
 
11
- export interface WizardStepProps extends Omit<WizardControlStep, 'parentId' | 'subStepIds' | 'visited'> {
11
+ export interface WizardStepProps extends Omit<WizardBasicStep, 'visited'> {
12
12
  /** Optional for when the step is used as a parent to sub-steps */
13
13
  children?: React.ReactNode;
14
14
  /** Props for WizardBody that wraps content by default. Can be set to null for exclusion of WizardBody. */
15
- body?: WizardBodyProps | null;
15
+ body?: Omit<WizardBodyProps, 'children'> | null;
16
16
  /** Optional list of sub-steps */
17
17
  steps?: React.ReactElement<WizardStepProps>[];
18
18
  }
19
19
 
20
20
  export const WizardStep = ({ body, children }: WizardStepProps) =>
21
- body === undefined ? <WizardBody {...body}>{children}</WizardBody> : <>{children}</>;
21
+ body || body === undefined ? <WizardBody {...body}>{children}</WizardBody> : <>{children}</>;
22
22
 
23
23
  WizardStep.displayName = 'WizardStep';
@@ -6,16 +6,17 @@ import AngleRightIcon from '@patternfly/react-icons/dist/esm/icons/angle-right-i
6
6
  import CaretDownIcon from '@patternfly/react-icons/dist/esm/icons/caret-down-icon';
7
7
 
8
8
  import { KeyTypes } from '../../../helpers/constants';
9
- import { WizardNav, WizardNavItem } from '../Wizard';
9
+ import { WizardNav, WizardNavItem, WizardNavProps } from '../Wizard';
10
10
  import {
11
11
  WizardControlStep,
12
- CustomWizardNavFunction,
13
- DefaultWizardNavProps,
14
12
  isWizardBasicStep,
15
13
  isWizardParentStep,
16
14
  isWizardSubStep,
17
- isCustomWizardNav
15
+ isCustomWizardNav,
16
+ DefaultWizardNavProps,
17
+ CustomWizardNavFunction
18
18
  } from './types';
19
+ import { useWizardContext } from './WizardContext';
19
20
 
20
21
  /**
21
22
  * Used to toggle between step content, including the body and footer. This is also where the nav and its expandability is controlled.
@@ -26,16 +27,18 @@ export interface WizardToggleProps {
26
27
  steps: WizardControlStep[];
27
28
  /** The currently active WizardStep */
28
29
  activeStep: WizardControlStep;
29
- /** The WizardFooter */
30
+ /** Wizard footer */
30
31
  footer: React.ReactElement;
31
- /** Custom WizardNav or callback used to create a default WizardNav */
32
- nav: DefaultWizardNavProps | CustomWizardNavFunction;
33
- /** Navigate using the step index */
34
- goToStepByIndex: (index: number) => void;
35
- /** The button's aria-label */
32
+ /** Wizard nav */
33
+ nav: React.ReactElement<WizardNavProps>;
34
+ /** The expandable dropdown button's aria-label */
36
35
  'aria-label'?: string;
37
36
  /** Flag to unmount inactive steps instead of hiding. Defaults to true */
38
37
  unmountInactiveSteps?: boolean;
38
+ /** Flag to determine whether the dropdown nav is expanded */
39
+ isNavExpanded?: boolean;
40
+ /** Callback to expand or collapse the dropdown nav */
41
+ toggleNavExpanded?: () => void;
39
42
  }
40
43
 
41
44
  export const WizardToggle = ({
@@ -43,20 +46,20 @@ export const WizardToggle = ({
43
46
  activeStep,
44
47
  footer,
45
48
  nav,
46
- goToStepByIndex,
49
+ isNavExpanded,
50
+ toggleNavExpanded,
47
51
  unmountInactiveSteps = true,
48
52
  'aria-label': ariaLabel = 'Wizard toggle'
49
53
  }: WizardToggleProps) => {
50
- const [isNavOpen, setIsNavOpen] = React.useState(false);
51
54
  const isActiveSubStep = isWizardSubStep(activeStep);
52
55
 
53
56
  const handleKeyClicks = React.useCallback(
54
57
  (event: KeyboardEvent): void => {
55
- if (isNavOpen && event.key === KeyTypes.Escape) {
56
- setIsNavOpen(!isNavOpen);
58
+ if (isNavExpanded && event.key === KeyTypes.Escape) {
59
+ toggleNavExpanded();
57
60
  }
58
61
  },
59
- [isNavOpen]
62
+ [isNavExpanded, toggleNavExpanded]
60
63
  );
61
64
 
62
65
  // Open/close collapsable nav on keydown event
@@ -84,19 +87,60 @@ export const WizardToggle = ({
84
87
  );
85
88
  });
86
89
 
90
+ return (
91
+ <>
92
+ <button
93
+ onClick={toggleNavExpanded}
94
+ className={css(styles.wizardToggle, isNavExpanded && 'pf-m-expanded')}
95
+ aria-label={ariaLabel}
96
+ aria-expanded={isNavExpanded}
97
+ >
98
+ <span className={css(styles.wizardToggleList)}>
99
+ <span className={css(styles.wizardToggleListItem)}>
100
+ {activeStep?.name}
101
+ {isActiveSubStep && <AngleRightIcon className={css(styles.wizardToggleSeparator)} aria-hidden="true" />}
102
+ </span>
103
+ {isActiveSubStep && <span className={css(styles.wizardToggleListItem)}>{activeStep?.name}</span>}
104
+ </span>
105
+
106
+ <span className={css(styles.wizardToggleIcon)}>
107
+ <CaretDownIcon aria-hidden="true" />
108
+ </span>
109
+ </button>
110
+ <div className={css(styles.wizardOuterWrap)}>
111
+ <div className={css(styles.wizardInnerWrap)}>
112
+ {nav}
113
+ {bodyContent}
114
+ </div>
115
+
116
+ {footer}
117
+ </div>
118
+ </>
119
+ );
120
+ };
121
+
122
+ interface WizardToggleInternalProps extends Pick<WizardToggleProps, 'unmountInactiveSteps'> {
123
+ /** Custom WizardNav or callback used to create a default WizardNav */
124
+ nav?: DefaultWizardNavProps | CustomWizardNavFunction;
125
+ }
126
+
127
+ export const WizardToggleInternal = ({ nav, unmountInactiveSteps }: WizardToggleInternalProps) => {
128
+ const [isNavExpanded, setIsNavExpanded] = React.useState(false);
129
+ const { activeStep, steps, footer, goToStepByIndex } = useWizardContext();
130
+
87
131
  const wizardNav = React.useMemo(() => {
88
132
  if (isCustomWizardNav(nav)) {
89
- return nav(isNavOpen, steps, activeStep, goToStepByIndex);
133
+ return nav(isNavExpanded, steps, activeStep, goToStepByIndex);
90
134
  }
91
135
 
92
- const props = {
93
- isOpen: isNavOpen,
136
+ const navProps = {
137
+ isExpanded: isNavExpanded,
94
138
  'aria-label': nav?.ariaLabel || 'Wizard nav',
95
139
  ...(nav?.ariaLabelledBy && { 'aria-labelledby': nav?.ariaLabelledBy })
96
140
  };
97
141
 
98
142
  return (
99
- <WizardNav {...props}>
143
+ <WizardNav {...navProps}>
100
144
  {steps.map((step, index) => {
101
145
  const stepIndex = index + 1;
102
146
  const stepNavItem = step.navItem && <React.Fragment key={step.id}>{step.navItem}</React.Fragment>;
@@ -148,7 +192,7 @@ export const WizardToggle = ({
148
192
  step={firstSubStepIndex}
149
193
  onNavItemClick={goToStepByIndex}
150
194
  >
151
- <WizardNav {...props} returnList>
195
+ <WizardNav {...navProps} returnList>
152
196
  {subNavItems}
153
197
  </WizardNav>
154
198
  </WizardNavItem>
@@ -174,37 +218,18 @@ export const WizardToggle = ({
174
218
  })}
175
219
  </WizardNav>
176
220
  );
177
- }, [activeStep?.id, goToStepByIndex, isNavOpen, nav, steps]);
221
+ }, [activeStep, goToStepByIndex, isNavExpanded, nav, steps]);
178
222
 
179
223
  return (
180
- <>
181
- <button
182
- onClick={() => setIsNavOpen(prevIsOpen => !prevIsOpen)}
183
- className={css(styles.wizardToggle, isNavOpen && 'pf-m-expanded')}
184
- aria-label={ariaLabel}
185
- aria-expanded={isNavOpen}
186
- >
187
- <span className={css(styles.wizardToggleList)}>
188
- <span className={css(styles.wizardToggleListItem)}>
189
- {activeStep?.name}
190
- {isActiveSubStep && <AngleRightIcon className={css(styles.wizardToggleSeparator)} aria-hidden="true" />}
191
- </span>
192
- {isActiveSubStep && <span className={css(styles.wizardToggleListItem)}>{activeStep?.name}</span>}
193
- </span>
194
-
195
- <span className={css(styles.wizardToggleIcon)}>
196
- <CaretDownIcon aria-hidden="true" />
197
- </span>
198
- </button>
199
- <div className={css(styles.wizardOuterWrap)}>
200
- <div className={css(styles.wizardInnerWrap)}>
201
- {wizardNav}
202
- {bodyContent}
203
- </div>
204
-
205
- {footer}
206
- </div>
207
- </>
224
+ <WizardToggle
225
+ nav={wizardNav}
226
+ footer={footer}
227
+ steps={steps}
228
+ activeStep={activeStep}
229
+ isNavExpanded={isNavExpanded}
230
+ toggleNavExpanded={() => setIsNavExpanded(prevIsExpanded => !prevIsExpanded)}
231
+ unmountInactiveSteps={unmountInactiveSteps}
232
+ />
208
233
  );
209
234
  };
210
235