react-card-brand
Version:
> A zero-dependency React Hook to show and get the brand from a card type.
24 lines (23 loc) • 748 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const React = require("react");
const validation_1 = require("./utils/validation");
function useCardBrand() {
const getSvgProps = React.useCallback((props = {}) => {
const images = props.images ?? {};
const type = props.type ?? 'unknown';
return React.useMemo(() => ({
'aria-label': props.ariaLabel ?? 'Unknown card',
children: images[type] || null,
width: '1.5em',
height: '1em',
viewBox: '0 0 24 16',
...props,
}), [props]);
}, []);
return {
getSvgProps,
getCardBrand: validation_1.getCardBrand,
};
}
exports.default = useCardBrand;