{"version":3,"file":"NativeForm.mjs","names":[],"sources":["../../../../../../../react-form/src/components/NativeForm.tsx"],"sourcesContent":["\"use client\";\n\nimport React, { forwardRef, useImperativeHandle } from \"react\";\nimport { FormContext } from \"../contexts/FormContext\";\nimport { StandardSchemaV1 } from \"../standard-schema/types\";\nimport { FormInterface, FormProps } from \"../types\";\nimport { useFormEngine } from \"./useFormEngine\";\n\n/**\n * Generic call signature preserving schema inference and `ref` support.\n */\ntype NativeFormComponent = <\n  Schema extends StandardSchemaV1 | undefined = undefined,\n>(\n  props: FormProps<Schema> & { ref?: React.Ref<FormInterface> }\n) => React.ReactElement | null;\n\n/**\n * React Native form. Renders no host element by default (just a Fragment) so it\n * does not depend on `react-native` being installed; pass a `component` prop\n * (e.g. `View`) to wrap children with a host view.\n *\n * Same engine, context, hooks, validation, and value collection as the web\n * `Form`. Submission is programmatic only — call `form.submit()`.\n */\nexport const NativeForm = forwardRef(function NativeForm(\n  props: FormProps<any>,\n  ref: React.Ref<FormInterface>\n) {\n  const { engine } = useFormEngine(props, (formEngine) =>\n    formEngine.handleSubmit()\n  );\n\n  useImperativeHandle(ref, () => engine, [engine]);\n\n  const {\n    onError: _onError,\n    onSubmit: _onSubmit,\n    component: Component,\n    children,\n    ignoreEmptyValues: _ignoreEmptyValues,\n    defaultValue: _defaultValue,\n    values: _values,\n    schema: _schema,\n    validateOn: _validateOn,\n    focusFirstError: _focusFirstError,\n    id: _id,\n    ...otherProps\n  } = props;\n\n  const content = Component ? (\n    <Component\n      ref={(node: any) => {\n        engine.formElement = node;\n      }}\n      {...otherProps}\n    >\n      {children}\n    </Component>\n  ) : (\n    <>{children}</>\n  );\n\n  return <FormContext.Provider value={engine}>{content}</FormContext.Provider>;\n}) as unknown as NativeFormComponent;\n"],"mappings":";;;;;;;;;;;;;;;;AAyBA,MAAa,aAAa,WAAW,SAAS,WAC5C,OACA,KACA;CACA,MAAM,EAAE,WAAW,cAAc,QAAQ,eACvC,WAAW,aAAa,CAC1B;CAEA,oBAAoB,WAAW,QAAQ,CAAC,MAAM,CAAC;CAE/C,MAAM,EACJ,SAAS,UACT,UAAU,WACV,WAAW,WACX,UACA,mBAAmB,oBACnB,cAAc,eACd,QAAQ,SACR,QAAQ,SACR,YAAY,aACZ,iBAAiB,kBACjB,IAAI,KACJ,GAAG,eACD;CAEJ,MAAM,UAAU,YACd,oBAAC,WAAD;EACE,MAAM,SAAc;GAClB,OAAO,cAAc;EACvB;EACA,GAAI;EAEH;CACQ,KAEX,gCAAG,SAAW;CAGhB,OAAO,oBAAC,YAAY,UAAb;EAAsB,OAAO;YAAS;CAA8B;AAC7E,CAAC"}