From 4f041ddca90c47ec216c0877c828a1d73b7a9b0b Mon Sep 17 00:00:00 2001 From: EnyelSequeira Date: Thu, 31 Aug 2023 22:39:02 +0100 Subject: [PATCH 1/2] docs: updating docs-field-api removing old doc and updating to new properties --- docs/reference/fieldApi.md | 52 ++++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/docs/reference/fieldApi.md b/docs/reference/fieldApi.md index 0b338ef12..1de2356cc 100644 --- a/docs/reference/fieldApi.md +++ b/docs/reference/fieldApi.md @@ -26,33 +26,57 @@ An object type representing the options for a field in a form. ``` - An optional default value for the field. - ```tsx - form?: FormApi + defaultMeta?: Partial ``` - - An optional reference to the form API instance. + - An optional object with default metadata for the field. + - ```tsx - validate?: (value: TData, fieldApi: FieldApi) => ValidationError | Promise + onMount?: (formApi: FieldApi) => void ``` - - An optional validation function for the field. + - An optional function that takes a param of `formApi` which is a generic type of `TData` and `TFormData` + - ```tsx - validatePristine?: boolean + onChange?: ValidateFn ``` - - An optional flag indicating whether to validate the field when it is pristine (untouched). + - An optional property that takes a `ValidateFn` which is a generic of `TData` and `TFormData` + - ```tsx - defaultMeta?: Partial + onChangeAsync?: ValidateAsyncFn ``` - - An optional object with default metadata for the field. + - An optional property similar to `onChange` but async validation + + - ```tsx - validateOn?: ValidationCause + onChangeAsyncDebounceMs?: number ``` - - An optional string indicating when to perform field validation. + - An optional number to represent how long the `onChangeAsync` should wait before running + - If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds + - ```tsx - validateAsyncOn?: ValidationCause + onBlur?: ValidateFn ``` - - An optional string indicating when to perform async field validation. + - An optional function, when that run when subscribing to blur event of input + - ```tsx - validateAsyncDebounceMs?: number + onBlurAsync?: ValidateAsyncFn + ``` + - An optional function that takes a `ValidateFn` which is a generic of `TData` and `TFormData` happens async + + ```tsx + onBlurAsyncDebounceMs?: number + ``` + - An optional number to represent how long the `onBlurAsyncDebounceMs` should wait before running + - If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds + + ```tsx + onSubmitAsync?: number ``` - - If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds. + - If set to a number larger than 0, will debounce the async validation event by this length of time in milliseconds + + + + + ### `ValidationCause` From d504c61c925b5355bdcd25095c16fc5bbea7338c Mon Sep 17 00:00:00 2001 From: EnyelSequeira Date: Thu, 31 Aug 2023 22:52:16 +0100 Subject: [PATCH 2/2] docs: field-api removing disclaimer about API shift --- docs/reference/fieldApi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/fieldApi.md b/docs/reference/fieldApi.md index 1de2356cc..69ba5bbba 100644 --- a/docs/reference/fieldApi.md +++ b/docs/reference/fieldApi.md @@ -5,7 +5,7 @@ title: Field API ### Creating a new FieldApi Instance -> Some of these docs may be inaccurate due to an API shift in `0.11.0`. If you're interested in helping us fix these issues, please [join our Discord](https://tlinz.com/discord) and reach out in the `#form` channel. + Normally, you will not need to create a new `FieldApi` instance directly. Instead, you will use a framework hook/function like `useField` or `createField` to create a new instance for you that utilizes your frameworks reactivity model. However, if you need to create a new instance manually, you can do so by calling the `new FieldApi` constructor.