rc-field-form
Advanced tools
Comparing version 2.1.0 to 2.2.0
import * as React from 'react'; | ||
import type { Store, FormInstance, FieldData, ValidateMessages, Callbacks } from './interface'; | ||
import type { Store, FormInstance, FieldData, ValidateMessages, Callbacks, FormRef } from './interface'; | ||
type BaseFormProps = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'children'>; | ||
@@ -21,3 +21,3 @@ type RenderProps = (values: Store, form: FormInstance) => JSX.Element | React.ReactNode; | ||
} | ||
declare const Form: React.ForwardRefRenderFunction<FormInstance, FormProps>; | ||
declare const Form: React.ForwardRefRenderFunction<FormRef, FormProps>; | ||
export default Form; |
@@ -30,2 +30,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
restProps = _objectWithoutProperties(_ref, _excluded); | ||
var nativeElementRef = React.useRef(null); | ||
var formContext = React.useContext(FormContext); | ||
@@ -48,3 +49,5 @@ | ||
React.useImperativeHandle(ref, function () { | ||
return formInstance; | ||
return _objectSpread(_objectSpread({}, formInstance), {}, { | ||
nativeElement: nativeElementRef.current | ||
}); | ||
}); | ||
@@ -132,2 +135,3 @@ | ||
return /*#__PURE__*/React.createElement(Component, _extends({}, restProps, { | ||
ref: nativeElementRef, | ||
onSubmit: function onSubmit(event) { | ||
@@ -134,0 +138,0 @@ event.preventDefault(); |
import * as React from 'react'; | ||
import { FormInstance } from './interface'; | ||
import type { FormRef, FormInstance } from './interface'; | ||
import Field from './Field'; | ||
@@ -12,3 +12,3 @@ import List from './List'; | ||
declare const InternalForm: <Values = any>(props: FormProps<Values> & { | ||
ref?: React.Ref<FormInstance<Values>>; | ||
ref?: React.Ref<FormRef<Values>>; | ||
}) => React.ReactElement; | ||
@@ -25,3 +25,3 @@ type InternalFormType = typeof InternalForm; | ||
export { Field, List, useForm, FormProvider, FieldContext, ListContext, useWatch }; | ||
export type { FormProps, FormInstance }; | ||
export type { FormProps, FormInstance, FormRef }; | ||
export default RefForm; |
@@ -198,2 +198,5 @@ import type { ReactElement } from 'react'; | ||
} | ||
export type FormRef<Values = any> = FormInstance<Values> & { | ||
nativeElement?: HTMLElement; | ||
}; | ||
export type InternalFormInstance = Omit<FormInstance, 'validateFields'> & { | ||
@@ -200,0 +203,0 @@ validateFields: InternalValidateFields; |
import * as React from 'react'; | ||
import type { Store, FormInstance, FieldData, ValidateMessages, Callbacks } from './interface'; | ||
import type { Store, FormInstance, FieldData, ValidateMessages, Callbacks, FormRef } from './interface'; | ||
type BaseFormProps = Omit<React.FormHTMLAttributes<HTMLFormElement>, 'onSubmit' | 'children'>; | ||
@@ -21,3 +21,3 @@ type RenderProps = (values: Store, form: FormInstance) => JSX.Element | React.ReactNode; | ||
} | ||
declare const Form: React.ForwardRefRenderFunction<FormInstance, FormProps>; | ||
declare const Form: React.ForwardRefRenderFunction<FormRef, FormProps>; | ||
export default Form; |
@@ -38,2 +38,3 @@ "use strict"; | ||
restProps = (0, _objectWithoutProperties2.default)(_ref, _excluded); | ||
var nativeElementRef = React.useRef(null); | ||
var formContext = React.useContext(_FormContext.default); | ||
@@ -56,3 +57,5 @@ | ||
React.useImperativeHandle(ref, function () { | ||
return formInstance; | ||
return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, formInstance), {}, { | ||
nativeElement: nativeElementRef.current | ||
}); | ||
}); | ||
@@ -140,2 +143,3 @@ | ||
return /*#__PURE__*/React.createElement(Component, (0, _extends2.default)({}, restProps, { | ||
ref: nativeElementRef, | ||
onSubmit: function onSubmit(event) { | ||
@@ -142,0 +146,0 @@ event.preventDefault(); |
import * as React from 'react'; | ||
import { FormInstance } from './interface'; | ||
import type { FormRef, FormInstance } from './interface'; | ||
import Field from './Field'; | ||
@@ -12,3 +12,3 @@ import List from './List'; | ||
declare const InternalForm: <Values = any>(props: FormProps<Values> & { | ||
ref?: React.Ref<FormInstance<Values>>; | ||
ref?: React.Ref<FormRef<Values>>; | ||
}) => React.ReactElement; | ||
@@ -25,3 +25,3 @@ type InternalFormType = typeof InternalForm; | ||
export { Field, List, useForm, FormProvider, FieldContext, ListContext, useWatch }; | ||
export type { FormProps, FormInstance }; | ||
export type { FormProps, FormInstance, FormRef }; | ||
export default RefForm; |
@@ -198,2 +198,5 @@ import type { ReactElement } from 'react'; | ||
} | ||
export type FormRef<Values = any> = FormInstance<Values> & { | ||
nativeElement?: HTMLElement; | ||
}; | ||
export type InternalFormInstance = Omit<FormInstance, 'validateFields'> & { | ||
@@ -200,0 +203,0 @@ validateFields: InternalValidateFields; |
{ | ||
"name": "rc-field-form", | ||
"version": "2.1.0", | ||
"version": "2.2.0", | ||
"description": "React Form Component", | ||
@@ -5,0 +5,0 @@ "typings": "es/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
290936
6715
159
1
1
1
13