@patternfly/react-core 4.234.3 → 4.235.1

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 (147) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/next/components/Wizard/Wizard.d.ts +40 -0
  3. package/dist/esm/next/components/Wizard/Wizard.d.ts.map +1 -0
  4. package/dist/esm/next/components/Wizard/Wizard.js +86 -0
  5. package/dist/esm/next/components/Wizard/Wizard.js.map +1 -0
  6. package/dist/esm/next/components/Wizard/WizardBody.d.ts +20 -0
  7. package/dist/esm/next/components/Wizard/WizardBody.d.ts.map +1 -0
  8. package/dist/esm/next/components/Wizard/WizardBody.js +7 -0
  9. package/dist/esm/next/components/Wizard/WizardBody.js.map +1 -0
  10. package/dist/esm/next/components/Wizard/WizardContext.d.ts +49 -0
  11. package/dist/esm/next/components/Wizard/WizardContext.d.ts.map +1 -0
  12. package/dist/esm/next/components/Wizard/WizardContext.js +34 -0
  13. package/dist/esm/next/components/Wizard/WizardContext.js.map +1 -0
  14. package/dist/esm/next/components/Wizard/WizardFooter.d.ts +28 -0
  15. package/dist/esm/next/components/Wizard/WizardFooter.d.ts.map +1 -0
  16. package/dist/esm/next/components/Wizard/WizardFooter.js +11 -0
  17. package/dist/esm/next/components/Wizard/WizardFooter.js.map +1 -0
  18. package/dist/esm/next/components/Wizard/WizardHeader.d.ts +21 -0
  19. package/dist/esm/next/components/Wizard/WizardHeader.d.ts.map +1 -0
  20. package/dist/esm/next/components/Wizard/WizardHeader.js +13 -0
  21. package/dist/esm/next/components/Wizard/WizardHeader.js.map +1 -0
  22. package/dist/esm/next/components/Wizard/WizardNav.d.ts +15 -0
  23. package/dist/esm/next/components/Wizard/WizardNav.d.ts.map +1 -0
  24. package/dist/esm/next/components/Wizard/WizardNav.js +13 -0
  25. package/dist/esm/next/components/Wizard/WizardNav.js.map +1 -0
  26. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts +25 -0
  27. package/dist/esm/next/components/Wizard/WizardNavItem.d.ts.map +1 -0
  28. package/dist/esm/next/components/Wizard/WizardNavItem.js +33 -0
  29. package/dist/esm/next/components/Wizard/WizardNavItem.js.map +1 -0
  30. package/dist/esm/next/components/Wizard/WizardStep.d.ts +20 -0
  31. package/dist/esm/next/components/Wizard/WizardStep.d.ts.map +1 -0
  32. package/dist/esm/next/components/Wizard/WizardStep.js +5 -0
  33. package/dist/esm/next/components/Wizard/WizardStep.js.map +1 -0
  34. package/dist/esm/next/components/Wizard/WizardToggle.d.ts +26 -0
  35. package/dist/esm/next/components/Wizard/WizardToggle.d.ts.map +1 -0
  36. package/dist/esm/next/components/Wizard/WizardToggle.js +81 -0
  37. package/dist/esm/next/components/Wizard/WizardToggle.js.map +1 -0
  38. package/dist/esm/next/components/Wizard/hooks/index.d.ts +2 -0
  39. package/dist/esm/next/components/Wizard/hooks/index.d.ts.map +1 -0
  40. package/dist/esm/next/components/Wizard/hooks/index.js +2 -0
  41. package/dist/esm/next/components/Wizard/hooks/index.js.map +1 -0
  42. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts +8 -0
  43. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -0
  44. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.js +20 -0
  45. package/dist/esm/next/components/Wizard/hooks/useWizardFooter.js.map +1 -0
  46. package/dist/esm/next/components/Wizard/index.d.ts +12 -0
  47. package/dist/esm/next/components/Wizard/index.d.ts.map +1 -0
  48. package/dist/esm/next/components/Wizard/index.js +12 -0
  49. package/dist/esm/next/components/Wizard/index.js.map +1 -0
  50. package/dist/esm/next/components/Wizard/types.d.ts +69 -0
  51. package/dist/esm/next/components/Wizard/types.d.ts.map +1 -0
  52. package/dist/esm/next/components/Wizard/types.js +20 -0
  53. package/dist/esm/next/components/Wizard/types.js.map +1 -0
  54. package/dist/esm/next/components/Wizard/utils.d.ts +15 -0
  55. package/dist/esm/next/components/Wizard/utils.d.ts.map +1 -0
  56. package/dist/esm/next/components/Wizard/utils.js +35 -0
  57. package/dist/esm/next/components/Wizard/utils.js.map +1 -0
  58. package/dist/esm/next/components/index.d.ts +1 -1
  59. package/dist/esm/next/components/index.d.ts.map +1 -1
  60. package/dist/esm/next/components/index.js +1 -1
  61. package/dist/esm/next/components/index.js.map +1 -1
  62. package/dist/js/next/components/Wizard/Wizard.d.ts +40 -0
  63. package/dist/js/next/components/Wizard/Wizard.d.ts.map +1 -0
  64. package/dist/js/next/components/Wizard/Wizard.js +90 -0
  65. package/dist/js/next/components/Wizard/Wizard.js.map +1 -0
  66. package/dist/js/next/components/Wizard/WizardBody.d.ts +20 -0
  67. package/dist/js/next/components/Wizard/WizardBody.d.ts.map +1 -0
  68. package/dist/js/next/components/Wizard/WizardBody.js +12 -0
  69. package/dist/js/next/components/Wizard/WizardBody.js.map +1 -0
  70. package/dist/js/next/components/Wizard/WizardContext.d.ts +49 -0
  71. package/dist/js/next/components/Wizard/WizardContext.d.ts.map +1 -0
  72. package/dist/js/next/components/Wizard/WizardContext.js +40 -0
  73. package/dist/js/next/components/Wizard/WizardContext.js.map +1 -0
  74. package/dist/js/next/components/Wizard/WizardFooter.d.ts +28 -0
  75. package/dist/js/next/components/Wizard/WizardFooter.d.ts.map +1 -0
  76. package/dist/js/next/components/Wizard/WizardFooter.js +16 -0
  77. package/dist/js/next/components/Wizard/WizardFooter.js.map +1 -0
  78. package/dist/js/next/components/Wizard/WizardHeader.d.ts +21 -0
  79. package/dist/js/next/components/Wizard/WizardHeader.d.ts.map +1 -0
  80. package/dist/js/next/components/Wizard/WizardHeader.js +18 -0
  81. package/dist/js/next/components/Wizard/WizardHeader.js.map +1 -0
  82. package/dist/js/next/components/Wizard/WizardNav.d.ts +15 -0
  83. package/dist/js/next/components/Wizard/WizardNav.d.ts.map +1 -0
  84. package/dist/js/next/components/Wizard/WizardNav.js +18 -0
  85. package/dist/js/next/components/Wizard/WizardNav.js.map +1 -0
  86. package/dist/js/next/components/Wizard/WizardNavItem.d.ts +25 -0
  87. package/dist/js/next/components/Wizard/WizardNavItem.d.ts.map +1 -0
  88. package/dist/js/next/components/Wizard/WizardNavItem.js +37 -0
  89. package/dist/js/next/components/Wizard/WizardNavItem.js.map +1 -0
  90. package/dist/js/next/components/Wizard/WizardStep.d.ts +20 -0
  91. package/dist/js/next/components/Wizard/WizardStep.d.ts.map +1 -0
  92. package/dist/js/next/components/Wizard/WizardStep.js +10 -0
  93. package/dist/js/next/components/Wizard/WizardStep.js.map +1 -0
  94. package/dist/js/next/components/Wizard/WizardToggle.d.ts +26 -0
  95. package/dist/js/next/components/Wizard/WizardToggle.d.ts.map +1 -0
  96. package/dist/js/next/components/Wizard/WizardToggle.js +86 -0
  97. package/dist/js/next/components/Wizard/WizardToggle.js.map +1 -0
  98. package/dist/js/next/components/Wizard/hooks/index.d.ts +2 -0
  99. package/dist/js/next/components/Wizard/hooks/index.d.ts.map +1 -0
  100. package/dist/js/next/components/Wizard/hooks/index.js +6 -0
  101. package/dist/js/next/components/Wizard/hooks/index.js.map +1 -0
  102. package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts +8 -0
  103. package/dist/js/next/components/Wizard/hooks/useWizardFooter.d.ts.map +1 -0
  104. package/dist/js/next/components/Wizard/hooks/useWizardFooter.js +25 -0
  105. package/dist/js/next/components/Wizard/hooks/useWizardFooter.js.map +1 -0
  106. package/dist/js/next/components/Wizard/index.d.ts +12 -0
  107. package/dist/js/next/components/Wizard/index.d.ts.map +1 -0
  108. package/dist/js/next/components/Wizard/index.js +17 -0
  109. package/dist/js/next/components/Wizard/index.js.map +1 -0
  110. package/dist/js/next/components/Wizard/types.d.ts +69 -0
  111. package/dist/js/next/components/Wizard/types.d.ts.map +1 -0
  112. package/dist/js/next/components/Wizard/types.js +29 -0
  113. package/dist/js/next/components/Wizard/types.js.map +1 -0
  114. package/dist/js/next/components/Wizard/utils.d.ts +15 -0
  115. package/dist/js/next/components/Wizard/utils.d.ts.map +1 -0
  116. package/dist/js/next/components/Wizard/utils.js +41 -0
  117. package/dist/js/next/components/Wizard/utils.js.map +1 -0
  118. package/dist/js/next/components/index.d.ts +1 -1
  119. package/dist/js/next/components/index.d.ts.map +1 -1
  120. package/dist/js/next/components/index.js +1 -1
  121. package/dist/js/next/components/index.js.map +1 -1
  122. package/dist/umd/react-core.css +230 -230
  123. package/dist/umd/react-core.min.css +734 -734
  124. package/package.json +5 -5
  125. package/src/components/Card/examples/Card.md +67 -38
  126. package/src/components/Wizard/examples/Wizard.md +21 -4
  127. package/src/demos/CardDemos.md +4 -0
  128. package/src/next/components/Wizard/Wizard.tsx +184 -0
  129. package/src/next/components/Wizard/WizardBody.tsx +34 -0
  130. package/src/next/components/Wizard/WizardContext.tsx +104 -0
  131. package/src/next/components/Wizard/WizardFooter.tsx +63 -0
  132. package/src/next/components/Wizard/WizardHeader.tsx +53 -0
  133. package/src/next/components/Wizard/WizardNav.tsx +41 -0
  134. package/src/next/components/Wizard/WizardNavItem.tsx +103 -0
  135. package/src/next/components/Wizard/WizardStep.tsx +23 -0
  136. package/src/next/components/Wizard/WizardToggle.tsx +209 -0
  137. package/src/next/components/Wizard/__tests__/Wizard.test.tsx +298 -0
  138. package/src/next/components/Wizard/examples/Wizard.md +125 -0
  139. package/src/next/components/Wizard/examples/WizardBasic.tsx +22 -0
  140. package/src/next/components/Wizard/examples/WizardCustomNav.tsx +46 -0
  141. package/src/next/components/Wizard/examples/WizardKitchenSink.tsx +170 -0
  142. package/src/next/components/Wizard/hooks/index.ts +1 -0
  143. package/src/next/components/Wizard/hooks/useWizardFooter.tsx +22 -0
  144. package/src/next/components/Wizard/index.ts +11 -0
  145. package/src/next/components/Wizard/types.tsx +101 -0
  146. package/src/next/components/Wizard/utils.ts +47 -0
  147. package/src/next/components/index.ts +1 -1
@@ -0,0 +1,101 @@
1
+ import React from 'react';
2
+ import { WizardNavProps, WizardNavItemProps } from '../Wizard';
3
+
4
+ /** Type used to define 'basic' steps, or in other words, steps that are neither parents or children of parents. */
5
+ export interface WizardBasicStep {
6
+ /** Name of the step's nav item */
7
+ name: React.ReactNode;
8
+ /** Unique identifier */
9
+ id: string | number;
10
+ /** Flag to disable the step's nav item */
11
+ isDisabled?: boolean;
12
+ /** Flag to represent whether the step has been visited (navigated to) */
13
+ visited?: boolean;
14
+ /** Content shown when the step's nav item is selected. When treated as a parent step, only sub-step content will be shown. */
15
+ component?: React.ReactElement;
16
+ /** (Unused if nav is controlled) Custom WizardNavItem */
17
+ navItem?: React.ReactElement<WizardNavItemProps>;
18
+ /** (Unused if footer is controlled) Can change the Next button text. If nextButtonText is also set for the Wizard, this step specific one overrides it. */
19
+ nextButtonText?: React.ReactNode;
20
+ /** (Unused if footer is controlled) The condition needed to disable the Next button */
21
+ disableNext?: boolean;
22
+ /** (Unused if footer is controlled) True to hide the Cancel button */
23
+ hideCancelButton?: boolean;
24
+ /** (Unused if footer is controlled) True to hide the Back button */
25
+ hideBackButton?: boolean;
26
+ }
27
+
28
+ /** Type used to define parent steps. */
29
+ export interface WizardParentStep extends WizardBasicStep {
30
+ /** Nested step IDs */
31
+ subStepIds: string[];
32
+ }
33
+
34
+ /** Type used to define sub-steps. */
35
+ export interface WizardSubStep extends WizardBasicStep {
36
+ /** Unique identifier of the parent step */
37
+ parentId: string | number;
38
+ }
39
+
40
+ /** Used to customize aspects of the Wizard's default navigation. */
41
+ export interface DefaultWizardNavProps {
42
+ /** Flag indicating nav items with sub steps are expandable */
43
+ isExpandable?: boolean;
44
+ /** Aria-label for the Nav */
45
+ ariaLabel?: string;
46
+ /** Sets aria-labelledby on nav element */
47
+ ariaLabelledBy?: string;
48
+ /** Disable step nav items until they are visited */
49
+ forceStepVisit?: boolean;
50
+ }
51
+
52
+ /** Used to customize aspects of the Wizard's default footer. */
53
+ export interface DefaultWizardFooterProps {
54
+ /** The Next button text */
55
+ nextButtonText?: React.ReactNode;
56
+ /** The Back button text */
57
+ backButtonText?: React.ReactNode;
58
+ /** The Cancel button text */
59
+ cancelButtonText?: React.ReactNode;
60
+ }
61
+
62
+ /** Encompasses all step type variants that are internally controlled by the Wizard. */
63
+ export type WizardControlStep = WizardBasicStep | WizardParentStep | WizardSubStep;
64
+
65
+ /** Callback for the Wizard's 'onNext', 'onBack', and 'onNavByIndex' properties. */
66
+ export type WizardNavStepFunction = (currentStep: WizardNavStepData, previousStep: WizardNavStepData) => void;
67
+
68
+ /** Data returned for either parameter of WizardNavStepFunction. */
69
+ export type WizardNavStepData = Pick<WizardControlStep, 'id' | 'name'>;
70
+
71
+ /** Callback for the Wizard's 'nav' property. Returns element which replaces the Wizard's default navigation. */
72
+ export type CustomWizardNavFunction = (
73
+ isOpen: boolean,
74
+ steps: WizardControlStep[],
75
+ activeStep: WizardControlStep,
76
+ goToStepByIndex: (index: number) => void
77
+ ) => React.ReactElement<WizardNavProps>;
78
+
79
+ export function isCustomWizardNav(
80
+ nav: DefaultWizardNavProps | CustomWizardNavFunction
81
+ ): nav is CustomWizardNavFunction {
82
+ return typeof nav === 'function';
83
+ }
84
+
85
+ export function isCustomWizardFooter(
86
+ footer: DefaultWizardFooterProps | React.ReactElement
87
+ ): footer is React.ReactElement {
88
+ return React.isValidElement(footer);
89
+ }
90
+
91
+ export function isWizardBasicStep(step: WizardControlStep): step is WizardBasicStep {
92
+ return (step as WizardParentStep)?.subStepIds === undefined && !isWizardSubStep(step);
93
+ }
94
+
95
+ export function isWizardSubStep(step: WizardControlStep): step is WizardSubStep {
96
+ return (step as WizardSubStep)?.parentId !== undefined;
97
+ }
98
+
99
+ export function isWizardParentStep(step: WizardControlStep): step is WizardParentStep {
100
+ return (step as WizardParentStep)?.subStepIds !== undefined;
101
+ }
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+
3
+ import { WizardControlStep, WizardNavStepData } from './types';
4
+ import { WizardStep, WizardStepProps } from './WizardStep';
5
+
6
+ function hasWizardStepProps(props: WizardStepProps | any): props is WizardStepProps {
7
+ return props.name !== undefined && props.id !== undefined && props.children !== undefined;
8
+ }
9
+
10
+ /**
11
+ * Accumulate list of step & sub-step props pulled from child components
12
+ * @param children
13
+ * @returns WizardControlStep[]
14
+ */
15
+ export const buildSteps = (children: React.ReactElement<WizardStepProps> | React.ReactElement<WizardStepProps>[]) =>
16
+ React.Children.toArray(children).reduce((acc: WizardControlStep[], child) => {
17
+ if (React.isValidElement(child)) {
18
+ if (child.type === WizardStep || hasWizardStepProps(child.props)) {
19
+ // Omit "children" and use the whole "child" (WizardStep) for the component prop. Sub-steps will do the same.
20
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
+ const { steps: subSteps, id, children, ...stepProps } = child.props as WizardStepProps;
22
+
23
+ acc.push({
24
+ id,
25
+ component: child,
26
+ ...stepProps,
27
+ ...(subSteps && {
28
+ subStepIds: subSteps?.map(subStep => {
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
+ const { children, ...subStepProps } = subStep.props;
31
+ acc.push({ ...subStepProps, component: subStep, parentId: id });
32
+
33
+ return subStep.props.id;
34
+ })
35
+ })
36
+ });
37
+ } else {
38
+ throw new Error('Wizard only accepts children of type WizardStep');
39
+ }
40
+ }
41
+
42
+ return acc;
43
+ }, []);
44
+
45
+ export const normalizeNavStep = ({ id, name }: WizardNavStepData) => ({ id, name });
46
+ export const getActiveStep = (steps: WizardControlStep[], currentStepIndex: number) =>
47
+ steps.find((_, index) => index + 1 === currentStepIndex);
@@ -1 +1 @@
1
- export * from './';
1
+ export * from './Wizard';