@trackunit/react-form-wizard 1.13.28 → 1.13.30
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
|
@@ -169,9 +169,9 @@ const getStateIcon = (state) => {
|
|
|
169
169
|
* A sidebar step component used by the FormWizard component to render each step.
|
|
170
170
|
* This component is generally used internally by the FormWizard component.
|
|
171
171
|
*/
|
|
172
|
-
const FormWizardSidebarStep = ({ stepNumber, state, basePath, title, subTitle, path, "data-testid": dataTestId,
|
|
172
|
+
const FormWizardSidebarStep = ({ stepNumber, state, basePath, title, subTitle, path, "data-testid": dataTestId, onClickNavigate, isSubStep, }) => {
|
|
173
173
|
const stateIcon = getStateIcon(state);
|
|
174
|
-
return (jsxRuntime.jsx(reactRouter.Link, { className: cvaFormWizardSidebarStep({ state, isSubStep }), "data-testid": dataTestId ?? `form-wizard-sidebar-step-${path}`, onClick:
|
|
174
|
+
return (jsxRuntime.jsx(reactRouter.Link, { className: cvaFormWizardSidebarStep({ state, isSubStep }), "data-testid": dataTestId ?? `form-wizard-sidebar-step-${path}`, onClick: onClickNavigate, params: prev => ({ ...prev, stepPath: path }), search: prev => ({ ...prev }), to: basePath, children: jsxRuntime.jsxs("div", { className: cvaSectionHeaderContainer({ state }), children: [jsxRuntime.jsx("div", { className: cvaStepNumberContainer(), children: stateIcon ?? (jsxRuntime.jsx("span", { className: cvaStepNumber({ state, isSubStep }), "data-testid": isSubStep ? `form-wizard-sidebar-substep` : `form-wizard-sidebar-step-number-${stepNumber}`, children: stepNumber })) }), jsxRuntime.jsxs("div", { className: cvaTitleAndDescription(), children: [jsxRuntime.jsx("h3", { className: cvaHeader(), children: title }), subTitle ? jsxRuntime.jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
const cvaFooterContainer = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -191,9 +191,9 @@ const cvaNavigationContainer = cssClassVarianceUtilities.cvaMerge(["flex", "gap-
|
|
|
191
191
|
* The footer component for the FormWizard.
|
|
192
192
|
* In most cases you should not be using this component directly, but rather use the FormWizard component.
|
|
193
193
|
*/
|
|
194
|
-
const FormWizardFooter = ({ disablePrimaryAction = false, loading = false,
|
|
194
|
+
const FormWizardFooter = ({ disablePrimaryAction = false, loading = false, onClickBack, onClickCancel, primaryActionLabel, }) => {
|
|
195
195
|
const [t] = useTranslation();
|
|
196
|
-
return (jsxRuntime.jsxs("div", { className: cvaFooterContainer(), children: [jsxRuntime.jsx(reactComponents.Button, { "data-testid": "wizard-cancel", onClick:
|
|
196
|
+
return (jsxRuntime.jsxs("div", { className: cvaFooterContainer(), children: [jsxRuntime.jsx(reactComponents.Button, { "data-testid": "wizard-cancel", onClick: onClickCancel, variant: "ghost-neutral", children: t("wizard.defaults.cancel") }), jsxRuntime.jsxs("div", { className: cvaNavigationContainer(), children: [onClickBack ? (jsxRuntime.jsx(reactComponents.Button, { "data-testid": "wizard-back", onClick: onClickBack, variant: "secondary", children: t("wizard.defaults.back") })) : null, jsxRuntime.jsx(reactComponents.Button, { "data-testid": "wizard-next", disabled: disablePrimaryAction, loading: loading, type: "submit", children: primaryActionLabel ? primaryActionLabel : t("wizard.defaults.next") })] })] }));
|
|
197
197
|
};
|
|
198
198
|
|
|
199
199
|
const cvaFormWizardHeader = cssClassVarianceUtilities.cvaMerge([
|
|
@@ -335,11 +335,11 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
335
335
|
beforeStepSubmit: beforeStepSubmit,
|
|
336
336
|
resetFullFormState,
|
|
337
337
|
}) }) }), jsxRuntime.jsx(FormWizardFooter, { stepForms,
|
|
338
|
-
|
|
338
|
+
onClickBack: previousStepPath
|
|
339
339
|
? () => navigate({ to: basePath, params: { stepPath: previousStepPath } })
|
|
340
340
|
: null,
|
|
341
341
|
primaryActionLabel: isLastStep ? lastStepPrimaryActionLabel : undefined,
|
|
342
|
-
|
|
342
|
+
onClickCancel: handleCancel,
|
|
343
343
|
loading: isLastStep ? isSubmitting : false,
|
|
344
344
|
disablePrimaryAction: isSubmitting })] }, String(stepKey)));
|
|
345
345
|
};
|
|
@@ -542,7 +542,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, isEdit, steps, fullFormSchema,
|
|
|
542
542
|
return (jsxRuntime.jsx(FormWizardSidebarStep, { state: stepState(),
|
|
543
543
|
stepNumber: isSubStep ? undefined : rootSteps.indexOf(key) + 1,
|
|
544
544
|
title,
|
|
545
|
-
|
|
545
|
+
onClickNavigate: () => {
|
|
546
546
|
if (previousStepKey) {
|
|
547
547
|
const previousStepForm = stepForms[previousStepKey];
|
|
548
548
|
setFullFormState(prev => ({
|
package/index.esm.js
CHANGED
|
@@ -167,9 +167,9 @@ const getStateIcon = (state) => {
|
|
|
167
167
|
* A sidebar step component used by the FormWizard component to render each step.
|
|
168
168
|
* This component is generally used internally by the FormWizard component.
|
|
169
169
|
*/
|
|
170
|
-
const FormWizardSidebarStep = ({ stepNumber, state, basePath, title, subTitle, path, "data-testid": dataTestId,
|
|
170
|
+
const FormWizardSidebarStep = ({ stepNumber, state, basePath, title, subTitle, path, "data-testid": dataTestId, onClickNavigate, isSubStep, }) => {
|
|
171
171
|
const stateIcon = getStateIcon(state);
|
|
172
|
-
return (jsx(Link, { className: cvaFormWizardSidebarStep({ state, isSubStep }), "data-testid": dataTestId ?? `form-wizard-sidebar-step-${path}`, onClick:
|
|
172
|
+
return (jsx(Link, { className: cvaFormWizardSidebarStep({ state, isSubStep }), "data-testid": dataTestId ?? `form-wizard-sidebar-step-${path}`, onClick: onClickNavigate, params: prev => ({ ...prev, stepPath: path }), search: prev => ({ ...prev }), to: basePath, children: jsxs("div", { className: cvaSectionHeaderContainer({ state }), children: [jsx("div", { className: cvaStepNumberContainer(), children: stateIcon ?? (jsx("span", { className: cvaStepNumber({ state, isSubStep }), "data-testid": isSubStep ? `form-wizard-sidebar-substep` : `form-wizard-sidebar-step-number-${stepNumber}`, children: stepNumber })) }), jsxs("div", { className: cvaTitleAndDescription(), children: [jsx("h3", { className: cvaHeader(), children: title }), subTitle ? jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
const cvaFooterContainer = cvaMerge([
|
|
@@ -189,9 +189,9 @@ const cvaNavigationContainer = cvaMerge(["flex", "gap-2"]);
|
|
|
189
189
|
* The footer component for the FormWizard.
|
|
190
190
|
* In most cases you should not be using this component directly, but rather use the FormWizard component.
|
|
191
191
|
*/
|
|
192
|
-
const FormWizardFooter = ({ disablePrimaryAction = false, loading = false,
|
|
192
|
+
const FormWizardFooter = ({ disablePrimaryAction = false, loading = false, onClickBack, onClickCancel, primaryActionLabel, }) => {
|
|
193
193
|
const [t] = useTranslation();
|
|
194
|
-
return (jsxs("div", { className: cvaFooterContainer(), children: [jsx(Button, { "data-testid": "wizard-cancel", onClick:
|
|
194
|
+
return (jsxs("div", { className: cvaFooterContainer(), children: [jsx(Button, { "data-testid": "wizard-cancel", onClick: onClickCancel, variant: "ghost-neutral", children: t("wizard.defaults.cancel") }), jsxs("div", { className: cvaNavigationContainer(), children: [onClickBack ? (jsx(Button, { "data-testid": "wizard-back", onClick: onClickBack, variant: "secondary", children: t("wizard.defaults.back") })) : null, jsx(Button, { "data-testid": "wizard-next", disabled: disablePrimaryAction, loading: loading, type: "submit", children: primaryActionLabel ? primaryActionLabel : t("wizard.defaults.next") })] })] }));
|
|
195
195
|
};
|
|
196
196
|
|
|
197
197
|
const cvaFormWizardHeader = cvaMerge([
|
|
@@ -333,11 +333,11 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
333
333
|
beforeStepSubmit: beforeStepSubmit,
|
|
334
334
|
resetFullFormState,
|
|
335
335
|
}) }) }), jsx(FormWizardFooter, { stepForms,
|
|
336
|
-
|
|
336
|
+
onClickBack: previousStepPath
|
|
337
337
|
? () => navigate({ to: basePath, params: { stepPath: previousStepPath } })
|
|
338
338
|
: null,
|
|
339
339
|
primaryActionLabel: isLastStep ? lastStepPrimaryActionLabel : undefined,
|
|
340
|
-
|
|
340
|
+
onClickCancel: handleCancel,
|
|
341
341
|
loading: isLastStep ? isSubmitting : false,
|
|
342
342
|
disablePrimaryAction: isSubmitting })] }, String(stepKey)));
|
|
343
343
|
};
|
|
@@ -540,7 +540,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, isEdit, steps, fullFormSchema,
|
|
|
540
540
|
return (jsx(FormWizardSidebarStep, { state: stepState(),
|
|
541
541
|
stepNumber: isSubStep ? undefined : rootSteps.indexOf(key) + 1,
|
|
542
542
|
title,
|
|
543
|
-
|
|
543
|
+
onClickNavigate: () => {
|
|
544
544
|
if (previousStepKey) {
|
|
545
545
|
const previousStepForm = stepForms[previousStepKey];
|
|
546
546
|
setFullFormState(prev => ({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-wizard",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.30",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
"react-hook-form": "7.62.0",
|
|
11
11
|
"@tanstack/react-router": "1.114.29",
|
|
12
12
|
"@tanstack/router-core": "1.114.29",
|
|
13
|
-
"@trackunit/shared-utils": "1.13.
|
|
14
|
-
"@trackunit/css-class-variance-utilities": "1.11.
|
|
15
|
-
"@trackunit/react-components": "1.17.
|
|
16
|
-
"@trackunit/i18n-library-translation": "1.12.
|
|
13
|
+
"@trackunit/shared-utils": "1.13.45",
|
|
14
|
+
"@trackunit/css-class-variance-utilities": "1.11.45",
|
|
15
|
+
"@trackunit/react-components": "1.17.27",
|
|
16
|
+
"@trackunit/i18n-library-translation": "1.12.30"
|
|
17
17
|
},
|
|
18
18
|
"engines": {
|
|
19
19
|
"node": ">=24.x",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
|
-
import { ReactElement } from "react";
|
|
2
|
+
import { ReactElement, MouseEventHandler } from "react";
|
|
3
3
|
interface FormWizardFooterProps extends CommonProps {
|
|
4
4
|
primaryActionLabel?: string;
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
onClickCancel: MouseEventHandler<HTMLElement>;
|
|
6
|
+
onClickBack: (() => void) | null;
|
|
7
7
|
disablePrimaryAction?: boolean;
|
|
8
8
|
loading: boolean;
|
|
9
9
|
}
|
|
@@ -11,5 +11,5 @@ interface FormWizardFooterProps extends CommonProps {
|
|
|
11
11
|
* The footer component for the FormWizard.
|
|
12
12
|
* In most cases you should not be using this component directly, but rather use the FormWizard component.
|
|
13
13
|
*/
|
|
14
|
-
export declare const FormWizardFooter: ({ disablePrimaryAction, loading,
|
|
14
|
+
export declare const FormWizardFooter: ({ disablePrimaryAction, loading, onClickBack, onClickCancel, primaryActionLabel, }: FormWizardFooterProps) => ReactElement;
|
|
15
15
|
export {};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RegisteredRouter, RouteIds } from "@tanstack/react-router";
|
|
2
2
|
import { CommonProps } from "@trackunit/react-components";
|
|
3
|
+
import { MouseEventHandler } from "react";
|
|
3
4
|
import { StepState, StringWithStepKey } from "../FormWizard/useFormWizard";
|
|
4
5
|
interface FormWizardSidebarStepProps extends CommonProps {
|
|
5
6
|
state: StepState;
|
|
@@ -8,12 +9,12 @@ interface FormWizardSidebarStepProps extends CommonProps {
|
|
|
8
9
|
basePath: StringWithStepKey<`${RouteIds<RegisteredRouter["routeTree"]>}`>;
|
|
9
10
|
subTitle?: string;
|
|
10
11
|
path: string;
|
|
11
|
-
|
|
12
|
+
onClickNavigate: MouseEventHandler<HTMLElement>;
|
|
12
13
|
isSubStep?: boolean;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* A sidebar step component used by the FormWizard component to render each step.
|
|
16
17
|
* This component is generally used internally by the FormWizard component.
|
|
17
18
|
*/
|
|
18
|
-
export declare const FormWizardSidebarStep: ({ stepNumber, state, basePath, title, subTitle, path, "data-testid": dataTestId,
|
|
19
|
+
export declare const FormWizardSidebarStep: ({ stepNumber, state, basePath, title, subTitle, path, "data-testid": dataTestId, onClickNavigate, isSubStep, }: FormWizardSidebarStepProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
20
|
export {};
|