chore: properly types cell components (#5474)
This commit is contained in:
@@ -2,6 +2,7 @@ import type { CollectionConfig } from 'payload/types'
|
||||
|
||||
import { slateEditor } from '@payloadcms/richtext-slate'
|
||||
|
||||
import { CustomCell } from '../components/CustomCell/index.js'
|
||||
import { DemoUIFieldCell } from '../components/DemoUIField/Cell.js'
|
||||
import { DemoUIField } from '../components/DemoUIField/Field.js'
|
||||
import {
|
||||
@@ -82,6 +83,15 @@ export const Posts: CollectionConfig = {
|
||||
},
|
||||
relationTo: 'posts',
|
||||
},
|
||||
{
|
||||
name: 'customCell',
|
||||
type: 'text',
|
||||
admin: {
|
||||
components: {
|
||||
Cell: CustomCell,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'sidebarField',
|
||||
type: 'text',
|
||||
|
||||
10
test/admin/components/CustomCell/index.tsx
Normal file
10
test/admin/components/CustomCell/index.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
'use client'
|
||||
import type { CellComponentProps } from 'payload/types'
|
||||
|
||||
import { useTableCell } from '@payloadcms/ui/elements/Table'
|
||||
import React from 'react'
|
||||
|
||||
export const CustomCell: React.FC<CellComponentProps> = (props) => {
|
||||
const context = useTableCell()
|
||||
return <div>{`Custom cell: ${context.cellData || 'No data'}`}</div>
|
||||
}
|
||||
Reference in New Issue
Block a user