File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import unionpay from './unionpay.js';
77import mastercard from './mastercard.js' ;
88import placeholder from './placeholder.js' ;
99import visa from './visa.js' ;
10+ import { CardType } from '../utils/validation.js' ;
1011
1112export default {
1213 amex,
@@ -18,4 +19,4 @@ export default {
1819 mastercard,
1920 placeholder,
2021 visa,
21- } ;
22+ } as { [ key in CardType ] : React . ReactNode | JSX . Element } ;
Original file line number Diff line number Diff line change @@ -5,19 +5,19 @@ interface UseCardBrandProps {
55 images ?: {
66 [ key : string ] : React . ReactNode | JSX . Element ;
77 } ;
8- cardNumber ?: string ;
8+ type ?: string ;
99 ariaLabel ?: string ;
1010}
1111
1212export default function useCardBrand ( ) {
1313 const getSvgProps = React . useCallback ( ( props : UseCardBrandProps = { } ) => {
1414 const images = props . images ?? { } ;
15- const type = 'placeholder' ;
15+ const type = props . type ?? 'placeholder' ;
1616
1717 return React . useMemo (
1818 ( ) => ( {
1919 'aria-label' : props . ariaLabel ?? 'Placeholder card' ,
20- children : images [ type ] || images ,
20+ children : images [ type ] || null ,
2121 width : '1.5em' ,
2222 height : '1em' ,
2323 viewBox : '0 0 24 16' ,
Original file line number Diff line number Diff line change 1- enum CardType {
1+ export enum CardType {
22 Amex = 'amex' ,
33 Diners = 'dinersclub' ,
44 Discover = 'discover' ,
You can’t perform that action at this time.
0 commit comments