@trackunit/react-form-wizard 0.1.11 → 0.1.13

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
@@ -332,7 +332,9 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
332
332
  // A possible workaround could be to type it Partial<<DeepPartial<...>>> everywhere
333
333
  // Any weakening of the type in a union would be worse and likely just push the issue forward until it hits react-hook-form
334
334
  // eslint-disable-next-line local-rules/no-typescript-assertion
335
- {});
335
+ sharedUtils.objectFromEntries(sharedUtils.objectEntries(steps)
336
+ .filter(([_, { defaultValues }]) => defaultValues)
337
+ .map(([key, { defaultValues }]) => [key, defaultValues])));
336
338
  const currentVisibleStepKey = (_a = sharedUtils.objectEntries(steps).find(([, { path }]) => subStepPath ? path === `${stepPath}/${subStepPath}` : path === stepPath)) === null || _a === void 0 ? void 0 : _a[0];
337
339
  const currentVisibleStepIndex = sharedUtils.objectKeys(steps).findIndex(key => key === currentVisibleStepKey);
338
340
  return (jsxRuntime.jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, children: jsxRuntime.jsxs("div", { className: cvaFormWizardLayout(), children: [jsxRuntime.jsx(FormWizardSidebar, { children: sharedUtils.objectEntries(steps)
package/index.esm.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { registerTranslations, useNamespaceTranslation } from '@trackunit/i18n-library-translation';
3
3
  import { Link, useNavigate, useParams } from '@tanstack/react-router';
4
- import { objectKeys, objectEntries, objectValues, objectFromEntries } from '@trackunit/shared-utils';
4
+ import { objectKeys, objectFromEntries, objectEntries, objectValues } from '@trackunit/shared-utils';
5
5
  import { useState, useRef, useEffect, useCallback, useMemo } from 'react';
6
6
  import { cvaMerge } from '@trackunit/css-class-variance-utilities';
7
7
  import { Icon, Button, Heading } from '@trackunit/react-components';
@@ -328,7 +328,9 @@ const FormWizard = ({ lastStepPrimaryActionLabel, steps, fullFormSchema, onCance
328
328
  // A possible workaround could be to type it Partial<<DeepPartial<...>>> everywhere
329
329
  // Any weakening of the type in a union would be worse and likely just push the issue forward until it hits react-hook-form
330
330
  // eslint-disable-next-line local-rules/no-typescript-assertion
331
- {});
331
+ objectFromEntries(objectEntries(steps)
332
+ .filter(([_, { defaultValues }]) => defaultValues)
333
+ .map(([key, { defaultValues }]) => [key, defaultValues])));
332
334
  const currentVisibleStepKey = (_a = objectEntries(steps).find(([, { path }]) => subStepPath ? path === `${stepPath}/${subStepPath}` : path === stepPath)) === null || _a === void 0 ? void 0 : _a[0];
333
335
  const currentVisibleStepIndex = objectKeys(steps).findIndex(key => key === currentVisibleStepKey);
334
336
  return (jsx("div", { className: cvaFormWizardContainer({ className }), "data-testid": dataTestId, children: jsxs("div", { className: cvaFormWizardLayout(), children: [jsx(FormWizardSidebar, { children: objectEntries(steps)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-wizard",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "dependencies": {
@@ -1,7 +1,7 @@
1
1
  import { RegisteredRouter, RouteIds } from "@tanstack/react-router";
2
2
  import { CommonProps } from "@trackunit/react-components";
3
3
  import { ReactNode } from "react";
4
- import { UseFormReturn } from "react-hook-form";
4
+ import { DeepPartial, UseFormReturn } from "react-hook-form";
5
5
  import { AnyZodObject, SomeZodObject, z } from "zod";
6
6
  export type StepState = "active" | "done" | "invalid" | "disabled" | "ready";
7
7
  export type StepDefinitions<TFullSchema extends AnyZodObject> = {
@@ -22,6 +22,7 @@ interface DefinedStep<TStepSchema extends TFullSchemaValue[keyof TFullSchemaValu
22
22
  component: (props: StepComponentPropsInner<TStepSchema, TFullSchemaValue>) => React.ReactNode;
23
23
  parent?: keyof TFullSchemaValue;
24
24
  shouldRender?: (fullFormState: Partial<TFullSchemaValue>) => boolean;
25
+ defaultValues?: DeepPartial<TStepSchema>;
25
26
  }
26
27
  export type StepComponentProps<TFullSchemaHook extends () => AnyZodObject, TStepKey extends keyof z.TypeOf<ReturnType<TFullSchemaHook>>> = StepComponentPropsInner<z.TypeOf<ReturnType<TFullSchemaHook>>[TStepKey], z.TypeOf<ReturnType<TFullSchemaHook>>>;
27
28
  export type ComponentStepDefinitions<TFullSchema extends AnyZodObject> = {