import type { ReactNode } from 'react'; import type { MappedColumnStyles } from '../styles/style-mapper'; import type { MountsMap, WidgetInstanceProps } from './component-props'; /** Where this render happens. Cards skip placeholder filling in `Compose`. */ export type PageViewType = 'Preview' | 'Compose' | 'RenderedPage'; export declare const PageViewTypes: { readonly Preview: "Preview"; readonly Compose: "Compose"; readonly RenderedPage: "RenderedPage"; }; export type { WidgetInstanceProps, ComponentPropsMap, MountsMap } from './component-props'; /** * Contract for a RuleCMS component library (mirror of ComponentLibraryModule). * * `@rulecms/widget-react` never imports a concrete library; consumers register * libraries. Same here: `RuleCMSWidgetProvider.libraries` supplies modules. */ export interface ComponentLibrary { id: string; version: string; /** Component type id → entry (e.g. `r-text`). */ components: Record; } /** What a resolver knows about the render it is being asked about. */ export interface NoContainerResolverContext { /** Device-resolved attribute bag (keys still end in `-3-resolutions`). */ componentAttributes?: Record; /** Column styles about to be applied, either to a wrapper or to the card. */ styles?: MappedColumnStyles; } export type ResolveNoContainer = (context: NoContainerResolverContext) => boolean; export type ResolveRendersOwnElement = (context: NoContainerResolverContext) => boolean; export interface LibraryComponentBuildContext { /** Device-resolved attribute bag (keys still end in `-3-resolutions`). */ componentAttributes: Record; styles: MappedColumnStyles; /** Host-app classes for this column, when the renderer decided this card carries them. */ className?: string; /** * Props the embedding application supplied for this specific instance via * `RuleCMSWidget.componentProps`. Absent whenever the host addressed no * props at this column. */ widgetInstanceProps?: WidgetInstanceProps; /** * Host-supplied map of mount name → React component. Only `r-mount` * reads this. Absent in the composer, and absent whenever the host * passed no `mounts` on `RuleCMSWidget`. */ mounts?: MountsMap; /** * `Compose` means the author is looking at the canvas, so cards leave * `{{ … }}` tokens in place. Omitted renders as `RenderedPage`. */ pageViewType?: PageViewType; /** * `/`-separated column ids from the widget root to this instance. Omitted * while composing. */ columnPath?: string; /** * Nested content slot. Unshipped on the React renderer too; libraries may * honour it (accordion appends it after authored detail) when a later * platform path starts composing a subtree here. */ children?: ReactNode; } export type LibraryComponentBuilder = (context: LibraryComponentBuildContext) => ReactNode; export interface LibraryComponentEntry { id: string; builder: LibraryComponentBuilder; /** * Per-render replacement for `noContainer`. When present it is called for * every render and `noContainer` is ignored entirely. * * A component that returns `false` MUST apply the `styles` it receives to * the view it renders — no wrapper is emitted to do it for them. */ resolveNoContainer?: ResolveNoContainer; /** * When true, column box styles are applied via a wrapper rather than left * solely on the component (for inline / non-box elements). * * Used only when the entry has no `resolveNoContainer`. */ noContainer?: boolean; /** * Per-render answer to whether this card's own root can carry a * `className`. Absence defaults to `false`. */ resolveRendersOwnElement?: ResolveRendersOwnElement; } /** Consumer registration map, e.g. `{ default: sourceComponentsLibrary }`. */ export type LibraryRegistrationMap = Record; //# sourceMappingURL=component-library.d.ts.map