import type { ItemValues, FlowValues, ListValues, CondValues, LoopValues, SwitchValues, FormValues, YieldValues, ReturnValues, VariablesValues } from "../values"; import type { OnNext, OnBack, GetFlow, SetFlow } from "../callbacks"; /** * Defines the structure and behavior of any element in a multi-step form. * * @template Render The type of the rendered output for each form step. This can vary depending on * the framework; for example, in React, it would typically be `ReactNode`. * * @template Values A type extending `ItemValues` that defines the structure of the multi-step form, * including the values handled in each phase. * * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. * * @template Params An object type defining the values accessible when rendering each form step in * the multi-step process. */ export type ItemSchema = Values extends FlowValues ? FlowSchema : Values extends FormValues ? FormSchema : Values extends YieldValues ? YieldSchema : Values extends ReturnValues ? ReturnSchema : Values extends VariablesValues ? VariablesSchema : never; /** * Defines the structure and behavior of any flow element in a multi-step form. * * @template Render The type of the rendered output for each form step. This can vary depending on * the framework; for example, in React, it would typically be `ReactNode`. * * @template Values A type extending `FlowValues` that defines the structure of the multi-step form, * including the values handled in each phase. * * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. * * @template Params An object type defining the values accessible when rendering each form step in * the multi-step process. */ export type FlowSchema = Values extends ListValues ? ListSchema : Values extends CondValues ? CondSchema : Values extends LoopValues ? LoopSchema : Values extends SwitchValues ? SwitchSchema : never; /** * Defines the structure and behavior of a list element in a multi-step form. * * @template Render The type of the rendered output for each form step. This can vary depending on * the framework; for example, in React, it would typically be `ReactNode`. * * @template Values A type extending `ListValues` that defines the structure of the multi-step form, * including the values handled in each phase. * * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. * * @template Params An object type defining the values accessible when rendering each form step in * the multi-step process. */ export type ListSchema = Values extends [infer First, ...infer Other] ? First extends ItemValues ? Other extends ListValues ? [ ItemSchema, ...ListSchema>, Params> ] : never : never : []; /** * Defines the structure and behavior of a condition element in a multi-step form. * * @template Render The type of the rendered output for each form step. This can vary depending on * the framework; for example, in React, it would typically be `ReactNode`. * * @template Values A type extending `CondValues` that defines the structure of the multi-step form, * including the values handled in each phase. * * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. * * @template Params An object type defining the values accessible when rendering each form step in * the multi-step process. */ export type CondSchema = { cond: { if: (inputs: Inputs) => boolean; then: ListSchema; else: ListSchema; }; }; /** * Defines the structure and behavior of a loop element in a multi-step form. * * @template Render The type of the rendered output for each form step. This can vary depending on * the framework; for example, in React, it would typically be `ReactNode`. * * @template Values A type extending `LoopValues` that defines the structure of the multi-step form, * including the values handled in each phase. * * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. * * @template Params An object type defining the values accessible when rendering each form step in * the multi-step process. */ export type LoopSchema = { loop: { while: (inputs: Inputs) => boolean; do: ListSchema; }; }; /** * Defines the structure and behavior of a switch element in a multi-step form. * * @template Render The type of the rendered output for each form step. This can vary depending on * the framework; for example, in React, it would typically be `ReactNode`. * * @template Values A type extending `SwitchValues` that defines the structure of the multi-step * form, including the values handled in each phase. * * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. * * @template Params An object type defining the values accessible when rendering each form step in * the multi-step process. */ export type SwitchSchema = { switch: { branches: SwitchBranchesSchema; default: ListSchema; }; }; type SwitchBranchesSchema = Values extends [infer First, ...infer Other] ? First extends ListValues ? Other extends ListValues[] ? [ { case: (inputs: Inputs) => boolean; then: ListSchema; }, ...SwitchBranchesSchema ] : never : never : []; /** * Defines the structure and behavior of a form element in a multi-step form. * * @template Render The type of the rendered output for each form step. This can vary depending on * the framework; for example, in React, it would typically be `ReactNode`. * * @template Values A type extending `FormValues` that defines the values of the form element. * * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. * * @template Params An object type defining the values accessible when rendering each form step in * the multi-step process. */ export type FormSchema = { form: { values: (inputs: Inputs) => { [K in keyof Values["form"]]: [Values["form"][K], PropertyKey[]]; }; render: (args: { inputs: Inputs; values: Values["form"]; params: Params; onNext: OnNext; onBack: OnBack; getFlow: GetFlow; setFlow: SetFlow; }) => Render; }; }; /** * Defines the structure and behavior of a yield element in a multi-step form. * * @template Values A type extending `YieldValues` that defines the values of the yield element. * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. */ export type YieldSchema = { yield: (inputs: Inputs) => Values["yield"]; }; /** * Defines the structure and behavior of a return element in a multi-step form. * * @template Values A type extending `ReturnValues` that defines the values of the return element. * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. */ export type ReturnSchema = { return: (inputs: Inputs) => Values["return"]; }; /** * Defines the structure and behavior of a variables element in a multi-step form. * * @template Values A type extending `VariablesValues` that defines the values of the variables element. * @template Inputs An object type representing additional values available during form execution, * beyond those generated by the multi-step form itself. */ export type VariablesSchema = { variables: (inputs: Inputs) => Values["variables"]; }; type Join = Omit & U; type ItemOutput = Values extends FormValues ? FormOutput : Values extends VariablesValues ? VariablesOutput : object; type FormOutput = Values["form"]; type VariablesOutput = Values["variables"]; export {}; //# sourceMappingURL=custom.d.ts.map