import React from 'react'; import { Attrs, DataAttributes, ExecutionContext, ExecutionProps, Interpolation, IStyledComponent, IStyledComponentFactory, KnownTarget, NoInfer, Runtime, StyledOptions, StyledTarget, Styles, SubsetOnly } from '../types'; /** * for types a and b, if b shares a field with a, mark a's field as optional */ type OptionalIntersection = { [K in Extract]?: A[K]; }; type AttrsResult = T extends (...args: any) => infer P ? P : T; type ExtractAttrsTarget> = P['as'] extends KnownTarget ? P['as'] : DefaultTarget; /** * If attrs type is a function (no type provided, inferring from usage), extract the return value * and merge it with the existing type to hole-punch any required fields that are satisfied as * a result of running attrs. Otherwise if we have a definite type then union the base props * with the passed attr type to capture any intended overrides. */ type PropsSatisfiedByAttrs> = Omit & OptionalIntersection & Partial>; /** * Rejects an attr factory function argument (T) if it returns any properties not defined in Props. */ type StrictAttrFactory = T extends ((props: ExecutionContext & Props) => infer TResult) ? TResult extends SubsetOnly & ExecutionProps & DataAttributes & React.AriaAttributes)> ? (props: ExecutionContext & Props) => TResult : never : never; export interface Styled, OuterProps extends object = object, OuterStatics extends object = object, RuntimeInjectedProps extends ExecutionProps = object> { (initialStyles: Styles>, ...interpolations: Interpolation>[]): // @ts-expect-error KnownTarget is a subset of StyledTarget IStyledComponent, OuterProps & Props> & OuterStatics & Statics; /** * This is a chainable method that attaches some props to a styled component. * @param props An object containing prop values that will be merged into the rest of the component's props * @argument Props Additional props being injected in `props` */ attrs & ExecutionProps & DataAttributes & React.AriaAttributes & NoInfer = Partial & ExecutionProps & DataAttributes & React.AriaAttributes & NoInfer>(props: PropValues & SubsetOnly & ExecutionProps & DataAttributes & React.AriaAttributes & NoInfer>): Styled, OuterStatics, Omit & PropValues>; /** * This is a chainable method that attaches some props to a styled component. * @param propFactory A function that receives the props that are passed into the component and computes a value, that is then going to be merged into the existing component props. * @argument Props Additional props being returned by `propFactory` */ attrs any) = (...args: any[]) => any, TTarget extends StyledTarget = ExtractAttrsTarget, Target>>(propFactory: Factory & StrictAttrFactory>): Styled, OuterStatics, Omit> & AttrsResult>; withConfig: (config: StyledOptions) => Styled; } export default function constructWithOptions, OuterProps extends object = Target extends KnownTarget ? React.ComponentPropsWithRef : object, OuterStatics extends object = object>(componentConstructor: IStyledComponentFactory, tag: Target, options?: StyledOptions): Styled; export {};