UNPKG

@prismicio/react

Version:

React components and hooks to fetch and present Prismic content

68 lines (67 loc) 1.9 kB
import { JSXMapSerializer } from "./PrismicRichText.js"; import { TableField, TableFieldBody, TableFieldBodyRow, TableFieldDataCell, TableFieldHead, TableFieldHeadRow, TableFieldHeaderCell } from "@prismicio/client"; import { ComponentType, FC, ReactNode } from "react"; //#region src/PrismicTable.d.ts type TableComponents = { table?: ComponentType<{ table: TableField<"filled">; children: ReactNode; }>; thead?: ComponentType<{ head: TableFieldHead; children: ReactNode; }>; tbody?: ComponentType<{ body: TableFieldBody; children: ReactNode; }>; tr?: ComponentType<{ row: TableFieldHeadRow | TableFieldBodyRow; children: ReactNode; }>; th?: ComponentType<{ cell: TableFieldHeaderCell; children: ReactNode; }>; td?: ComponentType<{ cell: TableFieldDataCell; children: ReactNode; }>; }; /** Props for `<PrismicTable>`. */ type PrismicTableProps = { /** The Prismic table field to render. */field: TableField; /** * An object that maps a table block to a React component. * * @example * A map serializer. * * ```jsx * { * table: ({children}) => <table>{children}</table> * thead: ({children}) => <thead>{children}</thead> * } * ``` */ components?: JSXMapSerializer & TableComponents; /** * The value to be rendered when the field is empty. If a fallback is not given, `null` will be * rendered. */ fallback?: ReactNode; }; /** * Renders content from a Prismic table field as React components. * * @example * ```tsx * <PrismicTable field={slice.primary.pricing_table} />; * ``` * * @see Learn how to style tables and customize table element components: {@link https://prismic.io/docs/fields/table} */ declare const PrismicTable: FC<PrismicTableProps>; //#endregion export { PrismicTable, PrismicTableProps }; //# sourceMappingURL=PrismicTable.d.ts.map