chore: improves field types (#9172)

### What?
Ensures `path` is required and only present on the fields that expect it
(all fields except row).

Deprecates `useFieldComponents` and `FieldComponentsProvider` and
instead extends the RenderField component to account for all field
types. This also improves type safety within `RenderField`.

### Why?
`path` being optional just adds DX overhead and annoyance. 

### How?
Added `FieldPaths` type which is added to iterable field types. Placed
`path` back onto the ClientFieldBase type.
This commit is contained in:
Jarrod Flesch
2024-11-13 13:53:47 -05:00
committed by GitHub
parent cd95daf029
commit bcbca0e44a
68 changed files with 305 additions and 281 deletions

View File

@@ -4,22 +4,6 @@ import type { TextFieldClientComponent } from 'payload'
import { TextField } from '@payloadcms/ui'
import React from 'react'
export const MyClientFieldComponent: TextFieldClientComponent = ({
field,
indexPath,
parentPath,
parentSchemaPath,
path,
schemaPath,
}) => {
return (
<TextField
field={field}
indexPath={indexPath}
parentPath={parentPath}
parentSchemaPath={parentSchemaPath}
path={path}
schemaPath={schemaPath}
/>
)
export const MyClientFieldComponent: TextFieldClientComponent = (props) => {
return <TextField {...props} />
}