@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
55 lines (54 loc) • 3.03 kB
TypeScript
import { ComponentPropsWithRef, ComponentPropsWithoutRef, ElementType } from "react";
//#region src/utils/types.d.ts
/** Type for a a no-op function stub. */
type AnyFunction = (...args: any[]) => any;
/** Type for any number without breaking autocompletion. */
type AnyNumber = number & {};
/** Type for any string without breaking autocompletion. */
type AnyString = string & {};
/** Type of change event defaulted to input element */
type ChangeEvent<T = HTMLInputElement> = React.ChangeEvent<T>;
/** Type of change event handler defaulted to input element */
type ChangeEventHandler<T = HTMLInputElement> = React.ChangeEventHandler<T>;
type CreateContextOptions = {
/** Message displayed when context is used outside of the provider */
errorMessage?: string;
/** Accessing context outside of provider won't throw error */
isOptional?: boolean;
/** Name of the context */
name?: string;
};
/** Return value of the createContext function. */
type CreateContextReturn<T> = [React.Provider<T>, () => T];
/** Basic dictionary typing. */
type Dict<T = any> = Record<string, T>;
/** Classic application's environment names. */
type Environment = 'Prod' | 'Stag' | 'Test';
/** Type of blur/focus event defaulted to any html element */
type FocusEvent<T = HTMLElement> = React.FocusEvent<T>;
/** Type of blur/focus event handler defaulted to any html element */
type FocusEventHandler<T = HTMLElement> = React.FocusEventHandler<T>;
/** Type of keyboard event defaulted to any html element */
type KeyboardEvent<T = HTMLElement> = React.KeyboardEvent<T>;
/** Type of keyboard event handler defaulted to any html element */
type KeyboardEventHandler<T = HTMLElement> = React.KeyboardEventHandler<T>;
/** Type of mouse event defaulted to any html element */
type MouseEvent<T = HTMLElement> = React.MouseEvent<T>;
/** Type of mouse event handler defaulted to any html element */
type MouseEventHandler<T = HTMLElement> = React.MouseEventHandler<T>;
/** Merges component/element base props and custom props */
type PropsOf<C extends ElementType, Props = object> = RightJoinProps<ComponentPropsWithoutRef<C>, Props>;
/** Merges component/element base props and custom props including ref */
type RefPropsOf<C extends ElementType, Props = object> = RightJoinProps<ComponentPropsWithRef<C>, Props>;
/** Render props of component's children. */
type RenderProps<P> = React.ReactNode | ((props: P) => React.ReactNode);
/** Merges props definitions, overriding source keys */
type RightJoinProps<SourceProps, OverrideProps> = Omit<SourceProps, keyof OverrideProps> & OverrideProps;
type SortOrder = 'asc' | 'desc' | null;
type Sort<T = string> = {
key: T;
order: SortOrder;
};
//#endregion
export { AnyFunction, AnyNumber, AnyString, ChangeEvent, ChangeEventHandler, CreateContextOptions, CreateContextReturn, Dict, Environment, FocusEvent, FocusEventHandler, KeyboardEvent, KeyboardEventHandler, MouseEvent, MouseEventHandler, PropsOf, RefPropsOf, RenderProps, RightJoinProps, Sort, SortOrder };
//# sourceMappingURL=types.d.ts.map