Skip to content

Commit 8c4267d

Browse files
committed
fix: fixed missing type for set image
1 parent 8427d82 commit 8c4267d

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/images/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import unionpay from './unionpay.js';
77
import mastercard from './mastercard.js';
88
import placeholder from './placeholder.js';
99
import visa from './visa.js';
10+
import { CardType } from '../utils/validation.js';
1011

1112
export 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 };

src/useCardBrand.ts

+3-3
Original file line numberDiff line numberDiff 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

1212
export 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',

src/utils/validation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum CardType {
1+
export enum CardType {
22
Amex = 'amex',
33
Diners = 'dinersclub',
44
Discover = 'discover',

0 commit comments

Comments
 (0)