Skip to content

Commit

Permalink
fix: adds path to server field component prop types (payloadcms#10330)
Browse files Browse the repository at this point in the history
### What?
`path` was missing in server component prop types.

### How?
Adds a BaseFieldServerProps for each field type that accepts takes
`path` as a prop.
  • Loading branch information
JarrodMFlesch authored Jan 3, 2025
1 parent 3847718 commit e97c43e
Show file tree
Hide file tree
Showing 19 changed files with 147 additions and 47 deletions.
8 changes: 6 additions & 2 deletions packages/payload/src/admin/fields/Array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ type ArrayFieldBaseClientProps = {
readonly validate?: ArrayFieldValidation
} & FieldPaths

type ArrayFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type ArrayFieldClientProps = ArrayFieldBaseClientProps &
ClientFieldBase<ArrayFieldClientWithoutType>

export type ArrayFieldServerProps = ServerFieldBase<ArrayField, ArrayFieldClientWithoutType>
export type ArrayFieldServerProps = ArrayFieldBaseServerProps &
ServerFieldBase<ArrayField, ArrayFieldClientWithoutType>

export type ArrayFieldServerComponent = FieldServerComponent<
ArrayField,
ArrayFieldClientWithoutType
ArrayFieldClientWithoutType,
ArrayFieldBaseServerProps
>

export type ArrayFieldClientComponent = FieldClientComponent<
Expand Down
8 changes: 6 additions & 2 deletions packages/payload/src/admin/fields/Blocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@ type BlocksFieldBaseClientProps = {
readonly validate?: BlocksFieldValidation
} & FieldPaths

type BlocksFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type BlocksFieldClientProps = BlocksFieldBaseClientProps &
ClientFieldBase<BlocksFieldClientWithoutType>

export type BlocksFieldServerProps = ServerFieldBase<BlocksField, BlocksFieldClientWithoutType>
export type BlocksFieldServerProps = BlocksFieldBaseServerProps &
ServerFieldBase<BlocksField, BlocksFieldClientWithoutType>

export type BlocksFieldServerComponent = FieldServerComponent<
BlocksField,
BlocksFieldClientWithoutType
BlocksFieldClientWithoutType,
BlocksFieldBaseServerProps
>

export type BlocksFieldClientComponent = FieldClientComponent<
Expand Down
12 changes: 7 additions & 5 deletions packages/payload/src/admin/fields/Checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -28,17 +29,18 @@ type CheckboxFieldBaseClientProps = {
readonly validate?: CheckboxFieldValidation
}

type CheckboxFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type CheckboxFieldClientProps = CheckboxFieldBaseClientProps &
ClientFieldBase<CheckboxFieldClientWithoutType>

export type CheckboxFieldServerProps = ServerFieldBase<
CheckboxField,
CheckboxFieldClientWithoutType
>
export type CheckboxFieldServerProps = CheckboxFieldBaseServerProps &
ServerFieldBase<CheckboxField, CheckboxFieldClientWithoutType>

export type CheckboxFieldServerComponent = FieldServerComponent<
CheckboxField,
CheckboxFieldClientWithoutType
CheckboxFieldClientWithoutType,
CheckboxFieldBaseServerProps
>

export type CheckboxFieldClientComponent = FieldClientComponent<
Expand Down
12 changes: 10 additions & 2 deletions packages/payload/src/admin/fields/Code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -26,12 +27,19 @@ type CodeFieldBaseClientProps = {
readonly validate?: CodeFieldValidation
}

type CodeFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type CodeFieldClientProps = ClientFieldBase<CodeFieldClientWithoutType> &
CodeFieldBaseClientProps

export type CodeFieldServerProps = ServerFieldBase<CodeField, CodeFieldClientWithoutType>
export type CodeFieldServerProps = CodeFieldBaseServerProps &
ServerFieldBase<CodeField, CodeFieldClientWithoutType>

export type CodeFieldServerComponent = FieldServerComponent<CodeField, CodeFieldClientWithoutType>
export type CodeFieldServerComponent = FieldServerComponent<
CodeField,
CodeFieldClientWithoutType,
CodeFieldBaseServerProps
>

export type CodeFieldClientComponent = FieldClientComponent<
CodeFieldClientWithoutType,
Expand Down
12 changes: 10 additions & 2 deletions packages/payload/src/admin/fields/Date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -23,12 +24,19 @@ type DateFieldBaseClientProps = {
readonly validate?: DateFieldValidation
}

type DateFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type DateFieldClientProps = ClientFieldBase<DateFieldClientWithoutType> &
DateFieldBaseClientProps

export type DateFieldServerProps = ServerFieldBase<DateField, DateFieldClientWithoutType>
export type DateFieldServerProps = DateFieldBaseServerProps &
ServerFieldBase<DateField, DateFieldClientWithoutType>

export type DateFieldServerComponent = FieldServerComponent<DateField, DateFieldClientWithoutType>
export type DateFieldServerComponent = FieldServerComponent<
DateField,
DateFieldClientWithoutType,
DateFieldBaseServerProps
>

export type DateFieldClientComponent = FieldClientComponent<
DateFieldClientWithoutType,
Expand Down
9 changes: 7 additions & 2 deletions packages/payload/src/admin/fields/Email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -23,14 +24,18 @@ type EmailFieldBaseClientProps = {
readonly validate?: EmailFieldValidation
}

type EmailFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type EmailFieldClientProps = ClientFieldBase<EmailFieldClientWithoutType> &
EmailFieldBaseClientProps

export type EmailFieldServerProps = ServerFieldBase<EmailField, EmailFieldClientWithoutType>
export type EmailFieldServerProps = EmailFieldBaseServerProps &
ServerFieldBase<EmailField, EmailFieldClientWithoutType>

export type EmailFieldServerComponent = FieldServerComponent<
EmailField,
EmailFieldClientWithoutType
EmailFieldClientWithoutType,
EmailFieldBaseServerProps
>

export type EmailFieldClientComponent = FieldClientComponent<
Expand Down
8 changes: 6 additions & 2 deletions packages/payload/src/admin/fields/Group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@ import type {

type GroupFieldClientWithoutType = MarkOptional<GroupFieldClient, 'type'>

type GroupFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type GroupFieldBaseClientProps = FieldPaths

export type GroupFieldClientProps = ClientFieldBase<GroupFieldClientWithoutType> &
GroupFieldBaseClientProps

export type GroupFieldServerProps = ServerFieldBase<GroupField, GroupFieldClientWithoutType>
export type GroupFieldServerProps = GroupFieldBaseServerProps &
ServerFieldBase<GroupField, GroupFieldClientWithoutType>

export type GroupFieldServerComponent = FieldServerComponent<
GroupField,
GroupFieldClientWithoutType
GroupFieldClientWithoutType,
GroupFieldBaseServerProps
>

export type GroupFieldClientComponent = FieldClientComponent<
Expand Down
12 changes: 10 additions & 2 deletions packages/payload/src/admin/fields/JSON.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -23,12 +24,19 @@ type JSONFieldBaseClientProps = {
readonly validate?: JSONFieldValidation
}

type JSONFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type JSONFieldClientProps = ClientFieldBase<JSONFieldClientWithoutType> &
JSONFieldBaseClientProps

export type JSONFieldServerProps = ServerFieldBase<JSONField, JSONFieldClientWithoutType>
export type JSONFieldServerProps = JSONFieldBaseServerProps &
ServerFieldBase<JSONField, JSONFieldClientWithoutType>

export type JSONFieldServerComponent = FieldServerComponent<JSONField, JSONFieldClientWithoutType>
export type JSONFieldServerComponent = FieldServerComponent<
JSONField,
JSONFieldClientWithoutType,
JSONFieldBaseServerProps
>

export type JSONFieldClientComponent = FieldClientComponent<
JSONFieldClientWithoutType,
Expand Down
11 changes: 9 additions & 2 deletions packages/payload/src/admin/fields/Join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -21,12 +22,18 @@ type JoinFieldBaseClientProps = {
readonly path: string
}

type JoinFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type JoinFieldClientProps = ClientFieldBase<JoinFieldClientWithoutType> &
JoinFieldBaseClientProps

export type JoinFieldServerProps = ServerFieldBase<JoinField>
export type JoinFieldServerProps = JoinFieldBaseServerProps & ServerFieldBase<JoinField>

export type JoinFieldServerComponent = FieldServerComponent<JoinField>
export type JoinFieldServerComponent = FieldServerComponent<
JoinField,
JoinFieldClientWithoutType,
JoinFieldBaseServerProps
>

export type JoinFieldClientComponent = FieldClientComponent<
JoinFieldClientWithoutType,
Expand Down
9 changes: 7 additions & 2 deletions packages/payload/src/admin/fields/Number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -24,14 +25,18 @@ type NumberFieldBaseClientProps = {
readonly validate?: NumberFieldValidation
}

type NumberFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type NumberFieldClientProps = ClientFieldBase<NumberFieldClientWithoutType> &
NumberFieldBaseClientProps

export type NumberFieldServerProps = ServerFieldBase<NumberField, NumberFieldClientWithoutType>
export type NumberFieldServerProps = NumberFieldBaseServerProps &
ServerFieldBase<NumberField, NumberFieldClientWithoutType>

export type NumberFieldServerComponent = FieldServerComponent<
NumberField,
NumberFieldClientWithoutType
NumberFieldClientWithoutType,
NumberFieldBaseServerProps
>

export type NumberFieldClientComponent = FieldClientComponent<
Expand Down
9 changes: 7 additions & 2 deletions packages/payload/src/admin/fields/Point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -23,14 +24,18 @@ type PointFieldBaseClientProps = {
readonly validate?: PointFieldValidation
}

type PointFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type PointFieldClientProps = ClientFieldBase<PointFieldClientWithoutType> &
PointFieldBaseClientProps

export type PointFieldServerProps = ServerFieldBase<PointField, PointFieldClientWithoutType>
export type PointFieldServerProps = PointFieldBaseServerProps &
ServerFieldBase<PointField, PointFieldClientWithoutType>

export type PointFieldServerComponent = FieldServerComponent<
PointField,
PointFieldClientWithoutType
PointFieldClientWithoutType,
PointFieldBaseServerProps
>

export type PointFieldClientComponent = FieldClientComponent<
Expand Down
9 changes: 7 additions & 2 deletions packages/payload/src/admin/fields/Radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -29,14 +30,18 @@ type RadioFieldBaseClientProps = {
readonly value?: string
}

type RadioFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type RadioFieldClientProps = ClientFieldBase<RadioFieldClientWithoutType> &
RadioFieldBaseClientProps

export type RadioFieldServerProps = ServerFieldBase<RadioField, RadioFieldClientWithoutType>
export type RadioFieldServerProps = RadioFieldBaseServerProps &
ServerFieldBase<RadioField, RadioFieldClientWithoutType>

export type RadioFieldServerComponent = FieldServerComponent<
RadioField,
RadioFieldClientWithoutType
RadioFieldClientWithoutType,
RadioFieldBaseServerProps
>

export type RadioFieldClientComponent = FieldClientComponent<
Expand Down
12 changes: 7 additions & 5 deletions packages/payload/src/admin/fields/Relationship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -23,17 +24,18 @@ type RelationshipFieldBaseClientProps = {
readonly validate?: RelationshipFieldValidation
}

type RelationshipFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type RelationshipFieldClientProps = ClientFieldBase<RelationshipFieldClientWithoutType> &
RelationshipFieldBaseClientProps

export type RelationshipFieldServerProps = ServerFieldBase<
RelationshipField,
RelationshipFieldClientWithoutType
>
export type RelationshipFieldServerProps = RelationshipFieldBaseServerProps &
ServerFieldBase<RelationshipField, RelationshipFieldClientWithoutType>

export type RelationshipFieldServerComponent = FieldServerComponent<
RelationshipField,
RelationshipFieldClientWithoutType
RelationshipFieldClientWithoutType,
RelationshipFieldBaseServerProps
>

export type RelationshipFieldClientComponent = FieldClientComponent<
Expand Down
12 changes: 7 additions & 5 deletions packages/payload/src/admin/fields/RichText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { FieldErrorClientComponent, FieldErrorServerComponent } from '../fo
import type {
ClientFieldBase,
FieldClientComponent,
FieldPaths,
FieldServerComponent,
ServerFieldBase,
} from '../forms/Field.js'
Expand All @@ -31,21 +32,22 @@ type RichTextFieldBaseClientProps<
readonly validate?: RichTextFieldValidation
}

type RichTextFieldBaseServerProps = Pick<FieldPaths, 'path'>

export type RichTextFieldClientProps<
TValue extends object = any,
TAdapterProps = any,
TExtraProperties = object,
> = ClientFieldBase<RichTextFieldClientWithoutType<TValue, TAdapterProps, TExtraProperties>> &
RichTextFieldBaseClientProps<TValue, TAdapterProps, TExtraProperties>

export type RichTextFieldServerProps = ServerFieldBase<
RichTextField,
RichTextFieldClientWithoutType
>
export type RichTextFieldServerProps = RichTextFieldBaseServerProps &
ServerFieldBase<RichTextField, RichTextFieldClientWithoutType>

export type RichTextFieldServerComponent = FieldServerComponent<
RichTextField,
RichTextFieldClientWithoutType
RichTextFieldClientWithoutType,
RichTextFieldBaseServerProps
>

export type RichTextFieldClientComponent = FieldClientComponent<
Expand Down
Loading

0 comments on commit e97c43e

Please sign in to comment.