@trackunit/react-form-wizard 0.1.136 → 0.1.142

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
@@ -205,7 +205,7 @@ const cvaNavigationContainer = cssClassVarianceUtilities.cvaMerge(["flex", "gap-
205
205
  * The footer component for the FormWizard.
206
206
  * In most cases you should not be using this component directly, but rather use the FormWizard component.
207
207
  */
208
- const FormWizardFooter = ({ disablePrimaryAction = false, onBack, onCancel, primaryActionLabel = "Next", }) => {
208
+ const FormWizardFooter = ({ disablePrimaryAction = false, onBack, onCancel, primaryActionLabel, }) => {
209
209
  const [t] = useTranslation();
210
210
  return (jsxRuntime.jsxs("div", { className: cvaFooterContainer(), children: [jsxRuntime.jsx(reactComponents.Button, { dataTestId: "wizard-cancel", onClick: onCancel, variant: "ghost-neutral", children: t("wizard.defaults.cancel") }), jsxRuntime.jsxs("div", { className: cvaNavigationContainer(), children: [onBack ? (jsxRuntime.jsx(reactComponents.Button, { dataTestId: "wizard-back", onClick: onBack, variant: "secondary", children: t("wizard.defaults.back") })) : null, jsxRuntime.jsx(reactComponents.Button, { dataTestId: "wizard-next", disabled: disablePrimaryAction, type: "submit", children: primaryActionLabel ? primaryActionLabel : t("wizard.defaults.next") })] })] }));
211
211
  };
@@ -528,7 +528,7 @@ const useFormWizard = (props) => {
528
528
  * This component is not intended to be used in production code.
529
529
  * It is used to test the individual steps of a form wizard.
530
530
  */
531
- const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, children, overrides = {}, }) => {
531
+ const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, children, overrides = {}, }) => {
532
532
  const form = reactHookForm.useForm({
533
533
  resolver: zod.zodResolver(fullFormSchema.shape[stepKey]),
534
534
  mode: "all",
@@ -536,6 +536,7 @@ const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, children, overrides
536
536
  const fullForm = reactHookForm.useForm({
537
537
  resolver: zod.zodResolver(fullFormSchema),
538
538
  mode: "all",
539
+ defaultValues: defaultValues,
539
540
  });
540
541
  return jsxRuntime.jsx("div", { "data-testid": stepKey, children: children(Object.assign({ form, fullForm, setSubmitHandler: () => { } }, overrides)) });
541
542
  };
package/index.esm.js CHANGED
@@ -201,7 +201,7 @@ const cvaNavigationContainer = cvaMerge(["flex", "gap-responsive-space"]);
201
201
  * The footer component for the FormWizard.
202
202
  * In most cases you should not be using this component directly, but rather use the FormWizard component.
203
203
  */
204
- const FormWizardFooter = ({ disablePrimaryAction = false, onBack, onCancel, primaryActionLabel = "Next", }) => {
204
+ const FormWizardFooter = ({ disablePrimaryAction = false, onBack, onCancel, primaryActionLabel, }) => {
205
205
  const [t] = useTranslation();
206
206
  return (jsxs("div", { className: cvaFooterContainer(), children: [jsx(Button, { dataTestId: "wizard-cancel", onClick: onCancel, variant: "ghost-neutral", children: t("wizard.defaults.cancel") }), jsxs("div", { className: cvaNavigationContainer(), children: [onBack ? (jsx(Button, { dataTestId: "wizard-back", onClick: onBack, variant: "secondary", children: t("wizard.defaults.back") })) : null, jsx(Button, { dataTestId: "wizard-next", disabled: disablePrimaryAction, type: "submit", children: primaryActionLabel ? primaryActionLabel : t("wizard.defaults.next") })] })] }));
207
207
  };
@@ -524,7 +524,7 @@ const useFormWizard = (props) => {
524
524
  * This component is not intended to be used in production code.
525
525
  * It is used to test the individual steps of a form wizard.
526
526
  */
527
- const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, children, overrides = {}, }) => {
527
+ const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, children, overrides = {}, }) => {
528
528
  const form = useForm({
529
529
  resolver: zodResolver(fullFormSchema.shape[stepKey]),
530
530
  mode: "all",
@@ -532,6 +532,7 @@ const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, children, overrides
532
532
  const fullForm = useForm({
533
533
  resolver: zodResolver(fullFormSchema),
534
534
  mode: "all",
535
+ defaultValues: defaultValues,
535
536
  });
536
537
  return jsx("div", { "data-testid": stepKey, children: children(Object.assign({ form, fullForm, setSubmitHandler: () => { } }, overrides)) });
537
538
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-wizard",
3
- "version": "0.1.136",
3
+ "version": "0.1.142",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
@@ -1,10 +1,12 @@
1
1
  import { ReactNode } from "react";
2
+ import { DeepPartial } from "react-hook-form";
2
3
  import { AnyZodObject, z } from "zod";
3
4
  import { StepComponentProps } from "../FormWizard/useFormWizard";
4
5
  export interface TestHelperFormWizardStepProps<TStepKey extends keyof z.infer<TFullSchema>, TFullSchema extends AnyZodObject> {
5
6
  overrides?: Partial<StepComponentProps<() => TFullSchema, TStepKey>>;
6
7
  fullFormSchema: TFullSchema;
7
8
  stepKey: TStepKey;
9
+ defaultValues?: DeepPartial<z.TypeOf<TFullSchema>>;
8
10
  children: (props: StepComponentProps<() => TFullSchema, TStepKey>) => ReactNode;
9
11
  }
10
12
  /**
@@ -12,4 +14,4 @@ export interface TestHelperFormWizardStepProps<TStepKey extends keyof z.infer<TF
12
14
  * This component is not intended to be used in production code.
13
15
  * It is used to test the individual steps of a form wizard.
14
16
  */
15
- export declare const TestHelperFormWizardStep: <TStepKey extends keyof z.TypeOf<TFullSchema>, TFullSchema extends AnyZodObject>({ stepKey, fullFormSchema, children, overrides, }: TestHelperFormWizardStepProps<TStepKey, TFullSchema>) => JSX.Element;
17
+ export declare const TestHelperFormWizardStep: <TStepKey extends keyof z.TypeOf<TFullSchema>, TFullSchema extends AnyZodObject>({ stepKey, fullFormSchema, defaultValues, children, overrides, }: TestHelperFormWizardStepProps<TStepKey, TFullSchema>) => JSX.Element;