import type { ComponentType, ReactNode } from 'react' import type { ArchiveEntries } from '../content/getArchiveEntries.js' import type { BuilderFormClassNames } from '../forms/BuilderForm.js' import type { SendFormAction } from '../forms/RenderForm.js' import type { ResolveLinkHrefOptions } from '../links/resolveLinkHref.js' import type { BlockTexts } from './texts.js' import type { LibraryBlockSlug } from './types.js' import type { LinkComponent } from './ui/Anchor.js' import type { CardProps } from './ui/Card.js' import type { CMSLinkProps, ResolveLink } from './ui/CMSLink.js' import type { ContainerProps } from './ui/Container.js' import type { PartClasses } from './ui/cx.js' import type { ImageComponent, MediaProps } from './ui/Media.js' import type { SectionProps } from './ui/Section.js' import type { SectionHeaderProps } from './ui/SectionHeader.js' /** The UI primitives every library block is built from. Swap any of them with createBlockRegistry({ ui }). */ export type BlockUi = { buttonClass: (appearance?: null | string) => string Card: ComponentType CMSLink: (props: CMSLinkProps) => Promise | ReactNode Container: ComponentType Media: ComponentType Section: ComponentType SectionHeader: ComponentType } /** One line of contact details beside the contact form. */ export type ContactDetail = { href?: string; label: string; value: string } /** One testimonial as the component renders it. */ export type TestimonialItem = { heading: string; id?: null | string; media?: unknown; quote: string; rating?: null | number; text?: null | string } /** One entry card of the entry list. */ export type EntryCard = { date?: null | string; media?: unknown; text?: null | string; title: string } /** What the blocks may need from lib/content (createContentHelpers). Only resolveLink is required. */ export type BlockContent = { getEntries?: (collection: string, locale: string, page: number, perPage: number) => Promise getFormTexts?: (locale: string) => Promise getLinkOptions?: (locale: string) => Promise resolveLink: ResolveLink } /** Everything a block gets from the registry besides its data. */ export type BlockContext = { /** Contact details beside the form (from the project's company global). */ contactDetails?: (locale: string) => ContactDetail[] | Promise content: BlockContent /** Turns a collection document into an entry card. Default: title, excerpt/description, media/image, publishedAt. */ entryCard?: (doc: Record, collection: string) => EntryCard | null formClassNames?: BuilderFormClassNames /** The project's icon components by name (the names of buildFeatureGridBlock({ icons })). */ icons?: Record> /** next/image — optimized images with blur-up. Without it: a plain . */ Image?: ImageComponent /** Heading level of a block's items (cards, plans, steps), per block. Default: one below the section heading (itemHeadingLevel). */ itemHeadings?: Partial> /** Lightbox triggers on gallery images. Default true (needs ). */ lightbox: boolean /** next/link — client-side navigation for internal links. Without it: a plain . */ Link?: LinkComponent /** Turns a testimonials-collection document into an item. Default: quote, heading/author/name, text/role, media, rating. */ mapTestimonial?: (doc: Record) => null | TestimonialItem /** The first image of the leading block loads eagerly with high priority (LCP). Default true; `false` = never. */ priorityImage?: boolean richText?: { className?: string } /** The project's sendForm server action (createSubmitAction) — the contact block needs it. */ sendForm?: SendFormAction texts?: Partial>> } /** Props of every library block component: its data + locale + what the registry binds. */ export type LibraryBlockProps = { classNames?: PartClasses ctx: BlockContext /** No block before this one shows an image (createPageRoute, blockPosition). */ firstImage?: boolean isFirst?: boolean locale: string ui: BlockUi } & D