@trackunit/react-form-wizard 0.0.14 → 0.0.17
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 +18 -0
- package/index.esm.js +18 -1
- package/package.json +1 -1
- package/src/TestHelpers/TestHelperFormWizardStep.d.ts +15 -0
- package/src/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -364,6 +364,23 @@ const useFormWizard = (props) => {
|
|
|
364
364
|
])) })), [props]);
|
|
365
365
|
};
|
|
366
366
|
|
|
367
|
+
/**
|
|
368
|
+
* A helper component to be used in tests to render a single step of a form wizard.
|
|
369
|
+
* This component is not intended to be used in production code.
|
|
370
|
+
* It is used to test the individual steps of a form wizard.
|
|
371
|
+
*/
|
|
372
|
+
const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, children, overrides = {}, }) => {
|
|
373
|
+
const form = reactHookForm.useForm({
|
|
374
|
+
resolver: zod.zodResolver(fullFormSchema.shape[stepKey]),
|
|
375
|
+
mode: "all",
|
|
376
|
+
});
|
|
377
|
+
const fullForm = reactHookForm.useForm({
|
|
378
|
+
resolver: zod.zodResolver(fullFormSchema),
|
|
379
|
+
mode: "all",
|
|
380
|
+
});
|
|
381
|
+
return jsxRuntime.jsx("div", { "data-testid": stepKey, children: children(Object.assign({ form, fullForm, setSubmitHandler: () => { } }, overrides)) });
|
|
382
|
+
};
|
|
383
|
+
|
|
367
384
|
/*
|
|
368
385
|
* ----------------------------
|
|
369
386
|
* | SETUP TRANSLATIONS START |
|
|
@@ -374,4 +391,5 @@ const useFormWizard = (props) => {
|
|
|
374
391
|
setupLibraryTranslations();
|
|
375
392
|
|
|
376
393
|
exports.FormWizard = FormWizard;
|
|
394
|
+
exports.TestHelperFormWizardStep = TestHelperFormWizardStep;
|
|
377
395
|
exports.useFormWizard = useFormWizard;
|
package/index.esm.js
CHANGED
|
@@ -360,6 +360,23 @@ const useFormWizard = (props) => {
|
|
|
360
360
|
])) })), [props]);
|
|
361
361
|
};
|
|
362
362
|
|
|
363
|
+
/**
|
|
364
|
+
* A helper component to be used in tests to render a single step of a form wizard.
|
|
365
|
+
* This component is not intended to be used in production code.
|
|
366
|
+
* It is used to test the individual steps of a form wizard.
|
|
367
|
+
*/
|
|
368
|
+
const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, children, overrides = {}, }) => {
|
|
369
|
+
const form = useForm({
|
|
370
|
+
resolver: zodResolver(fullFormSchema.shape[stepKey]),
|
|
371
|
+
mode: "all",
|
|
372
|
+
});
|
|
373
|
+
const fullForm = useForm({
|
|
374
|
+
resolver: zodResolver(fullFormSchema),
|
|
375
|
+
mode: "all",
|
|
376
|
+
});
|
|
377
|
+
return jsx("div", { "data-testid": stepKey, children: children(Object.assign({ form, fullForm, setSubmitHandler: () => { } }, overrides)) });
|
|
378
|
+
};
|
|
379
|
+
|
|
363
380
|
/*
|
|
364
381
|
* ----------------------------
|
|
365
382
|
* | SETUP TRANSLATIONS START |
|
|
@@ -369,4 +386,4 @@ const useFormWizard = (props) => {
|
|
|
369
386
|
*/
|
|
370
387
|
setupLibraryTranslations();
|
|
371
388
|
|
|
372
|
-
export { FormWizard, useFormWizard };
|
|
389
|
+
export { FormWizard, TestHelperFormWizardStep, useFormWizard };
|
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { AnyZodObject, z } from "zod";
|
|
3
|
+
import { StepComponentProps } from "../FormWizard/useFormWizard";
|
|
4
|
+
export interface TestHelperFormWizardStepProps<TStepKey extends keyof z.infer<TFullSchema>, TFullSchema extends AnyZodObject> {
|
|
5
|
+
overrides?: Partial<StepComponentProps<() => TFullSchema, TStepKey>>;
|
|
6
|
+
fullFormSchema: TFullSchema;
|
|
7
|
+
stepKey: TStepKey;
|
|
8
|
+
children: (props: StepComponentProps<() => TFullSchema, TStepKey>) => ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A helper component to be used in tests to render a single step of a form wizard.
|
|
12
|
+
* This component is not intended to be used in production code.
|
|
13
|
+
* It is used to test the individual steps of a form wizard.
|
|
14
|
+
*/
|
|
15
|
+
export declare const TestHelperFormWizardStep: <TStepKey extends keyof z.TypeOf<TFullSchema>, TFullSchema extends AnyZodObject>({ stepKey, fullFormSchema, children, overrides, }: TestHelperFormWizardStepProps<TStepKey, TFullSchema>) => JSX.Element;
|
package/src/index.d.ts
CHANGED