@mage-ui/components 1.0.198 → 1.0.199
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/dist/components/forms/multi-step/MultiForm.d.mts +4 -1
- package/dist/components/forms/multi-step/MultiForm.d.mts.map +1 -1
- package/dist/components/forms/multi-step/MultiForm.mjs +1 -1
- package/dist/components/forms/multi-step/MultiForm.mjs.map +1 -1
- package/dist/components/forms/multi-step/parser/Form.mjs +1 -1
- package/dist/components/forms/multi-step/parser/Form.mjs.map +1 -1
- package/dist/components/forms/multi-step/parser/Schema.d.mts +2 -1
- package/dist/components/forms/multi-step/parser/Schema.d.mts.map +1 -1
- package/dist/components/forms/multi-step/parser/Schema.mjs +1 -1
- package/dist/components/forms/multi-step/parser/Schema.mjs.map +1 -1
- package/dist/components/forms/multi-step/parser/Schemas.mjs +1 -1
- package/dist/components/forms/multi-step/parser/Schemas.mjs.map +1 -1
- package/dist/components/forms/multi-step/parser/utils/use-local-storage.d.mts +10 -0
- package/dist/components/forms/multi-step/parser/utils/use-local-storage.d.mts.map +1 -0
- package/dist/components/forms/multi-step/parser/utils/use-local-storage.mjs +1 -1
- package/dist/components/forms/multi-step/parser/utils/use-local-storage.mjs.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { StepperProps } from "../../navigations/stepper/Stepper.mjs";
|
|
2
|
+
import { StorageType } from "./parser/utils/use-local-storage.mjs";
|
|
2
3
|
import { SchemaProps } from "./parser/Schema.mjs";
|
|
3
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
5
|
import { ComponentType, ReactNode } from "react";
|
|
@@ -27,6 +28,7 @@ type MultiFormProps = {
|
|
|
27
28
|
multiForm?: string;
|
|
28
29
|
};
|
|
29
30
|
stepperProps?: Omit<StepperProps, 'children' | 'active'>;
|
|
31
|
+
storage?: StorageType;
|
|
30
32
|
};
|
|
31
33
|
declare const MultiForm: (({
|
|
32
34
|
name,
|
|
@@ -34,7 +36,8 @@ declare const MultiForm: (({
|
|
|
34
36
|
Success,
|
|
35
37
|
Loading,
|
|
36
38
|
classNames,
|
|
37
|
-
stepperProps
|
|
39
|
+
stepperProps,
|
|
40
|
+
storage
|
|
38
41
|
}: MultiFormProps) => react_jsx_runtime0.JSX.Element) & {
|
|
39
42
|
Step: {
|
|
40
43
|
(_props: MultiFormStepProps): null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiForm.d.mts","names":[],"sources":["../../../../src/components/forms/multi-step/MultiForm.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MultiForm.d.mts","names":[],"sources":["../../../../src/components/forms/multi-step/MultiForm.tsx"],"mappings":";;;;;;;KAkBY,kBAAA;EACV,IAAA;EACA,KAAA,EAAO,WAAA;EACP,KAAA;EACA,WAAA;EACA,QAAA,EAAU,WAAA;AAAA;AAAA,cAGC,aAAA;EAAA,SAAyB,kBAAA;;;KAG1B,cAAA;EACV,IAAA;EACA,QAAA,EAAU,SAAA;EACV,OAAA,EAAS,aAAA;IAAgB,MAAA,EAAQ,OAAA;EAAA;EACjC,OAAA,EAAS,aAAA;EACT,UAAA;IAAe,IAAA;IAAe,SAAA;EAAA;EAC9B,YAAA,GAAe,IAAA,CAAK,YAAA;EACpB,OAAA,GAAU,WAAA;AAAA;AAAA,cAyEC,SAAA;EAAS,IAAA;EAAA,QAAA;EAAA,OAAA;EAAA,OAAA;EAAA,UAAA;EAAA,YAAA;EAAA;AAAA,GA9DnB,cAAA,KAAc,kBAAA,CAAA,GAAA,CAAA,OAAA;;aArBqB,kBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{NoSsr as e}from"../../misc/no-ssr/NoSsr.mjs";import{PendingErrorsProvider as t}from"./PendingErrorsContext.mjs";import{
|
|
1
|
+
import{NoSsr as e}from"../../misc/no-ssr/NoSsr.mjs";import{PendingErrorsProvider as t}from"./PendingErrorsContext.mjs";import{Schemas as n}from"./parser/Schemas.mjs";import{getStorage as r}from"./parser/utils/use-local-storage.mjs";import{jsx as i}from"react/jsx-runtime";import{Children as a,isValidElement as o,useCallback as s,useState as c}from"react";import{Formity as l}from"@formity/react";const u=e=>null;u.displayName=`MultiForm.Step`;const d=Object.assign(({name:d,children:f,Success:p,Loading:m,classNames:h,stepperProps:g,storage:_})=>{let v=r(_),[y,b]=c(!1),[x,S]=c({}),C=s(e=>{S({...x,...e})},[x]),w=s(()=>{b(!0)},[]);if(y)return v.set(d,{}),i(p,{values:x});let T=new n(d,v,a.toArray(f).filter(o).map(e=>{if(e.type!==u)throw Error(`MultiForm children must be MultiForm.Step elements`);let t=e.props;return{name:t.name,rules:t.rules,label:t.label,description:t.description,form:t.children}}),v.get(d,{}),h,g),E=T.getFieldToStepMapping();return i(e,{fallback:i(m,{}),children:i(t,{fieldToStepMap:E,children:i(l,{schema:T.toRender(),params:{fields:x,onChange:C,onSubmit:w},initialState:T.currentState(),onReturn:w})})})},{Step:u});export{d as MultiForm,u as MultiFormStep};
|
|
2
2
|
//# sourceMappingURL=MultiForm.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiForm.mjs","names":[],"sources":["../../../../src/components/forms/multi-step/MultiForm.tsx"],"sourcesContent":["import {\n Children,\n type ComponentType,\n isValidElement,\n type ReactNode,\n useCallback,\n useState,\n} from 'react';\n\nimport { Formity } from '@formity/react';\n\nimport { NoSsr } from '../../misc/no-ssr/NoSsr';\nimport type { StepperProps } from '../../navigations/stepper/Stepper';\nimport { PendingErrorsProvider } from './PendingErrorsContext';\nimport type { SchemaProps } from './parser/Schema';\nimport { Schemas } from './parser/Schemas';\nimport {
|
|
1
|
+
{"version":3,"file":"MultiForm.mjs","names":[],"sources":["../../../../src/components/forms/multi-step/MultiForm.tsx"],"sourcesContent":["import {\n Children,\n type ComponentType,\n isValidElement,\n type ReactNode,\n useCallback,\n useState,\n} from 'react';\n\nimport { Formity } from '@formity/react';\n\nimport { NoSsr } from '../../misc/no-ssr/NoSsr';\nimport type { StepperProps } from '../../navigations/stepper/Stepper';\nimport { PendingErrorsProvider } from './PendingErrorsContext';\nimport type { SchemaProps } from './parser/Schema';\nimport { Schemas } from './parser/Schemas';\nimport { getStorage, type StorageType } from './parser/utils/use-local-storage';\n\nexport type MultiFormStepProps = {\n name: string;\n rules: SchemaProps['rules'];\n label?: string;\n description?: string;\n children: SchemaProps['form'];\n};\n\nexport const MultiFormStep = (_props: MultiFormStepProps) => null;\nMultiFormStep.displayName = 'MultiForm.Step';\n\nexport type MultiFormProps = {\n name: string;\n children: ReactNode;\n Success: ComponentType<{ values: Partial<unknown> }>;\n Loading: ComponentType;\n classNames?: { root?: string; multiForm?: string };\n stepperProps?: Omit<StepperProps, 'children' | 'active'>;\n storage?: StorageType;\n};\n\nconst MultiFormBase = ({\n name,\n children,\n Success,\n Loading,\n classNames,\n stepperProps,\n storage,\n}: MultiFormProps) => {\n const store = getStorage(storage);\n const [submitted, setSubmitted] = useState(false);\n const [fields, setFields] = useState({});\n\n const onChange = useCallback(\n (values: Partial<unknown>) => {\n setFields({ ...fields, ...values });\n },\n [fields],\n );\n\n const onSubmit = useCallback(() => {\n setSubmitted(true);\n }, []);\n\n if (submitted) {\n store.set(name, {});\n return <Success values={fields} />;\n }\n\n const schema: SchemaProps[] = Children.toArray(children)\n .filter(isValidElement)\n .map((element) => {\n if (element.type !== MultiFormStep) {\n throw new Error('MultiForm children must be MultiForm.Step elements');\n }\n const props = element.props as MultiFormStepProps;\n return {\n name: props.name,\n rules: props.rules,\n label: props.label,\n description: props.description,\n form: props.children,\n };\n });\n\n const schemaObj = new Schemas(\n name,\n store,\n schema,\n store.get(name, {}),\n classNames,\n stepperProps,\n );\n\n const fieldToStepMap = schemaObj.getFieldToStepMapping();\n\n return (\n <NoSsr fallback={<Loading />}>\n <PendingErrorsProvider fieldToStepMap={fieldToStepMap}>\n <Formity\n schema={schemaObj.toRender()}\n params={{ fields, onChange, onSubmit }}\n initialState={schemaObj.currentState()}\n onReturn={onSubmit}\n />\n </PendingErrorsProvider>\n </NoSsr>\n );\n};\n\nexport const MultiForm = Object.assign(MultiFormBase, { Step: MultiFormStep });\n"],"mappings":"6YA0BA,MAAa,EAAiB,GAA+B,KAC7D,EAAc,YAAc,iBAkF5B,MAAa,EAAY,OAAO,QAtET,CACrB,OACA,WACA,UACA,UACA,aACA,eACA,aACoB,CACpB,IAAM,EAAQ,EAAW,EAAQ,CAC3B,CAAC,EAAW,GAAgB,EAAS,GAAM,CAC3C,CAAC,EAAQ,GAAa,EAAS,EAAE,CAAC,CAElC,EAAW,EACd,GAA6B,CAC5B,EAAU,CAAE,GAAG,EAAQ,GAAG,EAAQ,CAAC,EAErC,CAAC,EAAO,CACT,CAEK,EAAW,MAAkB,CACjC,EAAa,GAAK,EACjB,EAAE,CAAC,CAEN,GAAI,EAEF,OADA,EAAM,IAAI,EAAM,EAAE,CAAC,CACZ,EAAC,EAAD,CAAS,OAAQ,EAAU,CAAA,CAmBpC,IAAM,EAAY,IAAI,EACpB,EACA,EAlB4B,EAAS,QAAQ,EAAS,CACrD,OAAO,EAAe,CACtB,IAAK,GAAY,CAChB,GAAI,EAAQ,OAAS,EACnB,MAAU,MAAM,qDAAqD,CAEvE,IAAM,EAAQ,EAAQ,MACtB,MAAO,CACL,KAAM,EAAM,KACZ,MAAO,EAAM,MACb,MAAO,EAAM,MACb,YAAa,EAAM,YACnB,KAAM,EAAM,SACb,EACD,CAMF,EAAM,IAAI,EAAM,EAAE,CAAC,CACnB,EACA,EACD,CAEK,EAAiB,EAAU,uBAAuB,CAExD,OACE,EAAC,EAAD,CAAO,SAAU,EAAC,EAAD,EAAW,CAAA,UAC1B,EAAC,EAAD,CAAuC,0BACrC,EAAC,EAAD,CACE,OAAQ,EAAU,UAAU,CAC5B,OAAQ,CAAE,SAAQ,WAAU,WAAU,CACtC,aAAc,EAAU,cAAc,CACtC,SAAU,EACV,CAAA,CACoB,CAAA,CAClB,CAAA,EAI0C,CAAE,KAAM,EAAe,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Step as e}from"../Step.mjs";import{extractFields as t}from"./utils/extract-fields.mjs";import{extractValues as n}from"./utils/extract-values.mjs";import{replaceValues as r}from"./utils/replace-in-state.mjs";import{
|
|
1
|
+
import{Step as e}from"../Step.mjs";import{extractFields as t}from"./utils/extract-fields.mjs";import{extractValues as n}from"./utils/extract-values.mjs";import{replaceValues as r}from"./utils/replace-in-state.mjs";import{jsx as i}from"react/jsx-runtime";import{z as a}from"zod";function o(e){if(e instanceof a.ZodObject)return e.shape;if(e instanceof a.ZodPipe)return o(e.in);let t=e.unwrap;return typeof t==`function`?o(t.call(e)):{}}var s=class{values;name;store;rules;component;step;states;steps;classNames;stepperProps;constructor(e,n,r,i,a,o,s,c){this.values=t(r.rules),this.name=e,this.store=n,this.rules=r.rules,this.component=r.form,this.step=i,this.states=a,this.steps=o,this.classNames=s,this.stepperProps=c,this.fixState(this.states.states[i.current-1].state)}toRender(){return{form:{values:()=>this.values,render:({values:t,getState:a,setState:o,onBack:s,onNext:c,params:{fields:l,onChange:u},...d})=>{let f=n(this.states.states[this.step.current-1].state),p=Object.assign({},f,l);return i(e,{values:p,rules:this.rules,step:this.step,steps:this.steps,getState:a,setState:o,onNext:e=>{let t=Object.assign({},p,e);u(t),this.updateState(a(t),this.step.current+1),c(t)},onBack:()=>{u(p),this.updateState(a(p),this.step.current-1),s(p)},onWatch:e=>{u(e),this.states=r(this.states,e),o(this.fixState(this.states.states[this.step.current-1].state)),this.store.set(this.name,this.states)},onEnter:()=>{this.updateState(a(p),this.step.current)},goTo:e=>{this.updateState(a(p),e),o(this.fixState(this.states.states[e-1].state))},Component:this.component,classNames:this.classNames,stepperProps:this.stepperProps,...d})}}}}fixState(e){if(e.inputs.list.length===0)return e;let t=Number.parseInt(Object.keys(e.inputs.list)[this.step.current-1]);Number.isNaN(t)&&(t=(this.step.current-1)*2);let n=o(this.rules),r=Object.keys(n||{}),i=Object.keys(e.inputs.list[t]||[]);for(let n of r)i.includes(n)||(e.inputs.list[t]===void 0&&(e.inputs.list[t]={}),e.inputs.list[t][n]={data:{data:void 0}});return e}updateState(e,t){t<=this.states.states.length&&t>0&&(this.states.step=t,this.states.states[this.step.current-1].state=e,this.store.set(this.name,this.states))}getRules(){return this.rules}};export{s as Form};
|
|
2
2
|
//# sourceMappingURL=Form.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.mjs","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Form.tsx"],"sourcesContent":["import { z } from 'zod';\n\nimport type { GetState, OnBack, OnNext, SetState, State } from '@formity/react';\n\nimport { Step, type Props as StepProps } from '../Step';\nimport type { SchemaProps } from './Schema';\nimport { extractFields } from './utils/extract-fields';\nimport { extractValues } from './utils/extract-values';\nimport { replaceValues } from './utils/replace-in-state';\nimport {
|
|
1
|
+
{"version":3,"file":"Form.mjs","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Form.tsx"],"sourcesContent":["import { z } from 'zod';\n\nimport type { GetState, OnBack, OnNext, SetState, State } from '@formity/react';\n\nimport { Step, type Props as StepProps } from '../Step';\nimport type { SchemaProps } from './Schema';\nimport { extractFields } from './utils/extract-fields';\nimport { extractValues } from './utils/extract-values';\nimport { replaceValues } from './utils/replace-in-state';\nimport type { MultiFormStorage } from './utils/use-local-storage';\n\ntype ZodSchema = z.ZodType;\n\nfunction getSchemaShape(schema: ZodSchema): Record<string, z.ZodTypeAny> {\n if (schema instanceof z.ZodObject) {\n return schema.shape;\n }\n if (schema instanceof z.ZodPipe) {\n return getSchemaShape(schema.in as ZodSchema);\n }\n const unwrap = (schema as { unwrap?: () => ZodSchema }).unwrap;\n if (typeof unwrap === 'function') {\n return getSchemaShape(unwrap.call(schema));\n }\n return {};\n}\n\ntype Render = {\n values: object;\n getState: GetState;\n setState: SetState;\n onBack: OnBack;\n onNext: OnNext;\n params: {\n fields: Record<string, unknown>;\n onChange: (values: Record<string, unknown>) => void;\n };\n};\n\nexport type StatesProps = {\n state: State;\n check: ZodSchema;\n};\n\nexport type States = {\n step: number;\n states: StatesProps[];\n};\n\nexport class Form {\n private values;\n private name;\n private store;\n private rules: ZodSchema;\n private component;\n private step;\n private states;\n private steps;\n private classNames;\n private stepperProps;\n\n constructor(\n name: string,\n store: MultiFormStorage,\n schema: SchemaProps,\n step: { current: number; total: number },\n states: States,\n steps: { label: string; description?: string }[],\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ) {\n this.values = extractFields(schema.rules);\n this.name = name;\n this.store = store;\n this.rules = schema.rules;\n this.component = schema.form;\n this.step = step;\n this.states = states;\n this.steps = steps;\n this.classNames = classNames;\n this.stepperProps = stepperProps;\n this.fixState(this.states.states[step.current - 1].state);\n }\n\n toRender() {\n return {\n form: {\n values: () => this.values,\n render: ({\n values,\n getState,\n setState,\n onBack,\n onNext,\n params: { fields, onChange },\n ...props\n }: Render) => {\n const realValues = extractValues(\n this.states.states[this.step.current - 1].state,\n );\n const formValues = Object.assign({}, realValues, fields);\n\n return (\n <Step\n values={formValues}\n rules={this.rules}\n step={this.step}\n steps={this.steps}\n getState={getState}\n setState={setState}\n onNext={(nextValues?: object) => {\n const merged = Object.assign({}, formValues, nextValues);\n onChange(merged);\n this.updateState(getState(merged), this.step.current + 1);\n onNext(merged);\n }}\n onBack={() => {\n onChange(formValues);\n this.updateState(getState(formValues), this.step.current - 1);\n onBack(formValues);\n }}\n onWatch={(val: Record<string, unknown>) => {\n onChange(val);\n this.states = replaceValues(this.states, val);\n setState(\n this.fixState(\n this.states.states[this.step.current - 1].state,\n ),\n );\n this.store.set(this.name, this.states);\n }}\n onEnter={() => {\n this.updateState(getState(formValues), this.step.current);\n }}\n goTo={(step: number) => {\n this.updateState(getState(formValues), step);\n setState(this.fixState(this.states.states[step - 1].state));\n }}\n Component={this.component}\n classNames={this.classNames}\n stepperProps={this.stepperProps}\n {...props}\n />\n );\n },\n },\n };\n }\n\n private fixState(state: State) {\n if ((state.inputs.list as []).length === 0) {\n return state;\n }\n\n let formIndex = Number.parseInt(\n Object.keys(state.inputs.list)[this.step.current - 1],\n );\n if (Number.isNaN(formIndex)) {\n formIndex = (this.step.current - 1) * 2;\n }\n\n const shape = getSchemaShape(this.rules);\n\n const keys = Object.keys(shape || {});\n const fields = Object.keys(state.inputs.list[formIndex] || []);\n for (const key of keys) {\n if (!fields.includes(key)) {\n if (state.inputs.list[formIndex] === undefined) {\n state.inputs.list[formIndex] = {};\n }\n\n (\n state.inputs.list[formIndex] as Record<\n string,\n { data: { data: unknown } }\n >\n )[key] = {\n data: { data: undefined },\n };\n }\n }\n\n return state;\n }\n\n private updateState(state: State, step: number) {\n if (step <= this.states.states.length && step > 0) {\n this.states.step = step;\n this.states.states[this.step.current - 1].state = state;\n this.store.set(this.name, this.states);\n }\n }\n\n getRules() {\n return this.rules;\n }\n}\n"],"mappings":"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"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Props } from "../Step.mjs";
|
|
2
|
+
import { MultiFormStorage } from "./utils/use-local-storage.mjs";
|
|
2
3
|
import { States } from "./Form.mjs";
|
|
3
4
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
5
|
import { ComponentType } from "react";
|
|
@@ -38,7 +39,7 @@ type SchemaProps = {
|
|
|
38
39
|
declare class Schema {
|
|
39
40
|
private form;
|
|
40
41
|
private yield;
|
|
41
|
-
constructor(name: string, schema: SchemaProps, step: {
|
|
42
|
+
constructor(name: string, store: MultiFormStorage, schema: SchemaProps, step: {
|
|
42
43
|
current: number;
|
|
43
44
|
total: number;
|
|
44
45
|
}, states: States, steps: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.d.mts","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Schema.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Schema.d.mts","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Schema.ts"],"mappings":";;;;;;;;;KAUY,eAAA;EACV,MAAA;EACA,IAAA;EACA,UAAA;EACA,GAAA;AAAA;AAAA,KAGU,kBAAA;EACV,aAAA;EACA,KAAA,EAAO,CAAA,CAAE,OAAA;EACT,IAAA;IAAQ,OAAA;IAAiB,KAAA;EAAA;EACzB,aAAA,GAAgB,MAAA;EAChB,OAAA,IAAW,QAAA,EAAU,eAAA;EACrB,QAAA,EAAU,QAAA;EACV,QAAA,EAAU,QAAA;EACV,MAAA,EAAQ,MAAA;EACR,MAAA,EAAQ,MAAA;EACR,IAAA,GAAO,IAAA;EACP,OAAA,GAAU,MAAA,EAAQ,MAAA;AAAA;AAAA,KAGR,WAAA;EACV,IAAA;EACA,KAAA,EAAO,CAAA,CAAE,OAAA;EACT,IAAA,EAAM,aAAA,CAAc,kBAAA;EACpB,KAAA;EACA,WAAA;AAAA;AAAA,cAGW,MAAA;EAAA,QACH,IAAA;EAAA,QACA,KAAA;cAGN,IAAA,UACA,KAAA,EAAO,gBAAA,EACP,MAAA,EAAQ,WAAA,EACR,IAAA;IAAQ,OAAA;IAAiB,KAAA;EAAA,GACzB,MAAA,EAAQ,MAAA,EACR,KAAA;IAAS,KAAA;IAAe,WAAA;EAAA,KACxB,UAAA,GAAa,KAAA,gBACb,YAAA,GAAe,KAAA;EAejB,QAAA,CAAA,GAAQ,CAAA,CAAA,OAAA,mBAAA,CAAA,CAAA,IAAA,CAAA,iBAAA;EAIR,QAAA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Form as e}from"./Form.mjs";import{Yield as t}from"./Yield.mjs";var n=class{form;yield;constructor(n,r,i,a,o,s,c){this.form=new e(n,r,i,a,o,s,c),this.yield=new t}getRules(){return this.form.getRules()}toRender(){return[this.form.toRender(),this.yield.toRender()]}};export{n as Schema};
|
|
1
|
+
import{Form as e}from"./Form.mjs";import{Yield as t}from"./Yield.mjs";var n=class{form;yield;constructor(n,r,i,a,o,s,c,l){this.form=new e(n,r,i,a,o,s,c,l),this.yield=new t}getRules(){return this.form.getRules()}toRender(){return[this.form.toRender(),this.yield.toRender()]}};export{n as Schema};
|
|
2
2
|
//# sourceMappingURL=Schema.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schema.mjs","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Schema.ts"],"sourcesContent":["import type { ComponentType } from 'react';\nimport type { z } from 'zod';\n\nimport type { GetState, OnBack, OnNext, SetState } from '@formity/react';\n\nimport type { Props as StepProps } from '../Step';\nimport { Form, type States } from './Form';\nimport { Yield } from './Yield';\n\nexport type RequestResponse = {\n status: number;\n data: unknown;\n redirected: boolean;\n url: string;\n};\n\nexport type MultiStepFormProps = {\n defaultValues: object;\n rules: z.ZodType;\n step: { current: number; total: number };\n initialErrors?: Record<string, string>;\n onError?: (response: RequestResponse) => void;\n getState: GetState;\n setState: SetState;\n onBack: OnBack;\n onNext: OnNext;\n goTo: (step: number) => void;\n onWatch: (values: Record<string, unknown>) => void;\n};\n\nexport type SchemaProps = {\n name: string;\n rules: z.ZodType;\n form: ComponentType<MultiStepFormProps>;\n label?: string;\n description?: string;\n};\n\nexport class Schema {\n private form: Form;\n private yield: Yield;\n\n constructor(\n name: string,\n schema: SchemaProps,\n step: { current: number; total: number },\n states: States,\n steps: { label: string; description?: string }[],\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ) {\n this.form = new Form(\n name,\n schema,\n step,\n states,\n steps,\n classNames,\n stepperProps,\n );\n this.yield = new Yield();\n }\n\n getRules() {\n return this.form.getRules();\n }\n\n toRender() {\n return [this.form.toRender(), this.yield.toRender()];\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Schema.mjs","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Schema.ts"],"sourcesContent":["import type { ComponentType } from 'react';\nimport type { z } from 'zod';\n\nimport type { GetState, OnBack, OnNext, SetState } from '@formity/react';\n\nimport type { Props as StepProps } from '../Step';\nimport { Form, type States } from './Form';\nimport type { MultiFormStorage } from './utils/use-local-storage';\nimport { Yield } from './Yield';\n\nexport type RequestResponse = {\n status: number;\n data: unknown;\n redirected: boolean;\n url: string;\n};\n\nexport type MultiStepFormProps = {\n defaultValues: object;\n rules: z.ZodType;\n step: { current: number; total: number };\n initialErrors?: Record<string, string>;\n onError?: (response: RequestResponse) => void;\n getState: GetState;\n setState: SetState;\n onBack: OnBack;\n onNext: OnNext;\n goTo: (step: number) => void;\n onWatch: (values: Record<string, unknown>) => void;\n};\n\nexport type SchemaProps = {\n name: string;\n rules: z.ZodType;\n form: ComponentType<MultiStepFormProps>;\n label?: string;\n description?: string;\n};\n\nexport class Schema {\n private form: Form;\n private yield: Yield;\n\n constructor(\n name: string,\n store: MultiFormStorage,\n schema: SchemaProps,\n step: { current: number; total: number },\n states: States,\n steps: { label: string; description?: string }[],\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ) {\n this.form = new Form(\n name,\n store,\n schema,\n step,\n states,\n steps,\n classNames,\n stepperProps,\n );\n this.yield = new Yield();\n }\n\n getRules() {\n return this.form.getRules();\n }\n\n toRender() {\n return [this.form.toRender(), this.yield.toRender()];\n }\n}\n"],"mappings":"sEAuCA,IAAa,EAAb,KAAoB,CAClB,KACA,MAEA,YACE,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACA,KAAK,KAAO,IAAI,EACd,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACD,CACD,KAAK,MAAQ,IAAI,EAGnB,UAAW,CACT,OAAO,KAAK,KAAK,UAAU,CAG7B,UAAW,CACT,MAAO,CAAC,KAAK,KAAK,UAAU,CAAE,KAAK,MAAM,UAAU,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Result as e}from"./Result.mjs";import{Schema as t}from"./Schema.mjs";import{z as n}from"zod";function r(e){if(e instanceof n.ZodObject)return e.shape;if(e instanceof n.ZodPipe)return r(e.in);let t=e.unwrap;return typeof t==`function`?r(t.call(e)):{}}var i=class i{schemas;states;fieldToStepMap;constructor(e,t,n,r,a){i.validateSchema(
|
|
1
|
+
import{Result as e}from"./Result.mjs";import{Schema as t}from"./Schema.mjs";import{z as n}from"zod";function r(e){if(e instanceof n.ZodObject)return e.shape;if(e instanceof n.ZodPipe)return r(e.in);let t=e.unwrap;return typeof t==`function`?r(t.call(e)):{}}var i=class i{schemas;states;fieldToStepMap;constructor(e,t,n,r,a,o){i.validateSchema(n),this.fieldToStepMap=i.buildFieldToStepMapping(n),this.states=i.getState(n,r);let s=n.map(e=>({label:e.label??e.name,description:e.description}));this.schemas=i.createSchemas(e,t,n,this.states,s,a,o)}static validateSchema(e){if(e.length===0)throw Error(`Schema must have at least one step`)}static getState(e,t){let n=[];if(Object.keys(t).length===0){let t=0;for(let r of e)n.push({state:{points:Array.from({length:++t},(e,t)=>({path:[{type:`list`,slot:t}],values:{}})),inputs:{type:`list`,list:[]}},check:r.rules});return{step:1,states:n}}return t}static createSchemas(e,n,r,a,o,s,c){let l,u=r.reduce((i,u,d)=>u.name===`summary`?(l=u,i):(i.push(new t(e,n,u,{current:d+1,total:r.length},a,o,s,c)),i),[]);return l!==void 0&&u.push(i.getSummary(e,n,u,l.form,{current:r.length,total:r.length},a,o,s,c)),u}static getSummary(e,i,a,o,s,c,l,u,d){return new t(e,i,{name:`summary`,rules:a.reduce((e,t)=>{let i=r(t.getRules());return n.object({...e.shape,...i})},n.object({})),form:o},s,c,l,u,d)}static buildFieldToStepMapping(e){let t={};return e.forEach((e,n)=>{if(e.name===`summary`)return;let i=r(e.rules);for(let e of Object.keys(i))e in t||(t[e]=n+1)}),t}getFieldToStepMapping(){return this.fieldToStepMap}currentState(){return this.states.states[this.states.step-1].state}toRender(){let t=this.schemas.flatMap(e=>e.toRender());return t.push(new e().toRender()),t}};export{i as Schemas};
|
|
2
2
|
//# sourceMappingURL=Schemas.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Schemas.mjs","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Schemas.ts"],"sourcesContent":["import type { ComponentType } from 'react';\nimport { z } from 'zod';\n\nimport type { Schema as FormitySchema, Values } from '@formity/react';\n\nimport type { Props as StepProps } from '../Step';\nimport type { States, StatesProps } from './Form';\nimport { Result } from './Result';\nimport { type MultiStepFormProps, Schema, type SchemaProps } from './Schema';\n\ntype ZodSchema = z.ZodType;\n\nfunction getSchemaShape(schema: ZodSchema): Record<string, z.ZodTypeAny> {\n if (schema instanceof z.ZodObject) {\n return schema.shape;\n }\n if (schema instanceof z.ZodPipe) {\n return getSchemaShape(schema.in as ZodSchema);\n }\n const unwrap = (schema as { unwrap?: () => ZodSchema }).unwrap;\n if (typeof unwrap === 'function') {\n return getSchemaShape(unwrap.call(schema));\n }\n return {};\n}\n\nexport class Schemas {\n private schemas: Schema[];\n private states: States;\n private fieldToStepMap: Record<string, number>;\n\n constructor(\n name: string,\n schemas: SchemaProps[],\n initialState: States,\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ) {\n Schemas.validateSchema(schemas);\n this.fieldToStepMap = Schemas.buildFieldToStepMapping(schemas);\n this.states = Schemas.getState(schemas, initialState);\n const steps = schemas.map((schema) => ({\n label: schema.label ?? schema.name,\n description: schema.description,\n }));\n this.schemas = Schemas.createSchemas(\n name,\n schemas,\n this.states,\n steps,\n classNames,\n stepperProps,\n );\n }\n\n private static validateSchema(schemas: SchemaProps[]): void {\n if (schemas.length === 0) {\n throw new Error('Schema must have at least one step');\n }\n }\n\n private static getState(\n schemas: SchemaProps[],\n initialState: States,\n ): States {\n const arrStates: StatesProps[] = [];\n if (Object.keys(initialState).length === 0) {\n let i = 0;\n for (const schema of schemas) {\n arrStates.push({\n state: {\n points: Array.from({ length: ++i }, (_, index) => ({\n path: [{ type: 'list', slot: index }],\n values: {},\n })),\n inputs: { type: 'list', list: [] },\n },\n check: schema.rules,\n });\n }\n return {\n step: 1,\n states: arrStates,\n };\n }\n return initialState;\n }\n\n private static createSchemas(\n name: string,\n schemas: SchemaProps[],\n states: States,\n steps: { label: string; description?: string }[],\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ): Schema[] {\n let summary: SchemaProps | undefined;\n const formitySchemas = schemas.reduce<Schema[]>((acc, schema, index) => {\n if (schema.name === 'summary') {\n summary = schema;\n return acc;\n }\n acc.push(\n new Schema(\n name,\n schema,\n { current: index + 1, total: schemas.length },\n states,\n steps,\n classNames,\n stepperProps,\n ),\n );\n return acc;\n }, []);\n if (summary !== undefined) {\n formitySchemas.push(\n Schemas.getSummary(\n name,\n formitySchemas,\n summary.form,\n {\n current: schemas.length,\n total: schemas.length,\n },\n states,\n steps,\n classNames,\n stepperProps,\n ),\n );\n }\n\n return formitySchemas;\n }\n\n private static getSummary(\n name: string,\n schemas: Schema[],\n form: ComponentType<MultiStepFormProps>,\n step: { current: number; total: number },\n states: States,\n steps: { label: string; description?: string }[],\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ): Schema {\n const rules = schemas.reduce(\n (acc: z.ZodObject<{ [key: string]: z.ZodTypeAny }>, schema: Schema) => {\n const schemaShape = getSchemaShape(schema.getRules());\n return z.object({\n ...acc.shape,\n ...schemaShape,\n });\n },\n z.object({}),\n );\n\n return new Schema(\n name,\n {\n name: 'summary',\n rules,\n form,\n },\n step,\n states,\n steps,\n classNames,\n stepperProps,\n );\n }\n\n private static buildFieldToStepMapping(\n schemas: SchemaProps[],\n ): Record<string, number> {\n const mapping: Record<string, number> = {};\n schemas.forEach((schema, index) => {\n if (schema.name === 'summary') return;\n const shape = getSchemaShape(schema.rules);\n for (const key of Object.keys(shape)) {\n if (!(key in mapping)) mapping[key] = index + 1;\n }\n });\n return mapping;\n }\n\n getFieldToStepMapping(): Record<string, number> {\n return this.fieldToStepMap;\n }\n\n currentState() {\n const state = this.states.states[this.states.step - 1].state;\n return state;\n }\n\n toRender() {\n const render: object[] = this.schemas.flatMap((schema) => {\n return schema.toRender();\n });\n render.push(new Result().toRender());\n return render as FormitySchema<\n Values,\n Record<string, unknown>,\n Record<string, unknown>\n >;\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Schemas.mjs","names":[],"sources":["../../../../../src/components/forms/multi-step/parser/Schemas.ts"],"sourcesContent":["import type { ComponentType } from 'react';\nimport { z } from 'zod';\n\nimport type { Schema as FormitySchema, Values } from '@formity/react';\n\nimport type { Props as StepProps } from '../Step';\nimport type { States, StatesProps } from './Form';\nimport { Result } from './Result';\nimport { type MultiStepFormProps, Schema, type SchemaProps } from './Schema';\nimport type { MultiFormStorage } from './utils/use-local-storage';\n\ntype ZodSchema = z.ZodType;\n\nfunction getSchemaShape(schema: ZodSchema): Record<string, z.ZodTypeAny> {\n if (schema instanceof z.ZodObject) {\n return schema.shape;\n }\n if (schema instanceof z.ZodPipe) {\n return getSchemaShape(schema.in as ZodSchema);\n }\n const unwrap = (schema as { unwrap?: () => ZodSchema }).unwrap;\n if (typeof unwrap === 'function') {\n return getSchemaShape(unwrap.call(schema));\n }\n return {};\n}\n\nexport class Schemas {\n private schemas: Schema[];\n private states: States;\n private fieldToStepMap: Record<string, number>;\n\n constructor(\n name: string,\n store: MultiFormStorage,\n schemas: SchemaProps[],\n initialState: States,\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ) {\n Schemas.validateSchema(schemas);\n this.fieldToStepMap = Schemas.buildFieldToStepMapping(schemas);\n this.states = Schemas.getState(schemas, initialState);\n const steps = schemas.map((schema) => ({\n label: schema.label ?? schema.name,\n description: schema.description,\n }));\n this.schemas = Schemas.createSchemas(\n name,\n store,\n schemas,\n this.states,\n steps,\n classNames,\n stepperProps,\n );\n }\n\n private static validateSchema(schemas: SchemaProps[]): void {\n if (schemas.length === 0) {\n throw new Error('Schema must have at least one step');\n }\n }\n\n private static getState(\n schemas: SchemaProps[],\n initialState: States,\n ): States {\n const arrStates: StatesProps[] = [];\n if (Object.keys(initialState).length === 0) {\n let i = 0;\n for (const schema of schemas) {\n arrStates.push({\n state: {\n points: Array.from({ length: ++i }, (_, index) => ({\n path: [{ type: 'list', slot: index }],\n values: {},\n })),\n inputs: { type: 'list', list: [] },\n },\n check: schema.rules,\n });\n }\n return {\n step: 1,\n states: arrStates,\n };\n }\n return initialState;\n }\n\n private static createSchemas(\n name: string,\n store: MultiFormStorage,\n schemas: SchemaProps[],\n states: States,\n steps: { label: string; description?: string }[],\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ): Schema[] {\n let summary: SchemaProps | undefined;\n const formitySchemas = schemas.reduce<Schema[]>((acc, schema, index) => {\n if (schema.name === 'summary') {\n summary = schema;\n return acc;\n }\n acc.push(\n new Schema(\n name,\n store,\n schema,\n { current: index + 1, total: schemas.length },\n states,\n steps,\n classNames,\n stepperProps,\n ),\n );\n return acc;\n }, []);\n if (summary !== undefined) {\n formitySchemas.push(\n Schemas.getSummary(\n name,\n store,\n formitySchemas,\n summary.form,\n {\n current: schemas.length,\n total: schemas.length,\n },\n states,\n steps,\n classNames,\n stepperProps,\n ),\n );\n }\n\n return formitySchemas;\n }\n\n private static getSummary(\n name: string,\n store: MultiFormStorage,\n schemas: Schema[],\n form: ComponentType<MultiStepFormProps>,\n step: { current: number; total: number },\n states: States,\n steps: { label: string; description?: string }[],\n classNames?: StepProps['classNames'],\n stepperProps?: StepProps['stepperProps'],\n ): Schema {\n const rules = schemas.reduce(\n (acc: z.ZodObject<{ [key: string]: z.ZodTypeAny }>, schema: Schema) => {\n const schemaShape = getSchemaShape(schema.getRules());\n return z.object({\n ...acc.shape,\n ...schemaShape,\n });\n },\n z.object({}),\n );\n\n return new Schema(\n name,\n store,\n {\n name: 'summary',\n rules,\n form,\n },\n step,\n states,\n steps,\n classNames,\n stepperProps,\n );\n }\n\n private static buildFieldToStepMapping(\n schemas: SchemaProps[],\n ): Record<string, number> {\n const mapping: Record<string, number> = {};\n schemas.forEach((schema, index) => {\n if (schema.name === 'summary') return;\n const shape = getSchemaShape(schema.rules);\n for (const key of Object.keys(shape)) {\n if (!(key in mapping)) mapping[key] = index + 1;\n }\n });\n return mapping;\n }\n\n getFieldToStepMapping(): Record<string, number> {\n return this.fieldToStepMap;\n }\n\n currentState() {\n const state = this.states.states[this.states.step - 1].state;\n return state;\n }\n\n toRender() {\n const render: object[] = this.schemas.flatMap((schema) => {\n return schema.toRender();\n });\n render.push(new Result().toRender());\n return render as FormitySchema<\n Values,\n Record<string, unknown>,\n Record<string, unknown>\n >;\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/forms/multi-step/parser/utils/use-local-storage.d.ts
|
|
2
|
+
type StorageType = 'localStorage' | 'sessionStorage';
|
|
3
|
+
declare const getStorage: (type?: StorageType) => {
|
|
4
|
+
set: (key: string, value: object) => void;
|
|
5
|
+
get: (key: string, defaultValue?: object | undefined) => any;
|
|
6
|
+
};
|
|
7
|
+
type MultiFormStorage = ReturnType<typeof getStorage>;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { MultiFormStorage, StorageType };
|
|
10
|
+
//# sourceMappingURL=use-local-storage.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-local-storage.d.mts","names":[],"sources":["../../../../../../src/components/forms/multi-step/parser/utils/use-local-storage.ts"],"mappings":";KAAY,WAAA;AAAA,cAEC,UAAA,GAAc,IAAA,GAAM,WAAA;qBACd,KAAA;qBAKA,YAAA;AAAA;AAAA,KAUP,gBAAA,GAAmB,UAAA,QAAkB,UAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={set:(
|
|
1
|
+
const e=(e=`localStorage`)=>({set:(t,n)=>{globalThis[e]!==void 0&&globalThis[e].setItem(t,JSON.stringify(n))},get:(t,n=void 0)=>{try{let r=globalThis[e].getItem(t);return r?JSON.parse(r):n}catch{return n}}});export{e as getStorage};
|
|
2
2
|
//# sourceMappingURL=use-local-storage.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-local-storage.mjs","names":[],"sources":["../../../../../../src/components/forms/multi-step/parser/utils/use-local-storage.ts"],"sourcesContent":["export const
|
|
1
|
+
{"version":3,"file":"use-local-storage.mjs","names":[],"sources":["../../../../../../src/components/forms/multi-step/parser/utils/use-local-storage.ts"],"sourcesContent":["export type StorageType = 'localStorage' | 'sessionStorage';\n\nexport const getStorage = (type: StorageType = 'localStorage') => ({\n set: (key: string, value: object) => {\n if (typeof globalThis[type] !== 'undefined') {\n globalThis[type].setItem(key, JSON.stringify(value));\n }\n },\n get: (key: string, defaultValue: object | undefined = undefined) => {\n try {\n const value = globalThis[type].getItem(key);\n return value ? JSON.parse(value) : defaultValue;\n } catch (_) {\n return defaultValue;\n }\n },\n});\n\nexport type MultiFormStorage = ReturnType<typeof getStorage>;\n"],"mappings":"AAEA,MAAa,GAAc,EAAoB,kBAAoB,CACjE,KAAM,EAAa,IAAkB,CACxB,WAAW,KAAU,QAC9B,WAAW,GAAM,QAAQ,EAAK,KAAK,UAAU,EAAM,CAAC,EAGxD,KAAM,EAAa,EAAmC,IAAA,KAAc,CAClE,GAAI,CACF,IAAM,EAAQ,WAAW,GAAM,QAAQ,EAAI,CAC3C,OAAO,EAAQ,KAAK,MAAM,EAAM,CAAG,OACzB,CACV,OAAO,IAGZ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mage-ui/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.199",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [],
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"rimraf": "^6.1.3",
|
|
26
26
|
"tsdown": "^0.21.4",
|
|
27
27
|
"typescript": "^5.9.3",
|
|
28
|
-
"@mage-ui/preset": "1.0.
|
|
28
|
+
"@mage-ui/preset": "1.0.199",
|
|
29
29
|
"@mage-ui/styled-system": "1.0.8"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|