@trackunit/react-form-wizard 0.1.4 → 0.1.5
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
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
6
|
var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
|
|
7
|
+
var reactRouter = require('@tanstack/react-router');
|
|
7
8
|
var sharedUtils = require('@trackunit/shared-utils');
|
|
8
9
|
var react = require('react');
|
|
9
|
-
var reactRouterDom = require('react-router-dom');
|
|
10
10
|
var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
|
|
11
11
|
var reactComponents = require('@trackunit/react-components');
|
|
12
12
|
var zod = require('@hookform/resolvers/zod');
|
|
@@ -154,9 +154,9 @@ const getStateIcon = (state) => {
|
|
|
154
154
|
* A sidebar step component used by the FormWizard component to render each step.
|
|
155
155
|
* This component is generally used internally by the FormWizard component.
|
|
156
156
|
*/
|
|
157
|
-
const FormWizardSidebarStep = ({ stepNumber, state, title, subTitle, path, dataTestId, onNavigate, isSubStep, }) => {
|
|
157
|
+
const FormWizardSidebarStep = ({ stepNumber, state, basePath, title, subTitle, path, dataTestId, onNavigate, isSubStep, }) => {
|
|
158
158
|
const stateIcon = getStateIcon(state);
|
|
159
|
-
return (jsxRuntime.jsx(
|
|
159
|
+
return (jsxRuntime.jsx(reactRouter.Link, { className: cvaFormWizardSidebarStep({ state, isSubStep }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : `form-wizard-sidebar-step-${path}`, onClick: () => onNavigate(), params: { stepPath: path }, to: basePath, children: jsxRuntime.jsxs("div", { className: cvaSectionHeaderContainer(), children: [jsxRuntime.jsx("div", { children: stateIcon !== null && stateIcon !== void 0 ? stateIcon : jsxRuntime.jsx("span", { className: cvaStepNumber({ state, isSubStep }), children: stepNumber }) }), jsxRuntime.jsxs("div", { className: cvaTitleAndDescription(), children: [jsxRuntime.jsx("h1", { className: cvaHeader(), children: title }), subTitle ? jsxRuntime.jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
|
|
160
160
|
};
|
|
161
161
|
|
|
162
162
|
/******************************************************************************
|
|
@@ -229,7 +229,7 @@ const cvaFormWizardComponentStepForm = cssClassVarianceUtilities.cvaMerge(["grid
|
|
|
229
229
|
* In most cases you should not be using this component directly, but rather use the FormWizard component.
|
|
230
230
|
*/
|
|
231
231
|
const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, component, formSchema, nextStepPath, previousStepPath, lastStepPrimaryActionLabel, fullFormSchema, setFullFormState, fullFormState, stepForms, setStepForms, setStepStates, basePath, }) => {
|
|
232
|
-
const navigate =
|
|
232
|
+
const navigate = reactRouter.useNavigate();
|
|
233
233
|
const formRef = react.useRef(null);
|
|
234
234
|
const [submitHandlerInternal, setSubmitHandlerInternal] = react.useState(null);
|
|
235
235
|
const form = reactHookForm.useForm({
|
|
@@ -259,7 +259,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
259
259
|
const isLastStep = nextStepPath === null;
|
|
260
260
|
const handleCancel = react.useCallback(() => {
|
|
261
261
|
// TODO: Get previous path from before wizard the wizard was started
|
|
262
|
-
return onCancel ? onCancel() : navigate(basePath);
|
|
262
|
+
return onCancel ? onCancel() : navigate({ to: basePath, params: { stepPath: "" } });
|
|
263
263
|
}, [onCancel, navigate, basePath]);
|
|
264
264
|
const setSubmitHandler = react.useCallback(callback => {
|
|
265
265
|
setSubmitHandlerInternal(() => callback);
|
|
@@ -277,7 +277,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
277
277
|
submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(Object.assign(Object.assign({}, fullFormState), { [stepKey]: data }));
|
|
278
278
|
}
|
|
279
279
|
else if (nextStepPath) {
|
|
280
|
-
navigate(basePath
|
|
280
|
+
navigate({ to: basePath, params: { stepPath: nextStepPath } });
|
|
281
281
|
}
|
|
282
282
|
})), [
|
|
283
283
|
basePath,
|
|
@@ -296,7 +296,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
296
296
|
fullForm,
|
|
297
297
|
setSubmitHandler: isLastStep ? setSubmitHandler : null,
|
|
298
298
|
}) }), jsxRuntime.jsx(FormWizardFooter, { stepForms,
|
|
299
|
-
onBack: previousStepPath ? () => navigate(basePath
|
|
299
|
+
onBack: previousStepPath ? () => navigate({ to: basePath, params: { stepPath: previousStepPath } }) : null,
|
|
300
300
|
primaryActionLabel: isLastStep ? lastStepPrimaryActionLabel : undefined,
|
|
301
301
|
onCancel: handleCancel,
|
|
302
302
|
isValid: isEmptyStep ? true : form.formState.isValid })] }, String(stepKey)));
|
|
@@ -318,7 +318,7 @@ const cvaStepContainer = cssClassVarianceUtilities.cvaMerge(["h-full", "grid", "
|
|
|
318
318
|
*/
|
|
319
319
|
const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCancel, className, dataTestId, basePath, }) => {
|
|
320
320
|
var _a;
|
|
321
|
-
const
|
|
321
|
+
const { stepPath, subStepPath } = reactRouter.useParams({ from: basePath });
|
|
322
322
|
const [stepStates, setStepStates] = react.useState({});
|
|
323
323
|
const [stepForms, setStepForms] = react.useState({});
|
|
324
324
|
const [fullFormState, setFullFormState] = react.useState(
|
|
@@ -327,7 +327,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
|
|
|
327
327
|
// Any weakening of the type in a union would be worse and likely just push the issue forward until it hits react-hook-form
|
|
328
328
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
329
329
|
{});
|
|
330
|
-
const currentVisibleStepKey = (_a = sharedUtils.objectEntries(steps).find(([, { path }]) =>
|
|
330
|
+
const currentVisibleStepKey = (_a = sharedUtils.objectEntries(steps).find(([, { path }]) => subStepPath ? path === `${stepPath}/${subStepPath}` : path === stepPath)) === null || _a === void 0 ? void 0 : _a[0];
|
|
331
331
|
const currentVisibleStepIndex = sharedUtils.objectKeys(steps).findIndex(key => key === currentVisibleStepKey);
|
|
332
332
|
return (jsxRuntime.jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, children: jsxRuntime.jsxs("div", { className: cvaFormWizardLayout(), children: [jsxRuntime.jsx(FormWizardSidebar, { children: sharedUtils.objectEntries(steps)
|
|
333
333
|
.filter(([_, step]) => { var _a, _b; return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true; })
|
|
@@ -367,32 +367,33 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
|
|
|
367
367
|
return (Object.assign(Object.assign({}, prev), { [previousStepKey]: (_a = stepForms[previousStepKey]) === null || _a === void 0 ? void 0 : _a.getValues() }));
|
|
368
368
|
});
|
|
369
369
|
},
|
|
370
|
-
|
|
370
|
+
basePath,
|
|
371
|
+
path: path,
|
|
371
372
|
subTitle: sidebarDescription,
|
|
372
373
|
isSubStep }));
|
|
373
|
-
}) }), jsxRuntime.jsx("div", { className: cvaStepContainer(), children:
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
374
|
+
}) }), jsxRuntime.jsx("div", { className: cvaStepContainer(), children: sharedUtils.objectEntries(steps)
|
|
375
|
+
.filter(([_, step]) => {
|
|
376
|
+
var _a, _b;
|
|
377
|
+
return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true;
|
|
378
|
+
})
|
|
379
|
+
.map(([stepKey, props], index) => {
|
|
380
|
+
var _a, _b, _c, _d;
|
|
381
|
+
return (subStepPath ? props.path === `${stepPath}/${subStepPath}` : props.path === stepPath) ? (jsxRuntime.jsx(FormWizardStepWrapper, Object.assign({}, props, {
|
|
382
|
+
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
383
|
+
formSchema: props.formSchema,
|
|
384
|
+
basePath,
|
|
385
|
+
stepKey: stepKey.toString(),
|
|
386
|
+
stepForms,
|
|
387
|
+
setStepForms,
|
|
388
|
+
onCancel,
|
|
389
|
+
fullFormState,
|
|
390
|
+
setFullFormState,
|
|
391
|
+
setStepStates,
|
|
392
|
+
fullFormSchema,
|
|
393
|
+
lastStepPrimaryActionLabel,
|
|
394
|
+
nextStepPath: (_b = (_a = sharedUtils.objectValues(steps).filter(step => { var _a, _b; return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true; })[index + 1]) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : null,
|
|
395
|
+
previousStepPath: (_d = (_c = sharedUtils.objectValues(steps).filter(step => { var _a, _b; return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true; })[index - 1]) === null || _c === void 0 ? void 0 : _c.path) !== null && _d !== void 0 ? _d : null }), stepKey.toString())) : null;
|
|
396
|
+
}) })] }) }));
|
|
396
397
|
};
|
|
397
398
|
|
|
398
399
|
/**
|
package/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
|
|
3
|
+
import { Link, useNavigate, useParams } from '@tanstack/react-router';
|
|
3
4
|
import { objectKeys, objectEntries, objectValues, objectFromEntries } from '@trackunit/shared-utils';
|
|
4
5
|
import { useRef, useState, useEffect, useCallback, useMemo } from 'react';
|
|
5
|
-
import { NavLink, useNavigate, useLocation, Routes, Route } from 'react-router-dom';
|
|
6
6
|
import { cvaMerge } from '@trackunit/css-class-variance-utilities';
|
|
7
7
|
import { Icon, Button, Heading } from '@trackunit/react-components';
|
|
8
8
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
@@ -150,9 +150,9 @@ const getStateIcon = (state) => {
|
|
|
150
150
|
* A sidebar step component used by the FormWizard component to render each step.
|
|
151
151
|
* This component is generally used internally by the FormWizard component.
|
|
152
152
|
*/
|
|
153
|
-
const FormWizardSidebarStep = ({ stepNumber, state, title, subTitle, path, dataTestId, onNavigate, isSubStep, }) => {
|
|
153
|
+
const FormWizardSidebarStep = ({ stepNumber, state, basePath, title, subTitle, path, dataTestId, onNavigate, isSubStep, }) => {
|
|
154
154
|
const stateIcon = getStateIcon(state);
|
|
155
|
-
return (jsx(
|
|
155
|
+
return (jsx(Link, { className: cvaFormWizardSidebarStep({ state, isSubStep }), "data-testid": dataTestId !== null && dataTestId !== void 0 ? dataTestId : `form-wizard-sidebar-step-${path}`, onClick: () => onNavigate(), params: { stepPath: path }, to: basePath, children: jsxs("div", { className: cvaSectionHeaderContainer(), children: [jsx("div", { children: stateIcon !== null && stateIcon !== void 0 ? stateIcon : jsx("span", { className: cvaStepNumber({ state, isSubStep }), children: stepNumber }) }), jsxs("div", { className: cvaTitleAndDescription(), children: [jsx("h1", { className: cvaHeader(), children: title }), subTitle ? jsx("p", { className: cvaSubtitle(), children: subTitle }) : null] })] }) }));
|
|
156
156
|
};
|
|
157
157
|
|
|
158
158
|
/******************************************************************************
|
|
@@ -255,7 +255,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
255
255
|
const isLastStep = nextStepPath === null;
|
|
256
256
|
const handleCancel = useCallback(() => {
|
|
257
257
|
// TODO: Get previous path from before wizard the wizard was started
|
|
258
|
-
return onCancel ? onCancel() : navigate(basePath);
|
|
258
|
+
return onCancel ? onCancel() : navigate({ to: basePath, params: { stepPath: "" } });
|
|
259
259
|
}, [onCancel, navigate, basePath]);
|
|
260
260
|
const setSubmitHandler = useCallback(callback => {
|
|
261
261
|
setSubmitHandlerInternal(() => callback);
|
|
@@ -273,7 +273,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
273
273
|
submitHandlerInternal === null || submitHandlerInternal === void 0 ? void 0 : submitHandlerInternal(Object.assign(Object.assign({}, fullFormState), { [stepKey]: data }));
|
|
274
274
|
}
|
|
275
275
|
else if (nextStepPath) {
|
|
276
|
-
navigate(basePath
|
|
276
|
+
navigate({ to: basePath, params: { stepPath: nextStepPath } });
|
|
277
277
|
}
|
|
278
278
|
})), [
|
|
279
279
|
basePath,
|
|
@@ -292,7 +292,7 @@ const FormWizardStepWrapper = ({ stepKey, onCancel, description, title, componen
|
|
|
292
292
|
fullForm,
|
|
293
293
|
setSubmitHandler: isLastStep ? setSubmitHandler : null,
|
|
294
294
|
}) }), jsx(FormWizardFooter, { stepForms,
|
|
295
|
-
onBack: previousStepPath ? () => navigate(basePath
|
|
295
|
+
onBack: previousStepPath ? () => navigate({ to: basePath, params: { stepPath: previousStepPath } }) : null,
|
|
296
296
|
primaryActionLabel: isLastStep ? lastStepPrimaryActionLabel : undefined,
|
|
297
297
|
onCancel: handleCancel,
|
|
298
298
|
isValid: isEmptyStep ? true : form.formState.isValid })] }, String(stepKey)));
|
|
@@ -314,7 +314,7 @@ const cvaStepContainer = cvaMerge(["h-full", "grid", "bg-white", "overflow-hidde
|
|
|
314
314
|
*/
|
|
315
315
|
const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCancel, className, dataTestId, basePath, }) => {
|
|
316
316
|
var _a;
|
|
317
|
-
const
|
|
317
|
+
const { stepPath, subStepPath } = useParams({ from: basePath });
|
|
318
318
|
const [stepStates, setStepStates] = useState({});
|
|
319
319
|
const [stepForms, setStepForms] = useState({});
|
|
320
320
|
const [fullFormState, setFullFormState] = useState(
|
|
@@ -323,7 +323,7 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
|
|
|
323
323
|
// Any weakening of the type in a union would be worse and likely just push the issue forward until it hits react-hook-form
|
|
324
324
|
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
325
325
|
{});
|
|
326
|
-
const currentVisibleStepKey = (_a = objectEntries(steps).find(([, { path }]) =>
|
|
326
|
+
const currentVisibleStepKey = (_a = objectEntries(steps).find(([, { path }]) => subStepPath ? path === `${stepPath}/${subStepPath}` : path === stepPath)) === null || _a === void 0 ? void 0 : _a[0];
|
|
327
327
|
const currentVisibleStepIndex = objectKeys(steps).findIndex(key => key === currentVisibleStepKey);
|
|
328
328
|
return (jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, children: jsxs("div", { className: cvaFormWizardLayout(), children: [jsx(FormWizardSidebar, { children: objectEntries(steps)
|
|
329
329
|
.filter(([_, step]) => { var _a, _b; return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true; })
|
|
@@ -363,32 +363,33 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
|
|
|
363
363
|
return (Object.assign(Object.assign({}, prev), { [previousStepKey]: (_a = stepForms[previousStepKey]) === null || _a === void 0 ? void 0 : _a.getValues() }));
|
|
364
364
|
});
|
|
365
365
|
},
|
|
366
|
-
|
|
366
|
+
basePath,
|
|
367
|
+
path: path,
|
|
367
368
|
subTitle: sidebarDescription,
|
|
368
369
|
isSubStep }));
|
|
369
|
-
}) }), jsx("div", { className: cvaStepContainer(), children:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
370
|
+
}) }), jsx("div", { className: cvaStepContainer(), children: objectEntries(steps)
|
|
371
|
+
.filter(([_, step]) => {
|
|
372
|
+
var _a, _b;
|
|
373
|
+
return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true;
|
|
374
|
+
})
|
|
375
|
+
.map(([stepKey, props], index) => {
|
|
376
|
+
var _a, _b, _c, _d;
|
|
377
|
+
return (subStepPath ? props.path === `${stepPath}/${subStepPath}` : props.path === stepPath) ? (jsx(FormWizardStepWrapper, Object.assign({}, props, {
|
|
378
|
+
// eslint-disable-next-line local-rules/no-typescript-assertion
|
|
379
|
+
formSchema: props.formSchema,
|
|
380
|
+
basePath,
|
|
381
|
+
stepKey: stepKey.toString(),
|
|
382
|
+
stepForms,
|
|
383
|
+
setStepForms,
|
|
384
|
+
onCancel,
|
|
385
|
+
fullFormState,
|
|
386
|
+
setFullFormState,
|
|
387
|
+
setStepStates,
|
|
388
|
+
fullFormSchema,
|
|
389
|
+
lastStepPrimaryActionLabel,
|
|
390
|
+
nextStepPath: (_b = (_a = objectValues(steps).filter(step => { var _a, _b; return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true; })[index + 1]) === null || _a === void 0 ? void 0 : _a.path) !== null && _b !== void 0 ? _b : null,
|
|
391
|
+
previousStepPath: (_d = (_c = objectValues(steps).filter(step => { var _a, _b; return (_b = (_a = step.shouldRender) === null || _a === void 0 ? void 0 : _a.call(step, fullFormState)) !== null && _b !== void 0 ? _b : true; })[index - 1]) === null || _c === void 0 ? void 0 : _c.path) !== null && _d !== void 0 ? _d : null }), stepKey.toString())) : null;
|
|
392
|
+
}) })] }) }));
|
|
392
393
|
};
|
|
393
394
|
|
|
394
395
|
/**
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-form-wizard",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"react": "^18.2.0",
|
|
8
|
-
"react-router-dom": "6.18.0",
|
|
9
8
|
"zod": "3.22.4",
|
|
10
9
|
"@trackunit/css-class-variance-utilities": "*",
|
|
11
10
|
"@trackunit/react-components": "*",
|
|
12
11
|
"@hookform/resolvers": "^3.3.4",
|
|
13
12
|
"react-hook-form": "7.40.0",
|
|
14
13
|
"@trackunit/i18n-library-translation": "*",
|
|
14
|
+
"@tanstack/react-router": "1.19.1",
|
|
15
15
|
"@trackunit/shared-utils": "*"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RegisteredRouter, RouteIds } from "@tanstack/react-router";
|
|
1
2
|
import { CommonProps } from "@trackunit/react-components";
|
|
2
3
|
import { ReactNode } from "react";
|
|
3
4
|
import { UseFormReturn } from "react-hook-form";
|
|
@@ -32,11 +33,12 @@ interface DefinedComponentStep<TStepSchema extends TFullSchemaValue[keyof TFullS
|
|
|
32
33
|
export interface FromWizardComponentProps<TFullSchema extends AnyZodObject, TComponentStepDefinitions extends ComponentStepDefinitions<TFullSchema>> extends Omit<UseFormWizardProps<TFullSchema, TComponentStepDefinitions>, "steps">, CommonProps {
|
|
33
34
|
steps: TComponentStepDefinitions;
|
|
34
35
|
}
|
|
36
|
+
export type StringWithStepKey<TPath> = TPath extends `${infer Prefix}/$stepPath` ? TPath : never;
|
|
35
37
|
export interface UseFormWizardProps<TFullSchema extends SomeZodObject, TStepDefinitions extends StepDefinitions<TFullSchema>> {
|
|
36
38
|
fullFormSchema: TFullSchema;
|
|
37
39
|
lastStepPrimaryActionLabel: string;
|
|
38
40
|
onCancel?: () => void;
|
|
39
|
-
basePath:
|
|
41
|
+
basePath: StringWithStepKey<`${RouteIds<RegisteredRouter["routeTree"]>}`>;
|
|
40
42
|
steps: TStepDefinitions;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
import { RegisteredRouter, RouteIds } from "@tanstack/react-router";
|
|
2
3
|
import { CommonProps } from "@trackunit/react-components";
|
|
3
|
-
import { StepState } from "../FormWizard/useFormWizard";
|
|
4
|
+
import { StepState, StringWithStepKey } from "../FormWizard/useFormWizard";
|
|
4
5
|
interface FormWizardSidebarStepProps extends CommonProps {
|
|
5
6
|
state: StepState;
|
|
6
7
|
stepNumber?: number;
|
|
7
8
|
title: string;
|
|
9
|
+
basePath: StringWithStepKey<`${RouteIds<RegisteredRouter["routeTree"]>}`>;
|
|
8
10
|
subTitle?: string;
|
|
9
11
|
path: string;
|
|
10
12
|
onNavigate: () => void;
|
|
@@ -14,5 +16,5 @@ interface FormWizardSidebarStepProps extends CommonProps {
|
|
|
14
16
|
* A sidebar step component used by the FormWizard component to render each step.
|
|
15
17
|
* This component is generally used internally by the FormWizard component.
|
|
16
18
|
*/
|
|
17
|
-
export declare const FormWizardSidebarStep: ({ stepNumber, state, title, subTitle, path, dataTestId, onNavigate, isSubStep, }: FormWizardSidebarStepProps) => JSX.Element;
|
|
19
|
+
export declare const FormWizardSidebarStep: ({ stepNumber, state, basePath, title, subTitle, path, dataTestId, onNavigate, isSubStep, }: FormWizardSidebarStepProps) => JSX.Element;
|
|
18
20
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { RegisteredRouter, RoutePaths } from "@tanstack/react-router";
|
|
1
2
|
import { Dispatch, ReactNode, SetStateAction } from "react";
|
|
2
3
|
import { DeepPartial, UseFormReturn } from "react-hook-form";
|
|
3
4
|
import { AnyZodObject, z } from "zod";
|
|
4
5
|
import { FormWizardStepFormReturnMap } from "../FormWizard/FormWizard";
|
|
5
|
-
import { ComponentStepDefinitions, SimpleStepProps, StepComponentPropsInner } from "../FormWizard/useFormWizard";
|
|
6
|
+
import { ComponentStepDefinitions, SimpleStepProps, StepComponentPropsInner, StringWithStepKey } from "../FormWizard/useFormWizard";
|
|
6
7
|
export type StepFormValidity = "valid" | "invalid";
|
|
7
8
|
export interface FormWizardStepWrapperProps<TStepKey extends keyof z.TypeOf<TFullSchema>, TFullSchema extends AnyZodObject> extends SimpleStepProps {
|
|
8
9
|
description: string | ReactNode;
|
|
9
10
|
lastStepPrimaryActionLabel: string;
|
|
10
11
|
nextStepPath: string | null;
|
|
11
|
-
basePath:
|
|
12
|
+
basePath: StringWithStepKey<`${RoutePaths<RegisteredRouter["routeTree"]>}`>;
|
|
12
13
|
previousStepPath: string | null;
|
|
13
14
|
onCancel?: () => void;
|
|
14
15
|
fullFormSchema: TFullSchema;
|