import { RecordContextProvider, RecordRepresentation, useListContext, } from "ra-core"; import { Badge } from "@/components/ui/badge"; /** * Renders a horizontal list of records from a ListContext, displaying each as a badge. * * This component is used inside ArrayField, ReferenceArrayField, or ReferenceManyField to display * records in a compact inline format. By default, it renders each record with its record representation. * * @see {@link https://marmelab.com/shadcn-admin-kit/docs/singlefieldlist/ SingleFieldList documentation} * * @example * import { * Show, * RecordField, * TextField, * ReferenceArrayField, * SingleFieldList, * } from '@/components/admin'; * * const PostShow = () => ( * *
* * * * * * * * *
*
* ); */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export const SingleFieldList = ({ children, render, className, }: { children?: React.ReactNode; render?: (record: RecordType, index: number) => React.ReactNode; className?: string; }) => { const { data } = useListContext(); return (
{data?.map((record, index) => ( {render ? render(record, index) : children || } ))}
); }; const DefaultChildren = () => ( );