import type { GenericContext } from "../rsc.js"; import type { PropsWithChildren } from "react"; /** * Define an element as a React Component, React ExoticComponent or string name * representing a HTML Element (e.g. "div", "a", etc...), this value can be used * as first argument of React.createElement() */ export type ElementType = (React.ComponentType) | (React.ExoticComponent) | (keyof JSX.IntrinsicElements); /** * Define an element as a React Component, React ExoticComponent or string name * representing a HTML Element (e.g. "div", "a", etc...), this value can be used * as first argument of React.createElement() * * The type must support children */ export type ElementWithChildrenType = React.ComponentType | React.ExoticComponent | keyof Omit; /** * The properties type of an ElementType */ export type ElementProps = T extends keyof JSX.IntrinsicElements ? React.HTMLProps : React.ComponentProps; /** * Tests if K is a property of T - if so: it is the type of * T[K]; if not: it is equal to never */ export type PropTypeIfPropExists = K extends keyof ElementProps ? ElementProps[K] : never; /** * Tests if K is a property of T - if so: it is equal to U; * if not: it is equal to never */ export type TypeIfPropExists = K extends keyof ElementProps ? U : never; /** * Defines the type to be T or an array of T */ export type MayBeArray = T | T[]; /** * The union of property names of an Element that may receive child elements */ export type ElementChildrenProps = keyof { [P in keyof ElementProps as React.ReactElement[] extends ElementProps[P] ? P : never]: ElementProps[P]; }; export type GenericContextProps = keyof { [P in keyof ElementProps as GenericContext extends ElementProps[P] ? P : never]: ElementProps[P]; }; /** * Reserved Element properties that may not be passed to CmsContentArea wrappers, as these are auto-injected */ export type ReservedKeys = "data-epi-edit" | "data-epi-property-name" | "data-epi-property-render" | "data-epi-property-edittype" | "data-epi-block-id" | "data-displayoption" | "data-tag" | "data-component"; export type WithAs = Base & { as?: CT; children?: PropTypeIfPropExists; key: PropTypeIfPropExists; } & Omit, keyof Base>;