import { PropCombination , PropDeclaration , Props , PropsDeclaration } from './propTypes' ; export const permutateProps = ( allProps , filter ? , remainingProps = Object . keys ( allProps ) , values = { } ) : PropCombination [ ] => { const prop = remainingProps [ 0 ] ; if ( ! prop ) { const props = { } ; Object . keys ( values ) . forEach ( prop => { props [ prop ] = values ?. [ prop ] ?. value ; } ) ; if ( filter && ! filter ( props ) ) { return [ ] ; } const label = Object . keys ( values ) . map ( prop => values ?. [ prop ] ?. label ) . join ( ' ' ) ; return [ { label , props , } , ] ; } const possiblePropValues = allProps [ prop ] ; const permutations = possiblePropValues ?. map ( ( value ) => { const newValues = { ... values } ; newValues [ prop ] = value ; return permutateProps ( allProps , filter , remainingProps ! . slice ( 1 , remainingProps ! . length ) , newValues ) ; } ) ; return ( permutations as any ) . flat ( ) ; } ;