Skip to content

Commit 9f067a2

Browse files
committed
fix(carbon): add ts for wizard and tests
1 parent 98666bd commit 9f067a2

File tree

3 files changed

+394
-2
lines changed

3 files changed

+394
-2
lines changed

packages/carbon-component-mapper/src/files/wizard.d.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
import { Field, AnyObject } from "@data-driven-forms/react-form-renderer";
2+
import { ReactNode } from "react";
3+
import { ButtonProps, ProgressIndicatorProps, ProgressStepProps } from "carbon-components-react";
4+
5+
export interface WizardButtonLabels {
6+
submit?: ReactNode;
7+
back?: ReactNode;
8+
next?: ReactNode;
9+
}
210

311
export interface WizardNextStepFunctionArgument {
412
values?: AnyObject;
@@ -27,9 +35,21 @@ export interface WizardField {
2735
disableForwardJumping?: boolean;
2836
}
2937

38+
export interface WizardNavItem extends ProgressStepProps {
39+
title: ReactNode;
40+
}
41+
3042
export interface WizardProps {
3143
crossroads?: string[];
3244
fields: WizardField[];
45+
buttonLabels?: WizardButtonLabels;
46+
BackButtonProps?: ButtonProps;
47+
NextButtonProps?: ButtonProps;
48+
SubmitButtonProps?: ButtonProps;
49+
ButtonSetProps?: React.HTMLProps<HTMLDivElement>;
50+
ProgressIndicatorProps?: ProgressIndicatorProps;
51+
vertical?: boolean;
52+
stepsInfo?: WizardNavItem[];
3353
}
3454

3555
declare const Wizard: React.ComponentType<WizardProps>;

packages/carbon-component-mapper/src/files/wizard.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,17 @@ const WizardInternal = ({
9999
{currentStep.nextStep ? (
100100
<Button
101101
onClick={() => handleNext(selectNext(currentStep.nextStep, formOptions.getState))}
102-
disabled={invalid || validating || submitting}
102+
disabled={!formOptions.valid || invalid || validating || submitting}
103103
{...NextButtonProps}
104104
>
105105
{finalButtoLabels.next}
106106
</Button>
107107
) : (
108-
<Button onClick={() => formOptions.handleSubmit()} disabled={invalid || validating || submitting} {...SubmitButtonProps}>
108+
<Button
109+
onClick={() => formOptions.handleSubmit()}
110+
disabled={!formOptions.valid || invalid || validating || submitting}
111+
{...SubmitButtonProps}
112+
>
109113
{finalButtoLabels.submit}
110114
</Button>
111115
)}

0 commit comments

Comments
 (0)