import { type ComponentType, type PropsWithChildren } from "react"; import { type InlineContentLinkWithLocale, type ContentLinkWithLocale } from "@remkoj/optimizely-graph-client"; import { type ContentType } from "../../types.js"; import { type PropsWithContext, type PropsWithOptionalContext } from "../../context/types.js"; import { type PropsWithCmsContent } from "../cms-content/types.js"; export declare enum StructureNodeTypes { Experience = "experience", Section = "section", Row = "row", Column = "column" } export type CompositionNodeBase = { name: string | null; key: string | null; type?: string | null; template?: string | null; settings?: Array<{ key: string; value: string | number | boolean; } | null> | null; }; export type CompositionStructureNode = CompositionNodeBase & { layoutType: "experience" | "section" | "row" | "column"; nodes?: Array; }; export type CompositionComponentNode = Record> = CompositionNodeBase & { layoutType: "component"; component: E; }; export type CompositionNode = Record> = CompositionStructureNode | CompositionComponentNode; export type CompositionComponentType = ComponentType ? { node: Omit; element: DT; } : PropsWithChildren<{ node: Omit; }>>; /** * Get the props to render a leaf inside an experience * * @returns An array with the contentLink, Content Type, Node ID, Loaded Data & Layout Properties */ export type LeafPropsFactory = , LT = string>(node: CompositionComponentNode) => [ContentLinkWithLocale | InlineContentLinkWithLocale, ContentType, string | undefined, ET] | [ContentLinkWithLocale | InlineContentLinkWithLocale, ContentType, string | undefined, ET, Record]; export type NodePropsFactory = , LT = string>(node: CompositionStructureNode) => [ContentLinkWithLocale | InlineContentLinkWithLocale, Array, string | undefined, ET] | [ContentLinkWithLocale | InlineContentLinkWithLocale, Array, string | undefined, ET, Record]; export type OptimizelyCompositionProps = PropsWithOptionalContext>; /** * Allows overriding of the factory that transforms the data received from * Optimizely Graph into properties for an element. */ leafPropsFactory?: LeafPropsFactory; /** * Allows overriding of the factory that transforms the data received from * Optimizely Graph into properties for a structure node. */ nodePropsFactory?: NodePropsFactory; }>; export type BaseOptimizelyCompositionProps = PropsWithCmsContent>; export type OptimizelyCompositionComponent = ComponentType; export type OptimizelyCompositionBaseComponent = ComponentType;