@trackunit/react-form-wizard 1.24.1 → 1.24.2
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
|
@@ -459,7 +459,7 @@ const cvaStepContainer = cssClassVarianceUtilities.cvaMerge(["h-full", "grid", "
|
|
|
459
459
|
* });
|
|
460
460
|
* ```
|
|
461
461
|
*/
|
|
462
|
-
const FormWizard = ({ lastStepPrimaryActionLabel, isEdit = false, steps, fullFormSchema, onCancel, className, "data-testid": dataTestId, basePath, ref, }) => {
|
|
462
|
+
const FormWizard = ({ lastStepPrimaryActionLabel, isEdit = false, steps, fullFormSchema, onCancel, className, "data-testid": dataTestId, basePath, ref, style, }) => {
|
|
463
463
|
const navigate = reactRouter.useNavigate();
|
|
464
464
|
const { stepPath, subStepPath } = reactRouter.useParams({ strict: false });
|
|
465
465
|
const initialFullFormState = react.useMemo(() => sharedUtils.objectFromEntries(sharedUtils.objectEntries(steps)
|
|
@@ -604,7 +604,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, isEdit = false, steps, fullFor
|
|
|
604
604
|
steps,
|
|
605
605
|
initialFullFormState,
|
|
606
606
|
]);
|
|
607
|
-
return (jsxRuntime.jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, ref: ref, children: jsxRuntime.jsxs("div", { className: cvaFormWizardLayout(), children: [jsxRuntime.jsx(FormWizardSidebar, { children: sidebarSteps }), jsxRuntime.jsx("div", { className: cvaStepContainer(), children: stepWrapper })] }) }));
|
|
607
|
+
return (jsxRuntime.jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, ref: ref, style: style, children: jsxRuntime.jsxs("div", { className: cvaFormWizardLayout(), children: [jsxRuntime.jsx(FormWizardSidebar, { children: sidebarSteps }), jsxRuntime.jsx("div", { className: cvaStepContainer(), children: stepWrapper })] }) }));
|
|
608
608
|
};
|
|
609
609
|
|
|
610
610
|
/**
|
|
@@ -668,7 +668,7 @@ const useFormWizard = (props) => {
|
|
|
668
668
|
* This component is not intended to be used in production code.
|
|
669
669
|
* It is used to test the individual steps of a form wizard.
|
|
670
670
|
*/
|
|
671
|
-
const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, children, overrides = {}, }) => {
|
|
671
|
+
const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, children, overrides = {}, style, }) => {
|
|
672
672
|
const form = reactHookForm.useForm({
|
|
673
673
|
resolver: zod.zodResolver(fullFormSchema.shape[stepKey]),
|
|
674
674
|
mode: "all",
|
|
@@ -679,10 +679,12 @@ const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, chil
|
|
|
679
679
|
mode: "all",
|
|
680
680
|
defaultValues: defaultValues,
|
|
681
681
|
});
|
|
682
|
-
return (jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx("div", { "data-testid": stepKey, children: children({
|
|
682
|
+
return (jsxRuntime.jsx(reactHookForm.FormProvider, { ...form, children: jsxRuntime.jsx("div", { "data-testid": stepKey, style: style, children: children({
|
|
683
683
|
form,
|
|
684
684
|
fullForm,
|
|
685
|
-
setSubmitHandler: () => {
|
|
685
|
+
setSubmitHandler: () => {
|
|
686
|
+
/* noop */
|
|
687
|
+
},
|
|
686
688
|
...overrides,
|
|
687
689
|
}) }) }));
|
|
688
690
|
};
|
package/index.esm.js
CHANGED
|
@@ -457,7 +457,7 @@ const cvaStepContainer = cvaMerge(["h-full", "grid", "bg-white", "overflow-hidde
|
|
|
457
457
|
* });
|
|
458
458
|
* ```
|
|
459
459
|
*/
|
|
460
|
-
const FormWizard = ({ lastStepPrimaryActionLabel, isEdit = false, steps, fullFormSchema, onCancel, className, "data-testid": dataTestId, basePath, ref, }) => {
|
|
460
|
+
const FormWizard = ({ lastStepPrimaryActionLabel, isEdit = false, steps, fullFormSchema, onCancel, className, "data-testid": dataTestId, basePath, ref, style, }) => {
|
|
461
461
|
const navigate = useNavigate();
|
|
462
462
|
const { stepPath, subStepPath } = useParams({ strict: false });
|
|
463
463
|
const initialFullFormState = useMemo(() => objectFromEntries(objectEntries(steps)
|
|
@@ -602,7 +602,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, isEdit = false, steps, fullFor
|
|
|
602
602
|
steps,
|
|
603
603
|
initialFullFormState,
|
|
604
604
|
]);
|
|
605
|
-
return (jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, ref: ref, children: jsxs("div", { className: cvaFormWizardLayout(), children: [jsx(FormWizardSidebar, { children: sidebarSteps }), jsx("div", { className: cvaStepContainer(), children: stepWrapper })] }) }));
|
|
605
|
+
return (jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, ref: ref, style: style, children: jsxs("div", { className: cvaFormWizardLayout(), children: [jsx(FormWizardSidebar, { children: sidebarSteps }), jsx("div", { className: cvaStepContainer(), children: stepWrapper })] }) }));
|
|
606
606
|
};
|
|
607
607
|
|
|
608
608
|
/**
|
|
@@ -666,7 +666,7 @@ const useFormWizard = (props) => {
|
|
|
666
666
|
* This component is not intended to be used in production code.
|
|
667
667
|
* It is used to test the individual steps of a form wizard.
|
|
668
668
|
*/
|
|
669
|
-
const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, children, overrides = {}, }) => {
|
|
669
|
+
const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, children, overrides = {}, style, }) => {
|
|
670
670
|
const form = useForm({
|
|
671
671
|
resolver: zodResolver(fullFormSchema.shape[stepKey]),
|
|
672
672
|
mode: "all",
|
|
@@ -677,10 +677,12 @@ const TestHelperFormWizardStep = ({ stepKey, fullFormSchema, defaultValues, chil
|
|
|
677
677
|
mode: "all",
|
|
678
678
|
defaultValues: defaultValues,
|
|
679
679
|
});
|
|
680
|
-
return (jsx(FormProvider, { ...form, children: jsx("div", { "data-testid": stepKey, children: children({
|
|
680
|
+
return (jsx(FormProvider, { ...form, children: jsx("div", { "data-testid": stepKey, style: style, children: children({
|
|
681
681
|
form,
|
|
682
682
|
fullForm,
|
|
683
|
-
setSubmitHandler: () => {
|
|
683
|
+
setSubmitHandler: () => {
|
|
684
|
+
/* noop */
|
|
685
|
+
},
|
|
684
686
|
...overrides,
|
|
685
687
|
}) }) }));
|
|
686
688
|
};
|
package/package.json
CHANGED
|
@@ -108,4 +108,4 @@ export type FormWizardStepFormReturnMap<TFullSchema extends AnyZodObject> = Part
|
|
|
108
108
|
* });
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
|
-
export declare const FormWizard: <TFullSchema extends AnyZodObject, TComponentStepDefinitions extends StepDefinitions<TFullSchema>>({ lastStepPrimaryActionLabel, isEdit, steps, fullFormSchema, onCancel, className, "data-testid": dataTestId, basePath, ref, }: FromWizardComponentProps<TFullSchema, TComponentStepDefinitions>) => import("react/jsx-runtime").JSX.Element;
|
|
111
|
+
export declare const FormWizard: <TFullSchema extends AnyZodObject, TComponentStepDefinitions extends StepDefinitions<TFullSchema>>({ lastStepPrimaryActionLabel, isEdit, steps, fullFormSchema, onCancel, className, "data-testid": dataTestId, basePath, ref, style, }: FromWizardComponentProps<TFullSchema, TComponentStepDefinitions>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RegisteredRouter } from "@tanstack/react-router";
|
|
2
2
|
import { RoutePaths } from "@tanstack/router-core";
|
|
3
|
-
import { CommonProps, Refable } from "@trackunit/react-components";
|
|
3
|
+
import { CommonProps, Refable, type Styleable } from "@trackunit/react-components";
|
|
4
4
|
import { MappedOmit } from "@trackunit/shared-utils";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { UseFormReturn } from "react-hook-form";
|
|
@@ -30,7 +30,7 @@ interface DefinedStep<TStepSchema extends TFullSchemaValue[keyof TFullSchemaValu
|
|
|
30
30
|
defaultValues?: Partial<TStepSchema>;
|
|
31
31
|
}
|
|
32
32
|
export type StepComponentProps<TFullSchemaHook extends () => AnyZodObject, TStepKey extends keyof z.TypeOf<ReturnType<TFullSchemaHook>>> = StepComponentPropsInner<z.TypeOf<ReturnType<TFullSchemaHook>>[TStepKey], z.TypeOf<ReturnType<TFullSchemaHook>>>;
|
|
33
|
-
export interface FromWizardComponentProps<TFullSchema extends AnyZodObject, TComponentStepDefinitions extends StepDefinitions<TFullSchema>> extends MappedOmit<UseFormWizardProps<TFullSchema, TComponentStepDefinitions>, "steps">, CommonProps, Refable<HTMLDivElement
|
|
33
|
+
export interface FromWizardComponentProps<TFullSchema extends AnyZodObject, TComponentStepDefinitions extends StepDefinitions<TFullSchema>> extends MappedOmit<UseFormWizardProps<TFullSchema, TComponentStepDefinitions>, "steps">, CommonProps, Refable<HTMLDivElement>, Styleable {
|
|
34
34
|
steps: TComponentStepDefinitions;
|
|
35
35
|
}
|
|
36
36
|
type StepPathString = `${string}/$stepPath`;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { Styleable } from "@trackunit/react-components";
|
|
1
2
|
import { ReactNode } from "react";
|
|
2
3
|
import { DefaultValues } from "react-hook-form";
|
|
3
4
|
import { AnyZodObject, z } from "zod";
|
|
4
5
|
import { StepComponentProps } from "../FormWizard/useFormWizard";
|
|
5
|
-
export interface TestHelperFormWizardStepProps<TStepKey extends keyof z.infer<TFullSchema>, TFullSchema extends AnyZodObject> {
|
|
6
|
+
export interface TestHelperFormWizardStepProps<TStepKey extends keyof z.infer<TFullSchema>, TFullSchema extends AnyZodObject> extends Styleable {
|
|
6
7
|
overrides?: Partial<StepComponentProps<() => TFullSchema, TStepKey>>;
|
|
7
8
|
fullFormSchema: TFullSchema;
|
|
8
9
|
stepKey: TStepKey;
|
|
@@ -14,4 +15,4 @@ export interface TestHelperFormWizardStepProps<TStepKey extends keyof z.infer<TF
|
|
|
14
15
|
* This component is not intended to be used in production code.
|
|
15
16
|
* It is used to test the individual steps of a form wizard.
|
|
16
17
|
*/
|
|
17
|
-
export declare const TestHelperFormWizardStep: <TStepKey extends keyof z.infer<TFullSchema>, TFullSchema extends AnyZodObject>({ stepKey, fullFormSchema, defaultValues, children, overrides, }: TestHelperFormWizardStepProps<TStepKey, TFullSchema>) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare const TestHelperFormWizardStep: <TStepKey extends keyof z.infer<TFullSchema>, TFullSchema extends AnyZodObject>({ stepKey, fullFormSchema, defaultValues, children, overrides, style, }: TestHelperFormWizardStepProps<TStepKey, TFullSchema>) => import("react/jsx-runtime").JSX.Element;
|