import React from 'react'; import type { ElementDisplayName } from './types'; /** * @internal @unstable */ export interface Elements extends Partial> {} export const ElementsContext = React.createContext( undefined ); /** * @internal @unstable * * `ElementsProvider` provides the values contained in `ElementsContext` * to its `children`. `ElementsContext` lookup is handled directly * by `BaseElement`components returned by `defineBaseElement` and * `defineBaseElementWithRef`. * * @example * * Add `ElementsContext` aware `BaseElement` components to a Connected * Component * * ```tsx * // `BaseElement`, renders custom or default element defintion * const ViewElement = defineBaseElementWithRef({ * displayName: "View", * type: "div", * }); * * // `BaseElement` components to be provided through `ElementsContext` * interface ConnectedComponentElements { * View: typeof ViewElement; * } * * function createConnectedComponent( * elements?: T * ) { * const Provider = ({ children }: { children?: React.ReactNode }) => ( * * * * ); * * function ConnectedComponent() { * return ( * * * * ); * } * * ConnectedComponent.Provider = Provider; * * return ConnectedComponent; * } * ``` */ export function ElementsProvider({ elements, ...props }: { children?: React.ReactNode; elements?: T; }): React.JSX.Element { return ; }