/* eslint-disable @typescript-eslint/explicit-module-boundary-types */ /* eslint-disable @typescript-eslint/ban-types */ /* eslint-disable @typescript-eslint/no-explicit-any */ import styled, { AnyStyledComponent, StyledComponent, StyledComponentInnerComponent, StyledComponentInnerOtherProps, StyledComponentInnerAttrs, DefaultTheme, } from 'styled-components' import shouldForwardProp from '@styled-system/should-forward-prop' import { compose, space, color, typography, layout, flexbox, grid, background, border, position, shadow, } from 'styled-system' import { StyledSystemProps } from './types' import React from 'react' type MergePropsWithSS = Omit & StyledSystemProps function withStyledSystem< C extends AnyStyledComponent, T extends object = DefaultTheme, O extends object = {}, A extends keyof any = never >( Component: C ): StyledComponent< StyledComponentInnerComponent, T, MergePropsWithSS>, A | StyledComponentInnerAttrs > function withStyledSystem< C extends keyof JSX.IntrinsicElements | React.ComponentType, T extends object = DefaultTheme, O extends object = {}, A extends keyof any = never >(Component: C): StyledComponent, A> function withStyledSystem(Component: any) { return styled(Component).withConfig<{}>({ shouldForwardProp, })( compose( space, color, typography, layout, flexbox, grid, background, border, position, shadow ) ) } export default withStyledSystem