Skip to content

Commit

Permalink
Update API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
JoseLion committed Jul 7, 2024
1 parent 390b61f commit 8b3143e
Show file tree
Hide file tree
Showing 56 changed files with 1,577 additions and 1,606 deletions.
10 changes: 7 additions & 3 deletions packages/core/docs/functions/ArrayField.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
Helper component for array fields with finner control over the re-renders.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

struct type of the form values

**K** *extends* `string`

the type of the path of the array field

## Parameters

**props**: [`ArrayFieldProps`](../interfaces/ArrayFieldProps.md)\<`T`, `K`\>
Expand All @@ -26,6 +30,6 @@ the array field props

`ReactElement`\<`any`, `string` \| `JSXElementConstructor`\<`any`\>\>

## Source
## Defined in

[lib/components/ArrayField.component.tsx:63](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L63)
[components/ArrayField.component.tsx:63](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L63)
10 changes: 7 additions & 3 deletions packages/core/docs/functions/Field.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@
Helper component for rendering fields with finner control over the re-renders

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

struct type of the form values

**K** *extends* `string`

the type of the path of the field

**D** = [`Optional`](../type-aliases/Optional.md)\<[`ValueByPath`](../type-aliases/ValueByPath.md)\<`T`, `K`\>\>

## Parameters
Expand All @@ -28,6 +32,6 @@ the field props

`ReactElement`\<`any`, `string` \| `JSXElementConstructor`\<`any`\>\>

## Source
## Defined in

[lib/components/Field.component.tsx:79](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/Field.component.tsx#L79)
[components/Field.component.tsx:79](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/Field.component.tsx#L79)
8 changes: 5 additions & 3 deletions packages/core/docs/functions/FormProvider.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
The form context provider component.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

struct type of the form values

## Parameters

**props**: [`FormProviderProps`](../interfaces/FormProviderProps.md)\<`T`\>
Expand All @@ -24,6 +26,6 @@ the provider component props

`ReactElement`\<`any`, `string` \| `JSXElementConstructor`\<`any`\>\>

## Source
## Defined in

[lib/Form.provider.tsx:148](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/Form.provider.tsx#L148)
[Form.provider.tsx:148](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/Form.provider.tsx#L148)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/arrayFieldOf.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Utility function which helps you create an [ArrayField](ArrayField.md) component
an specific struct type. Once you have this, the only type parameter left is
the [Path\<T\>](../type-aliases/Path.md) of the property which is an array.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -37,6 +37,6 @@ const ArrayField = arrayFieldOf<User>();
</ArrayField>
```

## Source
## Defined in

[lib/components/ArrayField.component.tsx:101](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L101)
[components/ArrayField.component.tsx:101](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L101)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/fieldOf.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Utility function which helps you create a [Field](Field.md) component of an
specific struct type. Once you have this, the only type parameters left is
the [Path\<T\>](../type-aliases/Path.md) of the property and the optional fallback type.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand Down Expand Up @@ -49,6 +49,6 @@ const Field = fieldOf<User>();
</Field>
```

## Source
## Defined in

[lib/components/Field.component.tsx:138](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/Field.component.tsx#L138)
[components/Field.component.tsx:138](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/Field.component.tsx#L138)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/noValidate.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Helper function that creates an [Adapter\<T\>](../interfaces/Adapter.md) to bypass the
form validation.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -23,6 +23,6 @@ struct type of the form values

an adapter to bypass validation

## Source
## Defined in

[lib/helpers/adapters.ts:65](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L65)
[helpers/adapters.ts:65](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L65)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/useArrayField.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A hook to handle array field in the form. It provides the array field items
to iterate over and a few helper functions to handle changes and renders on
the array.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -30,6 +30,6 @@ the path of the array field in `T`

an object containing the array items and helper array functions

## Source
## Defined in

[lib/hooks/useArrayField.ts:104](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/hooks/useArrayField.ts#L104)
[hooks/useArrayField.ts:104](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/hooks/useArrayField.ts#L104)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/useField.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ field and helper function to change its state.

If the `fallback` parameter is not set, the default value is `undefined`.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -37,6 +37,6 @@ optional default value the field should take

an object with the field value and some helper functions

## Source
## Defined in

[lib/hooks/useField.ts:39](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/hooks/useField.ts#L39)
[hooks/useField.ts:39](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/hooks/useField.ts#L39)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/useFieldValidation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
A hook to retrieve validation related states of a field.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -26,6 +26,6 @@ the path of the field in `T`

an object with validation related states

## Source
## Defined in

[lib/hooks/useFieldValidation.ts:27](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/hooks/useFieldValidation.ts#L27)
[hooks/useFieldValidation.ts:27](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/hooks/useFieldValidation.ts#L27)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/useForm.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ A hook to access the entire value of `FormCtxt<T>`. If you want just some
properties of the context, use [useFormSelector](useFormSelector.md) instead for an
increased performance and avoid unnecessary renders.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -22,6 +22,6 @@ increased performance and avoid unnecessary renders.

the entire value of the form context

## Source
## Defined in

[lib/Form.context.ts:210](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/Form.context.ts#L210)
[Form.context.ts:210](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/Form.context.ts#L210)
6 changes: 3 additions & 3 deletions packages/core/docs/functions/useFormSelector.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
A hook to select a value from the form `FormCtxt<T>`.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -28,6 +28,6 @@ a function to select a value from the context

the selected value

## Source
## Defined in

[lib/Form.context.ts:222](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/Form.context.ts#L222)
[Form.context.ts:222](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/Form.context.ts#L222)
40 changes: 14 additions & 26 deletions packages/core/docs/interfaces/Adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Validation adapter for a `T` structure. Specifies functions required for the
form validations and their hooks.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -21,10 +21,6 @@ struct type of the form values

> **required**: (`path`) => `boolean`
Should return `true` if the field in the `path` is required in the
validation schema. I.e., whenever the field cannot be `null`,
`undefined`, non-empty, etc.

#### Parameters

**path**: [`Path`](../type-aliases/Path.md)\<`T`\>
Expand All @@ -35,23 +31,18 @@ the path to check if it's requried

`boolean`

#### Source
wether a path is required or not

#### Defined in

[lib/helpers/adapters.ts:30](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L30)
[helpers/adapters.ts:30](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L30)

***

### validate()

> **validate**: (`values`) => `Promise`\<[`Result`](../type-aliases/Result.md)\<`T`, `Map`\<[`Path`](../type-aliases/Path.md)\<`T`\>, `string`\>\>\>
Should return a promise containing the `Result<S, E>` of the validation.
Where `S` represents the success and `E` the error.

If the validation success, the promise should resolve to the form values.
Otherwise, if the validation fails, the promise should resolve to a
`Map<Path<T>, string>` of the path/message for the invalid fields.

#### Parameters

**values**: `Partial`\<`T`\>
Expand All @@ -62,24 +53,19 @@ the form values to validate

`Promise`\<[`Result`](../type-aliases/Result.md)\<`T`, `Map`\<[`Path`](../type-aliases/Path.md)\<`T`\>, `string`\>\>\>

#### Source
a promise with the `Result<S, E>` of the validation

[lib/helpers/adapters.ts:42](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L42)
#### Defined in

[helpers/adapters.ts:42](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L42)

***

### validateAt()

> **validateAt**: \<`K`\>(`path`, `value`) => `Promise`\<[`Result`](../type-aliases/Result.md)\<`true`, `string`\>\>
Should return a promise containing the `Result<S, E>` of the field
validation. Where `S` represents the success and `E` the error.

If the validation success, the promise should resolve to a simple `true`.
Otherwise, if the validation fails, the promise should resolve to a
`Map<Path<T>, string>` of the path/message for the invalid fields.

#### Type parameters
#### Type Parameters

**K** *extends* `string`

Expand All @@ -97,6 +83,8 @@ the value to validate against

`Promise`\<[`Result`](../type-aliases/Result.md)\<`true`, `string`\>\>

#### Source
a promise with the `Result<S, E>` of the validation

#### Defined in

[lib/helpers/adapters.ts:55](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L55)
[helpers/adapters.ts:55](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/helpers/adapters.ts#L55)
19 changes: 9 additions & 10 deletions packages/core/docs/interfaces/ArrayFieldProps.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

The props of the [ArrayField](../functions/ArrayField.md) component.

## Type parameters
## Type Parameters

**T** *extends* [`Struct`](../type-aliases/Struct.md)

Expand All @@ -24,9 +24,6 @@ the path type of the array field

> **children**: (`props`) => `ReactNode`
The children is a function which takes the result of [useArrayField](../functions/useArrayField.md)
hook in the first argument and returns a React.js node.

#### Parameters

**props**: [`UseArrayField`](UseArrayField.md)\<[`ArrayValue`](../type-aliases/ArrayValue.md)\<`T`, `K`\>\>
Expand All @@ -37,9 +34,11 @@ render props same as the `useArrayField` hook result

`ReactNode`

#### Source
a React.js node

#### Defined in

[lib/components/ArrayField.component.tsx:42](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L42)
[components/ArrayField.component.tsx:42](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L42)

***

Expand All @@ -52,9 +51,9 @@ change if the array field value changes. This prop lets you add an
additional dependency list to that memoization, so you can add external
state changes when required.

#### Source
#### Defined in

[lib/components/ArrayField.component.tsx:49](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L49)
[components/ArrayField.component.tsx:49](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L49)

***

Expand All @@ -64,6 +63,6 @@ state changes when required.
The path to the array field in `T`.

#### Source
#### Defined in

[lib/components/ArrayField.component.tsx:53](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L53)
[components/ArrayField.component.tsx:53](https://github.com/JoseLion/lynxts/blob/main/packages/core/src/lib/components/ArrayField.component.tsx#L53)
Loading

0 comments on commit 8b3143e

Please sign in to comment.