@jfdevelops/react-multi-step-form 1.0.0-alpha.21 → 1.0.0-alpha.22

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.
Files changed (45) hide show
  1. package/package.json +2 -2
  2. package/dist/create-context.cjs +0 -92
  3. package/dist/create-context.cjs.map +0 -1
  4. package/dist/create-context.d.cts +0 -154
  5. package/dist/create-context.d.mts +0 -154
  6. package/dist/create-context.mjs +0 -92
  7. package/dist/create-context.mjs.map +0 -1
  8. package/dist/field.cjs +0 -22
  9. package/dist/field.cjs.map +0 -1
  10. package/dist/field.d.cts +0 -38
  11. package/dist/field.d.mts +0 -38
  12. package/dist/field.mjs +0 -16
  13. package/dist/field.mjs.map +0 -1
  14. package/dist/form-config.cjs +0 -32
  15. package/dist/form-config.cjs.map +0 -1
  16. package/dist/form-config.d.cts +0 -160
  17. package/dist/form-config.d.mts +0 -160
  18. package/dist/form-config.mjs +0 -27
  19. package/dist/form-config.mjs.map +0 -1
  20. package/dist/hooks/use-multi-step-form-data.cjs +0 -41
  21. package/dist/hooks/use-multi-step-form-data.cjs.map +0 -1
  22. package/dist/hooks/use-multi-step-form-data.d.cts +0 -28
  23. package/dist/hooks/use-multi-step-form-data.d.mts +0 -28
  24. package/dist/hooks/use-multi-step-form-data.mjs +0 -39
  25. package/dist/hooks/use-multi-step-form-data.mjs.map +0 -1
  26. package/dist/index.cjs +0 -17
  27. package/dist/index.d.cts +0 -5
  28. package/dist/index.d.mts +0 -5
  29. package/dist/index.mjs +0 -6
  30. package/dist/schema.cjs +0 -45
  31. package/dist/schema.cjs.map +0 -1
  32. package/dist/schema.d.cts +0 -34
  33. package/dist/schema.d.mts +0 -34
  34. package/dist/schema.mjs +0 -44
  35. package/dist/schema.mjs.map +0 -1
  36. package/dist/step-schema.cjs +0 -222
  37. package/dist/step-schema.cjs.map +0 -1
  38. package/dist/step-schema.d.cts +0 -135
  39. package/dist/step-schema.d.mts +0 -135
  40. package/dist/step-schema.mjs +0 -215
  41. package/dist/step-schema.mjs.map +0 -1
  42. package/dist/utils.cjs +0 -22
  43. package/dist/utils.cjs.map +0 -1
  44. package/dist/utils.mjs +0 -22
  45. package/dist/utils.mjs.map +0 -1
@@ -1,39 +0,0 @@
1
- import { VALIDATED_STEP_REGEX, invariant } from "@jfdevelops/multi-step-form-core";
2
- import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
3
-
4
- //#region src/hooks/use-multi-step-form-data.ts
5
- function throwIfInvalidStepNumber(schema, targetStep) {
6
- invariant(typeof targetStep === "string", `The target step must be a string, was ${typeof targetStep}`);
7
- const { as, isValidStepNumber } = schema.stepSchema.steps;
8
- const formattedStepNumbersList = new Intl.ListFormat("en", {
9
- type: "disjunction",
10
- style: "long"
11
- }).format(as("array.string.untyped"));
12
- invariant(VALIDATED_STEP_REGEX.test(targetStep), `The target step must match the following format: "step{number}". Available steps are ${formattedStepNumbersList}`);
13
- const stepNumber = Number.parseInt(targetStep.replace("step", ""));
14
- invariant(isValidStepNumber(stepNumber), `The step number "${stepNumber}" is not a valid step number. Valid step numbers include ${formattedStepNumbersList}`, TypeError);
15
- return stepNumber;
16
- }
17
- function createMultiStepFormDataHook(schema) {
18
- function useMultiStepFormData$1(optionsOrSelector) {
19
- return useSyncExternalStoreWithSelector(schema.subscribe, () => schema.getSnapshot(), () => schema.getSnapshot(), (snapshot) => {
20
- if (typeof optionsOrSelector === "object") {
21
- const stepNumber = throwIfInvalidStepNumber(snapshot, optionsOrSelector.targetStep);
22
- return snapshot.stepSchema.get({ step: stepNumber }).data;
23
- }
24
- if (typeof optionsOrSelector === "function") return optionsOrSelector(snapshot);
25
- return snapshot;
26
- });
27
- }
28
- return useMultiStepFormData$1;
29
- }
30
- function useMultiStepFormData(schema, optionsOrSelector) {
31
- const hook = createMultiStepFormDataHook(schema);
32
- if (typeof optionsOrSelector === "object") return hook(optionsOrSelector);
33
- if (typeof optionsOrSelector === "function") return hook(optionsOrSelector);
34
- return hook();
35
- }
36
-
37
- //#endregion
38
- export { createMultiStepFormDataHook, throwIfInvalidStepNumber, useMultiStepFormData };
39
- //# sourceMappingURL=use-multi-step-form-data.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-multi-step-form-data.mjs","names":["useMultiStepFormData"],"sources":["../../src/hooks/use-multi-step-form-data.ts"],"sourcesContent":["import type { AnyMultiStepFormSchema, MultiStepFormSchema } from '@/schema';\nimport {\n invariant,\n VALIDATED_STEP_REGEX,\n} from '@jfdevelops/multi-step-form-core';\nimport { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector';\n\nexport type UseMultiStepFormDataOptions<\n TSchema extends AnyMultiStepFormSchema,\n TTarget extends keyof MultiStepFormSchema.resolvedStep<TSchema> = keyof MultiStepFormSchema.resolvedStep<TSchema>\n> = {\n targetStep: TTarget;\n};\nexport type UseMultiStepFormData<\n // step extends Step<casing>,\n // casing extends CasingType,\n // storageKey extends string,\n // resolvedStep extends ResolvedStep<step, casing>,\n // schema extends MultiStepFormSchema<\n // step,\n // casing,\n // storageKey\n // > = MultiStepFormSchema<step, casing, storageKey>,\n TSchema extends AnyMultiStepFormSchema,\n TResolvedStep extends MultiStepFormSchema.resolvedStep<TSchema> = MultiStepFormSchema.resolvedStep<TSchema>\n> = {\n /**\n * Returns the entire {@linkcode MultiStepFormSchema instance}.\n */\n (): TSchema;\n /**\n * Returns the data for the target step.\n * @param stepNumber The step number to return.\n * @throws {TypeError} If `options.stepNumber` is invalid.\n */\n <targetStep extends keyof TResolvedStep>(\n options: UseMultiStepFormDataOptions<TSchema, targetStep>\n ): MultiStepFormSchema.getData<TSchema, targetStep>;\n /**\n * Returns the specified data from the {@linkcode MultiStepFormSchema} instance via the callback's return.\n */\n <data>(selector: (schema: TSchema) => data): data;\n};\n\nexport function throwIfInvalidStepNumber<\n // step extends Step<casing>,\n // casing extends CasingType = DefaultCasing,\n // storageKey extends string = DefaultStorageKey,\n // resolvedStep extends ResolvedStep<step, casing> = ResolvedStep<step, casing>,\n // stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n schema extends AnyMultiStepFormSchema\n>(schema: schema, targetStep: unknown) {\n invariant(\n typeof targetStep === 'string',\n `The target step must be a string, was ${typeof targetStep}`\n );\n\n const { as, isValidStepNumber } = schema.stepSchema.steps;\n const formatter = new Intl.ListFormat('en', {\n type: 'disjunction',\n style: 'long',\n });\n const formattedStepNumbersList = formatter.format(as('array.string.untyped'));\n\n invariant(\n VALIDATED_STEP_REGEX.test(targetStep),\n `The target step must match the following format: \"step{number}\". Available steps are ${formattedStepNumbersList}`\n );\n\n const stepNumber = Number.parseInt(targetStep.replace('step', ''));\n\n invariant(\n isValidStepNumber(stepNumber),\n `The step number \"${stepNumber}\" is not a valid step number. Valid step numbers include ${formattedStepNumbersList}`,\n TypeError\n );\n\n return stepNumber as MultiStepFormSchema.stepNumbers<schema>;\n}\n\nexport function createMultiStepFormDataHook<\n // step extends Step<casing>,\n // casing extends CasingType = DefaultCasing,\n // storageKey extends string = DefaultStorageKey,\n // resolvedStep extends ResolvedStep<step, casing> = ResolvedStep<step, casing>,\n // stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n schema extends AnyMultiStepFormSchema\n>(schema: schema): UseMultiStepFormData<schema> {\n function useMultiStepFormData(\n optionsOrSelector?:\n | UseMultiStepFormDataOptions<schema>\n | ((data: schema) => unknown)\n ) {\n return useSyncExternalStoreWithSelector(\n schema.subscribe,\n () => schema.getSnapshot(),\n () => schema.getSnapshot(),\n (snapshot) => {\n if (typeof optionsOrSelector === 'object') {\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const stepNumber = throwIfInvalidStepNumber(\n snapshot,\n optionsOrSelector.targetStep\n );\n\n return snapshot.stepSchema.get({ step: stepNumber as never }).data;\n }\n\n if (typeof optionsOrSelector === 'function') {\n return optionsOrSelector(snapshot);\n }\n\n return snapshot;\n }\n );\n }\n\n return useMultiStepFormData as any;\n}\n\nfunction useMultiStepFormData<schema extends AnyMultiStepFormSchema>(\n schema: schema\n): schema;\nfunction useMultiStepFormData<\n schema extends AnyMultiStepFormSchema,\n targetStep extends keyof MultiStepFormSchema.resolvedStep<schema>\n>(\n schema: schema,\n options: UseMultiStepFormDataOptions<schema, targetStep>\n): MultiStepFormSchema.getData<schema, targetStep>;\nfunction useMultiStepFormData<schema extends AnyMultiStepFormSchema, data>(\n schema: schema,\n selector: (schema: schema) => data\n): data;\nfunction useMultiStepFormData<\n // step extends Step<casing>,\n // casing extends CasingType = DefaultCasing,\n // storageKey extends string = DefaultStorageKey,\n // resolvedStep extends ResolvedStep<step, casing> = ResolvedStep<step, casing>,\n // stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n schema extends AnyMultiStepFormSchema\n>(\n schema: schema,\n optionsOrSelector?:\n | UseMultiStepFormDataOptions<schema>\n | ((data: schema) => unknown)\n) {\n const hook = createMultiStepFormDataHook(schema);\n\n if (typeof optionsOrSelector === 'object') {\n return hook(optionsOrSelector);\n }\n\n if (typeof optionsOrSelector === 'function') {\n return hook(optionsOrSelector);\n }\n\n return hook();\n}\n\nexport { useMultiStepFormData };\n"],"mappings":";;;;AA4CA,SAAgB,yBAOd,QAAgB,YAAqB;AACrC,WACE,OAAO,eAAe,UACtB,yCAAyC,OAAO,aACjD;CAED,MAAM,EAAE,IAAI,sBAAsB,OAAO,WAAW;CAKpD,MAAM,2BAJY,IAAI,KAAK,WAAW,MAAM;EAC1C,MAAM;EACN,OAAO;EACR,CAAC,CACyC,OAAO,GAAG,uBAAuB,CAAC;AAE7E,WACE,qBAAqB,KAAK,WAAW,EACrC,wFAAwF,2BACzF;CAED,MAAM,aAAa,OAAO,SAAS,WAAW,QAAQ,QAAQ,GAAG,CAAC;AAElE,WACE,kBAAkB,WAAW,EAC7B,oBAAoB,WAAW,2DAA2D,4BAC1F,UACD;AAED,QAAO;;AAGT,SAAgB,4BAOd,QAA8C;CAC9C,SAASA,uBACP,mBAGA;AACA,SAAO,iCACL,OAAO,iBACD,OAAO,aAAa,QACpB,OAAO,aAAa,GACzB,aAAa;AACZ,OAAI,OAAO,sBAAsB,UAAU;IAEzC,MAAM,aAAa,yBACjB,UACA,kBAAkB,WACnB;AAED,WAAO,SAAS,WAAW,IAAI,EAAE,MAAM,YAAqB,CAAC,CAAC;;AAGhE,OAAI,OAAO,sBAAsB,WAC/B,QAAO,kBAAkB,SAAS;AAGpC,UAAO;IAEV;;AAGH,QAAOA;;AAiBT,SAAS,qBAQP,QACA,mBAGA;CACA,MAAM,OAAO,4BAA4B,OAAO;AAEhD,KAAI,OAAO,sBAAsB,SAC/B,QAAO,KAAK,kBAAkB;AAGhC,KAAI,OAAO,sBAAsB,WAC/B,QAAO,KAAK,kBAAkB;AAGhC,QAAO,MAAM"}
package/dist/index.cjs DELETED
@@ -1,17 +0,0 @@
1
- const require_step_schema = require('./step-schema.cjs');
2
- const require_schema = require('./schema.cjs');
3
- const require_use_multi_step_form_data = require('./hooks/use-multi-step-form-data.cjs');
4
- const require_create_context = require('./create-context.cjs');
5
-
6
- exports.MultiStepFormSchema = require_schema.MultiStepFormSchema;
7
- exports.MultiStepFormStepSchema = require_step_schema.MultiStepFormStepSchema;
8
- Object.defineProperty(exports, 'StepSpecificComponent', {
9
- enumerable: true,
10
- get: function () {
11
- return require_step_schema.StepSpecificComponent;
12
- }
13
- });
14
- exports.createDefaultValues = require_step_schema.createDefaultValues;
15
- exports.createMultiStepFormContext = require_create_context.createMultiStepFormContext;
16
- exports.createMultiStepFormSchema = require_schema.createMultiStepFormSchema;
17
- exports.useMultiStepFormData = require_use_multi_step_form_data.useMultiStepFormData;
package/dist/index.d.cts DELETED
@@ -1,5 +0,0 @@
1
- import { AnyResolvedStep, CreateComponent, CreateComponentCallback, CreateComponentFn, CreateFunction, CreateStepSpecificComponentCallback, CreatedMultiStepFormComponent, ExtractedDefaultValues, HelperFunctions, MultiStepFormSchemaStepConfig, MultiStepFormStepSchema, ResolvedStep, StepSpecificComponent, StepSpecificCreateComponentFn, createDefaultValues } from "./step-schema.cjs";
2
- import { AnyMultiStepFormSchema, MultiStepFormSchema, MultiStepFormSchemaOptions, createMultiStepFormSchema } from "./schema.cjs";
3
- import { useMultiStepFormData } from "./hooks/use-multi-step-form-data.cjs";
4
- import { CreateHOC, MultiStepFormContextResult, UseCurrentStepBaseResult, UseCurrentStepErrorResult, UseCurrentStepOptions, UseCurrentStepResult, UseCurrentStepSuccessResult, UseProgressBaseOptions, UseProgressOptions, UseProgressResult, createMultiStepFormContext } from "./create-context.cjs";
5
- export { AnyMultiStepFormSchema, AnyResolvedStep, CreateComponent, CreateComponentCallback, CreateComponentFn, CreateFunction, CreateHOC, CreateStepSpecificComponentCallback, CreatedMultiStepFormComponent, ExtractedDefaultValues, HelperFunctions, MultiStepFormContextResult, MultiStepFormSchema, MultiStepFormSchemaOptions, MultiStepFormSchemaStepConfig, MultiStepFormStepSchema, ResolvedStep, StepSpecificComponent, StepSpecificCreateComponentFn, UseCurrentStepBaseResult, UseCurrentStepErrorResult, UseCurrentStepOptions, UseCurrentStepResult, UseCurrentStepSuccessResult, UseProgressBaseOptions, UseProgressOptions, UseProgressResult, createDefaultValues, createMultiStepFormContext, createMultiStepFormSchema, useMultiStepFormData };
package/dist/index.d.mts DELETED
@@ -1,5 +0,0 @@
1
- import { AnyResolvedStep, CreateComponent, CreateComponentCallback, CreateComponentFn, CreateFunction, CreateStepSpecificComponentCallback, CreatedMultiStepFormComponent, ExtractedDefaultValues, HelperFunctions, MultiStepFormSchemaStepConfig, MultiStepFormStepSchema, ResolvedStep, StepSpecificComponent, StepSpecificCreateComponentFn, createDefaultValues } from "./step-schema.mjs";
2
- import { AnyMultiStepFormSchema, MultiStepFormSchema, MultiStepFormSchemaOptions, createMultiStepFormSchema } from "./schema.mjs";
3
- import { useMultiStepFormData } from "./hooks/use-multi-step-form-data.mjs";
4
- import { CreateHOC, MultiStepFormContextResult, UseCurrentStepBaseResult, UseCurrentStepErrorResult, UseCurrentStepOptions, UseCurrentStepResult, UseCurrentStepSuccessResult, UseProgressBaseOptions, UseProgressOptions, UseProgressResult, createMultiStepFormContext } from "./create-context.mjs";
5
- export { AnyMultiStepFormSchema, AnyResolvedStep, CreateComponent, CreateComponentCallback, CreateComponentFn, CreateFunction, CreateHOC, CreateStepSpecificComponentCallback, CreatedMultiStepFormComponent, ExtractedDefaultValues, HelperFunctions, MultiStepFormContextResult, MultiStepFormSchema, MultiStepFormSchemaOptions, MultiStepFormSchemaStepConfig, MultiStepFormStepSchema, ResolvedStep, StepSpecificComponent, StepSpecificCreateComponentFn, UseCurrentStepBaseResult, UseCurrentStepErrorResult, UseCurrentStepOptions, UseCurrentStepResult, UseCurrentStepSuccessResult, UseProgressBaseOptions, UseProgressOptions, UseProgressResult, createDefaultValues, createMultiStepFormContext, createMultiStepFormSchema, useMultiStepFormData };
package/dist/index.mjs DELETED
@@ -1,6 +0,0 @@
1
- import { MultiStepFormStepSchema, StepSpecificComponent, createDefaultValues } from "./step-schema.mjs";
2
- import { MultiStepFormSchema, createMultiStepFormSchema } from "./schema.mjs";
3
- import { useMultiStepFormData } from "./hooks/use-multi-step-form-data.mjs";
4
- import { createMultiStepFormContext } from "./create-context.mjs";
5
-
6
- export { MultiStepFormSchema, MultiStepFormStepSchema, StepSpecificComponent, createDefaultValues, createMultiStepFormContext, createMultiStepFormSchema, useMultiStepFormData };
package/dist/schema.cjs DELETED
@@ -1,45 +0,0 @@
1
- const require_step_schema = require('./step-schema.cjs');
2
- let __jfdevelops_multi_step_form_core = require("@jfdevelops/multi-step-form-core");
3
- let __jfdevelops_multi_step_form_core__internals = require("@jfdevelops/multi-step-form-core/_internals");
4
-
5
- //#region src/schema.ts
6
- var MultiStepFormSchema = class extends __jfdevelops_multi_step_form_core.MultiStepFormSchema {
7
- stepSchema;
8
- #internal;
9
- constructor(config) {
10
- const { nameTransformCasing = __jfdevelops_multi_step_form_core.DEFAULT_CASING, storage, ...rest } = config;
11
- const options = {
12
- nameTransformCasing,
13
- storage,
14
- ...rest
15
- };
16
- super(options);
17
- this.stepSchema = new require_step_schema.MultiStepFormStepSchema(options);
18
- this.#internal = new __jfdevelops_multi_step_form_core__internals.MultiStepFormStepSchemaInternal({
19
- originalValue: this.stepSchema.original,
20
- getValue: () => this.stepSchema.value,
21
- setValue: (value) => {
22
- this.stepSchema.value = { ...value };
23
- this.storage.add(value);
24
- this.notify();
25
- }
26
- });
27
- }
28
- createComponent(options, fn) {
29
- const { stepData } = options;
30
- const ctx = (0, __jfdevelops_multi_step_form_core.createCtx)(this.stepSchema.value, stepData);
31
- return ((props) => fn({
32
- ctx,
33
- update: this.#internal.createHelperFnInputUpdate(stepData),
34
- reset: this.#internal.createHelperFnInputReset(stepData)
35
- }, props));
36
- }
37
- };
38
- function createMultiStepFormSchema(options) {
39
- return new MultiStepFormSchema(options);
40
- }
41
-
42
- //#endregion
43
- exports.MultiStepFormSchema = MultiStepFormSchema;
44
- exports.createMultiStepFormSchema = createMultiStepFormSchema;
45
- //# sourceMappingURL=schema.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.cjs","names":["MultiStepFormSchemaCore","#internal","DEFAULT_CASING","MultiStepFormStepSchema","MultiStepFormStepSchemaInternal"],"sources":["../src/schema.ts"],"sourcesContent":["import {\n type CasingType,\n type Constrain,\n createCtx,\n type CreateHelperFunctionOptionsBase,\n DEFAULT_CASING,\n type DefaultCasing,\n type DefaultStorageKey,\n type HelperFnChosenSteps,\n type MultiStepFormSchemaOptions as MultiStepFormSchemaBaseOptions,\n MultiStepFormSchema as MultiStepFormSchemaCore,\n type ResolvedStep as ResolvedStepCore,\n type Step,\n type StepNumbers,\n} from '@jfdevelops/multi-step-form-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { MultiStepFormSchemaConfig } from './form-config';\nimport {\n type CreateComponentCallback,\n type CreatedMultiStepFormComponent,\n type HelperFunctions,\n MultiStepFormStepSchema,\n type ResolvedStep,\n} from './step-schema';\nimport { MultiStepFormStepSchemaInternal } from '@jfdevelops/multi-step-form-core/_internals';\n\n// export type AnyMultiStepFormSchema = MultiStepFormSchema<any, any, any>;\nexport type AnyMultiStepFormSchema = { [x: string]: any };\n\n// Helper inference types for `AnyMultiStepFormSchema`\nexport namespace MultiStepFormSchema {\n /**\n * Infer the resolved step from a {@linkcode MultiStepFormSchema}.\n */\n export type resolvedStep<T extends AnyMultiStepFormSchema> =\n T['stepSchema']['value'];\n /**\n * Infer the {@linkcode MultiStepFormSchema}'s step numbers.\n */\n export type stepNumbers<T extends AnyMultiStepFormSchema> = StepNumbers<\n resolvedStep<T>\n >;\n /**\n * Get the data for a specific step from a {@linkcode MultiStepFormSchema}.\n */\n export type getData<\n T extends AnyMultiStepFormSchema,\n TTarget extends keyof resolvedStep<T>\n > = resolvedStep<T>[TTarget];\n}\n\nexport interface MultiStepFormSchemaOptions<\n TStep extends Step<TCasing>,\n TCasing extends CasingType,\n TStorageKey extends string,\n TFormAlias extends string,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>,\n TFormProps extends object,\n TResolvedStep extends ResolvedStep<TStep, TCasing> = ResolvedStep<\n TStep,\n TCasing\n >\n> extends MultiStepFormSchemaBaseOptions<TStep, TCasing, TStorageKey>,\n MultiStepFormSchemaConfig.Form<\n TResolvedStep,\n TFormAlias,\n TFormEnabledFor,\n TFormProps\n > {}\n\nexport class MultiStepFormSchema<\n step extends Step<casing>,\n casing extends CasingType = DefaultCasing,\n storageKey extends string = DefaultStorageKey,\n formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias,\n formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep> = MultiStepFormSchemaConfig.defaultEnabledFor,\n formProps extends object = ComponentPropsWithRef<'form'>,\n resolvedStep extends ResolvedStep<step, casing> = ResolvedStep<\n step,\n casing\n >,\n stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n >\n extends MultiStepFormSchemaCore<\n step,\n casing,\n ResolvedStepCore<step, casing>,\n StepNumbers<ResolvedStepCore<step, casing>>,\n storageKey\n >\n implements HelperFunctions<resolvedStep, stepNumbers>\n{\n // @ts-ignore\n stepSchema: MultiStepFormStepSchema<\n step,\n casing,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >;\n readonly #internal: MultiStepFormStepSchemaInternal<\n step,\n casing,\n resolvedStep,\n stepNumbers\n >;\n\n constructor(\n config: MultiStepFormSchemaOptions<\n step,\n Constrain<casing, CasingType>,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >\n ) {\n const { nameTransformCasing = DEFAULT_CASING, storage, ...rest } = config;\n const options = { nameTransformCasing, storage, ...rest };\n\n super(options);\n\n this.stepSchema = new MultiStepFormStepSchema<\n step,\n casing,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >(options);\n this.#internal = new MultiStepFormStepSchemaInternal<\n step,\n casing,\n resolvedStep,\n stepNumbers\n >({\n originalValue: this.stepSchema.original,\n getValue: () => this.stepSchema.value as never,\n setValue: (value) => {\n this.stepSchema.value = { ...value } as never;\n this.storage.add(value);\n this.notify();\n },\n });\n }\n\n createComponent<\n chosenSteps extends HelperFnChosenSteps<resolvedStep, stepNumbers>,\n props = undefined\n >(\n options: CreateHelperFunctionOptionsBase<\n resolvedStep,\n stepNumbers,\n chosenSteps\n >,\n fn: CreateComponentCallback<resolvedStep, stepNumbers, chosenSteps, props>\n ): CreatedMultiStepFormComponent<props> {\n const { stepData } = options;\n const ctx = createCtx<resolvedStep, stepNumbers, chosenSteps>(\n this.stepSchema.value as never,\n stepData\n ) as never;\n\n return ((props?: props) =>\n fn(\n {\n ctx,\n update: this.#internal.createHelperFnInputUpdate(stepData),\n reset: this.#internal.createHelperFnInputReset(stepData),\n },\n props as any\n )) as any;\n }\n}\n\nexport function createMultiStepFormSchema<\n step extends Step<casing>,\n casing extends CasingType = DefaultCasing,\n storageKey extends string = DefaultStorageKey,\n formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias,\n formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep> = MultiStepFormSchemaConfig.defaultEnabledFor,\n formProps extends object = ComponentPropsWithRef<'form'>,\n resolvedStep extends ResolvedStep<step, casing> = ResolvedStep<step, casing>,\n stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n>(\n options: MultiStepFormSchemaOptions<\n step,\n Constrain<casing, CasingType>,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >\n) {\n return new MultiStepFormSchema<\n step,\n casing,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps,\n resolvedStep,\n stepNumbers\n >(options);\n}\n"],"mappings":";;;;;AAsEA,IAAa,sBAAb,cAaUA,sDAQV;CAEE;CAQA,CAASC;CAOT,YACE,QAQA;EACA,MAAM,EAAE,sBAAsBC,kDAAgB,SAAS,GAAG,SAAS;EACnE,MAAM,UAAU;GAAE;GAAqB;GAAS,GAAG;GAAM;AAEzD,QAAM,QAAQ;AAEd,OAAK,aAAa,IAAIC,4CAOpB,QAAQ;AACV,QAAKF,WAAY,IAAIG,6EAKnB;GACA,eAAe,KAAK,WAAW;GAC/B,gBAAgB,KAAK,WAAW;GAChC,WAAW,UAAU;AACnB,SAAK,WAAW,QAAQ,EAAE,GAAG,OAAO;AACpC,SAAK,QAAQ,IAAI,MAAM;AACvB,SAAK,QAAQ;;GAEhB,CAAC;;CAGJ,gBAIE,SAKA,IACsC;EACtC,MAAM,EAAE,aAAa;EACrB,MAAM,uDACJ,KAAK,WAAW,OAChB,SACD;AAED,WAAS,UACP,GACE;GACE;GACA,QAAQ,MAAKH,SAAU,0BAA0B,SAAS;GAC1D,OAAO,MAAKA,SAAU,yBAAyB,SAAS;GACzD,EACD,MACD;;;AAIP,SAAgB,0BAUd,SAQA;AACA,QAAO,IAAI,oBAST,QAAQ"}
package/dist/schema.d.cts DELETED
@@ -1,34 +0,0 @@
1
- import { CreateComponentCallback, CreatedMultiStepFormComponent, HelperFunctions, MultiStepFormStepSchema as MultiStepFormStepSchema$1, ResolvedStep as ResolvedStep$1 } from "./step-schema.cjs";
2
- import { MultiStepFormSchemaConfig } from "./form-config.cjs";
3
- import { CasingType, Constrain, CreateHelperFunctionOptionsBase, DefaultCasing, DefaultStorageKey, HelperFnChosenSteps, MultiStepFormSchema, MultiStepFormSchemaOptions, ResolvedStep, Step, StepNumbers } from "@jfdevelops/multi-step-form-core";
4
- import { ComponentPropsWithRef } from "react";
5
-
6
- //#region src/schema.d.ts
7
- type AnyMultiStepFormSchema = {
8
- [x: string]: any;
9
- };
10
- declare namespace MultiStepFormSchema$1 {
11
- /**
12
- * Infer the resolved step from a {@linkcode MultiStepFormSchema}.
13
- */
14
- type resolvedStep<T extends AnyMultiStepFormSchema> = T['stepSchema']['value'];
15
- /**
16
- * Infer the {@linkcode MultiStepFormSchema}'s step numbers.
17
- */
18
- type stepNumbers<T extends AnyMultiStepFormSchema> = StepNumbers<resolvedStep<T>>;
19
- /**
20
- * Get the data for a specific step from a {@linkcode MultiStepFormSchema}.
21
- */
22
- type getData<T extends AnyMultiStepFormSchema, TTarget extends keyof resolvedStep<T>> = resolvedStep<T>[TTarget];
23
- }
24
- interface MultiStepFormSchemaOptions$1<TStep extends Step<TCasing>, TCasing extends CasingType, TStorageKey extends string, TFormAlias extends string, TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>, TFormProps extends object, TResolvedStep extends ResolvedStep$1<TStep, TCasing> = ResolvedStep$1<TStep, TCasing>> extends MultiStepFormSchemaOptions<TStep, TCasing, TStorageKey>, MultiStepFormSchemaConfig.Form<TResolvedStep, TFormAlias, TFormEnabledFor, TFormProps> {}
25
- declare class MultiStepFormSchema$1<step extends Step<casing>, casing extends CasingType = DefaultCasing, storageKey extends string = DefaultStorageKey, formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias, formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep$1> = MultiStepFormSchemaConfig.defaultEnabledFor, formProps extends object = ComponentPropsWithRef<'form'>, resolvedStep$1 extends ResolvedStep$1<step, casing> = ResolvedStep$1<step, casing>, stepNumbers extends StepNumbers<resolvedStep$1> = StepNumbers<resolvedStep$1>> extends MultiStepFormSchema<step, casing, ResolvedStep<step, casing>, StepNumbers<ResolvedStep<step, casing>>, storageKey> implements HelperFunctions<resolvedStep$1, stepNumbers> {
26
- #private;
27
- stepSchema: MultiStepFormStepSchema$1<step, casing, storageKey, formAlias, formEnabledFor, formProps>;
28
- constructor(config: MultiStepFormSchemaOptions$1<step, Constrain<casing, CasingType>, storageKey, formAlias, formEnabledFor, formProps>);
29
- createComponent<chosenSteps extends HelperFnChosenSteps<resolvedStep$1, stepNumbers>, props = undefined>(options: CreateHelperFunctionOptionsBase<resolvedStep$1, stepNumbers, chosenSteps>, fn: CreateComponentCallback<resolvedStep$1, stepNumbers, chosenSteps, props>): CreatedMultiStepFormComponent<props>;
30
- }
31
- declare function createMultiStepFormSchema<step extends Step<casing>, casing extends CasingType = DefaultCasing, storageKey extends string = DefaultStorageKey, formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias, formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep$1> = MultiStepFormSchemaConfig.defaultEnabledFor, formProps extends object = ComponentPropsWithRef<'form'>, resolvedStep$1 extends ResolvedStep$1<step, casing> = ResolvedStep$1<step, casing>, stepNumbers extends StepNumbers<resolvedStep$1> = StepNumbers<resolvedStep$1>>(options: MultiStepFormSchemaOptions$1<step, Constrain<casing, CasingType>, storageKey, formAlias, formEnabledFor, formProps>): MultiStepFormSchema$1<step, casing, storageKey, formAlias, formEnabledFor, formProps, resolvedStep$1, stepNumbers>;
32
- //#endregion
33
- export { AnyMultiStepFormSchema, MultiStepFormSchema$1 as MultiStepFormSchema, MultiStepFormSchemaOptions$1 as MultiStepFormSchemaOptions, createMultiStepFormSchema };
34
- //# sourceMappingURL=schema.d.cts.map
package/dist/schema.d.mts DELETED
@@ -1,34 +0,0 @@
1
- import { CreateComponentCallback, CreatedMultiStepFormComponent, HelperFunctions, MultiStepFormStepSchema as MultiStepFormStepSchema$1, ResolvedStep as ResolvedStep$1 } from "./step-schema.mjs";
2
- import { MultiStepFormSchemaConfig } from "./form-config.mjs";
3
- import { CasingType, Constrain, CreateHelperFunctionOptionsBase, DefaultCasing, DefaultStorageKey, HelperFnChosenSteps, MultiStepFormSchema, MultiStepFormSchemaOptions, ResolvedStep, Step, StepNumbers } from "@jfdevelops/multi-step-form-core";
4
- import { ComponentPropsWithRef } from "react";
5
-
6
- //#region src/schema.d.ts
7
- type AnyMultiStepFormSchema = {
8
- [x: string]: any;
9
- };
10
- declare namespace MultiStepFormSchema$1 {
11
- /**
12
- * Infer the resolved step from a {@linkcode MultiStepFormSchema}.
13
- */
14
- type resolvedStep<T extends AnyMultiStepFormSchema> = T['stepSchema']['value'];
15
- /**
16
- * Infer the {@linkcode MultiStepFormSchema}'s step numbers.
17
- */
18
- type stepNumbers<T extends AnyMultiStepFormSchema> = StepNumbers<resolvedStep<T>>;
19
- /**
20
- * Get the data for a specific step from a {@linkcode MultiStepFormSchema}.
21
- */
22
- type getData<T extends AnyMultiStepFormSchema, TTarget extends keyof resolvedStep<T>> = resolvedStep<T>[TTarget];
23
- }
24
- interface MultiStepFormSchemaOptions$1<TStep extends Step<TCasing>, TCasing extends CasingType, TStorageKey extends string, TFormAlias extends string, TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>, TFormProps extends object, TResolvedStep extends ResolvedStep$1<TStep, TCasing> = ResolvedStep$1<TStep, TCasing>> extends MultiStepFormSchemaOptions<TStep, TCasing, TStorageKey>, MultiStepFormSchemaConfig.Form<TResolvedStep, TFormAlias, TFormEnabledFor, TFormProps> {}
25
- declare class MultiStepFormSchema$1<step extends Step<casing>, casing extends CasingType = DefaultCasing, storageKey extends string = DefaultStorageKey, formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias, formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep$1> = MultiStepFormSchemaConfig.defaultEnabledFor, formProps extends object = ComponentPropsWithRef<'form'>, resolvedStep$1 extends ResolvedStep$1<step, casing> = ResolvedStep$1<step, casing>, stepNumbers extends StepNumbers<resolvedStep$1> = StepNumbers<resolvedStep$1>> extends MultiStepFormSchema<step, casing, ResolvedStep<step, casing>, StepNumbers<ResolvedStep<step, casing>>, storageKey> implements HelperFunctions<resolvedStep$1, stepNumbers> {
26
- #private;
27
- stepSchema: MultiStepFormStepSchema$1<step, casing, storageKey, formAlias, formEnabledFor, formProps>;
28
- constructor(config: MultiStepFormSchemaOptions$1<step, Constrain<casing, CasingType>, storageKey, formAlias, formEnabledFor, formProps>);
29
- createComponent<chosenSteps extends HelperFnChosenSteps<resolvedStep$1, stepNumbers>, props = undefined>(options: CreateHelperFunctionOptionsBase<resolvedStep$1, stepNumbers, chosenSteps>, fn: CreateComponentCallback<resolvedStep$1, stepNumbers, chosenSteps, props>): CreatedMultiStepFormComponent<props>;
30
- }
31
- declare function createMultiStepFormSchema<step extends Step<casing>, casing extends CasingType = DefaultCasing, storageKey extends string = DefaultStorageKey, formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias, formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep$1> = MultiStepFormSchemaConfig.defaultEnabledFor, formProps extends object = ComponentPropsWithRef<'form'>, resolvedStep$1 extends ResolvedStep$1<step, casing> = ResolvedStep$1<step, casing>, stepNumbers extends StepNumbers<resolvedStep$1> = StepNumbers<resolvedStep$1>>(options: MultiStepFormSchemaOptions$1<step, Constrain<casing, CasingType>, storageKey, formAlias, formEnabledFor, formProps>): MultiStepFormSchema$1<step, casing, storageKey, formAlias, formEnabledFor, formProps, resolvedStep$1, stepNumbers>;
32
- //#endregion
33
- export { AnyMultiStepFormSchema, MultiStepFormSchema$1 as MultiStepFormSchema, MultiStepFormSchemaOptions$1 as MultiStepFormSchemaOptions, createMultiStepFormSchema };
34
- //# sourceMappingURL=schema.d.mts.map
package/dist/schema.mjs DELETED
@@ -1,44 +0,0 @@
1
- import { MultiStepFormStepSchema as MultiStepFormStepSchema$1 } from "./step-schema.mjs";
2
- import { DEFAULT_CASING, MultiStepFormSchema, createCtx } from "@jfdevelops/multi-step-form-core";
3
- import { MultiStepFormStepSchemaInternal } from "@jfdevelops/multi-step-form-core/_internals";
4
-
5
- //#region src/schema.ts
6
- var MultiStepFormSchema$1 = class extends MultiStepFormSchema {
7
- stepSchema;
8
- #internal;
9
- constructor(config) {
10
- const { nameTransformCasing = DEFAULT_CASING, storage, ...rest } = config;
11
- const options = {
12
- nameTransformCasing,
13
- storage,
14
- ...rest
15
- };
16
- super(options);
17
- this.stepSchema = new MultiStepFormStepSchema$1(options);
18
- this.#internal = new MultiStepFormStepSchemaInternal({
19
- originalValue: this.stepSchema.original,
20
- getValue: () => this.stepSchema.value,
21
- setValue: (value) => {
22
- this.stepSchema.value = { ...value };
23
- this.storage.add(value);
24
- this.notify();
25
- }
26
- });
27
- }
28
- createComponent(options, fn) {
29
- const { stepData } = options;
30
- const ctx = createCtx(this.stepSchema.value, stepData);
31
- return ((props) => fn({
32
- ctx,
33
- update: this.#internal.createHelperFnInputUpdate(stepData),
34
- reset: this.#internal.createHelperFnInputReset(stepData)
35
- }, props));
36
- }
37
- };
38
- function createMultiStepFormSchema(options) {
39
- return new MultiStepFormSchema$1(options);
40
- }
41
-
42
- //#endregion
43
- export { MultiStepFormSchema$1 as MultiStepFormSchema, createMultiStepFormSchema };
44
- //# sourceMappingURL=schema.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.mjs","names":["MultiStepFormSchema","MultiStepFormSchemaCore","#internal","MultiStepFormStepSchema"],"sources":["../src/schema.ts"],"sourcesContent":["import {\n type CasingType,\n type Constrain,\n createCtx,\n type CreateHelperFunctionOptionsBase,\n DEFAULT_CASING,\n type DefaultCasing,\n type DefaultStorageKey,\n type HelperFnChosenSteps,\n type MultiStepFormSchemaOptions as MultiStepFormSchemaBaseOptions,\n MultiStepFormSchema as MultiStepFormSchemaCore,\n type ResolvedStep as ResolvedStepCore,\n type Step,\n type StepNumbers,\n} from '@jfdevelops/multi-step-form-core';\nimport type { ComponentPropsWithRef } from 'react';\nimport { MultiStepFormSchemaConfig } from './form-config';\nimport {\n type CreateComponentCallback,\n type CreatedMultiStepFormComponent,\n type HelperFunctions,\n MultiStepFormStepSchema,\n type ResolvedStep,\n} from './step-schema';\nimport { MultiStepFormStepSchemaInternal } from '@jfdevelops/multi-step-form-core/_internals';\n\n// export type AnyMultiStepFormSchema = MultiStepFormSchema<any, any, any>;\nexport type AnyMultiStepFormSchema = { [x: string]: any };\n\n// Helper inference types for `AnyMultiStepFormSchema`\nexport namespace MultiStepFormSchema {\n /**\n * Infer the resolved step from a {@linkcode MultiStepFormSchema}.\n */\n export type resolvedStep<T extends AnyMultiStepFormSchema> =\n T['stepSchema']['value'];\n /**\n * Infer the {@linkcode MultiStepFormSchema}'s step numbers.\n */\n export type stepNumbers<T extends AnyMultiStepFormSchema> = StepNumbers<\n resolvedStep<T>\n >;\n /**\n * Get the data for a specific step from a {@linkcode MultiStepFormSchema}.\n */\n export type getData<\n T extends AnyMultiStepFormSchema,\n TTarget extends keyof resolvedStep<T>\n > = resolvedStep<T>[TTarget];\n}\n\nexport interface MultiStepFormSchemaOptions<\n TStep extends Step<TCasing>,\n TCasing extends CasingType,\n TStorageKey extends string,\n TFormAlias extends string,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>,\n TFormProps extends object,\n TResolvedStep extends ResolvedStep<TStep, TCasing> = ResolvedStep<\n TStep,\n TCasing\n >\n> extends MultiStepFormSchemaBaseOptions<TStep, TCasing, TStorageKey>,\n MultiStepFormSchemaConfig.Form<\n TResolvedStep,\n TFormAlias,\n TFormEnabledFor,\n TFormProps\n > {}\n\nexport class MultiStepFormSchema<\n step extends Step<casing>,\n casing extends CasingType = DefaultCasing,\n storageKey extends string = DefaultStorageKey,\n formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias,\n formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep> = MultiStepFormSchemaConfig.defaultEnabledFor,\n formProps extends object = ComponentPropsWithRef<'form'>,\n resolvedStep extends ResolvedStep<step, casing> = ResolvedStep<\n step,\n casing\n >,\n stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n >\n extends MultiStepFormSchemaCore<\n step,\n casing,\n ResolvedStepCore<step, casing>,\n StepNumbers<ResolvedStepCore<step, casing>>,\n storageKey\n >\n implements HelperFunctions<resolvedStep, stepNumbers>\n{\n // @ts-ignore\n stepSchema: MultiStepFormStepSchema<\n step,\n casing,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >;\n readonly #internal: MultiStepFormStepSchemaInternal<\n step,\n casing,\n resolvedStep,\n stepNumbers\n >;\n\n constructor(\n config: MultiStepFormSchemaOptions<\n step,\n Constrain<casing, CasingType>,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >\n ) {\n const { nameTransformCasing = DEFAULT_CASING, storage, ...rest } = config;\n const options = { nameTransformCasing, storage, ...rest };\n\n super(options);\n\n this.stepSchema = new MultiStepFormStepSchema<\n step,\n casing,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >(options);\n this.#internal = new MultiStepFormStepSchemaInternal<\n step,\n casing,\n resolvedStep,\n stepNumbers\n >({\n originalValue: this.stepSchema.original,\n getValue: () => this.stepSchema.value as never,\n setValue: (value) => {\n this.stepSchema.value = { ...value } as never;\n this.storage.add(value);\n this.notify();\n },\n });\n }\n\n createComponent<\n chosenSteps extends HelperFnChosenSteps<resolvedStep, stepNumbers>,\n props = undefined\n >(\n options: CreateHelperFunctionOptionsBase<\n resolvedStep,\n stepNumbers,\n chosenSteps\n >,\n fn: CreateComponentCallback<resolvedStep, stepNumbers, chosenSteps, props>\n ): CreatedMultiStepFormComponent<props> {\n const { stepData } = options;\n const ctx = createCtx<resolvedStep, stepNumbers, chosenSteps>(\n this.stepSchema.value as never,\n stepData\n ) as never;\n\n return ((props?: props) =>\n fn(\n {\n ctx,\n update: this.#internal.createHelperFnInputUpdate(stepData),\n reset: this.#internal.createHelperFnInputReset(stepData),\n },\n props as any\n )) as any;\n }\n}\n\nexport function createMultiStepFormSchema<\n step extends Step<casing>,\n casing extends CasingType = DefaultCasing,\n storageKey extends string = DefaultStorageKey,\n formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias,\n formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep> = MultiStepFormSchemaConfig.defaultEnabledFor,\n formProps extends object = ComponentPropsWithRef<'form'>,\n resolvedStep extends ResolvedStep<step, casing> = ResolvedStep<step, casing>,\n stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n>(\n options: MultiStepFormSchemaOptions<\n step,\n Constrain<casing, CasingType>,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >\n) {\n return new MultiStepFormSchema<\n step,\n casing,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps,\n resolvedStep,\n stepNumbers\n >(options);\n}\n"],"mappings":";;;;;AAsEA,IAAaA,wBAAb,cAaUC,oBAQV;CAEE;CAQA,CAASC;CAOT,YACE,QAQA;EACA,MAAM,EAAE,sBAAsB,gBAAgB,SAAS,GAAG,SAAS;EACnE,MAAM,UAAU;GAAE;GAAqB;GAAS,GAAG;GAAM;AAEzD,QAAM,QAAQ;AAEd,OAAK,aAAa,IAAIC,0BAOpB,QAAQ;AACV,QAAKD,WAAY,IAAI,gCAKnB;GACA,eAAe,KAAK,WAAW;GAC/B,gBAAgB,KAAK,WAAW;GAChC,WAAW,UAAU;AACnB,SAAK,WAAW,QAAQ,EAAE,GAAG,OAAO;AACpC,SAAK,QAAQ,IAAI,MAAM;AACvB,SAAK,QAAQ;;GAEhB,CAAC;;CAGJ,gBAIE,SAKA,IACsC;EACtC,MAAM,EAAE,aAAa;EACrB,MAAM,MAAM,UACV,KAAK,WAAW,OAChB,SACD;AAED,WAAS,UACP,GACE;GACE;GACA,QAAQ,MAAKA,SAAU,0BAA0B,SAAS;GAC1D,OAAO,MAAKA,SAAU,yBAAyB,SAAS;GACzD,EACD,MACD;;;AAIP,SAAgB,0BAUd,SAQA;AACA,QAAO,IAAIF,sBAST,QAAQ"}
@@ -1,222 +0,0 @@
1
- const require_field = require('./field.cjs');
2
- const require_form_config = require('./form-config.cjs');
3
- const require_utils = require('./utils.cjs');
4
- let __jfdevelops_multi_step_form_core = require("@jfdevelops/multi-step-form-core");
5
- let __jfdevelops_multi_step_form_core__internals = require("@jfdevelops/multi-step-form-core/_internals");
6
-
7
- //#region src/step-schema.ts
8
- let StepSpecificComponent;
9
- (function(_StepSpecificComponent) {
10
- _StepSpecificComponent.DEFAULT_FORM_INSTANCE_ALIAS = "form";
11
- })(StepSpecificComponent || (StepSpecificComponent = {}));
12
- /**
13
- * Creates a default values object for the target step.
14
- * @param steps The steps schema.
15
- * @param targetStep The step to create the default values for.
16
- * @returns An object containing the field names and their default values.
17
- */
18
- function createDefaultValues(steps, targetStep) {
19
- (0, __jfdevelops_multi_step_form_core.invariant)(targetStep in steps, `The target step ${targetStep} is not a valid step key`);
20
- const current = steps[targetStep];
21
- (0, __jfdevelops_multi_step_form_core.invariant)("fields" in current, `No "fields" were found for ${targetStep}`);
22
- let defaultValues = {};
23
- for (const [fieldName, fieldValues] of Object.entries(current.fields)) defaultValues = {
24
- ...defaultValues,
25
- [fieldName]: fieldValues.defaultValue
26
- };
27
- return defaultValues;
28
- }
29
- var MultiStepFormStepSchema = class extends __jfdevelops_multi_step_form_core.MultiStepFormStepSchema {
30
- value;
31
- #internal;
32
- constructor(config) {
33
- const { form, ...rest } = config;
34
- super(rest);
35
- this.value = (0, __jfdevelops_multi_step_form_core.createStep)(this.original);
36
- this.#internal = new __jfdevelops_multi_step_form_core__internals.MultiStepFormStepSchemaInternal({
37
- originalValue: this.original,
38
- getValue: () => this.value,
39
- setValue: (next) => this.handlePostUpdate(next)
40
- });
41
- this.sync();
42
- this.value = this.#internal.enrichValues(this.value, (step) => {
43
- const key = `step${step}`;
44
- const stepData = [key];
45
- const id = form?.id ?? key;
46
- const ctx = (0, __jfdevelops_multi_step_form_core.createCtx)(this.value, stepData);
47
- return { createComponent: this.createStepSpecificComponentFactory(stepData, {
48
- isStepSpecific: true,
49
- defaultId: id,
50
- form
51
- }, ctx) };
52
- });
53
- }
54
- createFormComponent(form, defaultId) {
55
- const { render, enabledForSteps = "all", id = defaultId } = form;
56
- const ctx = {
57
- id,
58
- steps: (0, __jfdevelops_multi_step_form_core.createCtx)(this.value, enabledForSteps)
59
- };
60
- return (props) => render(ctx, props);
61
- }
62
- createStepSpecificComponentImpl(stepData, config, input, extraInput = {}) {
63
- return (fn) => ((props) => {
64
- const hookResults = {};
65
- for (const [key, value] of Object.entries(extraInput)) if (typeof value === "function") try {
66
- hookResults[key] = value();
67
- } catch (error) {
68
- const errorMessage = error instanceof Error ? error.message : String(error);
69
- throw new Error(`[multi-step-form] Error calling hook "${key}" in useFormInstance.render: ${errorMessage}\n\nThis usually means:\n1. The hook is being called outside of a React component\n2. The hook has invalid dependencies or configuration\n3. There's an error in your hook implementation\n\nOriginal error: ${errorMessage}`, { cause: error });
70
- }
71
- else hookResults[key] = value;
72
- const { defaultId, form } = config;
73
- const { ctx } = input;
74
- const [step] = stepData;
75
- (0, __jfdevelops_multi_step_form_core.invariant)(this.steps.isValidStepKey(step), `[createComponent]: the target step ${step} is invalid. Note, this error shouldn't appear as the target step should always be valid. If you see this error, please open an issue.`);
76
- const stepNumber = Number.parseInt(step.replace("step", ""));
77
- (0, __jfdevelops_multi_step_form_core.invariant)(!Number.isNaN(stepNumber), `[${step}:"createComponent"]: an error occurred while extracting the number`);
78
- const current = this.value[step];
79
- (0, __jfdevelops_multi_step_form_core.invariant)("fields" in current, `[${step}:createComponent]: unable to find the "fields" for the current step`);
80
- (0, __jfdevelops_multi_step_form_core.invariant)(typeof current.fields === "object", `[${step}:createComponent]: the "fields" property must be an object, was ${typeof current.fields}`);
81
- const stepUpdater = this.#internal.createStepUpdaterFn(step);
82
- const Field = require_field.field.create((name) => {
83
- const currentFields = Object.keys(current.fields);
84
- (0, __jfdevelops_multi_step_form_core.invariant)(typeof name === "string", (formatter) => `[${step}:Field]: the "name" prop must be a string and a valid field for ${step}. Available fields include: "${formatter.format(currentFields)}"`);
85
- (0, __jfdevelops_multi_step_form_core.invariant)(name in current.fields, (formatter) => `[${step}:Field]: the field "${name}" doesn't exist for the current step. Available fields include: "${formatter.format(currentFields)}".`);
86
- (0, __jfdevelops_multi_step_form_core.invariant)("update" in current, `[${step}:Field]: No "update" function was found`);
87
- const defaultValue = this.getValue(step, name);
88
- const { label, nameTransformCasing, type } = current.fields[name];
89
- const targetFields = `fields.${name}.defaultValue`;
90
- return {
91
- defaultValue,
92
- label,
93
- nameTransformCasing,
94
- type,
95
- name,
96
- onInputChange: (value) => {
97
- let resolvedValue;
98
- if (typeof value === "function") resolvedValue = value(this.getValue(step, name));
99
- else resolvedValue = value;
100
- this.update({
101
- targetStep: step,
102
- updater: resolvedValue,
103
- fields: [targetFields]
104
- });
105
- },
106
- reset: () => this.reset({
107
- fields: [targetFields],
108
- targetStep: step
109
- })
110
- };
111
- });
112
- let fnInput = {
113
- ctx,
114
- onInputChange: stepUpdater,
115
- reset: this.#internal.createStepResetterFn(step),
116
- Field,
117
- ...hookResults
118
- };
119
- if (form) {
120
- const { alias = require_form_config.MultiStepFormSchemaConfig.DEFAULT_FORM_ALIAS, ...rest } = form;
121
- const enabledFor = rest.enabledForSteps ?? "all";
122
- if (require_form_config.MultiStepFormSchemaConfig.isFormAvailable(stepData, enabledFor)) fnInput = {
123
- ...fnInput,
124
- [alias]: this.createFormComponent(rest, defaultId)
125
- };
126
- return fn(fnInput, props);
127
- }
128
- return fn({
129
- ...fnInput,
130
- [require_form_config.MultiStepFormSchemaConfig.DEFAULT_FORM_ALIAS]: require_form_config.MultiStepFormSchemaConfig.createDefaultForm(defaultId)
131
- }, props);
132
- });
133
- }
134
- createStepSpecificComponentFactory(stepData, config, ctx) {
135
- const createStepSpecificComponentImpl = this.createStepSpecificComponentImpl.bind(this);
136
- const createDefaultValues$1 = this.createDefaultValues.bind(this);
137
- const resolvedValues = this.value;
138
- const [targetStep] = stepData;
139
- const update = this.#internal.createStepUpdaterFn(targetStep).bind(this.#internal);
140
- const reset = this.#internal.createStepResetterFn(targetStep).bind(this.#internal);
141
- function impl(optionsOrFn, fn) {
142
- function createResolvedCtx(additionalCtx) {
143
- return additionalCtx ? { ctx: {
144
- ...ctx,
145
- ...additionalCtx
146
- } } : { ctx };
147
- }
148
- function createStepSpecificComponent() {
149
- (0, __jfdevelops_multi_step_form_core.invariant)(typeof optionsOrFn === "function", "The first argument must be a function");
150
- return createStepSpecificComponentImpl(stepData, config, createResolvedCtx(void 0))(optionsOrFn);
151
- }
152
- if (typeof optionsOrFn === "object") {
153
- const { useFormInstance, ctxData, debug } = optionsOrFn;
154
- const logger = new __jfdevelops_multi_step_form_core.MultiStepFormLogger({
155
- debug,
156
- prefix(prefix) {
157
- return `${prefix}-${targetStep}-createComponent`;
158
- }
159
- });
160
- logger.info("First argument is an object");
161
- const { [targetStep]: _, ...values } = resolvedValues;
162
- (0, __jfdevelops_multi_step_form_core.invariant)(typeof fn === "function", "The second argument must be a function");
163
- const createdCtx = require_utils.resolvedCtxCreator(logger, values);
164
- if (useFormInstance) {
165
- const { render, alias = StepSpecificComponent.DEFAULT_FORM_INSTANCE_ALIAS } = useFormInstance;
166
- const [step] = stepData;
167
- const defaultValues = createDefaultValues$1(step);
168
- const resolvedCtx = ctxData ? createdCtx({
169
- ctx,
170
- ctxData
171
- }) : ctx;
172
- const renderInput = {
173
- ctx: resolvedCtx,
174
- defaultValues
175
- };
176
- return createStepSpecificComponentImpl(stepData, config, {
177
- ctx: resolvedCtx,
178
- update,
179
- reset
180
- }, { [alias]: () => render(renderInput) })(fn);
181
- }
182
- if (ctxData) return createStepSpecificComponentImpl(stepData, config, {
183
- ctx: createdCtx({
184
- ctx,
185
- ctxData
186
- }),
187
- update,
188
- reset
189
- })(fn);
190
- return createStepSpecificComponent();
191
- }
192
- return createStepSpecificComponent();
193
- }
194
- return impl;
195
- }
196
- /**
197
- * A helper function to create a component for a specific step.
198
- * @param options The options for creating the step specific component.
199
- * @param fn A callback that is used for accessing the target step's data and defining
200
- * any props that the component should have. This function must return a valid `JSX` element.
201
- * @returns The created component for the step.
202
- */
203
- createComponent(options, fn) {
204
- const { stepData } = options;
205
- const ctx = (0, __jfdevelops_multi_step_form_core.createCtx)(this.value, stepData);
206
- return ((props) => fn(ctx, props));
207
- }
208
- createDefaultValues(targetStep) {
209
- return createDefaultValues(this.value, targetStep);
210
- }
211
- };
212
-
213
- //#endregion
214
- exports.MultiStepFormStepSchema = MultiStepFormStepSchema;
215
- Object.defineProperty(exports, 'StepSpecificComponent', {
216
- enumerable: true,
217
- get: function () {
218
- return StepSpecificComponent;
219
- }
220
- });
221
- exports.createDefaultValues = createDefaultValues;
222
- //# sourceMappingURL=step-schema.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"step-schema.cjs","names":["MultiStepFormStepSchemaBase","#internal","MultiStepFormStepSchemaInternal","hookResults: Record<string, unknown>","field","MultiStepFormSchemaConfig","createDefaultValues","MultiStepFormLogger","resolvedCtxCreator"],"sources":["../src/step-schema.ts"],"sourcesContent":["import {\n type AnyStepField,\n type CasingType,\n type Constrain,\n createCtx,\n type CreateHelperFunctionOptionsBase,\n createStep,\n type DefaultCasing,\n type DefaultStorageKey,\n type Expand,\n type GetCurrentStep,\n type GetFieldsForStep,\n type HelperFnChosenSteps,\n type HelperFnCtx,\n type HelperFnInputBase,\n invariant,\n MultiStepFormLogger,\n type MultiStepFormSchemaStepConfig as MultiStepFormSchemaStepBaseConfig,\n MultiStepFormStepSchema as MultiStepFormStepSchemaBase,\n type Relaxed,\n type ResetFn,\n type ResolvedStep as ResolvedCoreStep,\n type Step,\n type StepNumbers,\n type StrippedResolvedStep,\n type UpdateFn,\n type Updater,\n type ValidStepKey,\n} from '@jfdevelops/multi-step-form-core';\nimport { MultiStepFormStepSchemaInternal } from '@jfdevelops/multi-step-form-core/_internals';\nimport type { ComponentPropsWithRef, ReactNode } from 'react';\nimport { field } from './field';\nimport { MultiStepFormSchemaConfig } from './form-config';\nimport { resolvedCtxCreator } from './utils';\n\nexport interface MultiStepFormSchemaStepConfig<\n TStep extends Step<TCasing>,\n TCasing extends CasingType,\n TStorageKey extends string,\n TFormAlias extends string,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>,\n TFormProps extends object,\n TResolvedStep extends ResolvedStep<TStep, TCasing> = ResolvedStep<\n TStep,\n TCasing\n >\n> extends MultiStepFormSchemaStepBaseConfig<TStep, TCasing, TStorageKey>,\n MultiStepFormSchemaConfig.Form<\n TResolvedStep,\n TFormAlias,\n TFormEnabledFor,\n TFormProps\n > {}\n\nexport type CreateFunction<TArgs extends any[], TReturn = void> = (\n ...args: TArgs\n) => TReturn;\nexport type CreateComponent<TInput, TProps> = CreateFunction<\n [input: TInput, props: TProps],\n ReactNode\n>;\n\nexport type CreateComponentCallback<\n TResolvedStep extends StrippedResolvedStep<AnyResolvedStep>,\n TSteps extends StepNumbers<TResolvedStep>,\n TChosenSteps extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TProps\n> = CreateComponent<\n HelperFnInputBase<TResolvedStep, TSteps, TChosenSteps>,\n TProps\n>;\nexport type CreatedMultiStepFormComponent<TProps> = TProps extends undefined\n ? () => ReactNode\n : (props: TProps) => ReactNode;\nexport type CreateComponentFn<\n TResolvedStep extends AnyResolvedStep,\n // This is needed to make TS happy with all types\n TStepNumbers extends StepNumbers<TResolvedStep>\n> = <\n chosenSteps extends HelperFnChosenSteps<TResolvedStep, TStepNumbers>,\n props = undefined\n>(\n options: CreateHelperFunctionOptionsBase<\n TResolvedStep,\n TStepNumbers,\n chosenSteps\n >,\n fn: CreateComponentCallback<TResolvedStep, TStepNumbers, chosenSteps, props>\n) => CreatedMultiStepFormComponent<props>;\n\nexport namespace StepSpecificComponent {\n // The logic for getting the formCtx only works for step specific `createComponent`\n // (i.e: step1.createComponent(...)) as of now. Reason is because I can't think of a good API for integrating the form\n // ctx into the main `createComponent` since multiple steps can be chosen. In that case\n // how would the logic work for when the form component should be defined in the callback?\n // Ideas:\n // - Make the main `createComponent` return a function that accepts the current step\n export type formComponent<\n TResolvedStep extends StrippedResolvedStep<AnyResolvedStep>,\n TSteps extends StepNumbers<TResolvedStep>,\n TChosenSteps extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TFormAlias extends string,\n TFormProps extends object,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>\n > = TFormEnabledFor extends MultiStepFormSchemaConfig.defaultEnabledFor\n ? MultiStepFormSchemaConfig.formCtx<TFormAlias, TFormProps>\n : TFormEnabledFor extends HelperFnChosenSteps.tupleNotation<\n ValidStepKey<TSteps>\n >\n ? TFormEnabledFor[number] extends keyof TResolvedStep\n ? TChosenSteps extends HelperFnChosenSteps.tupleNotation<\n ValidStepKey<TSteps>\n >\n ? TChosenSteps[number] extends keyof TResolvedStep\n ? TChosenSteps[number] extends TFormEnabledFor[number]\n ? MultiStepFormSchemaConfig.formCtx<TFormAlias, TFormProps>\n : {}\n : {}\n : {}\n : {}\n : keyof TFormEnabledFor extends keyof TResolvedStep\n ? TChosenSteps extends HelperFnChosenSteps.tupleNotation<\n ValidStepKey<TSteps>\n >\n ? TChosenSteps[number] extends keyof TResolvedStep\n ? TChosenSteps[number] extends keyof TFormEnabledFor\n ? MultiStepFormSchemaConfig.formCtx<TFormAlias, TFormProps>\n : {}\n : {}\n : {}\n : {};\n export type onInputChange<\n TResolvedStep extends AnyResolvedStep,\n TStepNumbers extends StepNumbers<TResolvedStep>,\n TTargetStep extends TStepNumbers\n > = <\n CurrentStepData extends GetCurrentStep<TResolvedStep, TTargetStep>,\n Field extends keyof CurrentStepData\n >(\n field: Field,\n updater: Updater<CurrentStepData[Field], Relaxed<CurrentStepData[Field]>>\n ) => void;\n export type updateWrappers<\n TResolvedStep extends StrippedResolvedStep<AnyResolvedStep>,\n TSteps extends StepNumbers<TResolvedStep>,\n TChosenSteps extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TStepNumber extends HelperFnChosenSteps.extractStepNumber<\n TResolvedStep,\n TSteps,\n TChosenSteps\n >\n > = TStepNumber extends TSteps\n ? {\n /**\n * A useful wrapper around `update` to update the specific field.\n */\n onInputChange: UpdateFn.stepSpecific<\n TResolvedStep,\n TSteps,\n ValidStepKey<TStepNumber>\n >;\n /**\n * A useful wrapper for `update` to reset a specific field's value to its\n * original config value.\n * @resetFn\n */\n reset: ResetFn.stepSpecific<\n TResolvedStep,\n TSteps,\n ValidStepKey<TStepNumber>\n >;\n }\n : {};\n export type input<\n TResolvedStep extends StrippedResolvedStep<AnyResolvedStep>,\n TSteps extends StepNumbers<TResolvedStep>,\n TChosenSteps extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TAdditionalCtx extends Record<string, unknown>,\n TStepNumber extends HelperFnChosenSteps.extractStepNumber<\n TResolvedStep,\n TSteps,\n TChosenSteps\n > = HelperFnChosenSteps.extractStepNumber<\n TResolvedStep,\n TSteps,\n TChosenSteps\n >\n > = HelperFnInputBase<\n TResolvedStep,\n TSteps,\n TChosenSteps,\n never,\n TAdditionalCtx\n > &\n updateWrappers<TResolvedStep, TSteps, TChosenSteps, TStepNumber> & {\n Field: field.component<\n TResolvedStep,\n ValidStepKey<\n HelperFnChosenSteps.extractStepNumber<\n TResolvedStep,\n TSteps,\n TChosenSteps\n >\n >\n >;\n };\n\n export type callback<\n TResolvedStep extends StrippedResolvedStep<AnyResolvedStep>,\n TSteps extends StepNumbers<TResolvedStep>,\n TChosenSteps extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TProps,\n TFormAlias extends string,\n TFormProps extends object,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>,\n TAdditionalInput extends object,\n TAdditionalCtx extends Record<string, unknown>\n > = CreateComponent<\n Expand<\n input<TResolvedStep, TSteps, TChosenSteps, TAdditionalCtx> &\n formComponent<\n TResolvedStep,\n TSteps,\n TChosenSteps,\n TFormAlias,\n TFormProps,\n TFormEnabledFor\n > &\n TAdditionalInput\n >,\n TProps\n >;\n export const DEFAULT_FORM_INSTANCE_ALIAS = 'form';\n export type defaultFormInstanceAlias = typeof DEFAULT_FORM_INSTANCE_ALIAS;\n export type formInstanceOptions<\n TAlias extends string,\n TRenderInput,\n TReturn\n > = {\n /**\n * The name of the return value of the `render` method.\n */\n alias?: TAlias;\n /**\n * A function that renders/creates the form instance. This function will be called\n * at the top level of the component, ensuring hooks are called in a valid React context.\n *\n * @param input - The input object containing context and default values\n * @returns The form instance (typically from a hook like `useForm`)\n *\n * @example\n * ```tsx\n * useFormInstance: {\n * render({ defaultValues }) {\n * return useForm({\n * defaultValues,\n * });\n * },\n * }\n * ```\n *\n * **Verification**: The hook call is automatically verified:\n * - Errors are caught and reported with helpful messages\n * - In development, hook calls are logged to console.debug\n * - The hook must be called at the component top level (enforced by the framework)\n */\n render: CreateFunction<[input: TRenderInput], TReturn>;\n };\n\n export interface CtxSelector<\n TResolvedStep extends AnyResolvedStep,\n TSteps extends StepNumbers<TResolvedStep>,\n TTargetStep extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TCtx\n > {\n /**\n * A function to select the data that will be available in the `fn`'s ctx.\n * @param input The available input to create the context with.\n * @returns The created ctx.\n */\n ctxData?: (\n input: HelperFnInputBase<\n TResolvedStep,\n TSteps,\n 'all',\n HelperFnChosenSteps.resolve<TResolvedStep, TSteps, TTargetStep>\n >\n ) => TCtx;\n }\n\n export type options<\n TResolvedStep extends AnyResolvedStep,\n TSteps extends StepNumbers<TResolvedStep>,\n TTargetStep extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TFormInstanceAlias extends string,\n TFormInstance,\n TCtx\n > = CtxSelector<TResolvedStep, TSteps, TTargetStep, TCtx> & {\n /**\n * If set to `true`, you'll be able to open the {@linkcode console} to view logs.\n */\n debug?: boolean;\n useFormInstance?: formInstanceOptions<\n TFormInstanceAlias,\n HelperFnInputBase<TResolvedStep, TSteps, TTargetStep> & {\n /**\n * An object containing all the default values for the current step.\n */\n defaultValues: Expand<\n ExtractedDefaultValues<TResolvedStep, TSteps, TTargetStep>\n >;\n },\n TFormInstance\n >;\n };\n}\n\nexport type CreateStepSpecificComponentCallback<\n TResolvedStep extends StrippedResolvedStep<AnyResolvedStep>,\n TSteps extends StepNumbers<TResolvedStep>,\n TChosenSteps extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TProps,\n TFormAlias extends string,\n TFormProps extends object,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>,\n TAdditionalInput extends object = {},\n TAdditionalCtx extends Record<string, unknown> = {}\n> = StepSpecificComponent.callback<\n TResolvedStep,\n TSteps,\n TChosenSteps,\n TProps,\n TFormAlias,\n TFormProps,\n TFormEnabledFor,\n TAdditionalInput,\n TAdditionalCtx\n>;\n\nexport type ExtractedDefaultValues<\n TResolvedStep extends AnyResolvedStep,\n TSteps extends StepNumbers<TResolvedStep>,\n TTargetStep extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TExtractedStepNumber extends number = HelperFnChosenSteps.extractStepNumber<\n TResolvedStep,\n TSteps,\n TTargetStep\n >,\n TFields extends GetFieldsForStep<\n TResolvedStep,\n ValidStepKey<TExtractedStepNumber>\n > = GetFieldsForStep<TResolvedStep, ValidStepKey<TExtractedStepNumber>>\n> = { [field in keyof TFields]: TFields[field]['defaultValue'] };\nexport interface StepSpecificCreateComponentFn<\n TResolvedStep extends AnyResolvedStep,\n TSteps extends StepNumbers<TResolvedStep>,\n TTargetStep extends HelperFnChosenSteps<TResolvedStep, TSteps>,\n TFormAlias extends string,\n TFormProps extends object,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>\n> {\n /**\n * A utility function to easily create a component for the current step.\n * @param fn The callback function where the component is defined.\n */\n <props = undefined>(\n fn: CreateStepSpecificComponentCallback<\n TResolvedStep,\n TSteps,\n TTargetStep,\n props,\n TFormAlias,\n TFormProps,\n TFormEnabledFor\n >\n ): CreatedMultiStepFormComponent<props>;\n /**\n * A utility function to easily create a component for the current step.\n * @param options Specific config options for creating a component for the current step.\n * @param fn The callback function where the component is defined.\n * @returns The created component.\n */\n <\n formInstance,\n additionalCtx extends Record<string, unknown> = {},\n formInstanceAlias extends string = StepSpecificComponent.defaultFormInstanceAlias,\n props = undefined\n >(\n options: StepSpecificComponent.options<\n TResolvedStep,\n TSteps,\n TTargetStep,\n formInstanceAlias,\n formInstance,\n additionalCtx\n >,\n fn: CreateStepSpecificComponentCallback<\n TResolvedStep,\n TSteps,\n TTargetStep,\n props,\n TFormAlias,\n TFormProps,\n TFormEnabledFor,\n { [_ in formInstanceAlias]: formInstance },\n additionalCtx\n >\n ): CreatedMultiStepFormComponent<props>;\n}\n\nexport type ResolvedStep<\n TStep extends Step<TDefaultCasing>,\n TDefaultCasing extends CasingType = DefaultCasing,\n TResolvedStep extends ResolvedCoreStep<\n TStep,\n TDefaultCasing\n > = ResolvedCoreStep<TStep, TDefaultCasing>,\n TFormAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep> = MultiStepFormSchemaConfig.defaultEnabledFor,\n TFormProps extends object = ComponentPropsWithRef<'form'>\n> = {\n [stepKey in keyof TResolvedStep]: TResolvedStep[stepKey] &\n (stepKey extends ValidStepKey<StepNumbers<TResolvedStep>>\n ? {\n createComponent: StepSpecificCreateComponentFn<\n TResolvedStep,\n StepNumbers<TResolvedStep>,\n [stepKey],\n TFormAlias,\n TFormProps,\n TFormEnabledFor\n >;\n }\n : {});\n};\n\nexport type AnyResolvedStep = ResolvedStep<any, any, any>;\nexport interface HelperFunctions<\n TResolvedStep extends AnyResolvedStep,\n TStepNumbers extends StepNumbers<TResolvedStep>\n> {\n createComponent: CreateComponentFn<TResolvedStep, TStepNumbers>;\n}\nnamespace CreateComponentImplConfig {\n export type stepSpecificConfig<\n TResolvedStep extends AnyResolvedStep,\n TFormAlias extends string,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>,\n TFormProps extends object\n > = {\n isStepSpecific: true;\n defaultId: string;\n form?: MultiStepFormSchemaConfig.FormConfig<\n TResolvedStep,\n TFormAlias,\n TFormEnabledFor,\n TFormProps\n >;\n };\n\n export type nonStepSpecific = {\n isStepSpecific: false;\n };\n\n export type config<\n TResolvedStep extends AnyResolvedStep,\n TFormAlias extends string,\n TFormEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<TResolvedStep>,\n TFormProps extends object\n > =\n | nonStepSpecific\n | stepSpecificConfig<\n TResolvedStep,\n TFormAlias,\n TFormEnabledFor,\n TFormProps\n >;\n}\n\n/**\n * Creates a default values object for the target step.\n * @param steps The steps schema.\n * @param targetStep The step to create the default values for.\n * @returns An object containing the field names and their default values.\n */\nexport function createDefaultValues<\n resolvedStep extends AnyResolvedStep,\n stepNumbers extends StepNumbers<resolvedStep>,\n targetStep extends ValidStepKey<stepNumbers>\n>(steps: resolvedStep, targetStep: targetStep) {\n invariant(\n targetStep in steps,\n `The target step ${targetStep} is not a valid step key`\n );\n\n const current = steps[targetStep as unknown as keyof resolvedStep];\n\n invariant('fields' in current, `No \"fields\" were found for ${targetStep}`);\n\n let defaultValues = {};\n\n for (const [fieldName, fieldValues] of Object.entries(\n current.fields as Record<string, Record<string, unknown>>\n )) {\n defaultValues = {\n ...defaultValues,\n [fieldName]: fieldValues.defaultValue,\n };\n }\n\n return defaultValues as Expand<\n ExtractedDefaultValues<resolvedStep, stepNumbers, [targetStep]>\n >;\n}\nexport class MultiStepFormStepSchema<\n step extends Step<casing>,\n casing extends CasingType = DefaultCasing,\n storageKey extends string = DefaultStorageKey,\n formAlias extends string = MultiStepFormSchemaConfig.defaultFormAlias,\n formEnabledFor extends MultiStepFormSchemaConfig.formEnabledFor<resolvedStep> = MultiStepFormSchemaConfig.defaultEnabledFor,\n formProps extends object = ComponentPropsWithRef<'form'>,\n core extends ResolvedCoreStep<step, casing> = ResolvedCoreStep<\n step,\n casing\n >,\n resolvedStep extends ResolvedStep<\n step,\n casing,\n core,\n formAlias,\n formEnabledFor,\n formProps\n > = ResolvedStep<step, casing, core, formAlias, formEnabledFor, formProps>,\n stepNumbers extends StepNumbers<resolvedStep> = StepNumbers<resolvedStep>\n >\n extends MultiStepFormStepSchemaBase<step, casing>\n implements HelperFunctions<resolvedStep, stepNumbers>\n{\n // @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`\n value: resolvedStep;\n readonly #internal: MultiStepFormStepSchemaInternal<\n step,\n casing,\n resolvedStep,\n stepNumbers\n >;\n\n constructor(\n config: MultiStepFormSchemaStepConfig<\n step,\n Constrain<casing, CasingType>,\n storageKey,\n formAlias,\n formEnabledFor,\n formProps\n >\n ) {\n const { form, ...rest } = config;\n\n super(rest as never);\n\n this.value = createStep(this.original);\n\n this.#internal = new MultiStepFormStepSchemaInternal<\n step,\n casing,\n resolvedStep,\n stepNumbers\n >({\n originalValue: this.original,\n getValue: () => this.value,\n setValue: (next) => this.handlePostUpdate(next as never),\n });\n\n // this.value = this.#internal.enrichValues(resolvedValues);\n this.sync();\n this.value = this.#internal.enrichValues(this.value, (step) => {\n const key = `step${step as stepNumbers}`;\n const stepData = [key] as HelperFnChosenSteps.tupleNotation<\n ValidStepKey<stepNumbers>\n >;\n const id = form?.id ?? key;\n const ctx = createCtx<\n resolvedStep,\n stepNumbers,\n HelperFnChosenSteps.tupleNotation<ValidStepKey<stepNumbers>>\n >(this.value, stepData);\n\n return {\n createComponent: this.createStepSpecificComponentFactory(\n stepData,\n {\n isStepSpecific: true,\n defaultId: id,\n form: form as never,\n },\n ctx\n ),\n };\n });\n }\n\n private createFormComponent(\n form: Omit<\n MultiStepFormSchemaConfig.FormConfig<\n resolvedStep,\n formAlias,\n formEnabledFor,\n formProps\n >,\n 'alias'\n >,\n defaultId: string\n ) {\n const { render, enabledForSteps = 'all', id = defaultId } = form;\n\n const ctx = {\n id,\n steps: createCtx(this.value, enabledForSteps as never),\n };\n\n return (props: formProps) => render(ctx, props);\n }\n\n private createStepSpecificComponentImpl<\n chosenStep extends HelperFnChosenSteps<resolvedStep, stepNumbers>\n >(\n stepData: chosenStep,\n config: CreateComponentImplConfig.stepSpecificConfig<\n resolvedStep,\n formAlias,\n formEnabledFor,\n formProps\n >,\n input: HelperFnInputBase<resolvedStep, stepNumbers, chosenStep>,\n extraInput = {}\n ) {\n return <props>(fn: Function) =>\n ((props: props) => {\n // Call hook functions from extraInput at the top level of the component\n // This ensures hooks are called in a valid React context (before any conditionals)\n const hookResults: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(extraInput)) {\n if (typeof value === 'function') {\n try {\n const result = value();\n // Verify the hook was actually called and returned a value\n // (hooks should always return something, even if it's undefined)\n hookResults[key] = result;\n\n // In development, we can add additional verification here\n // Log hook calls for debugging (can be disabled in production by removing console.debug)\n // if (typeof console !== 'undefined' && console.debug) {\n // console.debug(\n // `[multi-step-form] Hook \"${key}\" called successfully`,\n // { result: result === undefined ? 'defined' : 'undefined' }\n // );\n // }\n } catch (error) {\n // Provide helpful error message if hook throws\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n\n throw new Error(\n `[multi-step-form] Error calling hook \"${key}\" in useFormInstance.render: ${errorMessage}\\n\\n` +\n `This usually means:\\n` +\n `1. The hook is being called outside of a React component\\n` +\n `2. The hook has invalid dependencies or configuration\\n` +\n `3. There's an error in your hook implementation\\n\\n` +\n `Original error: ${errorMessage}`,\n { cause: error }\n );\n }\n } else {\n hookResults[key] = value;\n }\n }\n\n const { defaultId, form } = config;\n const { ctx } = input;\n\n // Safe cast here since the step specific `createComponent` will always have\n // `stepData` as a tuple\n const [step] =\n stepData as HelperFnChosenSteps.tupleNotation<`step${stepNumbers}`>;\n\n invariant(\n this.steps.isValidStepKey(step),\n `[createComponent]: the target step ${step} is invalid. Note, this error shouldn't appear as the target step should always be valid. If you see this error, please open an issue.`\n );\n\n const stepNumber = Number.parseInt(step.replace('step', ''));\n\n invariant(\n !Number.isNaN(stepNumber),\n `[${step}:\"createComponent\"]: an error occurred while extracting the number`\n );\n const current = this.value[step as keyof resolvedStep];\n\n // These checks are mostly for type safety. `current` should _always_ be in the proper format.\n // On the off chance that it's not, we have the checks here to help, but these checks are basically\n // just for type safety.\n invariant(\n 'fields' in current,\n `[${step}:createComponent]: unable to find the \"fields\" for the current step`\n );\n invariant(\n typeof current.fields === 'object',\n `[${step}:createComponent]: the \"fields\" property must be an object, was ${typeof current.fields}`\n );\n const stepUpdater = this.#internal.createStepUpdaterFn(step);\n\n const Field = field.create<\n resolvedStep,\n HelperFnChosenSteps.resolve<resolvedStep, stepNumbers, chosenStep>\n >((name) => {\n const currentFields = Object.keys(\n current.fields as Record<string, unknown>\n );\n\n invariant(\n typeof name === 'string',\n (formatter) =>\n `[${step}:Field]: the \"name\" prop must be a string and a valid field for ${step}. Available fields include: \"${formatter.format(\n currentFields\n )}\"`\n );\n // TODO add support for deep keys (`name`)\n\n invariant(\n name in (current.fields as object),\n (formatter) =>\n `[${step}:Field]: the field \"${name}\" doesn't exist for the current step. Available fields include: \"${formatter.format(\n currentFields\n )}\".`\n );\n\n invariant(\n 'update' in current,\n `[${step}:Field]: No \"update\" function was found`\n );\n\n const defaultValue = this.getValue(step as never, name as never);\n\n const { label, nameTransformCasing, type } = (\n current.fields as AnyStepField\n )[name];\n const targetFields = `fields.${name}.defaultValue`;\n\n return {\n defaultValue,\n label,\n nameTransformCasing,\n type,\n name,\n onInputChange: (value: unknown) => {\n // Handle Updater pattern: if value is a function, call it with the current field value\n let resolvedValue;\n\n if (typeof value === 'function') {\n const defaultValue = this.getValue(\n step as never,\n name as never\n );\n\n resolvedValue = value(defaultValue);\n } else {\n resolvedValue = value;\n }\n\n this.update({\n targetStep: step,\n updater: resolvedValue as never,\n fields: [targetFields] as never,\n });\n },\n reset: () =>\n this.reset({\n fields: [targetFields] as never,\n targetStep: step,\n }),\n } as never;\n });\n\n let fnInput = {\n ctx,\n onInputChange: stepUpdater,\n reset: this.#internal.createStepResetterFn(step),\n Field,\n ...hookResults,\n };\n\n if (form) {\n const {\n alias = MultiStepFormSchemaConfig.DEFAULT_FORM_ALIAS,\n ...rest\n } = form;\n const enabledFor = rest.enabledForSteps ?? 'all';\n\n if (\n MultiStepFormSchemaConfig.isFormAvailable(\n stepData as never,\n enabledFor as never\n )\n ) {\n fnInput = {\n ...fnInput,\n [alias]: this.createFormComponent(rest, defaultId),\n };\n }\n\n return fn(fnInput, props);\n }\n\n return fn(\n {\n ...fnInput,\n [MultiStepFormSchemaConfig.DEFAULT_FORM_ALIAS]:\n MultiStepFormSchemaConfig.createDefaultForm(defaultId),\n },\n props\n );\n }) as CreatedMultiStepFormComponent<props>;\n }\n\n private createStepSpecificComponentFactory<\n chosenStep extends HelperFnChosenSteps.tupleNotation<\n ValidStepKey<stepNumbers>\n >\n >(\n stepData: chosenStep,\n config: CreateComponentImplConfig.stepSpecificConfig<\n resolvedStep,\n formAlias,\n formEnabledFor,\n formProps\n >,\n ctx: HelperFnCtx<resolvedStep, stepNumbers, chosenStep>\n ): StepSpecificCreateComponentFn<\n resolvedStep,\n stepNumbers,\n chosenStep,\n formAlias,\n formProps,\n formEnabledFor\n > {\n const createStepSpecificComponentImpl =\n this.createStepSpecificComponentImpl.bind(this);\n const createDefaultValues = this.createDefaultValues.bind(this);\n\n // Not exactly sure why `this.value` could be undefined, but it can be so\n // we fallback to the internal value\n const resolvedValues = this.value;\n const [targetStep] = stepData;\n const update = this.#internal\n .createStepUpdaterFn(targetStep)\n .bind(this.#internal) as never;\n const reset = this.#internal\n .createStepResetterFn(targetStep)\n .bind(this.#internal) as never;\n\n function impl<props = undefined>(\n fn: CreateStepSpecificComponentCallback<\n resolvedStep,\n stepNumbers,\n chosenStep,\n props,\n formAlias,\n formProps,\n formEnabledFor\n >\n ): CreatedMultiStepFormComponent<props>;\n function impl<\n formInstance,\n formInstanceAlias extends string = StepSpecificComponent.defaultFormInstanceAlias,\n props = undefined,\n additionalCtx = {}\n >(\n options: StepSpecificComponent.options<\n resolvedStep,\n stepNumbers,\n chosenStep,\n formInstanceAlias,\n formInstance,\n additionalCtx\n >,\n fn: CreateStepSpecificComponentCallback<\n resolvedStep,\n stepNumbers,\n chosenStep,\n props,\n formAlias,\n formProps,\n formEnabledFor,\n { [_ in formInstanceAlias]: formInstance }\n >\n ): CreatedMultiStepFormComponent<props>;\n function impl<\n formInstance,\n formInstanceAlias extends string = StepSpecificComponent.defaultFormInstanceAlias,\n props = undefined,\n additionalCtx = {}\n >(\n optionsOrFn:\n | StepSpecificComponent.options<\n resolvedStep,\n stepNumbers,\n chosenStep,\n formInstanceAlias,\n formInstance,\n additionalCtx\n >\n | CreateStepSpecificComponentCallback<\n resolvedStep,\n stepNumbers,\n chosenStep,\n props,\n formAlias,\n formProps,\n formEnabledFor\n >,\n fn?: CreateStepSpecificComponentCallback<\n resolvedStep,\n stepNumbers,\n chosenStep,\n props,\n formAlias,\n formProps,\n formEnabledFor,\n { [_ in formInstanceAlias]: formInstance }\n >\n ) {\n function createResolvedCtx(additionalCtx: unknown) {\n return (\n additionalCtx ? { ctx: { ...ctx, ...additionalCtx } } : { ctx }\n ) as HelperFnInputBase<resolvedStep, stepNumbers, chosenStep>;\n }\n\n function createStepSpecificComponent() {\n invariant(\n typeof optionsOrFn === 'function',\n 'The first argument must be a function'\n );\n\n return createStepSpecificComponentImpl(\n stepData,\n config,\n createResolvedCtx(undefined)\n )(optionsOrFn);\n }\n\n if (typeof optionsOrFn === 'object') {\n const { useFormInstance, ctxData, debug } = optionsOrFn;\n const logger = new MultiStepFormLogger({\n debug,\n prefix(prefix) {\n return `${prefix}-${targetStep}-createComponent`;\n },\n });\n\n logger.info('First argument is an object');\n\n const { [targetStep]: _, ...values } = resolvedValues;\n\n invariant(\n typeof fn === 'function',\n 'The second argument must be a function'\n );\n const createdCtx = resolvedCtxCreator(logger, values);\n\n if (useFormInstance) {\n const {\n render,\n alias = StepSpecificComponent.DEFAULT_FORM_INSTANCE_ALIAS,\n } = useFormInstance;\n\n // Safe cast here since the step specific `createComponent` will always have\n // `stepData` as a tuple\n const [step] =\n stepData as HelperFnChosenSteps.tupleNotation<`step${stepNumbers}`>;\n\n // Store the render function and inputs to call it at component level\n // This ensures hooks are called in a valid React context\n const defaultValues = createDefaultValues(step) as never;\n const resolvedCtx = ctxData ? createdCtx({ ctx, ctxData }) : ctx;\n const renderInput = { ctx: resolvedCtx, defaultValues };\n\n return createStepSpecificComponentImpl(\n stepData,\n config,\n {\n ctx: resolvedCtx as never,\n update,\n reset,\n },\n {\n [alias]: () => render(renderInput as never),\n }\n )(fn);\n }\n\n if (ctxData) {\n const resolvedCtx = createdCtx({ ctx, ctxData });\n\n return createStepSpecificComponentImpl(stepData, config, {\n ctx: resolvedCtx as never,\n update,\n reset,\n })(fn);\n }\n\n // Empty options object. Can throw here 🤷‍♂️\n // Maybe add \"global\" - top level config - option to tune fine grained errors.\n return createStepSpecificComponent();\n }\n\n return createStepSpecificComponent();\n }\n\n return impl;\n }\n\n /**\n * A helper function to create a component for a specific step.\n * @param options The options for creating the step specific component.\n * @param fn A callback that is used for accessing the target step's data and defining\n * any props that the component should have. This function must return a valid `JSX` element.\n * @returns The created component for the step.\n */\n createComponent<\n chosenSteps extends HelperFnChosenSteps<resolvedStep, stepNumbers>,\n props = undefined\n >(\n options: CreateHelperFunctionOptionsBase<\n resolvedStep,\n stepNumbers,\n chosenSteps\n >,\n fn: CreateComponentCallback<resolvedStep, stepNumbers, chosenSteps, props>\n ) {\n const { stepData } = options;\n const ctx = createCtx<resolvedStep, stepNumbers, chosenSteps>(\n this.value,\n stepData\n ) as never;\n\n return ((props?: props) =>\n fn(ctx, props as any)) as CreatedMultiStepFormComponent<props>;\n }\n\n createDefaultValues<targetStep extends ValidStepKey<stepNumbers>>(\n targetStep: targetStep\n ) {\n return createDefaultValues(this.value, targetStep);\n }\n}\n"],"mappings":"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"}