@appbuckets/react-ui-core
Version:
Core utilities built for AppBuckets React UI Framework
50 lines (49 loc) • 1.98 kB
TypeScript
import * as React from 'react';
import { PropsWithAs } from '../generic';
/**
* Compute the React Element Type used to render a Component.
*
* First look to get the right type is checking props or default props
* searching for `as` key.
*
* If no `as` key exists, function will use the `getDefault` function
* to compute the Element Type.
*
* getElementType will fallback to `div` element.
*
* @param Component A React Component Type
* @param userDefinedProps The Element props defined when using a Component
* @param themedProps AppBuckets UI will use themed variable, userDefinedProps will be extended with theme defined
* @param getDefault A function that must return an Element Type
*/
export declare function getElementType<P extends {} = {}>(
Component: React.ComponentType<PropsWithAs<P>>,
userDefinedProps: PropsWithAs<P>,
themedProps?: PropsWithAs<P>,
getDefault?: (props: PropsWithAs<P>) => React.ElementType | undefined
): React.FunctionComponent<any>;
/**
* Hook version of getElementType, return a memoized
* variable with component
*
* Compute the React Element Type used to render a Component.
*
* First look to get the right type is checking props or default props
* searching for `as` key.
*
* If no `as` key exists, function will use the `getDefault` function
* to compute the Element Type.
*
* getElementType will fallback to `div` element.
*
* @param Component A React Component Type
* @param userDefinedProps The Element props defined when using a Component
* @param themedProps AppBuckets UI will use themed variable, userDefinedProps will be extended with theme defined
* @param getDefault A function that must return an Element Type
*/
export declare function useElementType<P extends {} = {}>(
Component: React.ComponentType<PropsWithAs<P>>,
userDefinedProps: PropsWithAs<P>,
themedProps?: PropsWithAs<P>,
getDefault?: (props: PropsWithAs<P>) => React.ElementType | undefined
): React.FunctionComponent<any>;