UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

56 lines (55 loc) 2.96 kB
import type { MantineThemeComponent } from '../MantineProvider'; import type { ClassNames, PartialVarsResolver, Styles, VarsResolver } from '../styles-api'; export type DataAttributes = Record<`data-${string}`, any>; export interface FactoryPayload { props: Record<string, any>; ctx?: any; ref?: any; stylesNames?: string; vars?: any; variant?: string; staticComponents?: Record<string, any>; compound?: boolean; signature?: any; } export interface ExtendCompoundComponent<Payload extends FactoryPayload> { defaultProps?: Partial<Payload['props']> & DataAttributes; } export interface ExtendsRootComponent<Payload extends FactoryPayload> { defaultProps?: Partial<Payload['props']> & DataAttributes & { component?: any; }; classNames?: ClassNames<Payload>; styles?: Styles<Payload>; vars?: PartialVarsResolver<Payload>; } export type ExtendComponent<Payload extends FactoryPayload> = Payload['compound'] extends true ? ExtendCompoundComponent<Payload> : ExtendsRootComponent<Payload>; export type StaticComponents<Input> = Input extends Record<string, any> ? Input : Record<string, never>; export interface ThemeExtend<Payload extends FactoryPayload> { extend: (input: ExtendComponent<Payload>) => MantineThemeComponent; } export type ComponentClasses<Payload extends FactoryPayload> = { classes: Payload['stylesNames'] extends string ? Record<string, string> : never; }; export type MantineComponentStaticProperties<Payload extends FactoryPayload> = ThemeExtend<Payload> & ComponentClasses<Payload> & StaticComponents<Payload['staticComponents']> & ComponentVariablesResolver<Payload> & FactoryComponentWithProps<Payload>; export interface PlaceholderPolymorphicProps { component?: any; renderRoot?: (props: Record<string, any>) => React.ReactNode; } export type FactoryComponentWithProps<Payload extends FactoryPayload> = { withProps: (props: Partial<Payload['props']>) => React.NamedExoticComponent<Payload['props'] & React.RefAttributes<Payload['ref']> & PlaceholderPolymorphicProps>; }; export type ComponentVariablesResolver<Payload extends FactoryPayload> = Payload['vars'] extends Record<string, any> ? { varsResolver: VarsResolver<Payload>; } : {}; export type MantineComponent<Payload extends FactoryPayload> = React.NamedExoticComponent<Payload['props'] & React.RefAttributes<Payload['ref']> & { component?: any; renderRoot?: (props: Record<string, any>) => React.ReactNode; }> & MantineComponentStaticProperties<Payload>; export declare function identity<T>(value: T): T; export declare function factory<Payload extends FactoryPayload>(ui: (props: Payload['props'] & { ref?: React.Ref<Payload['ref']>; }) => React.ReactNode): MantineComponent<Payload>; export declare function genericFactory<Payload extends FactoryPayload>(ui: Payload['signature']): Payload["signature"] & MantineComponentStaticProperties<Payload> & { displayName?: string; };