chore: properly types cell components (#5474)

This commit is contained in:
Jacob Fletcher
2024-03-26 12:08:33 -04:00
committed by GitHub
parent 9c7e7ed8d4
commit 20b4585666
24 changed files with 93 additions and 67 deletions

View File

@@ -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',

View 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>
}