@trackunit/react-form-wizard 0.0.10 → 0.0.14

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/index.cjs.js CHANGED
@@ -162,9 +162,9 @@ const getStateIcon = (state) => {
162
162
  * A sidebar step component used by the FormWizard component to render each step.
163
163
  * This component is generally used internally by the FormWizard component.
164
164
  */
165
- const FormWizardSidebarStep = ({ stepNumber, state, title, subTitle, path, dataTestId, }) => {
165
+ const FormWizardSidebarStep = ({ stepNumber, state, title, subTitle, path, dataTestId, onBeforeNavigate, }) => {
166
166
  const stateIcon = getStateIcon(state);
167
- return (jsxRuntime.jsx(reactRouterDom.NavLink, { className: cvaFormWizardSidebarStep({ state }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : `form-wizard-sidebar-step-${path}`, to: path, children: jsxRuntime.jsxs("div", { className: cvaSectionHeaderContainer(), children: [jsxRuntime.jsx("div", { children: stateIcon !== null && stateIcon !== void 0 ? stateIcon : jsxRuntime.jsx("span", { className: cvaStepNumber({ state }), children: stepNumber }) }), jsxRuntime.jsxs("div", { className: cvaTitleAndDescription(), children: [jsxRuntime.jsx("h1", { className: cvaHeader(), children: title }), subTitle ? jsxRuntime.jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
167
+ return (jsxRuntime.jsx(reactRouterDom.NavLink, { className: cvaFormWizardSidebarStep({ state }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : `form-wizard-sidebar-step-${path}`, onClick: () => onBeforeNavigate(), to: path, children: jsxRuntime.jsxs("div", { className: cvaSectionHeaderContainer(), children: [jsxRuntime.jsx("div", { children: stateIcon !== null && stateIcon !== void 0 ? stateIcon : jsxRuntime.jsx("span", { className: cvaStepNumber({ state }), children: stepNumber }) }), jsxRuntime.jsxs("div", { className: cvaTitleAndDescription(), children: [jsxRuntime.jsx("h1", { className: cvaHeader(), children: title }), subTitle ? jsxRuntime.jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
168
168
  };
169
169
 
170
170
  const cvaFooterContainer = cssClassVarianceUtilities.cvaMerge([
@@ -210,15 +210,23 @@ const cvaFormWizardComponentStepForm = cssClassVarianceUtilities.cvaMerge(["grid
210
210
  * A wrapper component used by the FormWizard component to render each step.
211
211
  * In most cases you should not be using this component directly, but rather use the FormWizard component.
212
212
  */
213
- const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, component, formSchema, nextStepPath, previousStepPath, lastStepPrimaryActionLabel, fullFormSchema, setFullFormState, fullFormState, setStepStates, basePath, }) => {
213
+ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, component, formSchema, nextStepPath, previousStepPath, lastStepPrimaryActionLabel, fullFormSchema, setFullFormState, fullFormState, stepForms, setStepForms, setStepStates, basePath, }) => {
214
214
  const navigate = reactRouterDom.useNavigate();
215
+ const formRef = react.useRef(null);
215
216
  const [submitHandlerInternal, setSubmitHandlerInternal] = react.useState(null);
216
- const form = reactHookForm.useForm({ resolver: zod.zodResolver(formSchema), mode: "all" });
217
+ const form = reactHookForm.useForm({
218
+ resolver: zod.zodResolver(formSchema),
219
+ mode: "all",
220
+ defaultValues: fullFormState[stepKey],
221
+ });
217
222
  const fullForm = reactHookForm.useForm({
218
223
  resolver: zod.zodResolver(fullFormSchema),
219
224
  mode: "all",
220
225
  defaultValues: fullFormState,
221
226
  });
227
+ react.useEffect(() => {
228
+ setStepForms(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: form })));
229
+ }, [form, setStepForms, stepKey]);
222
230
  react.useEffect(() => {
223
231
  setStepStates(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: form.formState.isValid ? "valid" : "invalid" })));
224
232
  }, [form.formState.isValid, setStepStates, stepKey]);
@@ -231,27 +239,38 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
231
239
  setSubmitHandlerInternal(() => callback);
232
240
  }, [setSubmitHandlerInternal]);
233
241
  const isEmptyStep = Object.keys(form.getValues()).length === 0;
234
- const handleSubmitING = isEmptyStep
235
- ? (e) => {
236
- e.preventDefault();
237
- submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(fullFormState);
238
- }
239
- : form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
242
+ const emptyStepSubmitHandler = react.useCallback((e) => {
243
+ e === null || e === void 0 ? void 0 : e.preventDefault();
244
+ submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(fullFormState);
245
+ }, [fullFormState, submitHandlerInternal]);
246
+ const nonEmptyStepSubmitHandler = react.useMemo(() => form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
247
+ //? This state is not updated for the submit handler below; therefore, there is duplication.
248
+ setFullFormState(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: data })));
249
+ if (isLastStep) {
240
250
  //? This state is not updated for the submit handler below; therefore, there is duplication.
241
- setFullFormState(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: data })));
242
- if (isLastStep) {
243
- //? This state is not updated for the submit handler below; therefore, there is duplication.
244
- submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(Object.assign(Object.assign({}, fullFormState), { [stepKey]: data }));
245
- }
246
- else if (nextStepPath) {
247
- navigate(basePath + nextStepPath);
248
- }
249
- }));
250
- return (jsxRuntime.jsxs("form", { className: cvaFormWizardComponentStepForm(), onSubmit: handleSubmitING, children: [jsxRuntime.jsx(FormWizardHeader, { title, description }), jsxRuntime.jsx("div", { className: cvaFormWizardComponentContainer(), children: component({
251
+ submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(Object.assign(Object.assign({}, fullFormState), { [stepKey]: data }));
252
+ }
253
+ else if (nextStepPath) {
254
+ navigate(basePath + nextStepPath);
255
+ }
256
+ })), [
257
+ basePath,
258
+ form,
259
+ fullFormState,
260
+ isLastStep,
261
+ navigate,
262
+ nextStepPath,
263
+ setFullFormState,
264
+ stepKey,
265
+ submitHandlerInternal,
266
+ ]);
267
+ const handleSubmit = react.useMemo(() => (isEmptyStep ? emptyStepSubmitHandler : nonEmptyStepSubmitHandler), [emptyStepSubmitHandler, isEmptyStep, nonEmptyStepSubmitHandler]);
268
+ return (jsxRuntime.jsxs("form", { className: cvaFormWizardComponentStepForm(), onSubmit: handleSubmit, ref: formRef, children: [jsxRuntime.jsx(FormWizardHeader, { title, description }), jsxRuntime.jsx("div", { className: cvaFormWizardComponentContainer(), children: component({
251
269
  form,
252
270
  fullForm,
253
271
  setSubmitHandler: isLastStep ? setSubmitHandler : null,
254
- }) }), jsxRuntime.jsx(FormWizardFooter, { onBack: previousStepPath ? () => navigate(basePath + previousStepPath) : null,
272
+ }) }), jsxRuntime.jsx(FormWizardFooter, { stepForms,
273
+ onBack: previousStepPath ? () => navigate(basePath + previousStepPath) : null,
255
274
  primaryActionLabel: isLastStep ? lastStepPrimaryActionLabel : undefined,
256
275
  onCancel: handleCancel,
257
276
  isValid: isEmptyStep ? true : form.formState.isValid })] }, String(stepKey)));
@@ -275,6 +294,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
275
294
  var _a;
276
295
  const location = reactRouterDom.useLocation();
277
296
  const [stepStates, setStepStates] = react.useState({});
297
+ const [stepForms, setStepForms] = react.useState({});
278
298
  const [fullFormState, setFullFormState] = react.useState({});
279
299
  const currentVisibleStepKey = (_a = Object.entries(steps).find(([, { path }]) => location.pathname === basePath + path)) === null || _a === void 0 ? void 0 : _a[0];
280
300
  const currentVisibleStepIndex = Object.keys(steps).findIndex(key => key === currentVisibleStepKey);
@@ -282,6 +302,8 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
282
302
  const isPastStep = index < currentVisibleStepIndex;
283
303
  const isFutureStep = index > currentVisibleStepIndex;
284
304
  const isCurrentStep = key === currentVisibleStepKey;
305
+ // eslint-disable-next-line local-rules/no-typescript-assertion
306
+ const previousStepKey = Object.keys(steps)[index - 1];
285
307
  const stepState = () => {
286
308
  if (isCurrentStep) {
287
309
  return "active";
@@ -302,6 +324,13 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
302
324
  state: stepState(),
303
325
  stepNumber: index + 1,
304
326
  title,
327
+ onBeforeNavigate: () => {
328
+ previousStepKey &&
329
+ setFullFormState(prev => {
330
+ var _a;
331
+ return (Object.assign(Object.assign({}, prev), { [previousStepKey]: (_a = stepForms[previousStepKey]) === null || _a === void 0 ? void 0 : _a.getValues() }));
332
+ });
333
+ },
305
334
  path: basePath + path,
306
335
  subTitle: sidebarDescription }));
307
336
  }) }), jsxRuntime.jsx("div", { className: cvaStepContainer(), children: jsxRuntime.jsx(reactRouterDom.Routes, { children: Object.entries(steps).map((_a, index) => {
@@ -309,6 +338,8 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
309
338
  var [stepKey, _f] = _a, { path } = _f, rest = __rest(_f, ["path"]);
310
339
  return (jsxRuntime.jsx(reactRouterDom.Route, { index: false, path, key: stepKey, element: jsxRuntime.jsx(FormWizardStepWrapper, Object.assign({}, rest, { basePath,
311
340
  stepKey,
341
+ stepForms,
342
+ setStepForms,
312
343
  onCancel,
313
344
  fullFormState,
314
345
  setFullFormState,
package/index.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { registerTranslations } from '@trackunit/i18n-library-translation';
3
- import { useState, useEffect, useCallback, useMemo } from 'react';
3
+ import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
4
4
  import { NavLink, useNavigate, useLocation, Routes, Route } from 'react-router-dom';
5
5
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
6
6
  import { Icon, Button, Heading } from '@trackunit/react-components';
@@ -158,9 +158,9 @@ const getStateIcon = (state) => {
158
158
  * A sidebar step component used by the FormWizard component to render each step.
159
159
  * This component is generally used internally by the FormWizard component.
160
160
  */
161
- const FormWizardSidebarStep = ({ stepNumber, state, title, subTitle, path, dataTestId, }) => {
161
+ const FormWizardSidebarStep = ({ stepNumber, state, title, subTitle, path, dataTestId, onBeforeNavigate, }) => {
162
162
  const stateIcon = getStateIcon(state);
163
- return (jsx(NavLink, { className: cvaFormWizardSidebarStep({ state }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : `form-wizard-sidebar-step-${path}`, to: path, children: jsxs("div", { className: cvaSectionHeaderContainer(), children: [jsx("div", { children: stateIcon !== null && stateIcon !== void 0 ? stateIcon : jsx("span", { className: cvaStepNumber({ state }), children: stepNumber }) }), jsxs("div", { className: cvaTitleAndDescription(), children: [jsx("h1", { className: cvaHeader(), children: title }), subTitle ? jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
163
+ return (jsx(NavLink, { className: cvaFormWizardSidebarStep({ state }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : `form-wizard-sidebar-step-${path}`, onClick: () => onBeforeNavigate(), to: path, children: jsxs("div", { className: cvaSectionHeaderContainer(), children: [jsx("div", { children: stateIcon !== null && stateIcon !== void 0 ? stateIcon : jsx("span", { className: cvaStepNumber({ state }), children: stepNumber }) }), jsxs("div", { className: cvaTitleAndDescription(), children: [jsx("h1", { className: cvaHeader(), children: title }), subTitle ? jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
164
164
  };
165
165
 
166
166
  const cvaFooterContainer = cvaMerge([
@@ -206,15 +206,23 @@ const cvaFormWizardComponentStepForm = cvaMerge(["grid-rows-min-fr-min", "grid",
206
206
  * A wrapper component used by the FormWizard component to render each step.
207
207
  * In most cases you should not be using this component directly, but rather use the FormWizard component.
208
208
  */
209
- const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, component, formSchema, nextStepPath, previousStepPath, lastStepPrimaryActionLabel, fullFormSchema, setFullFormState, fullFormState, setStepStates, basePath, }) => {
209
+ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, component, formSchema, nextStepPath, previousStepPath, lastStepPrimaryActionLabel, fullFormSchema, setFullFormState, fullFormState, stepForms, setStepForms, setStepStates, basePath, }) => {
210
210
  const navigate = useNavigate();
211
+ const formRef = useRef(null);
211
212
  const [submitHandlerInternal, setSubmitHandlerInternal] = useState(null);
212
- const form = useForm({ resolver: zodResolver(formSchema), mode: "all" });
213
+ const form = useForm({
214
+ resolver: zodResolver(formSchema),
215
+ mode: "all",
216
+ defaultValues: fullFormState[stepKey],
217
+ });
213
218
  const fullForm = useForm({
214
219
  resolver: zodResolver(fullFormSchema),
215
220
  mode: "all",
216
221
  defaultValues: fullFormState,
217
222
  });
223
+ useEffect(() => {
224
+ setStepForms(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: form })));
225
+ }, [form, setStepForms, stepKey]);
218
226
  useEffect(() => {
219
227
  setStepStates(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: form.formState.isValid ? "valid" : "invalid" })));
220
228
  }, [form.formState.isValid, setStepStates, stepKey]);
@@ -227,27 +235,38 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
227
235
  setSubmitHandlerInternal(() => callback);
228
236
  }, [setSubmitHandlerInternal]);
229
237
  const isEmptyStep = Object.keys(form.getValues()).length === 0;
230
- const handleSubmitING = isEmptyStep
231
- ? (e) => {
232
- e.preventDefault();
233
- submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(fullFormState);
234
- }
235
- : form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
238
+ const emptyStepSubmitHandler = useCallback((e) => {
239
+ e === null || e === void 0 ? void 0 : e.preventDefault();
240
+ submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(fullFormState);
241
+ }, [fullFormState, submitHandlerInternal]);
242
+ const nonEmptyStepSubmitHandler = useMemo(() => form.handleSubmit((data) => __awaiter(void 0, void 0, void 0, function* () {
243
+ //? This state is not updated for the submit handler below; therefore, there is duplication.
244
+ setFullFormState(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: data })));
245
+ if (isLastStep) {
236
246
  //? This state is not updated for the submit handler below; therefore, there is duplication.
237
- setFullFormState(prev => (Object.assign(Object.assign({}, prev), { [stepKey]: data })));
238
- if (isLastStep) {
239
- //? This state is not updated for the submit handler below; therefore, there is duplication.
240
- submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(Object.assign(Object.assign({}, fullFormState), { [stepKey]: data }));
241
- }
242
- else if (nextStepPath) {
243
- navigate(basePath + nextStepPath);
244
- }
245
- }));
246
- return (jsxs("form", { className: cvaFormWizardComponentStepForm(), onSubmit: handleSubmitING, children: [jsx(FormWizardHeader, { title, description }), jsx("div", { className: cvaFormWizardComponentContainer(), children: component({
247
+ submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(Object.assign(Object.assign({}, fullFormState), { [stepKey]: data }));
248
+ }
249
+ else if (nextStepPath) {
250
+ navigate(basePath + nextStepPath);
251
+ }
252
+ })), [
253
+ basePath,
254
+ form,
255
+ fullFormState,
256
+ isLastStep,
257
+ navigate,
258
+ nextStepPath,
259
+ setFullFormState,
260
+ stepKey,
261
+ submitHandlerInternal,
262
+ ]);
263
+ const handleSubmit = useMemo(() => (isEmptyStep ? emptyStepSubmitHandler : nonEmptyStepSubmitHandler), [emptyStepSubmitHandler, isEmptyStep, nonEmptyStepSubmitHandler]);
264
+ return (jsxs("form", { className: cvaFormWizardComponentStepForm(), onSubmit: handleSubmit, ref: formRef, children: [jsx(FormWizardHeader, { title, description }), jsx("div", { className: cvaFormWizardComponentContainer(), children: component({
247
265
  form,
248
266
  fullForm,
249
267
  setSubmitHandler: isLastStep ? setSubmitHandler : null,
250
- }) }), jsx(FormWizardFooter, { onBack: previousStepPath ? () => navigate(basePath + previousStepPath) : null,
268
+ }) }), jsx(FormWizardFooter, { stepForms,
269
+ onBack: previousStepPath ? () => navigate(basePath + previousStepPath) : null,
251
270
  primaryActionLabel: isLastStep ? lastStepPrimaryActionLabel : undefined,
252
271
  onCancel: handleCancel,
253
272
  isValid: isEmptyStep ? true : form.formState.isValid })] }, String(stepKey)));
@@ -271,6 +290,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
271
290
  var _a;
272
291
  const location = useLocation();
273
292
  const [stepStates, setStepStates] = useState({});
293
+ const [stepForms, setStepForms] = useState({});
274
294
  const [fullFormState, setFullFormState] = useState({});
275
295
  const currentVisibleStepKey = (_a = Object.entries(steps).find(([, { path }]) => location.pathname === basePath + path)) === null || _a === void 0 ? void 0 : _a[0];
276
296
  const currentVisibleStepIndex = Object.keys(steps).findIndex(key => key === currentVisibleStepKey);
@@ -278,6 +298,8 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
278
298
  const isPastStep = index < currentVisibleStepIndex;
279
299
  const isFutureStep = index > currentVisibleStepIndex;
280
300
  const isCurrentStep = key === currentVisibleStepKey;
301
+ // eslint-disable-next-line local-rules/no-typescript-assertion
302
+ const previousStepKey = Object.keys(steps)[index - 1];
281
303
  const stepState = () => {
282
304
  if (isCurrentStep) {
283
305
  return "active";
@@ -298,6 +320,13 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
298
320
  state: stepState(),
299
321
  stepNumber: index + 1,
300
322
  title,
323
+ onBeforeNavigate: () => {
324
+ previousStepKey &&
325
+ setFullFormState(prev => {
326
+ var _a;
327
+ return (Object.assign(Object.assign({}, prev), { [previousStepKey]: (_a = stepForms[previousStepKey]) === null || _a === void 0 ? void 0 : _a.getValues() }));
328
+ });
329
+ },
301
330
  path: basePath + path,
302
331
  subTitle: sidebarDescription }));
303
332
  }) }), jsx("div", { className: cvaStepContainer(), children: jsx(Routes, { children: Object.entries(steps).map((_a, index) => {
@@ -305,6 +334,8 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
305
334
  var [stepKey, _f] = _a, { path } = _f, rest = __rest(_f, ["path"]);
306
335
  return (jsx(Route, { index: false, path, key: stepKey, element: jsx(FormWizardStepWrapper, Object.assign({}, rest, { basePath,
307
336
  stepKey,
337
+ stepForms,
338
+ setStepForms,
308
339
  onCancel,
309
340
  fullFormState,
310
341
  setFullFormState,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-wizard",
3
- "version": "0.0.10",
3
+ "version": "0.0.14",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
@@ -1,6 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ZodTypeAny } from "zod";
2
+ import { UseFormReturn } from "react-hook-form";
3
+ import { ZodTypeAny, z } from "zod";
3
4
  import { ComponentStepDefinitions, FromWizardComponentProps } from "./useFormWizard";
5
+ export type FormWizardStepFormReturnMap<TFullSchema extends ZodTypeAny> = Partial<{
6
+ [TStepKey in keyof z.infer<TFullSchema>]: UseFormReturn<z.TypeOf<TFullSchema>[TStepKey]>;
7
+ }>;
4
8
  /**
5
9
  * The FormWizard component is used for forms in multiple steps.
6
10
  * Use the useFormWizard hook to generate the props for this component.
@@ -7,10 +7,11 @@ interface FormWizardSidebarStepProps extends CommonProps {
7
7
  title: string;
8
8
  subTitle?: string;
9
9
  path: string;
10
+ onBeforeNavigate: () => void;
10
11
  }
11
12
  /**
12
13
  * A sidebar step component used by the FormWizard component to render each step.
13
14
  * This component is generally used internally by the FormWizard component.
14
15
  */
15
- export declare const FormWizardSidebarStep: ({ stepNumber, state, title, subTitle, path, dataTestId, }: FormWizardSidebarStepProps) => JSX.Element;
16
+ export declare const FormWizardSidebarStep: ({ stepNumber, state, title, subTitle, path, dataTestId, onBeforeNavigate, }: FormWizardSidebarStepProps) => JSX.Element;
16
17
  export {};
@@ -1,5 +1,7 @@
1
1
  import { Dispatch, SetStateAction } from "react";
2
+ import { UseFormReturn } from "react-hook-form";
2
3
  import { ZodTypeAny, z } from "zod";
4
+ import { FormWizardStepFormReturnMap } from "../FormWizard/FormWizard";
3
5
  import { SimpleStepProps, StepComponentPropsInner, StepState } from "../FormWizard/useFormWizard";
4
6
  export interface FormWizardStepWrapperProps<TStepKey extends keyof z.infer<TFullSchema>, TFullSchema extends ZodTypeAny> extends SimpleStepProps {
5
7
  description: string;
@@ -15,9 +17,13 @@ export interface FormWizardStepWrapperProps<TStepKey extends keyof z.infer<TFull
15
17
  formSchema: z.infer<TFullSchema>[TStepKey];
16
18
  setStepStates: Dispatch<SetStateAction<Partial<Record<TStepKey, StepState>>>>;
17
19
  component: (props: StepComponentPropsInner<z.infer<TFullSchema>[TStepKey], TFullSchema>) => React.ReactNode;
20
+ stepForms: FormWizardStepFormReturnMap<TFullSchema>;
21
+ setStepForms: Dispatch<SetStateAction<Partial<{
22
+ [TStepKey2 in keyof z.TypeOf<TFullSchema>]: UseFormReturn<z.TypeOf<TFullSchema>[TStepKey2]>;
23
+ }>>>;
18
24
  }
19
25
  /**
20
26
  * A wrapper component used by the FormWizard component to render each step.
21
27
  * In most cases you should not be using this component directly, but rather use the FormWizard component.
22
28
  */
23
- export declare const FormWizardStepWrapper: <TFullSchema extends ZodTypeAny, TStepKey extends keyof z.TypeOf<TFullSchema>>({ stepKey, onCancel, description, title, component, formSchema, nextStepPath, previousStepPath, lastStepPrimaryActionLabel, fullFormSchema, setFullFormState, fullFormState, setStepStates, basePath, }: FormWizardStepWrapperProps<TStepKey, TFullSchema>) => JSX.Element;
29
+ export declare const FormWizardStepWrapper: <TFullSchema extends ZodTypeAny, TStepKey extends keyof z.TypeOf<TFullSchema>>({ stepKey, onCancel, description, title, component, formSchema, nextStepPath, previousStepPath, lastStepPrimaryActionLabel, fullFormSchema, setFullFormState, fullFormState, stepForms, setStepForms, setStepStates, basePath, }: FormWizardStepWrapperProps<TStepKey, TFullSchema>) => JSX.Element;