diff --git a/jest.config.js b/jest.config.js index 76f17402b..79e91a255 100644 --- a/jest.config.js +++ b/jest.config.js @@ -2,10 +2,7 @@ export default { collectCoverageFrom: [ - '**/*.{ts,tsx}', - '!**/*.stor{y,ies}.tsx', // stories - '!**/components/**/*', // components - '!**/internal/**/*', // internal components + '**/*.ts', '!**/dist/**/*', // distribution files '!**/index.ts', // index files ], diff --git a/packages/react/src/components/checkbox/checkbox.tsx b/packages/react/src/components/checkbox/checkbox.tsx index da63b6f19..f2eae915b 100644 --- a/packages/react/src/components/checkbox/checkbox.tsx +++ b/packages/react/src/components/checkbox/checkbox.tsx @@ -1,6 +1,6 @@ import { c, CheckboxProps as BaseProps, classy, m } from '@onfido/castor'; import React from 'react'; -import { IndicatorContainer } from '../../internal'; +import { IndicatorContainer, splitContainerProps } from '../../internal'; import { withRef } from '../../utils'; export const Checkbox = withRef( @@ -14,21 +14,30 @@ export const Checkbox = withRef( ...restProps }: CheckboxProps, ref: CheckboxProps['ref'] - ): JSX.Element => ( - - {{ - children, - input: ( - - ), - }} - - ) + ): JSX.Element => { + const [containerProps, inputProps] = splitContainerProps(restProps); + + return ( + + {{ + children, + input: ( + + ), + }} + + ); + } ); Checkbox.displayName = 'Checkbox'; diff --git a/packages/react/src/components/radio/radio.tsx b/packages/react/src/components/radio/radio.tsx index 3bde032d9..1ee7194d7 100644 --- a/packages/react/src/components/radio/radio.tsx +++ b/packages/react/src/components/radio/radio.tsx @@ -1,27 +1,36 @@ import { c, classy, m, RadioProps as BaseProps } from '@onfido/castor'; import React from 'react'; -import { IndicatorContainer } from '../../internal'; +import { IndicatorContainer, splitContainerProps } from '../../internal'; import { withRef } from '../../utils'; export const Radio = withRef( ( { bordered, invalid, children, className, style, ...restProps }: RadioProps, ref: RadioProps['ref'] - ): JSX.Element => ( - - {{ - children, - input: ( - - ), - }} - - ) + ): JSX.Element => { + const [containerProps, inputProps] = splitContainerProps(restProps); + + return ( + + {{ + children, + input: ( + + ), + }} + + ); + } ); Radio.displayName = 'Radio'; diff --git a/packages/react/src/internal/indicator-container/indicator-container.tsx b/packages/react/src/internal/indicator-container/indicator-container.tsx index 6017bc40f..98df6dfcb 100644 --- a/packages/react/src/internal/indicator-container/indicator-container.tsx +++ b/packages/react/src/internal/indicator-container/indicator-container.tsx @@ -2,6 +2,8 @@ import { c, classy, m } from '@onfido/castor'; import { IndicatorContainerProps as BaseProps } from '@onfido/castor/src/internal'; import React from 'react'; +export * from './splitContainerProps'; + /** * Container for `Checkbox` and `Radio` input components, adding custom * indicator within