@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
37 lines (36 loc) • 1.92 kB
TypeScript
import { PropsOf, RefPropsOf } from "../utils/types.js";
import "../utils/index.js";
import { ElementType, PropsWithChildren, PropsWithoutRef, ReactElement } from "react";
//#region src/core/vui.d.ts
/**
* Component creation utility, which combines forwardRef, memo and ensures correct typing with all props included.
* Config object allows toggling memoization and providing custom 'areEqual' function.
*/
declare function vui<C extends React.ElementType, Props = object>(component: React.ForwardRefRenderFunction<any, PropsOf<C, Props>>, config?: VuiComponentConfig<C, Props>): VuiComponent<C, Props>;
/** VUI component type, which allows element props inference and extension, 'as' and 'ref'. */
type VuiComponent<C extends ElementType, Props = object> = {
<AsC extends ElementType>(props: PropsWithChildren<RefPropsOf<AsC, Props>> & {
as: AsC;
}): ReactElement<any, any> | null;
(props: RefPropsOf<C, Props>): ReactElement<any, any> | null;
defaultProps?: Partial<PropsOf<C, Props>>;
displayName?: string;
sizes?: string[];
};
/** Config for VUI component creator helper, which allows toggling memoization and 'areEqual' function. */
type VuiComponentConfig<C extends ElementType, Props = object> = {
isMemo?: boolean;
memoCompare?: (prevProps: Readonly<PropsWithChildren<PropsWithoutRef<PropsOf<C, Props>>>>, nextProps: Readonly<PropsWithChildren<PropsWithoutRef<PropsOf<C, Props>>>>) => boolean;
};
/**
* @deprecated Use FC or plain functions instead. If you need typing for HTML attributes of a given element,
* use PropsOf type, like: type MyBoxProps = PropsOf<'div', MyProps>
*/
type VC<C extends ElementType, Props = object> = {
(props: PropsOf<C, Props>): ReactElement<any, any> | null;
defaultProps?: Partial<PropsOf<C, Props>>;
displayName?: string;
};
//#endregion
export { VC, VuiComponent, VuiComponentConfig, vui as default, vui };
//# sourceMappingURL=vui.d.ts.map