UNPKG

@appbuckets/react-ui-core

Version:

Core utilities built for AppBuckets React UI Framework

133 lines (132 loc) 3.77 kB
import * as React from 'react'; import { AnyObject, ShorthandMethodOptions, ShorthandedComponent, ShorthandValue, } from '@appbuckets/react-ui-core'; declare type ShorthandPropsMapper<P> = (value: ShorthandValue<P>) => Partial<P>; interface ShorthandComponentProps extends AnyObject { /** Main component content */ children?: React.ReactNode | null; /** Defined className */ className?: string; /** Component key */ key?: React.Key; /** Style to merge */ style?: React.CSSProperties; } /** * A more robust React.createElement. * It can create elements from primitive values. * * @param Component Component to Create * @param mapValueToProps Function to transform props * @param getKey Function to get key from props * @param value Value to use * @param options Options to Apply */ export declare function createShorthand<P extends ShorthandComponentProps = {}>( Component: ShorthandedComponent<P>, mapValueToProps: ShorthandPropsMapper<P>, getKey: ((props: P) => React.Key) | undefined, value: ShorthandValue<P>, options: ShorthandMethodOptions<P> ): React.ReactElement<P> | null; /** * Get a callback function to be used to easily generate * a new component based on shorthand value * * @param Component The Component to Generate * @param mapValueToProps The function to map value to props * @param getKey A function that will be used to get key */ export declare function createShorthandFactory<P>( Component: ShorthandedComponent<P>, mapValueToProps: ShorthandPropsMapper<P>, getKey?: (props: P) => React.Key ): ( value: ShorthandValue<P>, options: ShorthandMethodOptions<P> ) => React.ReactElement<P, string | React.JSXElementConstructor<any>> | null; export declare const createHTMLLabel: ( value: ShorthandValue< React.DetailedHTMLProps< React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement > >, options: ShorthandMethodOptions< React.DetailedHTMLProps< React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement > > ) => React.ReactElement< React.DetailedHTMLProps< React.LabelHTMLAttributes<HTMLLabelElement>, HTMLLabelElement >, string | React.JSXElementConstructor<any> > | null; export declare const createHTMLImage: ( value: ShorthandValue< React.DetailedHTMLProps< React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement > >, options: ShorthandMethodOptions< React.DetailedHTMLProps< React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement > > ) => React.ReactElement< React.DetailedHTMLProps< React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement >, string | React.JSXElementConstructor<any> > | null; export declare const createHTMLInput: ( value: ShorthandValue< React.DetailedHTMLProps< React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement > >, options: ShorthandMethodOptions< React.DetailedHTMLProps< React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement > > ) => React.ReactElement< React.DetailedHTMLProps< React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement >, string | React.JSXElementConstructor<any> > | null; export declare const createHTMLParagraph: ( value: ShorthandValue< React.DetailedHTMLProps< React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement > >, options: ShorthandMethodOptions< React.DetailedHTMLProps< React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement > > ) => React.ReactElement< React.DetailedHTMLProps< React.HTMLAttributes<HTMLParagraphElement>, HTMLParagraphElement >, string | React.JSXElementConstructor<any> > | null; export {};